BRL-CAD
#include "common.h"
#include <math.h>
#include "bio.h"
#include "vmath.h"
#include "nmg.h"
#include "raytrace.h"
#include "plot3.h"
Include dependency graph for nmg_class.c:

Go to the source code of this file.

Data Structures

struct  neighbor
 

Macros

#define MAX_DIR_TRYS   10
 
#define INSIDE   32
 
#define ON_SURF   64
 
#define OUTSIDE   128
 

Functions

const char * nmg_class_status (int status)
 
void nmg_pr_class_status (char *prefix, int status)
 
int nmg_class_lu_fu (const struct loopuse *lu, const struct bn_tol *tol)
 
int nmg_class_pt_s (const fastf_t *pt, const struct shell *s, const int in_or_out_only, const struct bn_tol *tol)
 
int nmg_2lu_identical (const struct edgeuse *eu1, const struct edgeuse *eu2)
 
void nmg_reclassify_lu_eu (struct loopuse *lu, char **classlist, int newclass)
 
void nmg_class_shells (struct shell *sA, struct shell *sB, char **classlist, const struct bn_tol *tol)
 
int nmg_classify_pt_loop (const point_t pt, const struct loopuse *lu, const struct bn_tol *tol)
 
int nmg_get_interior_pt (fastf_t *pt, const struct loopuse *lu, const struct bn_tol *tol)
 
int nmg_classify_lu_lu (const struct loopuse *lu1, const struct loopuse *lu2, const struct bn_tol *tol)
 
int nmg_classify_s_vs_s (struct shell *s2, struct shell *s, const struct bn_tol *tol)
 

Variables

int nmg_class_nothing_broken
 

Detailed Description

Subroutines to classify one object with respect to another. Possible classifications are AinB, AoutB, AinBshared, AinBanti.

The first set of routines (nmg_class_pt_xxx) are used to classify an arbitrary point specified by its Cartesian coordinates, against various kinds of NMG elements. nmg_class_pt_f() and nmg_class_pt_s() are available to applications programmers for direct use, and have no side effects.

The second set of routines (class_xxx_vs_s) are used only to support the routine nmg_class_shells() mid-way through the NMG Boolean algorithm. These routines operate with special knowledge about the state of the data structures after the intersector has been called, and depends on all geometric equivalences to have been converted into shared topology.

Definition in file nmg_class.c.

Macro Definition Documentation

#define MAX_DIR_TRYS   10

Definition at line 54 of file nmg_class.c.

Referenced by nmg_class_pt_s().

#define INSIDE   32
#define ON_SURF   64

Definition at line 58 of file nmg_class.c.

Referenced by nmg_class_status().

#define OUTSIDE   128

Function Documentation

const char* nmg_class_status ( int  status)

Convert classification status to string.

Definition at line 96 of file nmg_class.c.

References INSIDE, ON_SURF, and OUTSIDE.

Referenced by nmg_pr_class_status().

void nmg_pr_class_status ( char *  prefix,
int  status 
)

Definition at line 111 of file nmg_class.c.

References bu_log(), and nmg_class_status().

Here is the call graph for this function:

int nmg_class_lu_fu ( const struct loopuse *  lu,
const struct bn_tol tol 
)

This is intended as an internal routine to support nmg_lu_reorient().

Given a loopuse in a face, pick one of its vertexuses, and classify that point with respect to all the rest of the loopuses in the face. The containment status of that point is the status of the loopuse.

If the first vertex chosen is "ON" another loop boundary, choose the next vertex and try again. Only return an "ON" status if all the vertices are ON.

The point is "A", and the face is "B".

Returns - NMG_CLASS_AinB lu is INSIDE the area of the face. NMG_CLASS_AonBshared ALL of lu is ON other loop boundaries. NMG_CLASS_AoutB lu is OUTSIDE the area of the face.

Called by - nmg_mod.c, nmg_lu_reorient()

Definition at line 503 of file nmg_class.c.

References BN_CK_TOL, BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_PNEXT_CIRC, bu_log(), bn_tol::dist, NMG_CK_LOOPUSE(), nmg_class_name(), nmg_class_pt_fu_except(), rt_g::NMG_debug, NMG_VERTEXUSE_MAGIC, RTG, V3ARGS, and VPRINT.

Here is the call graph for this function:

int nmg_class_pt_s ( const fastf_t pt,
const struct shell *  s,
const int  in_or_out_only,
const struct bn_tol tol 
)

This is intended as a general user interface routine. Given the Cartesian coordinates for a point in space, return the classification for that point with respect to a shell.

The algorithm used is to fire a ray from the point, and count the number of times it crosses a face.

The flag "in_or_out_only" specifies that the point is known to not be on the shell, therefore only returns of NMG_CLASS_AinB or NMG_CLASS_AoutB are acceptable.

The point is "A", and the face is "B".

Returns - NMG_CLASS_AinB pt is INSIDE the volume of the shell. NMG_CLASS_AonBshared pt is ON the shell boundary. NMG_CLASS_AoutB pt is OUTSIDE the volume of the shell.

Definition at line 618 of file nmg_class.c.

References BN_CK_TOL, bn_dist_pt3_pt3(), bu_bomb(), bu_calloc(), bu_free(), BU_LIST_FOR, bu_log(), bn_tol::dist, MAX_DIR_TRYS, NMG_CK_SHELL(), nmg_class_name(), nmg_class_pt_fu_except(), nmg_class_ray_vs_shell(), rt_g::NMG_debug, nmg_model_bb(), out, xray::r_dir, xray::r_pt, RTG, V3ARGS, X, Y, and Z.

Referenced by nmg_assoc_void_shells(), and nmg_classify_s_vs_s().

Here is the call graph for this function:

int nmg_2lu_identical ( const struct edgeuse *  eu1,
const struct edgeuse *  eu2 
)

Given two edgeuses in different faces that share a common edge, determine if they are from identical loops or not.

Note that two identical loops in an anti-shared pair of faces (faces with opposite orientations) will also have opposite orientations.

Returns - 0 Loops not identical 1 Loops identical, faces are ON-shared 2 Loops identical, faces are ON-anti-shared 3 Loops identical, at least one is a wire loop.

Definition at line 1156 of file nmg_class.c.

References bu_bomb(), BU_LIST_PNEXT_CIRC, bu_log(), eu1, NMG_CK_LOOPUSE(), rt_g::NMG_debug, NMG_FACEUSE_MAGIC, nmg_pr_fu_briefly(), out, RTG, and SMALL_FASTF.

Here is the call graph for this function:

void nmg_reclassify_lu_eu ( struct loopuse *  lu,
char **  classlist,
int  newclass 
)

Make all the edges and vertices of a loop carry the same classification as the loop. There is no intrinsic way to tell if an edge is "shared" or "antishared", except by reference to its loopuse, but the heritage of the edgeuse makes a difference to the boolean evaluator.

"newclass" should only be AonBshared or AonBanti.

Definition at line 1258 of file nmg_class.c.

References bu_bomb(), BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_FOR, bu_log(), NMG_CK_LOOPUSE(), nmg_class_name(), rt_g::NMG_debug, NMG_VERTEXUSE_MAGIC, RTG, and OSL::Strings::v.

Here is the call graph for this function:

void nmg_class_shells ( struct shell *  sA,
struct shell *  sB,
char **  classlist,
const struct bn_tol tol 
)

Classify one shell WRT the other shell

Implicit return - Each element's classification will be represented by a SET entry in the appropriate classlist[] array.

Called by - nmg_bool.c

Definition at line 1975 of file nmg_class.c.

