BRL-CAD
db_diff.c File Reference
#include "common.h"
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include "bio.h"
#include "tcl.h"
#include "vmath.h"
#include "nmg.h"
#include "rtgeom.h"
#include "raytrace.h"
#include "rt/db_diff.h"
Include dependency graph for db_diff.c:

Go to the source code of this file.

Data Structures

struct  diff_elements
 

Functions

HIDDEN int rt_intern_struct_size (int type)
 
int tcl_list_to_avs (const char *tcl_list, struct bu_attribute_value_set *avs, int offset)
 
HIDDEN const char * arb_type_to_str (int type)
 
HIDDEN const char * type_to_str (const struct rt_db_internal *obj, int arb_type)
 
void diff_init_avp (struct diff_avp *attr_result)
 
void diff_free_avp (struct diff_avp *attr_result)
 
void diff_init_result (struct diff_result *result, const struct bn_tol *curr_diff_tol, const char *obj_name)
 
void diff_free_result (struct diff_result *result)
 
HIDDEN int avpp_val_compare (const char *val1, const char *val2, const struct bn_tol *diff_tol)
 
int db_avs_diff (const struct bu_attribute_value_set *left_set, const struct bu_attribute_value_set *right_set, const struct bn_tol *diff_tol, int(*add_func)(const char *attr_name, const char *attr_val, void *data), int(*del_func)(const char *attr_name, const char *attr_val, void *data), int(*chgd_func)(const char *attr_name, const char *attr_val_left, const char *attr_val_right, void *data), int(*unchgd_func)(const char *attr_name, const char *attr_val, void *data), void *client_data)
 
HIDDEN int db_diff_external (const struct bu_external *ext1, const struct bu_external *ext2)
 
HIDDEN void get_diff_components (struct diff_elements *el, const struct db_i *dbip, const struct directory *dp)
 
HIDDEN void free_diff_components (struct diff_elements *el)
 
HIDDEN int diff_dp_attr_add (const char *attr_name, const char *attr_val, void *data)
 
HIDDEN int diff_dp_attr_del (const char *attr_name, const char *attr_val, void *data)
 
HIDDEN int diff_dp_attr_chgd (const char *attr_name, const char *attr_val_left, const char *attr_val_right, void *data)
 
HIDDEN int diff_dp_attr_unchgd (const char *attr_name, const char *attr_val, void *data)
 
int db_diff_dp (const struct db_i *left, const struct db_i *right, const struct directory *left_dp, const struct directory *right_dp, const struct bn_tol *diff_tol, db_compare_criteria_t flags, struct diff_result *ext_result)
 
int db_diff (const struct db_i *dbip1, const struct db_i *dbip2, const struct bn_tol *diff_tol, db_compare_criteria_t flags, struct bu_ptbl *results)
 
int db_avs_diff3 (const struct bu_attribute_value_set *left_set, const struct bu_attribute_value_set *ancestor_set, const struct bu_attribute_value_set *right_set, const struct bn_tol *diff_tol, int(*add_func)(const char *attr_name, const char *attr_val_left, const char *attr_val_right, void *data), int(*del_func)(const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data), int(*chgd_func)(const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data), int(*conflict_func)(const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data), int(*unchgd_func)(const char *attr_name, const char *attr_val, void *data), void *client_data)
 
HIDDEN int diff3_dp_attr_add (const char *attr_name, const char *attr_val_left, const char *attr_val_right, void *data)
 
HIDDEN int diff3_dp_attr_del (const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data)
 
HIDDEN int diff3_dp_attr_chgd (const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data)
 
HIDDEN int diff3_dp_attr_conflict (const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data)
 
HIDDEN int diff3_dp_attr_unchgd (const char *attr_name, const char *attr_val, void *data)
 
int db_diff3_dp (const struct db_i *left, const struct db_i *ancestor, const struct db_i *right, const struct directory *left_dp, const struct directory *ancestor_dp, const struct directory *right_dp, const struct bn_tol *diff3_tol, db_compare_criteria_t flags, struct diff_result *ext_result)
 
int db_diff3 (const struct db_i *dbip_left, const struct db_i *dbip_ancestor, const struct db_i *dbip_right, const struct bn_tol *diff3_tol, db_compare_criteria_t flags, struct bu_ptbl *results)
 

Detailed Description

Routines to determine the differences between two BRL-CAD databases.

Definition in file db_diff.c.

Function Documentation

HIDDEN int rt_intern_struct_size ( int  type)

<Unused

<Toroid

<Generalized Truncated General Cone

<Ellipsoid

<Generalized ARB. V + 7 vectors

<ARS

<Half-space

<Right Elliptical Cylinder [TGC special]

<Polygonal faceted object

<B-spline object

<Sphere

<n-Manifold Geometry solid

<Extruded bitmap solid

<3-D Volume

<ARB with N faces

<Pipe (wire) solid

<Particle system solid

<Right Parabolic Cylinder

<Right Hyperbolic Cylinder

<Elliptical Paraboloid

<Elliptical Hyperboloid

<Elliptical Torus

<Pseudo Solid Grip

<Pseudo Solid/Region Joint

<Height Field

<Displacement map

<2D sketch

<Solid of extrusion

<Instanced submodel

<FASTGEN4 CLINE solid

<Bag o' triangles

<Combination Record

<Uniform-array binary

<Constraint object

<Superquadratic ellipsoid

<Metaball

<B-rep object

<Hyperboloid of one sheet

<Solid of Revolution

<Collection of Points

<Annotation

<Heart

Definition at line 48 of file db_diff.c.

References ID_ANNOTATION, ID_ARB8, ID_ARBN, ID_ARS, ID_BINUNIF, ID_BOT, ID_BREP, ID_BSPLINE, ID_CLINE, ID_COMBINATION, ID_CONSTRAINT, ID_DSP, ID_EBM, ID_EHY, ID_ELL, ID_EPA, ID_ETO, ID_EXTRUDE, ID_GRIP, ID_HALF, ID_HF, ID_HRT, ID_HYP, ID_JOINT, ID_MAXIMUM, ID_METABALL, ID_NMG, ID_NULL, ID_PARTICLE, ID_PIPE, ID_PNTS, ID_POLY, ID_REC, ID_REVOLVE, ID_RHC, ID_RPC, ID_SKETCH, ID_SPH, ID_SUBMODEL, ID_SUPERELL, ID_TGC, ID_TOR, and ID_VOL.

Referenced by db_diff3_dp(), and db_diff_dp().

int tcl_list_to_avs ( const char *  tcl_list,
struct bu_attribute_value_set avs,
int  offset 
)

Function to convert an ft_get list of parameters into an avs.

Returns
0 if the conversion succeeds, -1 if it does not.

Definition at line 187 of file db_diff.c.

References bu_avs_add(), BU_AVS_INIT, and BU_AVS_IS_INITIALIZED.

Referenced by f_objparam(), and get_diff_components().

Here is the call graph for this function:

HIDDEN const char* arb_type_to_str ( int  type)

Definition at line 218 of file db_diff.c.

Referenced by type_to_str().

HIDDEN const char* type_to_str ( const struct rt_db_internal obj,
int  arb_type 
)

Definition at line 242 of file db_diff.c.

References arb_type_to_str(), rt_functab::ft_label, and rt_db_internal::idb_meth.

Referenced by get_diff_components().

Here is the call graph for this function:

void diff_free_avp ( struct diff_avp attr_result)

Definition at line 258 of file db_diff.c.

References diff_avp::ancestor_value, bu_free(), diff_avp::left_value, diff_avp::name, and diff_avp::right_value.

Referenced by diff_free_result().

Here is the call graph for this function:

void diff_free_result ( struct diff_result result)

Definition at line 299 of file db_diff.c.

References diff_result::attr_diffs, bu_free(), bu_ptbl_free(), BU_PTBL_GET, BU_PTBL_LEN, BU_PUT, diff_free_avp(), diff_result::diff_tol, diff_result::obj_name, and diff_result::param_diffs.

Referenced by db_diff(), db_diff3(), db_diff3_dp(), db_diff_dp(), and main().

Here is the call graph for this function:

HIDDEN int avpp_val_compare ( const char *  val1,
const char *  val2,
const struct bn_tol diff_tol 
)

Definition at line 323 of file db_diff.c.

References BU_STR_EQUAL, bn_tol::dist, and VSET.

Referenced by db_avs_diff(), and db_avs_diff3().

