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
24 #include <HYDROData_Bathymetry.h>
31 PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints );
32 HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList );
36 class HYDROData_Bathymetry : HYDROData_Entity
39 %ConvertToSubClassCode
40 switch ( sipCpp->GetKind() )
43 sipClass = sipClass_HYDROData_Bathymetry;
47 // We don't recognise the type.
53 #include <HYDROData_Bathymetry.h>
58 PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints )
60 int aListSize = thePoints.size();
62 PyObject* aPythonList = NULL;
63 if ( ( aPythonList = PyList_New( aListSize ) ) == NULL )
66 for ( int i = 0; i < aListSize; ++i )
68 const HYDROData_Bathymetry::AltitudePoint& aPoint = thePoints.at( i );
70 PyObject* aTypleObj = Py_BuildValue( "(ddd)", aPoint.X(), aPoint.Y(), aPoint.Z() );
72 PyList_SET_ITEM( aPythonList, i, aTypleObj );
78 HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList )
80 HYDROData_Bathymetry::AltitudePoints aPoints;
81 if ( thePythonList == NULL )
84 for ( int i = 0, n = PyList_GET_SIZE( thePythonList ); i < n; ++i )
86 PyObject* aTypleObj = PyList_GET_ITEM( thePythonList, i );
89 if ( !PyArg_ParseTuple( aTypleObj, "ddd", &anArr[ 0 ], &anArr[ 1 ], &anArr[ 2 ] ) )
92 HYDROData_Bathymetry::AltitudePoint aPoint;
93 aPoint.SetX( anArr[ 0 ] );
94 aPoint.SetY( anArr[ 1 ] );
95 aPoint.SetZ( anArr[ 2 ] );
97 aPoints.append( aPoint );
106 // Public methods to work with Bathymetry altitudes.
109 * Returns altitude points list.
110 * \return points list
112 static double GetInvalidAltitude();
115 * Replace current altitude points by new one.
116 * \param thePoints the altitude points list
118 virtual void SetAltitudePoints( SIP_PYLIST ) [void (const HYDROData_Bathymetry::AltitudePoints&)] ;
121 // The C++ API takes a list of gp_XYZ objects,
122 // but we pass a list of python tuples.
124 HYDROData_Bathymetry::AltitudePoints aPoints =
125 convertFromPythonAltitudeList( a0 );
127 Py_BEGIN_ALLOW_THREADS
128 sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::SetAltitudePoints( aPoints ) :
129 sipCpp->SetAltitudePoints( aPoints );
135 PyObject* aPythonList = convertToPythonAltitudeList( a0 );
136 if ( aPythonList != NULL )
138 sipCallMethod( &sipIsErr, sipMethod, "O", aPythonList );
139 Py_DECREF( aPythonList );
145 * Returns altitude points list.
146 * \return points list
148 SIP_PYLIST GetAltitudePoints() const [HYDROData_Bathymetry::AltitudePoints ()] ;
151 // The C++ API returns a list of gp_XYZ objects,
152 // we convert it to list of python tuples.
154 HYDROData_Bathymetry::AltitudePoints aPoints;
156 Py_BEGIN_ALLOW_THREADS
157 aPoints = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudePoints() :
158 sipCpp->GetAltitudePoints();
161 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;
178 // The C++ API gets the gp_XY object, we convert it from QPointF.
179 gp_XY aPoint( a0->x(), a0->y() );
181 Py_BEGIN_ALLOW_THREADS
182 sipRes = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudeForPoint( aPoint ) :
183 sipCpp->GetAltitudeForPoint( aPoint );
189 // Public methods to work with files.
192 * Imports Bathymetry data from file. The supported file types:
194 * \param theFileName the path to file
195 * \return \c true if file has been successfully read
197 bool ImportFromFile( const QString& theFileName );
203 * Creates new object in the internal data structure. Use higher level objects
204 * to create objects with real content.
206 HYDROData_Bathymetry();
209 * Destructs properties of the object and object itself, removes it from the document.
211 ~HYDROData_Bathymetry();