MCPcopy Create free account
hub / github.com/MITK/MITK / SurfaceStamp

Method SurfaceStamp

Modules/Segmentation/src/Algorithms/mitkSurfaceStampImageFilter.cpp:102–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void mitk::SurfaceStampImageFilter::SurfaceStamp(int time)
103{
104 mitk::Image::Pointer inputImage = this->GetInput();
105
106 const mitk::TimeGeometry *surfaceTimeGeometry = GetInput()->GetTimeGeometry();
107 const mitk::TimeGeometry *imageTimeGeometry = inputImage->GetTimeGeometry();
108
109 // Convert time step from image time-frame to surface time-frame
110 mitk::TimePointType matchingTimePoint = imageTimeGeometry->TimeStepToTimePoint(time);
111 mitk::TimeStepType surfaceTimeStep = surfaceTimeGeometry->TimePointToTimeStep(matchingTimePoint);
112
113 vtkPolyData *polydata = m_Surface->GetVtkPolyData(surfaceTimeStep);
114 if (!polydata)
115 mitkThrow() << "Polydata is null.";
116
117 vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
118 transformFilter->SetInputData(polydata);
119 // transformFilter->ReleaseDataFlagOn();
120
121 vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
122 BaseGeometry::Pointer geometry = surfaceTimeGeometry->GetGeometryForTimeStep(surfaceTimeStep);
123
124 transform->PostMultiply();
125 transform->Concatenate(geometry->GetVtkTransform()->GetMatrix());
126 // take image geometry into account. vtk-Image information will be changed to unit spacing and zero origin below.
127 BaseGeometry::Pointer imageGeometry = imageTimeGeometry->GetGeometryForTimeStep(time);
128
129 transform->Concatenate(imageGeometry->GetVtkTransform()->GetLinearInverse());
130 transformFilter->SetTransform(transform);
131 transformFilter->Update();
132
133 polydata = transformFilter->GetOutput();
134
135 if (!polydata || !polydata->GetNumberOfPoints())
136 mitkThrow() << "Polydata retrieved from transformation is null or has no points.";
137
138 MeshType::Pointer mesh = MeshType::New();
139 mesh->SetCellsAllocationMethod(itk::MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell);
140 unsigned int numberOfPoints = polydata->GetNumberOfPoints();
141 mesh->GetPoints()->Reserve(numberOfPoints);
142
143 vtkPoints *points = polydata->GetPoints();
144
145 MeshType::PointType point;
146 for (unsigned int i = 0; i < numberOfPoints; i++)
147 {
148 double *aux = points->GetPoint(i);
149 point[0] = aux[0];
150 point[1] = aux[1];
151 point[2] = aux[2];
152 mesh->SetPoint(i, point);
153 }
154
155 // Load the polygons into the itk::Mesh
156 typedef MeshType::CellAutoPointer CellAutoPointerType;
157 typedef MeshType::CellType CellType;
158 typedef itk::TriangleCell<CellType> TriangleCellType;
159 typedef MeshType::PointIdentifier PointIdentifierType;

Callers 1

GenerateDataMethod · 0.95

Calls 15

GetMatrixMethod · 0.80
GetNumberOfPointsMethod · 0.80
NewFunction · 0.50
GetInputMethod · 0.45
TimeStepToTimePointMethod · 0.45
TimePointToTimeStepMethod · 0.45
GetVtkPolyDataMethod · 0.45
ConcatenateMethod · 0.45
GetVtkTransformMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected