几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】3d to 2d vectorization (http://www.dimcax.com/hust/showthread.php?t=14932)

yang686526 2009-05-04 03:03 PM

【转帖】3d to 2d vectorization
 
3d to 2d vectorization
3d to 2d vectorization
i need some help on the below issues. hope someone can provide some pointers
1. how are coordinates mapped in vectorization framework. using the odreadex project, i get the same coordinate values as drawn in autocad(wcs). but in vectorization to screen coordinates, why do i get the z coordinate values??. i think the exsimpleview::update() function in the odvectorizeex example is the one i need to understand. i understand the terminology of eye,screen and world coordinates, but cannot relate them from the example...
i drew two 3d polyline in autocad in "top-view" mode and here are the results after importing them via odreadex and odvectorizeex( screensize(100,100)).
polyline 1:
odreadex odvectorizeex
10,10,0 (29.098950, 29.098950, -26.846938)
20,20,0 (43.032983, 43.032983, -26.846938)
40,40,0 (70.901050, 70.901050, -26.846938)
polyline2:
odreadex odvectorizeex
10,10,10 (32.677148, 18.258780, 13.506119)
20,20,20 (33.779837, 27.232734, 13.206939)
40,40,40 (35.985214, 45.180644, 12.608578)
i do not know how to interpret the z-values here.
since my app is a 2d app, can i ignore the z-values after this transformation by vectorization??

please respond.
tia.
many applications ignore z values... however if you do you are making the assumption that everything is going to be drawn from a given perspective. if your users bring in autocad drawings that don't conform to your standard (say positive z is into the drawing instead of out of it) you can get renderings that won't look like autocad. i've seen arcs that curve the wrong direction that position wise are fine...all due to the entity normal that wasn't drawn according to the "standard" imposed by the developer.

i have a question to this topic:
is in a dwg file something like a flag, that indicates that it is 3d or 2d ?

no, there is no such flag in dwg files.
sincerely yours,
george udov
in continuation of the above discussion,
when is the z parameter relevant in vectorization in 2d coordinates?
is it only in case of circulararcproc(), circleproc() and ellipsearcproc() ??
in the above 3 cases, is the eye2screen matrix in the function exsimpleview::update() applied to all parameters(link normal, radius etc.)??
tia

once more.
z-coordinate is always relevant in vectorization.
but if you vectorize to 2d device, you must project result geometry to xy plane (just like our svg and dwf exports). for linear primitives (polylines, triangles) projecting to xy plane is equal ignoring z coordinate. for other primitives projection is a bit more sophisticated operation.
sincerely yours,
george udov
mine is also a 2d application. during vectorization i want all entities to be projected into a bounding rectangle on my device.
this works for me in case the view is non-perspective if i just specify my required box in the onsize() method of my device.
however when the view is perspective, the entities sometimes overflow the bounds.
i am simply ignoring the z-values and working with only x and y values.
how can i handle the case of perspective correctly?
regards,
varun
someone help!
regards,
varun
dear varunsnair,
for what it is worth, if you are using opengl, you can use stenciling, this is how i achieve the result. direct3d would have some equivilant.
the only other alternative you have is to clip the geometry yourself, or i think the vectorization frame of opendwg does this for you anyway.
i chose the stenciling method, as this allows me to "view" the geometry through a "viewport". i can also zoom the viewport in and out etc.. this works really nice.
anyhow, i hope these suggestions help
cheers
jason
thanks jason.
unfortunately, i am not using opengl or any other library having math routines except dwgdirect. our rendering engine is 2d and also also does not has the required support. the entire interpretation of the coordinates, outside the vectorization support of dwgdirect, has to be done by hand by us.
with the older opendwg library we were simply dropping the perspective view and hence everything worked fine. but now we want to map the perspective view too with the help of vectorization.
and it looks good too, except that the functionality we seek (fit into the bounds that we define) does not work with perspective view.
can anyone from dd help?
regards,
varun
are you sure your rendering engine does not have equivilant, ie if it is using windows gdi, you could use region. i would of thought pretty much any gdi interface would support this type of image clipping as standard.
anyhow to me it looks like you are down to good old clipping. (the manual way unless the people in opendwg have some magic i dont know about. :-) )
oh well, good luck in finding a way.
cheers
jason
i do have support for clipping. however my problem is a bit different, i am struck at 3d to 2d transformation with only a 2d coordinate space to work in. let me try and explain a bit more clearly.
say i have an area setup in my application of (0, 0, 100, 100). to get all the entities in the modelspace to fit into this area, i call zoomextents() on a viewport of the modelspace and vectorize with (0, 0, 100, 100) specified in onsize(). this works well in non-perspective case, when all x and y coordinates outputted by the vectorizor honor these bounds and i just ignore the z values.
but in case of perspective, the x and y bounds are not honored. i need a way to squeeze all entities into the bounds, while also maintaining the relative appearance of the objects. i don't want anything to be clipped off.
one roundaround and inefficient way to acheive this would be to import everything as explained above, and in case of perspective, get the bounds of the entities in my app and resize to fit the required bounds. but this would fail in case when infinite and semi-infinite lines are present in the drawing, in which case i do want these entities to go beyond the bounds. again, excluding these specific entities while calculating the actual bounds comes to mind, but i think this is not a very elegant solution. there must a better mathematical way to do this.
regards,
varun
ok, i understand now, and i dont know of a solution to this. i would think a little more about what you are trying to do, becuase lets say for example you have a house, and with now perspective it looks great, however, if you apply a very heavy perspective to the house, you can create a massive kind of tunnel effect, and hence you would have a very small door but a 1000 fold larger house, and if you cram this into a view port of 0,0,100,100, the door could be the size of a dot, while the house takes up the entire viewport. i have some very good examples of drawings like this. this to me is not a really elegant solution, but i will let you decide that .
anyhow good luck in finding a solution to your problem
cheers
jason


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