Пример #1
0
/*-------------------------------------------------------------------*
 |  dxfReadTableTypeName                                             |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |  Output: TableType Code else TAB_NOTSET                           |
 *-------------------------------------------------------------------*/
DWORD dxfReadTableTypeName( HDXF hDxf )
{
	PDXF	pDxf;
	int		GCode;
	char	strValue[2048];
	DWORD	result;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	// Check if current section is TABLES
	if(pDxf->Read.CurrentSection!=SEC_TABLES)
	{
		// Current section is not TABLES
		GlobalUnlock(hDxf);
		return FALSE;
	}

	dxfStorePos(pDxf);

	// Read TableType Name
	dxfReadParam(hDxf, GCode, strValue);
	if((GCode==0) && (strcmp(strValue, "TABLE")==0))
		ReadTableTypeName(pDxf);
	else
		dxfRestorePos(pDxf); // Restore Old Position

	result = pDxf->Read.CurrentTableType;

	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return result;
}
Пример #2
0
/*-------------------------------------------------------------------*
 |  dxfFindNextTableType                                             |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |  Output: TableType Code else TAB_NOTSET                           |
 *-------------------------------------------------------------------*/
DWORD dxfFindNextTableType( HDXF hDxf )
{
	PDXF	pDxf;
	DWORD	result;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	// Check if current section is TABLES
	if(pDxf->Read.CurrentSection!=SEC_TABLES)
	{
		// Current section is not TABLES
		GlobalUnlock(hDxf);
		return FALSE;
	}

	// Find TableType Name
	if(FindParamFromDxfFile(pDxf, 0, "TABLE"))
	{
		// Read TableType Name
		ReadTableTypeName(pDxf);
		result = pDxf->Read.CurrentTableType;
	}
	else
		result = TAB_NOTSET;

	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return result;
}
Пример #3
0
/*-------------------------------------------------------------------*
 |  dxfReadBlockHeader                                               |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |      PDXFBLOCKHEADER pBlockHeader =                               |
 |                           pointer to blockheader structure        |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL dxfReadBlockHeader( HDXF hDxf, PDXFBLOCKHEADER pBlockHeader )
{
	PDXF	pDxf;
	int		GCode;
	char	strValue[2048];

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	// Check if current section is BLOCKS
	if(pDxf->Read.CurrentSection!=SEC_BLOCKS)
	{
		// Current section is not BLOCKS
		GlobalUnlock(hDxf);
		return FALSE;
	}

	dxfStorePos(pDxf);
	ReadParamFromDxfFile(pDxf, GCode, strValue);
	if((GCode==0) && (strcmp(strValue, "BLOCK")==0))
		ReadBlockHeader(pDxf, pBlockHeader);
	else
	{
		// Can not read block header
		dxfRestorePos(pDxf);
		GlobalUnlock(hDxf);
		return FALSE;
	}
	
	// UnInitilize hDxf -----------------
	return UnInitilizePDXF(hDxf);
}
Пример #4
0
/*-------------------------------------------------------------------*
 |  dxfFindBlockHeader                                               |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |      PDXFBLOCKHEADER pBlockHeader =                               |
 |                           pointer to blockheader structure        |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL dxfFindBlockHeader( HDXF hDxf, PDXFBLOCKHEADER pBlockHeader )
{
	PDXF	pDxf;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	// Check if current section is BLOCKS
	if(pDxf->Read.CurrentSection!=SEC_BLOCKS)
	{
		// Current section is not BLOCKS
		GlobalUnlock(hDxf);
		return FALSE;
	}

	dxfStorePos(pDxf);
	if(FindParamFromDxfFile(pDxf, 0, "BLOCK"))
		ReadBlockHeader(pDxf, pBlockHeader);
	else
	{
		// Can not read block header
		dxfRestorePos(pDxf);
		GlobalUnlock(hDxf);
		return FALSE;
	}
	
	// UnInitilize hDxf -----------------
	return UnInitilizePDXF(hDxf);
}
Пример #5
0
/*-------------------------------------------------------------------*
 |  dxfGetBlockOpen                                                  |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |  Output: TRUE if block is open.                                   |
 *-------------------------------------------------------------------*/
