cgma
GroupingEntity Class Reference

#include <GroupingEntity.hpp>

Inheritance diagram for GroupingEntity:
TopologyEntity Body Chain Loop Shell

List of all members.

Public Member Functions

 GroupingEntity ()
virtual ~GroupingEntity ()
SenseEntityget_first_sense_entity_ptr ()
SenseEntityget_last_sense_entity_ptr ()
CubitStatus get_sense_entity_list (DLIList< SenseEntity * > &list)
CubitStatus set_sense_entity_list (DLIList< SenseEntity * > &list, DLIList< SenseEntity * > &removed)
GroupingEntitynext ()
GroupingEntityprevious ()
BasicTopologyEntityget_basic_topology_entity_ptr ()
CubitStatus add_sense_entity (SenseEntity *sense_entity_ptr, SenseEntity *after_this=0)
CubitStatus remove_sense_entity (SenseEntity *sense_entity_ptr)
void reverse_direction ()
virtual int get_parents (DLIList< TopologyEntity * > *list=0) const
virtual int get_children (DLIList< TopologyEntity * > *list=0) const

Protected Member Functions

virtual CubitBoolean query_append_parents (DLIList< TopologyEntity * > &list)
virtual CubitBoolean query_append_children (DLIList< TopologyEntity * > &list)
virtual CubitStatus remove_child_link (TopologyEntity *child_ptr)
CubitStatus disconnect_all_children (DLIList< TopologyEntity * > *children=0)
CubitStatus disconnect_all_parents (DLIList< TopologyEntity * > *parents=0)

Private Member Functions

CubitStatus remove_from_list ()
void set_basic_topology_entity_ptr (BasicTopologyEntity *)
CubitStatus insert_after (GroupingEntity *next)
CubitStatus insert_before (GroupingEntity *prev)
 GroupingEntity (const GroupingEntity &)
void operator= (const GroupingEntity &)

Private Attributes

BasicTopologyEntitymyParent
GroupingEntitynextInParent
GroupingEntityprevInParent
SenseEntityfirstSenseEntity
SenseEntitylastSenseEntity

Friends

class BasicTopologyEntity

Detailed Description

Definition at line 52 of file GroupingEntity.hpp.


Constructor & Destructor Documentation


Member Function Documentation

CubitStatus GroupingEntity::add_sense_entity ( SenseEntity sense_entity_ptr,
SenseEntity after_this = 0 
)

Definition at line 92 of file GroupingEntity.cpp.

{
    // Check to make sure that we are getting the correct type of 
    // SenseEntity.
  if ( dag_type() != sense_entity->dag_type().parent() )
     return CUBIT_FAILURE ;
   
    // Check that the sense entity is not already in some other
    // grouping entity
  if ( sense_entity->get_grouping_entity_ptr() )
    return CUBIT_FAILURE;
  
    // prev and next ptrs should be NULL if sense entity is not
    // in a grouping entity
  assert (!sense_entity->next() && !sense_entity->previous());
  
  if (after_this)
  {
    if (after_this->get_grouping_entity_ptr() != this )
      return CUBIT_FAILURE;
  
    if (!sense_entity->gpe_insert_after(after_this))
      return CUBIT_FAILURE;
      
    if (after_this == lastSenseEntity)
      lastSenseEntity = sense_entity;
  }
  else if (lastSenseEntity)
  {
    if (!sense_entity->gpe_insert_after(lastSenseEntity))
      return CUBIT_FAILURE;
    lastSenseEntity = sense_entity;
  }
  else
  {
    firstSenseEntity = lastSenseEntity = sense_entity;
  }
  
  sense_entity->set_grouping_entity_ptr(this);
  return CUBIT_SUCCESS;
}
CubitStatus GroupingEntity::disconnect_all_children ( DLIList< TopologyEntity * > *  children = 0) [protected, virtual]

Implements TopologyEntity.

Definition at line 401 of file GroupingEntity.cpp.

{
  while (firstSenseEntity)
  {
    if (list)
      list->append(firstSenseEntity);
    if (!remove_sense_entity(firstSenseEntity))
      return CUBIT_FAILURE;
  }
  return CUBIT_SUCCESS;
}
CubitStatus GroupingEntity::disconnect_all_parents ( DLIList< TopologyEntity * > *  parents = 0) [protected, virtual]

