Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 4ec50365 authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

added processor registrar to all processors

parent 6b58827e
......@@ -328,7 +328,7 @@ namespace campvis {
virtual size_t getVideoMemoryFootprint() const = 0;
virtual AbstractData* clone() const = 0;
};
/* DataHandle */
class DataHandle {
......
......@@ -82,6 +82,7 @@ namespace campvis {
* \note When overwriting this method, make sure to call the base class version at the end.
*/
virtual void deinit();
DataNameProperty p_sourceImageID; ///< image ID for input image
DataNameProperty p_entryImageID; ///< image ID for output entry points image
......
......@@ -76,7 +76,7 @@ namespace campvis {
/// \see AbstractProcessor::deinit
virtual void deinit();
/// \see cgt::EventListener::onEvent()
virtual void onEvent(cgt::Event* e);
......
......@@ -43,6 +43,7 @@
#include "modules/vis/processors/sliceextractor.h"
#include <vector>
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -113,9 +114,13 @@ namespace campvis {
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "MicroscopyImageSegmentation"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "MicroscopyImageSegmentation"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Combines a volume raycaster and 3 slice views for explorative volume visualization."; };
/// \see AbstractProcessor::getAuthor()
......@@ -223,6 +228,8 @@ namespace campvis {
int insertNextVoxelAt;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<MicroscopyImageSegmentation>;
}
#endif // MICROSCOPYIMAGESEGMENTATION_H__
......@@ -34,6 +34,7 @@
#include "core/properties/optionproperty.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class BufferObject;
......@@ -60,9 +61,13 @@ namespace campvis {
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GlGaussianFilter"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GlGaussianFilter"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Performs a gaussian filtering on the input image using OpenGL."; };
/// \see AbstractProcessor::getAuthor()
......@@ -96,6 +101,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<GlGaussianFilter>;
}
#endif // GLGAUSSIANFILTER_H__
......@@ -32,6 +32,7 @@
#include "core/properties/datanameproperty.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -57,9 +58,13 @@ namespace campvis {
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GlGradientVolumeGenerator"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GlGradientVolumeGenerator"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Creates the gradient volume for the given intensity volume using OpenGL."; };
/// \see AbstractProcessor::getAuthor()
......@@ -83,6 +88,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<GlGradientVolumeGenerator>;
}
#endif // GLGRADIENTVOLUMEGENERATOR_H__
......@@ -32,6 +32,7 @@
#include "core/properties/datanameproperty.h"
#include "core/properties/transferfunctionproperty.h"
#include "core/properties/numericproperty.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -57,9 +58,13 @@ namespace campvis {
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GlImageCrop"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GlImageCrop"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Quantizes image intensities into a fixed number of bins using the GPU."; };
/// \see AbstractProcessor::getAuthor()
......@@ -84,6 +89,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<GlImageCrop>;
}
#endif // GLIMAGECROP_H__
......@@ -33,6 +33,7 @@
#include "core/properties/floatingpointproperty.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -58,9 +59,13 @@ namespace campvis {
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GlImageResampler"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GlImageResampler"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Resamples am image on the GPU using OpenGL."; };
/// \see AbstractProcessor::getAuthor()
......@@ -84,6 +89,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<GlImageResampler>;
}
#endif // GLIMAGERESAMPLER_H__
......
......@@ -34,6 +34,7 @@
#include "core/properties/numericproperty.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -59,9 +60,13 @@ namespace campvis {
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GlIntensityQuantizer"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GlIntensityQuantizer"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Quantizes image intensities into a fixed number of bins using the GPU."; };
/// \see AbstractProcessor::getAuthor()
......@@ -84,6 +89,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<GlIntensityQuantizer>;
}
#endif // GLINTENSITYQUANTIZER_H__
......@@ -34,6 +34,7 @@
#include "core/properties/stringproperty.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -59,9 +60,13 @@ namespace campvis {
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GlMorphologyFilter"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GlMorphologyFilter"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Creates the gradient volume for the given intensity volume using OpenGL."; };
/// \see AbstractProcessor::getAuthor()
......@@ -98,6 +103,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<GlMorphologyFilter>;
}
#endif // GLMORPHOLOGYFILTER_H__
......@@ -32,6 +32,7 @@
#include "core/properties/datanameproperty.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -57,9 +58,13 @@ namespace campvis {
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GlSignalToNoiseRatioFilter"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GlSignalToNoiseRatioFilter"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Creates the gradient volume for the given intensity volume using OpenGL."; };
/// \see AbstractProcessor::getAuthor()
......@@ -81,6 +86,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<GlSignalToNoiseRatioFilter>;
}
#endif // GLSIGNALTONOISERATIOFILTER_H__
......@@ -32,6 +32,7 @@
#include "core/properties/floatingpointproperty.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -57,9 +58,13 @@ namespace campvis {
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GlVesselnessFilter"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GlVesselnessFilter"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Computes a Vesselness Measure very similar to the one proposed by Frangi."; };
/// \see AbstractProcessor::getAuthor()
......@@ -87,6 +92,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<GlVesselnessFilter>;
}
#endif // GLVESSELNESSFILTER_H__
......@@ -53,10 +53,10 @@ namespace campvis {
tbb::spin_mutex::scoped_lock lock(_mutex);
std::vector<std::string> toReturn;
toReturn.reserve(_processorMap2.size()+_processorMap.size());
for (auto it = _processorMap2.begin(); it != _processorMap2.end(); ++it)
toReturn.reserve(_processorMapWithIVec2Param.size()+_processorMapDefault.size());
for (auto it = _processorMapWithIVec2Param.begin(); it != _processorMapWithIVec2Param.end(); ++it)
toReturn.push_back(it->first);
for (auto it = _processorMap.begin(); it != _processorMap.end(); ++it)
for (auto it = _processorMapDefault.begin(); it != _processorMapDefault.end(); ++it)
toReturn.push_back(it->first);
return toReturn;
}
......@@ -65,14 +65,14 @@ namespace campvis {
tbb::spin_mutex::scoped_lock lock(_mutex);
if (viewPortSizeProp != nullptr) {
auto it = _processorMap2.find(id);
if (it == _processorMap2.end())
auto it = _processorMapWithIVec2Param.find(id);
if (it == _processorMapWithIVec2Param.end())
return nullptr;
else
return (it->second)(viewPortSizeProp);
} else {
auto it = _processorMap.find(id);
if (it == _processorMap.end())
auto it = _processorMapDefault.find(id);
if (it == _processorMapDefault.end())
return nullptr;
else
return (it->second)();
......
......@@ -76,19 +76,19 @@ namespace campvis {
* \return The registration index.
*/
template<typename T>
size_t registerProcessor(std::function<AbstractProcessor*()> callee) {
size_t registerProcessorWithDefaultConstructor(std::function<AbstractProcessor*()> callee) {
tbb::spin_mutex::scoped_lock lock(_mutex);
auto it = _processorMap.lower_bound(T::getId());
if (it == _processorMap.end() || it->first != T::getId()) {
_processorMap.insert(it, std::make_pair(T::getId(), callee));
auto it = _processorMapDefault.lower_bound(T::getId());
if (it == _processorMapDefault.end() || it->first != T::getId()) {
_processorMapDefault.insert(it, std::make_pair(T::getId(), callee));
}
else {
// do nothing, a double registration may occure due to having the ProcessorRegistrar
// being referenced in both campvis-application and campvis-modules
}
return _processorMap.size();
return _processorMapDefault.size();
}
/**
......@@ -98,27 +98,27 @@ namespace campvis {
* \return The registration index.
*/
template<typename T>
size_t registerProcessor2(std::function<AbstractProcessor*(IVec2Property*)> callee) {
size_t registerProcessorWithIVec2PropParam(std::function<AbstractProcessor*(IVec2Property*)> callee) {
tbb::spin_mutex::scoped_lock lock(_mutex);
auto it = _processorMap2.lower_bound(T::getId());
if (it == _processorMap2.end() || it->first != T::getId()) {
_processorMap2.insert(it, std::make_pair(T::getId(), callee));
auto it = _processorMapWithIVec2Param.lower_bound(T::getId());
if (it == _processorMapWithIVec2Param.end() || it->first != T::getId()) {
_processorMapWithIVec2Param.insert(it, std::make_pair(T::getId(), callee));
}
else {
// do nothing, a double registration may occure due to having the ProcessorRegistrar
// being referenced in both campvis-application and campvis-modules
}
return _processorMap2.size();
return _processorMapWithIVec2Param.size();
}
private:
mutable tbb::spin_mutex _mutex;
static tbb::atomic<ProcessorFactory*> _singleton; ///< the singleton object
std::map< std::string, std::function<AbstractProcessor*()>> _processorMap;
std::map< std::string, std::function<AbstractProcessor*(IVec2Property*)>> _processorMap2;
std::map< std::string, std::function<AbstractProcessor*()>> _processorMapDefault;
std::map< std::string, std::function<AbstractProcessor*(IVec2Property*)>> _processorMapWithIVec2Param;
};
......@@ -144,7 +144,7 @@ namespace campvis {
};
template<typename T>
const size_t ProcessorRegistrarSwitch<T, false>::_factoryId = ProcessorFactory::getRef().registerProcessor<T>(&ProcessorRegistrarSwitch<T, false>::create);
const size_t ProcessorRegistrarSwitch<T, false>::_factoryId = ProcessorFactory::getRef().registerProcessorWithDefaultConstructor<T>(&ProcessorRegistrarSwitch<T, false>::create);
template<typename T>
......@@ -164,7 +164,7 @@ namespace campvis {
};
template<typename T>
const size_t ProcessorRegistrarSwitch<T, true>::_factoryId = ProcessorFactory::getRef().registerProcessor2<T>(&ProcessorRegistrarSwitch<T, true>::create);
const size_t ProcessorRegistrarSwitch<T, true>::_factoryId = ProcessorFactory::getRef().registerProcessorWithIVec2PropParam<T>(&ProcessorRegistrarSwitch<T, true>::create);
......
......@@ -35,6 +35,7 @@
#include "core/datastructures/geometrydata.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -69,9 +70,13 @@ namespace campvis {
* Destructor
**/
virtual ~TensorGlyphRenderer();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "TensorGlyphRenderer"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "TensorGlyphRenderer"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Renders axis-aligned slices with tensor glyphs."; };
/// \see AbstractProcessor::getAuthor()
......@@ -123,6 +128,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<TensorGlyphRenderer>;
}
#endif // TENSORGLYPHRENDERER_H__
......@@ -37,6 +37,7 @@
#include "core/datastructures/geometrydata.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class BufferObject;
......@@ -65,9 +66,13 @@ namespace campvis {
* Destructor
**/
virtual ~ParticleFlowRenderer();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "ParticleFlowRenderer"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "ParticleFlowRenderer"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Visualization of a flow field using a particle system."; };
/// \see AbstractProcessor::getAuthor()
......@@ -146,6 +151,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<ParticleFlowRenderer>;
}
#endif // PARTICLEFLOWRENDERER_H__
......@@ -35,6 +35,7 @@
#include "core/datastructures/geometrydata.h"
#include "modules/modulesapi.h"
#include "modules/processorfactory.h"
namespace cgt {
class Shader;
......@@ -63,9 +64,13 @@ namespace campvis {
* Destructor
**/
virtual ~VectorFieldRenderer();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "VectorFieldRenderer"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "VectorFieldRenderer"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Renders vector fields with arrows"; };
/// \see AbstractProcessor::getAuthor()
......@@ -126,6 +131,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<VectorFieldRenderer>;
}
#endif // VECTORFIELDRENDERER_H__
......@@ -5,6 +5,8 @@
#include "core/pipeline/autoevaluationpipeline.h"
#include "modules/vis/processors/volumeexplorer.h"
#include "modules/vis/processors/volumerenderer.h"
#include "modules/processorfactory.h"
%}
......@@ -46,6 +48,33 @@ namespace campvis {
campvis::DataNameProperty p_outputImage;
%mutable;
};
/* ProcessorFactory */
class ProcessorFactory {
public:
static ProcessorFactory& getRef();
std::vector<std::string> getRegisteredProcessors() const;
AbstractProcessor* createProcessor(const std::string& id, IVec2Property* viewPortSizeProp = 0) const;
};
/* Down casting or super classes.
* Down casting follows the order of declaration.
* Declare the classes as child first according to the class hierarchy.
*/
/* Downcast the return value of HasPropertyCollection::getProperty to appropriate subclass */
%factory(AbstractProperty* campvis::ProcessorFactory::createProcessor,
campvis::SimpleRaycaster, campvis::OptimizedRaycaster, campvis::DRRRaycaster, campvis::ContextPreservingRaycaster, campvis::AdvOptimizedRaycaster,
campvis::SliceExtractor, SliceRenderer2D, SliceRenderer3D,
campvis::VolumeExplorer, campvis::VolumeRenderer,
campvis::MicroscopyImageSegmentation,
campvis::GlGaussianFilter, campvis::GlGradientVolumeGenerator, campvis::GlImageCrop, campvis::GlImageResampler, campvis::GlIntensityQuantizer, campvis::GlMorphologyFilter,
campvis::GlSignalToNoiseRatioFilter, campvis::GlVesselnessFilter, campvis::TensorGlyphRenderer, campvis::ParticleFlowRenderer,
campvis::VectorFieldRenderer,
campvis::QuadView, campvis::RenderTargetCompositor, campvis::VirtualMirrorCombine,
campvis::DepthDarkening, campvis::EEPGenerator, campvis::GeometryRenderer, campvis::MprRenderer);
}
%luacode {
......
......@@ -32,6 +32,7 @@
#include "modules/modulesapi.h"
#include "modules/vis/tools/voxelhierarchymapper.h"
#include "modules/processorfactory.h"
#include <string>
......@@ -61,9 +62,13 @@ namespace campvis {
* Destructor
**/
virtual ~AdvOptimizedRaycaster();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "AdvOptimizedRaycaster"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "AdvOptimizedRaycaster"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Performs advanced ray casting to render sparse and big volumes faster."; };
/// \see AbstractProcessor::getAuthor()
......@@ -95,6 +100,8 @@ namespace campvis {
static const std::string loggerCat_;
};
// Instantiate template to register the pipelines.
template class SmartProcessorRegistrar<AdvOptimizedRaycaster>;
}