summaryrefslogtreecommitdiff
path: root/src/ShapeExtend/ShapeExtend_ComplexCurve.cxx
blob: 12e53f81d97d3e320f44eeb2aba6fb8ad6a9eca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// File:	ShapeExtend_ComplexCurve.cxx
// Created:	Tue Jun 22 19:19:20 1999
// Author:	Roman LYGIN
//		<rln@kinox.nnov.matra-dtv.fr>
//    pdn 13.07.99 Derivatives are scaled in accordance with local/global parameter transition

#include <ShapeExtend_ComplexCurve.ixx>
#include <Precision.hxx>

//=======================================================================
//function : ShapeExtend_ComplexCurve
//purpose  : 
//=======================================================================

ShapeExtend_ComplexCurve::ShapeExtend_ComplexCurve()
{
  myClosed = Standard_False;
}

//=======================================================================
//function : Transform
//purpose  : 
//=======================================================================

 void ShapeExtend_ComplexCurve::Transform(const gp_Trsf& T) 
{
  for (Standard_Integer i = 1; i <= NbCurves(); i++)
    Curve(i)->Transform(T);
}

//=======================================================================
//function : D0
//purpose  : 
//=======================================================================

 void ShapeExtend_ComplexCurve::D0(const Standard_Real U,gp_Pnt& P) const
{
  Standard_Real UOut;
  Standard_Integer ind = LocateParameter (U, UOut);
  Curve(ind)->D0(UOut, P);
}

//=======================================================================
//function : D1
//purpose  : 
//=======================================================================

 void ShapeExtend_ComplexCurve::D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V1) const
{
  Standard_Real UOut;
  Standard_Integer ind = LocateParameter (U, UOut);
  Curve(ind)->D1(UOut, P, V1);
  TransformDN(V1,ind,1);
}

//=======================================================================
//function : D2
//purpose  : 
//=======================================================================

 void ShapeExtend_ComplexCurve::D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const
{
  Standard_Real UOut;
  Standard_Integer ind = LocateParameter (U, UOut);
  Curve(ind)->D2(UOut, P, V1, V2);
  TransformDN(V1,ind,1);
  TransformDN(V2,ind,2);
}

//=======================================================================
//function : D3
//purpose  : 
//=======================================================================

 void ShapeExtend_ComplexCurve::D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const
{
  Standard_Real UOut;
  Standard_Integer ind = LocateParameter (U, UOut);
  Curve(ind)->D3(UOut, P, V1, V2, V3);
  TransformDN(V1,ind,1);
  TransformDN(V2,ind,2);
  TransformDN(V3,ind,3);
}

//=======================================================================
//function : DN
//purpose  : 
//=======================================================================

 gp_Vec ShapeExtend_ComplexCurve::DN(const Standard_Real U,const Standard_Integer N) const
{
  Standard_Real UOut;
  Standard_Integer ind = LocateParameter (U, UOut);
  gp_Vec res = Curve(ind)->DN(UOut, N);
  if(N)
    TransformDN(res,ind,N); 
  return res;
}

//=======================================================================
//function : CheckConnectivity
//purpose  : 
//=======================================================================

 Standard_Boolean ShapeExtend_ComplexCurve::CheckConnectivity (const Standard_Real Preci)
{
  Standard_Integer NbC = NbCurves();
  Standard_Boolean ok = Standard_True;
  for (Standard_Integer i = 1; i < NbC; i++ ) {
    if (i == 1) myClosed = Value (FirstParameter()).IsEqual (Value (LastParameter()), Preci);
    ok &= Curve (i)->Value (Curve(i)->LastParameter()).IsEqual
      (Curve (i + 1)->Value (Curve(i + 1)->FirstParameter()), Preci);
  }
#ifdef DEB
  if (!ok) cout << "Warning: ShapeExtend_ComplexCurve: not connected in 3d" << endl;
#endif
  return ok;
}

//=======================================================================
//function : TransformDN
//purpose  : 
//=======================================================================

void ShapeExtend_ComplexCurve::TransformDN (gp_Vec& V,
					 const Standard_Integer ind,
					 const Standard_Integer N) const
{
  Standard_Real fact = GetScaleFactor(ind);
  for(Standard_Integer i = 1; i <= N; i++)
    V*= fact;
}