0032742: Coding - get rid of unused headers [Adaptor2d to Approx]
[occt.git] / src / AdvApp2Var / AdvApp2Var_Network.cxx
1 // Created on: 1996-07-02
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 // Modified:    Mon Dec  9 11:39:13 1996
18 //   by:        Joelle CHAUVET
19 //              G1135 : empty constructor
20
21 #include <AdvApp2Var_Network.hxx>
22 #include <AdvApp2Var_Patch.hxx>
23 #include <AdvApp2Var_SequenceOfPatch.hxx>
24 #include <TColStd_SequenceOfReal.hxx>
25
26 //==========================================================================================
27 //function : AdvApp2Var_Network
28 //purpose  : 
29 //==========================================================================================
30 AdvApp2Var_Network::AdvApp2Var_Network()
31 {
32 }
33
34
35 //==========================================================================================
36 //function : AdvApp2Var_Network
37 //purpose  : 
38 //==========================================================================================
39
40 AdvApp2Var_Network::AdvApp2Var_Network(const AdvApp2Var_SequenceOfPatch& Net,
41                                        const TColStd_SequenceOfReal& TheU,
42                                        const TColStd_SequenceOfReal& TheV)
43 {
44   myNet=Net;
45   myUParameters=TheU;
46   myVParameters=TheV;
47 }
48
49 //==========================================================================================
50 //function : FirstNotApprox
51 //purpose  : return the first Patch not approximated
52 //==========================================================================================
53
54 Standard_Boolean AdvApp2Var_Network::FirstNotApprox(Standard_Integer& theIndex) const
55 {
56   Standard_Integer anIndex = 1;
57   for (AdvApp2Var_SequenceOfPatch::Iterator aPatchIter (myNet); aPatchIter.More(); aPatchIter.Next(), ++anIndex)
58   {
59     const Handle(AdvApp2Var_Patch)& aPatch = aPatchIter.Value();
60     if (!aPatch->IsApproximated())
61     {
62       theIndex = anIndex;
63       return true;
64     }
65   }
66   return false;
67 }
68
69 //==========================================================================================
70 //function : UpdateInU
71 //purpose  : modification and insertion of patches and parameters
72 //==========================================================================================
73
74 void AdvApp2Var_Network::UpdateInU(const Standard_Real CuttingValue)
75 {
76
77 //  insertion du nouveau parametre de decoupe
78   Standard_Integer i=1,j;
79   while (myUParameters.Value(i)<CuttingValue) {
80     i++;
81   }
82   myUParameters.InsertBefore(i,CuttingValue);
83
84   for (j=1; j< myVParameters.Length() ; j++)
85   {
86 //    modification des patches concernes par la decoupe
87     Standard_Integer indice = (myUParameters.Length()-1) * (j-1) + i - 1;
88     const Handle(AdvApp2Var_Patch)& aPat = myNet.Value(indice);
89     aPat->ChangeDomain (aPat->U0(), CuttingValue, aPat->V0(), aPat->V1());
90     aPat->ResetApprox();
91
92 //    insertion des nouveaux patches
93     Handle(AdvApp2Var_Patch) aNewPat = new AdvApp2Var_Patch (CuttingValue,myUParameters.Value(i+1),
94                             myVParameters.Value(j),myVParameters.Value(j+1),
95                 aPat->UOrder(), aPat->VOrder());
96     aNewPat->ResetApprox();
97     myNet.InsertAfter(indice, aNewPat);
98   }
99
100 }
101
102 //==========================================================================================
103 //function : UpdateInV
104 //purpose  : modification and insertion of patches and parameters
105 //==========================================================================================
106
107 void AdvApp2Var_Network::UpdateInV(const Standard_Real CuttingValue)
108 {
109
110 //  insertion du nouveau parametre de decoupe
111   Standard_Integer j = 1;
112   Handle(AdvApp2Var_Patch) Pat;
113   while (myVParameters.Value(j)<CuttingValue)
114   {
115     j++;
116   }
117   myVParameters.InsertBefore(j,CuttingValue);
118
119 //  modification des patches concernes par la decoupe
120   for (Standard_Integer i = 1; i < myUParameters.Length(); i++)
121   {
122     const Standard_Integer indice = (myUParameters.Length()-1) * (j-2) + i;
123     Pat = myNet.Value(indice);
124     Pat->ChangeDomain(Pat->U0(), Pat->U1(), Pat->V0(), CuttingValue);
125     Pat->ResetApprox();
126   }
127
128 //  insertion des nouveaux patches
129   for (Standard_Integer i = 1; i < myUParameters.Length(); i++)
130   {
131     const Standard_Integer indice = (myUParameters.Length()-1) * (j-1) + i-1;
132     Handle(AdvApp2Var_Patch) aNewPat = new AdvApp2Var_Patch (myUParameters.Value(i), myUParameters.Value(i+1),
133                             CuttingValue,myVParameters.Value(j+1),
134                 Pat->UOrder(),Pat->VOrder());
135     aNewPat->ResetApprox();
136     myNet.InsertAfter (indice, aNewPat);
137   }
138 }
139
140 //=======================================================================
141 //function : SameDegree
142 //purpose  : same numbers of coefficients for all patches
143 //=======================================================================
144
145 void AdvApp2Var_Network::SameDegree(const Standard_Integer iu,
146                                     const Standard_Integer iv,
147                                     Standard_Integer& ncfu,
148                                     Standard_Integer& ncfv)
149 {
150 //  calcul des coeff. max avec init selon l'ordre de continuite
151   ncfu = 2*iu+2;
152   ncfv = 2*iv+2;
153   for (AdvApp2Var_SequenceOfPatch::Iterator aPatIter (myNet); aPatIter.More(); aPatIter.Next())
154   {
155     const Handle(AdvApp2Var_Patch)& aPat = aPatIter.Value();
156     ncfu = Max(ncfu, aPat->NbCoeffInU());
157     ncfv = Max(ncfv, aPat->NbCoeffInV());
158   }
159
160 //  augmentation des nombres de coeff.
161   for (AdvApp2Var_SequenceOfPatch::Iterator aPatIter (myNet); aPatIter.More(); aPatIter.Next())
162   {
163     const Handle(AdvApp2Var_Patch)& aPat = aPatIter.Value();
164     aPat->ChangeNbCoeff (ncfu, ncfv);
165   }
166
167 }
168
169 //=======================================================================
170 //function : NbPatch
171 //purpose  : 
172 //=======================================================================
173
174 Standard_Integer AdvApp2Var_Network::NbPatch() const
175 {
176   return myNet.Length();
177 }
178
179 //=======================================================================
180 //function : NbPatchInU
181 //purpose  : 
182 //=======================================================================
183
184 Standard_Integer AdvApp2Var_Network::NbPatchInU() const
185 {
186   return myUParameters.Length()-1;
187 }
188
189 //=======================================================================
190 //function : NbPatchInV
191 //purpose  : 
192 //=======================================================================
193
194 Standard_Integer AdvApp2Var_Network::NbPatchInV() const
195 {
196   return myVParameters.Length()-1;
197 }
198
199 //=======================================================================
200 //function : UParameter
201 //purpose  : 
202 //=======================================================================
203
204 Standard_Real AdvApp2Var_Network::UParameter(const Standard_Integer Index) const 
205 {
206   return myUParameters.Value(Index);
207 }
208
209 //=======================================================================
210 //function : VParameter
211 //purpose  : 
212 //=======================================================================
213
214 Standard_Real AdvApp2Var_Network::VParameter(const Standard_Integer Index) const 
215 {
216   return myVParameters.Value(Index);
217 }
218