drawing with extreme coordinates - zoom extent error i odamf
drawing with extreme coordinates - zoom extent error i odamfcapp
please find attached a dwg file containing objects with extreme coordinates.
extmax is defined as
$extmax
10
535049.1146723913
20
114001.0567647243
30
1.127356102486858e+99
this is most likely due to a problem in an application inserting objects in
the drawing. however, autocad accepts the values, but opendwg does
not. normal pan and zoom in/out works fine, but zoom extents fail in odamfcapp (also in 112_04).
i have tried to modify my own zoom extents function, but the problem seems to infect all coordinate transformation functions.
best regards,
dag barosen
attached files
the problem is really caused by huge z extents. in dwg file they are abour e+174.
(autocad while saving values to dxf and displaying truncate decimal exponent to e+99)
sergey slezkin
thank you. do you see any workaround to be able to use this file?
br
dag barosen
workaround is possible. see dwgviewer.cpp
in cdwgviewer:

nviewzoomextents() 2 points are passed to setview() - camera position and target. target is set to the center of extents (e+174) view direction is unit length vector. as a result adding view direction to target gives position equal to target.
in modified function below extents are truncated to be sure that
target + view_direction != target
code:
void cdwgviewer:

nviewzoomextents()
{
oddbdatabase* pdb = (codamfcappdoc*)getdocument();
oddbextents ext;
// world extents to view cs:
odgsview* pview = getactiveview();
ext.addblockext(oddbblocktablerecordptr(pdb->getactivelayoutbtrid().safeopenobject()),
pview->viewingmatrix());
if(ext.isvalidextents())
{ // truncate the extents
#define max_ext (1.e15)
odgepoint3d minpoint(ext.minpoint());
odgepoint3d maxpoint(ext.maxpoint());
if (minpoint.x < -max_ext)
minpoint.x = -max_ext;
else if (minpoint.x > max_ext)
minpoint.x = max_ext;
if (minpoint.y < -max_ext)
minpoint.y = -max_ext;
else if (minpoint.y > max_ext)
minpoint.y = max_ext;
if (minpoint.z < -max_ext)
minpoint.z = -max_ext;
else if (minpoint.z > max_ext)
minpoint.z = max_ext;
if (maxpoint.x < -max_ext)
maxpoint.x = -max_ext;
else if (maxpoint.x > max_ext)
maxpoint.x = max_ext;
if (maxpoint.y < -max_ext)
maxpoint.y = -max_ext;
else if (maxpoint.y > max_ext)
maxpoint.y = max_ext;
if (maxpoint.z < -max_ext)
maxpoint.z = -max_ext;
else if (maxpoint.z > max_ext)
maxpoint.z = max_ext;
ext.set(minpoint, maxpoint);
odgepoint3d targ = pview->target();
odgevector3d dirfromtarg = pview->position() - targ;
// set target to center of the scene, keep view direction:
targ = ext.minpoint() + (ext.maxpoint() - ext.minpoint()) / 2.0;
targ.transformby(pview->viewingmatrix().invert());
if(pview->isfrontclipped() || pview->isbackclipped())
{
// keep distance from target to front & back planes
targ = targ.orthoproject(odgeplane(pview->target(), dirfromtarg));
}
double fw = ext.maxpoint().x - ext.minpoint().x;
double fh = ext.maxpoint().y - ext.minpoint().y;
odgepoint3d position(targ + dirfromtarg);
assert(position != targ);
pview->setview(position, targ, pview->upvector(), fw * 1.02, fh * 1.02);
redrawwindow();
}
}
sergey slezkin