]> Creatis software - creaVtk.git/blobdiff - lib/creaVtk/vtkVectorsVisu.cpp
#3274 creaVtk Feature New Normal - BooleanOperationPolyDataFilter BoxWidget ClipPol...
[creaVtk.git] / lib / creaVtk / vtkVectorsVisu.cpp
index c29dace97f7f3ddbccc12d64f61bc51ba4331aa1..f88c650456a4fc8b3356af713ba27cc1f4d46206 100644 (file)
@@ -65,167 +65,173 @@ vtkVectorsVisu::~vtkVectorsVisu()
 //------------------------------------------------------------------------------
 void vtkVectorsVisu::Process()
 {
+       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(_active==true)
      {
-               if (_vtkglyph==NULL) 
+
+               if (GetDataObject()!=NULL) 
                {
-                       if (GetOrientation()==-1) 
+       #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() );
+       #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();
+
+
+                       if (_externalLut==NULL)
                        {
-                               _vtkglyph = vtkGlyph3D::New(); 
-                       } // _orientation                       
-                       if ((GetOrientation()>=0) && (GetOrientation()<=2))
+                       _vtkglyph->SetColorModeToColorByVector();   
+                       } else {
+                               _vtkglyph->SetColorModeToColorByScalar();   
+                       } // if _externalLut
+
+                    _vtkglyph->SetScaleFactor( GetScaleFactor() );
+                       _vtkglyph->Update();
+
+       #if VTK_MAJOR_VERSION <= 5
+                    _pdm->SetInput( _vtkglyph->GetOutput());
+       #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;i<sizeDa;i++)
+       //{
+       //      data->GetArray(i)->Print(std::cout);
+       //}
+
+                       if (_externalLut==NULL)
                        {
-                               _vtkglyph = vtkGlyph3D::New(); 
-//                             _vtkglyph = vtkGlyph2D::New(); 
-                       } // _orientation                       
-               } // _vtkglyph NULL
-
-
-#if VTK_MAJOR_VERSION <= 5
-         _vtkglyph->SetInput( GetDataObject() );  
-#else
-         _vtkglyph->SetInputData( GetDataObject() );  
-#endif
-                       if(GetTypeForm()==1)                                                            // source Arrow
+                               _pdm->ScalarVisibilityOn();
+                               _pdm->SetColorModeToMapScalars();
+                       //      _pdm->SetColorModeToDefault();
+                               // _pdm->SetColorModeToDirectScalars();  // NOT compile
+                               _pdm->SetScalarModeToUsePointFieldData();
+                       //      _pdm->ImmediateModeRenderingOn();   // obsolete
+                               _LutEED->SetVectorModeToComponent();
+                               //_LutEED->SetVectorModeToRGBColors();
+                               //_LutEED->SetVectorModeToMagnitud();
+                       //         _pdm->SetScalarModeToUsePointFieldData();
+                    _pdm->SetLookupTable( _LutEED );
+                    _pdm->SelectColorArray( "GlyphVector" );
+                       } else {
+                               data->SetActiveScalars("angle");
+
+                               _pdm->ScalarVisibilityOn(); 
+                               double scalarRange[2];
+                               scalarRange[0]=0;
+                               scalarRange[1]=40;
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
+                               _pdm->SetScalarRange(scalarRange);
+                               _pdm->SetColorModeToMapScalars();
+       //                      _pdm->SetColorModeToDefault();
+       //                       _pdm->SetColorModeToDirectScalars();  // NOT compile
+       //                      _pdm->SetScalarModeToUsePointFieldData();
+                               _pdm->ImmediateModeRenderingOn();   // obsolete
+                            _pdm->SetLookupTable( _externalLut );
+                            _pdm->SelectColorArray( "angle" );
+                       }  // if _externalLut
+
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
+       printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
+
+       /*
+       _vtkglyph->Update();
+       vtkPointData *pointdata=_vtkglyph->GetOutput()->GetPointData();
+       int i,size=pointdata->GetNumberOfArrays();
+       for (i=0;i<size;i++)
+       {
+               vtkDataArray *array=pointdata->GetArray(i);
+               printf(" vtkVectorsVisu::Process array name %d:<%s>  size:%d\n", i, array->GetName(), array->GetSize() );
+       }
+       */
+
+
+       //       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) 
                        {
-#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
+                               _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);
                        }
