nmg_index.c File Reference

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

Include dependency graph for nmg_index.c:

Go to the source code of this file.

Defines

#define NMG_HIGH_BIT   0x80000000
#define NMG_MARK_INDEX(_p)   ((_p)->index |= NMG_HIGH_BIT)
#define NMG_ASSIGN_NEW_INDEX(_p)
#define MARK_VU(_vu)
#define ASSIGN_VU(_vu)
#define NMG_UNIQ_INDEX(_p, _type)
#define UNIQ_VU(_vu)
#define CHECK_INDEX(_p)   if((_p)->index > maxindex ) maxindex = (_p)->index
#define CHECK_VU_INDEX(_vu)

Functions

int nmg_index_of_struct (register const long int *p)
void nmg_m_set_high_bit (struct model *m)
void nmg_m_reindex (struct model *m, register long int newindex)
void nmg_vls_struct_counts (struct bu_vls *str, const struct nmg_struct_counts *ctr)
void nmg_pr_struct_counts (const struct nmg_struct_counts *ctr, const char *str)
long ** nmg_m_struct_count (register struct nmg_struct_counts *ctr, const struct model *m)
void nmg_struct_counts (const struct model *m, const char *str)
void nmg_merge_models (struct model *m1, struct model *m2)
long nmg_find_max_index (const struct model *m)


Detailed Description

Handle counting and re-indexing of NMG data structures.

Authors - Michael John Muuss Lee A. Butler

Source - SECAD/VLD Computing Consortium, Bldg 394 The U. S. Army Ballistic Research Laboratory Aberdeen Proving Ground, Maryland 21005

Definition in file nmg_index.c.


Define Documentation

#define NMG_HIGH_BIT   0x80000000
 

Definition at line 124 of file nmg_index.c.

#define NMG_MARK_INDEX _p   )     ((_p)->index |= NMG_HIGH_BIT)
 

Definition at line 126 of file nmg_index.c.

Referenced by nmg_m_set_high_bit().

#define NMG_ASSIGN_NEW_INDEX _p   ) 
 

Value:

{ if( ((_p)->index & NMG_HIGH_BIT) != 0 ) \
                (_p)->index = newindex++; }

Definition at line 128 of file nmg_index.c.

Referenced by nmg_m_reindex().

#define MARK_VU _vu   ) 
 

Value:

{ \
        struct vertex   *v; \
        NMG_CK_VERTEXUSE(_vu); \
        NMG_MARK_INDEX(_vu); \
        if(_vu->a.magic_p) switch(*_vu->a.magic_p)  { \
        case NMG_VERTEXUSE_A_PLANE_MAGIC: \
                NMG_MARK_INDEX(_vu->a.plane_p); \
                break; \
        case NMG_VERTEXUSE_A_CNURB_MAGIC: \
                NMG_MARK_INDEX(_vu->a.cnurb_p); \
                break; \
        } \
        v = _vu->v_p; \
        NMG_CK_VERTEX(v); \
        NMG_MARK_INDEX(v); \
        if(v->vg_p)  { \
                NMG_CK_VERTEX_G(v->vg_p); \
                NMG_MARK_INDEX(v->vg_p); \
        } \
    }

Referenced by nmg_m_set_high_bit().

#define ASSIGN_VU _vu   ) 
 

Value:

{ \
                NMG_CK_VERTEXUSE(_vu); \
                NMG_ASSIGN_NEW_INDEX(_vu); \
                if(_vu->a.magic_p)  switch(*_vu->a.magic_p)  { \
                case NMG_VERTEXUSE_A_PLANE_MAGIC: \
                        NMG_ASSIGN_NEW_INDEX(_vu->a.plane_p); \
                        break; \
                case NMG_VERTEXUSE_A_CNURB_MAGIC: \
                        NMG_ASSIGN_NEW_INDEX(_vu->a.cnurb_p); \
                        break; \
                } \
                v = _vu->v_p; \
                NMG_CK_VERTEX(v); \
                NMG_ASSIGN_NEW_INDEX(v); \
                if(v->vg_p) NMG_ASSIGN_NEW_INDEX(v->vg_p); \
        }

