--- /dev/null
+// 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 <test_HYDROData_Channel.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_Channel.h>
+#include <HYDROData_PolylineXY.h>
+#include <HYDROData_Polyline3D.h>
+#include <HYDROData_Profile.h>
+
+#include <TestShape.h>
+#include <TestViewer.h>
+
+#include <AIS_DisplayMode.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <QColor>
+#include <QString>
+
+TopoDS_Edge Spline( const QList<double>& 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<double> aCoords = QList<double>() << 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<double> aCoordsPr = QList<double>() << 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();
+}
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <GeomAPI_Interpolate.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
#include <TestViewer.h>
+#include <TestShape.h>
#include <TopTools_ListOfShape.hxx>
#include <AIS_DisplayMode.hxx>
#include <Aspect_ColorScale.hxx>
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<double>& 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<double>& 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);
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC1 = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
- TopoDS_Face aLC2 = LandCover( QList<double>() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 );
+ TopoDS_Face aLC2 = Face( QList<double>() << 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" );
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ TopoDS_Face aLC = Face( QList<double>() << 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<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire();
+ TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10, false );
aPolyline->SetShape( aWire );
CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ TopoDS_Face aLC = Face( QList<double>() << 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<double>() << 10 << 40 << 30 << 10 << 40 << 10 ) ).Wire();
+ TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10, false );
aPolyline->SetShape( aWire );
CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
- TopoDS_Face aLC2 = LandCover( QList<double>() << 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<double>() << 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<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
- 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+ TopoDS_Face aLC3 = Face( QList<double>() << 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 );
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
- TopoDS_Face aLC2 = LandCover( QList<double>() << 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<double>() << 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<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
- 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+ TopoDS_Face aLC3 = Face( QList<double>() << 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;
// aST.size() == aDBFV.size()!!
Handle(HYDROData_PolylineXY) aPolyline =
Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
- TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire();
+ TopoDS_Wire aWire = Wire( QList<double>() << 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<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
Handle(HYDROData_LandCoverMap) aMap =
Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
- TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face( QList<double>() << 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<double>() << 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<double>() << 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<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
- 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+ TopoDS_Face aLC3 = Face( QList<double>() << 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 );
Handle(HYDROData_LandCoverMap) aMap =
Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
- TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face( QList<double>() << 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<double>() << 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<double>() << 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<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
- 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+ TopoDS_Face aLC3 = Face( QList<double>() << 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 );