Skip to content

Commit

Permalink
Merge pull request #3 from jcfr/improve-and-fix-buildsystem
Browse files Browse the repository at this point in the history
Improve and fix buildsystem
  • Loading branch information
giogadi authored Aug 26, 2017
2 parents 8e9a570 + 818dbc8 commit 1a0fc89
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 155 deletions.
2 changes: 1 addition & 1 deletion AutoPortPlacement/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.5)

if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH OFF)
Expand Down
81 changes: 0 additions & 81 deletions AutoPortPlacement/Logic/CMake/FindEigen3.cmake

This file was deleted.

33 changes: 0 additions & 33 deletions AutoPortPlacement/Logic/CMake/FindNLopt.cmake

This file was deleted.

14 changes: 3 additions & 11 deletions AutoPortPlacement/Logic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.5)

if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH OFF)
Expand All @@ -7,22 +7,14 @@ endif()
#-----------------------------------------------------------------------------
project(vtkSlicer${MODULE_NAME}ModuleLogic)

set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake
${CMAKE_MODULE_PATH})

find_package(Eigen3 REQUIRED)
find_package(NLopt REQUIRED)
find_package(Eigen3 REQUIRED CONFIG)

set(KIT ${PROJECT_NAME})

set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_MODULE_LOGIC_EXPORT")

set(${KIT}_INCLUDE_DIRECTORIES
${EIGEN3_INCLUDE_DIR}
${NLopt_INCLUDE_DIRS}
)
include_directories(${${KIT}_INCLUDE_DIRECTORIES})

set(${KIT}_SRCS
vtkSlicer${MODULE_NAME}Logic.cxx
Expand All @@ -33,7 +25,7 @@ set(${KIT}_TARGET_LIBRARIES
collisions
davinci
${ITK_LIBRARIES}
${NLopt_LIBRARIES}
Eigen3::Eigen
optim
vtkSlicerAnnotationsModuleMRML
vtkSlicerMarkupsModuleMRML
Expand Down
4 changes: 4 additions & 0 deletions AutoPortPlacement/Logic/collisions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ add_library(collisions STATIC
collisions.cxx
collisions.h
)
target_link_libraries(collisions PUBLIC Eigen3::Eigen)

set_property(TARGET collisions PROPERTY POSITION_INDEPENDENT_CODE ON)

set_property(GLOBAL APPEND PROPERTY Slicer_TARGETS collisions)
2 changes: 2 additions & 0 deletions AutoPortPlacement/Logic/davinci-kinematics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ target_link_libraries(davinci
${ITK_LIBRARIES}
${VTK_LIBRARIES}
)

set_property(GLOBAL APPEND PROPERTY Slicer_TARGETS davinci)
20 changes: 0 additions & 20 deletions AutoPortPlacement/Logic/davinci-kinematics/davinci.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -721,26 +721,6 @@ void DavinciKinematics::unscentedIK(const Eigen::Matrix4d& portFrame,
covariance_qOut->swap(covariance_q);
}

namespace
{
double fromPoseToExtraClearance(const DavinciKinematics& kin,
const Eigen::Matrix4d& portFrameL,
const Eigen::Matrix4d& portFrameR,
const Eigen::Matrix4d& targetPose)
{
std::vector<double> qL(6);
std::vector<double> qR(6);
std::vector<Collisions::Cylisphere> cylL, cylR;
std::vector<Collisions::Sphere> sL, sR;

kin.intraIK(portFrameL, targetPose, &qL);
kin.intraIK(portFrameR, targetPose, &qR);
kin.getExtraCylispheres(portFrameL, qL, &cylL);
kin.getExtraCylispheres(portFrameR, qR, &cylR);
return Collisions::distance(cylL, sL, cylR, sR);
}
}

double DavinciKinematics::fullClearances(const Eigen::Matrix4d& baseFrameL,
const Eigen::Matrix4d& baseFrameR,
const std::vector<double>& qL,
Expand Down
11 changes: 10 additions & 1 deletion AutoPortPlacement/Logic/optim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@

find_package(NLopt REQUIRED CONFIG)

add_library(optim STATIC
optim.cxx
optim.h
)
set_property(TARGET optim PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(optim
davinci
${NLopt_LIBRARIES}
${NLOPT_LIBRARIES}
${VTK_LIBRARIES}
)

target_include_directories(optim PUBLIC
${NLOPT_INCLUDE_DIRS}
)

set_property(GLOBAL APPEND PROPERTY Slicer_TARGETS optim)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <davinci-kinematics/davinci.h>
#include <cmath>

int main(int argc, char** argv)
int main(int, char* [])
{
DavinciKinematics kinematics;

Expand Down
2 changes: 1 addition & 1 deletion AutoPortPlacement/Logic/tests/da-vinci-passive-ik-test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <iostream>

int main(int argc, char* argv[])
int main(int, char* [])
{
DavinciKinematics kinematics;

Expand Down
2 changes: 1 addition & 1 deletion AutoPortPlacement/Logic/tests/jacobian-test.cxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <davinci-kinematics/davinci.h>
#include <iostream>

int main(int argc, char** argv)
int main(int, char* [])
{
std::vector<double> q(6, 0.0);
q[0] = 0.5;
Expand Down
2 changes: 1 addition & 1 deletion AutoPortPlacement/Logic/tests/min-distance-test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <iostream>

int main(int argc, char* argv[])
int main(int, char* [])
{
std::vector<Collisions::Cylisphere> c1, c2;
std::vector<Collisions::Sphere> s1, s2;
Expand Down
5 changes: 5 additions & 0 deletions AutoPortPlacement/Logic/vtkSlicerAutoPortPlacementLogic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ void vtkSlicerAutoPortPlacementLogic::RenderRobot()
// Initializes the models and transforms for visualizing the Davinci robot.
void vtkSlicerAutoPortPlacementLogic::InitRobot()
{
if (!this->GetMRMLScene())
{
return;
}

std::vector<Collisions::Cylisphere> cylispheres;
std::vector<Collisions::Sphere> spheres(2);

Expand Down
3 changes: 3 additions & 0 deletions AutoPortPlacement/qSlicerAutoPortPlacementModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
#include "qSlicerAutoPortPlacementModuleWidget.h"

//-----------------------------------------------------------------------------
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
#include <QtPlugin>
Q_EXPORT_PLUGIN2(qSlicerAutoPortPlacementModule, qSlicerAutoPortPlacementModule);
#endif

//-----------------------------------------------------------------------------
/// \ingroup Slicer_QtModules_ExtensionTemplate
Expand Down
3 changes: 3 additions & 0 deletions AutoPortPlacement/qSlicerAutoPortPlacementModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ qSlicerAutoPortPlacementModule
: public qSlicerLoadableModule
{
Q_OBJECT
#ifdef Slicer_HAVE_QT5
Q_PLUGIN_METADATA(IID "org.slicer.modules.loadable.qSlicerLoadableModule/1.0");
#endif
Q_INTERFACES(qSlicerLoadableModule);

public:
Expand Down
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.5)

project(PortPlacement)

Expand All @@ -9,19 +9,41 @@ set(EXTENSION_CONTRIBUTORS "Luis G. Torres (UNC)")
set(EXTENSION_DESCRIPTION "Assists in the planning of surgical port placement in a laparoscopic procedure.")
set(EXTENSION_ICONURL "http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/PortPlacement/PortPlacement.png?revision=21747&view=co")
set(EXTENSION_SCREENSHOTURLS "http://wiki.slicer.org/slicerWiki/images/e/e2/Slicer-r19441-PortPlacement-screenshot.png")
set(EXTENSION_DEPENDS "Eigen3")
set(EXTENSION_BUILD_SUBDIRECTORY inner-build)

set(SUPERBUILD_TOPLEVEL_PROJECT inner)

#
# Implementation agnostic fPIC
#
set( CMAKE_POSITION_INDEPENDENT_CODE ON )

#-----------------------------------------------------------------------------
# Extension dependencies
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})
mark_as_superbuild(Slicer_DIR)

find_package(Git REQUIRED)
mark_as_superbuild(GIT_EXECUTABLE)

find_package(Eigen3 REQUIRED CONFIG)
mark_as_superbuild(Eigen3_DIR)

#-----------------------------------------------------------------------------
# SuperBuild setup
option(${EXTENSION_NAME}_SUPERBUILD "Build ${EXTENSION_NAME} and the projects it depends on." ON)
mark_as_advanced(${EXTENSION_NAME}_SUPERBUILD)
if(${EXTENSION_NAME}_SUPERBUILD)
include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
return()
endif()

#-----------------------------------------------------------------------------
add_subdirectory(PortPlacement)
add_subdirectory(AutoPortPlacement)

#-----------------------------------------------------------------------------
include(${Slicer_EXTENSION_GENERATE_CONFIG})
include(${Slicer_EXTENSION_CPACK})
6 changes: 3 additions & 3 deletions PortPlacement/PortPlacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def onRemovePortButton(self):
# Problem: currentIndex() can be valid even when there is no
# visible selection. This will have to do for now while I figure
# out how to making Python bindings to QList<QModelIndex> (ugh)
index = self.portsTable.selectionModel().currentIndex()
index = self.portsTable.selectionModel().currentIndex
self.logic.markupsNode.RemoveMarkup(index.row())
self.updateTable()

Expand Down Expand Up @@ -718,7 +718,7 @@ def test_PortPlacement1(self):

target_p = [0,0,0]
targetNode.GetNthFiducialPosition(0, target_p)
targetWorld = target_p + [1]
targetWorld = target_p

# check retargeting by verifying that tools' positions are
# unchanged and that their y-axes are oriented toward point
Expand All @@ -731,7 +731,7 @@ def test_PortPlacement1(self):
diff = numpy.array(p) - numpy.array(tool_pos)
self.assertTrue(numpy.dot(diff,diff) < 1e-10)

targetLocal = [0,0,0,1]
targetLocal = [0,0,0]
logic.toolList[i].modelNode.TransformPointFromWorld(targetWorld, targetLocal)

targetLocal = numpy.array(targetLocal)[0:3]
Expand Down
Loading

0 comments on commit 1a0fc89

Please sign in to comment.