cgma
|
#include <FacetAttrib.hpp>
Public Member Functions | |
FacetAttrib (const CubitSimpleAttrib &) | |
~FacetAttrib () | |
CubitSimpleAttrib | get_CSA () const |
bool | equals (const CubitSimpleAttrib &) const |
CubitStatus | save (FILE *file) const |
CubitString | name () const |
Static Public Member Functions | |
static FacetAttrib * | restore (FILE *file, unsigned int endian) |
Public Attributes | |
CubitString * | stringArray |
double * | doubleArray |
int * | integerArray |
int | numStrings |
int | numDoubles |
int | numIntegers |
FacetAttrib * | listNext |
Private Member Functions | |
FacetAttrib (int string_count, CubitString *strings, int double_count, double *doubles, int integer_count, int *integers) |
Definition at line 9 of file FacetAttrib.hpp.
FacetAttrib::FacetAttrib | ( | const CubitSimpleAttrib & | csa | ) |
Definition at line 9 of file FacetAttrib.cpp.
: listNext(0) { int i; // save counts numStrings = csa.string_data_list().size(); numDoubles = csa.double_data_list().size(); numIntegers = csa.int_data_list().size(); // allocate arrays, but don't try to allocate zero-length arrays stringArray = numStrings ? new CubitString[numStrings] : NULL; doubleArray = numDoubles ? new double[numDoubles] : NULL; integerArray = numIntegers ? new int[numIntegers] : NULL; // copy data into arrays for( i = 0; i < numStrings; i++ ) stringArray[i] = csa.string_data_list()[i]; for( i = 0; i < numIntegers; i++ ) integerArray[i] = csa.int_data_list()[i]; for( i = 0; i < numDoubles; i++ ) doubleArray[i] = csa.double_data_list()[i]; }
Definition at line 43 of file FacetAttrib.cpp.
{ // "delete"ing NULL pointers is okay. delete [] integerArray; delete [] doubleArray; delete [] stringArray; }
FacetAttrib::FacetAttrib | ( | int | string_count, |
CubitString * | strings, | ||
int | double_count, | ||
double * | doubles, | ||
int | integer_count, | ||
int * | integers | ||
) | [private] |
bool FacetAttrib::equals | ( | const CubitSimpleAttrib & | csa | ) | const |
Definition at line 73 of file FacetAttrib.cpp.
{ // compare counts if( csa.int_data_list().size() != (size_t)numIntegers || csa.double_data_list().size() != (size_t)numDoubles || csa.string_data_list().size() != (size_t)numStrings ) return false; // compare strings first because most likely the // first string (the name) will differ. if(!std::equal(stringArray, stringArray+numStrings, csa.string_data_list().begin())) return false; if(!std::equal(doubleArray, doubleArray+numDoubles, csa.double_data_list().begin())) return false; if(!std::equal(integerArray, integerArray+numIntegers, csa.int_data_list().begin())) return false; return true; }
CubitSimpleAttrib FacetAttrib::get_CSA | ( | ) | const |
Definition at line 52 of file FacetAttrib.cpp.
{ // Set initial list size std::vector<CubitString> string_list(numStrings); std::vector<int> int_list(numIntegers); std::vector<double> double_list(numDoubles); // Don't need to 'new' objects in DLIList because // CSA will make copies. Just put addresses in list. int i; for( i = 0; i < numStrings; i++ ) string_list[i] = stringArray[i]; for( i = 0; i < numIntegers; i++ ) int_list[i] = integerArray[i]; for( i = 0; i < numDoubles; i++ ) double_list[i] = doubleArray[i]; return CubitSimpleAttrib( &string_list, &double_list, &int_list ); }
CubitString FacetAttrib::name | ( | ) | const [inline] |
Definition at line 25 of file FacetAttrib.hpp.
{ return stringArray[0]; }
FacetAttrib * FacetAttrib::restore | ( | FILE * | file, |
unsigned int | endian | ||
) | [static] |
Definition at line 128 of file FacetAttrib.cpp.
{ if( restore_file == NULL ) return NULL; NCubitFile::CIOWrapper wrapper(endian, restore_file ); // write a version number for the attribute data unsigned int version; wrapper.Read(&version, 1); // haven't handled any version changes yet if( version != 1 ) { PRINT_ERROR("Wrong FacetAttrib version : %u\n", version ); return NULL; } // read the number of strings, number of doubles, and number of integers int counts[3]; wrapper.Read(reinterpret_cast<unsigned int*>(counts), 3); int n_strings = counts[0]; int n_doubles = counts[1]; int n_ints = counts[2]; // allocate arrays, but don't try to allocate zero-length array CubitString* strings = n_strings ? new CubitString[n_strings] : NULL; double *doubles = n_doubles ? new double[n_doubles] : NULL; int *ints = n_ints ? new int[n_ints] : NULL; // read the string data int i; for( i = 0; i < n_strings; i++ ) { char *string = wrapper.Read(); strings[i] = CubitString(string); delete [] string; } // write the doubles wrapper.Read(doubles, n_doubles); // write the integers wrapper.Read(reinterpret_cast<unsigned int*>(ints), n_ints); return new FacetAttrib(n_strings, strings, n_doubles, doubles, n_ints, ints); }
CubitStatus FacetAttrib::save | ( | FILE * | file | ) | const |
Definition at line 94 of file FacetAttrib.cpp.
{ if( save_file == NULL) { PRINT_ERROR("Problem saving MBG attributes: null FILE ptr\n"); return CUBIT_FAILURE; } NCubitFile::CIOWrapper wrapper(save_file); // write a version number for the attribute data unsigned int Attrib_Version = 1; wrapper.Write(&Attrib_Version, 1); // write the number of strings, number of doubles, and number of integers int counts[3] = { numStrings, numDoubles, numIntegers }; wrapper.Write(reinterpret_cast<unsigned int*>(counts), 3); // write the string data int i; for( i = 0; i < numStrings; i++ ) wrapper.Write(stringArray[i].c_str()); // write the doubles wrapper.Write(doubleArray, numDoubles); // write the integers wrapper.Write(reinterpret_cast<unsigned int*>(integerArray), numIntegers); return CUBIT_SUCCESS; }
double* FacetAttrib::doubleArray |
Definition at line 31 of file FacetAttrib.hpp.
Definition at line 32 of file FacetAttrib.hpp.
Definition at line 38 of file FacetAttrib.hpp.
Definition at line 35 of file FacetAttrib.hpp.
Definition at line 36 of file FacetAttrib.hpp.
Definition at line 34 of file FacetAttrib.hpp.
Definition at line 30 of file FacetAttrib.hpp.