Salome HOME
Modify creation of curves: 1) using QDockWidget instead of QDialog; 2) selection...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_SplitZonesTool.cxx
index af490e461ac878098a6c723bd0a7ed83bde5a60d..d570f46c50288b83dff9e5d4449d241d90e98c17 100644 (file)
 
 #include <HYDROData_Zone.h>
 
+void printPath( const QString& thePrefix, const QPainterPath& thePath )
+{
+  printf( "%s (n=%d) :", qPrintable( thePrefix ), thePath.elementCount() );
+  for( int i = 0, n = thePath.elementCount(); i < n; i++ )
+  {
+    const QPainterPath::Element anElement = thePath.elementAt( i );
+    switch( anElement.type )
+    {
+      case QPainterPath::MoveToElement:
+        printf( " M(%.0f,%.0f)", anElement.x, anElement.y );
+        break;
+      case QPainterPath::LineToElement:
+        printf( " L(%.0f,%.0f)", anElement.x, anElement.y );
+        break;
+      default:
+        break;
+    }
+  }
+  printf( "\n" );
+}
+
 HYDROGUI_SplitZonesTool::SplitDataList
-HYDROGUI_SplitZonesTool::SplitZones( const HYDROData_SequenceOfObjects& theZoneList )
+HYDROGUI_SplitZonesTool::SplitZones( const HYDROData_SequenceOfObjects& theZoneList,
+                                     const Handle(HYDROData_Polyline)&  thePolylie )
 {
   SplitDataList anOutputSplitDataList;
 
@@ -85,25 +107,32 @@ HYDROGUI_SplitZonesTool::SplitTwoData( const SplitData& theData1,
 
   const QPainterPath& aPath1 = theData1.Path;
   const QPainterPath& aPath2 = theData2.Path;
+  printPath( "aPath1", aPath1 );
+  printPath( "aPath2", aPath2 );
 
   const QStringList& aZoneNames1 = theData1.ZoneNames;
   const QStringList& aZoneNames2 = theData2.ZoneNames;
 
   QPainterPath anIntersection = aPath1.intersected( aPath2 );
+  printPath( "anIntersection", anIntersection );
+  anIntersection.closeSubpath();
+  printPath( "anIntersection after closing", anIntersection );
   if( anIntersection.isEmpty() )
   {
     aSplitDataList.append( theData1 );
-    aSplitDataList.append( theData2 );
+    //aSplitDataList.append( theData2 );
   }
   else
   {
     aSplitDataList.append( SplitData( anIntersection, aZoneNames1 + aZoneNames2 ) );
 
     QPainterPath aPath1Sub = aPath1.subtracted( aPath2 );
+    printPath( "aPath1Sub", aPath1Sub );
     if( !aPath1Sub.isEmpty() )
       aSplitDataList.append( ExtractSeparateData( SplitData( aPath1Sub, aZoneNames1 ) ) );
 
     QPainterPath aPath2Sub = aPath2.subtracted( aPath1 );
+    printPath( "aPath2Sub", aPath2Sub );
     if( !aPath2Sub.isEmpty() )
       aSplitDataList.append( ExtractSeparateData( SplitData( aPath2Sub, aZoneNames2 ) ) );
   }
@@ -146,6 +175,7 @@ HYDROGUI_SplitZonesTool::ExtractSeparateData( const SplitData& theData )
     const QPainterPath& aPath2 = aPathList.last();
     if( aPath1.contains( aPath2 ) || aPath2.contains( aPath1 ) )
     {
+      printf( "HOLE CASE!\n" );
       aSplitDataList.append( theData );
       return aSplitDataList;
     }
@@ -155,6 +185,7 @@ HYDROGUI_SplitZonesTool::ExtractSeparateData( const SplitData& theData )
   while( anIter.hasNext() )
   {
     const QPainterPath& aPath = anIter.next();
+    printPath( "aPath", aPath );
     aSplitDataList.append( SplitData( aPath, aBaseZoneNames ) );
   }
   return aSplitDataList;