MeVisLab Toolbox Reference
WEMNearestPointOnSurface.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2019, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#pragma once
14
16
17// #define WEM_BSH_DEBUG // un-comment this to get an idea of how many checks are performed
18
20
21namespace WEMBoundingSphereHierarchy {
22 class TreeElement;
23};
24
30{
31public:
35
37 bool isValid() const { return _bsh != nullptr; }
38
40 struct Result
41 {
42 Result() : patch(nullptr), triangle(nullptr) { w[0] = 0; w[1] = 0; w[2] = 0; }
43
49 double w[3];
50 };
51
54
55#ifdef WEM_BSH_DEBUG
56 // debugging interface:
57 static void incSphereChecks() { _sphereChecks++; }
58 static void incTriangleChecks() { _triangleChecks++; }
59#endif
60
61private:
63 WEMBoundingSphereHierarchy::TreeElement* _bsh;
64
65 // debugging/profiling data
66 int _usedTriangleCount;
67#ifdef WEM_BSH_DEBUG
68 // this is not thread-safe!!!
69 static int _sphereChecks;
70 static int _triangleChecks;
71#endif
72};
73
74
75
76
#define MLWEM_EXPORT
Definition MLWEMSystem.h:18
This class constructs a bounding sphere hierarchy of all non-empty triangles (i.e.
Result getNearestTriangle(const Vector3 &p) const
Get the nearest triangle point of the WEM relative to p.
WEMNearestPointOnSurface(WEM *wem)
WEM must solely consist of WEMTrianglePatches, otherwise isValid returns false.
bool isValid() const
Return if the given WEM only had triangle patches.
This represents a WEMPatch consisting of triangles only.
Defines the mesh component: triangle.
Definition WEMTriangle.h:27
A WEM comprises a number of WEMPatches.
Definition WEM.h:88
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Result structure for getNearestTriangle:
WEMTrianglePatch * patch
The patch containing the nearest triangle, may be nullptr if the WEM was empty.
WEMTriangle * triangle
The nearest triangle containing the nearest point, may be nullptr if the WEM was empty.