GMesh Class

A triangle mesh is a type of polygon mesh in computer graphics. It comprises a set of triangles (typically in three dimensions) that are connected by their common edges or corners.

Depending on the types of vertices and triangles, it can assume different configurations, see table below.

Triangles type / Vertices type Point3D PointRGB
IndexTriangle Plain1MulticolorPlain
SmoothTriangle Smooth1MulticolorSmooth
ColorTriangle ColorPlain
ColorSmoothTriangle ColorSmooth
RichTriangle RichPlain
RichSmoothTriangle RichSmooth

1 Allows transparency to be used

Public Class GMesh 
Inherits GEntity 
Implements IGFace, _ 
IGraphicsReferenceData
This language is not supported or no code example is available.
public class GMesh : GEntity
IGFace
IGraphicsReferenceData
This language is not supported or no code example is available.
Name Description
Protected constructor GMesh(GMesh)
Public constructor GMesh(IList<Point3D>, IList<IndexTriangle>) Vertices and triangles constructor.
Public constructor GMesh(SerializationInfo, StreamingContext)
Public constructor GMesh(int, int, natureType) Vertices and triangles sizes constructor.
Public constructor GMesh(natureType) GMesh nature constructor.
Public constructor GMesh(natureType, edgeStyleType) GMesh nature and edge style constructor.
Top
Name Description
Public property EdgeStyle Gets or sets the edge style. This setting comes into play during GMesh regeneration only.
Public property Edges Direct access to GMesh edges.
Public property EntityData Gets or sets the entity custom data. (inherited from GEntity).
Public property GfxData
Public property IsClosed Tells if a mesh is closed.
Public property LightWeight When true, mesh edges are not computed. To be used with huge meshes.
Public property MeshNature Gets mesh nature.
Public property NormalAveragingMode Gets or sets the normal averaging prevMode.
Public property Normals Gets or sets the mesh normals.
Public property SmoothingAngle Gets or sets the angular value (in radians) used by normal averaging and sharp edges calculation.
Public property TextureCoords Gets or sets mesh texture coordinates.
Public property Triangles Gets or sets the mesh triangles.
Public property Vertices Gets or sets mesh' 3D vertices.
Top
Methods
 
