1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <Adaptor3d_CurveOnSurface.hxx>
16 #include <BRep_Tool.hxx>
17 #include <BRepAdaptor_Curve.hxx>
18 #include <BRepLib_CheckCurveOnSurface.hxx>
19 #include <GeomAdaptor_Surface.hxx>
20 #include <Geom2dAdaptor_Curve.hxx>
21 #include <Geom_Surface.hxx>
22 #include <Standard_ErrorHandler.hxx>
24 #include <TopoDS_Edge.hxx>
25 #include <TopoDS_Face.hxx>
26 #include <Geom_Curve.hxx>
28 //=======================================================================
29 //function : BRepLib_CheckCurveOnSurface
31 //=======================================================================
32 BRepLib_CheckCurveOnSurface::BRepLib_CheckCurveOnSurface
33 ( const TopoDS_Edge& theEdge,
34 const TopoDS_Face& theFace)
36 Init(theEdge, theFace);
39 //=======================================================================
42 //=======================================================================
43 void BRepLib_CheckCurveOnSurface::Init(const TopoDS_Edge& theEdge, const TopoDS_Face& theFace)
47 if (theEdge.IsNull() || theFace.IsNull())
52 if (BRep_Tool::Degenerated(theEdge) ||
53 !BRep_Tool::IsGeometric(theEdge))
58 // 3D curve initialization
59 const Handle(Adaptor3d_Curve) anAdaptor3dCurve = new BRepAdaptor_Curve(theEdge);
61 // Surface initialization
63 TopLoc_Location aLocation;
64 Standard_Real aFirstParam, aLastParam;
66 Handle(Geom2d_Curve) aGeom2dCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirstParam, aLastParam);
67 Handle(Geom_Surface) aGeomSurface = BRep_Tool::Surface(theFace);
69 // 2D curves initialization
70 Handle(Adaptor2d_Curve2d) anAdaptorCurve =
71 new Geom2dAdaptor_Curve(aGeom2dCurve, aFirstParam, aLastParam);
72 Handle(GeomAdaptor_Surface) aGeomAdaptorSurface = new GeomAdaptor_Surface(aGeomSurface);
74 myAdaptorCurveOnSurface = new Adaptor3d_CurveOnSurface(anAdaptorCurve, aGeomAdaptorSurface);
76 if(BRep_Tool::IsClosed(theEdge, theFace))
78 Handle(Geom2d_Curve) aGeom2dReversedCurve =
79 BRep_Tool::CurveOnSurface(TopoDS::Edge(theEdge.Reversed()), theFace, aFirstParam, aLastParam);
80 Handle(Adaptor2d_Curve2d) anAdaptorReversedCurve =
81 new Geom2dAdaptor_Curve(aGeom2dReversedCurve, aFirstParam, aLastParam);
82 myAdaptorCurveOnSurface2 = new Adaptor3d_CurveOnSurface(anAdaptorReversedCurve, aGeomAdaptorSurface);
85 myCOnSurfGeom.Init(anAdaptor3dCurve);
88 //=======================================================================
90 //purpose : if isTheMTDisabled == TRUE parallelization is not used
91 //=======================================================================
92 void BRepLib_CheckCurveOnSurface::Perform(const Standard_Boolean isMultiThread)
94 // Compute the max distance
95 Compute(myAdaptorCurveOnSurface, isMultiThread);
101 if (!myAdaptorCurveOnSurface2.IsNull())
103 // compute max distance for myAdaptorCurveOnSurface2
104 // (for the second curve on closed surface)
105 Compute(myAdaptorCurveOnSurface2, isMultiThread);
109 //=======================================================================
111 //purpose : if isTheMTDisabled == TRUE parallelization is not used
112 //=======================================================================
113 void BRepLib_CheckCurveOnSurface::Compute(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface,
114 const Standard_Boolean isMultiThread)
116 myCOnSurfGeom.Perform(theCurveOnSurface, isMultiThread);