#include <GeomAPI_Interpolate.hxx>
#include <gp_Circ.hxx>
-TopoDS_Edge Edge( const QList<double>& theXYList, bool isClosed )
+TopoDS_Edge Edge2d( const QList<double>& theXYList, bool isClosed )
{
int n = theXYList.size()/2;
Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
return TopoDS_Edge();
}
-TopoDS_Wire Wire( const QList<double>& theXYList, bool isClosed )
+TopoDS_Wire Wire2d( const QList<double>& theXYList, bool isClosed )
{
- return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire();
+ return BRepBuilderAPI_MakeWire( Edge2d( theXYList, isClosed ) ).Wire();
}
-TopoDS_Face Face( const QList<double>& theXYList )
+TopoDS_Edge Edge3d( const QList<double>& theXYZList, bool isClosed )
{
- return BRepBuilderAPI_MakeFace( Wire( theXYList, true ), Standard_True ).Face();
+ int n = theXYZList.size()/3;
+ Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
+ for( int i=1; i<=n; i++ )
+ {
+ double x = theXYZList[3*i-3];
+ double y = theXYZList[3*i-2];
+ double z = theXYZList[3*i-1];
+ gp_Pnt aPnt( x, y, z );
+ 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 Wire3d( const QList<double>& theXYZList, bool isClosed )
+{
+ return BRepBuilderAPI_MakeWire( Edge3d( theXYZList, isClosed ) ).Wire();
+}
+
+TopoDS_Face Face2d( const QList<double>& theXYList )
+{
+ return BRepBuilderAPI_MakeFace( Wire2d( theXYList, true ), Standard_True ).Face();
+}
+
+TopoDS_Face Face3d( const QList<double>& theXYZList )
+{
+ return BRepBuilderAPI_MakeFace( Wire3d( theXYZList, true ), Standard_True ).Face();
}
TopoDS_Wire WireCirc( const gp_Pnt& theCenter, double theRadius )
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ TopoDS_Face aLC1 = Face2d( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
//DEBTRACE("--- ajout test1 " << aLC1);
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
- TopoDS_Face aLC2 = Face( QList<double>() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 );
+ TopoDS_Face aLC2 = Face2d( QList<double>() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 );
//DEBTRACE("--- ajout test2 " << aLC2);
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ TopoDS_Face aLC = Face2d( 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 = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10, false );
+ TopoDS_Wire aWire = Wire2d( 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 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ TopoDS_Face aLC = Face2d( 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 = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10, false );
+ TopoDS_Wire aWire = Wire2d( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10, false );
aPolyline->SetShape( aWire );
CPPUNIT_ASSERT_EQUAL( false, aMap->Split( aPolyline ) );
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face2d( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
- TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
+ TopoDS_Face aLC2 = Face2d( 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 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
+ TopoDS_Face aLC3 = Face2d( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face2d( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
- TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
+ TopoDS_Face aLC2 = Face2d( 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 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
+ TopoDS_Face aLC3 = Face2d( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
// aST.size() == aDBFV.size()!!
Handle(HYDROData_PolylineXY) aPolyline =
Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
- TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 );
+ TopoDS_Wire aWire = Wire2d( 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 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ TopoDS_Face aLC1 = Face2d( 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 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face2d( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Zones de champs cultivé à végétation basse")) );
- TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
+ TopoDS_Face aLC2 = Face2d( 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, QString::fromUtf8("Zones de champs cultivé à végétation haute")) );
- TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
+ TopoDS_Face aLC3 = Face2d( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, QString::fromUtf8("Zones de champs, prairies, sans cultures")) );
Handle(HYDROData_LandCoverMap) aMap =
Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
- TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face2d( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Zones de champs cultivé à végétation basse")) );
- TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
+ TopoDS_Face aLC2 = Face2d( 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, QString::fromUtf8("Zones de champs cultivé à végétation haute")) );
- TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
+ TopoDS_Face aLC3 = Face2d( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, QString::fromUtf8("Zones de champs, prairies, sans cultures")) );
CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
- TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face2d( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
- TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
+ TopoDS_Face aLC2 = Face2d( 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 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
+ TopoDS_Face aLC3 = Face2d( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
Handle(HYDROData_LandCoverMap) aMap =
Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
- aMap->LocalPartition( Face( QList<double>() << 1 << 1 << 10 << 10 << 10 << 20 ), QString::fromUtf8("Zones de champs cultivé à végétation haute"));
- aMap->LocalPartition( Face( QList<double>() << 5 << 5 << 10 << 5 << 10 << 8 << 5 << 12 << 5 << 8 ), QString::fromUtf8("Zones de champs cultivé à végétation haute"));
+ aMap->LocalPartition( Face2d( QList<double>() << 1 << 1 << 10 << 10 << 10 << 20 ), QString::fromUtf8("Zones de champs cultivé à végétation haute"));
+ aMap->LocalPartition( Face2d( QList<double>() << 5 << 5 << 10 << 5 << 10 << 8 << 5 << 12 << 5 << 8 ), QString::fromUtf8("Zones de champs cultivé à végétation haute"));
aMap->SetName( "test_LCM" );
TestViewer::show( aZone->GetTopShape(), AIS_Shaded, true, "LandCoverMap_TransparentPrs" );
Handle(HYDROData_LandCoverMap) aMap =
Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
- TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ TopoDS_Face aLC1 = Face2d( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Forêt et végétation arbustive en mutation")) );
- TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 <<
+ TopoDS_Face aLC2 = Face2d( 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, QString::fromUtf8("Forêts de conifères")) );
- TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
+ TopoDS_Face aLC3 = Face2d( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, QString::fromUtf8("Forêts de feuillus")) );
Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
aMap->SetName( "map_1" );
- TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 30 << 10 << 20 << 20 );
+ TopoDS_Face aLC1 = Face2d( QList<double>() << 10 << 10 << 30 << 10 << 20 << 20 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Forêts de conifères")) );
- TopoDS_Face aLC2 = Face( QList<double>() << 110 << 10 << 130 << 10 << 120 << 20 );
+ TopoDS_Face aLC2 = Face2d( QList<double>() << 110 << 10 << 130 << 10 << 120 << 20 );
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, QString::fromUtf8("Forêts de feuillus")) );
Handle(HYDROData_LandCoverMap) aMap2 =
aPolyline->SetName( "test" );
QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
- TopoDS_Wire aWire = Wire( aCoords, true );
+ TopoDS_Wire aWire = Wire2d( aCoords, true );
aPolyline->SetShape( aWire );
gp_Pnt2d aPnt( 20, 20 );
aPolyline->SetName( "test" );
QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
- TopoDS_Wire aWire = Wire( aCoords, true );
+ TopoDS_Wire aWire = Wire2d( aCoords, true );
aPolyline->SetShape( aWire );
Handle(HYDROData_ImmersibleZone) aZone =
aPolyline3d->SetPolylineXY( aPolyline2d );
QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
- TopoDS_Wire aWire = Wire( aCoords, false );
+ TopoDS_Wire aWire = Wire2d( aCoords, false );
aPolyline2d->SetShape( aWire );
aPolyline3d->SetTopShape( aWire );
aPolyline3d->SetShape3D( aWire );
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 );
+ QList<double> aCoordsPr = QList<double>() << 0.0 << 0.1 << 0.0 << 0.0 << 1.0 << 0.0;
+ TopoDS_Wire aWirePr = Wire3d( aCoordsPr, false );
aProfile->SetTopShape( aWirePr );
aProfile->SetShape3D( aWirePr );
aPolyline->SetName( "test" );
QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
- TopoDS_Wire aWire = Wire( aCoords, false );
+ TopoDS_Wire aWire = Wire2d( aCoords, false );
aPolyline->SetShape( aWire );
aPolyline->SetWireColor( Qt::red );
CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() );
CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() );
- aPolyline2->SetShape( Wire( QList<double>() << 0 << 0 << 10 << 10 << 20 << 0 ) );
+ aPolyline2->SetShape( Wire2d( QList<double>() << 0 << 0 << 10 << 10 << 20 << 0 ) );
CPPUNIT_ASSERT_EQUAL( true, aPolyline2->IsCustom() );
HYDROData_PolylineXY::PointsList aPointsList = aPolyline2->GetPoints( 0 );