diff --git a/Apps/Examples/volumeExplorer.cpp b/Apps/Examples/volumeExplorer.cpp index 62434a43438c3516893d21b945133250fbadb236..a2e24ae6ea846b8370ea72c4cbdcb615ffec211f 100644 --- a/Apps/Examples/volumeExplorer.cpp +++ b/Apps/Examples/volumeExplorer.cpp @@ -415,7 +415,7 @@ int main(int argc, char **argv) { position = myMap.addAttribute("position"); - int nb = 16; + int nb = 3; Algo::Volume::Tilings::Cubic::Grid cubic(myMap, nb, nb, nb); cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f); diff --git a/Apps/Tuto/Modelling/tuto_oper2.cpp b/Apps/Tuto/Modelling/tuto_oper2.cpp index c3764181a8a8f06228b4f6cf3cbc1455e88d471d..cf13bf06aaf466c11e793420c66b83ba1f86a249 100644 --- a/Apps/Tuto/Modelling/tuto_oper2.cpp +++ b/Apps/Tuto/Modelling/tuto_oper2.cpp @@ -132,7 +132,7 @@ void MyQT::operation(int x) break; case 7: CGoGNout <<"split face"<::recalPoints(const Geom::Vec3f& orig { VEC3& P = m_positions[i]; P -= m_fOrigin; - P[0] = (P[0]+0.5f) * m_fScal[0]; - P[1] = (P[1]+0.5f) * m_fScal[1]; - P[2] = (P[2]+0.5f) * m_fScal[2]; - P+=origin; + P[0] = P[0] * m_fScal[0]; + P[1] = P[1] * m_fScal[1]; + P[2] = P[2] * m_fScal[2]; +// P[0] = (P[0]+0.5f) * m_fScal[0]; +// P[1] = (P[1]+0.5f) * m_fScal[1]; +// P[2] = (P[2]+0.5f) * m_fScal[2]; + P-=origin; } } diff --git a/CGoGN/include/Container/attributeMultiVector.hpp b/CGoGN/include/Container/attributeMultiVector.hpp index 5ddc85d8f7bc337e9e59c61ad6f1b439ca63bbdf..d357e2091da77071eaa9871894e9fa2169b1b3c4 100644 --- a/CGoGN/include/Container/attributeMultiVector.hpp +++ b/CGoGN/include/Container/attributeMultiVector.hpp @@ -191,7 +191,7 @@ bool AttributeMultiVector::copy(const AttributeMultiVectorGen* atmvg) } for (unsigned int i = 0; i < atmv->m_tableData.size(); ++i) - std::memcpy(m_tableData[i], atmv->m_tableData[i], _BLOCKSIZE_ * sizeof(T)); + std::memcpy( (void*) m_tableData[i], (void*) atmv->m_tableData[i], _BLOCKSIZE_ * sizeof(T)); return true; } diff --git a/CGoGN/include/Topology/generic/traversor/traversorCell.hpp b/CGoGN/include/Topology/generic/traversor/traversorCell.hpp index 23d62cadaf8f5cfd7e612ef7884f8160e4233583..10d4bd2e189daf3f745f4b1ad482a07b351afb9d 100644 --- a/CGoGN/include/Topology/generic/traversor/traversorCell.hpp +++ b/CGoGN/include/Topology/generic/traversor/traversorCell.hpp @@ -648,28 +648,155 @@ inline void foreach_cell_until(const MAP& map, FUNC f, TraversalOptim opt) namespace Parallel { +///// internal functor for boost call +//template +//class ThreadFunction +//{ +//protected: +// typedef Cell CELL; +// std::vector& m_cells; +// Utils::Barrier& m_sync1; +// Utils::Barrier& m_sync2; +// bool& m_finished; +// unsigned int m_id; +// FUNC m_lambda; +// std::thread::id& m_threadId; // ref on thread::id in table of threads in genericMap for init at operator() + +//public: +// ThreadFunction(FUNC func, std::vector& vd, Utils::Barrier& s1, Utils::Barrier& s2, bool& finished, unsigned int id, std::thread::id& threadId) : +// m_cells(vd), m_sync1(s1), m_sync2(s2), m_finished(finished), m_id(id), m_lambda(func), m_threadId(threadId) +// { +// } + +// ThreadFunction(const ThreadFunction& tf): +// m_cells(tf.m_cells), m_sync1(tf.m_sync1), m_sync2(tf.m_sync2), m_finished(tf.m_finished), m_id(tf.m_id), m_lambda(tf.m_lambda){} + +// std::thread::id& getThreadId() { return m_threadId; } + +// void operator()() +// { +// // first thing to do set the thread id in genericMap +// m_threadId = std::this_thread::get_id(); + +// while (!m_finished) +// { +// for (typename std::vector::const_iterator it = m_cells.begin(); it != m_cells.end(); ++it) +// m_lambda(*it, m_id); +// m_cells.clear(); +// m_sync1.wait(); // wait every body has finished +// m_sync2.wait(); // wait vectors has been refilled +// } +// } +//}; + + +//template +//void foreach_cell_tmpl(MAP& map, FUNC func, unsigned int nbth) +//{ +// // buffer for cell traversing +// std::vector< Cell >* vd = new std::vector< Cell >[nbth]; +// for (unsigned int i = 0; i < nbth; ++i) +// vd[i].reserve(SIZE_BUFFER_THREAD); + +// unsigned int nb = 0; +// TraversorCell trav(map); +// Cell cell = trav.begin(); +// Cell c_end = trav.end(); +// while ((cell.dart != c_end.dart) && (nb < nbth*SIZE_BUFFER_THREAD) ) +// { +// vd[nb%nbth].push_back(cell); +// nb++; +// cell = trav.next(); +// } +// Utils::Barrier sync1(nbth+1); +// Utils::Barrier sync2(nbth+1); +// bool finished=false; + +// // launch threads +// std::thread** threads = new std::thread*[nbth]; +// ThreadFunction** tfs = new ThreadFunction*[nbth]; + +// // add place for nbth new threads in the table of threadId in genericmap +//// unsigned int firstThread = map.addEmptyThreadIds(nbth); + +// for (unsigned int i = 0; i < nbth; ++i) +// { +// std::thread::id& threadId = map.addEmptyThreadId(); +// tfs[i] = new ThreadFunction(func, vd[i], sync1, sync2, finished, 1+i, threadId); +// threads[i] = new std::thread( std::ref( *(tfs[i]) ) ); +// } + +// // and continue to traverse the map +// std::vector< Cell >* tempo = new std::vector< Cell >[nbth]; +// for (unsigned int i = 0; i < nbth; ++i) +// tempo[i].reserve(SIZE_BUFFER_THREAD); + +// while (cell.dart != c_end.dart) +// { +// for (unsigned int i = 0; i < nbth; ++i) +// tempo[i].clear(); +// unsigned int nb = 0; + +// while ((cell.dart != c_end.dart) && (nb < nbth*SIZE_BUFFER_THREAD) ) +// { +// tempo[nb%nbth].push_back(cell); +// nb++; +// cell = trav.next(); +// } +// sync1.wait();// wait for all thread to finish its vector +// for (unsigned int i = 0; i < nbth; ++i) +// vd[i].swap(tempo[i]); +// sync2.wait();// everybody refilled then go +// } + +// sync1.wait(); // wait for all thread to finish its vector +// finished = true; // say finsih to everyone +// sync2.wait(); // just wait for last barrier wait ! + +// // wait for all theads to be finished +// for (unsigned int i = 0; i < nbth; ++i) +// { +// threads[i]->join(); +// delete threads[i]; +// map.removeThreadId(tfs[i]->getThreadId()); +// delete tfs[i]; +// } + +// delete[] tfs; +// delete[] threads; +// delete[] vd; +// delete[] tempo; +//} + + /// internal functor for boost call -template +template class ThreadFunction { protected: typedef Cell CELL; - std::vector& m_cells; - Utils::Barrier& m_sync1; - Utils::Barrier& m_sync2; - bool& m_finished; + + std::vector m_cells; + unsigned int m_id; FUNC m_lambda; std::thread::id& m_threadId; // ref on thread::id in table of threads in genericMap for init at operator() + std::mutex& m_mutex_map; + TraversorCell& m_trav; + Cell& m_current_cell; + public: - ThreadFunction(FUNC func, std::vector& vd, Utils::Barrier& s1, Utils::Barrier& s2, bool& finished, unsigned int id, std::thread::id& threadId) : - m_cells(vd), m_sync1(s1), m_sync2(s2), m_finished(finished), m_id(id), m_lambda(func), m_threadId(threadId) + ThreadFunction(FUNC func,unsigned int id, std::thread::id& threadId, std::mutex& mutmap, TraversorCell& trav, Cell& current_cell) : + m_id(id), m_lambda(func), m_threadId(threadId), + m_mutex_map(mutmap), m_trav(trav), m_current_cell(current_cell) { } - ThreadFunction(const ThreadFunction& tf): - m_cells(tf.m_cells), m_sync1(tf.m_sync1), m_sync2(tf.m_sync2), m_finished(tf.m_finished), m_id(tf.m_id), m_lambda(tf.m_lambda){} + ThreadFunction(const ThreadFunction& tf): + m_id(tf.m_id), m_lambda(tf.m_lambda), + m_mutex_map(tf.mutmap), m_trav(tf.trav), m_current_cell(tf.current_cell) + {} std::thread::id& getThreadId() { return m_threadId; } @@ -678,81 +805,55 @@ public: // first thing to do set the thread id in genericMap m_threadId = std::this_thread::get_id(); - while (!m_finished) + m_cells.reserve(SIZE_BUFFER_THREAD); + + bool finished = false; + + while (!finished) { - for (typename std::vector::const_iterator it = m_cells.begin(); it != m_cells.end(); ++it) - m_lambda(*it, m_id); - m_cells.clear(); - m_sync1.wait(); // wait every body has finished - m_sync2.wait(); // wait vectors has been refilled + // get data + m_mutex_map.lock(); + Cell c_end = m_trav.end(); + while ((m_current_cell.dart != c_end.dart) && (m_cells.size() ::const_iterator it = m_cells.begin(); it != m_cells.end(); ++it) + m_lambda(*it, m_id); + m_cells.clear(); + } } } }; - template void foreach_cell_tmpl(MAP& map, FUNC func, unsigned int nbth) { - // buffer for cell traversing - std::vector< Cell >* vd = new std::vector< Cell >[nbth]; - for (unsigned int i = 0; i < nbth; ++i) - vd[i].reserve(SIZE_BUFFER_THREAD); - unsigned int nb = 0; TraversorCell trav(map); Cell cell = trav.begin(); - Cell c_end = trav.end(); - while ((cell.dart != c_end.dart) && (nb < nbth*SIZE_BUFFER_THREAD) ) - { - vd[nb%nbth].push_back(cell); - nb++; - cell = trav.next(); - } - Utils::Barrier sync1(nbth+1); - Utils::Barrier sync2(nbth+1); - bool finished=false; + + std::mutex mutex_map; // launch threads std::thread** threads = new std::thread*[nbth]; - ThreadFunction** tfs = new ThreadFunction*[nbth]; - - // add place for nbth new threads in the table of threadId in genericmap -// unsigned int firstThread = map.addEmptyThreadIds(nbth); + ThreadFunction** tfs = new ThreadFunction*[nbth]; for (unsigned int i = 0; i < nbth; ++i) { std::thread::id& threadId = map.addEmptyThreadId(); - tfs[i] = new ThreadFunction(func, vd[i], sync1, sync2, finished, 1+i, threadId); + tfs[i] = new ThreadFunction(func, 1+i,threadId,mutex_map,trav,cell); threads[i] = new std::thread( std::ref( *(tfs[i]) ) ); } - // and continue to traverse the map - std::vector< Cell >* tempo = new std::vector< Cell >[nbth]; - for (unsigned int i = 0; i < nbth; ++i) - tempo[i].reserve(SIZE_BUFFER_THREAD); - - while (cell.dart != c_end.dart) - { - for (unsigned int i = 0; i < nbth; ++i) - tempo[i].clear(); - unsigned int nb = 0; - - while ((cell.dart != c_end.dart) && (nb < nbth*SIZE_BUFFER_THREAD) ) - { - tempo[nb%nbth].push_back(cell); - nb++; - cell = trav.next(); - } - sync1.wait();// wait for all thread to finish its vector - for (unsigned int i = 0; i < nbth; ++i) - vd[i].swap(tempo[i]); - sync2.wait();// everybody refilled then go - } - - sync1.wait(); // wait for all thread to finish its vector - finished = true; // say finsih to everyone - sync2.wait(); // just wait for last barrier wait ! - // wait for all theads to be finished for (unsigned int i = 0; i < nbth; ++i) { @@ -764,10 +865,9 @@ void foreach_cell_tmpl(MAP& map, FUNC func, unsigned int nbth) delete[] tfs; delete[] threads; - delete[] vd; - delete[] tempo; } + template void foreach_cell(MAP& map, FUNC func, TraversalOptim opt, unsigned int nbth) { diff --git a/CGoGN/include/Utils/vbo.hpp b/CGoGN/include/Utils/vbo.hpp index 4b5ccc662071a61d9ca6ed0a73c93005f665532f..1a5c7b0d676d909f2714e7f0f7b5bbdfa0a3dd26 100644 --- a/CGoGN/include/Utils/vbo.hpp +++ b/CGoGN/include/Utils/vbo.hpp @@ -28,23 +28,42 @@ namespace CGoGN namespace Utils { -template +template void VBO::updateData(std::vector& data) { if (m_lock) { - CGoGNerr << "Error locked VBO" << CGoGNendl; + CGoGNerr << "VBO::updateData : Error locked VBO" << CGoGNendl; return; } if (data.empty()) return; - m_data_size = sizeof(T) / sizeof(float); + m_data_size = VEC_DIM; m_nbElts = uint32(data.size()); - glBindBuffer(GL_ARRAY_BUFFER, *m_id); - glBufferData(GL_ARRAY_BUFFER, m_nbElts * sizeof(T), &(data[0]), GL_STREAM_DRAW); + + if (sizeof(T) / sizeof(double) == VEC_DIM) + { + unsigned int nbf = m_nbElts * m_data_size; + float* buffer = new float[nbf]; + float* ptr_out = buffer; + double* ptr_in = reinterpret_cast(&(data[0])); + for (unsigned int i=0; i + template void updateData(std::vector& data); void* lockPtr(); diff --git a/CGoGN/src/Utils/GLSLShader.cpp b/CGoGN/src/Utils/GLSLShader.cpp index d00b72cd14fc6d470404af980d8167d6f421a1d2..3cca7c3d44778e43d085546b63e159e11cf1eb03 100644 --- a/CGoGN/src/Utils/GLSLShader.cpp +++ b/CGoGN/src/Utils/GLSLShader.cpp @@ -39,43 +39,7 @@ namespace CGoGN namespace Utils { -//#ifdef CGOGN_USE_OGL_CORE_PROFILE -//unsigned int GLSLShader::CURRENT_OGL_VERSION = 3; -//unsigned int GLSLShader::MAJOR_OGL_CORE = 3; -//unsigned int GLSLShader::MINOR_OGL_CORE = 3; -//#else -//unsigned int GLSLShader::CURRENT_OGL_VERSION = 2; -//unsigned int GLSLShader::MAJOR_OGL_CORE = 2; -//unsigned int GLSLShader::MINOR_OGL_CORE = 1; -//#endif - - - -//std::string GLSLShader::DEFINES_GL2=\ -//"#version 110\n" -//"#define PRECISION float pipo_PRECISION\n" -//"#define ATTRIBUTE attribute\n" -//"#define VARYING_VERT varying\n" -//"#define VARYING_FRAG varying\n" -//"#define FRAG_OUT_DEF float pipo_FRAGDEF\n" -//"#define FRAG_OUT gl_FragColor\n" -//"#define INVARIANT_POS float pipo_INVARIANT\n" -//"#define TEXTURE2D texture2D\n"; - - -//std::string GLSLShader::DEFINES_GL3=\ -//"#version 150\n" -//"#define PRECISION precision highp float\n" -//"#define ATTRIBUTE in\n" -//"#define VARYING_VERT out\n" -//"#define VARYING_FRAG in\n" -//"#define FRAG_OUT_DEF out vec4 outFragColor\n" -//"#define FRAG_OUT outFragColor\n" -//"#define INVARIANT_POS invariant gl_Position\n" -//"#define TEXTURE2D texture\n"; - - -//std::string* GLSLShader::DEFINES_GL = NULL; + std::vector GLSLShader::m_pathes; diff --git a/CGoGN/src/Utils/drawer.cpp b/CGoGN/src/Utils/drawer.cpp index 1a0167dedfd5ef2f40508fa4ac2807aac5003efe..6dbce3f87b0dc0ab3f6557ccae0348848a53a024 100644 --- a/CGoGN/src/Utils/drawer.cpp +++ b/CGoGN/src/Utils/drawer.cpp @@ -190,6 +190,9 @@ void Drawer::newList(GLenum comp) m_dataPos.clear(); m_dataCol.clear(); m_begins.clear(); + m_begins_point.clear(); + m_begins_line.clear(); + m_begins_face.clear(); } void Drawer::endList() diff --git a/README.md b/README.md index 8e64e4ca6c16fc6cab1f37e74de4f729dcc085f8..60e5ebc87828786193ebee5381384025ba497782 100644 --- a/README.md +++ b/README.md @@ -78,10 +78,7 @@ Dependencies ------------ * install (or compile) Qt (choose 32/64 bits) * install python 2.7 (choose 32/64 bits) (Needed for SCHNApps) -* Other Windows dependencies are furnished at: - * http://cgogn.unistra.fr/Dependencies/dependencies.txt - * http://cgogn.unistra.fr/Dependencies/windows_dependencies32.zip - * http://cgogn.unistra.fr/Dependencies/windows_dependencies64.zip +* Other Windows dependencies are furnished at: http://cgogn.unistra.fr/download **Supported compilers: Visual C++ 2013 (12.0) or greater** diff --git a/SCHNApps/Plugins/CMakeLists.txt b/SCHNApps/Plugins/CMakeLists.txt index 7d711cfb125bc6a2d6e550c902bb1a3f98241bc8..d4fa96a0a5ffef9e89734103939e744c27b8af7c 100644 --- a/SCHNApps/Plugins/CMakeLists.txt +++ b/SCHNApps/Plugins/CMakeLists.txt @@ -24,14 +24,15 @@ ADD_SUBDIRECTORY(surface_subdivision) ADD_SUBDIRECTORY(surface_selection) ADD_SUBDIRECTORY(surface_deformation) ADD_SUBDIRECTORY(surface_modelisation) -#ADD_SUBDIRECTORY(surface_tilings) -ADD_SUBDIRECTORY(surface_distance) ADD_SUBDIRECTORY(surface_radiance) +ADD_SUBDIRECTORY(surface_distance) +ADD_SUBDIRECTORY(volume_import) + +#ADD_SUBDIRECTORY(surface_tilings) #ADD_SUBDIRECTORY(cage2D_deformation) #ADD_SUBDIRECTORY(cage3D_deformation) -ADD_SUBDIRECTORY(volume_import) #ADD_SUBDIRECTORY(volume_render) #ADD_SUBDIRECTORY(volumetric) diff --git a/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp b/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp index eb995123f90d68fdbb168e78df4b9f315e2e4e9e..ababd7100336331b3be6f41db9c6a5afc7e58d9b 100644 --- a/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp +++ b/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp @@ -40,7 +40,7 @@ bool Surface_Selection_Plugin::enable() m_selectedEdgesDrawer = new Utils::Drawer(1); m_selectedFacesDrawer = new Utils::Drawer(); - m_selectedFacesDrawer->setFaceShading(true); + m_selectedFacesDrawer->setFaceShading(false); m_selectingCellDrawer = new Utils::Drawer(1); @@ -110,7 +110,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit); if(selector) { - unsigned int nbCells = map->getGenericMap()->getNbCells(orbit); +// unsigned int nbCells = map->getGenericMap()->getNbCells(orbit); switch(orbit) { case VERTEX : { @@ -132,7 +132,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) { std::vector selectionPoint; selectionPoint.push_back(p.positionAttribute[m_selectingVertex]); - m_selectionSphereVBO->updateData(selectionPoint); + m_selectionSphereVBO->updateData<3>(selectionPoint); m_pointSprite->setAttributePosition(m_selectionSphereVBO); m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f)); m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f)); @@ -184,7 +184,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) // PFP2::MAP* m = static_cast*>(map)->getMap(); std::vector selectionPoint; selectionPoint.push_back(p.positionAttribute[m_selectingEdge.dart]); - m_selectionSphereVBO->updateData(selectionPoint); + m_selectionSphereVBO->updateData<3>(selectionPoint); m_pointSprite->setAttributePosition(m_selectionSphereVBO); m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f)); @@ -237,7 +237,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) std::vector selectionPoint; selectionPoint.push_back(p.positionAttribute[m_selectingFace.dart]); - m_selectionSphereVBO->updateData(selectionPoint); + m_selectionSphereVBO->updateData<3>(selectionPoint); m_pointSprite->setAttributePosition(m_selectionSphereVBO); m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f)); @@ -561,7 +561,7 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering() std::vector selectedPoints; for(std::vector::const_iterator v = selectedCells.begin(); v != selectedCells.end(); ++v) selectedPoints.push_back(p.positionAttribute[*v]); - m_selectedVerticesVBO->updateData(selectedPoints); + m_selectedVerticesVBO->updateData<3>(selectedPoints); m_selectedVertices_dirty = false; break; } @@ -609,7 +609,6 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering() } m_selectedFacesDrawer->end(); m_selectedFacesDrawer->endList(); - m_selectedFacesDrawer->setFaceShading(true); m_selectedFaces_dirty = false; break; } diff --git a/SCHNApps/Plugins/surface_selection/src/surface_selection_dockTab.cpp b/SCHNApps/Plugins/surface_selection/src/surface_selection_dockTab.cpp index de8e706aabd895d599f50c0c61e75af912578360..cf756c922b0f0a9ccc68e224b763286d6ae94984 100644 --- a/SCHNApps/Plugins/surface_selection/src/surface_selection_dockTab.cpp +++ b/SCHNApps/Plugins/surface_selection/src/surface_selection_dockTab.cpp @@ -178,11 +178,11 @@ void Surface_Selection_DockTab::clearPressed() { MapHandlerGen* map = m_schnapps->getSelectedMap(); unsigned int orbit = m_schnapps->getCurrentOrbit(); - - if (map) + CellSelectorGen* sel = m_schnapps->getSelectedSelector(orbit); + if (map && sel) { - m_plugin->clearSelection(map->getName(), orbit, m_schnapps->getSelectedSelector(orbit)->getName()); - m_plugin->pythonRecording("clearSelection", "", map->getName(), orbit, m_schnapps->getSelectedSelector(orbit)->getName()); + m_plugin->clearSelection(map->getName(), orbit, sel->getName()); + m_plugin->pythonRecording("clearSelection", "", map->getName(), orbit, sel->getName()); } } } diff --git a/SCHNApps/src/view.cpp b/SCHNApps/src/view.cpp index 142a4595ce6710af65ed08d81fbf37c6ee4666e1..804945e1a86f801d5bdd9eeed5e03c704e4e76e5 100644 --- a/SCHNApps/src/view.cpp +++ b/SCHNApps/src/view.cpp @@ -329,7 +329,7 @@ void View::init() std::cout << "using " << glGetString(GL_VERSION) << std::endl; - qglviewer::Camera* c = this->camera(); +// qglviewer::Camera* c = this->camera(); this->setCamera(m_currentCamera); // delete c;