X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Polyline3D.cxx;h=15959d971f698ca5499aa347c7d7f3dc604470af;hb=fce3f1240b6161d7cb837344078e5943b90eca65;hp=44ce9a2adf92135b3d0a8d84924ae9221f1ebc68;hpb=fb4a3fcbc15b382e6af6a82329b74418775b6c5e;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Polyline3D.cxx b/src/HYDROData/HYDROData_Polyline3D.cxx index 44ce9a2a..15959d97 100644 --- a/src/HYDROData/HYDROData_Polyline3D.cxx +++ b/src/HYDROData/HYDROData_Polyline3D.cxx @@ -28,10 +28,10 @@ #include -#include -#include - #include +#include +#include +#include #include #include @@ -56,12 +56,11 @@ #include #include -IMPLEMENT_STANDARD_HANDLE(HYDROData_Polyline3D,HYDROData_Object) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Polyline3D,HYDROData_Object) HYDROData_Polyline3D::HYDROData_Polyline3D() -: HYDROData_Object() +: HYDROData_Object( Geom_3d ) { } @@ -69,25 +68,26 @@ HYDROData_Polyline3D::~HYDROData_Polyline3D() { } -QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +QStringList HYDROData_Polyline3D::DumpToPython( const QString& thePyScriptPath, + MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); QString aPolylineName = GetObjPyName(); Handle(HYDROData_PolylineXY) aRefPolyline = GetPolylineXY(); - setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolylineXY" ); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefPolyline, "SetPolylineXY" ); Handle(HYDROData_ProfileUZ) aRefProfileUZ = GetProfileUZ(); if ( !aRefProfileUZ.IsNull() ) { Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aRefProfileUZ->GetFatherObject() ); - if ( checkObjectPythonDefinition( theTreatedObjects, aResList, aProfile ) ) + if ( checkObjectPythonDefinition( thePyScriptPath, theTreatedObjects, aResList, aProfile ) ) { QString aProfileName = aProfile->GetObjPyName(); if ( !aProfileName.isEmpty() ) { - aResList << QString( "%1.SetProfileUZ( %2.GetProfileUZ() );" ) + aResList << QString( "%1.SetProfileUZ( %2.GetProfileUZ() )" ) .arg( aPolylineName ).arg( aProfileName ); } } @@ -102,23 +102,23 @@ QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedO { Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aChildProfileUZ->GetFatherObject() ); - if ( checkObjectPythonDefinition( theTreatedObjects, aResList, aProfile ) ) + if ( checkObjectPythonDefinition( thePyScriptPath, theTreatedObjects, aResList, aProfile ) ) { QString aProfileName = aProfile->GetObjPyName(); if ( !aProfileName.isEmpty() ) { - aResList << QString( "%1.SetChildProfileUZ( %2.GetProfileUZ() );" ) + aResList << QString( "%1.SetChildProfileUZ( %2.GetProfileUZ() )" ) .arg( aPolylineName ).arg( aProfileName ); } } } - setPythonReferenceObject( theTreatedObjects, aResList, aRefBathymetry, "SetAltitudeObject" ); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefBathymetry, "SetAltitudeObject" ); } } aResList << QString( "" ); - aResList << QString( "%1.Update();" ).arg( aPolylineName ); + aResList << QString( "%1.Update()" ).arg( aPolylineName ); aResList << QString( "" ); return aResList; @@ -143,16 +143,6 @@ HYDROData_SequenceOfObjects HYDROData_Polyline3D::GetAllReferenceObjects() const return aResSeq; } -TopoDS_Shape HYDROData_Polyline3D::GetTopShape() const -{ - return getTopShape(); -} - -TopoDS_Shape HYDROData_Polyline3D::GetShape3D() const -{ - return getShape3D(); -} - void HYDROData_Polyline3D::Update() { HYDROData_Object::Update(); @@ -213,35 +203,18 @@ void HYDROData_Polyline3D::Update() TopoDS_Wire aResWire = HYDROData_PolylineXY::BuildWire( aSectionType, anIsSectionClosed, aResPoints ); SetTopShape( aResWire ); SetShape3D( aResWire ); - - double Xmin=0, Xmax=0, Ymin=0, Ymax=0, Zmin=-9999, Zmax=-9999; - Bnd_Box B; - BRepBndLib::Add(aResWire, B); - B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); - DEBTRACE("Bounding Box xyz min:" << Xmin << " " << Ymin << " " << Zmin << " xyz max:" << Xmax << " " << Ymax << " " << Zmax); - SetMiddleZ((Zmin+Zmax)/2.); } -QColor HYDROData_Polyline3D::DefaultFillingColor() +QColor HYDROData_Polyline3D::DefaultFillingColor() const { return QColor( Qt::transparent ); } -QColor HYDROData_Polyline3D::DefaultBorderColor() +QColor HYDROData_Polyline3D::DefaultBorderColor() const { return QColor( Qt::red ); } -QColor HYDROData_Polyline3D::getDefaultFillingColor() const -{ - return DefaultFillingColor(); -} - -QColor HYDROData_Polyline3D::getDefaultBorderColor() const -{ - return DefaultBorderColor(); -} - bool HYDROData_Polyline3D::SetPolylineXY( const Handle(HYDROData_PolylineXY)& thePolyline, const bool theIsUpdateProfile ) { @@ -259,7 +232,7 @@ bool HYDROData_Polyline3D::SetPolylineXY( const Handle(HYDROData_PolylineXY)& th updateChildProfilePoints(); // Indicate model of the need to update the polyline presentation - SetToUpdate( true ); + Changed( Geom_2d ); return true; } @@ -279,7 +252,7 @@ void HYDROData_Polyline3D::RemovePolylineXY() ClearReferenceObjects( DataTag_PolylineXY ); // Indicate model of the need to update the polyline presentation - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_Polyline3D::SetProfileUZ( const Handle(HYDROData_ProfileUZ)& theProfile ) @@ -297,7 +270,7 @@ bool HYDROData_Polyline3D::SetProfileUZ( const Handle(HYDROData_ProfileUZ)& theP RemoveAltitudeObject(); // Indicate model of the need to update the polyline presentation - SetToUpdate( true ); + Changed( Geom_Z ); return true; } @@ -317,7 +290,7 @@ void HYDROData_Polyline3D::RemoveProfileUZ() ClearReferenceObjects( DataTag_ProfileUZ ); // Indicate model of the need to update the polyline presentation - SetToUpdate( true ); + Changed( Geom_Z ); } bool HYDROData_Polyline3D::SetAltitudeObject( @@ -449,7 +422,7 @@ void HYDROData_Polyline3D::removeChildProfileUZ() */ } -HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetPoints() const +HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetPoints( double theEqDistance ) const { Polyline3DPoints aPoints; @@ -500,7 +473,29 @@ HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetPoints() const } else { // Get points from spline curve Standard_Real aStart, anEnd; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve( TopoDS::Edge( anEdges.First() ), aStart, anEnd ); + TopoDS_Edge anEdge = TopoDS::Edge( anEdges.First() ); + Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aStart, anEnd ); + + if( theEqDistance > 0 ) + { + GeomAdaptor_Curve anAdaptorCurve( aCurve ); + double aLength = GCPnts_AbscissaPoint::Length( anAdaptorCurve ); + int aNbPoints = ceil( aLength / theEqDistance ); + GCPnts_QuasiUniformAbscissa aDist( anAdaptorCurve, aNbPoints ); + if( aDist.IsDone() ) + { + aNbPoints = aDist.NbPoints(); + for( int i=1; i<=aNbPoints; i++ ) + { + double p = aDist.Parameter( i ); + gp_Pnt aPnt; + aCurve->D0( p, aPnt ); + aPoints.Append( aPnt.XYZ() ); + } + return aPoints; + } + } + Handle(Geom_BSplineCurve) aGeomSpline = Handle(Geom_BSplineCurve)::DownCast( aCurve ); if ( !aGeomSpline.IsNull() ) {