]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_ObstacleAltitude.cxx
Salome HOME
change def hasher for indexed map
[modules/hydro.git] / src / HYDROData / HYDROData_ObstacleAltitude.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROData_ObstacleAltitude.h"
20
21 #include "HYDROData_Document.h"
22 #include "HYDROData_Object.h"
23 #include "HYDROData_Projection.h"
24
25 #define _DEVDEBUG_
26 #include "HYDRO_trace.hxx"
27 #include <QString>
28
29 #include <Precision.hxx>
30
31 #include <TopoDS_Shape.hxx>
32 #include <BRepTools.hxx>
33
34 IMPLEMENT_STANDARD_HANDLE(HYDROData_ObstacleAltitude, HYDROData_IAltitudeObject)
35 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ObstacleAltitude, HYDROData_IAltitudeObject)
36
37 HYDROData_ObstacleAltitude::HYDROData_ObstacleAltitude()
38 : HYDROData_IAltitudeObject()
39 {
40 }
41
42 HYDROData_ObstacleAltitude::~HYDROData_ObstacleAltitude()
43 {
44 }
45
46 double HYDROData_ObstacleAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
47                                                         int theMethod) const
48 {
49   DEBTRACE("HYDROData_ObstacleAltitude::GetAltitudeForPoint");
50   double aResAltitude = GetInvalidAltitude();
51
52   Handle(HYDROData_Object) anObject =
53     Handle(HYDROData_Object)::DownCast( GetFatherObject() );
54   if ( anObject.IsNull() )
55   {
56         DEBTRACE("anObject.IsNull()");
57     return aResAltitude;
58   }
59 //  DEBTRACE("object: " << anObject->GetName().toStdString());
60
61   TopoDS_Shape anObjectShape3D = anObject->GetShape3D();
62   if ( anObjectShape3D.IsNull() )
63   {
64         DEBTRACE("anObjectShape3D.IsNull()");
65     return aResAltitude;
66   }
67 //  else
68 //  {
69 //      DEBTRACE("anObjectShape3D type " << anObjectShape3D.ShapeType());
70 //      BRepTools::Write(anObjectShape3D, "digue3D.brep");
71 //  }
72
73   HYDROData_Make3dMesh aMesher3D( anObjectShape3D, Precision::Intersection() );
74
75   gp_Pnt aHighestPoint;
76   if ( aMesher3D.GetHighestOriginal( thePoint.X(), thePoint.Y(), aHighestPoint ) )
77     aResAltitude = aHighestPoint.Z();
78   DEBTRACE("aResAltitude=" << aResAltitude);
79   return aResAltitude;
80 }
81
82
83
84