C++ mpi module for stochmagnet_main Package
EXPR_Paver.h
1 #ifndef EXPR_Paver_H
2 #define EXPR_Paver_H
3 
4 #include "EXPR_ElementaryGeometryNode.h"
5 
6 
18 
19 private:
20 
21 
22  std::array<tReal,3> mMinPoint;
23  std::array<tReal,3> mMaxPoint;
24 
25 private:
26  //associations
27 protected:
28  //builders
29 
33  setName("PAVER");
34  for(auto& Pk:mMinPoint) Pk=0;
35  for(auto& Pk:mMaxPoint) Pk=1;
36 
37  }
38  //deleters
41  virtual ~EXPR_Paver() {
42  }
43 
44 public:
45  //MEMORY
46  //======
54  virtual tMemSize getMemorySize() const override {
55  return sizeof(*this)+getContentsMemorySize();
56  }
57 
66  virtual tMemSize getContentsMemorySize() const override {
68  mem+=mMinPoint.size()*sizeof(tReal);
69  mem+=mMaxPoint.size()*sizeof(tReal);
70  return mem;
71  }
72 
73 public:
77  virtual CORE_UniquePointer<EXPR_ElementaryGeometryNode> newInstance() const override {
78  return New();
79  }
80 
84  static inline CORE_UniquePointer<EXPR_Paver> New() {
85  CORE_UniquePointer<EXPR_Paver> p(new EXPR_Paver(),
87 
88  return p;
89  }
90 
91 
92 
93 
97  virtual void copy(const EXPR_Node& node) override {
99  const EXPR_Paver *paver=dynamic_cast< const EXPR_Paver *>(&node);
100  if (paver!=null) {
101  setMinPoint(paver->getMinPoint());
102  setMaxPoint(paver->getMaxPoint());
103  }
104  }
111  virtual void setArguments(const std::vector<tString>& args) override;
112 
121  inline void setBox(const tReal& x0,const tReal& x1,
122  const tReal& y0,const tReal& y1,
123  const tReal& z0,const tReal& z1) {
124  tReal *P=mMinPoint.data(),*Q=mMaxPoint.data();
125  *P=x0;P++;
126  *P=y0;P++;
127  *P=z0;
128  *Q=x1;Q++;
129  *Q=y1;Q++;
130  *Q=z1;
131 
132  }
136  inline void setBox(const std::array<tReal,6>& x) {
137  //iretaror on min & max points
138  tReal *iP=mMinPoint.data(),*iQ=mMaxPoint.data();
139  //iterators on x
140  const tReal *iX=x.data();
141  const tReal *eX=iX;eX+=x.size();
142 
143  while (iX!=eX) {
144  (*iP)=(*iX);iP++;iX++;
145  (*iQ)=(*iX);iQ++;iX++;
146  }
147 
148 
149  }
150 
154  inline void setMinPoint(const std::array<tReal,3>& A) {
155  memcpy(mMinPoint.data(),A.data(),A.size()*sizeof(tReal));
156  }
160  inline void setMaxPoint(const std::array<tReal,3>& A) {
161  memcpy(mMaxPoint.data(),A.data(),A.size()*sizeof(tReal));
162  }
166  inline const std::array<tReal,3>& getMinPoint() const {
167  return mMinPoint;
168  }
172  inline const std::array<tReal,3>& getMaxPoint() const {
173  return mMaxPoint;
174  }
178  inline tReal getSize(const tUSInt& k) const {
179  if (k<3) return (mMaxPoint[k]-mMinPoint[k]);
180  return 0;
181  }
185  inline void setSize(const std::array<tReal,3>& H) {
186  const tReal *iP=mMinPoint.data();
187  const tReal *iH=H.data();
188  for(auto& Qk:mMaxPoint) {
189  Qk=(*iP)+(*iH);
190  iP++;
191  iH++;
192  }
193  }
194 
198  virtual void adimensionize(const tReal& L) final;
199 
200 
201 protected:
206  virtual tBoolean isInsideCanonicalGeometry(const std::array<tReal,3>& p) const final ;
207 
212  virtual void computeCanonicalBoundingBox(std::array<tReal,3>& minPoint,
213  std::array<tReal,3>& maxPoint) const final ;
214 
215 
216 private:
220  virtual tString toString() const final;
221 };
222 
223 
224 
225 
226 
227 #endif
228 
229 
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
This class describes an elementary geometry.
Definition: EXPR_ElementaryGeometryNode.h:20
void setName(const tString &name)
set name
Definition: EXPR_ElementaryGeometryNode.h:89
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
This class is a base class of the binary tree.
Definition: EXPR_Node.h:16
This class describes a right paver define by a min & max points PAVER[X0,X1,Y0,Y1,...
Definition: EXPR_Paver.h:17
void setMaxPoint(const std::array< tReal, 3 > &A)
set the max point
Definition: EXPR_Paver.h:160
void setBox(const std::array< tReal, 6 > &x)
set the paver
Definition: EXPR_Paver.h:136
tReal getSize(const tUSInt &k) const
get the size in the direction
Definition: EXPR_Paver.h:178
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: EXPR_Paver.h:54
virtual tBoolean isInsideCanonicalGeometry(const std::array< tReal, 3 > &p) const final
return true if the point is inside the canonical geometry
Definition: EXPR_Paver.cpp:34
void setBox(const tReal &x0, const tReal &x1, const tReal &y0, const tReal &y1, const tReal &z0, const tReal &z1)
set the paver
Definition: EXPR_Paver.h:121
void setSize(const std::array< tReal, 3 > &H)
set the size
Definition: EXPR_Paver.h:185
virtual void computeCanonicalBoundingBox(std::array< tReal, 3 > &minPoint, std::array< tReal, 3 > &maxPoint) const final
compute the bounding box of the geometry
Definition: EXPR_Paver.cpp:48
virtual tMemSize getContentsMemorySize() const override
return nthe memory size of the included associations
Definition: EXPR_Paver.h:66
virtual ~EXPR_Paver()
delete the class
Definition: EXPR_Paver.h:41
const std::array< tReal, 3 > & getMaxPoint() const
get the max point
Definition: EXPR_Paver.h:172
EXPR_Paver()
create the class
Definition: EXPR_Paver.h:32
void setMinPoint(const std::array< tReal, 3 > &A)
set the min point
Definition: EXPR_Paver.h:154
const std::array< tReal, 3 > & getMinPoint() const
get the min point
Definition: EXPR_Paver.h:166
virtual CORE_UniquePointer< EXPR_ElementaryGeometryNode > newInstance() const override
create a new instance of this
Definition: EXPR_Paver.h:77
virtual void copy(const EXPR_Node &node) override
copy
Definition: EXPR_Paver.h:97
virtual void setArguments(const std::vector< tString > &args) override
set the argument to define the geometry
Definition: EXPR_Paver.cpp:5
static CORE_UniquePointer< EXPR_Paver > New()
crete the new instance of this
Definition: EXPR_Paver.h:84
virtual void adimensionize(const tReal &L) final
adimensionize the cylinder
Definition: EXPR_Paver.cpp:26