BRL-CAD
#include "common.h"
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "bio.h"
#include "bu/parallel.h"
#include "vmath.h"
#include "nmg.h"
#include "raytrace.h"
#include "plot3.h"
Include dependency graph for nmg_tri_mc.c:

Go to the source code of this file.

Data Structures

struct  whack
 
struct  mci_s
 

Macros

#define MAX_INTERSECTS   1024
 
#define VOODOO   10010.001
 
#define INHIT   1
 
#define OUTHIT   2
 
#define NOHIT   -1
 
#define MEH(A, I, O)
 
#define MUH(a, l)   if (bitdiff(pv, edge_vertex[a][0], edge_vertex[a][1])) { VMOVE(edges[a], l->hit); l++; } /* we already have ray intersect data for these. */
 
#define MEH(A, B, C)   if (bitdiff(pv, B, C)) rt_nmg_mc_crosspew(a, A, p+B, edges, muh, step, tol)
 
#define MEH(A, B, C, D)   if (NEAR_EQUAL(edges[B][Z], p[A][Z], tol->dist)) { VMOVE(edges[C], p[A]); VMOVE(edges[D], p[A]); }
 

Functions

int rt_tri_mc_realize_cube (fastf_t *tris, int pv, point_t *edges)
 
int nmg_mc_realize_cube (struct shell *s, int pv, point_t *edges, const struct bn_tol *tol)
 
HIDDEN fastf_t bin (fastf_t val, fastf_t step)
 
HIDDEN int bangbang (struct application *a, struct partition *PartHeadp, struct seg *s)
 
HIDDEN int missed (struct application *a)
 
HIDDEN int bitdiff (unsigned char t, unsigned char a, unsigned char b)
 
HIDDEN int rt_nmg_mc_crosspew (struct application *a, int edge, point_t *p, point_t *edges, struct whack *muh, const fastf_t step, const struct bn_tol *tol)
 
HIDDEN int rt_nmg_mc_pew (struct shell *s, struct whack *primp[4], struct application *a, fastf_t x, fastf_t y, fastf_t b, fastf_t step, const struct bn_tol *tol)
 
HIDDEN void fire_row (int cpu, void *ptr)
 
int nmg_mc_evaluate (struct shell *s, struct rt_i *rtip, const struct db_full_path *pathp, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
 
void nmg_triangulate_model_mc (struct model *m, const struct bn_tol *tol)
 

Variables

int marching_cubes_use_midpoint = 0
 
HIDDEN int mc_tris [256][16]
 
HIDDEN int edge_vertex [12][2]
 
HIDDEN point_t point_offset [8]
 

Detailed Description

Triangulate the faces of a polygonal NMG using the marching cubes algorithm.

Vertex and edge indices (note that it seems rotated 90 degrees from the stuff you see on the sources. They used OpenGL coordinates, we use BRL-CAD.) 4 4--------—5 8/| 9/| / | 0 / | 0--------—1 |5 | |7 | | | | 6 1| | 3| 7-----—|–6 | / | / |/11 |/10 3--------—2 2

Definition in file nmg_tri_mc.c.

Macro Definition Documentation

#define MAX_INTERSECTS   1024

Definition at line 81 of file nmg_tri_mc.c.

Referenced by bangbang(), fire_row(), and rt_nmg_mc_crosspew().

#define VOODOO   10010.001

Definition at line 83 of file nmg_tri_mc.c.

Referenced by fire_row(), rt_nmg_mc_crosspew(), and rt_nmg_mc_pew().

#define INHIT   1

Definition at line 463 of file nmg_tri_mc.c.

Referenced by bangbang().

#define OUTHIT   2

Definition at line 464 of file nmg_tri_mc.c.

Referenced by bangbang().

#define NOHIT   -1

Definition at line 465 of file nmg_tri_mc.c.

Referenced by bangbang(), and missed().

#define MEH (   A,
  I,
 
)
Value:
if (primp[A][1].in > 0 && primp[A][1].hit[Z] < b+step+tol->dist) primp[A]+=2; \
if (primp[A]->hit[Z] < b+step+tol->dist) { \
if (primp[A]->in==1) { in[A]=1; pv |= 1<<I;} \
if (primp[A]->in==2) { in[A]=0; pv |= 1<<O;} \
} else pv |= in[A]<<I | in[A]<<O;
Definition: raytrace.h:248
if(share_geom)
Definition: nmg_mod.c:3829
#define A
Definition: msr.c:51
Definition: color.c:51

Referenced by rt_nmg_mc_pew().

#define MUH (   a,
 
)    if (bitdiff(pv, edge_vertex[a][0], edge_vertex[a][1])) { VMOVE(edges[a], l->hit); l++; } /* we already have ray intersect data for these. */

Referenced by rt_nmg_mc_pew().

#define MEH (   A,
  B,
  C 
)    if (bitdiff(pv, B, C)) rt_nmg_mc_crosspew(a, A, p+B, edges, muh, step, tol)
#define MEH (   A,
  B,
  C,
 
)    if (NEAR_EQUAL(edges[B][Z], p[A][Z], tol->dist)) { VMOVE(edges[C], p[A]); VMOVE(edges[D], p[A]); }

Function Documentation

int rt_tri_mc_realize_cube ( fastf_t tris,
int  pv,
point_t *  edges 
)

Definition at line 369 of file nmg_tri_mc.c.

