MorphoGraphX  2.0-1-227
Triangulate.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef TRIANGULATE_HPP
12 #define TRIANGULATE_HPP
13 
14 #include <Misc.hpp>
15 #include <Subdivide.hpp>
16 #include <Attributes.hpp>
17 
18 #include <ImageData.hpp>
19 
20 namespace mgx
21 {
22 
30  mgx_EXPORT bool triangleOrientationCheck(std::vector<Point3i>& triList, int idxRefTri = -1);
31 
39  mgx_EXPORT std::vector<Point3d> orderPolygonSegs(std::vector<std::pair<Point3d,Point3d> > &polygonSegs, bool keepPolySegs = true);
40  mgx_EXPORT std::vector<std::vector<Point3d> > orderPolygonSegsMulti(std::vector<std::pair<Point3d,Point3d> > &polygonSegs);
41 
51  mgx_EXPORT Point3d getPolygonNrml(std::vector<Point3d>& pointsPolygon);
52  mgx_EXPORT Point3d getPolygonNrml(std::vector<Point3d>& pointsPolygon, int& idxP3);
53 
60  mgx_EXPORT bool isDataPlanar(std::vector<Point3d>& inputVertices);
61 
70  mgx_EXPORT bool findPolygonPlane(std::vector<Point3d> &pointsPolygon, Point3d &planePos, Point3d &planeNrml);
71 
76  mgx_EXPORT void inplaceMatrixMultiply(std::vector<Point3d>& P, const Matrix3d& M);
77 
86  mgx_EXPORT bool projectPointsOnPlane(std::vector<Point3d> &points, Point3d planePos, Point3d planeNrml);
87 
95  mgx_EXPORT Matrix3d calcRotMatrix(Point3d nrmlStart, Point3d nrmlEnd, Point3d rot_axis = Point3d(0,0,0));
96 
109  mgx_EXPORT void rotatePointsIntoXY(Point3d polygonNormal, std::vector<Point3d>& pointsPolygon, Matrix3d& inv_rot_polygon_plane);
110 
126  mgx_EXPORT bool triangulatePolygon3D(float maxArea, Point3d polygonNormal, std::vector<Point3d> &pointsPolygon,
127  std::vector<Point3i> &triList, std::vector<Point3d> &ptList, bool boundary, bool inOrder, bool pointsCenter);
128 
135  mgx_EXPORT Point3d orthogonalVector(Point3d vec);
136 
146  mgx_EXPORT Point3d calcNearestPointOnBezierGrid(const Point3d& targetPoint, std::vector<std::vector<Point3d> >& bezier, Point2i& bezIdx);
147 
153  // mgx_EXPORT Point3d projectPointOnPlane(const Point3d& P, const Point3d& Q, const Point3d& N);
154 
155 
156 
157  mgx_EXPORT Matrix3d calcProjectedGrowthTensor(Matrix3d tensor, Point3d planeNrml);
158 
159  mgx_EXPORT bool pointInPolygon(Point3d pointToTest, std::vector<Point3d>& polygon, bool debug = false);
160 
170  mgx_EXPORT std::vector<Point2d> lloydKMeans2D(std::vector<Point2d>& clusters, std::vector<Point2d>& data, int maxStep = -1);
171 
182  mgx_EXPORT bool lloydKMeans(std::vector<std::vector<double> >& inputClusters,
183  std::vector<AttrMap<int, double> >& dataPoints, int maxStep = -1, double convergenceThreshold = 0.01);
184 
185  // interpolates the appropriate array index for the landscape function which has a
186  // resolution of newRange+1
187  mgx_EXPORT double interpolateArrayIndex(double value, double min, double max, double newRange);
188  mgx_EXPORT void drawCross(QImage& image, int x, int y, int size, int crossSize, QRgb color);
189  mgx_EXPORT void drawCircle(QImage& image, int x, int y, int size, QRgb color);
190 
203  mgx_EXPORT double gauss2D(double x, double y, double muX, double muY, double sigmaX, double sigmaY);
204 
205 
217  mgx_EXPORT Point3d calcNearestPointOnBezierLine(const Point3d& targetPoint, std::vector<Point3d>& bezierVec, int& bezIdx, double& bezWeight);
218  mgx_EXPORT Point3d calcNearestPointOnBezierLine(const Point3d& targetPoint, std::map<int, Point3d>& bMap, int& bezIdx, double& bezWeight);
219  mgx_EXPORT Point3d calcNearestPointOnBezierLine(const Point3d& targetPoint, std::map<int, Point3d>& bMap);
220 
221  mgx_EXPORT QRgb calcRGB(double maxValue, double currentValue);
222 
223  mgx_EXPORT QRgb getColorFromLabel(int label);
224 
225  mgx_EXPORT double angleVectors(Point3d v1, Point3d v2, bool directed = false);
226 
227 }
228 #endif
229 
mgx::getColorFromLabel
mgx_EXPORT QRgb getColorFromLabel(int label)
Attributes.hpp
mgx::orthogonalVector
mgx_EXPORT Point3d orthogonalVector(Point3d vec)
orthogonalVector
ImageData.hpp
mgx::calcRGB
mgx_EXPORT QRgb calcRGB(double maxValue, double currentValue)
mgx::Point2i
Vector< 2, int > Point2i
Definition: CuttingSurface.hpp:22
mgx::Matrix3d
Matrix< 3, 3, double > Matrix3d
Definition: Geometry.hpp:111
mgx::drawCircle
mgx_EXPORT void drawCircle(QImage &image, int x, int y, int size, QRgb color)
mgx::orderPolygonSegs
mgx_EXPORT std::vector< Point3d > orderPolygonSegs(std::vector< std::pair< Point3d, Point3d > > &polygonSegs, bool keepPolySegs=true)
orderPolygonSegs
mgx::calcNearestPointOnBezierLine
mgx_EXPORT Point3d calcNearestPointOnBezierLine(const Point3d &targetPoint, std::vector< Point3d > &bezierVec, int &bezIdx, double &bezWeight)
calculates the nearest point of a tragetPoint on a bezier line (bMap) as the bezier is discretized,...
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::inplaceMatrixMultiply
mgx_EXPORT void inplaceMatrixMultiply(std::vector< Point3d > &P, const Matrix3d &M)
inplaceMatrixMultiply P := P*M
mgx::calcNearestPointOnBezierGrid
mgx_EXPORT Point3d calcNearestPointOnBezierGrid(const Point3d &targetPoint, std::vector< std::vector< Point3d > > &bezier, Point2i &bezIdx)
calculates the nearest point of a tragetPoint on a bezier grid (bezier)
Subdivide.hpp
mgx::interpolateArrayIndex
mgx_EXPORT double interpolateArrayIndex(double value, double min, double max, double newRange)
mgx::max
T CU_HOST_DEVICE max(const T a, const T b)
Definition: Util.hpp:34
mgx::orderPolygonSegsMulti
mgx_EXPORT std::vector< std::vector< Point3d > > orderPolygonSegsMulti(std::vector< std::pair< Point3d, Point3d > > &polygonSegs)
mgx::Point3d
Vector< 3, double > Point3d
Definition: Geometry.hpp:56
mgx::pointInPolygon
mgx_EXPORT bool pointInPolygon(Point3d pointToTest, std::vector< Point3d > &polygon, bool debug=false)
mgx::triangleOrientationCheck
mgx_EXPORT bool triangleOrientationCheck(std::vector< Point3i > &triList, int idxRefTri=-1)
triangleOrientationCheck
mgx::drawCross
mgx_EXPORT void drawCross(QImage &image, int x, int y, int size, int crossSize, QRgb color)
mgx::gauss2D
mgx_EXPORT double gauss2D(double x, double y, double muX, double muY, double sigmaX, double sigmaY)
returns the value of a 2D gaussian function
mgx::triangulatePolygon3D
mgx_EXPORT bool triangulatePolygon3D(float maxArea, Point3d polygonNormal, std::vector< Point3d > &pointsPolygon, std::vector< Point3i > &triList, std::vector< Point3d > &ptList, bool boundary, bool inOrder, bool pointsCenter)
triangulatePolygon3D
mgx::lloydKMeans
mgx_EXPORT bool lloydKMeans(std::vector< std::vector< double > > &inputClusters, std::vector< AttrMap< int, double > > &dataPoints, int maxStep=-1, double convergenceThreshold=0.01)
k means function for n-D data (lloyds algorithm) NOTE: dimensions have to match, otherwise function r...
mgx::lloydKMeans2D
mgx_EXPORT std::vector< Point2d > lloydKMeans2D(std::vector< Point2d > &clusters, std::vector< Point2d > &data, int maxStep=-1)
k means function for 2D data (lloyds algorithm)
Misc.hpp
mgx::angleVectors
mgx_EXPORT double angleVectors(Point3d v1, Point3d v2, bool directed=false)
mgx::min
CU_HOST_DEVICE T min(const T a, const T b)
Definition: Util.hpp:26
mgx::calcRotMatrix
mgx_EXPORT Matrix3d calcRotMatrix(Point3d nrmlStart, Point3d nrmlEnd, Point3d rot_axis=Point3d(0, 0, 0))
calcRotMatrix
mgx::calcProjectedGrowthTensor
mgx_EXPORT Matrix3d calcProjectedGrowthTensor(Matrix3d tensor, Point3d planeNrml)
projectPointOnPlane
mgx::findPolygonPlane
mgx_EXPORT bool findPolygonPlane(std::vector< Point3d > &pointsPolygon, Point3d &planePos, Point3d &planeNrml)
findPolygonPlane
mgx::isDataPlanar
mgx_EXPORT bool isDataPlanar(std::vector< Point3d > &inputVertices)
isDataPlanar
mgx::projectPointsOnPlane
mgx_EXPORT bool projectPointsOnPlane(std::vector< Point3d > &points, Point3d planePos, Point3d planeNrml)
projectPointsOnPlane
mgx::rotatePointsIntoXY
mgx_EXPORT void rotatePointsIntoXY(Point3d polygonNormal, std::vector< Point3d > &pointsPolygon, Matrix3d &inv_rot_polygon_plane)
rotatePointsIntoXY
mgx::getPolygonNrml
mgx_EXPORT Point3d getPolygonNrml(std::vector< Point3d > &pointsPolygon)
getPolygonNrml