From: isn Date: Wed, 27 Feb 2019 14:49:01 +0000 (+0300) Subject: lot 11 (linear interpolation of stream) untested X-Git-Tag: SH_V2_2_0~99^2~27^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cae2c4634e8f33338e48c886f1ccbd4c6b1ab348;p=modules%2Fhydro.git lot 11 (linear interpolation of stream) untested --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 9c412e81..9594d546 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -67,6 +67,8 @@ set(PROJECT_HEADERS HYDROData_BCPolygon.h HYDROData_BoundaryPolygonTools.h HYDROData_CompleteCalcCase.h + HYDROData_StreamLinearInterpolation.h + HYDROData_LISM.h ) set(PROJECT_SOURCES @@ -132,6 +134,8 @@ set(PROJECT_SOURCES HYDROData_BCPolygon.cxx HYDROData_BoundaryPolygonTools.cxx HYDROData_CompleteCalcCase.cxx + HYDROData_StreamLinearInterpolation.cxx + HYDROData_LISM.cxx ) SET( ECW_INCLUDES $ENV{ECWLIB_ROOT_DIR}/include ) diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index cef1e985..7084a5be 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -148,6 +148,8 @@ QString HYDROData_Entity::Type( ObjectKind theKind ) return "Land_cover_map"; case KIND_DTM: return "DTM"; + case KIND_LISM: + return "LISM"; case KIND_BC_POLYGON: return "Boundary_Polygon"; } diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index f55fa33a..a4bcbd36 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -77,6 +77,7 @@ const ObjectKind KIND_CHANNEL_ALTITUDE = 28; const ObjectKind KIND_LAND_COVER_MAP = 29; const ObjectKind KIND_DTM = 30; const ObjectKind KIND_BC_POLYGON = 31; +const ObjectKind KIND_LISM = 32; const ObjectKind KIND_LAST = KIND_BC_POLYGON+1; class MapOfTreatedObjects : public QMap diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index 46212c31..ef160756 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -45,6 +45,7 @@ #include "HYDROData_Zone.h" #include "HYDROData_StricklerTable.h" #include "HYDROData_DTM.h" +#include #include "HYDROData_BCPolygon.h" #include #include @@ -163,6 +164,7 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel ) case KIND_LAND_COVER_MAP: aResult = new HYDROData_LandCoverMap(); break; case KIND_DTM: aResult = new HYDROData_DTM(); break; case KIND_BC_POLYGON: aResult = new HYDROData_BCPolygon(); break; + case KIND_LISM: aResult = new HYDROData_LISM(); break; default: break; } diff --git a/src/HYDROData/HYDROData_LISM.cxx b/src/HYDROData/HYDROData_LISM.cxx new file mode 100644 index 00000000..f60f03c1 --- /dev/null +++ b/src/HYDROData/HYDROData_LISM.cxx @@ -0,0 +1,162 @@ + +#include +#include +#include +#include + +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT( HYDROData_LISM, HYDROData_Bathymetry ) + +HYDROData_LISM::HYDROData_LISM() +{ +} + +HYDROData_LISM::~HYDROData_LISM() +{ +} + +// +HYDROData_SequenceOfObjects HYDROData_LISM::GetProfiles() const +{ + return GetReferenceObjects( DataTag_Profiles ); +} + +void HYDROData_LISM::SetProfiles( const HYDROData_SequenceOfObjects& theProfiles ) +{ + SetReferenceObjects( theProfiles, DataTag_Profiles ); + Changed( Geom_3d ); +} + +// +bool HYDROData_LISM::SetLeftBank( const Handle(HYDROData_PolylineXY)& theBank ) +{ + if (theBank.IsNull()) + return false; + + if ( !HYDROData_Stream::IsValidAsAxis( theBank ) ) + return false; + + Handle(HYDROData_PolylineXY) aPrevBank = GetLeftBank(); + if ( IsEqual( aPrevBank, theBank ) ) + return true; + + SetReferenceObject( theBank, DataTag_LeftBank ); + Changed( Geom_3d ); + return true; +} + +Handle(HYDROData_PolylineXY) HYDROData_LISM::GetLeftBank() const +{ + return Handle(HYDROData_PolylineXY)::DownCast(GetReferenceObject( DataTag_LeftBank ) ); +} + +bool HYDROData_LISM::SetRightBank( const Handle(HYDROData_PolylineXY)& theBank ) +{ + if (theBank.IsNull()) + return false; + + if ( !HYDROData_Stream::IsValidAsAxis( theBank ) ) + return false; + + Handle(HYDROData_PolylineXY) aPrevBank = GetRightBank(); + if ( IsEqual( aPrevBank, theBank ) ) + return true; + + SetReferenceObject( theBank, DataTag_RightBank ); + Changed( Geom_3d ); + return true; +} + +bool HYDROData_LISM::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis ) +{ + if ( !HYDROData_Stream::IsValidAsAxis( theAxis ) ) + return false; + + Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis(); + if ( IsEqual( aPrevAxis, theAxis ) ) + return true; + + SetReferenceObject( theAxis, DataTag_HydraulicAxis ); + + Changed( Geom_3d ); + return true; +} + +Handle(HYDROData_PolylineXY) HYDROData_LISM::GetHydraulicAxis() const +{ + return Handle(HYDROData_PolylineXY)::DownCast( GetReferenceObject( DataTag_HydraulicAxis ) ); +} + + +Handle(HYDROData_PolylineXY) HYDROData_LISM::GetRightBank() const +{ + return Handle(HYDROData_PolylineXY)::DownCast(GetReferenceObject( DataTag_RightBank ) ); +} + +int HYDROData_LISM::GetNbProfilePoints() const +{ + return GetInteger( DataTag_NbProfilePoints ); +} + +void HYDROData_LISM::SetNbProfilePoints( int theNbProints ) +{ + SetInteger( DataTag_NbProfilePoints, theNbProints ); + Changed( Geom_3d ); +} + +double HYDROData_LISM::GetHaxStep() const +{ + return GetDouble( DataTag_HaxStep ); +} + +void HYDROData_LISM::SetHaxStep( double theHaxStep ) +{ + SetDouble( DataTag_HaxStep, theHaxStep ); + Changed( Geom_3d ); +} + +void HYDROData_LISM::Update() +{ + AltitudePoints anOutPoints; + HYDROData_SequenceOfObjects aRefProfiles = GetProfiles(); + int nbprofilepoints = GetNbProfilePoints(); + double step = GetHaxStep(); + Handle(HYDROData_PolylineXY) aHAX = GetHydraulicAxis(); + Handle(HYDROData_PolylineXY) aLB = GetLeftBank(); + Handle(HYDROData_PolylineXY) aRB = GetRightBank(); + + std::vector warnings; + HYDROData_Stream::PrsDefinition prsDef; + HYDROData_StreamLinearInterpolation::Perform(aRefProfiles, nbprofilepoints, step, aHAX, aLB, aRB, anOutPoints, true, false, prsDef, &warnings); + + SetAltitudePoints( anOutPoints ); + + SetShape( DataTag_LeftBankShape, prsDef.myLeftBank); + SetShape( DataTag_RightBankShape, prsDef.myRightBank); + SetShape( DataTag_InletShape, prsDef.myInlet); + SetShape( DataTag_OutletShape, prsDef.myOutlet ); + SetShape( DataTag_3DShape, prsDef.myPrs3D ); + SetShape( DataTag_2DShape, prsDef.myPrs2D ); + + HYDROData_Bathymetry::Update(); +} + + +void HYDROData_LISM::GetShapePresentations( HYDROData_Stream::PrsDefinition& prsDef) +{ + prsDef.myLeftBank = GetShape( DataTag_LeftBankShape); + prsDef.myRightBank = GetShape( DataTag_RightBankShape); + prsDef.myInlet = GetShape( DataTag_InletShape); + prsDef.myOutlet = GetShape( DataTag_OutletShape ); + prsDef.myPrs3D = GetShape( DataTag_3DShape ); + prsDef.myPrs2D = GetShape( DataTag_2DShape ); +} + + +/*void HYDROData_LISM::GetWarnings(NCollection_DataMap>& warnings) +{ + warnings = myWarnings; +} + */ \ No newline at end of file diff --git a/src/HYDROData/HYDROData_LISM.h b/src/HYDROData/HYDROData_LISM.h new file mode 100644 index 00000000..d19d66fd --- /dev/null +++ b/src/HYDROData/HYDROData_LISM.h @@ -0,0 +1,97 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROData_LISM_HeaderFile +#define HYDROData_LISM_HeaderFile + +#include "HYDROData_Bathymetry.h" +#include "HYDROData_Profile.h" + +#include +#include +#include + +/**\class HYDROData_LISM + * \ + */ +class HYDROData_LISM : public HYDROData_Bathymetry +{ +protected: + /** + * Enumeration of tags corresponding to the persistent object parameters. + */ + enum DataTag + { + DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve + DataTag_Profiles, + DataTag_HaxStep, + DataTag_NbProfilePoints, + DataTag_HydraulicAxis, + DataTag_LeftBank, + DataTag_RightBank, + DataTag_LeftBankShape, + DataTag_RightBankShape, + DataTag_InletShape, + DataTag_OutletShape, + DataTag_3DShape, + DataTag_2DShape + }; + +public: + + HYDRODATA_EXPORT HYDROData_LISM(); + virtual HYDRODATA_EXPORT ~HYDROData_LISM(); + + DEFINE_STANDARD_RTTIEXT( HYDROData_LISM, HYDROData_Bathymetry ); + + HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const; + HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& ); + + HYDRODATA_EXPORT bool SetLeftBank( const Handle(HYDROData_PolylineXY)& theBank ); + HYDRODATA_EXPORT Handle(HYDROData_PolylineXY) GetLeftBank() const; + + HYDRODATA_EXPORT bool SetRightBank( const Handle(HYDROData_PolylineXY)& theBank ); + HYDRODATA_EXPORT Handle(HYDROData_PolylineXY) GetRightBank() const; + + HYDRODATA_EXPORT bool SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis ); + HYDRODATA_EXPORT Handle(HYDROData_PolylineXY) GetHydraulicAxis() const; + + HYDRODATA_EXPORT int GetNbProfilePoints() const; + HYDRODATA_EXPORT void SetNbProfilePoints( int ); + + HYDRODATA_EXPORT double GetHaxStep() const; + HYDRODATA_EXPORT void SetHaxStep( double ); + + HYDRODATA_EXPORT virtual void Update(); + + HYDRODATA_EXPORT void GetShapePresentations( HYDROData_Stream::PrsDefinition& prsDef); + + + +public: + + //HYDRODATA_EXPORT void GetWarnings(NCollection_DataMap>& warnings); + +protected: + //NCollection_DataMap> myWarnings; +}; + + + + +#endif diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index ae79ef48..3ec51658 100644 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -435,19 +435,27 @@ void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints, bool I HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints ( bool IsConvertToGlobal, bool CanUseDefaultLeftRight ) const { - ProfilePoints aResPoints; - gp_XY aFirstPoint, aLastPoint; if ( !GetLeftPoint( aFirstPoint, IsConvertToGlobal, CanUseDefaultLeftRight ) || !GetRightPoint( aLastPoint, IsConvertToGlobal, CanUseDefaultLeftRight ) ) - return aResPoints; + return HYDROData_Profile::ProfilePoints(); HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints(); - if ( aParametricPoints.Length() < 2 ) + + return CalculateProfilePoints(aParametricPoints, aFirstPoint, aLastPoint); +} + +HYDROData_Profile::ProfilePoints HYDROData_Profile::CalculateProfilePoints( + const HYDROData_ProfileUZ::PointsList& theParametricPoints, + const gp_XY& aFirstPoint, const gp_XY& aLastPoint) +{ + ProfilePoints aResPoints; + + if ( theParametricPoints.Length() < 2 ) return aResPoints; - const HYDROData_ProfileUZ::Point& aFirstParPoint = aParametricPoints.First(); - const HYDROData_ProfileUZ::Point& aLastParPoint = aParametricPoints.Last(); + const HYDROData_ProfileUZ::Point& aFirstParPoint = theParametricPoints.First(); + const HYDROData_ProfileUZ::Point& aLastParPoint = theParametricPoints.Last(); double aFullLength = aLastPoint.X() - aFirstPoint.X(); double aParFullLength = aLastParPoint.X() - aFirstParPoint.X(); @@ -456,9 +464,9 @@ HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints aResPoints.Append( ProfilePoint( aFirstPoint.X(), aFirstPoint.Y(), aFirstParPoint.Y() ) ); // Compute all other points - for ( int i = 2, n = aParametricPoints.Length(); i < n ; ++i ) + for ( int i = 2, n = theParametricPoints.Length(); i < n ; ++i ) { - const HYDROData_ProfileUZ::Point& aParPoint = aParametricPoints.Value( i ); + const HYDROData_ProfileUZ::Point& aParPoint = theParametricPoints.Value( i ); double aParPointDist = aParPoint.X() - aFirstParPoint.X(); double aRatio = aParPointDist / aParFullLength; diff --git a/src/HYDROData/HYDROData_Profile.h b/src/HYDROData/HYDROData_Profile.h index 94ca5bb2..cdac0d31 100644 --- a/src/HYDROData/HYDROData_Profile.h +++ b/src/HYDROData/HYDROData_Profile.h @@ -83,6 +83,9 @@ public: HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); + HYDRODATA_EXPORT static ProfilePoints CalculateProfilePoints(const HYDROData_ProfileUZ::PointsList& theParametricPoints, + const gp_XY& aFirstPoint, const gp_XY& aLastPoint); + /** * Returns default filling color for new profile. */ diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 6ecd009f..8b458e2a 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -28,6 +28,8 @@ #include "HYDROData_IProfilesInterpolator.h" #include "HYDROData_Tool.h" #include "HYDROData_DTM.h" +#include "HYDROData_LISM.h" + #include #include @@ -177,27 +179,40 @@ void HYDROData_Stream::GetWarnings(NCollection_DataMapGetPolylineXY(); - if ( !aPolylineXY.IsNull() ) { - aPolylineXY->Update(); + if (GetInterpolationMethod() == 0) + { + if (!GetHydraulicAxis().IsNull()) + updateProfilesOrder(); + + // Update bottom polyline if exists + const Handle(HYDROData_Polyline3D) aBottomPolyline = GetBottomPolyline(); + if ( !aBottomPolyline.IsNull() ) { + if ( GenerateBottomPolyline() ) { + Handle(HYDROData_PolylineXY) aPolylineXY = aBottomPolyline->GetPolylineXY(); + if ( !aPolylineXY.IsNull() ) { + aPolylineXY->Update(); + } + aBottomPolyline->Update(); } - aBottomPolyline->Update(); } - } - Handle(HYDROData_DTM) dtm = DTM(); - dtm->Update(); - UpdatePrs( dtm ); + Handle(HYDROData_DTM) dtm = DTM(); + dtm->Update(); + UpdatePrs( dtm ); + + myWarnings.Clear(); + dtm->GetWarnings(myWarnings); + } + else + { + Handle(HYDROData_LISM) lism = LISM(); + lism->Update(); + UpdatePrs( lism ); - myWarnings.Clear(); - dtm->GetWarnings(myWarnings); + myWarnings.Clear(); + //lism->GetWarnings(myWarnings); + //TODO warnings + } HYDROData_NaturalObject::Update(); } @@ -253,14 +268,8 @@ bool HYDROData_Stream::CreatePresentations( const Handle(HYDROData_DTM)& theDTM, return true; } -void HYDROData_Stream::UpdatePrs( const Handle(HYDROData_DTM)& theDTM ) +void HYDROData_Stream::internalUpdatePrs( const PrsDefinition& aResultPrs ) { - HYDROData_NaturalObject::Update(); - - PrsDefinition aResultPrs; - if ( !CreatePresentations( theDTM, aResultPrs ) ) - return; - SetShape3D( aResultPrs.myPrs3D ); SetTopShape( aResultPrs.myPrs2D ); @@ -290,6 +299,27 @@ void HYDROData_Stream::UpdatePrs( const Handle(HYDROData_DTM)& theDTM ) anOutGroup->AddShape( aResultPrs.myOutlet ); } + +void HYDROData_Stream::UpdatePrs( const Handle(HYDROData_DTM)& theDTM ) +{ + HYDROData_NaturalObject::Update(); + + PrsDefinition aResultPrs; + if ( !CreatePresentations( theDTM, aResultPrs ) ) + return; + + internalUpdatePrs(aResultPrs); +} + +void HYDROData_Stream::UpdatePrs( const Handle(HYDROData_LISM)& theLISM ) +{ + HYDROData_NaturalObject::Update(); + PrsDefinition prsDef; + theLISM->GetShapePresentations(prsDef); + + internalUpdatePrs(prsDef); +} + QColor HYDROData_Stream::DefaultFillingColor() const { return QColor( Qt::green ); @@ -344,6 +374,12 @@ Handle(HYDROData_DTM) HYDROData_Stream::DTM() const return Handle(HYDROData_DTM)::DownCast( GetAltitudeObject() ); } +Handle(HYDROData_LISM) HYDROData_Stream::LISM() const +{ + const_cast( this )->checkAndSetAltitudeObject(); + return Handle(HYDROData_LISM)::DownCast( GetAltitudeObject() ); +} + double HYDROData_Stream::GetDDZ() const { return DTM()->GetDDZ(); @@ -354,42 +390,103 @@ void HYDROData_Stream::SetDDZ( double theDDZ ) DTM()->SetDDZ( theDDZ ); Changed( Geom_3d ); } + +Handle(HYDROData_PolylineXY) HYDROData_Stream::GetLeftBank() const +{ + return LISM()->GetLeftBank(); +} + +void HYDROData_Stream::SetLeftBank( const Handle(HYDROData_PolylineXY)& theBank ) +{ + LISM()->SetLeftBank( theBank ); + Changed( Geom_3d ); +} + +Handle(HYDROData_PolylineXY) HYDROData_Stream::GetRightBank() const +{ + return LISM()->GetRightBank(); +} + +void HYDROData_Stream::SetRightBank( const Handle(HYDROData_PolylineXY)& theBank ) +{ + LISM()->SetRightBank( theBank ); + Changed( Geom_3d ); +} + + +double HYDROData_Stream::GetHaxStep() const +{ + return LISM()->GetHaxStep(); +} + +void HYDROData_Stream::SetHaxStep( double theHaxStep ) +{ + LISM()->SetHaxStep( theHaxStep ); + Changed( Geom_3d ); +} + +int HYDROData_Stream::GetNbProfilePoints() const +{ + return LISM()->GetNbProfilePoints(); +} + +void HYDROData_Stream::SetNbProfilePoints( int theNbPoints ) +{ + LISM()->SetNbProfilePoints( theNbPoints ); + Changed( Geom_3d ); +} double HYDROData_Stream::GetSpatialStep() const { - return DTM()->GetSpatialStep(); + if (GetInterpolationMethod() == 0) + return DTM()->GetSpatialStep(); + else + return LISM()->GetHaxStep(); } void HYDROData_Stream::SetSpatialStep( double theSpatialStep ) { - DTM()->SetSpatialStep( theSpatialStep ); + if (GetInterpolationMethod() == 0 ) + DTM()->SetSpatialStep( theSpatialStep ); + else + LISM()->SetHaxStep( theSpatialStep ); Changed( Geom_3d ); } bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis ) { - if ( !IsValidAsAxis( theAxis ) ) - return false; + if (GetInterpolationMethod() == 0) + { + if ( !IsValidAsAxis( theAxis ) ) + return false; - Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis(); - if ( IsEqual( aPrevAxis, theAxis ) ) - return true; + Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis(); + if ( IsEqual( aPrevAxis, theAxis ) ) + return true; - SetReferenceObject( theAxis, DataTag_HydraulicAxis ); + SetReferenceObject( theAxis, DataTag_HydraulicAxis ); - // Update the order of profiles - updateProfilesOrder(); + // Update the order of profiles + updateProfilesOrder(); - // Indicate model of the need to update the stream presentation - Changed( Geom_3d ); + // Indicate model of the need to update the stream presentation + Changed( Geom_3d ); + } + else + { + LISM()->SetHydraulicAxis( theAxis ); + Changed( Geom_3d ); + } return true; } Handle(HYDROData_PolylineXY) HYDROData_Stream::GetHydraulicAxis() const { - return Handle(HYDROData_PolylineXY)::DownCast( - GetReferenceObject( DataTag_HydraulicAxis ) ); + if (GetInterpolationMethod() == 0) + return Handle(HYDROData_PolylineXY)::DownCast( GetReferenceObject( DataTag_HydraulicAxis ) ); + else + return LISM()->GetHydraulicAxis(); } void HYDROData_Stream::RemoveHydraulicAxis() @@ -561,7 +658,10 @@ bool HYDROData_Stream::AddProfile( const Handle(HYDROData_Profile)& theProfile ) int aProfileIndex = insertParameter( aPar ); insertProfileInToOrder( theProfile, aProfileIndex ); - DTM()->SetProfiles( GetProfiles() ); + if (GetInterpolationMethod()==0) + DTM()->SetProfiles( GetProfiles() ); + else + LISM()->SetProfiles( GetProfiles() ); // Indicate model of the need to update the stream presentation Changed( Geom_3d ); @@ -616,7 +716,10 @@ bool HYDROData_Stream::SetProfiles( const HYDROData_SequenceOfObjects& theProfil Changed( Geom_3d ); } - DTM()->SetProfiles( GetProfiles() ); + if (GetInterpolationMethod()==0) + DTM()->SetProfiles( GetProfiles() ); + else + LISM()->SetProfiles( GetProfiles() ); return true; } @@ -673,6 +776,19 @@ void HYDROData_Stream::RemoveProfiles() Changed( Geom_3d ); } + +int HYDROData_Stream::GetInterpolationMethod() const +{ + return GetInteger( DataTag_InterpMethod ); +} + +void HYDROData_Stream::SetInterpolationMethod( int theMethod ) //if DTM => 0 ; if LISM => 1 +{ + SetInteger( DataTag_InterpMethod, theMethod ); + Changed( Geom_3d ); +} + + void HYDROData_Stream::insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile, const int theBeforeIndex ) { @@ -776,7 +892,11 @@ void HYDROData_Stream::updateProfilesOrder() ObjectKind HYDROData_Stream::getAltitudeObjectType() const { - return KIND_DTM; + int InterpMethod = GetInterpolationMethod(); + if (InterpMethod == 1) + return KIND_LISM; + else + return KIND_DTM; } void HYDROData_Stream::setParametersArray( const QVector& theArray ) diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index b297484d..4d57079a 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -31,6 +31,7 @@ #include class HYDROData_DTM; +class HYDROData_LISM; class HYDROData_PolylineXY; class HYDROData_Polyline3D; class HYDROData_Profile; @@ -66,7 +67,8 @@ protected: DataTag_HydraulicAxis, ///< reference hydraulic axis DataTag_Profile, ///< reference profiles DataTag_ParamsArray, ///< parameters array - DataTag_BottomPolyline ///< reference bottom polyline + DataTag_BottomPolyline, ///< reference bottom polyline + DataTag_InterpMethod ///< interpolation method (via DTM(0) or LISM(1)) }; public: @@ -119,6 +121,8 @@ public: */ HYDRODATA_EXPORT void UpdatePrs( const Handle(HYDROData_DTM)& ); + HYDRODATA_EXPORT void UpdatePrs( const Handle(HYDROData_LISM)& theLISM ); + /** * */ @@ -183,6 +187,13 @@ public: */ HYDRODATA_EXPORT virtual void RemoveHydraulicAxis(); + HYDRODATA_EXPORT Handle(HYDROData_PolylineXY) GetLeftBank() const; + + HYDRODATA_EXPORT void SetLeftBank( const Handle(HYDROData_PolylineXY)& theBank ); + + HYDRODATA_EXPORT Handle(HYDROData_PolylineXY) GetRightBank() const; + + HYDRODATA_EXPORT void SetRightBank( const Handle(HYDROData_PolylineXY)& theBank ); /** * Returns true if profile has the intersection with the given hydraulic axis. * Returns the parameter of inresection point on axis if axis is presented by one curve, @@ -262,9 +273,18 @@ public: HYDRODATA_EXPORT double GetDDZ() const; HYDRODATA_EXPORT void SetDDZ( double theDDZ ); + HYDRODATA_EXPORT int GetInterpolationMethod() const; + HYDRODATA_EXPORT void SetInterpolationMethod( int theDDZ ); + HYDRODATA_EXPORT double GetSpatialStep() const; HYDRODATA_EXPORT void SetSpatialStep( double theSpatialStep ); + HYDRODATA_EXPORT double GetHaxStep() const; + HYDRODATA_EXPORT void SetHaxStep( double theHaxStep ); + + HYDRODATA_EXPORT int GetNbProfilePoints() const; + HYDRODATA_EXPORT void SetNbProfilePoints( int theNbPoints ); + HYDRODATA_EXPORT void GetWarnings(NCollection_DataMap>& warnings); @@ -308,6 +328,10 @@ private: Handle(HYDROData_DTM) DTM() const; + Handle(HYDROData_LISM) LISM() const; + + void internalUpdatePrs( const PrsDefinition& aResultPrs ); + protected: friend class HYDROData_Iterator; diff --git a/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx b/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx new file mode 100644 index 00000000..9cea6d8c --- /dev/null +++ b/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx @@ -0,0 +1,541 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROData_StreamLinearInterpolation.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static std::vector GetProfileUZPoints(const Handle(HYDROData_Profile)& theProfile) +{ + Handle(HYDROData_ProfileUZ) aProfileUZ = theProfile->GetProfileUZ( false ); + HYDROData_ProfileUZ::PointsList aSectPointsList = aProfileUZ->GetPoints(); + std::vector points; + points.reserve(aSectPointsList.Size()); + for ( int i = 1; i <= aSectPointsList.Size(); i++ ) + { + const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList(i); + points.push_back( gp_Pnt2d(aSectPoint.X(), aSectPoint.Y())); + } + return points; +} + +static void GetMaxDist(const std::vector& PNTS, + double& dmax, + double& dmax2, + int& imax) +{ + dmax = 0; + dmax2 = 0; + imax = -1; + std::vector dist; + dist.reserve(PNTS.size()-1); + for (int i=0; i dmax) + { + dmax = d; + imax = i; + } + } + for (int i=0; i dmax2 && d < dmax) + dmax2 = d; + } +} + +static void InsertPoints(std::vector& points, int nbpoints) +{ + points.reserve(points.size() + nbpoints); + while (nbpoints) + { + double dmax=0, dmax2=0; + int imax=-1; + GetMaxDist(points, dmax, dmax2, imax); + int nbPins = 0; + if (dmax2 != 0) + nbPins = floor(dmax/dmax2); + else + nbPins = nbpoints; //one segment, put all points here + //insert nbPins points in [imax, imax+1] segment + gp_Pnt2d p1 = points[imax]; + gp_Pnt2d p2 = points[imax+1]; + double X0 = p1.X(); + double Y0 = p1.Y(); + double X1 = p2.X(); + double Y1 = p2.Y(); + for (int i=0;iGetShape(); + if (sh.ShapeType() == TopAbs_COMPOUND) + { + TopoDS_Iterator it(sh); + if (it.More()) + sh = it.Value(); + } + + if (sh.IsNull()) + return; + + TopoDS_Edge ee; + if (sh.ShapeType() == TopAbs_EDGE) + ee = TopoDS::Edge(sh); + else if (sh.ShapeType() == TopAbs_WIRE) + ee = BRepAlgo::ConcatenateWireC0(TopoDS::Wire(sh)); //convert to bspline + + if (ee.IsNull()) + return; + + BRepAdaptor_Curve Ad(ee); + + c2d = HYDROData_Tool::BRepAdaptorTo2DCurve(Ad); +} + +static void InterProfilesAndHAX(const HYDROData_SequenceOfObjects& profiles, + const Handle(Geom2d_Curve)& Hax2d, + std::map& profToInterParam, + std::vector* warnings) +{ + for (int i=1;i<=profiles.Size();i++) + { + Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(profiles(i)); + gp_XY LP, RP; + aProfile->GetLeftPoint( LP, true, true ); + aProfile->GetRightPoint( RP, true, true ); + gp_Pnt2d P1(LP), P2(RP); + double d = P2.Distance(P1); + if (d < gp::Resolution()) + { + if (warnings) + warnings->push_back(aProfile->GetName().toStdString() + " is skipped: Left and Right points is the same"); + continue; + } + Handle(Geom2d_Line) lin2d = new Geom2d_Line(P1,gp_Dir2d(P2.XY()-P1.XY())); + + Geom2dAdaptor_Curve linAd(lin2d, 0, d); + Geom2dAdaptor_Curve haxAd(Hax2d); + Geom2dInt_GInter isec( linAd, haxAd, 1.0e-6, 1.0e-6); + if (!isec.IsDone()) + { + if (warnings) + warnings->push_back(aProfile->GetName().toStdString() + " is skipped: intersection between hydraulic axis & profile is failed"); + continue; + } + if (isec.NbPoints() == 0) + { + if (warnings) + warnings->push_back(aProfile->GetName().toStdString() + " is skipped: no intersection between hydraulic axis & profile"); + continue; + } + if (isec.NbPoints() > 1) + { + if (warnings) + warnings->push_back(aProfile->GetName().toStdString() + " is skipped; intersection between hydraulic axis & profile produces more than 1 point"); + continue; + } + double param = isec.Point(1).ParamOnSecond(); + profToInterParam[param] = aProfile; + } +} + +static bool EquidParamsOnHAX(const Handle(Geom2d_Curve)& Hax2d, double step, double fp, double lp, std::set& params) +{ + Geom2dAdaptor_Curve ad(Hax2d); + GCPnts_UniformAbscissa GUA(ad, step, fp, lp); + if (!GUA.IsDone()) + return false; + + for(int i = 1; i<= GUA.NbPoints(); i++) + params.insert(GUA.Parameter(i)); + + return true; +} + +static void GetPointsOnBanks(const std::vector& gua_params, + const Handle(Geom2d_Curve)& Hax2d, + const Handle(Geom2d_Curve)& LB2d, + const Handle(Geom2d_Curve)& RB2d, + std::map>& parToBankPoints, + std::vector* warnings) +{ + for(int i = 0; i < gua_params.size(); i++) + { + double par = gua_params[i]; + gp_Pnt2d p; + gp_Vec2d v; + Hax2d->D1(par, p, v); //if non-diff? + gp_Pnt2d outpLB, outpRB; + + gp_Dir2d n2d(v.X(), v.Y()); //ignore Z (Z==0) + n2d.Rotate(M_PI/2); + //nLine2d is an orthogonal line to hydr. axis + gp_Pnt2d p2d(gp_Pnt2d(p.X(), p.Y())); + Handle(Geom2d_Line) nLine2d = new Geom2d_Line(p2d, n2d); + //intersect nLine2d with banks + Geom2dAPI_InterCurveCurve intL(LB2d, nLine2d); + Geom2dAPI_InterCurveCurve intR(RB2d, nLine2d); + + if (warnings && intL.NbPoints()==0 ) + { + std::string coord = (QString::number(p2d.X()) + ", "+QString::number(p2d.Y())).toStdString(); + warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ coord +")) and left bank found; skipped"); + } + + if (warnings && intR.NbPoints()==0) + { + std::string coord = (QString::number(p2d.X()) + ", "+QString::number(p2d.Y())).toStdString(); + warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ coord +")) and right bank found; skipped"); + } + + if ( intL.NbPoints()==0 || intR.NbPoints()==0) + continue; + + gp_Pnt2d aNearSolL, aNearSolR; + double min_sq_dist = Precision::Infinite(); + for (int j=1;j<=intL.NbPoints();j++) + { + double sq_dist = p2d.SquareDistance(intL.Point(j)); + if (min_sq_dist > sq_dist) + { + min_sq_dist = sq_dist; + aNearSolL = intL.Point(j); + } + } + min_sq_dist = Precision::Infinite(); + for (int j=1;j<=intR.NbPoints();j++) + { + double sq_dist = p2d.SquareDistance(intR.Point(j)); + if (min_sq_dist > sq_dist) + { + min_sq_dist = sq_dist; + aNearSolR = intR.Point(j); + } + } + + std::pair int_pair(aNearSolL, aNearSolR); + parToBankPoints[par]=int_pair; + } +} + + +bool GetItersectionParam(const Handle(HYDROData_Profile)& aProfile, const Handle(Geom2d_Curve)& B2d, double& outIntersectionParam) +{ + gp_XY LP, RP; + aProfile->GetLeftPoint( LP, true, true ); + aProfile->GetRightPoint( RP, true, true ); + gp_Pnt2d P1(LP), P2(RP); + double d = P2.Distance(P1); + if (d < gp::Resolution()) + return false; + Handle(Geom2d_Line) lin2d = new Geom2d_Line(P1,gp_Dir2d(P2.XY()-P1.XY())); + + Geom2dAdaptor_Curve linAd(lin2d, 0, d); + Geom2dAdaptor_Curve BAd(B2d); + Geom2dInt_GInter isec( linAd, BAd, 1.0e-6, 1.0e-6); + if (!isec.IsDone()) + return false; + if (isec.NbPoints() == 0) + return false; + if (isec.NbPoints() > 1) + return false; + outIntersectionParam = isec.Point(1).ParamOnSecond(); + return true; +} + +void BuildFace(const Handle(HYDROData_Profile)& F_prof, + const Handle(HYDROData_Profile)& S_prof, + const Handle(Geom2d_Curve)& LB2d, + const Handle(Geom2d_Curve)& RB2d, + HYDROData_Stream::PrsDefinition& prsDef) +{ + prsDef.myPrs3D.Nullify(); + prsDef.myPrs2D.Nullify(); + prsDef.myLeftBank.Nullify(); + prsDef.myRightBank.Nullify(); + prsDef.myInlet.Nullify(); + prsDef.myOutlet.Nullify(); + + bool stat = true; + double lb_1, lb_2, rb_1, rb_2; + stat = GetItersectionParam(F_prof, LB2d, lb_1) && GetItersectionParam(F_prof, RB2d, rb_1) + && GetItersectionParam(S_prof, LB2d, lb_2) && GetItersectionParam(S_prof, RB2d, rb_2); + if (stat) + { + BRepBuilderAPI_MakeEdge2d LEM(LB2d, lb_1, lb_2); + if (!LEM.IsDone()) + return; + BRepBuilderAPI_MakeEdge2d REM(RB2d, rb_1, rb_2); + if (!REM.IsDone()) + return; + TopoDS_Edge LBE = LEM.Edge(); + TopoDS_Edge RBE = REM.Edge(); + if (LBE.IsNull() || RBE.IsNull()) + return; + BRepBuilderAPI_MakeEdge PFEM(BRep_Tool::Pnt(LEM.Vertex1()), BRep_Tool::Pnt(REM.Vertex1())); + BRepBuilderAPI_MakeEdge PLEM(BRep_Tool::Pnt(LEM.Vertex2()), BRep_Tool::Pnt(REM.Vertex2())); + if (!PFEM.IsDone()) + return; + if (!PLEM.IsDone()) + return; + TopoDS_Edge FProfE = PFEM.Edge(); + TopoDS_Edge SProfE = PLEM.Edge(); + BRepBuilderAPI_MakeWire WM(FProfE, LBE, SProfE, RBE); + if (WM.IsDone()) + { + TopoDS_Wire W = WM.Wire(); + BRepLib::BuildCurves3d(W); + BRepBuilderAPI_MakeFace FM(Geom_Plane(gp::XOY()).Pln(), WM.Wire()); + if (FM.IsDone()) + { + prsDef.myPrs2D = FM.Face(); + prsDef.myLeftBank = LBE; + prsDef.myRightBank = RBE; + prsDef.myInlet = FProfE; + prsDef.myOutlet = SProfE; + } + } + } +} + +void HYDROData_StreamLinearInterpolation::Perform(const HYDROData_SequenceOfObjects& profiles, + int pointsToInsert, + double stepOnHA, + const Handle(HYDROData_PolylineXY)& hax, + const Handle(HYDROData_PolylineXY)& LB, + const Handle(HYDROData_PolylineXY)& RB, + HYDROData_Bathymetry::AltitudePoints& outBathypoints, + bool buildPresentationShapes, + bool estimateWarnOnly, + HYDROData_Stream::PrsDefinition& prsDef, + std::vector* warnings) +{ + //intersect profiles with given hydr.axis + if (hax.IsNull() || LB.IsNull() || RB.IsNull()) + return; + + Handle(Geom2d_Curve) Hax2d; + PolyToCurve2d(hax, Hax2d); + if (Hax2d->IsClosed()) //can't be closed + { + if (warnings) + warnings->push_back(hax->GetName().toStdString() + " is closed; abort"); + return; + } + + std::map InterParamToProf; + //profToInterParam is output param map: profile to intersection param on hydr.axis + InterProfilesAndHAX(profiles, Hax2d, InterParamToProf, warnings); + // + std::vector> profilesPoints; + profilesPoints.reserve(InterParamToProf.size()); + int maxNbPoints = 0; + + //for (int i=1;i<=InterParamToProf.Extent();i++) + for( std::map::iterator it = InterParamToProf.begin(); it != InterParamToProf.end(); ++it ) + { + //ordered by param on hydr axis + Handle(HYDROData_Profile) aProfile = it->second; + const std::vector& profile_points = GetProfileUZPoints(aProfile); + profilesPoints.push_back(profile_points); + if (profile_points.size() > maxNbPoints) + maxNbPoints = profile_points.size(); + } + std::set paramsOnHAX; + + if (InterParamToProf.size() <= 1) + { + if (warnings) + warnings->push_back("Insufficient count of correct input profiles; abort"); + return; + } + + EquidParamsOnHAX(Hax2d, stepOnHA, InterParamToProf.begin()->first, + InterParamToProf.rbegin()->first, paramsOnHAX); + + //prepare ParamsPerSegm - number of interm.profiles for profile_points + std::vector> ParamsPerSegm; + std::set::iterator it_params_hax = paramsOnHAX.begin(); + std::map::iterator it_p = InterParamToProf.begin(); + it_p++; + ParamsPerSegm.resize(profilesPoints.size()-1); + for( int k=0; it_p != InterParamToProf.end(); ) + { + if (*it_params_hax < it_p->first) + { + ParamsPerSegm[k].push_back(*it_params_hax); + it_params_hax++; + } + else + { + it_p++; + k++; + } + } + ParamsPerSegm.back().push_back(*paramsOnHAX.rbegin()); + // + std::map> parToBankPoints; + std::vector paramHAXVec; + paramHAXVec.reserve(paramsOnHAX.size()); + for( std::set::iterator it = paramsOnHAX.begin(); it != paramsOnHAX.end(); ++it ) + paramHAXVec.push_back(*it); + // + Handle(Geom2d_Curve) LB2d, RB2d; + PolyToCurve2d(LB, LB2d); + PolyToCurve2d(RB, RB2d); + GetPointsOnBanks( paramHAXVec, Hax2d, LB2d, RB2d, parToBankPoints, warnings); + + if (buildPresentationShapes) + { + Handle(HYDROData_Profile) F_prof = InterParamToProf.begin()->second; + Handle(HYDROData_Profile) S_prof = InterParamToProf.rbegin()->second; + BuildFace(F_prof, S_prof, LB2d, RB2d, prsDef); + } + // + + if (estimateWarnOnly) + return; + + maxNbPoints = Max(pointsToInsert, maxNbPoints); + + //insert points to profiles + for (int i=0;i& prof1 = profilesPoints[i]; + const std::vector& prof2 = profilesPoints[i+1]; + std::vector> IntermProf; + + std::map indToParam; //index of im.profile to param on hax. () + for (int j=0;j 0) //not intersected with banks; skip this + indToParam[j]=param; + } + int NbIntermProf = indToParam.size(); + IntermProf.resize(NbIntermProf); + + for (int l=0;l::iterator it = indToParam.begin(); + for ( int m=0; it != indToParam.end(); it++, m++ ) + { + int ind = it->first; + double t = ((double)ind+1)/((double)NbIntermProf+1); + double Xp = X0 + (X1-X0)*t; + double Yp = Y0 + (Y1-Y0)*t; + gp_Pnt2d P(Xp, Yp); + IntermProf[m][j] = P; + } + } + std::map::iterator it = indToParam.begin(); + for ( int m=0; it != indToParam.end(); it++, m++ ) + { + const std::vector& im_prof = IntermProf[m]; + double param = it->second; + const std::pair& BB = parToBankPoints[param]; //param is included in map; no checks + gp_Pnt2d LP = BB.first; + gp_Pnt2d RP = BB.second; + HYDROData_ProfileUZ::PointsList pl; + for (int k=0;kSetAltitudePoints(bathypoints); +} + + + diff --git a/src/HYDROData/HYDROData_StreamLinearInterpolation.h b/src/HYDROData/HYDROData_StreamLinearInterpolation.h new file mode 100644 index 00000000..557f578c --- /dev/null +++ b/src/HYDROData/HYDROData_StreamLinearInterpolation.h @@ -0,0 +1,50 @@ +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _HYDROData_HYDRODATA_STREAMLINEARINTERPOLATION_HXX_ +#define _HYDROData_HYDROData_STREAMLINEARINTERPOLATION_HXX_ + +#include +#include +#include +#include +#include +class TopoDS_Face; + +class HYDROData_StreamLinearInterpolation +{ +public: + +HYDRODATA_EXPORT static void Perform(const HYDROData_SequenceOfObjects& profiles, + int pointsToInsert, + double stepOnHA, + const Handle(HYDROData_PolylineXY)& hax, + const Handle(HYDROData_PolylineXY)& LB, + const Handle(HYDROData_PolylineXY)& RB, + HYDROData_Bathymetry::AltitudePoints& outBathypoints, + bool buildPresentationShapes, + bool estimateWarnOnly, + HYDROData_Stream::PrsDefinition& prsDef, + std::vector* warnings = NULL); +}; + +#endif diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index f5b1acfc..4cd66c6a 100755 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -70,7 +70,16 @@ #include #include #include - +#include +#include +#include +#include +#include +#include + +#include +#include +#include #include #define BLOCK_SIZE 10000 @@ -899,6 +908,38 @@ bool HYDROData_Tool::importPolylineFromXYZ(QString aFileName, Handle(HYDROData_D } + + +Handle(Geom2d_Curve) HYDROData_Tool::BRepAdaptorTo2DCurve( const BRepAdaptor_Curve& ad ) +{ + if( ad.GetType() == GeomAbs_Line) + { + double f = ad.FirstParameter(); + double l = ad.LastParameter(); + return new Geom2d_TrimmedCurve( GeomAPI::To2d(ad.Curve().Curve(), Geom_Plane(gp::XOY()).Pln()), f, l ); + } + + if( ad.GetType() == GeomAbs_BSplineCurve ) + { + //just ignore Z coord, without projecting + Handle(Geom_BSplineCurve) aSpline = ad.Curve().BSpline(); + if (aSpline.IsNull()) + return Handle(Geom2d_Curve)(); + TColgp_Array1OfPnt poles3d = aSpline->Poles(); + TColgp_HArray1OfPnt2d poles2d(poles3d.Lower(), poles3d.Upper()); + for (int i=poles3d.Lower(); i<=poles3d.Upper();i++) + { + gp_XY p2d(poles3d(i).X(), poles3d(i).Y()); + poles2d(i).SetXY(p2d); + } + const TColStd_Array1OfReal& knots = aSpline->Knots(); + const TColStd_Array1OfInteger& multiplicities = aSpline->Multiplicities(); + int aDegree = aSpline->Degree(); + return new Geom2d_BSplineCurve( poles2d, knots, multiplicities, aDegree ); + } + return Handle(Geom2d_Curve)(); +} + std::ostream& operator<<( std::ostream& theStream, const QString& theText ) { theStream << theText.toStdString(); diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index c7bd4fe6..f8bec7df 100755 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include class HYDROData_PolylineXY; @@ -160,6 +163,7 @@ public: static bool importPolylineFromXYZ(QString aFilename, Handle(HYDROData_Document) theDocument, bool importXY, NCollection_Sequence& importedEntities); + static Handle(Geom2d_Curve) BRepAdaptorTo2DCurve( const BRepAdaptor_Curve& ad ); static void SetSIProgress(const Handle(Message_ProgressIndicator)& thePI); static const Handle(Message_ProgressIndicator)& GetSIProgress(); @@ -174,6 +178,11 @@ private: static Handle(Message_ProgressIndicator)& StricklerInterpolationProgress(); static Handle(Message_ProgressIndicator)& BathymetryInterpolationProgress(); static ExecStatus myTriangulationStatus; + + + + + }; inline bool ValuesEquals( const double& theFirst, const double& theSecond ) diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx index 3a06ca02..df7f3844 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx @@ -37,6 +37,7 @@ #include #include #include +#include HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) @@ -57,6 +58,17 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin myAxes = new QComboBox( aParamGroup ); myAxes->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myLeftBanks = new QComboBox( aParamGroup ); + myLeftBanks->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myRightBanks = new QComboBox( aParamGroup ); + myRightBanks->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myProfilePoints = new QSpinBox(); + myProfilePoints->setRange(3, 99999); + myProfilePoints->setValue(100); + myDDZ = new QDoubleSpinBox( aParamGroup ); myDDZ->setRange( 0.01, 100 ); myDDZ->setSingleStep( 0.1 ); @@ -67,15 +79,39 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin mySpatialStep->setSingleStep( 0.1 ); mySpatialStep->setValue( 1 ); mySpatialStep->setDecimals( 2 ); - + + myModeButton = new QRadioButton( tr( "VIA_DTM" ), myObjectNameGroup ); + myModeButton->setAutoExclusive(true); + myModeButton2 = new QRadioButton( tr( "VIA_LISM" ), myObjectNameGroup ); + myModeButton2->setAutoExclusive(true); + myModeButton->setChecked(true); + myModeButton2->setChecked(false); + QGridLayout* aParam1Layout = new QGridLayout(); + + aParam1Layout->addWidget( myModeButton, 0, 0 ); + aParam1Layout->addWidget( myModeButton2, 0, 1 ); + + myDDZLabel = new QLabel( tr( "STREAM_DDZ" ) ); aParam1Layout->setMargin( 0 ); - aParam1Layout->addWidget( new QLabel( tr( "STREAM_HYDRAULIC_AXIS" ) ), 0, 0 ); - aParam1Layout->addWidget( myAxes, 0, 1 ); - aParam1Layout->addWidget( new QLabel( tr( "STREAM_DDZ" ) ), 1, 0 ); - aParam1Layout->addWidget( myDDZ, 1, 1 ); - aParam1Layout->addWidget( new QLabel( tr( "STREAM_SPATIAL_STEP" ) ), 2, 0 ); - aParam1Layout->addWidget( mySpatialStep, 2, 1 ); + aParam1Layout->addWidget( new QLabel( tr( "STREAM_HYDRAULIC_AXIS" ) ), 1, 0 ); + aParam1Layout->addWidget( myAxes, 1, 1 ); + aParam1Layout->addWidget( myDDZLabel, 2, 0 ); + aParam1Layout->addWidget( myDDZ, 2, 1 ); + aParam1Layout->addWidget( new QLabel( tr( "STREAM_SPATIAL_STEP" ) ), 3, 0 ); + aParam1Layout->addWidget( mySpatialStep, 3, 1 ); + + ///line. intr method widgets + myLeftBanksLabel = new QLabel( tr( "STREAM_LEFT_BANK" ) ); + myRightBanksLabel = new QLabel( tr( "STREAM_RIGHT_BANK" ) ); + myProfilePointsLabel = new QLabel( tr( "STREAM_PROFILE_POINTS" ) ); + + aParam1Layout->addWidget( myLeftBanksLabel, 4, 0 ); + aParam1Layout->addWidget( myLeftBanks, 4, 1 ); + aParam1Layout->addWidget( myRightBanksLabel, 5, 0 ); + aParam1Layout->addWidget( myRightBanks, 5, 1 ); + aParam1Layout->addWidget( myProfilePointsLabel, 6, 0 ); + aParam1Layout->addWidget( myProfilePoints, 6, 1 ); myProfiles = new HYDROGUI_OrderedListWidget( aParamGroup, 0 ); myProfiles->setHiddenObjectsShown(true); @@ -132,6 +168,17 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin connect( myRemoveButton, SIGNAL( clicked() ), this, SLOT( onRemoveProfiles() ) ); connect( myDDZ, SIGNAL( valueChanged (double) ), this, SLOT (onDDZValueChanged(double))); connect( mySpatialStep, SIGNAL( valueChanged (double) ), this, SLOT (onSSValueChanged(double))); + /// + connect( myLeftBanks, SIGNAL( currentIndexChanged( const QString & ) ), this, SIGNAL( LeftBankChanged( const QString& ) ) ); + connect( myRightBanks, SIGNAL( currentIndexChanged( const QString & ) ), this, SIGNAL( RightBankChanged( const QString& ) ) ); + connect( myProfilePoints, SIGNAL( valueChanged (int) ), this, SIGNAL (ProfilePointsChanged(int))); + + connect( myModeButton, SIGNAL( toggled( bool ) ), this, SIGNAL( ModeChanged( bool ) ) ); + connect( myModeButton, SIGNAL( toggled( bool ) ), this, SLOT( ModeChangedDlg( bool ) ) ); + + ModeChangedDlg(true); + + //myModeButton->setChecked(false); } HYDROGUI_StreamDlg::~HYDROGUI_StreamDlg() @@ -145,13 +192,22 @@ void HYDROGUI_StreamDlg::reset() myObjectName->clear(); myAxes->clear(); + myLeftBanks->clear(); + myRightBanks->clear(); + myProfiles->setObjects( HYDROGUI_ListModel::Object2VisibleList() ); + myAddButton->setEnabled( true ); myRemoveButton->setEnabled( true ); blockSignals( isBlocked ); } +QList HYDROGUI_StreamDlg::getProfiles() +{ + return myProfiles->getObjects(); +} + void HYDROGUI_StreamDlg::setObjectName( const QString& theName ) { myObjectName->setText( theName ); @@ -172,6 +228,26 @@ void HYDROGUI_StreamDlg::setAxisNames( const QStringList& theAxises ) blockSignals( isBlocked ); } +void HYDROGUI_StreamDlg::setLeftBankNames( const QStringList& theBanks ) +{ + bool isBlocked = blockSignals( true ); + + myLeftBanks->clear(); + myLeftBanks->addItems( theBanks ); + + blockSignals( isBlocked ); +} + +void HYDROGUI_StreamDlg::setRightBankNames( const QStringList& theBanks ) +{ + bool isBlocked = blockSignals( true ); + + myRightBanks->clear(); + myRightBanks->addItems( theBanks ); + + blockSignals( isBlocked ); +} + void HYDROGUI_StreamDlg::setAxisName( const QString& theName ) { bool isBlocked = blockSignals( true ); @@ -185,11 +261,48 @@ void HYDROGUI_StreamDlg::setAxisName( const QString& theName ) blockSignals( isBlocked ); } +void HYDROGUI_StreamDlg::setLeftBankName( const QString& theName ) +{ + bool isBlocked = blockSignals( true ); + + int aNewId = myLeftBanks->findText( theName ); + if ( aNewId != myLeftBanks->currentIndex() ) { + myLeftBanks->setCurrentIndex( aNewId ); + } + //myAddButton->setEnabled( myAxes->currentIndex() > -1 ); + + blockSignals( isBlocked ); +} + +void HYDROGUI_StreamDlg::setRightBankName( const QString& theName ) +{ + bool isBlocked = blockSignals( true ); + + int aNewId = myRightBanks->findText( theName ); + if ( aNewId != myRightBanks->currentIndex() ) { + myRightBanks->setCurrentIndex( aNewId ); + } + //myAddButton->setEnabled( myAxes->currentIndex() > -1 ); + + blockSignals( isBlocked ); +} + + QString HYDROGUI_StreamDlg::getAxisName() const { return myAxes->currentText(); } +QString HYDROGUI_StreamDlg::getLeftBankName() const +{ + return myLeftBanks->currentText(); +} + +QString HYDROGUI_StreamDlg::getRightBankName() const +{ + return myRightBanks->currentText(); +} + void HYDROGUI_StreamDlg::setProfiles( const QStringList& theProfiles ) { bool isBlocked = blockSignals( true ); @@ -257,6 +370,17 @@ double HYDROGUI_StreamDlg::getSpatialStep() const return mySpatialStep->value(); } +void HYDROGUI_StreamDlg::setNbProfilePoints( const int theNbPoints ) +{ + myProfilePoints->setValue( theNbPoints ); +} + +int HYDROGUI_StreamDlg::getNbProfilePoints() const +{ + return myProfilePoints->value(); +} + + void HYDROGUI_StreamDlg::setBackgroundColorForProfileList (int theInd, QColor theColor) { myProfiles->setBackgroundColor(theInd, theColor); @@ -287,3 +411,54 @@ void HYDROGUI_StreamDlg::clearWarnings() myWarnText->clear(); } + +void HYDROGUI_StreamDlg::ModeChangedDlg(bool mode) +{ + if ( signalsBlocked() ) + return; + if (mode) + { + myProfilePoints->setVisible(false); + myProfilePointsLabel->setVisible(false); + + myLeftBanks->setVisible(false); + myLeftBanksLabel->setVisible(false); + + myRightBanks->setVisible(false); + myRightBanksLabel->setVisible(false); + + myDDZ->setVisible(true); + myDDZLabel->setVisible(true); + } + else + { + myProfilePoints->setVisible(true); + myProfilePointsLabel->setVisible(true); + + myLeftBanks->setVisible(true); + myLeftBanksLabel->setVisible(true); + + myRightBanks->setVisible(true); + myRightBanksLabel->setVisible(true); + + myDDZ->setVisible(false); + myDDZLabel->setVisible(false); + } + +} + +int HYDROGUI_StreamDlg::getMode() +{ + bool isCh = myModeButton->isChecked(); + return isCh ? 0 : 1; +} + +void HYDROGUI_StreamDlg::setMode(int mode) +{ + bool checkState = mode == 0; + myModeButton->setChecked(checkState); + myModeButton2->setChecked(!checkState); +} + + + diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.h b/src/HYDROGUI/HYDROGUI_StreamDlg.h index adb087bf..b8fbeaf3 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.h +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.h @@ -20,6 +20,7 @@ #define HYDROGUI_StreamDlg_H #include "HYDROGUI_InputPanel.h" +#include class HYDROGUI_OrderedListWidget; @@ -30,6 +31,9 @@ class QListWidget; class QPushButton; class QDoubleSpinBox; class QTextEdit; +class QRadioButton; +class QSpinBox; +class QLabel; class HYDROGUI_StreamDlg : public HYDROGUI_InputPanel { @@ -45,9 +49,16 @@ public: QString getObjectName() const; void setAxisNames( const QStringList& theAxises ); + void setLeftBankNames( const QStringList& theAxises ); + void setRightBankNames( const QStringList& theAxises ); void setAxisName( const QString& thePolyline ); + void setLeftBankName( const QString& theName ); + void setRightBankName( const QString& theName ); + QString getAxisName() const; + QString getLeftBankName() const; + QString getRightBankName() const; void setProfiles( const QStringList& theProfiles ); @@ -57,14 +68,23 @@ public: void setSpatialStep( const double ); double getSpatialStep() const; + void setNbProfilePoints( const int ); + int getNbProfilePoints() const; + void addWarning( const QString& theWarnMess ); void clearWarnings(); + QList getProfiles(); + void setBackgroundColorForProfileList (int theInd, QColor theColor); void setBackgroundColorForProfileList (QString name, QColor theColor); QColor getBackgroundColorForProfileList (int theInd) const; void clearAllBackgroundColorsForProfileList (); + int getMode(); + void setMode(int mode); + + signals: void AddProfiles(); void RemoveProfiles( const QStringList& ); @@ -72,22 +92,42 @@ signals: void DDZValueChanged (double d); void SSValueChanged (double d); + void LeftBankChanged( const QString& ) ; + void RightBankChanged( const QString& ); + void ProfilePointsChanged (int); + void ModeChanged(bool); + private slots: void onRemoveProfiles(); void onDDZValueChanged(double d); void onSSValueChanged(double d); + void ModeChangedDlg(bool); + + private: QGroupBox* myObjectNameGroup; QLineEdit* myObjectName; QDoubleSpinBox* myDDZ; QDoubleSpinBox* mySpatialStep; + QSpinBox* myProfilePoints; QComboBox* myAxes; + + QComboBox* myLeftBanks; + QComboBox* myRightBanks; + HYDROGUI_OrderedListWidget* myProfiles; QPushButton* myRemoveButton; QPushButton* myAddButton; QTextEdit* myWarnText; + QRadioButton* myModeButton; + QRadioButton* myModeButton2; + + QLabel* myDDZLabel; + QLabel* myLeftBanksLabel; + QLabel* myRightBanksLabel; + QLabel* myProfilePointsLabel; }; diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 87322f42..74835af2 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -55,6 +55,7 @@ #include #include #include +#include void insertProfileInToOrder( const QString& theProfileName, const double& theProfilePar, @@ -97,6 +98,7 @@ HYDROGUI_StreamOp::~HYDROGUI_StreamOp() void HYDROGUI_StreamOp::startOperation() { HYDROGUI_Operation::startOperation(); + int mode = 0; //DTM mode by def if ( !myIsEdit || isApplyAndClose() ) myEditedObject.Nullify(); @@ -115,8 +117,10 @@ void HYDROGUI_StreamOp::startOperation() myEditedObject = Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if ( !myEditedObject.IsNull() ) - { + { + mode = myEditedObject->GetInterpolationMethod(); anObjectName = myEditedObject->GetName(); + //aPanel->setMode(mode); // Hydraulic axis Handle(HYDROData_PolylineXY) aHydraulicAxis = myEditedObject->GetHydraulicAxis(); @@ -157,15 +161,30 @@ void HYDROGUI_StreamOp::startOperation() // set the existing 2D polylines names to the panel aPanel->setAxisNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) ); + aPanel->setLeftBankNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) ); + aPanel->setRightBankNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) ); + + bool isBlocked = aPanel->blockSignals( true ); if (myIsEdit) { - aPanel->setDDZ( myEditedObject->GetDDZ() ); + if (mode == 0) + { + aPanel->setDDZ( myEditedObject->GetDDZ() ); + } + else + { + aPanel->setNbProfilePoints( myEditedObject->GetNbProfilePoints() ); + aPanel->setLeftBankName(myEditedObject->GetLeftBank()->GetName()); + aPanel->setRightBankName(myEditedObject->GetRightBank()->GetName()); + } aPanel->setSpatialStep( myEditedObject->GetSpatialStep() ); - } + } + + aPanel->setMode(mode); + aPanel->blockSignals( isBlocked ); // synchronize the panel state with the edited object state updatePanelData(); - // Create preview createPreview(); } @@ -194,6 +213,17 @@ HYDROGUI_InputPanel* HYDROGUI_StreamOp::createInputPanel() const connect( aPanel, SIGNAL( DDZValueChanged( double ) ), this, SLOT( onDDZValueChanged( double ) ) ); connect( aPanel, SIGNAL( SSValueChanged( double ) ), this, SLOT( onSSValueChanged( double ) ) ); + + connect( aPanel, SIGNAL( LeftBankChanged( const QString& ) ), + this, SLOT( onLeftBankChanged( const QString& ) ) ); + + connect( aPanel, SIGNAL( RightBankChanged( const QString& ) ), + this, SLOT( onRightBankChanged( const QString& ) ) ); + + connect( aPanel, SIGNAL( ProfilePointsChanged( int ) ), this, SLOT( onProfilePointsChanged( int ) ) ); + + connect( aPanel, SIGNAL( ModeChanged( bool ) ), this, SLOT( onModeChanged( bool ) ) ); + return aPanel; } @@ -248,7 +278,7 @@ void HYDROGUI_StreamOp::apply() } } - +//#include bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ) @@ -305,26 +335,48 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, return false; } - bool ToOrder = true; + int InterpMethod = aPanel->getMode(); - if (aHydAxis.IsNull()) - ToOrder = false; + myEditedObject->SetInterpolationMethod(InterpMethod); - myEditedObject->SetProfiles (aRefProfiles, ToOrder) ; - myEditedObject->SetName( anObjectName ); - - if (!aHydAxis.IsNull()) - myEditedObject->SetHydraulicAxis( aHydAxis ); - myEditedObject->SetProfiles( aRefProfiles, false ); - myEditedObject->SetDDZ( aPanel->getDDZ() ); - myEditedObject->SetSpatialStep( aPanel->getSpatialStep() ); + if (InterpMethod == 0) + { + //DTM + bool ToOrder = !aHydAxis.IsNull(); + myEditedObject->SetProfiles (aRefProfiles, ToOrder) ; + myEditedObject->SetName( anObjectName ); + + if (!aHydAxis.IsNull()) + myEditedObject->SetHydraulicAxis( aHydAxis ); + myEditedObject->SetProfiles( aRefProfiles, false ); + myEditedObject->SetDDZ( aPanel->getDDZ() ); + myEditedObject->SetSpatialStep( aPanel->getSpatialStep() ); + } + else if (InterpMethod == 1) + { + //LISM + myEditedObject->SetProfiles (aRefProfiles, false) ; + myEditedObject->SetName( anObjectName ); + if (!aHydAxis.IsNull()) + myEditedObject->SetHydraulicAxis( aHydAxis ); + Handle(HYDROData_PolylineXY) aLeftBank = Handle(HYDROData_PolylineXY)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aPanel->getLeftBankName(), KIND_POLYLINEXY ) ); + Handle(HYDROData_PolylineXY) aRightBank = Handle(HYDROData_PolylineXY)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aPanel->getRightBankName(), KIND_POLYLINEXY ) ); + //myEditedObject->Se + myEditedObject->SetLeftBank(aLeftBank); + myEditedObject->SetRightBank(aRightBank); + + myEditedObject->SetNbProfilePoints( aPanel->getNbProfilePoints() ); + myEditedObject->SetHaxStep( aPanel->getSpatialStep() ); + } if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) { myEditedObject->Update(); - NCollection_DataMap> warnings; - myEditedObject->GetWarnings(warnings); - QString totalWarning; + //NCollection_DataMap> warnings; + //myEditedObject->GetWarnings(warnings); + //QString totalWarning; //for (NCollection_DataMap>::Iterator it(warnings); it.More(); it.Next()) //{ // const QSet& V = it.Value(); @@ -367,11 +419,14 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, void HYDROGUI_StreamOp::createPreview() { + HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); + int mode = aPanel->getMode(); + LightApp_Application* anApp = module()->getApp(); if ( !getPreviewManager() ) { setPreviewManager( ::qobject_cast( - anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); + anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); } OCCViewer_ViewManager* aViewManager = getPreviewManager(); @@ -401,83 +456,113 @@ void HYDROGUI_StreamOp::createPreview() if ( !aViewManager || !myPreviewPrs ) return; - Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) ); - - HYDROData_SequenceOfObjects aRefProfiles; - //std::vector aRefProfiles; - int plen = myProfiles.length(); - for ( int i = 0; i < plen; ++i ) + if (mode == 0) { - QString aProfileName = myProfiles.value( i ); + Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) ); - Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); - if ( !aProfile.IsNull() ) - aRefProfiles.Append( aProfile ); - } + HYDROData_SequenceOfObjects aRefProfiles; + //std::vector aRefProfiles; + int plen = myProfiles.length(); + for ( int i = 0; i < plen; ++i ) + { + QString aProfileName = myProfiles.value( i ); + + Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); + if ( !aProfile.IsNull() ) + aRefProfiles.Append( aProfile ); + } - HYDROData_Stream::PrsDefinition aPrsDef; + HYDROData_Stream::PrsDefinition aPrsDef; - TopoDS_Shape Out3dPres; - TopoDS_Shape Out2dPres; - TopoDS_Shape OutLeftB; - TopoDS_Shape OutRightB; - TopoDS_Shape OutInlet; - TopoDS_Shape OutOutlet; + TopoDS_Shape Out3dPres; + TopoDS_Shape Out2dPres; + TopoDS_Shape OutLeftB; + TopoDS_Shape OutRightB; + TopoDS_Shape OutInlet; + TopoDS_Shape OutOutlet; - HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); - double ddz = aPanel->getDDZ(); - double ss = aPanel->getSpatialStep(); + double ddz = aPanel->getDDZ(); + double ss = aPanel->getSpatialStep(); - std::set InvInd; + std::set InvInd; #ifdef _DEBUG - const int MAX_POINTS_IN_PREVIEW = 50000; + const int MAX_POINTS_IN_PREVIEW = 50000; #else - const int MAX_POINTS_IN_PREVIEW = 500000; + const int MAX_POINTS_IN_PREVIEW = 500000; #endif - HYDROData_Bathymetry::AltitudePoints points; - - bool ProjStat = true; - NCollection_DataMap> warnings; - bool ToEstimateWarnings = false; - HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, - OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, ProjStat, warnings, ToEstimateWarnings ); - - aPanel->clearAllBackgroundColorsForProfileList(); - // for (std::set::const_iterator it = InvInd.begin(); it != InvInd.end(); it++) - // aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow)); - - aPrsDef.myInlet = OutInlet; - aPrsDef.myOutlet = OutOutlet; - aPrsDef.myLeftBank = OutLeftB; - aPrsDef.myRightBank = OutRightB; - if (ProjStat) - aPrsDef.myPrs2D = Out2dPres; - aPrsDef.myPrs3D = Out3dPres; + HYDROData_Bathymetry::AltitudePoints points; - aPanel->clearWarnings(); - if (!ProjStat) - aPanel->addWarning(tr("STREAM_PROJECTION_FAILED")); - - for (NCollection_DataMap>::Iterator it(warnings); it.More(); it.Next()) - { - const QSet& V = it.Value(); - if (V.empty()) - continue; - const Handle(HYDROData_Profile)& K = it.Key(); - QString ProfName = K->GetName(); - foreach (QString str, V) + bool ProjStat = true; + NCollection_DataMap> warnings; + bool ToEstimateWarnings = false; + HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, + OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, ProjStat, warnings, ToEstimateWarnings ); + + aPanel->clearAllBackgroundColorsForProfileList(); + // for (std::set::const_iterator it = InvInd.begin(); it != InvInd.end(); it++) + // aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow)); + + aPrsDef.myInlet = OutInlet; + aPrsDef.myOutlet = OutOutlet; + aPrsDef.myLeftBank = OutLeftB; + aPrsDef.myRightBank = OutRightB; + if (ProjStat) + aPrsDef.myPrs2D = Out2dPres; + aPrsDef.myPrs3D = Out3dPres; + + aPanel->clearWarnings(); + if (!ProjStat) + aPanel->addWarning(tr("STREAM_PROJECTION_FAILED")); + + for (NCollection_DataMap>::Iterator it(warnings); it.More(); it.Next()) { - aPanel->addWarning("Profile: " + ProfName + ": " + str); + const QSet& V = it.Value(); + if (V.empty()) + continue; + const Handle(HYDROData_Profile)& K = it.Key(); + QString ProfName = K->GetName(); + foreach (QString str, V) + { + aPanel->addWarning("Profile: " + ProfName + ": " + str); + } + + aPanel->setBackgroundColorForProfileList(ProfName, QColor(Qt::yellow)); } - aPanel->setBackgroundColorForProfileList(ProfName, QColor(Qt::yellow)); + myPreviewPrs->setShape( aPrsDef.myPrs2D ); + } + else //mode == 1 + { + aPanel->clearAllBackgroundColorsForProfileList(); + aPanel->clearWarnings(); + int nbProfPoints = aPanel->getNbProfilePoints(); + double ss = aPanel->getSpatialStep(); + QString axisName = aPanel->getAxisName(); + QString leftBankName = aPanel->getLeftBankName(); + QString rightBankName = aPanel->getRightBankName(); + QList listProf = aPanel->getProfiles(); + HYDROData_SequenceOfObjects seqProf; + foreach (Handle(HYDROData_Entity) ent, listProf) + seqProf.Append(ent); + + Handle(HYDROData_PolylineXY) axis = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), axisName, KIND_POLYLINEXY ) ); + Handle(HYDROData_PolylineXY) LB = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), leftBankName, KIND_POLYLINEXY ) ); + Handle(HYDROData_PolylineXY) RB = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), rightBankName, KIND_POLYLINEXY ) ); + HYDROData_Bathymetry::AltitudePoints outBathypoints; + + std::vector warnings; + HYDROData_Stream::PrsDefinition prsDef; + + HYDROData_StreamLinearInterpolation::Perform(seqProf, 500, 1, axis, LB, RB, outBathypoints, true, true, prsDef, &warnings); + //TODO for prs3d?? + myPreviewPrs->setShape( prsDef.myPrs2D ); + for (int i=0;iaddWarning(warnings[i].c_str()); } - - myPreviewPrs->setShape( aPrsDef.myPrs2D ); } void HYDROGUI_StreamOp::erasePreview() @@ -491,6 +576,7 @@ void HYDROGUI_StreamOp::erasePreview() void HYDROGUI_StreamOp::onAddProfiles() { + //TODO skip if mode == 1?? Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) ); //if ( aHydAxis.IsNull() ) @@ -616,16 +702,26 @@ void HYDROGUI_StreamOp::onRemoveProfiles( const QStringList& theProfilesToRemove void HYDROGUI_StreamOp::onDDZValueChanged( double d ) { - createPreview(); + HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); + if (!aPanel) + return; + if (aPanel->getMode() == 0) + createPreview(); } void HYDROGUI_StreamOp::onSSValueChanged( double d ) { + HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); + if (!aPanel) + return; createPreview(); } void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis ) { + HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); + if (!aPanel) + return; // Get axis object Handle(HYDROData_PolylineXY) aNewAxis = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theNewAxis, KIND_POLYLINEXY ) ); @@ -704,6 +800,38 @@ void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis ) } } +void HYDROGUI_StreamOp::onLeftBankChanged( const QString& theNewAxis ) +{ + HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); + if (!aPanel) + return; + if (aPanel->getMode() == 1) + createPreview(); +} + +void HYDROGUI_StreamOp::onRightBankChanged( const QString& theNewAxis ) +{ + HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); + if (!aPanel) + return; + if (aPanel->getMode() == 1) + createPreview(); +} + +void HYDROGUI_StreamOp::onProfilePointsChanged( int d ) +{ + HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); + if (!aPanel) + return; + if (aPanel->getMode() == 1) + createPreview(); +} + +void HYDROGUI_StreamOp::onModeChanged( bool mode ) +{ + createPreview(); +} + void HYDROGUI_StreamOp::updatePanelData() { HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -712,4 +840,5 @@ void HYDROGUI_StreamOp::updatePanelData() aPanel->setAxisName( myHydAxis ); aPanel->setProfiles( myProfiles ); + } diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.h b/src/HYDROGUI/HYDROGUI_StreamOp.h index 5e3a9160..2f2616d7 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.h +++ b/src/HYDROGUI/HYDROGUI_StreamOp.h @@ -55,6 +55,12 @@ private slots: void onAxisChanged( const QString& ); void onDDZValueChanged( double d ); void onSSValueChanged( double d ); + void onLeftBankChanged( const QString& ); + void onRightBankChanged( const QString& ); + void onProfilePointsChanged( int ); + void onModeChanged( bool ); + + private: void createPreview(); @@ -70,6 +76,9 @@ private: QString myHydAxis; QStringList myProfiles; QList myProfileParams; + //QString myLeftBank; + //QString myRightBank; + }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 545516e2..1e87f9f1 100755 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -3001,8 +3001,24 @@ file cannot be correctly imported for an Obstacle definition. Stream ddz - STREAM_SPATIAL_STEP - Stream spatial step + VIA_DTM + via DTM + + + VIA_LISM + via Linear Interpolation + + + STREAM_LEFT_BANK + Left Bank + + + STREAM_RIGHT_BANK + Right Bank + + + STREAM_PROFILE_POINTS + Number of points on profiles