cgma
PartitionShell Class Reference

#include <PartitionShell.hpp>

Inheritance diagram for PartitionShell:
ShellSM TopologyBridge

List of all members.

Public Member Functions

 PartitionShell ()
virtual ~PartitionShell ()
PartitionLumpget_lump () const
PartitionCoSurfnext_co_surface (const PartitionCoSurf *prev=0) const
CubitStatus add (PartitionCoSurf *cosurf)
CubitStatus remove (PartitionCoSurf *cosurf)
PartitionCoSurfadd (PartitionSurface *surf, CubitSense sense)
PartitionCoSurffind_first (const PartitionSurface *surface) const
PartitionCoSurffind_next (const PartitionCoSurf *cosurf) const
CubitSense find_sense (const PartitionSurface *surface) const
void remove_all_surfaces (DLIList< PartitionSurface * > *removed=0)
void get_parents_virt (DLIList< TopologyBridge * > &parents)
void get_children_virt (DLIList< TopologyBridge * > &children)
int layer () const
GeometryQueryEngineget_geometry_query_engine () const
void append_simple_attribute_virt (const CubitSimpleAttrib &)
void remove_simple_attribute_virt (const CubitSimpleAttrib &)
void remove_all_simple_attribute_virt ()
CubitStatus get_simple_attribute (DLIList< CubitSimpleAttrib > &)
CubitStatus get_simple_attribute (const CubitString &, DLIList< CubitSimpleAttrib > &)
void print_debug_info (const char *prefix=0) const
CubitPointContainment point_containment (const CubitVector &pt)
bool is_nonmanifold (PartitionSurface *surface) const
CubitStatus mass_properties (CubitVector &centroid, double &volume)

Private Attributes

PartitionLumpmyLump
PartitionShelllumpNext
PartitionCoSurffirstCoSurf

Friends

class PartitionLump

Detailed Description

Definition at line 11 of file PartitionShell.hpp.


Constructor & Destructor Documentation

Definition at line 7 of file PartitionShell.cpp.

  : myLump(0), lumpNext(0), firstCoSurf(0)
  { }

Definition at line 11 of file PartitionShell.cpp.

{
  assert( !myLump );
  remove_all_surfaces();
}

Member Function Documentation

Definition at line 17 of file PartitionShell.cpp.

{
  if( cosurf->myShell || cosurf->shellNext )
  {
    assert(!cosurf->myShell && !cosurf->shellNext);
    return CUBIT_FAILURE;
  }
  
  cosurf->myShell = this;
  cosurf->shellNext = firstCoSurf;
  firstCoSurf = cosurf;
  return CUBIT_SUCCESS;
}

Definition at line 60 of file PartitionShell.cpp.

{
  PartitionCoSurf* new_cos = new PartitionCoSurf( sense );
  if( !surf->add(new_cos) || !this->add(new_cos) )
  {
    delete new_cos;
    new_cos = 0;
  }
  return new_cos;
}

Implements TopologyBridge.

Definition at line 141 of file PartitionShell.cpp.

  { }

Definition at line 71 of file PartitionShell.cpp.

{
  PartitionCoSurf* cos = firstCoSurf;
  while( cos && cos->get_surface() != surf )
    cos = cos->shellNext;
  return cos;
}

Definition at line 78 of file PartitionShell.cpp.

{
  PartitionCoSurf* cos = prev->shellNext;
  while( cos && cos->get_surface() != prev->get_surface() )
    cos = cos->shellNext;
  return cos;
}

Definition at line 85 of file PartitionShell.cpp.

{
  PartitionCoSurf* cos = find_first( surf );
  if( ! cos )
    return CUBIT_UNKNOWN;
  
  CubitSense result = cos->sense();
  while( (cos = find_next( cos )) )
    if( cos->sense() != result )
      return CUBIT_UNKNOWN;
  
  return result;
}
void PartitionShell::get_children_virt ( DLIList< TopologyBridge * > &  children) [virtual]

Implements TopologyBridge.

Definition at line 126 of file PartitionShell.cpp.

{
  PartitionCoSurf* cos = 0;
  while( (cos = next_co_surface( cos )) )
    if( cos->get_surface() )
      children.append_unique( cos->get_surface() );
}

Implements TopologyBridge.

Definition at line 136 of file PartitionShell.cpp.

Definition at line 65 of file PartitionShell.hpp.

  { return myLump; }
void PartitionShell::get_parents_virt ( DLIList< TopologyBridge * > &  parents) [virtual]

Implements TopologyBridge.

Definition at line 120 of file PartitionShell.cpp.

{
  if( myLump )
    parents.append( myLump );
}

Implements TopologyBridge.

Definition at line 147 of file PartitionShell.cpp.

  { return CUBIT_FAILURE; }

Implements TopologyBridge.

Definition at line 149 of file PartitionShell.cpp.

{ return CUBIT_FAILURE; }

Definition at line 221 of file PartitionShell.cpp.

{
  int count = 0;
  PartitionCoSurf* cosurf = 0;
  while ((cosurf = surf->next_co_surface( cosurf )))
    if (cosurf->get_shell() == this)
      count++;
  
  return count != 1;
}
int PartitionShell::layer ( ) const [virtual]

Reimplemented from TopologyBridge.

Definition at line 134 of file PartitionShell.cpp.

{ return get_lump()->layer(); }
CubitStatus PartitionShell::mass_properties ( CubitVector centroid,
double &  volume 
)

Definition at line 232 of file PartitionShell.cpp.

{
  PartitionCoSurf* cosurf = 0;
  DLIList<CubitFacetData*> facets;
  CubitVector p1, p2, p3, normal;
  const CubitVector p0(0.0, 0.0, 0.0);
  centroid.set(0.0, 0.0, 0.0 );
  volume = 0.0;
  
  while ((cosurf = next_co_surface( cosurf )))
  {
    if (is_nonmanifold( cosurf->get_surface() ))
      continue;
    
    facets.clean_out();
    cosurf->get_surface()->get_facet_data( facets );
    
    for (int i = facets.size(); i--; )
    {
      CubitFacet* facet = facets.step_and_get();
      p1 = facet->point(0)->coordinates();
      p2 = facet->point(1)->coordinates();
      p3 = facet->point(2)->coordinates();
      normal = (p3 - p1) * (p2 - p1);
  
      double two_area = normal.length();
      if (two_area > CUBIT_RESABS )
      {
        if (cosurf->sense() == CUBIT_REVERSED)
          normal = -normal;
        
        normal /= two_area;
        
        double height = normal % (p0 - p1);
        double vol = two_area * height;
        
        volume += vol;
        centroid += vol * (p0 + p1 + p2 + p3);
      }
    }
  }
  
  if (volume > CUBIT_RESABS)
    centroid /= 4.0 * volume;
  volume /= 6.0;
  return CUBIT_SUCCESS;
}
PartitionCoSurf * PartitionShell::next_co_surface ( const PartitionCoSurf prev = 0) const [inline]

Definition at line 69 of file PartitionShell.hpp.

  { return !prev ? firstCoSurf : prev->myShell == this ? prev->shellNext : 0; }

Definition at line 166 of file PartitionShell.cpp.

{
    // Find closest cosurface to passed point
  PartitionCoSurf* cosurf = 0;
  PartitionCoSurf* closest = 0;
  double dist_to_closest = CUBIT_DBL_MAX;
  CubitVector pt_on_surface;
  while( (cosurf = next_co_surface(cosurf)) )
  {
    PartitionSurface* surf = cosurf->get_surface();
    
      // Ignore surfaces that occur more than once in the 
      // shell.
    bool skip = false;
    PartitionCoSurf* surf_cosurf = 0;
    while( (surf_cosurf = surf->next_co_surface(surf_cosurf)) )
    {
      if( surf_cosurf->get_shell() == this && surf_cosurf != cosurf )
      {
        skip = true;
        break;
      }
    }
    
    if( skip )
      continue;
    
    surf->closest_point_trimmed( pt, pt_on_surface );
    double dist_sqr = (pt - pt_on_surface).length_squared();
    if( dist_sqr < dist_to_closest )
    {
      closest = cosurf;
      dist_to_closest = dist_sqr;
    }
  }
  
  if( !closest )
    return CUBIT_PNT_UNKNOWN;  // already printed error messages above
  
  if( dist_to_closest < (GEOMETRY_RESABS*GEOMETRY_RESABS) ) // point is on shell
    return CUBIT_PNT_BOUNDARY;
  
  CubitVector normal;
  closest->get_surface()->closest_point_trimmed( pt, pt_on_surface );
  closest->get_surface()->closest_point( pt_on_surface, 0, &normal );
  if( closest->sense() == CUBIT_REVERSED )
    normal *= -1.0;
  
  pt_on_surface -= pt;
  if ( pt_on_surface.length_squared() < GEOMETRY_RESABS*GEOMETRY_RESABS )
    return CUBIT_PNT_BOUNDARY;
  
  return (normal % pt_on_surface) > 0.0 ? CUBIT_PNT_INSIDE : CUBIT_PNT_OUTSIDE;
}
void PartitionShell::print_debug_info ( const char *  prefix = 0) const

Definition at line 153 of file PartitionShell.cpp.

{
}

Definition at line 31 of file PartitionShell.cpp.

{
  if( cosurf->myShell != this )
  {
    assert( cosurf->myShell == this );
    return CUBIT_FAILURE;
  }
  
  if( cosurf == firstCoSurf )
  {
    firstCoSurf->shellNext = cosurf->shellNext;
    firstCoSurf = firstCoSurf->shellNext;
  }
  else
  {
    PartitionCoSurf* prev = firstCoSurf;
    while( prev && prev->shellNext != cosurf )
      prev = prev->shellNext;
    
    if( !prev ) { assert(0); return CUBIT_FAILURE; }
  
    prev->shellNext = cosurf->shellNext;
  }
  
  cosurf->myShell = 0;
  cosurf->shellNext = 0;
  return CUBIT_SUCCESS;
}

Implements TopologyBridge.

Definition at line 145 of file PartitionShell.cpp.

  { }

Definition at line 102 of file PartitionShell.cpp.

{
  while( PartitionCoSurf* cosurf = firstCoSurf )
  {
    if( cosurf->get_surface() )
    {
      if( list ) 
        list->append( cosurf->get_surface() );
      cosurf->get_surface()->remove( cosurf );
    }
    remove( cosurf );
    delete cosurf;
  }
  
  if( list )
    list->uniquify_ordered();
}

Implements TopologyBridge.

Definition at line 143 of file PartitionShell.cpp.

  { }

Friends And Related Function Documentation

friend class PartitionLump [friend]

Definition at line 13 of file PartitionShell.hpp.


Member Data Documentation

Definition at line 62 of file PartitionShell.hpp.

Definition at line 60 of file PartitionShell.hpp.

Definition at line 59 of file PartitionShell.hpp.


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