MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMeshOrTriMesh.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMesh.h"
4#include "MRTriMesh.h"
5#include "MRTriMeshPart.h"
6#include "MRSaveSettings.h"
7#include "MRBitSet.h"
8
11namespace MR::detail
12{
13
16{
17 int numVerts = 0;
18 int sizeVerts() const { return numVerts; }
19 int operator()( VertId v ) const { assert( v ); return (int)v; }
20};
21
23inline VertRenumber getVertRenumber( const Mesh & mesh, bool packValidOnly ) { return VertRenumber( mesh.topology.getValidVerts(), packValidOnly ); }
24inline NoRenumber getVertRenumber( const TriMesh & mesh, bool ) { return { .numVerts = (int)mesh.points.size() }; }
25inline VertRenumber getVertRenumber( const TriMeshPart & part, bool packValidOnly ) { return VertRenumber( part.regionVerts, packValidOnly ); }
26
27inline VertId lastValidVert( const Mesh & mesh ) { return mesh.topology.lastValidVert(); }
28inline VertId lastValidVert( const TriMesh & mesh ) { return VertId( (int)mesh.points.size() - 1 ); }
29inline VertId lastValidVert( const TriMeshPart & part ) { return part.regionVerts.find_last(); }
30
31inline bool hasVert( const Mesh & mesh, VertId v ) { return mesh.topology.hasVert( v ); }
32inline bool hasVert( const TriMesh &, VertId ) { return true; }
33inline bool hasVert( const TriMeshPart & part, VertId v ) { return part.regionVerts.test( v ); }
34
35inline const VertBitSet & validVerts( const Mesh & mesh ) { return mesh.topology.getValidVerts(); }
36inline VertBitSet validVerts( const TriMesh & mesh ) { return VertBitSet( mesh.points.size(), true ); }
37inline const VertBitSet & validVerts( const TriMeshPart & part ) { return part.regionVerts; }
38
39inline FaceId lastValidFace( const Mesh & mesh ) { return mesh.topology.lastValidFace(); }
40inline FaceId lastValidFace( const TriMesh & mesh ) { return FaceId( (int)mesh.tris.size() - 1 ); }
41inline FaceId lastValidFace( const TriMeshPart & part ) { return part.region.find_last(); }
42
43inline int numValidFaces( const Mesh & mesh ) { return mesh.topology.numValidFaces(); }
44inline int numValidFaces( const TriMesh & mesh ) { return (int)mesh.tris.size(); }
45inline int numValidFaces( const TriMeshPart & part ) { return (int)part.region.count(); }
46
47inline bool hasFace( const Mesh & mesh, FaceId f ) { return mesh.topology.hasFace( f ); }
48inline bool hasFace( const TriMesh &, FaceId ) { return true; }
49inline bool hasFace( const TriMeshPart & part, FaceId f ) { return part.region.test( f ); }
50
51inline const FaceBitSet & validFaces( const Mesh & mesh ) { return mesh.topology.getValidFaces(); }
52inline FaceBitSet validFaces( const TriMesh & mesh ) { return FaceBitSet( mesh.tris.size(), true ); }
53inline const FaceBitSet & validFaces( const TriMeshPart & part ) { return part.region; }
54
55inline ThreeVertIds getTriVerts( const Mesh & mesh, FaceId f ) { return mesh.topology.getTriVerts( f ); }
56inline const ThreeVertIds & getTriVerts( const TriMesh & mesh, FaceId f ) { return mesh.tris[f]; }
57inline const ThreeVertIds & getTriVerts( const TriMeshPart & part, FaceId f ) { return part.tris[f]; }
58
59template<typename MeshType>
60Triangle3f getTriPoints( const MeshType & mesh, FaceId f )
61{
62 const auto [a, b, c] = getTriVerts( mesh, f );
63 return { mesh.points[a], mesh.points[b], mesh.points[c] };
64}
65
66}
maps valid points to packed sequential indices
Definition MRSaveSettings.h:96
Triangulation tris
Definition MRTriMesh.h:17
void getTriVerts(FaceId f, VertId &v0, VertId &v1, VertId &v2) const
Definition MRMeshTopology.h:163
const Triangulation & tris
Definition MRTriMeshPart.h:14
VertCoords points
Definition MRTriMesh.h:18
bool hasVert(VertId a) const
returns true if given vertex is present in the mesh
Definition MRMeshTopology.h:212
bool hasFace(FaceId a) const
returns true if given face is present in the mesh
Definition MRMeshTopology.h:260
FaceId lastValidFace() const
returns last valid face id, or invalid id if no single valid face exists
int numValidFaces() const
returns the number of valid faces
Definition MRMeshTopology.h:275
VertBitSet regionVerts
vertices of region triangles
Definition MRTriMeshPart.h:17
const FaceBitSet & region
Definition MRTriMeshPart.h:16
Triangle3< float > Triangle3f
Definition MRMeshFwd.h:466
const VertBitSet & getValidVerts() const
returns cached set of all valid vertices
Definition MRMeshTopology.h:239
const FaceBitSet & getValidFaces() const
returns cached set of all valid faces
Definition MRMeshTopology.h:317
VertId lastValidVert() const
returns last valid vertex id, or invalid id if no single valid vertex exists
for internal use: namespace detail is not bound to other languages
Definition MRAllocator.h:23
FaceId lastValidFace(const Mesh &mesh)
Definition MRMeshOrTriMesh.h:39
Triangle3f getTriPoints(const MeshType &mesh, FaceId f)
Definition MRMeshOrTriMesh.h:60
VertId lastValidVert(const Mesh &mesh)
Definition MRMeshOrTriMesh.h:27
bool hasFace(const Mesh &mesh, FaceId f)
Definition MRMeshOrTriMesh.h:47
ThreeVertIds getTriVerts(const Mesh &mesh, FaceId f)
Definition MRMeshOrTriMesh.h:55
const VertBitSet & validVerts(const Mesh &mesh)
Definition MRMeshOrTriMesh.h:35
const FaceBitSet & validFaces(const Mesh &mesh)
Definition MRMeshOrTriMesh.h:51
int numValidFaces(const Mesh &mesh)
Definition MRMeshOrTriMesh.h:43
bool hasVert(const Mesh &mesh, VertId v)
Definition MRMeshOrTriMesh.h:31
VertRenumber getVertRenumber(const Mesh &mesh, bool packValidOnly)
maps valid vertices to packed sequential indices (if packValidOnly = true) or keeps the same indices
Definition MRMeshOrTriMesh.h:23
Definition MRMesh.h:24
MeshTopology topology
Definition MRMesh.h:25
three vertex ids describing a triangle with the corners in vertices given by their ids
Definition MRId.h:203
TriMesh with a region of triangles: only the triangles of the region and their vertices are valid.
Definition MRTriMeshPart.h:13
Definition MRTriMesh.h:16
identity vertex renumbering for TriMesh
Definition MRMeshOrTriMesh.h:16
int numVerts
Definition MRMeshOrTriMesh.h:17
int operator()(VertId v) const
Definition MRMeshOrTriMesh.h:19
int sizeVerts() const
Definition MRMeshOrTriMesh.h:18