BRL-CAD
#include "common.h"
#include <stddef.h>
#include <math.h>
#include <string.h>
#include "bio.h"
#include "vmath.h"
#include "nmg.h"
#include "raytrace.h"
#include "nurb.h"
Include dependency graph for nmg_mk.c:

Go to the source code of this file.

Functions

struct model * nmg_mm (void)
 
struct model * nmg_mmr (void)
 
struct nmgregion * nmg_mrsv (struct model *m)
 
struct shell * nmg_msv (struct nmgregion *r)
 
struct faceuse * nmg_mf (struct loopuse *lu1)
 
struct loopuse * nmg_mlv (uint32_t *magic, struct vertex *v, int orientation)
 
struct edgeuse * nmg_me (struct vertex *v1, struct vertex *v2, struct shell *s)
 
struct edgeuse * nmg_meonvu (struct vertexuse *vu)
 
struct loopuse * nmg_ml (struct shell *s)
 
int nmg_kvu (struct vertexuse *vu)
 
int nmg_kfu (struct faceuse *fu1)
 
int nmg_klu (struct loopuse *lu1)
 
int nmg_keg (struct edgeuse *eu)
 
int nmg_keu (register struct edgeuse *eu1)
 
int nmg_ks (struct shell *s)
 
int nmg_kr (struct nmgregion *r)
 
void nmg_km (struct model *m)
 
void nmg_vertex_gv (struct vertex *v, const fastf_t *pt)
 
void nmg_vertex_g (register struct vertex *v, fastf_t x, fastf_t y, fastf_t z)
 
void nmg_vertexuse_nv (struct vertexuse *vu, const fastf_t *norm)
 
void nmg_vertexuse_a_cnurb (struct vertexuse *vu, const fastf_t *uvw)
 
void nmg_edge_g (struct edgeuse *eu)
 
void nmg_edge_g_cnurb (struct edgeuse *eu, int order, int n_knots, fastf_t *kv, int n_pts, int pt_type, fastf_t *points)
 
void nmg_edge_g_cnurb_plinear (struct edgeuse *eu)
 
int nmg_use_edge_g (struct edgeuse *eu, uint32_t *magic_p)
 
void nmg_loop_g (struct loop *l, const struct bn_tol *tol)
 
void nmg_face_g (struct faceuse *fu, const fastf_t *p)
 
void nmg_face_new_g (struct faceuse *fu, const fastf_t *pl)
 
void nmg_face_g_snurb (struct faceuse *fu, int u_order, int v_order, int n_u_knots, int n_v_knots, fastf_t *ukv, fastf_t *vkv, int n_rows, int n_cols, int pt_type, fastf_t *mesh)
 
void nmg_face_bb (struct face *f, const struct bn_tol *tol)
 
void nmg_shell_a (struct shell *s, const struct bn_tol *tol)
 
void nmg_region_a (struct nmgregion *r, const struct bn_tol *tol)
 
int nmg_demote_lu (struct loopuse *lu1)
 
int nmg_demote_eu (struct edgeuse *eu)
 
void nmg_movevu (struct vertexuse *vu, struct vertex *v)
 
void nmg_je (struct edgeuse *eudst, struct edgeuse *eusrc)
 
void nmg_unglueedge (struct edgeuse *eu)
 
void nmg_jv (register struct vertex *v1, register struct vertex *v2)
 
void nmg_jfg (struct face *f1, struct face *f2)
 
void nmg_jeg (struct edge_g_lseg *dest_eg, struct edge_g_lseg *src_eg)
 
int nmg_keu_zl (struct shell *s, const struct bn_tol *tol)
 

Detailed Description

Support routines for n-Manifold Geometry.

Naming convention nmg_m* routines "make" NMG structures. nmg_k* routines "kill" (delete) NMG structures.

in each of the above cases the letters or words following are an attempt at a mnemonic representation for what is manipulated

m Model r Region s shell f face fu faceuse l loop lu loopuse e edge eu edgeuse v vertex vu vertexuse

Rules:

edges of loops of the same face must not overlap XXX - What does "overlap" mean? ctj the "magic" member of each struct is the first item.

All routines which create and destroy the NMG data structures are contained in this module.

Definition in file nmg_mk.c.

Function Documentation

struct model* nmg_mm ( void  )

The nmg_m*() routines are used to create a topology-only object which at first has no geometry associated with it at all. A topology-only object can be used to answer questions like: is this vertex ON this shell? is this vertex ON this face? is this vertex ON this edge? Is this face ON this shell? and many more.

After the topology has been built, most applications will proceed to associate geometry with the topology, primarily by supplying Cartesian coordinates for each struct vertex, and by supplying or computing face normals for the planar faces. (Linear edge geometry is optional, as it is implicit from the vertex geometry).

Objects which have been fully populated with geometry can be used to answer questions about where things are located and how large they are.

The abstract objects are: model, nmgregion, shell, face, loop, edge and vertex. The uses of those objects are: faceuse, loopuse, edgeuse and vertexuse. Geometry can optionally be associated with the abstract objects: face_g (plane equation, bounding box) loop_g (just a bounding box, for planar faces) edge_g (to track edge subdivision heritage, for linear edges) vertex_g (Cartesian coordinates) The uses of those objects can optionally have attributes: nmgregion_a (region bounding box) [nmgregions have no uses] shell_a (shell bounding box) [shells have no uses] vertexuse_a (special surface normal, for normal interpolation)

Consider for example a simple cube.

As a topology-only object, it would have the following structures:

