GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/gepetto/viewer/leaf-node-line.h Lines: 0 8 0.0 %
Date: 2024-04-14 11:13:22 Branches: 0 24 0.0 %

Line Branch Exec Source
1
//
2
//  leaf-node-line.h
3
//  gepetto-viewer
4
//
5
//  Created by Justin Carpentier, Mathieu Geisert in November 2014.
6
//  Copyright (c) 2014 LAAS-CNRS. All rights reserved.
7
//
8
9
#ifndef GEPETTO_VIEWER_LEAFNODELINE_HH
10
#define GEPETTO_VIEWER_LEAFNODELINE_HH
11
12
#include <gepetto/viewer/node-drawable.h>
13
#include <gepetto/viewer/properties.h>
14
15
namespace gepetto {
16
namespace viewer {
17
DEF_CLASS_SMART_PTR(LeafNodeLine)
18
19
class LeafNodeLine : public Node {
20
 private:
21
  /** Associated weak pointer */
22
  LeafNodeLineWeakPtr weak_ptr_;
23
24
  /** Geometry */
25
  ::osg::GeometryRefPtr beam_ptr_;
26
  ::osg::ref_ptr< ::osg::DrawArrays> drawArray_ptr_;
27
  ::osg::Vec3ArrayRefPtr points_ptr_;
28
  ::osg::Vec4ArrayRefPtr color_ptr_;
29
30
  BackfaceDrawingProperty backfaceDrawing_;
31
32
  void init();
33
34
  /* Default constructor */
35
  LeafNodeLine(const std::string& name, const osgVector3& start_point,
36
               const osgVector3& end_point);
37
  LeafNodeLine(const std::string& name, const osgVector3& start_point,
38
               const osgVector3& end_point, const osgVector4& color);
39
  LeafNodeLine(const std::string& name, const ::osg::Vec3ArrayRefPtr& points,
40
               const osgVector4& color);
41
42
  /* Copy constructor */
43
  LeafNodeLine(const LeafNodeLine& other);
44
45
  /** Initialize weak_ptr */
46
  void initWeakPtr(LeafNodeLineWeakPtr other_weak_ptr);
47
48
 protected:
49
 public:
50
  /** Static method which create a new box defined by the half_axis vector
51
   */
52
  static LeafNodeLinePtr_t create(const std::string& name,
53
                                  const osgVector3& start_point,
54
                                  const osgVector3& end_point);
55
  static LeafNodeLinePtr_t create(const std::string& name,
56
                                  const osgVector3& start_point,
57
                                  const osgVector3& end_point,
58
                                  const osgVector4& color);
59
  static LeafNodeLinePtr_t create(const std::string& name,
60
                                  const ::osg::Vec3ArrayRefPtr& points,
61
                                  const osgVector4& color);
62
63
  /** Static method for creating a clone of box other with the copy constructor
64
   */
65
  static LeafNodeLinePtr_t createCopy(LeafNodeLinePtr_t other);
66
67
  /** Proceed to a clonage of the current object defined by the copy constructor
68
   */
69
  virtual LeafNodeLinePtr_t clone(void) const;
70
71
  /** Copy
72
   \brief Proceed to a copy of the currend object as clone
73
   */
74
  virtual NodePtr_t copy() const { return clone(); }
75
76
  /** Return a shared pointer of the current object
77
   */
78
  LeafNodeLinePtr_t self(void) const;
79
80
  /** Apply a new global configuration
81
   */
82
83
  /** Define the new start point of the line
84
   */
85
  virtual void setStartPoint(const osgVector3& start_point);
86
87
  osgVector3 getStartPoint() const;
88
89
  /** Define the new end point of the line
90
   */
91
  virtual void setEndPoint(const osgVector3& end_point);
92
93
  osgVector3 getEndPoint() const;
94
95
  /** Define the immediate mode of OpenGL used to draw the line.
96
   *  Possible values are:
97
   *  \image html opengl_primitives.png
98
   */
99
  virtual void setMode(const GLenum& mode);
100
101
  GLenum getMode() const;
102
103
  /** Define the start and end point of the line
104
   */
105
  virtual void setPoints(const osgVector3& start_point,
106
                         const osgVector3& end_point);
107
108
  virtual void setPoints(const ::osg::Vec3ArrayRefPtr& points);
109
110
  /** Draw only a subset of the points
111
   */
112
  void setPointsSubset(const int first, const std::size_t count);
113
114
  ::osg::Vec3ArrayRefPtr getPoints() { return points_ptr_; }
115
116
  void setColor(const osgVector4& color);
117
  void setColors(const ::osg::Vec4ArrayRefPtr& color);
118
119
  osgVector4 getColor() const {
120
    ::osg::Vec4ArrayRefPtr color_array_ptr =
121
        dynamic_cast<osg::Vec4Array*>(beam_ptr_->getColorArray());
122
    ASSERT(color_array_ptr,
123
           "Problem of dynamic casting from VecArray to Vec4Array");
124
125
    return color_array_ptr->at(0);
126
  }
127
128
  ::osg::GeometryRefPtr geometry() const { return beam_ptr_; }
129
130
  SCENE_VIEWER_ACCEPT_VISITOR;
131
132
  /** Destructor */
133
  virtual ~LeafNodeLine();
134
};
135
136
} /* namespace viewer */
137
} /* namespace gepetto */
138
139
#endif /* GEPETTO_VIEWER_LEAFNODELINE_HH */