/src/contrib/geom-5.1.2.7/src/NMTTools/NMTTools_PaveFiller_9.cpp

http://pythonocc.googlecode.com/ · C++ · 126 lines · 78 code · 10 blank · 38 comment · 7 complexity · fb356d09bd08d72de83e63df9b3a1ec4 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: NMTTools_PaveFiller_9.cxx
  23. // Created: Fri Dec 19 11:15:53 2003
  24. // Author: Peter KURNEV
  25. // <pkv@irinox>
  26. //
  27. #include <NMTTools_PaveFiller.ixx>
  28. #include <Geom_Surface.hxx>
  29. #include <TopLoc_Location.hxx>
  30. #include <TopAbs_Orientation.hxx>
  31. #include <TopoDS.hxx>
  32. #include <TopoDS_Face.hxx>
  33. #include <TopoDS_Wire.hxx>
  34. #include <TopoDS_Edge.hxx>
  35. #include <TopoDS_Shape.hxx>
  36. #include <BRep_Builder.hxx>
  37. #include <BRep_Tool.hxx>
  38. #include <TopExp_Explorer.hxx>
  39. #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
  40. #include <BOPTools_ListOfPaveBlock.hxx>
  41. #include <BOPTools_PaveBlock.hxx>
  42. #include <BOPTools_Tools3D.hxx>
  43. #include <NMTDS_ShapesDataStructure.hxx>
  44. #include <NMTTools_CommonBlockAPI.hxx>
  45. #include <NMTTools_CommonBlock.hxx>
  46. //=======================================================================
  47. // function: PrepareFace
  48. // purpose:
  49. //=======================================================================
  50. void NMTTools_PaveFiller::PrepareFace(const Standard_Integer nF,
  51. TopoDS_Face& newFace)
  52. {
  53. Standard_Boolean bToReverse, bIsDegenerated;
  54. Standard_Integer iRankF, nE, nSp, aNbPB;
  55. Standard_Real aTol;
  56. TopLoc_Location aLoc;
  57. TopoDS_Face aF;
  58. TopoDS_Wire newWire;
  59. TopoDS_Edge aSp;
  60. TopAbs_Orientation anOrF, anOrE;
  61. BRep_Builder aBB;
  62. TopExp_Explorer aExpW, aExpE;
  63. BOPTools_ListIteratorOfListOfPaveBlock aItPB;
  64. //
  65. iRankF=myDS->Rank(nF);
  66. aF=TopoDS::Face(myDS->Shape(nF));
  67. anOrF=aF.Orientation();
  68. aF.Orientation(TopAbs_FORWARD);
  69. //
  70. Handle(Geom_Surface) aS=BRep_Tool::Surface(aF, aLoc);
  71. aTol=BRep_Tool::Tolerance(aF);
  72. //
  73. aBB.MakeFace (newFace, aS, aLoc, aTol);
  74. //
  75. aExpW.Init(aF, TopAbs_WIRE);
  76. for (; aExpW.More(); aExpW.Next()) {
  77. const TopoDS_Shape& aW=aExpW.Current();
  78. aBB.MakeWire(newWire);
  79. //
  80. aExpE.Init(aW, TopAbs_EDGE);
  81. for (; aExpE.More(); aExpE.Next()) {
  82. const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current());
  83. bIsDegenerated=BRep_Tool::Degenerated(aE);
  84. anOrE=aE.Orientation();
  85. //
  86. nE=myDS->ShapeIndex(aE, iRankF);
  87. const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
  88. aNbPB=aLPB.Extent();
  89. if (!aNbPB) {
  90. aBB.Add(newWire, aE);
  91. continue;
  92. }
  93. //
  94. aItPB.Initialize(aLPB);
  95. for (; aItPB.More(); aItPB.Next()) {
  96. const BOPTools_PaveBlock& aPB=aItPB.Value();
  97. const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB);
  98. nSp=aPBR.Edge();
  99. //
  100. aSp=TopoDS::Edge(myDS->Shape(nSp));
  101. if (!bIsDegenerated) {
  102. bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, myContext);
  103. if (bToReverse) {
  104. aSp.Reverse();
  105. }
  106. }
  107. else {
  108. aSp.Orientation(anOrE);
  109. }
  110. aBB.Add(newWire, aSp);
  111. }
  112. }
  113. aBB.Add(newFace, newWire);
  114. }
  115. newFace.Orientation(anOrF);
  116. }