cgma
CompositeAttrib.cpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : CompositeAttrib.cpp
00003 //
00004 // Purpose       : Container for attribute data placed on composite geometry.
00005 //
00006 // Special Notes : This object is intended for internal use by CompositeGeom
00007 //                 exclusively.
00008 //
00009 // Creator       : Jason Kraftcheck
00010 //
00011 // Creation Date : 07/01/03
00012 //-------------------------------------------------------------------------
00013 
00014 #include "CompositeAttrib.hpp"
00015 #include "CubitString.hpp"
00016 #include "CubitSimpleAttrib.hpp"
00017 
00018 //-------------------------------------------------------------------------
00019 // Purpose       : Construct composite attribute object from CSA
00020 //
00021 // Special Notes : 
00022 //
00023 // Creator       : Jason Kraftcheck
00024 //
00025 // Creation Date : 06/30/03
00026 //-------------------------------------------------------------------------
00027 CompositeAttrib::CompositeAttrib( const CubitSimpleAttrib& attrib, CompositeAttrib* n )
00028   : int_array(0), real_array(0), string_array(0), next(n)
00029 {
00030   int_array = attrib.int_data_list();
00031   real_array = attrib.double_data_list();
00032   string_array = attrib.string_data_list();
00033 }  
00034   
00035 //-------------------------------------------------------------------------
00036 // Purpose       : Copy constructor
00037 //
00038 // Special Notes : 
00039 //
00040 // Creator       : Jason Kraftcheck
00041 //
00042 // Creation Date : 06/30/03
00043 //-------------------------------------------------------------------------
00044 CompositeAttrib::CompositeAttrib( const CompositeAttrib& copy) 
00045   : next(0)
00046 {
00047   int_array = copy.int_array;
00048   real_array = copy.real_array;
00049   string_array = copy.string_array;
00050 }
00051     
00052 //-------------------------------------------------------------------------
00053 // Purpose       : Populate attribute for saving
00054 //
00055 // Special Notes : 
00056 //
00057 // Creator       : Jason Kraftcheck
00058 //
00059 // Creation Date : 06/30/03
00060 //-------------------------------------------------------------------------
00061 void CompositeAttrib::append_to_csa( CubitSimpleAttrib& attrib ) const
00062 {
00063   append_to_lists(attrib.string_data_list(),
00064                   attrib.int_data_list(),
00065                   attrib.double_data_list());
00066 }
00067 
00068 //-------------------------------------------------------------------------
00069 // Purpose       : Common functionality for append_to_csa() and csa()
00070 //
00071 // Special Notes : 
00072 //
00073 // Creator       : Jason Kraftcheck
00074 //
00075 // Creation Date : 06/30/03
00076 //-------------------------------------------------------------------------
00077 void CompositeAttrib::append_to_lists( std::vector<CubitString>& string_list,
00078                                        std::vector<int>& int_list,
00079                                        std::vector<double>& real_list ) const
00080 {
00081   int_list.insert(int_list.end(), int_array.begin(), int_array.end());
00082   real_list.insert(real_list.end(), real_array.begin(), real_array.end());
00083   string_list.insert(string_list.end(), string_array.begin(), string_array.end());
00084 }
00085   
00086 //-------------------------------------------------------------------------
00087 // Purpose       : Copy data into CSA for return to higher level
00088 //
00089 // Special Notes : 
00090 //
00091 // Creator       : Jason Kraftcheck
00092 //
00093 // Creation Date : 06/30/03
00094 //-------------------------------------------------------------------------
00095 CubitSimpleAttrib CompositeAttrib::csa() const
00096 {
00097   std::vector<CubitString> string_list;
00098   std::vector<int> int_list;
00099   std::vector<double> real_list;
00100   append_to_lists( string_list, int_list, real_list );
00101   return CubitSimpleAttrib(&string_list, &real_list, &int_list);
00102 }
00103 
00104 
00105 //-------------------------------------------------------------------------
00106 // Purpose       : CompositeAttrib destructor
00107 //
00108 // Special Notes : 
00109 //
00110 // Creator       : Jason Kraftcheck
00111 //
00112 // Creation Date : 06/30/03
00113 //-------------------------------------------------------------------------
00114 CompositeAttrib::~CompositeAttrib()
00115 {
00116 }
00117 
00118 //-------------------------------------------------------------------------
00119 // Purpose       : Compare to a csa
00120 //
00121 // Special Notes : 
00122 //
00123 // Creator       : Jason Kraftcheck
00124 //
00125 // Creation Date : 06/30/03
00126 //-------------------------------------------------------------------------
00127 bool CompositeAttrib::equals( const CubitSimpleAttrib& attrib ) const
00128 {
00129   if (attrib.string_data_list().size() != string_array.size() ||
00130       attrib.int_data_list().size() != int_array.size() ||
00131       attrib.double_data_list().size() != real_array.size())
00132     return false;
00133   
00134   return std::equal(string_array.begin(), string_array.end(), attrib.string_data_list().begin()) &&
00135       std::equal(int_array.begin(), int_array.end(), attrib.int_data_list().begin()) &&
00136       std::equal(real_array.begin(), real_array.end(), attrib.double_data_list().begin());
00137 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines