Revision: 42272
http://brlcad.svn.sourceforge.net/brlcad/?rev=42272&view=rev
Author: brlcad
Date: 2011-01-14 20:01:54 +0000 (Fri, 14 Jan 2011)
Log Message:
-----------
separate out rt_rpp_region() and rt_bound_tree() into bbox.c so we can
consolidate bounding box routines into one place.
Modified Paths:
--------------
brlcad/trunk/misc/win32-msvc8/librt/librt.vcproj
brlcad/trunk/src/librt/CMakeLists.txt
brlcad/trunk/src/librt/Makefile.am
brlcad/trunk/src/librt/tree.c
Added Paths:
-----------
brlcad/trunk/src/librt/bbox.c
Modified: brlcad/trunk/misc/win32-msvc8/librt/librt.vcproj
===================================================================
--- brlcad/trunk/misc/win32-msvc8/librt/librt.vcproj 2011-01-14 19:48:37 UTC
(rev 42271)
+++ brlcad/trunk/misc/win32-msvc8/librt/librt.vcproj 2011-01-14 20:01:54 UTC
(rev 42272)
@@ -268,6 +268,10 @@
>
</File>
<File
+ RelativePath="..\..\..\src\librt\bbox.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\src\librt\bezier_2d_isect.c"
>
</File>
Modified: brlcad/trunk/src/librt/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/librt/CMakeLists.txt 2011-01-14 19:48:37 UTC (rev
42271)
+++ brlcad/trunk/src/librt/CMakeLists.txt 2011-01-14 20:01:54 UTC (rev
42272)
@@ -1,5 +1,6 @@
set(LIBRT_SOURCES
attributes.c
+ bbox.c
bezier_2d_isect.c
binunif/binunif.c
binunif/db5_bin.c
Modified: brlcad/trunk/src/librt/Makefile.am
===================================================================
--- brlcad/trunk/src/librt/Makefile.am 2011-01-14 19:48:37 UTC (rev 42271)
+++ brlcad/trunk/src/librt/Makefile.am 2011-01-14 20:01:54 UTC (rev 42272)
@@ -35,6 +35,7 @@
librt_nil_la_SOURCES = \
attributes.c \
+ bbox.c \
bezier_2d_isect.c \
binunif/binunif.c \
binunif/db5_bin.c \
Added: brlcad/trunk/src/librt/bbox.c
===================================================================
--- brlcad/trunk/src/librt/bbox.c (rev 0)
+++ brlcad/trunk/src/librt/bbox.c 2011-01-14 20:01:54 UTC (rev 42272)
@@ -0,0 +1,178 @@
+/* B B O X . C
+ * BRL-CAD
+ *
+ * Copyright (c) 1995-2011 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @addtogroup librt */
+/** @{ */
+/** @file bbox.c
+ *
+ * Routines related to creating and processing bounding boxes.
+ *
+ */
+/** @} */
+
+#include "common.h"
+
+#include "bu.h"
+#include "vmath.h"
+#include "raytrace.h"
+
+
+/**
+ * R T _ B O U N D _ T R E E
+ *
+ * Calculate the bounding RPP of the region whose boolean tree is
+ * 'tp'. The bounding RPP is returned in tree_min and tree_max, which
+ * need not have been initialized first.
+ *
+ * Returns -
+ * 0 success
+ * -1 failure (tree_min and tree_max may have been altered)
+ */
+int
+rt_bound_tree(const union tree *tp, fastf_t *tree_min, fastf_t *tree_max)
+{
+ vect_t r_min, r_max; /* rpp for right side of tree */
+
+ RT_CK_TREE(tp);
+
+ switch (tp->tr_op) {
+
+ case OP_SOLID:
+ {
+ const struct soltab *stp;
+
+ stp = tp->tr_a.tu_stp;
+ RT_CK_SOLTAB(stp);
+ if (stp->st_aradius <= 0) {
+ bu_log("rt_bound_tree: encountered dead solid '%s'\n",
+ stp->st_dp->d_namep);
+ return -1; /* ERROR */
+ }
+
+ if (stp->st_aradius >= INFINITY) {
+ VSETALL(tree_min, -INFINITY);
+ VSETALL(tree_max, INFINITY);
+ return 0;
+ }
+ VMOVE(tree_min, stp->st_min);
+ VMOVE(tree_max, stp->st_max);
+ return 0;
+ }
+
+ default:
+ bu_log("rt_bound_tree(x%x): unknown op=x%x\n",
+ tp, tp->tr_op);
+ return -1;
+
+ case OP_XOR:
+ case OP_UNION:
+ /* BINARY type -- expand to contain both */
+ if (rt_bound_tree(tp->tr_b.tb_left, tree_min, tree_max) < 0 ||
+ rt_bound_tree(tp->tr_b.tb_right, r_min, r_max) < 0)
+ return -1;
+ VMIN(tree_min, r_min);
+ VMAX(tree_max, r_max);
+ break;
+ case OP_INTERSECT:
+ /* BINARY type -- find common area only */
+ if (rt_bound_tree(tp->tr_b.tb_left, tree_min, tree_max) < 0 ||
+ rt_bound_tree(tp->tr_b.tb_right, r_min, r_max) < 0)
+ return -1;
+ /* min = largest min, max = smallest max */
+ VMAX(tree_min, r_min);
+ VMIN(tree_max, r_max);
+ break;
+ case OP_SUBTRACT:
+ /* BINARY type -- just use left tree */
+ if (rt_bound_tree(tp->tr_b.tb_left, tree_min, tree_max) < 0 ||
+ rt_bound_tree(tp->tr_b.tb_right, r_min, r_max) < 0)
+ return -1;
+ /* Discard right rpp */
+ break;
+ case OP_NOP:
+ /* Implies that this tree has nothing in it */
+ break;
+ }
+ return 0;
+}
+
+
+/**
+ * Return a pointer to the corresponding region structure of the given
+ * region's name (reg_name), or REGION_NULL if it does not exist.
+ *
+ * If the full path of a region is specified, then that one is
+ * returned. However, if only the database node name of the region is
+ * specified and that region has been referenced multiple time in the
+ * tree, then this routine will simply return the first one.
+ */
+HIDDEN struct region *
+_rt_getregion(struct rt_i *rtip, const char *reg_name)
+{
+ struct region *regp;
+ const char *reg_base = bu_basename(reg_name);
+
+ RT_CK_RTI(rtip);
+ for (BU_LIST_FOR(regp, region, &(rtip->HeadRegion))) {
+ const char *cp;
+ /* First, check for a match of the full path */
+ if (*reg_base == regp->reg_name[0] &&
+ BU_STR_EQUAL(reg_base, regp->reg_name))
+ return regp;
+ /* Second, check for a match of the database node name */
+ cp = bu_basename(regp->reg_name);
+ if (*cp == *reg_name && BU_STR_EQUAL(cp, reg_name))
+ return regp;
+ }
+ return REGION_NULL;
+}
+
+
+/**
+ * R T _ R P P _ R E G I O N
+ *
+ * Calculate the bounding RPP for a region given the name of the
+ * region node in the database. See remarks in _rt_getregion() above
+ * for name conventions. Returns 0 for failure (and prints a
+ * diagnostic), or 1 for success.
+ */
+int
+rt_rpp_region(struct rt_i *rtip, const char *reg_name, fastf_t *min_rpp,
fastf_t *max_rpp)
+{
+ struct region *regp;
+
+ RT_CHECK_RTI(rtip);
+
+ regp = _rt_getregion(rtip, reg_name);
+ if (regp == REGION_NULL) return 0;
+ if (rt_bound_tree(regp->reg_treetop, min_rpp, max_rpp) < 0)
+ return 0;
+ return 1;
+}
+
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Property changes on: brlcad/trunk/src/librt/bbox.c
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: brlcad/trunk/src/librt/tree.c
===================================================================
--- brlcad/trunk/src/librt/tree.c 2011-01-14 19:48:37 UTC (rev 42271)
+++ brlcad/trunk/src/librt/tree.c 2011-01-14 20:01:54 UTC (rev 42272)
@@ -1000,86 +1000,6 @@
/**
- * R T _ B O U N D _ T R E E
- *
- * Calculate the bounding RPP of the region whose boolean tree is
- * 'tp'. The bounding RPP is returned in tree_min and tree_max, which
- * need not have been initialized first.
- *
- * Returns -
- * 0 success
- * -1 failure (tree_min and tree_max may have been altered)
- */
-int
-rt_bound_tree(const union tree *tp, fastf_t *tree_min, fastf_t *tree_max)
-{
- vect_t r_min, r_max; /* rpp for right side of tree */
-
- RT_CK_TREE(tp);
-
- switch (tp->tr_op) {
-
- case OP_SOLID:
- {
- const struct soltab *stp;
-
- stp = tp->tr_a.tu_stp;
- RT_CK_SOLTAB(stp);
- if (stp->st_aradius <= 0) {
- bu_log("rt_bound_tree: encountered dead solid '%s'\n",
- stp->st_dp->d_namep);
- return -1; /* ERROR */
- }
-
- if (stp->st_aradius >= INFINITY) {
- VSETALL(tree_min, -INFINITY);
- VSETALL(tree_max, INFINITY);
- return 0;
- }
- VMOVE(tree_min, stp->st_min);
- VMOVE(tree_max, stp->st_max);
- return 0;
- }
-
- default:
- bu_log("rt_bound_tree(x%x): unknown op=x%x\n",
- tp, tp->tr_op);
- return -1;
-
- case OP_XOR:
- case OP_UNION:
- /* BINARY type -- expand to contain both */
- if (rt_bound_tree(tp->tr_b.tb_left, tree_min, tree_max) < 0 ||
- rt_bound_tree(tp->tr_b.tb_right, r_min, r_max) < 0)
- return -1;
- VMIN(tree_min, r_min);
- VMAX(tree_max, r_max);
- break;
- case OP_INTERSECT:
- /* BINARY type -- find common area only */
- if (rt_bound_tree(tp->tr_b.tb_left, tree_min, tree_max) < 0 ||
- rt_bound_tree(tp->tr_b.tb_right, r_min, r_max) < 0)
- return -1;
- /* min = largest min, max = smallest max */
- VMAX(tree_min, r_min);
- VMIN(tree_max, r_max);
- break;
- case OP_SUBTRACT:
- /* BINARY type -- just use left tree */
- if (rt_bound_tree(tp->tr_b.tb_left, tree_min, tree_max) < 0 ||
- rt_bound_tree(tp->tr_b.tb_right, r_min, r_max) < 0)
- return -1;
- /* Discard right rpp */
- break;
- case OP_NOP:
- /* Implies that this tree has nothing in it */
- break;
- }
- return 0;
-}
-
-
-/**
* R T _ T R E E _ E L I M _ N O P S
*
* Eliminate any references to NOP nodes from the tree. It is safe to
@@ -1179,64 +1099,7 @@
return 0;
}
-
/**
- * R T _ G E T R E G I O N
- *
- * Return a pointer to the corresponding region structure of the given
- * region's name (reg_name), or REGION_NULL if it does not exist.
- *
- * If the full path of a region is specified, then that one is
- * returned. However, if only the database node name of the region is
- * specified and that region has been referenced multiple time in the
- * tree, then this routine will simply return the first one.
- */
-HIDDEN struct region *
-_rt_getregion(struct rt_i *rtip, const char *reg_name)
-{
- struct region *regp;
- const char *reg_base = bu_basename(reg_name);
-
- RT_CK_RTI(rtip);
- for (BU_LIST_FOR(regp, region, &(rtip->HeadRegion))) {
- const char *cp;
- /* First, check for a match of the full path */
- if (*reg_base == regp->reg_name[0] &&
- BU_STR_EQUAL(reg_base, regp->reg_name))
- return regp;
- /* Second, check for a match of the database node name */
- cp = bu_basename(regp->reg_name);
- if (*cp == *reg_name && BU_STR_EQUAL(cp, reg_name))
- return regp;
- }
- return REGION_NULL;
-}
-
-
-/**
- * R T _ R P P _ R E G I O N
- *
- * Calculate the bounding RPP for a region given the name of the
- * region node in the database. See remarks in _rt_getregion() above
- * for name conventions. Returns 0 for failure (and prints a
- * diagnostic), or 1 for success.
- */
-int
-rt_rpp_region(struct rt_i *rtip, const char *reg_name, fastf_t *min_rpp,
fastf_t *max_rpp)
-{
- struct region *regp;
-
- RT_CHECK_RTI(rtip);
-
- regp = _rt_getregion(rtip, reg_name);
- if (regp == REGION_NULL) return 0;
- if (rt_bound_tree(regp->reg_treetop, min_rpp, max_rpp) < 0)
- return 0;
- return 1;
-}
-
-
-/**
* R T _ F I N D _ S O L I D
*
* Given the (leaf) name of a solid, find the first occurance of it in
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits