nmg_inter.c File Reference

#include "common.h"
#include <stddef.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "machine.h"
#include "vmath.h"
#include "nmg.h"
#include "raytrace.h"
#include "./debug.h"
#include "plot3.h"

Include dependency graph for nmg_inter.c:

Go to the source code of this file.

Data Structures

struct  ee_2d_state

Defines

#define ISECT_NONE   0
#define ISECT_SHARED_V   1
#define ISECT_SPLIT1   2
#define ISECT_SPLIT2   4
#define VDIST(a, b)   sqrt( (a[X]-b[X])*(a[X]-b[X]) + (a[Y]-b[Y])*(a[Y]-b[Y]) + (a[Z]-b[Z])*(a[Z]-b[Z]) )
#define VDIST_SQ(a, b)   ( (a[X]-b[X])*(a[X]-b[X]) + (a[Y]-b[Y])*(a[Y]-b[Y]) + (a[Z]-b[Z])*(a[Z]-b[Z]) )
#define MAX_FACES   200

Functions

vertexusenmg_make_dualvu (struct vertex *v, struct faceuse *fu, const struct bn_tol *tol)
vertexusenmg_enlist_vu (struct nmg_inter_struct *is, const struct vertexuse *vu, struct vertexuse *dualvu, fastf_t dist)
void nmg_isect2d_prep (struct nmg_inter_struct *is, const long int *assoc_use)
void nmg_isect2d_cleanup (struct nmg_inter_struct *is)
void nmg_isect2d_final_cleanup (void)
void nmg_isect_vert2p_face2p (struct nmg_inter_struct *is, struct vertexuse *vu1, struct faceuse *fu2)
edgeusenmg_break_eu_on_v (struct edgeuse *eu1, struct vertex *v2, struct faceuse *fu, struct nmg_inter_struct *is)
void nmg_break_eg_on_v (const struct edge_g_lseg *eg, struct vertex *v, const struct bn_tol *tol)
int nmg_isect_2colinear_edge2p (struct edgeuse *eu1, struct edgeuse *eu2, struct faceuse *fu, struct nmg_inter_struct *is, struct bu_ptbl *l1, struct bu_ptbl *l2)
int nmg_isect_edge2p_edge2p (struct nmg_inter_struct *is, struct edgeuse *eu1, struct edgeuse *eu2, struct faceuse *fu1, struct faceuse *fu2)
int nmg_isect_construct_nice_ray (struct nmg_inter_struct *is, struct faceuse *fu2)
void nmg_enlist_one_vu (struct nmg_inter_struct *is, const struct vertexuse *vu, fastf_t dist)
int nmg_isect_line2_edge2p (struct nmg_inter_struct *is, struct bu_ptbl *list, struct edgeuse *eu1, struct faceuse *fu1, struct faceuse *fu2)
void nmg_isect_line2_vertex2 (struct nmg_inter_struct *is, struct vertexuse *vu1, struct faceuse *fu1)
int nmg_isect_two_ptbls (struct nmg_inter_struct *is, const struct bu_ptbl *t1, const struct bu_ptbl *t2)
edge_g_lsegnmg_find_eg_on_line (const long int *magic_p, const fastf_t *pt, const fastf_t *dir, const struct bn_tol *tol)
int nmg_k0eu (struct vertex *v)
vertexnmg_repair_v_near_v (struct vertex *hit_v, struct vertex *v, const struct edge_g_lseg *eg1, const struct edge_g_lseg *eg2, int bomb, const struct bn_tol *tol)
vertexnmg_search_v_eg (const struct edgeuse *eu, int second, const struct edge_g_lseg *eg1, const struct edge_g_lseg *eg2, register struct vertex *hit_v, const struct bn_tol *tol)
vertexnmg_common_v_2eg (struct edge_g_lseg *eg1, struct edge_g_lseg *eg2, const struct bn_tol *tol)
int nmg_is_vertex_on_inter (struct vertex *v, struct faceuse *fu1, struct faceuse *fu2, struct nmg_inter_struct *is)
void nmg_isect_eu_verts (struct edgeuse *eu, struct vertex_g *vg1, struct vertex_g *vg2, struct bu_ptbl *verts, struct bu_ptbl *inters, const struct bn_tol *tol)
void nmg_isect_eu_eu (struct edgeuse *eu1, struct vertex_g *vg1a, struct vertex_g *vg1b, fastf_t *dir1, struct edgeuse *eu2, struct bu_ptbl *verts, struct bu_ptbl *inters, const struct bn_tol *tol)
void nmg_isect_eu_fu (struct nmg_inter_struct *is, struct bu_ptbl *verts, struct edgeuse *eu, struct faceuse *fu)
void nmg_isect_fu_jra (struct nmg_inter_struct *is, struct faceuse *fu1, struct faceuse *fu2, struct bu_ptbl *eu1_list, struct bu_ptbl *eu2_list)
void nmg_isect_line2_face2pNEW (struct nmg_inter_struct *is, struct faceuse *fu1, struct faceuse *fu2, struct bu_ptbl *eu1_list, struct bu_ptbl *eu2_list)
int nmg_is_eu_on_line3 (const struct edgeuse *eu, const fastf_t *pt, const fastf_t *dir, const struct bn_tol *tol)
edge_g_lsegnmg_find_eg_between_2fg (const struct faceuse *ofu1, const struct faceuse *fu2, const struct bn_tol *tol)
edgeusenmg_does_fu_use_eg (const struct faceuse *fu1, const long int *eg)
int rt_line_on_plane (const fastf_t *pt, const fastf_t *dir, const fastf_t *plane, const struct bn_tol *tol)
void nmg_cut_lu_into_coplanar_and_non (struct loopuse *lu, fastf_t *pl, struct nmg_inter_struct *is)
void nmg_check_radial_angles (char *str, struct shell *s, const struct bn_tol *tol)
int nmg_faces_can_be_intersected (struct nmg_inter_struct *bs, const struct faceuse *fu1, const struct faceuse *fu2, const struct bn_tol *tol)
void nmg_isect_two_generic_faces (struct faceuse *fu1, struct faceuse *fu2, const struct bn_tol *tol)
void nmg_crackshells (struct shell *s1, struct shell *s2, const struct bn_tol *tol)
int nmg_fu_touchingloops (const struct faceuse *fu)


Detailed Description

Routines to intersect two NMG regions. When complete, all loops in each region have a single classification w.r.t. the other region, i.e. all geometric intersections of the two regions have explicit topological representations.

The intersector makes sure that all geometric intersections gets recorded with explicit geometry and topology that is shared between both regions. Primary examples of this are (a) the line of intersection between two planes (faces), and (b) the point of intersection where two edges cross.

Entities of one region that are INSIDE, but not ON the other region do not become shared during the intersection process.

All point -vs- point comparisons should be done in 3D, for consistency.

Method -

Find all the points of intersection between the two regions, and insert vertices at those points, breaking edges on those new vertices as appropriate.

Call the face cutter to construct and delete edges and loops along the line of intersection, as appropriate.

There are no "user interface" routines in here.

Authors - Michael John Muuss Lee A. Butler

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

Definition in file nmg_inter.c.


Define Documentation

#define ISECT_NONE   0
 

Definition at line 81 of file nmg_inter.c.

Referenced by nmg_isect_edge2p_edge2p().

#define ISECT_SHARED_V   1
 

Definition at line 82 of file nmg_inter.c.

Referenced by nmg_isect_edge2p_edge2p().

#define ISECT_SPLIT1   2
 

Definition at line 83 of file nmg_inter.c.

Referenced by nmg_isect_edge2p_edge2p().

#define ISECT_SPLIT2   4
 

Definition at line 84 of file nmg_inter.c.

Referenced by nmg_isect_edge2p_edge2p().

#define VDIST a,
 )     sqrt( (a[X]-b[X])*(a[X]-b[X]) + (a[Y]-b[Y])*(a[Y]-b[Y]) + (a[Z]-b[Z])*(a[Z]-b[Z]) )
 

Definition at line 3584 of file nmg_inter.c.

