From 8c05a41958c8a87be3a7fbdf67d06f368349f71e Mon Sep 17 00:00:00 2001 From: szy Date: Thu, 26 Dec 2013 14:47:56 +0000 Subject: [PATCH] 26.12.2013. Small update. --- src/HYDROData/HYDROData_SplitToZonesTool.cxx | 87 ++++++-------------- src/HYDROData/HYDROData_SplitToZonesTool.h | 22 ++++- 2 files changed, 42 insertions(+), 67 deletions(-) diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.cxx b/src/HYDROData/HYDROData_SplitToZonesTool.cxx index a4312ab4..998667b7 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.cxx +++ b/src/HYDROData/HYDROData_SplitToZonesTool.cxx @@ -14,31 +14,15 @@ #include #include #include -#include #include -#include -#include -#include -#include -#include #include #include -#include #include #include #include #include #include - -typedef NCollection_Map HYDROData_MapOfShape; -typedef HYDROData_MapOfShape::Iterator HYDROData_MapIteratorOfMapOfShape; -typedef NCollection_DataMap HYDROData_DataMapOfShapeListOfShape; -typedef HYDROData_DataMapOfShapeListOfShape::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape; -typedef NCollection_DataMap HYDROData_DataMapOfShapeListOfString; -typedef HYDROData_DataMapOfShapeListOfString::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfString; -#undef _NCollection_MapHasher - //#define DEB_SPLIT_TO_ZONES 1 #ifdef DEB_SPLIT_TO_ZONES #include @@ -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() <*/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++) { diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.h b/src/HYDROData/HYDROData_SplitToZonesTool.h index 28413ef7..2939d558 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.h +++ b/src/HYDROData/HYDROData_SplitToZonesTool.h @@ -3,9 +3,14 @@ #define HYDROData_SplitToZonesTool_H #include - +#include +#include +#include #include - +#include +#include +#include +#include #include class Handle(HYDROData_PolylineXY); @@ -48,7 +53,14 @@ public: }; typedef QList SplitDataList; - typedef QListIterator SplitDataListIterator; + typedef QListIterator SplitDataListIterator; + typedef NCollection_Map HYDROData_MapOfShape; + typedef HYDROData_MapOfShape::Iterator HYDROData_MapIteratorOfMapOfShape; + typedef NCollection_DataMap HYDROData_DataMapOfShapeListOfShape; + typedef HYDROData_DataMapOfShapeListOfShape::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape; + typedef NCollection_DataMap 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 -- 2.39.2