]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
another version of projection of dtm (3d >> 2d)
authorisn <isn@opencascade.com>
Wed, 23 Nov 2016 13:01:48 +0000 (16:01 +0300)
committerisn <isn@opencascade.com>
Wed, 23 Nov 2016 13:01:48 +0000 (16:01 +0300)
src/HYDROData/HYDROData_DTM.cxx
src/HYDROGUI/HYDROGUI_ImagePrs.cxx
src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx

index 13861a4b6d9bffbe4ebc1e2736bcf3f1f794e84b..bdbac0cb3c9b6d8280907a2a491dd7bce96c1d6b 100644 (file)
@@ -47,6 +47,7 @@
 #include <BRepLib_MakeWire.hxx>
 #include <BRep_Builder.hxx>
 #include <ShapeAnalysis_Wire.hxx>
+#include <BRepAlgo_NormalProjection.hxx>
 
 
 
@@ -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
 }
 
index d9c0076ab1fc81f21b0d5374332f5023927da264..b85450ebf4b54bff6e1147044b0d78d1334f9bfd 100644 (file)
@@ -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 );
index 0575b94616ac63c8dddbc34f0afc00aa8a3d9680..e8e7941b670df5490036037941cc70b95161a62b 100644 (file)
@@ -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();