Salome HOME
Cascade ascii string added for SIP.
[modules/hydro.git] / src / HYDROPy / HYDROData_Bathymetry.sip
index 8666ba56f60e203520e7a1469649e20a79aab00c..349318a679dc1e316f2b02630aed237344d01356 100644 (file)
 
 %ExportedHeaderCode
 #include <HYDROData_Bathymetry.h>
-#include <gp_XYZ.hxx>
 %End
 
-%ModuleCode
-
-PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints );
-HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList );
-
-%End
-
-class HYDROData_Bathymetry : HYDROData_Object
+class HYDROData_Bathymetry : HYDROData_IAltitudeObject
 {
 
+  typedef gp_XYZ                       AltitudePoint;
+  typedef NCollection_Sequence<gp_XYZ> AltitudePoints;
+
 %ConvertToSubClassCode
-    if ( !Handle(HYDROData_Bathymetry)::DownCast( sipCpp ).IsNull() )
-      sipClass = sipClass_HYDROData_Bathymetry;
-    else
-      sipClass = NULL;
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_BATHYMETRY:
+        sipClass = sipClass_HYDROData_Bathymetry;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
 %End
 
 %TypeHeaderCode
 #include <HYDROData_Bathymetry.h>
 %End
 
-%TypeCode
-
-PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints )
-{ 
-  int aListSize = thePoints.size();
-
-  PyObject* aPythonList = NULL;
-  if ( ( aPythonList = PyList_New( aListSize ) ) == NULL )
-    return NULL;
-        
-  for ( int i = 0; i < aListSize; ++i )
-  {
-    const HYDROData_Bathymetry::AltitudePoint& aPoint = thePoints.at( i );
-
-    PyObject* aTypleObj = Py_BuildValue( "(ddd)", aPoint.X(), aPoint.Y(), aPoint.Z() );
-
-    PyList_SET_ITEM( aPythonList, i, aTypleObj );
-  }
-
-  return aPythonList;
-}
-
-HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList )
-{ 
-  HYDROData_Bathymetry::AltitudePoints aPoints;
-  if ( thePythonList == NULL )
-    return aPoints;
-
-  for ( int i = 0, n = PyList_GET_SIZE( thePythonList ); i < n; ++i )
-  {
-    PyObject* aTypleObj = PyList_GET_ITEM( thePythonList, i );
-
-    double anArr[ 3 ];
-    if ( !PyArg_ParseTuple( aTypleObj, "ddd", &anArr[ 0 ], &anArr[ 1 ], &anArr[ 2 ] ) )
-      continue;
-
-    HYDROData_Bathymetry::AltitudePoint aPoint;
-    aPoint.SetX( anArr[ 0 ] );
-    aPoint.SetY( anArr[ 1 ] );
-    aPoint.SetZ( anArr[ 2 ] );
-
-    aPoints.append( aPoint );
-  }
-  
-  return aPoints;
-}
-
-%End
-
-
-public:
-
-  const ObjectKind          GetKind() const;
-
-
 public:      
   // Public methods to work with Bathymetry altitudes.
 
   /**
-   * Returns altitude points list.
-   * \return points list
+   * Returns altitude for given point.
+   * \param thePoint the point to examine
+   * \return altitude value
    */
-  static double             GetInvalidAltitude();
+  double           GetAltitudeForPoint( const gp_XY& thePoint );
 
   /**
    * Replace current altitude points by new one.
    * \param thePoints the altitude points list
    */
-  virtual void             SetAltitudePoints( SIP_PYLIST ) [void (const HYDROData_Bathymetry::AltitudePoints&)] ;
-  %MethodCode
-  
-    // The C++ API takes a list of gp_XYZ objects,
-    // but we pass a list of python tuples.
-
-    HYDROData_Bathymetry::AltitudePoints aPoints =
-      convertFromPythonAltitudeList( a0 );
-
-    Py_BEGIN_ALLOW_THREADS
-    sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::SetAltitudePoints( aPoints ) : 
-                    sipCpp->SetAltitudePoints( aPoints );
-    Py_END_ALLOW_THREADS
-
-  %End
-  %VirtualCatcherCode
-  
-    PyObject* aPythonList = convertToPythonAltitudeList( a0 );
-    if ( aPythonList != NULL )
-    {
-      sipCallMethod( &sipIsErr, sipMethod, "O", aPythonList );
-      Py_DECREF( aPythonList );
-    }
-    
-  %End
+  virtual void             SetAltitudePoints( const HYDROData_Bathymetry::AltitudePoints& );
 
   /**
    * Returns altitude points list.
    * \return points list
    */
-  SIP_PYLIST GetAltitudePoints() const [HYDROData_Bathymetry::AltitudePoints ()] ;
-  %MethodCode
-  
-    // The C++ API returns a list of gp_XYZ objects,
-    // we convert it to list of python tuples.
-
-    HYDROData_Bathymetry::AltitudePoints aPoints;
-    
-    Py_BEGIN_ALLOW_THREADS
-    aPoints = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudePoints() : 
-                              sipCpp->GetAltitudePoints();
-    Py_END_ALLOW_THREADS
-
-    sipRes = convertToPythonAltitudeList( aPoints );
-    
-  %End
+  HYDROData_Bathymetry::AltitudePoints GetAltitudePoints() const;
+
   /**
    * Remove all altitude points.
    */
   void              RemoveAltitudePoints();
 
-  /**
-   * Returns altitude for given point.
-   * \param thePoint the point to examine
-   * \return altitude value
-   */
-  double           GetAltitudeForPoint( const QPointF& thePoint ) const;
-
 
 public:
   // Public methods to work with files.
@@ -182,7 +84,7 @@ public:
    * \param theFileName the path to file
    * \return \c true if file has been successfully read
    */
-  bool             ImportFromFile( const QString& theFileName );
+  bool             ImportFromFile( const TCollection_AsciiString& theFileName );
 
 
 protected: