Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions

BKE_bmesh.h File Reference

BMesh modeler structure and functions. More...

#include "DNA_listBase.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_mempool.h"
#include "BLI_memarena.h"
#include "DNA_image_types.h"
#include "BLI_editVert.h"
#include "BKE_DerivedMesh.h"

Go to the source code of this file.

Classes

struct  BME_CycleNode
struct  BME_Mesh
struct  BME_Vert
struct  BME_Edge
struct  BME_Loop
struct  BME_Poly
struct  BME_TransData
struct  BME_TransData_Head
struct  BME_Glob

Defines

#define BME_BEVEL_ORIG   1
#define BME_BEVEL_BEVEL   (1<<1)
#define BME_BEVEL_NONMAN   (1<<2)
#define BME_BEVEL_WIRE   (1<<3)
#define BME_BEVEL_SELECT   1
#define BME_BEVEL_VERT   (1<<1)
#define BME_BEVEL_RADIUS   (1<<2)
#define BME_BEVEL_ANGLE   (1<<3)
#define BME_BEVEL_WEIGHT   (1<<4)
#define BME_BEVEL_PERCENT   (1<<6)
#define BME_BEVEL_EMIN   (1<<7)
#define BME_BEVEL_EMAX   (1<<8)
#define BME_BEVEL_RUNNING   (1<<9)
#define BME_BEVEL_RES   (1<<10)

Typedefs

typedef struct BME_CycleNode BME_CycleNode
typedef struct BME_Mesh BME_Mesh
typedef struct BME_Vert BME_Vert
typedef struct BME_Edge BME_Edge
typedef struct BME_Loop BME_Loop
typedef struct BME_Poly BME_Poly
typedef struct BME_TransData BME_TransData
typedef struct BME_TransData_Head BME_TransData_Head
typedef struct BME_Glob BME_Glob

Functions

int BME_verts_in_edge (struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge *e)
int BME_vert_in_edge (struct BME_Edge *e, BME_Vert *v)
struct BME_VertBME_edge_getothervert (struct BME_Edge *e, struct BME_Vert *v)
int BME_cycle_length (void *h)
struct BME_EdgeBME_disk_nextedge (struct BME_Edge *e, struct BME_Vert *v)
struct BME_CycleNodeBME_disk_getpointer (struct BME_Edge *e, struct BME_Vert *v)
struct BME_EdgeBME_disk_next_edgeflag (struct BME_Edge *e, struct BME_Vert *v, int eflag, int tflag)
int BME_disk_count_edgeflag (struct BME_Vert *v, int eflag, int tflag)
struct BME_LoopBME_radial_nextloop (struct BME_Loop *l)
int BME_radial_find_face (struct BME_Edge *e, struct BME_Poly *f)
struct BME_LoopBME_loop_find_loop (struct BME_Poly *f, struct BME_Vert *v)
struct BME_MeshBME_make_mesh (int allocsize[4])
void BME_free_mesh (struct BME_Mesh *bm)
int BME_validate_mesh (struct BME_Mesh *bm, int halt)
int BME_model_begin (struct BME_Mesh *bm)
void BME_model_end (struct BME_Mesh *bm)
struct BME_VertBME_MV (struct BME_Mesh *bm, float *vec)
struct BME_EdgeBME_ME (struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2)
struct BME_PolyBME_MF (struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge **elist, int len)
int BME_KV (struct BME_Mesh *bm, struct BME_Vert *v)
int BME_KE (struct BME_Mesh *bm, struct BME_Edge *e)
int BME_KF (struct BME_Mesh *bm, struct BME_Poly *bply)
struct BME_VertBME_SEMV (struct BME_Mesh *bm, struct BME_Vert *tv, struct BME_Edge *e, struct BME_Edge **re)
struct BME_PolyBME_SFME (struct BME_Mesh *bm, struct BME_Poly *f, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Loop **rl)
int BME_JEKV (struct BME_Mesh *bm, struct BME_Edge *ke, struct BME_Vert *kv)
struct BME_PolyBME_JFKE (struct BME_Mesh *bm, struct BME_Poly *f1, struct BME_Poly *f2, struct BME_Edge *e)
int BME_loop_reverse (struct BME_Mesh *bm, struct BME_Poly *f)
struct BME_TransDataBME_get_transdata (struct BME_TransData_Head *td, struct BME_Vert *v)
void BME_free_transdata (struct BME_TransData_Head *td)
float * BME_bevel_calc_polynormal (struct BME_Poly *f, struct BME_TransData_Head *td)
struct BME_MeshBME_bevel (struct BME_Mesh *bm, float value, int res, int options, int defgrp_index, float angle, BME_TransData_Head **rtd)
struct BME_MeshBME_editmesh_to_bmesh (EditMesh *em)
void BME_bmesh_to_editmesh (struct BME_Mesh *bm, BME_TransData_Head *td, EditMesh *em)
struct BME_MeshBME_derivedmesh_to_bmesh (struct DerivedMesh *dm)
struct DerivedMeshBME_bmesh_to_derivedmesh (struct BME_Mesh *bm, struct DerivedMesh *dm)

Detailed Description

BMesh modeler structure and functions.

Since:
January 2007

Definition in file BKE_bmesh.h.


Define Documentation

#define BME_BEVEL_ANGLE   (1<<3)

Definition at line 201 of file BKE_bmesh.h.

Referenced by BME_bevel_initialize(), and rna_def_modifier_bevel().

#define BME_BEVEL_BEVEL   (1<<1)
#define BME_BEVEL_EMAX   (1<<8)

Definition at line 207 of file BKE_bmesh.h.

Referenced by BME_bevel_add_vweight(), and rna_def_modifier_bevel().

#define BME_BEVEL_EMIN   (1<<7)

Definition at line 206 of file BKE_bmesh.h.

Referenced by BME_bevel_add_vweight(), and rna_def_modifier_bevel().

#define BME_BEVEL_NONMAN   (1<<2)
#define BME_BEVEL_ORIG   1
#define BME_BEVEL_PERCENT   (1<<6)

Definition at line 205 of file BKE_bmesh.h.

#define BME_BEVEL_RADIUS   (1<<2)

Definition at line 200 of file BKE_bmesh.h.

#define BME_BEVEL_RES   (1<<10)

Definition at line 209 of file BKE_bmesh.h.

#define BME_BEVEL_RUNNING   (1<<9)

Definition at line 208 of file BKE_bmesh.h.

Referenced by bevel_menu().

#define BME_BEVEL_SELECT   1

Definition at line 198 of file BKE_bmesh.h.

Referenced by bevel_menu(), and BME_bevel_initialize().

#define BME_BEVEL_VERT   (1<<1)

Definition at line 199 of file BKE_bmesh.h.

Referenced by Bevel(), BME_bevel_initialize(), handleEventBevel(), and rna_def_modifier_bevel().

#define BME_BEVEL_WEIGHT   (1<<4)

Definition at line 202 of file BKE_bmesh.h.

Referenced by BME_bevel_initialize(), and rna_def_modifier_bevel().

#define BME_BEVEL_WIRE   (1<<3)

Definition at line 195 of file BKE_bmesh.h.


Typedef Documentation

typedef struct BME_CycleNode BME_CycleNode
typedef struct BME_Edge BME_Edge
typedef struct BME_Glob BME_Glob
typedef struct BME_Loop BME_Loop
typedef struct BME_Mesh BME_Mesh
typedef struct BME_Poly BME_Poly
typedef struct BME_TransData BME_TransData
typedef struct BME_Vert BME_Vert

Function Documentation

struct BME_Mesh* BME_bevel ( struct BME_Mesh bm,
float  value,
int  res,
int  options,
int  defgrp_index,
float  angle,
BME_TransData_Head **  rtd 
) [read]
float* BME_bevel_calc_polynormal ( struct BME_Poly f,
struct BME_TransData_Head td 
)
struct DerivedMesh* BME_bmesh_to_derivedmesh ( struct BME_Mesh bm,
struct DerivedMesh dm 
) [read]
void BME_bmesh_to_editmesh ( struct BME_Mesh bm,
BME_TransData_Head td,
EditMesh em 
)
int BME_cycle_length ( void *  h)
struct BME_Mesh* BME_derivedmesh_to_bmesh ( struct DerivedMesh dm) [read]
int BME_disk_count_edgeflag ( BME_Vert v,
int  eflag,
int  tflag 
)

BME_disk_count_edgeflag

Counts number of edges in this verts disk cycle which have either eflag or tflag (but not both!)

Returns - Integer.

Definition at line 540 of file BME_structure.c.

References BME_cycle_length(), BME_disk_getpointer(), BME_disk_nextedge(), BME_Vert::edge, BME_Edge::eflag1, i, len(), and BME_Edge::tflag1.

Referenced by BME_MF().

struct BME_CycleNode* BME_disk_getpointer ( BME_Edge e,
BME_Vert v 
) [read]

BME_disk_getpointer

Given an edge and one of its vertices, find the apporpriate CycleNode

Returns - Pointer to BME_CycleNode.

Definition at line 426 of file BME_structure.c.

References BME_Edge::d2, NULL, BME_Edge::v1, and BME_Edge::v2.

Referenced by BME_bevel_initialize(), BME_bevel_mesh(), BME_disk_append_edge(), BME_disk_count_edgeflag(), BME_disk_hasedge(), BME_disk_remove_edge(), BME_JEKV(), BME_ME(), BME_SEMV(), and BME_validate_mesh().

struct BME_Edge* BME_disk_next_edgeflag ( BME_Edge e,
BME_Vert v,
int  eflag,
int  tflag 
) [read]

BME_disk_next_edgeflag

Searches the disk cycle of v, starting with e, for the next edge that has either eflag or tflag.

BME_Edge pointer.

Definition at line 504 of file BME_structure.c.

References BME_disk_nextedge(), BME_vert_in_edge(), BME_Edge::eflag1, NULL, and BME_Edge::tflag1.

Referenced by BME_bevel_mesh(), and BME_MF().

struct BME_Edge* BME_disk_nextedge ( BME_Edge e,
BME_Vert v 
) [read]

BME_disk_nextedge

Find the next edge in a disk cycle

Returns - Pointer to the next edge in the disk cycle for the vertex v.

Definition at line 409 of file BME_structure.c.

References BME_vert_in_edge(), BME_Edge::d2, BME_Edge::data, BME_CycleNode::data, BME_CycleNode::next, BME_Edge::next, NULL, BME_Edge::v1, and BME_Edge::v2.

Referenced by BME_bevel_mesh(), BME_bevel_split_edge(), BME_bevel_wire(), BME_disk_count_edgeflag(), BME_disk_hasedge(), BME_disk_next_edgeflag(), BME_is_nonmanifold_vert(), BME_JEKV(), BME_validate_mesh(), and bmesh_dissolve_disk().

struct BME_Vert* BME_edge_getothervert ( struct BME_Edge e,
struct BME_Vert v 
) [read]
struct BME_Mesh* BME_editmesh_to_bmesh ( EditMesh em) [read]
void BME_free_mesh ( struct BME_Mesh bm)
void BME_free_transdata ( struct BME_TransData_Head td)
struct BME_TransData* BME_get_transdata ( struct BME_TransData_Head td,
struct BME_Vert v 
) [read]
int BME_JEKV ( BME_Mesh bm,
BME_Edge ke,
BME_Vert kv 
)

BME_JEKV

JOIN EDGE KILL VERT: Takes a an edge and pointer to one of its vertices and collapses the edge on that vertex.

Before: OE KE ------- ------- | || | OV KV TV

After: OE --------------- | | OV TV

Restrictions: KV is a vertex that must have a valance of exactly two. Furthermore both edges in KV's disk cycle (OE and KE) must be unique (no double edges).

It should also be noted that this euler has the possibility of creating faces with just 2 edges. It is up to the caller to decide what to do with these faces.

Returns - 1 for success, 0 for failure.

Definition at line 687 of file BME_eulers.c.

References BLI_remlink(), BME_cycle_length(), BME_cycle_validate(), BME_disk_append_edge(), BME_disk_getpointer(), BME_disk_nextedge(), BME_disk_remove_edge(), BME_edge_getothervert(), BME_edge_swapverts(), BME_error(), BME_free_edge(), BME_free_loop(), BME_free_vert(), BME_radial_nextloop(), BME_vert_in_edge(), BME_verts_in_edge(), BME_CycleNode::data, BME_Vert::edge, BME_Mesh::edges, BME_Loop::f, i, len(), BME_Poly::len, BME_Edge::loop, BME_Poly::loopbase, BME_Mesh::lpar, BME_Mesh::lparlen, MEM_callocN(), MEM_freeN(), BME_Loop::next, BME_CycleNode::next, BME_Loop::prev, BME_Loop::radial, BME_Loop::v, and BME_Mesh::verts.

