当前位置: 首页>>代码示例>>C++>>正文


C++ LineReader::Is方法代码示例

本文整理汇总了C++中dxf::LineReader::Is方法的典型用法代码示例。如果您正苦于以下问题:C++ LineReader::Is方法的具体用法?C++ LineReader::Is怎么用?C++ LineReader::Is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dxf::LineReader的用法示例。


在下文中一共展示了LineReader::Is方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParseBlocks

// ------------------------------------------------------------------------------------------------
void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) {
    while( !reader.End() && !reader.Is(0,"ENDSEC")) {
        if (reader.Is(0,"BLOCK")) {
            ParseBlock(++reader,output);
            continue;
        }
        ++reader;
    }

    ASSIMP_LOG_DEBUG_F("DXF: got ", output.blocks.size()," entries in BLOCKS" );
}
开发者ID:JLouis-B,项目名称:assimp,代码行数:12,代码来源:DXFLoader.cpp

示例2: ParseBlocks

// ------------------------------------------------------------------------------------------------
void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output)
{
    while( !reader.End() && !reader.Is(0,"ENDSEC")) {
        if (reader.Is(0,"BLOCK")) {
            ParseBlock(++reader,output);
            continue;
        }
        ++reader;
    }

    DefaultLogger::get()->debug((Formatter::format("DXF: got "),
        output.blocks.size()," entries in BLOCKS"
    ));
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:15,代码来源:DXFLoader.cpp

示例3: ParseEntities

// ------------------------------------------------------------------------------------------------
void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output)
{
    // push a new block onto the stack.
    output.blocks.push_back( DXF::Block() );
    DXF::Block& block = output.blocks.back();

    block.name = AI_DXF_ENTITIES_MAGIC_BLOCK;

    while( !reader.End() && !reader.Is(0,"ENDSEC")) {
        if (reader.Is(0,"POLYLINE")) {
            ParsePolyLine(++reader,output);
            continue;
        }

        else if (reader.Is(0,"INSERT")) {
            ParseInsertion(++reader,output);
            continue;
        }

        else if (reader.Is(0,"3DFACE") || reader.Is(0,"LINE") || reader.Is(0,"3DLINE")) {
            //http://sourceforge.net/tracker/index.php?func=detail&aid=2970566&group_id=226462&atid=1067632
            Parse3DFace(++reader, output);
            continue;
        }

        ++reader;
    }

    DefaultLogger::get()->debug((Formatter::format("DXF: got "),
        block.lines.size()," polylines and ", block.insertions.size() ," inserted blocks in ENTITIES"
    ));
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:33,代码来源:DXFLoader.cpp

示例4: ParseInsertion

void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output)
{
    output.blocks.back().insertions.push_back( DXF::InsertBlock() );
    DXF::InsertBlock& bl = output.blocks.back().insertions.back();

    while( !reader.End() && !reader.Is(0)) {

        switch(reader.GroupCode())
        {
            // name of referenced block
        case 2:
            bl.name = reader.Value();
            break;

            // translation
        case 10:
            bl.pos.x = reader.ValueAsFloat();
            break;
        case 20:
            bl.pos.y = reader.ValueAsFloat();
            break;
        case 30:
            bl.pos.z = reader.ValueAsFloat();
            break;

            // scaling
        case 41:
            bl.scale.x = reader.ValueAsFloat();
            break;
        case 42:
            bl.scale.y = reader.ValueAsFloat();
            break;
        case 43:
            bl.scale.z = reader.ValueAsFloat();
            break;

            // rotation angle
        case 50:
            bl.angle = reader.ValueAsFloat();
            break;
        }
        reader++;
    }
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:44,代码来源:DXFLoader.cpp

示例5: ParseBlock

// ------------------------------------------------------------------------------------------------
void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output)
{
    // push a new block onto the stack.
    output.blocks.push_back( DXF::Block() );
    DXF::Block& block = output.blocks.back();

    while( !reader.End() && !reader.Is(0,"ENDBLK")) {

        switch(reader.GroupCode()) {
            case 2:
                block.name = reader.Value();
                break;

            case 10:
                block.base.x = reader.ValueAsFloat();
                break;
            case 20:
                block.base.y = reader.ValueAsFloat();
                break;
            case 30:
                block.base.z = reader.ValueAsFloat();
                break;
        }

        if (reader.Is(0,"POLYLINE")) {
            ParsePolyLine(++reader,output);
            continue;
        }

        // XXX is this a valid case?
        if (reader.Is(0,"INSERT")) {
            DefaultLogger::get()->warn("DXF: INSERT within a BLOCK not currently supported; skipping");
            for( ;!reader.End() && !reader.Is(0,"ENDBLK"); ++reader);
            break;
        }

        else if (reader.Is(0,"3DFACE") || reader.Is(0,"LINE") || reader.Is(0,"3DLINE")) {
            //http://sourceforge.net/tracker/index.php?func=detail&aid=2970566&group_id=226462&atid=1067632
            Parse3DFace(++reader, output);
            continue;
        }
        ++reader;
    }
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:45,代码来源:DXFLoader.cpp

示例6: ParsePolyLineVertex

// ------------------------------------------------------------------------------------------------
void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& line)
{
    unsigned int cnti = 0, flags = 0;
    unsigned int indices[4];

    aiVector3D out;
    aiColor4D clr = AI_DXF_DEFAULT_COLOR;

    while( !reader.End() ) {

        if (reader.Is(0)) { // SEQEND or another VERTEX
            break;
        }

        switch (reader.GroupCode())
        {
        case 8:
                // layer to which the vertex belongs to - assume that
                // this is always the layer the top-level polyline
                // entity resides on as well.
                if(reader.Value() != line.layer) {
                    DefaultLogger::get()->warn("DXF: expected vertex to be part of a polyface but the 0x128 flag isn't set");
                }
                break;

        case 70:
                flags = reader.ValueAsUnsignedInt();
                break;

        // VERTEX COORDINATES
        case 10: out.x = reader.ValueAsFloat();break;
        case 20: out.y = reader.ValueAsFloat();break;
        case 30: out.z = reader.ValueAsFloat();break;

        // POLYFACE vertex indices
        case 71:
        case 72:
        case 73:
        case 74:
            if (cnti == 4) {
                DefaultLogger::get()->warn("DXF: more than 4 indices per face not supported; ignoring");
                break;
            }
            indices[cnti++] = reader.ValueAsUnsignedInt();
            break;

        // color
        case 62:
            clr = g_aclrDxfIndexColors[reader.ValueAsUnsignedInt() % AI_DXF_NUM_INDEX_COLORS];
            break;
        };

        reader++;
    }

    if (line.flags & DXF_POLYLINE_FLAG_POLYFACEMESH && !(flags & DXF_VERTEX_FLAG_PART_OF_POLYFACE)) {
        DefaultLogger::get()->warn("DXF: expected vertex to be part of a polyface but the 0x128 flag isn't set");
    }

    if (cnti) {
        line.counts.push_back(cnti);
        for (unsigned int i = 0; i < cnti; ++i) {
            // IMPORTANT NOTE: POLYMESH indices are ONE-BASED
            if (indices[i] == 0) {
                DefaultLogger::get()->warn("DXF: invalid vertex index, indices are one-based.");
                --line.counts.back();
                continue;
            }
            line.indices.push_back(indices[i]-1);
        }
    }
    else {
        line.positions.push_back(out);
        line.colors.push_back(clr);
    }
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:77,代码来源:DXFLoader.cpp

示例7: 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);
        }
    }
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:97,代码来源:DXFLoader.cpp

