1022a0e1b4bf1d0ebc9acfba0126924f07ec0c60
[occt.git] / src / ShapeAnalysis / ShapeAnalysis_Edge.hxx
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
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 _ShapeAnalysis_Edge_HeaderFile
18 #define _ShapeAnalysis_Edge_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Real.hxx>
27 #include <ShapeExtend_Status.hxx>
28 class TopoDS_Edge;
29 class Geom_Curve;
30 class TopoDS_Face;
31 class Geom_Surface;
32 class TopLoc_Location;
33 class Geom2d_Curve;
34 class gp_Pnt2d;
35 class TopoDS_Vertex;
36 class gp_Vec2d;
37 class gp_Pnt;
38 class Adaptor3d_Curve;
39
40
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
44 //! vertices).
45 //! Provides methods for analyzing geometry and topology consistency
46 //! (3d and pcurve(s) consistency, their adjacency to the vertices).
47 class ShapeAnalysis_Edge 
48 {
49 public:
50
51   DEFINE_STANDARD_ALLOC
52
53   
54   //! Empty constructor; initialises Status to OK
55   Standard_EXPORT ShapeAnalysis_Edge();
56   
57   //! Tells if the edge has a 3d curve
58   Standard_EXPORT Standard_Boolean HasCurve3d (const TopoDS_Edge& edge) const;
59   
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;
65   
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;
69   
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;
72   
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;
75   
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;
77   
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;
84   
85   Standard_EXPORT Standard_Boolean BoundUV (const TopoDS_Edge& edge, const TopoDS_Face& face, gp_Pnt2d& first, gp_Pnt2d& last) const;
86   
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;
90   
91   Standard_EXPORT Standard_Boolean IsSeam (const TopoDS_Edge& edge, const TopoDS_Face& face) const;
92   
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;
95   
96   //! Returns start vertex of the edge (taking edge orientation
97   //! into account).
98   Standard_EXPORT TopoDS_Vertex FirstVertex (const TopoDS_Edge& edge) const;
99   
100   //! Returns end vertex of the edge (taking edge orientation
101   //! into account).
102   Standard_EXPORT TopoDS_Vertex LastVertex (const TopoDS_Edge& edge) const;
103   
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;
105   
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;
112   
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);
121   
122   Standard_EXPORT Standard_Boolean CheckVerticesWithPCurve (const TopoDS_Edge& edge, const TopoDS_Face& face, const Standard_Real preci = -1, const Standard_Integer vtx = 0);
123   
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
128   //! <vtx> = 0 : both
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);
132   
133   Standard_EXPORT Standard_Boolean CheckVertexTolerance (const TopoDS_Edge& edge, const TopoDS_Face& face, Standard_Real& toler1, Standard_Real& toler2);
134   
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
138   //! (second one)
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);
142   
143   Standard_EXPORT Standard_Boolean CheckCurve3dWithPCurve (const TopoDS_Edge& edge, const TopoDS_Face& face);
144   
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);
148   
149   //! Returns the status (in the form of True/False) of last Check
150   Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status status) const;
151   
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);
160
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);
169   
170   //! Computes the maximal deviation between the two curve
171   //! representations.
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);
176   
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);
182
183
184
185
186 protected:
187
188
189
190   Standard_Integer myStatus;
191
192
193 private:
194
195   
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);
201
202
203
204
205 };
206
207
208
209
210
211
212
213 #endif // _ShapeAnalysis_Edge_HeaderFile