UG二次开发PK内核获得面积

//梅雷提示!内核获得面积的好处是不用抽取面

BOOL PK_AskFaceAreas(tag_t face_tag, double tol, double &areas)
{//获得面积
	tag_t      ps_tag = NULL_TAG;
	double     amount[3] = { 0.0, 0.0, 0.0 };
	double     mass[3] = { 0.0, 0.0, 0.0 };
	double     c_of_g[3] = { 0.0, 0.0, 0.0 };
	double     m_of_i[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
	double	   periphery[3] = { 0.0, 0.0, 0.0 };
	PK_FACE_t  pkFace = 0;
	PK_TOPOL_eval_mass_props_o_t props_o_t;

	areas = 0.0;
	if (NULL_TAG == face_tag
		|| UF_PS_ask_ps_tag_of_object(face_tag, &ps_tag))
		return FALSE;
	pkFace = ps_tag;
	if (tol < 0.99)
		tol = 0.99;
	if (tol > 1.0)
		tol = 1.0;
	PK_TOPOL_eval_mass_props_o_m(props_o_t);
	props_o_t.mass = PK_mass_c_of_g_c;
	PK_TOPOL_eval_mass_props(1, &pkFace, tol, &props_o_t, amount, mass, c_of_g, m_of_i, periphery);
	areas = amount[0] * 1000.0 * 1000.0;
	return TRUE;
}
BOOL PK_AskFaceAreas(CUIntArray &tFaceTags, double tol, double &areas)
{//获得面积
	int        i = 0;
	tag_t      ps_tag = NULL_TAG;
	double     amount[3] = { 0.0, 0.0, 0.0 };
	double     mass[3] = { 0.0, 0.0, 0.0 };
	double     c_of_g[3] = { 0.0, 0.0, 0.0 };
	double     m_of_i[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
	double	   periphery[3] = { 0.0, 0.0, 0.0 };
	PK_FACE_t  *pkFaces = NULL;
	CUIntArray temps;
	PK_TOPOL_eval_mass_props_o_t props_o_t;

	areas = 0.0;
	if (0 == tFaceTags.GetSize())
		return FALSE;
	for (i = 0; i < tFaceTags.GetSize(); i++)
	{
		if (!UF_PS_ask_ps_tag_of_object(tFaceTags[i], &ps_tag))
		{
			temps.Add(ps_tag);
		}
	}
	if (0 == temps.GetSize())
		return FALSE;
	pkFaces = new PK_FACE_t[temps.GetSize()];
	for (i = 0; i < temps.GetSize(); i++)
	{
		pkFaces[i] = temps[i];
	}
	if (tol < 0.99)
		tol = 0.99;
	if (tol > 1.0)
		tol = 1.0;
	PK_TOPOL_eval_mass_props_o_m(props_o_t);
	props_o_t.mass = PK_mass_c_of_g_c;
	PK_TOPOL_eval_mass_props(temps.GetSize(), pkFaces, tol, &props_o_t, amount, mass, c_of_g, m_of_i, periphery);
	areas = amount[0] * 1000.0 * 1000.0;
	delete pkFaces;
	pkFaces = NULL;
	return TRUE;
}

你可能感兴趣的:(UG二次开发,UG二次开发内核获得面积)