1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROData_ObstacleAltitude.h"
21 #include "HYDROData_Document.h"
22 #include "HYDROData_Object.h"
23 #include "HYDROData_Projection.h"
26 #include "HYDRO_trace.hxx"
29 #include <Precision.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <BRepTools.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ObstacleAltitude, HYDROData_IAltitudeObject)
36 HYDROData_ObstacleAltitude::HYDROData_ObstacleAltitude()
37 : HYDROData_IAltitudeObject()
41 HYDROData_ObstacleAltitude::~HYDROData_ObstacleAltitude()
45 double HYDROData_ObstacleAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
48 DEBTRACE("HYDROData_ObstacleAltitude::GetAltitudeForPoint");
49 double aResAltitude = GetInvalidAltitude();
51 Handle(HYDROData_Object) anObject =
52 Handle(HYDROData_Object)::DownCast( GetFatherObject() );
53 if ( anObject.IsNull() )
55 DEBTRACE("anObject.IsNull()");
58 // DEBTRACE("object: " << anObject->GetName().toStdString());
60 TopoDS_Shape anObjectShape3D = anObject->GetShape3D();
61 if ( anObjectShape3D.IsNull() )
63 DEBTRACE("anObjectShape3D.IsNull()");
68 // DEBTRACE("anObjectShape3D type " << anObjectShape3D.ShapeType());
69 // BRepTools::Write(anObjectShape3D, "digue3D.brep");
72 HYDROData_Make3dMesh aMesher3D( anObjectShape3D, Precision::Intersection() );
75 if ( aMesher3D.GetHighestOriginal( thePoint.X(), thePoint.Y(), aHighestPoint ) )
76 aResAltitude = aHighestPoint.Z();
77 DEBTRACE("aResAltitude=" << aResAltitude);