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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified: Mon Dec 9 11:39:13 1996
19 // G1135 : empty constructor
22 #include <AdvApp2Var_Framework.hxx>
23 #include <AdvApp2Var_Iso.hxx>
24 #include <AdvApp2Var_Strip.hxx>
25 #include <AdvApp2Var_SequenceOfStrip.hxx>
26 #include <AdvApp2Var_Node.hxx>
27 #include <AdvApp2Var_SequenceOfNode.hxx>
28 #include <TColStd_HArray1OfReal.hxx>
31 //==========================================================================================
32 //function : AdvApp2Var_Framework
34 //==========================================================================================
36 AdvApp2Var_Framework::AdvApp2Var_Framework()
41 //==========================================================================================
42 //function : AdvApp2Var_Framework
44 //==========================================================================================
46 AdvApp2Var_Framework::AdvApp2Var_Framework(const AdvApp2Var_SequenceOfNode& Frame,
47 const AdvApp2Var_SequenceOfStrip& UFrontier,
48 const AdvApp2Var_SequenceOfStrip& VFrontier)
50 myNodeConstraints = Frame;
51 myUConstraints = UFrontier;
52 myVConstraints = VFrontier;
55 //==========================================================================================
56 //function : FirstNotApprox
57 //purpose : return the first Iso not approximated
58 //==========================================================================================
60 Standard_Boolean AdvApp2Var_Framework::FirstNotApprox(Standard_Integer& IndexIso,
61 Standard_Integer& IndexStrip,
62 AdvApp2Var_Iso& anIso) const
64 Standard_Boolean good = Standard_True;
68 for (i = 1; i <= myUConstraints.Length() && good ; i++) {
69 S = myUConstraints.Value(i);
70 for (j = 1; j <= S.Length() && good ; j++) {
71 good = (S.Value(j)).IsApproximated();
83 for (i = 1; i <= myVConstraints.Length() && good; i++) {
84 S = myVConstraints.Value(i);
85 for (j = 1; j <= S.Length() && good ; j++) {
86 good = (S.Value(j)).IsApproximated();
99 //==========================================================================================
100 //function : FirstNode
101 //purpose : return the first node of an iso
102 //==========================================================================================
104 Standard_Integer AdvApp2Var_Framework::FirstNode(const GeomAbs_IsoType Type,
105 const Standard_Integer IndexIso,
106 const Standard_Integer IndexStrip) const
108 Standard_Integer NbIso,Index;
109 NbIso = myUConstraints.Length()+1;
110 if (Type==GeomAbs_IsoU) {
111 Index = NbIso * (IndexStrip-1) + IndexIso;
115 Index = NbIso * (IndexIso-1) + IndexStrip;
120 //==========================================================================================
121 //function : LastNode
122 //purpose : return the last node of an iso
123 //==========================================================================================
125 Standard_Integer AdvApp2Var_Framework::LastNode(const GeomAbs_IsoType Type,
126 const Standard_Integer IndexIso,
127 const Standard_Integer IndexStrip) const
129 Standard_Integer NbIso,Index;
130 NbIso = myUConstraints.Length()+1;
131 if (Type==GeomAbs_IsoU) {
132 Index = NbIso * IndexStrip + IndexIso;
136 Index = NbIso * (IndexIso-1) + IndexStrip + 1;
141 //==========================================================================================
142 //function : ChangeIso
143 //purpose : replace the iso IndexIso of the strip IndexStrip by anIso
144 //==========================================================================================
146 void AdvApp2Var_Framework::ChangeIso(const Standard_Integer IndexIso,
147 const Standard_Integer IndexStrip,
148 const AdvApp2Var_Iso& anIso)
151 if (anIso.Type()==GeomAbs_IsoV) {
152 S0 = myUConstraints.Value(IndexStrip);
153 S0.SetValue(IndexIso,anIso);
154 myUConstraints.SetValue(IndexStrip,S0);
157 S0 = myVConstraints.Value(IndexStrip);
158 S0.SetValue(IndexIso,anIso);
159 myVConstraints.SetValue(IndexStrip,S0);
163 //==========================================================================================
165 //purpose : return the node of coordinates (U,V)
166 //==========================================================================================
168 const AdvApp2Var_Node& AdvApp2Var_Framework::Node(const Standard_Real U,
169 const Standard_Real V) const
171 Standard_Integer Index=1;
172 while ( ( ((myNodeConstraints.Value(Index)).Coord()).X() != U
173 || ((myNodeConstraints.Value(Index)).Coord()).Y() != V )
174 && (Index<myNodeConstraints.Length()) ) {
177 return myNodeConstraints.Value(Index);
180 //==========================================================================================
182 //purpose : return the Iso U=U with V0<=V<=V1
183 //==========================================================================================
185 const AdvApp2Var_Iso&
186 AdvApp2Var_Framework::IsoU(const Standard_Real U,
187 const Standard_Real V0,
188 const Standard_Real V1) const
190 Standard_Integer IndexStrip=1,IndexIso=1;
191 while ( ( ((myVConstraints.Value(IndexStrip)).Value(1)).T0() != V0
192 || ((myVConstraints.Value(IndexStrip)).Value(1)).T1() != V1 )
193 && (IndexStrip<myVConstraints.Length()) ) {
196 while ( ( ((myVConstraints.Value(IndexStrip)).Value(IndexIso)).Constante() != U)
197 && (IndexIso<=myUConstraints.Length()) ) {
200 return (myVConstraints.Value(IndexStrip)).Value(IndexIso);
203 //==========================================================================================
205 //purpose : return the Iso V=V with U0<=U<=U1
206 //==========================================================================================
208 const AdvApp2Var_Iso&
209 AdvApp2Var_Framework::IsoV(const Standard_Real U0,
210 const Standard_Real U1,
211 const Standard_Real V) const
213 Standard_Integer IndexStrip=1,IndexIso=1;
214 while ( ( ((myUConstraints.Value(IndexStrip)).Value(1)).T0() != U0
215 || ((myUConstraints.Value(IndexStrip)).Value(1)).T1() != U1 )
216 && (IndexStrip<myUConstraints.Length()) ) {
219 while ( ( ((myUConstraints.Value(IndexStrip)).Value(IndexIso)).Constante() != V)
220 && (IndexIso<=myVConstraints.Length()) ) {
223 return (myUConstraints.Value(IndexStrip)).Value(IndexIso);
226 //==========================================================================================
227 //function : UpdateInU
228 //purpose : modification and insertion of nodes and isos
229 //==========================================================================================
231 void AdvApp2Var_Framework::UpdateInU(const Standard_Real CuttingValue)
233 Standard_Integer i=1,j;
234 while (((myUConstraints.Value(i)).Value(1)).U0()>CuttingValue
235 || ((myUConstraints.Value(i)).Value(1)).U1()<CuttingValue) {
240 S0 = myUConstraints.Value(i);
241 Standard_Real Udeb = (S0.Value(1)).U0(), Ufin = (S0.Value(1)).U1();
243 // modification des Isos V de la bande en U d'indice i
244 for (j=1;j<=S0.Length();j++) {
246 Is.ChangeDomain(Udeb,CuttingValue);
250 myUConstraints.SetValue(i,S0);
252 // insertion d'une nouvelle bande en U apres l'indice i
253 AdvApp2Var_Strip NewStrip;
254 for (j=1;j<=S0.Length();j++) {
255 AdvApp2Var_Iso NewIso((S0.Value(j)).Type(),(S0.Value(j)).Constante(),
256 CuttingValue,Ufin,(S0.Value(j)).V0(),(S0.Value(j)).V1(),
257 0,(S0.Value(j)).UOrder(),(S0.Value(j)).VOrder());
258 NewIso.ResetApprox();
259 NewStrip.Append(NewIso);
261 myUConstraints.InsertAfter(i,NewStrip);
263 // insertion d'une nouvelle Iso U=U* dans chaque bande en V apres l'indice i
264 // et restriction des paves des Isos adjacentes
265 for (j=1;j<=myVConstraints.Length();j++) {
266 S0 = myVConstraints.Value(j);
268 Is.ChangeDomain(Is.U0(),CuttingValue,Is.V0(),Is.V1());
270 AdvApp2Var_Iso NewIso(Is.Type(),CuttingValue,Is.U0(),CuttingValue,Is.V0(),Is.V1(),
271 0,Is.UOrder(),Is.VOrder());
272 NewIso.ResetApprox();
273 S0.InsertAfter(i,NewIso);
275 Is.ChangeDomain(CuttingValue,Is.U1(),Is.V0(),Is.V1());
277 myVConstraints.SetValue(j,S0);
280 // insertion des nouveaux noeuds (U*,Vj)
281 AdvApp2Var_Node Prev, Next;
282 Prev=myNodeConstraints.Value(1);
283 for (j=1;j<myNodeConstraints.Length();j++) {
284 Next=myNodeConstraints.Value(j+1);
285 if ((Prev.Coord()).X()<CuttingValue && ((Next.Coord()).X()>CuttingValue)
286 && ((Prev.Coord()).Y()==(Next.Coord()).Y())) {
287 gp_XY NewUV(CuttingValue,(Prev.Coord()).Y());
288 AdvApp2Var_Node NewNode(NewUV,Prev.UOrder(),Prev.VOrder());
289 myNodeConstraints.InsertAfter(j,NewNode);
295 //==========================================================================================
296 //function : UpdateInV
297 //purpose : modification and insertion of nodes and isos
298 //==========================================================================================
300 void AdvApp2Var_Framework::UpdateInV(const Standard_Real CuttingValue)
302 Standard_Integer i,j=1;
303 while (((myVConstraints.Value(j)).Value(1)).V0()>CuttingValue
304 || ((myVConstraints.Value(j)).Value(1)).V1()<CuttingValue) {
309 S0 = myVConstraints.Value(j);
310 Standard_Real Vdeb = (S0.Value(1)).V0(), Vfin = (S0.Value(1)).V1();
312 // modification des Isos U de la bande en V d'indice j
313 for (i=1;i<=S0.Length();i++) {
315 Is.ChangeDomain(Vdeb,CuttingValue);
319 myVConstraints.SetValue(j,S0);
321 // insertion d'une nouvelle bande en V apres l'indice j
322 AdvApp2Var_Strip NewStrip;
323 for (i=1;i<=S0.Length();i++) {
324 AdvApp2Var_Iso NewIso((S0.Value(i)).Type(),(S0.Value(i)).Constante(),
325 (S0.Value(i)).U0(),(S0.Value(i)).U1(),CuttingValue,Vfin,
326 0,(S0.Value(i)).UOrder(),(S0.Value(i)).VOrder());
327 NewIso.ResetApprox();
328 NewStrip.Append(NewIso);
330 myVConstraints.InsertAfter(j,NewStrip);
332 // insertion d'une nouvelle Iso V=V* dans chaque bande en U apres l'indice j
333 // et restriction des paves des Isos adjacentes
334 for (i=1;i<=myUConstraints.Length();i++) {
335 S0 = myUConstraints.Value(i);
337 Is.ChangeDomain(Is.U0(),Is.U1(),Is.V0(),CuttingValue);
339 AdvApp2Var_Iso NewIso(Is.Type(),CuttingValue,Is.U0(),Is.U1(),Is.V0(),CuttingValue,
340 0,Is.UOrder(),Is.VOrder());
341 NewIso.ResetApprox();
342 S0.InsertAfter(j,NewIso);
344 Is.ChangeDomain(Is.U0(),Is.U1(),CuttingValue,Is.V1());
346 myUConstraints.SetValue(i,S0);
349 // insertion des nouveaux noeuds (Ui,V*)
351 while ( i<=myNodeConstraints.Length()
352 && ( ((myNodeConstraints.Value(i)).Coord()).Y()) < CuttingValue) {
353 i+=myUConstraints.Length()+1;
355 for (j=1;j<=myUConstraints.Length()+1;j++) {
356 gp_XY NewUV(((myNodeConstraints.Value(j)).Coord()).X(),CuttingValue);
357 AdvApp2Var_Node NewNode(NewUV,
358 (myNodeConstraints.Value(j)).UOrder(),
359 (myNodeConstraints.Value(j)).VOrder());
360 myNodeConstraints.InsertAfter(i+j-2,NewNode);
364 //==========================================================================================
365 //function : UEquation
366 //purpose : return the coefficients of the polynomial equation which approximates an iso U
367 //==========================================================================================
369 const Handle(TColStd_HArray1OfReal)&
370 AdvApp2Var_Framework::UEquation(const Standard_Integer IndexIso,
371 const Standard_Integer IndexStrip) const
373 return ((myVConstraints.Value(IndexStrip)).Value(IndexIso)).Polynom();
376 //==========================================================================================
377 //function : VEquation
378 //purpose : return the coefficients of the polynomial equation which approximates an iso V
379 //==========================================================================================
381 const Handle(TColStd_HArray1OfReal)&
382 AdvApp2Var_Framework::VEquation(const Standard_Integer IndexIso,
383 const Standard_Integer IndexStrip) const
385 return myUConstraints.Value(IndexStrip).Value(IndexIso).Polynom();