00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "vtkMaskedGlyph3D.h" 00019 00020 #include "vtkMaskPoints.h" 00021 #include "vtkObjectFactory.h" 00022 #include "vtkPolyData.h" 00023 00024 vtkStandardNewMacro(vtkMaskedGlyph3D); 00025 vtkCxxRevisionMacro(vtkMaskedGlyph3D, ""); 00026 00027 vtkMaskedGlyph3D::vtkMaskedGlyph3D() 00028 { 00029 this->SetColorModeToColorByScalar(); 00030 this->SetScaleModeToScaleByVector(); 00031 this->MaskPoints = vtkMaskPoints::New(); 00032 this->MaximumNumberOfPoints = 5000; 00033 this->UseMaskPoints = 1; 00034 } 00035 00036 vtkMaskedGlyph3D::~vtkMaskedGlyph3D() 00037 { 00038 if(this->MaskPoints) 00039 { 00040 this->MaskPoints->Delete(); 00041 } 00042 } 00043 00044 void vtkMaskedGlyph3D::SetInput(vtkDataSet *input) 00045 { 00046 this->MaskPoints->SetInput(input); 00047 this->Superclass::SetInputConnection(this->MaskPoints->GetOutputPort()); 00048 } 00049 00050 void vtkMaskedGlyph3D::SetInputConnection(vtkAlgorithmOutput* input) 00051 { 00052 this->MaskPoints->SetInputConnection(input); 00053 this->Superclass::SetInputConnection(this->MaskPoints->GetOutputPort()); 00054 } 00055 00056 void vtkMaskedGlyph3D::SetRandomMode(int mode) 00057 { 00058 this->MaskPoints->SetRandomMode(mode); 00059 } 00060 00061 int vtkMaskedGlyph3D::GetRandomMode() 00062 { 00063 return this->MaskPoints->GetRandomMode(); 00064 } 00065 00066 void vtkMaskedGlyph3D::Execute() 00067 { 00068 if (this->UseMaskPoints) 00069 { 00070 vtkIdType numPts = this->MaskPoints->GetPolyDataInput(0)->GetNumberOfPoints(); 00071 this->MaskPoints->SetMaximumNumberOfPoints( MaximumNumberOfPoints ); 00072 this->MaskPoints->SetOnRatio( numPts / MaximumNumberOfPoints ); 00073 this->MaskPoints->Update(); 00074 this->Superclass::SetInput(this->MaskPoints->GetOutput()); 00075 } 00076 else 00077 { 00078 this->Superclass::SetInput(this->MaskPoints->GetInput()); 00079 } 00080 00081 this->Superclass::Execute(); 00082 } 00083 00084 int vtkMaskedGlyph3D::RequestData( 00085 vtkInformation *request, 00086 vtkInformationVector **inputVector, 00087 vtkInformationVector *outputVector) 00088 { 00089 if (this->UseMaskPoints) 00090 { 00091 this->Superclass::SetInput(this->MaskPoints->GetOutput()); 00092 vtkIdType numPts = this->MaskPoints->GetPolyDataInput(0)->GetNumberOfPoints(); 00093 this->MaskPoints->SetMaximumNumberOfPoints( MaximumNumberOfPoints ); 00094 this->MaskPoints->SetOnRatio( numPts / MaximumNumberOfPoints ); 00095 this->MaskPoints->Update(); 00096 } 00097 else 00098 { 00099 this->Superclass::SetInput(this->MaskPoints->GetInput()); 00100 } 00101 00102 return this->Superclass::RequestData( 00103 request,inputVector,outputVector); 00104 } 00105 00106 void vtkMaskedGlyph3D::PrintSelf(ostream& os, vtkIndent indent) 00107 { 00108 this->Superclass::PrintSelf(os,indent); 00109 00110 os << indent << "MaximumNumberOfPoints: " << this->GetMaximumNumberOfPoints() 00111 << endl; 00112 00113 os << indent << "UseMaskPoints: " << (this->UseMaskPoints?"on":"off") << endl; 00114 }