Blender V5.0
scanfill.cc File Reference
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BLI_memarena.h"
#include "BLI_utildefines.h"
#include "BLI_scanfill.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Macros

#define SF_EPSILON   0.00003f
#define SF_EPSILON_SQ   (SF_EPSILON * SF_EPSILON)
#define SF_VERT_NEW   0 /* all new verts have this flag set */
#define SF_VERT_AVAILABLE   1 /* available - in an edge */
#define SF_VERT_ZERO_LEN   2
#define SF_EDGE_NEW   0 /* all new edges have this flag set */
#define SF_EDGE_INTERNAL   2 /* edge is created while scan-filling */
#define SF_POLY_NEW   0 /* all polys initialized to this */
#define SF_POLY_VALID   1 /* has at least 3 verts */

Functions

static int vergscdata (const void *a1, const void *a2)
ScanFillVertBLI_scanfill_vert_add (ScanFillContext *sf_ctx, const float vec[3])
ScanFillEdgeBLI_scanfill_edge_add (ScanFillContext *sf_ctx, ScanFillVert *v1, ScanFillVert *v2)
static void addfillface (ScanFillContext *sf_ctx, ScanFillVert *v1, ScanFillVert *v2, ScanFillVert *v3)
static bool boundisect (const PolyFill *pf2, const PolyFill *pf1)
static void fill_target_map_recursive (const PolyFill *__restrict pf_list, const uint pf_len, const uint pf_target, const uint pf_test, uint *__restrict target_map)
static void mergepolysSimp (ScanFillContext *sf_ctx, PolyFill *pf1, PolyFill *pf2)
static bool testedgeside (const float v1[2], const float v2[2], const float v3[2])
static bool addedgetoscanvert (ScanFillVertLink *sc, ScanFillEdge *eed)
static ScanFillVertLink * addedgetoscanlist (ScanFillVertLink *scdata, ScanFillEdge *eed, uint len)
static bool boundinsideEV (const ScanFillEdge *eed, const ScanFillVert *eve)
static void testvertexnearedge (ScanFillContext *sf_ctx)
static void splitlist (ScanFillContext *sf_ctx, ListBase *tempve, ListBase *temped, ushort nr)
static uint scanfill (ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
void BLI_scanfill_begin (ScanFillContext *sf_ctx)
void BLI_scanfill_begin_arena (ScanFillContext *sf_ctx, MemArena *arena)
void BLI_scanfill_end (ScanFillContext *sf_ctx)
void BLI_scanfill_end_arena (ScanFillContext *sf_ctx, MemArena *arena)
uint BLI_scanfill_calc_ex (ScanFillContext *sf_ctx, const int flag, const float nor_proj[3])
uint BLI_scanfill_calc (ScanFillContext *sf_ctx, const int flag)

Detailed Description

Triangulate multiple 2D/3D polygon with support for holes, use for tessellating curves, fonts and geometry. See main function BLI_scanfill_calc

Uses sweep-line method.

Note
There is a similar API in polyfill2d.c which uses ear clipping, but has no hole support.

Definition in file scanfill.cc.

Macro Definition Documentation

◆ SF_EDGE_INTERNAL

#define SF_EDGE_INTERNAL   2 /* edge is created while scan-filling */

Definition at line 69 of file scanfill.cc.

Referenced by scanfill().

◆ SF_EDGE_NEW

#define SF_EDGE_NEW   0 /* all new edges have this flag set */

ScanFillEdge::f (status)

Definition at line 67 of file scanfill.cc.

Referenced by BLI_scanfill_edge_add(), and scanfill().

◆ SF_EPSILON

#define SF_EPSILON   0.00003f

Definition at line 56 of file scanfill.cc.

Referenced by BLI_scanfill_calc_ex(), and testvertexnearedge().

◆ SF_EPSILON_SQ

#define SF_EPSILON_SQ   (SF_EPSILON * SF_EPSILON)

Definition at line 57 of file scanfill.cc.

Referenced by testvertexnearedge().

◆ SF_POLY_NEW

#define SF_POLY_NEW   0 /* all polys initialized to this */

#PolyFill::f (status)

Definition at line 72 of file scanfill.cc.

Referenced by BLI_scanfill_calc_ex(), and scanfill().

◆ SF_POLY_VALID

#define SF_POLY_VALID   1 /* has at least 3 verts */

Definition at line 73 of file scanfill.cc.

Referenced by BLI_scanfill_calc_ex().

◆ SF_VERT_AVAILABLE

#define SF_VERT_AVAILABLE   1 /* available - in an edge */

Definition at line 61 of file scanfill.cc.

Referenced by BLI_scanfill_calc_ex(), and scanfill().

◆ SF_VERT_NEW

#define SF_VERT_NEW   0 /* all new verts have this flag set */

ScanFillVert::f (status)

Definition at line 60 of file scanfill.cc.

Referenced by BLI_scanfill_vert_add(), and scanfill().

◆ SF_VERT_ZERO_LEN

#define SF_VERT_ZERO_LEN   2

Definition at line 62 of file scanfill.cc.

Referenced by scanfill().

Function Documentation

◆ addedgetoscanlist()

ScanFillVertLink * addedgetoscanlist ( ScanFillVertLink * scdata,
ScanFillEdge * eed,
uint len )
static

◆ addedgetoscanvert()

bool addedgetoscanvert ( ScanFillVertLink * sc,
ScanFillEdge * eed )
static

◆ addfillface()

◆ BLI_scanfill_begin()

void BLI_scanfill_begin ( ScanFillContext * sf_ctx)

◆ BLI_scanfill_begin_arena()

void BLI_scanfill_begin_arena ( ScanFillContext * sf_ctx,
MemArena * arena )

◆ BLI_scanfill_calc()

uint BLI_scanfill_calc ( ScanFillContext * sf_ctx,
const int flag )

Definition at line 1131 of file scanfill.cc.

References BLI_scanfill_calc_ex(), and flag.

◆ BLI_scanfill_calc_ex()

◆ BLI_scanfill_edge_add()

◆ BLI_scanfill_end()

◆ BLI_scanfill_end_arena()

◆ BLI_scanfill_vert_add()

◆ boundinsideEV()

bool boundinsideEV ( const ScanFillEdge * eed,
const ScanFillVert * eve )
static

Return true if eve inside the bound-box of eed.

Definition at line 345 of file scanfill.cc.

References ScanFillEdge::v1, ScanFillEdge::v2, and ScanFillVert::xy.

Referenced by testvertexnearedge().

◆ boundisect()

bool boundisect ( const PolyFill * pf2,
const PolyFill * pf1 )
static

Definition at line 157 of file scanfill.cc.

References pf2.

Referenced by fill_target_map_recursive().

◆ fill_target_map_recursive()

void fill_target_map_recursive ( const PolyFill *__restrict pf_list,
const uint pf_len,
const uint pf_target,
const uint pf_test,
uint *__restrict target_map )
static

◆ mergepolysSimp()

void mergepolysSimp ( ScanFillContext * sf_ctx,
PolyFill * pf1,
PolyFill * pf2 )
static

◆ scanfill()

◆ splitlist()

void splitlist ( ScanFillContext * sf_ctx,
ListBase * tempve,
ListBase * temped,
ushort nr )
static

◆ testedgeside()

bool testedgeside ( const float v1[2],
const float v2[2],
const float v3[2] )
static

Definition at line 236 of file scanfill.cc.

References v2.

Referenced by scanfill().

◆ testvertexnearedge()

◆ vergscdata()

int vergscdata ( const void * a1,
const void * a2 )
static

Definition at line 77 of file scanfill.cc.

References ScanFillVert::xy.

Referenced by addedgetoscanlist(), and scanfill().