BOOL dxfGetBlockOpen( HDXF hDxf )
{
	PDXF	pDxf;
	BOOL	result;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	result = pDxf->Read.isBlockOpen;

	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return result;
}
Пример #6
0
/*-------------------------------------------------------------------*
 |  dxfGetCurrentSection                                             |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |  Output: current section code if everything is ok                 |
 *-------------------------------------------------------------------*/
DWORD dxfGetCurrentSection( HDXF hDxf )
{
	PDXF	pDxf;
	DWORD	result;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	result = pDxf->Read.CurrentSection;
	
	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return result;
}
Пример #7
0
/*-------------------------------------------------------------------*
 |  dxfReadEntityData                                                |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      LPVOID pEntityData = pointer to entity data structure to read|
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL dxfReadEntityData( HDXF hDxf, PDXFENTITYHEADER pEntityHeader, LPVOID pEntityData )
{
	PDXF	pDxf;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	if(!dxfReadEntityData_Direct(pDxf, pEntityHeader, pEntityData))
	{
		GlobalUnlock(hDxf);
		return FALSE;
	}

	// UnInitilize hDxf -----------------
	return UnInitilizePDXF(hDxf);
}
Пример #8
0
/*-------------------------------------------------------------------*
 |  dxfFindParam                                                     |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |      int GroupCode = group code                                   |
 |      LPCTSTR valuestr = pointer to null terminated string to find |
 |  Output: TRUE if found else FALSE                                 |
 *-------------------------------------------------------------------*/
BOOL dxfFindParam( HDXF hDxf, int GroupCode, LPCTSTR valuestr )
{
	PDXF	pDxf;
	int		groupcode;
	char	value[2048];
	BOOL	found;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	found = FALSE;
	dxfStorePos(pDxf);
	while(/*!feof(pDxf->pStream)*/pDxf->Read.CurrentPos<pDxf->Read.FileSize)
	{
/*		if(fscanf(pDxf->pStream, "%d", &groupcode)<=0)
		{
			// file read error
			GlobalUnlock(hDxf);
			return FALSE;
		}

		ReadLine(pDxf, value);*/

		char strGroupCode[32];
		ReadLine(pDxf, strGroupCode);
		groupcode = atoi(strGroupCode);
		ReadLine(pDxf, value);

		if((groupcode==GroupCode) && (strcmp(valuestr, value)==0))
		{
			found = TRUE;
			break;
		}
	}

	if(!found)
		dxfRestorePos(pDxf);

	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return found;
}
Пример #9
0
/*-------------------------------------------------------------------*
 |  dxfFindNextSection                                               |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |  Output: section code if everything is ok else SEC_NOTSET         |
 *-------------------------------------------------------------------*/
DWORD dxfFindNextSection( HDXF hDxf )
{
	PDXF	pDxf;
	int		GCode;
	char	SectionName[32];

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	// Set CurrentSection to SEC_NOTSET
	pDxf->Read.CurrentSection = SEC_NOTSET;

	// Search for Section
	if(!dxfFindParam( hDxf, 0, "SECTION" ))
	{
		// Invalid Dxf file format
		GlobalUnlock(hDxf);
		return SEC_NOTSET;
	}

	if(/*!feof(pDxf->pStream)*/pDxf->Read.CurrentPos<pDxf->Read.FileSize)
	{
		dxfReadParam(hDxf, GCode, SectionName);
		if(strcmp(SectionName, "HEADER")==0)
			pDxf->Read.CurrentSection = SEC_HEADER;
		else if(strcmp(SectionName, "TABLES")==0)
			pDxf->Read.CurrentSection = SEC_TABLES;
		else if(strcmp(SectionName, "BLOCKS")==0)
			pDxf->Read.CurrentSection = SEC_BLOCKS;
		else if(strcmp(SectionName, "ENTITIES")==0)
			pDxf->Read.CurrentSection = SEC_ENTITIES;
		else
			pDxf->Read.CurrentSection = SEC_UNKNOWN;
	}

	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return pDxf->Read.CurrentSection;
}
Пример #10
0
/*-------------------------------------------------------------------*
 |  dxfGetCurrentTableType                                           |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |  Output: current table type code if everything is ok              |
 *-------------------------------------------------------------------*/
