InfoPlugin.cc 16.3 KB
Newer Older
Jan Möbius's avatar
   
Jan Möbius committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//=============================================================================
//
//  CLASS InfoPlugin - IMPLEMENTATION
//
//=============================================================================


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

#include <QtGui>

#include "InfoPlugin.hh"

#include <iostream>
#include <ACG/GL/GLState.hh>
#include <QStringList>
Jan Möbius's avatar
Jan Möbius committed
17
#include <QLocale>
Jan Möbius's avatar
   
Jan Möbius committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <MeshTools/MeshInfoT.hh>
#include <OpenFlipper/common/BaseObject.hh>
#include <ACG/Geometry/Algorithms.hh>

#include <Math_Tools/Math_Tools.hh>

#include <float.h>

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

/// initialize the plugin
void InfoPlugin::pluginsInitialized() {

  //set the slot descriptions
  setDescriptions();
Jan Möbius's avatar
Jan Möbius committed
35

Jan Möbius's avatar
   
Jan Möbius committed
36
37
38
39
40
41
42
43
  // Initialize hit point
  hit_point_ = ACG::Vec3d(0.0, 0.0, 0.0);
}

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

template< class MeshT >
void InfoPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _face ) {
Jan Möbius's avatar
Jan Möbius committed
44
45
46

  QLocale locale;

Jan Möbius's avatar
   
Jan Möbius committed
47
48
49
  if (info_ == 0){
    info_ = new InfoDialog();
  }
Jan Möbius's avatar
Jan Möbius committed
50

Jan Möbius's avatar
   
Jan Möbius committed
51
52
  int closest_v_idx = getClosestVertex(_mesh, _face);
  int closest_e_idx = getClosestEdge(_mesh, _face);
Jan Möbius's avatar
Jan Möbius committed
53

Jan Möbius's avatar
   
Jan Möbius committed
54
  // ID
Jan Möbius's avatar
Jan Möbius committed
55
  info_->id->setText( "<B>Object ID:</B> " + locale.toString(_id) );
Jan Möbius's avatar
   
Jan Möbius committed
56
  // Vertices
Jan Möbius's avatar
Jan Möbius committed
57
  info_->vertices->setText( "<B>Vertices:</B> " + locale.toString( _mesh->n_vertices() ) );
Jan Möbius's avatar
   
Jan Möbius committed
58
  // Faces
Jan Möbius's avatar
Jan Möbius committed
59
  info_->faces->setText( "<B>Faces:</B> " + locale.toString( _mesh->n_faces() ) );
Jan Möbius's avatar
   
Jan Möbius committed
60
  // Edges
Jan Möbius's avatar
Jan Möbius committed
61
  info_->edges->setText( "<B>Edges:</B> " + locale.toString( _mesh->n_edges() ) );
Jan Möbius's avatar
   
Jan Möbius committed
62
  // Closest Vertex
Jan Möbius's avatar
Jan Möbius committed
63
  info_->closestv->setText( "<B>Closest vertex:</B> " + locale.toString( closest_v_idx ) );
Jan Möbius's avatar
   
Jan Möbius committed
64
  // Closest Edge
Jan Möbius's avatar
Jan Möbius committed
65
  info_->closeste->setText( "<B>Closest edge:</B> " + locale.toString( closest_e_idx ) );
Jan Möbius's avatar
Jan Möbius committed
66
67
  // Picked Vertex
  info_->pickedFace->setText( "<B>Picked face:</B> " + locale.toString( _face ) );
Jan Möbius's avatar
   
Jan Möbius committed
68
  // Components
Jan Möbius's avatar
Jan Möbius committed
69
  info_->components->setText( "<B>Components:</B> " + locale.toString(MeshInfo::componentCount(_mesh)));
Jan Möbius's avatar
   
Jan Möbius committed
70
  // Boundaries
Jan Möbius's avatar
Jan Möbius committed
71
  info_->boundaries->setText( "<B>Boundaries:</B> " + locale.toString(MeshInfo::boundaryCount(_mesh)) );
Jan Möbius's avatar
   
Jan Möbius committed
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
  // Genus
  int genus = 1 - (_mesh->n_vertices() - _mesh->n_edges() + _mesh->n_faces() ) / 2;
  info_->genus->setText( "<B>Genus:</B> " + QString::number(genus) );

  info_->table->clear();

  info_->table->setColumnCount ( 3 );
  info_->table->setRowCount ( 8 );


  QStringList headerdata;
  headerdata << "Min" << "Mean" << "Max";

  info_->table->setHorizontalHeaderLabels(headerdata);

  headerdata.clear();
  headerdata << "X Coordinate" << "Y Coordinate" << "Z Coordinate" << "Vertex Valence" << "Edge Length" << "Aspect Ratio";
  headerdata << "Inner Face Angles" << "Dihedral Angles";

  info_->table->setVerticalHeaderLabels(headerdata);

  //set tooltips
  info_->table->verticalHeaderItem(0)->setToolTip("minimum, maximum and arithmetic mean of the vertex x-coordinates");
  info_->table->verticalHeaderItem(1)->setToolTip("minimum, maximum and arithmetic mean of the vertex y-coordinates");
  info_->table->verticalHeaderItem(2)->setToolTip("minimum, maximum and arithmetic mean of the vertex z-coordinates");
  info_->table->verticalHeaderItem(3)->setToolTip("minimum, maximum and arithmetic mean of the vertex valences");
  info_->table->verticalHeaderItem(4)->setToolTip("minimum, maximum and arithmetic mean of the edge lengthes");
  info_->table->verticalHeaderItem(5)->setToolTip("minimum, maximum and arithmetic mean of the aspect ratio."
                                                  " i.e. the ratio between longest and shortest edge in a triangle.");
  info_->table->verticalHeaderItem(6)->setToolTip("minimum, maximum and arithmetic mean of the inner angles in a face.");
  info_->table->verticalHeaderItem(7)->setToolTip("minimum, maximum and arithmetic mean of the dihedral angles"
                                                  " i.e. the angles between neighboring faces.");

  // Coordinates
  typename MeshT::VertexIter v_it;
  typename MeshT::VertexIter v_end = _mesh->vertices_end();
Jan Möbius's avatar
Jan Möbius committed
108

Jan Möbius's avatar
   
Jan Möbius committed
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  float maxX = FLT_MIN;
  float minX = FLT_MAX;
  float sumX = 0.0;
  float maxY = FLT_MIN;
  float minY = FLT_MAX;
  float sumY = 0.0;
  float maxZ = FLT_MIN;
  float minZ = FLT_MAX;
  float sumZ = 0.0;
  int minV = 999;
  int maxV = 0;
  int sumV = 0;
  float maxE = FLT_MIN;
  float minE = FLT_MAX;
  float sumE = 0.0;
Jan Möbius's avatar
Jan Möbius committed
124

Jan Möbius's avatar
   
Jan Möbius committed
125
126
127
128
129
130
131
132
133
134
135
136
137
  //iterate over all vertices
  for (v_it = _mesh->vertices_begin(); v_it != v_end; ++v_it){
    typename MeshT::Point p = _mesh->point( v_it.handle() );
    if (p[0] < minX) minX = p[0];
    if (p[0] > maxX) maxX = p[0];
    sumX += p[0];
    if (p[1] < minY) minY = p[1];
    if (p[1] > maxY) maxY = p[1];
    sumY += p[1];
    if (p[2] < minZ) minZ = p[2];
    if (p[2] > maxZ) maxZ = p[2];
    sumZ += p[2];

Jan Möbius's avatar
Jan Möbius committed
138
139


Jan Möbius's avatar
   
Jan Möbius committed
140
141
142
    //check valence + edge length
    int valence = 0;
    typename MeshT::VertexVertexIter vv_it;
Jan Möbius's avatar
Jan Möbius committed
143

Jan Möbius's avatar
   
Jan Möbius committed
144
145
    for (vv_it=_mesh->vv_iter( v_it ); vv_it; ++vv_it){
      valence++;
Jan Möbius's avatar
Jan Möbius committed
146

Jan Möbius's avatar
   
Jan Möbius committed
147
148
149
150
151
152
153
154
155
156
157
158
      typename MeshT::Point p2 = _mesh->point( vv_it.handle() );
      typename MeshT::Scalar len = (p2 - p).norm();

      if (len < minE) minE = len;
      if (len > maxE) maxE = len;
      sumE += len;
    }

    if (valence < minV) minV = valence;
    if (valence > maxV) maxV = valence;
    sumV += valence;
  }
Jan Möbius's avatar
Jan Möbius committed
159

Jan Möbius's avatar
   
Jan Möbius committed
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
  int row=0;
  info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minX,'f') ) );
  info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumX / _mesh->n_vertices(),'f' )) );
  info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxX,'f') ) );
  row++;
  info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minY,'f') ) );
  info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumY / _mesh->n_vertices(),'f' )) );
  info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxY,'f') ) );
  row++;
  info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minZ,'f') ) );
  info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumZ / _mesh->n_vertices(),'f' )) );
  info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxZ,'f') ) );
  row++;
  info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minV) ) );
  info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumV / (float)_mesh->n_vertices(),'f' )) );
  info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxV) ) );
  row++;
  info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minE,'f') ) );
  info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumE / (_mesh->n_edges()*2),'f' )) );
  info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxE,'f') ) );

  //get aspect ratio

  typename MeshT::FaceIter f_it;
  typename MeshT::FaceIter f_end = _mesh->faces_end();

  float maxA = FLT_MIN;
  float minA = FLT_MAX;
  float sumA = 0.0;
  float maxI = FLT_MIN;
  float minI = FLT_MAX;
  float sumI = 0.0;
  float maxD = FLT_MIN;
  float minD = FLT_MAX;
  float sumD = 0.0;

  //iterate over all faces
  for (f_it = _mesh->faces_begin(); f_it != f_end; ++f_it){
    typename MeshT::ConstFaceVertexIter cfv_it = _mesh->cfv_iter(f_it);

    typename MeshT::Point v0 = _mesh->point( cfv_it.handle() );
    ++cfv_it;
    typename MeshT::Point v1 = _mesh->point( cfv_it.handle() );
    ++cfv_it;
    typename MeshT::Point v2 = _mesh->point( cfv_it.handle() );

    float aspect = ACG::Geometry::aspectRatio(v0, v1, v2);

    if (aspect < minA) minA = aspect;
    if (aspect > maxA) maxA = aspect;
    sumA += aspect;

    //inner triangle angles

    double angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v2 - v0) | MathTools::sane_normalized(v1 - v0) )));

    if (angle < minI) minI = angle;
    if (angle > maxI) maxI = angle;
    sumI += angle;

    angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v2 - v1) | MathTools::sane_normalized(v0 - v1) )));

    if (angle < minI) minI = angle;
    if (angle > maxI) maxI = angle;
    sumI += angle;

    angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v1 - v2) | MathTools::sane_normalized(v0 - v2) )));

    if (angle < minI) minI = angle;
    if (angle > maxI) maxI = angle;
    sumI += angle;

    //compute dihedral angles
    typename MeshT::FaceFaceIter ff_it;
    typename MeshT::Normal n1 = _mesh->normal(f_it);

    for (ff_it = _mesh->ff_iter(f_it); ff_it; ++ff_it){

Jan Möbius's avatar
Jan Möbius committed
238
      typename MeshT::Normal n2 = _mesh->normal(ff_it);
Jan Möbius's avatar
   
Jan Möbius committed
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

      angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(n1) | MathTools::sane_normalized(n2) )));

      if (angle < minD) minD = angle;
      if (angle > maxD) maxD = angle;
      sumD += angle;

    }
  }

  row++;
  info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minA,'f') ) );
  info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumA / _mesh->n_faces(),'f' )) );
  info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxA,'f') ) );
  row++;
  info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minI,'f') ) );
  info_->table->setItem(row,1, new QTableWidgetItem( "-" ) );
  info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxI,'f') ) );
  row++;
