Revision: 53674
          http://brlcad.svn.sourceforge.net/brlcad/?rev=53674&view=rev
Author:   n_reed
Date:     2012-11-14 15:57:33 +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/eto/eto.c

Modified: brlcad/trunk/src/librt/primitives/eto/eto.c
===================================================================
--- brlcad/trunk/src/librt/primitives/eto/eto.c 2012-11-14 15:24:39 UTC (rev 
53673)
+++ brlcad/trunk/src/librt/primitives/eto/eto.c 2012-11-14 15:57:33 UTC (rev 
53674)
@@ -872,6 +872,20 @@
     VSCALE(contour_B, eto_B, c);
 }
 
+static int
+eto_ellipse_points(
+       vect_t ellipse_A,
+       vect_t ellipse_B,
+       const struct rt_view_info *info)
+{
+    fastf_t avg_radius, circumference;
+
+    avg_radius = (MAGNITUDE(ellipse_A) + MAGNITUDE(ellipse_B)) / 2.0;
+    circumference = bn_twopi * avg_radius;
+
+    return circumference / info->point_spacing;
+}
+
 int
 rt_eto_adaptive_plot(struct rt_db_internal *ip, const struct rt_view_info 
*info)
 {
@@ -880,7 +894,7 @@
     vect_t ellipse_A, ellipse_B, contour_A, contour_B, I, J;
     vect_t center, cross_AN, eto_V, eto_N, eto_A, eto_B;
     fastf_t mag_N, mag_ai, mag_aj, mag_bi, mag_bj;
-    int i, samples, num_cross_sections, points_per_cross_section;
+    int i, num_cross_sections, points_per_ellipse;
 
     BU_CK_LIST_HEAD(info->vhead);
     RT_CK_DB_INTERNAL(ip);
@@ -890,16 +904,6 @@
        return -1;
     }
 
-    samples = sqrt(primitive_diagonal_samples(ip, info));
-
-    if (samples < 8) {
-       samples = 8;
-    }
-
-    while (samples % 4 != 0) {
-       ++samples;
-    }
-
     VMOVE(eto_V, eto->eto_V);
 
     VMOVE(eto_N, eto->eto_N);
@@ -946,28 +950,52 @@
     mag_bi = VDOT(ellipse_B, I);
     mag_bj = VDOT(ellipse_B, J);
 
+
     /* plot elliptical contour showing extent of ellipse +A/-A */
     eto_contour_axes(contour_A, contour_B, eto_A, eto_B, mag_ai);
+
+    points_per_ellipse = eto_ellipse_points(contour_A, contour_B, info);
+
+    if (points_per_ellipse < 6) {
+       points_per_ellipse = 6;
+    }
+
     VJOIN1(center, eto_V, mag_aj / mag_N, eto_N);
-    plot_ellipse(info->vhead, center, contour_A, contour_B, samples);
+    plot_ellipse(info->vhead, center, contour_A, contour_B, 
points_per_ellipse);
 
     eto_contour_axes(contour_A, contour_B, eto_A, eto_B, -mag_ai);
     VJOIN1(center, eto_V, -mag_aj / mag_N, eto_N);
-    plot_ellipse(info->vhead, center, contour_A, contour_B, samples);
+    plot_ellipse(info->vhead, center, contour_A, contour_B, 
points_per_ellipse);
 
     /* plot elliptical contour showing extent of ellipse +B/-B */
     eto_contour_axes(contour_A, contour_B, eto_A, eto_B, mag_bi);
+
+    points_per_ellipse = eto_ellipse_points(contour_A, contour_B, info);
+
+    if (points_per_ellipse < 6) {
+       points_per_ellipse = 6;
+    }
+
     VJOIN1(center, eto_V, mag_bj / mag_N, eto_N);
-    plot_ellipse(info->vhead, center, contour_A, contour_B, samples);
+    plot_ellipse(info->vhead, center, contour_A, contour_B, 
points_per_ellipse);
 
     eto_contour_axes(contour_A, contour_B, eto_A, eto_B, -mag_bi);
     VJOIN1(center, eto_V, -mag_bj / mag_N, eto_N);
-    plot_ellipse(info->vhead, center, contour_A, contour_B, samples);
+    plot_ellipse(info->vhead, center, contour_A, contour_B, 
points_per_ellipse);
 
     /* draw elliptical radial cross sections */
-    num_cross_sections = samples;
-    points_per_cross_section = samples / 2.0;
+    num_cross_sections = primitive_curve_count(ip, info);
 
+    if (num_cross_sections < 3) {
+       num_cross_sections = 3;
+    }
+
+    points_per_ellipse = eto_ellipse_points(eto_A, eto_B, info);
+
+    if (points_per_ellipse < 6) {
+       points_per_ellipse = 6;
+    }
+
     radian_step = bn_twopi / num_cross_sections;
     radian = 0;
     for (i = 0; i < num_cross_sections; ++i) {
@@ -980,7 +1008,7 @@
        VCOMB2(ellipse_A, mag_ai, I, mag_aj, J);
        VCOMB2(ellipse_B, mag_bi, I, mag_bj, J);
 
-       plot_ellipse(info->vhead, center, ellipse_A, ellipse_B, 
points_per_cross_section);
+       plot_ellipse(info->vhead, center, ellipse_A, ellipse_B, 
points_per_ellipse);
 
        radian += radian_step;
     }

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
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to