Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
vtkMaskedGlyph3D.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "vtkMaskedGlyph3D.h"
14 
15 #include "vtkMaskPoints.h"
16 #include "vtkObjectFactory.h"
17 #include "vtkPolyData.h"
18 
20 
22 {
23  this->SetColorModeToColorByScalar();
24  this->SetScaleModeToScaleByVector();
25  this->MaskPoints = vtkMaskPoints::New();
26  this->MaximumNumberOfPoints = 5000;
27  this->UseMaskPoints = 1;
28 }
29 
31 {
32  if (this->MaskPoints)
33  {
34  this->MaskPoints->Delete();
35  }
36 }
37 
38 void vtkMaskedGlyph3D::SetInput(vtkDataSet *input)
39 {
40  this->MaskPoints->SetInputData(input);
41  this->Superclass::SetInputConnection(this->MaskPoints->GetOutputPort());
42 }
43 
44 void vtkMaskedGlyph3D::SetInputConnection(vtkAlgorithmOutput *input)
45 {
46  this->MaskPoints->SetInputConnection(input);
47  this->Superclass::SetInputConnection(this->MaskPoints->GetOutputPort());
48 }
49 
51 {
52  this->MaskPoints->SetRandomMode(mode);
53 }
54 
56 {
57  return this->MaskPoints->GetRandomMode();
58 }
59 
60 int vtkMaskedGlyph3D::RequestData(vtkInformation *request,
61  vtkInformationVector **inputVector,
62  vtkInformationVector *outputVector)
63 {
64  if (this->UseMaskPoints)
65  {
66  this->Superclass::SetInputConnection(this->MaskPoints->GetOutputPort());
67  vtkIdType numPts = this->MaskPoints->GetPolyDataInput(0)->GetNumberOfPoints();
68  this->MaskPoints->SetMaximumNumberOfPoints(MaximumNumberOfPoints);
69  this->MaskPoints->SetOnRatio(numPts / MaximumNumberOfPoints);
70  this->MaskPoints->Update();
71  }
72  else
73  {
74  this->Superclass::SetInputData(this->MaskPoints->GetInput());
75  }
76 
77  return this->Superclass::RequestData(request, inputVector, outputVector);
78 }
79 
80 void vtkMaskedGlyph3D::PrintSelf(ostream &os, vtkIndent indent)
81 {
82  this->Superclass::PrintSelf(os, indent);
83 
84  os << indent << "MaximumNumberOfPoints: " << this->GetMaximumNumberOfPoints() << endl;
85 
86  os << indent << "UseMaskPoints: " << (this->UseMaskPoints ? "on" : "off") << endl;
87 }
vtkMaskPoints * MaskPoints
void PrintSelf(ostream &os, vtkIndent indent) override
void SetInputConnection(vtkAlgorithmOutput *input) override
void SetRandomMode(int mode)
~vtkMaskedGlyph3D() override
virtual void SetInput(vtkDataSet *input)
vtkStandardNewMacro(vtkMaskedGlyph3D)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override