Commit 9c85376f authored by Pierre Kraemer's avatar Pierre Kraemer

minor fixes

parent 4714ba08
......@@ -37,95 +37,95 @@ namespace Geom
template <typename VEC>
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<VEC>& bb) ;
// return true if bb intersects the bounding box
bool intersects(const BoundingBox<VEC>& bb) ;
// fusion with the given bounding box
void fusion(const BoundingBox<VEC>& bb) ;
// fusion with the given bounding box
void fusion(const BoundingBox<VEC>& 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<VEC> & bb);
// return true if the bounding box belongs strictly to a bounding box
bool contains(const BoundingBox<VEC> & 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<VEC>& bb)
{
out << bb.min() << " " << bb.max() ;
return out ;
}
friend std::ostream& operator<<(std::ostream& out, const BoundingBox<VEC>& bb)
{
out << bb.min() << " " << bb.max() ;
return out ;
}
friend std::istream& operator>>(std::istream& in, BoundingBox<VEC>& bb)
{
in >> bb.min() >> bb.max() ;
return in ;
}
friend std::istream& operator>>(std::istream& in, BoundingBox<VEC>& 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
......
......@@ -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<PFP2>(*map, position);
}
if (mapParams.normalApproximator == NULL)
{
mapParams.normalApproximator =
new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, PFP2::VEC3>(
*map,
normal,
position,
((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute()
);
}
if (mapParams.radianceApproximator == NULL)
{
mapParams.radianceApproximator =
new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3> >(
*map,
mapParams.radiance,
position,
((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute()
);
}
// if (mapParams.normalApproximator == NULL)
// {
// mapParams.normalApproximator =
// new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, PFP2::VEC3>(
// *map,
// normal,
// position,
// ((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute()
// );
// }
// if (mapParams.radianceApproximator == NULL)
// {
// mapParams.radianceApproximator =
// new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3> >(
// *map,
// mapParams.radiance,
// position,
// ((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute()
// );
// }
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 =
new EdgeSelector_Radiance<PFP2>(
new Algo::Surface::Decimation::EdgeSelector_ColorNaive<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)
*(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator)
);
}
}
......
......@@ -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)
......
......@@ -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();
......
......@@ -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 : {
......
......@@ -100,7 +100,10 @@ void MapHandler<PFP>::updateBB()
VertexAttribute<VEC3, MAP> bbVertexAttribute(map, dynamic_cast<AttributeMultiVector<VEC3>*>(m_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
{
......@@ -117,6 +120,9 @@ void MapHandler<PFP>::updateBB()
template <typename PFP>
void MapHandler<PFP>::updateBBDrawer()
{
if (!m_bb.isInitialized())
return;
if (!m_bbDrawer)
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