- 积分
- 1
- 注册时间
- 2004-5-15
- 仿真币
-
- 最后登录
- 1970-1-1
|
//////////////////////////////////////////////////////////////////////////////
//
// mesh_ansys_2d.cpp
//
// Description:
// Contains Unigraphics entry points for the application.
//
//////////////////////////////////////////////////////////////////////////////
// Include files
#include <stdio.h>
#include "stdafx.h"
#include <malloc.h>
//#include <strstream.h>
#include <uf.h>
#include "uf_modl.h"
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_part.h>
#include <uf_sf.h>
#include <uf_object_types.h>
#include <uf_disp.h>
static int init_proc(UF_UI_selection_p_t select,void *user_data);
#include <iostream.h>
//FILE *fpt =fopen("e:\fgl.dat", "a+");
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
if(irc)
{ char message[133];
printf("%s, line %d: %s\n", file, line, call);
(UF_get_fail_message(irc, message)) ?
printf(" returned a %d\n", irc) :
printf(" returned error %d: %s\n", irc, message);
}
return(irc);
}
static void do_ugopen_api(void)
{
FILE *fpt =fopen("e:\\fgl.txt", "a+");
int count=1,ret;
UF_SF_AMM_mesh_parameters_t mesh_params;
char cue[] = "select a face";
char title[] = "reference face selecting";
int response;
char *element_type="Tri3";
tag_t face_id;
tag_t object_id ;
tag_t mesh_tag;
int number_of_nodes;
tag_t object, view;
double cursor[3];
if(!(UF_UI_select_with_single_dialog(cue,title,
UF_UI_SEL_SCOPE_NO_CHANGE, init_proc, NULL,
&response, &object, cursor, &view)))
{
if (response == UF_UI_OBJECT_SELECTED ||
response == UF_UI_OBJECT_SELECTED_BY_NAME)
{
fprintf(fpt,"object tag = %d\n", object);
if (response == UF_UI_OBJECT_SELECTED)
{
fprintf(fpt,"view = %d\n", view);
fprintf(fpt,"cursor position = %f %f %f\n",
cursor[0], cursor[1], cursor[2]);
}
fprintf(fpt,"face_id =%d\n",face_id);
}
UF_DISP_set_highlight(object,1);
}
mesh_params.mesh_dimension=UF_SF_DIMENSION_2D;
mesh_params.midnode_needed=1;
mesh_params.ansys_area_element_shape=4;
mesh_params.overall_elem_size=4;
mesh_params.quad_splitting=1;
mesh_params.element_descritor_tag=UF_SF_TRIA3;
mesh_params.smart_edge_seeding=1;
mesh_params.do_not_format_mesh=1;
mesh_params.split_quad_toggle=0;
mesh_params.midnode_snapping=1;
mesh_params.smart_sizing=0;
mesh_params.quad_splitting=0;
mesh_params.smoothing=1;
mesh_params.cleanup=0;
mesh_params.debugging=1;
mesh_params.journaling=1;
mesh_params.mapped_mesh=1;
mesh_params.area_transition_factor=1;
mesh_params.area_transition_lower_limit=0;
mesh_params.area_transition_upper_limit=0;
mesh_params.area_expansion_factor=0;
mesh_params.area_expansion_lower_limit=0;
mesh_params.area_expansion_upper_limit=0;
mesh_params.volume_expansion_factor=0;
mesh_params.volume_expansion_lower_limit=0;
mesh_params.volume_expansion_upper_limit=0;
mesh_params.edge_matching_tol=0;
mesh_params.jacobian_ratio=0;
ret=UF_SF_create_2d_ansys_mesh(&mesh_params,element_type,count,&object_id,&mesh_tag);
fprintf(fpt,"object_id= %d\n mesh_tag= %d\n ret= %d\n",object_id,mesh_tag,ret);
UF_SF_count_nodes(mesh_tag,&number_of_nodes);
fprintf(fpt,"number of node= %d\n ",number_of_nodes);
fclose(fpt);
}
/*ARGSUSED*/
//void ufsta(char *param, int *retcode, int param_len)
void ufusr(char *param, int *retcode, int param_len)
{
// int error_code;
// if (UF_initialize()==0)
if(!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
static int init_proc(UF_UI_selection_p_t select,void* user_data)
{
int num_triples = 2;
UF_UI_mask_t mask_triples[] = {
UF_face_type, 0, 0,
UF_solid_type, 0, UF_UI_SEL_FEATURE_ANY_EDGE};
/* enable only lines and edges */
if((UF_CALL(UF_UI_set_sel_mask(select,
UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,
num_triples, mask_triples))) == 0)
{
return (UF_UI_SEL_SUCCESS);
}
else
{
return (UF_UI_SEL_FAILURE);
}
} |
|