From daa87628ed7bc4033d311efd035a44da12a668ea Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Mon, 27 Jul 2020 16:58:20 +0200 Subject: [PATCH] when importing several isoContours from SinusX with the same name, treat them as several sections of one polyline --- src/HYDROData/HYDROData_SinusX.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/HYDROData/HYDROData_SinusX.cxx b/src/HYDROData/HYDROData_SinusX.cxx index 8ffc1319..e9e376f4 100644 --- a/src/HYDROData/HYDROData_SinusX.cxx +++ b/src/HYDROData/HYDROData_SinusX.cxx @@ -34,6 +34,7 @@ #include #include #include +#include //#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 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 ) ); -- 2.39.2