cgma
ChollaMesh Class Reference

#include <ChollaMesh.hpp>

List of all members.

Public Member Functions

 ChollaMesh ()
 ~ChollaMesh ()
FacetEntityconvert_to_facet (SMD::SMDElement elem)
CubitPointconvert_to_point (SMD::SMDNode node)
SMD::SMDElement convert_from_facet (FacetEntity *f)
SMD::SMDNode convert_from_point (CubitPoint *p)
SMD::ErrorCode get_ids (size_t num, const SMD::SMDNode nodes[], int ids[])
SMD::ErrorCode get_ids (size_t num, const SMD::SMDElement elems[], int ids[])
SMD::ErrorCode get_node_handle (int id, SMD::SMDNode &node)
SMD::ErrorCode get_element_handle (SMD::ElementType type, int id, SMD::SMDElement &elem)
SMD::ErrorCode get_element_types (int num_elems, const SMD::SMDElement elem_handle_array[], SMD::ElementType type_array[], bool *same_type)
SMD::ErrorCode get_element_dimensions (int num_elems, const SMD::SMDElement elem_handle_array[], int dimensions[])
SMD::ErrorCode get_element_length (SMD::SMDElement elem_handle, double &length)
SMD::ErrorCode get_element_area (SMD::SMDElement elem_handle, double &area)
SMD::ErrorCode get_element_normal (SMD::SMDElement elem_handle, double normal_vector[3])
SMD::ErrorCode get_element_centroid (SMD::SMDElement elem_handle, double centroid[3])
SMD::ErrorCode get_coords (int num_nodes, const SMD::SMDNode node_handle_array[], float coords[][3])
SMD::ErrorCode get_coords (int num_nodes, const SMD::SMDNode node_handle_array[], double coords[][3])
SMD::ErrorCode get_coords (int num_nodes, const SMD::SMDNode node_handle_array[], SMD::Real x_coords[], SMD::Real y_coords[], SMD::Real z_coords[])
SMD::ErrorCode get_connectivity (int num_elems, const SMD::SMDElement elements[], int &node_array_size, SMD::SMDNode node_handles[])
SMD::ErrorCode get_expanded_connectivity (int num_elems, const SMD::SMDElement elements[], unsigned int nodes_per_elem, int node_array_size, SMD::SMDNode node_handles[])
SMD::ErrorCode get_expanded_connectivity (SMD::SMDElement elements, unsigned int &nodes_per_elem, int node_array_size, SMD::SMDNode node_handles[])
SMD::ErrorCode create_nodes (unsigned int num_nodes, const SMD::Real coords[][3], SMD::SMeshOwner owner, SMD::SMDNode node_handles[])
SMD::ErrorCode create_nodes (unsigned int num_nodes, const SMD::Real *coords, SMD::SMeshOwner owner, SMD::SMDNode node_handles[])
SMD::ErrorCode create_elements (SMD::ElementType type, unsigned int num_nodes, const SMD::SMDNode node_handle_array[], unsigned int num_elements, unsigned int num_nodes_per_element, const unsigned int connectivity[], SMD::SMeshOwner new_entities_owner, SMD::SMDElement *created_element_handles)
SMD::ErrorCode delete_node (SMD::SMDNode node)
SMD::ErrorCode delete_element (SMD::SMDElement element)
SMD::ErrorCode reverse_element_connectivity (SMD::SMDElement element)
SMD::ErrorCode find_element (SMD::ElementType type, unsigned int num_pts, const SMD::SMDNode nodes[], SMD::SMDElement &found_element)

Detailed Description

Definition at line 11 of file ChollaMesh.hpp.


Constructor & Destructor Documentation

Definition at line 7 of file ChollaMesh.cpp.

{
}

Definition at line 11 of file ChollaMesh.cpp.

{
}

Member Function Documentation

SMD::SMDElement ChollaMesh::convert_from_facet ( FacetEntity f)

Definition at line 25 of file ChollaMesh.cpp.

{
  SMD::SMDElement e;
  e.mHandle = reinterpret_cast<size_t>(f);
  return e;
}

Definition at line 32 of file ChollaMesh.cpp.

{
  SMD::SMDNode n;
  n.mHandle = reinterpret_cast<size_t>(p);
  return n;
}
FacetEntity * ChollaMesh::convert_to_facet ( SMD::SMDElement  elem)

Definition at line 15 of file ChollaMesh.cpp.

