mirror of https://github.com/CGAL/cgal
more on parameterization demo.
This commit is contained in:
parent
0949438e32
commit
8f351ebd66
|
|
@ -48,7 +48,9 @@ protected slots:
|
|||
void on_actionSetPolyhedronA_triggered();
|
||||
void on_actionSetPolyhedronB_triggered();
|
||||
void on_actionInsideOut_triggered();
|
||||
|
||||
void on_actionMVC_triggered();
|
||||
void on_actionDCP_triggered();
|
||||
|
||||
// save
|
||||
// TODO: save all, save current (do we store the current file name?)
|
||||
|
|
@ -88,13 +90,20 @@ protected slots:
|
|||
// remeshing, in MainWindow_remeshing.cpp
|
||||
void on_actionRemeshing_triggered();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
enum Boolean_operation { BOOLEAN_UNION,
|
||||
BOOLEAN_INTERSECTION,
|
||||
BOOLEAN_DIFFERENCE };
|
||||
// define in MainWindow_boolean_operations.cpp
|
||||
enum Parameterization_method { PARAM_MVC,
|
||||
PARAM_DCP};
|
||||
// defined in MainWindow_boolean_operations.cpp
|
||||
void boolean_operation(const Boolean_operation operation);
|
||||
|
||||
// defined in MainWindow_parameterization.cpp
|
||||
void parameterize(const Parameterization_method method);
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@
|
|||
<string>Parameterization</string>
|
||||
</property>
|
||||
<addaction name="actionMVC" />
|
||||
<addaction name="on_actionDCP_triggered" />
|
||||
</widget>
|
||||
<addaction name="actionConvexHull" />
|
||||
<addaction name="actionKernel" />
|
||||
|
|
@ -535,6 +536,11 @@
|
|||
<string>Mean value coordinates</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="on_actionDCP_triggered" >
|
||||
<property name="text" >
|
||||
<string>Discrete conformal maps</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@
|
|||
|
||||
#include <CGAL/Parameterization_polyhedron_adaptor_3.h>
|
||||
#include <CGAL/parameterize.h>
|
||||
#include <CGAL/Discrete_conformal_map_parameterizer_3.h>
|
||||
#include <CGAL/Two_vertices_parameterizer_3.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void MainWindow::on_actionMVC_triggered()
|
||||
void MainWindow::parameterize(const Parameterization_method method)
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
|
|
@ -23,10 +25,66 @@ void MainWindow::on_actionMVC_triggered()
|
|||
time.start();
|
||||
typedef CGAL::Parameterization_polyhedron_adaptor_3<Polyhedron> Adaptor;
|
||||
Adaptor adaptor(*pMesh);
|
||||
std::cerr << "Parameterize...";
|
||||
typedef CGAL::Parameterizer_traits_3<Adaptor> Parameterizer;
|
||||
Parameterizer::Error_code err = CGAL::parameterize(adaptor);
|
||||
|
||||
bool success;
|
||||
switch(method)
|
||||
{
|
||||
case PARAM_MVC:
|
||||
{
|
||||
std::cerr << "Parameterize (MVC)...";
|
||||
typedef CGAL::Mean_value_coordinates_parameterizer_3<Adaptor> Parameterizer;
|
||||
Parameterizer::Error_code err = CGAL::parameterize(adaptor,Parameterizer());
|
||||
success = err == Parameterizer::OK;
|
||||
break;
|
||||
}
|
||||
case PARAM_DCP:
|
||||
{
|
||||
std::cerr << "Parameterize (DCP)...";
|
||||
typedef CGAL::Discrete_conformal_map_parameterizer_3<Adaptor,CGAL::Two_vertices_parameterizer_3<Adaptor> > Parameterizer;
|
||||
Parameterizer::Error_code err = CGAL::parameterize(adaptor,Parameterizer());
|
||||
success = err == Parameterizer::OK;
|
||||
}
|
||||
}
|
||||
|
||||
if(success)
|
||||
std::cout << "ok (" << time.elapsed() << " ms)" << std::endl;
|
||||
else
|
||||
{
|
||||
std::cout << "failure" << std::endl;
|
||||
QApplication::setOverrideCursor(Qt::ArrowCursor);
|
||||
return;
|
||||
}
|
||||
|
||||
// add parameterized mesh
|
||||
Polyhedron *pParameterization = new Polyhedron(*pMesh);
|
||||
Polyhedron::Vertex_iterator it1, it2;
|
||||
for(it1 = pMesh->vertices_begin(),
|
||||
it2 = pParameterization->vertices_begin();
|
||||
it1 != pMesh->vertices_end(),
|
||||
it2 != pParameterization->vertices_end();
|
||||
it1++, it2++)
|
||||
{
|
||||
// (u,v) pair is stored in any halfedge
|
||||
FT u = adaptor.info(it1->halfedge())->uv().x();
|
||||
FT v = adaptor.info(it1->halfedge())->uv().y();
|
||||
it2->point() = Point(u-0.5,v-0.5,0.0);
|
||||
}
|
||||
|
||||
scene->addPolyhedron(pParameterization,
|
||||
tr("%1 (parameterization)").arg(scene->polyhedronName(index)),
|
||||
Qt::magenta,
|
||||
scene->isPolyhedronActivated(index),
|
||||
scene->polyhedronRenderingMode(index));
|
||||
|
||||
QApplication::setOverrideCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionMVC_triggered()
|
||||
{
|
||||
parameterize(PARAM_MVC);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDCP_triggered()
|
||||
{
|
||||
parameterize(PARAM_DCP);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,6 +298,9 @@ Scene::draw(bool with_names)
|
|||
void
|
||||
Scene::draw(Polyhedron_entry& entry)
|
||||
{
|
||||
this->gl_render_facets(entry.polyhedron_ptr);
|
||||
|
||||
/*
|
||||
if(!entry.display_list_built)
|
||||
{
|
||||
entry.display_list = ::glGenLists(1);
|
||||
|
|
@ -315,6 +318,7 @@ Scene::draw(Polyhedron_entry& entry)
|
|||
}
|
||||
|
||||
::glCallList(entry.display_list);
|
||||
*/
|
||||
}
|
||||
|
||||
void Scene::gl_render_facets(Polyhedron_ptr ptr)
|
||||
|
|
|
|||
Loading…
Reference in New Issue