MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMeshSubdivideCallbacks.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMesh.h"
5
6namespace MR
7{
10
14template <typename T>
15auto onEdgeSplitVertAttribute( const Mesh& mesh, Vector<T, VertId>& data );
16
20template <typename T>
21auto onEdgeSplitFaceAttribute( const Mesh& mesh, Vector<T, FaceId>& data );
22
37
39
41
42#if __GNUC__ == 13 // false positive stringop-overflow from GCC 13 on the push_back below, arm64 only
43#pragma GCC diagnostic push
44#pragma GCC diagnostic ignored "-Wstringop-overflow"
45#endif
46
47template <typename T>
49{
50 auto onEdgeSplit = [&] ( EdgeId e1, EdgeId e )
51 {
52 const auto org = mesh.topology.org( e1 );
53 const auto dest = mesh.topology.dest( e );
54 if ( org < data.size() && dest < data.size() )
55 data.push_back( data[org] * 0.5f + data[dest] * 0.5f );
56 };
57
58 return onEdgeSplit;
59}
60
61#if __GNUC__ == 13
62#pragma GCC diagnostic pop
63#endif
64
65template <typename T>
67{
68 auto onEdgeSplit = [&] ( EdgeId e1, EdgeId e )
69 {
71 auto oldLeft = mesh.topology.left( e );
73 auto newLeft = mesh.topology.left( e1 );
74
75 if ( newLeft && oldLeft && oldLeft < data.size() )
76 data.autoResizeSet( newLeft, data[oldLeft] );
77
79 auto oldRight = mesh.topology.right( e );
81 auto newRight = mesh.topology.right( e1 );
82
83 if ( newRight && oldRight && oldRight < data.size() )
84 data.autoResizeSet( newRight, data[oldRight] );
85 };
86
87 return onEdgeSplit;
88}
89
90}
#define MRMESH_API
Definition MRMeshFwd.h:85
Vector<T> is indexed by size_t.
Definition MRVector.h:24
std::size_t size() const
Definition MRVector.h:70
OnEdgeSplit meshOnEdgeSplitFaceAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
FaceId left(EdgeId he) const
returns left face of half-edge
Definition MRMeshTopology.h:115
VertId dest(EdgeId he) const
returns destination vertex of half-edge
Definition MRMeshTopology.h:112
void autoResizeSet(I pos, size_t len, T val)
Definition MRVector.h:113
void push_back(const T &t MR_LIFETIME_CAPTURE_BY_NESTED(this))
Definition MRVector.h:145
VertId org(EdgeId he) const
returns origin vertex of half-edge
Definition MRMeshTopology.h:109
OnEdgeSplit meshOnEdgeSplitVertAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
auto onEdgeSplitVertAttribute(const Mesh &mesh, Vector< T, VertId > &data)
Definition MRMeshSubdivideCallbacks.h:48
auto onEdgeSplitFaceAttribute(const Mesh &mesh, Vector< T, FaceId > &data)
Definition MRMeshSubdivideCallbacks.h:66
OnEdgeSplit meshOnEdgeSplitAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
std::function< void(EdgeId e1, EdgeId e)> OnEdgeSplit
Definition MRMeshFwd.h:597
FaceId right(EdgeId he) const
returns right face of half-edge
Definition MRMeshTopology.h:118
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
the attribute data of the mesh that needs to be updated
Definition MRMeshAttributesToUpdate.h:13
Definition MRMesh.h:24
MeshTopology topology
Definition MRMesh.h:25