From e3000ba337d23a437393722a865e2074609ef51a Mon Sep 17 00:00:00 2001 From: abk Date: Fri, 10 Jul 2015 14:00:28 +0300 Subject: [PATCH] refs #628: Fatal error as result of splitting polyline without tool object The split algorithms were changed to do not perform the splitting if: - the polyline is absent during the split by a point; - one of the polylines is absent during the split of a polyline by a tool; - less than two polylines are present during the split of polylines by each other. --- src/HYDROData/HYDROData_PolylineOperator.cxx | 29 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index 612d24f9..c8bc099f 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -64,6 +64,11 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD const gp_Pnt2d& thePoint, double theTolerance ) const { + if (thePolyline.IsNull()) + { + return false; + } + std::vector aPointsList( 1 ); aPointsList[0] = thePoint; std::vector aCurves; @@ -84,6 +89,11 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD const Handle( HYDROData_PolylineXY )& theTool, double theTolerance ) const { + if (thePolyline.IsNull() || theTool.IsNull()) + { + return false; + } + HYDROData_SequenceOfObjects aSeq; aSeq.Append( theTool ); return split( theDoc, thePolyline, aSeq, theTolerance, -1 ); @@ -155,6 +165,11 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD double theTolerance, int theIgnoreIndex ) const { + if (thePolyline.IsNull()) + { + return false; + } + std::vector aCurves; GetWires(thePolyline, aCurves); std::vector aToolCurves; @@ -163,11 +178,19 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD { Handle( HYDROData_PolylineXY ) aToolPolyline = Handle( HYDROData_PolylineXY )::DownCast( theTools.Value( i ) ); - std::vector aTCurves; - GetWires(aToolPolyline, aTCurves); - append( aToolCurves, aTCurves); + if (!aToolPolyline.IsNull()) + { + std::vector aTCurves; + GetWires(aToolPolyline, aTCurves); + append( aToolCurves, aTCurves); + } } + if (aToolCurves.empty()) + { + return false; + } + const int aPSCount = aCurves.size(); const int aTSCount = aToolCurves.size(); std::vector aResult; -- 2.39.2