00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <pcl_visualization/common/shapes.h>
00038
00040
00044 vtkSmartPointer<vtkDataSet>
00045 pcl_visualization::createCylinder (const pcl::ModelCoefficients &coefficients, int numsides)
00046 {
00047 vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New ();
00048 line->SetPoint1 (coefficients.values[0], coefficients.values[1], coefficients.values[2]);
00049 line->SetPoint2 (coefficients.values[3]+coefficients.values[0], coefficients.values[4]+coefficients.values[1], coefficients.values[5]+coefficients.values[2]);
00050
00051 vtkSmartPointer<vtkTubeFilter> tuber = vtkSmartPointer<vtkTubeFilter>::New ();
00052 tuber->SetInputConnection (line->GetOutputPort ());
00053 tuber->SetRadius (coefficients.values[6]);
00054 tuber->SetNumberOfSides (numsides);
00055
00056 return (tuber->GetOutput ());
00057 }
00058
00063 vtkSmartPointer<vtkDataSet>
00064 pcl_visualization::createSphere (const pcl::ModelCoefficients &coefficients, int res)
00065 {
00066
00067 vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New ();
00068 t->Identity (); t->Translate (coefficients.values[0], coefficients.values[1], coefficients.values[2]);
00069
00070 vtkSmartPointer<vtkSphereSource> s_sphere = vtkSmartPointer<vtkSphereSource>::New ();
00071 s_sphere->SetRadius (coefficients.values[3]);
00072 s_sphere->SetPhiResolution (res);
00073 s_sphere->SetThetaResolution (res);
00074 s_sphere->LatLongTessellationOff ();
00075
00076 vtkSmartPointer<vtkTransformPolyDataFilter> tf = vtkSmartPointer<vtkTransformPolyDataFilter>::New ();
00077 tf->SetTransform (t);
00078 tf->SetInputConnection (s_sphere->GetOutputPort ());
00079
00080 return (tf->GetOutput ());
00081 }
00082
00086 vtkSmartPointer<vtkDataSet>
00087 pcl_visualization::createLine (const pcl::ModelCoefficients &coefficients)
00088 {
00089 vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New ();
00090 line->SetPoint1 (coefficients.values[0], coefficients.values[1], coefficients.values[2]);
00091 line->SetPoint2 (coefficients.values[3] + coefficients.values[0],
00092 coefficients.values[4] + coefficients.values[1],
00093 coefficients.values[5] + coefficients.values[2]);
00094 line->Update ();
00095
00096 return (line->GetOutput ());
00097 }
00098
00102 vtkSmartPointer<vtkDataSet>
00103 pcl_visualization::createPlane (const pcl::ModelCoefficients &coefficients)
00104 {
00105 vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
00106 plane->SetNormal (coefficients.values[0], coefficients.values[1], coefficients.values[2]);
00107 plane->Push (coefficients.values[3]);
00108 return (plane->GetOutput ());
00109 }
00110
00115 vtkSmartPointer<vtkDataSet>
00116 pcl_visualization::create2DCircle (const pcl::ModelCoefficients &coefficients, double z)
00117 {
00118 vtkSmartPointer<vtkDiskSource> disk = vtkSmartPointer<vtkDiskSource>::New ();
00119
00120 disk->SetCircumferentialResolution (100);
00121 disk->SetInnerRadius (coefficients.values[2] - 0.001);
00122 disk->SetOuterRadius (coefficients.values[2] + 0.001);
00123 disk->SetCircumferentialResolution (20);
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New ();
00139 t->Identity ();
00140 t->Translate (coefficients.values[0], coefficients.values[1], z);
00141
00142 vtkSmartPointer<vtkTransformPolyDataFilter> tf = vtkSmartPointer<vtkTransformPolyDataFilter>::New ();
00143 tf->SetTransform (t);
00144 tf->SetInputConnection (disk->GetOutputPort ());
00145
00146
00147
00148
00149 return (tf->GetOutput ());
00150 }
00151
00155 vtkSmartPointer<vtkDataSet>
00156 pcl_visualization::createCone (const pcl::ModelCoefficients &coefficients)
00157 {
00158 vtkSmartPointer<vtkConeSource> cone = vtkSmartPointer<vtkConeSource>::New ();
00159 cone->SetHeight (1.0);
00160 cone->SetCenter (coefficients.values[0] + coefficients.values[3] * 0.5,
00161 coefficients.values[1] + coefficients.values[1] * 0.5,
00162 coefficients.values[2] + coefficients.values[2] * 0.5);
00163 cone->SetDirection (-coefficients.values[3], -coefficients.values[4], -coefficients.values[5]);
00164 cone->SetResolution (100);
00165 cone->SetAngle (coefficients.values[6]);
00166
00167 return (cone->GetOutput ());
00168 }
00169