Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

SculptDemoApp Class Reference

Application implementing demonstration of capabilities. More...

#include <SculptDemoApp.h>

Inheritance diagram for SculptDemoApp:

OIVAppShell Observer List of all members.

Public Member Functions

 SculptDemoApp (int, char **)
 Constructor takes parameters from the command line.
virtual ~SculptDemoApp ()
 Destuctor cleans up memory.
SbBox3f getWorkspaceSize ()
 Get the PHANToM's physical workspace size.
void setPhantomOffset (const SbVec3f &)
 Set the PHANToM offset from the CAVE origin.
void addIVFile (char *filename)
 Observer update method is triggered when notified by Subjects.
CAVE-related template method callbacks
virtual void buildScene ()
 Builds the Inventor and GHOST scene graphs.
int hasOne (float xmin, float ymin, float zmin, float xmax, float ymax, float zmax, int size)
void loadFile (char *filename, int siz)
void makeCubes (int, int, SbVec3f)
void addCube (SbVec3f cur, SbVec3f cen, float size, SculptCube *node, float rad)
void reloadOctree ()
void buildOctree (SbVec3f cen, float size, SculptCube *node, float orgsize)
void modifyCube (SbVec3f cur, SbVec3f center, float size, SculptCube *octSculpt, float rad, int flag)
void modifyCube (SbVec3f cur, SbVec3f center, float summa, float size, SculptCube *octSculpt)
void modifyCuboid (SbVec3f cur, SbVec3f center, float xsize, float ysize, float zsize, SculptCube *octSculpt)
void modifyOctree ()
void deleteOctree (SculptCube *)
void modifyOctree (SculptCube *)
void sculptSphere (SbBox3f bounds, float rad, SbVec3f curr, float size, SculptCube *node)
void loadOctree (char *filename)
void loadOctree (SculptCube *, SoTransformSeparator *)
virtual void frameUpdate ()
 Once-per-frame update will trigger GHOST notification.
virtual void update ()
 Update method called from main will check the stylus button.
virtual void handleEvents ()
virtual void update (Subject *)

Static Public Member Functions

static void PointerGraphicCB (gstTransform *, void *, void *)
 Callback copies the PHANToM transform to the pointer graphics.
static void HapticTransformCB (gstTransform *nodePtr, void *callbackData, void *userData)
static void triangle_cb (void *userdata, SoCallbackAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3)

Public Attributes

SbBox3f m_defectBounds
SbBox3f m_implantBounds
SbBox3f m_toolBounds

Protected Types

enum  SCULPTTools {
  TRANSLATE_TOOL = 0, ROTATE_TOOL, SCULPT_TOOL, ADDITION_TOOL,
  RELOAD, RECONSTRUCT, NUM_SCULPT_TOOLS
}

Protected Attributes

SoGroup * m_toolGroup
SoAsciiText * m_toolNameText
SoSwitch * m_wandSwitch
CrWandControllerm_wand
CrGrabberTool * m_wandPointer
bool m_canTranslate
 Whether or not use of the translation manipulator is enabled.
bool m_canRotate
 Whether or not use of the rotation manipulator is enabled.
int m_stylusButtonOn
 Current status of the PHANToM stylus button.
int m_currentTool
SbString m_defectFilename
SoSwitch * m_hapSwitch
SoGroup * m_defectGroup
IVFilem_defectMesh
SoSwitch * m_defectSwitch
SoSeparator * m_defectSep
SoTransform * m_defectFitTransform
SoTransform * m_defectTransform
gstSeparator * m_hapFitSeparator
SoSeparator * catchSeparator
gstSeparator * hapdefectSep
float defw
float defh
float defd
SoSphere * ptr
Inventor scene graph elements
SoSeparator * m_ghostSep
 Separator under which the haptic scene is contained.
SoSeparator * newCubeSep
 Separator under which the haptic scene is contained.
SoTransformSeparator * rootOIVSep
SoTransform * m_phantomOffset
 Transform of the PHANToM device offset from the CAVE origin.
