0024677: Control of license statements and non-ascii characters in integrated code
[occt.git] / src / ShapeExtend / ShapeExtend_ComplexCurve.cxx
1 // Created on: 1999-06-22
2 // Created by: Roman LYGIN
3 // Copyright (c) 1999-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 //    pdn 13.07.99 Derivatives are scaled in accordance with local/global parameter transition
18
19 #include <Geom_Curve.hxx>
20 #include <gp_Pnt.hxx>
21 #include <gp_Trsf.hxx>
22 #include <gp_Vec.hxx>
23 #include <Precision.hxx>
24 #include <ShapeExtend_ComplexCurve.hxx>
25 #include <Standard_Type.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(ShapeExtend_ComplexCurve,Geom_Curve)
28
29 //=======================================================================
30 //function : ShapeExtend_ComplexCurve
31 //purpose  : 
32 //=======================================================================
33 ShapeExtend_ComplexCurve::ShapeExtend_ComplexCurve()
34 {
35   myClosed = Standard_False;
36 }
37
38 //=======================================================================
39 //function : Transform
40 //purpose  : 
41 //=======================================================================
42
43  void ShapeExtend_ComplexCurve::Transform(const gp_Trsf& T) 
44 {
45   for (Standard_Integer i = 1; i <= NbCurves(); i++)
46     Curve(i)->Transform(T);
47 }
48
49 //=======================================================================
50 //function : D0
51 //purpose  : 
52 //=======================================================================
53
54  void ShapeExtend_ComplexCurve::D0(const Standard_Real U,gp_Pnt& P) const
55 {
56   Standard_Real UOut;
57   Standard_Integer ind = LocateParameter (U, UOut);
58   Curve(ind)->D0(UOut, P);
59 }
60
61 //=======================================================================
62 //function : D1
63 //purpose  : 
64 //=======================================================================
65
66  void ShapeExtend_ComplexCurve::D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V1) const
67 {
68   Standard_Real UOut;
69   Standard_Integer ind = LocateParameter (U, UOut);
70   Curve(ind)->D1(UOut, P, V1);
71   TransformDN(V1,ind,1);
72 }
73
74 //=======================================================================
75 //function : D2
76 //purpose  : 
77 //=======================================================================
78
79  void ShapeExtend_ComplexCurve::D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const
80 {
81   Standard_Real UOut;
82   Standard_Integer ind = LocateParameter (U, UOut);
83   Curve(ind)->D2(UOut, P, V1, V2);
84   TransformDN(V1,ind,1);
85   TransformDN(V2,ind,2);
86 }
87
88 //=======================================================================
89 //function : D3
90 //purpose  : 
91 //=======================================================================
92
93  void ShapeExtend_ComplexCurve::D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const
94 {
95   Standard_Real UOut;
96   Standard_Integer ind = LocateParameter (U, UOut);
97   Curve(ind)->D3(UOut, P, V1, V2, V3);
98   TransformDN(V1,ind,1);
99   TransformDN(V2,ind,2);
100   TransformDN(V3,ind,3);
101 }
102
103 //=======================================================================
104 //function : DN
105 //purpose  : 
106 //=======================================================================
107
108  gp_Vec ShapeExtend_ComplexCurve::DN(const Standard_Real U,const Standard_Integer N) const
109 {
110   Standard_Real UOut;
111   Standard_Integer ind = LocateParameter (U, UOut);
112   gp_Vec res = Curve(ind)->DN(UOut, N);
113   if(N)
114     TransformDN(res,ind,N); 
115   return res;
116 }
117
118 //=======================================================================
119 //function : CheckConnectivity
120 //purpose  : 
121 //=======================================================================
122
123  Standard_Boolean ShapeExtend_ComplexCurve::CheckConnectivity (const Standard_Real Preci)
124 {
125   Standard_Integer NbC = NbCurves();
126   Standard_Boolean ok = Standard_True;
127   for (Standard_Integer i = 1; i < NbC; i++ ) {
128     if (i == 1) myClosed = Value (FirstParameter()).IsEqual (Value (LastParameter()), Preci);
129     ok &= Curve (i)->Value (Curve(i)->LastParameter()).IsEqual
130       (Curve (i + 1)->Value (Curve(i + 1)->FirstParameter()), Preci);
131   }
132 #ifdef OCCT_DEBUG
133   if (!ok) cout << "Warning: ShapeExtend_ComplexCurve: not connected in 3d" << endl;
134 #endif
135   return ok;
136 }
137
138 //=======================================================================
139 //function : TransformDN
140 //purpose  : 
141 //=======================================================================
142
143 void ShapeExtend_ComplexCurve::TransformDN (gp_Vec& V,
144                                          const Standard_Integer ind,
145                                          const Standard_Integer N) const
146 {
147   Standard_Real fact = GetScaleFactor(ind);
148   for(Standard_Integer i = 1; i <= N; i++)
149     V*= fact;
150 }