Jan Möbius's avatar
Jan Möbius committed
258

Jan Möbius's avatar
   
Jan Möbius committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
  info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minD,'f') ) );
  info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumD / (_mesh->n_faces()*3),'f' )) );
  info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxD,'f') ) );

  info_->table->resizeColumnsToContents();


  info_->table3->clear();

  info_->table3->setColumnCount ( 3 );


  headerdata.clear();
  headerdata << "X" << "Y" << "Z";

  info_->table3->setHorizontalHeaderLabels(headerdata);

  typename MeshT::FaceHandle fh = _mesh->face_handle(_face);

  headerdata.clear();
  headerdata << "Bounding Box (Minimum)" << "Bounding Box (Maximum)" << "BoundingBox (Size)" << "Center of Gravity";
  headerdata << "Picked Face Normal (Handle "+ QString::number(fh.idx()) +")";

  typename MeshT::FaceVertexIter fv_it = _mesh->fv_iter(fh);
  int vertexCount = 0;
  while( fv_it ){
    headerdata << "Adjacent Vertex (Handle " + QString::number(fv_it.handle().idx()) + ")";
    ++fv_it;
    vertexCount++;
  }

  info_->table3->setRowCount ( 5 + vertexCount );
  info_->table3->setVerticalHeaderLabels(headerdata);

  //set tooltips
  info_->table3->verticalHeaderItem(0)->setToolTip("minimum corner coordinates of the bounding box");
