Free Electron
SurfaceAccessorCatalog.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_SurfaceAccessorCatalog_h__
8 #define __surface_SurfaceAccessorCatalog_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 //* TODO coordinate counts between accessors
16 
17 /**************************************************************************//**
18  @brief Accessor backed with a Catalog
19 
20  @ingroup surface
21 *//***************************************************************************/
22 class FE_DL_EXPORT SurfaceAccessorCatalog:
23  virtual public SurfaceAccessorBase,
24  public CastableAs<SurfaceAccessorCatalog>
25 {
26  public:
28 virtual ~SurfaceAccessorCatalog(void);
29 
30  using SurfaceAccessorBase::set;
31  using SurfaceAccessorBase::append;
32  using SurfaceAccessorBase::spatialVector;
33 
34  //* as SurfaceAccessorI
35 virtual U32 count(void) const;
36 virtual U32 subCount(U32 a_index) const;
37 
38 virtual void set(U32 a_index,U32 subIndex,String a_string);
39 virtual String string(U32 a_index,U32 a_subIndex=0);
40 
41 virtual void set(U32 a_index,U32 a_subIndex,I32 a_integer);
42 virtual I32 integer(U32 a_index,U32 a_subIndex=0);
43 
44 virtual I32 append(I32 a_integer);
45 virtual I32 append(void);
46 virtual I32 append(SurfaceAccessibleI::Form a_form);
47 virtual void append(U32 a_index,I32 a_integer);
48 virtual void append(Array< Array<I32> >& a_rPrimVerts);
49 
50 virtual void set(U32 a_index,U32 a_subIndex,Real a_real);
51 virtual Real real(U32 a_index,U32 a_subIndex=0);
52 
53 virtual void set(U32 a_index,U32 a_subIndex,
54  const SpatialVector& a_spatialVector);
55 virtual SpatialVector spatialVector(U32 a_index,U32 a_subIndex=0);
56 
57  BWORD bind(SurfaceAccessibleI::Element a_element,
58  SurfaceAccessibleI::Attribute a_attribute)
59  {
60  m_attribute=a_attribute;
61 
62  String name;
63  switch(a_attribute)
64  {
65  case SurfaceAccessibleI::e_generic:
66  case SurfaceAccessibleI::e_position:
67  name="spc:at";
68  break;
69  case SurfaceAccessibleI::e_normal:
70  name="spc:up";
71  break;
72  case SurfaceAccessibleI::e_uv:
73  name="surf:uvw";
74  break;
75  case SurfaceAccessibleI::e_color:
76  name="surf:color";
77  break;
78  case SurfaceAccessibleI::e_vertices:
79  name="surf:points";
80  break;
81 // m_attrName="vertices";
82 // FEASSERT(a_element==
83 // SurfaceAccessibleI::e_primitive);
84 // m_element=a_element;
85 // return TRUE;
86  case SurfaceAccessibleI::e_properties:
87  name="properties";
88  break;
89 // m_attrName="properties";
90 // FEASSERT(a_element==
91 // SurfaceAccessibleI::e_primitive);
92 // m_element=a_element;
93 // return TRUE;
94  }
95  return bindInternal(a_element,name);
96  }
97  BWORD bind(SurfaceAccessibleI::Element a_element,
98  const String& a_name)
99  {
100  String name=a_name;
101  m_attribute=SurfaceAccessibleI::e_generic;
102 
103  if(name=="P")
104  {
105  name="spc:at";
106  m_attribute=SurfaceAccessibleI::e_position;
107  }
108  else if(name=="N")
109  {
110  name="spc:up";
111  m_attribute=SurfaceAccessibleI::e_normal;
112  }
113  else if(name=="uv")
114  {
115  name="surf:uvw";
116  m_attribute=SurfaceAccessibleI::e_uv;
117  }
118  else if(name=="Cd")
119  {
120  name="surf:color";
121  m_attribute=SurfaceAccessibleI::e_color;
122  }
123 
124  return bindInternal(a_element,name);
125  }
126 
127  //* Catalog specific
128  void setCatalog(sp<Catalog> a_spCatalog)
129  { m_spCatalog=a_spCatalog; }
130  void setKey(String a_key)
131  { m_key=a_key; }
132 
133  private:
134 
135  void bindVector(U32 a_subIndex,BWORD a_create);
136 
137 virtual BWORD bindInternal(SurfaceAccessibleI::Element a_element,
138  const String& a_name);
139 
140  void setAttrType(String a_attrType);
141 
142  sp<Catalog> m_spCatalog;
143  String m_key;
144 
145  Array<String>* m_pStringList;
146  Array<I32>* m_pIntegerList;
147  Array<Real>* m_pRealList;
148 
149  Array< Array<SpatialVector>* > m_vectorListArray;
150 };
151 
152 } /* namespace ext */
153 } /* namespace fe */
154 
155 #endif /* __surface_SurfaceAccessorCatalog_h__ */
Accessor backed with a Catalog.
Definition: SurfaceAccessorCatalog.h:22
kernel
Definition: namespace.dox:3
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
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192