cgma
FaceterPointData.cpp
Go to the documentation of this file.
00001 #include "FaceterPointData.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 
00009 static int point_counter = 0;
00010 
00011 //===========================================================================
00012 // Function Name: FaceterPointData
00013 //
00014 // Member Type:  PUBLIC
00015 // Description:  constructor
00016 // Author: 
00017 // Date:
00018 //===========================================================================
00019 FaceterPointData::FaceterPointData( double x_val, double y_val, double z_val )
00020   : coords( x_val, y_val, z_val )
00021 {
00022   attachedFacets = NULL;
00023   point_counter++;
00024   entityId = point_counter;
00025   myOwner = NULL;
00026   myInteriorAngle = CUBIT_DBL_MAX;
00027   mPrev = NULL;
00028   mNext = NULL;
00029 }
00030 
00031 //===========================================================================
00032 // Function Name: FaceterPointData
00033 //
00034 // Member Type:  PUBLIC
00035 // Description:  constructor
00036 // Author: 
00037 // Date:
00038 //===========================================================================
00039 FaceterPointData::FaceterPointData( const CubitVector &new_point )
00040   : coords( new_point )
00041 {
00042   attachedFacets = NULL;
00043   point_counter++;
00044   entityId = point_counter;
00045   myOwner = NULL;
00046   myInteriorAngle = CUBIT_DBL_MAX;
00047   mPrev = NULL;
00048   mNext = NULL;
00049 }
00050 
00051 //===========================================================================
00052 // Function Name: ~CubitPoint
00053 //
00054 // Member Type:  PUBLIC
00055 // Description:  destructor
00056 // Author: 
00057 // Date:
00058 //===========================================================================
00059 FaceterPointData::~FaceterPointData()
00060 {
00061   delete attachedFacets;
00062 }
00063 
00064 //===========================================================================
00065 // Function Name: coordinates
00066 //
00067 // Member Type:  PUBLIC
00068 // Description:  return coordinates of point in form of array
00069 // Author: 
00070 // Date:
00071 //===========================================================================
00072 void FaceterPointData::coordinates(double point_array[3])
00073 {
00074   point_array[0] = coords.x();
00075   point_array[1] = coords.y();
00076   point_array[2] = coords.z();
00077 }
00078 
00079 //===========================================================================
00080 // Function Name: add_facet
00081 //
00082 // Member Type:  PUBLIC
00083 // Description:  add a facet to the point's adjacency list
00084 // Author: 
00085 // Date:
00086 //===========================================================================
00087 void FaceterPointData::add_facet( CubitFacet *facet )
00088 {
00089   if ( attachedFacets == NULL )
00090     attachedFacets = new DLIList<CubitFacet*>(8);
00091   attachedFacets->append(facet);
00092   return;
00093 }
00094 
00095 //===========================================================================
00096 // Function Name: remove_facet
00097 //
00098 // Member Type:  PUBLIC
00099 // Description:  remove a facet to the point's adjacency list
00100 // Author: 
00101 // Date:
00102 //===========================================================================
00103 void FaceterPointData::remove_facet( CubitFacet *facet )
00104 {
00105   if ( attachedFacets == NULL )
00106     return;
00107   attachedFacets->remove(facet);
00108   return;
00109 }
00110 
00111 //===========================================================================
00112 // Function Name: edges
00113 //
00114 // Member Type:  PUBLIC
00115 // Description:  return the list of facet-edges attached to this point
00116 // Author: sjowen
00117 // Date:  4/28/01
00118 //===========================================================================
00119 void FaceterPointData::edges( DLIList<CubitFacetEdge *> &edge_list)
00120 {
00121   int ii, jj, kk;
00122   CubitFacet *facet_ptr;
00123   CubitFacetEdge *edge_ptr, *check_edge_ptr;
00124   for (ii=0; ii<attachedFacets->size(); ii++)
00125   {
00126     facet_ptr = attachedFacets->get_and_step();
00127     for (jj=0; jj<3; jj++)
00128     {
00129       edge_ptr = facet_ptr->edge( jj );
00130       if (edge_ptr)
00131       {
00132         if (edge_ptr->point(0) == this ||
00133           edge_ptr->point(1) == this)
00134         {
00135           int found = 0;
00136           for (kk=0; kk<edge_list.size() && !found; kk++)
00137           {
00138             check_edge_ptr = edge_list.get_and_step();
00139             if (check_edge_ptr == edge_ptr)
00140               found = 1;
00141           }
00142           if (!found)
00143           {
00144             edge_list.append( edge_ptr );
00145           }
00146         }
00147       }
00148     }
00149   }
00150   
00151   return;
00152 }
00153 
00154 //===========================================================================
00155 // Function Name: num_adj_facets
00156 //
00157 // Member Type:  PUBLIC
00158 // Description:  return the number of facets attached to the point
00159 // Author: 
00160 // Date:
00161 //===========================================================================
00162 int FaceterPointData::num_adj_facets()
00163 { 
00164   if (attachedFacets == NULL)
00165     return 0;
00166   else
00167     return attachedFacets->size(); 
00168 }
00169 
00170 int FaceterPointData::sort_by_angle (FaceterPointData *&pt_1,
00171                                      FaceterPointData *&pt_2)
00172 {
00173   if ( (pt_1->get_interior_angle() > pt_2->get_interior_angle() ) )
00174     return -1;
00175   if ( (pt_2->get_interior_angle() < pt_2->get_interior_angle() ) )
00176     return 1;
00177   else
00178     return 0;
00179 }
00180 
00181 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines