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

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
This diff is collapsed.
......@@ -84,7 +84,7 @@ class Plane3D
// project the point p onto the plane
void project(Vector<3,T>& p) const;
// return true or false according to the side of the plane where point p is
// return on/over/under according to the side of the plane where point p is
Orientation3D orient(const Vector<3,T>& p) const;
/**********************************************/
......
......@@ -106,7 +106,7 @@ T Plane3D<T>::distance(const Vector<3,T>& p) const
template <typename T>
void Plane3D<T>::project(Vector<3,T>& p) const
{
#define PRECISION 1e-20
#define PRECISION 1e-5
T d = -distance(p) ;
if(abs(d) > PRECISION)
{
......@@ -119,7 +119,7 @@ void Plane3D<T>::project(Vector<3,T>& p) const
template <typename T>
Orientation3D Plane3D<T>::orient(const Vector<3,T>& p) const
{
#define PRECISION 1e-20
#define PRECISION 1e-5
T dist = distance(p) ;
if(dist < -PRECISION)
return UNDER ;
......
......@@ -74,7 +74,7 @@ public:
virtual ~CellMarker()
{
unmarkAll();
m_map.releaseMarker(m_marker,m_thread);
m_map.releaseMarker(m_marker, m_thread);
}
protected:
......@@ -183,15 +183,20 @@ public:
CellMarkerStore(AttribMap& map, unsigned int cell): CellMarker(map, cell)
{}
CellMarkerStore(AttribMap& map, unsigned int cell, unsigned int thread): CellMarker(map, cell,thread)
CellMarkerStore(AttribMap& map, unsigned int cell, unsigned int thread): CellMarker(map, cell, thread)
{}
~CellMarkerStore()
{
unmarkAll();
m_map.releaseMarker(m_marker, m_thread);
}
protected:
// protected copy constructor to forbid its usage
CellMarkerStore(const CellMarkerStore& cm) : CellMarker(cm)
{}
public:
/**
* mark the cell of dart
......
......@@ -39,11 +39,6 @@ class EmbeddedMap3 : public MAP3
{
public:
//!
/*!
*
*/
virtual void deleteOrientedVolume(Dart d);
//!
/*!
......@@ -100,6 +95,11 @@ public:
*/
virtual void collapseFace(Dart d, bool delDegenerateFaces = true,
bool delDegenerateVolumes = true);
virtual unsigned int closeHole(Dart d);
virtual void closeMap(DartMarker &marker);
} ;
} // namespace CGoGN
......
......@@ -28,62 +28,17 @@
namespace CGoGN
{
template <typename MAP3>
void EmbeddedMap3<MAP3>::deleteOrientedVolume(Dart d)
{
// DartMarkerStore mark(*this); // Lock a marker
//
// std::vector<Dart> visitedFaces; // Faces that are traversed
// visitedFaces.reserve(16);
// visitedFaces.push_back(d); // Start with the face of d
// std::vector<Dart>::iterator face;
//
// //For every face added to the list
// for (face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
// {
// if (!mark.isMarked(*face)) // Face has not been visited yet
// {
// Dart dNext = *face ;
//
// do
// {
// mark.mark(dNext); // Mark
//
// unsigned int vEmb1 = EMBNULL; //Manage the embedding
// if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
// {
// vEmb1 = MAP3::getDartEmbedding(VERTEX_ORBIT, dNext);
// MAP3::embedOrbit(VERTEX_ORBIT, d, vEmb1) ; //alpha1 peut ne pas fonctionner
// }
//
// if(MAP3::isOrbitEmbedded(EDGE_ORBIT))
// {
// vEmb1 = MAP3::getDartEmbedding(EDGE_ORBIT, dNext);
// MAP3::setDartEmbedding(VERTEX_ORBIT, MAP3::alpha2(dNext), vEmb1);
// }
//
// Dart adj = MAP3::phi2(dNext); // Get adjacent face
// if (adj != dNext && !mark.isMarked(adj))
// visitedFaces.push_back(adj); // Add it
// dNext = MAP3::phi1(dNext);
// } while(dNext != *face);
// }
// }
MAP3::deleteOrientedVolume(d);
}
template <typename MAP3>
void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
{
unsigned int vEmb1 = EMBNULL ;
//topological sewing
MAP3::sewVolumes(d,e);
//embed the new vertex orbit (with the new cell) with old vertex orbit value
//embed the vertex orbits from the oriented face with dart e
//with vertex orbits value from oriented face with dart d
if (MAP3::isOrbitEmbedded(VERTEX_ORBIT))
{
unsigned int vEmb1 = EMBNULL ;
Dart dd = d ;
do {
vEmb1 = MAP3::getEmbedding(VERTEX_ORBIT, d);
......@@ -93,96 +48,74 @@ void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
}
//embed the new edge orbit with the old edge orbit value
//for all the face
if (MAP3::isOrbitEmbedded(EDGE_ORBIT))
{
unsigned int vEmb1 = EMBNULL ;
Dart dd = d ;
do {
MAP3::copyDartEmbedding(EDGE_ORBIT, e, d) ;
vEmb1 = MAP3::getEmbedding(EDGE_ORBIT, d);
MAP3::embedOrbit(EDGE_ORBIT, d, vEmb1) ;
dd = MAP3::phi1(dd) ;
} while(dd != d) ;
}
//embed the face orbit from the volume sewn
if (MAP3::isOrbitEmbedded(FACE_ORBIT))
MAP3::copyDartEmbedding(FACE_ORBIT, e, d) ;
}
template <typename MAP3>
void EmbeddedMap3<MAP3>::unsewVolumes(Dart d)
{
unsigned int vEmb1 = EMBNULL ;
Dart dd = d ;
do {
//embed the vertex in the dart of the two volumes for the face
// if (MAP3::isOrbitEmbedded(VERTEX_ORBIT))
// {
// Dart e = MAP3::alpha1(dd);
//
// vEmb1 = MAP3::getEmbedding(dd, VERTEX_ORBIT) ;
// MAP3::setDartEmbedding(VERTEX_ORBIT, dd, vEmb1);
//
// if(e != MAP3::phi1(dd))
// {
// MAP3::embedNewCell(VERTEX_ORBIT, e);
// MAP3::copyCell(VERTEX_ORBIT, e, dd);
// }
// }
Dart d3 = MAP3::phi3(d);
bool boundaryD = false;
bool boundaryE = false;
if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
{
if(MAP3::isBoundaryVertex(d))
boundaryD = true;
if(MAP3::isBoundaryVertex(MAP3::phi1(d)))
boundaryE = true;
}
MAP3::unsewVolumes(d);
Dart dd = d;
Dart dd3 = d3;
do
{
if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
MAP3::copyCell(VERTEX_ORBIT, dd3, MAP3::phi1(dd));
if(MAP3::isOrbitEmbedded(EDGE_ORBIT))
{
Dart e = MAP3::phi3(dd);
vEmb1 = MAP3::getEmbedding(EDGE_ORBIT, dd);
MAP3::setDartEmbedding(EDGE_ORBIT, dd, vEmb1) ;
if(MAP3::isOrbitEmbedded(FACE_ORBIT))
if(e != dd)
{
MAP3::embedNewCell(EDGE_ORBIT, e);
MAP3::copyCell(EDGE_ORBIT, e, d);
}
}
dd = MAP3::phi1(dd) ;
} while(dd != d) ;
}while( dd != d );
MAP3::unsewVolumes(d);
}
template <typename MAP3>
bool EmbeddedMap3<MAP3>::mergeVolumes(Dart d)
{
unsigned int fEmb = EMBNULL;
unsigned int eEmb = EMBNULL;
Dart d2 = MAP3::phi2(d);
Dart a2 = MAP3::alpha2(d);
if (MAP3::isOrbitEmbedded(VOLUME_ORBIT))
{
fEmb = MAP3::getEmbedding(VOLUME_ORBIT, d);
if(fEmb != EMBNULL)
MAP3::setDartEmbedding(VOLUME_ORBIT, d2, fEmb) ;
}
if (MAP3::isOrbitEmbedded(EDGE_ORBIT))
{
eEmb = MAP3::getEmbedding(EDGE_ORBIT, d);
if(eEmb != EMBNULL)
MAP3::setDartEmbedding(EDGE_ORBIT, a2, eEmb);
}
Dart a_2 = MAP3::phi3(MAP3::phi2(d));