/* # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la Sante) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ #include "vtkVectorsVisu.h" #include "vtkProperty.h" //Borrame #include "vtkPointData.h" #include "vtkArrayData.h" #include "vtkDataObject.h" #include #include //------------------------------------------------------------------------------ vtkVectorsVisu::vtkVectorsVisu() :vtkVectorsTensorsVisuBase() { _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 *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(); } //------------------------------------------------------------------------------ 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 (GetDataObject()!=NULL) { #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->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) { _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 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) { _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); } _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(); //EED2021-09-03 Deprecated. Removed in vtk 8.1 // _pdm->ImmediateModeRenderingOn(); _LutEED->SetVectorModeToComponent(); //_LutEED->SetVectorModeToRGBColors(); //_LutEED->SetVectorModeToMagnitud(); // _pdm->SetScalarModeToUsePointFieldData(); _pdm->SetLookupTable( _LutEED ); _pdm->SelectColorArray( "GlyphVector" ); // vSliceMapperVec->SetLookupTable( vGreenToRedLut ); // vSliceMapperVec->SetColorModeToMapScalars(); #if VTK_MAJOR_VERSION <= 5 // .. #else _pdm->Update(); #endif _actor->SetMapper( _pdm ); _actor->GetProperty()->SetOpacity( GetOpacity() ); } else { _vtkglyph->SetInputData( NULL ); _vtkglyph->Update(); }// if _active VisibilityActor(); }