Exemplo n.º 1
0
/*-------------------------------------------------------------------*
 |  ReadBlockHeader                                                  |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFBLOCKHEADER pBlockHeader =                               |
 |                           pointer to blockheader structure        |
 |  Output: Nothing!                                                 |
 *-------------------------------------------------------------------*/
void ReadBlockHeader( PDXF pDxf, PDXFBLOCKHEADER pBlockHeader )
{
	int		GCode;
	char	strValue[2048];

	dxfStorePos(pDxf);
	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pBlockHeader->LayerName, strValue);
			break;
		case 2:		// Block Name
			strcpy(pBlockHeader->Name, strValue);
			break;
		case 70:	// Block-type flags
			pBlockHeader->Flags = char(atoi(strValue));
		case 10:	// Base point X
			pBlockHeader->BasePoint.x = atoi(strValue);
			break;
		case 20:	// Base point Y
			pBlockHeader->BasePoint.y = atoi(strValue);
			break;
		case 30:	// Base point Z
			pBlockHeader->BasePoint.z = atoi(strValue);
			break;
		case 3:		// Block Name
			strcpy(pBlockHeader->Name, strValue);
			break;
		}
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}

	if((GCode==0) && (strcmp(strValue, "ENDBLK")==0))
	{
		pDxf->Read.isBlockOpen = FALSE;

		do{
			dxfStorePos(pDxf);
			ReadParamFromDxfFile(pDxf, GCode, strValue);
		} while(GCode!=0);

		if(strcmp(strValue, "ENDSEC")==0)
			pDxf->Read.CurrentSection = SEC_NOTSET; // Blocks section has been finished
		else // Reached to next block
			dxfRestorePos(pDxf);
	}
	else
	{
		dxfRestorePos(pDxf);
		pDxf->Read.isBlockOpen = TRUE;
	}
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
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;
}
Exemplo n.º 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);
}
Exemplo n.º 5
0
/*-------------------------------------------------------------------*
 |  ReadLayerData                                                    |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFLAYER pLayer = pointer to Layer structure                |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadLayerData( PDXF pDxf, PDXFLAYER pLayer )
{
	int		GCode;
	char	strValue[2048];

	ZeroMemory(pLayer, sizeof(DXFLAYER));
	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 2:		// Layer Name
			strcpy(pLayer->Name, strValue);
			break;
		case 70:	// Standard flags
			pLayer->StandardFlags = char(atoi(strValue));
			break;
		case 62:	// Layer Color
			pLayer->Color = atoi(strValue);
			break;
		case 6:		// Linetype
			strcpy(pLayer->LineType, strValue);
			break;
 		}
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	dxfRestorePos(pDxf);
	return TRUE;
}
Exemplo n.º 6
0
/*-------------------------------------------------------------------*
 |  FindParamFromDxfFile                                             |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer 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 FindParamFromDxfFile( PDXF pDxf, int GroupCode, LPCTSTR valuestr )
{
	int		groupcode;
	char	value[2048];
	BOOL	found;

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

		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);

	return found;
}
Exemplo n.º 7
0
/*-------------------------------------------------------------------*
 |  ReadInsertData                                                   |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTINSERT pInsert = pointer to Insert structure          |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadInsertData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTINSERT pInsert )
{
	ZeroMemory(pInsert, sizeof(DXFENTINSERT));

	pEntityHeader->EntityType = ENT_INSERT;
	pInsert->XScale = 1;
	pInsert->YScale = 1;
	pInsert->ZScale = 1;
	pInsert->RotationAngle = 0;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 2:		// Block Name
			strcpy(pInsert->BlockHeaderName, strValue);
			break;
		case 10:	// Insertion point X
			pInsert->Point0.x = atof(strValue);
			break;
		case 20:	// Insertion point Y
			pInsert->Point0.y = atof(strValue);
			break;
		case 30:	// Insertion point Z
			pInsert->Point0.z = atof(strValue);
			break;
		case 41:	// X scale factor (optional; default = 1)
			pInsert->XScale = atof(strValue);
			break;
		case 42:	// Y scale factor (optional; default = 1)
			pInsert->YScale = atof(strValue);
			break;
		case 43:	// Z scale factor (optional; default = 1)
			pInsert->ZScale = atof(strValue);
			break;
		case 50:	// Rotation angle (optional; default = 0)
			pInsert->RotationAngle = atof(strValue);
			break;
 		}

		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	return TRUE;
}
Exemplo n.º 8
0
/*-------------------------------------------------------------------*
 |  ReadArcData                                                      |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTARC pArc = pointer to Arc structure                   |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadArcData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTARC pArc )
{
	ZeroMemory(pArc, sizeof(DXFENTARC));

	pEntityHeader->EntityType = ENT_ARC;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 10:	// Center point X
			pArc->Point0.x = atof(strValue);
			break;
		case 20:	// Center point Y
			pArc->Point0.y = atof(strValue);
			break;
		case 30:	// Center point Z
			pArc->Point0.z = atof(strValue);
			break;
		case 40:	// Radius
			pArc->Radius = atof(strValue);
			break;
		case 50:	// Start angle
			pArc->StartAngle = atof(strValue);
			break;
		case 51:	// End angle
			pArc->EndAngle = atof(strValue);
			break;
 		}

		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	return TRUE;
}
Exemplo n.º 9
0
/*-------------------------------------------------------------------*
 |  ReadLineData                                                     |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTLINE pLine = pointer to Line structure                |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadLineData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTLINE pLine )
{
	ZeroMemory(pLine, sizeof(DXFENTLINE));

	pEntityHeader->EntityType = ENT_LINE;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 10:	// Start point X
			pLine->Point0.x = atof(strValue);
			break;
		case 20:	// Start point Y
			pLine->Point0.y = atof(strValue);
			break;
		case 30:	// Start point Z
			pLine->Point0.z = atof(strValue);
			break;
		case 11:	// End point X
			pLine->Point1.x = atof(strValue);
			break;
		case 21:	// End point Y
			pLine->Point1.y = atof(strValue);
			break;
		case 31:	// End point Z
			pLine->Point1.z = atof(strValue);
			break;
 		}

		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}

	return TRUE;
}
Exemplo n.º 10
0
/*-------------------------------------------------------------------*
 |  ReadCircleData                                                   |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTCIRCLE pPoint = pointer to Circle structure           |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadCircleData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTCIRCLE pCircle )
{
	ZeroMemory(pCircle, sizeof(DXFENTCIRCLE));

	pEntityHeader->EntityType = ENT_CIRCLE;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 10:	// Center point X
			pCircle->Point0.x = atof(strValue);
			break;
		case 20:	// Center point Y
			pCircle->Point0.y = atof(strValue);
			break;
		case 30:	// Center point Z
			pCircle->Point0.z = atof(strValue);
			break;
		case 40:	// Radius
			pCircle->Radius = atof(strValue);
			break;
 		}
	
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	return TRUE;
}
Exemplo n.º 11
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;
}
Exemplo n.º 12
0
/*-------------------------------------------------------------------*
 |  ReadStyleData                                                    |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFSTYLE pStyle = pointer to Style structure                |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadStyleData( PDXF pDxf, PDXFSTYLE pStyle )
{
	int		GCode;
	char	strValue[2048];

	ZeroMemory(pStyle, sizeof(DXFSTYLE));
	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 2:		// Style Name
			strcpy(pStyle->Name, strValue);
			break;
		case 3:		// Primary Font Filename
			strcpy(pStyle->PrimaryFontFilename, strValue);
			break;
		case 70:	// Standard flags
			pStyle->StandardFlags = char(atoi(strValue));
			break;
		case 71:	// Text generation flags -> 2=Text is backward  4=Text is upside down
			pStyle->TextGenerationFlags = atoi(strValue);
			break;
		case 40:	// Fixed text height
			pStyle->FixedTextHeight = atof(strValue);
			break;
		case 41:	// Width Factor
			pStyle->WidthFactor = atof(strValue);
			break;
		case 42:	// Height
			pStyle->Height = atof(strValue);
			break;
		case 50:	// Oblique angle
			pStyle->ObliqueAngle = atof(strValue);
			break;
		}
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}

	dxfRestorePos(pDxf);
	return TRUE;
}
Exemplo n.º 13
0
/*-------------------------------------------------------------------*
 |  ReadPointData                                                    |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTPOINT pPoint = pointer to Point structure             |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadPointData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTPOINT pPoint )
{
	ZeroMemory(pPoint, sizeof(DXFENTPOINT));

	pEntityHeader->EntityType = ENT_POINT;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 10:	// Point location X
			pPoint->Point0.x = atof(strValue);
			break;
		case 20:	// Point location Y
			pPoint->Point0.y = atof(strValue);
			break;
		case 30:	// Point location Z
			pPoint->Point0.z = atof(strValue);
			break;
 		}

		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	return TRUE;
}
Exemplo n.º 14
0
/*-------------------------------------------------------------------*
 |  ReadLTypeData                                                    |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFLTYPE pLType = pointer to LType structure                |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadLTypeData( PDXF pDxf, PDXFLTYPE pLType )
{
	int		GCode;
	char	strValue[2048];
	int		i;

	i = 0;
	ZeroMemory(pLType, sizeof(DXFLTYPE));
	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 2:		// Linetype Name
			strcpy(pLType->Name, strValue);
			break;
		case 70:	// Standard flags
			pLType->StandardFlags = char(atoi(strValue));
			break;
		case 3:		// Descriptive text for linetype
			strcpy(pLType->DescriptiveText, strValue);
			break;
		case 73:	// Number of linetype elements
			pLType->ElementsNumber = atoi(strValue);
			break;
		case 40:	// Total pattern length
			pLType->TotalPatternLength = atof(strValue);
			break;
		case 49:	// Dash, dot or space length
			pLType->Elements[i] = atof(strValue);
			i++;
			break;
		}
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	dxfRestorePos(pDxf);
	return TRUE;
}
Exemplo n.º 15
0
/*-------------------------------------------------------------------*
 |  ReadDimStyleData                                                 |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFDIMSTYLE pDimStyle = pointer to DimStyle structure       |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadDimStyleData( PDXF pDxf, PDXFDIMSTYLE pDimStyle )
{
	int		GCode;
	char	strValue[2048];

	ZeroMemory(pDimStyle, sizeof(DXFDIMSTYLE));
	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 2:		// DimStyle Name
			strcpy(pDimStyle->Name, strValue);
			break;
		case 70:	// Standard flag values
			pDimStyle->StandardFlags = char(atoi(strValue));
			break;
		case 176:	// Dimension line & Arrow heads color
			pDimStyle->DIMCLRD = atoi(strValue);
			break;
		case 46:	// Dimension line size after Extensionline
			pDimStyle->DIMDLE = atof(strValue);
			break;
		case 177:	// Extension line color
			pDimStyle->DIMCLRE = atoi(strValue);
			break;
		case 44:	// Extension line size after Dimline
			pDimStyle->DIMEXE = atof(strValue);
			break;
		case 42:	// Offset from origin
			pDimStyle->DIMEXO = atof(strValue);
			break;
		case 6:		// 1st Arrow head
			strcpy(pDimStyle->DIMBLK1, strValue);
			break;
		case 7:		// 2nd Arrow head
			strcpy(pDimStyle->DIMBLK2, strValue);
			break;
		case 41:	// Arrow size
			pDimStyle->DIMASZ = atof(strValue);
			break;
		case 340:	// Text style handle
			pDimStyle->DIMTXSTYObjhandle = atoi(strValue);
			break;
		case 178:	// Text color
			pDimStyle->DIMCLRT = atoi(strValue);
			break;
		case 140:	// Text height
			pDimStyle->DIMTXT = atof(strValue);
			break;
		case 77:	// Vertical Text Placement
			pDimStyle->DIMTAD = atoi(strValue);
			break;
		case 147:	// Offset from dimension line
			pDimStyle->DIMGAP = atof(strValue);
			break;
		}
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	dxfRestorePos(pDxf);
	return TRUE;
}
Exemplo n.º 16
0
/*-------------------------------------------------------------------*
 |  ReadTextData                                                     |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTTEXT pText = pointer to Text structure                |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadTextData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTTEXT pText )
{
	ZeroMemory(pText, sizeof(DXFENTTEXT));

	pEntityHeader->EntityType = ENT_TEXT;
	pText->TextData.Justification = 0;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 7:		// Text Style Name
			strcpy(pText->TextData.TextStyleName, strValue);
			break;
		case 10:	// First alignment point (in OCS) X
			pText->Point0.x = atof(strValue);
			break;
		case 20:	// First alignment point (in OCS) Y
			pText->Point0.y = atof(strValue);
			break;
		case 30:	// First alignment point (in OCS) Z
			pText->Point0.z = atof(strValue);
			break;
		case 72:	// Horizontal text justification type (default = 0)
			pText->TextData.Justification = (pText->TextData.Justification & 0xff00) | (char)atoi(strValue);
			break;
		case 73:	// Vertical text justification type (default = 0)
			pText->TextData.Justification = (pText->TextData.Justification & 0x00ff) | (char)atoi(strValue) << 8;
			break;
		case 11:	// Second alignment point (in OCS) X
			pText->TextData.SecondAlignmentPoint.x = atof(strValue);
			break;
		case 21:	// Second alignment point (in OCS) Y
			pText->TextData.SecondAlignmentPoint.y = atof(strValue);
			break;
		case 31:	// Second alignment point (in OCS) Z
			pText->TextData.SecondAlignmentPoint.z = atof(strValue);
			break;
		case 40:	// Text Height
			pText->TextData.Height = atof(strValue);
			break;
		case 41:	// Width Factor
			pText->TextData.WidthFactor = atof(strValue);
			break;
		case 50:	// Text Rotation Angle
			pText->TextData.RotationAngle = atof(strValue);
			break;
		case 1:		// Default value (the string itself)
			strcpy(pText->strText, strValue);
			break;
 		}

		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	return TRUE;
}
Exemplo n.º 17
0
/*-------------------------------------------------------------------*
 |  dxfReadEntityData_Direct                                         |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer 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 new entity is loaded                             |
 *-------------------------------------------------------------------*/
BOOL dxfReadEntityData_Direct( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, LPVOID pEntityData )
{
	BOOL	result;

	// Check if current section is ENTITIES or BLOCKS
	if(pDxf->Read.CurrentSection!=SEC_ENTITIES)
	{
		if((pDxf->Read.CurrentSection!=SEC_BLOCKS) || (!pDxf->Read.isBlockOpen))
		{
			// Can not read entity data
			return FALSE;
		}
	}

	dxfStorePos(pDxf);
	ReadParamFromDxfFile(pDxf, GCode, strValue);
	if(GCode!=0)
	{
		// Can not read entity data
		dxfRestorePos(pDxf);
		return FALSE;
	}

	SetEntityHeaderDefaultValues(pEntityHeader);	// Set Entities Header to Default Values
	result = FALSE;

	do {
		if(strcmp(strValue, "LINE")==0)
		{
			ReadLineData(pDxf, pEntityHeader, (PDXFENTLINE)pEntityData);
			result = TRUE;
			break;
		}
		else if(strcmp(strValue, "POINT")==0)
		{
			ReadPointData(pDxf, pEntityHeader, (PDXFENTPOINT)pEntityData);
			result = TRUE;
			break;
		}
		else if(strcmp(strValue, "CIRCLE")==0)
		{
			ReadCircleData(pDxf, pEntityHeader, (PDXFENTCIRCLE)pEntityData);
			result = TRUE;
			break;
		}
		else if(strcmp(strValue, "ELLIPSE")==0)
		{
			ReadEllipseData(pDxf, pEntityHeader, (PDXFENTELLIPSE)pEntityData);
			result = TRUE;
			break;
		}
		else if(strcmp(strValue, "TEXT")==0)
		{
			ReadTextData(pDxf, pEntityHeader, (PDXFENTTEXT)pEntityData);
			result = TRUE;
			break;
		}
		else if(strcmp(strValue, "ARC")==0)
		{
			ReadArcData(pDxf, pEntityHeader, (PDXFENTARC)pEntityData);
			result = TRUE;
			break;
		}
		else if(strcmp(strValue, "SOLID")==0)
		{
			ReadSolidData(pDxf, pEntityHeader, (PDXFENTSOLID)pEntityData);
			result = TRUE;
			break;
		}
		else if(strcmp(strValue, "INSERT")==0)
		{
			ReadInsertData(pDxf, pEntityHeader, (PDXFENTINSERT)pEntityData);
			result = TRUE;
			break;
		}
		//This code is implemented by tran duy dung
		//*******************************************************************
		else if(strcmp(strValue, "POLYLINE")==0){
			ReadPolyLineData(pDxf, pEntityHeader, (PDXFENTPOLYLINE)pEntityData);
			result = TRUE;
			break;
		}
		//*******************************************************************
		else if(strcmp(strValue, "DIMENSION")==0)
		{
			ReadDimensionData(pDxf, pEntityHeader, (PDXFENTDIMENSION)pEntityData);
			result = TRUE;
			break;
		}
		else
		{
			// Unknown entity
			// Looking for next entity
			do {
				ReadParamFromDxfFile(pDxf, GCode, strValue);
			} while(GCode!=0);
		}
	} while((strcmp(strValue, "ENDBLK")!=0) && (strcmp(strValue, "ENDSEC")!=0) && (pDxf->Read.CurrentPos<pDxf->Read.FileSize));

	if((pDxf->Read.CurrentSection==SEC_BLOCKS) && (pDxf->Read.isBlockOpen))
	{
		if((GCode==0) && (strcmp(strValue, "ENDBLK")==0))
		{
			pDxf->Read.isBlockOpen = FALSE;

			do{
				dxfStorePos(pDxf);
				ReadParamFromDxfFile(pDxf, GCode, strValue);
			} while(GCode!=0);

			if(strcmp(strValue, "ENDSEC")==0)
				pDxf->Read.CurrentSection = SEC_NOTSET; // Blocks section has been finished
			else // Reached to the next block
				dxfRestorePos(pDxf);
		}
		else
			dxfRestorePos(pDxf);
	}
	else
	{
		if((GCode==0) && (strcmp(strValue, "ENDSEC")==0))
			pDxf->Read.CurrentSection = SEC_NOTSET; // Entities section has been finished
		else
			dxfRestorePos(pDxf);
	}

	return result;
}
Exemplo n.º 18
0
/*-------------------------------------------------------------------*
 |  ReadPolyLineData                                                 |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTLINE pPolyLine = pointer to PolyLine structure        |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadPolyLineData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTPOLYLINE pPolyLine )
{
	ZeroMemory(pPolyLine, sizeof(DXFENTPOLYLINE));

	pEntityHeader->EntityType = ENT_POLYLINE;
	pPolyLine->Flag = 0;

	ReadParamFromDxfFile(pDxf, GCode, strValue);	
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;	
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 70:	// Polyline flag (bit-coded); default is 0
			pPolyLine->Flag = atoi(strValue);
			break;	
 		}
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}

	// Reading Vertex Data
	SimpleList<DXFENTVERTEX> vertices;
	DXFENTVERTEX Vertex;
	while((GCode==0) && (strcmp(strValue,"VERTEX")==0))
	{
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);	
		while(GCode!=0){
			switch(GCode)
			{
				case 10:	// Start point X
					Vertex.Point.x = atof(strValue);
					break;		
				case 20:	// Start point X
					Vertex.Point.y = atof(strValue);
					break;		
				case 30:	// Start point X
					Vertex.Point.z = atof(strValue);
					break;		
				case 42:	// Bulge (optional; default is 0)
					Vertex.Bulge = atof(strValue);
					break;		
 			}
			dxfStorePos(pDxf);
			ReadParamFromDxfFile(pDxf, GCode, strValue);
		}
		vertices.add(Vertex);		
	}

	pPolyLine->nVertex = vertices.getSize();
	pPolyLine->pVertex = new DXFENTVERTEX[pPolyLine->nVertex];
	int i=0;
	vertices.start();
	while (vertices.next()) {
		pPolyLine->pVertex[i] = vertices.get();		
		i++;
	}
	
	return TRUE;
}
Exemplo n.º 19
0
/*-------------------------------------------------------------------*
 |  ReadSolidData                                                    |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTSOLID pSolid = pointer to Solid structure             |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadSolidData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTSOLID pSolid )
{
	ZeroMemory(pSolid, sizeof(DXFENTSOLID));

	pEntityHeader->EntityType = ENT_SOLID;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 10:	// First corner X
			pSolid->Point0.x = atof(strValue);
			break;
		case 20:	// First corner Y
			pSolid->Point0.y = atof(strValue);
			break;
		case 30:	// First corner Z
			pSolid->Point0.z = atof(strValue);
			break;
		case 11:	// Second corner X
			pSolid->Point1.x = atof(strValue);
			break;
		case 21:	// Second corner Y
			pSolid->Point1.y = atof(strValue);
			break;
		case 31:	// Second corner Z
			pSolid->Point1.z = atof(strValue);
			break;
		case 12:	// Third corner X
			pSolid->Point2.x = atof(strValue);
			break;
		case 22:	// Third corner Y
			pSolid->Point2.y = atof(strValue);
			break;
		case 32:	// Third corner Z
			pSolid->Point2.z = atof(strValue);
			break;
		case 13:	// Fourth corner X
			pSolid->Point3.x = atof(strValue);
			break;
		case 23:	// Fourth corner Y
			pSolid->Point3.y = atof(strValue);
			break;
		case 33:	// Fourth corner Z
			pSolid->Point3.z = atof(strValue);
			break;
 		}

		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	return TRUE;
}
Exemplo n.º 20
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;
}
Exemplo n.º 21
0
/*-------------------------------------------------------------------*
 |  ReadDimensionData                                                |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTDIMENSION pDimension = pointer to Dimension structure |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadDimensionData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTDIMENSION pDimension )
{
	ZeroMemory(pDimension, sizeof(DXFENTDIMENSION));

	pEntityHeader->EntityType = ENT_DIMENSION;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;	
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 10:	// Definition point (in WCS) X
			pDimension->DimLineDefPoint.x = atof(strValue);
			break;
		case 20:	// Definition point (in WCS) Y
			pDimension->DimLineDefPoint.y = atof(strValue);
			break;
		case 30:	// Definition point (in WCS) Z
			pDimension->DimLineDefPoint.z = atof(strValue);
			break;
		case 13:	// Definition point for linear and angular dimensions (in WCS) X
			pDimension->DefPoint3.x = atof(strValue);
			break;
		case 23:	// Definition point for linear and angular dimensions (in WCS) Y
			pDimension->DefPoint3.y = atof(strValue);
			break;
		case 33:	// Definition point for linear and angular dimensions (in WCS) Z
			pDimension->DefPoint3.z = atof(strValue);
			break;
		case 14:	// Definition point for linear and angular dimensions (in WCS) X
			pDimension->DefPoint4.x = atof(strValue);
			break;
		case 24:	// Definition point for linear and angular dimensions (in WCS) Y
			pDimension->DefPoint4.y = atof(strValue);
			break;
		case 34:	// Definition point for linear and angular dimensions (in WCS) Z
			pDimension->DefPoint4.z = atof(strValue);
			break;
		case 53:	// The rotation angle of the dimension text away from its default orientation (the direction of the dimension line)
			pDimension->DimRotationAngle = atof(strValue);
			break;
		case 3:		// Dimension style name
			strcpy(pDimension->DimStyleName, strValue);
			break;
		case 1:		// Dimension text explicitly entered by the user. Optional; default is the measurement. If null or "<>", the dimension measurement is drawn as the text, if " " (one blank space), the text is suppressed.
			strcpy(pDimension->DimText, strValue);
			break;
		case 2:		// Name of the block that contains the entities that make up the dimension picture
			strcpy(pDimension->BlockName, strValue);
			break;
 		}

		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	return TRUE;
}
Exemplo n.º 22
0
/*-------------------------------------------------------------------*
 |  ReadEllipseData                                                  |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTCIRCLE pPoint = pointer to Circle structure           |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadEllipseData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTELLIPSE pEllipse )
{
	ZeroMemory(pEllipse, sizeof(DXFENTELLIPSE));

	pEntityHeader->EntityType = ENT_ELLIPSE;

	ReadParamFromDxfFile(pDxf, GCode, strValue);
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 10:	// Center point X
			pEllipse->CenterPoint.x = atof(strValue);
			break;
		case 20:	// Center point Y
			pEllipse->CenterPoint.y = atof(strValue);
			break;
		case 30:	// Center point Z
			pEllipse->CenterPoint.z = atof(strValue);
			break;
		case 11:	// Endpoint of major axis X
			pEllipse->MajorAxisEndPoint.x = atof(strValue);
			break;
		case 21:	// Endpoint of major axis Y
			pEllipse->MajorAxisEndPoint.y = atof(strValue);
			break;
		case 31:	// Endpoint of major axis Z
			pEllipse->MajorAxisEndPoint.z = atof(strValue);
			break;
		case 40:	// Ratio of minor axis to major axis
			pEllipse->MinorToMajorRatio = atof(strValue);
			break;
		case 41:	// Start parameter (this value is 0.0 for a full ellipse)
			pEllipse->StartParam = atof(strValue);
			break;
		case 42:	// End parameter (this value is 2pi for a full ellipse)
			pEllipse->EndParam = atof(strValue);
			break;
 		}
	
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}
	
	return TRUE;
}