Commit 14baf27c authored by Maire Nicolas's avatar Maire Nicolas

Merge branch 'master' of cgogn:~cgogn/CGoGN

parents 268227cb 8643542f
......@@ -23,6 +23,7 @@
*******************************************************************************/
#include "stage_shader.h"
#include "Utils/static_assert.h"
/*******************************************************************************
* SLOTS
......
......@@ -13,6 +13,14 @@ find_package(OpenGL REQUIRED)
find_package(Qt4 REQUIRED)
find_package(GLUT)
IF (DEFINED ASSERTON)
add_definitions(-DCGOGN_ASSERT_BOOL=${ASSERTON})
ELSE (DEFINED ASSERTON)
add_definitions(-DCGOGN_ASSERT_BOOL=false)
ENDIF (DEFINED ASSERTON)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
# qq definition specifiques pour mac
IF(APPLE)
# attention a changer pour chercher la bonne version automatiquement
......
......@@ -78,8 +78,6 @@ add_library(
# ${files_geometry}
#)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
add_definitions(-DDBG_MAX_LEVEL=5)
file(
GLOB_RECURSE
......
......@@ -80,8 +80,6 @@ add_library(
# ${files_geometry}
#)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
add_definitions(-DDBG_MAX_LEVEL=0)
file(
GLOB_RECURSE
......
......@@ -73,7 +73,12 @@ template <typename PFP>
bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good = SelectorTrue()) ;
/**
* export the map into a PLYPTM file
* export the map into a PLYPTMgeneric file (K. Vanhoey generic format).
*
* exports position + any attribute named : "frame_T" (frame tangent : VEC3), "frame_B" (frame binormal : VEC3), "frame_N" (frame normal : VEC3),
* "colorPTM_a<i> : VEC3" (coefficient number i of the 3 polynomials - one per channel - ; the max i depends on the degree of the PTM polynomial),
* "errL2 : REAL" (L2 fitting error), "errLmax : REAL" (maximal fitting error), "stdDev : REAL" (standard deviation of the L2 fitting errors).
*
* @param map map to be exported
* @param filename filename of ply file
* @param position the position container
......@@ -82,6 +87,17 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position,
template <typename PFP>
bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const FunctorSelect& good = SelectorTrue()) ;
/**
* export the map into a PLYPTMgeneric file (K. Vanhoey generic format)
* @param map map to be exported
* @param filename filename of ply file
* @param position the position container
* @param the local frame (3xVEC3 : tangent, bitangent, normal)
* @param colorPTM the 6 coefficients (x3 channels) of the PTM functions
* @return true
*/
template <typename PFP>
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good) ;
/**
* export pout l'InESS
......
This diff is collapsed.
......@@ -548,16 +548,17 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector<
* @param filename the file to import;
* @param attrNames reference that will be filled with the attribute names
* the number of attrNames returned depends on the degree of the polynomials :
* - 1 attrName for geometric position (VEC3)
* - 3 attrNames for local frame (3xVEC3) : Tangent, Bitangent and Normal vector
* - 1 attrName for geometric position (VEC3) : name = "position" ;
* - 3 attrNames for local frame (3xVEC3) : names are "Frame_T" (Tangent), "Frame_B" (Binormal) and "Frame_N" (Normal) ;
* - N attrNames for the function coefficients (NxVEC3) : N RGB coefficients being successively the constants, the linears (v then u), the quadratics, etc. : : a0 + a1*v + a2*u + a3*u*v + a4*v^2 + a5*u^2.
* Their names are : "colorPTM_a<i>" (where <i> is a number from 0 to N-1).
* N = 1 for constant polynomial,
* N = 3 for linear polynomial,
* N = 6 for quadratic polynomial,
* N = 10 for cubic degree polynomial,
* N = 15 for 4th degree polynomial,
* ...
* Hint : N = attrNames.size() - 4 ;
* - K remaining attrNames named "remainderNo<k>" where k is an integer from 0 to K-1.
* @return bool : success.
*/
template <typename PFP>
......@@ -588,13 +589,33 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st
unsigned int nbVertices ;
fp >> nbVertices ; // Read #vertices
unsigned int nbProps = 0 ;
bool position = false ;
bool tangent = false ;
bool binormal = false ;
bool normal = false ;
unsigned int nbProps = 0 ; // # properties
unsigned int nbCoefsPerPol = 0 ; // # coefficients per polynomial
do // go to #faces and count #properties
{
fp >> tag ;
if (tag == std::string("property"))
++nbProps ;
if (tag == std::string("x") || tag == std::string("y") || tag == std::string("z"))
position = true ;
else if (tag == std::string("tx") || tag == std::string("ty") || tag == std::string("tz"))
tangent = true ;
else if (tag == std::string("bx") || tag == std::string("by") || tag == std::string("bz"))
binormal = true ;
else if (tag == std::string("nx") || tag == std::string("ny") || tag == std::string("nz"))
normal = true ;
else if (tag.substr(2,2) == std::string("_a"))
++nbCoefsPerPol ;
} while (tag != std::string("face")) ;
unsigned int nbRemainders = nbProps ; // # remaining properties
nbRemainders -= nbCoefsPerPol + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ;
nbCoefsPerPol /= 3 ;
fp >> m_nbFaces ; // Read #vertices
do // go to end of header
......@@ -602,8 +623,6 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st
fp >> tag ;
} while (tag != std::string("end_header")) ;
unsigned int nbCoefsPerPol = (nbProps - 12) / 3 ; // get #coefficients per polynomial
// Define containers
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
if (!positions.isValid())
......@@ -627,6 +646,15 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st
attrNames.push_back(colorPTM[i].name()) ;
}
AttributeHandler<typename PFP::REAL> *remainders = new AttributeHandler<typename PFP::REAL>[nbRemainders] ;
for (unsigned int i = 0 ; i < nbRemainders ; ++i)
{
std::stringstream name ;
name << "remainderNo" << i ;
remainders[i] = m_map.template addAttribute<typename PFP::REAL>(VERTEX, name.str()) ;
attrNames.push_back(remainders[i].name()) ;
}
// Read vertices
std::vector<unsigned int> verticesID ;
verticesID.reserve(nbVertices) ;
......@@ -648,6 +676,9 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st
for (unsigned int k = 0 ; k < 3 ; ++k) // coefficients
for (unsigned int l = 0 ; l < nbCoefsPerPol ; ++l)
colorPTM[l][id][k] = properties[12+(nbCoefsPerPol*k+l)] ;
unsigned int cur = 12+3*nbCoefsPerPol ;
for (unsigned int k = 0 ; k < nbRemainders ; ++k) // remaining data
remainders[k][id] = properties[cur + k] ;
}
m_nbVertices = verticesID.size() ;
delete[] properties ;
......
......@@ -32,6 +32,7 @@ namespace Algo
namespace Import
{
template <typename PFP>
bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor)
{
......@@ -177,19 +178,18 @@ bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector<
//Association des phi3
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
std::vector<Dart>& vec = vecDartsPerVertex[d];
for(typename std::vector<Dart>::iterator it = vec.begin(); it!=vec.end(); ++it)
const std::vector<Dart>& vec = vecDartsPerVertex[d];
for(typename std::vector<Dart>::const_iterator it = vec.begin(); it!=vec.end(); ++it)
{
if(map.phi3(*it) == *it)
{
bool sewn = false;
for(typename std::vector<Dart>::iterator itnext = it+1; itnext != vec.end() && !sewn; ++itnext)
for(typename std::vector<Dart>::const_iterator itnext = it+1; itnext != vec.end() && !sewn; ++itnext)
{
if(map.getEmbedding(VERTEX,map.phi1(*it))==map.getEmbedding(VERTEX,map.phi_1(*itnext))
&& map.getEmbedding(VERTEX,map.phi_1(*it))==map.getEmbedding(VERTEX,map.phi1(*itnext)))
{
map.sewVolumes(*it, map.phi_1(*itnext));
map.PFP::MAP::TOPO_MAP::sewVolumes(*it, map.phi_1(*itnext));
sewn = true;
}
}
......
......@@ -28,6 +28,7 @@
#include <GL/glew.h>
#include <vector>
#include <list>
#include <utility>
#include "Topology/generic/dart.h"
#include "Topology/generic/functor.h"
......@@ -67,7 +68,8 @@ enum bufferIndex
POINT_INDICES = 0,
LINE_INDICES = 1,
TRIANGLE_INDICES = 2,
FLAT_BUFFER = 3
FLAT_BUFFER = 3,
SIZE_BUFFER
} ;
......@@ -78,12 +80,14 @@ protected:
/**
* vbo buffers
*/
GLuint m_indexBuffers[4] ;
GLuint m_indexBuffers[SIZE_BUFFER] ;
/**
* nb indices
*/
GLuint m_nbIndices[4] ;
GLuint m_nbIndices[SIZE_BUFFER] ;
typedef std::pair<GLuint*, unsigned int> buffer_array;
public:
/**
......@@ -101,6 +105,9 @@ public:
*/
~MapRender() ;
buffer_array get_index_buffer() { return std::make_pair(m_indexBuffers, SIZE_BUFFER); }
buffer_array get_nb_index_buffer() { return std::make_pair(m_nbIndices, SIZE_BUFFER); }
protected:
/**
* addition of indices table of one triangle
......
......@@ -29,6 +29,7 @@
#include "Topology/generic/attribmap.h"
#include "Topology/generic/functor.h"
#include "Utils/static_assert.h"
namespace CGoGN
{
......@@ -196,10 +197,12 @@ public:
CellMarkerStore(AttribMap& map, unsigned int cell, unsigned int thread = 0) : CellMarkerGen(map, cell, thread)
{}
virtual ~CellMarkerStore()
{
unmarkAll() ;
assert(isAllUnmarked()) ;
// assert(isAllUnmarked);
CGoGN_ASSERT(isAllUnmarked())
}
protected:
......@@ -239,7 +242,8 @@ public:
virtual ~CellMarkerNoUnmark()
{
assert(isAllUnmarked()) ;
// assert(isAllUnmarked()) ;
CGoGN_ASSERT(isAllUnmarked())
}
protected:
......
......@@ -38,6 +38,7 @@ template <typename MAP2>
class EmbeddedMap2 : public MAP2
{
public:
typedef MAP2 TOPO_MAP;
/**
* The attributes attached to the old vertex are duplicated on both resulting vertices
* No attribute is attached to the new edge
......
......@@ -38,7 +38,7 @@ template <typename MAP3>
class EmbeddedMap3 : public MAP3
{
public:
typedef MAP3 TOPO_MAP;
//!
/*!
......
......@@ -54,8 +54,6 @@ public:
{
int va_id;
VBO* vbo_ptr;
// GLuint vbo_id;
// unsigned int size;
};
/**
......@@ -118,7 +116,6 @@ protected:
/**
* a set of pair VA_id / VBO_id
*/
// std::vector<pair<int,unsigned int> > m_va_vbo_binding;
std::vector<VAStr> m_va_vbo_binding;
static std::vector<std::string> m_pathes;
......@@ -344,10 +341,6 @@ public:
*/
void addPathFileSeach(const std::string& path);
/**
* remove VBO index from binding
*/
void unbindVBO(VBO* ptr);
/**
* remove VBO index from binding
......@@ -368,7 +361,7 @@ public:
/**
* get binding VA VBO
*/
const std::vector<VAStr>& getVA_VBO_Bindings() { return m_va_vbo_binding; }
// const std::vector<VAStr>& getVA_VBO_Bindings() { return m_va_vbo_binding; }
void bindAttrib(unsigned int att, const char* name) const;
......
......@@ -25,10 +25,6 @@
#ifndef _CGOGNSTREAM_H_
#define _CGOGNSTREAM_H_
// pb of compilation ??
#ifndef DBG_MAX_LEVEL
#define DBG_MAX_LEVEL 5
#endif
#include <string>
#include <iostream>
......
......@@ -34,5 +34,8 @@ namespace CGoGN
#define CGoGN_STATIC_ASSERT(expr, msg) \
{ CGoGN::CompileTimeError<((expr) != 0)> STATIC_ASSERT_ERROR_##msg; (void)STATIC_ASSERT_ERROR_##msg; }
#define CGoGN_ASSERT(expr) if (CGOGN_ASSERT_BOOL) assert(expr);
#endif
......@@ -95,11 +95,8 @@ public:
void bind() const { glBindBuffer(GL_ARRAY_BUFFER,m_id); }
/**
* reference vbo as used by shader sh
* alloc buffer of same size than parameter
*/
void ref(GLSLShader* sh);
void sameAllocSameBufferSize(const VBO& vbo);
/**
......
......@@ -764,7 +764,6 @@ bool Map3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
bool found = false; // Last functor return value
std::list<Dart> darts_list; //Darts that are traversed
darts_list.push_back(d); //Start with the dart d
mv.mark(d);
......
......@@ -910,25 +910,9 @@ void GLSLShader::addPathFileSeach(const std::string& path)
m_pathes.push_back(path);
}
void GLSLShader::unbindVBO(VBO* ptr)
{
unsigned int nb = m_va_vbo_binding.size();
for (unsigned int i = 0; i < nb; ++i)
{
if (m_va_vbo_binding[i].vbo_ptr == ptr)
{
if (i != (nb-1))
m_va_vbo_binding[i] = m_va_vbo_binding[nb-1];
m_va_vbo_binding.pop_back();
return;
}
}
}
unsigned int GLSLShader::bindVA_VBO(const std::string& name, VBO* vbo)
{
vbo->ref(this);
GLint idVA = glGetAttribLocation(this->m_program_object, name.c_str());
//valid ?
if (idVA < 0)
......@@ -953,11 +937,16 @@ unsigned int GLSLShader::bindVA_VBO(const std::string& name, VBO* vbo)
return (m_va_vbo_binding.size() -1);
}
void GLSLShader::changeVA_VBO(unsigned int id, VBO* vbo)
{
m_va_vbo_binding[id].vbo_ptr = vbo;
}
void GLSLShader::unbindVA(const std::string& name)
{
GLint idVA = glGetAttribLocation(this->m_program_object, name.c_str());
......@@ -982,6 +971,9 @@ void GLSLShader::unbindVA(const std::string& name)
CGoGNerr << "GLSLShader: Attribute "<<name<< " not binded"<< CGoGNendl;
}
void GLSLShader::setCurrentOGLVersion(unsigned int version)
{
CURRENT_OGL_VERSION = version;
......
......@@ -57,9 +57,9 @@ Drawer::Drawer() : m_currentWidth(1.0f)
Drawer::~Drawer()
{
Utils::GLSLShader::unregisterShader(NULL, m_shader);
delete m_shader;
delete m_vboPos;
delete m_vboCol;
delete m_shader;
}
void Drawer::lineWidth(float lw)
......
......@@ -109,7 +109,6 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc) : m_nbChars(0)
m_vbo1 = new Utils::VBO();
m_vbo1->setDataSize(4);
m_vbo1->ref(this);
bindVA_VBO("VertexPosition", m_vbo1);
......
......@@ -63,21 +63,9 @@ VBO::~VBO()
if (m_lock)
releasePtr();
glDeleteBuffers(1, &m_id);
for(std::vector<GLSLShader*>::iterator it = m_refs.begin(); it != m_refs.end(); ++it)
{
(*it)->unbindVBO(this);
}
}
void VBO::ref(GLSLShader* sh)
{
//already referenced ?
for(std::vector<GLSLShader*>::iterator it = m_refs.begin(); it != m_refs.end(); ++it)
if (*it == sh)
return;
// no then add
m_refs.push_back(sh);
}
void VBO::sameAllocSameBufferSize(const VBO& vbo)
{
......
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