BRL-CAD
comb.c File Reference
#include "common.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "bio.h"
#include "bu/parse.h"
#include "bu/cv.h"
#include "vmath.h"
#include "bn.h"
#include "db5.h"
#include "raytrace.h"
Include dependency graph for comb.c:

Go to the source code of this file.

Data Structures

struct  db_tree_counter_state
 
struct  rt_comb_v5_serialize_state
 

Macros

#define DB_TREE_COUNTER_STATE_MAGIC   0x64546373 /* dTcs */
 
#define DB_CK_TREE_COUNTER_STATE(_p)   BU_CKMAG(_p, DB_TREE_COUNTER_STATE_MAGIC, "db_tree_counter_state");
 
#define DB5COMB_TOKEN_LEAF   1
 
#define DB5COMB_TOKEN_UNION   2
 
#define DB5COMB_TOKEN_INTERSECT   3
 
#define DB5COMB_TOKEN_SUBTRACT   4
 
#define DB5COMB_TOKEN_XOR   5
 
#define DB5COMB_TOKEN_NOT   6
 
#define RT_COMB_V5_SERIALIZE_STATE_MAGIC   0x43357373 /* C5ss */
 
#define RT_CK_COMB_V5_SERIALIZE_STATE(_p)   BU_CKMAG(_p, RT_COMB_V5_SERIALIZE_STATE_MAGIC, "rt_comb_v5_serialize_state")
 
#define MAX_V5_STACK   8000
 

Functions

size_t db_tree_counter (const union tree *tp, struct db_tree_counter_state *tcsp)
 
void rt_comb_v5_serialize (const union tree *tp, struct rt_comb_v5_serialize_state *ssp)
 
int rt_comb_export5 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip, struct resource *resp)
 
int rt_comb_import5 (struct rt_db_internal *ip, const struct bu_external *ep, const mat_t mat, const struct db_i *dbip, struct resource *resp)
 
int rt_comb_get (struct bu_vls *logstr, const struct rt_db_internal *intern, const char *item)
 
int rt_comb_adjust (struct bu_vls *logstr, struct rt_db_internal *intern, int argc, char **argv)
 
int rt_comb_form (struct bu_vls *logstr, const struct rt_functab *ftp)
 
void rt_comb_make (const struct rt_functab *ftp, struct rt_db_internal *intern)
 

Macro Definition Documentation

#define DB_TREE_COUNTER_STATE_MAGIC   0x64546373 /* dTcs */

Definition at line 66 of file comb.c.

Referenced by rt_comb_export5().

#define DB_CK_TREE_COUNTER_STATE (   _p)    BU_CKMAG(_p, DB_TREE_COUNTER_STATE_MAGIC, "db_tree_counter_state");

Definition at line 67 of file comb.c.

Referenced by db_tree_counter().

#define DB5COMB_TOKEN_LEAF   1

Definition at line 134 of file comb.c.

Referenced by rt_comb_import5(), and rt_comb_v5_serialize().

#define DB5COMB_TOKEN_UNION   2

Definition at line 135 of file comb.c.

Referenced by rt_comb_import5(), and rt_comb_v5_serialize().

#define DB5COMB_TOKEN_INTERSECT   3

Definition at line 136 of file comb.c.

Referenced by rt_comb_import5(), and rt_comb_v5_serialize().

#define DB5COMB_TOKEN_SUBTRACT   4

Definition at line 137 of file comb.c.

Referenced by rt_comb_import5(), and rt_comb_v5_serialize().

#define DB5COMB_TOKEN_XOR   5

Definition at line 138 of file comb.c.

Referenced by rt_comb_import5(), and rt_comb_v5_serialize().

#define DB5COMB_TOKEN_NOT   6

Definition at line 139 of file comb.c.

Referenced by rt_comb_import5(), and rt_comb_v5_serialize().

#define RT_COMB_V5_SERIALIZE_STATE_MAGIC   0x43357373 /* C5ss */

Definition at line 150 of file comb.c.

Referenced by rt_comb_export5().

#define RT_CK_COMB_V5_SERIALIZE_STATE (   _p)    BU_CKMAG(_p, RT_COMB_V5_SERIALIZE_STATE_MAGIC, "rt_comb_v5_serialize_state")

Definition at line 151 of file comb.c.

Referenced by rt_comb_v5_serialize().

#define MAX_V5_STACK   8000

Referenced by rt_comb_import5().

Function Documentation

size_t db_tree_counter ( const union tree tp,
struct db_tree_counter_state tcsp 
)

Count number of non-identity matrices, number of leaf nodes, number of operator nodes, etc.

Returns - maximum depth of stack needed to unpack this tree, if serialized.

Notes - We over-estimate the size of the width fields used for holding the matrix subscripts. The caller is responsible for correcting by saying:

tcsp->leafbytes -= tcsp->n_leaf * (8 - DB5_ENC_LEN(wid));

Definition at line 84 of file comb.c.

References bn_mat_is_identity(), bu_bomb(), bu_log(), DB_CK_TREE_COUNTER_STATE, db_tree_counter_state::leafbytes, db_tree_counter_state::n_leaf, db_tree_counter_state::n_mat, db_tree_counter_state::n_oper, db_tree_counter_state::non_union_seen, OP_DB_LEAF, OP_INTERSECT, OP_NOT, OP_SUBTRACT, OP_UNION, OP_XOR, RT_CK_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, tree::tree_db_leaf::tl_mat, tree::tree_db_leaf::tl_name, tree::tr_b, and tree::tr_l.

Referenced by rt_comb_export5().

Here is the call graph for this function:

int rt_comb_export5 ( struct bu_external ep,
const struct rt_db_internal ip,
double  local2mm,
const struct db_i dbip,
struct resource resp 
)

Definition at line 252 of file comb.c.

References rt_comb_internal::aircode, BU_ASSERT_PTR, BU_ASSERT_SIZE_T, bu_avs_add(), bu_avs_add_vls(), bu_avs_init(), BU_AVS_MAGIC, bu_avs_remove(), bu_bomb(), bu_calloc(), BU_EXTERNAL_INIT, bu_vls_free(), BU_VLS_INIT_ZERO, bu_vls_printf(), bu_vls_strlen(), bu_vls_trunc(), db5_encode_length(), db5_select_length_encoding(), db_tree_counter(), DB_TREE_COUNTER_STATE_MAGIC, rt_comb_v5_serialize_state::exprp, bu_external::ext_buf, bu_external::ext_nbytes, rt_comb_internal::GIFTmater, ID_COMBINATION, rt_db_internal::idb_avs, rt_db_internal::idb_ptr, if(), rt_comb_internal::inherit, rt_comb_internal::is_fastgen, db_tree_counter_state::leafbytes, rt_comb_v5_serialize_state::leafp, rt_comb_internal::los, db_tree_counter_state::magic, bu_attribute_value_set::magic, rt_comb_v5_serialize_state::magic, rt_comb_v5_serialize_state::mat_num, rt_comb_v5_serialize_state::matp, memset(), db_tree_counter_state::n_leaf, db_tree_counter_state::n_mat, db_tree_counter_state::n_oper, rt_comb_v5_serialize_state::nmat, db_tree_counter_state::non_union_seen, REGION_FASTGEN_PLATE, REGION_FASTGEN_VOLUME, rt_comb_internal::region_flag, rt_comb_internal::region_id, REGION_NON_FASTGEN, rt_comb_internal::rgb, rt_comb_internal::rgb_valid, RT_CK_COMB, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_CK_RESOURCE, rt_comb_v5_serialize(), RT_COMB_V5_SERIALIZE_STATE_MAGIC, rt_comb_internal::shader, SIZEOF_NETWORK_DOUBLE, rt_comb_internal::tree, V3ARGS, and rt_comb_v5_serialize_state::wid.

Here is the call graph for this function:

int rt_comb_get ( struct bu_vls logstr,
const struct rt_db_internal intern,
const char *  item 
)

Sets the result string to a description of the given combination. Entered via OBJ[].ft_get().

Definition at line 793 of file comb.c.

References rt_comb_internal::aircode, BRLCAD_ERROR, BRLCAD_OK, BU_STR_EQUAL, bu_vls_addr(), bu_vls_printf(), bu_vls_putc(), bu_vls_strlen(), db_tree_list(), rt_comb_internal::GIFTmater, rt_db_internal::idb_ptr, rt_comb_internal::inherit, rt_comb_internal::los, rt_comb_internal::material, rt_comb_internal::region_flag, rt_comb_internal::region_id, rt_comb_internal::rgb, rt_comb_internal::rgb_valid, RT_CK_COMB, RT_CK_DB_INTERNAL, rt_comb_internal::shader, rt_comb_internal::tree, and V3ARGS.

Here is the call graph for this function:

int rt_comb_form ( struct bu_vls logstr,
const struct rt_functab ftp 
)

Definition at line 1069 of file comb.c.

References BRLCAD_OK, bu_vls_printf(), and RT_CK_FUNCTAB.

Here is the call graph for this function:

void rt_comb_make ( const struct rt_functab ftp,
struct rt_db_internal intern 
)

Create a blank combination with appropriate values. Called via OBJ[ID_COMBINATION].ft_make().

Definition at line 1084 of file comb.c.

References BU_ALLOC, bu_vls_init(), ID_COMBINATION, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, rt_comb_internal::material, OBJ, RT_COMB_INTERNAL_INIT, and rt_comb_internal::shader.

Here is the call graph for this function: