]> Creatis software - creaVtk.git/blobdiff - lib/creaVtk/vtkVectorsVisu.cpp
VectorField 2D view
[creaVtk.git] / lib / creaVtk / vtkVectorsVisu.cpp
index 92c3df40293c4ceac6970204482ccad1dbd404da..7c8a6bc1776e0d0d29ffa25e3e81e88ce74e9f8f 100644 (file)
 vtkVectorsVisu::vtkVectorsVisu()
   :vtkVectorsTensorsVisuBase()
 {
-       _vtkarrowsource = vtkArrowSource::New();
-       _vtklinesource          = vtkLineSource::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()
 {
      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
          _vtkglyph->SetInputData( GetDataObject() );  
 #endif
-
                        if(GetTypeForm()==1)                                                            // source Arrow
                        {
 #if VTK_MAJOR_VERSION <= 5
-                _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
+                       _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
 #else
-                _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
+                               _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() );
-         _vtkglyph->Update();
+               _vtkglyph->Update();
 
 #if VTK_MAJOR_VERSION <= 5
          _pdm->SetInput( _vtkglyph->GetOutput());
@@ -90,31 +115,11 @@ vtkPointData       *data   = _vtkglyph->GetOutput()->GetPointData();
 //_vtkglyph->GetOutput()->Print(std::cout);
 //printf("EED -------------------------------------------\n");
 //data->Print(std::cout);
-printf("EED -------------------------------------------\n");                   
-int i,sizeDa = data->GetNumberOfArrays();
-printf("EED vtkVectorsVisu::Process  sizeDa %d \n", sizeDa );
-for (i=0;i<sizeDa;i++)
-{
-       printf("EED vtkVectorsVisu::Process-name %d, %s \n", i, data->GetArrayName(i) );
-       data->GetArray(i)->Print(std::cout);
-       printf("EED -------------------------------------------\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();
-
-
-
-
+//int i,sizeDa = data->GetNumberOfArrays();
+//for (i=0;i<sizeDa;i++)
+//{
+//     data->GetArray(i)->Print(std::cout);
+//}
 
        _pdm->ScalarVisibilityOn();
        _pdm->SetColorModeToMapScalars();
@@ -127,8 +132,6 @@ for (i=0;i<sizeDa;i++)
        //_LutEED->SetVectorModeToRGBColors();
        //_LutEED->SetVectorModeToMagnitud();
 
-
-
 //         _pdm->SetScalarModeToUsePointFieldData();
          _pdm->SetLookupTable( _LutEED );
          _pdm->SelectColorArray( "GlyphVector" );
@@ -136,15 +139,36 @@ for (i=0;i<sizeDa;i++)
 //       vSliceMapperVec->SetLookupTable( vGreenToRedLut );
 //       vSliceMapperVec->SetColorModeToMapScalars();
 
+#if VTK_MAJOR_VERSION <= 5
+               // ..
+#else
+         _pdm->Update();
+#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
 
     VisibilityActor(); 
 }
-       
-
-
-
-