高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】setclosed Does Not Work 9as Expected0
setclosed does not work (as expected)
setclosed does not work (as expected)
hi
the setclosed method on a polyline does not really do that much. the method isclosed returns always (!!) true even if i call explicitely setclosed(false). it does not matter whether the polyline is really closed (last point = first point).
code:
oddbpolylineptr pentity = ...
...
pentity->setclosed(false);
bool bclosed = pentity->isclosed();
isn't that how setclosed and isclosed are supposed to work?!?
simon
this is obviously dd bug. thanks for reporting it.
sergey slezkin
are you sure your sample code is the same as in your application? we failed to reproduce the situation. oddbpolyline::setclosed() and isclosed() work fine for us. maybe your situation is a bit different. for example oddbcurve has implementation of isclosed() which checks start and end points. but the function is virtual and if you use pointer to polyline oddbpolyline::isclosed() should be called.
sergey slezkin
quote:
originally posted by sergey slezkin
are you sure your sample code is the same as in your application? we failed to reproduce the situation. oddbpolyline::setclosed() and isclosed() work fine for us. maybe your situation is a bit different. for example oddbcurve has implementation of isclosed() which checks start and end points. but the function is virtual and if you use pointer to polyline oddbpolyline::isclosed() should be called.
i use an oddbpolyline:
code:
oddbpolylineptr pentity = oddbpolyline::createobject();
does a call to addvertex change the value of isclosed()? i call setclosed(true) first and then i add vertices. if i remember correctly then it didn't even work when i called setclosed after i added all the vertices, but i'll have to check again. fact is, that i ported some code from arx to dwgdirect and the ported code failed because setclosed did not work the same.
simon
as i know setclosed/isclosed do not worry about vertices. closed is a flag in polyline.
for example if you have polyline with 3 vertices it is rendered as 2 connected lines if closed is set to false and as a triangle if closed is set to true.
i would appreciate if you could supply more info about the difference between how it works in arx and dd.
sergey slezkin
quote:
originally posted by sergey slezkin
as i know setclosed/isclosed do not worry about vertices. closed is a flag in polyline.
for example if you have polyline with 3 vertices it is rendered as 2 connected lines if closed is set to false and as a triangle if closed is set to true.
i would appreciate if you could supply more info about the difference between how it works in arx and dd.
that's what i expected. anyway, i tried to create a simple example that exhibits the failing of setclosed(). however, i did not succeed. the application where i had the problem is a little bit more complex, so it might be something else. i'll let you know if i find out anything.
simon
isclosed, again...
hi
so i've finally stumbled across this problem again. i've created a very simple dwg with just one polyline (it's a oddbpolyline) consisting of three segments (line segment, arc segment, line segment). the isclosed flag in autocad is explicitely set to false, the polyline is not closed. when i read the dwg with dwgdirect, the isclosed method returns always true. i could attach the dwg but i think it does not matter.
i read the file with:
code:
oddbdatabaseptr pdatabase = m_svcs->readfile(name);
and iterate over all entities in the model space with
code:
oddbblocktablerecordptr pblock = pdatabase->getmodelspaceid().safeopenobject();
oddbobjectiteratorptr pentiter = pblock->newiterator();
for (; !pentiter->done(); pentiter->step())
{
oddbentityptr pent = pentiter->objectid().safeopenobject();
odsmartptr<oddbentityhandler> penthandler = pent;
penthandler->handle(pent, &handler);
}
inside the entity handler i use the following statement:
code:
void handle(oddbentity* pent, idwgentityhandler* handler) const
{
oddbpolygonmeshptr pmesh = pent; // (1)
handler->handlepolygonmesh(pmesh);
}
is there a problem with statement (1) and some virtual/non-virtual methods?
i'll try to reproduce the problem tomorrow without the protocol extension stuff.
simon
ps: i use dwgdirect 1.11 update 1
isclosed and odreadex
strange, i could not reproduce the behavior with odreadex. everything works as it should. any ideas what could be wrong in my case? i'll have to investigate further...
i've implemented the simplest possible application for reading just my simple dwg. and once again it works. i'm wondering if it has anything to do with the libraries i'm using. so far, the mt libs seem to work perfect. the version with the isclosed problems uses the md libraries. so i'll try once again with the md libraries...
ps: i'm using vc2003
i cannot reproduce the problem with simple applications. our real application uses managed c++ to read a dwg. could there be a problem related to the use of dwgdirect with managed c++? i'm just guessing, it's so strange!
well. it seems that my blind guess was correct. as soon as i use managed c++ isclosed returns always 1! i have a managed c++ dll project that just reads my test dwg and prints out, whether a polyline is closed or not. this managed c++ dll is referenced from a csharp command line app that calls the read method.
the interesting point is, that the very same code does work in pure c++, it just fails in my current (managed) setup. i post the code reading the file:
code:
oddbdatabaseptr pdatabase = svcs->readfile(filename);
oddbblocktablerecordptr pblock = pdatabase->getmodelspaceid().safeopenobject();
oddbobjectiteratorptr pentiter = pblock->newiterator();
for (; !pentiter->done(); pentiter->step())
{
oddbentityptr pent = pentiter->objectid().safeopenobject();
oddbpolylineptr ppoly = pent;
cout << " => " << ppoly->isclosed() << endl;
}
note, there are only polylines in the test dwg...
so, i really have no clue what the problem could be. some project setting, linker option, ...??? do you need more information?
any help is really appreciated!
simon
should i post my complete example project including the dwg? i really don't see how i could solve this.
please post the entire project (or mail it to ), and we will look into the problem.
|