Page MenuHomePhabricator

0001-FIX-5535-Allow-to-render-small-images-and-shapes-cor.patch

Authored By
xplanes
Sep 12 2011, 2:37 PM
Size
5 KB
Referenced Files
None
Subscribers
None

0001-FIX-5535-Allow-to-render-small-images-and-shapes-cor.patch

From 590516600fd34fb3ac88848737c3783c44081a27 Mon Sep 17 00:00:00 2001
From: Xavier Planes <xavier.planes@upf.edu>
Date: Mon, 12 Sep 2011 14:36:05 +0200
Subject: [PATCH] FIX #5535: Allow to render small images and shapes correctly
---
Core/Code/DataManagement/mitkDisplayGeometry.cpp | 8 ++--
Core/Code/DataManagement/mitkVector.cpp | 4 +-
.../Rendering/mitkGeometry2DDataVtkMapper3D.cpp | 34 ++++++++++++++++++++
Core/Code/Rendering/mitkImageVtkMapper2D.cpp | 22 ++++++++-----
4 files changed, 54 insertions(+), 14 deletions(-)
diff --git a/Core/Code/DataManagement/mitkDisplayGeometry.cpp b/Core/Code/DataManagement/mitkDisplayGeometry.cpp
index c7a302b..0a1cb38 100644
--- a/Core/Code/DataManagement/mitkDisplayGeometry.cpp
+++ b/Core/Code/DataManagement/mitkDisplayGeometry.cpp
@@ -166,10 +166,10 @@ bool mitk::DisplayGeometry::GetConstrainZommingAndPanning() const
bool mitk::DisplayGeometry::SetScaleFactor(ScalarType mmPerDisplayUnit)
{
- if(mmPerDisplayUnit<0.0001)
- {
- mmPerDisplayUnit=0.0001;
- }
+ // if(mmPerDisplayUnit<0.0001)
+ // {
+ // mmPerDisplayUnit=0.0001;
+ // }
m_ScaleFactorMMPerDisplayUnit = mmPerDisplayUnit;
assert(m_ScaleFactorMMPerDisplayUnit < ScalarTypeNumericTraits::infinity());
diff --git a/Core/Code/DataManagement/mitkVector.cpp b/Core/Code/DataManagement/mitkVector.cpp
index 5bea5b3..3317a4c 100644
--- a/Core/Code/DataManagement/mitkVector.cpp
+++ b/Core/Code/DataManagement/mitkVector.cpp
@@ -19,6 +19,6 @@ PURPOSE. See the above copyright notices for more information.
#include <vtkSystemIncludes.h>
#include <vtkMatrix4x4.h>
-const mitk::ScalarType mitk::eps = vnl_math::float_eps*100;
-const mitk::ScalarType mitk::sqrteps = vnl_math::float_sqrteps;
+const mitk::ScalarType mitk::eps = vnl_math::float_eps*0.001;
+const mitk::ScalarType mitk::sqrteps = vnl_math::float_sqrteps*0.001;
extern const double mitk::large = VTK_LARGE_FLOAT;
diff --git a/Core/Code/Rendering/mitkGeometry2DDataVtkMapper3D.cpp b/Core/Code/Rendering/mitkGeometry2DDataVtkMapper3D.cpp
index 02e1198..94a1c0b 100644
--- a/Core/Code/Rendering/mitkGeometry2DDataVtkMapper3D.cpp
+++ b/Core/Code/Rendering/mitkGeometry2DDataVtkMapper3D.cpp
@@ -325,6 +325,40 @@ namespace mitk
tubeRadius = sqrt( m_SurfaceCreator->GetBoundingBox()->GetDiagonalLength2() ) / 450.0;
}
+
+ if ( input->GetGeometry2D()->HasReferenceGeometry() )
+ {
+ ScalarType minSpacing = 1;
+
+ Geometry3D *referenceGeometry =
+ input->GetGeometry2D()->GetReferenceGeometry();
+
+ // spacing
+ try
+ {
+ AffineTransform3D::Pointer inverseTransform = AffineTransform3D::New();
+ referenceGeometry->GetIndexToWorldTransform()->GetInverse(inverseTransform);
+ vnl_vector< AffineTransform3D::MatrixType::ValueType > unitVector(3);
+ int axis;
+ for(axis = 0; axis < 3; ++axis)
+ {
+ unitVector.fill(0);
+ unitVector[axis] = 1.0;
+ ScalarType mmPerPixel = 1.0/(inverseTransform->GetMatrix()*unitVector).magnitude();
+ if(minSpacing > mmPerPixel)
+ {
+ minSpacing = mmPerPixel;
+ }
+ }
+ }
+ catch(itk::ExceptionObject e)
+ {
+ LOG_ERROR << e << std::endl;
+ }
+
+ tubeRadius = tubeRadius * minSpacing;
+ }
+
// Calculate the surface of the Geometry2D
m_SurfaceCreator->Update();
Surface *surface = m_SurfaceCreator->GetOutput();
diff --git a/Core/Code/Rendering/mitkImageVtkMapper2D.cpp b/Core/Code/Rendering/mitkImageVtkMapper2D.cpp
index a2e2bca..17aa50a 100644
--- a/Core/Code/Rendering/mitkImageVtkMapper2D.cpp
+++ b/Core/Code/Rendering/mitkImageVtkMapper2D.cpp
@@ -414,31 +414,37 @@ void mitk::ImageVtkMapper2D::GenerateDataForRenderer( mitk::BaseRenderer *render
localStorage->m_Reslicer->SetResliceAxesDirectionCosines( cosines );
int xMin, xMax, yMin, yMax;
+ mitk::ScalarType xfMin, xfMax, yfMin, yfMax;
if ( boundsInitialized )
{
// Calculate output extent (integer values)
- xMin = static_cast< int >( sliceBounds[0] / mmPerPixel[0] + 0.5 );
- xMax = static_cast< int >( sliceBounds[1] / mmPerPixel[0] + 0.5 );
- yMin = static_cast< int >( sliceBounds[2] / mmPerPixel[1] + 0.5 );
- yMax = static_cast< int >( sliceBounds[3] / mmPerPixel[1] + 0.5 );
+ xfMin = ( bounds[0] / mmPerPixel[0] + 0.5 );
+ xfMax = ( bounds[1] / mmPerPixel[0] + 0.5 );
+ yfMin = ( bounds[2] / mmPerPixel[1] + 0.5 );
+ yfMax = ( bounds[3] / mmPerPixel[1] + 0.5 );
}
else
{
// If no reference geometry is available, we also don't know about the
// maximum plane size;
- xMin = yMin = 0;
- xMax = static_cast< int >( extent[0]
+ xfMin = yfMin = 0;
+ xfMax = ( extent[0]
- pixelsPerMM[0] + 0.5);
- yMax = static_cast< int >( extent[1]
+ yfMax = ( extent[1]
- pixelsPerMM[1] + 0.5);
}
// Disallow huge dimensions
- if ( (xMax-xMin) * (yMax-yMin) > 4096*4096 )
+ if ( float ( (xfMax-xfMin) * (yfMax-yfMin) ) > 4096*4096 )
{
return;
}
+ xMin = static_cast< int > ( xfMin );
+ xMax = static_cast< int > ( xfMax );
+ yMin = static_cast< int > ( yfMin );
+ yMax = static_cast< int > ( yfMax );
+
// Calculate dataset spacing in plane z direction (NOT spacing of current
// world geometry)
double dataZSpacing = 1.0;
--
1.7.4.msysgit.0

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
578
Default Alt Text
0001-FIX-5535-Allow-to-render-small-images-and-shapes-cor.patch (5 KB)