Representation.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-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_PARTICLES_REPRESENTATION_H
#define SURGSIM_PARTICLES_REPRESENTATION_H
#include <memory>
#include <string>
#include "SurgSim/Collision/Representation.h"
#include "SurgSim/Framework/Representation.h"
#include "SurgSim/Math/Vector.h"
#include "SurgSim/Particles/Particles.h"
namespace SurgSim
{
namespace Framework
{
class Logger;
};
namespace Particles
{
class Representation : public SurgSim::Framework::Representation
{
public:
explicit Representation(const std::string& name);
virtual ~Representation();
void setMaxParticles(size_t maxParticles);
size_t getMaxParticles() const;
bool addParticle(const Particle& particle);
bool addParticle(const Math::Vector3d& position, const Math::Vector3d& velocity, double lifetime);
void removeParticle(size_t index);
SurgSim::DataStructures::BufferedValue<Particles>& getParticles();
void update(double dt);
void handleCollisions(double dt);
void setCollisionRepresentation(std::shared_ptr<SurgSim::Collision::Representation> representation);
std::shared_ptr<SurgSim::Collision::Representation> getCollisionRepresentation() const;
protected:
virtual bool doUpdate(double dt) = 0;
virtual bool doHandleCollisions(double dt, const SurgSim::Collision::ContactMapType& collisions) = 0;
bool doInitialize() override;
size_t m_maxParticles;
SurgSim::DataStructures::BufferedValue<Particles> m_particles;
std::shared_ptr<SurgSim::Framework::Logger> m_logger;
std::shared_ptr<SurgSim::Collision::Representation> m_collisionRepresentation;
};
}; // namespace Particles
}; // namespace SurgSim
#endif // SURGSIM_PARTICLES_REPRESENTATION_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::BufferedValue
BufferedValue is a class to enable a representation of two values for one variable, where both values need to be accessible at the same time, one in a thread safe, single threaded context, the other in a thread unsafe context.
Definition: BufferedValue.h:33
SurgSim::Particles::Representation
The Representation class defines the base class for all Particle System.
Definition: Representation.h:40
SurgSim::Particles::Particles
DataStructures::Vertices< ParticleData > Particles
Definition: Particles.h:53
SurgSim::DataStructures::Vertex
Vertex structure for meshes.
Definition: Vertex.h:44
Representation.h
SurgSim::Collision::ContactMapType
std::unordered_map< std::shared_ptr< SurgSim::Collision::Representation >, std::list< std::shared_ptr< SurgSim::Collision::Contact > > > ContactMapType
Definition: Representation.h:47
Representation.h
SurgSim::Particles::Representation::m_particles
SurgSim::DataStructures::BufferedValue< Particles > m_particles
BufferedValue of particles.
Definition: Representation.h:110
Particles.h
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Particles::Representation::m_maxParticles
size_t m_maxParticles
Maximum amount of particles allowed in this particle system.
Definition: Representation.h:107
SurgSim::Framework::Representation
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
SurgSim::Particles::Representation::m_collisionRepresentation
std::shared_ptr< SurgSim::Collision::Representation > m_collisionRepresentation
This entity&#39;s collision representation.
Definition: Representation.h:116
SurgSim::Particles::Representation::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the particle system.
Definition: Representation.h:113
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57