Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "vtkUnstructuredGridMapper.h"
00018
00019 #include "vtkGeometryFilter.h"
00020 #include "vtkExecutive.h"
00021 #include "vtkGarbageCollector.h"
00022 #include "vtkInformation.h"
00023 #include "vtkObjectFactory.h"
00024 #include "vtkPolyData.h"
00025 #include "vtkPolyDataMapper.h"
00026 #include "vtkUnstructuredGrid.h"
00027
00028 vtkCxxRevisionMacro(vtkUnstructuredGridMapper, "$Revision$");
00029 vtkStandardNewMacro(vtkUnstructuredGridMapper);
00030
00031
00032 vtkUnstructuredGridMapper::vtkUnstructuredGridMapper()
00033 {
00034 this->GeometryExtractor = 0;
00035 this->PolyDataMapper = 0;
00036 }
00037
00038
00039 vtkUnstructuredGridMapper::~vtkUnstructuredGridMapper()
00040 {
00041
00042 if ( this->GeometryExtractor )
00043 {
00044 this->GeometryExtractor->Delete();
00045 }
00046 if ( this->PolyDataMapper )
00047 {
00048 this->PolyDataMapper->Delete();
00049 }
00050
00051 }
00052
00053 void vtkUnstructuredGridMapper::SetBoundingObject(mitk::BoundingObject* bo)
00054 {
00055 m_BoundingObject = bo;
00056 }
00057
00058
00059 void vtkUnstructuredGridMapper::SetInput(vtkUnstructuredGrid *input)
00060 {
00061 if(input)
00062 {
00063 this->SetInputConnection(0, input->GetProducerPort());
00064 }
00065 else
00066 {
00067
00068 this->SetInputConnection(0, 0);
00069 }
00070 }
00071
00072
00073 vtkUnstructuredGrid *vtkUnstructuredGridMapper::GetInput()
00074 {
00075
00076 return vtkUnstructuredGrid::SafeDownCast(
00077 this->GetExecutive()->GetInputData(0, 0));
00078 }
00079
00080
00081 void vtkUnstructuredGridMapper::ReleaseGraphicsResources( vtkWindow *renWin )
00082 {
00083 if (this->PolyDataMapper)
00084 {
00085 this->PolyDataMapper->ReleaseGraphicsResources( renWin );
00086 }
00087 }
00088
00089
00090
00091
00092 void vtkUnstructuredGridMapper::Render(vtkRenderer *ren, vtkActor *act)
00093 {
00094
00095
00096 if ( !this->GetInput() )
00097 {
00098 vtkErrorMacro(<< "No input!\n");
00099 return;
00100 }
00101
00102
00103
00104 if ( this->LookupTable == 0 )
00105 {
00106 this->CreateDefaultLookupTable();
00107 }
00108 this->LookupTable->Build();
00109
00110
00111
00112 if ( this->PolyDataMapper == 0 )
00113 {
00114 vtkGeometryFilter *gf = vtkGeometryFilter::New();
00115 vtkPolyDataMapper *pm = vtkPolyDataMapper::New();
00116 pm->SetInput(gf->GetOutput());
00117
00118 this->GeometryExtractor = gf;
00119 this->PolyDataMapper = pm;
00120 }
00121
00122
00123
00124 if (this->ClippingPlanes != this->PolyDataMapper->GetClippingPlanes())
00125 {
00126 this->PolyDataMapper->SetClippingPlanes(this->ClippingPlanes);
00127 }
00128
00129 if (this->m_BoundingObject)
00130 {
00131 mitk::BoundingBox::BoundsArrayType bounds = this->m_BoundingObject->GetGeometry()->CalculateBoundingBoxRelativeToTransform(0)->GetBounds();
00132 this->GeometryExtractor->SetExtent(bounds[0], bounds[1], bounds[2],
00133 bounds[3], bounds[4], bounds[5]);
00134 this->GeometryExtractor->ExtentClippingOn();
00135 }
00136 else
00137 {
00138 this->GeometryExtractor->ExtentClippingOff();
00139 }
00140
00141 this->GeometryExtractor->SetInput(this->GetInput());
00142 this->PolyDataMapper->SetInput(this->GeometryExtractor->GetOutput());
00143
00144
00145 this->PolyDataMapper->SetLookupTable(this->GetLookupTable());
00146 this->PolyDataMapper->SetScalarVisibility(this->GetScalarVisibility());
00147 this->PolyDataMapper->SetUseLookupTableScalarRange(
00148 this->GetUseLookupTableScalarRange());
00149 this->PolyDataMapper->SetScalarRange(this->GetScalarRange());
00150 this->PolyDataMapper->SetImmediateModeRendering(
00151 this->GetImmediateModeRendering());
00152 this->PolyDataMapper->SetColorMode(this->GetColorMode());
00153 this->PolyDataMapper->SetInterpolateScalarsBeforeMapping(
00154 this->GetInterpolateScalarsBeforeMapping());
00155
00156 this->PolyDataMapper->SetScalarMode(this->GetScalarMode());
00157 if ( this->ScalarMode == VTK_SCALAR_MODE_USE_POINT_FIELD_DATA ||
00158 this->ScalarMode == VTK_SCALAR_MODE_USE_CELL_FIELD_DATA )
00159 {
00160 if ( this->ArrayAccessMode == VTK_GET_ARRAY_BY_ID )
00161 {
00162 this->PolyDataMapper->ColorByArrayComponent(this->ArrayId,ArrayComponent);
00163 }
00164 else
00165 {
00166 this->PolyDataMapper->ColorByArrayComponent(this->ArrayName,ArrayComponent);
00167 }
00168 }
00169
00170 this->PolyDataMapper->Render(ren,act);
00171 this->TimeToDraw = this->PolyDataMapper->GetTimeToDraw();
00172 }
00173
00174
00175 void vtkUnstructuredGridMapper::PrintSelf(ostream& os, vtkIndent indent)
00176 {
00177 this->Superclass::PrintSelf(os,indent);
00178
00179 if ( this->PolyDataMapper )
00180 {
00181 os << indent << "Poly Mapper: (" << this->PolyDataMapper << ")\n";
00182 }
00183 else
00184 {
00185 os << indent << "Poly Mapper: (none)\n";
00186 }
00187
00188 if ( this->GeometryExtractor )
00189 {
00190 os << indent << "Geometry Extractor: (" << this->GeometryExtractor << ")\n";
00191 }
00192 else
00193 {
00194 os << indent << "Geometry Extractor: (none)\n";
00195 }
00196 }
00197
00198
00199 unsigned long vtkUnstructuredGridMapper::GetMTime()
00200 {
00201 unsigned long mTime=this->vtkMapper::GetMTime();
00202 unsigned long time;
00203
00204 if ( this->LookupTable != NULL )
00205 {
00206 time = this->LookupTable->GetMTime();
00207 mTime = ( time > mTime ? time : mTime );
00208 }
00209
00210 return mTime;
00211 }
00212
00213
00214 int vtkUnstructuredGridMapper::FillInputPortInformation(
00215 int vtkNotUsed(port), vtkInformation* info)
00216 {
00217 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkUnstructuredGrid");
00218 return 1;
00219 }
00220
00221
00222 void vtkUnstructuredGridMapper::ReportReferences(vtkGarbageCollector* collector)
00223 {
00224 this->Superclass::ReportReferences(collector);
00225
00226
00227 vtkGarbageCollectorReport(collector, this->GeometryExtractor,
00228 "GeometryExtractor");
00229 vtkGarbageCollectorReport(collector, this->PolyDataMapper,
00230 "PolyDataMapper");
00231 }