Compare commits
50 Commits
v1.0.0
...
c04722c2bb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c04722c2bb | ||
|
|
8566ceb662 | ||
|
|
5ae2e106ab | ||
| c526f61f8c | |||
|
|
54997fe0ac | ||
| 94bad596ed | |||
|
|
fc909da400 | ||
| b0240dc807 | |||
|
|
591cc9d8bc | ||
|
|
2e401f6fc5 | ||
|
|
91abd56587 | ||
|
|
01ff8a0a0d | ||
|
|
b86e27a9c4 | ||
|
|
820730bc84 | ||
|
|
06c363ab8c | ||
|
|
b7c775ee35 | ||
|
|
7bc4932d09 | ||
|
|
8832f47e75 | ||
|
|
043a44150c | ||
|
|
fce2a39393 | ||
|
|
d223a3a308 | ||
|
|
843a2d69cf | ||
|
|
a60a21bfe4 | ||
|
|
9d899928b8 | ||
|
|
c9d3eac038 | ||
|
|
27dab10434 | ||
|
|
8666283a8a | ||
|
|
89d333632c | ||
|
|
3236b9e599 | ||
|
|
192529aa78 | ||
|
|
884f5ca084 | ||
|
|
6b43046fb6 | ||
|
|
621084fbfc | ||
|
|
38c61a4e9b | ||
|
|
52d574e317 | ||
|
|
8fe8311483 | ||
|
|
d6448ea42f | ||
|
|
51ef9d05f0 | ||
|
|
701d89d030 | ||
|
|
841091a591 | ||
|
|
d02a095028 | ||
|
|
c00e4a6382 | ||
|
|
f8cb48d051 | ||
|
|
9fa51cdc3b | ||
|
|
19865a7c8c | ||
|
|
8d8cc285a5 | ||
|
|
e8b99dd0d5 | ||
|
|
a8672e8620 | ||
| b02399cb21 | |||
|
|
e49eb6a484 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CMakeFiles/
|
||||||
|
build/
|
||||||
|
.cache/
|
||||||
8
.vscode/settings.json
vendored
Normal file
8
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"clangd.fallbackFlags": [
|
||||||
|
"-I${workspaceFolder}/src",
|
||||||
|
"-I/home/share/micromamba/envs/mutom/include",
|
||||||
|
"-I/home/rigoni/.conan2/p/eigen5481853932f72/p/include/eigen3"
|
||||||
|
],
|
||||||
|
"clangd.semanticHighlighting.enable": true
|
||||||
|
}
|
||||||
@@ -15,16 +15,16 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "build path for
|
|||||||
mark_as_advanced(EXECUTABLE_OUTPUT_PATH)
|
mark_as_advanced(EXECUTABLE_OUTPUT_PATH)
|
||||||
|
|
||||||
## Install directories ##
|
## Install directories ##
|
||||||
set(PACKAGE_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
|
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
|
||||||
set(PACKAGE_INSTALL_LIB_DIR lib/${PACKAGE_NAME} CACHE PATH "Installation directory for libraries")
|
set(INSTALL_LIB_DIR lib/${PACKAGE_NAME} CACHE PATH "Installation directory for libraries")
|
||||||
set(PACKAGE_INSTALL_INC_DIR include/${PACKAGE_NAME} CACHE PATH "Installation directory for headers")
|
set(INSTALL_INC_DIR include/${PACKAGE_NAME} CACHE PATH "Installation directory for headers")
|
||||||
set(PACKAGE_INSTALL_DATA_DIR share/${PACKAGE_NAME} CACHE PATH "Installation directory for data files")
|
set(INSTALL_DATA_DIR share/${PACKAGE_NAME} CACHE PATH "Installation directory for data files")
|
||||||
if(WIN32 AND NOT CYGWIN)
|
if(WIN32 AND NOT CYGWIN)
|
||||||
set(DEF_INSTALL_CMAKE_DIR CMake)
|
set(DEF_INSTALL_CMAKE_DIR CMake)
|
||||||
else()
|
else()
|
||||||
set(DEF_INSTALL_CMAKE_DIR lib/cmake/${PACKAGE_NAME})
|
set(DEF_INSTALL_CMAKE_DIR lib/cmake/${PACKAGE_NAME})
|
||||||
endif()
|
endif()
|
||||||
set(PACKAGE_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
|
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
|
||||||
|
|
||||||
# Make relative paths absolute (needed later on)
|
# Make relative paths absolute (needed later on)
|
||||||
foreach(p LIB BIN INC DATA CMAKE)
|
foreach(p LIB BIN INC DATA CMAKE)
|
||||||
@@ -58,7 +58,7 @@ endif()
|
|||||||
set(CMAKE_CXX_WARNING_OPTION "" CACHE STRING "Warning level -WAll to verbose all warnings")
|
set(CMAKE_CXX_WARNING_OPTION "" CACHE STRING "Warning level -WAll to verbose all warnings")
|
||||||
set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE STRING "Verbose compile output switch")
|
set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE STRING "Verbose compile output switch")
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ${CMAKE_CXX_WARNING_OPTION}")
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ${CMAKE_CXX_WARNING_OPTION}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,6 @@ set(BOOST_PP_VARIADICS ON)
|
|||||||
message(STATUS "PROJECT NAME = ${PROJECT_NAME}")
|
message(STATUS "PROJECT NAME = ${PROJECT_NAME}")
|
||||||
message(STATUS "PACKAGE VERSION = ${PACKAGE_VERSION}")
|
message(STATUS "PACKAGE VERSION = ${PACKAGE_VERSION}")
|
||||||
message(STATUS "PACKAGE NAME = ${PACKAGE_NAME}")
|
message(STATUS "PACKAGE NAME = ${PACKAGE_NAME}")
|
||||||
execute_process(COMMAND "svnversion"
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
||||||
OUTPUT_VARIABLE SVN_REVISION
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE )
|
|
||||||
|
|
||||||
message(STATUS "SVN REVISION = ${SVN_REVISION}")
|
|
||||||
|
|
||||||
CHECK_INCLUDE_FILES(inittypes.h HAVE_INITTYPES_H)
|
CHECK_INCLUDE_FILES(inittypes.h HAVE_INITTYPES_H)
|
||||||
CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
|
CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ set(Boost_USE_STATIC_LIBS OFF)
|
|||||||
set(Boost_USE_MULTITHREADED ON)
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
|
||||||
find_package(Boost 1.45.0 COMPONENTS serialization signals program_options REQUIRED)
|
find_package(Boost 1.45.0 COMPONENTS program_options REQUIRED)
|
||||||
if(Boost_FOUND)
|
if(Boost_FOUND)
|
||||||
set(HAVE_BOOST true)
|
set(HAVE_BOOST true)
|
||||||
endif(Boost_FOUND)
|
endif(Boost_FOUND)
|
||||||
@@ -75,36 +75,36 @@ endif(ULIB_USE_VTK)
|
|||||||
|
|
||||||
|
|
||||||
## GEANT ##
|
## GEANT ##
|
||||||
option(ULIB_USE_GEANT4 "Activate use of GEANT Integration" ON)
|
#option(ULIB_USE_GEANT4 "Activate use of GEANT Integration" ON)
|
||||||
message(STATUS "## GEANT 4 ##")
|
#message(STATUS "## GEANT 4 ##")
|
||||||
#include(FindGEANT4) # disabled using system finder
|
##include(FindGEANT4) # disabled using system finder
|
||||||
find_package(Geant4)
|
#find_package(Geant4)
|
||||||
set(GEANT4_FOUND Geant4_DIR)
|
#set(GEANT4_FOUND Geant4_DIR)
|
||||||
if(GEANT4_FOUND AND ULIB_USE_GEANT4)
|
#if(GEANT4_FOUND AND ULIB_USE_GEANT4)
|
||||||
message(STATUS "Looking for Geant4... - Geant4 found in ${Geant4_DIR}")
|
# message(STATUS "Looking for Geant4... - Geant4 found in ${Geant4_DIR}")
|
||||||
set(HAVE_GEANT4 true)
|
# set(HAVE_GEANT4 true)
|
||||||
include_directories(${Geant4_INCLUDE_DIRS}) # Add -I type paths
|
# include_directories(${Geant4_INCLUDE_DIRS}) # Add -I type paths
|
||||||
add_definitions(${Geant4_DEFINITIONS}) # Add -D type defs
|
# add_definitions(${Geant4_DEFINITIONS}) # Add -D type defs
|
||||||
debug_package(Geant4)
|
# debug_package(Geant4)
|
||||||
endif(GEANT4_FOUND AND ULIB_USE_GEANT4)
|
#endif(GEANT4_FOUND AND ULIB_USE_GEANT4)
|
||||||
|
|
||||||
## QT4 ##
|
## QT4 ##
|
||||||
option(ULIB_USE_QT4 "Activate use of Qt Framework" ON)
|
#option(ULIB_USE_QT4 "Activate use of Qt Framework" ON)
|
||||||
if(ULIB_USE_QT4)
|
#if(ULIB_USE_QT4)
|
||||||
message(STATUS "## QT4 ##")
|
# message(STATUS "## QT4 ##")
|
||||||
find_package(Qt4)
|
# find_package(Qt4)
|
||||||
# include_directories(${Qt4_INCLUDE_DIRS})
|
## include_directories(${Qt4_INCLUDE_DIRS})
|
||||||
# debug(Qt4_INCLUDE_DIRS)
|
## debug(Qt4_INCLUDE_DIRS)
|
||||||
endif(ULIB_USE_QT4)
|
#endif(ULIB_USE_QT4)
|
||||||
|
|
||||||
## QT5 ##
|
## QT5 ##
|
||||||
option(ULIB_USE_QT5 "Activate use of Qt Framework" ON)
|
#option(ULIB_USE_QT5 "Activate use of Qt Framework" ON)
|
||||||
if(ULIB_USE_QT5)
|
#if(ULIB_USE_QT5)
|
||||||
message(STATUS "## QT5 ##")
|
# message(STATUS "## QT5 ##")
|
||||||
find_package(Qt5Widgets)
|
# find_package(Qt5Widgets)
|
||||||
# include_directories(${Qt5_INCLUDE_DIRS})
|
## include_directories(${Qt5_INCLUDE_DIRS})
|
||||||
# debug(Qt5_INCLUDE_DIRS)
|
## debug(Qt5_INCLUDE_DIRS)
|
||||||
endif(ULIB_USE_QT5)
|
#endif(ULIB_USE_QT5)
|
||||||
|
|
||||||
## READLINE ##
|
## READLINE ##
|
||||||
message(STATUS "## READLINE ##")
|
message(STATUS "## READLINE ##")
|
||||||
|
|||||||
97
CMake/uLibGenerateDoc.cmake
Normal file
97
CMake/uLibGenerateDoc.cmake
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
find_package(Doxygen)
|
||||||
|
|
||||||
|
set(doxydirlist "")
|
||||||
|
foreach(modname ${ULIB_SELECTED_MODULES})
|
||||||
|
set(doxydirlist "${CMAKE_CURRENT_SOURCE_DIR}/src/${modname} ${doxydirlist}")
|
||||||
|
endforeach(modname)
|
||||||
|
|
||||||
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
|
||||||
|
"PROJECT_NAME=${CMAKE_PROJECT_NAME}-${PACKAGE_VERSION}\n"
|
||||||
|
"OUTPUT_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}\n"
|
||||||
|
"CREATE_SUBDIRS=NO\n"
|
||||||
|
"OUTPUT_LANGUAGE=English\n"
|
||||||
|
"BRIEF_MEMBER_DESC=YES\n"
|
||||||
|
"REPEAT_BRIEF=YES\n"
|
||||||
|
"ALWAYS_DETAILED_SEC=NO\n"
|
||||||
|
"INLINE_INHERITED_MEMB=NO\n"
|
||||||
|
"STRIP_FROM_INC_PATH=${CMAKE_CURRENT_SOURCE_DIR}/src\n"
|
||||||
|
"FULL_PATH_NAMES=YES\n"
|
||||||
|
"STRIP_FROM_PATH=${CMAKE_CURRENT_SOURCE_DIR}/src\n"
|
||||||
|
"SHORT_NAMES=NO\n"
|
||||||
|
"MULTILINE_CPP_IS_BRIEF=NO\n"
|
||||||
|
"INHERIT_DOCS=YES\n"
|
||||||
|
"DISTRIBUTE_GROUP_DOC=NO\n"
|
||||||
|
"OPTIMIZE_OUTPUT_FOR_C=YES\n"
|
||||||
|
"SUBGROUPING=YES\n"
|
||||||
|
"EXTRACT_ALL=YES\n"
|
||||||
|
"EXTRACT_PRIVATE=NO\n"
|
||||||
|
"EXTRACT_STATIC=NO\n"
|
||||||
|
"EXTRACT_LOCAL_CLASSES=YES\n"
|
||||||
|
"EXTRACT_LOCAL_METHODS=NO\n"
|
||||||
|
"HIDE_UNDOC_MEMBERS=NO\n"
|
||||||
|
"HIDE_UNDOC_CLASSES=NO\n"
|
||||||
|
"HIDE_FRIEND_COMPOUNDS=NO\n"
|
||||||
|
"HIDE_IN_BODY_DOCS=NO\n"
|
||||||
|
"INTERNAL_DOCS=NO\n"
|
||||||
|
"CASE_SENSE_NAMES=NO\n"
|
||||||
|
"HIDE_SCOPE_NAMES=NO\n"
|
||||||
|
"SHOW_INCLUDE_FILES=YES\n"
|
||||||
|
"INLINE_INFO=YES\n"
|
||||||
|
"SORT_MEMBER_DOCS=YES\n"
|
||||||
|
"SORT_BRIEF_DOCS=NO\n"
|
||||||
|
"SORT_BY_SCOPE_NAME=NO\n"
|
||||||
|
"GENERATE_TODOLIST=YES\n"
|
||||||
|
"GENERATE_TESTLIST=YES\n"
|
||||||
|
"GENERATE_BUGLIST=YES\n"
|
||||||
|
"GENERATE_DEPRECATEDLIST=YES\n"
|
||||||
|
"MAX_INITIALIZER_LINES=30\n"
|
||||||
|
"SHOW_USED_FILES=YES\n"
|
||||||
|
"QUIET=YES\n"
|
||||||
|
"WARNINGS=NO\n"
|
||||||
|
"WARN_IF_UNDOCUMENTED=YES\n"
|
||||||
|
"WARN_IF_DOC_ERROR=YES\n"
|
||||||
|
"WARN_FORMAT=\"$file:$line: $text\"\n"
|
||||||
|
"INPUT=${doxydirlist}\n"
|
||||||
|
"FILE_PATTERNS=*.h *.hpp\n"
|
||||||
|
"ENABLE_PREPROCESSING=YES\n"
|
||||||
|
"MACRO_EXPANSION=YES\n"
|
||||||
|
"RECURSIVE=YES\n"
|
||||||
|
"EXCLUDE_SYMLINKS=NO\n"
|
||||||
|
"FILTER_SOURCE_FILES=NO\n"
|
||||||
|
"SOURCE_BROWSER=NO\n"
|
||||||
|
"INLINE_SOURCES=NO\n"
|
||||||
|
"STRIP_CODE_COMMENTS=YES\n"
|
||||||
|
"REFERENCED_BY_RELATION=YES\n"
|
||||||
|
"REFERENCES_RELATION=YES\n"
|
||||||
|
"VERBATIM_HEADERS=YES\n"
|
||||||
|
"ALPHABETICAL_INDEX=YES\n"
|
||||||
|
"COLS_IN_ALPHA_INDEX=5\n"
|
||||||
|
"GENERATE_HTML=YES\n"
|
||||||
|
"HTML_OUTPUT=html\n"
|
||||||
|
"HTML_FILE_EXTENSION=.html\n"
|
||||||
|
"GENERATE_HTMLHELP=NO\n"
|
||||||
|
"BINARY_TOC=NO\n"
|
||||||
|
"TOC_EXPAND=NO\n"
|
||||||
|
"DISABLE_INDEX=NO\n"
|
||||||
|
"ENUM_VALUES_PER_LINE=4\n"
|
||||||
|
"GENERATE_TREEVIEW=YES\n"
|
||||||
|
"TREEVIEW_WIDTH=250\n"
|
||||||
|
"GENERATE_LATEX=NO\n"
|
||||||
|
"GENERATE_RTF=NO\n"
|
||||||
|
"GENERATE_MAN=NO\n"
|
||||||
|
"GENERATE_XML=NO\n"
|
||||||
|
"GENERATE_AUTOGEN_DEF=NO\n"
|
||||||
|
"GENERATE_PERLMOD=NO\n")
|
||||||
|
|
||||||
|
option(NODOXYGEN "Disable the creation of the API documentation")
|
||||||
|
if(NODOXYGEN OR (NOT DOXYGEN_FOUND))
|
||||||
|
message("Doxygen is disabled or not installed")
|
||||||
|
else(NODOXYGEN OR (NOT DOXYGEN_FOUND))
|
||||||
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
|
||||||
|
COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg)
|
||||||
|
|
||||||
|
add_custom_target(doxygen ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
|
||||||
|
|
||||||
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||||
|
DESTINATION share/doc/${PACKAGE_NAME})
|
||||||
|
endif(NODOXYGEN OR (NOT DOXYGEN_FOUND))
|
||||||
@@ -28,26 +28,28 @@ macro(uLib_add_shared_library name)
|
|||||||
set(ULIB_SHARED_LIBRARIES ${shared} PARENT_SCOPE)
|
set(ULIB_SHARED_LIBRARIES ${shared} PARENT_SCOPE)
|
||||||
source_group("${project_name}\\${name}" FILES ${SOURCES})
|
source_group("${project_name}\\${name}" FILES ${SOURCES})
|
||||||
set_target_properties(${mname} PROPERTIES
|
set_target_properties(${mname} PROPERTIES
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION ${PROJECT_SOVERSION}
|
SOVERSION ${PROJECT_SOVERSION}
|
||||||
INTERFACE_LINK_LIBRARIES "${LIBRARIES}"
|
# INTERFACE_LINK_LIBRARIES "${LIBRARIES}"
|
||||||
LINK_INTERFACE_LIBRARIES "${LIBRARIES}" ## <- ok for cmake from 2.12 ?
|
# LINK_INTERFACE_LIBRARIES "${LIBRARIES}" ## <- ok for cmake from 2.12 ?
|
||||||
IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBRARIES}" ## <- breaks cmake after 2.11 ?
|
# IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBRARIES}" ## <- breaks cmake after 2.11 ?
|
||||||
# PUBLIC_HEADER ""
|
# PUBLIC_HEADER ""
|
||||||
)
|
)
|
||||||
debug(LIBRARIES)
|
debug(LIBRARIES)
|
||||||
|
|
||||||
|
target_link_libraries(${mname} ${LIBRARIES})
|
||||||
|
|
||||||
install(TARGETS ${mname}
|
install(TARGETS ${mname}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
RUNTIME DESTINATION ${PACKAGE_INSTALL_BIN_DIR} COMPONENT bin
|
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
||||||
LIBRARY DESTINATION ${PACKAGE_INSTALL_LIB_DIR} COMPONENT lib
|
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib
|
||||||
# PUBLIC_HEADER DESTINATION ${PACKAGE_INSTALL_INC_DIR} COMPONENT dev
|
# PUBLIC_HEADER DESTINATION ${INSTALL_INC_DIR} COMPONENT dev
|
||||||
)
|
)
|
||||||
endif(SOURCES)
|
endif(SOURCES)
|
||||||
|
|
||||||
if(HEADERS)
|
if(HEADERS)
|
||||||
foreach(header ${HEADERS})
|
foreach(header ${HEADERS})
|
||||||
install(FILES ${header} DESTINATION ${PACKAGE_INSTALL_INC_DIR}/${name})
|
install(FILES ${header} DESTINATION ${INSTALL_INC_DIR}/${name})
|
||||||
endforeach(header)
|
endforeach(header)
|
||||||
endif(HEADERS)
|
endif(HEADERS)
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ macro(uLib_add_target name)
|
|||||||
|
|
||||||
install(TARGETS ${name}
|
install(TARGETS ${name}
|
||||||
EXPORT "${PROJECT_NAME}Targets"
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
RUNTIME DESTINATION ${PACKAGE_INSTALL_BIN_DIR} COMPONENT bin
|
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
||||||
)
|
)
|
||||||
ENDMACRO(uLib_add_target)
|
ENDMACRO(uLib_add_target)
|
||||||
|
|
||||||
@@ -79,25 +81,17 @@ ENDMACRO(uLib_add_target)
|
|||||||
|
|
||||||
# TESTS and LIBRARIES must be defined
|
# TESTS and LIBRARIES must be defined
|
||||||
macro(uLib_add_tests name)
|
macro(uLib_add_tests name)
|
||||||
foreach(tn ${TESTS})
|
foreach(tn ${TESTS})
|
||||||
add_executable(${tn} EXCLUDE_FROM_ALL ${tn}.cpp)
|
add_executable(${tn} EXCLUDE_FROM_ALL ${tn}.cpp)
|
||||||
add_test(${tn} ${tn})
|
add_test(NAME ${tn} COMMAND ${tn})
|
||||||
|
|
||||||
# adds dependencies to all selected modules in uLib
|
target_link_libraries(${tn} ${LIBRARIES})
|
||||||
# foreach(module ${ULIB_SELECTED_MODULES})
|
|
||||||
# add_dependencies(${tn} ${project_name}${module})
|
|
||||||
# endforeach(module)
|
|
||||||
|
|
||||||
# adds libraries dependencies
|
endforeach(tn)
|
||||||
foreach(library ${LIBRARIES})
|
|
||||||
target_link_libraries(${tn} ${library})
|
|
||||||
endforeach(library)
|
|
||||||
|
|
||||||
endforeach(tn)
|
# custom target to compile all tests
|
||||||
|
add_custom_target(all-${name}-tests)
|
||||||
# custom target to compile all tests
|
add_dependencies(all-${name}-tests ${TESTS})
|
||||||
add_custom_target(all-${name}-tests)
|
|
||||||
add_dependencies(all-${name}-tests ${TESTS})
|
|
||||||
endmacro(uLib_add_tests name)
|
endmacro(uLib_add_tests name)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
365
CMakeLists.txt
365
CMakeLists.txt
@@ -3,12 +3,7 @@
|
|||||||
##### CMAKE LISTS ##############################################################
|
##### CMAKE LISTS ##############################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 2.6)
|
cmake_minimum_required (VERSION 3.26)
|
||||||
|
|
||||||
execute_process(COMMAND "clear")
|
|
||||||
message("//////////////////////////////////////////////////////////////////////")
|
|
||||||
message("/////////////////// CMAKE PJOJECT CONFIGURATION //////////////////////")
|
|
||||||
message("//////////////////////////////////////////////////////////////////////")
|
|
||||||
|
|
||||||
## -------------------------------------------------------------------------- ##
|
## -------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
@@ -16,7 +11,7 @@ project(uLib)
|
|||||||
|
|
||||||
# The version number.
|
# The version number.
|
||||||
set(PROJECT_VERSION_MAJOR 0)
|
set(PROJECT_VERSION_MAJOR 0)
|
||||||
set(PROJECT_VERSION_MINOR 2)
|
set(PROJECT_VERSION_MINOR 6)
|
||||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
|
|
||||||
@@ -31,207 +26,245 @@ set(PACKAGE_AUTHOR "Andrea Rigoni Garola <andrea.rigoni@pd.infn.it>")
|
|||||||
|
|
||||||
set(ULIB_CMAKE_DIR "${PROJECT_SOURCE_DIR}/CMake")
|
set(ULIB_CMAKE_DIR "${PROJECT_SOURCE_DIR}/CMake")
|
||||||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
|
||||||
message(STATUS "Module path: ${CMAKE_MODULE_PATH}")
|
message(STATUS "Project name = ${PROJECT_NAME}")
|
||||||
|
message(STATUS "Package name = ${PACKAGE_NAME}")
|
||||||
include(uLibMacros)
|
message(STATUS "Package version = ${PACKAGE_VERSION}")
|
||||||
include(uLibDebugMacro)
|
message(STATUS "Module path = ${CMAKE_MODULE_PATH}")
|
||||||
include(uLibTargetMacros)
|
|
||||||
include(uLibGenerateRMake)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## GLOBALS ------------------------------------------------------------------ ##
|
## GLOBALS ------------------------------------------------------------------ ##
|
||||||
|
|
||||||
include(uLibCommon)
|
# -- move to GnuInstallDirs
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ") ## Add flags here ##
|
# ref: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
set(INSTALL_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${PACKAGE_NAME}
|
||||||
|
CACHE PATH "Location of header files (.../include)" )
|
||||||
|
set(INSTALL_ETC_DIR ${CMAKE_INSTALL_SYSCONFDIR}/${PACKAGE_NAME}
|
||||||
|
CACHE PATH "Location of configuration files (.../etc)" )
|
||||||
|
set(INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR}/${PACKAGE_NAME}
|
||||||
|
CACHE PATH "Location of executable files (.../bin)" )
|
||||||
|
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
CACHE PATH "Location of library files (.../lib)" )
|
||||||
|
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PACKAGE_NAME}
|
||||||
|
CACHE PATH "Location of cmake files (.../lib/cmake)" )
|
||||||
|
set(INSTALL_DATA_DIR ${CMAKE_INSTALL_DATADIR}/${PACKAGE_NAME}
|
||||||
|
CACHE PATH "Location of data files (.../share)" )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
set(SRC_DIR ${PROJECT_SOURCE_DIR}/src)
|
||||||
|
|
||||||
|
# this is used to be exported in build target
|
||||||
|
# ( to compile against build directory instead of install )
|
||||||
|
set(ULIB_SOURCE_DIR ${PROJECT_SOURCE_DIR})
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||||
|
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed")
|
||||||
|
# Set the possible values of build type for cmake-gui
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
||||||
|
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_WARNING_OPTION ""
|
||||||
|
CACHE STRING "Warning level -WAll to verbose all warnings")
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE FALSE
|
||||||
|
CACHE STRING "Verbose compile output switch")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_WARNING_OPTION}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -UULIB_SERIALIZATION_ON -Wno-cpp")
|
||||||
|
|
||||||
|
# CTEST framework
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
|
|
||||||
## FIND PACKAGES ------------------------------------------------------------ ##
|
## FIND PACKAGES ------------------------------------------------------------ ##
|
||||||
|
|
||||||
include(uLibFindDependencies)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
message(STATUS "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}")
|
||||||
|
find_package(Boost 1.45.0 COMPONENTS program_options REQUIRED)
|
||||||
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
find_package(Eigen3 CONFIG REQUIRED)
|
||||||
|
get_target_property(EIGEN3_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
include_directories(${EIGEN3_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
find_package(ROOT CONFIG REQUIRED)
|
||||||
|
include(${ROOT_USE_FILE})
|
||||||
|
|
||||||
|
find_package(VTK REQUIRED)
|
||||||
|
# include(${VTK_USE_FILE})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
option(CENTOS_SUPPORT "VTK definitions for CentOS" OFF)
|
||||||
|
if(CENTOS_SUPPORT)
|
||||||
|
find_package(VTK CONFIG REQUIRED)
|
||||||
|
include(${VTK_USE_FILE})
|
||||||
|
else()
|
||||||
|
find_package(VTK REQUIRED
|
||||||
|
COMPONENTS CommonColor
|
||||||
|
CommonCore
|
||||||
|
FiltersCore
|
||||||
|
FiltersModeling
|
||||||
|
FiltersSources
|
||||||
|
IOLegacy
|
||||||
|
IOXML
|
||||||
|
IOXMLParser
|
||||||
|
ImagingCore
|
||||||
|
InteractionStyle
|
||||||
|
InteractionWidgets
|
||||||
|
RenderingAnnotation
|
||||||
|
RenderingContextOpenGL2
|
||||||
|
RenderingCore
|
||||||
|
RenderingFreeType
|
||||||
|
RenderingGL2PSOpenGL2
|
||||||
|
RenderingOpenGL2
|
||||||
|
RenderingVolumeOpenGL2)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_INCLUDES math.h)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES CMAKE_REQUIRED_LIBRARIES m)
|
||||||
|
|
||||||
## CONFIG ------------------------------------------------------------------- ##
|
## CONFIG ------------------------------------------------------------------- ##
|
||||||
|
|
||||||
include(uLibConfigHeader)
|
set(BOOST_PP_VARIADICS ON)
|
||||||
|
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
|
||||||
|
CHECK_INCLUDE_FILES(inittypes.h HAVE_INITTYPES_H)
|
||||||
|
CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
|
||||||
|
CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
|
||||||
|
CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
|
||||||
|
CHECK_INCLUDE_FILES(dlfcn.h HAVE_DLFCN_H)
|
||||||
|
CHECK_INCLUDE_FILES(malloc.h HAVE_MALLOC_H)
|
||||||
|
CHECK_FUNCTION_EXISTS(malloc HAVE_MALLOC)
|
||||||
|
CHECK_INCLUDE_FILES(memory.h HAVE_MEMORY_H)
|
||||||
|
CHECK_INCLUDE_FILES(math.h HAVE_MATH_H)
|
||||||
|
CHECK_FUNCTION_EXISTS(fsetround HAVE_FSETROUND)
|
||||||
|
CHECK_FUNCTION_EXISTS(floor HAVE_FLOOR)
|
||||||
|
CHECK_FUNCTION_EXISTS(pow HAVE_POW)
|
||||||
|
CHECK_FUNCTION_EXISTS(sqrt HAVE_SQRT)
|
||||||
|
CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP)
|
||||||
|
CHECK_FUNCTION_EXISTS(strstr HAVE_STRSTR)
|
||||||
|
CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
|
||||||
|
CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
|
||||||
|
CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
|
||||||
|
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
|
||||||
|
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
|
||||||
|
CHECK_INCLUDE_FILES(assert.h HAVE_ASSERT_H)
|
||||||
|
|
||||||
|
configure_file("${PROJECT_SOURCE_DIR}/CMakeConfig.in.h"
|
||||||
|
"${PROJECT_BINARY_DIR}/config.h")
|
||||||
|
|
||||||
|
install(FILES "${PROJECT_BINARY_DIR}/config.h"
|
||||||
|
DESTINATION ${INSTALL_INC_DIR})
|
||||||
|
|
||||||
## ADD LIBRARIES SUBDIRECTORIES --------------------------------------------- ##
|
## ADD LIBRARIES SUBDIRECTORIES --------------------------------------------- ##
|
||||||
|
|
||||||
## select modules ##
|
include_directories(${PROJECT_BINARY_DIR})
|
||||||
set(ULIB_SELECTED_MODULES
|
include_directories(${SRC_DIR})
|
||||||
ltk
|
|
||||||
Core
|
|
||||||
Math
|
|
||||||
Detectors
|
|
||||||
Root
|
|
||||||
)
|
|
||||||
|
|
||||||
## uLib_add_shared_library puts names there
|
## uLib_add_shared_library puts names there
|
||||||
set(ULIB_SHARED_LIBRARIES)
|
set(ULIB_SHARED_LIBRARIES)
|
||||||
|
## select modules ##
|
||||||
|
set(ULIB_SELECTED_MODULES)
|
||||||
|
|
||||||
if(ULIB_USE_VTK)
|
include_directories(${SRC_DIR}/Core)
|
||||||
LIST(APPEND ULIB_SELECTED_MODULES Vtk)
|
add_subdirectory(${SRC_DIR}/Core)
|
||||||
endif(ULIB_USE_VTK)
|
|
||||||
|
|
||||||
## this gets ulib modules into a variable ##
|
include_directories(${SRC_DIR}/Math)
|
||||||
function(uLib_modules result)
|
add_subdirectory(${SRC_DIR}/Math)
|
||||||
set(out)
|
|
||||||
foreach(module ${ULIB_SELECTED_MODULES})
|
|
||||||
list(APPEND out ${PACKAGE_LIBPREFIX}${module})
|
|
||||||
endforeach(module)
|
|
||||||
set(${result} "${out}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
|
include_directories(${SRC_DIR}/Detectors)
|
||||||
|
add_subdirectory(${SRC_DIR}/Detectors)
|
||||||
|
|
||||||
## ENTERING MODULES SUBDIRECTORIES ##
|
include_directories(${SRC_DIR}/Root)
|
||||||
message("/////////// SELECTED MODULES //////////////")
|
add_subdirectory(${SRC_DIR}/Root)
|
||||||
foreach(module ${ULIB_SELECTED_MODULES})
|
|
||||||
message(STATUS "adding module: ${module}")
|
|
||||||
set( uLib-module ${module})
|
|
||||||
include_directories(${SRC_DIR}/${module})
|
|
||||||
add_subdirectory(${SRC_DIR}/${module})
|
|
||||||
endforeach(module)
|
|
||||||
|
|
||||||
## SINGLE LIBRARY LINKING ## (work in progress ... )
|
include_directories(${SRC_DIR}/Vtk)
|
||||||
option(ULIB_SINGLELIBRARY "Link everything to a single library" OFF)
|
add_subdirectory(${SRC_DIR}/Vtk)
|
||||||
if(ULIB_SINGLELIBRARY)
|
|
||||||
# set(modgrp)
|
#add_subdirectory("${SRC_DIR}/utils/make_recipe")
|
||||||
# foreach(module ${ULIB_SELECTED_MODULES})
|
|
||||||
# set(grpn srcgrp_${module})
|
## Documentation and packages
|
||||||
# list(APPEND modgrp ${grpn})
|
|
||||||
# endforeach(module)
|
#include(uLibGenerateDoc)
|
||||||
# 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)
|
||||||
export(PACKAGE ULIB)
|
#export(TARGETS ${ULIB_SHARED_LIBRARIES} ${ULIB_EXPORTED_TARGETS}
|
||||||
export(TARGETS ${ULIB_SHARED_LIBRARIES} ${ULIB_EXPORTED_TARGETS}
|
# FILE "${PROJECT_BINARY_DIR}/uLibTargets.cmake" )
|
||||||
FILE "${PROJECT_BINARY_DIR}/uLibTargets.cmake" )
|
|
||||||
#export(TARGETS ${ULIB_EXPORTED_TARGETS}
|
|
||||||
# FILE "${PROJECT_BINARY_DIR}/uLibExeTargets.cmake" )
|
|
||||||
|
|
||||||
|
|
||||||
# Create the FooBarConfig.cmake and FooBarConfigVersion files
|
# Create the FooBarConfig.cmake and FooBarConfigVersion files
|
||||||
file(RELATIVE_PATH REL_INCLUDE_DIR "${PACKAGE_INSTALL_CMAKE_DIR}"
|
# file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
|
||||||
"${PACKAGE_INSTALL_INC_DIR}")
|
# "${INSTALL_INC_DIR}")
|
||||||
|
|
||||||
# ... for the build tree
|
# ... for the build tree
|
||||||
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}")
|
#set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}")
|
||||||
configure_file(uLibConfig.cmake.in
|
#configure_file(uLibConfig.cmake.in
|
||||||
"${PROJECT_BINARY_DIR}/uLibConfig.cmake" @ONLY)
|
# "${PROJECT_BINARY_DIR}/uLibConfig.cmake" @ONLY)
|
||||||
|
|
||||||
# ... for the install tree
|
# ... for the install tree
|
||||||
set(CONF_INCLUDE_DIRS "\${ULIB_CMAKE_DIR}/${REL_INCLUDE_DIR}")
|
set(CONF_INCLUDE_DIRS "\${ULIB_CMAKE_DIR}/${REL_INCLUDE_DIR}")
|
||||||
configure_file(uLibConfig.cmake.in
|
# [ removed for the configure_config_file ]
|
||||||
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/uLibConfig.cmake" @ONLY)
|
# configure_file(uLibConfig.cmake.in
|
||||||
|
# "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/uLibConfig.cmake"
|
||||||
|
# @ONLY)
|
||||||
|
|
||||||
# ... for both
|
# ... for both
|
||||||
configure_file(uLibConfigVersion.cmake.in
|
configure_file(uLibConfigVersion.cmake.in
|
||||||
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake" @ONLY)
|
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake" @ONLY)
|
||||||
|
|
||||||
# Install the FooBarConfig.cmake and FooBarConfigVersion.cmake
|
|
||||||
install(FILES
|
|
||||||
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/uLibConfig.cmake"
|
|
||||||
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake"
|
|
||||||
DESTINATION "${PACKAGE_INSTALL_CMAKE_DIR}" COMPONENT dev)
|
|
||||||
|
|
||||||
# Install the export set for use with the install-tree
|
|
||||||
install(EXPORT "${PROJECT_NAME}Targets" DESTINATION
|
|
||||||
"${PACKAGE_INSTALL_CMAKE_DIR}" COMPONENT dev)
|
|
||||||
|
|
||||||
install(FILES ${PROJECT_SOURCE_DIR}/ulib.h DESTINATION ${PACKAGE_INSTALL_INC_DIR})
|
|
||||||
|
|
||||||
|
|
||||||
|
# from CMake 3.x configure file shall be created using a dedicated function
|
||||||
|
# see: https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html
|
||||||
|
#
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
configure_package_config_file(uLibConfig.cmake.in
|
||||||
|
"${PROJECT_BINARY_DIR}/uLibConfig.cmake"
|
||||||
|
INSTALL_DESTINATION ${INSTALL_CMAKE_DIR}
|
||||||
|
PATH_VARS
|
||||||
|
INSTALL_LIB_DIR
|
||||||
|
INSTALL_INC_DIR
|
||||||
|
INSTALL_BIN_DIR
|
||||||
|
INSTALL_CMAKE_DIR
|
||||||
|
INSTALL_ETC_DIR
|
||||||
|
INSTALL_DATA_DIR
|
||||||
|
ULIB_SOURCE_DIR
|
||||||
|
ULIB_SHARED_LIBRARIES
|
||||||
|
# NO_SET_AND_CHECK_MACRO
|
||||||
|
# NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
||||||
|
)
|
||||||
|
|
||||||
## dummy main executable ---------------------------------------------------- ##
|
install(FILES "${PROJECT_BINARY_DIR}/uLibConfig.cmake"
|
||||||
|
"${PROJECT_BINARY_DIR}/uLibConfigVersion.cmake"
|
||||||
message("Sara's debug....")
|
DESTINATION "${INSTALL_CMAKE_DIR}"
|
||||||
message(${ROOT_LIBRARIES})
|
COMPONENT dev)
|
||||||
|
|
||||||
# add the executable
|
|
||||||
add_executable(Coretest test.cpp)
|
|
||||||
target_link_libraries(Coretest ${PACKAGE_LIBPREFIX}Core)
|
|
||||||
#target_link_libraries(Coretest ${Boost_SERIALIZATION_LIBRARY})
|
|
||||||
#target_link_libraries(Coretest ${Boost_SIGNALS_LIBRARY})
|
|
||||||
#target_link_libraries(Coretest ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
||||||
#target_link_libraries(Coretest ${Geant4_LIBRARIES})
|
|
||||||
target_link_libraries(Coretest ${ROOT_LIBRARIES})
|
|
||||||
target_link_libraries(Coretest ${VTK_LIBRARIES})
|
|
||||||
|
|
||||||
#message( "---------------------------------------------------------------------" )
|
|
||||||
#execute_process(COMMAND
|
|
||||||
# "ls"
|
|
||||||
## "cmake --find-package -DNAME=uLib -DLANGUAGE=C -DCOMPILER_ID=GNU -DMODE=COMPILE"
|
|
||||||
# )
|
|
||||||
#message( "---------------------------------------------------------------------" )
|
|
||||||
|
|
||||||
## -------------------------------------------------------------------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# TODO clean also subdirectories
|
# this is a special target file for the build tree
|
||||||
add_custom_target(clean-cmake-files
|
# it is used also to identify if we are using a build direcory
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${ULIB_CMAKE_DIR}/clean-all.cmake
|
# to link a project against uLib. see: uLibConfig.cmake ( IF )
|
||||||
|
export (TARGETS ${ULIB_SHARED_LIBRARIES}
|
||||||
|
FILE "${PROJECT_BINARY_DIR}/uLibTargets-build.cmake"
|
||||||
|
# NAMESPACE "uLib::"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Install the export set for use with the install-tree
|
||||||
|
install(EXPORT "uLibTargets"
|
||||||
|
FILE "uLibTargets.cmake"
|
||||||
|
DESTINATION "${INSTALL_CMAKE_DIR}"
|
||||||
|
COMPONENT dev)
|
||||||
|
|
||||||
|
|||||||
9
CMakeUserPresets.json
Normal file
9
CMakeUserPresets.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"vendor": {
|
||||||
|
"conan": {}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"build/CMakePresets.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
35
Jenkinsfile
vendored
Normal file
35
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
pipeline {
|
||||||
|
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'infnpd/cmt-environment:1.1-centos7'
|
||||||
|
args '-u 0:0'
|
||||||
|
label 'DOCKER'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
NEXUS_PD_CREDS = credentials('jenkins-nexus-pd-creds')
|
||||||
|
NEXUS_PD_URL = 'https://cld-smact-02.pd.infn.it/artifacts/repository/muotom/devel/centos7/x86_64/'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
|
||||||
|
stage('Build') {
|
||||||
|
|
||||||
|
steps {
|
||||||
|
sh "mkdir build && cd build && cmake -DNODOXYGEN=ON .. && make rpm"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
stage('Deploy') {
|
||||||
|
|
||||||
|
steps {
|
||||||
|
sh "find . -name '*.x86_64.rpm' curl -v -k --user '${NEXUS_PD_CREDS_USR}:${NEXUS_PD_CREDS_PSW}' --upload-file '{}' ${NEXUS_PD_URL} ';'"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
63
README.md
Normal file
63
README.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# uLib
|
||||||
|
|
||||||
|
[](https://zenodo.org/badge/latestdoi/36926725)
|
||||||
|
|
||||||
|
base toolkit library
|
||||||
|
|
||||||
|
CMT Cosmic Muon Tomography reconstruction, analysis and imaging software
|
||||||
|
Developed by University of Padova and INFN Sezione di Padova Italy
|
||||||
|
|
||||||
|
## Build Instructions
|
||||||
|
|
||||||
|
This project relies on `conan` (v2) for dependency management (Eigen3, Boost) and `cmake` for configuration. VTK is provided through the micromamba/conda-forge environment.
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
This project requires a `conda` or `micromamba` environment containing the necessary global tools like **ROOT**, **VTK**, and **Conan** (v2). We provide a `condaenv.yml` file to quickly build this environment.
|
||||||
|
|
||||||
|
#### Installing Micromamba (Optional)
|
||||||
|
|
||||||
|
If you do not have `conda` installed, `micromamba` is a fast and lightweight alternative. You can install it on Linux via:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
"${SHELL}" <(curl -L micro.mamba.pm/install.sh)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Creating the Environment
|
||||||
|
|
||||||
|
You can create and activate the environment using either `micromamba` or `conda`.
|
||||||
|
|
||||||
|
**Using Micromamba:**
|
||||||
|
```bash
|
||||||
|
micromamba env create -f condaenv.yml
|
||||||
|
micromamba activate mutom
|
||||||
|
```
|
||||||
|
|
||||||
|
**Using Conda:**
|
||||||
|
```bash
|
||||||
|
conda env create -f condaenv.yml
|
||||||
|
conda activate mutom
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configure and Build
|
||||||
|
|
||||||
|
1. **Configure Conan profile (if you haven't yet on your machine):**
|
||||||
|
```bash
|
||||||
|
conan profile detect
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Install Conan dependencies:**
|
||||||
|
```bash
|
||||||
|
conan install . --output-folder=build --build=missing
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Configure the project with CMake:**
|
||||||
|
```bash
|
||||||
|
cmake --preset conan-release
|
||||||
|
```
|
||||||
|
*(Alternatively: `cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release`)*
|
||||||
|
|
||||||
|
4. **Build the project:**
|
||||||
|
```bash
|
||||||
|
cmake --build build -j10
|
||||||
|
```
|
||||||
36
build.log
Normal file
36
build.log
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
make: Entering directory '/home/rigoni/devel/cmt/ulib/build'
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/VoxImage.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/TriangleMesh.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Core/CMakeFiles/mutomCore.dir/Options.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/Dense.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/StructuredGrid.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/VoxRaytracer.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/StructuredData.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/Structured2DGrid.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/Structured4DGrid.cpp.o
|
||||||
|
[ 33%] Linking CXX shared library libmutomCore.so
|
||||||
|
[ 33%] Built target mutomCore
|
||||||
|
[ 36%] Linking CXX shared library libmutomMath.so
|
||||||
|
[ 36%] Built target mutomMath
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkContainerBox.cpp.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/uLibVtkInterface.cxx.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkStructuredGrid.cpp.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkMuonScatter.cxx.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/uLibVtkViewer.cpp.o
|
||||||
|
[ 63%] Generating mutomRootDict.cxx, libmutomRootDict_rdict.pcm, libmutomRootDict.rootmap
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkVoxImage.cpp.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkVoxRaytracerRepresentation.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorSkinHit.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorHit.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorMCTrack.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorInfo.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/RootMuonScatter.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorPrimaryVertex.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorMuDetDIGI.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/SkinDetectorWriter.cpp.o
|
||||||
|
[ 93%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/mutomRootDict.cxx.o
|
||||||
|
[ 96%] Linking CXX shared library libmutomVtk.so
|
||||||
|
[ 96%] Built target mutomVtk
|
||||||
|
[100%] Linking CXX shared library libmutomRoot.so
|
||||||
|
[100%] Built target mutomRoot
|
||||||
|
make: Leaving directory '/home/rigoni/devel/cmt/ulib/build'
|
||||||
7
conanfile.txt
Normal file
7
conanfile.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[requires]
|
||||||
|
eigen/3.4.0
|
||||||
|
boost/1.83.0
|
||||||
|
|
||||||
|
[generators]
|
||||||
|
CMakeDeps
|
||||||
|
CMakeToolchain
|
||||||
10
condaenv.yml
Normal file
10
condaenv.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
name: mutom
|
||||||
|
channels:
|
||||||
|
- conda-forge
|
||||||
|
dependencies:
|
||||||
|
- compiler-rt
|
||||||
|
- make
|
||||||
|
- cmake
|
||||||
|
- conan
|
||||||
|
- root
|
||||||
|
- vtk
|
||||||
@@ -1,46 +1,27 @@
|
|||||||
|
|
||||||
set(HEADERS
|
set(HEADERS Options.h
|
||||||
Archives.h
|
StaticInterface.h)
|
||||||
Array.h
|
|
||||||
Collection.h
|
set(SOURCES Options.cpp)
|
||||||
Debug.h
|
|
||||||
Export.h
|
set(LIBRARIES ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
||||||
Function.h
|
|
||||||
Macros.h
|
set(libname ${PACKAGE_LIBPREFIX}Core)
|
||||||
Mpl.h
|
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
||||||
Object.h
|
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Core PARENT_SCOPE)
|
||||||
ObjectProps.h
|
|
||||||
Options.h
|
add_library(${libname} SHARED ${SOURCES})
|
||||||
Serializable.h
|
set_target_properties(${libname} PROPERTIES
|
||||||
Signal.h
|
VERSION ${PROJECT_VERSION}
|
||||||
Singleton.h
|
SOVERSION ${PROJECT_SOVERSION})
|
||||||
SmartPointer.h
|
target_link_libraries(${libname} ${LIBRARIES})
|
||||||
StaticInterface.h
|
|
||||||
StringReader.h
|
install(TARGETS ${libname}
|
||||||
Types.h
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
Uuid.h
|
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
||||||
Vector.h
|
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib)
|
||||||
CommaInitializer.h
|
|
||||||
Timer.h
|
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Core)
|
||||||
)
|
|
||||||
|
|
||||||
SET(SOURCES
|
|
||||||
Archives.cpp
|
|
||||||
Object.cpp
|
|
||||||
Options.cpp
|
|
||||||
Serializable.cpp
|
|
||||||
Signal.cpp
|
|
||||||
Uuid.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(LIBRARIES
|
|
||||||
${Boost_SERIALIZATION_LIBRARY}
|
|
||||||
${Boost_SIGNALS_LIBRARY}
|
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
|
||||||
${ROOT_LIBRARIES}
|
|
||||||
${PACKAGE_LIBPREFIX}Core
|
|
||||||
${PACKAGE_LIBPREFIX}Math
|
|
||||||
)
|
|
||||||
|
|
||||||
uLib_add_shared_library(${uLib-module})
|
|
||||||
add_subdirectory(testing)
|
|
||||||
|
|||||||
@@ -29,12 +29,11 @@
|
|||||||
#define U_CORE_DEBUG_H
|
#define U_CORE_DEBUG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include "ltk/ltkdebug.h"
|
|
||||||
#include "Macros.h"
|
#include "Macros.h"
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Mpl.h"
|
#include "Mpl.h"
|
||||||
#include "Vector.h"
|
#include "SmartPointer.h"
|
||||||
|
|
||||||
#include <boost/any.hpp>
|
#include <boost/any.hpp>
|
||||||
#include <TObject.h>
|
#include <TObject.h>
|
||||||
@@ -128,8 +127,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<DItem> m_v;
|
std::vector<DItem> m_v;
|
||||||
Vector<Adapter> m_a;
|
std::vector<Adapter> m_a;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ library_include_HEADERS = \
|
|||||||
Macros.h \
|
Macros.h \
|
||||||
Mpl.h \
|
Mpl.h \
|
||||||
Object.h \
|
Object.h \
|
||||||
ObjectProps.h \
|
|
||||||
Options.h \
|
Options.h \
|
||||||
Serializable.h \
|
Serializable.h \
|
||||||
Signal.h \
|
Signal.h \
|
||||||
|
|||||||
@@ -23,178 +23,126 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
#include "boost/archive/polymorphic_xml_oarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_xml_iarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_text_oarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_text_iarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_binary_oarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_binary_iarchive.hpp"
|
#include "boost/archive/polymorphic_binary_iarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_binary_oarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_text_iarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_text_oarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_xml_iarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_xml_oarchive.hpp"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
const char *Version::PackageName = PACKAGE_NAME;
|
||||||
const char *Version::PackageName = PACKAGE_NAME;
|
|
||||||
const char *Version::VersionNumber = PACKAGE_VERSION;
|
const char *Version::VersionNumber = PACKAGE_VERSION;
|
||||||
const char *Version::Release = "x"; //SVN_REVISION;
|
const char *Version::Release = "x"; // SVN_REVISION;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Object Private //
|
// Object Private //
|
||||||
|
|
||||||
class ObjectPrivate {
|
class ObjectPrivate {
|
||||||
public:
|
public:
|
||||||
|
struct Signal {
|
||||||
|
GenericMFPtr sigptr;
|
||||||
|
std::string sigstr;
|
||||||
|
SignalBase *signal;
|
||||||
|
};
|
||||||
|
|
||||||
struct Signal {
|
struct Slot {
|
||||||
GenericMFPtr sigptr;
|
GenericMFPtr sloptr;
|
||||||
std::string sigstr;
|
std::string slostr;
|
||||||
SignalBase *signal;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
struct Slot {
|
Vector<Signal> sigv;
|
||||||
GenericMFPtr sloptr;
|
Vector<Slot> slov;
|
||||||
std::string slostr;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Vector<Signal> sigv;
|
|
||||||
Vector<Slot> slov;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// OBJECT IMPLEMENTATION
|
// OBJECT IMPLEMENTATION
|
||||||
|
|
||||||
|
Object::Object() : d(new ObjectPrivate) {}
|
||||||
|
|
||||||
|
Object::Object(const Object ©) : d(new ObjectPrivate(*copy.d)) {}
|
||||||
|
|
||||||
Object::Object() :
|
Object::~Object() { delete d; }
|
||||||
d(new ObjectPrivate)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Object::Object(const Object ©) :
|
void Object::DeepCopy(const Object ©) {
|
||||||
ObjectPropable(copy),
|
// should lock to be tread safe //
|
||||||
d(new ObjectPrivate(*copy.d))
|
memcpy(d, copy.d, sizeof(ObjectPrivate));
|
||||||
{}
|
// ERROR! does not copy parameters ... <<<< FIXXXXX
|
||||||
|
|
||||||
Object::~Object() {
|
|
||||||
delete d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::DeepCopy(const Object ©)
|
void Object::SaveXml(std::ostream &os, Object &ob) {
|
||||||
{
|
Archive::xml_oarchive ar(os);
|
||||||
// should lock to be tread safe //
|
ar << boost::serialization::make_nvp("Object", ob);
|
||||||
memcpy(d,copy.d,sizeof(ObjectPrivate));
|
|
||||||
// ERROR! does not copy parameters ... <<<< FIXXXXX
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::LoadXml(std::istream &is, Object &ob) {
|
||||||
|
Archive::xml_iarchive ar(is);
|
||||||
|
ar >> boost::serialization::make_nvp("Object", ob);
|
||||||
|
|
||||||
void Object::SaveXml(std::ostream &os, Object &ob)
|
|
||||||
{
|
|
||||||
Archive::xml_oarchive ar(os);
|
|
||||||
ar << boost::serialization::make_nvp("Object",ob);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::LoadXml(std::istream &is, Object &ob)
|
|
||||||
{
|
|
||||||
Archive::xml_iarchive ar(is);
|
|
||||||
ar >> boost::serialization::make_nvp("Object",ob);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// FINIRE
|
// FINIRE
|
||||||
void Object::SaveConfig(std::ostream &os, int version)
|
void Object::SaveConfig(std::ostream &os, int version) {
|
||||||
{
|
Archive::xml_oarchive ar(os);
|
||||||
Archive::xml_oarchive ar(os);
|
|
||||||
ObjectPropable::serialize(ar,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::LoadConfig(std::istream &is, int version)
|
void Object::LoadConfig(std::istream &is, int version) {
|
||||||
{
|
Archive::xml_iarchive ar(is);
|
||||||
if(!props()) this->init_properties();
|
|
||||||
Archive::xml_iarchive ar(is);
|
|
||||||
ObjectPropable::serialize(ar,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::PrintSelf(std::ostream &o) const {
|
||||||
|
o << "OBJECT signals: ------------------\n";
|
||||||
|
Vector<ObjectPrivate::Signal>::Iterator itr;
|
||||||
|
for (itr = d->sigv.begin(); itr < d->sigv.end(); itr++) {
|
||||||
void Object::PrintSelf(std::ostream &o) const
|
o << " signal:[ " << itr->sigstr << " ]\n";
|
||||||
{
|
}
|
||||||
o << "OBJECT signals: ------------------\n";
|
o << "--------------------------------------\n\n";
|
||||||
Vector<ObjectPrivate::Signal>::Iterator itr;
|
|
||||||
for(itr = d->sigv.begin(); itr<d->sigv.end(); itr++)
|
|
||||||
{
|
|
||||||
o << " signal:[ " << itr->sigstr << " ]\n";
|
|
||||||
}
|
|
||||||
o << "--------------------------------------\n\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Object::addSignalImpl(SignalBase *sig, GenericMFPtr fptr,
|
||||||
bool Object::addSignalImpl(SignalBase *sig, GenericMFPtr fptr, const char *name)
|
const char *name) {
|
||||||
{
|
ObjectPrivate::Signal s = {fptr, std::string(name), sig};
|
||||||
ObjectPrivate::Signal s = {fptr,std::string(name),sig};
|
d->sigv.push_back(s);
|
||||||
d->sigv.push_back(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Object::addSlotImpl(GenericMFPtr fptr, const char *name)
|
bool Object::addSlotImpl(GenericMFPtr fptr, const char *name) {
|
||||||
{
|
ObjectPrivate::Slot s = {fptr, std::string(name)};
|
||||||
ObjectPrivate::Slot s = {fptr,std::string(name)};
|
d->slov.push_back(s);
|
||||||
d->slov.push_back(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalBase *Object::findSignalImpl(const GenericMFPtr &fptr) const
|
SignalBase *Object::findSignalImpl(const GenericMFPtr &fptr) const {
|
||||||
{
|
for (int i = 0; i < d->sigv.size(); ++i) {
|
||||||
for(int i=0; i<d->sigv.size(); ++i)
|
if (d->sigv[i].sigptr == fptr)
|
||||||
{
|
return d->sigv[i].signal;
|
||||||
if(d->sigv[i].sigptr == fptr)
|
}
|
||||||
return d->sigv[i].signal;
|
return NULL;
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalBase *Object::findSignalImpl(const char *name) const
|
SignalBase *Object::findSignalImpl(const char *name) const {
|
||||||
{
|
std::string in(name);
|
||||||
std::string in(name);
|
for (int i = 0; i < d->sigv.size(); ++i) {
|
||||||
for(int i=0; i<d->sigv.size(); ++i)
|
if (d->sigv[i].sigstr == in)
|
||||||
{
|
return d->sigv[i].signal;
|
||||||
if(d->sigv[i].sigstr == in)
|
}
|
||||||
return d->sigv[i].signal;
|
return NULL;
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericMFPtr *Object::findSlotImpl(const char *name) const
|
GenericMFPtr *Object::findSlotImpl(const char *name) const {
|
||||||
{
|
std::string in(name);
|
||||||
std::string in(name);
|
for (int i = 0; i < d->slov.size(); ++i) {
|
||||||
for(int i=0; i<d->slov.size(); ++i)
|
if (d->slov[i].slostr == in)
|
||||||
{
|
return &d->slov[i].sloptr;
|
||||||
if(d->slov[i].slostr == in)
|
}
|
||||||
return &d->slov[i].sloptr;
|
return NULL;
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// std::ostream &
|
// std::ostream &
|
||||||
// operator << (std::ostream &os, uLib::Object &ob)
|
// operator << (std::ostream &os, uLib::Object &ob)
|
||||||
// {
|
// {
|
||||||
@@ -218,10 +166,4 @@ GenericMFPtr *Object::findSlotImpl(const char *name) const
|
|||||||
// return is;
|
// return is;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,200 +23,183 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_CORE_OBJECT_H
|
#ifndef U_CORE_OBJECT_H
|
||||||
#define U_CORE_OBJECT_H
|
#define U_CORE_OBJECT_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// WARNING: COPILE ERROR if this goes after mpl/vector //
|
// WARNING: COPILE ERROR if this goes after mpl/vector //
|
||||||
//#include "Core/Vector.h"
|
// #include "Core/Vector.h"
|
||||||
|
|
||||||
#include "Core/Types.h"
|
|
||||||
#include "Core/Debug.h"
|
#include "Core/Debug.h"
|
||||||
|
#include "Core/Types.h"
|
||||||
|
|
||||||
#include "Core/Function.h"
|
#include "Core/Function.h"
|
||||||
#include "Core/Signal.h"
|
#include "Core/Signal.h"
|
||||||
|
|
||||||
#include "Core/Mpl.h"
|
#include "Core/Mpl.h"
|
||||||
#include "Core/Serializable.h"
|
#include "Core/Serializable.h"
|
||||||
#include "Core/ObjectProps.h"
|
|
||||||
#include "Core/Uuid.h"
|
#include "Core/Uuid.h"
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace archive {
|
namespace archive {
|
||||||
class polymorphic_iarchive;
|
class polymorphic_iarchive;
|
||||||
class polymorphic_oarchive;
|
class polymorphic_oarchive;
|
||||||
} // archive
|
} // namespace archive
|
||||||
} // boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
class Version {
|
class Version {
|
||||||
public:
|
public:
|
||||||
static const char *PackageName;
|
static const char *PackageName;
|
||||||
static const char *VersionNumber;
|
static const char *VersionNumber;
|
||||||
static const char *Release;
|
static const char *Release;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//// OBJECT ////////////////////////////////////////////////////////////////////
|
//// OBJECT ////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Object class is the object base implementation for uLib Framework.
|
* @brief Object class is the object base implementation for uLib Framework.
|
||||||
*/
|
*/
|
||||||
class Object : public ObjectPropable
|
class Object {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// std::string name;
|
// std::string name;
|
||||||
// void PrintName() { std::cout << "Ob name: " << name << "\n"; }
|
// void PrintName() { std::cout << "Ob name: " << name << "\n"; }
|
||||||
|
|
||||||
Object();
|
Object();
|
||||||
Object(const Object ©);
|
Object(const Object ©);
|
||||||
~Object();
|
~Object();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// PARAMETERS //
|
// PARAMETERS //
|
||||||
|
|
||||||
// FIXX !!!
|
// FIXX !!!
|
||||||
virtual void DeepCopy(const Object ©);
|
virtual void DeepCopy(const Object ©);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// SERIALIZATION //
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
template <class ArchiveT>
|
||||||
// SERIALIZATION //
|
void serialize(ArchiveT &ar, const unsigned int version) {}
|
||||||
|
template <class ArchiveT>
|
||||||
|
void save_override(ArchiveT &ar, const unsigned int version) {}
|
||||||
|
|
||||||
template <class ArchiveT> void serialize(ArchiveT &ar, const unsigned int version) {
|
void SaveConfig(std::ostream &os, int version = 0);
|
||||||
ObjectPropable::serialize(ar,version);
|
void LoadConfig(std::istream &is, int version = 0);
|
||||||
|
|
||||||
|
static void SaveXml(std::ostream &os, Object &ob);
|
||||||
|
static void LoadXml(std::istream &is, Object &ob);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// SIGNALS //
|
||||||
|
|
||||||
|
// Qt4 style connector //
|
||||||
|
static bool connect(const Object *ob1, const char *signal_name,
|
||||||
|
const Object *receiver, const char *slot_name) {
|
||||||
|
// // NOT WORKING YET //
|
||||||
|
// 1) find slot pointer from name
|
||||||
|
// SignalBase *sig = ob1->findSignal(signal_name);
|
||||||
|
// GenericMFPtr *slo = receiver->findSlot(slot_name);
|
||||||
|
// if(sig && slo)
|
||||||
|
// return Object::connect(sig,slo->operator ()(),receiver);
|
||||||
|
// else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Qt5 style connector //
|
||||||
|
template <typename Func1, typename Func2>
|
||||||
|
static bool
|
||||||
|
connect(typename FunctionPointer<Func1>::Object *sender, Func1 sigf,
|
||||||
|
typename FunctionPointer<Func2>::Object *receiver, Func2 slof) {
|
||||||
|
SignalBase *sigb = sender->findOrAddSignal(sigf);
|
||||||
|
typedef boost::signals2::signal<
|
||||||
|
typename FunctionPointer<Func2>::SignalSignature>
|
||||||
|
SigT;
|
||||||
|
ConnectSignal(sigb, slof, receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FuncT>
|
||||||
|
static inline bool connect(SignalBase *sigb, FuncT slof, Object *receiver) {
|
||||||
|
ConnectSignal(sigb, slof, receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FuncT>
|
||||||
|
inline
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
||||||
|
addSignal(FuncT fun, const char *name) {
|
||||||
|
typedef
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
|
||||||
|
SigT;
|
||||||
|
SignalBase *sig = NewSignal(fun);
|
||||||
|
addSignalImpl(sig, fun, name);
|
||||||
|
return (SigT *)sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FuncT> inline bool addSlot(FuncT fun, const char *name) {
|
||||||
|
this->addSlotImpl(GenericMFPtr(fun), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FuncT>
|
||||||
|
inline
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
||||||
|
findSignal(FuncT fptr) {
|
||||||
|
typedef
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
|
||||||
|
SigT;
|
||||||
|
return (SigT *)findSignalImpl(GenericMFPtr(fptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FuncT>
|
||||||
|
inline
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
||||||
|
findOrAddSignal(FuncT fptr) {
|
||||||
|
typedef
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
|
||||||
|
SigT;
|
||||||
|
SignalBase *sig = findSignalImpl(GenericMFPtr(fptr));
|
||||||
|
if (!sig) {
|
||||||
|
sig = NewSignal(fptr);
|
||||||
|
addSignalImpl(sig, fptr, "signal_name_to_be_implemented");
|
||||||
}
|
}
|
||||||
template <class ArchiveT> void save_override(ArchiveT &ar,const unsigned int version) {}
|
return (SigT *)sig;
|
||||||
|
}
|
||||||
|
|
||||||
void SaveConfig(std::ostream &os, int version = 0);
|
inline SignalBase *findSignal(const char *name) const {
|
||||||
void LoadConfig(std::istream &is, int version = 0);
|
return findSignalImpl(name);
|
||||||
|
}
|
||||||
|
|
||||||
static void SaveXml(std::ostream &os, Object &ob);
|
inline GenericMFPtr *findSlot(const char *name) const {
|
||||||
static void LoadXml(std::istream &is, Object &ob);
|
return findSlotImpl(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintSelf(std::ostream &o) const;
|
||||||
|
|
||||||
|
inline const Object &operator=(const Object ©) {
|
||||||
////////////////////////////////////////////////////////////////////////////
|
this->DeepCopy(copy);
|
||||||
// SIGNALS //
|
return *this;
|
||||||
|
}
|
||||||
// Qt4 style connector //
|
|
||||||
static bool connect(const Object *ob1, const char *signal_name, const Object *receiver, const char *slot_name) {
|
|
||||||
// // NOT WORKING YET //
|
|
||||||
// 1) find slot pointer from name
|
|
||||||
// SignalBase *sig = ob1->findSignal(signal_name);
|
|
||||||
// GenericMFPtr *slo = receiver->findSlot(slot_name);
|
|
||||||
// if(sig && slo)
|
|
||||||
// return Object::connect(sig,slo->operator ()(),receiver);
|
|
||||||
// else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Qt5 style connector //
|
|
||||||
template <typename Func1, typename Func2>
|
|
||||||
static bool connect( typename FunctionPointer<Func1>::Object *sender, Func1 sigf,
|
|
||||||
typename FunctionPointer<Func2>::Object *receiver, Func2 slof)
|
|
||||||
{
|
|
||||||
SignalBase *sigb = sender->findOrAddSignal(sigf);
|
|
||||||
typedef boost::signals2::signal<typename FunctionPointer<Func2>::SignalSignature> SigT;
|
|
||||||
ConnectSignal(sigb,slof,receiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FuncT>
|
|
||||||
static inline bool connect(SignalBase *sigb, FuncT slof, Object *receiver) {
|
|
||||||
ConnectSignal(sigb,slof,receiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template< typename FuncT >
|
|
||||||
inline typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
|
||||||
addSignal(FuncT fun, const char *name) {
|
|
||||||
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT;
|
|
||||||
SignalBase *sig = NewSignal(fun);
|
|
||||||
addSignalImpl(sig,fun,name);
|
|
||||||
return (SigT *)sig;
|
|
||||||
}
|
|
||||||
|
|
||||||
template< typename FuncT>
|
|
||||||
inline bool addSlot(FuncT fun, const char *name) {
|
|
||||||
this->addSlotImpl(GenericMFPtr(fun),name);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename FuncT >
|
|
||||||
inline typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
|
||||||
findSignal(FuncT fptr)
|
|
||||||
{
|
|
||||||
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT;
|
|
||||||
return (SigT *)findSignalImpl(GenericMFPtr(fptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename FuncT >
|
|
||||||
inline typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
|
||||||
findOrAddSignal(FuncT fptr)
|
|
||||||
{
|
|
||||||
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT;
|
|
||||||
SignalBase *sig = findSignalImpl(GenericMFPtr(fptr));
|
|
||||||
if(!sig) {
|
|
||||||
sig = NewSignal(fptr);
|
|
||||||
addSignalImpl(sig,fptr,"signal_name_to_be_implemented");
|
|
||||||
}
|
|
||||||
return (SigT *)sig;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline SignalBase *
|
|
||||||
findSignal(const char *name) const
|
|
||||||
{
|
|
||||||
return findSignalImpl(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline GenericMFPtr *
|
|
||||||
findSlot(const char *name) const
|
|
||||||
{
|
|
||||||
return findSlotImpl(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PrintSelf(std::ostream &o) const;
|
|
||||||
|
|
||||||
inline const Object& operator = (const Object ©)
|
|
||||||
{ this->DeepCopy(copy); return *this; }
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool addSignalImpl(SignalBase *sig, GenericMFPtr fptr, const char *name);
|
bool addSignalImpl(SignalBase *sig, GenericMFPtr fptr, const char *name);
|
||||||
bool addSlotImpl(GenericMFPtr fptr, const char *name);
|
bool addSlotImpl(GenericMFPtr fptr, const char *name);
|
||||||
SignalBase *findSignalImpl(const GenericMFPtr &fptr) const;
|
SignalBase *findSignalImpl(const GenericMFPtr &fptr) const;
|
||||||
SignalBase *findSignalImpl(const char *name) const;
|
SignalBase *findSignalImpl(const char *name) const;
|
||||||
GenericMFPtr *findSlotImpl(const char *name) const;
|
GenericMFPtr *findSlotImpl(const char *name) const;
|
||||||
|
|
||||||
friend class boost::serialization::access;
|
friend class boost::serialization::access;
|
||||||
friend class ObjectPrivate;
|
friend class ObjectPrivate;
|
||||||
class ObjectPrivate *d;
|
class ObjectPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//std::ostream & operator << (std::ostream &os, uLib::Object &ob);
|
// std::ostream & operator << (std::ostream &os, uLib::Object &ob);
|
||||||
//std::ostream & operator << (std::ostream &os, uLib::Object *ob);
|
// std::ostream & operator << (std::ostream &os, uLib::Object *ob);
|
||||||
//std::istream & operator >> (std::istream &is, uLib::Object &ob);
|
// std::istream & operator >> (std::istream &is, uLib::Object &ob);
|
||||||
|
|
||||||
|
|
||||||
#endif // U_OBJECT_H
|
#endif // U_OBJECT_H
|
||||||
|
|||||||
@@ -1,278 +0,0 @@
|
|||||||
/*//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
|
||||||
All rights reserved
|
|
||||||
|
|
||||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
|
||||||
|
|
||||||
------------------------------------------------------------------
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library.
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_OBJECTPROPS_H
|
|
||||||
#define U_OBJECTPROPS_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
|
||||||
|
|
||||||
#include <Core/Mpl.h>
|
|
||||||
#include <Core/Types.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// MACROS //
|
|
||||||
|
|
||||||
|
|
||||||
#define ULIB_props() \
|
|
||||||
public: struct ObjectProps; \
|
|
||||||
virtual void init_properties(); \
|
|
||||||
inline struct ObjectProps &p() { /* static const unsigned int offset = props_offset(this); */ \
|
|
||||||
/* NON FUNZIA! return * (struct ObjectProps *)(reinterpret_cast<char*>(props())+offset); */ \
|
|
||||||
return *props()->ptr<ObjectProps>(); } \
|
|
||||||
typedef uLib::mpl::bool_<true>::type propable_trait; \
|
|
||||||
public: struct DLL_PUBLIC ObjectProps
|
|
||||||
|
|
||||||
#define properties() ULIB_props()
|
|
||||||
|
|
||||||
#define default(vlaue)
|
|
||||||
|
|
||||||
#define $$ p()
|
|
||||||
|
|
||||||
#define $(_name) props_ref<_name>()
|
|
||||||
|
|
||||||
#define $_init() \
|
|
||||||
if(props(this)) return; \
|
|
||||||
props_new(this); \
|
|
||||||
uLib::detail::ObjectProps::initializer::init_object_baselist(this);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
namespace serialization {
|
|
||||||
class access;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
struct ObjectProps {
|
|
||||||
|
|
||||||
/** Define a trait has_member to find if an Object is Propable*/
|
|
||||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(propable_trait)
|
|
||||||
|
|
||||||
/** IsA ProbapleObject Implementation Template */
|
|
||||||
template <class T>
|
|
||||||
struct IsA : has_propable_trait<T> {};
|
|
||||||
|
|
||||||
/** Lambda to get Props member type */
|
|
||||||
template <class T>
|
|
||||||
struct props_type {
|
|
||||||
typedef typename T::ObjectProps type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct get_props {
|
|
||||||
|
|
||||||
/** CFList has result but this method check for has BaseList */
|
|
||||||
typedef typename detail::TypeIntrospection::child_first<T>::type CFTypeList;
|
|
||||||
|
|
||||||
/** Filter List items that have not Propable feature */
|
|
||||||
typedef typename mpl::filter_view< CFTypeList, IsA<mpl::_> >::type FilteredCFTypeList;
|
|
||||||
|
|
||||||
/** Get Props from each Parent in Seq */
|
|
||||||
typedef typename mpl::transform_view< FilteredCFTypeList, props_type<mpl::_> >::type type;
|
|
||||||
|
|
||||||
|
|
||||||
// qui sotto ho un problema che ho temporaneamente tamponato //
|
|
||||||
// ovvero ho usato child_first_impl per ottenere la lista delle basi //
|
|
||||||
// vorrei farlo facendo un pop_back ma non va forse perche il tipo //
|
|
||||||
// non e' corretto. //
|
|
||||||
|
|
||||||
/** Get Parent list from CFTypeList */
|
|
||||||
typedef typename detail::TypeIntrospection::child_first_impl<T>::Childs CFBaseList;
|
|
||||||
|
|
||||||
/** Filter Parents that have not Propable feature */
|
|
||||||
typedef typename mpl::filter_view< CFBaseList, IsA<mpl::_> >::type FilteredCFBaseList;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: convert to pp const value,
|
|
||||||
// (non so se sia possibile con il dinamic casting intanto funziona cosi' )
|
|
||||||
template <typename T1, typename T2>
|
|
||||||
static unsigned int measure_offset(T1 base, T2 derived) {
|
|
||||||
return reinterpret_cast<char*>(derived) - reinterpret_cast<char*>(base);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct initializer {
|
|
||||||
|
|
||||||
template <class _ObjectT>
|
|
||||||
struct lambda_init_object {
|
|
||||||
_ObjectT *o;
|
|
||||||
lambda_init_object(_ObjectT *o) : o(o) {}
|
|
||||||
template<class T> void operator()(T) {
|
|
||||||
o->T::init_properties();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This calls the internal init_properties() virtual function for each
|
|
||||||
* object parent defined in BaseList only if it is propable
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
static void init_object_baselist(T *o) {
|
|
||||||
typedef typename uLib::detail::ObjectProps::get_props<T>::FilteredCFBaseList CFBaseList;
|
|
||||||
mpl::for_each<CFBaseList>(lambda_init_object<T>(o));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This calls the internal init_properties() virtual function only if
|
|
||||||
* object is propable ( implementation if not propable )
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
static
|
|
||||||
typename boost::enable_if<mpl::not_<IsA<T> >,void>::type
|
|
||||||
init_object(T *o) {
|
|
||||||
; // do nothing //
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This calls the internal init_properties() virtual function only if
|
|
||||||
* object is propable ( implementation if propable )
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
static
|
|
||||||
typename boost::enable_if<IsA<T>,void>::type
|
|
||||||
init_object(T *o) {
|
|
||||||
o->init_properties();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class ThisClass, class Archive>
|
|
||||||
struct serialize_baselist {
|
|
||||||
ThisClass & m_object;
|
|
||||||
Archive & m_ar;
|
|
||||||
serialize_baselist(ThisClass &o, Archive &ar) : m_object(o), m_ar(ar) {}
|
|
||||||
template <class T> void operator()(T &o) {
|
|
||||||
// T is taken fron get_props<BaseList>::FilteredPList types to get
|
|
||||||
// type_info_name that is the type name defined by Type macro
|
|
||||||
typedef typename props_type<T>::type PType;
|
|
||||||
std::string name(TypeIntrospection::access<T>::type_info::name);
|
|
||||||
boost::algorithm::replace_all(name,"::","_");
|
|
||||||
m_ar & boost::serialization::make_nvp(
|
|
||||||
name.c_str() ,
|
|
||||||
boost::serialization::base_object<PType>(m_object));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct ObjectPropsBase {
|
|
||||||
virtual ~ObjectPropsBase() {}
|
|
||||||
virtual ObjectPropsBase *copy() = 0;
|
|
||||||
|
|
||||||
template <class T> inline T *ptr() { return dynamic_cast<T*>(this); }
|
|
||||||
|
|
||||||
template<class ArchiveT> void serialize(ArchiveT &ar, const unsigned int version) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct ObjectPropsImpl :
|
|
||||||
ObjectPropsBase,
|
|
||||||
ULIB_MPL_INHERIT_NOFOLD_SEQ(typename uLib::detail::ObjectProps::get_props<T>::type)
|
|
||||||
{
|
|
||||||
typedef ObjectPropsImpl<T> ThisClass;
|
|
||||||
typedef typename uLib::detail::ObjectProps::get_props<T>::type CFList;
|
|
||||||
typedef typename uLib::detail::ObjectProps::get_props<T>::FilteredCFTypeList FilteredCFTypeList;
|
|
||||||
ObjectPropsBase *copy() { return new ThisClass(*this); }
|
|
||||||
|
|
||||||
template<class ArchiveT> void serialize(ArchiveT &ar, const unsigned int version) {
|
|
||||||
boost::serialization::void_cast_register<ThisClass,ObjectPropsBase>();
|
|
||||||
mpl::for_each<FilteredCFTypeList>(detail::ObjectProps::serialize_baselist<ThisClass,ArchiveT>(*this,ar));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectPropable {
|
|
||||||
|
|
||||||
ObjectPropsBase *m_props;
|
|
||||||
friend class uLib::detail::ObjectProps;
|
|
||||||
friend class boost::serialization::access;
|
|
||||||
public:
|
|
||||||
ObjectPropable() : m_props(NULL) {}
|
|
||||||
ObjectPropable(const ObjectPropable &c) { if(c.m_props) m_props = c.m_props->copy(); else m_props = NULL; }
|
|
||||||
~ObjectPropable() { if(m_props) delete m_props; }
|
|
||||||
|
|
||||||
|
|
||||||
template <class T> inline typename T::ObjectProps& props_ref() const { if(m_props) return *m_props->ptr<typename T::ObjectProps>(); else exit(1); }
|
|
||||||
template <class T> inline typename T::ObjectProps* props(T *ptr = NULL) const { if(m_props) return m_props->ptr<typename T::ObjectProps>(); else return NULL; }
|
|
||||||
protected:
|
|
||||||
ObjectPropsBase *props() const { return m_props; }
|
|
||||||
template <class T> inline void props_new(T* ptr = NULL) { if(!m_props) m_props = new ObjectPropsImpl<T>; }
|
|
||||||
|
|
||||||
/** NOT working dynamic cache casting */
|
|
||||||
template <class T> inline unsigned int props_offset(T *ptr) const
|
|
||||||
{ if(m_props) return detail::ObjectProps::measure_offset(m_props,m_props->ptr<T>()); else return -1; }
|
|
||||||
|
|
||||||
|
|
||||||
template<class ArchiveT> void serialize(ArchiveT &ar, const unsigned int version) {
|
|
||||||
if(m_props) ar & boost::serialization::make_nvp("properties",m_props);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* ObjectPropable is not directly propable itself to prevent Basclass
|
|
||||||
* duplication in inherit_nofold. And for the same reason ANY VIRTUAL BASE
|
|
||||||
* SHOULD NOT BE PROPABLE
|
|
||||||
*/
|
|
||||||
virtual void init_properties() {}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // U_OBJECTPROPS_H
|
|
||||||
@@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
|
#include <boost/property_tree/ptree.hpp>
|
||||||
|
#include <boost/property_tree/ini_parser.hpp>
|
||||||
|
|
||||||
|
|
||||||
//class boost::program_options::error_with_option_name;
|
//class boost::program_options::error_with_option_name;
|
||||||
//template<> boost::program_options::typed_value<int> boost::program_options::value<int>();
|
//template<> boost::program_options::typed_value<int> boost::program_options::value<int>();
|
||||||
@@ -74,6 +77,23 @@ void Options::parse_config_file(const char *fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Options::save_config_file(const char *fname) {
|
||||||
|
std::ofstream os;
|
||||||
|
os.open(fname);
|
||||||
|
|
||||||
|
using boost::property_tree::ptree;
|
||||||
|
|
||||||
|
ptree root;
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << m_configuration << "\n";
|
||||||
|
std::cout << m_global << "\n";
|
||||||
|
|
||||||
|
write_ini( std::cout, root );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Options::count(const char *str) const
|
bool Options::count(const char *str) const
|
||||||
{
|
{
|
||||||
return (m_vm.count(str));
|
return (m_vm.count(str));
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ public:
|
|||||||
|
|
||||||
void parse_config_file(const char *fname);
|
void parse_config_file(const char *fname);
|
||||||
|
|
||||||
|
void save_config_file(const char *fname);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline boost::program_options::typed_value<T>* value(T *v, T dvalue) {
|
static inline boost::program_options::typed_value<T>* value(T *v, T dvalue) {
|
||||||
boost::program_options::typed_value<T> *r = boost::program_options::value<T>(v);
|
boost::program_options::typed_value<T> *r = boost::program_options::value<T>(v);
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_SERIALIZABLE_H
|
#ifndef U_SERIALIZABLE_H
|
||||||
#define U_SERIALIZABLE_H
|
#define U_SERIALIZABLE_H
|
||||||
|
|
||||||
@@ -38,9 +36,6 @@ TODO:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <boost/serialization/access.hpp>
|
#include <boost/serialization/access.hpp>
|
||||||
#include <boost/serialization/export.hpp>
|
#include <boost/serialization/export.hpp>
|
||||||
|
|
||||||
@@ -48,26 +43,22 @@ TODO:
|
|||||||
#include <boost/mpl/remove_if.hpp>
|
#include <boost/mpl/remove_if.hpp>
|
||||||
#include <boost/serialization/nvp.hpp>
|
#include <boost/serialization/nvp.hpp>
|
||||||
|
|
||||||
//#include <boost/archive/xml_iarchive.hpp>
|
// #include <boost/archive/xml_iarchive.hpp>
|
||||||
//#include <boost/archive/xml_oarchive.hpp>
|
// #include <boost/archive/xml_oarchive.hpp>
|
||||||
//#include <boost/archive/text_iarchive.hpp>
|
// #include <boost/archive/text_iarchive.hpp>
|
||||||
//#include <boost/archive/text_oarchive.hpp>
|
// #include <boost/archive/text_oarchive.hpp>
|
||||||
//#include "boost/archive/polymorphic_iarchive.hpp"
|
// #include "boost/archive/polymorphic_iarchive.hpp"
|
||||||
//#include "boost/archive/polymorphic_oarchive.hpp"
|
// #include "boost/archive/polymorphic_oarchive.hpp"
|
||||||
|
|
||||||
#include <boost/preprocessor/comma_if.hpp>
|
|
||||||
#include <boost/preprocessor/repeat.hpp>
|
|
||||||
#include <boost/preprocessor/inc.hpp>
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
#include <boost/preprocessor/comma_if.hpp>
|
||||||
|
#include <boost/preprocessor/inc.hpp>
|
||||||
|
#include <boost/preprocessor/repeat.hpp>
|
||||||
#include <boost/preprocessor/tuple/to_seq.hpp>
|
#include <boost/preprocessor/tuple/to_seq.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include "Core/Mpl.h"
|
|
||||||
#include "Core/ObjectProps.h"
|
|
||||||
#include "Core/Archives.h"
|
#include "Core/Archives.h"
|
||||||
#include "Core/Export.h"
|
#include "Core/Export.h"
|
||||||
|
#include "Core/Mpl.h"
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -80,63 +71,47 @@ namespace serialization {
|
|||||||
// ACCESS 2 //
|
// ACCESS 2 //
|
||||||
template <class T> struct access2 {};
|
template <class T> struct access2 {};
|
||||||
|
|
||||||
|
|
||||||
// NON FUNZIONA ... SISTEMARE !!!! // ------------------------------------------
|
// NON FUNZIONA ... SISTEMARE !!!! // ------------------------------------------
|
||||||
template<class T>
|
template <class T> class hrp : public wrapper_traits<const hrp<T>> {
|
||||||
class hrp :
|
const char *m_name;
|
||||||
public wrapper_traits<const hrp< T > >
|
T *m_value;
|
||||||
{
|
std::string *m_str;
|
||||||
const char *m_name;
|
|
||||||
T *m_value;
|
|
||||||
std::string *m_str;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit hrp(const char * name_, T &t) :
|
explicit hrp(const char *name_, T &t)
|
||||||
m_str(new std::string),
|
: m_str(new std::string), m_name(name_), m_value(&t) {}
|
||||||
m_name(name_), m_value(&t) {}
|
|
||||||
|
|
||||||
const char * name() const {
|
const char *name() const { return this->m_name; }
|
||||||
return this->m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
template <class Archivex>
|
||||||
template<class Archivex>
|
void save(Archivex &ar, const unsigned int /* file_version */) const {
|
||||||
void save( Archivex & ar, const unsigned int /* file_version */) const {
|
//// ar.operator<<(const_value());
|
||||||
//// ar.operator<<(const_value());
|
// std::stringstream ss;
|
||||||
// std::stringstream ss;
|
// uLib::Archive::hrt_oarchive har(ss);
|
||||||
// uLib::Archive::hrt_oarchive har(ss);
|
// har << make_nvp(m_name,*m_value);
|
||||||
// har << make_nvp(m_name,*m_value);
|
// // (*m_str) = ss.str();
|
||||||
// // (*m_str) = ss.str();
|
//// ar.operator << (make_nvp(m_name, ss.str());
|
||||||
//// ar.operator << (make_nvp(m_name, ss.str());
|
}
|
||||||
}
|
template <class Archivex>
|
||||||
template<class Archivex>
|
void load(Archivex &ar, const unsigned int /* file_version */) {
|
||||||
void load( Archivex & ar, const unsigned int /* file_version */) {
|
// ar.operator>>(value());
|
||||||
// ar.operator>>(value());
|
}
|
||||||
}
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
||||||
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
template<class T>
|
|
||||||
inline
|
inline
|
||||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||||
const
|
const
|
||||||
#endif
|
#endif
|
||||||
hrp< T > make_hrp(const char * name, T & t){
|
hrp<T> make_hrp(const char *name, T &t) {
|
||||||
return hrp< T >(name, t);
|
return hrp<T>(name, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HRP(name) \
|
#define HRP(name) boost::serialization::make_hrp(BOOST_PP_STRINGIZE(name), name)
|
||||||
boost::serialization::make_hrp(BOOST_PP_STRINGIZE(name), name)
|
|
||||||
|
|
||||||
|
|
||||||
} // serialization
|
|
||||||
} // boost
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace serialization
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -151,9 +126,7 @@ hrp< T > make_hrp(const char * name, T & t){
|
|||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
#define _AR_OP(r, data, elem) data &BOOST_SERIALIZATION_BASE_OBJECT_NVP(elem);
|
||||||
|
|
||||||
#define _AR_OP(r,data,elem) data&BOOST_SERIALIZATION_BASE_OBJECT_NVP(elem);
|
|
||||||
|
|
||||||
#define NVP(data) BOOST_SERIALIZATION_NVP(data)
|
#define NVP(data) BOOST_SERIALIZATION_NVP(data)
|
||||||
|
|
||||||
@@ -166,51 +139,53 @@ namespace uLib {
|
|||||||
// SO LEAVE ULIB_CFG_INTRUSIVE_SERIALIZATION NOT DEFINED
|
// SO LEAVE ULIB_CFG_INTRUSIVE_SERIALIZATION NOT DEFINED
|
||||||
|
|
||||||
#ifdef ULIB_CFG_INTRUSIVE_SERIALIZATION_OBJECT
|
#ifdef ULIB_CFG_INTRUSIVE_SERIALIZATION_OBJECT
|
||||||
# define ULIB_SERIALIZABLE_OBJECT _ULIB_DETAIL_INTRUSIVE_SERIALIZABLE_OBJECT
|
#define ULIB_SERIALIZABLE_OBJECT _ULIB_DETAIL_INTRUSIVE_SERIALIZABLE_OBJECT
|
||||||
# define ULIB_SERIALIZE_OBJECT(_Ob,...) _ULIB_DETAIL_INTRUSIVE_SERIALIZE_OBJECT(_Ob,__VA_ARGS__)
|
#define ULIB_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
# define _AR_(_name) _ULIB_DETAIL_INTRUSIVE_AR_(_name)
|
_ULIB_DETAIL_INTRUSIVE_SERIALIZE_OBJECT(_Ob, __VA_ARGS__)
|
||||||
|
#define _AR_(_name) _ULIB_DETAIL_INTRUSIVE_AR_(_name)
|
||||||
#else
|
#else
|
||||||
# define ULIB_SERIALIZABLE(_Ob) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE(_Ob) \
|
#define ULIB_SERIALIZABLE(_Ob) \
|
||||||
ULIB_CLASS_EXPORT_KEY(_Ob)
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE(_Ob) \
|
||||||
# define ULIB_SERIALIZE(_Ob,...) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE(_Ob)
|
ULIB_CLASS_EXPORT_KEY(_Ob)
|
||||||
# define ULIB_SERIALIZE_DERIVED(_Ob,...) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_DERIVED(_Ob,__VA_ARGS__)
|
#define ULIB_SERIALIZE(_Ob, ...) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE(_Ob)
|
||||||
# define ULIB_SERIALIZABLE_OBJECT(_Ob) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE_OBJECT(_Ob) \
|
#define ULIB_SERIALIZE_DERIVED(_Ob, ...) \
|
||||||
ULIB_CLASS_EXPORT_OBJECT_KEY(_Ob)
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_DERIVED(_Ob, __VA_ARGS__)
|
||||||
# define ULIB_SERIALIZE_OBJECT(_Ob,...) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob,__VA_ARGS__)
|
#define ULIB_SERIALIZABLE_OBJECT(_Ob) \
|
||||||
# define ULIB_SERIALIZE_OBJECT_PROPS(_Ob) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_PROPS(_Ob)
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE_OBJECT(_Ob) \
|
||||||
# define AR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
ULIB_CLASS_EXPORT_OBJECT_KEY(_Ob)
|
||||||
# define HR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
#define ULIB_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob, __VA_ARGS__)
|
||||||
|
#define AR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
||||||
|
#define HR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ULIB_SERIALIZE_ACCESS \
|
||||||
|
friend class boost::serialization::access; \
|
||||||
|
template <class T> friend class boost::serialization::access2;
|
||||||
|
|
||||||
#define ULIB_SERIALIZE_ACCESS \
|
#define ULIB_CLASS_EXPORT_KEY(_FullNamespaceClass) \
|
||||||
friend class boost::serialization::access; \
|
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass)
|
||||||
template <class T> friend class boost::serialization::access2;
|
|
||||||
|
|
||||||
#define ULIB_CLASS_EXPORT_KEY(_FullNamespaceClass) \
|
#define ULIB_CLASS_EXPORT_OBJECT_KEY(_FullNamespaceClass) \
|
||||||
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass)
|
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass)
|
||||||
|
|
||||||
#define ULIB_CLASS_EXPORT_OBJECT_KEY(_FullNamespaceClass) \
|
|
||||||
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass) \
|
|
||||||
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass::ObjectProps) \
|
|
||||||
BOOST_CLASS_EXPORT_KEY(uLib::ObjectPropsImpl<_FullNamespaceClass>)
|
|
||||||
|
|
||||||
|
|
||||||
#define _SERIALIZE_IMPL_SEQ \
|
|
||||||
(uLib::Archive::text_iarchive) \
|
|
||||||
(uLib::Archive::text_oarchive) \
|
|
||||||
(uLib::Archive::hrt_iarchive) \
|
|
||||||
(uLib::Archive::hrt_oarchive) \
|
|
||||||
(uLib::Archive::xml_iarchive) \
|
|
||||||
(uLib::Archive::xml_oarchive) \
|
|
||||||
(uLib::Archive::log_archive)
|
|
||||||
|
|
||||||
|
#define _SERIALIZE_IMPL_SEQ \
|
||||||
|
(uLib::Archive::text_iarchive)(uLib::Archive::text_oarchive)( \
|
||||||
|
uLib::Archive:: \
|
||||||
|
hrt_iarchive)(uLib::Archive:: \
|
||||||
|
hrt_oarchive)(uLib::Archive:: \
|
||||||
|
xml_iarchive)(uLib::Archive:: \
|
||||||
|
xml_oarchive)(uLib::Archive:: \
|
||||||
|
log_archive)
|
||||||
|
|
||||||
/** Solving virtual class check problem */
|
/** Solving virtual class check problem */
|
||||||
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(_Base,_Derived) namespace boost{ template<> struct is_virtual_base_of<_Base,_Derived>: public boost::mpl::true_ {}; }
|
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(_Base, _Derived) \
|
||||||
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP(r,data,elem) _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(elem,data)
|
namespace boost { \
|
||||||
|
template <> \
|
||||||
|
struct is_virtual_base_of<_Base, _Derived> : public boost::mpl::true_ {}; \
|
||||||
|
}
|
||||||
|
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP(r, data, elem) \
|
||||||
|
_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(elem, data)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -220,38 +195,57 @@ namespace uLib {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// INTRUSIVE SERIALIZATION ( NOT WORKING YET !! ) //
|
// INTRUSIVE SERIALIZATION ( NOT WORKING YET !! ) //
|
||||||
|
|
||||||
#define _ULIB_DETAIL_INTRUSIVE_AR_(name) ar & BOOST_SERIALIZATION_NVP(name);
|
#define _ULIB_DETAIL_INTRUSIVE_AR_(name) ar &BOOST_SERIALIZATION_NVP(name);
|
||||||
|
|
||||||
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC(Class,Archive) \
|
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC(Class, Archive) \
|
||||||
template void Class::serialize(Archive &ar,const unsigned int);
|
template void Class::serialize(Archive &ar, const unsigned int);
|
||||||
|
|
||||||
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC_OP(r,data,elem) _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC(data,elem);
|
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC_OP(r, data, elem) \
|
||||||
|
_ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC(data, elem);
|
||||||
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZABLE_OBJECT \
|
|
||||||
typedef boost::mpl::bool_<true> serializable; \
|
|
||||||
typedef boost::mpl::remove_if< TypeList, IsUnSerializable >::type SerilizableTypeList; \
|
|
||||||
void PrintSerializableListId() { boost::mpl::for_each<SerilizableTypeList>(PrintTypeId()); } \
|
|
||||||
template <class ArchiveT> void serialize(ArchiveT &ar,const unsigned int version); \
|
|
||||||
template <class ArchiveT> void serialize_parents(ArchiveT &ar,const unsigned int version); \
|
|
||||||
template <class ArchiveT> void save_override(ArchiveT &ar,const unsigned int version);
|
|
||||||
|
|
||||||
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_OBJECT(_Ob,...) \
|
|
||||||
template <class ArchiveT> void _Ob::serialize(ArchiveT &ar, const unsigned int version) { \
|
|
||||||
boost::serialization::void_cast_register<_Ob,_Ob::BaseClass>(static_cast<_Ob *>(NULL),static_cast<_Ob::BaseClass *>(NULL)); \
|
|
||||||
_Ob::serialize_parents(ar,version); \
|
|
||||||
_Ob::save_override(ar,version); }\
|
|
||||||
template <class ArchiveT> void _Ob::serialize_parents(ArchiveT &ar, const unsigned int v) { \
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_AR_OP,ar,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); } \
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC_OP,_Ob,_SERIALIZE_IMPL_SEQ)\
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP,_Ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
|
||||||
namespace boost { \
|
|
||||||
namespace serialization { \
|
|
||||||
template<class ArchiveT> inline void load_construct_data(ArchiveT & ar, _Ob *o, const unsigned int file_version) \
|
|
||||||
{ ::new(o)_Ob(); o->init_parameters(); } }}\
|
|
||||||
template <class ArchiveT> void _Ob::save_override(ArchiveT &ar, const unsigned int version)
|
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZABLE_OBJECT \
|
||||||
|
typedef boost::mpl::bool_<true> serializable; \
|
||||||
|
typedef boost::mpl::remove_if<TypeList, IsUnSerializable>::type \
|
||||||
|
SerilizableTypeList; \
|
||||||
|
void PrintSerializableListId() { \
|
||||||
|
boost::mpl::for_each<SerilizableTypeList>(PrintTypeId()); \
|
||||||
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, const unsigned int version); \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, const unsigned int version); \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void save_override(ArchiveT &ar, const unsigned int version);
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void _Ob::serialize(ArchiveT &ar, const unsigned int version) { \
|
||||||
|
boost::serialization::void_cast_register<_Ob, _Ob::BaseClass>( \
|
||||||
|
static_cast<_Ob *>(NULL), static_cast<_Ob::BaseClass *>(NULL)); \
|
||||||
|
_Ob::serialize_parents(ar, version); \
|
||||||
|
_Ob::save_override(ar, version); \
|
||||||
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void _Ob::serialize_parents(ArchiveT &ar, const unsigned int v) { \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_AR_OP, ar, BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
||||||
|
} \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC_OP, _Ob, \
|
||||||
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP, _Ob, \
|
||||||
|
BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
||||||
|
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
||||||
|
namespace boost { \
|
||||||
|
namespace serialization { \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
inline void load_construct_data(ArchiveT &ar, _Ob *o, \
|
||||||
|
const unsigned int file_version) { \
|
||||||
|
::new (o) _Ob(); \
|
||||||
|
o->init_parameters(); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void _Ob::save_override(ArchiveT &ar, const unsigned int version)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -261,152 +255,171 @@ namespace uLib {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// UNINTRUSIVE SERIALIZATION
|
// UNINTRUSIVE SERIALIZATION
|
||||||
|
|
||||||
#define _UNAR_OP(r,data,elem) ar&boost::serialization::make_nvp(BOOST_PP_STRINGIZE(elem),boost::serialization::base_object<elem>(ob));
|
#define _UNAR_OP(r, data, elem) \
|
||||||
|
ar &boost::serialization::make_nvp( \
|
||||||
|
BOOST_PP_STRINGIZE(elem), boost::serialization::base_object<elem>(ob));
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC(Class,Archive) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC(Class, Archive) \
|
||||||
template void boost::serialization::serialize(Archive &ar, Class &ob, const unsigned int i);
|
template void boost::serialization::serialize(Archive &ar, Class &ob, \
|
||||||
|
const unsigned int i);
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP(r,data,elem) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC(data,elem)
|
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP(r, data, elem) \
|
||||||
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC(data, elem)
|
||||||
|
|
||||||
// NOTE: becouse of BOOST_PP_VARIADIC_SIZE issue of some boost macro has two
|
// NOTE: becouse of BOOST_PP_VARIADIC_SIZE issue of some boost macro has two
|
||||||
// different implementation
|
// different implementation
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE(_Ob) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE(_Ob) \
|
||||||
namespace boost { namespace serialization { \
|
namespace boost { \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
namespace serialization { \
|
||||||
template <class ArchiveT> void serialize_parents (ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
template <class ArchiveT> \
|
||||||
template <> struct access2< _Ob > { template <class ArchiveT> static void save_override (ArchiveT &ar, _Ob &ob, const unsigned int version); }; }}
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
||||||
|
template <class ArchiveT> \
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE(_Ob) \
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
||||||
namespace boost { namespace serialization { \
|
template <> struct access2<_Ob> { \
|
||||||
template <class ArchiveT> void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) {} \
|
template <class ArchiveT> \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
static void save_override(ArchiveT &ar, _Ob &ob, \
|
||||||
serialize_parents(ar,ob,version); \
|
const unsigned int version); \
|
||||||
access2< _Ob >::save_override(ar,ob,version); } }}\
|
}; \
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
} \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP,_Ob,_SERIALIZE_IMPL_SEQ)\
|
}
|
||||||
template <class ArchiveT> void boost::serialization::access2< _Ob >::save_override(ArchiveT &ar, _Ob &ob, const unsigned int version)
|
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_DERIVED(_Ob,...) \
|
|
||||||
namespace boost { namespace serialization { \
|
|
||||||
template <class ArchiveT> void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
|
||||||
BOOST_PP_IF(BOOST_PP_VARIADIC_SIZE((__VA_ARGS__)),BOOST_PP_SEQ_FOR_EACH(_UNAR_OP,ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__)));,) } \
|
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
|
||||||
serialize_parents(ar,ob,version); \
|
|
||||||
access2< _Ob >::save_override (ar,ob,version); } }}\
|
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP,_Ob,_SERIALIZE_IMPL_SEQ) \
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP,_Ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
|
||||||
template <class ArchiveT> void boost::serialization::access2< _Ob >::save_override(ArchiveT &ar, _Ob &ob, const unsigned int version)
|
|
||||||
|
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE_OBJECT(_Ob) \
|
|
||||||
namespace boost { namespace serialization { \
|
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
|
||||||
template <class ArchiveT> void serialize_parents (ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
|
||||||
template <> struct access2< _Ob > { template <class ArchiveT> static void save_override (ArchiveT &ar, _Ob &ob, const unsigned int version); }; \
|
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, class _Ob::ObjectProps &ob, const unsigned int version); \
|
|
||||||
template <class ArchiveT> void save_override (ArchiveT &ar, class _Ob::ObjectProps &ob, const unsigned int version); }}
|
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob,...) \
|
|
||||||
namespace boost { namespace serialization { \
|
|
||||||
template <class ArchiveT> void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
|
||||||
/* PP serialize */ BOOST_PP_SEQ_FOR_EACH(_UNAR_OP,ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
|
||||||
/* MPL serialize */ /*uLib::mpl::for_each<_Ob::BaseList>(uLib::detail::Serializable::serialize_baseobject<_Ob,ArchiveT>(ob,ar) );*/ } \
|
|
||||||
template<class ArchiveT> inline void load_construct_data(ArchiveT & ar, _Ob *ob, const unsigned int file_version) { \
|
|
||||||
::new(ob)_Ob(); uLib::detail::ObjectProps::initializer::init_object(ob); } \
|
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
|
||||||
void_cast_register<_Ob,_Ob::BaseClass>(static_cast<_Ob *>(NULL),static_cast<_Ob::BaseClass *>(NULL)); /*fix*/ \
|
|
||||||
serialize_parents(ar,ob,version); \
|
|
||||||
access2< _Ob >::save_override (ar,ob,version); } }}\
|
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP,_Ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP,_Ob,_SERIALIZE_IMPL_SEQ)\
|
|
||||||
template <class ArchiveT> void boost::serialization::access2< _Ob >::save_override(ArchiveT &ar, _Ob &ob, const unsigned int version)
|
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_PROPS(_Ob) \
|
|
||||||
namespace boost { namespace serialization { \
|
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob::ObjectProps &ob, const unsigned int version) { \
|
|
||||||
save_override (ar,ob,version); } }}\
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP,_Ob::ObjectProps,_SERIALIZE_IMPL_SEQ)\
|
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob::ObjectProps) \
|
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(uLib::ObjectPropsImpl<_Ob>) \
|
|
||||||
template <class ArchiveT> void boost::serialization::save_override(ArchiveT &ar, _Ob::ObjectProps &ob, const unsigned int version)
|
|
||||||
|
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_AR_(name) boost::serialization::make_nvp(BOOST_PP_STRINGIZE(name),ob.name)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE(_Ob) \
|
||||||
|
namespace boost { \
|
||||||
|
namespace serialization { \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) {} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
||||||
|
serialize_parents(ar, ob, version); \
|
||||||
|
access2<_Ob>::save_override(ar, ob, version); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP, _Ob, \
|
||||||
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void boost::serialization::access2<_Ob>::save_override( \
|
||||||
|
ArchiveT &ar, _Ob &ob, const unsigned int version)
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_DERIVED(_Ob, ...) \
|
||||||
|
namespace boost { \
|
||||||
|
namespace serialization { \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
||||||
|
BOOST_PP_IF(BOOST_PP_VARIADIC_SIZE((__VA_ARGS__)), \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_UNAR_OP, ob, \
|
||||||
|
BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
||||||
|
, ) \
|
||||||
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
||||||
|
serialize_parents(ar, ob, version); \
|
||||||
|
access2<_Ob>::save_override(ar, ob, version); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP, _Ob, \
|
||||||
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP, _Ob, \
|
||||||
|
BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void boost::serialization::access2<_Ob>::save_override( \
|
||||||
|
ArchiveT &ar, _Ob &ob, const unsigned int version)
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE_OBJECT(_Ob) \
|
||||||
|
namespace boost { \
|
||||||
|
namespace serialization { \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
||||||
|
template <> struct access2<_Ob> { \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
static void save_override(ArchiveT &ar, _Ob &ob, \
|
||||||
|
const unsigned int version); \
|
||||||
|
}; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
|
namespace boost { \
|
||||||
|
namespace serialization { \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
||||||
|
/* PP serialize */ BOOST_PP_SEQ_FOR_EACH( \
|
||||||
|
_UNAR_OP, ob, BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
||||||
|
/* MPL serialize */ /*uLib::mpl::for_each<_Ob::BaseList>(uLib::detail::Serializable::serialize_baseobject<_Ob,ArchiveT>(ob,ar) );*/ } \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
inline void load_construct_data(ArchiveT &ar, _Ob *ob, \
|
||||||
|
const unsigned int file_version) { \
|
||||||
|
::new (ob) _Ob(); \
|
||||||
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
||||||
|
void_cast_register<_Ob, _Ob::BaseClass>( \
|
||||||
|
static_cast<_Ob *>(NULL), \
|
||||||
|
static_cast<_Ob::BaseClass *>(NULL)); /*fix*/ \
|
||||||
|
serialize_parents(ar, ob, version); \
|
||||||
|
access2<_Ob>::save_override(ar, ob, version); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP, _Ob, \
|
||||||
|
BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP, _Ob, \
|
||||||
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void boost::serialization::access2<_Ob>::save_override( \
|
||||||
|
ArchiveT &ar, _Ob &ob, const unsigned int version)
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_AR_(name) \
|
||||||
|
boost::serialization::make_nvp(BOOST_PP_STRINGIZE(name), ob.name)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
struct Serializable {
|
struct Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializable trait to check if an object type is serializable.
|
* Serializable trait to check if an object type is serializable.
|
||||||
* This only works if UNINTRUSIVE SERIALIZATION is applyed; in intrusive
|
* This only works if UNINTRUSIVE SERIALIZATION is applyed; in intrusive
|
||||||
* cases a has_serialize trait should be implemented
|
* cases a has_serialize trait should be implemented
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T> struct serializable_trait : mpl::bool_<false> {};
|
||||||
struct serializable_trait : mpl::bool_<false> {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IsA Serializable Implementation Template
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
struct IsA : serializable_trait<T> {};
|
|
||||||
|
|
||||||
template <class ThisClass, class Archive>
|
|
||||||
struct serialize_baseobject {
|
|
||||||
ThisClass & m_object;
|
|
||||||
Archive & m_ar;
|
|
||||||
serialize_baseobject(ThisClass &o, Archive &ar) : m_object(o), m_ar(ar) {}
|
|
||||||
template <class T> void operator()(T &o) {
|
|
||||||
m_ar & boost::serialization::make_nvp(
|
|
||||||
typeid(T).name() ,
|
|
||||||
boost::serialization::base_object<T>(m_object));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IsA Serializable Implementation Template
|
||||||
|
*/
|
||||||
|
template <class T> struct IsA : serializable_trait<T> {};
|
||||||
|
|
||||||
|
template <class ThisClass, class Archive> struct serialize_baseobject {
|
||||||
|
ThisClass &m_object;
|
||||||
|
Archive &m_ar;
|
||||||
|
serialize_baseobject(ThisClass &o, Archive &ar) : m_object(o), m_ar(ar) {}
|
||||||
|
template <class T> void operator()(T &o) {
|
||||||
|
m_ar &boost::serialization::make_nvp(
|
||||||
|
typeid(T).name(), boost::serialization::base_object<T>(m_object));
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
} // detail
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Serializable {
|
struct Serializable {
|
||||||
friend class boost::serialization::access;
|
friend class boost::serialization::access;
|
||||||
template <class T> friend class boost::serialization::access2;
|
template <class T> friend class boost::serialization::access2;
|
||||||
virtual ~Serializable() {}
|
virtual ~Serializable() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // U_SERIALIZABLE_H
|
#endif // U_SERIALIZABLE_H
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
#include <istream>
|
#include <istream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Core/Vector.h"
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
|||||||
278
src/Core/Types.h
278
src/Core/Types.h
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_CORE_TYPES_H
|
#ifndef U_CORE_TYPES_H
|
||||||
#define U_CORE_TYPES_H
|
#define U_CORE_TYPES_H
|
||||||
|
|
||||||
@@ -33,244 +31,182 @@
|
|||||||
|
|
||||||
#include <boost/preprocessor.hpp>
|
#include <boost/preprocessor.hpp>
|
||||||
|
|
||||||
#include <ltk/ltktypes.h>
|
// #include <ltk/ltktypes.h>
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
#include "Core/Macros.h"
|
||||||
#include "Core/Mpl.h"
|
#include "Core/Mpl.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
struct TypeIntrospection {
|
struct TypeIntrospection {
|
||||||
|
|
||||||
// BOOST IMPL //
|
// BOOST IMPL //
|
||||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(type_info)
|
BOOST_MPL_HAS_XXX_TRAIT_DEF(type_info)
|
||||||
|
|
||||||
// SFINAE IMPL //
|
// SFINAE IMPL //
|
||||||
/*
|
/*
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_type_info {
|
struct has_type_info {
|
||||||
typedef char yes[1];
|
typedef char yes[1];
|
||||||
typedef char no[2];
|
typedef char no[2];
|
||||||
template <typename U> static yes& test(typename U::type_info::BaseList*);
|
template <typename U> static yes& test(typename U::type_info::BaseList*);
|
||||||
template <typename > static no& test(...);
|
template <typename > static no& test(...);
|
||||||
// struct apply {
|
// struct apply {
|
||||||
static const bool value = sizeof(test<T>(0)) == sizeof(yes);
|
static const bool value = sizeof(test<T>(0)) == sizeof(yes);
|
||||||
typedef boost::mpl::bool_<value> type;
|
typedef boost::mpl::bool_<value> type;
|
||||||
// };
|
// };
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** IsA Introspectable Object Implementation Template */
|
/** IsA Introspectable Object Implementation Template */
|
||||||
template <class T>
|
template <class T> struct IsIntrospectable : has_type_info<T> {};
|
||||||
struct IsIntrospectable : has_type_info<T> {};
|
|
||||||
|
|
||||||
template <typename T> struct access {
|
template <typename T> struct access {
|
||||||
typedef typename T::type_info type_info;
|
typedef typename T::type_info type_info;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T> struct child_first_impl {
|
||||||
|
|
||||||
|
template <class T1, bool cond> struct lambda_CFList_f {
|
||||||
|
typedef mpl::vector<T1> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <class T1> struct lambda_CFList_f<T1, true> {
|
||||||
struct child_first_impl {
|
// typedef typename T1::type_info::CFList type;
|
||||||
|
typedef typename access<T1>::type_info::CFList type;
|
||||||
template <class T1, bool cond>
|
|
||||||
struct lambda_CFList_f {
|
|
||||||
typedef mpl::vector<T1> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1>
|
|
||||||
struct lambda_CFList_f<T1,true> {
|
|
||||||
// typedef typename T1::type_info::CFList type;
|
|
||||||
typedef typename access<T1>::type_info::CFList type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1>
|
|
||||||
struct lambda_CFList : lambda_CFList_f<T1, has_type_info<T1>::value> {};
|
|
||||||
|
|
||||||
/** Transforms all Base Type into proper CFList */
|
|
||||||
typedef typename mpl::transform_view < typename access<T>::type_info::BaseList
|
|
||||||
, lambda_CFList<mpl::_>
|
|
||||||
>::type CFListSeq;
|
|
||||||
|
|
||||||
/** Folds each CFList into a new sequence */
|
|
||||||
typedef typename mpl::fold< CFListSeq
|
|
||||||
, mpl::vector<>
|
|
||||||
, mpl::copy< mpl::_1
|
|
||||||
, mpl::back_inserter<mpl::_2>
|
|
||||||
>
|
|
||||||
>::type Childs;
|
|
||||||
|
|
||||||
/** Add This Class to final CFList sequence */
|
|
||||||
typedef typename mpl::copy< Childs
|
|
||||||
, mpl::back_inserter< mpl::vector<T> >
|
|
||||||
>::type type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class T1>
|
||||||
|
struct lambda_CFList : lambda_CFList_f<T1, has_type_info<T1>::value> {};
|
||||||
|
|
||||||
/**
|
/** Transforms all Base Type into proper CFList */
|
||||||
* Tests if T has a member called type_info then compile type CFList
|
typedef
|
||||||
*/
|
typename mpl::transform_view<typename access<T>::type_info::BaseList,
|
||||||
template <typename T>
|
lambda_CFList<mpl::_>>::type CFListSeq;
|
||||||
struct child_first : mpl::if_< has_type_info<T>
|
|
||||||
, child_first_impl<T>
|
|
||||||
, mpl::vector<>
|
|
||||||
>::type {};
|
|
||||||
|
|
||||||
|
/** Folds each CFList into a new sequence */
|
||||||
|
typedef typename mpl::fold<
|
||||||
|
CFListSeq, mpl::vector<>,
|
||||||
|
mpl::copy<mpl::_1, mpl::back_inserter<mpl::_2>>>::type Childs;
|
||||||
|
|
||||||
|
/** Add This Class to final CFList sequence */
|
||||||
|
typedef typename mpl::copy<Childs, mpl::back_inserter<mpl::vector<T>>>::type
|
||||||
|
type;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if T has a member called type_info then compile type CFList
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
struct child_first
|
||||||
|
: mpl::if_<has_type_info<T>, child_first_impl<T>, mpl::vector<>>::type {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TYPE ADAPTERS // FINIRE !!!
|
// TYPE ADAPTERS // FINIRE !!!
|
||||||
|
|
||||||
//#define _REPETITION_V(vz,vn,vdata)
|
// #define _REPETITION_V(vz,vn,vdata)
|
||||||
|
|
||||||
|
|
||||||
//template < class TypeList >
|
|
||||||
//class TypeAdapterInputInterface {
|
|
||||||
// virtual ~TypeAdapterInputInterface() {}
|
|
||||||
//public:
|
|
||||||
|
|
||||||
|
|
||||||
|
// template < class TypeList >
|
||||||
|
// class TypeAdapterInputInterface {
|
||||||
|
// virtual ~TypeAdapterInputInterface() {}
|
||||||
|
// public:
|
||||||
|
|
||||||
// virtual void operator()(int val) {}
|
// virtual void operator()(int val) {}
|
||||||
// virtual void operator()(std::string val) {}
|
// virtual void operator()(std::string val) {}
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // detail ////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
#define CONSTEXPR BOOST_CONSTEXPR
|
#define CONSTEXPR BOOST_CONSTEXPR
|
||||||
|
|
||||||
|
// typedef ltk::Real_t Real_t;
|
||||||
typedef ltk::Real_t Real_t;
|
#ifndef LTK_DOUBLE_PRECISION
|
||||||
typedef ltk::Id_t Id_t;
|
typedef float Real_t;
|
||||||
//typedef ltk::Size_t Size_t;
|
#else
|
||||||
typedef ltk::Pointer_t Pointer_t;
|
typedef double Real_t;
|
||||||
typedef bool Bool_t; //Boolean (0=false, 1=true) (bool)
|
#endif
|
||||||
|
// typedef ltk::Id_t Id_t;
|
||||||
|
typedef id_t Id_t;
|
||||||
|
////typedef ltk::Size_t Size_t;
|
||||||
|
// typedef ltk::Pointer_t Pointer_t;
|
||||||
|
typedef void *Pointer_t;
|
||||||
|
typedef bool Bool_t; // Boolean (0=false, 1=true) (bool)
|
||||||
|
|
||||||
//--- bit manipulation ---------------------------------------------------------
|
//--- bit manipulation ---------------------------------------------------------
|
||||||
#ifndef BIT
|
#ifndef BIT
|
||||||
#define BIT(n) (1ULL << (n))
|
#define BIT(n) (1ULL << (n))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SETBIT
|
#ifndef SETBIT
|
||||||
#define SETBIT(n,i) ((n) |= BIT(i))
|
#define SETBIT(n, i) ((n) |= BIT(i))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CLRBIT
|
#ifndef CLRBIT
|
||||||
#define CLRBIT(n,i) ((n) &= ~BIT(i))
|
#define CLRBIT(n, i) ((n) &= ~BIT(i))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TESTBIT
|
#ifndef TESTBIT
|
||||||
#define TESTBIT(n,i) ((Bool_t)(((n) & BIT(i)) != 0))
|
#define TESTBIT(n, i) ((Bool_t)(((n) & BIT(i)) != 0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TYPE INTROSPECTION FOR OBJECTS //
|
// TYPE INTROSPECTION FOR OBJECTS //
|
||||||
|
|
||||||
|
#define uLibTypeMacro(thisClass, ...) \
|
||||||
|
\
|
||||||
#define uLibTypeMacro(thisClass,...) \
|
/* Friendship detail for accessing introspection */ \
|
||||||
\
|
template <typename> friend class uLib::detail::TypeIntrospection::access; \
|
||||||
/* Friendship detail for accessing introspection */ \
|
\
|
||||||
template <typename> friend class uLib::detail::TypeIntrospection::access; \
|
/* type info structure*/ public: \
|
||||||
\
|
/* in GCC 4.8 must be public or dynamic_cast wont work */ \
|
||||||
/* type info structure*/ public: \
|
struct type_info { \
|
||||||
/* in GCC 4.8 must be public or dynamic_cast wont work */ \
|
/*WARNING: -std=c++0x required for this! */ \
|
||||||
struct type_info { \
|
constexpr static const char *name = BOOST_PP_STRINGIZE(thisClass); \
|
||||||
/*WARNING: -std=c++0x required for this! */ \
|
typedef BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__) BaseClass; \
|
||||||
constexpr static const char *name = BOOST_PP_STRINGIZE(thisClass); \
|
typedef thisClass ThisClass; \
|
||||||
typedef BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__) BaseClass; \
|
typedef uLib::mpl::vector<__VA_ARGS__, thisClass> TypeList; \
|
||||||
typedef thisClass ThisClass; \
|
typedef uLib::mpl::vector<__VA_ARGS__> BaseList; \
|
||||||
typedef uLib::mpl::vector<__VA_ARGS__,thisClass> TypeList; \
|
typedef uLib::detail::TypeIntrospection::child_first<ThisClass>::type \
|
||||||
typedef uLib::mpl::vector<__VA_ARGS__> BaseList; \
|
CFList; \
|
||||||
typedef uLib::detail::TypeIntrospection::child_first<ThisClass>::type CFList; \
|
}; \
|
||||||
}; \
|
\
|
||||||
\
|
public: \
|
||||||
public: \
|
typedef type_info::BaseClass BaseClass; \
|
||||||
typedef type_info::BaseClass BaseClass; \
|
virtual const char *type_name() const { return type_info::name; } \
|
||||||
virtual const char *type_name() const { return type_info::name; } \
|
/**/
|
||||||
/* Object Props fwd declaration*/ \
|
|
||||||
struct ObjectProps; \
|
|
||||||
/**/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TypeList inheritance introspection
|
* TypeList inheritance introspection
|
||||||
*/
|
*/
|
||||||
struct TypeIntrospection {
|
struct TypeIntrospection {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct child_first : detail::TypeIntrospection::child_first<T> {};
|
struct child_first : detail::TypeIntrospection::child_first<T> {};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// SISTEMARE //
|
// SISTEMARE //
|
||||||
struct PrintTypeId {
|
struct PrintTypeId {
|
||||||
template <class T>
|
template <class T> void operator()(T) const {
|
||||||
void operator()(T) const
|
std::cout << typeid(T).name() << std::endl;
|
||||||
{ std::cout << typeid(T).name() << std::endl; }
|
}
|
||||||
|
|
||||||
template <typename SeqT>
|
template <typename SeqT> static void PrintMplSeq(SeqT *p = NULL) {
|
||||||
static void PrintMplSeq(SeqT *p = NULL) { boost::mpl::for_each<SeqT>(PrintTypeId()); }
|
boost::mpl::for_each<SeqT>(PrintTypeId());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Class>
|
template <typename Class> static void PrintType(Class *p = NULL) {
|
||||||
static void PrintType(Class *p = NULL) { std::cout << typeid(Class).name() << std::endl; }
|
std::cout << typeid(Class).name() << std::endl;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
#endif // U_CORE_TYPES_H
|
#endif // U_CORE_TYPES_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#define U_CORE_UUID_H
|
#define U_CORE_UUID_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/uuid/uuid.hpp>
|
#include <boost/uuid/uuid.hpp>
|
||||||
#include <boost/uuid/name_generator.hpp>
|
#include <boost/uuid/name_generator.hpp>
|
||||||
@@ -36,7 +37,6 @@
|
|||||||
#include <boost/uuid/uuid_io.hpp>
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
|
|
||||||
#include "Core/Mpl.h"
|
#include "Core/Mpl.h"
|
||||||
#include "Core/Vector.h"
|
|
||||||
#include "Core/Object.h"
|
#include "Core/Object.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
IDGen_t gen;
|
IDGen_t gen;
|
||||||
Vector<RegisterEntry> m_registry;
|
std::vector<RegisterEntry> m_registry;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ set( TESTS
|
|||||||
SerializeTest
|
SerializeTest
|
||||||
SerializeDreadDiamondTest
|
SerializeDreadDiamondTest
|
||||||
DreadDiamondParameters
|
DreadDiamondParameters
|
||||||
ObjectPropableTest
|
|
||||||
UuidTest
|
UuidTest
|
||||||
TypeIntrospectionTraversal
|
TypeIntrospectionTraversal
|
||||||
OptionsTest
|
OptionsTest
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ TESTS = SmartPointerTest \
|
|||||||
SerializeTest \
|
SerializeTest \
|
||||||
SerializeDreadDiamondTest \
|
SerializeDreadDiamondTest \
|
||||||
DreadDiamondParameters \
|
DreadDiamondParameters \
|
||||||
ObjectPropableTest \
|
|
||||||
TypeIntrospectionTraversal \
|
TypeIntrospectionTraversal \
|
||||||
OptionsTest
|
OptionsTest
|
||||||
|
|
||||||
|
|||||||
@@ -1,237 +0,0 @@
|
|||||||
/*//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
|
||||||
All rights reserved
|
|
||||||
|
|
||||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
|
||||||
|
|
||||||
------------------------------------------------------------------
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library.
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <typeinfo>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
#include "Core/Types.h"
|
|
||||||
#include "Core/Object.h"
|
|
||||||
#include "Core/ObjectProps.h"
|
|
||||||
#include "Core/StringReader.h"
|
|
||||||
#include "Math/Dense.h"
|
|
||||||
|
|
||||||
#include "boost/archive/text_oarchive.hpp"
|
|
||||||
#include "boost/archive/text_iarchive.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
#include "testing-prototype.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace uLib;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// STRUCTURES //
|
|
||||||
|
|
||||||
|
|
||||||
struct A : virtual Object {
|
|
||||||
|
|
||||||
uLibTypeMacro(A, Object)
|
|
||||||
|
|
||||||
properties() {
|
|
||||||
int p_a;
|
|
||||||
Vector3f p_3f;
|
|
||||||
};
|
|
||||||
|
|
||||||
int m_a;
|
|
||||||
};
|
|
||||||
|
|
||||||
void A::init_properties() {
|
|
||||||
$_init();
|
|
||||||
$$.p_a = 0;
|
|
||||||
$$.p_3f << 1,2,3;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(A)
|
|
||||||
ULIB_SERIALIZE_OBJECT(A, Object) { ar & AR(m_a); }
|
|
||||||
ULIB_SERIALIZE_OBJECT_PROPS(A) { ar & AR(p_a) & AR(p_3f); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct B : A {
|
|
||||||
uLibTypeMacro(B,A)
|
|
||||||
|
|
||||||
properties() {
|
|
||||||
std::string p;
|
|
||||||
};
|
|
||||||
|
|
||||||
B() : m_b(324) {}
|
|
||||||
|
|
||||||
int m_b;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void B::init_properties() {
|
|
||||||
$_init();
|
|
||||||
$$.p = "ciao";
|
|
||||||
}
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(B)
|
|
||||||
ULIB_SERIALIZE_OBJECT(B,A) { ar & AR(m_b); }
|
|
||||||
ULIB_SERIALIZE_OBJECT_PROPS(B) { ar & AR(p); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct C {
|
|
||||||
int m_c;
|
|
||||||
std::string m_str;
|
|
||||||
};
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(C)
|
|
||||||
ULIB_SERIALIZE(C) { ar & AR(m_c) & AR(m_str); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct D : virtual Object, B {
|
|
||||||
uLibTypeMacro(D,Object,B)
|
|
||||||
|
|
||||||
properties() {
|
|
||||||
C p_c;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
void D::init_properties() {
|
|
||||||
$_init();
|
|
||||||
$$.p_c.m_c = 1234;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(D)
|
|
||||||
ULIB_SERIALIZE_OBJECT(D,Object) {}
|
|
||||||
ULIB_SERIALIZE_OBJECT_PROPS(D) {
|
|
||||||
ar & AR(p_c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class E : public C, public D {
|
|
||||||
uLibTypeMacro(E,D,C)
|
|
||||||
public:
|
|
||||||
E() : m_Ea(5552368) {}
|
|
||||||
int m_Ea;
|
|
||||||
};
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(E)
|
|
||||||
ULIB_SERIALIZE_OBJECT(E,C,D) {
|
|
||||||
ar & AR(m_Ea);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TESTS //
|
|
||||||
|
|
||||||
|
|
||||||
int test_xml_direct() {
|
|
||||||
// TEST ARCHIVE SAVE AND LOAD direct //
|
|
||||||
E o; o.init_properties();
|
|
||||||
o.$$.p_c.m_str = "works";
|
|
||||||
{
|
|
||||||
std::ofstream file("test.xml");
|
|
||||||
Archive::xml_oarchive ar(file);
|
|
||||||
ar << NVP(o);
|
|
||||||
}
|
|
||||||
o.$$.p_c.m_str = "hola";
|
|
||||||
{
|
|
||||||
std::ifstream file("test.xml");
|
|
||||||
Archive::xml_iarchive ar(file);
|
|
||||||
ar >> NVP(o);
|
|
||||||
}
|
|
||||||
std::cout << o.$$.p_c.m_str << "\n";
|
|
||||||
return ( o.$$.p_c.m_str == "works" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int test_xml_pointer() {
|
|
||||||
// TEST ARCHIVE SAVE AND LOAD from pointer //
|
|
||||||
E *o = new E; o->init_properties();
|
|
||||||
o->$$.p_c.m_str = "works";
|
|
||||||
{
|
|
||||||
std::ofstream file("test.xml");
|
|
||||||
Archive::xml_oarchive ar(file);
|
|
||||||
ar << NVP(o);
|
|
||||||
}
|
|
||||||
o->$$.p_c.m_str = "hola";
|
|
||||||
{
|
|
||||||
std::ifstream file("test.xml");
|
|
||||||
Archive::xml_iarchive ar(file);
|
|
||||||
ar >> NVP(o);
|
|
||||||
}
|
|
||||||
std::cout << o->$$.p_c.m_str << "\n";
|
|
||||||
return ( o->$$.p_c.m_str == "works" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int test_xml_objsave() {
|
|
||||||
// TEST SELF SAVE
|
|
||||||
E o; o.init_properties();
|
|
||||||
o.$(B).p = "works";
|
|
||||||
{
|
|
||||||
std::ofstream file("test.xml");
|
|
||||||
Object::SaveXml(file,o);
|
|
||||||
}
|
|
||||||
o.$(B).p = "hola";
|
|
||||||
{
|
|
||||||
std::ifstream file("test.xml");
|
|
||||||
Object::LoadXml(file,o);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << o.$(B).p << "\n";
|
|
||||||
return ( o.$(B).p == "works" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// MAIN //
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
BEGIN_TESTING(PropableTest);
|
|
||||||
|
|
||||||
TEST1( test_xml_direct() );
|
|
||||||
TEST1( test_xml_pointer() );
|
|
||||||
TEST1( test_xml_objsave() );
|
|
||||||
|
|
||||||
END_TESTING;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include "Core/Object.h"
|
#include "Core/Object.h"
|
||||||
#include "Core/Archives.h"
|
#include "Core/Archives.h"
|
||||||
#include "ParticlePhysics/MuonTomography/MuonScatter.h"
|
|
||||||
|
|
||||||
#include "testing-prototype.h"
|
#include "testing-prototype.h"
|
||||||
|
|
||||||
@@ -189,48 +188,12 @@ int testing_hrt_class() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// MUON SCATTER EXAMPLE //
|
|
||||||
|
|
||||||
int testing_mu()
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
|
|
||||||
MuonScatter mu;
|
|
||||||
mu.SetMomentumIn(555);
|
|
||||||
mu.SetMomentumOut(2368);
|
|
||||||
{
|
|
||||||
std::ofstream file("test.txt");
|
|
||||||
file << mu;
|
|
||||||
}
|
|
||||||
|
|
||||||
mu.SetMomentumIn(0);
|
|
||||||
mu.SetMomentumOut(0);
|
|
||||||
{
|
|
||||||
std::ifstream file("test.txt");
|
|
||||||
file >> mu;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << mu << "\n";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
BEGIN_TESTING(Serialize Test);
|
BEGIN_TESTING(Serialize Test);
|
||||||
|
|
||||||
TEST1( test_V3f() );
|
TEST1( test_V3f() );
|
||||||
TEST1( testing_xml_class() );
|
TEST1( testing_xml_class() );
|
||||||
// testing_hrt_class(); ///// << ERRORE in HRT with properties
|
// testing_hrt_class(); ///// << ERRORE in HRT with properties
|
||||||
TEST1( testing_mu() );
|
|
||||||
|
|
||||||
END_TESTING;
|
END_TESTING;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,7 @@
|
|||||||
# HEADERS
|
set(HEADERS MuonScatter.h MuonError.h MuonEvent.h)
|
||||||
set(HEADERS
|
|
||||||
DetectorChamber.h
|
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Detectors PARENT_SCOPE)
|
||||||
ExperimentFitEvent.h
|
|
||||||
GeantEvent.h
|
|
||||||
HitMC.h
|
|
||||||
MuonScatter.h
|
|
||||||
MuonEvent.h
|
|
||||||
MuonError.h
|
|
||||||
ChamberHitEvent.h
|
|
||||||
Hit.h
|
|
||||||
LinearFit.h
|
|
||||||
Solid.h
|
|
||||||
Matter.h
|
|
||||||
Scene.h
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# SOURCES
|
install(FILES ${HEADERS}
|
||||||
set(SOURCES
|
DESTINATION ${INSTALL_INC_DIR}/Detectors)
|
||||||
Solid.cpp
|
|
||||||
Scene.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(LIBRARIES
|
|
||||||
${Boost_SERIALIZATION_LIBRARY}
|
|
||||||
${Boost_SIGNALS_LIBRARY}
|
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
|
||||||
${Eigen_LIBRARY}
|
|
||||||
${Geant4_LIBRARIES}
|
|
||||||
${ROOT_LIBRARIES}
|
|
||||||
${PACKAGE_LIBPREFIX}Core
|
|
||||||
${PACKAGE_LIBPREFIX}Math
|
|
||||||
${PACKAGE_LIBPREFIX}Detectors
|
|
||||||
)
|
|
||||||
|
|
||||||
uLib_add_shared_library(${uLib-module})
|
|
||||||
add_subdirectory(testing)
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#ifndef U_HITMC_H
|
#ifndef U_HITMC_H
|
||||||
#define U_HITMC_H
|
#define U_HITMC_H
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
#include "Hit.h"
|
#include "Hit.h"
|
||||||
|
|
||||||
@@ -43,10 +42,10 @@ public:
|
|||||||
DeltaRay
|
DeltaRay
|
||||||
};
|
};
|
||||||
|
|
||||||
uLibConstRefMacro(Position,HPoint3f)
|
inline const HPoint3f & Position() const { return this->m_Position; }
|
||||||
uLibGetMacro(Type, enum Type)
|
inline enum Type GetType() const { return this->m_Type; }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
HPoint3f m_Position;
|
HPoint3f m_Position;
|
||||||
enum Type m_Type;
|
enum Type m_Type;
|
||||||
};
|
};
|
||||||
@@ -54,8 +53,8 @@ private:
|
|||||||
|
|
||||||
class HitMC : public HitMCData {
|
class HitMC : public HitMCData {
|
||||||
public:
|
public:
|
||||||
uLibRefMacro(Position,HPoint3f)
|
inline HPoint3f & Position() { return this->m_Position; }
|
||||||
uLibSetMacro(Type, enum Type)
|
inline void SetType(enum Type name) { this->m_Type = name; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#ifndef U_LINEARFIT_H
|
#ifndef U_LINEARFIT_H
|
||||||
#define U_LINEARFIT_H
|
#define U_LINEARFIT_H
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
#include "ChamberDetector.h"
|
#include "ChamberDetector.h"
|
||||||
|
|
||||||
@@ -37,32 +36,31 @@ namespace uLib {
|
|||||||
|
|
||||||
class LinearFitData {
|
class LinearFitData {
|
||||||
public:
|
public:
|
||||||
uLibConstRefMacro(Position,Vector2f)
|
inline const Vector2f & Position() const { return this->m_Position; }
|
||||||
uLibConstRefMacro(Slope,Vector2f)
|
inline const Vector2f & Slope() const { return this->m_Slope; }
|
||||||
uLibConstRefMacro(PositionError,Vector2f)
|
inline const Vector2f & PositionError() const { return this->m_PositionError; }
|
||||||
uLibConstRefMacro(SlopeError,Vector2f)
|
inline const Vector2f & SlopeError() const { return this->m_SlopeError; }
|
||||||
uLibGetMacro(HitsNumber,int)
|
inline int GetHitsNumber() const { return this->m_HitsNumber; }
|
||||||
uLibGetMacro(Idv,ChamberDetector::ID)
|
inline ChamberDetector::ID GetIdv() const { return this->m_Idv; }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
friend class LinearFit;
|
Vector2f m_Position;
|
||||||
Vector2f m_Position;
|
Vector2f m_Slope;
|
||||||
Vector2f m_Slope;
|
Vector2f m_PositionError;
|
||||||
Vector2f m_PositionError;
|
Vector2f m_SlopeError;
|
||||||
Vector2f m_SlopeError;
|
int m_HitsNumber;
|
||||||
int m_HitsNumber;
|
|
||||||
DetectorChamber::ID m_Idv;
|
DetectorChamber::ID m_Idv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class LinearFit : public LinearFitData {
|
class LinearFit : public LinearFitData {
|
||||||
public:
|
public:
|
||||||
uLibRefMacro(Position,Vector2f)
|
inline Vector2f & Position() { return this->m_Position; }
|
||||||
uLibRefMacro(Slope,Vector2f)
|
inline Vector2f & Slope() { return this->m_Slope; }
|
||||||
uLibRefMacro(PositionError,Vector2f)
|
inline Vector2f & PositionError() { return this->m_PositionError; }
|
||||||
uLibRefMacro(SlopeError,Vector2f)
|
inline Vector2f & SlopeError() { return this->m_SlopeError; }
|
||||||
uLibSetMacro(HitsNumber,int)
|
inline void SetHitsNumber(int name) { this->m_HitsNumber = name; }
|
||||||
uLibSetMacro(Idv,ChamberDetector::ID)
|
inline void SetIdv(ChamberDetector::ID name) { this->m_Idv = name; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,18 +28,16 @@
|
|||||||
#ifndef U_MUONERROR_H
|
#ifndef U_MUONERROR_H
|
||||||
#define U_MUONERROR_H
|
#define U_MUONERROR_H
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
class MuonErrorData {
|
class MuonErrorData {
|
||||||
friend class MuonError;
|
|
||||||
public:
|
public:
|
||||||
uLibConstRefMacro(Theta,Scalarf)
|
inline const Scalarf & Theta() const { return this->m_Theta; }
|
||||||
uLibConstRefMacro(Phi,Scalarf)
|
inline const Scalarf & Phi() const { return this->m_Phi; }
|
||||||
private:
|
protected:
|
||||||
Scalarf m_Theta;
|
Scalarf m_Theta;
|
||||||
Scalarf m_Phi;
|
Scalarf m_Phi;
|
||||||
};
|
};
|
||||||
@@ -47,8 +45,8 @@ private:
|
|||||||
|
|
||||||
class MuonError : public MuonErrorData {
|
class MuonError : public MuonErrorData {
|
||||||
public:
|
public:
|
||||||
uLibRefMacro(Theta,Scalarf)
|
inline Scalarf & Theta() { return this->m_Theta; }
|
||||||
uLibRefMacro(Phi,Scalarf)
|
inline Scalarf & Phi() { return this->m_Phi; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,20 +28,18 @@
|
|||||||
#ifndef U_MUONEVENT_H
|
#ifndef U_MUONEVENT_H
|
||||||
#define U_MUONEVENT_H
|
#define U_MUONEVENT_H
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
class MuonEventData {
|
class MuonEventData {
|
||||||
friend class MuonEvent;
|
|
||||||
public:
|
public:
|
||||||
uLibConstRefMacro(LineIn,HLine3f)
|
inline const HLine3f & LineIn() const { return this->m_LineIn; }
|
||||||
uLibConstRefMacro(LineOut,HLine3f)
|
inline const HLine3f & LineOut() const { return this->m_LineOut; }
|
||||||
uLibGetMacro(Momentum,Scalarf)
|
inline Scalarf GetMomentum() const { return this->m_Momentum; }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
HLine3f m_LineIn;
|
HLine3f m_LineIn;
|
||||||
HLine3f m_LineOut;
|
HLine3f m_LineOut;
|
||||||
Scalarf m_Momentum;
|
Scalarf m_Momentum;
|
||||||
@@ -50,9 +48,9 @@ private:
|
|||||||
|
|
||||||
class MuonEvent : public MuonEventData {
|
class MuonEvent : public MuonEventData {
|
||||||
public:
|
public:
|
||||||
uLibRefMacro(LineIn,HLine3f)
|
inline HLine3f & LineIn() { return this->m_LineIn; }
|
||||||
uLibRefMacro(LineOut,HLine3f)
|
inline HLine3f & LineOut() { return this->m_LineOut; }
|
||||||
uLibRefMacro(Momentum,Scalarf)
|
inline Scalarf & Momentum() { return this->m_Momentum; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#ifndef U_MUONSCATTER_H
|
#ifndef U_MUONSCATTER_H
|
||||||
#define U_MUONSCATTER_H
|
#define U_MUONSCATTER_H
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
@@ -37,20 +36,21 @@ namespace uLib {
|
|||||||
|
|
||||||
class MuonScatter {
|
class MuonScatter {
|
||||||
public:
|
public:
|
||||||
uLibConstRefMacro(LineIn,HLine3f)
|
inline const HLine3f & LineIn() const { return this->m_LineIn; }
|
||||||
uLibConstRefMacro(ErrorIn,HError3f)
|
inline const HError3f & ErrorIn() const { return this->m_ErrorIn; }
|
||||||
uLibConstRefMacro(LineOut,HLine3f)
|
inline const HLine3f & LineOut() const { return this->m_LineOut; }
|
||||||
uLibConstRefMacro(ErrorOut,HError3f)
|
inline const HError3f & ErrorOut() const { return this->m_ErrorOut; }
|
||||||
|
|
||||||
uLibRefMacro(LineIn,HLine3f)
|
inline HLine3f & LineIn() { return this->m_LineIn; }
|
||||||
uLibRefMacro(ErrorIn,HError3f)
|
inline HError3f & ErrorIn() { return this->m_ErrorIn; }
|
||||||
uLibRefMacro(LineOut,HLine3f)
|
inline HLine3f & LineOut() { return this->m_LineOut; }
|
||||||
uLibRefMacro(ErrorOut,HError3f)
|
inline HError3f & ErrorOut() { return this->m_ErrorOut; }
|
||||||
uLibSetMacro(Momentum,Scalarf)
|
|
||||||
uLibSetMacro(MomentumPrime,Scalarf)
|
|
||||||
|
|
||||||
uLibGetMacro(Momentum,Scalarf)
|
inline void SetMomentum(Scalarf name) { this->m_Momentum = name; }
|
||||||
uLibGetMacro(MomentumPrime,Scalarf)
|
inline void SetMomentumPrime(Scalarf name) { this->m_MomentumPrime = name; }
|
||||||
|
|
||||||
|
inline Scalarf GetMomentum() const { return this->m_Momentum; }
|
||||||
|
inline Scalarf GetMomentumPrime() const { return this->m_MomentumPrime; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HLine3f m_LineIn;
|
HLine3f m_LineIn;
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
#ifndef U_DATABINNING_H
|
#ifndef U_DATABINNING_H
|
||||||
#define U_DATABINNING_H
|
#define U_DATABINNING_H
|
||||||
|
|
||||||
#include "Core/Vector.h"
|
#include <vector>
|
||||||
|
|
||||||
#include "Dense.h"
|
#include "Dense.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ public:
|
|||||||
void AddPass() { m_Means.push_back( Tmean(0,0) ); }
|
void AddPass() { m_Means.push_back( Tmean(0,0) ); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector< Tmean > m_Means;
|
std::vector< Tmean > m_Means;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,15 +27,16 @@
|
|||||||
#ifndef U_MATH_BITCODE_H
|
#ifndef U_MATH_BITCODE_H
|
||||||
#define U_MATH_BITCODE_H
|
#define U_MATH_BITCODE_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#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 {
|
||||||
|
|
||||||
|
|
||||||
@@ -237,9 +238,9 @@ public:
|
|||||||
// std::cout << boost::mpl::at_c< BitSet,1 >::type::value << "\n";
|
// std::cout << boost::mpl::at_c< BitSet,1 >::type::value << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int Get(unsigned short field) const {
|
// int Get(unsigned short field) const {
|
||||||
return boost::mpl::at_c< BitSet, field >::type::value;
|
// return boost::mpl::at_c< BitSet, field >::type::value;
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +1,60 @@
|
|||||||
|
|
||||||
# HEADERS
|
set(HEADERS ContainerBox.h
|
||||||
set(HEADERS
|
Dense.h
|
||||||
ContainerBox.h
|
Geometry.h
|
||||||
Dense.h
|
Transform.h
|
||||||
Geometry.h
|
StructuredData.h
|
||||||
Transform.h
|
StructuredGrid.h
|
||||||
StructuredData.h
|
VoxImage.h
|
||||||
StructuredGrid.h
|
VoxRaytracer.h
|
||||||
VoxImage.h
|
Utils.h
|
||||||
VoxRaytracer.h
|
VoxImageFilter.h
|
||||||
Utils.h
|
VoxImageFilter.hpp
|
||||||
VoxImageFilter.h
|
VoxImageFilterLinear.hpp
|
||||||
VoxImageFilter.hpp
|
VoxImageFilterMedian.hpp
|
||||||
VoxImageFilterLinear.hpp
|
VoxImageFilterABTrim.hpp
|
||||||
VoxImageFilterMedian.hpp
|
VoxImageFilterBilateral.hpp
|
||||||
VoxImageFilterABTrim.hpp
|
VoxImageFilterThreshold.hpp
|
||||||
VoxImageFilterBilateral.hpp
|
VoxImageFilter2ndStat.hpp
|
||||||
VoxImageFilterThreshold.hpp
|
VoxImageFilterCustom.hpp
|
||||||
VoxImageFilter2ndStat.hpp
|
Accumulator.h
|
||||||
VoxImageFilterCustom.hpp
|
TriangleMesh.h
|
||||||
Accumulator.h
|
BitCode.h
|
||||||
TriangleMesh.h
|
Structured2DGrid.h
|
||||||
BitCode.h
|
Structured4DGrid.h)
|
||||||
)
|
|
||||||
|
set(SOURCES VoxRaytracer.cpp
|
||||||
|
StructuredData.cpp
|
||||||
|
StructuredGrid.cpp
|
||||||
|
VoxImage.cpp
|
||||||
|
TriangleMesh.cpp
|
||||||
|
Dense.cpp
|
||||||
|
Structured2DGrid.cpp
|
||||||
|
Structured4DGrid.cpp)
|
||||||
|
|
||||||
|
set(LIBRARIES Eigen3::Eigen
|
||||||
|
${ROOT_LIBRARIES}
|
||||||
|
${VTK_LIBRARIES})
|
||||||
|
|
||||||
|
set(libname ${PACKAGE_LIBPREFIX}Math)
|
||||||
|
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
||||||
|
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Math PARENT_SCOPE)
|
||||||
|
|
||||||
|
add_library(${libname} SHARED ${SOURCES})
|
||||||
|
set_target_properties(${libname} PROPERTIES
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
SOVERSION ${PROJECT_SOVERSION})
|
||||||
|
target_link_libraries(${libname} ${LIBRARIES})
|
||||||
|
|
||||||
|
|
||||||
# SOURCES
|
install(TARGETS ${libname}
|
||||||
set(SOURCES
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
VoxRaytracer.cpp
|
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
||||||
StructuredData.cpp
|
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib)
|
||||||
StructuredGrid.cpp
|
|
||||||
VoxImage.cpp
|
|
||||||
TriangleMesh.cpp
|
|
||||||
Dense.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(LIBRARIES
|
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Math)
|
||||||
${Boost_SERIALIZATION_LIBRARY}
|
|
||||||
${Boost_SIGNALS_LIBRARY}
|
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
|
||||||
${Eigen_LIBRARY}
|
|
||||||
${ROOT_LIBRARIES}
|
|
||||||
${PACKAGE_LIBPREFIX}Core
|
|
||||||
${PACKAGE_LIBPREFIX}Math
|
|
||||||
)
|
|
||||||
|
|
||||||
|
# TESTING
|
||||||
|
# include(uLibTargetMacros)
|
||||||
|
# add_subdirectory(testing)
|
||||||
|
|
||||||
uLib_add_shared_library(${uLib-module})
|
|
||||||
add_subdirectory(testing)
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
224
src/Math/Dense.h
224
src/Math/Dense.h
@@ -23,9 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* <one line to give the program's name and a brief idea of what it does.>
|
* <one line to give the program's name and a brief idea of what it does.>
|
||||||
* Copyright (C) 2012 Andrea Rigoni Garola <andrea@pcimg05>
|
* Copyright (C) 2012 Andrea Rigoni Garola <andrea@pcimg05>
|
||||||
@@ -47,17 +44,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ULIB_DENSEMATRIX_H
|
#ifndef ULIB_DENSEMATRIX_H
|
||||||
#define ULIB_DENSEMATRIX_H
|
#define ULIB_DENSEMATRIX_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Eigen/Dense>
|
#include <Eigen/Dense>
|
||||||
#include "Core/Types.h"
|
|
||||||
#include "Core/Serializable.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// BOOST SERIALIZATION ///////////////////////////////////////////////////////
|
//// BOOST SERIALIZATION ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -65,20 +57,23 @@
|
|||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/serialization/string.hpp>
|
|
||||||
#include <boost/serialization/array.hpp>
|
#include <boost/serialization/array.hpp>
|
||||||
|
#include <boost/serialization/string.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace serialization {
|
namespace serialization {
|
||||||
|
|
||||||
template<class Archive, class Scalar, int RowsAtCompileTime, int ColsAtCompileTime>
|
template <class Archive, class Scalar, int RowsAtCompileTime,
|
||||||
void serialize(Archive & ar, ::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> & m, const unsigned int /*version*/) {
|
int ColsAtCompileTime>
|
||||||
ar & boost::serialization::make_array(m.data(), RowsAtCompileTime * ColsAtCompileTime);
|
void serialize(Archive &ar,
|
||||||
|
::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> &m,
|
||||||
|
const unsigned int /*version*/) {
|
||||||
|
ar &boost::serialization::make_array(m.data(),
|
||||||
|
RowsAtCompileTime * ColsAtCompileTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // serialization
|
} // namespace serialization
|
||||||
} // boost
|
} // namespace boost
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -87,194 +82,179 @@ void serialize(Archive & ar, ::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCo
|
|||||||
// this is needed by boost::lexical_cast to cope with Eigens Vectors ///////////
|
// this is needed by boost::lexical_cast to cope with Eigens Vectors ///////////
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
template <typename T, int size>
|
template <typename T, int size>
|
||||||
std::istream & operator >> (std::istream &is, Eigen::Matrix<T,size,1> &vec) {
|
std::istream &operator>>(std::istream &is, Eigen::Matrix<T, size, 1> &vec) {
|
||||||
std::string str;
|
std::string str;
|
||||||
for( unsigned int i=0; i<size; i++) {
|
for (unsigned int i = 0; i < size; i++) {
|
||||||
is >> std::skipws;
|
is >> std::skipws;
|
||||||
is >> str;
|
is >> str;
|
||||||
if(is.fail()) vec(i) = 0;
|
if (is.fail())
|
||||||
else vec(i) = boost::lexical_cast<T>(str);
|
vec(i) = 0;
|
||||||
}
|
else
|
||||||
return is;
|
vec(i) = boost::lexical_cast<T>(str);
|
||||||
|
}
|
||||||
|
return is;
|
||||||
}
|
}
|
||||||
template <typename T, int size>
|
template <typename T, int size>
|
||||||
std::ostream & operator << (std::ostream &os, const Eigen::Matrix<T,size,1> &vec) {
|
std::ostream &operator<<(std::ostream &os,
|
||||||
os << vec.transpose();
|
const Eigen::Matrix<T, size, 1> &vec) {
|
||||||
return os;
|
os << vec.transpose();
|
||||||
|
return os;
|
||||||
}
|
}
|
||||||
} // Eigen
|
} // namespace Eigen
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
typedef id_t Id_t;
|
||||||
|
|
||||||
typedef int Scalari;
|
typedef int Scalari;
|
||||||
typedef unsigned int Scalarui;
|
typedef unsigned int Scalarui;
|
||||||
typedef long Scalarl;
|
typedef long Scalarl;
|
||||||
typedef unsigned long Scalarul;
|
typedef unsigned long Scalarul;
|
||||||
typedef float Scalarf;
|
typedef float Scalarf;
|
||||||
typedef double Scalard;
|
typedef double Scalard;
|
||||||
|
|
||||||
|
typedef Eigen::Matrix<int, 1, 1> Matrix1i;
|
||||||
|
|
||||||
typedef Eigen::Matrix<int,1,1> Matrix1i;
|
|
||||||
typedef Eigen::Matrix2i Matrix2i;
|
typedef Eigen::Matrix2i Matrix2i;
|
||||||
typedef Eigen::Matrix3i Matrix3i;
|
typedef Eigen::Matrix3i Matrix3i;
|
||||||
typedef Eigen::Matrix4i Matrix4i;
|
typedef Eigen::Matrix4i Matrix4i;
|
||||||
|
|
||||||
typedef Eigen::Matrix<float,1,1> Matrix1f;
|
typedef Eigen::Matrix<float, 1, 1> Matrix1f;
|
||||||
typedef Eigen::Matrix2f Matrix2f;
|
typedef Eigen::Matrix2f Matrix2f;
|
||||||
typedef Eigen::Matrix3f Matrix3f;
|
typedef Eigen::Matrix3f Matrix3f;
|
||||||
typedef Eigen::Matrix4f Matrix4f;
|
typedef Eigen::Matrix4f Matrix4f;
|
||||||
|
|
||||||
typedef Eigen::Matrix<int,1,1> Vector1i;
|
typedef Eigen::Matrix<int, 1, 1> Vector1i;
|
||||||
typedef Eigen::Vector2i Vector2i;
|
typedef Eigen::Vector2i Vector2i;
|
||||||
typedef Eigen::Vector3i Vector3i;
|
typedef Eigen::Vector3i Vector3i;
|
||||||
typedef Eigen::Vector4i Vector4i;
|
typedef Eigen::Vector4i Vector4i;
|
||||||
|
|
||||||
typedef Eigen::Matrix<float,1,1> Vector1f;
|
typedef Eigen::Matrix<float, 1, 1> Vector1f;
|
||||||
typedef Eigen::Vector2f Vector2f;
|
typedef Eigen::Vector2f Vector2f;
|
||||||
typedef Eigen::Vector3f Vector3f;
|
typedef Eigen::Vector3f Vector3f;
|
||||||
typedef Eigen::Vector4f Vector4f;
|
typedef Eigen::Vector4f Vector4f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Vector String interaction ///////////////////////////////////////////////////
|
// Vector String interaction ///////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*! Given a string consisting of a series of doubles with some
|
/*! Given a string consisting of a series of doubles with some
|
||||||
* delimiter, return an Eigen::Vector populated with those
|
* delimiter, return an Eigen::Vector populated with those
|
||||||
* values, in the same order as they are given in the string.
|
* values, in the same order as they are given in the string.
|
||||||
*
|
*
|
||||||
* \param vec A double vector to be populated with the results
|
* \param vec A double vector to be populated with the results
|
||||||
* \param str A string to be parsed as a series of doubles.
|
* \param str A string to be parsed as a series of doubles.
|
||||||
* \param delim Delimiters of the text (a typical default is " ," for comma and space-delimited text
|
* \param delim Delimiters of the text (a typical default is " ," for comma and
|
||||||
*
|
* space-delimited text
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
template <typename T, int size>
|
template <typename T, int size>
|
||||||
void VectorxT_StringTo(Eigen::Matrix<T,size,1> &vec, std::string str, const char *delim = " ,;\t\n") {
|
void VectorxT_StringTo(Eigen::Matrix<T, size, 1> &vec, std::string str,
|
||||||
std::vector<std::string> strvec;
|
const char *delim = " ,;\t\n") {
|
||||||
|
std::vector<std::string> strvec;
|
||||||
|
|
||||||
boost::algorithm::trim_if( str, boost::algorithm::is_any_of(delim));
|
boost::algorithm::trim_if(str, boost::algorithm::is_any_of(delim));
|
||||||
boost::algorithm::split(strvec,str,boost::algorithm::is_any_of(delim), boost::algorithm::token_compress_on);
|
boost::algorithm::split(strvec, str, boost::algorithm::is_any_of(delim),
|
||||||
|
boost::algorithm::token_compress_on);
|
||||||
|
|
||||||
for( unsigned int i=0; i<size; i++) {
|
for (unsigned int i = 0; i < size; i++) {
|
||||||
vec(i) = boost::lexical_cast<T>(strvec[i]);
|
vec(i) = boost::lexical_cast<T>(strvec[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, int size>
|
template <typename T, int size>
|
||||||
std::string VectorxT_ToString(const Eigen::Matrix<T,size,1> &vec) {
|
std::string VectorxT_ToString(const Eigen::Matrix<T, size, 1> &vec) {
|
||||||
std::stringstream sst;
|
std::stringstream sst;
|
||||||
sst << vec.transpose();
|
sst << vec.transpose();
|
||||||
return sst.str();
|
return sst.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename T, int size>
|
||||||
//template <typename T, int size>
|
// Eigen::Matrix<T,size,1> & operator >> (std::istream &is,
|
||||||
//Eigen::Matrix<T,size,1> & operator >> (std::istream &is, Eigen::Matrix<T,size,1> &vec) {
|
// Eigen::Matrix<T,size,1> &vec) {
|
||||||
//}
|
// }
|
||||||
|
|
||||||
template <typename T, int size>
|
template <typename T, int size>
|
||||||
void operator>> (std::string& str, Eigen::Matrix<T,size,1> &vec){
|
void operator>>(std::string &str, Eigen::Matrix<T, size, 1> &vec) {
|
||||||
VectorxT_StringTo(vec,str);
|
VectorxT_StringTo(vec, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////// HOMOGENEOUS VECTORS //////////////////////////////////////////////////
|
////// HOMOGENEOUS VECTORS //////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <bool p>
|
template <bool p> class _HPoint3f : public Eigen::Matrix<Scalarf, 4, 1> {
|
||||||
class _HPoint3f : public Eigen::Matrix< Scalarf,4,1 > {
|
|
||||||
public:
|
public:
|
||||||
typedef Eigen::Matrix< Scalarf,4,1 > BaseClass;
|
typedef Eigen::Matrix<Scalarf, 4, 1> BaseClass;
|
||||||
|
|
||||||
_HPoint3f<p>() : BaseClass(0,0,0,p) {}
|
_HPoint3f() : BaseClass(0, 0, 0, p) {}
|
||||||
_HPoint3f<p>(float x,float y,float z) : BaseClass(x,y,z,p) {}
|
_HPoint3f(float x, float y, float z) : BaseClass(x, y, z, p) {}
|
||||||
_HPoint3f<p>(Vector3f &in) : BaseClass(in.homogeneous()) { this->operator()(3) = p; }
|
_HPoint3f(Vector3f &in) : BaseClass(in.homogeneous()) {
|
||||||
|
this->operator()(3) = p;
|
||||||
|
}
|
||||||
|
|
||||||
void operator delete(void* _p, size_t _s) {}
|
void operator delete(void *_p, size_t _s) {}
|
||||||
|
|
||||||
// This constructor allows to construct MyVectorType from Eigen expressions
|
// This constructor allows to construct MyVectorType from Eigen expressions
|
||||||
template<typename OtherDerived>
|
template <typename OtherDerived>
|
||||||
inline _HPoint3f<p>(const Eigen::MatrixBase<OtherDerived>& other)
|
inline _HPoint3f(const Eigen::MatrixBase<OtherDerived> &other)
|
||||||
: BaseClass(other)
|
: BaseClass(other) {}
|
||||||
{ }
|
|
||||||
|
|
||||||
// This method allows to assign Eigen expressions to Vector3H
|
|
||||||
template<typename OtherDerived>
|
|
||||||
inline _HPoint3f<p> & operator= (const Eigen::MatrixBase <OtherDerived>& other)
|
|
||||||
{
|
|
||||||
this->BaseClass::operator=(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// This method allows to assign Eigen expressions to Vector3H
|
||||||
|
template <typename OtherDerived>
|
||||||
|
inline _HPoint3f &operator=(const Eigen::MatrixBase<OtherDerived> &other) {
|
||||||
|
this->BaseClass::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
typedef _HPoint3f<false> HVector3f;
|
typedef _HPoint3f<false> HVector3f;
|
||||||
typedef _HPoint3f<true> HPoint3f;
|
typedef _HPoint3f<true> HPoint3f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////// HOMOGENEOUS LINE //////////////////////////////////////////////////
|
////// HOMOGENEOUS LINE //////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct _HLine3f {
|
||||||
struct _HLine3f
|
HPoint3f origin;
|
||||||
{
|
HVector3f direction;
|
||||||
HPoint3f origin;
|
|
||||||
HVector3f direction;
|
|
||||||
};
|
};
|
||||||
typedef struct _HLine3f HLine3f;
|
typedef struct _HLine3f HLine3f;
|
||||||
|
|
||||||
inline std::ostream&
|
inline std::ostream &operator<<(std::ostream &stream, const HLine3f &line) {
|
||||||
operator<< (std::ostream& stream, const HLine3f &line) {
|
stream << "HLine3f(" << "pt[" << line.origin.transpose() << "] , dr["
|
||||||
stream << "HLine3f(" << "pt[" << line.origin.transpose() <<"] , dr[" << line.direction.transpose() << "]) ";
|
<< line.direction.transpose() << "]) ";
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _HError3f {
|
||||||
|
HVector3f position_error;
|
||||||
|
HVector3f direction_error;
|
||||||
struct _HError3f
|
|
||||||
{
|
|
||||||
HVector3f position_error;
|
|
||||||
HVector3f direction_error;
|
|
||||||
};
|
};
|
||||||
typedef struct _HError3f HError3f;
|
typedef struct _HError3f HError3f;
|
||||||
|
|
||||||
inline std::ostream&
|
inline std::ostream &operator<<(std::ostream &stream, const HError3f &err) {
|
||||||
operator<< (std::ostream& stream, const HError3f &err) {
|
stream << "HError3f(" << "ept[" << err.position_error.transpose()
|
||||||
stream << "HError3f(" << "ept[" << err.position_error.transpose() <<"] , edr[" << err.direction_error.transpose() << "]) ";
|
<< "] , edr[" << err.direction_error.transpose() << "]) ";
|
||||||
return stream;
|
return stream;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// 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)
|
||||||
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(uLib::HLine3f)
|
ULIB_SERIALIZABLE(uLib::HLine3f)
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(uLib::HError3f)
|
ULIB_SERIALIZABLE(uLib::HError3f)
|
||||||
|
#endif // ULIB_SERIALIZATION_ON
|
||||||
|
|
||||||
|
#endif // U_DENSEMATRIX_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // U_DENSEMATRIX_H
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
130
src/Math/Structured2DGrid.cpp
Normal file
130
src/Math/Structured2DGrid.cpp
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/*//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||||
|
All rights reserved
|
||||||
|
|
||||||
|
Authors: Sara Vanini < sara.vanini@pd.infn.it >
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3.0 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library.
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "Structured2DGrid.h"
|
||||||
|
|
||||||
|
using namespace uLib;
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
Structured2DGrid::Structured2DGrid()
|
||||||
|
{
|
||||||
|
// reset uni-dim space
|
||||||
|
m_Dims = Vector2i(0,0);
|
||||||
|
m_Origin = Vector2f(0.,0.);
|
||||||
|
m_Increments = Vector2i(0,0);
|
||||||
|
m_binW = Vector2f(1.,1.);
|
||||||
|
m_debug = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
void Structured2DGrid::SetDims(const Vector2i &size)
|
||||||
|
{
|
||||||
|
this->m_Dims = size;
|
||||||
|
|
||||||
|
// set increments
|
||||||
|
this->m_Increments[0] = 1;
|
||||||
|
this->m_Increments[1] = m_Dims[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
void Structured2DGrid::SetPhysicalSpace(const Vector2f &origin, const Vector2f &spacing)
|
||||||
|
{
|
||||||
|
m_Origin = origin;
|
||||||
|
m_binW = spacing;
|
||||||
|
|
||||||
|
m_uni2phys_T = Translation<float,2>(m_Origin) * Scaling(m_binW);
|
||||||
|
m_phys2uni_T = m_uni2phys_T.matrix().inverse();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
bool Structured2DGrid::IsInsideBounds(const Vector2f &pt) const
|
||||||
|
{
|
||||||
|
Vector2i pLoc = this->PhysicsToUnitSpace(pt);
|
||||||
|
return this->IsInsideGrid(pLoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
Vector2i Structured2DGrid::UnMap(int index) const
|
||||||
|
{
|
||||||
|
Vector2i v( 0,0 );
|
||||||
|
Vector2i iv = m_Increments;
|
||||||
|
|
||||||
|
int id = 0;
|
||||||
|
for(int k=0; k<2; ++k) {
|
||||||
|
int inc = iv.maxCoeff(&id);
|
||||||
|
v(id) = index / inc;
|
||||||
|
index -= v(id) * inc;
|
||||||
|
iv(id) = 0;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
bool Structured2DGrid::IsInsideGrid(const Vector2i &v) const
|
||||||
|
{
|
||||||
|
int vok = 1;
|
||||||
|
vok *= (v(0) >= 0 && v(0) < m_Dims[0]);
|
||||||
|
vok *= (v(1) >= 0 && v(1) < m_Dims[1]);
|
||||||
|
|
||||||
|
return vok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
Vector2i Structured2DGrid::PhysicsToUnitSpace(const Vector2f &pt) const
|
||||||
|
{
|
||||||
|
Vector2i out;
|
||||||
|
Vector2f pLoc = m_phys2uni_T * pt;
|
||||||
|
|
||||||
|
out << (int)floor(pLoc(0)),
|
||||||
|
(int)floor(pLoc(1));
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
Vector2f Structured2DGrid::UnitToPhysicsSpace(const Vector2i &ind) const
|
||||||
|
{
|
||||||
|
Vector2f p;
|
||||||
|
p = m_uni2phys_T * ind.cast<float>();
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
void Structured2DGrid::PrintSelf(std::ostream &o)
|
||||||
|
{
|
||||||
|
o << "uLib Structured Data 2D: \n"
|
||||||
|
<< "dim = " << this->GetDims().transpose() << "\n"
|
||||||
|
<< "spacing = " << this->GetSpacing().transpose() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
74
src/Math/Structured2DGrid.h
Normal file
74
src/Math/Structured2DGrid.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||||
|
All rights reserved
|
||||||
|
|
||||||
|
Authors: Sara Vanini < sara.vanini@pd.infn.it >
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3.0 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library.
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
#ifndef Structured2DGrid_H
|
||||||
|
#define Structured2DGrid_H
|
||||||
|
|
||||||
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
|
#include <Eigen/Dense>
|
||||||
|
#include <Eigen/Geometry>
|
||||||
|
|
||||||
|
using namespace Eigen;
|
||||||
|
|
||||||
|
namespace uLib {
|
||||||
|
|
||||||
|
class Structured2DGrid {
|
||||||
|
public:
|
||||||
|
|
||||||
|
Structured2DGrid();
|
||||||
|
|
||||||
|
/// unit-space
|
||||||
|
void SetDims(const Vector2i &size);
|
||||||
|
inline Vector2i GetDims() {return m_Dims; }
|
||||||
|
bool IsInsideGrid(const Vector2i &v) const;
|
||||||
|
inline int Map(Vector2i index) const { return (m_Increments.transpose() * index);}
|
||||||
|
Vector2i UnMap(int index) const;
|
||||||
|
|
||||||
|
/// physics-space
|
||||||
|
void SetPhysicalSpace(const Vector2f &origin, const Vector2f &spacing);
|
||||||
|
inline Vector2f GetSpacing() const { return m_binW; }
|
||||||
|
inline Vector2f GetOrigin() const { return m_Origin; }
|
||||||
|
bool IsInsideBounds(const Vector2f &pt) const;
|
||||||
|
|
||||||
|
/// operations
|
||||||
|
Vector2i PhysicsToUnitSpace(const Vector2f &pt) const;
|
||||||
|
Vector2f UnitToPhysicsSpace(const Vector2i &ind) const;
|
||||||
|
void PrintSelf(std::ostream &o);
|
||||||
|
void SetDebug(bool debug){ m_debug = debug; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector2i m_Dims;
|
||||||
|
Vector2i m_Increments;
|
||||||
|
Vector2f m_binW;
|
||||||
|
Vector2f m_Origin;
|
||||||
|
bool m_debug;
|
||||||
|
|
||||||
|
Transform<float, 2, Eigen::Affine> m_uni2phys_T;
|
||||||
|
Transform<float, 2, Eigen::Affine> m_phys2uni_T;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Structured2DGrid_H
|
||||||
136
src/Math/Structured4DGrid.cpp
Normal file
136
src/Math/Structured4DGrid.cpp
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/*//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||||
|
All rights reserved
|
||||||
|
|
||||||
|
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3.0 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library.
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "Structured4DGrid.h"
|
||||||
|
|
||||||
|
using namespace uLib;
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
Structured4DGrid::Structured4DGrid()
|
||||||
|
{
|
||||||
|
// reset uni-dim space
|
||||||
|
m_Dims = Vector4i(0,0,0,0);
|
||||||
|
m_Origin = Vector4f(0.,0.,0.,0.);
|
||||||
|
m_Increments = Vector4i(0,0,0,0);
|
||||||
|
m_binW = Vector4f(1.,1.,1.,1.);
|
||||||
|
m_debug = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
void Structured4DGrid::SetDims(const Vector4i &size)
|
||||||
|
{
|
||||||
|
this->m_Dims = size;
|
||||||
|
|
||||||
|
// set increments
|
||||||
|
this->m_Increments[0] = 1;
|
||||||
|
this->m_Increments[1] = m_Dims[0];
|
||||||
|
this->m_Increments[2] = m_Dims[0] * m_Dims[1];
|
||||||
|
this->m_Increments[3] = m_Dims[0] * m_Dims[1] * m_Dims[2];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
void Structured4DGrid::SetPhysicalSpace(const Vector4f &origin, const Vector4f &spacing)
|
||||||
|
{
|
||||||
|
m_Origin = origin;
|
||||||
|
m_binW = spacing;
|
||||||
|
|
||||||
|
m_uni2phys_T = Translation<float,4>(m_Origin) * Scaling(m_binW);
|
||||||
|
m_phys2uni_T = m_uni2phys_T.matrix().inverse();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
bool Structured4DGrid::IsInsideBounds(const Vector4f &pt) const
|
||||||
|
{
|
||||||
|
Vector4i pLoc = this->PhysicsToUnitSpace(pt);
|
||||||
|
return this->IsInsideGrid(pLoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
Vector4i Structured4DGrid::UnMap(int index) const
|
||||||
|
{
|
||||||
|
Vector4i v( 0,0,0, 0 );
|
||||||
|
Vector4i iv = m_Increments;
|
||||||
|
|
||||||
|
int id = 0;
|
||||||
|
for(int k=0; k<4; ++k) {
|
||||||
|
int inc = iv.maxCoeff(&id);
|
||||||
|
v(id) = index / inc;
|
||||||
|
index -= v(id) * inc;
|
||||||
|
iv(id) = 0;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
bool Structured4DGrid::IsInsideGrid(const Vector4i &v) const
|
||||||
|
{
|
||||||
|
int vok = 1;
|
||||||
|
vok *= (v(0) >= 0 && v(0) < m_Dims[0]);
|
||||||
|
vok *= (v(1) >= 0 && v(1) < m_Dims[1]);
|
||||||
|
vok *= (v(2) >= 0 && v(2) < m_Dims[2]);
|
||||||
|
vok *= (v(3) >= 0 && v(3) < m_Dims[3]);
|
||||||
|
return vok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
Vector4i Structured4DGrid::PhysicsToUnitSpace(const Vector4f &pt) const
|
||||||
|
{
|
||||||
|
Vector4i out;
|
||||||
|
Vector4f pLoc = m_phys2uni_T * pt;
|
||||||
|
|
||||||
|
out << (int)floor(pLoc(0)),
|
||||||
|
(int)floor(pLoc(1)),
|
||||||
|
(int)floor(pLoc(2)),
|
||||||
|
(int)floor(pLoc(3));
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
Vector4f Structured4DGrid::UnitToPhysicsSpace(const Vector4i &ind) const
|
||||||
|
{
|
||||||
|
Vector4f p;
|
||||||
|
p = m_uni2phys_T * ind.cast<float>();
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________
|
||||||
|
void Structured4DGrid::PrintSelf(std::ostream &o)
|
||||||
|
{
|
||||||
|
o << "uLib Structured Data 4D: \n"
|
||||||
|
<< "dim = " << this->GetDims().transpose() << "\n"
|
||||||
|
<< "spacing = " << this->GetSpacing().transpose() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
74
src/Math/Structured4DGrid.h
Normal file
74
src/Math/Structured4DGrid.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||||
|
All rights reserved
|
||||||
|
|
||||||
|
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||||
|
|
||||||
|
------------------------------------------------------------------
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3.0 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library.
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
#ifndef Structured4DGrid_H
|
||||||
|
#define Structured4DGrid_H
|
||||||
|
|
||||||
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
|
#include <Eigen/Dense>
|
||||||
|
#include <Eigen/Geometry>
|
||||||
|
|
||||||
|
using namespace Eigen;
|
||||||
|
|
||||||
|
namespace uLib {
|
||||||
|
|
||||||
|
class Structured4DGrid {
|
||||||
|
public:
|
||||||
|
|
||||||
|
Structured4DGrid();
|
||||||
|
|
||||||
|
/// unit-space
|
||||||
|
void SetDims(const Vector4i &size);
|
||||||
|
inline Vector4i GetDims() {return m_Dims; }
|
||||||
|
bool IsInsideGrid(const Vector4i &v) const;
|
||||||
|
inline int Map(Vector4i index) const { return (m_Increments.transpose() * index);}
|
||||||
|
Vector4i UnMap(int index) const;
|
||||||
|
|
||||||
|
/// physics-space
|
||||||
|
void SetPhysicalSpace(const Vector4f &origin, const Vector4f &spacing);
|
||||||
|
inline Vector4f GetSpacing() const { return m_binW; }
|
||||||
|
inline Vector4f GetOrigin() const { return m_Origin; }
|
||||||
|
bool IsInsideBounds(const Vector4f &pt) const;
|
||||||
|
|
||||||
|
/// operations
|
||||||
|
Vector4i PhysicsToUnitSpace(const Vector4f &pt) const;
|
||||||
|
Vector4f UnitToPhysicsSpace(const Vector4i &ind) const;
|
||||||
|
void PrintSelf(std::ostream &o);
|
||||||
|
void SetDebug(bool debug){ m_debug = debug; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector4i m_Dims;
|
||||||
|
Vector4i m_Increments;
|
||||||
|
Vector4f m_binW;
|
||||||
|
Vector4f m_Origin;
|
||||||
|
bool m_debug;
|
||||||
|
|
||||||
|
Transform<float, 4, Eigen::Affine> m_uni2phys_T;
|
||||||
|
Transform<float, 4, Eigen::Affine> m_phys2uni_T;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Structured4DGrid_H
|
||||||
@@ -28,15 +28,12 @@
|
|||||||
#ifndef STRUCTUREDDATA_H
|
#ifndef STRUCTUREDDATA_H
|
||||||
#define STRUCTUREDDATA_H
|
#define STRUCTUREDDATA_H
|
||||||
|
|
||||||
#include "Core/Macros.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,
|
||||||
@@ -53,22 +50,23 @@ 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)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
uLibGetMacro(Dims,Vector3i)
|
inline Vector3i GetDims() const { return this->m_Dims; }
|
||||||
|
|
||||||
void SetDims(const Vector3i &size);
|
void SetDims(const Vector3i &size);
|
||||||
|
|
||||||
uLibGetSetMacro(Increments,Vector3i)
|
inline Vector3i GetIncrements() const { return this->m_Increments; }
|
||||||
|
|
||||||
|
inline void SetIncrements(Vector3i name) { this->m_Increments = name; }
|
||||||
|
|
||||||
void SetDataOrder(Order order = YXZ);
|
void SetDataOrder(Order order = YXZ);
|
||||||
|
|
||||||
uLibGetMacro(DataOrder,Order)
|
inline Order GetDataOrder() const { return this->m_DataOrder; }
|
||||||
|
|
||||||
bool IsInsideGrid(const Vector3i &v) const;
|
bool IsInsideGrid(const Vector3i &v) const;
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@
|
|||||||
#ifndef U_TRANSFORM_H
|
#ifndef U_TRANSFORM_H
|
||||||
#define U_TRANSFORM_H
|
#define U_TRANSFORM_H
|
||||||
|
|
||||||
#include <Core/Macros.h>
|
|
||||||
#include <Eigen/Geometry>
|
#include <Eigen/Geometry>
|
||||||
|
|
||||||
|
|
||||||
@@ -80,7 +79,10 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
Eigen::Affine3f& GetTransform() { return m_T; }
|
Eigen::Affine3f& GetTransform() { return m_T; }
|
||||||
uLibGetSetMacro(Parent,AffineTransform *)
|
|
||||||
|
inline AffineTransform *GetParent() const { return this->m_Parent; }
|
||||||
|
|
||||||
|
inline void SetParent(AffineTransform *name) { this->m_Parent = name; }
|
||||||
|
|
||||||
inline void SetMatrix (Matrix4f &mat) { m_T.matrix() = mat; }
|
inline void SetMatrix (Matrix4f &mat) { m_T.matrix() = mat; }
|
||||||
inline Matrix4f& GetMatrix () { return m_T.matrix(); }
|
inline Matrix4f& GetMatrix () { return m_T.matrix(); }
|
||||||
@@ -108,6 +110,17 @@ public:
|
|||||||
|
|
||||||
inline void Rotate(const Matrix3f &m) { this->m_T.rotate(m); }
|
inline void Rotate(const Matrix3f &m) { this->m_T.rotate(m); }
|
||||||
|
|
||||||
|
inline void Rotate(const float angle, Vector3f axis)
|
||||||
|
{
|
||||||
|
axis.normalize(); // prehaps not necessary ( see eigens )
|
||||||
|
Eigen::AngleAxisf ax(angle,axis);
|
||||||
|
this->m_T.rotate(Eigen::Quaternion<float>(ax));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Rotate(const Vector3f euler_axis) {
|
||||||
|
float angle = euler_axis.norm();
|
||||||
|
Rotate(angle,euler_axis);
|
||||||
|
}
|
||||||
|
|
||||||
inline void PreRotate(const Matrix3f &m) { this->m_T.prerotate(m); }
|
inline void PreRotate(const Matrix3f &m) { this->m_T.prerotate(m); }
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,14 @@
|
|||||||
#ifndef TRIANGLEMESH_H
|
#ifndef TRIANGLEMESH_H
|
||||||
#define TRIANGLEMESH_H
|
#define TRIANGLEMESH_H
|
||||||
|
|
||||||
#include "Core/Object.h"
|
#include <vector>
|
||||||
#include "Core/Vector.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);
|
||||||
|
|
||||||
@@ -44,12 +44,12 @@ public:
|
|||||||
void AddTriangle(const Id_t *id);
|
void AddTriangle(const Id_t *id);
|
||||||
void AddTriangle(const Vector3i &id);
|
void AddTriangle(const Vector3i &id);
|
||||||
|
|
||||||
uLibRefMacro(Points,Vector<Vector3f>)
|
inline std::vector<Vector3f> & Points() { return this->m_Points; }
|
||||||
uLibRefMacro(Triangles,Vector<Vector3i>)
|
inline std::vector<Vector3i> & Triangles() { return this->m_Triangles; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<Vector3f> m_Points;
|
std::vector<Vector3f> m_Points;
|
||||||
Vector<Vector3i> m_Triangles;
|
std::vector<Vector3i> m_Triangles;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,13 @@
|
|||||||
|
|
||||||
#include "VoxImage.h"
|
#include "VoxImage.h"
|
||||||
|
|
||||||
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkImageData.h>
|
||||||
|
#include <vtkXMLImageDataReader.h>
|
||||||
|
#include <vtkXMLImageDataWriter.h>
|
||||||
|
#include <vtkStringArray.h>
|
||||||
|
#include <vtkInformation.h>
|
||||||
|
#include <vtkInformationStringKey.h>
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
@@ -83,7 +90,103 @@ void Abstract::VoxImage::ExportToVtk (const char *file, bool density_type)
|
|||||||
printf("%s vtk file saved\n",file);
|
printf("%s vtk file saved\n",file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Abstract::VoxImage::ImportFromVtk(const char *file)
|
|
||||||
|
|
||||||
|
void Abstract::VoxImage::ExportToVti (const char *file, bool density_type, bool compressed)
|
||||||
|
{
|
||||||
|
Abstract::VoxImage *voxels = this;
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();
|
||||||
|
image->SetDimensions(voxels->GetDims()(0), voxels->GetDims()(1), voxels->GetDims()(2));
|
||||||
|
image->SetSpacing(voxels->GetSpacing()(0), voxels->GetSpacing()(1), voxels->GetSpacing()(2));
|
||||||
|
image->SetOrigin(voxels->GetPosition()(0), voxels->GetPosition()(1), voxels->GetPosition()(2));
|
||||||
|
image->AllocateScalars(VTK_FLOAT, 1);
|
||||||
|
|
||||||
|
float norm;
|
||||||
|
if (density_type) {
|
||||||
|
norm = 1;
|
||||||
|
} else norm = 1.E6;
|
||||||
|
|
||||||
|
int nx = voxels->GetDims()(0);
|
||||||
|
int ny = voxels->GetDims()(1);
|
||||||
|
int nz = voxels->GetDims()(2);
|
||||||
|
|
||||||
|
size_t npoints = nx*ny*nz;
|
||||||
|
float *scalar = static_cast<float*>(image->GetScalarPointer());
|
||||||
|
|
||||||
|
StructuredData unwrap(*voxels);
|
||||||
|
unwrap.SetDataOrder(StructuredData::XYZ); // move to XYZ order (VTK)
|
||||||
|
for (size_t i = 0; i < npoints; i++) {
|
||||||
|
Vector3i idx = unwrap.UnMap(i);
|
||||||
|
scalar[i] = static_cast<float>(voxels->GetValue(idx) * norm);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a custom string key
|
||||||
|
static vtkInformationStringKey* ConfigNote =
|
||||||
|
vtkInformationStringKey::MakeKey("cmt.config", "Config");
|
||||||
|
|
||||||
|
// Attach metadata
|
||||||
|
vtkInformation *info = image->GetInformation();
|
||||||
|
info->Set(ConfigNote,
|
||||||
|
|
||||||
|
"This image was generated with uLib\n"
|
||||||
|
"-----------------------------------\n"
|
||||||
|
"Author: Andrea Rigoni\n"
|
||||||
|
"Version: 0.1\n"
|
||||||
|
"Date: 2025\n"
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
// std::cout << info->Get(ConfigNote) << std::endl;
|
||||||
|
vtkSmartPointer<vtkXMLImageDataWriter> writer = vtkSmartPointer<vtkXMLImageDataWriter>::New();
|
||||||
|
writer->SetFileName(file);
|
||||||
|
writer->SetInputData(image);
|
||||||
|
if(compressed) {
|
||||||
|
writer->SetDataModeToBinary();
|
||||||
|
writer->SetCompressorTypeToZLib();
|
||||||
|
}
|
||||||
|
writer->Write();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Abstract::VoxImage::ImportFromVti(const char *file, bool density_type) {
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkXMLImageDataReader> reader = vtkSmartPointer<vtkXMLImageDataReader>::New();
|
||||||
|
reader->SetFileName(file);
|
||||||
|
reader->Update();
|
||||||
|
vtkImageData *image = reader->GetOutput();
|
||||||
|
if(!image) return false;
|
||||||
|
|
||||||
|
Abstract::VoxImage *voxels = this;
|
||||||
|
int nx = image->GetDimensions()[0];
|
||||||
|
int ny = image->GetDimensions()[1];
|
||||||
|
int nz = image->GetDimensions()[2];
|
||||||
|
|
||||||
|
voxels->SetDims(Vector3i(nx,ny,nz));
|
||||||
|
voxels->SetSpacing(Vector3f(image->GetSpacing()[0],image->GetSpacing()[1],image->GetSpacing()[2]));
|
||||||
|
voxels->SetPosition(Vector3f(image->GetOrigin()[0],image->GetOrigin()[1],image->GetOrigin()[2]));
|
||||||
|
|
||||||
|
float norm;
|
||||||
|
if (density_type) {
|
||||||
|
norm = 1;
|
||||||
|
} else norm = 1.E6;
|
||||||
|
|
||||||
|
size_t npoints = nx*ny*nz;
|
||||||
|
float *scalar = static_cast<float*>(image->GetScalarPointer());
|
||||||
|
|
||||||
|
StructuredData wrap(*voxels);
|
||||||
|
wrap.SetDataOrder(StructuredData::XYZ);
|
||||||
|
for (size_t i = 0; i < npoints; i++) {
|
||||||
|
Vector3i idx = wrap.UnMap(i);
|
||||||
|
voxels->SetValue(idx, scalar[i] / norm);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int Abstract::VoxImage::ImportFromVtk(const char *file, bool density_type)
|
||||||
{
|
{
|
||||||
FILE * vtk_file = fopen(file, "r");
|
FILE * vtk_file = fopen(file, "r");
|
||||||
if (!vtk_file) return false;
|
if (!vtk_file) return false;
|
||||||
@@ -115,14 +218,18 @@ int Abstract::VoxImage::ImportFromVtk(const char *file)
|
|||||||
this->SetSpacing(Vector3f(sx,sy,sz));
|
this->SetSpacing(Vector3f(sx,sy,sz));
|
||||||
this->SetPosition(Vector3f(ox,oy,oz));
|
this->SetPosition(Vector3f(ox,oy,oz));
|
||||||
|
|
||||||
|
float norm;
|
||||||
|
if (density_type) {
|
||||||
|
norm = 1;
|
||||||
|
} else norm = 1.E6;
|
||||||
|
|
||||||
for (int k = 0; k < dz; ++k) {
|
for (int k = 0; k < dz; ++k) {
|
||||||
for (int j = 0; j < dy; ++j) {
|
for (int j = 0; j < dy; ++j) {
|
||||||
for (int i = 0; i < dx; ++i) {
|
for (int i = 0; i < dx; ++i) {
|
||||||
Vector3i idx(i, j, k);
|
Vector3i idx(i, j, k);
|
||||||
float tmp_val;
|
float tmp_val;
|
||||||
fscanf(vtk_file, "%f", &tmp_val);
|
fscanf(vtk_file, "%f", &tmp_val);
|
||||||
//this->SetValue(idx,fabs(tmp_val)*1E-6);
|
this->SetValue(idx,tmp_val / norm);
|
||||||
this->SetValue(idx,tmp_val*1E-6);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,13 @@
|
|||||||
#ifndef U_MATH_VOXIMAGE_H
|
#ifndef U_MATH_VOXIMAGE_H
|
||||||
#define U_MATH_VOXIMAGE_H
|
#define U_MATH_VOXIMAGE_H
|
||||||
|
|
||||||
#include "Core/Vector.h"
|
|
||||||
#include "Core/StaticInterface.h"
|
#include "Core/StaticInterface.h"
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
#include "Math/StructuredGrid.h"
|
#include "Math/StructuredGrid.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
@@ -56,8 +56,18 @@ public:
|
|||||||
virtual void SetDims(const Vector3i &size) = 0;
|
virtual void SetDims(const Vector3i &size) = 0;
|
||||||
|
|
||||||
void ExportToVtk(const char *file, bool density_type = 0);
|
void ExportToVtk(const char *file, bool density_type = 0);
|
||||||
|
|
||||||
|
// use this function to export to VTK binary format
|
||||||
|
void ExportToVti (const char *file, bool density_type = 0, bool compressed = 0);
|
||||||
|
|
||||||
|
// this function has been deprecated in favor of ExportToVti
|
||||||
|
// but it is kept for backward compatibility and because it
|
||||||
|
// does not depend on vtk library
|
||||||
void ExportToVtkXml(const char *file, bool density_type = 0);
|
void ExportToVtkXml(const char *file, bool density_type = 0);
|
||||||
int ImportFromVtk(const char *file);
|
|
||||||
|
int ImportFromVtk(const char *file, bool density_type = 0);
|
||||||
|
|
||||||
|
int ImportFromVti(const char *file, bool density_type = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -104,8 +114,8 @@ public:
|
|||||||
this->m_Data = copy.m_Data;
|
this->m_Data = copy.m_Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uLibRefMacro(Data,Vector<T>)
|
inline std::vector<T> & Data() { return this->m_Data; }
|
||||||
inline const Vector<T>& ConstData() const { return m_Data; }
|
inline const std::vector<T>& ConstData() const { return m_Data; }
|
||||||
|
|
||||||
inline const T& At(int i) const { return m_Data.at(i); }
|
inline const T& At(int i) const { return m_Data.at(i); }
|
||||||
inline const T& At(const Vector3i &id) const { return m_Data.at(Map(id)); }
|
inline const T& At(const Vector3i &id) const { return m_Data.at(Map(id)); }
|
||||||
@@ -213,7 +223,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<T> m_Data;
|
std::vector<T> m_Data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
||||||
@@ -72,7 +71,7 @@ public:
|
|||||||
|
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
void SetKernelNumericXZY(const Vector<float> &numeric);
|
void SetKernelNumericXZY(const std::vector<float> &numeric);
|
||||||
|
|
||||||
void SetKernelSpherical(float (*shape)(float));
|
void SetKernelSpherical(float (*shape)(float));
|
||||||
|
|
||||||
@@ -84,9 +83,9 @@ public:
|
|||||||
template < class ShapeT >
|
template < class ShapeT >
|
||||||
void SetKernelWeightFunction( ShapeT shape );
|
void SetKernelWeightFunction( ShapeT shape );
|
||||||
|
|
||||||
uLibGetMacro(KernelData,Kernel<VoxelT>)
|
inline Kernel<VoxelT> GetKernelData() const { return this->m_KernelData; }
|
||||||
|
|
||||||
uLibGetMacro(Image,VoxImage<VoxelT> *)
|
inline VoxImage<VoxelT>* GetImage() const { return this->m_Image; }
|
||||||
|
|
||||||
void SetImage(Abstract::VoxImage *image);
|
void SetImage(Abstract::VoxImage *image);
|
||||||
|
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ public:
|
|||||||
inline T& operator[](const int &id) { return m_Data[id]; }
|
inline T& operator[](const int &id) { return m_Data[id]; }
|
||||||
inline int GetCenterData() const;
|
inline int GetCenterData() const;
|
||||||
|
|
||||||
uLibRefMacro(Data,Vector<T>)
|
inline std::vector<T> & Data() { return this->m_Data; }
|
||||||
|
|
||||||
inline const Vector<T>& ConstData() const { return this->m_Data; }
|
inline const std::vector<T>& ConstData() const { return this->m_Data; }
|
||||||
|
|
||||||
void PrintSelf(std::ostream &o) const;
|
void PrintSelf(std::ostream &o) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<T> m_Data;
|
std::vector<T> m_Data;
|
||||||
};
|
};
|
||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
@@ -163,7 +163,7 @@ float VoxImageFilter<_TPLT_>::Distance2(const Vector3i &v)
|
|||||||
|
|
||||||
|
|
||||||
_TPL_
|
_TPL_
|
||||||
void VoxImageFilter<_TPLT_>::SetKernelNumericXZY(const Vector<float> &numeric)
|
void VoxImageFilter<_TPLT_>::SetKernelNumericXZY(const std::vector<float> &numeric)
|
||||||
{
|
{
|
||||||
// set data order //
|
// set data order //
|
||||||
StructuredData::Order order = m_KernelData.GetDataOrder();
|
StructuredData::Order order = m_KernelData.GetDataOrder();
|
||||||
@@ -268,8 +268,8 @@ void VoxImageFilter<_TPLT_>::SetImage(Abstract::VoxImage *image)
|
|||||||
_TPL_
|
_TPL_
|
||||||
float VoxImageFilter<_TPLT_>::Convolve(const VoxImage<VoxelT> &buffer, int index)
|
float VoxImageFilter<_TPLT_>::Convolve(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = m_KernelData.ConstData();
|
||||||
int vox_size = vbuf.size();
|
int vox_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public:
|
|||||||
|
|
||||||
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
||||||
int vox_size = vbuf.size();
|
int vox_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ public:
|
|||||||
|
|
||||||
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
||||||
int vox_size = vbuf.size();
|
int vox_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
Vector<VoxelT> mfh(ker_size);
|
std::vector<VoxelT> mfh(ker_size);
|
||||||
for (int i = 0; i < ker_size; ++i)
|
for (int i = 0; i < ker_size; ++i)
|
||||||
mfh[i].Count = i; //index key for ordering function
|
mfh[i].Count = i; //index key for ordering function
|
||||||
for (int ik = 0; ik < ker_size; ik++) {
|
for (int ik = 0; ik < ker_size; ik++) {
|
||||||
@@ -126,13 +126,13 @@ public:
|
|||||||
|
|
||||||
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
||||||
int vox_size = vbuf.size();
|
int vox_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
Vector<VoxelT> mfh(ker_size);
|
std::vector<VoxelT> mfh(ker_size);
|
||||||
for (int i = 0; i < ker_size; ++i)
|
for (int i = 0; i < ker_size; ++i)
|
||||||
mfh[i].Count = i; //index key for ordering function
|
mfh[i].Count = i; //index key for ordering function
|
||||||
for (int ik = 0; ik < ker_size; ik++) {
|
for (int ik = 0; ik < ker_size; ik++) {
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public:
|
|||||||
|
|
||||||
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
||||||
int vox_size = vbuf.size();
|
int vox_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
@@ -101,15 +101,15 @@ public:
|
|||||||
|
|
||||||
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
||||||
int img_size = vbuf.size();
|
int img_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector<FPair> mfh(ker_size);
|
std::vector<FPair> mfh(ker_size);
|
||||||
for (int i = 0; i < ker_size; ++i)
|
for (int i = 0; i < ker_size; ++i)
|
||||||
mfh[i].first = vker[i].Value; // kernel value in first
|
mfh[i].first = vker[i].Value; // kernel value in first
|
||||||
for (int ik = 0; ik < ker_size; ik++) {
|
for (int ik = 0; ik < ker_size; ik++) {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include "Math/VoxImage.h"
|
#include "Math/VoxImage.h"
|
||||||
#include "VoxImageFilter.h"
|
#include "VoxImageFilter.h"
|
||||||
|
|
||||||
|
#define likely(expr) __builtin_expect(!!(expr), 1)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
///// VOXIMAGE FILTER CUSTOM /////////////////////////////////////////////////
|
///// VOXIMAGE FILTER CUSTOM /////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -43,7 +45,7 @@ class VoxFilterAlgorithmCustom :
|
|||||||
public VoxImageFilter<VoxelT, VoxFilterAlgorithmCustom<VoxelT> > {
|
public VoxImageFilter<VoxelT, VoxFilterAlgorithmCustom<VoxelT> > {
|
||||||
|
|
||||||
|
|
||||||
typedef float (* FunctionPt)(const Vector<Scalarf> &);
|
typedef float (* FunctionPt)(const std::vector<Scalarf> &);
|
||||||
public:
|
public:
|
||||||
typedef VoxImageFilter<VoxelT, VoxFilterAlgorithmCustom<VoxelT> > BaseClass;
|
typedef VoxImageFilter<VoxelT, VoxFilterAlgorithmCustom<VoxelT> > BaseClass;
|
||||||
VoxFilterAlgorithmCustom(const Vector3i &size) :
|
VoxFilterAlgorithmCustom(const Vector3i &size) :
|
||||||
@@ -53,14 +55,14 @@ public:
|
|||||||
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
if(likely(m_CustomEvaluate)) {
|
if(likely(m_CustomEvaluate)) {
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
||||||
int vox_size = vbuf.size();
|
int vox_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
float ker_sum = 0;
|
float ker_sum = 0;
|
||||||
Vector<Scalarf> mfh(ker_size);
|
std::vector<Scalarf> mfh(ker_size);
|
||||||
for (int ik = 0; ik < ker_size; ik++) {
|
for (int ik = 0; ik < ker_size; ik++) {
|
||||||
pos = index + vker[ik].Count - vker[this->m_KernelData.GetCenterData()].Count;
|
pos = index + vker[ik].Count - vker[this->m_KernelData.GetCenterData()].Count;
|
||||||
pos = (pos + vox_size) % vox_size;
|
pos = (pos + vox_size) % vox_size;
|
||||||
@@ -76,7 +78,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uLibSetMacro(CustomEvaluate,FunctionPt)
|
inline void SetCustomEvaluate(FunctionPt funPt) { this->m_CustomEvaluate = funPt; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FunctionPt m_CustomEvaluate;
|
FunctionPt m_CustomEvaluate;
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public:
|
|||||||
|
|
||||||
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
||||||
int vox_size = vbuf.size();
|
int vox_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
|
|||||||
@@ -47,13 +47,13 @@ public:
|
|||||||
|
|
||||||
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
float Evaluate(const VoxImage<VoxelT> &buffer, int index)
|
||||||
{
|
{
|
||||||
const Vector<VoxelT> &vbuf = buffer.ConstData();
|
const std::vector<VoxelT> &vbuf = buffer.ConstData();
|
||||||
const Vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
const std::vector<VoxelT> &vker = this->m_KernelData.ConstData();
|
||||||
int vox_size = vbuf.size();
|
int vox_size = vbuf.size();
|
||||||
int ker_size = vker.size();
|
int ker_size = vker.size();
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
Vector<float> mfh(ker_size);
|
std::vector<float> mfh(ker_size);
|
||||||
for (int ik = 0; ik < ker_size; ik++) {
|
for (int ik = 0; ik < ker_size; ik++) {
|
||||||
pos = index + vker[ik].Count - vker[this->m_KernelData.GetCenterData()].Count;
|
pos = index + vker[ik].Count - vker[this->m_KernelData.GetCenterData()].Count;
|
||||||
pos = (pos + vox_size) % vox_size;
|
pos = (pos + vox_size) % vox_size;
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -23,11 +23,12 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "VoxRaytracer.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "VoxRaytracer.h"
|
||||||
|
|
||||||
|
#define unlikely(expr) __builtin_expect(!!(expr), 0)
|
||||||
|
|
||||||
inline float fast_sign(float f) { return 1 - 2 * (f < 0); }
|
inline float fast_sign(float f) { return 1 - 2 * (f < 0); }
|
||||||
|
|
||||||
@@ -37,215 +38,206 @@ namespace uLib {
|
|||||||
///// RAY DATA /////////////////////////////////////////////////////////////////
|
///// RAY DATA /////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void VoxRaytracer::RayData::AddElement(Id_t id, float L)
|
void VoxRaytracer::RayData::AddElement(Id_t id, float L) {
|
||||||
{
|
Element el = {id, L};
|
||||||
Element el = {id, L};
|
m_Data.push_back(el);
|
||||||
m_Data.push_back(el);
|
m_TotalLength += L;
|
||||||
m_TotalLength += L;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in) {
|
||||||
void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in)
|
if (unlikely(!in.m_Data.size())) {
|
||||||
{
|
std::cout << "Warinig: PoCA on exit border!\n";
|
||||||
if (unlikely(!in.m_Data.size())) {
|
return;
|
||||||
std::cout << "Warinig: PoCA on exit border!\n";
|
} else if (unlikely(!m_Data.size())) {
|
||||||
return;
|
m_Data = in.m_Data;
|
||||||
}
|
std::cout << "Warinig: PoCA on entrance border!\n";
|
||||||
else if (unlikely(!m_Data.size())) {
|
return;
|
||||||
m_Data = in.m_Data;
|
} else {
|
||||||
std::cout << "Warinig: PoCA on entrance border!\n";
|
// Opzione 1) un voxel in piu' //
|
||||||
return;
|
if (in.m_Data.size() > 0) {
|
||||||
}
|
m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
|
||||||
else {
|
|
||||||
// Opzione 1) un voxel in piu' //
|
|
||||||
m_Data.reserve(m_Data.size() + in.m_Data.size());
|
|
||||||
m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
|
|
||||||
// Opzione 2) merge dei voxel nel poca.
|
|
||||||
// RayData::Element &e1 = m_Data.back();
|
|
||||||
// const RayData::Element &e2 = in.m_Data.front();
|
|
||||||
// if(e1.vox_id == e2.vox_id)
|
|
||||||
// {
|
|
||||||
// m_Data.reserve(m_Data.size() + in.m_Data.size() - 1);
|
|
||||||
// e1.L += e2.L; //fix//
|
|
||||||
// m_Data.insert(m_Data.end(), in.m_Data.begin()+1, in.m_Data.end());
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// m_Data.reserve(m_Data.size() + in.m_Data.size());
|
|
||||||
// m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
|
|
||||||
// }
|
|
||||||
m_TotalLength += in.m_TotalLength;
|
|
||||||
}
|
}
|
||||||
|
// Opzione 2) merge dei voxel nel poca.
|
||||||
|
// RayData::Element &e1 = m_Data.back();
|
||||||
|
// const RayData::Element &e2 = in.m_Data.front();
|
||||||
|
// if(e1.vox_id == e2.vox_id)
|
||||||
|
// {
|
||||||
|
// m_Data.reserve(m_Data.size() + in.m_Data.size() - 1);
|
||||||
|
// e1.L += e2.L; //fix//
|
||||||
|
// m_Data.insert(m_Data.end(), in.m_Data.begin()+1,
|
||||||
|
// in.m_Data.end());
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// m_Data.reserve(m_Data.size() + in.m_Data.size());
|
||||||
|
// m_Data.insert(m_Data.end(), in.m_Data.begin(),
|
||||||
|
// in.m_Data.end());
|
||||||
|
// }
|
||||||
|
m_TotalLength += in.m_TotalLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxRaytracer::RayData::PrintSelf(std::ostream &o)
|
void VoxRaytracer::RayData::PrintSelf(std::ostream &o) {
|
||||||
{
|
o << "Ray: total lenght " << m_TotalLength << "\n";
|
||||||
o << "Ray: total lenght " << m_TotalLength << "\n";
|
std::vector<Element>::iterator it;
|
||||||
Vector<Element>::Iterator it;
|
for (it = m_Data.begin(); it < m_Data.end(); ++it)
|
||||||
for(it = m_Data.begin(); it < m_Data.end(); ++it)
|
o << "[ " << (*it).vox_id << ", " << (*it).L << "] \n";
|
||||||
o << "[ " << (*it).vox_id << ", " << (*it).L << "] \n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//// RAY TRACER ////////////////////////////////////////////////////////////////
|
//// RAY TRACER ////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt) {
|
||||||
|
Vector4f s = m_Image->GetLocalPoint(line.direction);
|
||||||
|
pt = m_Image->GetLocalPoint(line.origin);
|
||||||
|
|
||||||
bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt)
|
// Considers Structured grid dimensions //
|
||||||
{
|
Vector4f dims = m_Image->GetDims().homogeneous().cast<float>();
|
||||||
Vector4f s = m_Image->GetLocalPoint(line.direction);
|
pt = pt.cwiseQuotient(dims);
|
||||||
pt = m_Image->GetLocalPoint(line.origin);
|
s = s.cwiseQuotient(dims);
|
||||||
|
|
||||||
// Considers Structured grid dimensions //
|
float l = s.head(3).norm();
|
||||||
Vector4f dims = m_Image->GetDims().homogeneous().cast<float>();
|
Vector3f L(l / s(0), l / s(1), l / s(2));
|
||||||
pt = pt.cwiseQuotient(dims);
|
|
||||||
s = s.cwiseQuotient(dims);
|
|
||||||
|
|
||||||
float l = s.head(3).norm();
|
Vector3f offset;
|
||||||
Vector3f L(l/s(0), l/s(1), l/s(2));
|
for (int i = 0; i < 3; ++i)
|
||||||
|
offset(i) = (s(i) > 0) - (pt(i) - floor(pt(i)));
|
||||||
|
offset = offset.cwiseProduct(L).cwiseAbs();
|
||||||
|
|
||||||
Vector3f offset;
|
int id;
|
||||||
for(int i=0;i<3;++i)
|
float d;
|
||||||
offset(i) = (s(i)>0) - (pt(i)-floor(pt(i))) ;
|
for (int loop = 0; loop < 8; loop++) {
|
||||||
offset = offset.cwiseProduct(L).cwiseAbs();
|
int check_border = 0;
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
int id; float d;
|
check_border += pt(i) > 1;
|
||||||
for(int loop=0; loop<8; loop++)
|
check_border += pt(i) < 0;
|
||||||
{
|
|
||||||
int check_border = 0;
|
|
||||||
for ( int i=0; i<3 ;++i) {
|
|
||||||
check_border += pt(i) > 1;
|
|
||||||
check_border += pt(i) < 0;
|
|
||||||
}
|
|
||||||
if(check_border == 0) {
|
|
||||||
for(int i=0;i<3;++i)
|
|
||||||
pt(i) *= (float)dims(i);
|
|
||||||
pt = m_Image->GetWorldPoint(pt);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
d = offset.minCoeff(&id);
|
|
||||||
for(int i=0; i<3; ++i)
|
|
||||||
pt(i) += d / L(i);
|
|
||||||
|
|
||||||
pt(id) = rintf(pt(id));
|
|
||||||
|
|
||||||
|
|
||||||
offset.array() -= d;
|
|
||||||
offset(id) = fabs(L(id));
|
|
||||||
}
|
}
|
||||||
for(int i=0;i<3;++i)
|
if (check_border == 0) {
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
pt(i) *= (float)dims(i);
|
pt(i) *= (float)dims(i);
|
||||||
pt = m_Image->GetWorldPoint(pt);
|
pt = m_Image->GetWorldPoint(pt);
|
||||||
return false;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
bool VoxRaytracer::GetExitPoint(const HLine3f &line, HPoint3f &pt)
|
|
||||||
{
|
|
||||||
HLine3f out = line;
|
|
||||||
out.direction *= -1;
|
|
||||||
return GetEntryPoint(out,pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VoxRaytracer::RayData VoxRaytracer::TraceBetweenPoints(const HPoint3f &in,
|
|
||||||
const HPoint3f &out)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
RayData ray;
|
|
||||||
Vector4f pt1 = m_Image->GetLocalPoint(in);
|
|
||||||
Vector4f pt2 = m_Image->GetLocalPoint(out);
|
|
||||||
Vector4f s = pt2 - pt1;
|
|
||||||
|
|
||||||
float l = s.head(3).norm();
|
|
||||||
Vector3f L(l/s(0), l/s(1), l/s(2));
|
|
||||||
|
|
||||||
// Vector3f scale; // FIXXX
|
|
||||||
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
|
|
||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
|
||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
|
||||||
|
|
||||||
Vector3f offset;
|
|
||||||
for(int i=0;i<3;++i) offset(i) = (s(i)>=0) - (pt1(i)-floor(pt1(i))) ;
|
|
||||||
offset = offset.cwiseProduct(L).cwiseAbs();
|
|
||||||
L = L.cwiseAbs();
|
|
||||||
|
|
||||||
//---- Check if the ray only crosses one voxel
|
|
||||||
Vector3i vid = m_Image->Find(in);
|
|
||||||
if(vid == m_Image->Find(out)){
|
|
||||||
ray.AddElement(m_Image->Map(vid),s.norm());
|
|
||||||
return ray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- Otherwise, loop until ray is finished
|
d = offset.minCoeff(&id);
|
||||||
int id; float d;
|
for (int i = 0; i < 3; ++i)
|
||||||
while(l>0){
|
pt(i) += d / L(i);
|
||||||
|
|
||||||
d = offset.minCoeff(&id);
|
pt(id) = rintf(pt(id));
|
||||||
|
|
||||||
if(m_Image->IsInsideGrid(vid)){
|
offset.array() -= d;
|
||||||
ray.AddElement(m_Image->Map(vid), d * m_scale(id) );
|
offset(id) = fabs(L(id));
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
pt(i) *= (float)dims(i);
|
||||||
|
pt = m_Image->GetWorldPoint(pt);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// nan check //
|
bool VoxRaytracer::GetExitPoint(const HLine3f &line, HPoint3f &pt) {
|
||||||
// if(unlikely(!isFinite(d * scale(id)))) {
|
HLine3f out = line;
|
||||||
// std:: cout << "NAN in raytracer\n";
|
out.direction *= -1;
|
||||||
// exit(1);
|
return GetEntryPoint(out, pt);
|
||||||
// }
|
}
|
||||||
|
|
||||||
vid(id) += (int)fast_sign(s(id));
|
VoxRaytracer::RayData
|
||||||
|
VoxRaytracer::TraceBetweenPoints(const HPoint3f &in,
|
||||||
|
const HPoint3f &out) const {
|
||||||
|
RayData ray;
|
||||||
|
Vector4f pt1 = m_Image->GetLocalPoint(in);
|
||||||
|
Vector4f pt2 = m_Image->GetLocalPoint(out);
|
||||||
|
Vector4f s = pt2 - pt1;
|
||||||
|
|
||||||
l -= d;
|
float l = s.head(3).norm();
|
||||||
offset.array() -= d;
|
Vector3f L(l / s(0), l / s(1), l / s(2));
|
||||||
offset(id) = fmin(L(id),l);
|
|
||||||
}
|
// Vector3f scale; // FIXXX
|
||||||
|
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
|
||||||
|
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
||||||
|
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
||||||
|
|
||||||
|
Vector3f offset;
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
offset(i) = (s(i) >= 0) - (pt1(i) - floor(pt1(i)));
|
||||||
|
offset = offset.cwiseProduct(L).cwiseAbs();
|
||||||
|
L = L.cwiseAbs();
|
||||||
|
|
||||||
|
//---- Check if the ray only crosses one voxel
|
||||||
|
Vector3i vid = m_Image->Find(in);
|
||||||
|
if (vid == m_Image->Find(out)) {
|
||||||
|
ray.AddElement(m_Image->Map(vid), s.norm());
|
||||||
return ray;
|
return ray;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---- Otherwise, loop until ray is finished
|
||||||
|
int id;
|
||||||
|
float d;
|
||||||
|
while (l > 0) {
|
||||||
|
|
||||||
|
d = offset.minCoeff(&id);
|
||||||
|
|
||||||
|
if (m_Image->IsInsideGrid(vid)) {
|
||||||
|
ray.AddElement(m_Image->Map(vid), d * m_scale(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// nan check //
|
||||||
|
// if(unlikely(!isFinite(d * scale(id)))) {
|
||||||
|
// std:: cout << "NAN in raytracer\n";
|
||||||
|
// exit(1);
|
||||||
|
// }
|
||||||
|
|
||||||
|
vid(id) += (int)fast_sign(s(id));
|
||||||
|
|
||||||
|
l -= d;
|
||||||
|
offset.array() -= d;
|
||||||
|
offset(id) = fmin(L(id), l);
|
||||||
|
}
|
||||||
|
return ray;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 20150528 SV for absorbed muons
|
// 20150528 SV for absorbed muons
|
||||||
VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const
|
VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const {
|
||||||
{
|
RayData ray;
|
||||||
RayData ray;
|
|
||||||
|
|
||||||
Vector4f pt = m_Image->GetLocalPoint(line.origin);
|
Vector4f pt = m_Image->GetLocalPoint(line.origin);
|
||||||
Vector4f s = m_Image->GetLocalPoint(line.direction);
|
Vector4f s = m_Image->GetLocalPoint(line.direction);
|
||||||
|
|
||||||
float l = s.head(3).norm();
|
float l = s.head(3).norm();
|
||||||
// intersection between track and grid when spacing is +1
|
// intersection between track and grid when spacing is +1
|
||||||
Vector3f L(l/s(0), l/s(1), l/s(2));
|
Vector3f L(l / s(0), l / s(1), l / s(2));
|
||||||
|
|
||||||
// RayTracer works with a grid of interspace +1
|
// RayTracer works with a grid of interspace +1
|
||||||
// Vector3f scale; // FIXXX
|
// Vector3f scale; // FIXXX
|
||||||
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
|
// scale << (m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
|
||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
||||||
|
|
||||||
// offset is the fraction of the segment between grid lines when origin is insiede voxel
|
// offset is the fraction of the segment between grid lines when origin is
|
||||||
// cwiseAbs for having positive distances
|
// insiede voxel cwiseAbs for having positive distances
|
||||||
Vector3f offset;
|
Vector3f offset;
|
||||||
for(int i=0;i<3;++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
offset(i) = (s(i)>=0) - (pt(i)-floor(pt(i)));
|
offset(i) = (s(i) >= 0) - (pt(i) - floor(pt(i)));
|
||||||
offset = offset.cwiseProduct(L).cwiseAbs();
|
offset = offset.cwiseProduct(L).cwiseAbs();
|
||||||
L = L.cwiseAbs();
|
L = L.cwiseAbs();
|
||||||
|
|
||||||
int id; float d;
|
int id;
|
||||||
Vector3i vid = m_Image->Find(line.origin);
|
float d;
|
||||||
while(m_Image->IsInsideGrid(vid))
|
Vector3i vid = m_Image->Find(line.origin);
|
||||||
{
|
while (m_Image->IsInsideGrid(vid)) {
|
||||||
// minimun coefficient of offset: id is the coordinate, d is the value
|
// minimun coefficient of offset: id is the coordinate, d is the value
|
||||||
// dependig on which grid line horizontal or vertical it is first intercept
|
// dependig on which grid line horizontal or vertical it is first intercept
|
||||||
d = offset.minCoeff(&id);
|
d = offset.minCoeff(&id);
|
||||||
|
|
||||||
// add Lij to ray
|
// add Lij to ray
|
||||||
ray.AddElement(m_Image->Map(vid), d * m_scale(id) );
|
ray.AddElement(m_Image->Map(vid), d * m_scale(id));
|
||||||
|
|
||||||
// move to the next voxel
|
// move to the next voxel
|
||||||
vid(id) += (int)fast_sign(s(id));
|
vid(id) += (int)fast_sign(s(id));
|
||||||
|
|
||||||
offset.array() -= d;
|
offset.array() -= d;
|
||||||
offset(id) = L(id);
|
offset(id) = L(id);
|
||||||
}
|
}
|
||||||
return ray;
|
return ray;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace uLib
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
#define VOXRAYTRACER_H
|
#define VOXRAYTRACER_H
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Core/Vector.h"
|
|
||||||
#include "Math/StructuredGrid.h"
|
#include "Math/StructuredGrid.h"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
@@ -51,14 +51,15 @@ public:
|
|||||||
|
|
||||||
void AppendRay ( const RayData &in);
|
void AppendRay ( const RayData &in);
|
||||||
|
|
||||||
uLibConstRefMacro(Data,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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<Element> m_Data;
|
std::vector<Element> m_Data;
|
||||||
Scalarf m_TotalLength;
|
Scalarf m_TotalLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ public:
|
|||||||
|
|
||||||
RayData TraceLine(const HLine3f &line) const;
|
RayData TraceLine(const HLine3f &line) const;
|
||||||
|
|
||||||
uLibGetMacro(Image,StructuredGrid *)
|
inline StructuredGrid* GetImage() const { return this->m_Image; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StructuredGrid *m_Image;
|
StructuredGrid *m_Image;
|
||||||
|
|||||||
@@ -44,14 +44,16 @@ int test_ABTrim() {
|
|||||||
|
|
||||||
acc.SetABTrim(1,1);
|
acc.SetABTrim(1,1);
|
||||||
|
|
||||||
Vector<float> v;
|
std::vector<float> v;
|
||||||
v << 1,5,5,5,300;
|
for(float tmpf : {1,5,5,5,300}) v.push_back(tmpf);
|
||||||
|
//v << 1,5,5,5,300;
|
||||||
|
|
||||||
for(Vector<float>::Iterator itr=v.begin(); itr<v.end(); itr++)
|
for(std::vector<float>::iterator itr=v.begin(); itr<v.end(); itr++)
|
||||||
acc += *itr;
|
acc += *itr;
|
||||||
|
|
||||||
std::cout << "Accumulating Trim(1,1) vector: "
|
// TODO missing operator <<
|
||||||
<< v << " ... out = " << acc() << "\n";
|
//std::cout << "Accumulating Trim(1,1) vector: "
|
||||||
|
// << v << " ... out = " << acc() << "\n";
|
||||||
|
|
||||||
return( acc() == 15.0 );
|
return( acc() == 15.0 );
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ int test_Mean() {
|
|||||||
Accumulator_Mean<float> mean;
|
Accumulator_Mean<float> mean;
|
||||||
TRandom rnd;
|
TRandom rnd;
|
||||||
const int c = 10000000;
|
const int c = 10000000;
|
||||||
Vector<float> v;
|
std::vector<float> v;
|
||||||
v.reserve(c);
|
v.reserve(c);
|
||||||
for(int i=0;i<c;++i) v.push_back( rnd.Gaus(2000,5) );
|
for(int i=0;i<c;++i) v.push_back( rnd.Gaus(2000,5) );
|
||||||
|
|
||||||
|
|||||||
@@ -14,5 +14,9 @@ set(TESTS
|
|||||||
BitCodeTest
|
BitCodeTest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(LIBRARIES
|
||||||
|
${PACKAGE_LIBPREFIX}Core
|
||||||
|
${PACKAGE_LIBPREFIX}Math
|
||||||
|
)
|
||||||
|
|
||||||
uLib_add_tests(${uLib-module})
|
uLib_add_tests(Math)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static float MaxInVector(const Vector<float> &v)
|
static float MaxInVector(const std::vector<float> &v)
|
||||||
{
|
{
|
||||||
float max = 0;
|
float max = 0;
|
||||||
for(int i=0; i<v.size(); ++i)
|
for(int i=0; i<v.size(); ++i)
|
||||||
@@ -93,7 +93,7 @@ int main()
|
|||||||
|
|
||||||
VoxImage<TestVoxel> filtered = image;
|
VoxImage<TestVoxel> filtered = image;
|
||||||
|
|
||||||
Vector<float> values;
|
std::vector<float> values;
|
||||||
for(int i=0; i < filter.GetKernelData().GetDims().prod(); ++i) {
|
for(int i=0; i < filter.GetKernelData().GetDims().prod(); ++i) {
|
||||||
values.push_back(1.);
|
values.push_back(1.);
|
||||||
std::cout << values[i] << " ";
|
std::cout << values[i] << " ";
|
||||||
@@ -128,7 +128,7 @@ int main()
|
|||||||
|
|
||||||
VoxFilterAlgorithmCustom<TestVoxel> filter(Vector3i(3,3,4));
|
VoxFilterAlgorithmCustom<TestVoxel> filter(Vector3i(3,3,4));
|
||||||
|
|
||||||
Vector<float> values;
|
std::vector<float> values;
|
||||||
for(int i=0; i < filter.GetKernelData().GetDims().prod(); ++i) {
|
for(int i=0; i < filter.GetKernelData().GetDims().prod(); ++i) {
|
||||||
values.push_back(static_cast<float>(1));
|
values.push_back(static_cast<float>(1));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,20 @@ int main() {
|
|||||||
imgR.ExportToVtk("./read_and_saved.vtk");
|
imgR.ExportToVtk("./read_and_saved.vtk");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
VoxImage<TestVoxel> img(Vector3i(4,4,4));
|
||||||
|
img.InitVoxels({0,0});
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
for (int j=0; j<4; j++) {
|
||||||
|
for (int k=0; k<4; k++) {
|
||||||
|
img[Vector3i(i,j,k)] = {i+j+k,0};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
img.ExportToVti("./vti_saved.vti",0,1);
|
||||||
|
// img.ImportFromVtkXml("./test_vox_image.vti");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
VoxImage<TestVoxel> img1(Vector3i(5,5,5));
|
VoxImage<TestVoxel> img1(Vector3i(5,5,5));
|
||||||
|
|||||||
@@ -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";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,65 @@
|
|||||||
set(HEADERS
|
set(HEADERS RootMathDense.h
|
||||||
TestTObject.h
|
RootMuonScatter.h
|
||||||
RootMathDense.h
|
RootHitRaw.h
|
||||||
RootMuonScatter.h
|
muCastorMCTrack.h
|
||||||
RootHitRaw.h
|
muCastorHit.h
|
||||||
muBlastHit.h
|
muCastorInfo.h
|
||||||
muBlastMCTrack.h
|
muCastorSkinHit.h
|
||||||
muCastorMCTrack.h
|
muCastorPrimaryVertex.h
|
||||||
muCastorHit.h
|
muCastorMuDetDIGI.h
|
||||||
)
|
SkinDetectorWriter.h)
|
||||||
|
|
||||||
set(DICTIONARY_HEADERS
|
set(SOURCES ${HEADERS} RootMuonScatter.cpp
|
||||||
TestTObject.h
|
muCastorMCTrack.cpp
|
||||||
RootMathDense.h
|
muCastorHit.cpp
|
||||||
RootMuonScatter.h
|
muCastorInfo.cpp
|
||||||
RootHitRaw.h
|
muCastorSkinHit.cpp
|
||||||
muBlastHit.h
|
muCastorPrimaryVertex.cpp
|
||||||
muBlastMCTrack.h
|
muCastorMuDetDIGI.cpp
|
||||||
muCastorMCTrack.h
|
SkinDetectorWriter.cpp)
|
||||||
muCastorHit.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(SOURCES
|
set(DICTIONARY_HEADERS muCastorMCTrack.h
|
||||||
TestTObject.cpp
|
muCastorHit.h
|
||||||
RootMuonScatter.cpp
|
muCastorInfo.h
|
||||||
muBlastHit.cpp
|
muCastorSkinHit.h
|
||||||
muBlastMCTrack.cpp
|
muCastorPrimaryVertex.h
|
||||||
muCastorMCTrack.cpp
|
muCastorMuDetDIGI.h
|
||||||
muCastorHit.cpp
|
SkinDetectorWriter.h)
|
||||||
)
|
|
||||||
|
|
||||||
set(LIBRARIES
|
set(LIBRARIES ${ROOT_LIBRARIES}
|
||||||
# ${Boost_SERIALIZATION_LIBRARY}
|
${PACKAGE_LIBPREFIX}Math)
|
||||||
# ${Boost_SIGNALS_LIBRARY}
|
|
||||||
# ${Boost_PROGRAM_OPTIONS_LIBRARY}
|
|
||||||
${ROOT_LIBRARIES}
|
|
||||||
${PACKAGE_LIBPREFIX}Core
|
|
||||||
${PACKAGE_LIBPREFIX}Math
|
|
||||||
)
|
|
||||||
|
|
||||||
include(FindROOTv6)
|
set(rDictName ${PACKAGE_LIBPREFIX}RootDict)
|
||||||
root_generate_dictionary(uLibRootDict ${DICTIONARY_HEADERS} LINKDEF Linkdef.h)
|
root_generate_dictionary(${rDictName} ${DICTIONARY_HEADERS}
|
||||||
set_source_files_properties(uLibRootDict.cxx PROPERTIES GENERATED TRUE)
|
LINKDEF Linkdef.h)
|
||||||
set_source_files_properties(uLibRootDict.h PROPERTIES GENERATED TRUE)
|
set_source_files_properties(${rDictName}.cxx
|
||||||
list(APPEND SOURCES uLibRootDict.cxx)
|
PROPERTIES GENERATED TRUE)
|
||||||
|
set_source_files_properties(${rDictName}.h
|
||||||
|
PROPERTIES GENERATED TRUE)
|
||||||
|
list(APPEND SOURCES ${rDictName}.cxx)
|
||||||
|
|
||||||
|
# TODO use a custom target linked to root_generate_dictionary
|
||||||
|
set(R_ARTIFACTS ${CMAKE_CURRENT_BINARY_DIR}/lib${rDictName}_rdict.pcm
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/lib${rDictName}.rootmap)
|
||||||
|
install(FILES ${R_ARTIFACTS}
|
||||||
|
DESTINATION ${INSTALL_LIB_DIR})
|
||||||
|
|
||||||
|
set(libname ${PACKAGE_LIBPREFIX}Root)
|
||||||
|
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
||||||
|
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Root PARENT_SCOPE)
|
||||||
|
|
||||||
|
add_library(${libname} SHARED ${SOURCES})
|
||||||
|
set_target_properties(${libname} PROPERTIES
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
SOVERSION ${PROJECT_SOVERSION}
|
||||||
|
CXX_STANDARD 17)
|
||||||
|
target_link_libraries(${libname} ${LIBRARIES})
|
||||||
|
|
||||||
|
install(TARGETS ${libname}
|
||||||
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
|
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
||||||
|
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib)
|
||||||
|
|
||||||
|
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Root)
|
||||||
|
|
||||||
|
|
||||||
uLib_add_shared_library(${uLib-module})
|
|
||||||
add_subdirectory(testing)
|
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_ROOT_LINKDEF_H
|
#ifndef U_ROOT_LINKDEF_H
|
||||||
#define U_ROOT_LINKDEF_H
|
#define U_ROOT_LINKDEF_H
|
||||||
|
|
||||||
@@ -35,49 +33,21 @@
|
|||||||
#pragma link off all functions;
|
#pragma link off all functions;
|
||||||
#pragma link C++ nestedclasses;
|
#pragma link C++ nestedclasses;
|
||||||
|
|
||||||
#pragma link C++ class TestTObject+;
|
|
||||||
|
|
||||||
using namespace ROOT::Mutom;
|
using namespace ROOT::Mutom;
|
||||||
|
|
||||||
#pragma link C++ class ROOT::Math::Cartesian2D<int>+;
|
#pragma link C++ class ROOT::Math::Cartesian3D < int> + ;
|
||||||
#pragma link C++ class ROOT::Math::Cartesian2D<float>+;
|
#pragma link C++ class ROOT::Math::Cartesian3D < float> + ;
|
||||||
#pragma link C++ class ROOT::Math::Cartesian2D<double>+;
|
#pragma link C++ class ROOT::Math::Cartesian3D < double> + ;
|
||||||
|
|
||||||
#pragma link C++ class ROOT::Math::Cartesian3D<int>+;
|
|
||||||
#pragma link C++ class ROOT::Math::Cartesian3D<float>+;
|
|
||||||
#pragma link C++ class ROOT::Math::Cartesian3D<double>+;
|
|
||||||
|
|
||||||
#pragma link C++ class Vector2i+;
|
|
||||||
#pragma link C++ class Vector2f+;
|
|
||||||
#pragma link C++ class Vector2d+;
|
|
||||||
|
|
||||||
#pragma link C++ class Vector3i+;
|
|
||||||
#pragma link C++ class Vector3f+;
|
|
||||||
#pragma link C++ class Vector3d+;
|
|
||||||
|
|
||||||
#pragma link C++ typedef Matrix3i;
|
|
||||||
#pragma link C++ typedef Matrix3f;
|
|
||||||
#pragma link C++ typedef Matrix3d;
|
|
||||||
|
|
||||||
#pragma link C++ class Line3f+;
|
|
||||||
#pragma link C++ class Line3d+;
|
|
||||||
|
|
||||||
#pragma link C++ class MuonTrack+;
|
|
||||||
#pragma link C++ class MuonScatter+;
|
|
||||||
#pragma link C++ function MuonScatter::p_mean() const;
|
|
||||||
|
|
||||||
// #pragma link C++ class DetectorChamber+;
|
// #pragma link C++ class DetectorChamber+;
|
||||||
|
|
||||||
#pragma link C++ class HitRaw+;
|
#pragma link C++ class muCastorMCTrack + ;
|
||||||
#pragma link C++ function HitRaw::Chm() const;
|
#pragma link C++ class muCastorHit + ;
|
||||||
#pragma link C++ function HitRaw::Rob() const;
|
#pragma link C++ class muCastorInfo + ;
|
||||||
#pragma link C++ function HitRaw::Tdc() const;
|
#pragma link C++ class muCastorSkinHit + ;
|
||||||
#pragma link C++ function HitRaw::Ch() const;
|
#pragma link C++ class muCastorPrimaryVertex + ;
|
||||||
|
#pragma link C++ class muCastorMuDetDIGI + ;
|
||||||
#pragma link C++ class muBlastMCTrack+;
|
#pragma link C++ class SkinDetectorWriter + ;
|
||||||
#pragma link C++ class muBlastHit+;
|
|
||||||
#pragma link C++ class muCastorMCTrack+;
|
|
||||||
#pragma link C++ class muCastorHit+;
|
|
||||||
|
|
||||||
#endif // __CINT__
|
#endif // __CINT__
|
||||||
|
|
||||||
|
|||||||
47
src/Root/SkinDetectorWriter.cpp
Normal file
47
src/Root/SkinDetectorWriter.cpp
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#include "SkinDetectorWriter.h"
|
||||||
|
#include "muCastorSkinHit.h"
|
||||||
|
#include "TVector3.h"
|
||||||
|
|
||||||
|
SkinDetectorWriter::SkinDetectorWriter(string filename) :
|
||||||
|
t_file(nullptr),
|
||||||
|
t_tree(nullptr),
|
||||||
|
t_buffer(nullptr),
|
||||||
|
i_status(0)
|
||||||
|
{
|
||||||
|
t_file = new TFile(filename.c_str(), "RECREATE");
|
||||||
|
t_tree = new TTree("muCastorMC", "muCastorMC");
|
||||||
|
t_buffer = new TClonesArray("muCastorSkinHit");
|
||||||
|
|
||||||
|
t_tree->Branch("CastorSkinHits", "TClonesArray", t_buffer, 32000, 99);
|
||||||
|
|
||||||
|
if (t_file->IsZombie()) i_status = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkinDetectorWriter::~SkinDetectorWriter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void SkinDetectorWriter::add(int detID, float p_x, float p_y, float p_z,
|
||||||
|
float m_x, float m_y, float m_z)
|
||||||
|
{
|
||||||
|
TClonesArray& ref = *t_buffer;
|
||||||
|
int size = ref.GetEntriesFast();
|
||||||
|
|
||||||
|
muCastorSkinHit* new_hit = new(ref[size]) muCastorSkinHit();
|
||||||
|
new_hit->SetDetID(detID);
|
||||||
|
new_hit->SetPdgCode(13);
|
||||||
|
new_hit->SetMotherID(-1);
|
||||||
|
new_hit->SetPos (TVector3(p_x, p_y, p_z));
|
||||||
|
new_hit->SetMom (TVector3(m_x, m_y, m_z));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkinDetectorWriter::write()
|
||||||
|
{
|
||||||
|
if (t_tree->Fill() < 0) i_status = 2;
|
||||||
|
t_buffer->Delete(); // or t_buffer->Clear() ??
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkinDetectorWriter::close()
|
||||||
|
{
|
||||||
|
if (t_tree->Write() == 0) i_status = 3;
|
||||||
|
t_file->Close();
|
||||||
|
}
|
||||||
32
src/Root/SkinDetectorWriter.h
Normal file
32
src/Root/SkinDetectorWriter.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef SkinDetectorWriter_h
|
||||||
|
#define SkinDetectorWriter_h
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "TFile.h"
|
||||||
|
#include "TTree.h"
|
||||||
|
#include "TClonesArray.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
class SkinDetectorWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SkinDetectorWriter(string filename);
|
||||||
|
virtual ~SkinDetectorWriter();
|
||||||
|
|
||||||
|
void add(int detID, float p_x, float p_y, float p_z, float m_x, float m_y, float m_z);
|
||||||
|
int status() { return i_status; }
|
||||||
|
void write();
|
||||||
|
void close();
|
||||||
|
|
||||||
|
private:
|
||||||
|
TFile* t_file;
|
||||||
|
TTree* t_tree;
|
||||||
|
TClonesArray* t_buffer;
|
||||||
|
int i_status;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //SkinDetectorWriter_h
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
// Martin Subieta martin.subieta@ing.unibs.it
|
// Martin Subieta martin.subieta@ing.unibs.it
|
||||||
//########################################
|
//########################################
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "TObject.h"
|
#include "TObject.h"
|
||||||
#include "TParticle.h"
|
#include "TParticle.h"
|
||||||
|
|||||||
44
src/Root/muCastorInfo.cpp
Normal file
44
src/Root/muCastorInfo.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
//------------------------------------------------
|
||||||
|
// The Virtual Monte Carlo examples
|
||||||
|
// Copyright (C) 2007, 2008 Ivana Hrivnacova
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// For the licensing terms see geant4_vmc/LICENSE.
|
||||||
|
// Contact: vmc@pcroot.cern.ch
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
/// \file muCastorInfo.cxx
|
||||||
|
/// \brief Implementation of the muCastorInfo class
|
||||||
|
///
|
||||||
|
/// \author G. Bonomi, A. Donzella - INFN
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "muCastorInfo.h"
|
||||||
|
|
||||||
|
/// \cond CLASSIMP
|
||||||
|
ClassImp(muCastorInfo)
|
||||||
|
/// \endcond
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorInfo::muCastorInfo()
|
||||||
|
: fMuGen(-1)
|
||||||
|
{
|
||||||
|
/// Default constructor
|
||||||
|
}
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorInfo::~muCastorInfo()
|
||||||
|
{
|
||||||
|
/// Destructor
|
||||||
|
}
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
void muCastorInfo::Print(const Option_t* /*opt*/) const
|
||||||
|
{
|
||||||
|
/// Printing
|
||||||
|
|
||||||
|
cout << " Generated muons: " << fMuGen
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
44
src/Root/muCastorInfo.h
Normal file
44
src/Root/muCastorInfo.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef muCastor_RUN_H
|
||||||
|
#define muCastor_RUN_H
|
||||||
|
|
||||||
|
//------------------------------------------------
|
||||||
|
// The Virtual Monte Carlo examples
|
||||||
|
// Copyright (C) 2007, 2008 Ivana Hrivnacova
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// For the licensing terms see geant4_vmc/LICENSE.
|
||||||
|
// Contact: vmc@pcroot.cern.ch
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
/// \file muCastorInfo.h
|
||||||
|
/// \brief Definition of the muCastorInfo class
|
||||||
|
///
|
||||||
|
/// \authors G. Bonomi, A. Donzella - INFN
|
||||||
|
|
||||||
|
#include <TObject.h>
|
||||||
|
#include <TVector3.h>
|
||||||
|
|
||||||
|
class muCastorInfo : public TObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
muCastorInfo();
|
||||||
|
virtual ~muCastorInfo();
|
||||||
|
|
||||||
|
// methods
|
||||||
|
virtual void Print(const Option_t* option = "") const;
|
||||||
|
|
||||||
|
void SetMuGen (Int_t muGen) { fMuGen = muGen; };
|
||||||
|
void SetMuTrk (Int_t muTrk) { fMuTrk = muTrk; };
|
||||||
|
|
||||||
|
Int_t GetMuGen() { return fMuGen; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
Int_t fMuGen; // Generated muons
|
||||||
|
Int_t fMuTrk; // Tracked muons
|
||||||
|
|
||||||
|
ClassDef(muCastorInfo,1) //muCastorInfo
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //muCastor_RUN_H
|
||||||
|
|
||||||
|
|
||||||
@@ -6,11 +6,9 @@
|
|||||||
// Martin Subieta martin.subieta@ing.unibs.it
|
// Martin Subieta martin.subieta@ing.unibs.it
|
||||||
//******************************************************************************************
|
//******************************************************************************************
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "Detectors/MuonScatter.h"
|
|
||||||
#include <Root/muCastorMCTrack.h>
|
#include <Root/muCastorMCTrack.h>
|
||||||
#include <TClonesArray.h>
|
#include <TClonesArray.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -32,8 +30,6 @@ uLib::MuonScatter &operator << (uLib::MuonScatter &mu, const muCastorMCTrack &bs
|
|||||||
return mu;
|
return mu;
|
||||||
}
|
}
|
||||||
|
|
||||||
//namespace ROOT {
|
|
||||||
//namespace Mutom {
|
|
||||||
// ----- Default constructor -------------------------------------------
|
// ----- Default constructor -------------------------------------------
|
||||||
muCastorMCTrack::muCastorMCTrack()
|
muCastorMCTrack::muCastorMCTrack()
|
||||||
{
|
{
|
||||||
@@ -223,5 +219,3 @@ void muCastorMCTrack::Reset()
|
|||||||
fPntE = 0;
|
fPntE = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
//} // Mutom
|
|
||||||
//} // ROOT
|
|
||||||
|
|||||||
@@ -9,20 +9,14 @@
|
|||||||
// Martin Subieta martin.subieta@ing.unibs.it
|
// Martin Subieta martin.subieta@ing.unibs.it
|
||||||
//########################################
|
//########################################
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include "vector"
|
#include "vector"
|
||||||
#include "TObject.h"
|
#include "TObject.h"
|
||||||
#include "TParticle.h"
|
#include "TParticle.h"
|
||||||
|
#include "Detectors/MuonScatter.h"
|
||||||
|
|
||||||
class TClonesArray;
|
class TClonesArray;
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
|
||||||
class MuonScatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
//namespace ROOT {
|
|
||||||
//namespace Mutom {
|
|
||||||
|
|
||||||
class muCastorMCTrack : public TObject
|
class muCastorMCTrack : public TObject
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -89,8 +83,6 @@ public:
|
|||||||
ClassDef(muCastorMCTrack,1);
|
ClassDef(muCastorMCTrack,1);
|
||||||
|
|
||||||
};
|
};
|
||||||
//} // Mutom
|
|
||||||
//} // ROOT
|
|
||||||
|
|
||||||
uLib::MuonScatter &operator << (uLib::MuonScatter &mu, const muCastorMCTrack &bsmu);
|
uLib::MuonScatter &operator << (uLib::MuonScatter &mu, const muCastorMCTrack &bsmu);
|
||||||
#endif //muCastor_MCTRACK_H
|
#endif //muCastor_MCTRACK_H
|
||||||
|
|||||||
41
src/Root/muCastorMuDetDIGI.cpp
Normal file
41
src/Root/muCastorMuDetDIGI.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/// \file muCastorMuDetDIGI.cxx
|
||||||
|
/// \brief Implementation of the muCastorMuDetDIGI class
|
||||||
|
// This class build the DIGI for the scintillator detectors
|
||||||
|
/// \author G. Bonomi, M. Subieta - INFN
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "muCastorMuDetDIGI.h"
|
||||||
|
|
||||||
|
/// \cond CLASSIMP
|
||||||
|
ClassImp(muCastorMuDetDIGI)
|
||||||
|
/// \endcond
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorMuDetDIGI::muCastorMuDetDIGI() :
|
||||||
|
fDetID(-1),
|
||||||
|
fLayID(-1),
|
||||||
|
fTubID(-1),
|
||||||
|
fDistMC(0.),
|
||||||
|
fDriftMC(0.),
|
||||||
|
fDist(0.),
|
||||||
|
fDrift(0.),
|
||||||
|
fEnergy(0.)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorMuDetDIGI::~muCastorMuDetDIGI()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
void muCastorMuDetDIGI::Print(const Option_t* /*opt*/) const
|
||||||
|
{
|
||||||
|
cout << " DetID: " << fDetID
|
||||||
|
<< " LayID: " << fLayID
|
||||||
|
<< " TubID: " << fTubID
|
||||||
|
<< " energy deposit (keV): " << fEnergy
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
75
src/Root/muCastorMuDetDIGI.h
Normal file
75
src/Root/muCastorMuDetDIGI.h
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
#ifndef muCastor_MuDetDIGI_H
|
||||||
|
#define muCastor_MuDetDIGI_H
|
||||||
|
|
||||||
|
/// \file muCastorMuDetDIGI.h
|
||||||
|
/// \brief Definition of the muCastorMuDetDIGI class
|
||||||
|
///
|
||||||
|
/// \authors G. Bonomi, M. Subieta - INFN
|
||||||
|
|
||||||
|
#include <TObject.h>
|
||||||
|
|
||||||
|
class muCastorMuDetDIGI : public TObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
muCastorMuDetDIGI();
|
||||||
|
virtual ~muCastorMuDetDIGI();
|
||||||
|
|
||||||
|
// -------> PUBLIC FUNCTIONS
|
||||||
|
virtual void Print(const Option_t* option = "") const;
|
||||||
|
|
||||||
|
// -------> SET METHODS
|
||||||
|
|
||||||
|
/// Set Det ID (Detector module)
|
||||||
|
void SetDetID(Int_t id) { fDetID = id; };
|
||||||
|
|
||||||
|
/// Set Layer ID (Layer [0,5])
|
||||||
|
void SetLayID(Int_t id) { fLayID = id; };
|
||||||
|
|
||||||
|
/// Set Tube ID (Tube inside each layer)
|
||||||
|
void SetTubID(Int_t id) { fTubID = id; };
|
||||||
|
|
||||||
|
void SetDistMC (Double_t v) { fDistMC = v; };
|
||||||
|
void SetDriftMC (Double_t v) { fDriftMC= v; };
|
||||||
|
void SetDist (Double_t v) { fDist = v; };
|
||||||
|
void SetDrift (Double_t v) { fDrift = v; };
|
||||||
|
|
||||||
|
// Set energy
|
||||||
|
void SetEnergy(Double_t e) { fEnergy = e; };
|
||||||
|
|
||||||
|
// -------> GET METHODS
|
||||||
|
|
||||||
|
/// \return The Module number
|
||||||
|
Int_t GetDetID() { return fDetID; };
|
||||||
|
|
||||||
|
/// \return The Layer number
|
||||||
|
Int_t GetLayID() { return fLayID; };
|
||||||
|
|
||||||
|
/// \return The Tube number
|
||||||
|
Int_t GetTubID() { return fTubID; };
|
||||||
|
|
||||||
|
Double_t GetDistMC() { return fDistMC; };
|
||||||
|
Double_t GetDriftMC() { return fDriftMC; };
|
||||||
|
Double_t GetDist() { return fDist; };
|
||||||
|
Double_t GetDrift() { return fDrift; };
|
||||||
|
|
||||||
|
/// \return Get energy
|
||||||
|
Double_t GetEnergy() { return fEnergy; };
|
||||||
|
|
||||||
|
|
||||||
|
// -------> PRIVATE VARIABLES
|
||||||
|
private:
|
||||||
|
Int_t fDetID; // Detector module ID
|
||||||
|
Int_t fLayID; // Detector layer ID
|
||||||
|
Int_t fTubID; // Layer tube ID
|
||||||
|
Double_t fDistMC; // Minimum distance of particle tracks to the wire
|
||||||
|
Double_t fDriftMC; // Minimum drift time to the wire
|
||||||
|
Double_t fDist; // Minimum distance of particle tracks to the wire (with smearing)
|
||||||
|
Double_t fDrift; // Minimum drift time to the wire (with smearing)
|
||||||
|
Double_t fEnergy; // Energy released in the element
|
||||||
|
|
||||||
|
ClassDef(muCastorMuDetDIGI,1) //muCastorMuDetDIGI
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //muCastorMuDetDIGI_H
|
||||||
|
|
||||||
|
|
||||||
47
src/Root/muCastorPrimaryVertex.cpp
Normal file
47
src/Root/muCastorPrimaryVertex.cpp
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include "muCastorPrimaryVertex.h"
|
||||||
|
|
||||||
|
/// \cond CLASSIMP
|
||||||
|
ClassImp(muCastorPrimaryVertex)
|
||||||
|
/// \endcond
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorPrimaryVertex::muCastorPrimaryVertex() {
|
||||||
|
/// Default constructor
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorPrimaryVertex::~muCastorPrimaryVertex()
|
||||||
|
{
|
||||||
|
/// Destructor
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
void muCastorPrimaryVertex::Reset()
|
||||||
|
{
|
||||||
|
fPdgCode = 0;
|
||||||
|
fVx = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
fVy = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
fVz = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
fPx = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
fPy = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
fPz = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
fE = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
}
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
void muCastorPrimaryVertex::Print(const Option_t* /*opt*/) const
|
||||||
|
{
|
||||||
|
/// Printing
|
||||||
|
|
||||||
|
cout << " Primary particle PDG Code " << fPdgCode << endl;
|
||||||
|
cout << " Vertex: (" << fVx << ", " << fVy << ", " << fVz << ") cm" << endl;
|
||||||
|
cout << " Mom: (" << fPx << ", " << fPy << ", " << fPz << ") MeV/c" << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
53
src/Root/muCastorPrimaryVertex.h
Normal file
53
src/Root/muCastorPrimaryVertex.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#ifndef muCastor_PVTX_H
|
||||||
|
#define muCastor_PVTX_H
|
||||||
|
|
||||||
|
/// \brief Definition of the muCastorPrimaryVertex class
|
||||||
|
///
|
||||||
|
/// \authors G. Bonomi (04/02/2020)
|
||||||
|
|
||||||
|
#include <TObject.h>
|
||||||
|
|
||||||
|
class muCastorPrimaryVertex : public TObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
muCastorPrimaryVertex();
|
||||||
|
virtual ~muCastorPrimaryVertex();
|
||||||
|
|
||||||
|
// -------> PUBLIC FUNCTIONS
|
||||||
|
virtual void Print(const Option_t* option = "") const;
|
||||||
|
|
||||||
|
// -------> SET METHODS
|
||||||
|
|
||||||
|
void SetPdgCode(Int_t code) { fPdgCode = code; };
|
||||||
|
|
||||||
|
void SetVx(Double_t Vx) { fVx = Vx; };
|
||||||
|
void SetVy(Double_t Vy) { fVy = Vy; };
|
||||||
|
void SetVz(Double_t Vz) { fVz = Vz; };
|
||||||
|
|
||||||
|
void SetPx(Double_t Px) { fPx = Px; };
|
||||||
|
void SetPy(Double_t Py) { fPy = Py; };
|
||||||
|
void SetPz(Double_t Pz) { fPz = Pz; };
|
||||||
|
|
||||||
|
void SetE(Double_t E) { fE = E; };
|
||||||
|
|
||||||
|
void Reset();
|
||||||
|
private:
|
||||||
|
// -------> PRIVATE VARIABLES
|
||||||
|
Int_t fPdgCode; // PDG code of the particle
|
||||||
|
|
||||||
|
Double_t fVx; // x of production vertex
|
||||||
|
Double_t fVy; // y of production vertex
|
||||||
|
Double_t fVz; // z of production vertex
|
||||||
|
|
||||||
|
Double_t fPx; // x component of momentum
|
||||||
|
Double_t fPy; // y component of momentum
|
||||||
|
Double_t fPz; // z component of momentum
|
||||||
|
Double_t fE; // Energy
|
||||||
|
|
||||||
|
|
||||||
|
ClassDef(muCastorPrimaryVertex,1) //muCastorPrimaryVertex
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //muCastor_PVTX_H
|
||||||
|
|
||||||
|
|
||||||
43
src/Root/muCastorSkinHit.cpp
Normal file
43
src/Root/muCastorSkinHit.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
//----------------------------------------------------------
|
||||||
|
// Class : CastorSkinHit
|
||||||
|
// Date: October 2020
|
||||||
|
// Author: Germano Bonomi germano.bonomi@unibs.it
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "muCastorSkinHit.h"
|
||||||
|
|
||||||
|
/// \cond CLASSIMP
|
||||||
|
ClassImp(muCastorSkinHit)
|
||||||
|
/// \endcond
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorSkinHit::muCastorSkinHit() :
|
||||||
|
fDetID(-1),
|
||||||
|
fPdgCode(-1),
|
||||||
|
fMotherID(-1),
|
||||||
|
fMomX(0.),
|
||||||
|
fMomY(0.),
|
||||||
|
fMomZ(0.),
|
||||||
|
fPosX(0.),
|
||||||
|
fPosY(0.),
|
||||||
|
fPosZ(0.)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorSkinHit::~muCastorSkinHit()
|
||||||
|
{}
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
void muCastorSkinHit::Print(const Option_t* /*opt*/) const
|
||||||
|
{
|
||||||
|
cout << " detID: " << fDetID
|
||||||
|
<< " position (cm): ("
|
||||||
|
<< fPosX << ", " << fPosY << ", " << fPosZ << ")"
|
||||||
|
<< " momentum (MeV/c): ("
|
||||||
|
<< fMomX << ", " << fMomY << ", " << fMomZ << ")"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
52
src/Root/muCastorSkinHit.h
Normal file
52
src/Root/muCastorSkinHit.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
//----------------------------------------------------------
|
||||||
|
// Class : CastorSkinHit
|
||||||
|
// Date: October 2020
|
||||||
|
// Author: Germano Bonomi germano.bonomi@unibs.it
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef muCastor_SKINHIT_H
|
||||||
|
#define muCastor_SKINHIT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <TObject.h>
|
||||||
|
#include <TVector3.h>
|
||||||
|
|
||||||
|
class muCastorSkinHit : public TObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
muCastorSkinHit();
|
||||||
|
virtual ~muCastorSkinHit();
|
||||||
|
|
||||||
|
// methods
|
||||||
|
virtual void Print(const Option_t* option = "") const;
|
||||||
|
|
||||||
|
// set methods
|
||||||
|
void SetDetID(Int_t id) { fDetID = id; };
|
||||||
|
void SetPdgCode(Int_t pdg) { fPdgCode = pdg; };
|
||||||
|
void SetMotherID(Int_t mid) { fMotherID = mid; };
|
||||||
|
void SetMom(TVector3 xyz) { fMomX = xyz.X(); fMomY = xyz.Y(); fMomZ = xyz.Z(); };
|
||||||
|
void SetPos(TVector3 xyz) { fPosX = xyz.X(); fPosY = xyz.Y(); fPosZ = xyz.Z(); };
|
||||||
|
|
||||||
|
Int_t GetDetID() { return fDetID; }
|
||||||
|
Int_t GetPdgCode() { return fPdgCode; }
|
||||||
|
Int_t GetMotherID() { return fMotherID; }
|
||||||
|
TVector3 GetMom() { return TVector3(fMomX, fMomY, fMomZ); }
|
||||||
|
TVector3 GetPos() { return TVector3(fPosX, fPosY, fPosZ); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Int_t fDetID; // Detector module ID
|
||||||
|
Int_t fPdgCode; // Particle PDG Code
|
||||||
|
Int_t fMotherID; // Particle mother ID (-1 = primary, 0 = secondary, etc..)
|
||||||
|
Double_t fMomX; // Track momentum when releasing the hit (X)
|
||||||
|
Double_t fMomY; // Track momentum when releasing the hit (Y)
|
||||||
|
Double_t fMomZ; // Track momentum when releasing the hit (Z)
|
||||||
|
Double_t fPosX; // Hit coordinates (at the entrance of the detector) (X)
|
||||||
|
Double_t fPosY; // Hit coordinates (at the entrance of the detector) (Y)
|
||||||
|
Double_t fPosZ; // Hit coordinates (at the entrance of the detector) (Z)
|
||||||
|
|
||||||
|
ClassDef(muCastorSkinHit,1) //muCastorSkinHit
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //muCastort_SKINHIT_H
|
||||||
|
|
||||||
|
|
||||||
@@ -1,39 +1,38 @@
|
|||||||
set(HEADERS
|
set(HEADERS uLibVtkInterface.h
|
||||||
uLibVtkInterface.h
|
uLibVtkViewer.h
|
||||||
uLibVtkViewer.h
|
vtkContainerBox.h
|
||||||
vtkContainerBox.h
|
vtkMuonScatter.h
|
||||||
vtkMuonScatter.h
|
vtkStructuredGrid.h
|
||||||
vtkStructuredGrid.h
|
vtkVoxRaytracerRepresentation.h
|
||||||
vtkVoxRaytracerRepresentation.h
|
vtkVoxImage.h)
|
||||||
vtkVoxImage.h
|
|
||||||
# vtkHLineRepresentation.h
|
|
||||||
# vtkTriangleMesh.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(SOURCES
|
set(SOURCES uLibVtkInterface.cxx
|
||||||
uLibVtkInterface.cxx
|
uLibVtkViewer.cpp
|
||||||
uLibVtkViewer.cpp
|
vtkContainerBox.cpp
|
||||||
vtkContainerBox.cpp
|
vtkMuonScatter.cxx
|
||||||
vtkMuonScatter.cxx
|
vtkStructuredGrid.cpp
|
||||||
vtkStructuredGrid.cpp
|
vtkVoxRaytracerRepresentation.cpp
|
||||||
vtkVoxRaytracerRepresentation.cpp
|
vtkVoxImage.cpp)
|
||||||
vtkVoxImage.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(LIBRARIES
|
set(LIBRARIES Eigen3::Eigen
|
||||||
${Boost_SERIALIZATION_LIBRARY}
|
${ROOT_LIBRARIES}
|
||||||
${Boost_SIGNALS_LIBRARY}
|
${VTK_LIBRARIES}
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${PACKAGE_LIBPREFIX}Math)
|
||||||
${Eigen_LIBRARY}
|
|
||||||
${ROOT_LIBRARIES}
|
|
||||||
${Geant4_LIBRARIES}
|
|
||||||
${VTK_LIBRARIES}
|
|
||||||
${PACKAGE_LIBPREFIX}Core
|
|
||||||
${PACKAGE_LIBPREFIX}Math
|
|
||||||
${PACKAGE_LIBPREFIX}Detectors
|
|
||||||
${PACKAGE_LIBPREFIX}Vtk
|
|
||||||
)
|
|
||||||
|
|
||||||
uLib_add_shared_library(${uLib-module})
|
set(libname ${PACKAGE_LIBPREFIX}Vtk)
|
||||||
|
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
||||||
|
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Vtk PARENT_SCOPE)
|
||||||
|
|
||||||
|
add_library(${libname} SHARED ${SOURCES})
|
||||||
|
set_target_properties(${libname} PROPERTIES
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
SOVERSION ${PROJECT_SOVERSION})
|
||||||
|
target_link_libraries(${libname} ${LIBRARIES})
|
||||||
|
|
||||||
|
install(TARGETS ${libname}
|
||||||
|
EXPORT "${PROJECT_NAME}Targets"
|
||||||
|
RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT bin
|
||||||
|
LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib)
|
||||||
|
|
||||||
|
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Vtk)
|
||||||
|
|
||||||
add_subdirectory(testing)
|
|
||||||
|
|||||||
@@ -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})
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <vtkConfigure.h>
|
#include <vtkVersion.h>
|
||||||
#include <vtkProp.h>
|
#include <vtkProp.h>
|
||||||
#include <vtkActor.h>
|
#include <vtkActor.h>
|
||||||
#include <vtkSmartPointer.h>
|
#include <vtkSmartPointer.h>
|
||||||
|
|||||||
@@ -33,9 +33,6 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include <Core/Vector.h>
|
|
||||||
#include <Core/Object.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// vtk classes forward declaration //
|
// vtk classes forward declaration //
|
||||||
@@ -49,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();
|
||||||
|
|||||||
@@ -31,15 +31,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <vtkSmartPointer.h>
|
#include <vtkSmartPointer.h>
|
||||||
#include <vtkRenderWindow.h>
|
|
||||||
#include <vtkRenderer.h>
|
|
||||||
#include <vtkRendererCollection.h>
|
#include <vtkRendererCollection.h>
|
||||||
#include <vtkRenderWindowInteractor.h>
|
#include <vtkRenderWindowInteractor.h>
|
||||||
|
|
||||||
#include <vtkCornerAnnotation.h>
|
|
||||||
#include <vtkTextProperty.h>
|
#include <vtkTextProperty.h>
|
||||||
#include <vtkAxesActor.h>
|
#include <vtkAxesActor.h>
|
||||||
#include <vtkOrientationMarkerWidget.h>
|
|
||||||
#include <vtkCamera.h>
|
#include <vtkCamera.h>
|
||||||
|
|
||||||
#include "uLibVtkViewer.h"
|
#include "uLibVtkViewer.h"
|
||||||
@@ -47,141 +43,114 @@
|
|||||||
namespace uLib {
|
namespace uLib {
|
||||||
namespace Vtk {
|
namespace Vtk {
|
||||||
|
|
||||||
template <>
|
|
||||||
class Tie<Viewer> {
|
|
||||||
public:
|
|
||||||
void DoAction() {
|
|
||||||
std::cout << " VIEWER TIE !!! \n";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//// PIMPL /////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class ViewerPimpl {
|
|
||||||
public:
|
|
||||||
ViewerPimpl() :
|
|
||||||
m_RenderWindow(vtkRenderWindow::New()),
|
|
||||||
m_Renderer(vtkRenderer::New()),
|
|
||||||
m_Annotation(vtkCornerAnnotation::New()),
|
|
||||||
m_Marker(vtkOrientationMarkerWidget::New())
|
|
||||||
{
|
|
||||||
this->InstallPipe();
|
|
||||||
}
|
|
||||||
|
|
||||||
~ViewerPimpl() {
|
|
||||||
this->UninstallPipe();
|
|
||||||
|
|
||||||
m_Annotation->Delete();
|
|
||||||
m_Marker->Delete();
|
|
||||||
m_Renderer->Delete();
|
|
||||||
m_RenderWindow->Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
// members //
|
|
||||||
vtkRenderer *m_Renderer;
|
|
||||||
vtkRenderWindow *m_RenderWindow;
|
|
||||||
vtkCornerAnnotation *m_Annotation;
|
|
||||||
vtkOrientationMarkerWidget *m_Marker;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void InstallPipe()
|
|
||||||
{
|
|
||||||
m_RenderWindow->AddRenderer(m_Renderer);
|
|
||||||
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
|
|
||||||
vtkSmartPointer<vtkRenderWindowInteractor>::New();
|
|
||||||
renderWindowInteractor->SetRenderWindow(m_RenderWindow);
|
|
||||||
|
|
||||||
// annotation //
|
|
||||||
m_Annotation->GetTextProperty()->SetColor(1,1,1);
|
|
||||||
m_Annotation->GetTextProperty()->SetFontFamilyToArial();
|
|
||||||
m_Annotation->GetTextProperty()->SetOpacity(0.5);
|
|
||||||
m_Annotation->SetMaximumFontSize(10);
|
|
||||||
m_Annotation->SetText(0,"uLib VTK Viewer - OpenCMT all right reserved.");
|
|
||||||
m_Renderer->AddViewProp(m_Annotation);
|
|
||||||
|
|
||||||
// orientation marker //
|
|
||||||
vtkSmartPointer<vtkAxesActor> axes =
|
|
||||||
vtkSmartPointer<vtkAxesActor>::New();
|
|
||||||
m_Marker->SetInteractor(renderWindowInteractor);
|
|
||||||
m_Marker->SetOrientationMarker(axes);
|
|
||||||
m_Marker->SetViewport(0.0,0.0,0.2,0.2);
|
|
||||||
m_Marker->SetEnabled(true);
|
|
||||||
m_Marker->InteractiveOff();
|
|
||||||
|
|
||||||
// Must be rendered here in Vtk-6.0 or seg-fault //
|
|
||||||
m_RenderWindow->Render();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UninstallPipe() {
|
|
||||||
m_Renderer->RemoveAllViewProps();
|
|
||||||
m_Renderer->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
///// VTK VIEWER //////////////////////////////////////////////////////////////
|
///// VTK VIEWER //////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
Viewer::Viewer() : d(new ViewerPimpl) {}
|
Viewer::Viewer() :
|
||||||
|
m_RenderWindow(vtkRenderWindow::New()),
|
||||||
|
m_Renderer(vtkRenderer::New()),
|
||||||
|
m_Annotation(vtkCornerAnnotation::New()),
|
||||||
|
m_Marker(vtkOrientationMarkerWidget::New())
|
||||||
|
{
|
||||||
|
InstallPipe();
|
||||||
|
}
|
||||||
|
|
||||||
Viewer::~Viewer() { delete d; }
|
Viewer::~Viewer()
|
||||||
|
{
|
||||||
|
UninstallPipe();
|
||||||
|
|
||||||
|
m_Annotation->Delete();
|
||||||
|
m_Marker->Delete();
|
||||||
|
m_Renderer->Delete();
|
||||||
|
m_RenderWindow->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Viewer::InstallPipe()
|
||||||
|
{
|
||||||
|
m_RenderWindow->AddRenderer(m_Renderer);
|
||||||
|
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
|
||||||
|
vtkSmartPointer<vtkRenderWindowInteractor>::New();
|
||||||
|
renderWindowInteractor->SetRenderWindow(m_RenderWindow);
|
||||||
|
|
||||||
|
// annotation //
|
||||||
|
m_Annotation->GetTextProperty()->SetColor(1,1,1);
|
||||||
|
m_Annotation->GetTextProperty()->SetFontFamilyToArial();
|
||||||
|
m_Annotation->GetTextProperty()->SetOpacity(0.5);
|
||||||
|
m_Annotation->SetMaximumFontSize(10);
|
||||||
|
m_Annotation->SetText(0,"uLib VTK Viewer - OpenCMT all right reserved.");
|
||||||
|
m_Renderer->AddViewProp(m_Annotation);
|
||||||
|
|
||||||
|
// orientation marker //
|
||||||
|
vtkSmartPointer<vtkAxesActor> axes =
|
||||||
|
vtkSmartPointer<vtkAxesActor>::New();
|
||||||
|
m_Marker->SetInteractor(renderWindowInteractor);
|
||||||
|
m_Marker->SetOrientationMarker(axes);
|
||||||
|
m_Marker->SetViewport(0.0,0.0,0.2,0.2);
|
||||||
|
m_Marker->SetEnabled(true);
|
||||||
|
m_Marker->InteractiveOff();
|
||||||
|
|
||||||
|
// Must be rendered here in Vtk-6.0 or seg-fault //
|
||||||
|
m_RenderWindow->Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Viewer::UninstallPipe()
|
||||||
|
{
|
||||||
|
m_Renderer->RemoveAllViewProps();
|
||||||
|
m_Renderer->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
void Viewer::addProp(vtkProp *prop)
|
void Viewer::addProp(vtkProp *prop)
|
||||||
{
|
{
|
||||||
d->m_Renderer->AddActor(prop);
|
m_Renderer->AddActor(prop);
|
||||||
d->m_Renderer->Render();
|
m_Renderer->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::RemoveProp(vtkProp *prop)
|
void Viewer::RemoveProp(vtkProp *prop)
|
||||||
{
|
{
|
||||||
d->m_Renderer->RemoveViewProp(prop);
|
m_Renderer->RemoveViewProp(prop);
|
||||||
d->m_Renderer->Render();
|
m_Renderer->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::AddPuppet(Puppet &prop)
|
void Viewer::AddPuppet(Puppet &prop)
|
||||||
{
|
{
|
||||||
prop.ConnectRenderer(d->m_Renderer);
|
prop.ConnectRenderer(m_Renderer);
|
||||||
d->m_Renderer->Render();
|
m_Renderer->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::RemovePuppet(Puppet &prop)
|
void Viewer::RemovePuppet(Puppet &prop)
|
||||||
{
|
{
|
||||||
prop.DisconnectRenderer(d->m_Renderer);
|
prop.DisconnectRenderer(m_Renderer);
|
||||||
d->m_Renderer->Render();
|
m_Renderer->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::Start()
|
void Viewer::Start()
|
||||||
{
|
{
|
||||||
d->m_RenderWindow->GetInteractor()->Start();
|
m_RenderWindow->GetInteractor()->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkCornerAnnotation *Viewer::GetAnnotation()
|
vtkCornerAnnotation *Viewer::GetAnnotation()
|
||||||
{
|
{
|
||||||
return d->m_Annotation;
|
return m_Annotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkRenderer *Viewer::GetRenderer()
|
vtkRenderer *Viewer::GetRenderer()
|
||||||
{
|
{
|
||||||
return d->m_Renderer;
|
return m_Renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkRenderWindowInteractor *Viewer::GetInteractor()
|
vtkRenderWindowInteractor *Viewer::GetInteractor()
|
||||||
{
|
{
|
||||||
return d->m_RenderWindow->GetInteractor();
|
return m_RenderWindow->GetInteractor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::Reset()
|
void Viewer::Reset()
|
||||||
{
|
{
|
||||||
d->m_Renderer->ResetCameraClippingRange();
|
m_Renderer->ResetCameraClippingRange();
|
||||||
d->m_Renderer->ResetCamera();
|
m_Renderer->ResetCamera();
|
||||||
d->m_Renderer->Render();
|
m_Renderer->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,13 @@
|
|||||||
#ifndef ULIBVTKVIEWER_H
|
#ifndef ULIBVTKVIEWER_H
|
||||||
#define ULIBVTKVIEWER_H
|
#define ULIBVTKVIEWER_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include "uLibVtkInterface.h"
|
#include "uLibVtkInterface.h"
|
||||||
|
|
||||||
|
#include <vtkRenderer.h>
|
||||||
|
#include <vtkRenderWindow.h>
|
||||||
|
#include <vtkCornerAnnotation.h>
|
||||||
|
#include <vtkOrientationMarkerWidget.h>
|
||||||
|
|
||||||
class vtkProp;
|
class vtkProp;
|
||||||
class vtk3DWidget;
|
class vtk3DWidget;
|
||||||
@@ -78,10 +83,22 @@ public:
|
|||||||
void RemoveProp(vtkProp *prop);
|
void RemoveProp(vtkProp *prop);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ViewerPimpl *d;
|
void InstallPipe();
|
||||||
|
void UninstallPipe();
|
||||||
|
|
||||||
|
vtkRenderer *m_Renderer;
|
||||||
|
vtkRenderWindow *m_RenderWindow;
|
||||||
|
vtkCornerAnnotation *m_Annotation;
|
||||||
|
vtkOrientationMarkerWidget *m_Marker;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> class Tie<Viewer>;
|
template <>
|
||||||
|
class Tie<Viewer> {
|
||||||
|
public:
|
||||||
|
void DoAction() {
|
||||||
|
std::cout << " VIEWER TIE !!! \n";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // vtk
|
} // vtk
|
||||||
|
|||||||
@@ -46,57 +46,32 @@ namespace uLib {
|
|||||||
namespace Vtk {
|
namespace Vtk {
|
||||||
|
|
||||||
|
|
||||||
// PIMPL -------------------------------------------------------------------- //
|
|
||||||
|
|
||||||
class vtkContainerBoxPimpl {
|
|
||||||
public:
|
|
||||||
vtkContainerBoxPimpl() :
|
|
||||||
m_Cube(vtkActor::New()),
|
|
||||||
m_Axes(vtkActor::New()),
|
|
||||||
m_Pivot(vtkActor::New()),
|
|
||||||
m_Content(NULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~vtkContainerBoxPimpl()
|
|
||||||
{
|
|
||||||
m_Cube->Delete();
|
|
||||||
m_Axes->Delete();
|
|
||||||
m_Pivot->Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
// MEMBERS //
|
|
||||||
vtkActor *m_Cube;
|
|
||||||
vtkActor *m_Axes;
|
|
||||||
vtkActor *m_Pivot;
|
|
||||||
vtkContainerBox::Content *m_Content;
|
|
||||||
};
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------- //
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vtkContainerBox::vtkContainerBox(vtkContainerBox::Content &content) :
|
vtkContainerBox::vtkContainerBox(vtkContainerBox::Content &content) :
|
||||||
d( new vtkContainerBoxPimpl)
|
m_Cube(vtkActor::New()),
|
||||||
|
m_Axes(vtkActor::New()),
|
||||||
|
m_Pivot(vtkActor::New()),
|
||||||
|
m_Content(&content)
|
||||||
{
|
{
|
||||||
d->m_Content = &content;
|
|
||||||
this->InstallPipe();
|
this->InstallPipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkContainerBox::~vtkContainerBox()
|
vtkContainerBox::~vtkContainerBox()
|
||||||
{
|
{
|
||||||
delete d;
|
m_Cube->Delete();
|
||||||
|
m_Axes->Delete();
|
||||||
|
m_Pivot->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData *vtkContainerBox::GetPolyData() const
|
vtkPolyData *vtkContainerBox::GetPolyData() const
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkContainerBox::InstallPipe()
|
void vtkContainerBox::InstallPipe()
|
||||||
{
|
{
|
||||||
if(!d->m_Content) return;
|
if(!m_Content) return;
|
||||||
Content *c = d->m_Content;
|
Content *c = m_Content;
|
||||||
|
|
||||||
// CUBE
|
// CUBE
|
||||||
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();
|
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();
|
||||||
@@ -113,9 +88,9 @@ void vtkContainerBox::InstallPipe()
|
|||||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
mapper->SetInputConnection(cube->GetOutputPort());
|
mapper->SetInputConnection(cube->GetOutputPort());
|
||||||
mapper->Update();
|
mapper->Update();
|
||||||
d->m_Cube->SetMapper(mapper);
|
m_Cube->SetMapper(mapper);
|
||||||
d->m_Cube->GetProperty()->SetRepresentationToWireframe();
|
m_Cube->GetProperty()->SetRepresentationToWireframe();
|
||||||
d->m_Cube->GetProperty()->SetAmbient(0.7);
|
m_Cube->GetProperty()->SetAmbient(0.7);
|
||||||
|
|
||||||
// AXES //
|
// AXES //
|
||||||
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New();
|
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New();
|
||||||
@@ -123,12 +98,12 @@ void vtkContainerBox::InstallPipe()
|
|||||||
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
mapper->SetInputConnection(axes->GetOutputPort());
|
mapper->SetInputConnection(axes->GetOutputPort());
|
||||||
mapper->Update();
|
mapper->Update();
|
||||||
d->m_Axes->SetMapper(mapper);
|
m_Axes->SetMapper(mapper);
|
||||||
Vector3f s = c->GetSize();
|
Vector3f s = c->GetSize();
|
||||||
// d->m_Axes->SetScale(s(0),s(1),s(2));
|
// m_Axes->SetScale(s(0),s(1),s(2));
|
||||||
d->m_Axes->GetProperty()->SetLineWidth(3);
|
m_Axes->GetProperty()->SetLineWidth(3);
|
||||||
d->m_Axes->GetProperty()->SetAmbient(0.4);
|
m_Axes->GetProperty()->SetAmbient(0.4);
|
||||||
d->m_Axes->GetProperty()->SetSpecular(0);
|
m_Axes->GetProperty()->SetSpecular(0);
|
||||||
|
|
||||||
// PIVOT //
|
// PIVOT //
|
||||||
axes = vtkSmartPointer<vtkAxes>::New();
|
axes = vtkSmartPointer<vtkAxes>::New();
|
||||||
@@ -136,16 +111,16 @@ void vtkContainerBox::InstallPipe()
|
|||||||
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
mapper->SetInputConnection(axes->GetOutputPort());
|
mapper->SetInputConnection(axes->GetOutputPort());
|
||||||
mapper->Update();
|
mapper->Update();
|
||||||
d->m_Pivot->SetMapper(mapper);
|
m_Pivot->SetMapper(mapper);
|
||||||
s = c->GetScale();
|
s = c->GetScale();
|
||||||
// d->m_Pivot->SetScale(s(0),s(1),s(2));
|
// m_Pivot->SetScale(s(0),s(1),s(2));
|
||||||
d->m_Pivot->GetProperty()->SetLineWidth(3);
|
m_Pivot->GetProperty()->SetLineWidth(3);
|
||||||
d->m_Pivot->GetProperty()->SetAmbient(0.4);
|
m_Pivot->GetProperty()->SetAmbient(0.4);
|
||||||
d->m_Pivot->GetProperty()->SetSpecular(0);
|
m_Pivot->GetProperty()->SetSpecular(0);
|
||||||
|
|
||||||
this->SetProp(d->m_Cube);
|
this->SetProp(m_Cube);
|
||||||
this->SetProp(d->m_Axes);
|
this->SetProp(m_Axes);
|
||||||
this->SetProp(d->m_Pivot);
|
this->SetProp(m_Pivot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
void InstallPipe();
|
void InstallPipe();
|
||||||
|
|
||||||
friend class vtkContainerBoxPimpl;
|
vtkActor *m_Cube;
|
||||||
class vtkContainerBoxPimpl *d;
|
vtkActor *m_Axes;
|
||||||
|
vtkActor *m_Pivot;
|
||||||
|
vtkContainerBox::Content *m_Content;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // vtk
|
} // vtk
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
#include "uLibVtkInterface.h"
|
#include "uLibVtkInterface.h"
|
||||||
@@ -66,8 +65,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void InstallPipe();
|
void InstallPipe();
|
||||||
|
|
||||||
friend class vtkMuonContainerScatteringPimpl;
|
|
||||||
class vtkMuonContainerScatteringPimpl *d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,22 +29,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <vtkSmartPointer.h>
|
|
||||||
#include <vtkSphereSource.h>
|
|
||||||
#include <vtkAppendPolyData.h>
|
|
||||||
#include <vtkPolyDataMapper.h>
|
|
||||||
#include <vtkLineSource.h>
|
|
||||||
#include <vtkActor.h>
|
|
||||||
|
|
||||||
#include <vtk3DWidget.h>
|
|
||||||
#include <vtkBoxWidget.h>
|
|
||||||
|
|
||||||
#include <vtkRenderWindowInteractor.h>
|
|
||||||
|
|
||||||
#include <vtkCommand.h>
|
|
||||||
#include <vtkTransform.h>
|
|
||||||
|
|
||||||
#include "vtkMuonEvent.h"
|
#include "vtkMuonEvent.h"
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
@@ -72,105 +56,77 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//// PIMPL /////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class vtkMuonEventPimpl {
|
|
||||||
typedef vtkWidgetCallback Callback;
|
|
||||||
public:
|
|
||||||
vtkMuonEventPimpl() :
|
|
||||||
m_Prop(vtkActor::New()),
|
|
||||||
m_PolyData(NULL),
|
|
||||||
m_Appender(vtkAppendPolyData::New()),
|
|
||||||
content(NULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~vtkMuonEventPimpl()
|
|
||||||
{
|
|
||||||
m_Prop->Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
// members //
|
|
||||||
vtkMuonEvent::Content *content;
|
|
||||||
vtkPolyData *m_PolyData;
|
|
||||||
vtkActor *m_Prop;
|
|
||||||
|
|
||||||
vtkAppendPolyData *m_Appender;
|
|
||||||
vtkBoxWidget *m_WidgetIN, *m_WidgetOUT;
|
|
||||||
HPoint3f m_Poca;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
///// VTK MUON EVENT /////////////////////////////////////////////////////////
|
///// VTK MUON EVENT /////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
vtkMuonEvent::vtkMuonEvent(MuonEventData &content) :
|
vtkMuonEvent::vtkMuonEvent(MuonEventData &content) :
|
||||||
d(new vtkMuonEventPimpl)
|
m_Prop(vtkActor::New()),
|
||||||
|
m_PolyData(NULL),
|
||||||
|
m_Appender(vtkAppendPolyData::New()),
|
||||||
|
content(&content)
|
||||||
{
|
{
|
||||||
d->content = &content;
|
InstallPipe();
|
||||||
InstallPipe();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkMuonEvent::vtkMuonEvent(const MuonEventData &content) :
|
vtkMuonEvent::vtkMuonEvent(const MuonEventData &content) :
|
||||||
d(new vtkMuonEventPimpl)
|
m_Prop(vtkActor::New()),
|
||||||
|
m_PolyData(NULL),
|
||||||
|
m_Appender(vtkAppendPolyData::New()),
|
||||||
|
content(const_cast<MuonEventData *>(&content))
|
||||||
{
|
{
|
||||||
d->content = const_cast<MuonEventData *>(&content);
|
InstallPipe();
|
||||||
InstallPipe();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vtkMuonEvent::~vtkMuonEvent()
|
vtkMuonEvent::~vtkMuonEvent()
|
||||||
{
|
{
|
||||||
if (d->m_Prop) d->m_Prop->Delete();
|
if (m_Prop) m_Prop->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkMuonEvent::Content &vtkMuonEvent::GetContent()
|
vtkMuonEvent::Content &vtkMuonEvent::GetContent()
|
||||||
{
|
{
|
||||||
return *d->content;
|
return *content;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkMuonEvent::PrintSelf(std::ostream &o) const
|
void vtkMuonEvent::PrintSelf(std::ostream &o) const
|
||||||
{
|
{
|
||||||
o << "..:: MuonEvent ::..\n" \
|
o << "..:: MuonEvent ::..\n" \
|
||||||
"\t[in] Origin > " << d->content->LineIn().origin.transpose() << "\n" <<
|
"\t[in] Origin > " << content->LineIn().origin.transpose() << "\n" <<
|
||||||
"\t[in] Direction > " << d->content->LineIn().direction.transpose() << "\n" <<
|
"\t[in] Direction > " << content->LineIn().direction.transpose() << "\n" <<
|
||||||
"\t[out] Origin > " << d->content->LineOut().origin.transpose() << "\n" <<
|
"\t[out] Origin > " << content->LineOut().origin.transpose() << "\n" <<
|
||||||
"\t[out] Direction > " << d->content->LineOut().direction.transpose()<< "\n" <<
|
"\t[out] Direction > " << content->LineOut().direction.transpose()<< "\n" <<
|
||||||
"\tMomentum > " << d->content->GetMomentum() << "\n" <<
|
"\tMomentum > " << content->GetMomentum() << "\n" <<
|
||||||
"...................\n";
|
"...................\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkProp *vtkMuonEvent::GetProp()
|
vtkProp *vtkMuonEvent::GetProp()
|
||||||
{
|
{
|
||||||
return d->m_Prop;
|
return m_Prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkMuonEvent::InstallPipe()
|
void vtkMuonEvent::InstallPipe()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
vtkAppendPolyData *appender = d->m_Appender;
|
vtkAppendPolyData *appender = m_Appender;
|
||||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
|
|
||||||
if(d->content) {
|
if(content) {
|
||||||
vtkSmartPointer<vtkLineSource> line_in = vtkSmartPointer<vtkLineSource>::New();
|
vtkSmartPointer<vtkLineSource> line_in = vtkSmartPointer<vtkLineSource>::New();
|
||||||
vtkSmartPointer<vtkLineSource> line_out = vtkSmartPointer<vtkLineSource>::New();
|
vtkSmartPointer<vtkLineSource> line_out = vtkSmartPointer<vtkLineSource>::New();
|
||||||
|
|
||||||
float distance = (d->content->LineIn().origin - d->content->LineOut().origin).norm() / 10;
|
float distance = (content->LineIn().origin - content->LineOut().origin).norm() / 10;
|
||||||
|
|
||||||
HPoint3f pt;
|
HPoint3f pt;
|
||||||
pt = d->content->LineIn().origin;
|
pt = content->LineIn().origin;
|
||||||
line_in->SetPoint1(pt(0),pt(1),pt(2));
|
line_in->SetPoint1(pt(0),pt(1),pt(2));
|
||||||
pt= d->content->LineIn().origin + d->content->LineIn().direction * distance;
|
pt= content->LineIn().origin + content->LineIn().direction * distance;
|
||||||
line_in->SetPoint2(pt(0),pt(1),pt(2));
|
line_in->SetPoint2(pt(0),pt(1),pt(2));
|
||||||
pt = d->content->LineOut().origin;
|
pt = content->LineOut().origin;
|
||||||
line_out->SetPoint1(pt(0),pt(1),pt(2));
|
line_out->SetPoint1(pt(0),pt(1),pt(2));
|
||||||
pt = d->content->LineOut().origin + d->content->LineOut().direction * distance;
|
pt = content->LineOut().origin + content->LineOut().direction * distance;
|
||||||
line_out->SetPoint2(pt(0),pt(1),pt(2));
|
line_out->SetPoint2(pt(0),pt(1),pt(2));
|
||||||
|
|
||||||
appender->AddInputConnection(line_in->GetOutputPort());
|
appender->AddInputConnection(line_in->GetOutputPort());
|
||||||
@@ -180,31 +136,31 @@ void vtkMuonEvent::InstallPipe()
|
|||||||
appender->Update();
|
appender->Update();
|
||||||
mapper->SetInputConnection(appender->GetOutputPort());
|
mapper->SetInputConnection(appender->GetOutputPort());
|
||||||
mapper->Update();
|
mapper->Update();
|
||||||
d->m_Prop->SetMapper(mapper);
|
m_Prop->SetMapper(mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData *vtkMuonEvent::GetPolyData() const
|
vtkPolyData *vtkMuonEvent::GetPolyData() const
|
||||||
{
|
{
|
||||||
return d->m_Appender->GetOutput();
|
return m_Appender->GetOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkMuonEvent::AddPocaPoint(HPoint3f poca)
|
void vtkMuonEvent::AddPocaPoint(HPoint3f poca)
|
||||||
{
|
{
|
||||||
d->m_Poca = poca;
|
m_Poca = poca;
|
||||||
vtkSmartPointer<vtkSphereSource> sphere =
|
vtkSmartPointer<vtkSphereSource> sphere =
|
||||||
vtkSmartPointer<vtkSphereSource>::New();
|
vtkSmartPointer<vtkSphereSource>::New();
|
||||||
float size = (d->content->LineIn().origin - d->content->LineOut().origin).head(3).norm();
|
float size = (content->LineIn().origin - content->LineOut().origin).head(3).norm();
|
||||||
size /= 100;
|
size /= 100;
|
||||||
sphere->SetRadius(size);
|
sphere->SetRadius(size);
|
||||||
sphere->SetCenter(poca(0),poca(1),poca(2));
|
sphere->SetCenter(poca(0),poca(1),poca(2));
|
||||||
sphere->Update();
|
sphere->Update();
|
||||||
d->m_Appender->AddInputConnection(sphere->GetOutputPort());
|
m_Appender->AddInputConnection(sphere->GetOutputPort());
|
||||||
d->m_Appender->Update();
|
m_Appender->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
HPoint3f vtkMuonEvent::GetPocaPoint()
|
HPoint3f vtkMuonEvent::GetPocaPoint()
|
||||||
{
|
{
|
||||||
return d->m_Poca;
|
return m_Poca;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,21 @@
|
|||||||
#ifndef VTKMUONEVENT_H
|
#ifndef VTKMUONEVENT_H
|
||||||
#define VTKMUONEVENT_H
|
#define VTKMUONEVENT_H
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkSphereSource.h>
|
||||||
|
#include <vtkAppendPolyData.h>
|
||||||
|
#include <vtkPolyDataMapper.h>
|
||||||
|
#include <vtkLineSource.h>
|
||||||
|
#include <vtkActor.h>
|
||||||
|
|
||||||
|
#include <vtk3DWidget.h>
|
||||||
|
#include <vtkBoxWidget.h>
|
||||||
|
|
||||||
|
#include <vtkRenderWindowInteractor.h>
|
||||||
|
|
||||||
|
#include <vtkCommand.h>
|
||||||
|
#include <vtkTransform.h>
|
||||||
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
#include "uLibVtkInterface.h"
|
#include "uLibVtkInterface.h"
|
||||||
@@ -64,8 +78,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
void InstallPipe();
|
void InstallPipe();
|
||||||
|
|
||||||
friend class vtkMuonEventPimpl;
|
vtkMuonEvent::Content *content;
|
||||||
class vtkMuonEventPimpl *d;
|
vtkPolyData *m_PolyData;
|
||||||
|
vtkActor *m_Prop;
|
||||||
|
|
||||||
|
vtkAppendPolyData *m_Appender;
|
||||||
|
vtkBoxWidget *m_WidgetIN;
|
||||||
|
vtkBoxWidget *m_WidgetOUT;
|
||||||
|
HPoint3f m_Poca;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,23 +30,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <vtkConfigure.h>
|
|
||||||
#include <vtkSmartPointer.h>
|
|
||||||
#include <vtkSphereSource.h>
|
|
||||||
#include <vtkAppendPolyData.h>
|
|
||||||
#include <vtkPolyDataMapper.h>
|
|
||||||
#include <vtkLineSource.h>
|
|
||||||
#include <vtkActor.h>
|
|
||||||
|
|
||||||
#include <vtk3DWidget.h>
|
|
||||||
#include <vtkBoxWidget.h>
|
|
||||||
|
|
||||||
#include <vtkRenderWindowInteractor.h>
|
|
||||||
|
|
||||||
#include <vtkCommand.h>
|
|
||||||
#include <vtkTransform.h>
|
|
||||||
|
|
||||||
#include "vtkMuonScatter.h"
|
#include "vtkMuonScatter.h"
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
@@ -78,36 +61,6 @@ namespace Vtk {
|
|||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//// PIMPL /////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class vtkMuonScatterPimpl {
|
|
||||||
public:
|
|
||||||
vtkMuonScatterPimpl() :
|
|
||||||
m_Content(NULL),
|
|
||||||
m_LineIn(vtkLineSource::New()),
|
|
||||||
m_LineOut(vtkLineSource::New()),
|
|
||||||
m_PolyData(vtkPolyData::New()),
|
|
||||||
m_SpherePoca(NULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~vtkMuonScatterPimpl()
|
|
||||||
{
|
|
||||||
m_LineIn->Delete();
|
|
||||||
m_LineOut->Delete();
|
|
||||||
if(m_SpherePoca) m_SpherePoca->Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
// members //
|
|
||||||
vtkMuonScatter::Content *m_Content;
|
|
||||||
vtkLineSource *m_LineIn, *m_LineOut;
|
|
||||||
vtkSphereSource *m_SpherePoca;
|
|
||||||
vtkPolyData *m_PolyData;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
///// VTK MUON Scatter /////////////////////////////////////////////////////////
|
///// VTK MUON Scatter /////////////////////////////////////////////////////////
|
||||||
@@ -115,63 +68,69 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
vtkMuonScatter::vtkMuonScatter(MuonScatter &content) :
|
vtkMuonScatter::vtkMuonScatter(MuonScatter &content) :
|
||||||
d(new vtkMuonScatterPimpl)
|
m_Content(&content),
|
||||||
|
m_LineIn(vtkLineSource::New()),
|
||||||
|
m_LineOut(vtkLineSource::New()),
|
||||||
|
m_PolyData(vtkPolyData::New()),
|
||||||
|
m_SpherePoca(NULL)
|
||||||
{
|
{
|
||||||
d->m_Content = &content;
|
InstallPipe();
|
||||||
InstallPipe();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkMuonScatter::vtkMuonScatter(const MuonScatter &content) :
|
vtkMuonScatter::vtkMuonScatter(const MuonScatter &content) :
|
||||||
d(new vtkMuonScatterPimpl)
|
m_Content(const_cast<MuonScatter *>(&content)),
|
||||||
|
m_LineIn(vtkLineSource::New()),
|
||||||
|
m_LineOut(vtkLineSource::New()),
|
||||||
|
m_PolyData(vtkPolyData::New()),
|
||||||
|
m_SpherePoca(NULL)
|
||||||
{
|
{
|
||||||
d->m_Content = const_cast<MuonScatter *>(&content);
|
InstallPipe();
|
||||||
InstallPipe();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vtkMuonScatter::~vtkMuonScatter()
|
vtkMuonScatter::~vtkMuonScatter()
|
||||||
{
|
{
|
||||||
delete d;
|
m_LineIn->Delete();
|
||||||
|
m_LineOut->Delete();
|
||||||
|
if(m_SpherePoca) m_SpherePoca->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkMuonScatter::Content &vtkMuonScatter::GetContent()
|
vtkMuonScatter::Content &vtkMuonScatter::GetContent()
|
||||||
{
|
{
|
||||||
return *d->m_Content;
|
return *m_Content;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkMuonScatter::PrintSelf(std::ostream &o) const
|
void vtkMuonScatter::PrintSelf(std::ostream &o) const
|
||||||
{
|
{}
|
||||||
// o << d->content;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void vtkMuonScatter::InstallPipe()
|
void vtkMuonScatter::InstallPipe()
|
||||||
{
|
{
|
||||||
if(d->m_Content) {
|
if(m_Content) {
|
||||||
vtkLineSource *line_in = d->m_LineIn;
|
vtkLineSource *line_in = m_LineIn;
|
||||||
vtkLineSource *line_out = d->m_LineOut;
|
vtkLineSource *line_out = m_LineOut;
|
||||||
|
|
||||||
float distance = (d->m_Content->LineIn().origin - d->m_Content->LineOut().origin).norm() / 10;
|
float distance = (m_Content->LineIn().origin - m_Content->LineOut().origin).norm() / 10;
|
||||||
|
|
||||||
HPoint3f pt;
|
HPoint3f pt;
|
||||||
pt = d->m_Content->LineIn().origin;
|
pt = m_Content->LineIn().origin;
|
||||||
line_in->SetPoint1(pt(0),pt(1),pt(2));
|
line_in->SetPoint1(pt(0),pt(1),pt(2));
|
||||||
pt= d->m_Content->LineIn().origin + d->m_Content->LineIn().direction * distance;
|
pt= m_Content->LineIn().origin + m_Content->LineIn().direction * distance;
|
||||||
line_in->SetPoint2(pt(0),pt(1),pt(2));
|
line_in->SetPoint2(pt(0),pt(1),pt(2));
|
||||||
pt = d->m_Content->LineOut().origin;
|
pt = m_Content->LineOut().origin;
|
||||||
line_out->SetPoint1(pt(0),pt(1),pt(2));
|
line_out->SetPoint1(pt(0),pt(1),pt(2));
|
||||||
pt = d->m_Content->LineOut().origin + d->m_Content->LineOut().direction * distance;
|
pt = m_Content->LineOut().origin + m_Content->LineOut().direction * distance;
|
||||||
line_out->SetPoint2(pt(0),pt(1),pt(2));
|
line_out->SetPoint2(pt(0),pt(1),pt(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
mapper->SetInputConnection(d->m_LineIn->GetOutputPort());
|
mapper->SetInputConnection(m_LineIn->GetOutputPort());
|
||||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
this->SetProp(actor);
|
this->SetProp(actor);
|
||||||
|
|
||||||
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
mapper->SetInputConnection(d->m_LineOut->GetOutputPort());
|
mapper->SetInputConnection(m_LineOut->GetOutputPort());
|
||||||
actor = vtkSmartPointer<vtkActor>::New();
|
actor = vtkSmartPointer<vtkActor>::New();
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
this->SetProp(actor);
|
this->SetProp(actor);
|
||||||
@@ -180,32 +139,26 @@ void vtkMuonScatter::InstallPipe()
|
|||||||
vtkPolyData *vtkMuonScatter::GetPolyData() const
|
vtkPolyData *vtkMuonScatter::GetPolyData() const
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkAppendPolyData> append = vtkSmartPointer<vtkAppendPolyData>::New();
|
vtkSmartPointer<vtkAppendPolyData> append = vtkSmartPointer<vtkAppendPolyData>::New();
|
||||||
//# if VTK_MAJOR_VERSION <= 5
|
append->AddInputConnection(m_LineIn->GetOutputPort());
|
||||||
append->AddInputConnection(d->m_LineIn->GetOutputPort());
|
append->AddInputConnection(m_LineOut->GetOutputPort());
|
||||||
append->AddInputConnection(d->m_LineOut->GetOutputPort());
|
if(m_SpherePoca) append->AddInputConnection(m_SpherePoca->GetOutputPort());
|
||||||
if(d->m_SpherePoca) append->AddInputConnection(d->m_SpherePoca->GetOutputPort());
|
|
||||||
//# else
|
|
||||||
// append->AddInputData(d->m_LineIn->GetOutput());
|
|
||||||
// append->AddInputData(d->m_LineOut->GetOutput());
|
|
||||||
// if(d->m_SpherePoca) append->AddInputData(d->m_SpherePoca->GetOutput());
|
|
||||||
//# endif
|
|
||||||
append->Update();
|
append->Update();
|
||||||
d->m_PolyData->DeepCopy(append->GetOutput());
|
m_PolyData->DeepCopy(append->GetOutput());
|
||||||
return d->m_PolyData;
|
return m_PolyData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkMuonScatter::AddPocaPoint(HPoint3f poca)
|
void vtkMuonScatter::AddPocaPoint(HPoint3f poca)
|
||||||
{
|
{
|
||||||
vtkSphereSource *sphere = vtkSphereSource::New();
|
vtkSphereSource *sphere = vtkSphereSource::New();
|
||||||
float size = (d->m_Content->LineIn().origin - d->m_Content->LineOut().origin).head(3).norm();
|
float size = (m_Content->LineIn().origin - m_Content->LineOut().origin).head(3).norm();
|
||||||
size /= 100;
|
size /= 100;
|
||||||
sphere->SetRadius(size);
|
sphere->SetRadius(size);
|
||||||
sphere->SetCenter(poca(0),poca(1),poca(2));
|
sphere->SetCenter(poca(0),poca(1),poca(2));
|
||||||
sphere->Update();
|
sphere->Update();
|
||||||
d->m_SpherePoca = sphere;
|
m_SpherePoca = sphere;
|
||||||
|
|
||||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
mapper->SetInputConnection(d->m_SpherePoca->GetOutputPort());
|
mapper->SetInputConnection(m_SpherePoca->GetOutputPort());
|
||||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
this->SetProp(actor);
|
this->SetProp(actor);
|
||||||
@@ -214,8 +167,8 @@ void vtkMuonScatter::AddPocaPoint(HPoint3f poca)
|
|||||||
HPoint3f vtkMuonScatter::GetPocaPoint()
|
HPoint3f vtkMuonScatter::GetPocaPoint()
|
||||||
{
|
{
|
||||||
double center[3];
|
double center[3];
|
||||||
if(d->m_SpherePoca) {
|
if(m_SpherePoca) {
|
||||||
d->m_SpherePoca->GetCenter(center);
|
m_SpherePoca->GetCenter(center);
|
||||||
return HPoint3f(center[0],center[1],center[2]);
|
return HPoint3f(center[0],center[1],center[2]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -28,7 +28,22 @@
|
|||||||
#ifndef VTKMUONSCATTER_H
|
#ifndef VTKMUONSCATTER_H
|
||||||
#define VTKMUONSCATTER_H
|
#define VTKMUONSCATTER_H
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
#include <vtkVersion.h>
|
||||||
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkSphereSource.h>
|
||||||
|
#include <vtkAppendPolyData.h>
|
||||||
|
#include <vtkPolyDataMapper.h>
|
||||||
|
#include <vtkLineSource.h>
|
||||||
|
#include <vtkActor.h>
|
||||||
|
|
||||||
|
#include <vtk3DWidget.h>
|
||||||
|
#include <vtkBoxWidget.h>
|
||||||
|
|
||||||
|
#include <vtkRenderWindowInteractor.h>
|
||||||
|
|
||||||
|
#include <vtkCommand.h>
|
||||||
|
#include <vtkTransform.h>
|
||||||
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
#include "uLibVtkInterface.h"
|
#include "uLibVtkInterface.h"
|
||||||
@@ -66,8 +81,11 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void InstallPipe();
|
void InstallPipe();
|
||||||
|
|
||||||
friend class vtkMuonScatterPimpl;
|
vtkMuonScatter::Content *m_Content;
|
||||||
class vtkMuonScatterPimpl *d;
|
vtkLineSource *m_LineIn;
|
||||||
|
vtkLineSource *m_LineOut;
|
||||||
|
vtkSphereSource *m_SpherePoca;
|
||||||
|
vtkPolyData *m_PolyData;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // vtk
|
} // vtk
|
||||||
|
|||||||
@@ -29,82 +29,12 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <vtkLineSource.h>
|
|
||||||
#include <vtkBoundingBox.h>
|
|
||||||
#include <vtkCubeSource.h>
|
|
||||||
#include <vtkSmartPointer.h>
|
|
||||||
#include <vtkPolyDataMapper.h>
|
|
||||||
#include <vtkActor.h>
|
|
||||||
#include <vtkProperty.h>
|
|
||||||
|
|
||||||
#include <vtkTransform.h>
|
|
||||||
#include <vtkTransformPolyDataFilter.h>
|
|
||||||
#include <vtkBoxWidget.h>
|
|
||||||
#include <vtkCommand.h>
|
|
||||||
|
|
||||||
#include "Math/StructuredGrid.h"
|
#include "Math/StructuredGrid.h"
|
||||||
#include "Vtk/vtkStructuredGrid.h"
|
#include "Vtk/vtkStructuredGrid.h"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
namespace Vtk {
|
namespace Vtk {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////// PIMPL //////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
class vtkStructuredGridPimpl {
|
|
||||||
|
|
||||||
// ---- WIDGET CBK ------------------------------------------------------ //
|
|
||||||
class vtkWidgetCallback : public vtkCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
|
|
||||||
void SetParent(uLib::Vtk::vtkStructuredGrid *parent) { this->parent = parent; }
|
|
||||||
virtual void Execute(vtkObject *caller, unsigned long, void*)
|
|
||||||
{
|
|
||||||
vtkSmartPointer<vtkTransform> t =
|
|
||||||
vtkSmartPointer<vtkTransform>::New();
|
|
||||||
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
|
|
||||||
widget->GetTransform(t);
|
|
||||||
parent->SetTransform(t);
|
|
||||||
//std::cout << "event\n";
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
uLib::Vtk::vtkStructuredGrid *parent;
|
|
||||||
};
|
|
||||||
// ---------------------------------------------------------------------- //
|
|
||||||
|
|
||||||
public:
|
|
||||||
vtkStructuredGridPimpl(vtkStructuredGrid *parent, StructuredGrid &content) :
|
|
||||||
p(parent),
|
|
||||||
m_Content(&content),
|
|
||||||
m_Actor(vtkActor::New()),
|
|
||||||
m_Widget(vtkBoxWidget::New()),
|
|
||||||
m_Transform(vtkTransform::New())
|
|
||||||
{
|
|
||||||
vtkSmartPointer<vtkWidgetCallback> callback =
|
|
||||||
vtkSmartPointer<vtkWidgetCallback>::New();
|
|
||||||
callback->SetParent(p);
|
|
||||||
m_Widget->AddObserver(vtkCommand::InteractionEvent, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
~vtkStructuredGridPimpl()
|
|
||||||
{
|
|
||||||
m_Actor->Delete();
|
|
||||||
m_Widget->Delete();
|
|
||||||
m_Transform->Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
// members //
|
|
||||||
vtkActor *m_Actor;
|
|
||||||
vtkBoxWidget *m_Widget;
|
|
||||||
StructuredGrid *m_Content;
|
|
||||||
vtkTransform *m_Transform;
|
|
||||||
private:
|
|
||||||
vtkStructuredGrid *p;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////// VTK STRUCTURED GRID /////////////////////////////////////////////////////
|
////// VTK STRUCTURED GRID /////////////////////////////////////////////////////
|
||||||
@@ -113,14 +43,24 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
vtkStructuredGrid::vtkStructuredGrid(Content &content) :
|
vtkStructuredGrid::vtkStructuredGrid(Content &content) :
|
||||||
d(new vtkStructuredGridPimpl(this,content))
|
m_Content(&content),
|
||||||
|
m_Actor(vtkActor::New()),
|
||||||
|
m_Widget(vtkBoxWidget::New()),
|
||||||
|
m_Transform(vtkTransform::New())
|
||||||
{
|
{
|
||||||
|
vtkSmartPointer<vtkWidgetCallback> callback =
|
||||||
|
vtkSmartPointer<vtkWidgetCallback>::New();
|
||||||
|
callback->SetGrid(this);
|
||||||
|
m_Widget->AddObserver(vtkCommand::InteractionEvent, callback);
|
||||||
|
|
||||||
this->InstallPipe();
|
this->InstallPipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkStructuredGrid::~vtkStructuredGrid()
|
vtkStructuredGrid::~vtkStructuredGrid()
|
||||||
{
|
{
|
||||||
delete d;
|
m_Actor->Delete();
|
||||||
|
m_Widget->Delete();
|
||||||
|
m_Transform->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -131,26 +71,26 @@ void vtkStructuredGrid::SetTransform(vtkTransform *t)
|
|||||||
for(int i=0; i<4; ++i)
|
for(int i=0; i<4; ++i)
|
||||||
for(int j=0; j<4; ++j)
|
for(int j=0; j<4; ++j)
|
||||||
mat(i,j) = vmat->GetElement(i,j);
|
mat(i,j) = vmat->GetElement(i,j);
|
||||||
d->m_Content->SetMatrix(mat);
|
m_Content->SetMatrix(mat);
|
||||||
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> vmat2 = vtkSmartPointer<vtkMatrix4x4>::New();
|
vtkSmartPointer<vtkMatrix4x4> vmat2 = vtkSmartPointer<vtkMatrix4x4>::New();
|
||||||
mat = d->m_Content->GetWorldMatrix();
|
mat = m_Content->GetWorldMatrix();
|
||||||
for(int i=0; i<4; ++i)
|
for(int i=0; i<4; ++i)
|
||||||
for(int j=0; j<4; ++j)
|
for(int j=0; j<4; ++j)
|
||||||
vmat2->SetElement(i,j,mat(i,j));
|
vmat2->SetElement(i,j,mat(i,j));
|
||||||
d->m_Transform->SetMatrix(vmat2);
|
m_Transform->SetMatrix(vmat2);
|
||||||
d->m_Transform->Update();
|
m_Transform->Update();
|
||||||
this->Update();
|
this->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkBoxWidget *vtkStructuredGrid::GetWidget()
|
vtkBoxWidget *vtkStructuredGrid::GetWidget()
|
||||||
{
|
{
|
||||||
return d->m_Widget;
|
return m_Widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkStructuredGrid::Update()
|
void vtkStructuredGrid::Update()
|
||||||
{
|
{
|
||||||
d->m_Actor->GetMapper()->Update();
|
m_Actor->GetMapper()->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtkStructuredGrid::InstallPipe()
|
void vtkStructuredGrid::InstallPipe()
|
||||||
@@ -161,15 +101,15 @@ void vtkStructuredGrid::InstallPipe()
|
|||||||
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
|
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
|
||||||
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
|
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
|
||||||
Matrix4f mat = d->m_Content->GetWorldMatrix();
|
Matrix4f mat = m_Content->GetWorldMatrix();
|
||||||
for(int i=0; i<4; ++i)
|
for(int i=0; i<4; ++i)
|
||||||
for(int j=0; j<4; ++j)
|
for(int j=0; j<4; ++j)
|
||||||
vmat->SetElement(i,j,mat(i,j));
|
vmat->SetElement(i,j,mat(i,j));
|
||||||
d->m_Transform->SetMatrix(vmat);
|
m_Transform->SetMatrix(vmat);
|
||||||
filter->SetTransform(d->m_Transform);
|
filter->SetTransform(m_Transform);
|
||||||
filter->SetInputConnection(cube->GetOutputPort());
|
filter->SetInputConnection(cube->GetOutputPort());
|
||||||
|
|
||||||
Vector3i dims = d->m_Content->GetDims();
|
Vector3i dims = m_Content->GetDims();
|
||||||
cube->SetBounds(0,dims(0),0,dims(1),0,dims(2));
|
cube->SetBounds(0,dims(0),0,dims(1),0,dims(2));
|
||||||
cube->Update();
|
cube->Update();
|
||||||
filter->Update();
|
filter->Update();
|
||||||
@@ -178,16 +118,16 @@ void vtkStructuredGrid::InstallPipe()
|
|||||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
mapper->SetInputConnection(filter->GetOutputPort());
|
mapper->SetInputConnection(filter->GetOutputPort());
|
||||||
|
|
||||||
d->m_Actor->SetMapper(mapper);
|
m_Actor->SetMapper(mapper);
|
||||||
d->m_Actor->GetProperty()->SetRepresentationToSurface();
|
m_Actor->GetProperty()->SetRepresentationToSurface();
|
||||||
d->m_Actor->GetProperty()->SetEdgeVisibility(true);
|
m_Actor->GetProperty()->SetEdgeVisibility(true);
|
||||||
d->m_Actor->GetProperty()->SetOpacity(0.4);
|
m_Actor->GetProperty()->SetOpacity(0.4);
|
||||||
d->m_Actor->GetProperty()->SetAmbient(0.7);
|
m_Actor->GetProperty()->SetAmbient(0.7);
|
||||||
// set content transform to actor //
|
// set content transform to actor //
|
||||||
this->Update();
|
this->Update();
|
||||||
d->m_Widget->SetProp3D(d->m_Actor);
|
m_Widget->SetProp3D(m_Actor);
|
||||||
|
|
||||||
this->SetProp(d->m_Actor);
|
this->SetProp(m_Actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,19 @@
|
|||||||
#ifndef U_VTKSTRUCTUREDGRID_H
|
#ifndef U_VTKSTRUCTUREDGRID_H
|
||||||
#define U_VTKSTRUCTUREDGRID_H
|
#define U_VTKSTRUCTUREDGRID_H
|
||||||
|
|
||||||
#include "Core/Macros.h"
|
#include <vtkLineSource.h>
|
||||||
|
#include <vtkBoundingBox.h>
|
||||||
|
#include <vtkCubeSource.h>
|
||||||
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkPolyDataMapper.h>
|
||||||
|
#include <vtkActor.h>
|
||||||
|
#include <vtkProperty.h>
|
||||||
|
|
||||||
|
#include <vtkTransform.h>
|
||||||
|
#include <vtkTransformPolyDataFilter.h>
|
||||||
|
#include <vtkBoxWidget.h>
|
||||||
|
#include <vtkCommand.h>
|
||||||
|
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
#include "uLibVtkInterface.h"
|
#include "uLibVtkInterface.h"
|
||||||
@@ -55,8 +67,28 @@ public:
|
|||||||
private:
|
private:
|
||||||
void InstallPipe();
|
void InstallPipe();
|
||||||
|
|
||||||
friend class vtkStructuredGridPimpl;
|
class vtkWidgetCallback : public vtkCommand
|
||||||
class vtkStructuredGridPimpl *d;
|
{
|
||||||
|
public:
|
||||||
|
static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
|
||||||
|
|
||||||
|
void SetGrid(uLib::Vtk::vtkStructuredGrid *grid) { this->grid = grid; }
|
||||||
|
|
||||||
|
virtual void Execute(vtkObject *caller, unsigned long, void*)
|
||||||
|
{
|
||||||
|
vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New();
|
||||||
|
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
|
||||||
|
widget->GetTransform(t);
|
||||||
|
grid->SetTransform(t);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
uLib::Vtk::vtkStructuredGrid *grid;
|
||||||
|
};
|
||||||
|
|
||||||
|
vtkActor *m_Actor;
|
||||||
|
vtkBoxWidget *m_Widget;
|
||||||
|
StructuredGrid *m_Content;
|
||||||
|
vtkTransform *m_Transform;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user