MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
MLWEMIncludes.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, 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
15#include "MLWEMSystem.h"
16
17#include <algorithm>
18#include <vector>
19#include <string>
20
22const double WEM_EPSILON = 0.00001;
23
25const double WEM_LARGE_EPSILON = 0.0002;
26
28const int WEM_VERSION = 7;
29
31const double WEM_GOLDEN_PERIMETER = 4.5590141139;
32
34const unsigned int WEM_MAX_VALENCE = 30;
35
37const unsigned int WEM_DEFAULT_VALENCE = 16;
38
40const unsigned int WEM_MAX_NUM_NODES = 100;
41
43const double WEM_NODE_VALENCE3_THRESHOLD = 0.35;
44
47
52const std::string WEM_SINGLE_COLORED_FACES = "WEMSingleColoredFaces";
53
54#include <mlModuleIncludes.h>
55#include <mlModule.h>
56
57#define NULL_VEC Vector3(0, 0, 0)
58#define UNIT_VEC Vector3(0, 1, 0)
59
61#define WEM_PRINT(msg) \
62 { \
63 std::cout << msg << std::endl; \
64 };
66#define WEM_ERROR(msg) \
67 { \
68 WEM_PRINT("WEM ERROR: " << msg << " in file " << __FILE__ << ", line: " << __LINE__); \
69 };
71#define WEM_WARNING(msg) \
72 { \
73 WEM_PRINT("WEM WARNING: " << msg << " in file " << __FILE__ << ", line: " << __LINE__); \
74 };
76#define WEM_DEBUG(msg) \
77 { \
78 WEM_PRINT("WEM Debug: " << msg << " in file " << __FILE__ << ", line: " << __LINE__); \
79 };
80
82#define WEM_MODULE_ERROR(function, msg) \
83 { \
84 mlError(function) << whoAmI() << ": " << msg; \
85 };
87#define WEM_MODULE_WARNING(function, msg) \
88 { \
89 mlWarning(function) << whoAmI() << ": " << msg; \
90 };
92#define WEM_MODULE_INFO(function, msg) \
93 { \
94 mlInfo(function) << whoAmI() << ": " << msg; \
95 };
96
98#define NORMALIZE_VECTOR3(v) v.normalize()
99
100#include <fstream>
101#include <mlUnicode.h>
102
104
106
113
115
124
126
128const int WEM_PATCH_ID_ALL = -1;
129
131
141
143
150
152
158
160
167
169
171// The underlying type is required for serialization.
178
180
182// The underlying type is required for serialization.
188
190
197
199
202{
204 {
205 shouldSaveNodeNormals = true;
206 shouldSaveNodeColors = true;
207 shouldSaveEdges = true;
208 shouldSaveFaceNormals = true;
209 shouldSavePVLs = true;
210 }
216};
217
219
222{
224 {
225 progressField = nullptr;
226 }
228 : progressField(pf)
229 , ratio(r)
230 , offset(o)
231 , mod(10000)
232 {}
233
234 template <typename DT> void update(DT current)
235 {
236 update(current, current);
237 }
238
239 template <typename DT1, typename DT2> void update(DT1 current, DT2 read)
240 {
241 if (progressField && (current > 0) && (static_cast<int>(current) % mod == 0)) {
242 progressField->setFloatValue(offset + static_cast<float>(read) * ratio);
243 }
244 }
245
246 template <typename DT> void addOffset(DT o)
247 {
248 offset += static_cast<float>(o) * ratio;
249 }
250
252 float ratio;
253 float offset;
254 unsigned int mod;
255};
256
258
261{
263 {
264 version = wemVersion;
265 vectorByteSize = (version > 4) ? 8 : 4;
266 }
267
268 size_t version;
270};
271
273
const double WEM_NODE_VALENCE3_THRESHOLD
Angle threshold for nodes with valence 3 removal for default check (~70 degrees).
const double WEM_EPSILON
Epsilon value used in Vector3 comparisons.
const double WEM_NODE_VALENCE3_NEIGHBORHOOD_THRESHOLD
Angle threshold for nodes with valence 3 removal for neighborhood check (~50 degrees).
const double WEM_GOLDEN_PERIMETER
Golden perimeter.
const int WEM_VERSION
Current version of WEM library.
const unsigned int WEM_MAX_NUM_NODES
Maximum number of nodes for polygons.
const unsigned int WEM_DEFAULT_VALENCE
Default vector size of edge and face valence for nodes.
const std::string WEM_SINGLE_COLORED_FACES
Name of the PVL for faces where a value of -1 signals to use the nodes' PVL, all other values are to ...
const double WEM_LARGE_EPSILON
Epsilon value used in Vector3 comparisons when precision is an issue.
const unsigned int WEM_MAX_VALENCE
Maximum edge and face valence for nodes.
#define MLWEM_EXPORT
Definition MLWEMSystem.h:18
Field to encapsulate an increasing float value from range [0,1].
Definition mlFields.h:519
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
const int WEM_PATCH_ID_ALL
Patch Id meaning: all patches.
NodeRenderingModes
Enumeration of the node rendering modes. Note that these are 'mirrored' in the SoWEM part.
@ WEM_NODE_RENDERING_NORMAL
Only the nodes' positions are rendered.
@ WEM_NODE_RENDERING_EXTRA_HIGH
As 'high', but with positions on all edges.
@ WEM_NODE_RENDERING_HIGH
As 'normal', but with the faces' centroids.
PrimitiveValueListTypes
Enumeration of primitive value list types.
@ WEM_PRIMITIVE_VALUE_LIST_FACE
Face values.
@ WEM_PRIMITIVE_VALUE_LIST_EDGE
Edge values.
@ WEM_PRIMITIVE_VALUE_LIST_NODE
Node values.
OrientationTypes
Enumeration of orientation types.
@ WEM_ORIENTATION_INWARD
Orientation: outward normals (positive volume).
@ WEM_ORIENTATION_UNKNOWN
@ WEM_ORIENTATION_OUTWARD
Orientation: unknown.
TriangulationModes
Enumeration of the triangulation modes. Note that these are 'mirrored' in the SoWEM part.
@ WEM_TRIANGULATION_FAN
A triangle fan is created out of the face.
@ WEM_TRIANGULATION_CENTER
A new node is created at the center of the face.
@ WEM_TRIANGULATION_STRIP
A triangle strip is created out of the face.
BoundingBoxModes
Enumeration of bounding box visualization. Note that these are 'mirrored' in the SoWEM part.
@ WEM_BOUNDING_BOX_OBJECT_ALIGNED
Object aligned (PCA) bounding box.
@ WEM_BOUNDING_BOX_AXIS_ALIGNED
Axis aligned bounding box.
ColorModes
Enumeration of the color modes. Note that these are 'mirrored' in the SoWEM part.
@ WEM_COLOR_GENERAL
A general color is taken for the whole WEM.
@ WEM_COLOR_LUT_VALUES
The nodes' LUT values are taken to read out the color of a LUT.
@ WEM_COLOR_TEXTURED
The nodes' are textured using textureS and textureT primitive value lists.
@ WEM_COLOR_NODE_COLORS
The nodes' colors are takes for coloring.
@ WEM_COLOR_LUT_VALUES_INTEGER
The nodes' LUT values are taken to read out the color of an integer LUT.
@ WEM_COLOR_NONE
No internal SoMaterial node is used in the output scene.
WEMUpdateMode
Defines the update modes of WEM modules.
@ AutoUpdate
Module computes anew on any input change.
@ AutoClear
Module clears its output on any input change (output WEM is empty).
@ Off
Module does not react on input change, output WEM remains.
PatchTypes
Enumeration of mesh types.
@ WEM_PATCH_POLYGONS
Patch type: the faces can be n-polygons with up to WEM_MAX_NUM_NODES.
@ WEM_PATCH_TRIANGLES
Patch type: all faces are triangles.
@ WEM_PATCH_QUADS
Patch type: all faces are quads.
@ WEM_PATCH_UNKNOWN
Patch type: the type of the faces is unknown.
WEMNotificationType
Defines the available WEM notifications.
@ WEM_NOTIFICATION_FINISHED
Notification flag: an interaction on a part has been finished.
@ WEM_NOTIFICATION_INTERACTION_INIT
Notification flag: an interaction module needs initialization.
@ WEM_NOTIFICATION_NONE
Notification flag: no notification at all (for initializing).
@ WEM_NOTIFICATION_SELECTION
Notification flag: a part has been selected.
@ WEM_NOTIFICATION_REPAINT
Notification flag: a part needs a repainting.
Structure to gather persistence parameters.
Helper struct for updating the progress bar while loading/saving.
void update(DT current)
ProgressField * progressField
void update(DT1 current, DT2 read)
WEMProgressUpdater(ProgressField *pf, float r, float o)
Helper struct for bundling parameters to keep method interfaces small.
WEMReadParameters(size_t wemVersion)