Commit 04bba86e authored by Sylvain Thery's avatar Sylvain Thery

continue gen algorithms simplification

parents 42e869b6 059d7f9c
......@@ -196,6 +196,16 @@ void MyQT::cb_Open()
updateGL() ;
}
void MyQT::cb_Save()
{
std::string filters("all (*.*);; tetmesh (*.tetmesh);; tet (*.tet);; node (*.node);; msh (*.msh);; vtu (*.vtu);; nas (*.nas);; vbgz (*.vbgz)") ;
std::string filename = selectFileSave("Save Mesh", "", filters) ;
if (filename.empty())
return ;
Algo::Volume::Export::exportMesh<PFP>(myMap,position,filename);
}
void MyQT::cb_initGL()
{
......
......@@ -48,6 +48,8 @@
#include "ui_volumeExplorer.h"
#include "Utils/Qt/qtui.h"
#include "Algo/Export/exportVol.h"
using namespace CGoGN ;
......@@ -127,6 +129,7 @@ protected:
void cb_mousePress(int button, int x, int y);
void cb_mouseRelease(int button, int x, int y);
void cb_Open();
void cb_Save();
// slots locaux
......
......@@ -9,5 +9,5 @@ ADD_SUBDIRECTORY(renderScalar)
ADD_SUBDIRECTORY(renderExplod)
ADD_SUBDIRECTORY(renderTopoSurface)
ADD_SUBDIRECTORY(subdivideSurface)
ADD_SUBDIRECTORY(surfaceDeformation)
#ADD_SUBDIRECTORY(surfaceDeformation)
ADD_SUBDIRECTORY(subdivideMRVolume)
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>174</width>
<width>200</width>
<height>545</height>
</rect>
</property>
......@@ -101,7 +101,7 @@
<item row="1" column="1">
<widget class="QSlider" name="slider_facesScaleFactor">
<property name="value">
<number>50</number>
<number>99</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -118,7 +118,7 @@
<item row="2" column="1">
<widget class="QSlider" name="slider_volumesScaleFactor">
<property name="value">
<number>50</number>
<number>99</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
......
......@@ -276,7 +276,7 @@ void RenderExplodPlugin::changeRenderFaces(View* view, MapHandlerGen* map, bool
void RenderExplodPlugin::changeFacesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()]->facesScaleFactor = i / 50.0;
params->perMap[map->getName()]->facesScaleFactor = i / 99.0;
if(view->isCurrentView())
{
......@@ -289,7 +289,7 @@ void RenderExplodPlugin::changeFacesScaleFactor(View* view, MapHandlerGen* map,
void RenderExplodPlugin::changeVolumesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()]->volumesScaleFactor = i / 50.0;
params->perMap[map->getName()]->volumesScaleFactor = i / 99.0;
if(view->isCurrentView())
{
......
......@@ -775,7 +775,7 @@ bool exportTetmesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::V
VertexAutoAttribute<unsigned int> indices(map,"indices_vert");
fout << " Vertices" << std::endl<< position.nbElements() << std::endl;
fout << "Vertices" << std::endl<< position.nbElements() << std::endl;
std::vector<unsigned int> tetra;
tetra.reserve(2048);
......@@ -784,7 +784,7 @@ bool exportTetmesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::V
for (unsigned int i = position.begin(); i != position.end(); position.next(i))
{
const VEC3& P = position[i];
fout << P[0]<< " " << P[1]<< " " << P[2] << std::endl;
fout << P[0]<< " " << P[1]<< " " << P[2] << " " << "0" << std::endl;
indices[i] = count++;
}
......@@ -815,7 +815,7 @@ bool exportTetmesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::V
}
unsigned int nbtetra = tetra.size()/4;
fout << " Tetrahedra" << std::endl << nbtetra << std::endl;
fout << "Tetrahedra" << std::endl << nbtetra << std::endl;
for (unsigned int i=0; i<nbtetra; ++i)
{
......@@ -858,6 +858,7 @@ bool exportMesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3
break;
default:
CGoGNerr << "unknown file format for " << filename << CGoGNendl;
return false;
break;
}
}
......
......@@ -349,6 +349,7 @@ public:
};
template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidELWVolumes(typename PFP::MAP& map,
const V_ATT& position, W_ATT& vol_centroid,
......
......@@ -40,23 +40,24 @@ namespace Surface
namespace Geometry
{
template <typename PFP>
typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Dart d, const V_ATT& position) ;
template <typename PFP>
typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position);
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Dart d, const V_ATT& position);
template <typename PFP>
typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Dart d, const V_ATT& position) ;
template <typename PFP>
typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Dart d, const V_ATT& position) ;
template <typename PFP>
typename PFP::VEC3 vertexBorderNormal(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Dart d, const V_ATT& position) ;
template <typename PFP>
void computeNormalFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, FaceAttribute<typename PFP::VEC3>& face_normal, unsigned int thread = 0) ;
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_normal, unsigned int thread = 0) ;
/**
......@@ -67,27 +68,27 @@ void computeNormalFaces(typename PFP::MAP& map, const VertexAttribute<typename P
* @param the selector
* @ param th the thread number
*/
template <typename PFP>
void computeNormalVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, VertexAttribute<typename PFP::VEC3>& normal, unsigned int thread = 0) ;
template <typename PFP,typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal, unsigned int thread = 0) ;
namespace Parallel
{
template <typename PFP>
void computeNormalVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, VertexAttribute<typename PFP::VEC3>& normal, unsigned int nbth = 0) ;
template <typename PFP,typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal, unsigned int nbth = 0) ;
template <typename PFP>
void computeNormalFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, FaceAttribute<typename PFP::VEC3>& face_normal, unsigned int nbth = 0) ;
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_normal, unsigned int nbth = 0) ;
}
template <typename PFP>
typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
template <typename PFP, typename V_ATT>
typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart d, const V_ATT& position) ;
template <typename PFP>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, EdgeAttribute<typename PFP::REAL>& angles, unsigned int thread = 0) ;
template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles, unsigned int thread = 0) ;
} // namespace Geometry
......
This diff is collapsed.
......@@ -141,6 +141,10 @@ public:
* Topological operations on Hierarchical Implicit 3-maps
*************************************************************************/
// void deleteVolume(Dart d);
bool isWellEmbedded();
//@{
//!
......@@ -162,6 +166,11 @@ public:
void deleteVertexSubdividedFace(Dart d);
//@}
void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; }
void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; }
void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; }
void setVolumeVertexFunctor(FunctorType* f) { volumeVertexFunctor = f ; }
void computeVertexVertexFunctor(Dart d) { (*vertexVertexFunctor)(d); }
void computeEdgeVertexFunctor(Dart d) { (*edgeVertexFunctor)(d); }
void computeFaceVertexFunctor(Dart d) { (*faceVertexFunctor)(d); }
......@@ -373,7 +382,8 @@ public:
virtual bool foreach_dart_of_face2(Dart d, FunctorType& f, unsigned int thread = 0);
//@}
template <unsigned int ORBIT>
unsigned int getEmbedding(Dart d);
} ;
template <typename T, unsigned int ORBIT>
......@@ -398,9 +408,9 @@ public:
return AttributeHandler<T, ORBIT>::isValid() ;
}
T& operator[](Dart d) ;
virtual T& operator[](Dart d) ;
const T& operator[](Dart d) const ;
virtual const T& operator[](Dart d) const ;
T& operator[](unsigned int a)
{
......@@ -411,6 +421,7 @@ public:
{
return AttributeHandler<T, ORBIT>::operator[](a) ;
}
} ;
template <typename T>
......
......@@ -601,6 +601,59 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r;
}
template <unsigned int ORBIT>
inline unsigned int ImplicitHierarchicalMap3::getEmbedding(Dart d)
{
unsigned int nbSteps = m_curLevel - vertexInsertionLevel(d);
unsigned int index = EmbeddedMap3::getEmbedding<ORBIT>(d);
unsigned int step = 0;
while(step < nbSteps)
{
step++;
unsigned int next = m_nextLevelCell[ORBIT]->operator[](index);
//index = next;
if(next != EMBNULL) index = next;
else break;
}
return index;
}
inline bool ImplicitHierarchicalMap3::isWellEmbedded()
{
//std::cout << "yeahhh ? " << std::endl;
TraversorV<ImplicitHierarchicalMap3> tv(*this);
for(Dart dv = tv.begin() ; dv != tv.end() ; dv = tv.next())
{
unsigned int curem = this->getEmbedding<VERTEX>(dv);
//std::cout << "current emb = " << curem << std::endl;
unsigned int count = 0;
TraversorDartsOfOrbit<ImplicitHierarchicalMap3, VERTEX> to(*this, dv);
for(Dart dit = to.begin() ; dit != to.end() ; dit = to.next())
{
//std::cout << getDartLevel(dit) << std::endl;
if(curem != this->getEmbedding<VERTEX>(dit))
{
std::cout << "erreur dart #" << dit;
std::cout << " / curem = " << curem;
std::cout << " / em = " << this->getEmbedding<VERTEX>(dit);
std::cout << std::endl;
}
std::cout << EmbeddedMap3::getEmbedding<VERTEX>(dit) << "(" << this->getEmbedding<VERTEX>(dit) << ")" << " / ";
++count;
}
std::cout << " / vertex degree = " << count << std::endl;
}
return true;
}
/***************************************************
* ATTRIBUTE HANDLER *
......@@ -613,14 +666,20 @@ T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d)
assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ;
assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ;
unsigned int orbit = this->getOrbit() ;
// std::cout << std::endl << "vertexInsertionLevel[" << d <<"] = " << m->vertexInsertionLevel(d) << "\t";
unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
unsigned int index = m->getEmbedding<ORBIT>(d) ;
unsigned int index = m->EmbeddedMap3::getEmbedding<ORBIT>(d) ;
// std::cout << " m->vertexInsertionLevel(d) = " << m->vertexInsertionLevel(d) << std::endl;
// std::cout << "m_curLevel = " << m->m_curLevel << std::endl;
// std::cout << " nbSteps = " << nbSteps << std::endl;
// std::cout << "index EmbMap3 = " << index << std::endl;
if(index == EMBNULL)
{
index = m->setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ;
m->m_nextLevelCell[ORBIT]->operator[](index) = EMBNULL ;
}
AttributeContainer& cont = m->getAttributeContainer<ORBIT>() ;
......@@ -628,17 +687,24 @@ T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d)
while(step < nbSteps)
{
step++ ;
unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ;
unsigned int nextIdx = m->m_nextLevelCell[ORBIT]->operator[](index) ;
if (nextIdx == EMBNULL)
{
nextIdx = m->newCell<ORBIT>() ;
m->copyCell<ORBIT>(nextIdx, index) ;
m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ;
m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ;
m->m_nextLevelCell[ORBIT]->operator[](index) = nextIdx ;
m->m_nextLevelCell[ORBIT]->operator[](nextIdx) = EMBNULL ;
cont.refLine(index) ;
}
index = nextIdx ;
}
// std::cout << "emb = " << index << std::endl;
// std::cout << "index IHM = " << index << std::endl;
// if(index != EMBNULL)
// std::cout << " emb = " << this->m_attrib->operator[](index) << std::endl << std::endl;
return this->m_attrib->operator[](index);
}
......@@ -649,21 +715,30 @@ const T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d) const
assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ;
assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ;
unsigned int orbit = this->getOrbit() ;
unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
unsigned int index = m->getEmbedding<ORBIT>(d) ;
unsigned int index = m->EmbeddedMap3::getEmbedding<ORBIT>(d) ;
// std::cout << "(const) m->vertexInsertionLevel(d) = " << m->vertexInsertionLevel(d) << std::endl;
// std::cout << "(const) m_curLevel = " << m->m_curLevel << std::endl;
// std::cout << "(const) nbSteps = " << nbSteps << std::endl;
// std::cout << "(const) index EmbMap3 = " << index << std::endl;
unsigned int step = 0 ;
while(step < nbSteps)
{
step++ ;
unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ;
if(next != EMBNULL) index = next ;
unsigned int nextIdx = m->m_nextLevelCell[ORBIT]->operator[](index) ;
if(nextIdx != EMBNULL) index = nextIdx ;
else break ;
}
// if(index != EMBNULL)
// std::cout << "(const) emb = " << this->m_attrib->operator[](index) << std::endl << std::endl;
return this->m_attrib->operator[](index);
}
} //namespace IHM
} // Volume
} //namespace Algo
......
......@@ -41,7 +41,7 @@ template <typename PFP>
void subdivideEdge(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3>& position) ;
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3>& position) ;
void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3>& position, bool forceTri = true);
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3>& position) ;
......
......@@ -61,7 +61,7 @@ void subdivideEdge(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP:
}
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3>& position)
void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3>& position, bool forceTri)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
......@@ -89,7 +89,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP:
map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision
if(degree == 3) // if subdividing a triangle
if(degree == 3 && forceTri) // if subdividing a triangle
{
Dart dd = map.phi1(old) ;
Dart e = map.phi1(map.phi1(dd)) ;
......@@ -134,17 +134,16 @@ void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP:
}
else if(t == 2)
{
if(dId == eId)
{
std::cout << "plop" << std::endl;
map.setEdgeId(dit, 0);
map.setEdgeId(map.phi2(dit), 0);
}
else
{
map.setEdgeId(dit, 1);
map.setEdgeId(map.phi2(dit), 1);
}
if(dId == eId)
{
map.setEdgeId(dit, 0);
map.setEdgeId(map.phi2(dit), 0);
}
else
{
map.setEdgeId(dit, 1);
map.setEdgeId(map.phi2(dit), 1);
}
}
else if(t == 3)
{
......
......@@ -54,14 +54,44 @@ void subdivideEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType = S_TRI);
template <typename PFP>
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
void subdivideEdgeWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) ;
template <typename PFP>
void subdivideFaceWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType = S_TRI);
template <typename PFP>
Dart subdivideVolumeClassicWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
Dart subdivideVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
......
......@@ -41,7 +41,7 @@ namespace MovingObjects
template <typename PFP>
class ParticleBase
{
private:
protected:
typename PFP::VEC3 m_position ;
unsigned int m_state ;
......
#ifndef PARTCELL_H
#define PARTCELL_H
#include "particle_base.h"
#include "Algo/MovingObjects/particle_base.h"
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
......@@ -31,12 +31,12 @@ enum {
};
template <typename PFP>
class ParticleCell3D : public Algo::MovingObjects::ParticleBase
class ParticleCell3D : public Algo::MovingObjects::ParticleBase<PFP>
{
public :
typedef typename PFP::MAP Map;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<typename PFP::VEC3> TAB_POS;
typedef VertexAttribute<VEC3> TAB_POS;
Map& m;
......@@ -55,7 +55,11 @@ public :
{}
ParticleCell3D(Map& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
Algo::MovingObjects::ParticleBase(pos), m(map), position(tabPos), d(belonging_cell), state(3)
Algo::MovingObjects::ParticleBase<PFP>(pos),
m(map),
position(tabPos),
d(belonging_cell),
state(3)
{
m_positionFace = pointInFace(d);
}
......@@ -107,7 +111,7 @@ public :
{
crossCell = NO_CROSS ;
if(!Geom::arePointsEquals(newCurrent, m_position))
if(!Geom::arePointsEquals(newCurrent, this->getPosition()))
{
switch(state) {
case VERTEX : vertexState(newCurrent); break;
......@@ -121,10 +125,10 @@ public :
}
};
}
}
}
}
} //MovingObjects
} //Volume
} //Algo
} //CGoGN
#include "particle_cell_3D.hpp"
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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. *