Beispiel #1
0
long OGRDXFWriterDS::WriteEntityID( VSILFILE *fpIn, long nPreferredFID )

{
    CPLString osEntityID;

    if( nPreferredFID != OGRNullFID )
    {

        osEntityID.Printf( "%X", (unsigned int) nPreferredFID );
        if( !CheckEntityID( osEntityID ) )
        {
            aosUsedEntities.insert( osEntityID );
            WriteValue( fpIn, 5, osEntityID );
            return nPreferredFID;
        }
    }

    do
    {
        osEntityID.Printf( "%X", nNextFID++ );
    }
    while( CheckEntityID( osEntityID ) );

    aosUsedEntities.insert( osEntityID );
    WriteValue( fpIn, 5, osEntityID );

    return nNextFID - 1;
}
Beispiel #2
0
bool CFilterSet::CheckShape(CShape* pShape) const
{
	n_assert(pShape);
	return CheckMaterialType(pShape->GetMaterialType()) ||
		(pShape->GetEntity() && CheckEntityID(pShape->GetEntity()->GetUniqueID())) ||
		(pShape->GetRigidBody() && CheckRigidBodyID(pShape->GetRigidBody()->GetUniqueID()));
}
void OGRDXFWriterDS::ScanForEntities( const char *pszFilename,
                                      const char *pszTarget )

{
    OGRDXFReader oReader;
    VSILFILE *fp;

/* -------------------------------------------------------------------- */
/*      Open the file and setup a reader.                               */
/* -------------------------------------------------------------------- */
    fp = VSIFOpenL( pszFilename, "r" );

    if( fp == NULL )
        return;

    oReader.Initialize( fp );

/* -------------------------------------------------------------------- */
/*      Add every code "5" line to our entities list.                   */
/* -------------------------------------------------------------------- */
    char szLineBuf[257];
    int  nCode;
    const char *pszPortion = "HEADER";

    while( (nCode = oReader.ReadValue( szLineBuf, sizeof(szLineBuf) )) != -1 )
    {
        if( (nCode == 5 || nCode == 105) && EQUAL(pszTarget,pszPortion) )
        {
            CPLString osEntity( szLineBuf );

            if( CheckEntityID( osEntity ) )
                CPLDebug( "DXF", "Encounted entity '%s' multiple times.",
                          osEntity.c_str() );
            else
                aosUsedEntities.insert( osEntity );
        }

        if( nCode == 0 && EQUAL(szLineBuf,"SECTION") )
        {
            nCode = oReader.ReadValue( szLineBuf, sizeof(szLineBuf) );
            if( nCode == 2 && EQUAL(szLineBuf,"ENTITIES") )
                pszPortion = "BODY";
            if( nCode == 2 && EQUAL(szLineBuf,"OBJECTS") )
                pszPortion = "TRAILER";
        }
    }

    VSIFCloseL( fp );
}