[brlcad-commits] SF.net SVN: brlcad:[66393] brlcad/trunk/src/libbrep/shape_recognition_cone. cpp
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <sta...@us...> - 2015-10-05 20:39:35
|
Revision: 66393 http://sourceforge.net/p/brlcad/code/66393 Author: starseeker Date: 2015-10-05 20:39:32 +0000 (Mon, 05 Oct 2015) Log Message: ----------- better, but not handling multiple cutting planes on top and bottom of cones yet. Modified Paths: -------------- brlcad/trunk/src/libbrep/shape_recognition_cone.cpp Modified: brlcad/trunk/src/libbrep/shape_recognition_cone.cpp =================================================================== --- brlcad/trunk/src/libbrep/shape_recognition_cone.cpp 2015-10-05 19:31:47 UTC (rev 66392) +++ brlcad/trunk/src/libbrep/shape_recognition_cone.cpp 2015-10-05 20:39:32 UTC (rev 66393) @@ -132,20 +132,29 @@ axis_pts_init.Append(ipoint); } else { - ON_3dVector av = ipoint - cone.ApexPoint(); + ON_3dVector av = cone.ApexPoint() - ipoint; double side = av.Length(); av.Unitize(); double dpc = ON_DotProduct(av, (*cone_planes)[i].Normal()); + bu_log("dpc: %f\n", dpc*180/M_PI); double angle_plane_axis = (dpc < 0) ? M_PI/2 - acos(dpc) : acos(dpc); + bu_log("angle_plane_axis : %f\n", angle_plane_axis*180/M_PI); - double C = M_PI/2 - (M_PI/4 - angle_plane_axis) - cone.AngleInRadians(); + double C = M_PI/2 - angle_plane_axis - cone.AngleInRadians(); double a = side * sin(cone.AngleInRadians()) / sin(C); - C = M_PI/2 - (M_PI/4 + angle_plane_axis) - cone.AngleInRadians(); + bu_log("a: %f\n", a); + C = M_PI/2 - (M_PI/2 - angle_plane_axis) - cone.AngleInRadians(); double b = side * sin(cone.AngleInRadians()) / sin(C); + bu_log("b: %f\n", b); ON_3dVector avect, bvect; - ON_3dVector pvect = cone.Axis() - ((*cone_planes)[i].Normal() * dpc); + ON_3dVector cone_unit_axis = cone.Axis(); + cone_unit_axis.Unitize(); + ON_3dVector pvect = cone.Axis() - ((*cone_planes)[i].Normal() * ON_DotProduct(cone_unit_axis, (*cone_planes)[i].Normal())); pvect.Unitize(); + bu_log("in rcc_%d.s rcc %f, %f, %f %f, %f, %f 0.1\n", i, ipoint.x, ipoint.y, ipoint.z, pvect.x, pvect.y, pvect.z); + bu_log("in rcc_av.s rcc %f, %f, %f %f, %f, %f 0.1\n", ipoint.x, ipoint.y, ipoint.z, av.x, av.y, av.z); + double abdp = ON_DotProduct(pvect, av); avect = (abdp < 0) ? pvect : -1 * pvect; bvect = (abdp > 0) ? pvect : -1 * pvect; @@ -201,17 +210,18 @@ data->params->negative = negative_cone(brep, shoal_nonplanar_face, BREP_CONIC_TOL); data->params->bool_op = (data->params->negative == -1) ? '-' : 'u'; + fastf_t hdelta; if (l.PointAt(tmin).DistanceTo(cone.ApexPoint()) > BREP_CONIC_TOL) { - fastf_t hdelta = cone.BasePoint().DistanceTo(l.PointAt(tmin)); + hdelta = cone.BasePoint().DistanceTo(l.PointAt(tmin)); hdelta = (cone.height < 0) ? -1*hdelta : hdelta; data->params->radius = cone.CircleAt(cone.height - hdelta).Radius(); BN_VMOVE(data->params->origin, l.PointAt(tmin)); } if (l.PointAt(tmax).DistanceTo(cone.ApexPoint()) > BREP_CONIC_TOL) { - fastf_t hdelta = cone.BasePoint().DistanceTo(l.PointAt(tmax)); - hdelta = (cone.height < 0) ? -1*hdelta : hdelta; - data->params->r2 = cone.CircleAt(cone.height - hdelta).Radius(); + fastf_t hdelta2 = cone.BasePoint().DistanceTo(l.PointAt(tmax)); + hdelta2 = (cone.height < 0) ? -1*hdelta2 : hdelta2; + data->params->r2 = cone.CircleAt(cone.height - hdelta2).Radius(); } else { data->params->r2 = 0.000001; } @@ -220,6 +230,28 @@ BN_VMOVE(data->params->hv, hvect); data->params->height = hvect.Length(); + // constructed oriented bounding box planes + if (need_arbn) { + ON_3dVector v1 = cone.CircleAt(cone.height - hdelta).Plane().xaxis; + ON_3dVector v2 = cone.CircleAt(cone.height - hdelta).Plane().yaxis; + v1.Unitize(); + v2.Unitize(); + v1 = v1 * cone.CircleAt(cone.height - hdelta).Radius(); + v2 = v2 * cone.CircleAt(cone.height - hdelta).Radius(); + ON_3dPoint arbmid = (l.PointAt(tmax) + l.PointAt(tmin)) * 0.5; + ON_3dVector cone_axis_unit = l.PointAt(tmax) - l.PointAt(tmin); + cone_axis_unit.Unitize(); + + (*cone_planes).Append(ON_Plane(l.PointAt(tmin), -1 * cone_axis_unit)); + (*cone_planes).Append(ON_Plane(l.PointAt(tmax), cone_axis_unit)); + (*cone_planes).Append(ON_Plane(arbmid + v1, cone.CircleAt(cone.height - hdelta).Plane().xaxis)); + (*cone_planes).Append(ON_Plane(arbmid - v1, -1 *cone.CircleAt(cone.height - hdelta).Plane().xaxis)); + (*cone_planes).Append(ON_Plane(arbmid + v2, cone.CircleAt(cone.height - hdelta).Plane().yaxis)); + (*cone_planes).Append(ON_Plane(arbmid - v2, -1 * cone.CircleAt(cone.height - hdelta).Plane().yaxis)); + } + + + return need_arbn; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |