Sample Mesh API Operations

Introduction

This example describes the different mesh functionalities as follows:

  • Create mesh with unindexed points
  • Create mesh elements with variable length faces
  • Mesh Boolean operations (union, intersection, difference)

How to

  • Create a mesh element with 4 unindexed points

EditElementHandle       eeh;
PolyfaceHeaderPtr dgnPolyface = PolyfaceHeader::CreateFixedBlockCoordinates (4);

dgnPolyface->Point ().CopyVectorFrom (m_Points);
if (SUCCESS != MeshHeaderHandler::CreateMeshElement(eeh, NULL, *dgnPolyface, true, *ACTIVEMODEL))
    return false;

  • Create a mesh element with variable length faces

EditElementHandle       eeh;
PolyfaceHeaderPtr dgnPolyface = PolyfaceHeader::CreateVariableSizeIndexed ();
dgnPolyface->AddPolygon(m_Points);

// Create Element
if (SUCCESS != MeshHeaderHandler::CreateMeshElement(eeh, NULL, *dgnPolyface, true, *ACTIVEMODEL))
    return false;

  • Create a mesh element from Boolean operations using two input breps and mdlPop_polyBrepFromPolyBrepBoolOp

//Compute a boolean operation on two breps
if (mdlPop_polyBrepFromPolyBrepBoolOp(pContext, pBrep0, pBrep1, m_boolMode, false, false, false, false))
    {
    if (GetKeepOriginals() == MESH_BOOLEANMODE_KeepNone || false)
        mdlPop_elementDescrFromPolyBrep(outEdPP, &inEdP1->el, pBrep0, false, false);
    else
        mdlPop_elementDescrFromPolyBrep(outEdPP, NULL, pBrep0, false, false);

        pBrep1 = NULL;          // brep1 is consumed#ifdef TIME_RECORD
    }
else
    {
    pBrep0 = pBrep1 = NULL; // both breps are consumed
    }

To run the Example

Load the example mdl application using one of the following methods:

  1. Key-in: mdl load meshtools
  2. OR, Utilities > MDL Applications > Browse…, Select: meshtools.ma
  • To create a mesh element using different methods from existing sample shapes, open the MeshExample.dgn sample file and select a shape before running tool

Prerequisite to create a mesh using Boolean operations:

  • Create two mesh elements, see sample file: MeshBooleanExample.dgn
  • Select mesh elements, before selecting a tool

Mesh Unite Operation:

Mesh Subtract Operation:

Mesh Intersect Operation: