b311480e |
1 | // Created on: 1999-06-22 |
2 | // Created by: Roman LYGIN |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | // pdn 13.07.99 Derivatives are scaled in accordance with local/global parameter transition |
18 | |
19 | #include <ShapeExtend_ComplexCurve.ixx> |
20 | #include <Precision.hxx> |
21 | |
22 | //======================================================================= |
23 | //function : ShapeExtend_ComplexCurve |
24 | //purpose : |
25 | //======================================================================= |
26 | |
27 | ShapeExtend_ComplexCurve::ShapeExtend_ComplexCurve() |
28 | { |
29 | myClosed = Standard_False; |
30 | } |
31 | |
32 | //======================================================================= |
33 | //function : Transform |
34 | //purpose : |
35 | //======================================================================= |
36 | |
37 | void ShapeExtend_ComplexCurve::Transform(const gp_Trsf& T) |
38 | { |
39 | for (Standard_Integer i = 1; i <= NbCurves(); i++) |
40 | Curve(i)->Transform(T); |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : D0 |
45 | //purpose : |
46 | //======================================================================= |
47 | |
48 | void ShapeExtend_ComplexCurve::D0(const Standard_Real U,gp_Pnt& P) const |
49 | { |
50 | Standard_Real UOut; |
51 | Standard_Integer ind = LocateParameter (U, UOut); |
52 | Curve(ind)->D0(UOut, P); |
53 | } |
54 | |
55 | //======================================================================= |
56 | //function : D1 |
57 | //purpose : |
58 | //======================================================================= |
59 | |
60 | void ShapeExtend_ComplexCurve::D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V1) const |
61 | { |
62 | Standard_Real UOut; |
63 | Standard_Integer ind = LocateParameter (U, UOut); |
64 | Curve(ind)->D1(UOut, P, V1); |
65 | TransformDN(V1,ind,1); |
66 | } |
67 | |
68 | //======================================================================= |
69 | //function : D2 |
70 | //purpose : |
71 | //======================================================================= |
72 | |
73 | void ShapeExtend_ComplexCurve::D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const |
74 | { |
75 | Standard_Real UOut; |
76 | Standard_Integer ind = LocateParameter (U, UOut); |
77 | Curve(ind)->D2(UOut, P, V1, V2); |
78 | TransformDN(V1,ind,1); |
79 | TransformDN(V2,ind,2); |
80 | } |
81 | |
82 | //======================================================================= |
83 | //function : D3 |
84 | //purpose : |
85 | //======================================================================= |
86 | |
87 | void ShapeExtend_ComplexCurve::D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const |
88 | { |
89 | Standard_Real UOut; |
90 | Standard_Integer ind = LocateParameter (U, UOut); |
91 | Curve(ind)->D3(UOut, P, V1, V2, V3); |
92 | TransformDN(V1,ind,1); |
93 | TransformDN(V2,ind,2); |
94 | TransformDN(V3,ind,3); |
95 | } |
96 | |
97 | //======================================================================= |
98 | //function : DN |
99 | //purpose : |
100 | //======================================================================= |
101 | |
102 | gp_Vec ShapeExtend_ComplexCurve::DN(const Standard_Real U,const Standard_Integer N) const |
103 | { |
104 | Standard_Real UOut; |
105 | Standard_Integer ind = LocateParameter (U, UOut); |
106 | gp_Vec res = Curve(ind)->DN(UOut, N); |
107 | if(N) |
108 | TransformDN(res,ind,N); |
109 | return res; |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : CheckConnectivity |
114 | //purpose : |
115 | //======================================================================= |
116 | |
117 | Standard_Boolean ShapeExtend_ComplexCurve::CheckConnectivity (const Standard_Real Preci) |
118 | { |
119 | Standard_Integer NbC = NbCurves(); |
120 | Standard_Boolean ok = Standard_True; |
121 | for (Standard_Integer i = 1; i < NbC; i++ ) { |
122 | if (i == 1) myClosed = Value (FirstParameter()).IsEqual (Value (LastParameter()), Preci); |
123 | ok &= Curve (i)->Value (Curve(i)->LastParameter()).IsEqual |
124 | (Curve (i + 1)->Value (Curve(i + 1)->FirstParameter()), Preci); |
125 | } |
126 | #ifdef DEB |
127 | if (!ok) cout << "Warning: ShapeExtend_ComplexCurve: not connected in 3d" << endl; |
128 | #endif |
129 | return ok; |
130 | } |
131 | |
132 | //======================================================================= |
133 | //function : TransformDN |
134 | //purpose : |
135 | //======================================================================= |
136 | |
137 | void ShapeExtend_ComplexCurve::TransformDN (gp_Vec& V, |
138 | const Standard_Integer ind, |
139 | const Standard_Integer N) const |
140 | { |
141 | Standard_Real fact = GetScaleFactor(ind); |
142 | for(Standard_Integer i = 1; i <= N; i++) |
143 | V*= fact; |
144 | } |