Drawings SDK Developer Guide > Working with .dwg Files > Working with Entities > Working with Specific Entitites > Working with Polygon Meshes > Specific Properties of Polygon Meshes
Specific Properties of Polygon Meshes

A polygon mesh can be open or closed in both directions (M-direction and N-direction); it has a number of columns and rows, a plane, and if it has a surface fitting entity, it also has a density value for both directions. The OdDbPolygonMesh class has methods for getting and setting these properties. In the following examples, the pPolyMesh variable stores a pointer to the polygon mesh object.

Closed status

The OdDbPolygonMesh entity has the following properties that determine whether the polygon mesh is open or closed:

  • MClosed property — When set to "true", the polygon mesh is closed by drawing quadrangular figures in a row between the last and first rows. When set to "false" and NClosed is set to "false", the polygon mesh is open.
  • NClosed property — When set to "true", the polygon mesh is closed by drawing quadrangular figures in a column between the last and first columns. When set to "false" and MClosed is set to "false", the polygon mesh is open.

To check the closed status for a polygon mesh, use the isMClosed() and isNClosed() methods which return the status as a boolean value. For example:


// Check closed status in M direction
odPrintConsoleString(L"\nPolygon mesh is %s in M direction", ((pPolyMesh->isMClosed()) ? L"closed" : L"opened"));

// Check closed status in N direction
odPrintConsoleString(L"\nPolygon mesh is %s in N direction", ((pPolyMesh->isNClosed()) ? L"closed" : L"opened"));

To switch the closed status for a polygon mesh, use the makeMClosed(), makeNClosed(), makeMOpen, and makeNOpen() methods which do not have arguments. For example:


// Make the closed polygon mesh
pPolyMesh->makeMClosed();
pPolyMesh->makeNClosed();

// Make the opened polygon mesh
pPolyMesh->makeMOpen();
pPolyMesh->makeNOpen();

Plane

The polygon mesh is planar when all vertices lie in the same plane.

To get the plane for a polygon mesh, use the getPlane() method which requires a reference to a variable of the OdGePlane type in which the plane instance must be saved as the first argument, a reference to a variable of the OdDb::Planarity type in which the plane type must be saved as the second argument, and returns the plane properties through arguments and the resulting code. To check whether or not a polygon mesh is planar, use the isPlanar() method.

Size of the polygon mesh

A polygon mesh entity stores the number of rows and columns.

To get the number of rows, use the mSize() method, which returns the number of rows as an integer value. To get the number of columns, use the nSize() method, which returns the number of columns as an integer value. For example:


// Get number of rows
OdInt16 sizeM = pPolyMesh->mSize();
odPrintConsoleString(L"\nNumber of rows = %i", sizeM); 

// Get number of columns
OdInt16 sizeN = pPolyMesh->nSize();
odPrintConsoleString(L"\nNumber of columns = %i", sizeN);

To set the number of rows, use the setMSize() method, which requires the number of the rows as an integer value. To set the number of columns, use the setNSize() method, which requires the number of columns as an integer value. For example:


// Set number of rows
OdInt16 sizeM = 10
pPolyMesh->setMSize(sizeM);

// Set number of columns
OdInt16 sizeN = 10;
pPolyMesh->setNSize(sizeN);

Density

The OdDbPolygonMesh entity has MDensity and NDensity properties that determine the density of Quadratic, Cubic, and Bezier polygon meshes. These properties specify or return the vertex count used to determine the density of the rows (MDensity) and columns (NDensity) of a polygon mesh.

To get the density of the rows and columns, use the mSurfaceDensity() and nSurfaceDensity() methods which return MDensity and NDensity properties as an integer value. For example:


// Get density of rows
OdInt16 denM = pPolyMesh->mSurfaceDensity();
odPrintConsoleString(L"\nDensity of rows = %i", denM); 

// Get density of columns
OdInt16 denN = pPolyMesh->nSurfaceDensity();
odPrintConsoleString(L"\nDensity of columns = %i", denN);

To set the density of rows, use the setMSurfaceDensity() method, which requires density of the rows as an integer value. To set the density of columns, use the setNSurfaceDensity() method, which requires the density of the columns as an integer value.

See Also

Working with Polygon Meshes

Overview of Polygon Meshes

Types of Polygon Meshes and Vertices

Working with Vertices of Polygon Meshes

Example of Working with Polygon Meshes

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.