1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_VTKPrsBathymetry.h"
25 #include <HYDROData_Entity.h>
27 #include <SALOME_Actor.h>
29 #include <vtkPoints.h>
30 #include <vtkPolyData.h>
31 #include <vtkPolyDataMapper.h>
32 #include <vtkVertex.h>
36 //=======================================================================
37 // name : HYDROGUI_VTKPrsBathymetry
38 // Purpose : Constructor
39 //=======================================================================
40 HYDROGUI_VTKPrsBathymetry::HYDROGUI_VTKPrsBathymetry( const Handle(HYDROData_Bathymetry)& theObject )
41 : HYDROGUI_VTKPrs( theObject )
45 //=======================================================================
46 // name : HYDROGUI_VTKPrsBathymetry
47 // Purpose : Destructor
48 //=======================================================================
49 HYDROGUI_VTKPrsBathymetry::~HYDROGUI_VTKPrsBathymetry()
53 //================================================================
56 //================================================================
57 void HYDROGUI_VTKPrsBathymetry::compute()
59 if ( !getObject().IsNull() )
61 Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast( getObject() );
62 if ( !aBathymetry.IsNull() )
64 HYDROData_Bathymetry::AltitudePoints anAltPoints = aBathymetry->GetAltitudePoints();
65 int aNbPoints = anAltPoints.length();
67 HYDROData_Bathymetry::AltitudePoint anAltPnt;
68 vtkPoints* aPoints = vtkPoints::New();
69 aPoints->SetNumberOfPoints( aNbPoints );
71 vtkPolyData* aVertexGrid = vtkPolyData::New();
72 aVertexGrid->Allocate( aNbPoints );
74 vtkVertex* aVertex = vtkVertex::New();
76 for (int i = 0; i < aNbPoints; i++ )
78 anAltPnt = anAltPoints.at( i );
79 aPoints->InsertPoint( i, anAltPnt.X(), anAltPnt.Y(), anAltPnt.Z() );
80 aVertex->GetPointIds()->SetId( 0, i );
81 aVertexGrid->InsertNextCell( aVertex->GetCellType(), aVertex->GetPointIds());
86 aVertexGrid->SetPoints( aPoints );
87 vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
88 aMapper->SetInputData( aVertexGrid );
89 SALOME_Actor* anActor = SALOME_Actor::New();
90 anActor->SetMapper( aMapper );
91 anActor->setIO( getIO() );
92 //anActor->setName( aBathymetry->GetName().toLatin1() );
94 //anActor.AddPosition(0, 0, 6);
95 //anActor.GetProperty().SetDiffuseColor(1, 1, 1);