Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 218a41b3 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

Merge cgogn:~jund/CGoGN

parents e74ca673 98309936
......@@ -245,6 +245,26 @@ public:
* has already been subdivided to the next level
*/
bool volumeIsSubdivided(Dart d);
/**
* Return true if the edge of d in the current level map
* is subdivided to the next level,
* none of its resulting edges is in turn subdivided to the next level
* and the middle vertex is of degree 2
*/
bool edgeCanBeCoarsened(Dart d);
/**
*
*/
bool faceIsSubdividedOnce(Dart d);
/**
*
*/
bool volumeIsSubdividedOnce(Dart d);
} ;
template <typename T>
......
......@@ -48,12 +48,19 @@ template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_QUAD);
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/*******************************************************
*
......
......@@ -168,7 +168,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
}
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.volumeIsSubdivided(d) || !"Trying to subdivide an already subdivided volume") ;
......@@ -293,7 +293,6 @@ void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
}
while(e != *edge);
map.closeHole(f1);
Dart old = map.phi2(map.phi1(e));
......@@ -362,6 +361,8 @@ void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
}
map.setCurrentLevel(cur) ;
return subdividedfaces.begin()->first;
}
......@@ -591,6 +592,38 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(map.edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ;
unsigned int cur = map.getCurrentLevel() ;
Dart d2 = map.phi2(d) ;
map.setCurrentLevel(cur + 1) ;
unsigned int dl = map.getDartLevel(d2) ;
map.setDartLevel(map.phi1(d2), dl) ;
map.collapseEdge(d2) ;
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
//assert(map.faceIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided face or a more than once subdivided face") ;
}
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
//assert(map.volumeIsSubdivdedOnce(d) || !"Trying to coarsen a non-subdivided volume or a more than once subdivided volume") ;
}
/***********************************************************************************
*
*/
......@@ -1372,107 +1405,14 @@ void subdivideVolumeTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos
}
} //namespace IHM
} //namespace Algo
} //namespace CGoGN
/*
//Second step : deconnect the corners
for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
{
Dart e = *edge;
do
{
map.unsewFaces(map.phi1(map.phi1(e)));
map.unsewFaces(map.phi1(e));
e = map.phi2(map.phi_1(e));
}while(e != *edge);
// map.unsewFaces(map.phi1(*edge));
// moe.markOrbit(DART_ORBIT,map.phi1(*edge));
// }
//
// //Third step : close the hole
// for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
// {
// if(moe.isMarked(map.phi1(*edge)))
// {
map.closeHole(map.phi1(*edge));
Dart h = map.phi2(map.phi1(*edge));
unsigned int degree=0;
do
{
map.setEdgeId(h,map.getEdgeId(map.phi2(h)), DART_ORBIT) ;
h = map.phi1(h);
++degree;
}while(h != map.phi2(map.phi1(*edge)));
// moe.unmark(map.phi1(*edge));
// moe.unmark(map.phi1(map.phi2(map.phi_1(*edge))));
// moe.unmark(map.phi1(map.phi1(map.phi2(*edge))));
//si nouvelle diff de tri alors subdiviser la nouvelle face
if(degree != 3)
{
Dart old = map.phi1(map.phi2(map.phi1(*edge)));
Dart dd = map.phi1(old) ;
map.splitFace(dd, map.phi1(map.phi1(dd))) ;
Dart ne = map.phi2(map.phi_1(dd));
Dart ne2 = map.phi2(ne);
map.cutEdge(ne) ;
//unsigned int id = map.getNewEdgeId() ;
//map.setEdgeId(ne, id, EDGE_ORBIT) ;
//id = map.getNewEdgeId() ;
//map.setEdgeId(ne2, id, EDGE_ORBIT) ;
position[map.phi2(ne)] = volCenter;
dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ;
while(dd != ne)
{
Dart next = map.phi1(map.phi1(dd)) ;
map.splitFace(map.phi1(ne), dd) ;
Dart nne = map.phi2(map.phi_1(dd)) ;
//id = map.getNewEdgeId() ;
//map.setEdgeId(nne, id, EDGE_ORBIT) ;
dd = next ;
}
}
//}
}
} //namespace IHM
// moe.unmarkAll();
} //namespace Algo
for (std::vector<Dart>::iterator nvol = quadfaces.begin(); nvol != quadfaces.end(); nvol = nvol + 2)
{
if(map.phi3(map.phi2(*nvol)) == map.phi2(*nvol) && map.phi3(map.phi2(*(nvol+1))) == map.phi2(*(nvol+1)))
{
map.sewVolumes(map.phi2(*nvol), map.phi2(*(nvol+1)));
unsigned int idface = map.getNewFaceId();
map.setFaceId(map.phi2(*nvol),idface, FACE_ORBIT);
} //namespace CGoGN
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(map.phi1(map.phi2(*nvol)), idedge, EDGE_ORBIT);
}
}
// Dart ec = quadfaces.front();
// unsigned int idedge = map.getNewEdgeId();
// map.setEdgeId(map.phi1(map.phi1(ec)), idedge, EDGE_ORBIT);
//
// ec = map.phi_1(map.phi2(map.phi3(map.phi2(map.phi1(ec)))));
// idedge = map.getNewEdgeId();
// map.setEdgeId(ec, idedge, EDGE_ORBIT);
*/
......@@ -71,12 +71,6 @@ bool importTet(typename PFP::MAP& the_map, const std::string& filename, std::vec
template <typename PFP>
bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP>
bool importInESSSurfacique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, std::vector<std::pair<typename PFP::VEC3, typename PFP::VEC3> >& influences);
template <typename PFP>
bool importInESSVolumique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames);
} // namespace Import
......
#ifndef PARTCELL_H
#define PARTCELL_H
#include "particle_base.h"
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
#include "Geometry/orientation.h"
#include "Geometry/plane_3d.h"
#include <iostream>
/* A particle cell is a particle base within a map, within a precise cell, the displacement function should indicate
after each displacement wherein lies the new position of the particle */
namespace CGoGN
{
namespace Algo
{
namespace MovingObjects
{
enum {
NO_CROSS,
CROSS_FACE,
CROSS_OTHER
};
template <typename PFP>
class ParticleCell3D : public ParticleBase
{
public :
typedef typename PFP::MAP Map;
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::TVEC3 TAB_POS;
Map& m;
const TAB_POS& position;
Dart d;
Dart lastCrossed;
VEC3 m_positionFace;
unsigned int state;
unsigned int crossCell ;
ParticleCell3D(Map& map) : m(map)
{}
ParticleCell3D(Map& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
ParticleBase(pos), m(map), position(tabPos), d(belonging_cell), state(3)
{
m_positionFace = pointInFace(d);
}
void display();
Dart getCell() { return d; }
VEC3 pointInFace(Dart d);
Geom::Orientation3D isLeftENextVertex(VEC3 c, Dart d, VEC3 base);
bool isRightVertex(VEC3 c, Dart d, VEC3 base);
Geom::Orientation3D whichSideOfFace(VEC3 c, Dart d);
Geom::Orientation3D isLeftL1DVol(VEC3 c, Dart d, VEC3 base, VEC3 top);
Geom::Orientation3D isRightDVol(VEC3 c, Dart d, VEC3 base, VEC3 top);
Geom::Orientation3D isAbove(VEC3 c, Dart d, VEC3 top);
int isLeftL1DFace(VEC3 c, Dart d, VEC3 base, VEC3 normal);
bool isRightDFace(VEC3 c, Dart d, VEC3 base, VEC3 normal);
Dart nextDartOfVertexNotMarked(Dart d, CellMarker& mark);
Dart nextNonPlanar(Dart d);
Dart nextFaceNotMarked(Dart d,CellMarker& mark);
Geom::Orientation3D whichSideOfEdge(VEC3 c, Dart d);
bool isOnHalfEdge(VEC3 c, Dart d);
void vertexState(const VEC3& current);
void edgeState(const VEC3& current);
void faceState(const VEC3& current, Geom::Orientation3D sideOfFace=Geom::ON);
void volumeState(const VEC3& current);
void volumeSpecialCase(const VEC3& current);
void move(const VEC3& newCurrent)
{
crossCell = NO_CROSS ;
if(!Geom::arePointsEquals(newCurrent, m_position))
{
switch(state) {
case VERTEX_ORBIT : vertexState(newCurrent); break;
case EDGE_ORBIT : edgeState(newCurrent); break;
case FACE_ORBIT : faceState(newCurrent); break;
case VOLUME_ORBIT : volumeState(newCurrent); break;
}
display();
}
}
};
#include "particle_cell_3D.hpp"
}
}
}
#endif
// #define DEBUG
#define DELTA 0.00001
//static const float DELTA=0.00001;
template <typename PFP>
void ParticleCell3D<PFP>::display()
{
// std::cout << "position : " << m_position << std::endl;
}
template <typename PFP>
typename PFP::VEC3 ParticleCell3D<PFP>::pointInFace(Dart d)
{
return Algo::Geometry::faceCentroid<PFP>(m,d,position);
// const VEC3& p1(m_positions[d]);
// Dart dd=m.phi1(d);
// const VEC3& p2(m_positions[dd]);
// dd=m.phi1(dd);
// VEC3& p3(m_positions[dd]);
//
// while(Geom::testOrientation2D(p3,p1,p2)==Geom::ALIGNED) {
// dd = m.phi1(dd);
// p3 = m_positions[dd];
// }
//
// CGoGNout << "pointInFace " << (p1+p3)*0.5f << CGoGNendl;
//
// return (p1+p3)*0.5f;
}
template <typename PFP>
Geom::Orientation3D ParticleCell3D<PFP>::isLeftENextVertex(VEC3 c, Dart d, VEC3 base)
{
VEC3 p = position[d];
VEC3 p1 = position[m.phi1(m.phi2(d))];
Geom::Plane3D<typename PFP::REAL> pl(p,base,p1);
return pl.orient(c);
}
template <typename PFP>
bool ParticleCell3D<PFP>::isRightVertex(VEC3 c, Dart d, VEC3 base)
{
VEC3 p = position[d];
VEC3 p1 = position[m.phi_1(d)];
Geom::Plane3D<typename PFP::REAL> pl(p,base,p1);
return pl.orient(c)==Geom::UNDER;
}
template <typename PFP>
Geom::Orientation3D ParticleCell3D<PFP>::whichSideOfFace(VEC3 c, Dart d)
{
Geom::Plane3D<typename PFP::REAL> pl = Algo::Geometry::facePlane<PFP>(m,d,position);
return pl.orient(c);
}
template <typename PFP>
Geom::Orientation3D ParticleCell3D<PFP>::isLeftL1DVol(VEC3 c, Dart d, VEC3 base, VEC3 top)
{
VEC3 p2 = position[d];
Geom::Plane3D<typename PFP::REAL> pl(top,p2,base);
return pl.orient(c);
}
template <typename PFP>
Geom::Orientation3D ParticleCell3D<PFP>::isRightDVol(VEC3 c, Dart d, VEC3 base, VEC3 top)
{
VEC3 p1= position[m.phi1(d)];
Geom::Plane3D<typename PFP::REAL> pl(top,p1,base);
return pl.orient(c);
}
template <typename PFP>
Geom::Orientation3D ParticleCell3D<PFP>::isAbove(VEC3 c, Dart d, VEC3 top)
{
VEC3 p1 = position[d];
VEC3 p2 = position[m.phi1(d)];
Geom::Plane3D<typename PFP::REAL> pl(top,p2,p1);
return pl.orient(c);
}
template <typename PFP>
int ParticleCell3D<PFP>::isLeftL1DFace(VEC3 c, Dart d, VEC3 base, VEC3 normal)
{
VEC3 p2 = position[d];
VEC3 v2(p2-base);
VEC3 np = normal ^ v2;
Geom::Plane3D<typename PFP::REAL> pl(np,base*np);
return pl.orient(c);
}
template <typename PFP>
bool ParticleCell3D<PFP>::isRightDFace(VEC3 c, Dart d, VEC3 base, VEC3 normal)
{
VEC3 p1 = position[m.phi1(d)];
VEC3 np = normal ^ VEC3(p1-base);
Geom::Plane3D<typename PFP::REAL> pl(np,base*np);
return pl.orient(c)==Geom::UNDER;
}
template <typename PFP>
Dart ParticleCell3D<PFP>::nextDartOfVertexNotMarked(Dart d, CellMarker& mark)
{
// lock a marker
Dart d1;
DartMarkerNoUnmark markCC(m);
// init algo with parameter dart
std::list<Dart> darts_list;
darts_list.push_back(d);
markCC.mark(d);
// use iterator for begin of not yet treated darts
std::list<Dart>::iterator beg = darts_list.begin();
// until all darts treated
while (beg != darts_list.end())
{
d1 = *beg;
// add phi1, phi2 and phi3 successor if they are not yet marked
Dart d2 = m.phi1(m.phi2(d1));
Dart d3 = m.phi1(m.phi3(d1));
if (!markCC.isMarked(d2)) {
darts_list.push_back(d2);
markCC.mark(d2);
}
if (!markCC.isMarked(d3)) {
darts_list.push_back(d3);
markCC.mark(d3);
}
beg++;
// apply functor
if (!mark.isMarked(d1)) {
for (std::list<Dart>::iterator it=darts_list.begin(); it!=darts_list.end(); ++it)
markCC.unmark(*it);
return d1;
}
}
// clear markers
for (std::list<Dart>::iterator it=darts_list.begin(); it!=darts_list.end(); ++it)
markCC.unmark(*it);
return d;
}
template <typename PFP>
Dart ParticleCell3D<PFP>::nextNonPlanar(Dart d)
{
// lock a marker
Dart d1;
DartMarkerNoUnmark markCC(m);
// init algo with parameter dart
std::list<Dart> darts_list;
darts_list.push_back(d);
markCC.mark(d);
// use iterator for begin of not yet treated darts
std::list<Dart>::iterator beg = darts_list.begin();
// until all darts treated
while (beg != darts_list.end()) {
d1 = *beg;
// add phi1, phi2 and phi3 successor if they are not yet marked
Dart d2 = m.phi1(d1);
Dart d3 = m.phi2(d1);
Dart d4 = m.phi_1(d1);
if (!markCC.isMarked(d2)) {
darts_list.push_back(d2);
markCC.mark(d2);
}
if (!markCC.isMarked(d3)) {
darts_list.push_back(d3);
markCC.mark(d3);
}
if (!markCC.isMarked(d4)) {
darts_list.push_back(d4);
markCC.mark(d4);
}
beg++;
// apply functor
Geom::Plane3D<typename PFP::REAL> pl1 = Algo::Geometry::facePlane<PFP>(m,d,position);
Geom::Plane3D<typename PFP::REAL> pl2 = Algo::Geometry::facePlane<PFP>(m,d1,position);
if ((pl1.normal()-pl2.normal()).norm2()>0.000001)
beg = darts_list.end();
// remove the head of the list
}
// clear markers
for (std::list<Dart>::iterator it=darts_list.begin(); it!=darts_list.end(); ++it)
markCC.unmark(*it);
return d1;
}
template <typename PFP>
Dart ParticleCell3D<PFP>::nextFaceNotMarked(Dart d,CellMarker& mark)
{
// lock a marker
Dart d1;
DartMarkerNoUnmark markCC(m);
// init algo with parameter dart
std::list<Dart> darts_list;