]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
z interpolation parameter on Python script
authorPaul RASCLE <paul.rascle@edf.fr>
Fri, 29 Apr 2016 15:59:28 +0000 (17:59 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Fri, 29 Apr 2016 15:59:28 +0000 (17:59 +0200)
16 files changed:
src/HYDROData/HYDROData_AltitudeObject.cxx
src/HYDROData/HYDROData_AltitudeObject.h
src/HYDROData/HYDROData_Bathymetry.cxx
src/HYDROData/HYDROData_Bathymetry.h
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_ChannelAltitude.cxx
src/HYDROData/HYDROData_ChannelAltitude.h
src/HYDROData/HYDROData_IAltitudeObject.h
src/HYDROData/HYDROData_IInterpolator.cxx
src/HYDROData/HYDROData_ObstacleAltitude.cxx
src/HYDROData/HYDROData_ObstacleAltitude.h
src/HYDROData/HYDROData_StreamAltitude.cxx
src/HYDROData/HYDROData_StreamAltitude.h
src/HYDROPy/HYDROData_CalculationCase.sip
src/HYDROTools/interpolZ.py

index bec225593d196c76e2501db5be74c8098925fe63..0286c1e3d558fe02d3989aa47737406389185b73 100644 (file)
@@ -51,7 +51,8 @@ QStringList HYDROData_AltitudeObject::DumpToPython( const QString& thePyScriptPa
   return aResList;
 }
 
-double HYDROData_AltitudeObject::GetAltitudeForPoint( const gp_XY& thePoint ) const
+double HYDROData_AltitudeObject::GetAltitudeForPoint( const gp_XY& thePoint,
+                                                      int theMethod) const
 {
   DEBTRACE("HYDROData_AltitudeObject::GetAltitudeForPoint");
   double aResAltitude = GetInvalidAltitude();
index 3d10f39bf0b10031d3aa543413f906a96c097137..5770be48504fe109211d6ed8cccc9cb1074ddac3 100644 (file)
@@ -67,7 +67,8 @@ public:
    * \param thePoint the point to examine
    * \return altitude value
    */
-  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const;
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint,
+                                                                 int theMethod = 0) const;
 
 protected:
 
index 05fd27019719d4fcc325dc52627d28394b3f1116..34bd4a21d2c0dff8e6a939c9bbdaf48137852717 100644 (file)
@@ -350,9 +350,9 @@ bool interpolZtriangle(const gp_XY& point, vtkPolyData* delaunay2D, vtkIdList* t
   return false;
 }
 
-double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint) const
+double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint, int theMethod) const
 {
-  DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << ")");
+  DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << "), interpolation method: " << theMethod);
   double anInvalidAltitude = GetInvalidAltitude();
   double aResAltitude = anInvalidAltitude;
 
@@ -384,7 +384,9 @@ double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint) const
   //     - get the triangle containing the point in the Delaunay2D mesh,
   //     - interpolate altitude
 
-  bool isBathyInterpolRequired = true;
+  bool isBathyInterpolRequired = false;
+  if (theMethod)
+    isBathyInterpolRequired =true;
   if (isBathyInterpolRequired)
     {
       vtkPolyData* aDelaunay2D = GetVtkDelaunay2D();
index 1d4493b235c1deeac911c43ea6a8aa1987d3ac0c..6a555afdf39052c92054c6762d3db8803fcb7110 100644 (file)
@@ -101,9 +101,10 @@ public:
   /**
    * Returns altitude for given point.
    * \param thePoint the point to examine
+   * \param theMethod interpolation model, default 0 = nearest point
    * \return altitude value
    */
-  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const;
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint, int theMethod=0 ) const;
 
 public:
   // Public methods to work with files.
index 5aebfb76ec155690cb55adce63c95522d962bc31..78c2de6856e3c2f11592ace8fb0bce9a866fc68a 100644 (file)
@@ -719,7 +719,8 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) c
 }
 
 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&                    thePoint,
