OsgVectorFieldRepresentation.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_GRAPHICS_OSGVECTORFIELDREPRESENTATION_H
#define SURGSIM_GRAPHICS_OSGVECTORFIELDREPRESENTATION_H
#include "SurgSim/Framework/LockedContainer.h"
#include "SurgSim/Graphics/OsgRepresentation.h"
#include "SurgSim/Graphics/VectorFieldRepresentation.h"
#include "SurgSim/Graphics/VectorField.h"
#include <osg/Array>
#include <osg/Geometry>
#include <osg/LineWidth>
#include <osg/Point>
namespace SurgSim
{
namespace Graphics
{
SURGSIM_STATIC_REGISTRATION(OsgVectorFieldRepresentation);
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4250)
#endif
class OsgVectorFieldRepresentation : public VectorFieldRepresentation, public OsgRepresentation
{
public:
explicit OsgVectorFieldRepresentation(const std::string& name);
~OsgVectorFieldRepresentation();
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgVectorFieldRepresentation);
std::shared_ptr<VectorField> getVectorField() const override;
void setLineWidth(double width) override;
double getLineWidth() const override;
void setScale(double scale) override;
double getScale() const override;
virtual void setPointSize(double size);
virtual double getPointSize() const;
void doUpdate(double dt) override;
void updateVectorField(const VectorField& vectorfield) override;
private:
void privateUpdate(const std::vector<DataStructures::Vertex<VectorFieldData>>& vertices);
std::shared_ptr<SurgSim::Graphics::VectorField> m_vectorField;
SurgSim::Framework::LockedContainer<VectorField> m_writeBuffer;
osg::ref_ptr<osg::Vec3Array> m_vertexData;
osg::ref_ptr<osg::Geometry> m_lineGeometry;
osg::ref_ptr<osg::Geometry> m_pointGeometry;
osg::ref_ptr<osg::DrawArrays> m_drawArrays;
osg::ref_ptr<osg::DrawElementsUInt> m_drawPoints;
osg::ref_ptr<osg::LineWidth> m_line;
osg::ref_ptr<osg::Point> m_point;
osg::ref_ptr<osg::Vec4Array> m_colors;
double m_scale;
};
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
}; // Graphics
}; // SurgSim
#endif // SURGSIM_GRAPHICS_OSGVECTORFIELDREPRESENTATION_H
SurgSim::Graphics::OsgVectorFieldRepresentation::privateUpdate
void privateUpdate(const std::vector< DataStructures::Vertex< VectorFieldData >> &vertices)
Definition: OsgVectorFieldRepresentation.cpp:96
SurgSim::Graphics::OsgVectorFieldRepresentation::getScale
double getScale() const override
Gets the scale applied to all vectors.
Definition: OsgVectorFieldRepresentation.cpp:184
SurgSim::Graphics::OsgVectorFieldRepresentation::m_point
osg::ref_ptr< osg::Point > m_point
OSG::Point for representing vector starting point.
Definition: OsgVectorFieldRepresentation.h:98
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgVectorFieldRepresentation
OSG vector field representation, implements a VectorFieldRepresenation using OSG. ...
Definition: OsgVectorFieldRepresentation.h:42
SurgSim::Graphics::OsgVectorFieldRepresentation::getPointSize
virtual double getPointSize() const
Gets the size of starting point of a vector.
Definition: OsgVectorFieldRepresentation.cpp:194
SurgSim::Graphics::OsgVectorFieldRepresentation::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgVectorFieldRepresentation)
SurgSim::Graphics::VectorFieldRepresentation
Graphic representation of a vector field Each point/location, i.e.
Definition: VectorFieldRepresentation.h:30
SurgSim::Graphics::OsgVectorFieldRepresentation::m_colors
osg::ref_ptr< osg::Vec4Array > m_colors
OSG::Vec4Array to hold color for each vector.
Definition: OsgVectorFieldRepresentation.h:101
SurgSim::Graphics::OsgVectorFieldRepresentation::setLineWidth
void setLineWidth(double width) override
Sets vector line width.
Definition: OsgVectorFieldRepresentation.cpp:169
SurgSim::Graphics::OsgVectorFieldRepresentation::m_vertexData
osg::ref_ptr< osg::Vec3Array > m_vertexData
OSG vertex data structure.
Definition: OsgVectorFieldRepresentation.h:83
SurgSim::Graphics::OsgVectorFieldRepresentation::getVectorField
std::shared_ptr< VectorField > getVectorField() const override
Gets the vector field.
Definition: OsgVectorFieldRepresentation.cpp:164
LockedContainer.h
SurgSim::Graphics::OsgVectorFieldRepresentation::m_line
osg::ref_ptr< osg::LineWidth > m_line
OSG::LineWidth for representing vector.
Definition: OsgVectorFieldRepresentation.h:96
VectorFieldRepresentation.h
SurgSim::DataStructures::Vertex
Vertex structure for meshes.
Definition: Vertex.h:44
SurgSim::Graphics::OsgVectorFieldRepresentation::setScale
void setScale(double scale) override
Sets the scale to be applied to all vectors.
Definition: OsgVectorFieldRepresentation.cpp:179
SurgSim::Graphics::OsgVectorFieldRepresentation::doUpdate
void doUpdate(double dt) override
Definition: OsgVectorFieldRepresentation.cpp:82
SurgSim::Graphics::OsgVectorFieldRepresentation::m_drawPoints
osg::ref_ptr< osg::DrawElementsUInt > m_drawPoints
An OSG::DrawElementUInt object specifying how vector starting points will be drawn.
Definition: OsgVectorFieldRepresentation.h:93
SurgSim::Graphics::OsgVectorFieldRepresentation::setPointSize
virtual void setPointSize(double size)
Sets the size of point indicating the starting of vector.
Definition: OsgVectorFieldRepresentation.cpp:189
SurgSim::Graphics::OsgVectorFieldRepresentation::m_pointGeometry
osg::ref_ptr< osg::Geometry > m_pointGeometry
OSG::Geometry node holding OSG representation of vector starting points.
Definition: OsgVectorFieldRepresentation.h:88
SurgSim::Graphics::OsgVectorFieldRepresentation::updateVectorField
void updateVectorField(const VectorField &vectorfield) override
Updates the vector field in a threadsafe manner.
Definition: OsgVectorFieldRepresentation.cpp:159
VectorField.h
SurgSim::Graphics::OsgVectorFieldRepresentation::m_scale
double m_scale
A scale to scale the length of vector.
Definition: OsgVectorFieldRepresentation.h:104
SurgSim::Framework::LockedContainer
A simple thread-safe data container that can support multiple writers and readers.
Definition: LockedContainer.h:54
SurgSim::Graphics::OsgVectorFieldRepresentation::m_vectorField
std::shared_ptr< SurgSim::Graphics::VectorField > m_vectorField
Vector Field holds a list of vertices/points (X,Y,Z) in 3D space Each point is associated with a vect...
Definition: OsgVectorFieldRepresentation.h:78
SurgSim::Graphics::OsgVectorFieldRepresentation::OsgVectorFieldRepresentation
OsgVectorFieldRepresentation(const std::string &name)
Constructor.
Definition: OsgVectorFieldRepresentation.cpp:36
SurgSim::Graphics::OsgVectorFieldRepresentation::~OsgVectorFieldRepresentation
~OsgVectorFieldRepresentation()
Destructor.
Definition: OsgVectorFieldRepresentation.cpp:78
OsgRepresentation.h
SurgSim::Graphics::OsgVectorFieldRepresentation::getLineWidth
double getLineWidth() const override
Gets line width.
Definition: OsgVectorFieldRepresentation.cpp:174
SurgSim::Graphics::OsgVectorFieldRepresentation::m_drawArrays
osg::ref_ptr< osg::DrawArrays > m_drawArrays
An OSG::DrawArrays object specifying how vectors will be drawn.
Definition: OsgVectorFieldRepresentation.h:91
SurgSim::Graphics::OsgVectorFieldRepresentation::m_lineGeometry
osg::ref_ptr< osg::Geometry > m_lineGeometry
OSG::Geometry node holding OSG representation of vectors.
Definition: OsgVectorFieldRepresentation.h:86
SurgSim::Graphics::OsgRepresentation
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55
SurgSim::DataStructures::Vertices
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51
SurgSim::Graphics::OsgVectorFieldRepresentation::m_writeBuffer
SurgSim::Framework::LockedContainer< VectorField > m_writeBuffer
Definition: OsgVectorFieldRepresentation.h:80