Jan Möbius's avatar
Jan Möbius committed
295
  info_->table3->verticalHeaderItem(1)->setToolTip("maximum corner coordinates of the bounding box");
Jan Möbius's avatar
   
Jan Möbius committed
296
297
298
299
300
301
302
303
304
305
  info_->table3->verticalHeaderItem(2)->setToolTip("diagonal size of the bounding box");
  info_->table3->verticalHeaderItem(3)->setToolTip("coordinates of the center of gravity");
  info_->table3->verticalHeaderItem(4)->setToolTip("direction of the face normal that was picked");
  for (int i=0; i < vertexCount; i++)
    info_->table3->verticalHeaderItem(5 + i)->setToolTip("Coordinates of a vertex which is adjacent to the picked face");

  //Calculate Bounding Box(min,max,cog)
  ACG::Vec3d min;
  ACG::Vec3d max;
  MeshInfo::getBoundingBox(*_mesh, min, max);
Jan Möbius's avatar
Jan Möbius committed
306

Jan Möbius's avatar
   
Jan Möbius committed
307
308
  //Bounding Box Size
  ACG::Vec3d diff = max-min;
Jan Möbius's avatar
Jan Möbius committed
309

Jan Möbius's avatar
   
Jan Möbius committed
310
311
312
313
314
315
316
317
318
319
320
321
322
  row=0;
  info_->table3->setItem(row,0, new QTableWidgetItem( QString::number(min[0],'f') ) );
  info_->table3->setItem(row,1, new QTableWidgetItem( QString::number(min[1],'f') ) );
  info_->table3->setItem(row,2, new QTableWidgetItem( QString::number(min[2],'f') ) );
  row++;
  info_->table3->setItem(row,0, new QTableWidgetItem( QString::number(max[0],'f') ) );
  info_->table3->setItem(row,1, new QTableWidgetItem( QString::number(max[1],'f') ) );
  info_->table3->setItem(row,2, new QTableWidgetItem( QString::number(max[2],'f') ) );
  row++;
  info_->table3->setItem(row,0, new QTableWidgetItem( QString::number(diff[0],'f') ) );
  info_->table3->setItem(row,1, new QTableWidgetItem( QString::number(diff[1],'f') ) );
  info_->table3->setItem(row,2, new QTableWidgetItem( QString::number(diff[2],'f') ) );

Jan Möbius's avatar
Jan Möbius committed
323
  //COG
Jan Möbius's avatar
   
Jan Möbius committed
324
325
326
327
328
329
330
331
332
333
334
  ACG::Vec3d cog = MeshInfo::cog(*_mesh);

  row++;
  info_->table3->setItem(row,0, new QTableWidgetItem( QString::number(cog[0],'f') ) );
  info_->table3->setItem(row,1, new QTableWidgetItem( QString::number(cog[1],'f') ) );
  info_->table3->setItem(row,2, new QTableWidgetItem( QString::number(cog[2],'f') ) );

  //face-normal
  row++;
  info_->table3->setItem(row,0, new QTableWidgetItem( QString::number( _mesh->normal(fh)[0],'f' ) ) );
  info_->table3->setItem(row,1, new QTableWidgetItem( QString::number( _mesh->normal(fh)[1],'f' ) ) );
Jan Möbius's avatar
Jan Möbius committed
335
336
  info_->table3->setItem(row,2, new QTableWidgetItem( QString::number( _mesh->normal(fh)[2],'f' ) ) );

Jan Möbius's avatar
   
Jan Möbius committed
337
338
  fv_it = _mesh->fv_iter(fh);
  while( fv_it )
Jan Möbius's avatar
Jan Möbius committed
339
  {
Jan Möbius's avatar
   
Jan Möbius committed
340
341
342
    row++;
    info_->table3->setItem(row,0, new QTableWidgetItem( QString::number( _mesh->point(fv_it)[0],'f' ) ) );
    info_->table3->setItem(row,1, new QTableWidgetItem( QString::number( _mesh->point(fv_it)[1],'f' ) ) );
Jan Möbius's avatar
Jan Möbius committed
343
    info_->table3->setItem(row,2, new QTableWidgetItem( QString::number( _mesh->point(fv_it)[2],'f' ) ) );
Jan Möbius's avatar
   
Jan Möbius committed
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364

    ++fv_it;
  }

  info_->table3->resizeColumnsToContents();

  info_->setWindowFlags(info_->windowFlags() | Qt::WindowStaysOnTopHint);

  info_->show();
}

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

