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 gp_Dir2d;
47 class HLRBRep_EdgeData;
48 class HLRBRep_FaceData;
49 class IntRes2d_IntersectionPoint;
50 class TableauRejection;
51 
52 class HLRBRep_Data;
53 DEFINE_STANDARD_HANDLE(HLRBRep_Data, Standard_Transient)
54 
55 class HLRBRep_Data : public Standard_Transient
56 {
57 
58 public:
59 
60 
61   //! Create an  empty data structure  of <NV> vertices,
62   //! <NE> edges and <NF> faces.
63   Standard_EXPORT HLRBRep_Data(const Standard_Integer NV, const Standard_Integer NE, const Standard_Integer NF);
64 
65   //! Write <DS>    in   me  with   a     translation of
66   //! <dv>,<de>,<df>.
67   Standard_EXPORT void Write (const Handle(HLRBRep_Data)& DS, const Standard_Integer dv, const Standard_Integer de, const Standard_Integer df);
68 
69     HLRBRep_Array1OfEData& EDataArray();
70 
71     HLRBRep_Array1OfFData& FDataArray();
72 
73   //! Set the  tolerance for the  rejections  during the
74   //! exploration
75     void Tolerance (const Standard_ShortReal tol);
76 
77   //! returns  the tolerance for the  rejections  during
78   //! the exploration
79     Standard_ShortReal Tolerance() const;
80 
81   //! end of building  of the Data and updating
82   //! all the information linked to the projection.
83   Standard_EXPORT void Update (const HLRAlgo_Projector& P);
84 
85     HLRAlgo_Projector& Projector();
86 
87     Standard_Integer NbVertices() const;
88 
89     Standard_Integer NbEdges() const;
90 
91     Standard_Integer NbFaces() const;
92 
93     TopTools_IndexedMapOfShape& EdgeMap();
94 
95     TopTools_IndexedMapOfShape& FaceMap();
96 
97   //! to compare with only non rejected edges.
98   Standard_EXPORT void InitBoundSort (const HLRAlgo_EdgesBlock::MinMaxIndices& MinMaxTot, const Standard_Integer e1, const Standard_Integer e2);
99 
100   //! Begin an iteration only  on visible Edges
101   //! crossing the face number <FI>.
102   Standard_EXPORT void InitEdge (const Standard_Integer FI, BRepTopAdaptor_MapOfShapeTool& MST);
103 
104   Standard_EXPORT Standard_Boolean MoreEdge();
105 
106   Standard_EXPORT void NextEdge (const Standard_Boolean skip = Standard_True);
107 
108   //! Returns the  current Edge
109   Standard_EXPORT Standard_Integer Edge() const;
110 
111   //! Returns true if   the  current edge to   be hidden
112   //! belongs to the hiding face.
113     Standard_Boolean HidingTheFace() const;
114 
115   //! Returns true if the current hiding face is not  an
116   //! auto-intersected one.
117     Standard_Boolean SimpleHidingFace() const;
118 
119   //! Intersect  the current  Edge  with the boundary of
120   //! the hiding  face.   The interferences are given by
121   //! the More, Next, and Value methods.
122   Standard_EXPORT void InitInterference();
123 
124     Standard_Boolean MoreInterference() const;
125 
126   Standard_EXPORT void NextInterference();
127 
128   //! Returns  True if the  interference is rejected.
129   Standard_EXPORT Standard_Boolean RejectedInterference();
130 
131   //! Returns True if the rejected interference is above
132   //! the face.
133   Standard_EXPORT Standard_Boolean AboveInterference();
134 
135     HLRAlgo_Interference& Interference();
136 
137   //! Returns the local description of the projection of
138   //! the current LEdge  at parameter  <Param>.
139   Standard_EXPORT void LocalLEGeometry2D (const Standard_Real Param, gp_Dir2d& Tg, gp_Dir2d& Nm, Standard_Real& Cu);
140 
141   //! Returns the local description of the projection of
142   //! the current FEdge  at parameter  <Param>.
143   Standard_EXPORT void LocalFEGeometry2D (const Standard_Integer FE, const Standard_Real Param, gp_Dir2d& Tg, gp_Dir2d& Nm, Standard_Real& Cu);
144 
145   //! Returns the local  3D   state of the  intersection
146   //! between the current edge and the current face at the
147   //! <p1> and <p2> parameters.
148   Standard_EXPORT void EdgeState (const Standard_Real p1, const Standard_Real p2, TopAbs_State& stbef, TopAbs_State& staf);
149 
150   //! Returns the  true if the  Edge <ED> belongs to the
151   //! Hiding Face.
152     Standard_Boolean EdgeOfTheHidingFace (const Standard_Integer E, const HLRBRep_EdgeData& ED) const;
153 
154   //! Returns the number of  levels of hiding face above
155   //! the   first  point  of   the    edge <ED>.     The
156   //! InterferenceList is  given to  compute far away of
157   //! the Interferences and then come back.
158   Standard_EXPORT Standard_Integer HidingStartLevel (const Standard_Integer E, const HLRBRep_EdgeData& ED, const HLRAlgo_InterferenceList& IL);
159 
160   //! Returns   the  state   of  the   Edge  <ED>  after
161   //! classification.
162   Standard_EXPORT TopAbs_State Compare (const Standard_Integer E, const HLRBRep_EdgeData& ED);
163 
164   //! Simple classification of part of edge [p1,  p2].
165   //! Returns OUT if at least 1 of Nbp points of edge is out; otherwise returns IN.
166   //! It is used to check "suspicion" hidden part of edge.
167   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);
168 
169   //! Classification of an edge.
170   Standard_EXPORT TopAbs_State Classify (const Standard_Integer E, const HLRBRep_EdgeData& ED, const Standard_Boolean LevelFlag, Standard_Integer& Level, const Standard_Real param);
171 
172   //! Returns true if the current face is bad.
173   Standard_EXPORT Standard_Boolean IsBadFace() const;
174 
175   Standard_EXPORT void Destroy();
~HLRBRep_Data()176 ~HLRBRep_Data()
177 {
178   Destroy();
179 }
180 
181   DEFINE_STANDARD_RTTIEXT(HLRBRep_Data,Standard_Transient)
182 
183 private:
184 
185   //! Orient the   OutLines  ( left  must  be  inside in
186   //! projection ). Returns True if the face of a closed
187   //! shell has been inverted;
188   Standard_EXPORT Standard_Boolean OrientOutLine (const Standard_Integer I, HLRBRep_FaceData& FD);
189 
190   //! Orient the Edges which  are not  Internal OutLine,
191   //! not Double and not IsoLine.
192   Standard_EXPORT void OrientOthEdge (const Standard_Integer I, HLRBRep_FaceData& FD);
193 
194   //! Returns  True  if the  intersection is  rejected.
195   Standard_EXPORT Standard_Boolean RejectedPoint (const IntRes2d_IntersectionPoint& PInter, const TopAbs_Orientation BoundOri, const Standard_Integer NumSeg);
196 
197   //! Returns True if there is a common vertex between myLE and myFE depending on <head1> and <head2>.
198   Standard_EXPORT Standard_Boolean SameVertex (const Standard_Boolean head1, const Standard_Boolean head2);
199 
200 private:
201 
202   Standard_Integer myNbVertices;
203   Standard_Integer myNbEdges;
204   Standard_Integer myNbFaces;
205   TopTools_IndexedMapOfShape myEMap;
206   TopTools_IndexedMapOfShape myFMap;
207   HLRBRep_Array1OfEData myEData;
208   HLRBRep_Array1OfFData myFData;
209   TColStd_Array1OfInteger myEdgeIndices;
210   Standard_ShortReal myToler;
211   HLRAlgo_Projector myProj;
212   HLRBRep_CLProps myLLProps;
213   HLRBRep_CLProps myFLProps;
214   HLRBRep_SLProps mySLProps;
215   Standard_Real myBigSize;
216   HLRBRep_FaceIterator myFaceItr1;
217   HLRBRep_FaceIterator myFaceItr2;
218   Standard_Integer iFace;
219   HLRBRep_FaceData* iFaceData;
220   Standard_Address iFaceGeom;
221   HLRAlgo_EdgesBlock::MinMaxIndices* iFaceMinMax;
222   GeomAbs_SurfaceType iFaceType;
223   Standard_Boolean iFaceBack;
224   Standard_Boolean iFaceSimp;
225   Standard_Boolean iFaceSmpl;
226   Standard_Boolean iFaceTest;
227   Standard_Integer myHideCount;
228   Standard_Real myDeca[16];
229   Standard_Real mySurD[16];
230   Standard_Integer myCurSortEd;
231   Standard_Integer myNbrSortEd;
232   Standard_Integer myLE;
233   Standard_Boolean myLEOutLine;
234   Standard_Boolean myLEInternal;
235   Standard_Boolean myLEDouble;
236   Standard_Boolean myLEIsoLine;
237   HLRBRep_EdgeData* myLEData;
238   const HLRBRep_Curve* myLEGeom;
239   HLRAlgo_EdgesBlock::MinMaxIndices* myLEMinMax;
240   GeomAbs_CurveType myLEType;
241   Standard_ShortReal myLETol;
242   Standard_Integer myFE;
243   TopAbs_Orientation myFEOri;
244   Standard_Boolean myFEOutLine;
245   Standard_Boolean myFEInternal;
246   Standard_Boolean myFEDouble;
247   HLRBRep_EdgeData* myFEData;
248   HLRBRep_Curve* myFEGeom;
249   GeomAbs_CurveType myFEType;
250   Standard_ShortReal myFETol;
251   HLRBRep_Intersector myIntersector;
252   Handle(BRepTopAdaptor_TopolTool) myClassifier;
253   Standard_Boolean mySameVertex;
254   Standard_Boolean myIntersected;
255   Standard_Integer myNbPoints;
256   Standard_Integer myNbSegments;
257   Standard_Integer iInterf;
258   HLRAlgo_Interference myIntf;
259   Standard_Boolean myAboveIntf;
260   TableauRejection* myReject;
261 
262 };
263 
264 #include <HLRBRep_Data.lxx>
265 
266 
267 #endif // _HLRBRep_Data_HeaderFile
268