Fem-inl.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 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_FEM_INL_H
#define SURGSIM_PHYSICS_FEM_INL_H
#include "SurgSim/DataStructures/PlyReader.h"
#include "SurgSim/Framework/Log.h"
using SurgSim::DataStructures::PlyReader;
namespace SurgSim
{
namespace Physics
{
template <class VertexData, class Element>
Fem<VertexData, Element>::Fem()
{
}
template <class VertexData, class Element>
size_t Fem<VertexData, Element>::addElement(std::shared_ptr<Element> element)
{
m_elements.push_back(element);
return m_elements.size() - 1;
}
template <class VertexData, class Element>
size_t Fem<VertexData, Element>::getNumElements() const
{
return m_elements.size();
}
template <class VertexData, class Element>
const std::vector<std::shared_ptr<Element>>&
Fem<VertexData, Element>::getElements() const
{
return m_elements;
}
template <class VertexData, class Element>
std::vector<std::shared_ptr<Element>>& Fem<VertexData, Element>::getElements()
{
return m_elements;
}
template <class VertexData, class Element>
std::shared_ptr<Element> Fem<VertexData, Element>::getElement(size_t id) const
{
return m_elements[id];
}
template <class VertexData, class Element>
size_t Fem<VertexData, Element>::addBoundaryCondition(size_t boundaryCondition)
{
m_boundaryConditions.push_back(boundaryCondition);
return m_boundaryConditions.size() - 1;
}
template <class VertexData, class Element>
const std::vector<size_t>& Fem<VertexData, Element>::getBoundaryConditions() const
{
return m_boundaryConditions;
}
template <class VertexData, class Element>
std::vector<size_t>& Fem<VertexData, Element>::getBoundaryConditions()
{
return m_boundaryConditions;
}
template <class VertexData, class Element>
size_t Fem<VertexData, Element>::getBoundaryCondition(size_t id) const
{
return m_boundaryConditions[id];
}
template <class VertexData, class Element> template <class PlyType, class FemType>
bool Fem<VertexData, Element>::loadFemFile(const std::string& filename)
{
SurgSim::DataStructures::PlyReader reader(filename);
if (!reader.isValid())
{
SURGSIM_LOG_SEVERE(SurgSim::Framework::Logger::getDefaultLogger())
<< "'" << filename << "' is an invalid .ply file.";
return false;
}
auto delegate = std::make_shared<PlyType>(
std::dynamic_pointer_cast<FemType>(this->shared_from_this()));
if (!reader.parseWithDelegate(delegate))
{
SURGSIM_LOG_SEVERE(SurgSim::Framework::Logger::getDefaultLogger())
<< "The input file '" << filename << "' does not have the property required by FEM element mesh.";
return false;
}
return true;
}
} // namespace Physics
} // namespace SurgSim
#endif // SURGSIM_PHYSICS_FEM_INL_H
SurgSim::Physics::Fem::getBoundaryCondition
size_t getBoundaryCondition(size_t id) const
Retrieves a specific boundary condition.
Definition: Fem-inl.h:86
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::Fem::getBoundaryConditions
const std::vector< size_t > & getBoundaryConditions() const
Gets entire vector of boundary conditions.
Definition: Fem-inl.h:74
SurgSim::Physics::Fem::getElement
std::shared_ptr< Element > getElement(size_t id) const
Retrieve a specific element from the mesh.
Definition: Fem-inl.h:61
Log.h
The convenience header that provides the entirety of the logging API.
SurgSim::Physics::Fem::addElement
size_t addElement(std::shared_ptr< Element > element)
Adds FEM element to mesh of Element template type.
Definition: Fem-inl.h:35
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::Fem::getElements
const std::vector< std::shared_ptr< Element > > & getElements() const
Gets entire FEM element vector.
Definition: Fem-inl.h:49
SurgSim::Physics::Fem::loadFemFile
bool loadFemFile(const std::string &filename)
Shared loading method for all 3 dimensions.
Definition: Fem-inl.h:91
SurgSim::Physics::Fem::addBoundaryCondition
size_t addBoundaryCondition(size_t boundaryCondition)
Add boundary condition to mesh.
Definition: Fem-inl.h:67
PlyReader.h
SurgSim::Physics::Fem::Fem
Fem()
Default constructor.
Definition: Fem-inl.h:30
SurgSim::DataStructures::PlyReader::isValid
bool isValid() const
Query if this object is valid.
Definition: PlyReader.cpp:89
SurgSim::Framework::Logger::getDefaultLogger
static std::shared_ptr< Logger > getDefaultLogger()
Get default logger.
Definition: Logger.h:116
SurgSim::Physics::Fem::getNumElements
size_t getNumElements() const
Gets number of FEM elements in the mesh.
Definition: Fem-inl.h:42
SurgSim::DataStructures::PlyReader::parseWithDelegate
bool parseWithDelegate(std::shared_ptr< PlyReaderDelegate > delegate)
Sets a delegate for parsing and then parse the file.
Definition: PlyReader.cpp:333
SURGSIM_LOG_SEVERE
#define SURGSIM_LOG_SEVERE(logger)
Logs a message to the specified logger at the SEVERE level.
Definition: LogMacros.h:106