[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51604] trunk/blender/source/blender: SVN maintenance.
gsr b3d
gsr.b3d at infernal-iceberg.com
Thu Oct 25 02:49:52 CEST 2012
Revision: 51604
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51604
Author: gsrb3d
Date: 2012-10-25 00:49:47 +0000 (Thu, 25 Oct 2012)
Log Message:
-----------
SVN maintenance.
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/operators/bmo_smooth_laplacian.c
trunk/blender/source/blender/modifiers/intern/MOD_laplaciansmooth.c
Property Changed:
----------------
trunk/blender/source/blender/bmesh/operators/bmo_smooth_laplacian.c
trunk/blender/source/blender/compositor/nodes/COM_PixelateNode.cpp
trunk/blender/source/blender/compositor/nodes/COM_PixelateNode.h
trunk/blender/source/blender/compositor/operations/COM_PixelateOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_PixelateOperation.h
trunk/blender/source/blender/modifiers/intern/MOD_laplaciansmooth.c
trunk/blender/source/blender/nodes/composite/nodes/node_composite_pixelate.c
Modified: trunk/blender/source/blender/bmesh/operators/bmo_smooth_laplacian.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_smooth_laplacian.c 2012-10-24 22:36:06 UTC (rev 51603)
+++ trunk/blender/source/blender/bmesh/operators/bmo_smooth_laplacian.c 2012-10-25 00:49:47 UTC (rev 51604)
@@ -1,618 +1,618 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Alexander Pinzon
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/bmesh/operators/bmo_smooth_laplacian.c
- * \ingroup bmesh
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_meshdata_types.h"
-
-#include "BLI_array.h"
-#include "BLI_heap.h"
-#include "BLI_math.h"
-#include "BLI_math_geom.h"
-#include "BLI_smallhash.h"
-
-#include "BKE_customdata.h"
-#include "BKE_mesh.h"
-
-#include "bmesh.h"
-
-#include "ONL_opennl.h"
-
-#include "intern/bmesh_operators_private.h" /* own include */
-
-#define SMOOTH_LAPLACIAN_AREA_FACTOR 4.0f
-#define SMOOTH_LAPLACIAN_EDGE_FACTOR 2.0f
-#define SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE 1.8
-#define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE 0.15
-
-struct BLaplacianSystem {
- float *eweights; /* Length weights per Edge */
- float (*fweights)[3]; /* Cotangent weights per face */
- float *ring_areas; /* Total area per ring*/
- float *vlengths; /* Total sum of lengths(edges) per vertice*/
- float *vweights; /* Total sum of weights per vertice*/
- int numEdges; /* Number of edges*/
- int numFaces; /* Number of faces*/
- int numVerts; /* Number of verts*/
- short *zerola; /* Is zero area or length*/
-
- /* Pointers to data*/
- BMesh *bm;
- BMOperator *op;
- NLContext *context;
-
- /*Data*/
- float min_area;
-};
-typedef struct BLaplacianSystem LaplacianSystem;
-
-static float compute_volume(BMesh *bm);
-static float cotan_weight(float *v1, float *v2, float *v3);
-static int vert_is_boundary(BMVert *v);
-static LaplacianSystem * init_laplacian_system( int a_numEdges, int a_numFaces, int a_numVerts);
-static void init_laplacian_matrix(LaplacianSystem * sys);
-static void delete_laplacian_system(LaplacianSystem * sys);
-static void delete_void_pointer(void * data);
-static void fill_laplacian_matrix(LaplacianSystem * sys);
-static void memset_laplacian_system(LaplacianSystem *sys, int val);
-static void validate_solution(LaplacianSystem * sys, int usex, int usey, int usez, int volumepreservation);
-static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez);
-
-static void delete_void_pointer(void * data)
-{
- if (data) {
- MEM_freeN(data);
- data = NULL;
- }
-}
-
-static void delete_laplacian_system(LaplacianSystem * sys)
-{
- delete_void_pointer(sys->eweights);
- delete_void_pointer(sys->fweights);
- delete_void_pointer(sys->ring_areas);
- delete_void_pointer(sys->vlengths);
- delete_void_pointer(sys->vweights);
- delete_void_pointer(sys->zerola);
- if (sys->context) {
- nlDeleteContext(sys->context);
- }
- sys->bm = NULL;
- sys->op = NULL;
- MEM_freeN(sys);
-}
-
-static void memset_laplacian_system(LaplacianSystem *sys, int val)
-{
- memset(sys->eweights , val, sizeof(float) * sys->numEdges);
- memset(sys->fweights , val, sizeof(float) * sys->numFaces * 3);
- memset(sys->ring_areas , val, sizeof(float) * sys->numVerts);
- memset(sys->vlengths , val, sizeof(float) * sys->numVerts);
- memset(sys->vweights , val, sizeof(float) * sys->numVerts);
- memset(sys->zerola , val, sizeof(short) * sys->numVerts);
-}
-
-static LaplacianSystem * init_laplacian_system( int a_numEdges, int a_numFaces, int a_numVerts)
-{
- LaplacianSystem * sys;
- sys = MEM_callocN(sizeof(LaplacianSystem), "ModLaplSmoothSystem");
- sys->numEdges = a_numEdges;
- sys->numFaces = a_numFaces;
- sys->numVerts = a_numVerts;
-
- sys->eweights = MEM_callocN(sizeof(float) * sys->numEdges, "ModLaplSmoothEWeight");
- if (!sys->eweights) {
- delete_laplacian_system(sys);
- return NULL;
- }
-
- sys->fweights = MEM_callocN(sizeof(float) * 3 * sys->numFaces, "ModLaplSmoothFWeight");
- if (!sys->fweights) {
- delete_laplacian_system(sys);
- return NULL;
- }
-
- sys->ring_areas = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothRingAreas");
- if (!sys->ring_areas) {
- delete_laplacian_system(sys);
- return NULL;
- }
-
- sys->vlengths = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVlengths");
- if (!sys->vlengths) {
- delete_laplacian_system(sys);
- return NULL;
- }
-
- sys->vweights = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVweights");
- if (!sys->vweights) {
- delete_laplacian_system(sys);
- return NULL;
- }
-
- sys->zerola = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothZeloa");
- if (!sys->zerola) {
- delete_laplacian_system(sys);
- return NULL;
- }
-
- return sys;
-}
-
-/* Compute weigth between vertice v_i and all your neighbors
- * weight between v_i and v_neighbor
- * Wij = cot(alpha) + cot(beta) / (4.0 * total area of all faces * sum all weight)
- * v_i *
- * / | \
- * / | \
- * v_beta* | * v_alpha
- * \ | /
- * \ | /
- * * v_neighbor
-*/
-
-static void init_laplacian_matrix(LaplacianSystem * sys)
-{
- float areaf;
- float *v1, *v2, *v3, *v4;
- float w1, w2, w3, w4;
- int i, j;
- int has_4_vert ;
- unsigned int idv1, idv2, idv3, idv4, idv[4];
- BMEdge *e;
- BMFace *f;
- BMIter eiter;
- BMIter fiter;
- BMIter vi;
- BMVert *vn;
- BMVert *vf[4];
-
- BM_ITER_MESH_INDEX (e, &eiter, sys->bm, BM_EDGES_OF_MESH, j) {
- if (!BM_elem_flag_test(e, BM_ELEM_SELECT) && BM_edge_is_boundary(e)) {
- v1 = e->v1->co;
- v2 = e->v2->co;
- idv1 = BM_elem_index_get(e->v1);
- idv2 = BM_elem_index_get(e->v2);
-
- w1 = len_v3v3(v1, v2);
- if (w1 > sys->min_area) {
- w1 = 1.0f / w1;
- i = BM_elem_index_get(e);
- sys->eweights[i] = w1;
- sys->vlengths[idv1] += w1;
- sys->vlengths[idv2] += w1;
- }else{
- sys->zerola[idv1] = 1;
- sys->zerola[idv2] = 1;
- }
- }
- }
-
- BM_ITER_MESH (f, &fiter, sys->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
-
- BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) {
- vf[i] = vn;
- }
- has_4_vert = (i == 4) ? 1 : 0;
- idv1 = BM_elem_index_get(vf[0]);
- idv2 = BM_elem_index_get(vf[1]);
- idv3 = BM_elem_index_get(vf[2]);
- idv4 = has_4_vert ? BM_elem_index_get(vf[3]) : 0;
-
- v1 = vf[0]->co;
- v2 = vf[1]->co;
- v3 = vf[2]->co;
- v4 = has_4_vert ? vf[3]->co : 0;
-
- if (has_4_vert) {
- areaf = area_quad_v3(v1, v2, v3, v4);
- }
- else {
- areaf = area_tri_v3(v1, v2, v3);
- }
-
- if (fabs(areaf) < sys->min_area) {
- sys->zerola[idv1] = 1;
- sys->zerola[idv2] = 1;
- sys->zerola[idv3] = 1;
- if (has_4_vert) sys->zerola[idv4] = 1;
- }
-
- sys->ring_areas[idv1] += areaf;
- sys->ring_areas[idv2] += areaf;
- sys->ring_areas[idv3] += areaf;
- if (has_4_vert) sys->ring_areas[idv4] += areaf;
-
- if (has_4_vert) {
-
- idv[0] = idv1;
- idv[1] = idv2;
- idv[2] = idv3;
- idv[3] = idv4;
-
- for (j = 0; j < 4; j++) {
- idv1 = idv[j];
- idv2 = idv[(j + 1) % 4];
- idv3 = idv[(j + 2) % 4];
- idv4 = idv[(j + 3) % 4];
-
- v1 = vf[j]->co;
- v2 = vf[(j + 1) % 4]->co;
- v3 = vf[(j + 2) % 4]->co;
- v4 = vf[(j + 3) % 4]->co;
-
- w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2);
- w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3);
- w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1);
-
- sys->vweights[idv1] += (w2 + w3 + w4) / 4.0f;
- }
- }
- else {
- i = BM_elem_index_get(f);
-
- w1 = cotan_weight(v1, v2, v3);
- w2 = cotan_weight(v2, v3, v1);
- w3 = cotan_weight(v3, v1, v2);
-
- sys->fweights[i][0] += w1;
- sys->fweights[i][1] += w2;
- sys->fweights[i][2] += w3;
-
- sys->vweights[idv1] += w2 + w3;
- sys->vweights[idv2] += w1 + w3;
- sys->vweights[idv3] += w1 + w2;
- }
- }
- }
-}
-
-static void fill_laplacian_matrix(LaplacianSystem * sys)
-{
- float *v1, *v2, *v3, *v4;
- float w2, w3, w4;
- int i, j;
- int has_4_vert ;
- unsigned int idv1, idv2, idv3, idv4, idv[4];
-
- BMEdge *e;
- BMFace *f;
- BMIter eiter;
- BMIter fiter;
- BMIter vi;
- BMVert *vn;
- BMVert *vf[4];
-
- BM_ITER_MESH (f, &fiter, sys->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) {
- vf[i] = vn;
- }
- has_4_vert = (i == 4) ? 1 : 0;
- if (has_4_vert) {
- idv[0] = BM_elem_index_get(vf[0]);
- idv[1] = BM_elem_index_get(vf[1]);
- idv[2] = BM_elem_index_get(vf[2]);
- idv[3] = BM_elem_index_get(vf[3]);
- for (j = 0; j < 4; j++) {
- idv1 = idv[j];
- idv2 = idv[(j + 1) % 4];
- idv3 = idv[(j + 2) % 4];
- idv4 = idv[(j + 3) % 4];
-
- v1 = vf[j]->co;
- v2 = vf[(j + 1) % 4]->co;
- v3 = vf[(j + 2) % 4]->co;
- v4 = vf[(j + 3) % 4]->co;
-
- w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2);
- w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3);
- w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1);
-
- w2 = w2 / 4.0f;
- w3 = w3 / 4.0f;
- w4 = w4 / 4.0f;
-
- if (!vert_is_boundary(vf[j]) && sys->zerola[idv1] == 0) {
- nlMatrixAdd(idv1, idv2, w2 * sys->vweights[idv1]);
- nlMatrixAdd(idv1, idv3, w3 * sys->vweights[idv1]);
- nlMatrixAdd(idv1, idv4, w4 * sys->vweights[idv1]);
- }
- }
- }
- else {
- idv1 = BM_elem_index_get(vf[0]);
- idv2 = BM_elem_index_get(vf[1]);
- idv3 = BM_elem_index_get(vf[2]);
- /* Is ring if number of faces == number of edges around vertice*/
- i = BM_elem_index_get(f);
- if (!vert_is_boundary(vf[0]) && sys->zerola[idv1] == 0) {
- nlMatrixAdd(idv1, idv2, sys->fweights[i][2] * sys->vweights[idv1]);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list