Changeset 800
- Timestamp:
- 01/08/06 16:35:04 (6 years ago)
- Location:
- trunk/applications/NXtranslate
- Files:
-
- 4 edited
-
nexus_util.cpp (modified) (2 diffs)
-
node.cpp (modified) (2 diffs)
-
node.h (modified) (3 diffs)
-
xml_parser.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/applications/NXtranslate/nexus_util.cpp
r416 r800 81 81 82 82 // create the data 83 if(node.compress_type()==Node::COMP_NONE){ 83 int comp_type=node.compress_type(); 84 if(comp_type==Node::COMP_NONE){ 84 85 //std::cout << "in open: " << node.type() << " " << *(node.dims().begin()) << std::endl; // REMOVE 85 86 if(NXmakedata(*handle,name,type,rank,dims)!=NX_OK){ … … 88 89 } 89 90 }else{ 90 int comp_type=node.compress_type(); 91 // warn that this is not supported 92 std::cout << "WARN: do not currently support compression (type=" << comp_type << ")" << std::endl; 93 return; 94 /* TAKEN FROM <napi.h> 95 NX_EXTERNAL NXstatus CALLING_STYLE NXcompmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]); 96 */ 91 vector<int> buff_size_vec=node.comp_buffer_dims(); 92 int *buff_size=new int[rank]; 93 for( size_t i=0 ; i<rank ; i++ ){ 94 buff_size[i]=buff_size_vec[i]; 95 } 96 97 buff_size[rank-1]=dims[rank-1]; 98 if(NXcompmakedata(*handle,name,type,rank,dims,comp_type,buff_size)!=NX_OK){ 99 std::cout << "NXcompmakedata failed" << std::endl; 100 throw runtime_error("NXcompmakedata failed"); 101 } 102 delete buff_size; // FIXME - is this the correct form? 97 103 } 98 104 } -
trunk/applications/NXtranslate/node.cpp
r683 r800 167 167 } 168 168 169 const std::vector<int> Node::comp_buffer_dims() const{ 170 return __comp_buffer_dims; 171 } 172 169 173 void* Node::data() const{ 170 174 return __value; … … 202 206 throw out_of_range("asked for attribute with higher index than size"); 203 207 return (*(__attrs.begin()+attr_num)); 208 } 209 210 const void Node::set_comp(const string &comp_type){ 211 if(string_util::starts_with(comp_type,"NONE")){ 212 __comp_type=COMP_NONE; 213 }else if(string_util::starts_with(comp_type,"LZW")){ 214 __comp_type=COMP_LZW; 215 }else if(string_util::starts_with(comp_type,"RLE")){ 216 __comp_type=COMP_RLE; 217 }else if(string_util::starts_with(comp_type,"HUF")){ 218 __comp_type=COMP_HUF; 219 }else{ 220 throw invalid_argument("Do not understand compression type: "+comp_type); 221 } 222 223 // work with user specified dimension information 224 vector<string> temp=string_util::split(comp_type,":"); 225 if(temp.size()==2){ 226 __comp_buffer_dims=string_util::str_to_intVec(*(temp.rbegin())); 227 } 228 229 // use default if anything is wrong 230 if(__comp_buffer_dims.size()!=__dims.size()){ 231 __comp_buffer_dims=__dims; 232 for( size_t i=0 ; i<__comp_buffer_dims.size()-1 ; ++i ){ 233 __comp_buffer_dims[i]=1; 234 } 235 } 204 236 } 205 237 -
trunk/applications/NXtranslate/node.h
r772 r800 32 32 const int rank() const; 33 33 const std::vector<int> dims() const; 34 const std::vector<int> comp_buffer_dims() const; 34 35 const NXtype int_type() const; 35 36 const NXcompress compress_type() const; … … 40 41 41 42 // mutator methods 43 const void set_comp(const std::string &comp_type); 42 44 const void set_name(const std::string &name); 43 45 const void set_data(void *&data,const int rank,const int* dims,const int type); … … 53 55 bool __is_data; 54 56 std::vector<int> __dims; 57 std::vector<int> __comp_buffer_dims; 55 58 void *__value; 56 59 std::vector<Attr> __attrs; -
trunk/applications/NXtranslate/xml_parser.cpp
r783 r800 40 40 typedef NodeVector* NodeVectorP; 41 41 typedef Ptr<Retriever> RetrieverPtr; 42 typedef tree<Node> NodeTree; 42 43 43 44 static const int GROUP_STRING_LEN = 128; … … 47 48 static const string SOURCE = "NXS:source"; 48 49 static const string LOCATION = "NXS:location"; 50 static const string COMPRESSION = "NXS:compression"; 49 51 static const string LINK = "NAPIlink"; 50 52 static const string TARGET = "target"; … … 190 192 191 193 // check for "name", "type", "source", "mime_type", "location", 192 // "target" attributes194 // "target", "compression" attributes 193 195 string source; 194 196 string mime_type; 195 197 string location; 198 string compression; 196 199 string type; 197 200 bool update_dims=false; … … 199 202 for( StrVector::iterator it=str_attrs.begin() ; it!=str_attrs.end() ; it+=2){ 200 203 if( (*it==SOURCE) || (*it==MIME_TYPE) || (*it==LOCATION) || (*it==TYPE) 201 || ((*it==TARGET) && (is_link)) || (*it==NAME) ){204 || ((*it==TARGET) && (is_link)) || (*it==NAME) || (*it==COMPRESSION) ){ 202 205 if(*it==SOURCE){ 203 206 source=*(it+1); … … 206 209 }else if(*it==LOCATION){ 207 210 location=*(it+1); 211 }else if(*it==COMPRESSION){ 212 compression=*(it+1); 208 213 }else if(*it==NAME){ 209 214 type=str_name; … … 316 321 } 317 322 323 // set the compression flag 324 if(!compression.empty()){ 325 if(node_from_retriever){ 326 for( NodeTree::iterator it=tree.begin() ; it!=tree.end() ; ++it ){ 327 it->set_comp(compression); 328 } 329 }else{ 330 node.set_comp(compression); 331 } 332 } 333 318 334 // mutate the attributes if necessary 319 335 if(node_attrs.size()>0)
Note: See TracChangeset
for help on using the changeset viewer.
