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 a0142259 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

* Introducing DataSeries type (like ImageSeries but holding AbstractData,...

* Introducing DataSeries type (like ImageSeries but holding AbstractData, ImageSeries should be replaced some time)
* Fixed cgt::dmatX typedefs
parent b2307f63
......@@ -31,6 +31,7 @@
#include "application/gui/qtdatahandle.h"
#include "core/datastructures/datacontainer.h"
#include "core/datastructures/abstractdata.h"
#include "core/datastructures/dataseries.h"
#include "core/datastructures/lightsourcedata.h"
#include "core/datastructures/facegeometry.h"
#include "core/datastructures/meshgeometry.h"
......@@ -130,6 +131,9 @@ namespace campvis {
return QVariant(QString("Render Data"));
}
else if (const DataSeries* tester = dynamic_cast<const DataSeries*>(data)) {
return QVariant(QString("Data Series"));
}
else if (const ImageSeries* tester = dynamic_cast<const ImageSeries*>(data)) {
return QVariant(QString("Image Series"));
}
......@@ -168,6 +172,11 @@ namespace campvis {
new DataHandleTreeItem(QtDataHandle(tester->getDepthDataHandle()), _name + "::DepthTexture", this);
}
}
else if (const DataSeries* tester = dynamic_cast<const DataSeries*>(data)) {
for (size_t i = 0; i < tester->getNumDatas(); ++i) {
new DataHandleTreeItem(QtDataHandle(tester->getData(i)), _name + "::Data" + StringUtils::toString(i), this);
}
}
else if (const ImageSeries* tester = dynamic_cast<const ImageSeries*>(data)) {
for (size_t i = 0; i < tester->getNumImages(); ++i) {
new DataHandleTreeItem(QtDataHandle(tester->getImage(i)), _name + "::Image" + StringUtils::toString(i), this);
......
......@@ -10,6 +10,7 @@
%{
#include "core/datastructures/abstractdata.h"
#include "core/datastructures/dataseries.h"
#include "core/datastructures/imagedata.h"
#include "core/properties/allproperties.h"
#include "core/pipeline/abstractprocessor.h"
......@@ -251,8 +252,40 @@ namespace campvis {
AbstractData();
virtual ~AbstractData();
virtual size_t getLocalMemoryFootprint() const = 0;
virtual size_t getVideoMemoryFootprint() const = 0;
virtual AbstractData* clone() const = 0;
};
/* DataHandle */
class DataHandle {
public:
explicit DataHandle(AbstractData* data = 0);
DataHandle(const DataHandle& rhs);
DataHandle& operator=(const DataHandle& rhs);
virtual ~DataHandle();
const AbstractData* getData() const;
};
/* DataSeries */
class DataSeries : public AbstractData {
public:
DataSeries();
virtual ~DataSeries();
virtual DataSeries* clone() const;
void addData(AbstractData* data);
void addData(DataHandle dh);
size_t getNumDatas() const;
DataHandle getData(size_t index) const;
protected:
std::vector<DataHandle> _data; ///< the images of this series
};
/* ImageData */
......@@ -268,18 +301,6 @@ namespace campvis {
/* Downcast the return value of DataHandle::getData to appropriate subclass */
%factory(AbstractData* campvis::DataHandle::getData, campvis::ImageData);
/* DataHandle */
class DataHandle {
public:
explicit DataHandle(AbstractData* data = 0);
DataHandle(const DataHandle& rhs);
DataHandle& operator=(const DataHandle& rhs);
virtual ~DataHandle();
const AbstractData* getData() const;
};
/* DataContainer */
class DataContainer {
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "dataseries.h"
#include "cgt/assert.h"
namespace campvis {
DataSeries::DataSeries()
: AbstractData()
{
}
DataSeries::~DataSeries() {
}
DataSeries* DataSeries::clone() const {
DataSeries* toReturn = new DataSeries();
for (size_t i = 0; i < _data.size(); ++i)
toReturn->_data.push_back(_data[i]);
return toReturn;
}
size_t DataSeries::getLocalMemoryFootprint() const {
size_t toReturn = sizeof(DataHandle) * _data.capacity();
for (size_t i = 0; i < _data.size(); ++i)
toReturn += _data[i].getData()->getLocalMemoryFootprint();
return toReturn;
}
size_t DataSeries::getVideoMemoryFootprint() const {
size_t toReturn = 0;
for (size_t i = 0; i < _data.size(); ++i)
toReturn += _data[i].getData()->getVideoMemoryFootprint();
return toReturn;
}
void DataSeries::addData(AbstractData* image) {
_data.push_back(DataHandle(image));
}
void DataSeries::addData(DataHandle dh) {
cgtAssert(dh.getData() != nullptr, "DataHandle must contain data!");
_data.push_back(dh);
}
size_t DataSeries::getNumDatas() const {
return _data.size();
}
DataHandle DataSeries::getData(size_t index) const {
cgtAssert(index < _data.size(), "Index out of bounds.");
return _data[index];
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef DATASERIES_H__
#define DATASERIES_H__
#include "core/datastructures/abstractdata.h"
#include "core/datastructures/datahandle.h"
#include <vector>
namespace campvis {
/**
* Class encapsulating a series of AbstractData objects.
*/
class CAMPVIS_CORE_API DataSeries : public AbstractData {
public:
/**
* Constructor
*/
DataSeries();
/**
* Virtual destructor
*/
virtual ~DataSeries();
/**
* Prototype - clone method, some people call this virtual constructor...
* \return A copy of this object.
*/
virtual DataSeries* clone() const;
/**
* Returns the local memory footprint of the data in bytes.
* \return Number of bytes occupied in local memory by the data.
*/
virtual size_t getLocalMemoryFootprint() const;
/**
* Returns the video memory footprint of the data in bytes.
* \return Number of bytes occupied in video memory by the data.
*/
virtual size_t getVideoMemoryFootprint() const;
/**
* Appends the AbstractData instance \a data to the series.
* \param AbstractData Data to be added.
*/
void addData(AbstractData* data);
/**
* Appends the DataHandle \a dh to the series.
* \note The DataHandle must contain valid data.
* \param dh DataHandle with data to be added.
*/
void addData(DataHandle dh);
/**
* Returns the number of AbstractData instances in this series.
* \return _data.size()
*/
size_t getNumDatas() const;
/**
* Returns a DataHandle with the AbstractData instance number \a index of this series.
* \param index Index of the data to return
* \return _data[index]
*/
DataHandle getData(size_t index) const;
protected:
std::vector<DataHandle> _data; ///< the images of this series
};
}
#endif // DATASERIES_H__
\ No newline at end of file
......@@ -18,11 +18,15 @@ namespace cgt {
Vector2(T t1, T t2);
static Vector2<T> zero;
T x;
T y;
};
%template(ivec2) Vector2<int>;
typedef Vector2<int> ivec2;
%template(svec2) Vector2<size_t>;
typedef Vector2<size_t> svec2;
%template(vec2) Vector2<float>;
typedef Vector2<float> vec2;
......@@ -37,13 +41,18 @@ namespace cgt {
Vector3(T _x, const Vector2<T>& v);
static Vector3<T> zero;
T x;
T y;
T z;
};
%template(vec3) Vector3<float>;
typedef Vector3<float> vec3;
%template(ivec3) Vector3<int>;
typedef Vector3<int> ivec3;
%template(svec3) Vector3<size_t>;
typedef Vector3<size_t> svec3;
%template(vec3) Vector3<float>;
typedef Vector3<float> vec3;
/* Vector4 */
......@@ -55,14 +64,71 @@ namespace cgt {
Vector4(const Vector2<T>& v1, const Vector2<T>& v2);
Vector4(const Vector2<T>& vec, T z_, T w_);
Vector4(T _x, T _y, const Vector2<T>& v);
T x;
T y;
T z;
T w;
};
%template(ivec4) Vector4<int>;
typedef Vector4<int> ivec4;
%template(svec4) Vector4<size_t>;
typedef Vector4<size_t> svec4;
%template(vec4) Vector4<float>;
typedef Vector4<float> vec4;
%template(col4) Vector4<uint8_t>;
typedef Vector4<uint8_t> col4;
/* Matrix */
template<class T>
struct Matrix4 {
T t00, t01, t02, t03;
T t10, t11, t12, t13;
T t20, t21, t22, t23;
T t30, t31, t32, t33;
Matrix4();
explicit Matrix4(T t);
template<class U> Matrix4(const Matrix4<U>& m);
explicit Matrix4(const T* t);
Matrix4(T _t00, T _t01, T _t02, T _t03,
T _t10, T _t11, T _t12, T _t13,
T _t20, T _t21, T _t22, T _t23,
T _t30, T _t31, T _t32, T _t33);
Matrix4(const Vector4<T>& v1, const Vector4<T>& v2,
const Vector4<T>& v3, const Vector4<T>& v4);
static const Matrix4<T> zero;
static const Matrix4<T> identity;
static Matrix4<T> createTranslation(const Vector3<T>& v);
static Matrix4<T> createScale(const Vector3<T>& v);
static Matrix4<T> createRotationX(T angle);
static Matrix4<T> createRotationY(T angle);
static Matrix4<T> createRotationZ(T angle);
static Matrix4<T> createRotation(T angle, Vector3<T> axis);
static Matrix4<T> createLookAt(const Vector3<T>& eye, const Vector3<T>& focus, const Vector3<T>& up);
static Matrix4<T> createFrustum(T left, T right, T top, T bottom, T pnear, T pfar);
static Matrix4<T> createPerspective(T fov, T aspect, T pnear, T pfar);
static Matrix4<T> createOrtho(T left, T right, T top, T bottom, T pnear, T pfar);
Vector4<T> operator [] (size_t i) const;
Vector4<T> operator [] (size_t i);
bool invert(Matrix4<T>& result) const;
};
/* EventListener */
class EventListener {
......
......@@ -694,9 +694,9 @@ typedef Matrix2f mat2;
typedef Matrix3f mat3;
typedef Matrix4f mat4;
typedef Matrix2f dmat2;
typedef Matrix3f dmat3;
typedef Matrix4f dmat4;
typedef Matrix2d dmat2;
typedef Matrix3d dmat3;
typedef Matrix4d dmat4;
#ifdef DLL_TEMPLATE_INST
template struct CGT_API Matrix2<float>;
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "dataseriessplitter.h"
#include "core/datastructures/dataseries.h"
namespace campvis {
const std::string DataSeriesSplitter::loggerCat_ = "CAMPVis.modules.io.DataSeriesSplitter";
DataSeriesSplitter::DataSeriesSplitter()
: AbstractProcessor()
, p_inputID("InputID", "Input Data Series ID", "input", DataNameProperty::READ)
, p_outputID("OutputID", "Output Data ID", "output", DataNameProperty::WRITE)
, p_imageIndex("ImageIndex", "Image to Select", 0, 0, 0)
{
addProperty(p_inputID, INVALID_RESULT | INVALID_PROPERTIES);
addProperty(p_outputID);
addProperty(p_imageIndex);
}
DataSeriesSplitter::~DataSeriesSplitter() {
}
void DataSeriesSplitter::updateResult(DataContainer& data) {
ScopedTypedData<DataSeries> series(data, p_inputID.getValue());
if (series != 0) {
if (p_imageIndex.getValue() < static_cast<int>(series->getNumDatas())) {
data.addDataHandle(p_outputID.getValue(), series->getData(p_imageIndex.getValue()));
}
}
}
void DataSeriesSplitter::updateProperties(DataContainer& dataContainer) {
ScopedTypedData<DataSeries> series(dataContainer, p_inputID.getValue());
if (series != 0)
p_imageIndex.setMaxValue(static_cast<int>(series->getNumDatas()));
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef DATASERIESSPLITTER_H__
#define DATASERIESSPLITTER_H__
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/numericproperty.h"
namespace campvis {
/**
* Extracts a single AbstractData instance from a DataSeries.
*/
class DataSeriesSplitter : public AbstractProcessor {
public:
/**
* Constructs a new DataSeriesSplitter Processor
**/
DataSeriesSplitter();
/**
* Destructor
**/
virtual ~DataSeriesSplitter();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "DataSeriesSplitter"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Extracts a single AbstractData instance from a DataSeries."; };
/// \see AbstractProcessor::getAuthor()
virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::STABLE; };
DataNameProperty p_inputID; ///< image ID for input data series
DataNameProperty p_outputID; ///< image ID for output data
IntProperty p_imageIndex; ///< index of the image to select
protected:
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
/// \see AbstractProcessor::updateProperties
virtual void updateProperties(DataContainer& dc);
static const std::string loggerCat_;
};
}
#endif // DATASERIESSPLITTER_H__
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment