]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
get altitude with GetDepthFromDistance function OK, housekeeping needed
authorPaul RASCLE <paul.rascle@edf.fr>
Wed, 12 Aug 2015 08:48:40 +0000 (10:48 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Wed, 12 Aug 2015 08:48:40 +0000 (10:48 +0200)
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_Channel.h
src/HYDROData/HYDROData_ChannelAltitude.cxx

index 04b316c93f23420f26f1c900abcd83b3f29e7dfc..3ac722fbfa3be33792efb4322131ddcf7fe812c3 100644 (file)
@@ -126,6 +126,11 @@ TopoDS_Shape HYDROData_Channel::GetShape3D() const
   return getShape3D();
 }
 
+//TopoDS_Wire HYDROData_Channel::GetLeftBank() const
+//{
+//
+//}
+
 bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
                                              const Handle(HYDROData_Profile)&    theProfile,
                                              PrsDefinition&                      thePrs )
@@ -318,6 +323,11 @@ void HYDROData_Channel::Update()
   SetShape3D( aResultPrs.myPrs3D );
   SetTopShape( aResultPrs.myPrs2D );
 
+//  TopoDS_Wire aPrevLeftBank = GetLeftBank();
+//  if ( ! aPrevLeftBank.IsNull() )
+//    ClearReferenceObjects( DataTag_LeftBank );
+//  SetReferenceObject( aResultPrs.myLeftBank, DataTag_LeftBank );
+
   // Create groups for channel
   TopTools_SequenceOfShape aLeftBankEdges;
   HYDROData_ShapesTool::ExploreShapeToShapes( aResultPrs.myLeftBank, TopAbs_EDGE, aLeftBankEdges );
index a53db842abeda6bbfce977a717ca1bb7e0dbc176..55a26aa78f0426df8c86d49ac38f65d044f5518e 100644 (file)
@@ -58,6 +58,7 @@ protected:
     DataTag_First = HYDROData_ArtificialObject::DataTag_First + 100, ///< first tag, to reserve
     DataTag_GuideLine, 
     DataTag_Profile,
+//    DataTag_LeftBank,
   };
 
 public:
@@ -100,7 +101,12 @@ public:
    */
   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
 
-  /**
+//  /**
+//   * Returns the left bank of the object.
+//   */
+//  HYDRODATA_EXPORT virtual TopoDS_Wire GetLeftBank() const;
+
+ /**
    * Update the shape presentations of stream.
    * Call this method whenever you made changes for channel data.
    */
index 1b1111c45350801030b209a93c823d6a9410f187..7d985833b7e56d8ff02fdec348aaf06390b292c5 100644 (file)
@@ -256,16 +256,27 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
           // Store the valid solution.
           hasValidSolution = Standard_True;
 
-          // Normalize parameter.
-          TopoDS_Edge aSupportEdge = TopoDS::Edge(aSupportShape);
-          Standard_Real aF, aL;
-          BRep_Tool::Range(aSupportEdge, aF, aL);
-          if (Abs(aL - aF) <= aTolConf)
+          DEBTRACE("distance XY: "<< aParam);
+//          // Normalize parameter.
+//          TopoDS_Edge aSupportEdge = TopoDS::Edge(aSupportShape);
+//          Standard_Real aF, aL;
+//          BRep_Tool::Range(aSupportEdge, aF, aL);
+//          if (Abs(aL - aF) <= aTolConf)
+//            {
+//              DEBTRACE("Projection aborted : degenerated projection edge");
+//              return aResAltitude;
+//            }
+//          aParam = (aParam - aF)/(aL - aF);
+
+          // profile altitude at projection point
+          HYDROData_IPolyline::PointsList aProfilePoints = aGuideUZ->GetPoints();
+          if ( aProfilePoints.IsEmpty() )
             {
-              DEBTRACE("Projection aborted : degenerated projection edge");
+              DEBTRACE("empty profile UZ");
               return aResAltitude;
             }
