1 // File: NMTTools_IteratorOfCoupleOfShape.cxx
2 // Created: Thu Dec 4 17:00:03 2003
3 // Author: Peter KURNEV
7 #include <NMTTools_IteratorOfCoupleOfShape.ixx>
8 #include <Standard_NoSuchObject.hxx>
9 #include <NMTDS_ShapesDataStructure.hxx>
10 #include <BOPTools_CoupleOfInteger.hxx>
11 #include <NMTDS_CArray1OfIndexRange.hxx>
12 #include <BooleanOperations_ShapesDataStructure.hxx>
14 //=======================================================================
17 //=======================================================================
18 NMTTools_IteratorOfCoupleOfShape::NMTTools_IteratorOfCoupleOfShape()
20 BOPTools_IteratorOfCoupleOfShape()
24 myWithSubShapeFlag=Standard_False;
26 //=======================================================================
29 //=======================================================================
30 void NMTTools_IteratorOfCoupleOfShape::SetDS(const NMTDS_PShapesDataStructure& PDS)
33 SetDataStructure(myPNMTPS);
35 //=======================================================================
36 // function: Initialize
38 //=======================================================================
39 void NMTTools_IteratorOfCoupleOfShape::Initialize(const TopAbs_ShapeEnum Type1,
40 const TopAbs_ShapeEnum Type2)
43 Standard_NoSuchObject::Raise("NMTTools_IteratorOfCoupleOfShape::Initialize: myPDS==NULL");
52 myFirstUpperIndex=myPNMTPS->NumberOfShapesOfTheObject();
53 mySecondLowerIndex=myFirstUpperIndex+1;
54 mySecondUpperIndex=myFirstUpperIndex+myPNMTPS->NumberOfShapesOfTheTool();
56 Standard_Integer n1, n2, aIR1, aIR2;//, aN1, aN2, aNS;
58 const NMTDS_CArray1OfIndexRange& aRanges=myPNMTPS->Ranges();
60 //aNS=myPNMTPS->NumberOfShapesOfTheObject();
63 myWithSubShapeFlag=Standard_False;
65 myListOfCouple.Clear();
69 for (; MoreP(); NextP()) {
72 aIR1=myPNMTPS->ShapeRangeIndex(n1);
73 aIR2=myPNMTPS->ShapeRangeIndex(n2);
78 BOPTools_CoupleOfInteger aCouple(n1, n2);
79 myListOfCouple.Append(aCouple);
82 aN1=(n1>aNS)? n1-aNS : n1;
83 aN2=(n2>aNS)? n2-aNS : n2;
84 BOPTools_CoupleOfInteger aCoupleX(aN1, aN2);
88 myIterator.Initialize(myListOfCouple);
90 //=======================================================================
93 //=======================================================================
94 void NMTTools_IteratorOfCoupleOfShape::Current(Standard_Integer& aIndex1,
95 Standard_Integer& aIndex2,
96 Standard_Boolean& aWithSubShape) const
100 aWithSubShape=myWithSubShapeFlag;
102 //=======================================================================
105 //=======================================================================
106 Standard_Boolean NMTTools_IteratorOfCoupleOfShape::More()const
108 Standard_Boolean bMore, bWithSubShape;
109 Standard_Integer n1, n2, aNS, aN1, aN2;
110 BOPTools_CoupleOfInteger aCoupleX;
111 NMTTools_IteratorOfCoupleOfShape* pIt=(NMTTools_IteratorOfCoupleOfShape*)this;
113 aNS=myPNMTPS->NumberOfShapesOfTheObject();
116 pIt->myWithSubShapeFlag=Standard_False;
119 bMore=myIterator.More();
124 BOPTools_IteratorOfCoupleOfShape::Current(n1, n2, bWithSubShape);
125 aN1=(n1>aNS)? n1-aNS : n1;
126 aN2=(n2>aNS)? n2-aNS : n2;
127 aCoupleX.SetCouple(aN1, aN2);
128 if (!myMap.Contains(aCoupleX)) {
129 pIt->myMap.Add(aCoupleX);
133 pIt->myWithSubShapeFlag=bWithSubShape;