void AttributeContainer::copyFrom(const AttributeContainer& cont) { // clear is done from the map m_size = cont.m_size; m_maxSize = cont.m_maxSize; m_orbit = cont.m_orbit; m_nbUnknown = cont.m_nbUnknown; m_nbAttributes = cont.m_nbAttributes; m_lineCost = cont.m_lineCost; // blocks unsigned int sz = cont.m_holesBlocks.size(); m_holesBlocks.resize(sz); for (unsigned int i = 0; i < sz; ++i) m_holesBlocks[i] = new HoleBlockRef(*(cont.m_holesBlocks[i])); // blocks with free sz = cont.m_tableBlocksWithFree.size(); m_tableBlocksWithFree.resize(sz); for (unsigned int i = 0; i < sz; ++i) m_tableBlocksWithFree[i] = cont.m_tableBlocksWithFree[i]; // empty blocks sz = cont.m_tableBlocksEmpty.size(); m_tableBlocksEmpty.resize(sz); for (unsigned int i = 0; i < sz; ++i) m_tableBlocksEmpty[i] = cont.m_tableBlocksEmpty[i]; //attributes (warning attribute can have different numbers than in original) m_tableAttribs.reserve(m_nbAttributes); sz = cont.m_tableAttribs.size(); for (unsigned int i = 0; i < sz; ++i) { if (cont.m_tableAttribs[i] != NULL) { AttributeMultiVectorGen* ptr = cont.m_tableAttribs[i]->new_obj(); ptr->setName(cont.m_tableAttribs[i]->getName()); ptr->setOrbit(cont.m_tableAttribs[i]->getOrbit()); ptr->setIndex(m_tableAttribs.size()); ptr->setNbBlocks(cont.m_tableAttribs[i]->getNbBlocks()); ptr->copy(cont.m_tableAttribs[i]); // if (cont.m_tableAttribs[i]->toProcess()) // ptr->toggleProcess(); // else // ptr->toggleNoProcess(); m_tableAttribs.push_back(ptr); } } }
bool AttributeContainer::loadBin(CGoGNistream& fs) { if (m_attributes_registry_map == NULL) { CGoGNerr << "Attribute Registry non initialized"<< CGoGNendl; return false; } std::vector<unsigned int> bufferui; bufferui.resize(256); fs.read(reinterpret_cast<char*>(&(bufferui[0])), 8*sizeof(unsigned int)); //WARNING 9 hard coded unsigned int bs, szHB, szBWF, nbAtt; bs = bufferui[0]; szHB = bufferui[1]; szBWF = bufferui[2]; nbAtt = bufferui[3]; m_size = bufferui[4]; m_maxSize = bufferui[5]; m_orbit = bufferui[6]; m_nbUnknown = bufferui[7]; if (bs != _BLOCKSIZE_) { CGoGNerr << "Loading unavailable, different block sizes: "<<_BLOCKSIZE_<<" / " << bs << CGoGNendl; return false; } for (unsigned int j = 0; j < nbAtt; ++j) { std::string nameAtt; std::string typeAtt; /*unsigned int id = */AttributeMultiVectorGen::loadBinInfos(fs,nameAtt, typeAtt); std::map<std::string, RegisteredBaseAttribute*>::iterator itAtt = m_attributes_registry_map->find(typeAtt); if (itAtt == m_attributes_registry_map->end()) { CGoGNout << "Skipping non registred attribute of type name"<< typeAtt <<CGoGNendl; AttributeMultiVectorGen::skipLoadBin(fs); } else { RegisteredBaseAttribute* ra = itAtt->second; AttributeMultiVectorGen* amvg = ra->addAttribute(*this, nameAtt); // CGoGNout << "loading attribute " << nameAtt << " : " << typeAtt << CGoGNendl; amvg->loadBin(fs); } } m_holesBlocks.resize(szHB); // blocks for (unsigned int i = 0; i < szHB; ++i) { m_holesBlocks[i] = new HoleBlockRef; m_holesBlocks[i]->loadBin(fs); } // les indices des blocks libres m_tableBlocksWithFree.resize(szBWF); fs.read(reinterpret_cast<char*>(&(m_tableBlocksWithFree[0])), szBWF*sizeof(unsigned int)); return true; }
void AttributeContainer::copyFrom(const AttributeContainer& cont) { // clear is done from the map m_size = cont.m_size; m_maxSize = cont.m_maxSize; m_orbit = cont.m_orbit; m_nbUnknown = cont.m_nbUnknown; m_nbAttributes = cont.m_nbAttributes; m_lineCost = cont.m_lineCost; // blocks unsigned int sz = cont.m_holesBlocks.size(); m_holesBlocks.resize(sz); for (unsigned int i = 0; i < sz; ++i) m_holesBlocks[i] = new HoleBlockRef(*(cont.m_holesBlocks[i])); // free indices sz = cont.m_freeIndices.size(); m_freeIndices.resize(sz); for (unsigned int i = 0; i < sz; ++i) m_freeIndices[i] = cont.m_freeIndices[i]; // blocks with free sz = cont.m_tableBlocksWithFree.size(); m_tableBlocksWithFree.resize(sz); for (unsigned int i = 0; i < sz; ++i) m_tableBlocksWithFree[i] = cont.m_tableBlocksWithFree[i]; // empty blocks sz = cont.m_tableBlocksEmpty.size(); m_tableBlocksEmpty.resize(sz); for (unsigned int i = 0; i < sz; ++i) m_tableBlocksEmpty[i] = cont.m_tableBlocksEmpty[i]; //attributes (warning attribute can have different numbers than in original) m_tableAttribs.reserve(m_nbAttributes); sz = cont.m_tableAttribs.size(); for (unsigned int i = 0; i < sz; ++i) { if (cont.m_tableAttribs[i] != NULL) { std::string sub = cont.m_tableAttribs[i]->getName().substr(0, 5); if (sub != "Mark_") // Mark leaved by { AttributeMultiVectorGen* ptr = cont.m_tableAttribs[i]->new_obj(); ptr->setName(cont.m_tableAttribs[i]->getName()); ptr->setOrbit(cont.m_tableAttribs[i]->getOrbit()); ptr->setIndex(m_tableAttribs.size()); ptr->setNbBlocks(cont.m_tableAttribs[i]->getNbBlocks()); ptr->copy(cont.m_tableAttribs[i]); m_tableAttribs.push_back(ptr); } else { // get id of thread const std::string& str = cont.m_tableAttribs[i]->getName(); unsigned int thId = (unsigned int)(str[5]-'0'); if (str.size()==7) thId = 10*thId + (unsigned int)(sub[6]-'0'); // Mark always at the begin, because called after clear AttributeMultiVectorGen* ptr = m_tableAttribs[thId]; ptr->setNbBlocks(cont.m_tableAttribs[i]->getNbBlocks()); ptr->copy(cont.m_tableAttribs[i]); } } } }