TopoDS_Shape HYDROData_Profile::GetShape3D() const
{
- return getShape3D();
+ TopoDS_Shape aShape = getShape3D();
+ if( aShape.IsNull() )
+ aShape = CreateProfileWire( true );
+ return aShape;
}
-void HYDROData_Profile::Update()
+TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints ) const
{
- HYDROData_Object::Update();
-
TopoDS_Wire aWire;
Handle(HYDROData_ProfileUZ) aProfile = GetProfileUZ( false );
if ( !aProfile.IsNull() )
{
- ProfilePoints aProfilePoints = GetProfilePoints( false );
+ ProfilePoints aProfilePoints = GetProfilePoints( false, canUseDefaultPoints );
HYDROData_IPolyline::SectionType aSectionType = aProfile->GetSectionType( 0 );
aWire = HYDROData_PolylineXY::BuildWire( aSectionType, false, aProfilePoints );
}
- SetShape3D( aWire );
+ return aWire;
+}
+
+void HYDROData_Profile::Update()
+{
+ HYDROData_Object::Update();
+
+ TopoDS_Shape aShape = CreateProfileWire( false );
+ SetShape3D( aShape );
}
QColor HYDROData_Profile::DefaultFillingColor()
SetToUpdate( true );
}
-bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal ) const
+bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal,
+ bool CanUseDefault ) const
{
+ HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints();
+ if ( aParametricPoints.Length() < 2 )
+ return false;
+
+ thePoint = GetParametricPoints().First();
+
+ thePoint.SetX( 0 );
+ thePoint.SetY( 0 ); //default left point of not-georeferenced profile
TDF_Label aLabel = myLab.FindChild( DataTag_FirstPoint, false );
if ( aLabel.IsNull() )
- return false;
+ {
+ return CanUseDefault;
+ }
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
Handle(TDataStd_RealArray) anArray;
if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
- return false;
+ {
+ return CanUseDefault;
+ }
thePoint.SetX( anArray->Value( 0 ) );
thePoint.SetY( anArray->Value( 1 ) );
SetToUpdate( true );
}
-bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal ) const
+bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal,
+ bool CanUseDefault ) const
{
+ HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints();
+ if ( aParametricPoints.Length() < 2 )
+ return false;
+
+ thePoint = GetParametricPoints().First();
+
TDF_Label aLabel = myLab.FindChild( DataTag_LastPoint, false );
if ( aLabel.IsNull() )
- return false;
+ {
+ return CanUseDefault;
+ }
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
Handle(TDataStd_RealArray) anArray;
if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
- return false;
+ {
+ return CanUseDefault;
+ }
thePoint.SetX( anArray->Value( 0 ) );
thePoint.SetY( anArray->Value( 1 ) );
SetRightPoint( aLastPoint, false );
}
-HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints( bool IsConvertToGlobal ) const
+HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints
+ ( bool IsConvertToGlobal, bool CanUseDefaultLeftRight ) const
{
ProfilePoints aResPoints;
gp_XY aFirstPoint, aLastPoint;
- if ( !GetLeftPoint( aFirstPoint, IsConvertToGlobal ) ||
- !GetRightPoint( aLastPoint, IsConvertToGlobal ) )
+ if ( !GetLeftPoint( aFirstPoint, IsConvertToGlobal, CanUseDefaultLeftRight ) ||
+ !GetRightPoint( aLastPoint, IsConvertToGlobal, CanUseDefaultLeftRight ) )
return aResPoints;
HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints();
* \param thePoint[out] profile first point
* \return true if point has been set
*/
- HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
+ HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false,
+ bool CanUseDefault = false ) const;
/**
* Set last(right) point for profile.
* \param thePoint[out] profile last point
* \return true if point has been set
*/
- HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
-
+ HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false,
+ bool CanUseDefault = false ) const;
/**
* Returns object which store parametric presentation of profile points.
* Empty sequence is returned if first or last point was not set.
* \return profile points list
*/
- HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false ) const;
+ HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false,
+ bool CanUseDefaultLeftRight = false ) const;
/**
*/
HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
+ TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints ) const;
protected: