cgma
|
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 : CoFace.cc 00010 // 00011 // Purpose : 00012 // 00013 // Special Notes : 00014 // 00015 // Creator : Xuechen Liu 00016 // 00017 // Creation Date : 08/02/96 00018 // 00019 // Owner : Jihong Ma 00020 //------------------------------------------------------------------------- 00021 00022 // ********** BEGIN STANDARD INCLUDES ********** 00023 // ********** END STANDARD INCLUDES ********** 00024 00025 // ********** BEGIN MOTIF INCLUDES ********** 00026 // ********** END MOTIF INCLUDES ********** 00027 00028 // ********** BEGIN OPEN INVENTOR INCLUDES ********** 00029 // ********** END OPEN INVENTOR INCLUDES ********** 00030 00031 // ********** BEGIN CUBIT INCLUDES ********** 00032 00033 #include "CoFace.hpp" 00034 #include "RefFace.hpp" 00035 #include "RefVolume.hpp" 00036 #include "GroupingEntity.hpp" 00037 #include "CastTo.hpp" 00038 #include "GeometryDefines.h" 00039 #include "Shell.hpp" 00040 00041 // ********** END CUBIT INCLUDES ********** 00042 00043 // ********** BEGIN STATIC DECLARATIONS ********** 00044 // ********** END STATIC DECLARATIONS ********** 00045 00046 00047 // ********** BEGIN PUBLIC FUNCTIONS ********** 00048 //------------------------------------------------------------------------- 00049 // Purpose : The default constructor. 00050 // 00051 // Special Notes : 00052 // 00053 // Creator : Xuechen Liu 00054 // 00055 // Creation Date : 08/02/96 00056 //------------------------------------------------------------------------- 00057 CoFace::CoFace() 00058 { 00059 } 00060 00061 //------------------------------------------------------------------------- 00062 // Purpose : The destructor. 00063 // 00064 // Special Notes : 00065 // 00066 // Creator : Raikanta Sahu 00067 // 00068 // Creation Date : 10/22/96 00069 //------------------------------------------------------------------------- 00070 CoFace::~CoFace() 00071 { 00072 } 00073 00074 //------------------------------------------------------------------------- 00075 // Purpose : The constructor with a pointer to a face and the 00076 // sense of this CoFace. 00077 // 00078 // Special Notes : 00079 // 00080 // Creator : Xuechen Liu 00081 // 00082 // Creation Date : 08/02/96 00083 //------------------------------------------------------------------------- 00084 CoFace::CoFace(RefFace* facePtr, CubitSense sense) 00085 { 00086 attach_basic_topology_entity(facePtr) ; 00087 set_sense(sense) ; 00088 } 00089 00090 //------------------------------------------------------------------------- 00091 // Purpose : This function returns a pointer to the RefFace which 00092 // the current CoFace is associated with. 00093 // 00094 // Special Notes : 00095 // 00096 // Creator : Malcolm J. Panthaki 00097 // 00098 // Creation Date : 08/02/96 00099 //------------------------------------------------------------------------- 00100 RefFace* CoFace::get_ref_face_ptr() 00101 { 00102 // Call the generic function defined in the SenseEntity class to 00103 // do the real work 00104 BasicTopologyEntity* BTEPtr = get_basic_topology_entity_ptr(); 00105 00106 // Cast the returned pointer to RefFace and return it 00107 return CAST_TO( BTEPtr, RefFace ); 00108 } 00109 00110 //------------------------------------------------------------------------- 00111 // Purpose : Get the parent Shell. 00112 // 00113 // Special Notes : 00114 // 00115 // Creator : Jason Kraftcheck 00116 // 00117 // Creation Date : 06/09/99 00118 //------------------------------------------------------------------------- 00119 Shell* CoFace::get_shell_ptr() 00120 { 00121 GroupingEntity* gpe_ptr = get_grouping_entity_ptr(); 00122 00123 // Cast the returned pointer to RefFace and return it 00124 return CAST_TO( gpe_ptr, Shell ); 00125 } 00126 00127 //------------------------------------------------------------------------- 00128 // Purpose : This function returns a pointer to the RefVolume which 00129 // the current CoFace is associated with. 00130 // 00131 // Special Notes : 00132 // 00133 // Creator : David White 00134 // 00135 // Creation Date : 03/14/97 00136 //------------------------------------------------------------------------- 00137 RefVolume* CoFace::get_ref_volume() 00138 { 00139 BasicTopologyEntity* bte_ptr = get_parent_basic_topology_entity_ptr(); 00140 00141 // Cast the returned pointer to RefFace and return it 00142 return dynamic_cast<RefVolume*>(bte_ptr); 00143 } 00144 00145 00146 //------------------------------------------------------------------------- 00147 // Purpose : This function is called after a child of a TopologyEntity 00148 // is switched. The sense of a CoFace may change if one 00149 // of its RefFace changes. This function takes care of 00150 // that. If the sense of the RefFaces that were switched 00151 // is same, nothing is done. If the RefFaces are of 00152 // opposite sense, the sense of this object is switched, 00153 // i.e. if it was FORWARD, it is made REVERSE, and vice 00154 // versa. 00155 // 00156 // Special Notes : This function assumes the RefFaces are equivalent... 00157 // 00158 // Creator : David White 00159 // 00160 // Creation Date : 4/3/97 00161 //------------------------------------------------------------------------- 00162 00163 void CoFace::switch_child_notify(TopologyEntity const* newChild, 00164 TopologyEntity const* oldChild ) 00165 { 00166 // Make sure the entities being switched are RefFaces. If not, 00167 // get out of this function. 00168 TopologyEntity* tmp_new_child = const_cast<TopologyEntity*>(newChild); 00169 TopologyEntity* tmp_old_child = const_cast<TopologyEntity*>(oldChild); 00170 RefFace* new_child_ref_face = CAST_TO(tmp_new_child, RefFace) ; 00171 RefFace* old_child_ref_face = CAST_TO(tmp_old_child, RefFace) ; 00172 00173 if ( ( new_child_ref_face == NULL ) || ( old_child_ref_face == NULL ) ) 00174 { 00175 return ; 00176 } 00177 00178 CubitSense sense = 00179 old_child_ref_face->compare_alignment( new_child_ref_face ); 00180 00181 // If the sense of the old RefFace relative to the new RefFace is 00182 // same, nothing needs to be done. However, if the relative sense 00183 // is reversed, switch the sense of the CoFace. 00184 if ( sense == CUBIT_REVERSED ) 00185 { 00186 if ( get_sense() == CUBIT_FORWARD ) 00187 { 00188 set_sense(CUBIT_REVERSED) ; 00189 } 00190 else 00191 { 00192 set_sense(CUBIT_FORWARD) ; 00193 } 00194 } 00195 } 00196 00197 00198 // ********** END PUBLIC FUNCTIONS ********** 00199 00200 // ********** BEGIN PROTECTED FUNCTIONS ********** 00201 // ********** END PROTECTED FUNCTIONS ********** 00202 00203 // ********** BEGIN PRIVATE FUNCTIONS ********** 00204 // ********** END PRIVATE FUNCTIONS ********** 00205 00206 // ********** BEGIN HELPER CLASSES ********** 00207 // ********** END HELPER CLASSES ********** 00208 00209 // ********** BEGIN EXTERN FUNCTIONS ********** 00210 // ********** END EXTERN FUNCTIONS ********** 00211 00212 // ********** BEGIN STATIC FUNCTIONS ********** 00213 // ********** END STATIC FUNCTIONS ********** 00214