PageRenderTime 28ms CodeModel.GetById 12ms app.highlight 13ms RepoModel.GetById 2ms app.codeStats 0ms

/src/contrib/geom-5.1.2.7/src/GEOMAlgo/GEOMAlgo_WireSolid.cpp

http://pythonocc.googlecode.com/
C++ | 172 lines | 104 code | 8 blank | 60 comment | 19 complexity | 771f57dd46a9cb87971d27449f66e4f9 MD5 | raw file
  1//  Copyright (C) 2007-2008  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// File:	GEOMAlgo_WireSolid.cxx
 23// Created:	Wed Jan 12 10:19:31 2005
 24// Author:	Peter KURNEV
 25//		<pkv@irinox>
 26//
 27#include <GEOMAlgo_WireSolid.ixx>
 28
 29#include <Standard_Failure.hxx>
 30
 31#include <TopAbs_ShapeEnum.hxx>
 32
 33#include <TopTools_ListIteratorOfListOfShape.hxx>
 34
 35#include <BOPTColStd_Dump.hxx>
 36
 37#include <BooleanOperations_ShapesDataStructure.hxx>
 38#include <BooleanOperations_StateOfShape.hxx>
 39
 40#include <BOPTools_PaveFiller.hxx>
 41#include <BOPTools_SplitShapesPool.hxx>
 42#include <BOPTools_PaveBlock.hxx>
 43#include <BOPTools_ListOfPaveBlock.hxx>
 44#include <BOPTools_DSFiller.hxx>
 45#include <BOPTools_WireStateFiller.hxx>
 46
 47//=======================================================================
 48//function : GEOMAlgo_WireSolid
 49//purpose  : 
 50//=======================================================================
 51GEOMAlgo_WireSolid::GEOMAlgo_WireSolid()
 52: 
 53  GEOMAlgo_ShapeSolid()
 54{
 55}
 56//=======================================================================
 57//function : ~
 58//purpose  : 
 59//=======================================================================
 60GEOMAlgo_WireSolid::~GEOMAlgo_WireSolid()
 61{
 62}
 63//=======================================================================
 64// function: Perform
 65// purpose: 
 66//=======================================================================
 67void GEOMAlgo_WireSolid::Perform()
 68{
 69  myErrorStatus=0;
 70  //
 71  try {
 72    if (myDSFiller==NULL) {
 73      myErrorStatus=10;
 74      return;
 75    }
 76    if(!myDSFiller->IsDone()) {
 77      myErrorStatus=11;
 78      return;
 79    }
 80    //
 81    Standard_Boolean bIsNewFiller;
 82    //
 83    bIsNewFiller=myDSFiller->IsNewFiller();
 84    
 85    if (bIsNewFiller) {
 86      Prepare();
 87      myDSFiller->SetNewFiller(!bIsNewFiller);
 88    }
 89    BuildResult();
 90  }
 91  //
 92  catch (Standard_Failure) {
 93    myErrorStatus= 12;
 94  }
 95} 
 96//=======================================================================
 97// function: Prepare
 98// purpose: 
 99//=======================================================================
100void GEOMAlgo_WireSolid::Prepare()
101{
102  const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller();
103  //
104  BOPTools_WireStateFiller aStateFiller(aPaveFiller);
105  aStateFiller.Do();
106  //
107}
108//=======================================================================
109// function: BuildResult
110// purpose: 
111//=======================================================================
112void GEOMAlgo_WireSolid::BuildResult()
113{
114  const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
115  const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller();
116  const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool();
117  //
118  Standard_Integer i, aNbPB, nSp, iBeg, iEnd;
119  TopAbs_ShapeEnum aType;
120  BooleanOperations_StateOfShape aState;
121  //
122  myLSIN.Clear();
123  myLSOUT.Clear();
124  myLSON.Clear();
125  //
126  iBeg=1;
127  iEnd=aDS.NumberOfShapesOfTheObject();
128  if (aDS.Tool().ShapeType()==TopAbs_WIRE) {
129    iBeg=iEnd+1;
130    iEnd=aDS.NumberOfSourceShapes();
131  }
132  //
133  for (i=iBeg; i<=iEnd; ++i) {
134    aType=aDS.GetShapeType(i);
135    if (aType==TopAbs_EDGE) {
136      const TopoDS_Shape& aE=aDS.Shape(i);
137      const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(i));
138      aNbPB=aLPB.Extent();
139      //
140      if (!aNbPB) {
141	aState=aDS.GetState(i);
142	//
143	if (aState==BooleanOperations_IN) {
144	  myLSIN.Append(aE);
145	}
146	else if (aState==BooleanOperations_OUT) {
147	  myLSOUT.Append(aE);
148	}
149	else if (aState==BooleanOperations_ON) {
150	  myLSON.Append(aE);
151	}
152      }
153      //
154      else if (aNbPB==1) {
155	const BOPTools_PaveBlock& aPB=aLPB.First();
156	nSp=aPB.Edge();
157	const TopoDS_Shape& aSp=aDS.Shape(nSp);
158	aState=aDS.GetState(nSp);
159	 //
160	if (aState==BooleanOperations_IN) {
161	  myLSIN.Append(aE);
162	}
163	else if (aState==BooleanOperations_OUT) {
164	  myLSOUT.Append(aE);
165	}
166	else if (aState==BooleanOperations_ON) {
167	  myLSON.Append(aE);
168	} 
169      }
170    }
171  }
172}