Commit 48ceef07 authored by Matthias Möller's avatar Matthias Möller

- set tooltip for Octree Depth value

- cleanup some code
- set slot description
- add splatclodu support

refs #1403

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free-Staging@16359 383ad7c9-94d9-4d36-a494-682f7c89f535
parent db843ead
......@@ -50,6 +50,7 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/SplatCloud/SplatCloud.hh>
#include "PoissonReconstructionT.hh"
......@@ -103,27 +104,44 @@ void PoissonPlugin::initializePlugin(){
}
void PoissonPlugin::pluginsInitialized()
{
std::cout << "set slot description" << std::endl;
emit setSlotDescription("poissonReconstruct(int)",tr("Reconstruct a triangle mesh from the given object."),
QStringList(tr("ObjectId")),QStringList(tr("ObjectId of the object")));
emit setSlotDescription("poissonReconstruct(IdList)",tr("Reconstruct one triangle mesh from the given objects."),
QStringList(tr("IdList")),QStringList(tr("Id of the objects")));
}
void PoissonPlugin::slotPoissonReconstruct(){
void PoissonPlugin::poissionReconstruct(int _id)
{
IdList list(1,_id);
poissionReconstruct(list);
}
void PoissonPlugin::poissionReconstruct(IdList _ids)
{
unsigned int n_points = 0;
std::vector< Real > pt_data;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,(DATA_TRIANGLE_MESH | DATA_POLY_MESH)) ;o_it != PluginFunctions::objectsEnd(); ++o_it) {
//datacontainer for the algorithm
//holds two 3D vectors in 6 columns, first the position, followed by the normal of the point
std::vector< Real > pt_data;
if ( o_it->dataType() == DATA_TRIANGLE_MESH) {
TriMeshObject* object = PluginFunctions::triMeshObject(*o_it);
//get data from objects
for (IdList::iterator idIter = _ids.begin(); idIter != _ids.end(); ++idIter)
{
BaseObjectData* obj = 0;
PluginFunctions::getObject(*idIter,obj);
if ( obj == 0 ) {
emit log(LOGERR , QString("Unable to get Object width id %1").arg(*idIter));
continue;
}
if ( object == 0 ) {
emit log(LOGWARN , "Unable to get object ( Only Triangle Meshes supported)");
continue;
}
//Triangle mesh
if ( obj->dataType() == DATA_TRIANGLE_MESH) {
// Get triangle mesh
TriMesh* mesh = PluginFunctions::triMesh(*o_it);
TriMesh* mesh = PluginFunctions::triMesh(obj);
n_points += mesh->n_vertices();
......@@ -139,44 +157,50 @@ void PoissonPlugin::slotPoissonReconstruct(){
pt_data.push_back( mesh->normal( vit )[2] );
}
}
//Poly mesh
else if ( obj->dataType() == DATA_POLY_MESH) {
// Get poly mesh
PolyMesh* mesh = PluginFunctions::polyMesh(obj);
if ( o_it->dataType() == DATA_POLY_MESH) {
PolyMeshObject* object = PluginFunctions::polyMeshObject(*o_it);
if ( object == 0 ) {
emit log(LOGWARN , "Unable to get object ( Only Triangle Meshes supported)");
continue;
}
// Get triangle mesh
PolyMesh* mesh = PluginFunctions::polyMesh(*o_it);
n_points += mesh->n_vertices();
n_points += mesh->n_vertices();
pt_data.reserve( n_points );
PolyMesh::VertexIter vit = mesh->vertices_begin();
for ( ; vit != mesh->vertices_end(); ++vit )
{
pt_data.push_back( mesh->point( vit )[0] );
pt_data.push_back( mesh->point( vit )[1] );
pt_data.push_back( mesh->point( vit )[2] );
pt_data.push_back( mesh->normal( vit )[0] );
pt_data.push_back( mesh->normal( vit )[1] );
pt_data.push_back( mesh->normal( vit )[2] );
}
}
//Splat cloud
else if( obj->dataType() == DATA_SPLATCLOUD)
{
// Get poly mesh
SplatCloud* cloud = PluginFunctions::splatCloud(obj);
pt_data.reserve( n_points );
PolyMesh::VertexIter vit = mesh->vertices_begin();
for ( ; vit != mesh->vertices_end(); ++vit )
{
pt_data.push_back( mesh->point( vit )[0] );
pt_data.push_back( mesh->point( vit )[1] );
pt_data.push_back( mesh->point( vit )[2] );
pt_data.push_back( mesh->normal( vit )[0] );
pt_data.push_back( mesh->normal( vit )[1] );
pt_data.push_back( mesh->normal( vit )[2] );
}
}
n_points += cloud->numSplats();
pt_data.reserve( n_points );
for (unsigned i = 0 ; i < cloud->numSplats(); ++i )
{
pt_data.push_back( cloud->positions( i )[0] );
pt_data.push_back( cloud->positions( i )[1] );
pt_data.push_back( cloud->positions( i )[2] );
pt_data.push_back( cloud->normals( i )[0] );
pt_data.push_back( cloud->normals( i )[1] );
pt_data.push_back( cloud->normals( i )[2] );
}
}
else
emit log(LOGERR,QString("ObjectType of Object with id %1 is unsupported").arg(*idIter));
}
// Get triangle mesh
TriMesh* final_mesh = NULL;
ACG::PoissonReconstructionT<TriMesh> pr;
ACG::PoissonReconstructionT<TriMesh>::Parameter params;
params.Depth = tool_->depthBox->value();
//create and reconstruct mesh
if ( !pt_data.empty() ) {
// Add empty triangle mesh
......@@ -185,20 +209,39 @@ void PoissonPlugin::slotPoissonReconstruct(){
TriMeshObject* finalObject = PluginFunctions::triMeshObject(meshId);
// Get triangle mesh
TriMesh* final_mesh = NULL;
PluginFunctions::getMesh(meshId,final_mesh);
//Reconstruct
ACG::PoissonReconstructionT<TriMesh> pr;
ACG::PoissonReconstructionT<TriMesh>::Parameter params;
params.Depth = tool_->depthBox->value();
if ( pr.run( pt_data, *final_mesh, params ) ) {
emit log(LOGINFO,"Reconstruction succeeded");
emit updatedObject(meshId,UPDATE_ALL);
finalObject->setName("Poisson Reconstruction.obj");
//finalObject->target(true);
} else {
emit log(LOGERR,"Reconstruction failed");
emit deleteObject( meshId );
}
}
}
void PoissonPlugin::slotPoissonReconstruct(){
IdList ids;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,(DATA_TRIANGLE_MESH | DATA_POLY_MESH)) ;o_it != PluginFunctions::objectsEnd(); ++o_it)
{
ids.push_back(o_it->id());
}
poissionReconstruct(ids);
}
......
......@@ -50,10 +50,11 @@
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include "PoissonToolbox.hh"
class PoissonPlugin : public QObject, BaseInterface, ToolboxInterface, LoadSaveInterface, LoggingInterface,AboutInfoInterface
class PoissonPlugin : public QObject, BaseInterface, ToolboxInterface, LoadSaveInterface, LoggingInterface, AboutInfoInterface, ScriptInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
......@@ -61,6 +62,7 @@ Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(AboutInfoInterface)
Q_INTERFACES(ScriptInterface)
//BaseInterface
......@@ -83,13 +85,26 @@ signals:
//AboutInfoInterface
void addAboutInfo(QString _text, QString _tabName );
//ScriptInterface
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
private slots:
void initializePlugin(); // BaseInterface
// BaseInterface
void initializePlugin();
void pluginsInitialized();
public slots:
private slots:
void slotPoissonReconstruct();
public slots:
void poissionReconstruct(int _id);
void poissionReconstruct(IdList _ids);
public :
PoissonPlugin();
~PoissonPlugin() {};
......
......@@ -17,54 +17,14 @@ namespace ACG {
//== IMPLEMENTATION ==========================================================
char* outputFile=NULL;
int echoStdout=0;
void DumpOutput( const char* format , ... )
{
// if( outputFile )
// {
// FILE* fp = fopen( outputFile , "a" );
// va_list args;
// va_start( args , format );
// vfprintf( fp , format , args );
// fclose( fp );
// va_end( args );
// }
// if( echoStdout )
// {
va_list args;
va_start( args , format );
vprintf( format , args );
va_end( args );
// }
va_list args;
va_start( args , format );
vprintf( format , args );
va_end( args );
}
void DumpOutput2( char* str , const char* format , ... )
{
// if( outputFile )
// {
// FILE* fp = fopen( outputFile , "a" );
// va_list args;
// va_start( args , format );
// vfprintf( fp , format , args );
// fclose( fp );
// va_end( args );
// }
// if( echoStdout )
// {
va_list args;
va_start( args , format );
vprintf( format , args );
va_end( args );
// }
// va_list args;
va_start( args , format );
vsprintf( str , format , args );
va_end( args );
if( str[strlen(str)-1]=='\n' ) str[strlen(str)-1] = 0;
}
template <class MeshT>
bool
PoissonReconstructionT<MeshT>::
......@@ -73,8 +33,6 @@ run( std::vector< Real >& _pt_data, MeshT& _mesh, const Parameter& _parameter )
m_parameter = _parameter;
double t;
// double tt=Time();
Real isoValue = 0;
Octree<2> tree;
......@@ -87,45 +45,42 @@ run( std::vector< Real >& _pt_data, MeshT& _mesh, const Parameter& _parameter )
tree.setBSplineData( m_parameter.Depth );
double maxMemoryUsage;
t=Time() , tree.maxMemoryUsage=0;
tree.maxMemoryUsage=0;
XForm4x4< Real > xForm = XForm4x4< Real >::Identity();
int pointCount = tree.setTreeMemory( _pt_data , m_parameter.Depth , m_parameter.MinDepth , m_parameter.Depth , Real(m_parameter.SamplesPerNode),
m_parameter.Scale , m_parameter.Confidence , m_parameter.PointWeight , m_parameter.AdaptiveExponent , xForm );
tree.ClipTree();
tree.finalize( m_parameter.IsoDivide );
// DumpOutput2( comments[commentNum++] , "# Tree set in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
DumpOutput( "Input Points: %d\n" , pointCount );
DumpOutput( "Leaves/Nodes: %d/%d\n" , tree.tree.leaves() , tree.tree.nodes() );
DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );
maxMemoryUsage = tree.maxMemoryUsage;
t=Time() , tree.maxMemoryUsage=0;
tree.maxMemoryUsage=0;
tree.SetLaplacianConstraints();
// DumpOutput2( comments[commentNum++] , "# Constraints set in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage())/(1<<20) );
maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );
t=Time() , tree.maxMemoryUsage=0;
tree.maxMemoryUsage=0;
tree.LaplacianMatrixIteration( m_parameter.SolverDivide, m_parameter.ShowResidual, m_parameter.MinIters, m_parameter.SolverAccuracy, m_parameter.Depth, m_parameter.FixedIters );
// DumpOutput2( comments[commentNum++] , "# Linear system solved in: %9.1f (s), %9.1f (MB)\n" , Time()-t , tree.maxMemoryUsage );
DumpOutput( "Memory Usage: %.3f MB\n" , float( MemoryInfo::Usage() )/(1<<20) );
maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );
CoredFileMeshData mesh;
if( m_parameter.Verbose ) tree.maxMemoryUsage=0;
t=Time();
double time=Time();
isoValue = tree.GetIsoValue();
DumpOutput( "Got average in: %f\n" , Time()-t );
DumpOutput( "Got average in: %f\n" , Time()-time );
DumpOutput( "Iso-Value: %e\n" , isoValue );
t = Time() , tree.maxMemoryUsage = 0;
tree.maxMemoryUsage = 0;
tree.GetMCIsoTriangles( isoValue , m_parameter.IsoDivide , &mesh );
_mesh.clear();
mesh.resetIterator();
DumpOutput( "Time for Iso: %f\n" , Time()-t );
DumpOutput( "Time for Iso: %f\n" , Time()-time );
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>445</width>
<height>63</height>
<height>71</height>
</rect>
</property>
<property name="windowTitle">
......@@ -18,6 +18,15 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Increased Octree Depth results in higher resolution of the recontructed model showing more details but also the memory consumption will increase.</string>
</property>
<property name="statusTip">
<string>Increased Octree Depth results in higher resolution of the recontructed model showing more details but also the memory consumption will increase.</string>
</property>
<property name="whatsThis">
<string>Increased Octree Depth results in higher resolution of the recontructed model showing more details but also the memory consumption will increase.</string>
</property>
<property name="text">
<string>Octree Depth</string>
</property>
......@@ -25,6 +34,15 @@
</item>
<item>
<widget class="QSpinBox" name="depthBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Increased Octree Depth results in higher resolution of the recontructed model showing more details but also the memory consumption will increase.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string>Increased Octree Depth results in higher resolution of the recontructed model showing more details but also the memory consumption will increase.</string>
</property>
<property name="whatsThis">
<string>Increased Octree Depth results in higher resolution of the recontructed model showing more details but also the memory consumption will increase.</string>
</property>
<property name="minimum">
<number>1</number>
</property>
......
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