Implements TopologyEntity.

Definition at line 383 of file GroupingEntity.cpp.

{
  if (!myParent)
    return CUBIT_SUCCESS;
  if (list) 
    list->append(myParent);
  return myParent->remove_grouping_entity(this);
}
int GroupingEntity::get_children ( DLIList< TopologyEntity * > *  list = 0) const [virtual]

Implements TopologyEntity.

Definition at line 335 of file GroupingEntity.cpp.

{
  if (!firstSenseEntity)
    return 0;
  
  int count = 0;
  for (SenseEntity* ptr = firstSenseEntity; ptr; ptr = ptr->next() )
  {
    assert(ptr->get_grouping_entity_ptr() == this);
    if(list)
      list->append(ptr);
    count++;
  }
  
  return count;
}

Definition at line 174 of file GroupingEntity.hpp.

  { return firstSenseEntity; }

Definition at line 177 of file GroupingEntity.hpp.

  { return lastSenseEntity; }
int GroupingEntity::get_parents ( DLIList< TopologyEntity * > *  list = 0) const [virtual]

Implements TopologyEntity.

Definition at line 315 of file GroupingEntity.cpp.

{
  if (!myParent)
    return 0;
  
  if (list)
    list->append(myParent);
  
  return 1;
}

Definition at line 63 of file GroupingEntity.cpp.

{
  if (!firstSenseEntity)
    return CUBIT_SUCCESS;
  
  for (SenseEntity* ptr = firstSenseEntity; ptr; ptr = ptr->next())
  {
    assert(ptr->get_grouping_entity_ptr() == this);
    list.append(ptr);
  }
  return CUBIT_SUCCESS;
}

Definition at line 199 of file GroupingEntity.hpp.

{
  prevInParent = next_ptr;
  nextInParent = next_ptr->nextInParent;
  if (nextInParent)
    nextInParent->prevInParent = this;
  next_ptr->nextInParent = this;
  return CUBIT_SUCCESS;
}

Definition at line 209 of file GroupingEntity.hpp.

{
  nextInParent = prev_ptr;
  prevInParent = prev_ptr->prevInParent;
  if (prevInParent)
    prevInParent->nextInParent = this;
  prev_ptr->prevInParent = this;
  return CUBIT_SUCCESS;
}

Definition at line 180 of file GroupingEntity.hpp.

  { return nextInParent; }
void GroupingEntity::operator= ( const GroupingEntity ) [private]

Definition at line 183 of file GroupingEntity.hpp.

  { return prevInParent; }

Implements TopologyEntity.

Definition at line 432 of file GroupingEntity.cpp.

{
  ModelQueryEngine *const mqe = ModelQueryEngine::instance();
  CubitBoolean found_some = CUBIT_FALSE;
  
  if (!firstSenseEntity)
    return CUBIT_FALSE;
  
  for (SenseEntity* ptr = firstSenseEntity; ptr; ptr = ptr->next())
  {
    if (!mqe->encountered(ptr))
    {
      list.append(ptr);
      found_some = CUBIT_TRUE;
    }
  }
    
  return found_some;
}

Implements TopologyEntity.

Definition at line 422 of file GroupingEntity.cpp.

{
  if (myParent && !ModelQueryEngine::instance()->encountered(myParent))
  {
    list.append(myParent);
    return CUBIT_TRUE;
  }
  
  return CUBIT_FALSE;
}
CubitStatus GroupingEntity::remove_child_link ( TopologyEntity child_ptr) [protected, virtual]

Implements TopologyEntity.

Definition at line 365 of file GroupingEntity.cpp.

{
  SenseEntity* se = dynamic_cast<SenseEntity*>(child_ptr);
  if (!se)
    return CUBIT_FAILURE;
  
  return remove_sense_entity(se);
}

Definition at line 145 of file GroupingEntity.cpp.

{
  if (sense_entity_ptr->get_grouping_entity_ptr() != this)
    return CUBIT_FAILURE;
  
  if (firstSenseEntity == sense_entity_ptr)
    firstSenseEntity = sense_entity_ptr->next();
  if (lastSenseEntity == sense_entity_ptr)
    lastSenseEntity = sense_entity_ptr->previous();
  
  sense_entity_ptr->gpe_remove();
  sense_entity_ptr->set_grouping_entity_ptr(NULL);
  return CUBIT_SUCCESS;
}

