00001
00002
00003 #include "Iguana/Inventor/interface/IgSoHits.h"
00004 #include <Inventor/nodes/SoPointSet.h>
00005 #include <Inventor/nodes/SoVertexProperty.h>
00006 #include <vector>
00007
00008
00009
00010
00011
00012
00013
00014
00015 SO_KIT_SOURCE (IgSoHits);
00016
00017
00018
00019
00020
00021 void
00022 IgSoHits::initClass (void)
00023 { SO_KIT_INIT_CLASS (IgSoHits, IgSoShapeKit, "IgSoShapeKit"); }
00024
00025 IgSoHits::IgSoHits (void)
00026 {
00027 SO_KIT_CONSTRUCTOR (IgSoHits);
00028 SO_KIT_ADD_FIELD (points, (0, 0, 0));
00029 SO_KIT_ADD_CATALOG_ENTRY (pointset, SoPointSet, FALSE, separator,\x0, TRUE);
00030 SO_KIT_INIT_INSTANCE ();
00031 setUpConnections (true, true);
00032 }
00033
00034 void
00035 IgSoHits::refresh (void)
00036 {
00037 SoPointSet *pointset = new SoPointSet;
00038 SoVertexProperty *vtx = new SoVertexProperty;
00039
00040 vtx->vertex = points;
00041 pointset->vertexProperty = vtx;
00042
00043 setPart ("pointset", pointset);
00044 }
00045
00046 void
00047 IgSoHits::convertRZPhiToXYZ (const float *rzphi, float *xyz)
00048 {
00049 xyz [0] = rzphi [0] * cos (rzphi [2]);
00050 xyz [1] = rzphi [0] * sin (rzphi [2]);
00051 xyz [2] = rzphi [1];
00052 }
00053
00054 void
00055 IgSoHits::initXYZ (int n, const float (*pts) [3])
00056 {
00057 points.deleteValues (0);
00058 std::vector<SbVec3f> p;
00059 p.reserve (n);
00060 for (int i = 0; i < n; ++i)
00061 p.push_back (pts [n]);
00062 points.setValues (0, n, &p [0]);
00063 }
00064
00065 void
00066 IgSoHits::initXYZ (int n, const SbVec3f *pts)
00067 {
00068 points.deleteValues (0);
00069 points.setValues (0, n, pts);
00070 }
00071
00072 void
00073 IgSoHits::initRZPhi (int n, const float (*pts) [3])
00074 {
00075 std::vector<SbVec3f> xyz;
00076 xyz.reserve (n);
00077 for (int i = 0; i < n; ++i)
00078 {
00079 SbVec3f pt;
00080 convertRZPhiToXYZ (pts [n], &pt[0]);
00081 xyz.push_back (pt);
00082 }
00083 initXYZ (n, &xyz[0]);
00084 }