From 48b7797ee5e8131ebb5669224e285cc555ee731c Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Thu, 27 Jan 2011 14:31:30 +0100 Subject: [PATCH] Test commit --- Apps/Examples/SocialAgents/CMakeLists.txt | 6 +- .../SocialAgents/include/env_generator.hpp | 4 +- Apps/Examples/SocialAgents/src/env_map.cpp | 28 +++++++-- Apps/Examples/SocialAgents/src/simulator.cpp | 9 +-- Apps/Examples/SocialAgents/src/viewer.cpp | 44 +++++++------ Apps/Examples/ihmView.cpp | 1 - Apps/Examples/miniTest.cpp | 2 +- include/Algo/ImplicitHierarchicalMesh/ihm.hpp | 22 ------- .../ImplicitHierarchicalMesh/subdivision.hpp | 2 +- include/Container/attrib_container.h | 41 +++++++++--- include/Container/holeblockref.h | 63 +++++++++++++------ include/Container/sizeblock.h | 35 ++++++++--- include/Topology/generic/functor.h | 33 ---------- include/Topology/generic/genericmap.h | 8 ++- include/Topology/generic/genericmap.hpp | 61 +++++++++++++++++- include/Topology/map/map1.hpp | 6 +- include/Topology/map/map2.h | 6 +- src/Container/holeblockref.cpp | 58 ++++++++++------- src/Topology/generic/genericmap.cpp | 2 +- src/Topology/map/map2.cpp | 8 +-- 20 files changed, 273 insertions(+), 166 deletions(-) diff --git a/Apps/Examples/SocialAgents/CMakeLists.txt b/Apps/Examples/SocialAgents/CMakeLists.txt index cc8b2763..de5847d6 100644 --- a/Apps/Examples/SocialAgents/CMakeLists.txt +++ b/Apps/Examples/SocialAgents/CMakeLists.txt @@ -2,14 +2,12 @@ cmake_minimum_required(VERSION 2.6) project(SocialAgents) -SET(CMAKE_BUILD_TYPE Debug) +SET(CMAKE_BUILD_TYPE Release) link_directories( ${CGoGN_ROOT_DIR}/lib/Debug/ ${CGoGN_ROOT_DIR}/lib/Release/) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -O3") - # define includes path include_directories( /usr/include/libxml2/ @@ -22,8 +20,6 @@ include_directories( ${CGoGN_ROOT_DIR}/ThirdParty/Zinri ) - - #define exec to compile add_executable(socialAgents ./src/viewer.cpp ./src/env_map.cpp ./src/agent.cpp ./src/simulator.cpp ) target_link_libraries( socialAgents container topology utils algo ${COMMON_LIBS} ) diff --git a/Apps/Examples/SocialAgents/include/env_generator.hpp b/Apps/Examples/SocialAgents/include/env_generator.hpp index a04ebae4..d5e8d6f1 100644 --- a/Apps/Examples/SocialAgents/include/env_generator.hpp +++ b/Apps/Examples/SocialAgents/include/env_generator.hpp @@ -34,7 +34,7 @@ void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& close // sideSize *= 0.2f; unsigned int nbBuilding=1000; float height = sideSize/2.0f; - unsigned int side = 40; + unsigned int side = 25; generateGrid(map,position,side,side,sideSize,closeMark); Dart dEnd = map.end(); @@ -568,4 +568,4 @@ void generateBridge(typename PFP::MAP& map, EMBV& position, unsigned int cX, uns } -} \ No newline at end of file +} diff --git a/Apps/Examples/SocialAgents/src/env_map.cpp b/Apps/Examples/SocialAgents/src/env_map.cpp index 21f3510d..6f845a06 100644 --- a/Apps/Examples/SocialAgents/src/env_map.cpp +++ b/Apps/Examples/SocialAgents/src/env_map.cpp @@ -227,7 +227,7 @@ void EnvMap::insertObstacleOfFace(PFP::AGENTS agents,const Dart d) (*it)->insertObstacleNeighbor(dd); // } } - return; +// return; } dd = map.phi1(dd); } while (dd!=d); @@ -340,7 +340,7 @@ void EnvMap::addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo) void EnvMap::updateMap() { // simplifyFaces(); - subdivideFaces(); + subdivideFaces() ; map.setCurrentLevel(map.getMaxLevel()) ; } @@ -352,18 +352,38 @@ void EnvMap::subdivideFaces() if(!m.isMarked(d)) { m.mark(d) ; - if(!closeMark.isMarked(d) && agentvect[d].size() > 10) + if(!closeMark.isMarked(d) && agentvect[d].size() > 8) { if(!map.faceIsSubdivided(d)) { std::vector agents ; agents.swap(agentvect[d]) ; + + unsigned int cur = map.getCurrentLevel() ; + unsigned int fLevel = map.faceLevel(d) ; + map.setCurrentLevel(fLevel) ; + std::vector marked ; + Dart fit = d ; + do + { + if(closeMark.isMarked(map.phi2(fit))) + marked.push_back(fit) ; + fit = map.phi1(fit) ; + } while(fit != d) ; + Algo::IHM::subdivideFace(map, d, position) ; + + map.setCurrentLevel(fLevel + 1) ; + for(std::vector::iterator it = marked.begin(); it != marked.end(); ++it) + closeMark.mark(map.phi2(*it)) ; + for(PFP::AGENTS::iterator it = agents.begin(); it != agents.end(); ++it) { - this->resetAgentInFace(*it) ; + resetAgentInFace(*it) ; agentvect[(*it)->part->d].push_back(*it) ; } + + map.setCurrentLevel(cur) ; } } } diff --git a/Apps/Examples/SocialAgents/src/simulator.cpp b/Apps/Examples/SocialAgents/src/simulator.cpp index 4e9204b0..2a67ef1b 100644 --- a/Apps/Examples/SocialAgents/src/simulator.cpp +++ b/Apps/Examples/SocialAgents/src/simulator.cpp @@ -14,16 +14,17 @@ Simulator::Simulator() : agents_(), defaultAgent_(0), globalTime_(0.0f), timeSte // CGoGN::CityGenerator::generateGrid(envMap.map,envMap.position,100,100,50.0f,envMap.closeMark); envMap.sideSize = 70.0f; -// CGoGN::CityGenerator::generateSmallCity(envMap.map,envMap.position,envMap.closeMark,envMap.sideSize); + CGoGN::CityGenerator::generateSmallCity(envMap.map,envMap.position,envMap.closeMark,envMap.sideSize); - CGoGN::CityGenerator::generateAbsolutSpiralOfDeath(envMap.map,envMap.position,envMap.closeMark,2000,0.25,110,100); +// CGoGN::CityGenerator::generateAbsolutSpiralOfDeath(envMap.map,envMap.position,envMap.closeMark,2000,0.25,110,100); - std::cout << "simplify" << std::endl; +// std::cout << "simplify" << std::endl; // envMap.simplify(); envMap.map.init(); std::cout << "setup scenario" << std::endl; - setupHelicoidScenario(1,50); +// setupHelicoidScenario(1,50); + setupScenario(); // Dart dStop=envMap.map.begin(); // for(unsigned int i=0;i<5000;++i) envMap.map.next(dStop); diff --git a/Apps/Examples/SocialAgents/src/viewer.cpp b/Apps/Examples/SocialAgents/src/viewer.cpp index 4fcf8390..620364f8 100644 --- a/Apps/Examples/SocialAgents/src/viewer.cpp +++ b/Apps/Examples/SocialAgents/src/viewer.cpp @@ -223,13 +223,13 @@ void MyGlutWin::myRedraw() // } // glEnd(); - glBegin(GL_POINTS); - for(unsigned int i = 0; i<4;++i) { - for(std::vector::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) { - glVertex3fv(&(*it)[0]); - } - } - glEnd(); +// glBegin(GL_POINTS); +// for(unsigned int i = 0; i<4;++i) { +// for(std::vector::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) { +// glVertex3fv(&(*it)[0]); +// } +// } +// glEnd(); unsigned int i=0; for(std::vector::iterator it = sim->agents_.begin() ; it != sim->agents_.end() ; ++ it, ++i) { @@ -244,7 +244,7 @@ void MyGlutWin::myRedraw() //draw containing center face glColor3f(0,0,1); glLineWidth(4.0f); - renderFace(sim->envMap,(*it)->nearestDart); + renderFace(sim->envMap,(*it)->part->d); glLineWidth(1.0f); // //draw displacement @@ -254,18 +254,18 @@ void MyGlutWin::myRedraw() // glEnd(); // //and prediction triangle -// glColor3f(((*it)->part->state)/3.0f,((*it)->part->state%2),0); -// glLineWidth(5.0f); -// renderPredictionTriangle(sim->envMap,(*it)->nearestDart,(*it)->part->m_position); -// glLineWidth(1.0f); + glColor3f(((*it)->part->state)/3.0f,((*it)->part->state%2),0); + glLineWidth(5.0f); + renderPredictionTriangle(sim->envMap,(*it)->part->d,(*it)->part->m_position); + glLineWidth(1.0f); //draw next goal - glBegin(GL_LINES); - glVertex3f((*it)->part->m_position[0],(*it)->part->m_position[1],(*it)->part->m_position[2]); - glVertex3f((*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][0], - (*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][1], - (*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][2]); - glEnd(); +// glBegin(GL_LINES); +// glVertex3f((*it)->part->m_position[0],(*it)->part->m_position[1],(*it)->part->m_position[2]); +// glVertex3f((*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][0], +// (*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][1], +// (*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][2]); +// glEnd(); } // glCircle3i((*it)->position_[0],(*it)->position_[1],(*it)->neighborDist_); @@ -403,8 +403,8 @@ void MyGlutWin::animate(void) // std::cout << "pos to reach : " << posToReach << std::endl; // std::cout << sim->getGlobalTime() << " " << std::endl; updateVisualization(sim); -// sim->setPreferredVelocities(posToReach); - sim->setPreferredPathVelocities(); + sim->setPreferredVelocities(posToReach); +// sim->setPreferredPathVelocities(); sim->doStep(); // sim->envMap.simplify(); glutPostRedisplay(); @@ -628,6 +628,10 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) render_anim=!render_anim; } break; + case 'c': { + sim->envMap.map.check(); + } + break; } updateUI(); diff --git a/Apps/Examples/ihmView.cpp b/Apps/Examples/ihmView.cpp index e86f2bd7..ec60720a 100644 --- a/Apps/Examples/ihmView.cpp +++ b/Apps/Examples/ihmView.cpp @@ -39,7 +39,6 @@ #include "Algo/Geometry/boundingbox.h" #include "Algo/Render/map_glRender.h" #include "Algo/Render/vbo_MapRender.h" -#include "Topology/generic/ecell.h" #include "Algo/Render/topo_vboRender.h" using namespace CGoGN ; diff --git a/Apps/Examples/miniTest.cpp b/Apps/Examples/miniTest.cpp index 9a5148eb..681e8d8f 100644 --- a/Apps/Examples/miniTest.cpp +++ b/Apps/Examples/miniTest.cpp @@ -531,7 +531,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) unsigned int nbVertices = myMap.getNbOrbits(VERTEX_ORBIT) ; GLint t1 = glutGet(GLUT_ELAPSED_TIME); - Algo::Decimation::decimate(myMap, Algo::Decimation::S_EdgeLength, Algo::Decimation::A_QEM, position, nbVertices * 0.95) ; + Algo::Decimation::decimate(myMap, Algo::Decimation::S_QEM, Algo::Decimation::A_QEM, position, nbVertices * 0.75) ; GLint t2 = glutGet(GLUT_ELAPSED_TIME); GLfloat seconds = (t2 - t1) / 1000.0f; std::cout << "decimation: "<< seconds << "sec" << std::endl; diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm.hpp b/include/Algo/ImplicitHierarchicalMesh/ihm.hpp index d9092cc0..c1f48d3e 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/ihm.hpp @@ -84,11 +84,7 @@ inline Dart ImplicitHierarchicalMap::phi1(Dart d) else { while(m_edgeId[it] != edgeId) - { - if(Map2::phi2(it) == it) - std::cout << "fix point in the middle" << std::endl ; it = Map2::alpha_1(it) ; - } } } while(!finished) ; return it ; @@ -100,7 +96,6 @@ inline Dart ImplicitHierarchicalMap::phi_1(Dart d) bool finished = false ; Dart it = Map2::phi_1(d) ; unsigned int edgeId = m_edgeId[it] ; - do { if(m_dartLevel[it] <= m_curLevel) @@ -112,21 +107,6 @@ inline Dart ImplicitHierarchicalMap::phi_1(Dart d) it = Map2::phi_1(Map2::phi2(it)) ; } } while(!finished) ; - -// do -// { -// if(m_dartLevel[it] <= m_curLevel) -// finished = true ; -// else -// { -// do -// { -// it = Map2::alpha1(it) ; -// } while(m_edgeId[it] != edgeId) ; -// it = Map2::phi2(it) ; -// } -// } while(!finished) ; - return it ; } @@ -329,8 +309,6 @@ inline unsigned int ImplicitHierarchicalMap::edgeLevel(Dart d) return ld < ldd ? ldd : ld ; // insertion levels of its two darts } - - template T& AttributeHandler_IHM::operator[](Dart d) { diff --git a/include/Algo/ImplicitHierarchicalMesh/subdivision.hpp b/include/Algo/ImplicitHierarchicalMesh/subdivision.hpp index 63ec08ac..917eb820 100644 --- a/include/Algo/ImplicitHierarchicalMesh/subdivision.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/subdivision.hpp @@ -128,7 +128,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position while(dd != ne) // turn around the face and insert new edges { // linked to the central vertex Dart next = map.phi1(map.phi1(dd)) ; - map.splitFace(dd, map.phi1(ne)) ; + map.splitFace(map.phi1(ne), dd) ; Dart nne = map.alpha1(dd) ; id = map.getNewEdgeId() ; map.setEdgeId(nne, id) ; diff --git a/include/Container/attrib_container.h b/include/Container/attrib_container.h index d6f09bbe..ca51c5a4 100644 --- a/include/Container/attrib_container.h +++ b/include/Container/attrib_container.h @@ -1,9 +1,33 @@ -#ifndef __MULTIATTRIB_CONTAINER__ -#define __MULTIATTRIB_CONTAINER__ - -#include "sizeblock.h" -#include "holeblockref.h" -#include "attribmv.h" +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __ATTRIB_CONTAINER__ +#define __ATTRIB_CONTAINER__ + +#include "Container/sizeblock.h" +#include "Container/holeblockref.h" +#include "Container/attribmv.h" #include #include @@ -105,7 +129,6 @@ protected: std::map< std::string, RegisteredBaseAttribute* >* m_attributes_registry_map; public: - /** * constante d'attribut inconnu */ @@ -232,8 +255,8 @@ public: unsigned int getNbAttributes() { - for (unsigned int i =0; i #include -#include "sizeblock.h" +#include "Container/sizeblock.h" namespace CGoGN { -//WARNING WE USED SHORT INT BLOCK_SIZE MUST BE < 65536 + +//WARNING WE USE SHORT INT BLOCK_SIZE MUST BE < 65536 + class HoleBlockRef { protected: /** * Table of free index */ - uint* m_tableFree; - uint m_nbfree; + unsigned int* m_tableFree; + unsigned int m_nbfree; /** * Reference counter (if 0 it is a hole) */ - uint* m_refCount; - uint m_nbref; + unsigned int* m_refCount; + unsigned int m_nbref; /** * nb element in block */ - uint m_nb; + unsigned int m_nb; public: /** @@ -50,16 +76,16 @@ public: * @param nbEltsMax (IN/OUT) max number of element stored * @return index on new element */ - uint newRefElt(uint& nbEltsMax); + unsigned int newRefElt(unsigned int& nbEltsMax); /** * remove an element */ - inline void removeElt(uint idx) + inline void removeElt(unsigned int idx) { m_nb--; - m_tableFree[m_nbfree++]=idx; - m_refCount[idx]=0; + m_tableFree[m_nbfree++] = idx; + m_refCount[idx] = 0; } /** @@ -109,12 +135,12 @@ public: * @param bf ptr on the block of other line * @param j index of the other line in bf */ - void overwrite(int i, HoleBlockRef *bf, int j); + void overwrite(unsigned int i, HoleBlockRef *bf, unsigned int j); /** * increment ref counter of element i */ - inline void ref(uint i) + inline void ref(unsigned int i) { m_refCount[i]++; } @@ -123,7 +149,7 @@ public: * decrement ref counter of element i * @return true if ref=0 and element has been destroyed */ - inline bool unref(uint i) + inline bool unref(unsigned int i) { m_refCount[i]--; if (m_refCount[i] == 1) @@ -137,22 +163,21 @@ public: /** * set ref counter of element i with j */ - inline void setNbRefs(uint i, uint nb) { m_refCount[i] = nb; } + inline void setNbRefs(unsigned int i, unsigned int nb) { m_refCount[i] = nb; } /** * number of references of element i * @return the number of references (0 = no elements) */ - inline uint nbRefs(uint i) { return m_refCount[i]; } + inline unsigned int nbRefs(unsigned int i) { return m_refCount[i]; } - bool updateHoles(uint nb); + bool updateHoles(unsigned int nb); void saveBin(CGoGNostream& fs); bool loadBin(CGoGNistream& fs); }; -} +} // namespace CGoGN #endif - diff --git a/include/Container/sizeblock.h b/include/Container/sizeblock.h index 95312601..a2266af4 100644 --- a/include/Container/sizeblock.h +++ b/include/Container/sizeblock.h @@ -1,22 +1,37 @@ -/* - * sizeblock.h - * - * Created on: Jun 10, 2010 - * Author: thery - */ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ -#ifndef SIZEBLOCK_H_ -#define SIZEBLOCK_H_ +#ifndef _SIZEBLOCK_H_ +#define _SIZEBLOCK_H_ #include "gzstream.h" #define _BLOCKSIZE_ 4096 -typedef unsigned int uint; //typedef std::ifstream CGoGNistream; //typedef std::ofstream CGoGNostream; - /// use everywhere in save/load compressed stream typedef igzstream CGoGNistream; typedef ogzstream CGoGNostream; diff --git a/include/Topology/generic/functor.h b/include/Topology/generic/functor.h index 34aa8a42..71b517ac 100644 --- a/include/Topology/generic/functor.h +++ b/include/Topology/generic/functor.h @@ -120,39 +120,6 @@ public: } }; -class FunctorGetLazyEmb: public FunctorType -{ -protected: - AttribMultiVect& m_emb; - unsigned int m_val; - std::vector m_darts; - -public: - FunctorGetLazyEmb(AttribMultiVect& emb): m_emb(emb), m_val(EMBNULL) - { - m_darts.reserve(8) ; - } - - bool operator()(Dart d) - { - if (m_emb[d.index] != EMBNULL) - { - m_val = m_emb[d.index]; - return true; - } - m_darts.push_back(d); - return false; - } - - unsigned int getVal() - { - for(std::vector::iterator it = m_darts.begin(); it != m_darts.end(); ++it) - m_emb[it->index] = m_val; - - return m_val; - } -}; - // Search Functor: look for a given dart when applied /********************************************************/ diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index cb6ebe5a..418e917a 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -127,7 +127,7 @@ protected: /** * Add a dart to the map */ - Dart newDart(); + virtual Dart newDart(); /** * Erase a dart of the map @@ -154,6 +154,12 @@ public: */ bool isOrbitEmbedded(unsigned int orbit) const; + /** + * return a pointer to the Dart attribute vector that store the embedding of the given orbit + * (may be NULL if the orbit is not embedded) + */ + AttribMultiVect* getEmbeddingAttributeVector(unsigned int orbit) const; + /** * return the number of embedded orbits (including DART_ORBIT) */ diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index b49162b1..b91eed8f 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -42,13 +42,21 @@ inline Dart GenericMap::newDart() for(unsigned int i = 0; i < NB_ORBITS; ++i) if (m_embeddings[i]) (*m_embeddings[i])[d.index] = EMBNULL ; - return d ; } inline void GenericMap::deleteDart(Dart d) { m_attribs[DART_ORBIT].removeLine(d.index) ; + for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) + { + if (m_embeddings[orbit]) + { + unsigned int emb = (*m_embeddings[orbit])[d.index] ; + if(emb != EMBNULL) + m_attribs[orbit].unrefLine(emb) ; + } + } } inline bool GenericMap::isDartValid(Dart d) @@ -70,6 +78,11 @@ inline bool GenericMap::isOrbitEmbedded(unsigned int orbit) const return (orbit == DART_ORBIT) || (m_embeddings[orbit] != NULL) ; } +inline AttribMultiVect* GenericMap::getEmbeddingAttributeVector(unsigned int orbit) const +{ + return m_embeddings[orbit] ; +} + inline unsigned int GenericMap::nbEmbeddings() const { unsigned int nb = 0; @@ -90,7 +103,51 @@ inline unsigned int GenericMap::getEmbedding(Dart d, unsigned int orbit) if(emb != EMBNULL) return emb ; - FunctorGetLazyEmb fle(*m_embeddings[orbit]); + class FunctorGetLazyEmb: public FunctorType + { + protected: + GenericMap& m_map; + unsigned int m_orbit; + AttribMultiVect* m_emb; + unsigned int m_val; + std::vector m_darts; + + public: + FunctorGetLazyEmb(GenericMap& map, unsigned int orbit): + m_map(map), m_orbit(orbit), m_val(EMBNULL) + { + m_emb = m_map.getEmbeddingAttributeVector(orbit) ; + m_darts.reserve(8) ; + } + + bool operator()(Dart d) + { + if ((*m_emb)[d.index] != EMBNULL) + { + m_val = (*m_emb)[d.index]; + return true; + } + m_darts.push_back(d); + return false; + } + + unsigned int getVal() + { + if(m_val != EMBNULL) + { + AttribContainer& cont = m_map.getAttributeContainer(m_orbit) ; + for(std::vector::iterator it = m_darts.begin(); it != m_darts.end(); ++it) + { + (*m_emb)[it->index] = m_val; + cont.refLine(m_val) ; + } + } + + return m_val; + } + }; + + FunctorGetLazyEmb fle(*this, orbit); foreach_dart_of_orbit(orbit, d, fle); return fle.getVal(); diff --git a/include/Topology/map/map1.hpp b/include/Topology/map/map1.hpp index 90fb6a71..075741f0 100644 --- a/include/Topology/map/map1.hpp +++ b/include/Topology/map/map1.hpp @@ -140,7 +140,7 @@ inline void Map1::deleteFace(Dart d) inline void Map1::cutEdge(Dart d) { Dart e = newDart() ; // Create a new dart - phi1sew(d,e) ; // Insert dart e between d and phi1(d) + phi1sew(d, e) ; // Insert dart e between d and phi1(d) } inline void Map1::collapseEdge(Dart d) @@ -152,8 +152,8 @@ inline void Map1::collapseEdge(Dart d) inline void Map1::splitFace(Dart d, Dart e) { assert(d != e && sameOrientedFace(d, e)) ; - Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart after d) - Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart after e) + Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d) + Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e) phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts } diff --git a/include/Topology/map/map2.h b/include/Topology/map/map2.h index 17f8059b..78db0ab4 100644 --- a/include/Topology/map/map2.h +++ b/include/Topology/map/map2.h @@ -235,6 +235,7 @@ public: */ void reverseOrientation(); + // TODO a mettre en algo /** * compute the topological dual of the current map */ @@ -287,11 +288,10 @@ public: */ bool isTriangular() ; + // TODO a mettre en algo /** * Check if map is complete - */ - /* TODO devrait disparaitre : - * Le test doit être fait à l'import. + * Should be executed after import */ virtual bool check(); //@} diff --git a/src/Container/holeblockref.cpp b/src/Container/holeblockref.cpp index 050f4792..8271272c 100644 --- a/src/Container/holeblockref.cpp +++ b/src/Container/holeblockref.cpp @@ -1,9 +1,27 @@ -/* - * holeblockref.cpp - * - * Created on: Jun 10, 2010 - * Author: thery - */ +/******************************************************************************* +* 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 "Container/holeblockref.h" #include @@ -25,19 +43,19 @@ namespace CGoGN HoleBlockRef::HoleBlockRef(): m_nbfree(0),m_nbref(0),m_nb(0) { - m_tableFree = new uint[_BLOCKSIZE_]; - m_refCount = new uint[_BLOCKSIZE_]; + m_tableFree = new unsigned int[_BLOCKSIZE_]; + m_refCount = new unsigned int[_BLOCKSIZE_]; } HoleBlockRef::~HoleBlockRef() { - delete[] m_tableFree; - delete[] m_refCount; + delete[] m_tableFree; + delete[] m_refCount; } void HoleBlockRef::swap(HoleBlockRef& hb) { - uint temp = m_nbfree; + unsigned int temp = m_nbfree; m_nbfree = hb.m_nbfree; hb.m_nbfree = temp; @@ -49,21 +67,21 @@ void HoleBlockRef::swap(HoleBlockRef& hb) m_nb = hb.m_nb; hb.m_nb = temp; - uint* ptr = m_tableFree; + unsigned int* ptr = m_tableFree; m_tableFree = hb.m_tableFree; hb.m_tableFree = ptr; - uint* ptr2 = m_refCount; + unsigned int* ptr2 = m_refCount; m_refCount = hb.m_refCount; hb.m_refCount = ptr2; } -uint HoleBlockRef::newRefElt(uint& nbEltsMax) +unsigned int HoleBlockRef::newRefElt(unsigned int& nbEltsMax) { // no hole then add a line at the end of block if (m_nbfree == 0) { - uint nbElts = m_nbref; + unsigned int nbElts = m_nbref; m_refCount[m_nbref++] = 1; @@ -72,7 +90,7 @@ uint HoleBlockRef::newRefElt(uint& nbEltsMax) return nbElts; } - uint index = m_tableFree[--m_nbfree]; + unsigned int index = m_tableFree[--m_nbfree]; m_refCount[index] = 1; @@ -84,7 +102,6 @@ bool HoleBlockRef::compressFree() { if (m_nb) { - m_nbfree = 0; m_nbref = m_nb; return false; @@ -92,7 +109,7 @@ bool HoleBlockRef::compressFree() return true; } -void HoleBlockRef::overwrite(int i, HoleBlockRef *bf, int j) +void HoleBlockRef::overwrite(unsigned int i, HoleBlockRef *bf, unsigned int j) { m_refCount[i] = bf->m_refCount[j]; bf->m_refCount[j] = 0; @@ -144,7 +161,7 @@ void HoleBlockRef::saveBin(CGoGNostream& fs) bool HoleBlockRef::loadBin(CGoGNistream& fs) { - uint numbers[3]; + unsigned int numbers[3]; fs.read(reinterpret_cast(numbers), 3*sizeof(uint)); m_nb = numbers[0]; @@ -157,5 +174,4 @@ bool HoleBlockRef::loadBin(CGoGNistream& fs) return true; } -} - +} // namespace CGoGN diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index 5aa2ac59..a64020ca 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -151,7 +151,7 @@ void GenericMap::update_m_emb_afterLoad() std::vector listeNames; cont.getAttributesStrings(listeNames); - // chreck if there are EMB_X attributes + // check if there are EMB_X attributes for (unsigned int i = 0; i < listeNames.size(); ++i) { std::string sub = listeNames[i].substr(0,listeNames[i].size()-1); diff --git a/src/Topology/map/map2.cpp b/src/Topology/map/map2.cpp index 068ffba0..a23d005e 100644 --- a/src/Topology/map/map2.cpp +++ b/src/Topology/map/map2.cpp @@ -482,7 +482,7 @@ bool Map2::check() { std::cout << "Check: topology begin" << std::endl; DartMarker m(*this); - for(Dart d = begin(); d != end(); next(d)) + for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d)) { Dart d2 = phi2(d); if (phi2(d2) != d) // phi2 involution ? @@ -494,7 +494,7 @@ bool Map2::check() Dart d1 = phi1(d); if (phi_1(d1) != d) // phi1 a une image correcte ? { - std::cout << "Check: unconsistent phi_1 link" << std::endl; + std::cout << "Check: inconsistent phi_1 link" << std::endl; return false; } @@ -510,9 +510,9 @@ bool Map2::check() if (phi1(d1) == d) std::cout << "Check: (warning) face with only two edges" << std::endl; if (phi2(d1) == d) - std::cout << "Check: (warning) dandling edge" << std::endl; + std::cout << "Check: (warning) dangling edge" << std::endl; } - for(Dart d = begin(); d != end(); next(d)) + for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d)) { if (!m.isMarked(d)) // phi1 a au moins un antécédent ? { -- GitLab