/** \brief Find closest vertex to selection
 *
 * @param _mesh Refernce to the mesh
 * @param _face_idx Index of the face that has been clicked on
 */

template <class MeshT>
int InfoPlugin::getClosestVertex(MeshT* _mesh, int _face_idx) {
Jan Möbius's avatar
Jan Möbius committed
365

Jan Möbius's avatar
   
Jan Möbius committed
366
    typename MeshT::FaceVertexIter fv_it;
Jan Möbius's avatar
Jan Möbius committed
367

Jan Möbius's avatar
   
Jan Möbius committed
368
369
370
    int closest_v_idx = 0;
    double dist = DBL_MAX;
    double temp_dist = 0.0;
Jan Möbius's avatar
Jan Möbius committed
371

Jan Möbius's avatar
   
Jan Möbius committed
372
373
    ACG::Vec3d vTemp = ACG::Vec3d(0.0, 0.0, 0.0);
    typename MeshT::Point p;
Jan Möbius's avatar
Jan Möbius committed
374

Jan Möbius's avatar
   
Jan Möbius committed
375
    for (fv_it = _mesh->fv_iter(_mesh->face_handle(_face_idx)); fv_it; ++fv_it){
Jan Möbius's avatar
Jan Möbius committed
376

Jan Möbius's avatar
   
Jan Möbius committed
377
	p = _mesh->point( fv_it.handle() );
Jan Möbius's avatar
Jan Möbius committed
378

Jan Möbius's avatar
   
Jan Möbius committed
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
	// Find closest vertex to selection
	vTemp = ACG::Vec3d(p[0], p[1], p[2]);
	temp_dist = (vTemp - hit_point_).length();

	if (temp_dist < dist) {
	    dist = temp_dist;
	    closest_v_idx = fv_it.handle().idx();
	}

    }
    return closest_v_idx;
}

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

/** \brief Find closest edge to selection
 *
 * @param _mesh Reference to the mesh
 * @param _face_idx Index of the face that has been clicked on
 */

