Salome HOME
Merge branch 'BR_v14_rc' into BR_quadtree
[modules/hydro.git] / src / HYDROData / HYDROData_SinusX.cxx
index 3c8ff3cf35249618a34643c207effe7ecf2aeace..86a5b1518e092ef95e35b6753b4cd1037093f376 100644 (file)
@@ -304,7 +304,7 @@ bool HYDROData_SinusX::Parse(QFile& theFile)
 
 }
 
-bool HYDROData_SinusX::Export(const QString& theFilePath, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities)
+bool HYDROData_SinusX::Export(const QString& theFilePath, const NCollection_Sequence<Handle_HYDROData_Entity>& theEntities)
 {
   if ( theFilePath.isEmpty() )
   { 
@@ -330,7 +330,7 @@ bool HYDROData_SinusX::Export(const QString& theFilePath, NCollection_Sequence<H
 
 }
 
-void HYDROData_SinusX::HydroToSX(QFile& theFile, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities)
+void HYDROData_SinusX::HydroToSX(QFile& theFile, const NCollection_Sequence<Handle_HYDROData_Entity>& theEntities)
 {
   QTextStream aTextStream(&theFile);
   aTextStream << "C  Generated by HYDRO Module\n";
@@ -378,5 +378,33 @@ void HYDROData_SinusX::HydroToSX(QFile& theFile, NCollection_Sequence<Handle_HYD
                      << " 0.000\n"; 
       }
     }
+    else if (anEnt->IsKind( STANDARD_TYPE(HYDROData_Profile) ))
+    {
+      //Collect data
+      Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( anEnt );
+      HYDROData_ProfileUZ::PointsList aPointList = aProfile->GetParametricPoints();
+      bool IsClosed = aProfile->GetProfileUZ(false)->IsClosedSection(0);;
+      bool IsSpline = false;
+      if (aProfile->GetProfileUZ(false)->GetSectionType(0) == HYDROData_PolylineXY::SECTION_SPLINE)
+        IsSpline = true;
+      //Write to stream
+      aTextStream << "B P\n";
+      aTextStream << "CN " << aProfile->GetName() << "\n";
+      aTextStream << "CP " << IsClosed << " " << IsSpline << "\n";
+      gp_XY aLeftPoint(0.0, 0.0);
+      gp_XY aRightPoint(0.0, 0.0);
+      if (aProfile->GetLeftPoint(aLeftPoint, true) && aProfile->GetRightPoint(aRightPoint, true))
+        aTextStream << "CP " << QString::number(aLeftPoint.X(), 'f', 3) << " " <<
+                                QString::number(aLeftPoint.Y(), 'f', 3) << " " <<
+                                QString::number(aRightPoint.X(), 'f', 3) << " " <<
+                                QString::number(aRightPoint.Y(), 'f', 3) << "\n";
+      else
+        aTextStream << "CP 0.0 0.0 0.0 0.0\n";
+      aTextStream << "CP 2\n";
+      for (int k = aPointList.Lower(); k <= aPointList.Upper(); k++)
+         aTextStream << " " << QString::number(aPointList(k).X(), 'f', 3)  
+                     << " 0.000 "
+                     << QString::number(aPointList(k).Y(), 'f', 3) << "\n";  
+    }
   }
 }
\ No newline at end of file