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/
20 // File: NMTTools_CommonBlockAPI.cxx
21 // Created: Mon Dec 15 11:38:04 2003
22 // Author: Peter KURNEV
26 #include <NMTTools_CommonBlockAPI.ixx>
28 #include <BOPTools_PaveBlock.hxx>
29 #include <BOPTools_ListOfPaveBlock.hxx>
30 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
32 #include <NMTTools_CommonBlock.hxx>
33 #include <NMTTools_ListOfCommonBlock.hxx>
34 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
36 //=======================================================================
37 // function: NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI
39 //=======================================================================
40 NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI (const NMTTools_ListOfCommonBlock& aLCB)
42 myListOfCommonBlock=(void *)&aLCB;
44 //=======================================================================
47 //=======================================================================
48 const NMTTools_ListOfCommonBlock& NMTTools_CommonBlockAPI::List () const
50 NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
51 return *pListOfCommonBlock;
53 //=======================================================================
54 // function: CommonPaveBlocks
55 // purpose: get all CommonPaveBlocks
56 //=======================================================================
57 const BOPTools_ListOfPaveBlock& NMTTools_CommonBlockAPI::CommonPaveBlocks(const Standard_Integer anE) const
59 Standard_Integer anECurrent;
60 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
62 BOPTools_ListOfPaveBlock* pmyListOfPaveBlock=(BOPTools_ListOfPaveBlock*) &myListOfPaveBlock;
63 pmyListOfPaveBlock->Clear();
65 NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
67 NMTTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock);
68 for (; anIt.More(); anIt.Next()) {
69 const NMTTools_CommonBlock& aCB=anIt.Value();
71 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
72 anItPB.Initialize(aLPB);
73 for (; anItPB.More(); anItPB.Next()) {
74 const BOPTools_PaveBlock& aPB=anItPB.Value();
75 anECurrent=aPB.OriginalEdge();
76 if (anECurrent==anE) {
77 pmyListOfPaveBlock->Append(aPB);
82 return myListOfPaveBlock;
84 //=======================================================================
85 // function: IsCommonBlock
87 //=======================================================================
88 Standard_Boolean NMTTools_CommonBlockAPI::IsCommonBlock(const BOPTools_PaveBlock& aPB) const
92 anE=aPB.OriginalEdge();
94 CommonPaveBlocks(anE);
96 BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock);
97 for (; anIt.More(); anIt.Next()) {
98 const BOPTools_PaveBlock& aPB1=anIt.Value();
99 if (aPB1.IsEqual(aPB)) {
100 return Standard_True;
103 return Standard_False;
106 //=======================================================================
107 // function: CommonBlock
109 //=======================================================================
110 NMTTools_CommonBlock& NMTTools_CommonBlockAPI::CommonBlock(const BOPTools_PaveBlock& aPB)const
112 static NMTTools_CommonBlock aCBTMP;
114 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
115 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
117 NMTTools_ListOfCommonBlock* pLCB=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
119 anItCB.Initialize(*pLCB);
120 for (; anItCB.More(); anItCB.Next()) {
121 NMTTools_CommonBlock& aCB=anItCB.Value();
123 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
124 anItPB.Initialize(aLPB);
125 for (; anItPB.More(); anItPB.Next()) {
126 const BOPTools_PaveBlock& aPBx=anItPB.Value();
127 if (aPBx.IsEqual(aPB)) {