# include "StdAfx.h"
# include "DxfReadMgr.h"
# include "LogMgr.h"
# include "GlobalFunction.h"
# include "SmartPtr.h"
# include "ObjCircle.h"
# include "ObjPline.h"
# include "DataPoint.h"
# include "GlobalDefine.h"
# include "CommandMgr.h"
# include "WorkRecord.h"
# include "WorkFileMgr.h"
# include "ProgramCutMgr.h"
# include "FileMgr.h"
# ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
static char THIS_FILE [ ] = __FILE__ ;
# endif
# if 1
float x , y , z ;
CPos : : CPos ( )
{
x = 0.0 ;
y = 0.0 ;
z = 0.0 ;
}
CPos : : CPos ( float tx , float ty , float tz )
{
x = tx ;
y = ty ;
z = tz ;
}
CPos : : CPos ( POS tpos )
{
x = tpos . x ;
y = tpos . y ;
z = tpos . z ;
}
CPos : : CPos ( CPoint pot )
{
x = ( float ) pot . x ;
y = ( float ) pot . y ;
z = 0.0 ;
}
CPos : : ~ CPos ( )
{
}
float CPos : : Clear ( )
{
x = 0.0 ;
y = 0.0 ;
z = 0.0 ;
return 0 ;
}
CPos CPos : : operator = ( CPos pos )
{
x = pos . x ;
y = pos . y ;
z = pos . z ;
return * this ;
}
CPos CPos : : operator = ( int pos )
{
x = ( float ) pos ;
y = ( float ) pos ;
z = ( float ) pos ;
return * this ;
}
CPos CPos : : operator + ( CPos pos )
{
CPos tmp ;
tmp . x = x + pos . x ;
tmp . y = y + pos . y ;
tmp . z = z + pos . z ;
return tmp ;
}
CPos CPos : : operator - ( CPos pos )
{
CPos tmp ;
tmp . x = x - pos . x ;
tmp . y = y - pos . y ;
tmp . z = z - pos . z ;
return tmp ;
}
bool CPos : : operator = = ( CPos pos )
{
if ( ( x = = pos . x ) & & ( y = = pos . y ) & & ( z = pos . z ) )
return true ;
else
return false ;
}
CPoint Point ( CPos pos )
{
CPoint tmp ;
tmp . x = ( int ) pos . x ;
tmp . y = ( int ) pos . y ;
return tmp ;
}
# endif
# if 1
const int MAX_NUMBER = 500 ;
int a ;
CString tr ;
bool finded = false ;
# if 1
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡstrMarket<65> <74> ǩ
# define READ_MARKET(strMarket) \
if ( ! feof ( fp ) & & ! ferror ( fp ) ) \
{ \
tr . Empty ( ) ; \
fscanf ( fp , " %s \n " , m_str ) ; \
a + + ; \
while ( strcmp ( m_str , strMarket ) ! = 0 ) \
{ \
fscanf ( fp , " %s \n " , m_str ) ; \
a + + ; \
} }
# endif
//<2F> Ƚϱ <C8BD> ǩ<EFBFBD> <C7A9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
# define CMP(array, num) \
for ( int i = 0 ; i < num ; i + + ) \
{ \
if ( finded ) \
break ; \
if ( strcmp ( m_str , array # # [ i ] ) = = 0 ) \
finded = true ; \
else \
finded = false ; \
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡstrMarket<65> <74> ǩ<EFBFBD> <C7A9> <EFBFBD> <EFBFBD> -------------------------------------------????????????????????????
# define READ_MARKETARRAY(strMarket, num) \
if ( ! feof ( fp ) & & ! ferror ( fp ) ) \
{ \
tr . Empty ( ) ; \
finded = false ; \
fscanf ( fp , " %s \n " , m_str ) ; \
a + + ; \
CMP ( strMarket , num ) ; \
while ( ! finded ) \
{ \
fscanf ( fp , " %s \n " , m_str ) ; \
a + + ; \
CMP ( strMarket , num ) ; \
} \
}
/*
*/
bool bbreak = false ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> β
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡvalue<75> <65> ֵ
# define READ_VALUE1(strVal) \
ASSERT ( fp ! = NULL ) ; \
bbreak = false ; \
if ( ! feof ( fp ) & & ! ferror ( fp ) ) \
{ \
fscanf ( fp , " %s \n " , m_str ) ; \
while ( strcmp ( m_str , strVal ) ! = 0 ) \
{ \
if ( strcmp ( m_str , " ENDSEC " ) ! = 0 ) \
fscanf ( fp , " %s \n " , m_str ) ; \
else \
{ \
bbreak = true ; \
break ; \
} } \
if ( ! bbreak ) \
fscanf ( fp , " %f \n " , & m_val ) ; \
}
//ֱ<> Ӷ<EFBFBD> ȡvalue<75> <65> ֵ
# define READ_VALUE(strVal) \
ASSERT ( fp ! = NULL ) ; \
if ( ! feof ( fp ) & & ! ferror ( fp ) ) \
{ \
fscanf ( fp , " %s \n " , m_str ) ; \
if ( strcmp ( m_str , strVal ) = = 0 ) \
fscanf ( fp , " %f \n " , & m_val ) ; \
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡvalue<75> <65> <EFBFBD> <EFBFBD>
# define READ_STR1(strVal) \
ASSERT ( fp ! = NULL ) ; \
if ( ! feof ( fp ) & & ! ferror ( fp ) ) \
{ \
fscanf ( fp , " %s \n " , m_str ) ; \
while ( strcmp ( m_str , strVal ) = = 0 ) \
{ \
fscanf ( fp , " %s \n " , & m_strcont ) ; \
fscanf ( fp , " %s \n " , & m_strcont ) ; \
} }
//ֱ<> Ӷ<EFBFBD> ȡvalue<75> <65> <EFBFBD> <EFBFBD>
# define READ_STR(strVal) \
ASSERT ( fp ! = NULL ) ; \
if ( ! feof ( fp ) & & ! ferror ( fp ) ) \
{ \
fscanf ( fp , " %s \n " , m_str ) ; \
if ( strcmp ( m_str , strVal ) = = 0 ) \
fscanf ( fp , " %s \n " , & m_strcont ) ; \
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡ3ά<33> <CEAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
# define READ_3DCOORD(number) \
m_pos . Clear ( ) ; \
if ( number = = 0 ) \
{ \
READ_VALUE1 ( " 10 " ) ; \
m_pos . x = m_val ; \
if ( ! bbreak ) \
{ \
READ_VALUE ( " 20 " ) ; \
m_pos . y = m_val ; \
READ_VALUE ( " 30 " ) ; \
m_pos . z = m_val ; \
} \
} \
else if ( number = = 1 ) \
{ \
READ_VALUE1 ( " 11 " ) ; \
m_pos . x = m_val ; \
if ( ! bbreak ) \
{ \
READ_VALUE ( " 21 " ) ; \
m_pos . y = m_val ; \
READ_VALUE ( " 31 " ) ; \
m_pos . z = m_val ; \
} \
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡ2ά<32> <CEAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
# define READ_2DCOORD(number) \
m_pos . Clear ( ) ; \
if ( number = = 0 ) \
{ \
READ_VALUE1 ( " 10 " ) ; \
m_pos . x = m_val ; \
if ( ! bbreak ) \
{ \
READ_VALUE ( " 20 " ) ; \
m_pos . y = m_val ; \
} \
} \
else if ( number = = 1 ) \
{ \
READ_VALUE1 ( " 11 " ) ; \
m_pos . x = m_val ; \
if ( ! bbreak ) \
{ \
READ_VALUE ( " 21 " ) ; \
m_pos . y = m_val ; \
} \
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡ<EFBFBD> ߴ <EFBFBD> <DFB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
# define READ_JXCOORD(number) \
m_pos . x = 0.0 ; \
m_pos . y = 0.0 ; \
m_pos . z = 0.0 ; \
if ( number = = 0 ) \
{ \
READ_VALUE1 ( " 13 " ) ; \
m_pos . x = m_val ; \
if ( ! bbreak ) \
{ \
READ_VALUE ( " 23 " ) ; \
m_pos . y = m_val ; \
READ_VALUE ( " 33 " ) ; \
m_pos . z = m_val ; \
} \
} \
else if ( number = = 1 ) \
{ \
READ_VALUE1 ( " 14 " ) ; \
m_pos . x = m_val ; \
if ( ! bbreak ) \
{ \
READ_VALUE ( " 24 " ) ; \
m_pos . y = m_val ; \
READ_VALUE ( " 34 " ) ; \
m_pos . z = m_val ; \
} \
}
CDxfReadMgr * gDxfReadMgr = new CDxfReadMgr ;
CDxfReadMgr : : CDxfReadMgr ( void )
{
b_ShowArcRadius = true ; //<2F> <> ʾ <EFBFBD> <CABE> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Բ<EFBFBD> <D4B2> <EFBFBD> 뾶(<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֻ<EFBFBD> <D6BB> ʾ һ <CABE> <D2BB> )
}
CDxfReadMgr : : ~ CDxfReadMgr ( void )
{
}
//Angle <20> Ǵ<EFBFBD> <C7B4> <EFBFBD> <EFBFBD> Ժ<EFBFBD> <D4BA> <EFBFBD> <EFBFBD> <EFBFBD> ת<EFBFBD> Ƕ<EFBFBD>
bool CDxfReadMgr : : OpenDxfFileDlg ( double Angle )
{
CString FilePath = gServer - > m_RcvFileName ;
if ( FilePath . IsEmpty ( ) )
{
CFileDialog FileOpen ( TRUE , NULL , NULL , OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT , " dxf <20> ļ<EFBFBD> (*.dxf) | * . dxf ; " );
/*CFileMgr fg;
CString exeDir = fg . GetWorkPath ( ) ;
CString dxfDir = exeDir + " \\ DXF " ;
FileOpen . m_ofn . lpstrInitialDir = dxfDir ; //ָ<> <D6B8> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> */
if ( IDOK = = FileOpen . DoModal ( ) )
{
FilePath = FileOpen . GetPathName ( ) ;
}
else
{
throw ( CString ) " opencancle " ;
}
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> obj
CLayer & layer = GetLayerInstance ( ) ;
layer . SelAllObj ( ) ;
layer . DelSelObj ( ) ;
layer . NotSelAllObj ( ) ; //ȫ<> <C8AB> ѡ
if ( ReadDxfFile ( FilePath ) )
{
layer . SelAllObj ( ) ; //ȫѡ
layer . OnRotato ( Angle ) ; //<2F> <> <EFBFBD> <EFBFBD> ת90 <20> <>
GetCurViewPtr ( ) - > MoveSelObjToCenter ( ) ; //<2F> ƶ<EFBFBD> <C6B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
layer . NotSelAllObj ( ) ; //ȫ<> <C8AB> ѡ
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> undo ָ<> <D6B8> ,<2C> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> layer obj <20> <> <EFBFBD> <EFBFBD>
gCommandMgr . Reset ( ) ;
//<2F> <> <EFBFBD> õ<EFBFBD> ǰ<EFBFBD> <C7B0> Ʒ <EFBFBD> ͺ <EFBFBD>
CFileMgr FileMgr ;
CString s = FileMgr . GetFileNameFromPath ( FilePath , true ) ;
gWorkRecordMgr - > SetProductType ( s ) ;
CWorkFileMgr WorkFileMgr ;
WorkFileMgr . SaveFileName ( FilePath ) ;
//<2F> <> ¼<EFBFBD> <C2BC> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
gProgramCutMgr - > SetCurOpenFileName ( FileMgr . GetFileNameFromPath ( FilePath , true ) ) ;
return true ;
}
//}
return false ;
}
bool CDxfReadMgr : : ReadDxfFile ( CString FilePath )
{
FILE * fp ;
if ( FilePath . IsEmpty ( ) )
{
gLogMgr - > WriteDebugLog ( " Func : ReadDxfFile ---->Dxf File Path Empty! " ) ; //·<> <C2B7> Ϊ<EFBFBD> <CEAA>
return false ;
}
fp = fopen ( FilePath , " r " ) ;
if ( ! fp )
{
gLogMgr - > WriteDebugLog ( " Func : ReadDxfFile ---->Dxf File Open Error! " ) ;
//"D:\<5C> <> <EFBFBD> <EFBFBD> <EFBFBD> и<EFBFBD> <D0B8> <EFBFBD> \ͬ<> ˴ <EFBFBD> ˫ͷ-<2D> <> <EFBFBD> ξ<EFBFBD> \LaiPuLaser\Debug\TempMarkData\D287.dxf"
return false ;
}
m_LINE . Empty ( ) ;
m_CIRCLE . Empty ( ) ;
m_POLYLINE . Empty ( ) ;
m_ARC . Empty ( ) ;
m_TEXT . Empty ( ) ;
m_MTEXT . Empty ( ) ;
m_DIMENSION . Empty ( ) ;
b_ShowArcRadius = true ;
ReadEntitiesSec ( fp ) ;
//gLogMgr->WriteDebugLog(m_POLYLINE);
FilePath = " Func : ReadDxfFile ----> " + FilePath ;
gLogMgr - > WriteDebugLog ( FilePath ) ;
fclose ( fp ) ;
return true ;
}
void CDxfReadMgr : : SetVal ( CPos & tagpos )
{
tagpos = m_pos ;
}
//<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> ʵ<EFBFBD> <CAB5>
bool CDxfReadMgr : : ReadEntitiesSec ( FILE * fp )
{
if ( fp = = NULL )
return false ;
CString strBlockWord = _T ( " LINE, CIRCLE, LWPOLYLINE, ARC, MTEXT, TEXT, DIMENSION " ) ;
CString strSynWord = _T ( " AcDbLine, AcDbCircle, AcDbPolyline, AcDbArc, AcDbMText,AcDbText,AcDbDimension " ) ;
CString strDimension [ 2 ] = { " AcDbAlignedDimension " , " AcDbOrdinateDimension " } ;
vector < CString > strTypeArray ;
LoadSynWord ( strBlockWord , strTypeArray ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ؼ<CDB9> <D8BC> <EFBFBD>
int number [ 7 ] = { 0 } ;
READ_MARKET ( " ENTITIES " ) ;
fscanf ( fp , " %s \n " , m_str ) ;
a + + ;
do {
fscanf ( fp , " %s \n " , m_str ) ;
a + + ;
int size = strTypeArray . size ( ) ;
for ( int i = 0 ; i < size ; i + + ) //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
if ( strcmp ( m_str , strTypeArray [ i ] ) = = 0 ) //ȡ<> <C8A1> <EFBFBD> <EFBFBD> Ӧ<EFBFBD> <D3A6> <EFBFBD> <EFBFBD>
{
CString str ;
switch ( i )
{
case 0 : //ֱ<> <D6B1>
number [ 0 ] + + ;
LoadLineData ( fp ) ;
break ;
case 1 : //Բ
number [ 1 ] + + ;
LoadCircleData ( fp ) ;
break ;
case 2 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
number [ 2 ] + + ;
str . Format ( " <EFBFBD> <EFBFBD> %d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \r \n " , number [ 2 ] ) ;
m_POLYLINE + = str ;
LoadPolyLineData ( fp ) ;
break ;
case 3 : //Բ<> <D4B2>
number [ 3 ] + + ;
LoadArcData ( fp ) ;
break ;
case 4 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD>
number [ 4 ] + + ;
LoadMtextData ( fp ) ;
break ;
case 5 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD>
number [ 5 ] + + ;
LoadTextData ( fp ) ;
break ;
case 6 : //<2F> <> ע
number [ 6 ] + + ;
LoadDimensionData ( fp ) ;
break ;
default :
break ;
}
}
}
} while ( strcmp ( m_str , " ENDSEC " ) ! = 0 ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> β
return true ;
}
void CDxfReadMgr : : LoadSynWord ( CString strSynWord , vector < CString > & strArrayKeyWords )
{
CString strTemp ;
int nPosPrior = - 1 ;
int nPos ;
nPos = strSynWord . Find ( _T ( " , " ) , 0 ) ;
while ( nPos ! = - 1 )
{
strTemp = strSynWord . Mid ( nPosPrior + 1 , nPos - nPosPrior - 1 ) ;
strTemp . TrimRight ( ) ;
strTemp . TrimLeft ( ) ;
strArrayKeyWords . push_back ( strTemp ) ;
nPosPrior = nPos ;
nPos = strSynWord . Find ( _T ( " , " ) , nPosPrior + 1 ) ;
}
strTemp = strSynWord . Mid ( nPosPrior + 1 , strSynWord . GetLength ( ) - nPosPrior - 1 ) ;
strTemp . TrimRight ( ) ;
strTemp . TrimLeft ( ) ;
strArrayKeyWords . push_back ( strTemp ) ;
}
bool CDxfReadMgr : : LoadLineData ( FILE * fp ) //<2F> <> <EFBFBD> <EFBFBD> ֱ<EFBFBD> <D6B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
CPos pos1 , pos2 ;
CString strtmp ;
READ_MARKET ( " AcDbLine " ) ;
READ_3DCOORD ( 0 ) ;
SetVal ( pos1 ) ; //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
READ_3DCOORD ( 1 ) ;
SetVal ( pos2 ) ; //<2F> <> ȡ<EFBFBD> ˵<EFBFBD> <CBB5> <EFBFBD> <EFBFBD> <EFBFBD>
strtmp . Format ( " <EFBFBD> <EFBFBD> %d<> <64> ֱ<EFBFBD> <D6B1> \r \n <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f \r \n <20> ˵<EFBFBD> <CBB5> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f \r \n " , \
2 , pos1 . x , pos1 . y , pos1 . z , pos2 . x , pos2 . y , pos2 . z ) ;
m_LINE + = strtmp ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ζ<DFB6> <CEB6> <EFBFBD>
CObjPline * pObjPline = new CObjPline ;
pObjPline - > Creat ( Dbxy ( pos1 . x , pos1 . y ) , Dbxy ( pos2 . x , pos2 . y ) ) ;
GetLayerInstance ( ) . AddObject ( pObjPline ) ;
return 0 ;
}
bool CDxfReadMgr : : LoadCircleData ( FILE * fp ) //<2F> <> <EFBFBD> <EFBFBD> Բ<EFBFBD> <D4B2> <EFBFBD> <EFBFBD>
{
CPos pos1 ;
CString strtmp ;
READ_MARKET ( " AcDbCircle " ) ;
READ_3DCOORD ( 0 ) ;
SetVal ( pos1 ) ; //<2F> <> ȡԲ<C8A1> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
READ_VALUE ( " 40 " ) ; //<2F> <> ȡԲ<C8A1> 뾶
strtmp . Format ( " <EFBFBD> <EFBFBD> %d<> <64> Բ\r \n Բ<> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f <20> 뾶: %.4f \r \n " , 3 , pos1 . x , pos1 . y , pos1 . z , m_val ) ;
m_CIRCLE + = strtmp ;
//<2F> <> <EFBFBD> <EFBFBD> circle <20> <> obj <20> <> <EFBFBD> <EFBFBD>
CObjCircle * p = new CObjCircle ;
CCirclePar ObjCirclePar ;
ObjCirclePar . CenterPt = Dbxy ( pos1 . x , pos1 . y ) ;
ObjCirclePar . Radius = m_val ;
ObjCirclePar . DEdgeCnt = 0 ;
p - > Creat ( ObjCirclePar ) ;
GetLayerInstance ( ) . AddObject ( p ) ;
return 0 ;
}
//<2F> <> ȡһ <C8A1> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bool CDxfReadMgr : : LoadPolyLineData ( FILE * fp )
{
CPos pos [ MAX_NUMBER ] ;
float Convexity [ MAX_NUMBER ] ; //<> <CDB9>
memset ( Convexity , 0 , sizeof ( float ) * MAX_NUMBER ) ;
CString strtmp ;
int m ;
int PtCnt ;
int bClose ; //<2F> Ƿ<EFBFBD> <C7B7> պ<EFBFBD>
READ_MARKET ( " AcDbPolyline " ) ;
READ_VALUE1 ( " 90 " ) ; //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
PtCnt = int ( m_val ) ;
READ_VALUE1 ( " 70 " ) ; //<2F> Ƿ<EFBFBD> <C7B7> պ<EFBFBD>
bClose = int ( m_val ) ; //1Ϊ<31> պ<EFBFBD>
if ( PtCnt < 2 | | PtCnt > MAX_NUMBER )
{
//strtmp.Format("<22> <> ȡ<EFBFBD> <C8A1> %d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> %d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> 궨<EFBFBD> <EAB6A8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <DEB7> <EFBFBD> ʾ !", 3, PtCnt);
return false ;
}
bool bFlg10 = true ; //<2F> Ƿ<EFBFBD> <C7B7> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> 10
for ( m = 0 ; m < PtCnt ; m + + )
{
if ( bFlg10 )
{
READ_VALUE1 ( " 10 " ) ;
m_pos . x = m_val ;
}
if ( ! bbreak )
{
READ_VALUE ( " 20 " ) ;
m_pos . y = m_val ;
SetVal ( pos [ m ] ) ; //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD>
if ( ! feof ( fp ) & & ! ferror ( fp ) )
{
fscanf ( fp , " %s \n " , m_str ) ;
if ( strcmp ( m_str , ( " 40 " ) ) = = 0 )
{
READ_VALUE ( " 41 " ) ; //41 ȥ<> <C8A5>
fscanf ( fp , " %s \n " , m_str ) ;
fscanf ( fp , " %f \n " , & m_val ) ;
fscanf ( fp , " %s \n " , m_str ) ;
}
if ( strcmp ( m_str , ( " 10 " ) ) = = 0 ) //û<> <C3BB> <EFBFBD> ȵ<EFBFBD> <C8B5> <EFBFBD> <EFBFBD> <EFBFBD>
{
fscanf ( fp , " %f \n " , & m_val ) ;
m_pos . x = m_val ;
bFlg10 = false ;
}
else if ( strcmp ( m_str , ( " 42 " ) ) = = 0 ) //<2F> <> <EFBFBD> ȵ<EFBFBD> <C8B5> <EFBFBD> <EFBFBD> <EFBFBD>
{
fscanf ( fp , " %f \n " , & m_val ) ;
Convexity [ m ] = m_val ;
bFlg10 = true ;
}
}
}
}
if ( PtCnt < = 0 )
return 0 ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ζ<DFB6> <CEB6> <EFBFBD>
CObjPline * pObjPline = new CObjPline ;
//<2F> <> <EFBFBD> <EFBFBD> ƫ<EFBFBD> Ƶ<EFBFBD> ԭ<EFBFBD> <D4AD>
Dbxy AllOffset ( pos [ 0 ] . x - 100 , pos [ 0 ] . y - 100 ) ;
for ( int k = 0 ; k < MAX_NUMBER ; k + + )
{
pos [ k ] . x - = AllOffset . x ;
pos [ k ] . y - = AllOffset . y ;
}
for ( m = 0 ; m < PtCnt ; m + + )
{
double CurConvexity = Convexity [ m ] ;
#if 0
strtmp . Format ( " %d<> ˵<EFBFBD> <CBB5> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f \r \n " , m , pos [ m ] . x , pos [ m ] . y , pos [ m ] . z ) ;
gLogMgr - > WriteDebugLog ( strtmp ) ;
strtmp . Format ( " %d<64> <CDB9> ֵ=%.4f \r \n " , m , CurConvexity ) ;
gLogMgr - > WriteDebugLog ( strtmp ) ;
# endif
if ( m = = 0 ) //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶<EFBFBD>
{
pObjPline - > Creat ( Dbxy ( pos [ m ] . x , pos [ m ] . y ) , Dbxy ( pos [ m ] . x , pos [ m ] . y ) ) ;
}
else
{
CDataPoint DataPoint ( Dbxy ( pos [ m ] . x , pos [ m ] . y ) ) ;
DataPoint . SetIsNode ( true ) ;
pObjPline - > AddDataPoint ( DataPoint ) ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ε<DFB6> Բ<EFBFBD> <D4B2>
if ( ! IsDbEqualZero ( CurConvexity ) )
{
vector < Dbxy > PtVec ;
if ( m ! = PtCnt - 1 )
{
CreatArcData ( Dbxy ( pos [ m ] . x , pos [ m ] . y ) , Dbxy ( pos [ m + 1 ] . x , pos [ m + 1 ] . y ) , CurConvexity , PtVec ) ;
}
else //<2F> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <E2B4A6>
{
CreatArcData ( Dbxy ( pos [ m ] . x , pos [ m ] . y ) , Dbxy ( pos [ 0 ] . x , pos [ 0 ] . y ) , CurConvexity , PtVec ) ;
}
vector < Dbxy > : : iterator iter = PtVec . begin ( ) ;
vector < Dbxy > : : iterator iter_end = PtVec . end ( ) ;
for ( ; iter ! = iter_end ; iter + + )
{
CDataPoint DataPoint ( ( * iter ) ) ;
DataPoint . SetIsNode ( true ) ;
pObjPline - > AddDataPoint ( DataPoint ) ;
}
}
}
# if 1
if ( bClose ) //<2F> պ<EFBFBD>
{
CDataPoint DataPoint ( Dbxy ( pos [ 0 ] . x , pos [ 0 ] . y ) ) ;
DataPoint . SetIsNode ( true ) ;
pObjPline - > AddDataPoint ( DataPoint ) ;
}
# endif
//<2F> <> <EFBFBD> <EFBFBD> ƫ<EFBFBD> ƻ<EFBFBD> ԭ<EFBFBD> <D4AD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB>
vector < CDataPoint > & PtContainer = pObjPline - > GetPtContainer ( ) ;
int size = PtContainer . size ( ) ;
for ( int k = 0 ; k < size ; k + + )
{
Dbxy pt = PtContainer [ k ] . GetPt ( ) ;
pt . x + = AllOffset . x ;
pt . y + = AllOffset . y ;
PtContainer [ k ] . SetPt ( pt ) ;
}
GetLayerInstance ( ) . AddObject ( pObjPline ) ;
return 0 ;
}
bool CDxfReadMgr : : LoadArcData ( FILE * fp ) //<2F> <> <EFBFBD> <EFBFBD> Բ<EFBFBD> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
CString strtmp ;
CPos pos ;
float nRadio ;
float angle1 , angle2 ;
READ_MARKET ( " AcDbCircle " ) ;
READ_3DCOORD ( 0 ) ;
SetVal ( pos ) ; //<2F> <> ȡԲ<C8A1> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
READ_VALUE ( " 40 " ) ; //<2F> <> ȡԲ<C8A1> 뾶
nRadio = m_val ;
READ_MARKET ( " AcDbArc " ) ;
READ_VALUE ( " 50 " ) ; //<2F> <> ȡ<EFBFBD> <C8A1> ʼ <EFBFBD> Ƕ<EFBFBD>
angle1 = m_val ;
READ_VALUE ( " 51 " ) ; //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> Ƕ<EFBFBD>
angle2 = m_val ;
strtmp . Format ( " <EFBFBD> <EFBFBD> %d<> <64> Բ<EFBFBD> <D4B2> \r \n Բ<> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f <20> 뾶: %.4f \r \n <20> <> ʼ <EFBFBD> Ƕ<EFBFBD> : %.0f <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ƕ<EFBFBD> : %.0f \r \n " , \
4 , pos . x , pos . y , pos . z , nRadio , angle1 , angle2 ) ;
//m_ARC += strtmp;
if ( angle1 > angle2 )
{
angle2 = angle2 + 360 ;
}
//Բ<> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ζ<DFB6> <CEB6> <EFBFBD>
CCirclePar CirclePar ;
vector < Dbxy > PtVec ;
CirclePar . StartAng = angle1 ;
CirclePar . EndAng = angle2 ;
CirclePar . CenterPt = Dbxy ( pos . x , pos . y ) ;
CirclePar . Radius = nRadio ;
CirclePar . DEdgeCnt = 0 ; //<2F> <> <EFBFBD> <EFBFBD> Բ<EFBFBD> İ뾶<C4B0> Զ<EFBFBD> ѡ <EFBFBD> <D1A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
CirclePar . bMerge = false ; //<2F> պ<EFBFBD>
CreatCircleData ( CirclePar , PtVec ) ;
CObjPline * pObjPline = new CObjPline ;
vector < Dbxy > : : iterator iter = PtVec . begin ( ) ;
vector < Dbxy > : : iterator iter_end = PtVec . end ( ) ;
for ( ; iter ! = iter_end ; iter + + )
{
CDataPoint DataPoint ( ( * iter ) ) ;
DataPoint . SetIsNode ( true ) ;
pObjPline - > AddDataPoint ( DataPoint ) ;
}
GetLayerInstance ( ) . AddObject ( pObjPline ) ;
return 0 ;
}
bool CDxfReadMgr : : LoadTextData ( FILE * fp ) //<2F> <> <EFBFBD> ص<EFBFBD> <D8B5> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD>
{
CString strtmp ;
CPos pos ;
float fontheight ;
char strcont [ 50 ] ; //<2F> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> ݻ<EFBFBD> <DDBB> <EFBFBD> <EFBFBD> <EFBFBD> **
READ_MARKET ( " AcDbText " ) ;
READ_3DCOORD ( 0 ) ;
SetVal ( pos ) ; //<2F> <> ȡ<EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
READ_VALUE ( " 40 " ) ;
fontheight = m_val ; //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> ָ߶<D6B8>
//
READ_STR ( " 1 " ) ;
strcpy ( strcont , m_strcont ) ;
strtmp . Format ( " <EFBFBD> <EFBFBD> %d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> ֶ<EFBFBD> \r \n <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f <20> ߶<EFBFBD> : %.2f \r \n <20> <> <EFBFBD> <EFBFBD> : %s \r \n " , \
5 , pos . x , pos . y , pos . z , fontheight , strcont ) ;
m_TEXT + = strtmp ;
return 0 ;
}
bool CDxfReadMgr : : LoadMtextData ( FILE * fp ) //<2F> <> <EFBFBD> ض<EFBFBD> <D8B6> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD>
{
CString strtmp ;
CPos pos1 ;
float fontheight , fontwidth ;
char strcont [ 255 ] ; //<2F> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> ݻ<EFBFBD> <DDBB> <EFBFBD> <EFBFBD> <EFBFBD> **
READ_MARKET ( " AcDbMText " ) ;
READ_3DCOORD ( 0 ) ;
SetVal ( pos1 ) ; //<2F> <> ȡ<EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
READ_VALUE ( " 40 " ) ;
fontheight = m_val ; //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> ָ߶<D6B8>
READ_VALUE ( " 41 " ) ;
fontwidth = m_val ; //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> ֿ<EFBFBD> <D6BF> <EFBFBD>
READ_VALUE ( " 71 " ) ;
READ_VALUE ( " 72 " ) ;
READ_STR ( " 1 " ) ;
strcpy ( strcont , m_strcont ) ;
strtmp . Format ( " <EFBFBD> <EFBFBD> %d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> ֶ<EFBFBD> \r \n <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f \r \n <20> ߶<EFBFBD> : %.2f <20> <> <EFBFBD> <EFBFBD> : %.2f \r \n <20> <> <EFBFBD> <EFBFBD> : %s \r \n " , \
5 , pos1 . x , pos1 . y , pos1 . z , fontheight , fontwidth , strcont ) ;
m_MTEXT + = strtmp ;
return 0 ;
}
bool CDxfReadMgr : : LoadDimensionData ( FILE * fp ) //<2F> <> <EFBFBD> ر<EFBFBD> ע<EFBFBD> <D7A2> <EFBFBD> <EFBFBD>
{
CString strDimension [ 2 ] = { " AcDbAlignedDimension " , " AcDbOrdinateDimension " } ;
CString strtmp ;
CPos pos1 , pos2 , pos3 , pos4 ;
char strcont [ 255 ] ; //<2F> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> ݻ<EFBFBD> <DDBB> <EFBFBD> <EFBFBD> <EFBFBD> **
READ_MARKET ( " AcDbDimension " ) ;
READ_3DCOORD ( 0 ) ;
SetVal ( pos1 ) ; //<2F> <> ȡ<EFBFBD> ߴ <EFBFBD> <DFB4> ߶<EFBFBD> <DFB6> <EFBFBD> <EFBFBD> <EFBFBD>
READ_3DCOORD ( 1 ) ;
SetVal ( pos2 ) ; //<2F> <> ȡ<EFBFBD> <C8A1> עλ<D7A2> <CEBB>
READ_VALUE ( " 70 " ) ;
READ_VALUE ( " 71 " ) ;
READ_STR ( " 42 " ) ; //<2F> <> ȡ<EFBFBD> <C8A1> ע<EFBFBD> <D7A2> <EFBFBD> <EFBFBD>
strcpy ( strcont , m_strcont ) ;
READ_MARKETARRAY ( strDimension , 2 ) ;
strtmp . Format ( " <EFBFBD> <EFBFBD> %d<> <64> <EFBFBD> <EFBFBD> ע\r \n <20> <> һ <EFBFBD> ߴ <EFBFBD> <DFB4> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f \r \n <20> ڶ<EFBFBD> <DAB6> ߴ <EFBFBD> <DFB4> <EFBFBD> <EFBFBD> <EFBFBD> : x=%.4f y=%.4f z=%.4f \r \n <20> ߴ <EFBFBD> <DFB4> <EFBFBD> : x=%.4f y=%.4f z=%.4f \r \n <20> <> עλ<D7A2> <CEBB> : x=%.4f y=%.4f z=%.4f \r \n <20> <> <EFBFBD> ִ<EFBFBD> С : %d <20> <> ע<EFBFBD> <D7A2> <EFBFBD> <EFBFBD> : %s \r \n " , \
6 , pos3 . x , pos3 . y , pos3 . z , pos4 . x , pos4 . y , pos4 . z , \
pos1 . x , pos1 . y , pos1 . z , pos2 . x , pos2 . y , pos2 . z , 20 , strcont ) ;
m_DIMENSION + = strtmp ;
return 0 ;
}
# if 1
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˵<EFBFBD> <CBB5> <EFBFBD> <EFBFBD> ȼ<EFBFBD> <C8BC> <EFBFBD> Բ<EFBFBD> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> CenterPoint (u Ϊ<CEAA> <CDB9> )
//<2F> <> <EFBFBD> <EFBFBD> Բ<EFBFBD> <D4B2> <EFBFBD> İ뾶
double CDxfReadMgr : : GetCenterPtByConvexity ( Dbxy BeginPoint , Dbxy EndPoint , double Convexity , Dbxy & CenterPoint )
{
double dConvexityDegree = Convexity ; //<> <CDB9>
double theta_degree ; //<2F> Ƕ<EFBFBD> ,<2C> <> <EFBFBD> <EFBFBD>
double dStarX = 0 , dStarY = 0 ; //Բ<> <D4B2> <EFBFBD> <EFBFBD> ʼ <EFBFBD> <CABC>
double dEndX = 0 , dEndY = 0 ; //Բ<> <D4B2> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9>
double dStarC = 0 , dEndC = 0 ; //Բ<> <D4B2> <EFBFBD> <EFBFBD> ʼ <EFBFBD> Ƕȣ <C7B6> <C8A3> <EFBFBD> ֹ<EFBFBD> Ƕ<EFBFBD>
double dmiddleX = 0 , dmiddleY = 0 ; //<2F> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߵ <EFBFBD> <DFB5> е <EFBFBD> <D0B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
double dCenterX = 0 , dCenterY = 0 ; //Բ<> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
double dCenterX1 = 0 , dCenterY1 = 0 ; //Բ<> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 1
double dCenterX2 = 0 , dCenterY2 = 0 ; //Բ<> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 2
double dLength ; //<2F> ҳ<EFBFBD>
double dfR ; //<2F> 뾶
double k = 0.0 ; //<2F> ҵ<EFBFBD> б <EFBFBD> <D0B1>
double k_verticle = 0.0 ; //<2F> ҵ<EFBFBD> <D2B5> д<EFBFBD> <D0B4> ߵ <EFBFBD> б <EFBFBD> <D0B1>
double mid_x = 0.0 , mid_y = 0.0 ; //<2F> ҵ<EFBFBD> <D2B5> е <EFBFBD> <D0B5> <EFBFBD> <EFBFBD> <EFBFBD>
double a = 1.0 ;
double b = 1.0 ;
double c = 1.0 ;
double angleChordX = 0 ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> X<EFBFBD> <58> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĽǶ<C4BD>
int direction = 0 ; //<2F> ж<EFBFBD> <D0B6> <EFBFBD> G02<30> <32> <EFBFBD> <EFBFBD> G03
bool isMinorArc = TRUE ; //Բ<> <D4B2> <EFBFBD> 뾶<EFBFBD> Ƿ<EFBFBD> Ϊ<EFBFBD> <CEAA> С <EFBFBD> <D0A1>
double dStartVale = 0 ; //<2F> <> ʼ <EFBFBD> ǵ<EFBFBD> cos<6F> <73> dStarC<72> <43> ֵ
double dEndVale = 0 ; //<2F> <> ֹ<EFBFBD> ǵ<EFBFBD> cos<6F> <73> dEndC<64> <43> ֵ
//<2F> <> <EFBFBD> <CDB9> dConvexityDegree<65> <65> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 0ʱ<30> <CAB1> <EFBFBD> <EFBFBD> ʾ ΪԲ<CEAA> <D4B2>
if ( 0 ! = dConvexityDegree )
{
theta_degree = 4 * atan ( fabs ( dConvexityDegree ) ) ;
//<2F> <> ʼ <EFBFBD> 㣬<EFBFBD> <E3A3AC> ֹ<EFBFBD> <D6B9>
dStarX = BeginPoint . x ;
dStarY = BeginPoint . y ;
dEndX = EndPoint . x ;
dEndY = EndPoint . y ;
//<2F> ҳ<EFBFBD>
dLength = sqrt ( pow ( dStarX - dEndX , 2 ) + pow ( dStarY - dEndY , 2 ) ) ;
//<2F> <> <EFBFBD> <EFBFBD> Բ<EFBFBD> <D4B2> <EFBFBD> 뾶
dfR = fabs ( 0.5 * dLength / sin ( 0.5 * theta_degree ) ) ;
k = ( dEndY - dStarY ) / ( dEndX - dStarX ) ;
if ( k = = 0 )
{
dCenterX1 = ( dStarX + dEndX ) / 2.0 ;
dCenterX2 = ( dStarX + dEndX ) / 2.0 ;
dCenterY1 = dStarY + sqrt ( dfR * dfR - ( dStarX - dEndX ) * ( dStarX - dEndX ) / 4.0 ) ;
dCenterY2 = dEndY - sqrt ( dfR * dfR - ( dStarX - dEndX ) * ( dStarX - dEndX ) / 4.0 ) ;
}
else
{
k_verticle = - 1.0 / k ;
mid_x = ( dStarX + dEndX ) / 2.0 ;
mid_y = ( dStarY + dEndY ) / 2.0 ;
a = 1.0 + k_verticle * k_verticle ;
b = - 2 * mid_x - k_verticle * k_verticle * ( dStarX + dEndX ) ;
c = mid_x * mid_x + k_verticle * k_verticle * ( dStarX + dEndX ) * ( dStarX + dEndX ) / 4.0 -
( dfR * dfR - ( ( mid_x - dStarX ) * ( mid_x - dStarX ) + ( mid_y - dStarY ) * ( mid_y - dStarY ) ) ) ;
dCenterX1 = ( - 1.0 * b + sqrt ( b * b - 4 * a * c ) ) / ( 2 * a ) ;
dCenterX2 = ( - 1.0 * b - sqrt ( b * b - 4 * a * c ) ) / ( 2 * a ) ;
dCenterY1 = k_verticle * dCenterX1 - k_verticle * mid_x + mid_y ;
dCenterY2 = k_verticle * dCenterX2 - k_verticle * mid_x + mid_y ;
}
//<> Ⱦ<EFBFBD> <C8BE> <EFBFBD> ֵС <D6B5> <D0A1> 1<EFBFBD> <31> ʾ Բ<CABE> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С <EFBFBD> <D0A1> 180<38> 㣬<E3A3AC> Ⱦ<EFBFBD> <C8BE> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> 1<EFBFBD> <31> ʾ Բ<CABE> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> Ǵ<EFBFBD> <C7B4> <EFBFBD> 180<38> <30>
if ( fabs ( dConvexityDegree ) < = 1 )
isMinorArc = TRUE ;
else
isMinorArc = FALSE ;
//ȷ<> <C8B7> Բ<EFBFBD> <D4B2> <EFBFBD> <EFBFBD> ˳<EFBFBD> <CBB3>
if ( 0 > dConvexityDegree )
direction = 2 ;
else
direction = 3 ;
//ȷ<> <C8B7> Բ<EFBFBD> <D4B2> ------------------------------------------------------
angleChordX = acos ( ( 1 * ( dEndX - dStarX ) + 0 * ( dEndY - dStarY ) ) / dLength ) * 180 / PI ;
if ( ( dEndY - dStarY ) < 0 )
{
angleChordX * = - 1 ;
}
if ( ( angleChordX > 0 & & angleChordX < 180 ) | | angleChordX = = 180 )
{
if ( direction = = 2 ) //˳Բ
{
if ( isMinorArc )
{
dCenterX = dCenterX1 ;
dCenterY = dCenterY1 ;
}
else
{
dCenterX = dCenterX2 ;
dCenterY = dCenterY2 ;
}
}
else if ( direction = = 3 ) //<2F> <> Բ
{
if ( isMinorArc )
{
dCenterX = dCenterX2 ;
dCenterY = dCenterY2 ;
}
else
{
dCenterX = dCenterX1 ;
dCenterY = dCenterY1 ;
}
}
}
else
{
if ( direction = = 2 ) //˳Բ
{
if ( isMinorArc )
{
dCenterX = dCenterX2 ;
dCenterY = dCenterY2 ;
}
else
{
dCenterX = dCenterX1 ;
dCenterY = dCenterY1 ;
}
}
else if ( direction = = 3 ) //<2F> <> Բ
{
if ( isMinorArc )
{
dCenterX = dCenterX1 ;
dCenterY = dCenterY1 ;
}
else
{
dCenterX = dCenterX2 ;
dCenterY = dCenterY2 ;
}
}
}
}
CenterPoint . x = dCenterX ;
CenterPoint . y = dCenterY ;
return dfR ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ε<DFB6> Բ<EFBFBD> <D4B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Convexity Ϊ<CEAA> <CDB9>
void CDxfReadMgr : : CreatArcData ( Dbxy Pt1 , Dbxy Pt2 , double Convexity , vector < Dbxy > & PtVec )
{
int times = 10 ;
int OffsetTimes = 0 ;
Dbxy Offset ;
for ( int k = 0 ; k < times ; k + + )
{
if ( OffsetTimes > 0 )
{
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ,ƫ<> <C6AB> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB>
double Gap = 0.000001 ;
Pt1 . x + = Gap ;
Pt1 . y + = Gap ;
Pt2 . x + = Gap ;
Pt2 . y + = Gap ;
Offset . x + = Gap ;
Offset . y + = Gap ;
}
//<2F> <> <EFBFBD> 㻡<EFBFBD> ߵ <EFBFBD> Բ<EFBFBD> ĵ<EFBFBD> -------------------------------------
Dbxy CenterPoint ;
double R = GetCenterPtByConvexity ( Pt1 , Pt2 , Convexity , CenterPoint ) ;
if ( b_ShowArcRadius )
{
CString LogStr ;
LogStr . Format ( _T ( " [Բ<> <D4B2> <EFBFBD> 뾶ArcRadius] = [%f] " ) , R ) ;
gLogMgr - > WriteDebugLog ( LogStr ) ;
LogStr . Format ( _T ( " [CenterPoint.x] = [%f],[CenterPoint.y] = [%f] " ) , CenterPoint . x , CenterPoint . y ) ;
gLogMgr - > WriteDebugLog ( LogStr ) ;
LogStr . Format ( _T ( " [Dis1 ] = [%f] " ) , CalDistance ( Pt1 , CenterPoint ) ) ;
gLogMgr - > WriteDebugLog ( LogStr ) ;
LogStr . Format ( _T ( " [Dis2 ] = [%f] " ) , CalDistance ( Pt2 , CenterPoint ) ) ;
gLogMgr - > WriteDebugLog ( LogStr ) ;
b_ShowArcRadius = false ;
}
//<2F> <> <EFBFBD> û<EFBFBD> <C3BB> ߲<EFBFBD> <DFB2> <EFBFBD> --------------------------------------------
//<2F> <> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƕ<EFBFBD>
CCirclePar CirclePar ;
double StartAng = Cal360AngleByTwoPt ( Pt1 , CenterPoint ) ;
double EndAng = Cal360AngleByTwoPt ( Pt2 , CenterPoint ) ;
if ( StartAng < 0 )
StartAng + = 360 ;
if ( EndAng < 0 )
EndAng + = 360 ;
if ( Convexity < 0 )
{
swap ( StartAng , EndAng ) ;
}
if ( StartAng > EndAng )
EndAng + = 360 ;
CirclePar . StartAng = StartAng ;
CirclePar . EndAng = EndAng ;
CirclePar . CenterPt = CenterPoint ;
CirclePar . Radius = R ;
CirclePar . DEdgeCnt = 0 ; //<2F> <> <EFBFBD> <EFBFBD> Բ<EFBFBD> İ뾶<C4B0> Զ<EFBFBD> ѡ <EFBFBD> <D1A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
CirclePar . bMerge = false ;
CreatCircleData ( CirclePar , PtVec ) ;
if ( Convexity < 0 ) //<> <CDB9> С <EFBFBD> <D0A1> 0 Ϊ˳ʱ<CBB3> <CAB1>
{
vector < Dbxy > : : iterator iter = PtVec . begin ( ) ;
vector < Dbxy > : : iterator iter_end = PtVec . end ( ) ;
reverse ( iter , iter_end ) ;
}
if ( ! PtVec . empty ( ) )
break ;
OffsetTimes + + ;
}
#if 0
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƫ<EFBFBD> <C6AB> -----------------------------------------
CString LogStr ;
LogStr . Format ( _T ( " CreatArcData[OffsetTimes] = [%d] " ) , OffsetTimes ) ;
gLogMgr - > WriteDebugLog ( LogStr ) ;
# endif
//ƫ<> ƻ<EFBFBD> ԭ<EFBFBD> <D4AD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB>
vector < Dbxy > : : iterator iter = PtVec . begin ( ) ;
vector < Dbxy > : : iterator iter_end = PtVec . end ( ) ;
for ( ; iter ! = iter_end ; iter + + )
{
if ( OffsetTimes > 0 )
{
( * iter ) . x - = Offset . x ;
( * iter ) . y - = Offset . y ;
}
}
}
# endif
# endif