25 : m_MakeOutputBinary(true), m_TimeStep(0), m_ReferenceImage(nullptr)
28 itk::DataObject::Pointer output = this->
MakeOutput(0);
29 Superclass::SetNumberOfRequiredInputs(1);
30 Superclass::SetNumberOfRequiredOutputs(1);
31 Superclass::SetNthOutput(0, output);
51 itkDebugMacro(<<
"GenerateOutputInformation()");
71 return OutputType::New().GetPointer();
76 itkDebugMacro(
"MakeOutput(" << name <<
")");
77 if (this->IsIndexedOutputName(name))
79 return this->
MakeOutput(this->MakeIndexFromOutputName(name));
81 return OutputType::New().GetPointer();
86 if (this->GetNumberOfInputs() < 1)
97 this->ProcessObject::SetNthInput(0, const_cast<mitk::ContourModelSet *>(input));
123 if (outputImage.IsNull() || outputImage->IsInitialized() ==
false || !outputImage->IsVolumeSet(
m_TimeStep))
125 MITK_ERROR <<
"Error creating output for specified image!";
129 if (!contourSet || contourSet->GetContourModelList()->size() == 0)
138 vtkSmartPointer<mitkVtkImageOverwrite> reslice = vtkSmartPointer<mitkVtkImageOverwrite>::New();
142 extractor->SetInput(outputImage);
144 extractor->SetResliceTransformByGeometry(outputImageGeo);
147 auto it = contourSet->Begin();
148 auto end = contourSet->End();
161 bool isFrontside =
true;
162 bool isRotated =
false;
175 sliceIndex = point3D[0];
180 sliceIndex = point3D[1];
185 sliceIndex = point3D[2];
191 <<
"Cannot detect correct slice number! Only axial, sagittal and frontal oriented contours are supported!";
196 plane->InitializeStandardPlane(outputImageGeo, orientation, sliceIndex, isFrontside, isRotated);
197 point3D = plane->GetOrigin();
198 normal = plane->GetNormal();
200 point3D += normal * 0.5;
201 plane->SetOrigin(point3D);
204 extractor->SetWorldGeometry(plane);
205 extractor->SetVtkOutputRequest(
false);
206 reslice->SetOverwriteMode(
false);
208 extractor->Modified();
211 slice = extractor->GetOutput();
212 slice->DisconnectPipeline();
220 reslice->SetInputSlice(slice->GetVtkImageData());
223 reslice->SetOverwriteMode(
true);
226 extractor->Modified();
229 reslice->SetInputSlice(
nullptr);
237 outputImage->Modified();
238 outputImage->GetVtkImageData()->Modified();
249 for (
unsigned int dim = 0; dim < output->
GetDimension(); ++dim)
256 memset(writeAccess.GetData(), 0, byteSize);
261 for (
unsigned int dim = 0; dim < 3; ++dim)
266 for (
unsigned int volumeNumber = 0; volumeNumber < output->
GetDimension(3); volumeNumber++)
270 memset(writeAccess.GetData(), 0, byteSize);
int GetNumberOfVertices(int timestep=0) const
Returns the number of vertices at a given timestep.
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
const mitk::ContourModelSet * GetInput(void)
const mitk::Image * GetImage(void)
void InitializeOutputEmpty()
Initializes the volume of the output image with zeros.
itk::DataObject::DataObjectIdentifierType DataObjectIdentifierType
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
virtual const VertexType * GetVertexAt(int index, int timestep=0) const
Returns the vertex at the index position within the container.
mitk::Point3D Coordinates
Coordinates in 3D space.
static void FillContourInSlice(ContourModel *projectedContour, Image *sliceImage, mitk::Image::Pointer workingImage, int paintingPixelValue=1)
Fill a contour in a 2D slice with a specified pixel value at time step 0.
void GenerateOutputInformation() override
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
const mitk::Image * m_ReferenceImage
itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
void GenerateData() override
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
ContourModelSetToImageFilter()
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
unsigned int GetDimension() const
Get dimension of the image.
ContourModelListType * GetContourModelList()
Returns the container of the contours.
virtual ImageDataItemPointer GetVolumeData(int t=0, int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
Image class for storing images.
static ContourModel::Pointer ProjectContourTo2DSlice(Image *slice, ContourModel *contourIn3D, bool correctionForIpSegmentation, bool constrainToInside)
Projects a contour onto an image point by point. Converts from world to index coordinates.
void SetImage(const mitk::Image *refImage)
Set the image which will be used to initialize the output of this filter.
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
void GenerateTimeInInputRegion(const mitk::TimeGeometry *outputTimeGeometry, const TOutputRegion &outputRegion, const mitk::TimeGeometry *inputTimeGeometry, TInputRegion &inputRegion)
vcl_size_t GetSize() const
Get size of the PixelType in bytes.
virtual void SetInput(const mitk::ContourModelSet *input)
mitk::PropertyList::Pointer GetPropertyList() const
Get the data's property list.
void AddStepsToDo(unsigned int steps)
Adds steps to totalSteps.
~ContourModelSetToImageFilter() override
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
virtual bool IsInitialized() const
Check whether the data has been initialized, i.e., at least the Geometry and other header data has be...
OutputType * GetOutput()
Get the output data of this image source object.
void GenerateInputRequestedRegion() override
ImageWriteAccessor class to get locked write-access for a particular image part.
BaseGeometry Describes the geometry of a data object.