Commit a832aa96 authored by thomas's avatar thomas

Merge branch 'master' of cgogn.u-strasbg.fr:~cgogn/CGoGN

parents f291c2f6 787e7e45
This diff is collapsed.
......@@ -53,6 +53,7 @@
#include "Utils/frameManipulator.h"
#include "Utils/clippingPresets.h"
#include "Utils/clippingPresetsAnimated.h"
#include "Utils/cgognStream.h"
#include "Utils/drawer.h"
......@@ -107,6 +108,7 @@ public:
//QT
Utils::QT::uiDockInterface dock;
QTimer *m_timer;
// Picking
Utils::LineDrawable* m_planeDrawable;
......@@ -118,6 +120,9 @@ public:
Utils::Pickable* m_lastPickedObject;
int m_lastClickedX, m_lastClickedY;
// Clipping
Utils::ClippingPresetAnimated *m_lastAnimatedClippingPreset;
Clipping();
void initGUI();
......@@ -129,6 +134,7 @@ public:
void cb_mouseMove(int buttons, int x, int y);
void cb_keyPress(int code);
void importMesh(std::string& filename);
void updatePickables();
public slots:
void slot_drawVertices(bool b);
......@@ -156,7 +162,15 @@ public slots:
void slot_pushButton_deleteSelectedObject();
void slot_pushButton_applyClippingPreset();
void slot_pushButton_applyStaticClippingPreset();
void slot_pushButton_applyAnimatedClippingPreset();
void slot_pushButton_StopAnimation();
void slot_doubleSpinBox_AnimatedClippingPresetSpeed(double c);
void slot_setAnimationState(bool state);
void slot_animationTimer();
void button_compile();
};
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>374</width>
<height>783</height>
<height>780</height>
</rect>
</property>
<property name="allowedAreas">
......@@ -316,29 +316,6 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QGroupBox" name="groupBox_ClippingPresets">
<property name="title">
<string>Clipping Presets</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QComboBox" name="comboBox_ClippingPresets"/>
</item>
<item>
<widget class="QPushButton" name="PushButton_ApplyClippingPreset">
<property name="text">
<string>Apply Preset</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
......@@ -413,6 +390,108 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_ClippingPresets">
<attribute name="title">
<string>Clipping Presets</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QGroupBox" name="groupBox_StaticClippingPresets">
<property name="title">
<string>Static Clipping Presets</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QComboBox" name="comboBox_StaticClippingPresets"/>
</item>
<item>
<widget class="QPushButton" name="PushButton_ApplyStaticClippingPreset">
<property name="text">
<string>Apply Static Preset</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QGroupBox" name="groupBox_AnimatedClippingPresets">
<property name="title">
<string>Animated Clipping Presets</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<widget class="QComboBox" name="comboBox_AnimatedClippingPresets"/>
</item>
<item>
<widget class="QPushButton" name="PushButton_ApplyAnimatedClippingPreset">
<property name="text">
<string>Apply Animated Preset</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_StopAnimation">
<property name="text">
<string>Stop Animation</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_AnimatedClippingPresetSpeed">
<property name="title">
<string>Speed Factor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_AnimatedClippingPresetSpeed">
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......
......@@ -70,14 +70,21 @@ AttributeHandler<PFP::VEC3> normal;
void MyQT::cb_Open()
{
// set some filters
std::string filters("all (*.*);; trian (*.trian);; ctm (*.ctm);; off (*.off);; ply (*.ply)");
std::string filename = selectFile("OpenMesh","",filters);
// std::string filters("all (*.*);; trian (*.trian);; ctm (*.ctm);; off (*.off);; ply (*.ply)");
//
// std::string filename = selectFile("OpenMesh","",filters);
//
// std::vector<std::string> attrNames ;
// if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
// {
// CGoGNerr << "could not import " << filename << CGoGNendl ;
// return;
// }
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
if(!Algo::Import::importMesh<PFP>(myMap, "/home/thery/Data/liver.trian", attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
CGoGNerr << "could not import xxx" << CGoGNendl ;
return;
}
......@@ -133,34 +140,45 @@ void MyQT::cb_initGL()
glewInit();
// init lighting parameters
float lightPosition[4]= {0.0f,0.0f,10000.0f,1.0f};
float lightPosition[4]= {10.0f,10.0f,10000.0f,1.0f};
float lightColor[4]= {0.9f,0.9f,0.9f,1.0f};
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_NORMALIZE);
// glDisable(GL_CULL_FACE);
// glFrontFace(GL_CCW);
}
void MyQT::cb_redraw()
{
GLfloat diff[4]= {0.0f,1.0f,0.1f,1.0f};
GLfloat amb[4]= {0.1f,0.0f,0.1f,1.0f};
GLfloat spec[4]= {1.0f,1.0f,1.0f,1.0f};
float shininess=125.0f;
// draw the lines
glDisable(GL_LIGHTING);
glColor3f(0.0f, 0.0f, 0.3f);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glDisable(GL_LIGHTING);
glEnable(GL_SMOOTH);
Algo::Render::GL1::renderTriQuadPoly<PFP>(myMap,Algo::Render::GL1::LINE, 1.0f,position, normal);
// glDisable(GL_LIGHTING);
// glColor3f(0.0f, 0.0f, 0.3f);
// glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
// glDisable(GL_LIGHTING);
//
// Algo::Render::GL1::renderTriQuadPoly<PFP>(myMap,Algo::Render::GL1::LINE, 1.0f,position, normal);
// draw the faces
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
glColor3f(0.1f, 0.8f, 0.0f);
glEnable(GL_LIGHTING);
glEnable(GL_SMOOTH);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
glMaterialfv(GL_FRONT, GL_AMBIENT, amb);
glMaterialfv(GL_FRONT,GL_SPECULAR,spec);
glMaterialf( GL_FRONT, GL_SHININESS, shininess);
Algo::Render::GL1::renderTriQuadPoly<PFP>(myMap,Algo::Render::GL1::SMOOTH, 1.0f,position, normal);
glDisable(GL_POLYGON_OFFSET_FILL);
}
......@@ -370,25 +388,27 @@ int main(int argc, char **argv)
sqt.statusMsg("Neww to create a sphere or Load for a mesh file");
CGoGNStream::allToConsole(&sqt);
int xx = 3;
double yy = 2.5;
bool zz=true;
int kk=32;
int cc=2;
{
using namespace CGoGN::Utils::QT;
inputValues( VarInteger(0,20,xx, "Entier",
VarBool(zz, "Bool",
VarDbl(0.314,3.14,yy,"Double",
VarSlider(10,100,kk,"Slider",
VarCombo("Riri;Fifi;Loulou;Donald",cc,"Combo") )))));
}
std::cout << "Int:" << xx << " Bool:"<<zz<< std::endl;
std::cout << "Dbl:" << yy << " Slider:"<<kk<< std::endl;
std::cout << "Combo:" << cc << std::endl;
sqt.cb_Open();
// int xx = 3;
// double yy = 2.5;
// bool zz=true;
// int kk=32;
// int cc=2;
//
// {
// using namespace CGoGN::Utils::QT;
//
// inputValues( VarInteger(0,20,xx, "Entier",
// VarBool(zz, "Bool",
// VarDbl(0.314,3.14,yy,"Double",
// VarSlider(10,100,kk,"Slider",
// VarCombo("Riri;Fifi;Loulou;Donald",cc,"Combo") )))));
// }
//
// std::cout << "Int:" << xx << " Bool:"<<zz<< std::endl;
// std::cout << "Dbl:" << yy << " Slider:"<<kk<< std::endl;
// std::cout << "Combo:" << cc << std::endl;
return app.exec();
}
Dépendences Linux:
installer les paquets suivants:
cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev libboost-thread-dev libzip-dev libqt4-help qt4-designer qt4-dev-tools uuid-dev
cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-all-dev libzip-dev libqt4-help qt4-designer qt4-dev-tools uuid-dev
Pour compiler CGoGN:
- aller dans ThirdParty et taper "cmake .", puis make
......
......@@ -148,11 +148,11 @@ void decimate(
while(!finished)
{
CGoGNout << "Countdown : " ;
CGoGNout << std::setprecision(8) << (nbVertices - nbWantedVertices) << "\r" << CGoGNflush ;
// CGoGNout << "Countdown : " ;
// CGoGNout << std::setprecision(8) << (nbVertices - nbWantedVertices) << "\r" << CGoGNflush ;
if(!selector->nextEdge(d)) {
CGoGNout << CGoGNendl << "out" << CGoGNendl ;
// CGoGNout << CGoGNendl << "out" << CGoGNendl ;
break ;
}
......@@ -178,7 +178,7 @@ void decimate(
if(nbVertices <= nbWantedVertices) {
finished = true ;
CGoGNout << CGoGNendl << "done" << CGoGNendl ;
// CGoGNout << CGoGNendl << "done" << CGoGNendl ;
}
}
......
......@@ -1195,24 +1195,24 @@ bool MeshTablesSurface<PFP>::mergeCloseVertices()
newIndices[i] = 0xffffffff;
}
// compute EPSILON: average length of 50 of 100 first edges of first faces divide by 10000
int nb = 100;
if (m_nbEdges.size()< 100)
nb = m_nbEdges.size();
// compute EPSILON: average length of 50 of 100 first edges of faces divide by 10000 (very very closed)
unsigned int nbf = 100;
if (nbf> m_nbFaces)
nbf = m_nbFaces;
int k=0;
typename PFP::REAL d=0;
for (int i=0; i< nb; i+=2)
double d=0;
for (unsigned int i=0; i< nbf;++i)
{
typename PFP::VEC3 e1 = positions[m_emb[k+1]] - positions[m_emb[k]];
d += e1.norm();
d += double(e1.norm());
k += m_nbEdges[i];
}
d /= float(nb/2);
typename PFP::REAL EPSILON = d/10000.0f;
d /= double(nbf);
typename PFP::REAL EPSILON = d/10000.0;
// traverse vertices
for (unsigned int i = positions.begin(); i != positions.end(); positions.next(i))
{
......
......@@ -432,7 +432,7 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
if(!mts.importMesh(filename, attrNames, kind))
return false;
if (mergeCloseVertices)
mts.mergeCloseVertices();
......
......@@ -332,6 +332,17 @@ public:
float computeCurvatureCount(const DataType *ptrVox, const std::vector<int>& sphere, DataType val);
float computeCurvatureCount3(const DataType *ptrVox, const std::vector<int>& cylX, const std::vector<int>& cylY, const std::vector<int>& cyl2, DataType val);
void createMaskOffsetCylinders(std::vector<int>& tableX, std::vector<int>& tableY, std::vector<int>& tableZ, int _i32radius);
Image<DataType>* cropz(unsigned int zmin, unsigned int zmax);
void createNormalSphere(std::vector<Geom::Vec3f>& table, int _i32radius);
Geom::Vec3f computeNormal(DataType *ptrVox, const std::vector<Geom::Vec3f>& sphere, DataType val, unsigned int radius);
bool checkSaddlecomputeNormal(const Geom::Vec3f& P, const Geom::Vec3f& normal, unsigned int radius);
};
......
......@@ -479,7 +479,6 @@ Image<DataType>* Image<DataType>::Blur3()
return newImg;
}
template<typename DataType>
......@@ -548,6 +547,325 @@ float Image<DataType>::computeCurvatureCount(const DataType *ptrVox, const std::
}
// TESTING NEW CURVATURE METHODS
template<typename DataType>
void Image<DataType>::createMaskOffsetCylinders(std::vector<int>& tableX, std::vector<int>& tableY, std::vector<int>& tableZ, int _i32radius)
{
// compute the width of the sphere for memory allocation
int i32Width = 2*_i32radius + 1;
// squared radius
float fRad2 = (float)(_i32radius*_i32radius);
// memory allocation
// difficult to know how many voxels before computing,
// so the reserve for the BB
tableX.reserve(i32Width*i32Width*7);
tableX.clear();
tableY.reserve(i32Width*i32Width*7);
tableY.clear();
tableZ.reserve(i32Width*i32Width*7);
tableZ.clear();
// scan all the BB of the sphere
for (int z = -_i32radius; z<=_i32radius; z++)
{
for (int y = -_i32radius; y<=_i32radius; y++)
{
for (int x = -_i32radius; x<=_i32radius; x++)
{
Geom::Vec3f v((float)x,(float)y,(float)z);
float fLength = v.norm2();
// if inside the sphere
if (fLength<=fRad2)
{
// the the index of the voxel
int index = z * m_WXY + y * m_WX + x;
if ((x<=3) && (x>=-3))
tableX.push_back(index);
if ((y<=3) && (y>=-3))
tableY.push_back(index);
if ((z<=3) && (z>=-3))
tableZ.push_back(index);
}
}
}
}
}
template<typename DataType>
float Image<DataType>::computeCurvatureCount3(const DataType *ptrVox, const std::vector<int>& cylX, const std::vector<int>& cylY, const std::vector<int>& cylZ, DataType val)
{
int noir = 0;
int blanc = 0;
float vals[3];
for (std::vector<int>::const_iterator it=cylX.begin(); it!=cylX.end();it++)
{
const DataType *data = ptrVox + *it;
if (*data != val)
{
blanc++;
}
else
{
noir++;
}
}
if (blanc >= noir)
{
vals[0] = 1.0f - ((float)noir) / ((float)blanc);
}
else
{
vals[0] = -1.0f + ((float)blanc)/((float)noir);
}
noir = 0;
blanc = 0;
for (std::vector<int>::const_iterator it=cylY.begin(); it!=cylY.end();it++)
{
const DataType *data = ptrVox + *it;
if (*data != val)
{
blanc++;
}
else
{
noir++;
}
}
if (blanc >= noir)
{
vals[1] = 1.0f - ((float)noir) / ((float)blanc);
}
else
{
vals[1] = -1.0f + ((float)blanc)/((float)noir);
}
noir = 0;
blanc = 0;
for (std::vector<int>::const_iterator it=cylZ.begin(); it!=cylZ.end();it++)
{
const DataType *data = ptrVox + *it;
if (*data != val)
{
blanc++;
}
else
{
noir++;
}
}
if (blanc >= noir)
{
vals[2] = 1.0f - ((float)noir) / ((float)blanc);
}
else
{
vals[2] = -1.0f + ((float)blanc)/((float)noir);
}
// if ((valZ>valX) && (valZ>valY))
// return (valX + valY)/2.0f;
//
// if ((valY>valX) && (valY>valZ))
// return (valX + valZ)/2.0f;
//
// return (valY + valZ)/2.0f;
unsigned short m1,m2;
if ((abs(vals[0]) < abs(vals[1])) && (abs(vals[0]) < abs(vals[2])))
{
m1 =1;
m2 =2;
}
else
{
m1=0;
if (abs(vals[1]) < abs(vals[2]))
m2 = 2;
else
m2 = 1;
}
if (vals[m1]>0.0f)
if (vals[m2]<0.0f)
if ((vals[m1] - vals[m2])>0.8f)
return 1.0f;
if (vals[m1]<0.0f)
if (vals[m2]>0.0f)
if ((vals[m2] - vals[m1])>0.8f)
return 1.0f;
return std::max(std::max(abs(vals[0]),abs(vals[1])),abs(vals[2]));
}
template< typename DataType >
Image<DataType>* Image<DataType>::cropz(unsigned int zmin, unsigned int nb)
{
unsigned int zmax = zmin+nb;
if (zmax> m_WZ)
{
zmax = m_WZ;
nb = zmax - zmin;
}
DataType* data2 = new DataType[150*m_WY*m_WZ];
Image<DataType>* newImg = new Image<DataType>(data2,150,m_WY,nb,getVoxSizeX(),getVoxSizeY(),getVoxSizeZ());
newImg->m_Alloc=true;
// set origin of real data in image ??
for(unsigned int z=zmin; z< zmax; ++z)
{
for(int y=0; y<m_WY; ++y)
{
for(int x=0; x<150; ++x)
{