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