X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_PolylineXY.cxx;h=18dc1e4c663e2bed89a8a823d1af7ee06fb35f1e;hb=424f8230c9003d00fb27499b2441c4b3a2a28292;hp=b20f1bd8717e1fce598ba5a731723a7ba67f1342;hpb=aab4319f1f8306683e93dbd71ac7a02c0437fac6;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index b20f1bd8..18dc1e4c 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -40,6 +40,8 @@ #define PYTHON_POLYLINEXY_ID "KIND_POLYLINEXY" +const double LOCAL_SELECTION_TOLERANCE = 0.0001; + IMPLEMENT_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline) @@ -138,13 +140,16 @@ TopoDS_Wire HYDROData_PolylineXY::BuildWire( const SectionType& gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z() ); gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), aLastPoint.Z() ); + if ( aPnt1.IsEqual( aPnt2, LOCAL_SELECTION_TOLERANCE ) ) + continue; + TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge(); aMakeWire.Add( anEdge ); } } else //if( theType == PolylineSection::SECTION_SPLINE ) { - HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed ); + HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE ); TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge(); aMakeWire.Add( anEdge ); @@ -183,13 +188,15 @@ void HYDROData_PolylineXY::BuildPainterPath( QPainterPath& } else { - HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed ); + HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE ); aBSpline.ComputePath( thePath ); } } void HYDROData_PolylineXY::Update() { + HYDROData_IPolyline::Update(); + NCollection_Sequence aSectNames; NCollection_Sequence aSectTypes; NCollection_Sequence aSectClosures; @@ -294,6 +301,9 @@ double HYDROData_PolylineXY::GetDistance( const int theSectionIndex, const Point& aSectPoint = aSectPointsList.Value( i ); aResDistance += gp_Pnt2d( aPrevPoint ).Distance( aSectPoint ); aPrevPoint = aSectPoint; + + if ( thePointIndex == i - 1 ) + break; } } else @@ -313,7 +323,7 @@ double HYDROData_PolylineXY::GetDistance( const int theSectionIndex, aPointToTest = aPoint; } - HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed ); + HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE ); Quantity_Parameter aFirstParam = aBSpline.Curve()->FirstParameter(); Quantity_Parameter aSecondParam = aBSpline.Curve()->LastParameter(); @@ -379,6 +389,8 @@ void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectNam aNamesList->Append( aSectName ); aTypesList->Append( theSectionType ); aClosuresList->Append( theIsClosed ); + + SetToUpdate( true ); } TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const @@ -422,6 +434,8 @@ void HYDROData_PolylineXY::SetSectionName( const int theSec TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList ); for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i ) aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() ); + + SetToUpdate( true ); } HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const @@ -458,6 +472,8 @@ void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex, TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList ); for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i ) aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() ); + + SetToUpdate( true ); } bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const @@ -494,6 +510,8 @@ void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex, TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList ); for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i ) aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() ); + + SetToUpdate( true ); } void HYDROData_PolylineXY::GetSections( NCollection_Sequence& theSectNames, @@ -574,12 +592,15 @@ void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex ) // Remove points that belongs to removed section removePointsLists( theSectionIndex ); } + + SetToUpdate( true ); } void HYDROData_PolylineXY::RemoveSections() { removeSectionsLists(); removePointsLists(); + SetToUpdate( true ); } void HYDROData_PolylineXY::AddPoint( const int theSectionIndex, @@ -624,6 +645,8 @@ void HYDROData_PolylineXY::AddPoint( const int theSectionIndex, aListY->Append( aCoordY ); } } + + SetToUpdate( true ); } void HYDROData_PolylineXY::SetPoint( const int theSectionIndex, @@ -673,6 +696,8 @@ void HYDROData_PolylineXY::SetPoint( const int theSectionIndex, aListY->Append( aCoordY ); } } + + SetToUpdate( true ); } void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex, @@ -710,6 +735,8 @@ void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex, aListY->Append( anIterY.Value() ); } } + + SetToUpdate( true ); } HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex ) const