Referenced by nmg_m_reindex().

#define NMG_UNIQ_INDEX _p,
_type   ) 
 

Value:

if( (_p)->index > m->maxindex )  { \
                bu_log("x%x (%s) has index %d, m->maxindex=%d\n", (_p), \
                        bu_identify_magic(*((long *)(_p))), (_p)->index, m->maxindex ); \
                rt_bomb("nmg_m_struct_count index overflow\n"); \
        } \
        if( ptrs[(_p)->index] == (long *)0 )  { \
                ptrs[(_p)->index] = (long *)(_p); \
                ctr->_type++; \
        }

Referenced by nmg_m_struct_count().

#define UNIQ_VU _vu   ) 
 

Value:

{ \
                NMG_CK_VERTEXUSE(_vu); \
                NMG_UNIQ_INDEX(_vu, vertexuse); \
                if(_vu->a.magic_p) switch(*_vu->a.magic_p) { \
                case NMG_VERTEXUSE_A_PLANE_MAGIC: \
                        NMG_UNIQ_INDEX(_vu->a.plane_p, vertexuse_a_plane); \
                        break; \
                case NMG_VERTEXUSE_A_CNURB_MAGIC: \
                        NMG_UNIQ_INDEX(_vu->a.cnurb_p, vertexuse_a_cnurb); \
                        break; \
                } \
                v = _vu->v_p; \
                NMG_CK_VERTEX(v); \
                NMG_UNIQ_INDEX(v, vertex); \
                if(v->vg_p)  { \
                        NMG_CK_VERTEX_G(v->vg_p); \
                        NMG_UNIQ_INDEX(v->vg_p, vertex_g); \
                } \
        }

Referenced by nmg_m_struct_count().

#define CHECK_INDEX _p   )     if((_p)->index > maxindex ) maxindex = (_p)->index
 

Definition at line 800 of file nmg_index.c.

Referenced by nmg_find_max_index().

#define CHECK_VU_INDEX _vu   ) 
 

Value:

{\
                NMG_CK_VERTEXUSE(_vu); \
                CHECK_INDEX(_vu); \
                if(_vu->a.magic_p)  switch(*_vu->a.magic_p)  { \
                case NMG_VERTEXUSE_A_PLANE_MAGIC: \
                        CHECK_INDEX(_vu->a.plane_p); \
                        break; \
                case NMG_VERTEXUSE_A_CNURB_MAGIC: \
                        CHECK_INDEX(_vu->a.cnurb_p); \
                        break; \
                } \
                v = _vu->v_p; \
                NMG_CK_VERTEX(v); \
                CHECK_INDEX(v); \
                if(v->vg_p) CHECK_INDEX(v->vg_p); \
        }

Definition at line 801 of file nmg_index.c.

Referenced by nmg_find_max_index().


Function Documentation

int nmg_index_of_struct register const long int *  p  ) 
 

N M G _ I N D E X _ O F _ S T R U C T

Return the structure index number of an arbitrary NMG structure.

Returns - >=0 index number -1 pointed at struct bu_list embedded within NMG structure. -2 error: unknown magic number

Definition at line 67 of file nmg_index.c.

References BU_LIST_HEAD_MAGIC, BU_LIST_MAIN_PTR, bu_log(), NMG_EDGE_G_CNURB_MAGIC, NMG_EDGE_G_LSEG_MAGIC, NMG_EDGE_MAGIC, NMG_EDGEUSE2_MAGIC, NMG_EDGEUSE_MAGIC, NMG_FACE_G_PLANE_MAGIC, NMG_FACE_G_SNURB_MAGIC, NMG_FACE_MAGIC, NMG_FACEUSE_MAGIC, NMG_LOOP_G_MAGIC, NMG_LOOP_MAGIC, NMG_LOOPUSE_MAGIC, NMG_MODEL_MAGIC, NMG_REGION_A_MAGIC, NMG_REGION_MAGIC, NMG_SHELL_A_MAGIC, NMG_SHELL_MAGIC, NMG_VERTEX_G_MAGIC, NMG_VERTEX_MAGIC, NMG_VERTEXUSE_A_CNURB_MAGIC, NMG_VERTEXUSE_A_PLANE_MAGIC, and NMG_VERTEXUSE_MAGIC.

Here is the call graph for this function:

void nmg_m_reindex struct model m,
register long int  newindex
 

N M G _ M _ R E I N D E X

Reassign index numbers to all the data structures in a model. The model structure will get index 0, all others will be sequentially assigned after that.

Because the first pass has done extensive error checking, the second pass can do less.

Definition at line 320 of file nmg_index.c.

References ASSIGN_VU, BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_FOR, bu_log(), edgeuse::cnurb_p, DEBUG_BASIC, loopuse::down_hd, edgeuse::e_p, shell::eu_hd, faceuse::f_p, shell::fu_hd, edgeuse::g, face::g, model::index, loopuse::l_p, loop::lg_p, edgeuse::lseg_p, shell::lu_hd, faceuse::lu_hd, edgeuse::magic_p, face::magic_p, model::maxindex, NMG_ASSIGN_NEW_INDEX, NMG_CK_EDGE, NMG_CK_EDGEUSE, NMG_CK_FACE, NMG_CK_FACEUSE, NMG_CK_LOOP, NMG_CK_LOOPUSE, NMG_CK_MODEL, NMG_CK_REGION, NMG_CK_SHELL, NMG_EDGE_G_CNURB_MAGIC, NMG_EDGE_G_LSEG_MAGIC, NMG_FACE_G_PLANE_MAGIC, NMG_FACE_G_SNURB_MAGIC, nmg_m_set_high_bit(), NMG_VERTEXUSE_MAGIC, face::plane_p, model::r_hd, nmgregion::ra_p, nmgregion::s_hd, shell::sa_p, face::snurb_p, shell::vu_p, and edgeuse::vu_p.

Here is the call graph for this function:

long** nmg_m_struct_count register struct nmg_struct_counts ctr,
const struct model m
 

N M G _ M _ S T R U C T _ C O U N T

Returns - Pointer to magic-number/structure-base pointer array, indexed by nmg structure index. Caller is responsible for freeing it.

Definition at line 551 of file nmg_index.c.

References bu_calloc(), BU_LIST_FIRST, BU_LIST_FIRST_MAGIC, BU_LIST_FOR, bzero, edgeuse::cnurb_p, loopuse::down_hd, edgeuse::e_p, shell::eu_hd, faceuse::f_p, shell::fu_hd, edgeuse::g, face::g, loopuse::l_p, loop::lg_p, edgeuse::lseg_p, shell::lu_hd, faceuse::lu_hd, edgeuse::magic_p, face::magic_p, model::maxindex, NMG_CK_EDGE, NMG_CK_EDGEUSE, NMG_CK_FACE, NMG_CK_FACEUSE, NMG_CK_LOOP, NMG_CK_LOOP_G, NMG_CK_LOOPUSE, NMG_CK_MODEL, NMG_CK_REGION, NMG_CK_REGION_A, NMG_CK_SHELL, NMG_CK_SHELL_A, NMG_EDGE_G_CNURB_MAGIC, NMG_EDGE_G_LSEG_MAGIC, NMG_FACE_G_PLANE_MAGIC, NMG_FACE_G_SNURB_MAGIC, NMG_UNIQ_INDEX, NMG_VERTEXUSE_MAGIC, face::plane_p, model::r_hd, nmgregion::ra_p, nmgregion::s_hd, shell::sa_p, face::snurb_p, UNIQ_VU, shell::vu_p, and edgeuse::vu_p.

Here is the call graph for this function:


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