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 | |
9ae88397 |
15 | #include <Adaptor3d_CurveOnSurface.hxx> |
769fb6a4 |
16 | #include <BRep_Tool.hxx> |
9ae88397 |
17 | #include <BRepAdaptor_Curve.hxx> |
42cf5bc1 |
18 | #include <BRepLib_CheckCurveOnSurface.hxx> |
9ae88397 |
19 | #include <GeomAdaptor_Surface.hxx> |
20 | #include <Geom2dAdaptor_Curve.hxx> |
42cf5bc1 |
21 | #include <Geom_Surface.hxx> |
769fb6a4 |
22 | #include <Standard_ErrorHandler.hxx> |
769fb6a4 |
23 | #include <TopoDS.hxx> |
42cf5bc1 |
24 | #include <TopoDS_Edge.hxx> |
25 | #include <TopoDS_Face.hxx> |
92efcf78 |
26 | #include <Geom_Curve.hxx> |
769fb6a4 |
27 | |
1b7ae951 |
28 | //======================================================================= |
29 | //function : BRepLib_CheckCurveOnSurface |
30 | //purpose : |
31 | //======================================================================= |
32 | BRepLib_CheckCurveOnSurface::BRepLib_CheckCurveOnSurface |
5adae760 |
33 | ( const TopoDS_Edge& theEdge, |
34 | const TopoDS_Face& theFace) |
1b7ae951 |
35 | { |
36 | Init(theEdge, theFace); |
37 | } |
38 | |
1b7ae951 |
39 | //======================================================================= |
40 | //function : Init |
41 | //purpose : |
42 | //======================================================================= |
9ae88397 |
43 | void BRepLib_CheckCurveOnSurface::Init(const TopoDS_Edge& theEdge, const TopoDS_Face& theFace) |
1b7ae951 |
44 | { |
5adae760 |
45 | myCOnSurfGeom.Init(); |
769fb6a4 |
46 | |
5adae760 |
47 | if (theEdge.IsNull() || theFace.IsNull()) |
48 | { |
1b7ae951 |
49 | return; |
50 | } |
51 | // |
52 | if (BRep_Tool::Degenerated(theEdge) || |
5adae760 |
53 | !BRep_Tool::IsGeometric(theEdge)) |
54 | { |
1b7ae951 |
55 | return; |
56 | } |
5adae760 |
57 | |
1b7ae951 |
58 | // 3D curve initialization |
9ae88397 |
59 | const Handle(Adaptor3d_Curve) anAdaptor3dCurve = new BRepAdaptor_Curve(theEdge); |
769fb6a4 |
60 | |
1b7ae951 |
61 | // Surface initialization |
9ae88397 |
62 | |
63 | TopLoc_Location aLocation; |
64 | Standard_Real aFirstParam, aLastParam; |
65 | |
66 | Handle(Geom2d_Curve) aGeom2dCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirstParam, aLastParam); |
67 | Handle(Geom_Surface) aGeomSurface = BRep_Tool::Surface(theFace); |
68 | |
1b7ae951 |
69 | // 2D curves initialization |
9ae88397 |
70 | Handle(Adaptor2d_Curve2d) anAdaptorCurve = |
71 | new Geom2dAdaptor_Curve(aGeom2dCurve, aFirstParam, aLastParam); |
72 | Handle(GeomAdaptor_Surface) aGeomAdaptorSurface = new GeomAdaptor_Surface(aGeomSurface); |
73 | |
74 | myAdaptorCurveOnSurface = new Adaptor3d_CurveOnSurface(anAdaptorCurve, aGeomAdaptorSurface); |
769fb6a4 |
75 | |
76 | if(BRep_Tool::IsClosed(theEdge, theFace)) |
9ae88397 |
77 | { |
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); |
83 | } |
1b7ae951 |
84 | |
9ae88397 |
85 | myCOnSurfGeom.Init(anAdaptor3dCurve); |
1b7ae951 |
86 | } |
87 | |
88 | //======================================================================= |
89 | //function : Perform |
769fb6a4 |
90 | //purpose : if isTheMTDisabled == TRUE parallelization is not used |
1b7ae951 |
91 | //======================================================================= |
c9337e33 |
92 | void BRepLib_CheckCurveOnSurface::Perform(const Standard_Boolean isMultiThread) |
1b7ae951 |
93 | { |
5adae760 |
94 | // Compute the max distance |
9ae88397 |
95 | Compute(myAdaptorCurveOnSurface, isMultiThread); |
5adae760 |
96 | if (ErrorStatus()) |
769fb6a4 |
97 | { |
769fb6a4 |
98 | return; |
99 | } |
1b7ae951 |
100 | // |
9ae88397 |
101 | if (!myAdaptorCurveOnSurface2.IsNull()) |
769fb6a4 |
102 | { |
9ae88397 |
103 | // compute max distance for myAdaptorCurveOnSurface2 |
5adae760 |
104 | // (for the second curve on closed surface) |
9ae88397 |
105 | Compute(myAdaptorCurveOnSurface2, isMultiThread); |
769fb6a4 |
106 | } |
1b7ae951 |
107 | } |
108 | |
109 | //======================================================================= |
5adae760 |
110 | //function : Compute |
111 | //purpose : if isTheMTDisabled == TRUE parallelization is not used |
1b7ae951 |
112 | //======================================================================= |
9ae88397 |
113 | void BRepLib_CheckCurveOnSurface::Compute(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface, |
c9337e33 |
114 | const Standard_Boolean isMultiThread) |
1b7ae951 |
115 | { |
9ae88397 |
116 | myCOnSurfGeom.Perform(theCurveOnSurface, isMultiThread); |
1b7ae951 |
117 | } |