35 #define SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE 1.8f
36 #define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE 0.15f
67 LaplacianSystem *sys,
int usex,
int usey,
int usez,
int preserve_volume);
69 BMOperator *
op,
float vini,
float vend,
int usex,
int usey,
int usez);
96 memset(sys->eweights, val,
sizeof(
float) * sys->numEdges);
97 memset(sys->
fweights, val,
sizeof(
float) * sys->numFaces * 3);
98 memset(sys->ring_areas, val,
sizeof(
float) * sys->numVerts);
99 memset(sys->vlengths, val,
sizeof(
float) * sys->numVerts);
100 memset(sys->vweights, val,
sizeof(
float) * sys->numVerts);
101 memset(sys->zerola, val,
sizeof(
short) * sys->numVerts);
108 sys->numEdges = a_numEdges;
109 sys->numFaces = a_numFaces;
110 sys->numVerts = a_numVerts;
112 sys->eweights =
MEM_callocN(
sizeof(
float) * sys->numEdges,
"ModLaplSmoothEWeight");
113 if (!sys->eweights) {
124 sys->ring_areas =
MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothRingAreas");
125 if (!sys->ring_areas) {
130 sys->vlengths =
MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothVlengths");
131 if (!sys->vlengths) {
136 sys->vweights =
MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothVweights");
137 if (!sys->vweights) {
142 sys->zerola =
MEM_callocN(
sizeof(
short) * sys->numVerts,
"ModLaplSmoothZeloa");
170 float *
v1, *
v2, *v3, *v4;
171 float w1, w2, w3, w4;
174 uint idv1, idv2, idv3, idv4, idv[4];
191 if (w1 > sys->min_area) {
193 sys->eweights[i] = w1;
194 sys->vlengths[idv1] += w1;
195 sys->vlengths[idv2] += w1;
198 sys->zerola[idv1] = 1;
199 sys->zerola[idv2] = 1;
210 has_4_vert = (j == 4) ? 1 : 0;
219 v4 = has_4_vert ? vf[3]->
co :
NULL;
228 if (
fabsf(areaf) < sys->min_area) {
229 sys->zerola[idv1] = 1;
230 sys->zerola[idv2] = 1;
231 sys->zerola[idv3] = 1;
233 sys->zerola[idv4] = 1;
237 sys->ring_areas[idv1] += areaf;
238 sys->ring_areas[idv2] += areaf;
239 sys->ring_areas[idv3] += areaf;
241 sys->ring_areas[idv4] += areaf;
251 for (j = 0; j < 4; j++) {
253 idv2 = idv[(j + 1) % 4];
254 idv3 = idv[(j + 2) % 4];
255 idv4 = idv[(j + 3) % 4];
258 v2 = vf[(j + 1) % 4]->co;
259 v3 = vf[(j + 2) % 4]->co;
260 v4 = vf[(j + 3) % 4]->co;
266 sys->vweights[idv1] += (w2 + w3 + w4) / 4.0f;
278 sys->vweights[idv1] += w2 + w3;
279 sys->vweights[idv2] += w1 + w3;
280 sys->vweights[idv3] += w1 + w2;
288 float *
v1, *
v2, *v3, *v4;
292 uint idv1, idv2, idv3, idv4, idv[4];
307 has_4_vert = (j == 4) ? 1 : 0;
313 for (j = 0; j < 4; j++) {
315 idv2 = idv[(j + 1) % 4];
316 idv3 = idv[(j + 2) % 4];
317 idv4 = idv[(j + 3) % 4];
320 v2 = vf[(j + 1) % 4]->co;
321 v3 = vf[(j + 2) % 4]->co;
322 v4 = vf[(j + 3) % 4]->co;
371 if (sys->zerola[idv1] == 0 && sys->zerola[idv2] == 0) {
373 sys->
context, idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]);
375 sys->
context, idv2, idv1, sys->eweights[i] * sys->vlengths[idv2]);
401 BMOperator *
op,
float vini,
float vend,
int usex,
int usey,
int usez)
408 beta =
pow(vini / vend, 1.0f / 3.0f);
424 LaplacianSystem *sys,
int usex,
int usey,
int usez,
int preserve_volume)
429 float *vi1, *vi2, ve1[3], ve2[3];
451 sys->zerola[idv1] = 1;
452 sys->zerola[idv2] = 1;
456 if (preserve_volume) {
461 if (sys->zerola[m_vertex_id] == 0) {
473 if (preserve_volume) {
483 bool usex, usey, usez, preserve_volume;
484 float lambda_factor, lambda_border;
505 sys->min_area = 0.00001f;
531 if (sys->zerola[i] == 0) {
532 w = sys->vweights[i] * sys->ring_areas[i];
533 sys->vweights[i] = (
w == 0.0f) ? 0.0f : -lambda_factor / (4.0f *
w);
534 w = sys->vlengths[i];
535 sys->vlengths[i] = (
w == 0.0f) ? 0.0f : -lambda_border * 2.0f /
w;
539 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])
float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[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 GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint vn
_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_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)
#define BM_ITER_ELEM_INDEX(ele, iter, data, 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 bool vert_is_boundary(BMVert *v)
static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int preserve_volume)
static LaplacianSystem * init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts)
#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)
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
ccl_device_inline float beta(float x, float y)