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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-07, 06:25 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】vectorizeex And Viewports

vectorizeex and viewports
vectorizeex and viewports
hi,
is there a way to change the vectorizeex example so that all entities are listed in paperspace coordinates?
right now, the vertices of a viewport are printed out in paperspace coords, the entities shown by this viewport are printed out in their modelspace coords.
help is highly appreciated.
torsten
hi,
yes, there is.
>>right now, the vertices of a viewport are printed out in paperspace coords, the entities shown by this viewport are printed out in their modelspace coords
it's not correct, vertices of overall viewport are printed out in paperspace view's eye coordsfff">, the entities shown by model viewport are printed out in modelspace view's eyefff"> coords.
the odgsbasevectorizeview initialy generates geometry in eye coordinates and has seteyetooutputtransform() method to specify additional transform for output geometry. so it's just necessary to call this method in exsimpleview::update() passing in appropriate matrix prior to calling odgsbasevectorizeview::update().
code:
// how to obtain matrix:
// for overall (ps) view:
odgematrix3d x2paperspace = poveralview->geteyetoworldtransform();
poveralview->seteyetooutputtransform(x2paperspace);
// for model view:
odgematrix3d xmodel2paperspace =
poveralview->eyetoscreenmatrix().inverse() *
pmodelview->eyetoscreenmatrix();
pmodelview->seteyetooutputtransform(xmodel2paperspace);
// how to obtain poveralview:
odgslayouthelperptr playouthelper = oddbgsmanager::setupactivelayoutviews(...);
odgspaperlayouthelperptr ppaperhelper =
odgspaperlayouthelper::cast(playouthelper);
odgsviewptr poveralview;
if(ppaperhelper.get()) // paper space is active
{
poveralview = pdevicewrapper->overallview();
}
else
{
// no overall view; all views are independent
}
last edited by dmitry a. novikov; 23rd august 2004 at 09:04 amfff">.
dimitri,
i had the same issue, and this might be an obvious , but i seem to be missing something, and i couldnt figure out much from your answer.
pdevicewrapper in this case would be exgssimpledevice which does nto have a overallview() function
ppaperhelper has an overallview defined, ocne i get the overall view
poveralview has no geteyetoworldtransform() defined
could you please help me with further guidance
thanks in advance
regards
krishna
quote:
originally posted by dmitry a. novikov
hi,
yes, there is.
>>right now, the vertices of a viewport are printed out in paperspace coords, the entities shown by this viewport are printed out in their modelspace coords
it's not correct, vertices of overall viewport are printed out in paperspace view's eye coordsfff">, the entities shown by model viewport are printed out in modelspace view's eyefff"> coords.
the odgsbasevectorizeview initialy generates geometry in eye coordinates and has seteyetooutputtransform() method to specify additional transform for output geometry. so it's just necessary to call this method in exsimpleview::update() passing in appropriate matrix prior to calling odgsbasevectorizeview::update().
code:
// how to obtain matrix:
// for overall (ps) view:
odgematrix3d x2paperspace = poveralview->geteyetoworldtransform();
poveralview->seteyetooutputtransform(x2paperspace);
// for model view:
odgematrix3d xmodel2paperspace =
poveralview->eyetoscreenmatrix().inverse() *
pmodelview->eyetoscreenmatrix();
pmodelview->seteyetooutputtransform(xmodel2paperspace);
// how to obtain poveralview:
odgslayouthelperptr playouthelper = oddbgsmanager::setupactivelayoutviews(...);
odgspaperlayouthelperptr ppaperhelper =
odgspaperlayouthelper::cast(playouthelper);
odgsviewptr poveralview;
if(ppaperhelper.get()) // paper space is active
{
poveralview = pdevicewrapper->overallview();
}
else
{
// no overall view; all views are independent
}
hi dmitry,
thanks for your reply.
it's not correct, vertices of overall viewport are printed out in paperspace view's eye coordsfff">, the entities shown by
model viewport are printed out in modelspace view's eyefff"> coords.
you're right, the original example had the output in eye coords. i changed that some time ago to modelspace coords ( geteyetoworldtransform() in the function void exsimpleview::update() ) and forgot the initial code - sorry for the confusion.
but i still have a question to this problem:
> // for model view:
> odgematrix3d xmodel2paperspace = poveralview->eyetoscreenmatrix().inverse() * pmodelview->eyetoscreenmatrix();
> pmodelview->seteyetooutputtransform(xmodel2paperspace);
which class is poveralview and how do i obtain it in exsimpleview::update()? i did some testing/reseach, but i couldn't find anything useful.
torsten
hi torsten,
odgslayouthelperptr oddbgsmanager::setupactivelayoutviews(odgsdevice* pdevice, odgicontextfordbdatabase* pgictx);
returns a odgsdevice based wrapper of passed in odgsdevice pointer. the wrapper can be casted to either odgspaperlayouthelper or odgsmodellayouthelper. overallview() is a method of odgspaperlayouthelper interface (see dbgsmanager.h).
last edited by dmitry a. novikov; 10th august 2006 at 05:38 amfff">.
hi dmitry,
thanks for your reply. unfortunately i made a mistake in my last reply: what i really was looking for is pmodelview (sorry for the mixup). can you tell me how to obtain this value?
another question concerning this problem:
in the sample code you wrote how to obtain and how to use poveralview. is this necessary? in the function exsimpleview::update() the commands seteyetooutputtransform(...) and eyetoscreenmatrix() can be called without poveralview, so i thought it's all already in the class exsimpleview. am i right, or is this something different?
torsten
if a view pointer is not equal to overall view pointer (poveralview) then it is a model view.
'poveralview' is necessary to calculate model to paper transform because model viewports "inherit" paper view transform.
hi dmitry,
i am not certain whether i fully understood your code. below is how i implemented the code in the example:
odvectorizeex.cpp
code:
odgsviewptr poveralview;
int main(int argc, char* argv[])
{
....
// prepare the device to render the active layout in this database.
pdevice = oddbgsmanager::setupactivelayoutviews(pdevice, pdwgcontext);
odgspaperlayouthelperptr ppaperhelper = odgspaperlayouthelper::cast( pdevice );
if( ppaperhelper.get() ) // paper space is active
{
poveralview = ppaperhelper->overallview();
}
else
{
poveralview = null;
}
// set the screen size for the generated geometry.
....
}
exgssimpledevice.cpp
code:
void exsimpleview::update()
{
device()->setdrawcontext(drawcontext());

// new code
odgematrix3d xmodel2paperspace = poveralview->eyetoscreenmatrix().inverse() * eyetoscreenmatrix();
seteyetooutputtransform( xmodel2paperspace );
// perform viewport clipping in eye coordinates:
...
} // end exsimpleview::update()
when compiling this i get the error message: 'eyetoscreenmatrix' : is not a member of 'odgsview'
can you tell me what's going wrong?
torsten
eyetoscreenmatrix() is a member of odgsbasevectorizeview which is an implementation of odgsview whose pointer you obtained correctly. you should use equivalent transform (poveralview->screenmatrix() * poveralview->projectionmatrix()).
hi dmitry,
right now the example compiles, but the result is not what i expected.
as test file i am using a dwg which contains a line from 100/100 to 200/150 (modelspace coords). the file was saved in paperspace mode with one viewport (29/19 - 257/176 in paperspace coords). the line is in paperspace coords from 30/41 to 256/154.
using the command "seteyetooutputtransform( geteyetoworldtransform() )" in exsimpleview::update() i received the coorect paperspace coords for the viewport, but the line was in modelspace coords.
with the modified code the coords of the line are from 34/42 to 65/57. the coords of the viewport are from 14/25 to 85/74. what's wrong with my code? is there a scale factor i have to use??
torsten

hi dmitry,
i found it (due to your help)!!!
my function exsimpleview::update() now looks like this:
code:
void exsimpleview::update()
{
device()->setdrawcontext(drawcontext());
odgematrix3d xmodel2paperspace =
poveralview->objecttodevicematrix().inverse() *
objecttodevicematrix() * geteyetoworldtransform();
seteyetooutputtransform( xmodel2paperspace );
...
}
all elements of a dwg file saved in paperspace mode now are drawn in paperspace coords.
just one thing: i noticed that modelspace elements which were clipped by a viewport may have coords that are outside the viewport (<1.0mm). is there an accuracy factor which will prevent this?
torsten

well, today seems to be my lucky day. the accuracy factor is the screen size set in the main function
code:
// set the screen size for the generated geometry.
odgsdcrect screenrect(odgsdcpoint(0, 0), odgsdcpoint(100000, 100000));
pdevice->onsize(screenrect);
originally, the second point was 100/100. after i increased it, i got much better results.
is there a recommendation for these values? for example i could imagine that very high values could result in a slow performence. and what about negative values for the first point?
torsten
hi torsten,
viewport alignment to integer screen coordinates is a limitation of gs interface -- as you see odgsdevice:nsize() and odsgview::setviewport() take integers as parameters. then these values used for calculating objecttodevicematrix().
these values define target resolution. default tessellation uses half of pixel size in wcs as deviation. linetype processing uses pixel size to decide if dash density is too much and it's not needed to apply linetype. so it's optimal to use target resolution to calculate image size in pixels e.g. if you want get 8x11 inches hardcopy with 800dpi you should set viewport size 8*800x11*800 = 6400x8800 and viewport border accuracy will be 1 dot = 1/800 of inch = 0.03175mm on final picture.
dmitry.
>>and what about negative values for the first point?
they could be whatever you want.
thanks for that information and your help. i will use the papersize to adjust the values.
torsten
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】rendering Viewports With Shade On yang686526 DirectDWG 0 2009-05-07 03:02 PM
【转帖】rendering Polygonal Paperspace Viewports yang686526 DirectDWG 0 2009-05-07 02:59 PM
【转帖】rendering Paperspace Viewports yang686526 DirectDWG 0 2009-05-07 02:58 PM
【转帖】problem with erasing paperspace viewports yang686526 DirectDWG 0 2009-05-06 11:16 PM
【转帖】paperspace with multiple viewports using odvectorizee yang686526 DirectDWG 0 2009-05-06 09:40 PM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多