nmg_tri.c File Reference

#include "common.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "machine.h"
#include "vmath.h"
#include "nmg.h"
#include "raytrace.h"
#include "plot3.h"

Include dependency graph for nmg_tri.c:

Go to the source code of this file.

Data Structures

struct  pt2d
struct  trap

Defines

#define TOL_2D   1.0e-10
#define P_GT_V(_p, _v)   (((_p)->coord[Y] - (_v)->coord[Y]) > TOL_2D || (NEAR_ZERO((_p)->coord[Y] - (_v)->coord[Y], TOL_2D) && (_p)->coord[X] < (_v)->coord[X]))
#define P_LT_V(_p, _v)   (((_p)->coord[Y] - (_v)->coord[Y]) < (-TOL_2D) || (NEAR_ZERO((_p)->coord[Y] - (_v)->coord[Y], TOL_2D) && (_p)->coord[X] > (_v)->coord[X]))
#define P_GE_V(_p, _v)   (((_p)->coord[Y] - (_v)->coord[Y]) > TOL_2D || (NEAR_ZERO((_p)->coord[Y] - (_v)->coord[Y], TOL_2D) && (_p)->coord[X] <= (_v)->coord[X]))
#define P_LE_V(_p, _v)   (((_p)->coord[Y] - (_v)->coord[Y]) < (-TOL_2D) || (NEAR_ZERO((_p)->coord[Y] - (_v)->coord[Y], TOL_2D) && (_p)->coord[X] >= (_v)->coord[X]))
#define NMG_PT2D_MAGIC   0x2d2d2d2d
#define NMG_TRAP_MAGIC   0x1ab1ab
#define NMG_CK_PT2D(_p)   NMG_CKMAG(_p, NMG_PT2D_MAGIC, "pt2d")
#define NMG_CK_TRAP(_p)
#define NMG_TBL2D_MAGIC   0x3e3e3e3e
#define NMG_CK_TBL2D(_p)   NMG_CKMAG(_p, NMG_TBL2D_MAGIC, "tbl2d")
#define PT2D_NEXT(tbl, pt)   pt2d_pn(tbl, pt, 1)
#define PT2D_PREV(tbl, pt)   pt2d_pn(tbl, pt, -1)
#define POLY_SIDE   1
#define HOLE_START   2
#define POLY_START   3
#define HOLE_END   4
#define POLY_END   5
#define HOLE_POINT   6
#define POLY_POINT   7

Functions

int PvsV (struct trap *p, struct trap *v)
bu_listnmg_flatten_face (struct faceuse *fu, fastf_t *TformMat)
edgeusepick_eu (struct edgeuse *eu_p, struct faceuse *fu, fastf_t *dir, int find_max)
void nmg_find_first_last_use_of_v_in_fu (struct vertex *v, struct vertexuse **first_vu, struct vertexuse **last_vu, fastf_t *dir, struct faceuse *fu, const struct bn_tol *tol)
void nmg_triangulate_fu (struct faceuse *fu, const struct bn_tol *tol)
void nmg_triangulate_shell (struct shell *s, const struct bn_tol *tol)
void nmg_triangulate_model (struct model *m, const struct bn_tol *tol)


Detailed Description

Triangulate the faces of a polygonal NMG.

Author - Lee A. Butler

Source - The U. S. Army Research Laboratory Aberdeen Proving Ground, Maryland 21005-5068 USA

Definition in file nmg_tri.c.


Define Documentation

#define TOL_2D   1.0e-10
 

Definition at line 54 of file nmg_tri.c.

#define P_GT_V _p,
_v   )     (((_p)->coord[Y] - (_v)->coord[Y]) > TOL_2D || (NEAR_ZERO((_p)->coord[Y] - (_v)->coord[Y], TOL_2D) && (_p)->coord[X] < (_v)->coord[X]))
 

Definition at line 55 of file nmg_tri.c.

#define P_LT_V _p,
_v   )     (((_p)->coord[Y] - (_v)->coord[Y]) < (-TOL_2D) || (NEAR_ZERO((_p)->coord[Y] - (_v)->coord[Y], TOL_2D) && (_p)->coord[X] > (_v)->coord[X]))
 

Definition at line 57 of file nmg_tri.c.

#define P_GE_V _p,
_v   )     (((_p)->coord[Y] - (_v)->coord[Y]) > TOL_2D || (NEAR_ZERO((_p)->coord[Y] - (_v)->coord[Y], TOL_2D) && (_p)->coord[X] <= (_v)->coord[X]))
 

Definition at line 59 of file nmg_tri.c.

#define P_LE_V _p,
_v   )     (((_p)->coord[Y] - (_v)->coord[Y]) < (-TOL_2D) || (NEAR_ZERO((_p)->coord[Y] - (_v)->coord[Y], TOL_2D) && (_p)->coord[X] >= (_v)->coord[X]))
 

Definition at line 61 of file nmg_tri.c.

#define NMG_PT2D_MAGIC   0x2d2d2d2d
 

Definition at line 64 of file nmg_tri.c.

#define NMG_TRAP_MAGIC   0x1ab1ab
 

Definition at line 65 of file nmg_tri.c.

#define NMG_CK_PT2D _p   )     NMG_CKMAG(_p, NMG_PT2D_MAGIC, "pt2d")
 

Definition at line 66 of file nmg_tri.c.

#define NMG_CK_TRAP _p   ) 
 

Value:

{NMG_CKMAG(_p, NMG_TRAP_MAGIC, "trap");\
        if ( ! BU_LIST_PREV(bu_list, &(_p)->l) ) {\
                bu_log("%s %d bad prev pointer of trapezoid 0x%08x\n",\
                        __FILE__, __LINE__, &(_p)->l);\
                rt_bomb("NMG_CK_TRAP: aborting");\
        } else if (! BU_LIST_NEXT(bu_list, &(_p)->l) ) {\
                bu_log("%s %d bad next pointer of trapezoid 0x%08x\n",\
                        __FILE__, __LINE__, &(_p)->l);\
                rt_bomb("NMG_CL_TRAP: aborting");\
        }}

Definition at line 67 of file nmg_tri.c.

Referenced by PvsV().

#define NMG_TBL2D_MAGIC   0x3e3e3e3e
 

Definition at line 78 of file nmg_tri.c.

Referenced by nmg_flatten_face().

#define NMG_CK_TBL2D _p   )     NMG_CKMAG(_p, NMG_TBL2D_MAGIC, "tbl2d")
 

Definition at line 79 of file nmg_tri.c.

#define PT2D_NEXT tbl,
pt   )     pt2d_pn(tbl, pt, 1)
 

Definition at line 82 of file nmg_tri.c.

#define PT2D_PREV tbl,
pt   )     pt2d_pn(tbl, pt, -1)
 

Definition at line 83 of file nmg_tri.c.

#define POLY_SIDE   1
 

Definition at line 530 of file nmg_tri.c.

#define HOLE_START   2
 

Definition at line 531 of file nmg_tri.c.

Referenced by nmg_triangulate_fu().

#define POLY_START   3
 

Definition at line 532 of file nmg_tri.c.

#define HOLE_END   4
 

Definition at line 533 of file nmg_tri.c.

#define POLY_END   5
 

Definition at line 534 of file nmg_tri.c.

#define HOLE_POINT   6
 

Definition at line 535 of file nmg_tri.c.

#define POLY_POINT   7
 

Definition at line 536 of file nmg_tri.c.


Function Documentation

int PvsV struct trap p,
struct trap v
 

Definition at line 108 of file nmg_tri.c.

References pt2d::coord, NMG_CK_TRAP, trap::top, X, and Y.

struct bu_list* nmg_flatten_face struct faceuse fu,
fastf_t TformMat
 

N M G _ F L A T T E N _ F A C E

