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
34MRMESH_API OnEdgeSplit meshOnEdgeSplitAttribute( const Mesh& mesh, const MeshAttributesToUpdate& params );
35
36MRMESH_API OnEdgeSplit meshOnEdgeSplitVertAttribute( const Mesh& mesh, const MeshAttributesToUpdate& params );
37
38MRMESH_API OnEdgeSplit meshOnEdgeSplitFaceAttribute( const Mesh& mesh, const MeshAttributesToUpdate& params );
39
40template <typename T>
42{
43 auto onEdgeSplit = [&] ( EdgeId e1, EdgeId e )
44 {
45 const auto org = mesh.topology.org( e1 );
46 const auto dest = mesh.topology.dest( e );
47 if ( org < data.size() && dest < data.size() )
48 data.push_back( data[org] * 0.5f + data[dest] * 0.5f );
49 };
50
51 return onEdgeSplit;
52}
53
54template <typename T>
56{
57 auto onEdgeSplit = [&] ( EdgeId e1, EdgeId e )
58 {
60 auto oldLeft = mesh.topology.left( e );
62 auto newLeft = mesh.topology.left( e1 );
63
64 if ( newLeft && oldLeft && oldLeft < data.size() )
65 data.autoResizeSet( newLeft, data[oldLeft] );
66
68 auto oldRight = mesh.topology.right( e );
70 auto newRight = mesh.topology.right( e1 );
71
72 if ( newRight && oldRight && oldRight < data.size() )
73 data.autoResizeSet( newRight, data[oldRight] );
74 };
75
76 return onEdgeSplit;
77}
78
79}
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:23
MRMESH_API OnEdgeSplit meshOnEdgeSplitVertAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
std::size_t size() const
Definition MRVector.h:55
FaceId left(EdgeId he) const
returns left face of half-edge
Definition MRMeshTopology.h:99
VertId dest(EdgeId he) const
returns destination vertex of half-edge
Definition MRMeshTopology.h:96
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:93
auto onEdgeSplitVertAttribute(const Mesh &mesh, Vector< T, VertId > &data)
Definition MRMeshSubdivideCallbacks.h:41
auto onEdgeSplitFaceAttribute(const Mesh &mesh, Vector< T, FaceId > &data)
Definition MRMeshSubdivideCallbacks.h:55
MRMESH_API OnEdgeSplit meshOnEdgeSplitFaceAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
FaceId right(EdgeId he) const
returns right face of half-edge
Definition MRMeshTopology.h:102
void autoResizeSet(I pos, size_t len, T val) MR_REQUIRES_IF_SUPPORTED(sizeof(T)>0 &&std
Definition MRVector.h:100
MRMESH_API OnEdgeSplit meshOnEdgeSplitAttribute(const Mesh &mesh, const MeshAttributesToUpdate &params)
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:23
MeshTopology topology
Definition MRMesh.h:24