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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】oddbhatchappendloop exception (http://www.dimcax.com/hust/showthread.php?t=17539)

yang686526 2009-05-06 07:47 PM

【转帖】oddbhatchappendloop exception
 
oddbhatch::appendloop exception
oddbhatch::appendloop exception
i am using the following code to create a hatch:
code:
dword dwrgb = 0;
oddbobjectidarray aobjs;
// ...fill the array with closed oddbpolyline objects
oddbhatchptr phatch;
phatch->setpattern(oddbhatch::kpredefined, "solid");
phatch->setassociative(true);
phatch->sethatchstyle(oddbhatch::knormal);
phatch->setcolorindex(lookupaci(dwrgb));
phatch->appendloop(oddbhatch::kexternal, aobjs);
the call to appendloop throws exception 5 (invalid input) every time i call appendloop and the oddbobjectidarray contains more than one object id. (it works fine when the array contains exactly one object id.) i also get the following exception: (kernel32.dll): 0xe06d7363: microsoft c++ exception.
what constitues "invalid input" for this method?
thanks,
bob
ps...i am using visual c++ 6.0 with dd version 1.11.01.
if you have a number of closed polylines they should be used for creating a number of loops.
from dbhatch.h"
code:
/** description:
appends a loop onto this hatch, in the form of a set of oddbentities.
a loop must be simple, closed, and continuous, intersecting itself only at its endpoints.
furthermore, its start point and end point must coincide. when defining the hatch boundary,
the application must ensure that the loops and edges are well defined and structured. if
the boundary contains two or more loops, they must be organized into a nested structure
in which the external loop is constructed first, then followed by all its internal loops
in nested order. if there is more than one external loop, repeat the process.
dwgdirect provides limited validation of the hatch boundary in order to maintain api efficiency
and performance.
arguments:
looptype (i) type of loop to be appended.
dbobjids (i) array of oddbentity object id's that make up the loop.
*/
void appendloop(odint32 looptype, const oddbobjectidarray& dbobjids);
sergey slezkin
precision problem?
i have a similar problem.
my oddbobjectidarray aobjs is a collection of oddblineptr
when it is
(x y) - (x y); z is always 0
(0.00083750 0.00112600) - (0.00103850 0.00112600)
(0.00103850 0.00112600) - (0.00103850 0.00113600)
(0.00103850 0.00113600) - (0.00083750 0.00113600)
(0.00083750 0.00113600) - (0.00083750 0.00112600)
everything is ok.
but when it is
(x y) - (x y)
(0.00008375 0.00011260) (0.00010385 0.00011260)
(0.00010385 0.00011260) (0.00010385 0.00011360)
(0.00010385 0.00011360) (0.00008375 0.00011360)
(0.00008375 0.00011360) (0.00008375 0.00011260)
i receive an exception: "invalid input"
what is the point of it? a precision?
thanks in advance
mk
last edited by michał krzesiak; 6th january 2006 at 05:56 amfff">.

you listed only first 8 digits after decimal comma. the default world tolerance is 1.0e-10. i. e. two points, a and b, are considered equal when a.distanceto(b) <= 1.0e-10. so possible reason of exception is difference in 9th or 10th digit.
sincerely yours,
george udov
there are only zeros:
(8.37500000000000e-005 1.12600000000000e-004) (1.03850000000000e-004 1.12600000000000e-004)
(1.03850000000000e-004 1.12600000000000e-004) (1.03850000000000e-004 1.13600000000000e-004)
(1.03850000000000e-004 1.13600000000000e-004) (8.37500000000000e-005 1.13600000000000e-004)
(8.37500000000000e-005 1.13600000000000e-004) (8.37500000000000e-005 1.12600000000000e-004)
error:
code = 209
description: "invalid input"
m_phostappservices->geterrordescription(code): "repair"
and besides, where can i read the world tolerane (the constant or function)

michal,
odgecontest::gtol is used by dd as world tolerance.
which version of dd do you use?
is it possible to prepare a short fragment of code, that will let me to reproduce the problem on my side?
sincerely yours,
george udov
last edited by george udov; 26th october 2005 at 01:20 amfff">.
hello
thanks for a fast reply.
my version is 1.13.02
i attached the dwg file (eksport_1.dwg) with a hatch from the example above, (that one i can save)
and the code, that generate exception - i've tested it and hope is ok
code:
void addhatch()
{
oddbblocktablerecordptr pms = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite);
oddbhatchptr poddbhatch = oddbhatch::createobject();
poddbhatch->setdatabasedefaults(m_pdb);
poddbhatch->setlayer(m_player->getname());
poddbhatch->setpattern(oddbhatch::kpredefined, "solid");
poddbhatch->setassociative(true);
poddbhatch->sethatchstyle(oddbhatch::hatchstyle::knormal);
poddbhatch->appendseedpoint(odgepoint2d(0, 0));
oddbobjectidarray varray;
testtoedgearray(pms, varray);
poddbhatch->appendloop(oddbhatch::kexternal, varray); // <- error
pms->appendoddbentity(poddbhatch);
poddbhatch->evaluatehatch();
if (!m_pview.isnull())
m_pview->add(poddbhatch, 0);
}
void testtoedgearray(oddbblocktablerecordptr pms, oddbobjectidarray &aarray)
{
const int size = 4;
odgepoint3d p[size];
p[0] = odgepoint3d(8.37500000000000e-005, 1.12600000000000e-004, 0);
p[1] = odgepoint3d(1.03850000000000e-004, 1.12600000000000e-004, 0);
p[2] = odgepoint3d(1.03850000000000e-004, 1.13600000000000e-004, 0);
p[3] = odgepoint3d(8.37500000000000e-005, 1.13600000000000e-004, 0);
for (int i=0; i<size; i++)
{
int j = (i+1 < size ? i+1 : 0);
if (p[i].distanceto(p[j]) > 1.0e-10)
{
trace("(%0.14e %0.14e) (%0.14e %0.14e)\n", p[i].x, p[i].y, p[j].x, p[j].y);
oddblineptr pline = oddbline::createobject();
pline->setdatabasedefaults(m_pdb);
pline->setstartpoint(p[i]);
pline->setendpoint(p[j]);
oddbobjectid id = pms->appendoddbentity(pline);
aarray.push_back(id);
pline = null;
}
}
}
attached files (8.4 kb, 5 views)


michal, its bug of 1.13.02. fix will be available in 1.14.
sincerely yours,
george udov
quote:
originally posted by george udov
michal, its bug of 1.13.02. fix will be available in 1.14.
does it works correct now in 1.14.02?
best regards,
mk

dear michal,
was fixed in 1.14.
now oddbhatch::appendloop works same with objectarx's one acdbhatch::appendloop.
objectarx's function acdbhatch::appendloop uses absolute tolerance 1.0e-6 to compare loop points. so your points
code:
p[1] = odgepoint3d(1.03850000000000e-004, 1.12600000000000e-004, 0);
p[2] = odgepoint3d(1.03850000000000e-004, 1.13600000000000e-004, 0);
and
code:
p[0] = odgepoint3d(8.37500000000000e-005, 1.12600000000000e-004, 0);
p[3] = odgepoint3d(8.37500000000000e-005, 1.13600000000000e-004, 0);
will be considered equal. so your piece of code will still throw an invalid input exception :(
sincerely yours,
george udov


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