cgma
ChollaSkinTool.cpp
Go to the documentation of this file.
00001 //- Class:       ChollaSkinTool
00002 //- Description: Creates a skin defined by facets and points, depending on the
00003 //-              dimensionality of the desired skin.
00004 //- Owner:       Steve Owen
00005 //- Checked by:
00006 //- Version:
00007 #include "ChollaSkinTool.hpp"
00008 #include "FacetEntity.hpp"
00009 #include "TDGeomFacet.hpp"
00010 #include "CastTo.hpp"
00011 #include "ChollaSurface.hpp"
00012 #include "ChollaCurve.hpp"
00013 #include "CubitFacetEdge.hpp"
00014 #include "TDFacetBoundaryEdge.hpp"
00015 #include "ChollaDebug.hpp"
00016 #include "GfxDebug.hpp"
00017 
00018 static int mydebug = 0;
00019 //==================================================================================
00020 //Function:  ChollaSkinTool (PUBLIC) (constructor)
00021 //==================================================================================
00022 ChollaSkinTool::ChollaSkinTool()
00023 {
00024 }
00025 //==================================================================================
00026 //Function:  ~ChollaSkinTool (PUBLIC) (destructor)
00027 //==================================================================================
00028 ChollaSkinTool::~ChollaSkinTool()
00029 {
00030 }
00031 
00032 //==================================================================================
00033 //Function:  skin_1d  (PUBLIC)
00034 //Description:  creates a skin of the given facet entities.
00035 //==================================================================================
00036 CubitStatus ChollaSkinTool::skin_1d(DLIList<FacetEntity*> &facet_list,
00037                                    ChollaCurve *&facet_curve_mesh_ptr)
00038 {
00039   CubitStatus rv = CUBIT_SUCCESS;
00040   
00041   // create a ChollaCurve if we have to (only if this is a 1D facet)
00042   
00043   if (!facet_curve_mesh_ptr)
00044   {
00045     FacetEntity *edge_ptr = facet_list.get();
00046     TDGeomFacet *td_gm = TDGeomFacet::get_geom_facet( edge_ptr );
00047     facet_curve_mesh_ptr = new ChollaCurve( td_gm->get_block_id() );
00048     
00049     // associate all of the tooldata on the faces of this surf with the 
00050     // new ChollaCurve
00051     
00052     int ii;
00053     for (ii=0; ii<facet_list.size(); ii++)
00054     {
00055       edge_ptr = facet_list.get_and_step();
00056       facet_curve_mesh_ptr->add_facet( edge_ptr );
00057       td_gm = TDGeomFacet::get_geom_facet( edge_ptr );
00058       td_gm->add_cholla_curve( facet_curve_mesh_ptr );
00059     }
00060   }
00061   
00062   // Note: the start and end points of this curve will be defined in 
00063   // ChollaCurve::split_curve.  The BlockPointMesh objects at these points
00064   // will be defined in MeshGeometryCreator::classify_node
00065   
00066   return rv;
00067 }
00068 
00069 //==================================================================================
00070 //Function:  skin_2d  (PUBLIC)
00071 //Description:  creates a skin of the given mesh entities.
00072 //==================================================================================
00073 CubitStatus ChollaSkinTool::skin_2d(DLIList<FacetEntity*> &facet_list,
00074                                    ChollaSurface *&facet_surface_mesh_ptr)
00075 {
00076   if(facet_list.size() == 0){
00077     return CUBIT_SUCCESS;
00078   }
00079   
00080   int debugflag=0;
00081   if (debugflag)
00082   {
00083     dcolor(CUBIT_YELLOW_INDEX);
00084     dldraw( facet_list );
00085     dview();
00086     dcolor(CUBIT_RED_INDEX);
00087   }
00088   CubitStatus rv = CUBIT_SUCCESS;
00089   int block_id;
00090 
00091   // create a ChollaSurface if we have to (only if this is a 2D model)
00092 
00093   FacetEntity *face_ptr = facet_list.get();
00094   TDGeomFacet *td_gm = TDGeomFacet::get_geom_facet( face_ptr );
00095   block_id = td_gm->get_block_id();
00096   if (!facet_surface_mesh_ptr)
00097   {
00098     facet_surface_mesh_ptr = new ChollaSurface(block_id);
00099 
00100     // associate all of the tooldata on the faces of this surf with the new ChollaSurface
00101 
00102     int ii;
00103     for (ii=0; ii<facet_list.size(); ii++)
00104     {
00105       face_ptr = facet_list.get_and_step();
00106       facet_surface_mesh_ptr->add_facet( face_ptr );
00107       td_gm = TDGeomFacet::get_geom_facet( face_ptr );
00108       td_gm->add_cholla_surf( facet_surface_mesh_ptr );
00109       td_gm->set_hit_flag( facet_surface_mesh_ptr->get_id() );
00110     }
00111   }
00112 
00113   // create a single ChollaCurve for this surface (assumes one loop of edges)
00114 
00115   ChollaCurve *fcm_ptr = new ChollaCurve( block_id );
00116   facet_surface_mesh_ptr->add_curve( fcm_ptr );
00117   fcm_ptr->add_surface( facet_surface_mesh_ptr );
00118 
00119   // loop through all faces on this surface searching for the boundary edges
00120 
00121   int jj, kk, ll;
00122   for ( kk = 0; kk < facet_list.size(); kk++)
00123   {
00124     face_ptr = facet_list.get_and_step();
00125     DLIList<CubitFacetEdge*> edge_list;
00126     face_ptr->edges( edge_list );
00127 
00128     // loop through each edge on this face searching for boundary edges
00129 
00130     for (jj=edge_list.size(); jj > 0; jj--)
00131     {
00132       CubitFacetEdge *edge_ptr = edge_list.get_and_step();
00133 
00134       // check if this edge has already been processed from an adjacent surface.
00135       // If it has, then tool data would have already been defined at this edge
00136       // and by definition would be at the boundary (only tooldatas on edges
00137       // at the boundary ofa surface are created)
00138 
00139       TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
00140       int on_boundary = 0;
00141       if (td_gm_edge != NULL)
00142       { 
00143         on_boundary = 1;
00144 
00145         // check for internal C-zero edge
00146 
00147         if (edge_ptr->num_adj_facets() == 2)
00148         {
00149           TDFacetBoundaryEdge *td_fbe = 
00150             TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
00151           if (td_fbe != NULL)
00152           {
00153             if (td_fbe->is_internal_edge())
00154             {
00155               on_boundary = 0;
00156             }
00157           }
00158         } 
00159       }
00160 
00161       // check for general case where no tool data yet defined
00162 
00163       else 
00164       {
00165         DLIList<FacetEntity*> adj_face_list;
00166 
00167         // check the adjacent faces to this edge.  If only one adjacent face, then
00168         // it is on the boundary.  If more than one face, then the other face(s)
00169         // must be associated with a surface other than facet_surface_mesh_ptr
00170         // in order to be on the boundary
00171 
00172         edge_ptr->get_parents( adj_face_list );
00173         if (adj_face_list.size() <= 1)
00174         {
00175           on_boundary = 1;
00176         }
00177         else
00178         {
00179           for (ll=adj_face_list.size(); ll> 0 && !on_boundary; ll--)
00180           {
00181             FacetEntity *adj_face_ptr = adj_face_list.get_and_step();
00182             if (adj_face_ptr != face_ptr)
00183             {
00184               TDGeomFacet *td_gm_adjface = TDGeomFacet::get_geom_facet(adj_face_ptr);
00185               DLIList<ChollaSurface*> surf_list;
00186               td_gm_adjface->get_cholla_surfs( surf_list );
00187 
00188               // if it doesn't have an associated surface yet, then it is 
00189               // a neighboring surface that has not been defined yet (this
00190               // should only occur for the 2D case)
00191                        
00192               if (surf_list.size() == 0)
00193               {
00194                 on_boundary = 1;
00195               }
00196               else
00197               {
00198 
00199                 // there should only be one surface associated with
00200                 // each face - otherwise we've screwed up somewhere  
00201 
00202                 assert ( surf_list.size() == 1 );
00203 
00204                 // if the surface is not the same as the current surface
00205                 // then we are at the boundary
00206 
00207                 ChollaSurface *check_bsm_ptr = surf_list.get();
00208                 if (facet_surface_mesh_ptr != check_bsm_ptr)
00209                 {
00210                   on_boundary = 1;
00211                 }
00212               }
00213             }
00214           }
00215         }
00216       }
00217       if (on_boundary)
00218       {
00219         // create a tool data if needed
00220 
00221         if (td_gm_edge == NULL)
00222         {
00223           TDGeomFacet::add_geom_facet(edge_ptr, -1); 
00224           td_gm_edge = TDGeomFacet::get_geom_facet( edge_ptr );
00225           edge_ptr->set_as_feature();
00226         }
00227 
00228         // add the pointer to this surface onto the edge tool data
00229 
00230         td_gm_edge->add_cholla_surf( facet_surface_mesh_ptr );
00231 
00232         // add this edge to the curve
00233 
00234         fcm_ptr->add_facet( edge_ptr );
00235         if (mydebug)
00236           dedraw(edge_ptr);
00237       }
00238     }
00239   }
00240 
00241   return rv;
00242 }
00243 
00244        
00245               
00246   
00247 
00248       
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines