]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Algorithm corrected for case from one shape (Bug #269 and Bug #271)
authoradv <adv@opencascade.com>
Fri, 20 Dec 2013 10:50:40 +0000 (10:50 +0000)
committeradv <adv@opencascade.com>
Fri, 20 Dec 2013 10:50:40 +0000 (10:50 +0000)
src/HYDROData/HYDROData_SplitToZonesTool.cxx

index 1ae7a1b2e641b3f0b031343c84eabed0e326e02b..6f20f0d69115ead1f755c2160938c7cb4ea11642 100644 (file)
@@ -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 <BRepTools.hxx>
 #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" <<endl;       
+#ifdef DEB_SPLIT_TO_ZONES
+    cout << "result is not valid" <<endl;
     BRepTools::Write(aResult, "SplitFacesNV.brep");  
 #endif
     return anOutputSplitDataList;
   }
-#ifdef DEB_SPLIT_TO_ZONES      
+#ifdef DEB_SPLIT_TO_ZONES
   //BRepTools::Write(aResult, "SplitFacesV.brep");
 #endif
   
@@ -182,94 +190,94 @@ HYDROData_SplitToZonesTool::SplitDataList
   //TCollection_AsciiString aNamM ("EdgM_");
   //TCollection_AsciiString aNamG ("EdgG_");
   for (int i =1;anIt.More();anIt.Next(),i++) {
-       const TopTools_ListOfShape& aListOfNew = aBuilder->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() <<endl;
-               it.Initialize(aListM);    
-               for(int k=1;it.More();it.Next(),k++) {    
-             aList.Append(it.Value());
-                 //aName = aNamM + i + j +k +".brep";
-                 //BRepTools::Write(it.Value(),aName.ToCString());
-               }
-               const TopTools_ListOfShape& aListG = aBuilder->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() <<endl;
-               aDM1.Bind(exp.Current(), aList);
-         }      
-       }
+      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() <<endl;
+        it.Initialize(aListM);
+        for(int k=1;it.More();it.Next(),k++) {
+          aList.Append(it.Value());
+          //aName = aNamM + i + j +k +".brep";
+          //BRepTools::Write(it.Value(),aName.ToCString());
+        }
+        const TopTools_ListOfShape& aListG = aBuilder->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() <<endl;
+        aDM1.Bind(exp.Current(), aList);
+      }     
+    }
   }
 
   // aDM2: NewShape ==> 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 = " <<aDM2.Extent() <<endl;
   // Step 4. Fill output structure.
   aMIt.Initialize(aDM2);
   for(int i =1;aMIt.More();aMIt.Next(),i++) {
     SplitData aDestSplitData;
-       const TopoDS_Shape& aKey = aMIt.Key(); //new
-       aDestSplitData.Shape = aKey;
-       if(aKey.ShapeType() == TopAbs_FACE)
-         aDestSplitData.Type = SplitData::Data_Zone;
-       else
+    const TopoDS_Shape& aKey = aMIt.Key(); //new
+    aDestSplitData.Shape = aKey;
+    if(aKey.ShapeType() == TopAbs_FACE)
+      aDestSplitData.Type = SplitData::Data_Zone;
+    else
       aDestSplitData.Type = SplitData::Data_Edge;
 
-       QStringList aListOfNames; // names processing
+    QStringList aListOfNames; // names processing
     const TopTools_ListOfShape& aListOfOld = aMIt.Value();
     TopTools_ListIteratorOfListOfShape it(aListOfOld);
-       for(;it.More();it.Next()) {     
-         const TopoDS_Shape& aSh = it.Value(); //old
-         if(aDM3.IsBound(aSh)) {
-           const QStringList& ObjectNames = aDM3.Find(aSh);
-               aListOfNames.append(ObjectNames);
-         }      
-       }
-/*     
-       if(aKey.ShapeType() == TopAbs_EDGE) {
-         QString aStr("EDGE_Of_Face_");
-         aStr = aStr.append(TCollection_AsciiString(i).ToCString());
-         const QStringList& ObjectNames = QStringList( aStr);
-         cout << "EDGE ==> " << ObjectNames.size() <<" " << aStr.toStdString()<<endl;
-         aListOfNames.append(ObjectNames);
-       }*/
-       aDestSplitData.ObjectNames = aListOfNames;  
-       anOutputSplitDataList.append(aDestSplitData);
+    for(;it.More();it.Next()) {
+      const TopoDS_Shape& aSh = it.Value(); //old
+      if(aDM3.IsBound(aSh)) {
+        const QStringList& ObjectNames = aDM3.Find(aSh);
+        aListOfNames.append(ObjectNames);
+      }     
+    }
+/*    
+    if(aKey.ShapeType() == TopAbs_EDGE) {
+      QString aStr("EDGE_Of_Face_");
+      aStr = aStr.append(TCollection_AsciiString(i).ToCString());
+      const QStringList& ObjectNames = QStringList( aStr);
+      cout << "EDGE ==> " << ObjectNames.size() <<" " << aStr.toStdString()<<endl;
+      aListOfNames.append(ObjectNames);
+    }*/
+    aDestSplitData.ObjectNames = aListOfNames;
+    anOutputSplitDataList.append(aDestSplitData);
   }
   //cout << "anOutputSplitDataList = " <<anOutputSplitDataList.size() <<endl;
   return anOutputSplitDataList;