Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:06

0001 // Created on: 1993-07-07
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _BRep_Tool_HeaderFile
0018 #define _BRep_Tool_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <GeomAbs_Shape.hxx>
0025 #include <Geom_Surface.hxx>
0026 #include <Geom_Curve.hxx>
0027 #include <Geom2d_Curve.hxx>
0028 #include <gp_Pnt2d.hxx>
0029 #include <gp_Pnt.hxx>
0030 #include <Poly_ListOfTriangulation.hxx>
0031 #include <Poly_Polygon3D.hxx>
0032 #include <Poly_Polygon2D.hxx>
0033 #include <Poly_PolygonOnTriangulation.hxx>
0034 #include <TopAbs_ShapeEnum.hxx>
0035 
0036 class TopoDS_Shape;
0037 class TopoDS_Face;
0038 class TopLoc_Location;
0039 class TopoDS_Edge;
0040 class TopoDS_Vertex;
0041 
0042 
0043 //! Provides class methods  to  access to the geometry
0044 //! of BRep shapes.
0045 class BRep_Tool 
0046 {
0047 public:
0048 
0049   DEFINE_STANDARD_ALLOC
0050 
0051   
0052   //! If S is Shell, returns True if it has no free boundaries (edges).
0053   //! If S is Wire, returns True if it has no free ends (vertices).
0054   //! (Internal and External sub-shepes are ignored in these checks)
0055   //! If S is Edge, returns True if its vertices are the same.
0056   //! For other shape types returns S.Closed().
0057   Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Shape& S);
0058   
0059   //! Returns the geometric surface of the face. Returns
0060   //! in <L> the location for the surface.
0061   Standard_EXPORT static const Handle(Geom_Surface)& Surface (const TopoDS_Face& F, TopLoc_Location& L);
0062   
0063   //! Returns the geometric  surface of the face. It can
0064   //! be a copy if there is a Location.
0065   Standard_EXPORT static Handle(Geom_Surface) Surface (const TopoDS_Face& F);
0066 
0067   //! Returns the triangulation of the face according to the mesh purpose.
0068   //! @param theFace [in] the input face to find triangulation.
0069   //! @param theLocation [out] the face location.
0070   //! @param theMeshPurpose [in] a mesh purpose to find appropriate triangulation (NONE by default).
0071   //! @return an active triangulation in case of NONE purpose,
0072   //!         the first triangulation appropriate for the input purpose,
0073   //!         just the first triangulation if none matching other criteria and input purpose is AnyFallback
0074   //!         or null handle if there is no any suitable triangulation.
0075   Standard_EXPORT static const Handle(Poly_Triangulation)& Triangulation (const TopoDS_Face& theFace, TopLoc_Location& theLocation,
0076                                                                           const Poly_MeshPurpose theMeshPurpose = Poly_MeshPurpose_NONE);
0077 
0078   //! Returns all triangulations of the face.
0079   //! @param theFace [in] the input face.
0080   //! @param theLocation [out] the face location.
0081   //! @return list of all available face triangulations.
0082   Standard_EXPORT static const Poly_ListOfTriangulation& Triangulations (const TopoDS_Face& theFace, TopLoc_Location& theLocation);
0083 
0084   //! Returns the tolerance of the face.
0085   Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Face& F);
0086   
0087   //! Returns the  NaturalRestriction  flag of the  face.
0088   Standard_EXPORT static Standard_Boolean NaturalRestriction (const TopoDS_Face& F);
0089   
0090   //! Returns True if <F> has a surface, false otherwise.
0091   Standard_EXPORT static Standard_Boolean IsGeometric (const TopoDS_Face& F);
0092 
0093   //! Returns True if <E> is a 3d curve or a curve on
0094   //! surface.
0095   Standard_EXPORT static Standard_Boolean IsGeometric (const TopoDS_Edge& E);
0096   
0097   //! Returns the 3D curve  of the edge.  May be  a Null
0098   //! handle. Returns in <L> the location for the curve.
0099   //! In <First> and <Last> the parameter range.
0100   Standard_EXPORT static const Handle(Geom_Curve)& Curve (const TopoDS_Edge& E, TopLoc_Location& L, Standard_Real& First, Standard_Real& Last);
0101   
0102   //! Returns the 3D curve  of the edge. May be a Null handle.
0103   //! In <First> and <Last> the parameter range.
0104   //! It can be a copy if there is a Location.
0105   Standard_EXPORT static Handle(Geom_Curve) Curve (const TopoDS_Edge& E, Standard_Real& First, Standard_Real& Last);
0106   
0107   //! Returns the 3D polygon of the edge. May be   a Null
0108   //! handle. Returns in <L> the location for the polygon.
0109   Standard_EXPORT static const Handle(Poly_Polygon3D)& Polygon3D (const TopoDS_Edge& E, TopLoc_Location& L);
0110   
0111   //! Returns the curve  associated to the  edge in  the
0112   //! parametric  space of  the  face.  Returns   a NULL
0113   //! handle  if this curve  does not exist.  Returns in
0114   //! <First> and <Last> the parameter range.
0115   //! If the surface is a plane the curve can be not stored but created a new
0116   //! each time. The flag pointed by <theIsStored> serves to indicate storage status. 
0117   //! It is valued if the pointer is non-null.
0118   Standard_EXPORT static Handle(Geom2d_Curve) CurveOnSurface (const TopoDS_Edge& E,
0119                                                               const TopoDS_Face& F,
0120                                                               Standard_Real& First,
0121                                                               Standard_Real& Last,
0122                                                               Standard_Boolean* theIsStored = NULL);
0123   
0124   //! Returns the  curve associated to   the edge in the
0125   //! parametric  space of the   surface. Returns a NULL
0126   //! handle  if this curve does  not exist.  Returns in
0127   //! <First> and <Last> the parameter range.
0128   //! If the surface is a plane the curve can be not stored but created a new
0129   //! each time. The flag pointed by <theIsStored> serves to indicate storage status. 
0130   //! It is valued if the pointer is non-null.
0131   Standard_EXPORT static Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
0132                                                               const Handle(Geom_Surface)& S,
0133                                                               const TopLoc_Location& L,
0134                                                               Standard_Real& First,
0135                                                               Standard_Real& Last,
0136                                                               Standard_Boolean* theIsStored = NULL);
0137 
0138   //! For the planar surface builds the 2d curve for the edge
0139   //! by projection of the edge on plane.
0140   //! Returns a NULL handle if the surface is not planar or
0141   //! the projection failed.
0142   Standard_EXPORT static Handle(Geom2d_Curve) CurveOnPlane (const TopoDS_Edge& E,
0143                                                             const Handle(Geom_Surface)& S,
0144                                                             const TopLoc_Location& L,
0145                                                             Standard_Real& First,
0146                                                             Standard_Real& Last);
0147   
0148   //! Returns in <C>, <S>, <L> a 2d curve, a surface and
0149   //! a location for the edge <E>. <C> and <S>  are null
0150   //! if the  edge has no curve on  surface.  Returns in
0151   //! <First> and <Last> the parameter range.
0152   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);
0153   
0154   //! Returns in <C>, <S>, <L> the 2d curve, the surface
0155   //! and the location for the edge <E> of rank <Index>.
0156   //! <C> and <S> are null if the index is out of range.
0157   //! Returns in <First> and <Last> the parameter range.
0158   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);
0159   
0160   //! Returns the polygon associated to the  edge in  the
0161   //! parametric  space of  the  face.  Returns   a NULL
0162   //! handle  if this polygon  does not exist.
0163   Standard_EXPORT static Handle(Poly_Polygon2D) PolygonOnSurface (const TopoDS_Edge& E, const TopoDS_Face& F);
0164   
0165   //! Returns the polygon associated to the  edge in  the
0166   //! parametric  space of  the surface. Returns   a NULL
0167   //! handle  if this polygon  does not exist.
0168   Standard_EXPORT static Handle(Poly_Polygon2D) PolygonOnSurface (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
0169   
0170   //! Returns in <C>, <S>, <L> a 2d curve, a surface and
0171   //! a location for the edge <E>. <C> and <S>  are null
0172   //! if the  edge has no polygon on  surface.
0173   Standard_EXPORT static void PolygonOnSurface (const TopoDS_Edge& E, Handle(Poly_Polygon2D)& C, Handle(Geom_Surface)& S, TopLoc_Location& L);
0174   
0175   //! Returns in <C>, <S>, <L> the 2d curve, the surface
0176   //! and the location for the edge <E> of rank <Index>.
0177   //! <C> and <S> are null if the index is out of range.
0178   Standard_EXPORT static void PolygonOnSurface (const TopoDS_Edge& E, Handle(Poly_Polygon2D)& C, Handle(Geom_Surface)& S, TopLoc_Location& L, const Standard_Integer Index);
0179   
0180   //! Returns the polygon associated to the  edge in  the
0181   //! parametric  space of  the  face.  Returns   a NULL
0182   //! handle  if this polygon  does not exist.
0183   Standard_EXPORT static const Handle(Poly_PolygonOnTriangulation)& PolygonOnTriangulation (const TopoDS_Edge& E, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L);
0184   
0185   //! Returns in <P>, <T>, <L> a polygon on triangulation, a
0186   //! triangulation and a location for the edge <E>.
0187   //! <P>  and  <T>  are null  if  the  edge has no
0188   //! polygon on  triangulation.
0189   Standard_EXPORT static void PolygonOnTriangulation (const TopoDS_Edge& E, Handle(Poly_PolygonOnTriangulation)& P, Handle(Poly_Triangulation)& T, TopLoc_Location& L);
0190   
0191   //! Returns   in   <P>,  <T>,    <L> a     polygon  on
0192   //! triangulation,   a triangulation  and a  location for
0193   //! the edge <E> for the range index.  <C> and <S> are
0194   //! null if the edge has no polygon on triangulation.
0195   Standard_EXPORT static void PolygonOnTriangulation (const TopoDS_Edge& E, Handle(Poly_PolygonOnTriangulation)& P, Handle(Poly_Triangulation)& T, TopLoc_Location& L, const Standard_Integer Index);
0196   
0197   //! Returns  True  if  <E>  has  two  PCurves  in  the
0198   //! parametric space of <F>. i.e.  <F>  is on a closed
0199   //! surface and <E> is on the closing curve.
0200   Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const TopoDS_Face& F);
0201   
0202   //! Returns  True  if  <E>  has  two  PCurves  in  the
0203   //! parametric space  of <S>.  i.e.   <S>  is a closed
0204   //! surface and <E> is on the closing curve.
0205   Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
0206   
0207   //! Returns  True  if <E> has two arrays of indices in
0208   //! the triangulation <T>.
0209   Standard_EXPORT static Standard_Boolean IsClosed (const TopoDS_Edge& E, const Handle(Poly_Triangulation)& T, const TopLoc_Location& L);
0210   
0211   //! Returns the tolerance for <E>.
0212   Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Edge& E);
0213   
0214   //! Returns the SameParameter flag for the edge.
0215   Standard_EXPORT static Standard_Boolean SameParameter (const TopoDS_Edge& E);
0216   
0217   //! Returns the SameRange flag for the edge.
0218   Standard_EXPORT static Standard_Boolean SameRange (const TopoDS_Edge& E);
0219   
0220   //! Returns True  if the edge is degenerated.
0221   Standard_EXPORT static Standard_Boolean Degenerated (const TopoDS_Edge& E);
0222   
0223   //! Gets the range of the 3d curve.
0224   Standard_EXPORT static void Range (const TopoDS_Edge& E, Standard_Real& First, Standard_Real& Last);
0225   
0226   //! Gets the range  of the edge  on the pcurve on  the
0227   //! surface.
0228   Standard_EXPORT static void Range (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, Standard_Real& First, Standard_Real& Last);
0229   
0230   //! Gets the range of the edge on the pcurve on the face.
0231   Standard_EXPORT static void Range (const TopoDS_Edge& E, const TopoDS_Face& F, Standard_Real& First, Standard_Real& Last);
0232   
0233   //! Gets the UV locations of the extremities of the edge.
0234   Standard_EXPORT static void UVPoints (const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L, gp_Pnt2d& PFirst, gp_Pnt2d& PLast);
0235   
0236   //! Gets the UV locations of the extremities of the edge.
0237   Standard_EXPORT static void UVPoints (const TopoDS_Edge& E, const TopoDS_Face& F, gp_Pnt2d& PFirst, gp_Pnt2d& PLast);
0238   
0239   //! Sets the UV locations of the extremities of the edge.
0240   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);
0241   
0242   //! Sets the UV locations of the extremities of the edge.
0243   Standard_EXPORT static void SetUVPoints (const TopoDS_Edge& E, const TopoDS_Face& F, const gp_Pnt2d& PFirst, const gp_Pnt2d& PLast);
0244   
0245   //! Returns True if the edge is on the surfaces of the
0246   //! two faces.
0247   Standard_EXPORT static Standard_Boolean HasContinuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2);
0248   
0249   //! Returns the continuity.
0250   Standard_EXPORT static GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2);
0251   
0252   //! Returns True if the edge is on the surfaces.
0253   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);
0254   
0255   //! Returns the continuity.
0256   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);
0257   
0258   //! Returns True if the edge has regularity on some
0259   //! two surfaces
0260   Standard_EXPORT static Standard_Boolean HasContinuity (const TopoDS_Edge& E);
0261 
0262   //! Returns the max continuity of edge between some surfaces or GeomAbs_C0 if there no such surfaces.
0263   Standard_EXPORT static GeomAbs_Shape MaxContinuity (const TopoDS_Edge& theEdge);
0264   
0265   //! Returns the 3d point.
0266   Standard_EXPORT static gp_Pnt Pnt (const TopoDS_Vertex& V);
0267   
0268   //! Returns the tolerance.
0269   Standard_EXPORT static Standard_Real Tolerance (const TopoDS_Vertex& V);
0270   
0271   //! Finds the parameter of <theV> on <theE>.
0272   //! @param theV [in] input vertex
0273   //! @param theE [in] input edge
0274   //! @param theParam  [out] calculated parameter on the curve
0275   //! @return TRUE if done
0276   Standard_EXPORT static Standard_Boolean Parameter (const TopoDS_Vertex& theV,
0277                                                        const TopoDS_Edge& theE,
0278                                                        Standard_Real &theParam);
0279 
0280   //! Returns the parameter of <V> on <E>.
0281   //! Throws Standard_NoSuchObject if no parameter on edge
0282   Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E);
0283   
0284   //! Returns the  parameters  of   the  vertex   on the
0285   //! pcurve of the edge on the face.
0286   Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E, const TopoDS_Face& F);
0287   
0288   //! Returns the  parameters  of   the  vertex   on the
0289   //! pcurve of the edge on the surface.
0290   Standard_EXPORT static Standard_Real Parameter (const TopoDS_Vertex& V, const TopoDS_Edge& E, const Handle(Geom_Surface)& S, const TopLoc_Location& L);
0291   
0292   //! Returns the parameters of the vertex on the face.
0293   Standard_EXPORT static gp_Pnt2d Parameters (const TopoDS_Vertex& V, const TopoDS_Face& F);
0294 
0295   //! Returns the maximum tolerance of input shape subshapes.
0296   //@param theShape    - Shape to search tolerance.
0297   //@param theSubShape - Search subshape, only Face, Edge or Vertex are supported.
0298   Standard_EXPORT static Standard_Real MaxTolerance (const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theSubShape);
0299 
0300 };
0301 
0302 #endif // _BRep_Tool_HeaderFile