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;
}


————————————————
版权声明:本文为CSDN博主「梅雷」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/raley66/article/details/100764229

posted @ 2022-01-24 20:32  老婆饼里有老婆  阅读(130)  评论(0编辑  收藏  举报