Commit 74d64bc8 authored by Sylvain Thery's avatar Sylvain Thery

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

parents 8260d08a 1295cd62
......@@ -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()));
......@@ -28,6 +31,12 @@ MapHandlerGen* Surface_Import_Plugin::importFromFile(const QString& fileName)
if(fi.exists())
{
MapHandlerGen* mhg = m_schnapps->addMap(fi.baseName(), 2);
std::cout << "IMPORT PLUGIN 2" << std::endl;
std::cout << "PTR="<< GenericMap::s_instances<< std::endl;
for (auto inst : *GenericMap::s_instances)
std::cout << inst<< std::endl;
if(mhg)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
......@@ -62,11 +71,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
......
......@@ -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
......
......@@ -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() ;
......
......@@ -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 *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Topology/generic/marker.h"
#include <sstream>
namespace CGoGN
{
} // namespace CGoGN
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