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>
30 PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints );
31 HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList );
35 class HYDROData_Bathymetry : HYDROData_Entity
38 %ConvertToSubClassCode
39 switch ( sipCpp->GetKind() )
42 sipClass = sipClass_HYDROData_Bathymetry;
46 // We don't recognise the type.
52 #include <HYDROData_Bathymetry.h>
57 PyObject* convertToPythonAltitudeList( const HYDROData_Bathymetry::AltitudePoints& thePoints )
59 int aListSize = thePoints.size();
61 PyObject* aPythonList = NULL;
62 if ( ( aPythonList = PyList_New( aListSize ) ) == NULL )
65 for ( int i = 0; i < aListSize; ++i )
67 const HYDROData_Bathymetry::AltitudePoint& aPoint = thePoints.at( i );
69 PyObject* aTypleObj = Py_BuildValue( "(ddd)", aPoint.X(), aPoint.Y(), aPoint.Z() );
71 PyList_SET_ITEM( aPythonList, i, aTypleObj );
77 HYDROData_Bathymetry::AltitudePoints convertFromPythonAltitudeList( PyObject* thePythonList )
79 HYDROData_Bathymetry::AltitudePoints aPoints;
80 if ( thePythonList == NULL )
83 for ( int i = 0, n = PyList_GET_SIZE( thePythonList ); i < n; ++i )
85 PyObject* aTypleObj = PyList_GET_ITEM( thePythonList, i );
88 if ( !PyArg_ParseTuple( aTypleObj, "ddd", &anArr[ 0 ], &anArr[ 1 ], &anArr[ 2 ] ) )
91 HYDROData_Bathymetry::AltitudePoint aPoint;
92 aPoint.SetX( anArr[ 0 ] );
93 aPoint.SetY( anArr[ 1 ] );
94 aPoint.SetZ( anArr[ 2 ] );
96 aPoints.append( aPoint );
105 // Public methods to work with Bathymetry altitudes.
108 * Returns altitude points list.
109 * \return points list
111 static double GetInvalidAltitude();
114 * Replace current altitude points by new one.
115 * \param thePoints the altitude points list
117 virtual void SetAltitudePoints( SIP_PYLIST ) [void (const HYDROData_Bathymetry::AltitudePoints&)] ;
120 // The C++ API takes a list of gp_XYZ objects,
121 // but we pass a list of python tuples.
123 HYDROData_Bathymetry::AltitudePoints aPoints =
124 convertFromPythonAltitudeList( a0 );
126 Py_BEGIN_ALLOW_THREADS
127 sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::SetAltitudePoints( aPoints ) :
128 sipCpp->SetAltitudePoints( aPoints );
134 PyObject* aPythonList = convertToPythonAltitudeList( a0 );
135 if ( aPythonList != NULL )
137 sipCallMethod( &sipIsErr, sipMethod, "O", aPythonList );
138 Py_DECREF( aPythonList );
144 * Returns altitude points list.
145 * \return points list
147 SIP_PYLIST GetAltitudePoints() const [HYDROData_Bathymetry::AltitudePoints ()] ;
150 // The C++ API returns a list of gp_XYZ objects,
151 // we convert it to list of python tuples.
153 HYDROData_Bathymetry::AltitudePoints aPoints;
155 Py_BEGIN_ALLOW_THREADS
156 aPoints = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudePoints() :
157 sipCpp->GetAltitudePoints();
160 sipRes = convertToPythonAltitudeList( aPoints );
164 * Remove all altitude points.
166 void RemoveAltitudePoints();
169 * Returns altitude for given point.
170 * \param thePoint the point to examine
171 * \return altitude value
173 double GetAltitudeForPoint( const QPointF& thePoint ) const;
177 // Public methods to work with files.
180 * Imports Bathymetry data from file. The supported file types:
182 * \param theFileName the path to file
183 * \return \c true if file has been successfully read
185 bool ImportFromFile( const QString& theFileName );
191 * Creates new object in the internal data structure. Use higher level objects
192 * to create objects with real content.
194 HYDROData_Bathymetry();
197 * Destructs properties of the object and object itself, removes it from the document.
199 ~HYDROData_Bathymetry();