Commit ee777b79 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

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

parent eae3aa52
...@@ -7,3 +7,4 @@ ADD_SUBDIRECTORY(render) ...@@ -7,3 +7,4 @@ ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(renderVector) ADD_SUBDIRECTORY(renderVector)
ADD_SUBDIRECTORY(renderExplod) ADD_SUBDIRECTORY(renderExplod)
ADD_SUBDIRECTORY(subdivideSurface) ADD_SUBDIRECTORY(subdivideSurface)
ADD_SUBDIRECTORY(surfaceDeformation)
...@@ -41,8 +41,30 @@ public slots: ...@@ -41,8 +41,30 @@ public slots:
void openComputeNormalDialog(); void openComputeNormalDialog();
void openComputeCurvatureDialog(); void openComputeCurvatureDialog();
void computeNormal(); void computeNormalFromDialog();
void computeCurvature(); 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: private:
ComputeNormalDialog* m_computeNormalDialog; ComputeNormalDialog* m_computeNormalDialog;
......
...@@ -19,11 +19,11 @@ bool DifferentialPropertiesPlugin::enable() ...@@ -19,11 +19,11 @@ bool DifferentialPropertiesPlugin::enable()
connect(m_computeNormalAction, SIGNAL(triggered()), this, SLOT(openComputeNormalDialog())); connect(m_computeNormalAction, SIGNAL(triggered()), this, SLOT(openComputeNormalDialog()));
connect(m_computeCurvatureAction, SIGNAL(triggered()), this, SLOT(openComputeCurvatureDialog())); connect(m_computeCurvatureAction, SIGNAL(triggered()), this, SLOT(openComputeCurvatureDialog()));
connect(m_computeNormalDialog, SIGNAL(accepted()), this, SLOT(computeNormal())); connect(m_computeNormalDialog, SIGNAL(accepted()), this, SLOT(computeNormalFromDialog()));
connect(m_computeNormalDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeNormal())); connect(m_computeNormalDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeNormalFromDialog()));
connect(m_computeCurvatureDialog, SIGNAL(accepted()), this, SLOT(computeCurvature())); connect(m_computeCurvatureDialog, SIGNAL(accepted()), this, SLOT(computeCurvatureFromDialog()));
connect(m_computeCurvatureDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeCurvature())); connect(m_computeCurvatureDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeCurvatureFromDialog()));
return true; return true;
} }
...@@ -38,13 +38,12 @@ void DifferentialPropertiesPlugin::openComputeCurvatureDialog() ...@@ -38,13 +38,12 @@ void DifferentialPropertiesPlugin::openComputeCurvatureDialog()
m_computeCurvatureDialog->show(); m_computeCurvatureDialog->show();
} }
void DifferentialPropertiesPlugin::computeNormal() void DifferentialPropertiesPlugin::computeNormalFromDialog()
{ {
QList<QListWidgetItem*> currentItems = m_computeNormalDialog->mapList->selectedItems(); QList<QListWidgetItem*> currentItems = m_computeNormalDialog->mapList->selectedItems();
if(!currentItems.empty()) if(!currentItems.empty())
{ {
const QString& mapname = currentItems[0]->text(); const QString& mapName = currentItems[0]->text();
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapname));
QString positionName = m_computeNormalDialog->combo_positionAttribute->currentText(); QString positionName = m_computeNormalDialog->combo_positionAttribute->currentText();
QString normalName; QString normalName;
...@@ -53,109 +52,162 @@ void DifferentialPropertiesPlugin::computeNormal() ...@@ -53,109 +52,162 @@ void DifferentialPropertiesPlugin::computeNormal()
else else
normalName = m_computeNormalDialog->normalAttributeName->text(); normalName = m_computeNormalDialog->normalAttributeName->text();
VertexAttribute<PFP2::VEC3> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionName); bool createVBO = (m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked);
VertexAttribute<PFP2::VEC3> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalName);
if(!normal.isValid())
normal = mh->addAttribute<PFP2::VEC3, VERTEX>(normalName);
PFP2::MAP* map = mh->getMap(); computeNormal(mapName, positionName, normalName, createVBO);
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();
} }
} }
void DifferentialPropertiesPlugin::computeCurvature() void DifferentialPropertiesPlugin::computeCurvatureFromDialog()
{ {
QList<QListWidgetItem*> currentItems = m_computeCurvatureDialog->mapList->selectedItems(); QList<QListWidgetItem*> currentItems = m_computeCurvatureDialog->mapList->selectedItems();
if(!currentItems.empty()) if(!currentItems.empty())
{ {
const QString& mapname = currentItems[0]->text(); const QString& mapName = currentItems[0]->text();
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapname));
QString positionName = m_computeCurvatureDialog->combo_positionAttribute->currentText(); QString positionName = m_computeCurvatureDialog->combo_positionAttribute->currentText();
QString normalName = m_computeCurvatureDialog->combo_normalAttribute->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; QString KmaxName;
if(m_computeCurvatureDialog->KmaxAttributeName->text().isEmpty()) if(m_computeCurvatureDialog->KmaxAttributeName->text().isEmpty())
KmaxName = m_computeCurvatureDialog->combo_KmaxAttribute->currentText(); KmaxName = m_computeCurvatureDialog->combo_KmaxAttribute->currentText();
else else
KmaxName = m_computeCurvatureDialog->KmaxAttributeName->text(); 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; QString kmaxName;
if(m_computeCurvatureDialog->kmaxAttributeName->text().isEmpty()) if(m_computeCurvatureDialog->kmaxAttributeName->text().isEmpty())
kmaxName = m_computeCurvatureDialog->combo_kmaxAttribute->currentText(); kmaxName = m_computeCurvatureDialog->combo_kmaxAttribute->currentText();
else else
kmaxName = m_computeCurvatureDialog->kmaxAttributeName->text(); 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; QString KminName;
if(m_computeCurvatureDialog->KminAttributeName->text().isEmpty()) if(m_computeCurvatureDialog->KminAttributeName->text().isEmpty())
KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText(); KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText();
else else
KminName = m_computeCurvatureDialog->KminAttributeName->text(); 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; QString kminName;
if(m_computeCurvatureDialog->kminAttributeName->text().isEmpty()) if(m_computeCurvatureDialog->kminAttributeName->text().isEmpty())
kminName = m_computeCurvatureDialog->combo_kminAttribute->currentText(); kminName = m_computeCurvatureDialog->combo_kminAttribute->currentText();
else else
kminName = m_computeCurvatureDialog->kminAttributeName->text(); 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; QString KnormalName;
if(m_computeCurvatureDialog->KnormalAttributeName->text().isEmpty()) if(m_computeCurvatureDialog->KnormalAttributeName->text().isEmpty())
KnormalName = m_computeCurvatureDialog->combo_KnormalAttribute->currentText(); KnormalName = m_computeCurvatureDialog->combo_KnormalAttribute->currentText();
else else
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text(); 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"); bool KmaxVBO = (m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked);
if(!edgeAngle.isValid())
edgeAngle = mh->addAttribute<PFP2::REAL, EDGE>("edgeAngle");
PFP2::MAP* map = mh->getMap(); bool kmaxVBO = (m_computeCurvatureDialog->check_kmaxCreateVBO->checkState() == Qt::Checked);
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);
if(m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked) bool KminVBO = (m_computeCurvatureDialog->check_KminCreateVBO->checkState() == Qt::Checked);
mh->createVBO(Kmax);
if(m_computeCurvatureDialog->check_kmaxCreateVBO->checkState() == Qt::Checked) bool kminVBO = (m_computeCurvatureDialog->check_kminCreateVBO->checkState() == Qt::Checked);
mh->createVBO(kmax);
if(m_computeCurvatureDialog->check_KminCreateVBO->checkState() == Qt::Checked) bool KnormalVBO = (m_computeCurvatureDialog->check_KnormalCreateVBO->checkState() == Qt::Checked);
mh->createVBO(Kmin);
if(m_computeCurvatureDialog->check_kminCreateVBO->checkState() == Qt::Checked) computeCurvature(
mh->createVBO(kmin); mapName, positionName, normalName, KmaxName, kmaxName, KminName, kminName, KnormalName,
KmaxVBO, kmaxVBO, KminVBO, kminVBO, KnormalVBO
);
}
}
if(m_computeCurvatureDialog->check_KnormalCreateVBO->checkState() == Qt::Checked) void DifferentialPropertiesPlugin::computeNormal(
mh->createVBO(Knormal); 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(); VertexAttribute<PFP2::VEC3> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
foreach(View* view, views) if(!position.isValid())
view->updateGL(); 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 #ifndef DEBUG
......
importPlugin = schnapps.loadPlugin("ImportSurface"); importPlugin = schnapps.loadPlugin("ImportSurface");
differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties"); differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
renderPlugin = schnapps.loadPlugin("Render"); 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"); v = schnapps.getView("view_0");
schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName()); 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