Salome HOME
4fdf79092723c734c97bea809cd8cbb94a995402
[modules/geom.git] / src / OBJECT / GEOM_VertexSource.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #include "GEOM_VertexSource.h" 
23  
24 #include <vtkObjectFactory.h> 
25
26 #include <vtkPoints.h> 
27 #include <vtkCellArray.h> 
28 #include <vtkPolyData.h> 
29 #include <vtkPolyDataMapper.h> 
30  
31 #include <gp_Pnt.hxx>
32 #include <BRep_Tool.hxx>
33  
34 vtkStandardNewMacro(GEOM_VertexSource);
35  
36 GEOM_VertexSource::GEOM_VertexSource() 
37
38
39  
40 GEOM_VertexSource::~GEOM_VertexSource() 
41
42
43  
44 void  
45 GEOM_VertexSource:: 
46 AddVertex(const TopoDS_Vertex& theVertex) 
47
48   myVertexSet.Add(theVertex); 
49
50  
51 void
52 GEOM_VertexSource:: 
53 Execute()
54 {
55   vtkPolyData* aPolyData = GetOutput();
56   aPolyData->Allocate();
57   vtkPoints* aPts = vtkPoints::New();
58   aPolyData->SetPoints(aPts);
59   aPts->Delete();
60
61   TVertexSet::Iterator anIter(myVertexSet);
62   for(; anIter.More(); anIter.Next()){
63     const TopoDS_Vertex& aVertex = anIter.Value();
64     OCC2VTK(aVertex,aPolyData,aPts);
65   }
66 }
67
68 void  
69 GEOM_VertexSource:: 
70 OCC2VTK(const TopoDS_Vertex& theVertex,  
71         vtkPolyData* thePolyData, 
72         vtkPoints* thePts) 
73
74   gp_Pnt aPnt = BRep_Tool::Pnt(theVertex);
75   vtkIdType anId = thePts->InsertNextPoint(aPnt.X(),aPnt.Y(),aPnt.Z());
76   thePolyData->InsertNextCell(VTK_VERTEX,1,&anId);
77 }