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 "Value.h"
18 #include "SpanSpan.h"
19 #include "Buffer.h"
20 #include "IndexedBuffer.h"
21 #include "SparseBuffer.h"
22 
23  namespace maquina
24  {
26  class MAQUINA_EXPORT Shape : public Value
27  {
28  public:
29  Shape();
30 
32 
33  Shape(const Value &v);
34 
36  enum Topology
37  {
38  constant=0,
40  face,
42  };
43 
45  bool has_attribute(const char *attribute_name, Topology topology) const;
46 
48 
51  template<typename T>
52  T write_attribute(const char *attribute_name, Topology topology);
53 
55 
57  const Value read_attribute(const char *attribute_name, Topology topology) const;
58 
60  bool set_attribute(const char *name, Topology topology, const Value &value);
61 
63 
64  bool remove_attribute(const char *name, Topology topology);
65 
67 
68  void finalize();
69 
71  size_t topology_size(Topology topology) const;
72 
74  struct Attribute
75  {
82  };
83 
85 
87  {
88  public:
91  {
92  public:
93  bool operator==(const Iterator &other) const;
94  bool operator!=(const Iterator &other) const;
95  Iterator& operator++();
96  Iterator(const void *iterator);
97  Iterator(const Iterator& other);
98  ~Iterator();
99 
101  StringView name() const;
103  Value value() const;
105  Topology topology () const;
106 
107  Attribute operator * () const;
108  private:
109  const void *_internal;
110  };
111 
113  Attributes(std::shared_ptr<Impl> _value);
114 
115  Iterator begin() const;
116  Iterator end() const;
117 
119  size_t size() const;
120  private:
121  std::shared_ptr<Impl> _value;
122  };
123 
125  Attributes read_attributes() const;
126 
128  Shape(std::shared_ptr<Impl> impl) { _impl=impl; }
129  };
130 
131  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<int32_t> Shape::write_attribute<Buffer<int32_t>>(const char *attribute_name, Topology topology);
132  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<uint8_t> Shape::write_attribute<Buffer<uint8_t>>(const char *attribute_name, Topology topology);
133  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<uint32_t> Shape::write_attribute<Buffer<uint32_t>>(const char *attribute_name, Topology topology);
134  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<float> Shape::write_attribute<Buffer<float>>(const char *attribute_name, Topology topology);
135  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<Imath::V2f> Shape::write_attribute<Buffer<Imath::V2f>>(const char *attribute_name, Topology topology);
136  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<Imath::V3f> Shape::write_attribute<Buffer<Imath::V3f>>(const char *attribute_name, Topology topology);
137  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT Buffer<Imath::V4f> Shape::write_attribute<Buffer<Imath::V4f>>(const char *attribute_name, Topology topology);
138 
139  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<int32_t> Shape::write_attribute<IndexedBuffer<int32_t>>(const char *attribute_name, Topology topology);
140  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<uint8_t> Shape::write_attribute<IndexedBuffer<uint8_t>>(const char *attribute_name, Topology topology);
141  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<uint32_t> Shape::write_attribute<IndexedBuffer<uint32_t>>(const char *attribute_name, Topology topology);
142  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<float> Shape::write_attribute<IndexedBuffer<float>>(const char *attribute_name, Topology topology);
143  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<Imath::V2f> Shape::write_attribute<IndexedBuffer<Imath::V2f>>(const char *attribute_name, Topology topology);
144  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<Imath::V3f> Shape::write_attribute<IndexedBuffer<Imath::V3f>>(const char *attribute_name, Topology topology);
145  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT IndexedBuffer<Imath::V4f> Shape::write_attribute<IndexedBuffer<Imath::V4f>>(const char *attribute_name, Topology topology);
146 
147  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<int32_t> Shape::write_attribute<SparseBuffer<int32_t>>(const char *attribute_name, Topology topology);
148  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<uint8_t> Shape::write_attribute<SparseBuffer<uint8_t>>(const char *attribute_name, Topology topology);
149  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<uint32_t> Shape::write_attribute<SparseBuffer<uint32_t>>(const char *attribute_name, Topology topology);
150  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<float> Shape::write_attribute<SparseBuffer<float>>(const char *attribute_name, Topology topology);
151  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<Imath::V2f> Shape::write_attribute<SparseBuffer<Imath::V2f>>(const char *attribute_name, Topology topology);
152  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<Imath::V3f> Shape::write_attribute<SparseBuffer<Imath::V3f>>(const char *attribute_name, Topology topology);
153  MAQUINA_EXTERN_TEMPLATE MAQUINA_EXPORT SparseBuffer<Imath::V4f> Shape::write_attribute<SparseBuffer<Imath::V4f>>(const char *attribute_name, Topology topology);
154  }
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT SparseBuffer< int32_t >
Definition: SparseBuffer.h:122
Topology
The different attribute topologies.
Definition: Shape.h:36
A Shape attribute, with name, value and topology.
Definition: Shape.h:74
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT IndexedBuffer< float >
Definition: IndexedBuffer.h:113
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT Buffer< uint8_t >
Definition: Buffer.h:216
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT SparseBuffer< float >
Definition: SparseBuffer.h:125
StringView name
The attribute name.
Definition: Shape.h:77
A value with geometrical attributes. Base of all shape values.
Definition: Shape.h:26
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:112
A shape attributes iterator.
Definition: Shape.h:90
The attribute is a per-vertex buffer.
Definition: Shape.h:39
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT IndexedBuffer< int32_t >
Definition: IndexedBuffer.h:110
maquina::Shape::Topology topology
The attribute topology.
Definition: Shape.h:81
#define MAQUINA_EXPORT
Definition: Export.h:31
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT SparseBuffer< uint8_t >
Definition: SparseBuffer.h:123
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT Buffer< int32_t >
Definition: Buffer.h:215
bool operator!=(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:305
An shape&#39;s attribute iteration.
Definition: Shape.h:86
maquina::Value value
The attribute value.
Definition: Shape.h:79
bool operator==(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:273
#define MAQUINA_EXTERN_TEMPLATE
Definition: Export.h:25
The attribute is a per-face buffer.
Definition: Shape.h:40
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT Buffer< float >
Definition: Buffer.h:218
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT IndexedBuffer< uint8_t >
Definition: IndexedBuffer.h:111
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT Buffer< uint32_t >
Definition: Buffer.h:217
The attribute is a per-face corner buffer.
Definition: Shape.h:41
MAQUINA_EXTERN_TEMPLATE class MAQUINA_EXPORT SparseBuffer< uint32_t >
Definition: SparseBuffer.h:124
Color4< T > operator*(S a, const Color4< T > &v)
Definition: ImathColor.h:727
Base class of all Rumba values.
Definition: Value.h:34