-          aParam = (aParam - aF)/(aL - aF);
+          double aDepth = HYDROData_ProfileUZ::GetDepthFromDistance( aProfilePoints, aParam );
+          DEBTRACE("profile altitude: " << aDepth);
 
           // Compute edge index.
           TopExp_Explorer anExp(aShape, TopAbs_EDGE);
@@ -278,21 +289,23 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
                 }
             }
 
-          // Construct a projection vertex.
+          // get the XY distance from point to guideline
           const gp_Pnt &aPntProj = aDistShSh.PointOnShape2(i);
-//          TopoDS_Shape aProj = BRepBuilderAPI_MakeVertex(aPntProj).Shape();
           DEBTRACE("projection: (" << aPntProj.X() << ", " << aPntProj.Y() << ", " << aPntProj.Z() << ")");
           gp_XY aProjXY = gp_XY(aPntProj.X(), aPntProj.Y());
           aProjXY.Subtract(thePoint);
           double distance = aProjXY.Modulus();
-          DEBTRACE("distance " << distance);
+          DEBTRACE("distance to guideline " << distance);
+
+          // get delta altitude on section (supposed symmetric) from guideline distance
+          double delta = 0;
           int i1 = 0;
           gp_XY pt1 = gp_XY();
           gp_XY pt2 = gp_XY();
-          HYDROData_ProfileUZ::PointsList aProfilePoints = aProfile->GetParametricPoints();
-          for ( int i = 1, aNbPoints = aProfilePoints.Size(); i <= aNbPoints; ++i )
+          HYDROData_ProfileUZ::PointsList aSectionPoints = aProfile->GetParametricPoints();
+          for ( int i = 1, aNbPoints = aSectionPoints.Size(); i <= aNbPoints; ++i )
             {
-              const HYDROData_IPolyline::Point& aPolylinePoint = aProfilePoints.Value( i );
+              const HYDROData_IPolyline::Point& aPolylinePoint = aSectionPoints.Value( i );
               DEBTRACE("  profile point: " << aPolylinePoint.X() << " " << aPolylinePoint.Y());
               if (aPolylinePoint.X() < distance)
                 {
@@ -310,47 +323,16 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
               DEBTRACE("Projection aborted : non centered profile");
               return aResAltitude;
             }
-
-          // get the point with the same param on altitude profile
-          double zRef = 0; //aPntProj.Z();
-          TopoDS_Shape aShapeUZ =  aGuideUZ->GetShape();
-          if (!aShapeUZ.IsNull())
-            {
-              TopExp_Explorer anExpUZ(aShapeUZ, TopAbs_EDGE);
-              TopoDS_Edge anEdgeUZ;
-              int anI = 0;
-              for (; anExpUZ.More(); anExpUZ.Next(), anI++)
-                {
-                  if (anI == anIndex)
-                    {
-                      anEdgeUZ = TopoDS::Edge(anExpUZ.Current());
-                      break;
-                    }
-                }
-              if (!anEdgeUZ.IsNull())
-                {
-                  double anEdgePars[2];
-                  Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdgeUZ, anEdgePars[0], anEdgePars[1]);
-                  gp_Pnt aVal;
-                  aCurve->D0(aParam, aVal);
-                  DEBTRACE("altitude point: " << aVal.X() << " "<< aVal.Y() << " "<< aVal.Z());
-                  zRef = aVal.Y();
-                }
-              else zRef = 20;
-            }
-          else zRef = 20;
-
-          // distance on section to get altitude
           if (i1 == aProfilePoints.Size()) // distance >= profile width
             {
-              aResAltitude = zRef + pt1.Y();
+              delta = pt1.Y();
             }
           else
             {
-              double z = pt1.Y() + (pt2.Y() - pt1.Y())*(distance -pt1.X())/(pt2.X()-pt1.X());
-              aResAltitude = zRef + z;
+              delta = pt1.Y() + (pt2.Y() - pt1.Y())*(distance -pt1.X())/(pt2.X()-pt1.X());
             }
-          DEBTRACE("altitude: " << aResAltitude << " delta: " << aResAltitude - zRef);
+          aResAltitude = delta + aDepth;
+          DEBTRACE("final altitude: " << aResAltitude << " delta: " << delta);
           return aResAltitude;
         }
     }