Commit 45d85c6f authored by Romain Garrigues's avatar Romain Garrigues
Browse files

Ajout du répertoire ITK dans Utilities

parent e2edf4e2
# The DICOMParser Library is intended to be included in other
# projects. The library's namespace and library name can be
# configured.
# Typical usage is to import the DICOMParser directory tree into a
# subdirectory under a parent project and enable the library be used.
# The CMake listfile above this one configures the library as follows:
#
# SET(DICOMPARSER_NAMESPACE foodicomparser)
# SET(DICOMPARSER_LIBRARY foodicomparser)
# SUBDIRS(DICOMParser)
#
#-----------------------------------------------------------------------------
# If a namespace is not specified, use "dicomparser". This should be
# the case only when dicom is not included inside another project
#
IF(NOT DICOMPARSER_NAMESPACE)
SET(DICOMPARSER_NAMESPACE dicomparser)
SET(DICOMPARSER_LIBRARY dicomparser)
SET(DICOMPARSER_STANDALONE 1)
ENDIF(NOT DICOMPARSER_NAMESPACE)
#-----------------------------------------------------------------------------
# The project name is that of the specified namespace.
PROJECT(${DICOMPARSER_NAMESPACE})
# Put the binary tree first in the include path to protect against
# when people accidently configure in their source tree
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
IF(WIN32)
IF(BUILD_SHARED_LIBS)
SET(DICOM_DLL 1)
ELSE(BUILD_SHARED_LIBS)
SET(DICOM_STATIC 1)
ENDIF(BUILD_SHARED_LIBS)
ENDIF(WIN32)
IF(ITK_SOURCE_DIR)
# Inside ITK, use its setting.
SET(DICOM_ANSI_STDLIB 1)
ELSE(ITK_SOURCE_DIR)
# Not inside ITK, use ANSI streams.
SET(DICOM_ANSI_STDLIB 1)
ENDIF(ITK_SOURCE_DIR)
INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)
SET(DICOM_NO_STD_NAMESPACE ${CMAKE_NO_STD_NAMESPACE})
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/DICOMCMakeConfig.h.in
${PROJECT_BINARY_DIR}/DICOMCMakeConfig.h)
ADD_LIBRARY(${DICOMPARSER_LIBRARY} DICOMSource.cxx DICOMBuffer.cxx DICOMFile.cxx DICOMParser.cxx DICOMAppHelper.cxx)
INSTALL_TARGETS(/lib/InsightToolkit ${DICOMPARSER_LIBRARY})
INSTALL_FILES(/include/InsightToolkit "(\\.h|\\.txx)$")
INSTALL_FILES(/include/InsightToolkit FILES
${PROJECT_BINARY_DIR}/DICOMCMakeConfig.h)
/*=========================================================================
Program: DICOMParser
Module: $RCSfile: Copyright.txt,v $
Language: C++
Date: $Date: 2003/10/23 17:42:13 $
Version: $Revision: 1.1 $
Copyright (c) 2003 Matt Turek
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of Matt Turek nor the names of any contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
This diff is collapsed.
This diff is collapsed.
/*=========================================================================
Program: DICOMParser
Module: $RCSfile: DICOMBuffer.cxx,v $
Language: C++
Date: $Date: 2004/03/21 21:40:03 $
Version: $Revision: 1.2 $
Copyright (c) 2003 Matt Turek
All rights reserved.
See Copyright.txt 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 notice for more information.
=========================================================================*/
#ifdef _MSC_VER
#pragma warning ( disable : 4514 )
#pragma warning ( disable : 4710 )
#pragma warning ( push, 3 )
#endif
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include "DICOMConfig.h"
#include "DICOMBuffer.h"
namespace DICOMPARSER_NAMESPACE
{
DICOMBuffer::DICOMBuffer(unsigned char *buffer, long length)
: DICOMSource(),
Buffer(buffer),
Length(length),
Position(0)
{
}
DICOMBuffer::~DICOMBuffer()
{
}
DICOMBuffer::DICOMBuffer(const DICOMBuffer& in)
: DICOMSource(in)
{
Buffer = in.Buffer;
Length = in.Length;
Position = in.Position;
}
void DICOMBuffer::operator=(const DICOMBuffer& in)
{
DICOMSource::operator=(in);
Buffer = in.Buffer;
Length = in.Length;
Position = in.Position;
}
long DICOMBuffer::Tell()
{
return Position;
}
void DICOMBuffer::SkipToPos(long increment)
{
Position = increment;
}
long DICOMBuffer::GetSize()
{
return Length;
}
void DICOMBuffer::Skip(long increment)
{
Position += increment;
}
void DICOMBuffer::SkipToStart()
{
Position = 0;
}
void DICOMBuffer::Read(void* ptr, long nbytes)
{
memcpy(ptr, Buffer+Position, nbytes);
Position += nbytes;
}
}
#ifdef _MSC_VER
#pragma warning ( pop )
#endif
/*=========================================================================
Program: DICOMParser
Module: $RCSfile: DICOMBuffer.h,v $
Language: C++
Date: $Date: 2004/03/21 21:40:03 $
Version: $Revision: 1.2 $
Copyright (c) 2003 Matt Turek
All rights reserved.
See Copyright.txt 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 notice for more information.
=========================================================================*/
#ifndef __DICOMBUFFER_H_
#define __DICOMBUFFER_H_
#ifdef _MSC_VER
#pragma warning ( disable : 4514 )
#pragma warning ( push, 3 )
#endif
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include "DICOMTypes.h"
#include "DICOMConfig.h"
#include "DICOMSource.h"
namespace DICOMPARSER_NAMESPACE
{
//
// DICOM data source that is a memory buffer.
//
class DICOM_EXPORT DICOMBuffer : public DICOMSource
{
public:
DICOMBuffer(unsigned char *buffer, long length);
virtual ~DICOMBuffer();
//
// Return the position in the buffer.
//
long Tell();
//
// Move to a particular position in the buffer.
//
void SkipToPos(long);
//
// Return the size of the buffer.
//
long GetSize();
//
// Skip a number of bytes.
//
void Skip(long);
//
// Skip to the beginning of the buffer.
//
void SkipToStart();
//
// Read data of length len.
//
void Read(void* data, long len);
protected:
DICOMBuffer(const DICOMBuffer&);
void operator=(const DICOMBuffer&);
unsigned char *Buffer;
long Length;
long Position;
private:
DICOMBuffer();
};
}
#ifdef _MSC_VER
#pragma warning ( pop )
#endif
#endif // __DICOMBUFFER_H_
#ifndef __DICOMCMakeConfig_h_
#define __DICOMCMakeConfig_h_
#cmakedefine DICOM_DLL
#cmakedefine DICOM_STATIC
#cmakedefine DICOM_ANSI_STDLIB
#cmakedefine DICOM_NO_STD_NAMESPACE
#define DICOMPARSER_NAMESPACE @DICOMPARSER_NAMESPACE@
#endif
/*=========================================================================
Program: DICOMParser
Module: $RCSfile: DICOMCallback.h,v $
Language: C++
Date: $Date: 2005/05/13 19:44:21 $
Version: $Revision: 1.7 $
Copyright (c) 2003 Matt Turek
All rights reserved.
See Copyright.txt 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 notice for more information.
=========================================================================*/
#ifndef __DICOM_CALLBACK_H_
#define __DICOM_CALLBACK_H_
#ifdef _MSC_VER
#pragma warning ( disable : 4514 )
#pragma warning ( disable : 4786 )
#pragma warning ( disable : 4503 )
#pragma warning ( disable : 4710 )
#pragma warning ( disable : 4702 )
#pragma warning ( push, 3 )
#endif
#include "DICOMConfig.h"
#include "DICOMParser.h"
namespace DICOMPARSER_NAMESPACE
{
//
// Pure virtual class that specifies the interface
// for a DICOMCallback.
//
// The DICOMParser allows a vector of callbacks to
// be specified for each group element tag. When
// a group, element with a registered callback is
// encountered, the callback is called and passed
// the group, element, type, data, and data length.
//
class DICOM_EXPORT DICOMCallback
{
public:
virtual void Execute(DICOMParser *parser,
doublebyte group,
doublebyte element,
DICOMParser::VRTypes type,
unsigned char* val,
quadbyte len) = 0;
virtual ~DICOMCallback() {}
};
//
// Subclass of DICOMCallback which can be used
// with member functions.
//
template <class T>
class DICOMMemberCallback : public DICOMCallback
{
public:
typedef void (T::*TMemberFunctionPointer)(DICOMParser *parser,
doublebyte group,
doublebyte element,
DICOMParser::VRTypes type,
unsigned char* val,
quadbyte len);
//
// Method to set the object and member function pointers
// that will be called in the callback.
//
void SetCallbackFunction(T* object,
TMemberFunctionPointer memberFunction)
{
ObjectThis = object;
MemberFunction = memberFunction;
}
//
// Execute method implementation from DICOMCallback.
//
void Execute(DICOMParser *parser,
doublebyte group,
doublebyte element,
DICOMParser::VRTypes type,
unsigned char* val,
quadbyte len)
{
if (MemberFunction)
{
((*ObjectThis).*(MemberFunction))(parser, group, element, type, val,len);
}
}
protected:
T* ObjectThis;
TMemberFunctionPointer MemberFunction;
};
}
#ifdef _MSC_VER
#pragma warning ( pop )
#endif
#endif
/*=========================================================================
Program: DICOMParser
Module: $RCSfile: DICOMConfig.h,v $
Language: C++
Date: $Date: 2004/03/22 15:25:59 $
Version: $Revision: 1.4 $
Copyright (c) 2003 Matt Turek
All rights reserved.
See Copyright.txt 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 notice for more information.
=========================================================================*/
#ifndef __DICOM_CONFIG_H_
#define __DICOM_CONFIG_H_
//
// CMake Hook
//
#include "DICOMCMakeConfig.h"
//
// BEGIN Toolkit (ITK,VTK, etc) specific
//
#ifdef vtkDICOMParser_EXPORTS
#define DICOM_EXPORT_SYMBOLS
#endif
#ifdef ITKDICOMParser_EXPORTS
#define DICOM_EXPORT_SYMBOLS
#endif
//
// END toolkit (ITK, VTK, etc) specific
//
#ifdef DICOM_NO_STD_NAMESPACE
#define dicom_stl
#else
#define dicom_stl std
#endif
#ifdef DICOM_ANSI_STDLIB
#define dicom_stream std
#include <iostream>
#include <fstream>
#include <iomanip>
#else
#define dicom_stream
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#endif
#ifdef DICOM_DLL
#ifdef DICOM_EXPORT_SYMBOLS
#define DICOM_EXPORT __declspec(dllexport)
#define DICOM_EXPIMP_TEMPLATE
#else
#define DICOM_EXPORT __declspec(dllimport)
#define DICOM_EXPIMP_TEMPLATE extern
#endif
#else
#define DICOM_EXPORT
#endif
#endif // __DICOM_CONFIG_H_
/*=========================================================================
Program: DICOMParser
Module: $RCSfile: DICOMFile.cxx,v $
Language: C++
Date: $Date: 2004/03/21 21:40:03 $
Version: $Revision: 1.20 $
Copyright (c) 2003 Matt Turek
All rights reserved.
See Copyright.txt 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 notice for more information.
=========================================================================*/
#ifdef _MSC_VER
#pragma warning ( disable : 4514 )
#pragma warning ( disable : 4710 )
#pragma warning ( push, 3 )
#endif
#include <stdio.h>
#include <string>
#include "DICOMConfig.h"
#include "DICOMFile.h"
namespace DICOMPARSER_NAMESPACE
{
DICOMFile::DICOMFile() : DICOMSource(), InputStream()
{
}
DICOMFile::~DICOMFile()
{
this->Close();
}
DICOMFile::DICOMFile(const DICOMFile& in)
: DICOMSource(in)
{
//
// Some compilers can't handle. Comment out for now.
//
// InputStream = in.InputStream;
}
void DICOMFile::operator=(const DICOMFile& in)
{
DICOMSource::operator=(in);
//
// Some compilers can't handle. Comment out for now.
//
// InputStream = in.InputStream;
}
bool DICOMFile::Open(const dicom_stl::string& filename)
{
#ifdef _WIN32
InputStream.open(filename.c_str(), dicom_stream::ios::binary | dicom_stream::ios::in);
#else
InputStream.open(filename.c_str(), dicom_stream::ios::in);
#endif
//if (InputStream.is_open())
if (InputStream.rdbuf()->is_open())
{
return true;
}
else
{
return false;
}
}
void DICOMFile::Close()
{
InputStream.close();
}
long DICOMFile::Tell()
{
long loc = InputStream.tellg();
// dicom_stream::cout << "Tell: " << loc << dicom_stream::endl;
return loc;
}
void DICOMFile::SkipToPos(long increment)
{
InputStream.seekg(increment, dicom_stream::ios::beg);
}
long DICOMFile::GetSize()
{
long curpos = this->Tell();
InputStream.seekg(0,dicom_stream::ios::end);
long size = this->Tell();
// dicom_stream::cout << "Tell says size is: " << size << dicom_stream::endl;
this->SkipToPos(curpos);
return size;