1 // Created on: 1995-01-27
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <GeomInt_IntSS.hxx>
19 #include <Adaptor3d_TopolTool.hxx>
20 #include <GeomAdaptor_Surface.hxx>
22 //=======================================================================
24 //purpose : General intersection
25 //=======================================================================
26 void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1,
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)
33 myHS1 = new GeomAdaptor_Surface(S1);
37 myHS2 = new GeomAdaptor_Surface(S2);
38 InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.);
41 //=======================================================================
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)
54 myHS1 = new GeomAdaptor_Surface(S1);
58 myHS2 = new GeomAdaptor_Surface(S2);
59 InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2);
62 //=======================================================================
63 //function : Internal Perform
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)
76 myTolReached2d = myTolReached3d = 0.0;
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);
83 Standard_Real TolArc = Tol;
84 Standard_Real TolTang = Tol;
85 Standard_Real UVMaxStep = 0.001;
86 Standard_Real Deflection = 0.1;
88 myIntersector.SetTolerances(TolArc,TolTang,UVMaxStep,Deflection);
91 myIntersector.Perform(myHS1,dom1,TolArc,TolTang);
94 myIntersector.Perform(myHS1,dom1,myHS2,dom2,TolArc,TolTang);
97 myIntersector.Perform(myHS1,dom1,myHS2,dom2,U1,V1,U2,V2,TolArc,TolTang);
100 // ============================================================
101 if (myIntersector.IsDone()) {
102 const Standard_Integer nblin = myIntersector.NbLines();
103 for (Standard_Integer i=1; i<= nblin; i++)
105 MakeCurve(i,dom1,dom2,Tol,Approx,ApproxS1,ApproxS2);
110 //=======================================================================
113 //=======================================================================
114 const Handle(Geom_Curve) & GeomInt_IntSS::Line (const Standard_Integer Index) const
116 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::Line");
117 return sline(Index+myNbrestr);
120 //=======================================================================
121 //function : Boundary
123 //=======================================================================
124 const Handle(Geom_Curve) & GeomInt_IntSS::Boundary (const Standard_Integer Index) const
126 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::Line");
127 Standard_OutOfRange_Raise_if(Index <= 0 || Index > myNbrestr,
128 "GeomInt_IntSS::Boundary");
132 //=======================================================================
135 //=======================================================================
136 gp_Pnt2d GeomInt_IntSS::Pnt2d(const Standard_Integer Index,
137 const Standard_Boolean OnFirst) const
139 const IntPatch_Point& thept = myIntersector.Point(Index);
142 thept.ParametersOnS1(U,V);
144 thept.ParametersOnS2(U,V);
145 return gp_Pnt2d(U,V);
148 //=======================================================================
149 //function : HasLineOnS1
151 //=======================================================================
152 Standard_Boolean GeomInt_IntSS::HasLineOnS1(const Standard_Integer index) const
154 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::HasLineOnS1");
155 return (!slineS1(index).IsNull());
158 //=======================================================================
159 //function : HasLineOnS2
161 //=======================================================================
162 Standard_Boolean GeomInt_IntSS::HasLineOnS2(const Standard_Integer index) const
164 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::HasLineOnS2");
165 return (!slineS2(index).IsNull());
168 //=======================================================================
169 //function : LineOnS1
171 //=======================================================================
172 const Handle(Geom2d_Curve) & GeomInt_IntSS::LineOnS1(const Standard_Integer Index) const
174 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::LineOnS1");
175 return slineS1(Index);
178 //=======================================================================
179 //function : LineOnS2
181 //=======================================================================
182 const Handle(Geom2d_Curve) & GeomInt_IntSS::LineOnS2(const Standard_Integer Index) const
184 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::LineOnS2");
185 return slineS2(Index);