FemPlyReaderDelegate.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2014-2015, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_PHYSICS_FEMPLYREADERDELEGATE_H
#define SURGSIM_PHYSICS_FEMPLYREADERDELEGATE_H
#include <array>
#include <memory>
#include "SurgSim/DataStructures/PlyReaderDelegate.h"
#include "SurgSim/Physics/Fem.h"
namespace SurgSim
{
namespace Physics
{
class FemPlyReaderDelegate : public SurgSim::DataStructures::PlyReaderDelegate
{
public:
FemPlyReaderDelegate();
protected:
// \return Name of the element (1/2/3D), which this delegate processes.
virtual std::string getElementName() const = 0;
bool registerDelegate(SurgSim::DataStructures::PlyReader* reader) override;
bool fileIsAcceptable(const SurgSim::DataStructures::PlyReader& reader) override;
virtual void endParseFile() = 0;
virtual void* beginVertices(const std::string& elementName, size_t vertexCount);
virtual void processVertex(const std::string& elementName) = 0;
virtual void endVertices(const std::string& elementName);
void* beginFemElements(const std::string& elementName, size_t elementCount);
virtual void processFemElement(const std::string& elementName) = 0;
void endFemElements(const std::string& elementName);
void* beginMaterials(const std::string& elementName, size_t materialCount);
void endMaterials(const std::string& elementName);
void* beginBoundaryConditions(const std::string& elementName, size_t boundaryConditionCount);
virtual void processBoundaryCondition(const std::string& elementName) = 0;
protected:
struct Vertex6DData
{
double x;
double y;
double z;
int64_t overrun1;
double thetaX;
double thetaY;
double thetaZ;
int64_t overrun2;
} m_vertexData;
bool m_hasBoundaryConditions;
unsigned int m_boundaryConditionData;
struct MaterialData
{
double massDensity;
double poissonRatio;
double youngModulus;
int64_t overrun;
} m_materialData;
bool m_hasMaterial;
bool m_hasPerElementMaterial;
struct ElementData
{
unsigned int type; // “LinearBeam”, “CorotationalTetrahedron”…
int64_t overrun1;
unsigned int* indices;
unsigned int vertexCount;
int64_t overrun2;
double massDensity;
double poissonRatio;
double youngModulus;
} m_elementData;
bool m_hasRotationDOF;
};
} // namespace Physics
} // namespace SurgSim
#endif // SURGSIM_PHYSICS_FEMPLYREADERDELEGATE_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::FemPlyReaderDelegate::m_hasMaterial
bool m_hasMaterial
Definition: FemPlyReaderDelegate.h:126
SurgSim::Physics::FemPlyReaderDelegate::MaterialData::youngModulus
double youngModulus
Definition: FemPlyReaderDelegate.h:122
SurgSim::Physics::FemPlyReaderDelegate::MaterialData
Internal data to receive the "material" data.
Definition: FemPlyReaderDelegate.h:118
SurgSim::Physics::FemPlyReaderDelegate::MaterialData::massDensity
double massDensity
Definition: FemPlyReaderDelegate.h:120
SurgSim::Physics::FemPlyReaderDelegate::ElementData::youngModulus
double youngModulus
Definition: FemPlyReaderDelegate.h:140
SurgSim::Physics::FemPlyReaderDelegate::ElementData
Internal data to receive the fem element.
Definition: FemPlyReaderDelegate.h:130
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData::thetaZ
double thetaZ
Definition: FemPlyReaderDelegate.h:107
SurgSim::Physics::FemPlyReaderDelegate::beginMaterials
void * beginMaterials(const std::string &elementName, size_t materialCount)
Callback function, begin the processing of materials.
Definition: FemPlyReaderDelegate.cpp:175
SurgSim::Physics::FemPlyReaderDelegate::ElementData::overrun2
int64_t overrun2
Used to check for buffer overruns.
Definition: FemPlyReaderDelegate.h:137
SurgSim::Physics::FemPlyReaderDelegate::getElementName
virtual std::string getElementName() const =0
SurgSim::Physics::FemPlyReaderDelegate
Common part of implementation of PlyReaderDelegate for FemRepresentations.
Definition: FemPlyReaderDelegate.h:33
SurgSim::Physics::FemPlyReaderDelegate::FemPlyReaderDelegate
FemPlyReaderDelegate()
Constructor.
Definition: FemPlyReaderDelegate.cpp:27
SurgSim::Physics::FemPlyReaderDelegate::endVertices
virtual void endVertices(const std::string &elementName)
Callback function to finalize processing of vertices.
Definition: FemPlyReaderDelegate.cpp:153
SurgSim::Physics::FemPlyReaderDelegate::ElementData::vertexCount
unsigned int vertexCount
Definition: FemPlyReaderDelegate.h:136
SurgSim::Physics::FemPlyReaderDelegate::m_hasRotationDOF
bool m_hasRotationDOF
Definition: FemPlyReaderDelegate.h:142
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData::thetaY
double thetaY
Definition: FemPlyReaderDelegate.h:106
SurgSim::Physics::FemPlyReaderDelegate::m_hasPerElementMaterial
bool m_hasPerElementMaterial
Definition: FemPlyReaderDelegate.h:127
SurgSim::Physics::FemPlyReaderDelegate::m_materialData
struct SurgSim::Physics::FemPlyReaderDelegate::MaterialData m_materialData
SurgSim::Physics::FemPlyReaderDelegate::m_vertexData
struct SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData m_vertexData
SurgSim::Physics::FemPlyReaderDelegate::ElementData::poissonRatio
double poissonRatio
Definition: FemPlyReaderDelegate.h:139
SurgSim::DataStructures::PlyReader
Wrapper for the C .ply file parser This class wraps the main functionality for the original C ...
Definition: PlyReader.h:85
SurgSim::Physics::FemPlyReaderDelegate::m_boundaryConditionData
unsigned int m_boundaryConditionData
Internal data to receive the "boundary_condition" element.
Definition: FemPlyReaderDelegate.h:115
SurgSim::Physics::FemPlyReaderDelegate::ElementData::overrun1
int64_t overrun1
Used to check for buffer overruns.
Definition: FemPlyReaderDelegate.h:133
SurgSim::Physics::FemPlyReaderDelegate::ElementData::indices
unsigned int * indices
Definition: FemPlyReaderDelegate.h:135
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData
Vertex data containing 6 dofs (3 translational and 3 rotational)
Definition: FemPlyReaderDelegate.h:99
SurgSim::Physics::FemPlyReaderDelegate::beginFemElements
void * beginFemElements(const std::string &elementName, size_t elementCount)
Callback function, begin the processing of FemElements.
Definition: FemPlyReaderDelegate.cpp:160
SurgSim::Physics::FemPlyReaderDelegate::processBoundaryCondition
virtual void processBoundaryCondition(const std::string &elementName)=0
Callback function to process one boundary condition.
SurgSim::Physics::FemPlyReaderDelegate::beginVertices
virtual void * beginVertices(const std::string &elementName, size_t vertexCount)
Callback function, begin the processing of vertices.
Definition: FemPlyReaderDelegate.cpp:147
SurgSim::Physics::FemPlyReaderDelegate::beginBoundaryConditions
void * beginBoundaryConditions(const std::string &elementName, size_t boundaryConditionCount)
Callback function, begin the processing of boundary conditions.
Definition: FemPlyReaderDelegate.cpp:188
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData::x
double x
Definition: FemPlyReaderDelegate.h:101
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData::y
double y
Definition: FemPlyReaderDelegate.h:102
SurgSim::Physics::FemPlyReaderDelegate::processFemElement
virtual void processFemElement(const std::string &elementName)=0
Callback function to process one FemElement.
SurgSim::Physics::FemPlyReaderDelegate::endFemElements
void endFemElements(const std::string &elementName)
Callback function to finalize processing of FemElements.
Definition: FemPlyReaderDelegate.cpp:167
SurgSim::Physics::FemPlyReaderDelegate::registerDelegate
bool registerDelegate(SurgSim::DataStructures::PlyReader *reader) override
Registers the delegate with the reader.
Definition: FemPlyReaderDelegate.cpp:31
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData::thetaX
double thetaX
Definition: FemPlyReaderDelegate.h:105
SurgSim::Physics::FemPlyReaderDelegate::ElementData::type
unsigned int type
Definition: FemPlyReaderDelegate.h:132
SurgSim::Physics::FemPlyReaderDelegate::endMaterials
void endMaterials(const std::string &elementName)
Callback function, end the processing of materials.
Definition: FemPlyReaderDelegate.cpp:181
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData::overrun2
int64_t overrun2
Used to check for buffer overruns.
Definition: FemPlyReaderDelegate.h:108
PlyReaderDelegate.h
SurgSim::Physics::FemPlyReaderDelegate::processVertex
virtual void processVertex(const std::string &elementName)=0
Callback function to process one vertex.
SurgSim::Physics::FemPlyReaderDelegate::m_elementData
struct SurgSim::Physics::FemPlyReaderDelegate::ElementData m_elementData
SurgSim::Physics::FemPlyReaderDelegate::MaterialData::overrun
int64_t overrun
Used to check for buffer overruns.
Definition: FemPlyReaderDelegate.h:123
SurgSim::Physics::FemPlyReaderDelegate::endParseFile
virtual void endParseFile()=0
Callback for end of PlyReader::parseFile.
SurgSim::Physics::FemPlyReaderDelegate::ElementData::massDensity
double massDensity
Definition: FemPlyReaderDelegate.h:138
SurgSim::Physics::FemPlyReaderDelegate::fileIsAcceptable
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...
Definition: FemPlyReaderDelegate.cpp:113
SurgSim::Physics::FemPlyReaderDelegate::m_hasBoundaryConditions
bool m_hasBoundaryConditions
Flag indicating if the associated file has boundary conditions.
Definition: FemPlyReaderDelegate.h:112
Fem.h
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData::overrun1
int64_t overrun1
Used to check for buffer overruns.
Definition: FemPlyReaderDelegate.h:104
SurgSim::Physics::FemPlyReaderDelegate::Vertex6DData::z
double z
Definition: FemPlyReaderDelegate.h:103
SurgSim::Physics::FemPlyReaderDelegate::MaterialData::poissonRatio
double poissonRatio
Definition: FemPlyReaderDelegate.h:121
SurgSim::DataStructures::PlyReaderDelegate
PlyReaderDelegate abstract class.
Definition: PlyReaderDelegate.h:31