]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
middle z for 3D guideline
authorPaul RASCLE <paul.rascle@edf.fr>
Tue, 4 Aug 2015 16:57:35 +0000 (18:57 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Tue, 4 Aug 2015 16:57:35 +0000 (18:57 +0200)
src/HYDROData/HYDROData_ChannelAltitude.cxx
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_Polyline3D.cxx

index fd3917cc21566fda8e23c1f8d04bf44a255f53e6..4031dc82b2761fd4a9425a4163610ca9659061f0 100644 (file)
@@ -93,7 +93,9 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
   // --- See GEOMImpl_ProjectionDriver.cxx
 
   TopoDS_Shape aShape = aGuideLine->GetShape3D();
-  gp_Pnt P1(thePoint.X(), thePoint.Y(), 0); // plutot altitude moyenne
+  double middleZ = -9999;
+  aGuideLine->GetMiddleZ(middleZ); // use the middle Z value of the 3d line to help the projection.
+  gp_Pnt P1(thePoint.X(), thePoint.Y(), middleZ);
   TopoDS_Shape aPoint = BRepBuilderAPI_MakeVertex(P1).Shape();
 
   if (aPoint.IsNull() || aShape.IsNull())
@@ -235,34 +237,11 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c
               return aResAltitude;
             }
 
-//          aParam = (aParam - aF) / (aL - aF);
-//          aProj.SetU(aParam);
-//
-//          // Compute edge index.
-//          TopExp_Explorer anExp(aShape, TopAbs_EDGE);
-//          int anIndex = 0;
-//
-//          for (; anExp.More(); anExp.Next(), anIndex++)
-//            {
-//              if (aSupportShape.IsSame(anExp.Current()))
-//                {
-//                  aProj.SetIndex(anIndex);
-//                  break;
-//                }
-//            }
-//
-//          if (!anExp.More())
-//            {
-//              DEBTRACE("Projection aborted : Can't define edge index");
-//              return aResAltitude;
-//            }
-
           // Construct a projection vertex.
           const gp_Pnt &aPntProj = aDistShSh.PointOnShape2(i);
           TopoDS_Shape aProj = BRepBuilderAPI_MakeVertex(aPntProj).Shape();
           DEBTRACE("projection: (" << aPntProj.X() << ", " << aPntProj.Y() << ", " << aPntProj.Z() << ")");
-          return aPntProj.Z();
-          //aFunction->SetValue(aProj);
+          return aPntProj.Z() + 2.;
         }
     }
 
index 1ffc9cd5024489d17c60f9884dfbaa052c122788..fdd7e8fd9e741238ba5a98dc14ad28bb22bebe80 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <TopoDS_Shape.hxx>
 #include <TDataStd_Integer.hxx>
+#include <TDataStd_Real.hxx>
 
 #include <QColor>
 
@@ -120,6 +121,29 @@ void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
   checkAndSetObject3D();
 }
 
+Standard_Boolean HYDROData_Object::GetMiddleZ( Standard_Real& theMiddleZ ) const
+{
+  theMiddleZ = -9999;
+  TDF_Label aLabel = myLab.FindChild( DataTag_MiddleZ, false );
+  if ( !aLabel.IsNull() )
+  {
+    Handle(TDataStd_Real) aRealVal;
+    if ( aLabel.FindAttribute( TDataStd_Real::GetID(), aRealVal ) )
+    {
+      theMiddleZ = aRealVal->Get();
+      return Standard_True;
+    }
+  }
+
+  return Standard_False;
+
+}
+
+void HYDROData_Object::SetMiddleZ( const Standard_Real& theMiddleZ )
+{
+  TDataStd_Real::Set( myLab.FindChild( DataTag_MiddleZ ), theMiddleZ );
+}
+
 Handle(HYDROData_DummyObject3D) HYDROData_Object::GetObject3D() const
 {
   Handle(HYDROData_DummyObject3D) anObject;
index 520a70ab3515a41ea4d248f438fc6c70d821ae74..cd4cf20a4012983936c5f66f986bb384bfa46007 100644 (file)
@@ -50,6 +50,7 @@ protected:
     DataTag_EdgesGroup,          ///< child group objects
     DataTag_ChildAltitudeObject, ///< child altitude object
     DataTag_IsSubmersible,       ///< the attribute "is submersible"
+    DataTag_MiddleZ,             ///< middle Z value of Shape3D
   };
 
 public:
@@ -99,7 +100,16 @@ public:
    */
   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const = 0;
 
-  
+  /**
+   * Returns the middle z value of 3D object representation or -9999 if no value.
+   */
+  HYDRODATA_EXPORT virtual Standard_Boolean GetMiddleZ( Standard_Real& theMiddleZ ) const;
+
+  /**
+   * Set the middle z value of 3D object representation.
+   */
+  HYDRODATA_EXPORT virtual void SetMiddleZ( const Standard_Real& theMiddleZ );
+
   /**
    * Returns reference object which represent the 3D shape of object.
    */
index 67098e95e274235ccb83efbfa17e14121e35af3c..0ae2a44f78e3e65e919c0955940336a2db242c4d 100644 (file)
@@ -28,6 +28,9 @@
 
 #include <BRep_Tool.hxx>
 
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
+
 #include <Geom_BSplineCurve.hxx>
 
 #include <gp_Pnt2d.hxx>
@@ -207,6 +210,12 @@ void HYDROData_Polyline3D::Update()
   TopoDS_Wire aResWire = HYDROData_PolylineXY::BuildWire( aSectionType, anIsSectionClosed, aResPoints );
   SetTopShape( aResWire );
   SetShape3D( aResWire );
+
+  double Xmin=0, Xmax=0, Ymin=0, Ymax=0, Zmin=-9999, Zmax=-9999;
+  Bnd_Box B;
+  BRepBndLib::Add(aResWire, B);
+  B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
+  SetMiddleZ((Zmin+Zmax)/2.);
 } 
 
 QColor HYDROData_Polyline3D::DefaultFillingColor()