cgma
|
#include <GMem.hpp>
Public Member Functions | |
GMem () | |
~GMem () | |
void | allocate_tri (int num_tri) |
void | allocate_polylines (int num_lines) |
void | allocate_more_polylines (int num_lines) |
void | clean_out () |
void | points_consolidated (CubitBoolean yes_no) |
CubitBoolean | points_consolidated () |
void | consolidate_points (double tolerance) |
GPoint * | point_list () |
int * | facet_list () |
void | replace_point_list (GPoint new_point_list[], int num_valid_points, int array_size) |
void | replace_facet_list (int new_facet_list[], int num_valid_entries, int array_size) |
int | point_list_size () |
int | facet_list_size () |
GMem (const GMem &from) | |
GMem & | operator= (const GMem &from) |
void | transform (CubitTransformMatrix &transform) |
Public Attributes | |
int | pointListCount |
int | fListCount |
Private Member Functions | |
void | consolidate_few_points (double tolerance) |
void | consolidate_many_points (double tolerance) |
Private Attributes | |
GPoint * | pointList |
int | ptsSize |
int | fListSize |
int * | facetList |
CubitBoolean | pointsConsolidated |
GMem::GMem | ( | ) |
Definition at line 8 of file GMem.cpp.
{ ptsSize = 0; fListSize = 0; pointListCount = 0; fListCount = 0; pointList = NULL; facetList = NULL; pointsConsolidated = CUBIT_FALSE; }
GMem::~GMem | ( | ) |
GMem::GMem | ( | const GMem & | from | ) |
void GMem::allocate_more_polylines | ( | int | num_lines | ) |
Definition at line 62 of file GMem.cpp.
{ // Make sure we need to do something if (num_additional_segs <= 0) return; // If there are no points, we need space for one additional point if (pointListCount == 0) num_additional_segs++; // Make sure we need to grow if (ptsSize >= pointListCount + num_additional_segs) return; // Make a big enough array of points GPoint *new_points = new GPoint[pointListCount + num_additional_segs]; // Copy the old data to the new array if (pointList) { memcpy (new_points, pointList, pointListCount*sizeof(GPoint)); delete []pointList; } // Store the new array in 'pointList' pointList = new_points; ptsSize = pointListCount + num_additional_segs; }
void GMem::allocate_polylines | ( | int | num_lines | ) |
void GMem::allocate_tri | ( | int | num_tri | ) |
void GMem::clean_out | ( | ) |
Definition at line 87 of file GMem.cpp.
{ pointListCount = 0; fListCount = 0; }
void GMem::consolidate_few_points | ( | double | tolerance | ) | [private] |
Definition at line 162 of file GMem.cpp.
{ const double tolsqr = tolerance * tolerance; int* index_map = new int[pointListCount]; // Consolidate the point list. index_map is used // to maintain a map between the old index of a point // (the index into index_map) and the new index of a // point (the value in index_map). int write = 0, read, comp; for( read = 0; read < pointListCount; read++ ) { const GPoint& pti = pointList[read]; for( comp = 0; comp < write; comp++ ) { const GPoint& ptj = pointList[comp]; double x = pti.x - ptj.x; double y = pti.y - ptj.y; double z = pti.z - ptj.z; if( (x*x+y*y+z*z) <= tolsqr ) break; } index_map[read] = comp; if( comp == write ) { pointList[comp] = pointList[read]; write++; } } pointListCount = write; // Update the facet list using values from index_map. int *itor = facetList; const int* end = facetList + fListCount; while( itor < end ) for( int count = *(itor++); count--; itor++ ) *itor = index_map[*itor]; delete [] index_map; pointsConsolidated = CUBIT_TRUE; }
void GMem::consolidate_many_points | ( | double | tolerance | ) | [private] |
Definition at line 210 of file GMem.cpp.
{ const double tolsqr = tolerance * tolerance; // build OctTree DLIList<GPoint*> point_list(pointListCount); GPoint* p_itor = pointList; GPoint* p_end = p_itor + pointListCount; while( p_itor < p_end ) point_list.append( p_itor++ ); OctTree<GPoint, GPointOctTreeEval> tree( point_list, tolerance ); point_list.clean_out(); // Consolidate the point list. index_map is used // to maintain a map between the old index of a point // (the index into index_map) and the new index of a // point (the value in index_map). int* index_map = new int[pointListCount]; GPoint* new_array = new GPoint[pointListCount]; int read, write = 0; for ( read = 0; read < pointListCount; read++) { GPoint* pt = pointList + read; CubitVector v(pt->x, pt->y, pt->z); index_map[read] = write; point_list.clean_out(); tree.nodes_near( v, point_list ); while ( point_list.size() ) { GPoint* p = point_list.pop(); int index = p - pointList; assert( (index >= 0) && (index < pointListCount) ); CubitVector v2(p->x, p->y, p->z); if ( (index < read) && ((v - v2).length_squared() < tolsqr) ) { index_map[read] = index_map[index]; break; } } if ( index_map[read] == write ) { new_array[write++] = pointList[read]; } } pointListCount = write; delete [] pointList; pointList = new_array; // Update the facet list using values from index_map. int *itor = facetList; const int* end = facetList + fListCount; while( itor < end ) for( int count = *(itor++); count--; itor++ ) *itor = index_map[*itor]; delete [] index_map; pointsConsolidated = CUBIT_TRUE; }
void GMem::consolidate_points | ( | double | tolerance | ) |
Definition at line 154 of file GMem.cpp.
{ if ( pointListCount < 1000 ) consolidate_few_points( tolerance ); else consolidate_many_points( tolerance ); }
int* GMem::facet_list | ( | ) | [inline] |
int GMem::facet_list_size | ( | ) | [inline] |
Definition at line 133 of file GMem.cpp.
{ if (this != &from) { // Make a copy of the point array GPoint* temp1 = new GPoint[from.ptsSize]; memcpy (temp1, from.pointList, from.ptsSize*sizeof(GPoint)); // Put it in the receiving GMem replace_point_list(temp1, from.pointListCount, from.ptsSize); // Make a copy of the facet array int* temp2 = new int[from.fListSize]; memcpy (temp2, from.facetList, from.fListSize*sizeof(int)); // Put it in the receiving GMem replace_facet_list(temp2, from.fListCount, from.fListSize); // Set whether it's consolidated pointsConsolidated = from.pointsConsolidated; } return *this; }
GPoint* GMem::point_list | ( | ) | [inline] |
int GMem::point_list_size | ( | ) | [inline] |
void GMem::points_consolidated | ( | CubitBoolean | yes_no | ) | [inline] |
Definition at line 61 of file GMem.hpp.
{ pointsConsolidated = yes_no; }
CubitBoolean GMem::points_consolidated | ( | ) | [inline] |
Definition at line 63 of file GMem.hpp.
{ return pointsConsolidated; }
void GMem::replace_facet_list | ( | int | new_facet_list[], |
int | num_valid_entries, | ||
int | array_size | ||
) |
void GMem::replace_point_list | ( | GPoint | new_point_list[], |
int | num_valid_points, | ||
int | array_size | ||
) |
void GMem::transform | ( | CubitTransformMatrix & | transform | ) |
Definition at line 270 of file GMem.cpp.
{ int i=0; CubitVector temp_point; for (i=0; i<this->pointListCount; i++) { temp_point.set(pointList[i].x, pointList[i].y, pointList[i].z); temp_point = transform * temp_point; pointList[i].x = (float)temp_point.x(); pointList[i].y = (float)temp_point.y(); pointList[i].z = (float)temp_point.z(); } }
int* GMem::facetList [private] |
int GMem::fListCount |
int GMem::fListSize [private] |
GPoint* GMem::pointList [private] |
CubitBoolean GMem::pointsConsolidated [private] |
int GMem::ptsSize [private] |