Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CGoGN
CGoGN
Commits
1d9d93b1
Commit
1d9d93b1
authored
Apr 25, 2012
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
warnings
parent
ddefb9a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
431 additions
and
434 deletions
+431
-434
include/Algo/Export/export.h
include/Algo/Export/export.h
+6
-6
include/Algo/Import/import2tablesSurface.hpp
include/Algo/Import/import2tablesSurface.hpp
+425
-426
include/Topology/map/map2MR/map2MR_PM.h
include/Topology/map/map2MR/map2MR_PM.h
+0
-2
No files found.
include/Algo/Export/export.h
View file @
1d9d93b1
...
...
@@ -88,9 +88,9 @@ bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, ch
* @param filename filename of ply file
* @param position the position container
* @return true
*
template <typename PFP>
bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
*
/
//
template <typename PFP>
//
bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a PLYPTMgeneric file (K. Vanhoey generic format).
...
...
@@ -103,9 +103,9 @@ bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi
* @param filename filename of ply file
* @param position the position container
* @return true
*
template <typename PFP>
bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
*
/
//
template <typename PFP>
//
bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a PLYSLF file (K. Vanhoey generic format).
...
...
include/Algo/Import/import2tablesSurface.hpp
View file @
1d9d93b1
...
...
@@ -665,305 +665,305 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector<
* ...
* - K remaining attrNames named "remainderNo<k>" where k is an integer from 0 to K-1.
* @return bool : success.
*
template <typename PFP>
bool MeshTablesSurface<PFP>::importPlySLFgeneric(const std::string& filename, std::vector<std::string>& attrNames)
{
// Open file
std::ifstream fp(filename.c_str(), std::ios::in) ;
if (!fp.good())
{
CGoGNerr << "Unable to open file " << filename << CGoGNendl ;
return false ;
}
// Read quantities : #vertices, #faces, #properties, degree of polynomials
std::string tag ;
fp >> tag;
if (tag != std::string("ply")) // verify file type
{
CGoGNerr << filename << " is not a ply file !" << CGoGNout ;
return false ;
}
do // go to #vertices
{
fp >> tag ;
} while (tag != std::string("vertex")) ;
unsigned int nbVertices ;
fp >> nbVertices ; // Read #vertices
bool position = false ;
bool tangent = false ;
bool binormal = false ;
bool normal = false ;
unsigned int nbProps = 0 ; // # properties
unsigned int nbCoefs = 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("FrameT_0") || tag == std::string("FrameT_1") || tag == std::string("FrameT_2"))
tangent = true ;
else if (tag == std::string("FrameB_0") || tag == std::string("FrameB_1") || tag == std::string("FrameB_2"))
binormal = true ;
else if (tag == std::string("FrameN_0") || tag == std::string("FrameN_1") || tag == std::string("FrameN_2"))
normal = true ;
if ((tag.substr(3,5) == std::string("coefs") && tag.substr(8,1) == std::string("_")) || (tag.substr(2,5) == std::string("coefs") && tag.substr(7,1) == std::string("_")))
++nbCoefs ;
} while (tag != std::string("face")) ;
unsigned int nbRemainders = nbProps ; // # remaining properties
nbRemainders -= nbCoefs + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ;
nbCoefs /= 3 ;
fp >> m_nbFaces ; // Read #vertices
do // go to end of header
{
fp >> tag ;
} while (tag != std::string("end_header")) ;
// Define containers
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
if (!positions.isValid())
positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "position") ;
attrNames.push_back(positions.name()) ;
AttributeHandler<typename PFP::VEC3> *frame = new AttributeHandler<typename PFP::VEC3>[3] ;
frame[0] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameT") ; // Tangent
frame[1] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameB") ; // Bitangent
frame[2] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameN") ; // Normal
attrNames.push_back(frame[0].name()) ;
attrNames.push_back(frame[1].name()) ;
attrNames.push_back(frame[2].name()) ;
AttributeHandler<typename PFP::VEC3> *SLFcoefs = new AttributeHandler<typename PFP::VEC3>[nbCoefs] ;
for (unsigned int i = 0 ; i < nbCoefs ; ++i)
{
std::stringstream name ;
name << "SLFcoefs" << i ;
SLFcoefs[i] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, name.str()) ;
attrNames.push_back(SLFcoefs[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) ;
float* properties = new float[nbProps] ;
AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ;
for (unsigned int i = 0 ; i < nbVertices ; ++i) // Read and store properties for current vertex
{
unsigned int id = container.insertLine() ;
verticesID.push_back(id) ;
for (unsigned int j = 0 ; j < nbProps ; ++j) // get all properties
fp >> properties[j] ;
positions[id] = VEC3(properties[0],properties[1],properties[2]) ; // position
for (unsigned int k = 0 ; k < 3 ; ++k) // frame
for (unsigned int l = 0 ; l < 3 ; ++l)
frame[k][id][l] = properties[3+(3*k+l)] ;
for (unsigned int k = 0 ; k < 3 ; ++k) // coefficients
for (unsigned int l = 0 ; l < nbCoefs ; ++l)
SLFcoefs[l][id][k] = properties[12+(nbCoefs*k+l)] ;
unsigned int cur = 12+3*nbCoefs ;
for (unsigned int k = 0 ; k < nbRemainders ; ++k) // remaining data
remainders[k][id] = properties[cur + k] ;
}
m_nbVertices = verticesID.size() ;
delete[] properties ;
// Read faces index
m_nbEdges.reserve(m_nbFaces) ;
m_emb.reserve(3 * m_nbFaces) ;
for (unsigned int i = 0 ; i < m_nbFaces ; ++i)
{
// read the indices of vertices for current face
unsigned int nbEdgesForFace ;
fp >> nbEdgesForFace ;
m_nbEdges.push_back(nbEdgesForFace);
unsigned int vertexID ;
for (unsigned int j=0 ; j < nbEdgesForFace ; ++j)
{
fp >> vertexID ;
m_emb.push_back(verticesID[vertexID]);
}
}
// Close file
fp.close() ;
return true ;
}
template <typename PFP>
bool MeshTablesSurface<PFP>::importPlySLFgenericBin(const std::string& filename, std::vector<std::string>& attrNames)
{
// Open file
std::ifstream fp(filename.c_str(), std::ios::in | std::ios::binary) ;
if (!fp.good())
{
CGoGNerr << "Unable to open file " << filename << CGoGNendl ;
return false ;
}
// Read quantities : #vertices, #faces, #properties, degree of polynomials
std::string tag ;
fp >> tag;
if (tag != std::string("ply")) // verify file type
{
CGoGNerr << filename << " is not a ply file !" << CGoGNout ;
return false ;
}
do // go to #vertices
{
fp >> tag ;
} while (tag != std::string("vertex")) ;
unsigned int nbVertices ;
fp >> nbVertices ; // Read #vertices
bool position = false ;
bool tangent = false ;
bool binormal = false ;
bool normal = false ;
unsigned int nbProps = 0 ; // # properties
unsigned int nbCoefs = 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("FrameT_0") || tag == std::string("FrameT_1") || tag == std::string("FrameT_2"))
tangent = true ;
else if (tag == std::string("FrameB_0") || tag == std::string("FrameB_1") || tag == std::string("FrameB_2"))
binormal = true ;
else if (tag == std::string("FrameN_0") || tag == std::string("FrameN_1") || tag == std::string("FrameN_2"))
normal = true ;
if ((tag.substr(3,5) == std::string("coefs") && tag.substr(8,1) == std::string("_")) || (tag.substr(2,5) == std::string("coefs") && tag.substr(7,1) == std::string("_")))
++nbCoefs ;
} while (tag != std::string("face")) ;
unsigned int nbRemainders = nbProps ; // # remaining properties
nbRemainders -= nbCoefs + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ;
nbCoefs /= 3 ;
fp >> m_nbFaces ; // Read #vertices
do // go to end of header
{
fp >> tag ;
} while (tag != std::string("end_header")) ;
char* endline = new char[1] ;
fp.read(endline, sizeof(char)) ;
if (*endline == '\r') // for windows
fp.read(endline, sizeof(char)) ;
assert(*endline == '\n') ;
delete endline ;
// Define containers
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
if (!positions.isValid())
positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "position") ;
attrNames.push_back(positions.name()) ;
AttributeHandler<typename PFP::VEC3> *frame = new AttributeHandler<typename PFP::VEC3>[3] ;
frame[0] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameT") ; // Tangent
frame[1] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameB") ; // Bitangent
frame[2] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameN") ; // Normal
attrNames.push_back(frame[0].name()) ;
attrNames.push_back(frame[1].name()) ;
attrNames.push_back(frame[2].name()) ;
AttributeHandler<typename PFP::VEC3> *SLFcoefs = new AttributeHandler<typename PFP::VEC3>[nbCoefs] ;
for (unsigned int i = 0 ; i < nbCoefs ; ++i)
{
std::stringstream name ;
name << "SLFcoefs" << i ;
SLFcoefs[i] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, name.str()) ;
attrNames.push_back(SLFcoefs[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) ;
float* properties = new float[nbProps] ;
AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ;
for (unsigned int i = 0 ; i < nbVertices ; ++i) // Read and store properties for current vertex
{
unsigned int id = container.insertLine() ;
verticesID.push_back(id) ;
// for (unsigned int j = 0 ; j < nbProps ; ++j) // get all properties
fp.read((char*)properties,nbProps * sizeof(float)) ;
positions[id] = VEC3(properties[0],properties[1],properties[2]) ; // position
for (unsigned int k = 0 ; k < 3 ; ++k) // frame
for (unsigned int l = 0 ; l < 3 ; ++l)
frame[k][id][l] = (typename PFP::REAL)(properties[3+(3*k+l)]) ;
for (unsigned int k = 0 ; k < 3 ; ++k) // coefficients
for (unsigned int l = 0 ; l < nbCoefs ; ++l)
SLFcoefs[l][id][k] = (typename PFP::REAL)(properties[12+(nbCoefs*k+l)]) ;
unsigned int cur = 12+3*nbCoefs ;
for (unsigned int k = 0 ; k < nbRemainders ; ++k) // remaining data
remainders[k][id] = (typename PFP::REAL)(properties[cur + k]) ;
}
m_nbVertices = verticesID.size() ;
delete[] properties ;
// Read faces index
m_nbEdges.reserve(m_nbFaces) ;
m_emb.reserve(3 * m_nbFaces) ;
for (unsigned int i = 0 ; i < m_nbFaces ; ++i)
{
// read the indices of vertices for current face
unsigned int nbEdgesForFace ;
fp.read((char*)&(nbEdgesForFace), sizeof(unsigned int)) ;
m_nbEdges.push_back(nbEdgesForFace);
unsigned int vertexID ;
for (unsigned int j=0 ; j < nbEdgesForFace ; ++j)
{
fp.read((char*)&vertexID, sizeof(unsigned int)) ;
m_emb.push_back(verticesID[vertexID]);
}
}
// Close file
fp.close() ;
return true ;
}
*
/
//
template <typename PFP>
//
bool MeshTablesSurface<PFP>::importPlySLFgeneric(const std::string& filename, std::vector<std::string>& attrNames)
//
{
//
// Open file
//
std::ifstream fp(filename.c_str(), std::ios::in) ;
//
if (!fp.good())
//
{
//
CGoGNerr << "Unable to open file " << filename << CGoGNendl ;
//
return false ;
//
}
//
//
// Read quantities : #vertices, #faces, #properties, degree of polynomials
//
std::string tag ;
//
//
fp >> tag;
//
if (tag != std::string("ply")) // verify file type
//
{
//
CGoGNerr << filename << " is not a ply file !" << CGoGNout ;
//
return false ;
//
}
//
//
do // go to #vertices
//
{
//
fp >> tag ;
//
} while (tag != std::string("vertex")) ;
//
unsigned int nbVertices ;
//
fp >> nbVertices ; // Read #vertices
//
//
bool position = false ;
//
bool tangent = false ;
//
bool binormal = false ;
//
bool normal = false ;
//
unsigned int nbProps = 0 ; // # properties
//
unsigned int nbCoefs = 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("FrameT_0") || tag == std::string("FrameT_1") || tag == std::string("FrameT_2"))
//
tangent = true ;
//
else if (tag == std::string("FrameB_0") || tag == std::string("FrameB_1") || tag == std::string("FrameB_2"))
//
binormal = true ;
//
else if (tag == std::string("FrameN_0") || tag == std::string("FrameN_1") || tag == std::string("FrameN_2"))
//
normal = true ;
//
if ((tag.substr(3,5) == std::string("coefs") && tag.substr(8,1) == std::string("_")) || (tag.substr(2,5) == std::string("coefs") && tag.substr(7,1) == std::string("_")))
//
++nbCoefs ;
//
} while (tag != std::string("face")) ;
//
unsigned int nbRemainders = nbProps ; // # remaining properties
//
nbRemainders -= nbCoefs + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ;
//
nbCoefs /= 3 ;
//
//
fp >> m_nbFaces ; // Read #vertices
//
//
do // go to end of header
//
{
//
fp >> tag ;
//
} while (tag != std::string("end_header")) ;
//
//
// Define containers
//
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
//
if (!positions.isValid())
//
positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "position") ;
//
attrNames.push_back(positions.name()) ;
//
//
AttributeHandler<typename PFP::VEC3> *frame = new AttributeHandler<typename PFP::VEC3>[3] ;
//
frame[0] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameT") ; // Tangent
//
frame[1] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameB") ; // Bitangent
//
frame[2] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameN") ; // Normal
//
attrNames.push_back(frame[0].name()) ;
//
attrNames.push_back(frame[1].name()) ;
//
attrNames.push_back(frame[2].name()) ;
//
//
AttributeHandler<typename PFP::VEC3> *SLFcoefs = new AttributeHandler<typename PFP::VEC3>[nbCoefs] ;
//
for (unsigned int i = 0 ; i < nbCoefs ; ++i)
//
{
//
std::stringstream name ;
//
name << "SLFcoefs" << i ;
//
SLFcoefs[i] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, name.str()) ;
//
attrNames.push_back(SLFcoefs[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) ;
//
//
float* properties = new float[nbProps] ;
//
AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ;
//
for (unsigned int i = 0 ; i < nbVertices ; ++i) // Read and store properties for current vertex
//
{
//
unsigned int id = container.insertLine() ;
//
verticesID.push_back(id) ;
//
//
for (unsigned int j = 0 ; j < nbProps ; ++j) // get all properties
//
fp >> properties[j] ;
//
//
positions[id] = VEC3(properties[0],properties[1],properties[2]) ; // position
//
for (unsigned int k = 0 ; k < 3 ; ++k) // frame
//
for (unsigned int l = 0 ; l < 3 ; ++l)
//
frame[k][id][l] = properties[3+(3*k+l)] ;
//
for (unsigned int k = 0 ; k < 3 ; ++k) // coefficients
//
for (unsigned int l = 0 ; l < nbCoefs ; ++l)
//
SLFcoefs[l][id][k] = properties[12+(nbCoefs*k+l)] ;
//
unsigned int cur = 12+3*nbCoefs ;
//
for (unsigned int k = 0 ; k < nbRemainders ; ++k) // remaining data
//
remainders[k][id] = properties[cur + k] ;
//
}
//
m_nbVertices = verticesID.size() ;
//
delete[] properties ;
//
//
// Read faces index
//
m_nbEdges.reserve(m_nbFaces) ;
//
m_emb.reserve(3 * m_nbFaces) ;
//
for (unsigned int i = 0 ; i < m_nbFaces ; ++i)
//
{
//
// read the indices of vertices for current face
//
unsigned int nbEdgesForFace ;
//
fp >> nbEdgesForFace ;
//
m_nbEdges.push_back(nbEdgesForFace);
//
//
unsigned int vertexID ;
//
for (unsigned int j=0 ; j < nbEdgesForFace ; ++j)
//
{
//
fp >> vertexID ;
//
m_emb.push_back(verticesID[vertexID]);
//
}
//
}
//
//
// Close file
//
fp.close() ;
//
//
return true ;
//
}
//
template <typename PFP>
//
bool MeshTablesSurface<PFP>::importPlySLFgenericBin(const std::string& filename, std::vector<std::string>& attrNames)
//
{
//
// Open file
//
std::ifstream fp(filename.c_str(), std::ios::in | std::ios::binary) ;
//
if (!fp.good())
//
{
//
CGoGNerr << "Unable to open file " << filename << CGoGNendl ;
//
return false ;
//
}
//
//
// Read quantities : #vertices, #faces, #properties, degree of polynomials
//
std::string tag ;
//
//
fp >> tag;
//
if (tag != std::string("ply")) // verify file type
//
{
//
CGoGNerr << filename << " is not a ply file !" << CGoGNout ;
//
return false ;
//
}
//
//
do // go to #vertices
//
{
//
fp >> tag ;
//
} while (tag != std::string("vertex")) ;
//
unsigned int nbVertices ;
//
fp >> nbVertices ; // Read #vertices
//
//
bool position = false ;
//
bool tangent = false ;
//
bool binormal = false ;
//
bool normal = false ;
//
unsigned int nbProps = 0 ; // # properties
//
unsigned int nbCoefs = 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("FrameT_0") || tag == std::string("FrameT_1") || tag == std::string("FrameT_2"))
//
tangent = true ;
//
else if (tag == std::string("FrameB_0") || tag == std::string("FrameB_1") || tag == std::string("FrameB_2"))
//
binormal = true ;
//
else if (tag == std::string("FrameN_0") || tag == std::string("FrameN_1") || tag == std::string("FrameN_2"))
//
normal = true ;
//
if ((tag.substr(3,5) == std::string("coefs") && tag.substr(8,1) == std::string("_")) || (tag.substr(2,5) == std::string("coefs") && tag.substr(7,1) == std::string("_")))
//
++nbCoefs ;
//
} while (tag != std::string("face")) ;
//
unsigned int nbRemainders = nbProps ; // # remaining properties
//
nbRemainders -= nbCoefs + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ;
//
nbCoefs /= 3 ;
//
//
fp >> m_nbFaces ; // Read #vertices
//
//
do // go to end of header
//
{
//
fp >> tag ;
//
} while (tag != std::string("end_header")) ;
//
//
char* endline = new char[1] ;
//
fp.read(endline, sizeof(char)) ;
//
if (*endline == '\r') // for windows
//
fp.read(endline, sizeof(char)) ;
//
assert(*endline == '\n') ;
//
delete endline ;
//
//
// Define containers
//
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
//
if (!positions.isValid())
//
positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "position") ;
//
attrNames.push_back(positions.name()) ;
//
//
AttributeHandler<typename PFP::VEC3> *frame = new AttributeHandler<typename PFP::VEC3>[3] ;
//
frame[0] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameT") ; // Tangent
//
frame[1] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameB") ; // Bitangent
//
frame[2] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "frameN") ; // Normal
//
attrNames.push_back(frame[0].name()) ;
//
attrNames.push_back(frame[1].name()) ;
//
attrNames.push_back(frame[2].name()) ;
//
//
AttributeHandler<typename PFP::VEC3> *SLFcoefs = new AttributeHandler<typename PFP::VEC3>[nbCoefs] ;
//
for (unsigned int i = 0 ; i < nbCoefs ; ++i)
//
{
//
std::stringstream name ;
//
name << "SLFcoefs" << i ;
//
SLFcoefs[i] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, name.str()) ;
//
attrNames.push_back(SLFcoefs[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) ;
//
//
float* properties = new float[nbProps] ;
//
AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ;
//
for (unsigned int i = 0 ; i < nbVertices ; ++i) // Read and store properties for current vertex
//
{
//
unsigned int id = container.insertLine() ;
//
verticesID.push_back(id) ;
//
//
// for (unsigned int j = 0 ; j < nbProps ; ++j) // get all properties
//
fp.read((char*)properties,nbProps * sizeof(float)) ;
//
//
positions[id] = VEC3(properties[0],properties[1],properties[2]) ; // position
//
for (unsigned int k = 0 ; k < 3 ; ++k) // frame
//
for (unsigned int l = 0 ; l < 3 ; ++l)
//
frame[k][id][l] = (typename PFP::REAL)(properties[3+(3*k+l)]) ;
//
for (unsigned int k = 0 ; k < 3 ; ++k) // coefficients
//
for (unsigned int l = 0 ; l < nbCoefs ; ++l)
//
SLFcoefs[l][id][k] = (typename PFP::REAL)(properties[12+(nbCoefs*k+l)]) ;
//
unsigned int cur = 12+3*nbCoefs ;
//
for (unsigned int k = 0 ; k < nbRemainders ; ++k) // remaining data
//
remainders[k][id] = (typename PFP::REAL)(properties[cur + k]) ;
//
}
//
m_nbVertices = verticesID.size() ;
//
delete[] properties ;
//
//
// Read faces index
//
m_nbEdges.reserve(m_nbFaces) ;
//
m_emb.reserve(3 * m_nbFaces) ;
//
for (unsigned int i = 0 ; i < m_nbFaces ; ++i)
//
{
//
// read the indices of vertices for current face
//
unsigned int nbEdgesForFace ;
//
fp.read((char*)&(nbEdgesForFace), sizeof(unsigned int)) ;
//
m_nbEdges.push_back(nbEdgesForFace);
//
//
unsigned int vertexID ;
//
for (unsigned int j=0 ; j < nbEdgesForFace ; ++j)
//
{
//
fp.read((char*)&vertexID, sizeof(unsigned int)) ;
//
m_emb.push_back(verticesID[vertexID]);
//
}
//
}