]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
20.01.2014. Fix for case 1 object + limiting contour.
authorszy <szy@opencascade.com>
Mon, 20 Jan 2014 13:37:10 +0000 (13:37 +0000)
committerszy <szy@opencascade.com>
Mon, 20 Jan 2014 13:37:10 +0000 (13:37 +0000)
src/HYDROData/HYDROData_SplitToZonesTool.cxx

index 3661c514a1f63cb30bdeba18d061910d1170b2ed..c85539b2508d9babc7b281ea1cb030a1f240a57c 100644 (file)
@@ -179,11 +179,15 @@ HYDROData_SplitToZonesTool::SplitDataList
   }
   // 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;
+  bool limplus1Object(false);
+  if(theObjectList.Size() == 1 )  {
+       if(thePolyline.IsNull()) {
+         anOutputSplitDataList.append(anInputSplitDataList); 
+         if(!theGroupsList.IsEmpty() ) 
+           anOutputSplitDataList.append(anInputGroupList);     
+      return anOutputSplitDataList;
+       } else
+               limplus1Object = true;// size =1 && hasLimits
   }
   HYDROData_DataMapOfShapeListOfString aDM3;
   if(!anInputGroupList.isEmpty()) {// Old edge ==> List_Of_Names
@@ -194,6 +198,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     }
   }
   // Step 1. Prepare Partition structures. 
+  TopoDS_Shape aResult;
   BOPCol_ListOfShape aLS;  
   QStringList aListOfNames;
   TopoDS_Compound aCmp;
@@ -212,11 +217,13 @@ HYDROData_SplitToZonesTool::SplitDataList
   BRepTools::Write(aCmp, aNameBefore.ToCString());
 #endif
 
+  HYDROData_DataMapOfShapeListOfShape aDM1;
+  if(anInputSplitDataList.size() > 1) {
   HYDROData_Transform splitTool; 
   const Standard_Integer anErr = SplitFaces(aCmp, splitTool);    
   if(anErr)
     return anOutputSplitDataList;
-  const TopoDS_Shape& aResult = splitTool.Shape();
+  aResult = splitTool.Shape();
   if (aResult.IsNull()) 
     return anOutputSplitDataList;
   BRepCheck_Analyzer aCheck (aResult);
@@ -232,7 +239,7 @@ HYDROData_SplitToZonesTool::SplitDataList
 #endif
   
   // Step 3. Collect history  
-  HYDROData_DataMapOfShapeListOfShape aDM1;
+  //HYDROData_DataMapOfShapeListOfShape aDM1;
   BOPCol_ListIteratorOfListOfShape anIt(aLS); 
   TCollection_AsciiString aNamM ("EdgM_");
   TCollection_AsciiString aNamG ("EdgG_");
@@ -293,13 +300,14 @@ HYDROData_SplitToZonesTool::SplitDataList
          }      
        }
   }
-
+  } else 
+         aResult = anInputSplitDataList.at(0).Shape; // get single input shape
   // aDM2: NewShape ==> ListOfOldShapes
   HYDROData_DataMapOfShapeListOfShape aDM2;
   // make limiting face
   HYDROData_DataMapOfShapeListOfShape aDM4;
   Standard_Boolean hasLimits(Standard_False);
-  if (! thePolyline.IsNull()) {         
+  if (! thePolyline.IsNull()) {
     //const TopoDS_Shape aShape = thePolyline->GetShape();     
     const TopoDS_Wire aBndWire = TopoDS::Wire(thePolyline->GetShape());
     if(!aBndWire.IsNull()) {
@@ -315,10 +323,10 @@ HYDROData_SplitToZonesTool::SplitDataList
                    BRepTools::Write(aComResult,"CommonV.brep");
 #endif 
 
-                   hasLimits = Standard_True; // DM2 should filled here
+                   hasLimits = Standard_True; // DM2 should be filled here
                    HYDROData_MapOfShape aView;
                    TopExp_Explorer exp (aResult, TopAbs_FACE);
-                   for (int i =1;exp.More();exp.Next(),i++) {
+                       for (int i =1;exp.More();exp.Next(),i++) {
               const TopoDS_Shape& aFace = exp.Current();
                      if(!aFace.IsNull()) {
                        const TopTools_ListOfShape& aListOfNew = mkCom.Modified(aFace);
@@ -392,9 +400,29 @@ HYDROData_SplitToZonesTool::SplitDataList
                   }
                 }
                 //cout << "DM4 Ext = " <<aDM4.Extent() <<endl;
+                if(limplus1Object) {
+                  // fill DM1 (old - new) and DM2 (new - old)
+                  HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape mIt(aDM4);
+           for(;mIt.More();mIt.Next()) {
+                        const TopoDS_Shape& aKey = mIt.Key();//old
+                        TopTools_ListOfShape aList;
+                        aList.Append(aKey);
+                        const TopTools_ListOfShape& aListOfNew = mIt.Value();
+                        aDM1.Bind(aKey, aListOfNew);
+                        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);
+                          }
+                        }
+                  }
+                } else {
          HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape aMIt(aDM1); 
                 //DM4 contains Old - New after common op. DM1: old - new after Split op.
-         for(;aMIt.More();aMIt.Next()) {
+                for(;aMIt.More();aMIt.Next()) {
            const TopoDS_Shape& aKey = aMIt.Key();
            TopTools_ListOfShape aList;
            aList.Append(aKey);
@@ -416,7 +444,8 @@ HYDROData_SplitToZonesTool::SplitDataList
                                }
                         }
                   }//
-                 }
+                }
+                }
                 } else {
                         hasLimits = Standard_False;
 #ifdef DEB_SPLIT_TO_ZONES
@@ -426,7 +455,7 @@ HYDROData_SplitToZonesTool::SplitDataList
           }
          }
        }
-  }
+  }// end limits processing
   if(!hasLimits) {
     HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape aMIt(aDM1);
     for(;aMIt.More();aMIt.Next()) {