00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef VTKWRAP_PLANE_H
00022 #define VTKWRAP_PLANE_H
00023
00024 #include <string>
00025
00026 #include "vtkPlaneSource.h"
00027 #include "vtkPolyDataMapper.h"
00028 #include "vtkActor.h"
00029 #include "vtkProperty.h"
00030
00031 #include "colors.h"
00032
00033 class Plane
00034 {
00035 friend std::ostream & operator<< (std::ostream & os, Plane const & hh);
00036 public:
00037 Plane(double Xc, double Yc, double Zc,
00038 double nx, double ny, double nz, char const * Color=NULL, double Opacity=1.0)
00039 {
00040
00041 std::string * color;
00042 if (Color==NULL) color = new std::string ("red");
00043 else color = new std::string (Color);
00044
00045
00046 _plane = vtkPlaneSource ::New();
00047 _plane_mapper = vtkPolyDataMapper ::New();
00048 _plane_actor = vtkActor ::New();
00049 _plane -> SetCenter (Xc,Yc,Zc);
00050 _plane -> SetNormal (nx,ny,nz);
00051 _plane_mapper -> SetInputConnection (_plane->GetOutputPort());
00052 _plane_actor -> SetMapper (_plane_mapper);
00053 _plane_actor -> GetProperty()->SetColor (CLR[color->c_str()].C);
00054 _plane_actor -> GetProperty()->SetOpacity (Opacity);
00055
00056
00057 delete color;
00058 }
00059 Plane(double Xo, double Yo, double Zo,
00060 double X1, double Y1, double Z1,
00061 double X2, double Y2, double Z2,
00062 double nx, double ny, double nz, char const * Color=NULL, double Opacity=1.0)
00063 {
00064
00065 std::string * color;
00066 if (Color==NULL) color = new std::string ("red");
00067 else color = new std::string (Color);
00068
00069
00070 _plane = vtkPlaneSource ::New();
00071 _plane_mapper = vtkPolyDataMapper ::New();
00072 _plane_actor = vtkActor ::New();
00073 _plane -> SetOrigin (Xo,Yo,Zo);
00074 _plane -> SetNormal (nx,ny,nz);
00075 _plane -> SetPoint1 (X1,Y1,Z1);
00076 _plane -> SetPoint2 (X2,Y2,Z2);
00077 _plane_mapper -> SetInputConnection (_plane->GetOutputPort());
00078 _plane_actor -> SetMapper (_plane_mapper);
00079 _plane_actor -> GetProperty()->SetColor (CLR[color->c_str()].C);
00080 _plane_actor -> GetProperty()->SetOpacity (Opacity);
00081
00082
00083 delete color;
00084 }
00085 ~Plane()
00086 {
00087 _plane -> Delete();
00088 _plane_mapper -> Delete();
00089 _plane_actor -> Delete();
00090 }
00091 vtkActor * GetActor() { return _plane_actor; }
00092 vtkAlgorithmOutput * GetOutputPort() { return _plane->GetOutputPort(); }
00093 vtkPlaneSource * GetObject() { return _plane; }
00094 private:
00095 vtkPlaneSource * _plane;
00096 vtkPolyDataMapper * _plane_mapper;
00097 vtkActor * _plane_actor;
00098 };
00099
00100 std::ostream & operator<< (std::ostream & os, Plane const & hh)
00101 {
00102 hh._plane->Print(os);
00103 return os;
00104 }
00105
00106 #endif // VTKWRAP_PLANE_H
00107
00108