32 #include <dtkCoreSupport/dtkGlobal.h>
35 #include <vtkArrowSource.h>
36 #include <vtkCommand.h>
37 #include <vtkContourFilter.h>
38 #include <vtkDataSetMapper.h>
39 #include <vtkCellData.h>
40 #include <vtkGlyph3D.h>
41 #include <vtkHedgeHog.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkPointData.h>
44 #include <vtkPolyDataMapper.h>
45 #include <vtkRenderWindowInteractor.h>
46 #include <vtkSmartPointer.h>
47 #include <vtkSphere.h>
48 #include <vtkSphereRepresentation.h>
49 #include <vtkSphereSource.h>
50 #include <vtkSphereWidget2.h>
51 #include <vtkStreamTracer.h>
52 #include <vtkTubeFilter.h>
53 #include <vtkPolyData.h>
54 #include <vtkUnstructuredGrid.h>
56 #include <vtkDataArray.h>
57 #include <vtkFloatArray.h>
58 #include <vtkIntArray.h>
59 #include <vtkDoubleArray.h>
61 #include <vtkExtractUnstructuredGrid.h>
75 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
98 class axlActorFieldParametricPrivate
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 vtkSmartPointer<vtkScalarBarActor> scalar_bar_actor;
120 double scalar_color_range[2];
121 vtkSmartPointer<vtkDataSetMapper> scalar_color_mapper;
122 vtkSmartPointer<vtkActor> scalar_color_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<axlActorFieldParametricStreamObserver> 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());
177 double size = d->field->size();
190 for(
int i = 0; i < size; i++){
194 return field_magnitude;
205 return d->scalar_bar_actor;
211 return d->scalar_color_range[0];
216 return d->scalar_color_range[1];
221 return d->scalar_iso->GetNumberOfContours();
226 return d->scalar_iso_range[0];
231 return d->scalar_iso_range[1];
236 return d->vector_glyph->GetScaleFactor();
241 return d->vector_stream_filter->GetRadius();
246 d->interactor =
static_cast<vtkRenderWindowInteractor *
>(interactor);
253 size = d->field->size();
255 d->array->SetNumberOfTuples(size);
257 if(!d->mesh->getUnstructuredGrid() && !d->mesh->getPolyData()){
258 if(dynamic_cast<axlActorDataDynamic *>(d->mesh)){
260 d->mesh->setPolyData(dynamic_cast<axlActor *>(actorDD->
outputActor())->getMapper()->GetInput());
262 d->mesh->setPolyData(d->mesh->getMapper()->GetInput());
270 if(dynamic_cast<axlAbstractFieldParametricCurve *>(d->field)){
274 double start_u = fieldSurface->
start_u();
275 double end_u = fieldSurface->
end_u();
281 double step_u = (end_u - start_u)/(n_u);
286 for(
int i = 0; i < n_u - 1; i++)
290 d->array->SetTuple1( i, fieldSurface->
scalar(u));
291 d->array->Modified();
293 d->array->SetTuple( i, fieldSurface->
vector(u));
294 d->array->Modified();
296 d->array->SetTuple( i, fieldSurface->
tensor(u));
297 d->array->Modified();
307 else if(dynamic_cast<axlAbstractFieldParametricSurface *>(d->field)){
311 double start_u = fieldSurface->
start_u();
312 double start_v = fieldSurface->
start_v();
313 double end_u = fieldSurface->
end_u();
314 double end_v = fieldSurface->
end_v();
322 double step_u = (end_u - start_u)/(n_u);
323 double step_v = (end_v - start_v)/(n_v);
327 for(
int j = 0; j < n_v - 1; j++)
329 for(
int i = 0; i < n_u - 1; i++)
333 d->array->SetTuple1(j * n_u + i, fieldSurface->
scalar(u,v));
334 d->array->Modified();
336 d->array->SetTuple(j * n_u + i, fieldSurface->
vector(u,v) );
337 d->array->Modified();
339 d->array->SetTuple(j * n_u + i, fieldSurface->
tensor(u,v));
340 d->array->Modified();
348 d->array->SetTuple1(j * n_u + n_u - 1 , fieldSurface->
scalar(end_u,v));
349 d->array->Modified();
351 d->array->SetTuple(j * n_u + n_u - 1 , fieldSurface->
vector(end_u,v));
352 d->array->Modified();
354 d->array->SetTuple(j * n_u + n_u - 1 , fieldSurface->
tensor(end_u,v));
355 d->array->Modified();
362 for(
int i = 0; i < n_u - 1; i++)
365 d->array->SetTuple1((n_v - 1) * n_u + i, fieldSurface->
scalar(u,end_v));
366 d->array->Modified();
368 d->array->SetTuple((n_v - 1) * n_u + i, fieldSurface->
vector(u,end_v));
369 d->array->Modified();
371 d->array->SetTuple((n_v - 1) * n_u + i, fieldSurface->
tensor(u,end_v));
372 d->array->Modified();
379 d->array->SetTuple1(n_v * n_u - 1,fieldSurface->
scalar(end_u,end_v));
380 d->array->Modified();
382 d->array->SetTuple(n_v * n_u - 1,fieldSurface->
vector(end_u,end_v));
383 d->array->Modified();
385 d->array->SetTuple(n_v * n_u - 1,fieldSurface->
tensor(end_u,end_v));
386 d->array->Modified();
391 else if(dynamic_cast<axlAbstractFieldParametricVolume *>(d->field)){
394 double start_u = fieldVolume->
start_u();
395 double start_v = fieldVolume->
start_v();
396 double start_w = fieldVolume->
start_w();
397 double end_u = fieldVolume->
end_u();
398 double end_v = fieldVolume->
end_v();
399 double end_w = fieldVolume->
end_w();
409 double step_u = (end_u - start_u)/(n_u);
410 double step_v = (end_v - start_v)/(n_v);
411 double step_w = (end_w - start_w)/(n_w);
416 for(
int k = 0; k < n_w - 1; k++)
418 ind1 = k * n_u * n_v;
419 for(
int i = 0; i < n_v - 1; i++)
422 for(
int j = 0; j < n_u - 1; j++)
424 ind3 = ind1 + ind2 +j;
426 d->array->SetTuple1(ind3,fieldVolume->
scalar(u, v,w));
427 d->array->Modified();
431 d->array->Modified();
433 d->array->SetTuple(ind3,fieldVolume->
vector(u, v,w));
435 d->array->SetTuple(ind3,fieldVolume->
tensor(u, v,w));
436 d->array->Modified();
440 ind3 = ind1 + ind2 + (n_u - 1);
442 d->array->SetTuple1(ind3,fieldVolume->
scalar(end_u, v, w));
443 d->array->Modified();
445 d->array->SetTuple(ind3,fieldVolume->
vector(end_u, v, w));
446 d->array->Modified();
448 d->array->SetTuple(ind3,fieldVolume->
tensor(end_u, v, w));
449 d->array->Modified();
455 ind3 = ind1 + (n_v -1)* n_u + (n_u - 1);
457 d->array->SetTuple1(ind3,fieldVolume->
scalar(end_u, end_v, w));
458 d->array->Modified();
460 d->array->SetTuple(ind3,fieldVolume->
vector(end_u, end_v, w));
461 d->array->Modified();
463 d->array->SetTuple(ind3,fieldVolume->
tensor(end_u, end_v, w));
464 d->array->Modified();
474 ind1 = n_u * n_v * (n_w - 1);
475 for(
int j = 0; j < n_v - 1; j++)
478 for(
int i = 0; i < n_u - 1; i++)
480 ind3 = ind1 + ind2 + i;
482 d->array->SetTuple1(ind3, fieldVolume->
scalar(u, v, end_w));
483 d->array->Modified();
485 d->array->SetTuple(ind3, fieldVolume->
vector(u, v, end_w));
486 d->array->Modified();
488 d->array->SetTuple(ind3, fieldVolume->
tensor(u, v, end_w));
489 d->array->Modified();
494 ind3 = ind1 + ind2 + (n_u -1);
496 d->array->SetTuple1(ind3,fieldVolume->
scalar(end_u, v, end_w));
497 d->array->Modified();
499 d->array->SetTuple(ind3,fieldVolume->
vector(end_u, v, end_w));
500 d->array->Modified();
502 d->array->SetTuple(ind3,fieldVolume->
tensor(end_u, v, end_w));
503 d->array->Modified();
511 ind2 = (n_v-1) * n_u;
513 for(
int k = 0; k < n_w ; k++)
515 ind1 = n_u * n_v * k;
516 for(
int i = 0; i < n_u - 1; i++)
518 ind3 = ind1 + ind2 + i;
520 d->array->SetTuple1(ind3,fieldVolume->
scalar(u, end_v, w));
521 d->array->Modified();
523 d->array->SetTuple(ind3,fieldVolume->
vector(u, end_v, w));
524 d->array->Modified();
526 d->array->SetTuple(ind3,fieldVolume->
tensor(u, end_v, w));
527 d->array->Modified();
533 ind3 = ind2 + ind1 + (n_u-1);
539 d->array->SetTuple1(n_u * n_v * n_w -1,fieldVolume->
scalar(end_u, end_v, end_w));
540 d->array->Modified();
542 d->array->SetTuple(n_u * n_v * n_w -1,fieldVolume->
vector(end_u, end_v, end_w));
543 d->array->Modified();
545 d->array->SetTuple(n_u * n_v * n_w -1,fieldVolume->
tensor(end_u, end_v, end_w));
546 d->array->Modified();
555 if(d->scalar_color_range && d->scalar_color_mapper){
570 connect(parentData, SIGNAL(modifiedGeometry()),
this, SLOT(
update()));
573 connect(axlData, SIGNAL(modifiedGeometry()),
this, SLOT(
update()));
576 d->array = vtkIntArray::New();
578 d->array = vtkFloatArray::New();
580 d->array = vtkDoubleArray::New();
587 d->array->SetNumberOfComponents(1);
590 d->array->SetNumberOfComponents(3);
593 d->array->SetNumberOfComponents(9);
596 qDebug() <<
"Unsupported field kind";
599 QString name = d->field->objectName();
600 d->array->SetName(qPrintable(name));
610 d->mesh =
dynamic_cast<axlActor *
>(actorfield);
617 d->scalar_color_range[0] = min;
618 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
619 d->scalar_color_mapper->Update();
624 d->scalar_color_range[1] = max;
625 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
626 d->scalar_color_mapper->Update();
631 d->scalar_iso_count = count;
632 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
633 d->scalar_iso->Update();
638 d->scalar_iso_range[0] = min;
639 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
640 d->scalar_iso->Update();
641 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
642 d->scalar_iso_color_mapper->Update();
647 d->scalar_iso_range[1] = max;
648 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
649 d->scalar_iso->Update();
650 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
651 d->scalar_iso_color_mapper->Update();
657 double bounds[6]; d->mesh->GetBounds(bounds);
658 double side = qAbs(bounds[1]-bounds[0]);
659 side += qAbs(bounds[3]-bounds[2]);
660 side += qAbs(bounds[5]-bounds[4]);
666 d->vector_glyph->SetScaleFactor(scale * side);
667 d->vector_hedgehog->SetScaleFactor(scale * side * 0.1);
672 d->vector_stream_tracer->SetMaximumPropagation(propagation);
673 d->vector_stream_tracer->Update();
678 d->vector_stream_filter->SetRadius(radius);
679 d->vector_stream_filter->Update();
686 d->vector_stream_tracer->SetIntegrationDirectionToForward();
689 d->vector_stream_tracer->SetIntegrationDirectionToBackward();
692 d->vector_stream_tracer->SetIntegrationDirectionToBoth();
698 d->vector_stream_tracer->Update();
703 if (d->mesh->getUnstructuredGrid()) {
704 d->mesh->getDataSetMapper()->ScalarVisibilityOn();
706 d->mesh->getMapper()->ScalarVisibilityOn();
713 if(d->mesh->getUnstructuredGrid()){
714 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
716 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
720 if(d->mesh->getUnstructuredGrid()){
721 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
723 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
727 d->scalar_color_actor->SetVisibility(1);
728 d->scalar_iso_actor->SetVisibility(0);
729 d->scalar_iso_color_actor->SetVisibility(0);
730 d->scalar_display_as_iso =
false;
731 d->scalar_bar_actor->SetVisibility(1);
737 if(d->scalar_color_actor)
739 d->scalar_color_actor->SetVisibility(0);
740 d->scalar_iso_actor->SetVisibility(0);
741 d->scalar_iso_color_actor->SetVisibility(0);
742 d->scalar_display_as_iso =
false;
743 d->scalar_bar_actor->SetVisibility(0);
745 if(d->mesh->getUnstructuredGrid()){
746 d->mesh->getDataSetMapper()->ScalarVisibilityOn();
749 d->mesh->getMapper()->ScalarVisibilityOn();
752 if(d->mesh->getUnstructuredGrid()){
753 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(
"mapperCollorArrayDefaultField");
755 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(
"mapperCollorArrayDefaultField");
766 if (d->mesh->getUnstructuredGrid()) {
767 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
769 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
774 if(d->mesh->getUnstructuredGrid()){
775 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
778 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
783 if(d->mesh->getUnstructuredGrid()){
784 d->mesh->getDataSetMapper()->ScalarVisibilityOff();
787 d->mesh->getMapper()->ScalarVisibilityOff();
791 d->scalar_color_actor->SetVisibility(0);
792 d->scalar_iso_actor->SetVisibility(1);
793 d->scalar_iso_color_actor->SetVisibility(0);
794 d->scalar_display_as_iso =
true;
795 d->scalar_bar_actor->SetVisibility(0);
802 d->vector_hedgehog_actor->SetVisibility(0);
803 d->vector_glyph_actor->SetVisibility(0);
804 d->vector_stream_actor->SetVisibility(0);
805 d->vector_stream_widget->Off();
813 d->vector_hedgehog_actor->SetVisibility(1);
814 d->vector_glyph_actor->SetVisibility(0);
815 d->vector_stream_actor->SetVisibility(0);
816 d->vector_stream_widget->Off();
824 d->vector_hedgehog_actor->SetVisibility(0);
825 d->vector_glyph_actor->SetVisibility(1);
826 d->vector_stream_actor->SetVisibility(0);
827 d->vector_stream_widget->Off();
835 d->vector_hedgehog_actor->SetVisibility(0);
836 d->vector_glyph_actor->SetVisibility(0);
837 d->vector_stream_actor->SetVisibility(1);
838 d->vector_stream_widget->On();
849 if(d->mesh->getUnstructuredGrid()){
850 d->mesh->getUnstructuredGrid()->Modified();
851 #if (VTK_MAJOR_VERSION <= 5)
852 d->mesh->getUnstructuredGrid()->Update();
855 d->mesh->getPolyData()->Modified();
856 #if (VTK_MAJOR_VERSION <= 5)
857 d->mesh->getPolyData()->Update();
867 if(d->mesh->getUnstructuredGrid()){
868 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->RemoveArray(d->array->GetName());
869 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->AddArray(d->array);
871 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(d->array->GetName());
872 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(d->array);
876 d->scalar_iso_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
877 d->scalar_iso_actor->SetPosition(d->mesh->getActor()->GetPosition());
878 d->scalar_iso_color_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
879 d->scalar_iso_color_actor->SetPosition(d->mesh->getActor()->GetPosition());
880 d->scalar_color_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
881 d->scalar_color_actor->SetPosition(d->mesh->getActor()->GetPosition());
883 if(d->mesh->getUnstructuredGrid()){
884 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(d->array->GetName());
886 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(d->array->GetName());
890 d->vector_glyph_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
891 d->vector_glyph_actor->SetPosition(d->mesh->getActor()->GetPosition());
892 d->vector_hedgehog_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
893 d->vector_hedgehog_actor->SetPosition(d->mesh->getActor()->GetPosition());
894 d->vector_stream_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
895 d->vector_stream_actor->SetPosition(d->mesh->getActor()->GetPosition());
897 if(d->mesh->getUnstructuredGrid()){
898 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveVectors(d->array->GetName());
900 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(d->array->GetName());
903 if(d->mesh->getUnstructuredGrid()){
904 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveTensors(d->array->GetName());
906 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveTensors(d->array->GetName());
916 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->RemoveArray(d->array->GetName());
917 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(d->array);
919 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(d->array->GetName());
921 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(d->array->GetName());
923 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveTensors(d->array->GetName());
932 if(d->mesh && d->field)
935 if(d->mesh->getUnstructuredGrid()){
936 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
938 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(qPrintable(d->field->objectName()));
941 if(d->mesh->getUnstructuredGrid()){
942 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveVectors(qPrintable(d->field->objectName()));
944 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(qPrintable(d->field->objectName()));
948 if(d->mesh->getUnstructuredGrid()){
949 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveTensors(qPrintable(d->field->objectName()));
951 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveTensors(qPrintable(d->field->objectName()));
957 if(d->mesh && d->field)
960 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveScalars(qPrintable(d->field->objectName()));
962 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(qPrintable(d->field->objectName()));
964 static_cast<vtkPolyData *>(d->mesh->getPolyData())->GetCellData()->SetActiveTensors(qPrintable(d->field->objectName()));
971 return d->scalar_color_mapper;
996 qDebug() << DTK_PRETTY_FUNCTION <<
"No field.";
1010 if(d->scalar_color_mapper && d->scalar_color_actor && d->scalar_iso_color_actor)
1015 if(d->mesh->getPolyData()){
1016 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(d->array->GetName());
1017 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(d->array);
1018 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(d->array->GetName());
1020 if(d->mesh->getUnstructuredGrid()){
1021 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->RemoveArray(d->array->GetName());
1022 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->AddArray(d->array);
1023 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveScalars(d->array->GetName());
1029 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->RemoveArray(d->array->GetName());
1030 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(d->array);
1031 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveScalars(d->array->GetName());
1037 d->scalar_display_as_iso =
false;
1038 d->scalar_iso_count = 10;
1039 d->array->GetRange(d->scalar_iso_range);
1041 d->scalar_iso = vtkSmartPointer<vtkContourFilter>::New();
1042 if(d->mesh->getUnstructuredGrid()){
1043 #if (VTK_MAJOR_VERSION <= 5)
1044 d->scalar_iso->SetInput(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
1046 d->scalar_iso->SetInputData(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
1049 #if (VTK_MAJOR_VERSION <= 5)
1050 d->scalar_iso->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1052 d->scalar_iso->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1055 d->scalar_iso->GenerateValues(d->scalar_iso_count, d->scalar_iso_range[0], d->scalar_iso_range[1]);
1057 d->scalar_iso_tube_filter = vtkSmartPointer<vtkTubeFilter>::New();
1058 d->scalar_iso_tube_filter->SetRadius(d->isoRadius);
1059 d->scalar_iso_tube_filter->SetNumberOfSides(8);
1060 #if (VTK_MAJOR_VERSION <= 5)
1061 d->scalar_iso_tube_filter->SetInput(d->scalar_iso->GetOutput());
1063 d->scalar_iso_tube_filter->SetInputData(d->scalar_iso->GetOutput());
1065 d->scalar_iso_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
1066 #if (VTK_MAJOR_VERSION <= 5)
1067 d->scalar_iso_mapper->SetInput(d->scalar_iso_tube_filter->GetOutput());
1069 d->scalar_iso_mapper->SetInputData(d->scalar_iso_tube_filter->GetOutput());
1072 d->scalar_iso_actor = vtkSmartPointer<vtkActor>::New();
1073 d->scalar_iso_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
1074 d->scalar_iso_actor->SetPosition(d->mesh->getActor()->GetPosition());
1075 d->scalar_iso_actor->SetMapper(d->scalar_iso_mapper);
1076 d->scalar_iso_actor->SetVisibility(0);
1078 this->AddPart(d->scalar_iso_actor);
1082 d->scalar_iso_color_mapper = vtkPolyDataMapper::New();
1083 #if (VTK_MAJOR_VERSION <= 5)
1084 d->scalar_iso_color_mapper->SetInput(d->scalar_iso->GetOutput());
1086 d->scalar_iso_color_mapper->SetInputData(d->scalar_iso->GetOutput());
1088 d->scalar_iso_color_mapper->SetColorModeToMapScalars();
1091 d->scalar_iso_color_mapper->SetScalarModeToUsePointData();
1094 d->scalar_iso_color_mapper->SetScalarModeToUseCellData();
1096 d->scalar_iso_color_mapper->SelectColorArray(d->array->GetName());
1097 d->scalar_iso_color_mapper->SetScalarVisibility(
true);
1098 d->scalar_iso_color_mapper->SetScalarRange(d->scalar_iso_range);
1100 d->scalar_iso_color_actor = vtkSmartPointer<vtkActor>::New();
1101 d->scalar_iso_color_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
1102 d->scalar_iso_color_actor->SetPosition(d->mesh->getActor()->GetPosition());
1103 d->scalar_iso_color_actor->SetMapper(d->scalar_iso_color_mapper);
1104 d->scalar_iso_color_actor->SetVisibility(0);
1106 this->AddPart(d->scalar_iso_color_actor);
1110 d->array->GetRange(d->scalar_color_range);
1112 d->scalar_color_mapper = vtkDataSetMapper::New();
1113 #if (VTK_MAJOR_VERSION <= 5)
1114 if(d->mesh->getUnstructuredGrid())
1115 d->scalar_color_mapper->SetInput(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
1117 d->scalar_color_mapper->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1119 if(d->mesh->getUnstructuredGrid())
1120 d->scalar_color_mapper->SetInputData(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
1122 d->scalar_color_mapper->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1125 d->scalar_color_mapper->SetColorModeToMapScalars();
1128 d->scalar_color_mapper->SetScalarModeToUsePointData();
1131 d->scalar_color_mapper->SetScalarModeToUseCellData();
1133 d->scalar_color_mapper->SelectColorArray(d->array->GetName());
1134 d->scalar_color_mapper->SetScalarVisibility(
true);
1135 d->scalar_color_mapper->SetScalarRange(d->scalar_color_range);
1137 d->scalar_color_actor = vtkSmartPointer<vtkActor>::New();
1138 d->scalar_color_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
1139 d->scalar_color_actor->SetPosition(d->mesh->getActor()->GetPosition());
1140 d->scalar_color_actor->SetMapper(d->scalar_color_mapper);
1141 d->scalar_color_actor->SetVisibility(0);
1143 this->AddPart(d->scalar_color_actor);
1146 d->scalar_bar_actor = vtkSmartPointer<vtkScalarBarActor>::New();
1147 d->scalar_bar_actor ->SetLookupTable(d->scalar_color_mapper->GetLookupTable());
1148 d->scalar_bar_actor ->SetTitle(qPrintable(d->field->name()));
1149 d->scalar_bar_actor ->SetNumberOfLabels(4);
1150 d->scalar_bar_actor->SetVisibility(0);
1165 if(d->mesh->getPolyData()){
1166 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(d->array->GetName());
1167 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->AddArray(d->array);
1168 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->SetActiveVectors(d->array->GetName());
1170 if(d->mesh->getUnstructuredGrid()){
1171 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->RemoveArray(d->array->GetName());
1172 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->AddArray(d->array);
1173 static_cast<vtkUnstructuredGrid *
>(d->mesh->getUnstructuredGrid())->GetPointData()->SetActiveVectors(d->array->GetName());
1178 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetPointData()->RemoveArray(d->array->GetName());
1179 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->AddArray(d->array);
1180 static_cast<vtkPolyData *
>(d->mesh->getPolyData())->GetCellData()->SetActiveVectors(d->array->GetName());
1187 d->vector_hedgehog = vtkSmartPointer<vtkHedgeHog>::New();
1188 #if (VTK_MAJOR_VERSION <= 5)
1189 if(d->mesh->getPolyData())
1190 d->vector_hedgehog->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1192 d->vector_hedgehog->SetInput(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
1194 if(d->mesh->getPolyData())
1195 d->vector_hedgehog->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1197 d->vector_hedgehog->SetInputData(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
1199 d->vector_hedgehog->SetVectorModeToUseVector();
1202 d->vector_hedgehog_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
1203 d->vector_hedgehog_mapper->SetInputConnection(d->vector_hedgehog->GetOutputPort());
1204 d->vector_hedgehog_mapper->ScalarVisibilityOn();
1206 d->vector_hedgehog_actor = vtkSmartPointer<vtkActor>::New();
1207 d->vector_hedgehog_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
1208 d->vector_hedgehog_actor->SetPosition(d->mesh->getActor()->GetPosition());
1209 d->vector_hedgehog_actor->SetMapper(d->vector_hedgehog_mapper);
1210 d->vector_hedgehog_actor->SetVisibility(0);
1212 this->AddPart(d->vector_hedgehog_actor);
1216 d->vector_glyph_source = vtkArrowSource::New();
1218 d->vector_glyph = vtkSmartPointer<vtkGlyph3D>::New();
1219 #if (VTK_MAJOR_VERSION <= 5)
1220 if(d->mesh->getPolyData())
1221 d->vector_glyph->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1223 d->vector_glyph->SetInput(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
1224 d->vector_glyph->SetSource(d->vector_glyph_source->GetOutput());
1226 if(d->mesh->getPolyData())
1227 d->vector_glyph->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1229 d->vector_glyph->SetInputData(static_cast<vtkUnstructuredGrid *>(d->mesh->getUnstructuredGrid()));
1230 d->vector_glyph->SetSourceData(d->vector_glyph_source->GetOutput());
1233 d->vector_glyph->SetColorModeToColorByVector();
1234 d->vector_glyph->SetVectorModeToUseVector();
1236 d->vector_glyph->SetScaleModeToDataScalingOff();
1239 d->vector_glyph->OrientOn();
1240 d->vector_glyph->Update();
1242 d->vector_glyph_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
1243 d->vector_glyph_mapper->SetInputConnection(d->vector_glyph->GetOutputPort());
1254 d->vector_glyph_actor = vtkSmartPointer<vtkActor>::New();
1255 d->vector_glyph_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
1256 d->vector_glyph_actor->SetPosition(d->mesh->getActor()->GetPosition());
1257 d->vector_glyph_actor->SetMapper(d->vector_glyph_mapper);
1259 d->vector_glyph_actor->SetVisibility(0);
1261 this->AddPart(d->vector_glyph_actor);
1266 d->vector_stream_widget = vtkSmartPointer<vtkSphereWidget2>::New();
1267 d->vector_stream_widget->SetInteractor(d->interactor);
1268 d->vector_stream_widget->CreateDefaultRepresentation();
1269 d->vector_stream_widget->SetTranslationEnabled(
true);
1270 d->vector_stream_widget->SetScalingEnabled(
true);
1271 d->vector_stream_widget->Off();
1273 d->vector_stream_widget_data = vtkPolyData::New();
1275 d->vector_stream_widget_representation = vtkSphereRepresentation::SafeDownCast(d->vector_stream_widget->GetRepresentation());
1276 d->vector_stream_widget_representation->HandleVisibilityOff();
1277 d->vector_stream_widget_representation->HandleTextOff();
1278 d->vector_stream_widget_representation->RadialLineOff();
1279 d->vector_stream_widget_representation->SetPhiResolution(64);
1280 d->vector_stream_widget_representation->SetThetaResolution(64);
1281 d->vector_stream_widget_representation->GetPolyData(d->vector_stream_widget_data);
1283 d->vector_stream_tracer = vtkStreamTracer::New();
1284 #if (VTK_MAJOR_VERSION <= 5)
1285 d->vector_stream_tracer->SetInput(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1286 d->vector_stream_tracer->SetSource(d->vector_stream_widget_data);
1288 d->vector_stream_tracer->SetInputData(static_cast<vtkPolyData *>(d->mesh->getPolyData()));
1289 d->vector_stream_tracer->SetSourceData(d->vector_stream_widget_data);
1291 d->vector_stream_tracer->SetMaximumPropagation(100);
1292 d->vector_stream_tracer->SetMinimumIntegrationStep(1.0e-4);
1293 d->vector_stream_tracer->SetMaximumIntegrationStep(100.0);
1294 d->vector_stream_tracer->SetIntegrationDirectionToBoth();
1296 d->vector_stream_filter = vtkTubeFilter::New();
1297 #if (VTK_MAJOR_VERSION <= 5)
1298 d->vector_stream_filter->SetInput(d->vector_stream_tracer->GetOutput());
1300 d->vector_stream_filter->SetInputData(d->vector_stream_tracer->GetOutput());
1302 d->vector_stream_filter->SetRadius(0.01);
1303 d->vector_stream_filter->SetNumberOfSides(8);
1305 d->vector_stream_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
1306 d->vector_stream_mapper->SetInputConnection(d->vector_stream_filter->GetOutputPort());
1307 d->vector_stream_mapper->ScalarVisibilityOn();
1309 d->vector_stream_actor = vtkSmartPointer<vtkActor>::New();
1310 d->vector_stream_actor->SetOrientation(d->mesh->getActor()->GetOrientation());
1311 d->vector_stream_actor->SetPosition(d->mesh->getActor()->GetPosition());
1312 d->vector_stream_actor->SetMapper(d->vector_stream_mapper);
1313 d->vector_stream_actor->SetVisibility(0);
1316 d->vector_stream_observer->vector_stream_widget_representation = d->vector_stream_widget_representation;
1317 d->vector_stream_observer->vector_stream_widget_data = d->vector_stream_widget_data;
1318 d->vector_stream_observer->vector_stream_tracer = d->vector_stream_tracer;
1319 d->vector_stream_widget->AddObserver(vtkCommand::InteractionEvent, d->vector_stream_observer);
1321 this->AddPart(d->vector_stream_actor);
1329 double field_range[2];d->array->GetRange(field_range);
1330 return field_range[0];
1335 double field_range[2];d->array->GetRange(field_range);
1337 return field_range[1];
1342 d->isoRadius = radius;
1343 d->scalar_iso_tube_filter->SetRadius(radius);
1344 d->scalar_iso_tube_filter->Update();
Class axlAbstractFieldParametric defines an API for parametric field.
void setIsoRangeMin(double min)
virtual double start_u(void)
Returns the first u-value parameter.
dtkAbstractData * data(void)
virtual double scalar(double u, double v=0, double w=0)
Returns the value of the parametric field at the parameters values in input.
vtkCxxRevisionMacro(axlActorFieldParametric,"$Revision: 0.0.1 $")
virtual double end_u(void)
Returns the last u-value parameter.
void setActiveFieldKind(void)
virtual double start_u(void)
Returns the first u-value parameter.
void setStreamRadius(double radius)
virtual double * tensor(double u, double v=0, double w=0)
Returns the value of the spatial field at the coordinates point entered.
virtual void Execute(vtkObject *caller, unsigned long event, void *)
void displayAsGlyph(void)
virtual double * tensor(double u, double v, double w)
Returns the value of the spatial field at the coordinates point entered.
virtual double scalar(double u, double v, double w=0)
Returns the value of the parametric field at the parameters values in input.
virtual double numbersample_u(void)
Returns the number of u-parameters.
void * scalarColorMapper(void)
Class axlAbstractFieldParametricCurve defines an API for parametric field.
virtual double numbersample_v(void)
Returns the number of v-parameters.
virtual double start_v(void)
Returns the first v-value parameter.
virtual double end_w(void)
Returns the last w-value parameter.
virtual double start_v(void)
Returns the first v-value parameter.
vtkSmartPointer< vtkStreamTracer > vector_stream_tracer
virtual double numbersample_v(void)
Returns the number of v-parameters.
void setActorField(axlAbstractActor *actor)
virtual double * vector(double u, double v, double w)
Returns the value of the parametric field evaluated at the parameters in input.
virtual double numbersample_u(void)
Returns the number of u-parameters.
void setInteractor(void *interactor)
virtual double * tensor(double u, double v, double w=0)
Returns the value of the spatial field at the coordinates point entered.
axlAbstractActor * outputActor(void)
void onIsoRadiusChanged(double radius)
axlAbstractField * magnitude(void)
virtual double end_v(void)
Returns the last v-value parameter.
void setIsoRangeMax(double max)
virtual double end_u(void)
Returns the last v-value parameter.
vtkSmartPointer< vtkSphereRepresentation > vector_stream_widget_representation
axlAbstractActor * actorField(void)
virtual double * vector(double u, double v, double w=0)
Returns the value of the parametric field evaluated at the parameters in input.
void displayAsColor(void)
virtual double end_u(void)
Returns the last v-value parameter.
vtkScalarBarActor * scalarBar(void)
void setColRangeMax(double max)
vtkSmartPointer< vtkPolyData > vector_stream_widget_data
Class axlAbstractField defines an API for arrays of numeric data.
virtual double end_v(void)
Returns the last v-value parameter.
void setStreamPropagation(double propagation)
Class axlFieldDiscrete defines an API for arrays of numeric data.
virtual double numbersample_w(void)
Returns the number of w-parameters.
Class axlAbstractFieldParametricVolume defines an API for parametric field.
void displayAsNoneScalar(void)
virtual double start_u(void)
Returns the first u-value parameter.
void setColRangeMin(double min)
void setStreamDirection(int direction)
static axlActorFieldParametricStreamObserver * New(void)
axlAbstractField * field(void)
void displayAsHedge(void)
Class axlAbstractFieldParametricSurface defines an API for parametric field.
virtual void setData(dtkAbstractData *field)
~axlActorFieldParametric(void)
void displayAsStream(void)
axlActorFieldParametric(void)
void setGlyphScale(double scale)
virtual double start_w(void)
Returns the first w-value parameter.
Class axlAbstractData defines an API for all type of axel data.
void displayAsNoneVector(void)
void setIsoCount(int count)
virtual double numbersample_u(void)
Returns the number of u-parameters.
double streamRadius(void)
virtual double scalar(double u, double v, double w)
Returns the value of the parametric field at the parameters values in input.
virtual double * vector(double u, double v=0, double w=0)
Returns the value of the parametric field evaluated at the parameters in input.
vtkStandardNewMacro(axlActorFieldParametric)