]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
sinusX p.2
authorisn <isn@opencascade.com>
Tue, 16 Jun 2015 16:55:33 +0000 (19:55 +0300)
committerisn <isn@opencascade.com>
Wed, 17 Jun 2015 07:37:41 +0000 (10:37 +0300)
src/HYDROData/HYDROData_ProfileUZ.cxx
src/HYDROData/HYDROData_ProfileUZ.h
src/HYDROData/HYDROData_Stream.cxx
src/HYDROGUI/HYDROGUI_ImportSinusXOp.cxx
src/HYDROGUI/HYDROGUI_ImportSinusXOp.h

index a551f43f2d49248f38bd3df1f8284d12e51cb182..1189970cb45bfe753c1ae92687a2a2eec03186eb 100755 (executable)
@@ -32,6 +32,9 @@
 
 #include <TopoDS_Shape.hxx>
 
+#include <HYDROData_Profile.h>
+#include <HYDROData_PolylineXY.h>
+
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ProfileUZ, HYDROData_IPolyline)
@@ -275,4 +278,36 @@ HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theS
   return aResList;
 }
 
+void HYDROData_ProfileUZ::CalculateAndAddPoints(const NCollection_Sequence<gp_XYZ>& theXYZPoints, Handle_HYDROData_PolylineXY& thePolylineXY)
+{
+   // Fill 2D polyline
+  for ( int i = 1; i <= theXYZPoints.Size(); i++ ) {
+    const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i );
+    thePolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
+  }
+  
+  // Calculate profile UZ points
+
+  // First point
+  const HYDROData_Profile::ProfilePoint& aFirstBottomPoint = theXYZPoints.First();
+  AddPoint( 0, HYDROData_ProfileUZ::Point( 0, aFirstBottomPoint.Z() ) );
+
+  // Intermediate points
+  double aPolylineCommonDist = thePolylineXY->GetDistance( 0, thePolylineXY->NbPoints( 0 ) - 1 );
+
+  for ( int i = 2, aNbPoints = theXYZPoints.Size(); i < aNbPoints; i++ ) {
+    const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i );
+    
+    double aDistance = thePolylineXY->GetDistance( 0, i - 1 );
+    
+    Standard_Real anU = aDistance; // = ( aDistance / aPolylineCommonDist ) * aPolylineCommonDist;
+    AddPoint( 0, HYDROData_ProfileUZ::Point( anU, aBottomPoint.Z() ) );
+  }
+  
+  // Last point
+  const HYDROData_Profile::ProfilePoint& aLastBottomPoint = theXYZPoints.Last();
+  AddPoint( 0, HYDROData_ProfileUZ::Point( aPolylineCommonDist, aLastBottomPoint.Z() ) );
+}
+
 
index 62a5c14ef3fe98c95fade9ddf868630f1d3a7197..fd543f0723745efbb7263fcd9cca01da943e39a6 100644 (file)
@@ -23,6 +23,9 @@
 
 DEFINE_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline)
 
+class gp_XYZ;
+class Handle_HYDROData_PolylineXY;
+
 /**\class HYDROData_ProfileUZ
  * \brief Class that stores/retreives information about the 
  *        parametric profile points.
@@ -167,6 +170,8 @@ public:
    */
   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const;
 
+  HYDRODATA_EXPORT virtual void CalculateAndAddPoints(const NCollection_Sequence<gp_XYZ>& theXYZPoints, Handle_HYDROData_PolylineXY& thePolylineXY);
+
 protected:
 
   friend class HYDROData_Iterator;
index 29b7aae65a1f1b64c81ff8b6cad78aaae1b6c208..e9da1296964a7c1b7a99ba8d5be4df0784f08035 100644 (file)
@@ -1082,33 +1082,7 @@ bool HYDROData_Stream::GenerateBottomPolyline()
   
   aProfileUZ->RemoveSection( 0 );
 
-  // Fill 2D polyline
-  for ( int i = 1; i <= aNbBottomPoints; i++ ) {
-    const HYDROData_Profile::ProfilePoint& aBottomPoint = aBottomPoints.Value( i );
-    aPolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
-  }
-  
-  // Calculate profile UZ points
-
-  // First point
-  const HYDROData_Profile::ProfilePoint& aFirstBottomPoint = aBottomPoints.First();
-  aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( 0, aFirstBottomPoint.Z() ) );
-
-  // Intermediate points
-  double aPolylineCommonDist = aPolylineXY->GetDistance( 0, aPolylineXY->NbPoints( 0 ) - 1 );
-
-  for ( int i = 2, aNbPoints = aBottomPoints.Size(); i < aNbPoints; i++ ) {
-    const HYDROData_Profile::ProfilePoint& aBottomPoint = aBottomPoints.Value( i );
-    
-    double aDistance = aPolylineXY->GetDistance( 0, i - 1 );
-    
-    Standard_Real anU = aDistance; // = ( aDistance / aPolylineCommonDist ) * aPolylineCommonDist;
-    aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( anU, aBottomPoint.Z() ) );
-  }
-  
-  // Last point
-  const HYDROData_Profile::ProfilePoint& aLastBottomPoint = aBottomPoints.Last();
-  aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( aPolylineCommonDist, aLastBottomPoint.Z() ) );
+  aProfileUZ->CalculateAndAddPoints(aBottomPoints, aPolylineXY);
   
   return true;
 }
index 7491988e2c758967edb0af3507ae352980a9f90f..291338a0ed5b536e382a3e04fdf0db69e443282c 100644 (file)
@@ -111,72 +111,96 @@ void HYDROGUI_ImportSinusXOp::onApply()
 
 void HYDROGUI_ImportSinusXOp::ProcessSX()
 {
-  Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
+  /*Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
 
   Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( doc()->CreateObject( KIND_POLYLINE ) );
-
-  Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) );
-  HYDROData_Bathymetry::AltitudePoints aAPoints;
-
-  int aNSect = myCurveBlocks.size();
-  for ( int i = 0 ; i < aNSect ; i++ )
+  */
+  //TODO - move to hydro data
+  std::vector<Handle(HYDROData_Entity)> anEntities;
+  for ( int i = 0; i < myCurveBlocks.size(); i++ )
   {
-    bool aSectClosure = true;
-    HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; 
-    aPolylineXY->AddSection( TCollection_AsciiString(myCurveBlocks[i].myName.toStdString().c_str()), aSectType, myCurveBlocks[i].myIsConnected );
-  
-    for ( int k = 0 ; k < myCurveBlocks[i].myXYZPoints.size() ; k+=3 )
+    if (myCurveBlocks[i].myType == 4) ///  scatter plot -> to bathy
     {
-      HYDROData_PolylineXY::Point aSectPoint;
-      aSectPoint.SetX( myCurveBlocks[i].myXYZPoints[k].X() );
-      aSectPoint.SetY( myCurveBlocks[i].myXYZPoints[k].Y() );
-      aPolylineXY->AddPoint( i, aSectPoint );
-  
-      aAPoints.Append(myCurveBlocks[i].myXYZPoints[k]);
+      Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) );
+      HYDROData_Bathymetry::AltitudePoints aAPoints;
+      for (int j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+        aAPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[j]));
+
+      aBath->SetAltitudePoints(aAPoints);
+      aBath->SetName(myCurveBlocks[i].myName);
+      anEntities.push_back(aBath);
+    }
+    if (myCurveBlocks[i].myType == 1 || myCurveBlocks[i].myType == 3)
+    {
+      NCollection_Sequence<gp_XYZ> aPoints;
+      for (int j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+        aPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[j]));
+      if (myCurveBlocks[i].myIsClosed)
+        aPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[0]));
+      Handle(HYDROData_ProfileUZ) aProfileUZ = Handle(HYDROData_ProfileUZ)::DownCast( doc()->CreateObject( KIND_PROFILEUZ ) );
+      Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
+      aPolyXY->AddSection( "",  myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE, false ); 
+      aProfileUZ->CalculateAndAddPoints(aPoints, aPolyXY);
+      Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
+      aProfile->SetParametricPoints(aProfileUZ->GetPoints());
+      aPolyXY->SetName(myCurveBlocks[i].myName + "_polyXY");
+      aProfileUZ->SetName(myCurveBlocks[i].myName + "_profileUZ");
+      aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+      anEntities.push_back(aPolyXY);
+      anEntities.push_back(aProfileUZ);
+      anEntities.push_back(aProfile);
+    }
+    if (myCurveBlocks[i].myType == 2)
+    {
+      if (myCurveBlocks[i].myCurvePlane == 2)
+      {
+        if (myCurveBlocks[i].myAdditionalCurveInfo.size() == 4)
+        {
+          Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
+          HYDROData_ProfileUZ::PointsList aPointList;
+          for (int j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+            aPointList.Append(gp_XY (myCurveBlocks[i].myXYZPoints[j].X(), myCurveBlocks[i].myXYZPoints[j].Z()));
+           
+          aProfile->SetParametricPoints(aPointList);
+          if ( ! (myCurveBlocks[i].myAdditionalCurveInfo[0] == 0 &&  myCurveBlocks[i].myAdditionalCurveInfo[1] == 0 && 
+            myCurveBlocks[i].myAdditionalCurveInfo[2] == 0 && myCurveBlocks[i].myAdditionalCurveInfo[3] == 0) )
+          {
+            aProfile->SetLeftPoint(gp_XY(myCurveBlocks[i].myAdditionalCurveInfo[0], myCurveBlocks[i].myAdditionalCurveInfo[1]));
+            aProfile->SetRightPoint(gp_XY(myCurveBlocks[i].myAdditionalCurveInfo[2], myCurveBlocks[i].myAdditionalCurveInfo[3]));
+            aProfile->Update();
+          }
+          aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+          anEntities.push_back(aProfile);
+        }
+      }
+      if (myCurveBlocks[i].myCurvePlane == 0)
+      {
+         Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
+         HYDROData_Profile::ProfilePoints aPointList;
+         for (int j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+           aPointList.Append(myCurveBlocks[i].myXYZPoints[j]);
+         aProfile->SetProfilePoints(aPointList);
+         aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+         anEntities.push_back(aProfile);
+      }
     }
   }
-  QString aFileName = myFileDlg->selectedFile();
-  QFileInfo aFileInfo(aFileName);
-  QString aBaseFileName = aFileInfo.baseName();
-  QString aBathName = aBaseFileName + "_bath_1";
-  QString aPolyXYName = aBaseFileName + "_polyXY_1";
-  QString aPoly3DName = aBaseFileName + "_poly3D_1";
-  
-  int anInd = 2;
-  for (;HYDROGUI_Tool::FindObjectByName( module(), aBathName, KIND_BATHYMETRY) || 
-        HYDROGUI_Tool::FindObjectByName( module(), aPolyXYName, KIND_POLYLINEXY) ||
-        HYDROGUI_Tool::FindObjectByName( module(), aPoly3DName, KIND_POLYLINE);)
-  {
-    aBathName = aBaseFileName + "_bath_" + QString::number(anInd);
-    aPolyXYName = aBaseFileName + "_polyXY_" + QString::number(anInd);
-    aPoly3DName = aBaseFileName + "_poly3D_" + QString::number(anInd);
-    anInd++;
-  }
-  
-  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( HYDROData_Polyline3D::DefaultBorderColor() );
-  aPolylineObj->SetName( aPoly3DName );
-  
-  aPolylineObj->Update();
-  
+
+  /////
+
   size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
   if ( anActiveViewId == 0 )
     anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() );
