Rumba C++ SDK
Shape.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Buffer.h"
18 #include "IndexedBuffer.h"
19 #include "SparseBuffer.h"
20 #include "Value.h"
21 
22  namespace maquina
23  {
25  class MAQUINA_EXPORT Shape : public Value
26  {
27  public:
28  Shape();
29 
31 
32  Shape(const Value &v);
33 
35  Imath::Box3f bounding_box() const;
36 
38  enum Topology
39  {
42  face,
44  };
45 
47  bool has_attribute(const char *attribute_name, Topology topology) const;
48 
50 
53  template<typename T>
54  T write_attribute(const char *attribute_name, Topology topology);
55 
57 
59  const Value read_attribute(const char *attribute_name, Topology topology) const;
60 
62  bool set_attribute(const char *name, Topology topology, const Value &value);
63 
65 
66  bool remove_attribute(const char *name, Topology topology);
67 
69 
70  void finalize();
71 
73  size_t topology_size(Topology topology) const;
74 
76  struct Attribute
77  {
84  };
85 
87 
89  {
90  public:
93  {
94  public:
95  bool operator==(const Iterator &other) const;
96  bool operator!=(const Iterator &other) const;
97  Iterator& operator++();
98  Iterator(const void *iterator);
99  Iterator(const Iterator& other);
100  ~Iterator();
101 
103  StringView name() const;
105  Value value() const;
107  Topology topology () const;
108 
109  Attribute operator * () const;
110  private:
111  const void *_internal;
112  };
113 
115  Attributes(std::shared_ptr<Impl> _value);
116 
117  Iterator begin() const;
118  Iterator end() const;
119 
121  size_t size() const;
122  private:
123  std::shared_ptr<Impl> _value;
124  };
125 
127  Attributes read_attributes() const;
128 
130  Shape(std::shared_ptr<Impl> impl) { _impl=impl; }
131  };
132 
133  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<int32_t> Shape::write_attribute<Buffer<int32_t>>(const char *attribute_name, Topology topology);
134  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<uint8_t> Shape::write_attribute<Buffer<uint8_t>>(const char *attribute_name, Topology topology);
135  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<uint32_t> Shape::write_attribute<Buffer<uint32_t>>(const char *attribute_name, Topology topology);
136  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<float> Shape::write_attribute<Buffer<float>>(const char *attribute_name, Topology topology);
137  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<Imath::V2f> Shape::write_attribute<Buffer<Imath::V2f>>(const char *attribute_name, Topology topology);
138  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<Imath::V3f> Shape::write_attribute<Buffer<Imath::V3f>>(const char *attribute_name, Topology topology);
139  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<Imath::V4f> Shape::write_attribute<Buffer<Imath::V4f>>(const char *attribute_name, Topology topology);
140 
141  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<int32_t> Shape::write_attribute<IndexedBuffer<int32_t>>(const char *attribute_name, Topology topology);
142  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<uint8_t> Shape::write_attribute<IndexedBuffer<uint8_t>>(const char *attribute_name, Topology topology);
143  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<uint32_t> Shape::write_attribute<IndexedBuffer<uint32_t>>(const char *attribute_name, Topology topology);
144  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<float> Shape::write_attribute<IndexedBuffer<float>>(const char *attribute_name, Topology topology);
145  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<Imath::V2f> Shape::write_attribute<IndexedBuffer<Imath::V2f>>(const char *attribute_name, Topology topology);
146  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<Imath::V3f> Shape::write_attribute<IndexedBuffer<Imath::V3f>>(const char *attribute_name, Topology topology);
147  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<Imath::V4f> Shape::write_attribute<IndexedBuffer<Imath::V4f>>(const char *attribute_name, Topology topology);
148 
149  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<int32_t> Shape::write_attribute<SparseBuffer<int32_t>>(const char *attribute_name, Topology topology);
150  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<uint8_t> Shape::write_attribute<SparseBuffer<uint8_t>>(const char *attribute_name, Topology topology);
151  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<uint32_t> Shape::write_attribute<SparseBuffer<uint32_t>>(const char *attribute_name, Topology topology);
152  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<float> Shape::write_attribute<SparseBuffer<float>>(const char *attribute_name, Topology topology);
153  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<Imath::V2f> Shape::write_attribute<SparseBuffer<Imath::V2f>>(const char *attribute_name, Topology topology);
154  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<Imath::V3f> Shape::write_attribute<SparseBuffer<Imath::V3f>>(const char *attribute_name, Topology topology);
155  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<Imath::V4f> Shape::write_attribute<SparseBuffer<Imath::V4f>>(const char *attribute_name, Topology topology);
156  }
Definition: ImathBox.h:71
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT SparseBuffer< int32_t >
Definition: SparseBuffer.h:130
Topology
The different attribute topologies.
Definition: Shape.h:38
A Shape attribute, with name, value and topology.
Definition: Shape.h:76
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT IndexedBuffer< float >
Definition: IndexedBuffer.h:125
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT Buffer< uint8_t >
Definition: Buffer.h:227
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT SparseBuffer< float >
Definition: SparseBuffer.h:133
StringView name
The attribute name.
Definition: Shape.h:79
A value with geometrical attributes. Base of all shape values.
Definition: Shape.h:25
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT IndexedBuffer< uint32_t >
Definition: IndexedBuffer.h:124
A shape attributes iterator.
Definition: Shape.h:92
The attribute is a per-vertex buffer.
Definition: Shape.h:41
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT IndexedBuffer< int32_t >
Definition: IndexedBuffer.h:122
maquina::Shape::Topology topology
The attribute topology.
Definition: Shape.h:83
The channel is not animable.
#define MAQUINA_EXPORT
Definition: Export.h:31
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT SparseBuffer< uint8_t >
Definition: SparseBuffer.h:131
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT Buffer< int32_t >
Definition: Buffer.h:226
bool operator!=(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:306
An shape&#39;s attribute iteration.
Definition: Shape.h:88
maquina::Value value
The attribute value.
Definition: Shape.h:81
bool operator==(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:274
#define MAQUINA_EXTERN_TEMPLATE
Definition: Export.h:25
The attribute is a per-face buffer.
Definition: Shape.h:42
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT Buffer< float >
Definition: Buffer.h:229
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT IndexedBuffer< uint8_t >
Definition: IndexedBuffer.h:123
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT Buffer< uint32_t >
Definition: Buffer.h:228
The attribute is a per-face corner buffer.
Definition: Shape.h:43
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT SparseBuffer< uint32_t >
Definition: SparseBuffer.h:132
Color4< T > operator*(S a, const Color4< T > &v)
Definition: ImathColor.h:727
Base class of all Rumba values.
Definition: Value.h:34