利用者:Apinzonf/design

提供: wiki
< 利用者:Apinzonf
2018年6月29日 (金) 05:49時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Design

Project: Mesh smoothing based on curvature flow operator in a diffusion equation.

Language: C, C++.


Introduction

This document describe the methodology to achieve integration the mesh smoothing tool new in Blender.

This new tool go into the specials menu, because the tool do not working in real time.

Mode: Edit Mode (Mesh)

Hotkey: W

Menu: Specials → Laplacian Smooth


Methodology

The project would divide into following parts:


Understanding the Blender source code

To Identify the key points for the project with base on Blender documentation, and other related documents.

Initialize data and necessary structures

The structures and functions necessary to implement this new tool, modified as follows the source code of my branch.

  • soc-2012-sushi/source/blender/editors/mesh/mesh_intern.h
    void MESH_OT_vertices_smooth_laplacian(struct wmOperatorType *ot);
    
  • soc-2012-sushi/source/blender/bmesh/intern/bmesh_operators_private.h
    void bmo_vertexsmoothlaplacian_exec(BMesh *bm, BMOperator *op);
    
  • soc-2012-sushi/source/blender/editors/mesh/mesh_ops.c
    WM_operatortype_append(MESH_OT_vertices_smooth_laplacian);
    
  • soc-2012-sushi/source/blender/bmesh/intern/bmesh_opdefines.c
    static BMOpDefine bmo_vertexsmoothlaplacian_def = { ...
    
  • New file
    soc-2012-sushi/source/blender/bmesh/operators/bmo_smooth_laplacian.c
    void bmo_vertexsmoothlaplacian_exec(BMesh *bm, BMOperator *op){...
    
  • soc-2012-sushi/source/blender/editors/mesh/editmesh_tools.c
    void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot){...
    
  • soc-2012-sushi/source/blender/editors/mesh/editmesh_tools.c
    static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op)...
    


Implement methods for the initial configuration

To achieve this goal it is necessary to implement the following methods in bmo_smooth_laplacian.c file.

  • To initialize vertex index, parameters, and calculate initial ring area for each vertex.
    void init_index();
    
  • To compute rings in structure for get neighbors to each vertex.
    void compute_rings();
    


Compute the Laplacian Matrix

To achieve this goal i must create a method to calculate the Laplacian of a vertex based on the technique proposed in the article by Desbrun, et al.

<math> L_{ij}=\left\{ \begin{array}{c} w_{ij}=\cot \alpha _{ij}+\cot \beta _{ij} \\ \sum_{(i,j)\in E}^{k}-w_{ij} \\ 0 \end{array} \begin{array}{c} if~(i,j)\in E \\ if~i=j \\ otherwise \end{array} \right\} </math>

Where L is the laplacian matrix, w is the weigth between the vertex i and vertex j, and α and β are the opposite angles to edge between vertex i, and vertex j.

float compute_weight(int vertex_i_id, int * neighbors_to_i);


Integrate or use numerical library

Within the libraries present in Blender, I found that I can work with OpenNL, to solve the system of equations, besides that I have meshlaplacian.c guide document in which they solve a system similar to that I have.


Define the sparse linear system

I need to solve the following system of equations.

Difusion equation for mesh smoothing:

<math>\frac{\partial V}{\partial t}=\lambda L\left( V\right) </math>

Integrating the diffusion equation with a explicit Euler scheme:

<math>\left( I+\lambda dtL\right) V^{t+1}=V^{t}</math>

Where <math>V^{t}</math> is the actual position of vertex, and <math>V^{t+1}</math> is the vertex after smoothing.

Solving the sparse linear system

<math>Ax=b</math>

Where:

<math>A=\left( I+\lambda dtL\right) </math>

<math>x=V^{t+1}</math>

<math>b=V^{t}</math>


Define and implement graphical user integration

Testing the tool

Generation of the documentation and tutorials

Appendix

How would look the mesh smoothing tool in Blender

Mesh Smoothng: a) Original Mesh. b) Smooth with Blender c) New mesh smooth method

In the figure above, you can see the problem applying smoothing with blender (Figure b), it shows how you lose detail at the edge on the eyelid of the eye. Figure c smoothing was performed with the method proposed and the detail was not lost on the eyelid.


Description of my development computer

  • OS: Windows 7
  • Builder System CMake 2.8.8, MS VS2010
  • SVN tools: TortoiseSVN 1.7