00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "mitkPointSetVtkMapper3D.h"
00020 #include "mitkDataNode.h"
00021 #include "mitkProperties.h"
00022 #include "mitkColorProperty.h"
00023 #include "mitkVtkPropRenderer.h"
00024 #include "mitkPointSet.h"
00025
00026 #include <vtkActor.h>
00027 #include <vtkAppendPolyData.h>
00028 #include <vtkPropAssembly.h>
00029 #include <vtkTubeFilter.h>
00030 #include <vtkRenderer.h>
00031 #include <vtkSphereSource.h>
00032 #include <vtkCubeSource.h>
00033 #include <vtkConeSource.h>
00034 #include <vtkCylinderSource.h>
00035 #include <vtkProperty.h>
00036 #include <vtkPolyDataMapper.h>
00037 #include <vtkCellArray.h>
00038 #include <vtkVectorText.h>
00039 #include <vtkTransform.h>
00040 #include <vtkTransformPolyDataFilter.h>
00041
00042 #if (VTK_MAJOR_VERSION >= 5)
00043 #include <vtkPolyDataAlgorithm.h>
00044 #else
00045 #include <vtkPolyData.h>
00046 #endif
00047
00048 #include <stdlib.h>
00049
00050
00051
00052 const mitk::PointSet* mitk::PointSetVtkMapper3D::GetInput()
00053 {
00054 return static_cast<const mitk::PointSet * > ( GetData() );
00055 }
00056
00057 mitk::PointSetVtkMapper3D::PointSetVtkMapper3D()
00058 : m_vtkSelectedPointList(NULL),
00059 m_vtkUnselectedPointList(NULL),
00060
00061 m_VtkSelectedPolyDataMapper(NULL),
00062 m_VtkUnselectedPolyDataMapper(NULL),
00063
00064 m_vtkTextList(NULL),
00065
00066
00067 m_NumberOfSelectedAdded(0),
00068 m_NumberOfUnselectedAdded(0),
00069 m_PointSize(1.0),
00070 m_ContourRadius(0.5)
00071 {
00072
00073 m_PointsAssembly = vtkPropAssembly::New();
00074
00075
00076 m_SelectedActor = vtkActor::New();
00077 m_UnselectedActor = vtkActor::New();
00078 m_ContourActor = vtkActor::New();
00079 }
00080
00081 mitk::PointSetVtkMapper3D::~PointSetVtkMapper3D()
00082 {
00083 m_PointsAssembly->Delete();
00084
00085 m_SelectedActor->Delete();
00086 m_UnselectedActor->Delete();
00087 m_ContourActor->Delete();
00088 }
00089
00090 void mitk::PointSetVtkMapper3D::ReleaseGraphicsResources(vtkWindow *renWin)
00091 {
00092 m_PointsAssembly->ReleaseGraphicsResources(renWin);
00093
00094 m_SelectedActor->ReleaseGraphicsResources(renWin);
00095 m_UnselectedActor->ReleaseGraphicsResources(renWin);
00096 m_ContourActor->ReleaseGraphicsResources(renWin);
00097 }
00098
00099 void mitk::PointSetVtkMapper3D::CreateVTKRenderObjects()
00100 {
00101 m_vtkSelectedPointList = vtkAppendPolyData::New();
00102 m_vtkUnselectedPointList = vtkAppendPolyData::New();
00103
00104 m_PointsAssembly->VisibilityOn();
00105
00106 if(m_PointsAssembly->GetParts()->IsItemPresent(m_SelectedActor))
00107 m_PointsAssembly->RemovePart(m_SelectedActor);
00108 if(m_PointsAssembly->GetParts()->IsItemPresent(m_UnselectedActor))
00109 m_PointsAssembly->RemovePart(m_UnselectedActor);
00110 if(m_PointsAssembly->GetParts()->IsItemPresent(m_ContourActor))
00111 m_PointsAssembly->RemovePart(m_ContourActor);
00112
00113
00114 int mapperID;
00115 bool isInputDevice=false;
00116 if( this->GetDataNode()->GetBoolProperty("inputdevice",isInputDevice) && isInputDevice )
00117 {
00118 if( this->GetDataNode()->GetIntProperty("BaseRendererMapperID",mapperID) && mapperID == 2)
00119 return;
00120 }
00121
00122
00123 mitk::PointSet::Pointer input = const_cast<mitk::PointSet*>(this->GetInput());
00124
00125
00126 bool update = true;
00127 this->GetDataNode()->GetBoolProperty("updateDataOnRender", update);
00128 if (update == true)
00129 input->Update();
00130
00131 int timestep = this->GetTimestep();
00132
00133 mitk::PointSet::DataType::Pointer itkPointSet = input->GetPointSet( timestep );
00134
00135 if ( itkPointSet.GetPointer() == NULL)
00136 {
00137 m_PointsAssembly->VisibilityOff();
00138 return;
00139 }
00140
00141 mitk::PointSet::PointsContainer::Iterator pointsIter;
00142 mitk::PointSet::PointDataContainer::Iterator pointDataIter;
00143 int j;
00144
00145 m_NumberOfSelectedAdded = 0;
00146 m_NumberOfUnselectedAdded = 0;
00147
00148
00149 bool makeContour = false;
00150 this->GetDataNode()->GetBoolProperty("show contour", makeContour);
00151 if (makeContour)
00152 {
00153 this->CreateContour(NULL);
00154 }
00155
00156
00157
00158 m_PointSize = 2;
00159 mitk::FloatProperty::Pointer pointSizeProp = dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("pointsize"));
00160 if ( pointSizeProp.IsNotNull() )
00161 m_PointSize = pointSizeProp->GetValue();
00162
00163
00164 bool showLabel = true;
00165 this->GetDataNode()->GetBoolProperty("show label", showLabel);
00166 const char * pointLabel=NULL;
00167 if(showLabel)
00168 {
00169 if(dynamic_cast<mitk::StringProperty *>(this->GetDataNode()->GetPropertyList()->GetProperty("label")) != NULL)
00170 pointLabel =dynamic_cast<mitk::StringProperty *>(this->GetDataNode()->GetPropertyList()->GetProperty("label"))->GetValue();
00171 else
00172 showLabel = false;
00173 }
00174
00175
00176
00177 bool pointDataBroken = (itkPointSet->GetPointData()->Size() != itkPointSet->GetPoints()->Size());
00178
00179 pointDataIter = itkPointSet->GetPointData()->Begin();
00180 for (j=0, pointsIter=itkPointSet->GetPoints()->Begin();
00181 pointsIter!=itkPointSet->GetPoints()->End();
00182 pointsIter++, j++)
00183 {
00184
00185 int pointType;
00186
00187 if(itkPointSet->GetPointData()->size() == 0 || pointDataBroken)
00188 pointType = mitk::PTUNDEFINED;
00189 else
00190 pointType = pointDataIter.Value().pointSpec;
00191
00192 #if (VTK_MAJOR_VERSION >= 5)
00193 vtkPolyDataAlgorithm *source;
00194 #else
00195 vtkPolyDataSource *source;
00196 #endif
00197
00198 switch (pointType)
00199 {
00200 case mitk::PTUNDEFINED:
00201 {
00202 vtkSphereSource *sphere = vtkSphereSource::New();
00203 sphere->SetRadius(m_PointSize);
00204 itk::Point<float> point1 = pointsIter->Value();
00205 sphere->SetCenter(point1[0],point1[1],point1[2]);
00206
00207
00208
00209 if(isInputDevice)
00210 {
00211 sphere->SetThetaResolution(10);
00212 sphere->SetPhiResolution(10);
00213 }
00214 else
00215 {
00216 sphere->SetThetaResolution(20);
00217 sphere->SetPhiResolution(20);
00218 }
00219 source = sphere;
00220 }
00221 break;
00222 case mitk::PTSTART:
00223 {
00224 vtkCubeSource *cube = vtkCubeSource::New();
00225 cube->SetXLength(m_PointSize/2);
00226 cube->SetYLength(m_PointSize/2);
00227 cube->SetZLength(m_PointSize/2);
00228 itk::Point<float> point1 = pointsIter->Value();
00229 cube->SetCenter(point1[0],point1[1],point1[2]);
00230 source = cube;
00231 }
00232 break;
00233 case mitk::PTCORNER:
00234 {
00235 vtkConeSource *cone = vtkConeSource::New();
00236 cone->SetRadius(m_PointSize);
00237 itk::Point<float> point1 = pointsIter->Value();
00238 cone->SetCenter(point1[0],point1[1],point1[2]);
00239 cone->SetResolution(20);
00240 source = cone;
00241 }
00242 break;
00243 case mitk::PTEDGE:
00244 {
00245 vtkCylinderSource *cylinder = vtkCylinderSource::New();
00246 cylinder->SetRadius(m_PointSize);
00247 itk::Point<float> point1 = pointsIter->Value();
00248 cylinder->SetCenter(point1[0],point1[1],point1[2]);
00249 cylinder->SetResolution(20);
00250 source = cylinder;
00251 }
00252 break;
00253 case mitk::PTEND:
00254 {
00255 vtkSphereSource *sphere = vtkSphereSource::New();
00256 sphere->SetRadius(m_PointSize);
00257 itk::Point<float> point1 = pointsIter->Value();
00258 sphere->SetThetaResolution(20);
00259 sphere->SetPhiResolution(20);
00260 source = sphere;
00261 }
00262 break;
00263 default:
00264 {
00265 vtkSphereSource *sphere = vtkSphereSource::New();
00266 sphere->SetRadius(m_PointSize);
00267 itk::Point<float> point1 = pointsIter->Value();
00268 sphere->SetCenter(point1[0],point1[1],point1[2]);
00269 sphere->SetThetaResolution(20);
00270 sphere->SetPhiResolution(20);
00271 source = sphere;
00272 }
00273 break;
00274 }
00275 if (!pointDataBroken)
00276 {
00277 if (pointDataIter.Value().selected)
00278 {
00279 m_vtkSelectedPointList->AddInput(source->GetOutput());
00280 ++m_NumberOfSelectedAdded;
00281 }
00282 else
00283 {
00284 m_vtkUnselectedPointList->AddInput(source->GetOutput());
00285 ++m_NumberOfUnselectedAdded;
00286 }
00287 }
00288 else
00289 {
00290 m_vtkUnselectedPointList->AddInput(source->GetOutput());
00291 ++m_NumberOfUnselectedAdded;
00292 }
00293
00294 source->Delete();
00295
00296 if (showLabel)
00297 {
00298 char buffer[20];
00299 std::string l = pointLabel;
00300 if ( input->GetSize()>1 )
00301 {
00302 sprintf(buffer,"%d",j+1);
00303 l.append(buffer);
00304 }
00305
00306 vtkVectorText *label = vtkVectorText::New();
00307 label->SetText(l.c_str());
00308
00309
00310 vtkTransform *aLabelTransform =vtkTransform::New();
00311 aLabelTransform->Identity();
00312 itk::Point<float> point1 = pointsIter->Value();
00313 aLabelTransform->Translate(point1[0]+2,point1[1]+2,point1[2]);
00314 aLabelTransform->Scale(5.7,5.7,5.7);
00315
00316
00317 vtkTransformPolyDataFilter *labelTransform = vtkTransformPolyDataFilter::New();
00318 labelTransform->SetTransform(aLabelTransform);
00319 aLabelTransform->Delete();
00320 labelTransform->SetInput(label->GetOutput());
00321 label->Delete();
00322
00323
00324 if (pointType)
00325 {
00326 m_vtkSelectedPointList->AddInput(labelTransform->GetOutput());
00327 ++m_NumberOfSelectedAdded;
00328 }
00329 else
00330 {
00331 m_vtkUnselectedPointList->AddInput(labelTransform->GetOutput());
00332 ++m_NumberOfUnselectedAdded;
00333 }
00334 labelTransform->Delete();
00335 }
00336
00337 if(pointDataIter != itkPointSet->GetPointData()->End())
00338 pointDataIter++;
00339 }
00340
00341
00342
00343 if (m_NumberOfSelectedAdded > 0)
00344 {
00345 m_VtkSelectedPolyDataMapper = vtkPolyDataMapper::New();
00346 m_VtkSelectedPolyDataMapper->SetInput(m_vtkSelectedPointList->GetOutput());
00347
00348
00349 m_SelectedActor->Delete();
00350 m_SelectedActor = vtkActor::New();
00351
00352 m_SelectedActor->SetMapper(m_VtkSelectedPolyDataMapper);
00353 m_VtkSelectedPolyDataMapper->Delete();
00354 m_PointsAssembly->AddPart(m_SelectedActor);
00355 }
00356 m_vtkSelectedPointList->Delete();
00357
00358 if (m_NumberOfUnselectedAdded > 0)
00359 {
00360 m_VtkUnselectedPolyDataMapper = vtkPolyDataMapper::New();
00361 m_VtkUnselectedPolyDataMapper->SetInput(m_vtkUnselectedPointList->GetOutput());
00362
00363
00364 m_UnselectedActor->Delete();
00365 m_UnselectedActor = vtkActor::New();
00366
00367 m_UnselectedActor->SetMapper(m_VtkUnselectedPolyDataMapper);
00368 m_VtkUnselectedPolyDataMapper->Delete();
00369 m_PointsAssembly->AddPart(m_UnselectedActor);
00370 }
00371 m_vtkUnselectedPointList->Delete();
00372 }
00373
00374
00375 void mitk::PointSetVtkMapper3D::GenerateData()
00376 {
00377
00378 this->CreateVTKRenderObjects();
00379
00380
00381 Superclass::ApplyProperties( m_ContourActor, NULL );
00382 this->ApplyProperties(NULL);
00383
00384 }
00385
00386
00387 void mitk::PointSetVtkMapper3D::GenerateData( mitk::BaseRenderer *renderer )
00388 {
00389 SetVtkMapperImmediateModeRendering(m_VtkSelectedPolyDataMapper);
00390 SetVtkMapperImmediateModeRendering(m_VtkUnselectedPolyDataMapper);
00391
00392 mitk::FloatProperty::Pointer pointSizeProp = dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("pointsize"));
00393 mitk::FloatProperty::Pointer contourSizeProp = dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("contoursize"));
00394
00395 if ( pointSizeProp.IsNotNull() && contourSizeProp.IsNotNull() )
00396 {
00397 if (m_PointSize!=pointSizeProp->GetValue() || m_ContourRadius!= contourSizeProp->GetValue())
00398 {
00399 this->CreateVTKRenderObjects();
00400 }
00401 }
00402
00403
00404 Superclass::ApplyProperties( m_ContourActor, renderer );
00405 this->ApplyProperties(renderer);
00406
00407 if(IsVisible(renderer)==false)
00408 {
00409 m_UnselectedActor->VisibilityOff();
00410 m_SelectedActor->VisibilityOff();
00411 m_ContourActor->VisibilityOff();
00412 return;
00413 }
00414
00415 bool showPoints = true;
00416 this->GetDataNode()->GetBoolProperty("show points", showPoints);
00417 if(showPoints)
00418 {
00419 m_UnselectedActor->VisibilityOn();
00420 m_SelectedActor->VisibilityOn();
00421 }
00422 else
00423 {
00424 m_UnselectedActor->VisibilityOff();
00425 m_SelectedActor->VisibilityOff();
00426 }
00427
00428 if(dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("opacity")) != NULL)
00429 {
00430 mitk::FloatProperty::Pointer pointOpacity =dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("opacity"));
00431 float opacity = pointOpacity->GetValue();
00432 m_ContourActor->GetProperty()->SetOpacity(opacity);
00433 m_UnselectedActor->GetProperty()->SetOpacity(opacity);
00434 m_SelectedActor->GetProperty()->SetOpacity(opacity);
00435 }
00436
00437 bool makeContour = false;
00438 this->GetDataNode()->GetBoolProperty("show contour", makeContour);
00439 if (makeContour)
00440 {
00441 m_ContourActor->VisibilityOn();
00442 }
00443 else
00444 {
00445 m_ContourActor->VisibilityOff();
00446 }
00447 }
00448
00449
00450 void mitk::PointSetVtkMapper3D::ResetMapper( BaseRenderer* )
00451 {
00452 m_PointsAssembly->VisibilityOff();
00453 }
00454
00455
00456 vtkProp* mitk::PointSetVtkMapper3D::GetVtkProp(mitk::BaseRenderer * )
00457 {
00458 return m_PointsAssembly;
00459 }
00460
00461 void mitk::PointSetVtkMapper3D::UpdateVtkTransform(mitk::BaseRenderer * )
00462 {
00463 vtkLinearTransform * vtktransform =
00464 this->GetDataNode()->GetVtkTransform(this->GetTimestep());
00465
00466 m_SelectedActor->SetUserTransform(vtktransform);
00467 m_UnselectedActor->SetUserTransform(vtktransform);
00468 m_ContourActor->SetUserTransform(vtktransform);
00469 }
00470
00471 void mitk::PointSetVtkMapper3D::ApplyProperties(mitk::BaseRenderer* renderer)
00472 {
00473
00474
00475
00476
00477 vtkFloatingPointType unselectedColor[4]={1.0f,1.0f,0.0f,1.0f};
00478 vtkFloatingPointType selectedColor[4]={1.0f,0.0f,0.0f,1.0f};
00479 vtkFloatingPointType contourColor[4]={1.0f,0.0f,0.0f,1.0f};
00480
00481
00482 mitk::Color tmpColor;
00483 double opacity = 1.0;
00484
00485
00486 if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("unselectedcolor")) != NULL)
00487 {
00488 tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("unselectedcolor"))->GetValue();
00489 unselectedColor[0] = tmpColor[0];
00490 unselectedColor[1] = tmpColor[1];
00491 unselectedColor[2] = tmpColor[2];
00492 unselectedColor[3] = 1.0f;
00493 }
00494 else if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("unselectedcolor")) != NULL)
00495 {
00496 tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("unselectedcolor"))->GetValue();
00497 unselectedColor[0] = tmpColor[0];
00498 unselectedColor[1] = tmpColor[1];
00499 unselectedColor[2] = tmpColor[2];
00500 unselectedColor[3] = 1.0f;
00501 }
00502 else
00503 {
00504
00505 float unselectedColorTMP[4]={1.0f,1.0f,0.0f,1.0f};
00506 m_DataNode->GetColor(unselectedColorTMP, NULL);
00507 unselectedColor[0] = unselectedColorTMP[0];
00508 unselectedColor[1] = unselectedColorTMP[1];
00509 unselectedColor[2] = unselectedColorTMP[2];
00510
00511 }
00512
00513
00514 if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor")) != NULL)
00515 {
00516 tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor"))->GetValue();
00517 selectedColor[0] = tmpColor[0];
00518 selectedColor[1] = tmpColor[1];
00519 selectedColor[2] = tmpColor[2];
00520 selectedColor[3] = 1.0f;
00521 }
00522 else if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("selectedcolor")) != NULL)
00523 {
00524 tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("selectedcolor"))->GetValue();
00525 selectedColor[0] = tmpColor[0];
00526 selectedColor[1] = tmpColor[1];
00527 selectedColor[2] = tmpColor[2];
00528 selectedColor[3] = 1.0f;
00529 }
00530
00531
00532 if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor")) != NULL)
00533 {
00534 tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor"))->GetValue();
00535 contourColor[0] = tmpColor[0];
00536 contourColor[1] = tmpColor[1];
00537 contourColor[2] = tmpColor[2];
00538 contourColor[3] = 1.0f;
00539 }
00540 else if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("contourcolor")) != NULL)
00541 {
00542 tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("contourcolor"))->GetValue();
00543 contourColor[0] = tmpColor[0];
00544 contourColor[1] = tmpColor[1];
00545 contourColor[2] = tmpColor[2];
00546 contourColor[3] = 1.0f;
00547 }
00548
00549 if(dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("opacity")) != NULL)
00550 {
00551 mitk::FloatProperty::Pointer pointOpacity =dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("opacity"));
00552 opacity = pointOpacity->GetValue();
00553 }
00554 else if(dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("opacity")) != NULL)
00555 {
00556 mitk::FloatProperty::Pointer pointOpacity =dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("opacity"));
00557 opacity = pointOpacity->GetValue();
00558 }
00559
00560
00561
00562 bool makeContour = false;
00563 this->GetDataNode()->GetBoolProperty("show contour", makeContour, renderer);
00564 int visibleBefore = m_ContourActor->GetVisibility();
00565 if(makeContour && (m_ContourActor != NULL) )
00566 {
00567 if ( visibleBefore == 0)
00568 this->CreateContour(renderer);
00569 m_ContourActor->GetProperty()->SetColor(contourColor);
00570 m_ContourActor->GetProperty()->SetOpacity(opacity);
00571 }
00572
00573 m_SelectedActor->GetProperty()->SetColor(selectedColor);
00574 m_SelectedActor->GetProperty()->SetOpacity(opacity);
00575
00576 m_UnselectedActor->GetProperty()->SetColor(unselectedColor);
00577 m_UnselectedActor->GetProperty()->SetOpacity(opacity);
00578
00579 }
00580
00581 void mitk::PointSetVtkMapper3D::CreateContour(mitk::BaseRenderer* renderer)
00582 {
00583 vtkAppendPolyData* vtkContourPolyData = vtkAppendPolyData::New();
00584 vtkPolyDataMapper* vtkContourPolyDataMapper = vtkPolyDataMapper::New();
00585
00586 vtkPoints *points = vtkPoints::New();
00587 vtkCellArray *polys = vtkCellArray::New();
00588
00589 mitk::PointSet::PointsContainer::Iterator pointsIter;
00590 mitk::PointSet::PointDataContainer::Iterator pointDataIter;
00591 int j;
00592
00593
00594 mitk::PointSet::Pointer input = const_cast<mitk::PointSet*>(this->GetInput());
00595
00596
00597 int timestep = this->GetTimestep();
00598 mitk::PointSet::DataType::Pointer itkPointSet = input->GetPointSet( timestep );
00599 if ( itkPointSet.GetPointer() == NULL)
00600 {
00601 return;
00602 }
00603
00604 for (j=0, pointsIter=itkPointSet->GetPoints()->Begin(); pointsIter!=itkPointSet->GetPoints()->End() ; pointsIter++,j++)
00605 {
00606 vtkIdType cell[2] = {j-1,j};
00607 itk::Point<float> point1 = pointsIter->Value();
00608 points->InsertPoint(j,point1[0],point1[1],point1[2]);
00609 if (j>0)
00610 polys->InsertNextCell(2,cell);
00611 }
00612
00613 bool close;
00614 if (dynamic_cast<mitk::BoolProperty *>(this->GetDataNode()->GetPropertyList()->GetProperty("close contour"), renderer) == NULL)
00615 close = false;
00616 else
00617 close = dynamic_cast<mitk::BoolProperty *>(this->GetDataNode()->GetPropertyList()->GetProperty("close contour"), renderer)->GetValue();
00618 if (close)
00619 {
00620 vtkIdType cell[2] = {j-1,0};
00621 polys->InsertNextCell(2,cell);
00622 }
00623
00624 vtkPolyData* contour = vtkPolyData::New();
00625 contour->SetPoints(points);
00626 points->Delete();
00627 contour->SetLines(polys);
00628 polys->Delete();
00629 contour->Update();
00630
00631 vtkTubeFilter* tubeFilter = vtkTubeFilter::New();
00632 tubeFilter->SetNumberOfSides( 12 );
00633 tubeFilter->SetInput(contour);
00634 contour->Delete();
00635
00636
00637 m_ContourRadius = 0.5;
00638 mitk::FloatProperty::Pointer contourSizeProp = dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("contoursize") );
00639
00640 if (contourSizeProp.IsNotNull())
00641 m_ContourRadius = contourSizeProp->GetValue();
00642
00643 tubeFilter->SetRadius( m_ContourRadius );
00644 tubeFilter->Update();
00645
00646
00647 vtkContourPolyData->AddInput(tubeFilter->GetOutput());
00648 tubeFilter->Delete();
00649 vtkContourPolyDataMapper->SetInput(vtkContourPolyData->GetOutput());
00650 vtkContourPolyData->Delete();
00651
00652
00653 m_ContourActor->Delete();
00654 m_ContourActor = vtkActor::New();
00655
00656 m_ContourActor->SetMapper(vtkContourPolyDataMapper);
00657 vtkContourPolyDataMapper->Delete();
00658
00659 m_PointsAssembly->AddPart(m_ContourActor);
00660 }
00661
00662 void mitk::PointSetVtkMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite)
00663 {
00664 node->AddProperty( "line width", mitk::IntProperty::New(2), renderer, overwrite );
00665 node->AddProperty( "pointsize", mitk::FloatProperty::New(1.0), renderer, overwrite);
00666 node->AddProperty( "selectedcolor", mitk::ColorProperty::New(1.0f, 0.0f, 0.0f), renderer, overwrite);
00667 node->AddProperty( "color", mitk::ColorProperty::New(1.0f, 1.0f, 0.0f), renderer, overwrite);
00668 node->AddProperty( "show contour", mitk::BoolProperty::New(false), renderer, overwrite );
00669 node->AddProperty( "contourcolor", mitk::ColorProperty::New(1.0f, 0.0f, 0.0f), renderer, overwrite);
00670 node->AddProperty( "contoursize", mitk::FloatProperty::New(0.5), renderer, overwrite );
00671 node->AddProperty( "close contour", mitk::BoolProperty::New(false), renderer, overwrite );
00672 node->AddProperty( "show points", mitk::BoolProperty::New(true), renderer, overwrite );
00673 node->AddProperty( "updateDataOnRender", mitk::BoolProperty::New(true), renderer, overwrite );
00674 Superclass::SetDefaultProperties(node, renderer, overwrite);
00675 }
00676