Commit 1ea7a433 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

* introducing GeometryData::getWorldBounds()

 * added debug output to DataContainerInspector
parent 680b2de4
......@@ -47,9 +47,14 @@
#include "core/datastructures/abstractdata.h"
#include "core/datastructures/datacontainer.h"
#include "core/datastructures/facegeometry.h"
#include "core/datastructures/geometrydata.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
#include "modules/columbia/datastructures/fiberdata.h"
#endif
#include "application/gui/datacontainertreewidget.h"
#include "application/gui/qtdatahandle.h"
......@@ -130,6 +135,12 @@ namespace campvis {
_lblTimestamp = new QLabel("Timestamp: ", _infoWidget);
_infoWidgetLayout->addWidget(_lblTimestamp);
_lblSize = new QLabel(tr("Size: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblSize);
_lblBounds = new QLabel(tr("World Bounds:"), _infoWidget);
_infoWidgetLayout->addWidget(_lblBounds);
_btnSaveToFile = new QPushButton(tr("Save to File"), _infoWidget);
_infoWidgetLayout->addWidget(_btnSaveToFile);
......@@ -191,8 +202,39 @@ namespace campvis {
_lblName->setText("Name: " + handles.front().first);
_lblTimestamp->setText("Timestamp: " + QString::number(handles.front().second.getTimestamp()));
if (dynamic_cast<const ImageData*>(handles.front().second.getData()))
if (const ImageData* tester = dynamic_cast<const ImageData*>(handles.front().second.getData())) {
_canvas->p_transferFunction.getTF()->setImageHandle(handles.front().second);
std::ostringstream ss;
ss << tester->getSize();
_lblSize->setText(tr("Size: ") + QString::fromStdString(ss.str()));
ss.str("");
ss << tester->getWorldBounds();
_lblBounds->setText(tr("World Bounds: ") + QString::fromStdString(ss.str()));
}
else if (const GeometryData* tester = dynamic_cast<const GeometryData*>(handles.front().second.getData())) {
_lblSize->setText(tr("Size: n/a"));
std::ostringstream ss;
ss << tester->getWorldBounds();
_lblBounds->setText(tr("World Bounds: ") + QString::fromStdString(ss.str()));
}
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
else if (const FiberData* tester = dynamic_cast<const FiberData*>(handles.front().second.getData())) {
std::ostringstream ss;
ss << "Size: " << tester->numFibers() << " Fibers with " << tester->numSegments() << " Segments.";
_lblSize->setText(QString::fromStdString(ss.str()));
ss.str("");
ss << tester->getWorldBounds();
_lblBounds->setText(tr("World Bounds: ") + QString::fromStdString(ss.str()));
}
#endif
else {
_lblSize->setText(tr("Size: n/a"));
_lblBounds->setText(tr("World Bounds: n/a"));
}
}
else {
_lblName->setText(QString::number(handles.size()) + " DataHandles selected");
......
......@@ -166,6 +166,8 @@ namespace campvis {
QLabel* _lblLocalMemoryFootprint;
QLabel* _lblVideoMemoryFootprint;
QLabel* _lblTimestamp;
QLabel* _lblSize;
QLabel* _lblBounds;
QPushButton* _btnSaveToFile;
};
}
......
......@@ -222,4 +222,11 @@ namespace campvis {
return FaceGeometry(verts, texCoords, cols, norms);
}
tgt::Bounds FaceGeometry::getWorldBounds() const {
tgt::Bounds toReturn;
for (std::vector<tgt::vec3>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it)
toReturn.addPoint(*it);
return toReturn;
}
}
\ No newline at end of file
......@@ -137,6 +137,9 @@ namespace campvis {
* Must be called from a valid OpenGL context.
*/
virtual void createGLBuffers() const;
/// \see GeometryData::getWorldBounds
virtual tgt::Bounds getWorldBounds() const;
protected:
......
......@@ -31,6 +31,7 @@
#define GEOMETRYDATA_H__
#include "tgt/tgt_gl.h"
#include "tgt/bounds.h"
#include "core/datastructures/abstractdata.h"
#include <vector>
......@@ -70,6 +71,12 @@ namespace campvis {
* Must be called from a valid OpenGL context.
*/
virtual void render(GLenum mode = GL_POLYGON) const = 0;
/**
* Returns the geometry extent in world coordinates.
* \return The geometry extent in world coordinates.
*/
virtual tgt::Bounds getWorldBounds() const = 0;
/**
* Creates the OpenGL VBOs and the VAO for this geometry.
......
......@@ -149,5 +149,13 @@ namespace campvis {
_buffersInitialized = true;
}
}
tgt::Bounds IndexedMeshGeometry::getWorldBounds() const {
tgt::Bounds toReturn;
for (std::vector<tgt::vec3>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it)
toReturn.addPoint(*it);
return toReturn;
}
}
\ No newline at end of file
......@@ -93,6 +93,9 @@ namespace campvis {
*/
virtual void createGLBuffers() const;
/// \see GeometryData::getWorldBounds
virtual tgt::Bounds getWorldBounds() const;
protected:
std::vector<uint16_t> _indices; ///< Index list defining the faces
......
......@@ -392,4 +392,12 @@ namespace campvis {
return MeshGeometry(tmp);
}
tgt::Bounds MeshGeometry::getWorldBounds() const {
tgt::Bounds toReturn;
for (size_t i = 0; i < _faces.size(); ++i)
for (std::vector<tgt::vec3>::const_iterator it = _faces[i].getVertices().begin(); it != _faces[i].getVertices().end(); ++it)
toReturn.addPoint(*it);
return toReturn;
}
}
\ No newline at end of file
......@@ -114,6 +114,9 @@ namespace campvis {
*/
static MeshGeometry createCube(const tgt::Bounds& bounds, const tgt::Bounds& texBounds);
/// \see GeometryData::getWorldBounds
virtual tgt::Bounds getWorldBounds() const;
protected:
std::vector<FaceGeometry> _faces; ///< List of all faces of this mesh
......
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