1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include <HYDROData_Bathymetry.h>
33 PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints );
34 HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList );
38 class HYDROData_Bathymetry : HYDROData_Object
41 %ConvertToSubClassCode
42 if ( !Handle(HYDROData_Bathymetry)::DownCast( sipCpp ).IsNull() )
43 sipClass = sipClass_HYDROData_Bathymetry;
49 #include <HYDROData_Bathymetry.h>
54 PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints )
56 int aListSize = thePoints.size();
58 PyObject* aPythonList = NULL;
59 if ( ( aPythonList = PyList_New( aListSize ) ) == NULL )
62 for ( int i = 0; i < aListSize; ++i )
64 const HYDROData_Bathymetry::AltitudePoint& aPoint = thePoints.at( i );
66 PyObject* aTypleObj = Py_BuildValue( "(ddd)", aPoint.X(), aPoint.Y(), aPoint.Z() );
68 PyList_SET_ITEM( aPythonList, i, aTypleObj );
74 HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList )
76 HYDROData_Bathymetry::AltitudePoints aPoints;
77 if ( thePythonList == NULL )
80 for ( int i = 0, n = PyList_GET_SIZE( thePythonList ); i < n; ++i )
82 PyObject* aTypleObj = PyList_GET_ITEM( thePythonList, i );
85 if ( !PyArg_ParseTuple( aTypleObj, "ddd", &anArr[ 0 ], &anArr[ 1 ], &anArr[ 2 ] ) )
88 HYDROData_Bathymetry::AltitudePoint aPoint;
89 aPoint.SetX( anArr[ 0 ] );
90 aPoint.SetY( anArr[ 1 ] );
91 aPoint.SetZ( anArr[ 2 ] );
93 aPoints.append( aPoint );
104 //virtual const ObjectKind GetKind() const { return KIND_BATHYMETRY; }
108 // Public methods to work with Bathymetry altitudes.
111 * Returns altitude points list.
112 * \return points list
114 static double GetInvalidAltitude();
117 * Replace current altitude points by new one.
118 * \param thePoints the altitude points list
120 virtual void SetAltitudePoints( SIP_PYLIST ) [void (const HYDROData_Bathymetry::AltitudePoints&)] ;
123 // The C++ API takes a list of gp_XYZ objects,
124 // but we pass a list of python tuples.
126 HYDROData_Bathymetry::AltitudePoints aPoints =
127 convertFromPythonAltitudeList( a0 );
129 Py_BEGIN_ALLOW_THREADS
130 sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::SetAltitudePoints( aPoints ) :
131 sipCpp->SetAltitudePoints( aPoints );
137 PyObject* aPythonList = convertToPythonAltitudeList( a0 );
138 if ( aPythonList != NULL )
140 sipCallMethod( &sipIsErr, sipMethod, "O", aPythonList );
141 Py_DECREF( aPythonList );
147 * Returns altitude points list.
148 * \return points list
150 SIP_PYLIST GetAltitudePoints() const [HYDROData_Bathymetry::AltitudePoints ()] ;
153 // The C++ API returns a list of gp_XYZ objects,
154 // we convert it to list of python tuples.
156 HYDROData_Bathymetry::AltitudePoints aPoints;
158 Py_BEGIN_ALLOW_THREADS
159 aPoints = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudePoints() : sipCpp->GetAltitudePoints();
162 sipRes = convertToPythonAltitudeList( aPoints );
166 * Remove all altitude points.
168 void RemoveAltitudePoints();
171 * Returns altitude for given point.
172 * \param thePoint the point to examine
173 * \return altitude value
175 double GetAltitudeForPoint( const QPointF& thePoint ) const;
179 // Public methods to work with files.
182 * Imports Bathymetry data from file. The supported file types:
184 * \param theFileName the path to file
185 * \return \c true if file has been successfully read
187 bool ImportFromFile( const QString& theFileName );
192 //friend class HYDROData_Iterator;
195 * Creates new object in the internal data structure. Use higher level objects
196 * to create objects with real content.
198 HYDROData_Bathymetry();
201 * Destructs properties of the object and object itself, removes it from the document.
203 ~HYDROData_Bathymetry();