CMS 3D CMS Logo

IgSoCube Class Reference

Creates an OpenInventor representation for an outlined cube. More...

#include <Iguana/Inventor/interface/IgSoCube.h>

Inheritance diagram for IgSoCube:

IgSoShapeKit

List of all members.

Public Member Functions

 IgSoCube (void)

Static Public Member Functions

static void initClass (void)

Public Attributes

SoSFFloat length
SoSFFloat thickness
SoSFFloat width

Protected Member Functions

virtual void refresh (void)

Private Member Functions

 SO_KIT_CATALOG_ENTRY_HEADER (lines)
 SO_KIT_CATALOG_ENTRY_HEADER (faces)
 SO_KIT_CATALOG_ENTRY_HEADER (hints)
 SO_KIT_HEADER (IgSoCube)


Detailed Description

Creates an OpenInventor representation for an outlined cube.

Author:
Ianna Osborne, CMS/Northeastern Software Group
Date:
19 Mar 2002

Definition at line 28 of file IgSoCube.h.


Constructor & Destructor Documentation

IgSoCube::IgSoCube ( void   ) 

Definition at line 26 of file IgSoCube.cc.

References FALSE, length, IgSoShapeKit::setUpConnections(), thickness, TRUE, and width.

00027 {
00028     SO_KIT_CONSTRUCTOR (IgSoCube);
00029     SO_KIT_ADD_FIELD (width,            (1.0));
00030     SO_KIT_ADD_FIELD (length,           (1.0));
00031     SO_KIT_ADD_FIELD (thickness,        (1.0));
00032     SO_KIT_ADD_CATALOG_ENTRY (hints, SoShapeHints, FALSE, separator,\x0, TRUE);
00033     SO_KIT_ADD_CATALOG_ENTRY (faces, SoIndexedFaceSet, FALSE, separator,\x0, TRUE);
00034     SO_KIT_ADD_CATALOG_ENTRY (lines, SoIndexedLineSet, FALSE, separator,\x0, TRUE);
00035     SO_KIT_INIT_INSTANCE ();
00036     setUpConnections (true, true);
00037 }


Member Function Documentation

void IgSoCube::initClass ( void   )  [static]

Reimplemented from IgSoShapeKit.

Definition at line 23 of file IgSoCube.cc.

Referenced by initNodes(), and initShapes().

00024 { SO_KIT_INIT_CLASS (IgSoCube, IgSoShapeKit, "IgSoShapeKit"); }

void IgSoCube::refresh ( void   )  [protected, virtual]

Reimplemented from IgSoShapeKit.

Definition at line 40 of file IgSoCube.cc.

References f, length, thickness, width, x, y, and z.

00041 {
00042     SoShapeHints        *hints = new SoShapeHints;
00043     SoIndexedFaceSet    *faces = new SoIndexedFaceSet;
00044     SoIndexedLineSet    *lines = new SoIndexedLineSet;
00045     SoVertexProperty    *vtx = new SoVertexProperty;
00046     float               x = width.getValue ();
00047     float               y = length.getValue ();
00048     float               z = thickness.getValue ();
00049 
00050     // Set shape hints
00051     hints->vertexOrdering = SoShapeHints::CLOCKWISE;
00052     hints->shapeType = SoShapeHints::SOLID;
00053     hints->faceType = SoShapeHints::CONVEX;
00054 
00055     // Prepare coordinates and normals into the vertex property
00056     SbVec3f points [8] = {
00057         SbVec3f (-0.5f * x, -0.5f * y,  0.5f * z),      // (-x, -y,  z)
00058         SbVec3f (-0.5f * x,  0.5f * y,  0.5f * z),      // (-x,  y,  z)
00059         SbVec3f ( 0.5f * x,  0.5f * y,  0.5f * z),      // ( x,  y,  z)
00060         SbVec3f ( 0.5f * x, -0.5f * y,  0.5f * z),      // ( x, -y,  z)
00061 
00062         SbVec3f ( 0.5f * x, -0.5f * y, -0.5f * z),      // ( x, -y, -z)
00063         SbVec3f ( 0.5f * x,  0.5f * y, -0.5f * z),      // ( x,  y, -z)
00064         SbVec3f (-0.5f * x,  0.5f * y, -0.5f * z),      // (-x,  y, -z)
00065         SbVec3f (-0.5f * x, -0.5f * y, -0.5f * z)       // (-x, -y, -z)
00066     };
00067     
00068     SbVec3f normals [6] = {
00069         SbVec3f ( 0,  0,  1),
00070         SbVec3f ( 1,  0,  0),
00071         SbVec3f ( 0,  0, -1),
00072         SbVec3f (-1,  0,  0),
00073         SbVec3f ( 0,  1,  0),
00074         SbVec3f ( 0, -1,  0)
00075     };
00076 
00077     static const int faceIndices [] = {
00078         // each face has a quad + a stop flag
00079         0, 1, 2, 3, SO_END_FACE_INDEX, // +z face
00080         3, 2, 5, 4, SO_END_FACE_INDEX, // +x face
00081         4, 5, 6, 7, SO_END_FACE_INDEX, // -z face
00082         7, 6, 1, 0, SO_END_FACE_INDEX, // -x face
00083         1, 6, 5, 2, SO_END_FACE_INDEX, // +y face
00084         0, 3, 4, 7, SO_END_FACE_INDEX  // -y face
00085     };
00086 
00087     static int lineIndices [] = {
00088         // the first line does bottom (-y) and left (-x) sides,
00089         // second back (-z) and final the right (+x)
00090         0, 1, 2, 3, 0, 7, 6, 1, SO_END_LINE_INDEX,
00091         2, 5, 4, 3, SO_END_LINE_INDEX,
00092         4, 7, SO_END_LINE_INDEX,
00093         5, 6, SO_END_LINE_INDEX
00094     };
00095 
00096     vtx->vertex.setValues (0, 8, points);
00097     vtx->normal.setValues (0, 6, normals);
00098     vtx->normalBinding = SoVertexProperty::PER_PART;
00099     vtx->materialBinding = SoVertexProperty::OVERALL;
00100 
00101     // Set faces and lines
00102     faces->coordIndex.setValues (0, 6 * 5, faceIndices);
00103     faces->vertexProperty = vtx;
00104 
00105     lines->coordIndex.setValues (0, 9 + 5 + 3 + 3, lineIndices);
00106     lines->vertexProperty = vtx;
00107 
00108     setPart ("hints", hints);
00109     setPart ("faces", faces);
00110     setPart ("lines", lines);
00111 }

IgSoCube::SO_KIT_CATALOG_ENTRY_HEADER ( lines   )  [private]

IgSoCube::SO_KIT_CATALOG_ENTRY_HEADER ( faces   )  [private]

IgSoCube::SO_KIT_CATALOG_ENTRY_HEADER ( hints   )  [private]

IgSoCube::SO_KIT_HEADER ( IgSoCube   )  [private]


Member Data Documentation

SoSFFloat IgSoCube::length

Definition at line 40 of file IgSoCube.h.

Referenced by VisG4VisSceneHandler::AddSolid(), IgSoCube(), and refresh().

SoSFFloat IgSoCube::thickness

Definition at line 41 of file IgSoCube.h.

Referenced by VisG4VisSceneHandler::AddSolid(), IgSoCube(), and refresh().

SoSFFloat IgSoCube::width

Definition at line 39 of file IgSoCube.h.

Referenced by VisG4VisSceneHandler::AddSolid(), IgSoCube(), and refresh().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:41 2009 for CMSSW by  doxygen 1.5.4