Page MenuHomePhabricator

4598_RenderingManager_Changes_2.patch

Authored By
goch
Dec 8 2010, 2:25 PM
Size
4 KB
Referenced Files
None
Subscribers
None

4598_RenderingManager_Changes_2.patch

Index: Core/Code/Controllers/mitkRenderingManager.cpp
===================================================================
--- Core/Code/Controllers/mitkRenderingManager.cpp (revision 28250)
+++ Core/Code/Controllers/mitkRenderingManager.cpp (working copy)
@@ -443,7 +443,6 @@
}
-
int warningLevel = vtkObject::GetGlobalWarningDisplay();
vtkObject::GlobalWarningDisplayOff();
@@ -453,6 +452,28 @@
boundingBoxInitialized = true;
}
+ if (geometry.IsNotNull() )
+ {// make sure bounding box has an extent bigger than zero in any direction
+ // clone the input geometry
+ Geometry3D::Pointer modifiedGeometry = dynamic_cast<Geometry3D*>( dataGeometry->Clone().GetPointer() );
+ assert(modifiedGeometry.IsNotNull());
+ Geometry3D::BoundsArrayType newBounds = modifiedGeometry->GetBounds();
+ for( unsigned int dimension = 0; ( 2 * dimension ) < newBounds.Size() ; dimension++ )
+ {
+ if( std::abs( newBounds[ 2 * dimension ] - newBounds[ 2 * dimension + 1 ] )
+ < mitk::eps
+ )
+ {
+ newBounds[ 2 * dimension + 1 ] += 1;
+ }
+ }
+
+ // set the newly calculated bounds array
+ modifiedGeometry->SetBounds(newBounds);
+
+ geometry = modifiedGeometry;
+ }
+
RenderWindowList::iterator it;
for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it )
{
Index: Core/Code/Testing/mitkRenderingManagerTest.cpp
===================================================================
--- Core/Code/Testing/mitkRenderingManagerTest.cpp (revision 28250)
+++ Core/Code/Testing/mitkRenderingManagerTest.cpp (working copy)
@@ -24,7 +24,10 @@
#include "mitkTestingMacros.h"
+#include <vtkCubeSource.h>
+#include "mitkSurface.h"
+
//Propertylist Test
@@ -58,6 +61,63 @@
MITK_TEST_CONDITION(propertyList == renderingManager->GetPropertyList(), "Testing if the propertylist has changed during the last tests" )
}
+static void TestSurfaceLoading( mitk::RenderingManager::Pointer renderingManager )
+{
+ // create and render two dimensional surface
+ vtkCubeSource* plane = vtkCubeSource::New();
+
+ double planeBounds[] = { -1.0, 1.0, -1.0, 1.0, 0.0, 0.0 };
+ double cubeBounds[] = { -0.5, 0.5, -0.5, 0.5, -0.5, 0.5 };
+ plane->SetBounds( planeBounds );
+ plane->SetCenter( 0.0, 0.0, 0.0 );
+
+ vtkPolyData* polys = plane->GetOutput();
+ mitk::Surface::Pointer mitkPlane = mitk::Surface::New();
+ mitkPlane->SetVtkPolyData( polys );
+ plane->Delete();
+
+ mitk::DataNode::Pointer planeNode = mitk::DataNode::New();
+ planeNode->SetData( mitkPlane );
+
+ renderingManager->GetDataStorage()->Add( planeNode );
+
+ mitk::Geometry3D::Pointer planeGeometry = mitk::Geometry3D::New();
+ planeGeometry->SetFloatBounds( planeBounds );
+
+ MITK_TEST_CONDITION( renderingManager->InitializeViews( planeGeometry ), "Testing if two dimensional Geometry3Ds can be displayed" )
+
+ //clear rendering
+ renderingManager->GetDataStorage()->Remove( planeNode );
+
+ renderingManager->InitializeViews();
+
+ // create and render three dimensional surface
+ vtkCubeSource* cube = vtkCubeSource::New();
+ cube->SetBounds( cubeBounds );
+ cube->SetCenter( 0.0, 0.0, 0.0 );
+
+ vtkPolyData* polyCube = cube->GetOutput();
+ mitk::Surface::Pointer mitkCube = mitk::Surface::New();
+ mitkCube->SetVtkPolyData( polyCube );
+ cube->Delete();
+
+ mitk::DataNode::Pointer cubeNode = mitk::DataNode::New();
+ cubeNode->SetData( mitkCube );
+
+ renderingManager->GetDataStorage()->Add( cubeNode );
+
+ mitk::Geometry3D::Pointer cubeGeometry = mitk::Geometry3D::New();
+ cubeGeometry->SetFloatBounds( cubeBounds );
+
+ MITK_TEST_CONDITION( renderingManager->InitializeViews( cubeGeometry ), "Testing if three dimensional Geometry3Ds can be displayed" )
+
+ //clear rendering
+ renderingManager->GetDataStorage()->Remove( cubeNode );
+
+ renderingManager->InitializeViews();
+
+}
+
}; //mitkDataNodeTestClass
int mitkRenderingManagerTest(int /* argc */, char* /*argv*/[])
{
@@ -99,6 +159,8 @@
mitkRenderingManagerTestClass::TestPropertyList(myRenderingManager);
+ mitkRenderingManagerTestClass::TestSurfaceLoading( myRenderingManager );
+
// write your own tests here and use the macros from mitkTestingMacros.h !!!
// do not write to std::cout and do not return from this function yourself!

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
533
Default Alt Text
4598_RenderingManager_Changes_2.patch (4 KB)

Event Timeline

Setting all (near-)zero extents of the bounding box to one, with tests