HarmonicExamplePlugin.cc 4.78 KB
Newer Older
Henrik Zimmer's avatar
Henrik Zimmer committed
1
2
/*===========================================================================*\
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
3
 *                          Plugin-HarmonicExample                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
4
5
6
7
 *      Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.rwth-graphics.de                            *
 *                                                                           *
 *---------------------------------------------------------------------------* 
Henrik Zimmer's avatar
Henrik Zimmer committed
8
 *  This file is part of Plugin-HarmonicExample                              *
Henrik Zimmer's avatar
Henrik Zimmer committed
9
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
10
11
12
13
 *  Plugin-HarmonicExample 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 3 of the License, or     *
 *  (at your option) any later version.                                      *
Henrik Zimmer's avatar
Henrik Zimmer committed
14
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
15
 *  Plugin-HarmonicExample is distributed in the hope that it will be useful,*
Henrik Zimmer's avatar
Henrik Zimmer committed
16
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
Henrik Zimmer's avatar
Henrik Zimmer committed
18
 *  GNU General Public License for more details.                             *
Henrik Zimmer's avatar
Henrik Zimmer committed
19
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
20
21
22
 *  You should have received a copy of the GNU General Public License        *
 *  along with Plugin-HarmonicExample.                                       *
 *  If not, see <http://www.gnu.org/licenses/>.                              *
Henrik Zimmer's avatar
Henrik Zimmer committed
23
24
25
 *                                                                           *
\*===========================================================================*/ 

Henrik Zimmer's avatar
Henrik Zimmer committed
26

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//=============================================================================
//
//  CLASS HarmonicExamplePlugin - IMPLEMENTATION
//
//=============================================================================

//== INCLUDES =================================================================

#include <Qt>
#include <QtGui>
#include <QSpacerItem>

#include "HarmonicExamplePlugin.hh"

#include <iostream>
#include <ACG/Utils/StopWatch.hh>

#include <OpenFlipper/BasePlugin/PluginFunctions.hh>

// #include <PhySim/QtWidgets/QwtFunctionPlot.hh>
// #include <PhySim/Meshes/PrincipalCurvatureT.hh>
// #include <PhySim/Meshes/PrincipalCurvatureJetT.hh>
// #include <PhySim/Math/Algorithms.hh>


#undef min
#undef max


//== IMPLEMENTATION ==========================================================


void HarmonicExamplePlugin::initializePlugin()
{
  tool_ = new HarmonicExampleToolbar();

  QSize size(300,300);
  tool_->resize(size);
  
  // connect button press event to function slotCompute()
  connect(tool_->compute_pb, SIGNAL( clicked() ), this, SLOT( slotCompute() ) );

69
  emit addToolbox( tr("HarmonicExample") , tool_ );
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
}


//-----------------------------------------------------------------------------


void HarmonicExamplePlugin::pluginsInitialized() 
{
//   emit addPickMode("Separator");
}


//-----------------------------------------------------------------------------


HarmonicExamplePlugin::HarmonicExample*
HarmonicExamplePlugin::
get_harmonicexample_object( BaseObjectData* _object )
{
  // initialize PerObjectData if not done yet
  if (!_object->hasObjectData(pod_name()))
  {
    // get mesh object
    TriMesh* mesh = dynamic_cast< TriMeshObject* >( _object )->mesh();

    // initialize per object data
    _object->setObjectData(pod_name(), new POD(*mesh));
  }
  
  // get feature lines object
  HarmonicExample* harmonicexample = dynamic_cast<HarmonicExample*>(& (dynamic_cast< POD* >(_object->objectData(pod_name() )))->harmonicexample());

  return harmonicexample;
}


//-----------------------------------------------------------------------------


void HarmonicExamplePlugin::slotCompute() 
{
  // iterate over all target triangle meshes
  for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DATA_TRIANGLE_MESH) ; o_it != PluginFunctions::objectsEnd(); ++o_it) 
  {
    // get pointer to mesh
    TriMesh* mesh = dynamic_cast< TriMeshObject* >( *o_it )->mesh();
    if ( mesh )
    {
      // get feature line object and call compute function
      get_harmonicexample_object( *o_it )->compute();
      
      // set correct draw mode
      TriMeshObject  *mesh_obj;
      mesh_obj = PluginFunctions::triMeshObject((*o_it));
      mesh_obj->meshNode()->drawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED);
      mesh_obj->materialNode()->disable_color_material();
    }
  }
}


//-----------------------------------------------------------------------------


Q_EXPORT_PLUGIN2( harmonicexampleplugin , HarmonicExamplePlugin );