SoTransform * m_phantomTransform
 Transform representing the PHANToM.
GHOST scene graph elements
gstScene * m_hapScene
 GHOST scene graph.
gstSeparator * m_hapRoot
 GHOST scene graph root node.
gstSeparator * m_hapCube
 GHOST scene graph root node.
gstSeparator * m_tempHapRoot
 GHOST scene graph root node.
gstSeparator * rootGHOSTSep
 GHOST scene graph root node.
gstPHANToM * m_phantom
 GHOST PHANToM device instance.
gstPHANToM_SCP * m_phantomSCP
 PHANToM surface contact point.
gstTranslateManipulator * m_translateManip
 GHOST dynamic translation manipulator.
gstRotateManipulator * m_rotateManip
 GHOST dynamic rotation manipulator.
SbBox3f m_workspaceSize
 Box storing the available PHANToM workspace size.
gstPoint currentPosition
gstPoint previousPosition
int csSize
float csize
SculptCube * tempCube
int nurbed
int sculptFlag
float maxsize
int autoSculpt
SculptConfigm_config
unsigned char *** buffer3d

Detailed Description

Application implementing demonstration of capabilities.

Author:
vaidya Chandrasekar Using the capabilities of OIVAppShell with subclasses makes the management of code significantly easier. The interaction between Inventor and the CAVELib have been localized to the parent class, so that's less code to duplicate when working on several different applications. As a subclass, SculptDemoApp must construct its scene within SculptDemoApp::buildScene() and also add extra capabilities for the GHOST scene graph.


Member Enumeration Documentation

enum SculptDemoApp::SCULPTTools [protected]
 

Enumerator:
TRANSLATE_TOOL 
ROTATE_TOOL 
SCULPT_TOOL 
ADDITION_TOOL 
RELOAD 
RECONSTRUCT 
NUM_SCULPT_TOOLS 


Constructor & Destructor Documentation

SculptDemoApp::SculptDemoApp int  argc,
char **  argv
 

Constructor takes parameters from the command line.

The application constructor initializes several nodes and other variables. The PHANToM instance is initialized here and checked to make sure that a valid construction took place. The initial elements of the GHOST scene graph are created here. Once the PHANToM has been initialized, it is queried to determine the workspace size, and that size is stored for use when constructing the Inventor scene.

Parameters:
argc - number of arguments passed from the command line
argv - strings passed from the command line

SculptDemoApp::~SculptDemoApp  )  [virtual]
 

Destuctor cleans up memory.

When the application has finished running, it's important to stop the haptic servo loop. The destructor also dumps the Inventor scene graph to a file for debugging purposes. This makes it easy to check the construction of the scene graph.


Member Function Documentation

void SculptDemoApp::addCube SbVec3f  cur,
SbVec3f  cen,
float  size,
SculptCube *  node,
float  rad
 

void SculptDemoApp::addIVFile char *  filename  ) 
 

Observer update method is triggered when notified by Subjects.

void SculptDemoApp::buildOctree SbVec3f  cen,
float  size,
SculptCube *  node,
float  orgsize
 

void SculptDemoApp::buildScene  )  [virtual]
 

Builds the Inventor and GHOST scene graphs.

The base OIVAppShell implementation does not create any scene graph nodes to place into the scene. The Inventor graphics are constructed first. A PointLight provides illumination. A Separator is used to localize all haptic elements under a single sub-tree of the scene graph. The details of the scene graph are described in the source code.

Reimplemented from OIVAppShell.

void SculptDemoApp::deleteOctree SculptCube *   ) 
 

void SculptDemoApp::frameUpdate  )  [virtual]
 

Once-per-frame update will trigger GHOST notification.

Reimplemented from OIVAppShell.

SbBox3f SculptDemoApp::getWorkspaceSize  ) 
 

Get the PHANToM's physical workspace size.

void SculptDemoApp::handleEvents  )  [virtual]
 

Called once per cycle of the main loop, this function handles checking the PHANToM stylus to manage the use of the translation manipulator. It controls the logic for starting and stopping the manipulator.

Reimplemented from OIVAppShell.

void SculptDemoApp::HapticTransformCB gstTransform *  nodePtr,
void *  callbackData,
void *  userData
[static]
 

Each time the GHOST graphics update is called, this function will copy the PHANToM transform to a passed node.

Parameters:
nodePtr - GHOST shape
callbackData - gstDynamicGraphicsCBData
userData - pointer to the SculptDemoApp instance.

int SculptDemoApp::hasOne float  xmin,
float  ymin,
float  zmin,
float  xmax,
float  ymax,
float  zmax,
int  size
 

void SculptDemoApp::loadFile char *  filename,
int  siz
 

void SculptDemoApp::loadOctree SculptCube *  ,
SoTransformSeparator * 
 

void SculptDemoApp::loadOctree char *  filename  ) 
 

void SculptDemoApp::makeCubes int  ,
int  ,
SbVec3f 
 

void SculptDemoApp::modifyCube SbVec3f  cur,
SbVec3f  center,
float  summa,
float  size,
SculptCube *  octSculpt
 

void SculptDemoApp::modifyCube SbVec3f  cur,
SbVec3f  center,
float  size,
SculptCube *  octSculpt,
float  rad,
int  flag
 

void SculptDemoApp::modifyCuboid SbVec3f  cur,
SbVec3f  center,
float  xsize,
float  ysize,
float  zsize,
SculptCube *  octSculpt
 

void SculptDemoApp::modifyOctree SculptCube *   ) 
 

void SculptDemoApp::modifyOctree  ) 
 

void SculptDemoApp::PointerGraphicCB gstTransform *  ,
void *  ,
void * 
[static]
 

Callback copies the PHANToM transform to the pointer graphics.

void SculptDemoApp::reloadOctree  ) 
 

void SculptDemoApp::sculptSphere SbBox3f  bounds,
float  rad,
SbVec3f  curr,
float  size,
SculptCube *  node
 

void SculptDemoApp::setPhantomOffset const SbVec3f &  offset  ) 
 

Set the PHANToM offset from the CAVE origin.

The origin of the PHANToM work area must be measured from the origin of the CAVELib. This offset is the magic element which makes the haptics appear aligned with the rendering. If this offset is significantly displaced, the misalignment will be clearly evident to the user. This example code merely demonstrates how this offset must be placed into the scene graph. A more robust implementation should provide an interactive method for measuring and adjusting this offset.

Parameters:
offset - distance (mm) from CAVE origin to PHANToM origin

void SculptDemoApp::triangle_cb void *  userdata,
SoCallbackAction *  action,
const SoPrimitiveVertex *  v1,
const SoPrimitiveVertex *  v2,
const SoPrimitiveVertex *  v3
[static]
 

void SculptDemoApp::update Subject subj  )  [virtual]
 

The Observer Pattern provides a very easy way to update one object as a result of notification sent by another. The Observer is attached to a Subject object. At some point during execution, Subject::notify() will trigger this method. This state of the subject must be pulled by performing a cast and checking for the appropriate information. In this case, the check must determine whether or not the Subject is being touched by the PHANToM. The purpose is to set the m_canTranslate flag as appropriate.

Parameters:
subj - observed subject which has sent notification

Implements Observer.

void SculptDemoApp::update  )  [virtual]
 

Update method called from main will check the stylus button.

Called once per cycle of the main loop, this function handles checking the PHANToM stylus to manage the use of the translation manipulator. It controls the logic for starting and stopping the manipulator.


Member Data Documentation

int SculptDemoApp::autoSculpt [protected]
 

unsigned char*** SculptDemoApp::buffer3d [protected]
 

SoSeparator* SculptDemoApp::catchSeparator [protected]
 

float SculptDemoApp::csize [protected]
 

int SculptDemoApp::csSize [protected]
 

gstPoint SculptDemoApp::currentPosition [protected]
 

float SculptDemoApp::defd [protected]
 

float SculptDemoApp::defh [protected]
 

