⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dim.c

📁 AutoCAD DWG-file viewer
💻 C
字号:
/****************************************************************/
/*			COPYRIGHT NOTICE			*/
/*			----------------			*/
/*  All software in this listing remain the strict copyright	*/
/*  of Ilija Kovacevic and cannot be copied or used in any way	*/
/*  except by written permission of Ilija Kovacevic.		*/
/*								*/
/*	Copyright (c) 1992 Ilija Kovacevic			*/
/*	www.kov.com   email ilija@kov.com			*/
/****************************************************************/

#include "dwgin.h"

PUBLIC AcadDimension *AcadDimension__create( void )

{
AcadDimension *me;

me = ( AcadDimension * )get_memory( sizeof( AcadDimension ) );
me->explicit = NULL;
return( me );
}


PUBLIC void AcadDimension__delete( AcadDimension *me )

{
if ( me->explicit ) free( me->explicit );
free( ( char * )me );
}


PUBLIC int AcadDimension__length( AcadDimension *me )

{
return( me->common.size );
}


PUBLIC void AcadDimension__read( AcadDimension *me )

{
AcadEntity__read_elevation_etc( &me->common,true,true );
get_INT16( &me->block_number );
get_DOUBLE( &me->x );
get_DOUBLE( &me->y );
if ( __drawing->acad10 OR __drawing->acad11 ) get_DOUBLE( &me->z );
get_DOUBLE( &me->mid_text_x );
get_DOUBLE( &me->mid_text_y );
me->mid_text_z = 0.0;
if ( me->common.pflags & 0x1 )
	{
	get_DOUBLE( &me->clone_x );
	get_DOUBLE( &me->clone_y );
	}
else me->clone_x = me->clone_y = 0;

if ( me->common.pflags & 0x2 ) get_UINT8( &me->dimension_type );
else me->dimension_type = 0;

if ( me->common.pflags & 0x4 )
	{
	get_INT16( &me->length );
	me->explicit = get_memory( me->length+1 );
	get_array( me->explicit,me->length );
	me->explicit[ me->length ] = NULL;
	}
else me->explicit = NULL;

if ( me->common.pflags & 0x8 )
	{
	get_DOUBLE( &me->linear_x1 );
	get_DOUBLE( &me->linear_y1 );
	if ( __drawing->acad10 OR __drawing->acad11 ) get_DOUBLE( &me->linear_z1 );
	else me->linear_z1 = 0.0;
	}
else me->linear_x1 = me->linear_y1 = me->linear_z1 = 0.0;

if ( me->common.pflags & 0x10 )
	{
	get_DOUBLE( &me->linear_x2 );
	get_DOUBLE( &me->linear_y2 );
	if ( __drawing->acad10 OR __drawing->acad11 ) get_DOUBLE( &me->linear_z2 );
	else me->linear_z2 = 0.0;
	}
else me->linear_x2 = me->linear_y2 = me->linear_z2 = 0.0;

if ( me->common.pflags & 0x20 )
	{
	get_DOUBLE( &me->dia_x );
	get_DOUBLE( &me->dia_y );
	if ( __drawing->acad10 OR __drawing->acad11 ) get_DOUBLE( &me->dia_z );
	else me->dia_z = 0.0;
	}
else me->dia_x = me->dia_y = me->dia_z = 0.0;

if ( me->common.pflags & 0x40 )
	{
	get_DOUBLE( &me->arc_x );
	get_DOUBLE( &me->arc_y );
	me->arc_z = 0.0;
	}
else me->arc_x = me->arc_y = me->arc_z = 0.0;

if ( me->common.pflags & 0x80 ) get_DOUBLE( &me->leader_length );
else me->leader_length = 0.0;

if ( me->common.pflags & 0x100 ) get_DOUBLE( &me->angle );
else me->angle  = 0.0;
}


PUBLIC void AcadDimension__dump_to_debug_file( AcadDimension *me )

{
dprintf( "DIMENSION\n" );
dprintf( "\tat %lf,%lf,%lf\n",me->x,me->y,me->z );
dprintf( "\tBlock number %x\n",me->block_number );
dprintf( "\tMid text %lf,%lf,%lf\n",me->mid_text_x,me->mid_text_y,me->mid_text_z );
if ( me->common.pflags & 0x1 ) dprintf( "\tClone %lf,%lf\n",me->clone_x,me->clone_y );
if ( me->common.pflags & 0x2 ) dprintf( "\tType %x\n",me->dimension_type );
if ( me->common.pflags & 0x4 ) dprintf( "\tExplicit >%s<\n",me->explicit );
if ( me->common.pflags & 0x8 ) dprintf( "\tLinear 1 %lf,%lf,%lf\n",me->linear_x1,me->linear_y1,me->linear_z1 );
if ( me->common.pflags & 0x10 ) dprintf( "\tLinear 2 %lf,%lf,%lf\n",me->linear_x2,me->linear_y2,me->linear_z2 );
if ( me->common.pflags & 0x20 ) dprintf( "\tdia %lf radius %lf angular %lf\n",me->dia_x,me->dia_y,me->dia_z );
if ( me->common.pflags & 0x40 ) dprintf( "\tarc %lf,%lf,%lf\n",me->arc_x,me->arc_y,me->arc_z );
if ( me->common.pflags & 0x80 ) dprintf( "\tLeader length %lf\n",me->leader_length );
if ( me->common.pflags & 0x100 ) dprintf( "\tAngle %lf\n",me->angle );
AcadEntity__dump_to_debug_file( &me->common );
}


