21 #define SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE 1.8f
22 #define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE 0.15f
53 LaplacianSystem *sys,
int usex,
int usey,
int usez,
int preserve_volume);
55 BMOperator *
op,
float vini,
float vend,
int usex,
int usey,
int usez);
82 memset(sys->eweights, val,
sizeof(
float) * sys->numEdges);
83 memset(sys->
fweights, val,
sizeof(
float[3]) * sys->numLoops);
84 memset(sys->ring_areas, val,
sizeof(
float) * sys->numVerts);
85 memset(sys->vlengths, val,
sizeof(
float) * sys->numVerts);
86 memset(sys->vweights, val,
sizeof(
float) * sys->numVerts);
87 memset(sys->zerola, val,
sizeof(
bool) * sys->numVerts);
94 sys->numEdges = a_numEdges;
95 sys->numLoops = a_numLoops;
96 sys->numVerts = a_numVerts;
98 sys->eweights =
MEM_callocN(
sizeof(
float) * sys->numEdges,
"ModLaplSmoothEWeight");
110 sys->ring_areas =
MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothRingAreas");
111 if (!sys->ring_areas) {
116 sys->vlengths =
MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothVlengths");
117 if (!sys->vlengths) {
122 sys->vweights =
MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothVweights");
123 if (!sys->vweights) {
128 sys->zerola =
MEM_callocN(
sizeof(
bool) * sys->numVerts,
"ModLaplSmoothZeloa");
166 const float *
v1 =
e->v1->
co;
167 const float *
v2 =
e->v2->
co;
172 if (w1 > sys->min_area) {
174 sys->eweights[i] = w1;
175 sys->vlengths[idv1] += w1;
176 sys->vlengths[idv2] += w1;
179 sys->zerola[idv1] =
true;
180 sys->zerola[idv2] =
true;
184 uint l_curr_index = 0;
188 l_curr_index += f->
len;
201 const float *co_prev = l_iter->
prev->
v->
co;
202 const float *co_curr = l_iter->
v->
co;
203 const float *co_next = l_iter->
next->
v->
co;
205 const float areaf =
area_tri_v3(co_prev, co_curr, co_next);
208 sys->zerola[vi_curr] =
true;
211 sys->ring_areas[vi_prev] += areaf;
212 sys->ring_areas[vi_curr] += areaf;
213 sys->ring_areas[vi_next] += areaf;
219 sys->
fweights[l_curr_index][0] += w1;
220 sys->
fweights[l_curr_index][1] += w2;
221 sys->
fweights[l_curr_index][2] += w3;
223 sys->vweights[vi_prev] += w1 + w2;
224 sys->vweights[vi_curr] += w2 + w3;
225 sys->vweights[vi_next] += w1 + w3;
226 }
while (((
void)(l_curr_index += 1), (l_iter = l_iter->
next) != l_first));
238 uint l_curr_index = 0;
242 l_curr_index += f->
len;
263 sys->
fweights[l_curr_index][1] * sys->vweights[vi_prev]);
267 sys->
fweights[l_curr_index][0] * sys->vweights[vi_prev]);
273 sys->
fweights[l_curr_index][2] * sys->vweights[vi_curr]);
277 sys->
fweights[l_curr_index][1] * sys->vweights[vi_curr]);
283 sys->
fweights[l_curr_index][2] * sys->vweights[vi_next]);
287 sys->
fweights[l_curr_index][0] * sys->vweights[vi_next]);
296 }
while (((
void)(l_curr_index += 1), (l_iter = l_iter->
next) != l_first));
304 if (sys->zerola[idv1] ==
false && sys->zerola[idv2] ==
false) {
306 sys->
context, idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]);
308 sys->
context, idv2, idv1, sys->eweights[i] * sys->vlengths[idv2]);
333 BMOperator *
op,
float vini,
float vend,
int usex,
int usey,
int usez)
340 beta =
pow(vini / vend, 1.0f / 3.0f);
356 LaplacianSystem *sys,
int usex,
int usey,
int usez,
int preserve_volume)
361 float *vi1, *vi2, ve1[3], ve2[3];
383 sys->zerola[idv1] =
true;
384 sys->zerola[idv2] =
true;
388 if (preserve_volume) {
393 if (sys->zerola[m_vertex_id] ==
false) {
405 if (preserve_volume) {
415 bool usex, usey, usez, preserve_volume;
416 float lambda_factor, lambda_border;
437 sys->min_area = 0.00001f;
463 if ((sys->zerola[i] ==
false) &&
466 (sys->ring_areas[i] != 0.0f)) {
467 w = sys->vweights[i] * sys->ring_areas[i];
468 sys->vweights[i] = (
w == 0.0f) ? 0.0f : -lambda_factor / (4.0f *
w);
469 w = sys->vlengths[i];
470 sys->vlengths[i] = (
w == 0.0f) ? 0.0f : -lambda_border * 2.0f /
w;
474 sys->
context, i, i, 1.0f + lambda_factor / (4.0f * sys->ring_areas[i]));
typedef float(TangentPoint)[2]
float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float v3[3])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
#define BM_elem_index_get(ele)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
double BM_mesh_calc_volume(BMesh *bm, bool is_signed)
BLI_INLINE bool BM_edge_is_boundary(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
static void delete_void_pointer(void *data)
void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
static void init_laplacian_matrix(LaplacianSystem *sys)
static void delete_laplacian_system(LaplacianSystem *sys)
static LaplacianSystem * init_laplacian_system(int a_numEdges, int a_numLoops, int a_numVerts)
static bool vert_is_boundary(BMVert *v)
static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int preserve_volume)
#define SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE
static void memset_laplacian_system(LaplacianSystem *sys, int val)
#define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE
static void volume_preservation(BMOperator *op, float vini, float vend, int usex, int usey, int usez)
static void fill_laplacian_matrix(LaplacianSystem *sys)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void EIG_linear_solver_variable_set(LinearSolver *solver, int rhs, int index, double value)
void EIG_linear_solver_right_hand_side_add(LinearSolver *solver, int rhs, int index, double value)
void EIG_linear_solver_variable_unlock(LinearSolver *solver, int index)
LinearSolver * EIG_linear_least_squares_solver_new(int num_rows, int num_columns, int num_rhs)
void EIG_linear_solver_delete(LinearSolver *solver)
double EIG_linear_solver_variable_get(LinearSolver *solver, int rhs, int index)
void EIG_linear_solver_matrix_add(LinearSolver *solver, int row, int col, double value)
bool EIG_linear_solver_solve(LinearSolver *solver)
void EIG_linear_solver_variable_lock(LinearSolver *solver, int index)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float3 pow(float3 v, float e)
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
ccl_device_inline float beta(float x, float y)