高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】oddbviewport dump
oddbviewport dump
oddbviewport dump
i am trying to (completely) dump oddbviewport entities and i can't see how to get at the modelspace entities that are displayed in them.
i see several other threads asking this, but no answers!
i'd also like some simple guidance here. in my scenario, vectorization is not desirable, since i need to keep blocks intact.
how can one, given a viewport, iterate through the modelspace entities that should be displayed in it based on the viewport properties?
thanks,
f.
oddbviewport entity (except overall paper space viewport) displays all entities of model space except ones having layers which are frozen in the viewport. surely the entities are clipped by viewport borders, and possibly by front and back clips.
sergey slezkin
how does this occur - "oddbviewport entity (except overall paper space viewport) displays all entities of model space" ?
i am dumping entities similar to odreadex, except mine is from a layout-based approach. i iterate the layouts, opening their blocks and dumping their entities. when i get an oddbviewport entity i am calling worlddraw() on it and i see that oddbviewport::worlddraw(odgiworlddraw* pwd) gets called in oddbviewport.cpp and that calls odgisubentitytraits& traits = pwd->subentitytraits(); and pwd->geometry().polygon(4, points); ok, so traits and the rectangular border of the oddbviewport entity are handled. how does the modelspace entities that are visible in that viewport get iterated? i have attached an example that is not clipped, etc., and using the layout-based dumping, i encounted 2 oddblines for the modelspace layout as expected, then the overall viewport entity in the paperspace layout followed by the viewport entity as expected, then no more. i need to know how to get to those 2 (modelspace)oddblines in the (paperspace)viewport entity. is there a way to iterate the modelspace entities that are visible in oddbviewport entities? i'm looking for oddbviewport::getmodelentityiterator() !
alternatively, similar to odvectorizeex, is there a way to start, seek, resume, and stop the vectorization pipeline at the entity level? i need to send geometric data in "chunks "to another application, and need to be able to seek to previous locations in the dumping process. i was able to do this by changing some access levels to get at the drawables, but i was hoping you had a cleaner way as i can't get the transforms correct. i get the view via odgsdevice::viewat(), get the drawables via drawableholderarray drawables = pview->getdrawables(); drawableholder& holder = drawables[0]; and odgidrawableptr spdrawable = pview->drawableat(holder); then iterate the modelspace entities in the paperspace viewport entity via oddbblocktablerecordptr spbtr = (oddbblocktablerecordptr)spdrawable; oddbobjectiteratorptr piter = spbtr->newiterator(); for( ...!piter->done()... ) { pview->beginviewvectorization(); pview->draw(piter->entity()); pview->endviewvectorization(); } this allows me to traverse the appropriate modelspace entities and draw them one at a time. how can i transform them to have the appropriate geometry to be drawn in their corresponding oddbbviewport entity?
ugh, ok, a lot of stuff there. so there are really 3 questions on the different approaches i am using to solve 1 problem:
1) similar to odreadex, how to get an iterator of the modelspace entities for a paperspace oddbviewport entity.
2) similar to odvectorizeex, how to start, seek, resume, and stop the vectorization pipeline at the entity level?
3) similar to odvectorizeex, how to transform the modelspace entities of an odgidrawable iteration such that they fit into the appropriate paperspace viewport?
thanks so much!
attached files (21.6 kb, 1 views)
as you noticed oddbviewport::worlddraw() draws nothing but viewport borders.
for every viewport gsview is created (setupactivelayoutviews() in odvectorizeex sample.
layout block table record (drawable) is added to view created for overall paper space viewport.
model space table record (drawable) is added to views created for ms viewports.
so every ms entity is vectorized for every ms viewport.
sergey slezkin
quote:
originally posted by kdon
i am trying to (completely) dump oddbviewport entities and i can't see how to get at the modelspace entities that are displayed in them.
i see several other threads asking this, but no answers!
when i call worlddraw( ) on the oddbviewport entity i get:
...
pwd->geometry().polygon(4, points);
ok, so that means i can display the corresponding outline of the oddbviewport entity.
how i do i iterate/access the modelspace entities that are being displayed in the paperspace oddbviewport?
thanks!
how i draw my viewports is as simple as follows (i use opengl) :
1. get ms2ps transormation matrix (search forums for this).
2. draw viewport border, and setup stencil mask
3. push ms2ps matrix on the opengl stack
3. iterate through model space entities (obeying the frozen layers, if the viewport has some.)
4. pop matrix.
5. continue with my normal program.
other things to consider is the render options (wireframe, shaded) per viewport etc.etc.
i hope this helps
cheers
jason
sergey and jason, thanks for the responses!
jason's answer addresses my question 3), and was the approach i was having any success with. however, whatever transforms i applied (i did look into several forum threads) did not seem to put the coordinates for the lines (model space entities) into the same scale/location as the coordinates for the corresponding paperspace viewport. an example would be immensely helpful, please!
sergey, how about anything you could address regarding questions 1) and 2) ? those approaches appear to be easier for what i am trying to do. especially 2) ! is there a way to control the vectorization pipeline instead of having it completely dump everything?
thanks!
to get the ms2ps, is as follows :
void dd_ms2ps( oddbviewportptr pvp, odgematrix3d &resultmat) {
// first get all the data
odgevector3d viewdirection = pvp->viewdirection();
odgepoint2d centre2d = pvp->viewcenter();
odgepoint3d viewcenter = odgepoint3d( centre2d.x, centre2d.y, 0);
odgepoint3d viewtarget = pvp->viewtarget ();
double twistangle = -pvp->twistangle();
odgepoint3d centerpoint = pvp->centerpoint();
double viewheight = pvp->viewheight();
double height = pvp->height();
double width = pvp->width();
double scaling = viewheight / height;
double lenslength = pvp->lenslength();
// prepare the transformation
odgevector3d xaxis, yaxis, zaxis;
zaxis = viewdirection.normal();
xaxis = odgevector3d::kzaxis.crossproduct( viewdirection );
if( !xaxis.iszerolength() ) {
xaxis.normalize();
yaxis = zaxis.crossproduct( xaxis );
} else if( zaxis.z < 0 ) {
xaxis = -odgevector3d::kxaxis;
yaxis = odgevector3d::kyaxis;
zaxis = -odgevector3d::kzaxis;
} else {
xaxis = odgevector3d::kxaxis;
yaxis = odgevector3d::kyaxis;
zaxis = odgevector3d::kzaxis;
}
odgematrix3d dcs2wcs; // display coordinate system (dcs) to world coordinate system (wcs)
odgematrix3d ps2dcs; // paperspace to dcs
// first initialise with a transformation to centerpoint
ps2dcs = odgematrix3d::translation( odgepoint3d::korigin - centerpoint );
// then scale for the view
//ch_101102 viewcenter was placed by me; previous was centerpoint. and didn't work at all
ps2dcs = ps2dcs * odgematrix3d::scaling( scaling, centerpoint/*viewcenter*/ );
// then adjust to the viewcenter
dcs2wcs = odgematrix3d::translation( viewcenter - odgepoint3d::korigin );
// then transform for the view direction
odgematrix3d matcoords;
matcoords.setcoordsystem( odgepoint3d::korigin, xaxis, yaxis, zaxis);
dcs2wcs = matcoords * dcs2wcs;
// then adjust for the viewtarget
dcs2wcs = odgematrix3d::translation( viewtarget - odgepoint3d::korigin ) * dcs2wcs;
// then the twist angle
dcs2wcs = odgematrix3d::rotation(twistangle, zaxis, viewtarget ) * dcs2wcs;
odgematrix3d perspmat;
if( pvp->isperspectiveon()) {
// we do special perspective handling
double viewsize = viewheight;
double aspectratio = width / height;
double adjustfactor = 1.0 / 42.0;
double adjustedlenslength = viewsize * lenslength * sqrt ( 1.0 +
aspectratio * aspectratio ) * adjustfactor;
double eyedistance = viewdirection.length();
double lensdistance = eyedistance - adjustedlenslength;
double ed = eyedistance;
double ll = adjustedlenslength;
double l = lensdistance;
perspmat.entry[2][2] = (ll - l ) / ll;
perspmat.entry[2][3] = l * ( ed - ll ) / ll;
perspmat.entry[3][2] = -1.0 / ll;
perspmat.entry[3][3] = ed / ll;
}
resultmat = ps2dcs.inverse() * perspmat * dcs2wcs.inverse();
}
then simply use this matrix to transform all co-ordinates from model space.
also, be carefull of the alignment of opengl matrices and opendwg matrices, i think i had to re-arrange the ordering of the array of doubles to ensure opengl got a correct matrix, other than that, all works great.
also, another option is to look at the vectorization example, this would be an easier solution than manually having to go through the model space yourself, i do this because of other requirements, and if i did not have too, i wouldn't be doing it the "hard" way.
anyway, i hope this helps
cheers
jason
quote:
originally posted by kdon
sergey and jason, thanks for the responses!
jason's answer addresses my question 3), and was the approach i was having any success with. however, whatever transforms i applied (i did look into several forum threads) did not seem to put the coordinates for the lines (model space entities) into the same scale/location as the coordinates for the corresponding paperspace viewport. an example would be immensely helpful, please!
sergey, how about anything you could address regarding questions 1) and 2) ? those approaches appear to be easier for what i am trying to do. especially 2) ! is there a way to control the vectorization pipeline instead of having it completely dump everything?
thanks!
vectorization can be stopped if regenabort() overridden in your odgicommondraw derived class return true.
where is no way for "pause" and "resume".
sergey slezkin
|