OGS
VtkImageDataToLinePolyDataFilter Class Reference

Detailed Description

Creates lines that stand on top of the image with the length of the corresponding first sub-pixel value (the grey or red value). The maximum height is 0.1 * longest image dimension. Used by VtkCompositeImageDataToCylindersFilter.

Definition at line 27 of file VtkImageDataToLinePolyDataFilter.h.

#include <VtkImageDataToLinePolyDataFilter.h>

Inheritance diagram for VtkImageDataToLinePolyDataFilter:
[legend]
Collaboration diagram for VtkImageDataToLinePolyDataFilter:
[legend]

Public Member Functions

 vtkTypeMacro (VtkImageDataToLinePolyDataFilter, vtkPolyDataAlgorithm)
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Prints information about itself.
 
 ogsUserPropertyMacro (LengthScaleFactor, double)
 Sets the scaling of the length of the lines.
 
void SetUserProperty (QString name, QVariant value) override
 Sets a user property.
 
 vtkGetMacro (ImageSpacing, double)
 Returns the space between two pixels.
 
 VtkImageDataToLinePolyDataFilter (const VtkImageDataToLinePolyDataFilter &)=delete
 
void operator= (const VtkImageDataToLinePolyDataFilter &)=delete
 
- Public Member Functions inherited from VtkAlgorithmProperties
 VtkAlgorithmProperties (QObject *parent=nullptr)
 Constructor (sets default values)
 
 ~VtkAlgorithmProperties () override
 
vtkProperty * GetProperties () const
 Returns the vtk properties.
 
vtkTexture * GetTexture ()
 Returns a texture (if one has been assigned).
 
void SetTexture (vtkTexture *t)
 Sets a texture for the VtkVisPipelineItem.
 
vtkLookupTable * GetLookupTable (const QString &array_name)
 Returns the colour lookup table (if one has been assigned).
 
void RemoveLookupTable (const QString &array_name)
 Removes the lookup table for the given scalar.
 
void SetLookUpTable (const QString &array_name, vtkLookupTable *lut)
 Sets a colour lookup table for the given scalar array of the VtkVisPipelineItem.
 
void SetLookUpTable (const QString &array_name, const QString &filename)
 Loads a predefined color lookup table from a file for the specified scalar array.
 
bool GetScalarVisibility () const
 Returns the scalar visibility.
 
void SetScalarVisibility (bool on)
 Sets the scalar visibility.
 
QString GetName () const
 Returns the name. This is set to the file path if it is a source algorithm.
 
void SetName (QString name)
 Sets the name.
 
bool IsRemovable () const
 Is this algorithm removable from the pipeline (view).
 
QMap< QString, QVariant > * GetAlgorithmUserProperties () const
 Returns a map of user properties.
 
QMap< QString, QList< QVariant > > * GetAlgorithmUserVectorProperties () const
 Returns a map of vector user properties.
 
QVariant GetUserProperty (QString name) const
 Returns the value of a user property.
 
virtual void SetUserVectorProperty (QString name, QList< QVariant > values)
 Sets a vector user property. This should be implemented by subclasses.
 
QList< QVariant > GetUserVectorProperty (QString name) const
 Returns a list of values of a vector user property.
 
void SetActiveAttribute (QString name)
 Set the active attribute.
 
QString GetActiveAttribute () const
 Returns the desired active attribute.
 

Static Public Member Functions

static VtkImageDataToLinePolyDataFilterNew ()
 Create new objects with New() because of VTKs reference counting.
 

Protected Member Functions

 VtkImageDataToLinePolyDataFilter ()
 Constructor.
 
 ~VtkImageDataToLinePolyDataFilter () override
 Destructor.
 
int FillInputPortInformation (int port, vtkInformation *info) override
 Sets input port to vtkImageData.
 
int RequestData (vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
 Converts the image data to lines.
 

Protected Attributes

double ImageSpacing {0.0}
 The spacing of the image.
 
- Protected Attributes inherited from VtkAlgorithmProperties
vtkProperty * _property
 
vtkTexture * _texture
 
bool _scalarVisibility
 
std::map< QString, vtkLookupTable * > _lut
 
QString _name
 
QString _activeAttributeName
 
bool _removable
 
QMap< QString, QVariant > * _algorithmUserProperties
 
QMap< QString, QList< QVariant > > * _algorithmUserVectorProperties
 

Additional Inherited Members

- Signals inherited from VtkAlgorithmProperties
void ScalarVisibilityChanged (bool on)
 

Constructor & Destructor Documentation

◆ VtkImageDataToLinePolyDataFilter() [1/2]

VtkImageDataToLinePolyDataFilter::VtkImageDataToLinePolyDataFilter ( const VtkImageDataToLinePolyDataFilter & )
delete

◆ VtkImageDataToLinePolyDataFilter() [2/2]

VtkImageDataToLinePolyDataFilter::VtkImageDataToLinePolyDataFilter ( )
protected

Constructor.

Definition at line 29 of file VtkImageDataToLinePolyDataFilter.cpp.

31{
32 this->SetLengthScaleFactor(1.0);
33}

◆ ~VtkImageDataToLinePolyDataFilter()

VtkImageDataToLinePolyDataFilter::~VtkImageDataToLinePolyDataFilter ( )
overrideprotecteddefault

Destructor.

Member Function Documentation

◆ FillInputPortInformation()

int VtkImageDataToLinePolyDataFilter::FillInputPortInformation ( int port,
vtkInformation * info )
overrideprotected

Sets input port to vtkImageData.

Definition at line 43 of file VtkImageDataToLinePolyDataFilter.cpp.

45{
46 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkImageData");
47 return 1;
48}

◆ New()

static VtkImageDataToLinePolyDataFilter * VtkImageDataToLinePolyDataFilter::New ( )
static

Create new objects with New() because of VTKs reference counting.

Referenced by VtkFilterFactory::CreateSimpleFilter(), and VtkCompositeImageToCylindersFilter::init().

◆ ogsUserPropertyMacro()

VtkImageDataToLinePolyDataFilter::ogsUserPropertyMacro ( LengthScaleFactor ,
double  )

Sets the scaling of the length of the lines.

◆ operator=()

void VtkImageDataToLinePolyDataFilter::operator= ( const VtkImageDataToLinePolyDataFilter & )
delete

◆ PrintSelf()

void VtkImageDataToLinePolyDataFilter::PrintSelf ( ostream & os,
vtkIndent indent )
override

Prints information about itself.

Definition at line 37 of file VtkImageDataToLinePolyDataFilter.cpp.

38{
39 this->Superclass::PrintSelf(os, indent);
40 os << indent << "LengthScaleFactor: " << this->LengthScaleFactor << "\n";
41}

◆ RequestData()

int VtkImageDataToLinePolyDataFilter::RequestData ( vtkInformation * request,
vtkInformationVector ** inputVector,
vtkInformationVector * outputVector )
overrideprotected

Converts the image data to lines.

Definition at line 50 of file VtkImageDataToLinePolyDataFilter.cpp.

54{
55 vtkDebugMacro(<< "Executing VtkImageDataToPolyDataFilter");
56
57 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
58 vtkInformation* outInfo = outputVector->GetInformationObject(0);
59 vtkImageData* input =
60 vtkImageData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
61 vtkPolyData* output =
62 vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
63
64 void* inScalarPtr = input->GetScalarPointer();
65 int numScalarComponents = input->GetNumberOfScalarComponents();
66
67 double spacing[3];
68 input->GetSpacing(spacing);
69 this->ImageSpacing = spacing[0];
70
71 int dimensions[3];
72 input->GetDimensions(dimensions);
73
74 // Skip execution if there are no points
75 vtkIdType numPts = input->GetNumberOfPoints();
76 if (numPts < 1)
77 {
78 vtkDebugMacro("No data to extract lines!");
79 return 1;
80 }
81
82 // Allocate the space needed for the output cells.
83 output->Allocate(numPts);
84
85 // Allocate space for a new set of points
86 vtkSmartPointer<vtkPoints> newPts = vtkSmartPointer<vtkPoints>::New();
87 newPts->SetNumberOfPoints(numPts * 2);
88
89 // Allocate space for the data associated with the new set of points
90 vtkPointData* inPD = input->GetPointData();
91 vtkPointData* outPD = output->GetPointData();
92 outPD->CopyAllocate(inPD, numPts * 16, numPts);
93
94 // Compute scaling factor that max height is 0.1 * longest image dimension
95 double range[2];
96 inPD->GetArray(0)->GetRange(range);
97 double const scalingFactor =
98 (std::max(dimensions[0], dimensions[1]) * spacing[0] * 0.1) /
99 std::max(range[0], range[1]);
100
101 double dir[3] = {0, 0, 1};
102
103 // Traverse all points creating another point with scalar distance in Z
104 // direction
105 for (vtkIdType ptId = 0; ptId < numPts; ++ptId)
106 {
107 // Skip translucent pixels
108 float opacity =
109 (static_cast<float*>(inScalarPtr))[ptId * numScalarComponents + 1];
110 if (opacity < 0.00000001f)
111 {
112 continue;
113 }
114
115 // Compute length of the new line (scalar * LengthScaleFactor)
116 double const length =
117 (static_cast<float*>(inScalarPtr))[ptId * numScalarComponents] *
118 scalingFactor * this->LengthScaleFactor;
119
120 // Skip this line if length is zero
121 if (length < 0.00000001f)
122 {
123 continue;
124 }
125
126 // Get the old point location
127 double p[3];
128 input->GetPoint(ptId, p);
129
130 // Compute the new point location
131 double newPt[3];
132 for (std::size_t i = 0; i < 3; ++i)
133 {
134 newPt[i] = p[i] + dir[i] * length;
135 }
136
137 // Copy the old point
138 newPts->SetPoint(ptId * 2, p);
139 outPD->CopyData(inPD, ptId, ptId * 2);
140
141 // Create the new point
142 newPts->SetPoint(ptId * 2 + 1, newPt);
143 outPD->CopyData(inPD, ptId, ptId * 2 + 1);
144
145 // Create the line
146 vtkSmartPointer<vtkLine> line = vtkSmartPointer<vtkLine>::New();
147 line->GetPointIds()->SetId(0, ptId * 2);
148 line->GetPointIds()->SetId(1, ptId * 2 + 1);
149 output->InsertNextCell(line->GetCellType(), line->GetPointIds());
150 }
151
152 // Store the new set of points in the output
153 output->SetPoints(newPts);
154 output->GetPointData()->GetArray(0)->SetName("Colors");
155
156 // Avoid keeping extra memory around
157 output->Squeeze();
158
159 vtkDebugMacro(<< "Created: " << newPts->GetNumberOfPoints() << " points, "
160 << output->GetNumberOfCells() << " lines");
161
162 return 1;
163}

References ImageSpacing.

◆ SetUserProperty()

void VtkImageDataToLinePolyDataFilter::SetUserProperty ( QString name,
QVariant value )
inlineoverridevirtual

Sets a user property.

Reimplemented from VtkAlgorithmProperties.

Definition at line 42 of file VtkImageDataToLinePolyDataFilter.h.

43 {
44 if (name.compare("LengthScaleFactor") == 0)
45 SetLengthScaleFactor(value.toDouble());
46 }

Referenced by VtkCompositeImageToCylindersFilter::SetUserProperty().

◆ vtkGetMacro()

VtkImageDataToLinePolyDataFilter::vtkGetMacro ( ImageSpacing ,
double  )

Returns the space between two pixels.

◆ vtkTypeMacro()

VtkImageDataToLinePolyDataFilter::vtkTypeMacro ( VtkImageDataToLinePolyDataFilter ,
vtkPolyDataAlgorithm  )

Member Data Documentation

◆ ImageSpacing

double VtkImageDataToLinePolyDataFilter::ImageSpacing {0.0}
protected

The spacing of the image.

Definition at line 70 of file VtkImageDataToLinePolyDataFilter.h.

70{0.0};

Referenced by RequestData().


The documentation for this class was generated from the following files: