blob: 375d8a9379f8e499be4ffcb96fdf0fdde4148758 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// Copyright 2020 Blender Foundation. All rights reserved.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// Author: Sergey Sharybin
#ifndef OPENSUBDIV_MESH_TOPOLOGY_H_
#define OPENSUBDIV_MESH_TOPOLOGY_H_
#include "internal/base/memory.h"
#include "internal/base/type.h"
struct OpenSubdiv_Converter;
namespace blender {
namespace opensubdiv {
class VertexTopologyTag {
public:
float sharpness = 0.0f;
};
class EdgeTopologyTag {
public:
float sharpness = 0.0f;
};
// Simplified representation of mesh topology.
// Only includes parts of actual mesh topology which is needed to perform
// comparison between Application side and OpenSubddiv side.
class MeshTopology {
public:
MeshTopology();
MeshTopology(const MeshTopology &other) = default;
MeshTopology(MeshTopology &&other) noexcept = default;
~MeshTopology();
MeshTopology &operator=(const MeshTopology &other) = default;
MeshTopology &operator=(MeshTopology &&other) = default;
//////////////////////////////////////////////////////////////////////////////
// Vertices.
void setNumVertices(int num_vertices);
int getNumVertices() const;
void setVertexSharpness(int vertex_index, float sharpness);
float getVertexSharpness(int vertex_index) const;
//////////////////////////////////////////////////////////////////////////////
// Edges.
void setNumEdges(int num_edges);
// NOTE: Unless full topology was specified will return number of edges based
// on last edge index for which topology tag was specified.
int getNumEdges() const;
void setEdgeSharpness(int edge_index, float sharpness);
float getEdgeSharpness(int edge_index) const;
//////////////////////////////////////////////////////////////////////////////
// Comparison.
// Check whether this topology refiner defines same topology as the given
// converter.
bool isEqualToConverter(const OpenSubdiv_Converter *converter) const;
protected:
// Unless full topology was specified the number of edges is not know ahead
// of a time.
void ensureNumEdgesAtLeast(int num_edges);
// Geometry tags are stored sparsly.
//
// These functions ensures that the storage can be addressed by an index which
// corresponds to the given size.
void ensureVertexTagsSize(int num_vertices);
void ensureEdgeTagsSize(int num_edges);
int num_vertices_;
vector<VertexTopologyTag> vertex_tags_;
int num_edges_;
vector<EdgeTopologyTag> edge_tags_;
MEM_CXX_CLASS_ALLOC_FUNCS("MeshTopology");
};
} // namespace opensubdiv
} // namespace blender
#endif // OPENSUBDIV_MESH_TOPOLOGY_H_
|