Choreonoid  1.8
MaterialTable.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODY_MATERIAL_TABLE_H
7 #define CNOID_BODY_MATERIAL_TABLE_H
8 
9 #include "ContactMaterial.h"
10 #include <cnoid/NullOut>
11 #include <functional>
12 #include "exportdecl.h"
13 
14 namespace cnoid {
15 
16 class CloneMap;
17 
18 class CNOID_EXPORT MaterialTable : public Referenced
19 {
20 public:
21  typedef std::function<ContactMaterial*(const ContactMaterial* org)> ContactMaterialCopyFactory;
22 
23  MaterialTable();
24  virtual ~MaterialTable();
26  MaterialTable(const MaterialTable& org);
28  MaterialTable(const MaterialTable& org, CloneMap& cloneMap, ContactMaterialCopyFactory factory = nullptr);
29 
30  void clear();
31 
32  int maxMaterialId() const;
33  int numMaterials() const;
34  Material* material(int id) const;
35  int numContactMaterials() const;
36  ContactMaterial* contactMaterial(int id1, int id2) const;
37  ContactMaterial* contactMaterial(const std::string& name1, const std::string& name2) const;
38 
39  void forEachMaterial(std::function<void(int id, Material* material)> func);
40  void forEachMaterialPair(std::function<void(int id1, int id2, ContactMaterial* cm)> func);
41 
42  int addMaterial(Material* material);
43  void setContactMaterial(int id1, int id2, ContactMaterial* cm);
44 
45  void merge(MaterialTable* table);
46 
47  bool load(const std::string& filename, std::ostream& os = nullout());
48 
49 private:
50  class Impl;
51  Impl* impl;
52 };
53 
55 
56 }
57 
58 #endif
cnoid::MaterialTablePtr
ref_ptr< MaterialTable > MaterialTablePtr
Definition: MaterialTable.h:54
cnoid::MaterialTable::ContactMaterialCopyFactory
std::function< ContactMaterial *(const ContactMaterial *org)> ContactMaterialCopyFactory
Definition: MaterialTable.h:21
ContactMaterial.h
cnoid::nullout
std::ostream & nullout()
Definition: NullOut.cpp:26
cnoid::Material
Definition: Material.h:15
cnoid::ref_ptr< MaterialTable >
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::ContactMaterial
Definition: ContactMaterial.h:14
cnoid::Referenced
Definition: Referenced.h:54
cnoid::MaterialTable
Definition: MaterialTable.h:18