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