2011-02-18 13:58:08 +00:00
|
|
|
/*
|
2008-12-20 10:02:00 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-20 10:02:00 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLI_SCANFILL_H__
|
|
|
|
#define __BLI_SCANFILL_H__
|
2008-12-20 10:02:00 +00:00
|
|
|
|
2011-10-22 15:35:49 +00:00
|
|
|
/** \file BLI_scanfill.h
|
2011-02-18 13:58:08 +00:00
|
|
|
* \ingroup bli
|
|
|
|
* \since March 2001
|
|
|
|
* \author nzc
|
|
|
|
* \brief Filling meshes.
|
|
|
|
*/
|
|
|
|
|
2012-02-19 22:17:30 +00:00
|
|
|
struct ScanFillVert;
|
2008-12-20 10:02:00 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
typedef struct ScanFillContext {
|
2012-04-16 06:48:57 +00:00
|
|
|
ListBase fillvertbase;
|
|
|
|
ListBase filledgebase;
|
|
|
|
ListBase fillfacebase;
|
|
|
|
|
|
|
|
/* private */
|
|
|
|
struct ScanFillVertLink *_scdata;
|
2013-08-28 02:07:54 +00:00
|
|
|
struct MemArena *arena;
|
2012-04-16 06:48:57 +00:00
|
|
|
} ScanFillContext;
|
|
|
|
|
2013-10-10 18:18:13 +00:00
|
|
|
#define BLI_SCANFILL_ARENA_SIZE MEM_SIZE_OPTIMAL(1 << 14)
|
2013-08-28 02:07:54 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
typedef struct ScanFillVert {
|
2012-02-19 22:17:30 +00:00
|
|
|
struct ScanFillVert *next, *prev;
|
|
|
|
union {
|
|
|
|
struct ScanFillVert *v;
|
2012-04-18 14:30:57 +00:00
|
|
|
void *p;
|
2012-07-11 18:17:48 +00:00
|
|
|
intptr_t l;
|
|
|
|
unsigned int u;
|
2012-02-19 22:17:30 +00:00
|
|
|
} tmp;
|
2013-08-28 02:07:54 +00:00
|
|
|
float co[3]; /* vertex location */
|
|
|
|
float xy[2]; /* 2D projection of vertex location */
|
|
|
|
unsigned int keyindex; /* index, caller can use how it likes to match the scanfill result with own data */
|
2013-09-01 03:37:45 +00:00
|
|
|
unsigned short poly_nr;
|
2013-02-21 17:15:55 +00:00
|
|
|
unsigned char edge_tot; /* number of edges using this vertex */
|
|
|
|
unsigned char f;
|
2012-02-19 22:17:30 +00:00
|
|
|
} ScanFillVert;
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
typedef struct ScanFillEdge {
|
2012-02-19 22:17:30 +00:00
|
|
|
struct ScanFillEdge *next, *prev;
|
|
|
|
struct ScanFillVert *v1, *v2;
|
2013-09-01 03:37:45 +00:00
|
|
|
unsigned short poly_nr;
|
2012-02-19 22:17:30 +00:00
|
|
|
unsigned char f;
|
2012-07-12 08:34:59 +00:00
|
|
|
union {
|
|
|
|
unsigned char c;
|
|
|
|
} tmp;
|
2012-02-19 22:17:30 +00:00
|
|
|
} ScanFillEdge;
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
typedef struct ScanFillFace {
|
2012-02-19 22:17:30 +00:00
|
|
|
struct ScanFillFace *next, *prev;
|
|
|
|
struct ScanFillVert *v1, *v2, *v3;
|
|
|
|
} ScanFillFace;
|
|
|
|
|
2013-08-28 02:07:54 +00:00
|
|
|
/* scanfill.c */
|
2012-05-05 00:23:55 +00:00
|
|
|
struct ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3]);
|
|
|
|
struct ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, struct ScanFillVert *v1, struct ScanFillVert *v2);
|
2011-04-16 23:58:49 +00:00
|
|
|
|
2012-11-26 23:18:04 +00:00
|
|
|
enum {
|
|
|
|
BLI_SCANFILL_CALC_QUADTRI_FASTPATH = (1 << 0),
|
|
|
|
|
|
|
|
/* note: using BLI_SCANFILL_CALC_REMOVE_DOUBLES
|
|
|
|
* Assumes ordered edges, otherwise we risk an eternal loop
|
|
|
|
* removing double verts. - campbell */
|
|
|
|
BLI_SCANFILL_CALC_REMOVE_DOUBLES = (1 << 1),
|
2012-12-27 06:39:27 +00:00
|
|
|
|
|
|
|
/* note: This flag removes checks for overlapping polygons.
|
2013-01-07 03:24:22 +00:00
|
|
|
* when this flag is set, we'll never get back more faces then (totvert - 2) */
|
2014-02-04 02:54:19 +11:00
|
|
|
BLI_SCANFILL_CALC_HOLES = (1 << 2),
|
|
|
|
|
|
|
|
/* checks valid edge users - can skip for simple loops */
|
|
|
|
BLI_SCANFILL_CALC_LOOSE = (1 << 3),
|
2012-11-26 23:18:04 +00:00
|
|
|
};
|
2013-04-10 23:52:07 +00:00
|
|
|
void BLI_scanfill_begin(ScanFillContext *sf_ctx);
|
2013-09-01 03:37:45 +00:00
|
|
|
unsigned int BLI_scanfill_calc(ScanFillContext *sf_ctx, const int flag);
|
|
|
|
unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag,
|
2013-04-10 23:52:07 +00:00
|
|
|
const float nor_proj[3]);
|
2012-05-05 00:23:55 +00:00
|
|
|
void BLI_scanfill_end(ScanFillContext *sf_ctx);
|
2008-12-20 10:02:00 +00:00
|
|
|
|
2013-08-28 02:07:54 +00:00
|
|
|
void BLI_scanfill_begin_arena(ScanFillContext *sf_ctx, struct MemArena *arena);
|
|
|
|
void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, struct MemArena *arena);
|
|
|
|
|
2008-12-20 10:02:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|