cgma
OCCHistory Class Reference

#include <OCCHistory.hpp>

List of all members.

Classes

struct  CGMEvent
struct  OCCEvent

Public Member Functions

 OCCHistory ()
 ~OCCHistory ()
void add_event (const OCCEvent &event)
void add_refentity_tracking_id_pair (RefEntity *ref_ent, int tracking_id)
void add_to_tracking_ids_tb_map (std::set< int > &tracking_ids, TopologyBridge *tb)
void collect_relevant_pairs (std::set< int > &seed_set, std::vector< std::pair< std::set< int >, TopologyBridge * > > &found_pairs)
int generate_next_tracking_id ()
void print ()
void create_cgm_history_objects ()
void create_port_event (CGMHistory::EventType event_type, std::vector< std::pair< std::set< int >, TopologyBridge * > > &found_pairs)
void add_TopoDS_Shape (TopoDS_Shape *ent)
void remove_attributes ()

Public Attributes

bool highLevelCopying

Private Attributes

std::vector< OCCEventeventList
std::vector< std::pair
< RefEntity *, int > > 
refentity_tracking_id_map
std::list< std::pair< std::set
< int >, TopologyBridge * > > 
tracking_ids_to_tb_map
std::vector< CGMEventcgmEventList
int trackingId
std::vector< TopoDS_Shape * > all_ents

Detailed Description

Definition at line 17 of file OCCHistory.hpp.


Constructor & Destructor Documentation

Definition at line 56 of file OCCHistory.cpp.

{
  trackingId = -1;
  highLevelCopying = false;
}

Definition at line 62 of file OCCHistory.cpp.

{
 //OCC_ATTRIB_HISTORY::remove_all_attribs(); 
}

Member Function Documentation

void OCCHistory::add_event ( const OCCEvent event)

Definition at line 67 of file OCCHistory.cpp.

{
  eventList.push_back( event );
}
void OCCHistory::add_refentity_tracking_id_pair ( RefEntity ref_ent,
int  tracking_id 
)

Definition at line 72 of file OCCHistory.cpp.

{
  refentity_tracking_id_map.push_back( 
    std::pair<RefEntity*, int>( ref_ent, tracking_id));
}
void OCCHistory::add_to_tracking_ids_tb_map ( std::set< int > &  tracking_ids,
TopologyBridge tb 
)

Definition at line 110 of file OCCHistory.cpp.

{
  tracking_ids_to_tb_map.push_back( std::pair< std::set<int>, TopologyBridge*>( tracking_ids, tb ) );
}
void OCCHistory::add_TopoDS_Shape ( TopoDS_Shape *  ent)

Definition at line 332 of file OCCHistory.cpp.

{
  all_ents.push_back( entity );
}
void OCCHistory::collect_relevant_pairs ( std::set< int > &  seed_set,
std::vector< std::pair< std::set< int >, TopologyBridge * > > &  found_pairs 
)

Definition at line 240 of file OCCHistory.cpp.

{
   
  std::list< std::pair< std::set<int>, TopologyBridge*> >::iterator iter;
  iter = tracking_ids_to_tb_map.begin();

  for(; iter != tracking_ids_to_tb_map.end(); iter++ ) 
  {
    std::pair< std::set<int>, TopologyBridge*> my_pair1 = *iter; 
    std::set<int> set1 = my_pair1.first;

    if( set1.empty() )
      continue;
    
    std::set<int>::iterator iter1, iter2;
    //does set1 contain any integers that are in the seed set?
    //if so, remove the pair from the list and add it to 'found_pairs'
    iter1 = set1.begin();
    bool pair_found = false;
    for(; iter1 != set1.end(); iter1++ )
    {
      int int1 = *iter1;
      
      for( iter2 = seed_set.begin(); iter2 != seed_set.end(); iter2++ )
      {
        int int2 = *iter2; 

        if( int2 == int1 )
        {
          //clear out the set
          std::set<int> &tmp_set = (*iter).first; 
          tmp_set.clear();

          found_pairs.push_back( my_pair1 );
          //tracking_ids_to_tb_map.erase( iter++ );
          collect_relevant_pairs( set1, found_pairs );
          pair_found = true;
          break;
        }
      }
      if( pair_found )
        break;
    }
//    if( pair_found == false )
//      iter++;
  }
}

Definition at line 115 of file OCCHistory.cpp.

{
  //look for subdivision-absorption events.
  //Look in tracking_ids_to_tb_map for a pair whose vector 
  //has multiple integers in it.  If you find another pair with the 
  //same integers in it, you've found a subdivision-absorption event.

  std::vector< std::pair< std::set<int>, TopologyBridge*> > unrelated_pairs;
  std::list< std::pair< std::set<int>, TopologyBridge*> >::iterator iter;
 
  if( highLevelCopying )
  {
    while( tracking_ids_to_tb_map.size() )
    {
      iter = tracking_ids_to_tb_map.begin();

      std::pair< std::set<int>, TopologyBridge*> pair1 = *iter; 

      std::vector< std::pair< std::set<int>, TopologyBridge*> > found_pairs; 
      found_pairs.push_back( pair1 );
      
      create_port_event( CGMHistory::COPY, found_pairs );
      tracking_ids_to_tb_map.erase( iter++ );
    }
  }
  else
  {

    while( tracking_ids_to_tb_map.size() )
    {
      iter = tracking_ids_to_tb_map.begin();

      std::pair< std::set<int>, TopologyBridge*> pair1 = *iter; 
      std::set<int> set1 = pair1.first;

      //find all pairs that have a vector that contains any integer in set1,
      //and at the same time recursively do the same for the found pairs 
      //get back a 'found_pairs' list
      
      std::vector< std::pair< std::set<int>, TopologyBridge*> > found_pairs; 
      found_pairs.push_back( pair1 );
      tracking_ids_to_tb_map.erase( iter++ );
      collect_relevant_pairs( set1, found_pairs ); 

      //if the found_pairs just contains the original pair
      //it's a simple absorption
      std::vector< std::pair< std::set<int>, TopologyBridge*> >::iterator vec_iter;
      std::pair< std::set<int>, TopologyBridge*> tmp_pair; 
      if( found_pairs.size() == 1 )
      {
        //if the single set contains multiple integers, 
        //it's a simple absorption

        vec_iter = found_pairs.begin();
        tmp_pair = *vec_iter;
        std::set<int> tmp_set = tmp_pair.first;
        if( tmp_set.size() > 1 )
          create_port_event( CGMHistory::ABSORPTION, found_pairs ); 
        else
          unrelated_pairs.push_back( pair1 );
      }
      else
      {
        //if the found_pairs all have exactly one integer in their sets, 
        //it's a simple subdivision
        vec_iter = found_pairs.begin();
        tmp_pair = *vec_iter;
        std::set<int> tmp_set = tmp_pair.first;
        int size_of_set = tmp_set.size(); 
        vec_iter++; 
        bool varying_sizes = false;
        for(; vec_iter != found_pairs.end(); vec_iter++ )
        {
          tmp_pair = *vec_iter;
          tmp_set = tmp_pair.first;
          if( size_of_set != tmp_set.size() )
          {
            varying_sizes = true;
            break;
          }
        }

        if( varying_sizes )
          create_port_event( CGMHistory::SUBDIVISION_ABSORPTION, found_pairs ); 
        else
          create_port_event( CGMHistory::SUBDIVISION, found_pairs ); 
      }
    }
  }

  std::vector< std::pair< std::set<int>, TopologyBridge*> >::iterator vec_iter1;
  vec_iter1 = unrelated_pairs.begin();
  for(; vec_iter1 != unrelated_pairs.end(); vec_iter1++ ) 
  {
    std::set<int> set1 = (*vec_iter1).first;
    if( set1.size() == 0 )
      continue;
    int tracking_id = *set1.begin();

    std::vector<OCCEvent>::iterator vec_iter2 = eventList.begin();
    for(; vec_iter2 != eventList.end(); vec_iter2++ )
    {
      OCCEvent event = (*vec_iter2);
      if( event.eventType == CGMHistory::GEOMETRY_CHANGED ||
          event.eventType == CGMHistory::CUT ) 
      {
        int other_tracking_id = event.entities[0];

        if( tracking_id == other_tracking_id )
        {
          TopologyBridge *tb = (*vec_iter1).second;
          std::pair<RefEntity*, int> tmp_pair = refentity_tracking_id_map[tracking_id];
          RefEntity* ref_ent = tmp_pair.first; 
          CGMHistory::PortEvent port_event( event.eventType );
          port_event.RefEnts.push_back( ref_ent );
          port_event.TopologyBridges.push_back( tb );
          GeometryQueryTool::instance()->history().add_port_event( port_event ); 
          break;
        }
      }
    }
  }
}
void OCCHistory::create_port_event ( CGMHistory::EventType  event_type,
std::vector< std::pair< std::set< int >, TopologyBridge * > > &  found_pairs 
)

