1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTTools_IteratorOfCoupleOfShape.cxx
21 // Created: Thu Dec 4 17:00:03 2003
22 // Author: Peter KURNEV
26 #include <NMTTools_IteratorOfCoupleOfShape.ixx>
27 #include <Standard_NoSuchObject.hxx>
28 #include <NMTDS_ShapesDataStructure.hxx>
29 #include <BOPTools_CoupleOfInteger.hxx>
30 #include <NMTDS_CArray1OfIndexRange.hxx>
31 #include <BooleanOperations_ShapesDataStructure.hxx>
33 //=======================================================================
36 //=======================================================================
37 NMTTools_IteratorOfCoupleOfShape::NMTTools_IteratorOfCoupleOfShape()
39 BOPTools_IteratorOfCoupleOfShape()
43 myWithSubShapeFlag=Standard_False;
45 //=======================================================================
48 //=======================================================================
49 void NMTTools_IteratorOfCoupleOfShape::SetDS(const NMTDS_PShapesDataStructure& PDS)
52 SetDataStructure(myPNMTPS);
54 //=======================================================================
55 // function: Initialize
57 //=======================================================================
58 void NMTTools_IteratorOfCoupleOfShape::Initialize(const TopAbs_ShapeEnum Type1,
59 const TopAbs_ShapeEnum Type2)
62 Standard_NoSuchObject::Raise("NMTTools_IteratorOfCoupleOfShape::Initialize: myPDS==NULL");
71 myFirstUpperIndex=myPNMTPS->NumberOfShapesOfTheObject();
72 mySecondLowerIndex=myFirstUpperIndex+1;
73 mySecondUpperIndex=myFirstUpperIndex+myPNMTPS->NumberOfShapesOfTheTool();
75 Standard_Integer n1, n2, aIR1, aIR2;//, aN1, aN2, aNS;
77 const NMTDS_CArray1OfIndexRange& aRanges=myPNMTPS->Ranges();
79 //aNS=myPNMTPS->NumberOfShapesOfTheObject();
82 myWithSubShapeFlag=Standard_False;
84 myListOfCouple.Clear();
88 for (; MoreP(); NextP()) {
91 aIR1=myPNMTPS->ShapeRangeIndex(n1);
92 aIR2=myPNMTPS->ShapeRangeIndex(n2);
97 BOPTools_CoupleOfInteger aCouple(n1, n2);
98 myListOfCouple.Append(aCouple);
101 aN1=(n1>aNS)? n1-aNS : n1;
102 aN2=(n2>aNS)? n2-aNS : n2;
103 BOPTools_CoupleOfInteger aCoupleX(aN1, aN2);
107 myIterator.Initialize(myListOfCouple);
109 //=======================================================================
112 //=======================================================================
113 void NMTTools_IteratorOfCoupleOfShape::Current(Standard_Integer& aIndex1,
114 Standard_Integer& aIndex2,
115 Standard_Boolean& aWithSubShape) const
119 aWithSubShape=myWithSubShapeFlag;
121 //=======================================================================
124 //=======================================================================
125 Standard_Boolean NMTTools_IteratorOfCoupleOfShape::More()const
127 Standard_Boolean bMore, bWithSubShape;
128 Standard_Integer n1, n2, aNS, aN1, aN2;
129 BOPTools_CoupleOfInteger aCoupleX;
130 NMTTools_IteratorOfCoupleOfShape* pIt=(NMTTools_IteratorOfCoupleOfShape*)this;
132 aNS=myPNMTPS->NumberOfShapesOfTheObject();
135 pIt->myWithSubShapeFlag=Standard_False;
138 bMore=myIterator.More();
143 BOPTools_IteratorOfCoupleOfShape::Current(n1, n2, bWithSubShape);
144 aN1=(n1>aNS)? n1-aNS : n1;
145 aN2=(n2>aNS)? n2-aNS : n2;
146 aCoupleX.SetCouple(aN1, aN2);
147 if (!myMap.Contains(aCoupleX)) {
148 pIt->myMap.Add(aCoupleX);
152 pIt->myWithSubShapeFlag=bWithSubShape;