1 // Created on: 1998-06-08
2 // Created by: data exchange team
3 // Copyright (c) 1998-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 _ShapeAnalysis_Edge_HeaderFile
18 #define _ShapeAnalysis_Edge_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Real.hxx>
27 #include <ShapeExtend_Status.hxx>
32 class TopLoc_Location;
38 class Adaptor3d_Curve;
41 //! Tool for analyzing the edge.
42 //! Queries geometrical representations of the edge (3d curve, pcurve
43 //! on the given face or surface) and topological sub-shapes (bounding
45 //! Provides methods for analyzing geometry and topology consistency
46 //! (3d and pcurve(s) consistency, their adjacency to the vertices).
47 class ShapeAnalysis_Edge
54 //! Empty constructor; initialises Status to OK
55 Standard_EXPORT ShapeAnalysis_Edge();
57 //! Tells if the edge has a 3d curve
58 Standard_EXPORT Standard_Boolean HasCurve3d (const TopoDS_Edge& edge) const;
60 //! Returns the 3d curve and bounding parameteres for the edge
61 //! Returns False if no 3d curve.
62 //! If <orient> is True (default), takes orientation into account:
63 //! if the edge is reversed, cf and cl are toggled
64 Standard_EXPORT Standard_Boolean Curve3d (const TopoDS_Edge& edge, Handle(Geom_Curve)& C3d, Standard_Real& cf, Standard_Real& cl, const Standard_Boolean orient = Standard_True) const;
66 //! Gives True if the edge has a 3d curve, this curve is closed,
67 //! and the edge has the same vertex at start and end
68 Standard_EXPORT Standard_Boolean IsClosed3d (const TopoDS_Edge& edge) const;
70 //! Tells if the Edge has a pcurve on the face.
71 Standard_EXPORT Standard_Boolean HasPCurve (const TopoDS_Edge& edge, const TopoDS_Face& face) const;
73 //! Tells if the edge has a pcurve on the surface (with location).
74 Standard_EXPORT Standard_Boolean HasPCurve (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location) const;
76 Standard_EXPORT Standard_Boolean PCurve (const TopoDS_Edge& edge, const TopoDS_Face& face, Handle(Geom2d_Curve)& C2d, Standard_Real& cf, Standard_Real& cl, const Standard_Boolean orient = Standard_True) const;
78 //! Returns the pcurve and bounding parameteres for the edge
79 //! lying on the surface.
80 //! Returns False if the edge has no pcurve on this surface.
81 //! If <orient> is True (default), takes orientation into account:
82 //! if the edge is reversed, cf and cl are toggled
83 Standard_EXPORT Standard_Boolean PCurve (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location, Handle(Geom2d_Curve)& C2d, Standard_Real& cf, Standard_Real& cl, const Standard_Boolean orient = Standard_True) const;
85 Standard_EXPORT Standard_Boolean BoundUV (const TopoDS_Edge& edge, const TopoDS_Face& face, gp_Pnt2d& first, gp_Pnt2d& last) const;
87 //! Returns the ends of pcurve
88 //! Calls method PCurve with <orient> equal to True
89 Standard_EXPORT Standard_Boolean BoundUV (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location, gp_Pnt2d& first, gp_Pnt2d& last) const;
91 Standard_EXPORT Standard_Boolean IsSeam (const TopoDS_Edge& edge, const TopoDS_Face& face) const;
93 //! Returns True if the edge has two pcurves on one surface
94 Standard_EXPORT Standard_Boolean IsSeam (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location) const;
96 //! Returns start vertex of the edge (taking edge orientation
98 Standard_EXPORT TopoDS_Vertex FirstVertex (const TopoDS_Edge& edge) const;
100 //! Returns end vertex of the edge (taking edge orientation
102 Standard_EXPORT TopoDS_Vertex LastVertex (const TopoDS_Edge& edge) const;
104 Standard_EXPORT Standard_Boolean GetEndTangent2d (const TopoDS_Edge& edge, const TopoDS_Face& face, const Standard_Boolean atEnd, gp_Pnt2d& pos, gp_Vec2d& tang, const Standard_Real dparam = 0.0) const;
106 //! Returns tangent of the edge pcurve at its start (if atEnd is
107 //! False) or end (if True), regarding the orientation of edge.
108 //! If edge is REVERSED, tangent is reversed before return.
109 //! Returns True if pcurve is available and tangent is computed
110 //! and is not null, else False.
111 Standard_EXPORT Standard_Boolean GetEndTangent2d (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location, const Standard_Boolean atEnd, gp_Pnt2d& pos, gp_Vec2d& tang, const Standard_Real dparam = 0.0) const;
113 //! Checks the start and/or end vertex of the edge for matching
114 //! with 3d curve with the given precision.
115 //! <vtx> = 1 : start vertex only
116 //! <vtx> = 2 : end vertex only
117 //! <vtx> = 0 : both (default)
118 //! If preci < 0 the vertices are considered with their own
119 //! tolerances, else with the given <preci>.
120 Standard_EXPORT Standard_Boolean CheckVerticesWithCurve3d (const TopoDS_Edge& edge, const Standard_Real preci = -1, const Standard_Integer vtx = 0);
122 Standard_EXPORT Standard_Boolean CheckVerticesWithPCurve (const TopoDS_Edge& edge, const TopoDS_Face& face, const Standard_Real preci = -1, const Standard_Integer vtx = 0);
124 //! Checks the start and/or end vertex of the edge for matching
125 //! with pcurve with the given precision.
126 //! <vtx> = 1 : start vertex
127 //! <vtx> = 2 : end vertex
129 //! If preci < 0 the vertices are considered with their own
130 //! tolerances, else with the given <preci>.
131 Standard_EXPORT Standard_Boolean CheckVerticesWithPCurve (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location, const Standard_Real preci = -1, const Standard_Integer vtx = 0);
133 Standard_EXPORT Standard_Boolean CheckVertexTolerance (const TopoDS_Edge& edge, const TopoDS_Face& face, Standard_Real& toler1, Standard_Real& toler2);
135 //! Checks if it is necessary to increase tolerances of the edge
136 //! vertices to comprise the ends of 3d curve and pcurve on
137 //! the given face (first method) or all pcurves stored in an edge
139 //! toler1 returns necessary tolerance for first vertex,
140 //! toler2 returns necessary tolerance for last vertex.
141 Standard_EXPORT Standard_Boolean CheckVertexTolerance (const TopoDS_Edge& edge, Standard_Real& toler1, Standard_Real& toler2);
143 Standard_EXPORT Standard_Boolean CheckCurve3dWithPCurve (const TopoDS_Edge& edge, const TopoDS_Face& face);
145 //! Checks mutual orientation of 3d curve and pcurve on the
146 //! analysis of curves bounding points
147 Standard_EXPORT Standard_Boolean CheckCurve3dWithPCurve (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location);
149 //! Returns the status (in the form of True/False) of last Check
150 Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status status) const;
152 //! Checks the edge to be SameParameter.
153 //! Calculates the maximal deviation between 3d curve and each
154 //! pcurve of the edge on <NbControl> equidistant points (the same
155 //! algorithm as in BRepCheck; default value is 23 as in BRepCheck).
156 //! This deviation is returned in <maxdev> parameter.
157 //! If deviation is greater than tolerance of the edge (i.e.
158 //! incorrect flag) returns False, else returns True.
159 Standard_EXPORT Standard_Boolean CheckSameParameter (const TopoDS_Edge& edge, Standard_Real& maxdev, const Standard_Integer NbControl = 23);
161 //! Checks the edge to be SameParameter.
162 //! Calculates the maximal deviation between 3d curve and each
163 //! pcurve of the edge on <NbControl> equidistant points (the same
164 //! algorithm as in BRepCheck; default value is 23 as in BRepCheck).
165 //! This deviation is returned in <maxdev> parameter.
166 //! If deviation is greater than tolerance of the edge (i.e.
167 //! incorrect flag) returns False, else returns True.
168 Standard_EXPORT Standard_Boolean CheckSameParameter (const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, Standard_Real& theMaxdev, const Standard_Integer theNbControl = 23);
170 //! Computes the maximal deviation between the two curve
172 //! dev is an input/output parameter and contains the computed
173 //! deviation (should be initialized with 0. for the first call).
174 //! Used by CheckSameParameter().
175 Standard_EXPORT static Standard_Boolean ComputeDeviation (const Adaptor3d_Curve& CRef, const Adaptor3d_Curve& Other, const Standard_Boolean SameParameter, Standard_Real& dev, const Standard_Integer NCONTROL);
177 //! Checks the first edge is overlapped with second edge.
178 //! If distance between two edges is less then theTolOverlap
179 //! edges is overlapped.
180 //! theDomainDis - length of part of edges on wich edges is overlapped.
181 Standard_EXPORT Standard_Boolean CheckOverlapping (const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2, Standard_Real& theTolOverlap, const Standard_Real theDomainDist = 0.0);
190 Standard_Integer myStatus;
196 //! Check points by pairs (A and A, B and B) with precisions
197 //! (preci1 and preci2).
198 //! P1 are the points either from 3d curve or from vertices,
199 //! P2 are the points from pcurve
200 Standard_EXPORT Standard_Boolean CheckPoints (const gp_Pnt& P1A, const gp_Pnt& P1B, const gp_Pnt& P2A, const gp_Pnt& P2B, const Standard_Real preci1, const Standard_Real preci2);
213 #endif // _ShapeAnalysis_Edge_HeaderFile