Definition at line 290 of file OCCHistory.cpp.

{
  CGMHistory::PortEvent port_event( event_type );
  
  //add all TBs to the event's TB list
  std::vector< std::pair< std::set<int>, TopologyBridge*> >::iterator vec_iter;
  vec_iter = found_pairs.begin();
  std::pair< std::set<int>, TopologyBridge*> tmp_pair; 
  DLIList<RefEntity*> ref_ent_list;
  DLIList<TopologyBridge*> tb_list;
  for(; vec_iter != found_pairs.end(); vec_iter++ )
  {
    tmp_pair = *vec_iter;
    TopologyBridge *tb = tmp_pair.second; 
    tb_list.append( tb );

    std::set<int> tmp_set = tmp_pair.first;
    std::set<int>::iterator iter=tmp_set.begin();
    for(; iter != tmp_set.end(); iter++ )
    {
      int index = *iter;
      std::pair<RefEntity*, int> pair2 = refentity_tracking_id_map[index];
      RefEntity* ref_ent = pair2.first; 
      ref_ent_list.append( ref_ent );
    }
  }
    
  //uniquify the lists...then append them to the CGMEvent's vector
  ref_ent_list.uniquify_unordered(); 
  tb_list.uniquify_unordered(); 
  
  int i;
  for(i=ref_ent_list.size(); i--; )
    port_event.RefEnts.push_back( ref_ent_list.get_and_step() );
  for(i=tb_list.size(); i--; )
    port_event.TopologyBridges.push_back( tb_list.get_and_step() );

  GeometryQueryTool::instance()->history().add_port_event( port_event ); 
}

Definition at line 104 of file OCCHistory.cpp.

{
  trackingId++;
  return trackingId;
}

Definition at line 79 of file OCCHistory.cpp.

{
  /*
  std::vector<CGMEvent>::iterator iter = cgmEventList.begin();
  for(; iter != cgmEventList.end(); iter++ )
  {
    CGMEvent cgm_event = *iter;
    PRINT_INFO("Event type = %s RefEntities ", event_names[ cgm_event.eventType ]);

    int i;
    for( i=0; i<cgm_event.RefEnts.size(); i++ )
    {
      RefEntity *ref_ent = cgm_event.RefEnts[i];
      PRINT_INFO(" %s %d ", ref_ent->class_name(), ref_ent->id() );
    }
    PRINT_INFO(" ---> ");
    for( i=0; i<cgm_event.TopologyBridges.size(); i++ )
    {
      TopologyBridge *tb = cgm_event.TopologyBridges[i];
      PRINT_INFO(" %p", tb );
    }
    PRINT_INFO("\n"); 
  } */
}

Definition at line 337 of file OCCHistory.cpp.

{
/*
  int i;
  for( i=0; i<all_ents.size(); i++ )
  {
    OCC_ATTRIB_HISTORY *att = OCC_ATTRIB_HISTORY::get_history_attrib( all_ents[i], false ); 
    if( att )
      att->lose();
  }
*/
}

Member Data Documentation

std::vector<TopoDS_Shape*> OCCHistory::all_ents [private]

Definition at line 79 of file OCCHistory.hpp.

std::vector<CGMEvent> OCCHistory::cgmEventList [private]

Definition at line 77 of file OCCHistory.hpp.

std::vector<OCCEvent> OCCHistory::eventList [private]

Definition at line 74 of file OCCHistory.hpp.

Definition at line 70 of file OCCHistory.hpp.

std::vector< std::pair<RefEntity*, int> > OCCHistory::refentity_tracking_id_map [private]

Definition at line 75 of file OCCHistory.hpp.

std::list< std::pair< std::set<int>, TopologyBridge* > > OCCHistory::tracking_ids_to_tb_map [private]

Definition at line 76 of file OCCHistory.hpp.

int OCCHistory::trackingId [private]

Definition at line 78 of file OCCHistory.hpp.


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