-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from etienneschmitt/image
plugin Image etc.
- Loading branch information
Showing
27 changed files
with
1,612 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
project(plugin_image | ||
LANGUAGES CXX | ||
) | ||
|
||
find_package(cgogn_core REQUIRED) | ||
find_package(cgogn_io REQUIRED) | ||
find_package(Qt5 COMPONENTS Widgets REQUIRED) | ||
find_package(QOGLViewer REQUIRED) | ||
|
||
find_package(CGAL COMPONENTS Core ImageIO) | ||
if(CGAL_FOUND) | ||
include(${CGAL_USE_FILE}) | ||
find_package(MPFR REQUIRED) | ||
find_package(GMP REQUIRED) | ||
find_package(Boost REQUIRED) | ||
endif(CGAL_FOUND) | ||
|
||
set(HEADER_FILES | ||
dll.h | ||
image.h | ||
image_dock_tab.h | ||
cgal/cgal_image.h | ||
) | ||
|
||
set(SOURCE_FILES | ||
image.cpp | ||
image_dock_tab.cpp | ||
cgal/cgal_image.cpp | ||
) | ||
|
||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_AUTOUIC ON) | ||
|
||
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) | ||
|
||
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_d") | ||
|
||
target_include_directories(${PROJECT_NAME} PUBLIC | ||
$<BUILD_INTERFACE:${SCHNAPPS_SOURCE_DIR}> | ||
$<BUILD_INTERFACE:${CGOGN_SOURCE_DIR}> | ||
$<BUILD_INTERFACE:${CGAL_INCLUDE_DIRS}> | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
) | ||
|
||
#target_compile_definitions(${PROJECT_NAME} PUBLIC "-Dcimg_display=0") | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
schnapps_core | ||
${cgogn_core_LIBRARIES} | ||
${cgogn_io_LIBRARIES} | ||
${Qt5Widgets_LIBRARIES} | ||
${QOGLViewer_LIBRARIES} | ||
${CGAL_LIB} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/******************************************************************************* | ||
* SCHNApps * | ||
* Copyright (C) 2015, IGG Group, ICube, University of Strasbourg, France * | ||
* Plugin Image * | ||
* Author Etienne Schmitt ([email protected]) Inria/Mimesis * | ||
* 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 2.1 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; if not, write to the Free Software Foundation, * | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * | ||
* * | ||
* Web site: http://cgogn.unistra.fr/ * | ||
* Contact information: [email protected] * | ||
* * | ||
*******************************************************************************/ | ||
|
||
#define SCHNAPPS_PLUGIN_IMAGE_DLL_EXPORT | ||
|
||
#include "cgal_image.h" | ||
|
||
namespace schnapps | ||
{ | ||
|
||
namespace plugin_image | ||
{ | ||
|
||
SCHNAPPS_PLUGIN_IMAGE_API CGAL::Image_3 export_to_cgal_image(const Image3D& im) | ||
{ | ||
using DataType = cgogn::io::DataType; | ||
|
||
const auto& dims = im.get_image_dimensions(); | ||
const auto& voxel_dims = im.get_voxel_dimensions(); | ||
|
||
_image* image =_createImage(dims[0], dims[1], dims[2], | ||
im.get_nb_components(), | ||
voxel_dims[0], voxel_dims[1], voxel_dims[2], | ||
im.get_data_size(), | ||
get_cgal_word_kind(im.get_data_type()), | ||
get_cgal_sign(im.get_data_type())); | ||
|
||
image->endianness = cgogn::internal::cgogn_is_little_endian? END_LITTLE : END_BIG; | ||
|
||
image->vectMode = im.get_nb_components() == 1u ? VM_SCALAR : VM_NON_INTERLACED; | ||
const auto& trans = im.get_translation(); | ||
image->tx = trans[0]; | ||
image->ty = trans[1]; | ||
image->tz = trans[2]; | ||
|
||
const auto& rot = im.get_rotation(); | ||
image->rx = rot[0]; | ||
image->ry = rot[1]; | ||
image->rz = rot[2]; | ||
|
||
const auto& origin = im.get_origin(); | ||
image->cx = origin[0]; | ||
image->cy = origin[1]; | ||
image->cz = origin[2]; | ||
|
||
|
||
std::memcpy(image->data,im.data(), dims[0]*dims[1]*dims[2]*image->wdim * image->vdim); | ||
|
||
return CGAL::Image_3(image); | ||
} | ||
|
||
SCHNAPPS_PLUGIN_IMAGE_API WORD_KIND get_cgal_word_kind(cgogn::io::DataType data_type) | ||
{ | ||
using DataType = cgogn::io::DataType; | ||
|
||
if (data_type == DataType::FLOAT || data_type == DataType::DOUBLE) | ||
return WK_FLOAT; | ||
else | ||
return WK_FIXED; | ||
} | ||
|
||
SCHNAPPS_PLUGIN_IMAGE_API SIGN get_cgal_sign(cgogn::io::DataType data_type) | ||
{ | ||
using DataType = cgogn::io::DataType; | ||
|
||
switch(data_type) { | ||
case DataType::UINT8: | ||
case DataType::UINT16: | ||
case DataType::UINT32: | ||
case DataType::UINT64: return SGN_UNSIGNED; | ||
default: | ||
return SGN_SIGNED; | ||
} | ||
} | ||
|
||
|
||
} // namespace plugin_image | ||
} // namespace schnapps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* SCHNApps * | ||
* Copyright (C) 2015, IGG Group, ICube, University of Strasbourg, France * | ||
* Plugin Image * | ||
* Author Etienne Schmitt ([email protected]) Inria/Mimesis * | ||
* 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 2.1 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; if not, write to the Free Software Foundation, * | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * | ||
* * | ||
* Web site: http://cgogn.unistra.fr/ * | ||
* Contact information: [email protected] * | ||
* * | ||
*******************************************************************************/ | ||
|
||
#ifndef SCHNAPPS_PLUGIN_IMAGE_CGAL_IMAGE_H_ | ||
#define SCHNAPPS_PLUGIN_IMAGE_CGAL_IMAGE_H_ | ||
|
||
#include <CGAL/Image_3.h> | ||
#include "image.h" | ||
|
||
namespace schnapps | ||
{ | ||
|
||
namespace plugin_image | ||
{ | ||
SCHNAPPS_PLUGIN_IMAGE_API CGAL::Image_3 export_to_cgal_image(const schnapps::plugin_image::Image3D& im); | ||
SCHNAPPS_PLUGIN_IMAGE_API WORD_KIND get_cgal_word_kind(cgogn::io::DataType data_type); | ||
SCHNAPPS_PLUGIN_IMAGE_API SIGN get_cgal_sign(cgogn::io::DataType data_type); | ||
} // namespace plugin_image | ||
} // namespace schnapps | ||
|
||
#endif // SCHNAPPS_PLUGIN_IMAGE_CGAL_IMAGE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/******************************************************************************* | ||
* SCHNApps * | ||
* Copyright (C) 2015, IGG Group, ICube, University of Strasbourg, France * | ||
* Plugin Image * | ||
* Author Etienne Schmitt ([email protected]) Inria/Mimesis * | ||
* 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 2.1 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; if not, write to the Free Software Foundation, * | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * | ||
* * | ||
* Web site: http://cgogn.unistra.fr/ * | ||
* Contact information: [email protected] * | ||
* * | ||
*******************************************************************************/ | ||
|
||
#ifndef SCHNAPPS_PLUGIN_IMAGE_H_ | ||
#define SCHNAPPS_PLUGIN_IMAGE_H_ | ||
|
||
|
||
#ifdef WIN32 | ||
#ifndef SCHNAPPS_PLUGIN_IMAGE_API | ||
#if defined SCHNAPPS_PLUGIN_IMAGE_DLL_EXPORT | ||
#define SCHNAPPS_PLUGIN_IMAGE_API __declspec(dllexport) | ||
#else | ||
#define SCHNAPPS_PLUGIN_IMAGE_API __declspec(dllimport) | ||
#endif | ||
#endif | ||
#else | ||
#define SCHNAPPS_PLUGIN_IMAGE_API | ||
#endif | ||
|
||
#endif // SCHNAPPS_PLUGIN_IMAGE_H_ |
Oops, something went wrong.