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