cgma
|
#include <CurveFacetEvalTool.hpp>
Definition at line 26 of file CurveFacetEvalTool.hpp.
Definition at line 150 of file CurveFacetEvalTool.cpp.
{ static int counter = 0; toolID = counter++; myBBox = NULL; goodCurveData = CUBIT_TRUE; }
Definition at line 164 of file CurveFacetEvalTool.cpp.
{ if ( myBBox ) delete myBBox; destroy_facets(); }
CubitBox CurveFacetEvalTool::bounding_box | ( | void | ) |
Definition at line 578 of file CurveFacetEvalTool.cpp.
{ if ( !myBBox ) { int ii; CubitPoint *point_ptr; double x, y, z; double x_min = CUBIT_DBL_MAX, x_max = -CUBIT_DBL_MAX; double y_min = CUBIT_DBL_MAX, y_max = -CUBIT_DBL_MAX; double z_min = CUBIT_DBL_MAX, z_max = -CUBIT_DBL_MAX; for ( ii = myPointList.size(); ii > 0; ii-- ) { point_ptr = myPointList.get_and_step(); x = point_ptr->x(); y = point_ptr->y(); z = point_ptr->z(); if ( x < x_min ) x_min = x; if ( y < y_min ) y_min = y; if ( z < z_min ) z_min = z; if ( x > x_max ) x_max = x; if ( y > y_max ) y_max = y; if ( z > z_max ) z_max = z; } CubitVector min_v(x_min, y_min, z_min ); CubitVector max_v(x_max, y_max, z_max ); myBBox = new CubitBox( min_v, max_v ); } return *(myBBox); }
CubitStatus CurveFacetEvalTool::closest_point | ( | CubitVector & | this_point, |
CubitVector & | closest_point_ptr, | ||
CubitVector * | normal_ptr = NULL , |
||
CubitVector * | curvature_ptr = NULL , |
||
double * | param = NULL |
||
) |
Definition at line 805 of file CurveFacetEvalTool.cpp.
{ CubitStatus stat = CUBIT_SUCCESS; // int outside; int mydebug = 0; if (mydebug) { draw_location(this_point, CUBIT_RED_INDEX); } /* if (surfFacetEvalTool == NULL) { stat = project_to_linear_facet_edge( this_point, closest_point, tangent_ptr, curvature_ptr, param, &outside ); } else { stat = project_to_facet_edge( this_point, closest_point, tangent_ptr, curvature_ptr, param, &outside ); } */ int i; CubitVector test_pt_v, closest_pt_v, pt0_v, pt1_v; double distance2, closest_distance2; // distance squared CubitFacetEdge *edge, *best_edge = NULL; myEdgeList.reset(); closest_distance2 = CUBIT_DBL_MAX; for ( i = myEdgeList.size(); i > 0; i-- ) { edge = myEdgeList.get_and_step(); pt0_v = edge->point(0)->coordinates(); pt1_v = edge->point(1)->coordinates(); test_pt_v = FacetDataUtil::squared_distance_to_segment(this_point, pt0_v,pt1_v,distance2); if ( distance2 < closest_distance2 ) { closest_distance2 = distance2; closest_pt_v = test_pt_v; best_edge = edge; if ( distance2 < GEOMETRY_RESABS*GEOMETRY_RESABS ) break; } } if (mydebug) { myEdgeList.reset(); for ( i = myEdgeList.size(); i > 0; i-- ) { edge = myEdgeList.get_and_step(); pt0_v = edge->point(0)->coordinates(); pt1_v = edge->point(1)->coordinates(); GfxDebug::draw_point(pt0_v, CUBIT_GREEN_INDEX ); GfxDebug::draw_point(pt1_v, CUBIT_RED_INDEX ); GfxDebug::flush(); } } if ( interpOrder == 0 ) { closest_point = closest_pt_v; if (tangent_ptr) { CubitVector tangent; if (best_edge->edge_tangent( closest_point, tangent ) != CUBIT_SUCCESS) { return CUBIT_FAILURE; } if (curvSense == CUBIT_REVERSED) tangent = -tangent; *tangent_ptr = tangent; } // evaluate the curvature if required if (curvature_ptr) { if( myEdgeList.size() == 1 ) (*curvature_ptr).set( 0, 0, 0); else { CubitVector curvature; myEdgeList.move_to( best_edge ); int index = myEdgeList.get_index(); //"best_edge" could be last or first on curve CubitFacetEdge* prev_edge = NULL; myEdgeList.back(); if( (index - 1) == myEdgeList.get_index() ) prev_edge = myEdgeList.get(); CubitFacetEdge* next_edge = NULL; myEdgeList.step(2); if( (index + 1) == myEdgeList.get_index() ) next_edge = myEdgeList.get(); CubitFacetEdge *closest_edge; //determine which adjacent edge is closest to "best_point" if( prev_edge && next_edge ) { CubitVector tmp_vec; double prev_dist, next_dist; tmp_vec = (prev_edge->point(0)->coordinates() + prev_edge->point(1)->coordinates() ) / 2; prev_dist = closest_point.distance_between( tmp_vec ); tmp_vec = (next_edge->point(0)->coordinates() + next_edge->point(1)->coordinates() ) / 2; next_dist = closest_point.distance_between( tmp_vec ); if( prev_dist < next_dist ) closest_edge = prev_edge; else closest_edge = next_edge; } else if( prev_edge ) closest_edge = prev_edge; else closest_edge = next_edge; if (best_edge->edge_curvature( closest_point, curvature, closest_edge ) != CUBIT_SUCCESS) { return CUBIT_FAILURE; } if (curvSense == CUBIT_REVERSED) curvature = -curvature; *curvature_ptr = curvature; } } } else if ( interpOrder == 4 ) { double t_value; double tangent[3]; stat = project_to_bezier_edge(best_edge,this_point, closest_point,tangent,&t_value); if(curvSense == CUBIT_REVERSED){ tangent[0]= -tangent[0]; tangent[1]= -tangent[1]; tangent[2]= -tangent[2]; } if ( tangent_ptr ) { tangent_ptr->x(tangent[0]); tangent_ptr->y(tangent[1]); tangent_ptr->z(tangent[2]); } if ( curvature_ptr ) { // The idea here is to get the planes normal to two points on the curve // on either side of the closest_point, and also to get the plane through // these three points. The point of intersection of these three planes // should be a good approximation of the center of curvature, from which // the curvature vector is readily found. // tan1 and tan2 are the normals to the two planes for the endpoints; // norm3 is the normal for the plane through the three points. CubitVector tan1, tan2, point_1, point_2; CubitVector *tan1_ptr = &tan1; CubitVector *tan2_ptr = &tan2; // CubitVector *point_1_ptr = &point_1; CubitVector *point_2_ptr = &point_2; t_value -= 0.01; best_edge->evaluate_single_tangent(t_value,tan1_ptr); t_value += 0.02; best_edge->evaluate_single(t_value,tan2_ptr); best_edge->evaluate_single_tangent(t_value,point_2_ptr); tan1.normalize(); tan2.normalize(); // Get the plane through the point and normal to the tangent for the two // points at the end. // Get the plane for the three points. CubitVector arm1 = point_1 - closest_point; CubitVector arm2 = point_2 - closest_point; CubitVector norm3 = arm1*arm2; norm3.normalize(); double denominator; denominator = tan1 % ( tan2 * norm3 ); if ( fabs(denominator) < GEOMETRY_RESABS ) { // planes are parallel; // curvature is infinite curvature_ptr->x(CUBIT_DBL_MAX); curvature_ptr->y(CUBIT_DBL_MAX); curvature_ptr->z(CUBIT_DBL_MAX); } else { CubitVector IntersectionPoint; IntersectionPoint = ( (point_1%tan1)*(norm3*tan2) + (closest_point%norm3)*(tan2*tan1) + (point_2%tan2)*(tan1*norm3) )/denominator; curvature_ptr->x(closest_point.x() - IntersectionPoint.x()); curvature_ptr->y(closest_point.y() - IntersectionPoint.y()); curvature_ptr->z(closest_point.z() - IntersectionPoint.z()); } } } else { PRINT_ERROR("Error: Only curves or order 0 or 4 are supported.\n"); return CUBIT_FAILURE; } if (param) { *param = u_on_facet_edge( best_edge, closest_point ); } if (mydebug) { draw_location(closest_point, CUBIT_GREEN_INDEX); } return stat; }
void CurveFacetEvalTool::debug_draw_facet_edges | ( | int | color = -1 | ) |
Definition at line 2115 of file CurveFacetEvalTool.cpp.
{ draw_edges(color); }
void CurveFacetEvalTool::destroy_facets | ( | ) | [private] |
Definition at line 1783 of file CurveFacetEvalTool.cpp.
{ }
void CurveFacetEvalTool::draw_edge | ( | CubitFacetEdge * | edge, |
int | color | ||
) | [private] |
Definition at line 1822 of file CurveFacetEvalTool.cpp.
{ CubitPoint *begin_point = edge->point(0); CubitPoint *end_point = edge->point(1); GfxDebug::draw_line(begin_point->x(), begin_point->y(), begin_point->z(), end_point->x(), end_point->y(), end_point->z(), color); GfxDebug::flush(); }
void CurveFacetEvalTool::draw_edges | ( | int | color = -1 | ) | [private] |
Definition at line 1795 of file CurveFacetEvalTool.cpp.
{ int ii; if ( color == -1 ) color = CUBIT_BLUE_INDEX; for ( ii = myEdgeList.size(); ii > 0; ii-- ) { CubitFacetEdge *edge = myEdgeList.get_and_step(); CubitPoint *begin_point = edge->point(0); CubitPoint *end_point = edge->point(1); GfxDebug::draw_line(begin_point->x(), begin_point->y(), begin_point->z(), end_point->x(), end_point->y(), end_point->z(), color); } GfxDebug::flush(); }
void CurveFacetEvalTool::draw_line | ( | CubitVector & | begin, |
CubitVector & | end, | ||
int | color = -1 |
||
) | [private] |
Definition at line 1843 of file CurveFacetEvalTool.cpp.
{ GfxDebug::draw_line(begin.x(), begin.y(), begin.z(), end.x(), end.y(), end.z(), color); GfxDebug::flush(); }
void CurveFacetEvalTool::draw_location | ( | CubitVector & | loc, |
int | color = -1 |
||
) | [private] |
Definition at line 1855 of file CurveFacetEvalTool.cpp.
{ if ( color == -1 ) color = CUBIT_YELLOW_INDEX; GfxDebug::draw_point(loc, color); GfxDebug::flush(); }
CubitStatus CurveFacetEvalTool::evaluate_bezier_edge | ( | CubitFacetEdge * | edge, |
int | index0, | ||
int | index1, | ||
double | fraction, | ||
CubitVector & | location_on_curve, | ||
double * | tangent | ||
) | [private] |
Definition at line 708 of file CurveFacetEvalTool.cpp.
{ CubitStatus status; int numEdge, numVert, numLocs; int edgeVert[2]; //int order; double vert[6], edgeCtrlPts[9], location[3]; CubitVector *edge_ctrl_pts; double scaled_parameter; numEdge = 1; numVert = 2; numLocs = 1; edgeVert[0] = 0; edgeVert[1] = 1; vert[0] = edge->point(index0)->x(); vert[1] = edge->point(index0)->y(); vert[2] = edge->point(index0)->z(); vert[3] = edge->point(index1)->x(); vert[4] = edge->point(index1)->y(); vert[5] = edge->point(index1)->z(); edge_ctrl_pts = edge->control_points(); edgeCtrlPts[0] = edge_ctrl_pts[0].x(); edgeCtrlPts[1] = edge_ctrl_pts[0].y(); edgeCtrlPts[2] = edge_ctrl_pts[0].z(); edgeCtrlPts[3] = edge_ctrl_pts[1].x(); edgeCtrlPts[4] = edge_ctrl_pts[1].y(); edgeCtrlPts[5] = edge_ctrl_pts[1].z(); edgeCtrlPts[6] = edge_ctrl_pts[2].x(); edgeCtrlPts[7] = edge_ctrl_pts[2].y(); edgeCtrlPts[8] = edge_ctrl_pts[2].z(); //evalBezierEdge takes a parameter in the range of -1 to 1. // evalBezierEdge calls functions which convert back to // a range of 0 to 1, // but we must convert to -1 to 1, before sending it. scaled_parameter = (2.0 * fraction) - 1.0; // static function in Cholla.cpp evalBezierEdge(numEdge,numVert,edgeVert,vert,edgeCtrlPts,numLocs, &scaled_parameter, location,tangent); location_on_curve.x(location[0]); location_on_curve.y(location[1]); location_on_curve.z(location[2]); status = CUBIT_SUCCESS; return status; }
CubitSense CurveFacetEvalTool::find_curv_sense | ( | CubitPoint * | start_ptr | ) | [private] |
Definition at line 521 of file CurveFacetEvalTool.cpp.
{ myEdgeList.reset(); CubitFacetEdge *edge_ptr = myEdgeList.get(); CubitPoint *pt0 = edge_ptr->point(0); CubitPoint *pt1 = edge_ptr->point(1); CubitSense sense; if (start_pt == pt0) { sense = CUBIT_FORWARD; } else if (start_pt == pt1) { sense = CUBIT_REVERSED; } else { sense = CUBIT_UNKNOWN; } return sense; }
CubitSense CurveFacetEvalTool::find_curv_sense | ( | CubitVector & | start | ) | [private] |
Definition at line 553 of file CurveFacetEvalTool.cpp.
{ myEdgeList.reset(); CubitFacetEdge* temp_edge = myEdgeList.get(); CubitVector temp_vector = temp_edge->point(1)->coordinates() - temp_edge->point(0)->coordinates(); double tol = temp_vector.length() / 100.0; //if point(0) of first edge in list == start, it is CUBIT_FORWARD if(start.within_tolerance(temp_edge->point(0)->coordinates(), tol ) ) return CUBIT_FORWARD; //if point(1) of first edge in list == start, it is CUBIT_REVERSED else if(start.within_tolerance(temp_edge->point(1)->coordinates(), tol ) ) return CUBIT_REVERSED; else return CUBIT_UNKNOWN; }
CubitStatus CurveFacetEvalTool::fix_point_edge_order | ( | ) | [private] |
Definition at line 2051 of file CurveFacetEvalTool.cpp.
{ CubitFacetEdge* this_edge; CubitFacetEdge* next_edge; CubitPoint *this_pt1; CubitPoint *next_pt0, *next_pt1; if( myEdgeList.size() == 0 ) return CUBIT_FAILURE; this_edge = myEdgeList.get_and_step(); int ii; for( ii = myEdgeList.size() - 1; ii > 0; ii-- ) { if( 0 != this_edge->num_adj_facets() ) continue; next_edge = myEdgeList.get_and_step(); this_pt1 = this_edge->point( 1 ); next_pt0 = next_edge->point( 0 ); next_pt1 = next_edge->point( 1 ); if( this_pt1 != next_pt0 && this_pt1 != next_pt1 ) { //Swap direction of edge. (mod. 3-7-06) Now calling flip instead // of doing the flip manually. The flip function also tracks // the orientation so that we can remember the original orientation // of the edge. this_edge->flip(); } this_edge = next_edge; } //Handle last edge next_edge = myEdgeList.prev(2); if( 0 == this_edge->num_adj_facets() ) { CubitPoint* this_pt0 = this_edge->point( 0 ); next_pt0 = next_edge->point( 0 ); next_pt1 = next_edge->point( 1 ); if( this_pt0 != next_pt0 && this_pt0 != next_pt1 ) { //Swap direction of edge.(mod. 3-7-06) Now calling flip instead // of doing the flip manually. The flip function also tracks // the orientation so that we can remember the original orientation // of the edge. this_edge->flip(); } } return CUBIT_SUCCESS; }
void CurveFacetEvalTool::get_facets | ( | DLIList< CubitFacetEdge * > & | facet_list | ) | [inline] |
Definition at line 190 of file CurveFacetEvalTool.hpp.
{ facet_list += myEdgeList; }
int CurveFacetEvalTool::get_output_id | ( | ) | [inline] |
Definition at line 152 of file CurveFacetEvalTool.hpp.
{ return output_id; }
void CurveFacetEvalTool::get_points | ( | DLIList< CubitPoint * > & | point_list | ) | [inline] |
Definition at line 193 of file CurveFacetEvalTool.hpp.
{ point_list += myPointList; }
CubitStatus CurveFacetEvalTool::get_segments_from_loops | ( | DLIList< DLIList< CubitFacetEdge * > * > * | facet_loop_list, |
CubitVector & | start, | ||
CubitVector & | end, | ||
DLIList< CubitFacetEdge * > & | edge_list, | ||
DLIList< CubitPoint * > & | point_list, | ||
CubitSense | owrts | ||
) | [private] |
Definition at line 181 of file CurveFacetEvalTool.cpp.
{ CubitStatus stat = CUBIT_SUCCESS; int ii, jj; int mydebug = 0; CubitBoolean done = CUBIT_FALSE; DLIList<CubitFacetEdge*> *facet_loop; CubitFacetEdge *edge, *startedge = NULL; CubitPoint *pt0, *pt1; CubitVector loc_pt0, loc_pt1; double edge_length; facetLength = 0.0e0; int tool_id = surfFacetEvalTool->tool_id(); //loop over the "loops" for (ii=0; ii<facet_loop_list->size() && !done && stat == CUBIT_SUCCESS; ii++) { //get the next facet loop facet_loop = facet_loop_list->get_and_step(); // now loop over the edges in that loop for (jj=0; jj<facet_loop->size() && !done; jj++) { //get the start edge... we will //traverse the list forwards, if the surface is oriented forward //otherwise, traverse it backwards startedge = (orientation_wrt_surf == CUBIT_FORWARD) ? facet_loop->get_and_step() : facet_loop->get_and_back(); if (startedge->get_flag() == 0) { if (orientation_wrt_surf == CUBIT_FORWARD) { startedge->boundary_edge_points( pt0, pt1, tool_id ); } else { startedge->boundary_edge_points( pt1, pt0, tool_id ); } loc_pt0 = pt0->coordinates(); loc_pt1 = pt1->coordinates(); if (loc_pt0.within_tolerance( start, GEOMETRY_RESABS )) { startedge->set_flag( 1 ); edge = startedge; if (mydebug) draw_edge( edge, CUBIT_GREEN_INDEX ); while (!done) { edge_list.append( edge ); point_list.append( pt0 ); edge_length = loc_pt0.distance_between( loc_pt1 ); facetLength += edge_length; //if the other end of the edge is at the begginning of the //loop, then we're done. if (loc_pt1.within_tolerance( end, GEOMETRY_RESABS )) { done = CUBIT_TRUE; point_list.append( pt1 ); } else {//otherwise... if (orientation_wrt_surf == CUBIT_FORWARD) { edge = facet_loop->get_and_step(); edge->boundary_edge_points( pt0, pt1, tool_id ); } else { edge = facet_loop->get_and_back(); edge->boundary_edge_points( pt1, pt0, tool_id ); } loc_pt0 = pt0->coordinates(); loc_pt1 = pt1->coordinates(); if (mydebug) draw_edge( edge, CUBIT_BLUE_INDEX ); //if we got back to the startedge without the // other end of an edge getting to the start vertex, // we have a problem.... if (edge == startedge) { stat = CUBIT_FAILURE; // this shouldn't happen done = CUBIT_TRUE; }//end edge == startedge }//end else not within tolerance }//end while not done }//end if within tolerance }//end if not marked }//end loop over edges in facet loop }//end loop over facet loops if(done!=CUBIT_TRUE) { PRINT_ERROR("Can't define curve representation in mesh-based geometry\n"); stat = CUBIT_FAILURE; } return stat; }
CubitStatus CurveFacetEvalTool::get_segments_from_loops | ( | DLIList< DLIList< CubitFacetEdge * > * > * | facet_loop_list, |
CubitPoint * | start_pt, | ||
CubitPoint * | end_pt, | ||
DLIList< CubitFacetEdge * > & | edge_list, | ||
DLIList< CubitPoint * > & | point_list, | ||
CubitSense | owrts | ||
) | [private] |
Definition at line 285 of file CurveFacetEvalTool.cpp.
{ CubitStatus stat = CUBIT_SUCCESS; int ii, jj; int mydebug = DEBUG_FLAG(181); CubitBoolean done = CUBIT_FALSE; DLIList<CubitFacetEdge*> *facet_loop; CubitFacetEdge *edge, *startedge = NULL; CubitPoint *pt0, *pt1; CubitVector loc_pt0, loc_pt1; double edge_length; DLIList<CubitFacetEdge*> temp_edge_list; DLIList<CubitPoint*> temp_point_list; if (mydebug) { GfxDebug::draw_point( start_pt->x(), start_pt->y(), start_pt->z(), CUBIT_RED_INDEX ); GfxDebug::draw_point( end_pt->x(), end_pt->y(), end_pt->z(), CUBIT_GREEN_INDEX ); GfxDebug::flush(); } int tool_id = surfFacetEvalTool->tool_id(); //loop over the list of facet loops for (ii=0; ii<facet_loop_list->size() && !done && stat == CUBIT_SUCCESS; ii++) { //get the next facet loop facet_loop = facet_loop_list->get_and_step(); //now loop over the edges in that facet loop for (jj=0; jj<facet_loop->size() && !done; jj++) { //get the start edge... we will //traverse the list forwards, if the surface is oriented forward //otherwise, traverse it backwards startedge = (orientation_wrt_surf == CUBIT_FORWARD) ? facet_loop->get_and_step() : facet_loop->get_and_back(); //if startedge isn't marked if (startedge->get_flag() == 0) { //get the points from the start edge in the appropriate order if (orientation_wrt_surf == CUBIT_FORWARD) { startedge->boundary_edge_points( pt0, pt1, tool_id ); } else { startedge->boundary_edge_points( pt1, pt0, tool_id ); } //convert to CubitVector loc_pt0 = pt0->coordinates(); loc_pt1 = pt1->coordinates(); //if the first point on the edge is the start_pt... otherwise step if (pt0 == start_pt) { //mark the startedge CubitFacetEdge* marked_edge = NULL; edge = startedge; if (mydebug) draw_edge( edge, CUBIT_GREEN_INDEX );//draw the start edge //loop until we have reached an end or no more choices while (!done) { //if the first point is at the start, we are either // just starting, or we have looped back onto the // start point. The latter _may_ be ok. In case // the latter is the case, clean out the temporary // lists and (re)initialize the length. Also, unmark // the edge that we marked the last time we started, // if we previously marked an edge. if (pt0 == start_pt){ temp_point_list.clean_out(); temp_edge_list.clean_out(); facetLength = 0.0; if(marked_edge) marked_edge->set_flag(0); marked_edge=edge; edge->set_flag(1); } //add the current edge to the edge list temp_edge_list.append( edge ); //add the current start point to the point list temp_point_list.append( pt0 ); //measure the edge... essentially edge_length = loc_pt0.distance_between( loc_pt1 ); //keep a running tally of the curve length facetLength += edge_length; //if the second point is at the end, we're done if (pt1 == end_pt ) { done = CUBIT_TRUE; temp_point_list.append( pt1 ); } //otherwise, we need to step forward else { if (orientation_wrt_surf == CUBIT_FORWARD) { edge = facet_loop->get_and_step(); edge->boundary_edge_points( pt0, pt1, tool_id ); } else { edge = facet_loop->get_and_back(); edge->boundary_edge_points( pt1, pt0, tool_id ); } //convert point to CubitVector, as above loc_pt0 = pt0->coordinates(); loc_pt1 = pt1->coordinates(); if (mydebug) draw_edge( edge, CUBIT_BLUE_INDEX ); if (edge == startedge) { stat = CUBIT_FAILURE; // this shouldn't happen done = CUBIT_TRUE; } }//end else (ie, if not pt1==end_pt) }//end while !done }//end if pt0 == start_pt }//end if start edge isn't marked }//end loop over edges in the loop }//end loop over facet loops //now put the temporary list entries onto the end of the list we return. point_list += temp_point_list; edge_list += temp_edge_list; if(done!=CUBIT_TRUE || stat == CUBIT_FAILURE) { stat = CUBIT_FAILURE; PRINT_WARNING("Can't define curve representation in mesh-based geometry\n"); PRINT_INFO(" Hint: Try importing as a free mesh and examining nodes and attached\n"); PRINT_INFO(" elements near the following locations:\n"); PRINT_INFO(" Start curve = %f %f %f\n", start_pt->x(), start_pt->y(), start_pt->z()); PRINT_INFO(" End curve = %f %f %f\n", end_pt->x(), end_pt->y(), end_pt->z()); if (mydebug) { surfFacetEvalTool->debug_draw_facets( CUBIT_YELLOW_INDEX ); int i, j; for (i=0; i<facet_loop_list->size(); i++) { DLIList<CubitFacetEdge*> *my_facet_loop = facet_loop_list->get_and_step(); for (j=0; j<my_facet_loop->size(); j++) { draw_edge( my_facet_loop->get_and_step(), CUBIT_RED_INDEX ); } } GfxDebug::mouse_xforms(); } } return stat; }
CubitStatus CurveFacetEvalTool::get_segments_from_positions | ( | std::vector< CubitVector > & | positions, |
CubitVector & | start_pt, | ||
DLIList< CubitFacetEdge * > & | edge_list, | ||
DLIList< CubitPoint * > & | point_list | ||
) | [private] |
Definition at line 443 of file CurveFacetEvalTool.cpp.
{ DLIList<CubitPoint*> surface_pts; surfFacetEvalTool->get_points( surface_pts ); facetLength = 0; double smallest_dist = CUBIT_DBL_MAX; CubitPoint *start_pt = NULL; //find the closest point to 'start' for( int k=surface_pts.size(); k--; ) { double tmp_dist = surface_pts.get()->coordinates().distance_between_squared( start ); if( tmp_dist < smallest_dist ) { smallest_dist = tmp_dist; start_pt = surface_pts.get(); } surface_pts.get_and_step(); } myPointList.append( start_pt ); CubitPoint *current_pt = start_pt; CubitPoint *next_pt = NULL; for (size_t k = 1; k < positions.size(); k++ ) { CubitVector current_pos = positions[k]; //find the CubitPoint attached to this point via an edge double smallest_dist = CUBIT_DBL_MAX; CubitFacetEdge *next_edge; DLIList<CubitFacetEdge*> adj_edges; current_pt->edges( adj_edges ); for( int m=adj_edges.size(); m--; ) { CubitFacetEdge *tmp_edge = adj_edges.get_and_step(); CubitPoint *other_pt = tmp_edge->other_point( current_pt ); double tmp_dist = current_pos.distance_between_squared( other_pt->coordinates() ); if( tmp_dist < smallest_dist ) { smallest_dist = tmp_dist; next_pt = other_pt; next_edge = tmp_edge; } } current_pt = next_pt; facetLength += next_edge->length(); myEdgeList.append( next_edge ); myPointList.append( current_pt ); } if ((size_t)myPointList.size() != positions.size() || (size_t)myEdgeList.size() != positions.size() - 1 ) return CUBIT_FAILURE; return CUBIT_SUCCESS; }
FacetEvalTool* CurveFacetEvalTool::get_surf_eval_tool | ( | ) | [inline] |
Definition at line 197 of file CurveFacetEvalTool.hpp.
{ return surfFacetEvalTool; }
CubitBoolean CurveFacetEvalTool::has_good_curve_data | ( | ) | [inline] |
Definition at line 205 of file CurveFacetEvalTool.hpp.
{return goodCurveData;}
CubitStatus CurveFacetEvalTool::initialize | ( | DLIList< CubitFacetEdge * > & | edge_list, |
DLIList< CubitPoint * > & | point_list, | ||
FacetEvalTool * | surf_eval = NULL |
||
) |
Definition at line 124 of file CurveFacetEvalTool.cpp.
{ // static int counter = 0; output_id = -1; myBBox = NULL; curvSense = CUBIT_FORWARD; surfFacetEvalTool = surf_eval; myEdgeList = edge_list; myPointList = point_list; set_length(); CubitStatus status = fix_point_edge_order(); if( CUBIT_SUCCESS != status ) return status; interpOrder = 0; if(surf_eval) interpOrder = surf_eval->interp_order(); bounding_box(); goodCurveData = CUBIT_TRUE; return CUBIT_SUCCESS; }
CubitStatus CurveFacetEvalTool::initialize | ( | FacetEvalTool * | surf_eval_tool, |
CubitPoint * | start_point, | ||
CubitPoint * | end_point, | ||
CubitSense | orientation | ||
) |
Definition at line 91 of file CurveFacetEvalTool.cpp.
{ // static int counter = 0; output_id = -1; myBBox = NULL; surfFacetEvalTool = surf_eval_tool; CubitStatus stat = get_segments_from_loops( surfFacetEvalTool->loops(), start_pt, end_pt, myEdgeList, myPointList, orientation_wrt_surf ); goodCurveData = (stat == CUBIT_SUCCESS) ? CUBIT_TRUE : CUBIT_FALSE; if( !goodCurveData ) { PRINT_ERROR( "Unable to initialize Curve Evaluation Tool for Faceted Geometry.\n" ); return CUBIT_FAILURE; } interpOrder = surfFacetEvalTool->interp_order(); curvSense = find_curv_sense( start_pt ); bounding_box(); return CUBIT_SUCCESS; }
CubitStatus CurveFacetEvalTool::initialize | ( | FacetEvalTool * | surf_eval_tool, |
CubitVector & | start, | ||
CubitVector & | end, | ||
CubitSense | orientation | ||
) |
Definition at line 32 of file CurveFacetEvalTool.cpp.
{ // static int counter = 0; output_id = -1; myBBox = NULL; surfFacetEvalTool = surf_eval_tool; CubitStatus stat = get_segments_from_loops( surfFacetEvalTool->loops(), start, end, myEdgeList, myPointList, orientation_wrt_surface ); goodCurveData = (stat == CUBIT_SUCCESS) ? CUBIT_TRUE : CUBIT_FALSE; if( !goodCurveData ) { PRINT_ERROR( "Unable to initialize Curve Evaluation Tool for Faceted Geometry.\n" ); return CUBIT_FAILURE; } interpOrder = surfFacetEvalTool->interp_order(); curvSense = find_curv_sense( start ); bounding_box(); return CUBIT_SUCCESS; }
CubitStatus CurveFacetEvalTool::initialize | ( | FacetEvalTool * | surf_eval_tool, |
CubitVector & | start, | ||
std::vector< CubitVector > & | positions | ||
) |
Definition at line 58 of file CurveFacetEvalTool.cpp.
{ // static int counter = 0; output_id = -1; myBBox = NULL; surfFacetEvalTool = surf_eval_tool; CubitStatus stat = get_segments_from_positions( positions, start, myEdgeList, myPointList ); goodCurveData = (stat == CUBIT_SUCCESS) ? CUBIT_TRUE : CUBIT_FALSE; if( !goodCurveData ) { PRINT_ERROR( "Unable to initialize Curve Evaluation Tool for Faceted Geometry.\n" ); return CUBIT_FAILURE; } interpOrder = surfFacetEvalTool->interp_order(); curvSense = find_curv_sense( start ); bounding_box(); return CUBIT_SUCCESS; }
double CurveFacetEvalTool::length | ( | ) | [inline] |
Definition at line 184 of file CurveFacetEvalTool.hpp.
{ return facetLength; };
double CurveFacetEvalTool::length_from_u | ( | double | root_param, |
double | end_param | ||
) |
Definition at line 788 of file CurveFacetEvalTool.cpp.
{ double length = (end_param - root_param) * facetLength; return length; }
CubitStatus CurveFacetEvalTool::position_from_fraction | ( | double | fraction, |
CubitVector & | location_on_curve | ||
) |
Definition at line 621 of file CurveFacetEvalTool.cpp.
{ CubitStatus status = CUBIT_SUCCESS; CubitBoolean done = CUBIT_FALSE; double length, curlength, targetlength, lastlength; CubitFacetEdge *edge = NULL; CubitPoint *pt0=NULL, *pt1=NULL; CubitVector loc_pt0, loc_pt1; CubitVector eval_location; myEdgeList.reset(); myPointList.reset(); pt0 = myPointList.get(); if (fraction <= 0.0) { edge = myEdgeList.get_and_step(); location_on_curve = pt0->coordinates(); return status; } curlength = lastlength = 0.0e0; targetlength = fraction * facetLength; assert(myEdgeList.size() > 0); int ii = 0; for ( ; ii<myEdgeList.size() && !done; ii++) { edge = myEdgeList.get_and_step(); loc_pt0 = edge->point( 0 )->coordinates(); loc_pt1 = edge->point( 1 )->coordinates(); length = loc_pt0.distance_between( loc_pt1 ); curlength += length; if ( edge->point(0) == pt0 ){ pt1 = edge->point(1); } else{ pt1 = edge->point(0); } if (targetlength <= curlength) { done = CUBIT_TRUE; loc_pt0 = pt0->coordinates(); loc_pt1 = pt1->coordinates(); double local_fraction = (targetlength - lastlength) / length; eval_location = loc_pt0 + local_fraction * (loc_pt1 - loc_pt0); if (interpOrder == 0 || !surfFacetEvalTool) { location_on_curve = eval_location; } else { // evaluate Bezier edge int index0 = 0; int index1 = 1; if ( pt1 == edge->point(0) ) { //switching the indices causes evaluate_bezier_edge to compute the //wrong location, so I'm removing the switch (mbrewer) //index0 = 1; //index1 = 0; local_fraction = 1. - local_fraction; } status = evaluate_bezier_edge(edge,index0,index1,local_fraction, location_on_curve,0); } } else { lastlength = curlength; } if ( edge->point(0) == pt0 ) pt0 = edge->point(1); else pt0 = edge->point(0); } if (!done) { if(pt1 == NULL){ PRINT_ERROR("Opposite point not found while evaluating a curve.\n"); location_on_curve.set(0.0,0.0,0.0); return CUBIT_FAILURE; } location_on_curve = pt1->coordinates(); } return status; }
CubitStatus CurveFacetEvalTool::project_to_bezier_edge | ( | CubitFacetEdge * | edge, |
CubitVector & | point, | ||
CubitVector & | projected_point, | ||
double * | tangent, | ||
double * | tval | ||
) | [private] |
Definition at line 1025 of file CurveFacetEvalTool.cpp.
{ CubitStatus stat; int numEdge, numVert, edgeVert[2], numLocs; double vert[6], edgeCtrlPts[9], xyz[3], xyzOnEdge[3]; CubitVector *edge_ctrl_pts; stat = CUBIT_SUCCESS; numEdge = 1; numVert = 2; numLocs = 1; edgeVert[0] = 0; edgeVert[1] = 1; vert[0] = edge->point(0)->x(); vert[1] = edge->point(0)->y(); vert[2] = edge->point(0)->z(); vert[3] = edge->point(1)->x(); vert[4] = edge->point(1)->y(); vert[5] = edge->point(1)->z(); edge_ctrl_pts = edge->control_points(); edgeCtrlPts[0] = edge_ctrl_pts[0].x(); edgeCtrlPts[1] = edge_ctrl_pts[0].y(); edgeCtrlPts[2] = edge_ctrl_pts[0].z(); edgeCtrlPts[3] = edge_ctrl_pts[1].x(); edgeCtrlPts[4] = edge_ctrl_pts[1].y(); edgeCtrlPts[5] = edge_ctrl_pts[1].z(); edgeCtrlPts[6] = edge_ctrl_pts[2].x(); edgeCtrlPts[7] = edge_ctrl_pts[2].y(); edgeCtrlPts[8] = edge_ctrl_pts[2].z(); xyz[0] = point.x(); xyz[1] = point.y(); xyz[2] = point.z(); projToBezierEdge( numEdge,numVert,edgeVert,vert,edgeCtrlPts, numLocs,xyz,xyzOnEdge,tangent,tval ); projected_point.x(xyzOnEdge[0]); projected_point.y(xyzOnEdge[1]); projected_point.z(xyzOnEdge[2]); return stat; }
void CurveFacetEvalTool::remove_facets | ( | DLIList< CubitFacetEdge * > & | facet_edges | ) |
Definition at line 2168 of file CurveFacetEvalTool.cpp.
{ facet_edges = myEdgeList; myEdgeList.clean_out(); myPointList.clean_out(); }
CubitBoolean CurveFacetEvalTool::replace_facets | ( | DLIList< CubitFacetEdge * > & | curv_edges | ) |
Definition at line 2144 of file CurveFacetEvalTool.cpp.
{ // replace edges this->myEdgeList = curv_edges; // replace points DLIList<CubitPoint *> point_list; int i; // insert start point of every facet_edge curv_edges.reset(); for( i = 0; i < curv_edges.size(); i++ ) { point_list.append( CAST_TO( curv_edges.get_and_step(), CubitFacetEdge )->point(0) ); } // insert end point of last facet_edge curv_edges.step( curv_edges.size() - 1 ); point_list.append( CAST_TO( curv_edges.get(), CubitFacetEdge )->point(1) ); this->myPointList = point_list; return CUBIT_TRUE; }
CubitBoolean CurveFacetEvalTool::replace_point | ( | CubitPoint * | del_pnt, |
CubitPoint * | keep_pnt | ||
) |
Definition at line 2120 of file CurveFacetEvalTool.cpp.
{ CubitPoint *point_ptr; int npoints = myPointList.size(); myPointList.reset(); CubitBoolean istat = CUBIT_FALSE; int i; for ( i = 0; i < npoints; i++ ) { point_ptr = myPointList.get(); if( point_ptr == del_pnt ) { myPointList.remove(); myPointList.insert( keep_pnt ); istat = CUBIT_TRUE; } myPointList.step(); } return istat; }
CubitStatus CurveFacetEvalTool::restore | ( | FILE * | fp, |
unsigned int | endian, | ||
int | num_edges, | ||
int | num_points, | ||
CubitFacetEdge ** | edges, | ||
CubitPoint ** | points, | ||
int | num_fets, | ||
FacetEvalTool ** | fet_list | ||
) |
Definition at line 1968 of file CurveFacetEvalTool.cpp.
{ NCubitFile::CIOWrapper cio(endian, fp); typedef NCubitFile::UnsignedInt32 int32; // read stuff about this eval tool int ii; int int_data[4]; cio.Read(reinterpret_cast<int32*>(int_data), 4); interpOrder = int_data[0]; int surf_tool_id = int_data[1]; if (int_data[2] == -1 ) curvSense = CUBIT_UNKNOWN; else curvSense= int_data[2] ? CUBIT_REVERSED : CUBIT_FORWARD; goodCurveData = (int_data[3]==0) ? CUBIT_FALSE : CUBIT_TRUE; if( surf_tool_id != -1 ) surfFacetEvalTool = fet_array[ surf_tool_id ]; else surfFacetEvalTool = NULL; cio.Read(&facetLength, 1); // read the edges int nedges; cio.Read(reinterpret_cast<int32*>(&nedges), 1); if (nedges > 0) { int32* edge_id = new int32 [nedges]; cio.Read(edge_id, nedges); int id; for (ii=0; ii<nedges; ii++) { id = edge_id[ii]; if (id <0 || id >= num_edges) { delete [] edge_id; return CUBIT_FAILURE; } myEdgeList.append(edges[id]); } delete [] edge_id; } // read the points int npoints; cio.Read(reinterpret_cast<int32*>(&npoints), 1); int id; if (npoints > 0) { int32* point_id = new int32 [npoints]; cio.Read(point_id, npoints); for (ii=0; ii<npoints; ii++) { id = point_id[ii]; if (id <0 || id >= num_points) { delete [] point_id; return CUBIT_FAILURE; } myPointList.append(points[id]); } delete [] point_id; } bounding_box(); return CUBIT_SUCCESS; }
CubitStatus CurveFacetEvalTool::save | ( | FILE * | fp | ) |
Definition at line 1893 of file CurveFacetEvalTool.cpp.
{ NCubitFile::CIOWrapper cio(fp); typedef NCubitFile::UnsignedInt32 int32; // write out "interpOrder" cio.Write(reinterpret_cast<int32*>(&interpOrder), 1); // write the associated facet eval tool id. If there is none then write -1 int surf_tool_id = -1; if (surfFacetEvalTool != NULL) surf_tool_id = surfFacetEvalTool->get_output_id(); cio.Write(reinterpret_cast<int32*>(&surf_tool_id), 1); // convert "curvSense" in an int int sense; if( curvSense == CUBIT_UNKNOWN ) sense = -1; else sense = (curvSense == CUBIT_REVERSED) ? 1 : 0; // write "curveSense" and "goodCurveData" cio.Write(reinterpret_cast<int32*>(&sense), 1); int32 is_good = goodCurveData ? 1 : 0; cio.Write(&is_good, 1); // write "facetLength" cio.Write( &facetLength, 1 ); // write ids of facet edges in "myEdgeList" int ii; CubitFacetEdge *edge_ptr; int nedges = myEdgeList.size(); int32* edge_id = new int32 [nedges]; myEdgeList.reset(); for (ii=0; ii<nedges; ii++) { edge_ptr = myEdgeList.get_and_step(); edge_id[ii] = edge_ptr->id(); } cio.Write(reinterpret_cast<int32*>(&nedges), 1); if (nedges > 0) { cio.Write(edge_id, nedges); } delete [] edge_id; // write ids of points in "myPointList" CubitPoint *point_ptr; int npoints = myPointList.size(); int32* point_id = new int32 [npoints]; myPointList.reset(); for (ii=0; ii<npoints; ii++) { point_ptr = myPointList.get_and_step(); point_id[ii] = point_ptr->id(); } cio.Write(reinterpret_cast<int32*>(&npoints), 1); if (npoints > 0) { cio.Write(point_id, npoints); } delete [] point_id; return CUBIT_SUCCESS; }
CubitSense CurveFacetEvalTool::sense | ( | ) | [inline] |
Definition at line 187 of file CurveFacetEvalTool.hpp.
{ return curvSense; };
void CurveFacetEvalTool::set_facet_eval_tool | ( | FacetEvalTool * | surf_eval_tool_ptr | ) | [inline] |
Definition at line 198 of file CurveFacetEvalTool.hpp.
{ surfFacetEvalTool = surf_eval_tool_ptr;}
void CurveFacetEvalTool::set_length | ( | ) |
Definition at line 1870 of file CurveFacetEvalTool.cpp.
{ int ii; CubitFacetEdge *cf_edge; facetLength = 0.0e0; for (ii=0; ii<myEdgeList.size(); ii++) { cf_edge = myEdgeList.get_and_step(); facetLength += cf_edge->length(); } }
void CurveFacetEvalTool::set_output_id | ( | int | id | ) | [inline] |
Definition at line 153 of file CurveFacetEvalTool.hpp.
double CurveFacetEvalTool::u_from_arc_length | ( | double | root_param, |
double | arc_length | ||
) |
Definition at line 770 of file CurveFacetEvalTool.cpp.
{ if( facetLength == 0 ) return 0; double u = root_param + arc_length / facetLength; return u; }
double CurveFacetEvalTool::u_on_facet_edge | ( | CubitFacetEdge * | edge_at_pt, |
CubitVector | pt | ||
) | [private] |
Definition at line 1741 of file CurveFacetEvalTool.cpp.
{ int ii; double cum_len = 0.0; CubitBoolean done = CUBIT_FALSE; myEdgeList.reset(); for (ii=0; ii<myEdgeList.size() && !done; ii++) { CubitFacetEdge *edge = myEdgeList.get_and_step(); if (edge != edge_at_pt) { cum_len += edge->length(); } else { CubitVector pt0; if (curvSense == CUBIT_REVERSED) { pt0 = edge->point( 1 )->coordinates(); } else { pt0 = edge->point( 0 )->coordinates(); } cum_len += pt.distance_between( pt0 ); done = CUBIT_TRUE; } } if (!done) { PRINT_DEBUG_122( "Error in CurveFacetEvalTool::u_on_facet_edge" ); } double u = cum_len / facetLength; return u; }
CubitSense CurveFacetEvalTool::curvSense [private] |
Definition at line 38 of file CurveFacetEvalTool.hpp.
double CurveFacetEvalTool::facetLength [private] |
Definition at line 37 of file CurveFacetEvalTool.hpp.
Definition at line 39 of file CurveFacetEvalTool.hpp.
int CurveFacetEvalTool::interpOrder [private] |
Definition at line 30 of file CurveFacetEvalTool.hpp.
CubitBox* CurveFacetEvalTool::myBBox [private] |
Definition at line 35 of file CurveFacetEvalTool.hpp.
DLIList<CubitFacetEdge*> CurveFacetEvalTool::myEdgeList [private] |
Definition at line 33 of file CurveFacetEvalTool.hpp.
DLIList<CubitPoint*> CurveFacetEvalTool::myPointList [private] |
Definition at line 34 of file CurveFacetEvalTool.hpp.
int CurveFacetEvalTool::output_id [private] |
Definition at line 40 of file CurveFacetEvalTool.hpp.
Definition at line 36 of file CurveFacetEvalTool.hpp.
int CurveFacetEvalTool::toolID [private] |
Definition at line 29 of file CurveFacetEvalTool.hpp.