float SculptDemoApp::defw [protected]
 

gstSeparator* SculptDemoApp::hapdefectSep [protected]
 

bool SculptDemoApp::m_canRotate [protected]
 

Whether or not use of the rotation manipulator is enabled.

bool SculptDemoApp::m_canTranslate [protected]
 

Whether or not use of the translation manipulator is enabled.

SculptConfig* SculptDemoApp::m_config [protected]
 

int SculptDemoApp::m_currentTool [protected]
 

SbBox3f SculptDemoApp::m_defectBounds
 

SbString SculptDemoApp::m_defectFilename [protected]
 

SoTransform* SculptDemoApp::m_defectFitTransform [protected]
 

SoGroup* SculptDemoApp::m_defectGroup [protected]
 

IVFile* SculptDemoApp::m_defectMesh [protected]
 

SoSeparator* SculptDemoApp::m_defectSep [protected]
 

SoSwitch* SculptDemoApp::m_defectSwitch [protected]
 

SoTransform* SculptDemoApp::m_defectTransform [protected]
 

SoSeparator* SculptDemoApp::m_ghostSep [protected]
 

Separator under which the haptic scene is contained.

gstSeparator * SculptDemoApp::m_hapCube [protected]
 

GHOST scene graph root node.

gstSeparator* SculptDemoApp::m_hapFitSeparator [protected]
 

gstSeparator* SculptDemoApp::m_hapRoot [protected]
 

GHOST scene graph root node.

gstScene* SculptDemoApp::m_hapScene [protected]
 

GHOST scene graph.

SoSwitch* SculptDemoApp::m_hapSwitch [protected]
 

SbBox3f SculptDemoApp::m_implantBounds
 

gstPHANToM* SculptDemoApp::m_phantom [protected]
 

GHOST PHANToM device instance.

SoTransform* SculptDemoApp::m_phantomOffset [protected]
 

Transform of the PHANToM device offset from the CAVE origin.

gstPHANToM_SCP* SculptDemoApp::m_phantomSCP [protected]
 

PHANToM surface contact point.

SoTransform* SculptDemoApp::m_phantomTransform [protected]
 

Transform representing the PHANToM.

gstRotateManipulator* SculptDemoApp::m_rotateManip [protected]
 

GHOST dynamic rotation manipulator.

int SculptDemoApp::m_stylusButtonOn [protected]
 

Current status of the PHANToM stylus button.

gstSeparator * SculptDemoApp::m_tempHapRoot [protected]
 

GHOST scene graph root node.

SbBox3f SculptDemoApp::m_toolBounds
 

SoGroup* SculptDemoApp::m_toolGroup [protected]
 

SoAsciiText* SculptDemoApp::m_toolNameText [protected]
 

gstTranslateManipulator* SculptDemoApp::m_translateManip [protected]
 

GHOST dynamic translation manipulator.

CrWandController* SculptDemoApp::m_wand [protected]
 

CrGrabberTool* SculptDemoApp::m_wandPointer [protected]
 

SoSwitch* SculptDemoApp::m_wandSwitch [protected]
 

SbBox3f SculptDemoApp::m_workspaceSize [protected]
 

Box storing the available PHANToM workspace size.

float SculptDemoApp::maxsize [protected]
 

SoSeparator * SculptDemoApp::newCubeSep [protected]
 

Separator under which the haptic scene is contained.

int SculptDemoApp::nurbed [protected]
 

gstPoint SculptDemoApp::previousPosition [protected]
 

SoSphere* SculptDemoApp::ptr [protected]
 

gstSeparator * SculptDemoApp::rootGHOSTSep [protected]
 

GHOST scene graph root node.

SoTransformSeparator* SculptDemoApp::rootOIVSep [protected]
 

int SculptDemoApp::sculptFlag [protected]
 

SculptCube* SculptDemoApp::tempCube [protected]
 


The documentation for this class was generated from the following files:
Generated on Wed May 18 01:24:59 2005 for SculptDemo by  doxygen 1.4.3