X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_ProfileUZ.cxx;h=8247cba5c64255dacdfc4933be416e3362ca48df;hb=3b6027a83768bb776f6577b84c31c860fdb83505;hp=36ce31c6a528c9b03c6534072d23fa43c11e3c3d;hpb=deed826b2d6c39ba2ed410108cdf54d64cded321;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx index 36ce31c6..8247cba5 100755 --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -4,12 +4,16 @@ #include "HYDROData_Tool.h" #include +#include #include +#include +#include +#include #include -#include +#include IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline) @@ -24,10 +28,75 @@ HYDROData_ProfileUZ::~HYDROData_ProfileUZ() { } -TopoDS_Wire HYDROData_ProfileUZ::GetWire() const +QStringList HYDROData_ProfileUZ::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aName = GetObjPyName(); + + // Set polilyne data + const TCollection_AsciiString& aSectName = GetSectionName( 0 ); + const SectionType& aSectType = GetSectionType( 0 ); + bool aSectClosure = IsClosedSection( 0 ); + + aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aName ) + .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure ); + + HYDROData_IPolyline::PointsList aSectPointsList = GetPoints( 0 ); + for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k ) + { + const Point& aSectPoint = aSectPointsList.Value( k ); + + aResList << QString( "%1.AddPoint( 0, gp_XY( %2, %3 ) );" ).arg( aName ) + .arg( aSectPoint.X() ).arg( aSectPoint.Y() ); + } + + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aName ); + aResList << QString( "" ); + + return aResList; +} + +TopoDS_Shape HYDROData_ProfileUZ::GetShape() const { // TODO - return TopoDS_Wire(); + return TopoDS_Shape(); +} + +double HYDROData_ProfileUZ::GetDepthFromDistance( const PointsList& thePoints, + const double& theDistance ) +{ + double aResDepth = 0.0; + + int aNbPoints = thePoints.Size(); + if ( aNbPoints < 2 ) + return aResDepth; + + double aCompDist = 0.0; + HYDROData_IPolyline::Point aPrevPoint = thePoints.First(); + for ( int i = 2; i <= aNbPoints; ++i ) + { + const Point& aCurPoint = thePoints.Value( i ); + + double aPntDist = gp_Pnt2d( aPrevPoint.X(), 0 ).Distance( gp_Pnt2d( aCurPoint.X(), 0 ) ); + + aCompDist += aPntDist; + + if ( theDistance < aCompDist ) + { + double aComPntDist = gp_Pnt2d( thePoints.First().X(), 0 ).Distance( gp_Pnt2d( aPrevPoint.X(), 0 ) ); + + double aFindDist = theDistance - aComPntDist; + double aRatio = aFindDist / ( aPntDist - aFindDist ); + + aResDepth = ( aPrevPoint.Y() + aRatio * aCurPoint.Y() ) / ( 1 + aRatio ); + break; + } + + aPrevPoint = aCurPoint; + } + + return aResDepth; } int HYDROData_ProfileUZ::NbSections() const @@ -35,15 +104,59 @@ int HYDROData_ProfileUZ::NbSections() const return 1; } -void HYDROData_ProfileUZ::AddSection( const bool /*theIsClosed*/ ) +void HYDROData_ProfileUZ::AddSection( const TCollection_AsciiString& /*theSectName*/, + const SectionType /*theSectionType*/, + const bool /*theIsClosed*/ ) +{ +} + +TCollection_AsciiString HYDROData_ProfileUZ::GetSectionName( const int /*theSectionIndex*/ ) const +{ + return "Section_1"; +} + +void HYDROData_ProfileUZ::SetSectionName( const int /*theSectionIndex*/, + const TCollection_AsciiString& /*theSectionName*/ ) { } +HYDROData_ProfileUZ::SectionType HYDROData_ProfileUZ::GetSectionType( const int /*theSectionIndex*/ ) const +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aTypesList.IsNull() || aTypesList->IsEmpty() ) + return SECTION_POLYLINE; + + return (SectionType)aTypesList->First(); +} + +void HYDROData_ProfileUZ::SetSectionType( const int /*theSectionIndex*/, + const SectionType theSectionType ) +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList ); + if ( aTypesList.IsNull() ) + return; + + // Refill the existing list + aTypesList->Clear(); + aTypesList->Append( theSectionType ); +} + bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const { return false; } +void HYDROData_ProfileUZ::SetSectionClosed( const int /*theSectionIndex*/, + const bool /*theIsClosed*/ ) +{ +} + void HYDROData_ProfileUZ::RemoveSection( const int /*theSectionIndex*/ ) { RemoveSections(); @@ -118,8 +231,8 @@ void HYDROData_ProfileUZ::AddPoint( const int /*theSectionIndex*/, } void HYDROData_ProfileUZ::SetPoint( const int theSectionIndex, - const int /*thePointIndex*/, - const Point& thePoint ) + const Point& thePoint, + const int /*thePointIndex*/ ) { AddPoint( theSectionIndex, thePoint ); }