1 model structure This is the handle which everything else hangs on. The model structure r_hd references 1 region structure. 1 nmgregion structure. The region structure s_hd references 1 shell structure. Also, m_p references the model. 1 shell structure. The shell structure fu_hd references 12 faceuse structures. One for each side of each of the 6 faces of the cube. Also, r_p references the nmgregion. 12 faceuse structures. Each faceuse structure lu_hd references 1 loopuse structure. Also, 1 face structure and 1 faceuse structure (its mate), plus s_p references the shell. 6 face structures. Each face structure fu_p references a random choice of 1 of the two parent faceuse structures sharing this face, and is in turn referenced by that faceuse and its mate. 12 loopuse structures Each loopuse structure down_hd references 4 edgeuse structures. Also, 1 loop structure, and 1 loopuse structure (its mate). The four edgeuse structures define the perimeter of the surface area that comprises this face. Because their orientation is OT_SAME, each loopuse "claims" all the surface area inside it for the face. (OT_OPPOSITE makes a hole, claiming surface area outside). Plus, "up" references the parent object (faceuse, here). 6 loop structures Each loop structure references a random choice of 1 of its parent loopuse structures and is in turn referenced by that loopuse and its mate. 48 edgeuse structures Each edgeuse structure references 1 vertexuse structure, 1 edge structure, and 2 other edgeuse structures (its mate and the next edgeuse radial to this edgeuse). (if this edge was NOT used in another face, then the radial pointer and mate pointer would point to the SAME edgeuse) To find all edgeuses around a given edge, follow radial to mate to radial to mate until you are back to the original edgeuse. Plus, "up" references the parent object (loopuse, here). 12 edge structures Each edge structure references a random choice of one of its parent edgeuse structures and is in turn referenced by that edgeuse, the mate of that edgeuse, the radial of that edgeuse and the mate of the radial. (In this simple case of the cube, there are 4 edgeuses per edge). 48 vertexuse structures. Each vertexuse structure references one vertex structure and is in turn enrolled as a member of the linked list headed by that vertex structure. Each vertexuse is cited by exactly one edgeuse. Also, "up" references the parent object (edgeuse, here). 8 vertex structures Each vertex structure references 6 vertexuse structures via its linked list. (In the case of the cube, there are three faces meeting at each vertex, and each of those faces has two faceuse structs of one loopuse each. Each loopuse will cite the vertex via one edgeuse, so 3*2 = 6).

As well as each "use" pointing down to what it uses, the "use" points up to the structure that uses it. So working up from any abstract object or its use, the top of the tree (struct model) can be found. Working down from the struct model, all elements of the object can be visited.

The object just described contains no geometry. There is no way to tell where in space the object lies or how big it is.

To add geometry, the following structures are needed: 8 vertex_g structures each vertex_g structure contains a point in space (point_t) and is referenced by 1 vertex structure. 12 edge_g structures (completely optional) each edge_g structure contains the parametric definition of the line which contains the line segment which is the edge, given as a point in space and a direction vector. It is referenced by 1 edge structure. (In general, it is referenced by all edges sharing that line). In a simple case the point would be the same as one of the vertex_g points and the direction would be the normalized (unit) vector of the difference between the two vertex_g points. 6 loop_g structures Each loop_g structure contains a bounding box for the loop. It is referenced by 1 loop structure. 6 face_g_plane structures Each face_g_plane structure contains a plane equation and a bounding box. It is referenced by one face structure. The plane equation is calculated from the vertex_g data by nmg_fu_planeeqn(). See h/vmath.h for the definition of a plane equation. 1 shell_a structure Each shell_a structure contains the bounding box for the shell. It is referenced by 1 shell structure. 1 nmgregion_a structure Each nmgregion_a structure contains the bounding box for the region. It is referenced by 1 region structure. Make Model

Create a new model. The region list is empty. Creates a new model structure. The model region structure list is empty.

Returns - (struct model *)

"maxindex" is a misnomer. It is the value of the NEXT index assigned. This allows "ptab"s to be allocated easily using maxindex and the index value of the structures to be the actual index into the "ptab".

Definition at line 235 of file nmg_mk.c.

References BU_LIST_INIT, bu_log(), rt_g::NMG_debug, NMG_MODEL_MAGIC, and RTG.

Referenced by _ged_drawtrees(), add_solid(), brep_to_nmg(), fix_halfs(), gcv_region_end(), gcv_region_end_mc(), ged_bev(), ged_bot_fuse(), ged_facetize(), ged_fracture(), ged_make(), make_model_from_face(), nmg_booltree_leaf_tess(), nmg_clone_model(), nmg_mk_model_from_region(), nmg_mmr(), nmg_to_poly(), rt_arb_brep(), rt_arbn_brep(), rt_ars_brep(), rt_ars_prep(), rt_bot_brep(), rt_ebm_brep(), rt_nmg_ialloc(), rt_nmg_make(), rt_pg_brep(), rt_vol_brep(), rt_vol_tess(), stash_shell(), test_nmg_mm(), and testcase_nmg_mm().

Here is the call graph for this function:

struct model* nmg_mmr ( void  )

Make Model and Region.

Create a new model, and an "empty" region to go with it. Essentially this creates a minimal model system.

Returns - (struct model *)

Implicit Return - The new region is found with BU_LIST_FIRST(nmgregion, &m->r_hd);

Definition at line 268 of file nmg_mk.c.

References BU_LIST_APPEND, BU_LIST_INIT, bu_log(), rt_g::NMG_debug, nmg_mm(), NMG_REGION_MAGIC, and RTG.

Referenced by gcv_region_end_mc(), ged_shells(), test_nmg_mmr(), test_nmg_mrsv(), test_nmg_msv(), testcase_nmg_mmr(), and testcase_nmg_mrsv().

Here is the call graph for this function:

struct nmgregion* nmg_mrsv ( struct model *  m)

Make new region, shell, vertex in model as well as the required "uses". Create a new region in model consisting of a minimal shell.

Returns - (struct nmgregion *)

Implicit Returns - Region is also found with r=BU_LIST_FIRST(nmgregion, &m->r_hd); The new shell is found with s=BU_LIST_FIRST(shell, &r->s_hd); The new vertexuse is s->vu_p;

Definition at line 306 of file nmg_mk.c.

References BU_LIST_APPEND, BU_LIST_INIT, bu_log(), rt_g::NMG_debug, nmg_msv(), NMG_REGION_MAGIC, and RTG.

Referenced by brep_to_nmg(), fix_halfs(), gcv_region_end_mc(), ged_decompose(), ged_fracture(), ged_make(), make_model_from_face(), nmg_extrude_cleanup(), nmg_extrude_shell(), nmg_fix_normals(), nmg_hollow_shell(), nmg_to_poly(), rt_arb_tess(), rt_arb_tnurb(), rt_arbn_tess(), rt_ars_tess(), rt_bot_tess(), rt_cline_tess(), rt_dsp_tess(), rt_ebm_tess(), rt_ehy_tess(), rt_ell_tess(), rt_ell_tnurb(), rt_epa_tess(), rt_eto_tess(), rt_extrude_tess(), rt_hyp_tess(), rt_metaball_tess(), rt_nmg_adjust(), rt_part_tess(), rt_pg_tess(), rt_pipe_tess(), rt_rhc_tess(), rt_rpc_tess(), rt_tgc_tess(), rt_tgc_tnurb(), rt_tor_tess(), rt_vol_tess(), stash_shell(), test_nmg_mrsv(), and testcase_nmg_mrsv().

Here is the call graph for this function:

struct shell* nmg_msv ( struct nmgregion *  r)

Make Shell, Vertex Use, Vertex

Create a new shell in a specified region. The shell will consist of a single vertexuse and vertex (which are also created).

Returns - (struct shell *)

Implicit Returns - The new shell is also found with s=BU_LIST_FIRST(shell, &r->s_hd); The new vertexuse is s->vu_p;

Definition at line 423 of file nmg_mk.c.

References BU_LIST_APPEND, BU_LIST_INIT, bu_log(), rt_g::NMG_debug, NMG_SHELL_MAGIC, RTG, and s.

Referenced by nmg_decompose_shell(), nmg_dup_shell(), nmg_isect_shell_self(), nmg_mrsv(), nmg_polytonmg(), and test_nmg_msv().

Here is the call graph for this function:

struct faceuse* nmg_mf ( struct loopuse *  lu1)

Make Face from a wire loop.

make a face from a pair of loopuses. The loopuses must be direct children of a shell. The new face will be a child of the same shell.

Given a wire loop (by definition, a loop attached to a shell), create a new face, faceuse (and mate) and move the wire loop from the shell to the new faceuse (and mate).

Implicit Returns - The first faceuse is fu1=BU_LIST_FIRST(faceuse, &s->fu_hd); The second faceuse follows: fu2=BU_LIST_NEXT(faceuse, &fu1->l.magic);

Definition at line 470 of file nmg_mk.c.

References bu_bomb(), BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_INIT, bu_log(), NMG_CK_LOOPUSE(), NMG_CK_SHELL(), rt_g::NMG_debug, NMG_FACE_MAGIC, NMG_FACEUSE_MAGIC, nmg_find_model(), NMG_SHELL_MAGIC, RTG, and s.

Referenced by nmg_add_loop_to_face(), nmg_cface(), nmg_cmface(), nmg_dup_face(), nmg_dup_shell(), and nmg_mk_new_face_from_loop().

Here is the call graph for this function:

struct loopuse* nmg_mlv ( uint32_t *  magic,
struct vertex *  v,
int  orientation 
)

Make a new loop (with specified orientation) and vertex, in a shell or face. XXX - vertex or vertexuse? or both? ctj

If the vertex 'v' is NULL, the shell's lone vertex is used, or a new vertex is created.

"magic" must point to the magic number of a faceuse or shell.

If the shell has a lone vertex in it, that lone vertex will be used. If a non-NULL 'v' is provided, the lone vertex and 'v' will be fused together. XXX Why is this good?

If a convenient shell does not exist, use s=nmg_msv() to make the shell and vertex, then call lu=nmg_mlv(s, s->vu_p->v_p, OT_SAME), followed by nmg_kvu(s->vu_p).

Implicit returns - The new vertexuse can be had by: BU_LIST_FIRST(vertexuse, &lu->down_hd);

In case the returned loopuse isn't retained, the new loopuse was inserted at the +head+ of the appropriate list, e.g.: lu = BU_LIST_FIRST(loopuse, &fu->lu_hd); or lu = BU_LIST_FIRST(loopuse, &s->lu_hd);

N.B. This function is made more complex than warranted by using the "hack" of stealing a vertexuse structure from the shell if at all possible. A future enhancement to this function would be to remove the vertexuse steal and have the caller pass in the vertex from the shell followed by a call to nmg_kvu(s->vu_p). The v==NULL convention is used only in nmg_mod.c.

Definition at line 571 of file nmg_mk.c.

References bu_bomb(), BU_LIST_INIT, BU_LIST_INSERT, bu_log(), magic, magic_p, rt_g::NMG_debug, NMG_FACEUSE_MAGIC, nmg_find_model(), NMG_LOOP_MAGIC, NMG_LOOPUSE_MAGIC, nmg_movevu(), nmg_orientation(), NMG_SHELL_MAGIC, orientation, RTG, and s.

Referenced by nmg_add_loop_to_face(), nmg_cface(), nmg_cmface(), nmg_cut_loop(), nmg_demote_eu(), nmg_dup_loop(), nmg_enlist_vu(), nmg_fix_overlapping_loops(), nmg_isect_vert2p_face2p(), nmg_make_dualvu(), nmg_ml(), nmg_split_lu_at_vu(), tesselate_pipe_end(), and tesselate_pipe_start().

Here is the call graph for this function:

struct edgeuse* nmg_me ( struct vertex *  v1,
struct vertex *  v2,
struct shell *  s 
)

Make wire edge.

Make a new edge between a pair of vertices in a shell.

A new vertex will be made for any NULL vertex pointer parameters. If we need to make a new vertex and the shell still has its vertexuse we re-use that vertex rather than freeing and re-allocating.

If both vertices were specified, and the shell also had a vertexuse pointer, the vertexuse in the shell is killed. XXX Why?

Explicit Return - An edgeuse in shell "s" whose vertexuse refers to vertex v1. The edgeuse mate's vertexuse refers to vertex v2

Implicit Returns - 1) If the shell had a lone vertex in vu_p, it is destroyed, even if both vertices were specified. 2) The returned edgeuse is the first item on the shell's eu_hd list, followed immediately by the mate.

Definition at line 698 of file nmg_mk.c.

References BU_LIST_APPEND, BU_LIST_INIT, bu_log(), eu1, eu2, NMG_CK_SHELL(), rt_g::NMG_debug, NMG_EDGE_MAGIC, NMG_EDGEUSE2_MAGIC, NMG_EDGEUSE_MAGIC, nmg_find_model(), nmg_kvu(), RTG, and s.

Referenced by if(), nmg_cut_loop(), nmg_dup_shell(), nmg_vlist_to_eu(), and nmg_vlist_to_wire_edges().

Here is the call graph for this function:

struct edgeuse* nmg_meonvu ( struct vertexuse *  vu)

Make an edge on vertexuse.

The new edge runs from and to that vertex.

If the vertexuse was the shell's sole vertexuse, then the new edge is a wire edge in the shell's eu_hd list.

If the vertexuse was part of a loop-of-a-single-vertex, either as a loop in a face or as a wire-loop in the shell, the loop becomes a regular loop with one edge that runs from and to the original vertex.

Definition at line 800 of file nmg_mk.c.

References bu_bomb(), BU_LIST_APPEND, BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_INIT, bu_log(), eu1, eu2, lu, NMG_CK_LOOPUSE(), rt_g::NMG_debug, NMG_EDGE_MAGIC, NMG_EDGEUSE2_MAGIC, NMG_EDGEUSE_MAGIC, nmg_find_model(), NMG_LOOPUSE_MAGIC, NMG_SHELL_MAGIC, NMG_VERTEXUSE_MAGIC, RTG, and s.

Referenced by ged_make(), nmg_add_loop_to_face(), nmg_cface(), nmg_cmface(), nmg_dup_loop(), nmg_join_2singvu_loops(), and tesselate_pipe_start().

Here is the call graph for this function:

struct loopuse* nmg_ml ( struct shell *  s)

Make wire loop from wire edgeuse list

Passed a pointer to a shell. The wire edgeuse child of the shell is taken as the head of a list of edge(use)s which will form the new loop. The loop is created from the first N contiguous edges. Thus the end of the new loop is * delineated by the "next" edge(use)being:

A) the first object in the list (no other edgeuses in shell list) B) non-contiguous with the previous edge

A loop is created from this list of edges. The edges must form a true circuit, or we dump core on your disk. If we succeed, then the edgeuses are moved from the shell edgeuse list to the loop, and the two loopuses are inserted into the shell.

Definition at line 927 of file nmg_mk.c.

References bu_bomb(), BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_INIT, BU_LIST_INSERT, BU_LIST_IS_EMPTY, BU_LIST_NON_EMPTY, bu_log(), NMG_CK_SHELL(), rt_g::NMG_debug, nmg_find_model(), NMG_LOOP_MAGIC, NMG_LOOPUSE_MAGIC, nmg_mlv(), nmg_pr_s(), RTG, and s.

Referenced by ged_make().

Here is the call graph for this function:

int nmg_kvu ( struct vertexuse *  vu)

Kill vertexuse, and null out parent's vu_p.