PUBLIC void AcadDimension__dxfout( AcadDimension *me )

{
dxf_string( 0,"DIMENSION" );
AcadEntity__dxfout( &me->common );
dxf_string( 2,full_block_name( me->block_number ) );
dxf_DOUBLE( 10,me->x );
dxf_DOUBLE( 20,me->y );
if ( !__drawing->header->flatland ) dxf_DOUBLE( 30,me->z );
dxf_DOUBLE( 11,me->mid_text_x );
dxf_DOUBLE( 21,me->mid_text_y );
dxf_DOUBLE( 31,me->mid_text_z );
if ( me->common.pflags & 0x1 )
	{
	dxf_DOUBLE( 12,me->clone_x );
	dxf_DOUBLE( 22,me->clone_y );
	}
if ( me->common.pflags & 0x2 ) dxf_char( 70,me->dimension_type );
if ( me->common.pflags & 0x4 ) dxf_string( 1,me->explicit );
if ( me->common.pflags & 0x8 )
	{
	dxf_DOUBLE( 13,me->linear_x1 );
	dxf_DOUBLE( 23,me->linear_y1 );
	dxf_DOUBLE( 33,me->linear_z1 );
	}
if ( me->common.pflags & 0x10 )
	{
	dxf_DOUBLE( 14,me->linear_x2 );
	dxf_DOUBLE( 24,me->linear_y2 );
	dxf_DOUBLE( 34,me->linear_z2 );
	}
if ( me->common.pflags & 0x20 )
	{
	dxf_DOUBLE( 15,me->dia_x );
	dxf_DOUBLE( 25,me->dia_y );
	dxf_DOUBLE( 35,me->dia_z );
	}
if ( me->common.pflags & 0x40 )
	{
	if ( me->arc_x NEQ 0.0 AND me->arc_y NEQ 0.0 AND me->arc_z NEQ 0.0 )
		{
		dxf_DOUBLE( 16,me->arc_x );
		dxf_DOUBLE( 26,me->arc_y );
		dxf_DOUBLE( 36,me->arc_z );
		}
	}
if ( me->common.pflags & 0x80 ) dxf_DOUBLE( 40,me->leader_length );
if ( me->common.pflags & 0x100 ) dxf_DOUBLE( 50,rad_to_degrees( me->angle ) );
dxf_string( 3,"STANDARD" );
}


PUBLIC void AcadDimension__write( AcadDimension *me )

{
int size;

put_UINT8( 0x17 );  /* DIMENSION TYPE */
size = sizeof( DOUBLE )*5 + sizeof( INT16 ) + 1;
if ( me->common.pflags & 0x1 ) size += sizeof( DOUBLE )*2;
if ( me->common.pflags & 0x2 ) ++size;
if ( me->common.pflags & 0x4 ) size += strlen( me->explicit )+1;
if ( me->common.pflags & 0x8 ) size += sizeof( DOUBLE )*3;
if ( me->common.pflags & 0x10 ) size += sizeof( DOUBLE )*3;
if ( me->common.pflags & 0x20 ) size += sizeof( DOUBLE )*3;
if ( me->common.pflags & 0x40 ) size += sizeof( DOUBLE )*2;
if ( me->common.pflags & 0x80 ) size += sizeof( DOUBLE );
if ( me->common.pflags & 0x100 ) size += sizeof( DOUBLE );
if ( me->common.ucs ) size += sizeof( DOUBLE )*3;
AcadEntity__write_elevation_etc( &me->common,true,true,size );
if ( debugger ) dprintf( "\tdimension entity\n" );

put_INT16( me->block_number );
put_DOUBLE( me->x );
put_DOUBLE( me->y );
put_DOUBLE( me->z );
put_DOUBLE( me->mid_text_x );
put_DOUBLE( me->mid_text_y );
if ( me->common.pflags & 0x1 )
	{
	put_DOUBLE( me->clone_x );
	put_DOUBLE( me->clone_y );
	}
if ( me->common.pflags & 0x2 ) put_UINT8( me->dimension_type );
if ( me->common.pflags & 0x4 )
	{
	put_INT16( me->length );
	put_array( me->explicit,me->length );
	me->explicit[ me->length ] = NULL;
	}

if ( me->common.pflags & 0x8 )
	{
	put_DOUBLE( me->linear_x1 );
	put_DOUBLE( me->linear_y1 );
	put_DOUBLE( me->linear_z1 );
	}

if ( me->common.pflags & 0x10 )
	{
	put_DOUBLE( me->linear_x2 );
	put_DOUBLE( me->linear_y2 );
	put_DOUBLE( me->linear_z2 );
	}

if ( me->common.pflags & 0x20 )
	{
	put_DOUBLE( me->dia_x );
	put_DOUBLE( me->dia_y );
	put_DOUBLE( me->dia_z );
	}

if ( me->common.pflags & 0x40 )
	{
	put_DOUBLE( me->arc_x );
	put_DOUBLE( me->arc_y );
	}
if ( me->common.pflags & 0x80 ) put_DOUBLE( me->leader_length );
if ( me->common.pflags & 0x100 ) put_DOUBLE( me->angle );

if ( me->common.ucs ) AcadEntity__put_ucs_directions( &me->common );
}





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -