1 // Copyright (C) 2007-2011 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
23 // File: NMTTools_IteratorOfCoupleOfShape.cxx
24 // Created: Thu Dec 4 17:00:03 2003
25 // Author: Peter KURNEV
28 #include <NMTTools_IteratorOfCoupleOfShape.ixx>
29 #include <Standard_NoSuchObject.hxx>
30 #include <NMTDS_ShapesDataStructure.hxx>
31 #include <BOPTools_CoupleOfInteger.hxx>
32 #include <NMTDS_CArray1OfIndexRange.hxx>
33 #include <BooleanOperations_ShapesDataStructure.hxx>
35 //=======================================================================
38 //=======================================================================
39 NMTTools_IteratorOfCoupleOfShape::NMTTools_IteratorOfCoupleOfShape()
41 BOPTools_IteratorOfCoupleOfShape()
45 myWithSubShapeFlag=Standard_False;
47 //=======================================================================
50 //=======================================================================
51 void NMTTools_IteratorOfCoupleOfShape::SetDS(const NMTDS_PShapesDataStructure& PDS)
54 SetDataStructure(myPNMTPS);
56 //=======================================================================
57 // function: Initialize
59 //=======================================================================
60 void NMTTools_IteratorOfCoupleOfShape::Initialize(const TopAbs_ShapeEnum Type1,
61 const TopAbs_ShapeEnum Type2)
64 Standard_NoSuchObject::Raise("NMTTools_IteratorOfCoupleOfShape::Initialize: myPDS==NULL");
73 myFirstUpperIndex=myPNMTPS->NumberOfShapesOfTheObject();
74 mySecondLowerIndex=myFirstUpperIndex+1;
75 mySecondUpperIndex=myFirstUpperIndex+myPNMTPS->NumberOfShapesOfTheTool();
77 Standard_Integer n1, n2, aIR1, aIR2;//, aN1, aN2, aNS;
79 /*const NMTDS_CArray1OfIndexRange& aRanges=*/myPNMTPS->Ranges();
81 //aNS=myPNMTPS->NumberOfShapesOfTheObject();
84 myWithSubShapeFlag=Standard_False;
86 myListOfCouple.Clear();
90 for (; MoreP(); NextP()) {
93 aIR1=myPNMTPS->ShapeRangeIndex(n1);
94 aIR2=myPNMTPS->ShapeRangeIndex(n2);
99 BOPTools_CoupleOfInteger aCouple(n1, n2);
100 myListOfCouple.Append(aCouple);
103 aN1=(n1>aNS)? n1-aNS : n1;
104 aN2=(n2>aNS)? n2-aNS : n2;
105 BOPTools_CoupleOfInteger aCoupleX(aN1, aN2);
109 myIterator.Initialize(myListOfCouple);
111 //=======================================================================
114 //=======================================================================
115 void NMTTools_IteratorOfCoupleOfShape::Current(Standard_Integer& aIndex1,
116 Standard_Integer& aIndex2,
117 Standard_Boolean& aWithSubShape) const
121 aWithSubShape=myWithSubShapeFlag;
123 //=======================================================================
126 //=======================================================================
127 Standard_Boolean NMTTools_IteratorOfCoupleOfShape::More()const
129 Standard_Boolean bMore, bWithSubShape;
130 Standard_Integer n1, n2, aNS, aN1, aN2;
131 BOPTools_CoupleOfInteger aCoupleX;
132 NMTTools_IteratorOfCoupleOfShape* pIt=(NMTTools_IteratorOfCoupleOfShape*)this;
134 aNS=myPNMTPS->NumberOfShapesOfTheObject();
137 pIt->myWithSubShapeFlag=Standard_False;
140 bMore=myIterator.More();
145 BOPTools_IteratorOfCoupleOfShape::Current(n1, n2, bWithSubShape);
146 aN1=(n1>aNS)? n1-aNS : n1;
147 aN2=(n2>aNS)? n2-aNS : n2;
148 aCoupleX.SetCouple(aN1, aN2);
149 if (!myMap.Contains(aCoupleX)) {
150 pIt->myMap.Add(aCoupleX);
154 pIt->myWithSubShapeFlag=bWithSubShape;