Revision: 51735
http://brlcad.svn.sourceforge.net/brlcad/?rev=51735&view=rev
Author: crdueck
Date: 2012-07-31 20:44:11 +0000 (Tue, 31 Jul 2012)
Log Message:
-----------
added new analyze_ars(), uses technique similar to rt_ars_tess() to find
triangular faces
Modified Paths:
--------------
brlcad/trunk/src/libged/analyze.c
Modified: brlcad/trunk/src/libged/analyze.c
===================================================================
--- brlcad/trunk/src/libged/analyze.c 2012-07-31 20:38:55 UTC (rev 51734)
+++ brlcad/trunk/src/libged/analyze.c 2012-07-31 20:44:11 UTC (rev 51735)
@@ -752,6 +752,7 @@
* - arb8
* - arbn
* - bot
+ * - ars
*
* returns:
* - area in face->area
@@ -1120,6 +1121,103 @@
}
+#define ARS_PT(ii, jj) (&arip->curves[i+(ii)][(j+(jj))*ELEMENTS_PER_VECT])
+
+/**
+ * A N A L Y Z E _ A R S
+ */
+static void
+analyze_ars(struct ged *gedp, const struct rt_db_internal *ip)
+{
+ size_t i, j, k;
+ size_t nfaces = 0;
+ fastf_t tot_area = 0.0, tot_vol = 0.0;
+ table_t table;
+ struct poly_face face;
+ struct bu_vls tmpstr = BU_VLS_INIT_ZERO;
+ struct rt_ars_internal *arip = (struct rt_ars_internal *)ip->idb_ptr;
+ RT_ARS_CK_MAGIC(arip);
+
+ /* allocate pts array, max 3 pts per triangular face */
+ face.pts = (point_t *)bu_calloc(3, sizeof(point_t), "analyze_ars: pts");
+
+ k = arip->pts_per_curve - 2;
+ for (i = 0; i < arip->ncurves - 1; i++) {
+ int double_ended;
+
+ if (k != 1 && VEQUAL(&arip->curves[i][ELEMENTS_PER_VECT],
&arip->curves[i][k * ELEMENTS_PER_VECT])) {
+ double_ended = 1;
+ } else {
+ double_ended = 0;
+ }
+
+ for (j = 0; j < arip->pts_per_curve; j++) {
+ vect_t tmp;
+
+ if (double_ended && i != 0 && (j == 0 || j == k || j ==
arip->pts_per_curve - 1)) {
+ continue;
+ }
+
+ /* first triangular face */
+ if (bn_mk_plane_3pts(face.plane_eqn, ARS_PT(0, 0), ARS_PT(1, 1),
ARS_PT(0, 1), &gedp->ged_wdbp->wdb_tol) == 0) {
+ ADD_POINT(face, ARS_PT(0, 0));
+ ADD_POINT(face, ARS_PT(1, 1));
+ ADD_POINT(face, ARS_PT(0, 1));
+
+ bu_vls_printf(&tmpstr, "%zu%zu", i, j);
+ sprintf(face.label, "%s", bu_vls_addr(&tmpstr));
+
+ /* surface area */
+ analyze_poly_face(gedp, &face, &(table.rows[nfaces]));
+ tot_area += face.area;
+
+ /* volume */
+ VSCALE(tmp, face.plane_eqn, face.area);
+ tot_vol += fabs(VDOT(face.pts[0], tmp));
+
+ face.npts = 0;
+ nfaces++;
+ }
+
+ /* second triangular face */
+ if (bn_mk_plane_3pts(face.plane_eqn, ARS_PT(1, 0), ARS_PT(1, 1),
ARS_PT(0, 0), &gedp->ged_wdbp->wdb_tol) == 0) {
+ ADD_POINT(face, ARS_PT(1, 0));
+ ADD_POINT(face, ARS_PT(1, 1));
+ ADD_POINT(face, ARS_PT(0, 0));
+
+ bu_vls_printf(&tmpstr, "%zu%zu", i, j);
+ sprintf(face.label, "%s", bu_vls_addr(&tmpstr));
+
+ analyze_poly_face(gedp, &face, &table.rows[nfaces]);
+ tot_area += face.area;
+
+ VSCALE(tmp, face.plane_eqn, face.area);
+ tot_vol += fabs(VDOT(face.pts[0], tmp));
+
+ face.npts = 0;
+ nfaces++;
+ }
+ }
+ }
+ tot_vol /= 3.0;
+ table.nrows = nfaces;
+
+ bu_free((char *)face.pts, "analyze_ars: pts");
+
+ print_faces_table(gedp, &table);
+ print_volume_table(gedp,
+ tot_vol
+ * gedp->ged_wdbp->dbip->dbi_base2local
+ * gedp->ged_wdbp->dbip->dbi_base2local
+ * gedp->ged_wdbp->dbip->dbi_base2local,
+ tot_area
+ * gedp->ged_wdbp->dbip->dbi_base2local
+ * gedp->ged_wdbp->dbip->dbi_base2local,
+ tot_vol/GALLONS_TO_MM3
+ );
+}
+
+
#define PROLATE 1
#define OBLATE 2
@@ -1313,6 +1411,10 @@
analyze_arbn(gedp, ip);
break;
+ case ID_ARS:
+ analyze_ars(gedp, ip);
+ break;
+
case ID_TGC:
analyze_general(gedp, ip);
break;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits