本文整理汇总了C++中dxf::LineReader::ValueAsSignedInt方法的典型用法代码示例。如果您正苦于以下问题:C++ LineReader::ValueAsSignedInt方法的具体用法?C++ LineReader::ValueAsSignedInt怎么用?C++ LineReader::ValueAsSignedInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dxf::LineReader
的用法示例。
在下文中一共展示了LineReader::ValueAsSignedInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParsePolyLine
// ------------------------------------------------------------------------------------------------
void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
{
output.blocks.back().lines.push_back( std::shared_ptr<DXF::PolyLine>( new DXF::PolyLine() ) );
DXF::PolyLine& line = *output.blocks.back().lines.back();
unsigned int iguess = 0, vguess = 0;
while( !reader.End() && !reader.Is(0,"ENDSEC")) {
if (reader.Is(0,"VERTEX")) {
ParsePolyLineVertex(++reader,line);
if (reader.Is(0,"SEQEND")) {
break;
}
continue;
}
switch(reader.GroupCode())
{
// flags --- important that we know whether it is a
// polyface mesh or 'just' a line.
case 70:
if (!line.flags) {
line.flags = reader.ValueAsSignedInt();
}
break;
// optional number of vertices
case 71:
vguess = reader.ValueAsSignedInt();
line.positions.reserve(vguess);
break;
// optional number of faces
case 72:
iguess = reader.ValueAsSignedInt();
line.indices.reserve(iguess);
break;
// 8 specifies the layer on which this line is placed on
case 8:
line.layer = reader.Value();
break;
}
reader++;
}
//if (!(line.flags & DXF_POLYLINE_FLAG_POLYFACEMESH)) {
// DefaultLogger::get()->warn((Formatter::format("DXF: polyline not currently supported: "),line.flags));
// output.blocks.back().lines.pop_back();
// return;
//}
if (vguess && line.positions.size() != vguess) {
DefaultLogger::get()->warn((Formatter::format("DXF: unexpected vertex count in polymesh: "),
line.positions.size(),", expected ", vguess
));
}
if (line.flags & DXF_POLYLINE_FLAG_POLYFACEMESH ) {
if (line.positions.size() < 3 || line.indices.size() < 3) {
DefaultLogger::get()->warn("DXF: not enough vertices for polymesh; ignoring");
output.blocks.back().lines.pop_back();
return;
}
// if these numbers are wrong, parsing might have gone wild.
// however, the docs state that applications are not required
// to set the 71 and 72 fields, respectively, to valid values.
// So just fire a warning.
if (iguess && line.counts.size() != iguess) {
DefaultLogger::get()->warn((Formatter::format("DXF: unexpected face count in polymesh: "),
line.counts.size(),", expected ", iguess
));
}
}
else if (!line.indices.size() && !line.counts.size()) {
// a polyline - so there are no indices yet.
size_t guess = line.positions.size() + (line.flags & DXF_POLYLINE_FLAG_CLOSED ? 1 : 0);
line.indices.reserve(guess);
line.counts.reserve(guess/2);
for (unsigned int i = 0; i < line.positions.size()/2; ++i) {
line.indices.push_back(i*2);
line.indices.push_back(i*2+1);
line.counts.push_back(2);
}
// closed polyline?
if (line.flags & DXF_POLYLINE_FLAG_CLOSED) {
line.indices.push_back(static_cast<unsigned int>(line.positions.size()-1));
line.indices.push_back(0);
line.counts.push_back(2);
}
}
}