27 #include <dtkCoreSupport/dtkGlobal.h>
30 #include <vtkArrowSource.h>
31 #include <vtkCommand.h>
32 #include <vtkContourFilter.h>
33 #include <vtkDataSetMapper.h>
34 #include <vtkCellData.h>
35 #include <vtkGlyph3D.h>
36 #include <vtkHedgeHog.h>
37 #include <vtkObjectFactory.h>
38 #include <vtkPointData.h>
39 #include <vtkPolyDataMapper.h>
40 #include <vtkRenderWindowInteractor.h>
41 #include <vtkSmartPointer.h>
42 #include <vtkSphere.h>
43 #include <vtkSphereRepresentation.h>
44 #include <vtkSphereSource.h>
45 #include <vtkSphereWidget2.h>
46 #include <vtkStreamTracer.h>
47 #include <vtkTubeFilter.h>
48 #include <vtkPolyData.h>
49 #include <vtkUnstructuredGrid.h>
51 #include <vtkExtractUnstructuredGrid.h>
56 #include <vtkIntArray.h>
57 #include <vtkFloatArray.h>
58 #include <vtkDoubleArray.h>
59 #include <vtkDataArray.h>
73 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
96 class axlActorFieldDiscretePrivate
104 bool scalar_display_as_iso;
105 int scalar_iso_count;
106 double scalar_iso_range[2];
107 vtkSmartPointer<vtkTubeFilter> scalar_iso_tube_filter;
109 vtkSmartPointer<vtkContourFilter> scalar_iso;
110 vtkSmartPointer<vtkPolyDataMapper> scalar_iso_mapper;
111 vtkSmartPointer<vtkActor> scalar_iso_actor;
113 vtkSmartPointer<vtkPolyDataMapper> scalar_iso_color_mapper;
114 vtkSmartPointer<vtkActor> scalar_iso_color_actor;
117 vtkSmartPointer<vtkScalarBarActor> scalar_bar_actor;
119 double scalar_color_range[2];
120 vtkSmartPointer<vtkDataSetMapper> scalar_color_mapper;
121 vtkSmartPointer<vtkActor> scalar_color_actor;
123 vtkSmartPointer<vtkHedgeHog> vector_hedgehog;
124 vtkSmartPointer<vtkPolyDataMapper> vector_hedgehog_mapper;
125 vtkSmartPointer<vtkActor> vector_hedgehog_actor;
127 vtkSmartPointer<vtkArrowSource> vector_glyph_source;
128 vtkSmartPointer<vtkGlyph3D> vector_glyph;
129 vtkSmartPointer<vtkPolyDataMapper> vector_glyph_mapper;
130 vtkSmartPointer<vtkActor> vector_glyph_actor;
132 vtkSmartPointer<vtkSphereWidget2> vector_stream_widget;
133 vtkSmartPointer<vtkSphereRepresentation> vector_stream_widget_representation;
134 vtkSmartPointer<vtkPolyData> vector_stream_widget_data;
135 vtkSmartPointer<vtkStreamTracer> vector_stream_tracer;
136 vtkSmartPointer<vtkTubeFilter> vector_stream_filter;
137 vtkSmartPointer<vtkPolyDataMapper> vector_stream_mapper;
138 vtkSmartPointer<vtkActor> vector_stream_actor;
139 vtkSmartPointer<axlActorFieldDiscreteStreamObserver> vector_stream_observer;
141 vtkSmartPointer<vtkRenderWindowInteractor> interactor;
148 #if (VTK_MAJOR_VERSION <= 5)
169 if(d->mesh->fields().contains(QString(
"%1 magnitude").arg(d->field->objectName())))
172 QString field_magnitude_name = QString(
"%1 magnitude").arg(d->field->objectName());
176 double *tuple;
for(
int i = 0; i < d->field->size(); i++) {
177 tuple = d->field->vector(i);
178 field_magnitude->
setScalar(i, qSqrt(tuple[0]*tuple[0]+tuple[0]*tuple[0]+tuple[0]*tuple[0]));
180 return field_magnitude;
192 return d->scalar_bar_actor;
197 return d->scalar_color_range[0];
202 return d->scalar_color_range[1];
207 return d->scalar_iso->GetNumberOfContours();
212 return d->scalar_iso_range[0];
217 return d->scalar_iso_range[1];
222 return d->vector_glyph->GetScaleFactor();
227 return d->vector_stream_filter->GetRadius();
232 d->interactor =
static_cast<vtkRenderWindowInteractor *
>(interactor);
244 if(d->mesh->getUnstructuredGrid()){
245 size = d->mesh->getUnstructuredGrid()->GetNumberOfPoints();
246 }
else if(d->mesh->getPolyData()){
247 size = d->mesh->getPolyData()->GetNumberOfPoints();
249 if(dynamic_cast<axlActorDataDynamic *>(d->mesh)){
251 size =
dynamic_cast<axlActor *
>(actorDD->
outputActor())->getMapper()->GetInput()->GetNumberOfPoints();
252 d->mesh->setPolyData(dynamic_cast<axlActor *>(actorDD->
outputActor())->getMapper()->GetInput());
255 size = d->mesh->getMapper()->GetInput()->GetNumberOfPoints();
256 d->mesh->setPolyData(d->mesh->getMapper()->GetInput());
262 d->array->SetNumberOfTuples(size);
265 double *tuple1 = NULL;
267 for(
int i = 0; i < size; i++){
270 tuple2 = d->field->scalar(i);
272 d->array->SetTuple1(i, tuple2);
273 d->array->Modified();
278 tuple1 = d->field->vector(i);
280 d->array->SetTuple(i, tuple1);
281 d->array->Modified();
285 tuple1 = d->field->tensor(i);
287 d->array->SetTuple(i, tuple1);
288 d->array->Modified();
300 if(d->scalar_color_range && d->scalar_color_mapper){
316 connect(parentData, SIGNAL(modifiedGeometry()),
this, SLOT(
update()));
319 connect(axlData, SIGNAL(modifiedGeometry()),
this, SLOT(
update()));
322 d->array = vtkIntArray::New();
324 d->array = vtkFloatArray::New();
326 d->array = vtkDoubleArray::New();
332 d->array->SetNumberOfComponents(1);
335 d->array->SetNumberOfComponents(3);
338 d->array->SetNumberOfComponents(9);
341 qDebug() <<
"Unsupported field kind";
344 QString name = d->field->objectName();
345 d->array->SetName(qPrintable(name));
357 d->mesh =
dynamic_cast<axlActor *
>(actorfield);
364 d->scalar_color_range[0] = min;
365 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
366 d->scalar_color_mapper->Update();
371 d->scalar_color_range[1] = max;
372 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
373 d->scalar_color_mapper->Update();
378 d->scalar_iso_count = count;
379 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
380 d->scalar_iso->Update();
382 d->scalar_iso_tube_filter->Update();
387 d->scalar_iso_range[0] = min;
388 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
389 d->scalar_iso->Update();
390 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
391 d->scalar_iso_color_mapper->Update();
393 d->scalar_iso_tube_filter->Update();
398 d->scalar_iso_range[1] = max;
399 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
400 d->scalar_iso->Update();
401 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
402 d->scalar_iso_color_mapper->Update();
404 d->scalar_iso_tube_filter->Update();
410 double bounds[6]; d->mesh->GetBounds(bounds);
411 double side = qAbs(bounds[1]-bounds[0]);
412 side += qAbs(bounds[3]-bounds[2]);
413 side += qAbs(bounds[5]-bounds[4]);
416 d->vector_glyph->SetScaleFactor(scale * side);
417 d->vector_hedgehog->SetScaleFactor(scale * side * 0.1);
422 d->vector_stream_tracer->SetMaximumPropagation(propagation);
423 d->vector_stream_tracer->Update();
428 d->vector_stream_filter->SetRadius(radius);
429 d->vector_stream_filter->Update();
436 d->vector_stream_tracer->SetIntegrationDirectionToForward();
439 d->vector_stream_tracer->SetIntegrationDirectionToBackward();
442 d->vector_stream_tracer->SetIntegrationDirectionToBoth();
448 d->vector_stream_tracer->Update();
453 if(d->mesh->getUnstructuredGrid()){
454 d->mesh->getDataSetMapper()->ScalarVisibilityOn();
456 d->mesh->getMapper()->ScalarVisibilityOn();
463 if(d->mesh->getUnstructuredGrid()){
464 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
466 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
470 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
473 d->scalar_color_actor->SetVisibility(1);
474 d->scalar_iso_actor->SetVisibility(0);
475 d->scalar_iso_color_actor->SetVisibility(0);
476 d->scalar_display_as_iso =
false;
477 d->scalar_bar_actor->SetVisibility(1);
483 if(d->scalar_color_actor)
485 d->scalar_color_actor->SetVisibility(0);
486 d->scalar_iso_actor->SetVisibility(0);
487 d->scalar_iso_color_actor->SetVisibility(0);
488 d->scalar_display_as_iso =
false;
489 d->scalar_bar_actor->SetVisibility(0);
492 if(d->mesh->getUnstructuredGrid()){
493 d->mesh->getDataSetMapper()->ScalarVisibilityOn();
496 d->mesh->getMapper()->ScalarVisibilityOn();
500 if(d->mesh->getUnstructuredGrid()){
501 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(
"mapperCollorArrayDefaultField");
503 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(
"mapperCollorArrayDefaultField");
514 if(d->mesh->getUnstructuredGrid()){
515 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
518 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
522 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
525 if(d->mesh->getUnstructuredGrid()){
526 d->mesh->getDataSetMapper()->ScalarVisibilityOff();
529 d->mesh->getMapper()->ScalarVisibilityOff();
535 d->scalar_color_actor->SetVisibility(0);
536 d->scalar_iso_actor->SetVisibility(1);
537 d->scalar_iso_color_actor->SetVisibility(0);
538 d->scalar_display_as_iso =
true;
539 d->scalar_bar_actor->SetVisibility(0);
546 d->vector_hedgehog_actor->SetVisibility(0);
547 d->vector_glyph_actor->SetVisibility(0);
548 d->vector_stream_actor->SetVisibility(0);
549 d->vector_stream_widget->Off();
557 d->vector_hedgehog_actor->SetVisibility(1);
558 d->vector_glyph_actor->SetVisibility(0);
559 d->vector_stream_actor->SetVisibility(0);
560 d->vector_stream_widget->Off();
567 d->vector_hedgehog_actor->SetVisibility(0);
568 d->vector_glyph_actor->SetVisibility(1);
569 d->vector_stream_actor->SetVisibility(0);
570 d->vector_stream_widget->Off();
578 d->vector_hedgehog_actor->SetVisibility(0);
579 d->vector_glyph_actor->SetVisibility(0);
580 d->vector_stream_actor->SetVisibility(1);
581 d->vector_stream_widget->On();
592 if(d->mesh->getUnstructuredGrid()){
593 d->mesh->getUnstructuredGrid()->Modified();
594 #if (VTK_MAJOR_VERSION <= 5)
595 d->mesh->getUnstructuredGrid()->Update();
598 d->mesh->getPolyData()->Modified();
599 #if (VTK_MAJOR_VERSION <= 5)
600 d->mesh->getPolyData()->Update();
611 if(d->mesh->getUnstructuredGrid()){
612 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->RemoveArray(static_cast<vtkDataArray *>(d->array)->GetName());
613 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->AddArray(static_cast<vtkDataArray *>(d->array));
615 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(static_cast<vtkDataArray *>(d->array)->GetName());
616 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(static_cast<vtkDataArray *>(d->array));
619 if(d->mesh->getUnstructuredGrid()){
620 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(static_cast<vtkDataArray *>(d->array)->GetName());
622 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(static_cast<vtkDataArray *>(d->array)->GetName());
625 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(static_cast<vtkDataArray *>(d->array)->GetName());
627 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetPointData()->SetActiveTensors(static_cast<vtkDataArray *>(d->array)->GetName());
634 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->RemoveArray(static_cast<vtkDataArray *>(d->array)->GetName());
635 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(static_cast<vtkDataArray *>(d->array));
637 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(static_cast<vtkDataArray *>(d->array)->GetName());
639 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(static_cast<vtkDataArray *>(d->array)->GetName());
641 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveTensors(static_cast<vtkDataArray *>(d->array)->GetName());
652 if(d->mesh && d->field)
655 if(d->mesh->getUnstructuredGrid()){
656 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
658 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
661 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(qPrintable(d->field->objectName()));
663 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetPointData()->SetActiveTensors(qPrintable(d->field->objectName()));
667 if(d->mesh && d->field)
670 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
672 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(qPrintable(d->field->objectName()));
674 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveTensors(qPrintable(d->field->objectName()));
681 return d->scalar_color_mapper;
705 qDebug() << DTK_PRETTY_FUNCTION <<
"No field.";
719 if(d->scalar_color_mapper && d->scalar_color_actor && d->scalar_iso_color_actor)
724 if(d->mesh->getPolyData()){
725 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(static_cast<vtkDataArray *>(d->array)->GetName());
726 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(static_cast<vtkDataArray *>(d->array));
727 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(static_cast<vtkDataArray *>(d->array)->GetName());
729 if(d->mesh->getUnstructuredGrid()){
730 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->RemoveArray(static_cast<vtkDataArray *>(d->array)->GetName());
731 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->AddArray(static_cast<vtkDataArray *>(d->array));
732 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(static_cast<vtkDataArray *>(d->array)->GetName());
738 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->RemoveArray(static_cast<vtkDataArray *>(d->array)->GetName());
739 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(static_cast<vtkDataArray *>(d->array));
740 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(static_cast<vtkDataArray *>(d->array)->GetName());
746 d->scalar_display_as_iso =
false;
747 d->scalar_iso_count = 10;
748 static_cast<vtkDataArray *
>(d->array)->GetRange(d->scalar_iso_range);
750 d->scalar_iso = vtkSmartPointer<vtkContourFilter>::New();
751 if(d->mesh->getUnstructuredGrid()){
752 #if (VTK_MAJOR_VERSION <= 5)
753 d->scalar_iso->SetInput(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
755 d->scalar_iso->SetInputData(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
758 #if (VTK_MAJOR_VERSION <= 5)
759 d->scalar_iso->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
761 d->scalar_iso->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
764 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
766 d->scalar_iso_tube_filter = vtkSmartPointer<vtkTubeFilter>::New();
767 d->scalar_iso_tube_filter->SetRadius(d->isoRadius);
768 d->scalar_iso_tube_filter->SetNumberOfSides(8);
769 #if (VTK_MAJOR_VERSION <= 5)
770 d->scalar_iso_tube_filter->SetInput(d->scalar_iso->GetOutput());
772 d->scalar_iso_tube_filter->SetInputData(d->scalar_iso->GetOutput());
774 d->scalar_iso_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
775 #if (VTK_MAJOR_VERSION <= 5)
776 d->scalar_iso_mapper->SetInput(d->scalar_iso_tube_filter->GetOutput());
778 d->scalar_iso_mapper->SetInputData(d->scalar_iso_tube_filter->GetOutput());
781 d->scalar_iso_actor = vtkSmartPointer<vtkActor>::New();
782 d->scalar_iso_actor->SetMapper(d->scalar_iso_mapper);
783 d->scalar_iso_actor->SetVisibility(0);
785 this->AddPart(d->scalar_iso_actor);
789 d->scalar_iso_color_mapper = vtkPolyDataMapper::New();
790 #if (VTK_MAJOR_VERSION <= 5)
791 d->scalar_iso_color_mapper->SetInput(d->scalar_iso->GetOutput());
793 d->scalar_iso_color_mapper->SetInputData(d->scalar_iso->GetOutput());
795 d->scalar_iso_color_mapper->SetColorModeToMapScalars();
798 d->scalar_iso_color_mapper->SetScalarModeToUsePointData();
801 d->scalar_iso_color_mapper->SetScalarModeToUseCellData();
803 d->scalar_iso_color_mapper->SelectColorArray(static_cast<vtkDataArray *>(d->array)->GetName());
804 d->scalar_iso_color_mapper->SetScalarVisibility(
true);
805 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
807 d->scalar_iso_color_actor = vtkSmartPointer<vtkActor>::New();
808 d->scalar_iso_color_actor->SetMapper(d->scalar_iso_color_mapper);
809 d->scalar_iso_color_actor->SetVisibility(0);
811 this->AddPart(d->scalar_iso_color_actor);
815 static_cast<vtkDataArray *
>(d->array)->GetRange(d->scalar_color_range);
817 d->scalar_color_mapper = vtkDataSetMapper::New();
818 #if (VTK_MAJOR_VERSION <= 5)
819 if(d->mesh->getUnstructuredGrid())
820 d->scalar_color_mapper->SetInput(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
822 d->scalar_color_mapper->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
824 if(d->mesh->getUnstructuredGrid())
825 d->scalar_color_mapper->SetInputData(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
827 d->scalar_color_mapper->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
830 d->scalar_color_mapper->SetColorModeToMapScalars();
833 d->scalar_color_mapper->SetScalarModeToUsePointData();
836 d->scalar_color_mapper->SetScalarModeToUseCellData();
838 d->scalar_color_mapper->SelectColorArray(static_cast<vtkDataArray *>(d->array)->GetName());
839 d->scalar_color_mapper->SetScalarVisibility(
true);
840 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
842 d->scalar_color_actor = vtkSmartPointer<vtkActor>::New();
843 d->scalar_color_actor->SetMapper(d->scalar_color_mapper);
844 d->scalar_color_actor->SetVisibility(0);
846 this->AddPart(d->scalar_color_actor);
851 d->scalar_bar_actor = vtkSmartPointer<vtkScalarBarActor>::New();
852 d->scalar_bar_actor ->SetLookupTable(d->scalar_color_mapper->GetLookupTable());
853 d->scalar_bar_actor ->SetTitle(qPrintable(d->field->name()));
854 d->scalar_bar_actor ->SetNumberOfLabels(4);
855 d->scalar_bar_actor->SetVisibility(0);
870 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(static_cast<vtkDataArray *>(d->array)->GetName());
871 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(static_cast<vtkDataArray *>(d->array));
872 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(static_cast<vtkDataArray *>(d->array)->GetName());
877 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(static_cast<vtkDataArray *>(d->array)->GetName());
878 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(static_cast<vtkDataArray *>(d->array));
879 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(static_cast<vtkDataArray *>(d->array)->GetName());
886 if(! d->vector_hedgehog)
887 d->vector_hedgehog = vtkSmartPointer<vtkHedgeHog>::New();
889 #if (VTK_MAJOR_VERSION <= 5)
890 d->vector_hedgehog->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
892 d->vector_hedgehog->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
894 d->vector_hedgehog->SetVectorModeToUseVector();
895 d->vector_hedgehog->SetScaleFactor(0.05);
897 if(!d->vector_hedgehog_mapper) {
898 d->vector_hedgehog_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
899 d->vector_hedgehog_mapper->SetInputConnection(d->vector_hedgehog->GetOutputPort());
900 d->vector_hedgehog_mapper->ScalarVisibilityOn();
903 if(!d->vector_hedgehog_actor)
904 d->vector_hedgehog_actor = vtkSmartPointer<vtkActor>::New();
905 d->vector_hedgehog_actor->SetMapper(d->vector_hedgehog_mapper);
906 d->vector_hedgehog_actor->SetVisibility(0);
908 this->AddPart(d->vector_hedgehog_actor);
913 d->vector_glyph = vtkSmartPointer<vtkGlyph3D>::New();
915 if(!d->vector_glyph_source)
916 d->vector_glyph_source = vtkArrowSource::New();
919 #if (VTK_MAJOR_VERSION <= 5)
920 d->vector_glyph->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
921 d->vector_glyph->SetSource(d->vector_glyph_source->GetOutput());
923 d->vector_glyph->SetSourceData(d->vector_glyph_source->GetOutput());
924 d->vector_glyph->SetSourceConnection(d->vector_glyph_source->GetOutputPort());
925 d->vector_glyph->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
929 d->vector_glyph->SetColorModeToColorByVector();
930 d->vector_glyph->SetScaleModeToScaleByVector();
931 d->vector_glyph->SetVectorModeToUseVector();
932 d->vector_glyph->SetScaleModeToDataScalingOff();
936 d->vector_glyph->OrientOn();
938 if(!d->vector_glyph_mapper) {
939 d->vector_glyph_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
940 d->vector_glyph_mapper->SetInputConnection(d->vector_glyph->GetOutputPort());
941 d->vector_glyph_mapper->ScalarVisibilityOn();
945 if(!d->vector_glyph_actor){
946 d->vector_glyph_actor = vtkSmartPointer<vtkActor>::New();
947 d->vector_glyph_actor->SetMapper(d->vector_glyph_mapper);
948 d->vector_glyph_actor->SetVisibility(0);
951 this->AddPart(d->vector_glyph_actor);
955 d->vector_stream_widget = vtkSmartPointer<vtkSphereWidget2>::New();
956 d->vector_stream_widget->SetInteractor(d->interactor);
957 d->vector_stream_widget->CreateDefaultRepresentation();
958 d->vector_stream_widget->SetTranslationEnabled(
true);
959 d->vector_stream_widget->SetScalingEnabled(
true);
960 d->vector_stream_widget->Off();
962 d->vector_stream_widget_data = vtkPolyData::New();
964 d->vector_stream_widget_representation = vtkSphereRepresentation::SafeDownCast(d->vector_stream_widget->GetRepresentation());
965 d->vector_stream_widget_representation->HandleVisibilityOff();
966 d->vector_stream_widget_representation->HandleTextOff();
967 d->vector_stream_widget_representation->RadialLineOff();
968 d->vector_stream_widget_representation->SetPhiResolution(64);
969 d->vector_stream_widget_representation->SetThetaResolution(64);
970 d->vector_stream_widget_representation->GetPolyData(d->vector_stream_widget_data);
972 d->vector_stream_tracer = vtkStreamTracer::New();
973 #if (VTK_MAJOR_VERSION <= 5)
974 d->vector_stream_tracer->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
975 d->vector_stream_tracer->SetSource(d->vector_stream_widget_data);
977 d->vector_stream_tracer->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
978 d->vector_stream_tracer->SetSourceData(d->vector_stream_widget_data);
980 d->vector_stream_tracer->SetMaximumPropagation(100);
981 d->vector_stream_tracer->SetMinimumIntegrationStep(1.0e-4);
982 d->vector_stream_tracer->SetMaximumIntegrationStep(100.0);
983 d->vector_stream_tracer->SetIntegrationDirectionToBoth();
985 d->vector_stream_filter = vtkTubeFilter::New();
986 #if (VTK_MAJOR_VERSION <= 5)
987 d->vector_stream_filter->SetInput(d->vector_stream_tracer->GetOutput());
989 d->vector_stream_filter->SetInputData(d->vector_stream_tracer->GetOutput());
991 d->vector_stream_filter->SetRadius(0.01);
992 d->vector_stream_filter->SetNumberOfSides(8);
994 d->vector_stream_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
995 d->vector_stream_mapper->SetInputConnection(d->vector_stream_filter->GetOutputPort());
996 d->vector_stream_mapper->ScalarVisibilityOn();
998 d->vector_stream_actor = vtkSmartPointer<vtkActor>::New();
999 d->vector_stream_actor->SetMapper(d->vector_stream_mapper);
1000 d->vector_stream_actor->SetVisibility(0);
1003 d->vector_stream_observer->vector_stream_widget_representation = d->vector_stream_widget_representation;
1004 d->vector_stream_observer->vector_stream_widget_data = d->vector_stream_widget_data;
1005 d->vector_stream_observer->vector_stream_tracer = d->vector_stream_tracer;
1006 d->vector_stream_widget->AddObserver(vtkCommand::InteractionEvent, d->vector_stream_observer);
1008 this->AddPart(d->vector_stream_actor);
1015 double field_range[2];
static_cast<vtkDataArray *
>(d->array)->GetRange(field_range);
1016 return field_range[0];
1021 double field_range[2];
static_cast<vtkDataArray *
>(d->array)->GetRange(field_range);
1023 return field_range[1];
1028 d->isoRadius = radius;
1029 d->scalar_iso_tube_filter->SetRadius(radius);
1030 d->scalar_iso_tube_filter->Update();
void setStreamDirection(int direction)
void setIsoRangeMax(double max)
vtkSmartPointer< vtkSphereRepresentation > vector_stream_widget_representation
void setGlyphScale(double scale)
vtkSmartPointer< vtkStreamTracer > vector_stream_tracer
void setInteractor(void *interactor)
axlActorFieldDiscrete(void)
void displayAsNoneScalar(void)
~axlActorFieldDiscrete(void)
void displayAsColor(void)
void setActiveFieldKind(void)
axlAbstractActor * actorField(void)
Class axlAbstractFieldDiscrete defines an API for arrays of numeric data.
axlAbstractField * field(void)
axlAbstractField * magnitude(void)
static axlActorFieldDiscreteStreamObserver * New(void)
double streamRadius(void)
void displayAsStream(void)
axlAbstractActor * outputActor(void)
void setIsoRangeMin(double min)
void setStreamPropagation(double propagation)
virtual void setScalar(int index, double v1)
void setColRangeMin(double min)
virtual void setData(dtkAbstractData *field)
void displayAsHedge(void)
void setActorField(axlAbstractActor *actor)
Class axlAbstractField defines an API for arrays of numeric data.
Class axlFieldDiscrete defines an API for arrays of numeric data.
void displayAsGlyph(void)
void * scalarColorMapper(void)
void setStreamRadius(double radius)
vtkCxxRevisionMacro(axlActorFieldDiscrete,"$Revision: 0.0.1 $")
void displayAsNoneVector(void)
vtkScalarBarActor * scalarBar(void)
vtkStandardNewMacro(axlActorFieldDiscrete)
vtkSmartPointer< vtkPolyData > vector_stream_widget_data
virtual void Execute(vtkObject *caller, unsigned long event, void *)
dtkAbstractData * data(void)
void setColRangeMax(double max)
void setIsoCount(int count)
Class axlAbstractData defines an API for all type of axel data.
void onIsoRadiusChanged(double radius)