Corrections of include paths to comply the new folder arrangement of the VCG library (another set of the many filters; cleaning up and removing useless includes)

This commit is contained in:
Paolo Cignoni cignoni 2011-04-04 06:11:19 +00:00
parent 29810ca65d
commit 3965101582
14 changed files with 3984 additions and 4018 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,12 +19,6 @@
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
Revision 1.0 2008/02/20 Alessandro Maione, Federico Bellucci
FIRST RELEASE
****************************************************************************/
#include "qualitymapperdialog.h"
@ -32,8 +26,6 @@ FIRST RELEASE
#include <QPen>
#include <QBrush>
#include <vcg/complex/trimesh/update/color.h>
using namespace vcg;
//returns true if relative x of h1 is < then x of h2.

View File

@ -34,7 +34,7 @@ FIRST RELEASE
#include <QGraphicsItem>
#include <common/meshmodel.h>
#include <vcg/math/histogram.h>
#include <vcg/complex/trimesh/stat.h> // for ComputePerVertexQualityMinMax
#include <vcg/complex/algorithms/stat.h> // for ComputePerVertexQualityMinMax
#include <meshlab/glarea.h>
#include "ui_qualitymapperdialog.h"
#include "common/transferfunction.h"

View File

@ -28,7 +28,7 @@
#include <wrap/gl/pick.h>
#include <wrap/gl/picking.h>
#include <vcg/complex/trimesh/clean.h>
#include <vcg/complex/algorithms/clean.h>
using namespace vcg;

View File

