0023024: Update headers of OCCT files
[occt.git] / src / AdvApp2Var / AdvApp2Var_Network.cxx
CommitLineData
b311480e 1// Created on: 1996-07-02
2// Created by: Joelle CHAUVET
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21// Modified: Mon Dec 9 11:39:13 1996
22// by: Joelle CHAUVET
23// G1135 : empty constructor
24
25
26#include <AdvApp2Var_Network.ixx>
27#include <AdvApp2Var_Patch.hxx>
28#include <AdvApp2Var_SequenceOfPatch.hxx>
29#include <TColStd_SequenceOfReal.hxx>
30
31//==========================================================================================
32//function : AdvApp2Var_Network
33//purpose :
34//==========================================================================================
35
36AdvApp2Var_Network::AdvApp2Var_Network()
37{
38}
39
40
41//==========================================================================================
42//function : AdvApp2Var_Network
43//purpose :
44//==========================================================================================
45
46AdvApp2Var_Network::AdvApp2Var_Network(const AdvApp2Var_SequenceOfPatch& Net,
47 const TColStd_SequenceOfReal& TheU,
48 const TColStd_SequenceOfReal& TheV)
49{
50 myNet=Net;
51 myUParameters=TheU;
52 myVParameters=TheV;
53}
54
55//==========================================================================================
56//function : FirstNotApprox
57//purpose : return the first Patch not approximated
58//==========================================================================================
59
60Standard_Boolean AdvApp2Var_Network::FirstNotApprox(Standard_Integer& Index) const
61{
62 Standard_Boolean good = Standard_True;
63 Standard_Integer i;
64 for (i = 1; i <= myNet.Length() && good; i++) {
65 good = myNet.Value(i).IsApproximated();
66 if (!good) {Index = i;}
67 }
68 return !good;
69}
70
71//==========================================================================================
72//function : UpdateInU
73//purpose : modification and insertion of patches and parameters
74//==========================================================================================
75
76void AdvApp2Var_Network::UpdateInU(const Standard_Real CuttingValue)
77{
78
79// insertion du nouveau parametre de decoupe
80 Standard_Integer i=1,j;
81 while (myUParameters.Value(i)<CuttingValue) {
82 i++;
83 }
84 myUParameters.InsertBefore(i,CuttingValue);
85
86 Standard_Integer indice;
87 for (j=1; j< myVParameters.Length() ; j++){
88
89// modification des patches concernes par la decoupe
90 AdvApp2Var_Patch Pat;
91 indice = (myUParameters.Length()-1) * (j-1) + i - 1;
92 Pat = myNet.Value(indice);
93 Pat.ChangeDomain(Pat.U0(), CuttingValue, Pat.V0(), Pat.V1());
94 Pat.ResetApprox();
95 myNet.SetValue(indice, Pat);
96
97// insertion des nouveaux patches
98 AdvApp2Var_Patch NewPat(CuttingValue,myUParameters.Value(i+1),
99 myVParameters.Value(j),myVParameters.Value(j+1),
100 Pat.UOrder(),Pat.VOrder());
101 NewPat.ResetApprox();
102 myNet.InsertAfter(indice, NewPat);
103 }
104
105}
106
107//==========================================================================================
108//function : UpdateInV
109//purpose : modification and insertion of patches and parameters
110//==========================================================================================
111
112void AdvApp2Var_Network::UpdateInV(const Standard_Real CuttingValue)
113{
114
115// insertion du nouveau parametre de decoupe
116 Standard_Integer i,j=1;
117 AdvApp2Var_Patch Pat;
118 while (myVParameters.Value(j)<CuttingValue) {
119 j++;
120 }
121 myVParameters.InsertBefore(j,CuttingValue);
122
123// modification des patches concernes par la decoupe
124 Standard_Integer indice;
125 for (i=1; i< myUParameters.Length() ; i++){
126 indice = (myUParameters.Length()-1) * (j-2) + i;
127 Pat = myNet.Value(indice);
128 Pat.ChangeDomain(Pat.U0(), Pat.U1(), Pat.V0(), CuttingValue);
129 Pat.ResetApprox();
130 myNet.SetValue(indice,Pat);
131 }
132
133// insertion des nouveaux patches
134 for (i=1; i< myUParameters.Length() ; i++){
135 indice = (myUParameters.Length()-1) * (j-1) + i-1;
136 AdvApp2Var_Patch NewPat(myUParameters.Value(i), myUParameters.Value(i+1),
137 CuttingValue,myVParameters.Value(j+1),
138 Pat.UOrder(),Pat.VOrder());
139 NewPat.ResetApprox();
140 myNet.InsertAfter(indice,NewPat);
141 }
142}
143
144//=======================================================================
145//function : SameDegree
146//purpose : same numbers of coefficients for all patches
147//=======================================================================
148
149void AdvApp2Var_Network::SameDegree(const Standard_Integer iu,
150 const Standard_Integer iv,
151 Standard_Integer& ncfu,
152 Standard_Integer& ncfv)
153{
154
155// calcul des coeff. max avec init selon l'ordre de continuite
156 Standard_Integer IndPat;
157 ncfu = 2*iu+2;
158 ncfv = 2*iv+2;
159 for (IndPat=1;IndPat<=myNet.Length();IndPat++) {
160 ncfu = Max(ncfu,myNet.Value(IndPat).NbCoeffInU());
161 ncfv = Max(ncfv,myNet.Value(IndPat).NbCoeffInV());
162 }
163
164// augmentation des nombres de coeff.
165 AdvApp2Var_Patch Pat;
166 for (IndPat=1;IndPat<=myNet.Length();IndPat++) {
167 Pat = myNet.Value(IndPat);
168 Pat.ChangeNbCoeff(ncfu,ncfv);
169 myNet.SetValue(IndPat,Pat);
170 }
171
172}
173
174//=======================================================================
175//function : NbPatch
176//purpose :
177//=======================================================================
178
179Standard_Integer AdvApp2Var_Network::NbPatch() const
180{
181 return myNet.Length();
182}
183
184//=======================================================================
185//function : NbPatchInU
186//purpose :
187//=======================================================================
188
189Standard_Integer AdvApp2Var_Network::NbPatchInU() const
190{
191 return myUParameters.Length()-1;
192}
193
194//=======================================================================
195//function : NbPatchInV
196//purpose :
197//=======================================================================
198
199Standard_Integer AdvApp2Var_Network::NbPatchInV() const
200{
201 return myVParameters.Length()-1;
202}
203
204//=======================================================================
205//function : UParameter
206//purpose :
207//=======================================================================
208
209Standard_Real AdvApp2Var_Network::UParameter(const Standard_Integer Index) const
210{
211 return myUParameters.Value(Index);
212}
213
214//=======================================================================
215//function : VParameter
216//purpose :
217//=======================================================================
218
219Standard_Real AdvApp2Var_Network::VParameter(const Standard_Integer Index) const
220{
221 return myVParameters.Value(Index);
222}
223