00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef VTKWRAP_SPHERE_H
00022 #define VTKWRAP_SPHERE_H
00023
00024 #include <string>
00025
00026 #include "vtkSphereSource.h"
00027 #include "vtkPolyDataMapper.h"
00028 #include "vtkActor.h"
00029 #include "vtkProperty.h"
00030
00031 #include "colors.h"
00032
00033 class Sphere
00034 {
00035 friend std::ostream & operator<< (std::ostream & os, Sphere const & hh);
00036 public:
00037 Sphere(double Xc, double Yc, double Zc, double Radius, char const * Color=NULL, double Opacity=1.0, int ThetaRes=20, int PhiRes=20)
00038 {
00039
00040 std::string * color;
00041 if (Color==NULL) color = new std::string ("red");
00042 else color = new std::string (Color);
00043
00044
00045 _sphere = vtkSphereSource ::New();
00046 _sphere_mapper = vtkPolyDataMapper ::New();
00047 _sphere_actor = vtkActor ::New();
00048 _sphere -> SetCenter (Xc,Yc,Zc);
00049 _sphere -> SetRadius (Radius);
00050 _sphere -> SetThetaResolution (ThetaRes);
00051 _sphere -> SetPhiResolution (PhiRes);
00052 _sphere_mapper -> SetInputConnection (_sphere->GetOutputPort());
00053 _sphere_actor -> SetMapper (_sphere_mapper);
00054 _sphere_actor -> GetProperty()->SetColor (CLR[color->c_str()].C);
00055 _sphere_actor -> GetProperty()->SetOpacity (Opacity);
00056
00057
00058 delete color;
00059 }
00060 ~Sphere()
00061 {
00062 _sphere -> Delete();
00063 _sphere_mapper -> Delete();
00064 _sphere_actor -> Delete();
00065 }
00066 vtkActor * GetActor() { return _sphere_actor; }
00067 vtkAlgorithmOutput * GetOutputPort() { return _sphere->GetOutputPort(); }
00068 vtkSphereSource * GetObject() { return _sphere; }
00069 private:
00070 vtkSphereSource * _sphere;
00071 vtkPolyDataMapper * _sphere_mapper;
00072 vtkActor * _sphere_actor;
00073 };
00074
00075 std::ostream & operator<< (std::ostream & os, Sphere const & hh)
00076 {
00077 hh._sphere->Print(os);
00078 return os;
00079 }
00080
00081 #endif // VTKWRAP_SPHERE_H
00082
00083