Commit 7ff103c5 authored by Jan Möbius's avatar Jan Möbius

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4909 383ad7c9-94d9-4d36-a494-682f7c89f535
parents
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Config
#==============================================================================
SUBDIRS = $(call find-subdirs)
PACKAGES := qt4 glut glew opengl x11 math ACG2 openmesh2 openflipper
PROJ_LIBS =
MODULES := uic4compat moc4 cxx
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Rules
#==============================================================================
################################################################################
#
################################################################################
include( $$TOPDIR/qmake/all.include )
Plugin()
DIRECTORIES = .
# Input
HEADERS += $$getFilesFromDir($$DIRECTORIES,*.hh)
SOURCES += $$getFilesFromDir($$DIRECTORIES,*.cc)
FORMS += $$getFilesFromDir($$DIRECTORIES,*.ui)
################################################################################
#include "SmootherObject.hh"
SmootherObject::SmootherObject(TriMesh* _mesh){
smoother = new OpenMesh::Smoother::JacobiLaplaceSmootherT< TriMesh >( *_mesh );
}
SmootherObject::~SmootherObject(){
delete smoother;
}
#include <OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.hh>
#include <OpenFlipper/common/perObjectData.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
class SmootherObject : public PerObjectData
{
public:
SmootherObject(TriMesh* _mesh);
~SmootherObject();
OpenMesh::Smoother::JacobiLaplaceSmootherT< TriMesh >* smoother;
};
//=============================================================================
//
// CLASS SmootherPlugin - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include <QtGui>
#include "SmootherPlugin.hh"
#include <iostream>
#include <ACG/GL/GLState.hh>
#include <QStringList>
#include <ACG/Scenegraph/ManipulatorNode.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include "SmootherObject.hh"
#define SMOOTHER "SmootherData"
//== IMPLEMENTATION ==========================================================
bool
SmootherPlugin::
initializeToolbox(QWidget*& _widget)
{
tool_ = new SmootherToolbarWidget();
_widget = tool_;
QSize size(100, 100);
tool_->resize(size);
// connect signals->slots
connect(tool_->pB_smooth,SIGNAL(clicked() ),this,SLOT(slot_smooth()));
return true;
}
//-----------------------------------------------------------------------------
void
SmootherPlugin::
slot_smooth()
{
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DATA_TRIANGLE_MESH) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) {
TriMeshObject* object = PluginFunctions::triMeshObject(*o_it);
if ( object == 0 ) {
emit log(LOGWARN , "Unable to get object ( Only Triangle Meshes supported)");
continue;
}
SmootherObject* data = dynamic_cast< SmootherObject* > ( o_it->objectData(SMOOTHER) );
if (data == 0){
TriMesh* mesh = PluginFunctions::triMesh(*o_it);
data = new SmootherObject(mesh);
o_it->setObjectData(SMOOTHER, data);
}
OpenMesh::Smoother::SmootherT< TriMesh >::Component component = OpenMesh::Smoother::SmootherT< TriMesh >::Tangential_and_Normal;
if( tool_->rbTangential_and_Normal->isChecked() )
component = OpenMesh::Smoother::SmootherT< TriMesh >::Tangential_and_Normal;
else if( tool_->rbNormal->isChecked() )
component = OpenMesh::Smoother::SmootherT< TriMesh >::Normal;
else if( tool_->rbTangential->isChecked() )
component = OpenMesh::Smoother::SmootherT< TriMesh >::Tangential;
OpenMesh::Smoother::SmootherT< TriMesh >::Continuity continuity = OpenMesh::Smoother::SmootherT< TriMesh >::C0;
if( tool_->rB_c0->isChecked() )
continuity = OpenMesh::Smoother::SmootherT< TriMesh >::C0;
else if( tool_->rB_c1->isChecked() )
continuity = OpenMesh::Smoother::SmootherT< TriMesh >::C1;
// Read maximum distance Error from lineEdit
if ( tool_->cbDistance->isChecked() ) {
QString value;
value = tool_->distance->text();
bool ok = false;
double absoluteError = value.toDouble(&ok);
if ( ok )
data->smoother->set_absolute_local_error( absoluteError );
else
emit log(LOGWARN , "Unable to read distance error from LineEdit");
}
data->smoother->initialize(component,continuity);
data->smoother->smooth( tool_->sB_iter->value() );
TriMesh* mesh = PluginFunctions::triMesh(*o_it);
if (mesh != 0)
mesh->garbage_collection();
emit updatedObject( o_it->id() );
}
}
//-----------------------------------------------------------------------------
Q_EXPORT_PLUGIN2( SmootherPlugin , SmootherPlugin );
//=============================================================================
//
// SmootherPlugin
//
//=============================================================================
#ifndef SMOOTHERPLUGIN_HH
#define SMOOTHERPLUGIN_HH
//== INCLUDES =================================================================
#include <QObject>
#include <QMenuBar>
#include <QTimer>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.hh>
#include "SmootherToolbarWidget.hh"
//== CLASS DEFINITION =========================================================
/** Plugin for Smoother Support
*/
class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, BackupInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(BackupInterface)
Q_INTERFACES(LoggingInterface)
signals:
/// Force Examiner widget to update their views
void updateView();
void log(Logtype _type, QString _message);
void log(QString _message);
/// Emit this Signal, if object list has changed (e.g. Source or Target changed)
void updatedObject(int);
void activeObjectChanged();
public :
// default constructor
SmootherPlugin() : tool_(0) {};
// default destructor
~SmootherPlugin() {};
/** Initialize the toolbar (create a widget in the right side toolbox) */
bool initializeToolbox(QWidget*& _widget);
/// Name of the Plugin
QString name(){ return (QString("Smoother")); };
/// Description of the Plugin
QString description() { return (QString("Mesh Smoothing ...")); };
/// User selected plugins Toolbox
void toolboxActivated( bool /*_activated*/ ) {};
private :
/// Widget for Toolbox
SmootherToolbarWidget* tool_;
private slots:
void slot_smooth();
public slots:
QString version() { return QString("1.0"); };
};
#endif //SMOOTHERPLUGIN_HH
#include "SmootherToolbarWidget.hh"
#include <QtGui>
SmootherToolbarWidget::SmootherToolbarWidget(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
}
#include "ui_smootherToolbar.hh"
#include <QtGui>
class SmootherToolbarWidget : public QWidget, public Ui::SmootherToolbar
{
Q_OBJECT
public:
SmootherToolbarWidget(QWidget *parent = 0);
};
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="Plugin-Smoother"
ProjectGUID="{71F09B5A-DFF7-44D5-B7E4-9EAC8FBAC635}"
RootNamespace="PluginSmoother"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)Plugins\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="c:\glut\include;c:\glew\include;&quot;$(SolutionDir)\..&quot;;&quot;$(SolutionDir)&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include\QtNetwork&quot;;&quot;$(QTDIR)\include\QtOpenGL&quot;;&quot;$(QTDIR)\mkspecs\win32-msvc.net&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;QT_GUI_LIB;QT_CORE_LIB;_USE_MATH_DEFINES;INCLUDE_TEMPLATES;NOMINMAX"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="glew32.lib QtNetworkd4.lib QtCored4.lib QtGuid4.lib QtOpenGLd4.lib qtmaind.lib glut32.lib"
AdditionalLibraryDirectories="&quot;$(SolutionDir)/lib&quot;;C:\glut\lib;&quot;$(SolutionDir)\Debug&quot;;C:\glew\lib;&quot;$(QTDIR)/lib&quot;"
GenerateManifest="false"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)Plugins\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="c:\glut\include;c:\glew\include;&quot;$(SolutionDir)\..&quot;;&quot;$(SolutionDir)&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include\QtNetwork&quot;;&quot;$(QTDIR)\include\QtOpenGL&quot;;&quot;$(QTDIR)\mkspecs\win32-msvc.net&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGINDATACONTROL_EXPORTS;_USE_MATH_DEFINES;INCLUDE_TEMPLATES;NOMINMAX;QT_NO_DEBUG"
RuntimeLibrary="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="glew32.lib QtNetwork4.lib QtCore4.lib QtGui4.lib QtOpenGL4.lib qtmain.lib glut32.lib"
AdditionalLibraryDirectories="&quot;$(SolutionDir)/lib&quot;;C:\glut\lib;&quot;$(SolutionDir)\Debug&quot;;C:\glew\lib;&quot;$(QTDIR)/lib&quot;"
GenerateManifest="false"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\Plugin-Smoother\SmootherPlugin.cc"
>
</File>
<File
RelativePath="..\..\Plugin-Smoother\SmootherToolbarWidget.cc"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\Plugin-Smoother\SmootherPlugin.hh"
FileType="2"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Moc&apos;ing SmootherPlugin.hh"
CommandLine="$(QTDIR)\bin\moc.exe ..\..\Plugin-Smoother\SmootherPlugin.hh -I ..\..\ -o tmp\moc\moc_SmootherPlugin.cpp&#x0D;&#x0A;"
AdditionalDependencies="$(QTDIR)\bin\moc.exe"
Outputs="tmp\moc\moc_SmootherPlugin.cpp"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Moc&apos;ing SmootherPlugin.hh"
CommandLine="$(QTDIR)\bin\moc.exe ..\..\Plugin-Smoother\SmootherPlugin.hh -I ..\..\ -o tmp\moc\moc_SmootherPlugin.cpp&#x0D;&#x0A;"
AdditionalDependencies="$(QTDIR)\bin\moc.exe"
Outputs="tmp\moc\moc_SmootherPlugin.cpp"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Plugin-Smoother\SmootherToolbarWidget.hh"
FileType="2"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Moc&apos;ing SmootherToolbarWidget.hh"
CommandLine="$(QTDIR)\bin\moc.exe ..\..\Plugin-Smoother\SmootherToolbarWidget.hh -I ..\..\ -o tmp\moc\moc_SmootherToolbarWidget.cpp&#x0D;&#x0A;"
AdditionalDependencies="$(QTDIR)\bin\moc.exe"
Outputs="tmp\moc\moc_SmootherToolbarWidget.cpp"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Moc&apos;ing SmootherToolbarWidget.hh"
CommandLine="$(QTDIR)\bin\moc.exe ..\..\Plugin-Smoother\SmootherToolbarWidget.hh -I ..\..\ -o tmp\moc\moc_SmootherToolbarWidget.cpp&#x0D;&#x0A;"
AdditionalDependencies="$(QTDIR)\bin\moc.exe"
Outputs="tmp\moc\moc_SmootherToolbarWidget.cpp"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\..\Plugin-Smoother\ui_smootherToolbar.ui"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="UIC&apos;ing ui_smootherToolbar.ui"
CommandLine="$(QTDIR)\bin\uic.exe ..\..\Plugin-Smoother\ui_smootherToolbar.ui -o ..\..\Plugin-Smoother\ui_smootherToolbar.hh&#x0D;&#x0A;"
AdditionalDependencies="$(QTDIR)\bin\uic.exe"
Outputs="..\..\Plugin-Smoother\ui_smootherToolbar.hh"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="UIC&apos;ing ui_smootherToolbar.ui"
CommandLine="$(QTDIR)\bin\uic.exe ..\..\Plugin-Smoother\ui_smootherToolbar.ui -o ..\..\Plugin-Smoother\ui_smootherToolbar.hh&#x0D;&#x0A;"
AdditionalDependencies="$(QTDIR)\bin\uic.exe"
Outputs="..\..\Plugin-Smoother\ui_smootherToolbar.hh"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Generated MOC Files"
>
<File
RelativePath=".\tmp\moc\moc_SmootherPlugin.cpp"
>
</File>
<File
RelativePath=".\tmp\moc\moc_SmootherToolbarWidget.cpp"
>
</File>
</Filter>
<Filter
Name="Generated UI Files"
>
<File
RelativePath=".\tmp\ui\ui_smootherToolbar.hh"
FileType="2"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
<ui version="4.0" >
<class>SmootherToolbar</class>
<widget class="QWidget" name="SmootherToolbar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>388</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="groupBox_5" >
<property name="toolTip" >
<string>Set the smoothing directions</string>
</property>
<property name="statusTip" >
<string>Set the smoothing directions</string>
</property>
<property name="title" >
<string>Component</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QRadioButton" name="rbTangential" >
<property name="toolTip" >
<string>Smooth in tangent direction</string>
</property>
<property name="statusTip" >
<string>Smooth in tangent direction</string>
</property>
<property name="text" >
<string>Tangential</string>
</property>
<property name="checked" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbNormal" >
<property name="toolTip" >
<string>Smooth in normal direction</string>
</property>
<property name="statusTip" >
<string>Smooth in normal direction</string>
</property>
<property name="text" >
<string>Normal</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbTangential_and_Normal" >
<property name="toolTip" >
<string>Smooth in tangent and normal direction</string>
</property>
<property name="statusTip" >
<string>Smooth in tangent and normal direction</string>
</property>
<property name="text" >
<string>Tangential+Normal</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4" >
<property name="toolTip" >
<string>Set the continuity that should be used</string>
</property>
<property name="statusTip" >
<string>Set the continuity that should be used</string>
</property>
<property name="title" >
<string>Continuity</string>
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QRadioButton" name="rB_c0" >
<property name="toolTip" >
<string>use C0 continuity</string>
</property>
<property name="statusTip" >
<string>use C0 continuity</string>
</property>
<property name="text" >
<string>C0</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rB_c1" >
<property name="toolTip" >
<string>use C1 continuity</string>
</property>
<property name="statusTip" >
<string>use C1 continuity</string>
</property>
<property name="text" >
<string>C1</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Constraints</string>
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QCheckBox" name="cbDistance" >
<property name="toolTip" >
<string>the maximum distance that the smoothed mesh is allowed to differ from the original mesh</string>
</property>
<property name="statusTip" >
<string>the maximum distance that the smoothed mesh is allowed to differ from the original mesh</string>
</property>
<property name="text" >
<string>Distance</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="distance" >
<property name="toolTip" >
<string>the maximum distance that the smoothed mesh is allowed to differ from the original mesh</string>
</property>
<property name="statusTip" >
<string>the maximum distance that the smoothed mesh is allowed to differ from the original mesh</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2" >
<property name="title" >
<string>Smoothing</string>
</property>
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label3" >
<property name="toolTip" >
<string>number of smoothing iterations</string>
</property>
<property name="statusTip" >
<string>number of smoothing iterations</string>
</property>
<property name="text" >
<string>Iterations</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sB_iter" >
<property name="toolTip" >
<string>number of smoothing iterations</string>
</property>