diff --git a/src/fgt/edit_virtual_scan/edit_virtual_scan.pro b/src/fgt/edit_virtual_scan/edit_virtual_scan.pro new file mode 100644 index 000000000..7a1c694d1 --- /dev/null +++ b/src/fgt/edit_virtual_scan/edit_virtual_scan.pro @@ -0,0 +1,22 @@ +include( ../../shared.pri ) + +QT += opengl + +HEADERS += edit_virtual_scan_factory.h \ + edit_virtual_scan_plugin.h \ + edit_vs_widget.h \ + my_gl_widget.h \ + vs/povs_generator.h \ + vs/resources.h \ + vs/sampler.h \ + vs/simple_renderer.h \ + vs/stages.h \ + vs/utils.h + +SOURCES += edit_virtual_scan_factory.cpp \ + edit_virtual_scan_plugin.cpp \ + edit_vs_widget.cpp + +TARGET = edit_virtual_scan + +RESOURCES += edit_virtual_scan.qrc diff --git a/src/fgt/edit_virtual_scan/edit_virtual_scan.qrc b/src/fgt/edit_virtual_scan/edit_virtual_scan.qrc new file mode 100644 index 000000000..b4ba7f709 --- /dev/null +++ b/src/fgt/edit_virtual_scan/edit_virtual_scan.qrc @@ -0,0 +1,5 @@ + + + images/icon.png + + diff --git a/src/fgt/edit_virtual_scan/edit_virtual_scan_factory.cpp b/src/fgt/edit_virtual_scan/edit_virtual_scan_factory.cpp new file mode 100644 index 000000000..6d34b8a5f --- /dev/null +++ b/src/fgt/edit_virtual_scan/edit_virtual_scan_factory.cpp @@ -0,0 +1,50 @@ +#include "edit_virtual_scan_factory.h" +#include "edit_virtual_scan_plugin.h" + +EditVirtualScanFactory::EditVirtualScanFactory( void ) +{ + editVirtualScan = new QAction( QIcon( ":/images/icon.png" ), "Virtual Scan Sampling", this ); + + actionList << editVirtualScan; + + foreach( QAction* editAction, actionList ) + { + editAction->setCheckable( true ); + } +} + +EditVirtualScanFactory::~EditVirtualScanFactory( void ) +{ + delete editVirtualScan; +} + +QList< QAction* > EditVirtualScanFactory::actions( void ) const +{ + return actionList; +} + +MeshEditInterface* EditVirtualScanFactory::getMeshEditInterface( QAction* action ) +{ + if( action == editVirtualScan ) + { + return new EditVirtualScanPlugin(); + } + else + { + assert( 0 ); + } +} + +QString EditVirtualScanFactory::getEditToolDescription( QAction* action ) +{ + if( action == editVirtualScan ) + { + return EditVirtualScanPlugin::Info(); + } + else + { + return tr( "Invalid Operation" ); + } +} + +Q_EXPORT_PLUGIN(EditVirtualScanFactory) diff --git a/src/fgt/edit_virtual_scan/edit_virtual_scan_factory.h b/src/fgt/edit_virtual_scan/edit_virtual_scan_factory.h new file mode 100644 index 000000000..2f838ba5f --- /dev/null +++ b/src/fgt/edit_virtual_scan/edit_virtual_scan_factory.h @@ -0,0 +1,31 @@ +#ifndef EDIT_VIRTUAL_SCAN_FACTORY_PLUGIN_H +#define EDIT_VIRTUAL_SCAN_FACTORY_PLUGIN_H + +#include +#include + +class EditVirtualScanFactory: public QObject, public MeshEditInterfaceFactory +{ + + Q_OBJECT + Q_INTERFACES(MeshEditInterfaceFactory) + +public: + + /* constructor and destructor */ + EditVirtualScanFactory ( void ); + virtual ~EditVirtualScanFactory ( void ); + + /* MeshEditInterfaceFactory implementation */ + virtual QList< QAction* > actions ( void ) const; + virtual MeshEditInterface* getMeshEditInterface ( QAction* ); + virtual QString getEditToolDescription ( QAction* ); + +private: + + QList< QAction* > actionList; + QAction* editVirtualScan; + +}; + +#endif diff --git a/src/fgt/edit_virtual_scan/edit_virtual_scan_plugin.cpp b/src/fgt/edit_virtual_scan/edit_virtual_scan_plugin.cpp new file mode 100644 index 000000000..12ebc228f --- /dev/null +++ b/src/fgt/edit_virtual_scan/edit_virtual_scan_plugin.cpp @@ -0,0 +1,230 @@ +#include "edit_virtual_scan_plugin.h" +#include "my_gl_widget.h" + +#include + +// #include + +EditVirtualScanPlugin::EditVirtualScanPlugin( void ) +{ + dockWidget = 0; + editVsWidget = 0; + unifyClouds = true; +} + +EditVirtualScanPlugin::~EditVirtualScanPlugin( void ) +{ + ; +} + +const QString EditVirtualScanPlugin::Info( void ) +{ + return tr( "Virtual Scan Sampling" ); +} + +bool EditVirtualScanPlugin::StartEdit( MeshModel& m, GLArea* parent ) +{ + dockWidget = new QDockWidget( parent->window() ); + editVsWidget = new EditVsWidget( dockWidget ); + QPoint p = parent->mapToGlobal( QPoint( 0, 0 ) ); + + connectWidgetEvents(); + + // get the current rendering mode + params.cmDrawMode = parent->rm.drawMode; + params.cmColorMode = parent->rm.colorMode; + params.cmTextureMode = parent->rm.textureMode; + + // save some useful informations; + inputMeshModel = &m; + glArea = parent; + + // look for pre-computed povs + CMeshO::PerMeshAttributeHandle< std::vector< Pov > > povs_handle; + povs_handle = vcg::tri::Allocator< CMeshO >::GetPerMeshAttribute< std::vector< Pov > >( m.cm, "pointofviews" ); + bool customPovsAvailable = vcg::tri::Allocator< CMeshO >::IsValidHandle( m.cm, povs_handle ); + if( customPovsAvailable ) + { + params.customPovs = povs_handle(); + } + + // initialize widgets and indirectly the virtual scanning parameters + editVsWidget->initializeWidgets( customPovsAvailable, 25, 0.0f, 1.0f, 0.0f, 360, 6, 200, + 9, 20, 40, 20, 60, true ); + + dockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); + dockWidget->setWidget( editVsWidget ); + dockWidget->setGeometry( 5 + p.x(), p.y() + 5, editVsWidget->width(), parent->height() - 10 ); + dockWidget->setFloating( true ); + dockWidget->setVisible( true ); + + return true; +} + +void EditVirtualScanPlugin::EndEdit( MeshModel& m, GLArea* parent ) +{ + disconnectWidgetEvents(); + delete editVsWidget; + delete dockWidget; +} + +void EditVirtualScanPlugin::Decorate( MeshModel& m, GLArea* parent ) +{ + ; +} + +void EditVirtualScanPlugin::mousePressEvent( QMouseEvent* event, MeshModel& m, GLArea* parent ) +{ + ; +} + +void EditVirtualScanPlugin::mouseMoveEvent( QMouseEvent* event, MeshModel& m, GLArea* parent ) +{ + ; +} + +void EditVirtualScanPlugin::mouseReleaseEvent( QMouseEvent* event, MeshModel& m, GLArea* parent ) +{ + ; +} + +void EditVirtualScanPlugin::connectWidgetEvents( void ) +{ + QObject::connect ( editVsWidget, SIGNAL(customPovsMode(bool)), this, SLOT(customPovsMode(bool)) ); + QObject::connect ( editVsWidget, SIGNAL(povsNumberChanged(int)), this, SLOT(povsNumberChanged(int)) ); + QObject::connect ( editVsWidget, SIGNAL(xAxisChanged(float)), this, SLOT(xAxisChanged(float)) ); + QObject::connect ( editVsWidget, SIGNAL(yAxisChanged(float)), this, SLOT(yAxisChanged(float)) ); + QObject::connect ( editVsWidget, SIGNAL(zAxisChanged(float)), this, SLOT(zAxisChanged(float)) ); + QObject::connect ( editVsWidget, SIGNAL(povConeGapChanged(int)), this, SLOT(povsConeGapChanged(int)) ); + QObject::connect ( editVsWidget, SIGNAL(uResChanged(int)), this, SLOT(uResChanged(int)) ); + QObject::connect ( editVsWidget, SIGNAL(uConeGapChanged(int)), this, SLOT(uConeGapChanged(int)) ); + QObject::connect ( editVsWidget, SIGNAL(fResChanged(int)), this, SLOT(fResChanged(int)) ); + QObject::connect ( editVsWidget, SIGNAL(bigJumpChanged(float)), this, SLOT(bigJumpChanged(float)) ); + QObject::connect ( editVsWidget, SIGNAL(borderFGapChanged(int)), this, SLOT(borderFGapChanged(int)) ); + QObject::connect ( editVsWidget, SIGNAL(smallJumpChanged(float)), this, SLOT(smallJumpChanged(float)) ); + QObject::connect ( editVsWidget, SIGNAL(normalsAngleChanged(int)), this, SLOT(normalsAngleChanged(int)) ); + QObject::connect ( editVsWidget, SIGNAL(unifyPointClouds(bool)), this, SLOT(unifyPointClouds(bool)) ); + QObject::connect ( editVsWidget, SIGNAL(go()), this, SLOT(go()) ); +} + +void EditVirtualScanPlugin::disconnectWidgetEvents( void ) +{ + QObject::disconnect ( editVsWidget, SIGNAL(customPovsMode(bool)), this, SLOT(customPovsMode(bool)) ); + QObject::disconnect ( editVsWidget, SIGNAL(povsNumberChanged(int)), this, SLOT(povsNumberChanged(int)) ); + QObject::disconnect ( editVsWidget, SIGNAL(xAxisChanged(float)), this, SLOT(xAxisChanged(float)) ); + QObject::disconnect ( editVsWidget, SIGNAL(yAxisChanged(float)), this, SLOT(yAxisChanged(float)) ); + QObject::disconnect ( editVsWidget, SIGNAL(zAxisChanged(float)), this, SLOT(zAxisChanged(float)) ); + QObject::disconnect ( editVsWidget, SIGNAL(povConeGapChanged(int)), this, SLOT(povsConeGapChanged(int)) ); + QObject::disconnect ( editVsWidget, SIGNAL(uResChanged(int)), this, SLOT(uResChanged(int)) ); + QObject::disconnect ( editVsWidget, SIGNAL(uConeGapChanged(int)), this, SLOT(uConeGapChanged(int)) ); + QObject::disconnect ( editVsWidget, SIGNAL(fResChanged(int)), this, SLOT(fResChanged(int)) ); + QObject::disconnect ( editVsWidget, SIGNAL(bigJumpChanged(float)), this, SLOT(bigJumpChanged(float)) ); + QObject::disconnect ( editVsWidget, SIGNAL(borderFGapChanged(int)), this, SLOT(borderFGapChanged(int)) ); + QObject::disconnect ( editVsWidget, SIGNAL(smallJumpChanged(float)), this, SLOT(smallJumpChanged(float)) ); + QObject::disconnect ( editVsWidget, SIGNAL(normalsAngleChanged(int)), this, SLOT(normalsAngleChanged(int)) ); + QObject::disconnect ( editVsWidget, SIGNAL(unifyPointClouds(bool)), this, SLOT(unifyPointClouds(bool)) ); + QObject::disconnect ( editVsWidget, SIGNAL(go()), this, SLOT(go()) ); +} + +/* private slots */ +void EditVirtualScanPlugin::customPovsMode( bool on ) +{ + params.useCustomPovs = on; +} + +void EditVirtualScanPlugin::povsNumberChanged( int povsNumber ) +{ + params.povs = povsNumber; +} + +void EditVirtualScanPlugin::xAxisChanged( float newVal ) +{ + params.coneAxis[0] = newVal; +} + +void EditVirtualScanPlugin::yAxisChanged( float newVal ) +{ + params.coneAxis[1] = newVal; +} + +void EditVirtualScanPlugin::zAxisChanged( float newVal ) +{ + params.coneAxis[2] = newVal; +} + +void EditVirtualScanPlugin::povsConeGapChanged( int newGap ) +{ + params.coneGap = (float)newGap; +} + +void EditVirtualScanPlugin::uResChanged( int newRes ) +{ + params.uniformResolution = newRes; +} + +void EditVirtualScanPlugin::uConeGapChanged( int newGap ) +{ + params.frontFacingConeU = (float)newGap; +} + +void EditVirtualScanPlugin::fResChanged( int newRes ) +{ + params.featureResolution = newRes; +} + +void EditVirtualScanPlugin::bigJumpChanged( float newJump ) +{ + params.bigDepthJump = newJump; +} + +void EditVirtualScanPlugin::borderFGapChanged( int newGap ) +{ + params.frontFacingConeF = newGap; +} + +void EditVirtualScanPlugin::smallJumpChanged( float newJump ) +{ + params.smallDepthJump = newJump; +} + +void EditVirtualScanPlugin::normalsAngleChanged( int newAngle ) +{ + params.angleThreshold = newAngle; +} + +void EditVirtualScanPlugin::unifyPointClouds( bool unify ) +{ + unifyClouds = unify; +} + +void EditVirtualScanPlugin::go( void ) +{ + assert( glArea && inputMeshModel ); + CMeshO* firstCloud = 0, *secondCloud = 0; + MeshDocument* mDoc = glArea->meshDoc; + MeshModel* tmpModel = 0; + + if( unifyClouds ) + { + tmpModel = mDoc->addNewMesh( "VS Point Cloud", 0, false ); + firstCloud = &( tmpModel->cm ); + secondCloud = firstCloud; + } + else + { + tmpModel = mDoc->addNewMesh( "VS Uniform Samples", 0, false ); + firstCloud = &( tmpModel->cm ); + tmpModel = mDoc->addNewMesh( "VS Feature Samples", 0, false ); + secondCloud = &( tmpModel->cm ); + } + + MyGLWidget* tmpWidget = new MyGLWidget + ( ¶ms, inputMeshModel, firstCloud, secondCloud, glArea ); + bool ok = tmpWidget->result; + if( !ok ) + { + QString errorMessage = tmpWidget->errorString; + Log( errorMessage.toStdString().c_str() ); + } + delete tmpWidget; +} diff --git a/src/fgt/edit_virtual_scan/edit_virtual_scan_plugin.h b/src/fgt/edit_virtual_scan/edit_virtual_scan_plugin.h new file mode 100644 index 000000000..47edd38cb --- /dev/null +++ b/src/fgt/edit_virtual_scan/edit_virtual_scan_plugin.h @@ -0,0 +1,71 @@ +#ifndef EDIT_VIRTUAL_SCAN_PLUGIN_H +#define EDIT_VIRTUAL_SCAN_PLUGIN_H + +/* Qt includes */ +#include +#include + +/* meshlab includes */ +#include + +/* my includes */ +#include "edit_vs_widget.h" +#include "vs/sampler.h" + +using namespace vs; + +class EditVirtualScanPlugin: public QObject, public MeshEditInterface +{ + + Q_OBJECT + Q_INTERFACES(MeshEditInterface) + +public: + + EditVirtualScanPlugin ( void ); + virtual ~EditVirtualScanPlugin ( void ); + + static const QString Info ( void ); + + /* MeshEditInterface implementation */ + virtual bool StartEdit ( MeshModel& m, GLArea* parent ); + virtual void EndEdit ( MeshModel& m, GLArea* parent ); + virtual void Decorate ( MeshModel& m, GLArea* parent ); + virtual void mousePressEvent ( QMouseEvent* event, MeshModel& m, GLArea* parent ); + virtual void mouseMoveEvent ( QMouseEvent* event, MeshModel& m, GLArea* parent ); + virtual void mouseReleaseEvent ( QMouseEvent* event, MeshModel& m, GLArea* parent ); + +private: + + VSParameters params; + MeshModel* inputMeshModel; + bool unifyClouds; + GLArea* glArea; + + QDockWidget* dockWidget; + EditVsWidget* editVsWidget; + + void connectWidgetEvents ( void ); + void disconnectWidgetEvents ( void ); + +private slots: + + void customPovsMode ( bool on ); + void povsNumberChanged ( int povsNumber ); + void xAxisChanged ( float newVal ); + void yAxisChanged ( float newVal ); + void zAxisChanged ( float newVal ); + void povsConeGapChanged ( int newGap ); + void uResChanged ( int newRes ); + void uConeGapChanged ( int newGap ); + void fResChanged ( int newRes ); + void bigJumpChanged ( float newJump ); + void borderFGapChanged ( int newGap ); + void smallJumpChanged ( float newJump ); + void normalsAngleChanged ( int newAngle ); + void unifyPointClouds ( bool unify ); + void go ( void ); + +}; + +#endif diff --git a/src/fgt/edit_virtual_scan/edit_vs_widget.cpp b/src/fgt/edit_virtual_scan/edit_vs_widget.cpp new file mode 100644 index 000000000..56f6d2bbb --- /dev/null +++ b/src/fgt/edit_virtual_scan/edit_vs_widget.cpp @@ -0,0 +1,333 @@ +#include "edit_vs_widget.h" + +#include + +EditVsWidget::EditVsWidget( QWidget* parent, Qt::WindowFlags flags ) + : QWidget( parent, flags ) +{ + this->resize( 300, 200 ); + + createWidgets(); + prepareWidgets(); + makeEventConnections(); +} + +EditVsWidget::~EditVsWidget( void ) +{ + destroyWidgets(); +} + +/* widgets management */ +void EditVsWidget::createWidgets( void ) +{ + mainLayout = new QGridLayout( this ); + + /* povs group box */ + povsBox = new QGroupBox( tr( "Povs" ), this ); + povsBoxLayout = new QGridLayout( povsBox ); + genPovsRadioBtn = new QRadioButton( tr( "Generate povs within a cone of directions" ), povsBox ); + savedPovsRadioBtn = new QRadioButton( tr( "Use povs saved in the current mesh" ), povsBox ); + povsGroup = new QButtonGroup( 0 ); + povsNumberLabel = new QLabel( tr( "Povs number: " ), povsBox ); + povsNumberLine = new QLineEdit( povsBox ); + + /* cone axis group box */ + coneAxisBox = new QGroupBox( tr( "Cone Axis" ), povsBox ); + coneAxisBoxLayout = new QGridLayout( povsBox ); + xCompLabel = new QLabel( tr( "X component: " ), coneAxisBox ); + xCompLine = new QLineEdit( coneAxisBox ); + yCompLabel = new QLabel( tr( "Y component: " ), coneAxisBox ); + yCompLine = new QLineEdit( coneAxisBox ); + zCompLabel = new QLabel( tr( "Z component: " ), coneAxisBox ); + zCompLine = new QLineEdit( coneAxisBox ); + + coneAxisBoxLayout->addWidget( xCompLabel, 0, 0, 1, 1 ); + coneAxisBoxLayout->addWidget( xCompLine, 0, 1, 1, 1 ); + coneAxisBoxLayout->addWidget( yCompLabel, 1, 0, 1, 1 ); + coneAxisBoxLayout->addWidget( yCompLine, 1, 1, 1, 1 ); + coneAxisBoxLayout->addWidget( zCompLabel, 2, 0, 1, 1 ); + coneAxisBoxLayout->addWidget( zCompLine, 2, 1, 1, 1 ); + + coneAxisBox->setLayout( coneAxisBoxLayout ); + /* ------------------- */ + + gapLabel = new QLabel( tr( "Cone gap: " ), povsBox ); + gapSlider = new QSlider( Qt::Horizontal, povsBox ); + gapValue = new QLabel( tr( "180°" ), povsBox ); + + povsBoxLayout->addWidget( genPovsRadioBtn, 0, 0, 1, 4 ); + povsBoxLayout->addWidget( povsNumberLabel, 1, 1, 1, 1 ); + povsBoxLayout->addWidget( povsNumberLine, 1, 2, 1, 2 ); + povsBoxLayout->addWidget( coneAxisBox, 2, 1, 1, 3 ); + povsBoxLayout->addWidget( gapLabel, 3, 1, 1, 1 ); + povsBoxLayout->addWidget( gapSlider, 3, 2, 1, 1 ); + povsBoxLayout->addWidget( gapValue, 3, 3, 1, 1 ); + povsBoxLayout->addWidget( savedPovsRadioBtn, 4, 0, 1, 4 ); + + povsGroup->addButton( genPovsRadioBtn ); + povsGroup->addButton( savedPovsRadioBtn ); + + povsBox->setLayout( povsBoxLayout ); + /* ------------------- */ + + /* uniform samples group box */ + uniformBox = new QGroupBox( tr( "Uniform samples" ), this ); + uniformBoxLayout = new QGridLayout( this ); + uResLabel = new QLabel( tr( "Viewport side: " ), uniformBox ); + uResSlider = new QSlider( Qt::Horizontal, uniformBox ); + uResValue = new QLabel( tr( "64" ), uniformBox ); + uConeLabel = new QLabel( tr( "Front-facing cone gap: " ), uniformBox ); + uConeSlider = new QSlider( Qt::Horizontal, uniformBox ); + uConeValue = new QLabel( tr( "90°" ), uniformBox ); + + uniformBoxLayout->addWidget( uResLabel, 0, 0, 1, 1 ); + uniformBoxLayout->addWidget( uResSlider, 0, 1, 1, 2 ); + uniformBoxLayout->addWidget( uResValue, 0, 3, 1, 1 ); + uniformBoxLayout->addWidget( uConeLabel, 1, 0, 1, 1 ); + uniformBoxLayout->addWidget( uConeSlider, 1, 1, 1, 2 ); + uniformBoxLayout->addWidget( uConeValue, 1, 3, 1, 1 ); + + uniformBox->setLayout( uniformBoxLayout ); + /* ------------------------- */ + + /* feature samples group box */ + featureBox = new QGroupBox( tr( "Feature samples" ), this ); + featureBoxLayout = new QGridLayout( this ); + fResLabel = new QLabel( tr( "Viewport side: " ), featureBox ); + fResSlider = new QSlider( Qt::Horizontal, featureBox ); + fResValue = new QLabel( tr( "64" ), featureBox ); + borderJumpLabel = new QLabel( tr( "Border depth jump: " ), featureBox ); + borderJumpSlider = new QSlider( Qt::Horizontal, featureBox ); + borderJumpValue = new QLabel( tr( "20%" ), featureBox ); + borderFacingLabel = new QLabel( tr( "Facing-border cone gap: " ), featureBox ); + borderFacingSlider = new QSlider( Qt::Horizontal, featureBox ); + borderFacingValue = new QLabel( tr( "40°" ), featureBox ); + patchJumpLabel = new QLabel( tr( "Patch depth jump: " ), featureBox ); + patchJumpSlider = new QSlider( Qt::Horizontal, featureBox ); + patchJumpValue = new QLabel( tr( "1%" ), featureBox ); + normalsAngleLabel = new QLabel( tr( "Normals angle: " ), featureBox ); + normalsAngleSlider = new QSlider( Qt::Horizontal, featureBox ); + normalsAngleValue = new QLabel( tr( "40°" ), featureBox ); + + featureBoxLayout->addWidget( fResLabel, 0, 0, 1, 1 ); + featureBoxLayout->addWidget( fResSlider, 0, 1, 1, 2 ); + featureBoxLayout->addWidget( fResValue, 0, 3, 1, 1 ); + featureBoxLayout->addWidget( borderJumpLabel, 1, 0, 1, 1 ); + featureBoxLayout->addWidget( borderJumpSlider, 1, 1, 1, 2 ); + featureBoxLayout->addWidget( borderJumpValue, 1, 3, 1, 1 ); + featureBoxLayout->addWidget( borderFacingLabel, 2, 0, 1, 1 ); + featureBoxLayout->addWidget( borderFacingSlider, 2, 1, 1, 2 ); + featureBoxLayout->addWidget( borderFacingValue, 2, 3, 1, 1 ); + featureBoxLayout->addWidget( patchJumpLabel, 3, 0, 1, 1 ); + featureBoxLayout->addWidget( patchJumpSlider, 3, 1, 1, 2 ); + featureBoxLayout->addWidget( patchJumpValue, 3, 3, 1, 1 ); + featureBoxLayout->addWidget( normalsAngleLabel, 4, 0, 1, 1 ); + featureBoxLayout->addWidget( normalsAngleSlider, 4, 1, 1, 2 ); + featureBoxLayout->addWidget( normalsAngleValue, 4, 3, 1, 1 ); + + featureBox->setLayout( featureBoxLayout ); + /* ------------------------- */ + + unifyCheck = new QCheckBox( tr( "Unify feature and uniform samples" ), this ); + goBtn = new QPushButton( tr( "Generate samples" ), this ); + + mainLayout->addWidget( povsBox, 0, 0, 6, 1 ); + mainLayout->addWidget( uniformBox, 6, 0, 3, 1 ); + mainLayout->addWidget( featureBox, 9, 0, 5, 1 ); + mainLayout->addWidget( unifyCheck, 14, 0, 1, 1 ); + mainLayout->addWidget( goBtn, 15, 0, 1, 1 ); + + this->setLayout( mainLayout ); +} + +void EditVsWidget::prepareWidgets( void ) +{ + povsValidator = new QIntValidator( 1, 9999, this ); + povsNumberLine->setMaxLength( 4 ); + povsNumberLine->setValidator( povsValidator ); + povsNumberLine->setAlignment( Qt::AlignRight ); + + axisValidator = new QDoubleValidator( this ); + QLineEdit* axis[3] = { xCompLine, yCompLine, zCompLine }; + for( int i=0; i<3; i++ ) + { + axis[i]->setAlignment( Qt::AlignRight ); + axis[i]->setValidator( axisValidator ); + } + + gapSlider->setMinimum( 0 ); + gapSlider->setMaximum( 360 ); + + uResSlider->setMinimum( 0 ); + uResSlider->setMaximum( 13 ); + + uConeSlider->setMinimum( 0 ); + uConeSlider->setMaximum( 200 ); + + fResSlider->setMinimum( 0 ); + fResSlider->setMaximum( 13 ); + + borderJumpSlider->setMinimum( 0 ); + borderJumpSlider->setMaximum( 100 ); + + borderFacingSlider->setMinimum( 0 ); + borderFacingSlider->setMaximum( 200 ); + + patchJumpSlider->setMinimum( 0 ); + patchJumpSlider->setMaximum( 100 ); + + normalsAngleSlider->setMinimum( 0 ); + normalsAngleSlider->setMaximum( 200 ); +} + +void EditVsWidget::makeEventConnections( void ) +{ + QObject::connect( savedPovsRadioBtn, SIGNAL(toggled(bool)), this, SLOT(useSavedPovsRadioToggled(bool)) ); + QObject::connect( povsNumberLine, SIGNAL(textChanged(QString)), this, SLOT(povsNumberTextChanged(QString)) ); + QObject::connect( xCompLine, SIGNAL(textChanged(QString)), this, SLOT(xCompTextChanged(QString)) ); + QObject::connect( yCompLine, SIGNAL(textChanged(QString)), this, SLOT(yCompTextChanged(QString)) ); + QObject::connect( zCompLine, SIGNAL(textChanged(QString)), this, SLOT(zCompTextChanged(QString)) ); + QObject::connect( gapSlider, SIGNAL(valueChanged(int)), this, SLOT(gapSliderChanged(int)) ); + QObject::connect( uResSlider, SIGNAL(valueChanged(int)), this, SLOT(uResSliderChanged(int)) ); + QObject::connect( uConeSlider, SIGNAL(valueChanged(int)), this, SLOT(uGapSliderChanged(int)) ); + QObject::connect( fResSlider, SIGNAL(valueChanged(int)), this, SLOT(fResSliderChanged(int)) ); + QObject::connect( borderJumpSlider, SIGNAL(valueChanged(int)), this, SLOT(borderJumpSliderChanged(int)) ); + QObject::connect( borderFacingSlider, SIGNAL(valueChanged(int)), this, SLOT(borderFacingSliderChanged(int)) ); + QObject::connect( patchJumpSlider, SIGNAL(valueChanged(int)), this, SLOT(patchJumpSliderChanged(int)) ); + QObject::connect( normalsAngleSlider, SIGNAL(valueChanged(int)), this, SLOT(normalsSliderChanged(int)) ); + QObject::connect( unifyCheck, SIGNAL(toggled(bool)), this, SLOT(unifyCheckToggled(bool)) ); + QObject::connect( goBtn, SIGNAL(clicked()), this, SLOT(goBtnClicked()) ); +} + +void EditVsWidget::initializeWidgets( bool useCustomPovs, int povsNumber, + float xAxis, float yAxis, float zAxis, int gap, + int uRes, int uGap, + int fRes, int bigJump, int borderConeGap, int smallJump, int normalsAngle, + bool unifyClouds ) +{ + savedPovsRadioBtn->setChecked( true ); // little workaround + savedPovsRadioBtn->setChecked( useCustomPovs ); + genPovsRadioBtn->setChecked( !useCustomPovs ); + povsNumberLine->setText( QString::number( povsNumber ) ); + xCompLine->setText( QString::number( xAxis ) ); + yCompLine->setText( QString::number( yAxis ) ); + zCompLine->setText( QString::number( zAxis ) ); + gapSlider->setValue( gap ); + uResSlider->setValue( uRes ); + uConeSlider->setValue( uGap ); + fResSlider->setValue( fRes ); + borderJumpSlider->setValue( bigJump ); + borderFacingSlider->setValue( borderConeGap ); + patchJumpSlider->setValue( smallJump ); + normalsAngleSlider->setValue( normalsAngle ); + unifyCheck->setChecked( unifyClouds ); +} + +void EditVsWidget::destroyWidgets( void ) +{ + delete genPovsRadioBtn; + delete savedPovsRadioBtn; + delete povsGroup; + delete povsBoxLayout; + delete povsBox; + delete mainLayout; +} + +/* private slots */ +void EditVsWidget::useSavedPovsRadioToggled( bool toggled ) +{ + coneAxisBox->setEnabled( !toggled ); + povsNumberLabel->setEnabled( !toggled ); + povsNumberLine->setEnabled( !toggled ); + gapLabel->setEnabled( !toggled ); + gapSlider->setEnabled( !toggled ); + gapValue->setEnabled( !toggled ); + emit customPovsMode( toggled ); +} + +void EditVsWidget::povsNumberTextChanged( QString newText ) +{ + int val = newText.toInt(); + emit ( povsNumberChanged( val ) ); +} + +void EditVsWidget::xCompTextChanged( QString newText ) +{ + float comp = newText.toFloat(); + emit ( xAxisChanged( comp ) ); +} + +void EditVsWidget::yCompTextChanged( QString newText ) +{ + float comp = newText.toFloat(); + emit ( yAxisChanged( comp ) ); +} + +void EditVsWidget::zCompTextChanged( QString newText ) +{ + float comp = newText.toFloat(); + emit ( zAxisChanged( comp ) ); +} + +void EditVsWidget::gapSliderChanged( int val ) +{ + gapValue->setText( QString::number( val ) + tr( "°" ) ); + emit ( povConeGapChanged( val ) ); +} + +void EditVsWidget::uResSliderChanged( int val ) +{ + int resolution = (int)( pow( 2.0, (double)val ) ); + uResValue->setText( QString::number( resolution ) ); + emit ( uResChanged( resolution ) ); +} + +void EditVsWidget::uGapSliderChanged( int val ) +{ + uConeValue->setText( QString::number( val ) + tr( "°" ) ); + emit ( uConeGapChanged( val ) ); +} + +void EditVsWidget::fResSliderChanged( int val ) +{ + int resolution = (int)( pow( 2.0, (double)val ) ); + fResValue->setText( QString::number( resolution ) ); + emit ( fResChanged( resolution ) ); +} + +void EditVsWidget::borderJumpSliderChanged( int val ) +{ + borderJumpValue->setText( QString::number( val ) + tr( "%" ) ); + float jump = val / 100.0f; + emit ( bigJumpChanged( jump ) ); +} + +void EditVsWidget::borderFacingSliderChanged( int val ) +{ + borderFacingValue->setText( QString::number( val ) + tr( "°" ) ); + emit ( borderFGapChanged( val ) ); +} + +void EditVsWidget::patchJumpSliderChanged( int val ) +{ + float jump = ( val / 100.0f ) * 5.0f; + patchJumpValue->setText( QString::number( jump ) + tr( "%" ) ); + float toEmit = jump / 100.0f; + emit ( smallJumpChanged( toEmit ) ); +} + +void EditVsWidget::normalsSliderChanged( int val ) +{ + normalsAngleValue->setText( QString::number( val ) + tr( "°" ) ); + emit ( normalsAngleChanged( val ) ); +} + +void EditVsWidget::unifyCheckToggled( bool toggled ) +{ + emit ( unifyPointClouds( toggled ) ); +} + +void EditVsWidget::goBtnClicked( void ) +{ + emit ( go() ); +} diff --git a/src/fgt/edit_virtual_scan/edit_vs_widget.h b/src/fgt/edit_virtual_scan/edit_vs_widget.h new file mode 100644 index 000000000..9b40d144c --- /dev/null +++ b/src/fgt/edit_virtual_scan/edit_vs_widget.h @@ -0,0 +1,137 @@ +#ifndef EDIT_VS_WIDGET_H +#define EDIT_VS_WIDGET_H + +/* Qt includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class EditVsWidget: public QWidget +{ + Q_OBJECT + +public: + + EditVsWidget ( QWidget* parent = 0, Qt::WindowFlags flags = 0 ); + virtual ~EditVsWidget ( void ); + + void initializeWidgets ( bool useCustomPovs, int povsNumber, + float xAxis, float yAxis, float zAxis, int gap, + int uRes, int uGap, + int fRes, int bigJump, int borderConeGap, int smallJump, int normalsAngle, + bool unifyClouds ); + +signals: + + void customPovsMode ( bool on ); + void povsNumberChanged ( int povsNumber ); + void xAxisChanged ( float newComp ); + void yAxisChanged ( float newComp ); + void zAxisChanged ( float newComp ); + void povConeGapChanged ( int newGap ); + void uResChanged ( int newSide ); + void uConeGapChanged ( int newGap ); + void fResChanged ( int newSide ); + void bigJumpChanged ( float newJump ); + void borderFGapChanged ( int newGap ); + void smallJumpChanged ( float newJump ); + void normalsAngleChanged ( int newAngle ); + void unifyPointClouds ( bool unify ); + void go ( void ); + +private: + + /* QWidgets-related stuff */ + QGridLayout* mainLayout; + + QGroupBox* povsBox; + QGridLayout* povsBoxLayout; + QButtonGroup* povsGroup; + QRadioButton* genPovsRadioBtn; + QRadioButton* savedPovsRadioBtn; + QLabel* povsNumberLabel; + QLineEdit* povsNumberLine; + + QGroupBox* coneAxisBox; + QGridLayout* coneAxisBoxLayout; + QLabel* xCompLabel; + QLineEdit* xCompLine; + QLabel* yCompLabel; + QLineEdit* yCompLine; + QLabel* zCompLabel; + QLineEdit* zCompLine; + + QLabel* gapLabel; + QSlider* gapSlider; + QLabel* gapValue; + + QGroupBox* uniformBox; + QGridLayout* uniformBoxLayout; + QLabel* uResLabel; + QSlider* uResSlider; + QLabel* uResValue; + QLabel* uConeLabel; + QSlider* uConeSlider; + QLabel* uConeValue; + + QGroupBox* featureBox; + QGridLayout* featureBoxLayout; + QLabel* fResLabel; + QSlider* fResSlider; + QLabel* fResValue; + QLabel* borderJumpLabel; + QSlider* borderJumpSlider; + QLabel* borderJumpValue; + QLabel* borderFacingLabel; + QSlider* borderFacingSlider; + QLabel* borderFacingValue; + QLabel* patchJumpLabel; + QSlider* patchJumpSlider; + QLabel* patchJumpValue; + QLabel* normalsAngleLabel; + QSlider* normalsAngleSlider; + QLabel* normalsAngleValue; + + QCheckBox* unifyCheck; + QPushButton* goBtn; + + /* other Qt fields */ + QIntValidator* povsValidator; + QDoubleValidator* axisValidator; + + /* private functions */ + void createWidgets ( void ); + void destroyWidgets ( void ); + void prepareWidgets ( void ); + void makeEventConnections ( void ); + +private slots: + + void useSavedPovsRadioToggled ( bool toggled ); + void povsNumberTextChanged ( QString newText ); + void xCompTextChanged ( QString newText ); + void yCompTextChanged ( QString newText ); + void zCompTextChanged ( QString newText ); + void gapSliderChanged ( int val ); + void uResSliderChanged ( int val ); + void uGapSliderChanged ( int val ); + void fResSliderChanged ( int val ); + void borderJumpSliderChanged ( int val ); + void borderFacingSliderChanged ( int val ); + void patchJumpSliderChanged ( int val ); + void normalsSliderChanged ( int val ); + void unifyCheckToggled ( bool toggled ); + void goBtnClicked ( void ); + +}; + +#endif diff --git a/src/fgt/edit_virtual_scan/images/icon.png b/src/fgt/edit_virtual_scan/images/icon.png new file mode 100644 index 000000000..e95fe15b2 Binary files /dev/null and b/src/fgt/edit_virtual_scan/images/icon.png differ diff --git a/src/fgt/filter_virtual_range_scan/my_gl_widget.h b/src/fgt/edit_virtual_scan/my_gl_widget.h similarity index 91% rename from src/fgt/filter_virtual_range_scan/my_gl_widget.h rename to src/fgt/edit_virtual_scan/my_gl_widget.h index 55591848d..4c1a34c88 100644 --- a/src/fgt/filter_virtual_range_scan/my_gl_widget.h +++ b/src/fgt/edit_virtual_scan/my_gl_widget.h @@ -1,9 +1,9 @@ #ifndef MY_GL_WIDGET_H #define MY_GL_WIDGET_H -#include "filter_virtual_range_scan.h" +#include "vs/sampler.h" -#include +#include using namespace vs; @@ -14,8 +14,9 @@ public: MyGLWidget( VSParameters* params, MeshModel* inputMeshModel, CMeshO* uniformSamplesMesh, - CMeshO* featureSamplesMesh ) - : QGLWidget( (QWidget*)0 ) + CMeshO* featureSamplesMesh, + QGLWidget* shareWidget ) + : QGLWidget( (QWidget*)0, shareWidget ) { this->params = params; this->inputMeshModel = inputMeshModel; diff --git a/src/fgt/filter_virtual_range_scan/vs/povs_generator.h b/src/fgt/edit_virtual_scan/vs/povs_generator.h similarity index 100% rename from src/fgt/filter_virtual_range_scan/vs/povs_generator.h rename to src/fgt/edit_virtual_scan/vs/povs_generator.h diff --git a/src/fgt/filter_virtual_range_scan/vs/resources.h b/src/fgt/edit_virtual_scan/vs/resources.h similarity index 96% rename from src/fgt/filter_virtual_range_scan/vs/resources.h rename to src/fgt/edit_virtual_scan/vs/resources.h index 917784cfc..b4fa91c27 100644 --- a/src/fgt/filter_virtual_range_scan/vs/resources.h +++ b/src/fgt/edit_virtual_scan/vs/resources.h @@ -42,9 +42,6 @@ namespace vs vector< Pov > customPovs; // custom point-of-views bool useCustomPovs; - - // only for my sandbox - vector< vcg::Point3f > computedPovs; }; /* diff --git a/src/fgt/filter_virtual_range_scan/vs/sampler.h b/src/fgt/edit_virtual_scan/vs/sampler.h similarity index 90% rename from src/fgt/filter_virtual_range_scan/vs/sampler.h rename to src/fgt/edit_virtual_scan/vs/sampler.h index 5af5b2534..966b148a6 100644 --- a/src/fgt/filter_virtual_range_scan/vs/sampler.h +++ b/src/fgt/edit_virtual_scan/vs/sampler.h @@ -38,13 +38,6 @@ namespace vs MeshType* featureSamplesMesh, SamplerListener* listener = 0 ) { - /* - QTime alltime; - alltime.start(); - QTime detectionTime; - detectionTime.start(); - */ - if( listener ){ listener->startingSetup(); } // OpenGL initialization @@ -85,10 +78,6 @@ namespace vs FeatureDetector detector ( &resources ); GLint* samplesCount = &( resources.buffers[ "best_position" ]->elements ); - /* - int all_init_time = alltime.restart(); - qDebug( "init_time: %d msec", all_init_time ); - */ if( listener ){ listener->setupComplete( resources.params->povs ); } // *** sampling *** @@ -136,10 +125,6 @@ namespace vs // download samples downloadSamples( &resources, (i==0)? uniformSamplesMesh : featureSamplesMesh ); - /* - all_init_time = alltime.restart(); - qDebug( (i==0)? "uniforms time: %d msec" : "features time: %d msec", all_init_time ); - */ } // **************** diff --git a/src/fgt/filter_virtual_range_scan/vs/simple_renderer.h b/src/fgt/edit_virtual_scan/vs/simple_renderer.h similarity index 100% rename from src/fgt/filter_virtual_range_scan/vs/simple_renderer.h rename to src/fgt/edit_virtual_scan/vs/simple_renderer.h diff --git a/src/fgt/filter_virtual_range_scan/vs/stages.h b/src/fgt/edit_virtual_scan/vs/stages.h similarity index 96% rename from src/fgt/filter_virtual_range_scan/vs/stages.h rename to src/fgt/edit_virtual_scan/vs/stages.h index 67d38cbc5..afa6e43ac 100644 --- a/src/fgt/filter_virtual_range_scan/vs/stages.h +++ b/src/fgt/edit_virtual_scan/vs/stages.h @@ -199,9 +199,6 @@ namespace vs orthoRadius = ( inputMesh->bbox.Diag() / 2 ) * 1.2; PovsGenerator< ScalarType >::generatePovs( res->params->povs, orthoRadius, meshCenter, coneAxis, coneGap, povs ); generateUpVectors( povs, meshCenter, upVectors ); - - // only for my sandbox - resources->params->computedPovs = this->povs; } } diff --git a/src/fgt/filter_virtual_range_scan/vs/utils.h b/src/fgt/edit_virtual_scan/vs/utils.h similarity index 100% rename from src/fgt/filter_virtual_range_scan/vs/utils.h rename to src/fgt/edit_virtual_scan/vs/utils.h diff --git a/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.cpp b/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.cpp deleted file mode 100644 index 3760d4a8d..000000000 --- a/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************** -* MeshLab o o * -* An extendible mesh processor o o * -* _ O _ * -* Copyright(C) 2005, 2006 \/)\/ * -* Visual Computing Lab /\/| * -* ISTI - Italian National Research Council | * -* \ * -* All rights reserved. * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * -* for more details. * -* * -****************************************************************************/ - -#include -#include - -#include "filter_virtual_range_scan.h" -#include "my_gl_widget.h" - -#include -#include -#include -#include -#include - -using namespace std; -using namespace vcg; -using namespace vs; - -// ------- MeshFilterInterface implementation ------------------------ -FilterVirtualRangeScan::FilterVirtualRangeScan() -{ - typeList << FP_VRS; - FilterIDType tt; - foreach(tt , types()) - actionList << new QAction(filterName(tt), this); -} - -FilterVirtualRangeScan::~FilterVirtualRangeScan( void ) -{ - delete innerContext; -} - -QString FilterVirtualRangeScan::filterName(FilterIDType filterId) const -{ - switch (filterId) { - case FP_VRS: - return QString("Virtual Range Scan"); - break; - } - - return ""; -} - -QString FilterVirtualRangeScan::filterInfo(FilterIDType filterId) const -{ - QString description = "Performs a virtual range scan onto the current mesh"; - return description; -} - -void FilterVirtualRangeScan::initParameterSet(QAction* filter,MeshDocument &md, RichParameterSet &par) -{ - switch(ID(filter)) - { - case FP_VRS: - par.addParam( new RichInt( "povs", 20, "Povs:", "The number of point of views from which the target mesh is observed.") ); - par.addParam( new RichPoint3f( "coneAxis", vcg::Point3f( 0.0f, 1.0f, 0.0f ), "Looking cone axis", - QString( "Povs are generated within a cone of directions, centered at the mesh bounding box center. This parameter specifies the cone axis." ) ) ); - par.addParam( new RichDynamicFloat( "coneGap", 360.0f, 0.0f, 360.0f, "Cone gap:", "The looking cone gap (in degrees).") ); - - QStringList drawModes; - drawModes << "Flat" << "Smooth"; - par.addParam( new RichEnum( "drawMode", 0, drawModes, "Draw mode: ", - QString( "This parameter specifies the draw mode to be used by the vcg renderer to generate the color-map for each point of view." ) ) ); - - QStringList colorModes; - colorModes << "Per-vertex" << "Per-face" << "Per-mesh"; - par.addParam( new RichEnum( "colorMode", 0, colorModes, "Color mode: ", - QString( "This parameter specifies the color mode to be used by the vcg renderer to generate the color-map for each point of view." ) ) ); - - QStringList textureModes; - textureModes << "None" << "Per-vertex" << "Per-wedge" << "Per-wedge multi"; - par.addParam( new RichEnum( "textureMode", 0, textureModes, "Texture mode: ", - QString( "This parameter specifies the texture mode to be used by the vcg renderer to generate the color-map for each point of view." ) ) ); - - par.addParam( new RichBool( "useCustomPovs", false, "Use povs contained in the following layer, ignoring the above parameters", "" ) ); - par.addParam( new RichMesh( "povsLayer", md.mm(), &md, "Povs layer:", "" ) ); - - par.addParam( new RichInt( "uniform_side", 64, "Uniform sampling resolution:", - "The mesh will be sampled uniformly from a texture of v x v pixels, where v is the chosen value.") ); - par.addParam( new RichInt( "features_side", 512, "Feature sampling resolution:", - "The filter performs feature detection from a texture of v x v pixels, where v is the chosen value.") ); - par.addParam( new RichDynamicFloat( "frontFacingConeU", 180.0f, 0.0f, 180.0f, - "Front facing cone (uniform):", - QString("Pixels whose normal is directed towards the viewer are considered front-facing.
") + - "To be front-facing, these normals must reside within a given cone of directions, whose angle is set with this parameter.
" + - "Only the front-facing pixels form the uniform samples cloud" ) ); - par.addParam( new RichDynamicFloat( "bigJump", 0.1f, 0.0f, 1.0f, "Big depth jump threshold:", - QString("The filter detects mesh borders and big offsets within the mesh by testing the depth of neighbours pixels.
") + - "This parameter controls the (normalized) minimum depth offset for a depth jump to be recognized.") ); - par.addParam( new RichDynamicFloat( "frontFacingConeF", 40.0f, 0.0f, 180.0f, - "Front facing cone (features):", - QString("Look at the Front facing cone (uniform) parameter description to understand when a pixel is") + - "said front-facing. In the feature sensitive sampling step, border pixels are recognized as features if " + - "they are facing the observer within a given cone of direction, whose gap is specified (in degrees) with this parameter." ) ); - par.addParam( new RichDynamicFloat( "smallJump", 0.01f, 0.001f, 0.1f, "Small depth jump threshold:", - QString("To be considered on the same mesh patch, neighbours pixels must be within this depth range.
") + - "For example, if the max depth value is 0.6 and the min depth value is 0.4, then a value of 0.01 "+ - "means that the depth offset between neighbours pixels must be "+ - "less or equal 1/100th of (0.6 - 0.4) = 0.2.") ); - par.addParam( new RichDynamicFloat( "normalsAngle", 60, 0, 180, "Normals angle threshold:", - "The minimum angle between neighbour pixels normals for the center pixel to be considered feature.") ); - - par.addParam( new RichBool( "oneMesh", true, "Unify uniform and feature samples", - QString("If checked, generates a unique mesh that contains both uniform and feature samples.
") + - "If not checked, generates two output meshes: the first contains uniform samples and the second contains feature samples.") ); - break; - } -} - -bool FilterVirtualRangeScan::applyFilter( QAction* filter, - MeshDocument &md, - RichParameterSet &par, - vcg::CallBackPos* cb ) -{ - switch(ID(filter)) - { - case FP_VRS: - - MeshModel* curMeshModel = md.mm(); - CMeshO* startMesh = &( curMeshModel->cm ); - - if( !(startMesh->HasPerVertexNormal()) ) - { - errorMessage = "Cannot apply the virtual scanning filter: the current mesh doesn't have per-vertex normals."; - return false; - } - - bool useLayerPovs = par.getBool( "useCustomPovs" ); - if( useLayerPovs ) - { - MeshModel* tmpMesh = par.getMesh( "povsLayer" ); - assert( tmpMesh ); - CMeshO::PerMeshAttributeHandle< std::vector > povs_handle; - povs_handle = vcg::tri::Allocator::GetPerMeshAttribute > (tmpMesh->cm,"pointofviews"); - if (!vcg::tri::Allocator::IsValidHandle(tmpMesh->cm,povs_handle) ) - { - errorMessage = "Can't apply the filter because the selected layer contains no point of views."; - return false; - } - - vrsParams.customPovs = povs_handle(); // copies the povs data - } - else - { - vrsParams.povs = par.getInt( "povs" ); - vcg::Point3f coneAxis = par.getPoint3f( "coneAxis" ); - vrsParams.coneAxis[ 0 ] = coneAxis.X(); - vrsParams.coneAxis[ 1 ] = coneAxis.Y(); - vrsParams.coneAxis[ 2 ] = coneAxis.Z(); - vrsParams.coneGap = par.getDynamicFloat( "coneGap" ); - } - - vrsParams.uniformResolution = par.getInt( "uniform_side" ); - vrsParams.featureResolution = par.getInt( "features_side" ); - vrsParams.frontFacingConeU = par.getDynamicFloat( "frontFacingConeU" ); - vrsParams.frontFacingConeF = par.getDynamicFloat( "frontFacingConeF" ); - vrsParams.bigDepthJump = par.getDynamicFloat( "bigJump" ); - vrsParams.smallDepthJump = par.getDynamicFloat( "smallJump" ); - vrsParams.angleThreshold = par.getDynamicFloat( "normalsAngle" ); - - int choice = par.getEnum( "drawMode" ); - vrsParams.cmDrawMode = choice? vcg::GLW::DMSmooth : vcg::GLW::DMFlat; - - choice = par.getEnum( "colorMode" ); - vcg::GLW::ColorMode cMode; - - switch( choice ) - { - case 0: - cMode = vcg::GLW::CMPerVert; - break; - case 1: - cMode = vcg::GLW::CMPerFace; - break; - case 2: - cMode = vcg::GLW::CMPerMesh; - break; - default: - cMode = vcg::GLW::CMPerMesh; - break; - } - vrsParams.cmColorMode = cMode; - - choice = par.getEnum( "textureMode" ); - vcg::GLW::TextureMode tMode; - - switch( choice ) - { - case 0: - tMode = vcg::GLW::TMNone; - break; - case 1: - tMode = vcg::GLW::TMPerVert; - break; - case 2: - tMode = vcg::GLW::TMPerWedge; - break; - case 3: - tMode = vcg::GLW::TMPerWedgeMulti; - break; - default: - tMode = vcg::GLW::TMNone; - break; - } - vrsParams.cmTextureMode = tMode; - - vrsParams.useCustomPovs = useLayerPovs; - - bool oneMesh = par.getBool( "oneMesh" ); - MeshModel* firstMeshModel = 0, *secondMeshModel = 0; - CMeshO* firstMesh = 0, *secondMesh = 0; - - if( oneMesh ) - { - firstMeshModel = md.addNewMesh( "VRS Point Cloud" ); - firstMeshModel->updateDataMask( curMeshModel ); - firstMesh = &( firstMeshModel->cm ); - secondMesh = firstMesh; - } - else - { - firstMeshModel = md.addNewMesh( "VRS Uniform Samples" ); - firstMeshModel->updateDataMask( curMeshModel ); - firstMesh = &( firstMeshModel->cm ); - secondMeshModel = md.addNewMesh( "VRS Feature Samples" ); - secondMeshModel->updateDataMask( curMeshModel ); - secondMesh = &( secondMeshModel->cm ); - } - - MyGLWidget* tmpWidget = new MyGLWidget( &vrsParams, curMeshModel, firstMesh, secondMesh ); - bool ok = tmpWidget->result; - if( !ok ) - { - errorMessage = tmpWidget->errorString; - } - delete tmpWidget; - - return ok; - break; - } - return false; -} - -MeshFilterInterface::FilterClass FilterVirtualRangeScan::getClass(QAction* filter) -{ - switch(ID(filter)) { - case FP_VRS: - return MeshFilterInterface::Sampling; - break; - default: assert(0); - return MeshFilterInterface::Generic; - } -} - -int FilterVirtualRangeScan::getRequirements(QAction *filter) -{ - switch( ID(filter) ) - { - case FP_VRS: - return MeshModel::MM_NONE; - break; - } - - return MeshModel::MM_NONE; -} - -int FilterVirtualRangeScan::postCondition(QAction *filter) const -{ - switch(ID(filter)) - { - case FP_VRS: - return MeshModel::MM_NONE; - break; - } - - return MeshModel::MM_NONE; -} -// ---------------------------------------------------------------------- -Q_EXPORT_PLUGIN(FilterVirtualRangeScan) - diff --git a/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.h b/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.h deleted file mode 100644 index 81644f315..000000000 --- a/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.h +++ /dev/null @@ -1,68 +0,0 @@ - /**************************************************************************** -* MeshLab o o * -* A versatile mesh processing toolbox o o * -* _ O _ * -* Copyright(C) 2007 \/)\/ * -* Visual Computing Lab /\/| * -* ISTI - Italian National Research Council | * -* \ * -* All rights reserved. * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * -* for more details. * -* * -****************************************************************************/ - -#ifndef FILTERVIRTUALRANGESCANPLUGIN_H -#define FILTERVIRTUALRANGESCANPLUGIN_H - -#include -#include -#include - -#include -#include -#include - -#include "vs/sampler.h" - -using namespace vs; - -class FilterVirtualRangeScan : public QObject, public MeshFilterInterface -{ - Q_OBJECT - Q_INTERFACES(MeshFilterInterface) - -public: - FilterVirtualRangeScan(); - ~FilterVirtualRangeScan(); - - virtual QString filterName(FilterIDType filter) const; - virtual QString filterInfo(FilterIDType filter) const; - - virtual int getRequirements(QAction *); - virtual void initParameterSet(QAction*, MeshModel&, RichParameterSet &){ ;} - virtual void initParameterSet(QAction *, MeshDocument &, RichParameterSet &); - - virtual bool applyFilter (QAction* filter, MeshDocument &md, RichParameterSet & par, vcg::CallBackPos *cb); - - virtual int postCondition(QAction *action) const; - virtual FilterClass getClass(QAction *); - -private: - VSParameters vrsParams; - - enum {FP_VRS}; - - QGLContext* innerContext; -}; - -#endif diff --git a/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.pro b/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.pro deleted file mode 100644 index b96185b37..000000000 --- a/src/fgt/filter_virtual_range_scan/filter_virtual_range_scan.pro +++ /dev/null @@ -1,15 +0,0 @@ -include (../../shared.pri) -VCG_PATH = $$VCGDIR -TEMPLATE = lib -TARGET = filter_virtual_range_scan -QT += opengl -CONFIG += plugin -HEADERS += filter_virtual_range_scan.h \ - vs/resources.h \ - vs/sampler.h \ - vs/stages.h \ - vs/utils.h \ - vs/povs_generator.h \ - my_gl_widget.h \ - vs/simple_renderer.h -SOURCES += filter_virtual_range_scan.cpp