-                                                       const Handle(HYDROData_Region)& theRegion ) const
+                                                       const Handle(HYDROData_Region)& theRegion,
+                                                       int theMethod) const
 {
   double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
 
@@ -729,11 +730,11 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&
     //DEBTRACE("GetAltitudeForPoint Region " << theRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString());
     Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
     if ( IsEqual( aRefRegion, theRegion ) )
-      aResAltitude = GetAltitudeForPoint( thePoint, aZone );
+      aResAltitude = GetAltitudeForPoint( thePoint, aZone, theMethod );
     else
       {
         DEBTRACE("GetAltitudeForPoint Region " << aRefRegion->GetName().toStdString() << " Zone " << aZone->GetName().toStdString() << " ---------------------------");
-        aResAltitude = GetAltitudeForPoint( thePoint, aZone );
+        aResAltitude = GetAltitudeForPoint( thePoint, aZone, theMethod );
       }
   }
   else
@@ -745,7 +746,8 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&
 }
 
 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&                  thePoint,
-                                                       const Handle(HYDROData_Zone)& theZone ) const
+                                                       const Handle(HYDROData_Zone)& theZone,
+                                                       int theMethod) const
 {
   //DEBTRACE("GetAltitudeForPoint Zone " << theZone->GetName().toStdString());
   double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
@@ -814,7 +816,7 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&
       else
       {
        //DEBTRACE("aZoneInterpolator == NULL");
-        aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint );
+        aPointAltitude = anObjAltitude->GetAltitudeForPoint( thePoint, theMethod );
       }
 
       if ( ValuesEquals( aPointAltitude, HYDROData_IAltitudeObject::GetInvalidAltitude() ) )
@@ -849,16 +851,17 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&
 
 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints( 
   const NCollection_Sequence<gp_XY>& thePoints,
-  const Handle(HYDROData_Region)&    theRegion ) const
+  const Handle(HYDROData_Region)&    theRegion,
+  int theMethod) const
 {
-  //DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString());
+  DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString());
   NCollection_Sequence<double> aResSeq;
 
   for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
   {
     const gp_XY& thePnt = thePoints.Value( i );
     
-    double anAltitude = GetAltitudeForPoint( thePnt, theRegion );
+    double anAltitude = GetAltitudeForPoint( thePnt, theRegion, theMethod );
     aResSeq.Append( anAltitude );
   }
 
@@ -867,7 +870,8 @@ NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
 
 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints( 
   const NCollection_Sequence<gp_XY>& thePoints,
-  const Handle(HYDROData_Zone)&      theZone ) const
+  const Handle(HYDROData_Zone)&      theZone,
+  int theMethod) const
 {
   NCollection_Sequence<double> aResSeq;
 
@@ -875,7 +879,7 @@ NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
   {
     const gp_XY& thePnt = thePoints.Value( i );
     
-    double anAltitude = GetAltitudeForPoint( thePnt, theZone );
+    double anAltitude = GetAltitudeForPoint( thePnt, theZone, theMethod );
     aResSeq.Append( anAltitude );
   }
 
index 88f2c901abb59b7245b4ecd5f824ed30c6ef8308..1780ca9c682f246a4734398b3972a4acd3b39e08 100644 (file)
@@ -59,7 +59,7 @@ DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
 
 
 /**\class HYDROData_CalculationCase
- * \brief Calculation case is defined by selection of Geometry objects with or without \93Zone of water\94.
+ * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
  *
  */
 class HYDROData_CalculationCase : public HYDROData_Entity
@@ -313,7 +313,8 @@ public:
    * \return result altitude value
    */
   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                    thePoint,
-                                                       const Handle(HYDROData_Region)& theRegion ) const;
+                                                       const Handle(HYDROData_Region)& theRegion,
+                                                       int theMethod = 0) const;
 
   /**
    * Returns altitude for given point on given zone.
@@ -322,7 +323,8 @@ public:
    * \return result altitude value
    */
   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                  thePoint,
-                                                       const Handle(HYDROData_Zone)& theZone ) const;
+                                                       const Handle(HYDROData_Zone)& theZone,
+                                                       int theMethod = 0) const;
 
   /**
    * Returns strickler coefficient for given point.
@@ -339,7 +341,8 @@ public:
    */
   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
     const NCollection_Sequence<gp_XY>& thePoints,
-    const Handle(HYDROData_Region)&    theRegion ) const;
+    const Handle(HYDROData_Region)&    theRegion,
+    int theMethod = 0) const;
 
   /**
    * Returns altitudes for given points on given zone.
@@ -349,7 +352,8 @@ public:
    */
   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
     const NCollection_Sequence<gp_XY>& thePoints,
