// Created on: 1996-07-02 // Created by: Joelle CHAUVET // Copyright (c) 1996-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. // Modified: Mon Dec 9 11:39:13 1996 // by: Joelle CHAUVET // G1135 : empty constructor #include #include #include #include #include #include #include namespace { int findStripByBounds( const NCollection_Sequence>>& theConstraints, const double theFirst, const double theLast) { int aStripIndex = 1; while (aStripIndex < theConstraints.Length() && (theConstraints.Value(aStripIndex).First()->T0() != theFirst || theConstraints.Value(aStripIndex).First()->T1() != theLast)) { ++aStripIndex; } return aStripIndex; } int findIsoByConstant(const NCollection_Sequence>& theStrip, const int theNbIso, const double theConst) { int anIsoIndex = 1; while (anIsoIndex <= theNbIso && theStrip.Value(anIsoIndex)->Constante() != theConst) { ++anIsoIndex; } return anIsoIndex; } } // namespace //================================================================================================= AdvApp2Var_Framework::AdvApp2Var_Framework() = default; //================================================================================================= AdvApp2Var_Framework::AdvApp2Var_Framework( const NCollection_Sequence>& Frame, const NCollection_Sequence>>& UFrontier, const NCollection_Sequence>>& VFrontier) { myNodeConstraints = Frame; myUConstraints = UFrontier; myVConstraints = VFrontier; } //================================================================================================= occ::handle AdvApp2Var_Framework::FirstNotApprox(int& IndexIso, int& IndexStrip) const { for (int anUVIter = 0; anUVIter < 2; ++anUVIter) { const NCollection_Sequence>>& aSeq = anUVIter == 0 ? myUConstraints : myVConstraints; int i = 1; for (NCollection_Sequence>>::Iterator aConstIter(aSeq); aConstIter.More(); aConstIter.Next(), i++) { const NCollection_Sequence>& S = aConstIter.Value(); int j = 1; for (NCollection_Sequence>::Iterator anIsoIter(S); anIsoIter.More(); anIsoIter.Next(), j++) { const occ::handle& anIso = anIsoIter.Value(); if (!anIso->IsApproximated()) { IndexIso = j; IndexStrip = i; return anIso; } } } } return occ::handle(); } //================================================================================================= int AdvApp2Var_Framework::FirstNode(const GeomAbs_IsoType Type, const int IndexIso, const int IndexStrip) const { const int aNbIsoInV = myUConstraints.Length() + 1; if (Type == GeomAbs_IsoU) { return aNbIsoInV * (IndexStrip - 1) + IndexIso; } return aNbIsoInV * (IndexIso - 1) + IndexStrip; } //================================================================================================= int AdvApp2Var_Framework::LastNode(const GeomAbs_IsoType Type, const int IndexIso, const int IndexStrip) const { const int aNbIsoInV = myUConstraints.Length() + 1; if (Type == GeomAbs_IsoU) { return aNbIsoInV * IndexStrip + IndexIso; } return aNbIsoInV * (IndexIso - 1) + IndexStrip + 1; } //================================================================================================= void AdvApp2Var_Framework::ChangeIso(const int IndexIso, const int IndexStrip, const occ::handle& theIso) { NCollection_Sequence>& aStrip = theIso->Type() == GeomAbs_IsoV ? myUConstraints.ChangeValue(IndexStrip) : myVConstraints.ChangeValue(IndexStrip); aStrip.SetValue(IndexIso, theIso); } //================================================================================================= const occ::handle& AdvApp2Var_Framework::Node(const double U, const double V) const { for (NCollection_Sequence>::Iterator aNodeIter(myNodeConstraints); aNodeIter.More(); aNodeIter.Next()) { const occ::handle& aNode = aNodeIter.Value(); if (aNode->Coord().X() == U && aNode->Coord().Y() == V) { return aNode; } } return myNodeConstraints.Last(); } //================================================================================================= const AdvApp2Var_Iso& AdvApp2Var_Framework::IsoU(const double U, const double V0, const double V1) const { const int aStripIndex = findStripByBounds(myVConstraints, V0, V1); const NCollection_Sequence>& aStrip = myVConstraints.Value(aStripIndex); const int aIsoIndex = findIsoByConstant(aStrip, myUConstraints.Length(), U); return *(aStrip.Value(aIsoIndex)); } //================================================================================================= const AdvApp2Var_Iso& AdvApp2Var_Framework::IsoV(const double U0, const double U1, const double V) const { const int aStripIndex = findStripByBounds(myUConstraints, U0, U1); const NCollection_Sequence>& aStrip = myUConstraints.Value(aStripIndex); const int aIsoIndex = findIsoByConstant(aStrip, myVConstraints.Length(), V); return *(aStrip.Value(aIsoIndex)); } //================================================================================================= void AdvApp2Var_Framework::UpdateInU(const double CuttingValue) { int aUStripIndex = 1; for (NCollection_Sequence>>::Iterator anUConstIter(myUConstraints); anUConstIter.More(); anUConstIter.Next(), ++aUStripIndex) { if (anUConstIter.Value().First()->U0() <= CuttingValue && anUConstIter.Value().First()->U1() >= CuttingValue) { break; } } { const NCollection_Sequence>& aStrip = myUConstraints.Value(aUStripIndex); const double aUFirst = aStrip.First()->U0(); const double aULast = aStrip.First()->U1(); // Modify the V isos of the U strip at aUStripIndex. for (NCollection_Sequence>::Iterator aStripIter(aStrip); aStripIter.More(); aStripIter.Next()) { const occ::handle& anIso = aStripIter.Value(); anIso->ChangeDomain(aUFirst, CuttingValue); anIso->ResetApprox(); } // Insert a new U strip after aUStripIndex. NCollection_Sequence> aNewStrip; for (NCollection_Sequence>::Iterator aStripIter(aStrip); aStripIter.More(); aStripIter.Next()) { const occ::handle& anIso = aStripIter.Value(); occ::handle aNewIso = new AdvApp2Var_Iso(anIso->Type(), anIso->Constante(), CuttingValue, aULast, anIso->V0(), anIso->V1(), 0, anIso->UOrder(), anIso->VOrder()); aNewIso->ResetApprox(); aNewStrip.Append(aNewIso); } myUConstraints.InsertAfter(aUStripIndex, aNewStrip); } // Insert a new Iso U=U* in each V strip after aUStripIndex // and restrict the domains of the adjacent Isos for (int aVStripIndex = 1; aVStripIndex <= myVConstraints.Length(); aVStripIndex++) { NCollection_Sequence>& aStrip = myVConstraints.ChangeValue(aVStripIndex); occ::handle anIso = aStrip.Value(aUStripIndex); anIso->ChangeDomain(anIso->U0(), CuttingValue, anIso->V0(), anIso->V1()); occ::handle aNewIso = new AdvApp2Var_Iso(anIso->Type(), CuttingValue, anIso->U0(), CuttingValue, anIso->V0(), anIso->V1(), 0, anIso->UOrder(), anIso->VOrder()); aNewIso->ResetApprox(); aStrip.InsertAfter(aUStripIndex, aNewIso); anIso = aStrip.Value(aUStripIndex + 2); anIso->ChangeDomain(CuttingValue, anIso->U1(), anIso->V0(), anIso->V1()); } // Insert the new nodes (U*,Vj) occ::handle aNext; occ::handle aPrev = myNodeConstraints.First(); for (int aNodeIndex = 1; aNodeIndex < myNodeConstraints.Length(); aNodeIndex++) { aNext = myNodeConstraints.Value(aNodeIndex + 1); if (aPrev->Coord().X() < CuttingValue && aNext->Coord().X() > CuttingValue && aPrev->Coord().Y() == aNext->Coord().Y()) { gp_XY aNewUV(CuttingValue, aPrev->Coord().Y()); occ::handle aNewNode = new AdvApp2Var_Node(aNewUV, aPrev->UOrder(), aPrev->VOrder()); myNodeConstraints.InsertAfter(aNodeIndex, aNewNode); } aPrev = aNext; } } //================================================================================================= void AdvApp2Var_Framework::UpdateInV(const double CuttingValue) { int aVStripIndex = 1; while (myVConstraints.Value(aVStripIndex).First()->V0() > CuttingValue || myVConstraints.Value(aVStripIndex).First()->V1() < CuttingValue) { aVStripIndex++; } { NCollection_Sequence>& aStrip = myVConstraints.ChangeValue(aVStripIndex); const double aVFirst = aStrip.First()->V0(); const double aVLast = aStrip.First()->V1(); // Modify the U isos of the V strip at aVStripIndex. for (NCollection_Sequence>::Iterator anIsoIter(aStrip); anIsoIter.More(); anIsoIter.Next()) { const occ::handle& anIso = anIsoIter.Value(); anIso->ChangeDomain(aVFirst, CuttingValue); anIso->ResetApprox(); } // Insert a new V strip after aVStripIndex. NCollection_Sequence> aNewStrip; for (NCollection_Sequence>::Iterator anIsoIter(aStrip); anIsoIter.More(); anIsoIter.Next()) { const occ::handle& anIso = anIsoIter.Value(); occ::handle aNewIso = new AdvApp2Var_Iso(anIso->Type(), anIso->Constante(), anIso->U0(), anIso->U1(), CuttingValue, aVLast, 0, anIso->UOrder(), anIso->VOrder()); aNewIso->ResetApprox(); aNewStrip.Append(aNewIso); } myVConstraints.InsertAfter(aVStripIndex, aNewStrip); } // Insert a new Iso V=V* in each U strip after aVStripIndex // and restrict the domains of the adjacent Isos for (NCollection_Sequence>>::Iterator anUConstIter(myUConstraints); anUConstIter.More(); anUConstIter.Next()) { NCollection_Sequence>& aStrip = anUConstIter.ChangeValue(); occ::handle anIso = aStrip.Value(aVStripIndex); anIso->ChangeDomain(anIso->U0(), anIso->U1(), anIso->V0(), CuttingValue); occ::handle aNewIso = new AdvApp2Var_Iso(anIso->Type(), CuttingValue, anIso->U0(), anIso->U1(), anIso->V0(), CuttingValue, 0, anIso->UOrder(), anIso->VOrder()); aNewIso->ResetApprox(); aStrip.InsertAfter(aVStripIndex, aNewIso); anIso = aStrip.Value(aVStripIndex + 2); anIso->ChangeDomain(anIso->U0(), anIso->U1(), CuttingValue, anIso->V1()); } // Insert the new nodes (Ui,V*) int aNodeStartIndex = 1; while (aNodeStartIndex <= myNodeConstraints.Length() && myNodeConstraints.Value(aNodeStartIndex)->Coord().Y() < CuttingValue) { aNodeStartIndex += myUConstraints.Length() + 1; } for (int anIsoIndex = 1; anIsoIndex <= myUConstraints.Length() + 1; anIsoIndex++) { const occ::handle& aJNode = myNodeConstraints.Value(anIsoIndex); gp_XY NewUV(aJNode->Coord().X(), CuttingValue); occ::handle aNewNode = new AdvApp2Var_Node(NewUV, aJNode->UOrder(), aJNode->VOrder()); myNodeConstraints.InsertAfter(aNodeStartIndex + anIsoIndex - 2, aNewNode); } } //================================================================================================= const occ::handle>& AdvApp2Var_Framework::UEquation( const int IndexIso, const int IndexStrip) const { return myVConstraints.Value(IndexStrip).Value(IndexIso)->Polynom(); } //================================================================================================= const occ::handle>& AdvApp2Var_Framework::VEquation( const int IndexIso, const int IndexStrip) const { return myUConstraints.Value(IndexStrip).Value(IndexIso)->Polynom(); }