From 166b635309c21c9868887ca6caa65f31d2ba06e9 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Sun, 29 Nov 2020 22:19:33 +0100 Subject: [PATCH] test h034 on split polylines --- doc/salome/examples/CMakeLists.txt | 9 +++ .../examples/CTestTestfileInstall.cmake | 1 + doc/salome/examples/contour.shp | Bin 0 -> 236 bytes doc/salome/examples/contour.shx | Bin 0 -> 108 bytes doc/salome/examples/h034_splitShapes.py | 54 ++++++++++++++++ doc/salome/examples/lm2.shp | Bin 0 -> 540 bytes doc/salome/examples/lm2.shx | Bin 0 -> 108 bytes doc/salome/examples/lmajeur.shp | Bin 0 -> 332 bytes doc/salome/examples/lmajeur.shx | Bin 0 -> 108 bytes doc/salome/examples/openPoly.shp | Bin 0 -> 588 bytes doc/salome/examples/openPoly.shx | Bin 0 -> 108 bytes doc/salome/examples/testsplit.shp | Bin 0 -> 1396 bytes doc/salome/examples/testsplit.shx | Bin 0 -> 132 bytes src/HYDROData/HYDROData_PolylineOperator.cxx | 24 ++++---- src/HYDROData/HYDROData_PolylineOperator.h | 24 ++++---- src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx | 6 +- src/HYDROPy/HYDROData_PolylineOperator.sip | 58 +++++++++++------- src/HYDROTools/hydroGeoMeshUtils.py | 40 ++++++++++++ src/HYDRO_tests/test_HYDROData_PolylineXY.cxx | 6 +- 19 files changed, 171 insertions(+), 51 deletions(-) create mode 100644 doc/salome/examples/contour.shp create mode 100644 doc/salome/examples/contour.shx create mode 100644 doc/salome/examples/h034_splitShapes.py create mode 100644 doc/salome/examples/lm2.shp create mode 100644 doc/salome/examples/lm2.shx create mode 100644 doc/salome/examples/lmajeur.shp create mode 100644 doc/salome/examples/lmajeur.shx create mode 100644 doc/salome/examples/openPoly.shp create mode 100644 doc/salome/examples/openPoly.shx create mode 100644 doc/salome/examples/testsplit.shp create mode 100644 doc/salome/examples/testsplit.shx diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 7b38f76f..f67ef7f0 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -56,6 +56,7 @@ SET(EXAMPLES_TESTS h031_interpolationLineaireStream.py h032_completeCaseNoRegions.py h033_completeCaseModifiedRegions.py + h034_splitShapes.py ) SET(HYDRO_SAMPLES @@ -69,6 +70,8 @@ SET(HYDRO_SAMPLES constraint1.shx constraint2.shp constraint2.shx + contour.shp + contour.shx coupeDomaineAmontChevauchant.shp coupeDomaineAmontChevauchant.shx domaine.shp @@ -99,8 +102,14 @@ SET(HYDRO_SAMPLES jonction_5_2.shx lit_majeur.shp lit_majeur.shx + lm2.shp + lm2.shx + lmajeur.shp + lmajeur.shx nouvelleDigue.shp nouvelleDigue.shx + openPoly.shp + openPoly.shx raccord_4_1.shp raccord_4_1.shx raccord_4_2.shp diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake index 1eabdb2b..1446fb74 100644 --- a/doc/salome/examples/CTestTestfileInstall.cmake +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -58,6 +58,7 @@ SET(EXAMPLES_TESTS h031_interpolationLineaireStream h032_completeCaseNoRegions h033_completeCaseModifiedRegions + h034_splitShapes ) FOREACH(tfile ${EXAMPLES_TESTS}) diff --git a/doc/salome/examples/contour.shp b/doc/salome/examples/contour.shp new file mode 100644 index 0000000000000000000000000000000000000000..5d6586a6f1ffa4ff881a1cde72275c1566296386 GIT binary patch literal 236 zcmZQzQ0HR64$59IGcW)V1Cw^Un4Xi2W39dEyx-mtjv)RNMmfh>GiPqRoEYJVT|0^> zBar7nj9DOstWd2mdxe@0bV-CoI6l3g6y5kv25v9R9Rd-SN6rG}4}aCTGiPqRoEYJVT|0`X I5s>Eq0Ll3b)c^nh literal 0 HcmV?d00001 diff --git a/doc/salome/examples/h034_splitShapes.py b/doc/salome/examples/h034_splitShapes.py new file mode 100644 index 00000000..38fa162e --- /dev/null +++ b/doc/salome/examples/h034_splitShapes.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +import os +HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO") +HYDRO_TEST_RESOURCES = os.path.join(os.environ["HYDRO_DIR"], "bin", "salome", "test", "tmp_test") + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) + +# ---------------------------------------------------------------------------------- +# --- domain extension + +import sys +import salome + +salome.salome_init() + +offsetX = 430000. +offsetY = 6350000. + +#---------------------- +# --- HYDRO +#---------------------- + +from HYDROPy import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * + +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, splitShapesAll + +hydro_doc = HYDROData_Document.Document() +hydro_doc.SetLocalCS( offsetX, offsetY ) + +contours = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "contour.shp"), 'contour_PolyXY', False, 0) +lmajeurs = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lmajeur.shp"), 'lmajeur_PolyXY', True, 0) +lm2s = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lm2.shp"), 'lm2_PolyXY', True, 0) +openPolys = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "openPoly.shp"), 'openPoly_PolyXY', False, 0) + +seq = contours + lmajeurs +shapeList = splitShapesAll(hydro_doc, seq) +if len(shapeList) != 8: + raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 8"%len(shapeList)) +seq2 = contours + lm2s +shapeList2 = splitShapesAll(hydro_doc, seq2) +if len(shapeList2) != 16: + raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 16"%len(shapeList2)) +seq3 = contours + lm2s + lmajeurs + openPolys +shapeList3 = splitShapesAll(hydro_doc, seq3) +if len(shapeList3) != 89: + raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 89"%len(shapeList3)) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser() diff --git a/doc/salome/examples/lm2.shp b/doc/salome/examples/lm2.shp new file mode 100644 index 0000000000000000000000000000000000000000..6c8efd90d64f34daae339ae8f0ddc9b9d4f91ccd GIT binary patch literal 540 zcmZQzQ0HR63K;obFf%X!5yKVk)eCo-$vBFoyw$qz8R2N@v}YFMV_Cp3F>^bxhn){ZkL<9|MN%d#Y#2I-aiK zj*A2O=U>6nQ&W%0IvTQdnQ+HOIBHc*Sx`0`;lF2T6`xwnWF2oLzxpR16XB?rE0|{U yNXF4f`@`wrhzQ4|hfb|eCdfGIoHBNw4h+9vUQx2*VKR=4Yvt|R10x*K!y5q7qrCJ0 literal 0 HcmV?d00001 diff --git a/doc/salome/examples/lm2.shx b/doc/salome/examples/lm2.shx new file mode 100644 index 0000000000000000000000000000000000000000..421e87d2dfb527ea08de97851cdf785d3b7031d2 GIT binary patch literal 108 zcmZQzQ0HR64$NLKGcW)V!xiq;3wN2xIEtmb)w=H);b`f!XBOjQS;wyC!FFaJ=lBB#^XA*74w}g{^K05suik zqlhvBc?HCn1yaZj)e5uMZQEzv-LVmlXV08DQ(q|Km?RLfu`e>h@!yq-%vDci9E&q1 zt~CyeaNJOoG4Z9HtmBpwWpdYiBOH$^Z1}XIQWnGAKY|~(E((ZnT;#f~m}RT1v-_g!dAD02uJMN KQACY^yaE6suMS@T literal 0 HcmV?d00001 diff --git a/doc/salome/examples/openPoly.shp b/doc/salome/examples/openPoly.shp new file mode 100644 index 0000000000000000000000000000000000000000..c458f4fb656efd9fde68fc121109fb94742a3c51 GIT binary patch literal 588 zcmZQzQ0HR63K-R1Ff%X!5yO)|{Os-gGL9Q=<%JlzML2dYwc20vN7hj*nz3y0vw*5~)$n-m@4_+|F5sTYpQz}@-h?*HO2K3T_t3G;tG zOpI_0U31{!3`SYUYl4pgUo*j%P~)_WA?; zsZ}*)LD_6s$I!Xe3SvP0Hw?e|SuU4#WA{-Cy$~&8WUe@u>=|q*+VG)juVMo7*FO+o*IXNdHH#ovkPkMU)&i%5E6QXkW z1^Gufrg*O|c(h&Ck^kN)zFS@qj-QM6YW17QI*O&d)w=H);plwL+Mml$)-is&*(_UM zpn3I7$uo_B=6^W8+c+q~(S1Sn%06aUM^zU=?Mb1C@Hq5$@uT#>2*-jWUO{XB$~gYe z-EnvV(7e;-+HW_WM#S?kuP9mZFd4@whn_r^1={ca>1(~9nv7%M>W_)WK=;AYh0FqH IiD00807%T%bN~PV literal 0 HcmV?d00001 diff --git a/doc/salome/examples/openPoly.shx b/doc/salome/examples/openPoly.shx new file mode 100644 index 0000000000000000000000000000000000000000..d9c9a297ca179c225e0f1a0e3502b2c43ec66dae GIT binary patch literal 108 zcmZQzQ0HR64$NLKGcW)V!;?S!?CtzAjvH>}g&4U-ICd_z+F$cW)=?{(v2kxwgd=wC KD56F{-Uk3!Di3-9 literal 0 HcmV?d00001 diff --git a/doc/salome/examples/testsplit.shp b/doc/salome/examples/testsplit.shp new file mode 100644 index 0000000000000000000000000000000000000000..68b9206e5d0f385767738d66dada2fea3be0ffea GIT binary patch literal 1396 zcmZux3s6*L6y8O^f`Nr53FH5PVbB~lmtYNth~OYD%2QZaejf2|At#(o3Q%ZJ6iF-v zS_gLt1sq6)&811nMFNHO!9u7wwmBpM3#AUkBMT9z|4v>Q$$##-Gxy%}_|Es8b2*$h z%s4MRMw;JOa5(hh80L5@i+KptcXvd(iwGF;i*4jwdvJ;4?rlvW@WSxtUvlZAFO!Rj z75E|e%;)XnPlJ|nDHV#QzGMQ7qsg;a*7uct?IpGn0wXt^;`WXsV0~E}R>ZTjhkoyP zyskflgP+UI)MDeA^3-Guj;lc%Up_8GU@Wm5(NG+HAt_cV8Vr}ZYKlZj|KTuyhJ*DL zou6Lc@;-r{?(Xh_j}fF;k*32j1Qu@Ret2dCK~_eYN=R|2cV?75cn`z(*Rt*Jgb>g= zs;5rv!vCu^BOWfQ-A15x^Z6{}a~R6T^8Z*PCLoncN2il8jOY7U*vArZD0+0W@;ZVu zlechvA_23XPfmr3v`dUN0xDP|j{V%>fMmc7&#F$KP9*iRp z<9y%)r5uB(HQF&Xioh!C?ailLF=&0y$sSUkbUFO7CLMwfC$rt^U;=Zd-UAgUmU_F^ zvW4$fh(KogWl~olfzHX7ZZ>u!;9W?|DGMVI?>;mKYZ3%pm4i=lIDzGSQwfZzO)$DG z-?@Wz@3iI5;l-U}bhD$zoI`>zg+D@|iLi5hJ(@szL*YP%2m!yY=WHnLqd1M{(=J7j z(ZQH||`$G8|$ zPq!0Cs_X2`fJiRHAn3@g|D5t->Sz+tFTv3B>9*D|I#Vo9QB`@4HZ)%E_E)IqHyA7e z-J6=J|6(tD(rrx>=spd8r9V4`L4EMI{pFOmOPU=$>Ae{Gb;-_;s4iTI_V4H#43XEr zCYf|U1a=iiF0^4Njm`Wqg6f(U)F2yb#=yJRWqFtCKE1Qm<;VuSIP;tCc!imTVn}TE zP{K=tos*|iUFhVttU}pUf s9i?=K*g0hXhpevh%Z6c0>jz9dF0fvUAiQBRSxE7*TB7PrwqjcEU(!kkYXATM literal 0 HcmV?d00001 diff --git a/doc/salome/examples/testsplit.shx b/doc/salome/examples/testsplit.shx new file mode 100644 index 0000000000000000000000000000000000000000..ae03938aa71811760711e15d09de2d3bb327f251 GIT binary patch literal 132 zcmZQzQ0HR64xC;vGcW)V!;?S!?CtzAjvH>}g&4U-I5KIsi%nsabJU7vY}}g^;fP&3 bil`Bg=K#cIKwJRCuYmXl0|VnRApHRVJADxL literal 0 HcmV?d00001 diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index 01537030..3f139058 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -71,10 +71,10 @@ template void append( std::vector& theList, const std::vector& th theList[i] = theList2[j]; } -bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc, - const Handle( HYDROData_PolylineXY )& thePolyline, - const gp_Pnt2d& thePoint, - double theTolerance ) const +bool HYDROData_PolylineOperator::SplitPoint( const Handle( HYDROData_Document )& theDoc, + const Handle( HYDROData_PolylineXY )& thePolyline, + const gp_Pnt2d& thePoint, + double theTolerance ) const { if (thePolyline.IsNull()) { @@ -123,11 +123,11 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD return isOK; } -bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc, - const Handle( HYDROData_PolylineXY )& thePolyline, - const Handle( HYDROData_PolylineXY )& theTool, - double theTolerance, - bool& theIsIntersected) const +bool HYDROData_PolylineOperator::SplitTool( const Handle( HYDROData_Document )& theDoc, + const Handle( HYDROData_PolylineXY )& thePolyline, + const Handle( HYDROData_PolylineXY )& theTool, + double theTolerance, + bool& theIsIntersected) const { if (thePolyline.IsNull() || theTool.IsNull()) { @@ -139,9 +139,9 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD return split( theDoc, thePolyline, aSeq, theTolerance, -1, theIsIntersected); } -bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc, - const HYDROData_SequenceOfObjects& thePolylines, - double theTolerance ) +bool HYDROData_PolylineOperator::SplitAll( const Handle( HYDROData_Document )& theDoc, + const HYDROData_SequenceOfObjects& thePolylines, + double theTolerance ) { int f = thePolylines.Lower(), l = thePolylines.Upper(); for( int i=f; i<=l; i++ ) diff --git a/src/HYDROData/HYDROData_PolylineOperator.h b/src/HYDROData/HYDROData_PolylineOperator.h index ff64142a..e8f8d1be 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.h +++ b/src/HYDROData/HYDROData_PolylineOperator.h @@ -32,18 +32,18 @@ class HYDROData_Object; class HYDRODATA_EXPORT HYDROData_PolylineOperator { public: - bool Split( const Handle( HYDROData_Document )& theDoc, - const Handle( HYDROData_PolylineXY )& thePolyline, - const gp_Pnt2d& thePoint, - double theTolerance ) const; - bool Split( const Handle( HYDROData_Document )& theDoc, - const Handle( HYDROData_PolylineXY )& thePolyline, - const Handle( HYDROData_PolylineXY )& theTool, - double theTolerance, - bool& theIsIntersected) const; - bool Split( const Handle( HYDROData_Document )& theDoc, - const HYDROData_SequenceOfObjects& thePolylines, - double theTolerance ); + bool SplitPoint( const Handle( HYDROData_Document )& theDoc, + const Handle( HYDROData_PolylineXY )& thePolyline, + const gp_Pnt2d& thePoint, + double theTolerance ) const; + bool SplitTool( const Handle( HYDROData_Document )& theDoc, + const Handle( HYDROData_PolylineXY )& thePolyline, + const Handle( HYDROData_PolylineXY )& theTool, + double theTolerance, + bool& theIsIntersected) const; + bool SplitAll( const Handle( HYDROData_Document )& theDoc, + const HYDROData_SequenceOfObjects& thePolylines, + double theTolerance ); bool Merge( const Handle( HYDROData_Document )& theDoc, const QString& theName, const HYDROData_SequenceOfObjects& thePolylines, diff --git a/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx b/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx index a30a0e13..61a41a16 100644 --- a/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx @@ -101,12 +101,12 @@ bool HYDROGUI_SplitPolylinesOp::processApply( int& theUpdateFlags, switch( aPanel->GetMode() ) { case HYDROGUI_SplitPolylinesDlg::ByPoint: - anOp.Split( doc(), aMainPolyline, aPoint, aTolerance ); + anOp.SplitPoint( doc(), aMainPolyline, aPoint, aTolerance ); break; case HYDROGUI_SplitPolylinesDlg::ByTool: { bool isIntersected = false; - anOp.Split( doc(), aMainPolyline, aToolPolyline, aTolerance, isIntersected); + anOp.SplitTool( doc(), aMainPolyline, aToolPolyline, aTolerance, isIntersected); if (!isIntersected) { @@ -117,7 +117,7 @@ bool HYDROGUI_SplitPolylinesOp::processApply( int& theUpdateFlags, break; } case HYDROGUI_SplitPolylinesDlg::Split: - anOp.Split( doc(), aPolylinesList, aTolerance ); + anOp.SplitAll( doc(), aPolylinesList, aTolerance ); break; } diff --git a/src/HYDROPy/HYDROData_PolylineOperator.sip b/src/HYDROPy/HYDROData_PolylineOperator.sip index 90ab42be..2e7c57d4 100644 --- a/src/HYDROPy/HYDROData_PolylineOperator.sip +++ b/src/HYDROPy/HYDROData_PolylineOperator.sip @@ -24,6 +24,8 @@ class HYDROData_PolylineOperator { %TypeHeaderCode +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" #include %End @@ -33,10 +35,10 @@ public: ~HYDROData_PolylineOperator(); - bool Split( HYDROData_Document theDoc, - HYDROData_PolylineXY thePolyline, - double x, double y, - double theTolerance ) const + bool SplitPoint( 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 ) ); @@ -44,17 +46,17 @@ public: if ( !aPoly.IsNull() ) { Py_BEGIN_ALLOW_THREADS - sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::Split( a0, aPoly, aPnt, a4 ): - sipCpp->Split( a0, aPoly, aPnt, a4 ); + sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::SplitPoint( a0, aPoly, aPnt, a4 ): + sipCpp->SplitPoint( 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 SplitTool( 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 ) ); @@ -62,33 +64,47 @@ public: 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 ); + sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::SplitTool( a0, aPoly, aTool, a3, a4 ): + sipCpp->SplitTool( a0, aPoly, aTool, a3, a4 ); Py_END_ALLOW_THREADS } %End - bool Split( HYDROData_Document theDoc, - const HYDROData_SequenceOfObjects& thePolylines, - double theTolerance ) + bool SplitAll( HYDROData_Document theDoc, + std::vector thePolylines, + double theTolerance ) [bool (opencascade::handle&, const HYDROData_SequenceOfObjects&, double)]; %MethodCode + NCollection_Sequence objs; + for (size_t i = 0; i != a1->size(); i++) + { + DEBTRACE("item " << i); + Handle(HYDROData_Entity) anEnt = createHandle( (*a1)[i] ); + objs.Append(anEnt); + } Py_BEGIN_ALLOW_THREADS - sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::Split( a0, *a1, a2): - sipCpp->Split( a0, *a1, a2); + sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::SplitAll( a0, objs, a2): + sipCpp->SplitAll( a0, objs, a2); Py_END_ALLOW_THREADS %End bool Merge( HYDROData_Document theDoc, const QString& theName, - const HYDROData_SequenceOfObjects& thePolylines, + std::vector thePolylines, bool isConnectByNewSegment, double theTolerance ) [bool (opencascade::handle&, const QString&, const HYDROData_SequenceOfObjects&, bool, double)]; %MethodCode + NCollection_Sequence objs; + for (size_t i = 0; i != a2->size(); i++) + { + DEBTRACE("item " << i); + Handle(HYDROData_Entity) anEnt = createHandle( (*a2)[i] ); + objs.Append(anEnt); + } Py_BEGIN_ALLOW_THREADS - sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::Merge( a0, *a1, *a2, a3, a4): - sipCpp->Merge( a0, *a1, *a2, a3, a4); + sipRes = sipSelfWasArg ? sipCpp->HYDROData_PolylineOperator::Merge( a0, *a1, objs, a3, a4): + sipCpp->Merge( a0, *a1, objs, a3, a4); Py_END_ALLOW_THREADS %End }; diff --git a/src/HYDROTools/hydroGeoMeshUtils.py b/src/HYDROTools/hydroGeoMeshUtils.py index 6da1a4ef..30349857 100644 --- a/src/HYDROTools/hydroGeoMeshUtils.py +++ b/src/HYDROTools/hydroGeoMeshUtils.py @@ -91,6 +91,46 @@ def importPolylines(document, shapeFile, shapeName, iSpline, displayLevel): shapes.append(shape) return shapes +def splitShapesAll(document, shapeslist, precision=1.E-2): + """ + Split all the shapes in the list by all the other shapes. + return a list of all the other shapes, named after their original shape name, with a sequence suffix _n + """ + names = [s.GetName() for s in shapeslist] + + existingNbSplit = {} + for name in names: + index = 1 + found = True + while found: + nameIndex = name + "_%d"%(index) + shape = document.FindObjectByName(nameIndex) + if shape is None: + found = False + else: + index = index + 1 + existingNbSplit[name] = index + print(existingNbSplit) + + op = HYDROData_PolylineOperator() + op.SplitAll(document, shapeslist, 1.E-2) + + listSplit = [] + for name in names: + index = existingNbSplit[name] + found = True + while found: + nameIndex = name + "_%d"%(index) + shape = document.FindObjectByName(nameIndex) + if shape is None: + found = False + else: + print("found %s"%nameIndex) + index = index + 1 + listSplit.append(shape) + return listSplit + + def importBathymetry(document, bathyName, bathyPath): """ """ diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index 5120fb09..4d889421 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -119,7 +119,7 @@ void test_HYDROData_PolylineXY::test_split_refs_624() CPPUNIT_ASSERT_IMAGES HYDROData_PolylineOperator anOp; - CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline, aPnt, 1E-3 ) ); + CPPUNIT_ASSERT_EQUAL( true, anOp.SplitPoint( aDoc, aPolyline, aPnt, 1E-3 ) ); HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY ); CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); @@ -325,7 +325,7 @@ void test_HYDROData_PolylineXY::test_split_refs_627() gp_Pnt2d aPnt( 20, 20 ); HYDROData_PolylineOperator anOp; - CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline, aPnt, 1E-3 ) ); + CPPUNIT_ASSERT_EQUAL( true, anOp.SplitPoint( aDoc, aPolyline, aPnt, 1E-3 ) ); TestViewer::show( TopoDS_Shape(), 0, true, "Split_Polylines_Colors" ); HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY ); @@ -502,7 +502,7 @@ void test_HYDROData_PolylineXY::test_split_straight_refs_634() aPolylines.Append( aPolyline1 ); aPolylines.Append( aPolyline2 ); bool isIntersected; - CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline1, aPolyline2, 1E-3, isIntersected ) ); + CPPUNIT_ASSERT_EQUAL( true, anOp.SplitTool( aDoc, aPolyline1, aPolyline2, 1E-3, isIntersected ) ); CPPUNIT_ASSERT_EQUAL( true, isIntersected ); HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY ); -- 2.39.2