named view extents
named view extents
i am trying to get the extents of a named view but i must be doing something wrong. the extents value i get (in "boundblock" below) is 0.,0. for both max and min.
i am using the following code:
code:
oddbobjectid tablid = pdb->getviewtableid();
oddbviewtableptr tablptr = tablid.safeopenobject();
oddbsymboltableiteratorptr iter = tablptr->newiterator();
int i = 0;
for (iter->start(); !iter->done(); iter->step() )
{
oddbviewtablerecordptr pnamedview = iter->getrecordid().openobject();
if (stricmp(pnamedview->getname(), viewname) == 0)
{
cout << "view: "<< viewname << " ** selected **" << endl;
odabstractviewpeptr pnamedviewpe(pnamedview);
oddbobjectid ltid = oddbblocktablerecordptr(pdb->getactivelayoutbtrid().safeopenobject())->getlayoutid();
oddblayoutptr playout = ltid.safeopenobject();
oddbobjectid overallvpid = playout->overallvportid(); // for paper space
oddbviewporttableptr pvptabl = pdb->getviewporttableid().safeopenobject();
oddbobjectid id = pvptabl->getactiveviewportid();
if (id)
{
oddbviewporttablerecordptr prec = id.safeopenobject();
pnamedviewpe->setview(prec, pnamedview);
odgeboundblock3d boundblock;
pnamedviewpe->viewextents(pnamedview, boundblock);
}
}
}
named view extents
i still have not been able to figure out the extents of a named view. i must be missing something obvious. i could really use some help. thanks.
hi,
in current implememntation oddbviewtablerecord:

dabstractviewpe::viewextents () does nothing. but as you copy view to a viewport you may call last one's viewextents():
code:
oddbobjectid tablid = pdb->getviewtableid();
oddbviewtableptr tablptr = tablid.safeopenobject();
oddbsymboltableiteratorptr iter = tablptr->newiterator();
int i = 0;
for (iter->start(); !iter->done(); iter->step() )
{
oddbviewtablerecordptr pnamedview = iter->getrecordid().openobject();
if (pnamedview->getname()==viewname)
{
cout << "view: "<< viewname << " ** selected **" << endl;
oddbobjectid ltid = oddbblocktablerecordptr(pdb->getactivelayoutbtrid().safeopenobject())->getlayoutid();
oddblayoutptr playout = ltid.safeopenobject();
oddbobjectid overallvpid = playout->overallvportid(); // for paper space
oddbviewporttableptr pvptabl = pdb->getviewporttableid().safeopenobject();
oddbobjectid id = pvptabl->getactiveviewportid();
if (id)
{
oddbviewporttablerecordptr prec = id.safeopenobject(oddb::kforwrite);
odabstractviewpeptr pvppe(prec);
pvppe->setview(prec, pnamedview);
odgeboundblock3d boundblock;
pvppe->viewextents(prec, boundblock);
}
}
}
that does not seem to work for me. i get the height to width ratio of the full modelspace view, not that of a given named view. for instance, in the attached file i get a height to width ratio for the named view "frt" of about 1:2 (97 to 190) while it should be about 2:3 (about 12 high to 17 wide).
it appears that setview is being ignored for getting the extents.
here is the code i am currenlty using:
oddbviewporttableptr pvptabl = pdb->getviewporttableid().safeopenobject();
oddbobjectid id = pvptabl->getactiveviewportid();
if (id)
{
oddbviewporttablerecordptr prec = id.safeopenobject(oddb::kforwrite);
odabstractviewpeptr pvppe(prec);
pvppe->setview(prec, pnamedview);
odgeboundblock3d boundblock;
bool bvalid = pvppe->viewextents(prec, boundblock);
odgepoint3d bbmin = boundblock.minpoint ();
odgepoint3d bbmax = boundblock.maxpoint ();
}
attached files (52.5 kb, 2 views)
hi,
>>it appears that setview is being ignored for getting the extents.
viewextents() returns extents of space block viewed in giving view in eye coordinates of giving view. the result depends on view target, direction and up vector. but 1st of all extents depend on geometry drawn in this view.
what results do you want to achieve ?
last edited by dmitry a. novikov; 26th july 2005 at 11:25 pmfff">.
quote:
originally posted by dmitry a. novikov
hi,
>>it appears that setview is being ignored for getting the extents.
viewextents() returns extents of space block viewed in giving view in eye coordinates of giving view. the result depends on view target, direction and up vector. but 1st of all extents depend on geometry drawn in this view.
what results do you want to achieve ?
i need to know the coordinates (in whatever coordinate system i can get them in) of the limits of the named view. i need to know the lower left corner of the named view is at (x1,y1) and the upper right corner of the named view is at (x2,y2). i need to clip the geometry to the limits of the named view, but i can't do that without knowing those limits. i do not need to know the extents of the geometry within the view, but rather the size of the view itself (including the geometry and any white space that is in the view). that is obviously available somewhere since it will center the display around the named view. i just need to convert the drawing and not have anything that is outside the named view displayed.
hi,
in common case view defines a frustum (perspective case) or prism (parallel case).
here is how to calculate view rectangle (profile of view frustum or prism) in wcs:
code:
odgepoint3d target = pvppe->target(pview);
double fw2 = pvppe->fieldwidth(pview) / 2.;
double fh2 = pvppe->fieldheight(pview) / 2.;
odgevector3d z = pvppe->direction(pview);
odgevector3d y = pvppe->upvector(pview);
odgevector3d x = y.crossproduct(z);
odgepoint3d lowerleft = target - x * fw2 - y * fh2;
odgepoint3d upperleft = target - x * fw2 + y * fh2;
odgepoint3d upperright = target + x * fw2 + y * fh2;
odgepoint3d lowerright = target + x * fw2 - y * fh2;
in eye cs it's always planar and calculated as following:
code:
odgepoint3d lowerlefteye(-fw2, -fh2, 0.);
odgepoint3d upperrighteye(fw2, fh2, 0.);
// where:
// lowerlefteye == pvppe->worldtoeye(pview) * lowerleft;
// upperrighteye == pvppe->worldtoeye(pview) * upperright;