1 // Copyright(C) 1999-2021 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS).  Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6 
7 #include <Ioss_CoordinateFrame.h>
8 #include <Ioss_Utils.h>
9 #include <fmt/ostream.h>
10 
11 namespace Ioss {
CoordinateFrame(int64_t my_id,char my_tag,const double * point_list)12   CoordinateFrame::CoordinateFrame(int64_t my_id, char my_tag, const double *point_list)
13       : id_(my_id), tag_(my_tag)
14   {
15     pointList_.reserve(9);
16     for (int i = 0; i < 9; i++) {
17       pointList_.push_back(point_list[i]);
18     }
19   }
20 
id()21   int64_t CoordinateFrame::id() const { return id_; }
tag()22   char    CoordinateFrame::tag() const { return tag_; }
23 
coordinates()24   const double *CoordinateFrame::coordinates() const { return &pointList_[0]; }
origin()25   const double *CoordinateFrame::origin() const { return &pointList_[0]; }
axis_3_point()26   const double *CoordinateFrame::axis_3_point() const { return &pointList_[3]; }
plane_1_3_point()27   const double *CoordinateFrame::plane_1_3_point() const { return &pointList_[6]; }
28 
equal_(const Ioss::CoordinateFrame & rhs,bool quiet)29   bool Ioss::CoordinateFrame::equal_(const Ioss::CoordinateFrame &rhs, bool quiet) const
30   {
31     if (this->id_ != rhs.id_) {
32       if (!quiet) {
33         fmt::print(Ioss::OUTPUT(), "CoordinateFrame : ID mismatch ({} vs. {})\n", this->id_,
34                    rhs.id_);
35       }
36       return false;
37     }
38 
39     if (this->pointList_ != rhs.pointList_) {
40       if (!quiet) {
41         fmt::print(Ioss::OUTPUT(), "CoordinateFrame : Point list mismatch ([ ");
42         for (auto &point : this->pointList_) {
43           fmt::print(Ioss::OUTPUT(), "{} ", point);
44         }
45         fmt::print(Ioss::OUTPUT(), "] vs [");
46         for (auto &point : rhs.pointList_) {
47           fmt::print(Ioss::OUTPUT(), "{} ", point);
48         }
49         fmt::print(Ioss::OUTPUT(), "])\n");
50       }
51       return false;
52     }
53 
54     if (this->id_ != rhs.id_) {
55       if (!quiet) {
56         fmt::print(Ioss::OUTPUT(), "CoordinateFrame : TAG mismatch ({} vs. {})\n", this->tag_,
57                    rhs.tag_);
58       }
59       return false;
60     }
61 
62     return true;
63   }
64   bool Ioss::CoordinateFrame::operator==(const Ioss::CoordinateFrame &rhs) const
65   {
66     return equal_(rhs, true);
67   }
68 
69   bool Ioss::CoordinateFrame::operator!=(const Ioss::CoordinateFrame &rhs) const
70   {
71     return !(*this == rhs);
72   }
73 
equal(const Ioss::CoordinateFrame & rhs)74   bool Ioss::CoordinateFrame::equal(const Ioss::CoordinateFrame &rhs) const
75   {
76     return equal_(rhs, false);
77   }
78 
79 } // namespace Ioss
80