-    const Handle(HYDROData_Zone)&      theZone ) const;
+    const Handle(HYDROData_Zone)&      theZone,
+    int theMethod = 0) const;
 
   /**
    * Returns region to which the point is belongs.
index 413685f83f3ddbc4a8874ec8de21e856ee2d10c5..92d4d2fe7c9597ef543d069124532067126d0e66 100644 (file)
@@ -65,7 +65,8 @@ HYDROData_ChannelAltitude::~HYDROData_ChannelAltitude()
 {
 }
 
-double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) const
+double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
+                                                       int theMethod) const
 {
   DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << ")");
   double aResAltitude = GetInvalidAltitude();
index 0eb7b7016cd4dd33d90e4231d9881b0196f4215e..480e14fc3fea7ecd83492a012fa158e7b6d5afb1 100644 (file)
@@ -60,7 +60,8 @@ public:
    * \param thePoint the point to examine
    * \return altitude value
    */
-  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const;
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint,
+                                                                 int theMethod =0) const;
 
 protected:
 
index 50d65d9532070e494e75ba17dc5411977ffba5e7..a6d3658922e955cb9830c6c5e226f4cb6bddb13e 100644 (file)
@@ -65,7 +65,7 @@ public:
    * \param thePoint the point to examine
    * \return altitude value
    */
-  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const = 0;
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint, int theMethod=0 ) const = 0;
 
 
 protected:
index da40d5172b0f473029aa483b4095a10a21ef215a..2e3f3e878946b4d7c12b0d5d3f6de32652a7a45d 100644 (file)
@@ -48,7 +48,7 @@ double HYDROData_IInterpolator::GetAltitudeForPoint( const double theCoordX, con
          myAltitudeObject->GetAltitudeForPoint( gp_XY( theCoordX, theCoordY ) );
 }
 
-double HYDROData_IInterpolator::GetAltitudeForPoint( const gp_XY& thePoint ) const
+double HYDROData_IInterpolator::GetAltitudeForPoint( const gp_XY& thePoint) const
 {
   DEBTRACE("HYDROData_IInterpolator::GetAltitudeForPoint");
   return GetAltitudeForPoint( thePoint.X(), thePoint.Y() );
index a91e835968edd9402bfb5223371e7a5f551fde80..cba53dfa7e090ba1b7a5e720dd1094505bd80272 100644 (file)
@@ -43,7 +43,8 @@ HYDROData_ObstacleAltitude::~HYDROData_ObstacleAltitude()
 {
 }
 
-double HYDROData_ObstacleAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) const
+double HYDROData_ObstacleAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
+                                                        int theMethod) const
 {
   DEBTRACE("HYDROData_ObstacleAltitude::GetAltitudeForPoint");
   double aResAltitude = GetInvalidAltitude();
index ba95ba9b9288f5343c0ee3c17cd431854d7b482d..3dc1e2ceb8c11df381aced148e7d1c3f91847e4e 100644 (file)
@@ -60,7 +60,8 @@ public:
    * \param thePoint the point to examine
    * \return altitude value
    */
-  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const;
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint,
+                                                                 int theMethod = 0) const;
 
 protected:
 
index 4811380bd3c7c82f15aecbb85ee4db4fa344f9c8..d00d47c846d2dac6ae67b3d78766f27411b9b021 100644 (file)
@@ -281,7 +281,8 @@ bool HYDROData_StreamAltitude::getBoundaryWiresForPoint(
   return !theLeftWire.IsNull() && !theRightWire.IsNull();
 }
 
-double HYDROData_StreamAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) const
+double HYDROData_StreamAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
+                                                      int theMethod) const
 {
   DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << ")");
   double aResAltitude = GetInvalidAltitude();
index 02cbc3083d42ed54036a3aecd0fe171fe3bd7c91..77bf0b2afa8cb36769fa2c7f6b4c3e4d4912119b 100644 (file)
@@ -61,7 +61,8 @@ public:
    * \param thePoint the point to examine
    * \return altitude value
    */
-  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const;
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint,
+                                                                 int theMethod = 0) const;
 
 protected:
 