#define VDIST_SQ a,
 )     ( (a[X]-b[X])*(a[X]-b[X]) + (a[Y]-b[Y])*(a[Y]-b[Y]) + (a[Z]-b[Z])*(a[Z]-b[Z]) )
 

Definition at line 3585 of file nmg_inter.c.

Referenced by nmg_isect_eu_fu().

#define MAX_FACES   200
 

Definition at line 6435 of file nmg_inter.c.

Referenced by nmg_check_radial_angles().


Function Documentation

void nmg_isect2d_prep struct nmg_inter_struct is,
const long int *  assoc_use
 

N M G _ I S E C T 2 D _ P R E P

To intersect two co-planar faces, project all vertices from those faces into 2D. At the moment, use a memory intensive strategy which allocates a (3d) point_t for each "index" item, and subscripts the resulting array by the vertices index number. Since additional vertices can be created as the intersection process operates, 2*maxindex items are originall allocated, as a (generous) upper bound on the amount of intersecting that might happen.

In the array, the third double of each projected vertex is set to -1 when that slot has not been filled yet, and 0 when it has been.

Definition at line 564 of file nmg_inter.c.

References bn_mat_fromto(), bu_log(), bu_malloc(), DEBUG_POLYSECT, edge_g_lseg::e_dir, edgeuse::e_p, edge_g_lseg::e_pt, faceuse::f_p, face::flip, edgeuse::g, face::g, HMOVE, face::l, edgeuse::lseg_p, edge::magic, bu_list::magic, MAT4X3PNT, MAT_DELTAS_VEC_NEG, face::max_pt, model::maxindex, nmg_inter_struct::maxindex, face::min_pt, face_g_plane::N, NMG_CK_EDGE, NMG_CK_EDGE_G_LSEG, NMG_CK_FACE_G_PLANE, NMG_CK_INTER_STRUCT, NMG_EDGEUSE_MAGIC, NMG_FACEUSE_MAGIC, nmg_find_model(), nmg_isect2d_cleanup(), face::plane_p, PLPRINT, nmg_inter_struct::proj, rt_bomb(), nmg_inter_struct::twod, VADD2SCALE, nmg_inter_struct::vert2d, VREVERSE, VSET, and Z.

Here is the call graph for this function:

struct edge_g_lseg* nmg_find_eg_on_line const long int *  magic_p,
const fastf_t pt,
const fastf_t dir,
const struct bn_tol tol
 

N M G _ F I N D _ E G _ O N _ L I N E

Do a geometric search to find an edge_g_lseg on the given line. If the fuser did it's job, there should be only one.

Definition at line 3308 of file nmg_inter.c.

References BN_CK_TOL, BU_PTBL_BASEADDR, BU_PTBL_LASTADDR, and nmg_edgeuse_on_line_tabulate().

Here is the call graph for this function:

struct vertex* nmg_search_v_eg const struct edgeuse eu,
int  second,
const struct edge_g_lseg eg1,
const struct edge_g_lseg eg2,
register struct vertex hit_v,
const struct bn_tol tol
 

Search all edgeuses referring to this vu's vertex. If the vertex is used by edges on both eg1 and eg2, then it's a "hit" between the two edge geometries. If a new hit happens at a different vertex from a previous hit, that is a fatal error.

This routine exists only as a support routine for nmg_common_v_2eg().

XXX This is a lame name.

Definition at line 3472 of file nmg_inter.c.

References BN_CK_TOL, bn_distsq_line3_pt3(), BU_LIST_FOR, BU_LIST_PNEXT_CIRC, bu_log(), vertex_g::coord, bn_tol::dist_sq, edge_g_lseg::e_dir, edge_g_lseg::e_pt, vertexuse::eu_p, edgeuse::g, edge_g_lseg::l, edgeuse::lseg_p, bu_list::magic, vertexuse::magic_p, NMG_CK_EDGE_G_LSEG, NMG_CK_EDGEUSE, NMG_CK_VERTEX, NMG_EDGEUSE_MAGIC, nmg_pr_eg(), nmg_pr_eu(), nmg_repair_v_near_v(), rt_bomb(), vertexuse::up, vertex::vg_p, VPRINT, and vertex::vu_hd.

Here is the call graph for this function:

void nmg_isect_eu_eu struct edgeuse eu1,
struct vertex_g vg1a,
struct vertex_g vg1b,
fastf_t dir1,
struct edgeuse eu2,
struct bu_ptbl verts,
struct bu_ptbl inters,
const struct bn_tol tol
 

Definition at line 3678 of file nmg_inter.c.

References BN_CK_TOL, bn_isect_lseg3_lseg3(), BU_CK_PTBL, bu_log(), bu_ptbl_ins_unique(), vertex_g::coord, edgeuse::eumate_p, edgeuse::l, bu_list::magic, NMG_CK_EDGEUSE, NMG_CK_MODEL, NMG_CK_VERTEX_G, nmg_esplit(), nmg_find_model(), nmg_find_pt_in_model(), nmg_vertex_gv(), V3ARGS, vertexuse::v_p, VBLEND2, VDOT, vertex::vg_p, VJOIN1, VSUB2, and edgeuse::vu_p.

Here is the call graph for this function:

int nmg_is_eu_on_line3 const struct edgeuse eu,
const fastf_t pt,
const fastf_t dir,
const struct bn_tol tol
 

Definition at line 4984 of file nmg_inter.c.

References BN_CK_TOL, bn_distsq_line3_pt3(), vertex_g::coord, bn_tol::dist_sq, edge_g_lseg::e_dir, edge_g_lseg::e_pt, edgeuse::eumate_p, edgeuse::g, edgeuse::lseg_p, MAGNITUDE, NMG_CK_EDGE_G_LSEG, NMG_CK_EDGEUSE, vertexuse::v_p, VDOT, vertex::vg_p, and edgeuse::vu_p.

Here is the call graph for this function:

struct edgeuse* nmg_does_fu_use_eg const struct faceuse fu1,
const long int *  eg
 

N M G _ D O E S _ F U _ U S E _ E G

See if any edgeuse in the given faceuse lies on the indicated edge geometry (edge_g). This is a topology check only.

Returns - NULL No eu Yes, here is one edgeuse that does. There may be more.

Definition at line 5170 of file nmg_inter.c.

References BU_LIST_FIRST_MAGIC, BU_LIST_FOR, bu_log(), DEBUG_BASIC, loopuse::down_hd, edgeuse::g, faceuse::lu_hd, edgeuse::magic_p, NMG_CK_EDGE_G_EITHER, NMG_CK_FACEUSE, NMG_CK_LOOPUSE, and NMG_VERTEXUSE_MAGIC.

Here is the call graph for this function:

int rt_line_on_plane const fastf_t pt,
const fastf_t dir,
const fastf_t plane,
const struct bn_tol tol
 

R T _ L I N E _ O N _ P L A N E

Returns - 1 line is on plane, within tol 0 line does not lie on the plane

Definition at line 5208 of file nmg_inter.c.

References BN_CK_TOL, bn_tol::dist, DIST_PT_PLANE, NEAR_ZERO, bn_tol::para, VDOT, VMOVE, and VUNITIZE.

void nmg_cut_lu_into_coplanar_and_non struct loopuse lu,
fastf_t pl,
struct nmg_inter_struct is
 

Definition at line 5490 of file nmg_inter.c.

References BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_FOR, bu_log(), BU_PTBL_END, BU_PTBL_GET, bu_ptbl_init(), bu_ptbl_ins(), vertex_g::coord, bn_tol::dist, DIST_PT_PLANE, loopuse::down_hd, nmg_inter_struct::fu1, faceuse::l, bu_list::magic, NMG_CK_INTER_STRUCT, NMG_CK_LOOPUSE, NMG_CK_VERTEX_G, NMG_CLASS_AinB, NMG_CLASS_AonBshared, NMG_EDGEUSE_MAGIC, nmg_find_model(), nmg_inter_struct::tol, V4ARGS, vertexuse::v_p, vertex::vg_p, and edgeuse::vu_p.

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