cgma
CompositeBody Class Reference

#include <CompositeBody.hpp>

Inheritance diagram for CompositeBody:
BodySM TBOwner TopologyBridge

List of all members.

Public Member Functions

 CompositeBody ()
 ~CompositeBody ()
CompositeLumpnext_lump (CompositeLump *after_this=0) const
CubitStatus add (CompositeLump *lump)
CubitStatus remove (CompositeLump *lump)
int num_bodies () const
BodySMget_body (int index) const
int index_of (BodySM *body) const
CubitStatus add (BodySM *body)
CubitStatus remove (BodySM *body)
CubitStatus remove_body (int index)
CubitStatus get_transforms (CubitTransformMatrix &tfm)
void get_parents_virt (DLIList< TopologyBridge * > &parents)
void get_children_virt (DLIList< TopologyBridge * > &children)
int layer () const
GeometryQueryEngineget_geometry_query_engine () const
virtual void append_simple_attribute_virt (const CubitSimpleAttrib &simple_attrib_ptr)
virtual void remove_simple_attribute_virt (const CubitSimpleAttrib &simple_attrib_ptr)
virtual void remove_all_simple_attribute_virt ()
virtual CubitStatus get_simple_attribute (DLIList< CubitSimpleAttrib > &attrib_list)
virtual CubitStatus get_simple_attribute (const CubitString &name, DLIList< CubitSimpleAttrib > &attrib_list)
CubitStatus remove_bridge (TopologyBridge *bridge)
CubitStatus swap_bridge (TopologyBridge *old_tb, TopologyBridge *new_tb, bool reversed)
CubitBoolean contains_bridge (TopologyBridge *bridge) const
void notify_reversed (TopologyBridge *bridge)
CubitPointContainment point_containment (const CubitVector &pos, double tolerance=-1.0)
CubitStatus mass_properties (CubitVector &centroid, double &volume)
void combine (CompositeBody *other)

Private Attributes

CompositeLumpfirstLump
VGArray< BodySM * > realBodies

Detailed Description

Definition at line 23 of file CompositeBody.hpp.


Constructor & Destructor Documentation

Definition at line 19 of file CompositeBody.cpp.

  : firstLump(0)
{
}

Definition at line 24 of file CompositeBody.cpp.

{
  int i;
  
  for( i = 0; i < realBodies.size(); i++ )
    if( realBodies[i]->owner() == this )
      realBodies[i]->owner(0);
  
  while( firstLump )
    remove( firstLump );
}

Member Function Documentation

Definition at line 42 of file CompositeBody.cpp.

{
  if( lump->myBody != 0 )
    return CUBIT_FAILURE;
    
  lump->myBody = this;
  lump->nextLump = firstLump;
  firstLump = lump;
  return CUBIT_SUCCESS;
}

Definition at line 77 of file CompositeBody.cpp.

{
  if( index_of( body ) >= 0  )
    return CUBIT_FAILURE;
    
  if( body->owner() )
    body->owner()->swap_bridge( body, this, false );
  body->owner(this);
  
  realBodies.push( body );
  return CUBIT_SUCCESS;
}
void CompositeBody::append_simple_attribute_virt ( const CubitSimpleAttrib simple_attrib_ptr) [virtual]

Implements TopologyBridge.

Definition at line 271 of file CompositeBody.cpp.

{ }

Definition at line 364 of file CompositeBody.cpp.

{
  int oldsize = realBodies.size();
  realBodies.size( oldsize + other->realBodies.size() );
  for (int i = 0; i < other->realBodies.size(); i++)
  {
    BodySM* bod = other->realBodies[i];
    realBodies[i+oldsize] = bod;
    bod->owner(this);
  }
  other->realBodies.size(0);
}

Reimplemented from TBOwner.

Definition at line 254 of file CompositeBody.cpp.

{
  return index_of(dynamic_cast<BodySM*>(bridge)) < 0 ? CUBIT_FALSE : CUBIT_TRUE;
}
BodySM * CompositeBody::get_body ( int  index) const [inline]

Definition at line 88 of file CompositeBody.hpp.

  { return realBodies[index]; }
void CompositeBody::get_children_virt ( DLIList< TopologyBridge * > &  children) [virtual]

Implements TopologyBridge.

Definition at line 194 of file CompositeBody.cpp.

{
  for( CompositeLump* lump = firstLump; lump; lump = lump->nextLump )
    children.append( lump );
}

Implements TopologyBridge.

Definition at line 210 of file CompositeBody.cpp.

void CompositeBody::get_parents_virt ( DLIList< TopologyBridge * > &  parents) [virtual]

Implements TopologyBridge.

Definition at line 191 of file CompositeBody.cpp.

  { }

Implements TopologyBridge.

Definition at line 277 of file CompositeBody.cpp.

{ return CUBIT_FAILURE; }
CubitStatus CompositeBody::get_simple_attribute ( const CubitString name,
DLIList< CubitSimpleAttrib > &  attrib_list 
) [virtual]

Implements TopologyBridge.

Definition at line 279 of file CompositeBody.cpp.

{ return CUBIT_FAILURE; }

Implements BodySM.

Definition at line 188 of file CompositeBody.cpp.

  { return CUBIT_FAILURE; }
int CompositeBody::index_of ( BodySM body) const [inline]

Definition at line 91 of file CompositeBody.hpp.

  { return realBodies.find( body ); }
int CompositeBody::layer ( ) const [inline, virtual]

Reimplemented from TopologyBridge.

Definition at line 55 of file CompositeBody.hpp.

{ return COMPOSITE_LAYER; }
CubitStatus CompositeBody::mass_properties ( CubitVector centroid,
double &  volume 
) [virtual]

Implements BodySM.

Definition at line 333 of file CompositeBody.cpp.

{
  double vol;
  CubitVector centroid;
  result.set( 0.0, 0.0, 0.0 );
  volume = 0;
  
  for (int i = 0; i < realBodies.size(); ++i)
  {
    if (CUBIT_FAILURE == realBodies[i]->mass_properties( centroid, vol ))
      return CUBIT_FAILURE;
    
    result += vol * centroid;
    volume += vol;
  }
  
  if (volume > CUBIT_RESABS)
    result /= volume;
  return CUBIT_SUCCESS;
}
CompositeLump * CompositeBody::next_lump ( CompositeLump after_this = 0) const

Definition at line 37 of file CompositeBody.cpp.

{
  return prev ? prev->nextLump : firstLump;
}
void CompositeBody::notify_reversed ( TopologyBridge bridge) [virtual]

Implements TBOwner.

Definition at line 259 of file CompositeBody.cpp.

  { assert(0); }
int CompositeBody::num_bodies ( ) const [inline]

Definition at line 85 of file CompositeBody.hpp.

  { return realBodies.size(); }
CubitPointContainment CompositeBody::point_containment ( const CubitVector pos,
double  tolerance = -1.0 
) [virtual]

Implements BodySM.

Definition at line 292 of file CompositeBody.cpp.

{
  int inside = 0;
  int boundary = 0;
  
  for (int i = 0; i < realBodies.size(); ++i)
  {
    switch( realBodies[i]->point_containment( pos, tolerance ) )
    {
      case CUBIT_PNT_BOUNDARY:
        boundary++;
        break;
      case CUBIT_PNT_INSIDE:
        inside++;
        break;
      case CUBIT_PNT_OUTSIDE:
        break;
      default:
        return CUBIT_PNT_UNKNOWN;
    }
  }
  
  if (inside)
    return CUBIT_PNT_INSIDE;
  else if (boundary > 1)
    return CUBIT_PNT_INSIDE;
  else if (boundary)
    return CUBIT_PNT_BOUNDARY;
  else
    return CUBIT_PNT_OUTSIDE;
}

Definition at line 53 of file CompositeBody.cpp.

{
  if( lump->myBody != this )
    return CUBIT_FAILURE;
  
  if( firstLump == lump )
  {
    firstLump = lump->nextLump;
  }
  else
  {
    CompositeLump* prev = firstLump; 
    while( prev && prev->nextLump != lump )
      prev = prev->nextLump;
    assert( prev != NULL );
    
    prev->nextLump = lump->nextLump;
  }
  
  lump->myBody = 0;
  lump->nextLump = 0;
  return CUBIT_SUCCESS;
}

Definition at line 90 of file CompositeBody.cpp.

  { return remove_body( index_of( body ) ); }

Implements TopologyBridge.

Definition at line 275 of file CompositeBody.cpp.

{ }

Definition at line 93 of file CompositeBody.cpp.

{
  if( index < 0 ) return CUBIT_FAILURE;
  
  if( realBodies[index]->owner() == this )
    realBodies[index]->owner(0);
  realBodies.remove(index);
  return CUBIT_SUCCESS;
}

Implements TBOwner.

Definition at line 214 of file CompositeBody.cpp.

{
  int i;
  for (i = realBodies.size() - 1; i >= 0 && realBodies[i] != bridge; --i);
  if (i < 0)
    return CUBIT_FAILURE;
  
  assert( bridge->owner() == this );
  bridge->owner( 0 );
  realBodies.remove( i );
  
  if (realBodies.size() == 0)
    CompositeEngine::instance().notify_deactivated( this );
  
  return CUBIT_SUCCESS;
}
void CompositeBody::remove_simple_attribute_virt ( const CubitSimpleAttrib simple_attrib_ptr) [virtual]

Implements TopologyBridge.

Definition at line 273 of file CompositeBody.cpp.

{ }
CubitStatus CompositeBody::swap_bridge ( TopologyBridge old_tb,
TopologyBridge new_tb,
bool  reversed 
) [virtual]

Implements TBOwner.

Definition at line 232 of file CompositeBody.cpp.

{
  if( new_tb->owner() )
    return CUBIT_FAILURE;
  
  BodySM* new_body = dynamic_cast<BodySM*>(new_tb);
  BodySM* old_body = dynamic_cast<BodySM*>(old_tb);
  int index = realBodies.find( old_body );
  if( index >= 0 && new_body != 0 && realBodies.find(new_body) < 0 )
  {
    if( old_body->owner() == this )
      old_body->owner(0);
    new_body->owner(this);
    realBodies[index] = new_body;
    return CUBIT_SUCCESS;
  }
  
  return CUBIT_FAILURE;
}

Member Data Documentation

Definition at line 80 of file CompositeBody.hpp.

Definition at line 81 of file CompositeBody.hpp.


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