MeshLib C++ Docs
Loading...
Searching...
No Matches
MRIdentifyVertices.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRVector3.h"
5#include "MRVector.h"
6#include "MRphmap.h"
7#include <cstring>
8
9namespace MR
10{
11
12namespace MeshBuilder
13{
14
17{
18 bool operator() ( const Vector3f & a, const Vector3f & b ) const
19 {
20 static_assert( sizeof( Vector3f ) == 12 );
21 char ax[12], bx[12];
22 std::memcpy( ax, &a, 12 );
23 std::memcpy( bx, &b, 12 );
24 return std::memcmp( ax, bx, 12 ) == 0;
25 }
26};
27
32class VertexIdentifier
33{
34public:
36 MRMESH_API void reserve( size_t numTris );
38 MRMESH_API void addTriangles( const std::vector<Triangle3f> & buffer );
40 size_t numTris() const { return t_.size(); }
42 Triangulation takeTriangulation() { return std::move( t_ ); }
44 VertCoords takePoints() { return std::move( points_ ); }
45
46private:
47 using VertInHMap = std::array<VertId*, 3>;
48 std::vector<VertInHMap> vertsInHMap_;
49 using HMap = ParallelHashMap<Vector3f, VertId, phmap::priv::hash_default_hash<Vector3f>, equalVector3f>;
50 HMap hmap_;
51 Triangulation t_;
52 VertCoords points_;
53};
54
55} //namespace MeshBuilder
56
57} //namespace MR
#define MRMESH_API
Definition MRMeshFwd.h:80
unsafe MR.Triangulation takeTriangulation()
unsafe void addTriangles(MR.Std.Const_Vector_StdArrayMRVector3f3 buffer)
unsafe void reserve(ulong numTris)
unsafe MR.VertCoords takePoints()
Definition MRCameraOrientationPlugin.h:8
this makes bit-wise comparison of two Vector3f's thus making two NaNs equal
Definition MRIdentifyVertices.h:17
bool operator()(const Vector3f &a, const Vector3f &b) const
Definition MRIdentifyVertices.h:18