Brève interruption de service ce midi pour augmentation de la mémoire 🤞

Commit 3619c00b authored by Pierre Kraemer's avatar Pierre Kraemer

correction de bugs pour les Containers

parent 443b9e63
......@@ -211,7 +211,7 @@ public:
AttributeHandler_IHM() : AttributeHandler<T>()
{}
AttributeHandler_IHM(GenericMap* m, unsigned int orbit, unsigned int index) : AttributeHandler<T>(m, orbit, index)
AttributeHandler_IHM(GenericMap* m, AttributeMultiVector<T>* amv) : AttributeHandler<T>(m, amv)
{}
AttributeMultiVector<T>* getDataVector() const
......
......@@ -47,21 +47,20 @@ AttributeHandler_IHM<T> ImplicitHierarchicalMap::addAttribute(unsigned int orbit
if(addNextLevelCell)
{
AttributeContainer& cellCont = m_attribs[orbit] ;
unsigned int index = cellCont.addAttribute<unsigned int>("nextLevelCell") ;
AttributeMultiVector<unsigned int>& amv = cellCont.getDataVector<unsigned int>(index) ;
m_nextLevelCell[orbit] = &amv ;
AttributeMultiVector<unsigned int>* amv = cellCont.addAttribute<unsigned int>("nextLevelCell") ;
m_nextLevelCell[orbit] = amv ;
for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
amv[i] = EMBNULL ;
amv->operator[](i) = EMBNULL ;
}
return AttributeHandler_IHM<T>(this, h.getOrbit(), h.getIndex()) ;
return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
}
template <typename T>
AttributeHandler_IHM<T> ImplicitHierarchicalMap::getAttribute(unsigned int orbit, const std::string& nameAttr)
{
AttributeHandler<T> h = Map2::getAttribute<T>(orbit, nameAttr) ;
return AttributeHandler_IHM<T>(this, h.getOrbit(), h.getIndex()) ;
return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
}
/***************************************************
......
......@@ -347,18 +347,18 @@ public:
* @param attrIndex index of the attribute
*/
template<typename T>
AttributeMultiVector<T>& getDataVector(unsigned int attrIndex);
AttributeMultiVector<T>* getDataVector(unsigned int attrIndex);
AttributeMultiVectorGen& getVirtualDataVector(unsigned int attrIndex);
AttributeMultiVectorGen* getVirtualDataVector(unsigned int attrIndex);
/**
* get an AttributeMultiVector
* @param attribName name of the attribute
*/
template<typename T>
AttributeMultiVector<T>& getDataVector(const std::string& attribName);
AttributeMultiVector<T>* getDataVector(const std::string& attribName);
AttributeMultiVectorGen& getVirtualDataVector(const std::string& attribName);
AttributeMultiVectorGen* getVirtualDataVector(const std::string& attribName);
/**
* get a given element of a given attribute
......
......@@ -262,38 +262,38 @@ inline bool AttributeContainer::swapAttributes(unsigned int index1, unsigned int
**************************************/
template <typename T>
AttributeMultiVector<T>& AttributeContainer::getDataVector(unsigned int attrIndex)
AttributeMultiVector<T>* AttributeContainer::getDataVector(unsigned int attrIndex)
{
assert(attrIndex < m_tableAttribs.size() || !"getDataVector: attribute index out of bounds");
assert(m_tableAttribs[attrIndex] != NULL || !"getDataVector: attribute does not exist");
AttributeMultiVector<T>* atm = dynamic_cast<AttributeMultiVector<T>*>(m_tableAttribs[attrIndex]);
assert((atm != NULL) || !"getDataVector: wrong type");
return *atm;
return atm;
}
inline AttributeMultiVectorGen& AttributeContainer::getVirtualDataVector(unsigned int attrIndex)
inline AttributeMultiVectorGen* AttributeContainer::getVirtualDataVector(unsigned int attrIndex)
{
return *(m_tableAttribs[attrIndex]);
return m_tableAttribs[attrIndex];
}
template <typename T>
AttributeMultiVector<T>& AttributeContainer::getDataVector(const std::string& attribName)
AttributeMultiVector<T>* AttributeContainer::getDataVector(const std::string& attribName)
{
unsigned int index = getAttributeIndex(attribName) ;
assert(index != UNKNOWN) ;
if(index == UNKNOWN)
return NULL ;
AttributeMultiVector<T>* atm = dynamic_cast<AttributeMultiVector<T>*>(m_tableAttribs[index]);
assert((atm != NULL) || !"getDataVector: wrong type");
return *atm;
return atm;
}
inline AttributeMultiVectorGen& AttributeContainer::getVirtualDataVector(const std::string& attribName)
inline AttributeMultiVectorGen* AttributeContainer::getVirtualDataVector(const std::string& attribName)
{
unsigned int index = getAttributeIndex(attribName) ;
assert(index != UNKNOWN) ;
return *(m_tableAttribs[index]);
return m_tableAttribs[index];
}
template <typename T>
......
......@@ -30,8 +30,7 @@ inline AttributeHandler<T> AttribMap::addAttribute(unsigned int orbit, const std
{
if(!isOrbitEmbedded(orbit))
addEmbedding(orbit) ;
AttributeContainer& cellCont = m_attribs[orbit] ;
AttributeMultiVector<T>* amv = cellCont.addAttribute<T>(nameAttr) ;
AttributeMultiVector<T>* amv = m_attribs[orbit].addAttribute<T>(nameAttr) ;
return AttributeHandler<T>(this, amv) ;
}
......@@ -46,8 +45,8 @@ template <typename T>
inline AttributeHandler<T> AttribMap::getAttribute(unsigned int orbit, const std::string& nameAttr)
{
assert(isOrbitEmbedded(orbit) || !"Invalid parameter: orbit not embedded");
AttributeMultiVector<T>& amv = m_attribs[orbit].getDataVector<T>(nameAttr) ;
return AttributeHandler<T>(this, &amv) ;
AttributeMultiVector<T>* amv = m_attribs[orbit].getDataVector<T>(nameAttr) ;
return AttributeHandler<T>(this, amv) ;
}
template <typename T>
......
......@@ -27,10 +27,8 @@ namespace CGoGN
template <typename T>
AttributeHandler<T>::AttributeHandler(GenericMap* m, AttributeMultiVector<T>* amv):
m_map(m)
{
m_attrib = amv ;
}
m_map(m), m_attrib(amv)
{}
template <typename T>
AttributeHandler<T>::AttributeHandler(const AttributeHandler<T>& ta):
......@@ -81,9 +79,9 @@ const std::string& AttributeHandler<T>::name() const
template <typename T>
bool AttributeHandler<T>::isValid() const
{
return (m_attrib->getIndex() != AttributeContainer::UNKNOWN &&
m_map != NULL &&
m_attrib != NULL) ;
return (m_map != NULL &&
m_attrib != NULL &&
m_attrib->getIndex() != AttributeContainer::UNKNOWN) ;
}
template <typename T>
......
......@@ -230,22 +230,6 @@ public:
*/
AttributeContainer& getAttributeContainer(unsigned int orbit);
/**
* get a multi vector of attribute (direct access with [i])
* @param orbit orbit of attribute
* @param index index of attribute
*/
template <typename T>
AttributeMultiVector<T>& getAttributeVector(unsigned int orbit, unsigned int index);
/**
* get a virtual multi vector of attribute
* No access to data, useful for access to address (VBO)
* @param orbit orbit of attribute
* @param index index of attribute
*/
AttributeMultiVectorGen& getAttributeVectorGen(unsigned int orbit, unsigned int index);
/**
* get a multi vector of marker attribute (direct access with [i])
* @param orbit code
......
......@@ -221,19 +221,6 @@ inline AttributeContainer& GenericMap::getAttributeContainer(unsigned int orbit)
return m_attribs[orbit] ;
}
template <typename T>
inline AttributeMultiVector<T>& GenericMap::getAttributeVector(unsigned int orbit, unsigned int index)
{
assert(index != AttributeContainer::UNKNOWN) ;
return m_attribs[orbit].getDataVector<T>(index) ;
}
inline AttributeMultiVectorGen& GenericMap::getAttributeVectorGen(unsigned int orbit, unsigned int index)
{
assert(index != AttributeContainer::UNKNOWN) ;
return m_attribs[orbit].getVirtualDataVector(index) ;
}
inline AttributeMultiVector<Mark>* GenericMap::getMarkerVector(unsigned int orbit)
{
return m_markerTables[orbit] ;
......
......@@ -169,9 +169,9 @@ void GenericMap::update_m_emb_afterLoad()
{
unsigned int orb = listeNames[i][4]-'0'; // easy atoi computation for one char;
AttributeMultiVector<unsigned int>& amv = cont.getDataVector<unsigned int>(i);
m_embeddings[orb] = &amv ;
std::cout << "Ajoute m_emb["<<orb<<"]:"<< i <<std::endl;
AttributeMultiVector<unsigned int>* amv = cont.getDataVector<unsigned int>(i);
m_embeddings[orb] = amv ;
std::cout << "Ajoute m_emb[" << orb << "] : " << i << std::endl;
}
}
}
......
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