{
  return reinterpret_cast<FacetEntity*>(elem.mHandle);
}
CubitPoint * ChollaMesh::convert_to_point ( SMD::SMDNode  node)

Definition at line 20 of file ChollaMesh.cpp.

{
  return reinterpret_cast<CubitPoint*>(node.mHandle);
}
SMD::ErrorCode ChollaMesh::create_elements ( SMD::ElementType  type,
unsigned int  num_nodes,
const SMD::SMDNode  node_handle_array[],
unsigned int  num_elements,
unsigned int  num_nodes_per_element,
const unsigned int  connectivity[],
SMD::SMeshOwner  new_entities_owner,
SMD::SMDElement *  created_element_handles 
)

Definition at line 299 of file ChollaMesh.cpp.

{
  if(type == SMD::EDGE)
  {
    unsigned int conn_offset=0;
    for(unsigned int i=0; i<num_elements; i++, conn_offset += num_nodes_per_element)
    {
      CubitPoint* pts[2];
      pts[0] = convert_to_point(node_handle_array[connectivity[conn_offset]]);
      pts[1] = convert_to_point(node_handle_array[connectivity[conn_offset+1]]);
      created_element_handles[i] = convert_from_facet(new CubitFacetEdgeData(pts[0], pts[1]));
    }
    return SMD::STATUS_OK;
  }
  else if(type == SMD::TRI)
  {
    unsigned int conn_offset=0;
    for(unsigned int i=0; i<num_elements; i++, conn_offset += num_nodes_per_element)
    {
      CubitPoint* pts[3];
      pts[0] = convert_to_point(node_handle_array[connectivity[conn_offset]]);
      pts[1] = convert_to_point(node_handle_array[connectivity[conn_offset+1]]);
      pts[2] = convert_to_point(node_handle_array[connectivity[conn_offset+2]]);
      created_element_handles[i] = convert_from_facet(new CubitFacetData(pts[0], pts[1], pts[2]));
    }
    return SMD::STATUS_OK;
  }

  return SMD::ERR_INVALID_ENTITY_TYPE;
}
SMD::ErrorCode ChollaMesh::create_nodes ( unsigned int  num_nodes,
const SMD::Real  coords[][3],
SMD::SMeshOwner  owner,
SMD::SMDNode  node_handles[] 
)

Definition at line 285 of file ChollaMesh.cpp.

