AdvancedVisualizationFactory.h
Go to the documentation of this file.
1 
2 /* This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarXGuiPlugins::RobotTrajectoryDesigner::Visualization
17 * @author Timo Birr
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 #ifndef ADVANCEDVISUALIZATIONFACTORY_H
23 #define ADVANCEDVISUALIZATIONFACTORY_H
24 
25 #include <memory>
26 
27 #include <VirtualRobot/Robot.h>
28 
29 #include <VirtualRobot/Visualization/VisualizationFactory.h>
30 
32 
33 #include <VirtualRobot/Visualization/VisualizationNode.h>
34 
35 #include <VirtualRobot/Primitive.h>
36 
37 #include "VirtualRobot/MathTools.h"
38 
39 #include "VirtualRobot/Trajectory.h"
40 
41 #include "VirtualRobot/Visualization/TriMeshModel.h"
42 
43 #include "VirtualRobot/BoundingBox.h"
44 
45 namespace armarx
46 {
47  /**
48  * @brief The AdvancedVisualizationFactory class is the abstract decorator of the Decorator-Pattern and decorates the VisualizationFactoy in Simox
49  *
50  * The additional Functionality is that it can also generate the Visualization for a Manipulator
51  */
52  class AdvancedVisualizationFactory : public VirtualRobot::VisualizationFactory
53  {
54 
55 
56  public:
57  /**
58  * @brief createManipulator
59  * @param kc
60  * @param robot
61  * @return
62  */
63  AbstractManipulatorVisualizationPtr createManipulator(VirtualRobot::RobotNodeSetPtr kc, VirtualRobot::RobotPtr robot);
64 
65  virtual void init(int& argc, char* argv[], const std::string& appName) override
66  {
67  }
68 
69  virtual VirtualRobot::VisualizationNodePtr getVisualizationFromPrimitives(const std::vector<VirtualRobot::Primitive::PrimitivePtr>& primitives, bool boundingBox = false, Color color = Color::Gray()) override
70  {
71  return component.getVisualizationFromPrimitives(primitives, boundingBox, color);
72  }
73  virtual VirtualRobot::VisualizationNodePtr getVisualizationFromFile(const std::string& filename, bool boundingBox = false, float scaleX = 1.0f, float scaleY = 1.0f, float scaleZ = 1.0f) override
74  {
75  return component.getVisualizationFromFile(filename, boundingBox, scaleX, scaleY, scaleZ);
76  }
77  virtual VirtualRobot::VisualizationNodePtr getVisualizationFromFile(const std::ifstream& ifs, bool boundingBox = false, float scaleX = 1.0f, float scaleY = 1.0f, float scaleZ = 1.0f) override
78  {
79  return component.getVisualizationFromFile(ifs, boundingBox, scaleX, scaleY, scaleZ);
80  }
81 
82  virtual VirtualRobot::VisualizationNodePtr createBox(float width, float height, float depth, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f) override
83  {
84  return component.createBox(width, height, depth, colorR, colorG, colorB);
85  }
86  virtual VirtualRobot::VisualizationNodePtr createLine(const Eigen::Vector3f& from, const Eigen::Vector3f& to, float width = 1.0f, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f) override
87  {
88  return component.createLine(from, to, width, colorR, colorG, colorB);
89  }
90  virtual VirtualRobot::VisualizationNodePtr createLine(const Eigen::Matrix4f& from, const Eigen::Matrix4f& to, float width = 1.0f, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f) override
91  {
92  return component.createLine(from, to, width, colorR, colorG, colorB);
93  }
94  virtual VirtualRobot::VisualizationNodePtr createSphere(float radius, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f) override
95  {
96  return component.createSphere(radius, colorR, colorG, colorB);
97  }
98  virtual VirtualRobot::VisualizationNodePtr createCircle(float radius, float circleCompletion, float width, float colorR = 1.0f, float colorG = 0.5f, float colorB = 0.5f, size_t numberOfCircleParts = 30) override
99  {
100  return component.createCircle(radius, circleCompletion, width, colorR, colorG, colorB, numberOfCircleParts);
101  }
102 
103  virtual VirtualRobot::VisualizationNodePtr createTorus(float radius, float tubeRadius, float completion = 1.0f, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f, float transparency = 0.0f, int sides = 8, int rings = 30) override
104  {
105  return component.createTorus(radius, tubeRadius, completion, colorR, colorG, colorB, transparency, sides, rings);
106  }
107 
108  virtual VirtualRobot::VisualizationNodePtr createCircleArrow(float radius, float tubeRadius, float completion = 1, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f, float transparency = 0.0f, int sides = 8, int rings = 30) override
109  {
110  return component.createCircleArrow(radius, tubeRadius, completion, colorR, colorG, colorB, transparency, sides, rings);
111  }
112 
113  virtual VirtualRobot::VisualizationNodePtr createCylinder(float radius, float height, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f) override
114  {
115  return component.createCylinder(radius, height, colorR, colorG, colorB);
116  }
117  virtual VirtualRobot::VisualizationNodePtr createCoordSystem(float scaling = 1.0f, std::string* text = NULL, float axisLength = 100.0f, float axisSize = 3.0f, int nrOfBlocks = 10) override
118  {
119  return component.createCoordSystem(scaling, text, axisLength, axisSize, nrOfBlocks);
120  }
121  virtual VirtualRobot::VisualizationNodePtr createBoundingBox(const VirtualRobot::BoundingBox& bbox, bool wireFrame = false) override
122  {
123  return component.createBoundingBox(bbox, wireFrame);
124  }
125  virtual VirtualRobot::VisualizationNodePtr createVertexVisualization(const Eigen::Vector3f& position, float radius, float transparency, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f) override
126  {
127  return component.createVertexVisualization(position, radius, transparency, colorR, colorG, colorB);
128  }
129 
130  virtual VirtualRobot::VisualizationNodePtr createTriMeshModelVisualization(VirtualRobot::TriMeshModelPtr model, Eigen::Matrix4f& pose, float scaleX = 1.0f, float scaleY = 1.0f, float scaleZ = 1.0f) override
131  {
132  return component.createTriMeshModelVisualization(model, pose, scaleX, scaleY, scaleZ);
133  }
134 
135  virtual VirtualRobot::VisualizationNodePtr createTriMeshModelVisualization(VirtualRobot::TriMeshModelPtr model, bool showNormals, Eigen::Matrix4f& pose, bool showLines = true) override
136  {
137  return component.createTriMeshModelVisualization(model, showNormals, pose, showLines);
138  }
139  virtual VirtualRobot::VisualizationNodePtr createPlane(const Eigen::Vector3f& position, const Eigen::Vector3f& normal, float extend, float transparency, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f) override
140  {
141  return component.createPlane(position, normal, extend, transparency, colorR, colorG, colorB);
142  }
143  virtual VirtualRobot::VisualizationNodePtr createPlane(const VirtualRobot::MathTools::Plane& plane, float extend, float transparency, float colorR = 0.5f, float colorG = 0.5f, float colorB = 0.5f) override
144  {
145  return component.createPlane(plane, extend, transparency, colorR, colorG, colorB);
146  }
147  virtual VirtualRobot::VisualizationNodePtr createArrow(const Eigen::Vector3f& n, float length = 50.0f, float width = 2.0f, const Color& color = Color::Gray()) override
148  {
149  return component.createArrow(n, length, width, color);
150  }
151  virtual VirtualRobot::VisualizationNodePtr createTrajectory(VirtualRobot::TrajectoryPtr t, Color colorNode = Color::Blue(), Color colorLine = Color::Gray(), float nodeSize = 15.0f, float lineSize = 4.0f) override
152  {
153  return component.createTrajectory(t, colorNode, colorLine, nodeSize, lineSize);
154  }
155  virtual VirtualRobot::VisualizationNodePtr createText(const std::string& text, bool billboard = false, float scaling = 1.0f, Color c = Color::Black(), float offsetX = 20.0f, float offsetY = 20.0f, float offsetZ = 0.0f) override
156  {
157  return component.createText(text, billboard, scaling, c, offsetX, offsetY, offsetZ);
158  }
159 
160  virtual VirtualRobot::VisualizationNodePtr createEllipse(float x, float y, float z, bool showAxes = true, float axesHeight = 4.0f, float axesWidth = 8.0f) override
161  {
162  return component.createEllipse(x, y, z, showAxes, axesHeight, axesWidth);
163  }
164  virtual void applyDisplacement(VirtualRobot::VisualizationNodePtr o, Eigen::Matrix4f& m) override {}
165 
166  virtual VirtualRobot::VisualizationNodePtr createVisualization() override
167  {
168  return component.createVisualization();
169  }
170 
171  virtual VirtualRobot::VisualizationNodePtr createUnitedVisualization(const std::vector<VirtualRobot::VisualizationNodePtr>& visualizations) const override
172  {
173  return component.createUnitedVisualization(visualizations);
174  }
175  /**
176  * @brief createCurve creates the visualization of a curve that goes through the Waypoints in transition
177  * @param transition the curve/transition to visualize
178  * @param highligt true when the Transition should be highlighted(red) , false if not (blue)
179  * @return the visualization node in the visualization method of this factory
180  */
181  virtual VirtualRobot::VisualizationNodePtr createCurve(const std::vector<PoseBasePtr> transition, bool highligt);
182 
183 
184 
185  protected:
186  VisualizationFactory component;
187 
188 
189  };
190 
191  using AdvancedVisualizationFactoryPtr = std::shared_ptr<AdvancedVisualizationFactory>;
192 }
193 
194 #endif
armarx::AdvancedVisualizationFactory::createSphere
virtual VirtualRobot::VisualizationNodePtr createSphere(float radius, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f) override
Definition: AdvancedVisualizationFactory.h:94
armarx::TrajectoryPtr
IceInternal::Handle< Trajectory > TrajectoryPtr
Definition: Trajectory.h:52
armarx::AdvancedVisualizationFactory::createTorus
virtual VirtualRobot::VisualizationNodePtr createTorus(float radius, float tubeRadius, float completion=1.0f, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f, float transparency=0.0f, int sides=8, int rings=30) override
Definition: AdvancedVisualizationFactory.h:103
armarx::AdvancedVisualizationFactory::createTrajectory
virtual VirtualRobot::VisualizationNodePtr createTrajectory(VirtualRobot::TrajectoryPtr t, Color colorNode=Color::Blue(), Color colorLine=Color::Gray(), float nodeSize=15.0f, float lineSize=4.0f) override
Definition: AdvancedVisualizationFactory.h:151
armarx::AdvancedVisualizationFactory::createPlane
virtual VirtualRobot::VisualizationNodePtr createPlane(const VirtualRobot::MathTools::Plane &plane, float extend, float transparency, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f) override
Definition: AdvancedVisualizationFactory.h:143
armarx::AdvancedVisualizationFactory::createBoundingBox
virtual VirtualRobot::VisualizationNodePtr createBoundingBox(const VirtualRobot::BoundingBox &bbox, bool wireFrame=false) override
Definition: AdvancedVisualizationFactory.h:121
armarx::AdvancedVisualizationFactory::createCircle
virtual VirtualRobot::VisualizationNodePtr createCircle(float radius, float circleCompletion, float width, float colorR=1.0f, float colorG=0.5f, float colorB=0.5f, size_t numberOfCircleParts=30) override
Definition: AdvancedVisualizationFactory.h:98
armarx::AdvancedVisualizationFactory::createManipulator
AbstractManipulatorVisualizationPtr createManipulator(VirtualRobot::RobotNodeSetPtr kc, VirtualRobot::RobotPtr robot)
createManipulator
armarx::AdvancedVisualizationFactory::createCylinder
virtual VirtualRobot::VisualizationNodePtr createCylinder(float radius, float height, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f) override
Definition: AdvancedVisualizationFactory.h:113
armarx::AdvancedVisualizationFactory::createUnitedVisualization
virtual VirtualRobot::VisualizationNodePtr createUnitedVisualization(const std::vector< VirtualRobot::VisualizationNodePtr > &visualizations) const override
Definition: AdvancedVisualizationFactory.h:171
armarx::AdvancedVisualizationFactory::createPlane
virtual VirtualRobot::VisualizationNodePtr createPlane(const Eigen::Vector3f &position, const Eigen::Vector3f &normal, float extend, float transparency, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f) override
Definition: AdvancedVisualizationFactory.h:139
armarx::AdvancedVisualizationFactory::component
VisualizationFactory component
Definition: AdvancedVisualizationFactory.h:186
armarx::AdvancedVisualizationFactory
The AdvancedVisualizationFactory class is the abstract decorator of the Decorator-Pattern and decorat...
Definition: AdvancedVisualizationFactory.h:52
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
AbstractManipulatorVisualization.h
armarx::AdvancedVisualizationFactory::createBox
virtual VirtualRobot::VisualizationNodePtr createBox(float width, float height, float depth, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f) override
Definition: AdvancedVisualizationFactory.h:82
armarx::AdvancedVisualizationFactory::getVisualizationFromFile
virtual VirtualRobot::VisualizationNodePtr getVisualizationFromFile(const std::string &filename, bool boundingBox=false, float scaleX=1.0f, float scaleY=1.0f, float scaleZ=1.0f) override
Definition: AdvancedVisualizationFactory.h:73
armarx::AdvancedVisualizationFactory::createLine
virtual VirtualRobot::VisualizationNodePtr createLine(const Eigen::Vector3f &from, const Eigen::Vector3f &to, float width=1.0f, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f) override
Definition: AdvancedVisualizationFactory.h:86
armarx::AdvancedVisualizationFactory::getVisualizationFromPrimitives
virtual VirtualRobot::VisualizationNodePtr getVisualizationFromPrimitives(const std::vector< VirtualRobot::Primitive::PrimitivePtr > &primitives, bool boundingBox=false, Color color=Color::Gray()) override
Definition: AdvancedVisualizationFactory.h:69
armarx::AdvancedVisualizationFactory::getVisualizationFromFile
virtual VirtualRobot::VisualizationNodePtr getVisualizationFromFile(const std::ifstream &ifs, bool boundingBox=false, float scaleX=1.0f, float scaleY=1.0f, float scaleZ=1.0f) override
Definition: AdvancedVisualizationFactory.h:77
Color
uint32_t Color
RGBA color.
Definition: color.h:8
armarx::AdvancedVisualizationFactory::createTriMeshModelVisualization
virtual VirtualRobot::VisualizationNodePtr createTriMeshModelVisualization(VirtualRobot::TriMeshModelPtr model, Eigen::Matrix4f &pose, float scaleX=1.0f, float scaleY=1.0f, float scaleZ=1.0f) override
Definition: AdvancedVisualizationFactory.h:130
armarx::AdvancedVisualizationFactory::createArrow
virtual VirtualRobot::VisualizationNodePtr createArrow(const Eigen::Vector3f &n, float length=50.0f, float width=2.0f, const Color &color=Color::Gray()) override
Definition: AdvancedVisualizationFactory.h:147
armarx::AdvancedVisualizationFactory::createCircleArrow
virtual VirtualRobot::VisualizationNodePtr createCircleArrow(float radius, float tubeRadius, float completion=1, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f, float transparency=0.0f, int sides=8, int rings=30) override
Definition: AdvancedVisualizationFactory.h:108
filename
std::string filename
Definition: VisualizationRobot.cpp:83
armarx::AdvancedVisualizationFactoryPtr
std::shared_ptr< AdvancedVisualizationFactory > AdvancedVisualizationFactoryPtr
Definition: AdvancedVisualizationFactory.h:191
armarx::AdvancedVisualizationFactory::applyDisplacement
virtual void applyDisplacement(VirtualRobot::VisualizationNodePtr o, Eigen::Matrix4f &m) override
Definition: AdvancedVisualizationFactory.h:164
armarx::AdvancedVisualizationFactory::createVisualization
virtual VirtualRobot::VisualizationNodePtr createVisualization() override
Definition: AdvancedVisualizationFactory.h:166
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::AbstractManipulatorVisualizationPtr
std::shared_ptr< AbstractManipulatorVisualization > AbstractManipulatorVisualizationPtr
Definition: AbstractManipulatorVisualization.h:47
armarx::AdvancedVisualizationFactory::createCoordSystem
virtual VirtualRobot::VisualizationNodePtr createCoordSystem(float scaling=1.0f, std::string *text=NULL, float axisLength=100.0f, float axisSize=3.0f, int nrOfBlocks=10) override
Definition: AdvancedVisualizationFactory.h:117
armarx::AdvancedVisualizationFactory::createEllipse
virtual VirtualRobot::VisualizationNodePtr createEllipse(float x, float y, float z, bool showAxes=true, float axesHeight=4.0f, float axesWidth=8.0f) override
Definition: AdvancedVisualizationFactory.h:160
armarx::AdvancedVisualizationFactory::init
virtual void init(int &argc, char *argv[], const std::string &appName) override
Definition: AdvancedVisualizationFactory.h:65
armarx::AdvancedVisualizationFactory::createCurve
virtual VirtualRobot::VisualizationNodePtr createCurve(const std::vector< PoseBasePtr > transition, bool highligt)
createCurve creates the visualization of a curve that goes through the Waypoints in transition
Definition: AdvancedVisualizationFactory.cpp:12
armarx::AdvancedVisualizationFactory::createText
virtual VirtualRobot::VisualizationNodePtr createText(const std::string &text, bool billboard=false, float scaling=1.0f, Color c=Color::Black(), float offsetX=20.0f, float offsetY=20.0f, float offsetZ=0.0f) override
Definition: AdvancedVisualizationFactory.h:155
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::AdvancedVisualizationFactory::createVertexVisualization
virtual VirtualRobot::VisualizationNodePtr createVertexVisualization(const Eigen::Vector3f &position, float radius, float transparency, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f) override
Definition: AdvancedVisualizationFactory.h:125
armarx::AdvancedVisualizationFactory::createTriMeshModelVisualization
virtual VirtualRobot::VisualizationNodePtr createTriMeshModelVisualization(VirtualRobot::TriMeshModelPtr model, bool showNormals, Eigen::Matrix4f &pose, bool showLines=true) override
Definition: AdvancedVisualizationFactory.h:135
armarx::AdvancedVisualizationFactory::createLine
virtual VirtualRobot::VisualizationNodePtr createLine(const Eigen::Matrix4f &from, const Eigen::Matrix4f &to, float width=1.0f, float colorR=0.5f, float colorG=0.5f, float colorB=0.5f) override
Definition: AdvancedVisualizationFactory.h:90