查看单个帖子
旧 2009-05-06, 06:02 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】modifying hatch loops

modifying hatch loops
modifying hatch loops
my application needs to modify (i.e. change coordinates) of hatch loops. at this stage of development, using dwgdirect 2.1.0, testing with an r14 dwg file. hatch objects have a single loop of the "external" type, i.e. an edge array of odgelineseg2d objects.
i am able to extract the loop fine, but i get a memory exception (presumably from the placement new operator inside the edgearray object) when i try to replace the modified edge.
as there is no setloop or replaceloop member function, i have tried removing the loop and then inserting the modified loop using the same index value (zero since there is only one loop). i have also tried removing the loop and then appending the modified loop (which should work in this limited case as there isonly one loop).
in both of the above cases, i get the above mentioned memory exception error. appears to be coming from the odarray code while attempting to creat a new edge object.
is this a problem? is there is a better way to simply replace an existing loop with a modified loop? my need is simply to modify the coordinates in the loop; i have absolutely no desire to alter the form or structure of the loop in any way; nor do i want to try to figure out the form or structure(s) of the loops. all i need to do, for example, is convert the units of the coordinates in the loop definition.
thanks in advance for your help.
norm olsen
ps> code segment:
else if (looptype & oddbhatch::kexternal)
{
edgearray edges;
object.getloopat (idx,edges);
for (size_t jj = 0;ok && jj < edges.length ();jj += 1)
{
odgecurve2d* edgeptr = edges.at (jj);
ok = convert (edgeptr,cnvrsnstatus,conversiontype);
}
if (ok)
{
object.removeloopat (idx);
object.appendloop (looptype,edges);
}
ok = true;
}
with the conversion loop completely commented out, i still get the memory exception described above.l
last edited by olsennt; 25th october 2006 at 11:59 amfff">.
more information
the attached screen shots show where the problem is ocurring.
attached images (24.8 kb, 20 views)
(166.0 kb, 13 views)
(23.5 kb, 12 views)
(166.1 kb, 12 views)

help!!!
project is all done. need a resolution to the hatch loop problem. my guess is a problem in the "edge" assignment operator. maybe its me!!! please let me know.
thanks.
hatch loop owns its boundary objects. edges returned by getloopat become invalid when you remove the loop.
you should make the copy of the edges before removing the loop, or just modify the edges in-place.
after geometry modification call evaluatehatch()
vladimir
. . . or just modify the edges in-place.
thanks for your response. i was removing loops as the only way i saw to put loop data back in is either "insertloopat" or "appendloop". modify in place is exactly what i want to do.
how to do that is not obvious given the documentation. i'm still missing something.
how does one "modify the edges in place" ? is it that the pointers in the edgearray are non-const pointers to the internal odgecurve2d's?
how does one "modify vertices and bulges in place" ?
i still don't see how you modify vertices and bulges in place. the "getloopat" function will return the vertices and bulges; but how do i put them back after i modify them? i don't see anyway to access them "in place".
is it that the pointers in the edgearray are non-const pointers to the internal odgecurve2d's?
exactly.
vladimir
how does one modify vertices and bulges; in place or otherwise?
that is - you did try it and it does not work?
vladimir
thanks for your help, but clearly i'm still missing something.
per the api documentation:
"should be called with edgeptrs if the loop is not a polyline loop, and with vertices and bulges if it is."
the api documentation leads me to believe that a loop can be one of two types: oddbhatch::kpolyline or oddbhatch::kexternal. the code i have written with your help for the kexternal case works fine. however, the above mentioned quote from the aspi documentation suggests that if the loop is of the kpolyline type, i need to call:
oddbhatch::getloopat (int loopindex,odgepoint2darray& vertices,
odgedoublearray& bulges) const
if i do so and subsequently modify the vertices, how do i get the modified vertices back into the hatch loop. that is my question. since the arguments are references, not pointer, i don't see how i can modify them in place. please forgive me if i'm not seeing the obvious.
i suspect that i'm missing something, or misinterpreting the api documentation. just like to be confident that the application i am developing will perform as well as i can make it.
thanks for your patience.
the second variant of 'getloopat' returns the references to the actual arrays of bulges and vertices stored in polyline - that is they may be modified in place. that is a good way to shoot in one's foot, but it is much more effective, than copying the data, removing the loop and inserting a new one.
the documentation is not quite usable, but we are working at it. (well, i'm not sure that such dangerous details should be documented - it is a lot safer to clone the edge data, and modify the hatch with the copy (remove/add loop))
vladimir
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)