iMSTK
Interactive Medical Simulation Toolkit
imstkDebugGeometryModel.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkComponent.h"
10 #include "imstkColor.h"
11 #include "imstkMath.h"
12 
13 namespace imstk
14 {
15 class LineMesh;
16 class PointSet;
17 class RenderMaterial;
18 class SurfaceMesh;
19 template<typename T, int N> class VecDataArray;
20 class VisualModel;
21 
30 {
31 public:
32  DebugGeometryModel(const std::string& name = "DebugGeometryModel");
33  ~DebugGeometryModel() override = default;
34 
35 protected:
36  void init() override;
37 
38 public:
42  void addLine(const Vec3d& a, const Vec3d& b);
43 
47  void addLine(const Vec3d& a, const Vec3d& b, const Color& color);
48 
52  void addTriangle(const Vec3d& a, const Vec3d& b, const Vec3d& c);
53 
57  void addTriangle(const Vec3d& a, const Vec3d& b, const Vec3d& c, const Color& color);
58 
63  void addPoint(const Vec3d& a);
64 
70  void addPoint(const Vec3d& a, const Color& color);
71 
77  void addArrow(const Vec3d& start, const Vec3d& end);
78 
85  void addArrow(const Vec3d& start, const Vec3d& end, const Color& color);
86 
90  void clear();
91 
93  std::shared_ptr<RenderMaterial> getPointMaterial() const;
94  std::shared_ptr<RenderMaterial> getLineMaterial() const;
95  std::shared_ptr<RenderMaterial> getFaceMaterial() const;
96 
100  void visualUpdate(const double& dt) override;
101 
102  void setLineWidth(const double width);
103 
104  void setTriColor(const Color& color);
105  void setLineColor(const Color& color);
106  void setPointColor(const Color& color);
107  void setArrowColor(const Color& color);
108 
109  void setPointSize(const double size);
110 
111  void setArrowScale(const double arrowScale) { m_arrowScale = arrowScale; }
112 
113  int getNumPoints() const;
114  int getNumLines() const;
115  int getNumTriangles() const;
116 
117 protected:
118  double m_arrowScale;
119  Color m_arrowColor;
120 
121  std::shared_ptr<VisualModel> m_debugLineModel;
122  std::shared_ptr<VisualModel> m_debugPointModel;
123  std::shared_ptr<VisualModel> m_debugSurfModel;
124 
125  std::shared_ptr<LineMesh> m_debugLineMesh;
126  std::shared_ptr<PointSet> m_debugPointSet;
127  std::shared_ptr<SurfaceMesh> m_debugSurfMesh;
128 
129  std::shared_ptr<VecDataArray<double, 3>> m_triVerticesPtr;
130  std::shared_ptr<VecDataArray<int, 3>> m_triIndicesPtr;
131  std::shared_ptr<VecDataArray<unsigned char, 3>> m_triColorsPtr;
132  bool m_trianglesChanged;
133 
134  std::shared_ptr<VecDataArray<double, 3>> m_lineVerticesPtr;
135  std::shared_ptr<VecDataArray<int, 2>> m_lineIndicesPtr;
136  std::shared_ptr<VecDataArray<unsigned char, 3>> m_lineColorsPtr;
137  bool m_linesChanged;
138 
139  std::shared_ptr<VecDataArray<double, 3>> m_pointVerticesPtr;
140  std::shared_ptr<VecDataArray<unsigned char, 3>> m_pointColorsPtr;
141  bool m_ptsChanged;
142 };
143 } // namespace imstk
void visualUpdate(const double &dt) override
Update the primitives.
Class for quickly rendering and showing various primivites such as line segments, triangles...
void addTriangle(const Vec3d &a, const Vec3d &b, const Vec3d &c)
Adds a triangle to the debug triangles with default color.
void addPoint(const Vec3d &a)
Adds a point to the debug points.
Compound Geometry.
void init() override
Initialize the component, called at a later time after all component construction is complete...
A Behaviour represents a single component system A template is used here for UpdateInfo to keep the C...
void addLine(const Vec3d &a, const Vec3d &b)
Adds a line to the debug lines with default color.
std::shared_ptr< RenderMaterial > getPointMaterial() const
Accessors.
void addArrow(const Vec3d &start, const Vec3d &end)
Adds an arrow to the debug arrows.
Color in RGB space.
Definition: imstkColor.h:24
void clear()
Clears all primitives.