summaryrefslogtreecommitdiff
path: root/src/GeomFill/GeomFill_FunctionDraft.cxx
blob: 65f8dac4b08bcfb079468f047bce0f568a8aae56 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// File:	GeomFill_FunctionDraft.cxx
// Created:	Mon Apr 27 11:09:42 1998
// Author:	 Stephanie HUMEAU
//		<shu@sun17>


#include <GeomFill_FunctionDraft.ixx>
#include <GeomAdaptor_HSurface.hxx>
#include <GeomAdaptor_HCurve.hxx>
//#include <Precision.hxx>
#include <gp_Pnt.hxx>


//*******************************************************
//   Calcul de la valeur de la fonction :
//                      G(w(t)) - S(u(t),v(t)) = 0
//  ou     G = generatrice   et   S = surface d'arret
//   et de ses derivees
//*******************************************************


//*******************************************************
// Function : FunctionDraft
// Purpose : Initialisation de la section et de la surface d'arret
//*******************************************************
 GeomFill_FunctionDraft::GeomFill_FunctionDraft
  (const Handle(Adaptor3d_HSurface)& S, const Handle(Adaptor3d_HCurve)& C)
{
  TheCurve = C ;
  TheSurface = S;
}

//*******************************************************
// Function : NbVariables (t, u, v)
// Purpose :
//*******************************************************
 Standard_Integer GeomFill_FunctionDraft::NbVariables()const 
{
  return 3;
}

//*******************************************************
// Function : NbEquations
// Purpose :
//*******************************************************
 Standard_Integer GeomFill_FunctionDraft::NbEquations()const
{
  return 3;
}

//*******************************************************
// Function : Value
// Purpose : calcul of the value of the function at <X>
//*******************************************************
 Standard_Boolean GeomFill_FunctionDraft::Value(const math_Vector& X,
					        math_Vector& F) 
{
  gp_Pnt P,P1;
  TheCurve->D0(X(1), P);
  TheSurface->D0(X(2), X(3), P1);

  F(1) = P.Coord(1) - P1.Coord(1);
  F(2) = P.Coord(2) - P1.Coord(2);
  F(3) = P.Coord(3) - P1.Coord(3);

  return Standard_True;
}

//*******************************************************
// Function : Derivatives
// Purpose :calcul of the derivative of the function
//*******************************************************
 Standard_Boolean GeomFill_FunctionDraft::Derivatives(const math_Vector& X,
						      math_Matrix& D) 
{
  Standard_Integer i;
  gp_Pnt P,P1;
  gp_Vec DP,DP1U,DP1V;
  TheCurve->D1(X(1),P,DP);
  TheSurface->D1(X(2),X(3),P1,DP1U,DP1V);

  for (i=1;i<=3;i++)
    {
      D(i,1) = DP.Coord(i);  
      D(i,2) = -DP1U.Coord(i);
      D(i,3) = -DP1V.Coord(i);
    }
  return Standard_True;
}

//*******************************************************
// Function : Values
// Purpose : calcul of the value and the derivative of the function
//*******************************************************
 Standard_Boolean GeomFill_FunctionDraft::Values(const math_Vector& X,
						math_Vector& F,
						math_Matrix& D) 
{ 
  Standard_Integer i;
  gp_Pnt P,P1;
  gp_Vec DP,DP1U,DP1V;
  TheCurve->D1(X(1),P,DP); //derivee de la generatrice
  TheSurface->D1(X(2),X(3),P1,DP1U,DP1V); //derivee de la new surface

  for (i=1;i<=3;i++)
    { 
      F(i) = P.Coord(i) - P1.Coord(i);

      D(i,1) = DP.Coord(i);  
      D(i,2) = -DP1U.Coord(i);
      D(i,3) = -DP1V.Coord(i);
    }

  return Standard_True;
}

//*******************************************************
// Function : DerivT
// Purpose : calcul of the first derivative from t 
//*******************************************************
 Standard_Boolean GeomFill_FunctionDraft::DerivT(const Handle(Adaptor3d_HCurve)& C,
						const Standard_Real Param,
						const Standard_Real W,
						const gp_Vec & dN,
					        const Standard_Real teta,
					        math_Vector& F) 

{ 
  gp_Pnt P;
  gp_Vec DP;

  C->D1(Param, P, DP); // derivee de la section

  F(1) = DP.Coord(1) + W * dN.Coord(1) * Sin(teta);
  F(2) = DP.Coord(2) + W * dN.Coord(2) * Sin(teta);
  F(3) = DP.Coord(3) + W * dN.Coord(3) * Sin(teta);
  
  return Standard_True;
}

//*******************************************************
// Function : Deriv2T
// Purpose : calcul of the second derivatice from t
//*******************************************************
 Standard_Boolean GeomFill_FunctionDraft::Deriv2T(const Handle(Adaptor3d_HCurve)& C,
						 const Standard_Real Param,
						 const Standard_Real W,
						 const gp_Vec & d2N,
						 const Standard_Real teta,
						 math_Vector& F) 
{ 
  gp_Pnt P;
  gp_Vec DP,D2P;

  C->D2(Param, P, DP, D2P); // derivee de la section

  F(1) = D2P.Coord(1) + W * d2N.Coord(1) * Sin(teta);
  F(2) = D2P.Coord(2) + W * d2N.Coord(2) * Sin(teta);
  F(3) = D2P.Coord(3) + W * d2N.Coord(3) * Sin(teta);
  
  return Standard_True;
}

//*******************************************************
// Function : DerivTX
// Purpose : calcul of the second derivative from t and x
//*******************************************************
 Standard_Boolean GeomFill_FunctionDraft::DerivTX(const gp_Vec & dN,
						  const Standard_Real teta,
						  math_Matrix& D) 
{ 
//  gp_Pnt P;
//  gp_Vec DP,D2P;

  Standard_Integer i;
  for (i=1;i<=3;i++)
    {
      D(i,1) = dN.Coord(i)*Sin(teta); //derivee / W
      D(i,2) = 0.;  // derivee / U
      D(i,3) = 0.;  // derivee / V
    }

  return Standard_True;
}

//*******************************************************
// Function : Deriv2X
// Purpose : calcul of the second derivative from x
//*******************************************************
 Standard_Boolean GeomFill_FunctionDraft::Deriv2X(const math_Vector & X,
						  GeomFill_Tensor& T) 
{ 
  gp_Pnt P;
  gp_Vec DPu,DPv;
  gp_Vec D2Pu, D2Pv, D2Puv;
  Standard_Integer i;

  TheSurface->D2(X(2), X(3), P, DPu, DPv, D2Pu, D2Pv, D2Puv);
 
  T.Init(0.); // tenseur

  for (i=1;i<=3;i++)
    {
      T(i,2,2) = -D2Pu.Coord(i);
      T(i,3,2) = T(i,2,3) = -D2Puv.Coord(i);
      T(i,3,3) = -D2Pv.Coord(i);
    }

  return Standard_True;
}