1 // Created on: 1993-07-07
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _BRep_Tool_HeaderFile
18 #define _BRep_Tool_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <GeomAbs_Shape.hxx>
25 #include <Geom_Surface.hxx>
26 #include <Geom_Curve.hxx>
27 #include <Geom2d_Curve.hxx>
28 #include <gp_Pnt2d.hxx>
30 #include <Poly_Triangulation.hxx>
31 #include <Poly_Polygon3D.hxx>
32 #include <Poly_Polygon2D.hxx>
33 #include <Poly_PolygonOnTriangulation.hxx>
34 #include <TopAbs_ShapeEnum.hxx>
38 class TopLoc_Location;
43 //! Provides class methods to access to the geometry
52 //! If S is Shell, returns True if it has no free boundaries (edges).
53 //! If S is Wire, returns True if it has no free ends (vertices).
54 //! (Internal and External sub-shepes are ignored in these checks)
55 //! If S is Edge, returns True if its vertices are the same.
56 //! For other shape types returns S.Closed().
57 Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Shape& S);
59 //! Returns the geometric surface of the face. Returns
60 //! in <L> the location for the surface.
61 Standard_EXPORT static const Handle(Geom_Surface)& Surface (const TopoDS_Face& F, TopLoc_Location& L);
63 //! Returns the geometric surface of the face. It can
64 //! be a copy if there is a Location.
65 Standard_EXPORT static Handle(Geom_Surface) Surface (const TopoDS_Face& F);
67 //! Returns the Triangulation of the face. It is a
68 //! null handle if there is no triangulation.
69 Standard_EXPORT static const Handle(Poly_Triangulation)& Triangulation (const TopoDS_Face& F, TopLoc_Location& L);
71 //! Returns the tolerance of the face.
72 Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Face& F);
74 //! Returns the NaturalRestriction flag of the face.
75 Standard_EXPORT static Standard_Boolean NaturalRestriction (const TopoDS_Face& F);
77 //! Returns True if <F> has a surface, false otherwise.
78 Standard_EXPORT static Standard_Boolean IsGeometric (const TopoDS_Face& F);
80 //! Returns True if <E> is a 3d curve or a curve on
82 Standard_EXPORT static Standard_Boolean IsGeometric (const TopoDS_Edge& E);
84 //! Returns the 3D curve of the edge. May be a Null
85 //! handle. Returns in <L> the location for the curve.
86 //! In <First> and <Last> the parameter range.
87 Standard_EXPORT static const Handle(Geom_Curve)& Curve (const TopoDS_Edge& E, TopLoc_Location& L, Standard_Real& First, Standard_Real& Last);
89 //! Returns the 3D curve of the edge. May be a Null handle.
90 //! In <First> and <Last> the parameter range.
91 //! It can be a copy if there is a Location.
92 Standard_EXPORT static Handle(Geom_Curve) Curve (const TopoDS_Edge& E, Standard_Real& First, Standard_Real& Last);
94 //! Returns the 3D polygon of the edge. May be a Null
95 //! handle. Returns in <L> the location for the polygon.
96 Standard_EXPORT static const Handle(Poly_Polygon3D)& Polygon3D (const TopoDS_Edge& E, TopLoc_Location& L);
98 //! Returns the curve associated to the edge in the
99 //! parametric space of the face. Returns a NULL
100 //! handle if this curve does not exist. Returns in
101 //! <First> and <Last> the parameter range.
102 //! If the surface is a plane the curve can be not stored but created a new
103 //! each time. The flag pointed by <theIsStored> serves to indicate storage status.
104 //! It is valued if the pointer is non-null.
105 Standard_EXPORT static Handle(Geom2d_Curve) CurveOnSurface (const TopoDS_Edge& E,
106 const TopoDS_Face& F,
107 Standard_Real& First,
109 Standard_Boolean* theIsStored = NULL);
111 //! Returns the curve associated to the edge in the
112 //! parametric space of the surface. Returns a NULL
113 //! handle if this curve does not exist. Returns in
114 //! <First> and <Last> the parameter range.
115 //! If the surface is a plane the curve can be not stored but created a new
116 //! each time. The flag pointed by <theIsStored> serves to indicate storage status.
117 //! It is valued if the pointer is non-null.
118 Standard_EXPORT static Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
119 const Handle(Geom_Surface)& S,
120 const TopLoc_Location& L,
121 Standard_Real& First,
123 Standard_Boolean* theIsStored = NULL);
125 //! For the planar surface builds the 2d curve for the edge
126 //! by projection of the edge on plane.
127 //! Returns a NULL handle if the surface is not planar or
128 //! the projection failed.
129 Standard_EXPORT static Handle(Geom2d_Curve) CurveOnPlane (const TopoDS_Edge& E,
130 const Handle(Geom_Surface)& S,
131 const TopLoc_Location& L,
132 Standard_Real& First,
133 Standard_Real& Last);
135 //! Returns in <C>, <S>, <L> a 2d curve, a surface and
136 //! a location for the edge <E>. <C> and <S> are null
137 //! if the edge has no curve on surface. Returns in
138 //! <First> and <Last> the parameter range.
139 Standard_EXPORT static void CurveOnSurface (const TopoDS_Edge& E, Handle(Geom2d_Curve)& C, Handle(Geom_Surface)& S, TopLoc_Location& L, Standard_Real& First, Standard_Real& Last);
141 //! Returns in <C>, <S>, <L> the 2d curve, the surface
142 //! and the location for the edge <E> of rank <Index>.
143 //! <C> and <S> are null if the index is out of range.
144 //! Returns in <First> and <Last> the parameter range.
145 Standard_EXPORT static void CurveOnSurface (const TopoDS_Edge& E, Handle(Geom2d_Curve)& C, Handle(Geom_Surface)& S, TopLoc_Location& L, Standard_Real& First, Standard_Real& Last, const Standard_Integer Index);
147 //! Returns the polygon associated to the edge in the
148 //! parametric space of the face. Returns a NULL
149 //! handle if this polygon does not exist.
150 Standard_EXPORT static Handle(Poly_Polygon2D) PolygonOnSurface (const TopoDS_Edge& E, const TopoDS_Face& F);
152 //! Returns the polygon associated to the edge in the
153 //! parametric space of the surface. Returns a NULL
154 //! handle if this polygon does not exist.
155 Standard_EXPORT static Handle(Poly_Polygon2D) PolygonOnSurface (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
157 //! Returns in <C>, <S>, <L> a 2d curve, a surface and
158 //! a location for the edge <E>. <C> and <S> are null
159 //! if the edge has no polygon on surface.
160 Standard_EXPORT static void PolygonOnSurface (const TopoDS_Edge& E, Handle(Poly_Polygon2D)& C, Handle(Geom_Surface)& S, TopLoc_Location& L);
162 //! Returns in <C>, <S>, <L> the 2d curve, the surface
163 //! and the location for the edge <E> of rank <Index>.
164 //! <C> and <S> are null if the index is out of range.
165 Standard_EXPORT static void PolygonOnSurface (const TopoDS_Edge& E, Handle(Poly_Polygon2D)& C, Handle(Geom_Surface)& S, TopLoc_Location& L, const Standard_Integer Index);
167 //! Returns the polygon associated to the edge in the
168 //! parametric space of the face. Returns a NULL
169 //! handle if this polygon does not exist.
170 Standard_EXPORT static const Handle(Poly_PolygonOnTriangulation)& PolygonOnTriangulation (const TopoDS_Edge& E, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L);
172 //! Returns in <P>, <T>, <L> a polygon on triangulation, a
173 //! triangulation and a location for the edge <E>.
174 //! <P> and <T> are null if the edge has no
175 //! polygon on triangulation.
176 Standard_EXPORT static void PolygonOnTriangulation (const TopoDS_Edge& E, Handle(Poly_PolygonOnTriangulation)& P, Handle(Poly_Triangulation)& T, TopLoc_Location& L);
178 //! Returns in <P>, <T>, <L> a polygon on
179 //! triangulation, a triangulation and a location for
180 //! the edge <E> for the range index. <C> and <S> are
181 //! null if the edge has no polygon on triangulation.
182 Standard_EXPORT static void PolygonOnTriangulation (const TopoDS_Edge& E, Handle(Poly_PolygonOnTriangulation)& P, Handle(Poly_Triangulation)& T, TopLoc_Location& L, const Standard_Integer Index);
184 //! Returns True if <E> has two PCurves in the
185 //! parametric space of <F>. i.e. <F> is on a closed
186 //! surface and <E> is on the closing curve.
187 Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const TopoDS_Face& F);
189 //! Returns True if <E> has two PCurves in the
190 //! parametric space of <S>. i.e. <S> is a closed
191 //! surface and <E> is on the closing curve.
192 Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
194 //! Returns True if <E> has two arrays of indices in
195 //! the triangulation <T>.
196 Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L);
198 //! Returns the tolerance for <E>.
199 Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Edge& E);
201 //! Returns the SameParameter flag for the edge.
202 Standard_EXPORT static Standard_Boolean SameParameter (const TopoDS_Edge& E);
204 //! Returns the SameRange flag for the edge.
205 Standard_EXPORT static Standard_Boolean SameRange (const TopoDS_Edge& E);
207 //! Returns True if the edge is degenerated.
208 Standard_EXPORT static Standard_Boolean Degenerated (const TopoDS_Edge& E);
210 //! Gets the range of the 3d curve.
211 Standard_EXPORT static void Range (const TopoDS_Edge& E, Standard_Real& First, Standard_Real& Last);
213 //! Gets the range of the edge on the pcurve on the
215 Standard_EXPORT static void Range (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, Standard_Real& First, Standard_Real& Last);
217 //! Gets the range of the edge on the pcurve on the face.
218 Standard_EXPORT static void Range (const TopoDS_Edge& E, const TopoDS_Face& F, Standard_Real& First, Standard_Real& Last);
220 //! Gets the UV locations of the extremities of the edge.
221 Standard_EXPORT static void UVPoints (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, gp_Pnt2d& PFirst, gp_Pnt2d& PLast);
223 //! Gets the UV locations of the extremities of the edge.
224 Standard_EXPORT static void UVPoints (const TopoDS_Edge& E, const TopoDS_Face& F, gp_Pnt2d& PFirst, gp_Pnt2d& PLast);
226 //! Sets the UV locations of the extremities of the edge.
227 Standard_EXPORT static void SetUVPoints (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const gp_Pnt2d& PFirst, const gp_Pnt2d& PLast);
229 //! Sets the UV locations of the extremities of the edge.
230 Standard_EXPORT static void SetUVPoints (const TopoDS_Edge& E, const TopoDS_Face& F, const gp_Pnt2d& PFirst, const gp_Pnt2d& PLast);
232 //! Returns True if the edge is on the surfaces of the
234 Standard_EXPORT static Standard_Boolean HasContinuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2);
236 //! Returns the continuity.
237 Standard_EXPORT static GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2);
239 //! Returns True if the edge is on the surfaces.
240 Standard_EXPORT static Standard_Boolean HasContinuity (const TopoDS_Edge& E, const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const TopLoc_Location& L1, const TopLoc_Location& L2);
242 //! Returns the continuity.
243 Standard_EXPORT static GeomAbs_Shape Continuity (const TopoDS_Edge& E, const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const TopLoc_Location& L1, const TopLoc_Location& L2);
245 //! Returns True if the edge has regularity on some
247 Standard_EXPORT static Standard_Boolean HasContinuity (const TopoDS_Edge& E);
249 //! Returns the max continuity of edge between some surfaces or GeomAbs_C0 if there no such surfaces.
250 Standard_EXPORT static GeomAbs_Shape MaxContinuity (const TopoDS_Edge& theEdge);
252 //! Returns the 3d point.
253 Standard_EXPORT static gp_Pnt Pnt (const TopoDS_Vertex& V);
255 //! Returns the tolerance.
256 Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Vertex& V);
258 //! Finds the parameter of <theV> on <theE>.
259 //! @param theV [in] input vertex
260 //! @param theE [in] input edge
261 //! @param theParam [out] calculated parameter on the curve
262 //! @return TRUE if done
263 Standard_EXPORT static Standard_Boolean Parameter (const TopoDS_Vertex& theV,
264 const TopoDS_Edge& theE,
265 Standard_Real &theParam);
267 //! Returns the parameter of <V> on <E>.
268 //! Throws Standard_NoSuchObject if no parameter on edge
269 Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E);
271 //! Returns the parameters of the vertex on the
272 //! pcurve of the edge on the face.
273 Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E, const TopoDS_Face& F);
275 //! Returns the parameters of the vertex on the
276 //! pcurve of the edge on the surface.
277 Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
279 //! Returns the parameters of the vertex on the face.
280 Standard_EXPORT static gp_Pnt2d Parameters (const TopoDS_Vertex& V, const TopoDS_Face& F);
282 //! Returns the maximum tolerance of input shape subshapes.
283 //@param theShape - Shape to search tolerance.
284 //@param theSubShape - Search subshape, only Face, Edge or Vertex are supported.
285 Standard_EXPORT static Standard_Real MaxTolerance (const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theSubShape);
289 #endif // _BRep_Tool_HeaderFile