This routine is not intended for general use by applications, because it requires cooperation on the part of the caller to properly dispose of or fix the now quite illegal parent. (Illegal because the parent's vu_p is NULL). It exists primarily as a support routine for "mopping up" after nmg_klu(), nmg_keu(), nmg_ks(), and nmg_mv_vu_between_shells().

It is also used in a particularly ugly way in nmg_cut_loop() and nmg_split_lu_at_vu() as part of their method for obtaining an "empty" loopuse/loop set.

It is worth noting that all these callers ignore the return code, because they all exist to intentionally empty out the parent, but the return code is provided anyway, in the name of [CTJ] symmetry.

Returns - 0 If all is well in the parent 1 If parent is empty, and is thus "illegal"

Definition at line 1095 of file nmg_mk.c.

References bu_bomb(), BU_LIST_DEQUEUE, BU_LIST_INIT, BU_LIST_IS_EMPTY, bu_log(), rt_g::NMG_debug, NMG_EDGEUSE_MAGIC, NMG_LOOPUSE_MAGIC, nmg_shell_is_empty(), NMG_SHELL_MAGIC, NMG_VERTEXUSE_A_CNURB_MAGIC, NMG_VERTEXUSE_A_PLANE_MAGIC, RTG, and OSL::Strings::v.

Referenced by nmg_cut_loop(), nmg_decompose_shell(), nmg_eval_shell(), nmg_fix_overlapping_loops(), nmg_keu(), nmg_klu(), nmg_ks(), nmg_me(), nmg_polytonmg(), nmg_split_lu_at_vu(), and nmg_triangulate_rm_degen_loopuse().

Here is the call graph for this function:

int nmg_kfu ( struct faceuse *  fu1)

Kill Faceuse

delete a faceuse and its mate from the parent shell.

Any children found are brutally murdered as well. The faceuses are dequeued from the parent shell's list here.

Returns - 0 If all is well 1 If parent shell is now empty, and is thus "illegal"

Definition at line 1207 of file nmg_mk.c.

References bu_bomb(), BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_IS_EMPTY, BU_LIST_NON_EMPTY, bu_log(), f1, f2, NMG_CK_SHELL(), rt_g::NMG_debug, nmg_klu(), nmg_shell_is_empty(), RTG, and s.

Referenced by fix_halfs(), nmg_close_shell(), nmg_edge_collapse(), nmg_eval_shell(), nmg_jf(), nmg_keu_zl(), nmg_kill_anti_loops(), nmg_kill_cracks(), nmg_kill_cracks_at_vertex(), nmg_kill_non_common_cracks(), nmg_kill_zero_length_edgeuses(), nmg_ks(), nmg_make_connect_faces(), nmg_mc_realize_cube(), nmg_remove_short_eus_inter(), nmg_rm_redundancies(), nmg_sanitize_s_lv(), nmg_simplify_shell(), nmg_simplify_shell_edges(), nmg_triangulate_shell(), rt_ars_tess(), rt_bot_tess(), tesselate_pipe_bend(), tesselate_pipe_end(), and tesselate_pipe_linear().

Here is the call graph for this function:

int nmg_klu ( struct loopuse *  lu1)

Kill loopuse, loopuse mate, and loop.

if the loop contains any edgeuses or vertexuses they are killed before the loop is deleted.

We support the concept of killing a loop with no children to support the routine "nmg_demote_lu"

Returns - 0 If all is well 1 If parent is empty, and is thus "illegal"

Definition at line 1277 of file nmg_mk.c.

References bu_bomb(), bu_identify_magic(), BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_HEAD_MAGIC, BU_LIST_IS_EMPTY, BU_LIST_NON_EMPTY, bu_log(), NMG_CK_LOOPUSE(), rt_g::NMG_debug, NMG_EDGEUSE_MAGIC, NMG_FACEUSE_MAGIC, nmg_keu(), nmg_kvu(), nmg_shell_is_empty(), NMG_SHELL_MAGIC, NMG_VERTEXUSE_MAGIC, and RTG.

Referenced by fix_halfs(), nmg_demote_lu(), nmg_edge_collapse(), nmg_eval_shell(), nmg_face_state_transition(), nmg_fix_overlapping_loops(), nmg_jl(), nmg_join_2loops(), nmg_join_2singvu_loops(), nmg_join_singvu_loop(), nmg_keu_zl(), nmg_kfu(), nmg_kill_anti_loops(), nmg_kill_cracks(), nmg_kill_cracks_at_vertex(), nmg_kill_non_common_cracks(), nmg_kill_wire_edges(), nmg_kill_zero_length_edgeuses(), nmg_ks(), nmg_remove_short_eus_inter(), nmg_rm_redundancies(), nmg_sanitize_fu(), nmg_sanitize_s_lv(), nmg_simplify_face(), nmg_simplify_shell_edges(), and nmg_triangulate_rm_degen_loopuse().

Here is the call graph for this function:

int nmg_keg ( struct edgeuse *  eu)

Internal routine to kill an edge geometry structure (of either type), if all the edgeuses on its list have vanished. Regardless, the edgeuse's geometry pointer is cleared.

This routine does only a single edgeuse. If the edgeuse mate has geometry to be killed, make a second call. Sometimes only one of the two needs to release the geometry.

Returns - 0 If the old edge geometry (eu->g.magic_p) has other uses. 1 If the old edge geometry has been destroyed. Caller beware!

NOT INTENDED FOR GENERAL USE! However, nmg_mod.c needs it for nmg_eusplit(). (Drat!)

Definition at line 1365 of file nmg_mk.c.

References bu_free(), BU_LIST_NON_EMPTY, NMG_EDGE_G_CNURB_MAGIC, and NMG_EDGE_G_LSEG_MAGIC.

Referenced by nmg_keu(), and nmg_use_edge_g().

Here is the call graph for this function:

int nmg_keu ( register struct edgeuse *  eu1)

Delete an edgeuse & its mate from a shell or loop.

Returns - 0 If all is well 1 If the parent now has no edgeuses, and is thus "illegal" and in need of being deleted. (The lu / shell deletion can't be handled at this level, and must be done by the caller).

Definition at line 1413 of file nmg_mk.c.

References bu_bomb(), BU_LIST_DEQUEUE, BU_LIST_IS_EMPTY, bu_log(), eu2, NMG_CK_LOOPUSE(), rt_g::NMG_debug, nmg_keg(), nmg_kvu(), NMG_LOOPUSE_MAGIC, nmg_shell_is_empty(), NMG_SHELL_MAGIC, and RTG.

Referenced by nmg_demote_eu(), nmg_edge_collapse(), nmg_fuse_inters(), nmg_jl(), nmg_k0eu(), nmg_keu_zl(), nmg_kill_accordions(), nmg_kill_cracks(), nmg_kill_cracks_at_vertex(), nmg_kill_non_common_cracks(), nmg_kill_snakes(), nmg_kill_wire_edges(), nmg_kill_zero_length_edgeuses(), nmg_klu(), nmg_ks(), nmg_remove_short_eus_inter(), nmg_rm_redundancies(), nmg_simplify_shell_edges(), and nmg_tri_kill_accordions().

Here is the call graph for this function:

int nmg_ks ( struct shell *  s)

Kill a shell and all children

Returns - 0 If all is well 1 If parent nmgregion is now empty. While not "illegal", an empty region is probably worthy of note.

Definition at line 1546 of file nmg_mk.c.

References BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_IS_EMPTY, BU_LIST_NON_EMPTY, bu_log(), NMG_CK_SHELL(), rt_g::NMG_debug, nmg_keu(), nmg_kfu(), nmg_klu(), nmg_kvu(), and RTG.

Referenced by do_region_end(), gcv_region_end(), gcv_region_end_mc(), ged_decompose(), nmg_do_bool(), nmg_extrude_cleanup(), nmg_extrude_shell(), nmg_fix_normals(), nmg_hollow_shell(), nmg_isect_shell_self(), nmg_js(), nmg_kill_zero_length_edgeuses(), nmg_kr(), and nmg_region_end().

Here is the call graph for this function:

int nmg_kr ( struct nmgregion *  r)

Kill a region and all shells in it.

Returns - 0 If all is well 1 If model is now empty. While not "illegal", an empty model is probably worthy of note.

Definition at line 1595 of file nmg_mk.c.

References BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_IS_EMPTY, BU_LIST_NON_EMPTY, bu_log(), rt_g::NMG_debug, nmg_ks(), and RTG.

Referenced by db_free_tree(), do_region_end(), gcv_region_end(), gcv_region_end_mc(), nmg_do_bool(), nmg_extrude_cleanup(), nmg_extrude_shell(), nmg_hollow_shell(), nmg_kill_zero_length_edgeuses(), nmg_km(), nmg_merge_regions(), and rt_arbn_tess().

Here is the call graph for this function:

void nmg_km ( struct model *  m)
void nmg_vertex_g ( register struct vertex *  v,
fastf_t  x,
fastf_t  y,
fastf_t  z 
)

a version that can take x, y, z coords and doesn't need a point array. Mostly useful for quick and dirty programs.

Definition at line 1699 of file nmg_mk.c.

References bu_log(), rt_g::NMG_debug, nmg_vertex_gv(), and RTG.

Referenced by fix_halfs(), and ged_make().

Here is the call graph for this function:

void nmg_vertexuse_nv ( struct vertexuse *  vu,
const fastf_t norm 
)

Assign a normal vector to a vertexuse

Definition at line 1719 of file nmg_mk.c.

References bu_bomb(), bu_log(), rt_g::NMG_debug, nmg_find_model(), NMG_VERTEXUSE_A_CNURB_MAGIC, NMG_VERTEXUSE_A_PLANE_MAGIC, RTG, and V3ARGS.

Referenced by rt_ehy_tess(), rt_ell_tess(), rt_epa_tess(), rt_eto_tess(), rt_hyp_tess(), rt_part_tess(), rt_rhc_tess(), rt_rpc_tess(), rt_tgc_tess(), rt_tor_tess(), tesselate_pipe_bend(), and tesselate_pipe_linear().

Here is the call graph for this function:

void nmg_vertexuse_a_cnurb ( struct vertexuse *  vu,
const fastf_t uvw 
)

Given a vertex with associated geometry in model space which lies on a face_g_snurb surface, it will have a corresponding set of (u, v) or (u, v, w) parameters on that surface. Build the association here.

Note that all vertexuses of a single vertex which are all used by the same face_g_snurb will have the same "param" value, but will have individual vertexuse_a_cnurb structures.

Definition at line 1757 of file nmg_mk.c.

References bu_bomb(), bu_log(), rt_g::NMG_debug, nmg_find_model(), NMG_VERTEXUSE_A_CNURB_MAGIC, RTG, and V3ARGS.

Referenced by rt_arb_tnurb(), rt_ell_tnurb(), and rt_tgc_tnurb().

Here is the call graph for this function:

void nmg_edge_g ( struct edgeuse *  eu)

Compute the equation of the line formed by the endpoints of the edge.

XXX This isn't the best name. nmg_edge_g_lseg() ?

Definition at line 1789 of file nmg_mk.c.

References bu_bomb(), BU_LIST_DEQUEUE, BU_LIST_INIT, BU_LIST_INSERT, bu_log(), eu2, rt_g::NMG_debug, NMG_EDGE_G_LSEG_MAGIC, nmg_find_model(), RTG, SMALL_FASTF, VPRINT, VSET, X, Y, and Z.

Referenced by nmg_dup_loop(), nmg_edge_collapse(), nmg_edge_geom_isect_line(), nmg_loop_g(), nmg_move_edge_thru_pt(), nmg_radial_join_eu_NEW(), and nmg_vlist_to_wire_edges().

Here is the call graph for this function:

void nmg_edge_g_cnurb ( struct edgeuse *  eu,
int  order,
int  n_knots,
fastf_t kv,
int  n_pts,
int  pt_type,
fastf_t points 
)

For an edgeuse associated with a face_g_snurb surface, create a spline curve in the parameter space of the snurb which describes the path from the start vertex to the end vertex.

The parameters of the end points are taken from the vertexuse attributes at either end of the edgeuse.

Definition at line 1899 of file nmg_mk.c.

References bu_bomb(), bu_calloc(), BU_LIST_DEQUEUE, BU_LIST_INIT, BU_LIST_INSERT, bu_log(), rt_g::NMG_debug, NMG_EDGE_G_CNURB_MAGIC, nmg_find_fu_of_eu(), nmg_find_model(), rt_nurb_kvknot(), and RTG.

Here is the call graph for this function:

void nmg_edge_g_cnurb_plinear ( struct edgeuse *  eu)

For an edgeuse associated with a face_g_snurb surface, create a spline "curve" in the parameter space of the snurb which describes a STRAIGHT LINE in parameter space from the u, v parameters of the start vertex to the end vertex.

The parameters of the end points are found in the vertexuse attributes at either end of the edgeuse, which should have already been established.

This is a special case of nmg_edge_g_cnurb(), and should be used when the path through parameter space is known to be a line segment. This permits the savings of a lot of memory, both in core and on disk, by eliminating a knot vector (typ. 64 bytes or more) and a ctl_point[] array (typ. 16 bytes or more).

This special condition is indicated by order == 0. See nmg.h for details.

Definition at line 2019 of file nmg_mk.c.

References bu_bomb(), BU_LIST_DEQUEUE, BU_LIST_INIT, BU_LIST_INSERT, bu_log(), rt_g::NMG_debug, NMG_EDGE_G_CNURB_MAGIC, nmg_find_fu_of_eu(), nmg_find_model(), and RTG.

Referenced by rt_arb_tnurb(), and rt_ell_tnurb().

Here is the call graph for this function:

int nmg_use_edge_g ( struct edgeuse *  eu,
uint32_t *  magic_p 
)

Associate edgeuse 'eu' with the edge_g_X structure given as 'magic_p'. If the edgeuse is already associated with some geometry, release that first. Note that, to start with, the two edgeuses may be using different original geometries.

Also do the edgeuse mate.

Returns - 0 If the old edge geometry (eu->g.magic_p) has other uses. 1 If the old edge geometry has been destroyed. Caller beware!

Definition at line 2087 of file nmg_mk.c.

References bu_bomb(), BU_LIST_DEQUEUE, BU_LIST_INSERT, bu_log(), magic_p, rt_g::NMG_debug, nmg_keg(), and RTG.

Referenced by nmg_edge_geom_isect_line(), nmg_jeg(), nmg_radial_join_eu(), and nmg_radial_join_eu_NEW().

Here is the call graph for this function:

void nmg_loop_g ( struct loop *  l,
const struct bn_tol tol 
)

Build the bounding box for a loop.

The bounding box is guaranteed never to have zero thickness.

XXX This really isn't loop geometry, this is a loop attribute. This routine really should be called nmg_loop_bb(), unless it gets something more to do.

Definition at line 2152 of file nmg_mk.c.

References BN_CK_TOL, bu_bomb(), bu_identify_magic(), BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_FOR, bu_log(), bn_tol::dist, lu, NEAR_ZERO, NMG_CK_LOOPUSE(), rt_g::NMG_debug, nmg_edge_g(), NMG_EDGEUSE_MAGIC, nmg_find_model(), NMG_LOOP_G_MAGIC, NMG_VERTEXUSE_MAGIC, RTG, VSETALL, X, Y, and Z.

Referenced by nmg_cut_lu_into_coplanar_and_non(), nmg_enlist_vu(), nmg_face_bb(), nmg_face_state_transition(), nmg_fcut_face(), nmg_isect_vert2p_face2p(), nmg_loop_split_at_touching_jaunt(), nmg_lu_is_convex(), nmg_make_connect_faces(), nmg_make_dualvu(), nmg_rebound(), nmg_shell_a(), and nmg_split_touchingloops().

Here is the call graph for this function:

void nmg_face_g ( struct faceuse *  fu,
const fastf_t p 
)

Assign plane equation to face. XXX Should probably be called nmg_face_g_plane()

In the interest of modularity this no longer calls nmg_face_bb().

Definition at line 2235 of file nmg_mk.c.

References BU_LIST_APPEND, BU_LIST_INIT, bu_log(), rt_g::NMG_debug, NMG_FACE_G_PLANE_MAGIC, nmg_find_model(), and RTG.

Referenced by nmg_calc_face_g(), nmg_close_shell(), nmg_dup_face(), nmg_dup_shell(), nmg_extrude_shell(), nmg_face_new_g(), nmg_fu_planeeqn(), nmg_make_connect_faces(), nmg_move_edge_thru_pt(), nmg_polytonmg(), nmg_split_loops_handler(), nmg_translate_face(), rt_arb_tess(), and rt_extrude_tess().

Here is the call graph for this function:

void nmg_face_new_g ( struct faceuse *  fu,
const fastf_t pl 
)

Assign plane equation to this face. If other faces use current geometry for this face, then make a new geometry for this face.

Definition at line 2281 of file nmg_mk.c.

References BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_FOR, BU_LIST_INIT, bu_log(), rt_g::NMG_debug, nmg_face_g(), NMG_FACE_G_PLANE_MAGIC, nmg_find_model(), and RTG.

Referenced by nmg_make_faces_within_tol().

Here is the call graph for this function:

void nmg_face_g_snurb ( struct faceuse *  fu,
int  u_order,
int  v_order,
int  n_u_knots,
int  n_v_knots,
fastf_t ukv,
fastf_t vkv,
int  n_rows,
int  n_cols,
int  pt_type,
fastf_t mesh 
)

Create a new NURBS surface to be the geometry for an NMG face.

If either of the knot vector arrays or the ctl_points arrays are given as non-null, then simply swipe the caller's arrays. The caller must have allocated them with bu_malloc() or malloc(). If the pointers are NULL, then the necessary storage is allocated here.

This is the NMG parallel to rt_nurb_new_snurb().

Definition at line 2347 of file nmg_mk.c.

References bu_bomb(), bu_calloc(), BU_LIST_APPEND, BU_LIST_INIT, bu_log(), rt_g::NMG_debug, NMG_FACE_G_SNURB_MAGIC, nmg_find_model(), NMG_KNOT_VECTOR_MAGIC, and RTG.

Referenced by nmg_dup_face(), nmg_sphere_face_snurb(), and rt_arb_tnurb().

Here is the call graph for this function:

void nmg_face_bb ( struct face *  f,
const struct bn_tol tol 
)

Build the bounding box for a face

Definition at line 2423 of file nmg_mk.c.

References BN_CK_TOL, BU_LIST_FOR, bu_log(), lu, MAX_FASTF, rt_g::NMG_debug, NMG_FACE_G_SNURB_MAGIC, nmg_loop_g(), rt_nurb_s_bound(), RTG, X, Y, and Z.

Referenced by nmg_close_shell(), nmg_make_faces_at_vert(), nmg_rebound(), nmg_shell_a(), nmg_split_loops_handler(), and rt_nmg_import4_internal().

Here is the call graph for this function:

void nmg_shell_a ( struct shell *  s,
const struct bn_tol tol 
)

Build the bounding box for a shell

Definition at line 2474 of file nmg_mk.c.

References BN_CK_TOL, bu_bomb(), BU_LIST_FOR, BU_LIST_IS_EMPTY, BU_LIST_NEXT, BU_LIST_NOT_HEAD, BU_LIST_PNEXT, bu_log(), lu, MAX_FASTF, NMG_CK_SHELL(), rt_g::NMG_debug, nmg_face_bb(), nmg_find_model(), nmg_loop_g(), NMG_SHELL_A_MAGIC, RTG, and VSETALL.

Referenced by ged_decompose(), nmg_decompose_shell(), nmg_rebound(), nmg_region_a(), and nmg_shell_coplanar_face_merge().

Here is the call graph for this function:

void nmg_region_a ( struct nmgregion *  r,
const struct bn_tol tol 
)
int nmg_demote_lu ( struct loopuse *  lu1)

Demote a loopuse of edgeuses to a bunch of wire edges in the shell.

Returns - 0 If all is well (edges moved to shell, loopuse deleted). 1 If parent is empty, and is thus "illegal". Still successful.

Definition at line 2610 of file nmg_mk.c.

References bu_bomb(), BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_NON_EMPTY, bu_log(), eu1, NMG_CK_LOOPUSE(), NMG_CK_SHELL(), rt_g::NMG_debug, NMG_EDGEUSE_MAGIC, nmg_find_s_of_lu(), nmg_klu(), NMG_VERTEXUSE_MAGIC, RTG, and s.

Referenced by nmg_eval_shell().

Here is the call graph for this function:

int nmg_demote_eu ( struct edgeuse *  eu)

Demote a wire edge into a pair of self-loop vertices

Returns - 0 If all is well 1 If shell is empty, and is thus "illegal".

Definition at line 2676 of file nmg_mk.c.

References bu_bomb(), bu_log(), NMG_CK_SHELL(), rt_g::NMG_debug, nmg_is_vertex_a_selfloop_in_shell(), nmg_keu(), nmg_mlv(), nmg_shell_is_empty(), NMG_SHELL_MAGIC, RTG, s, and OSL::Strings::v.

Referenced by nmg_eval_shell().

Here is the call graph for this function:

void nmg_movevu ( struct vertexuse *  vu,
struct vertex *  v 
)

Move a vertexuse from an old vertex to a new vertex. If this was the last use, the old vertex is destroyed.

XXX nmg_jvu() as a better name?

Definition at line 2729 of file nmg_mk.c.

References BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_IS_EMPTY, bu_log(), rt_g::NMG_debug, RTG, and OSL::Strings::v.

Referenced by nmg_edge_collapse(), nmg_mlv(), and nmg_simplify_shell_edges().

Here is the call graph for this function:

void nmg_je ( struct edgeuse *  eudst,
struct edgeuse *  eusrc 
)

Move a pair of edgeuses onto a single edge (glue edgeuse). The edgeuse eusrc and its mate are moved to the edge used by eudst. eusrc is made to be immediately radial to eudst. if eusrc does not share the same vertices as eudst, we bomb.

The edgeuse geometry pointers are not changed by this operation.

This routine was formerly called nmg_moveeu().

Definition at line 2765 of file nmg_mk.c.

References bu_bomb(), bu_log(), rt_g::NMG_debug, RTG, and V3ARGS.

Referenced by nmg_cmface(), nmg_cut_loop(), nmg_disconnect_shells(), nmg_do_radial_join(), nmg_join_2loops(), nmg_join_2singvu_loops(), nmg_join_singvu_loop(), nmg_open_shells_connect(), nmg_radial_implement_decisions(), nmg_radial_join_eu(), nmg_radial_join_eu_NEW(), and rt_tgc_tnurb().

Here is the call graph for this function:

void nmg_unglueedge ( struct edgeuse *  eu)

If edgeuse is part of a shared edge (more than one pair of edgeuses on the edge), it and its mate are "unglued" from the edge, and associated with a new edge structure.

Primarily a support routine for nmg_eusplit()

If the original edge had edge geometry, that is not duplicated here, because it is not easy (or appropriate) for nmg_eusplit() to know whether the new vertex lies on the previous edge geometry or not. Hence having the nmg_ebreak() interface, which preserves the ege geometry across a split, and nmg_esplit() which does not.

Definition at line 2866 of file nmg_mk.c.

References bu_log(), rt_g::NMG_debug, NMG_EDGE_MAGIC, nmg_find_model(), and RTG.

Referenced by nmg_disconnect_shells().

Here is the call graph for this function:

void nmg_jv ( register struct vertex *  v1,
register struct vertex *  v2 
)

Join two vertexes into one.

v1 inherits all the vertexuses presently pointing to v2, and v2 is then destroyed.

Definition at line 2917 of file nmg_mk.c.

References BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_INSERT, BU_LIST_NOT_HEAD, BU_LIST_PNEXT, bu_log(), rt_g::NMG_debug, and RTG.

Referenced by nmg_break_eg_on_v(), nmg_break_eu_on_v(), nmg_isect_edge2p_edge2p(), nmg_isect_vert2p_face2p(), nmg_keu_zl(), nmg_make_faces_at_vert(), nmg_ptbl_vfuse(), nmg_region_both_vfuse(), nmg_remove_short_eus_inter(), nmg_repair_v_near_v(), and nmg_simplify_inter().

Here is the call graph for this function:

void nmg_jfg ( struct face *  f1,
struct face *  f2 
)

Join two faces, so that they share one underlying face geometry. The loops of the two faces remains unchanged.

If one of the faces does not have any geometry, then it is made to share the geometry of the other.

Definition at line 2968 of file nmg_mk.c.

References BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_INSERT, BU_LIST_NON_EMPTY, bu_log(), rt_g::NMG_debug, and RTG.

Referenced by nmg_two_face_fuse().

Here is the call graph for this function:

void nmg_jeg ( struct edge_g_lseg *  dest_eg,
struct edge_g_lseg *  src_eg 
)

Join two edge geometries.

For all edges in the model which refer to 'src_eg', change them to refer to 'dest_eg'. The source is destroyed.

It is the responsibility of the caller to make certain that the 'dest_eg' is the best one for these edges. Outrageously wrong requests will cause this routine to abort.

This algorithm does not make sense if dest_eg is an edge_g_cnurb; those only make sense in the parameter space of their associated face.

Definition at line 3047 of file nmg_mk.c.

References bu_bomb(), BU_LIST_FIRST, BU_LIST_MAIN_PTR, BU_LIST_NON_EMPTY, bu_log(), rt_g::NMG_debug, NMG_EDGEUSE2_MAGIC, nmg_use_edge_g(), and RTG.

Referenced by nmg_edge_g_fuse(), nmg_edge_geom_isect_line(), nmg_find_edge_between_2fu(), nmg_find_eg_between_2fg(), nmg_isect_line2_face2pNEW(), and nmg_radial_join_eu_NEW().

Here is the call graph for this function:

int nmg_keu_zl ( struct shell *  s,
const struct bn_tol tol 
)

Kill zero length edgeuse from a shell and return the number of edgeuse killed. If the shell becomes empty, this function will bomb.

Definition at line 3089 of file nmg_mk.c.

References bn_pt3_pt3_equal(), bu_bomb(), BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_NOT_HEAD, BU_LIST_PNEXT, lu, NMG_CK_LOOPUSE(), NMG_CK_SHELL(), NMG_EDGEUSE_MAGIC, nmg_jv(), nmg_keu(), nmg_kfu(), and nmg_klu().

Referenced by nmg_region_end(), and rt_tor_tess().

Here is the call graph for this function: