Commit 3997f4cc authored by Pierre Kraemer's avatar Pierre Kraemer

Algo Geometry with Traversors..

parent 7e4bfc8d
......@@ -173,6 +173,13 @@ void Viewer::cb_Open()
updateGL() ;
}
void Viewer::cb_Save()
{
std::string filters("off (*.off)") ;
std::string filename = selectFileSave("Save Mesh", "", filters) ;
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
}
void Viewer::importMesh(std::string& filename)
{
myMap.clear(true) ;
......
......@@ -35,6 +35,7 @@
#include "Geometry/matrix.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Algo/Render/GL2/mapRender.h"
......@@ -110,6 +111,7 @@ public:
void cb_initGL() ;
void cb_redraw() ;
void cb_Open() ;
void cb_Save() ;
void importMesh(std::string& filename) ;
......
......@@ -61,7 +61,7 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
* @return true
*/
template <typename PFP>
bool exportTrian(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, char* filename, const FunctorSelect& good = SelectorTrue()) ;
bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, char* filename, const FunctorSelect& good = SelectorTrue()) ;
/**
* export the map into a Trian file
......@@ -70,7 +70,7 @@ bool exportTrian(typename PFP::MAP& the_map, const typename PFP::TVEC3& position
* @return true
*/
template <typename PFP>
bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good = SelectorTrue()) ;
bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good = SelectorTrue()) ;
/**
* export the map into a PLYPTMgeneric file (K. Vanhoey generic format).
......
......@@ -24,6 +24,8 @@
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/autoAttributeHandler.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Topology/generic/cellmarker.h"
#include "openctm.h"
......@@ -60,28 +62,28 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ;
DartMarker markF(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
TraversorF<MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d) && !markF.isMarked(d))
if(good(d))
{
markF.markOrbit(FACE, d) ;
std::vector<unsigned int> fidx ;
fidx.reserve(4) ;
Dart dd = d ;
do
fidx.reserve(8) ;
unsigned int degree = 0 ;
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
unsigned int vNum = map.getEmbedding(VERTEX, dd) ;
if(!markV.isMarked(dd))
++degree ;
unsigned int vNum = map.getEmbedding(VERTEX, it) ;
if(!markV.isMarked(it))
{
markV.mark(dd) ;
markV.mark(it) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
dd = map.phi1(dd) ;
} while(dd != d) ;
facesSize.push_back(map.faceDegree(d)) ;
}
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
}
}
......@@ -138,28 +140,28 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ;
DartMarker markF(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
TraversorF<MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d) && !markF.isMarked(d))
if(good(d))
{
markF.markOrbit(FACE, d) ;
std::vector<unsigned int> fidx ;
fidx.reserve(4) ;
Dart dd = d ;
do
fidx.reserve(8) ;
unsigned int degree = 0 ;
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
unsigned int vNum = map.getEmbedding(VERTEX, dd) ;
if(!markV.isMarked(dd))
++degree ;
unsigned int vNum = map.getEmbedding(VERTEX, it) ;
if(!markV.isMarked(it))
{
markV.mark(dd) ;
markV.mark(it) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
dd = map.phi1(dd) ;
} while(dd != d) ;
facesSize.push_back(map.faceDegree(d)) ;
}
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
}
}
......@@ -185,44 +187,41 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
}
template <typename PFP>
bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good)
bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
AutoAttributeHandler<unsigned int> tableVertLab(the_map, VERTEX);
CellMarker markV(the_map,VERTEX);
AutoAttributeHandler<unsigned int> tableVertLab(map, VERTEX);
unsigned int nbDarts = the_map.getNbDarts() ;
unsigned int nbDarts = map.getNbDarts() ;
std::vector<CTMfloat> verticesBuffer;
std::vector<CTMuint> indicesBuffer;
verticesBuffer.reserve(nbDarts/5); // TODO non optimal reservation
indicesBuffer.reserve(nbDarts/3);
DartMarker markF(the_map);
unsigned int lab=0;
for(Dart d = the_map.begin(); d != the_map.end(); the_map.next(d))
CellMarker markV(map,VERTEX);
TraversorF<MAP> t(map) ;
unsigned int lab = 0;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d) && !markF.isMarked(d))
if(good(d))
{
markF.markOrbit(FACE, d) ;
Dart e = d;
do
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
if (!markV.isMarked(e))
if (!markV.isMarked(it))
{
tableVertLab[e] = lab++;
markV.mark(e);
const VEC3& vert = position[e];
markV.mark(it);
tableVertLab[it] = lab++;
const VEC3& vert = position[it];
verticesBuffer.push_back(vert[0]);
verticesBuffer.push_back(vert[1]);
verticesBuffer.push_back(vert[2]);
}
indicesBuffer.push_back(tableVertLab[e]);
e = the_map.phi1(e);
} while (e!=d);
indicesBuffer.push_back(tableVertLab[it]);
}
}
}
......@@ -265,7 +264,6 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
AutoAttributeHandler<unsigned int> tableVertLab(map, VERTEX);
CellMarker markV(map,VERTEX);
unsigned int nbDarts = map.getNbDarts() ;
......@@ -275,28 +273,26 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
vertices.reserve(nbDarts/5); // TODO non optimal reservation
faces.reserve(nbDarts/3);
DartMarker markF(map);
CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map) ;
unsigned int lab = 0;
unsigned int nbf = 0;
for(Dart d = map.begin(); d != map.end(); map.next(d))
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d) && !markF.isMarked(d))
if(good(d))
{
markF.markOrbit(FACE, d) ;
Dart e = d;
std::vector<unsigned int> face ;
do
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
if (!markV.isMarked(e))
if (!markV.isMarked(it))
{
vertices.push_back(map.getEmbedding(VERTEX, e));
tableVertLab[e] = lab++;
markV.mark(e);
markV.mark(it);
tableVertLab[it] = lab++;
vertices.push_back(map.getEmbedding(VERTEX, it));
}
face.push_back(tableVertLab[e]);
e = map.phi1(e);
} while (e!=d) ;
face.push_back(tableVertLab[it]);
}
faces.push_back(face.size()) ;
for (unsigned int i = 0 ; i < face.size() ; ++i)
......@@ -410,8 +406,6 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
AutoAttributeHandler<unsigned int> tableVertLab(map, VERTEX);
CellMarker markV(map,VERTEX);
unsigned int nbDarts = map.getNbDarts() ;
std::vector<unsigned int> vertices;
......@@ -420,28 +414,26 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
vertices.reserve(nbDarts/5); // TODO non optimal reservation
faces.reserve(nbDarts/3);
DartMarker markF(map);
CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map) ;
unsigned int lab = 0;
unsigned int nbf = 0;
for(Dart d = map.begin(); d != map.end(); map.next(d))
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d) && !markF.isMarked(d))
if(good(d))
{
markF.markOrbit(FACE, d) ;
Dart e = d;
std::vector<unsigned int> face ;
do
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
if (!markV.isMarked(e))
if (!markV.isMarked(it))
{
vertices.push_back(map.getEmbedding(VERTEX, e));
tableVertLab[e] = lab++;
markV.mark(e);
markV.mark(it);
tableVertLab[it] = lab++;
vertices.push_back(map.getEmbedding(VERTEX, it));
}
face.push_back(tableVertLab[e]);
e = map.phi1(e);
} while (e!=d) ;
face.push_back(tableVertLab[it]);
}
faces.push_back(face.size()) ;
for (unsigned int i = 0 ; i < face.size() ; ++i)
......@@ -515,7 +507,6 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
return true ;
}
template <typename PFP>
bool exportInESS(typename PFP::MAP& map, const char *filename, const typename PFP::TVEC3& position)
{
......@@ -528,8 +519,6 @@ bool exportInESS(typename PFP::MAP& map, const char *filename, const typename PF
CGoGNerr << "Unable to open file " << CGoGNendl ;
return false ;
}
}
} // namespace Export
......
#ifndef EXPORT_POV_H
#define EXPORT_POV
#define EXPORT_POV_H
#include "Topology/generic/attributeHandler.h"
#include "Utils/cgognStream.h"
......@@ -40,26 +40,30 @@ void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, typename PFP::T
DartMarkerStore traite(map);
for(Dart d = map.begin() ; d!= map.end() ; map.next(d)) {
if(good(d) && !traite.isMarked(d)) {
for(Dart d = map.begin() ; d!= map.end() ; map.next(d))
{
if(good(d) && !traite.isMarked(d))
{
unsigned int nb=0;
Dart dd=d;
do {
do
{
traite.markOrbit(DART,dd);
dd = map.phi1(dd);
nb++;
} while(dd!=d);
if(nb==3) {
if(nb == 3)
Algo::ExportPov::exportTrianglePlain<PFP>(out,position[dd],position[map.phi1(dd)],position[map.phi1(map.phi1(dd))]);
}
else {
else
{
out << "polygon{ " << nb+1 << std::endl;
dd=d;
do {
dd = d;
do
{
out << "<" << position[dd][0] << "," << position[dd][2] << "," << position[dd][1] << ">," << std::endl;
dd = map.phi1(dd);
}while(dd!=d);
} while(dd!=d);
out << "<" << position[d][0] << "," << position[d][2] << "," << position[d][1] << ">" << std::endl;
out << "}" << std::endl;
}
......@@ -76,30 +80,35 @@ void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, typename PFP::TV
DartMarkerStore traite(map);
for(Dart d = map.begin() ; d!= map.end() ; map.next(d)) {
if(good(d) && !traite.isMarked(d)) {
unsigned int nb=0;
Dart dd=d;
do {
traite.markOrbit(DART,dd);
for(Dart d = map.begin() ; d!= map.end() ; map.next(d))
{
if(good(d) && !traite.isMarked(d))
{
unsigned int nb = 0;
Dart dd = d;
do
{
traite.markOrbit(DART, dd);
dd = map.phi1(dd);
nb++;
} while(dd!=d);
} while(dd != d);
if(nb==3) {
if(nb == 3)
Algo::ExportPov::exportTriangleWire<PFP>(out,position[dd],position[map.phi1(dd)],position[map.phi1(map.phi1(dd))]);
}
else {
dd=d;
do {
if(position[dd][0]!=position[map.phi1(dd)][0] || position[dd][1]!=position[map.phi1(dd)][1] || position[dd][2]!=position[map.phi1(dd)][2]) {
else
{
dd = d;
do
{
if(position[dd][0]!=position[map.phi1(dd)][0] || position[dd][1]!=position[map.phi1(dd)][1] || position[dd][2]!=position[map.phi1(dd)][2])
{
out << "cylinder{ " << std::endl;
out << "<" << position[dd][0] << "," << position[dd][2] << "," << position[dd][1] << ">," << std::endl;
out << "<" << position[map.phi1(dd)][0] << "," << position[map.phi1(dd)][2] << "," << position[map.phi1(dd)][1] << ">, 0.5" << std::endl;
out << "}" << std::endl;
}
dd = map.phi1(dd);
}while(dd!=d);
} while(dd != d);
}
}
}
......@@ -111,7 +120,8 @@ template <typename PFP>
bool exportScenePov(typename PFP::MAP& map, typename PFP::TVEC3& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z,const FunctorSelect& good = SelectorTrue())
{
std::ofstream out(filename.c_str(), std::ios::out);
if (!out.good()) {
if (!out.good())
{
CGoGNerr << "(export) Unable to open file " << filename << CGoGNendl;
return false;
}
......@@ -147,10 +157,10 @@ bool exportScenePov(typename PFP::MAP& map, typename PFP::TVEC3& position, const
return true;
}
}
} // namespace ExportPov
}
} // namespace Algo
}
} // namespace CGoGN
#endif
......@@ -58,7 +58,6 @@ void filterTaubin(typename PFP::MAP& map, typename PFP::TVEC3& position, typenam
c.applyOnBorder(fa1) ;
VEC3 p = position[d] ;
VEC3 displ = fa1.getAverage() - p ;
// VEC3 displ = (fa1.getSum() - p * fa1.getCount()) / fa1.getCount() ;
displ *= lambda ;
position2[d] = p + displ ;
}
......@@ -77,7 +76,6 @@ void filterTaubin(typename PFP::MAP& map, typename PFP::TVEC3& position, typenam
c.applyOnBorder(fa2) ;
VEC3 p = position2[d] ;
VEC3 displ = fa2.getAverage() - p ;
// VEC3 displ = (fa2.getSum() - p * fa2.getCount()) / fa2.getCount() ;
displ *= mu ;
position[d] = p + displ ;
}
......@@ -92,7 +90,6 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position
{
typedef typename PFP::VEC3 VEC3 ;
const float lambda = 0.6307 ;
const float mu = -0.6732 ;
......
......@@ -115,7 +115,6 @@ typename PFP::VEC3 vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, co
return vertexNeighborhoodCentroidGen<PFP, typename PFP::TVEC3, typename PFP::VEC3>(map, d, position);
}
template <typename PFP>
void computeCentroidVolumes(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vol_centroid, const FunctorSelect& select = SelectorTrue()) ;
......
......@@ -24,7 +24,8 @@
#include "Algo/Geometry/localFrame.h"
#include "Geometry/matrix.h"
#include "Topology/generic/cellmarker.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Algo/Selection/collector.h"
extern "C"
......@@ -55,14 +56,11 @@ void computeCurvatureVertices_QuadraticFitting(
typename PFP::TVEC3& Kmin,
const FunctorSelect& select)
{
CellMarker marker(map, VERTEX);
for(Dart d = map.begin(); d != map.end(); map.next(d))
TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d) && !marker.isMarked(d))
{
marker.mark(d);
if(select(d))
computeCurvatureVertex_QuadraticFitting<PFP>(map, d, position, normal, kmax, kmin, Kmax, Kmin) ;
}
}
}
......@@ -129,22 +127,14 @@ void vertexQuadraticFitting(
LinearSolver<CPUSolverTraits> solver(5) ;
solver.set_least_squares(true) ;
solver.begin_system() ;
Dart it = dart ;
do
Traversor2VVaE<typename PFP::MAP> tav(map, dart) ;
for(Dart it = tav.begin(); it != tav.end(); it = tav.next())
{
// 1-ring vertices
typename PFP::VEC3 v = position[map.phi2(it)] ;
typename PFP::VEC3 v = position[it] ;
quadraticFittingAddVertexPos<PFP>(v, p, localFrame, solver) ;
typename PFP::VEC3 n = normal[map.phi2(it)] ;
typename PFP::VEC3 n = normal[it] ;
quadraticFittingAddVertexNormal<PFP>(v, n, p, localFrame, solver) ;
// 2-ring vertices
// Dart d2 = map.phi1(map.phi1(map.phi2(map.phi1(it)))) ;
// VEC3 v2 = position[d2] ;
// quadricFittingAddVertexPos(v2, p, localFrame, solver) ;
// VEC3 n2 = normal[d2] ;
// quadricFittingAddVertexNormal(v2, n2, p, localFrame, solver) ;
it = map.phi1( map.phi2(it)) ;
} while (it != dart) ;
}
solver.end_system() ;
solver.solve() ;
......@@ -208,23 +198,15 @@ void vertexCubicFitting(Dart dart, gmtl::Vec3f& normal, float& a, float& b, floa
solverC->reset(false) ;
solverC->set_least_squares(true) ;
solverC->begin_system() ;
Dart it = dart ;
do
Traversor2VVaE<typename PFP::MAP> tav(map, dart) ;
for(Dart it = tav.begin(); it != tav.end(); it = tav.next())
{
// 1-ring vertices
gmtl::Vec3f v = m_map.getVertexEmb(m_map.phi2(it))->getPosition() ;
gmtl::Vec3f v = m_map.getVertexEmb(it)->getPosition() ;
cubicFittingAddVertexPos(v,p,localFrame) ;
gmtl::Vec3f n = m_normalsV[m_map.getVertexEmb(m_map.phi2(it))->getLabel()] ;
gmtl::Vec3f n = m_normalsV[m_map.getVertexEmb(it)->getLabel()] ;
cubicFittingAddVertexNormal(v,n,p,localFrame) ;
// 2-ring vertices
// Dart d2 = m_map.phi1(m_map.phi1(m_map.phi2(m_map.phi1(it)))) ;
// gmtl::Vec3f v2 = m_map.getVertexEmb(d2)->getPosition() ;
// cubicFittingAddVertexPos(v2,p,localFrame) ;
// gmtl::Vec3f n2 = m_normalsV[m_map.getVertexEmb(d2)->getLabel()] ;
// cubicFittingAddVertexNormal(v2,n2,p,localFrame) ;
it = m_map.phi1( m_map.phi2(it)) ;
} while (it != dart) ;
}
solverC->end_system() ;
solverC->solve() ;
a = solverC->variable(0).value() ;
......@@ -312,14 +294,11 @@ void computeCurvatureVertices_NormalCycles(
typename PFP::TVEC3& Knormal,
const FunctorSelect& select = SelectorTrue())
{
CellMarker marker(map, VERTEX);
for(Dart d = map.begin(); d != map.end(); map.next(d))
TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d) && !marker.isMarked(d))
{
marker.mark(d);
if(select(d))
computeCurvatureVertex_NormalCycles<PFP>(map, d, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal) ;
}
}
}
......
......@@ -24,6 +24,7 @@
#include "Geometry/basic.h"
#include "Algo/Geometry/normal.h"
#include "Topology/generic/traversorCell.h"
namespace CGoGN
{
......@@ -47,15 +48,11 @@ void featureEdgeDetection(typename PFP::MAP& map, typename PFP::TVEC3& position,
fNormal = map.template addAttribute<VEC3>(FACE, "normal") ;
Algo::Geometry::computeNormalFaces<PFP>(map, position, fNormal) ;
CellMarker m(map, EDGE) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
TraversorE<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(!m.isMarked(d))
{
m.mark(d) ;
if(Geom::angle(fNormal[d], fNormal[map.phi2(d)]) > M_PI / REAL(6))
featureEdge.mark(d) ;
}
if(!map.isBoundaryEdge(d) && Geom::angle(fNormal[d], fNormal[map.phi2(d)]) > M_PI / REAL(6))
featureEdge.mark(d) ;
}
// map.template removeAttribute<VEC3>(fNormal) ;
......@@ -69,51 +66,46 @@ std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& ma
std::vector<VEC3> occludingContours ;
CellMarker m(map, FACE) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
TraversorF<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(!m.isMarked(d))
VEC3 p1 = position[d] ;
VEC3 p2 = position[map.phi1(d)] ;
VEC3 p3 = position[map.phi_1(d)] ;
REAL dp1 = (p1 - cameraPosition) * normal[d] ;
REAL dp2 = (p2 - cameraPosition) * normal[map.phi1(d)] ;
REAL dp3 = (p3 - cameraPosition) * normal[map.phi_1(d)] ;
if(dp1 < 0 && dp2 > 0)
{
REAL alpha = -dp1 / (-dp1 + dp2) ;
occludingContours.push_back(alpha * p1 + (1 - alpha) * p2) ;
}
if(dp2 < 0 && dp1 > 0)
{
REAL alpha = dp1 / (dp1 - dp2) ;
occludingContours.push_back(alpha * p1 + (1 - alpha) * p2) ;
}
if(dp1 < 0 && dp3 > 0)
{
REAL alpha = -dp1 / (-dp1 + dp3) ;
occludingContours.push_back(alpha * p1 + (1 - alpha) * p3) ;
}
if(dp3 < 0 && dp1 > 0)
{
REAL alpha = dp1 / (dp1 - dp3) ;
occludingContours.push_back(alpha * p1 + (1 - alpha) * p3) ;
}
if(dp2 < 0 && dp3 > 0)
{
REAL alpha = -dp2 / (-dp2 + dp3) ;
occludingContours.push_back(alpha * p2 + (1 - alpha) * p3) ;
}
if(dp3 < 0 && dp2 > 0)
{
m.mark(d) ;
VEC3 p1 = position[d] ;
VEC3 p2 = position[map.phi1(d)] ;
VEC3 p3 = position[map.phi_1(d)] ;
REAL dp1 = (p1 - cameraPosition) * normal[d] ;
REAL dp2 = (p2 - cameraPosition) * normal[map.phi1(d)] ;
REAL dp3 = (p3 - cameraPosition) * normal[map.phi_1(d)] ;
if(dp1 < 0 && dp2 > 0)
{
REAL alpha = -dp1 / (-dp1 + dp2) ;
occludingContours.push_back(alpha * p1 + (1 - alpha) * p2) ;
}
if(dp2 < 0 && dp1 > 0)
{
REAL alpha = dp1 / (dp1 - dp2) ;
occludingContours.push_back(alpha * p1 + (1 - alpha) * p2) ;
}
if(dp1 < 0 && dp3 > 0)
{
REAL alpha = -dp1 / (-dp1 + dp3) ;
occludingContours.push_back(alpha * p1 + (1 - alpha) * p3) ;
}
if(dp3 < 0 && dp1 > 0)
{
REAL alpha = dp1 / (dp1 - dp3) ;
occludingContours.push_back(alpha * p1 + (1 - alpha) * p3) ;
}
if(dp2 < 0 && dp3 > 0)
{
REAL alpha = -dp2 / (-dp2 + dp3) ;
occludingContours.push_back(alpha * p2 + (1 - alpha) * p3) ;
}
if(dp3 < 0 && dp2 > 0)
{
REAL alpha = dp2 / (dp2 - dp3) ;
occludingContours.push_back(alpha * p2 + (1 - alpha) * p3) ;
}
REAL alpha = dp2 / (dp2 - dp3) ;
occludingContours.push_back(alpha * p2 + (1 - alpha) * p3) ;
}
}
......
......@@ -123,11 +123,11 @@ bool isPointOnVertex(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3&
template <typename PFP>
bool isConvexFaceInOrIntersectingTetrahedron(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3 points[4],