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