Revision: 52715
http://brlcad.svn.sourceforge.net/brlcad/?rev=52715&view=rev
Author: n_reed
Date: 2012-10-03 13:46:48 +0000 (Wed, 03 Oct 2012)
Log Message:
-----------
check arguments to increase confidence that point is properly set
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/epa/epa.c
Modified: brlcad/trunk/src/librt/primitives/epa/epa.c
===================================================================
--- brlcad/trunk/src/librt/primitives/epa/epa.c 2012-10-03 12:13:00 UTC (rev
52714)
+++ brlcad/trunk/src/librt/primitives/epa/epa.c 2012-10-03 13:46:48 UTC (rev
52715)
@@ -704,19 +704,26 @@
*
* pts->p: the vertex (0, h, k)
* pts->next->p: another point on the parabola
+ * pts->next->next: NULL
* p: the constant from the above equation
*
* This routine inserts num_new_points points between the two input points to
* better approximate the parabolic curve passing between them.
+ *
+ * Returns number of points successfully added.
*/
static int
approximate_parabolic_curve(struct rt_pt_node *pts, fastf_t p, int
num_new_points)
{
fastf_t error, max_error, seg_slope, seg_intercept;
- point_t v, point, new_point = VINIT_ZERO, p0, p1;
+ point_t v, point, p0, p1, new_point = VINIT_ZERO;
struct rt_pt_node *node, *worst_node, *new_node;
int i;
+ if (pts == NULL || pts->next == NULL || num_new_points < 1) {
+ return 0;
+ }
+
VMOVE(v, pts->p);
for (i = 0; i < num_new_points; ++i) {
@@ -771,7 +778,7 @@
struct rt_epa_internal *xip;
struct rt_pt_node *pts, *node;
fastf_t mag_h, r1;
- int num_points = 4;
+ int count, num_points = 4;
BU_CK_LIST_HEAD(info->vhead);
RT_CK_DB_INTERNAL(ip);
@@ -787,8 +794,12 @@
VSET(pts->p, 0, 0, -mag_h);
VSET(pts->next->p, 0, r1, 0);
- approximate_parabolic_curve(pts, (r1 * r1) / (4 * mag_h), num_points - 2);
+ count = approximate_parabolic_curve(pts, (r1 * r1) / (4 * mag_h),
num_points - 2);
+ if (count != (num_points - 2)) {
+ return -1;
+ }
+
node = pts;
node->p[Z] *= -1.0;
VADD2(node->p, node->p, xip->epa_V);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits