X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaVtk%2FvtkVectorsVisu.cpp;h=51392f7300698a6dac591902cc216c62060a409c;hb=refs%2Fheads%2Fvtk9itk5wx3-macos;hp=ff49f557748d752cff0bd8be9224cdc5d392be26;hpb=0a78cc1bbbd1875930b8e9b74053f947e33691ef;p=creaVtk.git diff --git a/lib/creaVtk/vtkVectorsVisu.cpp b/lib/creaVtk/vtkVectorsVisu.cpp index ff49f55..51392f7 100644 --- a/lib/creaVtk/vtkVectorsVisu.cpp +++ b/lib/creaVtk/vtkVectorsVisu.cpp @@ -31,27 +31,66 @@ //Borrame #include "vtkPointData.h" +#include "vtkArrayData.h" +#include "vtkDataObject.h" +#include +#include //------------------------------------------------------------------------------ vtkVectorsVisu::vtkVectorsVisu() :vtkVectorsTensorsVisuBase() { - _vtkarrowsource = vtkArrowSource::New(); - _vtkglyph = NULL; - _vtklinesource = vtkLineSource ::New(); - _trans = vtkTransform ::New(); + _vtkarrowsource = vtkArrowSource::New(); + _vtkglyph = NULL; + _vtklineGlyphPolyData = NULL; + _trans = vtkTransform ::New(); + double sizeCross = 0.05; + double point1[3]; double point2[3]; - point1[0]=1; - point1[1]=0; - point1[2]=0; - point2[0]=-1; - point2[1]=0; - point2[2]=0; - _vtklinesource->SetPoint1( point1 ); - _vtklinesource->SetPoint2( point2 ); + + point1[0] = 1; + point1[1] = 0; + point1[2] = 0; + point2[0] = -1; + point2[1] = 0; + point2[2] = 0; + vtkLineSource *vtklinesource1 = vtkLineSource ::New(); + vtklinesource1->SetPoint1( point1 ); + vtklinesource1->SetPoint2( point2 ); + vtklinesource1->Update(); + + point1[0] = 0; + point1[1] = sizeCross; + point1[2] = 0; + point2[0] = 0; + point2[1] = -sizeCross; + point2[2] = 0; + vtkLineSource *vtklinesource2 = vtkLineSource ::New(); + vtklinesource2->SetPoint1( point1 ); + vtklinesource2->SetPoint2( point2 ); + vtklinesource2->Update(); + + point1[0] = 0; + point1[1] = 0; + point1[2] = sizeCross; + point2[0] = 0; + point2[1] = 0; + point2[2] = -sizeCross; + vtkLineSource *vtklinesource3 = vtkLineSource ::New(); + vtklinesource3->SetPoint1( point1 ); + vtklinesource3->SetPoint2( point2 ); + vtklinesource3->Update(); + + + vtkAppendPolyData *appendPolyData = vtkAppendPolyData::New(); + appendPolyData->AddInputData( vtklinesource1->GetOutput() ); + appendPolyData->AddInputData( vtklinesource2->GetOutput() ); + appendPolyData->AddInputData( vtklinesource3->GetOutput() ); + appendPolyData->Update(); + _vtklineGlyphPolyData = appendPolyData->GetOutput(); } //------------------------------------------------------------------------------ @@ -63,70 +102,176 @@ vtkVectorsVisu::~vtkVectorsVisu() //------------------------------------------------------------------------------ void vtkVectorsVisu::Process() { + if (_vtkglyph==NULL) + { + if (GetOrientation()==-1) + { + _vtkglyph = vtkGlyph3D::New(); + } // _orientation + if ((GetOrientation()>=0) && (GetOrientation()<=2)) + { + _vtkglyph = vtkGlyph3D::New(); +// _vtkglyph = vtkGlyph2D::New(); + } // _orientation + } // _vtkglyph NULL + + if(_active==true) { - if (_vtkglyph==NULL) + + if (GetDataObject()!=NULL) { - if (GetOrientation()==-1) + #if VTK_MAJOR_VERSION <= 5 + _vtkglyph->SetInput( GetDataObject() ); + #else + _vtkglyph->SetInputData( GetDataObject() ); + #endif + if(GetTypeForm()==1) // source Arrow + { + #if VTK_MAJOR_VERSION <= 5 + _vtkglyph->SetSource( _vtkarrowsource->GetOutput() ); + #else + _vtkarrowsource->Update(); + _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() ); + #endif + } else { // source Line + #if VTK_MAJOR_VERSION <= 5 + _vtkglyph->SetSource( _vtklineGlyphPolyData ); + #else + _vtkglyph->SetSourceData( _vtklineGlyphPolyData ); + #endif + } + _vtkglyph->SetScaleModeToScaleByVector(); + + + if (_externalLut==NULL) { - _vtkglyph = vtkGlyph3D::New(); - } // _orientation - if ((GetOrientation()>=0) && (GetOrientation()<=2)) + _vtkglyph->SetColorModeToColorByVector(); + } else { + _vtkglyph->SetColorModeToColorByScalar(); + } // if _externalLut + + _vtkglyph->SetScaleFactor( GetScaleFactor() ); + _vtkglyph->Update(); + + #if VTK_MAJOR_VERSION <= 5 + _pdm->SetInput( _vtkglyph->GetOutput()); + #else + _pdm->SetInputData( _vtkglyph->GetOutput()); + #endif + + vtkPointData *data = _vtkglyph->GetOutput()->GetPointData(); + //printf("EED -------------------------------------------\n"); + //_vtkglyph->GetOutput()->Print(std::cout); + //printf("EED -------------------------------------------\n"); + //data->Print(std::cout); + //int i,sizeDa = data->GetNumberOfArrays(); + //for (i=0;iGetArray(i)->Print(std::cout); + //} + + if (_externalLut==NULL) { - _vtkglyph = vtkGlyph2D::New(); - } // _orientation - } // _vtkglyph NULL + _pdm->ScalarVisibilityOn(); + _pdm->SetColorModeToMapScalars(); + // _pdm->SetColorModeToDefault(); + // _pdm->SetColorModeToDirectScalars(); // NOT compile + _pdm->SetScalarModeToUsePointFieldData(); + // _pdm->ImmediateModeRenderingOn(); // obsolete + _LutEED->SetVectorModeToComponent(); + //_LutEED->SetVectorModeToRGBColors(); + //_LutEED->SetVectorModeToMagnitud(); + // _pdm->SetScalarModeToUsePointFieldData(); + _pdm->SetLookupTable( _LutEED ); + _pdm->SelectColorArray( "GlyphVector" ); + } else { + data->SetActiveScalars("angle"); + _pdm->ScalarVisibilityOn(); + double scalarRange[2]; + scalarRange[0]=0; + scalarRange[1]=40; + printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n"); + printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n"); + printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n"); + printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n"); + printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n"); + _pdm->SetScalarRange(scalarRange); + _pdm->SetColorModeToMapScalars(); + // _pdm->SetColorModeToDefault(); + // _pdm->SetColorModeToDirectScalars(); // NOT compile + // _pdm->SetScalarModeToUsePointFieldData(); +// _pdm->ImmediateModeRenderingOn(); // obsolete + _pdm->SetLookupTable( _externalLut ); + _pdm->SelectColorArray( "angle" ); + } // if _externalLut -#if VTK_MAJOR_VERSION <= 5 - _vtkglyph->SetInput( GetDataObject() ); -#else - _vtkglyph->SetInputData( GetDataObject() ); -#endif - if(GetTypeForm()==1) // source Arrow + printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n"); + printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n"); + printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n"); + printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n"); + printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n"); + + /* + _vtkglyph->Update(); + vtkPointData *pointdata=_vtkglyph->GetOutput()->GetPointData(); + int i,size=pointdata->GetNumberOfArrays(); + for (i=0;iGetArray(i); + printf(" vtkVectorsVisu::Process array name %d:<%s> size:%d\n", i, array->GetName(), array->GetSize() ); + } + */ + + + // vSliceMapperVec->SetLookupTable( vGreenToRedLut ); + // vSliceMapperVec->SetColorModeToMapScalars(); + + #if VTK_MAJOR_VERSION <= 5 + // .. + #else + _pdm->Update(); + #endif + + // Orientation -1 3D OK + + // Orientation 0 2D yz + if (GetOrientation()==0) { -#if VTK_MAJOR_VERSION <= 5 - _vtkglyph->SetSource( _vtkarrowsource->GetOutput() ); -#else - _vtkarrowsource->Update(); - _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() ); -#endif - } else { // source Line -#if VTK_MAJOR_VERSION <= 5 - _vtkglyph->SetSource( _vtklinesource->GetOutput() ); -#else - _vtklinesource->Update(); - _vtkglyph->SetSourceData( _vtklinesource->GetOutput() ); -#endif + _trans->Identity(); + _trans->Translate(900,0,0); + _actor->SetUserTransform(_trans); + } + // Orientation 1 2D xz + if (GetOrientation()==1) + { + _trans->Identity(); + _trans->Translate(0,-900,0); + _actor->SetUserTransform(_trans); + } + // Orientation 2 2D xy + if (GetOrientation()==2) + { + _trans->Identity(); + _trans->Translate(0,0,-900); + _actor->SetUserTransform(_trans); } - _vtkglyph->SetScaleModeToScaleByVector(); - _vtkglyph->SetColorModeToColorByVector(); - _vtkglyph->SetScaleFactor( GetScaleFactor() ); - _vtkglyph->Update(); - -#if VTK_MAJOR_VERSION <= 5 - _pdm->SetInput( _vtkglyph->GetOutput()); -#else - _pdm->SetInputData( _vtkglyph->GetOutput()); -#endif -vtkPointData *data = _vtkglyph->GetOutput()->GetPointData(); -//printf("EED -------------------------------------------\n"); -//_vtkglyph->GetOutput()->Print(std::cout); -//printf("EED -------------------------------------------\n"); -//data->Print(std::cout); -//int i,sizeDa = data->GetNumberOfArrays(); -//for (i=0;iGetArray(i)->Print(std::cout); -//} + _actor->SetMapper( _pdm ); + _actor->GetProperty()->SetOpacity( GetOpacity() ); + } else { + printf("EED Warnning! vtkVectorsVisu::Process GetDataObject() is EMPTY\n"); + }// if GetDataObject()!=NULL _pdm->ScalarVisibilityOn(); _pdm->SetColorModeToMapScalars(); //_pdm->SetColorModeToDefault(); // _pdm->SetColorModeToDirectScalars(); // NOT compile _pdm->SetScalarModeToUsePointFieldData(); - _pdm->ImmediateModeRenderingOn(); + +//EED2021-09-03 Deprecated. Removed in vtk 8.1 +// _pdm->ImmediateModeRenderingOn(); _LutEED->SetVectorModeToComponent(); //_LutEED->SetVectorModeToRGBColors(); @@ -144,30 +289,12 @@ vtkPointData *data = _vtkglyph->GetOutput()->GetPointData(); #else _pdm->Update(); #endif - - // Orientation -1 3D OK - // Orientation 2 2D xy OK - - // Orientation 0 2D yz - if (GetOrientation()==0) - { - _trans->Identity(); - _trans->Translate(900,0,0); - _trans->RotateWXYZ(-90,0,1,0); - _actor->SetUserTransform(_trans); - } - - // Orientation 1 2D xz - if (GetOrientation()==1) - { - _trans->Identity(); - _trans->RotateWXYZ(90,1,0,0); - _actor->SetUserTransform(_trans); - } - _actor->SetMapper( _pdm ); _actor->GetProperty()->SetOpacity( GetOpacity() ); - }// if _active + } else { + _vtkglyph->SetInputData( NULL ); + _vtkglyph->Update(); + }// if _active VisibilityActor(); }