|
cgma
|
#include <CompositeGeom.hpp>
Definition at line 41 of file CompositeGeom.hpp.
| CompositeGeom::CompositeGeom | ( | int | size = 0 | ) |
Definition at line 39 of file CompositeGeom.cpp.
: entityList(size), currentIndex(0), firstIndex(-1), needToUpdateBbox( true ), needToUpdateMeasure( true ), listHead(0) { // initialization above both allocated space for size // entities, and set the current count in the list to // size. We want the initial memory, but need to set // the count back to zero. entityList.size(0); }
Definition at line 63 of file CompositeGeom.cpp.
| CompositeGeom::CompositeGeom | ( | const CompositeGeom & | ) | [private] |
| void CompositeGeom::add_attribute | ( | const CubitSimpleAttrib & | csa | ) |
Definition at line 569 of file CompositeGeom.cpp.
{
if (entityList.size() == 1)
entityList[0].entity->append_simple_attribute_virt(csa);
else
listHead = new CompositeAttrib( csa, listHead );
}
| CubitStatus CompositeGeom::append | ( | GeometryEntity * | geom_ptr, |
| CubitSense | sense | ||
| ) | [inline] |
Definition at line 62 of file CompositeGeom.hpp.
{ return insert( entityList.size(), geom_ptr, sense ); }
| CubitBox CompositeGeom::bounding_box | ( | void | ) |
Definition at line 286 of file CompositeGeom.cpp.
{
if( entityList.size() == 0 )
{
return CubitBox();
}
if( needToUpdateBbox )
update_data_bbox();
CubitBox box( entityList[0].bbox );
for( int i = 1; i < entityList.size(); i++ )
box |= entityList[i].bbox;
return box;
}
| void CompositeGeom::clean_up_attribs | ( | GeometryEntity * | ent | ) | [static, private] |
Definition at line 960 of file CompositeGeom.cpp.
{
DLIList<CubitSimpleAttrib> list;
ent->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
while (list.size())
{
CubitSimpleAttrib csa = list.pop();
ent->remove_simple_attribute_virt(csa);
}
}
| int CompositeGeom::closest_box | ( | const CubitVector & | position | ) |
Definition at line 372 of file CompositeGeom.cpp.
{
if( entityList.size() <= 0 ) return -1;
if( needToUpdateBbox ) update_data_bbox();
int min_index = 0;
double min_dist = entityList[0].dist_sqr
= entityList[0].bbox.distance_squared( position );
for( int i = 1; i < entityList.size(); i++ )
{
CompositeEntry& ent = entityList[i];
double dist_sqr = ent.dist_sqr = ent.bbox.distance_squared( position );
if( dist_sqr < min_dist )
min_index = i;
}
firstIndex = -1;
currentIndex = min_index;
return currentIndex;
}
| GeometryEntity * CompositeGeom::entity | ( | int | index | ) | const [inline] |
Definition at line 119 of file CompositeGeom.hpp.
{
return entityList[index].entity;
}
| void CompositeGeom::get_attributes | ( | DLIList< CubitSimpleAttrib > & | list | ) |
Definition at line 649 of file CompositeGeom.cpp.
{
// special case: single-entity 'composite'
if (entityList.size() == 1)
{
TopologyBridge* entity = entityList[0].entity;
entity->get_simple_attribute(list);
// handle 8.1 attribs on single-entity 'composites'
for (int i = list.size(); i--; )
{
const CubitSimpleAttrib& attrib = list.step_and_get();
if (attrib.character_type() == COMPOSITE_DATA_ATTRIB_NAME &&
attrib.int_data_list()[0] == 1)
{
entity->remove_simple_attribute_virt(attrib);
CubitSimpleAttrib newattrib = attrib;
newattrib.string_data_list().erase(newattrib.string_data_list().begin());
newattrib.int_data_list().erase(newattrib.int_data_list().begin());
entity->append_simple_attribute_virt(newattrib);
}
}
}
for (CompositeAttrib* ptr = listHead; ptr; ptr = ptr->next)
list.append(ptr->csa());
}
| void CompositeGeom::get_attributes | ( | const char * | name, |
| DLIList< CubitSimpleAttrib > & | list | ||
| ) |
Definition at line 687 of file CompositeGeom.cpp.
{
if (entityList.size() == 1)
{
// handle 8.1 attribs on single-entity 'composites'
list.clean_out();
entityList[0].entity->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
while (list.size())
{
CubitSimpleAttrib attrib = list.pop();
if (attrib.int_data_list()[0] == 1)
{
entityList[0].entity->remove_simple_attribute_virt(attrib);
std::vector<CubitString> s(attrib.string_data_list().begin()+1, attrib.string_data_list().end());
std::vector<int> i(attrib.int_data_list().begin()+1, attrib.int_data_list().end());
CubitSimpleAttrib new_attrib(&s, &attrib.double_data_list(), &i);
entityList[0].entity->append_simple_attribute_virt(new_attrib);
}
}
entityList[0].entity->get_simple_attribute(name, list);
}
for (CompositeAttrib* ptr = listHead; ptr; ptr = ptr->next)
if (ptr->name() == name)
list.append(ptr->csa());
}
| int CompositeGeom::index_of | ( | TopologyBridge * | geom_ptr | ) | const |
Definition at line 82 of file CompositeGeom.cpp.
{
int i;
for( i = entityList.size() - 1; i >= 0; i-- )
if( entityList[i].entity == ptr )
break;
return i;
}
| CubitStatus CompositeGeom::insert | ( | int | index, |
| GeometryEntity * | geom_ptr, | ||
| CubitSense | sense | ||
| ) |
Definition at line 101 of file CompositeGeom.cpp.
{
if( index < 0 )
{
assert( index >= 0 );
index = 0;
}
else if( index > entityList.size() )
{
assert( index <= entityList.size() );
index = entityList.size();
}
CompositeEntry ent;
ent.entity = geom_ptr;
ent.sense = sense;
ent.dist_sqr = ent.measure = 0.;
//force 0th surface to be one that has the composite attrib on it.
DLIList<CubitSimpleAttrib> list;
geom_ptr->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
if( list.size() )
index = 0;
entityList.insert( ent, index );
update_cached_data();
return CUBIT_SUCCESS;
}
| double CompositeGeom::measure | ( | int | index | ) | [inline] |
Definition at line 129 of file CompositeGeom.hpp.
{
if( needToUpdateMeasure )
update_data_measure();
return entityList[index].measure;
}
| double CompositeGeom::measure | ( | ) |
Definition at line 311 of file CompositeGeom.cpp.
{
if( entityList.size() == 0 )
return 0.0;
if( needToUpdateMeasure )
update_data_measure();
return entityList[entityList.size()-1].measure;
}
| CubitStatus CompositeGeom::merge | ( | CompositeGeom & | dead, |
| bool | prepend = false |
||
| ) |
Definition at line 488 of file CompositeGeom.cpp.
{
int i;
if (entityList.size() == 1)
{
DLIList<CubitSimpleAttrib> list;
entityList[0].entity->get_simple_attribute(list);
list.reset();
for (i = list.size(); i--; )
{
const CubitSimpleAttrib csa = list.get_and_step();
if (csa.character_type() != COMPOSITE_DATA_ATTRIB_NAME)
listHead = new CompositeAttrib(csa, listHead);
}
}
// find EntityName attribute
CompositeAttrib* this_name = listHead;
while (this_name && this_name->name() != "ENTITY_NAME")
this_name = this_name->next;
// merge entity name attributes
CompositeAttrib* dead_name = dead.listHead;
if (dead_name)
{
if (dead_name->name() == "ENTITY_NAME")
{
dead_name = dead.listHead;
dead.listHead = dead_name->next;
dead_name->next = 0;
}
else
{
while(dead_name->next && dead_name->next->name() != "ENTITY_NAME")
dead_name = dead_name->next;
if(dead_name->next)
{
CompositeAttrib* prev = dead_name;
prev->next = dead_name = dead_name->next;
dead_name->next = 0;
}
}
}
int insert ;
if ( prepend )
{
insert = 0;
entityList.size_end( entityList.size() + dead.entityList.size() );
}
else
{
insert = entityList.size();
entityList.size( entityList.size() + dead.entityList.size() );
}
for( i = 0; i < dead.entityList.size(); i++ )
{
entityList[insert].entity = dead.entityList[i].entity;
entityList[insert].sense = dead.entityList[i].sense;
insert++;
}
dead.entityList.size(0);
update_cached_data();
return CUBIT_SUCCESS;
}
| int CompositeGeom::next_box_within_dist | ( | double | dist_squared | ) |
Definition at line 408 of file CompositeGeom.cpp.
{
if( entityList.size() > 0 )
{
if( firstIndex < 0 )
{
firstIndex = currentIndex;
}
else if( firstIndex == currentIndex )
{
return -1;
}
while( (currentIndex = (currentIndex + 1) % entityList.size())
!= firstIndex )
{
if( entityList[currentIndex].dist_sqr < dist_squared )
{
return currentIndex;
}
}
}
return -1;
}
| int CompositeGeom::num_entities | ( | ) | const [inline] |
Definition at line 50 of file CompositeGeom.hpp.
{ return entityList.size(); }
| CompositeGeom& CompositeGeom::operator= | ( | const CompositeGeom & | ) | [private] |
| void CompositeGeom::print_debug_info | ( | const char * | line_prefix = 0 | ) |
Definition at line 725 of file CompositeGeom.cpp.
{
if( needToUpdateBbox )
update_data_bbox();
if( needToUpdateMeasure )
update_data_measure();
if( line_prefix == 0 )
line_prefix = "";
PRINT_INFO("%sCompositeGeom @ %p : \n", line_prefix, (void*)this );
for( int i = 0; i < entityList.size(); i++ )
{
GeometryEntity* ptr = entityList[i].entity;
#ifdef TOPOLOGY_BRIDGE_IDS
PRINT_INFO("%s %15s %d %7s\n", line_prefix,
ptr ? fix_type_name(typeid(*ptr).name()) : "GeometryEntity",
ptr ? ptr->get_id() : 0,
entityList[i].sense == CUBIT_FORWARD ? "Forward" :
entityList[i].sense == CUBIT_REVERSED ? "Reverse" :
"Unknown");
#else
/*
PRINT_INFO("%s %15s %p %7s\n", line_prefix,
ptr ? fix_type_name(typeid(*ptr).name()) : "GeometryEntity",
ptr,
entityList[i].sense == CUBIT_FORWARD ? "Forward" :
entityList[i].sense == CUBIT_REVERSED ? "Reverse" :
"Unknown");
*/
PRINT_INFO("%s %15s %d %7s\n", line_prefix,
ptr ? fix_type_name(typeid(*ptr).name()) : "GeometryEntity",
ptr ? ptr->get_saved_id() : 0,
entityList[i].sense == CUBIT_FORWARD ? "Forward" :
entityList[i].sense == CUBIT_REVERSED ? "Reverse" :
"Unknown");
#endif
}
}
| void CompositeGeom::read_attributes | ( | GeometryEntity * | entity = 0 | ) |
Definition at line 790 of file CompositeGeom.cpp.
{
DLIList<CubitSimpleAttrib> list;
int i;
// remove any attributes from previous read
rem_all_attributes();
if (geom_ptr)
{
// Special case for point-curves (no real curves to write
// attirbutes to.) Write to passed entity instead.
assert(entityList.size() == 0);
geom_ptr->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
list.reset();
for (i = list.size(); i--; )
{
const CubitSimpleAttrib& attrib = list.get_and_step();
assert(attrib.int_data_list().size());
if (attrib.int_data_list()[0] == entityList.size())
{
geom_ptr->remove_simple_attribute_virt(attrib);
CubitSimpleAttrib c = attrib;
c.int_data_list().erase(c.int_data_list().begin());
c.string_data_list().erase(c.string_data_list().begin());
listHead = new CompositeAttrib(c,listHead);
}
}
return;
}
for (i = 0; i < entityList.size(); i++)
{
list.clean_out();
entityList[i].entity->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
list.reset();
for (int j = list.size(); j--; )
{
const CubitSimpleAttrib& attrib = list.get_and_step();
assert(attrib.int_data_list().size());
if (attrib.int_data_list()[0] == entityList.size())
{
// Take the attributes off of the current entity and put them on the first entity
// in this list. I believe this is ok to do because the attributes should apply to
// the whole composite surface and not just the underlying entity they are on
// (the one exception to this might be UNIQUE_ID but I haven't seen any problems
// with this yet). The reason for doing this is that there is some code (I believe
// in uncomposite() that assumes any attributes will be on the first entity
// in the list. Previous code actually moved the entity to the beginning
// of the list but this reordering of the list does not fly with composite
// curves because there is code depending on the curves in the list being
// ordered so that they connect end to end in a contiguous manner (the
// faceting code, for one, relies on this). BWC 1/7/07.
entityList[i].entity->remove_simple_attribute_virt(attrib);
entityList[0].entity->append_simple_attribute_virt(attrib);
CubitSimpleAttrib c = attrib;
c.int_data_list().erase(c.int_data_list().begin());
c.string_data_list().erase(c.string_data_list().begin());
if( NULL == listHead )
listHead = new CompositeAttrib(c,listHead);
else //this assures that we are not adding duplicate attribs
{
bool is_duplicate = false;
CompositeAttrib* curr_attrib = listHead;
while( curr_attrib )
{
if( curr_attrib->equals( c ) )
{
is_duplicate = true;
break;
}
curr_attrib = curr_attrib->next;
}
if( false == is_duplicate )
listHead = new CompositeAttrib(c,listHead);
}
}
}
}
}
| void CompositeGeom::rem_all_attributes | ( | ) |
Definition at line 626 of file CompositeGeom.cpp.
{
while(listHead)
{
CompositeAttrib* dead = listHead;
listHead = listHead->next;
delete dead;
}
if (entityList.size() == 1)
entityList[0].entity->remove_all_simple_attribute_virt();
}
| void CompositeGeom::rem_attribute | ( | const CubitSimpleAttrib & | csa | ) |
Definition at line 586 of file CompositeGeom.cpp.
{
while (listHead && listHead->equals(csa))
{
CompositeAttrib* dead = listHead;
listHead = dead->next;
delete dead;
}
if (listHead)
{
CompositeAttrib* attrib = listHead;
while (attrib->next)
{
if(attrib->next->equals(csa))
{
CompositeAttrib* dead = attrib->next;
attrib->next = dead->next;
delete dead;
}
else
{
attrib = attrib->next;
}
}
}
if (entityList.size() == 1)
entityList[0].entity->remove_simple_attribute_virt(csa);
}
| CubitStatus CompositeGeom::remove | ( | int | index, |
| bool | dead | ||
| ) |
Definition at line 142 of file CompositeGeom.cpp.
{
if( (index < 0) || (index >= entityList.size()) )
{
assert( index >= 0 && index < entityList.size() );
return CUBIT_FAILURE;
}
if (!dead)
clean_up_attribs(entityList[index].entity);
entityList.remove( index );
update_cached_data();
return CUBIT_SUCCESS;
}
Definition at line 443 of file CompositeGeom.cpp.
{
reverse_order();
reverse_rel_senses();
return CUBIT_SUCCESS;
}
Definition at line 449 of file CompositeGeom.cpp.
{
int i, half = entityList.size() / 2;
for( i = 0; i < half; i++ )
{
int j = entityList.size() - (i+1);
GeometryEntity* temp_entity = entityList[i].entity;
entityList[i].entity = entityList[j].entity;
entityList[j].entity = temp_entity;
CubitSense temp_sense = entityList[i].sense;
entityList[i].sense = entityList[j].sense;
entityList[j].sense = temp_sense;
}
update_cached_data();
return CUBIT_SUCCESS;
}
Definition at line 465 of file CompositeGeom.cpp.
{
for( int i = 0; i < entityList.size(); i++ )
{
entityList[i].sense =
entityList[i].sense == CUBIT_FORWARD ? CUBIT_REVERSED :
entityList[i].sense == CUBIT_REVERSED ? CUBIT_FORWARD :
CUBIT_UNKNOWN;
}
return CUBIT_SUCCESS;
}
| void CompositeGeom::reverse_sense | ( | int | index | ) |
Definition at line 774 of file CompositeGeom.cpp.
{
assert(index < entityList.size() );
CubitSense old = entityList[index].sense;
entityList[index].sense = (old == CUBIT_REVERSED) ? CUBIT_FORWARD : CUBIT_REVERSED;
}
| CubitSense CompositeGeom::sense | ( | int | index | ) | const [inline] |
Definition at line 124 of file CompositeGeom.hpp.
{
return entityList[index].sense;
}
| CompositeGeom * CompositeGeom::split | ( | int | index | ) |
Definition at line 170 of file CompositeGeom.cpp.
{
int i;
if( (index < 0) || (index >= entityList.size()) )
{
assert( index >= 0 && index < entityList.size() );
return 0;
}
// find EntityName attribute
CompositeAttrib* name_attrib = listHead;
while (name_attrib && name_attrib->name() != "ENTITY_NAME")
name_attrib = name_attrib->next;
int first = index + 1;
CompositeGeom* new_geom = new CompositeGeom( entityList.size() - first );
for( i = first; i < entityList.size(); i++ )
new_geom->append( entityList[i].entity, entityList[i].sense );
entityList.size( first );
update_cached_data();
// copy entityname attrib to new entity
if ( name_attrib )
{
assert(!new_geom->listHead);
new_geom->listHead = new CompositeAttrib(*name_attrib);
}
return new_geom;
}
| CompositeGeom * CompositeGeom::split | ( | VGArray< int > & | index_array | ) |
Definition at line 202 of file CompositeGeom.cpp.
{
int i, j;
if( index_array.size() == 0 )
return 0;
for( i = 0; i < index_array.size(); i++ )
if( index_array[i] < 0 || index_array[i] >= entityList.size() )
{
assert(0);
return 0;
}
// find EntityName attribute
CompositeAttrib* name_attrib = listHead;
while (name_attrib && name_attrib->name() != "ENTITY_NAME")
name_attrib = name_attrib->next;
CompositeGeom* new_geom = new CompositeGeom( index_array.size() );
for( i = 0; i < index_array.size(); i++ )
{
int index = index_array[i];
assert( entityList[index].entity != NULL );
new_geom->append( entityList[index].entity, entityList[index].sense );
entityList[index].entity = 0;
}
for( i = 0; i < entityList.size() && entityList[i].entity; i++ );
for( j = i + 1; j < entityList.size(); j++ )
{
if( entityList[j].entity )
{
entityList[i].entity = entityList[j].entity;
entityList[i].sense = entityList[j].sense;
entityList[j].entity = 0;
i++;
}
}
entityList.size( i );
// copy entityname attrib to new entity
if ( name_attrib )
{
assert(!new_geom->listHead);
new_geom->listHead = new CompositeAttrib(*name_attrib);
}
update_cached_data();
return new_geom;
}
| CubitStatus CompositeGeom::swap | ( | int | index, |
| GeometryEntity * | new_geom | ||
| ) |
Definition at line 264 of file CompositeGeom.cpp.
{
if( (index < 0) || (index >= entityList.size()) )
{
assert( index >= 0 && index < entityList.size() );
return CUBIT_FAILURE;
}
entityList[index].entity = new_geom;
update_cached_data();
return CUBIT_SUCCESS;
}
| void CompositeGeom::update_cached_data | ( | ) | [inline] |
Definition at line 81 of file CompositeGeom.hpp.
{ needToUpdateBbox = true; needToUpdateMeasure = true; }
| void CompositeGeom::update_data_bbox | ( | ) | [private] |
Definition at line 351 of file CompositeGeom.cpp.
{
needToUpdateBbox = false;
for( int i = 0; i < entityList.size(); i++ )
{
entityList[i].bbox = entityList[i].entity->bounding_box();
}
}
| void CompositeGeom::update_data_measure | ( | ) | [private] |
Definition at line 331 of file CompositeGeom.cpp.
{
needToUpdateMeasure = false;
double sum = 0.0;
for( int i = 0; i < entityList.size(); i++ )
{
sum += entityList[i].entity->measure();
entityList[i].measure = sum;
}
}
| void CompositeGeom::write_attributes | ( | GeometryEntity * | entity = 0 | ) |
Definition at line 888 of file CompositeGeom.cpp.
{
DLIList<CubitSimpleAttrib> list;
if (geom_ptr)
{
// Special case for point-curves (no real curves to write
// attirbutes to.) Write to passed entity instead.
assert(entityList.size() == 0);
// clean up any attributes from the previous write
geom_ptr->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
while (list.size())
{
CubitSimpleAttrib csa = list.pop();
geom_ptr->remove_simple_attribute_virt(csa);
}
}
else
{
geom_ptr = entityList[0].entity;
// clean up any attributes from the previous write
for (int i = 0; i < entityList.size(); i++)
{
entityList[i].entity->get_simple_attribute(COMPOSITE_DATA_ATTRIB_NAME,list);
while (list.size())
{
CubitSimpleAttrib csa = list.pop();
entityList[i].entity->remove_simple_attribute_virt(csa);
}
}
}
CubitString name = COMPOSITE_DATA_ATTRIB_NAME;
int count = entityList.size();
CubitSimpleAttrib attrib;
for (CompositeAttrib* ptr = listHead; ptr; ptr = ptr->next)
{
attrib.string_data_list().push_back(name);
attrib.int_data_list().push_back(count);
ptr->append_to_csa(attrib);
//append the name attribute on all the rest of the entities too. This
//is so that if a one gets split, the results each get the name as well:
//jack --> jack and jack@A
if( ptr->name() == "ENTITY_NAME" )
{
for( int k=1; k<entityList.size(); k++ )
entityList[k].entity->append_simple_attribute_virt( attrib );
}
geom_ptr->append_simple_attribute_virt(attrib);
attrib.string_data_list().clear();
attrib.int_data_list().clear();
attrib.double_data_list().clear();
}
}
int CompositeGeom::currentIndex [private] |
Definition at line 109 of file CompositeGeom.hpp.
VGArray<CompositeEntry> CompositeGeom::entityList [private] |
Definition at line 108 of file CompositeGeom.hpp.
int CompositeGeom::firstIndex [private] |
Definition at line 110 of file CompositeGeom.hpp.
CompositeAttrib* CompositeGeom::listHead [private] |
Definition at line 115 of file CompositeGeom.hpp.
bool CompositeGeom::needToUpdateBbox [private] |
Definition at line 112 of file CompositeGeom.hpp.
bool CompositeGeom::needToUpdateMeasure [private] |
Definition at line 113 of file CompositeGeom.hpp.