opensurgsim
Representation.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2015, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_PARTICLES_REPRESENTATION_H
17 #define SURGSIM_PARTICLES_REPRESENTATION_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "SurgSim/Collision/Representation.h"
23 #include "SurgSim/Framework/Representation.h"
24 #include "SurgSim/Math/Vector.h"
25 #include "SurgSim/Particles/Particles.h"
26 
27 
28 namespace SurgSim
29 {
30 
31 namespace Framework
32 {
33 class Logger;
34 };
35 
36 namespace Particles
37 {
38 
41 {
42 public:
45  explicit Representation(const std::string& name);
46 
48  virtual ~Representation();
49 
53  void setMaxParticles(size_t maxParticles);
54 
56  size_t getMaxParticles() const;
57 
61  bool addParticle(const Particle& particle);
62 
68  bool addParticle(const Math::Vector3d& position, const Math::Vector3d& velocity, double lifetime);
69 
73  void removeParticle(size_t index);
74 
78 
81  void update(double dt);
82 
85  void handleCollisions(double dt);
86 
89  void setCollisionRepresentation(std::shared_ptr<SurgSim::Collision::Representation> representation);
90 
93  std::shared_ptr<SurgSim::Collision::Representation> getCollisionRepresentation() const;
94 
95 protected:
98  virtual bool doUpdate(double dt) = 0;
99 
102  virtual bool doHandleCollisions(double dt, const SurgSim::Collision::ContactMapType& collisions) = 0;
103 
104  bool doInitialize() override;
105 
108 
111 
113  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
114 
116  std::shared_ptr<SurgSim::Collision::Representation> m_collisionRepresentation;
117 };
118 
119 }; // namespace Particles
120 }; // namespace SurgSim
121 
122 #endif // SURGSIM_PARTICLES_REPRESENTATION_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
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
The Representation class defines the base class for all Particle System.
Definition: Representation.h:40
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
Vertex structure for meshes.
Definition: Vertex.h:44
SurgSim::DataStructures::BufferedValue< Particles > m_particles
BufferedValue of particles.
Definition: Representation.h:110
Definitions of small fixed-size vector types.
size_t m_maxParticles
Maximum amount of particles allowed in this particle system.
Definition: Representation.h:107
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
std::shared_ptr< SurgSim::Collision::Representation > m_collisionRepresentation
This entity&#39;s collision representation.
Definition: Representation.h:116
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the particle system.
Definition: Representation.h:113