vtkImageData* CImageLoader::load( std::string sFilename, TImagePtr& imagePtr ) { cerr << "Loading data... "; TDataFile theData = getFileServer().loadDataSet( sFilename ); if ( theData.first->getType() == typeid( short ) ) { imagePtr = static_pointer_cast<TImage>( theData.first ); cerr << "Correct" << endl; } else cerr << theData.first->getType().name() << endl; cerr << "done" << endl; cerr << "Starting conversion... "; // Create vtk structured points structure vtkImageData* sp = vtkImageData::New(); sp->SetDimensions( theData.first->getExtent(0), theData.first->getExtent(1), theData.first->getExtent(2) ); sp->AllocateScalars(); // Assign dataset to structured points vtkPointData *p=sp->GetPointData(); vtkShortArray* sArray = NULL; vtkDoubleArray* fArray = NULL; TField* floatSet = dynamic_cast<TField*>( theData.first.get() ); if ( floatSet != NULL ) { fArray = vtkDoubleArray::New(); fArray->SetArray(floatSet->getArray(), theData.first->getExtent(0)*theData.first->getExtent(1)*theData.first->getExtent(2), 1 ); p->SetScalars( fArray ); sp->SetScalarTypeToDouble(); } else { TImage* shortSet = dynamic_cast<TImage*>( theData.first.get() ); if ( shortSet != NULL ) { short* sA = new short[theData.first->getExtent(0)*theData.first->getExtent(1)*theData.first->getExtent(2)]; short* sAs = sA; for( TImage::iterator it = shortSet->begin(); it != shortSet->end(); ++it, ++sAs ) *sAs = *it; sArray = vtkShortArray::New(); sArray->SetArray( sA, theData.first->getExtent(0)*theData.first->getExtent(1)*theData.first->getExtent(2), 1 ); p->SetScalars( sArray ); sp->SetScalarTypeToShort(); } else { sp->Delete(); throw( FileException( "CVTkHandler - Unknown image format in dataset. Image was not saved" ) ); } } sp->UpdateData(); sp->SetSpacing( 1.0, 1.0, 1.0 ); sp->SetOrigin( static_cast<double>( theData.first->getExtent(0) )/ 2.0, static_cast<double>( theData.first->getExtent(1) )/ 2.0, static_cast<double>( theData.first->getExtent(2) )/ 2.0 ); cerr << sp->GetNumberOfScalarComponents() << endl; cerr << "done" << endl; return sp; }
void GetVariableTraverser::traverse(const TType &type, const TString &name, std::vector<VarT> *output) { const TStructure *structure = type.getStruct(); VarT variable; variable.name = name.c_str(); variable.arraySize = static_cast<unsigned int>(type.getArraySize()); if (!structure) { variable.type = GLVariableType(type); variable.precision = GLVariablePrecision(type); } else { // Note: this enum value is not exposed outside ANGLE variable.type = GL_STRUCT_ANGLEX; variable.structName = structure->name().c_str(); const TFieldList &fields = structure->fields(); for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) { TField *field = fields[fieldIndex]; traverse(*field->type(), field->name(), &variable.fields); } } visitVariable(&variable); ASSERT(output); output->push_back(variable); }
//--------------------------------------------------------------------------- void __fastcall ASEditDataSetAttachment::saveToFile(){ if(fFilePathExp.IsEmpty()) return; TClientDataSet *lds = fEditorDS->DataSetSvr->DataSet->DataSet; lds->First(); TField * lBlobField = lds->FieldByName(fBlobFieldName); if(!lBlobField) throw Exception("二进制字段不存在" + fFileNameField +"或者" + fBlobFieldName); while(!lds->Eof){ String lsPath = getFilePath(fEditorDS->DataSetSvr->DataSet->IDs); if(FileExists(lsPath)) DeleteFile(lsPath); if(lds->UpdateStatus() == usDeleted ){ lds->Next(); continue; } if(!lBlobField->IsNull){ // if(fIsImage) //图片 ((TGraphicField *)lBlobField)->SaveToFile(lsPath); else //附件 PCCompressor::DeCompressStringToBinFile(lsPath,lBlobField->AsString); if(fNotSaveInField){ fEditorDS->DataSetSvr->DataSet->beginEdit(); lBlobField->Clear(); fEditorDS->DataSetSvr->DataSet->endEdit(); } } lds->Next(); } }
static TString InterfaceBlockFieldName(const TInterfaceBlock &interfaceBlock, const TField &field) { if (interfaceBlock.hasInstanceName()) { return interfaceBlock.name() + "." + field.name(); } else { return field.name(); } }
bool CQueryResult::contains(string& filter, int nField) { bool bContains = false; TRecordSetIterator recordsIter = m_pRecords->begin(); while(recordsIter!=m_pRecords->end()) { TRecord* pRecord = *recordsIter; TField* field = (*pRecord)[nField]; if(field!=NULL && field->compare(filter)==0) { bContains = true; break; } recordsIter++; } return bContains; }
static TString InterfaceBlockFieldTypeString(const TField &field, TLayoutBlockStorage blockStorage) { const TType &fieldType = *field.type(); const TLayoutMatrixPacking matrixPacking = fieldType.getLayoutQualifier().matrixPacking; ASSERT(matrixPacking != EmpUnspecified); TStructure *structure = fieldType.getStruct(); if (fieldType.isMatrix()) { // Use HLSL row-major packing for GLSL column-major matrices const TString &matrixPackString = (matrixPacking == EmpRowMajor ? "column_major" : "row_major"); return matrixPackString + " " + TypeString(fieldType); } else if (structure) { // Use HLSL row-major packing for GLSL column-major matrices return QualifiedStructNameString(*structure, matrixPacking == EmpColumnMajor, blockStorage == EbsStd140); } else { return TypeString(fieldType); } }
void TListWindow::BogenhausenExport( TInfo *info ) { TPerson *person = (TPerson *)info->getRecord(); signed char *data = new char[TPerson::dataSize()]; memcpy( data, person->getData(), TPerson::dataSize() ); char fileName[13]; strcpy( fileName, &data[0x3C] ); strcat( fileName, ".Pat" ); mkdir( "Export" ); char fullpath[13 + 7]; strcpy( fullpath, "EXPORT\\" ); strcat( fullpath, fileName ); pvofstream file( fullpath, ios::out | ios::trunc ); signed char blanks[80]; memset( blanks, 0, sizeof( blanks ) ); file << "A"; switch( info->getAccessCode() ) { case 1: case 3: case 5: file << "A"; break; case 2: case 4: case 6: file << "S"; break; } file << "11"; file << '0'; file.write( &data[0x3C], 8 ); file.write( data, 30 ); file.write( blanks, 10 ); file.write( &data[0x1F], 15 ); file.write( blanks, 10 ); file.write( blanks, 30 ); strcpy( blanks, &data[0x2F] ); if( blanks[0] == ' ' ) blanks[0] = '0'; if( blanks[3] == ' ' ) blanks[3] = '0'; file.write( blanks, 10 ); memset( blanks, 0, sizeof( blanks ) ); file.write( blanks, 30 ); file.write( blanks, 2 ); switch( data[0x3A] ) { case 0: file << 'M'; break; case 1: file << 'W'; break; } file.write( blanks, 3 ); file.write( blanks, 2 ); file.write( blanks, 20 ); file.write( &data[0x54], 30 ); file.write( &data[0x73], 8 ); file.write( &data[0x7C], 20 ); file.write( blanks, 2 ); file.write( blanks, 20 ); file.write( blanks, 60 ); file.write( blanks, 1 ); file.write( blanks, 1 ); file << "\n"; file << "A"; switch( info->getAccessCode() ) { case 1: case 3: case 5: file << "A"; break; case 2: case 4: case 6: file << "S"; break; } file << "21"; file << '0'; file.write( &data[0x3C], 8 ); file.write( blanks, 30 ); strcpy( blanks, &data[0x45] ); if( blanks[0] == ' ' ) blanks[0] = '0'; if( blanks[3] == ' ' ) blanks[3] = '0'; file.write( blanks, 8 ); memset( blanks, 0, sizeof( blanks ) ); strcpy( blanks, &data[0x4E] ); blanks[2] = '.'; file.write( blanks, 5 ); memset( blanks, 0, sizeof( blanks ) ); switch( data[0x17F + 21] ) { case 0: file.write( "A3", 2 ); strcpy( blanks, "Selbst" ); break; case 1: file.write( "A1", 2 ); strcpy( blanks, "Rettungwagen" ); break; case 2: file.write( "A2", 2 ); strcpy( blanks, "Notarztwagen" ); break; case 3: file.write( "A4", 2 ); strcpy( blanks, "Hubschrauber" ); break; } file.write( blanks, 20 ); memset( blanks, 0, sizeof( blanks ) ); file.write( blanks, 3 ); file.write( blanks, 10 ); file.write( blanks, 30 ); file.write( &data[0x5D7 + 21], 38 ); file.write( &data[0x5D7 + 39 + 21], 38 ); file.write( &data[0x5D7 + 78 + 21], 38 ); file.write( &data[0x5D7 + 177 + 21], 6 ); formDialog->changeToPageNo( 2, False ); TField *field = formDialog->currentPage()->at( 0 ); field->getString( blanks ); file.write( blanks, 10 ); memset( blanks, 0, sizeof( blanks ) ); file.write( blanks, 4 ); // blanks? // file.write( blanks, 3 ); // memset( blanks, 0, sizeof( blanks ) ); // file.write( blanks, 1 ); // file.write( blanks, 5 ); // No blanks! // file.write( blanks, 2 ); // No blanks! formDialog->changeToPageNo( 2, False ); field = formDialog->currentPage()->at( 0 ); field->getString( blanks ); Boolean specialStation = False; int stationNum; if( strncmp( blanks, "04", 2 ) == 0 ) { specialStation = True; file.write( "N", 5 ); } if( strncmp( blanks, "05", 2 ) == 0 ) { specialStation = True; file.write( "OINT", 5 ); } if( strncmp( blanks, "08", 2 ) == 0 ) { specialStation = True; file.write( "B", 5 ); } if( strncmp( blanks, "31B", 3 ) == 0 ) { specialStation = True; file.write( "N", 5 ); } if( strncmp( blanks, "32", 2 ) == 0 ) { specialStation = True; file.write( "N", 5 ); } if( strncmp( blanks, "35", 2 ) == 0 ) { specialStation = True; file.write( "R", 5 ); } if( strncmp( blanks, "14", 2 ) == 0 ) { specialStation = True; file.write( "AKUT", 5 ); } if( strncmp( blanks, "15", 2 ) == 0 ) { specialStation = True; file.write( "AKUT", 5 ); } if( strncmp( blanks, "18", 2 ) == 0 ) { specialStation = True; file.write( "AKUT", 5 ); } if( strncmp( blanks, "33", 2 ) == 0 ) { specialStation = True; file.write( "AKUT", 5 ); } if( strncmp( blanks, "34", 2 ) == 0 ) { specialStation = True; file.write( "AKUT", 5 ); } memset( blanks, 0, sizeof( blanks ) ); if( specialStation ) { file.write( "01", 2 ); file.write( blanks, 5 ); file.write( blanks, 2 ); } else switch( info->getAccessCode() ) { case 1: case 3: case 5: if( data[0xCB] == 1 ) { file.write( "AMB", 5 ); file.write( "02", 2 ); file.write( blanks, 5 ); file.write( blanks, 2 ); } else { file.write( blanks, 5 ); file.write( blanks, 2 ); file.write( blanks, 5 ); file.write( blanks, 2 ); } break; case 2: case 4: case 6: if( data[0xCB] == 1 ) { file.write( "AKUT", 5 ); file.write( "01", 2 ); file.write( blanks, 5 ); file.write( blanks, 2 ); } else { file.write( "AKUT", 5 ); file.write( "01", 2 ); file.write( "ML", 5 ); file.write( "04", 2 ); } break; } file.write( blanks, 5 * 7 ); file.write( blanks, 10 ); file.write( blanks, 1 ); file << "\n"; file << "A"; switch( info->getAccessCode() ) { case 1: case 3: case 5: file << "A"; break; case 2: case 4: case 6: file << "S"; break; } file << "41"; file << '0'; file.write( &data[0x3C], 8 ); file.write( blanks, 3 ); file.write( data, 30 ); file.write( blanks, 10 ); file.write( blanks, 30 ); file.write( blanks, 8 ); file.write( blanks, 20 ); file.write( blanks, 20 ); file.write( blanks, 30 ); file.write( blanks, 30 ); file.write( blanks, 8 ); file.write( blanks, 20 ); file.write( blanks, 20 ); // file.write( &data[0xB8 + 21], 9 ); formDialog->changeToPageNo( 1, False ); field = formDialog->currentPage()->at( 0 ); field->getString( blanks ); if( info->getAccessCode() != 1 ) file.write( blanks, 9 ); // No blanks! else file.write( "DIVSONA", 9 ); memset( blanks, 0, sizeof( blanks ) ); file.write( blanks, 20 ); file.write( blanks, 1 ); file.write( blanks, 10 ); file << "\n"; if( info->getAccessCode() == 1 ) { file << "A"; switch( info->getAccessCode() ) { case 1: case 3: case 5: file << "A"; break; case 2: case 4: case 6: file << "S"; break; } file << "51"; file << '0'; file.write( &data[0x3C], 8 ); if( info->getAccessCode() != 1 ) file.write( blanks, 9 ); else file.write( "DIVSONA", 9 ); strcpy( blanks, &data[0x99] ); file.write( blanks, 30 ); //Name KrKasse memset( blanks, 0, sizeof( blanks ) ); strcpy( blanks, &data[0x91] ); file.write( blanks, 30 ); // Kassennr. memset( blanks, 0, sizeof( blanks ) ); strcpy( blanks, &data[0xB6] ); file.write( blanks, 30 ); //Versnr. memset( blanks, 0, sizeof( blanks ) ); strcpy( blanks, &data[0xC3] ); file.write( blanks, 8 ); //Status memset( blanks, 0, sizeof( blanks ) ); file.write( blanks, 20 ); file << "\n"; } if( data[0xCB] == 2 ) { file << "A"; switch( info->getAccessCode() ) { case 1: case 3: case 5: file << "A"; break; case 2: case 4: case 6: file << "S"; break; } file << "61"; file << '0'; file.write( &data[0x3C], 8 ); char name[100]; strcpy( name, data ); strcat( name, " " ); strcat( name, &data[0x1F] ); name[30] = 0; file.write( name, 30 ); //Name Vorname file.write( blanks, 20 ); file.write( blanks, 30 ); file.write( blanks, 30 ); file.write( blanks, 8 ); file.write( blanks, 20 ); file.write( blanks, 45 ); file.write( blanks, 8 ); file.write( blanks, 12 ); file.write( blanks, 30 ); file.write( blanks, 9 ); file << "\n"; } formDialog->changeToPageNo( noPage, False ); delete[] data; }