Commit b7085890 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'develop' of icube-forge.unistra.fr:cgogn/cgogn into develop

parents e1ddbb94 b29a40b3
......@@ -78,7 +78,9 @@ void Viewer::initGUI()
void Viewer::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Utils::GLSLShader::setCurrentOGLVersion(3) ;
CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl;
Utils::GLSLShader::areShadersSupported();
m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRenderMap<PFP>() ;
......
......@@ -206,6 +206,8 @@ void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl;
Utils::GLSLShader::areShadersSupported();
// create the renders
m_topo_render = new Algo::Render::GL2::Topo3RenderMap<PFP>();
......
......@@ -110,6 +110,9 @@ void MapParameters::stop(MapHandlerGen* mh)
bool Surface_Deformation_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_Deformation_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Deformation");
......@@ -539,11 +542,7 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_Deformation_Plugin, Surface_Deformation_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_Deformation_PluginD, Surface_Deformation_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -13,6 +13,9 @@ namespace SCHNApps
bool Surface_DifferentialProperties_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_computeNormalDialog = new Dialog_ComputeNormal(m_schnapps);
m_computeCurvatureDialog = new Dialog_ComputeCurvature(m_schnapps);
......@@ -292,11 +295,7 @@ void Surface_DifferentialProperties_Plugin::computeCurvature(
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_DifferentialProperties_Plugin, Surface_DifferentialProperties_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_DifferentialProperties_PluginD, Surface_DifferentialProperties_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -16,7 +16,8 @@ class Surface_Import_Plugin : public PluginProcessing
public:
Surface_Import_Plugin()
{}
{
}
~Surface_Import_Plugin()
{}
......
......@@ -16,6 +16,9 @@ namespace SCHNApps
bool Surface_Import_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
importAction = new QAction("import", this);
m_schnapps->addMenuAction(this, "Surface;Import", importAction);
connect(importAction, SIGNAL(triggered()), this, SLOT(importFromFileDialog()));
......@@ -62,11 +65,7 @@ void Surface_Import_Plugin::importFromFileDialog()
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_Import_Plugin, Surface_Import_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_Import_PluginD, Surface_Import_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -24,6 +24,9 @@ Surface_Modelisation_Plugin::Surface_Modelisation_Plugin()
bool Surface_Modelisation_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_Modelisation_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Modelisation");
......@@ -790,11 +793,7 @@ void Surface_Modelisation_Plugin::pathExtrudeFace(MapHandlerGen *mhg)
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_Modelisation_Plugin, Surface_Modelisation_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_Modelisation_PluginD, Surface_Modelisation_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -10,6 +10,9 @@ namespace SCHNApps
bool Surface_Render_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_Render_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Render");
......@@ -323,11 +326,7 @@ void Surface_Render_Plugin::changeRenderBoundary(const QString& view, const QStr
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_Render_Plugin, Surface_Render_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_Render_PluginD, Surface_Render_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -10,6 +10,9 @@ namespace SCHNApps
bool Surface_RenderScalar_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_RenderScalar_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_RenderScalar");
......@@ -255,11 +258,7 @@ void Surface_RenderScalar_Plugin::changeExpansion(const QString& view, const QSt
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_RenderScalar_Plugin, Surface_RenderScalar_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_RenderScalar_PluginD, Surface_RenderScalar_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -10,6 +10,9 @@ namespace SCHNApps
bool Surface_RenderTopo_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_RenderTopo_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_RenderTopo");
......@@ -217,11 +220,7 @@ void Surface_RenderTopo_Plugin::attributeAdded(unsigned int orbit, const QString
// }
//}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_RenderTopo_Plugin, Surface_RenderTopo_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_RenderTopo_PluginD, Surface_RenderTopo_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -10,6 +10,9 @@ namespace SCHNApps
bool Surface_RenderVector_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_RenderVector_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_RenderVector");
......@@ -209,11 +212,7 @@ void Surface_RenderVector_Plugin::changeVectorsScaleFactor(const QString& view,
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_RenderVector_Plugin, Surface_RenderVector_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_RenderVector_PluginD, Surface_RenderVector_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -23,6 +23,9 @@ Surface_Selection_Plugin::Surface_Selection_Plugin() :
bool Surface_Selection_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_Selection_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Selection");
......@@ -625,11 +628,7 @@ void Surface_Selection_Plugin::changeSelectionMethod(const QString& map, unsigne
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_Selection_Plugin, Surface_Selection_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_Selection_PluginD, Surface_Selection_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -12,6 +12,9 @@ namespace SCHNApps
bool Surface_Subdivision_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_subdivisionDialog = new Dialog_Surface_Subdivision(m_schnapps);
m_subdivisionAction = new QAction("Subdivide surface", this);
......@@ -122,11 +125,7 @@ void Surface_Subdivision_Plugin::trianguleFaces(
view->updateGL();
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Surface_Subdivision_Plugin, Surface_Subdivision_Plugin)
#else
Q_EXPORT_PLUGIN2(Surface_Subdivision_PluginD, Surface_Subdivision_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -16,7 +16,12 @@ class Volume_Import_Plugin : public PluginProcessing
public:
Volume_Import_Plugin()
{}
{
std::cout << "VOL IMPORT CONSTR" << std::endl;
std::cout << "&PTR="<< &(GenericMap::s_instances)<< std::endl;
std::cout << "PTR="<< GenericMap::s_instances<< std::endl;
}
~Volume_Import_Plugin()
{}
......
......@@ -16,6 +16,9 @@ namespace SCHNApps
bool Volume_Import_Plugin::enable()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
importAction = new QAction("import", this);
m_schnapps->addMenuAction(this, "Volume;Import", importAction);
connect(importAction, SIGNAL(triggered()), this, SLOT(importFromFileDialog()));
......@@ -62,11 +65,7 @@ void Volume_Import_Plugin::importFromFileDialog()
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(Volume_Import_Plugin, Volume_Import_Plugin)
#else
Q_EXPORT_PLUGIN2(Volume_Import_PluginD, Volume_Import_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -101,6 +101,8 @@ public slots:
void notifySelectedCellSelectorChanged(CellSelectorGen* cs) { emit(selectedCellSelectorChanged(cs)); }
CellSelectorGen* getSelectedSelector(unsigned int orbit) const;
const StaticPointers& getStaticPointers() const {return m_sp;}
/*********************************************************
* MANAGE TEXTURES
*********************************************************/
......@@ -180,6 +182,8 @@ protected:
MapSet m_maps;
TextureSet m_textures;
StaticPointers m_sp;
};
} // namespace SCHNApps
......
......@@ -24,9 +24,13 @@ int main(int argc, char* argv[])
// get a smart pointer to the __main__ module of the Python interpreter
PythonQtObjectPtr pythonContext = PythonQt::self()->getMainModule();
PythonQtScriptingConsole pythonConsole(NULL, pythonContext);
CGoGN::SCHNApps::SCHNApps schnapps(app.applicationDirPath(), pythonContext, pythonConsole);
// PythonQtScriptingConsole pythonConsole(NULL, pythonContext);
// CGoGN::SCHNApps::SCHNApps schnapps(app.applicationDirPath(), pythonContext, pythonConsole);
PythonQtScriptingConsole* pythonConsole = new PythonQtScriptingConsole(NULL, pythonContext);
CGoGN::SCHNApps::SCHNApps schnapps(app.applicationDirPath(), pythonContext, *pythonConsole);
schnapps.show();
pythonContext.addObject("schnapps", &schnapps);
......
......@@ -26,6 +26,7 @@
#include "plugin_processing.h"
#include "plugins_default_directory.h"
#include "Topology/generic/genericmap.h"
namespace CGoGN
{
......@@ -41,6 +42,8 @@ SCHNApps::SCHNApps(const QString& appPath, PythonQtObjectPtr& pythonContext, Pyt
m_firstView(NULL),
m_selectedView(NULL)
{
GenericMap::initAllStatics(&m_sp);
this->setupUi(this);
// create & setup control dock
......
......@@ -108,7 +108,8 @@ void View::unlinkPlugin(PluginInteraction* plugin)
{
plugin->unlinkView(this);
emit(pluginUnlinked(plugin));
updateGL();
// removed because of crash when application close
// updateGL();
}
}
......@@ -159,7 +160,8 @@ void View::unlinkMap(MapHandlerGen* map)
emit(mapUnlinked(map));
updateCurrentCameraBB();
updateGL();
// removed because of crash when application close
// updateGL();
disconnect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
disconnect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL()));
......
......@@ -106,7 +106,7 @@ void uniformOrientationCC(MAP& map, Dart faceSeed)
DartMarker<MAP> cmf(map);
cmf.markOrbit<FACE>(faceSeed);
cmf.template markOrbit<FACE>(faceSeed);
propag.push_back(faceSeed);
while (!propag.empty() || !propag_inv.empty())
......@@ -120,7 +120,7 @@ void uniformOrientationCC(MAP& map, Dart faceSeed)
do
{
Dart e = map.phi2(d);
if (map.isBoundaryMarked2(e))
if (map.template isBoundaryMarked<2>(e))
{
e = findOtherInCouplesOfDarts(couples,d);
if (e!=NIL)
......@@ -129,7 +129,7 @@ void uniformOrientationCC(MAP& map, Dart faceSeed)
{
propag_inv.push_back(e);
face2invert.push_back(e);
cmf.markOrbit<FACE>(e);
cmf.template markOrbit<FACE>(e);
}
cmf.mark(map.phi2(e));// use cmf also to mark boudary cycle to invert
}
......@@ -140,7 +140,7 @@ void uniformOrientationCC(MAP& map, Dart faceSeed)
if (!cmf.isMarked(e))
{
propag.push_back(e);
cmf.markOrbit<FACE>(e);
cmf.template markOrbit<FACE>(e);
}
}
d= map.phi1(d);
......@@ -157,7 +157,7 @@ void uniformOrientationCC(MAP& map, Dart faceSeed)
do
{
Dart e = map.phi2(d);
if (map.isBoundaryMarked2(e))
if (map.template isBoundaryMarked<2>(e))
{
e = findOtherInCouplesOfDarts(couples,d);
if (e!=NIL)
......@@ -165,7 +165,7 @@ void uniformOrientationCC(MAP& map, Dart faceSeed)
if (!cmf.isMarked(e))
{
propag.push_back(e);
cmf.markOrbit<FACE>(e);
cmf.template markOrbit<FACE>(e);
}
cmf.mark(map.phi2(d));// use cmf also to mark boudary cycle to invert
}
......@@ -176,7 +176,7 @@ void uniformOrientationCC(MAP& map, Dart faceSeed)
{
propag_inv.push_back(e);
face2invert.push_back(e);
cmf.markOrbit<FACE>(e);
cmf.template markOrbit<FACE>(e);
}
}
d= map.phi1(d); // traverse all edges of face
......@@ -195,7 +195,7 @@ void uniformOrientationCC(MAP& map, Dart faceSeed)
if (cmf.isMarked(e)) // check cmf for wrong orientation
{
reverse2MapFaceKeepPhi2<MAP>(map,e);
cmf.unmarkOrbit<FACE>(e);
cmf.template unmarkOrbit<FACE>(e);
}
}
......
......@@ -69,6 +69,17 @@ inline int getSystemNumberOfCores(bool hyperthreading=false)
}
// forward
class GenericMap;
// classs that store static pointer for copy in schnapps plugins
struct StaticPointers
{
std::map<std::string, RegisteredBaseAttribute*>* att_registry;
std::vector<GenericMap*>* instances;
std::vector< std::vector<Dart>* >* vdartsBuffers;
std::vector< std::vector<unsigned int>* >* vintsBuffers;
};
class AttributeHandlerGen ;
class DartMarkerGen ;
......@@ -117,16 +128,15 @@ protected:
AttributeContainer m_attribs[NB_ORBITS] ;
static std::map<std::string, RegisteredBaseAttribute*>* m_attributes_registry_map;
static int m_nbInstances;
/// buffer for less memory allocation
static std::vector< std::vector<Dart>* >* s_vdartsBuffers;
static std::vector< std::vector<unsigned int>* >* s_vintsBuffers;
public:
/// table of instancied maps for Dart/CellMarker release
static std::vector<GenericMap*>* s_instances;
protected:
/**
* Direct access to the Dart attributes that store the orbits embeddings
......@@ -161,6 +171,12 @@ protected:
public:
static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ;
/// copy all static pointers: use in SCHNApps only
static void copyAllStatics(const StaticPointers& sp);
/// init all static and store in sp (if not null) : use in SCHNApps only
static void initAllStatics(StaticPointers* sp);
GenericMap() ;
virtual ~GenericMap() ;
......
......@@ -16,13 +16,13 @@ void main(void)
N = normalize (vec3(NormalMatrix*vec4(N,0.0)));
vec3 center = POSITION_IN(0).xyz + POSITION_IN(1).xyz + POSITION_IN(2).xyz;
center /= 3.0;
vec4 newPos = ModelViewMatrix * vec4(center,0.0);
vec4 newPos = ModelViewMatrix * vec4(center,1.0);
vec3 L = normalize (lightPosition - newPos.xyz);
float lambertTerm = dot(N,L);
ColorFS = ambient;
ColorFS = ambient;
if(lambertTerm > 0.0)
ColorFS += diffuse * lambertTerm;
if(lambertTerm > 0.0)
ColorFS += diffuse * lambertTerm;
int i;
for(i=0; i< NBVERTS_IN; i++)
......
......@@ -44,8 +44,6 @@ int NumberOfThreads = getSystemNumberOfCores();
std::map<std::string, RegisteredBaseAttribute*>* GenericMap::m_attributes_registry_map = NULL;
int GenericMap::m_nbInstances = 0;
std::vector< std::vector<Dart>* >* GenericMap::s_vdartsBuffers = NULL;
std::vector< std::vector<unsigned int>* >* GenericMap::s_vintsBuffers = NULL;
......@@ -55,11 +53,36 @@ std::vector< std::vector<unsigned int>* >* GenericMap::s_vintsBuffers = NULL;
std::vector<GenericMap*>* GenericMap::s_instances=NULL;
GenericMap::GenericMap():
m_nextMarkerId(0),
m_manipulator(NULL)
{
if(m_attributes_registry_map == NULL)
initAllStatics(NULL); // no need here to store the pointers
s_instances->push_back(this);
m_thread_ids.reserve(NB_THREAD+1);
m_thread_ids.push_back( std::this_thread::get_id() );
for(unsigned int i = 0; i < NB_ORBITS; ++i)
{
m_attribs[i].setOrbit(i) ;
m_attribs[i].setRegistry(m_attributes_registry_map) ;
}
init();
}
void GenericMap::copyAllStatics(const StaticPointers& sp)
{
m_attributes_registry_map = sp.att_registry;
s_instances = sp.instances;
s_vdartsBuffers = sp.vdartsBuffers;
s_vintsBuffers = sp.vintsBuffers;
}
void GenericMap::initAllStatics(StaticPointers* sp)
{
if(m_attributes_registry_map == NULL)
{
......@@ -99,18 +122,9 @@ GenericMap::GenericMap():
registerAttribute<MarkerBool>("MarkerBool");
}
m_nbInstances++;
if (s_instances==NULL)
s_instances= new std::vector<GenericMap*>;
s_instances->push_back(this);
m_thread_ids.reserve(NB_THREAD+1);
m_thread_ids.push_back( std::this_thread::get_id() );
if (s_vdartsBuffers == NULL)
{
s_vdartsBuffers = new std::vector< std::vector<Dart>* >[NB_THREAD];
......@@ -123,15 +137,13 @@ GenericMap::GenericMap():
// prealloc ?
}
}
for(unsigned int i = 0; i < NB_ORBITS; ++i)
if (sp != NULL)
{
m_attribs[i].setOrbit(i) ;
m_attribs[i].setRegistry(m_attributes_registry_map) ;
sp->att_registry = m_attributes_registry_map;
sp->instances = s_instances;
sp->vdartsBuffers = s_vdartsBuffers;
sp->vintsBuffers = s_vintsBuffers;
}
init();
}
GenericMap::~GenericMap()
......@@ -147,10 +159,14 @@ GenericMap::~GenericMap()
(*it).second->setInvalid() ;
attributeHandlers.clear() ;
// remove instance of table
auto it = std::find(s_instances->begin(), s_instances->end(), this);
*it = s_instances->back();
s_instances->pop_back();
// clean type registry if necessary
m_nbInstances--;
if (m_nbInstances <= 0)
if (s_instances->size() == 0)
{
for (std::map<std::string, RegisteredBaseAttribute*>::iterator it = m_attributes_registry_map->begin(); it != m_attributes_registry_map->end(); ++it)
delete it->second;
......@@ -168,11 +184,6 @@ GenericMap::~GenericMap()
}
// remove instance of table
auto it = std::find(s_instances->begin(), s_instances->end(), this);
*it = s_instances->back();
s_instances->pop_back();
}
bool GenericMap::askManipulate(MapManipulator* ptr)
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *