Revision: 53675
http://brlcad.svn.sourceforge.net/brlcad/?rev=53675&view=rev
Author: n_reed
Date: 2012-11-14 16:38:34 +0000 (Wed, 14 Nov 2012)
Log Message:
-----------
use spacing parameters to choose number of points/curves to plot
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/rhc/rhc.c
Modified: brlcad/trunk/src/librt/primitives/rhc/rhc.c
===================================================================
--- brlcad/trunk/src/librt/primitives/rhc/rhc.c 2012-11-14 15:57:33 UTC (rev
53674)
+++ brlcad/trunk/src/librt/primitives/rhc/rhc.c 2012-11-14 16:38:34 UTC (rev
53675)
@@ -774,6 +774,10 @@
int count;
struct rt_pt_node *curve;
+ if (num_points < 2) {
+ return NULL;
+ }
+
curve = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node),
"rt_pt_node");
curve->next = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node),
"rt_pt_node");
@@ -781,6 +785,10 @@
VSET(curve->p, 0, 0, -mag_b);
VSET(curve->next->p, 0, r, 0);
+ if (num_points < 3) {
+ return curve;
+ }
+
count = approximate_hyperbolic_curve(curve, c, rhc_hyperbola_b(mag_b, c,
r), num_points - 2);
if (count != (num_points - 2)) {
@@ -892,12 +900,31 @@
}
}
+static int
+rhc_curve_points(
+ struct rt_rhc_internal *rhc,
+ const struct rt_view_info *info)
+{
+ fastf_t height, halfwidth, est_curve_length;
+ point_t p0, p1;
+
+ height = -MAGNITUDE(rhc->rhc_B);
+ halfwidth = rhc->rhc_r;
+
+ VSET(p0, 0, 0, height);
+ VSET(p1, 0, halfwidth, 0);
+
+ est_curve_length = 2.0 * DIST_PT_PT(p0, p1);
+
+ return est_curve_length / info->point_spacing;
+}
+
int
rt_rhc_adaptive_plot(struct rt_db_internal *ip, const struct rt_view_info
*info)
{
point_t p;
vect_t rhc_R;
- int num_curve_points;
+ int num_curve_points, num_connections;
struct rt_rhc_internal *rhc;
struct rt_pt_node *pts, *node, *tmp;
@@ -909,7 +936,7 @@
return -2;
}
- num_curve_points = sqrt(primitive_diagonal_samples(ip, info)) / 4.0;
+ num_curve_points = rhc_curve_points(rhc, info);
if (num_curve_points < 3) {
num_curve_points = 3;
@@ -920,13 +947,34 @@
VSCALE(rhc_R, rhc_R, rhc->rhc_r);
pts = rhc_hyperbolic_curve(MAGNITUDE(rhc->rhc_B), rhc->rhc_c, rhc->rhc_r,
num_curve_points);
-
rhc_plot_hyperbolas(info->vhead, rhc, pts);
+ node = pts;
+ while (node != NULL) {
+ tmp = node;
+ node = node->next;
+
+ bu_free(tmp, "rt_pt_node");
+ }
+
/* connect both halves of the hyperbolic contours of the opposing faces */
+ num_connections = primitive_curve_count(ip, info);
+ if (num_connections < 2) {
+ num_connections = 2;
+ }
+
+ pts = rhc_hyperbolic_curve(MAGNITUDE(rhc->rhc_B), rhc->rhc_c, rhc->rhc_r,
num_connections);
rhc_plot_curve_connections(info->vhead, rhc, pts, 1.0);
rhc_plot_curve_connections(info->vhead, rhc, pts, -1.0);
+ node = pts;
+ while (node != NULL) {
+ tmp = node;
+ node = node->next;
+
+ bu_free(tmp, "rt_pt_node");
+ }
+
/* plot rectangular face */
VADD2(p, rhc->rhc_V, rhc_R);
RT_ADD_VLIST(info->vhead, p, BN_VLIST_LINE_MOVE);
@@ -943,14 +991,6 @@
VJOIN1(p, p, 2.0, rhc_R);
RT_ADD_VLIST(info->vhead, p, BN_VLIST_LINE_DRAW);
- node = pts;
- while (node != NULL) {
- tmp = node;
- node = node->next;
-
- bu_free(tmp, "rt_pt_node");
- }
-
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits