]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
export of 3D poly to SHP (lot 5)
authorisn <isn@opencascade.com>
Fri, 8 Feb 2019 13:50:10 +0000 (16:50 +0300)
committerisn <isn@opencascade.com>
Fri, 8 Feb 2019 13:50:58 +0000 (16:50 +0300)
src/HYDROData/HYDROData_Polyline3D.cxx
src/HYDROData/HYDROData_Polyline3D.h
src/HYDROData/HYDROData_ShapeFile.cxx
src/HYDROGUI/HYDROGUI_ExportFileOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx

index 15959d971f698ca5499aa347c7d7f3dc604470af..858a0a6c7b73641ecef7d6b5231707b8c1488308 100644 (file)
@@ -153,9 +153,22 @@ void HYDROData_Polyline3D::Update()
 
   bool anIsSectionClosed = aPolylineXY->IsClosedSection( 0 );
   HYDROData_IPolyline::SectionType aSectionType = aPolylineXY->GetSectionType( 0 );
+  NCollection_Sequence<Polyline3DPoint> 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<HYDROData_Polyline3D::Polyline3DPoint>();
 
   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
 {
index 9500afa5091ba8f0c43a189e3eadf4a442b3d7ac..1666a459bc48c99551b7a927be765e1d1b2b56e6 100644 (file)
@@ -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();
index eef771c39552054b76c89b17c8e81f236e441431..fdcb4a592fb70be201b72ad7a03a9bcdc57dbcae 100644 (file)
@@ -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 = SHPCreateObjectSHPT_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<double> x, y, z;
   std::vector<int> 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;
index cf1565cfff4ba533c3a6ba2b6b764feaaa316b4c..956fb7f3e57eb159ab21e7c6e42531e85d893ed0 100644 (file)
@@ -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
index 4b0e8863dd3e6b614515aca308eb9221066d5067..aeacb30b53d9fb739a760cf440eab91fd948e7b1 100755 (executable)
@@ -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 ) );