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.ixx>
19 #include <Adaptor3d_TopolTool.hxx>
20 #include <Standard_ConstructionError.hxx>
21 #include <Geom_Surface.hxx>
22 #include <GeomAdaptor_Surface.hxx>
23 #include <GeomAdaptor_HSurface.hxx>
26 //=======================================================================
28 //purpose : General intersection
29 //=======================================================================
30 void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1,
31 const Handle(Geom_Surface)& S2,
32 const Standard_Real Tol,
33 const Standard_Boolean Approx,
34 const Standard_Boolean ApproxS1,
35 const Standard_Boolean ApproxS2)
37 myHS1 = new GeomAdaptor_HSurface(S1);
41 myHS2 = new GeomAdaptor_HSurface(S2);
42 InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.);
45 //=======================================================================
47 //purpose : General intersection with a Starting Point
48 //=======================================================================
49 void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1,
50 const Handle(Geom_Surface)& S2,
51 const Standard_Real Tol,
52 const Standard_Real U1, const Standard_Real V1,
53 const Standard_Real U2, const Standard_Real V2,
54 const Standard_Boolean Approx,
55 const Standard_Boolean ApproxS1,
56 const Standard_Boolean ApproxS2)
58 myHS1 = new GeomAdaptor_HSurface(S1);
62 myHS2 = new GeomAdaptor_HSurface(S2);
63 InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2);
66 //=======================================================================
67 //function : Internal Perform
69 //=======================================================================
70 void GeomInt_IntSS::InternalPerform(const Standard_Real Tol,
71 const Standard_Boolean Approx,
72 const Standard_Boolean ApproxS1,
73 const Standard_Boolean ApproxS2,
74 const Standard_Boolean useStart,
75 const Standard_Real U1,
76 const Standard_Real V1,
77 const Standard_Real U2,
78 const Standard_Real V2)
80 myTolReached2d = myTolReached3d = 0.0;
83 Handle(Adaptor3d_TopolTool) dom1 = new Adaptor3d_TopolTool(myHS1);
84 Handle(Adaptor3d_TopolTool) dom2 = new Adaptor3d_TopolTool(myHS2);
85 myLConstruct.Load(dom1,dom2,myHS1,myHS2);
87 Standard_Real TolArc = Tol;
88 Standard_Real TolTang = Tol;
89 Standard_Real UVMaxStep = 0.001;
90 Standard_Real Deflection = 0.1;
92 myIntersector.SetTolerances(TolArc,TolTang,UVMaxStep,Deflection);
95 myIntersector.Perform(myHS1,dom1,TolArc,TolTang);
98 myIntersector.Perform(myHS1,dom1,myHS2,dom2,TolArc,TolTang);
101 myIntersector.Perform(myHS1,dom1,myHS2,dom2,U1,V1,U2,V2,TolArc,TolTang);
104 // ============================================================
105 if (myIntersector.IsDone()) {
106 const Standard_Integer nblin = myIntersector.NbLines();
107 for (Standard_Integer i=1; i<= nblin; i++)
109 MakeCurve(i,dom1,dom2,Tol,Approx,ApproxS1,ApproxS2);
114 //=======================================================================
117 //=======================================================================
118 const Handle(Geom_Curve) & GeomInt_IntSS::Line (const Standard_Integer Index) const
120 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::Line");
121 return sline(Index+myNbrestr);
124 //=======================================================================
125 //function : Boundary
127 //=======================================================================
128 const Handle(Geom_Curve) & GeomInt_IntSS::Boundary (const Standard_Integer Index) const
130 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::Line");
131 Standard_OutOfRange_Raise_if(Index <= 0 || Index > myNbrestr,
132 "GeomInt_IntSS::Boundary");
136 //=======================================================================
139 //=======================================================================
140 gp_Pnt2d GeomInt_IntSS::Pnt2d(const Standard_Integer Index,
141 const Standard_Boolean OnFirst) const
143 const IntPatch_Point& thept = myIntersector.Point(Index);
146 thept.ParametersOnS1(U,V);
148 thept.ParametersOnS2(U,V);
149 return gp_Pnt2d(U,V);
152 //=======================================================================
153 //function : HasLineOnS1
155 //=======================================================================
156 Standard_Boolean GeomInt_IntSS::HasLineOnS1(const Standard_Integer index) const
158 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::HasLineOnS1");
159 return (!slineS1(index).IsNull());
162 //=======================================================================
163 //function : HasLineOnS2
165 //=======================================================================
166 Standard_Boolean GeomInt_IntSS::HasLineOnS2(const Standard_Integer index) const
168 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::HasLineOnS2");
169 return (!slineS2(index).IsNull());
172 //=======================================================================
173 //function : LineOnS1
175 //=======================================================================
176 const Handle(Geom2d_Curve) & GeomInt_IntSS::LineOnS1(const Standard_Integer Index) const
178 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::LineOnS1");
179 return slineS1(Index);
182 //=======================================================================
183 //function : LineOnS2
185 //=======================================================================
186 const Handle(Geom2d_Curve) & GeomInt_IntSS::LineOnS2(const Standard_Integer Index) const
188 StdFail_NotDone_Raise_if(!myIntersector.IsDone(),"GeomInt_IntSS::LineOnS2");
189 return slineS2(Index);