Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Superbuild/TetgenExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ SET(TETGEN_LIBRARY "tet")
ExternalProject_Add(Tetgen_external
URL "http://tetgen.org/files/tetgen1.4.3.tar.gz"
PATCH_COMMAND ""
#CONFIGURE_COMMAND ""
#BUILD_IN_SOURCE ON
#BUILD_COMMAND ""
INSTALL_COMMAND ""
CMAKE_CACHE_ARGS
-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}
Expand All @@ -45,6 +42,8 @@ ExternalProject_Add(Tetgen_external
ExternalProject_Add_Step(Tetgen_external add_cmakelists
COMMAND "${CMAKE_COMMAND}" -E copy ${SUPERBUILD_DIR}/TetgenCMakeLists.txt CMakeLists.txt
DEPENDEES download
DEPENDERS configure
ALWAYS 1
WORKING_DIRECTORY <SOURCE_DIR>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
DEALINGS IN THE SOFTWARE.
*/

#include <Application/Filters/Actions/ActionRadialBasisFunction.h>
#include <Application/Filters/Actions/ActionImplicitModel.h>

#include <Application/Filters/LayerFilter.h>
#include <Application/Filters/Actions/ActionThreshold.h>
Expand Down Expand Up @@ -54,12 +54,12 @@
#include <ScatteredData.h>
#include <vec3.h>

CORE_REGISTER_ACTION( RadialBasisFunction, RadialBasisFunction )
CORE_REGISTER_ACTION( ImplicitModel, ImplicitModel )

namespace RadialBasisFunction
namespace ImplicitModel
{

typedef boost::shared_ptr< ActionRadialBasisFunction > ActionRadialBasisFunctionHandle;
typedef boost::shared_ptr< ActionImplicitModel > ActionImplicitModelHandle;

using namespace ::Seg3D;
using namespace ::Core;
Expand All @@ -73,15 +73,15 @@ class NotifierRunnable : public Runnable, public ConnectionHandler
std::string layerID_;
ActionContextHandle layerContext_;
NotifierHandle notifier_;
ActionRadialBasisFunctionHandle action_;
ActionImplicitModelHandle action_;

NotifierRunnable(const std::string& layerID, ActionContextHandle& layerContext, ActionRadialBasisFunctionHandle action) :
NotifierRunnable(const std::string& layerID, ActionContextHandle& layerContext, ActionImplicitModelHandle action) :
layerID_(layerID),
layerContext_(layerContext),
action_(action)
{
this->add_connection(
this->runThresholdSignal_.connect( boost::bind(&ActionRadialBasisFunction::run_threshold, action_, _1) ) );
this->runThresholdSignal_.connect( boost::bind(&ActionImplicitModel::run_threshold, action_, _1) ) );
}

~NotifierRunnable()
Expand All @@ -99,10 +99,10 @@ class NotifierRunnable : public Runnable, public ConnectionHandler
}
};

class ActionRadialBasisFunctionPrivate
class ActionImplicitModelPrivate
{
public:
ActionRadialBasisFunctionPrivate() :
ActionImplicitModelPrivate() :
normalOffset_(0),
compute2DConvexHull_(true),
invertSeedOrder_(false),
Expand All @@ -120,24 +120,24 @@ class ActionRadialBasisFunctionPrivate
double thresholdValue_;
};

class RadialBasisFunctionAlgo : public LayerFilter
class ImplicitModelAlgo : public LayerFilter
{
public:
ActionRadialBasisFunctionPrivateHandle actionInternal_;
ActionImplicitModelPrivateHandle actionInternal_;

RadialBasisFunctionAlgo();
virtual ~RadialBasisFunctionAlgo();
ImplicitModelAlgo();
virtual ~ImplicitModelAlgo();

SCI_BEGIN_RUN()
{
DataLayerHandle srcDataLayer = boost::dynamic_pointer_cast<DataLayer>(this->actionInternal_->srcLayer_);
DataLayerHandle dstDataLayer = boost::dynamic_pointer_cast<DataLayer>(this->actionInternal_->dstLayer_);
GridTransform srcGridTransform = srcDataLayer->get_grid_transform();

std::vector<vec3> rbfPointData;
std::vector<vec3> modelPointData;
for ( auto &vertex : this->actionInternal_->vertices_ )
{
rbfPointData.push_back( vec3(vertex.x(), vertex.y(), vertex.z()) );
modelPointData.push_back( vec3(vertex.x(), vertex.y(), vertex.z()) );
}

std::vector<axis_t> axisData;
Expand All @@ -164,12 +164,11 @@ class RadialBasisFunctionAlgo : public LayerFilter
}
}


// origin and size from source data layer
Point origin = srcGridTransform.get_origin();
vec3 rbfOrigin(origin.x(), origin.y(), origin.z());
vec3 rbfGridSize(srcGridTransform.get_nx(), srcGridTransform.get_ny(), srcGridTransform.get_nz());
vec3 rbfGridSpacing(srcGridTransform.spacing_x(), srcGridTransform.spacing_y(), srcGridTransform.spacing_z());
vec3 modelOrigin(origin.x(), origin.y(), origin.z());
vec3 modelGridSize(srcGridTransform.get_nx(), srcGridTransform.get_ny(), srcGridTransform.get_nz());
vec3 modelGridSpacing(srcGridTransform.spacing_x(), srcGridTransform.spacing_y(), srcGridTransform.spacing_z());

// From RBF class. ThinPlate is the default kernel.
Kernel kernel = ThinPlate;
Expand All @@ -182,12 +181,12 @@ class RadialBasisFunctionAlgo : public LayerFilter
kernel = MultiQuadratic;
}

RBFInterface rbfAlgo( rbfPointData, rbfOrigin, rbfGridSize, rbfGridSpacing,
RBFInterface modelAlgo( modelPointData, modelOrigin, modelGridSize, modelGridSpacing,
this->actionInternal_->normalOffset_, axisData,
this->actionInternal_->compute2DConvexHull_,
this->actionInternal_->invertSeedOrder_, kernel );

this->actionInternal_->thresholdValue_ = rbfAlgo.getThresholdValue();
this->actionInternal_->thresholdValue_ = modelAlgo.getThresholdValue();

Core::DataBlockHandle dstDataBlock = Core::StdDataBlock::New( srcGridTransform, Core::DataType::DOUBLE_E );
if ( ! dstDataBlock )
Expand All @@ -196,7 +195,7 @@ class RadialBasisFunctionAlgo : public LayerFilter
return;
}

const DataStorage rasterData = rbfAlgo.getRasterData();
const DataStorage rasterData = modelAlgo.getRasterData();
for (size_t i = 0; i < dstDataBlock->get_nx(); ++i)
{
for (size_t j = 0; j < dstDataBlock->get_ny(); ++j)
Expand All @@ -222,28 +221,28 @@ class RadialBasisFunctionAlgo : public LayerFilter
// The name of the filter, this information is used for generating new layer labels.
virtual std::string get_filter_name() const
{
return "RadialBasisFunction Tool";
return "ImplicitModel Tool";
}

// GET_LAYER_PREFIX:
// This function returns the name of the filter. The latter is prepended to the new layer name,
// when a new layer is generated.
virtual std::string get_layer_prefix() const
{
return "RadialBasisFunction";
return "ImplicitModel";
}
};

RadialBasisFunctionAlgo::RadialBasisFunctionAlgo()
ImplicitModelAlgo::ImplicitModelAlgo()
{
}

RadialBasisFunctionAlgo::~RadialBasisFunctionAlgo()
ImplicitModelAlgo::~ImplicitModelAlgo()
{
}

ActionRadialBasisFunction::ActionRadialBasisFunction() :
private_( new ActionRadialBasisFunctionPrivate )
ActionImplicitModel::ActionImplicitModel() :
private_( new ActionImplicitModelPrivate )

{
this->add_layer_id( this->private_->targetLayerID_ );
Expand All @@ -256,7 +255,7 @@ ActionRadialBasisFunction::ActionRadialBasisFunction() :
this->add_parameter( this->sandbox_ );
}

bool ActionRadialBasisFunction::validate( ActionContextHandle& context )
bool ActionImplicitModel::validate( ActionContextHandle& context )
{
if (this->private_->vertices_.size() < 3)
{
Expand All @@ -282,9 +281,9 @@ bool ActionRadialBasisFunction::validate( ActionContextHandle& context )
return true;
}

bool ActionRadialBasisFunction::run( ActionContextHandle& context, ActionResultHandle& result )
bool ActionImplicitModel::run( ActionContextHandle& context, ActionResultHandle& result )
{
boost::shared_ptr< RadialBasisFunctionAlgo > algo( new RadialBasisFunctionAlgo() );
boost::shared_ptr< ImplicitModelAlgo > algo( new ImplicitModelAlgo() );

// Set up parameters
algo->set_sandbox( this->sandbox_ );
Expand Down Expand Up @@ -327,14 +326,14 @@ bool ActionRadialBasisFunction::run( ActionContextHandle& context, ActionResultH
NotifierRunnableHandle notifierThread_(
new NotifierRunnable( this->private_->dstLayer_->get_layer_id(),
layerContext,
boost::dynamic_pointer_cast< ActionRadialBasisFunction >(this->shared_from_this()) ) );
boost::dynamic_pointer_cast< ActionImplicitModel >(this->shared_from_this()) ) );
Runnable::Start( notifierThread_ );
}

return true;
}

bool ActionRadialBasisFunction::run_threshold( ActionContextHandle& context )
bool ActionImplicitModel::run_threshold( ActionContextHandle& context )
{
DataLayerHandle dstDataLayer = boost::dynamic_pointer_cast<DataLayer>( this->private_->dstLayer_ );
double dstMaxValue = dstDataLayer->get_data_volume()->get_data_block()->get_max();
Expand All @@ -346,18 +345,18 @@ bool ActionRadialBasisFunction::run_threshold( ActionContextHandle& context )
return true;
}

void ActionRadialBasisFunction::Dispatch(
ActionContextHandle context,
const std::string& target,
const VertexList& vertices,
const ViewModeList& viewModes,
double normalOffset,
bool compute2DConvexHull,
bool invertSeedOrder,
const std::string& kernel
)
void ActionImplicitModel::Dispatch(
ActionContextHandle context,
const std::string& target,
const VertexList& vertices,
const ViewModeList& viewModes,
double normalOffset,
bool compute2DConvexHull,
bool invertSeedOrder,
const std::string& kernel
)
{
ActionRadialBasisFunction* action = new ActionRadialBasisFunction;
ActionImplicitModel* action = new ActionImplicitModel;
action->private_->targetLayerID_ = target;
action->private_->vertices_ = vertices;
action->private_->view_modes_ = viewModes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,45 @@
DEALINGS IN THE SOFTWARE.
*/

#ifndef APPLICATION_TOOLS_ACTIONS_ACTIONRRADIALBASISFUNCTION_H
#define APPLICATION_TOOLS_ACTIONS_ACTIONRRADIALBASISFUNCTION_H
#ifndef APPLICATION_TOOLS_ACTIONS_ACTIONIMPLICITMODEL_H
#define APPLICATION_TOOLS_ACTIONS_ACTIONIMPLICITMODEL_H

#include <Application/Layer/LayerAction.h>
#include <Application/Layer/LayerManager.h>

namespace RadialBasisFunction
namespace ImplicitModel
{

class NotifierRunnable;
typedef boost::shared_ptr<NotifierRunnable> NotifierRunnableHandle;

class ActionRadialBasisFunctionPrivate;
typedef boost::shared_ptr< ActionRadialBasisFunctionPrivate > ActionRadialBasisFunctionPrivateHandle;
class ActionImplicitModelPrivate;
typedef boost::shared_ptr< ActionImplicitModelPrivate > ActionImplicitModelPrivateHandle;

typedef Core::Point VertexCoord;
typedef std::vector< VertexCoord > VertexList;

typedef std::vector< std::string > ViewModeList;

class ActionRadialBasisFunction : public Seg3D::LayerAction
class ActionImplicitModel : public Seg3D::LayerAction
{
CORE_ACTION(
CORE_ACTION_TYPE( "RadialBasisFunction", "Implicit function action interface" )
CORE_ACTION_TYPE( "ImplicitModel", "Implicit model function action interface" )
CORE_ACTION_ARGUMENT( "layerid", "The layerid on which this filter needs to be run." )
CORE_ACTION_ARGUMENT( "vertices", "The 3D points needed to generate the radial basis function." )
CORE_ACTION_ARGUMENT( "vertices", "The 3D points needed to generate the implicit model function." )
CORE_ACTION_ARGUMENT( "view_modes", "The 2D view where each point was picked (axial or sagittal or coronal)." )
CORE_ACTION_ARGUMENT( "normal_offset", "Normal vector offset parameter." )
CORE_ACTION_OPTIONAL_ARGUMENT( "convex_hull_2D", "true", "" )
CORE_ACTION_OPTIONAL_ARGUMENT( "invert_seed_order", "false", "" )
CORE_ACTION_OPTIONAL_ARGUMENT( "kernel", "thin_plate", "Radial basis function kernel (thin_plate or gaussian or multi_quadratic)." )
CORE_ACTION_OPTIONAL_ARGUMENT( "kernel", "thin_plate", "Implicit model function kernel (thin_plate or gaussian or multi_quadratic)." )
CORE_ACTION_OPTIONAL_ARGUMENT( "sandbox", "-1", "The sandbox in which to run the action." )
CORE_ACTION_ARGUMENT_IS_NONPERSISTENT( "sandbox" )
CORE_ACTION_CHANGES_PROJECT_DATA()
CORE_ACTION_IS_UNDOABLE()
)

public:
ActionRadialBasisFunction();
ActionImplicitModel();

// VALIDATE:
// Each action needs to be validated just before it is posted. This way we
Expand All @@ -79,7 +79,7 @@ CORE_ACTION(
bool run_threshold( Core::ActionContextHandle& context );

private:
ActionRadialBasisFunctionPrivateHandle private_;
ActionImplicitModelPrivateHandle private_;
Seg3D::SandboxID sandbox_;

public:
Expand Down
4 changes: 2 additions & 2 deletions src/Application/Filters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ SET(APPLICATION_FILTERS_ACTIONS_SRCS
Actions/ActionPointSetRegisterFilter.cc
Actions/ActionPointSetTransformFilter.h
Actions/ActionPointSetTransformFilter.cc
Actions/ActionRadialBasisFunction.h
Actions/ActionRadialBasisFunction.cc
Actions/ActionImplicitModel.h
Actions/ActionImplicitModel.cc
Actions/ActionPadFilter.h
Actions/ActionPadFilter.cc
Actions/ActionSingleThreshold.h
Expand Down
4 changes: 2 additions & 2 deletions src/Application/Tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ SET(APPLICATION_TOOLS_SRCS
PointsSelectTool.cc
PadTool.h
PadTool.cc
RadialBasisFunctionTool.h
RadialBasisFunctionTool.cc
ImplicitModelTool.h
ImplicitModelTool.cc
WatershedFilter.h
WatershedFilter.cc
)
Expand Down
Loading