]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
tentative utilisation ligne altitude, non disponible, probleme precision tracé ligne...
authorPaul RASCLE <paul.rascle@edf.fr>
Tue, 11 Aug 2015 12:49:18 +0000 (14:49 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Tue, 11 Aug 2015 12:49:18 +0000 (14:49 +0200)
src/HYDROData/HYDROData_ChannelAltitude.cxx

index 1b956feaba533ad209558abef0b8bfb94de3fd17..1b1111c45350801030b209a93c823d6a9410f187 100644 (file)
@@ -78,6 +78,7 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
       return aResAltitude;
     }
   DEBTRACE("aChannel: " << aChannel->GetName().toStdString());
+
   Handle(HYDROData_Polyline3D) aGuideLine = aChannel->GetGuideLine();
   if (aGuideLine.IsNull())
     {
@@ -85,6 +86,27 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
       return aResAltitude;
     }
   DEBTRACE("aGuideLine: " << aGuideLine->GetName().toStdString());
+
+  Handle(HYDROData_PolylineXY) aGuideXY = aGuideLine->GetPolylineXY();
+  if (aGuideXY.IsNull())
+    {
+      DEBTRACE("aGuideXY.IsNull()");
+      return aResAltitude;
+    }
+  DEBTRACE("aGuideXY: " << aGuideXY->GetName().toStdString());
+
+  Handle(HYDROData_ProfileUZ) aGuideUZ = aGuideLine->GetProfileUZ();
+  if (aGuideUZ.IsNull())
+    {
+      aGuideUZ = aGuideLine->GetChildProfileUZ(); // profile obtained from bathymetry
+    }
+  if (aGuideUZ.IsNull())
+    {
+      DEBTRACE("aGuideUZ.IsNull()");
+      return aResAltitude;
+    }
+  DEBTRACE("aGuideUZ: " << aGuideUZ->GetName().toStdString());
+
   Handle (HYDROData_Profile) aProfile = aChannel->GetProfile();
   if (aProfile.IsNull())
     {
@@ -94,14 +116,17 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
 
   // --- See GEOMImpl_ProjectionDriver.cxx
 
-  TopoDS_Shape aShape = aGuideLine->GetShape3D();
-  double middleZ = -9999;
-  aGuideLine->GetMiddleZ(middleZ); // use the middle Z value of the 3d line to help the projection.
-  if (middleZ < -9000)
-    {
-      DEBTRACE("the middle Z value of the 3d line is incorrect");
-    }
-  gp_Pnt P1(thePoint.X(), thePoint.Y(), middleZ);
+//  TopoDS_Shape aShape = aGuideLine->GetShape3D();
+//  double middleZ = -9999;
+//  aGuideLine->GetMiddleZ(middleZ); // use the middle Z value of the 3d line to help the projection.
+//  if (middleZ < -9000)
+//    {
+//      DEBTRACE("the middle Z value of the 3d line is incorrect");
+//    }
+//  gp_Pnt P1(thePoint.X(), thePoint.Y(), middleZ);
+
+  TopoDS_Shape aShape =  aGuideXY->GetShape();
+  gp_Pnt P1(thePoint.X(), thePoint.Y(), 0);
   TopoDS_Shape aPoint = BRepBuilderAPI_MakeVertex(P1).Shape();
 
   if (aPoint.IsNull() || aShape.IsNull())
@@ -234,18 +259,28 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
           // 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);
+
+          // Compute edge index.
+          TopExp_Explorer anExp(aShape, TopAbs_EDGE);
+          int anIndex = 0;
+          for (; anExp.More(); anExp.Next(), anIndex++)
+            {
+              if (aSupportShape.IsSame(anExp.Current()))
+                {
+                  break;
+                }
+            }
 
           // Construct a projection vertex.
           const gp_Pnt &aPntProj = aDistShSh.PointOnShape2(i);
-          TopoDS_Shape aProj = BRepBuilderAPI_MakeVertex(aPntProj).Shape();
+//          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);
@@ -275,16 +310,47 @@ 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 = aPntProj.Z() + pt1.Y();
+              aResAltitude = zRef + pt1.Y();
             }
           else
             {
               double z = pt1.Y() + (pt2.Y() - pt1.Y())*(distance -pt1.X())/(pt2.X()-pt1.X());
-              aResAltitude = aPntProj.Z() + z;
+              aResAltitude = zRef + z;
             }
-          DEBTRACE("altitude: " << aResAltitude << " delta: " << aResAltitude - aPntProj.Z());
+          DEBTRACE("altitude: " << aResAltitude << " delta: " << aResAltitude - zRef);
           return aResAltitude;
         }
     }