cgma
ImprintPointData.cpp
Go to the documentation of this file.
00001 #include "ImprintPointData.hpp"
00002 #include "CubitFacet.hpp"
00003 #include "CubitFacetEdge.hpp"
00004 #include "ToolData.hpp"
00005 #include "CubitFacetData.hpp"
00006 #include "CastTo.hpp"
00007 #include "RefEntity.hpp"
00008 #include "CubitMessage.hpp"
00009 
00010 static int point_counter = 0;
00011 
00012 //===========================================================================
00013 // Function Name: ImprintPointData
00014 //
00015 // Member Type:  PUBLIC
00016 // Description:  constructor
00017 // Author: 
00018 // Date:
00019 //===========================================================================
00020 ImprintPointData::ImprintPointData( double x_val, double y_val, double z_val )
00021   : coords( x_val, y_val, z_val )
00022 {
00023   initialize_imprint_data();
00024 }
00025 void ImprintPointData::initialize_imprint_data()
00026 {
00027   attachedFacets = NULL;
00028   point_counter++;
00029   entityId = point_counter;
00030   myOwner = NULL;
00031   myPointType = UNSET_POINT;
00032   ownerRefVertex = CUBIT_FALSE;
00033   matchingPoint = NULL;
00034   startPartition = CUBIT_FALSE;
00035   endPartition = CUBIT_FALSE;
00036   listLoopPos = 0;
00037   loopPos = 0;
00038   pointMatches = NULL;
00039   isMatched = CUBIT_FALSE;
00040   prevSeg = NULL;
00041   nextSeg = NULL;
00042 }
00043 
00044 
00045   
00046 CubitStatus ImprintPointData::set_matching_point(ImprintPointData *other)
00047 {
00048  // assert(matchingPoint == NULL|| other == matchingPoint);
00049   matchingPoint = other;
00050   return CUBIT_SUCCESS;
00051 }
00052 //===========================================================================
00053 // Function Name: ImprintPointData
00054 //
00055 // Member Type:  PUBLIC
00056 // Description:  constructor
00057 // Author: 
00058 // Date:
00059 //===========================================================================
00060 ImprintPointData::ImprintPointData( const CubitVector &new_point )
00061   : coords( new_point )
00062 {
00063   initialize_imprint_data();
00064 }
00065 
00066 //===========================================================================
00067 // Function Name: ImprintPointData
00068 //
00069 // Member Type:  PUBLIC
00070 // Description:  copy constructor
00071 // Author: 
00072 // Date:
00073 //===========================================================================
00074 ImprintPointData::ImprintPointData( ImprintPointData *copy, CubitVector &new_coords )
00075 {
00076   coords = new_coords;
00077   initialize_imprint_data();
00078   myPointType=copy->myPointType;
00079   owner(copy->myOwner);
00080   set_matching_point(copy);
00081   copy->set_matching_point(this);
00082 }
00083 
00084 
00085 //===========================================================================
00086 // Function Name: ~CubitPoint
00087 //
00088 // Member Type:  PUBLIC
00089 // Description:  destructor
00090 // Author: 
00091 // Date:
00092 //===========================================================================
00093 ImprintPointData::~ImprintPointData()
00094 {
00095   if ( attachedFacets )
00096     delete attachedFacets;
00097   if ( pointMatches )
00098     delete pointMatches;
00099 }
00100 
00101 //===========================================================================
00102 // Function Name: coordinates
00103 //
00104 // Member Type:  PUBLIC
00105 // Description:  return coordinates of point in form of array
00106 // Author: 
00107 // Date:
00108 //===========================================================================
00109 void ImprintPointData::coordinates(double point_array[3])
00110 {
00111   point_array[0] = coords.x();
00112   point_array[1] = coords.y();
00113   point_array[2] = coords.z();
00114 }
00115 
00116 //===========================================================================
00117 // Function Name: add_facet
00118 //
00119 // Member Type:  PUBLIC
00120 // Description:  add a facet to the point's adjacency list
00121 // Author: 
00122 // Date:
00123 //===========================================================================
00124 void ImprintPointData::add_facet( CubitFacet *facet )
00125 {
00126   if ( attachedFacets == NULL )
00127     attachedFacets = new DLIList<CubitFacet*>(8);
00128   attachedFacets->append(facet);
00129   return;
00130 }
00131 
00132 //===========================================================================
00133 // Function Name: remove_facet
00134 //
00135 // Member Type:  PUBLIC
00136 // Description:  remove a facet to the point's adjacency list
00137 // Author: 
00138 // Date:
00139 //===========================================================================
00140 void ImprintPointData::remove_facet( CubitFacet *facet )
00141 {
00142   if ( attachedFacets == NULL )
00143     return;
00144   attachedFacets->remove(facet);
00145   return;
00146 }
00147 
00148 //===========================================================================
00149 // Function Name: edges
00150 //
00151 // Member Type:  PUBLIC
00152 // Description:  return the list of facet-edges attached to this point
00153 // Author: sjowen
00154 // Date:  4/28/01
00155 //===========================================================================
00156 void ImprintPointData::edges( DLIList<CubitFacetEdge *> &edge_list)
00157 {
00158   int ii, jj, kk;
00159   CubitFacet *facet_ptr;
00160   CubitFacetEdge *edge_ptr, *check_edge_ptr;
00161   for (ii=0; ii<attachedFacets->size(); ii++)
00162   {
00163     facet_ptr = attachedFacets->get_and_step();
00164     for (jj=0; jj<3; jj++)
00165     {
00166       edge_ptr = facet_ptr->edge( jj );
00167       if (edge_ptr)
00168       {
00169         if (edge_ptr->point(0) == this ||
00170           edge_ptr->point(1) == this)
00171         {
00172           int found = 0;
00173           for (kk=0; kk<edge_list.size() && !found; kk++)
00174           {
00175             check_edge_ptr = edge_list.get_and_step();
00176             if (check_edge_ptr == edge_ptr)
00177               found = 1;
00178           }
00179           if (!found)
00180           {
00181             edge_list.append( edge_ptr );
00182           }
00183         }
00184       }
00185     }
00186   }
00187   
00188   return;
00189 }
00190 
00191 //===========================================================================
00192 // Function Name: num_adj_facets
00193 //
00194 // Member Type:  PUBLIC
00195 // Description:  return the number of facets attached to the point
00196 // Author: 
00197 // Date:
00198 //===========================================================================
00199 int ImprintPointData::num_adj_facets()
00200 { 
00201   if (attachedFacets == NULL)
00202     return 0;
00203   else
00204     return attachedFacets->size(); 
00205 }
00206 
00207 void ImprintPointData::add_match_data(ImprintMatchData *match_data)
00208 {
00209   if ( !pointMatches )
00210     pointMatches = new DLIList<ImprintMatchData*>;
00211   pointMatches->append(match_data);
00212 }
00213 void ImprintPointData::get_match_list(DLIList <ImprintMatchData*> &match_data_list)
00214 {
00215   if ( pointMatches != NULL )
00216   {
00217     match_data_list += *pointMatches;
00218   }
00219 }
00220 void ImprintPointData::set_unmatched()
00221 {
00222   if ( pointMatches != NULL)
00223   {
00224     pointMatches->clean_out();
00225   }
00226   isMatched = CUBIT_FALSE;
00227 }
00228 void ImprintPointData::set_matched(ImprintMatchData *match_data)
00229 {
00230   if ( !pointMatches )
00231     pointMatches = new DLIList<ImprintMatchData*>;
00232   else
00233   {
00234     pointMatches->clean_out();
00235   }
00236   pointMatches->append(match_data);
00237   isMatched = CUBIT_TRUE;
00238 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines