-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefinitions.h
142 lines (119 loc) · 3.13 KB
/
definitions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#pragma once
#include <stdint.h>
#include <algorithm>
#include <xsi_application.h>
#include <xsi_math.h>
#include <math.h>
#include <xsi_primitive.h>
#include <xsi_geometry.h>
#include <xsi_kinematics.h>
#include <xsi_point.h>
#include <xsi_string.h>
#include <xsi_vector3.h>
#include <xsi_polygonface.h>
#include <vector>
using namespace std;
using namespace XSI::MATH;
using namespace XSI;
#define TOLERANCE 0.000000001
#define PI 3.1415926535897932
static Application app;
typedef enum
{
ALL_VERTICES_AFFINITY,
BOUNDARY_BARYCENTER_AFFINITY,
BOUNDARY_AFFINITY,
}AFFINITY_TYPE;
typedef enum
{
BOUNDARY_DISTANCE,
CENTER_DISTANCE,
HYBRID_DISTANCE,
BASE_TRANSFORMATION_DISTANCE,
}DISTANCE_FUNCTION;
typedef enum
{
MVC_ENGINE,
GC_ENGINE,
HC_ENGINE
}ENGINE_TYPE;
typedef enum
{
VERTEX_CAGE,
VERTEX_MESH
}VERTEX_TYPE;
typedef std::vector<CVector3> VECTOR3_VECTOR;
typedef std::vector<int> INTEGER_VECTOR;
typedef std::vector<float> FLOAT_VECTOR;
typedef std::vector<double> DOUBLE_VECTOR;
typedef std::vector<bool> BOOL_VECTOR;
typedef std::vector<INTEGER_VECTOR> INTEGER_MATRIX;
struct DEFORMATION_COORDINATES
{
DOUBLE_VECTOR vertexCoordinates;
DOUBLE_VECTOR faceCoordinates;
};
typedef std::vector<DEFORMATION_COORDINATES> DEFORMATION_COORDINATES_VECTOR;
inline CVector3 faceNormalGeneric( CVector3 a, CVector3 b, CVector3 c)
{
CVector3 v1= b.SubInPlace(a);
CVector3 v2=c.SubInPlace(a);
return v1.Cross(v1, v2 );
}
/* ----------------------------------------------------------------------- */
/*
Easy embeddable cross-platform high resolution timer function. For each
platform we select the high resolution timer. You can call the 'ns()'
function in your file after embedding this.
*/
#if defined(__linux)
# define HAVE_POSIX_TIMER
# include <time.h>
# ifdef CLOCK_MONOTONIC
# define CLOCKID CLOCK_MONOTONIC
# else
# define CLOCKID CLOCK_REALTIME
# endif
#elif defined(__APPLE__)
# define HAVE_MACH_TIMER
# include <mach/mach_time.h>
#elif defined(_WIN32)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
static uint64_t ns() {
static uint64_t is_init = 0;
#if defined(__APPLE__)
static mach_timebase_info_data_t info;
if (0 == is_init) {
mach_timebase_info(&info);
is_init = 1;
}
uint64_t now;
now = mach_absolute_time();
now *= info.numer;
now /= info.denom;
return now;
#elif defined(__linux)
static struct timespec linux_rate;
if (0 == is_init) {
clock_getres(CLOCKID, &linux_rate);
is_init = 1;
}
uint64_t now;
struct timespec spec;
clock_gettime(CLOCKID, &spec);
now = spec.tv_sec * 1.0e9 + spec.tv_nsec;
return now;
#elif defined(_WIN32)
static LARGE_INTEGER win_frequency;
if (0 == is_init) {
QueryPerformanceFrequency(&win_frequency);
is_init = 1;
}
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return (uint64_t) ((1e9 * now.QuadPart) / win_frequency.QuadPart);
#endif
}
/* ----------------------------------------------------------------------- */