1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: NMTTools_IteratorOfCoupleOfShape.cxx
23 // Created: Thu Dec 4 17:00:03 2003
24 // Author: Peter KURNEV
27 #include <NMTTools_IteratorOfCoupleOfShape.ixx>
28 #include <Standard_NoSuchObject.hxx>
29 #include <NMTDS_ShapesDataStructure.hxx>
30 #include <BOPTools_CoupleOfInteger.hxx>
31 #include <NMTDS_CArray1OfIndexRange.hxx>
32 #include <BooleanOperations_ShapesDataStructure.hxx>
34 //=======================================================================
37 //=======================================================================
38 NMTTools_IteratorOfCoupleOfShape::NMTTools_IteratorOfCoupleOfShape()
40 BOPTools_IteratorOfCoupleOfShape()
44 myWithSubShapeFlag=Standard_False;
46 //=======================================================================
49 //=======================================================================
50 void NMTTools_IteratorOfCoupleOfShape::SetDS(const NMTDS_PShapesDataStructure& PDS)
53 SetDataStructure(myPNMTPS);
55 //=======================================================================
56 // function: Initialize
58 //=======================================================================
59 void NMTTools_IteratorOfCoupleOfShape::Initialize(const TopAbs_ShapeEnum Type1,
60 const TopAbs_ShapeEnum Type2)
63 Standard_NoSuchObject::Raise("NMTTools_IteratorOfCoupleOfShape::Initialize: myPDS==NULL");
72 myFirstUpperIndex=myPNMTPS->NumberOfShapesOfTheObject();
73 mySecondLowerIndex=myFirstUpperIndex+1;
74 mySecondUpperIndex=myFirstUpperIndex+myPNMTPS->NumberOfShapesOfTheTool();
76 Standard_Integer n1, n2, aIR1, aIR2;//, aN1, aN2, aNS;
78 const NMTDS_CArray1OfIndexRange& aRanges=myPNMTPS->Ranges();
80 //aNS=myPNMTPS->NumberOfShapesOfTheObject();
83 myWithSubShapeFlag=Standard_False;
85 myListOfCouple.Clear();
89 for (; MoreP(); NextP()) {
92 aIR1=myPNMTPS->ShapeRangeIndex(n1);
93 aIR2=myPNMTPS->ShapeRangeIndex(n2);
98 BOPTools_CoupleOfInteger aCouple(n1, n2);
99 myListOfCouple.Append(aCouple);
102 aN1=(n1>aNS)? n1-aNS : n1;
103 aN2=(n2>aNS)? n2-aNS : n2;
104 BOPTools_CoupleOfInteger aCoupleX(aN1, aN2);
108 myIterator.Initialize(myListOfCouple);
110 //=======================================================================
113 //=======================================================================
114 void NMTTools_IteratorOfCoupleOfShape::Current(Standard_Integer& aIndex1,
115 Standard_Integer& aIndex2,
116 Standard_Boolean& aWithSubShape) const
120 aWithSubShape=myWithSubShapeFlag;
122 //=======================================================================
125 //=======================================================================
126 Standard_Boolean NMTTools_IteratorOfCoupleOfShape::More()const
128 Standard_Boolean bMore, bWithSubShape;
129 Standard_Integer n1, n2, aNS, aN1, aN2;
130 BOPTools_CoupleOfInteger aCoupleX;
131 NMTTools_IteratorOfCoupleOfShape* pIt=(NMTTools_IteratorOfCoupleOfShape*)this;
133 aNS=myPNMTPS->NumberOfShapesOfTheObject();
136 pIt->myWithSubShapeFlag=Standard_False;
139 bMore=myIterator.More();
144 BOPTools_IteratorOfCoupleOfShape::Current(n1, n2, bWithSubShape);
145 aN1=(n1>aNS)? n1-aNS : n1;
146 aN2=(n2>aNS)? n2-aNS : n2;
147 aCoupleX.SetCouple(aN1, aN2);
148 if (!myMap.Contains(aCoupleX)) {
149 pIt->myMap.Add(aCoupleX);
153 pIt->myWithSubShapeFlag=bWithSubShape;