Commit d21e4444 authored by Emmanuel Promayon's avatar Emmanuel Promayon

FIXED starting to define arbitrary slice index

parent dc51a028
......@@ -139,10 +139,6 @@ int Slice::getNumberOfSlices() const {
int nbSlices;
switch (sliceOrientation) {
case ARBITRARY:
// for arbitrary, use the longest orthogonal dimension
nbSlices = std::max(originalSize[0], std::max(originalSize[1], originalSize[2])) + std::max(originalSpacing[0],std::max(originalSpacing[1], originalSpacing[2]));
break;
case AXIAL:
case AXIAL_NEURO:
nbSlices = extent[5] - extent[4] + 1;
......@@ -187,8 +183,6 @@ void Slice::setSlice(int s) {
originalVolume->GetExtent(extent);
switch (sliceOrientation) {
case ARBITRARY:
break;
case AXIAL:
case AXIAL_NEURO:
image3DActor->SetDisplayExtent(extent[0], extent[1], extent[2], extent[3], currentSliceIndex, currentSliceIndex);
......@@ -256,10 +250,8 @@ void Slice::setPixelRealPosition(double x, double y, double z) {
// -------------------- setReslicerTransform --------------------
void Slice::setArbitraryTransform(vtkSmartPointer<vtkTransform> transform) {
if (sliceOrientation == ARBITRARY) {
image2DReslicer->SetResliceAxes(transform->GetMatrix());
image2DReslicer->Update();
}
image2DReslicer->SetResliceAxes(transform->GetMatrix());
image2DReslicer->Update();
}
// -------------------- get2DImageActor --------------------
......@@ -295,6 +287,7 @@ void Slice::initActors() {
image2DReslicer = vtkSmartPointer<vtkImageReslice>::New();
image2DReslicer->SetOutputDimensionality(2);
image2DReslicer->SetInputConnection(imgToMapFilter->GetOutputPort());
image2DReslicer->AutoCropOutputOff();
// for the 2D and 3D image actors it is either directly plugged to the output of imgToMapFilter
// (if this is a perpendicular orientation) or to the reslicer (if this is an arbitrary orientation)
......
......@@ -249,4 +249,20 @@ int SingleImageComponent::getSlice() const {
}
}
// -------------------- getNumberOfSlices --------------------
int SingleImageComponent::getNumberOfSlices() const {
if (sliceOrientation == Slice::ARBITRARY) {
// approximate using the body diagonal of the image
int dimensions[3];
double spacing[3];
dynamic_cast<ImageComponent*>(myParentNode)->getImageData()->GetDimensions(dimensions);
dynamic_cast<ImageComponent*>(myParentNode)->getImageData()->GetSpacing(spacing);
double diag = sqrt(dimensions[0]*spacing[0]*dimensions[0]*spacing[0] + dimensions[1]*spacing[1]*dimensions[1]*spacing[1] + dimensions[2]*spacing[2]*dimensions[2]*spacing[2]);
return diag;
}
else {
return Component::getNumberOfSlices();
}
}
}
......@@ -106,10 +106,15 @@ public:
virtual void setSlice(double, double, double) override;
/// Rewritten for arbitrary slice.
/// Arbitrary return the current position in the volume
/// while nothing special has to be done for other orientation
/// Arbitrary returns the current position in the volume
/// while nothing special has to be done for other orientations.
virtual int getSlice() const override;
/// Rewritten for arbitrary slice.
/// Arbitrary returns the maximal translation inside the volume
/// while nothing special has to be done for other orientations.
virtual int getNumberOfSlices() const override;
protected:
/** The concrete building of the Service (Slice in this case, for a 2D representation). */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment