Commit 7fd11e5c authored by Mike Kremer's avatar Mike Kremer
Browse files

Fixed VolumeMeshNode such that it finally compiles under Win.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13858 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c81f31d0
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
#include <ACG/Scenegraph/DrawModes.hh> #include <ACG/Scenegraph/DrawModes.hh>
#include <OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh> #include <OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh>
#include <OpenVolumeMesh/Core/BaseEntities.hh> #include <OpenVolumeMesh/Core/BaseEntities.hh>
#include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
#include <OpenVolumeMesh/Attribs/ColorAttrib.hh>
#include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
//== FORWARDDECLARATIONS ====================================================== //== FORWARDDECLARATIONS ======================================================
...@@ -98,7 +101,11 @@ public: ...@@ -98,7 +101,11 @@ public:
}; };
/// Constructor /// Constructor
VolumeMeshNodeT(VolumeMesh& _mesh, BaseNode* _parent = 0, std::string _name = "<VolumeMeshNode>"); VolumeMeshNodeT(VolumeMesh& _mesh,
OpenVolumeMesh::StatusAttrib& _statusAttrib,
OpenVolumeMesh::ColorAttrib<Vec4f>& _colorAttrib,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& _normalAttrib,
BaseNode* _parent = 0, std::string _name = "<VolumeMeshNode>");
/// Destructor /// Destructor
~VolumeMeshNodeT(); ~VolumeMeshNodeT();
...@@ -273,6 +280,10 @@ private: ...@@ -273,6 +280,10 @@ private:
// Store point size // Store point size
float point_size_; float point_size_;
OpenVolumeMesh::StatusAttrib& statusAttrib_;
OpenVolumeMesh::ColorAttrib<Vec4f>& colorAttrib_;
OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_;
}; };
//============================================================================= //=============================================================================
......
...@@ -44,12 +44,17 @@ ...@@ -44,12 +44,17 @@
#define VOLUME_MESH_OBJECT_HH #define VOLUME_MESH_OBJECT_HH
// Includes // Includes
#include <ACG/Math/VectorT.hh>
#include <ACG/Scenegraph/SeparatorNode.hh> #include <ACG/Scenegraph/SeparatorNode.hh>
#include <ACG/Scenegraph/StatusNodesT.hh> #include <ACG/Scenegraph/StatusNodesT.hh>
#include <OpenFlipper/common/GlobalDefines.hh> #include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/common/BaseObjectData.hh> #include <OpenFlipper/common/BaseObjectData.hh>
#include <ObjectTypes/VolumeMeshObject/VolumeMeshNode.hh> #include <ObjectTypes/VolumeMeshObject/VolumeMeshNode.hh>
#include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
#include <OpenVolumeMesh/Attribs/ColorAttrib.hh>
#include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
template<class MeshT> template<class MeshT>
class DLLEXPORTONLY VolumeMeshObject : public BaseObjectData { class DLLEXPORTONLY VolumeMeshObject : public BaseObjectData {
public: public:
...@@ -120,8 +125,27 @@ public: ...@@ -120,8 +125,27 @@ public:
*/ */
BaseObject* copy(); BaseObject* copy();
typedef OpenVolumeMesh::ColorAttrib<ACG::Vec4f> ColorAttrib;
typedef OpenVolumeMesh::NormalAttrib<MeshT> NormalAttrib;
typedef OpenVolumeMesh::StatusAttrib StatusAttrib;
const StatusAttrib& status() const { return statusAttrib_; }
StatusAttrib& status() { return statusAttrib_; }
const ColorAttrib& colors() const { return colorAttrib_; }
ColorAttrib& colors() { return colorAttrib_; }
const NormalAttrib& normals() const { return normalAttrib_; }
NormalAttrib& normals() { return normalAttrib_; }
private: private:
MeshT* mesh_; MeshT* mesh_;
StatusAttrib statusAttrib_;
ColorAttrib colorAttrib_;
NormalAttrib normalAttrib_;
/** @} */ /** @} */
......
...@@ -61,7 +61,14 @@ ...@@ -61,7 +61,14 @@
template<class MeshT> template<class MeshT>
VolumeMeshObject<MeshT>::VolumeMeshObject(const VolumeMeshObject& _object) : VolumeMeshObject<MeshT>::VolumeMeshObject(const VolumeMeshObject& _object) :
BaseObjectData(_object), mesh_(0), meshNode_(0) { BaseObjectData(_object), mesh_(_object.mesh_),
statusAttrib_(*mesh_),
colorAttrib_(*mesh_),
normalAttrib_(*mesh_),
meshNode_((OpenFlipper::Options::nogui() ?
NULL :
new ACG::SceneGraph::VolumeMeshNodeT<MeshT>(*mesh_, statusAttrib_, colorAttrib_,
normalAttrib_, NULL, "NEW VolumeMeshNode"))) {
init(_object.mesh_); init(_object.mesh_);
...@@ -70,7 +77,14 @@ VolumeMeshObject<MeshT>::VolumeMeshObject(const VolumeMeshObject& _object) : ...@@ -70,7 +77,14 @@ VolumeMeshObject<MeshT>::VolumeMeshObject(const VolumeMeshObject& _object) :
template<class MeshT> template<class MeshT>
VolumeMeshObject<MeshT>::VolumeMeshObject(DataType _typeId) : VolumeMeshObject<MeshT>::VolumeMeshObject(DataType _typeId) :
BaseObjectData(), mesh_(0), meshNode_(0) { BaseObjectData(), mesh_(new MeshT()),
statusAttrib_(*mesh_),
colorAttrib_(*mesh_),
normalAttrib_(*mesh_),
meshNode_((OpenFlipper::Options::nogui() ?
NULL :
new ACG::SceneGraph::VolumeMeshNodeT<MeshT>(*mesh_, statusAttrib_, colorAttrib_,
normalAttrib_, NULL, "NEW VolumeMeshNode"))) {
setDataType(_typeId); setDataType(_typeId);
init(); init();
...@@ -125,13 +139,6 @@ void VolumeMeshObject<MeshT>::cleanup() { ...@@ -125,13 +139,6 @@ void VolumeMeshObject<MeshT>::cleanup() {
template<class MeshT> template<class MeshT>
void VolumeMeshObject<MeshT>::init(MeshT* _mesh) { void VolumeMeshObject<MeshT>::init(MeshT* _mesh) {
if(_mesh == 0)
mesh_ = new MeshT();
else
mesh_ = new MeshT(*_mesh);
mesh_->request_face_normals();
// Only initialize scenegraph nodes when we initialized a gui!! // Only initialize scenegraph nodes when we initialized a gui!!
if(OpenFlipper::Options::nogui()) if(OpenFlipper::Options::nogui())
return; return;
...@@ -142,7 +149,7 @@ void VolumeMeshObject<MeshT>::init(MeshT* _mesh) { ...@@ -142,7 +149,7 @@ void VolumeMeshObject<MeshT>::init(MeshT* _mesh) {
if(materialNode() == NULL) if(materialNode() == NULL)
std::cerr << "Error when creating mesh object! Material node is NULL!" << std::endl; std::cerr << "Error when creating mesh object! Material node is NULL!" << std::endl;
meshNode_ = new ACG::SceneGraph::VolumeMeshNodeT<MeshT>(*mesh_, materialNode(), "NEW VolumeMeshNode"); meshNode_->set_parent(materialNode());
// Update all nodes // Update all nodes
update(); update();
...@@ -223,6 +230,8 @@ void VolumeMeshObject<MeshT>::updateSelection() { ...@@ -223,6 +230,8 @@ void VolumeMeshObject<MeshT>::updateSelection() {
template<class MeshT> template<class MeshT>
void VolumeMeshObject<MeshT>::updateGeometry() { void VolumeMeshObject<MeshT>::updateGeometry() {
normalAttrib_.update_face_normals();
if(meshNode_) { if(meshNode_) {
meshNode_->set_geometry_changed(true); meshNode_->set_geometry_changed(true);
} }
......
include (plugin)
openflipper_plugin (DEPS OpenVolumeMesh)
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* OpenFlipper 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 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper 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 LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 13576 $ *
* $LastChangedBy: kremer $ *
* $Date: 2012-01-30 11:22:27 +0100 (Mo, 30 Jan 2012) $ *
* *
\*===========================================================================*/
#include "TypePolyhedralMesh.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <ObjectTypes/Plane/Plane.hh>
TypePolyhedralMeshPlugin::TypePolyhedralMeshPlugin() {
}
bool TypePolyhedralMeshPlugin::registerType() {
addDataType("PolyhedralMesh", tr("Polyhedral Volume Mesh"));
setTypeIcon("PolyhedralMesh", "PolyVolMeshType.png");
return true;
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::pluginsInitialized() {
if(OpenFlipper::Options::nogui()) return;
emit registerKey(Qt::Key_F8, Qt::ShiftModifier, "Set scaling of cell shrinkage");
// scaling action in context menu
QAction* act_scale_cells = new QAction(tr("Scale cells (Shift-F8)"), this);
act_scale_cells->setStatusTip(tr("Scale cells (Shift-F8)"));
connect(act_scale_cells, SIGNAL( triggered() ), this, SLOT( slot_change_shrinkage() ));
emit addContextMenuItem(act_scale_cells, DATA_POLYHEDRAL_MESH, CONTEXTOBJECTMENU);
}
//----------------------------------------------------------------------------
int TypePolyhedralMeshPlugin::addEmpty() {
// new object data struct
PolyhedralMeshObject* object = new PolyhedralMeshObject(DATA_POLYHEDRAL_MESH);
if (PluginFunctions::objectCount() == 1)
object->target(true);
if (PluginFunctions::targetCount() == 0)
object->target(true);
QString name = get_unique_name(object);
// call the local function to update names
QFileInfo f(name);
object->setName(f.fileName());
// enable backface culling
object->materialNode()->applyProperties(ACG::SceneGraph::MaterialNode::All);
// Set rendering props
object->meshNode()->drawMode(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED);
object->meshNode()->set_scaling(0.8);
object->update();
object->show();
emit log(LOGINFO, object->getObjectinfo());
emit emptyObjectAdded(object->id());
return object->id();
}
QString TypePolyhedralMeshPlugin::get_unique_name(PolyhedralMeshObject* _object) {
bool name_unique = false;
int cur_idx = _object->id();
while (!name_unique) {
name_unique = true;
QString cur_name = QString(tr("Polyhedral Mesh %1.ovm").arg(cur_idx));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_POLYHEDRAL_MESH);
for (; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if (o_it->name() == cur_name) {
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("Polyhedral Mesh %1.ovm").arg(cur_idx));
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::slotKeyEvent(QKeyEvent* _event) {
switch (_event->key()) {
case Qt::Key_F8:
if (_event->modifiers() & Qt::ShiftModifier)
slot_change_shrinkage();
break;
default:
break;
}
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::slotObjectUpdated(int _identifier) {
PlaneObject* pobj;
if (PluginFunctions::getObject(_identifier, pobj))
slot_update_planes_in_scenegraph_node();
}
void TypePolyhedralMeshPlugin::objectDeleted(int _identifier) {
PlaneObject* pobj;
if (PluginFunctions::getObject(_identifier, pobj)) {
slot_update_planes_in_scenegraph_node(_identifier);
}
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::slot_update_planes_in_scenegraph_node(int _deletedObject) {
typedef ACG::SceneGraph::VolumeMeshNodeT<PolyhedralMesh>::Plane Plane;
std::vector<Plane> planes;
// collect planes
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_PLANE); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
if(o_it->id() == _deletedObject) continue;
ACG::Vec3d p = (ACG::Vec3d) PluginFunctions::planeNode(*o_it)->position();
ACG::Vec3d n = (ACG::Vec3d) PluginFunctions::planeNode(*o_it)->normal();
ACG::Vec3d x = (ACG::Vec3d) PluginFunctions::planeNode(*o_it)->xDirection();
ACG::Vec3d y = (ACG::Vec3d) PluginFunctions::planeNode(*o_it)->yDirection();
x /= x.sqrnorm();
y /= y.sqrnorm();
planes.push_back(Plane(p, n, x, y));
}
// iterate over all target polyvolmeshes
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_POLYHEDRAL_MESH); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
PluginFunctions::polyhedralMeshObject(*o_it)->meshNode()->clear_cut_planes();
for (unsigned int i = 0; i < planes.size(); ++i) {
PluginFunctions::polyhedralMeshObject(*o_it)->meshNode()->add_cut_plane(planes[i]);
}
PluginFunctions::polyhedralMeshObject(*o_it)->meshNode()->set_geometry_changed(true);
}
emit updateView();
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::slot_change_shrinkage() {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS, DATA_POLYHEDRAL_MESH); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
// Popup dialog
bool ok;
double val = PluginFunctions::polyhedralMeshObject(*o_it)->meshNode()->scaling();
double scale = QInputDialog::getDouble(0, tr("Set singularity scaling for cell shrinkage"), tr("Size * :"), val,
0.0, 1.0, 2, &ok);
PluginFunctions::polyhedralMeshObject(*o_it)->meshNode()->set_scaling(scale);
emit updatedObject((*o_it)->id(), UPDATE_GEOMETRY);
}
}
Q_EXPORT_PLUGIN2( typepolyhedralmeshplugin , TypePolyhedralMeshPlugin );
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* OpenFlipper 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 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper 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 LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 13492 $ *
* $LastChangedBy: kremer $ *
* $Date: 2012-01-25 12:32:02 +0100 (Mi, 25 Jan 2012) $ *
* *
\*===========================================================================*/
#ifndef TYPEPOLYHEDRALMESH_HH
#define TYPEPOLYHEDRALMESH_HH
#include <QObject>
#include <ObjectTypes/PolyhedralMesh/PolyhedralMesh.hh>
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/TypeInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
class TypePolyhedralMeshPlugin : public QObject, BaseInterface, LoadSaveInterface, TypeInterface, KeyInterface, LoggingInterface, ContextMenuInterface {
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(TypeInterface)
Q_INTERFACES(KeyInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(ContextMenuInterface)
signals:
// Logging interface
void log(Logtype _type, QString _message);
void log(QString _message);
// LoadSave Interface
void emptyObjectAdded(int _id);
// ContextMenuInterface
void addContextMenuItem(QAction* /*_action*/, DataType /*_objectType*/, ContextMenuType /*_type*/);
private slots:
void noguiSupported() {}
void pluginsInitialized();
void slot_change_shrinkage();
void slotKeyEvent(QKeyEvent* _event);
void slotObjectUpdated(int _identifier);
void objectDeleted(int _identifier);
void slot_update_planes_in_scenegraph_node(int _deletedObject = -1);
public:
~TypePolyhedralMeshPlugin() {
}
TypePolyhedralMeshPlugin();
QString name() {
return (QString("TypePolyhedralMesh"));
}
QString description() {
return (QString(tr("Register Polyhedral Mesh Type")));
}
bool registerType();
public slots:
QString version() {
return QString("1.0");
}
// Type Interface
int addEmpty();
DataType supportedType() {
return DATA_POLYHEDRAL_MESH;
}
private:
QString get_unique_name(PolyhedralMeshObject* _object);
};
#endif //TYPEPOLYHEDRALMESH_HH
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