From 07ccf1206abd36c104230ae2051110e8e2bf27c0 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 21 Oct 2015 15:35:59 +0300 Subject: [PATCH] test for channel presentation --- src/HYDRO_tests/CMakeLists.txt | 4 + src/HYDRO_tests/TestShape.cxx | 43 +++++++ src/HYDRO_tests/TestShape.h | 13 ++ src/HYDRO_tests/TestViewer.cxx | 1 + src/HYDRO_tests/reference_data/Channel.png | Bin 0 -> 7698 bytes src/HYDRO_tests/test_HYDROData_Channel.cxx | 84 +++++++++++++ src/HYDRO_tests/test_HYDROData_Channel.h | 33 ++++++ .../test_HYDROData_LandCoverMap.cxx | 112 ++++++------------ src/HYDRO_tests/test_HYDROData_PolylineXY.cxx | 10 +- 9 files changed, 217 insertions(+), 83 deletions(-) create mode 100644 src/HYDRO_tests/TestShape.cxx create mode 100644 src/HYDRO_tests/TestShape.h create mode 100644 src/HYDRO_tests/reference_data/Channel.png create mode 100644 src/HYDRO_tests/test_HYDROData_Channel.cxx create mode 100644 src/HYDRO_tests/test_HYDROData_Channel.h diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index feb497da..7f1e99b1 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -3,6 +3,7 @@ include(ExternalFiles.cmake) set(PROJECT_HEADERS test_HYDROData_Bathymetry.h + test_HYDROData_Channel.h test_HYDROData_Document.h test_HYDROData_Entity.h test_HYDROData_Image.h @@ -16,6 +17,7 @@ set(PROJECT_HEADERS test_HYDROGUI_ListModel.h test_Dependencies.h + TestShape.h TestViewer.h TestLib_Listener.h TestLib_Runner.h @@ -23,6 +25,7 @@ set(PROJECT_HEADERS set(PROJECT_SOURCES test_HYDROData_Bathymetry.cxx + test_HYDROData_Channel.cxx test_HYDROData_Document.cxx test_HYDROData_Entity.cxx test_HYDROData_Image.cxx @@ -37,6 +40,7 @@ set(PROJECT_SOURCES test_HYDROGUI_ListModel.cxx test_Dependencies.cxx + TestShape.cxx TestViewer.cxx TestLib_Listener.cxx TestLib_Runner.cxx diff --git a/src/HYDRO_tests/TestShape.cxx b/src/HYDRO_tests/TestShape.cxx new file mode 100644 index 00000000..106ee9b5 --- /dev/null +++ b/src/HYDRO_tests/TestShape.cxx @@ -0,0 +1,43 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +TopoDS_Edge Edge( const QList& theXYList, bool isClosed ) +{ + int n = theXYList.size()/2; + Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n ); + for( int i=1; i<=n; i++ ) + { + double x = theXYList[2*i-2]; + double y = theXYList[2*i-1]; + gp_Pnt aPnt( x, y, 0 ); + aPointsArray->SetValue( i, aPnt ); + } + GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 ); + anInterpolator.Perform(); + bool aResult = anInterpolator.IsDone() == Standard_True; + if( aResult ) + { + Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve(); + return BRepBuilderAPI_MakeEdge( aCurve ).Edge(); + } + else + return TopoDS_Edge(); +} + +TopoDS_Wire Wire( const QList& theXYList, bool isClosed ) +{ + return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire(); +} + +TopoDS_Face Face( const QList& theXYList ) +{ + return BRepBuilderAPI_MakeFace( Wire( theXYList, true ), Standard_True ).Face(); +} diff --git a/src/HYDRO_tests/TestShape.h b/src/HYDRO_tests/TestShape.h new file mode 100644 index 00000000..d5bb2220 --- /dev/null +++ b/src/HYDRO_tests/TestShape.h @@ -0,0 +1,13 @@ + +#pragma once + +#include + +class TopoDS_Edge; +class TopoDS_Wire; +class TopoDS_Face; + +TopoDS_Edge Edge( const QList& theXYList, bool isClosed = false ); +TopoDS_Wire Wire( const QList& theXYList, bool isClosed = false ); +TopoDS_Face Face( const QList& theXYList ); + diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index f3bd5105..d6ae86ff 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -125,6 +125,7 @@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey ) { + context()->CloseLocalContext(); context()->EraseAll( Standard_False ); myKey = theKey; diff --git a/src/HYDRO_tests/reference_data/Channel.png b/src/HYDRO_tests/reference_data/Channel.png new file mode 100644 index 0000000000000000000000000000000000000000..f30b4949e76e848c7a2675073564e908ab052798 GIT binary patch literal 7698 zcmbt(2{_c-|Nr^SjAkTeEa6(l;0k4pL|G=Oq`^d22$9HEmNp~?6C)xw+0(R;HcLpk zma#>tDAH=lQY2+$XZW4r=HK`JzrW|X&;LKq%rob6&ilO1>%E-!Sw1mTiyizcB~}6e z_;;F`SOI`00f4f_t$;P@CnEgdALgj>&OJEz3Bes?z-L}RQ@f)82-I@<6m+$rVSfa8M=FYnaLPng9_@1j;a{Lm$ z7|GbPbZUWWMS-Z<%E!)eI&!IX_GjDwO4e1z4w~27+fx*ZyI;Rm)n@wJsQ+p3_UNaO zuL&htlS7k#1-O$ADLxN=J(GW^!utjWvI3wb-R>J6koQL=MfJ}6d@9GZlovfT0w5?; z1ZDlM+_aWq%YEAG@Bc z5YKncNzT=}2g6hmb)rS2y4Tsq3u~eXwFmglzxdcq_-$G$D+wn=^R#t9B2;%ocPpg~ z;#k@$xj+n7P3i<8iKj zl}E$~^EfP?*|sV-x#7-0A_4I_#75n6eTNuha#ObPrLBX?kOR5sVB&*1W`$kA~1B# zVVb`FpFBx*#u&P|m4pel&rJfA#FE2Mo?Nq`inbC+8)NYrydM!aEq)}Ra0FZvB2w{! zs6OWx$aY!%nR|h8haBfalN#jh$l9^|1*<>qjy8|{sGH$*N3Du?SZSWv?<#>ZDQp3f zKiqGxmtHMd;$XWnshqNvh7%QcKAc1B&(+h>k)VOS zzw?R5Zo@n{yK&z+Z@oT)`$j9_^>wUId$9-+$qx!Y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R3?91S&Rec({xF6e z%wPDJVcB`Kd4V%Ldikk)QHfYxewLnAh>Ol<_QmsJY7P&6T$AApbg74)Zi3n76uYN> zGHP}aqn^!J8?(ocgfFAW8Rhy(;E4whnvDaM@i0y zTncOV3CuGHO?o*Jd3j!&6Da=D*QqkZ&7U(-TE#hOX~Y?;`f%d?;i{=Ot_hsIX3D2$ zS}#{}#`D8Cr--3bABQ@}^G3Jdfbs^2}$5R=vhfvv%3&c{FsK|I9}x z#8>>~tZD((Kv?ii)(9{=zES8m^}9{NLynB z&z?hqa>_A+Gr#N8((NA5ZmBkynnlp>^WvF2q8d!)9Qk6?K%iQ99(g7tU(8x@l(|7v zo5^>8{w_6m@pV~;pnMV~5Zo<#fH)S#ToO{bDzESnDQ=d-7StW1D_unoT;#!biyxpX z2iC0|xKxjK<~cw=oO)vErQI6Mnzbfa)(aH|*hi385tarwigZzNb&@4BZu_yUFDgku zSX0_F!xPJLS4jm(ov9=gpHRsH)pe!@$&vC3FA$9te9GkQ(Ua#?gcS<~8n&B7pq*EW z+R%(+E(|jGX(1~2!D=DJ+rpB-tq`EKb6)G}t<|;?k_6d>O6X(PFY0Q(0=X&m611e3 wUj6|el4R52A( +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +TopoDS_Edge Spline( const QList& theXYList, bool isClosed = false ); + +void test_HYDROData_Channel::test_2d_prs() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_PolylineXY) aPolyline2d = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + aPolyline2d->SetName( "polyline2d_1" ); + aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false ); + + Handle(HYDROData_Polyline3D) aPolyline3d = + Handle(HYDROData_Polyline3D)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) ); + aPolyline3d->SetName( "polyline3d_1" ); + aPolyline3d->SetPolylineXY( aPolyline2d ); + + QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; + TopoDS_Wire aWire = Wire( aCoords, false ); + aPolyline2d->SetShape( aWire ); + aPolyline3d->SetTopShape( aWire ); + aPolyline3d->SetShape3D( aWire ); + + Handle(HYDROData_Profile) aProfile = + Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); + aProfile->SetName( "profile_1" ); + + QList aCoordsPr = QList() << 0.0 << 0.1 << 0.5 << 0.0 << 1.0 << 0.1; + TopoDS_Wire aWirePr = Wire( aCoordsPr, false ); + aProfile->SetTopShape( aWirePr ); + aProfile->SetShape3D( aWirePr ); + + + Handle(HYDROData_Channel) aChannel = + Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) ); + aChannel->SetName( "channel_1" ); + + aChannel->SetGuideLine( aPolyline3d ); + aChannel->SetProfile( aProfile ); + aChannel->Update(); + CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetTopShape().IsNull() ); + CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetShape3D().IsNull() ); + + TestViewer::show( aChannel->GetTopShape(), AIS_Shaded, true, "Channel" ); + TestViewer::show( aChannel->GetLeftShape(), AIS_WireFrame, true, Qt::red ); + TestViewer::show( aChannel->GetRightShape(), AIS_WireFrame, true, Qt::red ); + //TestViewer::show( aWire, AIS_Shaded, true, "Channel" ); + CPPUNIT_ASSERT_IMAGES + + aDoc->Close(); +} diff --git a/src/HYDRO_tests/test_HYDROData_Channel.h b/src/HYDRO_tests/test_HYDROData_Channel.h new file mode 100644 index 00000000..c4e22a89 --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_Channel.h @@ -0,0 +1,33 @@ +// 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 +// + +#include + +class test_HYDROData_Channel : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE( test_HYDROData_Channel ); + CPPUNIT_TEST( test_2d_prs ); + CPPUNIT_TEST_SUITE_END(); + +private: + +public: + void test_2d_prs(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_Channel ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_Channel, "HYDROData_Channel"); diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index 5726f296..5e7e8fca 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -26,12 +26,8 @@ #include #include #include -#include -#include -#include -#include -#include #include +#include #include #include #include @@ -44,40 +40,6 @@ const QString REF_DATA_PATH = qgetenv( "HYDRO_REFERENCE_DATA" ); const QString DEF_STR_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/share/salome/resources/hydro/def_strickler_table.txt"; -TopoDS_Edge Spline( const QList& theXYList, bool isClosed = false ) -{ - int n = theXYList.size()/2; - Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n ); - for( int i=1; i<=n; i++ ) - { - double x = theXYList[2*i-2]; - double y = theXYList[2*i-1]; - gp_Pnt aPnt( x, y, 0 ); - aPointsArray->SetValue( i, aPnt ); - } - GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 ); - anInterpolator.Perform(); - bool aResult = anInterpolator.IsDone() == Standard_True; - if( aResult ) - { - Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve(); - return BRepBuilderAPI_MakeEdge( aCurve ).Edge(); - } - else - return TopoDS_Edge(); -} - -TopoDS_Face LandCover( const QList& theXYList ) -{ - TopoDS_Edge anEdge = Spline( theXYList, true ); - if( anEdge.IsNull() ) - return TopoDS_Face(); - - TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire(); - TopoDS_Face aFace = BRepBuilderAPI_MakeFace( aWire, Standard_True ).Face(); - return aFace; -} - void test_HYDROData_LandCoverMap::test_add_2_objects() { Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); @@ -87,10 +49,10 @@ void test_HYDROData_LandCoverMap::test_add_2_objects() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC1 = LandCover( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + TopoDS_Face aLC1 = Face( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); - TopoDS_Face aLC2 = LandCover( QList() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 ); + TopoDS_Face aLC2 = Face( QList() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) ); TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Add_2_Objects" ); @@ -117,12 +79,12 @@ void test_HYDROData_LandCoverMap::test_split() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC = LandCover( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + TopoDS_Face aLC = Face( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) ); Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); - TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire(); + TopoDS_Wire aWire = Wire( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10, false ); aPolyline->SetShape( aWire ); CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) ); @@ -152,12 +114,12 @@ void test_HYDROData_LandCoverMap::test_incomplete_split() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC = LandCover( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + TopoDS_Face aLC = Face( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) ); Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); - TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList() << 10 << 40 << 30 << 10 << 40 << 10 ) ).Wire(); + TopoDS_Wire aWire = Wire( QList() << 10 << 40 << 30 << 10 << 40 << 10, false ); aPolyline->SetShape( aWire ); CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) ); @@ -184,18 +146,18 @@ void test_HYDROData_LandCoverMap::test_merge() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC1 = LandCover( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); - TopoDS_Face aLC2 = LandCover( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << - 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << - 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << - 31 << 114 ); + TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << + 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << + 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) ); - TopoDS_Face aLC3 = LandCover( QList() << 4 << 54 << 1 << 47 << 51 << 45 << - 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); + TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) ); //TestViewer::show( aMap->GetShape(), AIS_Shaded, true ); @@ -229,18 +191,18 @@ void test_HYDROData_LandCoverMap::test_remove() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC1 = LandCover( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); - TopoDS_Face aLC2 = LandCover( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << - 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << - 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << - 31 << 114 ); + TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << + 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << + 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) ); - TopoDS_Face aLC3 = LandCover( QList() << 4 << 54 << 1 << 47 << 51 << 45 << - 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); + TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) ); QString aType1, aType2; @@ -471,11 +433,11 @@ void test_HYDROData_LandCoverMap::test_import_dbf() // aST.size() == aDBFV.size()!! Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); - TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire(); + TopoDS_Wire aWire = Wire( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ); aPolyline->SetShape( aWire ); for (int i = 0; i < 3; i++) aMap->Add(aPolyline, ""); - TopoDS_Face aLC1 = LandCover( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + TopoDS_Face aLC1 = Face( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) ); @@ -503,17 +465,17 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types() Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); - TopoDS_Face aLC1 = LandCover( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) ); - TopoDS_Face aLC2 = LandCover( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << - 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << - 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << - 31 << 114 ); + TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << + 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << + 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) ); - TopoDS_Face aLC3 = LandCover( QList() << 4 << 54 << 1 << 47 << 51 << 45 << - 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); + TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) ); Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap ); @@ -535,17 +497,17 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff() Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); - TopoDS_Face aLC1 = LandCover( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) ); - TopoDS_Face aLC2 = LandCover( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << - 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << - 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << - 31 << 114 ); + TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << + 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << + 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) ); - TopoDS_Face aLC3 = LandCover( QList() << 4 << 54 << 1 << 47 << 51 << 45 << - 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); + TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) ); Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap ); diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index ee08e8bb..ff966ddc 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -28,18 +28,12 @@ #include #include +#include #include -#include -#include #include #include #include -TopoDS_Edge Spline( const QList& theXYList, bool isClosed = false ); - - - - void test_HYDROData_PolylineXY::testPolyline() { Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); @@ -98,7 +92,7 @@ void test_HYDROData_PolylineXY::testSplit_refs_624() aPolyline->SetName( "test" ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( aCoords, true ) ).Wire(); + TopoDS_Wire aWire = Wire( aCoords, true ); aPolyline->SetShape( aWire ); gp_Pnt2d aPnt( 20, 20 ); -- 2.39.2