Salome HOME
sinusX p.8 // Export of polyXY
[modules/hydro.git] / src / HYDROData / HYDROData_SinusX.cxx
index c4645975d52ee1708e203ba56b5d993ec3d377b0..3c8ff3cf35249618a34643c207effe7ecf2aeace 100644 (file)
@@ -343,14 +343,40 @@ void HYDROData_SinusX::HydroToSX(QFile& theFile, NCollection_Sequence<Handle_HYD
     {
        Handle(HYDROData_Bathymetry) aBathy = Handle(HYDROData_Bathymetry)::DownCast( anEnt );
        HYDROData_Bathymetry::AltitudePoints anXYZPoints = aBathy->GetAltitudePoints();
+       //Write to stream
        aTextStream << "B S\n";
        aTextStream << "CN " << aBathy->GetName() << "\n";
        aTextStream << "CP 0 0\n";
        aTextStream << "CP 0\n";
-       for (int j = 1; j <= anXYZPoints.Size(); j++)
+       for (int j = anXYZPoints.Lower(); j <= anXYZPoints.Upper(); j++)
          aTextStream << " " << QString::number(anXYZPoints(j).X(), 'f', 3)  
                      << " " << QString::number(anXYZPoints(j).Y(), 'f', 3)  
                      << " " << QString::number(anXYZPoints(j).Z(), 'f', 3) << "\n"; 
     }
+    else if (anEnt->IsKind( STANDARD_TYPE(HYDROData_PolylineXY) ))
+    {
+      Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( anEnt );
+      for (int j = 0; j < aPolyXY->NbSections(); j++)
+      { 
+        //Collect data
+        bool IsClosed = aPolyXY->IsClosedSection(j);
+        bool IsSpline = false;
+        if (aPolyXY->GetSectionType(j) == HYDROData_PolylineXY::SECTION_SPLINE)
+          IsSpline = true;
+        HYDROData_PolylineXY::PointsList anXYPoints = aPolyXY->GetPoints(j);
+        //Write to stream
+        aTextStream << "B N\n";
+        aTextStream << "CN " << aPolyXY->GetName() << "\n";
+        aTextStream << "CP " << IsClosed << " " << IsSpline << "\n";
+        aTextStream << "CP 0.0\n";
+        aTextStream << "CP 0\n";
+        if (aPolyXY->NbSections() > 1)
+          aTextStream << "C " << aPolyXY->GetName() << "_section_" << QString::number(j) << "\n";
+        for (int k = anXYPoints.Lower(); k <= anXYPoints.Upper(); k++)
+         aTextStream << " " << QString::number(anXYPoints(k).X(), 'f', 3)  
+                     << " " << QString::number(anXYPoints(k).Y(), 'f', 3)  
+                     << " 0.000\n"; 
+      }
+    }
   }
 }
\ No newline at end of file