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 <BRep_Tool.hxx>
16 #include <BRepLib_CheckCurveOnSurface.hxx>
17 #include <Geom_Surface.hxx>
18 #include <Standard_ErrorHandler.hxx>
20 #include <TopoDS_Edge.hxx>
21 #include <TopoDS_Face.hxx>
22 #include <Geom_Curve.hxx>
24 //=======================================================================
25 //function : BRepLib_CheckCurveOnSurface
27 //=======================================================================
28 BRepLib_CheckCurveOnSurface::BRepLib_CheckCurveOnSurface
29 ( const TopoDS_Edge& theEdge,
30 const TopoDS_Face& theFace)
32 Init(theEdge, theFace);
35 //=======================================================================
38 //=======================================================================
39 void BRepLib_CheckCurveOnSurface::Init
40 (const TopoDS_Edge& theEdge,
41 const TopoDS_Face& theFace)
45 if (theEdge.IsNull() || theFace.IsNull())
50 if (BRep_Tool::Degenerated(theEdge) ||
51 !BRep_Tool::IsGeometric(theEdge))
57 TopLoc_Location aLocE, aLocF, aLocC2D;
58 Standard_Real aFirst = 0.0, aLast = 0.0;
60 // 3D curve initialization
61 const Handle(Geom_Curve)& aC3dTmp = BRep_Tool::Curve(theEdge, aLocE, aFirst, aLast);
62 const Handle(Geom_Curve) aC3d(Handle(Geom_Curve)::DownCast(aC3dTmp->Transformed(aLocE.Transformation())));
64 // Surface initialization
65 const Handle(Geom_Surface)& aSTmp = BRep_Tool::Surface(theFace, aLocF);
66 const Handle(Geom_Surface) aS(Handle(Geom_Surface)::DownCast(aSTmp->Transformed(aLocF.Transformation())));
68 // 2D curves initialization
69 myPCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast);
71 if(BRep_Tool::IsClosed(theEdge, theFace))
72 myPCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(theEdge.Reversed()),
73 theFace, aFirst, aLast);
75 myCOnSurfGeom.Init(aC3d, aS, aFirst, aLast);
78 //=======================================================================
80 //purpose : if isTheMTDisabled == TRUE parallelization is not used
81 //=======================================================================
82 void BRepLib_CheckCurveOnSurface::Perform(const Standard_Boolean isTheMTDisabled)
84 // Compute the max distance
85 Compute(myPCurve, isTheMTDisabled);
91 if (!myPCurve2.IsNull())
93 // compute max distance for myPCurve2
94 // (for the second curve on closed surface)
95 Compute(myPCurve2, isTheMTDisabled);
99 //=======================================================================
101 //purpose : if isTheMTDisabled == TRUE parallelization is not used
102 //=======================================================================
103 void BRepLib_CheckCurveOnSurface::Compute(const Handle(Geom2d_Curve)& thePCurve,
104 const Standard_Boolean isTheMTDisabled)
106 myCOnSurfGeom.Perform(thePCurve, isTheMTDisabled);