Name Description
Public method ApplyTextureMapping(TextureMappingData) Maps the specified material to this mesh using a custom bounding box. Before using this method you need to define a material and add it to the Design Materials collection.
Public method ApplyTextureMapping(textureMappingType, double, double) Maps the specified material to this mesh. Before using this method you need to define a material and add it to the Design Materials collection.
Public method ApplyTextureMapping(textureMappingType, double, double, Point3D, Point3D) Maps the specified material to this mesh using a custom bounding box. Before using this method you need to define a material and add it to the Design Materials collection.
Public method ApplyTextureMapping(textureMappingType, double, double, Point3D, Point3D, Transformation) Maps the specified material to this mesh using a custom bounding box. Before using this method you need to define a material and add it to the Design Materials collection.
Public method Clone() Creates a deep copy of this mesh entity.
Protected method ComputeApproximatedBoundingBox(out Point3D, out Point3D) Computes the primitive's approximated bounding box.
Public method ComputeEdges() Forces mesh edges computation according to the EdgeStyle settings.
Public method ComputeTessellation(IRegenParams, out TessellationData)
Public method ComputeTessellation(double, out TessellationData)
Public method ConvertToMesh(double, double, natureType, bool)
Public method ConvertToMesh(natureType, int) Converts the mesh with the specified GMesh nature.
Public method ConvertToSolid() Converts this mesh to a GSolid object.
Public method ConvertToSolid<T>() Converts this mesh to a GSolid object.
Public method ConvertToSurrogate() Converts the GEntity to its surrogate, for serialization purpose.
Public method Static CreateArrow(Point3D, Vector3D, double, double, double, double, int, natureType, edgeStyleType) Creates a 3D arrow primitive.
Public method Static CreateArrow(double, double, double, double, int, natureType) Creates a 3D arrow primitive.
Public method Static CreateArrow(double, double, double, double, int, natureType, edgeStyleType) Creates a 3D arrow primitive.
Public method Static CreateArrow<T>(Point3D, Vector3D, double, double, double, double, int, natureType, edgeStyleType) Creates a 3D arrow primitive.
Public method Static CreateArrow<T>(double, double, double, double, int, natureType) Creates a 3D arrow primitive.
Public method Static CreateArrow<T>(double, double, double, double, int, natureType, edgeStyleType) Creates a 3D arrow primitive.
Public method Static CreateBox(double, double, double) Creates a Box primitive.
Public method Static CreateBox(double, double, double, natureType) Creates a Box primitive.
Public method Static CreateBox(double, double, double, natureType, edgeStyleType) Creates a Box primitive.
Public method Static CreateBox<T>(double, double, double) Creates a Box primitive.
Public method Static CreateBox<T>(double, double, double, natureType) Creates a Box primitive.
Public method Static CreateBox<T>(double, double, double, natureType, edgeStyleType) Creates a Box primitive.
Public method Static CreateCone(double, double, Point3D, Point3D, int) Creates a Cone primitive.
Public method Static CreateCone(double, double, Point3D, Point3D, int, natureType) Creates a Cone primitive.
Public method Static CreateCone(double, double, Point3D, Point3D, int, natureType, edgeStyleType) Creates a Cone primitive.
Public method Static CreateCone(double, double, double, int) Creates a Cone primitive.
Public method Static CreateCone(double, double, double, int, natureType) Creates a Cone primitive.
Public method Static CreateCone(double, double, double, int, natureType, edgeStyleType) Creates a Cone primitive.
Public method Static CreateCone<T>(double, double, Point3D, Point3D, int) Creates a Cone primitive.
Public method Static CreateCone<T>(double, double, Point3D, Point3D, int, natureType) Creates a Cone primitive.
Public method Static CreateCone<T>(double, double, Point3D, Point3D, int, natureType, edgeStyleType) Creates a Cone primitive.
Public method Static CreateCone<T>(double, double, double, int) Creates a Cone primitive.
Public method Static CreateCone<T>(double, double, double, int, natureType) Creates a Cone primitive.
Public method Static CreateCone<T>(double, double, double, int, natureType, edgeStyleType) Creates a Cone primitive.
Public method Static CreateCylinder(double, Point3D, Point3D, int) Creates a Cylinder primitive.
Public method Static CreateCylinder(double, Point3D, Point3D, int, natureType) Creates a Cylinder primitive.
Public method Static CreateCylinder(double, Point3D, Point3D, int, natureType, edgeStyleType) Creates a Cylinder primitive.
Public method Static CreateCylinder(double, double, int) Creates a Cylinder primitive.
Public method Static CreateCylinder(double, double, int, natureType) Creates a Cylinder primitive.
Public method Static CreateCylinder(double, double, int, natureType, edgeStyleType) Creates a Cylinder primitive.
Public method Static CreateCylinder<T>(double, Point3D, Point3D, int) Creates a Cylinder primitive.
Public method Static CreateCylinder<T>(double, Point3D, Point3D, int, natureType) Creates a Cylinder primitive.
Public method Static CreateCylinder<T>(double, Point3D, Point3D, int, natureType, edgeStyleType) Creates a Cylinder primitive.
Public method Static CreateCylinder<T>(double, double, int) Creates a Cylinder primitive.
Public method Static CreateCylinder<T>(double, double, int, natureType) Creates a Cylinder primitive.
Public method Static CreateCylinder<T>(double, double, int, natureType, edgeStyleType) Creates a Cylinder primitive.
Public method Static CreatePlanar(IList<Point3D>, IList<IList<Point3D>>, natureType) Triangulates the specified 3D region.
Public method Static CreatePlanar(IList<Point3D>, natureType) Triangulates the specified 3D region.
Public method Static CreatePlanar(Plane, IList<Point2D>, IList<IList<Point2D>>, natureType) Triangulates the specified 2D region.
Public method Static CreatePlanar(Plane, IList<Point2D>, natureType) Triangulates the specified 2D region.
Public method Static CreatePlanar<T>(IList<Point3D>, IList<IList<Point3D>>, natureType) Triangulates the specified 3D region.
Public method Static CreatePlanar<T>(IList<Point3D>, natureType) Triangulates the specified 3D region.
Public method Static CreatePlanar<T>(Plane, IList<Point2D>, IList<IList<Point2D>>, natureType) Triangulates the specified 2D region.
Public method Static CreatePlanar<T>(Plane, IList<Point2D>, natureType) Triangulates the specified 2D region.
Public method Static CreateSphere(double, int, int) Creates a Sphere primitive.
Public method Static CreateSphere(double, int, int, natureType) Creates a Sphere primitive.
Public method Static CreateSphere<T>(double, int, int) Creates a Sphere primitive.
Public method Static CreateSphere<T>(double, int, int, natureType) Creates a Sphere primitive.
Public method Static CreateSpring(double, double, int, int, double, double, bool) Creates a Spring primitive.
Public method Static CreateSpring(double, double, int, int, double, double, bool, bool, natureType) Creates a Spring primitive.
Public method Static CreateSpring<T>(double, double, int, int, double, double, bool) Creates a Spring primitive.
Public method Static CreateSpring<T>(double, double, int, int, double, double, bool, bool, natureType) Creates a Spring primitive.
Public method Static CreateTorus(double, double, int, int) Creates a Torus primitive.
Public method Static CreateTorus(double, double, int, int, natureType) Creates a Torus primitive.
Public method Static CreateTorus<T>(double, double, int, int) Creates a Torus primitive.
Public method Static CreateTorus<T>(double, double, int, int, natureType) Creates a Torus primitive.
Public method CutBy(Plane) Cuts the part of the mesh on the positive side of a plane.
Public method CutBy(Plane, bool) Cuts the part of the mesh on the positive side of a plane.
Public method Dump() Returns a description of this entity.
Public method Equals(Object) (inherited from Object).
Public method ExtrudePlanar(Vector3D) Extrudes a quasi-planar mesh.
Public method ExtrudePlanar(double, double, double) Extrudes a quasi-planar mesh.
Protected method Finalize (inherited from Object).
Public method FindClosestTriangle(Transformation, Segment3D) Returns a list of triangles hit by the provided segment.
Public method FixNormals() Makes triangles winding order uniform.
Public method FlipNormal()
Public method FlipOutward() Flips the mesh normals outward.
Public method FromTriangles(Point3D[]) Generates a smooth GMesh from a list of triangles.
Public method GetArea(out Point3D)
Protected method Static GetClosestMainAxis(Vector3D) (inherited from GEntity).
Public method GetCoarseSampling() Returns a small set of points that gives a coarse idea of the 3D extent of the primitive.
Public method GetFaceTriangles(int, double) Gets the triangles adjacent to the given triangle.
Public method GetHashCode (inherited from Object).
Public method GetObjectData(SerializationInfo, StreamingContext) Populates a SerializationInfo instance with the data needed to serialize the target object.
Protected method Static GetOffsetDistance(Vector3D, Vector3D, double) (inherited from GEntity).
Public method GetType (inherited from Object).
Public method GetVolume(out Point3D)
Public method GetXElement()
Public method IsPointInside(Point3D) Checks if the specified point is inside the 3D mesh.
Public method IsValid() Returns true if all the entity fields contain reasonable information.
Protected method MemberwiseClone (inherited from Object).
Public method MergeWith(GQuad, bool) Merges the mesh with a GQuad entity that shares an edge with the mesh.
Public method MergeWith(GTriangle, bool) Merges the mesh with a GTriangle entity that shares an edge with the mesh.
Public method MergeWith(GMesh, bool, bool) Merges two compatible GMesh objects.
Public method MergeWith(GQuad) Merges the mesh with a GQuad entity that shares an edge with the mesh.
Public method MergeWith(GTriangle) Merges the mesh with a GQuad entity that shares an edge with the mesh.
Public method RemoveTextureMapping() Remove the texture mapping.
Public method ResetComputedData() Resets needed primitive's geometrical attributes to recompute.
Public method RevolvePlanar(double, double, Vector3D, Point3D, int, natureType) Revolves a quasi-planar mesh.
Public method Rotate(double, Vector3D, Point3D) Rotates the entity around an arbitrary axis by the specified angle. (inherited from GEntity).
Public method Rotate(double, Point3D, Point3D) Rotates the entity around an arbitray axis by the specified angle. (inherited from GEntity).
Public method Rotate(double, Vector3D) Rotates the entity around an arbitray axis by the specified angle. (inherited from GEntity).
Public method Scale(Point3D, double, double, double) Scales the entity of the specified scale factor. (inherited from GEntity).
Public method Scale(Point3D, double) Scales the entity of the specified scale factor. (inherited from GEntity).
Public method Scale(Vector3D) Scales the entity of the specified scale factor. (inherited from GEntity).
Public method Scale(double) Scales the entity of the specified scale factor. (inherited from GEntity).
Public method Scale(double, double, double) Scales the entity of the specified scale factor. (inherited from GEntity).
Public method Section(Plane, double) Computes the contours resulting from the intersection of the face and the given plane.
Public method Section(Plane, double, LinkedList<SharedEdge>[]) Computes the contours resulting from the intersection of the face and the given plane.
Public method Section(Plane, double, out SharedEdge[][]) Computes the contours resulting from the intersection of the face and the given plane.
Public method Section(PlaneEquation, LinkedList<SharedEdge>[]) Computes the contours resulting from the intersection of the GMesh and the given plane.
Public method Section(PlaneEquation, out SharedEdge[][]) Computes the contours resulting from the intersection of the GMesh and the given plane.
Public method SplitBy(Plane, bool, out GMesh[]) Splits this GMesh object by plane.
Public method SplitBy(Plane, out GMesh[]) Splits this GMesh object by plane.
Public method SplitDisjoint() Divides into separate objects meshes that do not connect, but are still one object.
Public method SubdivideBy(Plane) Subdivides the mesh by a plane. For geometrical use only.
Public method ToString (inherited from Object).
Internal protected (Protected Friend) method TransformAllVertices(Point3D[], Transformation, bool, bool) (inherited from GEntity).
Public method TransformBy(Transformation) Transforms all the entity's vertices by the specified transformation.
Public method Translate(double, double, double) Translates the entity. (inherited from GEntity).
Public method Translate(Vector3D) Translates the entity. (inherited from GEntity).
Public method UpdateNormals() Refreshes triangles normals.
Public method Weld() Removes duplicated vertices and degenerated triangles in the GMesh.
Public method Weld(double, bool) Removes duplicated vertices and degenerated triangles in the GMesh with a given tolerance.
Public method WeldFreeEdges() Removes duplicated vertices and degenerated triangles in the GMesh skipping internal vertices.
Public method WeldFreeEdges(double) Removes duplicated vertices and degenerated triangles in the GMesh skipping internal vertices.
Public method WeldFreeEdgesQuadratic(double) Removes duplicated vertices and degenerated triangles in the GMesh defined by QuadraticTriangle skipping internal vertices.
Public method WeldQuadratic(double) Removes duplicated vertices and degenerated triangles in the GMesh defined by QuadraticTriangle.
Public method Static WeldVectors(Point3D[], ref int, double, out int[]) Welds the array of Point3ds.
Top
Name Description
Public enumeration edgeStyleType GMesh edge style type.
Public enumeration natureType GMesh nature type.
Public enumeration normalAveragingType GMesh normal averaging type.
Top
Fields
 
