1b7ae951 |
1 | // Created by: Eugeny MALTCHIKOV |
2 | // Copyright (c) 2014 OPEN CASCADE SAS |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
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. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
769fb6a4 |
15 | #include <BRep_Tool.hxx> |
42cf5bc1 |
16 | #include <BRepLib_CheckCurveOnSurface.hxx> |
42cf5bc1 |
17 | #include <Geom_Surface.hxx> |
769fb6a4 |
18 | #include <Standard_ErrorHandler.hxx> |
769fb6a4 |
19 | #include <TopoDS.hxx> |
42cf5bc1 |
20 | #include <TopoDS_Edge.hxx> |
21 | #include <TopoDS_Face.hxx> |
769fb6a4 |
22 | |
1b7ae951 |
23 | //======================================================================= |
24 | //function : BRepLib_CheckCurveOnSurface |
25 | //purpose : |
26 | //======================================================================= |
27 | BRepLib_CheckCurveOnSurface::BRepLib_CheckCurveOnSurface |
5adae760 |
28 | ( const TopoDS_Edge& theEdge, |
29 | const TopoDS_Face& theFace) |
1b7ae951 |
30 | { |
31 | Init(theEdge, theFace); |
32 | } |
33 | |
1b7ae951 |
34 | //======================================================================= |
35 | //function : Init |
36 | //purpose : |
37 | //======================================================================= |
38 | void BRepLib_CheckCurveOnSurface::Init |
39 | (const TopoDS_Edge& theEdge, |
40 | const TopoDS_Face& theFace) |
41 | { |
5adae760 |
42 | myCOnSurfGeom.Init(); |
769fb6a4 |
43 | |
5adae760 |
44 | if (theEdge.IsNull() || theFace.IsNull()) |
45 | { |
1b7ae951 |
46 | return; |
47 | } |
48 | // |
49 | if (BRep_Tool::Degenerated(theEdge) || |
5adae760 |
50 | !BRep_Tool::IsGeometric(theEdge)) |
51 | { |
1b7ae951 |
52 | return; |
53 | } |
5adae760 |
54 | |
1b7ae951 |
55 | // |
1b7ae951 |
56 | TopLoc_Location aLocE, aLocF, aLocC2D; |
5adae760 |
57 | Standard_Real aFirst = 0.0, aLast = 0.0; |
1b7ae951 |
58 | // |
59 | // 3D curve initialization |
5adae760 |
60 | const Handle(Geom_Curve)& aC3dTmp = BRep_Tool::Curve(theEdge, aLocE, aFirst, aLast); |
61 | const Handle(Geom_Curve) aC3d(Handle(Geom_Curve)::DownCast(aC3dTmp->Transformed(aLocE.Transformation()))); |
769fb6a4 |
62 | |
1b7ae951 |
63 | // Surface initialization |
5adae760 |
64 | const Handle(Geom_Surface)& aSTmp = BRep_Tool::Surface(theFace, aLocF); |
65 | const Handle(Geom_Surface) aS(Handle(Geom_Surface)::DownCast(aSTmp->Transformed(aLocF.Transformation()))); |
1b7ae951 |
66 | // |
67 | // 2D curves initialization |
5adae760 |
68 | myPCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast); |
769fb6a4 |
69 | |
70 | if(BRep_Tool::IsClosed(theEdge, theFace)) |
71 | myPCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(theEdge.Reversed()), |
5adae760 |
72 | theFace, aFirst, aLast); |
1b7ae951 |
73 | |
5adae760 |
74 | myCOnSurfGeom.Init(aC3d, aS, aFirst, aLast); |
1b7ae951 |
75 | } |
76 | |
77 | //======================================================================= |
78 | //function : Perform |
769fb6a4 |
79 | //purpose : if isTheMTDisabled == TRUE parallelization is not used |
1b7ae951 |
80 | //======================================================================= |
769fb6a4 |
81 | void BRepLib_CheckCurveOnSurface::Perform(const Standard_Boolean isTheMTDisabled) |
1b7ae951 |
82 | { |
5adae760 |
83 | // Compute the max distance |
84 | Compute(myPCurve, isTheMTDisabled); |
85 | if (ErrorStatus()) |
769fb6a4 |
86 | { |
769fb6a4 |
87 | return; |
88 | } |
1b7ae951 |
89 | // |
5adae760 |
90 | if (!myPCurve2.IsNull()) |
769fb6a4 |
91 | { |
5adae760 |
92 | // compute max distance for myPCurve2 |
93 | // (for the second curve on closed surface) |
94 | Compute(myPCurve2, isTheMTDisabled); |
769fb6a4 |
95 | } |
1b7ae951 |
96 | } |
97 | |
98 | //======================================================================= |
5adae760 |
99 | //function : Compute |
100 | //purpose : if isTheMTDisabled == TRUE parallelization is not used |
1b7ae951 |
101 | //======================================================================= |
5adae760 |
102 | void BRepLib_CheckCurveOnSurface::Compute(const Handle(Geom2d_Curve)& thePCurve, |
103 | const Standard_Boolean isTheMTDisabled) |
1b7ae951 |
104 | { |
5adae760 |
105 | myCOnSurfGeom.Perform(thePCurve, isTheMTDisabled); |
1b7ae951 |
106 | } |