opensurgsim
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SurgSim::Physics::MassSpringPlyReaderDelegate Class Reference

Common part of implementation of PlyReaderDelegate for MassSpringRepresentations. More...

#include <MassSpringPlyReaderDelegate.h>

Inheritance diagram for SurgSim::Physics::MassSpringPlyReaderDelegate:
SurgSim::DataStructures::PlyReaderDelegate

Classes

struct  ElementData
 Internal data to receive the element (nodeId) data. More...
 
struct  MassData
 Mass data containing 3 translational dofs and mass. More...
 
struct  SpringData
 Internal data to receive the spring (stretching and bending) data. More...
 

Public Member Functions

 MassSpringPlyReaderDelegate ()
 Default constructor.
 
 MassSpringPlyReaderDelegate (std::shared_ptr< MassSpringModel > mesh)
 Constructor.
 
- Public Member Functions inherited from SurgSim::DataStructures::PlyReaderDelegate
virtual ~PlyReaderDelegate ()
 Virtual destructor.
 

Protected Member Functions

bool registerDelegate (SurgSim::DataStructures::PlyReader *reader) override
 Registers the delegate with the reader. More...
 
bool fileIsAcceptable (const SurgSim::DataStructures::PlyReader &reader) override
 Check whether the file in the reader can be used with this delegate, this gives the delegate a chance to make sure that all the elements and properties that are required are available in the file encapsulated by the reader.
 
virtual void endParseFile ()
 Callback for end of PlyReader::parseFile.
 
virtual void * beginVertices (const std::string &elementName, size_t vertexCount)
 Callback function, begin the processing of vertices. More...
 
virtual void processVertex (const std::string &elementName)
 Callback function to process one vertex. More...
 
virtual void endVertices (const std::string &elementName)
 Callback function to finalize processing of vertices. More...
 
void * beginElements (const std::string &elementName, size_t elementCount)
 Callback function, begin the processing of Elements. More...
 
virtual void processElement (const std::string &elementName)
 Callback function to process one Element. More...
 
void endElements (const std::string &elementName)
 Callback function to finalize processing of Elements. More...
 
void * beginSprings (const std::string &elementName, size_t elementCount)
 Callback function, begin the processing of Springs. More...
 
virtual void processSpring (const std::string &elementName)
 Callback function to process one Spring. More...
 
void endSprings (const std::string &elementName)
 Callback function to finalize processing of Springs. More...
 
void * beginBoundaryConditions (const std::string &elementName, size_t boundaryConditionCount)
 Callback function, begin the processing of boundary conditions. More...
 
virtual void processBoundaryCondition (const std::string &elementName)
 Callback function to process one boundary condition. More...
 
void * beginRadius (const std::string &elementName, size_t radiusCount)
 Callback function, begin the processing of radius. More...
 
void endRadius (const std::string &elementName)
 Callback function, end the processing of radius. More...
 
void * beginThickness (const std::string &elementName, size_t thicknessCount)
 Callback function, begin the processing of thickness. More...
 
void endThickness (const std::string &elementName)
 Callback function, end the processing of thickness. More...
 

Protected Attributes

struct SurgSim::Physics::MassSpringPlyReaderDelegate::MassData m_massData
 
bool m_hasBoundaryConditions = false
 Flag indicating if the associated file has boundary conditions.
 
unsigned int m_boundaryConditionData = 0
 Internal data to receive the "boundary_condition" element.
 
bool m_has1dElement = false
 Flag indicating if the associated file has 1d elements.
 
bool m_has2dElement = false
 Flag indicating if the associated file has 2d elements.
 
bool m_has3dElement = false
 Flag indicating if the associated file has 3d elements.
 
struct SurgSim::Physics::MassSpringPlyReaderDelegate::ElementData m_elementData
 
struct SurgSim::Physics::MassSpringPlyReaderDelegate::SpringData m_springData
 
bool m_hasRadius = false
 Flag indicating if the associated file has a radius.
 
double m_radius = std::numeric_limits<double>::signaling_NaN()
 Radius information, if any.
 
bool m_hasThickness = false
 Flag indicating if the associated file has a thickness.
 
double m_thickness = std::numeric_limits<double>::signaling_NaN()
 Thickness information, if any.
 
std::shared_ptr< MassSpringModelm_mesh
 MassSpringModel to contain the ply file information.
 

Detailed Description

Common part of implementation of PlyReaderDelegate for MassSpringRepresentations.

In order for the same ply file to load with TriangleMeshPlyReaderDelegate (e.g., to create the graphics for a SegmentMesh or to match the shape in a CollisionRep), there must be elements named (for example) 1d_element, that have appropriate vertex_indices. See MassSpringRepresentation::saveMassSpringModel() or MassSpring::saveMassSpringModel() to create a valid ply file.