-  
-  module()->setObjectVisible( anActiveViewId, aPolylineXY, true );
-  module()->setObjectVisible( anActiveViewId, aPolylineObj, true );
-  
-  module()->setIsToUpdate( aPolylineObj );
+
+  for (int i = 0; i < anEntities.size() ; i++)
+  {
+    anEntities[i]->Update();
+    module()->setObjectVisible( anActiveViewId, anEntities[i], true );
+    module()->setIsToUpdate( anEntities[i] );
+  }
 }
+
 
 
 bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile)
@@ -196,7 +220,7 @@ bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile)
 
   for (;!theFile.atEnd();) 
   {
-    if (aList[0] == "B" && (aList[1] == "C" || aList[1] == "P" || aList[1] == "N"))
+    if (aList[0] == "B" && (aList[1] == "C" || aList[1] == "P" || aList[1] == "N" || aList[1] == "S" ))
     {  
       HYDROGUI_CurveBlock aCurveBlockInfo;
       if (aList[1] == "C")
@@ -204,7 +228,9 @@ bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile)
       else if (aList[1] == "P")
         aCurveBlockInfo.myType = 2;
       else if (aList[1] == "N")
-        aCurveBlockInfo.myType = 2;
+        aCurveBlockInfo.myType = 3;
+      else if (aList[1] == "S")
+        aCurveBlockInfo.myType = 4;
 
       if (aList.size() == 9)
       {
@@ -226,7 +252,7 @@ bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile)
           else if (aBList.size() == 3 && (aBList[1] == "0" || aBList[1] == "1") && (aBList[2] == "0" || aBList[2] == "1"))
           {
             aCurveBlockInfo.myIsClosed = aBList[1].toInt();
-            aCurveBlockInfo.myIsClosed = aBList[2].toInt();
+            aCurveBlockInfo.myIsSpline = aBList[2].toInt();
           }
           else
           {
@@ -264,10 +290,13 @@ bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile)
         else 
           break;
     
-      } while (!theFile.atEnd()/* && aBLine[0] == 'B'*/ );
+      } while (!theFile.atEnd() || !aBLine.isEmpty());
       if (aTotStat)
         myCurveBlocks.push_back(aCurveBlockInfo);
 
+      aLine = aBLine;
+      aList = aBList;
+
     }
     else
     {
index 0e1d3048e8c834f9651bfb023bc81666b361e2af..dcd38ed554c01c8a09b56ae4e738d0ddf761c564 100644 (file)
@@ -36,7 +36,7 @@ struct HYDROGUI_CurveBlock
     //{};
   std::vector<gp_XYZ> myXYZPoints;
   int myType;
-  bool myIsConnected;
+  bool myIsSpline;
   bool myIsClosed;
   int myCurvePlane;
   QString myName;