高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】getgeomextents
getgeomextents???
getgeomextents???
hi everyone,
can anyone help me?
i tried to get the real boundary box of the data in a dwg and failed:
1. i called it for the whole database and it returned the usual invalid box
2. i tried it with the model space block table record with the same result
3. i tried it all the way entity by entity (recursively about block references) and still nothing useful!!!
now either i just don't know about something i have to call before calling getgeomextents (); or it doesn't work as expected.
hello,
i just have to say that i have also problems with getgeomextents.
i guess there is some error in the implementation of this function that was not there in the older versions of dwgdirect.
for example, i have a drawing containing about 800 polylines.
if i use version 1.04 to examine the extents of these lines, all of them are valid.
if i do the same with ver. 1.08 or 1.09, about 400 of the polylines return invalid extents.
wolfgang
i used the odreadex example and called
odgeextents3d extents;
odresult res = pent->getgeomextents(extents);
on all items with expected results. can you send me this drawing with invalid extents on the polylines?
hi walt,
i refined my original algorithm into this:
bool getextent (odgeextents3d& c_extents,
oddbblocktablerecordptr& pblock,
odstring indent)
{
if (pblock.isnull ())
return (false);
printf ("%smeasure block %s\n",
(const char*) indent,
(const char*) (pblock->getname ()));
odstring l_indent = indent + " ";
// for each entity in the block
oddbobjectiteratorptr it = pblock->newiterator();
for (; !it->done(); it->step()) {
oddbentityptr e = it->entity (oddb::kforread);
odgeextents3d extents;
if (!e.isnull ()) {
if (e->iskindof (oddbblockreference::desc ())) {
oddbblockreferenceptr pinsert = e;
oddbblocktablerecordptr pblk =
pinsert->blocktablerecord ().safeopenobject ();
if (!pblk.isnull ()) {
odgeextents3d blkextents; // maybe 'extents' could be used
// directly instead of it...
if (getextent (blkextents, pblk, l_indent)) {
blkextents.transformby (pinsert->blocktransform ());
extents = blkextents;
printf ("%sentity %s: extents (%lf, %lf) - (%lf, %lf)\n",
(const char*) l_indent,
e->isa ()->name (),
extents.minpoint ().x, extents.minpoint ().y,
extents.maxpoint ().x, extents.maxpoint ().y);
}
}
} else {
e->getgeomextents (extents);
}
if (extents.isvalidextents ()) // ***
c_extents.addext (extents);
}
}
return (c_extents.isvalidextents ());
}
and now it gave me a realistic result (the refining meant the part marked with the asterisks). but i don't see why an oddbblocktablerecord can't do it instead of returning an invalid extent box. it could even be applied to an oddbdatabase...it is slow but we users will recognize this problem when we see it.
actually i tried it with the model space of campus.dwg in the autocad 2000 samples. it worked on polylines too - but i don't know whether walter's polylines are a different kind with a faulty algorithm... and other entity types may benefit from re-checking as well.
sorry, wolfgang, i failed to remember your name in the previous reply (i wrote walter instead...)
tibor
|