cgma
|
00001 #include "OctreeFacetPointData.hpp" 00002 00003 #include "CubitPoint.hpp" 00004 #include "CubitFacet.hpp" 00005 #include "CubitFacetEdge.hpp" 00006 //#include "SVDrawTool.hpp" 00007 #include "CubitColor.hpp" 00008 00009 /* -------------------- Methods of OctreeFacetPointData ----------------- */ 00010 int OctreeFacetPointData::calculate_id( void ){ 00011 static int count = -1; 00012 count++; 00013 return count; 00014 } 00015 00016 OctreeFacetPointData::OctreeFacetPointData( CubitVector coord, CubitFacet *ptr_facet ){ 00017 xyz = coord; 00018 type = CUBIT_FACET_POINT_DATA_FACET; 00019 facetPtr = ptr_facet; 00020 num = calculate_id(); 00021 } 00022 00023 OctreeFacetPointData::OctreeFacetPointData( CubitVector coord, CubitFacetEdge *ptr_facet_edge ){ 00024 xyz = coord; 00025 type = CUBIT_FACET_POINT_DATA_EDGE; 00026 facetEdgePtr = ptr_facet_edge; 00027 num = calculate_id(); 00028 } 00029 00030 OctreeFacetPointData::OctreeFacetPointData( CubitVector coord, CubitPoint *ptr_point ){ 00031 xyz = coord; 00032 type = CUBIT_FACET_POINT_DATA_POINT; 00033 facetPointPtr = ptr_point; 00034 num = calculate_id(); 00035 } 00036 00037 CubitBoolean OctreeFacetPointData::generate_facet_point_data_based_on_curvature( CubitFacetEdge *ptr_facet_edge, /*double angle,*/ DLIList< OctreeFacetPointData *> &facet_point_data_list ){ 00038 00039 CubitFacet *ptr_adj_facet0 = ptr_facet_edge->adj_facet(0); 00040 CubitFacet *ptr_adj_facet1 = ptr_facet_edge->adj_facet(1); 00041 00042 // Find minimum edge length 00043 int i; 00044 double edge_len, min_edge_len = CUBIT_DBL_MAX; 00045 for( i = 0; i < 3; i++ ){ 00046 edge_len = ptr_adj_facet0->edge(i)->length(); 00047 if( edge_len < min_edge_len ){ 00048 min_edge_len = edge_len; 00049 } 00050 } 00051 for( i = 0; i < 3; i++ ){ 00052 edge_len = ptr_adj_facet1->edge(i)->length(); 00053 if( edge_len < min_edge_len ){ 00054 min_edge_len = edge_len; 00055 } 00056 } 00057 00058 int num_seg = (int)(ptr_facet_edge->length() / min_edge_len) + 1; 00059 00060 // For triangles with high aspect ratio the number of segments can be enormous. Limit 00061 // the number of segments. 00062 if(num_seg > 100) 00063 num_seg = 100; 00064 00065 OctreeFacetPointData *facet_point_data; 00066 for( i = 1; i < num_seg; i++ ){ 00067 facet_point_data = new OctreeFacetPointData( (ptr_facet_edge->point(0)->coordinates() * (num_seg - i) + ptr_facet_edge->point(1)->coordinates() * (i)) / num_seg , ptr_facet_edge ); 00068 facet_point_data_list.push( facet_point_data ); 00069 } 00070 00071 return CUBIT_TRUE; 00072 } 00073 00074 void OctreeFacetPointData::display( void ){ 00075 00076 switch( type ){ 00077 case CUBIT_FACET_POINT_DATA_POINT: 00078 //SVDrawTool::draw_point( xyz, CUBIT_BLUE_INDEX ); 00079 break; 00080 00081 case CUBIT_FACET_POINT_DATA_EDGE: 00082 //SVDrawTool::draw_point( xyz, CUBIT_YELLOW_INDEX ); 00083 break; 00084 00085 case CUBIT_FACET_POINT_DATA_FACET: 00086 //SVDrawTool::draw_point( xyz, CUBIT_GREEN_INDEX ); 00087 break; 00088 00089 default: 00090 break; 00091 } 00092 00093 } 00094 00095 00096 00097 //EOF 00098