mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
Removed dependencies from Core lib
This commit is contained in:
@@ -56,7 +56,6 @@ include(uLibConfigHeader)
|
|||||||
set(ULIB_SELECTED_MODULES
|
set(ULIB_SELECTED_MODULES
|
||||||
Core
|
Core
|
||||||
Math
|
Math
|
||||||
Root
|
|
||||||
Detectors
|
Detectors
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -91,75 +90,10 @@ foreach(module ${ULIB_SELECTED_MODULES})
|
|||||||
add_subdirectory(${SRC_DIR}/${module})
|
add_subdirectory(${SRC_DIR}/${module})
|
||||||
endforeach(module)
|
endforeach(module)
|
||||||
|
|
||||||
## SINGLE LIBRARY LINKING ## (work in progress ... )
|
|
||||||
option(ULIB_SINGLELIBRARY "Link everything to a single library" OFF)
|
|
||||||
if(ULIB_SINGLELIBRARY)
|
|
||||||
# set(modgrp)
|
|
||||||
# foreach(module ${ULIB_SELECTED_MODULES})
|
|
||||||
# set(grpn srcgrp_${module})
|
|
||||||
# list(APPEND modgrp ${grpn})
|
|
||||||
# endforeach(module)
|
|
||||||
# add_library(${project_name} SHARED ${srcgrp_Core})
|
|
||||||
endif(ULIB_SINGLELIBRARY)
|
|
||||||
|
|
||||||
## UTILITIES ##
|
## UTILITIES ##
|
||||||
add_subdirectory("${SRC_DIR}/utils/make_recipe")
|
add_subdirectory("${SRC_DIR}/utils/make_recipe")
|
||||||
|
|
||||||
|
|
||||||
## PKG CONFIG compatible file ----------------------------------------------- ##
|
|
||||||
|
|
||||||
set(PKGCONFIG_FILE_ENABLE OFF CACHE BOOL "enable pkg-config file")
|
|
||||||
if(PKGCONFIG_FILE_ENABLE)
|
|
||||||
message("/////////// PKG-CONFIG DISTILLER //////////////")
|
|
||||||
set(PKGCONFIG_FILE_DESTDIR "/lib/pkgconfig/" CACHE PATH "destination path for pkg-config file")
|
|
||||||
set(PKGCONFIG_LIBS)
|
|
||||||
|
|
||||||
message(STATUS "[cflags] ${CMAKE_C_FLAGS}")
|
|
||||||
message(STATUS "[cxxflags] ${CMAKE_CXX_FLAGS}")
|
|
||||||
|
|
||||||
foreach(module ${ULIB_SHARED_LIBRARIES})
|
|
||||||
set(PKGCONFIG_LIBS "${PKGCONFIG_LIBS} ${CMAKE_LINK_LIBRARY_FLAG}${module}")
|
|
||||||
endforeach(module)
|
|
||||||
message(STATUS "[libs] ${PKGCONFIG_LIBS}")
|
|
||||||
|
|
||||||
set(PKGCONFIG_FLAGS)
|
|
||||||
#add_custom_target(Dummy)
|
|
||||||
|
|
||||||
# add the executable
|
|
||||||
uLib_add_target(Dummy test.cpp)
|
|
||||||
target_link_libraries(Dummy ${PACKAGE_LIBPREFIX}Core)
|
|
||||||
target_link_libraries(Dummy ${Boost_SERIALIZATION_LIBRARY})
|
|
||||||
target_link_libraries(Dummy ${Boost_SIGNALS_LIBRARY})
|
|
||||||
target_link_libraries(Dummy ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
||||||
target_link_libraries(Dummy ${Geant4_LIBRARIES})
|
|
||||||
target_link_libraries(Dummy ${ROOT_LIBRARIES})
|
|
||||||
target_link_libraries(Dummy ${VTK_LIBRARIES})
|
|
||||||
|
|
||||||
get_gcc_compile_flags(Dummy, gcc_flags_list)
|
|
||||||
foreach(item ${gcc_flags_list})
|
|
||||||
message(STATUS "[gcc cflags] ${item}")
|
|
||||||
set(PKGCONFIG_FLAGS "${PKGCONFIG_FLAGS} ${item}")
|
|
||||||
endforeach(item)
|
|
||||||
message(STATUS "[includes] ${PKGCONFIG_FLAGS}")
|
|
||||||
|
|
||||||
get_gcc_link_flags(Dummy, gcc_flags_list)
|
|
||||||
foreach(item ${gcc_flags_list})
|
|
||||||
message(STATUS "[gcc libs] ${item}")
|
|
||||||
endforeach(item)
|
|
||||||
|
|
||||||
configure_file(
|
|
||||||
"${PROJECT_SOURCE_DIR}/CMakePkgConfig.pc.in"
|
|
||||||
"${PROJECT_BINARY_DIR}/libmutom-${PACKAGE_VERSION}.pc"
|
|
||||||
)
|
|
||||||
INSTALL_FILES(${PKGCONFIG_FILE_DESTDIR} FILES ${PROJECT_BINARY_DIR}/libmutom-${PACKAGE_VERSION}.pc)
|
|
||||||
|
|
||||||
message("///////////////////////////////////////////")
|
|
||||||
endif(PKGCONFIG_FILE_ENABLE)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## INSTALLS AND EXPORTS ----------------------------------------------------- ##
|
## INSTALLS AND EXPORTS ----------------------------------------------------- ##
|
||||||
|
|
||||||
#export(PACKAGE uLib)
|
#export(PACKAGE uLib)
|
||||||
@@ -187,12 +121,9 @@ configure_file(uLibConfigVersion.cmake.in
|
|||||||
|
|
||||||
install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/uLibConfig.cmake"
|
install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/uLibConfig.cmake"
|
||||||
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake"
|
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake"
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/FindEigen3.cmake"
|
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/FindReadLine.cmake"
|
"${PROJECT_SOURCE_DIR}/CMake/FindReadLine.cmake"
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/FindROOT.cmake"
|
"${PROJECT_SOURCE_DIR}/CMake/FindROOT.cmake"
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/FindROOTv6.cmake"
|
"${PROJECT_SOURCE_DIR}/CMake/FindROOTv6.cmake"
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/FinduLib.cmake"
|
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/FindVTK.cmake"
|
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/uLibCommon.cmake"
|
"${PROJECT_SOURCE_DIR}/CMake/uLibCommon.cmake"
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/uLibConfigHeader.cmake"
|
"${PROJECT_SOURCE_DIR}/CMake/uLibConfigHeader.cmake"
|
||||||
"${PROJECT_SOURCE_DIR}/CMake/uLibDebugMacro.cmake"
|
"${PROJECT_SOURCE_DIR}/CMake/uLibDebugMacro.cmake"
|
||||||
|
|||||||
@@ -29,13 +29,11 @@
|
|||||||
|
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/type_traits.hpp>
|
#include <boost/type_traits.hpp>
|
||||||
//#include <Core/CommaInitializer.h>
|
|
||||||
#include <Math/Dense.h>
|
|
||||||
|
|
||||||
#include <Core/Mpl.h>
|
|
||||||
#include <boost/mpl/vector_c.hpp>
|
#include <boost/mpl/vector_c.hpp>
|
||||||
#include <boost/mpl/set_c.hpp>
|
#include <boost/mpl/set_c.hpp>
|
||||||
|
|
||||||
|
#include <Math/Dense.h>
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Dense.h"
|
#include "Dense.h"
|
||||||
#include "Core/Archives.h"
|
|
||||||
|
|
||||||
|
#ifdef ULIB_SERIALIZATION_ON
|
||||||
ULIB_SERIALIZE(uLib::HPoint3f) {
|
ULIB_SERIALIZE(uLib::HPoint3f) {
|
||||||
ar & boost::serialization::make_nvp(NULL,boost::serialization::base_object<uLib::HPoint3f::BaseClass,uLib::HPoint3f>(ob));
|
ar & boost::serialization::make_nvp(NULL,boost::serialization::base_object<uLib::HPoint3f::BaseClass,uLib::HPoint3f>(ob));
|
||||||
}
|
}
|
||||||
@@ -48,5 +48,5 @@ ULIB_SERIALIZE(uLib::HError3f) {
|
|||||||
ar
|
ar
|
||||||
& "HLine -> ( poserr: " & AR(position_error) & "; direrr: " & AR(direction_error) & ") ";
|
& "HLine -> ( poserr: " & AR(position_error) & "; direrr: " & AR(direction_error) & ") ";
|
||||||
}
|
}
|
||||||
|
#endif // ULIB_SERIALIZATION_ON
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Eigen/Dense>
|
#include <Eigen/Dense>
|
||||||
#include "Core/Types.h"
|
|
||||||
#include "Core/Serializable.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// BOOST SERIALIZATION ///////////////////////////////////////////////////////
|
//// BOOST SERIALIZATION ///////////////////////////////////////////////////////
|
||||||
@@ -109,6 +106,7 @@ std::ostream & operator << (std::ostream &os, const Eigen::Matrix<T,size,1> &vec
|
|||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
typedef id_t Id_t;
|
||||||
|
|
||||||
typedef int Scalari;
|
typedef int Scalari;
|
||||||
typedef unsigned int Scalarui;
|
typedef unsigned int Scalarui;
|
||||||
@@ -264,6 +262,9 @@ operator<< (std::ostream& stream, const HError3f &err) {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// SERIALIZTION //
|
// SERIALIZTION //
|
||||||
|
|
||||||
|
#ifdef ULIB_SERIALIZATION_ON
|
||||||
|
#include "Core/Serializable.h"
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(uLib::HPoint3f)
|
ULIB_SERIALIZABLE(uLib::HPoint3f)
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(uLib::HVector3f)
|
ULIB_SERIALIZABLE(uLib::HVector3f)
|
||||||
@@ -272,7 +273,7 @@ ULIB_SERIALIZABLE(uLib::HVector3f)
|
|||||||
ULIB_SERIALIZABLE(uLib::HLine3f)
|
ULIB_SERIALIZABLE(uLib::HLine3f)
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(uLib::HError3f)
|
ULIB_SERIALIZABLE(uLib::HError3f)
|
||||||
|
#endif // ULIB_SERIALIZATION_ON
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#ifndef U_GEOMETRY_H
|
#ifndef U_GEOMETRY_H
|
||||||
#define U_GEOMETRY_H
|
#define U_GEOMETRY_H
|
||||||
|
|
||||||
#include "Core/Object.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
#include "Math/Transform.h"
|
#include "Math/Transform.h"
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,11 @@
|
|||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
class Quote : public Vector2f {
|
class Quote : public Vector2f
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
inline Scalarf& Offset() { return this->m_Offset; }
|
||||||
uLibRefMacro(Offset,Scalarf);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Scalarf m_Offset;
|
Scalarf m_Offset;
|
||||||
|
|||||||
@@ -28,14 +28,12 @@
|
|||||||
#ifndef STRUCTUREDDATA_H
|
#ifndef STRUCTUREDDATA_H
|
||||||
#define STRUCTUREDDATA_H
|
#define STRUCTUREDDATA_H
|
||||||
|
|
||||||
#include "Core/Object.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
class StructuredData : public Object {
|
class StructuredData {
|
||||||
public:
|
public:
|
||||||
typedef Object BaseClass;
|
|
||||||
enum _Order
|
enum _Order
|
||||||
{
|
{
|
||||||
CustomOrder = 0,
|
CustomOrder = 0,
|
||||||
@@ -52,7 +50,6 @@ public:
|
|||||||
StructuredData(const Vector3i &size);
|
StructuredData(const Vector3i &size);
|
||||||
|
|
||||||
StructuredData(const StructuredData ©) :
|
StructuredData(const StructuredData ©) :
|
||||||
BaseClass(copy),
|
|
||||||
m_DataOrder(copy.m_DataOrder),
|
m_DataOrder(copy.m_DataOrder),
|
||||||
m_Dims(copy.m_Dims),
|
m_Dims(copy.m_Dims),
|
||||||
m_Increments(copy.m_Increments)
|
m_Increments(copy.m_Increments)
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#ifndef U_MATH_STRUCTUREDGRID_H
|
#ifndef U_MATH_STRUCTUREDGRID_H
|
||||||
#define U_MATH_STRUCTUREDGRID_H
|
#define U_MATH_STRUCTUREDGRID_H
|
||||||
|
|
||||||
#include "Core/Object.h"
|
|
||||||
#include "Math/ContainerBox.h"
|
#include "Math/ContainerBox.h"
|
||||||
#include "Math/StructuredData.h"
|
#include "Math/StructuredData.h"
|
||||||
|
|
||||||
|
|||||||
@@ -30,13 +30,12 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Core/Object.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
class TriangleMesh : public Object {
|
class TriangleMesh
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
void PrintSelf(std::ostream &o);
|
void PrintSelf(std::ostream &o);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#define VOXIMAGEFILTER_H
|
#define VOXIMAGEFILTER_H
|
||||||
|
|
||||||
#include "Core/StaticInterface.h"
|
#include "Core/StaticInterface.h"
|
||||||
#include "Core/Object.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
#include "Math/VoxImage.h"
|
#include "Math/VoxImage.h"
|
||||||
@@ -64,7 +63,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
template < typename VoxelT, typename AlgorithmT >
|
template < typename VoxelT, typename AlgorithmT >
|
||||||
class VoxImageFilter : public Abstract::VoxImageFilter, public Object
|
class VoxImageFilter : public Abstract::VoxImageFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#ifndef VOXIMAGEFILTERCUSTOM_HPP
|
#ifndef VOXIMAGEFILTERCUSTOM_HPP
|
||||||
#define VOXIMAGEFILTERCUSTOM_HPP
|
#define VOXIMAGEFILTERCUSTOM_HPP
|
||||||
|
|
||||||
|
#include "Core/Macros.h"
|
||||||
#include <Math/Dense.h>
|
#include <Math/Dense.h>
|
||||||
#include "Math/VoxImage.h"
|
#include "Math/VoxImage.h"
|
||||||
#include "VoxImageFilter.h"
|
#include "VoxImageFilter.h"
|
||||||
@@ -76,7 +77,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uLibSetMacro(CustomEvaluate,FunctionPt)
|
inline void SetCustomEvaluate(FunctionPt funPt) { this->m_CustomEvaluate = funPt; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FunctionPt m_CustomEvaluate;
|
FunctionPt m_CustomEvaluate;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "Core/Vector.h"
|
|
||||||
#include "Dense.h"
|
#include "Dense.h"
|
||||||
#include "VoxImage.h"
|
#include "VoxImage.h"
|
||||||
#include "VoxImageFilterUser.h"
|
#include "VoxImageFilterUser.h"
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "VoxRaytracer.h"
|
#include "VoxRaytracer.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
#include "Core/Macros.h"
|
||||||
|
|
||||||
inline float fast_sign(float f) { return 1 - 2 * (f < 0); }
|
inline float fast_sign(float f) { return 1 - 2 * (f < 0); }
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ public:
|
|||||||
|
|
||||||
void AppendRay ( const RayData &in);
|
void AppendRay ( const RayData &in);
|
||||||
|
|
||||||
uLibConstRefMacro(Data,std::vector<Element>)
|
inline const std::vector<Element>& Data() const { return this->m_Data; }
|
||||||
uLibConstRefMacro(TotalLength,Scalarf)
|
|
||||||
|
inline const Scalarf& TotalLength() const { return this->m_TotalLength; }
|
||||||
|
|
||||||
void PrintSelf(std::ostream &o);
|
void PrintSelf(std::ostream &o);
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ int main()
|
|||||||
TEST1( pt == HPoint3f(-3,-3,-3) );
|
TEST1( pt == HPoint3f(-3,-3,-3) );
|
||||||
|
|
||||||
Raytracer::RayData rdata = ray.TraceBetweenPoints(HPoint3f(-3,-3,-3), HPoint3f(3,3,3));
|
Raytracer::RayData rdata = ray.TraceBetweenPoints(HPoint3f(-3,-3,-3), HPoint3f(3,3,3));
|
||||||
foreach (const Raytracer::RayData::Element &el, rdata.Data())
|
for(const Raytracer::RayData::Element &el : rdata.Data())
|
||||||
{
|
{
|
||||||
std::cout << " " << el.vox_id << " , " << el.L << "\n";
|
std::cout << " " << el.vox_id << " , " << el.L << "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,10 @@ set( TESTS
|
|||||||
# vtkTriangleMeshTest
|
# vtkTriangleMeshTest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(LIBRARIES
|
||||||
|
${PACKAGE_LIBPREFIX}Core
|
||||||
|
${PACKAGE_LIBPREFIX}Vtk
|
||||||
|
)
|
||||||
|
|
||||||
include(${VTK_USE_FILE})
|
include(${VTK_USE_FILE})
|
||||||
uLib_add_tests(${uLib-module})
|
uLib_add_tests(${uLib-module})
|
||||||
|
|||||||
@@ -33,8 +33,6 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include <Core/Object.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// vtk classes forward declaration //
|
// vtk classes forward declaration //
|
||||||
@@ -48,22 +46,8 @@ class vtkRendererCollection;
|
|||||||
namespace uLib {
|
namespace uLib {
|
||||||
namespace Vtk {
|
namespace Vtk {
|
||||||
|
|
||||||
|
class Puppet
|
||||||
|
|
||||||
//template <class T>
|
|
||||||
//class Tie {
|
|
||||||
|
|
||||||
//public:
|
|
||||||
// typedef T Content;
|
|
||||||
|
|
||||||
|
|
||||||
//};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Puppet : public Object
|
|
||||||
{
|
{
|
||||||
uLibTypeMacro(Puppet, Object)
|
|
||||||
public:
|
public:
|
||||||
Puppet();
|
Puppet();
|
||||||
~Puppet();
|
~Puppet();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#ifndef ULIBVTKVIEWER_H
|
#ifndef ULIBVTKVIEWER_H
|
||||||
#define ULIBVTKVIEWER_H
|
#define ULIBVTKVIEWER_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include "uLibVtkInterface.h"
|
#include "uLibVtkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,53 +63,8 @@
|
|||||||
namespace uLib {
|
namespace uLib {
|
||||||
namespace Vtk {
|
namespace Vtk {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PIMPL
|
|
||||||
|
|
||||||
class vtkVoxImagePimpl {
|
void vtkVoxImage::GetContent()
|
||||||
public:
|
|
||||||
vtkVoxImagePimpl(vtkVoxImage::Content &content) :
|
|
||||||
m_Content(content),
|
|
||||||
m_Actor(vtkVolume::New()),
|
|
||||||
m_Image(vtkImageData::New()),
|
|
||||||
m_Outline(vtkCubeSource::New()),
|
|
||||||
m_Reader(NULL),
|
|
||||||
m_Writer(NULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~vtkVoxImagePimpl()
|
|
||||||
{
|
|
||||||
m_Image->Delete();
|
|
||||||
m_Actor->Delete();
|
|
||||||
m_Outline->Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetContent();
|
|
||||||
|
|
||||||
void SetContent();
|
|
||||||
|
|
||||||
// members //
|
|
||||||
vtkVolume *m_Actor;
|
|
||||||
vtkImageData *m_Image;
|
|
||||||
vtkCubeSource *m_Outline;
|
|
||||||
|
|
||||||
// io //
|
|
||||||
vtkXMLImageDataReader *m_Reader;
|
|
||||||
vtkXMLImageDataWriter *m_Writer;
|
|
||||||
|
|
||||||
// content //
|
|
||||||
vtkVoxImage::Content &m_Content;
|
|
||||||
|
|
||||||
// visual //
|
|
||||||
float m_Window;
|
|
||||||
float m_Level;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void vtkVoxImagePimpl::GetContent()
|
|
||||||
{
|
{
|
||||||
// ULIB -> VTK //
|
// ULIB -> VTK //
|
||||||
const int *dims = static_cast<const int *>(m_Content.GetDims().data());
|
const int *dims = static_cast<const int *>(m_Content.GetDims().data());
|
||||||
@@ -139,7 +94,7 @@ void vtkVoxImagePimpl::GetContent()
|
|||||||
// m_Image->Update();
|
// m_Image->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkVoxImagePimpl::SetContent()
|
void vtkVoxImage::SetContent()
|
||||||
{
|
{
|
||||||
// VTK -> ULIB //
|
// VTK -> ULIB //
|
||||||
int *ext = m_Image->GetExtent();
|
int *ext = m_Image->GetExtent();
|
||||||
@@ -181,22 +136,29 @@ void vtkVoxImagePimpl::SetContent()
|
|||||||
// VTK VOXIMAGE
|
// VTK VOXIMAGE
|
||||||
|
|
||||||
vtkVoxImage::vtkVoxImage(Content &content) :
|
vtkVoxImage::vtkVoxImage(Content &content) :
|
||||||
d(new vtkVoxImagePimpl(content))
|
m_Content(content),
|
||||||
|
m_Actor(vtkVolume::New()),
|
||||||
|
m_Image(vtkImageData::New()),
|
||||||
|
m_Outline(vtkCubeSource::New()),
|
||||||
|
m_Reader(NULL),
|
||||||
|
m_Writer(NULL),
|
||||||
|
writer_factor(1.E6)
|
||||||
{
|
{
|
||||||
init_properties();
|
GetContent();
|
||||||
d->GetContent();
|
|
||||||
InstallPipe();
|
InstallPipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkVoxImage::~vtkVoxImage()
|
vtkVoxImage::~vtkVoxImage()
|
||||||
{
|
{
|
||||||
delete d;
|
m_Image->Delete();
|
||||||
|
m_Actor->Delete();
|
||||||
|
m_Outline->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkImageData *vtkVoxImage::GetImageData()
|
vtkImageData *vtkVoxImage::GetImageData()
|
||||||
{
|
{
|
||||||
d->GetContent();
|
GetContent();
|
||||||
return d->m_Image;
|
return m_Image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkVoxImage::SaveToXMLFile(const char *fname)
|
void vtkVoxImage::SaveToXMLFile(const char *fname)
|
||||||
@@ -204,16 +166,16 @@ void vtkVoxImage::SaveToXMLFile(const char *fname)
|
|||||||
vtkSmartPointer<vtkXMLImageDataWriter> writer =
|
vtkSmartPointer<vtkXMLImageDataWriter> writer =
|
||||||
vtkSmartPointer<vtkXMLImageDataWriter>::New();
|
vtkSmartPointer<vtkXMLImageDataWriter>::New();
|
||||||
writer->SetFileName(fname);
|
writer->SetFileName(fname);
|
||||||
d->GetContent();
|
GetContent();
|
||||||
vtkSmartPointer<vtkImageShiftScale> vtkscale =
|
vtkSmartPointer<vtkImageShiftScale> vtkscale =
|
||||||
vtkSmartPointer<vtkImageShiftScale>::New();
|
vtkSmartPointer<vtkImageShiftScale>::New();
|
||||||
|
|
||||||
# if VTK_MAJOR_VERSION <= 5
|
# if VTK_MAJOR_VERSION <= 5
|
||||||
vtkscale->SetInputConnection(d->m_Image->GetProducerPort());
|
vtkscale->SetInputConnection(m_Image->GetProducerPort());
|
||||||
# else
|
# else
|
||||||
vtkscale->SetInputData(d->m_Image);
|
vtkscale->SetInputData(m_Image);
|
||||||
# endif
|
# endif
|
||||||
vtkscale->SetScale(p().writer_factor);
|
vtkscale->SetScale(writer_factor);
|
||||||
vtkscale->Update();
|
vtkscale->Update();
|
||||||
writer->SetInputConnection(vtkscale->GetOutputPort());
|
writer->SetInputConnection(vtkscale->GetOutputPort());
|
||||||
writer->Update();
|
writer->Update();
|
||||||
@@ -231,16 +193,16 @@ void vtkVoxImage::ReadFromVKTFile(const char *fname)
|
|||||||
vtkSmartPointer<vtkImageShiftScale> vtkscale =
|
vtkSmartPointer<vtkImageShiftScale> vtkscale =
|
||||||
vtkSmartPointer<vtkImageShiftScale>::New();
|
vtkSmartPointer<vtkImageShiftScale>::New();
|
||||||
vtkscale->SetInputConnection(reader->GetOutputPort());
|
vtkscale->SetInputConnection(reader->GetOutputPort());
|
||||||
vtkscale->SetScale(1/p().writer_factor);
|
vtkscale->SetScale(1/writer_factor);
|
||||||
vtkscale->Update();
|
vtkscale->Update();
|
||||||
|
|
||||||
d->m_Image->DeepCopy(vtkscale->GetOutput()); // FIX! (pipe connection)
|
m_Image->DeepCopy(vtkscale->GetOutput()); // FIX! (pipe connection)
|
||||||
d->SetContent();
|
SetContent();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cerr << "Error: file does not contain structured points\n";
|
std::cerr << "Error: file does not contain structured points\n";
|
||||||
}
|
}
|
||||||
d->m_Actor->Update();
|
m_Actor->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkVoxImage::ReadFromXMLFile(const char *fname)
|
void vtkVoxImage::ReadFromXMLFile(const char *fname)
|
||||||
@@ -252,25 +214,25 @@ void vtkVoxImage::ReadFromXMLFile(const char *fname)
|
|||||||
vtkSmartPointer<vtkImageShiftScale> vtkscale =
|
vtkSmartPointer<vtkImageShiftScale> vtkscale =
|
||||||
vtkSmartPointer<vtkImageShiftScale>::New();
|
vtkSmartPointer<vtkImageShiftScale>::New();
|
||||||
vtkscale->SetInputConnection(reader->GetOutputPort());
|
vtkscale->SetInputConnection(reader->GetOutputPort());
|
||||||
vtkscale->SetScale(1/p().writer_factor);
|
vtkscale->SetScale(1/writer_factor);
|
||||||
vtkscale->Update();
|
vtkscale->Update();
|
||||||
|
|
||||||
d->m_Image->DeepCopy(vtkscale->GetOutput());
|
m_Image->DeepCopy(vtkscale->GetOutput());
|
||||||
d->SetContent();
|
SetContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void vtkVoxImage::setShadingPreset(int blendType)
|
void vtkVoxImage::setShadingPreset(int blendType)
|
||||||
{
|
{
|
||||||
vtkSmartVolumeMapper *mapper =
|
vtkSmartVolumeMapper *mapper =
|
||||||
(vtkSmartVolumeMapper *)d->m_Actor->GetMapper();
|
(vtkSmartVolumeMapper *)m_Actor->GetMapper();
|
||||||
vtkVolumeProperty *property = d->m_Actor->GetProperty();
|
vtkVolumeProperty *property = m_Actor->GetProperty();
|
||||||
|
|
||||||
static vtkColorTransferFunction *colorFun = vtkColorTransferFunction::New();
|
static vtkColorTransferFunction *colorFun = vtkColorTransferFunction::New();
|
||||||
static vtkPiecewiseFunction *opacityFun = vtkPiecewiseFunction::New();
|
static vtkPiecewiseFunction *opacityFun = vtkPiecewiseFunction::New();
|
||||||
|
|
||||||
float window = 40 / $$.writer_factor;
|
float window = 40 / writer_factor;
|
||||||
float level = 20 / $$.writer_factor;
|
float level = 20 / writer_factor;
|
||||||
|
|
||||||
property->SetColor(colorFun);
|
property->SetColor(colorFun);
|
||||||
property->SetScalarOpacity(opacityFun);
|
property->SetScalarOpacity(opacityFun);
|
||||||
@@ -346,9 +308,9 @@ void vtkVoxImage::setShadingPreset(int blendType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void vtkVoxImage::Update() {
|
void vtkVoxImage::Update() {
|
||||||
d->m_Actor->Update();
|
m_Actor->Update();
|
||||||
d->m_Outline->SetBounds(d->m_Image->GetBounds());
|
m_Outline->SetBounds(m_Image->GetBounds());
|
||||||
d->m_Outline->Update();
|
m_Outline->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkVoxImage::InstallPipe()
|
void vtkVoxImage::InstallPipe()
|
||||||
@@ -356,26 +318,26 @@ void vtkVoxImage::InstallPipe()
|
|||||||
vtkSmartPointer<vtkSmartVolumeMapper> mapper =
|
vtkSmartPointer<vtkSmartVolumeMapper> mapper =
|
||||||
vtkSmartPointer<vtkSmartVolumeMapper>::New();
|
vtkSmartPointer<vtkSmartVolumeMapper>::New();
|
||||||
# if VTK_MAJOR_VERSION <= 5
|
# if VTK_MAJOR_VERSION <= 5
|
||||||
mapper->SetInputConnection(d->m_Image->GetProducerPort());
|
mapper->SetInputConnection(m_Image->GetProducerPort());
|
||||||
# else
|
# else
|
||||||
mapper->SetInputData(d->m_Image);
|
mapper->SetInputData(m_Image);
|
||||||
# endif
|
# endif
|
||||||
mapper->Update();
|
mapper->Update();
|
||||||
|
|
||||||
d->m_Actor->SetMapper(mapper);
|
m_Actor->SetMapper(mapper);
|
||||||
this->setShadingPreset(0);
|
this->setShadingPreset(0);
|
||||||
mapper->Update();
|
mapper->Update();
|
||||||
|
|
||||||
d->m_Outline->SetBounds(d->m_Image->GetBounds());
|
m_Outline->SetBounds(m_Image->GetBounds());
|
||||||
vtkSmartPointer<vtkPolyDataMapper> mmapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper> mmapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
mmapper->SetInputConnection(d->m_Outline->GetOutputPort());
|
mmapper->SetInputConnection(m_Outline->GetOutputPort());
|
||||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||||
actor->SetMapper(mmapper);
|
actor->SetMapper(mmapper);
|
||||||
actor->GetProperty()->SetRepresentationToWireframe();
|
actor->GetProperty()->SetRepresentationToWireframe();
|
||||||
actor->GetProperty()->SetAmbient(0.7);
|
actor->GetProperty()->SetAmbient(0.7);
|
||||||
|
|
||||||
// this->SetProp(actor);
|
// this->SetProp(actor);
|
||||||
this->SetProp(d->m_Actor);
|
this->SetProp(m_Actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,12 @@
|
|||||||
#ifndef U_VTKVOXIMAGE_H
|
#ifndef U_VTKVOXIMAGE_H
|
||||||
#define U_VTKVOXIMAGE_H
|
#define U_VTKVOXIMAGE_H
|
||||||
|
|
||||||
#include <Core/Object.h>
|
#include "vtk/vtkVolume.h"
|
||||||
|
#include "vtk/vtkImageData.h"
|
||||||
|
#include "vtk/vtkXMLImageDataReader.h"
|
||||||
|
#include "vtk/vtkXMLImageDataWriter.h"
|
||||||
|
#include "vtk/vtkCubeSource.h"
|
||||||
|
|
||||||
#include <Math/VoxImage.h>
|
#include <Math/VoxImage.h>
|
||||||
|
|
||||||
#include "uLibVtkInterface.h"
|
#include "uLibVtkInterface.h"
|
||||||
@@ -39,14 +44,8 @@ class vtkImageData;
|
|||||||
namespace uLib {
|
namespace uLib {
|
||||||
namespace Vtk {
|
namespace Vtk {
|
||||||
|
|
||||||
class vtkVoxImage : public Puppet {
|
class vtkVoxImage : public Puppet
|
||||||
uLibTypeMacro(vtkVoxImage,Puppet)
|
{
|
||||||
public:
|
|
||||||
properties()
|
|
||||||
{
|
|
||||||
float writer_factor;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Abstract::VoxImage Content;
|
typedef Abstract::VoxImage Content;
|
||||||
|
|
||||||
@@ -54,6 +53,10 @@ public:
|
|||||||
|
|
||||||
~vtkVoxImage();
|
~vtkVoxImage();
|
||||||
|
|
||||||
|
void GetContent();
|
||||||
|
|
||||||
|
void SetContent();
|
||||||
|
|
||||||
vtkImageData * GetImageData();
|
vtkImageData * GetImageData();
|
||||||
|
|
||||||
void SaveToXMLFile(const char *fname);
|
void SaveToXMLFile(const char *fname);
|
||||||
@@ -68,19 +71,23 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InstallPipe();
|
void InstallPipe();
|
||||||
|
float writer_factor;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class vtkVoxImagePimpl *d;
|
vtkVolume *m_Actor;
|
||||||
|
vtkImageData *m_Image;
|
||||||
|
vtkCubeSource *m_Outline;
|
||||||
|
|
||||||
|
vtkXMLImageDataReader *m_Reader;
|
||||||
|
vtkXMLImageDataWriter *m_Writer;
|
||||||
|
|
||||||
|
vtkVoxImage::Content &m_Content;
|
||||||
|
|
||||||
|
float m_Window;
|
||||||
|
float m_Level;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void vtkVoxImage::init_properties()
|
|
||||||
{
|
|
||||||
$_init();
|
|
||||||
$$.writer_factor = 1.E6;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // vtk
|
} // vtk
|
||||||
} // uLib
|
} // uLib
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user