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