Create the 2D coordinate table for the vertexuses of a face.

--------- ----------------------------------- |pt2d --+-----> | struct pt2d.{magic,coord[3]} | --------- ----------------------------------- | struct pt2d.{magic,coord[3]} | ----------------------------------- | struct pt2d.{magic,coord[3]} | -----------------------------------

When the caller is done, nmg_free_2d_map() should be called to dispose of the map

Definition at line 432 of file nmg_tri.c.

References bn_mat_fromto(), bn_mat_print(), bu_calloc(), BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_FOR, BU_LIST_INIT, BU_LIST_MAGIC_SET, bu_log(), vertex_g::coord, DEBUG_TRI, loopuse::down_hd, edgeuse::eumate_p, faceuse::lu_hd, NMG_CK_FACEUSE, NMG_EDGEUSE_MAGIC, NMG_GET_FU_NORMAL, NMG_TBL2D_MAGIC, NMG_VERTEXUSE_MAGIC, loopuse::orientation, OT_BOOLPLACE, OT_NONE, OT_OPPOSITE, OT_SAME, OT_UNSPEC, rt_bomb(), V3ARGS, vertexuse::v_p, vertex::vg_p, and edgeuse::vu_p.

Referenced by nmg_triangulate_fu().

Here is the call graph for this function:

struct edgeuse* pick_eu struct edgeuse eu_p,
struct faceuse fu,
fastf_t dir,
int  find_max
 

Support routine for nmg_find_first_last_use_of_v_in_fu

Given and edgeuse and a faceuse, pick the use of the edge in the faceuse whose left vector has the largest/smallest dot product with the given direction vector. The parameter "find_max" determines whether we return the edgeuse with the largest (find_max != 0) or the smallest (find_max == 0) left-dot-product.

Definition at line 1311 of file nmg_tri.c.

References BU_LIST_PNEXT_CIRC, bu_log(), vertex_g::coord, edgeuse::eumate_p, nmg_find_eu_leftvec(), nmg_find_fu_of_eu(), NULL, edgeuse::radial_p, rt_bomb(), V3ARGS, vertexuse::v_p, VDOT, vertex::vg_p, VSUB2, edgeuse::vu_p, and VUNITIZE.

Referenced by nmg_find_first_last_use_of_v_in_fu().

Here is the call graph for this function:

void nmg_find_first_last_use_of_v_in_fu struct vertex v,
struct vertexuse **  first_vu,
struct vertexuse **  last_vu,
fastf_t dir,
struct faceuse fu,
const struct bn_tol tol
 

Given a pointer to a vertexuse in a face and a ray, find the "first" and "last" uses of the vertex along the ray in the face. Consider the diagram below where 4 OT_SAME loopuses meet at a single vertex. The ray enters from the upper left and proceeds to the lower right. The ray encounters vertexuse (represented by "o" below) number 1 first and vertexuse 3 last.

edge A | \ ^|| \ ||| 1||V2 ------->o|o-------> edge D --------------.-------------edge B <-------o|o<------ 4^||3 ||| \ ||| \ ||V \| | - edge C

The primary purpose of this routine is to find the vertexuses that should be the parameters to nmg_cut_loop() and nmg_join_loop().

Definition at line 1419 of file nmg_tri.c.

References BU_LIST_PNEXT_CIRC, BU_LIST_PPREV_CIRC, bu_log(), vertex_g::coord, vertexuse::eu_p, edgeuse::eumate_p, NMG_CK_EDGEUSE, NMG_CK_FACEUSE, NMG_CK_VERTEX, NMG_CK_VERTEX_G, NMG_CK_VERTEXUSE, NULL, pick_eu(), rt_bomb(), vertexuse::up, V3ARGS, vertexuse::v_p, vertex::vg_p, edgeuse::vu_p, and VUNITIZE.

Here is the call graph for this function:


Generated on Mon Sep 18 01:25:08 2006 for BRL-CAD by  doxygen 1.4.6