X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcreaVtk%2FvtkVectorsVisu.cpp;h=2b4128d9cb3491d86d29b000fd1adc1e838327b6;hb=6c621b712c4f3ba585d24a2ce98ddc52abb19cb9;hp=43df474428cfa2e3e5c0701424a4b178ad4da08d;hpb=41a74698bb0203749248628baa1503144e1f12f7;p=creaVtk.git diff --git a/lib/creaVtk/vtkVectorsVisu.cpp b/lib/creaVtk/vtkVectorsVisu.cpp index 43df474..2b4128d 100644 --- a/lib/creaVtk/vtkVectorsVisu.cpp +++ b/lib/creaVtk/vtkVectorsVisu.cpp @@ -29,74 +29,154 @@ #include "vtkProperty.h" +//Borrame +#include "vtkPointData.h" + + //------------------------------------------------------------------------------ vtkVectorsVisu::vtkVectorsVisu() :vtkVectorsTensorsVisuBase() { - _vtkarrowsource = vtkArrowSource::New(); - _vtkglyph = vtkGlyph3D::New(); + _vtkarrowsource = vtkArrowSource::New(); + _vtkglyph = NULL; + _vtklinesource = vtkLineSource ::New(); + _trans = vtkTransform ::New(); + + 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 ); } - //------------------------------------------------------------------------------ vtkVectorsVisu::~vtkVectorsVisu() { } + //------------------------------------------------------------------------------ void vtkVectorsVisu::Process() { -printf("EED vtkVectorsVisu::Process() start\n"); if(_active==true) { -printf("EED vtkVectorsVisu::Process() 1\n"); + 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 VTK_MAJOR_VERSION <= 5 _vtkglyph->SetInput( GetDataObject() ); -printf("EED vtkVectorsVisu::Process() 2\n"); - _vtkglyph->SetSource( _vtkarrowsource->GetOutput() ); -printf("EED vtkVectorsVisu::Process() 3\n"); +#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( _vtklinesource->GetOutput() ); +#else + _vtklinesource->Update(); + _vtkglyph->SetSourceData( _vtklinesource->GetOutput() ); +#endif + } _vtkglyph->SetScaleModeToScaleByVector(); _vtkglyph->SetColorModeToColorByVector(); _vtkglyph->SetScaleFactor( GetScaleFactor() ); -printf("EED vtkVectorsVisu::Process() 4\n"); - _vtkglyph->Update(); -printf("EED vtkVectorsVisu::Process() 5\n"); + _vtkglyph->Update(); +#if VTK_MAJOR_VERSION <= 5 _pdm->SetInput( _vtkglyph->GetOutput()); -printf("EED vtkVectorsVisu::Process() 5.1\n"); -//EED _pdm->SetScalarRange( range ); -//EED vtkPolyData *pd = vGlyphFlowPlane->GetOutput(); -//EED vtkPointData *pointdata = pd->GetPointData(); -//EED vtkDataArray *da = pointdata->GetVectors(); -//EED vtkDataArray *nda = vtkFloatArray::New(); -//EED nda->DeepCopy(da); -// pointdata->RemoveArray( "GlyphVector" ); -// bbGetInputIn()->GetPointData()->RemoveArray( "GlyphVector" ); -//EED pointdata->AddArray( nda ); -//EED bbGetInputIn()->GetPointData()->AddArray( nda ); -//EED2 _pdm->ScalarVisibilityOn(); -printf("EED vtkVectorsVisu::Process() 6\n"); - _pdm->SetScalarModeToUsePointFieldData(); - +#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); +//} + + _pdm->ScalarVisibilityOn(); + _pdm->SetColorModeToMapScalars(); + //_pdm->SetColorModeToDefault(); + // _pdm->SetColorModeToDirectScalars(); // NOT compile + _pdm->SetScalarModeToUsePointFieldData(); + _pdm->ImmediateModeRenderingOn(); + + _LutEED->SetVectorModeToComponent(); + //_LutEED->SetVectorModeToRGBColors(); + //_LutEED->SetVectorModeToMagnitud(); + +// _pdm->SetScalarModeToUsePointFieldData(); _pdm->SetLookupTable( _LutEED ); -printf("EED vtkVectorsVisu::Process() 7\n"); _pdm->SelectColorArray( "GlyphVector" ); // 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 ); -printf("EED vtkVectorsVisu::Process() 8\n"); _actor->GetProperty()->SetOpacity( GetOpacity() ); -printf ("EED vtkVectorsVisu::Process opacity:%f\n",GetOpacity() ); }// if _active -printf("EED vtkVectorsVisu::Process() 9\n"); VisibilityActor(); -printf("EED vtkVectorsVisu::Process() end\n"); } - - - - -