Blender V5.3
opensubdiv_topology_refiner.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2016 Blender Foundation
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 *
5 * Author: Sergey Sharybin. */
6
7#ifndef OPENSUBDIV_TOPOLOGY_REFINER_IMPL_H_
8#define OPENSUBDIV_TOPOLOGY_REFINER_IMPL_H_
9
10#ifdef _MSC_VER
11# include <iso646.h>
12#endif
13
14#include <vector>
15
16#include <opensubdiv/far/topologyRefiner.h>
17
18#include "MEM_guardedalloc.h"
19
20// Those settings don't really belong to OpenSubdiv's topology refiner, but
21// we are keeping track of them on our side of topology refiner. This is to
22// make it possible to ensure we are not trying to abuse same OpenSubdiv's
23// topology refiner with different subdivision levels or with different
24// adaptive settings.
29
31
32namespace blender::opensubdiv {
33
35 public:
36 // NOTE: Will return nullptr if topology refiner can not be created (for
37 // example, when topology is detected to be corrupted or invalid).
40
43
44 const OpenSubdiv::Far::TopologyLevel &base_level() const
45 {
46 return topology_refiner->GetLevel(0);
47 }
48
49 // Check whether this topology refiner defines same topology as the given
50 // converter.
51 // Covers options, geometry, and geometry tags.
52 bool isEqualToConverter(const OpenSubdiv_Converter *converter) const;
53
54 OpenSubdiv::Far::TopologyRefiner *topology_refiner;
55
56 // Subdivision settingsa this refiner is created for.
58
60 // Topology of the mesh which corresponds to the base level.
61 //
62 // Only the parts which are needed to tell whether a different converter describes the same mesh
63 // are stored. See #isEqualToConverter.
64 //
65 // All the indices and values are exactly the ones the converter provided: they are copied
66 // straight from it before the refiner is built, never read back out of the refiner. That is
67 // what makes them comparable against a later converter, since the refinement process changes
68 // the values the refiner itself stores:
69 //
70 // - Face vertices, where OpenSubdiv could re-arrange them to keep winding
71 // uniform.
72 //
73 // - Vertex crease where OpenSubdiv will force crease for non-manifold or
74 // corner vertices.
75
77
78 // The pair of vertices each edge connects, but only up to the last edge which has sharpness.
79 //
80 // Sharpness is the only per-edge data which can not be derived from the faces, so the vertices
81 // of the remaining edges never have to be compared. Many meshes have no sharp edges at all, in
82 // which case this stays empty.
83 std::vector<std::pair<int, int>> base_edges_sparse;
84
85 // Sharpness of each edge, matching #OpenSubdiv_Converter::edge_sharpness: either one element per
86 // edge of the base mesh, or empty when no edge is sharp. Since it is stored densely, comparing
87 // it against a converter also compares the number of edges.
88 std::vector<float> base_edge_sharpness;
89
90 // The face topology of the base mesh, see #OffsetIndices and #Mesh::faces().
91 std::vector<int> base_face_offsets;
92
93 // Continuous array of all vertices of all faces, sliced by the face offsets.
94 std::vector<int> base_corner_verts;
95
96 // Sharpness of each vertex, matching #OpenSubdiv_Converter::vert_sharpness: either
97 // #base_verts_num elements, or empty when no vertex is sharp.
98 std::vector<float> base_vert_sharpness;
99
100 MEM_CXX_CLASS_ALLOC_FUNCS("TopologyRefinerImpl");
101};
102
103} // namespace blender::opensubdiv
104
105#endif // OPENSUBDIV_TOPOLOGY_REFINER_IMPL_H_
Read Blender memory allocation and freeing.
const OpenSubdiv::Far::TopologyLevel & base_level() const
MEM_CXX_CLASS_ALLOC_FUNCS("TopologyRefinerImpl")
OpenSubdiv::Far::TopologyRefiner * topology_refiner
static TopologyRefinerImpl * createFromConverter(OpenSubdiv_Converter *converter, const OpenSubdiv_TopologyRefinerSettings &settings)
bool isEqualToConverter(const OpenSubdiv_Converter *converter) const
std::vector< std::pair< int, int > > base_edges_sparse