Back to index

salome-geom  6.5.0
GEOM_VertexSource.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "GEOM_VertexSource.h" 
00021  
00022 #include <vtkObjectFactory.h> 
00023 
00024 #include <vtkPoints.h> 
00025 #include <vtkCellArray.h> 
00026 #include <vtkPolyData.h> 
00027 #include <vtkPolyDataMapper.h> 
00028  
00029 #include <gp_Pnt.hxx>
00030 #include <BRep_Tool.hxx>
00031  
00032 vtkStandardNewMacro(GEOM_VertexSource);
00033  
00034 GEOM_VertexSource::GEOM_VertexSource() 
00035 { 
00036 } 
00037  
00038 GEOM_VertexSource::~GEOM_VertexSource() 
00039 { 
00040 } 
00041  
00042 void  
00043 GEOM_VertexSource:: 
00044 AddVertex(const TopoDS_Vertex& theVertex) 
00045 { 
00046   myVertexSet.Add(theVertex); 
00047 } 
00048  
00049 void
00050 GEOM_VertexSource:: 
00051 Execute()
00052 {
00053   vtkPolyData* aPolyData = GetOutput();
00054   aPolyData->Allocate();
00055   vtkPoints* aPts = vtkPoints::New();
00056   aPolyData->SetPoints(aPts);
00057   aPts->Delete();
00058 
00059   TVertexSet::Iterator anIter(myVertexSet);
00060   for(; anIter.More(); anIter.Next()){
00061     const TopoDS_Vertex& aVertex = anIter.Value();
00062     OCC2VTK(aVertex,aPolyData,aPts);
00063   }
00064 }
00065 
00066 void  
00067 GEOM_VertexSource:: 
00068 OCC2VTK(const TopoDS_Vertex& theVertex,  
00069         vtkPolyData* thePolyData, 
00070         vtkPoints* thePts) 
00071 { 
00072   gp_Pnt aPnt = BRep_Tool::Pnt(theVertex);
00073   vtkIdType anId = thePts->InsertNextPoint(aPnt.X(),aPnt.Y(),aPnt.Z());
00074   thePolyData->InsertNextCell(VTK_VERTEX,1,&anId);
00075 }