BRL-CAD
shape_recognition.h
Go to the documentation of this file.
1 #include "common.h"
2 #include "bu/ptbl.h"
3 #include "brep.h"
4 
5 #ifndef SHAPE_RECOGNITION_H
6 #define SHAPE_RECOGNITION_H
7 
8 #define BREP_PLANAR_TOL 0.05
9 #define BREP_CYLINDRICAL_TOL 0.05
10 #define BREP_CONIC_TOL 0.05
11 #define BREP_SPHERICAL_TOL 0.05
12 #define BREP_ELLIPSOIDAL_TOL 0.05
13 #define BREP_TOROIDAL_TOL 0.05
14 
15 typedef enum {
22  //Insert any new types here
23  CURVE_GENERAL /* A curve that does not fit in any of the previous categories */
24 } curve_t;
25 
26 typedef enum {
36  //Insert any new types here
37  SURFACE_GENERAL /* A surface that does not fit in any of the previous categories */
38 } surface_t;
39 
40 typedef enum {
41  COMB = 0, /* A comb is a boolean combination of other solids */
48  //Insert any new types here
49  BREP /* A brep is a complex solid that cannot be represented by CSG */
50 } volume_t;
51 
52 struct filter_obj {
53  ON_Plane* plane;
54  ON_Sphere* sphere;
55  ON_Cylinder* cylinder;
56  ON_Cone* cone;
57  ON_Torus* torus;
60 };
61 void filter_obj_init(struct filter_obj *);
62 void filter_obj_free(struct filter_obj *);
63 
64 curve_t GetCurveType(ON_Curve *curve);
65 surface_t GetSurfaceType(const ON_Surface *surface, struct filter_obj *obj);
66 
67 
68 void set_to_array(int **array, int *array_cnt, std::set<int> *set);
69 void array_to_set(std::set<int> *set, int *array, int array_cnt);
70 
71 
72 /* Structure for holding parameters corresponding
73  * to a csg primitive. Not all parameters will be
74  * used for all primitives - the structure includes
75  * enough data slots to describe any primitive that may
76  * be matched by the shape recognition logic */
78  point_t origin;
79  vect_t hv;
83 };
84 
86  struct bu_vls *key;
87  int *faces;
88  int *loops;
89  int *edges;
90  int *fol; /* Faces with outer loops in object loop network */
91  int *fil; /* Faces with only inner loops in object loop network */
92  int faces_cnt;
93  int loops_cnt;
94  int edges_cnt;
95  int fol_cnt;
96  int fil_cnt;
97 
98  /* Maps */
99  int *face_map;
101  int *edge_map;
103  int *loop_map;
104  int *c3_map;
105  int *c2_map;
106  int *trim_map;
115 
121  struct bu_ptbl *children;
122 };
123 
124 void subbrep_object_init(struct subbrep_object_data *obj, ON_Brep *brep);
125 void subbrep_object_free(struct subbrep_object_data *obj);
126 
129 
130 struct bu_ptbl *find_subbreps(ON_Brep *brep);
131 void print_subbrep_object(struct subbrep_object_data *data, const char *offset);
133 
135 
136 int cylindrical_loop_planar_vertices(ON_BrepFace *face, int loop_index);
138 int cylinder_csg(struct subbrep_object_data *data, fastf_t cyl_tol);
139 
140 int subbrep_is_cone(struct subbrep_object_data *data, fastf_t cone_tol);
141 int cone_csg(struct subbrep_object_data *data, fastf_t cone_tol);
142 
143 
144 
145 #endif /* SHAPE_RECOGNITION_H */
146 
147 // Local Variables:
148 // tab-width: 8
149 // mode: C++
150 // c-basic-offset: 4
151 // indent-tabs-mode: t
152 // c-file-style: "stroustrup"
153 // End:
154 // ex: shiftwidth=4 tabstop=8
int cylindrical_loop_planar_vertices(ON_BrepFace *face, int loop_index)
int subbrep_is_cone(struct subbrep_object_data *data, fastf_t cone_tol)
int subbrep_is_planar(struct subbrep_object_data *data)
volume_t
curve_t GetCurveType(ON_Curve *curve)
void subbrep_object_init(struct subbrep_object_data *obj, ON_Brep *brep)
void array_to_set(std::set< int > *set, int *array, int array_cnt)
Header file for the BRL-CAD common definitions.
Definition: ptbl.h:62
COMPLEX data[64]
Definition: fftest.c:34
ON_Plane * plane
void set_to_array(int **array, int *array_cnt, std::set< int > *set)
int subbrep_split(struct subbrep_object_data *data)
struct bu_ptbl * children
ON_Cone * cone
void filter_obj_free(struct filter_obj *)
int subbrep_make_brep(struct subbrep_object_data *data)
void filter_obj_init(struct filter_obj *)
void print_subbrep_object(struct subbrep_object_data *data, const char *offset)
surface_t
int cylinder_csg(struct subbrep_object_data *data, fastf_t cyl_tol)
struct bu_ptbl * find_subbreps(ON_Brep *brep)
subbrep_object_data * parent
ON_Torus * torus
int subbrep_is_cylinder(struct subbrep_object_data *data, fastf_t cyl_tol)
struct bu_vls * key
surface_t stype
volume_t subbrep_shape_recognize(struct subbrep_object_data *data)
ON_Sphere * sphere
void subbrep_object_free(struct subbrep_object_data *obj)
Definition: vls.h:56
double fastf_t
Definition: defines.h:300
ON_Cylinder * cylinder
csg_object_params * params
int cone_csg(struct subbrep_object_data *data, fastf_t cone_tol)
surface_t GetSurfaceType(const ON_Surface *surface, struct filter_obj *obj)