22 #include <vtkConeSource.h>
29 #include <dtkCoreSupport/dtkGlobal.h>
32 #include <vtkArrowSource.h>
33 #include <vtkCommand.h>
34 #include <vtkContourFilter.h>
35 #include <vtkDataSetMapper.h>
36 #include <vtkCellData.h>
37 #include <vtkGlyph3D.h>
38 #include <vtkHedgeHog.h>
39 #include <vtkObjectFactory.h>
40 #include <vtkPointData.h>
41 #include <vtkPolyDataMapper.h>
42 #include <vtkRenderWindowInteractor.h>
43 #include <vtkSmartPointer.h>
44 #include <vtkSphere.h>
45 #include <vtkSphereRepresentation.h>
46 #include <vtkSphereSource.h>
47 #include <vtkSphereWidget2.h>
48 #include <vtkStreamTracer.h>
49 #include <vtkTubeFilter.h>
50 #include <vtkPolyData.h>
51 #include <vtkUnstructuredGrid.h>
53 #include <vtkExtractUnstructuredGrid.h>
55 #include <vtkIntArray.h>
56 #include <vtkFloatArray.h>
57 #include <vtkDoubleArray.h>
58 #include <vtkDataArray.h>
74 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
97 class axlActorFieldSpatialPrivate
106 bool scalar_display_as_iso;
107 int scalar_iso_count;
108 double scalar_iso_range[2];
109 vtkSmartPointer<vtkTubeFilter> scalar_iso_tube_filter;
111 vtkSmartPointer<vtkContourFilter> scalar_iso;
112 vtkSmartPointer<vtkPolyDataMapper> scalar_iso_mapper;
113 vtkSmartPointer<vtkActor> scalar_iso_actor;
115 vtkSmartPointer<vtkPolyDataMapper> scalar_iso_color_mapper;
116 vtkSmartPointer<vtkActor> scalar_iso_color_actor;
118 double scalar_color_range[2];
119 vtkSmartPointer<vtkDataSetMapper> scalar_color_mapper;
120 vtkSmartPointer<vtkActor> scalar_color_actor;
122 vtkSmartPointer<vtkScalarBarActor> scalar_bar_actor;
124 vtkSmartPointer<vtkHedgeHog> vector_hedgehog;
125 vtkSmartPointer<vtkPolyDataMapper> vector_hedgehog_mapper;
126 vtkSmartPointer<vtkActor> vector_hedgehog_actor;
128 vtkSmartPointer<vtkArrowSource> vector_glyph_source;
129 vtkSmartPointer<vtkGlyph3D> vector_glyph;
130 vtkSmartPointer<vtkPolyDataMapper> vector_glyph_mapper;
131 vtkSmartPointer<vtkActor> vector_glyph_actor;
133 vtkSmartPointer<vtkSphereWidget2> vector_stream_widget;
134 vtkSmartPointer<vtkSphereRepresentation> vector_stream_widget_representation;
135 vtkSmartPointer<vtkPolyData> vector_stream_widget_data;
136 vtkSmartPointer<vtkStreamTracer> vector_stream_tracer;
137 vtkSmartPointer<vtkTubeFilter> vector_stream_filter;
138 vtkSmartPointer<vtkPolyDataMapper> vector_stream_mapper;
139 vtkSmartPointer<vtkActor> vector_stream_actor;
140 vtkSmartPointer<axlActorFieldSpatialStreamObserver> vector_stream_observer;
142 vtkSmartPointer<vtkRenderWindowInteractor> interactor;
149 #if (VTK_MAJOR_VERSION <= 5)
170 if(d->mesh->fields().contains(QString(
"%1 magnitude").arg(d->field->objectName())))
173 QString field_magnitude_name = QString(
"%1 magnitude").arg(d->field->objectName());
176 if(d->mesh->getUnstructuredGrid())
177 size = d->mesh->getUnstructuredGrid()->GetNumberOfPoints();
179 size = d->mesh->getPolyData()->GetNumberOfPoints();
183 for(
int i = 0; i < size; i++){
184 if(d->mesh->getUnstructuredGrid())
185 tuple = d->field->vector(d->mesh->getUnstructuredGrid()->GetPoint(i)[0], d->mesh->getUnstructuredGrid()->GetPoint(i)[1], d->mesh->getUnstructuredGrid()->GetPoint(i)[2]);
187 tuple = d->field->vector(d->mesh->getPolyData()->GetPoint(i)[0], d->mesh->getPolyData()->GetPoint(i)[1], d->mesh->getPolyData()->GetPoint(i)[2]);
188 field_magnitude->
setScalar(i, qSqrt(tuple[0]*tuple[0]+tuple[0]*tuple[0]+tuple[0]*tuple[0]));
190 return field_magnitude;
201 return d->scalar_bar_actor;
206 return d->scalar_color_range[0];
211 return d->scalar_color_range[1];
216 return d->scalar_iso->GetNumberOfContours();
221 return d->scalar_iso_range[0];
226 return d->scalar_iso_range[1];
231 return d->vector_glyph->GetScaleFactor();
236 return d->vector_stream_filter->GetRadius();
241 d->interactor =
static_cast<vtkRenderWindowInteractor *
>(interactor);
252 if(d->mesh->getUnstructuredGrid()){
253 size = d->mesh->getUnstructuredGrid()->GetNumberOfPoints();
254 }
else if(d->mesh->getPolyData()){
255 size = d->mesh->getPolyData()->GetNumberOfPoints();
257 if(dynamic_cast<axlActorDataDynamic *>(d->mesh)){
259 size =
dynamic_cast<axlActor *
>(actorDD->
outputActor())->getMapper()->GetInput()->GetNumberOfPoints();
260 d->mesh->setPolyData(dynamic_cast<axlActor *>(actorDD->
outputActor())->getMapper()->GetInput());
263 size = d->mesh->getMapper()->GetInput()->GetNumberOfPoints();
264 d->mesh->setPolyData(d->mesh->getMapper()->GetInput());
270 d->array->SetNumberOfTuples(size);
273 double *tuple1 = NULL;
275 for(
int i = 0; i < size; i++){
278 if(d->mesh->getUnstructuredGrid())
279 tuple2 = d->field->scalar(d->mesh->getUnstructuredGrid()->GetPoint(i)[0], d->mesh->getUnstructuredGrid()->GetPoint(i)[1], d->mesh->getUnstructuredGrid()->GetPoint(i)[2]);
281 tuple2 = d->field->scalar(d->mesh->getPolyData()->GetPoint(i)[0], d->mesh->getPolyData()->GetPoint(i)[1], d->mesh->getPolyData()->GetPoint(i)[2]);
283 d->array->SetTuple1(i, tuple2);
284 d->array->Modified();
288 if(d->mesh->getUnstructuredGrid())
289 tuple1 = d->field->vector(d->mesh->getUnstructuredGrid()->GetPoint(i)[0], d->mesh->getUnstructuredGrid()->GetPoint(i)[1], d->mesh->getUnstructuredGrid()->GetPoint(i)[2]);
291 tuple1 = d->field->vector(d->mesh->getPolyData()->GetPoint(i)[0], d->mesh->getPolyData()->GetPoint(i)[1], d->mesh->getPolyData()->GetPoint(i)[2]);
292 d->array->SetTuple(i, tuple1);
293 d->array->Modified();
297 if(d->mesh->getUnstructuredGrid())
298 tuple1 = d->field->tensor(d->mesh->getUnstructuredGrid()->GetPoint(i)[0], d->mesh->getUnstructuredGrid()->GetPoint(i)[1], d->mesh->getUnstructuredGrid()->GetPoint(i)[2]);
300 tuple1 = d->field->tensor(d->mesh->getPolyData()->GetPoint(i)[0], d->mesh->getPolyData()->GetPoint(i)[1], d->mesh->getPolyData()->GetPoint(i)[2]);
301 d->array->SetTuple(i, tuple1);
302 d->array->Modified();
314 if(d->scalar_color_range && d->scalar_color_mapper){
328 connect(parentData, SIGNAL(modifiedGeometry()),
this, SLOT(
update()));
331 connect(axlData, SIGNAL(modifiedGeometry()),
this, SLOT(
update()));
335 d->array = vtkIntArray::New();
337 d->array = vtkFloatArray::New();
339 d->array = vtkDoubleArray::New();
345 d->array->SetNumberOfComponents(1);
348 d->array->SetNumberOfComponents(3);
351 d->array->SetNumberOfComponents(9);
354 qDebug() <<
"Unsupported field kind";
357 QString name = d->field->objectName();
358 d->array->SetName(qPrintable(name));
369 d->mesh =
dynamic_cast<axlActor *
>(actorfield);
376 d->scalar_color_range[0] = min;
377 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
378 d->scalar_color_mapper->Update();
383 d->scalar_color_range[1] = max;
384 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
385 d->scalar_color_mapper->Update();
390 d->scalar_iso_count = count;
391 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
392 d->scalar_iso->Update();
394 d->scalar_iso_tube_filter->Update();
399 d->scalar_iso_range[0] = min;
400 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
401 d->scalar_iso->Update();
402 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
403 d->scalar_iso_color_mapper->Update();
405 d->scalar_iso_tube_filter->Update();
410 d->scalar_iso_range[1] = max;
411 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
412 d->scalar_iso->Update();
413 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
414 d->scalar_iso_color_mapper->Update();
416 d->scalar_iso_tube_filter->Update();
422 double bounds[6]; d->mesh->GetBounds(bounds);
423 double side = qAbs(bounds[1]-bounds[0]);
424 side += qAbs(bounds[3]-bounds[2]);
425 side += qAbs(bounds[5]-bounds[4]);
431 d->vector_glyph->SetScaleFactor(scale * side);
432 d->vector_hedgehog->SetScaleFactor(scale * side * 0.1);
437 d->vector_stream_tracer->SetMaximumPropagation(propagation);
438 d->vector_stream_tracer->Update();
443 d->vector_stream_filter->SetRadius(radius);
444 d->vector_stream_filter->Update();
451 d->vector_stream_tracer->SetIntegrationDirectionToForward();
454 d->vector_stream_tracer->SetIntegrationDirectionToBackward();
457 d->vector_stream_tracer->SetIntegrationDirectionToBoth();
463 d->vector_stream_tracer->Update();
468 if(d->mesh->getUnstructuredGrid()){
469 d->mesh->getDataSetMapper()->ScalarVisibilityOn();
471 d->mesh->getMapper()->ScalarVisibilityOn();
478 if(d->mesh->getUnstructuredGrid()){
479 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
481 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
485 if(d->mesh->getUnstructuredGrid()){
486 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
488 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
493 d->scalar_color_actor->SetVisibility(1);
494 d->scalar_iso_actor->SetVisibility(0);
495 d->scalar_iso_color_actor->SetVisibility(0);
496 d->scalar_display_as_iso =
false;
497 d->scalar_bar_actor->SetVisibility(1);
503 if(d->scalar_color_actor)
505 d->scalar_color_actor->SetVisibility(0);
506 d->scalar_iso_actor->SetVisibility(0);
507 d->scalar_iso_color_actor->SetVisibility(0);
508 d->scalar_display_as_iso =
false;
509 d->scalar_bar_actor->SetVisibility(0);
512 if(d->mesh->getUnstructuredGrid()){
513 d->mesh->getDataSetMapper()->ScalarVisibilityOn();
516 d->mesh->getMapper()->ScalarVisibilityOn();
520 if(d->mesh->getUnstructuredGrid()){
521 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(
"mapperCollorArrayDefaultField");
523 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(
"mapperCollorArrayDefaultField");
534 if(d->mesh->getUnstructuredGrid()){
535 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
538 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
543 if(d->mesh->getUnstructuredGrid()){
544 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
547 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
552 if(d->mesh->getUnstructuredGrid()){
553 d->mesh->getDataSetMapper()->ScalarVisibilityOff();
556 d->mesh->getMapper()->ScalarVisibilityOff();
562 d->scalar_color_actor->SetVisibility(0);
563 d->scalar_iso_actor->SetVisibility(1);
564 d->scalar_iso_color_actor->SetVisibility(0);
565 d->scalar_display_as_iso =
true;
566 d->scalar_bar_actor->SetVisibility(0);
573 d->vector_hedgehog_actor->SetVisibility(0);
574 d->vector_glyph_actor->SetVisibility(0);
575 d->vector_stream_actor->SetVisibility(0);
576 d->vector_stream_widget->Off();
584 d->vector_hedgehog_actor->SetVisibility(1);
585 d->vector_glyph_actor->SetVisibility(0);
586 d->vector_stream_actor->SetVisibility(0);
587 d->vector_stream_widget->Off();
595 d->vector_hedgehog_actor->SetVisibility(0);
596 d->vector_glyph_actor->SetVisibility(1);
597 d->vector_stream_actor->SetVisibility(0);
598 d->vector_stream_widget->Off();
606 d->vector_hedgehog_actor->SetVisibility(0);
607 d->vector_glyph_actor->SetVisibility(0);
608 d->vector_stream_actor->SetVisibility(1);
609 d->vector_stream_widget->On();
620 if(d->mesh->getUnstructuredGrid()){
621 d->mesh->getUnstructuredGrid()->Modified();
622 #if (VTK_MAJOR_VERSION <= 5)
623 d->mesh->getUnstructuredGrid()->Update();
626 d->mesh->getPolyData()->Modified();
627 #if (VTK_MAJOR_VERSION <= 5)
628 d->mesh->getPolyData()->Update();
639 if(d->mesh->getUnstructuredGrid()){
640 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->RemoveArray(d->array->GetName());
641 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->AddArray(d->array);
643 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(d->array->GetName());
644 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(d->array);
648 d->scalar_iso_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
649 d->scalar_iso_actor->SetPosition(d->mesh->getActor()->GetPosition());
650 d->scalar_iso_color_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
651 d->scalar_iso_color_actor->SetPosition(d->mesh->getActor()->GetPosition());
652 d->scalar_color_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
653 d->scalar_color_actor->SetPosition(d->mesh->getActor()->GetPosition());
656 if(d->mesh->getUnstructuredGrid()){
657 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(d->array->GetName());
659 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(d->array->GetName());
663 d->vector_glyph_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
664 d->vector_glyph_actor->SetPosition(d->mesh->getActor()->GetPosition());
665 d->vector_hedgehog_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
666 d->vector_hedgehog_actor->SetPosition(d->mesh->getActor()->GetPosition());
667 d->vector_stream_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
668 d->vector_stream_actor->SetPosition(d->mesh->getActor()->GetPosition());
671 if(d->mesh->getUnstructuredGrid()){
672 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveVectors(d->array->GetName());
674 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(d->array->GetName());
678 if(d->mesh->getUnstructuredGrid()){
679 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveTensors(d->array->GetName());
681 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveTensors(d->array->GetName());
690 if(d->mesh->getPolyData()){
691 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->RemoveArray(d->array->GetName());
692 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(d->array);
694 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->RemoveArray(d->array->GetName());
695 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->AddArray(d->array);
698 if(d->mesh->getPolyData())
699 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(d->array->GetName());
701 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->SetActiveScalars(d->array->GetName());
704 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(d->array->GetName());
706 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->SetActiveVectors(d->array->GetName());
708 if( d->mesh->getPolyData())
709 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveTensors(d->array->GetName());
711 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->SetActiveTensors(d->array->GetName());
721 if(d->mesh && d->field)
724 if(d->mesh->getUnstructuredGrid()){
725 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
727 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
730 if(d->mesh->getUnstructuredGrid()){
731 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveVectors(qPrintable(d->field->objectName()));
733 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(qPrintable(d->field->objectName()));
736 if(d->mesh->getUnstructuredGrid()){
737 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveTensors(qPrintable(d->field->objectName()));
739 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveTensors(qPrintable(d->field->objectName()));
745 if(d->mesh && d->field)
748 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
750 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(qPrintable(d->field->objectName()));
752 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveTensors(qPrintable(d->field->objectName()));
759 return d->scalar_color_mapper;
784 qDebug() << DTK_PRETTY_FUNCTION <<
"No field.";
796 if(d->scalar_color_mapper && d->scalar_color_actor && d->scalar_iso_color_actor)
801 if(d->mesh->getPolyData()){
802 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(d->array->GetName());
803 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(d->array);
804 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(d->array->GetName());
806 if(d->mesh->getUnstructuredGrid()){
807 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->RemoveArray(d->array->GetName());
808 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->AddArray(d->array);
809 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(d->array->GetName());
815 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->RemoveArray(d->array->GetName());
816 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(d->array);
817 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(d->array->GetName());
823 d->scalar_display_as_iso =
false;
824 d->scalar_iso_count = 10;
825 d->array->GetRange(d->scalar_iso_range);
827 d->scalar_iso = vtkSmartPointer<vtkContourFilter>::New();
828 if(d->mesh->getUnstructuredGrid()){
829 #if (VTK_MAJOR_VERSION <= 5)
830 d->scalar_iso->SetInput(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
832 d->scalar_iso->SetInputData(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
835 #if (VTK_MAJOR_VERSION <= 5)
836 d->scalar_iso->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
838 d->scalar_iso->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
841 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
843 d->scalar_iso_tube_filter = vtkSmartPointer<vtkTubeFilter>::New();
844 d->scalar_iso_tube_filter->SetRadius(d->isoRadius);
845 d->scalar_iso_tube_filter->SetNumberOfSides(8);
846 #if (VTK_MAJOR_VERSION <= 5)
847 d->scalar_iso_tube_filter->SetInput(d->scalar_iso->GetOutput());
849 d->scalar_iso_tube_filter->SetInputData(d->scalar_iso->GetOutput());
851 d->scalar_iso_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
852 #if (VTK_MAJOR_VERSION <= 5)
853 d->scalar_iso_mapper->SetInput(d->scalar_iso_tube_filter->GetOutput());
855 d->scalar_iso_mapper->SetInputData(d->scalar_iso_tube_filter->GetOutput());
858 d->scalar_iso_actor = vtkSmartPointer<vtkActor>::New();
859 d->scalar_iso_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
860 d->scalar_iso_actor->SetPosition(d->mesh->getActor()->GetPosition());
861 d->scalar_iso_actor->SetMapper(d->scalar_iso_mapper);
862 d->scalar_iso_actor->SetVisibility(0);
864 this->AddPart(d->scalar_iso_actor);
868 d->scalar_iso_color_mapper = vtkPolyDataMapper::New();
869 #if (VTK_MAJOR_VERSION <= 5)
870 d->scalar_iso_color_mapper->SetInput(d->scalar_iso->GetOutput());
872 d->scalar_iso_color_mapper->SetInputData(d->scalar_iso->GetOutput());
874 d->scalar_iso_color_mapper->SetColorModeToMapScalars();
877 d->scalar_iso_color_mapper->SetScalarModeToUsePointData();
880 d->scalar_iso_color_mapper->SetScalarModeToUseCellData();
882 d->scalar_iso_color_mapper->SelectColorArray(d->array->GetName());
883 d->scalar_iso_color_mapper->SetScalarVisibility(
true);
884 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
886 d->scalar_iso_color_actor = vtkSmartPointer<vtkActor>::New();
887 d->scalar_iso_color_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
888 d->scalar_iso_color_actor->SetPosition(d->mesh->getActor()->GetPosition());
889 d->scalar_iso_color_actor->SetMapper(d->scalar_iso_color_mapper);
890 d->scalar_iso_color_actor->SetVisibility(0);
892 this->AddPart(d->scalar_iso_color_actor);
896 d->array->GetRange(d->scalar_color_range);
898 d->scalar_color_mapper = vtkDataSetMapper::New();
899 #if (VTK_MAJOR_VERSION <= 5)
900 if(d->mesh->getUnstructuredGrid())
901 d->scalar_color_mapper->SetInput(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
903 d->scalar_color_mapper->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
905 if(d->mesh->getUnstructuredGrid())
906 d->scalar_color_mapper->SetInputData(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
908 d->scalar_color_mapper->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
911 d->scalar_color_mapper->SetColorModeToMapScalars();
914 d->scalar_color_mapper->SetScalarModeToUsePointData();
917 d->scalar_color_mapper->SetScalarModeToUseCellData();
919 d->scalar_color_mapper->SelectColorArray(d->array->GetName());
920 d->scalar_color_mapper->SetScalarVisibility(
true);
921 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
923 d->scalar_color_actor = vtkSmartPointer<vtkActor>::New();
924 d->scalar_color_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
925 d->scalar_color_actor->SetPosition(d->mesh->getActor()->GetPosition());
926 d->scalar_color_actor->SetMapper(d->scalar_color_mapper);
927 d->scalar_color_actor->SetVisibility(0);
930 this->AddPart(d->scalar_color_actor);
933 d->scalar_bar_actor = vtkSmartPointer<vtkScalarBarActor>::New();
934 d->scalar_bar_actor ->SetLookupTable(d->scalar_color_mapper->GetLookupTable());
935 d->scalar_bar_actor ->SetTitle(qPrintable(d->field->name()));
936 d->scalar_bar_actor ->SetNumberOfLabels(4);
937 d->scalar_bar_actor->SetVisibility(0);
950 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(d->array->GetName());
951 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(d->array);
952 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(d->array->GetName());
957 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(d->array->GetName());
958 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(d->array);
959 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(d->array->GetName());
966 d->vector_hedgehog = vtkSmartPointer<vtkHedgeHog>::New();
967 #if (VTK_MAJOR_VERSION <= 5)
968 d->vector_hedgehog->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
970 d->vector_hedgehog->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
972 d->vector_hedgehog->SetVectorModeToUseVector();
975 d->vector_hedgehog_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
976 d->vector_hedgehog_mapper->SetInputConnection(d->vector_hedgehog->GetOutputPort());
977 d->vector_hedgehog_mapper->ScalarVisibilityOn();
979 d->vector_hedgehog_actor = vtkSmartPointer<vtkActor>::New();
980 d->vector_hedgehog_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
981 d->vector_hedgehog_actor->SetPosition(d->mesh->getActor()->GetPosition());
982 d->vector_hedgehog_actor->SetMapper(d->vector_hedgehog_mapper);
983 d->vector_hedgehog_actor->SetVisibility(0);
986 this->AddPart(d->vector_hedgehog_actor);
990 d->vector_glyph_source = vtkArrowSource::New();
992 d->vector_glyph = vtkSmartPointer<vtkGlyph3D>::New();
993 #if (VTK_MAJOR_VERSION <= 5)
994 d->vector_glyph->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
995 d->vector_glyph->SetSource(d->vector_glyph_source->GetOutput());
997 d->vector_glyph->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
998 d->vector_glyph->SetSourceData(d->vector_glyph_source->GetOutput());
1001 d->vector_glyph->SetColorModeToColorByVector();
1002 d->vector_glyph->SetVectorModeToUseVector();
1004 d->vector_glyph->SetScaleModeToDataScalingOff();
1007 d->vector_glyph->OrientOn();
1008 d->vector_glyph->Update();
1010 d->vector_glyph_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
1011 d->vector_glyph_mapper->SetInputConnection(d->vector_glyph->GetOutputPort());
1022 d->vector_glyph_actor = vtkSmartPointer<vtkActor>::New();
1023 d->vector_glyph_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
1024 d->vector_glyph_actor->SetPosition(d->mesh->getActor()->GetPosition());
1025 d->vector_glyph_actor->SetMapper(d->vector_glyph_mapper);
1027 d->vector_glyph_actor->SetVisibility(0);
1029 this->AddPart(d->vector_glyph_actor);
1033 d->vector_stream_widget = vtkSmartPointer<vtkSphereWidget2>::New();
1034 d->vector_stream_widget->SetInteractor(d->interactor);
1035 d->vector_stream_widget->CreateDefaultRepresentation();
1036 d->vector_stream_widget->SetTranslationEnabled(
true);
1037 d->vector_stream_widget->SetScalingEnabled(
true);
1038 d->vector_stream_widget->Off();
1040 d->vector_stream_widget_data = vtkPolyData::New();
1042 d->vector_stream_widget_representation = vtkSphereRepresentation::SafeDownCast(d->vector_stream_widget->GetRepresentation());
1043 d->vector_stream_widget_representation->HandleVisibilityOff();
1044 d->vector_stream_widget_representation->HandleTextOff();
1045 d->vector_stream_widget_representation->RadialLineOff();
1046 d->vector_stream_widget_representation->SetPhiResolution(64);
1047 d->vector_stream_widget_representation->SetThetaResolution(64);
1048 d->vector_stream_widget_representation->GetPolyData(d->vector_stream_widget_data);
1050 d->vector_stream_tracer = vtkStreamTracer::New();
1051 #if (VTK_MAJOR_VERSION <= 5)
1052 d->vector_stream_tracer->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1053 d->vector_stream_tracer->SetSource(d->vector_stream_widget_data);
1055 d->vector_stream_tracer->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1056 d->vector_stream_tracer->SetSourceData(d->vector_stream_widget_data);
1058 d->vector_stream_tracer->SetMaximumPropagation(100);
1059 d->vector_stream_tracer->SetMinimumIntegrationStep(1.0e-4);
1060 d->vector_stream_tracer->SetMaximumIntegrationStep(100.0);
1061 d->vector_stream_tracer->SetIntegrationDirectionToBoth();
1063 d->vector_stream_filter = vtkTubeFilter::New();
1064 #if (VTK_MAJOR_VERSION <= 5)
1065 d->vector_stream_filter->SetInput(d->vector_stream_tracer->GetOutput());
1067 d->vector_stream_filter->SetInputData(d->vector_stream_tracer->GetOutput());
1069 d->vector_stream_filter->SetRadius(0.01);
1070 d->vector_stream_filter->SetNumberOfSides(8);
1072 d->vector_stream_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
1073 d->vector_stream_mapper->SetInputConnection(d->vector_stream_filter->GetOutputPort());
1074 d->vector_stream_mapper->ScalarVisibilityOn();
1076 d->vector_stream_actor = vtkSmartPointer<vtkActor>::New();
1077 d->vector_stream_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
1078 d->vector_stream_actor->SetPosition(d->mesh->getActor()->GetPosition());
1079 d->vector_stream_actor->SetMapper(d->vector_stream_mapper);
1080 d->vector_stream_actor->SetVisibility(0);
1083 d->vector_stream_observer->vector_stream_widget_representation = d->vector_stream_widget_representation;
1084 d->vector_stream_observer->vector_stream_widget_data = d->vector_stream_widget_data;
1085 d->vector_stream_observer->vector_stream_tracer = d->vector_stream_tracer;
1086 d->vector_stream_widget->AddObserver(vtkCommand::InteractionEvent, d->vector_stream_observer);
1088 this->AddPart(d->vector_stream_actor);
1095 double field_range[2];d->array->GetRange(field_range);
1096 return field_range[0];
1101 double field_range[2];d->array->GetRange(field_range);
1103 return field_range[1];
1108 d->isoRadius = radius;
1109 d->scalar_iso_tube_filter->SetRadius(radius);
1110 d->scalar_iso_tube_filter->Update();
void setColRangeMin(double min)
vtkSmartPointer< vtkSphereRepresentation > vector_stream_widget_representation
void setStreamDirection(int direction)
void setGlyphScale(double scale)
void setIsoRangeMin(double min)
axlAbstractField * field(void)
void setColRangeMax(double max)
void setActorField(axlAbstractActor *actor)
~axlActorFieldSpatial(void)
vtkStandardNewMacro(axlActorFieldSpatial)
void displayAsStream(void)
void displayAsColor(void)
void setActiveFieldKind(void)
axlAbstractActor * outputActor(void)
void * scalarColorMapper(void)
vtkScalarBarActor * scalarBar(void)
void displayAsGlyph(void)
virtual void setScalar(int index, double v1)
void setStreamPropagation(double propagation)
Class axlAbstractFieldSpatial defines an API for spatial field.
axlActorFieldSpatial(void)
void setIsoCount(int count)
Class axlAbstractField defines an API for arrays of numeric data.
double streamRadius(void)
axlAbstractActor * actorField(void)
Class axlFieldDiscrete defines an API for arrays of numeric data.
virtual void setData(dtkAbstractData *field)
void displayAsHedge(void)
virtual void Execute(vtkObject *caller, unsigned long event, void *)
void onIsoRadiusChanged(double radius)
vtkSmartPointer< vtkStreamTracer > vector_stream_tracer
void setInteractor(void *interactor)
void setIsoRangeMax(double max)
static axlActorFieldSpatialStreamObserver * New(void)
void setStreamRadius(double radius)
vtkSmartPointer< vtkPolyData > vector_stream_widget_data
Class axlAbstractData defines an API for all type of axel data.
void displayAsNoneVector(void)
vtkCxxRevisionMacro(axlActorFieldSpatial,"$Revision: 0.0.1 $")
void displayAsNoneScalar(void)
axlAbstractField * magnitude(void)
dtkAbstractData * data(void)