bool PlyReader::requestProperty(const std::string& elementName, const std::string& propertyName, int dataType, int dataOffset, int countType, int countOffset) { SURGSIM_ASSERT(isValid()) << "'" << m_filename << "' is an invalid .ply file"; SURGSIM_ASSERT(hasElement(elementName)) << "The element <" << elementName << "> has not been requested yet, you cannot access properties for it"; SURGSIM_ASSERT(hasProperty(elementName, propertyName)) << "The requested property <" << propertyName << "> cannot be found in element <" << elementName << ">."; bool result = false; bool scalar = isScalar(elementName, propertyName); bool wantScalar = (countType == 0); if (wantScalar && !scalar) { SURGSIM_FAILURE() << "Trying to access a list property as a scalar." << "for element <" << elementName << "> and property <" << propertyName << ">."; } else if (!wantScalar && scalar) { SURGSIM_FAILURE() << "Trying to access a scalar property as a list." << "for element <" << elementName << "> and property <" << propertyName << ">."; } if (hasProperty(elementName, propertyName) && (scalar == wantScalar)) { auto itBegin = std::begin(m_requestedElements[elementName].requestedProperties); auto itEnd = std::end(m_requestedElements[elementName].requestedProperties); bool doAdd = std::find_if(itBegin, itEnd, [propertyName](PropertyInfo p){return p.propertyName == propertyName;}) == itEnd; if (doAdd) { PropertyInfo info; info.propertyName = propertyName; info.dataType = m_data->types[dataType]; info.dataOffset = dataOffset; info.countType = m_data->types[countType]; info.countOffset = countOffset; m_requestedElements[elementName].requestedProperties.push_back(info); result = true; } } return result; }
bool YAML::convert<std::shared_ptr<SurgSim::Framework::Asset>>::decode( const Node& node, std::shared_ptr<SurgSim::Framework::Asset>& rhs) //NOLINT { bool result = false; if (node.IsMap()) { if (nullptr == rhs) { std::string className = node.begin()->first.as<std::string>(); auto& factory = SurgSim::Framework::Asset::getFactory(); if (factory.isRegistered(className)) { rhs = factory.create(className); } else { SURGSIM_FAILURE() << "Class " << className << " is not registered in the Asset factory."; } } Node data = node.begin()->second; if (data.IsMap()) { rhs->decode(data); } result = true; } return result; }
SurgSim::Math::RigidTransform3d OsgSkeletonRepresentation::getNeutralBonePose(const std::string& name) const { SurgSim::Math::RigidTransform3d pose = SurgSim::Math::RigidTransform3d::Identity(); boost::shared_lock<boost::shared_mutex> lock(m_mutex); auto found = m_bones->find(name); if (found != m_bones->end()) { pose = found->second.neutralPose; } else if (isInitialized()) { SURGSIM_FAILURE() << "Bone with name " << name << " is not present in mesh."; } return std::move(pose); }
void OsgSkeletonRepresentation::setBonePose(const std::string& name, const SurgSim::Math::RigidTransform3d& pose) { boost::unique_lock<boost::shared_mutex> lock(m_mutex); auto found = m_bones->find(name); if (found != m_bones->end()) { found->second.pose = pose; } else if (isInitialized()) { SURGSIM_FAILURE() << "Bone with name " << name << " is not present in mesh."; } else { auto newBone = m_bones->emplace(std::make_pair(name, BoneData())).first; newBone->second.pose = pose; } }
bool OsgSkeletonRepresentation::setupBones() { boost::unique_lock<boost::shared_mutex> lock(m_mutex); BoneBuilder builder(m_skinningShader, m_bones); builder.traverse(*m_skeleton.get()); m_base = builder.getRootTransform(); for (auto bone = m_bones->begin(); bone != m_bones->end();) { if (bone->second.osgBone == nullptr) { SURGSIM_FAILURE() << "Bone with name " << bone->first << " is not present in mesh."; bone = m_bones->erase(bone); } else { ++bone; } } return (m_bones->size() != 0); }
Matrix33d OctreeShape::getSecondMomentOfVolume() const { SURGSIM_FAILURE() << "OctreeShape::getSecondMomentOfVolume not implemented"; return Matrix33d::Zero(); }
double OctreeShape::getVolume() const { SURGSIM_FAILURE() << "OctreeShape::getVolume not implemented"; return 0.0; }
void CombiningOutputComponent::setData(const SurgSim::DataStructures::DataGroup& dataGroup) { SURGSIM_FAILURE() << "Cannot setData on CombiningOutputComponent " << getFullName(); }
std::shared_ptr<Shape> Shape::getTransformed(const RigidTransform3d& pose) const { SURGSIM_FAILURE() << "getTransformed not implemented for " << getClassName(); return nullptr; }