Loading [MathJax]/extensions/TeX/AMSmath.js
Radium Engine  1.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CatmullClarkSubdivider.hpp
1#pragma once
2
3#include <Core/CoreMacros.hpp>
4#include <Core/Geometry/deprecated/TopologicalMesh.hpp>
5#include <Core/RaCore.hpp>
6#include <Core/Types.hpp>
7#include <OpenMesh/Core/Mesh/PolyMeshT.hh>
8#include <OpenMesh/Core/Utils/Property.hh>
9#include <OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh>
10#include <utility>
11#include <vector>
12
13namespace Ra {
14namespace Core {
15namespace Geometry {
16
23class RA_CORE_API CatmullClarkSubdivider
24 : public OpenMesh::Subdivider::Uniform::SubdividerT<deprecated::TopologicalMesh, Scalar>
25{
26 using base = OpenMesh::Subdivider::Uniform::SubdividerT<deprecated::TopologicalMesh, Scalar>;
33
34 public:
35 CatmullClarkSubdivider() : base() {}
36
37 explicit CatmullClarkSubdivider( deprecated::TopologicalMesh& mesh ) : base() {
38 attach( mesh );
39 }
40
41 ~CatmullClarkSubdivider() { detach(); }
42
43 public:
44 const char* name( void ) const override { return "CatmullClarkSubdivider"; }
45
51 // clang-format off
65 // clang-format on
66 void recompute( const Vector3Array& newCoarseVertices,
67 const Vector3Array& newCoarseNormals,
68 Vector3Array& newSubdivVertices,
69 Vector3Array& newSubdivNormals,
71
72 protected:
73 bool prepare( deprecated::TopologicalMesh& _m ) override;
74
75 bool cleanup( deprecated::TopologicalMesh& _m ) override;
76
77 bool subdivide( deprecated::TopologicalMesh& _m,
78 size_t _n,
79 const bool _update_points = true ) override;
80
81 private:
82 // topology helpers
83
85 void split_edge( deprecated::TopologicalMesh& mesh,
86 const deprecated::TopologicalMesh::EdgeHandle& eh,
87 size_t iter );
88
90 void split_face( deprecated::TopologicalMesh& mesh,
91 const deprecated::TopologicalMesh::FaceHandle& fh,
92 size_t iter );
93
94 // geometry helpers
95
97 void compute_midpoint( deprecated::TopologicalMesh& mesh,
98 const deprecated::TopologicalMesh::EdgeHandle& eh,
99 const bool update_points,
100 size_t iter );
101
103 void update_vertex( deprecated::TopologicalMesh& mesh,
104 const deprecated::TopologicalMesh::VertexHandle& vh,
105 size_t iter );
106
107 private:
109 OpenMesh::EPropHandleT<Scalar> m_creaseWeights;
110
112 OpenMesh::VPropHandleT<deprecated::TopologicalMesh::Point> m_vpPos;
113
115 OpenMesh::EPropHandleT<deprecated::TopologicalMesh::VertexHandle> m_epH;
116
118 OpenMesh::FPropHandleT<deprecated::TopologicalMesh::VertexHandle> m_fpH;
119
121 OpenMesh::FPropHandleT<deprecated::TopologicalMesh::Normal> m_normalPropF;
122
128
130 std::vector<SV_OPS> m_oldVertexOps;
131 std::vector<SV_OPS> m_newFaceVertexOps;
132 std::vector<SV_OPS> m_newEdgeVertexOps;
133 std::vector<SP_OPS> m_newEdgePropOps;
134 std::vector<SP_OPS> m_newFacePropOps;
135 SP_OPS m_triangulationPropOps;
136
138 OpenMesh::HPropHandleT<deprecated::TopologicalMesh::VertexHandle> m_hV;
139};
140
141} // namespace Geometry
142} // namespace Core
143} // 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:4