0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / TopOpeBRep / TopOpeBRep_EdgesIntersector.hxx
1 // Created on: 1994-10-13
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-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 _TopOpeBRep_EdgesIntersector_HeaderFile
18 #define _TopOpeBRep_EdgesIntersector_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <TopoDS_Face.hxx>
25 #include <GeomAbs_SurfaceType.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <IntRes2d_Domain.hxx>
28 #include <TopoDS_Edge.hxx>
29 #include <Geom2dAdaptor_Curve.hxx>
30 #include <Standard_Real.hxx>
31 #include <Geom2dInt_GInter.hxx>
32 #include <IntRes2d_SequenceOfIntersectionPoint.hxx>
33 #include <IntRes2d_SequenceOfIntersectionSegment.hxx>
34 #include <Standard_Integer.hxx>
35 #include <TopoDS_Vertex.hxx>
36 #include <TopOpeBRep_SequenceOfPoint2d.hxx>
37 #include <TopOpeBRep_P2Dstatus.hxx>
38 #include <TopAbs_Orientation.hxx>
39 #include <TopOpeBRepDS_Config.hxx>
40 class BRepAdaptor_HSurface;
41 class TopoDS_Shape;
42 class Bnd_Box;
43 class Geom2dAdaptor_Curve;
44 class BRepAdaptor_Surface;
45 class TCollection_AsciiString;
46 class TopOpeBRep_Point2d;
47 class IntRes2d_IntersectionSegment;
48 class IntRes2d_IntersectionPoint;
49 class TopOpeBRepDS_Transition;
50 class gp_Pnt;
51
52
53 //! Describes the intersection of two edges on the same surface
54 class TopOpeBRep_EdgesIntersector 
55 {
56 public:
57
58   DEFINE_STANDARD_ALLOC
59
60   
61   Standard_EXPORT TopOpeBRep_EdgesIntersector();
62   
63   Standard_EXPORT virtual ~TopOpeBRep_EdgesIntersector();
64   
65   Standard_EXPORT void SetFaces (const TopoDS_Shape& F1, const TopoDS_Shape& F2);
66   
67   Standard_EXPORT void SetFaces (const TopoDS_Shape& F1, const TopoDS_Shape& F2, const Bnd_Box& B1, const Bnd_Box& B2);
68   
69   Standard_EXPORT void ForceTolerances (const Standard_Real Tol1, const Standard_Real Tol2);
70   
71   Standard_EXPORT void Dimension (const Standard_Integer D);
72   
73   //! set working space dimension D = 1 for E &|| W, 2 for E in F
74   Standard_EXPORT Standard_Integer Dimension() const;
75   
76   Standard_EXPORT void Perform (const TopoDS_Shape& E1, const TopoDS_Shape& E2, const Standard_Boolean ReduceSegments = Standard_True);
77   
78   Standard_EXPORT Standard_Boolean IsEmpty();
79   
80   //! true if at least one intersection segment.
81   Standard_EXPORT Standard_Boolean HasSegment() const;
82   
83   //! = mySameDomain.
84   Standard_EXPORT Standard_Boolean SameDomain() const;
85   
86   Standard_EXPORT const TopoDS_Shape& Edge (const Standard_Integer Index) const;
87   
88   Standard_EXPORT const Geom2dAdaptor_Curve& Curve (const Standard_Integer Index) const;
89   
90   Standard_EXPORT const TopoDS_Shape& Face (const Standard_Integer Index) const;
91   
92   Standard_EXPORT const BRepAdaptor_Surface& Surface (const Standard_Integer Index) const;
93   
94   Standard_EXPORT Standard_Boolean SurfacesSameOriented() const;
95   
96   Standard_EXPORT Standard_Boolean FacesSameOriented() const;
97   
98   Standard_EXPORT Standard_Real ToleranceMax() const;
99   
100   Standard_EXPORT void Tolerances (Standard_Real& tol1, Standard_Real& tol2) const;
101   
102   Standard_EXPORT Standard_Integer NbPoints() const;
103   
104   Standard_EXPORT Standard_Integer NbSegments() const;
105   
106   Standard_EXPORT void Dump (const TCollection_AsciiString& str, const Standard_Integer ie1 = 0, const Standard_Integer ie2 = 0);
107   
108   Standard_EXPORT void InitPoint (const Standard_Boolean selectkeep = Standard_True);
109   
110   Standard_EXPORT Standard_Boolean MorePoint() const;
111   
112   Standard_EXPORT void NextPoint();
113   
114   Standard_EXPORT const TopOpeBRep_SequenceOfPoint2d& Points() const;
115   
116   Standard_EXPORT const TopOpeBRep_Point2d& Point() const;
117   
118   Standard_EXPORT const TopOpeBRep_Point2d& Point (const Standard_Integer I) const;
119   
120   Standard_EXPORT virtual Standard_Boolean ReduceSegment (TopOpeBRep_Point2d& P1, TopOpeBRep_Point2d& P2, TopOpeBRep_Point2d& Pn) const;
121   
122   Standard_EXPORT TopOpeBRep_P2Dstatus Status1() const;
123
124
125
126
127 protected:
128
129
130
131
132
133 private:
134
135   
136   Standard_EXPORT void Find();
137   
138   //! process if current edges can be considered as SameDomain
139   Standard_EXPORT Standard_Boolean ComputeSameDomain();
140   
141   //! set field mySameDomain to B and return B value
142   Standard_EXPORT Standard_Boolean SetSameDomain (const Standard_Boolean B);
143   
144   Standard_EXPORT void MakePoints2d();
145   
146   Standard_EXPORT void ReduceSegments();
147   
148   Standard_EXPORT const IntRes2d_IntersectionSegment& Segment1() const;
149   
150   Standard_EXPORT Standard_Boolean IsOpposite1() const;
151   
152   Standard_EXPORT void InitPoint1();
153   
154   Standard_EXPORT Standard_Boolean MorePoint1() const;
155   
156   Standard_EXPORT void NextPoint1();
157   
158   Standard_EXPORT const IntRes2d_IntersectionPoint& Point1() const;
159   
160   Standard_EXPORT TopOpeBRepDS_Transition Transition1 (const Standard_Integer Index, const TopAbs_Orientation EO) const;
161   
162   Standard_EXPORT Standard_Real Parameter1 (const Standard_Integer Index) const;
163   
164   Standard_EXPORT Standard_Boolean IsVertex1 (const Standard_Integer Index);
165   
166   Standard_EXPORT const TopoDS_Shape& Vertex1 (const Standard_Integer Index);
167   
168   Standard_EXPORT gp_Pnt Value1() const;
169   
170   Standard_EXPORT Standard_Boolean IsPointOfSegment1() const;
171   
172   Standard_EXPORT Standard_Integer Index1() const;
173   
174   //! geometric configuration of E1,E2 at current intersection point :
175   //! UNSHGEOMETRY if the edges do not share geometry.
176   //! SAMEORIENTED if the edges share geometry and are same oriented.
177   //! DIFFORIENTED if the edges share geometry and are not same oriented.
178   Standard_EXPORT TopOpeBRepDS_Config EdgesConfig1() const;
179
180
181   TopoDS_Face myFace1;
182   TopoDS_Face myFace2;
183   Handle(BRepAdaptor_HSurface) mySurface1;
184   Handle(BRepAdaptor_HSurface) mySurface2;
185   GeomAbs_SurfaceType mySurfaceType1;
186   GeomAbs_SurfaceType mySurfaceType2;
187   Standard_Boolean mySurfacesSameOriented;
188   Standard_Boolean myFacesSameOriented;
189   IntRes2d_Domain myDomain1;
190   IntRes2d_Domain myDomain2;
191   TopoDS_Edge myEdge1;
192   TopoDS_Edge myEdge2;
193   Geom2dAdaptor_Curve myCurve1;
194   Geom2dAdaptor_Curve myCurve2;
195   Standard_Real myTol1;
196   Standard_Real myTol2;
197   Standard_Boolean myTolForced;
198   Geom2dInt_GInter myIntersector;
199   IntRes2d_SequenceOfIntersectionPoint mylpnt;
200   IntRes2d_SequenceOfIntersectionSegment mylseg;
201   Standard_Integer myNbPoints;
202   Standard_Integer myNbSegments;
203   Standard_Integer myTrueNbPoints;
204   Standard_Integer myPointIndex;
205   Standard_Integer myIsVertexPointIndex;
206   Standard_Integer myIsVertexIndex;
207   Standard_Boolean myIsVertexValue;
208   TopoDS_Vertex myIsVertexVertex;
209   Standard_Integer myDimension;
210   Standard_Boolean myHasSegment;
211   Standard_Boolean mySameDomain;
212   Standard_Boolean myf1surf1F_sameoriented;
213   Standard_Boolean myf2surf1F_sameoriented;
214   TopOpeBRep_SequenceOfPoint2d mysp2d;
215   Standard_Integer myip2d;
216   Standard_Integer mynp2d;
217   Standard_Boolean myselectkeep;
218
219
220 };
221
222
223
224
225
226
227
228 #endif // _TopOpeBRep_EdgesIntersector_HeaderFile