MURE
Loading...
Searching...
No Matches
Shape.hxx
Go to the documentation of this file.
1/*
2 This file is part of MURE,
3 Copyright (C) 2007-2021 MURE developers.
4
5 MURE is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 MURE is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with MURE. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef _Shape_HXX_
20#define _Shape_HXX_
21
27#include <iostream>
28#include <fstream>
29#include <vector>
30#include <string>
31#include <algorithm>
32
33#include "TReference.hxx"
34#include "MureConstant.hxx"
35#include "SurfaceCard.hxx"
36
37class SurfaceCard;
38
39using namespace std;
40
41class Shape;
42class MathNode;
43
54typedef Reference_ptr < Shape > Shape_ptr;
55
57
84class Shape : public TReference
85{
86 public :
91 Shape();
92 Shape(const Shape &s);
93 ~Shape() override;
94 virtual Shape_ptr Clone(int count = 0) = 0;
96
101 Shape_ptr Not();
102 virtual void CalculNot() {}
103 void NewNot()
104 {
105 if(fNot) CalculNot();
106 }
107 void SetClone(Shape_ptr clone)
108 {
109 fCloneShape = clone;
110 }
111 void SetClone2Not();
113
119 {
120 return fSign;
121 }
122 void SetSign(int s)
123 {
124 fSign = s;
125 }
127
132 void SetOutermostShape(bool flag = true)
133 {
134 fOutermostShape = flag;
135 }
136
138
143 virtual unsigned IsBrick()
144 {
145 return 0;
146 }
147 virtual unsigned IsCylinder()
148 {
149 return 0;
150 }
151 virtual unsigned IsFullVoid()
152 {
153 return 0;
154 }
155 virtual unsigned IsHexagon()
156 {
157 return 0;
158 }
159 virtual unsigned IsNode()
160 {
161 return 0;
162 }
163 virtual unsigned IsPlane()
164 {
165 return 0;
166 }
167 virtual unsigned IsSphere()
168 {
169 return 0;
170 }
171 virtual unsigned IsTube()
172 {
173 return 0;
174 }
175 virtual unsigned IsFull()
176 {
177 return 0;
178 }
179 virtual unsigned IsVoid()
180 {
181 return 0;
182 }
183 virtual unsigned IsZTorus()
184 {
185 return 0;
186 }
188 {
189 return fInfinite;
190 }
191
197
200 virtual double GetVolume()
201 {
202 return fVolume;
203 }
204 void SetVolume(double V)
205 {
206 fVolume = V;
207 }
208
210
213 virtual double GetArea()
214 {
215 return fArea;
216 }
217 void SetArea(double S)
218 {
219 fArea = S;
220 }
221
222 virtual void SetMirrorBoundary(bool state = true);
224 {
225 fOpenZPlanes = true;
226 }
228 {
229 return fOpenZPlanes;
230 }
231 virtual void SetSidePlanesOpen()
232 {
233 fOpenXYPlanes = true;
234 }
235 virtual bool IsSidePlanesOpen()
236 {
237 return fOpenXYPlanes;
238 }
239 virtual void SetWhiteBoundary(bool state = true)
240 {
241 fWhiteBoundary = state;
242 }
243
245
253 virtual void SetPeriodicBoundary(bool state = true, string TopBottPlaneBC = "mirror") {};
254 virtual bool IsMirrorBoundary()
255 {
256 return fMirrorBoundary;
257 }
258 virtual bool IsWhiteBoundary()
259 {
260 return fWhiteBoundary;
261 }
262 virtual bool IsPeriodicBoundary()
263 {
264 return fPeriodicBoundary;
265 }
267
272
274
281 virtual void Rotate(double phi, double theta = 0, double psi = 0, double *center = nullptr, int count = 0) = 0;
283
289 virtual void Translate(double dx, double dy, double dz, int count = 0) = 0;
290
292 virtual unsigned Add(Shape_ptr OtherShape)
293 {
294 return 0;
295 }
296 virtual void ReplaceLeaf(int i, Shape_ptr OtherShape) {}
298
299
305
309 virtual unsigned IsIncluded(Shape_ptr OtherShape) = 0;
310
312
315 virtual unsigned IsDisjoint(Shape_ptr OtherShape) = 0;
317
318
324
328 unsigned AddInsideShape(Shape_ptr OtherShape);
329
331
336 {
337 fOriginalInsideShape.push_back(OtherShape);
338 return 1;
339 }
341 {
342 fOriginalInsideShape.clear();
343 }
345 {
346 fInsideShape.clear();
347 }
349 {
350 return fInsideShape.size();
351 }
353 {
354 return fOriginalInsideShape.size();
355 }
357 {
358 fInsideShape[i] = S;
359 }
361 {
362 fOriginalInsideShape[i] = S;
363 }
365 {
366 return fInsideShape[i];
367 }
369 {
370 return fOriginalInsideShape[i];
371 }
373
378
379 virtual void Copy(Shape_ptr S) {}
380 virtual Shape_ptr GetLeaf(int i)
381 {
382 Shape_ptr t(nullptr);
383 return t;
384 }
385 virtual int GetNumberOfLeaves()
386 {
387 return 0;
388 }
389 string GetShapeName();
390 virtual int NumberOfShapes()
391 {
392 return 1;
393 }
394
395 void SetDebugName(string str)
396 {
397 fDebugName = str;
398 }
400 {
401 return fDebugName;
402 }
403
405
409 virtual void SetUniverse(int u = - 1);
410 virtual void SetFill(int f)
411 {
412 fFill = f;
413 }
415 {
416 return fFill;
417 }
419 {
420 return fUniverse;
421 }
422
423 void IncrementSurface(double S)
424 {
425 fArea += S;
426 }
427
428 virtual double GetVirtualSphereRadius()
429 {
430 return fVirtualSphereR;
431 }
432 virtual double *GetVirtualSphereCenter()
433 {
434 return fVirtualSphereO;
435 }
436
437 virtual void RemoveSurface();
438
439 virtual string Print()
440 {
441 return "Oups! Print function of shape should not be called";
442 }
443 virtual void PrintX(int count = 0);
444 virtual void PrintY(int count = 0);
445
446#ifdef _PTODEBUG_
447 virtual void PrintLatex(int count = 0);
448 static void AddLatexLine(char *txt)
449 {
450 BeginLatex();
451 DEBUGFILE << txt << "\\\\ " << endl;
452 }
453 static void BeginLatex();
454 static void EndLatex();
455#endif
456
458
462 virtual bool PointInShape(double *P, int border)
463 {
464 return false;
465 }
466
467 virtual void SetLinkedPlane(Shape_ptr P)
468 {
469 fLinkedPlane = P;
470 }
471 virtual void ReplaceNode(Shape_ptr C) {}
472
474 {
475 return nullptr;
476 }
478 {
479 return nullptr;
480 }
483
487 virtual void Simplify(bool violent = false) {}
489
493 virtual void SetMouvement(bool state = true)
494 {
495 fMouvement = state;
496 }
497 virtual void UnSetMouvement();
499 {
500 return fMouvement;
501 }
503
506 virtual void DevElague(int count = 0, bool violent = false) {}
507 void SetViolentSimplify(bool Allowed = true);
508 void SetFreezeSimplify(bool flag = true){fFreezeSimplify = flag;}
510 {
512 }
513 virtual int GetMonoSurfaceType()
514 {
515 return 0;
516 }
518 {
519 if(IsBrick() || IsHexagon()) fInfinite = true;
520 }
522
523
524 protected :
525
526 virtual void MinimumCopy(Shape *S);
527
529
532 void SetNot(Shape *aNot)
533 {
534 if(fNot) fNot -> fNot = nullptr;
535 fNot = aNot;
536 fNot -> fNot = this;
537 }
539 {
540 fNot -> SetNot(this);
541 }
542
543 virtual Shape *CreateNewInstance(int sign = 1) = 0;
544
545 vector < Shape_ptr > fInsideShape;
546 vector < Shape_ptr > fOriginalInsideShape;
547
548 int fSign;
553 int fFill;
554 double fVolume;
555 double fArea;
556 string fShapeName;
557 string fDebugName;
571
572 //_________________________________________________________________________________________________
573 // Related Friend Functions
574 //_________________________________________________________________________________________________
575
577
602 friend Shape_ptr &operator>> (Shape_ptr &B, Shape_ptr &A );
603};
604//_________________________________________________________________________________________________
605// Related Functions
606//_________________________________________________________________________________________________
617
619
620
621#endif
#define sign(a)
Definition GenericReactorAssembly.cxx:43
Shape_ptr & operator&=(Shape_ptr &A, Shape_ptr B)
Definition Shape.cxx:302
Shape_ptr & operator|=(Shape_ptr &A, Shape_ptr B)
Definition Shape.cxx:309
Shape_ptr operator!(Shape_ptr A)
!A is an other way to obtain A->Not().
Definition Shape.cxx:437
Reference_ptr< Shape > Shape_ptr
Definition Shape.hxx:54
Header file for SurfaceCard class.
Header file for TReference class and Reference_ptr template.
MathNode allows to construct Union or Intersection of Shape.
Definition MathNode.hxx:50
Abstract class to define geometrical shapes.
Definition Shape.hxx:85
virtual void CalculNot()
Allocates and calculs the complement of a Shape.
Definition Shape.hxx:102
void SetNotofNot()
Definition Shape.hxx:538
virtual unsigned IsCylinder()
Definition Shape.hxx:147
string fShapeName
Name of a Shape.
Definition Shape.hxx:556
string GetDebugName()
Definition Shape.hxx:399
int GetSign()
Definition Shape.hxx:118
virtual Shape_ptr GetLeaf(int i)
Definition Shape.hxx:380
virtual unsigned IsSphere()
Definition Shape.hxx:167
virtual unsigned IsFullVoid()
Definition Shape.hxx:151
bool fMouvement
Flag that indicate a Shape is in mouvement (translation, ..) in a tree.
Definition Shape.hxx:551
void NewNot()
Definition Shape.hxx:103
string fTopBottPlaneBoundaryCondition
whether the top(bottom) plane of a periodic boundary Shape is white or mirror
Definition Shape.hxx:566
virtual bool IsSidePlanesOpen()
Definition Shape.hxx:235
virtual void SetSidePlanesOpen()
Definition Shape.hxx:231
virtual unsigned IsZTorus()
Definition Shape.hxx:183
unsigned GetOriginalInsideShapeSize()
Definition Shape.hxx:352
~Shape() override
Normal destructor.
Definition Shape.cxx:94
virtual unsigned IsBrick()
Definition Shape.hxx:143
virtual void SetPeriodicBoundary(bool state=true, string TopBottPlaneBC="mirror")
Periodic boundary (WARNING: only for Brick and Hexagon).
Definition Shape.hxx:253
vector< Shape_ptr > fInsideShape
a vector to remember which Shapes are inside the current one.Clear at each ">>"
Definition Shape.hxx:545
void SetNot(Shape *aNot)
Allocates and calculs the complement of Shape.
Definition Shape.hxx:532
bool fMirrorBoundary
whether or not mirror a particle on the surface
Definition Shape.hxx:561
virtual int GetNumberOfLeaves()
Definition Shape.hxx:385
virtual bool IsWhiteBoundary()
Definition Shape.hxx:258
virtual Shape * CreateNewInstance(int sign=1)=0
Create a new Shape instance.
virtual Shape_ptr Clone(int count=0)=0
Clone a Shape.
int fFill
Universe number that fill the Shape.
Definition Shape.hxx:553
string GetShapeName()
returns the Shape name
Definition Shape.cxx:227
virtual bool IsMirrorBoundary()
Definition Shape.hxx:254
virtual unsigned IsFull()
Definition Shape.hxx:175
bool fOpenZPlanes
whether the top/bottom planes are not mirrors (default=false)
Definition Shape.hxx:562
int GetUniverse()
Definition Shape.hxx:418
double fVolume
the Volume of a Shape;
Definition Shape.hxx:554
virtual string Print()
Definition Shape.hxx:439
virtual unsigned Add(Shape_ptr OtherShape)
Add a new Shape (in fact a Shape_ptr) to a Node.
Definition Shape.hxx:292
unsigned GetInsideShapeSize()
Definition Shape.hxx:348
virtual void SetMirrorBoundary(bool state=true)
mirror a particle on the surface
Definition Shape.cxx:274
unsigned AddOriginalInsideShape(Shape_ptr OtherShape)
This method is called by Shape::AddInsideShape.
Definition Shape.hxx:335
virtual void SetUniverse(int u=- 1)
Set the Universe number for a Shape .
Definition Shape.cxx:145
virtual void ResetIsDefinedSurfaceCalled()
Definition Shape.hxx:481
virtual bool PointInShape(double *P, int border)
true if the point P is in the Shape.
Definition Shape.hxx:462
virtual void DevElague(int count=0, bool violent=false)
Developps and Trims a tree of Node.
Definition Shape.hxx:506
void SetInsideShape(int i, Shape_ptr S)
Definition Shape.hxx:356
friend Shape_ptr operator|(Shape_ptr A, Shape_ptr B)
Definition Shape.cxx:316
virtual void Rotate(double phi, double theta=0, double psi=0, double *center=nullptr, int count=0)=0
Rotate the Shape clockwise.
virtual unsigned IsIncluded(Shape_ptr OtherShape)=0
return 1 if a shape is included in OtherShape.
virtual void SetWhiteBoundary(bool state=true)
Definition Shape.hxx:239
unsigned AddInsideShape(Shape_ptr OtherShape)
Add a Shape in fInsideShape each time a "put in" is done.
Definition Shape.cxx:219
virtual void Translate(double dx, double dy, double dz, int count=0)=0
Translate the Shape of (dx, dy, dz).
void SetArea(double S)
Definition Shape.hxx:217
virtual void SetTopBottomPlanesOpen()
Definition Shape.hxx:223
bool fOpenXYPlanes
whether the side planes are not mirrors (default=false)
Definition Shape.hxx:563
virtual void RemoveSurface()
Definition Shape.cxx:238
virtual void ReplaceLeaf(int i, Shape_ptr OtherShape)
Definition Shape.hxx:296
virtual unsigned IsPlane()
Definition Shape.hxx:163
friend Shape_ptr & operator>>(Shape_ptr &B, Shape_ptr &A)
Definition Shape.cxx:332
void SetOriginalInsideShape(int i, Shape_ptr S)
Definition Shape.hxx:360
void SetClone2Not()
Set the CloneShape to a Not.
Definition Shape.cxx:135
virtual void SetMouvement(bool state=true)
Definition Shape.hxx:493
int fUniverse
Universe number (for lattice filling)
Definition Shape.hxx:552
int GetFill()
Definition Shape.hxx:414
virtual SurfaceCard * GetSurfaceCard()
Definition Shape.hxx:473
virtual double GetVolume()
Get the Volume of a Shape.
Definition Shape.hxx:200
vector< Shape_ptr > fOriginalInsideShape
a vector to remember which Shapes are inside the current one.
Definition Shape.hxx:546
virtual unsigned IsHexagon()
Definition Shape.hxx:155
virtual void PrintX(int count=0)
Debug method: Print the shape surface when fMouvement=true.
Definition Shape.cxx:154
int fSign
Define whether the interior (-1) or the exterior (+1) of the Shape is considered.
Definition Shape.hxx:548
virtual bool IsPeriodicBoundary()
Definition Shape.hxx:262
bool fFreezeSimplify
disable any Node simplification (for serpent in ReactorAssembly)
Definition Shape.hxx:570
double fVirtualSphereR
the radius of a Sphere containing the Shape
Definition Shape.hxx:558
bool fOutermostShape
whether or not this Shape is the limit to the exterior world (for calculating particle losses).
Definition Shape.hxx:569
virtual void SetLinkedPlane(Shape_ptr P)
Definition Shape.hxx:467
Shape * fNot
pointer on complementary Shape if exists, else 0.
Definition Shape.hxx:550
Shape()
Default constructor. The interior of a Shape is built.
Definition Shape.cxx:35
virtual void MinimumCopy(Shape *S)
Copy all attributs of a Shape S (but not attributs of the father classes).
Definition Shape.cxx:244
double fArea
the area of a Shape;
Definition Shape.hxx:555
virtual int NumberOfShapes()
Definition Shape.hxx:390
void SetClone(Shape_ptr clone)
Definition Shape.hxx:107
Shape_ptr fCloneShape
the clone of a Shape
Definition Shape.hxx:560
bool fIsViolentSimplifyAllowed
whether or not a "violent simplification is allowed (ie a Node or a Brick are allowed to be separated...
Definition Shape.hxx:568
virtual unsigned IsDisjoint(Shape_ptr OtherShape)=0
return 1 if a shape is disjoint of OtherShape.
string fDebugName
Debug Name of a Shape.
Definition Shape.hxx:557
Shape_ptr Not()
Return the complementary Shape (i.e. the other side)
Definition Shape.cxx:106
virtual unsigned IsNode()
Definition Shape.hxx:159
virtual void SetFill(int f)
Definition Shape.hxx:410
virtual void ReplaceNode(Shape_ptr C)
Replace a Node by an other (C must be a Node)
Definition Shape.hxx:471
virtual void Copy(Shape_ptr S)
Copy all attributs of a Shape S (but not attributs of the father classes).
Definition Shape.hxx:379
void IncrementSurface(double S)
Definition Shape.hxx:423
virtual bool IsTopBottomPlanesOpen()
Definition Shape.hxx:227
double * fVirtualSphereO
the center of a Sphere containing the Shape
Definition Shape.hxx:559
virtual unsigned IsTube()
Definition Shape.hxx:171
virtual SurfaceCard * GetSurfaceCard(int i)
Definition Shape.hxx:477
virtual void PrintY(int count=0)
Debug method: Print the shape surfaces, InsideShape, ...
Definition Shape.cxx:176
Shape_ptr fLinkedPlane
the Plane linked to an this for periodic boundary
Definition Shape.hxx:567
void SetFreezeSimplify(bool flag=true)
Enable/disable simplification a certain nodes to avoid "union" (for Serpent outside)
Definition Shape.hxx:508
virtual void UnSetMouvement()
Set the fMouvement flag to false;.
Definition Shape.cxx:167
void ClearOriginalInsideShape()
Definition Shape.hxx:340
virtual double * GetVirtualSphereCenter()
Definition Shape.hxx:432
void SetOutermostShape(bool flag=true)
Say that this Shape is the most outer one.
Definition Shape.hxx:132
friend Shape_ptr operator&(Shape_ptr A, Shape_ptr B)
Intersection of A and B.
Definition Shape.cxx:286
void SetInfinite()
Definition Shape.hxx:517
virtual unsigned IsVoid()
Definition Shape.hxx:179
bool GetMouvement()
Definition Shape.hxx:498
bool IsViolentSimplifyAllowed()
Definition Shape.hxx:509
bool fInfinite
Determines whether the shape is infinite or not.
Definition Shape.hxx:549
bool fPeriodicBoundary
whether or not Periodic boundary are applied (only for plane)
Definition Shape.hxx:565
Shape_ptr GetInsideShape(int i)
Definition Shape.hxx:364
void SetDebugName(string str)
Definition Shape.hxx:395
virtual int GetMonoSurfaceType()
Definition Shape.hxx:513
bool IsInfinite()
Definition Shape.hxx:187
Shape_ptr GetOriginalInsideShape(int i)
Definition Shape.hxx:368
void SetVolume(double V)
Definition Shape.hxx:204
bool fWhiteBoundary
whether or not mirror a particle on the surface with a cosine distribution
Definition Shape.hxx:564
void SetSign(int s)
Definition Shape.hxx:122
void SetViolentSimplify(bool Allowed=true)
Enable/disable violent simplification a certain shapes to avoid "union" (for Serpent outside)
Definition Shape.cxx:266
virtual double GetArea()
Get the Area of a Shape.
Definition Shape.hxx:213
virtual double GetVirtualSphereRadius()
Definition Shape.hxx:428
void ClearInsideShape()
Definition Shape.hxx:344
virtual void Simplify(bool violent=false)
Simplify a tree of Node.
Definition Shape.hxx:487
SurfaceCard class is used to define geometrical math surface for MC output format.
Definition SurfaceCard.hxx:42
Base class to reference all Shape objects and some nucleus.
Definition TReference.hxx:38
the namespace of the Standard C++

MURE Project, documentation generated by Doxygen 1.9.7 - Fri Jan 19 2024