summaryrefslogtreecommitdiff
path: root/inc/ShapeAnalysis_WireOrder.hxx
blob: c90811035f565cac4f58ffcbeb826b32215ca91f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to 
// this header file considered to be the "object code" form of the original source.

#ifndef _ShapeAnalysis_WireOrder_HeaderFile
#define _ShapeAnalysis_WireOrder_HeaderFile

#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif

#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Handle_TColStd_HArray1OfInteger_HeaderFile
#include <Handle_TColStd_HArray1OfInteger.hxx>
#endif
#ifndef _Handle_TColgp_HSequenceOfXYZ_HeaderFile
#include <Handle_TColgp_HSequenceOfXYZ.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
class TColStd_HArray1OfInteger;
class TColgp_HSequenceOfXYZ;
class Standard_TypeMismatch;
class gp_XYZ;
class gp_XY;


//! This class is intended to control and, if possible, redefine <br>
//!          the order of a list of edges which define a wire <br>
//!          Edges are not given directly, but as their bounds (start,end) <br>
//! <br>
//!          This allows to use this tool, either on existing wire, or on <br>
//!          data just taken from a file (coordinates are easy to get) <br>
//! <br>
//!          It can work, either in 2D, or in 3D, but not miscible <br>
//!          Warning about tolerance : according to the mode (2D/3D), it <br>
//!          must be given as 2D or 3D (i.e. metric) tolerance, uniform <br>
//!          on the whole list <br>
//! <br>
//!          Two phases : firstly add the couples (start,end) <br>
//!          secondly perform then get the result <br>
class ShapeAnalysis_WireOrder  {
public:

  void* operator new(size_t,void* anAddress) 
  {
    return anAddress;
  }
  void* operator new(size_t size) 
  {
    return Standard::Allocate(size); 
  }
  void  operator delete(void *anAddress) 
  {
    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
  }

  //! Empty constructor <br>
  Standard_EXPORT   ShapeAnalysis_WireOrder();
  //! Creates a WireOrder in 3D (if mode3d is True) or 2D (if False) <br>
//!           with a tolerance <br>
  Standard_EXPORT   ShapeAnalysis_WireOrder(const Standard_Boolean mode3d,const Standard_Real tol);
  //! Sets new values. Clears the connexion list <br>
//!           If <mode3d> changes, also clears the edge list (else, doesnt) <br>
  Standard_EXPORT     void SetMode(const Standard_Boolean mode3d,const Standard_Real tol) ;
  //! Returns the working tolerance <br>
  Standard_EXPORT     Standard_Real Tolerance() const;
  //! Clears the list of edges, but not mode and tol <br>
  Standard_EXPORT     void Clear() ;
  //! Adds a couple of points 3D (start,end) <br>
  Standard_EXPORT     void Add(const gp_XYZ& start3d,const gp_XYZ& end3d) ;
  //! Adds a couple of points 2D (start,end) <br>
  Standard_EXPORT     void Add(const gp_XY& start2d,const gp_XY& end2d) ;
  //! Returns the count of added couples of points (one per edges) <br>
  Standard_EXPORT     Standard_Integer NbEdges() const;
  //! If this mode is True method perform does not sort edges of <br>
//!           different loops. The resulting order is first loop, second <br>
//!           one etc... <br>
  Standard_EXPORT     Standard_Boolean& KeepLoopsMode() ;
  //! Computes the better order <br>
//!           If <closed> is True (D) considers also closure <br>
//!           Optimised if the couples were already in order <br>
//!           The criterium is : two couples in order if distance between <br>
//!           end-prec and start-cur is less then starting tolerance <tol> <br>
//!           Else, the smallest distance is reached <br>
//!           Gap corresponds to a smallest distance greater than <tol> <br>
  Standard_EXPORT     void Perform(const Standard_Boolean closed = Standard_True) ;
  //! Tells if Perform has been done <br>
//!           Else, the following methods returns original values <br>
  Standard_EXPORT     Standard_Boolean IsDone() const;
  //! Returns the status of the order (0 if not done) : <br>
//!            0 : all edges are direct and in sequence <br>
//!            1 : all edges are direct but some are not in sequence <br>
//!            2 : in addition, unresolved gaps remain <br>
//!           -1 : some edges are reversed, but no gap remain <br>
//!           -2 : some edges are reversed and some gaps remain <br>
//!           -10 : COULD NOT BE RESOLVED, Failure on Reorder <br>
//!           gap : regarding starting <tol> <br>
  Standard_EXPORT     Standard_Integer Status() const;
  //! Returns the number of original edge which correspond to the <br>
//!           newly ordered number <n> <br>
//!  Warning : the returned value is NEGATIVE if edge should be reversed <br>
  Standard_EXPORT     Standard_Integer Ordered(const Standard_Integer n) const;
  //! Returns the values of the couple <num>, as 3D values <br>
  Standard_EXPORT     void XYZ(const Standard_Integer num,gp_XYZ& start3d,gp_XYZ& end3d) const;
  //! Returns the values of the couple <num>, as 2D values <br>
  Standard_EXPORT     void XY(const Standard_Integer num,gp_XY& start2d,gp_XY& end2d) const;
  //! Returns the gap between a couple and its preceeding <br>
//!           <num> is considered ordered <br>
//!           If <num> = 0 (D), returns the greatest gap found <br>
  Standard_EXPORT     Standard_Real Gap(const Standard_Integer num = 0) const;
  //! Determines the chains inside which successive edges have a gap <br>
//!           less than a given value. Queried by NbChains and Chain <br>
  Standard_EXPORT     void SetChains(const Standard_Real gap) ;
  //! Returns the count of computed chains <br>
  Standard_EXPORT     Standard_Integer NbChains() const;
  //! Returns, for the chain n0 num, starting and ending numbers of <br>
//!           edges. In the list of ordered edges (see Ordered for originals) <br>
  Standard_EXPORT     void Chain(const Standard_Integer num,Standard_Integer& n1,Standard_Integer& n2) const;
  //! Determines the couples of edges for which end and start fit <br>
//!           inside a given gap. Queried by NbCouples and Couple <br>
  Standard_EXPORT     void SetCouples(const Standard_Real gap) ;
  //! Returns the count of computed couples <br>
  Standard_EXPORT     Standard_Integer NbCouples() const;
  //! Returns, for the couple n0 num, the two implied edges <br>
//!           In the list of ordered edges <br>
  Standard_EXPORT     void Couple(const Standard_Integer num,Standard_Integer& n1,Standard_Integer& n2) const;





protected:





private:



Standard_Boolean myKeepLoops;
Handle_TColStd_HArray1OfInteger myOrd;
Handle_TColStd_HArray1OfInteger myChains;
Handle_TColStd_HArray1OfInteger myCouples;
Handle_TColgp_HSequenceOfXYZ myXYZ;
Standard_Real myTol;
Standard_Real myGap;
Standard_Integer myStat;
Standard_Boolean myMode;


};





// other Inline functions and methods (like "C++: function call" methods)


#endif