Overture  Version 25
TrimmedMapping.h
Go to the documentation of this file.
1 #ifndef TRIMMED_MAPPING_H
2 #define TRIMMED_MAPPING_H
3 
4 #include "Mapping.h"
5 #include "NurbsMapping.h"
6 //#include "PlotStuff.h"
8 
9 #define OLDSTUFF
10 #undef OLDSTUFF
11 
12 class TMquad;
13 class TMquadRoot;
15 
16 //---------------------------------------------------------------
17 // Define a Trimmed Mapping:
18 // A trimmed surface has curves defined on it (in parameter space)
19 // that "remove" parts the surface.
20 //---------------------------------------------------------------
21 class TrimmedMapping : public Mapping
22 {
23  public: // private // ************************************************
25  Mapping *surface; // here is the surface to be trimmed
26 
27 #ifdef OLDSTUFF
28  int numberOfInnerCurves; // number of curves that trim the surface
30  Mapping **innerCurve; // Here are the curves that trim the surface
31 #else
32  Mapping **trimCurves; // all the curves that trim the surface (including the boundary)
33  intArray trimOrientation; // orientations of the curves : 1 clockwise, -1 counterclockwise
34  int numberOfTrimCurves;
35 #endif
36 
37  bool isInitialized() { return upToDate; }
38  void setUnInitialized();
39 
40  bool trimmingIsValid() { return validTrimming; }
41  int validateTrimming();
43  void invalidateTrimming() { validTrimming = false; } // can only be turned true by call to validateTrimming
44 
45  bool verifyTrimCurve( Mapping *curve );
46 
47  void initializeTrimCurves();
48 
49  aString reportTrimCurveInfo(Mapping *curve, bool &curveok);
51 
52  bool addTrimCurve(Mapping *trimCurve);
53  bool deleteTrimCurve(int curveToDelete);
54  bool deleteTrimCurve( int numberOfCurvesToDelete, int *curvesToDelete);
55  bool undoLastDelete();
56 
57  intArray projectedMask; // mask from mapGrid
61 
62  realArray distanceToBoundary; // set by the map function
63  real rBound[3][2]; // *note* [axis][side]
64 
65  protected:
66  real smallestLengthScale; // Estimate of the smallest length scale in the trimming curves.
67  real dRmin, dSmin; // Smallest bounding boxes of any interior trimming curves. Used to set # lines
68 
69  bool upToDate;
71  bool allNurbs;
73 
74  public:
75 
77 #ifdef OLDSTUFF
80  const int & numberOfInnerCurves=0,
82 #else
85  const int & numberOfInnerCurves=0,
88  const int & numberOfTrimCurves_=0,
89  Mapping **trimCurves_=NULL);
90 #endif
91 
92  // Copy constructor is deep by default
93  TrimmedMapping( const TrimmedMapping &, const CopyType copyType=DEEP );
94 
96 
98 
99 #ifdef OLDSTUFF
100  int setCurves(Mapping & surface_,
101  Mapping *outerCurve_ =NULL,
102  const int & numberOfInnerCurves_ =0,
103  Mapping **innerCurve_ =NULL);
104 #else
105  int setCurves(Mapping & surface_,
106  const int & numberOfTrimCurves_=0,
107  Mapping **trimCurves=NULL);
108 #endif
109 
112 
113  // map a grid of points: r(0:n1,1), or r(0:n1,0:n2,2) or r((0:n1,0:n2,0:n3,3) for 1, 2 or 3d
114  virtual void mapGrid(const realArray & r,
115  realArray & x,
116  realArray & xr,
118 
119  virtual void basicInverse(const realArray & x,
120  realArray & r,
123 
125  bool includeGhost=false);
126 
127  // If boundary curves are made of sub-curves then return the total of all sub-curves
129 
130 #ifdef OLDSTUFF
133 #else
134  int getNumberOfTrimCurves();
135 #endif
136 
137 #ifdef OLDSTUFF
138  // access functions for the outer curve and inner curves
140  Mapping* getInnerCurve(const int & curveNumber);
141 
142 #else
144  Mapping* getInnerCurve(const int & curveNumber);
145  Mapping * getTrimCurve(const int & curveNumber);
146 #endif
147 
148  bool hasTriangulation() const; // return true if there is a triangulation computed
149 
151 
152  virtual int get( const GenericDataBase & dir, const aString & name); // get from a database file
153  virtual int put( GenericDataBase & dir, const aString & name) const; // put to a database file
154 
155  Mapping *make( const aString & mappingClassName );
157 
158  int update( MappingInformation & mapInfo ) ;
159  int editTrimCurve(Mapping &trimCurve, MappingInformation & mapInfo ) ;
160  int editNurbsTrimCurve(NurbsMapping &trimCurve, MappingInformation & mapInfo ) ;
161 
162  // return a pointer to the untrimmed surface
163  Mapping* untrimmedSurface() const {return surface;}
164 
165  void triangulate(MappingInformation & mapInfo); // interactive interface to triangulate.
166  void triangulate();
167 
168  bool isAllNurbs() const { return allNurbs; }
169 
170  public: // protected:// ************************************************
171 
172  int setup();
173 
174  // initialize and optionally build the quadtree
175  void initializeQuadTree(bool buildQuadTree=true );
176  // void initialize();
177  // void createTrimmedSurface();
178 
179  int destroy();
180 
181  int findClosestCurve(const realArray & x,
182  intArray & cMin,
183  realArray & rC,
184  realArray & xC,
185  realArray & dist,
186  const int & approximate =true );
187 
188  int findDistanceToACurve(const realArray & x,
189  IntegerArray & cMin,
190  realArray & dist,
191  const real & delta );
192  int insideOrOutside( const realArray & rr, const int & c );
193  int insideOrOutside( const realArray & rr, const int & c, realArray & distance );
194 
195  bool curveGoesThrough(const TMquad& square, const int& c, int& segstart, int& segstop )
196  const;
197  bool curveGoesThrough( const TMquad& square, const int& c ) const;
198  void setBounds(bool assignBoundsFromTriangulation = true);
199 
200  // These next three functions control the triangulation
201  int setMaxAreaForTriangulation( real area=.1 );
202  int setMinAngleForTriangulation( real minAngle=20. );
203  int setElementDensityToleranceForTriangulation( real elementDensity=.05 );
204 
205  int getTriangulationParameters( real &area, real &minAngle, real &elementDensity ) const;
206 
208  int &curve1, int &curve2, int curve1End, int curve2End,
209  const real *xSelect, const real *c1click );
210 
215  intersection, // snap to intersection
222 
223  int assembleSubCurves(int & currentCurve,
225  NurbsMapping & trimCurve,
226  NurbsMapping & newCurve,
227  int & numberOfAssembledCurves,
228  NurbsMapping ** & assemblyCurves,
229  MouseSelectMode & mouseMode,
230  bool & curveRebuilt,
231  bool & plotCurve );
232 
234 
240  real timeForSeg0 ; // jfp debug
241  real timeForSeg1 ; // jfp debug
243  int callsOfFindClosestCurve; // jfp debug
244  int callsOfFindClosestCurve_all; // jfp debug
245 
247  real minAngleForTriangulation; // use this to reduce allowable angle to we don't get too many triangles: -1=default
248  real elementDensityTolerance; // -1 = use default
249  real maxArea; // approximate maximum area for triangles, 0=use default
250 
252  static real defaultElementDensityToleranceForTriangulation; // num grid pts based on curvature/(this value)
253  static real defaultMaximumAreaForTriangulation; // 0=no max area
254 
255  private:
256  Mapping **oldTrimmingCurves;
257  int numberOfOldTrimmingCurves;
258  intArray oldTrimOrientations;
259  //
260  // Virtual member functions used only through class ReferenceCounting:
261  //
263  { return operator=((TrimmedMapping &)x); }
264  virtual void reference( const ReferenceCounting& x)
265  { reference((TrimmedMapping &)x); } // *** Conversion to this class for the virtual = ****
266  virtual ReferenceCounting* virtualConstructor( const CopyType ct = DEEP ) const
267  { return ::new TrimmedMapping(*this, ct); }
268 
269 };
270 
271 #endif