Blender
V5.3
source
blender
io
stl
importer
stl_import_mesh.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#pragma once
10
11
#include <cstdint>
12
13
#include "
BLI_math_vector_types.hh
"
14
#include "
BLI_vector.hh
"
15
#include "
BLI_vector_set.hh
"
16
#include "
stl_data.hh
"
17
18
namespace
blender
{
19
20
struct
Mesh
;
21
22
namespace
io::stl
{
23
class
Triangle
{
24
public
:
25
int
v1
,
v2
,
v3
;
26
/* Based on an old version of Python's frozen-set hash
27
* https://web.archive.org/web/20220520211017/https://stackoverflow.com/questions/20832279/python-frozenset-hashing-algorithm-implementation
28
*/
29
uint64_t
hash
()
const
30
{
31
uint64_t
res = 1927868237UL;
32
res *= 4;
33
res ^= (
v1
^ (
v1
<< 16) ^ 89869747UL) * 3644798167UL;
34
res ^= (
v2
^ (
v2
<< 16) ^ 89869747UL) * 3644798167UL;
35
res ^= (
v3
^ (
v3
<< 16) ^ 89869747UL) * 3644798167UL;
36
return
res * 69069U + 907133923UL;
37
}
38
friend
bool
operator==
(
const
Triangle
&a,
const
Triangle
&
b
)
39
{
40
bool
i = (a.
v1
==
b
.v1) && (a.
v2
==
b
.v2) && (a.
v3
==
b
.v3);
41
bool
j = (a.
v1
==
b
.v1) && (a.
v3
==
b
.v2) && (a.
v2
==
b
.v3);
42
bool
k = (a.
v2
==
b
.v1) && (a.
v1
==
b
.v2) && (a.
v3
==
b
.v3);
43
44
bool
l
= (a.
v2
==
b
.v1) && (a.
v3
==
b
.v2) && (a.
v1
==
b
.v3);
45
bool
m = (a.
v3
==
b
.v1) && (a.
v1
==
b
.v2) && (a.
v2
==
b
.v3);
46
bool
n = (a.
v3
==
b
.v1) && (a.
v2
==
b
.v2) && (a.
v1
==
b
.v3);
47
48
return
i || j || k ||
l
|| m || n;
49
}
50
};
51
52
class
STLMeshHelper
{
53
private
:
54
VectorSet<float3>
verts_;
55
VectorSet<Triangle>
tris_;
56
Vector<float3>
loop_normals_;
57
int
degenerate_tris_num_;
58
int
duplicate_tris_num_;
59
const
bool
use_custom_normals_;
60
61
public
:
62
STLMeshHelper
(
int
tris_num,
bool
use_custom_normals);
63
64
/* Creates a new triangle from specified vertex locations,
65
* duplicate vertices and triangles are merged.
66
*/
67
bool
add_triangle
(
const
PackedTriangle
&
data
);
68
69
Mesh
*
to_mesh
();
70
};
71
72
}
// namespace io::stl
73
}
// namespace blender
BLI_math_vector_types.hh
BLI_vector.hh
BLI_vector_set.hh
blender::VectorSet
Definition
BLI_vector_set.hh:94
blender::Vector
Definition
BLI_vector.hh:76
blender::io::stl::STLMeshHelper::add_triangle
bool add_triangle(const PackedTriangle &data)
Definition
stl_import_mesh.cc:40
blender::io::stl::STLMeshHelper::to_mesh
Mesh * to_mesh()
Definition
stl_import_mesh.cc:60
blender::io::stl::STLMeshHelper::STLMeshHelper
STLMeshHelper(int tris_num, bool use_custom_normals)
Definition
stl_import_mesh.cc:27
blender::io::stl::Triangle
Definition
stl_import_mesh.hh:23
blender::io::stl::Triangle::v1
int v1
Definition
stl_import_mesh.hh:25
blender::io::stl::Triangle::v3
int v3
Definition
stl_import_mesh.hh:25
blender::io::stl::Triangle::operator==
friend bool operator==(const Triangle &a, const Triangle &b)
Definition
stl_import_mesh.hh:38
blender::io::stl::Triangle::hash
uint64_t hash() const
Definition
stl_import_mesh.hh:29
blender::io::stl::Triangle::v2
int v2
Definition
stl_import_mesh.hh:25
b
b
Definition
compositor_morphological_distance_infos.hh:36
blender::io::stl
Definition
stl_export.cc:47
blender
BMesh Iterators.
Definition
ANIM_action.hh:30
blender::uint64_t
unsigned __int64 uint64_t
Definition
BKE_text.h:91
blender::l
ATTR_WARN_UNUSED_RESULT const BMLoop * l
Definition
bmesh_query_inline.hh:34
blender::data
BMesh const char void * data
Definition
bmesh_iterators_inline.hh:39
stl_data.hh
blender::Mesh
Definition
DNA_mesh_types.h:148
blender::io::stl::PackedTriangle
Definition
stl_data.hh:14
Generated on
for Blender by
doxygen
1.18.0