几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】explode problem in latest version 91.0.14.10 (http://www.dimcax.com/hust/showthread.php?t=16176)

yang686526 2009-05-05 10:09 AM

【转帖】explode problem in latest version 91.0.14.10
 
explode problem in latest version (1.0.14.1)
explode problem in latest version (1.0.14.1)
i am trying to explode all entities of type region, proxy, and insert. i have a problem on the given file (1.dwg) with the latest version.
the same code was ok with version 1.0.13 but i am probably doing something bad. the crash occurs in the destructor of odrxobjectptrarray (variable exploded_entities), in my function explodeallentitiesofblock.
do you have any ideas ? thanks
renaud
code:
bool flatten(oddbentityptr & entity)
{
if ((entity->iskindof(oddbregion::desc()) ||
(entity->iskindof(oddbproxyentity::desc()) ||
(entity->iskindof(oddbminsertblock::desc()) ||
(entity->iskindof(oddbblockreference::desc()))) return true;
return false;
}
void insertexplodedentities(odrxobjectptrarray & input,
oddbblocktablerecordptr & block)
{
odrxobjectptrarray to_explode(input);
while (!to_explode.empty()) {
odrxobjectptrarray exploded_entities;
odrxobjectptrarray::iterator it = (to_explode.begin());
while (it != to_explode.end()) {
oddbentityptr entity(*it);
if (flatten(entity)) {
odrxobjectptrarray array;
entity->explode(array);
exploded_entities.append(array);
}
else {
block->appendoddbentity(entity.get());
}
it++;
}
to_explode = exploded_entities;
};
}
void explodeallentitiesofblock(oddbblocktablerecordptr & block)
{
oddbobjectiteratorptr entity_it(block->newiterator());
{
odrxobjectptrarray exploded_entities;
while (!entity_it->done()) {
oddbentityptr entity(entity_it->entity());
if (flatten(entity)) {
odrxobjectptrarray array;
entity->explode(array);
exploded_entities.append(array);
//entity->erase();
}
entity_it->step();
};
insertexplodedentities(exploded_entities, block);
std::cout << "before crash";
}
std::cout << "after crash";
}
void explodeallentities(oddbblocktableptr & blocks)
{
oddbsymboltableiteratorptr block_it(blocks->newiterator());
while (!block_it->done()) {
oddbblocktablerecordptr
block(block_it->getrecordid().safeopenobject(oddb::kforwrite));
explodeallentitiesofblock(block);
block_it->step();
}
}
you forgot to attach the file.
sergey slezkin
the attached file
here is the attached file.
in fact i do something like
code:
odrxobjectptrarray exploded_array;
entity->explode(exploded_array);
...
while (it != explode_array.end()) {
oddbentityptr entity(*it);
block->appendoddbentity(entity.get());
}
but isn't the entity.get() a problem ? since when the exploded_array will be deleted .. this will delete the entity appended in the block ?
thanks renaud
attached files (96.5 kb, 3 views)

i can't reproduce the crash. i see 2 asserts while recomputing dimension blocks but no crash.
btw, i get exception if erase() call is uncommented because the entity is opened for read only.
sergey slezkin


所有的时间均为北京时间。 现在的时间是 05:44 PM.