Referenced by BME_bevel_wire(), and BME_collapse_vert().

struct BME_Poly* BME_JFKE ( BME_Mesh bm,
BME_Poly f1,
BME_Poly f2,
BME_Edge e 
) [read]

BME_JFKE

JOIN FACE KILL EDGE:

Takes two faces joined by a single 2-manifold edge and fuses them togather. The edge shared by the faces must not be connected to any other edges which have Both faces in its radial cycle

Examples:

A B ---------- ---------- | | | | | f1 | | f1 | v1========v2 = Ok! v1==V2==v3 == Wrong! | f2 | | f2 | | | | | ---------- ----------

In the example A, faces f1 and f2 are joined by a single edge, and the euler can safely be used. In example B however, f1 and f2 are joined by multiple edges and will produce an error. The caller in this case should call BME_JEKV on the extra edges before attempting to fuse f1 and f2.

Also note that the order of arguments decides whether or not certain per-face attributes are present in the resultant face. For instance vertex winding, material index, smooth flags, ect are inherited from f1, not f2.

Returns - A BME_Poly pointer

Definition at line 898 of file BME_eulers.c.

References BLI_remlink(), BME_cycle_length(), BME_cycle_validate(), BME_disk_remove_edge(), BME_error(), BME_free_edge(), BME_free_loop(), BME_free_poly(), BME_radial_find_face(), BME_Loop::e, BME_Mesh::edges, BME_Loop::f, i, BME_Poly::len, BME_Poly::loopbase, BME_Loop::next, next, NULL, BME_Mesh::polys, BME_Loop::prev, BME_Loop::radial, BME_Loop::v, BME_Edge::v1, and BME_Edge::v2.

Referenced by BME_bevel_edge(), and BME_JFKE_safe().

int BME_KE ( BME_Mesh bm,
BME_Edge e 
)

BME_KE

KILL EDGE EULER:

Kills a wire edge.

Returns - 1 for success, 0 for failure.

Definition at line 350 of file BME_eulers.c.

References BLI_remlink(), BME_disk_hasedge(), BME_disk_remove_edge(), BME_error(), BME_free_edge(), BME_Mesh::edges, BME_Edge::loop, NULL, BME_Edge::v1, and BME_Edge::v2.

int BME_KF ( BME_Mesh bm,
BME_Poly bply 
)

BME_KF

KILL FACE EULER:

The logical inverse of BME_MF. Kills a face and removes each of its loops from the radial that it belongs to.

Returns - 1 for success, 0 for failure.

Definition at line 384 of file BME_eulers.c.

References BLI_remlink(), BME_cycle_length(), BME_cycle_remove(), BME_free_loop(), BME_free_poly(), BME_radial_remove_loop(), BME_Loop::e, i, len(), BME_Poly::loopbase, BME_Loop::next, next, and BME_Mesh::polys.

int BME_KV ( BME_Mesh bm,
BME_Vert v 
)

BME_KV

KILL VERT EULER:

Kills a single loose vertex.

Returns - 1 for success, 0 for failure.

Definition at line 330 of file BME_eulers.c.

References BLI_remlink(), BME_free_vert(), BME_Vert::edge, NULL, and BME_Mesh::verts.

struct BME_Loop* BME_loop_find_loop ( struct BME_Poly f,
struct BME_Vert v 
) [read]

Definition at line 619 of file BME_structure.c.

References BME_cycle_length(), i, len(), BME_Poly::loopbase, next, NULL, and BME_Loop::v.

int BME_loop_reverse ( BME_Mesh bm,
BME_Poly f 
)

BME_loop_reverse

FLIP FACE EULER

Changes the winding order of a face from CW to CCW or vice versa. This euler is a bit peculiar in compairson to others as it is its own inverse.

TODO: reinsert validation code.

Returns - 1 for success, 0 for failure.

Definition at line 807 of file BME_eulers.c.

References BME_cycle_length(), BME_cycle_validate(), BME_error(), BME_radial_append(), BME_radial_remove_loop(), BME_verts_in_edge(), BME_Loop::e, BME_Mesh::edar, BME_Mesh::edarlen, i, len(), BME_Poly::loopbase, MEM_callocN(), MEM_freeN(), BME_Loop::next, BME_Edge::next, NULL, and BME_Edge::prev.