示例8: ParseHeader

// ------------------------------------------------------------------------------------------------
void DXFImporter::ParseHeader(DXF::LineReader& reader, DXF::FileData& /*output*/)
{
    for( ;!reader.End() && !reader.Is(0,"ENDSEC"); reader++);
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:5,代码来源:DXFLoader.cpp

示例9: SkipSection

// ------------------------------------------------------------------------------------------------
void DXFImporter::SkipSection(DXF::LineReader& reader)
{
    for( ;!reader.End() && !reader.Is(0,"ENDSEC"); reader++);
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:5,代码来源:DXFLoader.cpp

示例10: InternReadFile

// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
void DXFImporter::InternReadFile( const std::string& pFile,
    aiScene* pScene,
    IOSystem* pIOHandler)
{
    std::shared_ptr<IOStream> file = std::shared_ptr<IOStream>( pIOHandler->Open( pFile) );

    // Check whether we can read the file
    if( file.get() == NULL) {
        throw DeadlyImportError( "Failed to open DXF file " + pFile + "");
    }

    // check whether this is a binaray DXF file - we can't read binary DXF files :-(
    char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0};
    file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);

    if (!strncmp(AI_DXF_BINARY_IDENT,buff,AI_DXF_BINARY_IDENT_LEN)) {
        throw DeadlyImportError("DXF: Binary files are not supported at the moment");
    }

    // DXF files can grow very large, so read them via the StreamReader,
    // which will choose a suitable strategy.
    file->Seek(0,aiOrigin_SET);
    StreamReaderLE stream( file );

    DXF::LineReader reader (stream);
    DXF::FileData output;

    // now get all lines of the file and process top-level sections
    bool eof = false;
    while(!reader.End()) {

        // blocks table - these 'build blocks' are later (in ENTITIES)
        // referenced an included via INSERT statements.
        if (reader.Is(2,"BLOCKS")) {
            ParseBlocks(reader,output);
            continue;
        }

        // primary entity table
        if (reader.Is(2,"ENTITIES")) {
            ParseEntities(reader,output);
            continue;
        }

        // skip unneeded sections entirely to avoid any problems with them
        // altogether.
        else if (reader.Is(2,"CLASSES") || reader.Is(2,"TABLES")) {
            SkipSection(reader);
            continue;
        }

        else if (reader.Is(2,"HEADER")) {
            ParseHeader(reader,output);
            continue;
        }

        // comments
        else if (reader.Is(999)) {
            DefaultLogger::get()->info("DXF Comment: " + reader.Value());
        }

        // don't read past the official EOF sign
        else if (reader.Is(0,"EOF")) {
            eof = true;
            break;
        }

        ++reader;
    }
    if (!eof) {
        DefaultLogger::get()->warn("DXF: EOF reached, but did not encounter DXF EOF marker");
    }

    ConvertMeshes(pScene,output);

    // Now rotate the whole scene by 90 degrees around the x axis to convert from AutoCAD's to Assimp's coordinate system
    pScene->mRootNode->mTransformation = aiMatrix4x4(
        1.f,0.f,0.f,0.f,
        0.f,0.f,1.f,0.f,
        0.f,-1.f,0.f,0.f,
        0.f,0.f,0.f,1.f) * pScene->mRootNode->mTransformation;
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:84,代码来源:DXFLoader.cpp


注:本文中的dxf::LineReader::Is方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。