TTK
Loading...
Searching...
No Matches
ttkIcosphereFromObject.cpp
Go to the documentation of this file.
2
3#include <vtkInformation.h>
4#include <vtkObjectFactory.h>
5
6#include <vtkDataSet.h>
7#include <vtkMultiBlockDataSet.h>
8
10
12 this->setDebugMsgPrefix("IcosphereFromObject");
13 this->SetNumberOfInputPorts(1);
14}
16
18 vtkInformation *info) {
19 if(port == 0)
20 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject");
21 else
22 return 0;
23 return 1;
24}
25
26int ttkIcosphereFromObject::RequestData(vtkInformation *request,
27 vtkInformationVector **inputVector,
28 vtkInformationVector *outputVector) {
29 auto input = vtkDataObject::GetData(inputVector[0], 0);
30
31 double bounds[6] = {0, 0, 0, 0, 0, 0};
32 if(input->IsA("vtkMultiBlockDataSet")) {
33 auto inputAsMB = vtkMultiBlockDataSet::SafeDownCast(input);
34 inputAsMB->GetBounds(bounds);
35 } else if(input->IsA("vtkDataSet")) {
36 auto inputAsDS = vtkDataSet::SafeDownCast(input);
37 inputAsDS->GetBounds(bounds);
38 } else {
39 this->printErr("Unable to compute bounding box of "
40 + std::string(input->GetClassName()));
41 return 0;
42 }
43
44 double const dx = bounds[1] - bounds[0];
45 double const dy = bounds[3] - bounds[2];
46 double const dz = bounds[5] - bounds[4];
47
48 this->SetRadius(this->Scale * std::sqrt(dx * dx + dy * dy + dz * dz) / 2.0);
49 this->SetCenter(
50 bounds[0] + dx * 0.5, bounds[2] + dy * 0.5, bounds[4] + dz * 0.5);
51
52 return this->ttkIcosphere::RequestData(request, inputVector, outputVector);
53}
int FillInputPortInformation(int port, vtkInformation *info) override
~ttkIcosphereFromObject() override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
virtual void SetCenter(double, double, double)
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
virtual void SetRadius(double)
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:149
vtkStandardNewMacro(ttkIcosphereFromObject)