0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / AdvApp2Var / AdvApp2Var_Network.cxx
... / ...
CommitLineData
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
9// under the terms of the GNU Lesser General Public 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
22#include <AdvApp2Var_Network.ixx>
23#include <AdvApp2Var_Patch.hxx>
24#include <AdvApp2Var_SequenceOfPatch.hxx>
25#include <TColStd_SequenceOfReal.hxx>
26
27//==========================================================================================
28//function : AdvApp2Var_Network
29//purpose :
30//==========================================================================================
31
32AdvApp2Var_Network::AdvApp2Var_Network()
33{
34}
35
36
37//==========================================================================================
38//function : AdvApp2Var_Network
39//purpose :
40//==========================================================================================
41
42AdvApp2Var_Network::AdvApp2Var_Network(const AdvApp2Var_SequenceOfPatch& Net,
43 const TColStd_SequenceOfReal& TheU,
44 const TColStd_SequenceOfReal& TheV)
45{
46 myNet=Net;
47 myUParameters=TheU;
48 myVParameters=TheV;
49}
50
51//==========================================================================================
52//function : FirstNotApprox
53//purpose : return the first Patch not approximated
54//==========================================================================================
55
56Standard_Boolean AdvApp2Var_Network::FirstNotApprox(Standard_Integer& Index) const
57{
58 Standard_Boolean good = Standard_True;
59 Standard_Integer i;
60 for (i = 1; i <= myNet.Length() && good; i++) {
61 good = myNet.Value(i).IsApproximated();
62 if (!good) {Index = i;}
63 }
64 return !good;
65}
66
67//==========================================================================================
68//function : UpdateInU
69//purpose : modification and insertion of patches and parameters
70//==========================================================================================
71
72void AdvApp2Var_Network::UpdateInU(const Standard_Real CuttingValue)
73{
74
75// insertion du nouveau parametre de decoupe
76 Standard_Integer i=1,j;
77 while (myUParameters.Value(i)<CuttingValue) {
78 i++;
79 }
80 myUParameters.InsertBefore(i,CuttingValue);
81
82 Standard_Integer indice;
83 for (j=1; j< myVParameters.Length() ; j++){
84
85// modification des patches concernes par la decoupe
86 AdvApp2Var_Patch Pat;
87 indice = (myUParameters.Length()-1) * (j-1) + i - 1;
88 Pat = myNet.Value(indice);
89 Pat.ChangeDomain(Pat.U0(), CuttingValue, Pat.V0(), Pat.V1());
90 Pat.ResetApprox();
91 myNet.SetValue(indice, Pat);
92
93// insertion des nouveaux patches
94 AdvApp2Var_Patch NewPat(CuttingValue,myUParameters.Value(i+1),
95 myVParameters.Value(j),myVParameters.Value(j+1),
96 Pat.UOrder(),Pat.VOrder());
97 NewPat.ResetApprox();
98 myNet.InsertAfter(indice, NewPat);
99 }
100
101}
102
103//==========================================================================================
104//function : UpdateInV
105//purpose : modification and insertion of patches and parameters
106//==========================================================================================
107
108void AdvApp2Var_Network::UpdateInV(const Standard_Real CuttingValue)
109{
110
111// insertion du nouveau parametre de decoupe
112 Standard_Integer i,j=1;
113 AdvApp2Var_Patch Pat;
114 while (myVParameters.Value(j)<CuttingValue) {
115 j++;
116 }
117 myVParameters.InsertBefore(j,CuttingValue);
118
119// modification des patches concernes par la decoupe
120 Standard_Integer indice;
121 for (i=1; i< myUParameters.Length() ; i++){
122 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 myNet.SetValue(indice,Pat);
127 }
128
129// insertion des nouveaux patches
130 for (i=1; i< myUParameters.Length() ; i++){
131 indice = (myUParameters.Length()-1) * (j-1) + i-1;
132 AdvApp2Var_Patch NewPat(myUParameters.Value(i), myUParameters.Value(i+1),
133 CuttingValue,myVParameters.Value(j+1),
134 Pat.UOrder(),Pat.VOrder());
135 NewPat.ResetApprox();
136 myNet.InsertAfter(indice,NewPat);
137 }
138}
139
140//=======================================================================
141//function : SameDegree
142//purpose : same numbers of coefficients for all patches
143//=======================================================================
144
145void AdvApp2Var_Network::SameDegree(const Standard_Integer iu,
146 const Standard_Integer iv,
147 Standard_Integer& ncfu,
148 Standard_Integer& ncfv)
149{
150
151// calcul des coeff. max avec init selon l'ordre de continuite
152 Standard_Integer IndPat;
153 ncfu = 2*iu+2;
154 ncfv = 2*iv+2;
155 for (IndPat=1;IndPat<=myNet.Length();IndPat++) {
156 ncfu = Max(ncfu,myNet.Value(IndPat).NbCoeffInU());
157 ncfv = Max(ncfv,myNet.Value(IndPat).NbCoeffInV());
158 }
159
160// augmentation des nombres de coeff.
161 AdvApp2Var_Patch Pat;
162 for (IndPat=1;IndPat<=myNet.Length();IndPat++) {
163 Pat = myNet.Value(IndPat);
164 Pat.ChangeNbCoeff(ncfu,ncfv);
165 myNet.SetValue(IndPat,Pat);
166 }
167
168}
169
170//=======================================================================
171//function : NbPatch
172//purpose :
173//=======================================================================
174
175Standard_Integer AdvApp2Var_Network::NbPatch() const
176{
177 return myNet.Length();
178}
179
180//=======================================================================
181//function : NbPatchInU
182//purpose :
183//=======================================================================
184
185Standard_Integer AdvApp2Var_Network::NbPatchInU() const
186{
187 return myUParameters.Length()-1;
188}
189
190//=======================================================================
191//function : NbPatchInV
192//purpose :
193//=======================================================================
194
195Standard_Integer AdvApp2Var_Network::NbPatchInV() const
196{
197 return myVParameters.Length()-1;
198}
199
200//=======================================================================
201//function : UParameter
202//purpose :
203//=======================================================================
204
205Standard_Real AdvApp2Var_Network::UParameter(const Standard_Integer Index) const
206{
207 return myUParameters.Value(Index);
208}
209
210//=======================================================================
211//function : VParameter
212//purpose :
213//=======================================================================
214
215Standard_Real AdvApp2Var_Network::VParameter(const Standard_Integer Index) const
216{
217 return myVParameters.Value(Index);
218}
219