Commit 01337419 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'develop' into 'develop'

Develop

See merge request !71
parents 08e46fe3 d19cc06a
......@@ -57,6 +57,19 @@ typename PFP::REAL squaredDistancePoint2FacePlane(typename PFP::MAP& map, Face f
template <typename PFP>
typename PFP::REAL squaredDistancePoint2Face(typename PFP::MAP& map, Face f, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const typename PFP::VEC3& P) ;
/**
* compute the barycentric coordinates of the point in the triangle f that is closest to point P
* @param map the map
* @param f a triangle face
* @param position the vertex attribute storing positions
* @param P the point
* @param u barycentric coordinate 1 of closest point
* @param v barycentric coordinate 2 of closest point
* @param w barycentric coordinate 3 of closest point
*/
template <typename PFP>
void closestPointInTriangle(typename PFP::MAP& map, Face f, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const typename PFP::VEC3& P, double& u, double& v, double& w) ;
/**
* compute squared distance from point to an edge
* @param map the map
......
......@@ -71,6 +71,15 @@ typename PFP::REAL squaredDistancePoint2Face(typename PFP::MAP& map, Face f, con
return dist2;
}
template <typename PFP>
void closestPointInTriangle(typename PFP::MAP& map, Face f, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const typename PFP::VEC3& P, double& u, double& v, double& w)
{
Dart d = map.phi1(f.dart);
Dart e = map.phi1(d);
Geom::closestPointInTriangle(P, position[f.dart], position[d], position[e], u, v, w);
}
template <typename PFP>
typename PFP::REAL squaredDistancePoint2Edge(typename PFP::MAP& map, Edge e, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const typename PFP::VEC3& P)
{
......
......@@ -56,7 +56,7 @@ template <typename VEC3>
typename VEC3::DATA_TYPE distancePoint2TrianglePlane(const VEC3& P, const VEC3& A, const VEC3& B, const VEC3& C) ;
/**
* compute squared distance from point to triangle
* compute squared distance from point P to triangle ABC
* @param P the point
* @param A triangle point 1
* @param B triangle point 2
......@@ -66,6 +66,19 @@ typename VEC3::DATA_TYPE distancePoint2TrianglePlane(const VEC3& P, const VEC3&
template <typename VEC3>
typename VEC3::DATA_TYPE squaredDistancePoint2Triangle(const VEC3& P, const VEC3& A, const VEC3& B, const VEC3& C) ;
/**
* compute the barycentric coordinates of the point in the triangle ABC that is closest to point P
* @param P the point
* @param A triangle point 1
* @param B triangle point 2
* @param C triangle point 3
* @param u barycentric coordinate 1 of closest point
* @param v barycentric coordinate 2 of closest point
* @param w barycentric coordinate 3 of closest point
*/
template <typename VEC3>
void closestPointInTriangle(const VEC3& P, const VEC3& A, const VEC3& B, const VEC3& C, double& u, double& v, double& w) ;
/**
* compute squared distance from point to line
* @param P the point
......
This diff is collapsed.
......@@ -122,7 +122,7 @@ typedef Cell<VOLUME> Vol; // not Volume because of the namespace Volume
namespace Parallel
{
const unsigned int SIZE_BUFFER_THREAD = 8192;
const unsigned int SIZE_BUFFER_THREAD = 1024;
}
}
......
......@@ -903,7 +903,7 @@ unsigned int Map2<MAP_IMPL>::volumeDegree(Vol v) const
{
mark.mark(it); // Mark
Dart adj = phi2(it); // Get adjacent face
if ( !this->isBoundaryMarked<2>(adj) && !mark.isMarked(adj) )
if ( !this->template isBoundaryMarked<2>(adj) && !mark.isMarked(adj) )
visitedFaces.push_back(adj);// Add it
it = this->phi1(it);
} while(it != df);
......
......@@ -53,11 +53,14 @@ SphericalHarmonics<Tscalar,Tcoef>::~SphericalHarmonics()
template <typename Tscalar,typename Tcoef>
void SphericalHarmonics<Tscalar,Tcoef>::set_level(int res_level)
{
assert(res_level >= 0 && res_level < max_resolution);
assert(cpt_instances == 0);
resolution = res_level;
nb_coefs = (resolution + 1) * (resolution + 1);
init_K_tab();
if (res_level != resolution)
{
assert(res_level >= 0 && res_level < max_resolution);
assert(cpt_instances == 0);
resolution = res_level;
nb_coefs = (resolution + 1) * (resolution + 1);
init_K_tab();
}
}
template <typename Tscalar,typename Tcoef>
......
......@@ -28,7 +28,8 @@ ADD_SUBDIRECTORY(surface_modelisation)
ADD_SUBDIRECTORY(surface_distance)
ADD_SUBDIRECTORY(surface_radiance)
#ADD_SUBDIRECTORY(cage2D_deformation)
ADD_SUBDIRECTORY(cage2D_deformation)
ADD_SUBDIRECTORY(cage3D_deformation)
ADD_SUBDIRECTORY(volume_import)
#ADD_SUBDIRECTORY(volume_render)
......
......@@ -27,6 +27,7 @@ SET(
PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/surface_radiance.h
${PLUGIN_ROOT_DIR}/include/surface_radiance_dockTab.h
${PLUGIN_ROOT_DIR}/include/dialog_computeRadianceDistance.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_ComputeRadianceDistance</class>
<widget class="QDialog" name="Dialog_ComputeRadianceDistance">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>359</height>
</rect>
</property>
<property name="windowTitle">
<string>Compute Distance</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="list_maps_1"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_positionAttribute_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Distance attribute</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Existing attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_distanceAttribute_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>New attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="distanceAttributeName_1"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QListWidget" name="list_maps_2"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_positionAttribute_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Distance attribute</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Existing attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_distanceAttribute_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>New attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="distanceAttributeName_2"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="enableVBO">
<property name="text">
<string>Create VBOs</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>button_ok</sender>
<signal>clicked()</signal>
<receiver>Dialog_ComputeRadianceDistance</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>232</x>
<y>283</y>
</hint>
<hint type="destinationlabel">
<x>140</x>
<y>156</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_cancel</sender>
<signal>clicked()</signal>
<receiver>Dialog_ComputeRadianceDistance</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>52</x>
<y>283</y>
</hint>
<hint type="destinationlabel">
<x>140</x>
<y>156</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<width>227</width>
<height>600</height>
</rect>
</property>
......@@ -14,14 +14,14 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="checkbox_halfCollapse">
<property name="text">
<string>Position :</string>
<string>Half Collapse</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="combo_normalVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
......@@ -36,7 +36,35 @@
</item>
</widget>
</item>
<item row="0" column="1">
<item row="5" column="0" colspan="3">
<widget class="QPushButton" name="button_decimate">
<property name="text">
<string>Decimate</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Normal :</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="checkbox_fragInterp">
<property name="text">
<string>Fragment interpolation</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
......@@ -51,14 +79,7 @@
</item>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="button_decimate">
<property name="text">
<string>Decimate</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="6" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -71,21 +92,7 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Normal :</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="checkbox_halfCollapse">
<property name="text">
<string>Half Collapse</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="0" colspan="3">
<widget class="QSlider" name="slider_decimationGoal">
<property name="maximum">
<number>100</number>
......@@ -98,13 +105,6 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkbox_fragInterp">
<property name="text">
<string>Fragment interpolation</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
#ifndef _SURFACE_RADIANCE_DIALOG_COMPUTEDISTANCE_H_
#define _SURFACE_RADIANCE_DIALOG_COMPUTEDISTANCE_H_
#include "ui_dialog_computeRadianceDistance.h"
namespace CGoGN
{
namespace SCHNApps
{
class SCHNApps;
class MapHandlerGen;
class Dialog_ComputeRadianceDistance : public QDialog, public Ui::Dialog_ComputeRadianceDistance
{
Q_OBJECT
public:
Dialog_ComputeRadianceDistance(SCHNApps* s);
private:
SCHNApps* m_schnapps;
MapHandlerGen* m_selectedMap1;
MapHandlerGen* m_selectedMap2;
private slots:
void selectedMap1Changed();
void selectedMap2Changed();
void addMapToList(MapHandlerGen* map);
void removeMapFromList(MapHandlerGen* map);
void addAttributeToList1(unsigned int orbit, const QString& nameAttr);
void addAttributeToList2(unsigned int orbit, const QString& nameAttr);
};
} // namespace SCHNApps
} // namespace CGoGN
#endif // _SURFACE_RADIANCE_DIALOG_COMPUTEDISTANCE_H_
......@@ -3,9 +3,11 @@
#include "plugin_interaction.h"
#include "surface_radiance_dockTab.h"
#include "dialog_computeRadianceDistance.h"
#include "Utils/sphericalHarmonics.h"
#include "Utils/Shaders/shaderRadiancePerVertex.h"
#include "Utils/drawer.h"
#include "Algo/Decimation/decimation.h"
......@@ -56,6 +58,7 @@ class Surface_Radiance_Plugin : public PluginInteraction
#if CGOGN_QT_DESIRED_VERSION == 5
Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin")
#endif
friend class Surface_Radiance_DockTab;
public:
......@@ -87,6 +90,7 @@ private slots:
void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
void schnappsClosing();
// slots called from MapHandler signals
void vboAdded(Utils::VBO* vbo);
......@@ -95,6 +99,9 @@ private slots:
void importFromFileDialog();
void openComputeRadianceDistanceDialog();
void computeRadianceDistanceFromDialog();
public slots:
// slots for Python calls
void changePositionVBO(const QString& map, const QString& vbo);
......@@ -108,6 +115,14 @@ public slots:
bool halfCollapse = false,
bool exportMeshes = false
);
void computeRadianceDistance(
const QString& mapName1,
const QString& positionAttributeName1,
const QString& distanceAttributeName1,
const QString& mapName2,
const QString& positionAttributeName2,
const QString& distanceAttributeName2
);
void exportPLY(
const QString& mapName,
const QString& positionAttributeName,
......@@ -121,6 +136,10 @@ protected:
static void checkNbVerticesAndExport(Surface_Radiance_Plugin* p, const unsigned int* nbVertices);
Surface_Radiance_DockTab* m_dockTab;
Dialog_ComputeRadianceDistance* m_computeRadianceDistanceDialog;
QAction* m_computeRadianceDistanceAction;
QHash<MapHandlerGen*, MapParameters> h_mapParameterSet;
MapHandlerGen* m_currentlyDecimatedMap;
......
#include "dialog_computeRadianceDistance.h"
#include "surface_radiance.h"
#include "schnapps.h"
#include "mapHandler.h"
namespace CGoGN
{
namespace SCHNApps
{
Dialog_ComputeRadianceDistance::Dialog_ComputeRadianceDistance(SCHNApps* s) :
m_schnapps(s),
m_selectedMap1(NULL),
m_selectedMap2(NULL)
{
setupUi(this);
distanceAttributeName_1->setText("distance");
distanceAttributeName_2->setText("distance");
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*)));
connect(list_maps_1, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMap1Changed()));
connect(list_maps_2, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMap2Changed()));
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
{
list_maps_1->addItem(map->getName());
list_maps_2->addItem(map->getName());
}
}
void Dialog_ComputeRadianceDistance::selectedMap1Changed()
{
if(m_selectedMap1)
disconnect(m_selectedMap1, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList1(unsigned int, const QString&)));
QList<QListWidgetItem*> currentItems = list_maps_1->selectedItems();
if(!currentItems.empty())
{
combo_positionAttribute_1->clear();
combo_distanceAttribute_1->clear();
const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_schnapps->getMap(mapname);
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
QString realTypeName = QString::fromStdString(nameOfType(PFP2::REAL()));
const AttributeSet& attribs = mh->getAttributeSet(VERTEX);
for(AttributeSet::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{
if(i.value() == vec3TypeName)
{
combo_positionAttribute_1->addItem(i.key());
}
if(i.value() == realTypeName)
{
combo_distanceAttribute_1->addItem(i.key());
}
}
m_selectedMap1 = mh;
connect(m_selectedMap1, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList1(unsigned int, const QString&)));
}
else
m_selectedMap1 = NULL;
}
void Dialog_ComputeRadianceDistance::selectedMap2Changed()
{
if(m_selectedMap2)
disconnect(m_selectedMap2, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList2(unsigned int, const QString&)));
QList<QListWidgetItem*> currentItems = list_maps_2->selectedItems();
if(!currentItems.empty())
{
combo_positionAttribute_2->clear();
combo_distanceAttribute_2->clear();
const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_schnapps->getMap(mapname);
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
QString realTypeName = QString::fromStdString(nameOfType(PFP2::REAL()));
const AttributeSet& attribs = mh->getAttributeSet(VERTEX);
for(AttributeSet::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{
if(i.value() == vec3TypeName)
{
combo_positionAttribute_2->addItem(i.key());
}
if(i.value() == realTypeName)
{
combo_distanceAttribute_2->addItem(i.key());
}
}
m_selectedMap2 = mh;
connect(m_selectedMap2, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList2(unsigned int, const QString&)));
}
else
m_selectedMap2 = NULL;
}
void Dialog_ComputeRadianceDistance::addMapToList(MapHandlerGen* map)
{
list_maps_1->addItem(map->getName());
list_maps_2->addItem(map->getName());
}