0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / GeomPlate / GeomPlate_BuildPlateSurface.hxx
1 // Created on: 1996-04-03
2 // Created by: Stagiaire Frederic CALOONE
3 // Copyright (c) 1996-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 _GeomPlate_BuildPlateSurface_HeaderFile
18 #define _GeomPlate_BuildPlateSurface_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22
23 #include <GeomPlate_HSequenceOfCurveConstraint.hxx>
24 #include <GeomPlate_HArray1OfSequenceOfReal.hxx>
25 #include <GeomPlate_HSequenceOfPointConstraint.hxx>
26 #include <Plate_Plate.hxx>
27 #include <TColStd_HArray1OfInteger.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_Real.hxx>
30 #include <Extrema_ExtPS.hxx>
31 #include <GeomPlate_HArray1OfHCurve.hxx>
32 #include <TColgp_SequenceOfXY.hxx>
33 #include <TColgp_SequenceOfXYZ.hxx>
34 #include <TColGeom2d_HArray1OfCurve.hxx>
35 #include <TColStd_HArray1OfReal.hxx>
36 class Geom_Surface;
37 class GeomPlate_Surface;
38 class GeomPlate_CurveConstraint;
39 class GeomPlate_PointConstraint;
40 class gp_Pnt2d;
41 class gp_Pnt;
42 class Geom2d_Curve;
43
44
45 //! This class provides an algorithm for constructing such a plate surface that
46 //! it conforms to given curve and/or point constraints.
47 //! The algorithm accepts or constructs an initial surface
48 //! and looks for a deformation of it satisfying the
49 //! constraints and minimizing energy input.
50 //! A BuildPlateSurface object provides a framework for:
51 //! -   defining or setting constraints
52 //! -   implementing the construction algorithm
53 //! -   consulting the result.
54 class GeomPlate_BuildPlateSurface 
55 {
56 public:
57
58   DEFINE_STANDARD_ALLOC
59
60   
61   //! Constructor  compatible  with  the  old  version
62   //! with this constructor the constraint are given in a Array of Curve on Surface
63   //! The array NbPoints  contains the number of points for each constraint.
64   //! The Array Tang contains the order of constraint for each Constraint: The possible values for this
65   //! order has to be -1 , 0 , 1 , 2 . Order i means constraint Gi.
66   //! NbIter is the maximum number of iteration to optimise the number of points for resolution
67   //! Degree is the degree of resolution for Plate
68   //! Tol2d is the tolerance used to test if two points of different constraint are identical in the
69   //! parametric space of the initial surface
70   //! Tol3d is used to test if two identical points in the 2d space are identical in 3d space
71   //! TolAng is used to compare the angle between normal of two identical points in the 2d space
72   //! Raises  ConstructionError;
73   Standard_EXPORT GeomPlate_BuildPlateSurface(const Handle(TColStd_HArray1OfInteger)& NPoints, const Handle(GeomPlate_HArray1OfHCurve)& TabCurve, const Handle(TColStd_HArray1OfInteger)& Tang, const Standard_Integer Degree, const Standard_Integer NbIter = 3, const Standard_Real Tol2d = 0.00001, const Standard_Real Tol3d = 0.0001, const Standard_Real TolAng = 0.01, const Standard_Real TolCurv = 0.1, const Standard_Boolean Anisotropie = Standard_False);
74   
75   Standard_EXPORT GeomPlate_BuildPlateSurface(const Handle(Geom_Surface)& Surf, const Standard_Integer Degree = 3, const Standard_Integer NbPtsOnCur = 10, const Standard_Integer NbIter = 3, const Standard_Real Tol2d = 0.00001, const Standard_Real Tol3d = 0.0001, const Standard_Real TolAng = 0.01, const Standard_Real TolCurv = 0.1, const Standard_Boolean Anisotropie = Standard_False);
76   
77   //! Initializes the BuildPlateSurface framework for
78   //! deforming plate surfaces using curve and point
79   //! constraints. You use the first constructor if you have
80   //! an initial surface to work with at construction time. If
81   //! not, you use the second. You can add one later by
82   //! using the method LoadInitSurface. If no initial
83   //! surface is loaded, one will automatically be computed.
84   //! The curve and point constraints will be defined by
85   //! using the method Add.
86   //! Before the call to the algorithm, the curve constraints
87   //! will be transformed into sequences of discrete points.
88   //! Each curve defined as a constraint will be given the
89   //! value of NbPtsOnCur as the average number of points on it.
90   //! Several arguments serve to improve performance of
91   //! the algorithm. NbIter, for example, expresses the
92   //! number of iterations allowed and is used to control the
93   //! duration of computation. To optimize resolution,
94   //! Degree will have the default value of 3.
95   //! The surface generated must respect several tolerance values:
96   //! -   2d tolerance given by Tol2d, with a default value of 0.00001
97   //! -   3d tolerance expressed by Tol3d, with a default value of 0.0001
98   //! -   angular tolerance given by TolAng, with a default
99   //! value of 0.01, defining the greatest angle allowed
100   //! between the constraint and the target surface.
101   //! Exceptions
102   //! Standard_ConstructionError if NbIter is less than 1 or Degree is less than 3.
103   Standard_EXPORT GeomPlate_BuildPlateSurface(const Standard_Integer Degree = 3, const Standard_Integer NbPtsOnCur = 10, const Standard_Integer NbIter = 3, const Standard_Real Tol2d = 0.00001, const Standard_Real Tol3d = 0.0001, const Standard_Real TolAng = 0.01, const Standard_Real TolCurv = 0.1, const Standard_Boolean Anisotropie = Standard_False);
104   
105   //! Resets all constraints
106   Standard_EXPORT void Init();
107   
108   //! Loads the initial Surface
109   Standard_EXPORT void LoadInitSurface (const Handle(Geom_Surface)& Surf);
110   
111   //! Adds the linear constraint cont.
112   Standard_EXPORT void Add (const Handle(GeomPlate_CurveConstraint)& Cont);
113   
114   Standard_EXPORT void SetNbBounds (const Standard_Integer NbBounds);
115   
116   //! Adds the point constraint cont.
117   Standard_EXPORT void Add (const Handle(GeomPlate_PointConstraint)& Cont);
118   
119
120   //! Calls the algorithm and computes the plate surface using
121   //! the loaded constraints. If no initial surface is given, the
122   //! algorithm automatically computes one.
123   //! Exceptions
124   //! Standard_RangeError if the value of the constraint is
125   //! null or if plate is not done.
126   Standard_EXPORT void Perform(const Message_ProgressRange& theProgress = Message_ProgressRange());
127   
128   //! returns the CurveConstraints of order order
129   Standard_EXPORT Handle(GeomPlate_CurveConstraint) CurveConstraint (const Standard_Integer order) const;
130   
131   //! returns the PointConstraint of order order
132   Standard_EXPORT Handle(GeomPlate_PointConstraint) PointConstraint (const Standard_Integer order) const;
133   
134   Standard_EXPORT void Disc2dContour (const Standard_Integer nbp, TColgp_SequenceOfXY& Seq2d);
135   
136   Standard_EXPORT void Disc3dContour (const Standard_Integer nbp, const Standard_Integer iordre, TColgp_SequenceOfXYZ& Seq3d);
137   
138
139   //! Tests whether computation of the plate has been completed.
140   Standard_EXPORT Standard_Boolean IsDone() const;
141   
142
143   //! Returns the result of the computation. This surface can
144   //! then be used by GeomPlate_MakeApprox for
145   //! converting the resulting surface into a BSpline.
146   Standard_EXPORT Handle(GeomPlate_Surface) Surface() const;
147   
148   //! Returns the initial surface
149   Standard_EXPORT Handle(Geom_Surface) SurfInit() const;
150   
151
152   //! Allows you to ensure that the array of curves returned by
153   //! Curves2d has the correct orientation. Returns the
154   //! orientation of the curves in the array returned by
155   //! Curves2d. Computation changes the orientation of
156   //! these curves. Consequently, this method returns the
157   //! orientation prior to computation.
158   Standard_EXPORT Handle(TColStd_HArray1OfInteger) Sense() const;
159   
160
161   //! Extracts the array of curves on the plate surface which
162   //! correspond to the curve constraints set in Add.
163   Standard_EXPORT Handle(TColGeom2d_HArray1OfCurve) Curves2d() const;
164   
165
166   //! Returns the order of the curves in the array returned by
167   //! Curves2d. Computation changes this order.
168   //! Consequently, this method returns the order of the
169   //! curves prior to computation.
170   Standard_EXPORT Handle(TColStd_HArray1OfInteger) Order() const;
171   
172   //! Returns the max distance between the result and the constraints
173   Standard_EXPORT Standard_Real G0Error() const;
174   
175   //! Returns  the max angle between the result and the constraints
176   Standard_EXPORT Standard_Real G1Error() const;
177   
178   //! Returns  the max difference of curvature between the result and the constraints
179   Standard_EXPORT Standard_Real G2Error() const;
180   
181   //! Returns   the max distance between the result and the constraint Index
182   Standard_EXPORT Standard_Real G0Error (const Standard_Integer Index);
183   
184   //! Returns the max angle between the result and the constraint Index
185   Standard_EXPORT Standard_Real G1Error (const Standard_Integer Index);
186   
187   //! Returns the max difference of curvature between the result and the constraint Index
188   Standard_EXPORT Standard_Real G2Error (const Standard_Integer Index);
189
190
191
192
193 protected:
194
195
196
197
198
199 private:
200
201   
202   //! Evaluates the distance, the angle between normals, and the "courbure"
203   //! on middle points of constraints and corresponding points on the GeomPlate_Surface
204   //! the results are given for a curve c
205   Standard_EXPORT void EcartContraintesMil (const Standard_Integer c, Handle(TColStd_HArray1OfReal)& d, Handle(TColStd_HArray1OfReal)& an, Handle(TColStd_HArray1OfReal)& courb);
206   
207   Standard_EXPORT gp_Pnt2d ProjectPoint (const gp_Pnt& P);
208   
209   Standard_EXPORT Handle(Geom2d_Curve) ProjectCurve (const Handle(Adaptor3d_Curve)& Curv);
210   
211   Standard_EXPORT Handle(Adaptor2d_Curve2d) ProjectedCurve (Handle(Adaptor3d_Curve)& Curv);
212   
213   Standard_EXPORT void ComputeSurfInit(const Message_ProgressRange& theProgress);
214   
215   Standard_EXPORT void Intersect (Handle(GeomPlate_HArray1OfSequenceOfReal)& PntInter, Handle(GeomPlate_HArray1OfSequenceOfReal)& PntG1G1);
216   
217   Standard_EXPORT void Discretise (const Handle(GeomPlate_HArray1OfSequenceOfReal)& PntInter, const Handle(GeomPlate_HArray1OfSequenceOfReal)& PntG1G1);
218   
219   Standard_EXPORT void LoadCurve (const Standard_Integer NbBoucle, const Standard_Integer OrderMax = 2);
220   
221   Standard_EXPORT void LoadPoint (const Standard_Integer NbBoucle, const Standard_Integer OrderMax = 2);
222   
223   Standard_EXPORT void CalculNbPtsInit();
224   
225   Standard_EXPORT Standard_Boolean VerifSurface (const Standard_Integer NbLoop);
226   
227   Standard_EXPORT void VerifPoints (Standard_Real& dist, Standard_Real& ang, Standard_Real& curv) const;
228   
229   Standard_EXPORT Standard_Boolean CourbeJointive (const Standard_Real tolerance);
230   
231   Standard_EXPORT Standard_Real ComputeAnisotropie() const;
232   
233   Standard_EXPORT Standard_Boolean IsOrderG1() const;
234
235
236   Handle(GeomPlate_HSequenceOfCurveConstraint) myLinCont;
237   Handle(GeomPlate_HArray1OfSequenceOfReal) myParCont;
238   Handle(GeomPlate_HArray1OfSequenceOfReal) myPlateCont;
239   Handle(GeomPlate_HSequenceOfPointConstraint) myPntCont;
240   Handle(Geom_Surface) mySurfInit;
241   Handle(Geom_Surface) myPlanarSurfInit;
242   Handle(GeomPlate_Surface) myGeomPlateSurface;
243   Plate_Plate myPlate;
244   Plate_Plate myPrevPlate;
245   Standard_Boolean myAnisotropie;
246   Handle(TColStd_HArray1OfInteger) mySense;
247   Standard_Integer myDegree;
248   Handle(TColStd_HArray1OfInteger) myInitOrder;
249   Standard_Real myG0Error;
250   Standard_Real myG1Error;
251   Standard_Real myG2Error;
252   Standard_Integer myNbPtsOnCur;
253   Standard_Boolean mySurfInitIsGive;
254   Standard_Integer myNbIter;
255   Extrema_ExtPS myProj;
256   Standard_Real myTol2d;
257   Standard_Real myTol3d;
258   Standard_Real myTolAng;
259   Standard_Real myTolU;
260   Standard_Real myTolV;
261   Standard_Integer myNbBounds;
262   Standard_Boolean myIsLinear;
263   Standard_Boolean myFree;
264
265
266 };
267
268
269
270
271
272
273
274 #endif // _GeomPlate_BuildPlateSurface_HeaderFile