References BN_CK_TOL, BU_LIST_FIRST, BU_LIST_NON_EMPTY, BU_LIST_NOT_HEAD, BU_LIST_PNEXT, BU_LIST_PNEXT_PNEXT, bu_log(), lu, NMG_CK_SHELL(), rt_g::NMG_debug, and RTG.

Here is the call graph for this function:

int nmg_classify_pt_loop ( const point_t  pt,
const struct loopuse *  lu,
const struct bn_tol tol 
)

A generally available interface to nmg_class_pt_l

returns the classification from nmg_class_pt_l or a (-1) on error

Called by - nmg_extrude.c / nmg_fix_overlapping_loops()

XXX DANGER: Calls nmg_class_pt_l(), which does not work well.

Definition at line 2050 of file nmg_class.c.

References BN_CK_TOL, bu_log(), neighbor::dist, bn_tol::dist, neighbor::eu, MAX_FASTF, NMG_CK_LOOPUSE(), neighbor::nmg_class, NMG_FACEUSE_MAGIC, neighbor::p, and V3ARGS.

Referenced by nmg_fix_overlapping_loops().

Here is the call graph for this function:

int nmg_get_interior_pt ( fastf_t pt,
const struct loopuse *  lu,
const struct bn_tol tol 
)

Find any point that is interior to LU

Returns: 0 - All is well 1 - Loop is not part of a faceuse 2 - Loop is a single vertexuse 3 - Loop is a crack 4 - Just plain can't find an interior point

Definition at line 2101 of file nmg_class.c.

References BN_CK_TOL, BU_LIST_FIRST_MAGIC, BU_LIST_FOR, bu_log(), bn_tol::dist, NMG_CK_LOOPUSE(), nmg_class_pt_lu_except(), rt_g::NMG_debug, NMG_EDGEUSE_MAGIC, NMG_FACEUSE_MAGIC, nmg_find_eu_leftvec(), nmg_loop_is_a_crack(), nmg_pr_lu_briefly(), RTG, and VSETALL.

Here is the call graph for this function:

int nmg_classify_lu_lu ( const struct loopuse *  lu1,
const struct loopuse *  lu2,
const struct bn_tol tol 
)

Generally available classifier for determining if one loop is within another

returns classification based on nmg_class_pt_l results

Called by - nmg_misc.c / nmg_split_loops_handler()

Definition at line 2205 of file nmg_class.c.

References BN_CK_TOL, bu_bomb(), BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_FOR, BU_LIST_NOT_HEAD, BU_LIST_PNEXT, BU_LIST_PNEXT_CIRC, BU_LIST_PPREV_CIRC, bu_log(), eu1, eu2, NMG_CK_LOOPUSE(), nmg_class_name(), nmg_class_pt_lu_except(), rt_g::NMG_debug, NMG_EDGEUSE_MAGIC, NMG_FACEUSE_MAGIC, nmg_find_eu_leftvec(), nmg_find_vertex_in_lu(), NMG_VERTEXUSE_MAGIC, RTG, and SMALL_FASTF.

Referenced by insert_above(), insert_node(), nmg_rm_redundancies(), and nmg_split_loops_handler().

Here is the call graph for this function:

int nmg_classify_s_vs_s ( struct shell *  s2,
struct shell *  s,
const struct bn_tol tol 
)

Classify one shell (s2) with respect to another (s).

returns: NMG_CLASS_AinB if s2 is inside s NMG_CLASS_AoutB is s2 is outside s NMG_CLASS_Unknown if we can't tell

Assumes (but does not verify) that these two shells do not overlap, but are either entirely separate or entirely within one or the other.

Definition at line 2500 of file nmg_class.c.

References BU_LIST_FIRST, BU_LIST_NON_EMPTY, BU_PTBL_END, bu_ptbl_free(), BU_PTBL_GET, bu_ptbl::l, lu, bu_list::magic, nmg_class_pt_s(), nmg_vertex_tabulate(), and OSL::Strings::v.

Referenced by nmg_fix_normals().

Here is the call graph for this function: