Salome HOME
To implement issue 0019962: MakePipeBiNormalAlongAxis implementation.
[modules/geom.git] / src / OBJECT / GEOM_VertexSource.cxx
1 #include "GEOM_VertexSource.h" 
2  
3 #include <vtkObjectFactory.h> 
4
5 #include <vtkPoints.h> 
6 #include <vtkCellArray.h> 
7 #include <vtkPolyData.h> 
8 #include <vtkPolyDataMapper.h> 
9  
10 #include <gp_Pnt.hxx>
11 #include <BRep_Tool.hxx>
12  
13 vtkStandardNewMacro(GEOM_VertexSource);
14  
15 GEOM_VertexSource::GEOM_VertexSource() 
16
17
18  
19 GEOM_VertexSource::~GEOM_VertexSource() 
20
21
22  
23 void  
24 GEOM_VertexSource:: 
25 AddVertex(const TopoDS_Vertex& theVertex) 
26
27   myVertexSet.Add(theVertex); 
28
29  
30 void
31 GEOM_VertexSource:: 
32 Execute()
33 {
34   vtkPolyData* aPolyData = GetOutput();
35   aPolyData->Allocate();
36   vtkPoints* aPts = vtkPoints::New();
37   aPolyData->SetPoints(aPts);
38   aPts->Delete();
39
40   TVertexSet::Iterator anIter(myVertexSet);
41   for(; anIter.More(); anIter.Next()){
42     const TopoDS_Vertex& aVertex = anIter.Value();
43     OCC2VTK(aVertex,aPolyData,aPts);
44   }
45 }
46
47 void  
48 GEOM_VertexSource:: 
49 OCC2VTK(const TopoDS_Vertex& theVertex,  
50         vtkPolyData* thePolyData, 
51         vtkPoints* thePts) 
52
53   gp_Pnt aPnt = BRep_Tool::Pnt(theVertex);
54   vtkIdType anId = thePts->InsertNextPoint(aPnt.X(),aPnt.Y(),aPnt.Z());
55   thePolyData->InsertNextCell(VTK_VERTEX,1,&anId);
56 }