cgma
SenseEntity.cpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Copyright Notice
00003 //
00004 // Copyright (c) 1996 
00005 // by Malcolm J. Panthaki, DBA, and the University of New Mexico.
00006 //-------------------------------------------------------------------------
00007 //
00008 //-------------------------------------------------------------------------
00009 // Filename      : SenseEntity.C 
00010 //
00011 // Purpose       : This file contains the implementation of the class 
00012 //                 SenseEntity. 
00013 //
00014 // Special Notes :
00015 //
00016 // Creator       : Xuechen Liu
00017 //
00018 // Creation Date : 07/11/96 
00019 //
00020 // Owner         :  Malcolm J. Panthaki
00021 //-------------------------------------------------------------------------
00022 
00023 // ********** BEGIN STANDARD INCLUDES      **********
00024 // ********** END STANDARD INCLUDES        **********
00025 
00026 // ********** BEGIN MOTIF INCLUDES         **********
00027 // ********** END MOTIF INCLUDES           **********
00028 
00029 // ********** BEGIN OPEN INVENTOR INCLUDES **********
00030 // ********** END OPEN INVENTOR INCLUDES   **********
00031 
00032 // ********** BEGIN CUBIT INCLUDES         **********
00033 
00034 #include "CubitDefines.h"
00035 #include "SenseEntity.hpp"
00036 #include "GroupingEntity.hpp"
00037 #include "BasicTopologyEntity.hpp"
00038 #include "DLIList.hpp"
00039 #include "ModelQueryEngine.hpp"
00040 // ********** END CUBIT INCLUDES           **********
00041 
00042 // ********** BEGIN STATIC DECLARATIONS    **********
00043 // ********** END STATIC DECLARATIONS      **********
00044 
00045 // ********** BEGIN PUBLIC FUNCTIONS       **********
00046 
00047 //-------------------------------------------------------------------------
00048 // Purpose       : Destructor
00049 //
00050 // Special Notes : 
00051 //
00052 // Creator       : Jason Kraftcheck
00053 //
00054 // Creation Date : 07/22/03
00055 //-------------------------------------------------------------------------
00056 SenseEntity::~SenseEntity()
00057 {
00058   if (myParent)
00059     myParent->remove_sense_entity(this);
00060   if (myChild)
00061     myChild->remove_sense_entity(this);
00062   assert (!myParent && !myChild);
00063 }
00064 
00065 //-------------------------------------------------------------------------
00066 // Purpose       : This function is used to attach a BasicTopologyEntity as a
00067 //                 child of the current SenseEntity in the DAG. 
00068 //
00069 // Special Notes : Complete reimplementation - jk, July 2003
00070 //
00071 // Creator       : Xuechen Liu
00072 //
00073 // Creation Date : 07/28/96
00074 //-------------------------------------------------------------------------
00075 CubitStatus SenseEntity::attach_basic_topology_entity(
00076     BasicTopologyEntity* basic_topology_entity_ptr)
00077 {
00078   return basic_topology_entity_ptr->add_sense_entity( this );
00079 }
00080 
00081 
00082 
00083 //-------------------------------------------------------------------------
00084 // Purpose       : Change the BTE attached to this SenseEntity
00085 //
00086 // Special Notes : derived from attach_basic_topology_entity()
00087 //
00088 // Creator       : Jason Kraftcheck
00089 //
00090 // Creation Date : 01/11/01
00091 //-------------------------------------------------------------------------
00092 CubitStatus SenseEntity::switch_basic_topology_entity( BasicTopologyEntity* new_bte )
00093 {
00094   if (new_bte->dag_type().parent() != dag_type())
00095     return CUBIT_FAILURE;
00096   
00097   if (!myChild->remove_sense_entity(this))
00098     return CUBIT_FAILURE;
00099     
00100   if (!new_bte->add_sense_entity(this))
00101     return CUBIT_FAILURE; 
00102     
00103   return CUBIT_SUCCESS;
00104 }
00105 
00106 
00107 
00108  
00109 //-------------------------------------------------------------------------
00110 // Purpose       : Reverse
00111 //
00112 // Special Notes : 
00113 //
00114 // Creator       : Jason Kraftcheck
00115 //
00116 // Creation Date : 03/27/01
00117 //-------------------------------------------------------------------------
00118 void SenseEntity::reverse_sense()
00119 { 
00120   switch (mySense)
00121   {
00122     case CUBIT_FORWARD : mySense = CUBIT_REVERSED; break;
00123     case CUBIT_REVERSED: mySense = CUBIT_FORWARD ; break;
00124     default            : mySense = CUBIT_UNKNOWN ; break;
00125   }
00126 }
00127 
00128 // ********** END PUBLIC FUNCTIONS         **********
00129 
00130 // ********** BEGIN PROTECTED FUNCTIONS    **********
00131 
00132 //-------------------------------------------------------------------------
00133 // Purpose       : get parent grouping entity
00134 //
00135 // Special Notes : 
00136 //
00137 // Creator       : Jason Kraftcheck
00138 //
00139 // Creation Date : 07/22/03
00140 //-------------------------------------------------------------------------
00141 int SenseEntity::get_parents( DLIList<TopologyEntity*>* list ) const
00142 {
00143   if (!myParent)
00144     return 0;
00145   
00146   if (list)
00147     list->append(myParent);
00148   
00149   return 1;
00150 }
00151 
00152 //-------------------------------------------------------------------------
00153 // Purpose       : get child basic topology entity
00154 //
00155 // Special Notes : 
00156 //
00157 // Creator       : Jason Kraftcheck
00158 //
00159 // Creation Date : 07/22/03
00160 //-------------------------------------------------------------------------
00161 int SenseEntity::get_children( DLIList<TopologyEntity*>* list ) const
00162 {
00163   if (!myChild)
00164     return 0;
00165   
00166   if (list)
00167     list->append(myChild);
00168   
00169   return 1;
00170 }
00171 
00172 //-------------------------------------------------------------------------
00173 // Purpose       : Remove from child basic topology entity
00174 //
00175 // Special Notes : 
00176 //
00177 // Creator       : Jason Kraftcheck
00178 //
00179 // Creation Date : 07/22/03
00180 //-------------------------------------------------------------------------
00181 CubitStatus SenseEntity::remove_child_link( TopologyEntity* entity_ptr )
00182 {
00183   if (entity_ptr != myChild)
00184     return CUBIT_FAILURE;
00185   
00186   BasicTopologyEntity* bte_ptr = static_cast<BasicTopologyEntity*>(entity_ptr);
00187   return bte_ptr->remove_sense_entity(this);
00188 }
00189 
00190 //-------------------------------------------------------------------------
00191 // Purpose       : Get parent BasicTopologyEntity
00192 //
00193 // Special Notes : 
00194 //
00195 // Creator       : Jason Kraftcheck
00196 //
00197 // Creation Date : 07/22/03
00198 //-------------------------------------------------------------------------
00199 BasicTopologyEntity* SenseEntity::get_parent_basic_topology_entity_ptr()
00200 {
00201   return myParent ? myParent->get_basic_topology_entity_ptr() : 0;
00202 }
00203 
00204 //-------------------------------------------------------------------------
00205 // Purpose       : Remove from parent GroupingEntity
00206 //
00207 // Special Notes : 
00208 //
00209 // Creator       : Jason Kraftcheck
00210 //
00211 // Creation Date : 07/22/03
00212 //-------------------------------------------------------------------------
00213 CubitStatus SenseEntity::disconnect_all_parents( DLIList<TopologyEntity*>* list )
00214 {
00215   if (!myParent)
00216     return CUBIT_SUCCESS;
00217   
00218   if (list)
00219     list->append(myParent);
00220   
00221   return myParent->remove_sense_entity(this);
00222 }
00223 
00224 //-------------------------------------------------------------------------
00225 // Purpose       : Disconnect form child BasicTopologyEntity
00226 //
00227 // Special Notes : 
00228 //
00229 // Creator       : Jason Kraftcheck
00230 //
00231 // Creation Date : 07/22/03
00232 //-------------------------------------------------------------------------
00233 CubitStatus SenseEntity::disconnect_all_children( DLIList<TopologyEntity*>* list )
00234 {
00235   if (!myChild)
00236     return CUBIT_SUCCESS;
00237   
00238   if (list)
00239     list->append(myChild);
00240   
00241   return myChild->remove_sense_entity(this);
00242 }
00243 
00244 //-------------------------------------------------------------------------
00245 // Purpose       : Functions to support ModelQueryEngine
00246 //
00247 // Special Notes : 
00248 //
00249 // Creator       : Jason Kraftcheck
00250 //
00251 // Creation Date : 07/24/03
00252 //-------------------------------------------------------------------------
00253 CubitBoolean SenseEntity::query_append_parents( DLIList<TopologyEntity*>& list )
00254 {
00255   if (myParent && !ModelQueryEngine::instance()->encountered(myParent))
00256   {
00257     list.append(myParent);
00258     return CUBIT_TRUE;
00259   }
00260   
00261   return CUBIT_FALSE;
00262 }
00263 CubitBoolean SenseEntity::query_append_children( DLIList<TopologyEntity*>& list )
00264 {
00265   if (myChild && !ModelQueryEngine::instance()->encountered(myChild))
00266   {
00267     list.append(myChild);
00268     return CUBIT_TRUE;
00269   }
00270   
00271   return CUBIT_FALSE;
00272 }
00273 
00274 
00275 // ********** END PROTECTED FUNCTIONS      **********
00276 
00277 // ********** BEGIN PRIVATE FUNCTIONS      **********
00278 // ********** END PRIVATE FUNCTIONS        **********
00279 
00280 // ********** BEGIN HELPER CLASSES         **********
00281 // ********** END HELPER CLASSES           **********
00282 
00283 // ********** BEGIN EXTERN FUNCTIONS       **********
00284 // ********** END EXTERN FUNCTIONS         **********
00285 
00286 // ********** BEGIN STATIC FUNCTIONS       **********
00287 // ********** END STATIC FUNCTIONS         **********
00288 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines