BRL-CAD
analyze.h
Go to the documentation of this file.
1 /* A N A L Y Z E . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file analyze.h
21  *
22  * Functions provided by the LIBANALYZE geometry analysis library.
23  *
24  */
25 
26 #ifndef ANALYZE_H
27 #define ANALYZE_H
28 
29 #include "common.h"
30 
31 #include "raytrace.h"
32 
34 
35 #ifndef ANALYZE_EXPORT
36 # if defined(ANALYZE_DLL_EXPORTS) && defined(ANALYZE_DLL_IMPORTS)
37 # error "Only ANALYZE_DLL_EXPORTS or ANALYZE_DLL_IMPORTS can be defined, not both."
38 # elif defined(ANALYZE_DLL_EXPORTS)
39 # define ANALYZE_EXPORT __declspec(dllexport)
40 # elif defined(ANALYZE_DLL_IMPORTS)
41 # define ANALYZE_EXPORT __declspec(dllimport)
42 # else
43 # define ANALYZE_EXPORT
44 # endif
45 #endif
46 
47 /* Libanalyze return codes */
48 #define ANALYZE_OK 0x0000
49 #define ANALYZE_ERROR 0x0001 /**< something went wrong, function not completed */
50 
51 /*
52  * Density specific structures
53  */
54 
55 #define DENSITY_MAGIC 0xaf0127
56 
57 /* the entries in the density table */
58 struct density_entry {
59  uint32_t magic;
61  char *name;
62 };
63 
64 /*
65  * Overlap specific structures
66  */
67 
68 struct region_pair {
69  struct bu_list l;
70  union {
71  char *name;
72  struct region *r1;
73  } r;
74  struct region *r2;
75  unsigned long count;
76  double max_dist;
77  vect_t coord;
78 };
79 
80 /*
81  * Voxel specific structures
82  */
83 
84 /**
85  * This structure is for lists that store region names for each voxel
86  */
87 
88 struct voxelRegion {
89  char *regionName;
92 };
93 
94 /**
95  * This structure stores the information about voxels provided by a single raytrace.
96  */
97 
98 struct rayInfo {
102 };
103 
104 /**
105  * Routine to parse a .density file
106  */
107 ANALYZE_EXPORT extern int parse_densities_buffer(char *buf,
108  size_t len,
109  struct density_entry *densities,
110  struct bu_vls *result_str,
111  int *num_densities);
112 
113 /**
114  * region_pair for gqa
115  */
116 ANALYZE_EXPORT extern struct region_pair *add_unique_pair(struct region_pair *list,
117  struct region *r1,
118  struct region *r2,
119  double dist, point_t pt);
120 
121 
122 /**
123  * voxelize function takes raytrace instance and user parameters as inputs
124  */
125 ANALYZE_EXPORT extern void
126 voxelize(struct rt_i *rtip, fastf_t voxelSize[3], int levelOfDetail, void (*create_boxes)(void *callBackData, int x, int y, int z, const char *regionName, fastf_t percentageFill), void *callBackData);
127 
128 
129 /* diff.c */
130 
131 /* One of the design goals of this API is to allow developers
132  * to access the results of the diffing process in a structured
133  * way that lets them create their own custom reports, scripts,
134  * visualizations, etc. The functions diff_dp and diff_dbip are
135  * the workhorse functions that do the actual diffing, and the
136  * remainder of the API is devoted to accessing the results.
137  */
138 
139 /**
140  * Analyze the difference between two directory objects
141  *
142  * Returns a pointer to the results structure. If the first
143  * parameter is NULL, diff_dp will create a results structure - else,
144  * it uses the one provided. This allows a calling function to
145  * allocate a large number of result containers at once.
146  */
147 ANALYZE_EXPORT void *
148 diff_dp(void *result_in, struct directory *dp1, struct directory *dp2, struct db_i *dbip1, struct db_i *dbip2);
149 
150 /**
151  * Analyze the difference between two database objects
152  *
153  * Returns a bu_ptbl of results, which can be interpreted
154  * by diff_result and friends. To free the elements call
155  * diff_free_ptbl.
156  */
157 ANALYZE_EXPORT struct bu_ptbl *
158 diff_dbip(struct db_i *dbip1, struct db_i *dbip2);
159 
160 /**
161  * Free diff result
162  */
163 ANALYZE_EXPORT void
164 diff_free(void *result);
165 
166 /**
167  * Free diff results in a bu_ptbl
168  */
169 ANALYZE_EXPORT void
170 diff_free_ptbl(struct bu_ptbl *results_table);
171 
172 typedef enum {
173  DIFF_NONE = 0, /* No difference between objects */
174  DIFF_REMOVED, /* Items removed, none added or changed */
175  DIFF_ADDED, /* Items added, none removed or changed */
176  DIFF_TYPECHANGE, /* Item underwent a change in type (e.g. sph -> arb8) */
177  DIFF_BINARY, /* Only binary change testing available */
178  DIFF /* Differences present (none of the above cases */
179 } diff_t;
180 
181 /**
182  * Report on the status of the result object - 0 is OK, 1 means
183  * something went wrong with the diff.
184  */
185 ANALYZE_EXPORT int
186 diff_status(void *result);
187 
188 /**
189  * Report on the type of diff result contained in the object
190  */
191 ANALYZE_EXPORT diff_t
192 diff_type(void *result);
193 
194 typedef enum {
205 } diff_result_t;
206 
207 /**
208  * Return the attribute/value set corresponding to a particular
209  * subgroup in the result, as enumerated by the diff_result_t
210  * types.
211  */
212 ANALYZE_EXPORT struct bu_attribute_value_set *
213 diff_result(void *result, diff_result_t result_type);
214 
215 typedef enum {
218 } diff_obj_t;
219 
220 /**
221  * Return the directory pointer corresponding to either
222  * the original object or the object being compared to it.
223  */
224 ANALYZE_EXPORT struct directory *
225 diff_info_dp(void *result, diff_obj_t obj_type);
226 
227 /**
228  * Return the rt_db_internal information for either
229  * the original object or the object being compared to it.
230  */
231 ANALYZE_EXPORT struct rt_db_internal *
232 diff_info_intern(void *result, diff_obj_t obj_type);
233 
234 
236 
237 #endif /* ANALYZE_H */
238 
239 /*
240  * Local Variables:
241  * tab-width: 8
242  * mode: C
243  * indent-tabs-mode: t
244  * c-file-style: "stroustrup"
245  * End:
246  * ex: shiftwidth=4 tabstop=8
247  */
diff_t diff_type(void *result)
Definition: raytrace.h:800
Definition: analyze.h:178
Definition: list.h:118
void diff_free_ptbl(struct bu_ptbl *results_table)
diff_t
Definition: analyze.h:172
void voxelize(struct rt_i *rtip, fastf_t voxelSize[3], int levelOfDetail, void(*create_boxes)(void *callBackData, int x, int y, int z, const char *regionName, fastf_t percentageFill), void *callBackData)
Definition: voxels.c:147
unsigned long count
Definition: analyze.h:75
int diff_status(void *result)
fastf_t * fillDistances
Definition: analyze.h:100
struct bu_list l
Definition: analyze.h:69
Header file for the BRL-CAD common definitions.
void * diff_dp(void *result_in, struct directory *dp1, struct directory *dp2, struct db_i *dbip1, struct db_i *dbip2)
double grams_per_cu_mm
Definition: analyze.h:60
struct region * r2
Definition: analyze.h:74
Definition: ptbl.h:62
struct region * r1
Definition: analyze.h:72
diff_obj_t
Definition: analyze.h:215
struct density_entry * densities
Definition: gqa.c:167
#define __BEGIN_DECLS
Definition: common.h:73
fastf_t sizeVoxel
Definition: analyze.h:99
char * regionName
Definition: analyze.h:89
vect_t coord
Definition: analyze.h:77
struct directory * diff_info_dp(void *result, diff_obj_t obj_type)
struct voxelRegion * nextRegion
Definition: analyze.h:91
char * name
Definition: analyze.h:71
union region_pair::@16 r
uint32_t magic
Definition: analyze.h:59
int parse_densities_buffer(char *buf, size_t len, struct density_entry *densities, struct bu_vls *result_str, int *num_densities)
Definition: density.c:28
struct rt_db_internal * diff_info_intern(void *result, diff_obj_t obj_type)
char * name
Definition: analyze.h:61
Definition: analyze.h:58
double max_dist
Definition: analyze.h:76
diff_result_t
Definition: analyze.h:194
struct voxelRegion * regionList
Definition: analyze.h:101
#define __END_DECLS
Definition: common.h:74
void diff_free(void *result)
HIDDEN void create_boxes(void *callBackData, int x, int y, int z, const char *a, fastf_t fill)
Definition: voxelize.c:51
struct bu_attribute_value_set * diff_result(void *result, diff_result_t result_type)
Definition: vls.h:56
double fastf_t
Definition: defines.h:300
fastf_t regionDistance
Definition: analyze.h:90
struct bu_ptbl * diff_dbip(struct db_i *dbip1, struct db_i *dbip2)
struct region_pair * add_unique_pair(struct region_pair *list, struct region *r1, struct region *r2, double dist, point_t pt)
Definition: overlaps.c:31