DWORD dxfGetCurrentTableType( HDXF hDxf )
{
	PDXF	pDxf;
	DWORD	result;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	// Check if current section is TABLES
	if(pDxf->Read.CurrentSection!=SEC_TABLES)
	{
		// Current section is not TABLES
		GlobalUnlock(hDxf);
		return FALSE;
	}

	result = pDxf->Read.CurrentTableType;

	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return result;
}
Пример #11
0
/*-------------------------------------------------------------------*
 |  dxfReadTableType                                                 |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |      LPVOID pTableType = pointer to table type structure          |
 |  Output: TableType Code else TAB_NOTSET                           |
 *-------------------------------------------------------------------*/
DWORD dxfReadTableType( HDXF hDxf, LPVOID pTableType )
{
	PDXF	pDxf;
	int		GCode;
	char	strValue[2048];
	DWORD	result;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	// Check if current section is TABLES
	if(pDxf->Read.CurrentSection!=SEC_TABLES)
	{
		// Current section is not TABLES
		GlobalUnlock(hDxf);
		return TAB_NOTSET;
	}

	// Looking for next table type if CurrentTableType==TAB_NOTSET
	if(pDxf->Read.CurrentTableType==TAB_NOTSET)
	{
		if(dxfFindNextTableType(hDxf)==TAB_NOTSET)
		{
			pDxf->Read.CurrentSection = SEC_NOTSET;
			GlobalUnlock(hDxf);
			return TAB_NOTSET;
		}
	}

	// Read current table type data
	result = TAB_NOTSET;
	switch(pDxf->Read.CurrentTableType)
	{
	case TAB_DIMSTYLE:
		if(!FindParamFromDxfFile(pDxf, 0, "DIMSTYLE"))
			break;
		else
		{
			if(ReadDimStyleData(pDxf, (PDXFDIMSTYLE)pTableType))
				result = TAB_DIMSTYLE;
		}
		break;

	case TAB_LAYER:
		if(!FindParamFromDxfFile(pDxf, 0, "LAYER"))
			break;
		else
		{
			if(ReadLayerData(pDxf, (PDXFLAYER)pTableType))
				result = TAB_LAYER;
		}
		break;

	case TAB_LTYPE:
		if(!FindParamFromDxfFile(pDxf, 0, "LTYPE"))
			break;
		else
		{
			if(ReadLTypeData(pDxf, (PDXFLTYPE)pTableType))
				result = TAB_LTYPE;
		}
		break;

	case TAB_STYLE:
		if(!dxfFindParam( hDxf, 0, "STYLE" ))
			break;
		else
		{
			if(ReadStyleData(pDxf, (PDXFSTYLE)pTableType))
				result = TAB_STYLE;
		}
		break;
	}

	dxfStorePos(pDxf);
	dxfReadParam(hDxf, GCode, strValue);

	if((GCode==0) && (strcmp(strValue, "ENDTAB")==0))
	{
		pDxf->Read.CurrentTableType = TAB_NOTSET;

//		while(dxfReadTableTypeName(hDxf)==TAB_NOTSET)
//		{
			dxfStorePos(pDxf);
			dxfReadParam(hDxf, GCode, strValue);
			if((GCode==0) && (strcmp(strValue, "ENDSEC")==0))
			{
				pDxf->Read.CurrentSection = SEC_NOTSET; // Tables section has been finished
//				break;
			}
			else
				dxfRestorePos(pDxf);
//		}
	}
	else
		dxfRestorePos(pDxf);

	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return result;
}