]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
26.12.2013. Small update.
authorszy <szy@opencascade.com>
Thu, 26 Dec 2013 14:47:56 +0000 (14:47 +0000)
committerszy <szy@opencascade.com>
Thu, 26 Dec 2013 14:47:56 +0000 (14:47 +0000)
src/HYDROData/HYDROData_SplitToZonesTool.cxx
src/HYDROData/HYDROData_SplitToZonesTool.h

index a4312ab4671110e8e16b579f9c26ffe467621b7f..998667b7dbb903c8b1cfe0c4318ad5374f6d57b9 100644 (file)
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopoDS_Edge.hxx>
-#include <TopoDS_Iterator.hxx>
 #include <BRepCheck_Analyzer.hxx>
-#include <NCollection_IncAllocator.hxx>
-#include <BOPAlgo_Builder.hxx>
-#include <BOPAlgo_PaveFiller.hxx>
-#include <NCollection_Map.hxx>
-#include <NCollection_DataMap.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_ShapeMapHasher.hxx>
 #include <gp_Pln.hxx>
 #include <BRepGProp.hxx>
 #include <GProp_GProps.hxx>
 #include <Geom_Plane.hxx>
 #include <BRepBuilderAPI_FindPlane.hxx>
 
-
-typedef NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> HYDROData_MapOfShape;
-typedef HYDROData_MapOfShape::Iterator HYDROData_MapIteratorOfMapOfShape;
-typedef NCollection_DataMap<TopoDS_Shape, TopTools_ListOfShape, TopTools_ShapeMapHasher> HYDROData_DataMapOfShapeListOfShape;
-typedef HYDROData_DataMapOfShapeListOfShape::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape;
-typedef NCollection_DataMap<TopoDS_Shape,  QStringList, TopTools_ShapeMapHasher> HYDROData_DataMapOfShapeListOfString;
-typedef HYDROData_DataMapOfShapeListOfString::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfString;
-#undef _NCollection_MapHasher
-
 //#define DEB_SPLIT_TO_ZONES 1
 #ifdef DEB_SPLIT_TO_ZONES
 #include <BRepTools.hxx>
@@ -88,6 +72,21 @@ Standard_Boolean buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFac
   }
   return Standard_False;
 }
+//======================================================================================
+Standard_Integer HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& theComp, 
+                                                                                                               HYDROData_Transform& theTool)
+{
+  theTool.Clear();
+  theTool.SetArgument(theComp);
+  theTool.Detect();
+  const Standard_Boolean bToTransform = theTool.ToTransform();  
+  theTool.SetToTransform(bToTransform);  
+  theTool.Perform();
+  Standard_Integer anErr = theTool.ErrorStatus();
+  return anErr;
+}
+
+//======================================================================================
 HYDROData_SplitToZonesTool::SplitDataList
   HYDROData_SplitToZonesTool::Split( const HYDROData_SequenceOfObjects&  theObjectList,
                                      const HYDROData_SequenceOfObjects&  theGroupsList,
@@ -174,12 +173,8 @@ HYDROData_SplitToZonesTool::SplitDataList
       aDM3.Bind(aSh, anInputGroupList.at(i).ObjectNames);
     }
   }
-  // Step 1. Prepare Partition structures.
-  Handle(NCollection_BaseAllocator) pA1 = new NCollection_IncAllocator, pA2 = new NCollection_IncAllocator;
-  BOPAlgo_PaveFiller* aPaveFiller      = new BOPAlgo_PaveFiller(pA1);
-  BOPAlgo_Builder* aBuilder            = new BOPAlgo_Builder(pA2);
+  // Step 1. Prepare Partition structures. 
   BOPCol_ListOfShape aLS;  
-
   QStringList aListOfNames;
   TopoDS_Compound aCmp;
   BRep_Builder aBB;
@@ -192,47 +187,11 @@ HYDROData_SplitToZonesTool::SplitDataList
     //TCollection_AsciiString aName = aNam + i + ".brep";
     //BRepTools::Write(aSh, aName.ToCString());
   }
-  HYDROData_Transform sTool;
-  sTool.Clear();
-  sTool.SetArgument(aCmp);
-  sTool.Detect();
-  const Standard_Boolean bToTransform = sTool.ToTransform();
-  Standard_Integer anErr(0);  
-  sTool.SetToTransform(bToTransform);  
-  sTool.Perform();
-  anErr = sTool.ErrorStatus();
+  HYDROData_Transform splitTool; 
+  const Standard_Integer anErr = SplitFaces(aCmp, splitTool);    
   if(anErr)
     return anOutputSplitDataList;