int db_avs_diff ( const struct bu_attribute_value_set left_set,
const struct bu_attribute_value_set right_set,
const struct bn_tol diff_tol,
int(*)(const char *attr_name, const char *attr_val, void *data add_func,
int(*)(const char *attr_name, const char *attr_val, void *data del_func,
int(*)(const char *attr_name, const char *attr_val_left, const char *attr_val_right, void *data chgd_func,
int(*)(const char *attr_name, const char *attr_val, void *data unchgd_func,
void *  client_data 
)

Compare two attribute sets.

This function is useful for comparing the contents of two attribute/value sets.

Definition at line 365 of file db_diff.c.

References avpp_val_compare(), BU_AVS_FOR, bu_avs_get(), DIFF_EMPTY, bu_attribute_value_pair::name, diff_avp::state, and bu_attribute_value_pair::value.

Referenced by db_diff_dp().

Here is the call graph for this function:

HIDDEN int db_diff_external ( const struct bu_external ext1,
const struct bu_external ext2 
)

Definition at line 399 of file db_diff.c.

References bu_external::ext_buf, and bu_external::ext_nbytes.

Referenced by db_diff(), and db_diff3().

HIDDEN void free_diff_components ( struct diff_elements el)

Definition at line 500 of file db_diff.c.

References diff_elements::attrs, bu_avs_free(), BU_PUT, diff_elements::intern, diff_elements::params, and rt_db_free_internal().

Referenced by db_diff3_dp(), and db_diff_dp().

Here is the call graph for this function:

HIDDEN int diff_dp_attr_add ( const char *  attr_name,
const char *  attr_val,
void *  data 
)

Definition at line 513 of file db_diff.c.

References BU_GET, bu_ptbl_ins(), bu_strdup, DIFF_ADDED, diff_init_avp(), diff_avp::name, diff_avp::right_value, and diff_avp::state.

Referenced by db_diff_dp().

Here is the call graph for this function:

HIDDEN int diff_dp_attr_del ( const char *  attr_name,
const char *  attr_val,
void *  data 
)

Definition at line 527 of file db_diff.c.

References BU_GET, bu_ptbl_ins(), bu_strdup, diff_init_avp(), DIFF_REMOVED, diff_avp::left_value, diff_avp::name, and diff_avp::state.

Referenced by db_diff_dp().

Here is the call graph for this function:

HIDDEN int diff_dp_attr_chgd ( const char *  attr_name,
const char *  attr_val_left,
const char *  attr_val_right,
void *  data 
)

Definition at line 541 of file db_diff.c.

References BU_GET, bu_ptbl_ins(), bu_strdup, DIFF_CHANGED, diff_init_avp(), diff_avp::left_value, diff_avp::name, diff_avp::right_value, and diff_avp::state.

Referenced by db_diff_dp().

Here is the call graph for this function:

HIDDEN int diff_dp_attr_unchgd ( const char *  attr_name,
const char *  attr_val,
void *  data 
)

Definition at line 556 of file db_diff.c.

References BU_GET, bu_ptbl_ins(), bu_strdup, diff_init_avp(), DIFF_UNCHANGED, diff_avp::left_value, diff_avp::name, diff_avp::right_value, and diff_avp::state.

Referenced by db_diff_dp().

Here is the call graph for this function:

int db_diff_dp ( const struct db_i left_dbip,
const struct db_i right_dbip,
const struct directory left_dp,
const struct directory right_dp,
const struct bn_tol diff_tol,
db_compare_criteria_t  flags,
struct diff_result result 
)

Compare two database objects.

This function is useful for comparing two geometry objects and inspecting their differences. Differences are recorded in key=value form based on whether there is a difference added in the right, removed in the right, changed going from left to right, or unchanged.

The flags parameter is a bitfield specifying what type of comparisons to perform. The default is to compare everything and report on any differences encountered.

The same bu_attribute_value_set container may be passed to any of the provided containers to aggregate results. NULL may be passed to not inspect or record information for that type of comparison.

Returns an int with bit flags set according to the above four diff categories.

Negative returns indicate an error.

Definition at line 571 of file db_diff.c.

References diff_result::attr_diffs, diff_result::attr_state, diff_elements::attrs, diff_elements::bin_params, BU_GET, BU_PUT, db_avs_diff(), DB_COMPARE_ALL, DB_COMPARE_ATTRS, DB_COMPARE_PARAM, DIFF_CHANGED, diff_dp_attr_add(), diff_dp_attr_chgd(), diff_dp_attr_del(), diff_dp_attr_unchgd(), DIFF_EMPTY, diff_free_result(), diff_init_result(), DIFF_UNCHANGED, diff_result::dp_left, diff_result::dp_right, free_diff_components(), get_diff_components(), rt_db_internal::idb_minor_type, diff_elements::idb_ptr, diff_elements::intern, diff_result::param_diffs, diff_result::param_state, diff_elements::params, rt_intern_struct_size(), and diff_avp::state.

Referenced by db_diff().

Here is the call graph for this function:

int db_diff ( const struct db_i dbip_left,
const struct db_i dbip_right,
const struct bn_tol diff_tol,
db_compare_criteria_t  flags,
struct bu_ptbl diff_results 
)

Compare two database instances.

All objects in dbip_left are compared against the objects in dbip_right. Every object results in one of four callback functions getting called. Any objects in dbip_right but not in dbip_left cause add_func() to get called. Any objects in dbip_left but not in dbip_right cause del_func() to get called. Objects existing in both (i.e., with the same name) but differing in some fashion cause chgd_func() to get called. If the object exists in both but is unchanged, unch_func() is called. NULL may be passed to skip any callback.

Returns an int with bit flags set according to the above four diff categories.

Negative returns indicate an error.

Definition at line 640 of file db_diff.c.

References bu_free_external(), BU_GET, bu_log(), bu_ptbl_ins(), BU_PUT, directory::d_major_type, directory::d_namep, DB_COMPARE_ALL, DB_COMPARE_ATTRS, DB_COMPARE_PARAM, db_diff_dp(), db_diff_external(), db_get_external(), db_lookup(), DIFF_CHANGED, DIFF_EMPTY, diff_free_result(), diff_init_result(), DIFF_UNCHANGED, FOR_ALL_DIRECTORY_END, FOR_ALL_DIRECTORY_START, and RT_DIR_NULL.

Referenced by main().

Here is the call graph for this function:

int db_avs_diff3 ( const struct bu_attribute_value_set left_set,
const struct bu_attribute_value_set ancestor_set,
const struct bu_attribute_value_set right_set,
const struct bn_tol diff_tol,
int(*)(const char *attr_name, const char *attr_val_left, const char *attr_val_right, void *data add_func,
int(*)(const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data del_func,
int(*)(const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data chgd_func,
int(*)(const char *attr_name, const char *attr_val_left, const char *attr_val_ancestor, const char *attr_val_right, void *data conflict_func,
int(*)(const char *attr_name, const char *attr_val, void *data unchgd_func,
void *  client_data 
)

Definition at line 726 of file db_diff.c.

References avpp_val_compare(), BU_AVS_FOR, bu_avs_get(), DIFF_EMPTY, bu_attribute_value_pair::name, and bu_attribute_value_pair::value.

Referenced by db_diff3_dp().

Here is the call graph for this function:

HIDDEN int diff3_dp_attr_add ( const char *  attr_name,
const char *  attr_val_left,
const char *  attr_val_right,
void *  data 
)

Definition at line 845 of file db_diff.c.

References BU_GET, bu_ptbl_ins(), bu_strdup, DIFF_ADDED, diff_init_avp(), diff_avp::left_value, diff_avp::name, diff_avp::right_value, and diff_avp::state.

Referenced by db_diff3_dp().

Here is the call graph for this function:

HIDDEN int diff3_dp_attr_del ( const char *  attr_name,
const char *  attr_val_left,
const char *  attr_val_ancestor,
const char *  attr_val_right,
void *  data 
)

Definition at line 860 of file db_diff.c.

References diff_avp::ancestor_value, BU_GET, bu_ptbl_ins(), bu_strdup, diff_init_avp(), DIFF_REMOVED, diff_avp::left_value, diff_avp::name, diff_avp::right_value, and diff_avp::state.

Referenced by db_diff3_dp().

Here is the call graph for this function:

HIDDEN int diff3_dp_attr_chgd ( const char *  attr_name,
const char *  attr_val_left,
const char *  attr_val_ancestor,
const char *  attr_val_right,
void *  data 
)

Definition at line 878 of file db_diff.c.

References diff_avp::ancestor_value, BU_GET, bu_ptbl_ins(), bu_strdup, DIFF_CHANGED, diff_init_avp(), diff_avp::left_value, diff_avp::name, diff_avp::right_value, and diff_avp::state.

Referenced by db_diff3_dp().

Here is the call graph for this function:

HIDDEN int diff3_dp_attr_conflict ( const char *  attr_name,
const char *  attr_val_left,
const char *  attr_val_ancestor,
const char *  attr_val_right,
void *  data 
)

Definition at line 894 of file db_diff.c.

References diff_avp::ancestor_value, BU_GET, bu_ptbl_ins(), bu_strdup, DIFF_CONFLICT, diff_init_avp(), diff_avp::left_value, diff_avp::name, diff_avp::right_value, and diff_avp::state.

Referenced by db_diff3_dp().

Here is the call graph for this function:

HIDDEN int diff3_dp_attr_unchgd ( const char *  attr_name,
const char *  attr_val,
void *  data 
)

Definition at line 910 of file db_diff.c.

References diff_avp::ancestor_value, BU_GET, bu_ptbl_ins(), bu_strdup, diff_init_avp(), DIFF_UNCHANGED, diff_avp::left_value, diff_avp::name, diff_avp::right_value, and diff_avp::state.

Referenced by db_diff3_dp().

Here is the call graph for this function:

int db_diff3_dp ( const struct db_i left,
const struct db_i ancestor,
const struct db_i right,
const struct directory left_dp,
const struct directory ancestor_dp,
const struct directory right_dp,
const struct bn_tol diff_tol,
db_compare_criteria_t  flags,
struct diff_result result 
)

Compare three database objects.

The flags parameter is a bitfield specifying what type of comparisons to perform. The default is to compare everything and report on any differences encountered.

The same bu_attribute_value_set container may be passed to any of the provided containers to aggregate results. NULL may be passed to not inspect or record information for that type of comparison.

Returns an int with bit flags set according to the above diff3 categories.

Negative returns indicate an error.

Definition at line 926 of file db_diff.c.

References diff_result::attr_diffs, diff_result::attr_state, diff_elements::attrs, diff_elements::bin_params, BU_GET, BU_PUT, db_avs_diff3(), DB_COMPARE_ALL, DB_COMPARE_ATTRS, DB_COMPARE_PARAM, DBI_NULL, diff3_dp_attr_add(), diff3_dp_attr_chgd(), diff3_dp_attr_conflict(), diff3_dp_attr_del(), diff3_dp_attr_unchgd(), DIFF_CHANGED, DIFF_EMPTY, diff_free_result(), diff_init_result(), DIFF_UNCHANGED, diff_result::dp_ancestor, diff_result::dp_left, diff_result::dp_right, free_diff_components(), get_diff_components(), rt_db_internal::idb_minor_type, diff_elements::idb_ptr, diff_elements::intern, diff_result::param_diffs, diff_result::param_state, diff_elements::params, RT_DIR_NULL, rt_intern_struct_size(), and diff_avp::state.

Referenced by db_diff3().

Here is the call graph for this function:

int db_diff3 ( const struct db_i dbip_left,
const struct db_i dbip_ancestor,
const struct db_i dbip_right,
const struct bn_tol diff_tol,
db_compare_criteria_t  flags,
struct bu_ptbl diff3_results 
)

Compare three database instances.

This does a "3-way" diff to identify changes in the left and right databases relative to the ancestor database, and provides functional hooks for the various cases.

Returns an int with bit flags set according to the above diff3 categories.

Negative returns indicate an error.

Definition at line 1009 of file db_diff.c.

References bu_free_external(), BU_GET, bu_log(), bu_ptbl_ins(), BU_PUT, directory::d_major_type, directory::d_namep, DB_COMPARE_ALL, DB_COMPARE_ATTRS, DB_COMPARE_PARAM, db_diff3_dp(), db_diff_external(), db_get_external(), db_lookup(), DIFF_CHANGED, DIFF_EMPTY, diff_free_result(), diff_init_result(), DIFF_UNCHANGED, FOR_ALL_DIRECTORY_END, FOR_ALL_DIRECTORY_START, and RT_DIR_NULL.

Here is the call graph for this function: