Commit 5845cb12 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps:

- correct bug when clicking "Cancel" in import dialog
- correct display bug when a camera is used in several views of different sizes
parent 3ac5a5a6
......@@ -25,42 +25,45 @@ void ImportPlugin::cb_import()
QString fileName = QFileDialog::getOpenFileName(m_window, "Import file", m_window->getAppPath(), "Mesh Files (*.ply *.off)");
QFileInfo fi(fileName);
MAP* m = new MAP();
MapHandler<PFP>* h = new MapHandler<PFP>(fi.baseName(), m_window, m);
std::vector<std::string> attrNames ;
Algo::Import::importMesh<PFP>(*m, fileName.toUtf8().constData(), attrNames);
// get vertex position attribute
VertexAttribute<VEC3> position = m->getAttribute<VEC3, CGoGN::VERTEX>(attrNames[0]);
// create VBO for vertex position attribute
Utils::VBO* positionVBO = h->getVBO(position.name());
positionVBO->updateData(position);
// compute vertex normal attribute
VertexAttribute<VEC3> normal = m->getAttribute<VEC3, CGoGN::VERTEX>("normal");
if(!normal.isValid())
normal = m->addAttribute<VEC3, CGoGN::VERTEX>("normal");
Algo::Geometry::computeNormalVertices<PFP>(*m, position, normal);
// create VBO for vertex normal attribute
CGoGN::Utils::VBO* normalVBO = h->getVBO("normal");
normalVBO->updateData(normal);
// compute map bounding box
CGoGN::Geom::BoundingBox<VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*m, position);
qglviewer::Vec min(bb.min()[0], bb.min()[1], bb.min()[2]);
qglviewer::Vec max(bb.max()[0], bb.max()[1], bb.max()[2]);
h->setBBmin(min);
h->setBBmax(max);
// compute primitive connectivity VBOs
h->updatePrimitives(CGoGN::Algo::Render::GL2::POINTS, CGoGN::allDarts);
h->updatePrimitives(CGoGN::Algo::Render::GL2::LINES, CGoGN::allDarts);
h->updatePrimitives(CGoGN::Algo::Render::GL2::TRIANGLES, CGoGN::allDarts);
m_window->addMap(h);
if(fi.exists())
{
MAP* m = new MAP();
MapHandler<PFP>* h = new MapHandler<PFP>(fi.baseName(), m_window, m);
std::vector<std::string> attrNames ;
Algo::Import::importMesh<PFP>(*m, fileName.toUtf8().constData(), attrNames);
// get vertex position attribute
VertexAttribute<VEC3> position = m->getAttribute<VEC3, CGoGN::VERTEX>(attrNames[0]);
// create VBO for vertex position attribute
Utils::VBO* positionVBO = h->getVBO(position.name());
positionVBO->updateData(position);
// compute vertex normal attribute
VertexAttribute<VEC3> normal = m->getAttribute<VEC3, CGoGN::VERTEX>("normal");
if(!normal.isValid())
normal = m->addAttribute<VEC3, CGoGN::VERTEX>("normal");
Algo::Geometry::computeNormalVertices<PFP>(*m, position, normal);
// create VBO for vertex normal attribute
CGoGN::Utils::VBO* normalVBO = h->getVBO("normal");
normalVBO->updateData(normal);
// compute map bounding box
CGoGN::Geom::BoundingBox<VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*m, position);
qglviewer::Vec min(bb.min()[0], bb.min()[1], bb.min()[2]);
qglviewer::Vec max(bb.max()[0], bb.max()[1], bb.max()[2]);
h->setBBmin(min);
h->setBBmax(max);
// compute primitive connectivity VBOs
h->updatePrimitives(CGoGN::Algo::Render::GL2::POINTS, CGoGN::allDarts);
h->updatePrimitives(CGoGN::Algo::Render::GL2::LINES, CGoGN::allDarts);
h->updatePrimitives(CGoGN::Algo::Render::GL2::TRIANGLES, CGoGN::allDarts);
m_window->addMap(h);
}
}
/**
......
......@@ -38,7 +38,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>4</number>
<number>0</number>
</property>
<widget class="QWidget" name="dartTab">
<attribute name="title">
......
......@@ -76,7 +76,7 @@ void MapsDialog::cb_selectedMapChanged()
const QString& name = current->text();
MapHandlerGen* mh = m_window->getMap(name);
GenericMap* m = mh->getGenericMap();
for(unsigned int orbit = DART; orbit <= FACE; ++orbit)
for(unsigned int orbit = DART; orbit <= VOLUME; ++orbit)
{
unsigned int nbc = m->getNbCells(orbit);
switch(orbit)
......@@ -105,6 +105,12 @@ void MapsDialog::cb_selectedMapChanged()
lineEdit_face_cells->setText(QString::number(nbc));
break;
}
case VOLUME : {
unsigned int nb = m->getNbOrbits<VOLUME>();
lineEdit_volume_orbits->setText(QString::number(nb));
lineEdit_volume_cells->setText(QString::number(nbc));
break;
}
}
if(m->isOrbitEmbedded(orbit))
......
......@@ -101,6 +101,8 @@ void View::init()
void View::preDraw()
{
m_currentCamera->setScreenWidthAndHeight(width(), height());
glm::mat4 mm = getCurrentModelViewMatrix();
glm::mat4 pm = getCurrentProjectionMatrix();
for(std::set< std::pair<void*, CGoGN::Utils::GLSLShader*> >::iterator it = CGoGN::Utils::GLSLShader::m_registeredShaders.begin();
......
......@@ -418,6 +418,12 @@ public:
*/
bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of an face
/*! @param d a dart of the volume
* @param f the functor to apply
*/
bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of a connected component
/*! @param d a dart of the connected component
* @param f the functor to apply
......
......@@ -198,6 +198,10 @@ inline bool Map2::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thre
return Map1::foreach_dart_of_cc(d, f, thread);
}
inline bool Map2::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread)
{
return foreach_dart_of_cc(d, f, thread);
}
inline bool Map2::foreach_dart_of_vertex1(Dart d, FunctorType& f, unsigned int thread)
{
......
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