]> Creatis software - creaVtk.git/blobdiff - lib/creaVtk/vtkVectorsVisu.cpp
#3282 creaVtk Feature New Normal - PolyDataInfo
[creaVtk.git] / lib / creaVtk / vtkVectorsVisu.cpp
index f88c650456a4fc8b3356af713ba27cc1f4d46206..248420aa929128151ccc75ed66031266fe8fecdb 100644 (file)
 #include "vtkDataObject.h"
 #include <vtkPointData.h>
 
+#include <vtkAppendPolyData.h>
+
 //------------------------------------------------------------------------------
 vtkVectorsVisu::vtkVectorsVisu()
   :vtkVectorsTensorsVisuBase()
 {
-       _vtkarrowsource         = vtkArrowSource::New();
-       _vtkglyph                       = NULL;
-       _vtklinesource          = vtkLineSource ::New();
-       _trans                          = vtkTransform  ::New();
+                                       _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->SetPoint1( point1 );
-       _vtklinesource->SetPoint2( point2 );
+
+       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();
 }
 
 //------------------------------------------------------------------------------
@@ -99,10 +136,9 @@ void vtkVectorsVisu::Process()
        #endif
                                } else {                                                                                                // source Line
        #if VTK_MAJOR_VERSION <= 5
-                                       _vtkglyph->SetSource( _vtklinesource->GetOutput() );    
+                                       _vtkglyph->SetSource( _vtklineGlyphPolyData );          
        #else
-                                       _vtklinesource->Update();
-                                       _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );        
+                                       _vtkglyph->SetSourceData( _vtklineGlyphPolyData );      
        #endif
                                }
                     _vtkglyph->SetScaleModeToScaleByVector();
@@ -166,7 +202,7 @@ void vtkVectorsVisu::Process()
        //                      _pdm->SetColorModeToDefault();
        //                       _pdm->SetColorModeToDirectScalars();  // NOT compile
        //                      _pdm->SetScalarModeToUsePointFieldData();
-                               _pdm->ImmediateModeRenderingOn();   // obsolete
+//                             _pdm->ImmediateModeRenderingOn();   // obsolete
                             _pdm->SetLookupTable( _externalLut );
                             _pdm->SelectColorArray( "angle" );
                        }  // if _externalLut