Salome HOME
Porting on OCCT 7.0 and Qt 5. Make compilable version.
[modules/hydro.git] / src / HYDROData / HYDROData_SplitToZonesTool.cxx
index f91732cd2fcdba0a6ae49707008b8b684b76dee3..ba3359c295842b39e27564f0de103373f189e50a 100644 (file)
@@ -47,6 +47,9 @@
 static TCollection_AsciiString fileNameBefore("BeforeTranslation");
 #endif
 
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
 {
   TopoDS_Face aResFace;
@@ -129,6 +132,7 @@ HYDROData_SplitToZonesTool::SplitDataList
                                      const HYDROData_SequenceOfObjects&  theGroupsList,
                                      const Handle(HYDROData_PolylineXY)& thePolyline )
 {
+  DEBTRACE("Split");
   SplitDataList anOutputSplitDataList;
   if(theObjectList.IsEmpty()) return anOutputSplitDataList;
   // Preparation. 
@@ -150,7 +154,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     if ( aShape.IsNull() )
       continue;  
 #ifdef DEB_SPLIT_TO_ZONES
-   TCollection_AsciiString aName = aNam + anIndex + ".brep";
+   TCollection_AsciiString aName = aNam + anIndex + "_a.brep";
    BRepTools::Write(aShape, aName.ToCString());
 #endif
     if ( aShape.ShapeType() == TopAbs_COMPOUND ) {
@@ -198,7 +202,7 @@ HYDROData_SplitToZonesTool::SplitDataList
         anInputGroupList.append( aSplitData );
 #ifdef DEB_SPLIT_TO_ZONES
         QString aStr = aSplitData.ObjectNames.join(" "); 
-        cout << "Group# = " <<anIndex <<" Nmb in grp = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size() <<endl;   
+        DEBTRACE("Group# = " <<anIndex <<" Nmb in grp = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size());
 #endif
       }
     }
@@ -237,12 +241,12 @@ HYDROData_SplitToZonesTool::SplitDataList
     aLS.Append(aSh);
     aBB.Add(aCmp,aSh);
 #ifdef DEB_SPLIT_TO_ZONES
-    //TCollection_AsciiString aName = aNam + i + ".brep";
-    //BRepTools::Write(aSh, aName.ToCString());
+    TCollection_AsciiString aName = aNam + i + "_b.brep";
+    BRepTools::Write(aSh, aName.ToCString());
 #endif
   }
 #ifdef DEB_SPLIT_TO_ZONES_CHECK_PARTITION
-  TCollection_AsciiString aNameBefore = fileNameBefore + ".brep";
+  TCollection_AsciiString aNameBefore = fileNameBefore + "_c.brep";
   BRepTools::Write(aCmp, aNameBefore.ToCString());
 #endif
 