Example file that can also be loaded into a SegmentMesh; the third spring resists bending about the middle vertex: ply format ascii 1.0 element vertex 3 property double x property double y property double z property double mass element 1d_element 2 property list uint uint vertex_indices element spring 3 property list uint uint vertex_indices property double stiffness property double damping element boundary_condition 0 property uint vertex_index element radius 1 property double value end_header -0.02 -0.04 -0.001 0.001 -0.01 -0.03 -0.00075 0.002 0.0 0.0 0.0 0.002 2 0 1 2 1 2 2 0 1 5 10 2 1 2 5 10 2 0 2 3 10 0.001

This PlyReaderDelegate can load 1d_element, 2d_element, or 3d_element, passing the vectors of nodes to the MassSpringModel. Similarly, it can load radius or thickness.

Member Function Documentation

§ beginBoundaryConditions()

void * SurgSim::Physics::MassSpringPlyReaderDelegate::beginBoundaryConditions ( const std::string &  elementName,
size_t  boundaryConditionCount 
)
protected

Callback function, begin the processing of boundary conditions.

Parameters
elementNameName of the element.
boundaryConditionCountNumber of boundary conditions.
Returns
memory for boundary conditions data to the reader.

§ beginElements()

void * SurgSim::Physics::MassSpringPlyReaderDelegate::beginElements ( const std::string &  elementName,
size_t  elementCount 
)
protected

Callback function, begin the processing of Elements.

Parameters
elementNameName of the element.
elementCountNumber of elements.
Returns
memory for Elements data to the reader.

§ beginRadius()

void * SurgSim::Physics::MassSpringPlyReaderDelegate::beginRadius ( const std::string &  elementName,
size_t  radiusCount 
)
protected

Callback function, begin the processing of radius.

Parameters
elementNameName of the element.
radiusCountNumber of radii.
Returns
memory for radius data to the reader.

§ beginSprings()

void * SurgSim::Physics::MassSpringPlyReaderDelegate::beginSprings ( const std::string &  elementName,
size_t  elementCount 
)
protected

Callback function, begin the processing of Springs.

Parameters
elementNameName of the element.
elementCountNumber of elements.
Returns
memory for Springs data to the reader.

§ beginThickness()

void * SurgSim::Physics::MassSpringPlyReaderDelegate::beginThickness ( const std::string &  elementName,
size_t  thicknessCount 
)
protected

Callback function, begin the processing of thickness.

Parameters
elementNameName of the element.
thicknessCountNumber of radii.
Returns
memory for thickness data to the reader.

§ beginVertices()

void * SurgSim::Physics::MassSpringPlyReaderDelegate::beginVertices ( const std::string &  elementName,
size_t  vertexCount 
)
protectedvirtual

Callback function, begin the processing of vertices.

Parameters
elementNameName of the element.
vertexCountNumber of vertices.
Returns
memory for mass data to the reader.

§ endElements()

void SurgSim::Physics::MassSpringPlyReaderDelegate::endElements ( const std::string &  elementName)
protected

Callback function to finalize processing of Elements.

Parameters
elementNameName of the element.

§ endRadius()

void SurgSim::Physics::MassSpringPlyReaderDelegate::endRadius ( const std::string &  elementName)
protected

Callback function, end the processing of radius.

Parameters
elementNameName of the element.

§ endSprings()

void SurgSim::Physics::MassSpringPlyReaderDelegate::endSprings ( const std::string &  elementName)
protected

Callback function to finalize processing of Springs.

Parameters
elementNameName of the element.

§ endThickness()

void SurgSim::Physics::MassSpringPlyReaderDelegate::endThickness ( const std::string &  elementName)
protected

Callback function, end the processing of thickness.

Parameters
elementNameName of the element.

§ endVertices()

void SurgSim::Physics::MassSpringPlyReaderDelegate::endVertices ( const std::string &  elementName)
protectedvirtual

Callback function to finalize processing of vertices.

Parameters
elementNameName of the element.

§ processBoundaryCondition()

void SurgSim::Physics::MassSpringPlyReaderDelegate::processBoundaryCondition ( const std::string &  elementName)
protectedvirtual

Callback function to process one boundary condition.

Parameters
elementNameName of the element.

§ processElement()

void SurgSim::Physics::MassSpringPlyReaderDelegate::processElement ( const std::string &  elementName)
protectedvirtual

Callback function to process one Element.

Parameters
elementNameName of the element.

§ processSpring()

void SurgSim::Physics::MassSpringPlyReaderDelegate::processSpring ( const std::string &  elementName)
protectedvirtual

Callback function to process one Spring.

Parameters
elementNameName of the element.

§ processVertex()

void SurgSim::Physics::MassSpringPlyReaderDelegate::processVertex ( const std::string &  elementName)
protectedvirtual

Callback function to process one vertex.

Parameters
elementNameName of the element.

§ registerDelegate()

bool SurgSim::Physics::MassSpringPlyReaderDelegate::registerDelegate ( SurgSim::DataStructures::PlyReader reader)
overrideprotectedvirtual

Registers the delegate with the reader.

Parameters
[out]readerThe reader that should be used by the delegate.
Returns
true usually if the reader is valid and fileIsAcceptable() is true.

Implements SurgSim::DataStructures::PlyReaderDelegate.


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