From: Paul RASCLE Date: Sun, 19 Jun 2016 21:50:43 +0000 (+0200) Subject: debug HYDRO tests X-Git-Tag: v1.6~101 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e77a4312d0891c252baac0e1dcac298bb7bdeb72;p=modules%2Fhydro.git debug HYDRO tests --- diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index 1493f336..c311866a 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -158,8 +158,20 @@ bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theD } QString aName = theName; if( aName.isEmpty() ) - aName = "merged"; + { + aName = "merged"; + int anIndex = 1; + QString aNewName = aName + "_" + QString::number(anIndex); + while (!theDoc->FindObjectByName(aNewName).IsNull()) // the object with such a name is not found + { + anIndex++; + aNewName = aName + "_" + QString::number(anIndex); + } + aName = aNewName; + } + aNewPolyline->SetName(aName); + aNewPolyline->Update(); return true; } @@ -234,7 +246,6 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD } CreatePolylines( theDoc, thePolyline, aResult, true ); - //CreatePolylinesSplit( theDoc, thePolyline, aResult, true ); return true; } @@ -307,8 +318,6 @@ bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Docume return false; aPolyline->ImportShape(theShapes[i], false, theOldPolyline, false); - //aPolyline->SetShape( theShapes[i] ); - if( isUseIndices ) { diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index de46304a..4c223307 100644 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -238,7 +238,7 @@ bool HYDROData_PolylineXY::ImportFromGeomIOR( const TCollection_AsciiString& the if ( aShape.IsNull() ) return false; - return ImportShape( aShape, false ); + return ImportShape( aShape, false, NULL ); #endif } @@ -618,6 +618,10 @@ bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape, if ( theShape.IsNull() ) return false; + std::string brepName = this->GetName().toStdString(); + brepName += ".brep"; + BRepTools::Write( theShape, brepName.c_str() ); + RemoveSections(); bool anIsCanBeImported = false; @@ -695,7 +699,7 @@ bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape, } setEditable( anIsCanBeImported ); - + Update(); return true; } @@ -1506,5 +1510,5 @@ void HYDROData_PolylineXY::SetIsInCustomFlag( bool theValue ) void HYDROData_PolylineXY::Interpolate() { - ImportShape( GetShape(), true ); + ImportShape( GetShape(), true, NULL ); } diff --git a/src/HYDROData/HYDROData_PolylineXY.h b/src/HYDROData/HYDROData_PolylineXY.h index 12117de8..cbf5657b 100644 --- a/src/HYDROData/HYDROData_PolylineXY.h +++ b/src/HYDROData/HYDROData_PolylineXY.h @@ -132,7 +132,7 @@ public: */ HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape, bool IsInterpolationAllowed, - const Handle( HYDROData_PolylineXY )& theOldPolyline = NULL, + const Handle( HYDROData_PolylineXY )& theOldPolyline, bool IsClosureAllowed = true, double theDeviation = 1.); diff --git a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx index f0757cf9..381a78c1 100644 --- a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx @@ -243,7 +243,7 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags, anIsOk = true; } else if ( myOpType == ImportSelectedAsPolyline ) { Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( anObject ); - anIsOk = aPolyline->ImportShape( aShape, false ); + anIsOk = aPolyline->ImportShape( aShape, false, NULL ); /* TODO: check it before start operation if ( anIsOk && !aPolyline->IsEditable() ) diff --git a/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx b/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx index 1ed528f6..dfb279ff 100644 --- a/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx +++ b/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx @@ -228,7 +228,7 @@ bool HYDROGUI_RecognizeContoursOp::processApply( int& theUpdateFlags, if( !aPolylineObj.IsNull() ) { aPolylineObj->SetName( aName ); - aPolylineObj->ImportShape( aShape, false ); + aPolylineObj->ImportShape( aShape, false, NULL ); aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() ); aPolylineObj->Update(); @@ -379,7 +379,7 @@ void HYDROGUI_RecognizeContoursOp::updateRecognizedPolylines() TopoDS_Shape aSubShape = aSubShapes.Value( i ); // Transform the sub-shape - aPolylineObj->ImportShape( aSubShape, false ); + aPolylineObj->ImportShape( aSubShape, false, NULL ); aPolylineObj->Transform( aTrsf ); /* diff --git a/src/HYDRO_tests/reference_data/Merge_Polylines.png b/src/HYDRO_tests/reference_data/Merge_Polylines.png index 7798ae68..baed02ce 100644 Binary files a/src/HYDRO_tests/reference_data/Merge_Polylines.png and b/src/HYDRO_tests/reference_data/Merge_Polylines.png differ diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index 9ec336c1..1ec755ff 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -338,34 +338,34 @@ void test_HYDROData_PolylineXY::test_custom_polylines() CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() ); CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() ); - aPolyline2->SetShape( Wire( QList() << 0 << 0 << 1 << 1 << 2 << 0 ) ); + aPolyline2->SetShape( Wire( QList() << 0 << 0 << 10 << 10 << 20 << 0 ) ); CPPUNIT_ASSERT_EQUAL( true, aPolyline2->IsCustom() ); HYDROData_PolylineXY::PointsList aPointsList = aPolyline2->GetPoints( 0 ); CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() ); - CPPUNIT_ASSERT_EQUAL( 33, aPointsList.Size() ); + CPPUNIT_ASSERT_EQUAL( 5, aPointsList.Size() ); CPPUNIT_ASSERT_EQUAL( gp_XY( 0, 0 ), aPointsList.Value( 1 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( 0.5625, 0.808594 ), aPointsList.Value( 10 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( 1.1875, 0.964844 ), aPointsList.Value( 20 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( 2, 0 ), aPointsList.Value( 33 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 5, 7.5 ), aPointsList.Value( 2 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 10, 10 ), aPointsList.Value( 3 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 15, 7.5 ), aPointsList.Value( 4 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 20, 0 ), aPointsList.Value( 5 ) ); CPPUNIT_ASSERT_EQUAL( false, aPolyline3->IsCustom() ); - aPolyline3->SetShape( WireCirc( gp_Pnt(), 1.0 ) ); + aPolyline3->SetShape( WireCirc( gp_Pnt(), 10.0 ) ); CPPUNIT_ASSERT_EQUAL( true, aPolyline3->IsCustom() ); aPointsList = aPolyline3->GetPoints( 0 ); CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_SPLINE, aPolyline3->GetSectionType( 0 ) ); CPPUNIT_ASSERT_EQUAL( true, aPolyline3->IsClosedSection( 0 ) ); - CPPUNIT_ASSERT_EQUAL( 71, aPointsList.Size() ); - CPPUNIT_ASSERT_EQUAL( gp_XY( 1, 0 ), aPointsList.Value( 1 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( 0.699242, 0.714885 ), aPointsList.Value( 10 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( -0.110394, 0.993888 ), aPointsList.Value( 20 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( -0.839072, 0.54402 ), aPointsList.Value( 30 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( -0.952415, -0.304806 ), aPointsList.Value( 40 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( -0.367302, -0.930102 ), aPointsList.Value( 50 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( 0.487173, -0.873306 ), aPointsList.Value( 60 ) ); - CPPUNIT_ASSERT_EQUAL( gp_XY( 0.996087, -0.0883801 ), aPointsList.Value( 71 ) ); + CPPUNIT_ASSERT_EQUAL( 7, aPointsList.Size() ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 10, 0 ), aPointsList.Value( 1 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 6.2349, 7.81831 ), aPointsList.Value( 2 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -2.225, 9.749 ), aPointsList.Value( 3 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -9.01, 4.339 ), aPointsList.Value( 4 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -9.01, -4.339 ), aPointsList.Value( 5 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -2.225, -9.749 ), aPointsList.Value( 6 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 6.2349, -7.81831 ), aPointsList.Value( 7 ) ); aDoc->Close(); }