All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
importTranslator.h
1 //
2 // Copyright 2019 Google LLC
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 
25 #ifndef USDDRACO_IMPORT_TRANSLATOR_H
26 #define USDDRACO_IMPORT_TRANSLATOR_H
27 
28 #include "attributeDescriptor.h"
29 #include "importAttribute.h"
30 
31 #include "pxr/pxr.h"
32 #include "pxr/usd/usdGeom/mesh.h"
33 
34 #include <draco/mesh/corner_table.h>
35 #include <draco/mesh/mesh.h>
36 
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
46 public:
48  static SdfLayerRefPtr Translate(const draco::Mesh &dracoMesh);
49 
50 private:
51  typedef draco::AttributeValueIndex PositionIndex;
52  typedef std::map<PositionIndex, draco::PointIndex> PolygonEdges;
53 
54  UsdDracoImportTranslator(const draco::Mesh &dracoMesh);
55  SdfLayerRefPtr _Translate();
56  VtVec3fArray _ComputeExtent() const;
57  bool _CheckDescriptors() const;
58  bool _CheckData() const;
59  void _PopulateValuesFromMesh();
60  void _PopulateIndicesFromMesh();
61  void _SetIndices(size_t vertexIndex, draco::PointIndex pointIndex);
62  void _SetAttributesToMesh(UsdGeomMesh *usdMesh) const;
63  bool _HasTrianglesOnly() const;
64  bool _SubdivisionRefersToPositions(const UsdGeomMesh &usdMesh) const;
65  bool _SubdivisionRefersToFaces(const UsdGeomMesh &usdMesh) const;
66  void _FindOriginalFaceEdges(draco::FaceIndex faceIndex,
67  const draco::CornerTable *cornerTable,
68  std::vector<bool> &triangleVisited,
69  PolygonEdges &polygonEdges);
70  std::unique_ptr<UsdDracoImportAttributeInterface>
71  CreateAttributeFrom(const draco::PointAttribute &attribute,
72  const draco::AttributeMetadata &metadata);
73 
74 private:
75  const draco::Mesh &_dracoMesh;
76 
77  // Named attributes.
84 
85  // Generic attributes.
86  std::vector<std::unique_ptr<UsdDracoImportAttributeInterface>>
87  _genericAttributes;
88 
89  VtIntArray _faceVertexCounts;
90  VtIntArray _faceVertexIndices;
91  VtIntArray _holeIndices;
92 };
93 
94 
95 PXR_NAMESPACE_CLOSE_SCOPE
96 
97 #endif // USDDRACO_IMPORT_TRANSLATOR_H
static SdfLayerRefPtr Translate(const draco::Mesh &dracoMesh)
Translates Draco mesh to USD mesh and returns USD layer with mesh.
Translates Draco mesh to USD mesh.
Encodes a mesh surface whose definition and feature-set will converge with that of OpenSubdiv...
Definition: mesh.h:86