本文整理汇总了C++中StringBuilder::format方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuilder::format方法的具体用法?C++ StringBuilder::format怎么用?C++ StringBuilder::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder::format方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: predict
//.........这里部分代码省略.........
if (target_jump != INVALID_POINTER && (target_annotation == source_annotation || !limit_to_functions)) {
p.pc = target_jump;
CUSTOM_ASSERT(target_jump != INVALID_POINTER);
predict_brances.push_back(p);
}
if (target_no_jump != INVALID_POINTER && (!limit_to_functions || (target_no_jump >= source_annotation->startOfRange && target_no_jump <= source_annotation->endOfRange))) {
// BRA,BRL and the jumps always branches/jumps
p.pc = target_no_jump;
CUSTOM_ASSERT(target_no_jump != INVALID_POINTER);
predict_brances.push_back(p);
}
}
}
StringBuilder sb;
sb.clear();
if (writer)
writer->writeSeperator("Prediction diagnostics");
for (int pbi=0; pbi<(int)predict_brances.size(); ++pbi) {
const PredictBranch pb = predict_brances[pbi];
Pointer pc = pb.pc;
Pointer r0 = limit_to_functions ? pb.annotation->startOfRange : 0, r1 = limit_to_functions ? pb.annotation->endOfRange : 0xFFFFFF;
uint16_t P = pb.P, DP = pb.DP;
uint8_t DB = pb.DB;
bool P_unknown = false;
if (inside_op[pc]) {
if (writer) {
sb.clear();
sb.format("Predicted jump at %06X jumped inside instruction at %06X. Consider adding a \"hint branch_always/branch_never %06X\" annotation.", pc, pb.from_pc, pb.from_pc);
writer->writeComment(sb);
}
printf("Warning; predicted jump went inside instruction at %06X (from %06X)\n", pc, pb.from_pc);
}
while (!has_op[pc] && pc >= r0 && pc <= r1) {
// Make sure we don't run into a data scope
const Annotation *data_scope = nullptr, *function_scope = nullptr;
annotations.resolve_annotation(pc, &function_scope, &data_scope);
if (data_scope)
continue;
if (function_scope && function_scope != pb.annotation)
continue;
uint8_t opcode = rom.evalByte(pc);
bool abort_unknown_P = P_unknown;
if (P_unknown) {
switch(opcode) {
case 0x02: // COP const
case 0x40: // RTI
case 0x6B: // RTL
case 0x60: // RTS
case 0x3B: // TSC
case 0xBA: // TSX
case 0x8A: // TXA
case 0x9A: // TXS
case 0x9B: // TXY
case 0x98: // TYA
case 0xBB: // TYX
示例2: parameterizeCharts
void Atlas::parameterizeCharts()
{
ParameterizationQuality globalParameterizationQuality;
// Paramterize the charts.
uint diskCount = 0;
const uint chartCount = m_chartArray.count();
for (uint i = 0; i < chartCount; i++)\
{
Chart * chart = m_chartArray[i];
bool isValid = false;
if (chart->isDisk())
{
diskCount++;
ParameterizationQuality chartParameterizationQuality;
if (chart->faceCount() == 1) {
computeSingleFaceMap(chart->unifiedMesh());
chartParameterizationQuality = ParameterizationQuality(chart->unifiedMesh());
}
else {
computeOrthogonalProjectionMap(chart->unifiedMesh());
ParameterizationQuality orthogonalQuality(chart->unifiedMesh());
computeLeastSquaresConformalMap(chart->unifiedMesh());
ParameterizationQuality lscmQuality(chart->unifiedMesh());
// If the orthogonal projection produces better results, just use that. @@ Make sure the orthogonal map is valid has no overlaps.
/*if (orthogonalQuality.rmsStretchMetric() < lscmQuality.rmsStretchMetric()) {
computeOrthogonalProjectionMap(chart->unifiedMesh());
chartParameterizationQuality = orthogonalQuality;
}
else*/ {
chartParameterizationQuality = lscmQuality;
}
// If conformal map failed,
// @@ Experiment with other parameterization methods.
//computeCircularBoundaryMap(chart->unifiedMesh());
//computeConformalMap(chart->unifiedMesh());
//computeNaturalConformalMap(chart->unifiedMesh());
//computeGuidanceGradientMap(chart->unifiedMesh());
}
//ParameterizationQuality chartParameterizationQuality(chart->unifiedMesh());
isValid = chartParameterizationQuality.isValid();
if (!isValid)
{
nvDebug("*** Invalid parameterization.\n");
#if 0
// Dump mesh to inspect problem:
static int pieceCount = 0;
StringBuilder fileName;
fileName.format("invalid_chart_%d.obj", pieceCount++);
exportMesh(chart->unifiedMesh(), fileName.str());
#endif
}
// @@ Check that parameterization quality is above a certain threshold.
// @@ Detect boundary self-intersections.
globalParameterizationQuality += chartParameterizationQuality;
}
if (!isValid)
{
//nvDebugBreak();
// @@ Run the builder again, but only on this chart.
//AtlasBuilder builder(chart->chartMesh());
}
// Transfer parameterization from unified mesh to chart mesh.
chart->transferParameterization();
}
nvDebug(" Parameterized %d/%d charts.\n", diskCount, chartCount);
nvDebug(" RMS stretch metric: %f\n", globalParameterizationQuality.rmsStretchMetric());
nvDebug(" MAX stretch metric: %f\n", globalParameterizationQuality.maxStretchMetric());
nvDebug(" RMS conformal metric: %f\n", globalParameterizationQuality.rmsConformalMetric());
nvDebug(" RMS authalic metric: %f\n", globalParameterizationQuality.maxAuthalicMetric());
}
示例3: build
//.........这里部分代码省略.........
// This check is not valid anymore, if the original mesh vertices were linked with a canonical map, then it might have
// some colocal vertices that were unlinked. So, the unified mesh might have some duplicate vertices, because firstColocal()
// is not guaranteed to return the same vertex for two colocal vertices.
//nvCheck(m_chartMesh->colocalVertexCount() == m_unifiedMesh->vertexCount());
// Is that OK? What happens in meshes were that happens? Does anything break? Apparently not...
Array<uint> faceIndices(7);
// Add faces.
for (uint f = 0; f < faceCount; f++)
{
const HalfEdge::Face * face = originalMesh->faceAt(faceArray[f]);
nvDebugCheck(face != NULL);
faceIndices.clear();
for(HalfEdge::Face::ConstEdgeIterator it(face->edges()); !it.isDone(); it.advance())
{
const HalfEdge::Vertex * vertex = it.current()->vertex;
nvDebugCheck(vertex != NULL);
faceIndices.append(chartMeshIndices[vertex->id]);
}
m_chartMesh->addFace(faceIndices);
faceIndices.clear();
for(HalfEdge::Face::ConstEdgeIterator it(face->edges()); !it.isDone(); it.advance())
{
const HalfEdge::Vertex * vertex = it.current()->vertex;
nvDebugCheck(vertex != NULL);
vertex = vertex->firstColocal();
faceIndices.append(unifiedMeshIndices[vertex->id]);
}
m_unifiedMesh->addFace(faceIndices);
}
m_chartMesh->linkBoundary();
m_unifiedMesh->linkBoundary();
//exportMesh(m_unifiedMesh.ptr(), "debug_input.obj");
if (m_unifiedMesh->splitBoundaryEdges()) {
m_unifiedMesh = unifyVertices(m_unifiedMesh.ptr());
}
//exportMesh(m_unifiedMesh.ptr(), "debug_split.obj");
// Closing the holes is not always the best solution and does not fix all the problems.
// We need to do some analysis of the holes and the genus to:
// - Find cuts that reduce genus.
// - Find cuts to connect holes.
// - Use minimal spanning trees or seamster.
if (!closeHoles()) {
/*static int pieceCount = 0;
StringBuilder fileName;
fileName.format("debug_hole_%d.obj", pieceCount++);
exportMesh(m_unifiedMesh.ptr(), fileName.str());*/
}
m_unifiedMesh = triangulate(m_unifiedMesh.ptr());
//exportMesh(m_unifiedMesh.ptr(), "debug_triangulated.obj");
// Analyze chart topology.
MeshTopology topology(m_unifiedMesh.ptr());
m_isDisk = topology.isDisk();
// This is sometimes failing, when triangulate fails to add a triangle, it generates a hole in the mesh.
//nvDebugCheck(m_isDisk);
/*if (!m_isDisk) {
static int pieceCount = 0;
StringBuilder fileName;
fileName.format("debug_hole_%d.obj", pieceCount++);
exportMesh(m_unifiedMesh.ptr(), fileName.str());
}*/
#if 0
if (!m_isDisk) {
nvDebugBreak();
static int pieceCount = 0;
StringBuilder fileName;
fileName.format("debug_nodisk_%d.obj", pieceCount++);
exportMesh(m_chartMesh.ptr(), fileName.str());
}
#endif
}
示例4: write
void SimPersistSet::write( Stream& stream, U32 tabStop, U32 flags )
{
if( ( flags & SelectedOnly ) && !isSelected() )
return;
// If the selection is transient, we cannot really save it.
// Just invoke the default SimObject::write and return.
if( !getCanSave() )
{
Con::errorf( "SimPersistSet::write - transient set being saved: %d:%s (%s)",
getId(), getClassName(), getName() );
Parent::write( stream, tabStop, flags );
return;
}
// If there are unresolved PIDs, give resolving them one last
// chance before writing out the set.
if( !mUnresolvedPIDs.empty() )
resolvePIDs();
// Write the set out.
stream.writeTabs( tabStop );
StringBuilder buffer;
buffer.format( "new %s(%s", getClassName(), getName() ? getName() : "" );
// Write the persistent IDs of all child objects into the set's
// object constructor so we see them passed back to us through
// processArguments when the object gets read in.
const U32 numChildren = size();
for( U32 i = 0; i < numChildren; ++ i )
{
SimObject* child = at( i );
SimPersistID* pid = child->getPersistentId();
AssertWarn( pid != NULL, "SimPersistSet::write - object without pid in persistent selection!" );
if( !pid )
continue;
buffer.append( ',' );
buffer.append( '"' );
buffer.append( pid->getUUID().toString() );
buffer.append( '"' );
}
buffer.append( ") {\r\n" );
stream.write( buffer.length(), buffer.data() );
// Write our object fields.
writeFields( stream, tabStop + 1 );
// Close our object definition.
stream.writeTabs( tabStop );
stream.write( 4, "};\r\n" );
}