cgma
PartitionBody Class Reference

#include <PartitionBody.hpp>

Inheritance diagram for PartitionBody:
BodySM PartitionEntity TopologyBridge

List of all members.

Public Member Functions

 PartitionBody (BodySM *)
 ~PartitionBody ()
CubitStatus get_transforms (CubitTransformMatrix &)
CubitStatus mass_properties (CubitVector &centroid, double &volume)
CubitPointContainment point_containment (const CubitVector &pos, double tolerance=-1.0)
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 &name, DLIList< CubitSimpleAttrib > &)
virtual int layer () const
void get_parents_virt (DLIList< TopologyBridge * > &)
void get_children_virt (DLIList< TopologyBridge * > &)
GeometryQueryEngineget_geometry_query_engine () const
void reverse_sense ()
void notify_split (FacetEntity *, FacetEntity *)
CubitStatus save (CubitSimpleAttrib &)
CubitBox bounding_box () const
BodySMreal_body () const
void add (SubEntitySet &)
void remove (SubEntitySet &)
bool has_children () const
void destroy_all_children ()
void transform (const CubitTransformMatrix &)
void get_all_children (DLIList< PartitionEntity * > &list)

Private Attributes

SubEntitySetchildList

Detailed Description

Definition at line 23 of file PartitionBody.hpp.


Constructor & Destructor Documentation

Definition at line 33 of file PartitionBody.cpp.

  : childList(0)
{ 
  SubEntitySet* set = new SubEntitySet( body,this ); 
  set->bodyNext = 0;
  set->bodyPtr = this;
}

Definition at line 51 of file PartitionBody.cpp.

{ 
  assert(! sub_entity_set().bodyNext);
  sub_entity_set().bodyPtr = 0;
  
  while( SubEntitySet* dead = childList )
  {
    childList = dead->bodyNext;
    dead->bodyNext = 0;
    dead->bodyPtr = 0;
  }
}

Member Function Documentation

Definition at line 195 of file PartitionBody.cpp.

{
  assert(!set.bodyPtr);
  set.bodyPtr = this;
  set.bodyNext = childList;
  childList = &set;
}

Implements TopologyBridge.

Definition at line 87 of file PartitionBody.cpp.

CubitBox PartitionBody::bounding_box ( void  ) const [virtual]

Implements PartitionEntity.

Definition at line 160 of file PartitionBody.cpp.

{
  DLIList<TopologyBridge*> lumps;
  real_body()->get_children_virt(lumps);
  
  CubitBox result = dynamic_cast<Lump*>(lumps.step_and_get())->bounding_box();
  for( int i = 1; i < lumps.size(); i++ )
    result |= dynamic_cast<Lump*>(lumps.step_and_get())->bounding_box();
  
  return result;
}

Definition at line 243 of file PartitionBody.cpp.

{
  DLIList<PartitionLump*> lumps;
  DLIList<PartitionSurface*> surfs;
  DLIList<PartitionCoEdge*> coedges;
  DLIList<PartitionCurve*> curves;
  DLIList<PartitionPoint*> points;
  
  DLIList<PartitionEntity*> sub_geom, split_geom;
  for ( SubEntitySet* ptr = childList; ptr; ptr = ptr->next_in_body() )
  {
    ptr->get_sub_entities( sub_geom );
    ptr->get_lower_order( split_geom );
    sub_geom += split_geom;
    split_geom.clean_out();
    while( sub_geom.size() )
    { 
      PartitionEntity* ent = sub_geom.pop();
      if ( PartitionPoint* point = dynamic_cast<PartitionPoint*>(ent) )
        points.append(point);
      else if( PartitionCoEdge* coedge = dynamic_cast<PartitionCoEdge*>(ent) )
        coedges.append(coedge);
      else if( PartitionCurve* curve = dynamic_cast<PartitionCurve*>(ent) )
        curves.append(curve);
      else if( PartitionSurface* surf = dynamic_cast<PartitionSurface*>(ent) )
        surfs.append(surf);
      else if ( PartitionLump* lump = dynamic_cast<PartitionLump*>(ent) )
        lumps.append(lump);
      else
        assert(0);
    }
  }
  
  while( lumps.size() )
  {
    PartitionLump* lump = lumps.pop();
    while( PartitionShell* shell = lump->first_shell() )
    {
      lump->remove(shell);
      shell->remove_all_surfaces();
      delete shell;
    }
    delete lump;
  }

  while( surfs.size() )
  {
    PartitionSurface* surf = surfs.pop();
    while( PartitionLoop* loop = surf->next_loop(NULL) )
    {
      surf->remove(loop);
      loop->remove_all_coedges();
      delete loop;
    }
    delete surf;
  }

  while( coedges.size() )
  {
    PartitionCoEdge* coedge = coedges.pop();
    if (coedge->get_curve() != NULL)
       coedge->get_curve()->remove( coedge );
    delete coedge;
  }

  while( curves.size() )
  {
    PartitionCurve* curve = curves.pop();
    assert( !curve->next_coedge(NULL) );
    delete curve;
  }

  while( points.size() )
  {
    PartitionPoint* point = points.pop();
    assert( !point->num_curves() );
    delete point;
  }

  // All child SubEntitySets should have been deleted when they
  // became empty, and should be removed from the list in this
  // body as they are destroyed.  However, when the last SubEntitySet
  // in this body is destroyed, this body will be destroyed as well.
  // So don't do this check!
  //assert(!childList);
}

Definition at line 433 of file PartitionBody.cpp.

{
  DLIList<PartitionEntity*> tmp;
  for (SubEntitySet* ptr = childList; ptr; ptr = ptr->bodyNext )
  {
    tmp.clean_out();
    ptr->get_sub_entities( tmp );
    list += tmp;
    
    tmp.clean_out();
    ptr->get_lower_order( tmp );
    list += tmp;
  }
}
void PartitionBody::get_children_virt ( DLIList< TopologyBridge * > &  list) [virtual]

Implements TopologyBridge.

Definition at line 122 of file PartitionBody.cpp.

Implements TopologyBridge.

Definition at line 134 of file PartitionBody.cpp.

Implements TopologyBridge.

Definition at line 120 of file PartitionBody.cpp.

  { }

Implements TopologyBridge.

Definition at line 93 of file PartitionBody.cpp.

  { return real_body()->get_simple_attribute(list); }

Implements TopologyBridge.

Definition at line 95 of file PartitionBody.cpp.

  { return real_body()->get_simple_attribute(name,list); }

Implements BodySM.

Definition at line 73 of file PartitionBody.cpp.

{
  return real_body()->get_transforms( xforms );
}
bool PartitionBody::has_children ( ) const [inline]

Definition at line 96 of file PartitionBody.hpp.

{ return !!childList; } 
int PartitionBody::layer ( ) const [virtual]

Reimplemented from TopologyBridge.

Definition at line 108 of file PartitionBody.cpp.

CubitStatus PartitionBody::mass_properties ( CubitVector centroid,
double &  volume 
) [virtual]

Implements BodySM.

Definition at line 339 of file PartitionBody.cpp.

{
  DLIList<Lump*> lump_list;
  lumps( lump_list );
  
  DLIList<PartitionLump*> part_list;
  CAST_LIST( lump_list, part_list, PartitionLump );
  if (part_list.size() < lump_list.size())
    return real_body()->mass_properties( result, volume );
  
  CubitVector centroid(0.0, 0.0, 0.0), tmp_centroid;
  volume = 0.0;
  double tmp_volume;
  for (int i = part_list.size(); i--; )
  {
    if (CUBIT_FAILURE == 
        part_list.get_and_step()->mass_properties( tmp_centroid, tmp_volume ))
      return CUBIT_FAILURE;
    
    centroid += tmp_volume * tmp_centroid;
    volume += tmp_volume;
  }
  
  if (volume > CUBIT_RESABS)
  {
    result = centroid / volume;
  }
  else
  {
    result.set( 0.0, 0.0, 0.0 );
    volume = 0.0;
  }
  return CUBIT_SUCCESS;
}
void PartitionBody::notify_split ( FacetEntity ,
FacetEntity  
) [virtual]

Implements PartitionEntity.

Definition at line 147 of file PartitionBody.cpp.

{ assert(0); }
CubitPointContainment PartitionBody::point_containment ( const CubitVector pos,
double  tolerance = -1.0 
) [virtual]

Implements BodySM.

Definition at line 383 of file PartitionBody.cpp.

{
  DLIList<Lump*> lump_list;
  lumps( lump_list );
  
  DLIList<PartitionLump*> part_list;
  CAST_LIST( lump_list, part_list, PartitionLump );
  
  if (part_list.size() < lump_list.size())
  {
    return real_body()->point_containment( pos, tolerance );
  }
  
  bool inside = false, on = false;
  part_list.reset();
  for (int i = part_list.size(); i--; )
  {
    switch( part_list.get_and_step()->point_containment( pos ) )
    {
      case CUBIT_PNT_INSIDE:
        inside = true;
        break;
      case CUBIT_PNT_BOUNDARY:
        on = true;
        break;
      case CUBIT_PNT_OUTSIDE:
        break;
      default:
        return CUBIT_PNT_UNKNOWN;
    }
  }
  
  if (inside)
    return CUBIT_PNT_INSIDE;
  else if(on)
    return CUBIT_PNT_BOUNDARY;
  else
    return CUBIT_PNT_OUTSIDE; 
}

Definition at line 182 of file PartitionBody.cpp.

  { return dynamic_cast<BodySM*>(partitioned_entity()); }

Definition at line 212 of file PartitionBody.cpp.

{
  assert(set.bodyPtr == this);
  if( childList == &set )
  {
    childList = set.bodyNext;
  }
  else
  {
    SubEntitySet* ptr = childList;
    while( ptr->bodyNext != &set )
    {
      ptr = ptr->bodyNext;
      assert(!!ptr);
    }
    ptr->bodyNext = set.bodyNext;
  }
  set.bodyNext = 0;
  set.bodyPtr = 0;
}

Implements TopologyBridge.

Definition at line 89 of file PartitionBody.cpp.

void PartitionBody::reverse_sense ( ) [virtual]

Implements PartitionEntity.

Definition at line 146 of file PartitionBody.cpp.

{ assert(0); }

Implements PartitionEntity.

Definition at line 148 of file PartitionBody.cpp.

{ return CUBIT_FAILURE; }
void PartitionBody::transform ( const CubitTransformMatrix ) [inline, virtual]

Implements PartitionEntity.

Definition at line 100 of file PartitionBody.hpp.

{}

Member Data Documentation

Definition at line 108 of file PartitionBody.hpp.


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