Facebook
From Jeny, 3 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 190
  1. #include "vtkSphereSource.h"
  2. #include "vtkActor.h"
  3. #include "vtkPolyDataMapper.h"
  4. #include "vtkRenderer.h"
  5. #include "vtkRenderWindow.h"
  6. #include "vtkRenderWindowInteractor.h"
  7. #include "vtkSmartPointer.h"
  8. #include "vtkProperty.h"
  9. #include "vtkSetGet.h"
  10.  
  11. int main( int argc, char** argv )
  12. {
  13.  
  14.   vtkSmartPointer<vtkSphereSource> source;
  15.   source = vtkSmartPointer<vtkSphereSource>::New();
  16.  
  17.   vtkSmartPointer<vtkPolyDataMapper> mapper;
  18.   mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
  19.  
  20.   vtkSmartPointer<vtkActor> actor;
  21.   actor = vtkSmartPointer<vtkActor>::New();
  22.  
  23.  
  24.   vtkSmartPointer<vtkRenderer> renderer;
  25.   renderer = vtkSmartPointer<vtkRenderer>::New();
  26.  
  27.   vtkSmartPointer<vtkRenderWindow> renderWindow;
  28.   renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
  29.  
  30.   double Rayon;
  31.   Rayon = source->GetRadius();
  32.   std::cout << "Rayon = " << Rayon << std::endl;
  33.   //source->SetRadius(0.4);
  34.  
  35.   double Opacite;
  36.  
  37.   Opacite = actor.Get()->GetProperty()->GetOpacity();
  38.   std:cout << "Opacite = " << Opacite << std::endl;
  39.  
  40.   double *Couleur ;
  41.   Couleur = actor.Get()->GetProperty()->GetColor();
  42.   std::cout << "Couleur de la sphere = " << Couleur << std::endl;
  43.  
  44.  // std::cout << "couleur de la sphere : " << actor.Get()->GetProperty()->GetColor() << std::endl;
  45.  
  46.  
  47.   double RGB[3] = {1,0,1};
  48.   actor.Get()->GetProperty()->SetColor(RGB);
  49.   actor.Get()->GetProperty()->SetColor(0,0,1);
  50.   //std::cout << "couleur de la sphere : " << actor.Get()->GetProperty()->GetColor(r, g, b) << std::endl;
  51.  
  52.   actor.Get()->GetProperty()->SetOpacity(5.0);
  53.  
  54.   //std::cout << "couleur : " << source->GetCouleur() << std::endl;
  55.   //actor.Get()->GetProperty()->SetColor(0, 0, 1)
  56.   //actor.Get()->GetProperty()->GetColor()
  57.  
  58.  
  59.  
  60.   class VTKFILTERSSOURCES_EXPORT vtkSphereSource : public vtkPolyDataAlgorithm {
  61.  
  62.   private:
  63.           double Couleur[3];
  64.           double Opacite;
  65.    
  66.   public:
  67.  
  68.           vtkTypeMacro(vtkSphereSource, vtkPolyDataAlgorithm);
  69.           void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
  70.  
  71.           vtkSphereSource* source;
  72.  
  73.  
  74.           vtkGetVectorMacro(Couleur, double, 3);
  75.           vtkSetVector3Macro(Couleur, double);
  76.  
  77.           vtkSetClampMacro(Opacite, double, 0.0, 1.0);
  78.           vtkGetMacro(Opacite, double);
  79.  
  80.  
  81.   };
  82.  
  83.  
  84.  
  85.  
  86.   vtkSmartPointer<vtkRenderWindowInteractor> rwi;
  87.   rwi = vtkSmartPointer<vtkRenderWindowInteractor>::New();
  88.  
  89.   mapper->SetInputConnection( source->GetOutputPort());
  90.   actor->SetMapper( mapper);
  91.   renderer->AddViewProp( actor );
  92.   renderWindow->AddRenderer( renderer );
  93.   renderWindow->SetInteractor( rwi );
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.   rwi->Start( );
  111.  
  112.   return(EXIT_SUCCESS);
  113. }
  114.  

Replies to main.cpp rss

Title Name Language When
Re: main.cpp Jeny cpp 3 Years ago.