Commit 8167cd1c authored by Pierre Kraemer's avatar Pierre Kraemer

minor fixes

parent c165b337
...@@ -37,95 +37,95 @@ namespace Geom ...@@ -37,95 +37,95 @@ namespace Geom
template <typename VEC> template <typename VEC>
class BoundingBox class BoundingBox
{ {
public: public:
/**********************************************/ /**********************************************/
/* CONSTRUCTORS */ /* CONSTRUCTORS */
/**********************************************/ /**********************************************/
BoundingBox() ; BoundingBox() ;
// initialize the bounding box with one first point // initialize the bounding box with one first point
BoundingBox(const VEC& p) ; 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 // reinitialize the bounding box
void reset() ; void reset() ;
// add a point to the bounding box // add a point to the bounding box
void addPoint(const VEC& p) ; void addPoint(const VEC& p) ;
// return true if bb intersects the bounding box // return true if bb intersects the bounding box
bool intersects(const BoundingBox<VEC>& bb) ; bool intersects(const BoundingBox<VEC>& bb) ;
// fusion with the given bounding box // fusion with the given bounding box
void fusion(const BoundingBox<VEC>& bb) ; void fusion(const BoundingBox<VEC>& bb) ;
// return true if the point belongs strictly to a bounding box // return true if the point belongs strictly to a bounding box
bool contains(const VEC& p); bool contains(const VEC& p);
// return true if the segment belongs strictly to a bounding box // return true if the segment belongs strictly to a bounding box
bool contains(const VEC& a, const VEC& b); bool contains(const VEC& a, const VEC& b);
// return true if the bounding box belongs strictly to a bounding box // return true if the bounding box belongs strictly to a bounding box
bool contains(const BoundingBox<VEC> & bb); bool contains(const BoundingBox<VEC> & bb);
// scale the bounding box // scale the bounding box
void scale(typename VEC::DATA_TYPE size); void scale(typename VEC::DATA_TYPE size);
// 0-centered scale of the bounding box // 0-centered scale of the bounding box
void centeredScale(typename VEC::DATA_TYPE size); void centeredScale(typename VEC::DATA_TYPE size);
/// test if bb is intersected by a ray /// test if bb is intersected by a ray
bool rayIntersect(const VEC& P, const VEC& V) const; bool rayIntersect(const VEC& P, const VEC& V) const;
/**********************************************/ /**********************************************/
/* STREAM OPERATORS */ /* STREAM OPERATORS */
/**********************************************/ /**********************************************/
friend std::ostream& operator<<(std::ostream& out, const BoundingBox<VEC>& bb) friend std::ostream& operator<<(std::ostream& out, const BoundingBox<VEC>& bb)
{ {
out << bb.min() << " " << bb.max() ; out << bb.min() << " " << bb.max() ;
return out ; return out ;
} }
friend std::istream& operator>>(std::istream& in, BoundingBox<VEC>& bb) friend std::istream& operator>>(std::istream& in, BoundingBox<VEC>& bb)
{ {
in >> bb.min() >> bb.max() ; in >> bb.min() >> bb.max() ;
return in ; return in ;
} }
private: private:
bool m_initialized ; bool m_initialized ;
VEC m_pMin, m_pMax ; VEC m_pMin, m_pMax ;
} ; } ;
} // namespace Geom } // namespace Geom
......
...@@ -259,7 +259,9 @@ MapHandlerGen* Surface_Radiance_Plugin::importFromFile(const QString& fileName) ...@@ -259,7 +259,9 @@ MapHandlerGen* Surface_Radiance_Plugin::importFromFile(const QString& fileName)
mapParams.radianceTexture->update(); 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 = new Utils::VBO();
mapParams.paramVBO->updateData(mapParams.param); mapParams.paramVBO->updateData(mapParams.param);
...@@ -333,39 +335,53 @@ void Surface_Radiance_Plugin::decimate(const QString& mapName, const QString& po ...@@ -333,39 +335,53 @@ void Surface_Radiance_Plugin::decimate(const QString& mapName, const QString& po
mapParams.positionApproximator = new Algo::Surface::Decimation::Approximator_QEM<PFP2>(*map, position); mapParams.positionApproximator = new Algo::Surface::Decimation::Approximator_QEM<PFP2>(*map, position);
} }
if (mapParams.normalApproximator == NULL) // if (mapParams.normalApproximator == NULL)
{ // {
mapParams.normalApproximator = // mapParams.normalApproximator =
new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, PFP2::VEC3>( // new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, PFP2::VEC3>(
*map, // *map,
normal, // normal,
position, // position,
((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute() // ((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute()
); // );
} // }
if (mapParams.radianceApproximator == NULL) // if (mapParams.radianceApproximator == NULL)
{ // {
mapParams.radianceApproximator = // mapParams.radianceApproximator =
new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3> >( // new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3> >(
*map, // *map,
mapParams.radiance, // mapParams.radiance,
position, // position,
((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute() // ((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute()
); // );
} // }
if (mapParams.selector == NULL) if (mapParams.selector == NULL)
{ {
// mapParams.selector =
// new EdgeSelector_Radiance<PFP2>(
// *map,
// position,
// normal,
// mapParams.radiance,
// *(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator),
// *(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.normalApproximator),
// *(Algo::Surface::Decimation::Approximator<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>, EDGE>*)(mapParams.radianceApproximator)
// );
// mapParams.selector =
// new Algo::Surface::Decimation::EdgeSelector_QEM<PFP2>(
// *map,
// position,
// *(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator)
// );
mapParams.selector = mapParams.selector =
new EdgeSelector_Radiance<PFP2>( new Algo::Surface::Decimation::EdgeSelector_ColorNaive<PFP2>(
*map, *map,
position, position,
normal, *(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator)
mapParams.radiance,
*(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator),
*(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.normalApproximator),
*(Algo::Surface::Decimation::Approximator<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>, EDGE>*)(mapParams.radianceApproximator)
); );
} }
} }
......
...@@ -197,6 +197,7 @@ void Surface_Render_Plugin::vboRemoved(Utils::VBO *vbo) ...@@ -197,6 +197,7 @@ void Surface_Render_Plugin::vboRemoved(Utils::VBO *vbo)
{ {
m_dockTab->removePositionVBO(QString::fromStdString(vbo->name())); m_dockTab->removePositionVBO(QString::fromStdString(vbo->name()));
m_dockTab->removeNormalVBO(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) ...@@ -218,6 +219,11 @@ void Surface_Render_Plugin::vboRemoved(Utils::VBO *vbo)
mapParam.normalVBO = NULL; mapParam.normalVBO = NULL;
if(view->isLinkedToMap(map)) viewsToUpdate.insert(view); 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) foreach(View* v, viewsToUpdate)
......
...@@ -13,8 +13,8 @@ namespace SCHNApps ...@@ -13,8 +13,8 @@ namespace SCHNApps
Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugin* p) : Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugin* p) :
m_schnapps(s), m_schnapps(s),
m_plugin(p), m_plugin(p),
b_updatingUI(false), m_currentColorDial(0),
m_currentColorDial(0) b_updatingUI(false)
{ {
setupUi(this); setupUi(this);
...@@ -326,6 +326,9 @@ void Surface_Render_DockTab::updateMapParameters() ...@@ -326,6 +326,9 @@ void Surface_Render_DockTab::updateMapParameters()
combo_normalVBO->clear(); combo_normalVBO->clear();
combo_normalVBO->addItem("- select VBO -"); combo_normalVBO->addItem("- select VBO -");
combo_colorVBO->clear();
combo_colorVBO->addItem("- select VBO -");
View* view = m_schnapps->getSelectedView(); View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap(); MapHandlerGen* map = m_schnapps->getSelectedMap();
......
...@@ -105,7 +105,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -105,7 +105,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_pointSprite->setAttributePosition(m_selectedVerticesVBO); m_pointSprite->setAttributePosition(m_selectedVerticesVBO);
m_pointSprite->setColor(CGoGN::Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f)); 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->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(); m_pointSprite->enableVertexAttribs();
glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells()); glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells());
...@@ -126,7 +126,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -126,7 +126,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
{ {
case NormalAngle : case NormalAngle :
case SingleCell : { case SingleCell : {
m_pointSprite->setSize(30 * map->getBBdiagSize() / nbCells); m_pointSprite->setSize(map->getBBdiagSize() / 60.0f);
break; break;
} }
case WithinSphere : { case WithinSphere : {
......
...@@ -100,7 +100,10 @@ void MapHandler<PFP>::updateBB() ...@@ -100,7 +100,10 @@ void MapHandler<PFP>::updateBB()
VertexAttribute<VEC3, MAP> bbVertexAttribute(map, dynamic_cast<AttributeMultiVector<VEC3>*>(m_bbVertexAttribute)); VertexAttribute<VEC3, MAP> bbVertexAttribute(map, dynamic_cast<AttributeMultiVector<VEC3>*>(m_bbVertexAttribute));
m_bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*map, bbVertexAttribute); m_bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*map, bbVertexAttribute);
m_bbDiagSize = m_bb.diagSize(); if (m_bb.isInitialized())
m_bbDiagSize = m_bb.diagSize();
else
m_bbDiagSize = 0;
} }
else else
{ {
...@@ -117,6 +120,9 @@ void MapHandler<PFP>::updateBB() ...@@ -117,6 +120,9 @@ void MapHandler<PFP>::updateBB()
template <typename PFP> template <typename PFP>
void MapHandler<PFP>::updateBBDrawer() void MapHandler<PFP>::updateBBDrawer()
{ {
if (!m_bb.isInitialized())
return;
if (!m_bbDrawer) if (!m_bbDrawer)
m_bbDrawer = new Utils::Drawer(); m_bbDrawer = new Utils::Drawer();
......
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