References bu_log(), and mc_tris.

Here is the call graph for this function:

int nmg_mc_realize_cube ( struct shell *  s,
int  pv,
point_t *  edges,
const struct bn_tol tol 
)

Definition at line 396 of file nmg_tri_mc.c.

References bn_3pts_collinear(), bn_3pts_distinct(), bu_bomb(), bu_log(), bu_semaphore_acquire(), bu_semaphore_release(), mc_tris, memset(), nmg_calc_face_g(), nmg_cmface(), nmg_fu_planeeqn(), nmg_kfu(), nmg_vertex_gv(), RT_SEM_WORKER, and V3ARGS.

Referenced by rt_metaball_tess(), and rt_nmg_mc_pew().

Here is the call graph for this function:

HIDDEN int bangbang ( struct application a,
struct partition PartHeadp,
struct seg s 
)

Definition at line 473 of file nmg_tri_mc.c.

References application::a_ray, application::a_uptr, bu_bomb(), whack::hit, hit::hit_dist, whack::in, INHIT, MAX_INTERSECTS, NOHIT, OUTHIT, partition::pt_forw, partition::pt_inhit, partition::pt_outhit, xray::r_dir, and xray::r_pt.

Referenced by fire_row().

Here is the call graph for this function:

HIDDEN int missed ( struct application a)

Definition at line 501 of file nmg_tri_mc.c.

References application::a_uptr, whack::in, and NOHIT.

Referenced by fire_row(), and nmg_fix_decomposed_shell_normals().

HIDDEN int bitdiff ( unsigned char  t,
unsigned char  a,
unsigned char  b 
)

Definition at line 510 of file nmg_tri_mc.c.

Referenced by rt_nmg_mc_pew().

HIDDEN int rt_nmg_mc_crosspew ( struct application a,
int  edge,
point_t *  p,
point_t *  edges,
struct whack muh,
const fastf_t  step,
const struct bn_tol tol 
)

Definition at line 521 of file nmg_tri_mc.c.

References application::a_ray, bu_log(), bn_tol::dist, whack::hit, whack::in, MAX_INTERSECTS, xray::r_dir, xray::r_pt, rt_shootray(), V3ARGS, VOODOO, VSETALL, and Z.

Here is the call graph for this function:

HIDDEN int rt_nmg_mc_pew ( struct shell *  s,
struct whack primp[4],
struct application a,
fastf_t  x,
fastf_t  y,
fastf_t  b,
fastf_t  step,
const struct bn_tol tol 
)

Definition at line 552 of file nmg_tri_mc.c.

References application::a_ray, application::a_uptr, bin(), bitdiff(), bu_log(), bn_tol::dist, edge_vertex, whack::hit, whack::in, marching_cubes_use_midpoint, MEH, MUH, NEAR_ZERO, nmg_mc_realize_cube(), point_offset, xray::r_dir, VOODOO, VSET, VSETALL, X, Y, and Z.

Referenced by fire_row().

Here is the call graph for this function:

HIDDEN void fire_row ( int  cpu,
void *  ptr 
)
int nmg_mc_evaluate ( struct shell *  s,
struct rt_i rtip,
const struct db_full_path pathp,
const struct rt_tess_tol ttol,
const struct bn_tol tol 
)

Definition at line 737 of file nmg_tri_mc.c.

References rt_tess_tol::abs, bin(), bu_avail_cpus(), bu_parallel(), mci_s::count, db_path_to_string(), bn_tol::dist, mci_s::endx, mci_s::endy, fire_row(), MAX_PSW, rt_i::mdl_max, mci_s::ncpu, NEAR_ZERO, rt_tess_tol::rel, mci_s::resources, rt_gettree(), rt_init_resource(), rt_prep_parallel(), rt_i::rti_radius, mci_s::rtip, mci_s::s, s, mci_s::step, mci_s::tol, X, and Y.

Referenced by gcv_region_end_mc().

Here is the call graph for this function:

void nmg_triangulate_model_mc ( struct model *  m,
const struct bn_tol tol 
)

Definition at line 768 of file nmg_tri_mc.c.

References BN_CK_TOL, bu_log(), rt_g::NMG_debug, nmg_vmodel(), and RTG.

Referenced by ged_facetize().

Here is the call graph for this function:

Variable Documentation

int marching_cubes_use_midpoint = 0

Definition at line 86 of file nmg_tri_mc.c.

Referenced by rt_nmg_mc_pew().

HIDDEN int mc_tris[256][16]

Definition at line 98 of file nmg_tri_mc.c.

Referenced by nmg_mc_realize_cube(), and rt_tri_mc_realize_cube().

HIDDEN int edge_vertex[12][2]
Initial value:
= {
{0, 1}, {1, 2}, {2, 3}, {3, 0},
{4, 5}, {5, 6}, {6, 7}, {7, 4},
{0, 4}, {1, 5}, {2, 6}, {3, 7}}

Definition at line 357 of file nmg_tri_mc.c.

Referenced by rt_nmg_mc_pew().

HIDDEN point_t point_offset[8]
Initial value:
= {
{0, 0, 1}, {1, 0, 1}, {1, 0, 0}, {0, 0, 0},
{0, 1, 1}, {1, 1, 1}, {1, 1, 0}, {0, 1, 0}}

Definition at line 362 of file nmg_tri_mc.c.

Referenced by rt_nmg_mc_pew().