Removed dependencies from Core lib

This commit is contained in:
Paolo Andreetto
2019-08-07 09:10:36 +00:00
parent 38c61a4e9b
commit 621084fbfc
20 changed files with 104 additions and 219 deletions

View File

@@ -29,13 +29,11 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
//#include <Core/CommaInitializer.h>
#include <Math/Dense.h>
#include <Core/Mpl.h>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/set_c.hpp>
#include <Math/Dense.h>
namespace uLib {

View File

@@ -27,8 +27,8 @@
#include "Dense.h"
#include "Core/Archives.h"
#ifdef ULIB_SERIALIZATION_ON
ULIB_SERIALIZE(uLib::HPoint3f) {
ar & boost::serialization::make_nvp(NULL,boost::serialization::base_object<uLib::HPoint3f::BaseClass,uLib::HPoint3f>(ob));
}
@@ -48,5 +48,5 @@ ULIB_SERIALIZE(uLib::HError3f) {
ar
& "HLine -> ( poserr: " & AR(position_error) & "; direrr: " & AR(direction_error) & ") ";
}
#endif // ULIB_SERIALIZATION_ON

View File

@@ -26,25 +26,25 @@
/*
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2012 Andrea Rigoni Garola <andrea@pcimg05>
*
*
* 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
*
*
*/
@@ -54,9 +54,6 @@
#include <stdlib.h>
#include <Eigen/Dense>
#include "Core/Types.h"
#include "Core/Serializable.h"
//// BOOST SERIALIZATION ///////////////////////////////////////////////////////
@@ -109,6 +106,7 @@ std::ostream & operator << (std::ostream &os, const Eigen::Matrix<T,size,1> &vec
namespace uLib {
typedef id_t Id_t;
typedef int Scalari;
typedef unsigned int Scalarui;
@@ -199,7 +197,7 @@ public:
_HPoint3f<p>(Vector3f &in) : BaseClass(in.homogeneous()) { this->operator()(3) = p; }
void operator delete(void* _p, size_t _s) {}
// This constructor allows to construct MyVectorType from Eigen expressions
template<typename OtherDerived>
inline _HPoint3f<p>(const Eigen::MatrixBase<OtherDerived>& other)
@@ -264,6 +262,9 @@ operator<< (std::ostream& stream, const HError3f &err) {
////////////////////////////////////////////////////////////////////////////////
// SERIALIZTION //
#ifdef ULIB_SERIALIZATION_ON
#include "Core/Serializable.h"
ULIB_SERIALIZABLE(uLib::HPoint3f)
ULIB_SERIALIZABLE(uLib::HVector3f)
@@ -272,7 +273,7 @@ ULIB_SERIALIZABLE(uLib::HVector3f)
ULIB_SERIALIZABLE(uLib::HLine3f)
ULIB_SERIALIZABLE(uLib::HError3f)
#endif // ULIB_SERIALIZATION_ON

View File

@@ -28,7 +28,6 @@
#ifndef U_GEOMETRY_H
#define U_GEOMETRY_H
#include "Core/Object.h"
#include "Math/Dense.h"
#include "Math/Transform.h"

View File

@@ -32,11 +32,11 @@
namespace uLib {
class Quote : public Vector2f {
class Quote : public Vector2f
{
public:
uLibRefMacro(Offset,Scalarf);
inline Scalarf& Offset() { return this->m_Offset; }
private:
Scalarf m_Offset;

View File

@@ -28,14 +28,12 @@
#ifndef STRUCTUREDDATA_H
#define STRUCTUREDDATA_H
#include "Core/Object.h"
#include "Math/Dense.h"
namespace uLib {
class StructuredData : public Object {
class StructuredData {
public:
typedef Object BaseClass;
enum _Order
{
CustomOrder = 0,
@@ -52,7 +50,6 @@ public:
StructuredData(const Vector3i &size);
StructuredData(const StructuredData &copy) :
BaseClass(copy),
m_DataOrder(copy.m_DataOrder),
m_Dims(copy.m_Dims),
m_Increments(copy.m_Increments)

View File

@@ -28,7 +28,6 @@
#ifndef U_MATH_STRUCTUREDGRID_H
#define U_MATH_STRUCTUREDGRID_H
#include "Core/Object.h"
#include "Math/ContainerBox.h"
#include "Math/StructuredData.h"

View File

@@ -30,13 +30,12 @@
#include <vector>
#include "Core/Object.h"
#include "Math/Dense.h"
namespace uLib {
class TriangleMesh : public Object {
class TriangleMesh
{
public:
void PrintSelf(std::ostream &o);

View File

@@ -29,7 +29,6 @@
#define VOXIMAGEFILTER_H
#include "Core/StaticInterface.h"
#include "Core/Object.h"
#include "Math/Dense.h"
#include "Math/VoxImage.h"
@@ -64,7 +63,7 @@ protected:
template < typename VoxelT, typename AlgorithmT >
class VoxImageFilter : public Abstract::VoxImageFilter, public Object
class VoxImageFilter : public Abstract::VoxImageFilter
{
public:

View File

@@ -28,6 +28,7 @@
#ifndef VOXIMAGEFILTERCUSTOM_HPP
#define VOXIMAGEFILTERCUSTOM_HPP
#include "Core/Macros.h"
#include <Math/Dense.h>
#include "Math/VoxImage.h"
#include "VoxImageFilter.h"
@@ -76,7 +77,7 @@ public:
}
uLibSetMacro(CustomEvaluate,FunctionPt)
inline void SetCustomEvaluate(FunctionPt funPt) { this->m_CustomEvaluate = funPt; }
private:
FunctionPt m_CustomEvaluate;

View File

@@ -26,7 +26,6 @@
#include "Core/Vector.h"
#include "Dense.h"
#include "VoxImage.h"
#include "VoxImageFilterUser.h"

View File

@@ -29,6 +29,8 @@
#include "VoxRaytracer.h"
#include "Utils.h"
#include "Core/Macros.h"
inline float fast_sign(float f) { return 1 - 2 * (f < 0); }
namespace uLib {

View File

@@ -51,8 +51,9 @@ public:
void AppendRay ( const RayData &in);
uLibConstRefMacro(Data,std::vector<Element>)
uLibConstRefMacro(TotalLength,Scalarf)
inline const std::vector<Element>& Data() const { return this->m_Data; }
inline const Scalarf& TotalLength() const { return this->m_TotalLength; }
void PrintSelf(std::ostream &o);

View File

@@ -94,7 +94,7 @@ int main()
TEST1( pt == HPoint3f(-3,-3,-3) );
Raytracer::RayData rdata = ray.TraceBetweenPoints(HPoint3f(-3,-3,-3), HPoint3f(3,3,3));
foreach (const Raytracer::RayData::Element &el, rdata.Data())
for(const Raytracer::RayData::Element &el : rdata.Data())
{
std::cout << " " << el.vox_id << " , " << el.L << "\n";
}

View File

@@ -9,5 +9,10 @@ set( TESTS
# vtkTriangleMeshTest
)
set(LIBRARIES
${PACKAGE_LIBPREFIX}Core
${PACKAGE_LIBPREFIX}Vtk
)
include(${VTK_USE_FILE})
uLib_add_tests(${uLib-module})

View File

@@ -33,8 +33,6 @@
#include <ostream>
#include <iomanip>
#include <Core/Object.h>
// vtk classes forward declaration //
@@ -48,22 +46,8 @@ class vtkRendererCollection;
namespace uLib {
namespace Vtk {
//template <class T>
//class Tie {
//public:
// typedef T Content;
//};
class Puppet : public Object
class Puppet
{
uLibTypeMacro(Puppet, Object)
public:
Puppet();
~Puppet();

View File

@@ -28,6 +28,7 @@
#ifndef ULIBVTKVIEWER_H
#define ULIBVTKVIEWER_H
#include <iostream>
#include "uLibVtkInterface.h"

View File

@@ -63,53 +63,8 @@
namespace uLib {
namespace Vtk {
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// PIMPL
class vtkVoxImagePimpl {
public:
vtkVoxImagePimpl(vtkVoxImage::Content &content) :
m_Content(content),
m_Actor(vtkVolume::New()),
m_Image(vtkImageData::New()),
m_Outline(vtkCubeSource::New()),
m_Reader(NULL),
m_Writer(NULL)
{}
~vtkVoxImagePimpl()
{
m_Image->Delete();
m_Actor->Delete();
m_Outline->Delete();
}
void GetContent();
void SetContent();
// members //
vtkVolume *m_Actor;
vtkImageData *m_Image;
vtkCubeSource *m_Outline;
// io //
vtkXMLImageDataReader *m_Reader;
vtkXMLImageDataWriter *m_Writer;
// content //
vtkVoxImage::Content &m_Content;
// visual //
float m_Window;
float m_Level;
};
void vtkVoxImagePimpl::GetContent()
void vtkVoxImage::GetContent()
{
// ULIB -> VTK //
const int *dims = static_cast<const int *>(m_Content.GetDims().data());
@@ -139,7 +94,7 @@ void vtkVoxImagePimpl::GetContent()
// m_Image->Update();
}
void vtkVoxImagePimpl::SetContent()
void vtkVoxImage::SetContent()
{
// VTK -> ULIB //
int *ext = m_Image->GetExtent();
@@ -181,22 +136,29 @@ void vtkVoxImagePimpl::SetContent()
// VTK VOXIMAGE
vtkVoxImage::vtkVoxImage(Content &content) :
d(new vtkVoxImagePimpl(content))
{
init_properties();
d->GetContent();
m_Content(content),
m_Actor(vtkVolume::New()),
m_Image(vtkImageData::New()),
m_Outline(vtkCubeSource::New()),
m_Reader(NULL),
m_Writer(NULL),
writer_factor(1.E6)
{
GetContent();
InstallPipe();
}
vtkVoxImage::~vtkVoxImage()
{
delete d;
m_Image->Delete();
m_Actor->Delete();
m_Outline->Delete();
}
vtkImageData *vtkVoxImage::GetImageData()
{
d->GetContent();
return d->m_Image;
GetContent();
return m_Image;
}
void vtkVoxImage::SaveToXMLFile(const char *fname)
@@ -204,16 +166,16 @@ void vtkVoxImage::SaveToXMLFile(const char *fname)
vtkSmartPointer<vtkXMLImageDataWriter> writer =
vtkSmartPointer<vtkXMLImageDataWriter>::New();
writer->SetFileName(fname);
d->GetContent();
GetContent();
vtkSmartPointer<vtkImageShiftScale> vtkscale =
vtkSmartPointer<vtkImageShiftScale>::New();
# if VTK_MAJOR_VERSION <= 5
vtkscale->SetInputConnection(d->m_Image->GetProducerPort());
vtkscale->SetInputConnection(m_Image->GetProducerPort());
# else
vtkscale->SetInputData(d->m_Image);
vtkscale->SetInputData(m_Image);
# endif
vtkscale->SetScale(p().writer_factor);
vtkscale->SetScale(writer_factor);
vtkscale->Update();
writer->SetInputConnection(vtkscale->GetOutputPort());
writer->Update();
@@ -225,22 +187,22 @@ void vtkVoxImage::ReadFromVKTFile(const char *fname)
vtkSmartPointer<vtkGenericDataObjectReader> reader =
vtkSmartPointer<vtkGenericDataObjectReader>::New();
reader->SetFileName(fname);
reader->Update();
reader->Update();
if(reader->IsFileStructuredPoints())
{
vtkSmartPointer<vtkImageShiftScale> vtkscale =
vtkSmartPointer<vtkImageShiftScale>::New();
vtkscale->SetInputConnection(reader->GetOutputPort());
vtkscale->SetScale(1/p().writer_factor);
vtkscale->SetScale(1/writer_factor);
vtkscale->Update();
d->m_Image->DeepCopy(vtkscale->GetOutput()); // FIX! (pipe connection)
d->SetContent();
m_Image->DeepCopy(vtkscale->GetOutput()); // FIX! (pipe connection)
SetContent();
}
else {
std::cerr << "Error: file does not contain structured points\n";
}
d->m_Actor->Update();
m_Actor->Update();
}
void vtkVoxImage::ReadFromXMLFile(const char *fname)
@@ -252,25 +214,25 @@ void vtkVoxImage::ReadFromXMLFile(const char *fname)
vtkSmartPointer<vtkImageShiftScale> vtkscale =
vtkSmartPointer<vtkImageShiftScale>::New();
vtkscale->SetInputConnection(reader->GetOutputPort());
vtkscale->SetScale(1/p().writer_factor);
vtkscale->SetScale(1/writer_factor);
vtkscale->Update();
d->m_Image->DeepCopy(vtkscale->GetOutput());
d->SetContent();
m_Image->DeepCopy(vtkscale->GetOutput());
SetContent();
}
void vtkVoxImage::setShadingPreset(int blendType)
{
vtkSmartVolumeMapper *mapper =
(vtkSmartVolumeMapper *)d->m_Actor->GetMapper();
vtkVolumeProperty *property = d->m_Actor->GetProperty();
(vtkSmartVolumeMapper *)m_Actor->GetMapper();
vtkVolumeProperty *property = m_Actor->GetProperty();
static vtkColorTransferFunction *colorFun = vtkColorTransferFunction::New();
static vtkPiecewiseFunction *opacityFun = vtkPiecewiseFunction::New();
float window = 40 / $$.writer_factor;
float level = 20 / $$.writer_factor;
float window = 40 / writer_factor;
float level = 20 / writer_factor;
property->SetColor(colorFun);
property->SetScalarOpacity(opacityFun);
@@ -346,9 +308,9 @@ void vtkVoxImage::setShadingPreset(int blendType)
}
void vtkVoxImage::Update() {
d->m_Actor->Update();
d->m_Outline->SetBounds(d->m_Image->GetBounds());
d->m_Outline->Update();
m_Actor->Update();
m_Outline->SetBounds(m_Image->GetBounds());
m_Outline->Update();
}
void vtkVoxImage::InstallPipe()
@@ -356,26 +318,26 @@ void vtkVoxImage::InstallPipe()
vtkSmartPointer<vtkSmartVolumeMapper> mapper =
vtkSmartPointer<vtkSmartVolumeMapper>::New();
# if VTK_MAJOR_VERSION <= 5
mapper->SetInputConnection(d->m_Image->GetProducerPort());
mapper->SetInputConnection(m_Image->GetProducerPort());
# else
mapper->SetInputData(d->m_Image);
mapper->SetInputData(m_Image);
# endif
mapper->Update();
d->m_Actor->SetMapper(mapper);
m_Actor->SetMapper(mapper);
this->setShadingPreset(0);
mapper->Update();
d->m_Outline->SetBounds(d->m_Image->GetBounds());
m_Outline->SetBounds(m_Image->GetBounds());
vtkSmartPointer<vtkPolyDataMapper> mmapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mmapper->SetInputConnection(d->m_Outline->GetOutputPort());
mmapper->SetInputConnection(m_Outline->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mmapper);
actor->GetProperty()->SetRepresentationToWireframe();
actor->GetProperty()->SetAmbient(0.7);
// this->SetProp(actor);
this->SetProp(d->m_Actor);
this->SetProp(m_Actor);
}

View File

@@ -28,7 +28,12 @@
#ifndef U_VTKVOXIMAGE_H
#define U_VTKVOXIMAGE_H
#include <Core/Object.h>
#include "vtk/vtkVolume.h"
#include "vtk/vtkImageData.h"
#include "vtk/vtkXMLImageDataReader.h"
#include "vtk/vtkXMLImageDataWriter.h"
#include "vtk/vtkCubeSource.h"
#include <Math/VoxImage.h>
#include "uLibVtkInterface.h"
@@ -39,14 +44,8 @@ class vtkImageData;
namespace uLib {
namespace Vtk {
class vtkVoxImage : public Puppet {
uLibTypeMacro(vtkVoxImage,Puppet)
public:
properties()
{
float writer_factor;
};
class vtkVoxImage : public Puppet
{
public:
typedef Abstract::VoxImage Content;
@@ -54,6 +53,10 @@ public:
~vtkVoxImage();
void GetContent();
void SetContent();
vtkImageData * GetImageData();
void SaveToXMLFile(const char *fname);
@@ -67,20 +70,24 @@ public:
void Update();
protected:
void InstallPipe();
void InstallPipe();
float writer_factor;
private:
class vtkVoxImagePimpl *d;
vtkVolume *m_Actor;
vtkImageData *m_Image;
vtkCubeSource *m_Outline;
vtkXMLImageDataReader *m_Reader;
vtkXMLImageDataWriter *m_Writer;
vtkVoxImage::Content &m_Content;
float m_Window;
float m_Level;
};
inline void vtkVoxImage::init_properties()
{
$_init();
$$.writer_factor = 1.E6;
}
} // vtk
} // uLib