Definition at line 283 of file GroupingEntity.cpp.

{
  SenseEntity* ptr;
  if (!firstSenseEntity)
    return;
  
    // For each child sense entity
  for (ptr = firstSenseEntity; ptr; ptr = ptr->previous())
  {
      // change linked list pointers
    ptr->swap_gpe_list_ptrs();
      // change sense
    ptr->reverse_sense();
  }
  
    // Change first pointer the old last entity
    // (Preserves order as returnd by old DLIList rep and 
    //  makes this work to reverse a chain.)
  ptr = firstSenseEntity;
  firstSenseEntity = lastSenseEntity;
  lastSenseEntity = ptr;
}

Definition at line 219 of file GroupingEntity.hpp.

{
  assert(!myParent || !bte_ptr);
  myParent = bte_ptr;
}

Definition at line 169 of file GroupingEntity.cpp.

{
  int i;
  
    // Remove all?
  if (list.size() == 0)
  {
    get_sense_entity_list( removed );
    return disconnect_all_children();
  }
  
    // Check for error conditions before modifying anything
  list.reset();
  for (i = list.size(); i--; )
  {
    SenseEntity* sense_entity = list.get_and_step();
    
      // Check to make sure that we are getting the correct type of 
      // SenseEntity.
    if ( dag_type() != sense_entity->dag_type().parent() )
       return CUBIT_FAILURE ;
   
      // Check that the sense entity is not already in some other
      // grouping entity
    if ( sense_entity->get_grouping_entity_ptr() &&
         sense_entity->get_grouping_entity_ptr() != this )
      return CUBIT_FAILURE;
  }

    // Special case for first entity in list.
  list.reset();
  SenseEntity* new_first = list.get_and_step();
    // No sense entities currently attached...
  if (!firstSenseEntity)
  {
    firstSenseEntity = lastSenseEntity = new_first;
    new_first->set_grouping_entity_ptr(this);
  }
    // Already attached, but not first in list...
  else if( firstSenseEntity != new_first )
  {
    if (!new_first->get_grouping_entity_ptr())
      new_first->set_grouping_entity_ptr(this);
    else
    {
      if (lastSenseEntity == new_first)
        lastSenseEntity = new_first->previous();
      new_first->gpe_remove();
    }
      
    new_first->gpe_insert_before(firstSenseEntity);
    firstSenseEntity = new_first;
  }
  
    // Now loop through remaining sense entities.
  SenseEntity* prev = new_first;
  for (i = list.size() - 1; i--; )
  {
    SenseEntity* curr = list.get_and_step();

      // If next sense entity in input list is not
      // next sense entity in this GroupingEntity...
    if (prev->next() != curr)
    {
      if (!curr->get_grouping_entity_ptr())
        curr->set_grouping_entity_ptr(this);
      else
      {
        if (lastSenseEntity == curr)
          lastSenseEntity = curr->previous();
        curr->gpe_remove();
      }
      curr->gpe_insert_after(prev);
    }
    
      // update lastSenseEntity if necessary...
    if (lastSenseEntity == prev)
      lastSenseEntity = curr;
      
      // iterate
    prev = curr;
  }
  
    // Disconnect any sense entities in this GroupingEntity
    // that were not in in the input list (they should now
    // be at the end of the list of sense entities in this)
    // and pass them back in the 'removed' list.
  CubitStatus result = CUBIT_SUCCESS;
  while (prev != lastSenseEntity)
  {
    removed.append(prev->next());
    if (!remove_sense_entity(prev->next()))
    {
      assert(0);
      result = CUBIT_FAILURE;
      prev = prev->next();
    }
  }
  
  return result;
}

Friends And Related Function Documentation

friend class BasicTopologyEntity [friend]

Definition at line 145 of file GroupingEntity.hpp.


Member Data Documentation

Definition at line 154 of file GroupingEntity.hpp.

Definition at line 155 of file GroupingEntity.hpp.

Definition at line 151 of file GroupingEntity.hpp.

Definition at line 152 of file GroupingEntity.hpp.

Definition at line 153 of file GroupingEntity.hpp.


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