Blender
V4.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
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
struct
Mesh
;
19
20
namespace
blender::io::stl
{
21
class
Triangle
{
22
public
:
23
int
v1
,
v2
,
v3
;
24
/* Based on an old version of Python's frozen-set hash
25
* https://web.archive.org/web/20220520211017/https://stackoverflow.com/questions/20832279/python-frozenset-hashing-algorithm-implementation
26
*/
27
uint64_t
hash
()
const
28
{
29
uint64_t
res = 1927868237UL;
30
res *= 4;
31
res ^= (
v1
^ (
v1
<< 16) ^ 89869747UL) * 3644798167UL;
32
res ^= (
v2
^ (
v2
<< 16) ^ 89869747UL) * 3644798167UL;
33
res ^= (
v3
^ (
v3
<< 16) ^ 89869747UL) * 3644798167UL;
34
return
res * 69069U + 907133923UL;
35
}
36
friend
bool
operator==
(
const
Triangle
&a,
const
Triangle
&
b
)
37
{
38
bool
i = (a.v1 ==
b
.v1) && (a.v2 ==
b
.v2) && (a.v3 ==
b
.v3);
39
bool
j = (a.v1 ==
b
.v1) && (a.v3 ==
b
.v2) && (a.v2 ==
b
.v3);
40
bool
k = (a.v2 ==
b
.v1) && (a.v1 ==
b
.v2) && (a.v3 ==
b
.v3);
41
42
bool
l
= (a.v2 ==
b
.v1) && (a.v3 ==
b
.v2) && (a.v1 ==
b
.v3);
43
bool
m = (a.v3 ==
b
.v1) && (a.v1 ==
b
.v2) && (a.v2 ==
b
.v3);
44
bool
n = (a.v3 ==
b
.v1) && (a.v2 ==
b
.v2) && (a.v1 ==
b
.v3);
45
46
return
i || j || k ||
l
|| m || n;
47
}
48
};
49
50
class
STLMeshHelper
{
51
private
:
52
VectorSet<float3>
verts_;
53
VectorSet<Triangle>
tris_;
54
Vector<float3>
loop_normals_;
55
int
degenerate_tris_num_;
56
int
duplicate_tris_num_;
57
const
bool
use_custom_normals_;
58
59
public
:
60
STLMeshHelper
(
int
tris_num,
bool
use_custom_normals);
61
62
/* Creates a new triangle from specified vertex locations,
63
* duplicate vertices and triangles are merged.
64
*/
65
bool
add_triangle
(
const
PackedTriangle
&data);
66
67
Mesh
*
to_mesh
();
68
};
69
70
}
// namespace blender::io::stl
BLI_math_vector_types.hh
BLI_vector.hh
BLI_vector_set.hh
l
ATTR_WARN_UNUSED_RESULT const BMLoop * l
Definition
bmesh_query_inline.hh:26
blender::VectorSet
Definition
BLI_vector_set.hh:90
blender::Vector
Definition
BLI_vector.hh:65
blender::io::stl::STLMeshHelper
Definition
stl_import_mesh.hh:50
blender::io::stl::STLMeshHelper::add_triangle
bool add_triangle(const PackedTriangle &data)
Definition
stl_import_mesh.cc:36
blender::io::stl::STLMeshHelper::to_mesh
Mesh * to_mesh()
Definition
stl_import_mesh.cc:56
blender::io::stl::STLMeshHelper::STLMeshHelper
STLMeshHelper(int tris_num, bool use_custom_normals)
Definition
stl_import_mesh.cc:23
blender::io::stl::Triangle
Definition
stl_import_mesh.hh:21
blender::io::stl::Triangle::v1
int v1
Definition
stl_import_mesh.hh:23
blender::io::stl::Triangle::v3
int v3
Definition
stl_import_mesh.hh:23
blender::io::stl::Triangle::operator==
friend bool operator==(const Triangle &a, const Triangle &b)
Definition
stl_import_mesh.hh:36
blender::io::stl::Triangle::hash
uint64_t hash() const
Definition
stl_import_mesh.hh:27
blender::io::stl::Triangle::v2
int v2
Definition
stl_import_mesh.hh:23
b
local_group_size(16, 16) .push_constant(Type b
Definition
compositor_morphological_distance_info.hh:16
blender::io::stl
Definition
stl_export.cc:38
uint64_t
unsigned __int64 uint64_t
Definition
stdint.h:90
stl_data.hh
Mesh
Definition
DNA_mesh_types.h:56
blender::io::stl::PackedTriangle
Definition
stl_data.hh:14
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0