{
  for(unsigned int i=0; i<num_nodes; i++)
  {
    node_handles[i] = convert_from_point(new CubitPointData(coords[i][0], coords[i][1], coords[i][2]));
  }
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::create_nodes ( unsigned int  num_nodes,
const SMD::Real *  coords,
SMD::SMeshOwner  owner,
SMD::SMDNode  node_handles[] 
) [inline]

Definition at line 69 of file ChollaMesh.hpp.

                                {return SMD::ERR_NOT_IMPLEMENTED;}
SMD::ErrorCode ChollaMesh::delete_element ( SMD::SMDElement  element)

Definition at line 351 of file ChollaMesh.cpp.

{
  FacetEntity* f = convert_to_facet(element);
  if(!f)
    return SMD::ERR_INVALID_ENTITY_HANDLE;

  delete f;

  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::delete_node ( SMD::SMDNode  node)

Definition at line 339 of file ChollaMesh.cpp.

{
  CubitPoint* f = convert_to_point(node);
  if(!f)
    return SMD::ERR_INVALID_ENTITY_HANDLE;

  delete f;

  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::find_element ( SMD::ElementType  type,
unsigned int  num_pts,
const SMD::SMDNode  nodes[],
SMD::SMDElement &  found_element 
)

Definition at line 382 of file ChollaMesh.cpp.

{
  if(type == SMD::EDGE && num_pts == 2)
  {
    CubitFacetEdge* edge = convert_to_point(nodes[0])->shared_edge(convert_to_point(nodes[1]));
    found_element = convert_from_facet(edge);
    return SMD::STATUS_OK;
  }
  else if(type == SMD::TRI && num_pts == 3)
  {
    DLIList<CubitFacet*> facets[3];
    convert_to_point(nodes[0])->facets(facets[0]);
    convert_to_point(nodes[1])->facets(facets[1]);
    convert_to_point(nodes[2])->facets(facets[2]);
    facets[0].intersect_unordered(facets[1]);
    facets[0].intersect_unordered(facets[2]);

    if(facets[0].size())
    {
      found_element = convert_from_facet(facets[0][0]);
    }
    return SMD::STATUS_OK;
  }
  return SMD::ERR_INVALID_ENTITY_TYPE;
}
SMD::ErrorCode ChollaMesh::get_connectivity ( int  num_elems,
const SMD::SMDElement  elements[],
int &  node_array_size,
SMD::SMDNode  node_handles[] 
)

Definition at line 221 of file ChollaMesh.cpp.

{
  CubitFacet* tri;
  CubitFacetEdge* edge;

  int offset = 0;
  for(int i=0; i<num_elems; i++)
  {
    FacetEntity* f = convert_to_facet(elements[i]);
    if((tri = dynamic_cast<CubitFacet*>(f)))
    {
      if(offset + 3 > node_array_size)
      {
        return SMD::ERR_ARRAY_TOO_SMALL;
      }

      node_handles[offset++] = convert_from_point(tri->point(0));
      node_handles[offset++] = convert_from_point(tri->point(1));
      node_handles[offset++] = convert_from_point(tri->point(2));
    }
    else if((edge = dynamic_cast<CubitFacetEdge*>(f)))
    {
      if(offset + 2 > node_array_size)
      {
        return SMD::ERR_ARRAY_TOO_SMALL;
      }
      node_handles[offset++] = convert_from_point(edge->point(0));
      node_handles[offset++] = convert_from_point(edge->point(1));
    }
    else
    {
      return SMD::ERR_INVALID_ENTITY_HANDLE;
    }
  }
  node_array_size = offset;
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_coords ( int  num_nodes,
const SMD::SMDNode  node_handle_array[],
float  coords[][3] 
)

Definition at line 184 of file ChollaMesh.cpp.

{
  for(int i=0; i<num_nodes; i++)
  {
    CubitPoint* p = convert_to_point(node_handle_array[i]);
    coords[i][0] = p->x();
    coords[i][1] = p->y();
    coords[i][2] = p->z();
  }
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_coords ( int  num_nodes,
const SMD::SMDNode  node_handle_array[],
double  coords[][3] 
)

Definition at line 196 of file ChollaMesh.cpp.

{
  for(int i=0; i<num_nodes; i++)
  {
    CubitPoint* p = convert_to_point(node_handle_array[i]);
    coords[i][0] = p->x();
    coords[i][1] = p->y();
    coords[i][2] = p->z();
  }
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_coords ( int  num_nodes,
const SMD::SMDNode  node_handle_array[],
SMD::Real  x_coords[],
SMD::Real  y_coords[],
SMD::Real  z_coords[] 
)

Definition at line 208 of file ChollaMesh.cpp.

{
  for(int i=0; i<num_nodes; i++)
  {
    CubitPoint* p = convert_to_point(node_handle_array[i]);
    x_coords[i] = p->x();
    y_coords[i] = p->y();
    z_coords[i] = p->z();
  }
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_element_area ( SMD::SMDElement  elem_handle,
double &  area 
)

Definition at line 141 of file ChollaMesh.cpp.

{
  CubitFacet* f = dynamic_cast<CubitFacet*>(convert_to_facet(elem_handle));
  if(!f)
  {
    return SMD::ERR_INVALID_ENTITY_HANDLE;
  }

  area = f->area();
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_element_centroid ( SMD::SMDElement  elem_handle,
double  centroid[3] 
)

Definition at line 169 of file ChollaMesh.cpp.

{
  CubitFacet* f = dynamic_cast<CubitFacet*>(convert_to_facet(elem_handle));
  if(!f)
  {
    return SMD::ERR_INVALID_ENTITY_HANDLE;
  }

  CubitVector c = f->center();
  centroid[0] = c.x();
  centroid[1] = c.y();
  centroid[2] = c.z();
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_element_dimensions ( int  num_elems,
const SMD::SMDElement  elem_handle_array[],
int  dimensions[] 
)

Definition at line 106 of file ChollaMesh.cpp.

{
  for(int i=0; i<num_elems; i++)
  {
    FacetEntity* f = convert_to_facet(elem_handle_array[i]);
    if(dynamic_cast<CubitFacet*>(f))
    {
      dimensions[i] = 2;
    }
    else if(dynamic_cast<CubitFacetEdge*>(f))
    {
      dimensions[i] = 1;
    }
    else
    {
      dimensions[i] = 0;
    }
  }
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_element_handle ( SMD::ElementType  type,
int  id,
SMD::SMDElement &  elem 
)

Definition at line 79 of file ChollaMesh.cpp.

{
  return SMD::ERR_NOT_IMPLEMENTED;
}
SMD::ErrorCode ChollaMesh::get_element_length ( SMD::SMDElement  elem_handle,
double &  length 
)

Definition at line 129 of file ChollaMesh.cpp.

{
  CubitFacetEdge* f = dynamic_cast<CubitFacetEdge*>(convert_to_facet(elem_handle));
  if(!f)
  {
    return SMD::ERR_INVALID_ENTITY_HANDLE;
  }

  length = f->length();
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_element_normal ( SMD::SMDElement  elem_handle,
double  normal_vector[3] 
)

Definition at line 154 of file ChollaMesh.cpp.

{
  CubitFacet* f = dynamic_cast<CubitFacet*>(convert_to_facet(elem_handle));
  if(!f)
  {
    return SMD::ERR_INVALID_ENTITY_HANDLE;
  }

  CubitVector n = f->normal();
  normal_vector[0] = n.x();
  normal_vector[1] = n.y();
  normal_vector[2] = n.z();
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_element_types ( int  num_elems,
const SMD::SMDElement  elem_handle_array[],
SMD::ElementType  type_array[],
bool *  same_type 
)

Definition at line 84 of file ChollaMesh.cpp.

{
  for(int i=0; i<num_elems; i++)
  {
    FacetEntity* f = convert_to_facet(elem_handle_array[i]);
    if(dynamic_cast<CubitFacet*>(f))
    {
      type_array[i] = SMD::TRI;
    }
    else if(dynamic_cast<CubitFacetEdge*>(f))
    {
      type_array[i] = SMD::EDGE;
    }
    else
    {
      type_array[i] = SMD::NO_ELEMENT_TYPE;
    }
  }
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_expanded_connectivity ( int  num_elems,
const SMD::SMDElement  elements[],
unsigned int  nodes_per_elem,
int  node_array_size,
SMD::SMDNode  node_handles[] 
)

Definition at line 264 of file ChollaMesh.cpp.

{
  return SMD::ERR_NOT_IMPLEMENTED;
}
SMD::ErrorCode ChollaMesh::get_expanded_connectivity ( SMD::SMDElement  elements,
unsigned int &  nodes_per_elem,
int  node_array_size,
SMD::SMDNode  node_handles[] 
)

Definition at line 274 of file ChollaMesh.cpp.

{
  SMD::ErrorCode ret = get_connectivity(1, &element, node_array_size, node_handles);
  nodes_per_elem = node_array_size;
  return ret;
}
SMD::ErrorCode ChollaMesh::get_ids ( size_t  num,
const SMD::SMDNode  nodes[],
int  ids[] 
)

Definition at line 40 of file ChollaMesh.cpp.

{
  for(size_t i=0; i<num; i++)
  {
    ids[i] = convert_to_point(nodes[i])->id();
  }
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_ids ( size_t  num,
const SMD::SMDElement  elems[],
int  ids[] 
)

Definition at line 49 of file ChollaMesh.cpp.

{
  CubitFacet* tri;
  CubitFacetEdge* edge;

  for(size_t i=0; i<num; i++)
  {
    FacetEntity* f = convert_to_facet(elems[i]);
    if((tri = dynamic_cast<CubitFacet*>(f)))
    {
      ids[i] = tri->id();
    }
    else if((edge = dynamic_cast<CubitFacetEdge*>(f)))
    {
      ids[i] = edge->id();
    }
    else
    {
      ids[i] = 0;
    }
  }
  return SMD::STATUS_OK;
}
SMD::ErrorCode ChollaMesh::get_node_handle ( int  id,
SMD::SMDNode &  node 
)

Definition at line 74 of file ChollaMesh.cpp.

{
  return SMD::ERR_NOT_IMPLEMENTED;
}
SMD::ErrorCode ChollaMesh::reverse_element_connectivity ( SMD::SMDElement  element)

Definition at line 363 of file ChollaMesh.cpp.

{
  FacetEntity* f = convert_to_facet(element);
  CubitFacet* tri;
  CubitFacetEdge* edge;

  if((tri = dynamic_cast<CubitFacet*>(f)))
  {
    tri->flip();
    return SMD::STATUS_OK;
  }
  else if((edge = dynamic_cast<CubitFacetEdge*>(f)))
  {
    edge->flip();
    return SMD::STATUS_OK;
  }
  return SMD::ERR_INVALID_ENTITY_HANDLE;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines