39 #include "vtkSphereSource.h"
41 #include "vtkPolyDataMapper.h"
42 #include "vtkLabeledDataMapper.h"
44 #include "vtkPoints.h"
45 #include "vtkPolyLine.h"
46 #include "vtkCellArray.h"
47 #include "vtkPolyData.h"
48 #include "vtkPointData.h"
50 #include "vtkActor2D.h"
51 #include "vtkProperty.h"
54 #include "vtkRenderer.h"
55 #include "vtkRenderWindow.h"
56 #include "vtkRenderWindowInteractor.h"
57 #include "vtkRendererCollection.h"
68 QDialog(iParent), m_MeshContainer(imeshContainer),
69 m_MaxTrackID(0), m_NumberOfTracks(0), m_SecondClick(false)
73 renderer = vtkSmartPointer< vtkRenderer >::New();
119 const double *iColor1,
const double *iColor2)
125 vtkSmartPointer< vtkPoints > points = vtkSmartPointer< vtkPoints >::New();
126 points->InsertNextPoint(iCenter1);
127 points->InsertNextPoint(iCenter2);
129 vtkSmartPointer< vtkPolyLine > polyLine = vtkSmartPointer< vtkPolyLine >::New();
130 polyLine->GetPointIds()->SetNumberOfIds(2);
131 polyLine->GetPointIds()->SetId(0, 0);
132 polyLine->GetPointIds()->SetId(1, 1);
135 vtkSmartPointer< vtkCellArray > cells = vtkSmartPointer< vtkCellArray >::New();
136 cells->InsertNextCell(polyLine);
139 vtkSmartPointer< vtkPolyData > polyData = vtkSmartPointer< vtkPolyData >::New();
142 polyData->SetPoints(points);
145 polyData->SetLines(cells);
148 vtkSmartPointer< vtkPolyDataMapper > mapper =
149 vtkSmartPointer< vtkPolyDataMapper >::New();
150 mapper->SetInput(polyData);
152 vtkActor *actor = vtkActor::New();
153 actor->SetMapper(mapper);
227 unsigned int collection = std::numeric_limits< unsigned int >::max();
230 unsigned int current_track = 0;
232 while ( c_it != c_end )
234 unsigned int temp_collection = c_it->CollectionID;
235 unsigned int traceID = c_it->TraceID;
238 if ( temp_collection != collection )
240 collection = temp_collection;
288 boost::tuples::tie(it0, it1) =
296 vtkPolyData *nodes = tempStructure.
Nodes;
297 double * rgba = tempStructure.
rgba;
300 vtkSmartPointer<vtkIntArray> trackIDArray = vtkSmartPointer<vtkIntArray>::New();
301 trackIDArray->SetNumberOfComponents(1);
302 trackIDArray->SetNumberOfValues(1);
303 trackIDArray->SetName(
"MESH");
304 trackIDArray->SetValue(0,tempStructure.
TraceID);
306 nodes->GetPointData()->AddArray(trackIDArray);
309 vtkSmartPointer< vtkPolyDataMapper > mapper =
310 vtkSmartPointer< vtkPolyDataMapper >::New();
311 mapper->SetInput(nodes);
313 vtkActor *actor = vtkActor::New();
314 actor->SetMapper(mapper);
315 actor->GetProperty()->SetColor(rgba);
322 tempStructure.
ActorXZ = sphereActor;
341 vtkSmartPointer< vtkDoubleArray > randomScalars =
342 vtkSmartPointer< vtkDoubleArray >::New();
343 randomScalars->SetNumberOfComponents(1);
344 randomScalars->SetName(
"TimePoint");
346 vtkSmartPointer< vtkPoints > pts = vtkSmartPointer< vtkPoints >::New();
353 boost::tuples::tie(it0, it1) =
359 vtkPolyData *nodes = it0->Nodes;
360 unsigned int time = it0->TCoord;
362 randomScalars->InsertNextTuple1(time);
363 pts->InsertNextPoint( nodes->GetCenter() );
369 vtkSmartPointer< vtkPolyData > labelData = vtkSmartPointer< vtkPolyData >::New();
370 labelData->GetPointData()->SetScalars(randomScalars);
371 labelData->SetPoints(pts);
374 vtkSmartPointer< vtkLabeledDataMapper > labelMapper =
375 vtkSmartPointer< vtkLabeledDataMapper >::New();
376 labelMapper->SetFieldDataName(
"TimePoint");
377 labelMapper->SetInput(labelData);
378 labelMapper->SetLabelModeToLabelScalars();
379 labelMapper->SetLabelFormat(
"%6.0f");
381 vtkSmartPointer< vtkActor2D > isolabels =
382 vtkSmartPointer< vtkActor2D >::New();
383 isolabels->SetMapper(labelMapper);
402 unsigned int collectionID = it0->CollectionID;
403 unsigned int tLimit = it0->TCoord;
406 boost::tuples::tie(it2, it3) =
411 unsigned int time = it2->TCoord;
412 unsigned int traceID = it2->TraceID;
459 std::map< unsigned int, unsigned int > m_Time2MeshID;
463 m_Time2MeshID.clear();
466 boost::tuples::tie(it0, it1) =
471 m_Time2MeshID[it0->TCoord] = ( it0->TraceID );
476 std::map< unsigned int, unsigned int >::iterator polyLIt = m_Time2MeshID.begin();
477 if ( polyLIt != m_Time2MeshID.end() )
480 vtkActor *secondActor = NULL;
483 while ( polyLIt != m_Time2MeshID.end() )
487 secondActor->GetCenter() );
490 double color[3] = { 1, 1, 1 };
491 polyLine->GetProperty()->SetColor(color);
498 firstActor = secondActor;
504 std::cout <<
"List is empty" << std::endl;
517 unsigned int collection = 0;
525 collection = it->first;
527 switch ( it->second.Status )
546 if ( it->second.RealID )
560 std::list< unsigned int >
563 std::list< unsigned int > list_meshid;
567 boost::tuples::tie(it0, it1) =
572 list_meshid.push_back(it0->TraceID);
581 std::list< std::list< unsigned int > >
590 std::map< unsigned int, std::list< unsigned int > >
599 std::list< unsigned int >
611 unsigned int FirstCollectionID = 0;
612 unsigned int SecondCollectionID = 0;
618 catch (
const itk::ExceptionObject & e )
620 std::cout <<
"caught an exception: " << std::endl;
629 catch (
const itk::ExceptionObject & e )
631 std::cout <<
"caught an exception: " << std::endl;
636 if ( FirstCollectionID != SecondCollectionID )
639 std::pair< std::pair< unsigned int, unsigned int >,
640 std::pair< unsigned int, unsigned int > >
643 std::pair< std::pair< unsigned int, unsigned int >,
644 std::pair< unsigned int, unsigned int > >
648 if ( ( border2.first.second <= border1.second.second )
649 && ( border1.first.second <= border2.second.second ) )
656 unsigned int trackToUpdate = 0;
657 unsigned int trackToDelete = 0;
658 if ( border1.first.first < border2.first.first )
660 trackToDelete = FirstCollectionID;
661 trackToUpdate = SecondCollectionID;
665 trackToUpdate = FirstCollectionID;
666 trackToDelete = SecondCollectionID;
690 std::pair< std::pair< unsigned int, unsigned int >,
691 std::pair< unsigned int, unsigned int > >
696 boost::tuples::tie(it0, it1) =
699 std::pair< unsigned int, unsigned int >
700 minBorder( 0, std::numeric_limits< unsigned int >::max() );
702 std::pair< unsigned int, unsigned int >
705 unsigned int time = 0;
711 if ( minBorder.second > time )
713 minBorder.first = it0->TraceID;
714 minBorder.second = time;
717 if ( maxBorder.second < time )
719 maxBorder.first = it0->TraceID;
720 maxBorder.second = time;
725 return std::make_pair(minBorder, maxBorder);
733 const unsigned int & iIDToUpdate)
737 boost::tuples::tie(it0, it1) =
742 unsigned int traceID = it0->TraceID;
757 this->qvtkWidget->GetRenderWindow()->AddRenderer(
renderer);
762 this->qvtkWidget->GetRenderWindow()->Render();
802 while ( iter != c_end )
804 iter->ActorXY->SetVisibility(iRealMeshes);
805 iter->ActorXZ->SetVisibility(!iRealMeshes);
810 this->qvtkWidget->update();
820 vtkSmartPointer< vtkSphereSource > sphereSource =
821 vtkSmartPointer< vtkSphereSource >::New();
822 sphereSource->SetCenter(iCenter);
823 sphereSource->SetRadius(iRadius);
824 sphereSource->Update();
827 vtkSmartPointer<vtkIntArray> trackIDArray = vtkSmartPointer<vtkIntArray>::New();
828 trackIDArray->SetNumberOfComponents(1);
829 trackIDArray->SetNumberOfValues(1);
830 trackIDArray->SetName(
"MESH");
831 trackIDArray->SetValue(0,iTraceID);
833 sphereSource->GetOutput()->GetPointData()->AddArray(trackIDArray);
835 vtkSmartPointer< vtkPolyDataMapper > sphereMapper =
836 vtkSmartPointer< vtkPolyDataMapper >::New();
837 sphereMapper->SetInput( sphereSource->GetOutput() );
839 vtkActor *sphereActor = vtkActor::New();
840 sphereActor->SetMapper(sphereMapper);
841 sphereActor->SetVisibility(
false);
866 sqrt( vtkMath::Distance2BetweenPoints( it->Nodes->GetCenter(),
867 it2->Nodes->GetCenter() ) );
868 if ( it->TraceID != it2->TraceID )
void showMessage(const QString &message, int timeout)
void EnablePickMode()
Start the Pick Mode.
MultiIndexContainerType::template index< TraceID >::type::iterator MultiIndexContainerTraceIDIterator
MultiIndexContainerType m_Container
Trace Contaienr.
unsigned int GetCollectionIDOfGivenTraceID(unsigned int iTraceID)
Get the CollectionID given a TraceID.
static vtkInteractorStyleImage3D * New()
Convenient method to access the constructor.
std::vector< vtkActor * > GetActorGivenTraceID(unsigned int iTraceID)
Wraps a boost::multi_index_container of ContourMeshStructure. This class is specialized for the means...
unsigned int CollectionID
Structure which represent a contour or a mesh, and used for interaction between Visualization and Tab...
MultiIndexContainerType::template index< CollectionID >::type::iterator MultiIndexContainerCollectionIDIterator
vtkProp * GetCurrentProp()
Return the actor which is pointed by the cursor.
Define the interactor behavior withing a vtkImage3D. 4 modes (Default, Zoom, Pan and Pick) ...
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)