Free Electron
SurfaceAccessorRecord.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __surface_SurfaceAccessorRecord_h__
8 #define __surface_SurfaceAccessorRecord_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Accessor for a Record-based Surface
17 
18  @ingroup surface
19 *//***************************************************************************/
20 class FE_DL_EXPORT SurfaceAccessorRecord:
21  virtual public SurfaceAccessorBase,
22  public CastableAs<SurfaceAccessorRecord>
23 {
24  public:
26 virtual ~SurfaceAccessorRecord(void);
27 
28  using SurfaceAccessorBase::set;
29  using SurfaceAccessorBase::append;
30  using SurfaceAccessorBase::spatialVector;
31 
32  //* as SurfaceAccessorI
33 virtual void setWritable(BWORD a_writable);
34 
35 virtual U32 count(void) const;
36 virtual U32 subCount(U32 a_index) const;
37 
38 virtual String type(void) const;
39 
40 virtual void set(U32 a_index,U32 a_subIndex,String a_string);
41 virtual String string(U32 a_index,U32 a_subIndex=0);
42 
43 virtual void set(U32 a_index,U32 a_subIndex,I32 a_integer);
44 virtual I32 integer(U32 a_index,U32 a_subIndex=0);
45 
46 virtual void append(U32 a_index,I32 a_integer);
47 virtual I32 append(I32 a_integer,SurfaceAccessibleI::Form a_form);
48 virtual I32 append(SurfaceAccessibleI::Form a_form);
49 virtual void append(Array< Array<I32> >& a_rPrimVerts);
50 
51 virtual void remove(U32 a_index,I32 a_integer=0);
52 
53 virtual void set(U32 a_index,U32 a_subIndex,Real a_real);
54 virtual Real real(U32 a_index,U32 a_subIndex=0);
55 
56 virtual void set(U32 a_index,U32 a_subIndex,
57  const SpatialVector& a_vector);
58 virtual SpatialVector spatialVector(U32 a_index,U32 a_subIndex=0);
59 virtual BWORD spatialVector(SpatialVector* a_pVectorArray,
60  const Vector2i* a_pIndexArray,I32 a_arrayCount);
61 
62  BWORD bind(SurfaceAccessibleI::Element a_element,
63  SurfaceAccessibleI::Attribute a_attribute)
64  {
65  m_attribute=a_attribute;
66 
67  String name;
68  switch(a_attribute)
69  {
70  case SurfaceAccessibleI::e_generic:
71  case SurfaceAccessibleI::e_position:
72  name="spc:at";
73  break;
74  case SurfaceAccessibleI::e_normal:
75  name="spc:up";
76  break;
77  case SurfaceAccessibleI::e_uv:
78  name="surf:uvw";
79  break;
80  case SurfaceAccessibleI::e_color:
81  name="surf:color";
82  break;
83  case SurfaceAccessibleI::e_vertices:
84  name="surf:points";
85  break;
86 // m_attrName="vertices";
87 // FEASSERT(a_element==
88 // SurfaceAccessibleI::e_primitive);
89 // m_element=a_element;
90 // return TRUE;
91  case SurfaceAccessibleI::e_properties:
92  name="properties";
93  break;
94 // m_attrName="properties";
95 // FEASSERT(a_element==
96 // SurfaceAccessibleI::e_primitive);
97 // m_element=a_element;
98 // return TRUE;
99  }
100  return bindInternal(a_element,name);
101  }
102  BWORD bind(SurfaceAccessibleI::Element a_element,
103  const String& a_name)
104  {
105  String name=a_name;
106  m_attribute=SurfaceAccessibleI::e_generic;
107 
108  if(name=="P")
109  {
110  name="spc:at";
111  m_attribute=SurfaceAccessibleI::e_position;
112  }
113  else if(name=="N")
114  {
115  name="spc:up";
116  m_attribute=SurfaceAccessibleI::e_normal;
117  }
118  else if(name=="uv")
119  {
120  name="surf:uvw";
121  m_attribute=SurfaceAccessibleI::e_uv;
122  }
123  else if(name=="Cd")
124  {
125  name="surf:color";
126  m_attribute=SurfaceAccessibleI::e_color;
127  }
128 
129  return bindInternal(a_element,name);
130  }
131 
132  void bind(WeakRecord& a_rRecord)
133  { m_weakRecord=a_rRecord; }
134 
135  private:
136 
137 virtual BWORD bindInternal(SurfaceAccessibleI::Element a_element,
138  const String& a_name);
139 
140  sp<RecordArray> recordArray(void) const;
141  void ensureType(String a_attrType);
142  BWORD ensurePrimitiveArray(void);
143  void ensureGroupSetRecord(BWORD a_create);
144  I32 ensureVertex(U32 a_index,U32 a_subIndex);
145  BWORD ensurePointRV(void);
146 
147  WeakRecord m_weakRecord;
148  sp<RecordGroup> m_spRG;
149  sp<RecordArray> m_spRecordArray;
150  sp<RecordGroup> m_spPrimitiveRG; //* for e_vertex
151  sp<RecordArray> m_spPrimitiveArray; //* for e_vertex
152  sp<Layout> m_spLayout;
153  RecordArrayView<SurfacePoint> m_surfaceElementRAV;
154  RecordArrayView<SurfacePoint> m_surfacePointRAV; //* for e_vertices
155 
156  Accessor<String> m_accessorString;
157  Accessor<I32> m_accessorInteger;
158  Accessor<Real> m_accessorReal;
159  Accessor<SpatialVector> m_accessorSpatialVector;
160  Accessor<Color> m_accessorColor;
161 
162  Accessor< Array<I32> > m_vertexIndexAccessor;
163 
164  Record m_groupSetRecord;
165  Accessor<String> m_groupNameAccessor;
166  Accessor< std::set<I32> > m_groupSetAccessor;
167 
169 };
170 
171 } /* namespace ext */
172 } /* namespace fe */
173 
174 #endif /* __surface_SurfaceAccessorRecord_h__ */
kernel
Definition: namespace.dox:3
RecordView Iteration over a RecordArray.
Definition: RecordArrayView.h:37
Common Functionality for Accessor Surface.
Definition: SurfaceAccessorBase.h:20
Automatically reference-counted string container.
Definition: String.h:128
Wrapper for std::vector.
Definition: Array.h:21
Accessor for a Record-based Surface.
Definition: SurfaceAccessorRecord.h:20
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17