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

correction de bugs pour les Containers

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