db5_comb.c File Reference

#include "common.h"
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include "machine.h"
#include "bu.h"
#include "vmath.h"
#include "bn.h"
#include "db5.h"
#include "raytrace.h"
#include "./debug.h"

Include dependency graph for db5_comb.c:

Go to the source code of this file.

Data Structures

struct  db_tree_counter_state
struct  rt_comb_v5_serialize_state

Defines

#define DB_TREE_COUNTER_STATE_MAGIC   0x64546373
#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
#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

long 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, const int minor_type)


Detailed Description

Handle import/export of combinations (union tree) in v5 format.

The on-disk record looks like this: width byte n matricies (only non-identity matricies stored). n leaves len of RPN expression. (len=0 signals all-union expression) depth of stack Section 1: matricies Section 2: leaves Section 3: (Optional) RPN expression.

Encoding of a matrix is (ELEMENTS_PER_MAT * SIZEOF_NETWORK_DOUBLE) bytes, in network order (big-Endian, IEEE double precision).

Author - Michael John Muuss

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

Definition in file db5_comb.c.


Define Documentation

#define DB_TREE_COUNTER_STATE_MAGIC   0x64546373
 

Definition at line 83 of file db5_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 84 of file db5_comb.c.

Referenced by db_tree_counter().

#define DB5COMB_TOKEN_LEAF   1
 

Definition at line 151 of file db5_comb.c.

Referenced by rt_comb_v5_serialize().

#define DB5COMB_TOKEN_UNION   2
 

Definition at line 152 of file db5_comb.c.

Referenced by rt_comb_v5_serialize().

#define DB5COMB_TOKEN_INTERSECT   3
 

Definition at line 153 of file db5_comb.c.

Referenced by rt_comb_v5_serialize().

#define DB5COMB_TOKEN_SUBTRACT   4
 

Definition at line 154 of file db5_comb.c.

Referenced by rt_comb_v5_serialize().

#define DB5COMB_TOKEN_XOR   5
 

Definition at line 155 of file db5_comb.c.

Referenced by rt_comb_v5_serialize().

#define DB5COMB_TOKEN_NOT   6
 

Definition at line 156 of file db5_comb.c.

Referenced by rt_comb_v5_serialize().

#define RT_COMB_V5_SERIALIZE_STATE_MAGIC   0x43357373
 

Definition at line 167 of file db5_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 168 of file db5_comb.c.

Referenced by rt_comb_v5_serialize().

#define MAX_V5_STACK   8000
 

Referenced by rt_comb_import5().


Function Documentation

long db_tree_counter const union tree tp,
struct db_tree_counter_state tcsp
 

D B _ T R E E _ C O U N T E R

Count number of non-identity matricies, 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 102 of file db5_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:

void rt_comb_v5_serialize const union tree tp,
struct rt_comb_v5_serialize_state ssp
 

R T _ C O M B _ V 5 _ S E R I A L I Z E

In one single pass through the tree, serialize out all three output sections at once.

Definition at line 177 of file db5_comb.c.

References bcopy, bn_mat_is_identity(), BU_ASSERT_LONG, bu_bomb(), bu_log(), db5_encode_length(), DB5COMB_TOKEN_INTERSECT, DB5COMB_TOKEN_LEAF, DB5COMB_TOKEN_NOT, DB5COMB_TOKEN_SUBTRACT, DB5COMB_TOKEN_UNION, DB5COMB_TOKEN_XOR, ELEMENTS_PER_MAT, rt_comb_v5_serialize_state::exprp, htond(), rt_comb_v5_serialize_state::leafp, rt_comb_v5_serialize_state::mat_num, rt_comb_v5_serialize_state::matp, rt_comb_v5_serialize_state::nmat, OP_DB_LEAF, OP_INTERSECT, OP_NOT, OP_SUBTRACT, OP_UNION, OP_XOR, RT_CK_COMB_V5_SERIALIZE_STATE, RT_CK_TREE, SIZEOF_NETWORK_DOUBLE, 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, tree::tr_l, and rt_comb_v5_serialize_state::wid.

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
 

R T _ C O M B _ E X P O R T 5

Definition at line 264 of file db5_comb.c.

References rt_comb_internal::aircode, BU_ASSERT_LONG, BU_ASSERT_PTR, bu_avs_add(), bu_avs_add_vls(), bu_avs_init(), BU_AVS_MAGIC, bu_avs_remove(), bu_bomb(), bu_calloc(), BU_INIT_EXTERNAL, bu_malloc(), bu_vls_free(), bu_vls_init(), bu_vls_printf(), bu_vls_strlen(), bu_vls_trunc(), bzero, db5_enc_len, db5_encode_length(), db5_select_length_encoding(), db_tree_counter(), DB_TREE_COUNTER_STATE_MAGIC, ELEMENTS_PER_MAT, rt_comb_v5_serialize_state::exprp, rt_comb_internal::GIFTmater, ID_COMBINATION, rt_db_internal::idb_avs, rt_db_internal::idb_ptr, rt_comb_internal::inherit, rt_comb_internal::is_fastgen, rt_comb_v5_serialize_state::leafp, rt_comb_internal::los, bu_attribute_value_set::magic, rt_comb_v5_serialize_state::magic, rt_comb_v5_serialize_state::mat_num, rt_comb_internal::material, rt_comb_v5_serialize_state::matp, rt_comb_v5_serialize_state::nmat, NULL, 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_RESOURCE, rt_comb_v5_serialize(), RT_COMB_V5_SERIALIZE_STATE_MAGIC, rt_comb_internal::shader, SIZEOF_NETWORK_DOUBLE, rt_comb_internal::temperature, rt_comb_internal::tree, V3ARGS, value, and rt_comb_v5_serialize_state::wid.

Here is the call graph for this function:


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