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

http://pythonocc.googlecode.com/ · C++ · 251 lines · 159 code · 12 blank · 80 comment · 21 complexity · b0c040dcfe8a19b7758228da4307ea47 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_2.cxx
  23. // Created: Mon Dec 8 12:02:56 2003
  24. // Author: Peter KURNEV
  25. // <pkv@irinox>
  26. //
  27. #include <NMTTools_PaveFiller.ixx>
  28. #include <Precision.hxx>
  29. #include <gp_Pnt.hxx>
  30. #include <Geom_Curve.hxx>
  31. #include <TopAbs_Orientation.hxx>
  32. #include <TopoDS.hxx>
  33. #include <TopoDS_Edge.hxx>
  34. #include <TopoDS_Vertex.hxx>
  35. #include <TopoDS_Iterator.hxx>
  36. #include <BRep_Builder.hxx>
  37. #include <BRep_Tool.hxx>
  38. #include <BOPTools_Pave.hxx>
  39. #include <BOPTools_PaveSet.hxx>
  40. #include <BOPTools_CArray1OfVEInterference.hxx>
  41. #include <BOPTools_VEInterference.hxx>
  42. #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
  43. #include <NMTDS_Iterator.hxx>
  44. #include <NMTDS_ShapesDataStructure.hxx>
  45. #include <NMTDS_InterfPool.hxx>
  46. //
  47. // Modified Thu Sep 14 14:35:18 2006
  48. // Contribution of Samtech www.samcef.com BEGIN
  49. #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
  50. #include <BOPTools_CoupleOfInteger.hxx>
  51. #include <BooleanOperations_OnceExplorer.hxx>
  52. static
  53. Standard_Boolean Contains(const TopoDS_Edge& aE,
  54. const TopoDS_Vertex& aV);
  55. // Contribution of Samtech www.samcef.com END
  56. //=======================================================================
  57. // function: PerformVE
  58. // purpose:
  59. //=======================================================================
  60. void NMTTools_PaveFiller::PerformVE()
  61. {
  62. myIsDone=Standard_False;
  63. //
  64. Standard_Boolean bJustAdd;
  65. Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVEs, aBlockLength, iSDV, nV1;
  66. Standard_Real aT;
  67. TopoDS_Vertex aV1;
  68. TopoDS_Edge aE2;
  69. BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
  70. BOPTools_CoupleOfInteger aCouple;
  71. //
  72. BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences();
  73. //
  74. myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
  75. //
  76. // BlockLength correction
  77. aNbVEs=myDSIt->BlockLength();
  78. aBlockLength=aVEs.BlockLength();
  79. if (aNbVEs > aBlockLength) {
  80. aVEs.SetBlockLength(aNbVEs);
  81. }
  82. //
  83. for (; myDSIt->More(); myDSIt->Next()) {
  84. myDSIt->Current(n1, n2, bJustAdd);
  85. if (!IsSuccessorsComputed(n1, n2)) {
  86. anIndexIn=0;
  87. aWhat=n1; // Vertex
  88. aWith=n2; // Edge
  89. if (myDS->GetShapeType(n1)==TopAbs_EDGE) {
  90. aWhat=n2;
  91. aWith=n1;
  92. }
  93. //
  94. if(bJustAdd) {
  95. //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
  96. continue;
  97. }
  98. // Edge
  99. aE2=TopoDS::Edge(myDS->Shape(aWith));
  100. if (BRep_Tool::Degenerated(aE2)){
  101. continue;
  102. }
  103. // Vertex
  104. nV1=aWhat;
  105. aV1=TopoDS::Vertex(myDS->Shape(aWhat));
  106. //
  107. iSDV=FindSDVertex(aWhat);
  108. if (iSDV) {
  109. nV1=iSDV;
  110. aV1=TopoDS::Vertex(myDS->Shape(nV1));
  111. // Modified to find same domain vertex Thu Sep 14 14:35:18 2006
  112. // Contribution of Samtech www.samcef.com BEGIN
  113. Standard_Integer nVE, iSDVE, iRet;
  114. //
  115. BooleanOperations_OnceExplorer aExp(*myDS);
  116. iRet=0;
  117. aExp.Init(aWith, TopAbs_VERTEX);
  118. for (; aExp.More(); aExp.Next()) {
  119. nVE=aExp.Current();
  120. iSDVE=FindSDVertex(nVE);
  121. if (iSDVE==iSDV) {
  122. iRet=1;
  123. break;
  124. }
  125. }
  126. if (iRet) {
  127. continue;
  128. }
  129. }
  130. else {
  131. if (Contains(aE2, aV1)) {
  132. continue;
  133. }
  134. // Contribution of Samtech www.samcef.com END
  135. }
  136. //
  137. aFlag=myContext.ComputeVE (aV1, aE2, aT);
  138. //
  139. if (!aFlag) {
  140. // Add Interference to the Pool
  141. BOPTools_VEInterference anInterf (aWhat, aWith, aT);
  142. anIndexIn=aVEs.Append(anInterf);
  143. //
  144. // Add Pave to the Edge's myPavePool
  145. aCouple.SetCouple(nV1, aWith);
  146. if (!aSnareMap.Contains(aCouple)){
  147. aSnareMap.Add(aCouple);
  148. //
  149. BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
  150. aPave.SetInterference(anIndexIn);
  151. BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
  152. aPaveSet.Append(aPave);
  153. }
  154. //
  155. // State for the Vertex in DS;
  156. myDS->SetState (aWhat, BooleanOperations_ON);
  157. // Insert Vertex in Interference Object
  158. BOPTools_VEInterference& aVE=aVEs(anIndexIn);
  159. aVE.SetNewShape(aWhat);
  160. // qqf
  161. {
  162. myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE);
  163. }
  164. // qqt
  165. }
  166. //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
  167. }
  168. }
  169. myIsDone=Standard_True;
  170. }
  171. //=======================================================================
  172. // function: PrepareEdges
  173. // purpose:
  174. //=======================================================================
  175. void NMTTools_PaveFiller::PrepareEdges()
  176. {
  177. Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject;
  178. Standard_Real aT;
  179. TopAbs_Orientation anOr;
  180. TopoDS_Edge aE;
  181. TopoDS_Vertex aV;
  182. //
  183. aNbShapesObject=myDS->NumberOfShapesOfTheObject();
  184. for (i=1; i<=myNbSources; ++i) {
  185. if (myDS->GetShapeType(i)==TopAbs_EDGE) {
  186. aE=TopoDS::Edge(myDS->Shape(i));
  187. //
  188. if (BRep_Tool::Degenerated(aE)){
  189. continue;
  190. }
  191. //
  192. BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
  193. //
  194. // A <-
  195. aNBSuc=myDS->NumberOfSuccessors(i);
  196. for (ii=1; ii <=aNBSuc; ii++) {
  197. nV=myDS->GetSuccessor(i, ii);
  198. anOr=myDS->GetOrientation(i, ii);
  199. aV=TopoDS::Vertex(myDS->Shape(nV));
  200. aV.Orientation(anOr);
  201. aT=BRep_Tool::Parameter(aV, aE);
  202. //
  203. ip=FindSDVertex(nV);
  204. if (ip) {
  205. aV=TopoDS::Vertex(myDS->Shape(ip));
  206. aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
  207. nV=ip;
  208. }
  209. //
  210. BOPTools_Pave aPave(nV, aT);
  211. aPaveSet.Append (aPave);
  212. }
  213. }
  214. }
  215. }
  216. // Modified Thu Sep 14 14:35:18 2006
  217. // Contribution of Samtech www.samcef.com BEGIN
  218. //=======================================================================
  219. //function : Contains
  220. //purpose :
  221. //=======================================================================
  222. Standard_Boolean Contains(const TopoDS_Edge& aE,
  223. const TopoDS_Vertex& aV)
  224. {
  225. Standard_Boolean bRet;
  226. TopoDS_Iterator aIt;
  227. //
  228. bRet=Standard_False;
  229. aIt.Initialize(aE);
  230. for (; aIt.More(); aIt.Next()) {
  231. const TopoDS_Shape& aVE=aIt.Value();
  232. if (aVE.IsSame(aV)) {
  233. bRet=!bRet;
  234. break;
  235. }
  236. }
  237. return bRet;
  238. }
  239. // Contribution of Samtech www.samcef.com END