From: isn Date: Wed, 23 Nov 2016 13:01:48 +0000 (+0300) Subject: another version of projection of dtm (3d >> 2d) X-Git-Tag: v1.6~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d7e02f0b23d84c6b1636e64618083e44182a995;p=modules%2Fhydro.git another version of projection of dtm (3d >> 2d) --- diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 13861a4b..bdbac0cb 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -47,6 +47,7 @@ #include #include #include +#include @@ -243,7 +244,6 @@ void HYDROData_DTM::GetPresentationShapes( TopoDS_Shape& Out3dPres, Out3dPres = GetShape( DataTag_3DShape ); Out2dPres = GetShape( DataTag_2DShape ); } - void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& InpProfiles, double ddz, double step, @@ -290,8 +290,7 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire) { - //its also possible to use BrepAlgo_NormalProjection here! - BRepTools_WireExplorer ex(TopoDS::Wire(inpWire.Oriented(TopAbs_FORWARD))); + /*BRepTools_WireExplorer ex(TopoDS::Wire(inpWire.Oriented(TopAbs_FORWARD))); BRepLib_MakeWire WM; for (;ex.More();ex.Next()) { @@ -299,10 +298,34 @@ void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geo double f, l; Handle(Geom_Curve) C3d = BRep_Tool::Curve(CE, f, l); Handle(Geom_Curve) ProjectedCurve = GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d, f, l), RefPlane, RefPlane->Position().Direction(), Standard_True); - TopoDS_Edge ProjEdge = BRepLib_MakeEdge(ProjectedCurve); - WM.Add(ProjEdge); //auto sharing between edges if vertex is coincident - } + if (!ProjectedCurve.IsNull()) + { + TopoDS_Edge ProjEdge = BRepLib_MakeEdge(ProjectedCurve, f, l ); + if (!BRep_Tool::Degenerated(ProjEdge)) + WM.Add(ProjEdge); //auto sharing between edges if vertex is coincident + } + }*/ + + BRep_Builder BB; + TopoDS_Face F; + BB.MakeFace(F, RefPlane, Precision::Confusion()); + BRepLib_MakeWire WM; + + BRepAlgo_NormalProjection nproj(F); + nproj.Add(inpWire); + nproj.SetDefaultParams(); + nproj.Build(); + if(!nproj.IsDone()) + return; + TopoDS_Shape projRes = nproj.Projection(); + TopExp_Explorer exp(projRes, TopAbs_EDGE); + TopTools_ListOfShape llE; + for (;exp.More();exp.Next()) + llE.Append(exp.Current()); + + WM.Add(llE); outWire = WM.Wire(); + outWire.Orientation(inpWire.Orientation()); //take from the original wire } diff --git a/src/HYDROGUI/HYDROGUI_ImagePrs.cxx b/src/HYDROGUI/HYDROGUI_ImagePrs.cxx index d9c0076a..b85450eb 100644 --- a/src/HYDROGUI/HYDROGUI_ImagePrs.cxx +++ b/src/HYDROGUI/HYDROGUI_ImagePrs.cxx @@ -113,6 +113,9 @@ void HYDROGUI_ImagePrs::Compute( const Handle(PrsMgr_PresentationManager3d)&, aPrs->Clear(); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs ); + if( myImage.IsNull() ) + return; + if ( aMode == 0 ) { Handle(Graphic3d_ArrayOfPolylines) aSegments = new Graphic3d_ArrayOfPolylines( 5 ); diff --git a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx index 0575b946..e8e7941b 100644 --- a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx +++ b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx @@ -48,7 +48,7 @@ void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivate Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( getObject() ); - if ( !aBath.IsNull() ) + if ( !aBath.IsNull() && !aBath->GetAltitudePoints().empty()) { buildShape(); updateShape( false, false ); @@ -104,6 +104,8 @@ void HYDROGUI_ShapeBathymetry::GetRange( double& theMin, double& theMax ) const void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(Aspect_ColorScale)& theColorScale ) { + if (!myCoords) + return; for( int i=myCoords->Lower(), n=myCoords->Upper(); i<=n; i++ ) { double z = myCoords->Value( i ).Z();