From ae522e78e8c55629201efc69831cc49c6fe83a61 Mon Sep 17 00:00:00 2001 From: adv Date: Fri, 20 Dec 2013 10:50:40 +0000 Subject: [PATCH] Algorithm corrected for case from one shape (Bug #269 and Bug #271) --- src/HYDROData/HYDROData_SplitToZonesTool.cxx | 170 ++++++++++--------- 1 file changed, 89 insertions(+), 81 deletions(-) diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.cxx b/src/HYDROData/HYDROData_SplitToZonesTool.cxx index 1ae7a1b2..6f20f0d6 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.cxx +++ b/src/HYDROData/HYDROData_SplitToZonesTool.cxx @@ -29,7 +29,7 @@ typedef HYDROData_DataMapOfShapeListOfString::Iterator HYDROData_DataMapIterator #undef _NCollection_MapHasher #define DEB_SPLIT_TO_ZONES 1 -#ifdef DEB_SPLIT_TO_ZONES +#ifdef DEB_SPLIT_TO_ZONES #include #endif TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const @@ -98,7 +98,7 @@ HYDROData_SplitToZonesTool::SplitDataList Handle(HYDROData_ShapesGroup)::DownCast( theGroupsList.Value( anIndex ) ); if( aGeomGroup.IsNull() ) continue; - + TopTools_SequenceOfShape aGroupShapes; aGeomGroup->GetShapes( aGroupShapes ); for( int i = 1, aNbShapes = aGroupShapes.Length(); i <= aNbShapes; i++ ) { @@ -114,7 +114,7 @@ HYDROData_SplitToZonesTool::SplitDataList SplitData aSplitData( SplitData::Data_Edge, anEdge, aGeomGroup->GetName() ); anInputGroupList.append( aSplitData ); } - } + } } else { SplitData aSplitData( SplitData::Data_Edge, aGroupShape, aGeomGroup->GetName() ); anInputGroupList.append( aSplitData ); @@ -122,13 +122,21 @@ HYDROData_SplitToZonesTool::SplitDataList } } + // If is only one shape is given we do not process the intersection + // algorithm but just return the unpacked input data + if ( theObjectList.Length() == 1 ) + { + anOutputSplitDataList << anInputSplitDataList << anInputGroupList; + return anOutputSplitDataList; + } + HYDROData_DataMapOfShapeListOfString aDM3; - if(!anInputGroupList.isEmpty()) { // Old edge ==> List_Of_Names + 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); - } + 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; @@ -137,9 +145,9 @@ HYDROData_SplitToZonesTool::SplitDataList BOPCol_ListOfShape aLS; 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); + const TopoDS_Shape& aSh = anInputSplitDataList.at(i).Shape; + aDM3.Bind(aSh, anInputSplitDataList.at(i).ObjectNames); + aLS.Append(aSh); } aPaveFiller->SetArguments(aLS); aPaveFiller->Perform(); @@ -166,13 +174,13 @@ HYDROData_SplitToZonesTool::SplitDataList return anOutputSplitDataList; BRepCheck_Analyzer aCheck (aResult); if(!aCheck.IsValid()) { -#ifdef DEB_SPLIT_TO_ZONES - cout << "result is not valid" <Modified(anIt.Value()); + const TopTools_ListOfShape& aListOfNew = aBuilder->Modified(anIt.Value()); TopTools_ListOfShape aList; - 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 + 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()); - it.Initialize(aListOfGen); - for(;it.More();it.Next()) - aList.Append(it.Value()); + it.Initialize(aListOfGen); + for(;it.More();it.Next()) + aList.Append(it.Value()); - aDM1.Bind(anIt.Value(), aList); - //TCollection_AsciiString aName; - if(!anInputGroupList.isEmpty()) { /* 1 */ + aDM1.Bind(anIt.Value(), aList); + //TCollection_AsciiString aName; + if(!anInputGroupList.isEmpty()) { /* 1 */ aList.Clear(); - TopExp_Explorer exp (anIt.Value(), TopAbs_EDGE); - for (int j =1;exp.More();exp.Next(),j++) { - const TopTools_ListOfShape& aListM = aBuilder->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() <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 HYDROData_DataMapOfShapeListOfShape aDM2; HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape aMIt(aDM1); for(;aMIt.More();aMIt.Next()) { - const TopoDS_Shape& aKey = aMIt.Key(); - TopTools_ListOfShape aList; - aList.Append(aKey); - const TopTools_ListOfShape& aListOfNew = aMIt.Value(); - TopTools_ListIteratorOfListOfShape it(aListOfNew); - for(;it.More();it.Next()) { - if(!aDM2.IsBound(it.Value())) - aDM2.Bind(it.Value(), aList); - else { - TopTools_ListOfShape& aList = aDM2.ChangeFind(it.Value()); - aList.Prepend(aKey); - } - } + const TopoDS_Shape& aKey = aMIt.Key(); + TopTools_ListOfShape aList; + aList.Append(aKey); + const TopTools_ListOfShape& aListOfNew = aMIt.Value(); + TopTools_ListIteratorOfListOfShape it(aListOfNew); + for(;it.More();it.Next()) { + if(!aDM2.IsBound(it.Value())) + aDM2.Bind(it.Value(), aList); + else { + TopTools_ListOfShape& aList = aDM2.ChangeFind(it.Value()); + aList.Prepend(aKey); + } + } } //cout << "DM2 Ext = " < " << ObjectNames.size() <<" " << aStr.toStdString()< " << ObjectNames.size() <<" " << aStr.toStdString()<