Commit 71b3c990 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:~kraemer/CGoGN into BrowserTesting

Conflicts:
	Apps/Tuto/tuto_dual3.cpp
	include/Algo/Export/exportPov.h
	include/Algo/Render/GL2/explodeVolumeRender.hpp
	include/Algo/Render/GL2/mapRender.h
	include/Algo/Render/GL2/mapRender.hpp
parents 15b9e2d5 9da47178
......@@ -104,7 +104,7 @@ public:
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO ;
Utils::VBO* m_normalVBO;
Utils::ShaderPhong* m_phongShader ;
Utils::ShaderFlat* m_flatShader ;
......
......@@ -57,15 +57,24 @@ int main(int argc, char **argv)
std::string filename(argv[1]);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
// declaration of the map
PFP::MAP myMap;
std::vector<std::string> attrNames ;
Algo::Volume::Import::importMesh<PFP>(myMap, argv[1], attrNames);
if (extension == std::string(".map"))
myMap.loadMapBin(filename);
else
Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames);
// get a handler to the 3D vector attribute created by the import
VertexAttribute<PFP::VEC3> position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]);
// Les faces vont devenir des aretes -> echange de FACE ET EDGE
VolumeAttribute<PFP::VEC3> positionV = myMap.getAttribute<PFP::VEC3, VOLUME>("position") ;
if(!positionV.isValid())
positionV = myMap.addAttribute<PFP::VEC3, VOLUME>("position") ;
......@@ -81,21 +90,74 @@ int main(int argc, char **argv)
break;
}
}
if(dsave != NIL)
positionV[dsave] = PFP::VEC3(0.0);
//Algo::Modelisation::computeDual3<PFP>(myMap) ;
myMap.computeDual();
Dart dcenter = myMap.explodBorderTopo(dsave);
DartMarker mf(myMap);
for(Dart dit = myMap.begin() ; dit != myMap.end() ; myMap.next(dit))
{
if(myMap.isBoundaryMarked3(dit) && !mf.isMarked(dit))
{
mf.markOrbit<FACE>(dit);
positionV[dit] = Algo::Surface::Geometry::faceCentroid<PFP>(myMap,dit,position);
}
}
for(Dart dit = myMap.begin() ; dit != myMap.end() ; myMap.next(dit))
{
if(myMap.isBoundaryMarked3(dit))
{
myMap.fillHole(dit);
}
}
//
//Compute Dual Test -- begin
//
DartAttribute<Dart> old_phi1 = myMap.getAttribute<Dart, DART>("phi1") ;
DartAttribute<Dart> old_phi_1 = myMap.getAttribute<Dart, DART>("phi_1") ;
DartAttribute<Dart> new_phi1 = myMap.addAttribute<Dart, DART>("new_phi1") ;
DartAttribute<Dart> new_phi_1 = myMap.addAttribute<Dart, DART>("new_phi_1") ;
DartAttribute<Dart> old_phi2 = myMap.getAttribute<Dart, DART>("phi2") ;
DartAttribute<Dart> new_phi2 = myMap.addAttribute<Dart, DART>("new_phi2") ;
for(Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
Dart dd = myMap.phi2(myMap.phi3(d)) ;
new_phi1[d] = dd ;
new_phi_1[dd] = d ;
Dart ddd = myMap.phi1(myMap.phi3(d));
new_phi2[d] = ddd;
new_phi2[ddd] = d;
}
myMap.swapAttributes<Dart>(old_phi1, new_phi1) ;
myMap.swapAttributes<Dart>(old_phi_1, new_phi_1) ;
myMap.swapAttributes<Dart>(old_phi2, new_phi2) ;
myMap.removeAttribute(new_phi1) ;
myMap.removeAttribute(new_phi_1) ;
myMap.removeAttribute(new_phi2) ;
myMap.swapEmbeddingContainers(VERTEX, VOLUME) ;
//
//ComputeDualTest -- end
//
myMap.createHole(dcenter);
VolumeAttribute<PFP::VEC3> del;
del = position;
position = positionV ;
//turn_to<VertexAttribute<PFP::VEC3>, FaceAttribute<PFP::VEC3> >(&positionF);
//turn_to<FaceAttribute<PFP::VEC3>, VertexAttribute<PFP::VEC3> >(position);
myMap.removeAttribute(del);
//const std::type_info &t1 = typeid(&positionF);
//std::cout << "type name : " << t1.name() << std::endl;
myMap.dumpAttributesAndMarkers();
//Algo::Export::exportOFF<PFP>(myMap, position, "result.off");
myMap.saveMapBin("result.map");
std::cout << "Exported" << std::endl;
......
......@@ -602,8 +602,10 @@ void MyQT::cb_Open()
void MyQT::cb_Save()
{
std::string filename = selectFileSave("Export SVG file ",".","(*.off)");
Algo::Surface::Export::exportOFF<PFP>(myMap, position, filename.c_str()); // ???
std::string filename = selectFileSave("Export MAP file ",".","(*.map)");
//Algo::Surface::Export::exportOFF<PFP>(myMap, position, filename.c_str()); // ???
if(!myMap.saveMapBin(filename))
std::cout << "could not save file : " << filename << std::endl;
}
void MyQT::importMesh(std::string& filename)
......
......@@ -72,6 +72,7 @@ SET (CGoGN_EXT_INCLUDES
${ZLIB_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
)
# define libs for external libs
......
......@@ -17,6 +17,7 @@ find_package(GLEW REQUIRED)
find_package(Qt4 REQUIRED)
find_package(QGLViewer REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
find_package(SuiteSparse REQUIRED)
SET( QT_USE_QTOPENGL TRUE )
SET( QT_USE_QTXML TRUE )
......@@ -66,11 +67,13 @@ SET (EXT_INCLUDES
${QT_INCLUDE_DIR}
${QGLVIEWER_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${SUITESPARSE_INCLUDE_DIRS}
)
# define libs for external libs
SET (EXT_LIBS
PythonQt
nl
${OPENGL_LIBRARY}
${GLEW_LIBRARIES}
${ZLIB_LIBRARIES}
......@@ -81,6 +84,7 @@ SET (EXT_LIBS
${QT_LIBRARIES}
${QGLVIEWER_LIBRARIES}
${PYTHON_LIBRARIES}
${SUITESPARSE_LIBRARIES}
)
......@@ -108,6 +112,7 @@ file(
SCHNApps_FILES
${SCHNApps_ROOT_DIR}/src/*.cpp
${SCHNApps_ROOT_DIR}/include/*.h
${SCHNApps_ROOT_DIR}/include/*.hpp
)
file(
......
......@@ -7,4 +7,5 @@ ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(renderVector)
ADD_SUBDIRECTORY(renderExplod)
ADD_SUBDIRECTORY(subdivideSurface)
#ADD_SUBDIRECTORY(surfaceDeformation)
ADD_SUBDIRECTORY(surfaceDeformation)
#ADD_SUBDIRECTORY(renderTopoSurface)
......@@ -24,9 +24,10 @@ private:
MapHandlerGen* m_selectedMap;
public slots:
void refreshUI();
void selectedMapChanged();
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
};
} // namespace SCHNApps
......
......@@ -24,9 +24,12 @@ private:
MapHandlerGen* m_selectedMap;
public slots:
void refreshUI();
void selectedMapChanged();
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
void attributeModified(unsigned int orbit, QString nameAttr);
};
} // namespace SCHNApps
......
......@@ -72,6 +72,15 @@ private:
QAction* m_computeNormalAction;
QAction* m_computeCurvatureAction;
struct ComputeNormalParameters
{
ComputeNormalParameters() {}
ComputeNormalParameters(QString p, QString n) : positionName(p), normalName(n) {}
QString positionName;
QString normalName;
};
QHash<QString, ComputeNormalParameters> computeNormalLastParameters;
};
#endif
......@@ -25,17 +25,17 @@ ComputeCurvatureDialog::ComputeCurvatureDialog(Window* w) :
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*)));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(refreshUI()));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName());
}
void ComputeCurvatureDialog::refreshUI()
void ComputeCurvatureDialog::selectedMapChanged()
{
if(m_selectedMap)
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
......@@ -47,53 +47,50 @@ void ComputeCurvatureDialog::refreshUI()
combo_KnormalAttribute->clear();
combo_kmaxAttribute->clear();
combo_kminAttribute->clear();
const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_window->getMap(mapname);
GenericMap* map = mh->getGenericMap();
AttributeContainer& cont = map->getAttributeContainer<VERTEX>();
std::vector<std::string> names;
std::vector<std::string> types;
cont.getAttributesNames(names);
cont.getAttributesTypes(types);
std::string vec3TypeName = nameOfType(PFP2::VEC3());
std::string realTypeName = nameOfType(PFP2::REAL());
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
QString realTypeName = QString::fromStdString(nameOfType(PFP2::REAL()));
unsigned int j = 0;
unsigned int k = 0;
for(unsigned int i = 0; i < names.size(); ++i)
const AttributeHash& attribs = mh->getAttributesList(VERTEX);
for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{
if(types[i] == vec3TypeName)
if(i.value() == vec3TypeName)
{
combo_positionAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "position") // try to select a position attribute named "position"
combo_positionAttribute->addItem(i.key());
if(i.key() == "position") // try to select a position attribute named "position"
combo_positionAttribute->setCurrentIndex(j);
combo_normalAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "normal") // try to select a normal attribute named "normal"
combo_normalAttribute->addItem(i.key());
if(i.key() == "normal") // try to select a normal attribute named "normal"
combo_normalAttribute->setCurrentIndex(j);
combo_KmaxAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "Kmax") // try to select a normal attribute named "Kmax"
combo_KmaxAttribute->addItem(i.key());
if(i.key() == "Kmax") // try to select a normal attribute named "Kmax"
combo_KmaxAttribute->setCurrentIndex(j);
combo_KminAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "Kmin") // try to select a normal attribute named "Kmin"
combo_KminAttribute->addItem(i.key());
if(i.key() == "Kmin") // try to select a normal attribute named "Kmin"
combo_KminAttribute->setCurrentIndex(j);
combo_KnormalAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "Knormal") // try to select a normal attribute named "Knormal"
combo_KnormalAttribute->addItem(i.key());
if(i.key() == "Knormal") // try to select a normal attribute named "Knormal"
combo_KnormalAttribute->setCurrentIndex(j);
++j;
}
else if(types[i] == realTypeName)
else if(i.value() == realTypeName)
{
combo_kmaxAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "kmax") // try to select a normal attribute named "kmax"
combo_kmaxAttribute->addItem(i.key());
if(i.key() == "kmax") // try to select a normal attribute named "kmax"
combo_kmaxAttribute->setCurrentIndex(k);
combo_kminAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "kmin") // try to select a normal attribute named "kmin"
combo_kminAttribute->addItem(i.key());
if(i.key() == "kmin") // try to select a normal attribute named "kmin"
combo_kminAttribute->setCurrentIndex(k);
++k;
......@@ -101,7 +98,7 @@ void ComputeCurvatureDialog::refreshUI()
}
m_selectedMap = mh;
connect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
connect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
}
else
m_selectedMap = NULL;
......@@ -120,11 +117,33 @@ void ComputeCurvatureDialog::removeMapFromList(MapHandlerGen* m)
if(m_selectedMap == m)
{
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
m_selectedMap = NULL;
}
}
void ComputeCurvatureDialog::addAttributeToList(unsigned int orbit, const QString& nameAttr)
{
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
QString realTypeName = QString::fromStdString(nameOfType(PFP2::REAL()));
const QString& typeAttr = m_selectedMap->getAttributeTypeName(orbit, nameAttr);
if(typeAttr == vec3TypeName)
{
combo_positionAttribute->addItem(nameAttr);
combo_normalAttribute->addItem(nameAttr);
combo_KmaxAttribute->addItem(nameAttr);
combo_KminAttribute->addItem(nameAttr);
combo_KnormalAttribute->addItem(nameAttr);
}
else if(typeAttr == realTypeName)
{
combo_kmaxAttribute->addItem(nameAttr);
combo_kminAttribute->addItem(nameAttr);
}
}
} // namespace SCHNApps
} // namespace CGoGN
......@@ -21,44 +21,45 @@ ComputeNormalDialog::ComputeNormalDialog(Window* w) :
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*)));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(refreshUI()));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName());
{
QListWidgetItem* item = new QListWidgetItem(map->getName(), mapList);
item->setCheckState(Qt::Unchecked);
connect(map, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
}
}
void ComputeNormalDialog::refreshUI()
void ComputeNormalDialog::selectedMapChanged()
{
if(m_selectedMap)
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
{
combo_positionAttribute->clear();
combo_normalAttribute->clear();
const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_window->getMap(mapname);
GenericMap* map = mh->getGenericMap();
AttributeContainer& cont = map->getAttributeContainer<VERTEX>();
std::vector<std::string> names;
std::vector<std::string> types;
cont.getAttributesNames(names);
cont.getAttributesTypes(types);
std::string vec3TypeName = nameOfType(PFP2::VEC3());
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
unsigned int j = 0;
for(unsigned int i = 0; i < names.size(); ++i)
const AttributeHash& attribs = mh->getAttributesList(VERTEX);
for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{
if(types[i] == vec3TypeName)
if(i.value() == vec3TypeName)
{
combo_positionAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "position") // try to select a position attribute named "position"
combo_positionAttribute->addItem(i.key());
if(i.key() == "position") // try to select a position attribute named "position"
combo_positionAttribute->setCurrentIndex(j);
combo_normalAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "normal") // try to select a normal attribute named "normal"
combo_normalAttribute->addItem(i.key());
if(i.key() == "normal") // try to select a normal attribute named "normal"
combo_normalAttribute->setCurrentIndex(j);
++j;
......@@ -66,7 +67,7 @@ void ComputeNormalDialog::refreshUI()
}
m_selectedMap = mh;
connect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
connect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
}
else
m_selectedMap = NULL;
......@@ -74,7 +75,8 @@ void ComputeNormalDialog::refreshUI()
void ComputeNormalDialog::addMapToList(MapHandlerGen* m)
{
mapList->addItem(m->getName());
QListWidgetItem* item = new QListWidgetItem(m->getName(), mapList);
item->setCheckState(Qt::Unchecked);
}
void ComputeNormalDialog::removeMapFromList(MapHandlerGen* m)
......@@ -85,11 +87,33 @@ void ComputeNormalDialog::removeMapFromList(MapHandlerGen* m)
if(m_selectedMap == m)
{
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
m_selectedMap = NULL;
}
}
void ComputeNormalDialog::addAttributeToList(unsigned int orbit, const QString& nameAttr)
{
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
const QString& typeAttr = m_selectedMap->getAttributeTypeName(orbit, nameAttr);
if(typeAttr == vec3TypeName)
{
combo_positionAttribute->addItem(nameAttr);
combo_normalAttribute->addItem(nameAttr);
}
}
void ComputeNormalDialog::attributeModified(unsigned int orbit, QString nameAttr)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
// if(orbit == VERTEX && nameAttr == )
// {
// }
}
} // namespace SCHNApps
} // namespace CGoGN
......@@ -139,6 +139,9 @@ void DifferentialPropertiesPlugin::computeNormal(
if(createNormalVBO)
mh->createVBO(normal);
computeNormalLastParameters[mapName] =
ComputeNormalParameters(positionAttributeName, normalAttributeName) ;
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
......
......@@ -26,22 +26,18 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName)
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
PFP2::MAP* map = mh->getMap();
std::vector<std::string> attrNames ;
Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toUtf8().constData(), attrNames);
std::vector<std::string> attrNames;
Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toStdString(), attrNames);
// get vertex position attribute
VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, CGoGN::VERTEX>(attrNames[0]);
mh->registerAttribute<PFP2::VEC3, VERTEX>(position);
// create VBO for vertex position attribute
mh->createVBO(position);
// compute map bounding box
mh->updateBB(position);
// compute primitive connectivity VBOs
mh->updatePrimitives(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
}
return mhg;
}
......
......@@ -27,21 +27,17 @@ MapHandlerGen* ImportVolumePlugin::importFromFile(const QString& fileName)
PFP3::MAP* map = mh->getMap();
std::vector<std::string> attrNames ;
Algo::Volume::Import::importMesh<PFP3>(*map, fileName.toUtf8().constData(), attrNames);
Algo::Volume::Import::importMesh<PFP3>(*map, fileName.toStdString(), attrNames);
// get vertex position attribute
VertexAttribute<PFP3::VEC3> position = map->getAttribute<PFP3::VEC3, CGoGN::VERTEX>(attrNames[0]);
mh->registerAttribute<PFP2::VEC3, VERTEX>(position);
// create VBO for vertex position attribute
mh->createVBO(position);
// compute map bounding box
mh->updateBB(position);
// compute primitive connectivity VBOs
mh->updatePrimitives(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
}
return mhg;
}
......
......@@ -26,6 +26,7 @@ file(
SET(
PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/render.h
${PLUGIN_ROOT_DIR}/include/renderDockTab.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RenderWidget</class>
<widget class="QWidget" name="RenderWidget">
<class>RenderDockWidget</class>
<widget class="QWidget" name="RenderDockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>174</width>
<height>547</height>
<height>545</height>