0022627: Change OCCT memory management defaults
[occt.git] / src / ShapeExtend / ShapeExtend_ComplexCurve.cxx
1 // File:        ShapeExtend_ComplexCurve.cxx
2 // Created:     Tue Jun 22 19:19:20 1999
3 // Author:      Roman LYGIN
4 //              <rln@kinox.nnov.matra-dtv.fr>
5 //    pdn 13.07.99 Derivatives are scaled in accordance with local/global parameter transition
6
7 #include <ShapeExtend_ComplexCurve.ixx>
8 #include <Precision.hxx>
9
10 //=======================================================================
11 //function : ShapeExtend_ComplexCurve
12 //purpose  : 
13 //=======================================================================
14
15 ShapeExtend_ComplexCurve::ShapeExtend_ComplexCurve()
16 {
17   myClosed = Standard_False;
18 }
19
20 //=======================================================================
21 //function : Transform
22 //purpose  : 
23 //=======================================================================
24
25  void ShapeExtend_ComplexCurve::Transform(const gp_Trsf& T) 
26 {
27   for (Standard_Integer i = 1; i <= NbCurves(); i++)
28     Curve(i)->Transform(T);
29 }
30
31 //=======================================================================
32 //function : D0
33 //purpose  : 
34 //=======================================================================
35
36  void ShapeExtend_ComplexCurve::D0(const Standard_Real U,gp_Pnt& P) const
37 {
38   Standard_Real UOut;
39   Standard_Integer ind = LocateParameter (U, UOut);
40   Curve(ind)->D0(UOut, P);
41 }
42
43 //=======================================================================
44 //function : D1
45 //purpose  : 
46 //=======================================================================
47
48  void ShapeExtend_ComplexCurve::D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V1) const
49 {
50   Standard_Real UOut;
51   Standard_Integer ind = LocateParameter (U, UOut);
52   Curve(ind)->D1(UOut, P, V1);
53   TransformDN(V1,ind,1);
54 }
55
56 //=======================================================================
57 //function : D2
58 //purpose  : 
59 //=======================================================================
60
61  void ShapeExtend_ComplexCurve::D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const
62 {
63   Standard_Real UOut;
64   Standard_Integer ind = LocateParameter (U, UOut);
65   Curve(ind)->D2(UOut, P, V1, V2);
66   TransformDN(V1,ind,1);
67   TransformDN(V2,ind,2);
68 }
69
70 //=======================================================================
71 //function : D3
72 //purpose  : 
73 //=======================================================================
74
75  void ShapeExtend_ComplexCurve::D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const
76 {
77   Standard_Real UOut;
78   Standard_Integer ind = LocateParameter (U, UOut);
79   Curve(ind)->D3(UOut, P, V1, V2, V3);
80   TransformDN(V1,ind,1);
81   TransformDN(V2,ind,2);
82   TransformDN(V3,ind,3);
83 }
84
85 //=======================================================================
86 //function : DN
87 //purpose  : 
88 //=======================================================================
89
90  gp_Vec ShapeExtend_ComplexCurve::DN(const Standard_Real U,const Standard_Integer N) const
91 {
92   Standard_Real UOut;
93   Standard_Integer ind = LocateParameter (U, UOut);
94   gp_Vec res = Curve(ind)->DN(UOut, N);
95   if(N)
96     TransformDN(res,ind,N); 
97   return res;
98 }
99
100 //=======================================================================
101 //function : CheckConnectivity
102 //purpose  : 
103 //=======================================================================
104
105  Standard_Boolean ShapeExtend_ComplexCurve::CheckConnectivity (const Standard_Real Preci)
106 {
107   Standard_Integer NbC = NbCurves();
108   Standard_Boolean ok = Standard_True;
109   for (Standard_Integer i = 1; i < NbC; i++ ) {
110     if (i == 1) myClosed = Value (FirstParameter()).IsEqual (Value (LastParameter()), Preci);
111     ok &= Curve (i)->Value (Curve(i)->LastParameter()).IsEqual
112       (Curve (i + 1)->Value (Curve(i + 1)->FirstParameter()), Preci);
113   }
114 #ifdef DEB
115   if (!ok) cout << "Warning: ShapeExtend_ComplexCurve: not connected in 3d" << endl;
116 #endif
117   return ok;
118 }
119
120 //=======================================================================
121 //function : TransformDN
122 //purpose  : 
123 //=======================================================================
124
125 void ShapeExtend_ComplexCurve::TransformDN (gp_Vec& V,
126                                          const Standard_Integer ind,
127                                          const Standard_Integer N) const
128 {
129   Standard_Real fact = GetScaleFactor(ind);
130   for(Standard_Integer i = 1; i <= N; i++)
131     V*= fact;
132 }