Referenced by BME_JFKE_safe().

struct BME_Mesh* BME_make_mesh ( int  allocsize[4]) [read]
struct BME_Edge* BME_ME ( BME_Mesh bm,
BME_Vert v1,
BME_Vert v2 
) [read]

BME_ME

MAKE EDGE EULER:

Makes a single wire edge between two vertices. If the caller does not want there to be duplicate edges between the vertices, it is up to them to check for this condition beforehand.

Returns - A BME_Edge pointer.

Definition at line 124 of file BME_eulers.c.

References BME_addedgelist(), BME_cycle_length(), BME_cycle_validate(), BME_disk_append_edge(), BME_disk_getpointer(), BME_disk_hasedge(), BME_error(), credits_svn_gen::e, BME_Vert::edge, NULL, BME_Edge::v1, and BME_Edge::v2.

Referenced by BME_derivedmesh_to_bmesh(), and BME_editmesh_to_bmesh().

struct BME_Poly* BME_MF ( struct BME_Mesh bm,
struct BME_Vert v1,
struct BME_Vert v2,
struct BME_Edge **  elist,
int  len 
) [read]
int BME_model_begin ( struct BME_Mesh bm)
void BME_model_end ( struct BME_Mesh bm)
struct BME_Vert* BME_MV ( BME_Mesh bm,
float *  vec 
) [read]

BME_MV

MAKE VERT EULER:

Makes a single loose vertex.

Returns - A BME_Vert pointer.

Definition at line 104 of file BME_eulers.c.

References BME_addvertlist(), BME_Vert::co, NULL, and VECCOPY.

Referenced by BME_derivedmesh_to_bmesh(), and BME_editmesh_to_bmesh().

int BME_radial_find_face ( struct BME_Edge e,
struct BME_Poly f 
)
struct BME_Loop* BME_radial_nextloop ( struct BME_Loop l) [read]

Definition at line 581 of file BME_structure.c.

References BME_CycleNode::data, BME_CycleNode::next, and BME_Loop::radial.

Referenced by BME_JEKV().

struct BME_Vert* BME_SEMV ( BME_Mesh bm,
BME_Vert tv,
BME_Edge e,
BME_Edge **  re 
) [read]
struct BME_Poly* BME_SFME ( BME_Mesh bm,
BME_Poly f,
BME_Vert v1,
BME_Vert v2,
BME_Loop **  rl 
) [read]

BME_SFME

SPLIT FACE MAKE EDGE:

Takes as input two vertices in a single face. An edge is created which divides the original face into two distinct regions. One of the regions is assigned to the original face and it is closed off. The second region has a new face assigned to it.

Examples:

Before: After: ---------- ---------- | | | | | | | f1 | v1 f1 v2 v1======v2 | | | f2 | | | | | ---------- ----------

Note that the input vertices can be part of the same edge. This will result in a two edged face. This is desirable for advanced construction tools and particularly essential for edge bevel. Because of this it is up to the caller to decide what to do with the extra edge.

Returns - A BME_Poly pointer

Definition at line 595 of file BME_eulers.c.

References BME_addedgelist(), BME_addpolylist(), BME_create_loop(), BME_cycle_length(), BME_disk_append_edge(), BME_radial_append(), credits_svn_gen::e, i, len(), BME_Poly::len, BME_Poly::loopbase, BME_Loop::next, next, NULL, and BME_Loop::prev.

Referenced by BME_split_face().

int BME_validate_mesh ( struct BME_Mesh bm,
int  halt 
)
int BME_vert_in_edge ( BME_Edge e,
BME_Vert v 
)

MISC utility functions.

Definition at line 50 of file BME_structure.c.

References BME_Edge::v1, and BME_Edge::v2.

Referenced by BME_disk_append_edge(), BME_disk_next_edgeflag(), BME_disk_nextedge(), BME_JEKV(), BME_SEMV(), and BME_validate_mesh().

int BME_verts_in_edge ( struct BME_Vert v1,
struct BME_Vert v2,
struct BME_Edge e 
)

Definition at line 54 of file BME_structure.c.

References BME_Edge::v1, and BME_Edge::v2.

Referenced by BME_JEKV(), BME_loop_reverse(), BME_MF(), BME_SEMV(), and BME_validate_mesh().