本文整理汇总了C++中std::fstream::precision方法的典型用法代码示例。如果您正苦于以下问题:C++ fstream::precision方法的具体用法?C++ fstream::precision怎么用?C++ fstream::precision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::fstream
的用法示例。
在下文中一共展示了fstream::precision方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_coordinates
void Writer::write_coordinates(std::fstream& file)
{
// set precision for Real
Uint prec = file.precision();
file.precision(8);
// Assemble a list of all the coordinates that are used in this mesh
const boost::shared_ptr< common::List<Uint> > used_nodes_ptr = build_used_nodes_list(m_filtered_entities,m_mesh->geometry_fields(),m_enable_overlap);
const common::List<Uint>& used_nodes = *used_nodes_ptr;
// Create a mapping between the actual node-numbering in the mesh, and the node-numbering to be written
const Uint nb_nodes = used_nodes.size();
file << "$Nodes\n";
file << nb_nodes << "\n";
const Uint nb_dim = m_mesh->dimension();
const Dictionary& geometry = m_mesh->geometry_fields();
const common::Table<Real>& coordinates = geometry.coordinates();
boost_foreach( const Uint node, used_nodes.array())
{
common::Table<Real>::ConstRow coord = coordinates[node];
file << geometry.glb_idx()[node]+1 << " ";
for (Uint d=0; d<3; d++)
{
if (d<nb_dim)
file << coord[d] << " ";
else
file << 0 << " ";
}
file << "\n";
}
file << "$EndNodes\n";
// restore precision
file.precision(prec);
}
示例2: OutputLegacyVPCF
void OutputLegacyVPCF(const KeyValues& DataBlock, std::fstream& f, const std::string& szOutputName)
{
std::fstream out;
out.open(szOutputName, ios::out);
if (!out.is_open())
throw std::string("Could not open file \"" + szOutputName + "\" for writing.");
f.precision(6);
out << "<!-- schema text{7e125a45-3d83-4043-b292-9e24f8ef27b4} generic {198980d8-3a93-4919-b4c6-dd1fb07a3a4b} -->\n\n";
out << "CParticleSystemDefinition CParticleSystemDefinition_0\n{\n";
for (uint32_t i = 0; i < DataBlock.size; ++i)
{
uint16_t nDataType = *(uint16_t*)(&DataBlock.name[i][strlen(DataBlock.name[i]) + 1]);
out << "\t";
if ((!OutputVPCFTypeData(out, DataBlock, i)) && (nDataType == KV_DATA_TYPE_STRUCT))
{
out.seekp(-1, ios::cur);
if (strncmp(DataBlock.name[i], "m_Children\0", 11) == 0)
{
KeyValues* pChildren = (KeyValues*)DataBlock.data[i];
out << "\tParticleChildrenInfo_t[] m_Children =\n\t[\n";
for (uint32_t j = 0; j < pChildren->size; ++j)
{
out << "\t\t" << pChildren->name[j] << "\n\t\t{\n";
KeyValues* pChild = (KeyValues*)pChildren->data[j];
for (uint32_t k = 0; k < pChild->size; ++k)
{
out << "\t\t\t";
OutputVPCFTypeData(out, *pChild, k);
}
out << "\t\t}" << ((j == pChildren->size - 1) ? "\n" : ",\n");
}
out << "\t]\n";
}
else
{
KeyValues* pOperators = (KeyValues*)DataBlock.data[i];
out << "\tCParticleOperator*[] " << DataBlock.name[i] << " =\n\t[\n";
for (uint32_t j = 0; j < pOperators->size; ++j)
{
KeyValues* pOperator = (KeyValues*)pOperators->data[j];
out << "\t\t&" << pOperator->name[0] << "_" << j << ((j < pOperators->size - 1) ? ",\n" : "\n");
}
out << "\t]\n";
}
}
}
out << "}\n";
for (uint32_t i = 0; i < DataBlock.size; ++i)
{
uint16_t nDataType = *(uint16_t*)(&DataBlock.name[i][strlen(DataBlock.name[i]) + 1]);
if ((nDataType == KV_DATA_TYPE_STRUCT) && (strncmp(DataBlock.name[i], "m_Children\0", 11) != 0))
{
KeyValues* pOperators = (KeyValues*)DataBlock.data[i];
for (uint32_t j = 0; j < pOperators->size; ++j)
{
KeyValues* pOperator = (KeyValues*)pOperators->data[j];
KeyValues* pOperatorData = (KeyValues*)pOperator->data[0];
out << "\n" << pOperator->name[0] << " " << pOperator->name[0] << "_" << j << "\n{\n";
bool bLastOutputSuccess = true;
for (uint32_t k = 0; k < pOperatorData->size; ++k)
{
if (bLastOutputSuccess)
out << "\t";
bLastOutputSuccess = OutputVPCFTypeData(out, *pOperatorData, k);
}
out << "}\n";
}
}
}
out.close();
}