Commit bcbfbd82 authored by Sylvain Thery's avatar Sylvain Thery

update load/save for MRMaps

update bug in rendering topo after load
parent 3647ee4b
......@@ -255,6 +255,7 @@ void Viewer::importMesh(std::string& filename)
normalBaseSize = bb.diagSize() / 100.0f ;
// vertexBaseSize = normalBaseSize /5.0f ;
normal = myMap.getAttribute<PFP::VEC3>(VERTEX, "normal") ;
if(!normal.isValid())
normal = myMap.addAttribute<PFP::VEC3>(VERTEX, "normal") ;
......
......@@ -67,10 +67,9 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC
std::vector<Dart> vecDarts;
vecDarts.reserve(map.getNbDarts()); // no problem dart is int: no problem of memory
if (m_attIndex.map() != &map)
{
m_attIndex = map.template getAttribute<unsigned int>(DART, "dart_index");
if (!m_attIndex.isValid())
m_attIndex = map.template addAttribute<unsigned int>(DART, "dart_index");
}
for(Dart d = map.begin(); d!= map.end(); map.next(d))
{
......@@ -213,10 +212,10 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE
std::vector<Dart> vecDarts;
vecDarts.reserve(map.getNbDarts()); // no problem dart is int: no problem of memory
if (m_attIndex.map() != &map)
{
m_attIndex = map.template getAttribute<unsigned int>(DART, "dart_index");
if (!m_attIndex.isValid())
m_attIndex = map.template addAttribute<unsigned int>(DART, "dart_index");
}
for(Dart d = map.begin(); d!= map.end(); map.next(d))
{
......@@ -370,6 +369,13 @@ void TopoRender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& go
float* colorBuffer = reinterpret_cast<float*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE));
unsigned int nb=0;
m_attIndex = map.template getAttribute<unsigned int>(DART, "dart_index");
if (!m_attIndex.isValid())
{
CGoGNerr << "Error attribute_dartIndex does not exist during TopoRender::picking" << CGoGNendl;
return;
}
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (good(d))
......
......@@ -26,6 +26,7 @@
#define __GENERIC_MAP__
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <iomanip>
......
......@@ -38,6 +38,8 @@ protected:
public:
Map2MR_Primal() ;
std::string mapTypeName() { return "Map2MR_Primal";}
/***************************************************
* CELLS INFORMATION *
***************************************************/
......
......@@ -173,6 +173,8 @@ void GenericMap::initMR()
#endif
m_mrattribs.clear(true) ;
m_mrattribs.setRegistry(m_attributes_registry_map) ;
m_mrDarts.clear() ;
m_mrDarts.reserve(16) ;
m_mrNbDarts.clear();
......@@ -457,8 +459,16 @@ bool GenericMap::saveMapBin(const std::string& filename)
m_attribs[i].saveBin(fs, i);
if (m_isMultiRes)
{
m_mrattribs.saveBin(fs, 00);
fs.write(reinterpret_cast<const char*>(&m_mrCurrentLevel), sizeof(unsigned int));
unsigned int nb = m_mrNbDarts.size();
fs.write(reinterpret_cast<const char*>(&nb), sizeof(unsigned int));
fs.write(reinterpret_cast<const char*>(&(m_mrNbDarts[0])), nb *sizeof(unsigned int));
}
return true;
}
......@@ -538,16 +548,24 @@ bool GenericMap::loadMapBin(const std::string& filename)
}
if (m_isMultiRes)
{
AttributeContainer::loadBinId(fs); // not used but need to read to skip
m_mrattribs.loadBin(fs);
fs.read(reinterpret_cast<char*>(&m_mrCurrentLevel), sizeof(unsigned int));
unsigned int nb;
fs.read(reinterpret_cast<char*>(&nb), sizeof(unsigned int));
m_mrNbDarts.resize(nb);
fs.read(reinterpret_cast<char*>(&(m_mrNbDarts[0])), nb *sizeof(unsigned int));
}
// retrieve m_embeddings (from m_attribs)
update_m_emb_afterLoad();
// recursive call from real type of map (for topo relation attributes pointers) down to GenericMap (for Marker_cleaning & pointers)
update_topo_shortcuts();
return true;
}
......
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