0027092: Coding - src/BRep/BRep_Tool.hxx extra semicolon triggers annoying warnings...
[occt.git] / src / BRep / BRep_Tool.hxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _BRep_Tool_HeaderFile
18 #define _BRep_Tool_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
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>
29 #include <gp_Pnt.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>
35
36 class TopoDS_Shape;
37 class TopoDS_Face;
38 class TopLoc_Location;
39 class TopoDS_Edge;
40 class TopoDS_Vertex;
41
42
43 //! Provides class methods  to  access to the geometry
44 //! of BRep shapes.
45 class BRep_Tool 
46 {
47 public:
48
49   DEFINE_STANDARD_ALLOC
50
51   
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);
58   
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);
62   
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);
66   
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);
70   
71   //! Returns the tolerance of the face.
72   Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Face& F);
73   
74   //! Returns the  NaturalRestriction  flag of the  face.
75   Standard_EXPORT static Standard_Boolean NaturalRestriction (const TopoDS_Face& F);
76   
77   //! Returns True if <E> is a 3d curve or a curve on
78   //! surface.
79   Standard_EXPORT static Standard_Boolean IsGeometric (const TopoDS_Edge& E);
80   
81   //! Returns the 3D curve  of the edge.  May be  a Null
82   //! handle. Returns in <L> the location for the curve.
83   //! In <First> and <Last> the parameter range.
84   Standard_EXPORT static const Handle(Geom_Curve)& Curve (const TopoDS_Edge& E, TopLoc_Location& L, Standard_Real& First, Standard_Real& Last);
85   
86   //! Returns the 3D curve  of the edge. May be a Null handle.
87   //! In <First> and <Last> the parameter range.
88   //! It can be a copy if there is a Location.
89   Standard_EXPORT static Handle(Geom_Curve) Curve (const TopoDS_Edge& E, Standard_Real& First, Standard_Real& Last);
90   
91   //! Returns the 3D polygon of the edge. May be   a Null
92   //! handle. Returns in <L> the location for the polygon.
93   Standard_EXPORT static const Handle(Poly_Polygon3D)& Polygon3D (const TopoDS_Edge& E, TopLoc_Location& L);
94   
95   //! Returns the curve  associated to the  edge in  the
96   //! parametric  space of  the  face.  Returns   a NULL
97   //! handle  if this curve  does not exist.  Returns in
98   //! <First> and <Last> the parameter range.
99   Standard_EXPORT static Handle(Geom2d_Curve) CurveOnSurface (const TopoDS_Edge& E, const TopoDS_Face& F, Standard_Real& First, Standard_Real& Last);
100   
101   //! Returns the  curve associated to   the edge in the
102   //! parametric  space of the   surface. Returns a NULL
103   //! handle  if this curve does  not exist.  Returns in
104   //! <First> and <Last> the parameter range.
105   Standard_EXPORT static Handle(Geom2d_Curve) CurveOnSurface (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, Standard_Real& First, Standard_Real& Last);
106   
107   //! Returns in <C>, <S>, <L> a 2d curve, a surface and
108   //! a location for the edge <E>. <C> and <S>  are null
109   //! if the  edge has no curve on  surface.  Returns in
110   //! <First> and <Last> the parameter range.
111   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);
112   
113   //! Returns in <C>, <S>, <L> the 2d curve, the surface
114   //! and the location for the edge <E> of rank <Index>.
115   //! <C> and <S> are null if the index is out of range.
116   //! Returns in <First> and <Last> the parameter range.
117   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);
118   
119   //! Returns the polygon associated to the  edge in  the
120   //! parametric  space of  the  face.  Returns   a NULL
121   //! handle  if this polygon  does not exist.
122   Standard_EXPORT static Handle(Poly_Polygon2D) PolygonOnSurface (const TopoDS_Edge& E, const TopoDS_Face& F);
123   
124   //! Returns the polygon associated to the  edge in  the
125   //! parametric  space of  the surface. Returns   a NULL
126   //! handle  if this polygon  does not exist.
127   Standard_EXPORT static Handle(Poly_Polygon2D) PolygonOnSurface (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
128   
129   //! Returns in <C>, <S>, <L> a 2d curve, a surface and
130   //! a location for the edge <E>. <C> and <S>  are null
131   //! if the  edge has no polygon on  surface.
132   Standard_EXPORT static void PolygonOnSurface (const TopoDS_Edge& E, Handle(Poly_Polygon2D)& C, Handle(Geom_Surface)& S, TopLoc_Location& L);
133   
134   //! Returns in <C>, <S>, <L> the 2d curve, the surface
135   //! and the location for the edge <E> of rank <Index>.
136   //! <C> and <S> are null if the index is out of range.
137   Standard_EXPORT static void PolygonOnSurface (const TopoDS_Edge& E, Handle(Poly_Polygon2D)& C, Handle(Geom_Surface)& S, TopLoc_Location& L, const Standard_Integer Index);
138   
139   //! Returns the polygon associated to the  edge in  the
140   //! parametric  space of  the  face.  Returns   a NULL
141   //! handle  if this polygon  does not exist.
142   Standard_EXPORT static const Handle(Poly_PolygonOnTriangulation)& PolygonOnTriangulation (const TopoDS_Edge& E, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L);
143   
144   //! Returns in <P>, <T>, <L> a polygon on triangulation, a
145   //! triangulation and a location for the edge <E>.
146   //! <P>  and  <T>  are null  if  the  edge has no
147   //! polygon on  triangulation.
148   Standard_EXPORT static void PolygonOnTriangulation (const TopoDS_Edge& E, Handle(Poly_PolygonOnTriangulation)& P, Handle(Poly_Triangulation)& T, TopLoc_Location& L);
149   
150   //! Returns   in   <P>,  <T>,    <L> a     polygon  on
151   //! triangulation,   a triangulation  and a  location for
152   //! the edge <E> for the range index.  <C> and <S> are
153   //! null if the edge has no polygon on triangulation.
154   Standard_EXPORT static void PolygonOnTriangulation (const TopoDS_Edge& E, Handle(Poly_PolygonOnTriangulation)& P, Handle(Poly_Triangulation)& T, TopLoc_Location& L, const Standard_Integer Index);
155   
156   //! Returns  True  if  <E>  has  two  PCurves  in  the
157   //! parametric space of <F>. i.e.  <F>  is on a closed
158   //! surface and <E> is on the closing curve.
159   Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const TopoDS_Face& F);
160   
161   //! Returns  True  if  <E>  has  two  PCurves  in  the
162   //! parametric space  of <S>.  i.e.   <S>  is a closed
163   //! surface and <E> is on the closing curve.
164   Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
165   
166   //! Returns  True  if <E> has two arrays of indices in
167   //! the triangulation <T>.
168   Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L);
169   
170   //! Returns the tolerance for <E>.
171   Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Edge& E);
172   
173   //! Returns the SameParameter flag for the edge.
174   Standard_EXPORT static Standard_Boolean SameParameter (const TopoDS_Edge& E);
175   
176   //! Returns the SameRange flag for the edge.
177   Standard_EXPORT static Standard_Boolean SameRange (const TopoDS_Edge& E);
178   
179   //! Returns True  if the edge is degenerated.
180   Standard_EXPORT static Standard_Boolean Degenerated (const TopoDS_Edge& E);
181   
182   //! Gets the range of the 3d curve.
183   Standard_EXPORT static void Range (const TopoDS_Edge& E, Standard_Real& First, Standard_Real& Last);
184   
185   //! Gets the range  of the edge  on the pcurve on  the
186   //! surface.
187   Standard_EXPORT static void Range (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, Standard_Real& First, Standard_Real& Last);
188   
189   //! Gets the range of the edge on the pcurve on the face.
190   Standard_EXPORT static void Range (const TopoDS_Edge& E, const TopoDS_Face& F, Standard_Real& First, Standard_Real& Last);
191   
192   //! Gets the UV locations of the extremities of the edge.
193   Standard_EXPORT static void UVPoints (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, gp_Pnt2d& PFirst, gp_Pnt2d& PLast);
194   
195   //! Gets the UV locations of the extremities of the edge.
196   Standard_EXPORT static void UVPoints (const TopoDS_Edge& E, const TopoDS_Face& F, gp_Pnt2d& PFirst, gp_Pnt2d& PLast);
197   
198   //! Sets the UV locations of the extremities of the edge.
199   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);
200   
201   //! Sets the UV locations of the extremities of the edge.
202   Standard_EXPORT static void SetUVPoints (const TopoDS_Edge& E, const TopoDS_Face& F, const gp_Pnt2d& PFirst, const gp_Pnt2d& PLast);
203   
204   //! Returns True if the edge is on the surfaces of the
205   //! two faces.
206   Standard_EXPORT static Standard_Boolean HasContinuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2);
207   
208   //! Returns the continuity.
209   Standard_EXPORT static GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2);
210   
211   //! Returns True if the edge is on the surfaces.
212   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);
213   
214   //! Returns the continuity.
215   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);
216   
217   //! Returns True if the edge has regularity on some
218   //! two surfaces
219   Standard_EXPORT static Standard_Boolean HasContinuity (const TopoDS_Edge& E);
220   
221   //! Returns the 3d point.
222   Standard_EXPORT static gp_Pnt Pnt (const TopoDS_Vertex& V);
223   
224   //! Returns the tolerance.
225   Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Vertex& V);
226   
227   //! Returns the parameter of <V> on <E>.
228   Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E);
229   
230   //! Returns the  parameters  of   the  vertex   on the
231   //! pcurve of the edge on the face.
232   Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E, const TopoDS_Face& F);
233   
234   //! Returns the  parameters  of   the  vertex   on the
235   //! pcurve of the edge on the surface.
236   Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
237   
238   //! Returns the parameters of the vertex on the face.
239   Standard_EXPORT static gp_Pnt2d Parameters (const TopoDS_Vertex& V, const TopoDS_Face& F);
240
241   //! Returns the maximum tolerance of input shape subshapes.
242   //@param theShape    - Shape to search tolerance.
243   //@param theSubShape - Search subshape, only Face, Edge or Vertex are supported.
244   Standard_EXPORT static Standard_Real MaxTolerance (const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theSubShape);
245
246 };
247
248 #endif // _BRep_Tool_HeaderFile