From: Eduardo DAVILA Date: Thu, 3 Jan 2019 15:58:29 +0000 (+0100) Subject: VectorField 2D view X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=7b056a20a4768265dac820ba75338779e04c787d;p=creaVtk.git VectorField 2D view --- diff --git a/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Interface.bbg b/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Interface.bbg index 09bd8d8..c60a0dd 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Interface.bbg +++ b/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Interface.bbg @@ -49,7 +49,7 @@ BOX wx:Slider:Box01 ISEXEC:FALSE -2.231532:70.499689:-900.000000 -49.168468:60.499689:-900.000000 +29.343468:60.499689:-900.000000 PORT In:"100" PORT @@ -83,7 +83,7 @@ BOX wx:LayoutTab:Box04 ISEXEC:FALSE -83.037560:-20.291032:-900.000000 --25.477560:-30.291032:-900.000000 +-46.787560:-30.291032:-900.000000 FIN_BOX BOX std:MultipleInputs:Box05 @@ -97,7 +97,7 @@ BOX wx:Slider:Box06 ISEXEC:FALSE 76.333366:74.957602:-900.000000 -127.733366:64.957602:-900.000000 +107.908366:64.957602:-900.000000 PORT ChangeResolution:"true" PORT @@ -128,6 +128,8 @@ ISEXEC:FALSE -30.731216:78.085161:-900.000000 PORT In:"Line Arrow" +PORT +WinHeight:"50" FIN_BOX BOX wx:LayoutLine:Box09 diff --git a/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Interface.bbs b/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Interface.bbs index 02f5c8f..67df3f7 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Interface.bbs +++ b/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Interface.bbs @@ -51,6 +51,7 @@ new std:Div Box07 new wx:ComboBox Box08 set Box08.In "Line Arrow" + set Box08.WinHeight "50" new wx:LayoutLine Box09 set Box09.Orientation "H" diff --git a/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Widget.bbg b/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Widget.bbg index d47a5f1..b24dc42 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Widget.bbg +++ b/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Widget.bbg @@ -19,18 +19,22 @@ COMPLEX_PORT BoxChange -148.185967:-105.619763:-900.000000 FIN_COMPLEX_PORT -COMPLEXINPUTS:3 +COMPLEXINPUTS:4 COMPLEX_PORT renderer --116.813076:40.976013:-900.000000 +-115.777988:44.672757:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT vtkDataObject --138.011324:45.349330:-900.000000 +-139.194282:43.574893:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT boxExecute --196.920121:41.238358:-900.000000 +-196.920121:43.900014:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +orientation +-95.893542:43.917320:-900.000000 FIN_COMPLEX_PORT BOXES:3 BOX @@ -57,7 +61,7 @@ ISEXEC:FALSE PORT BoxProcessMode:"Reactive" FIN_BOX -CONNECTIONS:11 +CONNECTIONS:12 CONNECTION Box05:Opacity:Box03:Opacity NumberOfControlPoints:0 @@ -91,4 +95,7 @@ NumberOfControlPoints:0 CONNECTION Box05:Type:Box03:TypeForm NumberOfControlPoints:0 +CONNECTION +orientation:orientation:Box03:Orientation +NumberOfControlPoints:0 APP_END diff --git a/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Widget.bbs b/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Widget.bbs index cddcb38..032aaad 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Widget.bbs +++ b/bbtk_creaVtk_PKG/bbs/boxes/VectorsVisu_Widget.bbs @@ -36,6 +36,7 @@ connect Box05.Type Box03.TypeForm input renderer Box03.Renderer " " input vtkDataObject Box03.In " " input boxExecute Box07.In1 " " +input orientation Box03.Orientation " " # Complex output ports output BoxChange Box03.BoxChange " " diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx index 062e8e7..783fe64 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx @@ -32,6 +32,7 @@ void VectorsVisu::Process() vectorsvisu.SetOpacity( bbGetInputOpacity() ); vectorsvisu.SetRenderer( bbGetInputRenderer() ); vectorsvisu.SetTypeForm( bbGetInputTypeForm() ); + vectorsvisu.SetOrientation( bbGetInputOrientation() ); vectorsvisu.Process(); bbSetOutputOut( vectorsvisu.GetProp3D() ); @@ -51,6 +52,7 @@ void VectorsVisu::bbUserSetDefaultValues() bbSetInputScaleFactor(500); bbSetInputOpacity(1); bbSetInputTypeForm(0); + bbSetInputOrientation(0); } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.h b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.h index 27ad79c..7c8c52c 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.h @@ -29,6 +29,7 @@ class bbcreaVtk_EXPORT VectorsVisu BBTK_DECLARE_INPUT(ScaleFactor,double); BBTK_DECLARE_INPUT(Opacity,double); BBTK_DECLARE_INPUT(TypeForm,int); + BBTK_DECLARE_INPUT(Orientation,int); BBTK_DECLARE_OUTPUT(Out,vtkProp3D*); BBTK_PROCESS(Process); void Process(); @@ -52,6 +53,7 @@ BBTK_CATEGORY("empty"); BBTK_INPUT(VectorsVisu,Opacity,"Opacity (1 default)",double,""); BBTK_INPUT(VectorsVisu,Renderer,"vtkRenderer",vtkRenderer*,""); BBTK_INPUT(VectorsVisu,TypeForm,"0 Line, 1 Arrow (default 0)",int,""); + BBTK_INPUT(VectorsVisu,Orientation,"(default 0) 0=3D, 1=xy, 2=yz, 3=xz",int,""); BBTK_OUTPUT(VectorsVisu,Out,"vtkProp3D of an vtkActor",vtkProp3D*,""); BBTK_END_DESCRIBE_BLACK_BOX(VectorsVisu); //===== diff --git a/lib/creaVtk/vtkImageDataStrucPoints.cpp b/lib/creaVtk/vtkImageDataStrucPoints.cpp index 1299cdc..b06c5f2 100644 --- a/lib/creaVtk/vtkImageDataStrucPoints.cpp +++ b/lib/creaVtk/vtkImageDataStrucPoints.cpp @@ -52,8 +52,6 @@ void vtkImageDataStrucPoints::joinComponents(vtkImageData* imageX, vtkImageData* dim[0]=ext[1]-ext[0]+1; dim[1]=ext[3]-ext[2]+1; dim[2]=ext[5]-ext[4]+1; - std::cout<<"dim "<< dim[0] <<" "<< dim[1] <<" "<< dim[2] <GetSpacing(spc); @@ -75,7 +73,6 @@ void vtkImageDataStrucPoints::joinComponents(vtkImageData* imageX, vtkImageData* int i; -printf("EED vtkImageDataStrucPoints::joinComponents sizeimage %d\n", sizeimage ); for( i = 0 ; i < sizeimage ; i++ ) { vx = *ptrX; diff --git a/lib/creaVtk/vtkTensorsVisu.cpp b/lib/creaVtk/vtkTensorsVisu.cpp index 9a53519..c079422 100644 --- a/lib/creaVtk/vtkTensorsVisu.cpp +++ b/lib/creaVtk/vtkTensorsVisu.cpp @@ -37,7 +37,9 @@ vtkTensorsVisu::vtkTensorsVisu() : vtkVectorsTensorsVisuBase() ss = vtkSphereSource::New(); superquadratic = vtkSuperquadricSource::New(); cs = vtkCubeSource::New(); - tg = vtkTensorGlyph::New(); + + tg = NULL; + pdn = vtkPolyDataNormals::New(); pd = vtkPolyData::New(); pod = vtkPointData::New(); @@ -56,6 +58,8 @@ void vtkTensorsVisu::Process() { if(GetTypeForm()==2) // source superquadratic { + if (tg==NULL) { tg = vtkTensorGlyph::New(); } + superquadratic->SetThetaResolution(20); superquadratic->SetPhiResolution(20); #if VTK_MAJOR_VERSION <= 5 diff --git a/lib/creaVtk/vtkVectorsTensorsVisuBase.cpp b/lib/creaVtk/vtkVectorsTensorsVisuBase.cpp index 3d7c20b..8da1d1a 100644 --- a/lib/creaVtk/vtkVectorsTensorsVisuBase.cpp +++ b/lib/creaVtk/vtkVectorsTensorsVisuBase.cpp @@ -111,7 +111,7 @@ void vtkLookupTableMapDirVectorEED(vtkLookupTableDirectionVector *self, T *input inIncr=3; - printf("EED length %d %p\n", length,input); +// printf("EED length %d %p\n", length,input); // mag = new double[length]; for (i = 0; i < length; ++i) { @@ -151,7 +151,7 @@ void vtkLookupTableDirectionVector::MapScalarsThroughTable2(void *input, int inputIncrement, int outputFormat) { - printf("vtkLookupTableEED::MapScalarsThroughTable2 inputIncrement=%d inputDataType=%d\n",inputIncrement,inputDataType); +// printf("vtkLookupTableEED::MapScalarsThroughTable2 inputIncrement=%d inputDataType=%d\n",inputIncrement,inputDataType); // if (this->UseMagnitude && inputIncrement > 1) // { switch (inputDataType) @@ -194,6 +194,7 @@ vtkVectorsTensorsVisuBase::vtkVectorsTensorsVisuBase() _dataobject = NULL; _renderer = NULL; _typeForm = 0; + _orientation = 0; _LutEED = vtkLookupTableDirectionVector::New(); //_LutEED->SetVectorMode(0); @@ -338,4 +339,16 @@ void vtkVectorsTensorsVisuBase::SetColor(std::vector rgb) } } +//------------------------------------------------------------------------------ +void vtkVectorsTensorsVisuBase::SetOrientation(int orientation) +{ + _orientation = orientation; +} + +//------------------------------------------------------------------------------ +int vtkVectorsTensorsVisuBase::GetOrientation() +{ + return _orientation; +} + diff --git a/lib/creaVtk/vtkVectorsTensorsVisuBase.h b/lib/creaVtk/vtkVectorsTensorsVisuBase.h index 831fc2c..f229542 100644 --- a/lib/creaVtk/vtkVectorsTensorsVisuBase.h +++ b/lib/creaVtk/vtkVectorsTensorsVisuBase.h @@ -96,6 +96,7 @@ public : void SetTypeForm(int); void SetColorLaw(int); void SetColor(std::vector); + void SetOrientation(int orientation); bool GetActive(); vtkDataObject* GetDataObject(); @@ -104,6 +105,7 @@ public : double GetOpacity(); vtkProp3D* GetProp3D(); int GetTypeForm(); + int GetOrientation(); virtual void Process(); void VisibilityActor(); @@ -126,6 +128,7 @@ private: vtkDataObject *_dataobject; vtkRenderer *_renderer; int _typeForm; + int _orientation; protected: bool _firsttime; diff --git a/lib/creaVtk/vtkVectorsVisu.cpp b/lib/creaVtk/vtkVectorsVisu.cpp index 376d403..7c8a6bc 100644 --- a/lib/creaVtk/vtkVectorsVisu.cpp +++ b/lib/creaVtk/vtkVectorsVisu.cpp @@ -38,8 +38,9 @@ vtkVectorsVisu::vtkVectorsVisu() :vtkVectorsTensorsVisuBase() { _vtkarrowsource = vtkArrowSource::New(); - _vtkglyph = vtkGlyph3D::New(); - _vtklinesource = vtkLineSource::New(); + _vtkglyph = NULL; + _vtklinesource = vtkLineSource ::New(); + _trans = vtkTransform ::New(); double point1[3]; double point2[3]; @@ -64,6 +65,19 @@ void vtkVectorsVisu::Process() { if(_active==true) { + if (_vtkglyph==NULL) + { + if (GetOrientation()==0) + { + _vtkglyph = vtkGlyph3D::New(); + } // _orientation + if ((GetOrientation()>=1) && (GetOrientation()<=3)) + { + _vtkglyph = vtkGlyph2D::New(); + } // _orientation + } // _vtkglyph NULL + + #if VTK_MAJOR_VERSION <= 5 _vtkglyph->SetInput( GetDataObject() ); #else @@ -101,11 +115,11 @@ vtkPointData *data = _vtkglyph->GetOutput()->GetPointData(); //_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); -} +//int i,sizeDa = data->GetNumberOfArrays(); +//for (i=0;iGetArray(i)->Print(std::cout); +//} _pdm->ScalarVisibilityOn(); _pdm->SetColorModeToMapScalars(); @@ -130,6 +144,27 @@ for (i=0;iUpdate(); #endif + + // Orientation 0 3D OK + // Orientation 1 2D xy OK + + // Orientation 2 2D yz + if (GetOrientation()==2) + { + _trans->Identity(); + _trans->Translate(900,0,0); + _trans->RotateWXYZ(-90,0,1,0); + _actor->SetUserTransform(_trans); + } + + // Orientation 3 2D xz + if (GetOrientation()==3) + { + _trans->Identity(); + _trans->RotateWXYZ(90,1,0,0); + _actor->SetUserTransform(_trans); + } + _actor->SetMapper( _pdm ); _actor->GetProperty()->SetOpacity( GetOpacity() ); }// if _active diff --git a/lib/creaVtk/vtkVectorsVisu.h b/lib/creaVtk/vtkVectorsVisu.h index 8fe751f..719cdc1 100644 --- a/lib/creaVtk/vtkVectorsVisu.h +++ b/lib/creaVtk/vtkVectorsVisu.h @@ -32,8 +32,12 @@ #include "vtkArrowSource.h" #include "vtkLineSource.h" + #include "vtkGlyph3D.h" +#include "vtkGlyph2D.h" +#include + //--------------------------------------------- // Class Name: vtkVectorsVisu // [classdescription] @@ -68,7 +72,8 @@ protected: private: vtkArrowSource *_vtkarrowsource; vtkLineSource *_vtklinesource; - vtkGlyph3D *_vtkglyph; + vtkGlyph3D *_vtkglyph; + vtkTransform *_trans; }; //-end of _vtkVectorsVISU_H_------------------------------------------------------