Page MenuHomePhabricator

SceneReader.patch

Authored By
wald
Jan 27 2010, 5:18 PM
Size
6 KB
Referenced Files
None
Subscribers
None

SceneReader.patch

Index: Core/Code/files.cmake
===================================================================
--- Core/Code/files.cmake (revision 21094)
+++ Core/Code/files.cmake (working copy)
@@ -3,6 +3,7 @@
Algorithms/itkLocalVariationImageFilter.h
Algorithms/itkTotalVariationDenoisingImageFilter.h
Algorithms/itkTotalVariationSingleIterationImageFilter.h
+ IO/mitkSceneReader.h
)
SET(CPP_FILES
Index: Core/Code/IO/mitkSceneReader.h
===================================================================
--- Core/Code/IO/mitkSceneReader.h (revision 0)
+++ Core/Code/IO/mitkSceneReader.h (revision 0)
@@ -0,0 +1,66 @@
+/*=========================================================================
+
+Program: Medical Imaging & Interaction Toolkit
+Language: C++
+Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $
+Version: $Revision: 17179 $
+
+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 SceneReader_H_HEADER_INCLUDED_C1E7E521
+#define SceneReader_H_HEADER_INCLUDED_C1E7E521
+
+#include "mitkCommon.h"
+#include "mitkDataStorage.h"
+
+namespace mitk {
+
+//##Documentation
+//## @brief Interface class of scene readers that read from files
+//## @ingroup Process
+class MITK_CORE_EXPORT SceneReader : public itk::Object
+{
+ public:
+
+ mitkClassMacro(SceneReader,itk::Object);
+
+ //##Documentation
+ //## @brief Returns if the SceneReader is able to load the given file
+ //##
+ //##
+ //##
+ virtual bool CanReadScene(const char* fileName) const = 0;
+
+ //##Documentation
+ //## @brief Loads the content of the scene file to the data storage
+ //##
+ //##
+ //##
+ virtual void AddSceneFileContentToDataStorage(const char* fileName, DataStorage* dataStorage) = 0;
+
+ //##Documentation
+ //## @brief Returns the possible file extensions
+ //##
+ virtual const char* GetFileExtension() const = 0;
+
+protected:
+ SceneReader(){}
+
+ virtual ~SceneReader(){}
+public:
+
+protected:
+};
+} // namespace mitk
+#endif /* SceneReader_H_HEADER_INCLUDED_C1E7E521 */
+
+
Property changes on: Core\Code\IO\mitkSceneReader.h
___________________________________________________________________
Added: svn:eol-style
+ native
Index: Modules/SceneSerialization/mitkSceneIO.cpp
===================================================================
--- Modules/SceneSerialization/mitkSceneIO.cpp (revision 21094)
+++ Modules/SceneSerialization/mitkSceneIO.cpp (working copy)
@@ -72,6 +72,35 @@
return uniquename;
}
+bool mitk::SceneIO::CanReadScene( const char* fileName )
+{
+ // test input filename
+ if ( fileName.empty() )
+ {
+ return false;
+ }
+
+ // test if filename can be read
+ std::ifstream file( fileName.c_str(), std::ios::binary );
+ if (!file.good())
+ {
+ return false;
+ }
+ return true;
+}
+
+const char* mitk::SceneIO::GetFileExtension()
+{
+ return ".mitk";
+}
+
+void mitk::SceneIO::AddSceneFileContentToDataStorage(const char* fileName, DataStorage* dataStorage)
+{
+ std::stringstream ss;
+ ss << fileName;
+ LoadScene( ss.str(), dataStorage, false );
+}
+
mitk::DataStorage::Pointer mitk::SceneIO::LoadScene( const std::string& filename,
DataStorage* pStorage,
bool clearStorageFirst )
Index: Modules/SceneSerialization/mitkSceneIO.h
===================================================================
--- Modules/SceneSerialization/mitkSceneIO.h (revision 21094)
+++ Modules/SceneSerialization/mitkSceneIO.h (working copy)
@@ -34,7 +34,7 @@
class BaseData;
class PropertyList;
-class SceneSerialization_EXPORT SceneIO : public itk::Object
+class SceneSerialization_EXPORT SceneIO : public SceneReader, public itk::Object
{
public:
@@ -43,21 +43,26 @@
typedef DataStorage::SetOfObjects FailedBaseDataListType;
- /**
- * \brief Load a scene of objects from file
- * \return DataStorage with all scene objects and their relations. If loading failed, query GetFailedNodes() and GetFailedProperties() for more detail.
- *
- * Attempts to read the provided file and create objects with
- * parent/child relations into a DataStorage.
- *
- * \param filename full filename of the scene file
- * \param storage If given, this DataStorage is used instead of a newly created one
- * \param clearStorageFirst If set, the provided DataStorage will be cleared before populating it with the loaded objects
- */
- virtual DataStorage::Pointer LoadScene( const std::string& filename,
- DataStorage* storage = NULL,
- bool clearStorageFirst = false );
+ //##Documentation
+ //## @brief Returns if the SceneReader is able to load the given file
+ //##
+ //##
+ //##
+ virtual bool CanReadScene(const char* fileName);
+
+ //##Documentation
+ //## @brief Loads the content of the scene file to the data storage
+ //##
+ //## Internally calls the method LoadScene
+ //##
+ virtual void AddSceneFileContentToDataStorage(const char* fileName, DataStorage* dataStorage);
+
+ //##Documentation
+ //## @brief Returns the possible file extension
+ //##
+ virtual const char* GetFileExtension();
+
/**
* \brief Save a scene of objects to file
* \return True if complete success, false if any problem occurred. Note that a scene file might still be written if false is returned,
@@ -99,6 +104,21 @@
SceneIO();
virtual ~SceneIO();
+ /**
+ * \brief Load a scene of objects from file
+ * \return DataStorage with all scene objects and their relations. If loading failed, query GetFailedNodes() and GetFailedProperties() for more detail.
+ *
+ * Attempts to read the provided file and create objects with
+ * parent/child relations into a DataStorage.
+ *
+ * \param filename full filename of the scene file
+ * \param storage If given, this DataStorage is used instead of a newly created one
+ * \param clearStorageFirst If set, the provided DataStorage will be cleared before populating it with the loaded objects
+ */
+ virtual DataStorage::Pointer LoadScene( const std::string& filename,
+ DataStorage* storage = NULL,
+ bool clearStorageFirst = false );
+
std::string CreateEmptyTempDirectory();
TiXmlElement* SaveBaseData( BaseData* data, const std::string& filenamehint, bool& error);

File Metadata

Mime Type
application/octet-stream
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
370
Default Alt Text
SceneReader.patch (6 KB)

Event Timeline

first adaption of the SceneIO SceneReader mechanism