From 4a4a927ca9e3a323e57ac9a6b1877b2d7a2e9e63 Mon Sep 17 00:00:00 2001 From: isn Date: Wed, 12 Dec 2018 15:53:23 +0300 Subject: [PATCH] lot 6 :: import polylines form XY/XYZ + tests --- src/HYDROData/HYDROData_Tool.cxx | 203 ++++++++++++++++++ src/HYDROData/HYDROData_Tool.h | 7 + src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx | 21 +- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 6 +- src/HYDRO_tests/reference_data/CMakeLists.txt | 3 + .../linux/Polyline_import_XY.png | Bin 0 -> 4222 bytes .../linux/Polyline_import_XYZ.png | Bin 0 -> 4222 bytes .../linux/Polyline_import_XYZ_3D.png | Bin 0 -> 4222 bytes .../win32/Polyline_import_XY.png | Bin 0 -> 4286 bytes .../win32/Polyline_import_XYZ.png | Bin 0 -> 4286 bytes .../win32/Polyline_import_XYZ_3D.png | Bin 0 -> 4286 bytes src/HYDRO_tests/test_HYDROData_PolylineXY.cxx | 33 +++ src/HYDRO_tests/test_HYDROData_PolylineXY.h | 4 + 13 files changed, 275 insertions(+), 2 deletions(-) create mode 100644 src/HYDRO_tests/reference_data/linux/Polyline_import_XY.png create mode 100644 src/HYDRO_tests/reference_data/linux/Polyline_import_XYZ.png create mode 100644 src/HYDRO_tests/reference_data/linux/Polyline_import_XYZ_3D.png create mode 100644 src/HYDRO_tests/reference_data/win32/Polyline_import_XY.png create mode 100644 src/HYDRO_tests/reference_data/win32/Polyline_import_XYZ.png create mode 100644 src/HYDRO_tests/reference_data/win32/Polyline_import_XYZ_3D.png diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index f5f8d9e7..9ad6eccc 100755 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -67,6 +67,12 @@ #include #include +#include +#include +#include + +#include +#define BLOCK_SIZE 10000 HYDROData_Tool::ExecStatus HYDROData_Tool::myTriangulationStatus = ExecStatus::None; @@ -684,6 +690,203 @@ const HYDROData_Tool::ExecStatus& HYDROData_Tool::GetTriangulationStatus() return myTriangulationStatus; } +static bool AddXYZ(bool bImportXY, + double x, + double y, + double z, + std::vector& thePointsXYZ, + std::vector& thePointsXY) +{ + if (!bImportXY) + { + if ( HYDROData_Tool::IsNan( x ) || HYDROData_Tool::IsInf( x ) || + HYDROData_Tool::IsNan( y ) || HYDROData_Tool::IsInf( y ) || + HYDROData_Tool::IsNan( z ) || HYDROData_Tool::IsInf( z ) ) + return false; + + if( thePointsXYZ.size()>=thePointsXYZ.capacity() ) + thePointsXYZ.reserve( thePointsXYZ.size()+BLOCK_SIZE ); + + thePointsXYZ.push_back(gp_XYZ(x,y,z)); + } + else + { + if ( HYDROData_Tool::IsNan( x ) || HYDROData_Tool::IsInf( x ) || + HYDROData_Tool::IsNan( y ) || HYDROData_Tool::IsInf( y ) ) + return false; + + if( thePointsXY.size()>=thePointsXY.capacity() ) + thePointsXY.reserve( thePointsXY.size()+BLOCK_SIZE ); + + thePointsXY.push_back(gp_XY(x,y)); + } + return true; +} + +bool HYDROData_Tool::importFromXYZ( QString& theFileName, + bool bImportXY, + std::vector& thePointsXYZ, + std::vector& thePointsXY) +{ + QFile aFile( theFileName ); + if ( !aFile.exists() || !aFile.open( QIODevice::ReadOnly ) ) + return false; + + QString aFileSuf = QFileInfo( aFile ).suffix().toLower(); + + double x,y; + if ( aFileSuf == "xyz" ) + { + double z; + while ( !aFile.atEnd() ) + { + std::string aLine = aFile.readLine().simplified().toStdString(); + if ( aLine.empty() ) + continue; + + x = 0; + y = 0; + z = 0; + + if( sscanf( aLine.c_str(), "%lf %lf %lf", &x, &y, &z )!=3 ) + return false; + + if (!AddXYZ(bImportXY, x, y, z, thePointsXYZ, thePointsXY )) + return false; + } + } + else if (aFileSuf == "xy" ) + { + while ( !aFile.atEnd() ) + { + std::string aLine = aFile.readLine().simplified().toStdString(); + if ( aLine.empty() ) + continue; + + x = 0; + y = 0; + + if( sscanf( aLine.c_str(), "%lf %lf", &x, &y )!=2 ) + return false; + + if (!AddXYZ(true, x, y, 0, thePointsXYZ, thePointsXY )) + return false; + } + } + + aFile.close(); + + return true; +} + +bool HYDROData_Tool::importPolylineFromXYZ(QString aFileName, Handle(HYDROData_Document) theDocument, + bool importXY, NCollection_Sequence& importedEntities) +{ + if (importXY) + { + std::vector aPoints2d; + std::vector aDPoints3d; + + if (HYDROData_Tool::importFromXYZ(aFileName, importXY, aDPoints3d, aPoints2d)) + { + QString basename = QFileInfo( aFileName ).baseName(); + + Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) ); + HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; + bool IsClosed = false; + if ((aPoints2d.front()-aPoints2d.back()).Modulus()AddSection( TCollection_AsciiString("poly_section"), aSectType, true); + } + else + aPolylineXY->AddSection( TCollection_AsciiString("poly_section"), aSectType, false); + + int n = aPoints2d.size(); + if (IsClosed) + n--; + + for ( int i = 0; i < n; i++ ) + { + gp_XY aSectPoint = aPoints2d[i]; + theDocument->Transform(aSectPoint, true); + aPolylineXY->AddPoint( 0, aSectPoint ); + } + + aPolylineXY->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() ); + aPolylineXY->SetName( basename + "_PolyXY_" ); + aPolylineXY->Update(); + importedEntities.Append(aPolylineXY); + return true; + } + else + return false; + } + else //xyz + { + std::vector aDPoints2d; + std::vector aPoints3d; + if (HYDROData_Tool::importFromXYZ(aFileName, false, aPoints3d, aDPoints2d)) + { + QString basename = QFileInfo( aFileName ).baseName(); + Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) ); + Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( theDocument->CreateObject( KIND_POLYLINE ) ); + Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( theDocument->CreateObject( KIND_BATHYMETRY ) ); + HYDROData_Bathymetry::AltitudePoints aAPoints; + HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; + bool IsClosed = false; + if ((aPoints3d.front()-aPoints3d.back()).Modulus()AddSection( TCollection_AsciiString("poly_section"), aSectType, true); + } + else + aPolylineXY->AddSection( TCollection_AsciiString("poly_section"), aSectType, false); + + int n = aPoints3d.size(); + if (IsClosed) + n--; + + for ( int i = 0; i < n; i++ ) + { + gp_XY aSectPoint(aPoints3d[i].X(), aPoints3d[i].Y()); + theDocument->Transform(aSectPoint, true); + aPolylineXY->AddPoint( 0, aSectPoint ); + HYDROData_Bathymetry::AltitudePoint p; + p.X = aSectPoint.X(); + p.Y = aSectPoint.Y(); + p.Z = aPoints3d[i].Z(); + aAPoints.push_back(p); + } + + QString aBathName = basename + "_bath_"; + QString aPolyXYName = basename + "_polyXY_"; + QString aPoly3DName = basename + "_poly3D_"; + + aPolylineXY->SetName( aPolyXYName ); + aPolylineXY->SetWireColor(HYDROData_PolylineXY::DefaultWireColor()); + aPolylineXY->Update(); + + aBath->SetAltitudePoints(aAPoints); + aBath->SetName( aBathName ); + + aPolylineObj->SetPolylineXY (aPolylineXY, false); + aPolylineObj->SetAltitudeObject(aBath); + + aPolylineObj->SetBorderColor( aPolylineObj->DefaultBorderColor() ); + aPolylineObj->SetName( aPoly3DName ); + + aPolylineObj->Update(); + importedEntities.Append(aPolylineXY); + importedEntities.Append(aPolylineObj); + return true; + } + else + return false; + } +} + + std::ostream& operator<<( std::ostream& theStream, const QString& theText ) { theStream << theText.toStdString(); diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index 0047995a..c7bd4fe6 100755 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -154,6 +154,13 @@ public: static TopoDS_Shape PolyXY2Face(const Handle(HYDROData_PolylineXY)& aPolyline); + static bool importFromXYZ( QString& theFileName, bool bImportXY, std::vector& thePointsXYZ, + std::vector& thePointsXY); + + static bool importPolylineFromXYZ(QString aFilename, Handle(HYDROData_Document) theDocument, + bool importXY, NCollection_Sequence& importedEntities); + + static void SetSIProgress(const Handle(Message_ProgressIndicator)& thePI); static const Handle(Message_ProgressIndicator)& GetSIProgress(); diff --git a/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx b/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx index bc83c0f2..6697b420 100644 --- a/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -39,6 +40,7 @@ #include #include #include +#include HYDROGUI_ImportPolylineOp::HYDROGUI_ImportPolylineOp( HYDROGUI_Module* theModule ) @@ -77,7 +79,16 @@ NCollection_Sequence HYDROGUI_ImportPolylineOp::Import continue; QString anExt = aFileName.split('.', QString::SkipEmptyParts).back(); - + anExt.toLower(); + bool importXY = false; + if (anExt == "xyz") + { + importXY = SUIT_MessageBox::question( module->getApp()->desktop(), + tr( "IMPORT_POLYLINE" ), + tr( "IMPORT_POLYLINE_XY_PART_ONLY" ), + QMessageBox::Yes | QMessageBox::No, + SUIT_MessageBox::Yes) == SUIT_MessageBox::Yes; + } if (anExt == "shp") { HYDROData_ShapeFile anImporter; @@ -186,6 +197,14 @@ NCollection_Sequence HYDROGUI_ImportPolylineOp::Import } importedEntities.Append(theEntities); } + else if ( anExt == "xy" || (importXY && anExt == "xyz")) + { + HYDROData_Tool::importPolylineFromXYZ(aFileName, theDocument, true, importedEntities); + } + else if (anExt == "xyz") + { + HYDROData_Tool::importPolylineFromXYZ(aFileName, theDocument, false, importedEntities); + } } return importedEntities; } diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 0f46924b..3b654ee6 100755 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2554,7 +2554,11 @@ file cannot be correctly imported for an Obstacle definition. POLYLINE_FILTER - Shape files (*.shp) + Shape files (*.shp);;XY files(*.xy);;XYZ files(*.xyz) + + + IMPORT_POLYLINE_XY_PART_ONLY + Do you wish to import the XY part only? (Click 'Yes' to import as polylineXY and 'No' to import as Polyline3D) BAD_IMPORTED_POLYLINE_FILES_TLT diff --git a/src/HYDRO_tests/reference_data/CMakeLists.txt b/src/HYDRO_tests/reference_data/CMakeLists.txt index 6732da78..cb701d8b 100644 --- a/src/HYDRO_tests/reference_data/CMakeLists.txt +++ b/src/HYDRO_tests/reference_data/CMakeLists.txt @@ -151,6 +151,9 @@ SET(REFERENCE_DATA bathy_prs_fit_selected.png zone_random_colors.png diff_image.png + Polyline_import_XY.png + Polyline_import_XYZ.png + Polyline_import_XYZ_3D.png ) # Application tests diff --git a/src/HYDRO_tests/reference_data/linux/Polyline_import_XY.png b/src/HYDRO_tests/reference_data/linux/Polyline_import_XY.png new file mode 100644 index 0000000000000000000000000000000000000000..c71b5b64761f8fba5b249add9916c0548cdb5c93 GIT binary patch literal 4222 zcmY*ceNa@_6+gQRf&^WZpo9>1`4F4|aTBT~Y5@^Y#8Rh;2}Z}f8b8v8wwp4sbV~6i zX%G{NHdeDy0{+poGc6ObX&pMr=%ZROjnSk@2rZhdG1a7kUB=mD{n)0z^WHnR6K0s5 z-#zF2e&?L~@$TKZx^elml&lmYnpVG}=G#ObKau;sEiRC*~Zds|)=soUZ$ubppSA5ZodXxqlPx@&40kw2dunktP4 z-3dgelGDh)C9Yo5rrlA`wjzn5d*IYre$1Va48fUxsxoi5ZfVlSEpcj3_Y+msDWal3 zw9|hy&z`1Abxe?*Ut{=IN-Ts#E!y%>)D!E`2)eQT8g&BoYNVo`!Ciu^oWr$e4yl_$ zuVzDR7^T?N6|Du*wj$UrYg-a*m&InMm4mceeM8FK6zc%$*61mq zeS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rr=XULaozhKxzyabQ|7*GnelY_28UYOJOiN}r|yHHS2u)C(Z`bzuIHd*s#fsl+ZUvyMF56SVpQuzF??A-NNgiPE0 zxGvwEqMIlN!$*UgQYW9Ftgj2L-`-R=^b<5!8o5 z*Uk2ms?^c;+<+sabNk&%G#n~a&$eNff5L-A2WS=5Ss7c3k3}UHPCrO{CF!ey)>yYc zs*H9-8F9gSv+;5E`_P(+ac$OCHhpanHgB4`(kkvbw1SmeB`541HSmE&YNyin!FC`& z-L?N_K+edf2lC0ok=nAj?q5C6N8kVbQCML}gmd@Bp=Yhbu{RFS-tn|uH>Pk^dHVQV z=^il-c>en1@}X~=nwnA%4aWsxK8JYE9Lo#=@KwlkWReUx>gSg+if64Lju1{~g zh-oi3FTAZP|KdsGYUdiC*be>O^D(WL21m`qIl&VKyH+khm~JPhlPcuZtqjUN3^p3yXvv*ovVL-wZ!26Z@1r_6ke&->dX201x=k} z?-MTE>7$?0s?@1T-#RT4qkk=dOmKvhu036vv)2Za@x?N@a6KpKHwsixa91haLr3Vp zNT*ai_zAEgJ)b2FEEBhZ86iPhR|{V_q(}P1fuaqJ2_MP`=s*SSyBsX%@59{{+3O1b dCi<#ThsDZSwmU1{mi`xD)yfe6Gb=QE{|_}z #include #include +#include + +extern QString REF_DATA_PATH; void test_HYDROData_PolylineXY::test_polyline() { @@ -539,3 +542,33 @@ void test_HYDROData_PolylineXY::test_split_straight_refs_634() aDoc->Close(); } + +void test_HYDROData_PolylineXY::test_import_from_xyz() +{ + NCollection_Sequence ents; + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); + TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data(); + fname += "/profiles1.xyz"; + + NCollection_Sequence importedEntities; + bool stat = HYDROData_Tool::importPolylineFromXYZ(QString(fname.ToCString()), aDoc, true, importedEntities); + CPPUNIT_ASSERT (stat); + Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast(importedEntities.First()); + CPPUNIT_ASSERT_EQUAL (importedEntities.Size(), 1); + CPPUNIT_ASSERT (!aPolyXY.IsNull()); + TestViewer::show( aPolyXY->GetShape(), 0, true, "Polyline_import_XY" ); + CPPUNIT_ASSERT_IMAGES + importedEntities.Clear(); + + stat = HYDROData_Tool::importPolylineFromXYZ(QString(fname.ToCString()), aDoc, false, importedEntities); + CPPUNIT_ASSERT (stat); + CPPUNIT_ASSERT_EQUAL (importedEntities.Size(), 2); + Handle(HYDROData_Polyline3D) aPoly3D; + aPolyXY = Handle(HYDROData_PolylineXY)::DownCast(importedEntities.First()); + aPoly3D = Handle(HYDROData_Polyline3D)::DownCast(importedEntities.Last()); + CPPUNIT_ASSERT (!aPolyXY.IsNull()); + CPPUNIT_ASSERT (!aPoly3D.IsNull()); + TestViewer::show( aPolyXY->GetShape(), 0, false, "Polyline_import_XYZ" ); + TestViewer::show( aPoly3D->GetShape3D(), 0, false, "Polyline_import_XYZ_3D" ); + CPPUNIT_ASSERT_IMAGES +} \ No newline at end of file diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.h b/src/HYDRO_tests/test_HYDROData_PolylineXY.h index d51b20f5..b03ac734 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.h +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.h @@ -30,6 +30,8 @@ class test_HYDROData_PolylineXY : public CppUnit::TestFixture { CPPUNIT_TEST( test_custom_polylines ); CPPUNIT_TEST( test_merge_refs_630 ); CPPUNIT_TEST( test_split_straight_refs_634 ); + CPPUNIT_TEST( test_import_from_xyz ); + CPPUNIT_TEST_SUITE_END(); private: @@ -55,6 +57,8 @@ public: void test_custom_polylines(); void test_merge_refs_630(); void test_split_straight_refs_634(); + void test_import_from_xyz(); + }; CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY); -- 2.39.2