cgma
|
00001 #include "CubitPoint.hpp" 00002 #include "CubitFacet.hpp" 00003 #include "CubitFacetEdge.hpp" 00004 #include "TDFacetBoundaryPoint.hpp" 00005 #include "CubitTransformMatrix.hpp" 00006 #include "GfxDebug.hpp" 00007 #include "CubitQuadFacet.hpp" 00008 #include "GeometryDefines.h" 00009 00010 double CubitPoint::boxTol = GEOMETRY_RESABS; 00011 00012 //=========================================================================== 00013 // Function Name: CubitPoint 00014 // 00015 // Member Type: PUBLIC 00016 // Description: constructor 00017 // Author: 00018 // Date: 00019 //=========================================================================== 00020 CubitPoint::CubitPoint() 00021 : markedFlag(0), surfNormal(NULL), dCoef(0.0), 00022 uVal(0.0), vVal(0.0), sizeVal(0.0), 00023 surfU(NULL), surfV(NULL), 00024 coefVector(NULL), isFeature(0) 00025 { 00026 } 00027 00028 //=========================================================================== 00029 // Function Name: ~CubitPoint 00030 // 00031 // Member Type: PUBLIC 00032 // Description: destructor 00033 // Author: 00034 // Date: 00035 //=========================================================================== 00036 CubitPoint::~CubitPoint() 00037 { 00038 if (surfNormal) { 00039 delete surfNormal; 00040 } 00041 if (surfU) { 00042 delete surfU; 00043 } 00044 if (surfV) { 00045 delete surfV; 00046 } 00047 if (coefVector) { 00048 delete coefVector; 00049 } 00050 } 00051 00052 //=========================================================================== 00053 // Function Name: shared_facets 00054 // 00055 // Member Type: PUBLIC 00056 // Description: return the facets sharing this point and another point 00057 // Author: 00058 // Date: 00059 //=========================================================================== 00060 void CubitPoint::shared_facets( 00061 CubitPoint* other_pt, 00062 CubitFacet *& f1, 00063 CubitFacet*& f2 ) 00064 { 00065 f1 = f2 = 0; 00066 DLIList <CubitFacet *> attached_facets; 00067 facets( attached_facets ); 00068 if( attached_facets.size() > 0 && other_pt ) 00069 { 00070 for( int i = attached_facets.size(); i > 0; i-- ) 00071 { 00072 CubitFacet* facet = attached_facets.get_and_step(); 00073 if( facet->contains( other_pt ) ) 00074 { 00075 //three facets?? 00076 assert( !f2 ); 00077 00078 if( f1 ) f2 = facet; 00079 else f1 = facet; 00080 } 00081 } 00082 } 00083 } 00084 void CubitPoint::shared_facets( 00085 CubitPoint* other_pt, DLIList<CubitFacet*>& result_set ) 00086 { 00087 DLIList <CubitFacet *> attached_facets; 00088 facets( attached_facets ); 00089 if( attached_facets.size() > 0 && other_pt ) 00090 { 00091 for( int i = attached_facets.size(); i > 0; i-- ) 00092 { 00093 CubitFacet* facet = attached_facets.get_and_step(); 00094 if( facet->contains( other_pt ) ) 00095 { 00096 result_set.append( facet ); 00097 } 00098 } 00099 } 00100 } 00101 00102 00103 //=========================================================================== 00104 // Function Name: shared_edge 00105 // 00106 // Member Type: PUBLIC 00107 // Description: return the edge sharing this point and another point and 00108 // assumes there is only one edge shared by two points 00109 // Author: chynes 00110 // Date: 6/6/2002 00111 //=========================================================================== 00112 CubitFacetEdge * CubitPoint::shared_edge( CubitPoint* other_pt ) 00113 { 00114 00115 // CubitFacetEdge *edge = NULL; 00116 // DLIList <CubitFacetEdge *> attached_edges; 00117 // edges( attached_edges ); 00118 // if( attached_edges.size() > 0 && other_pt ) 00119 // { 00120 // for( int i = attached_edges.size(); i > 0; i-- ) 00121 // { 00122 // edge = attached_edges.get_and_step(); 00123 // if( edge->contains( other_pt ) ) 00124 // { 00125 // return edge; 00126 // } 00127 // } 00128 // } 00129 // return edge; 00130 return get_edge(other_pt); 00131 00132 } 00133 00134 00135 //=========================================================================== 00136 // Function Name: normal 00137 // 00138 // Member Type: PUBLIC 00139 // Description: return the facet normal with respect to the surface the 00140 // facet is on 00141 // Author: 00142 // Date: 00143 //=========================================================================== 00144 CubitVector CubitPoint::normal( CubitFacet *facet_ptr ) 00145 { 00146 TDFacetBoundaryPoint *td_bfp = 00147 TDFacetBoundaryPoint::get_facet_boundary_point( this ); 00148 if (td_bfp == NULL) 00149 { 00150 return normal(); 00151 } 00152 else 00153 { 00154 CubitVector norm; 00155 td_bfp->get_normal( facet_ptr, norm ); 00156 return norm; 00157 } 00158 } 00159 00160 //=========================================================================== 00161 // Function Name: normal 00162 // 00163 // Member Type: PUBLIC 00164 // Description: return the facet normal with respect to the surface the 00165 // quad facet is on 00166 // Author: 00167 // Date: 00168 //=========================================================================== 00169 CubitVector CubitPoint::normal( CubitQuadFacet *qfacet_ptr ) 00170 { 00171 CubitFacet *facet_ptr = qfacet_ptr->get_tri_facet_at_point( this ); 00172 return normal( facet_ptr ); 00173 } 00174 00175 00176 //=========================================================================== 00177 // Function Name: normal 00178 // 00179 // Member Type: PUBLIC 00180 // Description: return the facet normal with respect to the surface the 00181 // facet is on 00182 // Author: 00183 // Date: 00184 //=========================================================================== 00185 CubitVector CubitPoint::normal( CubitFacetEdge *edge_ptr ) 00186 { 00187 TDFacetBoundaryPoint *td_bfp = 00188 TDFacetBoundaryPoint::get_facet_boundary_point( this ); 00189 if (td_bfp == NULL) 00190 { 00191 return normal(); 00192 } 00193 else 00194 { 00195 CubitVector norm; 00196 td_bfp->get_normal( edge_ptr, norm ); 00197 return norm; 00198 } 00199 } 00200 00201 //=========================================================================== 00202 // Function Name: tangent 00203 // 00204 // Member Type: PUBLIC 00205 // Description: return tangent with respect to the edge 00206 // Notes : min_dot is the cosine of the feature angle. Tangent vector 00207 // will use the feature angle to determine tangent 00208 // Author: sjowen 00209 // Date: 10/28/2002 00210 //=========================================================================== 00211 CubitVector CubitPoint::tangent( CubitFacetEdge *edge_ptr, 00212 double min_dot ) 00213 { 00214 CubitPoint *p0 = edge_ptr->point( 0 ); 00215 CubitPoint *p1 = edge_ptr->point( 1 ); 00216 int ii; 00217 00218 assert( p0 == this || p1 == this ); // the point isn't on the edge 00219 00220 // if this isn't a feature edge, just return the tangent vector of 00221 // the edge. Otherwise compute the tangent based on neighboring 00222 // feature edges 00223 00224 CubitVector pt_tangent; 00225 if (!edge_ptr->is_feature()) 00226 { 00227 CubitVector tmp_vec = coordinates(); 00228 00229 edge_ptr->edge_tangent( tmp_vec, pt_tangent ); 00230 } 00231 else 00232 { 00233 // compute tangent for feature edge at previous 00234 if (p0 == this) 00235 { 00236 CubitFacetEdge *prev_edge; 00237 DLIList <CubitFacetEdge *>feature_edge_list; 00238 next_feature_edges( edge_ptr, feature_edge_list ); 00239 00240 // average the edges that meet the min_dot criteria 00241 CubitVector e1 = p1->coordinates() - p0->coordinates(); 00242 pt_tangent = e1; 00243 e1.normalize(); 00244 for (ii=0; ii<feature_edge_list.size(); ii++) 00245 { 00246 prev_edge = feature_edge_list.get_and_step(); 00247 CubitPoint *p2 = prev_edge->other_point( p0 ); 00248 CubitVector e0 = p0->coordinates() - p2->coordinates(); 00249 e0.normalize(); 00250 if (e0 % e1 >= min_dot) 00251 { 00252 pt_tangent += (p0->coordinates() - p2->coordinates()); 00253 } 00254 } 00255 if (feature_edge_list.size() == 0) 00256 pt_tangent = e1; 00257 else 00258 pt_tangent.normalize(); 00259 } 00260 00261 // compute tangent for feature edge at next 00262 else if (p1 == this) 00263 { 00264 CubitFacetEdge *next_edge; 00265 DLIList <CubitFacetEdge *>feature_edge_list; 00266 next_feature_edges( edge_ptr, feature_edge_list ); 00267 00268 // average the edges that meet the min_dot criteria 00269 CubitVector e1 = p1->coordinates() - p0->coordinates(); 00270 pt_tangent = e1; 00271 e1.normalize(); 00272 for (ii=0; ii<feature_edge_list.size(); ii++) 00273 { 00274 next_edge = feature_edge_list.get_and_step(); 00275 CubitPoint *p2 = next_edge->other_point( p1 ); 00276 CubitVector e0 = p2->coordinates() - p1->coordinates(); 00277 e0.normalize(); 00278 if (e0 % e1 >= min_dot) 00279 { 00280 pt_tangent += (p2->coordinates() - p1->coordinates()); 00281 } 00282 } 00283 if (feature_edge_list.size() == 0) 00284 pt_tangent = e1; 00285 else 00286 pt_tangent.normalize(); 00287 } 00288 } 00289 return pt_tangent; 00290 } 00291 00292 //=========================================================================== 00293 //Function Name: next_feature_edges 00294 // 00295 //Member Type: PRIVATE 00296 //Descriptoin: given a facet boundary edge and this point, get a list 00297 // of the next fetaure edges at this point 00298 //=========================================================================== 00299 void CubitPoint::next_feature_edges( 00300 CubitFacetEdge *this_edge_ptr, 00301 DLIList <CubitFacetEdge *> feature_edge_list ) 00302 { 00303 //CubitFacetEdge *next_edge_ptr = NULL; 00304 00305 DLIList<CubitFacetEdge*> edge_list; 00306 edges( edge_list ); 00307 int ii; 00308 00309 CubitFacetEdge *edge_ptr = NULL; 00310 for (ii=0; ii<edge_list.size(); ii++) 00311 { 00312 edge_ptr = edge_list.get_and_step(); 00313 if (edge_ptr != this_edge_ptr) 00314 { 00315 if (edge_ptr->is_feature()) 00316 { 00317 feature_edge_list.append(edge_ptr); 00318 } 00319 } 00320 } 00321 } 00322 00323 //=========================================================================== 00324 // Function Name: project_to_tangent_plane 00325 // 00326 // Member Type: PUBLIC 00327 // Descriptoin: Project a point to the tangent plane defined at the CubitPoint 00328 // Author: sjowen 00329 // Date: 06/28/00 00330 //=========================================================================== 00331 CubitVector CubitPoint::project_to_tangent_plane( CubitVector &pt ) 00332 { 00333 CubitVector surf_normal = normal(); 00334 double dist = (surf_normal)%pt + d_coef(); 00335 CubitVector point_on_plane( pt.x() - surf_normal.x() * dist, 00336 pt.y() - surf_normal.y() * dist, 00337 pt.z() - surf_normal.z() * dist ); 00338 return point_on_plane; 00339 } 00340 00341 //=========================================================================== 00342 // Function Name: adjacent_points 00343 // 00344 // Member Type: PUBLIC 00345 // Description: return array of points sharing adjacent facets 00346 // Author: sjowen 00347 // Date: 06/28/00 00348 //=========================================================================== 00349 void CubitPoint::adjacent_points( CubitPoint **adj_points, 00350 int &num_adj_points ) 00351 { 00352 int i, j, k, index = -1, nextindex = -1; 00353 CubitBoolean found; 00354 CubitFacet *facet; 00355 num_adj_points = 0; 00356 DLIList <CubitFacet *> attached_facets; 00357 facets( attached_facets ); 00358 for(i=0; i<attached_facets.size(); i++) { 00359 facet = attached_facets.get_and_step(); 00360 found = CUBIT_FALSE; 00361 for (j=0; j<3 && !found; j++) { 00362 if (facet->point(j) == this) { 00363 index = (j+1)%3; 00364 nextindex = (j+2)%3; 00365 found = CUBIT_TRUE; 00366 } 00367 } 00368 if (found) { 00369 found = CUBIT_FALSE; 00370 adj_points[num_adj_points++] = facet->point(index); 00371 for (k=0; k<num_adj_points-1 && !found; k++) { 00372 if(adj_points[k] == facet->point(nextindex)){ 00373 found = CUBIT_TRUE; 00374 } 00375 } 00376 if (!found) { 00377 adj_points[num_adj_points++] = facet->point(nextindex); 00378 } 00379 } 00380 } 00381 } 00382 void CubitPoint::adjacent_points( DLIList<CubitPoint*>& result ) 00383 { 00384 DLIList <CubitFacet *> attached_facets; 00385 facets( attached_facets ); 00386 for( int i = attached_facets.size(); i--; ) 00387 { 00388 CubitPoint *pt1, *pt2; 00389 attached_facets.get_and_step()->opposite_edge( this, pt1, pt2 ); 00390 result.append_unique(pt1); 00391 result.append_unique(pt2); 00392 } 00393 } 00394 00395 //=========================================================================== 00396 // Function Name: define_tangent_vectors 00397 // 00398 // Member Type: PUBLIC 00399 // Description: define the surface tangent vectors at a point 00400 // Author: sjowen 00401 // Date: 06/28/00 00402 //=========================================================================== 00403 void CubitPoint::define_tangent_vectors() 00404 { 00405 // define orthogonal vectors to the normal that are tangent to the 00406 // the surface. Note that du and dv are not defined in any global 00407 // parametric space - they are only defined locally. Their directions 00408 // are defined arbitrarily in the tangent plane by taking the smallest 00409 // components of the normal vector and setting them to "1" for the 00410 // du vector and then solving for the other component so that the 00411 // dot product of du and the normal will be zero. dv is just the cross 00412 // product of the normal and du 00413 00414 CubitVector absnorm, duvec, dvvec; 00415 CubitVector surf_normal = normal(); 00416 absnorm.x( fabs(surf_normal.x()) ); 00417 absnorm.y( fabs(surf_normal.y()) ); 00418 absnorm.z( fabs(surf_normal.z()) ); 00419 if (absnorm.x() >= absnorm.y() && absnorm.x() >= absnorm.z()) { 00420 duvec.x( (-surf_normal.y() - surf_normal.z()) / surf_normal.x() ); 00421 duvec.y( 1.0e0 ); 00422 duvec.z( 1.0e0 ); 00423 } 00424 else if (absnorm.y() >= absnorm.z() ) { 00425 duvec.x( 1.0e0 ); 00426 duvec.y( (-surf_normal.x() - surf_normal.z()) / surf_normal.y() ); 00427 duvec.z( 1.0e0 ); 00428 } 00429 else { 00430 duvec.x( 1.0e0 ); 00431 duvec.y( 1.0e0 ); 00432 duvec.z( (-surf_normal.x() - surf_normal.y()) / surf_normal.z() ); 00433 } 00434 duvec.normalize(); 00435 dvvec = surf_normal * duvec; 00436 00437 // //sjowen debug 00438 // CubitVector test = dvvec * surf_normal; 00439 // double dot = test % duvec; 00440 // if (dot < 0.999999999999) { 00441 // PRINT_ERROR("Error in define_tangent_vectors"); 00442 // } 00443 00444 du( duvec ); 00445 dv( dvvec ); 00446 } 00447 00448 //=========================================================================== 00449 // Function Name: transform_to_local 00450 // 00451 // Member Type: PUBLIC 00452 // Description: transform a vector from global to local system 00453 // Author: sjowen 00454 // Date: 06/28/00 00455 //=========================================================================== 00456 void CubitPoint::transform_to_local( CubitVector &glob_vec, 00457 CubitVector &loc_vec ) 00458 { 00459 // Translate to local origin at point 00460 00461 CubitVector vect = glob_vec - this->coordinates(); 00462 00463 // Multiply by transpose (inverse) of transformation vector */ 00464 00465 loc_vec.x( vect % du() ); 00466 loc_vec.y( vect % dv() ); 00467 loc_vec.z( vect % normal() ); 00468 } 00469 00470 //=========================================================================== 00471 // Function Name: transform_to_global 00472 // 00473 // Member Type: PUBLIC 00474 // Description: transform a vector from local to global system 00475 // Author: sjowen 00476 // Date: 06/28/00 00477 //=========================================================================== 00478 void CubitPoint::transform_to_global( CubitVector &loc_vec, 00479 CubitVector &glob_vec ) 00480 { 00481 // Multiply by transformation matrix 00482 00483 CubitVector vect; 00484 CubitVector surf_u = du(); 00485 CubitVector surf_v = dv(); 00486 CubitVector surf_normal = normal(); 00487 vect.x( loc_vec.x() * surf_u.x ()+ 00488 loc_vec.y() * surf_v.x() + 00489 loc_vec.z() * surf_normal.x() ); 00490 vect.y( loc_vec.x() * surf_u.y ()+ 00491 loc_vec.y() * surf_v.y() + 00492 loc_vec.z() * surf_normal.y() ); 00493 vect.z( loc_vec.x() * surf_u.z ()+ 00494 loc_vec.y() * surf_v.z() + 00495 loc_vec.z() * surf_normal.z() ); 00496 00497 // Translate from origin 00498 00499 glob_vec = vect + this->coordinates(); 00500 } 00501 00502 //=========================================================================== 00503 // Function Name: get_parents 00504 // 00505 // Member Type: PUBLIC 00506 // Description: get the list of attached edges 00507 // Author: sjowen 00508 // Date: 06/28/00 00509 //=========================================================================== 00510 void CubitPoint::get_parents( DLIList<FacetEntity*> &facet_list ) 00511 { 00512 DLIList<CubitFacetEdge*> edge_list; 00513 edges( edge_list ); 00514 int ii; 00515 for (ii=0; ii<edge_list.size(); ii++) 00516 facet_list.append( edge_list.get_and_step() ); 00517 } 00518 00519 //=========================================================================== 00520 // Function Name: draw 00521 // 00522 // Member Type: PUBLIC 00523 // Description: debug drawing 00524 // Author: sjowen 00525 // Date: 5/01 00526 //=========================================================================== 00527 void CubitPoint::debug_draw( int color, int flush, int /*draw_uv*/ ) 00528 { 00529 if ( color == -1 ) 00530 color = CUBIT_YELLOW_INDEX; 00531 CubitVector vec = this->coordinates(); 00532 GfxDebug::draw_point(vec, color); 00533 if (flush) 00534 GfxDebug::flush(); 00535 } 00536 00537 //=========================================================================== 00538 // Function Name: normal 00539 // 00540 // Member Type: PUBLIC 00541 // Description: set the normal of the surface at the point. Allocate a 00542 // new normal vector if necessary 00543 // Author: 00544 // Date: 00545 //=========================================================================== 00546 void CubitPoint::compute_avg_normal() 00547 { 00548 int j; 00549 DLIList<CubitFacet*> adj_facet_list; 00550 facets(adj_facet_list); 00551 if (adj_facet_list.size() > 0) { 00552 CubitVector avg_normal(0.0e0, 0.0e0, 0.0e0); 00553 double totangle = 0.0e0; 00554 00555 // weight the normal by the spanning angle at the point 00556 00557 for (j = 0; j < adj_facet_list.size(); j++) 00558 { 00559 CubitFacet* facet = adj_facet_list.get_and_step(); 00560 double angle = facet->angle( this ); 00561 facet->weight( angle ); 00562 totangle += angle; 00563 } 00564 for (j = 0; j < adj_facet_list.size(); j++) 00565 { 00566 CubitFacet* facet = adj_facet_list.get_and_step(); 00567 CubitVector normal = facet->normal(); 00568 normal.normalize(); 00569 avg_normal += (facet->weight() / totangle) * normal; 00570 } 00571 avg_normal.normalize(); 00572 if(!surfNormal) { 00573 surfNormal = new CubitVector ( avg_normal ); 00574 } 00575 else 00576 { 00577 *surfNormal = avg_normal; 00578 } 00579 dCoef = -(this->coordinates()%avg_normal); 00580 } 00581 } 00582 00583 //=========================================================================== 00584 // Function Name: facets_on_surf 00585 // 00586 // Member Type: PUBLIC 00587 // Description: return facets adjacent this point that are on the given 00588 // surface 00589 // surf_id is the FacetEvalTool ToolID 00590 // Author: sjowen 00591 // Date: 6/26/01 00592 //=========================================================================== 00593 CubitBox CubitPoint::bounding_box( ) 00594 { 00595 CubitVector ptmin( coordinates().x() - boxTol, 00596 coordinates().y() - boxTol, 00597 coordinates().z() - boxTol ); 00598 CubitVector ptmax( coordinates().x() + boxTol, 00599 coordinates().y() + boxTol, 00600 coordinates().z() + boxTol ); 00601 CubitBox ptbox( ptmin, ptmax ); 00602 return ptbox; 00603 } 00604 00605 //=========================================================================== 00606 // Function Name: facets_on_surf 00607 // 00608 // Member Type: PUBLIC 00609 // Description: return facets adjacent this point that are on the given 00610 // surface 00611 // surf_id is the FacetEvalTool ToolID 00612 // Author: sjowen 00613 // Date: 6/26/01 00614 //=========================================================================== 00615 void CubitPoint::facets_on_surf( int surf_id, 00616 DLIList<CubitFacet *> &facet_list, 00617 CubitBoolean &on_internal_boundary ) 00618 { 00619 DLIList<CubitFacet *>all_facets; 00620 facets( all_facets ); 00621 int ii; 00622 CubitFacet *facet; 00623 for (ii=0; ii<all_facets.size(); ii++) 00624 { 00625 facet = all_facets.get_and_step(); 00626 if (facet->tool_id() == surf_id) 00627 { 00628 facet_list.append( facet ); 00629 } 00630 } 00631 if (facet_list.size() == 0) 00632 { 00633 on_internal_boundary = CUBIT_FALSE; 00634 } 00635 else if (all_facets.size() == facet_list.size()) 00636 { 00637 on_internal_boundary = CUBIT_FALSE; 00638 } 00639 else 00640 { 00641 on_internal_boundary = CUBIT_TRUE; 00642 } 00643 } 00644 00645 //=========================================================================== 00646 // Function Name: get_uv 00647 // 00648 // Member Type: PUBLIC 00649 // Description: return the u-v coordinates for the surface the facet is on 00650 // - assumes facet is adjacent to this point 00651 // Author: sjowen 00652 // Date: 6/26/01 00653 //=========================================================================== 00654 CubitStatus CubitPoint::get_uv( CubitFacet *facet, double &u, double &v ) 00655 { 00656 CubitStatus stat; 00657 TDFacetBoundaryPoint *td_bfp = 00658 TDFacetBoundaryPoint::get_facet_boundary_point( this ); 00659 if (!td_bfp) 00660 { 00661 u = uVal; 00662 v = vVal; 00663 stat = CUBIT_SUCCESS; 00664 } 00665 else 00666 { 00667 stat = td_bfp->get_uv( facet, u, v ); 00668 } 00669 return stat; 00670 } 00671 00672 //=========================================================================== 00673 // Function Name: get_uvs 00674 // 00675 // Member Type: PUBLIC 00676 // Description: return the u-v coordinates and size for the surface the facet is on 00677 // - assumes facet is adjacent to this point 00678 // Author: chynes 00679 // Date: 7/16/02 00680 //=========================================================================== 00681 CubitStatus CubitPoint::get_uvs( CubitFacet *facet, double &u, double &v, double &s ) 00682 { 00683 CubitStatus stat; 00684 TDFacetBoundaryPoint *td_bfp = 00685 TDFacetBoundaryPoint::get_facet_boundary_point( this ); 00686 if (!td_bfp) 00687 { 00688 u = uVal; 00689 v = vVal; 00690 s = sizeVal; 00691 stat = CUBIT_SUCCESS; 00692 } 00693 else 00694 { 00695 stat = td_bfp->get_uvs( facet, u, v, s ); 00696 } 00697 return stat; 00698 } 00699 //=========================================================================== 00700 // Function Name: merge_points 00701 // 00702 // Member Type: PUBLIC 00703 // Description: merge two points 00704 // Author: sjowen 00705 // Date: 9/18/01 00706 //=========================================================================== 00707 CubitStatus CubitPoint::merge_points( CubitPoint * /*cp*/, CubitBoolean /* keep_point */ ) 00708 { 00709 // this virtual function must be defined in the inheriting class if you get here 00710 assert(0); 00711 return CUBIT_FAILURE; 00712 } 00713 00714 //=========================================================================== 00715 // Function Name: get_edge 00716 // 00717 // Member Type: PUBLIC 00718 // Description: return the CubitFacetEdge between the two points (if there is one) 00719 // Author: sjowen 00720 // Date: 9/25/01 00721 //=========================================================================== 00722 CubitFacetEdge *CubitPoint::get_edge( CubitPoint *other_point ) 00723 { 00724 DLIList<CubitFacetEdge *>edge_list; 00725 edges(edge_list); 00726 int ii; 00727 CubitFacetEdge *edge_ptr; 00728 for (ii=0; ii<edge_list.size(); ii++) 00729 { 00730 edge_ptr = edge_list.get_and_step(); 00731 if (edge_ptr->other_point( this ) == other_point) 00732 return edge_ptr; 00733 } 00734 return (CubitFacetEdge *)NULL; 00735 } 00736 00737 //=========================================================================== 00738 // Function Name: transform 00739 // 00740 // Member Type: PUBLIC 00741 // Description: transform the location of the point 00742 // Author: sjowen 00743 // Date: 3/16/02 00744 //=========================================================================== 00745 void CubitPoint::transform(CubitTransformMatrix &tfmat) 00746 { 00747 CubitVector loc; 00748 loc = tfmat * coordinates(); 00749 set( loc ); 00750 } 00751 00752 //=========================================================================== 00753 // Function Name: rotate_normal 00754 // 00755 // Member Type: PUBLIC 00756 // Description: transform the location of the point 00757 // Author: sjowen 00758 // Date: 3/16/02 00759 //=========================================================================== 00760 void CubitPoint::rotate_normal(CubitTransformMatrix &rotmat) 00761 { 00762 if (surfNormal) 00763 { 00764 *surfNormal = rotmat * (*surfNormal); 00765 } 00766 TDFacetBoundaryPoint *td = TDFacetBoundaryPoint::get_facet_boundary_point( this ); 00767 if (td) 00768 { 00769 td->rotate_normal(rotmat); 00770 } 00771 } 00772 00773 //=========================================================================== 00774 // Function Name: check_inverted_facets 00775 // 00776 // Member Type: PUBLIC 00777 // Description: check if moving a point will invert facets 00778 // Author: jakraft 00779 // Date: 05/09/03 00780 //=========================================================================== 00781 CubitStatus CubitPoint::check_inverted_facets( const CubitVector& pos ) 00782 { 00783 DLIList<CubitFacet*> facets; 00784 this->facets(facets); 00785 while( facets.size() ) 00786 { 00787 CubitFacet* facet = facets.pop(); 00788 int index = facet->point_index(this); 00789 CubitVector corner = facet->point((index+1)%3)->coordinates(); 00790 CubitVector opposite_edge = facet->point((index+2)%3)->coordinates(); 00791 opposite_edge -= corner; 00792 CubitVector old_edge = corner - coordinates(); 00793 CubitVector new_edge = corner - pos; 00794 old_edge *= opposite_edge; 00795 new_edge *= opposite_edge; 00796 if ( (old_edge % new_edge) <= 0.0 ) 00797 return CUBIT_FAILURE; 00798 } 00799 return CUBIT_SUCCESS; 00800 } 00801 00802 //EOF 00803