From 357e7016f4f6f28144795be74c2c817328172aa6 Mon Sep 17 00:00:00 2001 From: szy Date: Thu, 19 Dec 2013 14:00:59 +0000 Subject: [PATCH] 19.12.2013. Draft version for Groups processing. --- src/HYDROData/HYDROData_SplitToZonesTool.cxx | 167 +++++++++++++------ 1 file changed, 118 insertions(+), 49 deletions(-) diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.cxx b/src/HYDROData/HYDROData_SplitToZonesTool.cxx index cbc77b7c..7e48efb2 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.cxx +++ b/src/HYDROData/HYDROData_SplitToZonesTool.cxx @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -59,7 +60,8 @@ HYDROData_SplitToZonesTool::SplitDataList { SplitDataList anOutputSplitDataList; - // Preparation. Collect the object shapes to split. InputDataList will contain elements which will hold shape & name_of_shape. + // Preparation. + // Collect the object shapes to split. InputDataList will contain elements which will hold shape & name_of_shape. SplitDataList anInputSplitDataList; for( int anIndex = 1, aLength = theObjectList.Length(); anIndex <= aLength; anIndex++ ) { @@ -70,13 +72,13 @@ HYDROData_SplitToZonesTool::SplitDataList TopoDS_Shape aShape = aGeomObj->GetTopShape(); if ( aShape.IsNull() ) - continue; - + continue; + if ( aShape.ShapeType() == TopAbs_COMPOUND ) { // Create split data for each face contained in the compound TopExp_Explorer anExp( aShape, TopAbs_FACE ); for ( ; anExp.More(); anExp.Next() ) { - TopoDS_Face aFace = TopoDS::Face( anExp.Current() ); + const TopoDS_Face& aFace = TopoDS::Face( anExp.Current() ); if ( !aFace.IsNull() ) { SplitData aSplitData( SplitData::Data_Zone, aFace, aGeomObj->GetName() ); anInputSplitDataList.append( aSplitData ); @@ -87,75 +89,128 @@ HYDROData_SplitToZonesTool::SplitDataList anInputSplitDataList.append( aSplitData ); } } + // + SplitDataList anInputGroupList; + for( int anIndex = 1; anIndex <= theGroupsList.Length(); anIndex++ ) + { + Handle(HYDROData_Object) aGeomGroup = + Handle(HYDROData_Object)::DownCast( theGroupsList.Value( anIndex ) ); + if( aGeomGroup.IsNull() ) + continue; + const TopoDS_Shape& aShape = aGeomGroup->GetTopShape(); + if ( aShape.IsNull() ) + continue; + if ( aShape.ShapeType() == TopAbs_COMPOUND ) { + TopExp_Explorer anExp( aShape, TopAbs_EDGE ); + for ( ; anExp.More(); anExp.Next() ) { + const TopoDS_Edge& anEdge = TopoDS::Edge( anExp.Current() ); + if ( !anEdge.IsNull() ) { + SplitData aSplitData( SplitData::Data_Edge, anEdge, aGeomGroup->GetName() ); + anInputGroupList.append( aSplitData ); + } + } + } else { + SplitData aSplitData( SplitData::Data_Edge, aShape, aGeomGroup->GetName() ); + anInputGroupList.append( aSplitData ); + } + } + HYDROData_DataMapOfShapeListOfString aDM3; + if(!anInputGroupList.isEmpty()) { // Old edge ==> List_Of_Names + QStringList aListOfNames; + for (int i=0;i < anInputGroupList.size() ;i++) { + const TopoDS_Shape& aSh = anInputGroupList.at(i).Shape; + 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); BOPCol_ListOfShape aLS; - HYDROData_DataMapOfShapeListOfString aDM3; QStringList aListOfNames; for (int i=0;i < anInputSplitDataList.size() ;i++) { const TopoDS_Shape& aSh = anInputSplitDataList.at(i).Shape; aDM3.Bind(aSh, anInputSplitDataList.at(i).ObjectNames); aLS.Append(aSh); } - aPaveFiller->SetArguments(aLS); - aPaveFiller->Perform(); - Standard_Integer 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(aPaveFiller->Arguments()); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aS = anIt.Value(); - aBuilder->AddArgument(aS); - } - aBuilder->PerformWithFiller(*aPaveFiller); - anErr = aBuilder->ErrorStatus(); - if(anErr) - return anOutputSplitDataList; - const TopoDS_Shape& aResult = aBuilder->Shape(); + aPaveFiller->SetArguments(aLS); + aPaveFiller->Perform(); + Standard_Integer 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(aPaveFiller->Arguments()); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aS = anIt.Value(); + aBuilder->AddArgument(aS); + } + aBuilder->PerformWithFiller(*aPaveFiller); + anErr = aBuilder->ErrorStatus(); + if(anErr) + return anOutputSplitDataList; + const TopoDS_Shape& aResult = aBuilder->Shape(); if (aResult.IsNull()) return anOutputSplitDataList; BRepCheck_Analyzer aCheck (aResult); if(!aCheck.IsValid()) { #ifdef DEB_SPLIT_TO_ZONES - cout << "result is not valid" <Modified(anIt.Value()); TopTools_ListOfShape aList; - TopTools_ListIteratorOfListOfShape it1(aListOfNew); - for(;it1.More();it1.Next()) - aList.Append(it1.Value()); + TopTools_ListIteratorOfListOfShape it(aListOfNew); + 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->Generated(anIt.Value()); - TopTools_ListIteratorOfListOfShape it2(aListOfGen); - for(;it2.More();it2.Next()) - aList.Append(it2.Value()); + it.Initialize(aListOfGen); + for(;it.More();it.Next()) + aList.Append(it.Value()); aDM1.Bind(anIt.Value(), aList); - //cout << "NB_Face = " << aList.Extent() <Modified(exp.Current()); - // cout << "NB_EDGE = " << aList2.Extent() <Modified(exp.Current()); + //cout << "NB_EDGE_M = " << aListM.Extent() <Generated(exp.Current()); + it.Initialize(aListG); + for(int k=1;it.More();it.Next(),k++) { + aList.Append(it.Value()); + //aName = aNamG + i + j +k +".brep"; + //BRepTools::Write(it.Value(),aName.ToCString()); + } + //cout << "NB_EDGE = " << aList.Extent() < ListOfOldShapes @@ -179,11 +234,17 @@ HYDROData_SplitToZonesTool::SplitDataList //cout << "DM2 Ext = " < " << ObjectNames.size() <<" " << aStr.toStdString()<