sofa::component::collision::SphereTreeModel Class Reference

A Sphere Tree based collision object: No tool to generation .sph file are provided by Sofa. More...

#include <SphereTreeModel.h>

Inheritance diagram for sofa::component::collision::SphereTreeModel:

Inheritance graph
[legend]
Collaboration diagram for sofa::component::collision::SphereTreeModel:

Collaboration graph
[legend]

Public Types

typedef
component::MechanicalObject
< Vec3Types > 
Inherit
typedef Vec3Types InDataTypes
typedef Vec3Types DataTypes
typedef SingleSphere Element

Public Member Functions

 SphereTreeModel (double radius=1.0)
 Constructor.
int addSphere (const Vector3 &pos, SReal radius)
 Add a new sphere to the tree.
void setSphere (int index, const Vector3 &pos, SReal radius)
bool load (const char *filename)
 Load SphereTree Model.
void applyScale (const double s)
 Scale the current state.
sofa::core::componentmodel::behavior::MechanicalState
< InDataTypes > * 
getMechanicalState ()
int getSize () const
 Get the number of elements.
virtual void resize (int size)
 Set the number of elements.
virtual void computeBoundingTree (int maxDepth=0)
 It updates the hierarchical bounding tree.
virtual std::pair
< core::CollisionElementIterator,
core::CollisionElementIterator > 
getInternalChildren (int index) const
 Returns a pair of iterators.
virtual void computeContinuousBoundingTree (double dt, int maxDepth=0)
 To do.
void draw (int index)
 Render an collision element.
bool loadSphereTree (const char *fileName)
 Load sphere tree given a filename.
virtual bool isLeaf (int index) const
 It returns true is the element iterator is a leaf of the spheretree collision model.
void draw ()
 Render the whole collision model.

Data Fields

DataTypes::VecCoord VecCoord
 Container of Coord values with the same API as sofa::helper::vector.
int levels
 Levels of the tree of the collision model.
int degree
 Branching factor of the KTree (number of children for each node).

Protected Attributes

sofa::helper::vector< double > radius
 vector of radii of spheres in the model
Data< double > defaultRadius
 default radius

Friends

class SingleSphere

Detailed Description

A Sphere Tree based collision object: No tool to generation .sph file are provided by Sofa.

Tools can be found at http://isg.cs.tcd.ie/spheretree/ . If you manage to integrate an automatic generation tool to provide .sph files from .obj, don't hesitate to share it to the Sofa's comunity.

Definition at line 99 of file SphereTreeModel.h.


Member Typedef Documentation

Definition at line 105 of file SphereTreeModel.h.

Definition at line 103 of file SphereTreeModel.h.

Definition at line 102 of file SphereTreeModel.h.


Constructor & Destructor Documentation

sofa::component::collision::SphereTreeModel::SphereTreeModel ( double  radius = 1.0  ) 

Constructor.

Definition at line 58 of file SphereTreeModel.cpp.


Member Function Documentation

int sofa::component::collision::SphereTreeModel::addSphere ( const Vector3 &  pos,
SReal  radius 
)

Add a new sphere to the tree.

It actually increases the size of the DOF's of the model setting the radius and the center

Definition at line 82 of file SphereTreeModel.cpp.

References resize(), setSphere(), and sofa::core::CollisionModel::size.

void sofa::component::collision::SphereTreeModel::applyScale ( const double  s  )  [virtual]

void sofa::component::collision::SphereTreeModel::computeBoundingTree ( int  maxDepth = 0  )  [virtual]

It updates the hierarchical bounding tree.

Implements sofa::core::CollisionModel.

Definition at line 274 of file SphereTreeModel.cpp.

void sofa::component::collision::SphereTreeModel::computeContinuousBoundingTree ( double  dt,
int  maxDepth = 0 
) [virtual]

To do.

Reimplemented from sofa::core::CollisionModel.

Definition at line 281 of file SphereTreeModel.cpp.

void sofa::component::collision::SphereTreeModel::draw (  )  [virtual]

void sofa::component::collision::SphereTreeModel::draw ( int   )  [virtual]

Render an collision element.

Reimplemented from sofa::core::CollisionModel.

Definition at line 217 of file SphereTreeModel.cpp.

References sofa::component::MechanicalObject< DataTypes >::getX(), and radius.

std::pair< core::CollisionElementIterator, core::CollisionElementIterator > sofa::component::collision::SphereTreeModel::getInternalChildren ( int  index  )  const [virtual]

Returns a pair of iterators.

The first corresponds to the first child of iterator given by the index. The second element of the pair corresponds to the last children of collisionElementIterator index

Reimplemented from sofa::core::CollisionModel.

Definition at line 286 of file SphereTreeModel.cpp.

References degree, and sofa::core::CollisionModel::size.

sofa::core::componentmodel::behavior::MechanicalState<InDataTypes>* sofa::component::collision::SphereTreeModel::getMechanicalState (  )  [inline]

Definition at line 125 of file SphereTreeModel.h.

int sofa::component::collision::SphereTreeModel::getSize (  )  const [inline]

Get the number of elements.

Reimplemented from sofa::core::CollisionModel.

Definition at line 130 of file SphereTreeModel.h.

References sofa::component::MechanicalObject< DataTypes >::getSize().

bool sofa::component::collision::SphereTreeModel::isLeaf ( int  index  )  const [virtual]

It returns true is the element iterator is a leaf of the spheretree collision model.

Reimplemented from sofa::core::CollisionModel.

Definition at line 297 of file SphereTreeModel.cpp.

References degree, and sofa::core::CollisionModel::size.

Referenced by loadSphereTree().

bool sofa::component::collision::SphereTreeModel::load ( const char *  filename  )  [virtual]

Load SphereTree Model.

The file is generated offline using a medial axis approximation Windows executables to obtain the file are available at cesarmendoza_serrano@yahoo.fr

Reimplemented from sofa::component::MechanicalObject< DataTypes >.

Definition at line 97 of file SphereTreeModel.cpp.

References loadSphereTree(), and resize().

bool sofa::component::collision::SphereTreeModel::loadSphereTree ( const char *  fileName  ) 

Load sphere tree given a filename.

To obtain executables (win32) to obtain this sphere tree files hierarchies, please email: cesarmendoza_serrano@yahoo.fr

Definition at line 103 of file SphereTreeModel.cpp.

References sofa::core::CollisionModel::begin(), sofa::helper::system::DataRepository, degree, sofa::core::CollisionModel::end(), isLeaf(), levels, radius, resize(), sofa::component::collision::SingleSphere::setCenter(), and sofa::component::MechanicalObject< DataTypes >::x.

Referenced by load().

void sofa::component::collision::SphereTreeModel::resize ( int  s  )  [virtual]

Set the number of elements.

Reimplemented from sofa::core::CollisionModel.

Definition at line 64 of file SphereTreeModel.cpp.

References defaultRadius, sofa::core::objectmodel::Data< T >::getValue(), and radius.

Referenced by addSphere(), load(), and loadSphereTree().

void sofa::component::collision::SphereTreeModel::setSphere ( int  index,
const Vector3 &  pos,
SReal  radius 
)


Friends And Related Function Documentation

friend class SingleSphere [friend]

Definition at line 106 of file SphereTreeModel.h.


Field Documentation

default radius

Definition at line 169 of file SphereTreeModel.h.

Referenced by resize().

Branching factor of the KTree (number of children for each node).

Definition at line 152 of file SphereTreeModel.h.

Referenced by draw(), getInternalChildren(), isLeaf(), and loadSphereTree().

Levels of the tree of the collision model.

Definition at line 149 of file SphereTreeModel.h.

Referenced by draw(), and loadSphereTree().

vector of radii of spheres in the model

Definition at line 166 of file SphereTreeModel.h.

Referenced by applyScale(), draw(), loadSphereTree(), resize(), and setSphere().

Container of Coord values with the same API as sofa::helper::vector.

Reimplemented from sofa::component::MechanicalObject< DataTypes >.

Definition at line 107 of file SphereTreeModel.h.


The documentation for this class was generated from the following files:

Generated on Sun Nov 23 04:17:37 2008 for Sofa by  doxygen 1.5.7.1