1 // Copyright (C) 2007-2008 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
22 // File: NMTTools_CommonBlockAPI.cxx
23 // Created: Mon Dec 15 11:38:04 2003
24 // Author: Peter KURNEV
27 #include <NMTTools_CommonBlockAPI.ixx>
29 #include <BOPTools_PaveBlock.hxx>
30 #include <BOPTools_ListOfPaveBlock.hxx>
31 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
33 #include <NMTTools_CommonBlock.hxx>
34 #include <NMTTools_ListOfCommonBlock.hxx>
35 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
37 //=======================================================================
38 // function: NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI
40 //=======================================================================
41 NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI (const NMTTools_ListOfCommonBlock& aLCB)
43 myListOfCommonBlock=(void *)&aLCB;
45 //=======================================================================
48 //=======================================================================
49 const NMTTools_ListOfCommonBlock& NMTTools_CommonBlockAPI::List () const
51 NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
52 return *pListOfCommonBlock;
54 //=======================================================================
55 // function: CommonPaveBlocks
56 // purpose: get all CommonPaveBlocks
57 //=======================================================================
58 const BOPTools_ListOfPaveBlock& NMTTools_CommonBlockAPI::CommonPaveBlocks(const Standard_Integer anE) const
60 Standard_Integer anECurrent;
61 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
63 BOPTools_ListOfPaveBlock* pmyListOfPaveBlock=(BOPTools_ListOfPaveBlock*) &myListOfPaveBlock;
64 pmyListOfPaveBlock->Clear();
66 NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
68 NMTTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock);
69 for (; anIt.More(); anIt.Next()) {
70 const NMTTools_CommonBlock& aCB=anIt.Value();
72 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
73 anItPB.Initialize(aLPB);
74 for (; anItPB.More(); anItPB.Next()) {
75 const BOPTools_PaveBlock& aPB=anItPB.Value();
76 anECurrent=aPB.OriginalEdge();
77 if (anECurrent==anE) {
78 pmyListOfPaveBlock->Append(aPB);
83 return myListOfPaveBlock;
85 //=======================================================================
86 // function: IsCommonBlock
88 //=======================================================================
89 Standard_Boolean NMTTools_CommonBlockAPI::IsCommonBlock(const BOPTools_PaveBlock& aPB) const
93 anE=aPB.OriginalEdge();
95 CommonPaveBlocks(anE);
97 BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock);
98 for (; anIt.More(); anIt.Next()) {
99 const BOPTools_PaveBlock& aPB1=anIt.Value();
100 if (aPB1.IsEqual(aPB)) {
101 return Standard_True;
104 return Standard_False;
107 //=======================================================================
108 // function: CommonBlock
110 //=======================================================================
111 NMTTools_CommonBlock& NMTTools_CommonBlockAPI::CommonBlock(const BOPTools_PaveBlock& aPB)const
113 static NMTTools_CommonBlock aCBTMP;
115 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
116 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
118 NMTTools_ListOfCommonBlock* pLCB=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
120 anItCB.Initialize(*pLCB);
121 for (; anItCB.More(); anItCB.Next()) {
122 NMTTools_CommonBlock& aCB=anItCB.Value();
124 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
125 anItPB.Initialize(aLPB);
126 for (; anItPB.More(); anItPB.Next()) {
127 const BOPTools_PaveBlock& aPBx=anItPB.Value();
128 if (aPBx.IsEqual(aPB)) {