cgma
|
#include <RefGroup.hpp>
Public Member Functions | |
virtual const char * | class_name () const |
int | maximum_dimension () |
virtual const std::type_info & | entity_type_info () const |
Returns the type info of this enity. | |
DagType | dag_type () const |
Returns the dag type of this enity. | |
virtual CubitStatus | add_ref_entity (RefEntity *ref_entity, bool emit_event=false) |
virtual CubitStatus | add_ref_entity (DLIList< RefEntity * > &entity_list, bool emit_event=false) |
virtual CubitStatus | remove_ref_entity (RefEntity *ref_entity, bool emit_event=false) |
virtual CubitStatus | remove_ref_entity (DLIList< RefEntity * > &entity_list, bool emit_event=false) |
virtual void | get_sub_entities (DLIList< RefEntity * > &entity_list) |
virtual void | is_mergeable (AutoMergeStatus val) |
Setting auto merge status flag. | |
bool | is_mergeable () |
Query to see if entity is free to merge. | |
int | remove_all_ref_entities () |
virtual void | get_parent_ref_entities (DLIList< RefEntity * > &) |
virtual void | get_child_ref_entities (DLIList< RefEntity * > &entity_list) |
RefEntity * | get_child_ref_entity_by_index (const std::type_info &entity_type, int index) |
int | get_num_child_ref_entities_by_type (const std::type_info &entity_type) |
virtual void | get_child_entities (DLIList< CubitEntity * > &cub_entity_list) |
void | expand_group (DLIList< RefEntity * > &entity_list) |
virtual CubitBox | bounding_box () |
virtual CubitVector | center_point () |
Return the approximate (spatial) center of this RefEntity. | |
int | subtract (RefGroup *group_to_subtract, RefGroup *target_group) |
int | intersect (RefGroup *other_group, RefGroup *target_group) |
int | unite (RefGroup *other_group, RefGroup *target_group) |
virtual int | validate () |
Perform checks to see if entity valid. | |
void | notify_observer (const CubitEvent *observer_event) |
Static Public Member Functions | |
static const char * | get_class_name () |
static CubitStatus | delete_group (RefGroup *group_ptr, CubitBoolean propagate=CUBIT_FALSE) |
static void | delete_all_groups () |
static void | get_contained_groups (RefGroup *group_ptr, DLIList< RefGroup * > &contained_groups) |
static void | get_groups_within (CubitEntity *cubit_entity_ptr, DLIList< RefGroup * > &groups_within, const CubitBoolean recursive=CUBIT_TRUE) |
static void | get_groups_within (RefEntity *ref_entity_ptr, DLIList< RefGroup * > &groups_within, const CubitBoolean recursive=CUBIT_TRUE) |
static void | get_groups_within (RefGroup *ref_group_ptr, DLIList< RefGroup * > &groups_within, const CubitBoolean recursive=CUBIT_TRUE) |
Protected Member Functions | |
virtual | ~RefGroup () |
RefGroup (int proe_type) | |
RefGroup (const char *name=NULL, int id=0) | |
RefGroup (DLIList< RefEntity * > &entity_list) | |
Protected Attributes | |
DLIList< RefEntity * > | entityList |
int | recursionMark |
Friends | |
class | RefEntityFactory |
class | TDCAGE |
Definition at line 24 of file RefGroup.hpp.
RefGroup::~RefGroup | ( | ) | [protected, virtual] |
Definition at line 65 of file RefGroup.cpp.
{ remove_all_ref_entities(); }
RefGroup::RefGroup | ( | int | proe_type | ) | [protected] |
Definition at line 58 of file RefGroup.cpp.
{ // This constructor was created just to get around not doing a notify, // so we can use it for Pro/E parts and assemblies. recursionMark = 0; }
RefGroup::RefGroup | ( | const char * | name = NULL , |
int | id = 0 |
||
) | [protected] |
Definition at line 17 of file RefGroup.cpp.
{ recursionMark = 0; if( id == 0 ) entityId = RefEntityFactory::instance()->next_ref_group_id(); else entityId = id; // assign default names assign_default_name(); if (name != NULL) entity_name( name ); }
RefGroup::RefGroup | ( | DLIList< RefEntity * > & | entity_list | ) | [protected] |
Definition at line 33 of file RefGroup.cpp.
{ recursionMark = 0; //entityList = entity_list; int i; for ( i = entity_list.size(); i > 0; i-- ) { RefEntity *ent_ptr = entity_list.get_and_step(); if ( !entityList.move_to(ent_ptr) ) entityList.append(ent_ptr); } entityList.reset(); for (i=entityList.size(); i > 0; i--) register_observable(entityList.get_and_step()); entityId = RefEntityFactory::instance()->next_ref_group_id(); // Notify Model about the creation of this object AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED, this)) ; // assign default names assign_default_name(); }
CubitStatus RefGroup::add_ref_entity | ( | RefEntity * | ref_entity, |
bool | emit_event = false |
||
) | [virtual] |
Definition at line 70 of file RefGroup.cpp.
{ CubitStatus status = CUBIT_FAILURE; // Force failure of commands like: group 3 add group 3 if ( ( ref_entity->entity_type_info() == entity_type_info() ) && ( ref_entity->entity_name() == entity_name() ) ) return CUBIT_FAILURE; if (!entityList.move_to(ref_entity)) { entityList.append(ref_entity); register_observable(ref_entity); status = CUBIT_SUCCESS; if (emit_event) AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GROUP_MODIFIED, this)); } return status; }
CubitStatus RefGroup::add_ref_entity | ( | DLIList< RefEntity * > & | entity_list, |
bool | emit_event = false |
||
) | [virtual] |
Definition at line 90 of file RefGroup.cpp.
{ RefEntity* entity = NULL; CubitStatus status = CUBIT_FAILURE; for (int i=entity_list.size(); i > 0; i--) { entity = entity_list.get_and_step(); if ( entityList.move_to(entity) == CUBIT_FALSE ) { entityList.append(entity); register_observable(entity); status = CUBIT_SUCCESS; } } if (emit_event && status == CUBIT_SUCCESS) AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GROUP_MODIFIED, this)); return status; }
CubitBox RefGroup::bounding_box | ( | void | ) | [virtual] |
Implements CubitEntity.
Definition at line 274 of file RefGroup.cpp.
{ recursionMark = 1; CubitBox super_box = CubitBox(); int super_box_defined = CUBIT_FALSE; for (int i = entityList.size(); i > 0; i--) { RefEntity *entity = entityList.get_and_step(); RefGroup *group = CAST_TO(entity, RefGroup); if (!group || group->recursionMark == 0) { CubitBox entity_box = entity->bounding_box(); // "Concatenate" this box with the super_box, creating a bounding // box that bounds the entities (from the list), processed so far. if (super_box_defined) super_box |= entity_box; else { super_box = entity_box; super_box_defined = CUBIT_TRUE; } } } recursionMark = 0; return super_box; }
CubitVector RefGroup::center_point | ( | ) | [virtual] |
Return the approximate (spatial) center of this RefEntity.
Reimplemented from RefEntity.
Definition at line 348 of file RefGroup.cpp.
{ return bounding_box().center(); }
virtual const char* RefGroup::class_name | ( | ) | const [inline, virtual] |
DagType RefGroup::dag_type | ( | ) | const [inline, virtual] |
Returns the dag type of this enity.
Implements RefEntity.
Definition at line 60 of file RefGroup.hpp.
{ return DagType::invalid_type(); }
void RefGroup::delete_all_groups | ( | ) | [static] |
Definition at line 474 of file RefGroup.cpp.
{ DLIList<RefGroup*> ref_groups; GeometryQueryTool::instance()->ref_groups(ref_groups); int num_groups = ref_groups.size(); for( int i=0; i<num_groups; i++ ) delete_group( ref_groups.get_and_step() ); }
CubitStatus RefGroup::delete_group | ( | RefGroup * | group_ptr, |
CubitBoolean | propagate = CUBIT_FALSE |
||
) | [static] |
Definition at line 451 of file RefGroup.cpp.
{ // This function will delete the corresponding group from the Model // If propagate is CUBIT_TRUE, the contained groups are deleted also. AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_ENTITY_DESTRUCTED, group_ptr)); if( propagate ) { DLIList<RefGroup*> contained_groups; get_contained_groups ( group_ptr, contained_groups ); for( int i=0; i<contained_groups.size(); i++ ) { delete_group( contained_groups.get_and_step(), false ); } } group_ptr->remove_all_ref_entities(); delete group_ptr; return CUBIT_SUCCESS; }
virtual const std::type_info& RefGroup::entity_type_info | ( | ) | const [inline, virtual] |
Returns the type info of this enity.
Implements RefEntity.
Definition at line 56 of file RefGroup.hpp.
{ return typeid(RefGroup); }
void RefGroup::expand_group | ( | DLIList< RefEntity * > & | entity_list | ) |
Definition at line 199 of file RefGroup.cpp.
{ //This function will get the list of child entities for this group and //if there are any groups in its child list, it will call this fucntion //again on those groups. The end result should be that the returned //list does not contain groups... just basic_topology entities //(the other ref_entities) DLIList<RefEntity*> group_list, mixed_list; RefEntity *ref_entity_ptr; RefGroup *group; mixed_list.append( this ); // don't swap the upper and lower bounds on ii. for ( int ii = 0; ii < mixed_list.size(); ii++ ) { //Note, the list gets added to, so don't do a simple get_and_step mixed_list.reset(); mixed_list.step(ii); ref_entity_ptr = mixed_list.get(); group = CAST_TO( ref_entity_ptr, RefGroup ); if (group) { // avoid infinite recursion of groups A and B containing each other if (!group_list.move_to(group)) { group->get_child_ref_entities(mixed_list); group_list.append(group); } } // In the future if we have other RefEntities that are grouping // entities then we should have another statement here... else entity_list.append( ref_entity_ptr ); } return; }
void RefGroup::get_child_entities | ( | DLIList< CubitEntity * > & | cub_entity_list | ) | [virtual] |
Definition at line 194 of file RefGroup.cpp.
{ cub_entity_list.casting_merge_unique(entityList, CUBIT_TRUE); }
void RefGroup::get_child_ref_entities | ( | DLIList< RefEntity * > & | entity_list | ) | [virtual] |
Appends all immediate (child) RefEntities owned by this RefEntity to entity_list. (The query goes down just one dimension.)
Reimplemented from RefEntity.
Definition at line 156 of file RefGroup.cpp.
{ entityList.reset(); entity_list.merge_unique(entityList, CUBIT_TRUE ); }
RefEntity * RefGroup::get_child_ref_entity_by_index | ( | const std::type_info & | entity_type, |
int | index | ||
) |
Definition at line 175 of file RefGroup.cpp.
{ RefEntity *entity = NULL; int size = entityList.size(); int type_index = 0; for(int i=0; i<size && !entity; i++) { RefEntity *cur_ent = entityList[i]; if(cur_ent->entity_type_info() == entity_type) { if(type_index == index) entity = cur_ent; else type_index++; } } return entity; }
static const char* RefGroup::get_class_name | ( | ) | [inline, static] |
Definition at line 41 of file RefGroup.hpp.
{ return "Group"; }
void RefGroup::get_contained_groups | ( | RefGroup * | group_ptr, |
DLIList< RefGroup * > & | contained_groups | ||
) | [static] |
Definition at line 484 of file RefGroup.cpp.
{ DLIList<RefEntity*> group_list, mixed_list; RefEntity *ref_entity_ptr; RefGroup *group; mixed_list.append( group_ptr ); // Using expand_group algorithm to get sub_groups of group_ptr // don't swap the upper and lower bounds on ii. for ( int ii = 0; ii < mixed_list.size(); ii++ ) { // Note, the list gets added to, so don't do a simple get_and_step mixed_list.reset(); mixed_list.step(ii); ref_entity_ptr = mixed_list.get(); group = CAST_TO( ref_entity_ptr, RefGroup ); //which it should be the first time around if (group) { // avoid infinite recursion of groups A and B containing each other if (!group_list.move_to(group)) { group->get_child_ref_entities(mixed_list); group_list.append(group); } } } CAST_LIST(group_list, contained_groups, RefGroup); }
void RefGroup::get_groups_within | ( | CubitEntity * | cubit_entity_ptr, |
DLIList< RefGroup * > & | groups_within, | ||
const CubitBoolean | recursive = CUBIT_TRUE |
||
) | [static] |
Definition at line 514 of file RefGroup.cpp.
{ RefEntity* ref_entity_ptr = CAST_TO( cubit_entity_ptr, RefEntity ); if( ref_entity_ptr != NULL ) { get_groups_within( ref_entity_ptr, groups_within, recursive); return; } return; }
void RefGroup::get_groups_within | ( | RefEntity * | ref_entity_ptr, |
DLIList< RefGroup * > & | groups_within, | ||
const CubitBoolean | recursive = CUBIT_TRUE |
||
) | [static] |
Definition at line 528 of file RefGroup.cpp.
{ RefGroup* ref_group_ptr; // Get the observer's of this entity DLIList <CubitObserver*> observer_list; ref_entity_ptr->get_observer_list( observer_list ); // Now, loop through the observer list, adding them for (int i=0; i<observer_list.size(); i++) { ref_group_ptr = CAST_TO (observer_list.get(), RefGroup); if( ref_group_ptr != NULL ) { // Add this observer groups_within.append_unique( ref_group_ptr ); // Add all the groups the observer is within if (recursive) get_groups_within( ref_group_ptr, groups_within ); } observer_list.step(); } }
void RefGroup::get_groups_within | ( | RefGroup * | ref_group_ptr, |
DLIList< RefGroup * > & | groups_within, | ||
const CubitBoolean | recursive = CUBIT_TRUE |
||
) | [static] |
Definition at line 559 of file RefGroup.cpp.
{ // Get the model's groups DLIList<RefGroup*> model_group_list; GeometryQueryTool::instance()->ref_groups(model_group_list); int i, j; RefGroup* model_group; RefGroup* contained_group; // Go through all the groups, finding which ones contain // the entity, at any level below (checks groups within // groups). for( i=0; i<model_group_list.size(); i++ ) { model_group = model_group_list.get_and_step(); // See if it exists directly in model_group DLIList<RefEntity*> contained_ref_entities; model_group->get_child_ref_entities( contained_ref_entities ); if( contained_ref_entities.move_to( (RefEntity*)ref_group_ptr ) ) groups_within.append_unique( model_group ); if (!recursive) continue; // Now check all of model group's contained groups DLIList<RefGroup*> contained_group_list; model_group->get_contained_groups( model_group, contained_group_list ); contained_group_list.remove( model_group ); for( j=0; j<contained_group_list.size(); j++ ) { contained_group = contained_group_list.get_and_step(); contained_ref_entities.clean_out(); contained_group->get_child_ref_entities( contained_ref_entities ); if( contained_ref_entities.move_to( (RefEntity*)ref_group_ptr ) ) groups_within.append_unique( model_group ); } } }
int RefGroup::get_num_child_ref_entities_by_type | ( | const std::type_info & | entity_type | ) |
Definition at line 162 of file RefGroup.cpp.
{ int count = 0; int size = entityList.size(); for(int i=0; i<size; i++) { RefEntity *cur_ent = entityList[i]; if(cur_ent->entity_type_info() == entity_type) count++; } return count; }
void RefGroup::get_parent_ref_entities | ( | DLIList< RefEntity * > & | entity_list | ) | [virtual] |
Appends all RefEntities that own this (parent RefEntities) to entity_list. (The query goes up just one dimension. For example, if this is a vertex, the resulting list contains only RefEdges).
Implements RefEntity.
Definition at line 237 of file RefGroup.cpp.
{ //- appends all ref entities that own this to entity_list. //- Goes up just one dimension. // There is nothing above us. Do nothing }
void RefGroup::get_sub_entities | ( | DLIList< RefEntity * > & | entity_list | ) | [virtual] |
Definition at line 303 of file RefGroup.cpp.
{ recursionMark = 1; //- appends all ref entities owned by this entity on entity_list //- and recurses all the way down to dimension 0 DLIList<RefEntity*> local_entity_list; get_child_ref_entities(local_entity_list); // *need* to merge now if a group // else more efficient to merge later entity_list.merge_unique(local_entity_list, CUBIT_TRUE); DLIList<RefEntity*> temp_list, temp_list2; for (int i=local_entity_list.size(); i > 0; i--) { // take some care to avoid infinite recursion RefEntity *child = local_entity_list.get_and_step(); RefGroup *group = CAST_TO(child, RefGroup); if (!group || group->recursionMark == 0) { temp_list2.clean_out(); child->get_all_child_ref_entities(temp_list2); temp_list.merge_unique(temp_list2); } } entity_list.merge_unique(temp_list); recursionMark = 0; }
int RefGroup::intersect | ( | RefGroup * | other_group, |
RefGroup * | target_group | ||
) |
Definition at line 378 of file RefGroup.cpp.
{ // Get the list of RefEntities associated with each group DLIList<RefEntity*> entity_list_1; DLIList<RefEntity*> entity_list_2; get_child_ref_entities(entity_list_1); other_group->get_child_ref_entities(entity_list_2); DLIList<RefEntity*> final_list; // At this point, we have three groups, all non-null. Note that // some or all of these may be the same group, so don't destroy // the target group until all information is generated. // Final = all items in both group 1 and group 2. for (int i=entity_list_2.size(); i > 0; i--) { RefEntity *entity = entity_list_2.get_and_step(); if (entity_list_1.move_to(entity)) { final_list.append_unique(entity); } } target_group->remove_all_ref_entities(); target_group->add_ref_entity(final_list); return CUBIT_SUCCESS; }
void RefGroup::is_mergeable | ( | AutoMergeStatus | val | ) | [virtual] |
Setting auto merge status flag.
Reimplemented from RefEntity.
Definition at line 333 of file RefGroup.cpp.
{ recursionMark = 1; autoMergeStatus = val; DLIList<RefEntity*> children; get_child_ref_entities( children ); for ( int i = children.size(); i > 0; i-- ) { RefEntity *child = children.get_and_step(); RefGroup *group = CAST_TO(child, RefGroup); if (!group || group->recursionMark == 0) child->is_mergeable(val); } recursionMark = 0; }
bool RefGroup::is_mergeable | ( | ) | [inline] |
Query to see if entity is free to merge.
Reimplemented from RefEntity.
Definition at line 77 of file RefGroup.hpp.
{ return RefEntity::is_mergeable(); }
int RefGroup::maximum_dimension | ( | ) |
Definition at line 244 of file RefGroup.cpp.
{ recursionMark = 1; // This routine returns the maximum dimension of its owned subentities. // The 'only' kludge is that if one of its subentities is a RefGroup, it // must call 'maximum_dimension' on that entity instead of dimension(). RefEntity *entity; int test_dim = 0; int dimension = 0; for (int i = entityList.size(); i > 0; i--) { entity = entityList.get_and_step(); RefGroup* group; if ( (group = CAST_TO(entity,RefGroup) ) != NULL ) { if (group->recursionMark == 0) test_dim = group->maximum_dimension(); } else { test_dim = entity->dimension(); } dimension = CUBIT_MAX(dimension, test_dim); } recursionMark = 0; return dimension; }
void RefGroup::notify_observer | ( | const CubitEvent * | observer_event | ) | [virtual] |
Implements CubitObserver.
Definition at line 602 of file RefGroup.cpp.
{ const GeometryEvent* geom_event = dynamic_cast<const GeometryEvent*>(observer_event); if (geom_event != NULL) { RefEntity *entity = geom_event->get_entity(); int event = geom_event->get_type(); if (event == GeometryEvent::TOPOLOGY_ENTITY_CONSTRUCTED) { add_ref_entity(entity); return; } else if (event ==GeometryEvent:: TOPOLOGY_ENTITY_DESTRUCTED) { remove_ref_entity(entity); return; } else if ( event == GeometryEvent::ENTITIES_MERGED ) { // Out with the old... remove_ref_entity(entity); // ...in with the new. const MergeEvent *merge_event = static_cast<const MergeEvent*>(geom_event); RefEntity *kept_entity = CAST_TO( merge_event->get_kept_entity(), RefEntity ); add_ref_entity(kept_entity); } } return; }
Definition at line 146 of file RefGroup.cpp.
{ int num_entities = entityList.size(); for (int i=entityList.size(); i > 0; i--) { unregister_observable(entityList.get_and_step()); } entityList.clean_out(); return num_entities; }
CubitStatus RefGroup::remove_ref_entity | ( | RefEntity * | ref_entity, |
bool | emit_event = false |
||
) | [virtual] |
Definition at line 112 of file RefGroup.cpp.
{ CubitStatus status = CUBIT_FAILURE; if (entityList.remove(entity)) { unregister_observable(entity); status = CUBIT_SUCCESS; if (emit_event) AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GROUP_MODIFIED, this)); } return status; }
CubitStatus RefGroup::remove_ref_entity | ( | DLIList< RefEntity * > & | entity_list, |
bool | emit_event = false |
||
) | [virtual] |
Definition at line 125 of file RefGroup.cpp.
{ int i; RefEntity *entity; CubitStatus status = CUBIT_FAILURE; for (i = entity_list.size(); i > 0; i--) { entity = entity_list.get_and_step(); if (entityList.remove(entity)) { unregister_observable(entity); status = CUBIT_SUCCESS; } } if (emit_event && status == CUBIT_SUCCESS) AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::GROUP_MODIFIED, this)); return status; }
int RefGroup::subtract | ( | RefGroup * | group_to_subtract, |
RefGroup * | target_group | ||
) |
Definition at line 352 of file RefGroup.cpp.
{ // Get the list of RefEntities associated with each group DLIList<RefEntity*> final_list; DLIList<RefEntity*> entity_list_2; get_child_ref_entities(final_list); group_to_subtract->get_child_ref_entities(entity_list_2); // At this point, we have three groups, all non-null. Note that // some or all of these may be the same group, so don't destroy // the target group until all information is generated. // 1. Final = group 2 // 2. Remove from final all items that are in both final and group 1 for (int i=entity_list_2.size(); i > 0; i--) { RefEntity *entity = entity_list_2.get_and_step(); final_list.remove(entity); } target_group->remove_all_ref_entities(); target_group->add_ref_entity(final_list); return CUBIT_SUCCESS; }
int RefGroup::unite | ( | RefGroup * | other_group, |
RefGroup * | target_group | ||
) |
Definition at line 407 of file RefGroup.cpp.
{ // Get the list of RefEntities associated with each group DLIList<RefEntity*> final_list; DLIList<RefEntity*> entity_list_2; get_child_ref_entities(final_list); other_group->get_child_ref_entities(entity_list_2); // At this point, we have three groups, all non-null. Note that // some or all of these may be the same group, so don't destroy // the target group until all information is generated. // 1. Final = group 1 // 2. Add all items that are in group 2, but not already in group 1 for (int i=entity_list_2.size(); i > 0; i--) { RefEntity *entity = entity_list_2.get_and_step(); final_list.append_unique(entity); } target_group->remove_all_ref_entities(); target_group->add_ref_entity(final_list); return CUBIT_SUCCESS; }
int RefGroup::validate | ( | ) | [virtual] |
Perform checks to see if entity valid.
Reimplemented from RefEntity.
Definition at line 433 of file RefGroup.cpp.
{ // NOTE: RefGroup::validate() should not call RefEntity::validate() // directly since the contained entities will make that // call in their respective validate() functions. recursionMark = 1; int error = 0; for (int i = entityList.size(); i > 0; i--) { RefEntity *entity = entityList.get_and_step(); RefGroup *group = CAST_TO(entity, RefGroup); if (!group || group->recursionMark == 0) error += entity->validate(); } recursionMark = 0; return error; }
friend class RefEntityFactory [friend] |
Definition at line 30 of file RefGroup.hpp.
friend class TDCAGE [friend] |
Definition at line 33 of file RefGroup.hpp.
DLIList<RefEntity*> RefGroup::entityList [protected] |
Definition at line 156 of file RefGroup.hpp.
int RefGroup::recursionMark [protected] |
Definition at line 158 of file RefGroup.hpp.