MeVisLab Toolbox Reference
CSOPointInPolygonChecker.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, 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
16
17#pragma once
18
19
20#include "MLCSOIncludes.h"
21#include <mlRotation.h>
22#include "CSOBase/CSO.h"
23
25
27
33{
34
35public:
36
38
41
44 CSOPointInPolygonChecker(std::vector<Vector3>& pathPoints, const Vector3& normal, bool overwritePathPoints=false);
45
48
50
52 void set(const CSO* cso);
53
56 void set(std::vector<Vector3>& pathPoints, const Vector3& normal, bool overwritePathPoints=false);
57
59
61 bool isPointInsidePolygon(const Vector3& pos) const;
62
63private:
64
66
67 struct BinnedLine
68 {
69 Vector2 startPoint;
70 Vector2 endPoint;
71 };
72
73 typedef std::vector<BinnedLine> LinesVector;
74
76
78 void _transformAndProject(Vector3& voxelPos) const;
79
81 void _fillLineBins(const std::vector<Vector3>& projectedPathPoints);
82
85 bool _testLinesInBin(const Vector3& point) const;
86
88
90 mutable Rotation _toZRotation; // mutable because Rotation::rotate is not const although it could be :-(
91
93 Vector2 _boundingBoxStart;
95 Vector2 _boundingBoxEnd;
96
98 std::vector<LinesVector> _lineSegmentBin;
100 int _binShift;
101
102};
103
105
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
Checks whether a point is inside a planar, closed polygon in an arbitrary plane.
CSOPointInPolygonChecker(std::vector< Vector3 > &pathPoints, const Vector3 &normal, bool overwritePathPoints=false)
Sets the polygon based on a list of points and a normal.
CSOPointInPolygonChecker(const CSO *cso)
Sets the polygon based on a CSO.
bool isPointInsidePolygon(const Vector3 &pos) const
Checks whether a given point is inside the polygon.
void set(const CSO *cso)
Sets the polygon based on a CSO.
void set(std::vector< Vector3 > &pathPoints, const Vector3 &normal, bool overwritePathPoints=false)
Sets the polygon based on a list of points and a normal.
The CSO represents a contour segmentation object.
Definition CSO.h:44
Class to handle Rotations (internally the rotation is stored as a unit quaternion)
Definition mlRotation.h:40
Target mlrange_cast(Source arg)
Generic version of checked ML casts.