Page MenuHomePhabricator

patch-3293.diff

Authored By
maleike
Feb 10 2010, 4:35 PM
Size
64 KB
Referenced Files
None
Subscribers
None

patch-3293.diff

Index: Core/Code/files.cmake
===================================================================
--- Core/Code/files.cmake (revision 21264)
+++ Core/Code/files.cmake (working copy)
@@ -57,9 +57,9 @@
DataManagement/mitkClippingProperty.cpp
DataManagement/mitkColorProperty.cpp
DataManagement/mitkDataStorage.cpp
- DataManagement/mitkDataTree.cpp
+ #DataManagement/mitkDataTree.cpp
DataManagement/mitkDataTreeNode.cpp
- DataManagement/mitkDataTreeStorage.cpp
+ #DataManagement/mitkDataTreeStorage.cpp
DataManagement/mitkDisplayGeometry.cpp
DataManagement/mitkEnumerationProperty.cpp
DataManagement/mitkGeometry2D.cpp
Index: Core/Code/DataManagement/mitkDataTree.cpp
===================================================================
--- Core/Code/DataManagement/mitkDataTree.cpp (revision 21264)
+++ Core/Code/DataManagement/mitkDataTree.cpp (working copy)
@@ -1,318 +0,0 @@
-/*=========================================================================
-
-Program: Medical Imaging & Interaction Toolkit
-Language: C++
-Date: $Date$
-Version: $Revision$
-
-Copyright (c) German Cancer Research Center, Division of Medical and
-Biological Informatics. All rights reserved.
-See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
-
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
-
-=========================================================================*/
-
-
-#include "mitkDataTree.h"
-#include <mitkSmartPointerProperty.h>
-#include <mitkProperties.h>
-
-mitk::DataTree::DataTree() :
-DataTreeBase( )
-{
- DataTreeNode::Pointer emptyNode = DataTreeNode::New();
- emptyNode->SetProperty( "helper object", BoolProperty::New(true) );
- SetRoot(emptyNode);
-}
-
-
-mitk::DataTree::~DataTree()
-{
- Clear();
-}
-
-/**
-*
-*/
-mitk::DataTreeIteratorClone mitk::DataTree::GetNext( const char* propertyKey, const mitk::BaseProperty* property, mitk::DataTreeIteratorBase* startPosition )
-{
- DataTreeIteratorClone pos;
-
- if(startPosition != NULL)
- pos = *startPosition;
- else
- pos = DataTreePreOrderIterator(this);
-
- DataTreeNode::Pointer dtn;
- while ( !pos->IsAtEnd() )
- {
- dtn = pos->Get();
- PropertyList::Pointer propertyList = dtn->GetPropertyList();
- BaseProperty::Pointer tmp = propertyList->GetProperty( propertyKey );
- if ( (*property) == *(tmp) )
- return pos;
- ++pos;
- }
- return pos;
-}
-
-mitk::DataTreeIteratorClone mitk::DataTree::GetIteratorToNode(mitk::DataTreeBase* tree, const mitk::DataTreeNode* node, const mitk::DataTreeIteratorBase* startPosition )
-{
- DataTreeIteratorClone pos;
-
- if(startPosition != NULL)
- pos = *startPosition;
- else
- pos = DataTreePreOrderIterator(tree);
-
- while ( !pos->IsAtEnd() )
- {
- if ( pos->Get().GetPointer() == node )
- return pos;
- ++pos;
- }
- return pos;
-
-}
-
-mitk::Geometry3D::Pointer mitk::DataTree::ComputeBoundingGeometry3D(mitk::DataTreeIteratorBase* it, const char* boolPropertyKey, mitk::BaseRenderer* renderer, const char* boolPropertyKey2)
-{
- DataTreeIteratorClone _it=it;
- BoundingBox::PointsContainer::Pointer pointscontainer=BoundingBox::PointsContainer::New();
-
- BoundingBox::PointIdentifier pointid=0;
- Point3D point;
-
- Vector3D minSpacing;
- minSpacing.Fill(ScalarTypeNumericTraits::max());
-
- TimeBounds timeBounds;
- ScalarType stmin, stmax, cur;
- stmin= ScalarTypeNumericTraits::NonpositiveMin();
- stmax= ScalarTypeNumericTraits::max();
-
- timeBounds[0]=stmax; timeBounds[1]=stmin;
-
- // Needed for check of zero bounding boxes
- mitk::ScalarType nullpoint[]={0,0,0,0,0,0};
- BoundingBox::BoundsArrayType itkBoundsZero(nullpoint);
-
- while (!_it->IsAtEnd())
- {
- DataTreeNode::Pointer node = _it->Get();
- if((node.IsNotNull()) && (node->GetData() != NULL) &&
- (node->GetData()->IsEmpty()==false) &&
- node->IsOn(boolPropertyKey, renderer) &&
- node->IsOn(boolPropertyKey2, renderer)
- )
- {
- const Geometry3D* geometry = node->GetData()->GetUpdatedTimeSlicedGeometry();
- if (geometry != NULL )
- {
- // bounding box (only if non-zero)
- BoundingBox::BoundsArrayType itkBounds = geometry->GetBoundingBox()->GetBounds();
- if (itkBounds == itkBoundsZero)
- {
- continue;
- }
-
- unsigned char i;
- for(i=0; i<8; ++i)
- {
- point = geometry->GetCornerPoint(i);
- if(point[0]*point[0]+point[1]*point[1]+point[2]*point[2] < large)
- pointscontainer->InsertElement( pointid++, point);
- else
- {
- itkGenericOutputMacro( << "Unrealistically distant corner point encountered. Ignored. Node: " << node );
- }
- }
- // spacing
- try
- {
- AffineTransform3D::Pointer inverseTransform = AffineTransform3D::New();
- geometry->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[axis] > mmPerPixel)
- {
- minSpacing[axis] = mmPerPixel;
- }
- }
- // time bounds
- // Attention: Objects with zero bounding box are not respected in time bound calculation
- const TimeBounds & curTimeBounds = geometry->GetTimeBounds();
- cur=curTimeBounds[0];
- //is it after -infinity, but before everything else that we found until now?
- if((cur > stmin) && (cur < timeBounds[0]))
- timeBounds[0] = cur;
-
- cur=curTimeBounds[1];
- //is it before infinity, but after everything else that we found until now?
- if((cur < stmax) && (cur > timeBounds[1]))
- timeBounds[1] = cur;
- }
- catch(itk::ExceptionObject e)
- {
- MITK_ERROR << e << std::endl;
- }
- }
- }
- ++_it;
- }
-
- BoundingBox::Pointer result = BoundingBox::New();
- result->SetPoints(pointscontainer);
- result->ComputeBoundingBox();
-
- Geometry3D::Pointer geometry;
- if ( result->GetPoints()->Size()>0 )
- {
- geometry = Geometry3D::New();
- geometry->Initialize();
- // correct bounding-box (is now in mm, should be in index-coordinates)
- // according to spacing
- BoundingBox::BoundsArrayType bounds = result->GetBounds();
- int i;
- for(i = 0; i < 6; ++i)
- {
- bounds[i] /= minSpacing[i/2];
- }
- geometry->SetBounds(bounds);
- geometry->SetSpacing(minSpacing);
- // time bounds
- if(!(timeBounds[0]<stmax))
- {
- timeBounds[0] = stmin;
- timeBounds[1] = stmax;
- }
- geometry->SetTimeBounds(timeBounds);
- }
- return geometry;
-}
-
-mitk::Geometry3D::Pointer mitk::DataTree::ComputeVisibleBoundingGeometry3D(mitk::DataTreeIteratorBase* it, mitk::BaseRenderer* renderer, const char* boolPropertyKey)
-{
- return ComputeBoundingGeometry3D(it, "visible", renderer, boolPropertyKey);
-}
-
-mitk::BoundingBox::Pointer mitk::DataTree::ComputeBoundingBox(mitk::DataTreeIteratorBase* it, const char* boolPropertyKey, mitk::BaseRenderer* renderer, const char* boolPropertyKey2)
-{
- if(it == NULL)
- {
- return NULL;
- }
-
- DataTreeIteratorClone _it=it;
- BoundingBox::PointsContainer::Pointer pointscontainer=BoundingBox::PointsContainer::New();
-
- BoundingBox::PointIdentifier pointid=0;
- Point3D point;
-
- // Needed for check of zero bounding boxes
- mitk::ScalarType nullpoint[]={0,0,0,0,0,0};
- BoundingBox::BoundsArrayType itkBoundsZero(nullpoint);
-
- while (!_it->IsAtEnd())
- {
- DataTreeNode::Pointer node = _it->Get();
- if((node.IsNotNull()) && (node->GetData() != NULL) &&
- (node->GetData()->IsEmpty()==false) &&
- node->IsOn(boolPropertyKey, renderer) &&
- node->IsOn(boolPropertyKey2, renderer)
- )
- {
- const Geometry3D* geometry = node->GetData()->GetUpdatedTimeSlicedGeometry();
- if (geometry != NULL )
- {
- // ignore if zero
- BoundingBox::BoundsArrayType itkBounds = geometry->GetBoundingBox()->GetBounds();
- if (itkBounds == itkBoundsZero)
- {
- continue;
- }
-
- unsigned char i;
- for(i=0; i<8; ++i)
- {
- point = geometry->GetCornerPoint(i);
- if(point[0]*point[0]+point[1]*point[1]+point[2]*point[2] < large)
- pointscontainer->InsertElement( pointid++, point);
- else
- {
- itkGenericOutputMacro( << "Unrealistically distant corner point encountered. Ignored. Node: " << node );
- }
- }
- }
- }
- ++_it;
- }
-
- BoundingBox::Pointer result = BoundingBox::New();
- result->SetPoints(pointscontainer);
- result->ComputeBoundingBox();
-
- return result;
-}
-
-mitk::TimeBounds mitk::DataTree::ComputeTimeBounds(mitk::DataTreeIteratorBase* it, const char* boolPropertyKey, mitk::BaseRenderer* renderer, const char* boolPropertyKey2)
-{
- if(it == NULL)
- {
- return NULL;
- }
-
- TimeBounds timeBounds;
-
- DataTreeIteratorClone _it=it;
-
- ScalarType stmin, stmax, cur;
-
- stmin= ScalarTypeNumericTraits::NonpositiveMin();
- stmax= ScalarTypeNumericTraits::max();
-
- timeBounds[0]=stmax; timeBounds[1]=stmin;
-
- while (!_it->IsAtEnd())
- {
- DataTreeNode::Pointer node = _it->Get();
- if((node.IsNotNull()) && (node->GetData() != NULL) &&
- (node->GetData()->IsEmpty()==false) &&
- node->IsOn(boolPropertyKey, renderer) &&
- node->IsOn(boolPropertyKey2, renderer)
- )
- {
- const Geometry3D* geometry = node->GetData()->GetUpdatedTimeSlicedGeometry();
- if (geometry != NULL )
- {
- const TimeBounds & curTimeBounds = geometry->GetTimeBounds();
- cur=curTimeBounds[0];
- //is it after -infinity, but before everything else that we found until now?
- if((cur > stmin) && (cur < timeBounds[0]))
- timeBounds[0] = cur;
-
- cur=curTimeBounds[1];
- //is it before infinity, but after everything else that we found until now?
- if((cur < stmax) && (cur > timeBounds[1]))
- timeBounds[1] = cur;
- }
- }
- ++_it;
- }
-
- if(!(timeBounds[0]<stmax))
- {
- timeBounds[0] = stmin;
- timeBounds[1] = stmax;
- }
-
- return timeBounds;
-}
Index: Core/Code/DataManagement/mitkDataTree.h
===================================================================
--- Core/Code/DataManagement/mitkDataTree.h (revision 21264)
+++ Core/Code/DataManagement/mitkDataTree.h (working copy)
@@ -1,164 +0,0 @@
-/*=========================================================================
-
-Program: Medical Imaging & Interaction Toolkit
-Language: C++
-Date: $Date$
-Version: $Revision$
-
-Copyright (c) German Cancer Research Center, Division of Medical and
-Biological Informatics. All rights reserved.
-See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
-
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
-
-=========================================================================*/
-
-
-#ifndef DATATREE_H_HEADER_INCLUDED_C1C7797C
-#define DATATREE_H_HEADER_INCLUDED_C1C7797C
-
-#include "mitkCommon.h"
-#include "mitkDataTreeNode.h"
-#include "mitkGeometry3D.h"
-
-#include <itkTreeContainer.h>
-#include <itkTreeIteratorClone.h>
-#include <itkPreOrderTreeIterator.h>
-#include <itkChildTreeIterator.h>
-#include <itkEventObject.h>
-
-namespace mitk
-{
-
-
-typedef itk::TreeContainer<mitk::DataTreeNode::Pointer> DataTreeBase;
-
-//##Documentation
-//## @brief typedef to a base-iterator on the data tree
-//## @ingroup DataManagement
-typedef itk::TreeIteratorBase<DataTreeBase> DataTreeIteratorBase;
-
-//##Documentation
-//## @brief typedef to an iterator on the data tree
-//## @ingroup DataManagement
-typedef itk::TreeIteratorClone<DataTreeIteratorBase> DataTreeIteratorClone;
-
-//##Documentation
-//## @brief typedef to a preorder-iterator on the data tree
-//## @ingroup DataManagement
-typedef itk::PreOrderTreeIterator<DataTreeBase> DataTreePreOrderIterator;
-
-//##Documentation
-//## @brief typedef to a children-iterator on the data tree
-//## @ingroup DataManagement
-typedef itk::ChildTreeIterator<DataTreeBase> DataTreeChildIterator;
-
-typedef itk::TreeChangeEvent<DataTreeBase> DataTreeChangeEvent;
-
-//##Documentation
-//## @brief Main run-time data management class defining a data tree
-//## @ingroup DataManagement
-class MITK_CORE_EXPORT DataTree : public DataTreeBase
-{
-
-public:
- mitkClassMacro(DataTree, DataTreeBase);
-
- /** Method for creation through the object factory. */
- itkNewMacro(Self);
-
- DataTreeIteratorClone GetNext( const char* propertyName, const mitk::BaseProperty* property, DataTreeIteratorBase* startPosition = NULL );
-
- DataTreeIteratorClone GetIteratorToNode(const DataTreeNode* node, const DataTreeIteratorBase* startPosition = NULL )
- {
- return GetIteratorToNode(this, node, startPosition);
- }
-
- static DataTreeIteratorClone GetIteratorToNode(mitk::DataTreeBase* tree, const DataTreeNode* node, const DataTreeIteratorBase* startPosition = NULL );
-
- //##Documentation
- //## @brief Compute the axis-parallel bounding geometry of the data tree
- //## (bounding box, minimal spacing of the considered nodes, live-span)
- //##
- //## @param it an iterator to a data tree structure
- //## @param boolPropertyKey if a BoolProperty with this boolPropertyKey exists for a node (for @a renderer)
- //## and is set to @a false, the node is ignored for the bounding-box calculation.
- //## @param renderer see @a boolPropertyKey
- //## @param boolPropertyKey2 a second condition that is applied additionally to @a boolPropertyKey
- static Geometry3D::Pointer ComputeBoundingGeometry3D(mitk::DataTreeIteratorBase* it, const char* boolPropertyKey = NULL, mitk::BaseRenderer* renderer = NULL, const char* boolPropertyKey2 = NULL);
-
- //##Documentation
- //## @brief Compute the axis-parallel bounding geometry of all visible parts of the
- //## data tree bounding box, minimal spacing of the considered nodes, live-span)
- //##
- //## Simply calls ComputeBoundingGeometry3D(it, "visible", renderer, boolPropertyKey).
- //## @param it an iterator of a data tree structure
- //## @param renderer the reference to the renderer
- //## @param boolPropertyKey if a BoolProperty with this boolPropertyKey exists for a node (for @a renderer)
- //## and is set to @a false, the node is ignored for the bounding-box calculation.
- static mitk::Geometry3D::Pointer ComputeVisibleBoundingGeometry3D(mitk::DataTreeIteratorBase* it, mitk::BaseRenderer* renderer = NULL, const char* boolPropertyKey = NULL);
-
- //##Documentation
- //## @brief Compute the bounding box of data tree structure
- //## @param it an iterator to a data tree structure
- //## @param boolPropertyKey if a BoolProperty with this boolPropertyKey exists for a node (for @a renderer)
- //## and is set to @a false, the node is ignored for the bounding-box calculation.
- //## @param renderer see @a boolPropertyKey
- //## @param boolPropertyKey2 a second condition that is applied additionally to @a boolPropertyKey
- static mitk::BoundingBox::Pointer ComputeBoundingBox(mitk::DataTreeIteratorBase* it, const char* boolPropertyKey = NULL, mitk::BaseRenderer* renderer = NULL, const char* boolPropertyKey2 = NULL);
-
- //##Documentation
- //## \brief Compute the bounding box of all visible parts of the data tree structure, for general
- //## rendering or renderer specific visibility property checking
- //##
- //## Simply calls ComputeBoundingBox(it, "visible", renderer, boolPropertyKey).
- //## @param it an iterator of a data tree structure
- //## @param renderer the reference to the renderer
- //## @param boolPropertyKey if a BoolProperty with this boolPropertyKey exists for a node (for @a renderer)
- //## and is set to @a false, the node is ignored for the bounding-box calculation.
- static mitk::BoundingBox::Pointer ComputeVisibleBoundingBox(mitk::DataTreeIteratorBase* it, mitk::BaseRenderer* renderer = NULL, const char* boolPropertyKey = NULL)
- {
- return ComputeBoundingBox(it, "visible", renderer, boolPropertyKey);
- }
-
- //##Documentation
- //## @brief Compute the time-bounds of the contents of a data tree structure
- //##
- //## The methods returns only [-infinity, +infinity], if all data-objects have an infinite live-span. Otherwise,
- //## all data-objects with infinite live-span are ignored.
- //## @param it an iterator to a data tree structure
- //## @param boolPropertyKey if a BoolProperty with this boolPropertyKey exists for a node (for @a renderer)
- //## and is set to @a false, the node is ignored for the time-bounds calculation.
- //## @param renderer see @a boolPropertyKey
- //## @param boolPropertyKey2 a second condition that is applied additionally to @a boolPropertyKey
- static TimeBounds ComputeTimeBounds(mitk::DataTreeIteratorBase* it, const char* boolPropertyKey, mitk::BaseRenderer* renderer, const char* boolPropertyKey2);
-
- //##Documentation
- //## @brief Compute the time-bounds of all visible parts of the data tree structure, for general
- //## rendering or renderer specific visibility property checking
- //##
- //## The methods returns only [-infinity, +infinity], if all data-objects have an infinite live-span. Otherwise,
- //## all data-objects with infinite live-span are ignored.
- //## Simply calls ComputeTimeBounds(it, "visible", renderer, boolPropertyKey).
- //## @param it an iterator to a data tree structure
- //## @param boolPropertyKey if a BoolProperty with this boolPropertyKey exists for a node (for @a renderer)
- //## and is set to @a false, the node is ignored for the time-bounds calculation.
- //## @param renderer see @a boolPropertyKey
- static TimeBounds ComputeTimeBounds(mitk::DataTreeIteratorBase* it, mitk::BaseRenderer* renderer, const char* boolPropertyKey)
- {
- return ComputeTimeBounds(it, "visible", renderer, boolPropertyKey);
- }
-
-
-protected:
- DataTree();
-
- virtual ~DataTree();
-};
-
-} // namespace mitk
-#endif /* DATATREE_H_HEADER_INCLUDED_C1C7797C */
-
-
Index: Core/Code/DataManagement/mitkDataTreeStorage.h
===================================================================
--- Core/Code/DataManagement/mitkDataTreeStorage.h (revision 21264)
+++ Core/Code/DataManagement/mitkDataTreeStorage.h (working copy)
@@ -1,182 +0,0 @@
-/*=========================================================================
-
-Program: Medical Imaging & Interaction Toolkit
-Language: C++
-Date: $Date$
-Version: $Revision$
-
-Copyright (c) German Cancer Research Center, Division of Medical and
-Biological Informatics. All rights reserved.
-See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
-
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
-
-=========================================================================*/
-
-
-#ifndef MITKDATATREESTORAGE_H_HEADER_INCLUDED_
-#define MITKDATATREESTORAGE_H_HEADER_INCLUDED_
-
-#include "mitkDataStorage.h"
-//#include "mitkCommon.h"
-#include "mitkDataTree.h"
-
-namespace mitk {
-
- class NodePredicateBase;
- class DataTreeNode;
- class BaseRenderer;
- class Geometry2DDataVtkMapper3D;
-
- //##Documentation
- //## @brief Data management class that handles 'was created by' relations
- //##
- //## The DataTreeStorage provides data storage and management functionality.
- //## It handles a 'was created by' relation by associating each data object with a
- //## set of source objects, that this object was created from.
- //## Thus, nodes are stored in a noncyclical directed graph data structure.
- //## If a new node is added to the DataTreeStorage, AddNodeEvent is emitted.
- //## If a node is removed, RemoveNodeEvent is emitted.
- //## Currently, DataTreeStorage uses an underlying mitk::DataTree. Therefore a DataTreeStorage object
- //## must be initialized with a DataTree before it can be used by calling ->Initialize(myTree).
- //## @warning DataTreeStorage methods will raise exceptions if called before the DataTreeStorage is initialized.
- //##
- //## All objects that are added to DataTreeStorage get automatically added to the underlying tree.
- //## The tree can be used to get notifications on New/Delete events.
- //## @warning Do not mix Adding/Removing objects with the DataTreeStorage and DataTree methods.
- //## @warning The DataTreeStorage does not automatically return all objects that are stored in the
- //## DataTree. Use SetManageCompleteTree() to enable/disable management of objects that were
- //## added to the tree directly.
- //##
- //## @ingroup DataTreeStorage
- class MITK_CORE_EXPORT DataTreeStorage : public DataStorage
- {
- public:
- mitkClassMacro(DataTreeStorage, DataStorage);
-
- //##Documentation
- //## @brief Adds a DataTreeNode containing a data object to its internal storage
- //##
- //## This Method adds a new data object to the DataTreeStorage. The new object is
- //## passed in the first parameter. The second parameter is a set
- //## of source objects, that were used to create this object. The new object will have
- //## a 'was created from' relation to its source objects.
- //## the addition of a new object will fire the notification mechanism.
- //## If the node parameter is NULL or if the DataTreeNode has already been added,
- //## an exception will be thrown.
- void Add(mitk::DataTreeNode* node, const mitk::DataTreeStorage::SetOfObjects* parents = NULL);
-
- //##Documentation
- //## @brief Removes node from the DataTreeStorage
- //##
- void Remove(const mitk::DataTreeNode* node);
-
- //##Documentation
- //## @brief Checks if a node exists in the DataTreeStorage
- //##
- virtual bool Exists(const mitk::DataTreeNode* node) const;
-
- //##Documentation
- //## @brief returns a set of source objects for a given node that meet the given condition(s).
- //##
- SetOfObjects::ConstPointer GetSources(const mitk::DataTreeNode* node, const NodePredicateBase* condition = NULL, bool onlyDirectSources = true) const;
-
- //##Documentation
- //## @brief returns a set of derived objects for a given node.
- //##
- //## GetDerivations() returns a set of objects that are derived from the DataTreeNode node.
- //## This means, that node was used to create the returned objects. If the parameter
- //## onlyDirectDerivations is set to true (default value), only objects that directly have
- //## node as one of their source objects will be returned. Otherwise, objects that are
- //## derived from derivations of node are returned too.
- //## The derived objects can be filtered with a predicate object as described in the GetSubset()
- //## method by providing a predicate as the condition parameter.
- SetOfObjects::ConstPointer GetDerivations(const mitk::DataTreeNode* node, const NodePredicateBase* condition = NULL, bool onlyDirectDerivations = true) const;
-
- //##Documentation
- //## @brief returns a set of all data objects that are stored in the data storage
- //##
- SetOfObjects::ConstPointer GetAll() const;
-
- //##Documentation
- //## @brief Initializes the class by providing the data tree that should be used for data storage
- //##
- void Initialize(mitk::DataTree* tree);
-
- //##Documentation
- //## @brief Callback method to get notified, if a node in the underlying DataTree gets removed
- //##
- void NodeDeletedInTree(const itk::EventObject & treeChangedEvent);
-
- //##Documentation
- //## @brief If true, the DataTreeStorage object manages all objects in the dataTree, not only the ones added by it
- itkSetMacro(ManageCompleteTree, bool);
- itkGetMacro(ManageCompleteTree, bool);
- itkBooleanMacro(ManageCompleteTree);
-
- protected:
-
- //TODO investigate removing friend declarations when DataTreeStorage is
- // independent of the DataTree
- friend class BaseRenderer;
- friend class Geometry2DDataVtkMapper3D;
- friend class RenderingManager;
- friend class DataStorage;
-
- itkNewMacro(Self); // New Macro is protected, because we use Singleton pattern for DataTreeStorage
-
- typedef std::map<mitk::DataTreeNode::ConstPointer, SetOfObjects::ConstPointer> AdjacencyList;
-
-
- //##Documentation
- //## @brief Standard Constructor for ::New() instantiation
- DataTreeStorage();
- //##Documentation
- //## @brief Standard Destructor
- virtual ~DataTreeStorage();
-
- //##Documentation
- //## @brief convenience method to check if the object has been initialized (i.e. a data tree has been set)
- bool IsInitialized() const;
-
- //##Documentation
- //## @brief Traverses the Relation graph and extracts a list of related elements (e.g. Sources or Derivations)
- SetOfObjects::ConstPointer GetRelations(const mitk::DataTreeNode* node, const AdjacencyList& relation, const NodePredicateBase* condition = NULL, bool onlyDirectlyRelated = true) const;
-
- //##Documentation
- //## @brief deletes all references to a node in a given relation (used in Remove() and TreeListener)
- void RemoveFromRelation(const mitk::DataTreeNode* node, AdjacencyList& relation);
-
- //##Documentation
- //## @brief Prints the contents of the DataTreeStorage to os. Do not call directly, call ->Print() instead
- virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
-
-
- //##Documentation
- //## @brief holds the data tree that is encapsulated by this class
- mitk::DataTree::Pointer m_DataTree;
-
- //##Documentation
- //## @brief If true, the DataTreeStorage object manages all objects in the dataTree, not only the ones added by it
- bool m_ManageCompleteTree;
-
- //##Documentation
- //## @brief Flag that is set in Remove() method to prevent tree notification mechanism from deleting the same object we are just about to delete
- bool m_DuringRemove;
-
- //##Documentation
- //## @brief Nodes and their relation are stored in m_SourceNodes
- AdjacencyList m_SourceNodes;
-
- //##Documentation
- //## @brief Nodes are stored in reverse relation for easier traversal in the opposite direction of the relation
- AdjacencyList m_DerivedNodes;
-
- unsigned long m_DeleteInTreeObserverTag;
-
- };
-} // namespace mitk
-
-#endif /* MITKDATATREESTORAGE_H_HEADER_INCLUDED_ */
Index: Core/Code/DataManagement/mitkDataTreeStorage.cpp
===================================================================
--- Core/Code/DataManagement/mitkDataTreeStorage.cpp (revision 21264)
+++ Core/Code/DataManagement/mitkDataTreeStorage.cpp (working copy)
@@ -1,315 +0,0 @@
-/*=========================================================================
-
-Program: Medical Imaging & Interaction Toolkit
-Language: C++
-Date: $Date$
-Version: $Revision$
-
-Copyright (c) German Cancer Research Center, Division of Medical and
-Biological Informatics. All rights reserved.
-See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
-
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
-
-=========================================================================*/
-
-#include "mitkDataTreeStorage.h"
-
-#include "mitkDataTreeNode.h"
-#include "mitkProperties.h"
-#include "mitkNodePredicateBase.h"
-#include "mitkNodePredicateProperty.h"
-#include "mitkGroupTagProperty.h"
-#include "itkCommand.h"
-
-
-
-mitk::DataTreeStorage::DataTreeStorage()
-: mitk::DataStorage(), m_ManageCompleteTree(true), m_DuringRemove(false)
-{
- m_DataTree = NULL;
-}
-
-
-mitk::DataTreeStorage::~DataTreeStorage()
-{
- if(m_DataTree.IsNotNull())
- {
- m_DataTree->RemoveObserver(m_DeleteInTreeObserverTag);
- for(AdjacencyList::iterator it = m_SourceNodes.begin();
- it != m_SourceNodes.end(); it++)
- {
- this->RemoveListeners(it->first);
- }
- }
-}
-
-
-void mitk::DataTreeStorage::Initialize(mitk::DataTree* tree)
-{
- if (tree == NULL)
- throw 1; // insert exception handling here
- m_DataTree = tree;
- itk::ReceptorMemberCommand<Self>::Pointer command = itk::ReceptorMemberCommand<Self>::New();
- command->SetCallbackFunction(this, &mitk::DataTreeStorage::NodeDeletedInTree);
- m_DeleteInTreeObserverTag = m_DataTree->AddObserver(itk::TreeRemoveEvent<mitk::DataTreeBase>(), command);
-}
-
-void mitk::DataTreeStorage::NodeDeletedInTree(const itk::EventObject & treeChangedEvent)
-{
- if (m_DuringRemove == true) // this notification is from our own Remove() method and should not be processed further)
- return;
-
- const itk::TreeRemoveEvent<mitk::DataTreeBase>* rme = dynamic_cast< const itk::TreeRemoveEvent<mitk::DataTreeBase>* >(&treeChangedEvent);
- if (rme == NULL)
- return;
- const mitk::DataTreeIteratorClone it(rme->GetChangePosition());
- mitk::DataTreeNode* node = it->Get();
- if (node == NULL)
- return;
-
- // remove ITK modified event listener
- this->RemoveListeners(node);
-
- /* Notify observers of imminent node removal */
- EmitRemoveNodeEvent(node);
-
- /* remove the node from our relation, now that it was removed from the tree */
- this->RemoveFromRelation(node, m_SourceNodes);
- this->RemoveFromRelation(node, m_DerivedNodes);
-}
-
-
-bool mitk::DataTreeStorage::IsInitialized() const
-{
- return m_DataTree.IsNotNull();
-}
-
-
-void mitk::DataTreeStorage::Add(mitk::DataTreeNode* node, const mitk::DataStorage::SetOfObjects* parents)
-{
- if (!IsInitialized())
- throw 1; // insert exception handling here
-
- /* Check, if node is already in the DataTree */
- if (m_DataTree->Contains(node))
- throw 2;
-
- /* check if node is in its own list of sources */
- if ((parents != NULL) && (std::find(parents->begin(), parents->end(), node) != parents->end()))
- throw 3;
-
- /* save node in tree */
- node->SetProperty("IsDataStoreManaged", mitk::BoolProperty::New(true));
- mitk::DataTreeNode::ConstPointer parent;
- if ((parents != NULL) && (parents->Size() > 0))
- parent = parents->ElementAt(0);
- else
- parent = NULL;
- DataTreeIteratorClone it = m_DataTree->GetIteratorToNode(parent);
- if (it->IsAtEnd())
- it->GoToBegin();
- it->Add(node);
- /* create parentlist if it does not exist */
- mitk::DataStorage::SetOfObjects::ConstPointer sp;
- if (parents != NULL)
- sp = parents;
- else
- sp = mitk::DataStorage::SetOfObjects::New();
- /* Store node and parent list in sources adjacency list */
- m_SourceNodes.insert(std::make_pair(node, sp));
-
- /* Store node and an empty children list in derivations adjacency list */
- mitk::DataStorage::SetOfObjects::Pointer children = mitk::DataStorage::SetOfObjects::New();
- m_DerivedNodes.insert(std::make_pair(node, children));
-
- /* create entry in derivations adjacency list for each parent of the new node */
- for (SetOfObjects::ConstIterator it = sp->Begin(); it != sp->End(); it++)
- {
- mitk::DataTreeNode::ConstPointer parent = it.Value().GetPointer();
- mitk::DataStorage::SetOfObjects::ConstPointer derivedObjects = m_DerivedNodes[parent]; // get or create pointer to list of derived objects for that parent node
- if (derivedObjects.IsNull())
- m_DerivedNodes[parent] = mitk::DataStorage::SetOfObjects::New(); // Create a set of Objects, if it does not already exist
- mitk::DataStorage::SetOfObjects* deob = const_cast<mitk::DataStorage::SetOfObjects*>(m_DerivedNodes[parent].GetPointer()); // temporarily get rid of const pointer to insert new element
- deob->InsertElement(deob->Size(), node); // node is derived from parent. Insert it into the parents list of derived objects
- }
-
- // register for ITK changed events
- this->AddListeners(node);
-
- /* Notify observers */
- EmitAddNodeEvent(node);
-}
-
-
-void mitk::DataTreeStorage::Remove(const mitk::DataTreeNode* node)
-{
- if (!IsInitialized())
- throw 1; // insert exception handling here
- if (node == NULL)
- return;
-
- mitk::DataTreeIteratorClone it = m_DataTree->GetIteratorToNode(node); // search node in tree
- if (it->IsAtEnd())
- return; // node not found
-
- m_DuringRemove = true;
-
- // remove ITK modified event listener
- this->RemoveListeners(node);
-
- /* Notify observers of imminent node removal */
- EmitRemoveNodeEvent(node);
-
- /* remove node from tree, but keep its children */
- if (it->Disconnect() == false)
- {
- m_DuringRemove = false;
- throw 2;
- }
-
- /* remove node from both relation adjacency lists */
- this->RemoveFromRelation(node, m_SourceNodes);
- this->RemoveFromRelation(node, m_DerivedNodes);
-
- m_DuringRemove = false;
-
-}
-
-bool mitk::DataTreeStorage::Exists(const mitk::DataTreeNode* node) const
-{
- return (m_SourceNodes.find(node) != m_SourceNodes.end());
-}
-
-void mitk::DataTreeStorage::RemoveFromRelation(const mitk::DataTreeNode* node, AdjacencyList& relation)
-{
- for (AdjacencyList::const_iterator mapIter = relation.begin(); mapIter != relation.end(); ++mapIter) // for each node in the relation
- if (mapIter->second.IsNotNull()) // if node has a relation list
- {
- SetOfObjects::Pointer s = const_cast<SetOfObjects*>(mapIter->second.GetPointer()); // search for node to be deleted in the relation list
- SetOfObjects::STLContainerType::iterator relationListIter = std::find(s->begin(), s->end(), node); // this assumes, that the relation list does not contain duplicates (which should be safe to assume)
- if (relationListIter != s->end()) // if node to be deleted is in relation list
- s->erase(relationListIter); // remove it from parentlist
- }
- /* now remove node from the relation */
- AdjacencyList::iterator adIt;
- adIt = relation.find(node);
- if (adIt != relation.end())
- relation.erase(adIt);
-}
-
-
-mitk::DataStorage::SetOfObjects::ConstPointer mitk::DataTreeStorage::GetAll() const
-{
- if (!IsInitialized())
- throw 1; // insert exception handling here
-
- mitk::DataTreePreOrderIterator it(m_DataTree);
- mitk::DataStorage::SetOfObjects::Pointer resultset = mitk::DataStorage::SetOfObjects::New();
- /* Fill resultset with all objects that are managed by the DataTreeStorage object */
- unsigned int index = 0;
- for (it.GoToBegin(); !it.IsAtEnd(); it++)
- {
- mitk::DataTreeNode* node = it.Get();
- if (node == NULL)
- continue;
- if (m_ManageCompleteTree == true)
- resultset->InsertElement(index++, node);
- else
- if (node->IsOn("IsDataStoreManaged",NULL, false) == true) // check if node is managed by the DataTreeStorage object
- resultset->InsertElement(index++, node);
- }
- return SetOfObjects::ConstPointer(resultset);
-}
-
-
-mitk::DataStorage::SetOfObjects::ConstPointer mitk::DataTreeStorage::GetRelations(const mitk::DataTreeNode* node, const AdjacencyList& relation, const NodePredicateBase* condition, bool onlyDirectlyRelated) const
-{
- if (node == NULL)
- throw 1;
-
- if ((m_ManageCompleteTree == false) && (node->IsOn("IsDataStoreManaged",NULL, false) == false)) // node is not managed by DataTreeStorage
- throw 2;
-
- if (m_DataTree->GetIteratorToNode(node)->IsAtEnd()) // node not in tree
- {
- return SetOfObjects::ConstPointer( SetOfObjects::New() );
- //throw 3;
- }
-
- /* Either read direct relations directly from adjacency list */
- if (onlyDirectlyRelated)
- {
- AdjacencyList::const_iterator it = relation.find(node); // get parents of current node
- if ((it == relation.end()) || (it->second.IsNull())) // node not found in list or no set of parents
- return SetOfObjects::ConstPointer(mitk::DataStorage::SetOfObjects::New()); // return an empty set
- else
- return this->FilterSetOfObjects(it->second, condition);
- }
-
- /* Or traverse adjacency list to collect all related nodes */
- std::vector<mitk::DataTreeNode::ConstPointer> resultset;
- std::vector<mitk::DataTreeNode::ConstPointer> openlist;
-
- /* Initialize openlist with node. this will add node to resultset,
- but that is necessary to detect circular relations that would lead to endless recursion */
- openlist.push_back(node);
-
- while (openlist.size() > 0)
- {
- mitk::DataTreeNode::ConstPointer current = openlist.back(); // get element that needs to be processed
- openlist.pop_back(); // remove last element, because it gets processed now
- resultset.push_back(current); // add current element to resultset
- AdjacencyList::const_iterator it = relation.find(current); // get parents of current node
- if ( (it == relation.end()) // if node not found in list
- || (it->second.IsNull()) // or no set of parents available
- || (it->second->Size() == 0)) // or empty set of parents
- continue; // then continue with next node in open list
- else
- for (SetOfObjects::ConstIterator parentIt = it->second->Begin(); parentIt != it->second->End(); ++parentIt) // for each parent of current node
- {
- mitk::DataTreeNode::ConstPointer p = parentIt.Value().GetPointer();
- if ( !(std::find(resultset.begin(), resultset.end(), p) != resultset.end()) // if it is not already in resultset
- && !(std::find(openlist.begin(), openlist.end(), p) != openlist.end())) // and not already in openlist
- openlist.push_back(p); // then add it to openlist, so that it can be processed
- }
- }
-
- /* now finally copy the results to a proper SetOfObjects variable exluding the initial node and checking the condition if any is given */
- mitk::DataStorage::SetOfObjects::Pointer realResultset = mitk::DataStorage::SetOfObjects::New();
- if (condition != NULL)
- {
- for (std::vector<mitk::DataTreeNode::ConstPointer>::iterator resultIt = resultset.begin(); resultIt != resultset.end(); resultIt++)
- if ((*resultIt != node) && (condition->CheckNode(*resultIt) == true))
- realResultset->InsertElement(realResultset->Size(), mitk::DataTreeNode::Pointer(const_cast<mitk::DataTreeNode*>((*resultIt).GetPointer())));
- }
- else
- {
- for (std::vector<mitk::DataTreeNode::ConstPointer>::iterator resultIt = resultset.begin(); resultIt != resultset.end(); resultIt++)
- if (*resultIt != node)
- realResultset->InsertElement(realResultset->Size(), mitk::DataTreeNode::Pointer(const_cast<mitk::DataTreeNode*>((*resultIt).GetPointer())));
- }
- return SetOfObjects::ConstPointer(realResultset);
-}
-
-
-mitk::DataStorage::SetOfObjects::ConstPointer mitk::DataTreeStorage::GetSources(const mitk::DataTreeNode* node, const NodePredicateBase* condition, bool onlyDirectSources) const
-{
- return this->GetRelations(node, m_SourceNodes, condition, onlyDirectSources);
-}
-
-
-mitk::DataStorage::SetOfObjects::ConstPointer mitk::DataTreeStorage::GetDerivations(const mitk::DataTreeNode* node, const NodePredicateBase* condition, bool onlyDirectDerivations) const
-{
- return this->GetRelations(node, m_DerivedNodes, condition, onlyDirectDerivations);
-}
-
-
-void mitk::DataTreeStorage::PrintSelf(std::ostream& os, itk::Indent indent) const
-{
- os << indent << "DataTreeStorage:\n";
- os << indent << "Using DataTree: " << m_DataTree << "\n";
- Superclass::PrintSelf(os, indent);
-}
Index: Modules/MitkExt/DataManagement/mitkDataTreeHelper.h
===================================================================
--- Modules/MitkExt/DataManagement/mitkDataTreeHelper.h (revision 21264)
+++ Modules/MitkExt/DataManagement/mitkDataTreeHelper.h (working copy)
@@ -1,107 +0,0 @@
-/*=========================================================================
-
-Program: Medical Imaging & Interaction Toolkit
-Language: C++
-Date: $Date$
-Version: $Revision$
-
-Copyright (c) German Cancer Research Center, Division of Medical and
-Biological Informatics. All rights reserved.
-See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
-
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
-
-=========================================================================*/
-
-
-#ifndef DATATREEHELPER_H_HEADER_INCLUDED_C1C7797C
-#define DATATREEHELPER_H_HEADER_INCLUDED_C1C7797C
-
-#include "mitkCommon.h"
-#include "MitkExtExports.h"
-#include "mitkDataTree.h"
-
-#include "mitkImageCast.h"
-#include "mitkStringProperty.h"
-#include "mitkLevelWindowProperty.h"
-#include "mitkDataTreeNodeFactory.h"
-
-namespace mitk
-{
-
- //##Documentation
- //## @brief Convenience methods for common tasks concerning the data tree
- //## @ingroup DataManagement
- namespace DataTreeHelper
- {
- //##Documentation
- //## @brief Search a data tree for (the first) iterator to a given node
- MitkExt_EXPORT DataTreeIteratorClone FindIteratorToNode(mitk::DataTreeBase* tree, const DataTreeNode* node);
-
- //##Documentation
- //## @brief Search a data tree for (the first) iterator to a given node
- MitkExt_EXPORT DataTreeIteratorClone FindIteratorToNode(const DataTreeIteratorBase* startPosition, const DataTreeNode* node);
-
- //##Documentation
- //## @brief Add itk-image to data tree
- //##
- //## The itk-image is converted into an mitk::Image.
- //## @param itkImage the itk-image to be added
- //## @param iterator the iterator used for adding the node, containing the image
- //## @param name string with the name of the image, stored in the property "name"
- //## @param replaceByName if @a true, the tree is searched starting at
- //## @a iterator for a node called @a name, which data is replaced with
- //## @a itkImage
- template < typename TImageType >
- mitk::DataTreeNode::Pointer
- AddItkImageToDataTree(TImageType* itkImage, mitk::DataTreeIteratorBase* iterator, const char* name=NULL, bool replaceByName=false)
- {
- itkImage->Update();
-
- mitk::Image::Pointer mitkImage = mitk::Image::New();
- mitk::CastToMitkImage(itkImage, mitkImage);
-
- mitk::DataTreeNode::Pointer node = NULL;
- bool done=false;
- if((replaceByName) && (name != NULL))
- {
- mitk::DataTreeIteratorClone it=iterator;
- mitk::DataTreeIteratorClone itByName = ((mitk::DataTree *) it->GetTree())->GetNext("name", mitk::StringProperty::New( name ));
-
- if( (itByName->IsAtEnd() == false) && (itByName->Get().IsNotNull()) )
- {
- node = itByName->Get();
- node->SetData(mitkImage);
- done = true;
- }
- }
- if(done==false)
- {
- node=mitk::DataTreeNode::New();
- node->SetData(mitkImage);
- if(name!=NULL)
- node->SetProperty("name", mitk::StringProperty::New(name));
- iterator->Add(node);
- }
-
- mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New();
- mitk::LevelWindow levelwindow;
- levelwindow.SetAuto( mitkImage );
- levWinProp->SetLevelWindow( levelwindow );
- node->SetProperty( "levelwindow", levWinProp );
-
- return node;
- }
- /** Get child node which has a specified name
- * @returns child node of iterator which has the given name
- */
- MitkExt_EXPORT DataTreeIteratorClone GetNamedChild(mitk::DataTreeIteratorBase* iterator, std::string name);
- };
-
-} // namespace mitk
-
-#endif /* DATATREEHELPER_H_HEADER_INCLUDED_C1C7797C */
-
-
Index: Modules/MitkExt/DataManagement/mitkDataTreeHelper.txx
===================================================================
--- Modules/MitkExt/DataManagement/mitkDataTreeHelper.txx (revision 21264)
+++ Modules/MitkExt/DataManagement/mitkDataTreeHelper.txx (working copy)
@@ -1,38 +0,0 @@
-/*=========================================================================
-
-Program: Medical Imaging & Interaction Toolkit
-Module: $RCSfile$
-Language: C++
-Date: $Date$
-Version: $Revision$
-
-Copyright (c) German Cancer Research Center, Division of Medical and
-Biological Informatics. All rights reserved.
-See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
-
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
-
-=========================================================================*/
-
-#include <mitkImageToItkMultiplexer.h>
-#include <mitkStringProperty.h>
-#include <mitkLevelWindowProperty.h>
-#include <mitkDataTreeNodeFactory.h>
-
-namespace mitk
-{
-
-namespace DataTreeHelper
-
-{
-
-template < typename TImageType >
-mitk::DataTreeNode::Pointer
-AddItkImageToDataTree(TImageType* itkImage, mitk::DataTreeIteratorBase* iterator, const char* name=NULL, bool replaceByName=false)
-
-
-}
-
-}
Index: Modules/QmitkExt/QmitkApplicationBase/QmitkCommonFunctionality.cpp
===================================================================
--- Modules/QmitkExt/QmitkApplicationBase/QmitkCommonFunctionality.cpp (revision 21264)
+++ Modules/QmitkExt/QmitkApplicationBase/QmitkCommonFunctionality.cpp (working copy)
@@ -275,72 +275,6 @@
QMessageBox::critical(NULL,"ERROR","Save not successful. Possibly no writing permission.");
}
}
-
-mitk::DataTreeNode::Pointer CommonFunctionality::AddVtkMeshToDataTree(vtkPolyData* polys, mitk::DataTreeIteratorBase* iterator, std::string str)
-{
- mitk::DataTreeIteratorClone it=iterator;
-
- mitk::DataTreeNode::Pointer node = NULL;
- mitk::DataTreeIteratorClone subTree = ((mitk::DataTree *) it->GetTree())->GetNext("name", mitk::StringProperty::New( str.c_str() ));
-
- if (subTree->IsAtEnd() || subTree->Get().IsNull() )
- {
- node=mitk::DataTreeNode::New();
- mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New(str.c_str());
- node->SetProperty("name",nameProp);
- it->Add(node);
- }
- else
- {
- node = subTree->Get();
- }
-
- mitk::Surface::Pointer surface = mitk::Surface::New();
- surface->SetVtkPolyData(polys);
- node->SetData( surface );
- node->SetProperty("layer", mitk::IntProperty::New(1));
- node->SetVisibility(true,NULL);
-
- float meshColor[3] = {1.0,0.5,0.5};
- node->SetColor(meshColor, NULL );
- node->SetVisibility(true, NULL );
-
- return node;
-}
-
-mitk::DataTreeNode::Pointer CommonFunctionality::AddPicImageToDataTree(mitkIpPicDescriptor * pic, mitk::DataTreeIteratorBase* iterator, std::string str)
-{
- mitk::DataTreeIteratorClone it=iterator;
-
- mitk::Image::Pointer image = mitk::Image::New();
- image->Initialize(pic);
- image->SetPicVolume(pic);
-
- mitk::DataTreeNode::Pointer node = NULL;
- mitk::DataTreeIteratorClone subTree = ((mitk::DataTree *) it->GetTree())->GetNext("name", mitk::StringProperty::New( str.c_str() ));
-
- if (subTree->IsAtEnd() || subTree->Get().IsNull() )
- {
- node=mitk::DataTreeNode::New();
- mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New(str.c_str());
- node->SetProperty("name",nameProp);
- node->SetData(image);
- it->Add(node);
- }
- else
- {
- node = subTree->Get();
- node->SetData(image);
- }
-
- mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New();
- mitk::LevelWindow levelWindow;
- levelWindow.SetAuto( image );
- levWinProp->SetLevelWindow(levelWindow);
- node->GetPropertyList()->SetProperty("levelwindow",levWinProp);
- return node;
-}
-
mitk::DataTreeNode::Pointer CommonFunctionality::FileOpen( const QString& fileName)
{
return FileOpen( fileName.toLocal8Bit().constData() );
@@ -479,119 +413,7 @@
return NULL;
}
}
-mitk::DataTreeIteratorBase* CommonFunctionality::GetIteratorToFirstImage(mitk::DataTreeIteratorBase* dataTreeIterator)
-{
- mitk::DataTreeIteratorClone it = dataTreeIterator;
- while ( !it->IsAtEnd() )
- {
- mitk::DataTreeNode::Pointer node = it->Get();
- if ( node->GetData() != NULL )
- {
- // access the original image
- mitk::Image::Pointer img = dynamic_cast<mitk::Image*>( node->GetData() );
- // enquiry whether img is NULL
- if ( img.IsNotNull() )
- {
- return it->Clone();
- }
- }
- ++it;
- }
- std::cout << "No node containing an mitk::Image found, returning NULL..." << std::endl;
- return NULL;
-}
-
-mitk::DataTreeIteratorBase* CommonFunctionality::GetIteratorToFirstImageInDataTree(mitk::DataTree::Pointer dataTree)
-{
- mitk::DataTreePreOrderIterator dataTreeIterator( dataTree );
-
- if ( dataTree.IsNull() )
- {
- std::cout << "iterator to data tree is NULL. I cannot work without datatree !!" << std::endl;
- return NULL;
- }
-
- return GetIteratorToFirstImage(&dataTreeIterator);
-}
-
-mitk::Image* CommonFunctionality::GetFirstImageInDataTree(mitk::DataTree::Pointer dataTree)
-{
- mitk::DataTreeIteratorClone it = GetIteratorToFirstImageInDataTree(dataTree);
- if(it.IsNull())
- return NULL;
- return static_cast<mitk::Image*>(it->Get()->GetData());
-}
-mitk::DataTreeNode* CommonFunctionality::GetFirstNodeByProperty( mitk::DataTreeIteratorClone it, std::string propertyKey, mitk::BaseProperty* property )
-{
- mitk::DataTreeIteratorClone pos = dynamic_cast<mitk::DataTree*>( it->GetTree() )->GetNext( propertyKey.c_str(), property, it.GetPointer() );
- if ( ! pos->IsAtEnd() )
- {
- return pos->Get();
- }
- else
- {
- return NULL;
- }
-
-}
-mitk::BaseData* CommonFunctionality::GetFirstDataByProperty( mitk::DataTreeIteratorClone it, std::string propertyKey, mitk::BaseProperty* property )
-{
- mitk::DataTreeNode* node = GetFirstNodeByProperty( it, propertyKey, property );
- if ( node == NULL )
- {
- return NULL;
- }
- else
- {
- return node->GetData();
- }
-}
-
-mitk::DataTreeNode* CommonFunctionality::GetNodeForData( mitk::DataTreeIteratorClone it, mitk::BaseData* data )
-{
- if ( it.GetPointer() == NULL )
- {
- return NULL;
- }
-
- mitk::DataTreeIteratorClone iteratorClone = it;
- while ( !iteratorClone->IsAtEnd() )
- {
- mitk::DataTreeNode::Pointer node = iteratorClone->Get();
- if ( node.IsNotNull() )
- {
- if ( node->GetData() == data )
- return node.GetPointer();
- }
- ++iteratorClone;
- }
- return NULL;
-}
-
-CommonFunctionality::DataTreeIteratorVector CommonFunctionality::FilterNodes(mitk::DataTreeIteratorClone it, bool (* FilterFunction)(mitk::DataTreeNode*))
-{
-
- DataTreeIteratorVector result;
-
- if ( it.GetPointer() != NULL )
- {
-
- mitk::DataTreeIteratorClone iteratorClone = it;
- while ( !iteratorClone->IsAtEnd() )
- {
- mitk::DataTreeNode::Pointer node = iteratorClone->Get();
- if ( (FilterFunction == NULL) || FilterFunction( node ) )
- {
- result.push_back(iteratorClone);
- }
- ++iteratorClone;
- }
- }
- return result;
-
-}
-
#include "mitkSurfaceVtkWriter.h"
#include <vtkSTLWriter.h>
#include <vtkPolyDataWriter.h>
Index: Modules/QmitkExt/QmitkApplicationBase/QmitkCommonFunctionality.h
===================================================================
--- Modules/QmitkExt/QmitkApplicationBase/QmitkCommonFunctionality.h (revision 21264)
+++ Modules/QmitkExt/QmitkApplicationBase/QmitkCommonFunctionality.h (working copy)
@@ -39,7 +39,6 @@
#include <mitkDataTreeNode.h>
#include <mitkDataTreeNodeFactory.h>
#include <mitkImageCast.h>
-#include <mitkDataTree.h>
#include <mitkSurface.h>
#include "itkImage.h"
#include <mitkFileWriterWithInformation.h>
@@ -68,7 +67,6 @@
namespace CommonFunctionality
{
- typedef std::vector<mitk::DataTreeIteratorClone> DataTreeIteratorVector;
typedef std::vector<mitk::DataTreeNode*> DataTreeNodeVector;
/** \brief compute min and max
*/
@@ -118,94 +116,6 @@
}
}
-
- /**
- * \brief converts the itk image to mitk image, creates a datatreenode and adds the node to
- * the referenced datatree
- */
- template < typename TImageType >
- static mitk::DataTreeNode::Pointer
- AddItkImageToDataTree(typename TImageType::Pointer itkImage, mitk::DataTreeIteratorBase* iterator, std::string str)
- {
- mitk::DataTreeIteratorClone it=iterator;
-
- mitk::Image::Pointer image = mitk::Image::New();
- image->InitializeByItk(itkImage.GetPointer());
- image->SetVolume(itkImage->GetBufferPointer());
-
- mitk::DataTreeNode::Pointer node = NULL;
- mitk::DataTreeIteratorClone subTree = ((mitk::DataTree *) it->GetTree())->GetNext("name", mitk::StringProperty::New( str.c_str() ));
-
- if (subTree->IsAtEnd() || subTree->Get().IsNull() )
- {
- node=mitk::DataTreeNode::New();
- node->SetData(image);
- mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New(str.c_str());
- node->SetProperty("name",nameProp);
- it->Add(node);
- }
- else
- {
- node = subTree->Get();
- node->SetData(image);
- }
- return node;
- }
-
-
-
- /**
- * \brief converts the itk image to mitk image, creates a datatreenode and adds the node to
- * the referenced datatree
- */
- template < typename TMeshType >
- static void AddItkMeshToDataTree(typename TMeshType::Pointer itkMesh, mitk::DataTreeIteratorBase* iterator, std::string str)
- {
- mitk::DataTreeIteratorClone it=iterator;
-
- mitk::DataTreeNode::Pointer node = NULL;
- mitk::DataTreeIteratorClone subTree = ((mitk::DataTree *) it->GetTree())->GetNext("name", mitk::StringProperty::New( str.c_str() ));
-
- if (subTree->IsAtEnd() || subTree->Get() == NULL )
- {
- node=mitk::DataTreeNode::New();
- mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New(str.c_str());
- node->SetProperty("name",nameProp);
- it->Add(node);
- }
- else
- {
- node = subTree->Get();
- }
-
- mitk::Surface::Pointer surface = mitk::Surface::New();
- // vtkPolyData* polys = MeshUtil<TMeshType>::MeshToPolyData( itkMesh );
- /**
- * @todo include Algorithms/itkMeshDeformation into Framework module so the upper line can be used
- * and the conversion works correctly
- */
- vtkPolyData* polys = vtkPolyData::New();
- surface->SetVtkPolyData(polys);
- node->SetData( surface );
- node->SetProperty("layer", mitk::IntProperty::New(1));
- node->SetVisibility(true,NULL);
-
- float meshColor[3] = {.5f,.5f,.5f};
- node->SetColor(meshColor, NULL );
- node->SetVisibility(true, NULL );
- }
- /**
- * \brief converts the itk image to mitk image, creates a datatreenode and adds the node to
- * the referenced datatree
- */
- QmitkExt_EXPORT mitk::DataTreeNode::Pointer AddVtkMeshToDataTree(vtkPolyData* polys, mitk::DataTreeIteratorBase* iterator, std::string str);
-
- /**
- * \brief creates a datatreenode for th PIC image and adds the node to
- * the referenced datatree
- */
- QmitkExt_EXPORT mitk::DataTreeNode::Pointer AddPicImageToDataTree(mitkIpPicDescriptor * pic, mitk::DataTreeIteratorBase* iterator, std::string str);
-
QmitkExt_EXPORT mitk::DataTreeNode::Pointer FileOpen( const QString& fileName);
QmitkExt_EXPORT mitk::DataTreeNode::Pointer FileOpen( const char *fileName );
QmitkExt_EXPORT mitk::DataTreeNode::Pointer FileOpenSpecific( const QString& fileExtensions);
@@ -238,11 +148,6 @@
QmitkExt_EXPORT void SaveBaseData( mitk::BaseData* data, const char* name = NULL );
- QmitkExt_EXPORT mitk::DataTreeIteratorBase* GetIteratorToFirstImage(mitk::DataTreeIteratorBase* dataTreeIterator);
-
- QmitkExt_EXPORT mitk::DataTreeIteratorBase* GetIteratorToFirstImageInDataTree(mitk::DataTree::Pointer dataTree);
- QmitkExt_EXPORT mitk::Image* GetFirstImageInDataTree(mitk::DataTree::Pointer dataTree);
-
/**
* Checks if the filename is valid for writing. This includes checking whether the file already exists.
* If so, the user is asked whether he wants to overwrite the existing file. In addition, the writing permission is checked.
@@ -250,236 +155,5 @@
* @returns true if the filename is valid for writing
*/
QmitkExt_EXPORT bool IsFilenameValidForWriting(const char* aFileName);
-
-
- /**
- * Searches for the first node in the data tree, which holds a given type.
- * @param it an iterator pointing to the position in the data tree, where
- * the search should start
- * @returns the first node in the data tree which is of the type given by
- * the template parameter T, or NULL otherwise.
- */
- template <typename T>
- static mitk::DataTreeNode* GetFirstNodeByType( mitk::DataTreeIteratorClone it )
- {
- if ( it.GetPointer() == NULL )
- {
- return NULL;
- }
-
- mitk::DataTreeIteratorClone iteratorClone = it;
- while ( !iteratorClone->IsAtEnd() )
- {
- mitk::DataTreeNode::Pointer node = iteratorClone->Get();
- if ( node.IsNull() )
- {
- itkGenericOutputMacro("Iterator points to a node that is NULL!");
- }
- else if ( node->GetData() != NULL )
- {
- // access the original data
- T* data = dynamic_cast<T*>( node->GetData() );
-
- // enquiry whether img is NULL
- if ( data != NULL )
- {
- return node.GetPointer();
- }
- }
- ++iteratorClone;
- }
- return NULL;
- }
-
- /**
- * Searches for the data object in the data tree, which matches a given type.
- * @param it an iterator pointing to the position in the data tree, where
- * the search should start
- * @returns the first data oobject in the data tree which is of the type given by
- * the template parameter T, or NULL otherwise.
- */
- template <typename T>
- static T* GetFirstDataByType( mitk::DataTreeIteratorClone it )
- {
- mitk::DataTreeNode* node = GetFirstNodeByType<T>(it);
- if ( node == NULL )
- {
- return NULL;
- }
- else
- {
- return dynamic_cast<T*>( node->GetData() );
- }
- }
-
- /**
- * Searches for the first node in the data tree, which holds a given type
- * and matches a given property key and value. This may be used to search
- * e.g. for a node holding an image with a given name in the data tree.
- * @param it an iterator pointing to the position in the data tree, where
- * the search should start
- * @param propertyKey the name of the property we want to compare with
- * @param property the value of the property we want to search for in the data tree
- * @returns the first node in the data tree which is of the type given by
- * the template parameter T, and matches propertyKey and property, or NULL otherwise.
- */
- template <typename T>
- static mitk::DataTreeNode* GetFirstNodeByTypeAndProperty( mitk::DataTreeIteratorClone it, std::string propertyKey, mitk::BaseProperty* property )
- {
- if ( it.GetPointer() == NULL )
- {
- return NULL;
- }
-
- mitk::DataTreeIteratorClone iteratorClone = it;
- while ( !iteratorClone->IsAtEnd() )
- {
- mitk::DataTreeNode::Pointer node = iteratorClone->Get();
- if ( node.IsNull() )
- {
- itkGenericOutputMacro("Iterator points to a node that is NULL!");
- }
- else if ( node->GetData() != NULL )
- {
- // access the original data
- T* data = dynamic_cast<T*>( node->GetData() );
-
- // enquiry whether img is NULL
- if ( data != NULL )
- {
- // check, if the data has the given property...
- mitk::BaseProperty::Pointer tmp = node->GetPropertyList()->GetProperty( propertyKey.c_str() );
- if ( (*property) == *(tmp) )
- return node.GetPointer();
- }
- }
- ++iteratorClone;
- }
- return NULL;
- }
-
- /**
- * Searches for the first data object in the data tree, which is of a given type
- * and whose node matches a given property key and value. This may be used to search
- * e.g. for an image with a given name in the data tree.
- * @param it an iterator pointing to the position in the data tree, where
- * the search should start
- * @param propertyKey the name of the property we want to compare with
- * @param property the value of the property we want to search for in the data tree
- * @returns the first data object in the data tree which is of the type given by
- * the template parameter T, and matches propertyKey and property, or NULL otherwise.
- */
- template <typename T>
- static T* GetFirstDataByTypeAndProperty( mitk::DataTreeIteratorClone it, std::string propertyKey, mitk::BaseProperty* property )
- {
- mitk::DataTreeNode* node = GetFirstNodeByTypeAndProperty<T>( it, propertyKey, property );
- if ( node == NULL )
- {
- return NULL;
- }
- else
- {
- return dynamic_cast<T*>( node->GetData() );
- }
- }
-
- /**
- * Searches for the first node in the data tree, which matches a given
- * property key and value. This may be used to search e.g. for a node holding
- * a data object with a given name in the data tree.
- * @param it an iterator pointing to the position in the data tree, where
- * the search should start
- * @param propertyKey the name of the property we want to compare with
- * @param property the value of the property we want to search for in the data tree
- * @returns the first node in the data tree which matches propertyKey and property, or NULL otherwise.
- */
- QmitkExt_EXPORT mitk::DataTreeNode* GetFirstNodeByProperty( mitk::DataTreeIteratorClone it, std::string propertyKey, mitk::BaseProperty* property );
-
- /**
- * Searches for the first data object in the data tree, whose node matches a given
- * property key and value. This may be used to search e.g. for a node holding
- * a data object with a given name in the data tree.
- * @param it an iterator pointing to the position in the data tree, where
- * the search should start
- * @param propertyKey the name of the property we want to compare with
- * @param property the value of the property we want to search for in the data tree
- * @returns the first data object in the data tree whose node matches propertyKey and property, or NULL otherwise.
- */
- QmitkExt_EXPORT mitk::BaseData* GetFirstDataByProperty( mitk::DataTreeIteratorClone it, std::string propertyKey, mitk::BaseProperty* property );
- /**
- * Searches for the node in the data tree which holds a given mitk::BaseData
- * @param it an iterator pointing to the position in the data tree, where
- * the search should start
- * @param data the data object, for which the node in the tree should be searched.
- * @returns the node holding data, or NULL otherwise.
- */
- QmitkExt_EXPORT mitk::DataTreeNode* GetNodeForData( mitk::DataTreeIteratorClone it, mitk::BaseData* data );
-
- template <typename BaseDataType>
- static DataTreeNodeVector GetNodesForDataType(mitk::DataTreeIteratorClone it)
- {
- DataTreeNodeVector result;
-
- if ( it.GetPointer() != NULL )
- {
-
- mitk::DataTreeIteratorClone iteratorClone = it->Clone();
- while ( !iteratorClone->IsAtEnd() )
- {
- mitk::DataTreeNode::Pointer node = iteratorClone->Get();
- if ( dynamic_cast<BaseDataType*>( node->GetData() ) )
- {
- result.push_back(node);
- }
- ++iteratorClone;
- }
- }
- return result;
-
- }
-
- /**
- * Counts the number of nodes of a given type in a data tree. This
- * can for example be used to calculate the number of point sets in
- * the data tree.
- * @param it an iterator pointing to the position in the data tree, where
- * the search should start
- * @returns the number of nodes holding a data element of the given template
- * parameter
- */
- template <typename T>
- static unsigned int GetNumberOfNodesOfType( mitk::DataTreeIteratorClone it )
- {
- if ( it.GetPointer() == NULL )
- {
- return 0;
- }
- unsigned int numberOfNodes = 0;
- mitk::DataTreeIteratorClone iteratorClone = it;
- while ( !iteratorClone->IsAtEnd() )
- {
- mitk::DataTreeNode::Pointer node = iteratorClone->Get();
- if ( node.IsNotNull() )
- {
- if ( node->GetData() != NULL )
- {
- // access the original data
- T* data = dynamic_cast<T*>( node->GetData() );
-
- // enquiry whether data is NULL or not, that is
- // if the data is of type T
- if ( data != NULL )
- {
- numberOfNodes++;
- }
- }
- }
- ++iteratorClone;
- }
- return numberOfNodes;
- }
-
-
- QmitkExt_EXPORT DataTreeIteratorVector FilterNodes(mitk::DataTreeIteratorClone it, bool (* FilterFunction)(mitk::DataTreeNode*));
};
#endif // _CommonFunctionality__h_

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
436
Default Alt Text
patch-3293.diff (64 KB)

Event Timeline

Patch with changes to remove DataTree