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
35
37
39
40#if __GNUC__ == 13
41#pragma GCC diagnostic push
42#pragma GCC diagnostic ignored "-Wstringop-overflow"
43#endif
44
45template <typename T>
47{
48 auto onEdgeSplit = [&] ( EdgeId e1, EdgeId e )
49 {
50 const auto org = mesh.topology.org( e1 );
51 const auto dest = mesh.topology.dest( e );
52 if ( org < data.size() && dest < data.size() )
53 data.push_back( data[org] * 0.5f + data[dest] * 0.5f );
54 };
55
56 return onEdgeSplit;
57}
58
59#if __GNUC__ == 13
60#pragma GCC diagnostic pop
61#endif
62
63template <typename T>
65{
66 auto onEdgeSplit = [&] ( EdgeId e1, EdgeId e )
67 {
69 auto oldLeft = mesh.topology.left( e );
71 auto newLeft = mesh.topology.left( e1 );
72
73 if ( newLeft && oldLeft && oldLeft < data.size() )
74 data.autoResizeSet( newLeft, data[oldLeft] );
75
77 auto oldRight = mesh.topology.right( e );
79 auto newRight = mesh.topology.right( e1 );
80
81 if ( newRight && oldRight && oldRight < data.size() )
82 data.autoResizeSet( newRight, data[oldRight] );
83 };
84
85 return onEdgeSplit;
86}
87
88}
#define MRMESH_API
Definition MRMeshFwd.h:85
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:23
std::size_t size() const
Definition MRVector.h:55
OnEdgeSplit meshOnEdgeSplitFaceAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
FaceId left(EdgeId he) const
returns left face of half-edge
Definition MRMeshTopology.h:110
VertId dest(EdgeId he) const
returns destination vertex of half-edge
Definition MRMeshTopology.h:107
void push_back(const T &t MR_LIFETIME_CAPTURE_BY_NESTED(this))
Definition MRVector.h:132
VertId org(EdgeId he) const
returns origin vertex of half-edge
Definition MRMeshTopology.h:104
OnEdgeSplit meshOnEdgeSplitVertAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
auto onEdgeSplitVertAttribute(const Mesh &mesh, Vector< T, VertId > &data)
false positive stringop-overflow from GCC 13 on the push_back below, arm64 only
Definition MRMeshSubdivideCallbacks.h:46
auto onEdgeSplitFaceAttribute(const Mesh &mesh, Vector< T, FaceId > &data)
Definition MRMeshSubdivideCallbacks.h:64
OnEdgeSplit meshOnEdgeSplitAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
std::function< void(EdgeId e1, EdgeId e)> OnEdgeSplit
Definition MRMeshFwd.h:574
FaceId right(EdgeId he) const
returns right face of half-edge
Definition MRMeshTopology.h:113
void autoResizeSet(I pos, size_t len, T val) MR_REQUIRES_IF_SUPPORTED(sizeof(T)>0 &&std
Definition MRVector.h:100
only for bindings generation
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