How to: Extract exterior surface from a tetrahedron shell

Below is sample code on how to extract a tetrahedron shell to show only the exterior surface that have interior vertices vertices and faces.

void CSolidHoopsView::OnExtraSlot5() {
    HC_KEY key;

    // Input
    int pcount0, face_list_length0;
    float const* points0;
    int const* face_list0;

    // Intermediate
    int pcount1, face_list_length1;
    float* points1;
    int* face_list1;

    // Returned
    int* face_list2;
    int pcount2, face_list_length2;
    float* points2;


    HC_KEY shellkey;

    m_pHView->SetViewMode(ViewMode::HViewBack);

    HC_Open_Segment_By_Key(m_pHView->GetModelKey()); {


        HC_Begin_Contents_Search("...", "shells");
        if (!HC_Find_Contents(0, &key)) {
            m_pHView->Update();

        }
        HC_End_Contents_Search();

        HC_Show_Shell_Size(key, &pcount0, &face_list_length0);
        HC_Show_Geometry_Pointer(key, "points", &points0);
        HC_Show_Geometry_Pointer(key, "face list", &face_list0);

        pcount1 = pcount0;
        face_list_length1 = face_list_length0;
        face_list1 = new int[face_list_length1];
        points1 = new float[3 * pcount1];

        /*
            remove redundant points

        */
        HC_Compute_Optimized_Shell(
            pcount0, points0, 0, face_list_length0, face_list0, "", &pcount1, points1, &face_list_length1, face_list1, 0, 0);

        pcount2 = pcount1;
        face_list_length2 = face_list_length1;
        face_list2 = new int[face_list_length2];
        points2 = new float[3 * pcount2];

        /*
            Compute skin on shell

        */
        HC_Compute_Optimized_Shell(pcount1,
            points1,
            0,
            face_list_length1,
            face_list1,
            "skin",
            &pcount2,
            points2,
            &face_list_length2,
            face_list2,
            0,
            0);


        /*
            Insert shell to see result
        */
        HC_Open_Segment("skin_shell"); {

            HC_Set_Color("faces = yellow, edges=black");
            HC_Translate_Object(0, 0, 2);
            HC_Insert_Shell(pcount2, points2, face_list_length2, face_list2);

        }HC_Close_Segment();


        delete[] points1;
        delete[] points2;
        delete[] face_list1;
        delete[] face_list2;



    }HC_Close_Segment();

    HUtilityGeometryCreation::CreateCuttingPlane(m_pHView, "plane3");

    m_pHView->SetGeometryChanged();
    m_pHView->FitWorldExact();
    m_pHView->Update();


    HC_Open_Segment_By_Key(m_pHView->GetWindowspaceKey()); {
        HC_Insert_Text(-0.3f, -0.8f, 0, "Original shell");
        HC_Insert_Text(0.3f, -0.8f, 0, "Optimized shell");
    }HC_Close_Segment();
    m_pHView->Update();
    
}

Result:

1 Like