~FieldCache() { if (0 != id) { Cmiss_field_cache_destroy(&id); } }
StrainMeasures::~StrainMeasures() { for (unsigned int i = 0; i < num_elements; i++) { Cmiss_element_destroy(&(elements[i])); } Cmiss_field_module_destroy(&field_module); Cmiss_field_cache_destroy(&fieldCache); Cmiss_field_destroy(&coordianteField); Cmiss_context_destroy(&context_); }
FieldCache& operator=(const FieldCache& fieldCache) { Cmiss_field_cache_id temp_id = Cmiss_field_cache_access(fieldCache.id); if (0 != id) { Cmiss_field_cache_destroy(&id); } id = temp_id; return *this; }
ShortAxisFitting::~ShortAxisFitting() { for (int i = 0; i < NUMBER_OF_NODES; i++) { Cmiss_node_destroy(&cmiss_nodes[i]); } Cmiss_field_cache_destroy(&cache); Cmiss_field_destroy(&coordinates_rc_); Cmiss_field_module_destroy(&field_module_); Cmiss_context_destroy(&context_); delete[] initialSegmentLengths; for (int i = 0; i < 24; i++) { delete[] segmentNodes[i]; } delete[] segmentNodes; }
static void Element_tool_interactive_event_handler(void *device_id, struct Interactive_event *event,void *element_tool_void, struct Graphics_buffer *graphics_buffer) /******************************************************************************* LAST MODIFIED 18 November 2005 DESCRIPTION : Input handler for input from devices. <device_id> is a unique address enabling the editor to handle input from more than one device at a time. The <event> describes the type of event, button numbers and key modifiers, and the volume of space affected by the interaction. Main events are button press, movement and release. ==============================================================================*/ { enum Interactive_event_type event_type; FE_value time, xi[MAXIMUM_ELEMENT_XI_DIMENSIONS]; int clear_selection, element_dimension, i, input_modifier, number_of_xi_points, shift_pressed; int number_in_xi[MAXIMUM_ELEMENT_XI_DIMENSIONS]; struct FE_element *picked_element; struct FE_element_shape *element_shape; struct Element_tool *element_tool; struct Interaction_volume *interaction_volume,*temp_interaction_volume; struct LIST(Scene_picked_object) *scene_picked_object_list; struct Scene *scene; struct Cmiss_rendition *rendition = NULL; FE_value_triple *xi_points; ENTER(Element_tool_interactive_event_handler); if (device_id&&event&&(element_tool= (struct Element_tool *)element_tool_void)) { Cmiss_region_begin_hierarchical_change(element_tool->region); interaction_volume=Interactive_event_get_interaction_volume(event); scene=Interactive_event_get_scene(event); if (scene != 0) { event_type=Interactive_event_get_type(event); input_modifier=Interactive_event_get_input_modifier(event); shift_pressed=(INTERACTIVE_EVENT_MODIFIER_SHIFT & input_modifier); switch (event_type) { case INTERACTIVE_EVENT_BUTTON_PRESS: { /* interaction only works with first mouse button */ if (1==Interactive_event_get_button_number(event)) { scene_picked_object_list= Scene_pick_objects(scene,interaction_volume,graphics_buffer); if (scene_picked_object_list != 0) { element_tool->picked_element_was_unselected=1; if (0 != (picked_element=Scene_picked_object_list_get_nearest_element( scene_picked_object_list,(struct Cmiss_region *)NULL, element_tool->select_elements_enabled, element_tool->select_faces_enabled, element_tool->select_lines_enabled, (struct Scene_picked_object **)NULL, &rendition, (struct Cmiss_graphic **)NULL))) { /* Open command_field of picked_element in browser */ if (element_tool->command_field) { if (element_tool->time_keeper) { time = Time_keeper_get_time(element_tool->time_keeper); } else { time = 0; } /* since we don't really have fields constant over an element, evaluate at its centre */ element_dimension = get_FE_element_dimension(picked_element); for (i = 0; i < element_dimension; i++) { number_in_xi[i] = 1; } get_FE_element_shape(picked_element, &element_shape); if (FE_element_shape_get_xi_points_cell_centres( element_shape, number_in_xi, &number_of_xi_points, &xi_points)) { /*???debug*/printf("element_tool: xi ="); for (i = 0; i < element_dimension; i++) { xi[i] = xi_points[0][i]; /*???debug*/printf(" %g",xi[i]); } /*???debug*/printf("\n"); Cmiss_field_module_id field_module = Cmiss_field_get_field_module(element_tool->command_field); Cmiss_field_cache_id field_cache = Cmiss_field_module_create_cache(field_module); Cmiss_field_cache_set_time(field_cache, time); Cmiss_field_cache_set_mesh_location(field_cache, picked_element, element_dimension, xi); char *command_string = Cmiss_field_evaluate_string(element_tool->command_field, field_cache); if (command_string) { Execute_command_execute_string(element_tool->execute_command, command_string); DEALLOCATE(command_string); } Cmiss_field_cache_destroy(&field_cache); Cmiss_field_module_destroy(&field_module); DEALLOCATE(xi_points); } } Cmiss_field_group_id group = Cmiss_rendition_get_selection_group(rendition); if (group) { Cmiss_region_id temp_region = Cmiss_rendition_get_region(rendition); Cmiss_field_module_id field_module = Cmiss_region_get_field_module(temp_region); int dimension = Cmiss_element_get_dimension(picked_element); Cmiss_mesh_id master_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(group, master_mesh); Cmiss_mesh_destroy(&master_mesh); if (element_group) { Cmiss_mesh_group_id mesh_group = Cmiss_field_element_group_get_mesh(element_group); element_tool->picked_element_was_unselected = !Cmiss_mesh_contains_element(Cmiss_mesh_group_base_cast(mesh_group), picked_element); Cmiss_mesh_group_destroy(&mesh_group); Cmiss_field_element_group_destroy(&element_group); } Cmiss_field_group_destroy(&group); Cmiss_field_module_destroy(&field_module); } } REACCESS(FE_element)(&(element_tool->last_picked_element), picked_element); /*(if ((clear_selection = !shift_pressed) &&((!picked_element)|| (element_tool->picked_element_was_unselected)))*/ clear_selection = !shift_pressed; if (clear_selection) { if (element_tool->region) { Cmiss_rendition *root_rendition = Cmiss_region_get_rendition_internal(element_tool->region); Cmiss_field_group_id root_group = Cmiss_rendition_get_selection_group(root_rendition); if (root_group) { Cmiss_field_group_clear_region_tree_element(root_group); Cmiss_field_group_destroy(&root_group); } Cmiss_rendition_destroy(&root_rendition); } } if (picked_element) { REACCESS(Cmiss_rendition)(&(element_tool->rendition), rendition); Cmiss_region *sub_region = NULL; Cmiss_field_group_id sub_group = NULL; Cmiss_mesh_group_id mesh_group = 0; if (element_tool->rendition) { sub_region = Cmiss_rendition_get_region(element_tool->rendition); sub_group = Cmiss_rendition_get_or_create_selection_group(element_tool->rendition); if (sub_group) { int dimension = Cmiss_element_get_dimension(picked_element); Cmiss_field_module_id field_module = Cmiss_region_get_field_module(sub_region); Cmiss_mesh_id temp_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(sub_group, temp_mesh); if (!element_group) element_group = Cmiss_field_group_create_element_group(sub_group, temp_mesh); mesh_group = Cmiss_field_element_group_get_mesh(element_group); Cmiss_field_element_group_destroy(&element_group); Cmiss_mesh_destroy(&temp_mesh); Cmiss_field_module_destroy(&field_module); } } if (mesh_group) { Cmiss_mesh_group_add_element(mesh_group, picked_element); Cmiss_mesh_group_destroy(&mesh_group); } if (sub_group) { Cmiss_field_group_destroy(&sub_group); } } DESTROY(LIST(Scene_picked_object))(&(scene_picked_object_list)); } element_tool->motion_detected=0; REACCESS(Interaction_volume)( &(element_tool->last_interaction_volume),interaction_volume); } } break; case INTERACTIVE_EVENT_MOTION_NOTIFY: case INTERACTIVE_EVENT_BUTTON_RELEASE: { if (element_tool->last_interaction_volume&& ((INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) || (1==Interactive_event_get_button_number(event)))) { if (INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) { element_tool->motion_detected=1; } if (element_tool->last_picked_element) { /* unselect last_picked_element if not just added */ if ((INTERACTIVE_EVENT_BUTTON_RELEASE==event_type)&& shift_pressed&&(!(element_tool->picked_element_was_unselected))) { struct LIST(FE_element) *temp_element_list = CREATE(LIST(FE_element))(); ADD_OBJECT_TO_LIST(FE_element)(element_tool->last_picked_element, temp_element_list); Cmiss_rendition_remove_selection_from_element_list_of_dimension(element_tool->rendition, temp_element_list, Cmiss_element_get_dimension(element_tool->last_picked_element)); DESTROY(LIST(FE_element))(&temp_element_list); } } else if (element_tool->motion_detected) { /* rubber band select */ temp_interaction_volume= create_Interaction_volume_bounding_box( element_tool->last_interaction_volume,interaction_volume); if (temp_interaction_volume != 0) { if (INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) { if (!element_tool->rubber_band) { /* create rubber_band object and put in scene */ element_tool->rubber_band=CREATE(GT_object)( "element_tool_rubber_band",g_POLYLINE, element_tool->rubber_band_material); ACCESS(GT_object)(element_tool->rubber_band); } Interaction_volume_make_polyline_extents( temp_interaction_volume,element_tool->rubber_band); } else { #if defined (USE_SCENE_OBJECT) Scene_remove_graphics_object(scene,element_tool->rubber_band); #endif DEACCESS(GT_object)(&(element_tool->rubber_band)); } if (INTERACTIVE_EVENT_BUTTON_RELEASE==event_type) { scene_picked_object_list= Scene_pick_objects(scene,temp_interaction_volume, graphics_buffer); if (scene_picked_object_list != 0) { Region_element_map *element_map = (Region_element_map *)Scene_picked_object_list_get_picked_region_sorted_elements( scene_picked_object_list, element_tool->select_elements_enabled, element_tool->select_faces_enabled, element_tool->select_lines_enabled); if (element_map) { Cmiss_region *sub_region = NULL; Cmiss_field_group_id sub_group = NULL; Cmiss_rendition *region_rendition = NULL; Cmiss_mesh_group_id mesh_group[MAXIMUM_ELEMENT_XI_DIMENSIONS]; int iter = 0; for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { mesh_group[iter] = 0; } Region_element_map::iterator pos; for (pos = element_map->begin(); pos != element_map->end(); ++pos) { if (pos->first != sub_region) { if (sub_group) { Cmiss_field_group_destroy(&sub_group); } for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { if (mesh_group[iter]) { Cmiss_mesh_group_destroy(&(mesh_group[iter])); } } if (region_rendition) { Cmiss_rendition_destroy(®ion_rendition); } sub_region = pos->first; if (sub_region) { region_rendition= Cmiss_region_get_rendition_internal(sub_region); sub_group = Cmiss_rendition_get_or_create_selection_group(region_rendition); } } if (sub_region && sub_group) { Cmiss_field_module_id field_module = Cmiss_region_get_field_module(sub_region); int dimension = Cmiss_element_get_dimension(pos->second); if (dimension <= MAXIMUM_ELEMENT_XI_DIMENSIONS) { if (!mesh_group[dimension - 1]) { Cmiss_mesh_id temp_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(sub_group, temp_mesh); if (!element_group) { element_group = Cmiss_field_group_create_element_group(sub_group, temp_mesh); } mesh_group[dimension - 1] = Cmiss_field_element_group_get_mesh(element_group); Cmiss_field_element_group_destroy(&element_group); Cmiss_mesh_destroy(&temp_mesh); } Cmiss_mesh_group_add_element(mesh_group[dimension - 1], pos->second); } Cmiss_field_module_destroy(&field_module); } } if (sub_group) { Cmiss_field_group_destroy(&sub_group); } for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { if (mesh_group[iter]) { Cmiss_mesh_group_destroy(&(mesh_group[iter])); } } if (region_rendition) { Cmiss_rendition_destroy(®ion_rendition); } delete element_map; } DESTROY(LIST(Scene_picked_object))( &(scene_picked_object_list)); } } DESTROY(Interaction_volume)(&temp_interaction_volume); } } if (INTERACTIVE_EVENT_BUTTON_RELEASE==event_type) { Element_tool_reset((void *)element_tool); } } } break; default: { display_message(ERROR_MESSAGE, "Element_tool_interactive_event_handler. Unknown event type"); } break; }