MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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{
23 class TreeElement;
24};
25
31{
32public:
36
38 bool isValid() const
39 {
40 return _bsh != nullptr;
41 }
42
44 struct Result
45 {
47 : patch(nullptr)
48 , triangle(nullptr)
49 {
50 w[0] = 0;
51 w[1] = 0;
52 w[2] = 0;
53 }
54
60 double w[3];
61 };
62
65
66#ifdef WEM_BSH_DEBUG
67 // debugging interface:
68 static void incSphereChecks()
69 {
71 }
72 static void incTriangleChecks()
73 {
75 }
76#endif
77
78private:
80 WEMBoundingSphereHierarchy::TreeElement* _bsh;
81
82 // debugging/profiling data
83 int _usedTriangleCount;
84#ifdef WEM_BSH_DEBUG
85 // this is not thread-safe!!!
86 static int _sphereChecks;
87 static int _triangleChecks;
88#endif
89};
90
91
#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:86
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.