@@ -258,7 +262,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     BRepCheck_Analyzer aCheck (aResult);
     if(!aCheck.IsValid()) {
   #ifdef DEB_SPLIT_TO_ZONES
-      cout << "result is not valid" <<endl;
+      DEBTRACE("result is not valid");
       BRepTools::Write(aResult, "SplitFacesNV.brep");  
   #endif
       return anOutputSplitDataList;
@@ -306,14 +310,14 @@ HYDROData_SplitToZonesTool::SplitDataList
           aList.Clear();
           Standard_Boolean foundE(Standard_False);
           const TopTools_ListOfShape& aListM = splitTool.Modified(exp.Current());    
-          //cout << "NB_EDGE_M = " << aListM.Extent() <<endl;
+          DEBTRACE("NB_EDGE_M = " << aListM.Extent());
           if(aListM.Extent()) foundE = Standard_True;
           it.Initialize(aListM);    
           for(int k=1;it.More();it.Next(),k++) {    
             aList.Append(it.Value());
   #ifdef DEB_SPLIT_TO_ZONES
-            //aName = aNamM + i + j +k +".brep";
-            //BRepTools::Write(it.Value(),aName.ToCString());
+            aName = aNamM + i + j +k +"_d.brep";
+            BRepTools::Write(it.Value(),aName.ToCString());
   #endif
           }
           /* *********************************************************************
@@ -327,9 +331,9 @@ HYDROData_SplitToZonesTool::SplitDataList
           if(!foundE) {
             aList.Append (exp.Current());
   #ifdef DEB_SPLIT_TO_ZONES
-            aName = aNamG + i + j +".brep";
+            aName = aNamG + i + j +"_e.brep";
             BRepTools::Write(exp.Current(),aName.ToCString());
-            cout << aName.ToCString()<< " = " << exp.Current().TShape() <<endl;
+            DEBTRACE(aName.ToCString()<< " = " << exp.Current().TShape());
   #endif
           }
           aDM1.Add(exp.Current(), aList);
@@ -347,8 +351,10 @@ HYDROData_SplitToZonesTool::SplitDataList
   Standard_Boolean hasLimits(Standard_False);
   QString aBndName;
   HYDROData_MapOfShape aBndView;
-  if (! thePolyline.IsNull()) {    
-    const TopoDS_Wire aBndWire = TopoDS::Wire(thePolyline->GetShape());
+  if (! thePolyline.IsNull()) {
+    Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
+    int nbWires = thePolyline->GetNbConnectedWires(aConnectedWires);
+    const TopoDS_Wire aBndWire = TopoDS::Wire(aConnectedWires->Value(1));
     if(!aBndWire.IsNull()) {
       TopoDS_Face limFace;       
       if(buildLimFace(aBndWire, limFace)) {
@@ -382,12 +388,12 @@ HYDROData_SplitToZonesTool::SplitDataList
               const TopoDS_Shape& aFace = exp.Current();
               if(!aFace.IsNull()) {
                 const TopTools_ListOfShape& aListOfNew = mkCom.Modified(aFace);
-                //cout << "Modified: " << aListOfNew.Extent() <<endl;                                    
+                DEBTRACE("Modified: " << aListOfNew.Extent());
                 if(!aListOfNew.IsEmpty()) {
                   aDM4.Add(aFace, aListOfNew);
 #ifdef DEB_SPLIT_TO_ZONES
-                  //TCollection_AsciiString aName = aNam + i + ".brep";
-                  //BRepTools::Write(aListOfNew.Last(), aName.ToCString());                
+                  TCollection_AsciiString aName = aNam + i + "_f.brep";
+                  BRepTools::Write(aListOfNew.Last(), aName.ToCString());
 #endif
                 }
                 else {
@@ -396,8 +402,8 @@ HYDROData_SplitToZonesTool::SplitDataList
                       if(!aListOfGen.IsEmpty()) {
                         /* aDM4.Bind(aFace, aListOfGen); ???   */
 #ifdef DEB_SPLIT_TO_ZONES
-                        //TCollection_AsciiString aName = aNam + i + "g.brep";
-                        //BRepTools::Write(aListOfGen.Last(), aName.ToCString());
+                        TCollection_AsciiString aName = aNam + i + "_g.brep";
+                        BRepTools::Write(aListOfGen.Last(), aName.ToCString());
 #endif
                       }
                        else {
@@ -445,9 +451,9 @@ HYDROData_SplitToZonesTool::SplitDataList
 #ifdef DEB_SPLIT_TO_ZONES
              TopTools_ListIteratorOfListOfShape itl(aListOfNewEd);
              for(int j=1;itl.More();itl.Next(),j++) {
-               TCollection_AsciiString aName = aNam + i + "_" + j + ".brep";
+               TCollection_AsciiString aName = aNam + i + "_" + j + "_j.brep";
                BRepTools::Write(itl.Value(), aName.ToCString());
-               cout <<aName.ToCString()<<" = "<< itl.Value().TShape() <<endl;
+               DEBTRACE(aName.ToCString()<<" = "<< itl.Value().TShape());
              }
 #endif
              if(!aListOfNewEd.IsEmpty())
@@ -555,7 +561,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     else {
       aDestSplitData.Type = SplitData::Data_Edge;
 #ifdef DEB_SPLIT_TO_ZONES
-      TCollection_AsciiString aName = aNam4 + i + ".brep";
+      TCollection_AsciiString aName = aNam4 + i + "_k.brep";
       BRepTools::Write(aKey,aName.ToCString());
 #endif    
     }
@@ -569,19 +575,19 @@ HYDROData_SplitToZonesTool::SplitDataList
         const QStringList& ObjectNames = aDM3.FindFromKey(aSh);    
         aListOfNames.append(ObjectNames);
 #ifdef DEB_SPLIT_TO_ZONES
-        TCollection_AsciiString aName = aNam4 + i +"_" + j + ".brep";
+        TCollection_AsciiString aName = aNam4 + i +"_" + j + "_l.brep";
         BRepTools::Write(aSh ,aName.ToCString());        
 #endif    
       }    else {
 #ifdef DEB_SPLIT_TO_ZONES
-        TCollection_AsciiString aName = aNam4 +"__" + i +"_" + j + ".brep";
+        TCollection_AsciiString aName = aNam4 +"__" + i +"_" + j + "_m.brep";
         BRepTools::Write(aSh ,aName.ToCString());        
-        cout <<aName.ToCString()<<" = "<< aSh.TShape() <<endl;
+        DEBTRACE(aName.ToCString()<<" = "<< aSh.TShape());
 #endif
           if(aBndView.Contains(aSh) && hasLimits) {            
             aListOfNames.append(aBndName);
 #ifdef DEB_SPLIT_TO_ZONES
-            cout << " BndName = "<<aBndName.toStdString() <<endl; 
+            DEBTRACE(" BndName = "<<aBndName.toStdString());
 #endif
           }
       }
@@ -591,7 +597,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     anOutputSplitDataList.append(aDestSplitData);    
 #ifdef DEB_SPLIT_TO_ZONES
     QString aStr = aDestSplitData.ObjectNames.join(" "); 
-    cout << "New# = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aDestSplitData.ObjectNames.size() <<endl; 
+    DEBTRACE("New# = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aDestSplitData.ObjectNames.size());
 #endif
   }
 
@@ -605,4 +611,4 @@ HYDROData_SplitToZonesTool::SplitDataList
   Handle(HYDROData_PolylineXY) aPolyline;
 
   return Split( theObjectList, aGeomGroups, aPolyline );
-}
\ No newline at end of file
+}