Creating Face Group

function CreateFaceGroup(mesh, group_name, facet_array)
{
    mesh.beginEdit();
    if (!mesh.createFaceGroup(group_name)) 
    {
        print("Failed to create face group: " + group_name);
        return;
    }
    var face_group = mesh.getFaceGroup(mesh.getNumFaceGroups() - 1);
    for (var i = 0; i < facet_array.length; i++)
    {
        face_group.addIndex(facet_array[i]);
    }
    mesh.activateFaceGroup(mesh.getNumFaceGroups() - 1);
    mesh.finishEdit();
}

Face groups created, but vertex/face counts are zero

Comments

  • it seems there is no way to add facet to facegroup:


    Scene.clear();

    function create_cylinder()
    {
        var settings = new DzSettings();
        Geometry.getDefaultPrimitiveOptions(5, settings);
        
        settings.setFloatValue("Height", 2);
        settings.setStringValue("HeightUnits", "m");
        settings.setIntValue("Segments", 5);
        settings.setIntValue("Sides", 16);
        settings.setBoolValue("CapMin", true);
        settings.setBoolValue("CapMax", true);

        var cylinder_node = Geometry.createPrimitive(settings);
        Scene.addNode(cylinder_node);
        
        return cylinder_node;
    }

    var node = create_cylinder();
    var obj = node.getObject();
    var shape = obj.getCurrentShape();
    var mesh = shape.getGeometry();

    mesh.createFaceGroup("Default");
    var default_group = mesh.findFaceGroup("Default");

    mesh.createFaceGroup("Top");
    var top_group = mesh.findFaceGroup("Top");

    mesh.createFaceGroup("Bottom");
    var bottom_group = mesh.findFaceGroup("Bottom");

    mesh.beginEdit();
    var facet = mesh.getFacet(0);
    facet.faceGroupIndex = mesh.activateFaceGroup("Bottom");
    bottom_group.addIndex(0);
    mesh.finishEdit()

Sign In or Register to comment.