| 1 | #include "RefGroup_ccapi.h" |
|---|
| 2 | |
|---|
| 3 | #include "RefGroup.hpp" |
|---|
| 4 | #include "RefEntity.hpp" |
|---|
| 5 | #include "DLRefEntityList.hpp" |
|---|
| 6 | #include "DLRefGroupList.hpp" |
|---|
| 7 | #include "DLCubitEntityList.hpp" |
|---|
| 8 | #include "CubitBox.hpp" |
|---|
| 9 | |
|---|
| 10 | #include "copy_defines.h" |
|---|
| 11 | |
|---|
| 12 | int RefGroup_maximum_dimension(void *this_group) |
|---|
| 13 | { |
|---|
| 14 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 15 | return temp_group->maximum_dimension(); |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | //- This routine returns the maximum dimension of its owned subentities. |
|---|
| 19 | //- The 'only' kludge is that if one of its subentities is a RefGroup, it |
|---|
| 20 | //- must call 'maximum_dimension' on that entity instead of dimension(). |
|---|
| 21 | |
|---|
| 22 | enum EntityType RefGroup_entity_type(void *this_group) |
|---|
| 23 | { return RefGroup_TYPE; } |
|---|
| 24 | //- return the type for this geometryEntity |
|---|
| 25 | |
|---|
| 26 | enum CubitStatus RefGroup_add_ref_entity_1(void *this_group, |
|---|
| 27 | /* RefEntity * */ void *ref_entity) |
|---|
| 28 | { |
|---|
| 29 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 30 | RefEntity *temp_ref_entity = (RefEntity *) ref_entity; |
|---|
| 31 | |
|---|
| 32 | return temp_group->add_ref_entity(temp_ref_entity); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | enum CubitStatus RefGroup_add_ref_entity_2(void *this_group, |
|---|
| 37 | /* DLRefEntityList& */ void ***entity_list, |
|---|
| 38 | int *entity_list_size) |
|---|
| 39 | { |
|---|
| 40 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 41 | DLRefEntityList temp_entity_list; |
|---|
| 42 | COPY_ARRAY_TO_LIST(*entity_list, *entity_list_size, temp_entity_list); |
|---|
| 43 | |
|---|
| 44 | return temp_group->add_ref_entity(temp_entity_list); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | enum CubitStatus RefGroup_remove_ref_entity(void *this_group, |
|---|
| 49 | /* RefEntity * */ void *ref_entity, |
|---|
| 50 | const enum CubitBoolean from_observable) |
|---|
| 51 | { |
|---|
| 52 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 53 | RefEntity *temp_ref_entity = (RefEntity *) ref_entity; |
|---|
| 54 | |
|---|
| 55 | return temp_group->remove_ref_entity(temp_ref_entity); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | //- add or remove one or more ref entities to/from this group |
|---|
| 60 | |
|---|
| 61 | void RefGroup_get_sub_entities(void *this_group, |
|---|
| 62 | /* DLRefEntityList & */ void ***entity_list, |
|---|
| 63 | int *entity_list_size) |
|---|
| 64 | { |
|---|
| 65 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 66 | DLRefEntityList temp_entity_list; |
|---|
| 67 | |
|---|
| 68 | temp_group->get_sub_entities(temp_entity_list); |
|---|
| 69 | |
|---|
| 70 | COPY_LIST_TO_ARRAY(temp_entity_list, *entity_list, *entity_list_size); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | //- appends all ref entities owned by this entity and recurses |
|---|
| 74 | //- down to dimension 0 |
|---|
| 75 | |
|---|
| 76 | void RefGroup_is_mergeable_1(void *this_group, int val) |
|---|
| 77 | { |
|---|
| 78 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 79 | temp_group->is_mergeable(val); |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | int RefGroup_is_mergeable_2(void *this_group) |
|---|
| 84 | { |
|---|
| 85 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 86 | return temp_group->is_mergeable(); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | int RefGroup_remove_all_ref_entities(void *this_group) |
|---|
| 91 | { |
|---|
| 92 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 93 | return temp_group->remove_all_ref_entities(); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | //- remove all geometry entities in the group. |
|---|
| 97 | //- Returns number of items removed. |
|---|
| 98 | |
|---|
| 99 | void RefGroup_get_parent_ref_entities(void *this_group, |
|---|
| 100 | /* DLRefEntityList& */ void ***, |
|---|
| 101 | int *) |
|---|
| 102 | { |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | //- appends all ref entities that own this to entity_list. |
|---|
| 106 | //- Goes up just one dimension. |
|---|
| 107 | |
|---|
| 108 | void RefGroup_get_child_ref_entities(void *this_group, |
|---|
| 109 | /* DLRefEntityList& */ void ***entity_list, |
|---|
| 110 | int *entity_list_size) |
|---|
| 111 | { |
|---|
| 112 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 113 | DLRefEntityList temp_entity_list; |
|---|
| 114 | |
|---|
| 115 | temp_group->get_child_ref_entities(temp_entity_list); |
|---|
| 116 | |
|---|
| 117 | COPY_LIST_TO_ARRAY(temp_entity_list, *entity_list, *entity_list_size); |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | //- appends all immediate ref entities owned by this entity on entity_list |
|---|
| 121 | //- Goes down just one dimension. |
|---|
| 122 | |
|---|
| 123 | void RefGroup_get_child_entities(void *this_group, |
|---|
| 124 | /* DLCubitEntityList& */ void ***cub_entity_list, |
|---|
| 125 | int *cub_entity_list_size) |
|---|
| 126 | { |
|---|
| 127 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 128 | DLCubitEntityList temp_cub_entity_list; |
|---|
| 129 | |
|---|
| 130 | temp_group->get_child_entities(temp_cub_entity_list); |
|---|
| 131 | |
|---|
| 132 | COPY_LIST_TO_ARRAY(temp_cub_entity_list, *cub_entity_list, *cub_entity_list_size); |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | //- appends all immediate ref entities owned by this entity on entity_list |
|---|
| 136 | //- Goes down just one dimension. |
|---|
| 137 | |
|---|
| 138 | void RefGroup_expand_group(void *this_group, |
|---|
| 139 | /* DLRefEntityList& */ void ***entity_list, |
|---|
| 140 | int *entity_list_size) |
|---|
| 141 | { |
|---|
| 142 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 143 | DLRefEntityList temp_entity_list; |
|---|
| 144 | |
|---|
| 145 | temp_group->expand_group(temp_entity_list); |
|---|
| 146 | |
|---|
| 147 | COPY_LIST_TO_ARRAY(temp_entity_list, *entity_list, *entity_list_size); |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | //- appends all the ref entities owned by this group. It will go down |
|---|
| 151 | //- until there are no ref-groups in the entity_list. |
|---|
| 152 | |
|---|
| 153 | struct CubitBoxStruct RefGroup_bounding_box(void *this_group) |
|---|
| 154 | { |
|---|
| 155 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 156 | return temp_group->bounding_box(); |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | struct CubitVectorStruct RefGroup_center_point(void *this_group) |
|---|
| 161 | { |
|---|
| 162 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 163 | return temp_group->center_point(); |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | void* RefGroup_get_address(void *this_group, |
|---|
| 168 | enum EntityType inputEntityType) |
|---|
| 169 | { |
|---|
| 170 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 171 | return temp_group->get_address(inputEntityType); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | //R void* |
|---|
| 175 | //R- Returned void pointer |
|---|
| 176 | //I inputEntityType |
|---|
| 177 | //I- The input type to get the address of. |
|---|
| 178 | //- This function returns a void pointer that points to the |
|---|
| 179 | //- "appropriate" portion of this object. The appropriate |
|---|
| 180 | //- portion is determined by the input EntityType variable. |
|---|
| 181 | //- Returns NULL if the input type and the type of "this" |
|---|
| 182 | //- are not related by inheritance. |
|---|
| 183 | //- Note: The RTTI capabilities encoded in these functions |
|---|
| 184 | //- are designed to work with any form of multiple |
|---|
| 185 | //- inheritance, as well. Multiple inheritance is what |
|---|
| 186 | //- necessitates having this function defined in every |
|---|
| 187 | //- class in the hierarchy. |
|---|
| 188 | //- Note: This function can also be used to merely check if |
|---|
| 189 | //- an object of one type is related to another type |
|---|
| 190 | //- through inheritance. If a non-NULL pointer is |
|---|
| 191 | //- returned, then this is true. |
|---|
| 192 | |
|---|
| 193 | int RefGroup_subtract(void *this_group, |
|---|
| 194 | /* RefGroup * */ void *group_to_subtract, |
|---|
| 195 | /* RefGroup * */ void *target_group) |
|---|
| 196 | { |
|---|
| 197 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 198 | RefGroup *temp_group_to_subtract = (RefGroup *) group_to_subtract; |
|---|
| 199 | RefGroup *temp_target_group = (RefGroup *) target_group; |
|---|
| 200 | |
|---|
| 201 | return temp_group->subtract(temp_group_to_subtract, temp_target_group); |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | //- subtract group_to_subtract from this group |
|---|
| 205 | |
|---|
| 206 | int RefGroup_intersect(void *this_group, |
|---|
| 207 | /* RefGroup * */ void *other_group, |
|---|
| 208 | /* RefGroup * */ void *target_group) |
|---|
| 209 | { |
|---|
| 210 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 211 | RefGroup *temp_other_group = (RefGroup *) other_group; |
|---|
| 212 | RefGroup *temp_target_group = (RefGroup *) target_group; |
|---|
| 213 | |
|---|
| 214 | return temp_group->intersect(temp_other_group, temp_target_group); |
|---|
| 215 | } |
|---|
| 216 | |
|---|
| 217 | //- intersect other_group with this one |
|---|
| 218 | |
|---|
| 219 | int RefGroup_unite(void *this_group, |
|---|
| 220 | /* RefGroup * */ void *other_group, |
|---|
| 221 | /* RefGroup * */ void *target_group) |
|---|
| 222 | { |
|---|
| 223 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 224 | RefGroup *temp_other_group = (RefGroup *) other_group; |
|---|
| 225 | |
|---|
| 226 | RefGroup *temp_target_group = (RefGroup *) target_group; |
|---|
| 227 | |
|---|
| 228 | return temp_group->unite(temp_other_group, temp_target_group); |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | //- unite other_group with this one |
|---|
| 232 | |
|---|
| 233 | int RefGroup_validate(void *this_group) |
|---|
| 234 | { |
|---|
| 235 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 236 | return temp_group->validate(); |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | //- Return number of problems detected, 0 if none. |
|---|
| 240 | |
|---|
| 241 | void RefGroup_draw (void *this_group, int color) |
|---|
| 242 | { |
|---|
| 243 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 244 | temp_group->draw (color); |
|---|
| 245 | } |
|---|
| 246 | |
|---|
| 247 | //- draw the group's contained entities |
|---|
| 248 | |
|---|
| 249 | static enum CubitStatus RefGroup_delete_group (void *this_group, |
|---|
| 250 | /* RefGroup * */ void *group_ptr, |
|---|
| 251 | enum CubitBoolean propagate) |
|---|
| 252 | { |
|---|
| 253 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 254 | RefGroup *temp_group_ptr = (RefGroup *) group_ptr; |
|---|
| 255 | |
|---|
| 256 | return temp_group->delete_group (temp_group_ptr, propagate); |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | //- deletes a specified group from the global group list |
|---|
| 260 | //- if the boolean "propagate" is true, the groups sub_groups are |
|---|
| 261 | //- deleted also; as well as the sub_group's groups, etc.. |
|---|
| 262 | |
|---|
| 263 | void RefGroup_delete_all_groups (void *) |
|---|
| 264 | { |
|---|
| 265 | RefGroup::delete_all_groups (); |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | //- deletes all the groups from the model (except for 'picked_group' and 'drawn_group') |
|---|
| 269 | |
|---|
| 270 | void RefGroup_get_contained_groups (void *, |
|---|
| 271 | /* RefGroup * */ void *group_ptr, |
|---|
| 272 | /* DLRefGroupList & */ void ***contained_groups, |
|---|
| 273 | int *contained_groups_size) |
|---|
| 274 | { |
|---|
| 275 | DLRefGroupList temp_contained_groups; |
|---|
| 276 | RefGroup *temp_group_ptr = (RefGroup *) group_ptr; |
|---|
| 277 | |
|---|
| 278 | RefGroup::get_contained_groups (temp_group_ptr, temp_contained_groups); |
|---|
| 279 | |
|---|
| 280 | COPY_LIST_TO_ARRAY(temp_contained_groups, *contained_groups, *contained_groups_size); |
|---|
| 281 | } |
|---|
| 282 | |
|---|
| 283 | //- gets the groups owned by group_ptr, as well as any other groups |
|---|
| 284 | //- owned by these groups, etc.. Current group (group_ptr) is also |
|---|
| 285 | //- added to the list. |
|---|
| 286 | |
|---|
| 287 | void RefGroup_get_groups_within_1(void *, |
|---|
| 288 | /* CubitEntity* */ void *cubit_entity_ptr, |
|---|
| 289 | /* DLRefGroupList & */ void ***groups_within, |
|---|
| 290 | int *groups_within_size, |
|---|
| 291 | const enum CubitBoolean recursive) |
|---|
| 292 | { |
|---|
| 293 | DLRefGroupList temp_groups_within; |
|---|
| 294 | CubitEntity *temp_cubit_entity_ptr = (CubitEntity*) cubit_entity_ptr; |
|---|
| 295 | |
|---|
| 296 | RefGroup::get_groups_within(temp_cubit_entity_ptr, temp_groups_within, |
|---|
| 297 | recursive); |
|---|
| 298 | |
|---|
| 299 | COPY_LIST_TO_ARRAY(temp_groups_within, *groups_within, *groups_within_size); |
|---|
| 300 | } |
|---|
| 301 | |
|---|
| 302 | void RefGroup_get_groups_within_2(void *, |
|---|
| 303 | /* RefEntity* */ void *ref_entity_ptr, |
|---|
| 304 | /* DLRefGroupList & */ void ***groups_within, |
|---|
| 305 | int *groups_within_size, |
|---|
| 306 | const enum CubitBoolean recursive) |
|---|
| 307 | { |
|---|
| 308 | DLRefGroupList temp_groups_within; |
|---|
| 309 | RefEntity*temp_ref_entity_ptr = (RefEntity*) ref_entity_ptr; |
|---|
| 310 | |
|---|
| 311 | RefGroup::get_groups_within(temp_ref_entity_ptr, temp_groups_within, |
|---|
| 312 | recursive); |
|---|
| 313 | |
|---|
| 314 | COPY_LIST_TO_ARRAY(temp_groups_within, *groups_within, *groups_within_size); |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | void RefGroup_get_groups_within_3(void *, |
|---|
| 318 | /* RefGroup* */ void *ref_group_ptr, |
|---|
| 319 | /* DLRefGroupList & */ void ***groups_within, |
|---|
| 320 | int *groups_within_size, |
|---|
| 321 | const enum CubitBoolean recursive) |
|---|
| 322 | { |
|---|
| 323 | DLRefGroupList temp_groups_within; |
|---|
| 324 | RefGroup *temp_ref_group_ptr = (RefGroup*) ref_group_ptr; |
|---|
| 325 | |
|---|
| 326 | RefGroup::get_groups_within(temp_ref_group_ptr, temp_groups_within, recursive); |
|---|
| 327 | |
|---|
| 328 | COPY_LIST_TO_ARRAY(temp_groups_within, *groups_within, *groups_within_size); |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | //- Finds those groups which contain the input entity, at any level |
|---|
| 332 | //- (i.e., if group 2 contains group 3 which contains the entity, then |
|---|
| 333 | //- group 2 and group 3 will be returned in the output list). |
|---|
| 334 | |
|---|
| 335 | enum CubitStatus RefGroup_notify_observer(void *this_group, |
|---|
| 336 | /* CubitObservable * */ void *observable, |
|---|
| 337 | const /* CubitEvent & */ void *observer_event, |
|---|
| 338 | enum CubitBoolean from_observable) |
|---|
| 339 | { |
|---|
| 340 | RefGroup *temp_group = (RefGroup *) this_group; |
|---|
| 341 | CubitObservable *temp_observable = (CubitObservable *) observable; |
|---|
| 342 | CubitEvent *temp_observer_event = (CubitEvent *) observer_event; |
|---|
| 343 | |
|---|
| 344 | return temp_group->notify_observer(temp_observable, *temp_observer_event, from_observable); |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | //- handle notify observer function |
|---|