1  | 
     | 
     | 
    //  | 
    
    
    2  | 
     | 
     | 
    //  node-rod.cpp  | 
    
    
    3  | 
     | 
     | 
    //  gepetto-viewer  | 
    
    
    4  | 
     | 
     | 
    //  | 
    
    
    5  | 
     | 
     | 
    //  Created by Pierre Fernbach in may 2015.  | 
    
    
    6  | 
     | 
     | 
    //  Copyright (c) 2015 LAAS-CNRS. All rights reserved.  | 
    
    
    7  | 
     | 
     | 
    //  | 
    
    
    8  | 
     | 
     | 
     | 
    
    
    9  | 
     | 
     | 
    #ifndef ROD_HH  | 
    
    
    10  | 
     | 
     | 
    #define ROD_HH  | 
    
    
    11  | 
     | 
     | 
     | 
    
    
    12  | 
     | 
     | 
    #include <gepetto/viewer/config-osg.h>  | 
    
    
    13  | 
     | 
     | 
    #include <gepetto/viewer/group-node.h>  | 
    
    
    14  | 
     | 
     | 
    #include <gepetto/viewer/leaf-node-capsule.h>  | 
    
    
    15  | 
     | 
     | 
     | 
    
    
    16  | 
     | 
     | 
    #include <vector>  | 
    
    
    17  | 
     | 
     | 
     | 
    
    
    18  | 
     | 
     | 
    namespace gepetto { | 
    
    
    19  | 
     | 
     | 
    namespace viewer { | 
    
    
    20  | 
     | 
     | 
     | 
    
    
    21  | 
     | 
     | 
    DEF_CLASS_SMART_PTR(NodeRod)  | 
    
    
    22  | 
     | 
     | 
     | 
    
    
    23  | 
     | 
     | 
    class NodeRod : public Node { | 
    
    
    24  | 
     | 
     | 
     private:  | 
    
    
    25  | 
     | 
     | 
      std::vector<LeafNodeCapsulePtr_t> list_of_capsule_;  | 
    
    
    26  | 
     | 
     | 
      NodeRodWeakPtr weak_ptr_;  | 
    
    
    27  | 
     | 
     | 
      void initWeakPtr(NodeRodWeakPtr other_weak_ptr);  | 
    
    
    28  | 
     | 
     | 
      osgVector4 color_;  | 
    
    
    29  | 
     | 
     | 
      float radius_;  | 
    
    
    30  | 
     | 
     | 
      float totalLength_;  | 
    
    
    31  | 
     | 
     | 
      size_t maxCapsule_;  // max number of capsule for this rod  | 
    
    
    32  | 
     | 
     | 
     protected:  | 
    
    
    33  | 
     | 
     | 
      /** Default constructor */  | 
    
    
    34  | 
     | 
     | 
      NodeRod(const std::string& name, osgVector4 color, float radius,  | 
    
    
    35  | 
     | 
     | 
              float totalLength, size_t maxCapsule);  | 
    
    
    36  | 
     | 
     | 
     | 
    
    
    37  | 
     | 
     | 
      /** Copy constructor */  | 
    
    
    38  | 
     | 
     | 
      NodeRod(const NodeRod& other);  | 
    
    
    39  | 
     | 
     | 
     | 
    
    
    40  | 
     | 
     | 
     public:  | 
    
    
    41  | 
     | 
     | 
      typedef osg::Vec3f::value_type value_type;  | 
    
    
    42  | 
     | 
     | 
      /** Static method which create the new rod */  | 
    
    
    43  | 
     | 
     | 
      static NodeRodPtr_t create(const std::string& name, osgVector4 color,  | 
    
    
    44  | 
     | 
     | 
                                 float radius, float totalLength, short maxCapsule);  | 
    
    
    45  | 
     | 
     | 
     | 
    
    
    46  | 
     | 
     | 
      /** Return the ID of the capsule at the index i */  | 
    
    
    47  | 
     | 
     | 
      virtual std::string getCapsuleName(size_t i);  | 
    
    
    48  | 
     | 
     | 
     | 
    
    
    49  | 
     | 
     | 
      virtual LeafNodeCapsulePtr_t getCapsule(size_t i) const;  | 
    
    
    50  | 
     | 
     | 
     | 
    
    
    51  | 
     | 
     | 
      /** Static method for creating a clone of the rod other with the copy  | 
    
    
    52  | 
     | 
     | 
       * constructor        */  | 
    
    
    53  | 
     | 
     | 
      static NodeRodPtr_t createCopy(NodeRodPtr_t other);  | 
    
    
    54  | 
     | 
     | 
     | 
    
    
    55  | 
     | 
     | 
      /** Return a shared pointer of the current object      */  | 
    
    
    56  | 
     | 
     | 
      NodeRodPtr_t self(void) const;  | 
    
    
    57  | 
     | 
     | 
     | 
    
    
    58  | 
     | 
     | 
      virtual float radius() const { return radius_; } | 
    
    
    59  | 
     | 
     | 
     | 
    
    
    60  | 
     | 
     | 
      virtual float totalLength() const { return totalLength_; } | 
    
    
    61  | 
     | 
     | 
     | 
    
    
    62  | 
     | 
     | 
      void setColor(const osgVector4& color) { color_ = color; } | 
    
    
    63  | 
     | 
     | 
     | 
    
    
    64  | 
     | 
     | 
      virtual osgVector4 color() const { return color_; } | 
    
    
    65  | 
     | 
     | 
     | 
    
    
    66  | 
     | 
     | 
      virtual size_t maxCapsule() const { return maxCapsule_; } | 
    
    
    67  | 
     | 
     | 
     | 
    
    
    68  | 
     | 
     | 
      virtual void applyConfiguration(std::vector<std::vector<value_type> > params);  | 
    
    
    69  | 
     | 
     | 
    };  | 
    
    
    70  | 
     | 
     | 
    } /* namespace viewer */  | 
    
    
    71  | 
     | 
     | 
    } /* namespace gepetto */  | 
    
    
    72  | 
     | 
     | 
     | 
    
    
    73  | 
     | 
     | 
    #endif  // ROD_HH  |