├── GeometryAndMesh ├── Geometry │ ├── Geometry.cpp │ ├── Geometry.h │ ├── Geometry.vcxproj │ ├── Geometry.vcxproj.filters │ ├── dllmain.cpp │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h ├── Mesh │ ├── Mesh.cpp │ ├── Mesh.h │ ├── Mesh.vcxproj │ ├── Mesh.vcxproj.filters │ ├── Model.h │ ├── dllmain.cpp │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h ├── MeshAndGeometry.sln ├── MeshAndGeometry.vcxproj ├── MeshAndGeometry.vcxproj.filters └── main.cpp ├── LBO ├── LBO.cpp ├── LBO.h ├── LBO.sln ├── LBO.vcxproj ├── LBO.vcxproj.filters ├── dllmain.cpp ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── README.md ├── apps ├── DiskHarmonicMap │ ├── DiskHarmonicMap.sln │ ├── DiskHarmonicMap │ │ ├── DiskHarmonicMap.cpp │ │ ├── DiskHarmonicMap.h │ │ ├── DiskHarmonicMap.vcxproj │ │ ├── DiskHarmonicMap.vcxproj.filters │ │ ├── dllmain.cpp │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ └── targetver.h │ └── test_main │ │ ├── main.cpp │ │ ├── test_main.vcxproj │ │ └── test_main.vcxproj.filters ├── HeatMethod │ ├── HeatMethod.sln │ ├── HeatMethod │ │ ├── HeatMethod.cpp │ │ ├── HeatMethod.h │ │ ├── HeatMethod.vcxproj │ │ ├── HeatMethod.vcxproj.filters │ │ ├── HeatMethod.vcxproj.user │ │ ├── dllmain.cpp │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ └── targetver.h │ └── test_main │ │ ├── main.cpp │ │ ├── test_main.vcxproj │ │ ├── test_main.vcxproj.filters │ │ └── test_main.vcxproj.user ├── MeanCurvature │ ├── MeanCurvature.sln │ ├── MeanCurvature │ │ ├── MeanCurvature.cpp │ │ ├── MeanCurvature.h │ │ ├── MeanCurvature.vcxproj │ │ ├── MeanCurvature.vcxproj.filters │ │ ├── dllmain.cpp │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ └── targetver.h │ └── test_main │ │ ├── main.cpp │ │ ├── test_main.vcxproj │ │ └── test_main.vcxproj.filters └── SphericalHarmonicMap │ ├── SphericalHarmonicMap.sln │ ├── SphericalHarmonicMap │ ├── SphericalHarmonicMap.cpp │ ├── SphericalHarmonicMap.h │ ├── SphericalHarmonicMap.vcxproj │ ├── SphericalHarmonicMap.vcxproj.filters │ ├── dllmain.cpp │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ └── test_main │ ├── main.cpp │ ├── test_main.vcxproj │ └── test_main.vcxproj.filters └── figures ├── curvature_value_crop.png ├── curvature_vector_crop.png ├── harmonic_map00_crop.png ├── harmonic_map01_crop.png ├── harmonic_map02_crop.png ├── heat_method00_crop.png ├── heat_method01_crop.png ├── heat_method02_crop.png ├── spherical_harmonic_map00_crop.png └── spherical_harmonic_map01_crop.png /GeometryAndMesh/Geometry/Geometry.cpp: -------------------------------------------------------------------------------- 1 | // Geometry.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "Geometry.h" 6 | 7 | // Vector2D.cpp: implementation of the Vector2D class. 8 | // 9 | ////////////////////////////////////////////////////////////////////// 10 | 11 | #include "Geometry.h" 12 | 13 | ////////////////////////////////////////////////////////////////////// 14 | // Construction/Destruction 15 | ////////////////////////////////////////////////////////////////////// 16 | 17 | Vector3D::Vector3D(const Vector4D& v) 18 | { 19 | x = v.x / v.w; y = v.y / v.w, z = v.z / v.w; 20 | } 21 | Vector2D& Vector2D::operator=(const Vector2D& v) 22 | { 23 | x = v.x; y = v.y; 24 | return (*this); 25 | } 26 | Vector2D& Vector2D::operator+=(const Vector2D& v) 27 | { 28 | x += v.x; y += v.y; 29 | return (*this); 30 | } 31 | Vector2D& Vector2D::operator-=(const Vector2D& v) 32 | { 33 | x -= v.x; y -= v.y; 34 | return (*this); 35 | } 36 | Vector2D& Vector2D::operator*=(double u) 37 | { 38 | x *= u; y *= u; 39 | return (*this); 40 | } 41 | Vector2D& Vector2D::operator/=(double u) 42 | { 43 | if (!EQUALZERO(u)) 44 | { 45 | x /= u; y /= u; 46 | } 47 | return(*this); 48 | } 49 | 50 | GEOMETRY_API Vector2D operator+(const Vector2D& lv, const Vector2D& rv) 51 | { 52 | Vector2D rel = lv; 53 | rel += rv; 54 | return rel; 55 | } 56 | 57 | 58 | GEOMETRY_API Vector2D operator-(const Vector2D& lv, const Vector2D& rv) 59 | { 60 | Vector2D rel = lv; 61 | rel -= rv; 62 | return rel; 63 | } 64 | 65 | GEOMETRY_API Vector2D operator*(const double u, const Vector2D& rv) 66 | { 67 | Vector2D rel = rv; 68 | rel *= u; 69 | return rel; 70 | } 71 | 72 | GEOMETRY_API Vector2D operator*(const Vector2D& lv, const double u) 73 | { 74 | Vector2D rel = lv; 75 | rel *= u; 76 | return rel; 77 | } 78 | 79 | GEOMETRY_API Vector2D operator/(const Vector2D& lv, const double u) 80 | { 81 | Vector2D rel = lv; 82 | rel /= u; 83 | return rel; 84 | } 85 | 86 | GEOMETRY_API double operator*(const Vector2D& lv, const Vector2D& rv) 87 | { 88 | return lv.x*rv.x + lv.y*rv.y; 89 | } 90 | 91 | GEOMETRY_API double operator^(const Vector2D& lv, const Vector2D& rv) 92 | { 93 | return lv.x*rv.y - lv.y*rv.x; 94 | } 95 | 96 | GEOMETRY_API std::ostream& operator<< (std::ostream &output, Vector2D& v) 97 | { 98 | output << v.x << " " << v.y; 99 | return output; 100 | } 101 | 102 | short Vector2D::AtWhere(Vector2D v0, Vector2D v1) 103 | { 104 | Vector2D vTemp1(v1.y - v0.y, v0.x - v1.x); 105 | Vector2D vTemp2(x - v0.x, y - v0.y); 106 | double d = vTemp1*vTemp2; 107 | if (EQUALZERO(d)) 108 | return 0; 109 | if (d > 0)//right 110 | return 1; 111 | return -1; 112 | } 113 | 114 | bool Vector2D::AtRight(Vector2D v0, Vector2D v1) 115 | { 116 | if (AtWhere(v0, v1) == 1) 117 | return true; 118 | return false; 119 | } 120 | bool Vector2D::AtLeft(Vector2D v0, Vector2D v1) 121 | { 122 | if (AtWhere(v0, v1) == -1) 123 | return true; 124 | return false; 125 | } 126 | bool Vector2D::OnLine(Vector2D v0, Vector2D v1) 127 | { 128 | if (AtWhere(v0, v1) == 0) 129 | return true; 130 | return false; 131 | } 132 | 133 | bool Vector2D::Intersect(Vector2D v1, Vector2D v2)//intersect with uint circle 134 | { 135 | Vector2D vOrigin; 136 | short s = vOrigin.AtWhere(v1, v2); 137 | 138 | Vector2D vTemp1 = v2 - v1; 139 | vTemp1.normalize(); 140 | Vector2D vTemp2; 141 | // if(s==0)//pass point (0,0) 142 | if (s == 1)//right 143 | { 144 | vTemp2.x = -vTemp1.y; 145 | vTemp2.y = vTemp1.x; 146 | double d = vTemp2*v1; 147 | vTemp2 *= d; 148 | d = sqrt(1.0 - d*d); 149 | vTemp1 *= d; 150 | } 151 | else if (s == -1)//left 152 | { 153 | vTemp2.x = vTemp1.y; 154 | vTemp2.y = -vTemp1.x; 155 | double d = vTemp2*v1; 156 | vTemp2 *= d; 157 | d = sqrt(1.0 - d*d); 158 | vTemp1 *= d; 159 | } 160 | x = vTemp1.x + vTemp2.x; 161 | y = vTemp1.y + vTemp2.y; 162 | return true; 163 | } 164 | bool Vector2D::Intersect(Vector2D v1, Vector2D v2, Vector2D v3, Vector2D v4)//tow line intersect 165 | { 166 | double d = (v4.y - v3.y)*(v1.x - v2.x) - (v2.y - v1.y)*(v3.x - v4.x); 167 | if (EQUALZERO(d)) 168 | return false; 169 | 170 | double d1 = v1.x*v2.y - v2.x*v1.y; 171 | double d2 = v3.x*v4.y - v4.x*v3.y; 172 | x = ((v4.x - v3.x)*d1 - (v2.x - v1.x)*d2) / d; 173 | y = ((v4.y - v3.y)*d1 - (v2.y - v1.y)*d2) / d; 174 | return true; 175 | } 176 | double Vector2D::GetArea(Vector2D v) 177 | { 178 | return x*v.y - v.x*y; 179 | } 180 | ///////////////////////////////////////////////////////////// 181 | // Vector3D : 3D vector 182 | ///////////////////////////////////////////////////////////// 183 | Vector3D& Vector3D::operator=(const Vector3D& v) 184 | { 185 | x = v.x; y = v.y; z = v.z; 186 | return (*this); 187 | } 188 | 189 | Vector3D& Vector3D::operator=(const Vector4D& v) 190 | { 191 | x = v.x / v.w; y = v.y / v.w; z = v.z / v.w; 192 | return (*this); 193 | } 194 | Vector3D& Vector3D::operator+=(const Vector3D& v) 195 | { 196 | x += v.x; y += v.y; z += v.z; 197 | return (*this); 198 | } 199 | Vector3D& Vector3D::operator-=(const Vector3D& v) 200 | { 201 | x -= v.x; y -= v.y; z -= v.z; 202 | return (*this); 203 | } 204 | Vector3D& Vector3D::operator*=(double u) 205 | { 206 | x *= u; y *= u; z *= u; 207 | return (*this); 208 | } 209 | Vector3D& Vector3D::operator/=(double u) 210 | { 211 | if (!EQUALZERO(u)) 212 | { 213 | x /= u; y /= u; z /= u; 214 | } 215 | return(*this); 216 | } 217 | Vector3D& Vector3D::operator^=(const Vector3D& v) 218 | { 219 | double xx = y*v.z - z*v.y; 220 | double yy = z*v.x - x*v.z; 221 | double zz = x*v.y - y*v.x; 222 | x = xx; y = yy; z = zz; 223 | return (*this); 224 | } 225 | 226 | 227 | GEOMETRY_API Vector3D operator+(const Vector3D& lv, const Vector3D& rv) 228 | { 229 | Vector3D rel = lv; 230 | rel += rv; 231 | return rel; 232 | } 233 | 234 | 235 | GEOMETRY_API Vector3D operator-(const Vector3D& lv, const Vector3D& rv) 236 | { 237 | Vector3D rel = lv; 238 | rel -= rv; 239 | return rel; 240 | } 241 | 242 | GEOMETRY_API Vector3D operator*(const double u, const Vector3D& rv) 243 | { 244 | Vector3D rel = rv; 245 | rel *= u; 246 | return rel; 247 | } 248 | 249 | GEOMETRY_API Vector3D operator*(const Vector3D& lv, const double u) 250 | { 251 | Vector3D rel = lv; 252 | rel *= u; 253 | return rel; 254 | } 255 | 256 | GEOMETRY_API Vector3D operator/(const Vector3D& lv, const double u) 257 | { 258 | Vector3D rel = lv; 259 | rel /= u; 260 | return rel; 261 | } 262 | 263 | GEOMETRY_API double operator*(const Vector3D& lv, const Vector3D& rv) 264 | { 265 | return lv.x*rv.x + lv.y*rv.y + lv.z*rv.z; 266 | } 267 | 268 | GEOMETRY_API Vector3D operator^(const Vector3D& lv, const Vector3D& rv) 269 | { 270 | Vector3D rel = lv; 271 | rel ^= rv; 272 | return rel; 273 | } 274 | 275 | GEOMETRY_API std::ostream& operator<< (std::ostream &output, const Vector3D& v) 276 | { 277 | output << v.x << " " << v.y << " " << v.z; 278 | return output; 279 | } 280 | 281 | GEOMETRY_API double Area2(Vector2D &a, Vector2D &b, Vector2D &c){ 282 | return a.x*b.y + b.x*c.y + c.x*a.y - 283 | b.x*a.y - c.x*b.y - a.x*c.y; 284 | } 285 | 286 | GEOMETRY_API double SpcDivision(const double &a, const double &b){ 287 | if (!EQUALZERO(b)) return a / b; 288 | if (EQUALZERO(a)) return 0; 289 | if (a < 0) return -1e30; 290 | else return 1e30; 291 | return 0; 292 | } 293 | 294 | GEOMETRY_API Vector3D Rotate(Vector3D point, double angle, Vector3D rAxis) 295 | { 296 | rAxis.normalize(); 297 | double c = cos(angle), s = sin(angle); 298 | double m[3][3]; 299 | m[0][0] = c + (1 - c)*rAxis.x*rAxis.x; 300 | m[0][1] = (1 - c)*rAxis.x*rAxis.y - s*rAxis.z; 301 | m[0][2] = (1 - c)*rAxis.x*rAxis.z + s*rAxis.y; 302 | 303 | m[1][0] = (1 - c)*rAxis.y*rAxis.x + s*rAxis.z; 304 | m[1][1] = c + (1 - c)*rAxis.y*rAxis.y; 305 | m[1][2] = (1 - c)*rAxis.y*rAxis.z - s*rAxis.x; 306 | 307 | m[2][0] = (1 - c)*rAxis.z*rAxis.x - s*rAxis.y; 308 | m[2][1] = (1 - c)*rAxis.z*rAxis.y + s*rAxis.x; 309 | m[2][2] = c + (1 - c)*rAxis.z*rAxis.z; 310 | 311 | Vector3D ret; 312 | for (int i = 0; i < 3; ++i) 313 | { 314 | ret[i] = 0.0; 315 | for (int j = 0; j < 3; ++j) 316 | ret[i] += m[i][j] * point[j]; 317 | } 318 | return ret; 319 | } 320 | 321 | GEOMETRY_API bool toLeft(const Vector2D &p, const Vector2D &p0, const Vector2D &p1) 322 | { 323 | Vector2D vec0 = p1 - p0, vec1 = p - p0; 324 | vec0.normalize(); vec1.normalize(); 325 | return ((vec0 ^ vec1) > 0.0); 326 | } -------------------------------------------------------------------------------- /GeometryAndMesh/Geometry/Geometry.h: -------------------------------------------------------------------------------- 1 | #ifndef _GEOMETRY_H_ 2 | #define _GEOMETRY_H_ 3 | 4 | // The following ifdef block is the standard way of creating macros which make exporting 5 | // from a DLL simpler. All files within this DLL are compiled with the GEOMETRY_EXPORTS 6 | // symbol defined on the command line. This symbol should not be defined on any project 7 | // that uses this DLL. This way any other project whose source files include this file see 8 | // GEOMETRY_API functions as being imported from a DLL, whereas this DLL sees symbols 9 | // defined with this macro as being exported. 10 | #ifdef GEOMETRY_EXPORTS 11 | #define GEOMETRY_API __declspec(dllexport) 12 | #else 13 | #define GEOMETRY_API __declspec(dllimport) 14 | #endif 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #define DOUBLE_EPS 1e-12 21 | #define LDOUBLE_EPS 1e-6 22 | #define LHDOUBLE_EPS 1e-5 23 | #define EQUALZERO(x) (fabs((x)) < DOUBLE_EPS) 24 | #define LEQUALZERO(x) (fabs((x)) < LDOUBLE_EPS) 25 | #define PI 3.141592653589793238 26 | 27 | ///////////////////////////////////////////////////////////// 28 | // Vector2D : 2D vector 29 | ///////////////////////////////////////////////////////////// 30 | class GEOMETRY_API Vector2D 31 | { 32 | public: 33 | double x, y; 34 | 35 | public: 36 | Vector2D(){ x = 0; y = 0; } 37 | // constructions 38 | Vector2D(double xx, double yy) { x = xx; y = yy; } 39 | Vector2D(const Vector2D& v) { x = v.x; y = v.y; } 40 | 41 | 42 | // operator 43 | double length() const { return sqrt(x*x + y*y); } 44 | double length2() const { return x*x + y*y; } 45 | double normalize() { double len = length(); if (!EQUALZERO(len)) { x /= len; y /= len; } return len; } 46 | double normalizeStrict() { double len = length(); if (len != 0.0) { x /= len; y /= len; } return len; } 47 | Vector2D& operator=(const Vector2D& v); 48 | Vector2D& operator+=(const Vector2D& v); 49 | Vector2D& operator-=(const Vector2D& v); 50 | Vector2D& operator*=(double u); 51 | Vector2D& operator/=(double u); 52 | double& operator[](int idx) { 53 | assert(idx < 2); 54 | switch (idx) 55 | { 56 | case 0: return x; 57 | case 1: return y; 58 | } 59 | } 60 | bool operator == (const Vector2D& right) const 61 | { 62 | return x == right.x && y == right.y; 63 | } 64 | //Vector2D& operator^=(const Vector2D& v); 65 | 66 | bool Intersect(Vector2D v1, Vector2D v2, Vector2D v3, Vector2D v4); 67 | bool Intersect(Vector2D v1, Vector2D v2); 68 | 69 | GEOMETRY_API friend Vector2D operator+(const Vector2D& lv, const Vector2D& rv); 70 | GEOMETRY_API friend Vector2D operator-(const Vector2D& lv, const Vector2D& rv); 71 | GEOMETRY_API friend Vector2D operator*(const double u, const Vector2D& rv); 72 | GEOMETRY_API friend Vector2D operator*(const Vector2D& lv, const double u); 73 | GEOMETRY_API friend Vector2D operator/(const Vector2D& lv, const double u); 74 | GEOMETRY_API friend double operator*(const Vector2D& lv, const Vector2D& rv); 75 | GEOMETRY_API friend double operator^(const Vector2D& lv, const Vector2D& rv); 76 | GEOMETRY_API friend std::ostream& operator<< (std::ostream &output, Vector2D& v); 77 | 78 | short AtWhere(Vector2D v0, Vector2D v1); 79 | bool AtRight(Vector2D v0, Vector2D v1); 80 | bool AtLeft(Vector2D v0, Vector2D v1); 81 | bool OnLine(Vector2D v0, Vector2D v1); 82 | double GetArea(Vector2D v); 83 | 84 | 85 | }; 86 | 87 | ///////////////////////////////////////////////////////////// 88 | // Vector3D : 3D vector 89 | ///////////////////////////////////////////////////////////// 90 | 91 | class Vector4D; 92 | 93 | class GEOMETRY_API Vector3D 94 | { 95 | public: 96 | double x, y, z; 97 | 98 | // constructions 99 | Vector3D() { x = 0; y = 0; z = 0; } 100 | Vector3D(double xx, double yy, double zz) { x = xx; y = yy; z = zz; } 101 | Vector3D(const Vector3D& v) { x = v.x; y = v.y; z = v.z; } 102 | Vector3D(const Vector4D& v); 103 | 104 | // operator 105 | double length() const { return sqrt(x*x + y*y + z*z); } 106 | double length2() const { return x*x + y*y + z*z; } 107 | double normalize() { double len = length(); if (!EQUALZERO(len)) { x /= len; y /= len; z /= len; } return len; } 108 | double normalizeStrict() { double len = length(); if (len != 0.0) { x /= len; y /= len; z /= len; } return len; } 109 | 110 | Vector3D& operator=(const Vector3D& v); 111 | Vector3D& operator=(const Vector4D& v); 112 | Vector3D& operator+=(const Vector3D& v); 113 | Vector3D& operator-=(const Vector3D& v); 114 | Vector3D& operator*=(double u); 115 | Vector3D& operator/=(double u); 116 | Vector3D& operator^=(const Vector3D& v); 117 | double& operator[](int idx) { 118 | assert(idx < 3); 119 | switch (idx) 120 | { 121 | case 0: return x; 122 | case 1: return y; 123 | case 2: return z; 124 | } 125 | } 126 | 127 | bool operator < (const Vector3D& right) const 128 | { 129 | return x - right.x < -LHDOUBLE_EPS || 130 | fabs(x - right.x) <= LHDOUBLE_EPS && y - right.y < -LHDOUBLE_EPS || 131 | fabs(x - right.x) <= LHDOUBLE_EPS && fabs(y - right.y) <= LHDOUBLE_EPS && z - right.z < -LHDOUBLE_EPS; 132 | } 133 | 134 | bool operator == (const Vector3D& right) const 135 | { 136 | return x == right.x && y == right.y && z == right.z; 137 | } 138 | 139 | GEOMETRY_API friend Vector3D operator+(const Vector3D& lv, const Vector3D& rv); 140 | GEOMETRY_API friend Vector3D operator-(const Vector3D& lv, const Vector3D& rv); 141 | GEOMETRY_API friend Vector3D operator*(const double u, const Vector3D& rv); 142 | GEOMETRY_API friend Vector3D operator*(const Vector3D& lv, const double u); 143 | GEOMETRY_API friend Vector3D operator/(const Vector3D& lv, const double u); 144 | GEOMETRY_API friend double operator*(const Vector3D& lv, const Vector3D& rv); 145 | GEOMETRY_API friend Vector3D operator^(const Vector3D& lv, const Vector3D& rv); 146 | GEOMETRY_API friend std::ostream& operator<< (std::ostream &output, const Vector3D& v); 147 | 148 | }; 149 | 150 | class GEOMETRY_API Vector4D 151 | { 152 | public: 153 | double x, y, z, w; 154 | 155 | // constructions 156 | Vector4D() { x = 0; y = 0; z = 0; w = 1.0; } 157 | Vector4D(double xx, double yy, double zz, double ww = 1.0) { x = xx; y = yy; z = zz; w = ww; } 158 | Vector4D(const Vector4D& v) { x = v.x; y = v.y; z = v.z; w = v.w; } 159 | Vector4D(const Vector3D& v) { x = v.x; y = v.y; z = v.z; w = 1.0; } 160 | 161 | double operator* (const Vector4D& right) 162 | { 163 | return x * right.x + y * right.y + z * right.z + w * right.w; 164 | } 165 | 166 | double& operator[](int idx) { 167 | assert(idx < 4); 168 | switch (idx) 169 | { 170 | case 0: return x; 171 | case 1: return y; 172 | case 2: return z; 173 | case 3: return w; 174 | } 175 | } 176 | 177 | bool operator == (const Vector4D& right) const 178 | { 179 | return x == right.x && y == right.y && z == right.z && w == right.w; 180 | } 181 | 182 | Vector4D& operator=(const Vector3D& v) 183 | { 184 | x = v.x; y = v.y; z = v.z; w = 1.0; 185 | return (*this); 186 | } 187 | }; 188 | 189 | GEOMETRY_API double Area2(Vector2D &a, Vector2D &b, Vector2D &c); 190 | 191 | GEOMETRY_API double SpcDivision(const double &a, const double &b); 192 | 193 | GEOMETRY_API Vector3D Rotate(Vector3D point, double angle, Vector3D rAxis); 194 | 195 | GEOMETRY_API bool toLeft(const Vector2D &p, const Vector2D &p0, const Vector2D &p1); 196 | 197 | #endif -------------------------------------------------------------------------------- /GeometryAndMesh/Geometry/Geometry.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {C678C141-6809-469E-ADB7-18E750144DB1} 23 | Win32Proj 24 | Geometry 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | DynamicLibrary 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | Use 84 | Level3 85 | Disabled 86 | WIN32;_DEBUG;_WINDOWS;_USRDLL;GEOMETRY_EXPORTS;%(PreprocessorDefinitions) 87 | 88 | 89 | Windows 90 | true 91 | 92 | 93 | 94 | 95 | Use 96 | Level3 97 | Disabled 98 | WIN32;_DEBUG;_WINDOWS;_USRDLL;GEOMETRY_EXPORTS;%(PreprocessorDefinitions) 99 | 100 | 101 | Windows 102 | true 103 | 104 | 105 | 106 | 107 | Level3 108 | Use 109 | MaxSpeed 110 | true 111 | true 112 | WIN32;NDEBUG;_WINDOWS;_USRDLL;GEOMETRY_EXPORTS;%(PreprocessorDefinitions) 113 | 114 | 115 | Windows 116 | true 117 | true 118 | true 119 | 120 | 121 | 122 | 123 | Level3 124 | Use 125 | MaxSpeed 126 | true 127 | true 128 | WIN32;NDEBUG;_WINDOWS;_USRDLL;GEOMETRY_EXPORTS;%(PreprocessorDefinitions) 129 | 130 | 131 | Windows 132 | true 133 | true 134 | true 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | false 148 | false 149 | 150 | 151 | 152 | 153 | false 154 | false 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | Create 163 | Create 164 | Create 165 | Create 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /GeometryAndMesh/Geometry/Geometry.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /GeometryAndMesh/Geometry/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /GeometryAndMesh/Geometry/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // Geometry.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /GeometryAndMesh/Geometry/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /GeometryAndMesh/Geometry/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /GeometryAndMesh/Mesh/Mesh.h: -------------------------------------------------------------------------------- 1 | #ifndef MESH_H 2 | #define MESH_H 3 | 4 | // The following ifdef block is the standard way of creating macros which make exporting 5 | // from a DLL simpler. All files within this DLL are compiled with the MESH_EXPORTS 6 | // symbol defined on the command line. This symbol should not be defined on any project 7 | // that uses this DLL. This way any other project whose source files include this file see 8 | // MESH_API functions as being imported from a DLL, whereas this DLL sees symbols 9 | // defined with this macro as being exported. 10 | #ifdef MESH_EXPORTS 11 | #define MESH_API __declspec(dllexport) 12 | #else 13 | #define MESH_API __declspec(dllimport) 14 | #endif 15 | 16 | #include "Model.h" 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | typedef unsigned int UINT; 25 | typedef std::list _VECTORLIST; 26 | typedef std::list _UINTLIST; 27 | 28 | #define MAX_VERTEX_PER_FACE 20 29 | 30 | class MESH_API CVertex 31 | { 32 | public: 33 | Vector3D m_vPosition; // 34 | UINT* m_piEdge; //Ӹõ㷢İ,ҪݵĶ̬ 35 | _UINTLIST m_lEdgeList; //m_piEdgeʱ 36 | short m_nValence; //Ķ 37 | Vector3D m_vNormal; //㷨ɸ淨ƽõ 38 | Vector3D m_vRawNormal; //normals loaded from file 39 | bool m_bIsBoundary; //Ƿڱ߽ 40 | int m_nCutValence; 41 | UINT m_color; //ڱǿɫϢ; 42 | bool m_bValid; 43 | 44 | public: 45 | //constructions 46 | CVertex() { m_piEdge = NULL; m_nValence = 0; m_nCutValence = 0; m_bIsBoundary = false; m_color = 0; m_bValid = true; } 47 | CVertex(double x, double y, double z) { m_vPosition = Vector3D(x, y, z); m_piEdge = NULL; m_nValence = 0; m_bIsBoundary = false; m_nCutValence = 0; m_bValid = true; } 48 | CVertex(Vector3D v) { m_vPosition = v; m_piEdge = NULL; m_nValence = 0; m_bIsBoundary = false; m_nCutValence = 0; m_bValid = true; } 49 | virtual ~CVertex(); 50 | 51 | //operations 52 | CVertex& operator = (CVertex& v); 53 | 54 | }; 55 | 56 | class MESH_API CTexture 57 | { 58 | public: 59 | Vector2D m_vPosition; 60 | public: 61 | CTexture() { m_vPosition = Vector2D(0, 0); } 62 | CTexture(double x, double y) { m_vPosition = Vector2D(x, y); } 63 | CTexture(Vector2D v) { m_vPosition = v; } 64 | }; 65 | 66 | class MESH_API CEdge 67 | { 68 | public: 69 | UINT m_iVertex[2]; //ߵ˵㣬Vertex0>Vertex1 70 | 71 | UINT m_iTwinEdge; //ñ߷෴һߣΪ-1ñΪ߽ 72 | UINT m_iNextEdge; //ʱ뷽һ 73 | UINT m_iFace; //ñ棬Ӧ 74 | UINT m_color; //ڱǿɫϢ; 75 | double m_length; //߳; 76 | bool m_bValid; 77 | 78 | public: 79 | bool m_bCut; 80 | int m_nCutTag; 81 | 82 | public: 83 | //constructions 84 | CEdge() { 85 | m_iVertex[0] = m_iVertex[1] = m_iTwinEdge = m_iNextEdge = m_iFace = -1; 86 | m_bCut = false; m_nCutTag = 0; m_color = 0; m_length = 0; m_bValid = true; 87 | } 88 | CEdge(UINT iV0, UINT iV1) { m_iVertex[0] = iV0; m_iVertex[1] = iV1; m_iTwinEdge = m_iNextEdge = m_iFace = -1; m_bCut = false; m_nCutTag = 0; m_bValid = true; } 89 | virtual ~CEdge(); 90 | 91 | //operations 92 | CEdge& operator = (const CEdge& e); 93 | }; 94 | 95 | class MESH_API CFace 96 | { 97 | public: 98 | short m_nType; // 99 | UINT* m_piVertex; //е 100 | UINT* m_piEdge; //б 101 | double* m_pdAngle; 102 | Vector3D m_vNormal; // 103 | Vector3D m_vMassPoint; // 104 | double m_dArea; // 105 | UINT m_color; //ڱǿɫϢ; 106 | bool m_bValid; 107 | 108 | public: 109 | //constructions 110 | CFace() { m_nType = 0; m_piVertex = m_piEdge = NULL; m_pdAngle = NULL; m_vNormal = Vector3D(0.0, 0.0, 1.0); m_dArea = 0.0; m_color = 0; m_bValid = true; } 111 | CFace(short s); 112 | virtual ~CFace(); 113 | 114 | //operations 115 | void Create(short s); 116 | CFace& operator = (const CFace& f); 117 | }; 118 | 119 | class MESH_API CMesh :public CModel 120 | { 121 | public: 122 | UINT m_nVertex; // 123 | CVertex* m_pVertex; // 124 | 125 | std::vector m_pTexture; 126 | CTexture maxTex; 127 | 128 | UINT m_nEdge; // 129 | CEdge* m_pEdge; //߱ 130 | UINT m_nFace; // 131 | CFace* m_pFace; // 132 | UINT m_nVertexCapacity; //ǰб 133 | UINT m_nEdgeCapacity; //ǰ߱ 134 | UINT m_nFaceCapacity; //ǰ 135 | 136 | Vector3D color; 137 | bool isVisible; 138 | 139 | unsigned m_nValidVertNum; 140 | unsigned m_nValidFaceNum; 141 | unsigned m_nValidEdgeNum; 142 | 143 | std::vector isolatedPoints; 144 | 145 | double *m_pAngles; 146 | 147 | std::string filename; //ļ 148 | double scaleD; 149 | Vector3D origin; 150 | Vector3D bboxSize; 151 | 152 | //temp 153 | _UINTLIST m_lFocusEdge; 154 | _UINTLIST m_lFocusVertex; 155 | _UINTLIST m_lFocusFace; 156 | UINT m_iPickedFace; 157 | UINT m_iPickedEdge; 158 | UINT m_iPickedVertex; 159 | 160 | bool m_bClosed; 161 | 162 | public: 163 | CMesh() { 164 | m_nVertex = m_nEdge = m_nFace = 0; 165 | m_pVertex = NULL; m_pEdge = NULL; m_pFace = NULL; m_pAngles = NULL; 166 | m_iPickedFace = m_iPickedEdge = m_iPickedVertex = -1; 167 | isVisible = true; 168 | } 169 | CMesh(CMesh* pMesh); 170 | virtual ~CMesh(); 171 | 172 | public: 173 | bool Load(const char* sFileName); // load from file 174 | bool Save(const char* sFileName); // save to file 175 | 176 | MESH_API friend std::istream& operator >> (std::istream &input, CMesh &mesh); 177 | 178 | bool construct();// construct connectivity 179 | 180 | CMesh* clone(); 181 | 182 | //iEdgeڵ棨Ϊֻ߽һ棩iEdgeϸ֡ 183 | UINT split(UINT iEdge, double posPercent = -1.0); 184 | 185 | //flip edge whose two adjacent facws are in the same plane 186 | void flip(unsigned iEdge); 187 | 188 | void collapse(unsigned iEdge, Vector3D newPos); 189 | 190 | void add(Vector3D pos, unsigned iFace); 191 | 192 | //бߵı߳CEdge->m_length 193 | void calcAllEdgeLength(); 194 | private: 195 | void clear(); 196 | bool reConstruct();// construct connectivity from current mesh 197 | bool loadOBJ(const char* sFileName); 198 | bool loadOFF(const char* sFileName); 199 | bool loadM(const char* sFileName); 200 | bool loadFromSMF(std::list &VertexList, 201 | std::list &FaceList, 202 | std::vector &normals); 203 | bool saveToSMF(const char* sFileName); 204 | 205 | //iķ 206 | void calFaceNormal(UINT i); 207 | //㶥iķķƽõ 208 | void calVertexNormal(UINT i); 209 | //ебٳȲʱռӱ 210 | void expandCapacity(); 211 | //ÿΧĽǶ 212 | void calcVertexAngle(); 213 | 214 | std::vector splitString(std::string s, std::string sep); 215 | }; 216 | 217 | #endif //MESH_H 218 | -------------------------------------------------------------------------------- /GeometryAndMesh/Mesh/Mesh.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {249E5561-B563-4022-AFE1-B9B0B83D149B} 23 | Win32Proj 24 | Mesh 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | DynamicLibrary 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | Use 84 | Level3 85 | Disabled 86 | WIN32;_DEBUG;_WINDOWS;_USRDLL;MESH_EXPORTS;%(PreprocessorDefinitions) 87 | 88 | 89 | Windows 90 | true 91 | ..\Debug\Geometry.lib;%(AdditionalDependencies) 92 | 93 | 94 | 95 | 96 | Use 97 | Level3 98 | Disabled 99 | WIN32;_DEBUG;_WINDOWS;_USRDLL;MESH_EXPORTS;%(PreprocessorDefinitions) 100 | 101 | 102 | Windows 103 | true 104 | ..\x64\Debug\Geometry.lib;%(AdditionalDependencies) 105 | 106 | 107 | 108 | 109 | Level3 110 | Use 111 | MaxSpeed 112 | true 113 | true 114 | WIN32;NDEBUG;_WINDOWS;_USRDLL;MESH_EXPORTS;%(PreprocessorDefinitions) 115 | 116 | 117 | Windows 118 | true 119 | true 120 | true 121 | ..\Release\Geometry.lib;%(AdditionalDependencies) 122 | 123 | 124 | 125 | 126 | Level3 127 | Use 128 | MaxSpeed 129 | true 130 | true 131 | WIN32;NDEBUG;_WINDOWS;_USRDLL;MESH_EXPORTS;%(PreprocessorDefinitions) 132 | 133 | 134 | Windows 135 | true 136 | true 137 | true 138 | ..\x64\Release\Geometry.lib;%(AdditionalDependencies) 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | false 153 | false 154 | 155 | 156 | 157 | 158 | false 159 | false 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | Create 168 | Create 169 | Create 170 | Create 171 | 172 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /GeometryAndMesh/Mesh/Mesh.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | -------------------------------------------------------------------------------- /GeometryAndMesh/Mesh/Model.h: -------------------------------------------------------------------------------- 1 | #ifndef _MODEL_H_ 2 | #define _MODEL_H_ 3 | 4 | #include "..\Geometry\Geometry.h" 5 | 6 | class CModel 7 | { 8 | public: 9 | CModel() {} 10 | public: 11 | Vector3D m_vTranslation;//ƫ 12 | Vector3D m_vRotation;//ת 13 | double m_color[3];//ɫ 14 | 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /GeometryAndMesh/Mesh/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /GeometryAndMesh/Mesh/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // Mesh.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /GeometryAndMesh/Mesh/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /GeometryAndMesh/Mesh/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /GeometryAndMesh/MeshAndGeometry.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MeshAndGeometry", "MeshAndGeometry.vcxproj", "{8C0BB558-0456-4763-84B7-4274B17CD054}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {C678C141-6809-469E-ADB7-18E750144DB1} = {C678C141-6809-469E-ADB7-18E750144DB1} 9 | {249E5561-B563-4022-AFE1-B9B0B83D149B} = {249E5561-B563-4022-AFE1-B9B0B83D149B} 10 | EndProjectSection 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Geometry", "Geometry\Geometry.vcxproj", "{C678C141-6809-469E-ADB7-18E750144DB1}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mesh", "Mesh\Mesh.vcxproj", "{249E5561-B563-4022-AFE1-B9B0B83D149B}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | {C678C141-6809-469E-ADB7-18E750144DB1} = {C678C141-6809-469E-ADB7-18E750144DB1} 17 | EndProjectSection 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Win32 = Debug|Win32 22 | Debug|x64 = Debug|x64 23 | Release|Win32 = Release|Win32 24 | Release|x64 = Release|x64 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {8C0BB558-0456-4763-84B7-4274B17CD054}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {8C0BB558-0456-4763-84B7-4274B17CD054}.Debug|Win32.Build.0 = Debug|Win32 29 | {8C0BB558-0456-4763-84B7-4274B17CD054}.Debug|x64.ActiveCfg = Debug|x64 30 | {8C0BB558-0456-4763-84B7-4274B17CD054}.Debug|x64.Build.0 = Debug|x64 31 | {8C0BB558-0456-4763-84B7-4274B17CD054}.Release|Win32.ActiveCfg = Release|Win32 32 | {8C0BB558-0456-4763-84B7-4274B17CD054}.Release|Win32.Build.0 = Release|Win32 33 | {8C0BB558-0456-4763-84B7-4274B17CD054}.Release|x64.ActiveCfg = Release|x64 34 | {8C0BB558-0456-4763-84B7-4274B17CD054}.Release|x64.Build.0 = Release|x64 35 | {C678C141-6809-469E-ADB7-18E750144DB1}.Debug|Win32.ActiveCfg = Debug|Win32 36 | {C678C141-6809-469E-ADB7-18E750144DB1}.Debug|Win32.Build.0 = Debug|Win32 37 | {C678C141-6809-469E-ADB7-18E750144DB1}.Debug|x64.ActiveCfg = Debug|x64 38 | {C678C141-6809-469E-ADB7-18E750144DB1}.Debug|x64.Build.0 = Debug|x64 39 | {C678C141-6809-469E-ADB7-18E750144DB1}.Release|Win32.ActiveCfg = Release|Win32 40 | {C678C141-6809-469E-ADB7-18E750144DB1}.Release|Win32.Build.0 = Release|Win32 41 | {C678C141-6809-469E-ADB7-18E750144DB1}.Release|x64.ActiveCfg = Release|x64 42 | {C678C141-6809-469E-ADB7-18E750144DB1}.Release|x64.Build.0 = Release|x64 43 | {249E5561-B563-4022-AFE1-B9B0B83D149B}.Debug|Win32.ActiveCfg = Debug|Win32 44 | {249E5561-B563-4022-AFE1-B9B0B83D149B}.Debug|Win32.Build.0 = Debug|Win32 45 | {249E5561-B563-4022-AFE1-B9B0B83D149B}.Debug|x64.ActiveCfg = Debug|x64 46 | {249E5561-B563-4022-AFE1-B9B0B83D149B}.Debug|x64.Build.0 = Debug|x64 47 | {249E5561-B563-4022-AFE1-B9B0B83D149B}.Release|Win32.ActiveCfg = Release|Win32 48 | {249E5561-B563-4022-AFE1-B9B0B83D149B}.Release|Win32.Build.0 = Release|Win32 49 | {249E5561-B563-4022-AFE1-B9B0B83D149B}.Release|x64.ActiveCfg = Release|x64 50 | {249E5561-B563-4022-AFE1-B9B0B83D149B}.Release|x64.Build.0 = Release|x64 51 | EndGlobalSection 52 | GlobalSection(SolutionProperties) = preSolution 53 | HideSolutionNode = FALSE 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /GeometryAndMesh/MeshAndGeometry.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {8C0BB558-0456-4763-84B7-4274B17CD054} 23 | Win32Proj 24 | MeshAndGeometry 25 | 26 | 27 | 28 | Application 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | Application 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | Application 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | 84 | 85 | Level3 86 | Disabled 87 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 88 | 89 | 90 | Console 91 | true 92 | Debug\Geometry.lib;Debug\Mesh.lib;%(AdditionalDependencies) 93 | 94 | 95 | 96 | 97 | 98 | 99 | Level3 100 | Disabled 101 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 102 | 103 | 104 | Console 105 | true 106 | x64\Debug\Geometry.lib;x64\Debug\Mesh.lib;%(AdditionalDependencies) 107 | 108 | 109 | 110 | 111 | Level3 112 | 113 | 114 | MaxSpeed 115 | true 116 | true 117 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 118 | 119 | 120 | Console 121 | true 122 | true 123 | true 124 | Release\Geometry.lib;Release\Mesh.lib;%(AdditionalDependencies) 125 | 126 | 127 | 128 | 129 | Level3 130 | 131 | 132 | MaxSpeed 133 | true 134 | true 135 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 136 | 137 | 138 | Console 139 | true 140 | true 141 | true 142 | x64\Release\Geometry.lib;x64\Release\Mesh.lib;%(AdditionalDependencies) 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /GeometryAndMesh/MeshAndGeometry.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /GeometryAndMesh/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Mesh\Mesh.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(int argc, char **argv) 7 | { 8 | if (argc < 2) 9 | { 10 | cout << "USAGE: [.exe] [.obj]" << endl; 11 | return -1; 12 | } 13 | 14 | string baseFileName = argv[1]; 15 | baseFileName = baseFileName.substr(0, baseFileName.rfind(".")); 16 | 17 | CMesh mesh; 18 | if (!mesh.Load(argv[1])) 19 | { 20 | cout << "Cannot load mesh " << argv[1] << endl; 21 | return -2; 22 | } 23 | 24 | cout << "Mesh Loaded." << endl; 25 | cout << "nVert: " << mesh.m_nVertex << endl; 26 | cout << "nFace: " << mesh.m_nFace << endl; 27 | 28 | unsigned e0 = mesh.m_pVertex[0].m_piEdge[0]; 29 | mesh.split(e0); 30 | mesh.Save("test0.obj"); 31 | e0 = mesh.m_pVertex[0].m_piEdge[1]; 32 | mesh.split(e0); 33 | mesh.Save("test1.obj"); 34 | // unsigned v0 = mesh.m_pFace[0].m_piVertex[0]; 35 | // unsigned v1 = mesh.m_pFace[0].m_piVertex[1]; 36 | // unsigned v2 = mesh.m_pFace[0].m_piVertex[2]; 37 | // 38 | // Vector3D pos = (mesh.m_pVertex[v0].m_vPosition + mesh.m_pVertex[v1].m_vPosition + 39 | // mesh.m_pVertex[v2].m_vPosition) / 3.0; 40 | // mesh.add(pos, 0); 41 | // mesh.Save((baseFileName + ".add.obj").c_str()); 42 | // 43 | // unsigned lastFace = mesh.m_nFace - 1; 44 | // 45 | // v0 = mesh.m_pFace[lastFace].m_piVertex[0]; 46 | // v1 = mesh.m_pFace[lastFace].m_piVertex[1]; 47 | // v2 = mesh.m_pFace[lastFace].m_piVertex[2]; 48 | // 49 | // pos = (mesh.m_pVertex[v0].m_vPosition + mesh.m_pVertex[v1].m_vPosition + 50 | // mesh.m_pVertex[v2].m_vPosition) / 3.0; 51 | // mesh.add(pos, lastFace); 52 | // mesh.Save((baseFileName + ".add1.obj").c_str()); 53 | 54 | // for (int i = 0; i < mesh.m_nVertex; ++i) 55 | // mesh.m_pVertex[i].m_vPosition = Rotate(mesh.m_pVertex[i].m_vPosition, PI/2, Vector3D(1.0, 0.0, 0.0)); 56 | // mesh.Save("rotateTest.obj"); 57 | } -------------------------------------------------------------------------------- /LBO/LBO.cpp: -------------------------------------------------------------------------------- 1 | // LBO.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "LBO.h" 6 | 7 | using namespace std; 8 | 9 | 10 | // This is an example of an exported variable 11 | // LBO_API int nLBO=0; 12 | // 13 | // This is an example of an exported function. 14 | // LBO_API int fnLBO(void) 15 | // { 16 | // return 42; 17 | // } 18 | 19 | // This is the constructor of a class that has been exported. 20 | // see LBO.h for the class definition 21 | LBO_API LBO::LBO() 22 | { 23 | return; 24 | } 25 | 26 | LBO_API void LBO::AssignMesh(CMesh *mesh_) 27 | { 28 | mesh = mesh_; 29 | L.resize(mesh->m_nVertex, mesh->m_nVertex); 30 | A.resize(mesh->m_nVertex, mesh->m_nVertex); 31 | 32 | } 33 | 34 | LBO_API void LBO::Construct() 35 | { 36 | ConstructLaplacian(); 37 | ConstructAreaDiag(); 38 | } 39 | 40 | LBO_API double LBO::CalcCotWeight(unsigned edgeIndex) 41 | { 42 | unsigned e[5]; 43 | e[0] = edgeIndex; 44 | e[1] = mesh->m_pEdge[e[0]].m_iNextEdge; 45 | e[2] = mesh->m_pEdge[e[1]].m_iNextEdge; 46 | e[3] = -1, e[4] = -1; 47 | if (mesh->m_pEdge[e[0]].m_iTwinEdge != -1) 48 | { 49 | e[3] = mesh->m_pEdge[mesh->m_pEdge[e[0]].m_iTwinEdge].m_iNextEdge; 50 | e[4] = mesh->m_pEdge[e[3]].m_iNextEdge; 51 | } 52 | 53 | double l[5]; 54 | for (int i = 0; i < 5; ++i) 55 | l[i] = (e[i] != -1 ? mesh->m_pEdge[e[i]].m_length : 0); 56 | 57 | double cos1 = (l[1] * l[1] + l[2] * l[2] - l[0] * l[0]) / (2 * l[1] * l[2]); 58 | double cos2 = (l[3] != 0 ? (l[3] * l[3] + l[4] * l[4] - l[0] * l[0]) / (2 * l[3] * l[4]) : 0); 59 | 60 | double sin1 = sqrt(fabs(1 - cos1*cos1)); 61 | double sin2 = sqrt(fabs(1 - cos2*cos2)); 62 | 63 | return ((sin1 == 0 ? 0 : cos1 / sin1) + (sin2 == 0 ? 0 : cos2 / sin2)) / 2; 64 | } 65 | 66 | LBO_API void LBO::ConstructLaplacian() 67 | { 68 | vector tripletList; 69 | vector diag; 70 | diag.resize(mesh->m_nVertex, 0); 71 | 72 | for (unsigned i = 0; i < mesh->m_nEdge; ++i) 73 | { 74 | if (i > mesh->m_pEdge[i].m_iTwinEdge) continue; 75 | 76 | double wij = CalcCotWeight(i); 77 | unsigned v0 = mesh->m_pEdge[i].m_iVertex[0]; 78 | unsigned v1 = mesh->m_pEdge[i].m_iVertex[1]; 79 | tripletList.push_back(Triplet(v0, v1, wij)); 80 | tripletList.push_back(Triplet(v1, v0, wij)); 81 | diag[v0] -= wij; diag[v1] -= wij; 82 | } 83 | for (unsigned i = 0; i < diag.size(); ++i) 84 | { 85 | tripletList.push_back(Triplet(i, i, diag[i])); 86 | } 87 | 88 | L.setFromTriplets(tripletList.begin(), tripletList.end()); 89 | } 90 | 91 | LBO_API void LBO::ConstructAreaDiag() 92 | { 93 | vector tripletList; 94 | 95 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 96 | { 97 | double curArea = 0.0; 98 | for (unsigned j = 0; j < mesh->m_pVertex[i].m_nValence; ++j) 99 | curArea += mesh->m_pFace[mesh->m_pEdge[mesh->m_pVertex[i].m_piEdge[j]].m_iFace].m_dArea / 3.0; 100 | tripletList.push_back(Triplet(i, i, curArea)); 101 | } 102 | A.setFromTriplets(tripletList.begin(), tripletList.end()); 103 | } -------------------------------------------------------------------------------- /LBO/LBO.h: -------------------------------------------------------------------------------- 1 | // The following ifdef block is the standard way of creating macros which make exporting 2 | // from a DLL simpler. All files within this DLL are compiled with the LBO_EXPORTS 3 | // symbol defined on the command line. This symbol should not be defined on any project 4 | // that uses this DLL. This way any other project whose source files include this file see 5 | // LBO_API functions as being imported from a DLL, whereas this DLL sees symbols 6 | // defined with this macro as being exported. 7 | #ifdef LBO_EXPORTS 8 | #define LBO_API __declspec(dllexport) 9 | #else 10 | #define LBO_API __declspec(dllimport) 11 | #endif 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | // This class is exported from the LBO.dll 18 | class LBO_API LBO { 19 | public: 20 | typedef Eigen::SparseMatrix SparseMatrix; 21 | typedef Eigen::Triplet Triplet; 22 | 23 | LBO(); 24 | void AssignMesh(CMesh *mesh_); 25 | void Construct(); 26 | 27 | const SparseMatrix& LMatrix() { return L; } 28 | const SparseMatrix& AMatrix() { return A; } 29 | 30 | private: 31 | double CalcCotWeight(unsigned edgeIndex); 32 | void ConstructLaplacian(); 33 | void ConstructAreaDiag(); 34 | 35 | private: 36 | CMesh *mesh; 37 | SparseMatrix L, A; 38 | }; 39 | 40 | // extern LBO_API int nLBO; 41 | // 42 | // LBO_API int fnLBO(void); 43 | -------------------------------------------------------------------------------- /LBO/LBO.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LBO", "LBO.vcxproj", "{E96D51E8-1332-4576-BC7F-6B3556C2F78E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E}.Debug|Win32.Build.0 = Debug|Win32 18 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E}.Debug|x64.ActiveCfg = Debug|x64 19 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E}.Debug|x64.Build.0 = Debug|x64 20 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E}.Release|Win32.ActiveCfg = Release|Win32 21 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E}.Release|Win32.Build.0 = Release|Win32 22 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E}.Release|x64.ActiveCfg = Release|x64 23 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /LBO/LBO.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {E96D51E8-1332-4576-BC7F-6B3556C2F78E} 23 | Win32Proj 24 | LBO 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | DynamicLibrary 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | Use 84 | Level3 85 | Disabled 86 | WIN32;_DEBUG;_WINDOWS;_USRDLL;LBO_EXPORTS;%(PreprocessorDefinitions) 87 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;%(AdditionalIncludeDirectories) 88 | 89 | 90 | Windows 91 | true 92 | $(MESHANDGEOMETRY)\x64\$(Configuration);%(AdditionalLibraryDirectories) 93 | Geometry.lib;Mesh.lib;%(AdditionalDependencies) 94 | 95 | 96 | 97 | 98 | Use 99 | Level3 100 | Disabled 101 | WIN32;_DEBUG;_WINDOWS;_USRDLL;LBO_EXPORTS;%(PreprocessorDefinitions) 102 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;%(AdditionalIncludeDirectories) 103 | 104 | 105 | Windows 106 | true 107 | $(MESHANDGEOMETRY)\$(Configuration);%(AdditionalLibraryDirectories) 108 | Geometry.lib;Mesh.lib;%(AdditionalDependencies) 109 | 110 | 111 | 112 | 113 | Level3 114 | Use 115 | MaxSpeed 116 | true 117 | true 118 | WIN32;NDEBUG;_WINDOWS;_USRDLL;LBO_EXPORTS;%(PreprocessorDefinitions) 119 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;%(AdditionalIncludeDirectories) 120 | 121 | 122 | Windows 123 | true 124 | true 125 | true 126 | $(MESHANDGEOMETRY)\x64\$(Configuration);%(AdditionalLibraryDirectories) 127 | Geometry.lib;Mesh.lib;%(AdditionalDependencies) 128 | 129 | 130 | 131 | 132 | Level3 133 | Use 134 | MaxSpeed 135 | true 136 | true 137 | WIN32;NDEBUG;_WINDOWS;_USRDLL;LBO_EXPORTS;%(PreprocessorDefinitions) 138 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;%(AdditionalIncludeDirectories) 139 | 140 | 141 | Windows 142 | true 143 | true 144 | true 145 | $(MESHANDGEOMETRY)\$(Configuration);%(AdditionalLibraryDirectories) 146 | Geometry.lib;Mesh.lib;%(AdditionalDependencies) 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | false 160 | false 161 | 162 | 163 | 164 | 165 | false 166 | false 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | Create 175 | Create 176 | Create 177 | Create 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /LBO/LBO.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /LBO/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /LBO/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // LBO.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /LBO/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /LBO/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LBO 2 | Discrete Laplace Beltrami Operator (LBO) and related applications. 3 | 4 | ## Applications: 5 | 6 | ### Mean Curvature 7 | A direct application of discrete LBO is calculate the mean curvature vector of a surface by simply multipling the Laplacian matrix on the point itself. Following is an example: 8 |
9 | 10 | 11 |
12 | Figure 1. An example of meancurvature field and vectors computed from LBO 13 |
14 | 15 | ### Harmonic Map 16 | #### Disk Harmonic Map 17 | Disk Harmonic Map maps a surface homeomorphic to the planar unit disk. It is a popular parameterization method. An example of disk harmonic map on a nefertiti model is shown below: 18 |
19 | 20 | 21 | 22 |
23 | Figure 2. An example of disk harmonic maps. Left to right: Original mesh, mapped mesh, stretched mesh on unit disk 24 |
25 | #### Spherical Harmonic Map 26 | Spherical harmonic map "blows" a genus-0 model into a sphere. Here an iterative implementation is used. 27 |
28 | 29 | 30 |
31 | Figure 3. An example of spherical harmonic maps. A brain model is mapped onto a unit sphere. 32 |
33 | 34 | ### Heat method 35 | The heat method ([1]) is a discrete geodesic solution on various domains (grids, triangle/polygonal meshes, point clouds etc.). It's specially suitable for calculating distance fields with different sets of sources on the same mesh for several times. The implementation here is based on triangle mesh only. Here is an example output of heat method on a bunny model: 36 |
37 | 38 | 39 | 40 |
41 | Figure 4. An example of geodesic distance fields generated by heat method. 42 |
43 | 44 | [1] Crane K, Weischedel C, Wardetzky M. Geodesics in heat: A new approach to computing distance based on heat flow[J]. ACM Transactions on Graphics (TOG), 2013, 32(5): 152. 45 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DiskHarmonicMap", "DiskHarmonicMap\DiskHarmonicMap.vcxproj", "{68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_main", "test_main\test_main.vcxproj", "{149EB194-73D3-4A17-8CB5-C244EA84AB57}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF} = {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}.Debug|Win32.Build.0 = Debug|Win32 23 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}.Debug|x64.ActiveCfg = Debug|x64 24 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}.Debug|x64.Build.0 = Debug|x64 25 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}.Release|Win32.ActiveCfg = Release|Win32 26 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}.Release|Win32.Build.0 = Release|Win32 27 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}.Release|x64.ActiveCfg = Release|x64 28 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF}.Release|x64.Build.0 = Release|x64 29 | {149EB194-73D3-4A17-8CB5-C244EA84AB57}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {149EB194-73D3-4A17-8CB5-C244EA84AB57}.Debug|Win32.Build.0 = Debug|Win32 31 | {149EB194-73D3-4A17-8CB5-C244EA84AB57}.Debug|x64.ActiveCfg = Debug|x64 32 | {149EB194-73D3-4A17-8CB5-C244EA84AB57}.Debug|x64.Build.0 = Debug|x64 33 | {149EB194-73D3-4A17-8CB5-C244EA84AB57}.Release|Win32.ActiveCfg = Release|Win32 34 | {149EB194-73D3-4A17-8CB5-C244EA84AB57}.Release|Win32.Build.0 = Release|Win32 35 | {149EB194-73D3-4A17-8CB5-C244EA84AB57}.Release|x64.ActiveCfg = Release|x64 36 | {149EB194-73D3-4A17-8CB5-C244EA84AB57}.Release|x64.Build.0 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap/DiskHarmonicMap.cpp: -------------------------------------------------------------------------------- 1 | // DiskHarmonicMap.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "DiskHarmonicMap.h" 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | // This is the constructor of a class that has been exported. 11 | // see DiskHarmonicMap.h for the class definition 12 | DiskHarmonicMap::DiskHarmonicMap() 13 | { 14 | lbo = NULL; 15 | return; 16 | } 17 | 18 | 19 | DiskHarmonicMap::~DiskHarmonicMap() 20 | { 21 | if (lbo) delete lbo; 22 | } 23 | 24 | void DiskHarmonicMap::AssignMesh(CMesh *mesh_) 25 | { 26 | mesh = mesh_; 27 | lbo = new LBO(); 28 | lbo->AssignMesh(mesh); 29 | x1.resize(mesh->m_nVertex); 30 | x2.resize(mesh->m_nVertex); 31 | } 32 | 33 | void DiskHarmonicMap::Execute() 34 | { 35 | // construct bondary conditions 36 | unsigned boundVertCnt = 0; 37 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 38 | if (mesh->m_pVertex[i].m_bIsBoundary) 39 | ++boundVertCnt; 40 | cout << "# of boundary vertices: " << boundVertCnt << endl; 41 | 42 | vector boundVerts; 43 | vector boundVertsDouble; 44 | vector thetas; 45 | 46 | if (!ConstructBoundaryConditions(boundVerts, thetas)) 47 | { 48 | cout << "Fail to create boundary conditions!" << endl; 49 | return; 50 | } 51 | 52 | lbo->Construct(); 53 | // fix Laplacian matrix 54 | SparseMatrix L = lbo->LMatrix(); 55 | for (unsigned i = 0; i < boundVerts.size(); ++i) 56 | { 57 | for (unsigned j = 0; j < mesh->m_pVertex[boundVerts[i]].m_nValence; ++j) 58 | { 59 | unsigned opVert = mesh->m_pEdge[mesh->m_pVertex[boundVerts[i]].m_piEdge[j]].m_iVertex[1]; 60 | L.coeffRef(boundVerts[i], opVert) = 0; 61 | } 62 | // for the very first adjacent vertex 63 | unsigned opVert = mesh->m_pEdge[mesh->m_pEdge[mesh->m_pVertex[boundVerts[i]].m_piEdge[0]].m_iNextEdge].m_iVertex[1]; 64 | L.coeffRef(boundVerts[i], opVert) = 0; 65 | // make diagonal to be 1 66 | L.coeffRef(boundVerts[i], boundVerts[i]) = 1.0; 67 | } 68 | 69 | Eigen::VectorXd b1(mesh->m_nVertex); 70 | Eigen::VectorXd b2(mesh->m_nVertex); 71 | ConstructB(b1, b2, boundVerts, thetas); 72 | 73 | clock_t start = clock(); 74 | Eigen::SparseLU chol; 75 | chol.compute(L); 76 | x1 = chol.solve(b1); x2 = chol.solve(b2); 77 | clock_t end = clock(); 78 | cout << "Time consumed: " << (double)(end - start) / (double)CLOCKS_PER_SEC << endl; 79 | 80 | double angleDistortion, areaDistortion; 81 | computeDistortion(x1, x2, angleDistortion, areaDistortion); 82 | 83 | cout << "Angle distortion: " << angleDistortion << endl; 84 | cout << "Area distortion: " << areaDistortion << endl; 85 | } 86 | 87 | bool DiskHarmonicMap::ConstructBoundaryConditions(std::vector &boundVerts, std::vector &thetas) 88 | { 89 | boundVerts.clear(); thetas.clear(); 90 | unsigned startVert = -1; 91 | unsigned cntStart = 0; 92 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 93 | { 94 | if (mesh->m_pVertex[i].m_bIsBoundary) 95 | { 96 | ++cntStart; 97 | startVert = i; 98 | /*if (cntStart == 20) break;*/ 99 | break; 100 | } 101 | } 102 | 103 | if (startVert == -1) 104 | { 105 | cout << "No boundary!" << endl; 106 | return false; 107 | } 108 | 109 | boundVerts.push_back(startVert); 110 | thetas.push_back(0.0); 111 | 112 | do 113 | { 114 | unsigned prevVert = boundVerts.back(); 115 | for (unsigned i = 0; i < mesh->m_pVertex[prevVert].m_nValence; ++i) 116 | { 117 | unsigned curEdge = mesh->m_pVertex[prevVert].m_piEdge[i]; 118 | unsigned v0 = mesh->m_pEdge[curEdge].m_iVertex[1]; 119 | if (mesh->m_pEdge[curEdge].m_iTwinEdge != -1) continue; 120 | /*if (boundVerts.size() >= 2 && v0 == boundVerts[boundVerts.size()-2]) continue;*/ 121 | 122 | boundVerts.push_back(v0); 123 | thetas.push_back(thetas.back() + mesh->m_pEdge[curEdge].m_length); 124 | break; 125 | } 126 | } while (boundVerts.back() != startVert); 127 | 128 | double maxLen = thetas.back(); 129 | boundVerts.pop_back(); thetas.pop_back(); 130 | 131 | for (unsigned i = 0; i < thetas.size(); ++i) 132 | thetas[i] *= (2 * PI / maxLen); 133 | return true; 134 | } 135 | 136 | void DiskHarmonicMap::ConstructB(Eigen::VectorXd &b1, Eigen::VectorXd &b2, 137 | std::vector &boundVerts, std::vector &thetas) 138 | { 139 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 140 | { 141 | b1[i] = 0; b2[i] = 0; 142 | } 143 | for (unsigned i = 0; i < boundVerts.size(); ++i) 144 | { 145 | b1[boundVerts[i]] = cos(thetas[i]); 146 | b2[boundVerts[i]] = sin(thetas[i]); 147 | } 148 | } 149 | 150 | void DiskHarmonicMap::computeDistortion(Eigen::VectorXd &vt1, Eigen::VectorXd &vt2, 151 | double &angleDistortion, double &areaDistortion) 152 | { 153 | // compute area scale 154 | double totalArea = 0.0; 155 | for (unsigned i = 0; i < mesh->m_nFace; ++i) 156 | totalArea += mesh->m_pFace[i].m_dArea; 157 | double scale = PI / totalArea; 158 | totalArea = PI; 159 | 160 | angleDistortion = 0.0; areaDistortion = 0.0; 161 | for (unsigned i = 0; i < mesh->m_nFace; ++i) 162 | { 163 | double curArea = mesh->m_pFace[i].m_dArea * scale; 164 | 165 | Vector2D verts[3]; 166 | for (unsigned j = 0; j < 3; ++j) 167 | verts[j] = Vector2D(vt1[mesh->m_pFace[i].m_piVertex[j]], vt2[mesh->m_pFace[i].m_piVertex[j]]); 168 | double L[3]; 169 | for (unsigned j = 0; j < 3; ++j) 170 | L[j] = (verts[j] - verts[(j + 1) % 3]).length(); 171 | double p = (L[0] + L[1] + L[2]) / 2.0; 172 | double mappedArea = sqrt(p * (p - L[0]) * (p - L[1]) * (p - L[2])); 173 | 174 | if (mappedArea == 0.0 || curArea == 0.0) continue; 175 | /*areaDistortion += (curArea - mappedArea) * (curArea - mappedArea);*/ 176 | areaDistortion += 0.5 * (curArea / mappedArea + mappedArea / curArea) * curArea; 177 | 178 | double curAngleDistortion = 0.0; 179 | bool flag = false; 180 | for (unsigned j = 0; j < 3; ++j) 181 | { 182 | double l0 = mesh->m_pEdge[mesh->m_pFace[i].m_piEdge[j]].m_length; 183 | double l1 = mesh->m_pEdge[mesh->m_pFace[i].m_piEdge[(j + 2) % 3]].m_length; 184 | double l2 = mesh->m_pEdge[mesh->m_pFace[i].m_piEdge[(j + 1) % 3]].m_length; 185 | 186 | double acosAngle = (l0*l0 + l1*l1 - l2*l2) / (2 * l0*l1); 187 | if (acosAngle > 1.0) acosAngle = 1.0; 188 | if (acosAngle < -1.0) acosAngle = -1.0; 189 | double curAngle = acos(acosAngle); 190 | 191 | if (tan(curAngle) == 0.0) { flag = true; break; } 192 | curAngleDistortion += 1.0 / tan(curAngle) * L[(j + 1) % 3] * L[(j + 1) % 3]; 193 | /*angleDistortion += (curAngle - mappedAngle) * (curAngle - mappedAngle);*/ 194 | /*angleDistortion += fabs(mappedAngle/curAngle - 1.0)*(mappedAngle/curAngle - 1.0);*/ 195 | } 196 | if (flag) continue; 197 | angleDistortion += curAngleDistortion / (4.0 * mappedArea) * curArea; 198 | } 199 | 200 | angleDistortion /= totalArea; 201 | areaDistortion /= totalArea; 202 | } -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap/DiskHarmonicMap.h: -------------------------------------------------------------------------------- 1 | // The following ifdef block is the standard way of creating macros which make exporting 2 | // from a DLL simpler. All files within this DLL are compiled with the DISKHARMONICMAP_EXPORTS 3 | // symbol defined on the command line. This symbol should not be defined on any project 4 | // that uses this DLL. This way any other project whose source files include this file see 5 | // DISKHARMONICMAP_API functions as being imported from a DLL, whereas this DLL sees symbols 6 | // defined with this macro as being exported. 7 | #ifdef DISKHARMONICMAP_EXPORTS 8 | #define DISKHARMONICMAP_API __declspec(dllexport) 9 | #else 10 | #define DISKHARMONICMAP_API __declspec(dllimport) 11 | #endif 12 | 13 | #include 14 | #include 15 | 16 | // This class is exported from the DiskHarmonicMap.dll 17 | class DISKHARMONICMAP_API DiskHarmonicMap { 18 | public: 19 | typedef Eigen::SparseMatrix SparseMatrix; 20 | typedef Eigen::Triplet Triplet; 21 | 22 | DiskHarmonicMap(); 23 | ~DiskHarmonicMap(); 24 | 25 | void AssignMesh(CMesh *mesh_); 26 | void Execute(); 27 | 28 | const Eigen::VectorXd & GetX1() { return x1; } 29 | const Eigen::VectorXd & GetX2() { return x2; } 30 | 31 | private: 32 | 33 | // create boundaries. Note that here only one of the boundaries will be used if there are multiple. 34 | bool ConstructBoundaryConditions(std::vector &boundVerts, std::vector &thetas); 35 | // construct boundary conditions 36 | void ConstructB(Eigen::VectorXd &b1, Eigen::VectorXd &b2, 37 | std::vector &boundVerts, std::vector &thetas); 38 | // calculate distortion 39 | void computeDistortion(Eigen::VectorXd &vt1, Eigen::VectorXd &vt2, double &angleDistortion, double &areaDistortion); 40 | 41 | private: 42 | CMesh *mesh; 43 | LBO *lbo; 44 | 45 | Eigen::VectorXd x1, x2; 46 | }; 47 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap/DiskHarmonicMap.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {68B8F0B5-3B3C-48DC-BAA4-2A57142FEFCF} 23 | Win32Proj 24 | DiskHarmonicMap 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | DynamicLibrary 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | Use 84 | Level3 85 | Disabled 86 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DISKHARMONICMAP_EXPORTS;%(PreprocessorDefinitions) 87 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 88 | 89 | 90 | Windows 91 | true 92 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);%(AdditionalLibraryDirectories) 93 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 94 | 95 | 96 | 97 | 98 | Use 99 | Level3 100 | Disabled 101 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DISKHARMONICMAP_EXPORTS;%(PreprocessorDefinitions) 102 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 103 | 104 | 105 | Windows 106 | true 107 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);%(AdditionalLibraryDirectories) 108 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 109 | 110 | 111 | 112 | 113 | Level3 114 | Use 115 | MaxSpeed 116 | true 117 | true 118 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DISKHARMONICMAP_EXPORTS;%(PreprocessorDefinitions) 119 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 120 | 121 | 122 | Windows 123 | true 124 | true 125 | true 126 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);%(AdditionalLibraryDirectories) 127 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 128 | 129 | 130 | 131 | 132 | Level3 133 | Use 134 | MaxSpeed 135 | true 136 | true 137 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DISKHARMONICMAP_EXPORTS;%(PreprocessorDefinitions) 138 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 139 | 140 | 141 | Windows 142 | true 143 | true 144 | true 145 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);%(AdditionalLibraryDirectories) 146 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | false 161 | false 162 | 163 | 164 | 165 | 166 | false 167 | false 168 | 169 | 170 | 171 | 172 | 173 | 174 | Create 175 | Create 176 | Create 177 | Create 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap/DiskHarmonicMap.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // DiskHarmonicMap.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/DiskHarmonicMap/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/test_main/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(int argc, char **argv) 7 | { 8 | if (argc < 2) 9 | { 10 | cout << "USAGE: [.exe] [in.obj]" << endl; 11 | return -1; 12 | } 13 | 14 | CMesh *mesh = new CMesh(); 15 | if (!mesh->Load(argv[1])) 16 | { 17 | cout << "Cannot load mesh " << argv[1] << endl; 18 | return -2; 19 | } 20 | 21 | string baseFileName = argv[1]; 22 | baseFileName = baseFileName.substr(0, baseFileName.length() - 4); 23 | 24 | DiskHarmonicMap harmonicMap; 25 | harmonicMap.AssignMesh(mesh); 26 | harmonicMap.Execute(); 27 | 28 | char outputModel[255]; 29 | sprintf(outputModel, "%s.harmonicmap.obj", baseFileName.c_str()); 30 | ofstream output(outputModel); 31 | output << "mtllib texture.mtl" << endl; 32 | output << "usemtl Textured" << endl; 33 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 34 | output << "v " << mesh->m_pVertex[i].m_vPosition << endl; 35 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 36 | output << "vt " << harmonicMap.GetX1()[i] << " " << harmonicMap.GetX2()[i] << endl; 37 | for (unsigned i = 0; i < mesh->m_nFace; ++i) 38 | output << "f " << mesh->m_pFace[i].m_piVertex[0] + 1 << "/" << mesh->m_pFace[i].m_piVertex[0] + 1 << " " 39 | << mesh->m_pFace[i].m_piVertex[1] + 1 << "/" << mesh->m_pFace[i].m_piVertex[1] + 1 << " " 40 | << mesh->m_pFace[i].m_piVertex[2] + 1 << "/" << mesh->m_pFace[i].m_piVertex[2] + 1 << endl; 41 | return 0; 42 | } -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/test_main/test_main.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {149EB194-73D3-4A17-8CB5-C244EA84AB57} 23 | Win32Proj 24 | test_main 25 | 26 | 27 | 28 | Application 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | Application 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | Application 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | 84 | 85 | Level3 86 | Disabled 87 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 88 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\DiskHarmonicMap;%(AdditionalIncludeDirectories) 89 | 90 | 91 | Console 92 | true 93 | Geometry.lib;Mesh.lib;LBO.lib;DiskHarmonicMap.lib;%(AdditionalDependencies) 94 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration);%(AdditionalLibraryDirectories) 95 | 96 | 97 | 98 | 99 | 100 | 101 | Level3 102 | Disabled 103 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 104 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\DiskHarmonicMap;%(AdditionalIncludeDirectories) 105 | 106 | 107 | Console 108 | true 109 | Geometry.lib;Mesh.lib;LBO.lib;DiskHarmonicMap.lib;%(AdditionalDependencies) 110 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);..\x64\$(Configuration);%(AdditionalLibraryDirectories) 111 | 112 | 113 | 114 | 115 | Level3 116 | 117 | 118 | MaxSpeed 119 | true 120 | true 121 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 122 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\DiskHarmonicMap;%(AdditionalIncludeDirectories) 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | Geometry.lib;Mesh.lib;LBO.lib;DiskHarmonicMap.lib;%(AdditionalDependencies) 130 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration);%(AdditionalLibraryDirectories) 131 | 132 | 133 | 134 | 135 | Level3 136 | 137 | 138 | MaxSpeed 139 | true 140 | true 141 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 142 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\DiskHarmonicMap;%(AdditionalIncludeDirectories) 143 | 144 | 145 | Console 146 | true 147 | true 148 | true 149 | Geometry.lib;Mesh.lib;LBO.lib;DiskHarmonicMap.lib;%(AdditionalDependencies) 150 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);..\x64\$(Configuration);%(AdditionalLibraryDirectories) 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /apps/DiskHarmonicMap/test_main/test_main.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HeatMethod", "HeatMethod\HeatMethod.vcxproj", "{38814500-8133-4649-8D1C-A1491DCCE36F}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_main", "test_main\test_main.vcxproj", "{3E9A5309-06BA-47DC-A691-5CF064E8505A}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {38814500-8133-4649-8D1C-A1491DCCE36F} = {38814500-8133-4649-8D1C-A1491DCCE36F} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {38814500-8133-4649-8D1C-A1491DCCE36F}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {38814500-8133-4649-8D1C-A1491DCCE36F}.Debug|Win32.Build.0 = Debug|Win32 23 | {38814500-8133-4649-8D1C-A1491DCCE36F}.Debug|x64.ActiveCfg = Debug|x64 24 | {38814500-8133-4649-8D1C-A1491DCCE36F}.Debug|x64.Build.0 = Debug|x64 25 | {38814500-8133-4649-8D1C-A1491DCCE36F}.Release|Win32.ActiveCfg = Release|Win32 26 | {38814500-8133-4649-8D1C-A1491DCCE36F}.Release|Win32.Build.0 = Release|Win32 27 | {38814500-8133-4649-8D1C-A1491DCCE36F}.Release|x64.ActiveCfg = Release|x64 28 | {38814500-8133-4649-8D1C-A1491DCCE36F}.Release|x64.Build.0 = Release|x64 29 | {3E9A5309-06BA-47DC-A691-5CF064E8505A}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {3E9A5309-06BA-47DC-A691-5CF064E8505A}.Debug|Win32.Build.0 = Debug|Win32 31 | {3E9A5309-06BA-47DC-A691-5CF064E8505A}.Debug|x64.ActiveCfg = Debug|x64 32 | {3E9A5309-06BA-47DC-A691-5CF064E8505A}.Debug|x64.Build.0 = Debug|x64 33 | {3E9A5309-06BA-47DC-A691-5CF064E8505A}.Release|Win32.ActiveCfg = Release|Win32 34 | {3E9A5309-06BA-47DC-A691-5CF064E8505A}.Release|Win32.Build.0 = Release|Win32 35 | {3E9A5309-06BA-47DC-A691-5CF064E8505A}.Release|x64.ActiveCfg = Release|x64 36 | {3E9A5309-06BA-47DC-A691-5CF064E8505A}.Release|x64.Build.0 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/HeatMethod.cpp: -------------------------------------------------------------------------------- 1 | // HeatMethod.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "HeatMethod.h" 6 | #include 7 | 8 | using namespace std; 9 | 10 | // This is the constructor of a class that has been exported. 11 | // see HeatMethod.h for the class definition 12 | HEATMETHOD_API HeatMethod::HeatMethod() 13 | { 14 | lbo = NULL; 15 | outputInfo = true; 16 | return; 17 | } 18 | 19 | HEATMETHOD_API HeatMethod::~HeatMethod() 20 | { 21 | if (lbo) delete lbo; 22 | } 23 | 24 | HEATMETHOD_API void HeatMethod::SetOutputInfo(bool outputInfo_) 25 | { 26 | outputInfo = outputInfo_; 27 | } 28 | 29 | HEATMETHOD_API void HeatMethod::AssignMesh(CMesh *mesh_) 30 | { 31 | mesh = mesh_; 32 | lbo = new LBO(); 33 | lbo->AssignMesh(mesh_); 34 | X.resize(mesh->m_nFace); 35 | GX.resize(mesh->m_nVertex); 36 | delta.resize(mesh->m_nVertex); 37 | } 38 | 39 | HEATMETHOD_API void HeatMethod::AssignStep(double step_) 40 | { 41 | step = step_; 42 | } 43 | 44 | HEATMETHOD_API void HeatMethod::PreFactor() 45 | { 46 | double h = CalcMeanEdgeLen(); 47 | double t = step * h*h; 48 | 49 | lbo->Construct(); 50 | 51 | clock_t start = clock(); 52 | chol1.compute(lbo->AMatrix() - t * lbo->LMatrix()); 53 | clock_t end = clock(); 54 | if (outputInfo) 55 | cout << "Cholesky Decomposition Time: " << (double)(end - start) / (double)CLOCKS_PER_SEC << endl; 56 | 57 | start = clock(); 58 | chol2.compute(lbo->LMatrix()); 59 | end = clock(); 60 | if (outputInfo) 61 | cout << "Cholesky Decomposition Time: " << (double)(end - start) / (double)CLOCKS_PER_SEC << endl; 62 | } 63 | 64 | HEATMETHOD_API void HeatMethod::AssignSources(const std::list &sources_) 65 | { 66 | sources = sources_; 67 | ConstructDelta(delta); 68 | } 69 | 70 | HEATMETHOD_API void HeatMethod::BuildDistanceField() 71 | { 72 | clock_t start = clock(); 73 | Eigen::VectorXd u = chol1.solve(delta); 74 | clock_t end = clock(); 75 | if (outputInfo) 76 | cout << "Solving Time: " << (double)(end - start) / (double)CLOCKS_PER_SEC << endl; 77 | 78 | //Calculate X 79 | for (unsigned i = 0; i < mesh->m_nFace; ++i) 80 | { 81 | X[i] = Vector3D(0, 0, 0); 82 | for (unsigned j = 0; j < 3; ++j) 83 | { 84 | unsigned ei = mesh->m_pFace[i].m_piEdge[j]; 85 | unsigned vi = mesh->m_pEdge[mesh->m_pEdge[ei].m_iNextEdge].m_iVertex[1]; 86 | Vector3D eveci = mesh->m_pVertex[mesh->m_pEdge[ei].m_iVertex[1]].m_vPosition - mesh->m_pVertex[mesh->m_pEdge[ei].m_iVertex[0]].m_vPosition; 87 | X[i] += u[vi] * (mesh->m_pFace[i].m_vNormal ^ eveci); 88 | } 89 | X[i] /= 2 * mesh->m_pFace[i].m_dArea; 90 | X[i].normalizeStrict(); X[i] *= -1; 91 | } 92 | 93 | //Calculate Gradiant*X 94 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 95 | { 96 | GX[i] = 0.0; 97 | for (unsigned j = 0; j < mesh->m_pVertex[i].m_nValence; ++j) 98 | { 99 | unsigned curFace = mesh->m_pEdge[mesh->m_pVertex[i].m_piEdge[j]].m_iFace; 100 | 101 | unsigned v[3], ei[3]; 102 | for (int k = 0; k < 3; ++k) 103 | { 104 | if (mesh->m_pFace[curFace].m_piVertex[k] == i) 105 | { 106 | v[0] = i; v[1] = mesh->m_pFace[curFace].m_piVertex[(k + 1) % 3]; 107 | v[2] = mesh->m_pFace[curFace].m_piVertex[(k + 2) % 3]; 108 | ei[0] = mesh->m_pFace[curFace].m_piEdge[k]; 109 | ei[1] = mesh->m_pFace[curFace].m_piEdge[(k + 1) % 3]; 110 | ei[2] = mesh->m_pFace[curFace].m_piEdge[(k + 2) % 3]; 111 | break; 112 | } 113 | } 114 | Vector3D e1 = mesh->m_pVertex[v[1]].m_vPosition - mesh->m_pVertex[v[0]].m_vPosition; 115 | Vector3D e2 = mesh->m_pVertex[v[2]].m_vPosition - mesh->m_pVertex[v[0]].m_vPosition; 116 | Vector3D e3 = mesh->m_pVertex[v[2]].m_vPosition - mesh->m_pVertex[v[1]].m_vPosition; 117 | 118 | double l1 = mesh->m_pEdge[ei[0]].m_length; 119 | double l2 = mesh->m_pEdge[ei[2]].m_length; 120 | double l3 = mesh->m_pEdge[ei[1]].m_length; 121 | 122 | /*double l1 = e1.length(), l2 = e2.length(), l3 = e3.length();*/ 123 | 124 | double cos2 = (l1*l1 + l3*l3 - l2*l2) / (2 * l1*l3); 125 | double cos1 = (l2*l2 + l3*l3 - l1*l1) / (2 * l2*l3); 126 | 127 | double cot1 = cos1 >= 1.0 ? 0.0 : cos1 / sqrt(1 - cos1*cos1); 128 | double cot2 = cos2 >= 1.0 ? 0.0 : cos2 / sqrt(1 - cos2*cos2); 129 | 130 | GX[i] += cot1*(X[curFace] * e1) + cot2*(X[curFace] * e2); 131 | } 132 | GX[i] /= 2.0; 133 | } 134 | 135 | start = clock(); 136 | phi = chol2.solve(GX); 137 | end = clock(); 138 | if (outputInfo) 139 | cout << "Solving Time: " << (double)(end - start) / (double)CLOCKS_PER_SEC << endl; 140 | 141 | double srcDist = phi[sources.front()]; 142 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 143 | phi[i] -= srcDist; 144 | } 145 | 146 | HEATMETHOD_API const Eigen::VectorXd& HeatMethod::GetDistances() 147 | { 148 | return phi; 149 | } 150 | 151 | HEATMETHOD_API double HeatMethod::CalcMeanEdgeLen() 152 | { 153 | double avgEdgeLen = 0; 154 | unsigned edgeCnt = 0; 155 | for (unsigned i = 0; i < mesh->m_nEdge; ++i) 156 | if (i < mesh->m_pEdge[i].m_iTwinEdge) { avgEdgeLen += mesh->m_pEdge[i].m_length; ++edgeCnt; } 157 | return avgEdgeLen / edgeCnt; 158 | } 159 | 160 | HEATMETHOD_API void HeatMethod::ConstructDelta(Eigen::VectorXd &delta) 161 | { 162 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 163 | delta[i] = 0.0; 164 | for (list::iterator iter = sources.begin(); iter != sources.end(); ++iter) 165 | delta[*iter] = 1.0; 166 | } -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/HeatMethod.h: -------------------------------------------------------------------------------- 1 | // The following ifdef block is the standard way of creating macros which make exporting 2 | // from a DLL simpler. All files within this DLL are compiled with the HEATMETHOD_EXPORTS 3 | // symbol defined on the command line. This symbol should not be defined on any project 4 | // that uses this DLL. This way any other project whose source files include this file see 5 | // HEATMETHOD_API functions as being imported from a DLL, whereas this DLL sees symbols 6 | // defined with this macro as being exported. 7 | #ifdef HEATMETHOD_EXPORTS 8 | #define HEATMETHOD_API __declspec(dllexport) 9 | #else 10 | #define HEATMETHOD_API __declspec(dllimport) 11 | #endif 12 | 13 | #include 14 | #include 15 | 16 | // This class is exported from the HeatMethod.dll 17 | class HEATMETHOD_API HeatMethod { 18 | public: 19 | typedef Eigen::SparseMatrix SparseMatrix; 20 | 21 | HeatMethod(); 22 | ~HeatMethod(); 23 | 24 | void SetOutputInfo(bool outputInfo_); 25 | void AssignMesh(CMesh *mesh_); 26 | void AssignStep(double step_); 27 | void PreFactor(); 28 | void AssignSources(const std::list &sources_); 29 | void BuildDistanceField(); 30 | const Eigen::VectorXd & GetDistances(); 31 | 32 | private: 33 | double CalcMeanEdgeLen(); 34 | void ConstructDelta(Eigen::VectorXd &delta); 35 | 36 | private: 37 | CMesh *mesh; 38 | double step; 39 | LBO *lbo; 40 | Eigen::VectorXd phi; 41 | 42 | Eigen::SimplicialCholesky chol1, chol2; 43 | std::list sources; 44 | 45 | std::vector X; 46 | Eigen::VectorXd GX; 47 | Eigen::VectorXd delta; 48 | 49 | bool outputInfo; 50 | }; 51 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/HeatMethod.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {38814500-8133-4649-8D1C-A1491DCCE36F} 23 | Win32Proj 24 | HeatMethod 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | DynamicLibrary 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | Use 84 | Level3 85 | Disabled 86 | WIN32;_DEBUG;_WINDOWS;_USRDLL;HEATMETHOD_EXPORTS;%(PreprocessorDefinitions) 87 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 88 | 89 | 90 | Windows 91 | true 92 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);%(AdditionalLibraryDirectories) 93 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 94 | 95 | 96 | 97 | 98 | Use 99 | Level3 100 | Disabled 101 | WIN32;_DEBUG;_WINDOWS;_USRDLL;HEATMETHOD_EXPORTS;%(PreprocessorDefinitions) 102 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 103 | 104 | 105 | Windows 106 | true 107 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);%(AdditionalLibraryDirectories) 108 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 109 | 110 | 111 | 112 | 113 | Level3 114 | Use 115 | MaxSpeed 116 | true 117 | true 118 | WIN32;NDEBUG;_WINDOWS;_USRDLL;HEATMETHOD_EXPORTS;%(PreprocessorDefinitions) 119 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 120 | 121 | 122 | Windows 123 | true 124 | true 125 | true 126 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);%(AdditionalLibraryDirectories) 127 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 128 | 129 | 130 | 131 | 132 | Level3 133 | Use 134 | MaxSpeed 135 | true 136 | true 137 | WIN32;NDEBUG;_WINDOWS;_USRDLL;HEATMETHOD_EXPORTS;%(PreprocessorDefinitions) 138 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 139 | 140 | 141 | Windows 142 | true 143 | true 144 | true 145 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);%(AdditionalLibraryDirectories) 146 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | false 160 | false 161 | 162 | 163 | 164 | 165 | false 166 | false 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | Create 175 | Create 176 | Create 177 | Create 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/HeatMethod.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/HeatMethod.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // HeatMethod.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /apps/HeatMethod/HeatMethod/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /apps/HeatMethod/test_main/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main(int argc, char **argv) 8 | { 9 | if (argc < 4) 10 | { 11 | cout << "USAGE: [.exe] [in.obj] [srcFile] [step]" << endl; 12 | cout << "EXAMPLE: test_main.exe bunny.obj bunny.sources.txt 1.0" << endl; 13 | return -1; 14 | } 15 | CMesh *mesh = new CMesh(); 16 | if (!mesh->Load(argv[1])) 17 | { 18 | cout << "Cannot load mesh " << argv[1] << endl; 19 | return -2; 20 | } 21 | 22 | vector< list > sourcesSet; 23 | // load source 24 | ifstream input(argv[2]); 25 | stringstream sin; 26 | string curLine; 27 | while (getline(input, curLine)) 28 | { 29 | list curSetOfSource; 30 | sin.clear(); 31 | sin << curLine; 32 | unsigned curSrc; 33 | while (sin >> curSrc) 34 | curSetOfSource.push_back(curSrc); 35 | sourcesSet.push_back(curSetOfSource); 36 | } 37 | input.close(); 38 | 39 | double step = atof(argv[3]); 40 | string baseFileName = argv[1]; 41 | baseFileName = baseFileName.substr(0, baseFileName.length() - 4); 42 | 43 | HeatMethod heatMethod; 44 | heatMethod.AssignMesh(mesh); 45 | heatMethod.AssignStep(step); 46 | heatMethod.SetOutputInfo(true); 47 | heatMethod.PreFactor(); 48 | 49 | for (int i = 0; i < sourcesSet.size(); ++i) 50 | { 51 | cout << "Computing Source Set " << i << "......" << endl; 52 | 53 | heatMethod.AssignSources(sourcesSet[i]); 54 | heatMethod.BuildDistanceField(); 55 | 56 | const Eigen::VectorXd &dist = heatMethod.GetDistances(); 57 | double maxDist = *max_element(&dist[0], &dist[dist.size()-1]); 58 | 59 | //output 60 | char outputMeshName[255]; 61 | sprintf_s(outputMeshName, "%s_src%d.obj", baseFileName.c_str(), i); 62 | ofstream output(outputMeshName); 63 | output << "mtllib texture.mtl" << endl; 64 | output << "usemtl Textured" << endl; 65 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 66 | output << "v " << mesh->m_pVertex[i].m_vPosition << endl; 67 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 68 | output << "vt " << dist[i]/maxDist << " " << dist[i]/maxDist << endl; 69 | for (unsigned i = 0; i < mesh->m_nFace; ++i) 70 | output << "f " << mesh->m_pFace[i].m_piVertex[0] + 1 << "/" << mesh->m_pFace[i].m_piVertex[0] + 1 << " " 71 | << mesh->m_pFace[i].m_piVertex[1] + 1 << "/" << mesh->m_pFace[i].m_piVertex[1] + 1 << " " 72 | << mesh->m_pFace[i].m_piVertex[2] + 1 << "/" << mesh->m_pFace[i].m_piVertex[2] + 1 << endl; 73 | output.close(); 74 | } 75 | 76 | delete mesh; 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /apps/HeatMethod/test_main/test_main.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {3E9A5309-06BA-47DC-A691-5CF064E8505A} 23 | Win32Proj 24 | test_main 25 | 26 | 27 | 28 | Application 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | Application 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | Application 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | 84 | 85 | Level3 86 | Disabled 87 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 88 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\HeatMethod;%(AdditionalIncludeDirectories) 89 | 90 | 91 | Console 92 | true 93 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration);%(AdditionalLibraryDirectories) 94 | Geometry.lib;Mesh.lib;LBO.lib;HeatMethod.lib;%(AdditionalDependencies) 95 | 96 | 97 | 98 | 99 | 100 | 101 | Level3 102 | Disabled 103 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 104 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\HeatMethod;%(AdditionalIncludeDirectories) 105 | 106 | 107 | Console 108 | true 109 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);..\x64\$(Configuration);%(AdditionalLibraryDirectories) 110 | Geometry.lib;Mesh.lib;LBO.lib;HeatMethod.lib;%(AdditionalDependencies) 111 | 112 | 113 | 114 | 115 | Level3 116 | 117 | 118 | MaxSpeed 119 | true 120 | true 121 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 122 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\HeatMethod;%(AdditionalIncludeDirectories) 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration);%(AdditionalLibraryDirectories) 130 | Geometry.lib;Mesh.lib;LBO.lib;HeatMethod.lib;%(AdditionalDependencies) 131 | 132 | 133 | 134 | 135 | Level3 136 | 137 | 138 | MaxSpeed 139 | true 140 | true 141 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 142 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\HeatMethod;%(AdditionalIncludeDirectories) 143 | 144 | 145 | Console 146 | true 147 | true 148 | true 149 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);..\x64\$(Configuration);%(AdditionalLibraryDirectories) 150 | Geometry.lib;Mesh.lib;LBO.lib;HeatMethod.lib;%(AdditionalDependencies) 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /apps/HeatMethod/test_main/test_main.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /apps/HeatMethod/test_main/test_main.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | bunny.obj bunny.sources.txt 1.0 5 | WindowsLocalDebugger 6 | Path=$(Path);..\..\..\GeometryAndMesh\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration) 7 | $(LocalDebuggerEnvironment) 8 | 9 | 10 | bunny.obj bunny.sources.txt 1.0 11 | WindowsLocalDebugger 12 | Path=$(Path);..\..\..\GeometryAndMesh\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration) 13 | $(LocalDebuggerEnvironment) 14 | 15 | 16 | bunny.obj bunny.sources.txt 1.0 17 | WindowsLocalDebugger 18 | Path=$(Path);..\..\..\GeometryAndMesh\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration) 19 | $(LocalDebuggerEnvironment) 20 | 21 | 22 | bunny.obj bunny.sources.txt 1.0 23 | WindowsLocalDebugger 24 | Path=$(Path);..\..\..\GeometryAndMesh\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration) 25 | $(LocalDebuggerEnvironment) 26 | 27 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MeanCurvature", "MeanCurvature\MeanCurvature.vcxproj", "{E1D1AB6C-B743-485B-9DB3-EE5993E831CA}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_main", "test_main\test_main.vcxproj", "{88E8ECA3-5681-4510-9E34-5E7FD17323D8}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA} = {E1D1AB6C-B743-485B-9DB3-EE5993E831CA} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA}.Debug|Win32.Build.0 = Debug|Win32 23 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA}.Debug|x64.ActiveCfg = Debug|x64 24 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA}.Debug|x64.Build.0 = Debug|x64 25 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA}.Release|Win32.ActiveCfg = Release|Win32 26 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA}.Release|Win32.Build.0 = Release|Win32 27 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA}.Release|x64.ActiveCfg = Release|x64 28 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA}.Release|x64.Build.0 = Release|x64 29 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8}.Debug|Win32.Build.0 = Debug|Win32 31 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8}.Debug|x64.ActiveCfg = Debug|x64 32 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8}.Debug|x64.Build.0 = Debug|x64 33 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8}.Release|Win32.ActiveCfg = Release|Win32 34 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8}.Release|Win32.Build.0 = Release|Win32 35 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8}.Release|x64.ActiveCfg = Release|x64 36 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8}.Release|x64.Build.0 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature/MeanCurvature.cpp: -------------------------------------------------------------------------------- 1 | // MeanCurvature.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "MeanCurvature.h" 6 | 7 | // This is the constructor of a class that has been exported. 8 | // see MeanCurvature.h for the class definition 9 | MeanCurvature::MeanCurvature() 10 | { 11 | lbo = NULL; 12 | } 13 | 14 | MeanCurvature::~MeanCurvature() 15 | { 16 | if (lbo) delete lbo; 17 | } 18 | 19 | void MeanCurvature::AssignMesh(CMesh *mesh_) 20 | { 21 | mesh = mesh_; 22 | lbo = new LBO(); 23 | lbo->AssignMesh(mesh); 24 | meanCurvatureVecs.resize(mesh->m_nVertex); 25 | } 26 | 27 | void MeanCurvature::Execute() 28 | { 29 | lbo->Construct(); 30 | Eigen::VectorXd x(mesh->m_nVertex); 31 | 32 | for (int i = 0; i < 3; ++i) 33 | { 34 | for (int j = 0; j < mesh->m_nVertex; ++j) 35 | x[j] = mesh->m_pVertex[j].m_vPosition[i]; 36 | x = -(lbo->LMatrix() * x); 37 | for (int j = 0; j < mesh->m_nVertex; ++j) 38 | meanCurvatureVecs[j][i] = x[j]; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature/MeanCurvature.h: -------------------------------------------------------------------------------- 1 | // The following ifdef block is the standard way of creating macros which make exporting 2 | // from a DLL simpler. All files within this DLL are compiled with the MEANCURVATURE_EXPORTS 3 | // symbol defined on the command line. This symbol should not be defined on any project 4 | // that uses this DLL. This way any other project whose source files include this file see 5 | // MEANCURVATURE_API functions as being imported from a DLL, whereas this DLL sees symbols 6 | // defined with this macro as being exported. 7 | #ifdef MEANCURVATURE_EXPORTS 8 | #define MEANCURVATURE_API __declspec(dllexport) 9 | #else 10 | #define MEANCURVATURE_API __declspec(dllimport) 11 | #endif 12 | 13 | #include 14 | #include 15 | 16 | // This class is exported from the MeanCurvature.dll 17 | class MEANCURVATURE_API MeanCurvature { 18 | public: 19 | typedef Eigen::SparseMatrix SparseMatrix; 20 | 21 | MeanCurvature(); 22 | ~MeanCurvature(); 23 | 24 | void AssignMesh(CMesh *mesh_); 25 | void Execute(); 26 | 27 | const std::vector& GetMeanCurvature() { return meanCurvatureVecs; } 28 | 29 | private: 30 | CMesh *mesh; 31 | LBO *lbo; 32 | std::vector meanCurvatureVecs; 33 | }; 34 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature/MeanCurvature.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {E1D1AB6C-B743-485B-9DB3-EE5993E831CA} 23 | Win32Proj 24 | MeanCurvature 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | DynamicLibrary 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | Use 84 | Level3 85 | Disabled 86 | WIN32;_DEBUG;_WINDOWS;_USRDLL;MEANCURVATURE_EXPORTS;%(PreprocessorDefinitions) 87 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 88 | 89 | 90 | Windows 91 | true 92 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 93 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);%(AdditionalLibraryDirectories) 94 | 95 | 96 | 97 | 98 | Use 99 | Level3 100 | Disabled 101 | WIN32;_DEBUG;_WINDOWS;_USRDLL;MEANCURVATURE_EXPORTS;%(PreprocessorDefinitions) 102 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 103 | 104 | 105 | Windows 106 | true 107 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 108 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);%(AdditionalLibraryDirectories) 109 | 110 | 111 | 112 | 113 | Level3 114 | Use 115 | MaxSpeed 116 | true 117 | true 118 | WIN32;NDEBUG;_WINDOWS;_USRDLL;MEANCURVATURE_EXPORTS;%(PreprocessorDefinitions) 119 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 120 | 121 | 122 | Windows 123 | true 124 | true 125 | true 126 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 127 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);%(AdditionalLibraryDirectories) 128 | 129 | 130 | 131 | 132 | Level3 133 | Use 134 | MaxSpeed 135 | true 136 | true 137 | WIN32;NDEBUG;_WINDOWS;_USRDLL;MEANCURVATURE_EXPORTS;%(PreprocessorDefinitions) 138 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;%(AdditionalIncludeDirectories) 139 | 140 | 141 | Windows 142 | true 143 | true 144 | true 145 | Geometry.lib;Mesh.lib;LBO.lib;%(AdditionalDependencies) 146 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);%(AdditionalLibraryDirectories) 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | false 160 | false 161 | 162 | 163 | 164 | 165 | false 166 | false 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | Create 175 | Create 176 | Create 177 | Create 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature/MeanCurvature.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MeanCurvature.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /apps/MeanCurvature/MeanCurvature/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /apps/MeanCurvature/test_main/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(int argc, char **argv) 7 | { 8 | if (argc < 2) 9 | { 10 | cout << "USAGE: [.exe] [in.obj]" << endl; 11 | return -1; 12 | } 13 | 14 | CMesh *mesh = new CMesh(); 15 | if (!mesh->Load(argv[1])) 16 | { 17 | cout << "Cannot load mesh " << argv[1] << endl; 18 | return -2; 19 | } 20 | 21 | string baseFileName = argv[1]; 22 | baseFileName = baseFileName.substr(0, baseFileName.length() - 4); 23 | 24 | MeanCurvature meanCurvature; 25 | meanCurvature.AssignMesh(mesh); 26 | meanCurvature.Execute(); 27 | 28 | double maxMeanCurvature = 0.0; 29 | for (int i = 0; i < mesh->m_nVertex; ++i) 30 | maxMeanCurvature = __max(maxMeanCurvature, meanCurvature.GetMeanCurvature()[i].length()); 31 | 32 | char outputModel[255]; 33 | sprintf_s(outputModel, "%s.curvature.obj", baseFileName.c_str()); 34 | ofstream output(outputModel); 35 | output << "mtllib texture.mtl" << endl; 36 | output << "usemtl Textured" << endl; 37 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 38 | output << "v " << mesh->m_pVertex[i].m_vPosition << endl; 39 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 40 | output << "vt " << meanCurvature.GetMeanCurvature()[i].length() / maxMeanCurvature << " " 41 | << meanCurvature.GetMeanCurvature()[i].length() / maxMeanCurvature << endl; 42 | for (unsigned i = 0; i < mesh->m_nFace; ++i) 43 | output << "f " << mesh->m_pFace[i].m_piVertex[0] + 1 << "/" << mesh->m_pFace[i].m_piVertex[0] + 1 << " " 44 | << mesh->m_pFace[i].m_piVertex[1] + 1 << "/" << mesh->m_pFace[i].m_piVertex[1] + 1 << " " 45 | << mesh->m_pFace[i].m_piVertex[2] + 1 << "/" << mesh->m_pFace[i].m_piVertex[2] + 1 << endl; 46 | output.close(); 47 | 48 | sprintf_s(outputModel, "%s.curvature", baseFileName.c_str()); 49 | output.open(outputModel); 50 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 51 | output << meanCurvature.GetMeanCurvature()[i] << " " << meanCurvature.GetMeanCurvature()[i].length() << endl; 52 | output.close(); 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /apps/MeanCurvature/test_main/test_main.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {88E8ECA3-5681-4510-9E34-5E7FD17323D8} 23 | Win32Proj 24 | test_main 25 | 26 | 27 | 28 | Application 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | Application 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | Application 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | 84 | 85 | Level3 86 | Disabled 87 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 88 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\MeanCurvature;%(AdditionalIncludeDirectories) 89 | 90 | 91 | Console 92 | true 93 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration);%(AdditionalLibraryDirectories) 94 | Geometry.lib;Mesh.lib;LBO.lib;MeanCurvature.lib;%(AdditionalDependencies) 95 | 96 | 97 | 98 | 99 | 100 | 101 | Level3 102 | Disabled 103 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 104 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\MeanCurvature;%(AdditionalIncludeDirectories) 105 | 106 | 107 | Console 108 | true 109 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);..\x64\$(Configuration);%(AdditionalLibraryDirectories) 110 | Geometry.lib;Mesh.lib;LBO.lib;MeanCurvature.lib;%(AdditionalDependencies) 111 | 112 | 113 | 114 | 115 | Level3 116 | 117 | 118 | MaxSpeed 119 | true 120 | true 121 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 122 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\MeanCurvature;%(AdditionalIncludeDirectories) 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration);%(AdditionalLibraryDirectories) 130 | Geometry.lib;Mesh.lib;LBO.lib;MeanCurvature.lib;%(AdditionalDependencies) 131 | 132 | 133 | 134 | 135 | Level3 136 | 137 | 138 | MaxSpeed 139 | true 140 | true 141 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 142 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\MeanCurvature;%(AdditionalIncludeDirectories) 143 | 144 | 145 | Console 146 | true 147 | true 148 | true 149 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);..\x64\$(Configuration);%(AdditionalLibraryDirectories) 150 | Geometry.lib;Mesh.lib;LBO.lib;MeanCurvature.lib;%(AdditionalDependencies) 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /apps/MeanCurvature/test_main/test_main.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/SphericalHarmonicMap.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SphericalHarmonicMap", "SphericalHarmonicMap\SphericalHarmonicMap.vcxproj", "{44DA983F-9405-467B-818B-BB019F221E8D}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_main", "test_main\test_main.vcxproj", "{BCDAC051-73CB-4268-ABA1-43E99C3A921B}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {44DA983F-9405-467B-818B-BB019F221E8D} = {44DA983F-9405-467B-818B-BB019F221E8D} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {44DA983F-9405-467B-818B-BB019F221E8D}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {44DA983F-9405-467B-818B-BB019F221E8D}.Debug|Win32.Build.0 = Debug|Win32 23 | {44DA983F-9405-467B-818B-BB019F221E8D}.Debug|x64.ActiveCfg = Debug|x64 24 | {44DA983F-9405-467B-818B-BB019F221E8D}.Debug|x64.Build.0 = Debug|x64 25 | {44DA983F-9405-467B-818B-BB019F221E8D}.Release|Win32.ActiveCfg = Release|Win32 26 | {44DA983F-9405-467B-818B-BB019F221E8D}.Release|Win32.Build.0 = Release|Win32 27 | {44DA983F-9405-467B-818B-BB019F221E8D}.Release|x64.ActiveCfg = Release|x64 28 | {44DA983F-9405-467B-818B-BB019F221E8D}.Release|x64.Build.0 = Release|x64 29 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B}.Debug|Win32.Build.0 = Debug|Win32 31 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B}.Debug|x64.ActiveCfg = Debug|x64 32 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B}.Debug|x64.Build.0 = Debug|x64 33 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B}.Release|Win32.ActiveCfg = Release|Win32 34 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B}.Release|Win32.Build.0 = Release|Win32 35 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B}.Release|x64.ActiveCfg = Release|x64 36 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B}.Release|x64.Build.0 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/SphericalHarmonicMap/SphericalHarmonicMap.cpp: -------------------------------------------------------------------------------- 1 | // SphericalHarmonicMap.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "SphericalHarmonicMap.h" 6 | #include 7 | 8 | using namespace std; 9 | 10 | // This is the constructor of a class that has been exported. 11 | // see SphericalHarmonicMap.h for the class definition 12 | SphericalHarmonicMap::SphericalHarmonicMap() 13 | { 14 | lbo = NULL; 15 | mesh = NULL; 16 | } 17 | 18 | SphericalHarmonicMap::~SphericalHarmonicMap() 19 | { 20 | if (lbo) delete lbo; 21 | } 22 | 23 | void SphericalHarmonicMap::AssignMesh(CMesh *mesh_) 24 | { 25 | mesh = mesh_; 26 | lbo = new LBO(); 27 | lbo->AssignMesh(mesh); 28 | normals.resize(mesh->m_nVertex, 3); 29 | } 30 | 31 | void SphericalHarmonicMap::Execute() 32 | { 33 | lbo->Construct(); 34 | 35 | bool hasRawNormal = mesh->m_pVertex[0].m_vRawNormal.length() != 0.0; 36 | if (hasRawNormal) 37 | { 38 | for (int i = 0; i < mesh->m_nVertex; ++i) 39 | { 40 | for (int j = 0; j < 3; ++j) 41 | normals(i, j) = mesh->m_pVertex[i].m_vRawNormal[j]; 42 | } 43 | } 44 | else 45 | { 46 | for (int i = 0; i < mesh->m_nVertex; ++i) 47 | { 48 | for (int j = 0; j < 3; ++j) 49 | normals(i, j) = mesh->m_pVertex[i].m_vNormal[j]; 50 | } 51 | } 52 | 53 | Eigen::Matrix newNormals; 54 | double curEnergy = CalcEnergy(), prevEnergy = 0.0; 55 | unsigned iteration = 0; 56 | double curEnergyVar = 0.0; 57 | 58 | do 59 | { 60 | prevEnergy = curEnergy; 61 | 62 | newNormals = -lbo->LMatrix() * normals; 63 | for (int i = 0; i < normals.rows(); ++i) 64 | { 65 | normals.row(i) = normals.row(i) - (newNormals.row(i) - newNormals.row(i).dot(normals.row(i)) * normals.row(i)) * step; 66 | normals.row(i).normalize(); 67 | } 68 | 69 | curEnergy = CalcEnergy(); 70 | curEnergyVar = fabs(curEnergy - prevEnergy) / fabs(prevEnergy); 71 | printf("iteration %d, energy: %f, energy var: %f\n", iteration++, curEnergy, curEnergyVar); 72 | } while (iteration < iterLimit && curEnergyVar > energyVar); 73 | 74 | } 75 | 76 | double SphericalHarmonicMap::CalcEnergy() 77 | { 78 | double energy = 0.0; 79 | for (unsigned i = 0; i < mesh->m_nEdge; ++i) 80 | { 81 | if (i > mesh->m_pEdge[i].m_iTwinEdge) continue; 82 | unsigned v0 = mesh->m_pEdge[i].m_iVertex[0]; 83 | unsigned v1 = mesh->m_pEdge[i].m_iVertex[1]; 84 | 85 | double w = lbo->LMatrix().coeff(v0, v1); 86 | energy += -lbo->LMatrix().coeff(v0, v1) * 87 | (normals.row(v0) - normals.row(v1)).dot(normals.row(v0) - normals.row(v1)); 88 | } 89 | return energy; 90 | } -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/SphericalHarmonicMap/SphericalHarmonicMap.h: -------------------------------------------------------------------------------- 1 | // The following ifdef block is the standard way of creating macros which make exporting 2 | // from a DLL simpler. All files within this DLL are compiled with the SPHERICALHARMONICMAP_EXPORTS 3 | // symbol defined on the command line. This symbol should not be defined on any project 4 | // that uses this DLL. This way any other project whose source files include this file see 5 | // SPHERICALHARMONICMAP_API functions as being imported from a DLL, whereas this DLL sees symbols 6 | // defined with this macro as being exported. 7 | #ifdef SPHERICALHARMONICMAP_EXPORTS 8 | #define SPHERICALHARMONICMAP_API __declspec(dllexport) 9 | #else 10 | #define SPHERICALHARMONICMAP_API __declspec(dllimport) 11 | #endif 12 | 13 | #include 14 | #include 15 | 16 | // This class is exported from the SphericalHarmonicMap.dll 17 | class SPHERICALHARMONICMAP_API SphericalHarmonicMap { 18 | public: 19 | typedef Eigen::SparseMatrix SparseMatrix; 20 | 21 | SphericalHarmonicMap(); 22 | ~SphericalHarmonicMap(); 23 | 24 | void AssignMesh(CMesh *mesh_); 25 | void SetRelativeEnergyVar(double energyVar_) { energyVar = energyVar_; } 26 | void SetIterationLimit(int iterLimit_) { iterLimit = iterLimit_; } 27 | void SetStep(double step_) { step = step_; } 28 | 29 | void Execute(); 30 | 31 | const Eigen::Matrix& GetNormals() { return normals; } 32 | 33 | private: 34 | double CalcEnergy(); 35 | 36 | private: 37 | 38 | CMesh *mesh; 39 | LBO *lbo; 40 | 41 | double energyVar; 42 | int iterLimit; 43 | double step; 44 | 45 | Eigen::Matrix normals; 46 | }; 47 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/SphericalHarmonicMap/SphericalHarmonicMap.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/SphericalHarmonicMap/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/SphericalHarmonicMap/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SphericalHarmonicMap.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/SphericalHarmonicMap/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/SphericalHarmonicMap/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/test_main/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(int argc, char **argv) 7 | { 8 | if (argc < 5) 9 | { 10 | cout << "USAGE: [.exe] [in.obj] [step] [energyVar] [iterLimit]" << endl; 11 | return -1; 12 | } 13 | 14 | CMesh *mesh = new CMesh(); 15 | if (!mesh->Load(argv[1])) 16 | { 17 | cout << "Cannot load mesh " << argv[1] << endl; 18 | return -2; 19 | } 20 | 21 | string baseFileName = argv[1]; 22 | baseFileName = baseFileName.substr(0, baseFileName.length() - 4); 23 | 24 | SphericalHarmonicMap harmonicMap; 25 | harmonicMap.AssignMesh(mesh); 26 | harmonicMap.SetStep(atof(argv[2])); 27 | harmonicMap.SetRelativeEnergyVar(atof(argv[3])); 28 | harmonicMap.SetIterationLimit(atoi(argv[4])); 29 | harmonicMap.Execute(); 30 | 31 | char outputModel[255]; 32 | sprintf(outputModel, "%s.sphereharmonic.obj", baseFileName.c_str()); 33 | ofstream output(outputModel); 34 | output << "mtllib texture.mtl" << endl; 35 | output << "usemtl Textured" << endl; 36 | for (unsigned i = 0; i < mesh->m_nVertex; ++i) 37 | output << "v " << harmonicMap.GetNormals()(i, 0) << " " 38 | << harmonicMap.GetNormals()(i, 1) << " " 39 | << harmonicMap.GetNormals()(i, 2) << endl; 40 | for (unsigned i = 0; i < mesh->m_nFace; ++i) 41 | output << "f " << mesh->m_pFace[i].m_piVertex[0] + 1 << " " 42 | << mesh->m_pFace[i].m_piVertex[1] + 1 << " " 43 | << mesh->m_pFace[i].m_piVertex[2] + 1 << endl; 44 | return 0; 45 | } -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/test_main/test_main.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {BCDAC051-73CB-4268-ABA1-43E99C3A921B} 23 | Win32Proj 24 | test_main 25 | 26 | 27 | 28 | Application 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | Application 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | Application 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | 84 | 85 | Level3 86 | Disabled 87 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 88 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\SphericalHarmonicMap;%(AdditionalIncludeDirectories) 89 | 90 | 91 | Console 92 | true 93 | Geometry.lib;Mesh.lib;LBO.lib;SphericalHarmonicMap.lib;%(AdditionalDependencies) 94 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration);%(AdditionalLibraryDirectories) 95 | 96 | 97 | 98 | 99 | 100 | 101 | Level3 102 | Disabled 103 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 104 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\SphericalHarmonicMap;%(AdditionalIncludeDirectories) 105 | 106 | 107 | Console 108 | true 109 | Geometry.lib;Mesh.lib;LBO.lib;SphericalHarmonicMap.lib;%(AdditionalDependencies) 110 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);..\x64\$(Configuration);%(AdditionalLibraryDirectories) 111 | 112 | 113 | 114 | 115 | Level3 116 | 117 | 118 | MaxSpeed 119 | true 120 | true 121 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 122 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\SphericalHarmonicMap;%(AdditionalIncludeDirectories) 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | Geometry.lib;Mesh.lib;LBO.lib;SphericalHarmonicMap.lib;%(AdditionalDependencies) 130 | $(MESHANDGEOMETRY)\$(Configuration);..\..\..\LBO\$(Configuration);..\$(Configuration);%(AdditionalLibraryDirectories) 131 | 132 | 133 | 134 | 135 | Level3 136 | 137 | 138 | MaxSpeed 139 | true 140 | true 141 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 142 | $(MESHANDGEOMETRY)\Geometry;$(MESHANDGEOMETRY)\Mesh;..\..\..\LBO;..\SphericalHarmonicMap;%(AdditionalIncludeDirectories) 143 | 144 | 145 | Console 146 | true 147 | true 148 | true 149 | Geometry.lib;Mesh.lib;LBO.lib;SphericalHarmonicMap.lib;%(AdditionalDependencies) 150 | $(MESHANDGEOMETRY)\x64\$(Configuration);..\..\..\LBO\x64\$(Configuration);..\x64\$(Configuration);%(AdditionalLibraryDirectories) 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /apps/SphericalHarmonicMap/test_main/test_main.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /figures/curvature_value_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/curvature_value_crop.png -------------------------------------------------------------------------------- /figures/curvature_vector_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/curvature_vector_crop.png -------------------------------------------------------------------------------- /figures/harmonic_map00_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/harmonic_map00_crop.png -------------------------------------------------------------------------------- /figures/harmonic_map01_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/harmonic_map01_crop.png -------------------------------------------------------------------------------- /figures/harmonic_map02_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/harmonic_map02_crop.png -------------------------------------------------------------------------------- /figures/heat_method00_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/heat_method00_crop.png -------------------------------------------------------------------------------- /figures/heat_method01_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/heat_method01_crop.png -------------------------------------------------------------------------------- /figures/heat_method02_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/heat_method02_crop.png -------------------------------------------------------------------------------- /figures/spherical_harmonic_map00_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/spherical_harmonic_map00_crop.png -------------------------------------------------------------------------------- /figures/spherical_harmonic_map01_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Narusaki/LBO/dcb1342a0089e30a70dcdf2b44988057d50453d3/figures/spherical_harmonic_map01_crop.png --------------------------------------------------------------------------------