5#include <vtkInformation.h>
6#include <vtkObjectFactory.h>
8#include <vtkCellArray.h>
9#include <vtkDoubleArray.h>
10#include <vtkFloatArray.h>
11#include <vtkIdTypeArray.h>
12#include <vtkPointData.h>
13#include <vtkPolyData.h>
14#include <vtkSmartPointer.h>
19 this->SetNumberOfInputPorts(0);
20 this->SetNumberOfOutputPorts(1);
31 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkPolyData");
38 vtkInformationVector **
ttkNotUsed(inputVector),
39 vtkInformationVector *outputVector) {
41 size_t nSpheres = this->Centers ? this->Centers->GetNumberOfTuples() : 1;
45 bool useDoublePrecision
46 = this->Centers ? this->Centers->GetDataType() == VTK_DOUBLE :
false;
50 size_t nTriangles = 0;
52 nVertices, nTriangles, nSubdivisions);
54 const size_t nTotalVertices = nSpheres * nVertices;
55 const size_t nTotalTriangles = nSpheres * nTriangles;
58 points->SetDataType(useDoublePrecision ? VTK_DOUBLE : VTK_FLOAT);
59 points->SetNumberOfPoints(nTotalVertices);
62 if(this->ComputeNormals) {
63 if(useDoublePrecision)
68 normals->SetName(
"Normals");
69 normals->SetNumberOfComponents(3);
70 normals->SetNumberOfTuples(nTotalVertices);
74 offsets->SetNumberOfTuples(nTotalTriangles + 1);
77 for(
size_t i = 0; i <= nTotalTriangles; i++)
78 offsetsData[i] = i * 3;
81 connectivity->SetNumberOfTuples(nTotalTriangles * 3);
84 if(useDoublePrecision) {
86 status = this->computeIcospheres<DT, vtkIdType>(
87 ttkUtils::GetPointer<DT>(points->GetData()),
88 ttkUtils::GetPointer<vtkIdType>(connectivity),
90 nSpheres, nSubdivisions, radius,
91 this->Centers ? ttkUtils::GetPointer<DT>(this->Centers) : this->Center,
92 this->ComputeNormals ? ttkUtils::GetPointer<DT>(normals) :
nullptr);
96 (DT)this->Center[0], (DT)this->Center[1], (DT)this->Center[2]};
97 status = this->computeIcospheres<DT, vtkIdType>(
98 ttkUtils::GetPointer<DT>(points->GetData()),
99 ttkUtils::GetPointer<vtkIdType>(connectivity),
101 nSpheres, nSubdivisions, radius,
102 this->Centers ? ttkUtils::GetPointer<DT>(this->Centers) : centerFloat,
103 this->ComputeNormals ? ttkUtils::GetPointer<DT>(normals) :
nullptr);
111 auto output = vtkPolyData::GetData(outputVector);
112 output->SetPoints(points);
115 cells->SetData(offsets, connectivity);
116 output->SetPolys(cells);
118 if(this->ComputeNormals)
119 output->GetPointData()->SetNormals(normals);
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillInputPortInformation(int port, vtkInformation *info) override
virtual double GetRadius()
virtual int GetNumberOfSubdivisions()
int FillOutputPortInformation(int port, vtkInformation *info) override
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
int computeNumberOfVerticesAndTriangles(size_t &nVertices, size_t &nTriangles, const size_t nSubdivisions) const
vtkStandardNewMacro(ttkIcosphere)