本文整理汇总了C++中ParameterNameValueType::SetValueFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterNameValueType::SetValueFloat方法的具体用法?C++ ParameterNameValueType::SetValueFloat怎么用?C++ ParameterNameValueType::SetValueFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterNameValueType
的用法示例。
在下文中一共展示了ParameterNameValueType::SetValueFloat方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteSmallCelFileNoStdev
void TestFileGenerator::WriteSmallCelFileNoStdev()
{
CelFileData data("small_cel_file_no_stdev");
data.SetIntensityCount(25);
data.SetStdDevCount(0);
data.SetPixelCount(25);
data.SetOutlierCount(2);
data.SetMaskCount(3);
data.SetRows(5);
data.SetCols(5);
data.SetArrayType(L"Hg-small");
data.SetAlgorithmName(L"Feature Extraction");
ParameterNameValueType nvt;
nvt.SetName(L"percentile");
nvt.SetValueFloat(0.75f);
data.AddAlgorithmParameter(nvt);
nvt.SetName(L"outlierlow");
nvt.SetValueFloat(1.004f);
data.AddAlgorithmParameter(nvt);
CelFileWriter* writer = new CelFileWriter(data);
FloatVector vInten;
Int16Vector vPixels;
for (int i=0; i<25; ++i)
{
vInten.push_back(100.0f*i);
vPixels.push_back(25);
}
// Do some writing
writer->WriteIntensities(vInten);
writer->WritePixels(vPixels);
// XYCoordVector
XYCoordVector outlier;
XYCoord xy(0,0);
outlier.push_back(xy);
xy.xCoord = 1;
xy.yCoord = 2;
outlier.push_back(xy);
writer->WriteOutlierCoords(outlier);
XYCoordVector masked;
xy.xCoord = 1;
xy.yCoord = 0;
masked.push_back(xy);
xy.xCoord = 2;
xy.yCoord = 1;
masked.push_back(xy);
xy.xCoord = 3;
xy.yCoord = 2;
masked.push_back(xy);
writer->WriteMaskCoords(masked);
delete writer;
}
示例2: SetFloatToGenericHdr
void CHPData::SetFloatToGenericHdr(const std::wstring& name, float value)
{
ParameterNameValueType paramType;
paramType.SetName(name);
paramType.SetValueFloat(value);
GenericDataHeader* hdr = genericData.Header().GetGenericDataHdr();
hdr->AddNameValParam(paramType);
}
示例3: WriteCelFileWithADataSetWithZeroRows
void TestFileGenerator::WriteCelFileWithADataSetWithZeroRows()
{
CelFileData data("small_cel_file_with_dataset_of_zero_rows");
data.SetIntensityCount(25);
data.SetStdDevCount(25);
data.SetPixelCount(25);
data.SetOutlierCount(0);
data.SetMaskCount(0);
data.SetRows(5);
data.SetCols(5);
data.SetArrayType(L"Hg-small");
data.SetAlgorithmName(L"Feature Extraction");
ParameterNameValueType nvt;
nvt.SetName(L"percentile");
nvt.SetValueFloat(0.75f);
data.AddAlgorithmParameter(nvt);
nvt.SetName(L"outlierlow");
nvt.SetValueFloat(1.004f);
data.AddAlgorithmParameter(nvt);
CelFileWriter* writer = new CelFileWriter(data);
FloatVector vInten;
FloatVector vStdev;
Int16Vector vPixels;
for (int i=0; i<25; ++i)
{
vInten.push_back(100.0f*i);
vStdev.push_back(.123f);
vPixels.push_back(25);
}
// Do some writing
writer->WriteIntensities(vInten);
writer->WriteStdDevs(vStdev);
writer->WritePixels(vPixels);
XYCoordVector outlier;
writer->WriteOutlierCoords(outlier);
XYCoordVector masked;
writer->WriteMaskCoords(masked);
delete writer;
}
示例4: WriteOutGenericDATDataFileNoGrid
void TestFileGenerator::WriteOutGenericDATDataFileNoGrid()
{
GenericDataHeader gdh;
AddStandardGenericDataHeader(gdh);
// Fill the DataGroupHeader
DataGroupHeader dch;
dch.SetName(L"First Data Cube");
// Fill the DataSetHeader
DataSetHeader dph;
dph.SetName(L"acquired data");
ParameterNameValueType nvt;
nvt.SetName(L"Scanner");
nvt.SetValueText(L"M10");
dph.AddNameValParam(nvt);
nvt.SetName(L"Pixel Size");
nvt.SetValueFloat(0.051f);
dph.AddNameValParam(nvt);
dph.AddColumn(UShortColumn(L"Pixel"));
int32_t rows = 100;
dph.SetRowCnt(rows);
dch.AddDataSetHdr(dph);
// Set the FileHeader
FileHeader fh;
fh.SetFilename("test.file.data_dat");
fh.SetGenericDataHdr(gdh);
fh.AddDataGroupHdr(dch);
// Create the generic file writer
GenericFileWriter gfWriter(&fh);
gfWriter.WriteHeader();
DataGroupWriterIt dcwBegin, dcwEnd;
gfWriter.GetDataGroupWriters(dcwBegin, dcwEnd);
DataGroupWriter d = *dcwBegin;
dcwBegin->WriteHeader();
DataSetWriterIt dpwBegin, dpwEnd;
dcwBegin->GetDataSetWriters(dpwBegin, dpwEnd);
dpwBegin->WriteHeader();
// Write out the data
for( int32_t i=0; i < rows; ++i )
{
u_int16_t value = (u_int16_t)(i*10+i);
dpwBegin->Write(value);
}
dpwBegin->UpdateNextDataSetOffset();
dcwBegin->Close();
}
示例5: AddParameters
void DATFileUpdaterTest::AddParameters(DATData& data)
{
ParameterNameValueType nvt;
nvt.SetName(L"Santa Clara");
nvt.SetValueUInt8(56);
data.AddGridAlignmentAlgorithmParameter(nvt);
nvt.SetName(L"San Mateo");
nvt.SetValueFloat(4.56f);
data.AddGridAlignmentAlgorithmParameter(nvt);
}
示例6: WriteSmallCelFileNoOutlierNoMask
void TestFileGenerator::WriteSmallCelFileNoOutlierNoMask()
{
CelFileData data("small_cel_file_no_outlier_no_mask");
data.SetIntensityCount(10);
data.SetStdDevCount(10);
data.SetPixelCount(10);
data.SetOutlierCount(0);
data.SetMaskCount(0);
data.SetRows(2);
data.SetCols(5);
data.SetArrayType(L"Hg-small");
data.SetAlgorithmName(L"Feature Extraction");
ParameterNameValueType nvt;
nvt.SetName(L"percentile");
nvt.SetValueFloat(0.75f);
data.AddAlgorithmParameter(nvt);
nvt.SetName(L"outlierlow");
nvt.SetValueFloat(1.004f);
data.AddAlgorithmParameter(nvt);
CelFileWriter* writer = new CelFileWriter(data);
FloatVector vInten;
FloatVector vStdev;
Int16Vector vPixels;
for (int i=0; i<10; ++i)
{
vInten.push_back(100.0f*i);
vStdev.push_back(.5*i);
vPixels.push_back(25);
}
// Do some writing
writer->WriteIntensities(vInten);
writer->WriteStdDevs(vStdev);
writer->WritePixels(vPixels);
delete writer;
}
示例7: finish
/**
* No more probesets will be processed, this is a chance to finish outputting
* results and clean up.
* @param qMethod - Quantification method that was used.
* @return true if success, false otherwise.
*/
bool QuantMethodExprCCCHPReport::finish(QuantMethod &qMethod)
{
// Sanity to check we saw all the probe sets we were expecting.
if (m_CurrentProbeSetCount != m_Info.m_NumProbeSets) {
Err::errAbort("QuantMethodExprCCCHPReport::finish() - Expecting: " + ToStr(m_Info.m_NumProbeSets) +
" but got: " + ToStr(m_CurrentProbeSetCount) + ". Command Console CHP file will be corrupt.");
}
// Flush remaining signal entries in the buffer.
m_ExpressionQuantificationBufferWriter.FlushBuffer();
// Rewrite CHP files to get chip summary entires
Verbose::out(1,"Creating final files for CHP output");
Verbose::progressBegin(1, ToStr("Finalizing Expression CHP Files"),
m_CHPFileNames.size(), 1, m_CHPFileNames.size());
try {
for (unsigned int chip = 0; chip < m_CHPFileNames.size(); chip++) {
// open up tmp chp file to pull results from
GenericData data;
GenericFileReader reader;
std::string filename = m_CHPFileNames[chip]+".tmp";
reader.SetFilename(filename);
reader.ReadHeader(data);
GenericDataHeader* hdr = data.Header().GetGenericDataHdr();
GenericDataHeader updateHdr;
for (int source = 0; source < m_ChipSummaries.size(); source++) {
ChipSummary::metricDefVec_t metricDefs = m_ChipSummaries[source]->getMetricDefs();
for (int i = 0; i < metricDefs.size(); i++) {
ChipSummary::Metric metric;
if (!m_ChipSummaries[source]->getMetric(chip, metricDefs[i].m_name, metric)) {
Err::errAbort("QuantMethodExprCCCHPReport: metric '" + metricDefs[i].m_name +
"' was not found");
}
std::wstring mName(CHIP_SUMMARY_PARAMETER_NAME_PREFIX);
mName += StringUtils::ConvertMBSToWCS(metric.m_Name);
ParameterNameValueType param;
if (hdr->FindNameValParam(mName, param) == false) {
Err::errAbort("QuantMethodExprCCCHPReport: metric name '" + StringUtils::ConvertWCSToMBS(mName) +
"' could not be found in the header of " + filename);
}
switch (param.GetParameterType()) {
case ParameterNameValueType::Int8Type:
param.SetValueInt8((int8_t)metric.m_Integer);
break;
case ParameterNameValueType::UInt8Type:
param.SetValueUInt8((u_int8_t)metric.m_Integer);
break;
case ParameterNameValueType::Int16Type:
param.SetValueInt16((int16_t)metric.m_Integer);
break;
case ParameterNameValueType::UInt16Type:
param.SetValueUInt16((u_int16_t)metric.m_Integer);
break;
case ParameterNameValueType::Int32Type:
param.SetValueInt32((int32_t)metric.m_Integer);
break;
case ParameterNameValueType::UInt32Type:
param.SetValueUInt32((u_int32_t)metric.m_Integer);
break;
case ParameterNameValueType::FloatType:
param.SetValueFloat((float)metric.m_Double);
break;
case ParameterNameValueType::TextType:
param.SetValueText(StringUtils::ConvertMBSToWCS(metric.m_String), (int) metric.m_String.length());
break;
case ParameterNameValueType::AsciiType:
if (metric.m_String.size() > 256) {
Err::errAbort("QuantMethodExprCCCHPReport: string header parameter too long, name = '" +
metric.m_Name + "', value = '" + metric.m_String + "'");
}
param.SetValueAscii(metric.m_String, (int) metric.m_String.length());
break;
default:
Err::errAbort("QuantMethodExprCCCHPReport: unknown header parameter type found in file " +
filename);
}
updateHdr.AddNameValParam(param);
}
}
std::ofstream os;
Fs::aptOpen(os, filename, std::ios::out|std::ios::binary|std::ios::in);
if (!os) {
Err::errAbort("QuantMethodExprCCCHPReport: file " + filename +
//.........这里部分代码省略.........
示例8: prepare
//.........这里部分代码省略.........
Err::errAbort("Unable to read CEL file: "+FS_QUOTE_PATH(tmp_unc_name));
}
GenericData *gdata = cel.GetGenericData();
if (gdata != NULL) {
data->GetFileHeader()->GetGenericDataHdr()->AddParent(*gdata->Header().GetGenericDataHdr());
}
cel.Close();
}
catch (...) {
Err::errAbort("Unable to read CEL file: "+FS_QUOTE_PATH(tmp_unc_name));
}
data->SetEntryCount(m_Info.m_NumProbeSets, maxProbeSetNameLength);
data->SetAlgName(algName);
data->SetAlgVersion(algVersion);
data->SetArrayType(chipType);
param.SetName(L"program-name");
param.SetValueText(StringUtils::ConvertMBSToWCS(m_Info.m_ProgramName));
data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param);
param.SetName(L"program-version");
param.SetValueText(StringUtils::ConvertMBSToWCS(m_Info.m_ProgramVersion));
data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param);
param.SetName(L"program-company");
param.SetValueText(StringUtils::ConvertMBSToWCS(m_Info.m_ProgramCompany));
data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param);
// Add algorithm parameters to list.
ParameterNameValueTypeList paramList;
assert(m_Info.m_ParamNames.size() == m_Info.m_ParamValues.size());
for (int i=0; i<m_Info.m_ParamNames.size(); i++) {
if (m_Info.m_ParamValues[i].length() > 0) {
param.SetName(StringUtils::ConvertMBSToWCS(m_Info.m_ParamNames[i]));
param.SetValueText(StringUtils::ConvertMBSToWCS(m_Info.m_ParamValues[i]));
paramList.push_back(param);
}
}
// Add list of all CEL GUIDs in batch
///@todo should this be computed by the engine and passed in via AnalysisInfo?
string prefix = "apt-opt-";
for (int chip=0; chip<m_CHPFileNames.size(); chip++) {
if (m_celGuids[chip].empty() == false) {
string paramName = prefix + "cel-guid-" + ToStr(chip+1);
param.SetName(StringUtils::ConvertMBSToWCS(paramName));
param.SetValueText(StringUtils::ConvertMBSToWCS(m_celGuids[chip]));
paramList.push_back(param);
}
}
data->AddAlgParams(paramList);
// Add the run report parameters to the list
ParameterNameValueTypeList summaryParamList;
std::string blankStr(256, ' ');
for (int source=0; source<m_ChipSummaries.size(); source++) {
ChipSummary::metricDefVec_t metricDefs = m_ChipSummaries[source]->getMetricDefs();
for (int i = 0; i < metricDefs.size(); i++) {
param.SetName(StringUtils::ConvertMBSToWCS(metricDefs[i].m_name));
if (metricDefs[i].m_type == ChipSummary::Metric::Double) {
param.SetValueFloat(-1.0);
}
else if (metricDefs[i].m_type == ChipSummary::Metric::Integer) {
param.SetValueInt32(-1);
}
else if (metricDefs[i].m_type == ChipSummary::Metric::String) {
param.SetValueAscii(blankStr);
}
else {
Err::errAbort("QuantMethodExprCCCHPReport: Unable to handle unknown type: " +
ToStr(metricDefs[i].m_type) );
}
summaryParamList.push_back(param);
}
}
data->AddSummaryParams(summaryParamList);
ProbeSetQuantificationData entry;
CHPQuantificationFileWriter writer(*data);
writer.SeekToDataSet(); // seek to data table location
for (int index=0; index<m_Info.m_ProbesetNames.size(); index++) {
if (m_Info.m_ProbesetDisplayNames.size() > 0 && m_Info.m_ProbesetDisplayNames[index] != NULL)
entry.name = m_Info.m_ProbesetDisplayNames[index];
else
entry.name = m_Info.m_ProbesetNames[index];
entry.quantification = 0.0f;
writer.WriteEntry(entry);
}
delete data;
}
catch (...) {
Err::errAbort("QuantMethodExprCHPReport::prepare() - Unable to write header and/or precreate signal entries to file: " + m_CHPFileNames[chip] + ".tmp");
}
}
// initialize expression signal buffer writer
m_ExpressionQuantificationBufferWriter.Initialize(&m_TmpChpFiles);
return true;
}
示例9: data
void CalvinCHPMultiDataFileUpdaterTest::CreateReferenceFile2()
{
CHPMultiDataData data(TEST2_FILE);
vector<ColumnInfo> cols;
ParameterNameValueType nv;
ByteColumn bcol(L"byte");
cols.push_back(bcol);
UByteColumn ubcol(L"ubyte");
cols.push_back(ubcol);
ShortColumn scol(L"short");
cols.push_back(scol);
UShortColumn uscol(L"ushort");
cols.push_back(uscol);
IntColumn icol(L"int");
cols.push_back(icol);
UIntColumn uicol(L"uint");
cols.push_back(uicol);
FloatColumn fcol(L"float");
cols.push_back(fcol);
ASCIIColumn acol(L"ascii", 7);
cols.push_back(acol);
UnicodeColumn tcol(L"text", 10);
cols.push_back(tcol);
ProbeSetMultiDataGenotypeData e;
data.SetEntryCount(GenotypeMultiDataType, 4, 10, cols);
CHPMultiDataFileWriter *writer = new CHPMultiDataFileWriter(data);
nv.SetName(L"byte");
nv.SetValueInt8(8);
e.metrics.push_back(nv);
nv.SetName(L"ubyte");
nv.SetValueUInt8(8);
e.metrics.push_back(nv);
nv.SetName(L"short");
nv.SetValueInt16(16);
e.metrics.push_back(nv);
nv.SetName(L"ushort");
nv.SetValueUInt16(16);
e.metrics.push_back(nv);
nv.SetName(L"int");
nv.SetValueInt32(32);
e.metrics.push_back(nv);
nv.SetName(L"uint");
nv.SetValueUInt32(32);
e.metrics.push_back(nv);
nv.SetName(L"float");
nv.SetValueFloat(44.0f);
e.metrics.push_back(nv);
nv.SetName(L"ascii");
nv.SetValueAscii("ascii");
e.metrics.push_back(nv);
nv.SetName(L"text");
nv.SetValueText(L"text");
e.metrics.push_back(nv);
writer->SeekToDataSet(GenotypeMultiDataType);
e.name = "1";
e.call = 1;
e.confidence = 10.0f;
writer->WriteEntry(e);
e.name = "2";
e.call = 2;
e.confidence = 20.0f;
writer->WriteEntry(e);
e.name = "3";
e.call = 3;
e.confidence = 30.0f;
writer->WriteEntry(e);
e.name = "4";
e.call = 4;
e.confidence = 40.0f;
writer->WriteEntry(e);
delete writer;
}
示例10: WriteLargeCelFile
void TestFileGenerator::WriteLargeCelFile()
{
CelFileData data("large_cel_file");
data.SetRows(2560);
data.SetCols(2560);
int32_t cells = 2560*2560;
data.SetIntensityCount(cells);
data.SetStdDevCount(cells);
data.SetPixelCount(cells);
data.SetOutlierCount(2000);
data.SetMaskCount(3000);
ParameterNameValueType nvt;
nvt.SetName(L"percentile");
nvt.SetValueFloat(0.75f);
data.AddAlgorithmParameter(nvt);
nvt.SetName(L"outlierlow");
nvt.SetValueFloat(1.004f);
data.AddAlgorithmParameter(nvt);
CelFileWriter* writer = new CelFileWriter(data);
FloatVector vInten;
FloatVector vStdev;
Int16Vector vPixels;
vInten.resize(cells);
vStdev.resize(cells);
vPixels.resize(cells);
int32_t intenTestValues[4] = {55683.0f, 4568.0f, 2368.0f, 100.0f};
float stdevTestValues[4] = {2.345f, 56.23f, 1.53f, 3.875f};
//int32_t testIdx = 0;
for (int32_t i=0, testIdx=0; i<cells; ++i, ++testIdx)
{
if (testIdx >= 4)
testIdx = 0;
vInten[i] = intenTestValues[testIdx];
vStdev[i] = stdevTestValues[testIdx];
vPixels[i] = 25;
}
// Do some writing
writer->WriteIntensities(vInten);
writer->WriteStdDevs(vStdev);
writer->WritePixels(vPixels);
XYCoord xy(0,0);
XYCoordVector outlier;
for (int32_t i=0, col=2000; i<2000; ++i, --col)
{
xy.xCoord = i;
xy.yCoord = col;
outlier.push_back(xy);
}
writer->WriteOutlierCoords(outlier);
XYCoordVector masked;
for (int32_t i=0; i<1500; ++i)
{
xy.xCoord = 1200;
xy.yCoord = i;
masked.push_back(xy);
xy.xCoord = 2400;
xy.yCoord = i;
masked.push_back(xy);
}
writer->WriteMaskCoords(masked);
delete writer;
}
示例11: WriteRemaingSmallCelFileWithGridParameters
void TestFileGenerator::WriteRemaingSmallCelFileWithGridParameters(CelFileData& data)
{
data.SetIntensityCount(25);
data.SetStdDevCount(25);
data.SetPixelCount(25);
data.SetOutlierCount(2);
data.SetMaskCount(3);
data.SetRows(5);
data.SetCols(5);
data.SetArrayType(L"Hg-small");
data.SetLibraryPackageName(L"Hg-small-lib-package");
data.SetMasterFileName(L"Hg-small-master-file");
data.SetAlgorithmName(L"Feature Extraction");
ParameterNameValueType nvt;
nvt.SetName(L"percentile");
nvt.SetValueFloat(0.75f);
data.AddAlgorithmParameter(nvt);
nvt.SetName(L"outlierlow");
nvt.SetValueFloat(1.004f);
data.AddAlgorithmParameter(nvt);
nvt.SetName(L"CellMargin");
nvt.SetValueInt32(2);
data.AddAlgorithmParameter(nvt);
// Add grid
wchar_t* gridParams[] = {L"GridULX", L"GridULY", L"GridURX", L"GridURY", L"GridLRX", L"GridLRY", L"GridLLX", L"GridLLY" };
for (int32_t i = 0; i < 8; ++i)
{
nvt.SetName(gridParams[i]);
nvt.SetValueFloat(2.0f + (float)i);
data.AddAlgorithmParameter(nvt);
}
CelFileWriter* writer = new CelFileWriter(data);
FloatVector vInten;
FloatVector vStdev;
Int16Vector vPixels;
for (int i=0; i<25; ++i)
{
vInten.push_back(100.0f*i);
vStdev.push_back(.5*i);
vPixels.push_back(25);
}
// Do some writing
writer->WriteIntensities(vInten);
writer->WriteStdDevs(vStdev);
writer->WritePixels(vPixels);
// XYCoordVector
XYCoordVector outlier;
XYCoord xy(0,0);
outlier.push_back(xy);
xy.xCoord = 1;
xy.yCoord = 2;
outlier.push_back(xy);
writer->WriteOutlierCoords(outlier);
XYCoordVector masked;
xy.xCoord = 1;
xy.yCoord = 0;
masked.push_back(xy);
xy.xCoord = 2;
xy.yCoord = 1;
masked.push_back(xy);
xy.xCoord = 3;
xy.yCoord = 2;
masked.push_back(xy);
writer->WriteMaskCoords(masked);
delete writer;
}
示例12: WriteOutGenericDATDataFileWithGrid
void TestFileGenerator::WriteOutGenericDATDataFileWithGrid()
{
GenericDataHeader gdh;
AddStandardGenericDataHeader(gdh);
// Fill the DataGroupHeader
DataGroupHeader dch;
dch.SetName(L""); // unnamed DataGroup
// Fill the pixel intensity DataSetHeader
DataSetHeader dphPixel;
dphPixel.SetName(L"acquired data");
ParameterNameValueType nvt;
nvt.SetName(L"Scanner");
nvt.SetValueText(L"M10");
dphPixel.AddNameValParam(nvt);
nvt.SetName(L"Pixel Size");
nvt.SetValueFloat(0.051f);
dphPixel.AddNameValParam(nvt);
dphPixel.AddColumn(UShortColumn(L"Pixel"));
int32_t rows = 1000;
dphPixel.SetRowCnt(rows);
dch.AddDataSetHdr(dphPixel);
// Fill the grid DataSetHeader
DataSetHeader dphGrid;
dphGrid.SetName(L"grid position");
nvt.SetName(L"GhostGrids");
nvt.SetValueText(L"True");
dphGrid.AddNameValParam(nvt);
nvt.SetName(L"Pixel Size");
nvt.SetValueFloat(0.051f);
dphGrid.AddNameValParam(nvt);
dphGrid.AddColumn(FloatColumn(L"Upper left x"));
dphGrid.AddColumn(FloatColumn(L"Upper left y"));
dphGrid.AddColumn(FloatColumn(L"Upper right x"));
dphGrid.AddColumn(FloatColumn(L"Upper right y"));
dphGrid.AddColumn(FloatColumn(L"Lower right x"));
dphGrid.AddColumn(FloatColumn(L"Lower right y"));
dphGrid.AddColumn(FloatColumn(L"Lower left x"));
dphGrid.AddColumn(FloatColumn(L"Lower left y"));
int32_t grids = 5; // first is the global grid with 4 subgrids
dphGrid.SetRowCnt(grids);
dch.AddDataSetHdr(dphGrid);
// Set the FileHeader
FileHeader fh;
fh.SetFilename("test.file.data_dat_with_grid");
fh.SetGenericDataHdr(gdh);
fh.AddDataGroupHdr(dch);
// Create the generic file writer
GenericFileWriter gfWriter(&fh);
gfWriter.WriteHeader();
DataGroupWriterIt dcwBegin, dcwEnd;
gfWriter.GetDataGroupWriters(dcwBegin, dcwEnd);
DataGroupWriter d = *dcwBegin;
dcwBegin->WriteHeader();
DataSetWriterIt dpwBegin, dpwEnd;
dcwBegin->GetDataSetWriters(dpwBegin, dpwEnd);
// Write out the pixel DataSet
dpwBegin->WriteHeader();
for( int32_t i=0; i < rows; ++i )
{
u_int16_t value = (u_int16_t)(i*10+i);
dpwBegin->Write(value);
}
dpwBegin->UpdateNextDataSetOffset();
++dpwBegin;
// Write out the grid DataSet
dpwBegin->WriteHeader();
for( int32_t i=0; i < grids; ++i )
{
for (int32_t corner = 0; corner < 4; ++corner)
{
float value = (float)(i*100 + corner);
dpwBegin->Write(value);
dpwBegin->Write(value);
}
}
dpwBegin->UpdateNextDataSetOffset();
//.........这里部分代码省略.........
示例13: dphWriter
// Uses a mix of the GenericFileWriter and raw commands
void TestFileGenerator::WriteOutGenericDATDataFile1UsingGenericWriter()
{
GenericDataHeader gdh;
AddStandardGenericDataHeader(gdh);
// Fill the DataSetHeader
DataSetHeader dph;
dph.SetName(L"acquired data");
ParameterNameValueType nvt;
nvt.SetName(L"Scanner");
nvt.SetValueText(L"M10");
dph.AddNameValParam(nvt);
nvt.SetName(L"Pixel Size");
nvt.SetValueFloat(0.051f);
dph.AddNameValParam(nvt);
dph.AddColumn(UShortColumn(L"Pixel"));
int32_t rows = 100;
dph.SetRowCnt(rows);
// Open the file.
ofstream fileStream;
fileStream.open( "test.file.data_dat", ios_base::out | ios_base::binary | ios_base::trunc);
// Write the file header using raw methods until the writer is available.
// magic number
FileOutput::WriteUInt8(fileStream, 59);
// version
FileOutput::WriteInt8(fileStream, 1);
// Number of data cubes - confirm this
FileOutput::WriteUInt32(fileStream, 1);
// offset to the data cube byte offset array
int offsetLocation = fileStream.tellp();
FileOutput::WriteUInt32(fileStream, 1); //????
// Write the GenericDataHeader to the file
GenericDataHeaderWriter gdhWriter;
gdhWriter.Write(fileStream, gdh);
//
// Data Cube
//
int offset = fileStream.tellp();
// Write the DataSetHeader
DataSetWriter dphWriter(&fileStream, &dph);
dphWriter.WriteHeader();
// Write out the data
for( int32_t i=0; i < rows; ++i )
{
u_int16_t value = (u_int16_t)(i*10+i);
FileOutput::WriteUInt16(fileStream, value);
}
// write the offset
fileStream.seekp(offsetLocation);
FileOutput::WriteUInt32(fileStream, offset);
fileStream.close();
}