25 #include <BoundingBox.hpp> 28 #include <cuda/CudaGlobal.hpp> 43 typedef unsigned char ubyte;
44 typedef unsigned int uint;
45 typedef unsigned short ushort;
46 typedef unsigned long ulong;
48 typedef util::Vector<2, float> Point2f;
49 typedef util::Vector<3, float> Point3f;
50 typedef util::Vector<4, float> Point4f;
51 typedef util::Vector<5, float> Point5f;
52 typedef util::Vector<6, float> Point6f;
53 typedef util::Vector<12, float> Point12f;
55 typedef util::Vector<2, double> Point2d;
56 typedef util::Vector<3, double> Point3d;
57 typedef util::Vector<4, double> Point4d;
58 typedef util::Vector<5, double> Point5d;
59 typedef util::Vector<6, double> Point6d;
60 typedef util::Vector<16, double> Point16d;
62 typedef util::Vector<2, int> Point2i;
63 typedef util::Vector<3, int> Point3i;
64 typedef util::Vector<4, int> Point4i;
65 typedef util::Vector<5, int> Point5i;
66 typedef util::Vector<6, int> Point6i;
68 typedef util::Vector<2, uint> Point2u;
69 typedef util::Vector<3, uint> Point3u;
70 typedef util::Vector<4, uint> Point4u;
71 typedef util::Vector<5, uint> Point5u;
72 typedef util::Vector<6, uint> Point6u;
74 typedef util::Vector<2, size_t> Point2s;
75 typedef util::Vector<3, size_t> Point3s;
76 typedef util::Vector<4, size_t> Point4s;
77 typedef util::Vector<5, size_t> Point5s;
78 typedef util::Vector<6, size_t> Point6s;
80 typedef util::Vector<3, ushort> Point3us;
82 typedef util::Matrix<2, 2, float> Matrix2f;
83 typedef util::Matrix<3, 3, float> Matrix3f;
84 typedef util::Matrix<4, 4, float> Matrix4f;
86 typedef util::Matrix<2, 2, double> Matrix2d;
87 typedef util::Matrix<3, 3, double> Matrix3d;
88 typedef util::Matrix<4, 4, double> Matrix4d;
90 typedef util::BoundingBox<3, uint> BoundingBox3u;
91 typedef util::BoundingBox<3, int> BoundingBox3i;
92 typedef util::BoundingBox<3, float> BoundingBox3f;
95 Point3u toVoxelsCeil(
const Point3f& p,
const Point3f& step)
98 if(p.x() > 0 and step.x() > 0)
99 r.x() = uint(ceil(p.x() / step.x()));
100 if(p.y() > 0 and step.y() > 0)
101 r.y() = uint(ceil(p.y() / step.y()));
102 if(p.z() > 0 and step.z() > 0)
103 r.z() = uint(ceil(p.z() / step.z()));
108 template <
typename T>
109 CU_HOST_DEVICE util::Vector<3, T> multMatrix4Point3(
const util::Matrix<4, 4, T>& m,
const util::Vector<3, T>& p)
111 util::Vector<4, T> t(p.x(), p.y(), p.z(), T(1.0));
113 util::Vector<3, T> res(t.x() / t.t(), t.y() / t.t(), t.z() / t.t());
117 template <
typename T> T CU_HOST_DEVICE interpolate(
const T a,
const T b,
const T s)
119 T t = trim(s, (T)0.0, (T)1.0);
120 return ((1.0 - t) * a + t * b);
138 bool planeLineIntersect(Point3f p, Point3f n, Point3f u1, Point3f u2,
float& s, Point3f& u)
141 Point3f u1u2 = u2 - u1;
146 s = n * (p - u1) / t;
153 float triangleArea(Point3f a, Point3f b, Point3f c) {
154 return ((a - b).cross(a - c).norm() / 2.0);
159 float signedTetraVolume(Point3f a, Point3f b, Point3f c)
161 return ((-c.x() * b.y() * a.z() + b.x() * c.y() * a.z() + c.x() * a.y() * b.z() - a.x() * c.y() * b.z()
162 - b.x() * a.y() * c.z() + a.x() * b.y() * c.z()) / 6.0f);
167 void getBasisFromPlane(
const Point3f& nrml, Point3f& x, Point3f& y, Point3f& z)
171 x = Point3f(1, 0, 0);
172 y = Point3f(0, 1, 0);
173 z = Point3f(0, 0, 1);
174 if(z.cross(n).norm() != 0) {
192 int rayTriangleIntersect(
const Point3f& r0,
const Point3f& r1,
const Point3f& t0,
const Point3f& t1,
const Point3f& t2,
198 Point3f n = u.cross(v);
199 if(n.x() == 0 && n.y() == 0 && n.z() == 0)
202 Point3f dir = r1 - r0;
203 Point3f w0 = r0 - t0;
222 float uu, uv, vv, wu, wv, d;
226 Point3f w = intp - t0;
229 d = uv * uv - uu * vv;
233 s = (uv * wv - vv * wu) / d;
234 if(s < 0.0f || s > 1.0f)
236 t = (uv * wu - uu * wv) / d;
237 if(t < 0.0f || (s + t) > 1.0f)
245 float distLinePoint(Point3f v1, Point3f v2, Point3f p,
bool segment)
255 Point3f q = vn * (p * vn);
256 float dist = norm(p - q);
262 if(qn >= 0 and qn <= n)
267 float d = norm(p - v2);
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
Common definitions and utilities This file is shared by cuda, do not include headers that nvcc can't ...
Defines the Matrix class template This file is shared by cuda, do not include headers that nvcc can't...
Defines the Vector class template This file is shared by cuda, do not include headers that nvcc can't...