0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / GeomPlate / GeomPlate_CurveConstraint.hxx
1 // Created on: 1997-05-05
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1997-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_CurveConstraint_HeaderFile
18 #define _GeomPlate_CurveConstraint_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Integer.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <GeomLProp_SLProps.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Transient.hxx>
28 class Adaptor3d_HCurveOnSurface;
29 class Adaptor3d_HCurve;
30 class Geom2d_Curve;
31 class Adaptor2d_HCurve2d;
32 class Law_Function;
33 class Standard_ConstructionError;
34 class GeomLProp_SLProps;
35 class gp_Pnt;
36 class gp_Vec;
37
38
39 class GeomPlate_CurveConstraint;
40 DEFINE_STANDARD_HANDLE(GeomPlate_CurveConstraint, Standard_Transient)
41
42
43 //! Defines curves as constraints to be used to deform a surface.
44 class GeomPlate_CurveConstraint : public Standard_Transient
45 {
46
47 public:
48
49   
50
51   //! Initializes an empty curve constraint object.
52   Standard_EXPORT GeomPlate_CurveConstraint();
53   
54   //! Create a constraint
55   //! Order is the order of the constraint. The possible values for order are -1,0,1,2.
56   //! Order i means constraints Gi
57   //! Npt is the number of points associated with the constraint.
58   //! TolDist is the maximum error to satisfy for G0 constraints
59   //! TolAng is the maximum error to satisfy for G1 constraints
60   //! TolCurv is the maximum error to satisfy for G2 constraints
61   //! These errors can be replaced by laws of criterion.
62   //! Raises    ConstructionError if Order is not -1 , 0,  1,  2
63   Standard_EXPORT GeomPlate_CurveConstraint(const Handle(Adaptor3d_HCurve)& Boundary, const Standard_Integer Order, const Standard_Integer NPt = 10, const Standard_Real TolDist = 0.0001, const Standard_Real TolAng = 0.01, const Standard_Real TolCurv = 0.1);
64   
65   //! Allows you to set the order of continuity required for
66   //! the constraints: G0, G1, and G2, controlled
67   //! respectively by G0Criterion G1Criterion and G2Criterion.
68   Standard_EXPORT void SetOrder (const Standard_Integer Order);
69   
70   //! Returns the order of constraint, one of G0, G1 or G2.
71   Standard_EXPORT Standard_Integer Order() const;
72   
73   //! Returns the number of points on the curve used as a
74   //! constraint. The default setting is 10. This parameter
75   //! affects computation time, which increases by the cube of
76   //! the number of points.
77   Standard_EXPORT Standard_Integer NbPoints() const;
78   
79
80   //! Allows you to set the number of points on the curve
81   //! constraint. The default setting is 10. This parameter
82   //! affects computation time, which increases by the cube of
83   //! the number of points.
84   Standard_EXPORT void SetNbPoints (const Standard_Integer NewNb);
85   
86
87   //! Allows you to set the G0 criterion. This is the law
88   //! defining the greatest distance allowed between the
89   //! constraint and the target surface for each point of the
90   //! constraint. If this criterion is not set, TolDist, the
91   //! distance tolerance from the constructor, is used.
92   Standard_EXPORT void SetG0Criterion (const Handle(Law_Function)& G0Crit);
93   
94
95   //! Allows you to set the G1 criterion. This is the law
96   //! defining the greatest angle allowed between the
97   //! constraint and the target surface. If this criterion is not
98   //! set, TolAng, the angular tolerance from the constructor, is used.
99   //! Raises  ConstructionError if  the  curve  is  not  on  a  surface
100   Standard_EXPORT void SetG1Criterion (const Handle(Law_Function)& G1Crit);
101   
102   Standard_EXPORT void SetG2Criterion (const Handle(Law_Function)& G2Crit);
103   
104   //! Returns the G0 criterion at the parametric point U on
105   //! the curve. This is the greatest distance allowed between
106   //! the constraint and the target surface at U.
107   Standard_EXPORT Standard_Real G0Criterion (const Standard_Real U) const;
108   
109   //! Returns the G1 criterion at the parametric point U on
110   //! the curve. This is the greatest angle allowed between
111   //! the constraint and the target surface at U.
112   //! Raises  ConstructionError if  the  curve  is  not  on  a  surface
113   Standard_EXPORT Standard_Real G1Criterion (const Standard_Real U) const;
114   
115   //! Returns the G2 criterion at the parametric point U on
116   //! the curve. This is the greatest difference in curvature
117   //! allowed between the constraint and the target surface at U.
118   //! Raises  ConstructionError if  the  curve  is  not  on  a  surface
119   Standard_EXPORT Standard_Real G2Criterion (const Standard_Real U) const;
120   
121   Standard_EXPORT Standard_Real FirstParameter() const;
122   
123   Standard_EXPORT Standard_Real LastParameter() const;
124   
125   Standard_EXPORT Standard_Real Length() const;
126   
127   Standard_EXPORT GeomLProp_SLProps& LPropSurf (const Standard_Real U);
128   
129   Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const;
130   
131   Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const;
132   
133   Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3, gp_Vec& V4, gp_Vec& V5) const;
134   
135   Standard_EXPORT Handle(Adaptor3d_HCurve) Curve3d() const;
136   
137   //! loads a 2d curve associated the surface resulting of the constraints
138   Standard_EXPORT void SetCurve2dOnSurf (const Handle(Geom2d_Curve)& Curve2d);
139   
140   //! Returns a 2d curve associated the surface resulting of the constraints
141   Standard_EXPORT Handle(Geom2d_Curve) Curve2dOnSurf() const;
142   
143   //! loads a 2d curve  resulting from the normal projection of
144   //! the curve on the initial surface
145   Standard_EXPORT void SetProjectedCurve (const Handle(Adaptor2d_HCurve2d)& Curve2d, const Standard_Real TolU, const Standard_Real TolV);
146   
147   //! Returns the projected curve resulting from the normal projection of the
148   //! curve on the initial surface
149   Standard_EXPORT Handle(Adaptor2d_HCurve2d) ProjectedCurve() const;
150
151
152
153
154   DEFINE_STANDARD_RTTIEXT(GeomPlate_CurveConstraint,Standard_Transient)
155
156 protected:
157
158
159   Handle(Adaptor3d_HCurveOnSurface) myFrontiere;
160   Standard_Integer myNbPoints;
161   Standard_Integer myOrder;
162   Handle(Adaptor3d_HCurve) my3dCurve;
163   Standard_Integer myTang;
164   Handle(Geom2d_Curve) my2dCurve;
165   Handle(Adaptor2d_HCurve2d) myHCurve2d;
166   Handle(Law_Function) myG0Crit;
167   Handle(Law_Function) myG1Crit;
168   Handle(Law_Function) myG2Crit;
169   Standard_Boolean myConstG0;
170   Standard_Boolean myConstG1;
171   Standard_Boolean myConstG2;
172   GeomLProp_SLProps myLProp;
173   Standard_Real myTolDist;
174   Standard_Real myTolAng;
175   Standard_Real myTolCurv;
176   Standard_Real myTolU;
177   Standard_Real myTolV;
178
179
180 private:
181
182
183
184
185 };
186
187
188
189
190
191
192
193 #endif // _GeomPlate_CurveConstraint_HeaderFile