b311480e |
1 | // Created on: 1995-01-27 |
2 | // Created by: Jacques GOUSSARD |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
e2e0498b |
17 | #include <GeomInt_IntSS.hxx> |
7fd59977 |
18 | |
19 | #include <Adaptor3d_TopolTool.hxx> |
7fd59977 |
20 | #include <GeomAdaptor_HSurface.hxx> |
7fd59977 |
21 | |
22 | //======================================================================= |
23 | //function : Perform |
24 | //purpose : General intersection |
25 | //======================================================================= |
b311480e |
26 | void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1, |
7fd59977 |
27 | const Handle(Geom_Surface)& S2, |
28 | const Standard_Real Tol, |
29 | const Standard_Boolean Approx, |
30 | const Standard_Boolean ApproxS1, |
31 | const Standard_Boolean ApproxS2) |
32 | { |
33 | myHS1 = new GeomAdaptor_HSurface(S1); |
34 | if (S1==S2) |
35 | myHS2 = myHS1; |
36 | else |
37 | myHS2 = new GeomAdaptor_HSurface(S2); |
38 | InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.); |
39 | } |
40 | |
41 | //======================================================================= |
42 | //function : Perform |
43 | //purpose : General intersection with a Starting Point |
44 | //======================================================================= |
45 | void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1, |
46 | const Handle(Geom_Surface)& S2, |
47 | const Standard_Real Tol, |
48 | const Standard_Real U1, const Standard_Real V1, |
49 | const Standard_Real U2, const Standard_Real V2, |
50 | const Standard_Boolean Approx, |
51 | const Standard_Boolean ApproxS1, |
52 | const Standard_Boolean ApproxS2) |
53 | { |
54 | myHS1 = new GeomAdaptor_HSurface(S1); |
55 | if (S1==S2) |
56 | myHS2 = myHS1; |
57 | else |
58 | myHS2 = new GeomAdaptor_HSurface(S2); |
59 | InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2); |
60 | } |
61 | |
62 | //======================================================================= |
63 | //function : Internal Perform |
64 | //purpose : |
65 | //======================================================================= |
66 | void GeomInt_IntSS::InternalPerform(const Standard_Real Tol, |
67 | const Standard_Boolean Approx, |
68 | const Standard_Boolean ApproxS1, |
69 | const Standard_Boolean ApproxS2, |
70 | const Standard_Boolean useStart, |
71 | const Standard_Real U1, |
72 | const Standard_Real V1, |
73 | const Standard_Real U2, |
74 | const Standard_Real V2) |
75 | { |
76 | myTolReached2d = myTolReached3d = 0.0; |
77 | myNbrestr = 0; |
78 | sline.Clear(); |
79 | Handle(Adaptor3d_TopolTool) dom1 = new Adaptor3d_TopolTool(myHS1); |
80 | Handle(Adaptor3d_TopolTool) dom2 = new Adaptor3d_TopolTool(myHS2); |
81 | myLConstruct.Load(dom1,dom2,myHS1,myHS2); |
82 | |
83 | Standard_Real TolArc = Tol; |
84 | Standard_Real TolTang = Tol; |
85 | Standard_Real UVMaxStep = 0.001; |
86 | Standard_Real Deflection = 0.1; |
87 | |
88 | myIntersector.SetTolerances(TolArc,TolTang,UVMaxStep,Deflection); |
89 | |
90 | if(myHS1 == myHS2) { |
91 | myIntersector.Perform(myHS1,dom1,TolArc,TolTang); |
92 | } |
93 | else if (!useStart) { |
94 | myIntersector.Perform(myHS1,dom1,myHS2,dom2,TolArc,TolTang); |
95 | } |
96 | else { |
97 | myIntersector.Perform(myHS1,dom1,myHS2,dom2,U1,V1,U2,V2,TolArc,TolTang); |
98 | } |
99 | |
100 | // ============================================================ |
101 | if (myIntersector.IsDone()) { |
102 | const Standard_Integer nblin = myIntersector.NbLines(); |
00302ba4 |
103 | for (Standard_Integer i=1; i<= nblin; i++) |
104 | { |
7fd59977 |
105 | MakeCurve(i,dom1,dom2,Tol,Approx,ApproxS1,ApproxS2); |
106 | } |
107 | } |
108 | } |
109 | |
110 | //======================================================================= |
111 | //function : Line |
112 | //purpose : |
113 | //======================================================================= |
114 | const Handle(Geom_Curve) & GeomInt_IntSS::Line (const Standard_Integer Index) const |
115 | { |
116 | StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::Line"); |
117 | return sline(Index+myNbrestr); |
118 | } |
119 | |
120 | //======================================================================= |
121 | //function : Boundary |
122 | //purpose : |
123 | //======================================================================= |
124 | const Handle(Geom_Curve) & GeomInt_IntSS::Boundary (const Standard_Integer Index) const |
125 | { |
126 | StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::Line"); |
127 | Standard_OutOfRange_Raise_if(Index <= 0 || Index > myNbrestr, |
128 | "GeomInt_IntSS::Boundary"); |
129 | return sline(Index); |
130 | } |
131 | |
132 | //======================================================================= |
133 | //function : Pnt2d |
134 | //purpose : |
135 | //======================================================================= |
136 | gp_Pnt2d GeomInt_IntSS::Pnt2d(const Standard_Integer Index, |
137 | const Standard_Boolean OnFirst) const |
138 | { |
139 | const IntPatch_Point& thept = myIntersector.Point(Index); |
140 | Standard_Real U,V; |
141 | if (OnFirst) |
142 | thept.ParametersOnS1(U,V); |
143 | else |
144 | thept.ParametersOnS2(U,V); |
145 | return gp_Pnt2d(U,V); |
146 | } |
147 | |
148 | //======================================================================= |
149 | //function : HasLineOnS1 |
150 | //purpose : |
151 | //======================================================================= |
152 | Standard_Boolean GeomInt_IntSS::HasLineOnS1(const Standard_Integer index) const |
153 | { |
154 | StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::HasLineOnS1"); |
155 | return (!slineS1(index).IsNull()); |
156 | } |
157 | |
158 | //======================================================================= |
159 | //function : HasLineOnS2 |
160 | //purpose : |
161 | //======================================================================= |
162 | Standard_Boolean GeomInt_IntSS::HasLineOnS2(const Standard_Integer index) const |
163 | { |
164 | StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::HasLineOnS2"); |
165 | return (!slineS2(index).IsNull()); |
166 | } |
167 | |
168 | //======================================================================= |
169 | //function : LineOnS1 |
170 | //purpose : |
171 | //======================================================================= |
172 | const Handle(Geom2d_Curve) & GeomInt_IntSS::LineOnS1(const Standard_Integer Index) const |
173 | { |
174 | StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::LineOnS1"); |
175 | return slineS1(Index); |
176 | } |
177 | |
178 | //======================================================================= |
179 | //function : LineOnS2 |
180 | //purpose : |
181 | //======================================================================= |
182 | const Handle(Geom2d_Curve) & GeomInt_IntSS::LineOnS2(const Standard_Integer Index) const |
183 | { |
184 | StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::LineOnS2"); |
185 | return slineS2(Index); |
186 | } |