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

A polygon mesh object can have the following types:

  • Simple polygon mesh — Defines a simple polygon mesh without any surface fitting or smoothing.
  • Surface-fit — Defines a polygon mesh using an approximation method to create an object that is more smooth.

The polygon mesh object determines the object shape using the type property. The simple and surface-fit polygon mesh require a different number of vertices and use different determining geometry. To switch between types, the polygon mesh object adds or removes the vertices and recalculates parameters of the object. Users can change the polygon mesh type manually (using the setPolyMeshType() method), but this method does not add the fit vertices, so users must add them manually. Or users can use special methods to change the polyline type and recalculate properties of each vertex (using the straighten() and splineFit() methods) or transform a polyline into another type (using the convertToPolyMeshType() method).

Structurally, a polygon mesh is a container that stores its own vertices as individual entities and provides access to them using an iterator or ID. Each vertex entity stores the position and its type, which determines whether this vertex is used for storing and specifying the polygon mesh in a plane or used for surface fitting of the polygon mesh.

In the following examples, the pPolyMesh variable stores a pointer to the polygon mesh object.

Polygon mesh type

Polygon mesh type determines the form of polygon mesh and which types of vertices should be used.

The OdDb::PolyMeshType enumeration declares the following types for polygon meshes:


enum PolyMeshType {
  kSimpleMesh = 0, // default
  kQuadSurfaceMesh = 5,
  kCubicSurfaceMesh = 6,
  kBezierSurfaceMesh = 8
};
  • kSimpleMesh — Simple polygon mesh without any fitting; consists only of simple vertices.
  • kQuadSurfaceMesh — Polygon mesh that has quadric B-spline surface fitting. Simple vertices are used as control points to create surface-fit vertices, which are needed to form new surfaces.
  • kCubicSurfaceMesh — Polygon mesh that has cubic B-spline surface fitting. Simple vertices are used as control points to create surface-fit vertices, which are needed to form new surfaces.
  • kBezierSurfaceMesh — Polygon mesh that has Bezier surface fitting. Simple vertices are used as control points to create surface-fit vertices, which are needed to form new surfaces.

To get the polygon mesh type, use the polyMeshType() method which returns the type as a value of the OdDb::PolyMeshType enumeration.

To set the polygon mesh type, use the setPolyMeshType() method which requires the type value of the PolyMeshType enumeration as an argument.

For example:


// Set the simple polygon mesh type
pPolyMesh->setPolyMeshType(OdDb::kSimpleMesh);

// Set the quadratic B-spline type
pPolyMesh->setPolyMeshType(OdDb::kQuadSurfaceMesh);

// Set the cubic B-spline type
pPolyMesh->setPolyMeshType(OdDb::kCubicSurfaceMesh);

// Set the Bezier spline type
pPolyMesh->setPolyMeshType(OdDb::kBezierSurfaceMesh);

Note: The setPolyMeshType() method changes only the type value; it does not recalculate the entity shape and does not provide fitting of surfaces.

Vertex type

Each three-dimensional vertex object in a polygon mesh stores the type that determines its role in drawing the polygon mesh. Depending on its type, each vertex can be used as a simple vertex for a simple polygon mesh, or as a control vertex or calculated spline vertex in surface fitting.

The OdDb::Vertex3dType enumeration declares the following types for three-dimensional vertices:


enum Vertex3dType {
  k3dSimpleVertex = 0,  // default, simple non-fit vertex for simple polygon meshes
  k3dControlVertex = 1, // control vertex for surface-fit polygon meshes
  k3dFitVertex = 2      // surface-fit vertex for approximation in surface-fit polygon meshes
};

To get the vertex type, declare an iterator or use its object ID and call the vertexType() method of the obtained vertex which returns the vertex type as one value of the Vertex3dType enumeration.

Converting between mesh types

There are three methods available to transform a polygon mesh object from one type to another. The straighten() method removes all fit vertices and transforms all control vertices to simple vertices. The surfaceFit() method transforms the polygon mesh to the sequence of spline surfaces connected through vertices marked by "Surface-fit" type, changes the number of vertices subject to the approximation algorithm, stores the original coordinates in vertices marked by "Control" type, and creates the spline surfaces. The convertToPolyMeshType() method transforms the polygon mesh to a simple polygon mesh object, cubic B-spline surface, quadratic B-spline surface, or Bezier spline surface using the type value passed as an argument.

To change the polygon mesh type, call the straighten() or surfaceFit() method. For example:


// Change type to the cubic B-spline surface
pPolyMesh->surfaceFit(OdDb::kCubicSurfaceMesh);

// Change type to the quadratic B-spline surface
pPolyMesh->surfaceFit(OdDb::kQuadSurfaceMesh);

// Change type to the Bezier spline surface
pPolyMesh->surfaceFit(OdDb::kBezierSurfaceMesh);

// Change type to the simple polygon mesh
pPolyMesh->straighten();

To transform a polygon mesh to a specified type, use the convertToPolyMeshType() method which requires one value from the PolyMeshType enumeration as an argument. For example:


// Transform to the cubic B-spline surface
pPolyMesh->convertToPolyMeshType(OdDb::kCubicSurfaceMesh);

// Transform to the quadratic B-spline surface
pPolyMesh->convertToPolyMeshType(OdDb::kQuadSurfaceMesh);

// Transform to the Bezier spline surface
pPolyMesh->convertToPolyMeshType(OdDb::kBezierSurfaceMesh);

// Transform to the simple polygon mesh
pPolyMesh->convertToPolyMeshType(OdDb::kSimpleMesh);

See Also

Working with Polygon Meshes

Overview of Polygon Meshes

Specific Properties of Polygon Meshes

Working with Vertices of Polygon Meshes

Example of Working with Polygon Meshes

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