1 // Created on: 1994-02-07
2 // Created by: Modelistation
3 // Copyright (c) 1994-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
9 // under the terms of the GNU Lesser General Public 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 <BRepIntCurveSurface_Inter.ixx>
18 #include <Geom_Line.hxx>
19 #include <TopAbs_ShapeEnum.hxx>
21 #include <TopoDS_Face.hxx>
22 #include <BRepAdaptor_Surface.hxx>
23 #include <BRepAdaptor_HSurface.hxx>
24 #include <GeomAdaptor_HCurve.hxx>
25 #include <BRepTopAdaptor_TopolTool.hxx>
26 #include <BRepAdaptor_HSurface.hxx>
28 //modified by NIZNHY-PKV Sun Dec 15 16:57:10 2002 f
30 static Standard_Real currentU,currentV;
31 TopAbs_State currentstate;
32 static Handle(BRepTopAdaptor_TopolTool) FastClass
33 = new BRepTopAdaptor_TopolTool();
35 static Handle(BRepAdaptor_HSurface) SurfForFastClass
36 = new BRepAdaptor_HSurface();
38 //modified by NIZNHY-PKV Sun Dec 15 16:57:14 2002 t
40 //===========================================================================
41 //function :BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inte
43 //===========================================================================
44 BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inter()
45 : empty(Standard_True)
47 //modified by NIZNHY-PKV Sun Dec 15 16:58:10 2002 f
48 FastClass = new BRepTopAdaptor_TopolTool();
49 SurfForFastClass = new BRepAdaptor_HSurface();
50 //modified by NIZNHY-PKV Sun Dec 15 16:58:13 2002 t
53 void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& ashape,
54 const GeomAdaptor_Curve& acurve,
55 const Standard_Real tol) {
56 empty = Standard_False;
57 curveisaline = Standard_False;
59 explorer.Init(ashape,TopAbs_FACE);
65 void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& ashape,
67 const Standard_Real tol) {
68 empty = Standard_False;
69 curveisaline = Standard_True;
71 Handle(Geom_Line) geomline = new Geom_Line(aline);
73 explorer.Init(ashape,TopAbs_FACE);
79 Standard_Boolean BRepIntCurveSurface_Inter::More() const {
80 return(explorer.More());
83 void BRepIntCurveSurface_Inter::Next() {
87 void BRepIntCurveSurface_Inter::Find() {
89 static Standard_Real UMin = 0.0;
90 static Standard_Real UMax = 0.0;
91 static Standard_Real VMin = 0.0;
92 static Standard_Real VMax = 0.0;
93 static Standard_Real PeriodU = 0.0;
94 static Standard_Real PeriodV = 0.0;
97 while(currentindex < currentnbpoints) {
99 Standard_Real U = intcs.Point(currentindex).U();
100 Standard_Real V = intcs.Point(currentindex).V();
101 //-------------------------------------------------------
102 //-- Try to reframe point U,V in the face UV
112 // Standard_Real UInit = U;
113 Standard_Real VInit = V;
119 //-- classifier.Perform(TopoDS::Face(explorer.Current()),Puv,tolerance);
120 currentstate = FastClass->Classify(Puv,tolerance); //-- MODIF
121 //-- TopAbs_State currentstate = classifier.State();
123 if(currentstate == TopAbs_ON || currentstate == TopAbs_IN) {
130 while(PeriodV && V< VMax);
133 while(PeriodU && U<UMax);
138 if(explorer.More()) {
139 //---------------------------------------------
140 BRepAdaptor_Surface brepadaptsurf;
142 TopoDS_Face face=TopoDS::Face(explorer.Current());
143 face.Orientation(TopAbs_FORWARD);
145 brepadaptsurf.Initialize(face,Standard_True);
146 //----------------------------------------------
147 //-- Update variables PeriodU,PeriodV
150 SurfForFastClass->ChangeSurface().Initialize(face); //-- MODIF
151 // SurfForFastClass->ChangeSurface().Initialize(TopoDS::Face(face)); //-- MODIF
152 FastClass->Initialize(SurfForFastClass); //-- MODIF
154 if( brepadaptsurf.Surface().IsUPeriodic()) {
155 PeriodU = brepadaptsurf.Surface().UPeriod();
156 UMin = brepadaptsurf.Surface().FirstUParameter();
157 UMax = brepadaptsurf.Surface().LastUParameter();
162 if( brepadaptsurf.Surface().IsVPeriodic()) {
163 PeriodV = brepadaptsurf.Surface().VPeriod();
164 VMin = brepadaptsurf.Surface().FirstVParameter();
165 VMax = brepadaptsurf.Surface().LastVParameter();
171 //----------------------------------------------
172 Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(curve);
173 Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(brepadaptsurf);
174 //----------------------------------------------
175 //-- intcs.Perform(curve,brepadaptsurf);
176 intcs.Perform(HC,HS);
179 currentnbpoints = intcs.NbPoints();
180 if(currentnbpoints) {
194 IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const {
196 StdFail_NotDone::Raise();
197 const IntCurveSurface_IntersectionPoint& ICPS = intcs.Point(currentindex);
198 return(IntCurveSurface_IntersectionPoint(ICPS.Pnt(),
199 currentU, // ICPS.U(),
200 currentV, // ICPS.V(),
203 //-- return(intcs.Point(currentindex));
206 Standard_Real BRepIntCurveSurface_Inter::U() const {
208 StdFail_NotDone::Raise();
209 //-- return(intcs.Point(currentindex).U());
213 Standard_Real BRepIntCurveSurface_Inter::V() const {
215 StdFail_NotDone::Raise();
216 //-- return(intcs.Point(currentindex).V());
220 Standard_Real BRepIntCurveSurface_Inter::W() const {
222 StdFail_NotDone::Raise();
223 return(intcs.Point(currentindex).W());
226 TopAbs_State BRepIntCurveSurface_Inter::State() const {
228 StdFail_NotDone::Raise();
229 //-- return(classifier.State());
230 return(currentstate);
233 IntCurveSurface_TransitionOnCurve BRepIntCurveSurface_Inter::Transition() const {
235 StdFail_NotDone::Raise();
236 return(intcs.Point(currentindex).Transition());
239 const TopoDS_Face& BRepIntCurveSurface_Inter::Face() const {
240 return(TopoDS::Face(explorer.Current()));
243 const gp_Pnt& BRepIntCurveSurface_Inter::Pnt() const {
245 StdFail_NotDone::Raise();
246 return(intcs.Point(currentindex).Pnt());