Developer documentation | Axl-2.5.1

axlActorMesh.cpp
Go to the documentation of this file.
1 /* axlActorMesh.cpp ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Fri Dec 17 10:59:21 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Mon Dec 17 15:01:45 2012 (+0100)
8  * By: Julien Wintz
9  * Update #: 130
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 #include "axlActorMesh.h"
20 
21 #include "axlVtkViewPlugin.h"
22 
23 #include "axlControlPointsWidget.h"
24 
27 #include <dtkCoreSupport/dtkAbstractDataConverter.h>
28 #include <axlCore/axlPoint.h>
29 #include <axlCore/axlMesh.h>
30 
33 
34 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
35 
36 #include <vtkActor.h>
37 #include <vtkCommand.h>
38 #include <vtkCellArray.h>
39 #include <vtkCleanPolyData.h>
40 #include <vtkDoubleArray.h>
41 #include <vtkLine.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkDataSetMapper.h>
44 #include <vtkPointData.h>
45 #include <vtkPolyDataMapper.h>
46 #include <vtkPolyDataNormals.h>
47 #include <vtkPolygon.h>
48 #include <vtkProperty.h>
49 #include <vtkSmartPointer.h>
50 #include <vtkSphereSource.h>
51 #include <vtkTubeFilter.h>
52 #include <vtkUnstructuredGrid.h>
53 #include <vtkVertex.h>
54 
55 #include <vtkIntArray.h>
56 #include <vtkLookupTable.h>
57 #include <vtkAreaPicker.h>
58 #include <vtkCellPicker.h>
59 
60 #include <vtkRenderWindow.h>
61 #include <vtkRenderer.h>
62 #include <vtkRenderWindowInteractor.h>
63 #include <vtkIdFilter.h>
64 #include <vtkDataSetSurfaceFilter.h>
65 #include <vtkTriangleFilter.h>
66 
67 #include <vtkFeatureEdges.h>
68 #include <vtkExtractEdges.h>
69 
70 #include <vtkRendererCollection.h>
71 #include <vtkPoints.h>
72 
73 #include <QVector>
74 
75 // /////////////////////////////////////////////////////////////////
76 // axlActorMeshPrivate
77 // /////////////////////////////////////////////////////////////////
78 
79 class axlActorMeshPrivate
80 {
81 public:
82  vtkSmartPointer<vtkDataSetMapper> dataSetMapper;
83  vtkSmartPointer<vtkActor> actorSphereParam;
84  //vtkSmartPointer<vtkTubeFilter> meshLineTubeFilter;
85  vtkSmartPointer<vtkPolyDataNormals> polyDataNormals;
86 
87  axlAbstractData *data;
88  axlMesh *mesh;
89 
92 
93 };
94 
95 #if (VTK_MAJOR_VERSION <= 5)
96 vtkCxxRevisionMacro(axlActorMesh, "$Revision: 0.0.1 $");
97 #endif
98 
100 
101 
103  return "axlActorMesh";
104 }
105 
106 
107 dtkAbstractData *axlActorMesh::data(void)
108 {
109  return d->data;
110 }
111 
112 void axlActorMesh::setData(dtkAbstractData *data)
113 {
114  d->data = dynamic_cast<axlAbstractData *>(data);
115 
116  this->setActor(vtkSmartPointer<vtkActor>::New());
117  this->setCellArray(vtkSmartPointer<vtkCellArray>::New());
118  this->setPolyData(vtkSmartPointer<vtkPolyData>::New());
119  this->setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
120  this->setPoints(vtkSmartPointer<vtkPoints>::New());
121  this->getMapper()->ScalarVisibilityOff();
122 
123  this->onUpdateGeometry();
124 
125  //normals computation
126  if (!d->mesh->normal_count()){
127  computeNormals();
128  this->getActor()->GetProperty()->SetInterpolationToFlat();
129  }else{
130  d->mesh->setInterpolation(2);
131  this->getActor()->GetProperty()->SetInterpolationToPhong();
132  }
133 
134  this->getActor()->SetMapper(this->getMapper());
135 
136  this->AddPart(this->getActor());
137 
138  QColor color = d->data->color();
139  this->getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
140 
141  this->setSize(d->data->size());
142  QString shader = d->data->shader();
143  if(!shader.isEmpty())
144  this->setShader(shader);
145 
146  // signals connecting
147  connect(d->data, SIGNAL(modifiedGeometry()), this, SLOT(onUpdateGeometry()));
148  connect(d->data, SIGNAL(modifiedProperty()), this, SLOT(onUpdateProperty()));
149 }
150 
152  // Generate normals
153 #if VTK_MAJOR_VERSION <= 5
154  d->polyDataNormals->SetInput(polydata);
155 #else
156  d->polyDataNormals->SetInputData(this->getPolyData());
157 #endif
158  d->polyDataNormals->ComputePointNormalsOn();
159  d->polyDataNormals->ComputeCellNormalsOff();
160  d->polyDataNormals->SetSplitting(0); // We want exactly one normal per vertex
161 
162  d->polyDataNormals->Update();
163  /*
164  // Optional settings
165  normalGenerator->SetFeatureAngle(0.1);
166  normalGenerator->SetSplitting(1);
167  normalGenerator->SetConsistency(0);
168  normalGenerator->SetAutoOrientNormals(0);
169  normalGenerator->SetComputePointNormals(1);
170  normalGenerator->SetComputeCellNormals(0);
171  normalGenerator->SetFlipNormals(0);
172  normalGenerator->SetNonManifoldTraversal(1);
173  */
174  this->setPolyData(d->polyDataNormals->GetOutput());
175 
176  d->mesh->clearNormals();
177 
178  // Generic type point normals
179  vtkDataArray* normalsGeneric = this->getPolyData()->GetPointData()->GetNormals();
180  if (!normalsGeneric)
181  return;
182 
183  double normalDouble[3];
184  if (normalsGeneric->GetNumberOfTuples() != d->mesh->vertex_count()){
185  dtkWarn() << "Couldn't compute normals.";
186  return;
187  }
188 
189  // pass normals to mesh
190  for (int i = 0; i < normalsGeneric->GetNumberOfTuples(); i++) {
191  normalsGeneric->GetTuple(i, normalDouble);
192 // std::cout << "--Double " << i << " :" << normalDouble[0] << " " << normalDouble[1] << " " << normalDouble[2] << std::endl;
193  d->mesh->push_back_normal(normalDouble);
194  }
195 
196  // enable use of normals
197  //d->mesh->normal_used()=0;
198  // update geometry to use normals
199  this->onUpdateGeometry();
200 }
201 
202 void axlActorMesh::setMode(int state)
203 {
204  this->onModeChanged(state);
205 
206  emit stateChanged(this->data(), state);
207 }
208 
209 void axlActorMesh::setSize(double size)
210 {
211  //onTubeFilterRadiusChanged(size);
212  this->getActor()->GetProperty()->SetPointSize(10 * size);
213  this->getActor()->GetProperty()->SetLineWidth(10 * size);
214 
215 }
216 
218 {
219  if(state == 0)
220  {
222  this->getActor()->SetPickable(1);
223 
224  if(d->data)
225  {
226  QColor color = d->data->color();
227  this->getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
228  }
229  }
230  else if(state == 1)
231  {
232 
234  this->getActor()->SetPickable(1);
235  vtkProperty *prop = this->getActor()->GetProperty();
236 
237  if(d->data)
238  {
239  QColor color = d->data->color();
240  qreal *h = new qreal(0.0);
241  qreal *s = new qreal(0.0);
242  qreal *l = new qreal(0.0);
243  color.getHslF(h, s, l);
244  color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
245  prop->SetColor(color.redF(), color.greenF(), color.blueF());
246  delete h;
247  delete s;
248  delete l;
249  }
250  }
251  else if(state == 2)
252  {
254  this->getActor()->SetPickable(0);
255  vtkProperty *prop = this->getActor()->GetProperty();
256  if(d->data)
257  {
258  QColor color = d->data->color();
259  qreal *h = new qreal(0.0);
260  qreal *s = new qreal(0.0);
261  qreal *l = new qreal(0.0);
262  color.getHslF(h, s, l);
263  color.setHslF(*h, *s, *l + (1.0 - *l)/2.0);
264  prop->SetColor(color.redF(), color.greenF(), color.blueF());
265  delete h;
266  delete s;
267  delete l;
268  }
269  }
270 
271  this->Modified();
272 }
273 
275 {
276  Q_UNUSED(radius);
277  if(d->mesh &&d->data)
278  {
279  bool isNormal = (d->mesh->normal_used() && d->mesh->vertex_count() == d->mesh->normal_count());
280 
281  if(isNormal)
282  {
283 
284  if(d->data->size() >= 0.001 && d->mesh->edge_show() && (!d->mesh->face_show()))
285  {
286  //d->meshLineTubeFilter->SetInput(this->getPolyData());
287  //this->getMapper()->SetInput(d->meshLineTubeFilter->GetOutput());
288 #if (VTK_MAJOR_VERSION <= 5)
289  this->getMapper()->SetInput(this->getPolyData());
290 #else
291  this->getMapper()->SetInputData(this->getPolyData());
292 #endif
293  //d->meshLineTubeFilter->SetRadius(d->data->size());
294  //d->meshLineTubeFilter->Update();
295  }
296  else
297  {
298 #if (VTK_MAJOR_VERSION <= 5)
299  this->getMapper()->SetInput(this->getPolyData());
300 #else
301  this->getMapper()->SetInputData(this->getPolyData());
302 #endif
303  }
304 
305  }
306  else
307  {
308  if(d->data->size() >= 0.001 && d->mesh->edge_show() && (!d->mesh->face_show()))
309  {
310  //d->meshLineTubeFilter->SetInput(d->polyDataNormals->GetOutput());
311 #if (VTK_MAJOR_VERSION <= 5)
312  this->getMapper()->SetInput(d->polyDataNormals->GetOutput());
313 #else
314  this->getMapper()->SetInputData(d->polyDataNormals->GetOutput());
315 #endif
316  //d->meshLineTubeFilter->SetRadius(d->data->size());
317  //d->meshLineTubeFilter->Update();
318  }
319  else
320  {
321 #if (VTK_MAJOR_VERSION <= 5)
322  this->getMapper()->SetInput(d->polyDataNormals->GetOutput());
323 #else
324  this->getMapper()->SetInputData(d->polyDataNormals->GetOutput());
325 #endif
326  }
327  }
328  }
329 }
330 
332 {
333  // delete current vtkPoint and vtkCellArray
334  this->getMapper()->RemoveAllInputs();
335  this->getPolyData()->Initialize();
336 
337  // delete current vtkPoint and vtkCellArray
338  this->getPoints()->Reset();
339  this->getCellArray()->Reset();
340 
341  this->getPoints()->Squeeze();
342  this->getCellArray()->Squeeze();
343 
344  axlMesh *mesh;
345 
346 // this->getActor()->GetProperty()->SetInterpolationToFlat();
347 
348  // if(dynamic_cast<axlMesh *>(d->data)){
349  // mesh = dynamic_cast<axlMesh *>(d->data);
350 
351  // }
352 
353  //if(d->mesh == NULL){
354  if(!(mesh = dynamic_cast<axlMesh *>(d->data)) ){
355  // we have to transform the data in a mesh
356  foreach(QString t, axlVtkViewPlugin::dataFactSingleton->converters())
357  {
358  if(!mesh)
359  {
361  if(converter){
362  dtkWarn() << Q_FUNC_INFO << t ;
363  converter->setData(d->data);
364  mesh = converter->toMesh();
365  }
366  }
367  }
368  this->getActor()->GetProperty()->SetInterpolationToGouraud();
369  }
370 
371  if(!mesh)
372  return;
373 
374  d->mesh = mesh;
375  d->data->setMesh(mesh);
376  //}
377 
378  // d->mesh->noDuplicateVertices();
379  // qDebug()<< "axlActorMesh : number or unique points "<< d->mesh->verticesUniques_count();
380  dtkWarn()<<"axlActorMesh vertices"<<d->mesh->vertex_count();
381  dtkWarn()<<"axlActorMesh edges"<<d->mesh->edge_count();
382  dtkWarn()<<"axlActorMesh faces"<<d->mesh->face_count();
383 
384  axlPoint pointCourant;
385  this->getPoints()->SetNumberOfPoints(d->mesh->vertex_count());
386  // WITH POLYDATA GRID ---------------------------------------------------
387 
388 
389  // VTK POINTS
390  for (int i = 0; i < d->mesh->vertex_count(); i++){
391  this->getPoints()->SetPoint(i, d->mesh->vertex2(i, &pointCourant)->coordinates());
392  }
393 
394  //init PolyData geom
395  vtkSmartPointer<vtkCellArray> cellArray = this->getCellArray();
396  vtkSmartPointer<vtkPolygon> currentPolygon = vtkSmartPointer<vtkPolygon>::New();
397  vtkSmartPointer<vtkLine> currentLine = vtkSmartPointer<vtkLine>::New();
398  vtkSmartPointer<vtkVertex> currentVertex = vtkSmartPointer<vtkVertex>::New();
399  vtkSmartPointer<vtkCellArray> cellArrayVertex = vtkSmartPointer<vtkCellArray>::New();
400  vtkSmartPointer<vtkDoubleArray> normals = vtkSmartPointer<vtkDoubleArray>::New();
401 
402  // POLYDATA : VERTEX and NORMALS
403  bool isNormal = (d->mesh->normal_used() && d->mesh->vertex_count() == d->mesh->normal_count());
404  if(isNormal)
405  {
406  dtkWarn()<<"axlActorMesh::normal 1 ";
407  normals->SetNumberOfComponents(3);
408  normals->SetNumberOfTuples(d->mesh->normal_count());
409  normals->SetName("normalArray");
410  }
411 
412  axlPoint currentNormal;
413  for (int i = 0; i < d->mesh->vertex_count(); i++)
414  {
415  currentVertex->GetPointIds()->SetId(0, i);
416  cellArrayVertex->InsertNextCell(currentVertex);
417 
418  if(isNormal)
419  {
420  d->mesh->normal(i, currentNormal);
421  //qDebug()<<mesh->normal(i)->coordinates()[0]<<mesh->normal(i)->coordinates()[1]<<mesh->normal(i)->coordinates()[2];
422  normals->SetTuple(i, currentNormal.coordinates());
423  }
424  }
425 
426  //MAPPER LOOKUP TABLE : COLORS
427  if(d->mesh->color_count() > 0)
428  {
429  vtkSmartPointer<vtkIntArray> scalarArray = vtkSmartPointer<vtkIntArray>::New();
430  scalarArray->SetName("mapperCollorArrayDefaultField");
431  scalarArray->SetNumberOfComponents(1);
432  scalarArray->SetNumberOfTuples(d->mesh->vertex_count());
433 
434  vtkSmartPointer<vtkLookupTable> lookupTable = vtkSmartPointer<vtkLookupTable>::New();
435  lookupTable->SetRange(0.0, d->mesh->vertex_count());
436  lookupTable->SetNumberOfTableValues(d->mesh->vertex_count());
437 
438  for(int i = 0; i < d->mesh->vertex_count(); i++)
439  {
440  scalarArray->SetTuple1(i, i);
441  lookupTable->SetTableValue(i , d->mesh->colorRF(i), d->mesh->colorGF(i), d->mesh->colorBF(i), 1.0);
442  }
443  this->getPolyData()->GetPointData()->RemoveArray(scalarArray->GetName());
444  this->getPolyData()->GetPointData()->AddArray(scalarArray);
445  this->getPolyData()->GetPointData()->SetActiveScalars("mapperCollorArrayDefaultField");
446 
447  this->getMapper()->SelectColorArray("mapperCollorArrayDefaultField");
448  this->getMapper()->SetLookupTable(lookupTable);
449  // this->getMapper()->SetInterpolateScalarsBeforeMapping(true);
450  this->getMapper()->UseLookupTableScalarRangeOn();
451  this->getMapper()->SetScalarModeToUsePointData();
452 
453  this->getMapper()->ScalarVisibilityOn();
454 
455  }
456 
457 
458 
459  // POLYDATA : LINES
460  vtkSmartPointer<vtkCellArray> cellArrayLine = vtkSmartPointer<vtkCellArray>::New();
461 
462  if(d->mesh->edge_show())
463  {
464  for(int i = 0; i <d->mesh->edge_count(); i++)
465  {
466  axlMesh::Edge currentEdge = d->mesh->edge(i);
467 
468  for(int j=0; j< currentEdge.size()-1;j++) {
469  currentLine->GetPointIds()->SetId(0 , currentEdge.at(j));
470  currentLine->GetPointIds()->SetId(1 , currentEdge.at(j+1));
471  cellArrayLine->InsertNextCell(currentLine);
472  }
473 
474  }
475  }
476 
477  // POLYDATA : FACES
478  if(d->mesh->face_show())
479  {
480  for(int i = 0; i <d->mesh->face_count(); i++)
481  {
482  axlMesh::Face currentPoly = d->mesh->face(i);
483 
484  int sizeface = currentPoly.size();
485  currentPolygon->GetPointIds()->SetNumberOfIds(sizeface);
486 
487 
488  for(int j = 0; j < sizeface; j++)
489  {
490  currentPolygon->GetPointIds()->SetId(j , currentPoly.at(j));
491  }
492 
493  if(sizeface !=0){
494  cellArray->InsertNextCell(currentPolygon);
495  }
496 
497  }
498 
499  }
500 
501 
502 
503  this->getPolyData()->SetPoints(this->getPoints());
504 
505  if(d->mesh->vertex_show())
506  this->getPolyData()->SetVerts(cellArrayVertex);
507  if(d->mesh->edge_show())
508  this->getPolyData()->SetLines(cellArrayLine);
509  if(d->mesh->face_show())
510  this->getPolyData()->SetPolys(this->getCellArray());
511 
512 
513  if(isNormal)
514  {
515  this->getPolyData()->GetPointData()->SetNormals(normals);
516 #if (VTK_MAJOR_VERSION <= 5)
517  this->getMapper()->SetInput(this->getPolyData());
518 #else
519  this->getMapper()->SetInputData(this->getPolyData());
520 #endif
521 
522  if(d->data->size() >= 0.001 && d->mesh->edge_show() && (!d->mesh->face_show()))
523  {
524  //d->meshLineTubeFilter->SetInput(this->getPolyData());
525  //this->getMapper()->SetInput(d->meshLineTubeFilter->GetOutput());
526 #if (VTK_MAJOR_VERSION <= 5)
527  this->getMapper()->SetInput(this->getPolyData());
528 #else
529  this->getMapper()->SetInputData(this->getPolyData());
530 #endif
531  //d->meshLineTubeFilter->SetRadius(d->data->size());
532  //d->meshLineTubeFilter->Update();
533  }
534 
535  }
536  else
537  {
538 
539  if(false)
540  {
541  // In the case of vtk Create normal for polygons, we ensure that vtkPoints is cleaned.
542  // for each new vtk version. Please juste connec polydata to normal and try to create default rationnal surface with Axel.
543  vtkSmartPointer<vtkCleanPolyData> cleanPolyData = vtkSmartPointer<vtkCleanPolyData>::New();
544 #if (VTK_MAJOR_VERSION <= 5)
545  cleanPolyData->SetInput(this->getPolyData());
546  d->polyDataNormals->SetInput(cleanPolyData->GetOutput());
547  this->getMapper()->SetInput(d->polyDataNormals->GetOutput());
548 #else
549  cleanPolyData->SetInputData(this->getPolyData());
550  d->polyDataNormals->SetInputData(cleanPolyData->GetOutput());
551  this->getMapper()->SetInputData(d->polyDataNormals->GetOutput());
552 #endif
553  } else {
554 #if (VTK_MAJOR_VERSION <= 5)
555  this->getMapper()->SetInput(this->getPolyData());
556 #else
557  this->getMapper()->SetInputData(this->getPolyData());
558 #endif
559  }
560  //this->getMapper()->SetInput(this->getPolyData());
561 
562  if(d->data->size() >= 0.001 && d->mesh->edge_show() && (!d->mesh->face_show()))
563  {
564  //d->meshLineTubeFilter->SetInput(this->getPolyData());
565  //this->getMapper()->SetInput(d->meshLineTubeFilter->GetOutput());
566 #if (VTK_MAJOR_VERSION <= 5)
567  this->getMapper()->SetInput(this->getPolyData());
568 #else
569  this->getMapper()->SetInputData(this->getPolyData());
570 #endif
571  //d->meshLineTubeFilter->SetRadius(d->data->size());
572  //d->meshLineTubeFilter->Update();
573  }
574 
575  }
576 
577  if(!(d->mesh->fields().isEmpty())){
578  d->mesh->touchField();
579  }
580 
581  emit updated();
582 }
583 
584 //void axlActorMesh::selectCells(vtkSmartPointer<vtkPolyData> data){
585 
586 
587 // vtkSmartPointer<vtkTriangleFilter> triangleFilter =
588 // vtkSmartPointer<vtkTriangleFilter>::New();
589 //#if (VTK_MAJOR_VERSION <= 5)
590 // //triangleFilter->SetInput(this->getPolyData());
591 // triangleFilter->SetInput(data);
592 //#else
593 // //triangleFilter->SetInputData(this->getPolyData());
594 // triangleFilter->SetInputData(data);
595 //#endif
596 // triangleFilter->Update();
597 
598 // vtkSmartPointer<vtkPolyDataMapper> mapper =
599 // vtkSmartPointer<vtkPolyDataMapper>::New();
600 //#if (VTK_MAJOR_VERSION <= 5)
601 // //mapper->SetInput(this->getPolyData());
602 // mapper->SetInput(data);
603 //#else
604 // //mapper->SetInputData(this->getPolyData());
605 // mapper->SetInputData(data);
606 //#endif
607 
608 // vtkSmartPointer<vtkActor> actor =
609 // vtkSmartPointer<vtkActor>::New();
610 // //if(d->data)
611 // //actor->GetProperty()->SetColor(d->data->color().red(), d->data->color().green(), d->data->color().blue());
612 // actor->SetMapper(mapper);
613 
614 // vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =this->getInteractor();
615 
616 // //Create picker
617 // if(!d->picker)
618 // d->picker = axlInteractorCellPicking::New();
619 
620 // d->picker->SetDefaultRenderer(this->getInteractor()->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
621 // d->picker->setData(triangleFilter->GetOutput());
622 
623 
624 // renderWindowInteractor->SetInteractorStyle(d->picker);
625 
626 // this->AddPart(actor);
627 // // renderer->ResetCamera();
628 
629 // // renderer->SetBackground(0,0,1); // Blue
630 
631 // // renderWindow->Render();
632 // // renderWindowInteractor->Start();
633 //}
634 
635 //void axlActorMesh::selectEdges(void){
636 
637 
638 // vtkSmartPointer<vtkIdFilter> idFilter =
639 // vtkSmartPointer<vtkIdFilter>::New();
640 //#if (VTK_MAJOR_VERSION <= 5)
641 // idFilter->SetInput(this->getPolyData());
642 //#else
643 // idFilter->SetInputData(this->getPolyData());
644 //#endif
645 // idFilter->SetIdsArrayName("OriginalIds");
646 // idFilter->Update();
647 
648 // vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter =
649 // vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
650 // surfaceFilter->SetInputConnection(idFilter->GetOutputPort());
651 // surfaceFilter->Update();
652 
653 // vtkPolyData* input = surfaceFilter->GetOutput();
654 
655 
656 
657 // vtkSmartPointer<vtkAreaPicker> areaPicker =
658 // vtkSmartPointer<vtkAreaPicker>::New();
659 // vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = this->getInteractor();
660 // renderWindowInteractor->SetPicker(areaPicker);
661 
662 // //Create picker
663 // if(!d->style){
664 // d->style = axlInteractorStyleRubberBandPick::New();
665 // connect(d->style, SIGNAL(IdsSelectedChanged()),this,SLOT(onSelectionChanged()));
666 // }
667 
668 // d->style->SetPolyData(input);
669 
670 // renderWindowInteractor->SetInteractorStyle( d->style );
671 // //renderWindowInteractor->Start();
672 
673 //}
674 
675 //void axlActorMesh::selectBoundaryEdges(void){
676 
677 // vtkSmartPointer<vtkFeatureEdges> featureEdges =
678 // vtkSmartPointer<vtkFeatureEdges>::New();
679 //#if (VTK_MAJOR_VERSION <= 5)
680 // featureEdges->SetInput(this->getPolyData());
681 //#else
682 // featureEdges->SetInputData(this->getPolyData());
683 //#endif
684 // featureEdges->BoundaryEdgesOn();
685 // featureEdges->FeatureEdgesOff();
686 // featureEdges->ManifoldEdgesOff();
687 // featureEdges->NonManifoldEdgesOff();
688 // featureEdges->Update();
689 
690 // vtkSmartPointer<vtkPolyDataMapper> edgeMapper =
691 // vtkSmartPointer<vtkPolyDataMapper>::New();
692 // edgeMapper->SetInputConnection(featureEdges->GetOutputPort());
693 // vtkSmartPointer<vtkActor> edgeActor =
694 // vtkSmartPointer<vtkActor>::New();
695 // edgeActor->SetMapper(edgeMapper);
696 
697 // vtkSmartPointer<vtkPolyData> poly = featureEdges->GetOutput();
698 
699 // int nbLines = poly->GetNumberOfLines();
700 // vtkSmartPointer<vtkIdTypeArray> ids = poly->GetLines()->GetData();
701 
702 // qDebug() << Q_FUNC_INFO << nbLines;
703 
704 // //selectEdges(featureEdges->GetOutput());
705 
706 //}
707 
708 //void axlActorMesh::onSelectionChanged(void){
709 // qDebug() << Q_FUNC_INFO;
710 // if(d->mesh)
711 // d->mesh->setSelectedVertices(d->style->ids());
712 //}
713 
714 axlActorMesh::axlActorMesh(void) : axlActor(), d(new axlActorMeshPrivate)
715 {
716  d->polyDataNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
717  d->polyDataNormals->AutoOrientNormalsOn();
718  d->data = NULL;
719  d->mesh = NULL;
720  d->style = NULL;
721  d->picker = NULL;
722 
723 }
724 
726 {
727  disconnect(d->style, SIGNAL(IdsSelectedChanged()),this,SLOT(onSelectionChanged()));
728  delete d;
729 
730  d = NULL;
731 }
732 
734 
735  return axlActorMesh::New();
736 
737 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
vtkSmartPointer< vtkCellArray > getCellArray(void)
Definition: axlActor.cpp:307
virtual void onUpdateGeometry()
double * coordinates(void) const
Returns coordinates of this point.
Definition: axlPoint.cpp:445
vtkCxxRevisionMacro(axlActorMesh,"$Revision: 0.0.1 $")
void computeNormals(void)
void stateChanged(dtkAbstractData *data, int mode)
virtual void setMode(int state)
vtkSmartPointer< vtkPolyData > getPolyData(void)
Definition: axlActor.cpp:295
virtual void onTubeFilterRadiusChanged(double radius)
virtual void setState(int state)
Definition: axlActor.cpp:434
QVector< int > Edge
An edge is represented by a sequence of vertices.
Definition: axlMesh.h:55
void setCellArray(vtkSmartPointer< vtkCellArray > cellArray)
Definition: axlActor.cpp:312
vtkStandardNewMacro(axlActorMesh)
QString identifier(void)
dtkAbstractData * data(void)
void updated(void)
vtkSmartPointer< vtkPoints > getPoints(void)
Definition: axlActor.cpp:275
QVector< int > Face
A face is a polygon represented by a loop of vertices.
Definition: axlMesh.h:58
void setData(dtkAbstractData *data)
virtual void setShader(QString vsfile)
Definition: axlActor.cpp:517
void setPolyData(vtkSmartPointer< vtkPolyData > polyData)
Definition: axlActor.cpp:300
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
Definition: axlActor.cpp:332
virtual void onModeChanged(int state)
void setActor(vtkSmartPointer< vtkActor > actor)
Definition: axlActor.cpp:322
vtkSmartPointer< vtkActor > getActor(void)
Definition: axlActor.cpp:317
axlAbstractActor * createAxlActorMesh(void)
virtual void onUpdateProperty(void)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
Definition: axlActor.cpp:327
virtual void setSize(double size)
static axlActorMesh * New(void)
virtual axlMesh * toMesh(void)
Mesh conversion.
Class axlAbstractData defines an API for all type of axel data.
void setPoints(vtkSmartPointer< vtkPoints > points)
Definition: axlActor.cpp:280
static dtkAbstractDataFactory * dataFactSingleton
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41