-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathGEOM_VertexSource.cxx
81 lines (69 loc) · 2.27 KB
/
GEOM_VertexSource.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (C) 2014-2015 KIT-INR/NK
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//
#include "GEOM_VertexSource.h"
#include <vtkObjectFactory.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkInformation.h>
#include <vtkInformationVector.h>
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx>
vtkStandardNewMacro(GEOM_VertexSource);
GEOM_VertexSource::GEOM_VertexSource()
{
this->SetNumberOfInputPorts(0);
}
GEOM_VertexSource::~GEOM_VertexSource()
{
}
void
GEOM_VertexSource::
AddVertex(const TopoDS_Vertex& theVertex)
{
myVertexSet.Add(theVertex);
}
int GEOM_VertexSource::RequestData(vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector)
{
vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkPolyData *aPolyData = vtkPolyData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
aPolyData->Allocate();
vtkPoints* aPts = vtkPoints::New();
aPolyData->SetPoints(aPts);
aPts->Delete();
TVertexSet::Iterator anIter(myVertexSet);
for(; anIter.More(); anIter.Next()){
const TopoDS_Vertex& aVertex = anIter.Value();
OCC2VTK(aVertex,aPolyData,aPts);
}
return 1;
}
void
GEOM_VertexSource::
OCC2VTK(const TopoDS_Vertex& theVertex,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
gp_Pnt aPnt = BRep_Tool::Pnt(theVertex);
vtkIdType anId = thePts->InsertNextPoint(aPnt.X(),aPnt.Y(),aPnt.Z());
thePolyData->InsertNextCell(VTK_VERTEX,1,&anId);
}