-  const TopoDS_Shape& aResult = sTool.Shape();
-  /* 
-  else {  
-  BOP ==
-  aPaveFiller->SetArguments(aLS);
-  aPaveFiller->Perform();
-  anErr = aPaveFiller->ErrorStatus();
-  if(anErr) 
-    return anOutputSplitDataList;
-  BOPDS_PDS pDS = aPaveFiller->PDS();
-  if (!pDS) 
-    return anOutputSplitDataList;
-  aBuilder->Clear();
-
-  // Step 2. Split faces 
-  BOPCol_ListIteratorOfListOfShape anIt(aLS);
-  for (; anIt.More(); anIt.Next()) {
-    const TopoDS_Shape& aS = anIt.Value();
-    aBuilder->AddArgument(aS);
-  }
-  aBuilder->PerformWithFiller(*aPaveFiller);
-  anErr = aBuilder->ErrorStatus();
-
-  ////
-  if(anErr) 
-    return anOutputSplitDataList;
-  aResult = aBuilder->Shape();
-  } */
-
+  const TopoDS_Shape& aResult = splitTool.Shape();
   if (aResult.IsNull()) 
     return anOutputSplitDataList;
   BRepCheck_Analyzer aCheck (aResult);
@@ -254,7 +213,7 @@ HYDROData_SplitToZonesTool::SplitDataList
   //TCollection_AsciiString aNamG ("EdgG_");
   for (int i =1;anIt.More();anIt.Next(),i++) {
        Standard_Boolean foundF(Standard_False);
-    const TopTools_ListOfShape& aListOfNew = /*aBuilder->*/sTool.Modified(anIt.Value());
+    const TopTools_ListOfShape& aListOfNew = splitTool.Modified(anIt.Value());
        if(!aListOfNew.IsEmpty())
          foundF = Standard_True;
     TopTools_ListOfShape aList;
@@ -262,7 +221,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     for(;it.More();it.Next())       
       aList.Append(it.Value());
     // Bug in History: partition should give only modified entities! => temporary solution is used
-    const TopTools_ListOfShape& aListOfGen = /*aBuilder->*/sTool.Generated(anIt.Value());
+    const TopTools_ListOfShape& aListOfGen = splitTool.Generated(anIt.Value());
        if(!aListOfGen.IsEmpty())
          foundF = Standard_True;
        it.Initialize(aListOfGen);    
@@ -277,7 +236,7 @@ HYDROData_SplitToZonesTool::SplitDataList
          TopExp_Explorer exp (anIt.Value(), TopAbs_EDGE);
          for (int j =1;exp.More();exp.Next(),j++) {
            Standard_Boolean foundE(Standard_False);
-           const TopTools_ListOfShape& aListM = /*aBuilder->*/sTool.Modified(exp.Current());   
+           const TopTools_ListOfShape& aListM = splitTool.Modified(exp.Current());     
                //cout << "NB_EDGE_M = " << aListM.Extent() <<endl;
                if(aListM.Extent()) foundE = Standard_True;
                it.Initialize(aListM);    
@@ -286,7 +245,7 @@ HYDROData_SplitToZonesTool::SplitDataList
                  //aName = aNamM + i + j +k +".brep";
                  //BRepTools::Write(it.Value(),aName.ToCString());
                }
-               const TopTools_ListOfShape& aListG = /*aBuilder->*/sTool.Generated(exp.Current());
+               const TopTools_ListOfShape& aListG = splitTool.Generated(exp.Current());
                if(aListG.Extent()) foundE = Standard_True;
                it.Initialize(aListG);    
                for(int k=1;it.More();it.Next(),k++)   {  
index 28413ef7ca122a4c7e41129b142efbcb3a4fba9d..2939d5586fe9e018af07aa4c58842109c1dd3369 100644 (file)
@@ -3,9 +3,14 @@
 #define HYDROData_SplitToZonesTool_H
 
 #include <HYDROData_Object.h>
-
+#include <HYDROData_Transform.h>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
 #include <TopoDS_Face.hxx>
-
+#include <TopTools_ShapeMapHasher.hxx>
+#include <NCollection_Map.hxx>
+#include <NCollection_DataMap.hxx>
+#include <TopTools_ListOfShape.hxx>
 #include <QStringList>
 
 class Handle(HYDROData_PolylineXY);
@@ -48,7 +53,14 @@ public:
   };
 
   typedef QList        <SplitData> SplitDataList;
-  typedef QListIterator<SplitData> SplitDataListIterator;
+  typedef QListIterator<SplitData> SplitDataListIterator;  
+  typedef NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> HYDROData_MapOfShape;
+  typedef HYDROData_MapOfShape::Iterator HYDROData_MapIteratorOfMapOfShape;
+  typedef NCollection_DataMap<TopoDS_Shape, TopTools_ListOfShape, TopTools_ShapeMapHasher> HYDROData_DataMapOfShapeListOfShape;
+  typedef HYDROData_DataMapOfShapeListOfShape::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape;
+  typedef NCollection_DataMap<TopoDS_Shape,  QStringList, TopTools_ShapeMapHasher> HYDROData_DataMapOfShapeListOfString;
+  typedef HYDROData_DataMapOfShapeListOfString::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfString;
+  #undef _NCollection_MapHasher
 
 public:
 
@@ -66,6 +78,10 @@ private:
 
   static SplitDataList       ExtractSeparateData( const SplitData& theData );
 
+   /**
+   * Split input faces.
+   */
+  static Standard_Integer SplitFaces(const TopoDS_Compound& theComp, HYDROData_Transform& theTool);
 };
 
 #endif