00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ 00006 Version: $Revision: 18127 $ 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 "vtkMaskedProgrammableGlyphFilter.h" 00019 00020 #include "vtkMaskPoints.h" 00021 #include "vtkObjectFactory.h" 00022 #include "vtkPolyData.h" 00023 00024 vtkStandardNewMacro(vtkMaskedProgrammableGlyphFilter); 00025 vtkCxxRevisionMacro(vtkMaskedProgrammableGlyphFilter, ""); 00026 00027 vtkMaskedProgrammableGlyphFilter::vtkMaskedProgrammableGlyphFilter() 00028 { 00029 //this->SetColorModeToColorByScalar(); 00030 //this->SetScaleModeToScaleByVector(); 00031 this->MaskPoints = vtkMaskPoints::New(); 00032 this->MaximumNumberOfPoints = 5000; 00033 this->UseMaskPoints = 1; 00034 } 00035 00036 vtkMaskedProgrammableGlyphFilter::~vtkMaskedProgrammableGlyphFilter() 00037 { 00038 if(this->MaskPoints) 00039 { 00040 this->MaskPoints->Delete(); 00041 } 00042 } 00043 00044 void vtkMaskedProgrammableGlyphFilter::SetInput(vtkDataSet *input) 00045 { 00046 this->MaskPoints->SetInput(input); 00047 this->Superclass::SetInput(this->MaskPoints->GetOutput()); 00048 } 00049 00050 void vtkMaskedProgrammableGlyphFilter::SetRandomMode(int mode) 00051 { 00052 this->MaskPoints->SetRandomMode(mode); 00053 } 00054 00055 int vtkMaskedProgrammableGlyphFilter::GetRandomMode() 00056 { 00057 return this->MaskPoints->GetRandomMode(); 00058 } 00059 00060 void vtkMaskedProgrammableGlyphFilter::Execute() 00061 { 00062 if (this->UseMaskPoints) 00063 { 00064 this->Superclass::SetInput(this->MaskPoints->GetOutput()); 00065 vtkIdType numPts = this->MaskPoints->GetPolyDataInput(0)->GetNumberOfPoints(); 00066 this->MaskPoints->SetMaximumNumberOfPoints(MaximumNumberOfPoints); 00067 double onRatio = MaximumNumberOfPoints != 0.0 ? numPts / MaximumNumberOfPoints : 1.0; 00068 this->MaskPoints->SetOnRatio(onRatio); 00069 this->MaskPoints->Update(); 00070 } 00071 else 00072 { 00073 this->Superclass::SetInput(this->MaskPoints->GetInput()); 00074 } 00075 00076 this->Superclass::Execute(); 00077 } 00078 00079 int vtkMaskedProgrammableGlyphFilter::RequestData( 00080 vtkInformation *request, 00081 vtkInformationVector **inputVector, 00082 vtkInformationVector *outputVector) 00083 { 00084 if (this->UseMaskPoints) 00085 { 00086 this->Superclass::SetInput(this->MaskPoints->GetOutput()); 00087 vtkIdType numPts = this->MaskPoints->GetPolyDataInput(0)->GetNumberOfPoints(); 00088 this->MaskPoints->SetMaximumNumberOfPoints(MaximumNumberOfPoints); 00089 this->MaskPoints->SetOnRatio(numPts / MaximumNumberOfPoints); 00090 this->MaskPoints->Update(); 00091 } 00092 else 00093 { 00094 this->Superclass::SetInput(this->MaskPoints->GetInput()); 00095 } 00096 00097 return this->Superclass::RequestData( 00098 request,inputVector,outputVector); 00099 } 00100 00101 00102 void vtkMaskedProgrammableGlyphFilter::PrintSelf(ostream& os, vtkIndent indent) 00103 { 00104 this->Superclass::PrintSelf(os,indent); 00105 //os << indent << "InputScalarsSelection: " 00106 // << (this->InputScalarsSelection ? this->InputScalarsSelection : "(none)") 00107 // << endl; 00108 00109 //os << indent << "InputVectorsSelection: " 00110 // << (this->InputVectorsSelection ? this->InputVectorsSelection : "(none)") 00111 // << endl; 00112 00113 //os << indent << "InputNormalsSelection: " 00114 // << (this->InputNormalsSelection ? this->InputNormalsSelection : "(none)") 00115 // << endl; 00116 00117 os << indent << "MaximumNumberOfPoints: " << this->GetMaximumNumberOfPoints() 00118 << endl; 00119 00120 os << indent << "UseMaskPoints: " << (this->UseMaskPoints?"on":"off") << endl; 00121 }