4
/**************************************************************************/
6
/* Author: Joachim Schoeberl */
8
/**************************************************************************/
12
Constructive Solid Model (csg)
24
SolidIterator () { ; }
25
virtual ~SolidIterator () { ; }
26
virtual void Do (Solid * sol) = 0;
35
typedef enum optyp1 { TERM, TERM_REF, SECTION, UNION, SUB, ROOT, DUMMY } optyp;
46
// static int cntnames;
49
Solid (Primitive * aprim);
50
Solid (optyp aop, Solid * as1, Solid * as2 = NULL);
53
const char * Name () const { return name; }
54
void SetName (const char * aname);
56
Solid * Copy (class CSGeometry & geom) const;
57
void Transform (Transformation<3> & trans);
60
void IterateSolid (SolidIterator & it, bool only_once = 0);
63
void Boundaries (const Point<3> & p, ARRAY<int> & bounds) const;
64
int NumPrimitives () const;
65
void GetSurfaceIndices (ARRAY<int> & surfind) const;
66
void GetSurfaceIndices (IndexSet & iset) const;
68
void GetTangentialSurfaceIndices (const Point<3> & p, ARRAY<int> & surfids, double eps) const;
69
void GetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, ARRAY<int> & surfids, double eps) const;
70
void GetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, ARRAY<int> & surfids, double eps) const;
73
Primitive * GetPrimitive ()
74
{ return (op == TERM || op == TERM_REF) ? prim : NULL; }
75
const Primitive * GetPrimitive () const
76
{ return (op == TERM || op == TERM_REF) ? prim : NULL; }
78
Solid * S1() { return s1; }
79
Solid * S2() { return s2; }
83
bool IsIn (const Point<3> & p, double eps = 1e-6) const;
84
bool IsStrictIn (const Point<3> & p, double eps = 1e-6) const;
85
bool VectorIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const;
86
bool VectorStrictIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const;
88
bool VectorIn2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
90
bool VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
94
/// compute localization in point p
95
void TangentialSolid (const Point<3> & p, Solid *& tansol, ARRAY<int> & surfids, double eps) const;
97
/// compute localization in point p tangential to vector t
98
void TangentialSolid2 (const Point<3> & p, const Vec<3> & t,
99
Solid *& tansol, ARRAY<int> & surfids, double eps) const;
101
/** compute localization in point p, with second order approximation to edge
102
p + s t + s*s/2 t2 **/
103
void TangentialSolid3 (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,
104
Solid *& tansol, ARRAY<int> & surfids, double eps) const;
108
/** tangential solid, which follows the edge
110
with second order, and the neighbouring face
111
p + s t + s*s/2 t2 + r m
114
void TangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,
116
Solid *& tansol, ARRAY<int> & surfids, double eps) const;
119
void CalcOnePrimitiveSpecialPoints (const Box<3> & box, ARRAY<Point<3> > & pts) const;
122
int Edge (const Point<3> & p, const Vec<3> & v, double eps) const;
124
int OnFace (const Point<3> & p, const Vec<3> & v, double eps) const;
126
void Print (ostream & str) const;
128
void CalcSurfaceInverse ();
130
Solid * GetReducedSolid (const BoxSphere<3> & box) const;
133
void SetMaxH (double amaxh)
135
double GetMaxH () const
138
void GetSolidData (ostream & ost, int first = 1) const;
139
static Solid * CreateSolid (istream & ist, const SYMBOLTABLE<Solid*> & solids);
142
static BlockAllocator ball;
143
void * operator new(size_t /* s */)
148
void operator delete (void * p)
157
void RecBoundaries (const Point<3> & p, ARRAY<int> & bounds,
158
int & in, int & strin) const;
160
void RecTangentialSolid (const Point<3> & p, Solid *& tansol, ARRAY<int> & surfids,
161
int & in, int & strin, double eps) const;
163
void RecTangentialSolid2 (const Point<3> & p, const Vec<3> & vec,
164
Solid *& tansol, ARRAY<int> & surfids,
165
int & in, int & strin, double eps) const;
167
void RecTangentialSolid3 (const Point<3> & p, const Vec<3> & vec,const Vec<3> & vec2,
168
Solid *& tansol, ARRAY<int> & surfids,
169
int & in, int & strin, double eps) const;
171
void RecTangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,
173
Solid *& tansol, ARRAY<int> & surfids,
174
int & in, int & strin, double eps) const;
177
void RecEdge (const Point<3> & p, const Vec<3> & v,
178
int & in, int & strin, int & faces, double eps) const;
180
void CalcSurfaceInverseRec (int inv);
182
Solid * RecGetReducedSolid (const BoxSphere<3> & box, INSOLID_TYPE & in) const;
184
void RecGetSurfaceIndices (ARRAY<int> & surfind) const;
185
void RecGetTangentialSurfaceIndices (const Point<3> & p, ARRAY<int> & surfids, double eps) const;
186
void RecGetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, ARRAY<int> & surfids, double eps) const;
187
void RecGetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2,
188
ARRAY<int> & surfids, double eps) const;
189
void RecGetTangentialEdgeSurfaceIndices (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, const Vec<3> & m,
190
ARRAY<int> & surfids, double eps) const;
191
void RecGetSurfaceIndices (IndexSet & iset) const;
193
void RecCalcOnePrimitiveSpecialPoints (ARRAY<Point<3> > & pts) const;
195
friend class SolidIterator;
196
friend class ClearVisitedIt;
197
friend class RemoveDummyIterator;
198
friend class CSGeometry;
202
inline ostream & operator<< (ostream & ost, const Solid & sol)
213
class ReducePrimitiveIterator : public SolidIterator
215
const BoxSphere<3> & box;
217
ReducePrimitiveIterator (const BoxSphere<3> & abox)
218
: SolidIterator(), box(abox) { ; }
219
virtual ~ReducePrimitiveIterator () { ; }
220
virtual void Do (Solid * sol)
222
if (sol -> GetPrimitive())
223
sol -> GetPrimitive() -> Reduce (box);
228
class UnReducePrimitiveIterator : public SolidIterator
231
UnReducePrimitiveIterator () { ; }
232
virtual ~UnReducePrimitiveIterator () { ; }
233
virtual void Do (Solid * sol)
235
if (sol -> GetPrimitive())
236
sol -> GetPrimitive() -> UnReduce ();