Back to index

salome-geom  6.5.0
NMTTools_CommonBlockAPI.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:        NMTTools_CommonBlockAPI.cxx
00024 // Created:     Mon Dec 15 11:38:04 2003
00025 // Author:      Peter KURNEV
00026 //              <pkv@irinox>
00027 //
00028 #include <NMTTools_CommonBlockAPI.hxx>
00029 
00030 #include <BOPTools_PaveBlock.hxx>
00031 #include <BOPTools_ListOfPaveBlock.hxx>
00032 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
00033 
00034 #include <NMTTools_CommonBlock.hxx>
00035 #include <NMTTools_ListOfCommonBlock.hxx>
00036 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
00037 
00038 //=======================================================================
00039 // function:  NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI
00040 // purpose:
00041 //=======================================================================
00042   NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI (const NMTTools_ListOfCommonBlock& aLCB)
00043 {
00044   myListOfCommonBlock=(void *)&aLCB;
00045 }
00046 //=======================================================================
00047 // function:  List
00048 // purpose:
00049 //=======================================================================
00050   const NMTTools_ListOfCommonBlock& NMTTools_CommonBlockAPI::List () const
00051 {
00052   NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
00053   return *pListOfCommonBlock;
00054 }
00055 //=======================================================================
00056 // function:  CommonPaveBlocks
00057 // purpose:   get all CommonPaveBlocks
00058 //=======================================================================
00059   const BOPTools_ListOfPaveBlock& NMTTools_CommonBlockAPI::CommonPaveBlocks(const Standard_Integer anE) const
00060 {
00061   Standard_Integer anECurrent;
00062   BOPTools_ListIteratorOfListOfPaveBlock anItPB;
00063   //
00064   BOPTools_ListOfPaveBlock* pmyListOfPaveBlock=(BOPTools_ListOfPaveBlock*) &myListOfPaveBlock;
00065   pmyListOfPaveBlock->Clear();
00066 
00067   NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
00068 
00069   NMTTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock);
00070   for (; anIt.More(); anIt.Next()) {
00071     const NMTTools_CommonBlock& aCB=anIt.Value();
00072     //
00073     const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
00074     anItPB.Initialize(aLPB);
00075     for (; anItPB.More(); anItPB.Next()) {
00076       const BOPTools_PaveBlock& aPB=anItPB.Value();
00077       anECurrent=aPB.OriginalEdge();
00078       if (anECurrent==anE) {
00079         pmyListOfPaveBlock->Append(aPB);
00080         break;
00081       }
00082     }
00083   }
00084   return myListOfPaveBlock;
00085 }
00086 //=======================================================================
00087 // function:  IsCommonBlock
00088 // purpose:
00089 //=======================================================================
00090   Standard_Boolean NMTTools_CommonBlockAPI::IsCommonBlock(const BOPTools_PaveBlock& aPB) const
00091 {
00092   Standard_Integer anE;
00093   //
00094   anE=aPB.OriginalEdge();
00095   //
00096   CommonPaveBlocks(anE);
00097   //
00098   BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock);
00099   for (; anIt.More(); anIt.Next()) {
00100     const BOPTools_PaveBlock& aPB1=anIt.Value();
00101     if (aPB1.IsEqual(aPB)) {
00102       return Standard_True;
00103     }
00104   }
00105   return Standard_False;
00106 }
00107 
00108 //=======================================================================
00109 // function:  CommonBlock
00110 // purpose:
00111 //=======================================================================
00112   NMTTools_CommonBlock& NMTTools_CommonBlockAPI::CommonBlock(const BOPTools_PaveBlock& aPB)const
00113 {
00114   static NMTTools_CommonBlock aCBTMP;
00115   //
00116   NMTTools_ListIteratorOfListOfCommonBlock anItCB;
00117   BOPTools_ListIteratorOfListOfPaveBlock anItPB;
00118   //
00119   NMTTools_ListOfCommonBlock* pLCB=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock;
00120   //
00121   anItCB.Initialize(*pLCB);
00122   for (; anItCB.More(); anItCB.Next()) {
00123     NMTTools_CommonBlock& aCB=anItCB.ChangeValue();
00124     //
00125     const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
00126     anItPB.Initialize(aLPB);
00127     for (; anItPB.More(); anItPB.Next()) {
00128       const BOPTools_PaveBlock& aPBx=anItPB.Value();
00129       if (aPBx.IsEqual(aPB)) {
00130         return aCB;
00131       }
00132     }
00133   }
00134   return aCBTMP;
00135 }