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