Salome HOME
ImportFromFile()
[modules/hydro.git] / src / HYDROData / HYDROData_SinusX.cxx
index c7f7701ee77a232a447b45a855490d165d722815..9fcbef117ca52015ba3832dbf3ba374bef8dbcaa 100644 (file)
@@ -123,15 +123,21 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
     {
       Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( theDocument->CreateObject( KIND_BATHYMETRY ) );
       HYDROData_Bathymetry::AltitudePoints aAPoints;
-      for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+      size_t n = myCurveBlocks[i].myXYZPoints.size();
+      aAPoints.reserve( n );
+      for (size_t j = 0; j < n; j++)
       {
         gp_XYZ aLocalPoint = gp_XYZ (myCurveBlocks[i].myXYZPoints[j]);
         theDocument->Transform(aLocalPoint, true);
-        aAPoints.Append(aLocalPoint);
+        HYDROData_Bathymetry::AltitudePoint p;
+        p.X = aLocalPoint.X();
+        p.Y = aLocalPoint.Y();
+        p.Z = aLocalPoint.Z();
+        aAPoints.push_back(p);
       }
 
       aBath->SetAltitudePoints(aAPoints);
-      aBath->SetName(GetName(myCurveBlocks[i].myName + "_bath"));
+      aBath->SetName(GetName(myCurveBlocks[i].myName));
       theEntities.Append(aBath);
     }
     if (myCurveBlocks[i].myType == 1 || myCurveBlocks[i].myType == 3) // XYZ curve or isocontour
@@ -153,9 +159,9 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
       aProfileUZ->CalculateAndAddPoints(aPoints, aPolyXY);
       Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( theDocument->CreateObject( KIND_PROFILE ) );
       aProfile->SetParametricPoints(aProfileUZ->GetPoints());
-      aPolyXY->SetName(GetName(myCurveBlocks[i].myName + "_polyXY"));
-      aProfileUZ->SetName(GetName(myCurveBlocks[i].myName + "_profileUZ"));
-      aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
+      aPolyXY->SetName(GetName(myCurveBlocks[i].myName));
+      aProfileUZ->SetName(GetName(myCurveBlocks[i].myName));
+      aProfile->SetName(GetName(myCurveBlocks[i].myName));
       aPolyXY->SetWireColor(HYDROData_PolylineXY::DefaultWireColor());
       theEntities.Append(aPolyXY);
       theEntities.Append(aProfileUZ);
@@ -187,7 +193,7 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
             aProfile->SetRightPoint(gp_XY(xr, yr));
             aProfile->Update();
           }
-          aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
+          aProfile->SetName(GetName(myCurveBlocks[i].myName));
           theEntities.Append(aProfile);
         }
       }
@@ -204,7 +210,7 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
         aProfile->GetProfileUZ()->SetSectionType(0,  myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE);
         aProfile->GetProfileUZ()->SetSectionClosed(0, myCurveBlocks[i].myIsClosed ? true : false);
         aProfile->SetProfilePoints(aPointList);
-        aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
+        aProfile->SetName(GetName(myCurveBlocks[i].myName));
         theEntities.Append(aProfile);
       }
     }
@@ -273,7 +279,9 @@ bool HYDROData_SinusX::Parse(QFile& theFile)
         if (aBList[0] == "CN")
         {
            for (int i = 1; i < aBList.size(); i++)
-             Name += aBList[i] + "_"; 
+             Name += aBList[i] + "_";
+           if (Name.size() <= 1)
+             Name = "noname_";
            Name.remove(Name.size() - 1, 1);
            aCurveBlockInfo.myName = Name;
         }
@@ -364,10 +372,10 @@ void HYDROData_SinusX::HydroToSX(QFile& theFile, const NCollection_Sequence<Hand
       aTextStream << "CN " << aBathy->GetName() << "\n";
       aTextStream << "CP 0 0\n";
       aTextStream << "CP 0\n";
-      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"; 
+      for (size_t j = 0, m = anXYZPoints.size(); j < m; 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) ))
     {