From: asl Date: Wed, 5 Oct 2016 14:23:42 +0000 (+0300) Subject: new presentation using DTM X-Git-Tag: v1.6~68 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ca264f577959390521d4a56c950904992d64a4ac;p=modules%2Fhydro.git new presentation using DTM --- diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index 14ac7fb6..79fd3d25 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -280,8 +280,9 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& // Create presentation HYDROData_Stream::PrsDefinition aPrs; Handle(TopTools_HArray1OfShape) anArrOf2DProfiles; // we don't need 2D profiles for channel/digue presentation - bool aRes = HYDROData_Stream::CreatePresentations( anArrayOfFPnt, anArrayOfLPnt, - anArrOfProfiles, anArrOf2DProfiles, aPrs ); + bool aRes = false; + /*TODO: HYDROData_Stream::CreatePresentations( anArrayOfFPnt, anArrayOfLPnt, + anArrOfProfiles, anArrOf2DProfiles, aPrs );*/ if ( aRes ) { thePrs.myPrs3D = aPrs.myPrs3D; thePrs.myPrs2D = TopoDS::Face( aPrs.myPrs2D ); diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 579c09eb..ff489634 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -97,7 +97,7 @@ void HYDROData_DTM::Bank::clear() myDirs.clear(); } -TopoDS_Edge HYDROData_DTM::Bank::createEdge( bool is3d ) const +TopoDS_Edge HYDROData_DTM::Bank::createEdge3d() const { size_t n = myPoints.size(); Handle_Geom_BSplineCurve aCurve; @@ -109,11 +109,7 @@ TopoDS_Edge HYDROData_DTM::Bank::createEdge( bool is3d ) const for( size_t i = 1; i <= n; i++ ) { gp_Pnt aPnt = myPoints[i-1]; - if( !is3d ) - aPnt.SetZ( 0.0 ); gp_Vec aVec = myDirs[i-1]; - if( !is3d ) - aVec.SetZ( 0.0 ); points->SetValue( (int)i, aPnt ); tangents.SetValue( (int)i, aVec ); flags->SetValue( (int)i, Standard_True ); @@ -671,3 +667,9 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate } return points; } + +void HYDROData_DTM::CreateBankShapes( TopoDS_Edge& theLeft, TopoDS_Edge& theRight ) const +{ + theLeft = myLeft.createEdge3d(); + theRight = myRight.createEdge3d(); +} diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h index 717a9ed5..22bdcaa7 100644 --- a/src/HYDROData/HYDROData_DTM.h +++ b/src/HYDROData/HYDROData_DTM.h @@ -63,6 +63,8 @@ public: HYDRODATA_EXPORT virtual void Update(); + HYDRODATA_EXPORT void CreateBankShapes( TopoDS_Edge& theLeft, TopoDS_Edge& theRight ) const; + public: struct PointUZ { @@ -90,7 +92,7 @@ public: void reserve( int theNbPoints ); void push_back( const gp_Pnt& thePnt, const gp_Dir& theTangent ); void clear(); - TopoDS_Edge createEdge( bool is3d ) const; + TopoDS_Edge createEdge3d() const; private: std::vector myPoints; diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 9f166d7a..33515d7d 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -192,6 +192,7 @@ void HYDROData_Stream::Update() } } + DTM()->Update(); UpdatePrs(); } @@ -200,64 +201,43 @@ bool HYDROData_Stream::IsHas2dPrs() const return true; } -bool HYDROData_Stream::CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis, - const HYDROData_SequenceOfObjects& theProfiles, - PrsDefinition& thePrs ) +bool HYDROData_Stream::CreatePresentations( const Handle_HYDROData_DTM& theDTM, + PrsDefinition& thePrs ) { - if ( theHydAxis.IsNull() || theProfiles.Length() < 2 ) + if ( theDTM.IsNull() ) return false; - Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, theProfiles.Length()); - Handle(TColgp_HArray1OfPnt) anArrayOfLPnt = new TColgp_HArray1OfPnt(1, theProfiles.Length()); - Handle(TopTools_HArray1OfShape) anArrOfProfiles = new TopTools_HArray1OfShape(1, theProfiles.Length()); - Handle(TopTools_HArray1OfShape) anArrOf2DProfiles = new TopTools_HArray1OfShape(1, theProfiles.Length()); + HYDROData_SequenceOfObjects profiles = theDTM->GetProfiles(); + if( profiles.Length() < 2 ) + return false; + + TopTools_ListOfShape profiles3d; // Pre-processing - HYDROData_SequenceOfObjects::Iterator anIter( theProfiles ); + HYDROData_SequenceOfObjects::Iterator anIter( profiles ); for (int i=1 ; anIter.More(); anIter.Next(),i++ ) { Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( anIter.Value() ); - if ( aProfile.IsNull() ) - continue; - const TopoDS_Shape& aProf3d = aProfile->GetShape3D(); - gp_XY aPnt1, aPnt2; - if ( !aProfile->GetLeftPoint( aPnt1, false ) || !aProfile->GetRightPoint( aPnt2, false ) ) + if ( aProfile.IsNull() ) continue; - anArrOfProfiles->SetValue(i,aProfile->GetShape3D());//aProfile->GetTopShape(); - anArrOf2DProfiles->SetValue(i,aProfile->GetTopShape()); - - gp_Pnt aCurFP, aCurLP; - TopoDS_Vertex aV1, aV2; - TopExp::Vertices(TopoDS::Wire(aProf3d), aV1, aV2); - gp_Pnt aP1 = BRep_Tool::Pnt(aV1); - if(aP1.X() == aPnt1.X() && aP1.Y() == aPnt1.Y()) - aCurFP = aP1; - else - aCurLP = aP1; - aP1 = BRep_Tool::Pnt(aV2); - if(aP1.X() == aPnt2.X() && aP1.Y() == aPnt2.Y()) - aCurLP = aP1; - else - aCurFP = aP1; - anArrayOfFPnt->SetValue(i,aCurFP); - anArrayOfLPnt->SetValue(i,aCurLP); + const TopoDS_Shape& aProfileShape = aProfile->GetShape3D(); + profiles3d.Append( aProfileShape ); } - return CreatePresentations( anArrayOfFPnt, anArrayOfLPnt, anArrOfProfiles, anArrOf2DProfiles, thePrs ); + TopoDS_Edge aLeftBank, aRightBank; + theDTM->CreateBankShapes( aLeftBank, aRightBank ); + return CreatePresentations( aLeftBank, aRightBank, profiles3d, thePrs ); } void HYDROData_Stream::UpdatePrs() { HYDROData_NaturalObject::Update(); - Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis(); - HYDROData_SequenceOfObjects aRefProfiles = GetProfiles(); - PrsDefinition aResultPrs; - if ( !CreatePresentations( aHydAxis, aRefProfiles, aResultPrs ) ) + if ( !CreatePresentations( DTM(), aResultPrs ) ) return; SetShape3D( aResultPrs.myPrs3D ); @@ -1064,13 +1044,13 @@ void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination, } } -bool HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt) theArrayOfFPnt, - const Handle(TColgp_HArray1OfPnt) theArrayOfLPnt, - const Handle(TopTools_HArray1OfShape) theArrOfProfiles, - const Handle(TopTools_HArray1OfShape) theArrOf2DProfiles, - PrsDefinition& thePrs ) +bool HYDROData_Stream::CreatePresentations( const TopoDS_Edge& theLeftBank, + const TopoDS_Edge& theRightBank, + const TopTools_ListOfShape& theProfiles3d, + PrsDefinition& thePrs ) { - if ( theArrayOfFPnt.IsNull() || theArrayOfLPnt.IsNull() || theArrOfProfiles.IsNull() ) { + return true; + /*if ( theArrayOfFPnt.IsNull() || theArrayOfLPnt.IsNull() || theArrOfProfiles.IsNull() ) { return false; } @@ -1213,5 +1193,5 @@ bool HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt) } #endif - return true; + return true;*/ } \ No newline at end of file diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index 06dd511d..fdc74c63 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -35,6 +35,7 @@ class HYDROData_IProfilesInterpolator; class TColStd_Array1OfReal; class Handle(TopTools_HArray1OfShape); class Handle_HYDROData_DTM; +class TopTools_ListOfShape; /**\class HYDROData_Stream @@ -49,10 +50,10 @@ public: { TopoDS_Shape myPrs3D; TopoDS_Shape myPrs2D; - TopoDS_Edge myLeftBank; - TopoDS_Edge myRightBank; - TopoDS_Edge myInlet; - TopoDS_Edge myOutlet; + TopoDS_Edge myLeftBank; // 3d curve of the left bank + TopoDS_Edge myRightBank; // 3d curve of the right bank + TopoDS_Edge myInlet; // first (inlet) 2d profile + TopoDS_Edge myOutlet; // last (inlet) 2d profile }; protected: @@ -77,19 +78,17 @@ public: /** * Creates the presentations(2D and 3D) by given hydraulic axis and profiles. */ - HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis, - const HYDROData_SequenceOfObjects& theProfiles, - PrsDefinition& thePrs ); + HYDRODATA_EXPORT static bool CreatePresentations( const Handle_HYDROData_DTM& theDTM, + PrsDefinition& thePrs ); /** * Creates the presentations(2D and 3D) by given first points, last points and profiles. * If 2D profiles is null - they will not used in the presentation. */ - HYDRODATA_EXPORT static bool CreatePresentations( const Handle(TColgp_HArray1OfPnt) theArrayOfFPnt, - const Handle(TColgp_HArray1OfPnt) theArrayOfLPnt, - const Handle(TopTools_HArray1OfShape) theArrOfProfiles, - const Handle(TopTools_HArray1OfShape) theArrOf2DProfiles, - PrsDefinition& thePrs ); + HYDRODATA_EXPORT static bool CreatePresentations( const TopoDS_Edge& theLeftBank, + const TopoDS_Edge& theRightBank, + const TopTools_ListOfShape& theProfiles3d, + PrsDefinition& thePrs ); public: diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 7a66f2de..0e7020de 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -329,11 +329,11 @@ void HYDROGUI_StreamOp::createPreview() } HYDROData_Stream::PrsDefinition aPrsDef; - if ( !HYDROData_Stream::CreatePresentations( aHydAxis, aRefProfiles, aPrsDef ) ) + /*TODO: if ( !HYDROData_Stream::CreatePresentations( aHydAxis, aRefProfiles, aPrsDef ) ) { erasePreview(); return; - } + }*/ myPreviewPrs->setShape( aPrsDef.myPrs2D ); }