Back to index

salome-geom  6.5.0
GEOMAlgo_WireSolid.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:        GEOMAlgo_WireSolid.cxx
00024 // Created:     Wed Jan 12 10:19:31 2005
00025 // Author:      Peter KURNEV
00026 //              <pkv@irinox>
00027 //
00028 #include <GEOMAlgo_WireSolid.hxx>
00029 
00030 #include <Standard_Failure.hxx>
00031 
00032 #include <TopAbs_ShapeEnum.hxx>
00033 
00034 #include <TopTools_ListIteratorOfListOfShape.hxx>
00035 
00036 #include <BOPTColStd_Dump.hxx>
00037 
00038 #include <BooleanOperations_ShapesDataStructure.hxx>
00039 #include <BooleanOperations_StateOfShape.hxx>
00040 
00041 #include <BOPTools_PaveFiller.hxx>
00042 #include <BOPTools_SplitShapesPool.hxx>
00043 #include <BOPTools_PaveBlock.hxx>
00044 #include <BOPTools_ListOfPaveBlock.hxx>
00045 #include <BOPTools_DSFiller.hxx>
00046 #include <BOPTools_WireStateFiller.hxx>
00047 
00048 //=======================================================================
00049 //function : GEOMAlgo_WireSolid
00050 //purpose  :
00051 //=======================================================================
00052 GEOMAlgo_WireSolid::GEOMAlgo_WireSolid()
00053 :
00054   GEOMAlgo_ShapeSolid()
00055 {
00056 }
00057 //=======================================================================
00058 //function : ~
00059 //purpose  :
00060 //=======================================================================
00061 GEOMAlgo_WireSolid::~GEOMAlgo_WireSolid()
00062 {
00063 }
00064 //=======================================================================
00065 // function: Perform
00066 // purpose:
00067 //=======================================================================
00068 void GEOMAlgo_WireSolid::Perform()
00069 {
00070   myErrorStatus=0;
00071   //
00072   try {
00073     if (myDSFiller==NULL) {
00074       myErrorStatus=10;
00075       return;
00076     }
00077     if(!myDSFiller->IsDone()) {
00078       myErrorStatus=11;
00079       return;
00080     }
00081     //
00082     Standard_Boolean bIsNewFiller;
00083     //
00084     bIsNewFiller=myDSFiller->IsNewFiller();
00085 
00086     if (bIsNewFiller) {
00087       Prepare();
00088       myDSFiller->SetNewFiller(!bIsNewFiller);
00089     }
00090     BuildResult();
00091   }
00092   //
00093   catch (Standard_Failure) {
00094     myErrorStatus= 12;
00095   }
00096 }
00097 //=======================================================================
00098 // function: Prepare
00099 // purpose:
00100 //=======================================================================
00101 void GEOMAlgo_WireSolid::Prepare()
00102 {
00103   const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller();
00104   //
00105   BOPTools_WireStateFiller aStateFiller(aPaveFiller);
00106   aStateFiller.Do();
00107   //
00108 }
00109 //=======================================================================
00110 // function: BuildResult
00111 // purpose:
00112 //=======================================================================
00113 void GEOMAlgo_WireSolid::BuildResult()
00114 {
00115   const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
00116   const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller();
00117   const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool();
00118   //
00119   Standard_Integer i, aNbPB, nSp, iBeg, iEnd;
00120   TopAbs_ShapeEnum aType;
00121   BooleanOperations_StateOfShape aState;
00122   //
00123   myLSIN.Clear();
00124   myLSOUT.Clear();
00125   myLSON.Clear();
00126   //
00127   iBeg=1;
00128   iEnd=aDS.NumberOfShapesOfTheObject();
00129   if (aDS.Tool().ShapeType()==TopAbs_WIRE) {
00130     iBeg=iEnd+1;
00131     iEnd=aDS.NumberOfSourceShapes();
00132   }
00133   //
00134   for (i=iBeg; i<=iEnd; ++i) {
00135     aType=aDS.GetShapeType(i);
00136     if (aType==TopAbs_EDGE) {
00137       const TopoDS_Shape& aE=aDS.Shape(i);
00138       const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(i));
00139       aNbPB=aLPB.Extent();
00140       //
00141       if (!aNbPB) {
00142         aState=aDS.GetState(i);
00143         //
00144         if (aState==BooleanOperations_IN) {
00145           myLSIN.Append(aE);
00146         }
00147         else if (aState==BooleanOperations_OUT) {
00148           myLSOUT.Append(aE);
00149         }
00150         else if (aState==BooleanOperations_ON) {
00151           myLSON.Append(aE);
00152         }
00153       }
00154       //
00155       else if (aNbPB==1) {
00156         const BOPTools_PaveBlock& aPB=aLPB.First();
00157         nSp=aPB.Edge();
00158         /*const TopoDS_Shape& aSp=*/aDS.Shape(nSp);
00159         aState=aDS.GetState(nSp);
00160          //
00161         if (aState==BooleanOperations_IN) {
00162           myLSIN.Append(aE);
00163         }
00164         else if (aState==BooleanOperations_OUT) {
00165           myLSOUT.Append(aE);
00166         }
00167         else if (aState==BooleanOperations_ON) {
00168           myLSON.Append(aE);
00169         }
00170       }
00171     }
00172   }
00173 }