1 // Copyright (C) 2007-2019 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, or (at your option) any later version.
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 : GEOMAlgo_AlgoTools_2.cxx
24 // Author : Peter KURNEV
26 #include <GEOMAlgo_AlgoTools.hxx>
28 #include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
29 #include <GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
30 #include <TopTools_IndexedMapOfShape.hxx>
31 #include <GEOMAlgo_CoupleOfShapes.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <TopTools_IndexedMapOfShape.hxx>
38 void ProcessBlock(const TopoDS_Shape& aF,
39 const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
40 TopTools_IndexedMapOfShape& aProcessed,
41 TopTools_IndexedMapOfShape& aChain);
43 //=======================================================================
44 // function: FindChains
46 //=======================================================================
47 void GEOMAlgo_AlgoTools::FindChains(const GEOMAlgo_ListOfCoupleOfShapes& aLCS,
48 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains)
50 GEOMAlgo_ListIteratorOfListOfCoupleOfShapes aItCS;
51 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape aMCV;
53 aItCS.Initialize(aLCS);
54 for (; aItCS.More(); aItCS.Next()) {
55 const GEOMAlgo_CoupleOfShapes& aCS=aItCS.Value();
57 const TopoDS_Shape& aF1=aCS.Shape1();
58 const TopoDS_Shape& aF2=aCS.Shape2();
61 if (aMCV.Contains(aF1)) {
62 TopTools_IndexedMapOfShape& aMV=aMCV.ChangeFromKey(aF1);
67 TopTools_IndexedMapOfShape aMV;
73 if (aMCV.Contains(aF2)) {
74 TopTools_IndexedMapOfShape& aMV=aMCV.ChangeFromKey(aF2);
79 TopTools_IndexedMapOfShape aMV;
85 GEOMAlgo_AlgoTools::FindChains(aMCV, aMapChains);
87 //=======================================================================
88 // function: FindChains
90 //=======================================================================
91 void GEOMAlgo_AlgoTools::FindChains(const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
92 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains)
94 Standard_Integer i, j, aNbCV, aNbV;
95 TopTools_IndexedMapOfShape aProcessed, aChain;
98 for (i=1; i<=aNbCV; ++i) {
99 const TopoDS_Shape& aF=aMCV.FindKey(i);
100 if (aProcessed.Contains(aF)) {
107 const TopTools_IndexedMapOfShape& aMV=aMCV(i);
109 for (j=1; j<=aNbV; ++j) {
110 const TopoDS_Shape& aFx=aMV(j);
111 ProcessBlock(aFx, aMCV, aProcessed, aChain);
113 aMapChains.Add(aF, aChain);
117 //=======================================================================
118 // function: ProcessBlock
120 //=======================================================================
121 void ProcessBlock(const TopoDS_Shape& aF,
122 const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
123 TopTools_IndexedMapOfShape& aProcessed,
124 TopTools_IndexedMapOfShape& aChain)
126 Standard_Integer j, aNbV;
128 if (aProcessed.Contains(aF)) {
134 const TopTools_IndexedMapOfShape& aMV=aMCV.FindFromKey(aF);
136 for (j=1; j<=aNbV; ++j) {
137 const TopoDS_Shape& aFx=aMV(j);
138 ProcessBlock(aFx, aMCV, aProcessed, aChain);