]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
when importing several isoContours from SinusX with the same name, treat them as...
authorPaul RASCLE <paul.rascle@openfields.fr>
Mon, 27 Jul 2020 14:58:20 +0000 (16:58 +0200)
committerYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:06:22 +0000 (17:06 +0100)
src/HYDROData/HYDROData_SinusX.cxx

index 8ffc1319d9f62f9d5086c7e28b64d949d5aa377a..e9e376f49f19c03947baf8df1f06d7708571ad6d 100644 (file)
@@ -34,6 +34,7 @@
 #include <QStringList>
 #include <QTextStream>
 #include <QColor>
+#include <QMap>
 
 //#define _DEVDEBUG_
 #include "HYDRO_trace.hxx"
@@ -128,6 +129,8 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
   if (importOptions && (myCurveBlocks.size() != importOptions->size()))
     importOptions = NULL; //incorrect input
 
+  QMap<QString,Handle(HYDROData_PolylineXY) > polyMap;
+
   for ( size_t i = 0; i < myCurveBlocks.size(); i++ )
   {
     if (myCurveBlocks[i].myType == 4) ///  scatter plot -> to bathy
@@ -166,19 +169,28 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
           aPoints.Append(aLocalPoint);
         }
 
-        Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) );
+        QString polyName = myCurveBlocks[i].myName;
+        Handle(HYDROData_PolylineXY) aPolyXY;
+        if (polyMap.contains(polyName))
+               aPolyXY = polyMap[polyName];
+        else
+        {
+               aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) );
+               polyMap[polyName] = aPolyXY;
+            aPolyXY->SetName(GetName(myCurveBlocks[i].myName));
+            aPolyXY->SetWireColor(HYDROData_PolylineXY::DefaultWireColor());
+            theEntities.Append(aPolyXY);
+        }
         aPolyXY->AddSection( "",  
           myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE, 
-          myCurveBlocks[i].myIsClosed ? true : false); 
-        aPolyXY->SetName(GetName(myCurveBlocks[i].myName));
-        aPolyXY->SetWireColor(HYDROData_PolylineXY::DefaultWireColor());
+          myCurveBlocks[i].myIsClosed ? true : false);
+        int numSec = aPolyXY->NbSections() -1;
 
         for ( int k = 1; k <= aPoints.Size(); k++ ) {
           const HYDROData_Profile::ProfilePoint& aBottomPoint = aPoints.Value( k );
-          aPolyXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
+          aPolyXY->AddPoint( numSec, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
         }
 
-        theEntities.Append(aPolyXY);
         if (!importOptions || (importOptions && (*importOptions)[i].ImportAsProfile == true))
         {
           Handle(HYDROData_ProfileUZ) aProfileUZ = Handle(HYDROData_ProfileUZ)::DownCast( theDocument->CreateObject( KIND_PROFILEUZ ) );