template <class MeshT>
int InfoPlugin::getClosestEdge(MeshT* _mesh, int _face_idx) {
Jan Möbius's avatar
Jan Möbius committed
402

Jan Möbius's avatar
   
Jan Möbius committed
403
404
405
    typename MeshT::ConstFaceHalfedgeIter fh_it;
    typename MeshT::VertexHandle v1, v2;
    typename MeshT::Point p1, p2;
Jan Möbius's avatar
Jan Möbius committed
406

Jan Möbius's avatar
   
Jan Möbius committed
407
408
409
410
    ACG::Vec3d vp1, vp2, click, e, g, h;
    double x, temp_dist, dist = DBL_MAX;
    int closest_e_handle = 0;
    click = ACG::Vec3d(hit_point_[0], hit_point_[1], hit_point_[2]);
Jan Möbius's avatar
Jan Möbius committed
411

Jan Möbius's avatar
   
Jan Möbius committed
412
    for (fh_it = _mesh->fh_iter(_mesh->face_handle(_face_idx)); fh_it; ++fh_it){
Jan Möbius's avatar
Jan Möbius committed
413

Jan Möbius's avatar
   
Jan Möbius committed
414
415
	v1 = _mesh->from_vertex_handle(fh_it);
	v2 = _mesh->to_vertex_handle(fh_it);
Jan Möbius's avatar
Jan Möbius committed
416

Jan Möbius's avatar
   
Jan Möbius committed
417
418
	p1 = _mesh->point(v1);
	p2 = _mesh->point(v2);
Jan Möbius's avatar
Jan Möbius committed
419

Jan Möbius's avatar
   
Jan Möbius committed
420
421
	vp1 = ACG::Vec3d(p1[0], p1[1], p1[2]);
	vp2 = ACG::Vec3d(p2[0], p2[1], p2[2]);
Jan Möbius's avatar
Jan Möbius committed
422

Jan Möbius's avatar
   
Jan Möbius committed
423
424
425
426
	e = vp2 - vp1;
	e.normalize();
	g = click - vp1;
	x = g | e;
Jan Möbius's avatar
Jan Möbius committed
427

Jan Möbius's avatar
   
Jan Möbius committed
428
	temp_dist = (click - (vp1 + x * e)).length();
Jan Möbius's avatar
Jan Möbius committed
429

Jan Möbius's avatar
   
Jan Möbius committed
430
431
432
433
434
	if (temp_dist < dist) {
	    dist = temp_dist;
	    closest_e_handle = _mesh->edge_handle(fh_it.handle()).idx();
	}
    }
Jan Möbius's avatar
Jan Möbius committed
435

Jan Möbius's avatar
   
Jan Möbius committed
436
    return closest_e_handle;
Jan Möbius's avatar
Jan Möbius committed
437
438
}

Jan Möbius's avatar
   
Jan Möbius committed
439
440
//----------------------------------------------------------------------------------------------

Jan Möbius's avatar
Jan Möbius committed
441
void
Jan Möbius's avatar
   
Jan Möbius committed
442
InfoPlugin::
Jan Möbius's avatar
Jan Möbius committed
443
  slotMouseEventIdentify( QMouseEvent* _event ) {
Jan Möbius's avatar
   
Jan Möbius committed
444
445
446
447
  if (_event->type() == QEvent::MouseButtonPress)
  {
    unsigned int   node_idx, target_idx;
    ACG::Vec3d     hit_point;
Jan Möbius's avatar
Jan Möbius committed
448

Jan Möbius's avatar
   
Jan Möbius committed
449
450
451
452
    if (PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_FACE, _event->pos(),node_idx, target_idx, &hit_point)) {
      BaseObjectData* object;

//     BaseObject* obj = dynamic_cast< BaseObject* > (object);
Jan Möbius's avatar
Jan Möbius committed
453

Jan Möbius's avatar
   
Jan Möbius committed
454
      if ( PluginFunctions::getPickedObject(node_idx, object) ) {
Jan Möbius's avatar
Jan Möbius committed
455

Jan Möbius's avatar
   
Jan Möbius committed
456
         emit log( LOGINFO , object->getObjectinfo() );
Jan Möbius's avatar
Jan Möbius committed
457

Jan Möbius's avatar
   
Jan Möbius committed
458
459
	 // Set hit point
	 hit_point_ = ACG::Vec3d(hit_point[0], hit_point[1], hit_point[2]);
Jan Möbius's avatar
Jan Möbius committed
460
461

         if ( object->picked(node_idx) && object->dataType(DATA_TRIANGLE_MESH) )
Jan Möbius's avatar
   
Jan Möbius committed
462
            printMeshInfo( PluginFunctions::triMesh(object) , object->id(), target_idx );
Jan Möbius's avatar
Jan Möbius committed
463
464

         if ( object->picked(node_idx) && object->dataType(DATA_POLY_MESH) )
Jan Möbius's avatar
   
Jan Möbius committed
465
            printMeshInfo( PluginFunctions::polyMesh(object) , object->id(), target_idx );
Jan Möbius's avatar
Jan Möbius committed
466

Jan Möbius's avatar
   
Jan Möbius committed
467
468
469
470
471
472
473
474
475
      } else return;
    }
  }
}

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

Q_EXPORT_PLUGIN2( InfoPlugin , InfoPlugin );

Jan Möbius's avatar
Jan Möbius committed
476