Free Electron
SurfaceAccessibleUsd.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 __usd_SurfaceAccessibleUsd_h__
8 #define __usd_SurfaceAccessibleUsd_h__
9 namespace fe
10 {
11 namespace ext
12 {
13 
14 /**************************************************************************//**
15  @brief USD Surface Binding
16 
17  @ingroup usd
18 *//***************************************************************************/
19 class FE_DL_EXPORT SurfaceAccessibleUsd:
20  public SurfaceAccessibleBase,
21  public CastableAs<SurfaceAccessibleUsd>
22 {
23  public:
24  SurfaceAccessibleUsd(void) {}
25 virtual ~SurfaceAccessibleUsd(void) {}
26 
27  //* As Protectable
28 virtual Protectable* clone(Protectable* pInstance=NULL);
29 
30  //* as SurfaceAccessibleI
31 
33 
34 virtual void bind(Instance a_instance)
35  {
36  m_usdStage=
37  a_instance.cast<UsdStageRefPtr>();
38  }
39 virtual BWORD isBound(void)
40  { return (m_usdStage!=0); }
41 
43 
44 virtual sp<SurfaceAccessorI> accessor(String a_node,Element a_element,
45  String a_name,
46  Creation a_create,Writable a_writable);
47 
48 virtual sp<SurfaceAccessorI> accessor(String a_node,Element a_element,
49  Attribute a_attribute,
50  Creation a_create,Writable a_writable);
51 
52  using SurfaceAccessibleBase::discard;
53 
54 virtual BWORD discard(SurfaceAccessibleI::Element a_element,
55  String a_name);
56 
58 
59 virtual BWORD load(String a_filename,
60  sp<Catalog> a_spSettings);
61 
63 
64 virtual BWORD save(String a_filename,
65  sp<Catalog> a_spSettings);
66 
67  using SurfaceAccessibleBase::attributeSpecs;
68 
69 virtual void attributeSpecs(
71  a_rSpecs,
72  String a_nodeName,
73  SurfaceAccessibleI::Element
74  a_element) const;
75 
77 
78 virtual I32 count(String a_node,
79  SurfaceAccessibleI::Element
80  a_element) const;
81 
83 
84  sp<SurfaceI> surface(String a_group,
85  SurfaceI::Restrictions a_restrictions);
86 
87  //* USD specific
88  void setUsdStage(UsdStageRefPtr a_usdStage)
89  { m_usdStage=a_usdStage; }
90 
91  UsdStageRefPtr usdStage(void) { return m_usdStage; }
92 
93  void isolateNode(String a_nodeName)
94  { m_isolateNode=a_nodeName; }
95  String isolatedNode(void)
96  { return m_isolateNode; }
97 
98  class PrimNode: public Counted
99  {
100  public:
101  PrimNode(void)
102  {
103  setName("PrimNode");
104  }
105 
106  UsdPrim usdPrim(void) const { return m_usdPrim; }
107  void setUsdPrim(UsdPrim a_usdPrim)
108  { m_usdPrim=a_usdPrim; }
109 
110  String usdType(void) const { return m_usdType; }
111  void setUsdType(String a_usdType)
112  { m_usdType=a_usdType; }
113 
114  String usdPath(void) const { return m_usdPath; }
115  void setUsdPath(String a_usdPath)
116  { m_usdPath=a_usdPath; }
117 
118  String usdParent(void) const { return m_usdParent; }
119  void setUsdParent(String a_usdParent)
120  { m_usdParent=a_usdParent; }
121 
122  SpatialVector extentMin(void) const { return m_extentMin; }
123  void setExtentMin(SpatialVector a_extentMin)
124  { m_extentMin=a_extentMin; }
125 
126  SpatialVector extentMax(void) const { return m_extentMax; }
127  void setExtentMax(SpatialVector a_extentMax)
128  { m_extentMax=a_extentMax; }
129 
130  Array<SurfaceAccessibleI::Spec>& pointSpecs(void)
131  { return m_pointSpecs; }
132  Array<SurfaceAccessibleI::Spec>& vertexSpecs(void)
133  { return m_vertexSpecs; }
134  Array<SurfaceAccessibleI::Spec>& primitiveSpecs(void)
135  { return m_primitiveSpecs; }
136  Array<SurfaceAccessibleI::Spec>& detailSpecs(void)
137  { return m_detailSpecs; }
138 
139  I32 pointCount(void) const
140  { return m_pointCount; }
141  I32 vertexCount(void) const
142  { return m_vertexCount; }
143  I32 primitiveCount(void) const
144  { return m_primitiveCount; }
145 
146  void setPointCount(I32 a_pointCount)
147  { m_pointCount=a_pointCount; }
148  void setVertexCount(I32 a_vertexCount)
149  { m_vertexCount=a_vertexCount; }
150  void setPrimitiveCount(I32 a_primitiveCount)
151  { m_primitiveCount=a_primitiveCount; }
152 
153  I32 count(Element a_element) const;
154 
155  private:
156 
157  UsdPrim m_usdPrim;
158  String m_usdType;
159  String m_usdPath;
160  String m_usdParent;
161  SpatialVector m_extentMin;
162  SpatialVector m_extentMax;
163 
164  Array<SurfaceAccessibleI::Spec> m_pointSpecs;
165  Array<SurfaceAccessibleI::Spec> m_vertexSpecs;
166  Array<SurfaceAccessibleI::Spec> m_primitiveSpecs;
167  Array<SurfaceAccessibleI::Spec> m_detailSpecs;
168 
169  I32 m_pointCount;
170  I32 m_vertexCount;
171  I32 m_primitiveCount;
172  };
173 
174 const Array< sp<PrimNode> >& nodeArray(void) const
175  { return m_nodeArray; }
176 
177  private:
178 
179 virtual void reset(void);
180 
181  BWORD interpret(void);
182 
183  sp<PrimNode> primNodeAt(String a_nodeName) const;
184 
185  UsdStageRefPtr m_usdStage;
186  String m_filename;
187  String m_isolateNode;
188  BWORD m_ytoz;
189  Real m_frame;
190 
191  Array< sp<PrimNode> > m_nodeArray;
192  std::map<String, sp<PrimNode> > m_nodeMap;
193 };
194 
195 } /* namespace ext */
196 } /* namespace fe */
197 
198 #endif /* __usd_SurfaceAccessibleUsd_h__ */
Common Functionality for Accessible Surface.
Definition: SurfaceAccessibleBase.h:20
virtual sp< SurfaceI > surface(void)
Return current underlying SurfaceI.
Definition: SurfaceAccessibleBase.h:143
Heap-based support for classes participating in fe::ptr <>
Definition: Counted.h:35
Base class providing protection counting for cp<>
Definition: Protectable.h:28
Smart pointer used with types represented by BaseType.
Definition: Instance.h:28
kernel
Definition: namespace.dox:3
virtual void bind(Instance a_instance)
associate with model data
Definition: SurfaceAccessibleUsd.h:34
USD Surface Binding.
Definition: SurfaceAccessibleUsd.h:19
virtual void bind(Instance a_instance)
associate with model data
Definition: SurfaceAccessibleBase.h:31
Automatically reference-counted string container.
Definition: String.h:128
int count(void) const
Return the count of references.
Definition: Counted.h:156
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
virtual BWORD isBound(void)
Return true if surface is available.
Definition: SurfaceAccessibleUsd.h:39
virtual BWORD save(String a_filename)
save model data to file
Definition: SurfaceAccessibleBase.h:48
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192
virtual BWORD load(String a_filename)
load model data from file
Definition: SurfaceAccessibleBase.h:45
virtual sp< SurfaceAccessorI > accessor(String a_node, Element a_element, String a_name, Creation a_create, Writable a_writable)
Return access to an attribute.
Definition: SurfaceAccessibleBase.h:87