]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
20.12.2013.Update to fix case with one input shape: no split.
authorszy <szy@opencascade.com>
Fri, 20 Dec 2013 12:05:29 +0000 (12:05 +0000)
committerszy <szy@opencascade.com>
Fri, 20 Dec 2013 12:05:29 +0000 (12:05 +0000)
src/HYDROData/HYDROData_SplitToZonesTool.cxx

index 6f20f0d69115ead1f755c2160938c7cb4ea11642..f7cd068ae14aa102af62515a7c0d4776ec032251 100644 (file)
@@ -60,7 +60,7 @@ HYDROData_SplitToZonesTool::SplitDataList
                                      const Handle(HYDROData_PolylineXY)& thePolyline )
 {
   SplitDataList anOutputSplitDataList;
-
+  if(theObjectList.IsEmpty()) return anOutputSplitDataList;
   // Preparation. 
   // Collect the object shapes to split. InputDataList will contain elements which will hold shape & name_of_shape.
   SplitDataList anInputSplitDataList;
@@ -121,15 +121,15 @@ 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;
+  // If only one shape is given we don't split it 
+  // algorithm just returns the unpacked input data
+  if(theObjectList.Size() == 1)  {
+       anOutputSplitDataList.append(anInputSplitDataList); 
+       if(!theGroupsList.IsEmpty() ) 
+         anOutputSplitDataList.append(anInputGroupList);       
     return anOutputSplitDataList;
   }
-
   HYDROData_DataMapOfShapeListOfString aDM3;
   if(!anInputGroupList.isEmpty()) {// Old edge ==> List_Of_Names
     QStringList aListOfNames;
@@ -197,35 +197,35 @@ HYDROData_SplitToZonesTool::SplitDataList
       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() ) { 
       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
@@ -261,92 +261,21 @@ HYDROData_SplitToZonesTool::SplitDataList
     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);
+         }      
+       }
+
+       aDestSplitData.ObjectNames = aListOfNames;  
+       anOutputSplitDataList.append(aDestSplitData);
   }
   //cout << "anOutputSplitDataList = " <<anOutputSplitDataList.size() <<endl;
   return anOutputSplitDataList;
 
-  /*
-  SplitDataListIterator anInputIter( anInputSplitDataList );
-  while( anInputIter.hasNext() )
-  {
-    const SplitData& anInputSplitData = anInputIter.next();
-    if( anOutputSplitDataList.isEmpty() )
-      anOutputSplitDataList.append( anInputSplitData );
-    else
-    {
-      SplitDataList aSplitDataList;
-
-      SplitDataList aSrcSplitDataList;
-      aSrcSplitDataList.append( anInputSplitData );
-
-      SplitDataList aDestSplitDataList = anOutputSplitDataList;
-      anOutputSplitDataList.clear();
-
-      while( !aDestSplitDataList.isEmpty() )
-      {
-        SplitData aSrcSplitData = aSrcSplitDataList.last();
-
-        SplitData aDestSplitData = aDestSplitDataList.first();
-        aDestSplitDataList.pop_front();
-
-        SplitData aData1Subtracted, aData2Subtracted, aDataIntersected;
-        if( SplitTwoData( aSrcSplitData, aDestSplitData,
-                          aData1Subtracted, aData2Subtracted, aDataIntersected ) )
-          anOutputSplitDataList.append( aDataIntersected );
-        anOutputSplitDataList.append( aData2Subtracted );
-        aSrcSplitDataList.append( aData1Subtracted );
-      }
-
-      if( !aSrcSplitDataList.isEmpty() )
-        anOutputSplitDataList.append( aSrcSplitDataList.last() );
-    }
-  }
-
-  // Step 2. Take into account the boundary polyline.
-  if( !thePolyline.IsNull() )
-  {
-    TopoDS_Wire aWire = TopoDS::Wire( thePolyline->GetShape() );
-    if( !aWire.IsNull() )
-    {
-      BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
-      aMakeFace.Build();
-      if( aMakeFace.IsDone() )
-      {
-        SplitData aBoundarySplitData( SplitData::Data_Zone, aMakeFace.Face(), "" );
-
-        SplitDataList aCutSplitDataList;
-        SplitDataListIterator anOutputIter( anOutputSplitDataList );
-        while( anOutputIter.hasNext() )
-        {
-          const SplitData& anOutputSplitData = anOutputIter.next();
-
-          SplitData aData1Subtracted, aData2Subtracted, aDataIntersected;
-          if( SplitTwoData( anOutputSplitData, aBoundarySplitData,
-                            aData1Subtracted, aData2Subtracted, aDataIntersected ) )
-            aCutSplitDataList.append( aDataIntersected );
-        }
-        anOutputSplitDataList = aCutSplitDataList;
-      }
-    }
-  }
-
+/* 
   // Step 3. Extract the separate regions.
   SplitDataList anExtractedSplitDataList;
   SplitDataListIterator anOutputIter( anOutputSplitDataList );