Blender  V2.93
BLI_scanfill.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
26 struct ScanFillVert;
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 typedef struct ScanFillContext {
36 
37  /* increment this value before adding each curve to skip having to calculate
38  * 'poly_nr' for edges and verts (which can take approx half scan-fill time) */
39  unsigned short poly_nr;
40 
41  /* private */
42  struct MemArena *arena;
44 
45 #define BLI_SCANFILL_ARENA_SIZE MEM_SIZE_OPTIMAL(1 << 14)
46 
52 #define SF_POLY_UNSET ((unsigned short)-1)
53 
54 typedef struct ScanFillVert {
55  struct ScanFillVert *next, *prev;
56  union {
57  struct ScanFillVert *v;
58  void *p;
59  int i;
60  unsigned int u;
61  } tmp;
63  float co[3];
65  float xy[2];
67  unsigned int keyindex;
68  unsigned short poly_nr;
70  unsigned char edge_tot;
72  unsigned int f : 4;
74  unsigned int user_flag : 4;
76 
77 typedef struct ScanFillEdge {
78  struct ScanFillEdge *next, *prev;
79  struct ScanFillVert *v1, *v2;
80  unsigned short poly_nr;
81  unsigned int f : 4; /* edge status */
82  unsigned int user_flag : 4; /* flag callers can use as they like */
83  union {
84  unsigned char c;
85  } tmp;
87 
88 typedef struct ScanFillFace {
89  struct ScanFillFace *next, *prev;
90  struct ScanFillVert *v1, *v2, *v3;
92 
93 /* scanfill.c */
94 struct ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3]);
96  struct ScanFillVert *v1,
97  struct ScanFillVert *v2);
98 
99 enum {
100  /* note: using BLI_SCANFILL_CALC_REMOVE_DOUBLES
101  * Assumes ordered edges, otherwise we risk an eternal loop
102  * removing double verts. - campbell */
104 
105  /* calculate isolated polygons */
107 
108  /* note: This flag removes checks for overlapping polygons.
109  * when this flag is set, we'll never get back more faces than (totvert - 2) */
111 
112  /* checks valid edge users - can skip for simple loops */
114 };
115 void BLI_scanfill_begin(ScanFillContext *sf_ctx);
116 unsigned int BLI_scanfill_calc(ScanFillContext *sf_ctx, const int flag);
117 unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx,
118  const int flag,
119  const float nor_proj[3]);
120 void BLI_scanfill_end(ScanFillContext *sf_ctx);
121 
122 void BLI_scanfill_begin_arena(ScanFillContext *sf_ctx, struct MemArena *arena);
123 void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, struct MemArena *arena);
124 
125 /* scanfill_utils.c */
127  ListBase *fillvertbase,
128  ListBase *filledgebase);
129 
130 #ifdef __cplusplus
131 }
132 #endif
void BLI_scanfill_begin(ScanFillContext *sf_ctx)
Definition: scanfill.c:794
struct ScanFillVert * BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3])
Definition: scanfill.c:129
struct ScanFillFace ScanFillFace
struct ScanFillEdge * BLI_scanfill_edge_add(ScanFillContext *sf_ctx, struct ScanFillVert *v1, struct ScanFillVert *v2)
Definition: scanfill.c:151
@ BLI_SCANFILL_CALC_LOOSE
Definition: BLI_scanfill.h:113
@ BLI_SCANFILL_CALC_POLYS
Definition: BLI_scanfill.h:106
@ BLI_SCANFILL_CALC_HOLES
Definition: BLI_scanfill.h:110
@ BLI_SCANFILL_CALC_REMOVE_DOUBLES
Definition: BLI_scanfill.h:103
void BLI_scanfill_end(ScanFillContext *sf_ctx)
Definition: scanfill.c:808
struct ScanFillEdge ScanFillEdge
bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx, ListBase *fillvertbase, ListBase *filledgebase)
unsigned int BLI_scanfill_calc(ScanFillContext *sf_ctx, const int flag)
Definition: scanfill.c:1160
struct ScanFillVert ScanFillVert
void BLI_scanfill_begin_arena(ScanFillContext *sf_ctx, struct MemArena *arena)
Definition: scanfill.c:801
void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, struct MemArena *arena)
Definition: scanfill.c:818
unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float nor_proj[3])
Definition: scanfill.c:828
struct ScanFillContext ScanFillContext
_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
ATTR_WARN_UNUSED_RESULT const BMVert * v2
struct MemArena * arena
Definition: BLI_scanfill.h:42
ListBase fillvertbase
Definition: BLI_scanfill.h:33
ListBase filledgebase
Definition: BLI_scanfill.h:34
unsigned short poly_nr
Definition: BLI_scanfill.h:39
ListBase fillfacebase
Definition: BLI_scanfill.h:35
struct ScanFillEdge * prev
Definition: BLI_scanfill.h:78
unsigned short poly_nr
Definition: BLI_scanfill.h:80
union ScanFillEdge::@120 tmp
struct ScanFillVert * v1
Definition: BLI_scanfill.h:79
struct ScanFillVert * v2
Definition: BLI_scanfill.h:79
unsigned char c
Definition: BLI_scanfill.h:84
unsigned int f
Definition: BLI_scanfill.h:81
struct ScanFillEdge * next
Definition: BLI_scanfill.h:78
unsigned int user_flag
Definition: BLI_scanfill.h:82
struct ScanFillFace * next
Definition: BLI_scanfill.h:89
struct ScanFillVert * v2
Definition: BLI_scanfill.h:90
struct ScanFillVert * v3
Definition: BLI_scanfill.h:90
struct ScanFillFace * prev
Definition: BLI_scanfill.h:89
struct ScanFillVert * v1
Definition: BLI_scanfill.h:90
float xy[2]
Definition: BLI_scanfill.h:65
unsigned short poly_nr
Definition: BLI_scanfill.h:68
unsigned int f
Definition: BLI_scanfill.h:72
struct ScanFillVert * next
Definition: BLI_scanfill.h:55
float co[3]
Definition: BLI_scanfill.h:63
struct ScanFillVert * v
Definition: BLI_scanfill.h:57
unsigned char edge_tot
Definition: BLI_scanfill.h:70
union ScanFillVert::@119 tmp
unsigned int user_flag
Definition: BLI_scanfill.h:74
unsigned int u
Definition: BLI_scanfill.h:60
struct ScanFillVert * prev
Definition: BLI_scanfill.h:55
unsigned int keyindex
Definition: BLI_scanfill.h:67