TriangleNet.Mesh.Load C# (CSharp) Method

Load() public method

Reconstructs a mesh from raw input data.
public Load ( InputGeometry input, List triangles ) : void
input TriangleNet.Geometry.InputGeometry
triangles List
return void
        public void Load(InputGeometry input, List<ITriangle> triangles)
        {
            if (input == null || triangles == null)
            {
                throw new ArgumentException("Invalid input (argument is null).");
            }

            // Clear all data structures / reset hash seeds
            this.ResetData();

            if (input.HasSegments)
            {
                behavior.Poly = true;

                this.holes.AddRange(input.Holes);
            }

            //if (input.EdgeMarkers != null)
            //{
            //    behavior.UseBoundaryMarkers = true;
            //}

            //if (input.TriangleAreas != null)
            //{
            //    behavior.VarArea = true;
            //}

            // TODO: remove
            if (!behavior.Poly)
            {
                // Be careful not to allocate space for element area constraints that
                // will never be assigned any value (other than the default -1.0).
                behavior.VarArea = false;

                // Be careful not to add an extra attribute to each element unless the
                // input supports it (PSLG in, but not refining a preexisting mesh).
                behavior.useRegions = false;
            }

            behavior.useRegions = input.Regions.Count > 0;

            TransferNodes(input);

            // Read and reconstruct a mesh.
            hullsize = DataReader.Reconstruct(this, input, triangles.ToArray());

            // Calculate the number of edges.
            edges = (3 * triangles.Count + hullsize) / 2;
        }

Same methods

Mesh::Load ( string filename ) : void

Usage Example

Beispiel #1
0
        public Mesh Import(string filename)
        {
            InputGeometry geometry = this.Read(filename);

            List<ITriangle> triangles = null;

            if (this.json.ContainsKey("triangles"))
            {
                var tri = this.json["triangles"] as Dictionary<string, object>;

                if (tri != null)
                {
                    triangles = ReadTriangles(tri, geometry.Count);
                }
            }

            Mesh mesh = new Mesh();
            mesh.Load(geometry, triangles);

            return mesh;
        }