index d7cd159392c1c0d9cb9ab3325414ff1d236c78c0..cbca3857558b5e3cdb4e85a8e01ff02c4dc45ab6 100644 (file)
@@ -399,8 +399,9 @@ public:
    */
   NCollection_Sequence<double> GetAltitudesForPoints( const NCollection_Sequence<double>& theCoordsX,
                                                       const NCollection_Sequence<double>& theCoordsY,
-                                                      HYDROData_Region                    theRegion ) const
-  [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Region& )];
+                                                      HYDROData_Region                    theRegion,
+                                                      int                                 theMethod = 0) const
+  [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Region&, int)];
   %MethodCode
 
     NCollection_Sequence<gp_XY> aPnts;
@@ -414,11 +415,12 @@ public:
 
     Handle(HYDROData_Region) aRefRegion =
       Handle(HYDROData_Region)::DownCast( createHandle( a2 ) );
-
+    int aMethod = a3;
+    
     NCollection_Sequence<double> aRes;
     Py_BEGIN_ALLOW_THREADS
-    aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefRegion ) : 
-                           sipCpp->GetAltitudesForPoints( aPnts, aRefRegion );
+    aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefRegion, aMethod ) : 
+                           sipCpp->GetAltitudesForPoints( aPnts, aRefRegion, aMethod );
     Py_END_ALLOW_THREADS
     
     sipRes = new NCollection_Sequence<double>( aRes );
@@ -432,8 +434,9 @@ public:
    */
   NCollection_Sequence<double> GetAltitudesForPoints( const NCollection_Sequence<double>& theCoordsX,
                                                       const NCollection_Sequence<double>& theCoordsY,
-                                                      HYDROData_Zone                      theZone ) const
-  [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Zone& )];
+                                                      HYDROData_Zone                      theZone,
+                                                      int                                 theMethod = 0) const
+  [NCollection_Sequence<double> ( const NCollection_Sequence<gp_XY>&, const Handle_HYDROData_Zone&, int )];
   %MethodCode
 
     NCollection_Sequence<gp_XY> aPnts;
@@ -447,11 +450,12 @@ public:
 
     Handle(HYDROData_Zone) aRefZone =
       Handle(HYDROData_Zone)::DownCast( createHandle( a2 ) );
+    int aMethod = a3;
 
     NCollection_Sequence<double> aRes;
     Py_BEGIN_ALLOW_THREADS
-    aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefZone ) : 
-                           sipCpp->GetAltitudesForPoints( aPnts, aRefZone );
+    aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetAltitudesForPoints( aPnts, aRefZone, aMethod ) : 
+                           sipCpp->GetAltitudesForPoints( aPnts, aRefZone, aMethod );
     Py_END_ALLOW_THREADS
     
     sipRes = new NCollection_Sequence<double>( aRes );
index 268c0e350cf57ad4f65061f7b565d51340f4d2f0..93daf47ba89e217ad2e0f9da190e8466626f74db 100644 (file)
@@ -156,7 +156,7 @@ from salome.smesh import smeshBuilder
 
 smesh = smeshBuilder.New(theStudy)
 
-def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef):
+def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod = 0):
   """
   interpolZ takes a 2D (x,y) mesh and calls the active instance of module HYDRO
   to interpolate the bathymetry/altimetry on the mesh nodes, to produce the Z value of each node.
@@ -166,6 +166,7 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef):
   dicoGroupeRegion: python dictionary giving the coorespondance of mesh groups to HYDRO regions.
                     Key: face group name, value: region name in the HYDRO Case
   zUndef: Z value to use for nodes outside the regions (there must be none if the case is correct).
+  interpolMethod: integer value, default 0 = nearest point on bathymetry, 1 = linear interpolation
   return <fichierMaillage>Z.med : med file with Z value on nodes
   return <fichierMaillage>F.med : an exact copy of <fichierMaillage>Z.med
   """
@@ -220,7 +221,7 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef):
       #print xyz
       vx.append(xyz[0])
       vy.append(xyz[1])
-    vz = cas.GetAltitudesForPoints( vx, vy, region )
+    vz = cas.GetAltitudesForPoints( vx, vy, region, interpolMethod )
     minz = min(vz)
     maxz = max(vz)
     statz[grp.GetName()] = (minz, maxz)