HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_OSDTopology.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GU_OSDTopology.h ( GU Library, C++)
7  *
8  * COMMENTS: Build OpenSubdiv TopologyRefiner directly from GU_Detail.
9  * Replaces GT-based topology path (GT_OSDTopology / GT_GEODetail).
10  */
11 
12 #pragma once
13 
14 #include "GU_API.h"
15 
16 #include <UT/UT_FloatArray.h>
17 #include <UT/UT_IntArray.h>
18 #include <UT/UT_Span.h>
19 #include <UT/UT_UniquePtr.h>
20 
21 #include <opensubdiv/version.h>
22 namespace OpenSubdiv { namespace OPENSUBDIV_VERSION { namespace Far {
23  class TopologyRefiner;
24 } } }
25 
26 class GU_Detail;
27 class GU_OSDEval;
28 
29 /// Builds an OpenSubdiv TopologyRefiner directly from GU_Detail polygons.
30 /// All polygons are treated as Catmull-Clark subdivision faces (no creases).
32 {
33 public:
35  ~GU_OSDTopology();
36 
37  GU_OSDTopology(const GU_OSDTopology &) = delete;
38  GU_OSDTopology &operator=(const GU_OSDTopology &) = delete;
39  GU_OSDTopology(GU_OSDTopology &&) noexcept;
41 
42  /// Build topology refiner from polygon mesh in GU_Detail.
43  /// Returns false if the detail has no polygons.
44  bool createFromDetail(const GU_Detail &gdp);
45 
46  bool hasRefiner() const { return refiner() != nullptr; }
47 
48  /// Convert coarse face/u/v to patch coordinates.
49  /// coarseFace values are GA primitive indices; the internal face remap
50  /// is applied automatically.
51  bool convertToPatch(
52  UT_Span<const int> coarseFace,
53  UT_Span<const float> coarseU,
54  UT_Span<const float> coarseV,
55  UT_IntArray &patchFace,
56  UT_FloatArray &patchU,
57  UT_FloatArray &patchV) const;
58 
59  /// GA prim index -> topology face index.
60  const UT_IntArray &faceRemap() const { return myFaceRemap; }
61 
62  friend class GU_OSDEval;
63 
64 private:
65  /// Access the refiner (for GU_OSDEval::setTopology).
66  const OpenSubdiv::Far::TopologyRefiner *refiner() const;
67 
68  struct State;
69  UT_UniquePtr<State> myState;
70  UT_IntArray myFaceRemap;
71 };
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
#define GU_API
Definition: GU_API.h:14
LeafData & operator=(const LeafData &)=delete
bool hasRefiner() const
const UT_IntArray & faceRemap() const
GA prim index -> topology face index.