Commit ee777b79 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: add methods in diff properties plugin to call from script

parent eae3aa52
......@@ -7,3 +7,4 @@ ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(renderVector)
ADD_SUBDIRECTORY(renderExplod)
ADD_SUBDIRECTORY(subdivideSurface)
ADD_SUBDIRECTORY(surfaceDeformation)
......@@ -41,8 +41,30 @@ public slots:
void openComputeNormalDialog();
void openComputeCurvatureDialog();
void computeNormal();
void computeCurvature();
void computeNormalFromDialog();
void computeCurvatureFromDialog();
void computeNormal(
const QString& mapName,
const QString& positionAttributeName = "position",
const QString& normalAttributeName = "normal",
bool createNormalVBO = true
);
void computeCurvature(
const QString& mapName,
const QString& positionAttributeName = "position",
const QString& normalAttributeName = "normal",
const QString& KmaxAttributeName = "Kmax",
const QString& kmaxAttributeName = "kmax",
const QString& KminAttributeName = "Kmin",
const QString& kminAttributeName = "kmin",
const QString& KnormalAttributeName = "Knormal",
bool createKmaxVBO = true,
bool createkmaxVBO = true,
bool createKminVBO = true,
bool createkminVBO = true,
bool createKnormalVBO = true
);
private:
ComputeNormalDialog* m_computeNormalDialog;
......
......@@ -19,11 +19,11 @@ bool DifferentialPropertiesPlugin::enable()
connect(m_computeNormalAction, SIGNAL(triggered()), this, SLOT(openComputeNormalDialog()));
connect(m_computeCurvatureAction, SIGNAL(triggered()), this, SLOT(openComputeCurvatureDialog()));
connect(m_computeNormalDialog, SIGNAL(accepted()), this, SLOT(computeNormal()));
connect(m_computeNormalDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeNormal()));
connect(m_computeNormalDialog, SIGNAL(accepted()), this, SLOT(computeNormalFromDialog()));
connect(m_computeNormalDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeNormalFromDialog()));
connect(m_computeCurvatureDialog, SIGNAL(accepted()), this, SLOT(computeCurvature()));
connect(m_computeCurvatureDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeCurvature()));
connect(m_computeCurvatureDialog, SIGNAL(accepted()), this, SLOT(computeCurvatureFromDialog()));
connect(m_computeCurvatureDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeCurvatureFromDialog()));
return true;
}
......@@ -38,13 +38,12 @@ void DifferentialPropertiesPlugin::openComputeCurvatureDialog()
m_computeCurvatureDialog->show();
}
void DifferentialPropertiesPlugin::computeNormal()
void DifferentialPropertiesPlugin::computeNormalFromDialog()
{
QList<QListWidgetItem*> currentItems = m_computeNormalDialog->mapList->selectedItems();
if(!currentItems.empty())
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapname));
const QString& mapName = currentItems[0]->text();
QString positionName = m_computeNormalDialog->combo_positionAttribute->currentText();
QString normalName;
......@@ -53,109 +52,162 @@ void DifferentialPropertiesPlugin::computeNormal()
else
normalName = m_computeNormalDialog->normalAttributeName->text();
VertexAttribute<PFP2::VEC3> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionName);
VertexAttribute<PFP2::VEC3> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalName);
if(!normal.isValid())
normal = mh->addAttribute<PFP2::VEC3, VERTEX>(normalName);
bool createVBO = (m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked);
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeNormalVertices<PFP2>(*map, position, normal);
if(m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked)
mh->createVBO(normal);
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
computeNormal(mapName, positionName, normalName, createVBO);
}
}
void DifferentialPropertiesPlugin::computeCurvature()
void DifferentialPropertiesPlugin::computeCurvatureFromDialog()
{
QList<QListWidgetItem*> currentItems = m_computeCurvatureDialog->mapList->selectedItems();
if(!currentItems.empty())
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapname));
const QString& mapName = currentItems[0]->text();
QString positionName = m_computeCurvatureDialog->combo_positionAttribute->currentText();
QString normalName = m_computeCurvatureDialog->combo_normalAttribute->currentText();
VertexAttribute<PFP2::VEC3> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionName);
VertexAttribute<PFP2::VEC3> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalName);
QString KmaxName;
if(m_computeCurvatureDialog->KmaxAttributeName->text().isEmpty())
KmaxName = m_computeCurvatureDialog->combo_KmaxAttribute->currentText();
else
KmaxName = m_computeCurvatureDialog->KmaxAttributeName->text();
VertexAttribute<PFP2::VEC3> Kmax = mh->getAttribute<PFP2::VEC3, VERTEX>(KmaxName);
if(!Kmax.isValid())
Kmax = mh->addAttribute<PFP2::VEC3, VERTEX>(KmaxName);
QString kmaxName;
if(m_computeCurvatureDialog->kmaxAttributeName->text().isEmpty())
kmaxName = m_computeCurvatureDialog->combo_kmaxAttribute->currentText();
else
kmaxName = m_computeCurvatureDialog->kmaxAttributeName->text();
VertexAttribute<PFP2::REAL> kmax = mh->getAttribute<PFP2::REAL, VERTEX>(kmaxName);
if(!kmax.isValid())
kmax = mh->addAttribute<PFP2::REAL, VERTEX>(kmaxName);
QString KminName;
if(m_computeCurvatureDialog->KminAttributeName->text().isEmpty())
KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText();
else
KminName = m_computeCurvatureDialog->KminAttributeName->text();
VertexAttribute<PFP2::VEC3> Kmin = mh->getAttribute<PFP2::VEC3, VERTEX>(KminName);
if(!Kmin.isValid())
Kmin = mh->addAttribute<PFP2::VEC3, VERTEX>(KminName);
QString kminName;
if(m_computeCurvatureDialog->kminAttributeName->text().isEmpty())
kminName = m_computeCurvatureDialog->combo_kminAttribute->currentText();
else
kminName = m_computeCurvatureDialog->kminAttributeName->text();
VertexAttribute<PFP2::REAL> kmin = mh->getAttribute<PFP2::REAL, VERTEX>(kminName);
if(!kmin.isValid())
kmin = mh->addAttribute<PFP2::REAL, VERTEX>(kminName);
QString KnormalName;
if(m_computeCurvatureDialog->KnormalAttributeName->text().isEmpty())
KnormalName = m_computeCurvatureDialog->combo_KnormalAttribute->currentText();
else
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text();
VertexAttribute<PFP2::VEC3> Knormal = mh->getAttribute<PFP2::VEC3, VERTEX>(KnormalName);
if(!Knormal.isValid())
Knormal = mh->addAttribute<PFP2::VEC3, VERTEX>(KnormalName);
EdgeAttribute<PFP2::REAL> edgeAngle = mh->getAttribute<PFP2::REAL, EDGE>("edgeAngle");
if(!edgeAngle.isValid())
edgeAngle = mh->addAttribute<PFP2::REAL, EDGE>("edgeAngle");
bool KmaxVBO = (m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked);
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges<PFP2>(*map, position, edgeAngle);
Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected<PFP2>(*map, 0.01f * mh->getBBdiagSize(), position, normal, edgeAngle, kmax, kmin, Kmax, Kmin, Knormal);
bool kmaxVBO = (m_computeCurvatureDialog->check_kmaxCreateVBO->checkState() == Qt::Checked);
if(m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked)
mh->createVBO(Kmax);
bool KminVBO = (m_computeCurvatureDialog->check_KminCreateVBO->checkState() == Qt::Checked);
if(m_computeCurvatureDialog->check_kmaxCreateVBO->checkState() == Qt::Checked)
mh->createVBO(kmax);
bool kminVBO = (m_computeCurvatureDialog->check_kminCreateVBO->checkState() == Qt::Checked);
if(m_computeCurvatureDialog->check_KminCreateVBO->checkState() == Qt::Checked)
mh->createVBO(Kmin);
bool KnormalVBO = (m_computeCurvatureDialog->check_KnormalCreateVBO->checkState() == Qt::Checked);
if(m_computeCurvatureDialog->check_kminCreateVBO->checkState() == Qt::Checked)
mh->createVBO(kmin);
computeCurvature(
mapName, positionName, normalName, KmaxName, kmaxName, KminName, kminName, KnormalName,
KmaxVBO, kmaxVBO, KminVBO, kminVBO, KnormalVBO
);
}
}
if(m_computeCurvatureDialog->check_KnormalCreateVBO->checkState() == Qt::Checked)
mh->createVBO(Knormal);
void DifferentialPropertiesPlugin::computeNormal(
const QString& mapName,
const QString& positionAttributeName,
const QString& normalAttributeName,
bool createNormalVBO)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
if(mh == NULL)
return;
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
}
VertexAttribute<PFP2::VEC3> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
if(!position.isValid())
return;
VertexAttribute<PFP2::VEC3> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalAttributeName);
if(!normal.isValid())
normal = mh->addAttribute<PFP2::VEC3, VERTEX>(normalAttributeName);
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeNormalVertices<PFP2>(*map, position, normal);
if(createNormalVBO)
mh->createVBO(normal);
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
}
void DifferentialPropertiesPlugin::computeCurvature(
const QString& mapName,
const QString& positionAttributeName,
const QString& normalAttributeName,
const QString& KmaxAttributeName,
const QString& kmaxAttributeName,
const QString& KminAttributeName,
const QString& kminAttributeName,
const QString& KnormalAttributeName,
bool createKmaxVBO,
bool createkmaxVBO,
bool createKminVBO,
bool createkminVBO,
bool createKnormalVBO)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
if(mh == NULL)
return;
VertexAttribute<PFP2::VEC3> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
if(!position.isValid())
return;
VertexAttribute<PFP2::VEC3> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalAttributeName);
if(!normal.isValid())
return;
VertexAttribute<PFP2::VEC3> Kmax = mh->getAttribute<PFP2::VEC3, VERTEX>(KmaxAttributeName);
if(!Kmax.isValid())
Kmax = mh->addAttribute<PFP2::VEC3, VERTEX>(KmaxAttributeName);
VertexAttribute<PFP2::REAL> kmax = mh->getAttribute<PFP2::REAL, VERTEX>(kmaxAttributeName);
if(!kmax.isValid())
kmax = mh->addAttribute<PFP2::REAL, VERTEX>(kmaxAttributeName);
VertexAttribute<PFP2::VEC3> Kmin = mh->getAttribute<PFP2::VEC3, VERTEX>(KminAttributeName);
if(!Kmin.isValid())
Kmin = mh->addAttribute<PFP2::VEC3, VERTEX>(KminAttributeName);
VertexAttribute<PFP2::REAL> kmin = mh->getAttribute<PFP2::REAL, VERTEX>(kminAttributeName);
if(!kmin.isValid())
kmin = mh->addAttribute<PFP2::REAL, VERTEX>(kminAttributeName);
VertexAttribute<PFP2::VEC3> Knormal = mh->getAttribute<PFP2::VEC3, VERTEX>(KnormalAttributeName);
if(!Knormal.isValid())
Knormal = mh->addAttribute<PFP2::VEC3, VERTEX>(KnormalAttributeName);
EdgeAttribute<PFP2::REAL> edgeAngle = mh->getAttribute<PFP2::REAL, EDGE>("edgeAngle");
if(!edgeAngle.isValid())
edgeAngle = mh->addAttribute<PFP2::REAL, EDGE>("edgeAngle");
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges<PFP2>(*map, position, edgeAngle);
Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected<PFP2>(*map, 0.02f * mh->getBBdiagSize(), position, normal, edgeAngle, kmax, kmin, Kmax, Kmin, Knormal);
if(createKmaxVBO) mh->createVBO(Kmax);
if(createkmaxVBO) mh->createVBO(kmax);
if(createKminVBO) mh->createVBO(Kmin);
if(createkminVBO) mh->createVBO(kmin);
if(createKnormalVBO) mh->createVBO(Knormal);
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
}
#ifndef DEBUG
......
importPlugin = schnapps.loadPlugin("ImportSurface");
differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
renderPlugin = schnapps.loadPlugin("Render");
renderVectorPlugin = schnapps.loadPlugin("RenderVector");
hand = importPlugin.importFromFile("/home/kraemer/Media/Data/surface/midRes/handman_12k.off");
obj = importPlugin.importFromFile("/home/kraemer/Media/Data/surface/midRes/bimba_75k.off");
v = schnapps.getView("view_0");
schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName());
schnapps.linkViewAndMap(v.getName(), hand.getName());
schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName());
schnapps.linkViewAndMap(v.getName(), obj.getName());
#differentialPropertiesPlugin.computeNormal(obj.getName());
#differentialPropertiesPlugin.computeCurvature(obj.getName());
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment