Radium Engine  1.5.20
Loading...
Searching...
No Matches
CatmullClarkSubdivider.hpp
1#pragma once
2
3#include <Core/Geometry/deprecated/TopologicalMesh.hpp>
4
5#include <OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh>
6
7namespace Ra {
8namespace Core {
9namespace Geometry {
10
17class RA_CORE_API CatmullClarkSubdivider
18 : public OpenMesh::Subdivider::Uniform::SubdividerT<deprecated::TopologicalMesh, Scalar>
19{
20 using base = OpenMesh::Subdivider::Uniform::SubdividerT<deprecated::TopologicalMesh, Scalar>;
27
28 public:
29 CatmullClarkSubdivider() : base() {}
30
31 explicit CatmullClarkSubdivider( deprecated::TopologicalMesh& mesh ) : base() {
32 attach( mesh );
33 }
34
35 ~CatmullClarkSubdivider() { detach(); }
36
37 public:
38 const char* name( void ) const override { return "CatmullClarkSubdivider"; }
39
45 // clang-format off
59 // clang-format on
60 void recompute( const Vector3Array& newCoarseVertices,
61 const Vector3Array& newCoarseNormals,
62 Vector3Array& newSubdivVertices,
63 Vector3Array& newSubdivNormals,
65
66 protected:
67 bool prepare( deprecated::TopologicalMesh& _m ) override;
68
69 bool cleanup( deprecated::TopologicalMesh& _m ) override;
70
71 bool subdivide( deprecated::TopologicalMesh& _m,
72 size_t _n,
73 const bool _update_points = true ) override;
74
75 private:
76 // topology helpers
77
79 void split_edge( deprecated::TopologicalMesh& mesh,
80 const deprecated::TopologicalMesh::EdgeHandle& eh,
81 size_t iter );
82
84 void split_face( deprecated::TopologicalMesh& mesh,
85 const deprecated::TopologicalMesh::FaceHandle& fh,
86 size_t iter );
87
88 // geometry helpers
89
91 void compute_midpoint( deprecated::TopologicalMesh& mesh,
92 const deprecated::TopologicalMesh::EdgeHandle& eh,
93 const bool update_points,
94 size_t iter );
95
97 void update_vertex( deprecated::TopologicalMesh& mesh,
98 const deprecated::TopologicalMesh::VertexHandle& vh,
99 size_t iter );
100
101 private:
103 OpenMesh::EPropHandleT<Scalar> m_creaseWeights;
104
106 OpenMesh::VPropHandleT<deprecated::TopologicalMesh::Point> m_vpPos;
107
109 OpenMesh::EPropHandleT<deprecated::TopologicalMesh::VertexHandle> m_epH;
110
112 OpenMesh::FPropHandleT<deprecated::TopologicalMesh::VertexHandle> m_fpH;
113
115 OpenMesh::FPropHandleT<deprecated::TopologicalMesh::Normal> m_normalPropF;
116
122
124 std::vector<SV_OPS> m_oldVertexOps;
125 std::vector<SV_OPS> m_newFaceVertexOps;
126 std::vector<SV_OPS> m_newEdgeVertexOps;
127 std::vector<SP_OPS> m_newEdgePropOps;
128 std::vector<SP_OPS> m_newFacePropOps;
129 SP_OPS m_triangulationPropOps;
130
132 OpenMesh::HPropHandleT<deprecated::TopologicalMesh::VertexHandle> m_hV;
133};
134
135} // namespace Geometry
136} // namespace Core
137} // namespace Ra
@ Geometry
"Geometry" render objects are those loaded using Radium::IO and generated by GeometrySystem
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3