-         _vtkglyph->SetScaleModeToScaleByVector();
-
 
-               if (_externalLut==NULL)
-               {
-               _vtkglyph->SetColorModeToColorByVector();   
+                   _actor->SetMapper( _pdm );
+                   _actor->GetProperty()->SetOpacity( GetOpacity() );
                } else {
-                       _vtkglyph->SetColorModeToColorByScalar();   
-               } // if _externalLut
+                       printf("EED Warnning! vtkVectorsVisu::Process   GetDataObject()  is EMPTY\n");
+               }// if GetDataObject()!=NULL
 
-         _vtkglyph->SetScaleFactor( GetScaleFactor() );
+    } else {
+               _vtkglyph->SetInputData( NULL );  
                _vtkglyph->Update();
-
-#if VTK_MAJOR_VERSION <= 5
-         _pdm->SetInput( _vtkglyph->GetOutput());
-#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;i<sizeDa;i++)
-//{
-//     data->GetArray(i)->Print(std::cout);
-//}
-
-
-               if (_externalLut==NULL)
-               {
-                       _pdm->ScalarVisibilityOn();
-                       _pdm->SetColorModeToMapScalars();
-               //      _pdm->SetColorModeToDefault();
-                       // _pdm->SetColorModeToDirectScalars();  // NOT compile
-                       _pdm->SetScalarModeToUsePointFieldData();
-               //      _pdm->ImmediateModeRenderingOn();   // obsolete
-                       _LutEED->SetVectorModeToComponent();
-                       //_LutEED->SetVectorModeToRGBColors();
-                       //_LutEED->SetVectorModeToMagnitud();
-               //         _pdm->SetScalarModeToUsePointFieldData();
-         _pdm->SetLookupTable( _LutEED );
-         _pdm->SelectColorArray( "GlyphVector" );
-               } else {
-                       data->SetActiveScalars("angle");
-
-                       _pdm->ScalarVisibilityOn(); 
-                       double scalarRange[2];
-                       scalarRange[0]=0;
-                       scalarRange[1]=40;
-printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
-printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
-printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
-printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
-printf("EED warnnning  .....  vtkVectorsVisu::Process   clean scalar Range ......\n");
-                   _pdm->SetScalarRange(scalarRange);
-                       _pdm->SetColorModeToMapScalars();
-//                     _pdm->SetColorModeToDefault();
-//                      _pdm->SetColorModeToDirectScalars();  // NOT compile
-//                     _pdm->SetScalarModeToUsePointFieldData();
-                       _pdm->ImmediateModeRenderingOn();   // obsolete
-                _pdm->SetLookupTable( _externalLut );
-                _pdm->SelectColorArray( "angle" );
-               }  // if _externalLut
-
-printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
-printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
-printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
-printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
-printf("EED warnnning  .....  vtkVectorsVisu::Process   Clean angle ......\n");
-
-/*
-_vtkglyph->Update();
-vtkPointData *pointdata=_vtkglyph->GetOutput()->GetPointData();
-int i,size=pointdata->GetNumberOfArrays();
-for (i=0;i<size;i++)
-{
-       vtkDataArray *array=pointdata->GetArray(i);
-       printf(" vtkVectorsVisu::Process array name %d:<%s>  size:%d\n", i, array->GetName(), array->GetSize() );
-}
-*/
-
-
-//       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 );
-         _actor->GetProperty()->SetOpacity( GetOpacity() );
-    }// if _active
+       }// if _active
 
     VisibilityActor(); 
 }