static void Element_point_tool_reset(void *element_point_tool_void) /******************************************************************************* LAST MODIFIED : 25 February 2008 DESCRIPTION : Resets current edit. Called on button release or when tool deactivated. ==============================================================================*/ { struct Element_point_tool *element_point_tool; ENTER(Element_point_tool_reset); element_point_tool = (struct Element_point_tool *)element_point_tool_void; if (element_point_tool != 0) { REACCESS(Element_point_ranges)( &(element_point_tool->last_picked_element_point), (struct Element_point_ranges *)NULL); REACCESS(Interaction_volume)( &(element_point_tool->last_interaction_volume), (struct Interaction_volume *)NULL); } else { display_message(ERROR_MESSAGE,"Node_tool_reset. Invalid argument(s)"); } LEAVE; } /* Element_point_tool_reset */
void setMeshLocation(Cmiss_element_id element_in, const FE_value *xi_in) { REACCESS(FE_element)(&element, element_in); int dimension = Cmiss_element_get_dimension(element_in); for (int i = 0; i < dimension; ++i) { xi[i] = xi_in[i]; } }
int set_Cmiss_region_or_group(struct Parse_state *state, void *region_address_void, void *group_address_void) { Cmiss_region_id *region_address = reinterpret_cast<Cmiss_region_id*>(region_address_void); Cmiss_field_group_id *group_address = reinterpret_cast<Cmiss_field_group_id*>(group_address_void); if (!(state && region_address && *region_address && group_address && !*group_address)) return 0; const char *current_token = state->current_token; int return_code = 1; if (!current_token) { display_message(WARNING_MESSAGE, "Missing region/group path"); display_parse_state_location(state); return_code = 0; } else if (Parse_state_help_mode(state)) { display_message(INFORMATION_MESSAGE, " REGION_PATH/GROUP"); } else { char *region_path = 0; char *field_name = 0; Cmiss_region_id output_region = 0; if (Cmiss_region_get_partial_region_path(*region_address, current_token, &output_region, ®ion_path, &field_name) && output_region) { REACCESS(Cmiss_region)(region_address, output_region); if (field_name) { Cmiss_field *field = FIND_BY_IDENTIFIER_IN_MANAGER(Computed_field,name)( field_name, Cmiss_region_get_Computed_field_manager(output_region)); *group_address = Cmiss_field_cast_group(field); if (0 == *group_address) { return_code = 0; } } if (return_code) { shift_Parse_state(state, 1); } } else { return_code = 0; } if (!return_code) { display_message(ERROR_MESSAGE, "Invalid region or group path: %s", current_token); display_parse_state_location(state); } DEALLOCATE(region_path); DEALLOCATE(field_name); } return return_code; }
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; }
int gfx_modify_spectrum_settings_field(struct Parse_state *state, void *modify_spectrum_data_void,void *spectrum_command_data_void) /******************************************************************************* LAST MODIFIED : 11 April 2007 DESCRIPTION : Executes a GFX MODIFY SPECTRUM FIELD command. If return_code is 1, returns the completed Modify_spectrum_data with the parsed settings. Note that the settings are ACCESSed once on valid return. ==============================================================================*/ { enum Spectrum_settings_colour_mapping colour_mapping; int component, return_code; struct Computed_field *input_field, *output_field; struct Modify_spectrum_data *modify_spectrum_data; struct Option_table *option_table; struct Set_Computed_field_conditional_data set_input_field_data, set_output_field_data; struct Spectrum_settings *settings; ENTER(gfx_modify_spectrum_settings_field); USE_PARAMETER(spectrum_command_data_void); if (state) { modify_spectrum_data=(struct Modify_spectrum_data *)modify_spectrum_data_void; if (modify_spectrum_data) { /* create the spectrum_settings: */ settings=modify_spectrum_data->settings=CREATE(Spectrum_settings)(); if (settings) { /* access since deaccessed in gfx_modify_spectrum */ ACCESS(Spectrum_settings)(modify_spectrum_data->settings); Spectrum_settings_set_type(settings,SPECTRUM_FIELD); colour_mapping = Spectrum_settings_get_colour_mapping(settings); component = Spectrum_settings_get_component_number(settings); input_field = (struct Computed_field *)NULL; output_field = (struct Computed_field *)NULL; if (settings->input_field) { input_field = ACCESS(Computed_field)(settings->input_field); } if (settings->output_field) { output_field = ACCESS(Computed_field)(settings->output_field); } option_table = CREATE(Option_table)(); /* component */ Option_table_add_int_positive_entry(option_table, "component", &component); /* input_field */ set_input_field_data.computed_field_manager= modify_spectrum_data->computed_field_manager; set_input_field_data.conditional_function= Computed_field_has_numerical_components; set_input_field_data.conditional_function_user_data=(void *)NULL; Option_table_add_entry(option_table,"input", &input_field ,&set_input_field_data, set_Computed_field_conditional); /* output_field */ set_output_field_data.computed_field_manager= modify_spectrum_data->computed_field_manager; set_output_field_data.conditional_function= Computed_field_has_numerical_components; set_output_field_data.conditional_function_user_data=(void *)NULL; Option_table_add_entry(option_table,"output", &output_field, &set_output_field_data, set_Computed_field_conditional); /* conversion_mode */ Option_table_add_enumerator_Spectrum_settings_colour_mapping( option_table, &colour_mapping); if (!(return_code=Option_table_multi_parse(option_table,state))) { DEACCESS(Spectrum_settings)(&(modify_spectrum_data->settings)); } DESTROY(Option_table)(&option_table); if (return_code) { if (!input_field) { display_message(ERROR_MESSAGE,"gfx_modify_spectrum_settings_field. " "You must specify a numerical input field."); return_code=0; } if (!output_field) { display_message(ERROR_MESSAGE,"gfx_modify_spectrum_settings_field. " "You must specify a numerical input field."); return_code=0; } } if (return_code) { if (input_field != settings->input_field) { REACCESS(Computed_field)(&settings->input_field, input_field); settings->settings_changed = 1; } if (output_field != settings->output_field) { REACCESS(Computed_field)(&settings->output_field, output_field); settings->settings_changed = 1; } Spectrum_settings_set_component_number(settings, component); Spectrum_settings_set_colour_mapping(settings, colour_mapping); } DEACCESS(Computed_field)(&input_field); DEACCESS(Computed_field)(&output_field); } else { display_message(ERROR_MESSAGE,"gfx_modify_spectrum_settings_field. " "Could not create settings"); return_code=0; } } else { display_message(ERROR_MESSAGE,"gfx_modify_spectrum_settings_field. " "No modify data"); return_code=0; } } else { display_message(ERROR_MESSAGE,"gfx_modify_spectrum_settings_field. Missing state"); return_code=0; } LEAVE; return (return_code); } /* gfx_modify_spectrum_field */
int define_Computed_field_type_nodal_lookup(struct Parse_state *state, void *field_modify_void, void *computed_field_lookup_package_void) /******************************************************************************* LAST MODIFIED : 25 August 2006 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_NODAL_LOOKUP (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; Computed_field_lookup_package *computed_field_lookup_package; Computed_field_modify_data *field_modify; if (state&&(field_modify=(Computed_field_modify_data *)field_modify_void) && (computed_field_lookup_package= (Computed_field_lookup_package *) computed_field_lookup_package_void)) { return_code = 1; Cmiss_field_id source_field = 0; char *nodeset_name = duplicate_string("cmiss_nodes"); char node_flag = 0; int node_identifier = 0; if ((NULL != field_modify->get_field()) && (computed_field_nodal_lookup_type_string == Computed_field_get_type_string(field_modify->get_field()))) { Cmiss_node_id lookup_node = 0; return_code = Computed_field_get_type_nodal_lookup(field_modify->get_field(), &source_field, &lookup_node); if (source_field) { ACCESS(Computed_field)(source_field); } if (lookup_node) { node_identifier = get_FE_node_identifier(lookup_node); FE_region *fe_region = FE_node_get_FE_region(lookup_node); if (!FE_region_contains_FE_node(fe_region, lookup_node)) { DEALLOCATE(nodeset_name); nodeset_name = duplicate_string("cmiss_data"); } node_flag = 1; } } Option_table *option_table = CREATE(Option_table)(); /* source field */ Set_Computed_field_conditional_data set_source_field_data; set_source_field_data.computed_field_manager = field_modify->get_field_manager(); set_source_field_data.conditional_function = Computed_field_has_numerical_components; set_source_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table,"field", &source_field, &set_source_field_data,set_Computed_field_conditional); /* the node to nodal_lookup */ Option_table_add_entry(option_table, "node", &node_identifier, &node_flag, set_int_and_char_flag); /* the nodeset the node is from */ Option_table_add_string_entry(option_table, "nodeset", &nodeset_name, " NODE_GROUP_FIELD_NAME|[GROUP_NAME.]cmiss_nodes|cmiss_data[cmiss_nodes]"); return_code = Option_table_multi_parse(option_table,state); DESTROY(Option_table)(&option_table); if (return_code && node_flag) { Cmiss_nodeset_id nodeset = Cmiss_field_module_find_nodeset_by_name(field_modify->get_field_module(), nodeset_name); Cmiss_node_id node = Cmiss_nodeset_find_node_by_identifier(nodeset, node_identifier); if (node) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_nodal_lookup(field_modify->get_field_module(), source_field, node)); } else { display_message(ERROR_MESSAGE, "define field nodal lookup. Invalid node %d", node_identifier); return_code = 0; } Cmiss_node_destroy(&node); Cmiss_nodeset_destroy(&nodeset); } else { if ((!state->current_token)|| (strcmp(PARSER_HELP_STRING,state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING,state->current_token))) { display_message(ERROR_MESSAGE, "define_Computed_field_type_time_nodal_lookup. Failed"); } } DEALLOCATE(nodeset_name); REACCESS(Computed_field)(&source_field, NULL); } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_nodal_lookup. Invalid argument(s)"); return_code = 0; } return (return_code); }
int define_Computed_field_type_quaternion_SLERP(struct Parse_state *state, void *field_modify_void, void *computed_field_lookup_package_void) /******************************************************************************* LAST MODIFIED : 25 August 2006 DESCRIPTION : Converts <field> into type 'quaterions' (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; Computed_field_lookup_package *computed_field_lookup_package; Computed_field_modify_data *field_modify; ENTER(define_Computed_field_type_quaternion_SLERP); if (state&&(field_modify=(Computed_field_modify_data *)field_modify_void) && (computed_field_lookup_package= (Computed_field_lookup_package *) computed_field_lookup_package_void)) { return_code = 1; Cmiss_field_id source_field = 0; char *nodeset_name = duplicate_string("cmiss_nodes"); char node_flag = 0; int node_identifier = 0; if ((NULL != field_modify->get_field()) && (computed_field_quaternion_SLERP_type_string == Computed_field_get_type_string(field_modify->get_field()))) { Cmiss_node_id lookup_node = 0; return_code = Computed_field_get_type_quaternion_SLERP(field_modify->get_field(), &source_field, &lookup_node); if (source_field) { ACCESS(Computed_field)(source_field); } if (lookup_node) { node_identifier = get_FE_node_identifier(lookup_node); FE_region *fe_region = FE_node_get_FE_region(lookup_node); if (!FE_region_contains_FE_node(fe_region, lookup_node)) { DEALLOCATE(nodeset_name); nodeset_name = duplicate_string("cmiss_data"); } node_flag = 1; } } Option_table *option_table = CREATE(Option_table)(); Option_table_add_help(option_table, "A 4 components quaternion field. The components of " "the quaternion field are expected to be the w, x, y, z components" "of a quaternion (4 components in total). The quaternion field is" "evaluated and interpolated using SLERP at a normalised time between two" "quaternions (read in from the exnode generally). This quaternion field" "can be convert to a matrix with quaternion_to_matrix field, the resulting" "matrix can be used to create a smooth time dependent rotation for an object" "using the quaternion_to_matrix field. This field must be define directly from" "exnode file or from a matrix_to_quaternion field"); Set_Computed_field_conditional_data set_source_field_data; set_source_field_data.computed_field_manager = field_modify->get_field_manager(); set_source_field_data.conditional_function = Computed_field_has_4_components; set_source_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "field", &source_field, &set_source_field_data, set_Computed_field_conditional); /* identifier of the node to lookup */ Option_table_add_entry(option_table, "node", &node_identifier, &node_flag, set_int_and_char_flag); /* the nodeset the node is from */ Option_table_add_string_entry(option_table, "nodeset", &nodeset_name, " NODE_GROUP_FIELD_NAME|[GROUP_NAME.]cmiss_nodes|cmiss_data[cmiss_nodes]"); return_code = Option_table_multi_parse(option_table, state); DESTROY(Option_table)(&option_table); if (return_code && node_flag) { Cmiss_nodeset_id nodeset = Cmiss_field_module_find_nodeset_by_name(field_modify->get_field_module(), nodeset_name); Cmiss_node_id node = Cmiss_nodeset_find_node_by_identifier(nodeset, node_identifier); if (node) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_quaternion_SLERP(field_modify->get_field_module(), source_field, node)); } else { display_message(ERROR_MESSAGE, "define field quaternion_SLERP. Invalid node %d", node_identifier); return_code = 0; } Cmiss_node_destroy(&node); Cmiss_nodeset_destroy(&nodeset); } else { if ((!state->current_token)|| (strcmp(PARSER_HELP_STRING,state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING,state->current_token))) { display_message(ERROR_MESSAGE, "define_Computed_field_type_quaternion_SLERP. Failed"); } } DEALLOCATE(nodeset_name); REACCESS(Computed_field)(&source_field, NULL); } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_quaternion_SLERP. Invalid argument(s)"); return_code = 0; } LEAVE; return (return_code); } /* define_Computed_field_type_quaternion_SLERP */
int gfx_modify_rendition_graphic(struct Parse_state *state, enum Cmiss_graphic_type graphic_type, const char *help_text, struct Modify_rendition_data *modify_rendition_data, struct Rendition_command_data *rendition_command_data) { if (!(state && rendition_command_data && modify_rendition_data)) { display_message(ERROR_MESSAGE, "gfx_modify_rendition_graphic. Invalid argument(s)"); return 0; } Cmiss_graphic *graphic = 0; if (modify_rendition_data->modify_this_graphic) { graphic = Cmiss_graphic_access(modify_rendition_data->graphic); graphic_type = Cmiss_graphic_get_graphic_type(graphic); } else { graphic = get_graphic_for_gfx_modify(rendition_command_data->rendition, graphic_type, modify_rendition_data->graphic); if (modify_rendition_data->group && (!graphic->subgroup_field)) { graphic->subgroup_field = Cmiss_field_access(Cmiss_field_group_base_cast(modify_rendition_data->group)); } } if (!graphic) { display_message(ERROR_MESSAGE, "gfx_modify_rendition_graphic. Could not create graphic"); return 0; } REACCESS(Cmiss_graphic)(&(modify_rendition_data->graphic), graphic); int return_code = 1; Cmiss_graphics_coordinate_system coordinate_system = Cmiss_graphic_get_coordinate_system(graphic); char *font_name = (char *)NULL; Cmiss_field_id orientation_scale_field = 0; Cmiss_field_id variable_scale_field = 0; Cmiss_field_id xi_point_density_field = 0; GT_object *glyph = 0; Triple glyph_offset, glyph_scale_factors, glyph_size; enum Graphic_glyph_scaling_mode glyph_scaling_mode = GRAPHIC_GLYPH_SCALING_GENERAL; const char *glyph_scaling_mode_string = 0; if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_GLYPH)) { Cmiss_graphic_get_glyph_parameters(graphic, &glyph, &glyph_scaling_mode, glyph_offset, glyph_size, &orientation_scale_field, glyph_scale_factors, &variable_scale_field); if (glyph) ACCESS(GT_object)(glyph); if (orientation_scale_field) { ACCESS(Computed_field)(orientation_scale_field); } if (variable_scale_field) { ACCESS(Computed_field)(variable_scale_field); } glyph_scaling_mode_string = ENUMERATOR_STRING(Graphic_glyph_scaling_mode)(glyph_scaling_mode); } enum Use_element_type use_element_type; const char *use_element_type_string = 0; if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_USE_ELEMENT_TYPE)) { use_element_type = graphic->use_element_type; use_element_type_string = ENUMERATOR_STRING(Use_element_type)(use_element_type); } enum Xi_discretization_mode xi_discretization_mode; const char *xi_discretization_mode_string = 0; if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_XI_DISCRETIZATION_MODE)) { Cmiss_graphic_get_xi_discretization(graphic, &xi_discretization_mode, &xi_point_density_field); if (xi_point_density_field) { ACCESS(Computed_field)(xi_point_density_field); } xi_discretization_mode_string = ENUMERATOR_STRING(Xi_discretization_mode)(xi_discretization_mode); } int number_of_components = 3; int visibility = graphic->visibility_flag; int number_of_valid_strings; const char **valid_strings; enum Cmiss_graphics_render_type render_type = graphic->render_type; const char *render_type_string = ENUMERATOR_STRING(Cmiss_graphics_render_type)(render_type); /* The value stored in the graphic is an integer rather than a char */ char reverse_track = (graphic->reverse_track) ? 1 : 0; char *seed_nodeset_name = 0; if (graphic->seed_nodeset) { seed_nodeset_name = Cmiss_nodeset_get_name(graphic->seed_nodeset); } Option_table *option_table = CREATE(Option_table)(); if (help_text) { Option_table_add_help(option_table, help_text); } /* as */ Option_table_add_entry(option_table,"as",&(graphic->name), (void *)1,set_name); /* cell_centres/cell_corners/cell_density/exact_xi */ if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_XI_DISCRETIZATION_MODE)) { valid_strings = ENUMERATOR_GET_VALID_STRINGS(Xi_discretization_mode)( &number_of_valid_strings, (ENUMERATOR_CONDITIONAL_FUNCTION(Xi_discretization_mode) *)NULL, (void *)NULL); Option_table_add_enumerator(option_table,number_of_valid_strings, valid_strings,&xi_discretization_mode_string); DEALLOCATE(valid_strings); } /* centre */ if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_GLYPH)) { Option_table_add_entry(option_table,"centre",glyph_offset, &(number_of_components),set_reversed_float_vector); } /* circle_discretization */ if (graphic_type == CMISS_GRAPHIC_CYLINDERS) { Option_table_add_entry(option_table, "circle_discretization", (void *)&(graphic->circle_discretization), (void *)NULL, set_Circle_discretization); } /* constant_radius */ if (graphic_type == CMISS_GRAPHIC_CYLINDERS) { Option_table_add_entry(option_table,"constant_radius", &(graphic->constant_radius),NULL,set_float); } /* coordinate */ Set_Computed_field_conditional_data set_coordinate_field_data; set_coordinate_field_data.computed_field_manager = rendition_command_data->computed_field_manager; set_coordinate_field_data.conditional_function = Computed_field_has_up_to_3_numerical_components; set_coordinate_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_Computed_field_conditional_entry(option_table, "coordinate", &(graphic->coordinate_field), &set_coordinate_field_data); /* coordinate system */ const char *coordinate_system_string = ENUMERATOR_STRING(Cmiss_graphics_coordinate_system)(coordinate_system); valid_strings = ENUMERATOR_GET_VALID_STRINGS(Cmiss_graphics_coordinate_system)( &number_of_valid_strings, (ENUMERATOR_CONDITIONAL_FUNCTION(Cmiss_graphics_coordinate_system) *)NULL, (void *)NULL); Option_table_add_enumerator(option_table, number_of_valid_strings, valid_strings, &coordinate_system_string); DEALLOCATE(valid_strings); /* data */ Set_Computed_field_conditional_data set_data_field_data; set_data_field_data.computed_field_manager = rendition_command_data->computed_field_manager; set_data_field_data.conditional_function = Computed_field_has_numerical_components; set_data_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_Computed_field_conditional_entry(option_table, "data", &(graphic->data_field), &set_data_field_data); /* decimation_threshold */ if (graphic_type == CMISS_GRAPHIC_ISO_SURFACES) { Option_table_add_double_entry(option_table, "decimation_threshold", &(graphic->decimation_threshold)); } /* delete */ Option_table_add_entry(option_table,"delete", &(modify_rendition_data->delete_flag),NULL,set_char_flag); /* density */ Set_Computed_field_conditional_data set_xi_point_density_field_data; set_xi_point_density_field_data.computed_field_manager = rendition_command_data->computed_field_manager; set_xi_point_density_field_data.conditional_function = Computed_field_is_scalar; set_xi_point_density_field_data.conditional_function_user_data = (void *)NULL; if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_XI_DISCRETIZATION_MODE)) { Option_table_add_Computed_field_conditional_entry(option_table, "density", &xi_point_density_field, &set_xi_point_density_field_data); } /* discretization */ if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_DISCRETIZATION)) { Option_table_add_entry(option_table,"discretization", &(graphic->discretization),NULL, set_Element_discretization); } /* ellipse/line/rectangle/ribbon */ Streamline_type streamline_type = STREAM_LINE; const char *streamline_type_string = ENUMERATOR_STRING(Streamline_type)(streamline_type); if (graphic_type == CMISS_GRAPHIC_STREAMLINES) { valid_strings = ENUMERATOR_GET_VALID_STRINGS(Streamline_type)( &number_of_valid_strings, (ENUMERATOR_CONDITIONAL_FUNCTION(Streamline_type) *)NULL, (void *)NULL); Option_table_add_enumerator(option_table,number_of_valid_strings, valid_strings,&streamline_type_string); DEALLOCATE(valid_strings); }