Page MenuHomePhabricator

0001-enhanced-clippedsurfaceboundscalculator-so-that-the-.patch

Authored By
saruji
Oct 5 2011, 9:27 AM
Size
5 KB
Referenced Files
None
Subscribers
None

0001-enhanced-clippedsurfaceboundscalculator-so-that-the-.patch

From 4b312af1f601b12fe6e43db4d25dc316231f681f Mon Sep 17 00:00:00 2001
From: Danial Saruji <d.saruji@mint-medical.de>
Date: Wed, 5 Oct 2011 09:23:58 +0200
Subject: [PATCH] enhanced clippedsurfaceboundscalculator so that the intersection points
of 2 Geometry3D can be determined
---
.../mitkClippedSurfaceBoundsCalculator.cpp | 71 +++++++++++++++++--
.../mitkClippedSurfaceBoundsCalculator.h | 5 ++
2 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.cpp b/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.cpp
index 7f1aebe..a60674f 100644
--- a/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.cpp
+++ b/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.cpp
@@ -5,7 +5,10 @@
mitk::ClippedSurfaceBoundsCalculator::ClippedSurfaceBoundsCalculator(
const mitk::PlaneGeometry* geometry,
- mitk::Image::Pointer image)
+ mitk::Image::Pointer image):
+ m_PlaneGeometry(NULL),
+ m_Geometry3D(NULL),
+ m_Image(NULL)
{
// initialize with meaningless slice indices
m_MinMaxOutput.clear();
@@ -20,6 +23,26 @@ mitk::ClippedSurfaceBoundsCalculator::ClippedSurfaceBoundsCalculator(
this->SetInput(geometry, image);
}
+mitk::ClippedSurfaceBoundsCalculator::ClippedSurfaceBoundsCalculator(
+ const mitk::Geometry3D* geometry,
+ mitk::Image::Pointer image):
+ m_PlaneGeometry(NULL),
+ m_Geometry3D(NULL),
+ m_Image(NULL)
+{
+ // initialize with meaningless slice indices
+ m_MinMaxOutput.clear();
+ for(int i = 0; i < 3; i++)
+ {
+ m_MinMaxOutput.push_back(
+ OutputType( std::numeric_limits<int>::max() ,
+ std::numeric_limits<int>::min() ));
+ }
+
+
+ this->SetInput(geometry, image);
+}
+
mitk::ClippedSurfaceBoundsCalculator::~ClippedSurfaceBoundsCalculator()
{
}
@@ -33,6 +56,20 @@ mitk::ClippedSurfaceBoundsCalculator::SetInput(
{
this->m_PlaneGeometry = geometry;
this->m_Image = image;
+ this->m_Geometry3D = NULL; //Not possible to set both
+ }
+}
+
+void
+mitk::ClippedSurfaceBoundsCalculator::SetInput(
+ const mitk::Geometry3D* geometry,
+ mitk::Image* image)
+{
+ if(geometry && image)
+ {
+ this->m_Geometry3D = geometry;
+ this->m_Image = image;
+ this->m_PlaneGeometry = NULL; //Not possible to set both
}
}
@@ -56,16 +93,34 @@ mitk::ClippedSurfaceBoundsCalculator::GetMinMaxSpatialDirectionZ()
void mitk::ClippedSurfaceBoundsCalculator::Update()
{
- // SEE HEADER DOCUMENTATION for explanation
-
- typedef std::vector< std::pair<mitk::Point3D, mitk::Point3D> > EdgesVector;
-
this->m_MinMaxOutput.clear();
for(int i = 0; i < 3; i++)
{
this->m_MinMaxOutput.push_back(OutputType( std::numeric_limits<int>::max() , std::numeric_limits<int>::min() ));
}
+ if(m_PlaneGeometry.IsNotNull())
+ {
+ this->CalculateIntersectionPoints(m_PlaneGeometry);
+ }
+ else if(m_Geometry3D.IsNotNull())
+ {
+ // go through all slices of the image, ...
+ const mitk::SlicedGeometry3D* slicedGeometry3D = dynamic_cast<const mitk::SlicedGeometry3D*>( m_Geometry3D.GetPointer() );
+ int allSlices = slicedGeometry3D->GetSlices();
+ for ( int slice=0; slice<allSlices; slice++ )
+ {
+ this->CalculateIntersectionPoints(dynamic_cast<mitk::PlaneGeometry*>(slicedGeometry3D->GetGeometry2D(slice)));
+ }
+ }
+}
+
+void mitk::ClippedSurfaceBoundsCalculator::CalculateIntersectionPoints(const mitk::PlaneGeometry* geometry)
+{
+ // SEE HEADER DOCUMENTATION for explanation
+
+ typedef std::vector< std::pair<mitk::Point3D, mitk::Point3D> > EdgesVector;
+
Point3D origin;
Vector3D xDirection, yDirection, zDirection;
const Vector3D spacing = m_Image->GetGeometry()->GetSpacing();
@@ -181,7 +236,7 @@ void mitk::ClippedSurfaceBoundsCalculator::Update()
bool isIntersectionPointOnLine;
Vector3D lineVector = line.GetPoint1() - line.GetPoint2();
if(lineVector[0] == 0 && lineVector[1] == 0 && lineVector[2] == 0
- && m_PlaneGeometry->IsOnPlane(line.GetPoint1()))
+ && geometry->IsOnPlane(line.GetPoint1()))
{
t = 1.0;
isIntersectionPointOnLine = true;
@@ -189,8 +244,8 @@ void mitk::ClippedSurfaceBoundsCalculator::Update()
}
else
{
- m_PlaneGeometry->IntersectionPoint(line, intersectionWorldPoint);
- isIntersectionPointOnLine = m_PlaneGeometry->IntersectionPointParam(line, t);
+ geometry->IntersectionPoint(line, intersectionWorldPoint);
+ isIntersectionPointOnLine = geometry->IntersectionPointParam(line, t);
}
mitk::Point3D intersectionIndexPoint;
diff --git a/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.h b/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.h
index 89201b1..b5eca2a 100644
--- a/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.h
+++ b/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.h
@@ -50,10 +50,13 @@ class MITK_CORE_EXPORT ClippedSurfaceBoundsCalculator
ClippedSurfaceBoundsCalculator(const mitk::PlaneGeometry* geometry = NULL,
mitk::Image::Pointer image = NULL);
+ ClippedSurfaceBoundsCalculator(const mitk::Geometry3D* geometry,
+ mitk::Image::Pointer image);
virtual ~ClippedSurfaceBoundsCalculator();
void SetInput(const mitk::PlaneGeometry* geometry, mitk::Image* image);
+ void SetInput(const mitk::Geometry3D *geometry, mitk::Image *image);
/**
\brief Request calculation.
@@ -89,8 +92,10 @@ class MITK_CORE_EXPORT ClippedSurfaceBoundsCalculator
OutputType GetMinMaxSpatialDirectionZ();
protected:
+ void CalculateIntersectionPoints(const mitk::PlaneGeometry* geometry);
mitk::PlaneGeometry::ConstPointer m_PlaneGeometry;
+ mitk::Geometry3D::ConstPointer m_Geometry3D;
mitk::Image::Pointer m_Image;
std::vector< OutputType > m_MinMaxOutput;
--
1.7.0.4

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
705
Default Alt Text
0001-enhanced-clippedsurfaceboundscalculator-so-that-the-.patch (5 KB)

Event Timeline

quick solution to determine intersection points of 2 Geometry3D