高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】a problem of decimal separator
a problem of decimal separator
a problem of decimal separator
hi,
i have some questions about decimal separator when importing:
(1) is decimal seperator always a period in dxf?
(2) when importing a file( dwg or dxf file), if the decimal separator is comma, what we should do for this case? need we do some special things for it? now when the decimal separator is comma, it cann't import correctly, some data in oddb2dpolyline are wrong, but these data are right when using odreadex to read.( the decimal separator also is comma).
regards.
in dxf file decimal separator is always point (.)
dwgdirect uses atof() and sprintf() to convert between string and double. these functions take into consideration current locale. as a result they work incorrectly for dxf if computer has locale with comma as decimal separator.
windows application can temporary alter separator in current locale while loading/writing dxf (only separator and only for this instance of application)
sergey slezkin
my code is right?
hi,
thanks for your reply.
in my code i always have changed the decimal separator to period(.) before importing a dxf file. i use the following function to do this:
tchar* g_pdecimalsep = null;
bool begindxfimportexportspecific()
{
char name[128];
cstring csenglish = _t("english");
int rtn = getlocaleinfo(locale_user_default, locale_senglanguage, name,128);
if( rtn > 0 )
{
int numchars = 0;
numchars = getlocaleinfo(locale_user_default, locale_sdecimal, g_pdecimalsep, 0);
if(numchars > 0)
{
g_pdecimalsep = new tchar[numchars];
if (g_pdecimalsep != null)
{
rtn = getlocaleinfo(locale_user_default, locale_sdecimal, g_pdecimalsep, numchars);
assert( rtn > 0 );
// decimal seperator is always a period in dxf
cstring csdecimalsep = _t(".");
rtn = setlocaleinfo( locale_user_default, locale_sdecimal, csdecimalsep );
assert( rtn > 0 );
}
else
{
assert(0);
return false;
}
}
}
return true;
} fff">
is this function right?
now even if calling this function before importing a dxf file, there still have some errors: the vertex of a oddb2dpolyline have the same position. there still have somethings else need to be attentions, for example, need add some macros into the importing project or call some functions?
quote:
originally posted by sergey slezkin
in dxf file decimal separator is always point (.)
dwgdirect uses atof() and sprintf() to convert between string and double. these functions take into consideration current locale. as a result they work incorrectly for dxf if computer has locale with comma as decimal separator.
windows application can temporary alter separator in current locale while loading/writing dxf (only separator and only for this instance of application)
does the dxf file you experimenting with has correct decimal separators (.)?
what do you mean by "the vertex of a oddb2dpolyline have the same position"?
sergey slezkin
a probleme about decimal separator
hi,
i found some files have no decimal separator and some files have the right decimal separator(.). for the files which have no decimal separator, even if i call the function begindxfimportexportspecific() mentioned in my last post to change the locale decimal separator to period before importing, the data read from these dxf files are still wrong. for the files which have the correct decimal separator(.), the importing results some are right and some are wrong.
as to "the vertex of a oddb2dpolyline have the same position", i mean that:
before running my application, i set the local decimal separator to comma, then i run my application and my application will call the begindxfimportexportspecific() function to change the locale decimal separator to period(.) before reading dxf file, and do something like this:
oddb2dpolyline ppolyline;
oddb2dvertexptr pvertex, pvertex1;
if pvertex and pvertex1 are the vertex of the ppolyline, then we will get pvertex->position() == pvertex1->position(). a case occured here is that: the right positions of pvertex and pvertex1 read by odreadex are (1.689,6.11,0) and (1.581,6.11,0), but in my application they all change to (1.0,6.0,0).fff"> i don't know what cause this error( this error occurs in the e667032x_7.dxf file contained in e667032x_7.zip). i attach these dxf files here.(becasue the "dxf" is the invalid file extension, so i change "dxf" to "txt". if you test these files, please change the "txt" file extension to "dxf". )
and if i use odamfcapp to read these dxf files, even if the decimal separator is comma, the results are still good.
quote:
originally posted by sergey slezkin
does the dxf file you experimenting with has correct decimal separators (.)?
what do you mean by "the vertex of a oddb2dpolyline have the same position"?
attached files (71.1 kb, 5 views)
(28.0 kb, 4 views)
|