CMS 3D CMS Logo

IgSoHits.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
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 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00009 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00010 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00011 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00012 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00013 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00014 
00015 SO_KIT_SOURCE (IgSoHits);
00016 
00017 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00018 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00019 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
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 }

Generated on Tue Jun 9 17:38:46 2009 for CMSSW by  doxygen 1.5.4