Commit 09bf6799 authored by CGoGN GIT Supervisor's avatar CGoGN GIT Supervisor

Merge branch 'master' of /home/jund/CGoGN

* 'master' of /home/jund/CGoGN:
  algo geom
  removeAttribute corriger pour mettre a jour le cout mémoire

Conflicts:
	src/Container/attributeContainer.cpp
parents 18ee79cb aaeee384
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <iostream>
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
#include <Algo/Geometry/inclusion.h>
#include "Geometry/vector_gen.h"
using namespace CGoGN;
struct PFP: public PFP_STANDARD
{
// definition of the type of the map
typedef EmbeddedMap2<Map2> MAP;
};
int main()
{
std::cout << "Check Algo/Geometry/inclusion.h" << std::endl;
std::cout << "Check Status : PARTIAL" << std::endl;
PFP::MAP map;
AttributeHandler<PFP::VEC3> position = map.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position");
map.newFace(3);
PFP::VEC3 ta(0,0,0);
PFP::VEC3 tb(5,0,0);
PFP::VEC3 tc(0,5,0);
Dart d = map.begin();
position[d] = ta;
position[map.phi1(d)]= tb;
position[map.phi1(map.phi1(d))] = tc;
PFP::VEC3 pIn1(1,1,0);
PFP::VEC3 pIn2(2,0,0);
PFP::VEC3 pOut(6,0,0);
std::cout << "Check isPointInConvexFace2D : Start" << std::endl;
if(!Algo::Geometry::isPointInConvexFace2D<PFP>(map,d,position,pIn1))
std::cout << "ERROR : isPointInConvexFace2D : face inclusion" << std::endl;
if(!Algo::Geometry::isPointInConvexFace2D<PFP>(map,d,position,pIn2))
std::cout << "ERROR : isPointInConvexFace2D : face inclusion" << std::endl;
if(Algo::Geometry::isPointInConvexFace2D<PFP>(map,d,position,pOut))
std::cout << "ERROR : isPointInConvexFace2D : face inclusion" << std::endl;
if(!Algo::Geometry::isPointInConvexFace2D<PFP>(map,d,position,ta))
std::cout << "ERROR : isPointInConvexFace2D : vertex inclusion" << std::endl;
if(!Algo::Geometry::isPointInConvexFace2D<PFP>(map,d,position,tb))
std::cout << "ERROR : isPointInConvexFace2D : vertex inclusion" << std::endl;
if(!Algo::Geometry::isPointInConvexFace2D<PFP>(map,d,position,tc))
std::cout << "ERROR : isPointInConvexFace2D : vertex inclusion" << std::endl;
std::cout << "Check isPointInConvexFace2D : Done" << std::endl;
// template <typename PFP>
// bool isConvex(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, bool CCW);
// template <typename PFP>
// bool isPointInVolume(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& point);
// template <typename PFP>
// bool isPointInConvexVolume(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& point, bool CCW);
// template <typename PFP>
// bool isPointInConvexFace(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& point, bool CCW);
// template <typename PFP>
// bool isPointOnEdge(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& point);
// template <typename PFP>
// bool isPointOnHalfEdge(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& point);
// template <typename PFP>
// bool isPointOnVertex(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& point);
// template <typename PFP>
// bool isConvexFaceInOrIntersectingTetrahedron(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3 points[4], bool CCW);
return 0;
}
......@@ -75,6 +75,7 @@ class ParticleCell2D : public ParticleBase
{
changeCell = false ;
if(!Geom::arePointsEquals(newCurrent, m_position)) {
// std::cout << "-- " << m_position << "--" << newCurrent << std::endl;
prevPos = m_position;
switch(state) {
......
......@@ -159,6 +159,7 @@ public:
* @param attribName name of the attribute to remove
* @return removed or not
*/
template <typename T>
bool removeAttribute(const std::string& attribName);
/**
......@@ -166,6 +167,7 @@ public:
* @param index index of the attribute to remove
* @return removed or not
*/
template <typename T>
bool removeAttribute(unsigned int index);
/**************************************
......@@ -192,6 +194,11 @@ public:
*/
unsigned int memoryTotalSize() const;
/**
* Memory cost of every used line
*/
unsigned int memorySize() const;
/**
* is the line used in the container
*/
......
......@@ -139,6 +139,57 @@ void AttributeContainer::addAttribute(const std::string& attribName, const std::
m_nbAttributes++;
}
template <typename T>
bool AttributeContainer::removeAttribute(const std::string& attribName)
{
unsigned int index = getAttributeIndex(attribName) ;
if (index == UNKNOWN)
{
std::cerr << "removeAttribute by name: attribute not found" << std::endl ;
return false ;
}
// delete the attribute
delete m_tableAttribs[index] ;
m_tableAttribs[index] = NULL ;
if (index == m_tableAttribs.size() - 1)
m_tableAttribs.pop_back() ;
else
m_freeIndices.push_back(index) ;
--m_nbAttributes ;
m_lineCost -= sizeof(T);
return true ;
}
template <typename T>
bool AttributeContainer::removeAttribute(unsigned int index)
{
if(m_tableAttribs[index] == NULL)
{
std::cerr << "removeAttribute by index: attribute not found" << std::endl ;
return false ;
}
// delete the attribute
delete m_tableAttribs[index] ;
m_tableAttribs[index] = NULL ;
if(index == m_tableAttribs.size() - 1)
m_tableAttribs.pop_back() ;
else
m_freeIndices.push_back(index) ;
--m_nbAttributes ;
m_lineCost -= sizeof(T);
return true ;
}
/**************************************
* INFO ABOUT THE CONTAINER *
**************************************/
......@@ -160,7 +211,12 @@ inline unsigned int AttributeContainer::capacity() const
inline unsigned int AttributeContainer::memoryTotalSize() const
{
return _BLOCKSIZE_ * (m_holesBlocks.size() * m_lineCost + 8);
return capacity() * (m_lineCost + 8);
}
inline unsigned int AttributeContainer::memorySize() const
{
return size() * (m_lineCost + 8);
}
inline bool AttributeContainer::used(unsigned int index) const
......
......@@ -36,7 +36,7 @@ Orientation2D testOrientation2D(const VEC3& P, const VEC3& Pa, const VEC3& Pb)
typedef typename VEC3::DATA_TYPE T ;
// const T min = std::numeric_limits<T>::min()*T(100);
const T min = 0.000001;
const T min = 0.0001;
// T wsof = (Pa[0]-P[0])*(P[1]-Pb[1])-(P[0]-Pb[0])*(Pa[1]-P[1]);
T wsof = (P[0]-Pa[0])*(Pb[1]-Pa[1])-(Pb[0]-Pa[0])*(P[1]-Pa[1]);
......
......@@ -38,7 +38,7 @@ template <typename T>
inline bool AttribMap::removeAttribute(AttributeHandler<T>& attr)
{
assert(attr.isValid() || !"Invalid attribute handler") ;
return m_attribs[attr.getOrbit()].removeAttribute(attr.getIndex()) ;
return m_attribs[attr.getOrbit()].removeAttribute<T>(attr.getIndex()) ;
}
template <typename T>
......
......@@ -50,56 +50,6 @@ AttributeContainer::~AttributeContainer()
{
}
/**************************************
* BASIC FEATURES *
**************************************/
bool AttributeContainer::removeAttribute(const std::string& attribName)
{
unsigned int index = getAttributeIndex(attribName) ;
if (index == UNKNOWN)
{
CGoGNerr << "removeAttribute by name: attribute not found" << CGoGNendl ;
return false ;
}
// delete the attribute
delete m_tableAttribs[index] ;
m_tableAttribs[index] = NULL ;
if (index == m_tableAttribs.size() - 1)
m_tableAttribs.pop_back() ;
else
m_freeIndices.push_back(index) ;
--m_nbAttributes ;
return true ;
}
bool AttributeContainer::removeAttribute(unsigned int index)
{
if(m_tableAttribs[index] == NULL)
{
CGoGNerr << "removeAttribute by index: attribute not found" << CGoGNendl ;
return false ;
}
// delete the attribute
delete m_tableAttribs[index] ;
m_tableAttribs[index] = NULL ;
if(index == m_tableAttribs.size() - 1)
m_tableAttribs.pop_back() ;
else
m_freeIndices.push_back(index) ;
--m_nbAttributes ;
return true ;
}
/**************************************
* INFO ABOUT ATTRIBUTES *
**************************************/
......
......@@ -197,7 +197,7 @@ void GenericMap::removeThreadMarker(unsigned int nb)
std::stringstream ss ;
ss << "Mark_"<< th ;
AttributeContainer& cellCont = m_attribs[i] ;
cellCont.removeAttribute(ss.str()) ;
cellCont.removeAttribute<Mark>(ss.str()) ;
m_markerTables[i][th] = NULL ;
}
}
......
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