From: adv Date: Fri, 20 Dec 2013 12:26:40 +0000 (+0000) Subject: Stream creation corrected (Bug #272). X-Git-Tag: BR_hydro_v_0_6~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d6dbaa818a2738c91edcf1303a8a5c54bd44ac6d;p=modules%2Fhydro.git Stream creation corrected (Bug #272). --- diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 2fb2adb4..b9605be3 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -298,6 +298,20 @@ QColor HYDROData_Stream::DefaultBorderColor() return QColor( Qt::transparent ); } +bool HYDROData_Stream::IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theHydAxis ) +{ + if ( theHydAxis.IsNull() ) + return false; + + TopoDS_Shape aHydraulicShape = theHydAxis->GetShape(); + if ( aHydraulicShape.IsNull() || + aHydraulicShape.ShapeType() != TopAbs_WIRE || + BRep_Tool::IsClosed( aHydraulicShape ) ) + return false; // The polyline must be a single not closed wire + + return true; +} + QColor HYDROData_Stream::getDefaultFillingColor() const { return DefaultFillingColor(); @@ -310,20 +324,12 @@ QColor HYDROData_Stream::getDefaultBorderColor() const bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis ) { - Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis(); - - if ( theAxis.IsNull() ) - { - RemoveHydraulicAxis(); - return !aPrevAxis.IsNull(); - } - - if ( IsEqual( aPrevAxis, theAxis ) ) + if ( !IsValidAsAxis( theAxis ) ) return false; - TopoDS_Wire aHydraulicWire = TopoDS::Wire( theAxis->GetShape() ); - if ( aHydraulicWire.IsNull() ) - return false; // The polyline must be a single wire + Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis(); + if ( IsEqual( aPrevAxis, theAxis ) ) + return true; SetReferenceObject( theAxis, DataTag_HydraulicAxis ); @@ -362,7 +368,7 @@ bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_PolylineXY)& theH const TopoDS_Face& thePlane, Standard_Real& outPar) { - if ( theProfile.IsNull() || theHydAxis.IsNull() ) + if ( theProfile.IsNull() || !IsValidAsAxis( theHydAxis ) ) return false; TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() ); //guide line @@ -567,11 +573,14 @@ void HYDROData_Stream::insertProfileInToOrder( const Handle(HYDROData_Profile)& InsertReferenceObject( theProfile, DataTag_Profile, theBeforeIndex ); } -bool HYDROData_Stream::BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis, TopoDS_Face& thePlane) const +bool HYDROData_Stream::BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis, + TopoDS_Face& thePlane ) const { - if ( theHydAxis.IsNull() ) return false; + if ( !IsValidAsAxis( theHydAxis ) ) + return false; + TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() ); - if(aHydraulicWire.IsNull()) return false; + gp_Ax2 aX2(gp::XOY()); gp_Ax3 aX3(aX2); gp_Pln aPln(aX3); diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index 4f364406..4e968be7 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -73,6 +73,10 @@ public: */ HYDRODATA_EXPORT static QColor DefaultBorderColor(); + /** + * Returns true if given polyline can be used as stream axis. + */ + HYDRODATA_EXPORT static bool IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theAxis ); public: // Public methods to work with Stream diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 5882c2f8..822175be 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -366,11 +366,15 @@ void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis ) // Prepare data for intersection check TopoDS_Face aPlane; - if ( anAxis.IsNull() || !myEditedObject->BuildFace(anAxis, aPlane) ) { + if ( !myEditedObject->BuildFace(anAxis, aPlane) ) { + SUIT_MessageBox::critical( module()->getApp()->desktop(), + tr( "BAD_SELECTED_POLYLINE_TLT" ), + tr( "BAD_SELECTED_POLYLINE_MSG" ).arg( theNewAxis ) ); // To restore the old axis updatePanelData(); return; } + Standard_Real aPar(.0); // Get list of profiles which do not intersect the axis diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index bc4dc6cd..7b28a038 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1807,6 +1807,15 @@ file cannot be correctly imported for an Obstacle definition. Do you want to remove these profiles and continue? + + BAD_SELECTED_POLYLINE_TLT + Polyline is not appropriate for channel creation + + + BAD_SELECTED_POLYLINE_MSG + Polyline '%1' can not be used as hydraulic axis for channel. +Polyline should consist from one not closed curve. +