]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
debug HYDRO tests
authorPaul RASCLE <paul.rascle@edf.fr>
Sun, 19 Jun 2016 21:50:43 +0000 (23:50 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Sun, 19 Jun 2016 21:50:43 +0000 (23:50 +0200)
src/HYDROData/HYDROData_PolylineOperator.cxx
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROData/HYDROData_PolylineXY.h
src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx
src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx
src/HYDRO_tests/reference_data/Merge_Polylines.png
src/HYDRO_tests/test_HYDROData_PolylineXY.cxx

index 1493f336ec287b960a18b0ab49617c397cd7783a..c311866ad13104080b00befaaab77978511348cd 100644 (file)
@@ -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 )
     {
index de46304ab5b80c1428617cbaf9f704636b98fe69..4c223307635e1e50ce1d753099c394e41498a836 100644 (file)
@@ -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 );
 }
index 12117de8105dfaa68dfd30ed52a53c1f079807d3..cbf5657baaa9d2f66ab18501f6a56a5117c28136 100644 (file)
@@ -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.);
 
index f0757cf98aa53d93666c10d38ebe5be71947aa8f..381a78c1d9beb1cc13851e076b3f7bdf8926c660 100644 (file)
@@ -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() )
index 1ed528f676eb70ba5fc65791fe93986d7ab46588..dfb279ffed474376c0fe8054dc05b783b8ed6105 100644 (file)
@@ -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 );
 
       /*
index 7798ae68e0dd49c067d72bf019f3116b655c245f..baed02ce05628644575faf7c3497291ec15c0e3f 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/Merge_Polylines.png and b/src/HYDRO_tests/reference_data/Merge_Polylines.png differ
index 9ec336c1c6f70693c60f38104b8c93b01d2dd349..1ec755ff99871e3a40a56f56005fa51976b76931 100644 (file)
@@ -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<double>() << 0 << 0 << 1 << 1 << 2 << 0 ) );
+  aPolyline2->SetShape( Wire( QList<double>() << 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();
 }