Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:18:54

0001 // Created on: 1998-06-08
0002 // Created by: data exchange team
0003 // Copyright (c) 1998-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 _ShapeAnalysis_Edge_HeaderFile
0018 #define _ShapeAnalysis_Edge_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <ShapeExtend_Status.hxx>
0026 class TopoDS_Edge;
0027 class Geom_Curve;
0028 class TopoDS_Face;
0029 class Geom_Surface;
0030 class TopLoc_Location;
0031 class Geom2d_Curve;
0032 class gp_Pnt2d;
0033 class TopoDS_Vertex;
0034 class gp_Vec2d;
0035 class gp_Pnt;
0036 
0037 // resolve name collisions with X11 headers
0038 #ifdef Status
0039   #undef Status
0040 #endif
0041 
0042 //! Tool for analyzing the edge.
0043 //! Queries geometrical representations of the edge (3d curve, pcurve
0044 //! on the given face or surface) and topological sub-shapes (bounding
0045 //! vertices).
0046 //! Provides methods for analyzing geometry and topology consistency
0047 //! (3d and pcurve(s) consistency, their adjacency to the vertices).
0048 class ShapeAnalysis_Edge
0049 {
0050 public:
0051   DEFINE_STANDARD_ALLOC
0052 
0053   //! Empty constructor; initialises Status to OK
0054   Standard_EXPORT ShapeAnalysis_Edge();
0055 
0056   //! Tells if the edge has a 3d curve
0057   Standard_EXPORT bool HasCurve3d(const TopoDS_Edge& edge) const;
0058 
0059   //! Returns the 3d curve and bounding parameters for the edge
0060   //! Returns False if no 3d curve.
0061   //! If <orient> is True (default), takes orientation into account:
0062   //! if the edge is reversed, cf and cl are toggled
0063   Standard_EXPORT bool Curve3d(const TopoDS_Edge&       edge,
0064                                occ::handle<Geom_Curve>& C3d,
0065                                double&                  cf,
0066                                double&                  cl,
0067                                const bool               orient = true) const;
0068 
0069   //! Gives True if the edge has a 3d curve, this curve is closed,
0070   //! and the edge has the same vertex at start and end
0071   Standard_EXPORT bool IsClosed3d(const TopoDS_Edge& edge) const;
0072 
0073   //! Tells if the Edge has a pcurve on the face.
0074   Standard_EXPORT bool HasPCurve(const TopoDS_Edge& edge, const TopoDS_Face& face) const;
0075 
0076   //! Tells if the edge has a pcurve on the surface (with location).
0077   Standard_EXPORT bool HasPCurve(const TopoDS_Edge&               edge,
0078                                  const occ::handle<Geom_Surface>& surface,
0079                                  const TopLoc_Location&           location) const;
0080 
0081   Standard_EXPORT bool PCurve(const TopoDS_Edge&         edge,
0082                               const TopoDS_Face&         face,
0083                               occ::handle<Geom2d_Curve>& C2d,
0084                               double&                    cf,
0085                               double&                    cl,
0086                               const bool                 orient = true) const;
0087 
0088   //! Returns the pcurve and bounding parameters for the edge
0089   //! lying on the surface.
0090   //! Returns False if the edge has no pcurve on this surface.
0091   //! If <orient> is True (default), takes orientation into account:
0092   //! if the edge is reversed, cf and cl are toggled
0093   Standard_EXPORT bool PCurve(const TopoDS_Edge&               edge,
0094                               const occ::handle<Geom_Surface>& surface,
0095                               const TopLoc_Location&           location,
0096                               occ::handle<Geom2d_Curve>&       C2d,
0097                               double&                          cf,
0098                               double&                          cl,
0099                               const bool                       orient = true) const;
0100 
0101   Standard_EXPORT bool BoundUV(const TopoDS_Edge& edge,
0102                                const TopoDS_Face& face,
0103                                gp_Pnt2d&          first,
0104                                gp_Pnt2d&          last) const;
0105 
0106   //! Returns the ends of pcurve
0107   //! Calls method PCurve with <orient> equal to True
0108   Standard_EXPORT bool BoundUV(const TopoDS_Edge&               edge,
0109                                const occ::handle<Geom_Surface>& surface,
0110                                const TopLoc_Location&           location,
0111                                gp_Pnt2d&                        first,
0112                                gp_Pnt2d&                        last) const;
0113 
0114   Standard_EXPORT bool IsSeam(const TopoDS_Edge& edge, const TopoDS_Face& face) const;
0115 
0116   //! Returns True if the edge has two pcurves on one surface
0117   Standard_EXPORT bool IsSeam(const TopoDS_Edge&               edge,
0118                               const occ::handle<Geom_Surface>& surface,
0119                               const TopLoc_Location&           location) const;
0120 
0121   //! Returns start vertex of the edge (taking edge orientation
0122   //! into account).
0123   Standard_EXPORT TopoDS_Vertex FirstVertex(const TopoDS_Edge& edge) const;
0124 
0125   //! Returns end vertex of the edge (taking edge orientation
0126   //! into account).
0127   Standard_EXPORT TopoDS_Vertex LastVertex(const TopoDS_Edge& edge) const;
0128 
0129   Standard_EXPORT bool GetEndTangent2d(const TopoDS_Edge& edge,
0130                                        const TopoDS_Face& face,
0131                                        const bool         atEnd,
0132                                        gp_Pnt2d&          pos,
0133                                        gp_Vec2d&          tang,
0134                                        const double       dparam = 0.0) const;
0135 
0136   //! Returns tangent of the edge pcurve at its start (if atEnd is
0137   //! False) or end (if True), regarding the orientation of edge.
0138   //! If edge is REVERSED, tangent is reversed before return.
0139   //! Returns True if pcurve is available and tangent is computed
0140   //! and is not null, else False.
0141   Standard_EXPORT bool GetEndTangent2d(const TopoDS_Edge&               edge,
0142                                        const occ::handle<Geom_Surface>& surface,
0143                                        const TopLoc_Location&           location,
0144                                        const bool                       atEnd,
0145                                        gp_Pnt2d&                        pos,
0146                                        gp_Vec2d&                        tang,
0147                                        const double                     dparam = 0.0) const;
0148 
0149   //! Checks the start and/or end vertex of the edge for matching
0150   //! with 3d curve with the given precision.
0151   //! <vtx> = 1 : start vertex only
0152   //! <vtx> = 2 : end vertex only
0153   //! <vtx> = 0 : both (default)
0154   //! If preci < 0 the vertices are considered with their own
0155   //! tolerances, else with the given <preci>.
0156   Standard_EXPORT bool CheckVerticesWithCurve3d(const TopoDS_Edge& edge,
0157                                                 const double       preci = -1,
0158                                                 const int          vtx   = 0);
0159 
0160   Standard_EXPORT bool CheckVerticesWithPCurve(const TopoDS_Edge& edge,
0161                                                const TopoDS_Face& face,
0162                                                const double       preci = -1,
0163                                                const int          vtx   = 0);
0164 
0165   //! Checks the start and/or end vertex of the edge for matching
0166   //! with pcurve with the given precision.
0167   //! <vtx> = 1 : start vertex
0168   //! <vtx> = 2 : end vertex
0169   //! <vtx> = 0 : both
0170   //! If preci < 0 the vertices are considered with their own
0171   //! tolerances, else with the given <preci>.
0172   Standard_EXPORT bool CheckVerticesWithPCurve(const TopoDS_Edge&               edge,
0173                                                const occ::handle<Geom_Surface>& surface,
0174                                                const TopLoc_Location&           location,
0175                                                const double                     preci = -1,
0176                                                const int                        vtx   = 0);
0177 
0178   Standard_EXPORT bool CheckVertexTolerance(const TopoDS_Edge& edge,
0179                                             const TopoDS_Face& face,
0180                                             double&            toler1,
0181                                             double&            toler2);
0182 
0183   //! Checks if it is necessary to increase tolerances of the edge
0184   //! vertices to comprise the ends of 3d curve and pcurve on
0185   //! the given face (first method) or all pcurves stored in an edge
0186   //! (second one)
0187   //! toler1 returns necessary tolerance for first vertex,
0188   //! toler2 returns necessary tolerance for last vertex.
0189   Standard_EXPORT bool CheckVertexTolerance(const TopoDS_Edge& edge,
0190                                             double&            toler1,
0191                                             double&            toler2);
0192 
0193   Standard_EXPORT bool CheckCurve3dWithPCurve(const TopoDS_Edge& edge, const TopoDS_Face& face);
0194 
0195   //! Checks mutual orientation of 3d curve and pcurve on the
0196   //! analysis of curves bounding points
0197   Standard_EXPORT bool CheckCurve3dWithPCurve(const TopoDS_Edge&               edge,
0198                                               const occ::handle<Geom_Surface>& surface,
0199                                               const TopLoc_Location&           location);
0200 
0201   //! Returns the status (in the form of True/False) of last Check
0202   Standard_EXPORT bool Status(const ShapeExtend_Status status) const;
0203 
0204   //! Checks the edge to be SameParameter.
0205   //! Calculates the maximal deviation between 3d curve and each
0206   //! pcurve of the edge on <NbControl> equidistant points (the same
0207   //! algorithm as in BRepCheck; default value is 23 as in BRepCheck).
0208   //! This deviation is returned in <maxdev> parameter.
0209   //! If deviation is greater than tolerance of the edge (i.e.
0210   //! incorrect flag) returns False, else returns True.
0211   Standard_EXPORT bool CheckSameParameter(const TopoDS_Edge& edge,
0212                                           double&            maxdev,
0213                                           const int          NbControl = 23);
0214 
0215   //! Checks the edge to be SameParameter.
0216   //! Calculates the maximal deviation between 3d curve and each
0217   //! pcurve of the edge on <NbControl> equidistant points (the same
0218   //! algorithm as in BRepCheck; default value is 23 as in BRepCheck).
0219   //! This deviation is returned in <maxdev> parameter.
0220   //! If deviation is greater than tolerance of the edge (i.e.
0221   //! incorrect flag) returns False, else returns True.
0222   Standard_EXPORT bool CheckSameParameter(const TopoDS_Edge& theEdge,
0223                                           const TopoDS_Face& theFace,
0224                                           double&            theMaxdev,
0225                                           const int          theNbControl = 23);
0226 
0227   //! Checks possibility for pcurve thePC to have range [theFirst, theLast] (edge range)
0228   //! having respect to real first, last parameters of thePC
0229   Standard_EXPORT bool CheckPCurveRange(const double                     theFirst,
0230                                         const double                     theLast,
0231                                         const occ::handle<Geom2d_Curve>& thePC);
0232 
0233   //! Checks the first edge is overlapped with second edge.
0234   //! If distance between two edges is less then theTolOverlap
0235   //! edges are overlapped.
0236   //! theDomainDis - length of part of edges on which edges are overlapped.
0237   Standard_EXPORT bool CheckOverlapping(const TopoDS_Edge& theEdge1,
0238                                         const TopoDS_Edge& theEdge2,
0239                                         double&            theTolOverlap,
0240                                         const double       theDomainDist = 0.0);
0241 
0242 protected:
0243   int myStatus;
0244 
0245 private:
0246   //! Check points by pairs (A and A, B and B) with precisions
0247   //! (preci1 and preci2).
0248   //! P1 are the points either from 3d curve or from vertices,
0249   //! P2 are the points from pcurve
0250   Standard_EXPORT bool CheckPoints(const gp_Pnt& P1A,
0251                                    const gp_Pnt& P1B,
0252                                    const gp_Pnt& P2A,
0253                                    const gp_Pnt& P2B,
0254                                    const double  preci1,
0255                                    const double  preci2);
0256 };
0257 
0258 #endif // _ShapeAnalysis_Edge_HeaderFile