19 #include <vtkDataArray.h>
20 #include <vtkDataSetMapper.h>
21 #include <vtkImageAlgorithm.h>
22 #include <vtkImageChangeInformation.h>
23 #include <vtkImageData.h>
24 #include <vtkImageShiftScale.h>
25 #include <vtkPointData.h>
26 #include <vtkRenderer.h>
27 #include <vtkSmartPointer.h>
35 #include <vtkImageActor.h>
36 #include <vtkXMLImageDataWriter.h>
39 vtkAlgorithm* algorithm,
TreeItem* parentItem,
40 const QList<QVariant> data )
47 const QList<QVariant> data )
49 _transformFilter(nullptr)
60 auto* img =
dynamic_cast<vtkImageAlgorithm*
>(
_algorithm);
67 img->GetOutput()->GetOrigin(origin);
68 img->GetOutput()->GetSpacing(spacing);
70 img->GetOutput()->GetPointData()->GetScalars()->GetRange(range);
71 vtkImageShiftScale*
scale = vtkImageShiftScale::New();
72 scale->SetOutputScalarTypeToUnsignedChar();
73 scale->SetInputConnection(img->GetOutputPort());
74 scale->SetShift(-range[0]);
75 scale->SetScale(255.0 / (range[1] - range[0]));
89 vtkImageActor* imageActor = vtkImageActor::New();
109 newProps->SetScalarVisibility(parentProps->GetScalarVisibility());
110 newProps->SetTexture(parentProps->GetTexture());
126 if (vtkProps->GetActiveAttribute().length() > 0)
132 auto* visParentItem =
138 if (vtkProps->GetTexture() !=
nullptr)
153 const std::string& filename)
const
155 std::string file_name_cpy(filename);
156 auto* algID =
dynamic_cast<vtkImageAlgorithm*
>(
algorithm);
159 vtkSmartPointer<vtkXMLImageDataWriter> iWriter =
160 vtkSmartPointer<vtkXMLImageDataWriter>::New();
161 iWriter->SetInputData(algID->GetOutputDataObject(0));
164 file_name_cpy.append(
".vti");
166 iWriter->SetFileName(file_name_cpy.c_str());
167 return iWriter->Write();
169 ERR(
"VtkVisPipelineItem::writeToFile() - Unknown data type.");
void ERR(char const *fmt, Args const &... args)
Definition of the VtkAlgorithmProperties class.
Definition of the VtkGeoImageSource class.
Definition of the VtkVisImageItem class.
Objects nodes for the TreeModel.
TreeItem * parentItem() const
Contains properties for the visualization of objects as VtkVisPipelineItems.
Is used to combine several filter in one VtkVisPipelineItem. You can use vtk filter and custom filter...
vtkImageChangeInformation * _transformFilter
VtkVisImageItem(vtkAlgorithm *algorithm, TreeItem *parentItem, const QList< QVariant > data=QList< QVariant >())
Constructor for a source/filter object.
void Initialize(vtkRenderer *renderer) override
Initializes vtkMapper and vtkActor necessary for visualization of the item and sets the item's proper...
vtkAlgorithm * transformFilter() const override
int callVTKWriter(vtkAlgorithm *algorithm, const std::string &filename) const override
Selects the appropriate VTK-Writer object and writes the object to a file with the given name.
~VtkVisImageItem() override
void setVtkProperties(VtkAlgorithmProperties *vtkProps)
void setTranslation(double x, double y, double z) const override
Translates the item in visualisation-space. This function is empty and needs to be implemented by der...
An item in the VtkVisPipeline containing a graphic object to be visualized.
vtkAlgorithm * algorithm() const
Returns the algorithm object.
vtkAlgorithm * _algorithm
virtual void SetActiveAttribute(const QString &str)
std::string getFileExtension(const std::string &path)
void scale(PETScVector &x, double const a)