@ -30,7 +30,7 @@
#include "ui_textureeditor.h"
#include "renderarea.h"
#include <vcg/container/simple_temporary_data.h> // da rimuovere una volta spostato smooth
#include <vcg/complex/trimesh/textcoord_optimization.h>
#include <vcg/complex/algorithms/textcoord_optimization.h>
#define MARGIN 5
#define MAXW 1400

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,134 +1,134 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2008 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
#include <QtGui>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <meshlab/meshmodel.h>
#include <meshlab/interfaces.h>
#include <vcg/complex/trimesh/clean.h>
#include <vcg/complex/trimesh/update/normal.h>
#include <vcg/complex/trimesh/update/bounding.h>
#include "filter_topo.h"
#include "../edit_topo/edit_topomeshbuilder.h"
FilterTopoPlugin::FilterTopoPlugin()
{
typeList << FP_RE_TOPO;
foreach(FilterIDType tt , types())
actionList << new QAction(filterName(tt), this);
}
QString FilterTopoPlugin::filterName(FilterIDType filterId)
{
switch(filterId) {
case FP_RE_TOPO : return QString("Create mesh from basic topology");
default : assert(0);
}
}
QString FilterTopoPlugin::filterInfo(FilterIDType filterId)
{
switch(filterId) {
case FP_RE_TOPO : return QString("Creates a new mesh from a basic topology model applied to an high resolution model");
default : assert(0);
}
}
//
// Filter interface start up
//
void FilterTopoPlugin::initParameterSet(QAction *action, MeshDocument & md, RichParameterSet & parlst)
{
MeshModel *target= md.mm();
foreach (target, md.meshList)
if (target != md.mm()) break;
doc = &md;
switch(ID(action)) {
case FP_RE_TOPO :
// Iterations editbox
parlst.addParam(new RichInt( "it",
4,
"Number of refinement iterations used to build the new mesh",
"As higher is this value, as well defined will be the new mesh. Consider that more than 5 iterations may slow down your system"));
// Distance editbox
parlst.addParam(new RichAbsPerc( "dist", 0.3f, 0.01f, 0.99f,
"Incremental distance %",
"This param represents the % distance for the local search algorithm used for new vertices allocation. Generally, 0.25-0.30 is a good value"));
// Topology mesh list
parlst.addParam(new RichMesh( "userMesh", md.mm(),
"Topology mesh",
"This mesh will be used as the new base topology, and will be replaced by the new mesh"));
// Original mesh list
parlst.addParam(new RichMesh( "inMesh", target,
"Original mesh",
"The new mesh will be elaborated using this model"));
break;
default : assert(0);
}
}
//
// Apply filter
//
bool FilterTopoPlugin::applyFilter(QAction *filter, MeshModel &m, RichParameterSet & par, vcg::CallBackPos *cb)
{
// To run the retopology algorithm an istance of RetopoMeshBuilder is needed
RetopMeshBuilder rm;
// Load topology mesh
MeshModel *userMesh = par.getMesh("userMesh");
// Load (input) original mesh
MeshModel *inMesh = par.getMesh("inMesh");
// Load iterations value
int it = par.getInt("it");
// Load distance value
float dist = par.getAbsPerc("dist");
// Destination meshmodel: retopology mesh will replace flat topology mesh
MeshModel * outM = par.getMesh("userMesh");
// Prepare mesh
inMesh->updateDataMask(MeshModel::MM_FACEMARK);
tri::UpdateNormals<CMeshO>::PerFaceNormalized(inMesh->cm);
tri::UpdateFlags<CMeshO>::FaceProjection(inMesh->cm);
// Init the retopology builder with original input mesh and distance value
rm.init(inMesh, dist);
// Apply the algorithm
return rm.applyTopoMesh(*userMesh, *inMesh, it, dist, *outM);
}
Q_EXPORT_PLUGIN(FilterTopoPlugin)
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2008 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
#include <QtGui>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <meshlab/meshmodel.h>
#include <meshlab/interfaces.h>
#include <vcg/complex/algorithms/clean.h>
#include <vcg/complex/algorithms/update/normal.h>
#include <vcg/complex/algorithms/update/bounding.h>
#include "filter_topo.h"
#include "../edit_topo/edit_topomeshbuilder.h"
FilterTopoPlugin::FilterTopoPlugin()
{
typeList << FP_RE_TOPO;
foreach(FilterIDType tt , types())
actionList << new QAction(filterName(tt), this);
}
QString FilterTopoPlugin::filterName(FilterIDType filterId)
{
switch(filterId) {
case FP_RE_TOPO : return QString("Create mesh from basic topology");
default : assert(0);
}
}
QString FilterTopoPlugin::filterInfo(FilterIDType filterId)
{
switch(filterId) {
case FP_RE_TOPO : return QString("Creates a new mesh from a basic topology model applied to an high resolution model");
default : assert(0);
}
}
//
// Filter interface start up
//
void FilterTopoPlugin::initParameterSet(QAction *action, MeshDocument & md, RichParameterSet & parlst)
{
MeshModel *target= md.mm();
foreach (target, md.meshList)
if (target != md.mm()) break;
doc = &md;
switch(ID(action)) {
case FP_RE_TOPO :
// Iterations editbox
parlst.addParam(new RichInt( "it",
4,
"Number of refinement iterations used to build the new mesh",
"As higher is this value, as well defined will be the new mesh. Consider that more than 5 iterations may slow down your system"));
// Distance editbox
parlst.addParam(new RichAbsPerc( "dist", 0.3f, 0.01f, 0.99f,
"Incremental distance %",
"This param represents the % distance for the local search algorithm used for new vertices allocation. Generally, 0.25-0.30 is a good value"));
// Topology mesh list
parlst.addParam(new RichMesh( "userMesh", md.mm(),
"Topology mesh",
"This mesh will be used as the new base topology, and will be replaced by the new mesh"));
// Original mesh list
parlst.addParam(new RichMesh( "inMesh", target,
"Original mesh",
"The new mesh will be elaborated using this model"));
break;
default : assert(0);
}
}
//
// Apply filter
//
bool FilterTopoPlugin::applyFilter(QAction *filter, MeshModel &m, RichParameterSet & par, vcg::CallBackPos *cb)
{
// To run the retopology algorithm an istance of RetopoMeshBuilder is needed
RetopMeshBuilder rm;
// Load topology mesh
MeshModel *userMesh = par.getMesh("userMesh");
// Load (input) original mesh
MeshModel *inMesh = par.getMesh("inMesh");
// Load iterations value
int it = par.getInt("it");
// Load distance value
float dist = par.getAbsPerc("dist");
// Destination meshmodel: retopology mesh will replace flat topology mesh
MeshModel * outM = par.getMesh("userMesh");
// Prepare mesh
inMesh->updateDataMask(MeshModel::MM_FACEMARK);
tri::UpdateNormals<CMeshO>::PerFaceNormalized(inMesh->cm);
tri::UpdateFlags<CMeshO>::FaceProjection(inMesh->cm);
// Init the retopology builder with original input mesh and distance value
rm.init(inMesh, dist);
// Apply the algorithm
return rm.applyTopoMesh(*userMesh, *inMesh, it, dist, *outM);
}
Q_EXPORT_PLUGIN(FilterTopoPlugin)

