42cf5bc1 |
1 | // Created on: 1999-03-03 |
2 | // Created by: Fabrice SERVANT |
3 | // Copyright (c) 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 _IntPolyh_MaillageAffinage_HeaderFile |
18 | #define _IntPolyh_MaillageAffinage_HeaderFile |
19 | |
c22b52d6 |
20 | #include <Adaptor3d_Surface.hxx> |
42cf5bc1 |
21 | #include <Bnd_Box.hxx> |
42cf5bc1 |
22 | #include <IntPolyh_ArrayOfPoints.hxx> |
23 | #include <IntPolyh_ArrayOfEdges.hxx> |
24 | #include <IntPolyh_ArrayOfTriangles.hxx> |
68b07699 |
25 | #include <IntPolyh_ListOfCouples.hxx> |
42cf5bc1 |
26 | #include <TColStd_Array1OfReal.hxx> |
03cca6f7 |
27 | #include <IntPolyh_ArrayOfPointNormal.hxx> |
42cf5bc1 |
28 | #include <IntPolyh_ArrayOfSectionLines.hxx> |
29 | #include <IntPolyh_ArrayOfTangentZones.hxx> |
c22b52d6 |
30 | |
42cf5bc1 |
31 | class Bnd_Box; |
42cf5bc1 |
32 | class IntPolyh_StartPoint; |
42cf5bc1 |
33 | |
03cca6f7 |
34 | //! Low-level algorithm to compute intersection of the surfaces |
35 | //! by computing the intersection of their triangulations. |
36 | class IntPolyh_MaillageAffinage |
42cf5bc1 |
37 | { |
38 | public: |
39 | |
40 | DEFINE_STANDARD_ALLOC |
41 | |
42 | |
c22b52d6 |
43 | Standard_EXPORT IntPolyh_MaillageAffinage(const Handle(Adaptor3d_Surface)& S1, const Standard_Integer NbSU1, const Standard_Integer NbSV1, const Handle(Adaptor3d_Surface)& S2, const Standard_Integer NbSU2, const Standard_Integer NbSV2, const Standard_Integer PRINT); |
42cf5bc1 |
44 | |
c22b52d6 |
45 | Standard_EXPORT IntPolyh_MaillageAffinage(const Handle(Adaptor3d_Surface)& S1, const Handle(Adaptor3d_Surface)& S2, const Standard_Integer PRINT); |
42cf5bc1 |
46 | |
03cca6f7 |
47 | |
48 | //! Makes the sampling of the surface - |
49 | //! Fills the arrays with the parametric values of the sampling points (triangulation nodes). |
50 | Standard_EXPORT void MakeSampling (const Standard_Integer SurfID, |
51 | TColStd_Array1OfReal& theUPars, |
52 | TColStd_Array1OfReal& theVPars); |
53 | |
54 | //! Computes points on one surface and fills an array of points; |
42cf5bc1 |
55 | //! standard (default) method |
56 | Standard_EXPORT void FillArrayOfPnt (const Standard_Integer SurfID); |
57 | |
58 | //! isShiftFwd flag is added. The purpose is to define shift |
59 | //! of points along normal to the surface in this point. The |
60 | //! shift length represents maximal deflection of triangulation. |
61 | //! The direction (forward or reversed regarding to normal |
62 | //! direction) is defined by isShiftFwd flag. |
63 | //! Compute points on one surface and fill an array of points; |
64 | //! advanced method |
03cca6f7 |
65 | Standard_EXPORT void FillArrayOfPnt (const Standard_Integer SurfID, |
66 | const Standard_Boolean isShiftFwd); |
42cf5bc1 |
67 | |
68 | //! Compute points on one surface and fill an array of points; |
03cca6f7 |
69 | //! If given, <theDeflTol> is the deflection tolerance of the given sampling. |
42cf5bc1 |
70 | //! standard (default) method |
03cca6f7 |
71 | Standard_EXPORT void FillArrayOfPnt (const Standard_Integer SurfID, |
72 | const TColStd_Array1OfReal& Upars, |
73 | const TColStd_Array1OfReal& Vpars, |
74 | const Standard_Real *theDeflTol = NULL); |
42cf5bc1 |
75 | |
76 | //! isShiftFwd flag is added. The purpose is to define shift |
77 | //! of points along normal to the surface in this point. The |
78 | //! shift length represents maximal deflection of triangulation. |
79 | //! The direction (forward or reversed regarding to normal |
80 | //! direction) is defined by isShiftFwd flag. |
81 | //! Compute points on one surface and fill an array of points; |
03cca6f7 |
82 | //! If given, <theDeflTol> is the deflection tolerance of the given sampling. |
42cf5bc1 |
83 | //! advanced method |
03cca6f7 |
84 | Standard_EXPORT void FillArrayOfPnt (const Standard_Integer SurfID, |
85 | const Standard_Boolean isShiftFwd, |
86 | const TColStd_Array1OfReal& Upars, |
87 | const TColStd_Array1OfReal& Vpars, |
88 | const Standard_Real *theDeflTol = NULL); |
89 | |
90 | //! Fills the array of points for the surface taking into account the shift |
91 | Standard_EXPORT void FillArrayOfPnt(const Standard_Integer SurfID, |
92 | const Standard_Boolean isShiftFwd, |
93 | const IntPolyh_ArrayOfPointNormal& thePoints, |
94 | const TColStd_Array1OfReal& theUPars, |
95 | const TColStd_Array1OfReal& theVPars, |
96 | const Standard_Real theDeflTol); |
97 | |
98 | //! Looks for the common box of the surfaces and marks the points |
99 | //! of the surfaces inside that common box for possible intersection |
100 | Standard_EXPORT void CommonBox(); |
101 | |
42cf5bc1 |
102 | //! Compute the common box witch is the intersection |
103 | //! of the two bounding boxes, and mark the points of |
104 | //! the two surfaces that are inside. |
105 | Standard_EXPORT void CommonBox (const Bnd_Box& B1, const Bnd_Box& B2, Standard_Real& xMin, Standard_Real& yMin, Standard_Real& zMin, Standard_Real& xMax, Standard_Real& yMax, Standard_Real& zMax); |
106 | |
107 | //! Compute edges from the array of points |
108 | Standard_EXPORT void FillArrayOfEdges (const Standard_Integer SurfID); |
109 | |
110 | //! Compute triangles from the array of points, and -- |
111 | //! mark the triangles that use marked points by the |
112 | //! CommonBox function. |
113 | Standard_EXPORT void FillArrayOfTriangles (const Standard_Integer SurfID); |
114 | |
42cf5bc1 |
115 | //! Refine systematicaly all marked triangles of both surfaces |
116 | Standard_EXPORT void CommonPartRefinement(); |
117 | |
118 | //! Refine systematicaly all marked triangles of ONE surface |
119 | Standard_EXPORT void LocalSurfaceRefinement (const Standard_Integer SurfId); |
120 | |
121 | //! Compute deflection for all triangles of one |
122 | //! surface,and sort min and max of deflections |
123 | Standard_EXPORT void ComputeDeflections (const Standard_Integer SurfID); |
124 | |
125 | //! Refine both surfaces using BoundSortBox as -- |
126 | //! rejection. The criterions used to refine a -- |
127 | //! triangle are: The deflection The size of the -- |
128 | //! bounding boxes (one surface may be very small |
129 | //! compared to the other) |
130 | Standard_EXPORT void TrianglesDeflectionsRefinementBSB(); |
131 | |
132 | //! This fonction Check if two triangles are in |
133 | //! contact or no, return 1 if yes, return 0 |
134 | //! if no. |
135 | Standard_EXPORT Standard_Integer TriContact (const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& Q1, const IntPolyh_Point& Q2, const IntPolyh_Point& Q3, Standard_Real& Angle) const; |
136 | |
68b07699 |
137 | Standard_EXPORT Standard_Integer TriangleEdgeContact (const Standard_Integer TriSurfID, const Standard_Integer EdgeIndice, const IntPolyh_Triangle& Tri1, const IntPolyh_Triangle& Tri2, const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& C1, const IntPolyh_Point& C2, const IntPolyh_Point& C3, const IntPolyh_Point& Pe1, const IntPolyh_Point& Pe2, const IntPolyh_Point& E, const IntPolyh_Point& N, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const; |
42cf5bc1 |
138 | |
139 | //! From two triangles compute intersection points. |
140 | //! If I found more than two intersection points |
141 | //! that's mean that those triangle are coplanar |
68b07699 |
142 | Standard_EXPORT Standard_Integer StartingPointsResearch (const Standard_Integer T1, const Standard_Integer T2, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const; |
42cf5bc1 |
143 | |
144 | //! from two triangles and an intersection point I |
145 | //! seach the other point (if it exist). |
146 | //! This function is used by StartPointChain |
68b07699 |
147 | Standard_EXPORT Standard_Integer NextStartingPointsResearch (const Standard_Integer T1, const Standard_Integer T2, const IntPolyh_StartPoint& SPInit, IntPolyh_StartPoint& SPNext) const; |
42cf5bc1 |
148 | |
149 | //! Analyse each couple of triangles from the two -- |
150 | //! array of triangles, to see if they are in |
151 | //! contact, and compute the incidence. Then put |
152 | //! couples in contact in the array of couples |
153 | Standard_EXPORT Standard_Integer TriangleCompare(); |
154 | |
42cf5bc1 |
155 | //! Loop on the array of couples. Compute StartPoints. |
156 | //! Try to chain the StartPoints into SectionLines or |
157 | //! put the point in the ArrayOfTangentZones if |
158 | //! chaining it, is not possible. |
159 | Standard_EXPORT Standard_Integer StartPointsChain (IntPolyh_ArrayOfSectionLines& TSectionLines, IntPolyh_ArrayOfTangentZones& TTangentZones); |
160 | |
161 | //! Mainly used by StartPointsChain(), this function |
162 | //! try to compute the next StartPoint. |
163 | Standard_EXPORT Standard_Integer GetNextChainStartPoint (const IntPolyh_StartPoint& SPInit, IntPolyh_StartPoint& SPNext, IntPolyh_SectionLine& MySectionLine, IntPolyh_ArrayOfTangentZones& TTangentZones, const Standard_Boolean Prepend = Standard_False); |
164 | |
165 | Standard_EXPORT const IntPolyh_ArrayOfPoints& GetArrayOfPoints (const Standard_Integer SurfID) const; |
166 | |
167 | Standard_EXPORT const IntPolyh_ArrayOfEdges& GetArrayOfEdges (const Standard_Integer SurfID) const; |
168 | |
169 | Standard_EXPORT const IntPolyh_ArrayOfTriangles& GetArrayOfTriangles (const Standard_Integer SurfID) const; |
170 | |
171 | Standard_EXPORT Standard_Integer GetFinTE (const Standard_Integer SurfID) const; |
172 | |
173 | Standard_EXPORT Standard_Integer GetFinTT (const Standard_Integer SurfID) const; |
174 | |
175 | Standard_EXPORT Bnd_Box GetBox (const Standard_Integer SurfID) const; |
176 | |
68b07699 |
177 | //! This method returns list of couples of contact triangles. |
178 | Standard_EXPORT IntPolyh_ListOfCouples& GetCouples(); |
42cf5bc1 |
179 | |
03cca6f7 |
180 | Standard_EXPORT void SetEnlargeZone (const Standard_Boolean EnlargeZone); |
42cf5bc1 |
181 | |
182 | Standard_EXPORT Standard_Boolean GetEnlargeZone() const; |
183 | |
184 | //! returns FlecheMin |
185 | Standard_EXPORT Standard_Real GetMinDeflection (const Standard_Integer SurfID) const; |
186 | |
187 | //! returns FlecheMax |
188 | Standard_EXPORT Standard_Real GetMaxDeflection (const Standard_Integer SurfID) const; |
189 | |
190 | |
42cf5bc1 |
191 | protected: |
192 | |
193 | |
42cf5bc1 |
194 | private: |
195 | |
196 | |
c22b52d6 |
197 | Handle(Adaptor3d_Surface) MaSurface1; |
198 | Handle(Adaptor3d_Surface) MaSurface2; |
42cf5bc1 |
199 | Bnd_Box MyBox1; |
200 | Bnd_Box MyBox2; |
201 | Standard_Integer NbSamplesU1; |
202 | Standard_Integer NbSamplesU2; |
203 | Standard_Integer NbSamplesV1; |
204 | Standard_Integer NbSamplesV2; |
205 | Standard_Real FlecheMax1; |
206 | Standard_Real FlecheMax2; |
207 | Standard_Real FlecheMin1; |
208 | Standard_Real FlecheMin2; |
68b07699 |
209 | // For the arrays of Points, Edges and Triangles we need instant access to the items. |
210 | // Moreover, we might add new items during refinement process in case the deflection |
211 | // is too big, thus the vectors should be used. |
42cf5bc1 |
212 | IntPolyh_ArrayOfPoints TPoints1; |
213 | IntPolyh_ArrayOfPoints TPoints2; |
214 | IntPolyh_ArrayOfEdges TEdges1; |
215 | IntPolyh_ArrayOfEdges TEdges2; |
216 | IntPolyh_ArrayOfTriangles TTriangles1; |
217 | IntPolyh_ArrayOfTriangles TTriangles2; |
68b07699 |
218 | // The intersecting triangles are just filled and then |
219 | // sequentially analyzed, thus we might use the list. |
220 | IntPolyh_ListOfCouples TTrianglesContacts; |
42cf5bc1 |
221 | |
68b07699 |
222 | Standard_Boolean myEnlargeZone; |
42cf5bc1 |
223 | |
224 | }; |
225 | |
42cf5bc1 |
226 | #endif // _IntPolyh_MaillageAffinage_HeaderFile |