Choreonoid  1.8
StdBodyLoader.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODY_STD_BODY_LOADER_H
7 #define CNOID_BODY_STD_BODY_LOADER_H
8 
9 #include "AbstractBodyLoader.h"
10 #include <cnoid/EigenTypes>
11 #include <functional>
12 #include "exportdecl.h"
13 
14 namespace cnoid {
15 
16 class Mapping;
17 class Device;
18 class StdSceneReader;
19 
20 class CNOID_EXPORT StdBodyLoader : public AbstractBodyLoader
21 {
22 public:
23  StdBodyLoader();
24  ~StdBodyLoader();
25 
26  virtual void setMessageSink(std::ostream& os) override;
27  virtual void setVerbose(bool on) override;
28  virtual void setShapeLoadingEnabled(bool on) override;
29  virtual void setDefaultDivisionNumber(int n) override;
30  virtual void setDefaultCreaseAngle(double theta) override;
31  virtual bool load(Body* body, const std::string& filename) override;
32 
33  bool read(Body* body, Mapping* data);
34 
35  bool readDevice(Device* device, const Mapping* node);
36 
37  StdSceneReader* sceneReader();
38  const StdSceneReader* sceneReader() const;
39 
40  bool isDegreeMode() const;
41  double toRadian(double angle) const;
42 
43  bool readAngle(const Mapping* node, const char* key, double& angle) const;
44  bool readRotation(const Mapping* node, Matrix3& out_R) const;
45  bool readRotation(const Mapping* node, const char* key, Matrix3& out_R) const;
46  bool readRotation(const Mapping* node, std::initializer_list<const char*> keys, Matrix3& out_R) const;
47 
48  [[deprecated("Use readDevice(Device* device, Mapping* node)")]]
49  bool readDevice(Device* device, const Mapping& node);
50  [[deprecated("Use readAngle(const Mapping* node, const char* key, double& angle) const")]]
51  bool readAngle(const Mapping& node, const char* key, double& angle) const;
52  [[deprecated("Use readRotation(const Mapping* node, Matrix3& out_R) const")]]
53  bool readRotation(const Mapping& node, Matrix3& out_R) const;
54  [[deprecated("Use readRotation(const Mapping* node, const char* key, Matrix3& out_R) const")]]
55  bool readRotation(const Mapping& node, const char* key, Matrix3& out_R) const;
56 
57  // The following functions are used for defining new node types
58  static void registerNodeType(
59  const char* typeName,
60  std::function<bool(StdBodyLoader* loader, const Mapping* info)> readFunction);
61 
62  [[deprecated("Use StdBodyLoader::registerNodeType.")]]
63  static void addNodeType(
64  const char* typeName,
65  std::function<bool(StdBodyLoader& loader, const Mapping& info)> readFunction);
66 
69  const char* typeName,
70  std::function<bool(StdBodyLoader* loader, const Mapping* info)> readFunction)
71  {
72  registerNodeType(typeName, readFunction);
73  }
74 
75  [[deprecated("Use std::function<bool(StdBodyLoader* loader, Mapping* node)> as a function object type.")]]
77  const char* typeName, std::function<bool(StdBodyLoader& loader, const Mapping& info)> readFunction);
78  };
79 
80 private:
81  class Impl;
82  Impl* impl;
83 };
84 
85 }
86 
87 #endif
cnoid::Mapping
Definition: ValueTree.h:253
AbstractBodyLoader.h
cnoid::Matrix3
Eigen::Matrix3d Matrix3
Definition: EigenTypes.h:56
cnoid::StdBodyLoader::NodeTypeRegistration::NodeTypeRegistration
NodeTypeRegistration(const char *typeName, std::function< bool(StdBodyLoader *loader, const Mapping *info)> readFunction)
Definition: StdBodyLoader.h:68
cnoid::read
bool read(const Mapping *mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:43
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::StdBodyLoader
Definition: StdBodyLoader.h:20
cnoid::AbstractBodyLoader
Definition: AbstractBodyLoader.h:18
cnoid::Body
Definition: Body.h:28
cnoid::StdBodyLoader::NodeTypeRegistration
Definition: StdBodyLoader.h:67
cnoid::Device
Definition: Device.h:53
cnoid::StdSceneReader
Definition: StdSceneReader.h:20