MeVisLab Toolbox Reference
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 
22 const double WEM_EPSILON = 0.00001;
23 
25 const double WEM_LARGE_EPSILON = 0.0002;
26 
28 const int WEM_VERSION = 7;
29 
31 const double WEM_GOLDEN_PERIMETER = 4.5590141139;
32 
34 const unsigned int WEM_MAX_VALENCE = 30;
35 
37 const unsigned int WEM_DEFAULT_VALENCE = 16;
38 
40 const unsigned int WEM_MAX_NUM_NODES = 100;
41 
43 const double WEM_NODE_VALENCE3_THRESHOLD = 0.35;
44 
47 
52 const 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){ std::cout << msg << std::endl; };
63 #define WEM_ERROR(msg){ WEM_PRINT("WEM ERROR: " << msg << " in file " << __FILE__ << ", line: " << __LINE__); };
65 #define WEM_WARNING(msg){ WEM_PRINT("WEM WARNING: " << msg << " in file " << __FILE__ << ", line: " << __LINE__); };
67 #define WEM_DEBUG(msg){ WEM_PRINT("WEM Debug: " << msg << " in file " << __FILE__ << ", line: " << __LINE__); };
68 
70 #define WEM_MODULE_ERROR(function, msg){ mlError(function) << whoAmI() << ": " << msg; };
72 #define WEM_MODULE_WARNING(function, msg){ mlWarning(function) << whoAmI() << ": " << msg; };
74 #define WEM_MODULE_INFO(function, msg){ mlInfo(function) << whoAmI() << ": " << msg; };
75 
77 #define NORMALIZE_VECTOR3(v) v.normalize()
78 
79 #include <fstream>
80 #include <mlUnicode.h>
81 
82 ML_START_NAMESPACE
83 
85 
88 {
89  Off = 0,
91  AutoClear
92 };
93 
95 
98 {
104 };
105 
107 
109 const int WEM_PATCH_ID_ALL = -1;
110 
112 
115 {
121  WEM_COLOR_NONE = 5
122 };
123 
125 
128 {
132 };
133 
135 
138 {
141 };
142 
144 
147 {
151 };
152 
154 
156 // The underlying type is required for serialization.
157 enum PatchTypes : std::int32_t
158 {
162  WEM_PATCH_POLYGONS = 3
163 };
164 
166 
168 // The underlying type is required for serialization.
169 enum PrimitiveValueListTypes : std::int32_t
170 {
174 };
175 
177 
180 {
184 };
185 
187 
190 {
192  {
193  shouldSaveNodeNormals = true;
194  shouldSaveNodeColors = true;
195  shouldSaveEdges = true;
196  shouldSaveFaceNormals = true;
197  shouldSavePVLs = true;
198  }
204 };
205 
207 
210 {
212  {
213  progressField = nullptr;
214  }
215  WEMProgressUpdater(ProgressField* pf, float r, float o) :
216  progressField(pf),
217  ratio(r),
218  offset(o),
219  mod(10000)
220  {
221  }
222 
223  template <typename DT>
224  void update(DT current) { update(current, current); }
225 
226  template <typename DT1, typename DT2>
227  void update(DT1 current, DT2 read)
228  {
229  if (progressField && (current > 0) && (static_cast<int>(current) % mod == 0))
230  {
231  progressField->setFloatValue(offset + static_cast<float>(read)* ratio);
232  }
233  }
234 
235  template <typename DT>
236  void addOffset(DT o) { offset += static_cast<float>(o)* ratio; }
237 
239  float ratio;
240  float offset;
241  unsigned int mod;
242 };
243 
245 
248 {
249  WEMReadParameters(size_t wemVersion)
250  {
251  version = wemVersion;
252  vectorByteSize = (version > 4) ? 8 : 4;
253  }
254 
255  size_t version;
257 };
258 
260 
261 ML_END_NAMESPACE
const double WEM_NODE_VALENCE3_THRESHOLD
Angle threshold for nodes with valence 3 removal for default check (~70 degrees).
Definition: MLWEMIncludes.h:43
const double WEM_EPSILON
Epsilon value used in Vector3 comparisons.
Definition: MLWEMIncludes.h:22
const double WEM_NODE_VALENCE3_NEIGHBORHOOD_THRESHOLD
Angle threshold for nodes with valence 3 removal for neighborhood check (~50 degrees).
Definition: MLWEMIncludes.h:46
const double WEM_GOLDEN_PERIMETER
Golden perimeter.
Definition: MLWEMIncludes.h:31
const int WEM_VERSION
Current version of WEM library.
Definition: MLWEMIncludes.h:28
const unsigned int WEM_MAX_NUM_NODES
Maximum number of nodes for polygons.
Definition: MLWEMIncludes.h:40
const unsigned int WEM_DEFAULT_VALENCE
Default vector size of edge and face valence for nodes.
Definition: MLWEMIncludes.h:37
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 ...
Definition: MLWEMIncludes.h:52
const double WEM_LARGE_EPSILON
Epsilon value used in Vector3 comparisons when precision is an issue.
Definition: MLWEMIncludes.h:25
const unsigned int WEM_MAX_VALENCE
Maximum edge and face valence for nodes.
Definition: MLWEMIncludes.h:34
#define MLWEM_EXPORT
Definition: MLWEMSystem.h:18
Field to encapsulate an increasing float value from range [0,1].
Definition: mlFields.h:744
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.
Definition: MLWEMIncludes.h:88
@ AutoUpdate
Module computes anew on any input change.
Definition: MLWEMIncludes.h:90
@ AutoClear
Module clears its output on any input change (output WEM is empty).
Definition: MLWEMIncludes.h:91
@ Off
Module does not react on input change, output WEM remains.
Definition: MLWEMIncludes.h:89
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.
Definition: MLWEMIncludes.h:98
@ 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).
Definition: MLWEMIncludes.h:99
@ 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)