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

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

parents 268227cb 8643542f
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*******************************************************************************/ *******************************************************************************/
#include "stage_shader.h" #include "stage_shader.h"
#include "Utils/static_assert.h"
/******************************************************************************* /*******************************************************************************
* SLOTS * SLOTS
...@@ -581,7 +582,7 @@ void StageShader::cb_mousePress(int button, int x, int y) ...@@ -581,7 +582,7 @@ void StageShader::cb_mousePress(int button, int x, int y)
} }
/********************************************************************************************** /**********************************************************************************************
* MAIN FUNCTION * * MAIN FUNCTION *
**********************************************************************************************/ **********************************************************************************************/
int main(int argc, char** argv) int main(int argc, char** argv)
......
...@@ -13,6 +13,14 @@ find_package(OpenGL REQUIRED) ...@@ -13,6 +13,14 @@ find_package(OpenGL REQUIRED)
find_package(Qt4 REQUIRED) find_package(Qt4 REQUIRED)
find_package(GLUT) 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 # qq definition specifiques pour mac
IF(APPLE) IF(APPLE)
# attention a changer pour chercher la bonne version automatiquement # attention a changer pour chercher la bonne version automatiquement
......
...@@ -78,8 +78,6 @@ add_library( ...@@ -78,8 +78,6 @@ add_library(
# ${files_geometry} # ${files_geometry}
#) #)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
add_definitions(-DDBG_MAX_LEVEL=5)
file( file(
GLOB_RECURSE GLOB_RECURSE
......
...@@ -80,8 +80,6 @@ add_library( ...@@ -80,8 +80,6 @@ add_library(
# ${files_geometry} # ${files_geometry}
#) #)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
add_definitions(-DDBG_MAX_LEVEL=0)
file( file(
GLOB_RECURSE GLOB_RECURSE
......
...@@ -73,7 +73,12 @@ template <typename PFP> ...@@ -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()) ; 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 map map to be exported
* @param filename filename of ply file * @param filename filename of ply file
* @param position the position container * @param position the position container
...@@ -82,6 +87,17 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, ...@@ -82,6 +87,17 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position,
template <typename PFP> template <typename PFP>
bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const FunctorSelect& good = SelectorTrue()) ; 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 * export pout l'InESS
......
...@@ -259,7 +259,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ ...@@ -259,7 +259,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
std::ofstream out(filename, std::ios::out) ; std::ofstream out(filename, std::ios::out) ;
if (!out.good()) if (!out.good())
{ {
CGoGNerr << "Unable to open file " << CGoGNout ; CGoGNerr << "Unable to open file " << filename << CGoGNendl ;
return false ; return false ;
} }
...@@ -318,12 +318,11 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ ...@@ -318,12 +318,11 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
name << "colorPTM_a" << i ; name << "colorPTM_a" << i ;
colorPTM[i] = map.template getAttribute<VEC3>(VERTEX,name.str()) ; colorPTM[i] = map.template getAttribute<VEC3>(VERTEX,name.str()) ;
} }
const unsigned int degree = colorPTM[14].isValid() ? 4 : (colorPTM[9].isValid() ? 3 : 2) ; const unsigned int nbCoefs = colorPTM[14].isValid() ? 15 : (colorPTM[9].isValid() ? 10 : 6) ;
out << "ply" << std::endl ; out << "ply" << std::endl ;
out << "format ascii 1.0" << std::endl ; out << "format ascii 1.0" << std::endl ;
out << "comment ply PTM" << std::endl ; out << "comment ply PTM (K. Vanhoey generic format)" << std::endl ;
out << "element vertex " << vertices.size() << std::endl ; out << "element vertex " << vertices.size() << std::endl ;
out << "property float x" << std::endl ; out << "property float x" << std::endl ;
out << "property float y" << std::endl ; out << "property float y" << std::endl ;
...@@ -337,67 +336,16 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ ...@@ -337,67 +336,16 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
out << "property float nx" << std::endl ; out << "property float nx" << std::endl ;
out << "property float ny" << std::endl ; out << "property float ny" << std::endl ;
out << "property float nz" << std::endl ; out << "property float nz" << std::endl ;
out << "property float L1_a0" << std::endl ; for(unsigned int coefI = 0 ; coefI < nbCoefs ; ++coefI)
out << "property float L1_a1" << std::endl ; out << "property float L1_a" << coefI << std::endl ;
out << "property float L1_a2" << std::endl ; for(unsigned int coefI = 0 ; coefI < nbCoefs ; ++coefI)
out << "property float L1_a3" << std::endl ; out << "property float L2_a" << coefI << std::endl ;
out << "property float L1_a4" << std::endl ; for(unsigned int coefI = 0 ; coefI < nbCoefs ; ++coefI)
out << "property float L1_a5" << std::endl ; out << "property float L3_a" << coefI << std::endl ;
if (degree > 2) {
out << "property float L1_a6" << std::endl ;
out << "property float L1_a7" << std::endl ;
out << "property float L1_a8" << std::endl ;
out << "property float L1_a9" << std::endl ;
if (degree > 3) {
out << "property float L1_a10" << std::endl ;
out << "property float L1_a11" << std::endl ;
out << "property float L1_a12" << std::endl ;
out << "property float L1_a13" << std::endl ;
out << "property float L1_a14" << std::endl ;
}
}
out << "property float L2_a0" << std::endl ;
out << "property float L2_a1" << std::endl ;
out << "property float L2_a2" << std::endl ;
out << "property float L2_a3" << std::endl ;
out << "property float L2_a4" << std::endl ;
out << "property float L2_a5" << std::endl ;
if (degree > 2) {
out << "property float L2_a6" << std::endl ;
out << "property float L2_a7" << std::endl ;
out << "property float L2_a8" << std::endl ;
out << "property float L2_a9" << std::endl ;
if (degree > 3) {
out << "property float L2_a10" << std::endl ;
out << "property float L2_a11" << std::endl ;
out << "property float L2_a12" << std::endl ;
out << "property float L2_a13" << std::endl ;
out << "property float L2_a14" << std::endl ;
}
}
out << "property float L3_a0" << std::endl ;
out << "property float L3_a1" << std::endl ;
out << "property float L3_a2" << std::endl ;
out << "property float L3_a3" << std::endl ;
out << "property float L3_a4" << std::endl ;
out << "property float L3_a5" << std::endl ;
if (degree > 2) {
out << "property float L3_a6" << std::endl ;
out << "property float L3_a7" << std::endl ;
out << "property float L3_a8" << std::endl ;
out << "property float L3_a9" << std::endl ;
if (degree > 3) {
out << "property float L3_a10" << std::endl ;
out << "property float L3_a11" << std::endl ;
out << "property float L3_a12" << std::endl ;
out << "property float L3_a13" << std::endl ;
out << "property float L3_a14" << std::endl ;
}
}
TREAL errL2 = map.template getAttribute<REAL>(VERTEX,"errL2") ; TREAL errL2 = map.template getAttribute<REAL>(VERTEX,"errL2") ;
TREAL errLmax = map.template getAttribute<REAL>(VERTEX,"errLmax") ; TREAL errLmax = map.template getAttribute<REAL>(VERTEX,"errLmax") ;
TREAL stdDev = map.template getAttribute<REAL>(VERTEX,"StdDev") ; TREAL stdDev = map.template getAttribute<REAL>(VERTEX,"stdDev") ;
if (errL2.isValid()) if (errL2.isValid())
out << "property float errL2" << std::endl ; out << "property float errL2" << std::endl ;
if (errLmax.isValid()) if (errLmax.isValid())
...@@ -409,72 +357,28 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ ...@@ -409,72 +357,28 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
out << "property list uchar int vertex_indices" << std::endl ; out << "property list uchar int vertex_indices" << std::endl ;
out << "end_header" << std::endl ; out << "end_header" << std::endl ;
switch (degree) { for(unsigned int i = 0; i < vertices.size(); ++i)
case(2) : {
for(unsigned int i = 0; i < vertices.size(); ++i) unsigned int vi = vertices[i];
{ // position
unsigned int vi = vertices[i]; for(unsigned int coord = 0 ; coord < 3 ; ++coord)
out << position[vi][0] << " " << position[vi][1] << " " << position[vi][2] << " " ; out << position[vi][coord] << " " ;
out << frame[0][vi][0] << " " << frame[0][vi][1] << " " << frame[0][vi][2] << " " ; // frame
out << frame[1][vi][0] << " " << frame[1][vi][1] << " " << frame[1][vi][2] << " " ; for(unsigned int axis = 0 ; axis < 3 ; ++axis)
out << frame[2][vi][0] << " " << frame[2][vi][1] << " " << frame[2][vi][2] << " " ; for (unsigned int coord = 0 ; coord < 3 ; ++coord)
out << colorPTM[0][vi][0] << " " << colorPTM[1][vi][0] << " " << colorPTM[2][vi][0] << " " << colorPTM[3][vi][0] << " " << colorPTM[4][vi][0] << " " << colorPTM[5][vi][0] << " " ; out << frame[axis][vi][coord] << " " ;
out << colorPTM[0][vi][1] << " " << colorPTM[1][vi][1] << " " << colorPTM[2][vi][1] << " " << colorPTM[3][vi][1] << " " << colorPTM[4][vi][1] << " " << colorPTM[5][vi][1] << " " ; // coefficients
out << colorPTM[0][vi][2] << " " << colorPTM[1][vi][2] << " " << colorPTM[2][vi][2] << " " << colorPTM[3][vi][2] << " " << colorPTM[4][vi][2] << " " << colorPTM[5][vi][2] << " " ; for (unsigned int channel = 0 ; channel < 3 ; ++channel)
if (errL2.isValid()) for(unsigned int coefI = 0 ; coefI < nbCoefs ; ++coefI)
out << errL2[vi] << " " ; out << colorPTM[coefI][vi][channel] << " " ;
if (errLmax.isValid()) // fitting errors (if any)
out << errLmax[vi] << " " ; if (errL2.isValid())
if (stdDev.isValid()) out << errL2[vi] << " " ;
out << stdDev[vi] << " " ; if (errLmax.isValid())
out << std::endl ; out << errLmax[vi] << " " ;
} if (stdDev.isValid())
break ; out << stdDev[vi] << " " ;
case(3) : out << std::endl ;
for(unsigned int i = 0; i < vertices.size(); ++i)
{
unsigned int vi = vertices[i];
out << position[vi][0] << " " << position[vi][1] << " " << position[vi][2] << " " ;
out << frame[0][vi][0] << " " << frame[0][vi][1] << " " << frame[0][vi][2] << " " ;
out << frame[1][vi][0] << " " << frame[1][vi][1] << " " << frame[1][vi][2] << " " ;
out << frame[2][vi][0] << " " << frame[2][vi][1] << " " << frame[2][vi][2] << " " ;
out << colorPTM[0][vi][0] << " " << colorPTM[1][vi][0] << " " << colorPTM[2][vi][0] << " " << colorPTM[3][vi][0] << " " << colorPTM[4][vi][0] << " " << colorPTM[5][vi][0] << " " << colorPTM[6][vi][0] << " " << colorPTM[7][vi][0] << " " << colorPTM[8][vi][0] << " " << colorPTM[9][vi][0] << " " ;
out << colorPTM[0][vi][1] << " " << colorPTM[1][vi][1] << " " << colorPTM[2][vi][1] << " " << colorPTM[3][vi][1] << " " << colorPTM[4][vi][1] << " " << colorPTM[5][vi][1] << " " << colorPTM[6][vi][1] << " " << colorPTM[7][vi][1] << " " << colorPTM[8][vi][1] << " " << colorPTM[9][vi][1] << " " ;
out << colorPTM[0][vi][2] << " " << colorPTM[1][vi][2] << " " << colorPTM[2][vi][2] << " " << colorPTM[3][vi][2] << " " << colorPTM[4][vi][2] << " " << colorPTM[5][vi][2] << " " << colorPTM[6][vi][2] << " " << colorPTM[7][vi][2] << " " << colorPTM[8][vi][2] << " " << colorPTM[9][vi][2] << " " ;
if (errL2.isValid())
out << errL2[vi] << " " ;
if (errLmax.isValid())
out << errLmax[vi] << " " ;
if (stdDev.isValid())
out << stdDev[vi] << " " ;
out << std::endl ;
}
break ;
case (4) :
for(unsigned int i = 0; i < vertices.size(); ++i)
{
unsigned int vi = vertices[i];
out << position[vi][0] << " " << position[vi][1] << " " << position[vi][2] << " " ;
out << frame[0][vi][0] << " " << frame[0][vi][1] << " " << frame[0][vi][2] << " " ;
out << frame[1][vi][0] << " " << frame[1][vi][1] << " " << frame[1][vi][2] << " " ;
out << frame[2][vi][0] << " " << frame[2][vi][1] << " " << frame[2][vi][2] << " " ;
out << colorPTM[0][vi][0] << " " << colorPTM[1][vi][0] << " " << colorPTM[2][vi][0] << " " << colorPTM[3][vi][0] << " " << colorPTM[4][vi][0] << " " << colorPTM[5][vi][0] << " " << colorPTM[6][vi][0] << " " << colorPTM[7][vi][0] << " " << colorPTM[8][vi][0] << " " << colorPTM[9][vi][0] << " " << colorPTM[10][vi][0] << " " << colorPTM[11][vi][0] << " " << colorPTM[12][vi][0] << " " << colorPTM[13][vi][0] << " " << colorPTM[14][vi][0] << " " ;
out << colorPTM[0][vi][1] << " " << colorPTM[1][vi][1] << " " << colorPTM[2][vi][1] << " " << colorPTM[3][vi][1] << " " << colorPTM[4][vi][1] << " " << colorPTM[5][vi][1] << " " << colorPTM[6][vi][1] << " " << colorPTM[7][vi][1] << " " << colorPTM[8][vi][1] << " " << colorPTM[9][vi][1] << " " << colorPTM[10][vi][1] << " " << colorPTM[11][vi][1] << " " << colorPTM[12][vi][1] << " " << colorPTM[13][vi][1] << " " << colorPTM[14][vi][1] << " " ;
out << colorPTM[0][vi][2] << " " << colorPTM[1][vi][2] << " " << colorPTM[2][vi][2] << " " << colorPTM[3][vi][2] << " " << colorPTM[4][vi][2] << " " << colorPTM[5][vi][2] << " " << colorPTM[6][vi][2] << " " << colorPTM[7][vi][2] << " " << colorPTM[8][vi][2] << " " << colorPTM[9][vi][2] << " " << colorPTM[10][vi][2] << " " << colorPTM[11][vi][2] << " " << colorPTM[12][vi][2] << " " << colorPTM[13][vi][2] << " " << colorPTM[14][vi][2] << " " ;
if (errL2.isValid())
out << errL2[vi] << " " ;
if (errLmax.isValid())
out << errLmax[vi] << " " ;
if (stdDev.isValid())
out << stdDev[vi] << " " ;
out << std::endl ;
}
break ;
default :
assert(false || !"exportPlyPTM : degree not in {2,3,4} unhandled") ;
break ;
} }
std::vector<unsigned int>::iterator it = faces.begin(); std::vector<unsigned int>::iterator it = faces.begin();
...@@ -490,7 +394,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ ...@@ -490,7 +394,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
out.close() ; out.close() ;
return true ; return true ;
} }
/*
template <typename PFP> 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) 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)
{ {
...@@ -609,7 +513,7 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P ...@@ -609,7 +513,7 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
out.close() ; out.close() ;
return true ; return true ;
}*/ }
template <typename PFP> template <typename PFP>
......
...@@ -548,16 +548,17 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector< ...@@ -548,16 +548,17 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector<
* @param filename the file to import; * @param filename the file to import;
* @param attrNames reference that will be filled with the attribute names * @param attrNames reference that will be filled with the attribute names
* the number of attrNames returned depends on the degree of the polynomials : * the number of attrNames returned depends on the degree of the polynomials :
* - 1 attrName for geometric position (VEC3) * - 1 attrName for geometric position (VEC3) : name = "position" ;
* - 3 attrNames for local frame (3xVEC3) : Tangent, Bitangent and Normal vector * - 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. * - 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 = 1 for constant polynomial,
* N = 3 for linear polynomial, * N = 3 for linear polynomial,
* N = 6 for quadratic polynomial, * N = 6 for quadratic polynomial,
* N = 10 for cubic degree polynomial, * N = 10 for cubic degree polynomial,
* N = 15 for 4th 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. * @return bool : success.
*/ */
template <typename PFP> template <typename PFP>
...@@ -588,13 +589,33 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st ...@@ -588,13 +589,33 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st
unsigned int nbVertices ; unsigned int nbVertices ;
fp >> nbVertices ; // Read #vertices 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 do // go to #faces and count #properties
{ {
fp >> tag ; fp >> tag ;
if (tag == std::string("property")) if (tag == std::string("property"))
++nbProps ; ++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")) ; } 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 fp >> m_nbFaces ; // Read #vertices
do // go to end of header do // go to end of header
...@@ -602,8 +623,6 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st ...@@ -602,8 +623,6 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st
fp >> tag ; fp >> tag ;
} while (tag != std::string("end_header")) ; } while (tag != std::string("end_header")) ;
unsigned int nbCoefsPerPol = (nbProps - 12) / 3 ; // get #coefficients per polynomial
// Define containers // Define containers
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ; AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
if (!positions.isValid()) if (!positions.isValid())
...@@ -627,6 +646,15 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st ...@@ -627,6 +646,15 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st
attrNames.push_back(colorPTM[i].name()) ; 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 // Read vertices
std::vector<unsigned int> verticesID ; std::vector<unsigned int> verticesID ;
verticesID.reserve(nbVertices) ; verticesID.reserve(nbVertices) ;
...@@ -648,6 +676,9 @@ bool MeshTablesSurface<PFP>::importPlyPTMgeneric(const std::string& filename, st ...@@ -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 k = 0 ; k < 3 ; ++k) // coefficients
for (unsigned int l = 0 ; l < nbCoefsPerPol ; ++l) for (unsigned int l = 0 ; l < nbCoefsPerPol ; ++l)
colorPTM[l][id][k] = properties[12+(nbCoefsPerPol*k+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() ; m_nbVertices = verticesID.size() ;
delete[] properties ; delete[] properties ;
......
...@@ -32,6 +32,7 @@ namespace Algo ...@@ -32,6 +32,7 @@ namespace Algo
namespace Import namespace Import
{ {
template <typename PFP> template <typename PFP>
bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor) 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< ...@@ -177,19 +178,18 @@ bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector<
//Association des phi3 //Association des phi3
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
{ {
std::vector<Dart>& vec = vecDartsPerVertex[d]; const std::vector<Dart>& vec = vecDartsPerVertex[d];
for(typename std::vector<Dart>::const_iterator it = vec.begin(); it!=vec.end(); ++it)
for(typename std::vector<Dart>::iterator it = vec.begin(); it!=vec.end(); ++it)
{ {
if(map.phi3(*it) == *it) if(map.phi3(*it) == *it)
{ {
bool sewn = false; 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)) 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.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; sewn = true;
} }
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <vector> #include <vector>
#include <list> #include <list>
#include <utility>
#include "Topology/generic/dart.h" #include "Topology/generic/dart.h"
#include "Topology/generic/functor.h" #include "Topology/generic/functor.h"
...@@ -67,7 +68,8 @@ enum bufferIndex ...@@ -67,7 +68,8 @@ enum bufferIndex
POINT_INDICES = 0, POINT_INDICES = 0,
LINE_INDICES = 1, LINE_INDICES = 1,
TRIANGLE_INDICES = 2, TRIANGLE_INDICES = 2,
FLAT_BUFFER = 3 FLAT_BUFFER = 3,
SIZE_BUFFER
} ; } ;
...@@ -78,12 +80,14 @@ protected: ...@@ -78,12 +80,14 @@ protected:
/** /**
* vbo buffers * vbo buffers
*/ */
GLuint m_indexBuffers[4] ; GLuint m_indexBuffers[SIZE_BUFFER] ;
/** /**
* nb indices * nb indices