cgma
TDGeomFacet.cpp
Go to the documentation of this file.
00001 //- Class:       TDGeomFacet
00002 //- Description: Tool data for building a geometry from a mesh.
00003 //- Owner:       Steve Owen
00004 //- Checked by:
00005 //- Version:
00006 #include "TDGeomFacet.hpp"
00007 #include "CubitFacetEdge.hpp"
00008 #include "CubitFacet.hpp"
00009 #include "CastTo.hpp"
00010 #include "ChollaVolume.hpp"
00011 #include "ChollaSurface.hpp"
00012 #include "ChollaCurve.hpp"
00013 #include "ChollaPoint.hpp"
00014 #include "CubitPoint.hpp"
00015 
00016 TDGeomFacet::TDGeomFacet()
00017 {
00018   blockId = -1;
00019   hitFlag = 0;
00020   partnerEdgeList = NULL;
00021   partnerPointList = NULL;
00022 }
00023 
00024 TDGeomFacet::~TDGeomFacet()
00025 {
00026   if (partnerEdgeList != NULL)
00027     delete partnerEdgeList;
00028   if (partnerPointList != NULL)
00029     delete partnerPointList;
00030 }
00031 
00032 int TDGeomFacet::is_geom_facet(const ToolData* td)
00033 {
00034   return (CAST_TO(const_cast<ToolData*>(td), TDGeomFacet) != NULL);
00035 }
00036 
00037 CubitStatus TDGeomFacet::add_geom_facet( FacetEntity *facet_ptr, int block_id )
00038 {
00039   TDGeomFacet* td = (TDGeomFacet*) facet_ptr->get_TD( &TDGeomFacet::is_geom_facet );
00040   if ( td == NULL )
00041   {
00042     td = new TDGeomFacet;
00043     facet_ptr->add_TD( td );
00044   }
00045   td->set_block_id( block_id);
00046   return CUBIT_SUCCESS;
00047 }
00048 
00049 CubitStatus TDGeomFacet::add_geom_facet( CubitFacet *facet_ptr, int block_id)
00050 {
00051   TDGeomFacet *td = (TDGeomFacet*) facet_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00052   if ( td == NULL )
00053   {
00054     td = new TDGeomFacet;
00055     facet_ptr->add_TD( td );
00056   }
00057   td->set_block_id( block_id);
00058   return CUBIT_SUCCESS;
00059 }
00060 CubitStatus TDGeomFacet::add_geom_facet( CubitFacetEdge *edge_ptr, int block_id )
00061 {
00062   TDGeomFacet *td = (TDGeomFacet*) edge_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00063   if ( td == NULL )
00064   {
00065     td = new TDGeomFacet;
00066     edge_ptr->add_TD( td );
00067   }
00068   td->set_block_id( block_id);
00069   return CUBIT_SUCCESS;
00070 }
00071 CubitStatus TDGeomFacet::add_geom_facet( CubitPoint *point_ptr, int block_id )
00072 {
00073   TDGeomFacet* td = (TDGeomFacet*) point_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00074   if ( td == NULL )
00075   {
00076     td = new TDGeomFacet;
00077     point_ptr->add_TD( td );
00078   }
00079   td->set_block_id( block_id);
00080 
00081   return CUBIT_SUCCESS;
00082 }
00083 
00084 TDGeomFacet* TDGeomFacet::get_geom_facet( FacetEntity *facet_ptr )
00085 {
00086   TDGeomFacet* td = (TDGeomFacet*) facet_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00087   if ( td != NULL )
00088   {
00089     return td;
00090   }
00091   return (TDGeomFacet*) NULL;
00092 }
00093 TDGeomFacet* TDGeomFacet::get_geom_facet( CubitPoint *point_ptr )
00094 {
00095   TDGeomFacet *td = (TDGeomFacet*) point_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00096   if ( td != NULL )
00097   {
00098     return td;
00099   }
00100   return (TDGeomFacet*) NULL;
00101 }
00102 TDGeomFacet* TDGeomFacet::get_geom_facet( CubitFacetEdge *edge_ptr )
00103 {
00104   TDGeomFacet *td = (TDGeomFacet*) edge_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00105   if ( td != NULL )
00106   {
00107     return td;
00108   }
00109   return (TDGeomFacet*) NULL;
00110 }
00111 TDGeomFacet* TDGeomFacet::get_geom_facet( CubitFacet *facet_ptr )
00112 {
00113   TDGeomFacet *td = (TDGeomFacet*) facet_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00114   if ( td != NULL )
00115   {
00116     return td;
00117   }
00118   return (TDGeomFacet*) NULL;
00119 }
00120 
00121 
00122 int TDGeomFacet::get_block_id( FacetEntity *facet_ptr )
00123 {
00124   TDGeomFacet *td = (TDGeomFacet*) facet_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00125   if ( td != NULL )
00126   {
00127     return td->get_block_id();
00128   }
00129   return -1;
00130 }
00131 
00132 int TDGeomFacet::get_block_id( CubitFacet *facet_ptr )
00133 {
00134   TDGeomFacet *td = (TDGeomFacet*) facet_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00135   if ( td != NULL )
00136   {
00137     return td->get_block_id();
00138   }
00139   return -1;
00140 }
00141 
00142 int TDGeomFacet::get_block_id( CubitFacetEdge *edge_ptr )
00143 {
00144   TDGeomFacet *td = (TDGeomFacet*) edge_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00145   if ( td != NULL )
00146   {
00147     return td->get_block_id();
00148   }
00149   return -1;
00150 }
00151 void TDGeomFacet::add_cholla_owner( ChollaEntity *cholla_entity )
00152 {
00153   ChollaSurface *cholla_surface = dynamic_cast<ChollaSurface *> (cholla_entity);
00154   if (cholla_surface != NULL)
00155     add_cholla_surf(cholla_surface);
00156   else
00157   {
00158     ChollaCurve *cholla_curve = dynamic_cast<ChollaCurve *> (cholla_entity);
00159     if (cholla_curve != NULL)
00160       add_cholla_curve( cholla_curve );
00161     else
00162     {
00163       ChollaPoint *cholla_point = dynamic_cast<ChollaPoint *> (cholla_entity);
00164       if (cholla_point != NULL)
00165         add_cholla_point( cholla_point );
00166       else
00167         assert(0); // not a recognized cholla entity
00168     }
00169   }  
00170   return;
00171 }
00172 void TDGeomFacet::add_cholla_surf( ChollaSurface *f_s_m )
00173 {
00174   int ii;
00175   for ( ii = ChollaSurfaceList.size(); ii > 0; ii-- )
00176   {
00177     ChollaSurface *fsm_ptr = ChollaSurfaceList.get_and_step();
00178     if (f_s_m == fsm_ptr)
00179     {
00180       return;
00181     }
00182   }
00183   ChollaSurfaceList.append(f_s_m);
00184   return;
00185 }
00186 int TDGeomFacet::get_hit_flag( FacetEntity *facet_ptr )
00187 {
00188   TDGeomFacet *td = (TDGeomFacet*) facet_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00189   if ( td != NULL )
00190   {
00191     return td->get_hit_flag();
00192   }
00193   return -1;
00194 }
00195 void TDGeomFacet::set_hit_flag( FacetEntity *facet_ptr, int new_val )
00196 {
00197   TDGeomFacet *td = (TDGeomFacet*) facet_ptr->get_TD(&TDGeomFacet::is_geom_facet);
00198   if ( td != NULL )
00199   {
00200     td->set_hit_flag(new_val);
00201   }
00202   return;
00203 }
00204 
00205 CubitBoolean TDGeomFacet::is_partner( CubitFacetEdge *edge_ptr )
00206 {
00207   if (partnerEdgeList == NULL)
00208     return CUBIT_FALSE;
00209   for (int ii=0; ii<partnerEdgeList->size(); ii++)
00210   {
00211     if (partnerEdgeList->get_and_step() == edge_ptr)
00212       return CUBIT_TRUE;
00213   }
00214   return CUBIT_FALSE;
00215 }
00216 CubitBoolean TDGeomFacet::is_partner( CubitPoint *point_ptr )
00217 {
00218   if (partnerPointList == NULL)
00219     return CUBIT_FALSE;
00220   for (int ii=0; ii<partnerPointList->size(); ii++)
00221   {
00222     if (partnerPointList->get_and_step() == point_ptr)
00223       return CUBIT_TRUE;
00224   }
00225   return CUBIT_FALSE;
00226 }
00227 
00228 void TDGeomFacet::reset_TD_as_new()
00229 {
00230   blockId = -1;
00231   hitFlag = 0;
00232   partnerEdgeList = NULL;
00233   partnerPointList = NULL;
00234   ChollaSurfaceList.clean_out();
00235   ChollaCurveList.clean_out();
00236   myPoints.clean_out();
00237     //normal??????;
00238     //need to delete these?
00239   partnerEdgeList=NULL;
00240   partnerPointList=NULL;
00241 
00242 }
00243 
00244 int TDGeomFacet::geo_type()
00245 {
00246   if (ChollaSurfaceList.size() > 0)
00247     return 2;
00248   else if (ChollaCurveList.size() > 0)
00249     return 1;
00250   else if (myPoints.size() > 0)
00251     return 0;
00252   return -1;
00253 }
00254 
00255 CubitBoolean TDGeomFacet::is_in_volume( ChollaVolume *chvol_ptr )
00256 {
00257   for (int ii=0; ii<ChollaSurfaceList.size(); ii++)
00258   {
00259     ChollaSurface *chsurf_ptr = ChollaSurfaceList.get_and_step();
00260     if (chsurf_ptr->is_in_volume( chvol_ptr ))
00261       return CUBIT_TRUE;
00262   }
00263   for (int jj=0; jj<ChollaCurveList.size(); jj++)
00264   {
00265     ChollaCurve *chcurv_ptr = ChollaCurveList.get_and_step();
00266     if (chcurv_ptr->is_in_volume( chvol_ptr ))
00267       return CUBIT_TRUE;
00268   }
00269   return CUBIT_FALSE;
00270 }
00271 
00272 
00273 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines