All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hermiteCurves.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDGEOM_GENERATED_HERMITECURVES_H
25 #define USDGEOM_GENERATED_HERMITECURVES_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdGeom/api.h"
31 #include "pxr/usd/usdGeom/curves.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdGeom/tokens.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
45 PXR_NAMESPACE_OPEN_SCOPE
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // HERMITECURVES //
51 // -------------------------------------------------------------------------- //
52 
87 {
88 public:
93 
98  explicit UsdGeomHermiteCurves(const UsdPrim& prim=UsdPrim())
99  : UsdGeomCurves(prim)
100  {
101  }
102 
106  explicit UsdGeomHermiteCurves(const UsdSchemaBase& schemaObj)
107  : UsdGeomCurves(schemaObj)
108  {
109  }
110 
112  USDGEOM_API
113  virtual ~UsdGeomHermiteCurves();
114 
118  USDGEOM_API
119  static const TfTokenVector &
120  GetSchemaAttributeNames(bool includeInherited=true);
121 
131  USDGEOM_API
132  static UsdGeomHermiteCurves
133  Get(const UsdStagePtr &stage, const SdfPath &path);
134 
157  USDGEOM_API
158  static UsdGeomHermiteCurves
159  Define(const UsdStagePtr &stage, const SdfPath &path);
160 
161 protected:
165  USDGEOM_API
166  UsdSchemaKind _GetSchemaKind() const override;
167 
168 private:
169  // needs to invoke _GetStaticTfType.
170  friend class UsdSchemaRegistry;
171  USDGEOM_API
172  static const TfType &_GetStaticTfType();
173 
174  static bool _IsTypedSchema();
175 
176  // override SchemaBase virtuals.
177  USDGEOM_API
178  const TfType &_GetTfType() const override;
179 
180 public:
181  // --------------------------------------------------------------------- //
182  // TANGENTS
183  // --------------------------------------------------------------------- //
192  USDGEOM_API
194 
200  USDGEOM_API
201  UsdAttribute CreateTangentsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
202 
203 public:
204  // ===================================================================== //
205  // Feel free to add custom code below this line, it will be preserved by
206  // the code generator.
207  //
208  // Just remember to:
209  // - Close the class declaration with };
210  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
211  // - Close the include guard with #endif
212  // ===================================================================== //
213  // --(BEGIN CUSTOM CODE)--
214 
219  VtArray<GfVec3f> _points;
220  VtArray<GfVec3f> _tangents;
221 
222  explicit PointAndTangentArrays(const VtVec3fArray& interleaved);
223 
224  public:
225 
227  PointAndTangentArrays() = default;
230  PointAndTangentArrays& operator=(const PointAndTangentArrays&) =
231  default;
232  PointAndTangentArrays& operator=(PointAndTangentArrays&&) = default;
233 
238  PointAndTangentArrays(const VtVec3fArray& points,
239  const VtVec3fArray& tangents)
240  : _points(points), _tangents(tangents) {
241  if (_points.size() != _tangents.size()) {
242  TF_RUNTIME_ERROR("Points and tangents must be the same size.");
243  _points.clear();
244  _tangents.clear();
245  }
246  }
247 
250  USDGEOM_API static PointAndTangentArrays Separate(const VtVec3fArray& interleaved) {
251  return PointAndTangentArrays(interleaved);
252  }
253 
256  USDGEOM_API VtVec3fArray Interleave() const;
257 
259  bool IsEmpty() const {
260  // we only need to check the points, as we've verified on
261  // construction that _points and _tangents have the same size
262  return _points.empty();
263  }
264 
266  explicit operator bool() const { return !IsEmpty(); }
267 
269  const VtVec3fArray& GetPoints() const { return _points; }
270 
272  const VtVec3fArray& GetTangents() const { return _tangents; }
273 
274  bool operator==(const PointAndTangentArrays& other) {
275  return (GetPoints() == other.GetPoints()) &&
276  (GetTangents() == other.GetTangents());
277  }
278  bool operator!=(const PointAndTangentArrays& other) {
279  return !((*this) == other);
280  }
281  };
282 };
283 
284 PXR_NAMESPACE_CLOSE_SCOPE
285 
286 #endif
const VtVec3fArray & GetPoints() const
Get separated points array.
static USDGEOM_API UsdGeomHermiteCurves Define(const UsdStagePtr &stage, const SdfPath &path)
Attempt to ensure a UsdPrim adhering to this schema at path is defined (according to UsdPrim::IsDefin...
Base class for UsdGeomBasisCurves, UsdGeomNurbsCurves, and UsdGeomHermiteCurves.
Definition: curves.h:75
USDGEOM_API UsdAttribute GetTangentsAttr() const
Defines the outgoing trajectory tangent for each point.
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
static USDGEOM_API UsdGeomHermiteCurves Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdGeomHermiteCurves holding the prim adhering to this schema at path on stage...
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
bool IsEmpty() const
Returns true if the containers are empty.
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
UsdGeomHermiteCurves(const UsdSchemaBase &schemaObj)
Construct a UsdGeomHermiteCurves on the prim held by schemaObj .
Represents a concrete typed schema.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
size_t size() const
Return the total number of elements in this array.
Definition: array.h:505
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
static USDGEOM_API PointAndTangentArrays Separate(const VtVec3fArray &interleaved)
Given an interleaved points and tangents arrays (P0, T0, ..., Pn, Tn), separates them into two arrays...
virtual USDGEOM_API ~UsdGeomHermiteCurves()
Destructor.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
PointAndTangentArrays()=default
Construct empty points and tangents arrays.
Represents points and tangents of the same size.
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: hermiteCurves.h:92
TfType represents a dynamic runtime type.
Definition: type.h:64
USDGEOM_API UsdAttribute CreateTangentsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetTangentsAttr(), and also Create vs Get Property Methods for when to use Get vs Create...
const VtVec3fArray & GetTangents() const
Get separated tangents array.
Singleton registry that provides access to schema type information and the prim definitions for regis...
PointAndTangentArrays(const VtVec3fArray &points, const VtVec3fArray &tangents)
Initializes points and tangents if they are the same size.
USDGEOM_API VtVec3fArray Interleave() const
Interleaves points (P0, ..., Pn) and tangents (T0, ..., Tn) into one array (P0, T0, ..., Pn, Tn).
The base class for all schema types in Usd.
Definition: schemaBase.h:56
bool empty() const
Return true if this array contains no elements, false otherwise.
Definition: array.h:521
#define TF_RUNTIME_ERROR(fmt, args)
Issue a generic runtime error, but continue execution.
Definition: diagnostic.h:100
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
void clear()
Equivalent to resize(0).
Definition: array.h:633
This schema specifies a cubic hermite interpolated curve batch as sometimes used for defining guides ...
Definition: hermiteCurves.h:86
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
UsdGeomHermiteCurves(const UsdPrim &prim=UsdPrim())
Construct a UsdGeomHermiteCurves on UsdPrim prim .
Definition: hermiteCurves.h:98