#ifndef ENV_MAP_H #define ENV_MAP_H #include #include #include "Topology/generic/parameters.h" #include "Algo/Modelisation/polyhedron.h" #include "Algo/Modelisation/extrusion.h" #include "Algo/Modelisation/subdivision.h" #include "Algo/Geometry/centroid.h" #include "Algo/Geometry/area.h" #include "Geometry/bounding_box.h" #include "Container/fakeAttribute.h" #include "Algo/Tiling/Volume/cubic.h" #include "Algo/Modelisation/polyhedron.h" #include "Algo/Import/import.h" #include "Algo/Geometry/volume.h" #include "Algo/Geometry/area.h" //#include "Algo/ImplicitHierarchicalMesh/subdivision3.hxx" //#define DEBUG_affichage //#define DEBUG /////////////////particules #include "Algo/MovingObjects/particle_cell_3D_memo.h" using namespace CGoGN ; class Segment; #include "pfp.h" class EnvMap { public: EnvMap() ; void init(int argc, char **argv) ; bool checkPointInMap(VEC3 pos,Dart neighborhood); bool insideVolume(VEC3 pos, Dart d); VEC3 normaleFromVolume(Dart volume,Dart face); void open_file(std::string filename); VEC3 mapMinX; VEC3 mapMaxX; VEC3 mapMinY; VEC3 mapMaxY; VEC3 mapMinZ; VEC3 mapMaxZ; Dart getBelongingCell(const PFP::VEC3& pos); // // void resetAgentInFace(Agent* agent) ; PFP::MAP map ; VertexAttribute position ; FaceAttribute facecenter; VolumeAttribute color ; VolumeAttribute RegisteredEdges ; VolumeAttribute RegisteredNeighborEdges ; Geom::BoundingBox bb; // Enregistrement Aretes////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::vector getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1); void FindNeighborCellsOfSegment (const std::vector& belonging_cells, std::vector * nieghbor_cells); // Dart popAndPushSegment(Segment* o); void FirstRegistrationSegment(Segment * mo); void pushAOneCellSegment(Segment * o, Dart d); void pushSegmentInSetOfCells(Segment* o, const std::vector& memo_cross); void popSegment(Segment* o); void pushSegmentInCellAsNeighbor(Segment* o, Dart d); void popSegmentInCellAsNeighbor(Segment* o, Dart d); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //MULTIRES///////////////////////////////////////////////////////////////////////////// // static const unsigned int nbAgentsToSubdivide = 1 ; // static const unsigned int nbAgentsToSimplify = 0 ; // void refine() ; // void coarse() ; // void updateMap() ; // CellMarker refineMark ; // CellMarker coarsenMark ; // std::vector refineCandidate ; // std::vector coarsenCandidate ; /////////////////////////////////////////////////////////////////////////////////////// } ; //void update_registration(Segment * o); //void register_pop(Segment* o, int n); //void resetPartSubdiv(Segment* o); //void resetObstPartInFace(Segment* o, Dart d, unsigned int fLevel);// empeche de viser une dart ayant disparu //void resetObstPartInFace(Segment* o, Dart d);// empeche de viser une dart ayant disparu //void resetPart(Segment * mo, Dart d); // empeche de viser une dart ayant disparu pour les voisins /************************************** * INLINE FUNCTIONS * **************************************/ //////////////////// BASIC OPERATIONS //////////////////////////////////////////////////////////////// template inline void addElementToVector(std::vector& a, T ag) { assert(std::find(a.begin(), a.end(), ag) == a.end()); a.push_back(ag) ; } template inline bool removeElementFromVector(std::vector& a, T ag) { assert(std::find(a.begin(), a.end(), ag) != a.end()); typename std::vector::iterator end = a.template end() ; for (typename std::vector::iterator it = a.begin(); it != end; ++it) { if (*it == ag) { *it = a.back() ; a.pop_back() ; return true ; } } return false ; } ///////////////////////////////////////////////////////////////MULTIRES // //inline void EnvMap::nbAgentsIncrease(Dart d) //{ // if (refineMark.isMarked(d)) return ; // if (totalNeighborSize(d) < nbAgentsToSubdivide) return ; // // std::pair& sf = subdivisableFace[d] ; // if (sf.first == false || (sf.first == true && sf.second)) // { // refineMark.mark(d) ; // refineCandidate.push_back(d) ; // } //} // //inline void EnvMap::nbAgentsDecrease(Dart d) //{ // if (coarsenMark.isMarked(d) || refineMark.isMarked(d)) return ; // if (totalNeighborSize(d) > nbAgentsToSimplify) return ; // // coarsenMark.mark(d) ; // coarsenCandidate.push_back(map.faceOldestDart(d)) ; //} //inline void EnvMap::clearUpdateCandidates() //{ // refineCandidate.clear() ; // coarsenCandidate.clear() ; //} /////////////////////////////////////////////////////////////////////REGISTRATIONS inline std::vector EnvMap::getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1) { CGoGN::Algo::Volume::MovingObjects::ParticleCell3DMemo * registering_part = new CGoGN::Algo::Volume::MovingObjects::ParticleCell3DMemo(map, d1,pos,position); std::vector result =(registering_part->move(dest)); // d2=registering_part->d; // CGoGNout<<"d1 : "<< *d1<<"|| d2 : "<< *d2<<"|| start : "<< pos<<"|| stop : "<< dest<& belonging_cells, std::vector *neighbor_cells) { assert(map.getCurrentLevel() == map.getMaxLevel()); assert(!belonging_cells.empty()); neighbor_cells->clear(); CellMarkerMemo memo_mark(map); //marqueur des cellules "présentes" CellMarkerMemo OneRingMark(map); // marquer des cellules voisines for (std::vector::const_iterator it =belonging_cells.begin();it::const_iterator it=belonging_cells.begin(); Dart dd=NIL; // CGoGNout<<"debut neighbors cellules : "; // for (std::vector::const_iterator it =belonging_cells.begin();it(d) && !memo_mark.isMarked(d) && !OneRingMark.isMarked(d) ) { OneRingMark.mark(d); (*neighbor_cells).push_back(d); } } ++it; }while(it!=belonging_cells.end()); } inline void EnvMap::pushSegmentInCellAsNeighbor(Segment* o, Dart d) { assert(map.getCurrentLevel() == map.getMaxLevel()); assert(std::find(RegisteredNeighborEdges[d].begin(), RegisteredNeighborEdges[d].end(), o) == RegisteredNeighborEdges[d].end()); addElementToVector(RegisteredNeighborEdges[d],o); } inline void EnvMap::popSegmentInCellAsNeighbor(Segment* o, Dart d) { assert(map.getCurrentLevel() == map.getMaxLevel()); assert(std::find(RegisteredNeighborEdges[d].begin(), RegisteredNeighborEdges[d].end(), o) != RegisteredNeighborEdges[d].end()); removeElementFromVector(RegisteredNeighborEdges[d],o); } #endif