Skip to content

Commit

Permalink
Merge pull request #27 from etienneschmitt/image
Browse files Browse the repository at this point in the history
plugin Image etc.
  • Loading branch information
pierrekraemer authored Jul 7, 2016
2 parents 479f614 + 86690a7 commit 9bd83b4
Show file tree
Hide file tree
Showing 27 changed files with 1,612 additions and 301 deletions.
7 changes: 7 additions & 0 deletions schnapps/core/schnapps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,19 @@ void SCHNApps::register_plugins_directory(const QString& path)
#else
QString plugin_name = pfi.baseName().remove(0, 3);
#endif
if (plugin_name.endsWith("_d"))
plugin_name = plugin_name.left(plugin_name.size() -2);
if(plugin_name.startsWith("plugin_", Qt::CaseInsensitive))
plugin_name = plugin_name.right(plugin_name.size() - 7);

QString plugin_file_path = directory.absoluteFilePath(plugin_file);

if (available_plugins_.count(plugin_name) == 0ul)
{
available_plugins_.insert(std::make_pair(plugin_name, plugin_file_path));
emit(plugin_available_added(plugin_name));
} else {
std::cout << "Plugin \"" << plugin_name.toStdString() << "\" already loaded." << std::endl;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion schnapps/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ add_subdirectory(surface_differential_properties)
add_subdirectory(surface_render)
add_subdirectory(surface_render_vector)
add_subdirectory(surface_render_scalar)
add_subdirectory(volume_mesh_from_surface)
add_subdirectory(volume_render)
add_subdirectory(image)
add_subdirectory(volume_mesh_from_surface)
55 changes: 55 additions & 0 deletions schnapps/plugins/image/CMakeLists.txt
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}
)
99 changes: 99 additions & 0 deletions schnapps/plugins/image/cgal/cgal_image.cpp
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
42 changes: 42 additions & 0 deletions schnapps/plugins/image/cgal/cgal_image.h
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_
41 changes: 41 additions & 0 deletions schnapps/plugins/image/dll.h
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_
Loading

0 comments on commit 9bd83b4

Please sign in to comment.