本文整理汇总了C++中Chain::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ Chain::c_str方法的具体用法?C++ Chain::c_str怎么用?C++ Chain::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chain
的用法示例。
在下文中一共展示了Chain::c_str方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readObj
Chain VertexStream::readObj(const Chain & fname) {
InputBuffer in(fname.c_str());
Chain src = in.readString(in.get_Size()).c_str();
src.setDelimiters("\n\r");
int numValues;
Chain token;
if (!src.length()) {
return "The file could not be opened";
}
vector<GLfloat> OBJvertexList;
vector<GLfloat> OBJtexCoords;
vector<GLfloat> OBJnormals;
vector<GLfloat> OBJspaceCoords;
vector<GLfloat> OBJfaceVertex;
src.nextLink();
while(src.linksLeft()) {
Chain line;
line.setDelimiters(" ");
line = src.getLink().c_str();
//cout << "Currentline: {" << line << "}" << endl;
if (line.getLink()[0] == '#') {
// read comment
cout << "Reading a comment..." << endl;
src++;
} else if (line.getLink() == "v") {
// read vertices
Chain vertexLine;
vertexLine.setDelimiters(" \t");
vertexLine = line.c_str();
numValues = 0;
cout << "Read vertex {";
vertexLine++; // skip v
while(vertexLine.linksLeft()) {
numValues++;
OBJvertexList.push_back(atof(vertexLine.getLink().c_str()));
cout << vertexLine.getLink().c_str() << ", ";
vertexLine++;
}
if (numValues == 3) {
OBJvertexList.push_back(1.f);
cout << "1.f";
}
cout << "}" << endl;
src++;
} else if (line.getLink() == "vt") {
// texture coords
Chain textureLine;
textureLine.setDelimiters(" \t");
textureLine = line.c_str();
int numCoords = 0;
cout << "Read texCoords {";
textureLine++; // skip vt
while(textureLine.linksLeft() && numCoords < 2) {
cout << textureLine.getLink().c_str() << ", ";
OBJtexCoords.push_back(atof(textureLine.getLink().c_str()));
numCoords++;
textureLine++;
// discard optional 3rd coordinate
}
cout << "}\n";
src++;
} else if (line.getLink() == "vn") {
// normals
Chain normalLine;
normalLine.setDelimiters(" \t");
normalLine = line.c_str();
cout << "read normal {";
normalLine++; // skip vn
while(normalLine.linksLeft()){
cout << normalLine.getLink() << ", ";
OBJnormals.push_back(atof(normalLine.getLink().c_str()));
normalLine++;
}
cout << "}" << endl;
src++;
//.........这里部分代码省略.........
示例2: readPly
Chain VertexStream::readPly(const Chain & fname) {
InputBuffer in(fname.c_str());
Chain src = in.readString(in.get_Size()).c_str();
int stage = 0;
Chain format = "ascii";
Chain version = "0.f";
Chain comments = "";
vector<vector<GLfloat>> properties;
vector<Chain> propertyNames;
vector<vector<GLfloat>> elements;
vector<Chain> elementNames;
int curElement = 0;
// header
if (src.getLink() != "ply") {
return ("Header incorrect. Missing \" ply \".");
}
src++;
while (stage == 0 && src.linksLeft()) {
Chain curToken = src.getLink(); src++;
// reading format
if (curToken == "format") {
if (src.getLink() != "ascii" ||
src.getLink() != "binary_big_endian" ||
src.getLink() != "binary_little_endian") {
Chain out = "Header error: incorrect or unsupported format listed";
out += src.getLink();
} else {
format = src.getLink();
}
src++;
version = src.getLink(); src++;
} else if (curToken == "comment") {
// comments appended to one text buffer
comments += src.getLink(); src++;
} else if (curToken == "element") {
// element <element name> <num entries>
// can use the num entries to spot check the element list later
curElement = elementNames.size();
elementNames.push_back(src.getLink()); src++;
int size = atoi(src.getLink());
elements.push_back(vector<GLfloat>(size));
} else if (curToken == "property") {
// a propoerty is always of the currently defined element
}
}
return "";
}