View File

@ -1,195 +1,195 @@
#ifndef SAMPLER_H
#define SAMPLER_H
#include "stages.h"
#include <vcg/complex/trimesh/allocate.h>
#include <vcg/complex/trimesh/update/bounding.h>
#include <common/meshmodel.h>
#include <QTime>
namespace vs
{
class SamplerListener
{
public:
virtual void startingSetup ( void ) = 0;
virtual void setupComplete ( int povs ) = 0;
virtual void povProcessed ( int pov, int samples ) = 0;
virtual void startingFeatureSampling ( void ) = 0;
};
template< class MeshType >
class Sampler
{
public:
typedef typename MeshType::VertexIterator VertexIterator;
typedef typename MeshType::CoordType CoordType;
static void generateSamples
( VSParameters* params,
MeshModel* inputMeshModel,
MeshType* uniformSamplesMesh,
MeshType* featureSamplesMesh,
SamplerListener* listener = 0 )
{
if( listener ){ listener->startingSetup(); }
// OpenGL initialization
GLenum err = glGetError();
if( err != GL_NO_ERROR )
{
const GLubyte* errStr = gluErrorString( err );
qDebug( "OpenGL error: %s", (const char*)errStr );
assert( 0 );
}
glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
glEnable( GL_DEPTH_TEST );
glEnable( GL_TEXTURE_2D );
// prepare input/output mesh
vcg::tri::UpdateBounding< CMeshO >::Box( inputMeshModel->cm );
uniformSamplesMesh->Clear();
featureSamplesMesh->Clear();
// initializes resources
Resources resources( params );
resources.initialize();
resources.fbo->bind();
// builds stages
AttributesExtractor extractor ( inputMeshModel, &resources );
ConeFilter coneFilter ( &resources );
Compactor inputCompactor ( &resources, "out_mask", "input_", "best_" );
Killer killer ( &resources );
MaskUpdater maskUpdater ( &resources );
Compactor povCompactor ( &resources, "pov_alive_mask", "input_", "current_best_" );
Compactor deadsCompactor ( &resources, "killer_map", "dead_map", "compacted_deads", true );
DeadMasker deadMasker ( &resources );
AliveMasker aliveMasker ( &resources );
Compactor aliveCompactor ( &resources, "alive_mask", "best_", "alive_" );
FinalCompactor finalCompactor ( &resources );
FeatureDetector detector ( &resources );
GLint* samplesCount = &( resources.buffers[ "best_position" ]->elements );
if( listener ){ listener->setupComplete( resources.params->povs ); }
// *** sampling ***
for( int i=0; i<2; i++ )
{
if( i==1 )
{
if( listener ){ listener->startingFeatureSampling(); }
resources.changeResolution();
extractor.currentPov = 0;
}
// first pov
extractor.go();
if( i==0 ){ coneFilter.go(); }else{ detector.go(); }
inputCompactor.go();
if( listener ){ listener->povProcessed( 1, *samplesCount ); }
// subsequent povs
while( extractor.nextPov() )
{
extractor.go();
if( i==0 )
{
coneFilter.go();
}
else
{
detector.go();
}
killer.go();
maskUpdater.go();
povCompactor.go();
deadsCompactor.go();
deadMasker.go();
aliveMasker.go();
aliveCompactor.go();
finalCompactor.go();
if( listener ){ listener->povProcessed( extractor.currentPov + 1, *samplesCount ); }
}
// download samples
downloadSamples( &resources, (i==0)? uniformSamplesMesh : featureSamplesMesh );
}
// ****************
// finalize resources
resources.fbo->unbind();
resources.finalize();
err = glGetError();
if( err != GL_NO_ERROR )
{
const GLubyte* errStr = gluErrorString( err );
qDebug( "OpenGL error: %s", (const char*)errStr );
assert( 0 );
}
}
private:
static void downloadSamples( Resources* resources, MeshType* target )
{
// download samples from the gpu
PixelData* position = resources->buffers[ "best_position" ];
PixelData* normal = resources->buffers[ "best_normal" ];
PixelData* color = resources->buffers[ "best_color" ];
GLfloat* pos = position->download();
GLfloat* nrm = normal->download();
GLfloat* col = color->download();
GLfloat* posPix = pos;
GLfloat* nrmPix = nrm;
GLfloat* colPix = col;
// append samples to output mesh
int samples = position->elements;
VertexIterator vi = vcg::tri::Allocator< MeshType >::AddVertices( *target, samples );
while( vi != target->vert.end() )
{
(*vi).P() = CoordType( posPix[0], posPix[1], posPix[2] );
posPix = &(posPix[3]);
(*vi).N() = CoordType( nrmPix[0], nrmPix[1], nrmPix[2] );
nrmPix = &(nrmPix[3]);
for( int i=0; i<3; i++ )
{
(*vi).C()[i] = (unsigned char)( colPix[i] * 255 );
}
(*vi).C()[3] = (unsigned char)255;
colPix = &( colPix[3] );
vi++;
}
// free downloaded samples
free( pos );
free( nrm );
free( col );
// re-compute bounding box
vcg::tri::UpdateBounding< MeshType >::Box( *target );
}
};
}
#endif // SAMPLER_H
#ifndef SAMPLER_H
#define SAMPLER_H
#include "stages.h"
#include <vcg/complex/allocate.h>
#include <vcg/complex/algorithms/update/bounding.h>
#include <common/meshmodel.h>
#include <QTime>
namespace vs
{
class SamplerListener
{
public:
virtual void startingSetup ( void ) = 0;
virtual void setupComplete ( int povs ) = 0;
virtual void povProcessed ( int pov, int samples ) = 0;
virtual void startingFeatureSampling ( void ) = 0;
};
template< class MeshType >
class Sampler
{
public:
typedef typename MeshType::VertexIterator VertexIterator;
typedef typename MeshType::CoordType CoordType;
static void generateSamples
( VSParameters* params,
MeshModel* inputMeshModel,
MeshType* uniformSamplesMesh,
MeshType* featureSamplesMesh,
SamplerListener* listener = 0 )
{
if( listener ){ listener->startingSetup(); }
// OpenGL initialization
GLenum err = glGetError();
if( err != GL_NO_ERROR )
{
const GLubyte* errStr = gluErrorString( err );
qDebug( "OpenGL error: %s", (const char*)errStr );
assert( 0 );
}
glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
glEnable( GL_DEPTH_TEST );
glEnable( GL_TEXTURE_2D );
// prepare input/output mesh
vcg::tri::UpdateBounding< CMeshO >::Box( inputMeshModel->cm );
uniformSamplesMesh->Clear();
featureSamplesMesh->Clear();
// initializes resources
Resources resources( params );
resources.initialize();
resources.fbo->bind();
// builds stages
AttributesExtractor extractor ( inputMeshModel, &resources );
ConeFilter coneFilter ( &resources );
Compactor inputCompactor ( &resources, "out_mask", "input_", "best_" );
Killer killer ( &resources );
MaskUpdater maskUpdater ( &resources );
Compactor povCompactor ( &resources, "pov_alive_mask", "input_", "current_best_" );
Compactor deadsCompactor ( &resources, "killer_map", "dead_map", "compacted_deads", true );
DeadMasker deadMasker ( &resources );
AliveMasker aliveMasker ( &resources );
Compactor aliveCompactor ( &resources, "alive_mask", "best_", "alive_" );
FinalCompactor finalCompactor ( &resources );
FeatureDetector detector ( &resources );
GLint* samplesCount = &( resources.buffers[ "best_position" ]->elements );
if( listener ){ listener->setupComplete( resources.params->povs ); }
// *** sampling ***
for( int i=0; i<2; i++ )
{
if( i==1 )
{
if( listener ){ listener->startingFeatureSampling(); }
resources.changeResolution();
extractor.currentPov = 0;
}
// first pov
extractor.go();
if( i==0 ){ coneFilter.go(); }else{ detector.go(); }
inputCompactor.go();
if( listener ){ listener->povProcessed( 1, *samplesCount ); }
// subsequent povs
while( extractor.nextPov() )
{
extractor.go();
if( i==0 )
{
coneFilter.go();
}
else
{
detector.go();
}
killer.go();
maskUpdater.go();
povCompactor.go();
deadsCompactor.go();
deadMasker.go();
aliveMasker.go();
aliveCompactor.go();
finalCompactor.go();
if( listener ){ listener->povProcessed( extractor.currentPov + 1, *samplesCount ); }
}
// download samples
downloadSamples( &resources, (i==0)? uniformSamplesMesh : featureSamplesMesh );
}
// ****************
// finalize resources
resources.fbo->unbind();
resources.finalize();
err = glGetError();
if( err != GL_NO_ERROR )
{
const GLubyte* errStr = gluErrorString( err );
qDebug( "OpenGL error: %s", (const char*)errStr );
assert( 0 );
}
}
private:
static void downloadSamples( Resources* resources, MeshType* target )
{
// download samples from the gpu
PixelData* position = resources->buffers[ "best_position" ];
PixelData* normal = resources->buffers[ "best_normal" ];
PixelData* color = resources->buffers[ "best_color" ];
GLfloat* pos = position->download();
GLfloat* nrm = normal->download();
GLfloat* col = color->download();
GLfloat* posPix = pos;
GLfloat* nrmPix = nrm;
GLfloat* colPix = col;
// append samples to output mesh
int samples = position->elements;
VertexIterator vi = vcg::tri::Allocator< MeshType >::AddVertices( *target, samples );
while( vi != target->vert.end() )
{
(*vi).P() = CoordType( posPix[0], posPix[1], posPix[2] );
posPix = &(posPix[3]);
(*vi).N() = CoordType( nrmPix[0], nrmPix[1], nrmPix[2] );
nrmPix = &(nrmPix[3]);
for( int i=0; i<3; i++ )
{
(*vi).C()[i] = (unsigned char)( colPix[i] * 255 );
}
(*vi).C()[3] = (unsigned char)255;
colPix = &( colPix[3] );
vi++;
}
// free downloaded samples
free( pos );
free( nrm );
free( col );
// re-compute bounding box
vcg::tri::UpdateBounding< MeshType >::Box( *target );
}
};
}
#endif // SAMPLER_H

