First checkin for OpenMesh 2.0
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@2 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
37
Apps/Deprecated/IvViewer/ACGMakefile
Normal file
37
Apps/Deprecated/IvViewer/ACGMakefile
Normal file
@@ -0,0 +1,37 @@
|
||||
#== SYSTEM PART -- DON'T TOUCH ==============================================
|
||||
include $(ACGMAKE)/Config
|
||||
#==============================================================================
|
||||
|
||||
|
||||
SUBDIRS := $(call find-subdirs)
|
||||
|
||||
USE_COIN := no
|
||||
USE_SOQT := no
|
||||
|
||||
ifeq ($(USE_COIN),yes)
|
||||
USE_SOQT := yes
|
||||
endif
|
||||
|
||||
ifeq ($(USE_SOQT),yes)
|
||||
|
||||
CXX_DEFS += -DUSE_SOQT=1
|
||||
|
||||
ifeq ($(USE_COIN),yes)
|
||||
PACKAGES := coin soqt_coin glut opengl qt
|
||||
else
|
||||
PACKAGES := Inventor soqt_inventor glut opengl qt
|
||||
endif
|
||||
|
||||
else
|
||||
PACKAGES := inventor opengl x11
|
||||
endif
|
||||
|
||||
|
||||
PROJ_LIBS = OpenMesh/Core
|
||||
|
||||
MODULES := cxx
|
||||
|
||||
|
||||
#== SYSTEM PART -- DON'T TOUCH ==============================================
|
||||
include $(ACGMAKE)/Rules
|
||||
#==============================================================================
|
||||
370
Apps/Deprecated/IvViewer/SoOpenMeshNodeT.cc
Normal file
370
Apps/Deprecated/IvViewer/SoOpenMeshNodeT.cc
Normal file
@@ -0,0 +1,370 @@
|
||||
//=============================================================================
|
||||
//
|
||||
// OpenMesh
|
||||
// Copyright (C) 2003 by Computer Graphics Group, RWTH Aachen
|
||||
// www.openmesh.org
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// License
|
||||
//
|
||||
// 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, version 2.1.
|
||||
//
|
||||
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Revision: 1800 $
|
||||
// $Date: 2008-05-19 11:51:23 +0200 (Mo, 19. Mai 2008) $
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Class SoOpenMeshNodeT - implementation
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#define OPENMESH_SOOPENMESHNODE_CC
|
||||
|
||||
//== INCLUDES =================================================================
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <Inventor/SbBox.h>
|
||||
#include <Inventor/SoPrimitiveVertex.h>
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
#include <Inventor/misc/SoState.h>
|
||||
#include <Inventor/elements/SoLightModelElement.h>
|
||||
#include <Inventor/bundles/SoMaterialBundle.h>
|
||||
|
||||
#include "SoOpenMeshNodeT.hh"
|
||||
// Attention must be included after SoOpenMeshNodeT.hh
|
||||
// as it redefines several macros!
|
||||
#include "SoOpenMeshSupport.hh"
|
||||
|
||||
#include <OpenMesh/Core/Math/VectorT.hh>
|
||||
|
||||
|
||||
//== NAMESPACES ==============================================================
|
||||
|
||||
|
||||
namespace OpenMesh {
|
||||
|
||||
|
||||
//== IMPLEMENTATION ==========================================================
|
||||
|
||||
|
||||
// Helper functions: draw vertices
|
||||
inline void glVertex(const OpenMesh::Vec3f& _v) { glVertex3fv(_v); }
|
||||
inline void glVertex(const OpenMesh::Vec3d& _v) { glVertex3dv(_v); }
|
||||
|
||||
// Helper functions: draw normal
|
||||
inline void glNormal(const OpenMesh::Vec3f& _n) { glNormal3fv(_n); }
|
||||
inline void glNormal(const OpenMesh::Vec3d& _n) { glNormal3dv(_n); }
|
||||
|
||||
// Helper function: convert Vec to SbVec3f
|
||||
template <class Vec> inline SbVec3f sbvec3f(const Vec& _v) {
|
||||
return SbVec3f(_v[0], _v[1], _v[2]);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh>
|
||||
void
|
||||
SoOpenMeshNodeT<Mesh>::initClass()
|
||||
{
|
||||
SO_NODE_INIT_CLASS(SoOpenMeshNodeT<Mesh>, SoShape, "Shape");
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh>
|
||||
SoOpenMeshNodeT<Mesh>::SoOpenMeshNodeT(const Mesh* _mesh) :
|
||||
mesh_(_mesh)
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoOpenMeshNodeT<Mesh>);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh>
|
||||
void
|
||||
SoOpenMeshNodeT<Mesh>::GLRender(SoGLRenderAction *action)
|
||||
{
|
||||
if (mesh_ && shouldGLRender(action))
|
||||
{
|
||||
SoState* state = action->getState();
|
||||
SbBool send_normals = (SoLightModelElement::get(state) !=
|
||||
SoLightModelElement::BASE_COLOR);
|
||||
|
||||
SoMaterialBundle mb(action);
|
||||
mb.sendFirst();
|
||||
|
||||
drawFaces(send_normals);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template<class Mesh>
|
||||
void
|
||||
SoOpenMeshNodeT<Mesh>::
|
||||
drawFaces(bool _send_normals, OpenMesh::GenProg::Bool2Type<true>)
|
||||
{
|
||||
typename Mesh::ConstFaceIter f_it(mesh_->faces_begin()),
|
||||
f_end(mesh_->faces_end());
|
||||
|
||||
typename Mesh::ConstFaceVertexIter fv_it;
|
||||
|
||||
|
||||
if (_send_normals)
|
||||
{
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (; f_it!=f_end; ++f_it)
|
||||
{
|
||||
glNormal(mesh_->normal(f_it));
|
||||
fv_it = mesh_->cfv_iter(f_it.handle());
|
||||
glVertex(mesh_->point(fv_it));
|
||||
++fv_it;
|
||||
glVertex(mesh_->point(fv_it));
|
||||
++fv_it;
|
||||
glVertex(mesh_->point(fv_it));
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (; f_it!=f_end; ++f_it)
|
||||
{
|
||||
fv_it = mesh_->cfv_iter(f_it.handle());
|
||||
glVertex(mesh_->point(fv_it));
|
||||
++fv_it;
|
||||
glVertex(mesh_->point(fv_it));
|
||||
++fv_it;
|
||||
glVertex(mesh_->point(fv_it));
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template<class Mesh>
|
||||
void
|
||||
SoOpenMeshNodeT<Mesh>::
|
||||
drawFaces(bool _send_normals, OpenMesh::GenProg::Bool2Type<false>)
|
||||
{
|
||||
typename Mesh::ConstFaceIter f_it(mesh_->faces_begin()),
|
||||
f_end(mesh_->faces_end());
|
||||
|
||||
typename Mesh::ConstFaceVertexIter fv_it;
|
||||
|
||||
|
||||
if (_send_normals)
|
||||
{
|
||||
for (; f_it!=f_end; ++f_it)
|
||||
{
|
||||
glBegin(GL_POLYGON);
|
||||
glNormal(mesh_->normal(f_it));
|
||||
for (fv_it=mesh_->cfv_iter(f_it.handle()); fv_it; ++fv_it)
|
||||
glVertex(mesh_->point(fv_it));
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; f_it!=f_end; ++f_it)
|
||||
{
|
||||
glBegin(GL_POLYGON);
|
||||
for (fv_it=mesh_->cfv_iter(f_it.handle()); fv_it; ++fv_it)
|
||||
glVertex(mesh_->point(fv_it));
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh>
|
||||
void
|
||||
SoOpenMeshNodeT<Mesh>::generatePrimitives(SoAction* _action)
|
||||
{
|
||||
if (mesh_)
|
||||
genPrimitives(_action);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template<class Mesh>
|
||||
void
|
||||
SoOpenMeshNodeT<Mesh>::
|
||||
genPrimitives(SoAction* _action, OpenMesh::GenProg::Bool2Type<true>)
|
||||
{
|
||||
typename Mesh::ConstFaceIter f_it(mesh_->faces_begin()),
|
||||
f_end(mesh_->faces_end());
|
||||
|
||||
typename Mesh::ConstFaceVertexIter fv_it;
|
||||
|
||||
|
||||
SoPrimitiveVertex pv;
|
||||
|
||||
beginShape(_action, TRIANGLES);
|
||||
|
||||
for (; f_it!=f_end; ++f_it)
|
||||
{
|
||||
pv.setNormal(sbvec3f(mesh_->normal(f_it)));
|
||||
|
||||
fv_it = mesh_->cfv_iter(f_it.handle());
|
||||
|
||||
pv.setPoint(sbvec3f(mesh_->point(fv_it)));
|
||||
shapeVertex(&pv);
|
||||
++fv_it;
|
||||
|
||||
pv.setPoint(sbvec3f(mesh_->point(fv_it)));
|
||||
shapeVertex(&pv);
|
||||
++fv_it;
|
||||
|
||||
pv.setPoint(sbvec3f(mesh_->point(fv_it)));
|
||||
shapeVertex(&pv);
|
||||
}
|
||||
|
||||
endShape();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template<class Mesh>
|
||||
void
|
||||
SoOpenMeshNodeT<Mesh>::
|
||||
genPrimitives(SoAction* _action, OpenMesh::GenProg::Bool2Type<false>)
|
||||
{
|
||||
typename Mesh::ConstFaceIter f_it(mesh_->faces_begin()),
|
||||
f_end(mesh_->faces_end());
|
||||
|
||||
typename Mesh::ConstFaceVertexIter fv_it;
|
||||
|
||||
SoPrimitiveVertex pv;
|
||||
|
||||
|
||||
for (; f_it!=f_end; ++f_it)
|
||||
{
|
||||
beginShape(_action, POLYGON);
|
||||
|
||||
pv.setNormal(sbvec3f(mesh_->normal(f_it)));
|
||||
|
||||
for (fv_it=mesh_->cfv_iter(f_it.handle()); fv_it; ++fv_it)
|
||||
{
|
||||
pv.setPoint(sbvec3f(mesh_->point(fv_it)));
|
||||
shapeVertex(&pv);
|
||||
}
|
||||
|
||||
endShape();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh>
|
||||
void
|
||||
SoOpenMeshNodeT<Mesh>::computeBBox(SoAction *action,
|
||||
SbBox3f &box,
|
||||
SbVec3f ¢er)
|
||||
{
|
||||
if (mesh_ && mesh_->n_vertices())
|
||||
{
|
||||
typename Mesh::ConstVertexIter vIt(mesh_->vertices_begin());
|
||||
typename Mesh::ConstVertexIter vEnd(mesh_->vertices_end());
|
||||
|
||||
typename Mesh::Point min(mesh_->point(vIt));
|
||||
typename Mesh::Point max(mesh_->point(vIt));
|
||||
|
||||
|
||||
for (++vIt; vIt != vEnd; ++vIt)
|
||||
{
|
||||
max.maximize(mesh_->point(vIt));
|
||||
min.minimize(mesh_->point(vIt));
|
||||
}
|
||||
|
||||
box.setBounds(SbVec3f(min[0],min[1],min[2]),
|
||||
SbVec3f(max[0],max[1],max[2]));
|
||||
}
|
||||
|
||||
else box.setBounds(SbVec3f(0,0,0), SbVec3f(0,0,0));
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
/* As we are using templates, we cannot use the predefined macro
|
||||
SO_NODE_SOURCE to automatically generate the following piece of
|
||||
code. Ugly, but necessary.
|
||||
*/
|
||||
|
||||
template <class Mesh>
|
||||
SoType SoOpenMeshNodeT<Mesh>::classTypeId;
|
||||
|
||||
template <class Mesh>
|
||||
SoFieldData *SoOpenMeshNodeT<Mesh>::fieldData;
|
||||
|
||||
template <class Mesh>
|
||||
const SoFieldData **SoOpenMeshNodeT<Mesh>::parentFieldData;
|
||||
|
||||
template <class Mesh>
|
||||
SbBool SoOpenMeshNodeT<Mesh>::firstInstance = TRUE;
|
||||
|
||||
template <class Mesh>
|
||||
SoType SoOpenMeshNodeT<Mesh>::getTypeId() const {
|
||||
return classTypeId;
|
||||
}
|
||||
|
||||
template <class Mesh>
|
||||
const SoFieldData*
|
||||
SoOpenMeshNodeT<Mesh>::getFieldData() const {
|
||||
SO__NODE_CHECK_CONSTRUCT("SoOpenMeshNodeT");
|
||||
return fieldData;
|
||||
}
|
||||
|
||||
template <class Mesh>
|
||||
void* SoOpenMeshNodeT<Mesh>::createInstance() {
|
||||
return (void *)(new SoOpenMeshNodeT<Mesh>);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SO_NODE_SOURCE(SoOpenMeshNodeT<Mesh>);
|
||||
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
} // namespace OpenMesh
|
||||
//=============================================================================
|
||||
117
Apps/Deprecated/IvViewer/SoOpenMeshNodeT.hh
Normal file
117
Apps/Deprecated/IvViewer/SoOpenMeshNodeT.hh
Normal file
@@ -0,0 +1,117 @@
|
||||
//=============================================================================
|
||||
//
|
||||
// OpenMesh
|
||||
// Copyright (C) 2003 by Computer Graphics Group, RWTH Aachen
|
||||
// www.openmesh.org
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// License
|
||||
//
|
||||
// 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, version 2.1.
|
||||
//
|
||||
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Revision: 1800 $
|
||||
// $Date: 2008-05-19 11:51:23 +0200 (Mo, 19. Mai 2008) $
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Class SoOpenMeshNode
|
||||
//
|
||||
// This class defines an basic inventor node to display an OpenMesh
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#ifndef OPENMESH_SOOPENMESHNODE_HH
|
||||
#define OPENMESH_SOOPENMESHNODE_HH
|
||||
|
||||
|
||||
//== INCLUDES =================================================================
|
||||
|
||||
|
||||
#include <OpenMesh/Core/Utils/GenProg.hh>
|
||||
#include <Inventor/nodes/SoNode.h>
|
||||
#include <Inventor/nodes/SoShape.h>
|
||||
|
||||
//== NAMESPACES ===============================================================
|
||||
|
||||
|
||||
namespace OpenMesh {
|
||||
|
||||
|
||||
//== CLASS DEFINITION =========================================================
|
||||
|
||||
|
||||
template <class Mesh>
|
||||
class SoOpenMeshNodeT : public SoShape
|
||||
{
|
||||
|
||||
SO_NODE_HEADER(SoOpenMeshNodeT<Mesh>);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static void initClass();
|
||||
SoOpenMeshNodeT(const Mesh* _mesh=0);
|
||||
void setMesh(const Mesh* mesh) { d_mesh = mesh; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void GLRender(SoGLRenderAction *action);
|
||||
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
|
||||
virtual void generatePrimitives(SoAction *action);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
virtual ~SoOpenMeshNodeT() {};
|
||||
|
||||
|
||||
// Draw faces as triangles / polygons
|
||||
void drawFaces(bool _send_normals) {
|
||||
typedef typename Mesh::Face Face;
|
||||
drawFaces(_send_normals, typename Face::IsTriangle());
|
||||
}
|
||||
void drawFaces(bool _send_normals, OpenMesh::GenProg::Bool2Type<true>);
|
||||
void drawFaces(bool _send_normals, OpenMesh::GenProg::Bool2Type<false>);
|
||||
|
||||
|
||||
// Generate primitives
|
||||
void genPrimitives(SoAction* _action) {
|
||||
typedef typename Mesh::Face Face;
|
||||
genPrimitives(_action, typename Face::IsTriangle());
|
||||
}
|
||||
void genPrimitives(SoAction* _action, OpenMesh::GenProg::Bool2Type<true>);
|
||||
void genPrimitives(SoAction* _action, OpenMesh::GenProg::Bool2Type<false>);
|
||||
|
||||
|
||||
const Mesh* mesh_;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
} // namespace OpenMesh
|
||||
//=============================================================================
|
||||
#if defined(INCLUDE_TEMPLATES) && !defined(OPENMESH_SOOPENMESHNODE_CC)
|
||||
# define OPENMESH_SOOPENMESHMODE_TEMPLATES
|
||||
# include "SoOpenMeshNodeT.cc"
|
||||
#endif
|
||||
//=============================================================================
|
||||
#endif // OPENMESH_SOOPENMESHNODE_HH
|
||||
//=============================================================================
|
||||
111
Apps/Deprecated/IvViewer/SoOpenMeshSupport.hh
Normal file
111
Apps/Deprecated/IvViewer/SoOpenMeshSupport.hh
Normal file
@@ -0,0 +1,111 @@
|
||||
#ifndef SOOPENMESHSUPPORT_H
|
||||
#define SOOPENMESHSUPPORT_H
|
||||
|
||||
//== REDEFINE DEFINES SO THEY WORK WITH TEMPLATES ============================
|
||||
|
||||
#define SO_NODE_SOURCE_TEMPLATE template <class Mesh>
|
||||
|
||||
// ----------------------------------------------------------------- COIN ----
|
||||
//
|
||||
// define __COIN__ is set by coin headers
|
||||
#ifdef __COIN__
|
||||
|
||||
#ifdef PRIVATE_NODE_TYPESYSTEM_SOURCE
|
||||
# undef PRIVATE_NODE_TYPESYSTEM_SOURCE
|
||||
#endif
|
||||
|
||||
#define PRIVATE_NODE_TYPESYSTEM_SOURCE(_class_) \
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
SoType _class_::getClassTypeId(void) { return _class_::classTypeId; } \
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
SoType _class_::getTypeId(void) const { return _class_::classTypeId; } \
|
||||
/* Don't set value explicitly to SoType::badType(), to avoid a bug in */ \
|
||||
/* Sun CC v4.0. (Bitpattern 0x0000 equals SoType::badType()). */ \
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
SoType _class_::classTypeId
|
||||
|
||||
// FIXME: document. 20000103 mortene.
|
||||
#ifdef SO_NODE_ABSTRACT_SOURCE
|
||||
# undef SO_NODE_ABSTRACT_SOURCE
|
||||
#endif
|
||||
|
||||
#define SO_NODE_ABSTRACT_SOURCE(_class_) \
|
||||
PRIVATE_NODE_TYPESYSTEM_SOURCE(_class_); \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
unsigned int _class_::classinstances = 0; \
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
const SoFieldData ** _class_::parentFieldData = NULL; \
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
SoFieldData * _class_::fieldData = NULL; \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
const SoFieldData ** \
|
||||
_class_::getFieldDataPtr(void) \
|
||||
{ \
|
||||
return (const SoFieldData **)(&_class_::fieldData); \
|
||||
} \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
const SoFieldData * \
|
||||
_class_::getFieldData(void) const \
|
||||
{ \
|
||||
return _class_::fieldData; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FIXME: document. 20000103 mortene.
|
||||
#ifdef SO_NODE_SOURCE
|
||||
# undef SO_NODE_SOURCE
|
||||
#endif
|
||||
#define SO_NODE_SOURCE(_class_) \
|
||||
SO_NODE_ABSTRACT_SOURCE(_class_); \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
void * \
|
||||
_class_::createInstance(void) \
|
||||
{ \
|
||||
return new _class_; \
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ SGI ----
|
||||
#else
|
||||
|
||||
#ifdef SO_NODE_SOURCE
|
||||
# undef SO_NODE_SOURCE
|
||||
#endif
|
||||
|
||||
#define SO_NODE_SOURCE(_class_) \
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
SoType _class_::classTypeId; \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
SoFieldData *_class_::fieldData; \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
const SoFieldData **_class_::parentFieldData; \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
SbBool _class_::firstInstance = TRUE; \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
SoType _class_::getTypeId() const { \
|
||||
return classTypeId; \
|
||||
} \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
const SoFieldData* \
|
||||
_class_::getFieldData() const { \
|
||||
SO__NODE_CHECK_CONSTRUCT("SoOpenMeshNodeT"); \
|
||||
return fieldData; \
|
||||
} \
|
||||
\
|
||||
SO_NODE_SOURCE_TEMPLATE \
|
||||
void* _class_::createInstance() { \
|
||||
return (void *)(new _class_); \
|
||||
} \
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
140
Apps/Deprecated/IvViewer/ivviewer.cc
Normal file
140
Apps/Deprecated/IvViewer/ivviewer.cc
Normal file
@@ -0,0 +1,140 @@
|
||||
//=============================================================================
|
||||
//
|
||||
// OpenMesh
|
||||
// Copyright (C) 2003 by Computer Graphics Group, RWTH Aachen
|
||||
// www.openmesh.org
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// License
|
||||
//
|
||||
// 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, version 2.1.
|
||||
//
|
||||
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Revision: 4483 $
|
||||
// $Date: 2009-01-28 11:41:31 +0100 (Mi, 28. Jan 2009) $
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
//
|
||||
|
||||
#if !defined(USE_SOQT)
|
||||
# define USE_SOQT 0
|
||||
#endif
|
||||
|
||||
//== INCLUDES =================================================================
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
//
|
||||
// Attention! must include this before including inventor files!
|
||||
// There some dependencies not solved yet!
|
||||
#include <OpenMesh/Core/IO/MeshIO.hh>
|
||||
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
|
||||
//
|
||||
#include <Inventor/SoDB.h>
|
||||
#if USE_SOQT
|
||||
# include <qapplication.h>
|
||||
# include <Inventor/Qt/SoQt.h>
|
||||
# include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
|
||||
#else
|
||||
# include <Inventor/Xt/SoXt.h>
|
||||
# include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
|
||||
#endif
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
//
|
||||
#include <OpenMesh/Apps/IvViewer/SoOpenMeshNodeT.hh>
|
||||
|
||||
|
||||
//== CLASS DEFINITION =========================================================
|
||||
|
||||
|
||||
struct MyTraits : public OpenMesh::DefaultTraits
|
||||
{
|
||||
VertexAttributes(OpenMesh::Attributes::Normal);
|
||||
HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge);
|
||||
FaceAttributes(OpenMesh::Attributes::Normal);
|
||||
};
|
||||
|
||||
|
||||
typedef OpenMesh::TriMesh_ArrayKernelT<MyTraits> MyMesh;
|
||||
typedef OpenMesh::SoOpenMeshNodeT<MyMesh> MyNode;
|
||||
|
||||
|
||||
|
||||
//== IMPLEMENTATION ===========================================================
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
OpenMesh::IO::Options opt;
|
||||
|
||||
#if USE_SOQT
|
||||
QApplication app(argc,argv);
|
||||
|
||||
SoQt::init( argv[0] );
|
||||
|
||||
MyNode::initClass();
|
||||
SoQtExaminerViewer *myViewer = new SoQtExaminerViewer();
|
||||
|
||||
|
||||
// Read a mesh
|
||||
MyMesh mesh;
|
||||
if (argc > 1 && OpenMesh::IO::read_mesh(mesh, argv[1], opt))
|
||||
{
|
||||
if (!opt.check( OpenMesh::IO::Options::FaceNormal))
|
||||
mesh.update_face_normals();
|
||||
|
||||
SoSeparator* root = new SoSeparator();
|
||||
root->addChild(new MyNode(&mesh));
|
||||
|
||||
myViewer->setSceneGraph(root);
|
||||
}
|
||||
|
||||
QObject::connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));
|
||||
|
||||
myViewer->show();
|
||||
SoQt::mainLoop();
|
||||
#else
|
||||
// Inventor stuff
|
||||
Widget myWindow = SoXt::init(argv[0]);
|
||||
MyNode::initClass();
|
||||
SoXtExaminerViewer *myViewer =
|
||||
new SoXtExaminerViewer(myWindow);
|
||||
|
||||
|
||||
|
||||
// Read a mesh
|
||||
MyMesh mesh;
|
||||
if (argc > 1 && OpenMesh::IO::read_mesh(mesh, argv[1], opt))
|
||||
{
|
||||
if (!opt.check( OpenMesh::IO::Options::FaceNormal))
|
||||
mesh.update_face_normals();
|
||||
|
||||
SoSeparator* root = new SoSeparator();
|
||||
root->addChild(new MyNode(&mesh));
|
||||
|
||||
myViewer->setSceneGraph(root);
|
||||
}
|
||||
|
||||
myViewer->show();
|
||||
SoXt::show(myWindow);
|
||||
SoXt::mainLoop();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
Reference in New Issue
Block a user