diff --git a/CGoGN/include/Geometry/bounding_box.h b/CGoGN/include/Geometry/bounding_box.h index 1465970a1a83d9a076fc20cef924ed3e95ec84ed..be090635b24f6ee1ae41b155a9bfc865ca688184 100644 --- a/CGoGN/include/Geometry/bounding_box.h +++ b/CGoGN/include/Geometry/bounding_box.h @@ -37,95 +37,95 @@ namespace Geom template class BoundingBox { - public: - /**********************************************/ - /* CONSTRUCTORS */ - /**********************************************/ +public: + /**********************************************/ + /* CONSTRUCTORS */ + /**********************************************/ - BoundingBox() ; + BoundingBox() ; - // initialize the bounding box with one first point - BoundingBox(const VEC& p) ; + // initialize the bounding box with one first point + BoundingBox(const VEC& p) ; - /**********************************************/ - /* ACCESSORS */ - /**********************************************/ + /**********************************************/ + /* ACCESSORS */ + /**********************************************/ - VEC& min() ; + VEC& min() ; - const VEC& min() const ; + const VEC& min() const ; - VEC& max() ; + VEC& max() ; - const VEC& max() const ; + const VEC& max() const ; - typename VEC::DATA_TYPE size(unsigned int coord) const ; + typename VEC::DATA_TYPE size(unsigned int coord) const ; - typename VEC::DATA_TYPE maxSize() const ; + typename VEC::DATA_TYPE maxSize() const ; - typename VEC::DATA_TYPE minSize() const ; + typename VEC::DATA_TYPE minSize() const ; - VEC diag() const ; + VEC diag() const ; - typename VEC::DATA_TYPE diagSize() const ; + typename VEC::DATA_TYPE diagSize() const ; - VEC center() const ; + VEC center() const ; - bool isInitialized() const ; + bool isInitialized() const ; - /**********************************************/ - /* FUNCTIONS */ - /**********************************************/ + /**********************************************/ + /* FUNCTIONS */ + /**********************************************/ - // reinitialize the bounding box - void reset() ; + // reinitialize the bounding box + void reset() ; - // add a point to the bounding box - void addPoint(const VEC& p) ; + // add a point to the bounding box + void addPoint(const VEC& p) ; - // return true if bb intersects the bounding box - bool intersects(const BoundingBox& bb) ; + // return true if bb intersects the bounding box + bool intersects(const BoundingBox& bb) ; - // fusion with the given bounding box - void fusion(const BoundingBox& bb) ; + // fusion with the given bounding box + void fusion(const BoundingBox& bb) ; - // return true if the point belongs strictly to a bounding box - bool contains(const VEC& p); + // return true if the point belongs strictly to a bounding box + bool contains(const VEC& p); - // return true if the segment belongs strictly to a bounding box - bool contains(const VEC& a, const VEC& b); + // return true if the segment belongs strictly to a bounding box + bool contains(const VEC& a, const VEC& b); - // return true if the bounding box belongs strictly to a bounding box - bool contains(const BoundingBox & bb); + // return true if the bounding box belongs strictly to a bounding box + bool contains(const BoundingBox & bb); - // scale the bounding box - void scale(typename VEC::DATA_TYPE size); + // scale the bounding box + void scale(typename VEC::DATA_TYPE size); - // 0-centered scale of the bounding box - void centeredScale(typename VEC::DATA_TYPE size); + // 0-centered scale of the bounding box + void centeredScale(typename VEC::DATA_TYPE size); - /// test if bb is intersected by a ray - bool rayIntersect(const VEC& P, const VEC& V) const; + /// test if bb is intersected by a ray + bool rayIntersect(const VEC& P, const VEC& V) const; - /**********************************************/ - /* STREAM OPERATORS */ - /**********************************************/ + /**********************************************/ + /* STREAM OPERATORS */ + /**********************************************/ - friend std::ostream& operator<<(std::ostream& out, const BoundingBox& bb) - { - out << bb.min() << " " << bb.max() ; - return out ; - } + friend std::ostream& operator<<(std::ostream& out, const BoundingBox& bb) + { + out << bb.min() << " " << bb.max() ; + return out ; + } - friend std::istream& operator>>(std::istream& in, BoundingBox& bb) - { - in >> bb.min() >> bb.max() ; - return in ; - } + friend std::istream& operator>>(std::istream& in, BoundingBox& bb) + { + in >> bb.min() >> bb.max() ; + return in ; + } - private: - bool m_initialized ; - VEC m_pMin, m_pMax ; +private: + bool m_initialized ; + VEC m_pMin, m_pMax ; } ; } // namespace Geom diff --git a/SCHNApps/Plugins/surface_radiance/src/surface_radiance.cpp b/SCHNApps/Plugins/surface_radiance/src/surface_radiance.cpp index d1aa3361774de96bcef50b1ddb25c6ecd16ffdc9..60ef685e2aa4395172c454edb6da11bbbf0023df 100644 --- a/SCHNApps/Plugins/surface_radiance/src/surface_radiance.cpp +++ b/SCHNApps/Plugins/surface_radiance/src/surface_radiance.cpp @@ -259,7 +259,9 @@ MapHandlerGen* Surface_Radiance_Plugin::importFromFile(const QString& fileName) mapParams.radianceTexture->update(); - map->removeAttribute(mapParams.radiance); + // uncomment this line to be able to load multiple objects with different SH basis + // (decimation will be unavailable) +// map->removeAttribute(mapParams.radiance); mapParams.paramVBO = new Utils::VBO(); mapParams.paramVBO->updateData(mapParams.param); @@ -333,39 +335,53 @@ void Surface_Radiance_Plugin::decimate(const QString& mapName, const QString& po mapParams.positionApproximator = new Algo::Surface::Decimation::Approximator_QEM(*map, position); } - if (mapParams.normalApproximator == NULL) - { - mapParams.normalApproximator = - new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge( - *map, - normal, - position, - ((Algo::Surface::Decimation::Approximator*)(mapParams.positionApproximator))->getApproximationResultAttribute() - ); - } - - if (mapParams.radianceApproximator == NULL) - { - mapParams.radianceApproximator = - new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge >( - *map, - mapParams.radiance, - position, - ((Algo::Surface::Decimation::Approximator*)(mapParams.positionApproximator))->getApproximationResultAttribute() - ); - } +// if (mapParams.normalApproximator == NULL) +// { +// mapParams.normalApproximator = +// new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge( +// *map, +// normal, +// position, +// ((Algo::Surface::Decimation::Approximator*)(mapParams.positionApproximator))->getApproximationResultAttribute() +// ); +// } + +// if (mapParams.radianceApproximator == NULL) +// { +// mapParams.radianceApproximator = +// new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge >( +// *map, +// mapParams.radiance, +// position, +// ((Algo::Surface::Decimation::Approximator*)(mapParams.positionApproximator))->getApproximationResultAttribute() +// ); +// } if (mapParams.selector == NULL) { +// mapParams.selector = +// new EdgeSelector_Radiance( +// *map, +// position, +// normal, +// mapParams.radiance, +// *(Algo::Surface::Decimation::Approximator*)(mapParams.positionApproximator), +// *(Algo::Surface::Decimation::Approximator*)(mapParams.normalApproximator), +// *(Algo::Surface::Decimation::Approximator, EDGE>*)(mapParams.radianceApproximator) +// ); + +// mapParams.selector = +// new Algo::Surface::Decimation::EdgeSelector_QEM( +// *map, +// position, +// *(Algo::Surface::Decimation::Approximator*)(mapParams.positionApproximator) +// ); + mapParams.selector = - new EdgeSelector_Radiance( + new Algo::Surface::Decimation::EdgeSelector_ColorNaive( *map, position, - normal, - mapParams.radiance, - *(Algo::Surface::Decimation::Approximator*)(mapParams.positionApproximator), - *(Algo::Surface::Decimation::Approximator*)(mapParams.normalApproximator), - *(Algo::Surface::Decimation::Approximator, EDGE>*)(mapParams.radianceApproximator) + *(Algo::Surface::Decimation::Approximator*)(mapParams.positionApproximator) ); } } diff --git a/SCHNApps/Plugins/surface_render/src/surface_render.cpp b/SCHNApps/Plugins/surface_render/src/surface_render.cpp index b793b71ecfc786976d223c764707265ef5b31663..45be0b806b2512679442220c73a8c069d9abfc7a 100644 --- a/SCHNApps/Plugins/surface_render/src/surface_render.cpp +++ b/SCHNApps/Plugins/surface_render/src/surface_render.cpp @@ -197,6 +197,7 @@ void Surface_Render_Plugin::vboRemoved(Utils::VBO *vbo) { m_dockTab->removePositionVBO(QString::fromStdString(vbo->name())); m_dockTab->removeNormalVBO(QString::fromStdString(vbo->name())); + m_dockTab->removeColorVBO(QString::fromStdString(vbo->name())); } } @@ -218,6 +219,11 @@ void Surface_Render_Plugin::vboRemoved(Utils::VBO *vbo) mapParam.normalVBO = NULL; if(view->isLinkedToMap(map)) viewsToUpdate.insert(view); } + if(mapParam.colorVBO == vbo) + { + mapParam.colorVBO = NULL; + if(view->isLinkedToMap(map)) viewsToUpdate.insert(view); + } } foreach(View* v, viewsToUpdate) diff --git a/SCHNApps/Plugins/surface_render/src/surface_render_dockTab.cpp b/SCHNApps/Plugins/surface_render/src/surface_render_dockTab.cpp index abf2a5debafdbb56ade62629b9e428170de2621c..02aa5809bae0eff51e890920969a7a622bf82d81 100644 --- a/SCHNApps/Plugins/surface_render/src/surface_render_dockTab.cpp +++ b/SCHNApps/Plugins/surface_render/src/surface_render_dockTab.cpp @@ -13,8 +13,8 @@ namespace SCHNApps Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugin* p) : m_schnapps(s), m_plugin(p), - b_updatingUI(false), - m_currentColorDial(0) + m_currentColorDial(0), + b_updatingUI(false) { setupUi(this); @@ -326,6 +326,9 @@ void Surface_Render_DockTab::updateMapParameters() combo_normalVBO->clear(); combo_normalVBO->addItem("- select VBO -"); + combo_colorVBO->clear(); + combo_colorVBO->addItem("- select VBO -"); + View* view = m_schnapps->getSelectedView(); MapHandlerGen* map = m_schnapps->getSelectedMap(); diff --git a/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp b/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp index 6768846a5f63fb7dc38b5f685e250b53ca603986..29f839bdf9e9d074a5a4f262448fdc8137a2a988 100644 --- a/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp +++ b/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp @@ -105,7 +105,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) m_pointSprite->setAttributePosition(m_selectedVerticesVBO); m_pointSprite->setColor(CGoGN::Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f)); m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f)); - m_pointSprite->setSize(20 * map->getBBdiagSize() / nbCells); + m_pointSprite->setSize(map->getBBdiagSize() / 75.0f); m_pointSprite->enableVertexAttribs(); glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells()); @@ -126,7 +126,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) { case NormalAngle : case SingleCell : { - m_pointSprite->setSize(30 * map->getBBdiagSize() / nbCells); + m_pointSprite->setSize(map->getBBdiagSize() / 60.0f); break; } case WithinSphere : { diff --git a/SCHNApps/include/mapHandler.hpp b/SCHNApps/include/mapHandler.hpp index ba347b10d146a1a347153a19e95894e0ade5ee4f..206aadd7985540dc6889e74a24cf66dcafe68078 100644 --- a/SCHNApps/include/mapHandler.hpp +++ b/SCHNApps/include/mapHandler.hpp @@ -100,7 +100,10 @@ void MapHandler::updateBB() VertexAttribute bbVertexAttribute(map, dynamic_cast*>(m_bbVertexAttribute)); m_bb = CGoGN::Algo::Geometry::computeBoundingBox(*map, bbVertexAttribute); - m_bbDiagSize = m_bb.diagSize(); + if (m_bb.isInitialized()) + m_bbDiagSize = m_bb.diagSize(); + else + m_bbDiagSize = 0; } else { @@ -117,6 +120,9 @@ void MapHandler::updateBB() template void MapHandler::updateBBDrawer() { + if (!m_bb.isInitialized()) + return; + if (!m_bbDrawer) m_bbDrawer = new Utils::Drawer();