Poster of Linux kernelThe best gift for a Linux geek
Triangle

Triangle

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

Triangle -  

SYNOPSIS


 

Enumerations


enum IO_Type { INPUT = 0, OUTPUT = 1, BOTH = 2 }
 

Functions


void init (triangulateio &t)

void destroy (triangulateio &t, IO_Type)

void copy_tri_to_mesh (const triangulateio &triangle_data_input, UnstructuredMesh &mesh_output, const ElemType type)
 

Detailed Description

A special namespace for wrapping the standard Triangle API, as well as some helper functions for initializing/destroying the structs triangle uses to communicate.  

Enumeration Type Documentation

 

enum Triangle::IO_Type

Enumerator:

INPUT
OUTPUT
BOTH

Definition at line 54 of file mesh_triangle_support.h.

               {
    INPUT  = 0,
    OUTPUT = 1,
    BOTH   = 2};
 

Function Documentation

 

void Triangle::copy_tri_to_mesh (const triangulateio &triangle_data_input, UnstructuredMesh &mesh_output, const ElemTypetype)Copies triangulation data computed by triange from a triangulateio object to a LibMesh mesh. This routine is used internally by the MeshTools::Generation::build_delaunay_square(...) and MeshTools::Generation::build_delaunay_square_with_hole(...) routines.

Definition at line 222 of file mesh_triangle_support.C.

References MeshBase::add_elem(), MeshBase::add_point(), MeshBase::clear(), MeshBase::node_ptr(), MeshBase::prepare_for_use(), MeshBase::set_mesh_dimension(), Elem::set_node(), libMeshEnums::TRI3, and libMeshEnums::TRI6.

Referenced by TriangleInterface::triangulate().

{
  // Transfer the information into the LibMesh mesh.
  mesh_output.clear();
  
  // Make sure the new Mesh will be 2D
  mesh_output.set_mesh_dimension(2);
  
  // Node information
  for (int i=0, c=0; c<triangle_data_input.numberofpoints; i+=2, ++c)
    {
      mesh_output.add_point( Point(triangle_data_input.pointlist[i],
                                   triangle_data_input.pointlist[i+1]) );
    }

  // Element information
  for (int i=0; i<triangle_data_input.numberoftriangles; ++i)
    {
      switch (type)
        {
        case TRI3:
          {
            Elem* elem = mesh_output.add_elem (new Tri3);

            for (unsigned int n=0; n<3; ++n)
              elem->set_node(n) = mesh_output.node_ptr(triangle_data_input.trianglelist[i*3 + n]);

            break;
          }

        case TRI6:
          {
            Elem* elem = mesh_output.add_elem (new Tri6);

            // Triangle number TRI6 nodes in a different way to libMesh
            elem->set_node(0) = mesh_output.node_ptr(triangle_data_input.trianglelist[i*6 + 0]);
            elem->set_node(1) = mesh_output.node_ptr(triangle_data_input.trianglelist[i*6 + 1]);
            elem->set_node(2) = mesh_output.node_ptr(triangle_data_input.trianglelist[i*6 + 2]);
            elem->set_node(3) = mesh_output.node_ptr(triangle_data_input.trianglelist[i*6 + 5]);
            elem->set_node(4) = mesh_output.node_ptr(triangle_data_input.trianglelist[i*6 + 3]);
            elem->set_node(5) = mesh_output.node_ptr(triangle_data_input.trianglelist[i*6 + 4]);

            break;
          }

        default:
          {
            std::cerr << 'ERROR: Unrecognized triangular element type.' << std::endl;
            libmesh_error();
          }
        }
    }

  // Prepare mesh for usage.
  mesh_output.prepare_for_use();
}
 

void Triangle::destroy (triangulateio &t, IO_Type)Frees any memory which has been dynamically allocated by Triangle. Note the following facts: 1) Triangle does not free any memory itself 2) It is always safe to call free on a NULL pointer.

However, triangle *does* shallow-copy (for example) the holelist pointer from the input to output struct **without** performing a deep copy of the holelist itself. Therefore, double-free will occur without additional care!

Referenced by TriangleInterface::triangulate().  

void Triangle::init (triangulateio &t)Initializes the fields of t to NULL/0 as necessary. This is helpful for preventing the access of uninitialized memory when working with C, which has no constructors or destructors.

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Enumerations
Functions
Detailed Description
Enumeration Type Documentation
enum Triangle::IO_Type
Function Documentation
void Triangle::copy_tri_to_mesh (const triangulateio &triangle_data_input, UnstructuredMesh &mesh_output, const ElemTypetype)Copies triangulation data computed by triange from a triangulateio object to a LibMesh mesh. This routine is used internally by the MeshTools::Generation::build_delaunay_square(...) and MeshTools::Generation::build_delaunay_square_with_hole(...) routines.
void Triangle::destroy (triangulateio &t, IO_Type)Frees any memory which has been dynamically allocated by Triangle. Note the following facts: 1) Triangle does not free any memory itself 2) It is always safe to call free on a NULL pointer.
void Triangle::init (triangulateio &t)Initializes the fields of t to NULL/0 as necessary. This is helpful for preventing the access of uninitialized memory when working with C, which has no constructors or destructors.
Author

This document was created by man2html, using the manual pages.
Time: 21:57:47 GMT, April 16, 2011