1 // Copyright (C) 2007-2013 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_CommonBlockAPI.cxx
24 // Created: Mon Dec 15 11:38:04 2003
25 // Author: Peter KURNEV
28 #include <NMTTools_CommonBlockAPI.hxx>
30 #include <BOPTools_PaveBlock.hxx>
31 #include <BOPTools_ListOfPaveBlock.hxx>
32 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
34 #include <NMTTools_CommonBlock.hxx>
35 #include <NMTTools_ListOfCommonBlock.hxx>
36 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
38 //=======================================================================
39 // function: NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI
41 //=======================================================================
42 NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI (const NMTTools_ListOfCommonBlock& aLCB)
44 myListOfCommonBlock=(void *)&aLCB;
46 //=======================================================================
49 //=======================================================================
50 const NMTTools_ListOfCommonBlock& NMTTools_CommonBlockAPI::List () const
52 NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
53 return *pListOfCommonBlock;
55 //=======================================================================
56 // function: CommonPaveBlocks
57 // purpose: get all CommonPaveBlocks
58 //=======================================================================
59 const BOPTools_ListOfPaveBlock& NMTTools_CommonBlockAPI::CommonPaveBlocks(const Standard_Integer anE) const
61 Standard_Integer anECurrent;
62 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
64 BOPTools_ListOfPaveBlock* pmyListOfPaveBlock=(BOPTools_ListOfPaveBlock*) &myListOfPaveBlock;
65 pmyListOfPaveBlock->Clear();
67 NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
69 NMTTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock);
70 for (; anIt.More(); anIt.Next()) {
71 const NMTTools_CommonBlock& aCB=anIt.Value();
73 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
74 anItPB.Initialize(aLPB);
75 for (; anItPB.More(); anItPB.Next()) {
76 const BOPTools_PaveBlock& aPB=anItPB.Value();
77 anECurrent=aPB.OriginalEdge();
78 if (anECurrent==anE) {
79 pmyListOfPaveBlock->Append(aPB);
84 return myListOfPaveBlock;
86 //=======================================================================
87 // function: IsCommonBlock
89 //=======================================================================
90 Standard_Boolean NMTTools_CommonBlockAPI::IsCommonBlock(const BOPTools_PaveBlock& aPB) const
94 anE=aPB.OriginalEdge();
96 CommonPaveBlocks(anE);
98 BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock);
99 for (; anIt.More(); anIt.Next()) {
100 const BOPTools_PaveBlock& aPB1=anIt.Value();
101 if (aPB1.IsEqual(aPB)) {
102 return Standard_True;
105 return Standard_False;
108 //=======================================================================
109 // function: CommonBlock
111 //=======================================================================
112 NMTTools_CommonBlock& NMTTools_CommonBlockAPI::CommonBlock(const BOPTools_PaveBlock& aPB)const
114 static NMTTools_CommonBlock aCBTMP;
116 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
117 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
119 NMTTools_ListOfCommonBlock* pLCB=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
121 anItCB.Initialize(*pLCB);
122 for (; anItCB.More(); anItCB.Next()) {
123 NMTTools_CommonBlock& aCB=anItCB.ChangeValue();
125 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
126 anItPB.Initialize(aLPB);
127 for (; anItPB.More(); anItPB.Next()) {
128 const BOPTools_PaveBlock& aPBx=anItPB.Value();
129 if (aPBx.IsEqual(aPB)) {