View File

@ -1,210 +1,210 @@
#ifndef SIMPLE_RENDERER_H
#define SIMPLE_RENDERER_H
#include <GL/glew.h>
#include <vcg/space/point3.h>
#include <vcg/complex/trimesh/base.h>
#include <vcg/complex/trimesh/update/flag.h>
#include <vcg/complex/trimesh/update/color.h>
#include <wrap/gl/trimesh.h>
#include "assert.h"
#include <Qt>
#include <map>
namespace vs
{
template< class MeshType >
class SimpleRenderer
{
public:
SimpleRenderer( MeshType* m )
{
assert(m && m->vert.size() > 0 && m->face.size() > 0 );
this->m = m;
this->buffersOk = false;
//createBuffers();
}
~SimpleRenderer( void )
{
//glDeleteBuffers( 4, buffer );
}
void render( void )
{
/*
for( int i=0; i<4; i++ )
{
assert( glIsBuffer( buffer[i] ) == GL_TRUE );
}
glBindBuffer( GL_ARRAY_BUFFER, buffer[0] ); // coordinates
glVertexPointer( (GLint)3, GL_FLOAT, 0, 0 );
glEnableClientState( GL_VERTEX_ARRAY );
glBindBuffer( GL_ARRAY_BUFFER, buffer[1] ); // normals
glNormalPointer( GL_FLOAT, 0, 0 );
glEnableClientState( GL_NORMAL_ARRAY );
glBindBuffer( GL_ARRAY_BUFFER, buffer[2] ); // colors
glColorPointer( (GLint)4, GL_UNSIGNED_BYTE, 0, 0 );
glEnableClientState( GL_COLOR_ARRAY );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, buffer[3] ); // indices
glDrawElements( GL_TRIANGLES, elementsToDraw, GL_UNSIGNED_INT, 0 );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
*/
// immediate-mode rendering
if( m->vert.size() == 0 ) return;
typename MeshType::FaceIterator fi;
int i = 0;
vcg::Point3f* pp = 0;
vcg::Point3f* np = 0;
glBegin( GL_TRIANGLES );
for( fi = m->face.begin(); fi != m->face.end(); ++fi )
{
for( i = 0; i < 3; i++ )
{
np = &( (*fi).V(i)->N() );
glNormal3f( np->X(), np->Y(), np->Z() );
pp = &( (*fi).V(i)->P() );
glVertex3f( pp->X(), pp->Y(), pp->Z() );
}
}
glEnd();
}
private:
typedef typename MeshType::VertexIterator VertexIterator;
typedef typename MeshType::VertexType VertexType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::FaceIterator FaceIterator;
typedef typename MeshType::ScalarType ScalarType;
MeshType* m;
GLuint buffer[4]; // coords, normals, colors, indices
GLsizei elementsToDraw; // 3 * face_number
bool buffersOk; // true => use vbo's
// create the buffer objects to hold mesh data
void createBuffers( void )
{
assert( glGetError() == GL_NO_ERROR );
glGenBuffers( 4, buffer );
// prepare buffers
size_t scalarTypeSize = sizeof( ScalarType ); // size of scalar type
size_t vertexSize = 3 * scalarTypeSize; // size of a vertex
size_t verticesSize = m->vn * vertexSize; // size of vertices
void* vData = malloc( verticesSize ); // vertices buffer
void* nData = malloc( verticesSize ); // normals buffer
assert( vData && nData );
// assume that the color type is Color4b
size_t colorSize = 4 * m->vn;
void* cData = malloc( colorSize );
assert( cData );
bool perVertexColor = m->HasPerVertexColor();
// if per-vertex color is not available, we use per-mesh color
vcg::Color4b defaultColor = m->C();
ScalarType* vP = (ScalarType*)vData;
ScalarType* nP = (ScalarType*)nData;
unsigned char* cP = (unsigned char*)cData;
map< VertexPointer, unsigned int >* ptrToInt = new map< VertexPointer, unsigned int >();
unsigned int vertexIndex = 0;
for( VertexIterator vi = m->vert.begin(); vi != m->vert.end(); ++vi )
{
for( int i=0; i<3; i++ )
{
vP[i] = (*vi).P()[i];
nP[i] = (*vi).N()[i];
}
for( int i=0; i<4; i++ )
{
cP[i] = (perVertexColor? (*vi).C()[i] : defaultColor[i] );
}
vP = &( vP[3] );
nP = &( nP[3] );
cP = &( cP[4] );
(*ptrToInt)[ &(*vi) ] = vertexIndex;
vertexIndex++;
}
// fills coordinates buffer
glBindBuffer( GL_ARRAY_BUFFER, buffer[0] );
glBufferData( GL_ARRAY_BUFFER, verticesSize, vData, GL_STATIC_DRAW );
glVertexPointer( (GLint)3, GL_FLOAT, 0, 0 );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
free( vData );
assert( glGetError() == GL_NO_ERROR );
// fills normals buffer
glBindBuffer( GL_ARRAY_BUFFER, buffer[1] );
glBufferData( GL_ARRAY_BUFFER, verticesSize, nData, GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
free( nData );
assert( glGetError() == GL_NO_ERROR );
// fills colors buffer
glBindBuffer( GL_ARRAY_BUFFER, buffer[2] );
glBufferData( GL_ARRAY_BUFFER, colorSize, cData, GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
free( cData );
assert( glGetError() == GL_NO_ERROR );
// prepare indices buffer
elementsToDraw = (GLsizei)( m->fn * 3 ); // every face has three indices
size_t indicesSize = ((size_t)elementsToDraw) * sizeof(unsigned int);
void* iData = malloc( indicesSize );
assert( iData );
unsigned int* iP = (unsigned int*)iData;
for( FaceIterator fi = m->face.begin(); fi != m->face.end(); ++fi )
{
for( unsigned int i = 0; i < 3; i++ )
{
iP[ i ] = (*ptrToInt)[ (*fi).V(i) ];
}
iP = &( iP[3] );
}
// fills indices buffer
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, buffer[3] );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, indicesSize, iData, GL_STATIC_DRAW );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
free( iData );
delete ptrToInt;
assert( glGetError() == GL_NO_ERROR );
}
};
}
#endif // SIMPLE_RENDERER_H
#ifndef SIMPLE_RENDERER_H
#define SIMPLE_RENDERER_H
#include <GL/glew.h>
#include <vcg/space/point3.h>
#include <vcg/complex/complex.h>
#include <vcg/complex/algorithms/update/flag.h>
#include <vcg/complex/algorithms/update/color.h>
#include <wrap/gl/trimesh.h>
#include "assert.h"
#include <Qt>
#include <map>
namespace vs
{
template< class MeshType >
class SimpleRenderer
{
public:
SimpleRenderer( MeshType* m )
{
assert(m && m->vert.size() > 0 && m->face.size() > 0 );
this->m = m;
this->buffersOk = false;
//createBuffers();
}
~SimpleRenderer( void )
{
//glDeleteBuffers( 4, buffer );
}
void render( void )
{
/*
for( int i=0; i<4; i++ )
{
assert( glIsBuffer( buffer[i] ) == GL_TRUE );
}
glBindBuffer( GL_ARRAY_BUFFER, buffer[0] ); // coordinates
glVertexPointer( (GLint)3, GL_FLOAT, 0, 0 );
glEnableClientState( GL_VERTEX_ARRAY );
glBindBuffer( GL_ARRAY_BUFFER, buffer[1] ); // normals
glNormalPointer( GL_FLOAT, 0, 0 );
glEnableClientState( GL_NORMAL_ARRAY );
glBindBuffer( GL_ARRAY_BUFFER, buffer[2] ); // colors
glColorPointer( (GLint)4, GL_UNSIGNED_BYTE, 0, 0 );
glEnableClientState( GL_COLOR_ARRAY );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, buffer[3] ); // indices
glDrawElements( GL_TRIANGLES, elementsToDraw, GL_UNSIGNED_INT, 0 );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
*/
// immediate-mode rendering
if( m->vert.size() == 0 ) return;
typename MeshType::FaceIterator fi;
int i = 0;
vcg::Point3f* pp = 0;
vcg::Point3f* np = 0;
glBegin( GL_TRIANGLES );
for( fi = m->face.begin(); fi != m->face.end(); ++fi )
{
for( i = 0; i < 3; i++ )
{
np = &( (*fi).V(i)->N() );
glNormal3f( np->X(), np->Y(), np->Z() );
pp = &( (*fi).V(i)->P() );
glVertex3f( pp->X(), pp->Y(), pp->Z() );
}
}
glEnd();
}
private:
typedef typename MeshType::VertexIterator VertexIterator;
typedef typename MeshType::VertexType VertexType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::FaceIterator FaceIterator;
typedef typename MeshType::ScalarType ScalarType;
MeshType* m;
GLuint buffer[4]; // coords, normals, colors, indices
GLsizei elementsToDraw; // 3 * face_number
bool buffersOk; // true => use vbo's
// create the buffer objects to hold mesh data
void createBuffers( void )
{
assert( glGetError() == GL_NO_ERROR );
glGenBuffers( 4, buffer );
// prepare buffers
size_t scalarTypeSize = sizeof( ScalarType ); // size of scalar type
size_t vertexSize = 3 * scalarTypeSize; // size of a vertex
size_t verticesSize = m->vn * vertexSize; // size of vertices
void* vData = malloc( verticesSize ); // vertices buffer
void* nData = malloc( verticesSize ); // normals buffer
assert( vData && nData );
// assume that the color type is Color4b
size_t colorSize = 4 * m->vn;
void* cData = malloc( colorSize );
assert( cData );
bool perVertexColor = m->HasPerVertexColor();
// if per-vertex color is not available, we use per-mesh color
vcg::Color4b defaultColor = m->C();
ScalarType* vP = (ScalarType*)vData;
ScalarType* nP = (ScalarType*)nData;
unsigned char* cP = (unsigned char*)cData;
map< VertexPointer, unsigned int >* ptrToInt = new map< VertexPointer, unsigned int >();
unsigned int vertexIndex = 0;
for( VertexIterator vi = m->vert.begin(); vi != m->vert.end(); ++vi )
{
for( int i=0; i<3; i++ )
{
vP[i] = (*vi).P()[i];
nP[i] = (*vi).N()[i];
}
for( int i=0; i<4; i++ )
{
cP[i] = (perVertexColor? (*vi).C()[i] : defaultColor[i] );
}
vP = &( vP[3] );
nP = &( nP[3] );
cP = &( cP[4] );
(*ptrToInt)[ &(*vi) ] = vertexIndex;
vertexIndex++;
}
// fills coordinates buffer
glBindBuffer( GL_ARRAY_BUFFER, buffer[0] );
glBufferData( GL_ARRAY_BUFFER, verticesSize, vData, GL_STATIC_DRAW );
glVertexPointer( (GLint)3, GL_FLOAT, 0, 0 );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
free( vData );
assert( glGetError() == GL_NO_ERROR );
// fills normals buffer
glBindBuffer( GL_ARRAY_BUFFER, buffer[1] );
glBufferData( GL_ARRAY_BUFFER, verticesSize, nData, GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
free( nData );
assert( glGetError() == GL_NO_ERROR );
// fills colors buffer
glBindBuffer( GL_ARRAY_BUFFER, buffer[2] );
glBufferData( GL_ARRAY_BUFFER, colorSize, cData, GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
free( cData );
assert( glGetError() == GL_NO_ERROR );
// prepare indices buffer
elementsToDraw = (GLsizei)( m->fn * 3 ); // every face has three indices
size_t indicesSize = ((size_t)elementsToDraw) * sizeof(unsigned int);
void* iData = malloc( indicesSize );
assert( iData );
unsigned int* iP = (unsigned int*)iData;
for( FaceIterator fi = m->face.begin(); fi != m->face.end(); ++fi )
{
for( unsigned int i = 0; i < 3; i++ )
{
iP[ i ] = (*ptrToInt)[ (*fi).V(i) ];
}
iP = &( iP[3] );
}
// fills indices buffer
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, buffer[3] );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, indicesSize, iData, GL_STATIC_DRAW );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
free( iData );
delete ptrToInt;
assert( glGetError() == GL_NO_ERROR );
}
};
}
#endif // SIMPLE_RENDERER_H

View File

@ -22,17 +22,7 @@
****************************************************************************/
#include "editpaint.h"
#include <QtGui>
#include <GL/glew.h>
#include <cmath>
#include <cstdlib>
#include <meshlab/glarea.h>
#include <vcg/complex/trimesh/update/bounding.h>
#include <vcg/complex/trimesh/update/normal.h>
#include <vcg/complex/trimesh/update/color.h>
#include <vcg/complex/trimesh/update/topology.h>
#include <wrap/io_trimesh/io_mask.h>
#include <vcg/math/perlin_noise.h>
using namespace std;

View File

@ -22,18 +22,12 @@
****************************************************************************/
/* Standard includes */
#include <map>
#include <vector>
/* Local includes */
#include "filter_aging.h"
using namespace vcg;
/* VCG includes */
#include <vcg/complex/trimesh/update/curvature.h>
#include <vcg/complex/trimesh/stat.h>
#include <vcg/complex/trimesh/clean.h>
#include <vcg/complex/trimesh/smooth.h>
#include <vcg/complex/algorithms/update/curvature.h>
#include <vcg/complex/algorithms/stat.h>
#include <vcg/complex/algorithms/smooth.h>
#include <vcg/math/perlin_noise.h>

View File

@ -25,11 +25,8 @@
#ifndef GEOMETRYAGINGPLUGIN_H
#define GEOMETRYAGINGPLUGIN_H
#include <QObject>
#include <common/interfaces.h>
#include <vcg/complex/trimesh/refine.h>
#include <vcg/complex/algorithms/refine.h>
#include <vcg/space/index/grid_static_ptr.h>
#include "edgepred.h"