summaryrefslogtreecommitdiff
path: root/src/AdvApp2Var/AdvApp2Var_Network.cxx
blob: 89b19fefe751b9fbb1b44a2f8b93e3256ab21a76 (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
// File:	AdvApp2Var_Network.cxx
// Created:	Tue Jul  2 12:12:24 1996
// Author:	Joelle CHAUVET
//		<jct@sgi38>
// Modified:	Mon Dec  9 11:39:13 1996
//   by:	Joelle CHAUVET
//		G1135 : empty constructor


#include <AdvApp2Var_Network.ixx>
#include <AdvApp2Var_Patch.hxx>
#include <AdvApp2Var_SequenceOfPatch.hxx>
#include <TColStd_SequenceOfReal.hxx>

//==========================================================================================
//function : AdvApp2Var_Network
//purpose  : 
//==========================================================================================

AdvApp2Var_Network::AdvApp2Var_Network()
{
}


//==========================================================================================
//function : AdvApp2Var_Network
//purpose  : 
//==========================================================================================

AdvApp2Var_Network::AdvApp2Var_Network(const AdvApp2Var_SequenceOfPatch& Net,
				       const TColStd_SequenceOfReal& TheU,
				       const TColStd_SequenceOfReal& TheV)
{
  myNet=Net;
  myUParameters=TheU;
  myVParameters=TheV;
}

//==========================================================================================
//function : FirstNotApprox
//purpose  : return the first Patch not approximated
//==========================================================================================

Standard_Boolean AdvApp2Var_Network::FirstNotApprox(Standard_Integer& Index) const 
{
  Standard_Boolean good = Standard_True;
  Standard_Integer i;
  for (i = 1; i <= myNet.Length() && good; i++) {
    good = myNet.Value(i).IsApproximated();
    if (!good) {Index = i;}
  }
  return !good;
}

//==========================================================================================
//function : UpdateInU
//purpose  : modification and insertion of patches and parameters
//==========================================================================================

void AdvApp2Var_Network::UpdateInU(const Standard_Real CuttingValue)
{

//  insertion du nouveau parametre de decoupe
  Standard_Integer i=1,j;
  while (myUParameters.Value(i)<CuttingValue) {
    i++;
  }
  myUParameters.InsertBefore(i,CuttingValue);

  Standard_Integer indice;
  for (j=1; j< myVParameters.Length() ; j++){

//    modification des patches concernes par la decoupe
    AdvApp2Var_Patch Pat;
    indice = (myUParameters.Length()-1) * (j-1) + i - 1;
    Pat = myNet.Value(indice);
    Pat.ChangeDomain(Pat.U0(), CuttingValue, Pat.V0(), Pat.V1());
    Pat.ResetApprox();
    myNet.SetValue(indice, Pat);

//    insertion des nouveaux patches
    AdvApp2Var_Patch NewPat(CuttingValue,myUParameters.Value(i+1),
			    myVParameters.Value(j),myVParameters.Value(j+1),
			    Pat.UOrder(),Pat.VOrder());
    NewPat.ResetApprox();
    myNet.InsertAfter(indice, NewPat);
  }

}

//==========================================================================================
//function : UpdateInV
//purpose  : modification and insertion of patches and parameters
//==========================================================================================

void AdvApp2Var_Network::UpdateInV(const Standard_Real CuttingValue)
{

//  insertion du nouveau parametre de decoupe
  Standard_Integer i,j=1;
  AdvApp2Var_Patch Pat;
  while (myVParameters.Value(j)<CuttingValue) {
    j++;
  }
  myVParameters.InsertBefore(j,CuttingValue);

//  modification des patches concernes par la decoupe
  Standard_Integer indice;
  for (i=1; i< myUParameters.Length() ; i++){
    indice = (myUParameters.Length()-1) * (j-2) + i;
    Pat = myNet.Value(indice);
    Pat.ChangeDomain(Pat.U0(), Pat.U1(), Pat.V0(), CuttingValue);
    Pat.ResetApprox();
    myNet.SetValue(indice,Pat);
  }

//  insertion des nouveaux patches
  for (i=1; i< myUParameters.Length() ; i++){
    indice = (myUParameters.Length()-1) * (j-1) + i-1;
    AdvApp2Var_Patch NewPat(myUParameters.Value(i), myUParameters.Value(i+1),
			    CuttingValue,myVParameters.Value(j+1),
			    Pat.UOrder(),Pat.VOrder());
    NewPat.ResetApprox();
    myNet.InsertAfter(indice,NewPat);
  }
}

//=======================================================================
//function : SameDegree
//purpose  : same numbers of coefficients for all patches
//=======================================================================

void AdvApp2Var_Network::SameDegree(const Standard_Integer iu,
				    const Standard_Integer iv,
				    Standard_Integer& ncfu,
				    Standard_Integer& ncfv)
{

//  calcul des coeff. max avec init selon l'ordre de continuite
  Standard_Integer IndPat;
  ncfu = 2*iu+2;
  ncfv = 2*iv+2;
  for (IndPat=1;IndPat<=myNet.Length();IndPat++) {
    ncfu = Max(ncfu,myNet.Value(IndPat).NbCoeffInU());
    ncfv = Max(ncfv,myNet.Value(IndPat).NbCoeffInV());
  }

//  augmentation des nombres de coeff.
  AdvApp2Var_Patch Pat;
  for (IndPat=1;IndPat<=myNet.Length();IndPat++) {
    Pat = myNet.Value(IndPat);
    Pat.ChangeNbCoeff(ncfu,ncfv);
    myNet.SetValue(IndPat,Pat);
  }

}

//=======================================================================
//function : NbPatch
//purpose  : 
//=======================================================================

Standard_Integer AdvApp2Var_Network::NbPatch() const
{
  return myNet.Length();
}

//=======================================================================
//function : NbPatchInU
//purpose  : 
//=======================================================================

Standard_Integer AdvApp2Var_Network::NbPatchInU() const
{
  return myUParameters.Length()-1;
}

//=======================================================================
//function : NbPatchInV
//purpose  : 
//=======================================================================

Standard_Integer AdvApp2Var_Network::NbPatchInV() const
{
  return myVParameters.Length()-1;
}

//=======================================================================
//function : UParameter
//purpose  : 
//=======================================================================

Standard_Real AdvApp2Var_Network::UParameter(const Standard_Integer Index) const 
{
  return myUParameters.Value(Index);
}

//=======================================================================
//function : VParameter
//purpose  : 
//=======================================================================

Standard_Real AdvApp2Var_Network::VParameter(const Standard_Integer Index) const 
{
  return myVParameters.Value(Index);
}