1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-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 #ifndef _BOPTools_AlgoTools2D_HeaderFile
16 #define _BOPTools_AlgoTools2D_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
22 #include <Standard_Boolean.hxx>
23 #include <Standard_Real.hxx>
24 #include <BOPCol_ListOfShape.hxx>
25 #include <Standard_Integer.hxx>
31 class BRepAdaptor_Surface;
32 class ProjLib_ProjectedCurve;
33 class IntTools_Context;
37 //! The class contains handy static functions
38 //! dealing with the topology
39 //! This is the copy of the BOPTools_AlgoTools2D.cdl
40 class BOPTools_AlgoTools2D
48 //! Compute P-Curve for the edge <aE> on the face <aF>.<br>
49 //! Raises exception Standard_ConstructionError if projection algorithm fails.<br>
50 //! <theContext> - storage for caching the geometrical tools
51 Standard_EXPORT static void BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
52 const TopoDS_Face& aF,
53 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
56 //! Compute tangent for the edge <aE> [in 3D] at parameter <aT>
57 Standard_EXPORT static Standard_Boolean EdgeTangent (const TopoDS_Edge& anE, const Standard_Real aT, gp_Vec& Tau);
60 //! Compute surface parameters <U,V> of the face <aF>
61 //! for the point from the edge <aE> at parameter <aT>.<br>
62 //! If <aE> has't pcurve on surface, algorithm tries to get it by
63 //! projection and can
64 //! raise exception Standard_ConstructionError if projection algorithm fails.<br>
65 //! <theContext> - storage for caching the geometrical tools
66 Standard_EXPORT static void PointOnSurface (const TopoDS_Edge& aE,
67 const TopoDS_Face& aF,
68 const Standard_Real aT,
71 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
74 //! Get P-Curve <aC> for the edge <aE> on surface <aF> .<br>
75 //! If the P-Curve does not exist, build it using Make2D().<br>
76 //! [aToler] - reached tolerance
77 //! Raises exception Standard_ConstructionError if algorithm Make2D() fails.<br>
78 //! <theContext> - storage for caching the geometrical tools
79 Standard_EXPORT static void CurveOnSurface (const TopoDS_Edge& aE,
80 const TopoDS_Face& aF,
81 Handle(Geom2d_Curve)& aC,
82 Standard_Real& aToler,
83 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
85 //! Get P-Curve <aC> for the edge <aE> on surface <aF> .<br>
86 //! If the P-Curve does not exist, build it using Make2D().<br>
87 //! [aFirst, aLast] - range of the P-Curve<br>
88 //! [aToler] - reached tolerance<br>
89 //! Raises exception Standard_ConstructionError if algorithm Make2D() fails.<br>
90 //! <theContext> - storage for caching the geometrical tools
91 Standard_EXPORT static void CurveOnSurface (const TopoDS_Edge& aE,
92 const TopoDS_Face& aF,
93 Handle(Geom2d_Curve)& aC,
94 Standard_Real& aFirst,
96 Standard_Real& aToler,
97 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
100 //! Returns TRUE if the edge <aE> has P-Curve <aC>
101 //! on surface <aF> .
102 //! [aFirst, aLast] - range of the P-Curve
103 //! [aToler] - reached tolerance
104 //! If the P-Curve does not exist, aC.IsNull()=TRUE.
105 Standard_EXPORT static Standard_Boolean HasCurveOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF, Handle(Geom2d_Curve)& aC, Standard_Real& aFirst, Standard_Real& aLast, Standard_Real& aToler);
108 //! Returns TRUE if the edge <aE> has P-Curve <aC>
109 //! on surface <aF> .
110 //! If the P-Curve does not exist, aC.IsNull()=TRUE.
111 Standard_EXPORT static Standard_Boolean HasCurveOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF);
114 //! Adjust P-Curve <theC2D> (3D-curve <theC3D>) on surface of the face <theF>.<br>
115 //! <theContext> - storage for caching the geometrical tools
116 Standard_EXPORT static void AdjustPCurveOnFace (const TopoDS_Face& theF,
117 const Handle(Geom_Curve)& theC3D,
118 const Handle(Geom2d_Curve)& theC2D,
119 Handle(Geom2d_Curve)& theC2DA,
120 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
123 //! Adjust P-Curve <aC2D> (3D-curve <C3D>) on surface <aF> .<br>
124 //! [aT1, aT2] - range to adjust<br>
125 //! <theContext> - storage for caching the geometrical tools
126 Standard_EXPORT static void AdjustPCurveOnFace (const TopoDS_Face& theF,
127 const Standard_Real theFirst,
128 const Standard_Real theLast,
129 const Handle(Geom2d_Curve)& theC2D,
130 Handle(Geom2d_Curve)& theC2DA,
131 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
133 //! Adjust P-Curve <aC2D> (3D-curve <C3D>) on surface <aF> .
134 //! [aT1, aT2] - range to adjust
135 Standard_EXPORT static void AdjustPCurveOnSurf (const BRepAdaptor_Surface& aF, const Standard_Real aT1, const Standard_Real aT2, const Handle(Geom2d_Curve)& aC2D, Handle(Geom2d_Curve)& aC2DA);
138 //! Compute intermediate value in between [aFirst, aLast] .
139 Standard_EXPORT static Standard_Real IntermediatePoint (const Standard_Real aFirst, const Standard_Real aLast);
142 //! Compute intermediate value of parameter for the edge <anE>.
143 Standard_EXPORT static Standard_Real IntermediatePoint (const TopoDS_Edge& anE);
145 //! Build pcurve of edge on face if the surface is plane, and update the edge.
146 Standard_EXPORT static void BuildPCurveForEdgeOnPlane (const TopoDS_Edge& theE, const TopoDS_Face& theF);
148 //! Build pcurve of edge on face if the surface is plane, but do not update the edge.
149 //! The output are the pcurve and the flag telling that pcurve was built.
150 Standard_EXPORT static void BuildPCurveForEdgeOnPlane (const TopoDS_Edge& theE, const TopoDS_Face& theF,
151 Handle(Geom2d_Curve)& aC2D, Standard_Boolean& bToUpdate);
153 Standard_EXPORT static void BuildPCurveForEdgesOnPlane (const BOPCol_ListOfShape& theLE, const TopoDS_Face& theF);
156 //! Make P-Curve <aC> for the edge <aE> on surface <aF> .<br>
157 //! [aFirst, aLast] - range of the P-Curve<br>
158 //! [aToler] - reached tolerance<br>
159 //! Raises exception Standard_ConstructionError if algorithm fails.<br>
160 //! <theContext> - storage for caching the geometrical tools
161 Standard_EXPORT static void Make2D (const TopoDS_Edge& aE,
162 const TopoDS_Face& aF,
163 Handle(Geom2d_Curve)& aC,
164 Standard_Real& aFirst,
165 Standard_Real& aLast,
166 Standard_Real& aToler,
167 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
170 //! Make P-Curve <aC> for the 3D-curve <C3D> on surface <aF> .<br>
171 //! [aToler] - reached tolerance<br>
172 //! Raises exception Standard_ConstructionError if projection algorithm fails.<br>
173 //! <theContext> - storage for caching the geometrical tools
174 Standard_EXPORT static void MakePCurveOnFace (const TopoDS_Face& aF,
175 const Handle(Geom_Curve)& C3D,
176 Handle(Geom2d_Curve)& aC,
177 Standard_Real& aToler,
178 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
181 //! Make P-Curve <aC> for the 3D-curve <C3D> on surface <aF> .<br>
182 //! [aT1, aT2] - range to build<br>
183 //! [aToler] - reached tolerance<br>
184 //! Raises exception Standard_ConstructionError if projection algorithm fails.<br>
185 //! <theContext> - storage for caching the geometrical tools
186 Standard_EXPORT static void MakePCurveOnFace (const TopoDS_Face& aF,
187 const Handle(Geom_Curve)& C3D,
188 const Standard_Real aT1,
189 const Standard_Real aT2,
190 Handle(Geom2d_Curve)& aC,
191 Standard_Real& aToler,
192 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
194 //! Attach P-Curve from the edge <aEold> on surface <aF>
195 //! to the edge <aEnew>
196 //! Returns 0 in case of success
197 Standard_EXPORT static Standard_Integer AttachExistingPCurve (const TopoDS_Edge& aEold, const TopoDS_Edge& aEnew, const TopoDS_Face& aF, const Handle(IntTools_Context)& aCtx);
199 //! Checks if CurveOnSurface of theE on theF matches with isoline of theF surface.
200 //! Sets corresponding values for isTheUIso and isTheVIso variables.
202 //! This method is based on comparation between direction of
203 //! surface (which theF is based on) iso-lines and the direction
204 //! of the edge p-curve (on theF) in middle-point of the p-curve.
205 //! This method should be used carefully
206 //! (e.g. BRep_Tool::IsClosed(...) together) in order to
207 //! avoid false classification some p-curves as isoline (e.g. circle
209 Standard_EXPORT static void IsEdgeIsoline(const TopoDS_Edge& theE,
210 const TopoDS_Face& theF,
211 Standard_Boolean& isTheUIso,
212 Standard_Boolean& isTheVIso);
235 #endif // _BOPTools_AlgoTools2D_HeaderFile