#ifndef DUST3D_UTIL_H #define DUST3D_UTIL_H #include #include #include #include #include #include #include #include "positionkey.h" #ifndef M_PI #define M_PI 3.14159265358979323846 #endif QString valueOfKeyInMapOrEmpty(const std::map &map, const QString &key); bool isTrueValueString(const QString &str); bool isFloatEqual(float a, float b); void qNormalizeAngle(int &angle); QVector3D pointInHermiteCurve(float t, QVector3D p0, QVector3D m0, QVector3D p1, QVector3D m1); float angleInRangle360BetweenTwoVectors(QVector3D a, QVector3D b, QVector3D planeNormal); QVector3D projectLineOnPlane(QVector3D line, QVector3D planeNormal); QVector3D projectPointOnLine(const QVector3D &point, const QVector3D &linePointA, const QVector3D &linePointB); QString unifiedWindowTitle(const QString &text); QQuaternion quaternionOvershootSlerp(const QQuaternion &q0, const QQuaternion &q1, float t); float radianBetweenVectors(const QVector3D &first, const QVector3D &second); float degreesBetweenVectors(const QVector3D &first, const QVector3D &second); float areaOfTriangle(const QVector3D &a, const QVector3D &b, const QVector3D &c); QQuaternion eulerAnglesToQuaternion(double pitch, double yaw, double roll); void quaternionToEulerAngles(const QQuaternion &q, double *pitch, double *yaw, double *roll); void quaternionToEulerAnglesXYZ(const QQuaternion &q, double *pitch, double *yaw, double *roll); bool pointInTriangle(const QVector3D &a, const QVector3D &b, const QVector3D &c, const QVector3D &p); QVector3D polygonNormal(const std::vector &vertices, const std::vector &polygon); void angleSmooth(const std::vector &vertices, const std::vector> &triangles, const std::vector &triangleNormals, float thresholdAngleDegrees, std::vector &triangleVertexNormals); void recoverQuads(const std::vector &vertices, const std::vector> &triangles, const std::set> &sharedQuadEdges, std::vector> &triangleAndQuads); size_t weldSeam(const std::vector &sourceVertices, const std::vector> &sourceTriangles, float allowedSmallestDistance, const std::set &excludePositions, std::vector &destVertices, std::vector> &destTriangles); bool isManifold(const std::vector> &faces); void trim(std::vector *vertices, bool normalize=false); void chamferFace2D(std::vector *face); void subdivideFace2D(std::vector *face); QVector3D choosenBaseAxis(const QVector3D &layoutDirection); void saveAsObj(const char *filename, const std::vector &vertices, const std::vector> &faces); bool intersectSegmentAndPlane(const QVector3D &segmentPoint0, const QVector3D &segmentPoint1, const QVector3D &pointOnPlane, const QVector3D &planeNormal, QVector3D *intersection=nullptr); bool intersectSegmentAndTriangle(const QVector3D &segmentPoint0, const QVector3D &segmentPoint1, const std::vector &triangle, const QVector3D &triangleNormal, QVector3D *intersection=nullptr); bool intersectRayAndPolyhedron(const QVector3D &rayNear, const QVector3D &rayFar, const std::vector &vertices, const std::vector> &triangles, const std::vector &triangleNormals, QVector3D *intersection=nullptr, size_t *intersectedTriangleIndex=nullptr); QVector3D barycentricCoordinates(const QVector3D &a, const QVector3D &b, const QVector3D &c, const QVector3D &point); #endif