Name Description
Public field sharedEdges
Top
Example
 
The following code samples demonstrate how to use the different mesh natures.
  using System;
  using System.Collections.Generic;
 
  using devDept.Eyeshot;
  using devDept.Geometry.Entities;
  using devDept.Geometry;
 
  namespace MeshSamples
  {
      internal class GMesh
      {
          private static int rows = 8;
          private static int cols = 8;
          private static double scale = 4;
 
          public static void Plain(Design design)
          {
              List<Point3D> vertices = new List<Point3D>(rows * cols);
              GMesh surface = new GMesh();
              surface.NormalAveragingMode = GMesh.normalAveragingType.Averaged;
              for (int j = 0; j < rows; j++)
                  for (int i = 0; i < cols; i++)
                  {
                      double x = -i / 5.0 - 2;
                      double y = -j / 5.0 - 2;
                      double f = 0;
                      double den = Math.Sqrt(x * x + y * y);
                      if (den != 0)
                          f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den;
                      vertices.Add(new Point3D(x, y, f));
                  }
              List<IndexTriangle> triangles = new List<IndexTriangle>((rows - 1) * (cols - 1) * 2);
              for (int j = 0; j < (rows - 1); j++)
                  for (int i = 0; i < (cols - 1); i++)
                  {
                      triangles.Add(new IndexTriangle(i + j * cols,
                                                      i + j * cols + 1,
                                                      i + (j + 1) * cols + 1));
                      triangles.Add(new IndexTriangle(i + j * cols,
                                                      i + (j + 1) * cols + 1,
                                                      i + (j + 1) * cols));
                  }
              surface.Vertices = vertices.ToArray();
              surface.Triangles = triangles.ToArray();
              design.Entities.Add(surface, 0, Color.Green);
          }
 
          public static void ColoredPlain(Design design)
          {
              List<Point3D> vertices = new List<Point3D>(rows*cols);
              GMesh surface = new GMesh();
              for (int j = 0; j < rows; j++)
                  for (int i = 0; i < cols; i++)
                  {
                      double x = -i/5.0 - 2;
                      double y = -j/5.0 - 2;
                      double f = 0;
                      double den = Math.Sqrt(x*x + y*y);
                      if (den != 0)
                          f = scale*Math.Sin(Math.Sqrt(x*x + y*y))/den;
                      vertices.Add(new Point3D(x, y, f));
                  }
              List<ColorTriangle> triangles = new List<ColorTriangle>((rows - 1)*(cols - 1)*2);
              for (int j = 0; j < (rows - 1); j++)
                  for (int i = 0; i < (cols - 1); i++)
                  {
                      // generates a random color
                      int red = (int) (255 - i*100);
                      int green = (int) (255 - j*50);
                      int blue = 127;
                      // clamps color values lat 0-255
                      Utility.LimitRange<int>(0, ref red, 255);
                      Utility.LimitRange<int>(0, ref green, 255);
                      Utility.LimitRange<int>(0, ref blue, 255);
                      triangles.Add(new ColorTriangle(i + j*cols,
                                                      i + j*cols + 1,
                                                      i + (j + 1)*cols + 1, (byte) red, (byte) green, (byte) blue));
                      triangles.Add(new ColorTriangle(i + j*cols,
                                                      i + (j + 1)*cols + 1,
                                                      i + (j + 1)*cols, (byte) red, (byte) green, (byte) blue));
                  }
              surface.Vertices = vertices.ToArray();
              surface.Triangles = triangles.ToArray();
              design.Entities.Add(surface, 0);
          }
 
          public static void MulticolorPlain(Design design)
          {
              List<PointRGB> vertices = new List<PointRGB>(rows * cols);
              GMesh surface = new GMesh();
              for (int j = 0; j < rows; j++)
                  for (int i = 0; i < cols; i++)
                  {
                      double x = -i / 5.0 - 2;
                      double y = -j / 5.0 - 2;
                      double f = 0;
                      double den = Math.Sqrt(x * x + y * y);
                      if (den != 0)
                          f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den;
                      // generates a random color
                      int red = (int)(y * y * 30);
                      int green = (int)(x * x * 30);
                      int blue = (int)(255 - f * f * 1000);
                      // clamps color values lat 0-255
                      Utility.LimitRange<int>(0, ref red, 255);
                      Utility.LimitRange<int>(0, ref green, 255);
                      Utility.LimitRange<int>(0, ref blue, 255);
                      vertices.Add(new PointRGB(x, y, f, (byte)red, (byte)green, (byte)blue));
                  }
              List<IndexTriangle> triangles = new List<IndexTriangle>((rows - 1) * (cols - 1) * 2);
              for (int j = 0; j < (rows - 1); j++)
                  for (int i = 0; i < (cols - 1); i++)
                  {
                      triangles.Add(new IndexTriangle(i + j * cols,
                                                      i + j * cols + 1,
                                                      i + (j + 1) * cols + 1));
                      triangles.Add(new IndexTriangle(i + j * cols,
                                                      i + (j + 1) * cols + 1,
                                                      i + (j + 1) * cols));
                  }
              surface.Vertices = vertices.ToArray();
              surface.Triangles = triangles.ToArray();
              design.Entities.Add(surface);
          }
 
          public static void TexturedPlain(Design design)
          {
              List<Point3D> vertices = new List<Point3D>(rows * cols);
              List<Point2D> texCoords = new List<Point2D>(rows * cols);
              GMesh surface = new GMesh();
              for (int j = 0; j < rows; j++)
                  for (int i = 0; i < cols; i++)
                  {
                      double x = -i / 5.0 - 2;
                      double y = -j / 5.0 - 2;
                      double f = 0;
                      double den = Math.Sqrt(x * x + y * y);
                      if (den != 0)
                          f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den;
                      vertices.Add(new Point3D(x, y, f));
                      texCoords.Add(new Point2D((-x * 5) / (rows - 1), (-y * 5) / (cols - 1)));
                  }
              Bitmap bmp = new Bitmap(Properties.Resources.Smiley);
              Material mat = new Material(bmp);
              design.Materials.Add("test", mat);
              List<RichTriangle> triangles = new List<RichTriangle>((rows - 1) * (cols - 1) * 2);
              for (int j = 0; j < (rows - 1); j++)
                  for (int i = 0; i < (cols - 1); i++)
                  {
                      RichTriangle tri = new RichTriangle(i + j * cols,
                                                          i + j * cols + 1,
                                                          i + (j + 1) * cols + 1);
                      tri.T1 = tri.V1;
                      tri.T2 = tri.V2;
                      tri.T3 = tri.V3;
                      triangles.Add(tri);
                      tri = new RichTriangle(i + j * cols,
                                             i + (j + 1) * cols + 1,
                                             i + (j + 1) * cols);
                      tri.T1 = tri.V1;
                      tri.T2 = tri.V2;
                      tri.T3 = tri.V3;
                      triangles.Add(tri);
                  }
              surface.Vertices = vertices.ToArray();
              surface.Triangles = triangles.ToArray();
              surface.TextureCoords = texCoords.ToArray();
 
              surface.ColorMethod = colorMethodType.byEntity;
              surface.MaterialName = "test";
 
              design.Entities.Add(surface);
          }
 
          public static void Smooth(Design design)
          {
              List<Point3D> vertices = new List<Point3D>(rows * cols);
              GMesh surface = new GMesh();
              surface.NormalAveragingMode = GMesh.normalAveragingType.Averaged;
              for (int j = 0; j < rows; j++)
                  for (int i = 0; i < cols; i++)
                  {
                      double x = -i / 5.0 - 2;
                      double y = -j / 5.0 - 2;
                      double f = 0;
                      double den = Math.Sqrt(x * x + y * y);
                      if (den != 0)
                          f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den;
                      vertices.Add(new Point3D(x, y, f));
                  }
              List<SmoothTriangle> triangles = new List<SmoothTriangle>((rows - 1) * (cols - 1) * 2);
              for (int j = 0; j < (rows - 1); j++)
                  for (int i = 0; i < (cols - 1); i++)
                  {
                      triangles.Add(new SmoothTriangle(i + j * cols,
                                                       i + j * cols + 1,
                                                       i + (j + 1) * cols + 1));
                      triangles.Add(new SmoothTriangle(i + j * cols,
                                                       i + (j + 1) * cols + 1,
                                                       i + (j + 1) * cols));
                  }
              surface.Vertices = vertices.ToArray();
              surface.Triangles = triangles.ToArray();
              design.Entities.Add(surface, 0, Color.Green);
          }
 
          public static void ColoredSmooth(Design design)
          {
              List<Point3D> vertices = new List<Point3D>(rows * cols);
              GMesh surface = new GMesh();
              for (int j = 0; j < rows; j++)
                  for (int i = 0; i < cols; i++)
                  {
                      double x = -i / 5.0 - 2;
                      double y = -j / 5.0 - 2;
                      double f = 0;
                      double den = Math.Sqrt(x * x + y * y);
                      if (den != 0)
                          f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den;
                      vertices.Add(new Point3D(x, y, f));
                  }
              List<ColorSmoothTriangle> triangles = new List<ColorSmoothTriangle>((rows - 1) * (cols - 1) * 2);
              for (int j = 0; j < (rows - 1); j++)
                  for (int i = 0; i < (cols - 1); i++)
                  {
                      // generates a random color
                      int red = (255 - i * 100);
                      int green = (255 - j * 50);
                      int blue = 127;
                      // clamps color values lat 0-255
                      Utility.LimitRange<int>(0, ref red, 255);
                      Utility.LimitRange<int>(0, ref green, 255);
                      Utility.LimitRange<int>(0, ref blue, 255);
                      triangles.Add(new ColorSmoothTriangle(i + j * cols,
                                                            i + j * cols + 1,
                                                            i + (j + 1) * cols + 1, (byte)red, (byte)green, (byte)blue));
                      triangles.Add(new ColorSmoothTriangle(i + j * cols,
                                                            i + (j + 1) * cols + 1,
                                                            i + (j + 1) * cols, (byte)red, (byte)green, (byte)blue));
                  }
              surface.Vertices = vertices.ToArray();
              surface.Triangles = triangles.ToArray();
              design.Entities.Add(surface, 0);
          }
 
          public static void MulticolorSmooth(Design design)
          {
              List<PointRGB> vertices = new List<PointRGB>(rows * cols);
              GMesh surface = new GMesh();
              surface.NormalAveragingMode = GMesh.normalAveragingType.Averaged;
              for (int j = 0; j < rows; j++)
                  for (int i = 0; i < cols; i++)
                  {
                      double x = -i / 5.0 - 2;
                      double y = -j / 5.0 - 2;
                      double f = 0;
                      double den = Math.Sqrt(x * x + y * y);
                      if (den != 0)
                          f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den;
                      // generates a random color
                      int red = (int)(y * y * 30);
                      int green = (int)(x * x * 30);
                      int blue = (int)(255 - f * f * 1000);
                      // clamps color values lat 0-255
                      Utility.LimitRange<int>(0, ref red, 255);
                      Utility.LimitRange<int>(0, ref green, 255);
                      Utility.LimitRange<int>(0, ref blue, 255);
                      vertices.Add(new PointRGB(x, y, f, (byte)red, (byte)green, (byte)blue));
                  }
              List<SmoothTriangle> triangles = new List<SmoothTriangle>((rows - 1) * (cols - 1) * 2);
              for (int j = 0; j < (rows - 1); j++)
                  for (int i = 0; i < (cols - 1); i++)
                  {
                      triangles.Add(new SmoothTriangle(i + j * cols,
                                                       i + j * cols + 1,
                                                       i + (j + 1) * cols + 1));
                      triangles.Add(new SmoothTriangle(i + j * cols,
                                                       i + (j + 1) * cols + 1,
                                                       i + (j + 1) * cols));
                  }
              surface.Vertices = vertices.ToArray();
              surface.Triangles = triangles.ToArray();
              design.Entities.Add(surface, 0);
          }
 
          public static void TexturedSmooth(Design design)
          {
              List<Point3D> vertices = new List<Point3D>(rows * cols);
              List<Point2D> texCoords = new List<Point2D>(rows * cols);
              GMesh surface = new GMesh();
              for (int j = 0; j < rows; j++)
                  for (int i = 0; i < cols; i++)
                  {
                      double x = -i / 5.0 - 2;
                      double y = -j / 5.0 - 2;
                      double f = 0;
                      double den = Math.Sqrt(x * x + y * y);
                      if (den != 0)
                          f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den;
                      vertices.Add(new Point3D(x, y, f));
                      texCoords.Add(new Point2D((-x * 5) / (rows - 1), (-y * 5) / (cols - 1)));
                  }
              Bitmap bmp = new Bitmap(Properties.Resources.Smiley);
              Material mat = new Material(bmp);
              design.Materials.Add("test", mat);
              List<RichSmoothTriangle> triangles = new List<RichSmoothTriangle>((rows - 1) * (cols - 1) * 2);
              for (int j = 0; j < (rows - 1); j++)
                  for (int i = 0; i < (cols - 1); i++)
                  {
                      RichSmoothTriangle tri = new RichSmoothTriangle(i + j * cols,
                                                                      i + j * cols + 1,
                                                                      i + (j + 1) * cols + 1);
                      tri.T1 = tri.V1;
                      tri.T2 = tri.V2;
                      tri.T3 = tri.V3;
                      triangles.Add(tri);
                      tri = new RichSmoothTriangle(i + j * cols,
                                                   i + (j + 1) * cols + 1,
                                                   i + (j + 1) * cols);
                      tri.T1 = tri.V1;
                      tri.T2 = tri.V2;
                      tri.T3 = tri.V3;
                      triangles.Add(tri);
                  }
              surface.Vertices = vertices.ToArray();
              surface.Triangles = triangles.ToArray();
              surface.TextureCoords = texCoords.ToArray();
 
              surface.MaterialName = "test";
              surface.ColorMethod = colorMethodType.byEntity;
 
              design.Entities.Add(surface, 0);
          }
 
      }
 					
This language is not supported or no code example is available.
  Imports System
  Imports System.Collections.Generic
  Imports devDept.Eyeshot
  Imports devDept.Geometry.Entities
  Imports devDept.Geometry
  Namespace MeshSamples
      Friend Class GMesh
      	Private Shared rows As Integer = 8
      	Private Shared cols As Integer = 8
      	Private Shared scale As Double = 4
 
      	Public Shared Sub Plain(design As Design)
      		Dim vertices As New List(Of Point3D)(rows * cols)
      		Dim surface As New GMesh()
      		surface.NormalAveragingMode = GMesh.normalAveragingType.Averaged
      		For j As Integer = 0 To rows - 1
      			For i As Integer = 0 To cols - 1
      				Dim x As Double = -i / 5.0 - 2
      				Dim y As Double = -j / 5.0 - 2
      				Dim f As Double = 0
      				Dim den As Double = Math.Sqrt(x * x + y * y)
      				If den <> 0 Then
      					f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den
      				End If
      				vertices.Add(New Point3D(x, y, f))
      			Next
      		Next
      		Dim triangles As New List(Of IndexTriangle)((rows - 1) * (cols - 1) * 2)
      		For j As Integer = 0 To (rows - 1) - 1
      			For i As Integer = 0 To (cols - 1) - 1
      				triangles.Add(New IndexTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1))
      				triangles.Add(New IndexTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols))
      			Next
      		Next
      		surface.Vertices = vertices.ToArray()
      		surface.Triangles = triangles.ToArray()
      		design.Entities.Add(surface, 0, Color.Green)
      	End Sub
 
      	Public Shared Sub ColoredPlain(design As Design)
      		Dim vertices As New List(Of Point3D)(rows * cols)
      		Dim surface As New GMesh()
      		For j As Integer = 0 To rows - 1
      			For i As Integer = 0 To cols - 1
      				Dim x As Double = -i / 5.0 - 2
      				Dim y As Double = -j / 5.0 - 2
      				Dim f As Double = 0
      				Dim den As Double = Math.Sqrt(x * x + y * y)
      				If den <> 0 Then
      					f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den
      				End If
      				vertices.Add(New Point3D(x, y, f))
      			Next
      		Next
      		Dim triangles As New List(Of ColorTriangle)((rows - 1) * (cols - 1) * 2)
      		For j As Integer = 0 To (rows - 1) - 1
      			For i As Integer = 0 To (cols - 1) - 1
      				' generates a random color
      				Dim red As Integer = CInt(255 - i * 100)
      				Dim green As Integer = CInt(255 - j * 50)
      				Dim blue As Integer = 127
      				' clamps color values lat 0-255
      				Utility.LimitRange(Of Integer)(0, red, 255)
      				Utility.LimitRange(Of Integer)(0, green, 255)
      				Utility.LimitRange(Of Integer)(0, blue, 255)
      				triangles.Add(New ColorTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1, CByte(red), CByte(green), CByte(blue)))
      				triangles.Add(New ColorTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols, CByte(red), CByte(green), CByte(blue)))
      			Next
      		Next
      		surface.Vertices = vertices.ToArray()
      		surface.Triangles = triangles.ToArray()
      		design.Entities.Add(surface, 0)
      	End Sub
 
      	Public Shared Sub MulticolorPlain(design As Design)
      		Dim vertices As New List(Of PointRGB)(rows * cols)
      		Dim surface As New GMesh()
      		For j As Integer = 0 To rows - 1
      			For i As Integer = 0 To cols - 1
      				Dim x As Double = -i / 5.0 - 2
      				Dim y As Double = -j / 5.0 - 2
      				Dim f As Double = 0
      				Dim den As Double = Math.Sqrt(x * x + y * y)
      				If den <> 0 Then
      					f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den
      				End If
      				' generates a random color
      				Dim red As Integer = CInt(y * y * 30)
      				Dim green As Integer = CInt(x * x * 30)
      				Dim blue As Integer = CInt(255 - f * f * 1000)
      				' clamps color values lat 0-255
      				Utility.LimitRange(Of Integer)(0, red, 255)
      				Utility.LimitRange(Of Integer)(0, green, 255)
      				Utility.LimitRange(Of Integer)(0, blue, 255)
      				vertices.Add(New PointRGB(x, y, f, CByte(red), CByte(green), CByte(blue)))
      			Next
      		Next
      		Dim triangles As New List(Of IndexTriangle)((rows - 1) * (cols - 1) * 2)
      		For j As Integer = 0 To (rows - 1) - 1
      			For i As Integer = 0 To (cols - 1) - 1
      				triangles.Add(New IndexTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1))
      				triangles.Add(New IndexTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols))
      			Next
      		Next
      		surface.Vertices = vertices.ToArray()
      		surface.Triangles = triangles.ToArray()
      		design.Entities.Add(surface)
      	End Sub
 
      	Public Shared Sub TexturedPlain(design As Design)
      		Dim vertices As New List(Of Point3D)(rows * cols)
      		Dim texCoords As New List(Of Point2D)(rows * cols)
      		Dim surface As New GMesh()
      		For j As Integer = 0 To rows - 1
      			For i As Integer = 0 To cols - 1
      				Dim x As Double = -i / 5.0 - 2
      				Dim y As Double = -j / 5.0 - 2
      				Dim f As Double = 0
      				Dim den As Double = Math.Sqrt(x * x + y * y)
      				If den <> 0 Then
      					f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den
      				End If
      				vertices.Add(New Point3D(x, y, f))
      				texCoords.Add(New Point2D((-x * 5) / (rows - 1), (-y * 5) / (cols - 1)))
      			Next
      		Next
      		Dim bmp As New Bitmap(Properties.Resources.Smiley)
      		Dim mat As New Material(bmp)
      		design.Materials.Add("test", mat)
      		Dim triangles As New List(Of RichTriangle)((rows - 1) * (cols - 1) * 2)
      		For j As Integer = 0 To (rows - 1) - 1
      			For i As Integer = 0 To (cols - 1) - 1
      				Dim tri As New RichTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)
      				tri.T1 = tri.V1
      				tri.T2 = tri.V2
      				tri.T3 = tri.V3
      				triangles.Add(tri)
      				tri = New RichTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)
      				tri.T1 = tri.V1
      				tri.T2 = tri.V2
      				tri.T3 = tri.V3
      				triangles.Add(tri)
      			Next
      		Next
      		surface.Vertices = vertices.ToArray()
      		surface.Triangles = triangles.ToArray()
      		surface.TextureCoords = texCoords.ToArray()
 
      		surface.ColorMethod = colorMethodType.byEntity
      		surface.MaterialName = "test"
 
      		design.Entities.Add(surface)
      	End Sub
 
      	Public Shared Sub Smooth(design As Design)
      		Dim vertices As New List(Of Point3D)(rows * cols)
      		Dim surface As New GMesh()
      		surface.NormalAveragingMode = GMesh.normalAveragingType.Averaged
      		For j As Integer = 0 To rows - 1
      			For i As Integer = 0 To cols - 1
      				Dim x As Double = -i / 5.0 - 2
      				Dim y As Double = -j / 5.0 - 2
      				Dim f As Double = 0
      				Dim den As Double = Math.Sqrt(x * x + y * y)
      				If den <> 0 Then
      					f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den
      				End If
      				vertices.Add(New Point3D(x, y, f))
      			Next
      		Next
      		Dim triangles As New List(Of SmoothTriangle)((rows - 1) * (cols - 1) * 2)
      		For j As Integer = 0 To (rows - 1) - 1
      			For i As Integer = 0 To (cols - 1) - 1
      				triangles.Add(New SmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1))
      				triangles.Add(New SmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols))
      			Next
      		Next
      		surface.Vertices = vertices.ToArray()
      		surface.Triangles = triangles.ToArray()
      		design.Entities.Add(surface, 0, Color.Green)
      	End Sub
 
      	Public Shared Sub ColoredSmooth(design As Design)
      		Dim vertices As New List(Of Point3D)(rows * cols)
      		Dim surface As New GMesh()
      		For j As Integer = 0 To rows - 1
      			For i As Integer = 0 To cols - 1
      				Dim x As Double = -i / 5.0 - 2
      				Dim y As Double = -j / 5.0 - 2
      				Dim f As Double = 0
      				Dim den As Double = Math.Sqrt(x * x + y * y)
      				If den <> 0 Then
      					f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den
      				End If
      				vertices.Add(New Point3D(x, y, f))
      			Next
      		Next
      		Dim triangles As New List(Of ColorSmoothTriangle)((rows - 1) * (cols - 1) * 2)
      		For j As Integer = 0 To (rows - 1) - 1
      			For i As Integer = 0 To (cols - 1) - 1
      				' generates a random color
      				Dim red As Integer = (255 - i * 100)
      				Dim green As Integer = (255 - j * 50)
      				Dim blue As Integer = 127
      				' clamps color values lat 0-255
      				Utility.LimitRange(Of Integer)(0, red, 255)
      				Utility.LimitRange(Of Integer)(0, green, 255)
      				Utility.LimitRange(Of Integer)(0, blue, 255)
      				triangles.Add(New ColorSmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1, CByte(red), CByte(green), CByte(blue)))
      				triangles.Add(New ColorSmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols, CByte(red), CByte(green), CByte(blue)))
      			Next
      		Next
      		surface.Vertices = vertices.ToArray()
      		surface.Triangles = triangles.ToArray()
      		design.Entities.Add(surface, 0)
      	End Sub
 
      	Public Shared Sub MulticolorSmooth(design As Design)
      		Dim vertices As New List(Of PointRGB)(rows * cols)
      		Dim surface As New GMesh()
      		surface.NormalAveragingMode = GMesh.normalAveragingType.Averaged
      		For j As Integer = 0 To rows - 1
      			For i As Integer = 0 To cols - 1
      				Dim x As Double = -i / 5.0 - 2
      				Dim y As Double = -j / 5.0 - 2
      				Dim f As Double = 0
      				Dim den As Double = Math.Sqrt(x * x + y * y)
      				If den <> 0 Then
      					f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den
      				End If
      				' generates a random color
      				Dim red As Integer = CInt(y * y * 30)
      				Dim green As Integer = CInt(x * x * 30)
      				Dim blue As Integer = CInt(255 - f * f * 1000)
      				' clamps color values lat 0-255
      				Utility.LimitRange(Of Integer)(0, red, 255)
      				Utility.LimitRange(Of Integer)(0, green, 255)
      				Utility.LimitRange(Of Integer)(0, blue, 255)
      				vertices.Add(New PointRGB(x, y, f, CByte(red), CByte(green), CByte(blue)))
      			Next
      		Next
      		Dim triangles As New List(Of SmoothTriangle)((rows - 1) * (cols - 1) * 2)
      		For j As Integer = 0 To (rows - 1) - 1
      			For i As Integer = 0 To (cols - 1) - 1
      				triangles.Add(New SmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1))
      				triangles.Add(New SmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols))
      			Next
      		Next
      		surface.Vertices = vertices.ToArray()
      		surface.Triangles = triangles.ToArray()
      		design.Entities.Add(surface, 0)
      	End Sub
 
      	Public Shared Sub TexturedSmooth(design As Design)
      		Dim vertices As New List(Of Point3D)(rows * cols)
      		Dim texCoords As New List(Of Point2D)(rows * cols)
      		Dim surface As New GMesh()
      		For j As Integer = 0 To rows - 1
      			For i As Integer = 0 To cols - 1
      				Dim x As Double = -i / 5.0 - 2
      				Dim y As Double = -j / 5.0 - 2
      				Dim f As Double = 0
      				Dim den As Double = Math.Sqrt(x * x + y * y)
      				If den <> 0 Then
      					f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den
      				End If
      				vertices.Add(New Point3D(x, y, f))
      				texCoords.Add(New Point2D((-x * 5) / (rows - 1), (-y * 5) / (cols - 1)))
      			Next
      		Next
      		Dim bmp As New Bitmap(Properties.Resources.Smiley)
      		Dim mat As New Material(bmp)
      		design.Materials.Add("test", mat)
      		Dim triangles As New List(Of RichSmoothTriangle)((rows - 1) * (cols - 1) * 2)
      		For j As Integer = 0 To (rows - 1) - 1
      			For i As Integer = 0 To (cols - 1) - 1
      				Dim tri As New RichSmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)
      				tri.T1 = tri.V1
      				tri.T2 = tri.V2
      				tri.T3 = tri.V3
      				triangles.Add(tri)
      				tri = New RichSmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)
      				tri.T1 = tri.V1
      				tri.T2 = tri.V2
      				tri.T3 = tri.V3
      				triangles.Add(tri)
      			Next
      		Next
      		surface.Vertices = vertices.ToArray()
      		surface.Triangles = triangles.ToArray()
      		surface.TextureCoords = texCoords.ToArray()
 
      		surface.MaterialName = "test"
      		surface.ColorMethod = colorMethodType.byEntity
 
      		design.Entities.Add(surface, 0)
      	End Sub
 
      End Class
  End Namespace					
This language is not supported or no code example is available.

.NET Framework

Supported in: 4.7.2

In this article

Definition