[Bf-blender-cvs] [968f1c0de3c] uv_unwrapping_slim_algorithm: UV Unwrapping SLIM: reordering functino definitions to remove prototypes and cleaning header files

Aurel Gruber noreply at git.blender.org
Tue Mar 14 09:43:30 CET 2017


Commit: 968f1c0de3c698046e9d964ffcb9be7923f9945e
Author: Aurel Gruber
Date:   Fri Mar 10 10:40:49 2017 +0100
Branches: uv_unwrapping_slim_algorithm
https://developer.blender.org/rB968f1c0de3c698046e9d964ffcb9be7923f9945e

UV Unwrapping SLIM: reordering functino definitions to remove prototypes and cleaning header files

===================================================================

M	source/blender/bmesh/bmesh_class.h
M	source/blender/editors/uvedit/uvedit_parametrizer.c
M	source/blender/editors/uvedit/uvedit_parametrizer.h
M	source/blender/editors/uvedit/uvedit_unwrap_ops.c

===================================================================

diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 82f97b873e0..104df625ee6 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -99,8 +99,6 @@ typedef struct BMVert {
 	 *       which is a bit of an abuse of internal bmesh data but also works OK for now (use with care!).
 	 */
 	struct BMEdge *e;
-
-	int id;
 } BMVert;
 
 typedef struct BMVert_OFlag {
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 17799ae6e07..550f7589a6f 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -35,9 +35,6 @@
 #include "BLI_boxpack2d.h"
 #include "BLI_convexhull2d.h"
 
-#include "BKE_editmesh.h"
-#include "bmesh.h"
-
 #include "uvedit_parametrizer.h"
 
 #include <math.h>
@@ -245,16 +242,9 @@ typedef struct PHandle {
 	// SLIM uv unwrapping
 	SLIMMatrixTransfer *mt;
 	int n_iterations;
-	int slim_global_method;
 	bool skip_initialization;
-	bool pack_islands;
-	bool with_weighted_parameterization;
-	MDeformVert *weight_map_data;
-	int weight_map_index;
-	double weight_influence;
-	double relative_scale;
-	BMesh *bm;
-
+	float *weight_array;
+	bool is_interactive;
 } PHandle;
 
 /* PHash
@@ -4200,23 +4190,12 @@ void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
 	phandle->state = PHANDLE_STATE_CONSTRUCTED;
 }
 
-int retrieve_weightmap_index(Object *obedit, char *vertex_group)
-{
-	return defgroup_name_index(obedit, vertex_group);
-}
-
-void param_slim_enrich_handle(Object *obedit,
-							  BMEditMesh *em,
-							  ParamHandle *handle,
+void param_slim_enrich_handle(ParamHandle *handle,
 							  SLIMMatrixTransfer *mt,
-							  MDeformVert *dvert,
-							  int weight_map_index,
-							  double weight_influence,
-							  double relative_scale,
+							  float *weight_array,
 							  int n_iterations,
 							  bool skip_initialization,
-							  bool pack_islands,
-							  bool with_weighted_parameterization)
+							  bool is_interactive)
 {
 
 	PHandle *phandle = (PHandle *)handle;
@@ -4224,421 +4203,223 @@ void param_slim_enrich_handle(Object *obedit,
 	phandle->mt = mt;
 	phandle->n_iterations = n_iterations;
 	phandle->skip_initialization = skip_initialization;
-	phandle->pack_islands = pack_islands;
-	phandle->with_weighted_parameterization = with_weighted_parameterization;
-	phandle->weight_map_data = dvert;
-	phandle->weight_map_index = weight_map_index;
-	phandle->weight_influence = weight_influence;
-	phandle->relative_scale = relative_scale;
-	phandle->bm = em->bm;
+	phandle->weight_array = weight_array;
+	phandle->is_interactive = is_interactive;
 }
 
-void param_begin(ParamHandle *handle, ParamBool abf, bool use_slim)
-{
-	if (use_slim) {
-		param_slim_begin(handle);
-	} else {
-		param_lscm_begin(handle, PARAM_FALSE, abf);
-	}
-}
 
-void param_solve(ParamHandle *handle, bool use_slim)
-{
-	if (use_slim) {
-		param_slim_solve(handle);
-	} else {
-		param_lscm_solve(handle);
-	}
-}
+/*	In the following are all functions necessary to transfer data from the native part to SLIM.
+ */
 
-void param_end(ParamHandle *handle, bool use_slim)
+/*	Allocate pointer arrays for each matrix-group. Meaning as many pointers per array as there are charts.
+ */
+static void allocate_memory_for_pointerarrays(SLIMMatrixTransfer *mt, PHandle *phandle)
 {
-	if (use_slim) {
-		param_slim_end(handle);
-	} else {
-		param_lscm_end(handle);
-	}
-}
+	mt->n_charts = phandle->ncharts;
+	mt->n_verts = MEM_mallocN(mt->n_charts * sizeof(*mt->n_verts), "Array of number of vertices per Chart");
+	mt->n_faces = MEM_mallocN(mt->n_charts * sizeof(*mt->n_faces), "Array of number of Faces per Chart");
+	mt->n_edges = MEM_mallocN(mt->n_charts * sizeof(*mt->n_edges), "Array of number of Edges per Chart");
+	mt->n_pinned_vertices = MEM_mallocN(mt->n_charts * sizeof(*mt->n_pinned_vertices), "Array of number of Faces per Chart");
+	mt->n_boundary_vertices = MEM_mallocN(mt->n_charts * sizeof(*mt->n_boundary_vertices), "Array of number of Faces per Chart");
 
-void param_slim_begin(ParamHandle *handle)
-{
-	transfer_data_to_slim(handle);
-}
+	mt->v_matrices = MEM_mallocN(mt->n_charts * sizeof(*mt->v_matrices), "Array of pointers to Vertex matrices");
+	mt->uv_matrices = MEM_mallocN(mt->n_charts * sizeof(*mt->uv_matrices), "Array of pointers to UV matrices");
+	mt->pp_matrices = MEM_mallocN(mt->n_charts * sizeof(*mt->pp_matrices), "Array of pointers to Pinned-Vertex-Position matrices");
 
-void param_slim_solve(ParamHandle *handle)
-{
-	PHandle *phandle = (PHandle *) handle;
-	SLIMMatrixTransfer *mt = phandle->mt;
-	SLIM_parametrize(mt, phandle->n_iterations, mt->fixed_boundary, phandle->skip_initialization);
-}
+	mt->f_matrices = MEM_mallocN(mt->n_charts * sizeof(*mt->f_matrices), "Array of pointers to Face matrices");
+	mt->p_matrices = MEM_mallocN(mt->n_charts * sizeof(*mt->p_matrices), "Array of pointers to Pinned-Vertex matrices");
+	mt->b_vectors = MEM_mallocN(mt->n_charts * sizeof(*mt->b_vectors), "Array of pointers to boundary-Vertex vectors");
+	mt->e_matrices = MEM_mallocN(mt->n_charts * sizeof(*mt->e_matrices), "Array of pointers to Edge matrices");
 
-void param_slim_end(ParamHandle *handle)
-{
-	PHandle *phandle = (PHandle *) handle;
-	SLIMMatrixTransfer *mt = phandle->mt;
-	set_uv_param_slim(handle, mt);
-	free_slim_matrix_transfer(mt);
+	mt->el_vectors = MEM_mallocN(mt->n_charts * sizeof(*mt->el_vectors), "Array of pointers to Edge-Length vectors");
+	mt->w_vectors = MEM_mallocN(mt->n_charts * sizeof(*mt->w_vectors), "Array of pointers to weight-per-face vectors");
 }
 
+/*	For one chart, allocate memory. If no accurate estimate (e.g. for number of pinned vertices) overestimate and
+	correct later.
+ */
 
-void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
+static void allocate_memory_for_matrices(const int chartNr, const PHandle *phandle, const SLIMMatrixTransfer *mt)
 {
-	PHandle *phandle = (PHandle *)handle;
-	PFace *f;
-	int i;
+	mt->n_verts[chartNr] = phandle->charts[chartNr]->nverts;
+	mt->n_faces[chartNr] = phandle->charts[chartNr]->nfaces;
+	mt->n_edges[chartNr] = phandle->charts[chartNr]->nedges;
 
-	param_assert(phandle->state == PHANDLE_STATE_CONSTRUCTED);
-	phandle->state = PHANDLE_STATE_LSCM;
+	mt->v_matrices[chartNr] = MEM_mallocN(mt->n_verts[chartNr] * 3 * sizeof(**mt->v_matrices), "Vertex Matrix");
+	mt->uv_matrices[chartNr] = MEM_mallocN(mt->n_verts[chartNr] * 2 * sizeof(**mt->uv_matrices), "UV Matrix");
+	mt->pp_matrices[chartNr] = MEM_mallocN(mt->n_verts[chartNr] * 2 * sizeof(**mt->pp_matrices), "Pinned-Vertex-position Matrix");
 
-	for (i = 0; i < phandle->ncharts; i++) {
-		for (f = phandle->charts[i]->faces; f; f = f->nextlink)
-			p_face_backup_uvs(f);
-		p_chart_lscm_begin(phandle->charts[i], (PBool)live, (PBool)abf);
-	}
+	mt->f_matrices[chartNr] = MEM_mallocN(mt->n_faces[chartNr] * 3 * sizeof(**mt->f_matrices), "Face Matrix");
+	mt->p_matrices[chartNr] = MEM_mallocN(mt->n_verts[chartNr] * sizeof(**mt->p_matrices), " Pinned-Vertex Matrix");
+	mt->b_vectors[chartNr] = MEM_mallocN(mt->n_verts[chartNr] * sizeof(**mt->b_vectors), " Boundary-Vertex Vector");
+	//also clear memory for weight vectors, hence calloc
+	mt->w_vectors[chartNr] = MEM_callocN(mt->n_verts[chartNr] * sizeof(**mt->w_vectors), " Weight-per-face Vector");
+
+	mt->e_matrices[chartNr] = MEM_mallocN(mt->n_edges[chartNr] * 2 * 2 * sizeof(**mt->e_matrices), " Edge matrix");
+	mt->el_vectors[chartNr] = MEM_mallocN(mt->n_edges[chartNr] * 2 * sizeof(**mt->el_vectors), " Edge-Length Vector");
 }
 
-void param_lscm_solve(ParamHandle *handle)
+/*	Transfer edges and edge lengths */
+static void transfer_edges(const int chartNr, const PHandle *phandle, const SLIMMatrixTransfer *mt)
 {
-	PHandle *phandle = (PHandle *)handle;
-	PChart *chart;
-	int i;
-	PBool result;
+	PChart *chart = phandle->charts[chartNr];
 
-	param_assert(phandle->state == PHANDLE_STATE_LSCM);
+	int *E = mt->e_matrices[chartNr];
+	double *EL = mt->el_vectors[chartNr];
 
-	for (i = 0; i < phandle->ncharts; i++) {
-		chart = phandle->charts[i];
+	int vid = 0;
+	int eid = 0;
 
-		if (chart->u.lscm.context) {
-			result = p_chart_lscm_solve(phandle, chart);
+	PEdge *e, *e1;
+	PEdge *outer;
+	p_chart_boundaries(chart, NULL, &outer);
+	PEdge *be = outer;
 
-			if (result && !(chart->flag & PCHART_NOPACK))
-				p_chart_rotate_minimum_area(chart);
 
-			if (!result || (chart->u.lscm.pin1))
-				p_chart_lscm_end(chart);
-		}
+	do {
+		E[eid] = be->vert->slimId;
+		EL[eid] = p_edge_length(be);
+
+		be = p_boundary_edge_next(be);
+		E[eid + mt->n_edges[chartNr] + mt->n_boundary_vertices[chartNr]] = be->vert->slimId;
+		eid++;
+
+	} while (be != outer);
+
+	for (e = chart->edges; e; e = e->nextlink) {
+		e1 = e->next;
+
+		E[eid] = e->vert->slimId;
+		EL[eid] = p_edge_length(e);
+
+		E[eid + mt->n_edges[chartNr] + mt->n_boundary_vertices[chartNr]] = e1->vert->slimId;
+		eid++;
 	}
 }
 
-void param_lscm_end(ParamHandle *handle)
+/*	Transfer vertices and pinned information */
+static void transfer_vertices(const int chartNr, const PHandle *phandle, SLIMMatrixTransfer *mt, float *temp_w)
 {
-	PHandle *phandle = (PHandle *)handle;
-	int i;
+	PChart *chart = phandle->charts[chartNr];
+	PVert *v;
 
-	param_assert(phandle->state == PHANDLE_STATE_LSCM);
+	double *V, *UV, *PP;
+	float *W;
+	int *P;
+	float weight;
 
-	for (i = 0; i < phandle->ncharts; i++) {
-		p_chart_lscm_end(phandle->charts[i]);
-#if 0
-		p_chart_complexify(phandle->charts[i]);
-#endif
-	}
+	int r = mt->n_verts[chartNr];
+	V = mt->v_matrices[chartNr];
+	UV = mt->uv_matrices[chartNr];
+	P = mt->p_matrices[chartNr];
+	PP = mt->pp_matrices[chartNr];
+	W = mt->w_vectors[chartNr];
 
-	phandle->state = PHANDLE_STATE_CONSTRUCTED;
-}
+	int pVid = 0;
+	int vid = mt->n_boundary_vertices[chartNr];
+	//For every vertex, fill up V matrix and P matrix (pinned vertices)
+	for (v = chart->verts; v; v = v->nextlink) {
 
-void param_stretch_end(ParamHandle *handle)
-{
-	PHandle *phandle = (PHandle *)handle;
+		if (!v->on_boundary_flag) {
 
-	param_assert(phandle->state == PHANDLE_STATE_STRETCH);
-	phandle->state = PHANDLE_STAT

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list