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_Intersection_HeaderFile |
18 | #define _IntPolyh_Intersection_HeaderFile |
19 | |
c22b52d6 |
20 | #include <Adaptor3d_Surface.hxx> |
03cca6f7 |
21 | #include <IntPolyh_ArrayOfPointNormal.hxx> |
42cf5bc1 |
22 | #include <IntPolyh_ArrayOfSectionLines.hxx> |
23 | #include <IntPolyh_ArrayOfTangentZones.hxx> |
03cca6f7 |
24 | #include <IntPolyh_ListOfCouples.hxx> |
25 | #include <IntPolyh_PMaillageAffinage.hxx> |
42cf5bc1 |
26 | #include <TColStd_Array1OfReal.hxx> |
42cf5bc1 |
27 | |
03cca6f7 |
28 | //! API algorithm for intersection of two surfaces by intersection |
29 | //! of their triangulations. |
30 | //! |
31 | //! Algorithm provides possibility to intersect surfaces as without |
32 | //! the precomputed sampling as with it. |
33 | //! |
34 | //! If the numbers of sampling points are not given, it will build the |
35 | //! net of 10x10 sampling points for each surface. |
36 | //! |
37 | //! The intersection is done inside constructors. |
38 | //! Before obtaining the results of intersection it is necessary to check |
39 | //! if intersection has been performed correctly. It can be done by calling |
40 | //! the *IsDone()* method. |
41 | //! |
42 | //! The results of intersection are the intersection lines and points. |
43 | class IntPolyh_Intersection |
42cf5bc1 |
44 | { |
45 | public: |
46 | |
47 | DEFINE_STANDARD_ALLOC |
48 | |
03cca6f7 |
49 | public: //! @name Constructors |
50 | |
51 | //! Constructor for intersection of two surfaces with default parameters. |
52 | //! Performs intersection. |
c22b52d6 |
53 | Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1, |
54 | const Handle(Adaptor3d_Surface)& theS2); |
03cca6f7 |
55 | |
56 | //! Constructor for intersection of two surfaces with the given |
57 | //! size of the sampling nets: |
58 | //! - <theNbSU1> x <theNbSV1> - for the first surface <theS1>; |
59 | //! - <theNbSU2> x <theNbSV2> - for the second surface <theS2>. |
60 | //! Performs intersection. |
c22b52d6 |
61 | Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1, |
03cca6f7 |
62 | const Standard_Integer theNbSU1, |
63 | const Standard_Integer theNbSV1, |
c22b52d6 |
64 | const Handle(Adaptor3d_Surface)& theS2, |
03cca6f7 |
65 | const Standard_Integer theNbSU2, |
66 | const Standard_Integer theNbSV2); |
67 | |
68 | //! Constructor for intersection of two surfaces with the precomputed sampling. |
69 | //! Performs intersection. |
c22b52d6 |
70 | Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1, |
03cca6f7 |
71 | const TColStd_Array1OfReal& theUPars1, |
72 | const TColStd_Array1OfReal& theVPars1, |
c22b52d6 |
73 | const Handle(Adaptor3d_Surface)& theS2, |
03cca6f7 |
74 | const TColStd_Array1OfReal& theUPars2, |
75 | const TColStd_Array1OfReal& theVPars2); |
76 | |
77 | |
78 | public: //! @name Getting the results |
79 | |
80 | //! Returns state of the operation |
81 | Standard_Boolean IsDone() const |
82 | { |
83 | return myIsDone; |
84 | } |
85 | |
5c48956f |
86 | //! Returns state of the operation |
87 | Standard_Boolean IsParallel() const |
88 | { |
89 | return myIsParallel; |
90 | } |
91 | |
03cca6f7 |
92 | //! Returns the number of section lines |
93 | Standard_Integer NbSectionLines() const |
94 | { |
95 | return mySectionLines.NbItems(); |
96 | } |
97 | |
98 | //! Returns the number of points in the given line |
99 | Standard_Integer NbPointsInLine(const Standard_Integer IndexLine) const |
100 | { |
101 | return mySectionLines[IndexLine-1].NbStartPoints(); |
102 | } |
103 | |
104 | // Returns number of tangent zones |
105 | Standard_Integer NbTangentZones() const |
106 | { |
107 | return myTangentZones.NbItems(); |
108 | } |
109 | |
110 | //! Returns number of points in tangent zone |
111 | Standard_Integer NbPointsInTangentZone(const Standard_Integer) const |
112 | { |
113 | return 1; |
114 | } |
115 | |
116 | //! Gets the parameters of the point in section line |
117 | Standard_EXPORT void GetLinePoint(const Standard_Integer IndexLine, |
118 | const Standard_Integer IndexPoint, |
119 | Standard_Real& x, Standard_Real& y, Standard_Real& z, |
120 | Standard_Real& u1, Standard_Real& v1, |
121 | Standard_Real& u2, Standard_Real& v2, |
122 | Standard_Real& incidence) const; |
123 | |
124 | //! Gets the parameters of the point in tangent zone |
125 | Standard_EXPORT void GetTangentZonePoint(const Standard_Integer IndexLine, |
126 | const Standard_Integer IndexPoint, |
127 | Standard_Real& x, Standard_Real& y, Standard_Real& z, |
128 | Standard_Real& u1, Standard_Real& v1, |
129 | Standard_Real& u2, Standard_Real& v2) const; |
130 | |
131 | |
132 | private: //! @name Performing the intersection |
133 | |
134 | //! Compute the intersection by first making the sampling of the surfaces. |
42cf5bc1 |
135 | Standard_EXPORT void Perform(); |
42cf5bc1 |
136 | |
03cca6f7 |
137 | //! Compute the intersection on the precomputed sampling. |
138 | Standard_EXPORT void Perform(const TColStd_Array1OfReal& theUPars1, |
139 | const TColStd_Array1OfReal& theVPars1, |
140 | const TColStd_Array1OfReal& theUPars2, |
141 | const TColStd_Array1OfReal& theVPars2); |
142 | |
143 | //! Performs the default (standard) intersection of the triangles |
144 | Standard_EXPORT Standard_Boolean PerformStd(const TColStd_Array1OfReal& theUPars1, |
145 | const TColStd_Array1OfReal& theVPars1, |
146 | const TColStd_Array1OfReal& theUPars2, |
147 | const TColStd_Array1OfReal& theVPars2, |
148 | const Standard_Real theDeflTol1, |
149 | const Standard_Real theDeflTol2, |
150 | IntPolyh_PMaillageAffinage& theMaillageS, |
151 | Standard_Integer& theNbCouples); |
152 | |
153 | //! Performs the advanced intersection of the triangles - four intersection with |
154 | //! different shifts of the sampling points. |
155 | Standard_EXPORT Standard_Boolean PerformAdv(const TColStd_Array1OfReal& theUPars1, |
156 | const TColStd_Array1OfReal& theVPars1, |
157 | const TColStd_Array1OfReal& theUPars2, |
158 | const TColStd_Array1OfReal& theVPars2, |
159 | const Standard_Real theDeflTol1, |
160 | const Standard_Real theDeflTol2, |
161 | IntPolyh_PMaillageAffinage& theMaillageFF, |
162 | IntPolyh_PMaillageAffinage& theMaillageFR, |
163 | IntPolyh_PMaillageAffinage& theMaillageRF, |
164 | IntPolyh_PMaillageAffinage& theMaillageRR, |
165 | Standard_Integer& theNbCouples); |
166 | |
167 | //! Performs the advanced intersection of the triangles. |
168 | Standard_EXPORT Standard_Boolean PerformMaillage(const TColStd_Array1OfReal& theUPars1, |
169 | const TColStd_Array1OfReal& theVPars1, |
170 | const TColStd_Array1OfReal& theUPars2, |
171 | const TColStd_Array1OfReal& theVPars2, |
172 | const Standard_Real theDeflTol1, |
173 | const Standard_Real theDeflTol2, |
174 | IntPolyh_PMaillageAffinage& theMaillage); |
175 | |
176 | //! Performs the advanced intersection of the triangles. |
177 | Standard_EXPORT Standard_Boolean PerformMaillage(const TColStd_Array1OfReal& theUPars1, |
178 | const TColStd_Array1OfReal& theVPars1, |
179 | const TColStd_Array1OfReal& theUPars2, |
180 | const TColStd_Array1OfReal& theVPars2, |
181 | const Standard_Real theDeflTol1, |
182 | const Standard_Real theDeflTol2, |
183 | const IntPolyh_ArrayOfPointNormal& thePoints1, |
184 | const IntPolyh_ArrayOfPointNormal& thePoints2, |
185 | const Standard_Boolean theIsFirstFwd, |
186 | const Standard_Boolean theIsSecondFwd, |
187 | IntPolyh_PMaillageAffinage& theMaillage); |
188 | |
189 | //! Clears the arrays from the duplicate couples, keeping only one instance of it. |
190 | Standard_EXPORT void MergeCouples(IntPolyh_ListOfCouples& theArrayFF, |
191 | IntPolyh_ListOfCouples& theArrayFR, |
192 | IntPolyh_ListOfCouples& theArrayRF, |
193 | IntPolyh_ListOfCouples& theArrayRR) const; |
194 | |
5c48956f |
195 | Standard_Boolean AnalyzeIntersection(IntPolyh_PMaillageAffinage& theMaillage); |
196 | Standard_Boolean IsAdvRequired(IntPolyh_PMaillageAffinage& theMaillage); |
197 | |
03cca6f7 |
198 | |
199 | private: //! @name Fields |
200 | |
201 | // Inputs |
c22b52d6 |
202 | Handle(Adaptor3d_Surface) mySurf1; //!< First surface |
203 | Handle(Adaptor3d_Surface) mySurf2; //!< Second surface |
03cca6f7 |
204 | Standard_Integer myNbSU1; //!< Number of samples in U direction for first surface |
205 | Standard_Integer myNbSV1; //!< Number of samples in V direction for first surface |
206 | Standard_Integer myNbSU2; //!< Number of samples in U direction for second surface |
207 | Standard_Integer myNbSV2; //!< Number of samples in V direction for second surface |
208 | // Results |
209 | Standard_Boolean myIsDone; //!< State of the operation |
210 | IntPolyh_ArrayOfSectionLines mySectionLines; //!< Section lines |
211 | IntPolyh_ArrayOfTangentZones myTangentZones; //!< Tangent zones |
5c48956f |
212 | Standard_Boolean myIsParallel; |
42cf5bc1 |
213 | }; |
214 | |
42cf5bc1 |
215 | #endif // _IntPolyh_Intersection_HeaderFile |