cgma
MidPlaneTool.cpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : MidPlaneTool.hpp
00003 //
00004 // Purpose       : Create a mide surface between the two planar
00005 //                 surfaces passed in by the tool.
00006 //
00007 // Special Notes : 
00008 //
00009 // Creator       : David White
00010 //
00011 // Creation Date : 9/30/00
00012 //-------------------------------------------------------------------------
00013 
00014 #include "MidPlaneTool.hpp"
00015 #include "CubitVector.hpp"
00016 #include "CubitPlane.hpp"
00017 #include "RefFace.hpp"
00018 #include "RefEdge.hpp"
00019 #include "Loop.hpp"
00020 #include "Body.hpp"
00021 #include "CubitMessage.hpp"
00022 #include "GeometryModifyTool.hpp"
00023 #include "GeometryQueryTool.hpp"
00024 #include "DLIList.hpp"
00025 
00026 CubitStatus MidPlaneTool::sort_surfaces(RefFace* base_face, 
00027                     RefFace* predecessor,
00028                                         DLIList <RefFace*> &mid_surfaces)
00029 {
00030   DLIList <Loop*> loop_list;
00031   DLIList <RefEdge*> loop_edges;
00032   DLIList <RefFace*> edge_faces;
00033   RefFace *next_face;
00034   RefEdge *temp_edge;
00035   Loop* temp_loop;
00036 
00037   base_face->ordered_loops( loop_list );
00038 
00039   if(loop_list.size() == 1)
00040   {
00041     if(surfIndex%2==1)
00042     {
00043       mid_surfaces.append(base_face);
00044     }  
00045     if ( predecessor == NULL )
00046     {
00047       PRINT_ERROR("Bad logic in mid-plane extraction of sorting surfaces.\n");
00048       return CUBIT_SUCCESS;
00049     }
00050     //Now test to see if there are other surfaces attached to this
00051     //single loop (other than predecessor)
00052     DLIList <RefFace*> other_surfs;
00053     CubitStatus tmp_stat = get_other_surfs(base_face, predecessor, other_surfs);
00054     if ( tmp_stat != CUBIT_SUCCESS )
00055       return CUBIT_FAILURE;
00056     int jj;
00057     for ( jj = other_surfs.size(); jj > 0; jj-- )
00058     {
00059       next_face = other_surfs.get_and_step();
00060       surfIndex++;
00061       sort_surfaces(next_face,base_face,mid_surfaces);
00062       surfIndex--;
00063     }
00064       
00065     return CUBIT_SUCCESS;
00066   }
00067 
00068   if(surfIndex%2==1)
00069   {
00070     mid_surfaces.append(base_face);
00071   }
00072   loop_list.reset();
00073   loop_list.remove();
00074   for ( int ii = loop_list.size(); ii > 0; ii-- )
00075   {
00076     temp_loop = loop_list.get_and_step();
00077     loop_edges.clean_out();
00078     edge_faces.clean_out();
00079     temp_loop->ref_edges( loop_edges );
00080     temp_edge = loop_edges.get();
00081     temp_edge->ref_faces( edge_faces );
00082     if( edge_faces.size() > 2 )
00083     {
00084       PRINT_ERROR("Bad Logic.\n");
00085       return CUBIT_FAILURE;
00086     }
00087   
00088     if(edge_faces.size() == 2)
00089     {
00090       if(edge_faces.get() == base_face)
00091       {
00092         next_face = edge_faces.next();
00093       } else
00094       {
00095         next_face = edge_faces.get();
00096       }
00097 
00098       surfIndex++;
00099 
00100       sort_surfaces(next_face,base_face,mid_surfaces);
00101 
00102       surfIndex--;
00103 
00104     }
00105   }  
00106   return CUBIT_SUCCESS;
00107 }
00108 
00109 CubitStatus MidPlaneTool::get_other_surfs(RefFace* base_face, 
00110                       RefFace* predecessor, 
00111                       DLIList <RefFace*> &other_surfs)
00112 {
00113   DLIList <Loop*> loop_list;
00114   DLIList <RefEdge*> loop_edges;
00115   DLIList <RefFace*> edge_faces;
00116   RefFace *temp_face;
00117   RefEdge *temp_edge;
00118   Loop* temp_loop;
00119 
00120   base_face->loops( loop_list );
00121 
00122   for ( int ii = loop_list.size(); ii > 0; ii-- )
00123   {
00124     temp_loop = loop_list.get_and_step();
00125     loop_edges.clean_out();
00126     temp_loop->ref_edges( loop_edges );
00127     for ( int jj = loop_edges.size(); jj > 0; jj-- )
00128     {
00129       temp_edge = loop_edges.get_and_step();
00130       edge_faces.clean_out();
00131       temp_edge->ref_faces( edge_faces );
00132       for ( int kk = edge_faces.size(); kk > 0; kk-- )
00133       {
00134     temp_face = edge_faces.get_and_step();
00135     if ( ( temp_face != base_face ) && ( temp_face != predecessor ) )
00136     {
00137       other_surfs.append_unique( temp_face );
00138     }
00139       }
00140     }
00141   }
00142   return CUBIT_SUCCESS;
00143 }      
00144 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines