C++ mpi module for stochmagnet_main Package
EXPR_ElementaryGeometryNode.h
1 #ifndef EXPR_ElementaryGeometryNode_H
2 #define EXPR_ElementaryGeometryNode_H
3 
4 #include "EXPR_LeafNode.h"
5 
6 #include <vector>
7 
8 
21 
22 
23 private:
24  //attributes
25  tString mName;
26 
27 
28 private:
29  //associations
30 protected:
31  //builders
32 
36  }
37  //deleters
41  }
42 
43 public:
44 
48  virtual CORE_UniquePointer<EXPR_ElementaryGeometryNode> newInstance() const=0;
49 
50  //MEMORY
51  //======
59  virtual tMemSize getMemorySize() const override {
60  return sizeof(*this)+getContentsMemorySize();
61  }
62 
71  virtual tMemSize getContentsMemorySize() const override {
73  mem+=sizeof(tUChar)*mName.length();
74  return mem;
75  }
76 
80  virtual void copy(const EXPR_Node& node) override {
81  EXPR_LeafNode::copy(node);
82  const EXPR_ElementaryGeometryNode *geo=dynamic_cast<const EXPR_ElementaryGeometryNode*>(&node);
83  if (geo!=null) setName(geo->getName());
84  }
85 protected:
89  inline void setName(const tString& name) {
90  mName=name;
91  }
92 public:
96  inline const tString& getName() const {
97  return mName;
98  }
99 
103  virtual void setArguments(const std::vector<tString>& args)=0;
104 
105 
110  virtual tBoolean isInside(std::array<tReal,3> P) const override {
111  //test if the point p is in the box
112  if (!isInsideBoundingBox(P)) {
113 
114  return false;
115  }
116  applyInverse(P);
117  return isInsideCanonicalGeometry(P);
118  }
119 
120 
123  inline void computeBoundingBox() {
124  std::array<tReal,3>& P=getBoundingBoxMinPoint();
125  std::array<tReal,3>& Q=getBoundingBoxMaxPoint();
128  }
129 
134  virtual void computeBoundingBox(std::map<tString,tBoolean>& alreadyComputed) override {
135  if (alreadyComputed.find(getIdentityString())==alreadyComputed.end()) {
137  alreadyComputed[getIdentityString()]=true;
138  }
139  }
140 
145  virtual void adimensionize(const tReal& L,std::map<tString,tBoolean>& alreadyComputed) override {
146  if (alreadyComputed.find(getIdentityString())==alreadyComputed.end()) {
147  adimensionize(L);
148  EXPR_ChildNode::adimensionize(L,alreadyComputed);
149 
150  }
151  }
152 
153 
157  virtual void adimensionize(const tReal& L)=0;
158 
159 
160 protected:
165  virtual tBoolean isInsideCanonicalGeometry(const std::array<tReal,3>& P) const=0;
166 
172  virtual void computeCanonicalBoundingBox(std::array<tReal,3>& minPoint,
173  std::array<tReal,3>& maxPoint) const=0;
174 public:
175 
188  inline static void GetSphericalCoordinates(const std::array<tReal,3>& M,
189  const std::array<tReal,3>& C,
190  tReal& r,
191  tReal& theta,
192  tReal& phi) {
193  const tReal *Mk=M.data();
194  const tReal *Ck=C.data();
195  //(r,theta,phi)=CM
196  tReal x=(*Mk)-(*Ck);Mk++;Ck++;
197  tReal y=(*Mk)-(*Ck);Mk++;Ck++;
198  tReal z=(*Mk)-(*Ck);
199 
200  //r=|CM|
201  r=sqrt(x*x+y*y+z*z);
202  //theta=acos(z/r)
203  theta=acos(z/r);
204  //phi=atan(y/x)
205  phi=atan2(y,x);
206 
207  }
208 
209 
210 public:
214  virtual tString toString() const override {
215  std::stringstream sout;
216  sout<<EXPR_LeafNode::toString()<<"\n";
217  sout<<"name:"<<mName<<"\n";
218  return sout.str();
219 
220  }
221 };
222 
223 
224 
225 
226 
227 #endif
228 
229 
tString getIdentityString() const
retrun the string identification of the class
Definition: CORE_Object.h:321
This class describes an elementary geometry.
Definition: EXPR_ElementaryGeometryNode.h:20
virtual void adimensionize(const tReal &L)=0
adimensionize the primary geometry
virtual tBoolean isInside(std::array< tReal, 3 > P) const override
return true if the point is in the node
Definition: EXPR_ElementaryGeometryNode.h:110
virtual void computeCanonicalBoundingBox(std::array< tReal, 3 > &minPoint, std::array< tReal, 3 > &maxPoint) const =0
compute the bounding box of the node
void computeBoundingBox()
compute the bounding box of the geometry taking into account the transformation of node
Definition: EXPR_ElementaryGeometryNode.h:123
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: EXPR_ElementaryGeometryNode.h:59
virtual void setArguments(const std::vector< tString > &args)=0
set the argument to define the geometry
virtual CORE_UniquePointer< EXPR_ElementaryGeometryNode > newInstance() const =0
create a new instance of this
void setName(const tString &name)
set name
Definition: EXPR_ElementaryGeometryNode.h:89
virtual void adimensionize(const tReal &L, std::map< tString, tBoolean > &alreadyComputed) override
adimensionize the node
Definition: EXPR_ElementaryGeometryNode.h:145
const tString & getName() const
get name
Definition: EXPR_ElementaryGeometryNode.h:96
static void GetSphericalCoordinates(const std::array< tReal, 3 > &M, const std::array< tReal, 3 > &C, tReal &r, tReal &theta, tReal &phi)
get the spherical coordinate of the point M with center C, radius r, inclination theta and azimuth ph...
Definition: EXPR_ElementaryGeometryNode.h:188
EXPR_ElementaryGeometryNode()
create the class
Definition: EXPR_ElementaryGeometryNode.h:35
virtual tString toString() const override
return the string representation of this
Definition: EXPR_ElementaryGeometryNode.h:214
virtual tBoolean isInsideCanonicalGeometry(const std::array< tReal, 3 > &P) const =0
return true if the point is in the node
virtual ~EXPR_ElementaryGeometryNode()
delete the class
Definition: EXPR_ElementaryGeometryNode.h:40
virtual void copy(const EXPR_Node &node) override
copy
Definition: EXPR_ElementaryGeometryNode.h:80
virtual tMemSize getContentsMemorySize() const override
return nthe memory size of the included associations
Definition: EXPR_ElementaryGeometryNode.h:71
virtual void computeBoundingBox(std::map< tString, tBoolean > &alreadyComputed) override
compute the bounding box of the node
Definition: EXPR_ElementaryGeometryNode.h:134
This class describes a leaf node of the tree without children.
Definition: EXPR_LeafNode.h:15
virtual tMemSize getContentsMemorySize() const override
return nthe memory size of the included associations
Definition: EXPR_LeafNode.h:62
This class is a base class of the binary tree.
Definition: EXPR_Node.h:16
virtual void adimensionize(const tReal &L, std::map< tString, tBoolean > &alreadyComputed)
adimensionize the node
Definition: EXPR_Node.cpp:135
const std::array< tReal, 3 > & getBoundingBoxMinPoint() const
get the min point bounding box of the node for reading
Definition: EXPR_Node.h:652
void linearTransformBoundingBox(std::array< tReal, 3 > &P, std::array< tReal, 3 > &Q) const
compute the bounding box after transformation
Definition: EXPR_Node.cpp:44
tBoolean isInsideBoundingBox(const std::array< tReal, 3 > &P) const
return true if the point P is in the bounding box
Definition: EXPR_Node.h:694
virtual tString toString() const override
return the string representation of this
Definition: EXPR_Node.cpp:145
const std::array< tReal, 3 > & getBoundingBoxMaxPoint() const
get the max point bounding box of the node for reading
Definition: EXPR_Node.h:658
void applyInverse(std::array< tReal, 3 > &P) const
apply the inverse transformation to point P
Definition: EXPR_Node.h:550
virtual void copy(const EXPR_Node &node)
copy
Definition: EXPR_Node.h:93