X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaVtk%2FvtkVectorsTensorsVisuBase.cpp;h=c591a5f9beceaf7413a0cab2d0f1242756f1865d;hb=05400a294e401b74b2e7a3058f6a4ee3decfc62d;hp=405d741b32294ff3a936cb7bcc29967d591e31ed;hpb=08174c39ec53c37ea8ea7d6c97cf9f7af13659da;p=creaVtk.git diff --git a/lib/creaVtk/vtkVectorsTensorsVisuBase.cpp b/lib/creaVtk/vtkVectorsTensorsVisuBase.cpp index 405d741..c591a5f 100644 --- a/lib/creaVtk/vtkVectorsTensorsVisuBase.cpp +++ b/lib/creaVtk/vtkVectorsTensorsVisuBase.cpp @@ -26,13 +26,8 @@ */ #include "vtkVectorsTensorsVisuBase.h" - - #include "vtkObjectFactory.h" - - - vtkStandardNewMacro(vtkLookupTableDirectionVector); // Construct with range=(0,1); and hsv ranges set up for rainbow color table @@ -48,14 +43,11 @@ vtkLookupTableDirectionVector::~vtkLookupTableDirectionVector() { } - - unsigned char *vtkLookupTableDirectionVector::MapValue(double v) { //int idx = this->GetIndex(v); - //return (this->Table->GetPointer(0) + 4*idx); - + //return (this->Table->GetPointer(0) + 4*idx); return 0; } @@ -113,43 +105,27 @@ void vtkLookupTableMapDirVectorEED(vtkLookupTableDirectionVector *self, T *input int inIncr, int outFormat) { double tmp,sum; -// double *mag; int i, j; double dirx,diry,dirz; - - - printf("EED length %d %p\n", length,input); -// mag = new double[length]; + double angle; for (i = 0; i < length; ++i) { - dirx = 0; - diry = 0; - dirz = 0; - sum = 0; - for (j = 0; j < inIncr; ++j) - { - if (j==0) dirx= static_cast(*input); - if (j==1) diry= static_cast(*input); - if (j==2) dirz= static_cast(*input); - tmp = static_cast(*input); - sum += (tmp * tmp); - ++input; - } - sum=sqrt(sum); - *output++ = (unsigned char) abs( (255*dirx/sum) ); - *output++ = (unsigned char) abs( (255*diry/sum) ); - *output++ = (unsigned char) abs( (255*dirz/sum) ); - *output++ = 255; -// printf("%d %d %d ",(int)(255*dirx/sum),(int)(255*diry/sum),(int)(255*dirz/sum)); - } - -// vtkLookupTableMapData(self, mag, output, length, 1, outFormat); - -// delete [] mag; + dirx = static_cast(input[0]); + diry = static_cast(input[1]); + dirz = static_cast(input[2]); + input = input+inIncr; + sum = sqrt( dirx*dirx + diry*diry + dirz*dirz ); + *output++ = (unsigned char) abs( (255*dirx/sum) ); + *output++ = (unsigned char) abs( (255*diry/sum) ); + *output++ = (unsigned char) abs( (255*dirz/sum) ); + *output++ = 255; + // printf("%d %d %d ",(int)(255*dirx/sum),(int)(255*diry/sum),(int)(255*dirz/sum)); + // printf(" C %d %f %f %f \n",inIncr,dirx,diry,dirz); + + } // for } - //---------------------------------------------------------------------------- void vtkLookupTableDirectionVector::MapScalarsThroughTable2(void *input, unsigned char *output, @@ -158,7 +134,6 @@ void vtkLookupTableDirectionVector::MapScalarsThroughTable2(void *input, int inputIncrement, int outputFormat) { - printf("vtkLookupTableEED::MapScalarsThroughTable2 inputIncrement=%d inputDataType=%d\n",inputIncrement,inputDataType); // if (this->UseMagnitude && inputIncrement > 1) // { switch (inputDataType) @@ -192,34 +167,27 @@ void vtkLookupTableDirectionVector::PrintSelf(ostream& os, vtkIndent indent) //---------------------------------- //---------------------------------- - - - - - - - vtkVectorsTensorsVisuBase::vtkVectorsTensorsVisuBase() { - _firsttime = true; - _active = false; + _firsttime = true; + _active = false; _scalefactor = 1; - _opacity = 1; - _dataobject = NULL; - _renderer = NULL; - _typeForm = 0; - - _LutEED = vtkLookupTableDirectionVector::New(); -// _LutEED->SetVectorMode(0); -//_LutEED->SetVectorModeToMagnitude(); -//_LutEED->SetVectorModeToComponent(); -_LutEED->SetVectorModeToRGBColors(); - - - - _pdm = vtkPolyDataMapper::New(); - _actor = vtkActor::New(); - _actorAdded = false; + _opacity = 1; + _dataobject = NULL; + _renderer = NULL; + _typeForm = 0; + _orientation = 0; + + _LutEED = vtkLookupTableDirectionVector::New(); + _externalLut = NULL; + //_LutEED->SetVectorMode(0); + //_LutEED->SetVectorModeToMagnitude(); + //_LutEED->SetVectorModeToComponent(); + _LutEED->SetVectorModeToRGBColors(); + + _pdm = vtkPolyDataMapper::New(); + _actor = vtkActor::New(); + _actorAdded = false; } vtkVectorsTensorsVisuBase::~vtkVectorsTensorsVisuBase() @@ -312,8 +280,6 @@ void vtkVectorsTensorsVisuBase::Process() // virtual { } - - //------------------------------------------------------------------------------ void vtkVectorsTensorsVisuBase::VisibilityActor() { @@ -321,20 +287,56 @@ void vtkVectorsTensorsVisuBase::VisibilityActor() if ( (_active==true) && (_actorAdded==false) ){ if (GetRenderer()!=NULL) { - GetRenderer()->AddActor(_actor); + GetRenderer()->AddActor(_actor); _actorAdded=true; - } // if Renderer + } // if Renderer } // if _active==true if ( (_active==false) && (_actorAdded==true) ){ if (GetRenderer()!=NULL) { - GetRenderer()->RemoveActor(_actor); + GetRenderer()->RemoveActor(_actor); _actorAdded=false; - } // if Renderer + } // if Renderer } // if _active==false } +//------------------------------------------------------------------------------ +void vtkVectorsTensorsVisuBase::SetColorLaw(int colorlaw) +{ + _colorlaw = colorlaw; +} + +//------------------------------------------------------------------------------ +void vtkVectorsTensorsVisuBase::SetColor(std::vector rgb) +{ + if (rgb.size()==3) + { + _colorR=rgb[0]; + _colorG=rgb[1]; + _colorB=rgb[2]; + } else { + _colorR=1; + _colorG=1; + _colorB=1; + } +} + +//------------------------------------------------------------------------------ +void vtkVectorsTensorsVisuBase::SetOrientation(int orientation) +{ + _orientation = orientation; +} +//------------------------------------------------------------------------------ +int vtkVectorsTensorsVisuBase::GetOrientation() +{ + return _orientation; +} +//------------------------------------------------------------------------------ +void vtkVectorsTensorsVisuBase::SetExternalLut(vtkScalarsToColors* lut) +{ + _externalLut=lut; +}