Salome HOME
CMake porting.
[modules/geom.git] / src / NMTTools / NMTTools_CommonBlockAPI.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        NMTTools_CommonBlockAPI.cxx
24 // Created:     Mon Dec 15 11:38:04 2003
25 // Author:      Peter KURNEV
26 //              <pkv@irinox>
27 //
28 #include <NMTTools_CommonBlockAPI.hxx>
29
30 #include <BOPTools_PaveBlock.hxx>
31 #include <BOPTools_ListOfPaveBlock.hxx>
32 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
33
34 #include <NMTTools_CommonBlock.hxx>
35 #include <NMTTools_ListOfCommonBlock.hxx>
36 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
37
38 //=======================================================================
39 // function:  NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI
40 // purpose:
41 //=======================================================================
42   NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI (const NMTTools_ListOfCommonBlock& aLCB)
43 {
44   myListOfCommonBlock=(void *)&aLCB;
45 }
46 //=======================================================================
47 // function:  List
48 // purpose:
49 //=======================================================================
50   const NMTTools_ListOfCommonBlock& NMTTools_CommonBlockAPI::List () const
51 {
52   NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
53   return *pListOfCommonBlock;
54 }
55 //=======================================================================
56 // function:  CommonPaveBlocks
57 // purpose:   get all CommonPaveBlocks
58 //=======================================================================
59   const BOPTools_ListOfPaveBlock& NMTTools_CommonBlockAPI::CommonPaveBlocks(const Standard_Integer anE) const
60 {
61   Standard_Integer anECurrent;
62   BOPTools_ListIteratorOfListOfPaveBlock anItPB;
63   //
64   BOPTools_ListOfPaveBlock* pmyListOfPaveBlock=(BOPTools_ListOfPaveBlock*) &myListOfPaveBlock;
65   pmyListOfPaveBlock->Clear();
66
67   NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
68
69   NMTTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock);
70   for (; anIt.More(); anIt.Next()) {
71     const NMTTools_CommonBlock& aCB=anIt.Value();
72     //
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);
80         break;
81       }
82     }
83   }
84   return myListOfPaveBlock;
85 }
86 //=======================================================================
87 // function:  IsCommonBlock
88 // purpose:
89 //=======================================================================
90   Standard_Boolean NMTTools_CommonBlockAPI::IsCommonBlock(const BOPTools_PaveBlock& aPB) const
91 {
92   Standard_Integer anE;
93   //
94   anE=aPB.OriginalEdge();
95   //
96   CommonPaveBlocks(anE);
97   //
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;
103     }
104   }
105   return Standard_False;
106 }
107
108 //=======================================================================
109 // function:  CommonBlock
110 // purpose:
111 //=======================================================================
112   NMTTools_CommonBlock& NMTTools_CommonBlockAPI::CommonBlock(const BOPTools_PaveBlock& aPB)const
113 {
114   static NMTTools_CommonBlock aCBTMP;
115   //
116   NMTTools_ListIteratorOfListOfCommonBlock anItCB;
117   BOPTools_ListIteratorOfListOfPaveBlock anItPB;
118   //
119   NMTTools_ListOfCommonBlock* pLCB=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
120   //
121   anItCB.Initialize(*pLCB);
122   for (; anItCB.More(); anItCB.Next()) {
123     NMTTools_CommonBlock& aCB=anItCB.ChangeValue();
124     //
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)) {
130         return aCB;
131       }
132     }
133   }
134   return aCBTMP;
135 }