Emitter.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, 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_EMITTER_H
#define SURGSIM_PARTICLES_EMITTER_H
#include <cmath>
#include <memory>
#include <random>
#include "SurgSim/Framework/ObjectFactory.h"
#include "SurgSim/Framework/Behavior.h"
#include "SurgSim/Math/Vector.h"
#include "SurgSim/Particles/RandomPointGenerator.h"
namespace SurgSim
{
namespace Framework
{
class Logger;
};
namespace Math
{
class Shape;
};
namespace Particles
{
class Representation;
enum EmitMode
{
EMIT_MODE_VOLUME = 0,
EMIT_MODE_SURFACE,
EMIT_MODE_COUNT
};
SURGSIM_STATIC_REGISTRATION(Emitter);
class Emitter : public SurgSim::Framework::Behavior
{
public:
explicit Emitter(const std::string& name);
virtual ~Emitter();
SURGSIM_CLASSNAME(SurgSim::Particles::Emitter);
void update(double dt) override;
int getTargetManagerType() const override;
void setTarget(const std::shared_ptr<SurgSim::Framework::Component> target);
const std::shared_ptr<SurgSim::Framework::Component> getTarget();
void setShape(std::shared_ptr<SurgSim::Math::Shape> shape);
std::shared_ptr<SurgSim::Math::Shape> getShape() const;
void setMode(int mode);
int getMode() const;
void setRate(double rate);
double getRate() const;
void setLifetimeRange(const std::pair<double, double>& range);
std::pair<double, double> getLifetimeRange() const;
void setVelocityRange(const std::pair<SurgSim::Math::Vector3d, SurgSim::Math::Vector3d>& range);
const std::pair<SurgSim::Math::Vector3d, SurgSim::Math::Vector3d>& getVelocityRange() const;
virtual void setLocalPose(const SurgSim::Math::RigidTransform3d& pose);
virtual SurgSim::Math::RigidTransform3d getLocalPose() const;
virtual SurgSim::Math::RigidTransform3d getPose() const;
private:
bool doInitialize() override;
bool doWakeUp() override;
RandomPointGenerator m_pointGenerator;
int m_mode;
double m_rate;
std::pair<double, double> m_lifetimeRange;
std::pair<SurgSim::Math::Vector3d, SurgSim::Math::Vector3d> m_velocityRange;
double m_particlesNotAdded;
std::mt19937 m_generator;
std::uniform_real_distribution<double> m_zeroOneDistribution;
std::shared_ptr<SurgSim::Math::Shape> m_shape;
std::shared_ptr<SurgSim::Particles::Representation> m_target;
SurgSim::Math::RigidTransform3d m_localPose;
std::shared_ptr<SurgSim::Framework::Logger> m_logger;
};
}; // namespace Particles
}; // namespace SurgSim
#endif // SURGSIM_PARTICLES_EMITTER_H
SurgSim::Particles::EmitMode
EmitMode
Emitting modes of the Emitter.
Definition: Emitter.h:48
SurgSim::Particles::RandomPointGenerator
RandomPointGenerator will generate points based on the shape passed.
Definition: RandomPointGenerator.h:35
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
RandomPointGenerator.h
SurgSim::Particles::Emitter::m_shape
std::shared_ptr< SurgSim::Math::Shape > m_shape
Shape of emitter.
Definition: Emitter.h:167
SurgSim::Particles::EMIT_MODE_COUNT
The number of EmitModes.
Definition: Emitter.h:55
SurgSim::Particles::Emitter::m_mode
int m_mode
The emit mode of this emitter.
Definition: Emitter.h:146
ObjectFactory.h
SurgSim::Particles::Emitter::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the Emitter.
Definition: Emitter.h:176
SurgSim::Particles::Particles
DataStructures::Vertices< ParticleData > Particles
Definition: Particles.h:53
SurgSim::Particles::Emitter::m_localPose
SurgSim::Math::RigidTransform3d m_localPose
Local Pose of the Representation with respect to the SceneElement.
Definition: Emitter.h:173
SurgSim::Particles::Emitter::m_lifetimeRange
std::pair< double, double > m_lifetimeRange
The range of lifetimes of emitted particles.
Definition: Emitter.h:152
Behavior.h
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
SurgSim::Particles::Emitter::m_particlesNotAdded
double m_particlesNotAdded
Number of particles not added during last update.
Definition: Emitter.h:158
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Particles::Emitter
Emitter emits particles into a ParticleSystem.
Definition: Emitter.h:61
SurgSim::Particles::Emitter::m_generator
std::mt19937 m_generator
Definition: Emitter.h:162
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Particles::Emitter::m_rate
double m_rate
The emit rate of this emitter.
Definition: Emitter.h:149
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:40
SurgSim::Particles::Emitter::m_velocityRange
std::pair< SurgSim::Math::Vector3d, SurgSim::Math::Vector3d > m_velocityRange
The range of velocities of the emitted particles.
Definition: Emitter.h:155
SurgSim::Particles::EMIT_MODE_SURFACE
Emit particles only from the surface.
Definition: Emitter.h:53
SurgSim::Particles::EMIT_MODE_VOLUME
Emit particles from within the shapes volume.
Definition: Emitter.h:51
SurgSim::Particles::Emitter::m_pointGenerator
RandomPointGenerator m_pointGenerator
PointGenerator for generating random points within or on the emitter shape.
Definition: Emitter.h:143
SurgSim::Particles::Emitter::m_zeroOneDistribution
std::uniform_real_distribution< double > m_zeroOneDistribution
Definition: Emitter.h:163
SurgSim::Particles::Emitter::m_target
std::shared_ptr< SurgSim::Particles::Representation > m_target
Representation to emit to.
Definition: Emitter.h:170