From: isn Date: Fri, 8 Feb 2019 13:50:10 +0000 (+0300) Subject: export of 3D poly to SHP (lot 5) X-Git-Tag: SH_V2_2_0~99^2~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6120f6f24e5568ffa69e959689789e1fbe59d58a;p=modules%2Fhydro.git export of 3D poly to SHP (lot 5) --- diff --git a/src/HYDROData/HYDROData_Polyline3D.cxx b/src/HYDROData/HYDROData_Polyline3D.cxx index 15959d97..858a0a6c 100644 --- a/src/HYDROData/HYDROData_Polyline3D.cxx +++ b/src/HYDROData/HYDROData_Polyline3D.cxx @@ -153,9 +153,22 @@ void HYDROData_Polyline3D::Update() bool anIsSectionClosed = aPolylineXY->IsClosedSection( 0 ); HYDROData_IPolyline::SectionType aSectionType = aPolylineXY->GetSectionType( 0 ); + NCollection_Sequence aResPoints = GetProfilePoints3D(); + + TopoDS_Wire aResWire = HYDROData_PolylineXY::BuildWire( aSectionType, anIsSectionClosed, aResPoints ); + SetTopShape( aResWire ); + SetShape3D( aResWire ); +} + +HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetProfilePoints3D() +{ + Handle(HYDROData_PolylineXY) aPolylineXY = GetPolylineXY(); + if ( aPolylineXY.IsNull() ) + return Polyline3DPoints(); + HYDROData_IPolyline::PointsList aPolylinePoints = aPolylineXY->GetPoints( 0 ); if ( aPolylinePoints.IsEmpty() ) - return; + return Polyline3DPoints(); Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ(); @@ -164,11 +177,11 @@ void HYDROData_Polyline3D::Update() aProfileUZ = GetChildProfileUZ(); if ( aProfileUZ.IsNull() ) - return; + return Polyline3DPoints(); HYDROData_IPolyline::PointsList aProfilePoints = aProfileUZ->GetPoints(); if ( aProfilePoints.IsEmpty() ) - return; + return NCollection_Sequence(); const HYDROData_IPolyline::Point& aFirstPoint = aPolylinePoints.First(); const HYDROData_IPolyline::Point& aLastPoint = aPolylinePoints.Last(); @@ -200,10 +213,8 @@ void HYDROData_Polyline3D::Update() // Add last point as is aResPoints.Append( Polyline3DPoint( aLastPoint.X(), aLastPoint.Y(), aLastParPoint.Y() ) ); - TopoDS_Wire aResWire = HYDROData_PolylineXY::BuildWire( aSectionType, anIsSectionClosed, aResPoints ); - SetTopShape( aResWire ); - SetShape3D( aResWire ); -} + return aResPoints; +} QColor HYDROData_Polyline3D::DefaultFillingColor() const { diff --git a/src/HYDROData/HYDROData_Polyline3D.h b/src/HYDROData/HYDROData_Polyline3D.h index 9500afa5..1666a459 100644 --- a/src/HYDROData/HYDROData_Polyline3D.h +++ b/src/HYDROData/HYDROData_Polyline3D.h @@ -132,6 +132,7 @@ public: */ HYDRODATA_EXPORT virtual void RemoveAltitudeObject(); + HYDRODATA_EXPORT Polyline3DPoints GetProfilePoints3D(); /** * Returns the child u,z profile which has been generated from bathymetry. @@ -159,7 +160,6 @@ protected: protected: - void updateChildProfilePoints(); void removeChildProfileUZ(); diff --git a/src/HYDROData/HYDROData_ShapeFile.cxx b/src/HYDROData/HYDROData_ShapeFile.cxx index eef771c3..fdcb4a59 100644 --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@ -158,24 +158,24 @@ int HYDROData_ShapeFile::WriteObjectPolyXY(Handle(HYDROData_Document) theDocumen for (int i = 0; i < thePoly->NbSections(); i++) { anPartStart.push_back(x.size()); - HYDROData_PolylineXY::PointsList aPointList = thePoly->GetPoints(i); + HYDROData_PolylineXY::PointsList aPointList = thePoly->GetPoints(i, true); for (int j = 1; j <= aPointList.Size(); j++) { gp_XY P = aPointList(j); - theDocument->Transform(P, false); + //theDocument->Transform(P, false); x.push_back( P.X()); y.push_back( P.Y()); } if (thePoly->IsClosedSection(i)) { gp_XY P = aPointList(1); - theDocument->Transform(P, false); + //theDocument->Transform(P, false); x.push_back( P.X()); y.push_back( P.Y()); } } - aSHPObj = SHPCreateObject( SHPT_ARC, -1, thePoly->NbSections(), &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL ); + aSHPObj = SHPCreateObject (SHPT_ARC, -1, thePoly->NbSections(), &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL ); SHPWriteObject( theShpHandle, -1, aSHPObj ); SHPDestroyObject( aSHPObj ); return 1; @@ -185,38 +185,33 @@ int HYDROData_ShapeFile::WriteObjectPoly3D(Handle(HYDROData_Document) theDocumen SHPHandle theShpHandle, Handle(HYDROData_Polyline3D) thePoly ) { - SHPObject *aSHPObj; + SHPObject *aSHPObj; std::vector x, y, z; std::vector anPartStart; + anPartStart.push_back(0); //one section only - for (int i = 0; i < thePoly->GetPolylineXY()->NbSections(); i++) - if (thePoly->GetPolylineXY()->GetSectionType(i) == HYDROData_IPolyline::SECTION_SPLINE) - return -1; - - for (int i = 0; i < thePoly->GetPolylineXY()->NbSections(); i++) - { - anPartStart.push_back(x.size()); - HYDROData_PolylineXY::PointsList aPointList = thePoly->GetPolylineXY()->GetPoints(i); - for (int j = 1; j <= aPointList.Size(); j++) - { - gp_XY P = aPointList(j); - theDocument->Transform(P, false); - x.push_back( P.X()); - y.push_back( P.Y()); - z.push_back(thePoly->GetAltitudeObject()->GetAltitudeForPoint(gp_XY (aPointList(j).X(), aPointList(j).Y()))); - } - if ( thePoly->GetPolylineXY()->IsClosedSection(i)) - { - gp_XY P = aPointList(1); - theDocument->Transform(P, false); - x.push_back( P.X()); - y.push_back( P.Y()); - z.push_back(thePoly->GetAltitudeObject()->GetAltitudeForPoint(gp_XY (aPointList(1).X(), aPointList(1).Y()))); + if (thePoly->GetPolylineXY()->GetSectionType(0) == HYDROData_IPolyline::SECTION_SPLINE) + return -1; - } + HYDROData_Polyline3D::Polyline3DPoints aPointList3D = thePoly->GetProfilePoints3D(); + for (int j = 1; j <= aPointList3D.Size(); j++) + { + const gp_XYZ& P = aPointList3D(j); + //theDocument->Transform(P, false); + x.push_back(P.X()); + y.push_back(P.Y()); + z.push_back(P.Z()); } - - aSHPObj = SHPCreateObject( SHPT_ARCZ, -1, thePoly->GetPolylineXY()->NbSections(), &anPartStart[0], NULL, x.size(), &x[0], &y[0], &z[0], NULL ); + if ( thePoly->GetPolylineXY()->IsClosedSection(0)) + { + const gp_XYZ& P = aPointList3D(1); + //theDocument->Transform(P, false); + x.push_back(P.X()); + y.push_back(P.Y()); + z.push_back(P.Z()); + } + + aSHPObj = SHPCreateObject( SHPT_ARCZ, -1, 1, &anPartStart[0], NULL, x.size(), &x[0], &y[0], &z[0], NULL ); SHPWriteObject( theShpHandle, -1, aSHPObj ); SHPDestroyObject( aSHPObj ); return 1; diff --git a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx index cf1565cf..956fb7f3 100644 --- a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx @@ -108,7 +108,7 @@ void HYDROGUI_ExportFileOp::startOperation() QStringList aNonExpList; HYDROData_ShapeFile anExporter; Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() ); - if (!aPolyXYSeq.IsEmpty() || !aPolyXYSeq.IsEmpty()) + if (!aPolyXYSeq.IsEmpty() || !aPoly3DSeq.IsEmpty()) //Export polylines anExporter.Export(aDoc, aFileName, aPolyXYSeq, aPoly3DSeq, aNonExpList); else diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 4b0e8863..aeacb30b 100755 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -590,6 +590,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, break; case KIND_POLYLINE: theMenu->addAction( action( CreatePolyline3DId ) ); + theMenu->addAction( action( ImportPolylineId ) ); break; case KIND_PROFILE: theMenu->addAction( action( CreateProfileId ) );