From 6d184db62d1e8d53ee376d54369ef95993ce1d4d Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Thu, 27 Aug 2020 15:55:46 +0200 Subject: [PATCH] Python wrapping for HYDROData_PolylineOperator (split, merge) --- src/HYDROPy/CMakeLists.txt | 1 + src/HYDROPy/HYDROData.sip | 1 + src/HYDROPy/HYDROData_PolylineOperator.sip | 96 ++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 src/HYDROPy/HYDROData_PolylineOperator.sip diff --git a/src/HYDROPy/CMakeLists.txt b/src/HYDROPy/CMakeLists.txt index b6f3fade..866baef2 100644 --- a/src/HYDROPy/CMakeLists.txt +++ b/src/HYDROPy/CMakeLists.txt @@ -54,6 +54,7 @@ SET(_add_SOURCES sipHYDROPyHYDROData_Obstacle.cc sipHYDROPyHYDROData_Polyline3D.cc sipHYDROPyHYDROData_PolylineXY.cc + sipHYDROPyHYDROData_PolylineOperator.cc sipHYDROPyHYDROData_Profile.cc sipHYDROPyHYDROData_ProfileUZ.cc sipHYDROPyHYDROData_Region.cc diff --git a/src/HYDROPy/HYDROData.sip b/src/HYDROPy/HYDROData.sip index 0c6c993d..20643fe7 100644 --- a/src/HYDROPy/HYDROData.sip +++ b/src/HYDROPy/HYDROData.sip @@ -71,6 +71,7 @@ %Include HYDROData_Obstacle.sip %Include HYDROData_ObstacleAltitude.sip %Include HYDROData_PolylineXY.sip +%Include HYDROData_PolylineOperator.sip %Include HYDROData_Polyline3D.sip %Include HYDROData_Profile.sip %Include HYDROData_ProfileUZ.sip diff --git a/src/HYDROPy/HYDROData_PolylineOperator.sip b/src/HYDROPy/HYDROData_PolylineOperator.sip new file mode 100644 index 00000000..90ab42be --- /dev/null +++ b/src/HYDROPy/HYDROData_PolylineOperator.sip @@ -0,0 +1,96 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +%ExportedHeaderCode +#include +%End + +class HYDROData_PolylineOperator +{ + +%TypeHeaderCode +#include +%End + +public: + + HYDROData_PolylineOperator(); + + ~HYDROData_PolylineOperator(); + + bool Split( HYDROData_Document theDoc, + HYDROData_PolylineXY thePolyline, + double x, double y, + double theTolerance ) const + [bool (opencascade::handle&, opencascade::handle&, const gp_Pnt2d&, double)]; + %MethodCode + Handle(HYDROData_PolylineXY) aPoly = Handle(HYDROData_PolylineXY)::DownCast( createHandle( a1 ) ); + gp_Pnt2d aPnt( a2, a3 ); + if ( !aPoly.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::Split( a0, aPoly, aPnt, a4 ): + sipCpp->Split( a0, aPoly, aPnt, a4 ); + Py_END_ALLOW_THREADS + } + %End + + bool Split( HYDROData_Document theDoc, + HYDROData_PolylineXY thePolyline, + HYDROData_PolylineXY theTool, + double theTolerance, + bool& theIsIntersected) const + [bool (opencascade::handle&, opencascade::handle&, opencascade::handle&, double, bool&)]; + %MethodCode + Handle(HYDROData_PolylineXY) aPoly = Handle(HYDROData_PolylineXY)::DownCast( createHandle( a1 ) ); + Handle(HYDROData_PolylineXY) aTool = Handle(HYDROData_PolylineXY)::DownCast( createHandle( a2 ) ); + if ( !aPoly.IsNull() && !aTool.IsNull()) + { + Py_BEGIN_ALLOW_THREADS + sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::Split( a0, aPoly, aTool, a3, a4 ): + sipCpp->Split( a0, aPoly, aTool, a3, a4 ); + Py_END_ALLOW_THREADS + } + %End + + bool Split( HYDROData_Document theDoc, + const HYDROData_SequenceOfObjects& thePolylines, + double theTolerance ) + [bool (opencascade::handle&, const HYDROData_SequenceOfObjects&, double)]; + %MethodCode + Py_BEGIN_ALLOW_THREADS + sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::Split( a0, *a1, a2): + sipCpp->Split( a0, *a1, a2); + Py_END_ALLOW_THREADS + %End + + bool Merge( HYDROData_Document theDoc, + const QString& theName, + const HYDROData_SequenceOfObjects& thePolylines, + bool isConnectByNewSegment, + double theTolerance ) + [bool (opencascade::handle&, const QString&, const HYDROData_SequenceOfObjects&, bool, double)]; + %MethodCode + Py_BEGIN_ALLOW_THREADS + sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::Merge( a0, *a1, *a2, a3, a4): + sipCpp->Merge( a0, *a1, *a2, a3, a4); + Py_END_ALLOW_THREADS + %End +}; + + -- 2.39.2