就是下面这一段(tkuse中sections那一张的例子)我才可能是需要一个“显性类型转换”?恳请大家指点。
ProError ProDemoSectCreate(
double width, /* (In) The rectangle width */
double height, /* (In) The rectangle height */
double bite_radius, /* (In) The radius of the bite */
double bite_height, /* (In) The height of the bite */
  roUtilCname name, /* (In) The sketch name */
  roBoolean alloc, /* (In) mem Alloc specifier */
  roSection *p_section) /* (In/Out) The section handle for the sketch */
{
  roError status, solve_status;
  roSection section;
ProName wname;
Pro2dArcdef arc;
Pro2dLinedef line;
int bottom_id, right_id, top_id,
left_top_id,left_bottom_id, arc_id;
int width_dim, height_dim, bite_height_dim,
bite_radius_dim;
ProSectionPointType pnt_types[2];
Pro2dPnt point;
int n_errors, e;
ProWSecerror errors;
ProMsg wmsg;
char msg[PRO_PATH_SIZE];
int dims[2];
/*-----------------------------------------------------------*\
Check that the dimensions are possible.
\*-----------------------------------------------------------*/
if (width < EPSM6 || height < EPSM6)
return (-1);
if (bite_height <= bite_radius)
return (-1);
if (bite_height + bite_radius > height)
return (-1);
if (bite_radius >= width)
return (-1);
/*-----------------------------------------------------------*\
Allocate the handle for the 2-D section.
\*-----------------------------------------------------------*/
if (alloc == PRO_B_TRUE)
{
status = ProSection2DAlloc ([$section)]
}
else
section = *p_section;
/*-----------------------------------------------------------*\
Set the name of the section.
\*-----------------------------------------------------------*/
ProStringToWstring (wname, name);
status = ProSectionNameSet (section, wname);
/*-----------------------------------------------------------*\
Set the ?epsilon value.设定截面的最小值
\*-----------------------------------------------------------*/
status = ProSectionEpsilonSet (section, 0.5);
/*-----------------------------------------------------------*\
Add a straight-line entity for the bottom of the rectangle.
\*-----------------------------------------------------------*/
line.type = PRO_2D_LINE;
line.end1[0] = 0.0;
line.end1[1] = 0.0;
line.end2[0] = width + 0.1;
line.end2[1] = 0.0;
status = ProSectionEntityAdd (section, (Pro2dEntdef*)[$line, &bottom_id)]
/*-----------------------------------------------------------*\
...right
\*-----------------------------------------------------------*/
line.type = PRO_2D_LINE;
line.end1[0] = width + 0.1;
line.end1[1] = 0.0;
line.end2[0] = width;
line.end2[1] = height;
status = ProSectionEntityAdd (section,
(Pro2dEntdef*)[$line, &right_id)]
/*-----------------------------------------------------------*\
...top
\*-----------------------------------------------------------*/
line.type = PRO_2D_LINE;
line.end1[0] = width;
line.end1[1] = height;
line.end2[0] = 0.0;
line.end2[1] = height;
status = ProSectionEntityAdd (section, (Pro2dEntdef*)&line,
[$top_id)]
/*-----------------------------------------------------------*\
...left above the bite
\*-----------------------------------------------------------*/
line.type = PRO_2D_LINE;
line.end1[0] = 0.0;
line.end1[1] = bite_height - bite_radius;
line.end2[0] = 0.0;
line.end2[1] = 0.0;
status = ProSectionEntityAdd (section, (Pro2dEntdef*)&line,
[$left_top_id)]
/*-----------------------------------------------------------*\
...left below the bite
\*-----------------------------------------------------------*/
line.type = PRO_2D_LINE;
line.end1[0] = 0.0;
line.end1[1] = height;
line.end2[0] = 0.0;
line.end2[1] = bite_height + bite_radius;
status = ProSectionEntityAdd (section, (Pro2dEntdef*)&line,
[$left_bottom_id)]
/*-----------------------------------------------------------*\
Add an arc entity for the bite itself.
\*-----------------------------------------------------------*/
arc.type = PRO_2D_ARC;
arc.center[0] = 0.0;
arc.center[1] = bite_height;
arc.start_angle = PI * 1.5; /* 270 degrees counterclockwise
from the X axis */
arc.end_angle = PI / 2.0; /* 90 degrees counterclockwise
from the X axis */
arc.radius = bite_radius;
status = ProSectionEntityAdd (section, (Pro2dEntdef*)&arc,
[$arc_id)]
/*-----------------------------------------------------------*\
Add a dimension for the width (the length of the top
entity).
\*-----------------------------------------------------------*/
point[0] = width/2.0;
point[1] = height + 10.0;
pnt_types[0] = PRO_ENT_WHOLE;
status = ProSecdimCreate (section, &top_id, pnt_types, 1,
PRO_TK_DIM_LINE, point, [$width_dim)]
/*-----------------------------------------------------------*\
Add a dimension for the height (the length of the
right entity).
\*-----------------------------------------------------------*/
point[0] = width + 1.0;
point[1] = height/2.0;
pnt_types[0] = PRO_ENT_WHOLE;
status = ProSecdimCreate (section, &right_id, pnt_types, 1,
PRO_TK_DIM_LINE, point, [$height_dim)]
/*-----------------------------------------------------------*\
Add a dimension for the height of the bite.
\*-----------------------------------------------------------*/
point[0] = -1.0;
point[1] = bite_height/2.0;
dims[0] = bottom_id;
dims[1] = arc_id;
pnt_types[0] = PRO_ENT_WHOLE;
pnt_types[1] = PRO_ENT_CENTER;
status = ProSecdimCreate (section, dims, pnt_types, 2,
PRO_TK_DIM_LINE_POINT, point, [$bite_height_dim)]
/*-----------------------------------------------------------*\
Add a dimension for the radius of the bite.
\*-----------------------------------------------------------*/
point[0] = bite_radius + 1.0;
point[1] = bite_height;
pnt_types[0] = PRO_ENT_WHOLE;
status = ProSecdimCreate (section, &arc_id, pnt_types, 1,
PRO_TK_DIM_RAD, point, [$bite_radius_dim)]
/*-----------------------------------------------------------*\
Claim memory for the error structure.
\*-----------------------------------------------------------*/
status = ProSecerrorAlloc ([$errors)]
/*-----------------------------------------------------------*\
Solve the section.
\*-----------------------------------------------------------*/
solve_status = ProSectionSolve (section, [$errors)]
/*-----------------------------------------------------------*\
If the solve failed, report error messages and exit.
\*-----------------------------------------------------------*/
if (solve_status != PRO_TK_NO_ERROR)
{
status = ProSecerrorCount ([$errors, &n_errors)]
for (e = 0; e < n_errors; e++)
{
status = ProSecerrorMsgGet (errors, e, wmsg);
ProWstringToString (msg, wmsg);
printf ("Error %d message : %s\n",e, msg);
}
return (-1);
}
status = ProSecerrorFree ([$errors)]
/*-----------------------------------------------------------*\
Save the section.
\*-----------------------------------------------------------*/
status = ProMdlSave (section);
/*-----------------------------------------------------------*\
Return the section handle
\*-----------------------------------------------------------*/
*p_section = section;
return (0);
} |