0028832: MMgt_TShared can be replaced by Standard_Transient
[occt.git] / src / HLRBRep / HLRBRep_Data.hxx
1 // Created on: 1993-01-11
2 // Created by: Christophe MARION
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _HLRBRep_Data_HeaderFile
18 #define _HLRBRep_Data_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Integer.hxx>
24 #include <TopTools_IndexedMapOfShape.hxx>
25 #include <HLRBRep_Array1OfEData.hxx>
26 #include <HLRBRep_Array1OfFData.hxx>
27 #include <TColStd_Array1OfInteger.hxx>
28 #include <Standard_ShortReal.hxx>
29 #include <HLRAlgo_Projector.hxx>
30 #include <HLRBRep_CLProps.hxx>
31 #include <HLRBRep_SLProps.hxx>
32 #include <Standard_Real.hxx>
33 #include <HLRBRep_FaceIterator.hxx>
34 #include <Standard_Address.hxx>
35 #include <GeomAbs_SurfaceType.hxx>
36 #include <Standard_Boolean.hxx>
37 #include <GeomAbs_CurveType.hxx>
38 #include <TopAbs_Orientation.hxx>
39 #include <HLRBRep_Intersector.hxx>
40 #include <HLRAlgo_Interference.hxx>
41 #include <Standard_Transient.hxx>
42 #include <BRepTopAdaptor_MapOfShapeTool.hxx>
43 #include <TopAbs_State.hxx>
44 #include <HLRAlgo_InterferenceList.hxx>
45 class BRepTopAdaptor_TopolTool;
46 class StdFail_UndefinedDerivative;
47 class HLRAlgo_Projector;
48 class HLRAlgo_Interference;
49 class gp_Dir2d;
50 class HLRBRep_EdgeData;
51 class HLRBRep_FaceData;
52 class IntRes2d_IntersectionPoint;
53 class TableauRejection;
54
55
56 class HLRBRep_Data;
57 DEFINE_STANDARD_HANDLE(HLRBRep_Data, Standard_Transient)
58
59
60 class HLRBRep_Data : public Standard_Transient
61 {
62
63 public:
64
65   
66   //! Create an  empty data structure  of <NV> vertices,
67   //! <NE> edges and <NF> faces.
68   Standard_EXPORT HLRBRep_Data(const Standard_Integer NV, const Standard_Integer NE, const Standard_Integer NF);
69   
70   //! Write <DS>    in   me  with   a     translation of
71   //! <dv>,<de>,<df>.
72   Standard_EXPORT void Write (const Handle(HLRBRep_Data)& DS, const Standard_Integer dv, const Standard_Integer de, const Standard_Integer df);
73   
74     HLRBRep_Array1OfEData& EDataArray();
75   
76     HLRBRep_Array1OfFData& FDataArray();
77   
78   //! Set the  tolerance for the  rejections  during the
79   //! exploration
80     void Tolerance (const Standard_ShortReal tol);
81   
82   //! returns  the tolerance for the  rejections  during
83   //! the exploration
84     Standard_ShortReal Tolerance() const;
85   
86   //! end of building  of the Data and updating
87   //! all the informations linked to the projection.
88   Standard_EXPORT void Update (const HLRAlgo_Projector& P);
89   
90     HLRAlgo_Projector& Projector();
91   
92     Standard_Integer NbVertices() const;
93   
94     Standard_Integer NbEdges() const;
95   
96     Standard_Integer NbFaces() const;
97   
98     TopTools_IndexedMapOfShape& EdgeMap();
99   
100     TopTools_IndexedMapOfShape& FaceMap();
101   
102   //! to compare with only non rejected edges.
103   Standard_EXPORT void InitBoundSort (const HLRAlgo_EdgesBlock::MinMaxIndices& MinMaxTot, const Standard_Integer e1, const Standard_Integer e2);
104   
105   //! Begin an iteration only  on visible Edges
106   //! crossing the face number <FI>.
107   Standard_EXPORT void InitEdge (const Standard_Integer FI, BRepTopAdaptor_MapOfShapeTool& MST);
108   
109   Standard_EXPORT Standard_Boolean MoreEdge();
110   
111   Standard_EXPORT void NextEdge (const Standard_Boolean skip = Standard_True);
112   
113   //! Returns the  current Edge
114   Standard_EXPORT Standard_Integer Edge() const;
115   
116   //! Returns true if   the  current edge to   be hidden
117   //! belongs to the hiding face.
118     Standard_Boolean HidingTheFace() const;
119   
120   //! Returns true if the current hiding face is not  an
121   //! auto-intersected one.
122     Standard_Boolean SimpleHidingFace() const;
123   
124   //! Intersect  the current  Edge  with the boundary of
125   //! the hiding  face.   The interferences are given by
126   //! the More, Next, and Value methods.
127   Standard_EXPORT void InitInterference();
128   
129     Standard_Boolean MoreInterference() const;
130   
131   Standard_EXPORT void NextInterference();
132   
133   //! Returns  True if the  interference is rejected.
134   Standard_EXPORT Standard_Boolean RejectedInterference();
135   
136   //! Returns True if the rejected interference is above
137   //! the face.
138   Standard_EXPORT Standard_Boolean AboveInterference();
139   
140     HLRAlgo_Interference& Interference();
141   
142   //! Returns the local description of the projection of
143   //! the current LEdge  at parameter  <Param>.
144   Standard_EXPORT void LocalLEGeometry2D (const Standard_Real Param, gp_Dir2d& Tg, gp_Dir2d& Nm, Standard_Real& Cu);
145   
146   //! Returns the local description of the projection of
147   //! the current FEdge  at parameter  <Param>.
148   Standard_EXPORT void LocalFEGeometry2D (const Standard_Integer FE, const Standard_Real Param, gp_Dir2d& Tg, gp_Dir2d& Nm, Standard_Real& Cu);
149   
150   //! Returns the local  3D   state of the  intersection
151   //! between the current edge and the current face at the
152   //! <p1> and <p2> parameters.
153   Standard_EXPORT void EdgeState (const Standard_Real p1, const Standard_Real p2, TopAbs_State& stbef, TopAbs_State& staf);
154   
155   //! Returns the  true if the  Edge <ED> belongs to the
156   //! Hiding Face.
157     Standard_Boolean EdgeOfTheHidingFace (const Standard_Integer E, const HLRBRep_EdgeData& ED) const;
158   
159   //! Returns the number of  levels of hiding face above
160   //! the   first  point  of   the    edge <ED>.     The
161   //! InterferenceList is  given to  compute far away of
162   //! the Interferences and then come back.
163   Standard_EXPORT Standard_Integer HidingStartLevel (const Standard_Integer E, const HLRBRep_EdgeData& ED, const HLRAlgo_InterferenceList& IL);
164   
165   //! Returns   the  state   of  the   Edge  <ED>  after
166   //! classification.
167   Standard_EXPORT TopAbs_State Compare (const Standard_Integer E, const HLRBRep_EdgeData& ED);
168   
169   //! Simple classification of part of edge  [p1,  p2]
170   //! returns  OUT  if  at  least  1 of  Nbp  points  of  edge  is  out
171   //! othewise  returns  IN
172   //! It  is  used  to  check  "suspision"  hided  part  of  edge.
173   Standard_EXPORT TopAbs_State SimplClassify (const Standard_Integer E, const HLRBRep_EdgeData& ED, const Standard_Integer Nbp, const Standard_Real p1, const Standard_Real p2);
174   
175   //! Classification of an edge.
176   Standard_EXPORT TopAbs_State Classify (const Standard_Integer E, const HLRBRep_EdgeData& ED, const Standard_Boolean LevelFlag, Standard_Integer& Level, const Standard_Real param);
177
178   //! Returns true if the current face is bad.
179   Standard_EXPORT Standard_Boolean IsBadFace() const;
180
181   Standard_EXPORT void Destroy();
182 ~HLRBRep_Data()
183 {
184   Destroy();
185 }
186
187
188
189   DEFINE_STANDARD_RTTIEXT(HLRBRep_Data,Standard_Transient)
190
191 protected:
192
193
194
195
196 private:
197
198   
199   //! Orient the   OutLines  ( left  must  be  inside in
200   //! projection ). Returns True if the face of a closed
201   //! shell has been inverted;
202   Standard_EXPORT Standard_Boolean OrientOutLine (const Standard_Integer I, HLRBRep_FaceData& FD);
203   
204   //! Orient the Edges which  are not  Internal OutLine,
205   //! not Double and not IsoLine.
206   Standard_EXPORT void OrientOthEdge (const Standard_Integer I, HLRBRep_FaceData& FD);
207   
208   //! Returns  True  if the  intersection is  rejected.
209   Standard_EXPORT Standard_Boolean RejectedPoint (const IntRes2d_IntersectionPoint& PInter, const TopAbs_Orientation BoundOri, const Standard_Integer NumSeg);
210   
211   //! returns True  if there is a common  vertex between
212   //! myLE and myFE  dependig  on  <head1> and  <head2>.
213   Standard_EXPORT Standard_Boolean SameVertex (const Standard_Boolean head1, const Standard_Boolean head2);
214
215   Standard_Integer myNbVertices;
216   Standard_Integer myNbEdges;
217   Standard_Integer myNbFaces;
218   TopTools_IndexedMapOfShape myEMap;
219   TopTools_IndexedMapOfShape myFMap;
220   HLRBRep_Array1OfEData myEData;
221   HLRBRep_Array1OfFData myFData;
222   TColStd_Array1OfInteger myEdgeIndices;
223   Standard_ShortReal myToler;
224   HLRAlgo_Projector myProj;
225   HLRBRep_CLProps myLLProps;
226   HLRBRep_CLProps myFLProps;
227   HLRBRep_SLProps mySLProps;
228   Standard_Real myBigSize;
229   HLRBRep_FaceIterator myFaceItr1;
230   HLRBRep_FaceIterator myFaceItr2;
231   Standard_Integer iFace;
232   HLRBRep_FaceData* iFaceData;
233   Standard_Address iFaceGeom;
234   HLRAlgo_EdgesBlock::MinMaxIndices* iFaceMinMax;
235   GeomAbs_SurfaceType iFaceType;
236   Standard_Boolean iFaceBack;
237   Standard_Boolean iFaceSimp;
238   Standard_Boolean iFaceSmpl;
239   Standard_Boolean iFaceTest;
240   Standard_Integer myHideCount;
241   Standard_Real myDeca[16];
242   Standard_Real mySurD[16];
243   Standard_Integer myCurSortEd;
244   Standard_Integer myNbrSortEd;
245   Standard_Integer myLE;
246   Standard_Boolean myLEOutLine;
247   Standard_Boolean myLEInternal;
248   Standard_Boolean myLEDouble;
249   Standard_Boolean myLEIsoLine;
250   HLRBRep_EdgeData* myLEData;
251   const HLRBRep_Curve* myLEGeom;
252   HLRAlgo_EdgesBlock::MinMaxIndices* myLEMinMax;
253   GeomAbs_CurveType myLEType;
254   Standard_ShortReal myLETol;
255   Standard_Integer myFE;
256   TopAbs_Orientation myFEOri;
257   Standard_Boolean myFEOutLine;
258   Standard_Boolean myFEInternal;
259   Standard_Boolean myFEDouble;
260   HLRBRep_EdgeData* myFEData;
261   HLRBRep_Curve* myFEGeom;
262   GeomAbs_CurveType myFEType;
263   Standard_ShortReal myFETol;
264   HLRBRep_Intersector myIntersector;
265   Handle(BRepTopAdaptor_TopolTool) myClassifier;
266   Standard_Boolean mySameVertex;
267   Standard_Boolean myIntersected;
268   Standard_Integer myNbPoints;
269   Standard_Integer myNbSegments;
270   Standard_Integer iInterf;
271   HLRAlgo_Interference myIntf;
272   Standard_Boolean myAboveIntf;
273   TableauRejection* myReject;
274
275
276 };
277
278
279 #include <HLRBRep_Data.lxx>
280
281
282
283
284
285 #endif // _HLRBRep_Data_HeaderFile