cgma
TDFacetBoundaryPoint.cpp
Go to the documentation of this file.
00001 //- Class:       TDFacetBoundaryPoint
00002 //- Description: Tool data for storing additional information at 
00003 //-              the boundary of a facet set
00004 //- Owner:       Steve Owen
00005 //- Checked by:
00006 //- Version:
00007 
00008 #include "TDFacetBoundaryPoint.hpp"
00009 #include "CubitPoint.hpp"
00010 #include "CubitFacet.hpp"
00011 #include "CubitQuadFacet.hpp"
00012 #include "CubitFacetEdge.hpp"
00013 #include "CastTo.hpp"
00014 #include "CubitTransformMatrix.hpp"
00015 #include "GfxDebug.hpp"
00016 #include "CubitMessage.hpp"
00017 
00018 TDFacetBoundaryPoint::TDFacetBoundaryPoint()
00019 {
00020 
00021 }
00022 
00023 TDFacetBoundaryPoint::~TDFacetBoundaryPoint()
00024 {
00025   for (int ii=0; ii<pointDataList.size(); ii++)
00026   {
00027     BoundaryPointData *bpd_ptr = pointDataList.get_and_step();
00028     delete bpd_ptr;
00029   }
00030 }
00031 
00032 
00033 //-------------------------------------------------------------------------
00034 // Purpose       : create a new facet boundary edge
00035 //
00036 // Special Notes :
00037 //
00038 // Creator       : Steve Owen
00039 //
00040 // Creation Date : 05/01
00041 //------------------------------------------------------------------------- 
00042 CubitStatus TDFacetBoundaryPoint::add_facet_boundary_point( 
00043   CubitPoint *point_ptr )
00044 {
00045   ToolData *td;
00046   td = point_ptr->get_TD(&TDFacetBoundaryPoint::is_facet_boundary_point);
00047   if ( td == NULL )
00048   {
00049     TDFacetBoundaryPoint *td_gm = new TDFacetBoundaryPoint;
00050     point_ptr->add_TD( td_gm);
00051     td_gm->set_point( point_ptr );
00052   }
00053   else
00054   {
00055     TDFacetBoundaryPoint *td_gm = CAST_TO(td, TDFacetBoundaryPoint);
00056     td_gm->set_point( point_ptr );
00057   }
00058   return CUBIT_SUCCESS;
00059 }
00060 
00061 //-------------------------------------------------------------------------
00062 // Purpose       : create a new facet boundary point
00063 //
00064 // Special Notes : this is used to create and initialize with one facet
00065 //                 and its corresponding normal.
00066 //
00067 // Creator       : Steve Owen
00068 //
00069 // Creation Date : 05/01
00070 //------------------------------------------------------------------------- 
00071 CubitStatus TDFacetBoundaryPoint::add_facet_boundary_point( 
00072   CubitPoint *point_ptr,
00073   CubitFacet *facet_ptr,
00074   CubitVector &pt_normal )
00075 {
00076   ToolData *td;
00077   TDFacetBoundaryPoint *td_gm = NULL;
00078   td = point_ptr->get_TD(&TDFacetBoundaryPoint::is_facet_boundary_point);
00079   if ( td == NULL )
00080   {
00081     td_gm = new TDFacetBoundaryPoint;
00082     point_ptr->add_TD( td_gm);
00083     td_gm->set_point( point_ptr );
00084   }
00085   else
00086   {
00087     td_gm = CAST_TO(td, TDFacetBoundaryPoint);
00088     td_gm->set_point( point_ptr );
00089   }
00090 
00091   BoundaryPointData *bpd_ptr = new BoundaryPointData;
00092   bpd_ptr->surfFacetList.append( facet_ptr ); 
00093   bpd_ptr->surfID = -1;
00094   bpd_ptr->uVal = 0.0; 
00095   bpd_ptr->vVal = 0.0;
00096   bpd_ptr->sizeVal = 0.0;
00097   bpd_ptr->normal = pt_normal;
00098   td_gm->pointDataList.append( bpd_ptr );
00099   
00100   return CUBIT_SUCCESS;
00101 }
00102 
00103 //-------------------------------------------------------------------------
00104 // Purpose       : create a new facet boundary point
00105 //
00106 // Special Notes : this is used to create and initialize with one facet
00107 //                 and its corresponding normal.  Same as above but uses 
00108 //                 a CubitQuadFacet
00109 //
00110 // Creator       : Steve Owen
00111 //
00112 // Creation Date : 01/2004
00113 //------------------------------------------------------------------------- 
00114 CubitStatus TDFacetBoundaryPoint::add_facet_boundary_point( 
00115   CubitPoint *point_ptr,
00116   CubitQuadFacet *qfacet_ptr,
00117   CubitVector &pt_normal )
00118 {
00119   ToolData *td;
00120   TDFacetBoundaryPoint *td_gm = NULL;
00121   td = point_ptr->get_TD(&TDFacetBoundaryPoint::is_facet_boundary_point);
00122   if ( td == NULL )
00123   {
00124     td_gm = new TDFacetBoundaryPoint;
00125     point_ptr->add_TD( td_gm);
00126     td_gm->set_point( point_ptr );
00127   }
00128   else
00129   {
00130     td_gm = CAST_TO(td, TDFacetBoundaryPoint);
00131     td_gm->set_point( point_ptr );
00132   }
00133 
00134   CubitFacet *facet0 = qfacet_ptr->get_tri_facet(0);
00135   CubitFacet *facet1 = qfacet_ptr->get_tri_facet(1);
00136 
00137   BoundaryPointData *bpd_ptr = new BoundaryPointData;
00138   if (facet0->point_index( point_ptr ) >= 0)
00139     bpd_ptr->surfFacetList.append( facet0 );
00140   if (facet1->point_index( point_ptr ) >= 0)
00141     bpd_ptr->surfFacetList.append( facet1 );
00142   bpd_ptr->surfID = -1;
00143   bpd_ptr->uVal = 0.0; 
00144   bpd_ptr->vVal = 0.0;
00145   bpd_ptr->sizeVal = 0.0;
00146   bpd_ptr->normal = pt_normal;
00147   td_gm->pointDataList.append( bpd_ptr );
00148   
00149   return CUBIT_SUCCESS;
00150 }
00151 
00152 //-------------------------------------------------------------------------
00153 // Purpose       : get the facet boundary point from a point
00154 //
00155 // Special Notes :
00156 //
00157 // Creator       : Steve Owen
00158 //
00159 // Creation Date : 05/01
00160 //------------------------------------------------------------------------- 
00161 TDFacetBoundaryPoint* TDFacetBoundaryPoint::get_facet_boundary_point( 
00162   CubitPoint *point_ptr )
00163 {
00164   ToolData *td;
00165   td = point_ptr->get_TD(&TDFacetBoundaryPoint::is_facet_boundary_point);
00166   if ( td != NULL )
00167   {
00168     TDFacetBoundaryPoint *td_gm = CAST_TO(td, TDFacetBoundaryPoint);
00169     return td_gm;
00170   }
00171   return (TDFacetBoundaryPoint*) NULL;
00172 }
00173 
00174 
00175 //-------------------------------------------------------------------------
00176 // Purpose       : add a group of facets that are adjacent to this point
00177 //                 that are on the same surface
00178 //
00179 // Special Notes :
00180 //
00181 // Creator       : Steve Owen
00182 //
00183 // Creation Date : 05/01
00184 //------------------------------------------------------------------------- 
00185 void TDFacetBoundaryPoint::add_surf_facets(
00186   DLIList<CubitFacet *> adj_facet_list )
00187 {
00188   BoundaryPointData *bpd_ptr = new BoundaryPointData;
00189   int ii;
00190   for (ii=0; ii<adj_facet_list.size(); ii++)
00191   {
00192     CubitFacet *facet_ptr = adj_facet_list.get_and_step();
00193     bpd_ptr->surfFacetList.append( facet_ptr );
00194   }
00195   
00196   bpd_ptr->surfID = -1;
00197   bpd_ptr->uVal = 0.0; 
00198   bpd_ptr->vVal = 0.0;
00199   bpd_ptr->sizeVal = 0.0;
00200   pointDataList.append( bpd_ptr );
00201   init_normal( bpd_ptr );
00202 }
00203 
00204 //-------------------------------------------------------------------------
00205 // Purpose       : get the normal from a boundary point
00206 //
00207 // Special Notes :
00208 //
00209 // Creator       : Steve Owen
00210 //
00211 // Creation Date : 05/01
00212 //------------------------------------------------------------------------- 
00213 CubitStatus TDFacetBoundaryPoint::get_normal( int surf_id, 
00214                                               CubitVector &normal )
00215 {
00216   int found = 0;
00217   BoundaryPointData *bpd_ptr = NULL;
00218   for (int ii=0; ii<pointDataList.size(); ii++)
00219   {
00220     bpd_ptr = pointDataList.get_and_step();
00221     if(bpd_ptr->surfID == surf_id)
00222       found = 1;
00223   }
00224   if (!found)  // the surf_id does not match any in the list
00225     return CUBIT_FAILURE;
00226 
00227   normal = bpd_ptr->normal;
00228 
00229   return CUBIT_SUCCESS;
00230 }
00231 
00232 //-------------------------------------------------------------------------
00233 // Purpose       : get the normal from a boundary point based on its
00234 //                 adjacent facet
00235 //
00236 // Special Notes :
00237 //
00238 // Creator       : Steve Owen
00239 //
00240 // Creation Date : 05/01
00241 //------------------------------------------------------------------------- 
00242 CubitStatus TDFacetBoundaryPoint::get_normal( CubitFacet *adj_facet, 
00243                                               CubitVector &normal )
00244 {
00245   BoundaryPointData *bpd_ptr = get_bpd( adj_facet );
00246   if (!bpd_ptr)
00247     return CUBIT_FAILURE;
00248   normal = bpd_ptr->normal;
00249   return CUBIT_SUCCESS;
00250 }
00251 
00252 //-------------------------------------------------------------------------
00253 // Purpose       : get the normal from a boundary point based on its
00254 //                 adjacent edge
00255 //
00256 // Special Notes :  this is really only unique if the edge is non-manifold
00257 //                  or the facets adjacent the edge all lie on the same 
00258 //                  surface
00259 //
00260 // Creator       : Steve Owen
00261 //
00262 // Creation Date : 05/01
00263 //------------------------------------------------------------------------- 
00264 CubitStatus TDFacetBoundaryPoint::get_normal( CubitFacetEdge *edge_ptr, 
00265                                               CubitVector &normal )
00266 {
00267   DLIList<CubitFacet *>adj_facets;
00268   edge_ptr->facets(adj_facets);
00269   BoundaryPointData *bpd_ptr = NULL;
00270   for (int ii=0; ii<adj_facets.size() && bpd_ptr == NULL; ii++)
00271   {
00272     bpd_ptr = get_bpd( adj_facets.get_and_step() );
00273   }
00274   if (!bpd_ptr)
00275     return CUBIT_FAILURE;
00276   normal = bpd_ptr->normal;
00277   return CUBIT_SUCCESS;
00278 }
00279 
00280 //-------------------------------------------------------------------------
00281 // Purpose       : set the normal into a boundary point
00282 //
00283 // Special Notes :
00284 //
00285 // Creator       : Steve Owen
00286 //
00287 // Creation Date : 05/01
00288 //------------------------------------------------------------------------- 
00289 CubitStatus TDFacetBoundaryPoint::set_normal( int surf_id, 
00290                                               CubitVector &normal )
00291 {
00292   int found = 0;
00293   BoundaryPointData *bpd_ptr = NULL;
00294   for (int ii=0; ii<pointDataList.size(); ii++)
00295   {
00296     bpd_ptr = pointDataList.get_and_step();
00297     if(bpd_ptr->surfID == surf_id)
00298       found = 1;
00299   }
00300   if (!found)  // the surf_id does not match any in the list
00301     return CUBIT_FAILURE;
00302 
00303   bpd_ptr->normal = normal;
00304 
00305   return CUBIT_SUCCESS;
00306 }
00307 
00308 //-------------------------------------------------------------------------
00309 // Purpose       : reset the all normals for boundary points
00310 //
00311 // Special Notes :
00312 //
00313 // Creator       : Michael Brewer
00314 //
00315 // Creation Date : 02/05
00316 //------------------------------------------------------------------------- 
00317 CubitStatus TDFacetBoundaryPoint::reset_normals(  )
00318 {
00319   BoundaryPointData *bpd_ptr;
00320   for (int ii=0; ii<pointDataList.size(); ii++)
00321   {
00322     bpd_ptr = pointDataList.get_and_step();
00323     if(bpd_ptr)
00324       init_normal(bpd_ptr);
00325     else{
00326       PRINT_ERROR("Could not determine boundary point data.\n");
00327       return CUBIT_FAILURE;
00328     }
00329   }
00330   return CUBIT_SUCCESS;
00331 }
00332 
00333 //-------------------------------------------------------------------------
00334 // Purpose       : set the surface id of associated with one of the 
00335 //                 facets adjacent to this point
00336 //
00337 // Special Notes :
00338 //
00339 // Creator       : Steve Owen
00340 //
00341 // Creation Date : 05/01
00342 //------------------------------------------------------------------------- 
00343 void TDFacetBoundaryPoint::set_surf_id( CubitFacet *facet_ptr, int surf_id )
00344 {
00345   int found = 0;
00346   int ii, jj;
00347   CubitFacet *check_facet_ptr;
00348   BoundaryPointData *bpd_ptr;
00349   for (ii=0; ii<pointDataList.size() && !found; ii++)
00350   {
00351     bpd_ptr = pointDataList.get_and_step();
00352     for (jj=0; jj<bpd_ptr->surfFacetList.size() && !found; jj++)
00353     {
00354       check_facet_ptr = bpd_ptr->surfFacetList.get_and_step();
00355       if (check_facet_ptr == facet_ptr)
00356       {
00357         found = 1;
00358         bpd_ptr->surfID = surf_id;
00359       }
00360     }
00361   }
00362   assert(found);  // couldn't find the facet adjacent the surface
00363 }
00364 
00365 //-------------------------------------------------------------------------
00366 // Purpose       : compute and set the normal
00367 //
00368 // Special Notes :
00369 //
00370 // Creator       : Steve Owen
00371 //
00372 // Creation Date : 05/01
00373 //------------------------------------------------------------------------- 
00374 void TDFacetBoundaryPoint::init_normal( BoundaryPointData *bpd_ptr )
00375 {
00376   
00377   if (bpd_ptr && bpd_ptr->surfFacetList.size() > 0) {
00378     CubitFacet *facet;
00379     double angle;
00380     int j;
00381     CubitVector normal;
00382     CubitVector avg_normal(0.0e0, 0.0e0, 0.0e0);
00383     double totangle = 0.0e0;
00384 
00385       // weight the normal by the spanning angle at the point
00386     int mydebug =0;
00387     for (j = 0; j < bpd_ptr->surfFacetList.size(); j++)
00388     {
00389       facet = bpd_ptr->surfFacetList.get_and_step();
00390       angle = facet->angle( pointPtr );
00391       facet->weight( angle );
00392       totangle += angle;
00393       if(mydebug){
00394         if(angle <= 0.0){
00395           PRINT_INFO("Small angle.\n");
00396         }
00397       }
00398     }
00399       //First...
00400       // Attempt to handle this very odd case.  There is a facet with
00401       // zero area on the boundary.  Set normal to that of an adjacet
00402       // facet that doesn't have zero area.
00403     if(totangle == 0 && bpd_ptr->surfFacetList.size() == 1){
00404       PRINT_WARNING("Degenerate facet on edge of boundary.\n");
00405       facet = bpd_ptr->surfFacetList.get_and_step();
00406       
00407       CubitPoint* my_pt[3];
00408       my_pt[0] = facet->point(0);
00409       my_pt[1] = facet->point(1);
00410       my_pt[2] = facet->point(2);
00411       double largest_area=-1.0;
00412       double current_area=0.0;
00413       if(my_pt[0] == NULL || my_pt[1] == NULL || my_pt[2] == NULL){
00414         PRINT_ERROR("Problem determining normal.\n");
00415         return;
00416       }
00417       
00418       int tmp_i;
00419       for(tmp_i = 0; tmp_i < 3; tmp_i++){
00420         CubitFacet* other_facet = facet->shared_facet(my_pt[tmp_i],
00421                                                       my_pt[(tmp_i+1)%3]);
00422         if(other_facet != NULL){
00423           if(mydebug)
00424             other_facet->debug_draw(CUBIT_WHITE_INDEX);
00425           current_area=other_facet->area();
00426           if(current_area>largest_area){
00427             largest_area=current_area;
00428             normal=other_facet->normal();
00429           }
00430         }
00431       }
00432       if(largest_area < CUBIT_DBL_MIN){
00433         PRINT_ERROR("Could not initialize facet normal.\n");
00434         return;
00435       }
00436       if(mydebug){
00437         facet->debug_draw(CUBIT_RED_INDEX);
00438         PRINT_INFO("\n\nLargest area = %f\n\n",largest_area);
00439         GfxDebug::mouse_xforms();
00440       }
00441       bpd_ptr->normal = normal;
00442               
00443     }
00444       //Now...
00445       // Handle the normal case.
00446     else{
00447       for (j = 0; j < bpd_ptr->surfFacetList.size(); j++)
00448       {
00449         facet = bpd_ptr->surfFacetList.get_and_step();
00450         normal = facet->normal();
00451         normal.normalize();
00452         avg_normal += (facet->weight() / totangle) * normal;
00453       }
00454       avg_normal.normalize();
00455       bpd_ptr->normal = avg_normal;
00456     }
00457   }
00458 }
00459 
00460 //-------------------------------------------------------------------------
00461 // Purpose       : return the boundary point data associated with a facet
00462 //
00463 // Special Notes :
00464 //
00465 // Creator       : Steve Owen
00466 //
00467 // Creation Date : 05/01
00468 //------------------------------------------------------------------------- 
00469 BoundaryPointData *TDFacetBoundaryPoint::get_bpd( CubitFacet *facet )
00470 {
00471   BoundaryPointData *bpd_ptr = NULL;
00472   int found = 0;
00473   int ii, jj;
00474   for (ii=0; ii<pointDataList.size() && !found; ii++)
00475   {
00476     bpd_ptr = pointDataList.get_and_step();
00477     for (jj=0; jj<bpd_ptr->surfFacetList.size() && !found; jj++)
00478     {
00479       if (bpd_ptr->surfFacetList.get_and_step() == facet)
00480         return bpd_ptr;
00481     }
00482   }
00483   
00484   return NULL;
00485 }
00486 
00487 //===============================================================================
00488 //Function:  merge_normals (PRIVATE)
00489 //Description: Enforce continuity across facets by merging the normals at two
00490 //             points.  Assumes the points are coincident.
00491 //Date: 05/01
00492 //===============================================================================
00493 CubitStatus TDFacetBoundaryPoint::merge_normals( 
00494   CubitFacet *facet0,
00495   CubitFacet *facet1)
00496 {
00497 
00498   BoundaryPointData *bpd0_ptr = get_bpd( facet0 );
00499   BoundaryPointData *bpd1_ptr = get_bpd( facet1 );
00500   if (!bpd0_ptr || !bpd1_ptr)
00501     return CUBIT_FAILURE;
00502 
00503   CubitVector avg_normal(0.0e0, 0.0e0, 0.0e0);
00504   double totangle = 0.0e0;
00505   double angle;
00506   CubitFacet *facet;
00507   int j;
00508 
00509   // weight the normal by the spanning angle at the point
00510 
00511   for (j = 0; j < bpd0_ptr->surfFacetList.size(); j++)
00512   {
00513     facet = bpd0_ptr->surfFacetList.get_and_step();
00514     angle = facet->angle( pointPtr );
00515     facet->weight( angle );
00516     totangle += angle;
00517   }
00518 
00519   for (j = 0; j < bpd1_ptr->surfFacetList.size(); j++)
00520   {
00521     facet = bpd1_ptr->surfFacetList.get_and_step();
00522     angle = facet->angle( pointPtr );
00523     facet->weight( angle );
00524     totangle += angle;
00525   }
00526 
00527   // computed weighted normal
00528 
00529   CubitVector normal;
00530   for (j = 0; j < bpd0_ptr->surfFacetList.size(); j++)
00531   {
00532     facet = bpd0_ptr->surfFacetList.get_and_step();
00533     normal = facet->normal();
00534     normal.normalize();
00535     avg_normal += (facet->weight() / totangle) * normal;
00536   }
00537   
00538   // orientation of facets may be opposite on opposing surfaces.
00539   // Check for this case and correct of necessary
00540   
00541   CubitVector norm0, norm1;
00542   norm0 = bpd0_ptr->normal;
00543   norm0.normalize();
00544   norm1 = bpd1_ptr->normal;
00545   norm1.normalize();
00546   double dot = norm0 % norm1;
00547   double sign = 1.0;
00548   if (dot < 0.0)
00549     sign = -1.0;
00550 
00551   for (j = 0; j < bpd1_ptr->surfFacetList.size(); j++)
00552   {
00553     facet = bpd1_ptr->surfFacetList.get_and_step();
00554     normal = sign * facet->normal();
00555     normal.normalize();
00556     avg_normal += (facet->weight() / totangle) * normal;
00557   }
00558 
00559   // set the new normal on both points
00560 
00561   avg_normal.normalize();
00562   bpd0_ptr->normal = avg_normal;
00563   CubitVector temp_vector = sign * avg_normal;
00564   bpd1_ptr->normal = temp_vector;
00565 
00566   return CUBIT_SUCCESS;
00567 }
00568 
00569 //===============================================================================
00570 //Function:  set_uv (PUBLIC)
00571 //Description: set the u-v values on a boundary point data
00572 //Date: 06/01
00573 //===============================================================================
00574 CubitStatus TDFacetBoundaryPoint::set_uv( CubitFacet *adj_facet, 
00575                                           double u, double v )
00576 {
00577   BoundaryPointData *bpd_ptr = get_bpd( adj_facet ); 
00578   if (!bpd_ptr)
00579     return CUBIT_FAILURE;
00580   bpd_ptr->uVal = u;
00581   bpd_ptr->vVal = v;
00582   return CUBIT_SUCCESS;
00583 }
00584 //===============================================================================
00585 //Function:  set_uvs (PUBLIC)
00586 //Description: set the u-v values and size on a boundary point data
00587 //Date: 06/01
00588 //===============================================================================
00589 CubitStatus TDFacetBoundaryPoint::set_uvs( CubitFacet *adj_facet, 
00590                                           double u, double v, double s )
00591 {
00592   BoundaryPointData *bpd_ptr = get_bpd( adj_facet ); 
00593   if (!bpd_ptr)
00594     return CUBIT_FAILURE;
00595   bpd_ptr->uVal = u;
00596   bpd_ptr->vVal = v;
00597   bpd_ptr->sizeVal = s;
00598   return CUBIT_SUCCESS;
00599 }
00600 //===============================================================================
00601 //Function:  u (PUBLIC)
00602 //Description: get the u value from a boundary point data
00603 //Date: 06/01
00604 //===============================================================================
00605 double TDFacetBoundaryPoint::u( CubitFacet *adj_facet )
00606 {
00607   BoundaryPointData *bpd_ptr = get_bpd( adj_facet );                   
00608   assert( bpd_ptr != 0 );  // adjacent facet was not found in list
00609   return bpd_ptr->uVal;
00610 }
00611 
00612 //===============================================================================
00613 //Function:  v (PUBLIC)
00614 //Description: get the v value from a boundary point data
00615 //Date: 06/01
00616 //===============================================================================
00617 double TDFacetBoundaryPoint::v( CubitFacet *adj_facet )
00618 {
00619   BoundaryPointData *bpd_ptr = get_bpd( adj_facet );                   
00620   assert( bpd_ptr != 0 );  // adjacent facet was not found in list
00621   return bpd_ptr->vVal;
00622 }
00623 //===============================================================================
00624 //Function:  s (PUBLIC)
00625 //Description: get the s value from a boundary point data
00626 //Date: 07/02
00627 //===============================================================================
00628 double TDFacetBoundaryPoint::s( CubitFacet *adj_facet )
00629 {
00630   BoundaryPointData *bpd_ptr = get_bpd( adj_facet );                   
00631   assert( bpd_ptr != 0 );  // adjacent facet was not found in list
00632   return bpd_ptr->sizeVal;
00633 }
00634 //===============================================================================
00635 //Function:  get_uv (PUBLIC)
00636 //Description: get the uv values from a boundary point data
00637 //Date: 06/01
00638 //===============================================================================
00639 CubitStatus TDFacetBoundaryPoint::get_uv( CubitFacet *adj_facet, 
00640                                           double &u, double &v )
00641 {
00642   BoundaryPointData *bpd_ptr = get_bpd( adj_facet );                   
00643   if (!bpd_ptr)
00644     return CUBIT_FAILURE;
00645   u = bpd_ptr->uVal;
00646   v = bpd_ptr->vVal;
00647   return CUBIT_SUCCESS;
00648 }
00649 
00650 //===============================================================================
00651 //Function:  get_uvs (PUBLIC)
00652 //Description: get the uv values and size from a boundary point data
00653 //Date: 7/02
00654 //===============================================================================
00655 CubitStatus TDFacetBoundaryPoint::get_uvs( CubitFacet *adj_facet, 
00656                                           double &u, double &v, double &s )
00657 {
00658   BoundaryPointData *bpd_ptr = get_bpd( adj_facet );                   
00659   if (!bpd_ptr)
00660     return CUBIT_FAILURE;
00661   u = bpd_ptr->uVal;
00662   v = bpd_ptr->vVal;
00663   s = bpd_ptr->sizeVal;
00664   return CUBIT_SUCCESS;
00665 }
00666 
00667 //===============================================================================
00668 //Function:  rotate_normal (PUBLIC)
00669 //Description: rotate the normal at this point
00670 //Date: 03/02
00671 //===============================================================================
00672 CubitStatus TDFacetBoundaryPoint::rotate_normal( CubitTransformMatrix &rotmat )
00673 {
00674   BoundaryPointData * bpd_ptr;
00675   
00676   int ii;
00677   for (ii=0; ii<pointDataList.size(); ii++)
00678   {
00679     bpd_ptr = pointDataList.get_and_step();
00680     bpd_ptr->normal = rotmat * bpd_ptr->normal;
00681   }
00682   return CUBIT_SUCCESS;
00683 }
00684 
00685 //===============================================================================
00686 //Function:  get_boundary_point_data_size (PUBLIC)
00687 //Description: get the size of the boundary point data for mem alloc. purposes
00688 //Date: 01/23/2003
00689 //===============================================================================
00690 CubitStatus TDFacetBoundaryPoint::get_boundary_point_data_size( 
00691    int &size_int_data,
00692    int &size_double_data )
00693 {
00694    int num_bpd = pointDataList.size();
00695    int ii;
00696    BoundaryPointData *bpd_ptr;
00697 
00698    //pointPtr->id() and pointDataList.size()
00699    size_int_data += 2;
00700    for (ii=0; ii<num_bpd; ii++)
00701    {
00702      size_int_data += 2;
00703      bpd_ptr = pointDataList.get_and_step();
00704      //num_surfaces
00705      size_int_data += bpd_ptr->surfFacetList.size();
00706    }
00707    size_double_data += num_bpd * 6;
00708    return CUBIT_SUCCESS;
00709 }
00710                                                    
00711 //===============================================================================
00712 //Function:  get_boundary_point_data (PUBLIC)
00713 //Description: retreive the boundary point data so it can be dumped to a file
00714 //             data must be allocated prior to calling this function!
00715 //Date: 01/23/2003
00716 //===============================================================================
00717 CubitStatus TDFacetBoundaryPoint::get_boundary_point_data(int *int_data,
00718                                                           double *double_data,
00719                                                           int &iidx,
00720                                                           int &didx )
00721 {
00722   int_data[iidx++] = pointPtr->id();
00723   int num_bpd = pointDataList.size();
00724   int_data[iidx++] = num_bpd;
00725   
00726   BoundaryPointData *bpd_ptr;
00727   int ii, jj;
00728   int numfacs = 0;
00729   CubitFacet *facet_ptr;
00730   for (ii=0; ii<num_bpd; ii++)
00731   {
00732     bpd_ptr = pointDataList.get_and_step();
00733     numfacs = bpd_ptr->surfFacetList.size();
00734     int_data[iidx++] = numfacs;
00735     for (jj=0; jj<bpd_ptr->surfFacetList.size(); jj++)
00736     {
00737       facet_ptr = bpd_ptr->surfFacetList.get_and_step();
00738       int_data[iidx++] = facet_ptr->id();
00739     }
00740     int_data[iidx++] = bpd_ptr->surfID;
00741     
00742     double_data[didx++] = bpd_ptr->normal.x();
00743     double_data[didx++] = bpd_ptr->normal.y();
00744     double_data[didx++] = bpd_ptr->normal.z();
00745     double_data[didx++] = bpd_ptr->sizeVal;
00746     double_data[didx++] = bpd_ptr->uVal;
00747     double_data[didx++] = bpd_ptr->vVal;
00748   }
00749   return CUBIT_SUCCESS;
00750 }
00751 
00752 //===============================================================================
00753 //Function:  new_boundary_point_data (static PUBLIC)
00754 //Description: create a new boundary point data and assign to a cubit point
00755 //Author: sjowen
00756 //Date: 01/26/2003
00757 //===============================================================================
00758 CubitStatus TDFacetBoundaryPoint::new_facet_boundary_point(CubitPoint **points,
00759                                                            CubitFacet **facets,
00760                                                            int &iidx,
00761                                                            int &didx,
00762                                                            int *int_data,
00763                                                            double *double_data)
00764 {
00765   int id = int_data[iidx++];
00766   CubitPoint *point_ptr = points[id];
00767   TDFacetBoundaryPoint::add_facet_boundary_point(point_ptr);
00768   TDFacetBoundaryPoint *td = (TDFacetBoundaryPoint *)
00769     point_ptr->get_TD( &TDFacetBoundaryPoint::is_facet_boundary_point);
00770 
00771   td->initialize( facets, iidx, didx, int_data, double_data );
00772 
00773   return CUBIT_SUCCESS;
00774 }
00775 
00776 //===============================================================================
00777 //Function:  initialize (PUBLIC)
00778 //Description: initialize a boundary point data from data read from a CUB file
00779 //Author: sjowen
00780 //Date: 01/26/2003
00781 //===============================================================================
00782 void TDFacetBoundaryPoint::initialize(CubitFacet **facets,
00783                                       int &iidx,
00784                                       int &didx,
00785                                       int *int_data,
00786                                       double *double_data)
00787 {
00788   int num_bpd = int_data[iidx++];
00789   
00790   BoundaryPointData *bpd_ptr;
00791   int ii, jj, id;
00792   int numfacs = 0;
00793   CubitFacet *facet_ptr;
00794   for (ii=0; ii<num_bpd; ii++)
00795   {
00796     bpd_ptr = new BoundaryPointData;
00797     pointDataList.append(bpd_ptr);
00798     numfacs = int_data[iidx++];
00799     for (jj=0; jj<numfacs; jj++)
00800     {
00801       id = int_data[iidx++];
00802       facet_ptr = facets[id];
00803       bpd_ptr->surfFacetList.append(facet_ptr);
00804     }
00805     bpd_ptr->surfID = int_data[iidx++];
00806     
00807     bpd_ptr->normal.x(double_data[didx++]);
00808     bpd_ptr->normal.y(double_data[didx++]);
00809     bpd_ptr->normal.z(double_data[didx++]);
00810     bpd_ptr->sizeVal = double_data[didx++];
00811     bpd_ptr->uVal = double_data[didx++];
00812     bpd_ptr->vVal = double_data[didx++];
00813   }
00814 
00815 }
00816 
00817 // eof
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines