Compare commits

...
Author SHA1 Message Date
Thomas Browder 3883da443f Removing original branch which was replaced by branch 'binary-attributes'. (svn branch delete)
svn:revision:66642
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-22 18:33:26 +00:00
Thomas Browder ed74c18baa elim info on binary attrs
svn:revision:66639
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-22 12:35:20 +00:00
Thomas Browder 3515306f78 correct internal title
svn:revision:66629
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-20 18:05:22 +00:00
Thomas Browder 53f557d88f start a binary attr section
svn:revision:66627
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-20 18:03:43 +00:00
Thomas Browder a4059f417a add more scribbles
svn:revision:66626
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-20 18:03:14 +00:00
Thomas Browder 401e59cf13 change version no
svn:revision:66625
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-20 18:02:44 +00:00
Thomas Browder 6864048fb3 add new V6 version
svn:revision:66624
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-20 18:02:10 +00:00
Thomas Browder ada766bc34 start a new version to include binary attributes
svn:revision:66622
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-20 17:07:52 +00:00
Thomas Browder 41dbd307ac add the test to be executed
svn:revision:66620
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-19 22:11:23 +00:00
Thomas Browder 31cd46c64f add a stub of a test file for binary attributes
svn:revision:66619
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-19 22:10:54 +00:00
Thomas Browder 4e341109da make db-admin-tool installable
svn:revision:66618
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-19 19:57:33 +00:00
Thomas Browder 51dcbe46e9 rename per conversation with Sean (may change again later)
svn:revision:66617
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-19 19:56:58 +00:00
Thomas Browder 3109873add add missing semis; use correct var names; cast as necessary; correct arg types; remove incomplete line
svn:revision:66616
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-19 18:14:02 +00:00
Thomas Browder da94e91174 correct typo
svn:revision:66610
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-19 01:06:21 +00:00
Thomas Browder 2adf2317bc add a test plan; correct typo
svn:revision:66609
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-19 01:04:48 +00:00
Thomas Browder ecea40d49f sync merge trunk with branch
svn:revision:66607
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-19 00:53:28 +00:00
Thomas Browder 5d26aebca7 start documenting the binary attributes mod
svn:revision:66606
svn:branch:attr-extension-mods
svn:account:tbrowder2
2015-11-18 23:32:00 +00:00
Clifford Yapp 140bf4c3fe revert stray function definion.
svn:revision:66605
svn:branch:trunk
svn:account:starseeker
2015-11-18 22:44:04 +00:00
Clifford Yapp fdd990cc00 Not sure at this point if __attribute__ (()) is legal with the space, but we have instances both with and without. The GNU documentation has a space in the form description but none of their examples have it. The rest of our __attribute__ labels don't seem to use the space, and clang 3.7 is known to have trouble with it in at least one case. Remove spaces.
svn:revision:66604
svn:branch:trunk
svn:account:starseeker
2015-11-18 22:43:10 +00:00
Thomas Browder b1223c912d sync this branch with trunk rev 53577
svn:revision:57358
svn:branch:attr-extension-mods
svn:account:tbrowder2
2013-08-31 16:20:00 +00:00
Thomas Browder 5b700e170e creating a private branch for working on bu_avs_attribute_value_pair
svn:revision:57266
svn:branch:attr-extension-mods
svn:account:tbrowder2
2013-08-29 13:24:11 +00:00
276 changed files with 26456 additions and 217204 deletions
-3
View File
@@ -1,3 +0,0 @@
/bin
/lib
/build
+21 -162
View File
@@ -37,7 +37,7 @@ contributor credits are organized into the following general
categories depending on the level and type of involvement:
* Mathematical, Algorithmic, and Geometric Support
* Documentation, Artwork, and Website Contributors
* Documentation and Website Contributors
* Code Contributors
* Special Thanks
@@ -218,23 +218,6 @@ nicknames r_weiss
2008 December
U.S. Army Research Laboratory
Browder, Thomas M. Jr. **
nicknames tbrowder2
2008 June
ManTech International Corporation
Open Source
Reed, Nicholas **
nicknames n_reed
2008 July
ARL Student Hire / University of Maryland, Baltimore County
Quantum Research International, Inc.
Moore, Jr., Carl G. **
nicknames cmoore, carlmoore
2011 October
U.S. Army Research Laboratory
MATHEMATICAL, ALGORITHMIC, AND GEOMETRIC SUPPORT
------------------------------------------------
@@ -246,7 +229,7 @@ U.S. Army Ballistic Research Laboratory
Davisson, Edwin O. **
U.S. Army Research Laboratory
Rogers, David
Rodgers, David
U.S. Naval Academy
Stiller, Peter
@@ -268,8 +251,8 @@ Weaver, Stephanie 'Rain' **
ARL Student Hire / Bridgewater College
DOCUMENTATION, ARTWORK, AND WEBSITE CONTRIBUTORS
------------------------------------------------
DOCUMENTATION AND WEBSITE CONTRIBUTORS
--------------------------------------
Weaver, Earl P.
1980
@@ -334,25 +317,6 @@ Perez, Alex
2012 November
Open Source (GCI)
Tannous, Marc
2014 December
Open Source (GCI)
Chiplunkar, Shardul
nicknames microchip, shardulc
2014 December
Open Source (GCI)
Juvekar, Mandar
nicknames mandarj
2014 December
Open Source (GCI)
Sofat, Hitesh
nicknames sofat
2015 June
Open Source (GSoC)
CODE CONTRIBUTIONS
------------------
@@ -482,7 +446,6 @@ U.S. Army Research Laboratory
Howard, Doug
SURVICE Engineering, Inc.
2006 April
Silva, Prasad Prometheus
nicknames prasad_silva
@@ -535,6 +498,17 @@ nicknames homovulgaris, madant
2008 June
Open Source (GSoC)
Browder, Thomas M. Jr.
nicknames tbrowder2
2008 June
ManTech International Corporation
Open Source
Reed, Nicholas
nicknames n_reed
2008 July
ARL Student Hire / University of Maryland, Baltimore County
Saunders, Benjamin
nicknames Ralith
2008 July
@@ -586,6 +560,11 @@ nicknames abhi2011
2011 July
Open Source (SOCIS)
Moore, Jr., Carl G.
nicknames cmoore, carlmoore
2011 October
U.S. Army Research Laboratory
Silvko, Ksenija
nicknames ksuzee
2012 March
@@ -672,7 +651,6 @@ Calle, Adrián Arroyo
Open Source (GCI)
Keesing, Aaron
nicknames agkphysics
2012 December
Open Source (GCI)
@@ -685,11 +663,6 @@ nicknames ncsaba
2013 April
Open Source
Check, Nyah
nicknames Ch3ck
2013 July
Open Source (GSoC)
Shah, Kesha
nicknames keshashah
2013 April
@@ -710,101 +683,15 @@ nicknames zero_level
2013 June
Open Source (GSoC)
Kamga, Isaac
nicknames Izak
2013 July
Open Source (GSoC)
Singh, Harmanpreet
nicknames harmanpreet
2013 May
Open Source (GSoC)
Huff, Emory
nicknames hknoll
2013 July
ARL Student Hire
U.S. Army Research Laboratory (SEAP)
Engbert, Jonathan
nicknames ejno
2013 July
Open Source
ARL Student Hire / University of Maryland, Baltimore County
Andrew
2013 November
Open Source (GCI)
Schulte, Johannes
2013 November
Open Source (GCI)
Amidon, Peter
2013 November
Open Source (GCI)
Chiplunkar, Shardul
nicknames microchip
2013 November
Open Source (GCI)
Берегов, Станислав
2013 December
Open Source (GCI)
nicknames huskmate13
2014 January
Open Source
Gustave Granroth
2014 May
Open Source
Jain, Rishub
2014 July
ARL Student Hire
Roberts, Mitchell
2014 July
ARL Student Hire
Bayes, Matthew
nicknames klinger4077
2014 July
ARL Student Hire / University of Maryland College Park
Mirea, Ștefan-Gabriel
2014 October
Open Source
Krishna
2015 January
Open Source (GCI)
Thakkar, Kalpit
nicknames dracarys983
2015 May
Open Source (GSoC)
Ilinca, Andrei
nicknames andrei_il
2015 June
Open Source (GSoC)
Sofat, Hitesh
nicknames sofat
2015 June
Open Source (GSoC)
Hollister, Brad
nicknames bhollister
2015 July
Open Source (GSoC)
Alexandre da Silva Costa, Vasco
nicknames vasco_costa
2015 April
Open Source (GSoC)
SPECIAL THANKS
@@ -1079,34 +966,6 @@ nicknames talwindersaini
2013 July
Open Source
YuGin, Tan
2013 November
Open Source (GCI)
nicknames mandar
2013 December
Open Source (GCI)
Lotsu, Alexander
nicknames Alex
2013 December
Open Source (GCI)
Hyams, Daniel
nicknames dhyams
2014 February
Open Source
Reddy, Raj
nicknames raj12lnm
2014 May
Open Source
Malhotra, Shivoam
nicknames shiv05
2015 March
Open Source
CORPORATE AND ORGANIZATION SUPPORT
----------------------------------
+115
View File
@@ -0,0 +1,115 @@
branch/attr-extension-mods
==========================
To turn on the use of binary attributes define:
USE_BINARY_ATTRIBUTES
E.g., prior to running CMake:
export CFLAGS=-DUSE_BINARY_ATTRIBUTES
export CXXFLAGS=-DUSE_BINARY_ATTRIBUTES
Files affected:
./include/bu/parse.h
./include/bu/avs.h
./src/librt/db5_io.c
./src/librt/attributes.c
Features to be implemented and other considerations:
+ add a binary attribute using similar syntax as a string attribute
+ a binary attribute should have an optional description field
+ implement auto update of an object's ctime (creation time) and
mtime (last modification)
+ mtime and ctime should be 64-bit integers (based on Unix time and
epoch) (int64_t; see src/libbu/y2038/time64_config.h)
+ binary attributes should be able to be entered from or output to a
file
A db admin tool:
./src/util/db-admin-tool.cpp
On-disk format of a binary attribute [following the (char*)NULL
(char*)NULL end of the normal attributes]:
After more deliberation I believe we ought to create a separate object
structure section for binary attributes. Following is the existing
Table 1. in the V5 database format manual:
The following describes the current V5 db:
BRL_CAD_g_format_V5.xml
The following describes the proposed V6 db with the binary attributes:
BRL_CAD_g_format_V6.xml
Test plan:
1. Select a complex TGM in the db directory as a test subject.
2. Create a script to:
+ copy the TGM to a new file (TGM2)
+ add multiple binary attributes to TGM2
+ use the admin-db tool to check TGM2
+ delete the added binary attributes from TGM2
+ run cmp on TGM and TGM2 to see they are the same
The following is from the TODO file:
ATTRIBUTES
----------
* attr command option to output to a file
* attr command change to only output non-standard attributes
* attr command change to have an optional object argument and to work
with multiple objects. make output format scriptable.
* implement an attribute versioning system. can hang attribute
version off of _GLOBAL (ideally) or per-object so application codes
(including our own tools) know whether they're compatible or whether
the attributes must be upgraded.
* implement an "attr upgrade" subcommand that allows for forwards AND
backwards conversion of attributes. the command will need two
function pointers per version that describes how to upgrade and
downgrade for that version transition. this will allow new files to
be downgraded for use on older versions and obviously lets new files
be upgraded to the latest conventions.
* implement namespacing for attributes as a means to group attributes
together. examples: cad:color, cad:region_id, muves:component.
similar to svn properties, the namespace is predominantly (perhaps
entirely) a naming convention, but allows us to document and assert
requirements/conventions over a given prefix (e.g., 'cad:'), and
provides 3rd party applications with a sandbox to work with.
* expose the list of internally recognized attributes via the man page
documentation and some internal method (e.g., an 'attr standards'
subcommand).
* clean up default attributes to be consistent and upgrade old
attributes to their new names. includes likes of region, region_id,
material_id, air, los, rgb, oshader, and inherit. see
doc/docbook/system/man5/en/attributes.xml for more detailed listing.
* implement an option to "attr upgrade" for reading upgrade/downgrade
plugins/instructions from an external file for 3rd party use.
* prevent nirt from outputting a trailing space after values when
there are no attributes to be displayed. the problem is in the nirt
format strings where they use " %s" for displaying any attributes.
need to left-pad a space conditionally, perhaps by supporting %*s
and sizeof(var).
* add additional support for user-specified sorting for the attr
command when new attribute attributes are added (e.g., creation
date)
* binary attributes, see binary-incompatible section for details.
+17 -17
View File
@@ -6,17 +6,17 @@ add_definitions(
-DHAVE_CONFIG_H
-DBRLCADBUILD
-DCONSOLE
)
)
BRLCAD_ADDEXEC(pixcmp pixcmp.c libbu)
configure_file(run.sh ${CMAKE_CURRENT_BINARY_DIR}/benchmark COPYONLY)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/benchmark DESTINATION ${BIN_DIR})
if(CMAKE_CONFIGURATION_TYPES)
foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER)
configure_file(run.sh ${CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}}/bin/benchmark COPYONLY)
endforeach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER)
configure_file(run.sh ${CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}}/bin/benchmark COPYONLY)
endforeach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
else(CMAKE_CONFIGURATION_TYPES)
configure_file(run.sh ${CMAKE_BINARY_DIR}/bin/benchmark COPYONLY)
endif(CMAKE_CONFIGURATION_TYPES)
@@ -28,18 +28,18 @@ file(APPEND ${CMAKE_BINARY_DIR}/CMakeTmp/benchmsg.cmake "message(\"and image fil
CMAKEFILES(lgt.sh run.sh try.sh viewdiff.sh)
if(SH_EXEC)
add_custom_target(benchmark
COMMAND ${SH_EXEC} ${CMAKE_BINARY_DIR}/bin/benchmark run
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CMakeTmp/benchmsg.cmake
DEPENDS rt pixcmp BENCHMARK_PIX_cp PIX_LOG_cp
)
add_dependencies(benchmark bldg391.g m35.g moss.g sphflake.g star.g world.g)
add_custom_target(benchmark-clean
${SH_EXEC} ${CMAKE_BINARY_DIR}/bin/benchmark clean
)
add_custom_target(benchmark-clobber
${SH_EXEC} ${CMAKE_BINARY_DIR}/bin/benchmark clobber
)
add_custom_target(benchmark
COMMAND ${SH_EXEC} ${CMAKE_BINARY_DIR}/bin/benchmark run
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CMakeTmp/benchmsg.cmake
DEPENDS rt pixcmp BENCHMARK_PIX_cp PIX_LOG_cp
)
add_dependencies(benchmark bldg391.g m35.g moss.g sphflake.g star.g world.g)
add_custom_target(benchmark-clean
${SH_EXEC} ${CMAKE_BINARY_DIR}/bin/benchmark clean
)
add_custom_target(benchmark-clobber
${SH_EXEC} ${CMAKE_BINARY_DIR}/bin/benchmark clobber
)
endif(SH_EXEC)
# Local Variables:
+1 -1
View File
@@ -2,7 +2,7 @@
# L G T . S H
# BRL-CAD
#
# Copyright (c) 2004-2014 United States Government as represented by
# Copyright (c) 2004-2013 United States Government as represented by
# the U.S. Army Research Laboratory.
#
# Redistribution and use in source and binary forms, with or without
+6 -5
View File
@@ -1,7 +1,7 @@
/* P I X C M P . C
* BRL-CAD
*
* Copyright (c) 2004-2014 United States Government as represented by
* Copyright (c) 2004-2013 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This program is free software; you can redistribute it and/or
@@ -31,12 +31,13 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "bio.h"
#include "bu/getopt.h"
#include "bu/log.h"
#include "bu/file.h"
#include "bu/str.h"
#include "bu.h"
/* exit codes for argument processing errors */
#define OPTS_ERROR 127
+2 -15
View File
@@ -2,7 +2,7 @@
# R U N . S H
# BRL-CAD
#
# Copyright (c) 2004-2014 United States Government as represented by
# Copyright (c) 2004-2013 United States Government as represented by
# the U.S. Army Research Laboratory.
#
# Redistribution and use in source and binary forms, with or without
@@ -1496,7 +1496,7 @@ else
$ECHO
blankit=no
# BSD+
# BSD
look_for executable "a sysctl command" SYSCTL_CMD `echo "$PATH" | tr ":" "\n" | sed 's/$/\/sysctl/g'`
if test ! "x$SYSCTL_CMD" = "x" ; then
$ECHO "Collecting system state information (via $SYSCTL_CMD)"
@@ -1563,19 +1563,6 @@ else
blankit=yes
fi
# Linux+
look_for executable "an lscpu command" LSCPU_CMD `echo $PATH | tr ":" "\n" | sed 's/$/\/lscpu/g'`
if test ! "x$LSCPU_CMD" = "x" ; then
$ECHO "Collecting system CPU information (via $LSCPU_CMD)"
preQUIET="$QUIET"
QUIET=1
$ECHO "==============================================================================="
$ECHO "`$LSCPU_CMD 2>&1`"
$ECHO
QUIET="$preQUIET"
blankit=yes
fi
if test "x$blankit" = "xyes" ; then
$ECHO
fi
+1 -1
View File
@@ -2,7 +2,7 @@
# T R Y . S H
# BRL-CAD
#
# Copyright (c) 2004-2014 United States Government as represented by
# Copyright (c) 2004-2013 United States Government as represented by
# the U.S. Army Research Laboratory.
#
# Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -2,7 +2,7 @@
# V I E W D I F F . S H
# BRL-CAD
#
# Copyright (c) 2004-2014 United States Government as represented by
# Copyright (c) 2004-2013 United States Government as represented by
# the U.S. Army Research Laboratory.
#
# Redistribution and use in source and binary forms, with or without
Vendored
+28 -60
View File
@@ -66,18 +66,6 @@ do
shift;;
--disable-strict-compile-flags) options="$options -DBRLCAD_ENABLE_STRICT=OFF";
shift;;
--enable-all-cxx) options="$options -DENABLE_ALL_CXX_COMPILE=ON";
shift;;
--disable-all-cxx) options="$options -DENABLE_ALL_CXX_COMPILE=OFF";
shift;;
--enable-posix) options="$options -DENABLE_POSIX_COMPLIANCE=ON";
shift;;
--disable-posix) options="$options -DENABLE_POSIX_COMPLIANCE=OFF";
shift;;
--strict-iso-c) options="$options -DENABLE_STRICT_COMPILER_STANDARD_COMPLIANCE=ON";
shift;;
--strict-iso-c) options="$options -DENABLE_STRICT_COMPILER_STANDARD_COMPLIANCE=OFF";
shift;;
--enable-docs) options="$options -DBRLCAD_EXTRADOCS=ON";
shift;;
--disable-docs) options="$options -DBRLCAD_EXTRADOCS=OFF";
@@ -90,30 +78,6 @@ do
shift;;
--disable-docbook) options="$options -DBRLCAD_EXTRADOCS=OFF";
shift;;
--enable-lemon) options="$options -DBRLCAD_LEMON=BUNDLED";
shift;;
--disable-lemon) options="$options -DBRLCAD_LEMON=SYSTEM";
shift;;
--enable-re2c) options="$options -DBRLCAD_RE2C=BUNDLED";
shift;;
--disable-re2c) options="$options -DBRLCAD_RE2C=SYSTEM";
shift;;
--enable-perplex) options="$options -DBRLCAD_PERPLEX=BUNDLED";
shift;;
--disable-perplex) options="$options -DBRLCAD_PERPLEX=SYSTEM";
shift;;
--enable-astyle) options="$options -DBRLCAD_ASTYLE=BUNDLED";
shift;;
--disable-astyle) options="$options -DBRLCAD_ASTYLE=SYSTEM";
shift;;
--enable-xsltproc) options="$options -DBRLCAD_XSLTPROC=BUNDLED";
shift;;
--disable-xsltproc) options="$options -DBRLCAD_XSLTPROC=SYSTEM";
shift;;
--enable-xmllint) options="$options -DBRLCAD_XMLLINT=BUNDLED";
shift;;
--disable-xmllint) options="$options -DBRLCAD_XMLLINT=SYSTEM";
shift;;
--enable-regex) options="$options -DBRLCAD_REGEX=BUNDLED";
shift;;
--disable-regex) options="$options -DBRLCAD_REGEX=SYSTEM";
@@ -126,9 +90,25 @@ do
shift;;
--disable-libz) options="$options -DBRLCAD_ZLIB=SYSTEM";
shift;;
--enable-freetype) options="$options -DBRLCAD_FREETYPE=BUNDLED";
--enable-lemon) options="$options -DBRLCAD_LEMON=BUNDLED";
shift;;
--disable-freetype) options="$options -DBRLCAD_FREETYPE=SYSTEM";
--disable-lemon) options="$options -DBRLCAD_LEMON=SYSTEM";
shift;;
--enable-re2c) options="$options -DBRLCAD_RE2C=BUNDLED";
shift;;
--disable-re2c) options="$options -DBRLCAD_RE2C=SYSTEM";
shift;;
--enable-perplex) options="$options -DBRLCAD_PERPLEX=BUNDLED";
shift;;
--disable-perplex) options="$options -DBRLCAD_PERPLEX=SYSTEM";
shift;;
--enable-xsltproc) options="$options -DBRLCAD_XSLTPROC=BUNDLED";
shift;;
--disable-xsltproc) options="$options -DBRLCAD_XSLTPROC=SYSTEM";
shift;;
--enable-xmllint) options="$options -DBRLCAD_XMLLINT=BUNDLED";
shift;;
--disable-xmllint) options="$options -DBRLCAD_XMLLINT=SYSTEM";
shift;;
--enable-termlib) options="$options -DBRLCAD_TERMLIB=BUNDLED";
shift;;
@@ -178,37 +158,25 @@ do
shift;;
--disable-opennurbs) options="$options -DBRLCAD_OPENNURBS=SYSTEM";
shift;;
--enable-spr) options="$options -DBRLCAD_SPR=BUNDLED";
--enable-scl) options="$options -DBRLCAD_SCL=BUNDLED";
shift;;
--disable-spr) options="$options -DBRLCAD_SPR=SYSTEM";
--disable-scl) options="$options -DBRLCAD_SCL=SYSTEM";
shift;;
--enable-scl) options="$options -DBRLCAD_SC=BUNDLED";
--enable-step) options="$options -DBRLCAD_SCL=BUNDLED";
shift;;
--disable-scl) options="$options -DBRLCAD_SC=SYSTEM";
--disable-step) options="$options -DBRLCAD_SCL=SYSTEM";
shift;;
--enable-step) options="$options -DBRLCAD_SC=BUNDLED";
--enable-step-class-libraries) options="$options -DBRLCAD_SCL=BUNDLED";
shift;;
--disable-step) options="$options -DBRLCAD_SC=SYSTEM";
--disable-step-class-libraries) options="$options -DBRLCAD_SCL=SYSTEM";
shift;;
--enable-step-class-libraries) options="$options -DBRLCAD_SC=BUNDLED";
--enable-vds) options="$options -DBRLCAD_LIBVDS=BUNDLED";
shift;;
--disable-step-class-libraries) options="$options -DBRLCAD_SC=SYSTEM";
--disable-vds) options="$options -DBRLCAD_LIBVDS=SYSTEM";
shift;;
--enable-vds) options="$options -DBRLCAD_VDS=BUNDLED";
--enable-gdiam) options="$options -DBRLCAD_LIBGDIAM=BUNDLED";
shift;;
--disable-vds) options="$options -DBRLCAD_VDS=SYSTEM";
shift;;
--enable-openscenegraph) options="$options -DBRLCAD_OSG=BUNDLED";
shift;;
--disable-openscenegraph) options="$options -DBRLCAD_OSG=SYSTEM";
shift;;
--enable-gdiam) options="$options -DBRLCAD_GDIAM=BUNDLED";
shift;;
--disable-gdiam) options="$options -DBRLCAD_GDIAM=SYSTEM";
shift;;
--enable-bullet) options="$options -DBRLCAD_BULLET=BUNDLED";
shift;;
--disable-bullet) options="$options -DBRLCAD_BULLET=SYSTEM";
--disable-gdiam) options="$options -DBRLCAD_LIBGDIAM=SYSTEM";
shift;;
--prefix=*) inputstr=$1;
options="$options -DCMAKE_INSTALL_PREFIX=${inputstr#--prefix=}";
+19 -33
View File
@@ -8,6 +8,7 @@ set(G_BENCHMARK_MODELS
)
set(G_SAMPLE_MODELS
${G_BENCHMARK_MODELS}
axis.asc
boolean-ops.asc
castle.asc
@@ -36,26 +37,6 @@ set(G_SAMPLE_MODELS
xmp.asc
)
macro(ADD_G_TARGET g_model folder)
string(REGEX REPLACE "([0-9a-z]*).asc" "\\1" g_model_root "${g_model}")
set(output_file ${bin_root}/${DATA_DIR}/db/${g_model_root}.g)
add_custom_command(
OUTPUT ${output_file}
COMMAND asc2g ${CMAKE_CURRENT_SOURCE_DIR}/${g_model} ${output_file}
DEPENDS asc2g ${CMAKE_CURRENT_SOURCE_DIR}/${g_model}
)
add_custom_target(${g_model_root}.g ALL DEPENDS ${output_file})
set_target_properties(${g_model_root}.g PROPERTIES FOLDER "${folder}")
if(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" output_file "${output_file}")
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
install(FILES ${output_file} DESTINATION ${DATA_DIR}/db)
endif(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
set(BUILT_MODELS "${BUILT_MODELS};${output_file}")
endmacro(ADD_G_TARGET g_model folder)
# Get our root path
if(CMAKE_CONFIGURATION_TYPES)
set(bin_root "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}")
@@ -72,21 +53,26 @@ else(CMAKE_CONFIGURATION_TYPES)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DATA_DIR}/db)
endif(CMAKE_CONFIGURATION_TYPES)
add_subdirectory(comgeom)
add_subdirectory(nist)
add_subdirectory(faa)
foreach(g_input ${G_BENCHMARK_MODELS})
ADD_G_TARGET(${g_input} "BRL-CAD Geometry Models/Benchmark")
endforeach(g_input ${G_BENCHMARK_MODELS})
CMAKEFILES(${G_BENCHMARK_MODELS})
foreach(g_input ${G_SAMPLE_MODELS})
ADD_G_TARGET(${g_input} "BRL-CAD Geometry Models/Sample")
endforeach(g_input ${G_SAMPLE_MODELS})
foreach(g_model ${G_SAMPLE_MODELS})
string(REGEX REPLACE "([0-9a-z]*).asc" "\\1" g_model_root "${g_model}")
set(output_file ${bin_root}/${DATA_DIR}/db/${g_model_root}.g)
add_custom_command(
OUTPUT ${output_file}
COMMAND asc2g ${CMAKE_CURRENT_SOURCE_DIR}/${g_model} ${output_file}
DEPENDS asc2g ${CMAKE_CURRENT_SOURCE_DIR}/${g_model}
)
add_custom_target(${g_model_root}.g ALL DEPENDS ${output_file})
if(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" output_file "${output_file}")
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
install(FILES ${output_file} DESTINATION ${DATA_DIR}/db)
endif(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
set(BUILT_MODELS "${BUILT_MODELS};${output_file}")
endforeach(g_model ${G_SAMPLE_MODELS})
CMAKEFILES(${G_SAMPLE_MODELS})
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${BUILT_MODELS}")
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${BUILT_MODELS}")
if(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
BRLCAD_ADDDATA(terra.dsp db)
File diff suppressed because it is too large Load Diff
Binary file not shown.
-42
View File
@@ -1,42 +0,0 @@
set(COMGEOM_V5_MODELS
ADA073408.comgeom
)
macro(ADD_COMGEOM_V5_G_TARGET comgeom_model folder)
string(REGEX REPLACE "([0-9a-z]*).comgeom" "\\1" comgeom_model_root "${comgeom_model}")
set(output_file ${bin_root}/${DATA_DIR}/db/${comgeom_model_root}.g)
add_custom_command(
OUTPUT ${output_file}
COMMAND ${CMAKE_COMMAND} -E remove ${output_file}
COMMAND comgeom-g -v 5 ${CMAKE_CURRENT_SOURCE_DIR}/${comgeom_model} ${output_file}
DEPENDS comgeom-g ${CMAKE_CURRENT_SOURCE_DIR}/${comgeom_model}
)
add_custom_target(${comgeom_model_root}.g ALL DEPENDS ${output_file})
set_target_properties(${comgeom_model_root}.g PROPERTIES FOLDER "${folder}")
if(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" output_file "${output_file}")
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
install(FILES ${output_file} DESTINATION ${DATA_DIR}/db)
endif(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
set(BUILT_MODELS "${BUILT_MODELS};${output_file}")
endmacro(ADD_COMGEOM_V5_G_TARGET comgeom_model folder)
foreach(comgeom_input ${COMGEOM_V5_MODELS})
ADD_COMGEOM_V5_G_TARGET(${comgeom_input} "BRL-CAD Geometry Models/Sample")
endforeach(comgeom_input ${COMGEOM_V5_MODELS})
CMAKEFILES(${COMGEOM_V5_MODELS})
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${BUILT_MODELS}")
CMAKEFILES(
README_ADA073408
ADA073408_inputs.tar.gz
)
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8
-17
View File
@@ -1,17 +0,0 @@
Model ADA073408.comgeom is a transcription of the model documented in
the 1979 public release report:
A Combinatorial Geometry Computer Description of the MEP-021A Generator Set
http://www.dtic.mil/docs/citations/ADA073408
A series of Google GCI tasks worked to transcribe the ASCII COMGEOM
description from the original report to text, and post-processed it
into a form that the comgeom-g importer can handle:
http://www.google-melange.com/gci/task/view/google/gci2013/5597236545191936
http://www.google-melange.com/gci/task/view/google/gci2014/5293529710460928
http://www.google-melange.com/gci/task/view/google/gci2014/5792678377684992
The file ADA073408_inputs.tar.gz contains the original transcribed
files and the script used to create the comgeom file.
-856
View File
@@ -1,856 +0,0 @@
$COMMENT Generic Business Jet Rotor Burst Model
$COMMENT Todd Horelica
$COMMENT 28 Jan 2000
$COMMENT
$COMMENT The generic aircraft models were developed in support of the Federal
$COMMENT Aviation Administration's Aircraft Catastrophic Failure Prevention
$COMMENT Program. The models are used to demonstrate the Uncontained Engine
$COMMENT Debris Damage Assessment Model (UEDDAM) tool which evaluates the risk
$COMMENT to the aircraft from uncontained engine failures. This analysis
$COMMENT supports certification to Title 14 Code of Federal Regulations,
$COMMENT Part 25.903. The models are for demonstration purposes and do not
$COMMENT depict actual aircraft and /or Aircraft systems in service. The models
$COMMENT are available for public release.
$COMMENT
$COMMENT Note: Right and left are with respect to looking forward from the tail;
$COMMENT i.e. the pilot's perspective
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$COMMENT
$NAME 0 1 Right Engine Nacelle
SECTION 0 1 1 1
GRID 1 -375.96 -64.08 145.47
GRID 2 -491.31 -64.08 145.47
CCONE1 1 8 1 2 0.04 19.010000001
10000001 19.0 1 1
$NAME 0 11 Left Engine Nacelle
SECTION 0 11 1 1
GRID 3 -375.96 64.08 145.47
GRID 4 -491.31 64.08 145.47
CCONE1 2 8 3 4 0.04 19.010000002
10000002 19.0 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$COMMENT Pylons
$NAME 0 2 Left Pylon
SECTION 0 2 1 5
GRID 5 -392.28 45.24 142.98
GRID 6 -392.17 32.83 139.44
GRID 7 -494.47 45.24 142.98
GRID 8 -505.76 25.48 137.36
GRID 9 -392.28 46.75 137.69
GRID 10 -392.17 34.33 134.15
GRID 11 -494.47 46.75 137.69
GRID 12 -505.76 26.99 132.07
CQUAD 51 8 5 9 11 7 0.032 1
CQUAD 52 8 5 6 10 9 0.032 1
CQUAD 53 8 6 8 12 10 0.032 1
CQUAD 54 8 7 8 12 11 0.032 1
CQUAD 55 8 5 6 8 7 0.032 1
CQUAD 56 8 9 10 12 11 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 0 3 Right Pylon
SECTION 0 3 1 5
GRID 13 -392.28 -45.24 142.98
GRID 14 -392.17 -32.83 139.44
GRID 15 -494.47 -45.24 142.98
GRID 16 -505.76 -25.48 137.36
GRID 17 -392.28 -46.75 137.69
GRID 18 -392.17 -34.33 134.15
GRID 19 -494.47 -46.75 137.69
GRID 20 -505.76 -26.99 132.07
CQUAD 61 8 13 17 19 15 0.032 1
CQUAD 62 8 13 14 18 17 0.032 1
CQUAD 63 8 14 16 20 18 0.032 1
CQUAD 64 8 15 16 20 19 0.032 1
CQUAD 65 8 13 14 16 15 0.032 1
CQUAD 66 8 17 18 20 19 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 0 4 Aft Fuselage
SECTION 0 4 1 1
GRID 21 -373.75 -0.00 127.25
GRID 22 -512.50 -0.00 127.25
CCONE1 3 8 21 22 0.032 36.2510000003
10000003 26.96 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 0 101 Fairing
SECTION 0 101 1 1
GRID 223 -512.50 -0.00 100.27
GRID 224 -373.75 33.49 75.73
GRID 225 -373.75 -33.49 75.73
GRID 226 -373.75 33.49 127.25
GRID 227 -373.75 -33.49 127.25
CQUAD 87 8 224 225 227 226 0.032 1
CTRI 88 8 223 224 226 0.032 1
CTRI 89 8 223 224 225 0.032 1
CTRI 90 8 223 225 227 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$COMMENT Rotors
$NAME 1 1 Right Engine Fan
SECTION 1 1 2
GRID 294 -408.33 -64.08 145.47
GRID 295 -411.58 -64.08 145.47
CCONE2 1 7 294 295 13.609C90
C90 13.609 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 2 Right LPC1
SECTION 1 2 2
GRID 296 -416.62 -64.08 145.47
GRID 297 -418.62 -64.08 145.47
CCONE2 2 4 296 297 8.543C905
C905 8.543 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 3 Right HPC1
SECTION 1 3 2
GRID 298 -427.25 -64.08 145.47
GRID 299 -429.00 -64.08 145.47
CCONE2 3 4 298 299 5.09C91
C91 5.09 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 4 Right HPC2
SECTION 1 4 2
GRID 300 -431.36 -64.08 145.47
GRID 301 -432.61 -64.08 145.47
CCONE2 4 4 300 301 4.898C92
C92 4.898 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 5 Right HPC3
SECTION 1 5 2
GRID 302 -436.69 -64.08 145.47
GRID 303 -439.69 -64.08 145.47
CCONE2 5 4 302 303 6.644C93
C93 6.644 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 6 Right HPT1
SECTION 1 6 2
GRID 304 -443.53 -64.08 145.47
GRID 305 -445.28 -64.08 145.47
CCONE2 6 4 304 305 5.784C94
C94 5.784 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 7 Right LPT1
SECTION 1 7 2
GRID 306 -447.46 -64.08 145.47
GRID 307 -448.21 -64.08 145.47
CCONE2 7 4 306 307 7.286C95
C95 7.286 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 8 Right LPT2
SECTION 1 8 2
GRID 308 -450.10 -64.08 145.47
GRID 309 -450.98 -64.08 145.47
CCONE2 8 4 308 309 8.63C96
C96 8.63 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 9 Right LPT3
SECTION 1 9 2
GRID 310 -453.05 -64.08 145.47
GRID 311 -454.05 -64.08 145.47
CCONE2 9 4 310 311 8.985C97
C97 8.985 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 21 Right Engine Case
SECTION 1 21 1
GRID 332 -407.83 -64.08 145.47
GRID 333 -454.55 -64.08 145.47
CCONE1 21 4 332 333 0.1 14.109C332
C332 14.109 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 11 Left Engine Fan
SECTION 1 11 2
GRID 312 -408.33 64.08 145.47
GRID 313 -411.58 64.08 145.47
CCONE2 10 7 312 313 13.609C98
C98 13.609 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 12 Left LPC2
SECTION 1 12 2
GRID 314 -416.62 64.08 145.47
GRID 315 -418.62 64.08 145.47
CCONE2 19 4 314 315 8.543C985
C985 8.543 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 13 Left HPC1
SECTION 1 13 2
GRID 316 -427.25 64.08 145.47
GRID 317 -429.00 64.08 145.47
CCONE2 11 4 316 317 5.09C99
C99 5.09 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 14 Left HPC2
SECTION 1 14 2
GRID 318 -431.36 64.08 145.47
GRID 319 -432.61 64.08 145.47
CCONE2 12 4 318 319 4.898C100
C100 4.898 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 15 Left HPC3
SECTION 1 15 2
GRID 320 -436.69 64.08 145.47
GRID 321 -439.69 64.08 145.47
CCONE2 13 4 320 321 6.644C101
C101 6.644 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 16 Left HPT1
SECTION 1 16 2
GRID 322 -443.53 64.08 145.47
GRID 323 -445.28 64.08 145.47
CCONE2 14 4 322 323 5.784C102
C102 5.784 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 17 Left LPT1
SECTION 1 17 2
GRID 324 -447.46 64.08 145.47
GRID 325 -448.21 64.08 145.47
CCONE2 15 4 324 325 7.286C103
C103 7.286 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 18 Left LPT2
SECTION 1 18 2
GRID 326 -450.10 64.08 145.47
GRID 327 -450.98 64.08 145.47
CCONE2 16 4 326 327 8.63C104
C104 8.63 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 19 Left LPT3
SECTION 1 19 2
GRID 328 -453.05 64.08 145.47
GRID 329 -454.05 64.08 145.47
CCONE2 17 4 328 329 8.985C105
C105 8.985 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 1 22 Left Engine Case
SECTION 1 22 1
GRID 334 -407.83 64.08 145.47
GRID 335 -454.55 64.08 145.47
CCONE1 22 4 334 335 0.1 14.109C333
C333 14.109 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$COMMENT Control Cables
$NAME 3 1 Elevator Control Cables
SECTION 3 1 1
GRID 256 -373.75 13.97 90.17
GRID 257 -446.98 -2.25 95.25
GRID 258 -512.50 -1.03 104.95
GRID 259 -373.75 6.07 88.65
GRID 260 -446.96 -2.70 95.40
GRID 261 -512.50 -1.63 105.02
CLINE 1 4 256 257 0.063 0.063
CLINE 2 4 257 258 0.063 0.063
CLINE 3 4 259 260 0.063 0.063
CLINE 4 4 260 261 0.063 0.063
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 3 2 Elevator Trim Cables
SECTION 3 2 1
GRID 262 -373.75 -26.11 99.49
GRID 263 -388.77 -26.11 99.49
GRID 264 -385.59 -5.80 160.33
GRID 265 -512.50 -5.80 150.95
GRID 266 -375.75 -25.70 99.35
GRID 267 -388.78 -25.70 99.35
GRID 268 -385.59 -5.80 159.88
GRID 269 -512.50 -5.80 150.50
CLINE 5 4 262 263 0.063 0.063
CLINE 6 4 263 264 0.063 0.063
CLINE 7 4 264 265 0.063 0.063
CLINE 8 4 266 267 0.063 0.063
CLINE 9 4 267 268 0.063 0.063
CLINE 10 4 268 269 0.063 0.063
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 3 101 Rudder-Upper
SECTION 3 101 1
GRID 270 -373.75 -3.72 90.59
GRID 271 -384.74 -3.78 90.59
GRID 272 -391.84 -5.80 158.00
GRID 273 -512.50 -5.80 149.08
GRID 274 -373.75 -9.62 91.68
GRID 275 -383.88 -9.54 91.68
GRID 276 -392.62 -7.04 157.94
GRID 277 -512.50 -7.04 149.08
CLINE 11 4 270 271 0.063 0.063
CLINE 12 4 271 272 0.063 0.063
CLINE 13 4 272 273 0.063 0.063
CLINE 14 4 274 275 0.063 0.063
CLINE 15 4 275 276 0.063 0.063
CLINE 16 4 276 277 0.063 0.063
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 3 102 Rudder-Lower
SECTION 3 102 1
GRID 278 -373.75 -3.85 89.54
GRID 279 -448.81 -3.15 95.48
GRID 280 -512.50 -5.55 106.78
GRID 281 -373.75 -11.73 90.18
GRID 282 -448.78 -3.68 95.40
GRID 283 -512.50 -6.18 107.18
CLINE 17 4 278 279 0.063 0.063
CLINE 18 4 279 280 0.063 0.063
CLINE 19 4 281 282 0.063 0.063
CLINE 20 4 282 283 0.063 0.063
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 3 103 Rudder Trim
SECTION 3 103 1
GRID 284 -375.75 25.28 99.20
GRID 285 -388.78 25.28 99.20
GRID 286 -385.54 5.55 159.17
GRID 287 -406.34 -5.80 157.47
GRID 288 -512.50 -5.80 149.62
GRID 289 -373.75 26.53 99.63
GRID 290 -388.76 26.53 99.63
GRID 291 -385.75 5.95 159.27
GRID 292 -406.37 -5.80 157.91
GRID 293 -512.50 -5.80 150.06
CLINE 21 4 284 285 0.063 0.063
CLINE 22 4 285 286 0.063 0.063
CLINE 23 4 286 287 0.063 0.063
CLINE 24 4 287 288 0.063 0.063
CLINE 25 4 289 290 0.063 0.063
CLINE 26 4 290 291 0.063 0.063
CLINE 27 4 291 292 0.063 0.063
CLINE 28 4 292 293 0.063 0.063
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$COMMENT Fuel Lines
$NAME 4 1 Fuel Supply Line (Right Side)
SECTION 4 1 1 1
GRID 23 -378.88 -23.20 99.85
GRID 24 -380.84 -28.57 144.05
GRID 25 -428.13 -21.15 144.62
GRID 26 -428.85 -24.92 136.29
GRID 27 -427.79 -45.94 140.51
CLINE 1 12 23 24 0.035 0.5
CLINE 2 12 24 25 0.035 0.5
CLINE 3 12 25 26 0.035 0.5
CLINE 4 12 26 27 0.035 0.5
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 4 2 Fuel Supply Line (Left Side)
SECTION 4 2 1 1
GRID 28 -378.88 23.20 99.85
GRID 29 -380.84 28.57 144.05
GRID 30 -428.13 21.15 144.62
GRID 31 -428.85 24.92 136.29
GRID 32 -427.79 45.94 140.51
CLINE 5 12 28 29 0.035 0.5
CLINE 6 12 29 30 0.035 0.5
CLINE 7 12 30 31 0.035 0.5
CLINE 8 12 31 32 0.035 0.5
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 4 3 Fuel Motive Flow Line (Right Side)
SECTION 4 3 1 1
GRID 33 -378.82 -21.40 98.41
GRID 34 -380.84 -26.92 143.90
GRID 35 -428.20 -19.50 144.48
GRID 36 -428.89 -24.34 133.86
GRID 37 -427.77 -46.57 138.33
CLINE 9 12 33 34 0.035 0.25
CLINE 10 12 34 35 0.035 0.25
CLINE 11 12 35 36 0.035 0.25
CLINE 12 12 36 37 0.035 0.25
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 4 4 Fuel Motive Flow Line (Left Side)
SECTION 4 4 1 1
GRID 38 -378.82 21.40 98.41
GRID 39 -380.84 26.92 143.90
GRID 40 -428.20 19.50 144.48
GRID 41 -428.89 24.34 133.86
GRID 42 -427.77 46.57 138.33
CLINE 13 12 38 39 0.035 0.25
CLINE 14 12 39 40 0.035 0.25
CLINE 15 12 40 41 0.035 0.25
CLINE 16 12 41 42 0.035 0.25
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$COMMENT Structure
$NAME 7 1 Left Forward Engine Beam (1st 2 outboard; 2nd 2 inboard)
SECTION 7 1 1 1
GRID 43 -421.50 45.35 142.87
GRID 44 -421.50 46.64 137.80
GRID 45 -421.50 31.04 138.79
GRID 46 -421.50 32.33 133.72
$COMMENT Forward Engine Beam, Back Side (1st 2 outboard; 2nd 2 inboard)
GRID 47 -424.50 45.35 142.87
GRID 48 -424.50 46.64 137.80
GRID 49 -424.50 30.85 138.74
GRID 50 -424.50 32.13 133.67
CQUAD 1 8 49 45 43 47 0.190 1
CQUAD 2 8 49 47 48 50 0.100 1
CQUAD 3 8 44 46 50 48 0.190 1
CQUAD 4 8 44 46 45 43 0.100 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 2 Forward Beam through fuselage
SECTION 7 2 1 1
GRID 45 -421.50 31.04 138.79
GRID 46 -421.50 32.33 133.72
GRID 61 -421.50 -31.04 138.79
GRID 62 -421.50 -32.33 133.72
GRID 49 -424.50 30.85 138.74
GRID 50 -424.50 32.13 133.67
GRID 65 -424.50 -30.85 138.74
GRID 66 -424.50 -32.13 133.67
CQUAD 17 8 45 46 62 61 0.100 1
CQUAD 18 8 49 50 66 65 0.100 1
CQUAD 19 8 45 49 65 61 0.190 1
CQUAD 20 8 46 50 66 62 0.190 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 3 Right Forward Engine Beam (1st 2 outboard; 2nd 2 inboard)
SECTION 7 3 1 1
GRID 59 -421.50 -45.35 142.87
GRID 60 -421.50 -46.64 137.80
GRID 61 -421.50 -31.04 138.79
GRID 62 -421.50 -32.33 133.72
$COMMENT Forward Engine Beam, Back Side (1st 2 outboard; 2nd 2 inboard)
GRID 63 -424.50 -45.35 142.87
GRID 64 -424.50 -46.64 137.80
GRID 65 -424.50 -30.85 138.74
GRID 66 -424.50 -32.13 133.67
CQUAD 9 8 65 61 59 63 0.190 1
CQUAD 10 8 65 63 64 66 0.100 1
CQUAD 11 8 60 62 66 64 0.190 1
CQUAD 12 8 60 62 61 59 0.100 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 11 Left Aft Engine Beam (1st 2 outboard; 2nd 2 inboard)
SECTION 7 11 1 1
GRID 51 -460.50 45.14 142.88
GRID 52 -460.50 46.68 137.76
GRID 53 -460.50 28.51 138.09
GRID 54 -460.50 29.85 132.97
$COMMENT Left Aft Engine Beam Back Side (1st 2 outboard; 2nd 2 inboard)
GRID 55 -462.50 45.14 142.88
GRID 56 -462.50 46.68 137.76
GRID 57 -462.50 28.38 138.05
GRID 58 -462.50 29.72 132.93
CQUAD 5 8 57 53 51 55 0.160 1
CQUAD 6 8 57 55 56 58 0.064 1
CQUAD 7 8 52 54 58 56 0.100 1
CQUAD 8 8 52 54 53 51 0.064 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 12 Aft Engine Beam through fuselage
SECTION 7 12 1 1
GRID 53 -460.50 28.51 138.09
GRID 54 -460.50 29.85 132.97
GRID 57 -462.50 28.38 138.05
GRID 58 -462.50 29.72 132.93
GRID 69 -460.50 -28.51 138.09
GRID 70 -460.50 -29.85 132.97
GRID 73 -462.50 -28.38 138.05
GRID 74 -462.50 -29.72 132.93
CQUAD 21 8 53 54 70 69 0.064 1
CQUAD 22 8 57 58 74 73 0.064 1
CQUAD 23 8 53 57 73 69 0.160 1
CQUAD 24 8 54 58 74 70 0.100 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 13 Right Aft Engine Beam (1st 2 outboard; 2nd 2 inboard)
SECTION 7 13 1 1
GRID 67 -460.50 -45.14 142.88
GRID 68 -460.50 -46.68 137.76
GRID 69 -460.50 -28.51 138.09
GRID 70 -460.50 -29.85 132.97
$COMMENT Aft Engine Beam Back Side (1st 2 outboard; 2nd 2 inboard)
GRID 71 -462.50 -45.14 142.88
GRID 72 -462.50 -46.68 137.76
GRID 73 -462.50 -28.38 138.05
GRID 74 -462.50 -29.72 132.93
CQUAD 13 8 73 69 67 71 0.160 1
CQUAD 16 8 68 70 69 67 0.064 1
CQUAD 14 8 73 71 72 74 0.064 1
CQUAD 15 8 68 70 74 72 0.100 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$Frames
$COMMENT The number in parenthesis () is the actual location relative to the origin.
$COMMENT The other numbers are the numbers provided by the original source.
$NAME 7 51 Frame at FS 389.5
SECTION 7 51 1 1
GRID 75 -389.50 -0.00 127.25
GRID 76 -390.25 -0.00 127.25
CCONE1 5 8 75 76 0.032 35.163C1
C1 35.113 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 52 Frame at FS 405.5
SECTION 7 52 1 1
GRID 77 -405.50 -0.00 127.25
GRID 78 -406.25 -0.00 127.25
CCONE1 6 8 77 78 0.032 34.092C2
C2 34.042 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 53 Frame at FS 479.5
SECTION 7 53 1 1
GRID 79 -479.50 -0.00 127.25
GRID 80 -480.25 -0.00 127.25
CCONE1 7 8 79 80 0.032 29.138C3
C3 29.087 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 54 Frame at FS 496.5
SECTION 7 54 1 1
GRID 81 -496.50 -0.00 127.25
GRID 82 -497.25 -0.00 127.25
CCONE1 8 8 81 82 0.032 28.00C4
C4 27.95 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 55 Frame at FS 512.5
SECTION 7 55 1 1
GRID 83 -512.50 -0.00 127.25
GRID 84 -513.25 -0.00 127.25
CCONE1 9 8 83 84 0.032 26.928C5
C5 26.846 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$COMMENT Engine Beam Frames
$NAME 7 61 Frame at FS 420.75
SECTION 7 61 1 1
GRID 85 -420.75 -0.00 127.25
GRID 86 -421.50 -0.00 127.25
CCONE1 10 8 85 86 0.032 33.07C6
C6 33.021 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 62 Frame at FS 424.5
SECTION 7 62 1 1
GRID 87 -424.50 -0.00 127.25
GRID 88 -425.25 -0.00 127.25
CCONE1 11 8 87 88 0.032 32.82C7
C7 32.77 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 63 Frame at FS 459.75
SECTION 7 63 1 1
GRID 89 -459.75 -0.00 127.25
GRID 90 -460.50 -0.00 127.25
CCONE1 12 8 89 90 0.032 30.46C8
C8 30.41 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 64 Frame at FS 462.5
SECTION 7 64 1 1
GRID 91 -462.50 -0.00 127.25
GRID 92 -463.25 -0.00 127.25
CCONE1 13 8 91 92 0.032 30.28C9
C9 30.23 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 65 Frame at FS 442.5
$COMMENT (Missing frame--goes between the two engine beam frames)
SECTION 7 65 1 1
GRID 93 -442.50 -0.00 127.25
GRID 94 -443.25 -0.00 127.25
CCONE1 14 8 93 94 0.032 31.615C10
C10 31.565 1 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$COMMENT Stringers
$NAME 7 101 Stringer 1
SECTION 7 101 1 1
GRID 95 -373.75 0.75 91.13
GRID 96 -373.75 -0.75 91.13
GRID 97 -512.50 0.75 100.42
GRID 98 -512.50 -0.75 100.42
CQUAD 15 13 95 96 98 97 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 102 Stringer 2
SECTION 7 102 1 1
GRID 99 -373.75 0.75 163.38
GRID 100 -373.75 -0.75 163.38
GRID 101 -512.50 0.75 154.09
GRID 102 -512.50 -0.75 154.09
CQUAD 16 13 99 100 102 101 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 103 Stringer 3
SECTION 7 103 1 1
GRID 103 -373.75 6.00 162.51
GRID 104 -373.75 7.49 162.24
GRID 105 -512.50 4.25 153.47
GRID 106 -512.50 5.72 153.17
CQUAD 17 13 103 104 106 105 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 104 Stringer 4
SECTION 7 104 1 1
GRID 107 -373.75 -6.00 162.51
GRID 108 -373.75 -7.49 162.24
GRID 109 -512.50 -4.25 153.47
GRID 110 -512.50 -5.72 153.17
CQUAD 18 13 107 108 110 109 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 105 Stringer 5
SECTION 7 105 1 1
GRID 111 -373.75 12.78 160.63
GRID 112 -373.75 14.11 160.05
GRID 113 -512.50 9.22 152.04
GRID 114 -512.50 10.61 151.47
CQUAD 19 13 111 112 114 113 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 106 Stringer 6
SECTION 7 106 1 1
GRID 115 -373.75 -12.78 160.63
GRID 116 -373.75 -14.11 160.05
GRID 117 -512.50 -9.22 152.04
GRID 118 -512.50 -10.61 151.47
CQUAD 20 13 115 116 118 117 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 107 Stringer 7
SECTION 7 107 1 1
GRID 119 -373.75 19.11 157.41
GRID 120 -373.75 20.36 156.57
GRID 121 -512.50 13.95 149.68
GRID 122 -512.50 15.20 148.85
CQUAD 21 13 119 120 122 121 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 108 Stringer 8
SECTION 7 108 1 1
GRID 123 -373.75 -19.12 157.41
GRID 124 -373.75 -20.36 156.57
GRID 125 -512.50 -13.95 149.68
GRID 126 -512.50 -15.20 148.85
CQUAD 22 13 123 124 126 125 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 109 Stringer 9
SECTION 7 109 1 1
GRID 127 -373.75 24.70 153.01
GRID 128 -373.75 25.76 151.95
GRID 129 -512.50 18.13 146.44
GRID 130 -512.50 19.19 145.38
CQUAD 23 13 127 128 130 129 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 110 Stringer 10
SECTION 7 110 1 1
GRID 131 -373.75 -24.70 153.01
GRID 132 -373.75 -25.76 151.95
GRID 133 -512.75 -18.13 146.44
GRID 134 -512.75 -19.19 145.38
CQUAD 24 13 131 132 134 133 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 111 Stringer 11
SECTION 7 111 1 1
GRID 135 -373.75 29.32 147.61
GRID 136 -373.75 30.16 146.37
GRID 137 -512.50 21.60 142.45
GRID 138 -512.50 22.43 141.20
CQUAD 25 13 135 136 138 137 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 112 Stringer 12
SECTION 7 112 1 1
GRID 139 -373.75 -29.32 147.61
GRID 140 -373.75 -30.16 146.37
GRID 141 -512.50 -21.60 142.45
GRID 142 -512.50 -22.43 141.20
CQUAD 26 13 139 140 142 141 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 113 Stringer 13
SECTION 7 113 1 1
GRID 143 -373.75 32.80 141.41
GRID 144 -373.75 33.38 140.03
GRID 145 -512.50 24.22 137.86
GRID 146 -512.50 24.79 136.47
CQUAD 27 13 143 144 146 145 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 114 Stringer 14
SECTION 7 114 1 1
GRID 147 -373.75 -32.80 141.41
GRID 148 -373.75 -33.38 140.03
GRID 149 -512.50 -24.22 137.86
GRID 150 -512.50 -24.80 136.47
CQUAD 28 13 147 148 150 149 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 115 Stringer 15
SECTION 7 115 1 1
GRID 151 -373.75 35.01 134.66
GRID 152 -373.75 35.30 133.19
GRID 153 -512.50 25.90 132.85
GRID 154 -512.50 26.19 131.37
CQUAD 29 13 151 152 154 153 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 116 Stringer 16
SECTION 7 116 1 1
GRID 155 -373.75 -35.01 134.66
GRID 156 -373.75 -35.30 133.19
GRID 157 -512.50 -25.90 132.85
GRID 158 -512.50 -26.19 131.37
CQUAD 30 13 155 156 158 157 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 117 Stringer 17
SECTION 7 117 1 1
GRID 159 -373.75 35.85 127.60
GRID 160 -373.75 35.85 126.10
GRID 161 -512.50 26.56 127.60
GRID 162 -512.50 26.56 126.10
CQUAD 31 13 159 160 162 161 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 118 Stringer 18
SECTION 7 118 1 1
GRID 163 -373.75 -35.85 127.60
GRID 164 -373.75 -35.85 126.10
GRID 165 -512.50 -26.56 127.60
GRID 166 -512.50 -26.56 126.10
CQUAD 32 13 163 164 166 165 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 119 Stringer 19
SECTION 7 119 1 1
GRID 167 -373.75 35.30 121.31
GRID 168 -373.75 35.01 119.84
GRID 169 -512.50 26.19 123.13
GRID 170 -512.50 25.90 121.65
CQUAD 33 13 167 168 170 169 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 120 Stringer 20
SECTION 7 120 1 1
GRID 171 -373.75 -35.30 121.31
GRID 172 -373.75 -35.01 119.84
GRID 173 -512.50 -26.19 123.13
GRID 174 -512.50 -25.90 121.65
CQUAD 34 13 171 172 174 173 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 121 Stringer 21
SECTION 7 121 1 1
GRID 171 -373.75 -35.30 121.31
GRID 172 -373.75 -35.01 119.84
GRID 173 -512.50 -26.19 123.13
GRID 174 -512.50 -25.90 121.65
CQUAD 34 13 171 172 174 173 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 122 Stringer 22
SECTION 7 122 1 1
GRID 175 -373.75 33.38 114.47
GRID 176 -373.75 32.80 113.08
GRID 177 -512.50 24.79 118.03
GRID 178 -512.50 24.22 116.64
CQUAD 35 13 175 176 178 177 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 123 Stringer 23
SECTION 7 123 1 1
GRID 179 -373.75 -33.38 114.47
GRID 180 -373.75 -32.80 113.08
GRID 181 -512.50 -24.80 118.03
GRID 182 -512.50 -24.22 116.64
CQUAD 36 13 179 180 182 181 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 124 Stringer 24
SECTION 7 124 1 1
GRID 183 -373.75 30.16 108.14
GRID 184 -373.75 29.32 106.89
GRID 185 -512.50 22.43 113.30
GRID 186 -512.50 21.60 112.05
CQUAD 37 13 183 184 186 185 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 125 Stringer 25
SECTION 7 125 1 1
GRID 187 -373.75 -30.16 108.14
GRID 188 -373.75 -29.32 106.89
GRID 189 -512.50 -22.43 113.30
GRID 190 -512.50 -21.60 112.05
CQUAD 38 13 187 188 190 189 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 126 Stringer 26
SECTION 7 126 1 1
GRID 191 -373.75 25.76 102.55
GRID 192 -373.75 24.70 101.49
GRID 193 -512.50 19.19 109.12
GRID 194 -512.50 18.13 108.06
CQUAD 39 13 191 192 194 193 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 127 Stringer 27
SECTION 7 127 1 1
GRID 195 -373.75 -25.76 102.55
GRID 196 -373.75 -24.70 101.49
GRID 197 -512.50 -19.19 109.12
GRID 198 -512.50 -18.13 108.06
CQUAD 40 13 195 196 198 197 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 128 Stringer 28
SECTION 7 128 1 1
GRID 199 -373.75 20.36 97.93
GRID 200 -373.75 19.11 97.09
GRID 201 -512.50 15.20 105.65
GRID 202 -512.50 13.95 104.82
CQUAD 41 13 199 200 202 201 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 129 Stringer 29
SECTION 7 129 1 1
GRID 203 -373.75 -20.36 97.93
GRID 204 -373.75 -19.12 97.09
GRID 205 -512.50 -15.20 105.65
GRID 206 -512.50 -13.95 104.82
CQUAD 42 13 203 204 206 205 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 130 Stringer 30
SECTION 7 130 1 1
GRID 207 -373.75 14.16 94.45
GRID 208 -373.75 12.78 93.87
GRID 209 -512.50 10.61 103.03
GRID 210 -512.50 9.22 102.46
CQUAD 43 13 207 208 210 209 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 131 Stringer 31
SECTION 7 131 1 1
GRID 211 -373.75 -14.17 94.45
GRID 212 -373.75 -12.78 93.87
GRID 213 -512.50 -10.61 103.03
GRID 214 -512.50 -9.22 102.46
CQUAD 44 13 211 212 214 213 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 132 Stringer 32
SECTION 7 132 1 1
GRID 215 -373.75 7.41 92.24
GRID 216 -373.75 5.94 91.95
GRID 217 -512.50 5.59 101.35
GRID 218 -512.50 4.13 101.06
CQUAD 45 13 215 216 218 217 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 133 Stringer 33
SECTION 7 133 1 1
GRID 219 -373.75 -7.41 92.24
GRID 220 -373.75 -5.94 91.95
GRID 221 -512.50 -5.59 101.35
GRID 222 -512.50 -4.13 101.06
CQUAD 46 13 219 220 222 221 0.045 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 201 Fairing Structure 1
SECTION 7 201 1 1
GRID 228 -389.50 29.69 78.52
GRID 229 -389.50 -29.69 78.52
GRID 230 -389.50 29.69 108.35
GRID 231 -389.50 -29.69 108.35
CQUAD 11 8 228 229 231 230 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 202 Fairing Structure 2
SECTION 7 202 1 1
GRID 232 -405.50 25.83 81.35
GRID 233 -405.50 -25.83 81.35
GRID 234 -405.50 25.83 104.95
GRID 235 -405.50 -25.83 104.95
CQUAD 12 8 232 233 235 234 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 203 Fairing Structure 3
SECTION 7 203 1 1
GRID 236 -423.00 21.61 84.44
GRID 237 -423.00 -21.61 84.44
GRID 238 -423.00 21.61 102.37
GRID 239 -423.00 -21.61 102.37
CQUAD 13 8 236 237 239 238 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 204 Fairing Structure 4
SECTION 7 204 1 1
GRID 240 -442.50 16.90 87.89
GRID 241 -442.50 -16.90 87.89
GRID 242 -442.50 16.90 100.49
GRID 243 -442.50 -16.90 100.49
CQUAD 14 8 240 241 243 242 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 205 Fairing Structure 5
SECTION 7 205 1 1
GRID 244 -461.50 12.31 91.25
GRID 245 -461.50 -12.31 91.25
GRID 246 -461.50 12.31 99.48
GRID 247 -461.50 -12.31 99.48
CQUAD 15 8 244 245 247 246 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 206 Fairing Structure 6
SECTION 7 206 1 1
GRID 248 -479.50 7.97 94.43
GRID 249 -479.50 -7.97 94.43
GRID 250 -479.50 7.97 99.19
GRID 251 -479.50 -7.97 99.19
CQUAD 16 8 248 249 251 250 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 207 Fairing Structure 7
SECTION 7 207 1 1
GRID 252 -496.50 3.86 97.44
GRID 253 -496.50 -3.86 97.44
GRID 254 -496.50 3.86 99.49
GRID 255 -496.50 -3.86 99.49
CQUAD 17 8 252 253 255 254 0.032 1
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
$NAME 7 501 Pressure Bulkhead
SECTION 7 501 2
GRID 330 -373.25 -0.00 127.25
GRID 331 -373.75 -0.00 127.25
CCONE2 18 8 330 331 36.25C106
C106 36.25 0 0
$COMMENT123456781234567812345678123456781234567812345678123456781234567812345678
ENDDATA
-43
View File
@@ -1,43 +0,0 @@
set(FAA_SAMPLE_MODELS
Business_Jet.fg4
Generic_Twin.fg4
)
macro(ADD_FAA_G_TARGET faa_model folder)
string(REGEX REPLACE "([0-9a-z]*).fg4" "\\1" faa_model_root "${faa_model}")
set(output_file ${bin_root}/${DATA_DIR}/db/${faa_model_root}.g)
set(log_file ${CMAKE_CURRENT_BINARY_DIR}/${faa_model_root}.log)
add_custom_command(
OUTPUT ${output_file}
COMMAND fast4-g ${CMAKE_CURRENT_SOURCE_DIR}/${faa_model} ${output_file} > ${log_file} 2>&1
DEPENDS fast4-g ${CMAKE_CURRENT_SOURCE_DIR}/${faa_model}
)
add_custom_target(${faa_model_root}.g ALL DEPENDS ${output_file})
set_target_properties(${faa_model_root}.g PROPERTIES FOLDER "${folder}")
if(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" output_file "${output_file}")
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
install(FILES ${output_file} DESTINATION ${DATA_DIR}/db)
endif(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
set(BUILT_MODELS "${BUILT_MODELS};${output_file}")
set(LOG_FILES "${LOG_FILES};${log_file}")
endmacro(ADD_FAA_G_TARGET faa_model folder)
foreach(faa_input ${FAA_SAMPLE_MODELS})
ADD_FAA_G_TARGET(${faa_input} "BRL-CAD Geometry Models/Sample")
endforeach(faa_input ${FAA_SAMPLE_MODELS})
CMAKEFILES(
${FAA_SAMPLE_MODELS}
README
)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${BUILT_MODELS}")
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LOG_FILES}")
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8
File diff suppressed because it is too large Load Diff
-8
View File
@@ -1,8 +0,0 @@
For example images of these models, see the report:
Uncontained Engine Debris Analysis Using the Uncontained
Engine Debris Damage Assessment Model
DOT/FAA/AR-04/16
Office of Aviation Research
Washington, D.C. 20591
http://www.tc.faa.gov/its/worldpac/techrpt/AR04-16.pdf
-81
View File
@@ -1,81 +0,0 @@
set(NIST_SAMPLE_STEP_MODELS
NIST_MBE_PMI_1.stp
NIST_MBE_PMI_2.stp
NIST_MBE_PMI_3.stp
NIST_MBE_PMI_4.stp
NIST_MBE_PMI_5.stp
NIST_MBE_PMI_6.stp
NIST_MBE_PMI_11.stp
)
set(NIST_SAMPLE_3DM_MODELS
NIST_MBE_PMI_7-10.3dm
)
macro(ADD_NIST_STEP_TARGET step_model folder)
string(REGEX REPLACE "([0-9a-z]*).stp" "\\1" step_model_root "${step_model}")
set(output_file ${bin_root}/${DATA_DIR}/db/${step_model_root}.g)
set(log_file ${CMAKE_CURRENT_BINARY_DIR}/${step_model_root}.log)
add_custom_command(
OUTPUT ${output_file}
COMMAND step-g -O ${output_file} ${CMAKE_CURRENT_SOURCE_DIR}/${step_model} > ${log_file} 2>&1
DEPENDS step-g ${CMAKE_CURRENT_SOURCE_DIR}/${step_model}
)
add_custom_target(${step_model_root}.g ALL DEPENDS ${output_file})
set_target_properties(${step_model_root}.g PROPERTIES FOLDER "${folder}")
if(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" output_file "${output_file}")
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
install(FILES ${output_file} DESTINATION ${DATA_DIR}/db)
endif(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
set(BUILT_MODELS "${BUILT_MODELS};${output_file}")
set(LOG_FILES "${LOG_FILES};${log_file}")
endmacro(ADD_NIST_STEP_TARGET step_model folder)
macro(ADD_NIST_3DM_TARGET rhino_model folder)
string(REGEX REPLACE "([0-9a-z]*).3dm" "\\1" rhino_model_root "${rhino_model}")
set(output_file ${bin_root}/${DATA_DIR}/db/${rhino_model_root}.g)
set(log_file ${CMAKE_CURRENT_BINARY_DIR}/${rhino_model_root}.log)
add_custom_command(
OUTPUT ${output_file}
COMMAND 3dm-g -o ${output_file} ${CMAKE_CURRENT_SOURCE_DIR}/${rhino_model} > ${log_file} 2>&1
DEPENDS 3dm-g ${CMAKE_CURRENT_SOURCE_DIR}/${rhino_model}
)
add_custom_target(${rhino_model_root}.g ALL DEPENDS ${output_file})
set_target_properties(${rhino_model_root}.g PROPERTIES FOLDER "${folder}")
if(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" output_file "${output_file}")
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL "." AND CMAKE_CONFIGURATION_FILES)
install(FILES ${output_file} DESTINATION ${DATA_DIR}/db)
endif(BRLCAD_INSTALL_EXAMPLE_GEOMETRY)
set(BUILT_MODELS "${BUILT_MODELS};${output_file}")
set(LOG_FILES "${LOG_FILES};${log_file}")
endmacro(ADD_NIST_3DM_TARGET rhino_model folder)
foreach(step_input ${NIST_SAMPLE_STEP_MODELS})
ADD_NIST_STEP_TARGET(${step_input} "BRL-CAD Geometry Models/Sample")
endforeach(step_input ${NIST_SAMPLE_STEP_MODELS})
CMAKEFILES(${NIST_SAMPLE_STEP_MODELS})
foreach(rhino_input ${NIST_SAMPLE_3DM_MODELS})
ADD_NIST_3DM_TARGET(${rhino_input} "BRL-CAD Geometry Models/Sample")
endforeach(rhino_input ${NIST_SAMPLE_3DM_MODELS})
CMAKEFILES(${NIST_SAMPLE_3DM_MODELS})
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${BUILT_MODELS}")
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LOG_FILES}")
CMAKEFILES(
README
pdf
)
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
-37
View File
@@ -1,37 +0,0 @@
December 2014:
The files in this directory are conversions of the NIST MBE PMI test models
into the AP203 file format. These conversions are also in the public domain.
Originals are from http://www.nist.gov/el/msid/infotest/mbe-pmi-validation.cfm
Models 7 through 10 have been assembled into a single file, guided by the example
PDF provided with the original NIST data set.
MBE PMI Validation and Conformance Testing Models
NIST has created a Test System to measure conformance of Computer-Aided Design
(CAD) to American Society of Mechanical Engineers (ASME) standards for Product
and Manufacturing Information (PMI), specifically geometric dimensioning and
tolerancing (GD&T) information.
As part of this Test System, CAD Models were prepared.
For problems or questions about the MBE PMI CAD Models, contact: Robert Lipman
Dataset 1 First Release: December 2013
Dataset 1 Update Release: December 2014 (Note: Dataset 1 files currently in
BRL-CAD repo are based off of the
2013 version.)
Dataset 2 First Release: June 2015
These files were developed at the National Institute of Standards and
Technology by employees of the Federal Government in the course of their
official duties. Pursuant to Title 17 Section 105 of the United States Code
these files are not subject to copyright protection and are in the public
domain. These files are an experimental system. NIST assumes no responsibility
whatsoever for their use by other parties, and makes no guarantees, expressed
or implied, about their quality, reliability, or any other characteristic.
Any mention of commercial products is for information only; it does not imply
recommendation or endorsement by NIST.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
@@ -92,8 +92,8 @@
are combined using boolean operations to form regions of homogeneous material.
</para>
<para>
The database is organized as a <emphasis>directed acyclic graph</emphasis> (DAG), which
comprises
The database is organized as a <emphasis>directed acyclic graph</emphasis> (DAG), which is
comprised of:
<itemizedlist>
<listitem>
@@ -107,7 +107,7 @@
</para>
</listitem>
<listitem>
<para><emphasis>arcs</emphasis> - contain boolean operators and 4x4 homogeneous transformation matrices.</para>
<para><emphasis>arcs</emphasis> - containing boolean operators and 4x4 homogeneous transformation matrices.</para>
</listitem>
</itemizedlist>
</para>
@@ -1600,14 +1600,6 @@
place of anameN+1 signals the end of the ASCII attribute data.
</para>
<para>
PROPOSED: A second type of attribute has an ASCII key but a binary value.
Such attributes follow the ASCII-valued ones after the double NULLs:
<literallayout class="normal">anameN+1 NULL uintN &lt;uintN binary bytes&gt; [...0 or more binary attribute pairs]</literallayout>
where, for each binary attribute pair, the uintN is of size AWid and is
the length of the binary value for its ASCII key.
</para>
<para>
Every object in the database may have zero or more attributes
attached to it; the meaning of these attributes will vary
File diff suppressed because it is too large Load Diff
@@ -1,11 +1,18 @@
set(docbook_specifications_EN
BRL_CAD_g_format_V5.xml
)
set(docbook_specifications_EN_V6
BRL_CAD_g_format_V6.xml
)
DOCBOOK_TO_HTML(specification docbook_specifications_EN html/specifications/en "")
DOCBOOK_TO_PHP(specification docbook_specifications_EN html/specifications/en "")
DOCBOOK_TO_PDF(specification docbook_specifications_EN pdf/specifications/en "")
DOCBOOK_TO_HTML(specification docbook_specifications_EN_V6 html/specifications/en "")
DOCBOOK_TO_PHP(specification docbook_specifications_EN_V6 html/specifications/en "")
DOCBOOK_TO_PDF(specification docbook_specifications_EN_V6 pdf/specifications/en "")
# Local Variables:
# tab-width: 8
# mode: cmake
+27 -1
View File
@@ -66,7 +66,7 @@ objects.
<term><emphasis remap="B" role="bold">set</emphasis></term>
<listitem>
<para>
Assigned the value provied for the specified attribute to the object or objects matched by the pattern. The arguments for "set" sub-command are attribute name/value pairs.
Assigned the value provided for the specified attribute to the object or objects matched by the pattern. The arguments for "set" sub-command are attribute name/value pairs.
</para>
</listitem>
</varlistentry>
@@ -176,6 +176,32 @@ objects.
</example>
</refsection>
<refsection xml:id="binary-attributes"><title>BINARY ATTRIBUTES</title>
<para>
A new feature is the capability of adding binary attributes which
consist of a name as with normal attributes, but the value is an
unsigned integer (of minimum width to describe the total length of
the following struct) followed by a struct containing (1) an
optional, null-terminated description and (2) a "uniform array
binary object" which is defined as a contiguous
stream of one of the following integers (with its macro name in
parentheses):
</para>
<itemizedlist>
<listitem>8-bit signed ()</listitem>
<listitem>8-bit unsigned ()</listitem>
<listitem>16-bit signed ()</listitem>
<listitem>16-bit unsigned ()</listitem>
<listitem>32-bit signed ()</listitem>
<listitem>32-bit unsigned ()</listitem>
<listitem>64-bit signed ()</listitem>
<listitem>64-bit unsigned ()</listitem>
</itemizedlist>
</refsection>
<refsection xml:id="see_also"><title>SEE ALSO</title>
<para><citerefentry><refentrytitle>attributes</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
</refsection>
+54 -42
View File
@@ -1,90 +1,102 @@
add_subdirectory(bu)
add_subdirectory(bn)
add_subdirectory(bg)
add_subdirectory(dm)
add_subdirectory(gcv)
add_subdirectory(optical)
add_subdirectory(rt)
add_subdirectory(fb)
set(public_hdrs
bio.h
bresource.h
bsocket.h
set(include_hdrs
${CMAKE_CURRENT_BINARY_DIR}/brlcad_config.h
RtServerImpl.h
bn.h
bu.h
bg.h
common.h
cursor.h
ged.h
magic.h
pstdint.h
raytrace.h
rt/defines.h
rtfunc.h
rtgeom.h
rtserver.h
tclcad.h
analyze.h
anim.h
bot.h
brep.h
brlcad.h
brlcad.i
cmd.h
db.h
db5.h
dg.h
dm-Null.h
dm-X.h
dm-glx.h
dm-ogl.h
dm-pex.h
dm-plot.h
dm-ps.h
dm-qt.h
dm-rtgl.h
dm-tk.h
dm-wgl.h
dm.h
dm_color.h
dm_xvars.h
dvec.h
fb.h
fbio.h
fbserv_obj.h
fft.h
gcv.h
icv.h
libtermio.h
light.h
mater.h
nmg.h
nurb.h
obj.h
optical.h
orle.h
photonmap.h
pc.h
pkg.h
plastic.h
plot3.h
redblack.h
shadefuncs.h
shadework.h
solid.h
spectrum.h
spm.h
tie.h
tol.h
vectfont.h
vector_fpu.h
vector_x86.h
vfont-if.h
vmath.h
wdb.h
)
CMAKEFILES(${public_hdrs})
install(FILES ${public_hdrs} DESTINATION ${INCLUDE_DIR}/brlcad)
# Configuration headers
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/brlcad_config.h DESTINATION ${INCLUDE_DIR}/brlcad)
if(WIN32)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config_win.h DESTINATION ${INCLUDE_DIR}/brlcad)
set(include_hdrs ${include_hdrs} ${CMAKE_CURRENT_BINARY_DIR}/config_win_cmake.h)
endif(WIN32)
install(FILES ${include_hdrs} DESTINATION ${INCLUDE_DIR}/brlcad)
# headers used by multiple packages but still considered private.
# public headers should NOT include these headers.
set(noinst_HEADERS
bnetwork.h
brlcad_ident.h
bin.h
bio.h
brlcad_version.h
bselect.h
conf.h
fbmsg.h
sysv.h
)
CMAKEFILES(${noinst_HEADERS})
# Enforce the above list - check the public headers to make sure
# they do not include any private headers.
#set(inc_error 0)
#set(msgs "")
#foreach(header_file ${public_hdrs})
# file(READ "${header_file}" contents)
# foreach(noinst_file ${noinst_HEADERS})
# if("${contents}" MATCHES "include [\"<]${noinst_file}")
# set(inc_error 1)
# set(msgs "${msgs}\nPublic header file ${header_file} is including private header ${noinst_file}")
# endif("${contents}" MATCHES "include [\"<]${noinst_file}")
# endforeach(noinst_file ${noinst_HEADERS})
#endforeach(header_file ${public_hdrs})
#if(inc_error)
# message(FATAL_ERROR "${msgs}\nFATAL ERROR: Public headers are including private headers per messages above.")
#endif(inc_error)
set(include_misc
conf
config_win.h.in
config_win.h
config_win_cmake.h.in
)
CMAKEFILES(${include_hdrs})
CMAKEFILES(${noinst_HEADERS})
CMAKEFILES(${include_misc})
# Local Variables:
+5 -54
View File
@@ -1,7 +1,7 @@
/* A N A L Y Z E . H
* BRL-CAD
*
* Copyright (c) 2008-2014 United States Government as represented by
* Copyright (c) 2008-2013 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
@@ -23,10 +23,8 @@
*
*/
#ifndef ANALYZE_H
#define ANALYZE_H
#include "common.h"
#ifndef __ANALYZE_H__
#define __ANALYZE_H__
#include "raytrace.h"
@@ -123,59 +121,12 @@ ANALYZE_EXPORT extern struct region_pair *add_unique_pair(struct region_pair *li
* voxelize function takes raytrace instance and user parameters as inputs
*/
ANALYZE_EXPORT extern void
voxelize(struct rt_i *rtip, fastf_t voxelSize[3], int levelOfDetail, void (*create_boxes)(void *callBackData, int x, int y, int z, const char *regionName, fastf_t percentageFill), void *callBackData);
struct analyze_raydiff_results {
struct bu_ptbl *left;
struct bu_ptbl *right;
struct bu_ptbl *both;
};
struct diff_seg {
point_t in_pt;
point_t out_pt;
struct xray ray;
int valid;
};
ANALYZE_EXPORT int
analyze_raydiff(struct analyze_raydiff_results **results, struct db_i *dbip,
const char *left, const char *right, struct bn_tol *tol, int solidcheck);
ANALYZE_EXPORT void
analyze_raydiff_results_free(struct analyze_raydiff_results *results);
ANALYZE_EXPORT int
analyze_obj_inside(struct db_i *dbip, const char *outside, const char *inside, fastf_t tol);
typedef int (*hitfunc_t)(struct application *, struct partition *, struct seg *);
typedef int (*missfunc_t)(struct application *);
typedef int (*overlapfunc_t)(struct application *, struct partition *, struct region *, struct region *, struct partition *);
struct rt_gen_worker_vars {
struct rt_i *rtip;
struct resource *resp;
int rays_cnt;
const fastf_t *rays;
hitfunc_t fhit;
missfunc_t fmiss;
overlapfunc_t foverlap;
int step; /* number of rays to be fired by this worker before calling back */
int *ind_src; /* source of starting index */
int curr_ind; /* current ray index */
void *ptr; /* application specific info */
};
ANALYZE_EXPORT int
analyze_find_subtracted(struct bu_ptbl *results, struct rt_wdb *wdbp,
const char *pbrep, struct rt_gen_worker_vars *pbrep_rtvars,
const char *curr_comb, struct bu_ptbl *candidates, void *curr_union_data, int ncpus);
voxelize(struct rt_i *rtip, fastf_t voxelSize[3], int levelOfDetail, void (*create_boxes)(genptr_t callBackData, int x, int y, int z, const char *regionName, fastf_t percentageFill), genptr_t callBackData);
__END_DECLS
#endif /* ANALYZE_H */
#endif /* __ANALYZE_H__ */
/*
* Local Variables:
+133
View File
@@ -0,0 +1,133 @@
/* A N I M . H
* BRL-CAD
*
* Copyright (c) 1993-2013 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 anim */
/** @{ */
/** @file anim.h
*
*
*/
#ifndef __ANIM_H__
#define __ANIM_H__
#include "vmath.h"
#define ANIM_STEER_NEW 0
#define ANIM_STEER_END 1
#define VSUBUNIT(a, b, c) {VSUB2(a, b, c);\
VUNITIZE(a);}
#define FVSCAN(f, a) fscanf(f, "%lf %lf %lf", (a), (a)+1, (a)+2)
#define FMATSCAN(f, m) {FVSCAN(f, (m)); FVSCAN(f, (m)+4);\
FVSCAN(f, (m)+8); FVSCAN(f, (m)+12);}
#define VSCAN(a) scanf("%lf %lf %lf", (a), (a)+1, (a)+2)
#define VPRINTS(t, a) printf("%s %f %f %f ", t, (a)[0], (a)[1], (a)[2])
#define VPRINTN(t, a) printf("%s %f %f %f\n", t, (a)[0], (a)[1], (a)[2])
#define MAT_MOVE(m, n) MAT_COPY(m, n)
/***** 3x3 matrix format *****/
typedef fastf_t mat3_t[9];
#define MAT3ZERO(m) {\
int _j; for (_j=0;_j<9;_j++) m[_j]=0.0;}
#define MAT3IDN(m) {\
int _j; for (_j=0;_j<9;_j++) m[_j]=0.0;\
m[0] = m[4] = m[8] = 1.0;}
#define MAT3MUL(o, a, b) {\
(o)[0] = (a)[0]*(b)[0] + (a)[1]*(b)[3] + (a)[2]*(b)[6];\
(o)[1] = (a)[0]*(b)[1] + (a)[1]*(b)[4] + (a)[2]*(b)[7];\
(o)[2] = (a)[0]*(b)[2] + (a)[1]*(b)[5] + (a)[2]*(b)[8];\
(o)[3] = (a)[3]*(b)[0] + (a)[4]*(b)[3] + (a)[5]*(b)[6];\
(o)[4] = (a)[3]*(b)[1] + (a)[4]*(b)[4] + (a)[5]*(b)[7];\
(o)[5] = (a)[3]*(b)[2] + (a)[4]*(b)[5] + (a)[5]*(b)[8];\
(o)[6] = (a)[6]*(b)[0] + (a)[7]*(b)[3] + (a)[8]*(b)[6];\
(o)[7] = (a)[6]*(b)[1] + (a)[7]*(b)[4] + (a)[8]*(b)[7];\
(o)[8] = (a)[6]*(b)[2] + (a)[7]*(b)[5] + (a)[8]*(b)[8];}
#define MAT3SUM(o, a, b) {\
int _j; for (_j=0;_j<9;_j++) (o)[_j]=(a)[_j]+(b)[_j];}
#define MAT3DIF(o, a, b) {\
int _j; for (_j=0;_j<9;_j++) (o)[_j]=(a)[_j]-(b)[_j];}
#define MAT3SCALE(o, a, s) {\
int _j; for (_j=0;_j<9;_j++) (o)[_j]=(a)[_j] * (s);}
#define MAT3MOVE(o, a) {\
int _j; for (_j=0;_j<9;_j++) (o)[_j] = (a)[_j];}
#define MAT3XVEC(u, m, v) {\
(u)[0] = (m)[0]*(v)[0] + (m)[1]*(v)[1] + (m)[2]*(v)[2];\
(u)[1] = (m)[3]*(v)[0] + (m)[4]*(v)[1] + (m)[5]*(v)[2];\
(u)[2] = (m)[6]*(v)[0] + (m)[7]*(v)[1] + (m)[8]*(v)[2];}
#define MAT3TO4(o, i) {\
(o)[0] = (i)[0];\
(o)[1] = (i)[1];\
(o)[2] = (i)[2];\
(o)[4] = (i)[3];\
(o)[5] = (i)[4];\
(o)[6] = (i)[5];\
(o)[8] = (i)[6];\
(o)[9] = (i)[7];\
(o)[10] = (i)[8];\
(o)[3]=(o)[7]=(o)[11]=(o)[12]=(o)[13]=(o)[14]=0.0;\
(o)[15]=1.0;}
#define MAT4TO3(o, i) {\
(o)[0] = (i)[0];\
(o)[1] = (i)[1];\
(o)[2] = (i)[2];\
(o)[3] = (i)[4];\
(o)[4] = (i)[5];\
(o)[5] = (i)[6];\
(o)[6] = (i)[8];\
(o)[7] = (i)[9];\
(o)[8] = (i)[10];}
/* tilde matrix: [M]a = v X a */
#define MAKE_TILDE(m, v) {\
MAT3ZERO(m);\
m[1]= -v[2]; m[2]=v[1]; m[3]= v[2];\
m[5]= -v[0]; m[6]= -v[1]; m[7]= v[0];}
/* a = Ix Iy Iz b = Ixy Ixz Iyz*/
#define INERTIAL_MAT3(m, a, b) {\
(m)[0] = (a)[0]; (m)[1] = -(b)[0]; (m)[2] = -(b)[1];\
(m)[3] = -(b)[0]; (m)[4] = (a)[1]; (m)[5] = -(b)[2];\
(m)[6] = -(b)[1]; (m)[7] = -(b)[2]; (m)[8]= (a)[2];}
#endif /* __ANIM_H__ */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-69
View File
@@ -1,69 +0,0 @@
/* G M . H
* BRL-CAD
*
* Copyright (c) 2015 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 libbg
*
* @brief
* BRL-CAD geometry library. This library is intended for generic
* geometry algorithms, such as point-in-polygon, does a line
* intersect a sphere, ear clipping triangulation of a polygon, etc.
*
* Algorithms in this library should not require solid raytracing
* of the BRL-CAD CSG boolean hierarchy - routines using those high
* level constructs should be in libanalyze, which uses librt to
* do the necessary raytracing. libbg is lower level, and should
* depend only on the numerics library (libbn) and the libbu utility
* (libbu)
*
* Strictly numerical algorithms, which do not involve 3D geometry
* concepts, belong in libbn. An example of something that would belong
* in libbn would be sparse matrix solving.
*
* The functionality provided by this library is specified in the bg.h
* header or appropriate included files from the ./bg subdirectory.
*/
/** @{ */
/** @brief Header file for the BRL-CAD Geometry Library, LIBGM.*/
/** @file bg.h */
/** @} */
#ifndef GM_H
#define GM_H
#include "common.h"
#include "bg/defines.h"
#include "bg/chull.h"
#include "bg/obr.h"
#include "bg/polygon.h"
#include "bg/tri_ray.h"
#include "bg/tri_tri.h"
#endif /* GM_H */
/*
* Local Variables:
* tab-width: 8
* mode: C
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-19
View File
@@ -1,19 +0,0 @@
set(bg_headers
defines.h
chull.h
obr.h
polygon.h
tri_ray.h
tri_tri.h
)
install(FILES ${bg_headers} DESTINATION ${INCLUDE_DIR}/brlcad/bg)
CMAKEFILES(${bg_headers})
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8
-139
View File
@@ -1,139 +0,0 @@
/* C H U L L . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
/*----------------------------------------------------------------------*/
/* @file chull.h */
/** @addtogroup chull */
/** @{ */
/**
* @brief Routines for the computation of convex hulls in 2D and 3D
*/
#ifndef BG_CHULL_H
#define BG_CHULL_H
#include "common.h"
#include "vmath.h"
#include "bg/defines.h"
__BEGIN_DECLS
/**
* @brief
* Melkman's 2D simple polyline O(n) convex hull algorithm
*
* On-line construction of the convex hull of a simple polyline
* Melkman, Avraham A. Information Processing Letters 25.1 (1987): 11-12.
*
* See also <a href="http://geomalgorithms.com/a12-_hull-3.html">http://geomalgorithms.com/a12-_hull-3.html</a>
*
* @param[out] hull convex hull array vertices in ccw orientation (max is n)
* @param polyline The points defining the input polyline, stored with ccw orientation
* @param n the number of points in polyline
* @return the number of points in the output hull array
*/
BG_EXPORT int bg_polyline_2d_chull(point2d_t** hull, const point2d_t* polyline, int n);
/**
* @brief
* Find 2D convex hull for unordered co-planar point sets
*
* The monotone chain algorithm's sorting approach is used to do
* the initial ordering of the points:
*
* Another efficient algorithm for convex hulls in two dimensions.
* Andrew, A. M. Information Processing Letters 9.5 (1979): 216-219.
*
* See also <a href="http://geomalgorithms.com/a10-_hull-1.html">http://geomalgorithms.com/a10-_hull-1.html</a>
*
* From there, instead of using the monotonic chain hull assembly
* step, recognize that the points thus ordered can be viewed as
* defining a simple polyline and use Melkman's algorithm for the
* hull building.
*
* The input point array currently uses type point_t, but all Z
* values should be zero.
*
* @param[out] hull 2D convex hull array vertices in ccw orientation (max is n)
* @param points_2d The input 2d points for which a convex hull will be built
* @param n the number of points in the input set
* @return the number of points in the output hull array or zero if error.
*/
BG_EXPORT int bg_2d_chull(point2d_t** hull, const point2d_t* points_2d, int n);
/**
* @brief
* Find 3D coplanar point convex hull for unordered co-planar point sets
*
* This function assumes an input an array of 3D points which are coplanar
* in some arbitrary plane. This function:
*
* 1. Finds the plane that fits the points and picks an origin, x-axis and y-axis
* which allow 2D coordinates for all points to be calculated.
* 2. Calls 2D routines on the array found by step 1 to get a 2D convex hull
* 3. Translates the resultant 2D hull points back into 3D points so the hull array
* contains the bounding hull expressed in the 3D coordinate space of the
* original points.
*
* @param[out] hull convex hull array vertices using 3-space coordinates in ccw orientation (max is n)
* @param points_3d The input points for which a convex hull will be built
* @param n the number of points in the input set
* @return the number of points in the output hull array
*/
BG_EXPORT int bg_3d_coplanar_chull(point_t** hull, const point_t* points_3d, int n);
/**
* @brief
* Find 3D point convex hull for unordered point sets
*
* This routine computes the convex hull of a three dimensional point set and
* returns the set of vertices and triangular faces that define that hull, as
* well as the numerical count of vertices and faces in the hull.
*
* @param[out] faces set of faces in the convex hull, stored as integer indices to the vertices. The first three indices are the vertices of the face, the second three define the second face, and so forth.
* @param[out] num_faces the number of faces in the faces array
* @param[out] vertices the set of vertices used by the convex hull.
* @param[out] num_vertices the number of vertices in the convex hull.
* @param input_points_3d The input points for which a convex hull will be built
* @param num_input_pnts the number of points in the input set
* @return dimension of output (3 is three dimensional faces and hulls, 2 is a polygon hull in a plane, etc.)
*
* This routine is based off of Ken Clarkson's hull program from
* http://www.netlib.org/voronoi/hull.html - see the file chull3d.c
* for the full copyright and license statement.
*/
BG_EXPORT int bg_3d_chull(int **faces, int *num_faces, point_t **vertices, int *num_vertices,
const point_t *input_points_3d, int num_input_pnts);
__END_DECLS
#endif /* BG_CHULL_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-60
View File
@@ -1,60 +0,0 @@
/* D E F I N E S . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bg_defines
* @brief
* Common definitions for the headers used in bg.h (i.e. the headers found in include/bg)
*/
/** @{ */
/** @file bg/defines.h */
#ifndef BG_DEFINES_H
#define BG_DEFINES_H
#include "common.h"
#ifndef BG_EXPORT
# if defined(BG_DLL_EXPORTS) && defined(BG_DLL_IMPORTS)
# error "Only BG_DLL_EXPORTS or BG_DLL_IMPORTS can be defined, not both."
# elif defined(BG_DLL_EXPORTS)
# define BG_EXPORT __declspec(dllexport)
# elif defined(BG_DLL_IMPORTS)
# define BG_EXPORT __declspec(dllimport)
# else
# define BG_EXPORT
# endif
#endif
/* Definitions for clockwise and counter-clockwise loop directions */
#define BG_CW 1
#define BG_CCW -1
#endif /* BG_DEFINES_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-159
View File
@@ -1,159 +0,0 @@
/* O B R . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
/*----------------------------------------------------------------------*/
/* @file obr.h */
/** @addtogroup obr */
/** @{ */
/**
* @brief Routines for the computation of oriented bounding rectangles 2D and 3D
*/
#ifndef BG_OBR_H
#define BG_OBR_H
#include "common.h"
#include "vmath.h"
#include "bg/defines.h"
__BEGIN_DECLS
/**
*@brief
* Uses the Rotating Calipers algorithm to find the
* minimum oriented bounding rectangle for a set of 2D
* points. Returns 0 on success.
*
* The box will be described by a center point and 2
* vectors:
*
* \verbatim
* ----------------------------
* | ^ |
* | | |
* | v | |
* | | |
* | *------------>|
* | center u |
* | |
* | |
* ----------------------------
* \endverbatim
*
* Note that the box is oriented, and thus not necessarily axis
* aligned (u and v are perpendicular, but not necessarily parallel
* with the coordinate space V=0 and U=0 axis vectors.)
*
* @param[out] center center of oriented bounding rectangle
* @param[out] u vector in the direction of obr x with
* vector length of 0.5 * obr length
* @param[out] v vector in the obr y direction with vector
* length of 0.5 * obr width
* @param points_2d array of 2D points
* @param pnt_cnt number of points in pnts array
*/
BG_EXPORT extern int bg_2d_obr(point2d_t *center,
vect2d_t *u,
vect2d_t *v,
const point2d_t *points_2d,
int pnt_cnt);
/**
*@brief
* Uses the Rotating Calipers algorithm to find the
* minimum oriented bounding rectangle for a set of coplanar 3D
* points. Returns 0 on success.
*
* @param[out] center center of oriented bounding rectangle
* @param[out] v1 vector in the direction of obr x with
* vector length of 0.5 * obr length
* @param[out] v2 vector in the obr y direction with vector
* length of 0.5 * obr width
* @param points_3d array of coplanar 3D points
* @param pnt_cnt number of points in pnts array
*/
BG_EXPORT extern int bg_3d_coplanar_obr(point_t *center,
vect_t *v1,
vect_t *v2,
const point_t *points_3d,
int pnt_cnt);
/**
*@brief
* Find the minimum oriented bounding rectangular cuboid
* for a set of 3D points. Returns 0 on success.
*
* TODO - the GeometricTools engine has an implementation
* of the stack needed to do this - want to look not only
* at their MinimumVolumeBox3 implementation but the supporting
* convex hull 3d routines to see if they're an improvement
* on the Clarkson implementation. Also want to check their
* obb/obb intersection test (GteIntrOrientedBox3OrientedBox3.h)
*
* http://www.geometrictools.com/GTEngine/Include/GteMinimumVolumeBox3.h
*
* The points in the output array are arranged as seen
* in the figure below, with the integer number at each
* vertex position corresponding to the pnts array index
* n-1 (for example, the first point, labeled 1 below,
* would be pnts[0].)
*
* \verbatim
* 8
* * | *
* * | *
* 4 | 7
* | * | * |
* | * * |
* | | 3 |
* | | | |
* | 5 | |
* | * |* |
* | * | * |
* 1 | 6
* * | *
* * | *
* 2
* \endverbatim
*
*
* @param[out] pnts eight points of oriented bounding box
* @param points_3d array of coplanar 3D points
* @param pnt_cnt number of points in pnts array
*/
BG_EXPORT extern int bg_3d_obb(point_t **pnts,
const point_t *points_3d,
int pnt_cnt);
__END_DECLS
#endif /* BG_OBR_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-247
View File
@@ -1,247 +0,0 @@
/* P O L Y G O N . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
/*----------------------------------------------------------------------*/
/* @file polygon.h */
/** @addtogroup polygon */
/** @{ */
/**
* @brief Functions for working with polygons
*/
#ifndef BG_POLYGON_H
#define BG_POLYGON_H
#include "common.h"
#include "vmath.h"
#include "bg/defines.h"
__BEGIN_DECLS
/*********************************************************
Operations on 2D point types
*********************************************************/
/**
* @brief
* Test whether a polygon is clockwise (CW) or counter clockwise (CCW)
*
* Determine if a set of points forming a polygon are in clockwise
* or counter-clockwise order (see http://stackoverflow.com/a/1165943)
*
* @param[in] npts number of points in polygon
* @param[in] pts array of points
* @param[in] pt_indices index values into pts array building a convex polygon. duplicated points
* aren't allowed.
*
* If pt_indices is NULL, the first npts points in pts will be checked in array order.
*
* @return BG_CCW if polygon is counter-clockwise
* @return BG_CW if polygon is clockwise
* @return 0 if the test failed
*/
BG_EXPORT extern int bg_polygon_direction(size_t npts, const point2d_t *pts, const int *pt_indices);
/**
* @brief
* test whether a point is inside a 2d polygon
*
* franklin's test for point inclusion within a polygon - see
* http://www.ecse.rpi.edu/homepages/wrf/research/short_notes/pnpoly.html
* for more details and the implementation file polygon.c for license info.
*
* @param[in] npts number of points pts contains
* @param[in] pts array of points, building a convex polygon. duplicated points
* aren't allowed. the points in the array will be sorted counter-clockwise.
* @param[in] test_pt point to test.
*
* @return 0 if point is outside polygon
* @return 1 if point is inside polygon
*/
BG_EXPORT extern int bg_pt_in_polygon(size_t npts, const point2d_t *pts, const point2d_t *test_pt);
/**
* Triangulation is the process of finding a set of triangles that as a set cover
* the same total surface area as a polygon. There are many algorithms for this
* operation, which have various trade-offs in speed and output quality.
*
* Ear clipping is implemented here in a manner similar to the method
* documented in David Eberly's Triangulation by Ear Clipping, section 2:
* http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
*
*/
typedef enum {
EAR_CLIPPING = 0,
MONOTONE,
HERTEL_MEHLHORN,
KEIL_SNOEYINK,
DELAUNAY
} triangulation_t;
/**
* @brief
* Triangulate a 2D polygon with holes.
*
* The primary polygon definition must be provided as an array of
* counter-clockwise indices to 2D points. If interior "hole" polygons are
* present, they must be passed in via the holes_array and their indices be
* ordered clockwise.
*
* If no holes are present, caller should pass NULL for holes_array and holes_npts,
* and 0 for nholes, or use bg_polygon_triangulate instead.
*
* @param[out] faces Set of faces in the triangulation, stored as integer indices to the pts. The first three indices are the vertices of the first face, the second three define the second face, and so forth.
* @param[out] num_faces Number of faces created
* @param[out] out_pts output points used by faces set, if an algorithm was selected that generates new points
* @param[out] num_outpts number of output points, if an algorithm was selected that generates new points
* @param[in] poly Non-hole polygon, defined as a CCW array of indices into the pts array.
* @param[in] poly_npts Number of points in non-hole polygon
* @param[in] holes_array Array of hole polygons, each defined as a CW array of indices into the pts array.
* @param[in] holes_npts Array of counts of points in hole polygons
* @param[in] nholes Number of hole polygons contained in holes_array
* @param[in] pts Array of points defining a polygon. Duplicated points
* @param[in] npts Number of points pts contains
*
* @return 0 if triangulation is successful
* @return 1 if triangulation is unsuccessful
*/
BG_EXPORT extern int bg_nested_polygon_triangulate(int **faces, int *num_faces, point2d_t **out_pts, int *num_outpts,
const int *poly, const size_t poly_npts,
const int **holes_array, const size_t *holes_npts, const size_t nholes,
const point2d_t *pts, const size_t npts, triangulation_t type);
/**
* @brief
* Triangulate a 2D polygon without holes.
*
* The polygon cannot have holes and must be provided as an array of
* counter-clockwise 2D points.
*
* No points are added as part of this triangulation process - the result uses
* only those points in the original polygon, and hence only the face
* information is created as output.
*
* The same fundamental routines are used here as in the bg_nested_polygon_triangulate
* logic - this is a convenience function to simplify calling the routine when
* specification of hole polygons is not needed.
*
* @param[out] faces Set of faces in the triangulation, stored as integer indices to the pts. The first three indices are the vertices of the first face, the second three define the second face, and so forth.
* @param[out] num_faces Number of faces created
* @param[out] out_pts output points used by faces set, if an algorithm was selected that generates new points
* @param[out] num_outpts number of output points, if an algorithm was selected that generates new points
* @param[in] pts Array of points defining a polygon. Duplicated points
* @param[in] npts Number of points pts contains
*
* @return 0 if triangulation is successful
* @return 1 if triangulation is unsuccessful
*/
BG_EXPORT extern int bg_polygon_triangulate(int **faces, int *num_faces, point2d_t **out_pts, int *num_outpts,
const point2d_t *pts, const size_t npts, triangulation_t type);
/*********************************************************
Operations on 3D point types - these are assumed to be
polygons embedded in 3D planes in space
*********************************************************/
/**
* @brief
* Calculate the interior area of a polygon in a 3D plane in space.
*
* If npts > 4, Greens Theorem is used. The polygon mustn't
* be self-intersecting.
*
* @param[out] area The interior area of the polygon
* @param[in] npts Number of point_ts, stored in pts
* @param[in] pts All points of the polygon, sorted counter-clockwise.
* The array mustn't contain duplicated or non-coplanar points.
*
* @return 0 if calculation was successful
* @return 1 if calculation failed, e.g. because one parameter is a NULL-pointer
*/
BG_EXPORT extern int bg_3d_polygon_area(fastf_t *area, size_t npts, const point_t *pts);
/**
* @brief
* Calculate the centroid of a non self-intersecting polygon in a 3D plane in space.
*
* @param[out] cent The centroid of the polygon
* @param[in] npts Number of point_ts, stored in pts
* @param[in] pts all points of the polygon, sorted counter-clockwise.
* The array mustn't contain duplicated points or non-coplanar points.
*
* @return 0 if calculation was successful
* @return 1 if calculation failed, e.g. because one in-parameter is a NULL-pointer
*/
BG_EXPORT extern int bg_3d_polygon_centroid(point_t *cent, size_t npts, const point_t *pts);
/**
* @brief
* Sort an array of point_ts, building a convex polygon, counter-clockwise
*
*@param[in] npts Number of points, pts contains
*@param pts Array of point_ts, building a convex polygon. Duplicated points
*aren't allowed. The points in the array will be sorted counter-clockwise.
*@param[in] cmp Plane equation of the polygon
*
*@return 0 if calculation was successful
*@return 1 if calculation failed, e.g. because pts is a NULL-pointer
*/
BG_EXPORT extern int bg_3d_polygon_sort_ccw(size_t npts, point_t *pts, plane_t cmp);
/**
* @brief
* Calculate for an array of plane_eqs, which build a polyhedron, the
* point_t's for each face.
*
* @param[out] npts Array, which stores for every face the number of
* point_ts, added to pts. Needs to be allocated with npts[neqs] already.
* @param[out] pts 2D-array which stores the point_ts for every
* face. The array needs to be allocated with pts[neqs][neqs-1] already.
* @param[in] neqs Number of plane_ts, stored in eqs
* @param[in] eqs Array, that contains the plane equations, which
* build the polyhedron
*
* @return 0 if calculation was successful
* @return 1 if calculation failed, e.g. because one parameter is a NULL-Pointer
*/
BG_EXPORT extern int bg_3d_polygon_mk_pts_planes(size_t *npts, point_t **pts, size_t neqs, const plane_t *eqs);
__END_DECLS
#endif /* BG_POLYGON_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-66
View File
@@ -1,66 +0,0 @@
/* T R I _ R A Y . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
/*----------------------------------------------------------------------*/
/* @file tri_ray.h */
/** @addtogroup tri_ray */
/** @{ */
/**
* @brief
* Möller & Trumbore's triangle/ray intersection test
*
* From the article
*
* "Fast, Minimal Storage Ray-Triangle Intersection",
* Journal of Graphics Tools, 2(1):21-28, 1997
*
*/
#ifndef BG_TRI_RAY_H
#define BG_TRI_RAY_H
#include "common.h"
#include "vmath.h"
#include "bg/defines.h"
__BEGIN_DECLS
BG_EXPORT extern int bg_isect_tri_ray(const point_t orig,
const point_t dir,
const point_t vert0,
const point_t vert1,
const point_t vert2,
point_t *isect);
__END_DECLS
#endif /* BG_TRI_RAY_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-80
View File
@@ -1,80 +0,0 @@
/* T R I _ T R I . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
/*----------------------------------------------------------------------*/
/* @file tri_tri.h */
/** @addtogroup tri_tri */
/** @{ */
/**
* @brief
* Tomas Möller's triangle/triangle intersection routines from the article
*
* "A Fast Triangle-Triangle Intersection Test",
* Journal of Graphics Tools, 2(2), 1997
*/
#ifndef BG_TRI_TRI_H
#define BG_TRI_TRI_H
#include "common.h"
#include "vmath.h"
#include "bg/defines.h"
__BEGIN_DECLS
BG_EXPORT extern int bg_tri_tri_isect_coplanar(point_t V0,
point_t V1,
point_t V2,
point_t U0,
point_t U1,
point_t U2,
int area_flag);
BG_EXPORT extern int bg_tri_tri_isect(point_t V0,
point_t V1,
point_t V2,
point_t U0,
point_t U1,
point_t U2);
BG_EXPORT extern int bg_tri_tri_isect_with_line(point_t V0,
point_t V1,
point_t V2,
point_t U0,
point_t U1,
point_t U2,
int *coplanar,
point_t *isectpt1,
point_t *isectp2);
__END_DECLS
#endif /* BG_TRI_TRI_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
+21 -18
View File
@@ -1,7 +1,7 @@
/* B N E T W O R K . H
/* B I N . H
* BRL-CAD
*
* Copyright (c) 2011-2014 United States Government as represented by
* Copyright (c) 2011-2013 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
@@ -17,45 +17,48 @@
* License along with this file; see the file named COPYING for more
* information.
*/
/** @file bnetwork.h
/** @file bin.h
*
* BRL-CAD private system compatibility wrapper header that provides
* declarations for native and standard system NETWORKING routines.
*
* This header is commonly used in lieu of including the following:
* winsock2.h (not select, fd_set), netinet/in.h, netinet/tcp.h,
* arpa/inet.h (htonl, ntohl, etc)
* This header is commonly used in leu of including the following:
* winsock2.h, netinet/in.h, netinet/tcp.h, arpa/inet.h
*
* This header does not belong to any BRL-CAD library but may used by
* all of them. Consider this header PRIVATE and subject to change,
* NOT TO BE USED BY THIRD PARTIES.
*
* The below logic should not rely on common.h's HAVE_* defines and
* should not be including the common.h header. This is intended to
* be a stand-alone portability header intended to be independent of
* build system, reusable by external projects.
*/
#ifndef BNETWORK_H
#define BNETWORK_H
#ifndef __BIN_H__
#define __BIN_H__
/* Do not rely on common.h's HAVE_* defines. Do not include the
* common.h header. This is a stand-alone portability header intended
* to be independent of BRL-CAD and the BRL-CAD build system, reusable
* by external projects.
*/
#if defined(_WIN32) && !defined(__CYGWIN__)
# ifndef _WINSOCKAPI_
# include <winsock2.h> /* link against ws2_32 library */
# include <ws2tcpip.h> /* provides extensions */
# undef rad1 /* Win32 radio button 1 */
# undef rad2 /* Win32 radio button 2 */
# undef small /* defined as part of the Microsoft Interface Definition Language (MIDL) */
# undef rad1 /* Win32 radio button 1 */
# undef rad2 /* Win32 radio button 2 */
# undef small /* defined as part of the Microsoft Interface Definition Language (MIDL) */
# undef IN
# undef OUT
# endif
#else
# include <sys/types.h>
# include <netinet/in.h> /* sockaddr */
# include <netinet/tcp.h> /* for TCP_NODELAY sockopt */
# include <arpa/inet.h> /* hton/ntoh, inet_addr functions */
# include <sys/socket.h> /* accept, connect, send, recv, ... */
#endif
#endif /* BNETWORK_H */
#endif /* __BIN_H__ */
/*
* Local Variables:
+23 -26
View File
@@ -1,7 +1,7 @@
/* B I O . H
* BRL-CAD
*
* Copyright (c) 2008-2014 United States Government as represented by
* Copyright (c) 2008-2013 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
@@ -29,45 +29,42 @@
* all of them. Consider this header PRIVATE and subject to change,
* NOT TO BE USED BY THIRD PARTIES.
*
* The below logic should not rely on common.h's HAVE_* defines and
* should not be including the common.h header. This is intended to
* be a stand-alone portability header intended to be independent of
* build system, reusable by external projects.
*/
#ifndef BIO_H
#define BIO_H
#ifndef __BIO_H__
#define __BIO_H__
/* Do not rely on common.h's HAVE_* defines. Do not include the
* common.h header. This is a stand-alone portability header intended
* to be independent of BRL-CAD and the BRL-CAD build system, reusable
* by external projects.
*/
#include <stdio.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
# ifdef WIN32_LEAN_AND_MEAN
# undef WIN32_LEAN_AND_MEAN
# define NOMINMAX
# ifdef IGNORE
# define _BIO_IGNORE(x) IGNORE(x)
# undef IGNORE
# endif
# define WIN32_LEAN_AND_MEAN 434144 /* don't want winsock.h */
# ifdef NOMINMAX
# undef NOMINMAX
# endif
# define NOMINMAX 434144 /* don't break std::min and std::max */
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN /* unset to not interfere with calling apps */
# undef NOMINMAX
# include <io.h>
# undef rad1 /* Win32 radio button 1 */
# undef rad2 /* Win32 radio button 2 */
# undef small /* defined as part of the Microsoft Interface Definition Language (MIDL) */
# undef IN
# undef OUT
/* In case windows.h squashed our ignore, reinstate it - see common.h */
# ifdef _BIO_IGNORE
# ifdef IGNORE
# undef IGNORE
# endif
# define IGNORE(x) _BIO_IGNORE(x)
# endif
#else
# include <unistd.h>
/* provide a stub so we don't need to wrap all setmode() calls */
# define setmode(a, b) /* poof */
#endif
/* needed for testing O_TEMPORARY and O_BINARY */
@@ -90,7 +87,7 @@
# define S_ISDIR(_st_mode) (((_st_mode) & S_IFMT) == S_IFDIR)
#endif
#endif /* BIO_H */
#endif /* __BIO_H__ */
/*
* Local Variables:
+4426 -37
View File
File diff suppressed because it is too large Load Diff
-40
View File
@@ -1,40 +0,0 @@
set(bn_headers
adc.h
anim.h
clip.h
complex.h
defines.h
dvec.h
mat.h
msr.h
multipoly.h
noise.h
plane.h
plot3.h
poly.h
qmath.h
rand.h
randmt.h
spm.h
tabdata.h
str.h
tol.h
vectfont.h
vector_fpu.h
vector_x86.h
version.h
vert_tree.h
vlist.h
wavelet.h
)
install(FILES ${bn_headers} DESTINATION ${INCLUDE_DIR}/brlcad/bn)
CMAKEFILES(${bn_headers})
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8
-50
View File
@@ -1,50 +0,0 @@
/* A D C . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BN_ADC_H
#define BN_ADC_H
#include "common.h"
#include "vmath.h"
#include "bn/defines.h"
__BEGIN_DECLS
/* TODO - find another, more appropriate home for these... may just have to
* duplicate the logic in libdm and libged */
#include "dm/bview.h"
BN_EXPORT void adc_model_to_adc_view(struct bview_adc_state *adcs, mat_t model2view, fastf_t amax);
BN_EXPORT void adc_grid_to_adc_view(struct bview_adc_state *adcs, mat_t model2view, fastf_t amax);
BN_EXPORT void adc_view_to_adc_grid(struct bview_adc_state *adcs, mat_t model2view);
BN_EXPORT void adc_reset(struct bview_adc_state *adcs, mat_t view2model, mat_t model2view);
__END_DECLS
#endif /* BN_ADC_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-397
View File
@@ -1,397 +0,0 @@
/* A N I M . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_anim
* @brief
* Routines useful for moving geometry.
*
* Orientation conventions: The default object orientation is facing
* the positive x-axis, with the positive y-axis to the object's left
* and the positive z-axis above the object.
*
* The default view orientation for rt and mged is facing the negative
* z-axis, with the negative x-axis leading to the left and the
* positive y-axis going upwards.
*/
/** @{ */
/** @file bn/anim.h */
#ifndef BN_ANIM_H
#define BN_ANIM_H
#include "common.h"
#include <stdio.h> /* For FILE */
#include "vmath.h"
#include "bn/defines.h"
__BEGIN_DECLS
#define ANIM_STEER_NEW 0
#define ANIM_STEER_END 1
#define VSUBUNIT(a, b, c) {VSUB2(a, b, c);\
VUNITIZE(a);}
#define FVSCAN(f, a) fscanf(f, "%lf %lf %lf", (a), (a)+1, (a)+2)
#define FMATSCAN(f, m) {FVSCAN(f, (m)); FVSCAN(f, (m)+4);\
FVSCAN(f, (m)+8); FVSCAN(f, (m)+12);}
#define VSCAN(a) scanf("%lf %lf %lf", (a), (a)+1, (a)+2)
#define VPRINTS(t, a) printf("%s %f %f %f ", t, (a)[0], (a)[1], (a)[2])
#define VPRINTN(t, a) printf("%s %f %f %f\n", t, (a)[0], (a)[1], (a)[2])
#define MAT_MOVE(m, n) MAT_COPY(m, n)
/***** 3x3 matrix format *****/
typedef fastf_t mat3_t[9];
#define MAT3ZERO(m) {\
int _j; for (_j=0;_j<9;_j++) m[_j]=0.0;}
#define MAT3IDN(m) {\
int _j; for (_j=0;_j<9;_j++) m[_j]=0.0;\
m[0] = m[4] = m[8] = 1.0;}
#define MAT3MUL(o, a, b) {\
(o)[0] = (a)[0]*(b)[0] + (a)[1]*(b)[3] + (a)[2]*(b)[6];\
(o)[1] = (a)[0]*(b)[1] + (a)[1]*(b)[4] + (a)[2]*(b)[7];\
(o)[2] = (a)[0]*(b)[2] + (a)[1]*(b)[5] + (a)[2]*(b)[8];\
(o)[3] = (a)[3]*(b)[0] + (a)[4]*(b)[3] + (a)[5]*(b)[6];\
(o)[4] = (a)[3]*(b)[1] + (a)[4]*(b)[4] + (a)[5]*(b)[7];\
(o)[5] = (a)[3]*(b)[2] + (a)[4]*(b)[5] + (a)[5]*(b)[8];\
(o)[6] = (a)[6]*(b)[0] + (a)[7]*(b)[3] + (a)[8]*(b)[6];\
(o)[7] = (a)[6]*(b)[1] + (a)[7]*(b)[4] + (a)[8]*(b)[7];\
(o)[8] = (a)[6]*(b)[2] + (a)[7]*(b)[5] + (a)[8]*(b)[8];}
#define MAT3SUM(o, a, b) {\
int _j; for (_j=0;_j<9;_j++) (o)[_j]=(a)[_j]+(b)[_j];}
#define MAT3DIF(o, a, b) {\
int _j; for (_j=0;_j<9;_j++) (o)[_j]=(a)[_j]-(b)[_j];}
#define MAT3SCALE(o, a, s) {\
int _j; for (_j=0;_j<9;_j++) (o)[_j]=(a)[_j] * (s);}
#define MAT3MOVE(o, a) {\
int _j; for (_j=0;_j<9;_j++) (o)[_j] = (a)[_j];}
#define MAT3XVEC(u, m, v) {\
(u)[0] = (m)[0]*(v)[0] + (m)[1]*(v)[1] + (m)[2]*(v)[2];\
(u)[1] = (m)[3]*(v)[0] + (m)[4]*(v)[1] + (m)[5]*(v)[2];\
(u)[2] = (m)[6]*(v)[0] + (m)[7]*(v)[1] + (m)[8]*(v)[2];}
#define MAT3TO4(o, i) {\
(o)[0] = (i)[0];\
(o)[1] = (i)[1];\
(o)[2] = (i)[2];\
(o)[4] = (i)[3];\
(o)[5] = (i)[4];\
(o)[6] = (i)[5];\
(o)[8] = (i)[6];\
(o)[9] = (i)[7];\
(o)[10] = (i)[8];\
(o)[3]=(o)[7]=(o)[11]=(o)[12]=(o)[13]=(o)[14]=0.0;\
(o)[15]=1.0;}
#define MAT4TO3(o, i) {\
(o)[0] = (i)[0];\
(o)[1] = (i)[1];\
(o)[2] = (i)[2];\
(o)[3] = (i)[4];\
(o)[4] = (i)[5];\
(o)[5] = (i)[6];\
(o)[6] = (i)[8];\
(o)[7] = (i)[9];\
(o)[8] = (i)[10];}
/* tilde matrix: [M]a = v X a */
#define MAKE_TILDE(m, v) {\
MAT3ZERO(m);\
m[1]= -v[2]; m[2]=v[1]; m[3]= v[2];\
m[5]= -v[0]; m[6]= -v[1]; m[7]= v[0];}
/* a = Ix Iy Iz b = Ixy Ixz Iyz*/
#define INERTIAL_MAT3(m, a, b) {\
(m)[0] = (a)[0]; (m)[1] = -(b)[0]; (m)[2] = -(b)[1];\
(m)[3] = -(b)[0]; (m)[4] = (a)[1]; (m)[5] = -(b)[2];\
(m)[6] = -(b)[1]; (m)[7] = -(b)[2]; (m)[8]= (a)[2];}
/* FIXME: These should all have bn_ prefixes */
/**
* @brief Pre-multiply a rotation matrix by a matrix which maps the
* z-axis to the negative x-axis, the y-axis to the z-axis and the
* x-axis to the negative y-axis.
*
* This has the effect of twisting an object in the default view
* orientation into the default object orientation before applying the
* matrix. Given a matrix designed to operate on an object, yield a
* matrix which operates on the view.
*/
BN_EXPORT extern void anim_v_permute(mat_t m);
/**
* @brief Undo the mapping done by anim_v_permute().
*
* This has the effect of twisting an object in the default object
* orientation into the default view orientation before applying the
* matrix. Given a matrix designed to operate on the view, yield a
* matrix which operates on an object.
*/
BN_EXPORT extern void anim_v_unpermute(mat_t m);
/**
* @brief Transpose matrix in place
*/
BN_EXPORT extern void anim_tran(mat_t m);
/**
* @brief
* Convert the rotational part of a 4x4 transformation matrix to zyx
* form, that is to say, rotations carried out in the order z, y, and
* then x. The angles are stored in radians as a vector in the order
* x, y, z. A return value of ERROR1 means that arbitrary assumptions
* were necessary. ERROR2 means that the conversion failed.
*/
BN_EXPORT extern int anim_mat2zyx(const mat_t viewrot,
vect_t angle);
/**
* @brief
* Convert the rotational part of a 4x4 transformation matrix to
* yaw-pitch-roll form, that is to say, +roll degrees about the
* x-axis, -pitch degrees about the y-axis, and +yaw degrees about the
* z-axis. The angles are stored in radians as a vector in the order
* y, p, r. A return of ERROR1 means that arbitrary assumptions were
* necessary. ERROR2 means that the conversion failed.
*/
BN_EXPORT extern int anim_mat2ypr(mat_t viewrot,
vect_t angle);
/**
* @brief
* This interprets the rotational part of a 4x4 transformation matrix
* in terms of unit quaternions. The result is stored as a vector in
* the order x, y, z, w. The algorithm is from Ken Shoemake,
* Animating Rotation with Quaternion Curves, 1985 SIGGraph Conference
* Proceeding, p.245.
*/
BN_EXPORT extern int anim_mat2quat(quat_t quat,
const mat_t viewrot);
/**
* @brief Create a premultiplication rotation matrix to turn the front
* of an object (its x-axis) to the given yaw, pitch, and roll, which
* is stored in radians in the vector a.
*/
BN_EXPORT extern void anim_ypr2mat(mat_t m,
const vect_t a);
/**
* @brief Create a post-multiplication rotation matrix, which could be
* used to move the virtual camera to the given yaw, pitch, and roll,
* which are stored in radians in the given vector a. The following
* are equivalent sets of commands:
*
* ypr2vmat(matrix, a);
* -- or --
* ypr2mat(matrix, a);
* v_permute(matrix);
* transpose(matrix;
*/
BN_EXPORT extern void anim_ypr2vmat(mat_t m,
const vect_t a);
/**
* @brief
* Make matrix to rotate an object to the given yaw, pitch, and
* roll. (Specified in radians.)
*/
BN_EXPORT extern void anim_y_p_r2mat(mat_t m,
double y,
double p,
double r);
/**
* @brief Make matrix to rotate an object to the given yaw, pitch, and
* roll. (Specified in degrees.)
*/
BN_EXPORT extern void anim_dy_p_r2mat(mat_t m,
double y,
double p,
double r);
/**
* @brief Make a view rotation matrix, given desired yaw, pitch and
* roll. (Note that the matrix is a permutation of the object rotation
* matrix).
*/
BN_EXPORT extern void anim_dy_p_r2vmat(mat_t m,
double yaw,
double pch,
double rll);
/**
* @brief Make a rotation matrix corresponding to a rotation of "x"
* radians about the x-axis, "y" radians about the y-axis, and then
* "z" radians about the z-axis.
*/
BN_EXPORT extern void anim_x_y_z2mat(mat_t m,
double x,
double y,
double z);
/**
* @brief Make a rotation matrix corresponding to a rotation of "x"
* degrees about the x-axis, "y" degrees about the y-axis, and then
* "z" degrees about the z-axis.
*/
BN_EXPORT extern void anim_dx_y_z2mat(mat_t m,
double x,
double y,
double z);
/**
* @brief Make a rotation matrix corresponding to a rotation of "z"
* radians about the z-axis, "y" radians about the y-axis, and then
* "x" radians about the x-axis.
*/
BN_EXPORT extern void anim_zyx2mat(mat_t m,
const vect_t a);
/**
* @brief Make a rotation matrix corresponding to a rotation of "z"
* radians about the z-axis, "y" radians about the y-axis, and then
* "x" radians about the x-axis.
*/
BN_EXPORT extern void anim_z_y_x2mat(mat_t m,
double x,
double y,
double z);
/**
* @brief
* Make a rotation matrix corresponding to a rotation of "z" degrees
* about the z-axis, "y" degrees about the y-axis, and then "x"
* degrees about the x-axis.
*/
BN_EXPORT extern void anim_dz_y_x2mat(mat_t m,
double x,
double y,
double z);
/**
* @brief
* Make 4x4 matrix from the given quaternion Note: these quaternions
* are the conjugates of the quaternions used in the librt/qmath.c
* quat_quat2mat()
*/
BN_EXPORT extern void anim_quat2mat(mat_t m,
const quat_t qq);
/**
* @brief
* make a matrix which turns a vehicle from the x-axis to point in the
* desired direction, staying "right-side up" (i.e. the y-axis never has
* a z-component). A second direction vector is consulted when the
* given direction is vertical. This is intended to represent the
* direction from a previous frame.
*/
BN_EXPORT extern void anim_dir2mat(mat_t m,
const vect_t d,
const vect_t d2);
/**
* @brief make a matrix which turns a vehicle from the x-axis to point
* in the desired direction, staying "right-side up". In cases where
* the direction is vertical, the second vector is consulted. The
* second vector defines a normal to the vertical plane into which
* the vehicle's x and z axes should be put. A good choice to put here
* is the direction of the vehicle's y-axis in the previous frame.
*/
BN_EXPORT extern void anim_dirn2mat(mat_t m,
const vect_t dx,
const vect_t dn);
/**
* @brief given the next frame's position, remember the value of the
* previous frame's position and calculate a matrix which points the
* x-axis in the direction defined by those two positions. Return new
* matrix, and the remembered value of the current position, as
* arguments; return 1 as the normal value, and 0 when there is not
* yet information to remember.
*/
BN_EXPORT extern int anim_steer_mat(mat_t mat,
vect_t point,
int end);
/**
* @brief Add pre- and post- translation to a rotation matrix. The
* resulting matrix has the effect of performing the first
* translation, followed by the rotation, followed by the second
* translation.
*/
BN_EXPORT extern void anim_add_trans(mat_t m,
const vect_t post,
const vect_t pre);
/**
* @brief Rotate the vector "d" through "a" radians about the z-axis.
*/
BN_EXPORT extern void anim_rotatez(fastf_t a,
vect_t d);
/**
* @brief print out 4X4 matrix, with optional colon
*/
BN_EXPORT extern void anim_mat_print(FILE *fp,
const mat_t m,
int s_colon);
/**
* @brief print out 4X4 matrix. formstr must be less than twenty
* chars
*/
BN_EXPORT extern void anim_mat_printf(FILE *fp,
const mat_t m,
const char *formstr,
const char *linestr,
const char *endstr);
/**
* @brief Reverse the direction of a view matrix, keeping it
* right-side up
*/
BN_EXPORT extern void anim_view_rev(mat_t m);
__END_DECLS
#endif /* BN_ANIM_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-73
View File
@@ -1,73 +0,0 @@
/* C L I P . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_clip
* @brief
* Clipping functions
*/
/** @{ */
/** @file clip.h */
#ifndef BN_CLIP_H
#define BN_CLIP_H
#include "common.h"
#include "vmath.h"
#include "bn/defines.h"
__BEGIN_DECLS
/**
* @brief
* Clip a 2-D integer line seg against the size of the display
*/
BN_EXPORT extern int bn_lseg_clip(fastf_t *xp1, fastf_t *yp1, fastf_t *xp2, fastf_t *yp2, fastf_t clip_min, fastf_t clip_max);
/**
* @brief
* Clip a ray against a rectangular parallelepiped (RPP)
* that has faces parallel to the coordinate planes (a clipping RPP).
* The RPP is defined by a minimum point and a maximum point.
*
* Returns -
* 0 if ray does not hit RPP,
* !0 if ray hits RPP.
*
* Implicit Return -
* if !0 was returned, "a" and "b" have been clipped to the RPP.
*/
BN_EXPORT extern int bn_ray_vclip(vect_t a, vect_t b, fastf_t *min, fastf_t *max);
__END_DECLS
#endif /* BN_CLIP_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-103
View File
@@ -1,103 +0,0 @@
/* C O M P L E X . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_complex
* @brief
* Complex numbers
*/
/** @{ */
/** @file complex.h */
#ifndef BN_COMPLEX_H
#define BN_COMPLEX_H
#include "common.h"
#include "bn/defines.h"
__BEGIN_DECLS
/* "complex number" data type: */
typedef struct bn_complex {
double re; /**< @brief real part */
double im; /**< @brief imaginary part */
} bn_complex_t;
/* functions that are efficiently done as macros: */
#define bn_cx_copy(ap, bp) {*(ap) = *(bp);}
#define bn_cx_neg(cp) { (cp)->re = -((cp)->re);(cp)->im = -((cp)->im);}
#define bn_cx_real(cp) (cp)->re
#define bn_cx_imag(cp) (cp)->im
#define bn_cx_add(ap, bp) { (ap)->re += (bp)->re; (ap)->im += (bp)->im;}
#define bn_cx_ampl(cp) hypot((cp)->re, (cp)->im)
#define bn_cx_amplsq(cp) ((cp)->re * (cp)->re + (cp)->im * (cp)->im)
#define bn_cx_conj(cp) { (cp)->im = -(cp)->im; }
#define bn_cx_cons(cp, r, i) { (cp)->re = r; (cp)->im = i; }
#define bn_cx_phas(cp) atan2((cp)->im, (cp)->re)
#define bn_cx_scal(cp, s) { (cp)->re *= (s); (cp)->im *= (s); }
#define bn_cx_sub(ap, bp) { (ap)->re -= (bp)->re; (ap)->im -= (bp)->im;}
#define bn_cx_mul(ap, bp) \
{ register fastf_t a__re, b__re; \
(ap)->re = ((a__re=(ap)->re)*(b__re=(bp)->re)) - (ap)->im*(bp)->im; \
(ap)->im = a__re*(bp)->im + (ap)->im*b__re; }
/* Output variable "ap" is different from input variables "bp" or "cp" */
#define bn_cx_mul2(ap, bp, cp) { \
(ap)->re = (cp)->re * (bp)->re - (cp)->im * (bp)->im; \
(ap)->im = (cp)->re * (bp)->im + (cp)->im * (bp)->re; }
/**
*@brief
* Divide one complex by another
*
* bn_cx_div(&a, &b). divides a by b. Zero divisor fails. a and b
* may coincide. Result stored in a.
*/
BN_EXPORT extern void bn_cx_div(bn_complex_t *ap,
const bn_complex_t *bp);
/**
*@brief
* Compute square root of complex number
*
* bn_cx_sqrt(&out, &c) replaces out by sqrt(c)
*
* Note: This is a double-valued function; the result of bn_cx_sqrt()
* always has nonnegative imaginary part.
*/
BN_EXPORT extern void bn_cx_sqrt(bn_complex_t *op,
const bn_complex_t *ip);
__END_DECLS
#endif /* BN_COMPLEX_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-61
View File
@@ -1,61 +0,0 @@
/* D E F I N E S . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_defines
*
* Common definitions for the headers used in libbn (i.e. the headers found in include/bn)
*/
/** @{ */
/** @file bn/defines.h */
#ifndef BN_DEFINES_H
#define BN_DEFINES_H
#include "common.h"
#ifndef BN_EXPORT
# if defined(BN_DLL_EXPORTS) && defined(BN_DLL_IMPORTS)
# error "Only BN_DLL_EXPORTS or BN_DLL_IMPORTS can be defined, not both."
# elif defined(BN_DLL_EXPORTS)
# define BN_EXPORT __declspec(dllexport)
# elif defined(BN_DLL_IMPORTS)
# define BN_EXPORT __declspec(dllimport)
# else
# define BN_EXPORT
# endif
#endif
#define BN_AZIMUTH 0
#define BN_ELEVATION 1
#define BN_TWIST 2
#endif /* BN_DEFINES_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-498
View File
@@ -1,498 +0,0 @@
/* M A T . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 mat
*
* @brief
* Matrix and vector functionality
*/
/** @{ */
/* @file mat.h */
#ifndef BN_MAT_H
#define BN_MAT_H
#include "common.h"
#include <stdio.h> /* For FILE */
#include "vmath.h"
#include "bu/vls.h"
#include "bn/defines.h"
#include "bn/tol.h"
__BEGIN_DECLS
/*
* 4x4 Matrix math
*/
BN_EXPORT extern const mat_t bn_mat_identity;
BN_EXPORT extern void bn_mat_print(const char *title,
const mat_t m);
BN_EXPORT extern void bn_mat_print_guts(const char *title,
const mat_t m,
char *buf,
int buflen);
BN_EXPORT extern void bn_mat_print_vls(const char *title,
const mat_t m,
struct bu_vls *vls);
/**
* A wrapper for the system atan2(). On the Silicon Graphics, and
* perhaps on others, x==0 incorrectly returns infinity.
*/
BN_EXPORT extern double bn_atan2(double x, double y);
#define bn_mat_zero(_m) { \
bu_log("%s:%d bn_mat_zero() is deprecated, use MAT_ZERO()\n", \
__FILE__, __LINE__); \
(_m)[0] = (_m)[1] = (_m)[2] = (_m)[3] = \
(_m)[4] = (_m)[5] = (_m)[6] = (_m)[7] = \
(_m)[8] = (_m)[9] = (_m)[10] = (_m)[11] = \
(_m)[12] = (_m)[13] = (_m)[14] = (_m)[15] = 0.0; }
/*
#define bn_mat_zero(_m) (void)memset((void *)_m, 0, sizeof(mat_t))
*/
#define bn_mat_idn(_m) { \
bu_log("%s:%d bn_mat_idn() is deprecated, use MAT_IDN()\n", \
__FILE__, __LINE__); \
(_m)[1] = (_m)[2] = (_m)[3] = (_m)[4] = \
(_m)[6] = (_m)[7] = (_m)[8] = (_m)[9] = \
(_m)[11] = (_m)[12] = (_m)[13] = (_m)[14] = 0.0; \
(_m)[0] = (_m)[5] = (_m)[10] = (_m)[15] = 1.0; }
/*
#define bn_mat_idn(_m) (void)memcpy((void *)_m, (const void *)bn_mat_identity, sizeof(mat_t))
*/
#define bn_mat_copy(_d, _s) { \
bu_log("%s:%d bn_mat_copy() is deprecated, use MAT_COPY()\n", \
__FILE__, __LINE__); \
(_d)[0] = (_s)[0];\
(_d)[1] = (_s)[1];\
(_d)[2] = (_s)[2];\
(_d)[3] = (_s)[3];\
(_d)[4] = (_s)[4];\
(_d)[5] = (_s)[5];\
(_d)[6] = (_s)[6];\
(_d)[7] = (_s)[7];\
(_d)[8] = (_s)[8];\
(_d)[9] = (_s)[9];\
(_d)[10] = (_s)[10];\
(_d)[11] = (_s)[11];\
(_d)[12] = (_s)[12];\
(_d)[13] = (_s)[13];\
(_d)[14] = (_s)[14];\
(_d)[15] = (_s)[15]; }
/*
#define bn_mat_copy(_d, _s) (void)memcpy((void *)_d, (const void *)(_s), sizeof(mat_t))
*/
/**
* Multiply matrix "a" by "b" and store the result in "o".
*
* This is different from multiplying "b" by "a" (most of the time!)
* Also, "o" must not be the same as either of the inputs.
*/
BN_EXPORT extern void bn_mat_mul(mat_t o,
const mat_t a,
const mat_t b);
/**
* o = i * o
*
* A convenience wrapper for bn_mat_mul() to update a matrix in place.
* The argument ordering is confusing either way.
*/
BN_EXPORT extern void bn_mat_mul2(const mat_t i,
mat_t o);
/**
* o = a * b * c
*
* The output matrix may be the same as 'b' or 'c', but may not be
* 'a'.
*/
BN_EXPORT extern void bn_mat_mul3(mat_t o,
const mat_t a,
const mat_t b,
const mat_t c);
/**
* o = a * b * c * d
*
* The output matrix may be the same as any input matrix.
*/
BN_EXPORT extern void bn_mat_mul4(mat_t o,
const mat_t a,
const mat_t b,
const mat_t c,
const mat_t d);
/**
* Multiply the matrix "im" by the vector "iv" and store the result in
* the vector "ov". Note this is post-multiply, and operates on
* 4-tuples. Use MAT4X3VEC() to operate on 3-tuples.
*/
BN_EXPORT extern void bn_matXvec(hvect_t ov,
const mat_t im,
const hvect_t iv);
/**
* The matrix pointed at by "input" is inverted and stored in the area
* pointed at by "output".
*
* Calls bu_bomb if matrix is singular.
*/
BN_EXPORT extern void bn_mat_inv(mat_t output,
const mat_t input);
/**
* The matrix pointed at by "input" is inverted and stored in the area
* pointed at by "output".
*
* Invert a 4-by-4 matrix using Algorithm 120 from ACM. This is a
* modified Gauss-Jordan algorithm. Note: Inversion is done in place,
* with 3 work vectors.
*
* @return 1 if OK.
* @return 0 if matrix is singular.
*/
BN_EXPORT extern int bn_mat_inverse(mat_t output,
const mat_t input);
/**
* Takes a pointer to a [x, y, z] vector, and a pointer to space for a
* homogeneous vector [x, y, z, w], and builds [x, y, z, 1].
*/
BN_EXPORT extern void bn_vtoh_move(vect_t h,
const vect_t v);
/**
* Takes a pointer to [x, y, z, w], and converts it to an ordinary
* vector [x/w, y/w, z/w]. Optimization for the case of w==1 is
* performed.
*
* FIXME: make tolerance configurable
*/
BN_EXPORT extern void bn_htov_move(vect_t v,
const vect_t h);
BN_EXPORT extern void bn_mat_trn(mat_t om,
const mat_t im);
/**
* Compute a 4x4 rotation matrix given Azimuth and Elevation.
*
* Azimuth is +X, Elevation is +Z, both in degrees.
*
* Formula due to Doug Gwyn, BRL.
*/
BN_EXPORT extern void bn_mat_ae(mat_t m,
double azimuth,
double elev);
/**
* Find the azimuth and elevation angles that correspond to the
* direction (not including twist) given by a direction vector.
*/
BN_EXPORT extern void bn_ae_vec(fastf_t *azp,
fastf_t *elp,
const vect_t v);
/**
* Find the azimuth, elevation, and twist from two vectors. Vec_ae is
* in the direction of view (+z in mged view) and vec_twist points to
* the viewers right (+x in mged view). Accuracy (degrees) is used to
* stabilize flutter between equivalent extremes of atan2(), and to
* snap twist to zero when elevation is near +/- 90
*/
BN_EXPORT extern void bn_aet_vec(fastf_t *az,
fastf_t *el,
fastf_t *twist,
vect_t vec_ae,
vect_t vec_twist,
fastf_t accuracy);
/**
* Find a unit vector from the origin given azimuth and elevation.
*/
BN_EXPORT extern void bn_vec_ae(vect_t vec,
fastf_t az,
fastf_t el);
/**
* Find a vector from the origin given azimuth, elevation, and distance.
*/
BN_EXPORT extern void bn_vec_aed(vect_t vec,
fastf_t az,
fastf_t el,
fastf_t dist);
/**
* This routine builds a Homogeneous rotation matrix, given alpha,
* beta, and gamma as angles of rotation, in degrees.
*
* Alpha is angle of rotation about the X axis, and is done third.
* Beta is angle of rotation about the Y axis, and is done second.
* Gamma is angle of rotation about Z axis, and is done first.
*
* FIXME: make tolerance configurable
*/
BN_EXPORT extern void bn_mat_angles(mat_t mat,
double alpha,
double beta, double ggamma);
/**
* This routine builds a Homogeneous rotation matrix, given alpha,
* beta, and gamma as angles of rotation, in radians.
*
* Alpha is angle of rotation about the X axis, and is done third.
* Beta is angle of rotation about the Y axis, and is done second.
* Gamma is angle of rotation about Z axis, and is done first.
*
* FIXME: make tolerance configurable
*/
BN_EXPORT extern void bn_mat_angles_rad(mat_t mat,
double alpha,
double beta,
double ggamma);
/**
* Find the eigenvalues and eigenvectors of a symmetric 2x2 matrix.
* (a b)
* (b c)
*
* The eigenvalue with the smallest absolute value is returned in
* val1, with its eigenvector in vec1.
*/
BN_EXPORT extern void bn_eigen2x2(fastf_t *val1,
fastf_t *val2,
vect_t vec1,
vect_t vec2,
fastf_t a,
fastf_t b,
fastf_t c);
/**
* Given a vector, create another vector which is perpendicular to it.
* The output vector will have unit length only if the input vector
* did.
*
* FIXME: make tolerance configurable
*/
BN_EXPORT extern void bn_vec_perp(vect_t new_vec,
const vect_t old_vec);
/**
* Given two vectors, compute a rotation matrix that will transform
* space by the angle between the two. There are many candidate
* matrices.
*
* The input 'from' and 'to' vectors need not be unit length.
* MAT4X3VEC(to, m, from) is the identity that is created.
*
*/
BN_EXPORT extern void bn_mat_fromto(mat_t m,
const fastf_t *from,
const fastf_t *to,
const struct bn_tol *tol);
/**
* Given the sin and cos of an X rotation angle, produce the rotation
* matrix.
*/
BN_EXPORT extern void bn_mat_xrot(mat_t m,
double sinx,
double cosx);
/**
* Given the sin and cos of a Y rotation angle, produce the rotation
* matrix.
*/
BN_EXPORT extern void bn_mat_yrot(mat_t m,
double siny,
double cosy);
/**
* Given the sin and cos of a Z rotation angle, produce the rotation
* matrix.
*/
BN_EXPORT extern void bn_mat_zrot(mat_t m,
double sinz,
double cosz);
/**
* Given a direction vector D of unit length, product a matrix which
* rotates that vector D onto the -Z axis. This matrix will be
* suitable for use as a "model2view" matrix.
*
* XXX This routine will fail if the vector is already more or less
* aligned with the Z axis.
*
* This is done in several steps.
*
@code
1) Rotate D about Z to match +X axis. Azimuth adjustment.
2) Rotate D about Y to match -Y axis. Elevation adjustment.
3) Rotate D about Z to make projection of X axis again point
in the +X direction. Twist adjustment.
4) Optionally, flip sign on Y axis if original Z becomes inverted.
This can be nice for static frames, but is astonishing when
used in animation.
@endcode
*/
BN_EXPORT extern void bn_mat_lookat(mat_t rot,
const vect_t dir,
int yflip);
/**
* Given a vector, create another vector which is perpendicular to it,
* and with unit length. This algorithm taken from Gift's arvec.f; a
* faster algorithm may be possible.
*
* FIXME: make tolerance configurable
*/
BN_EXPORT extern void bn_vec_ortho(vect_t out,
const vect_t in);
/**
* Build a matrix to scale uniformly around a given point.
*
* @return -1 if scale is too small.
* @return 0 if OK.
*
* FIXME: make tolerance configurable
*/
BN_EXPORT extern int bn_mat_scale_about_pt(mat_t mat,
const point_t pt,
const double scale);
/**
* Build a matrix to apply arbitrary 4x4 transformation around a given
* point.
*/
BN_EXPORT extern void bn_mat_xform_about_pt(mat_t mat,
const mat_t xform,
const point_t pt);
/**
* @return 0 When matrices are not equal
* @return 1 When matrices are equal
*/
BN_EXPORT extern int bn_mat_is_equal(const mat_t a,
const mat_t b,
const struct bn_tol *tol);
/**
* This routine is intended for detecting identity matrices read in
* from ascii or binary files, where the numbers are pure ones or
* zeros. This routine is *not* intended for tolerance-based
* "near-zero" comparisons; as such, it shouldn't be used on matrices
* which are the result of calculation.
*
*
* @return 0 non-identity
* @return 1 a perfect identity matrix
*/
BN_EXPORT extern int bn_mat_is_identity(const mat_t m);
/**
* Construct a transformation matrix for rotation about an arbitrary
* axis. The axis is defined by a point (pt) and a unit direction
* vector (dir). The angle of rotation is "ang"
*
* FIXME: make tolerance configurable
*/
BN_EXPORT extern void bn_mat_arb_rot(mat_t m,
const point_t pt,
const vect_t dir,
const fastf_t ang);
/**
* Return a pointer to a copy of the matrix in dynamically allocated
* memory.
*/
BN_EXPORT extern matp_t bn_mat_dup(const mat_t in);
/**
* Check to ensure that a rotation matrix preserves axis
* perpendicularity. Note that not all matrices are rotation
* matrices.
*
*
* @return -1 FAIL
* @return 0 OK
*/
BN_EXPORT extern int bn_mat_ck(const char *title,
const mat_t m);
/**
* Calculates the determinant of the 3X3 "rotation" part of the passed
* matrix.
*/
BN_EXPORT extern fastf_t bn_mat_det3(const mat_t m);
/**
* Calculates the determinant of the 4X4 matrix
*/
BN_EXPORT extern fastf_t bn_mat_determinant(const mat_t m);
/**
* FIXME: make tolerance configurable
*/
BN_EXPORT extern int bn_mat_is_non_unif(const mat_t m);
/**
* Given a model-space transformation matrix "change",
* return a matrix which applies the change with-respect-to
* given "point" and "direc".
*/
BN_EXPORT extern void bn_wrt_point_direc(mat_t out,
const mat_t change,
const mat_t in,
const point_t point,
const vect_t direc,
const struct bn_tol *tol);
/* Matrix stuff from MGED's dozoom.c - somewhat unfinished,
* judging by the comments. Can probably be simplified/combined */
BN_EXPORT extern void persp_mat(mat_t m, fastf_t fovy, fastf_t aspect, fastf_t near1, fastf_t far1, fastf_t backoff);
BN_EXPORT extern void mike_persp_mat(fastf_t *pmat, const fastf_t *eye);
BN_EXPORT extern void deering_persp_mat(fastf_t *m, const fastf_t *l, const fastf_t *h, const fastf_t *eye);
__END_DECLS
#endif /* BN_MAT_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-282
View File
@@ -1,282 +0,0 @@
/* M S R . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_msr
*
* @brief
* Minimal Standard RANdom number generator
*
* @par From:
* Stephen K. Park and Keith W. Miller
* @n "Random number generators: good ones are hard to find"
* @n CACM vol 31 no 10, Oct 88
*
*/
/** @{ */
/** @file msr.h */
#ifndef BN_MSR_H
#define BN_MSR_H
#include "common.h"
#include "bn/defines.h"
#include "bu/magic.h"
__BEGIN_DECLS
/*
* Define data structures and constants for the "MSR" random number
* package.
*
* Also define a set of macros to access the random number tables and
* to limit the area/volume that a set of random numbers inhabit.
*/
struct bn_unif {
uint32_t magic;
long msr_seed;
int msr_double_ptr;
double *msr_doubles;
int msr_long_ptr;
long *msr_longs;
};
#define BN_CK_UNIF(_p) BU_CKMAG(_p, BN_UNIF_MAGIC, "bn_unif")
#define BN_CK_GAUSS(_p) BU_CKMAG(_p, BN_GAUSS_MAGIC, "bn_gauss")
/**
* NOTE!!! The order of msr_gauss and msr_unif MUST match in the first
* three entries as msr_gauss is passed as a msr_unif in
* msr_gauss_fill.
*/
struct bn_gauss {
uint32_t magic;
long msr_gauss_seed;
int msr_gauss_dbl_ptr;
double *msr_gauss_doubles;
int msr_gauss_ptr;
double *msr_gausses;
};
/* bn_unif_init Initialize a random number structure.
*
* @par Entry
* setseed seed to use
* method method to use to generate numbers;
*
* @par Exit
* returns a pointer to a bn_unif structure.
* returns 0 on error.
*
* @par Uses
* None.
*
* @par Calls
* bu_malloc
*
* @par Method @code
* malloc up a structure with pointers to the numbers
* get space for the integer table.
* get space for the floating table.
* set pointer counters
* set seed if one was given and setseed != 1
@endcode
*
*/
BN_EXPORT extern struct bn_unif *bn_unif_init(long setseed,
int method);
/*
* bn_unif_free free random number table
*
*/
BN_EXPORT extern void bn_unif_free(struct bn_unif *p);
/* bn_unif_long_fill fill a random number table.
*
* Use the msrad algorithm to fill a random number table
* with values from 1 to 2^31-1. These numbers can (and are) extracted from
* the random number table via high speed macros and bn_unif_long_fill called
* when the table is exhausted.
*
* @par Entry
* p pointer to a bn_unif structure.
*
* @par Exit
* if (!p) returns 1 else returns a value between 1 and 2^31-1
*
* @par Calls
* None. msran is inlined for speed reasons.
*
* @par Uses
* None.
*
* @par Method @code
* if (!p) return 1;
* if p->msr_longs != NULL
* msr_longs is reloaded with random numbers;
* msr_long_ptr is set to BN_MSR_MAXTBL
* endif
* msr_seed is updated.
@endcode
*/
BN_EXPORT extern long bn_unif_long_fill(struct bn_unif *p);
/* bn_unif_double_fill fill a random number table.
*
* Use the msrad algorithm to fill a random number table
* with values from -0.5 to 0.5. These numbers can (and are) extracted from
* the random number table via high speed macros and bn_unif_double_fill
* called when the table is exhausted.
*
* @par Entry
* p pointer to a bn_unif structure.
*
* @par Exit
* if (!p) returns 0.0 else returns a value between -0.5 and 0.5
*
* @par Calls
* None. msran is inlined for speed reasons.
*
* @par Uses
* None.
*
* @par Method @code
* if (!p) return (0.0)
* if p->msr_longs != NULL
* msr_longs is reloaded with random numbers;
* msr_long_ptr is set to BN_MSR_MAXTBL
* endif
* msr_seed is updated.
@endcode
*/
BN_EXPORT extern double bn_unif_double_fill(struct bn_unif *p);
/* bn_gauss_init Initialize a random number struct for gaussian
* numbers.
*
* @par Entry
* setseed Seed to use.
* method method to use to generate numbers (not used)
*
* @par Exit
* Returns a pointer toa bn_msr_gauss structure.
* returns 0 on error.
*
* @par Calls
* bu_malloc
*
* @par Uses
* None.
*
* @par Method @code
* malloc up a structure
* get table space
* set seed and pointer.
* if setseed != 0 then seed = setseed
@endcode
*/
BN_EXPORT extern struct bn_gauss *bn_gauss_init(long setseed,
int method);
/*
* bn_gauss_free free random number table
*
*/
BN_EXPORT extern void bn_gauss_free(struct bn_gauss *p);
/* bn_gauss_fill fill a random number table.
*
* Use the msrad algorithm to fill a random number table.
* hese numbers can (and are) extracted from
* the random number table via high speed macros and bn_msr_gauss_fill
* called when the table is exhausted.
*
* @par Entry
* p pointer to a bn_msr_gauss structure.
*
* @par Exit
* if (!p) returns 0.0 else returns a value with a mean of 0 and
* a variance of 1.0.
*
* @par Calls
* BN_UNIF_CIRCLE to get to uniform random number whose radius is
* <= 1.0. I.e. sqrt(v1*v1 + v2*v2) <= 1.0
* BN_UNIF_CIRCLE is a macro which can call bn_unif_double_fill.
*
* @par Uses
* None.
*
* @par Method @code
* if (!p) return (0.0)
* if p->msr_longs != NULL
* msr_longs is reloaded with random numbers;
* msr_long_ptr is set to BN_MSR_MAXTBL
* endif
* msr_seed is updated.
@endcode
*/
BN_EXPORT extern double bn_gauss_fill(struct bn_gauss *p);
#define BN_UNIF_LONG(_p) \
(((_p)->msr_long_ptr) ? \
(_p)->msr_longs[--(_p)->msr_long_ptr] : \
bn_unif_long_fill(_p))
#define BN_UNIF_DOUBLE(_p) \
(((_p)->msr_double_ptr) ? \
(_p)->msr_doubles[--(_p)->msr_double_ptr] : \
bn_unif_double_fill(_p))
#define BN_UNIF_CIRCLE(_p, _x, _y, _r) { \
do { \
(_x) = 2.0*BN_UNIF_DOUBLE((_p)); \
(_y) = 2.0*BN_UNIF_DOUBLE((_p)); \
(_r) = (_x)*(_x)+(_y)*(_y); \
} while ((_r) >= 1.0); }
#define BN_UNIF_SPHERE(_p, _x, _y, _z, _r) { \
do { \
(_x) = 2.0*BN_UNIF_DOUBLE(_p); \
(_y) = 2.0*BN_UNIF_DOUBLE(_p); \
(_z) = 2.0*BN_UNIF_DOUBLE(_p); \
(_r) = (_x)*(_x)+(_y)*(_y)+(_z)*(_z);\
} while ((_r) >= 1.0) }
#define BN_GAUSS_DOUBLE(_p) \
(((_p)->msr_gauss_ptr) ? \
(_p)->msr_gausses[--(_p)->msr_gauss_ptr] : \
bn_gauss_fill(_p))
__END_DECLS
#endif /* BN_MSR_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-173
View File
@@ -1,173 +0,0 @@
/* N O I S E . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 noise
*
* @brief
* These noise functions provide mostly random noise at the integer
* lattice points.
*
* The functions should be evaluated at non-integer
* locations for their nature to be realized.
*
* Contains contributed code from:
* F. Kenton Musgrave
* Robert Skinner
*
*/
/** @{ */
/* @file noise.h */
#ifndef BN_NOISE_H
#define BN_NOISE_H
#include "common.h"
#include "vmath.h"
#include "bn/defines.h"
__BEGIN_DECLS
/*
* fractal noise support
*/
BN_EXPORT extern void bn_noise_init(void);
/**
*@brief
* Robert Skinner's Perlin-style "Noise" function
*
* Results are in the range [-0.5 .. 0.5]. Unlike many
* implementations, this function provides random noise at the integer
* lattice values. However this produces much poorer quality and
* should be avoided if possible.
*
* The power distribution of the result has no particular shape,
* though it isn't as flat as the literature would have one believe.
*/
BN_EXPORT extern double bn_noise_perlin(point_t pt);
/* FIXME: Why isn't the result listed first? */
/**
* Vector-valued "Noise"
*/
BN_EXPORT extern void bn_noise_vec(point_t point,
point_t result);
/**
* @brief
* Procedural fBm evaluated at "point"; returns value stored in
* "value".
*
* @param point location to sample noise
* @param h_val fractal increment parameter
* @param lacunarity gap between successive frequencies
* @param octaves number of frequencies in the fBm
*
* The spectral properties of the result are in the APPROXIMATE range
* [-1..1] Depending upon the number of octaves computed, this range
* may be exceeded. Applications should clamp or scale the result to
* their needs. The results have a more-or-less gaussian
* distribution. Typical results for 1M samples include:
*
* @li Min -1.15246
* @li Max 1.23146
* @li Mean -0.0138744
* @li s.d. 0.306642
* @li Var 0.0940295
*
* The function call pow() is relatively expensive. Therefore, this
* function pre-computes and saves the spectral weights in a table for
* re-use in successive invocations.
*/
BN_EXPORT extern double bn_noise_fbm(point_t point,
double h_val,
double lacunarity,
double octaves);
/**
* @brief
* Procedural turbulence evaluated at "point";
*
* @return turbulence value for point
*
* @param point location to sample noise at
* @param h_val fractal increment parameter
* @param lacunarity gap between successive frequencies
* @param octaves number of frequencies in the fBm
*
* The result is characterized by sharp, narrow trenches in low values
* and a more fbm-like quality in the mid-high values. Values are in
* the APPROXIMATE range [0 .. 1] depending upon the number of octaves
* evaluated. Typical results:
@code
* Min 0.00857137
* Max 1.26712
* Mean 0.395122
* s.d. 0.174796
* Var 0.0305536
@endcode
* The function call pow() is relatively expensive. Therefore, this
* function pre-computes and saves the spectral weights in a table for
* re-use in successive invocations.
*/
BN_EXPORT extern double bn_noise_turb(point_t point,
double h_val,
double lacunarity,
double octaves);
/**
*
* From "Texturing and Modeling, A Procedural Approach" 2nd ed
*/
BN_EXPORT extern double bn_noise_mf(point_t point,
double h_val,
double lacunarity,
double octaves,
double offset);
/**
*@brief
* A ridged noise pattern
*
* From "Texturing and Modeling, A Procedural Approach" 2nd ed p338
*/
BN_EXPORT extern double bn_noise_ridged(point_t point,
double h_val,
double lacunarity,
double octaves,
double offset);
__END_DECLS
#endif /* BN_NOISE_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-1130
View File
File diff suppressed because it is too large Load Diff
-205
View File
@@ -1,205 +0,0 @@
/* P O L Y . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_poly
*
* @brief Library for dealing with polynomials.
*/
/** @{ */
/** @file poly.h */
#ifndef BN_POLY_H
#define BN_POLY_H
#include "common.h"
#include "bu/magic.h"
#include "bn/defines.h"
#include "bn/complex.h"
__BEGIN_DECLS
/* This could be larger, or even dynamic... */
#define BN_MAX_POLY_DEGREE 6 /* Maximum Poly Order */
/**
* Polynomial data type
* bn_poly->cf[n] corresponds to X^n
*/
typedef struct bn_poly {
uint32_t magic;
size_t dgr;
fastf_t cf[BN_MAX_POLY_DEGREE+1];
} bn_poly_t;
#define BN_CK_POLY(_p) BU_CKMAG(_p, BN_POLY_MAGIC, "struct bn_poly")
#define BN_POLY_NULL ((struct bn_poly *)NULL)
#define BN_POLY_INIT_ZERO { BN_POLY_MAGIC, 0, {0.0} }
/**
* bn_poly_mul
*
* @brief
* multiply two polynomials
*/
BN_EXPORT extern struct bn_poly *bn_poly_mul(struct bn_poly *product,
const struct bn_poly *m1,
const struct bn_poly *m2);
/**
* bn_poly_scale
*
* @brief
* scale a polynomial
*/
BN_EXPORT extern struct bn_poly *bn_poly_scale(struct bn_poly *eqn,
double factor);
/**
* bn_poly_add
* @brief
* add two polynomials
*/
BN_EXPORT extern struct bn_poly *bn_poly_add(struct bn_poly *sum,
const struct bn_poly *poly1,
const struct bn_poly *poly2);
/**
* bn_poly_sub
* @brief
* subtract two polynomials
*/
BN_EXPORT extern struct bn_poly *bn_poly_sub(struct bn_poly *diff,
const struct bn_poly *poly1,
const struct bn_poly *poly2);
/**
* @brief
* Divides any polynomial into any other polynomial using synthetic
* division. Both polynomials must have real coefficients.
*/
BN_EXPORT extern void bn_poly_synthetic_division(struct bn_poly *quo,
struct bn_poly *rem,
const struct bn_poly *dvdend,
const struct bn_poly *dvsor);
/**
*@brief
* Uses the quadratic formula to find the roots (in `complex' form) of
* any quadratic equation with real coefficients.
*
* @return 1 for success
* @return 0 for fail.
*/
BN_EXPORT extern int bn_poly_quadratic_roots(struct bn_complex roots[],
const struct bn_poly *quadrat);
/**
*@brief
* Uses the cubic formula to find the roots (in `complex' form)
* of any cubic equation with real coefficients.
*
* to solve a polynomial of the form:
*
* X**3 + c1*X**2 + c2*X + c3 = 0,
*
* first reduce it to the form:
*
* Y**3 + a*Y + b = 0,
*
* where
* Y = X + c1/3,
* and
* a = c2 - c1**2/3,
* b = (2*c1**3 - 9*c1*c2 + 27*c3)/27.
*
* Then we define the value delta, D = b**2/4 + a**3/27.
*
* If D > 0, there will be one real root and two conjugate
* complex roots.
* If D = 0, there will be three real roots at least two of
* which are equal.
* If D < 0, there will be three unequal real roots.
*
* Returns 1 for success, 0 for fail.
*/
BN_EXPORT extern int bn_poly_cubic_roots(struct bn_complex roots[],
const struct bn_poly *eqn);
/**
*@brief
* Uses the quartic formula to find the roots (in `complex' form)
* of any quartic equation with real coefficients.
*
* @return 1 for success
* @return 0 for fail.
*/
BN_EXPORT extern int bn_poly_quartic_roots(struct bn_complex roots[],
const struct bn_poly *eqn);
BN_EXPORT extern int bn_poly_findroot(bn_poly_t *eqn,
bn_complex_t *nxZ,
const char *str);
BN_EXPORT extern void bn_poly_eval_w_2derivatives(bn_complex_t *cZ,
bn_poly_t *eqn,
bn_complex_t *b,
bn_complex_t *c,
bn_complex_t *d);
BN_EXPORT extern int bn_poly_checkroots(bn_poly_t *eqn,
bn_complex_t *roots,
int nroots);
BN_EXPORT extern void bn_poly_deflate(bn_poly_t *oldP,
bn_complex_t *root);
BN_EXPORT extern int bn_poly_roots(bn_poly_t *eqn,
bn_complex_t roots[],
const char *name);
/**
* Print out the polynomial.
*/
BN_EXPORT extern void bn_pr_poly(const char *title,
const struct bn_poly *eqn);
/**
* Print out the roots of a given polynomial (complex numbers)
*/
BN_EXPORT extern void bn_pr_roots(const char *title,
const struct bn_complex roots[],
int n);
__END_DECLS
#endif /* BN_POLY_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-185
View File
@@ -1,185 +0,0 @@
/* Q M A T H . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_quat
*
* @brief
* Quaternion math routines.
*
* Unit Quaternions:
* Q = [ r, a ] where r = cos(theta/2) = rotation amount
* |a| = sin(theta/2) = rotation axis
*
* If a = 0 we have the reals; if one coord is zero we have
* complex numbers (2D rotations).
*
* [r, a][s, b] = [rs - a.b, rb + sa + axb]
*
* -1
* [r, a] = (r - a) / (r^2 + a.a)
*
* Powers of quaternions yield incremental rotations,
* e.g. Q^3 is rotated three times as far as Q.
*
* Some operations on quaternions:
* -1
* [0, P'] = Q [0, P]Q Rotate a point P by quaternion Q
* -1 a
* slerp(Q, R, a) = Q(Q R) Spherical linear interp: 0 < a < 1
*
* bisect(P, Q) = (P + Q) / |P + Q| Great circle bisector
*
* Additions inspired by "Quaternion Calculus For Animation" by Ken Shoemake,
* SIGGRAPH '89 course notes for "Math for SIGGRAPH", May 1989.
*
*/
/** @{ */
/* @file qmath.h */
#ifndef BN_QMATH_H
#define BN_QMATH_H
#include "common.h"
#include "vmath.h"
#include "bn/defines.h"
__BEGIN_DECLS
/*
* Quaternion support
*/
/**
*@brief Convert Matrix to Quaternion.
*/
BN_EXPORT extern void quat_mat2quat(quat_t quat,
const mat_t mat);
/**
*@brief Convert Quaternion to Matrix.
*
* NB: This only works for UNIT quaternions. We may get imaginary results
* otherwise. We should normalize first (still yields same rotation).
*/
BN_EXPORT extern void quat_quat2mat(mat_t mat,
const quat_t quat);
/**
*@brief Gives the euclidean distance between two quaternions.
*/
BN_EXPORT extern double quat_distance(const quat_t q1,
const quat_t q2);
/**
*@brief
* Gives the quaternion point representing twice the rotation
* from q1 to q2.
*
* Needed for patching Bezier curves together.
* A rather poor name admittedly.
*/
BN_EXPORT extern void quat_double(quat_t qout,
const quat_t q1,
const quat_t q2);
/**
*@brief Gives the bisector of quaternions q1 and q2.
*
* (Could be done with quat_slerp and factor 0.5)
* [I believe they must be unit quaternions this to work]
*/
BN_EXPORT extern void quat_bisect(quat_t qout,
const quat_t q1,
const quat_t q2);
/**
*@brief
* Do Spherical Linear Interpolation between two unit quaternions
* by the given factor.
*
* As f goes from 0 to 1, qout goes from q1 to q2.
* Code based on code by Ken Shoemake
*/
BN_EXPORT extern void quat_slerp(quat_t qout,
const quat_t q1,
const quat_t q2,
double f);
/**
*@brief
* Spherical Bezier Interpolate between four quaternions by amount f.
* These are intended to be used as start and stop quaternions along
* with two control quaternions chosen to match spline segments with
* first order continuity.
*
* Uses the method of successive bisection.
*/
BN_EXPORT extern void quat_sberp(quat_t qout,
const quat_t q1,
const quat_t qa,
const quat_t qb,
const quat_t q2,
double f);
/**
*@brief
* Set the quaternion q1 to the quaternion which yields the
* smallest rotation from q2 (of the two versions of q1 which
* produce the same orientation).
*
* Note that smallest euclidian distance implies smallest great
* circle distance as well (since surface is convex).
*/
BN_EXPORT extern void quat_make_nearest(quat_t q1,
const quat_t q2);
BN_EXPORT extern void quat_print(const char *title,
const quat_t quat);
/**
*@brief
* Exponentiate a quaternion, assuming that the scalar part is 0.
* Code by Ken Shoemake.
*/
BN_EXPORT extern void quat_exp(quat_t out,
const quat_t in);
/**
*@brief
* Take the natural logarithm of a unit quaternion.
* Code by Ken Shoemake.
*/
BN_EXPORT extern void quat_log(quat_t out,
const quat_t in);
__END_DECLS
#endif /* BN_QMATH_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-155
View File
@@ -1,155 +0,0 @@
/* R A N D . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_rnt
*
* @brief
* A supply of fast pseudo-random numbers from table in bn/rand.c.
* The values are in the open interval (i.e. exclusive) of 0.0 to 1.0
* range with a period of 4096.
*
* @par Usage:
@code
unsigned idx;
float f;
BN_RANDSEED(idx, integer_seed);
while (NEED_MORE_RAND_NUMBERS) {
f = BN_RANDOM(idx);
}
@endcode
*
* Note that the values from bn_rand_half() become all 0.0 when the
* benchmark flag is set (bn_rand_halftab is set to all 0's). The
* numbers from bn_rand_table do not change, because the procedural
* noise would cease to exist.
*/
/** @{ */
/** @file rand.h */
#ifndef BN_RAND_H
#define BN_RAND_H
#include "common.h"
#include "bn/defines.h"
__BEGIN_DECLS
#define BN_RAND_TABSIZE 4096
#define BN_RAND_TABMASK 0xfff
#define BN_RANDSEED(_i, _seed) _i = ((unsigned)_seed) % BN_RAND_TABSIZE
/**
* This is our table of random numbers. Rather than calling drand48()
* or random() or rand() we just pick numbers out of this table. This
* table has 4096 unique entries with floating point values ranging
* from the open interval (i.e. exclusive) 0.0 to 1.0 range.
*
* There are convenience macros for access in the bn.h header.
*/
BN_EXPORT extern const float bn_rand_table[BN_RAND_TABSIZE];
/** BN_RANDOM always gives numbers between the open interval 0.0 to 1.0 */
#define BN_RANDOM(_i) bn_rand_table[ _i = (_i+1) % BN_RAND_TABSIZE ]
/** BN_RANDHALF always gives numbers between the open interval -0.5 and 0.5 */
#define BN_RANDHALF(_i) (bn_rand_table[ _i = (_i+1) % BN_RAND_TABSIZE ]-0.5)
#define BN_RANDHALF_INIT(_p) _p = bn_rand_table
#define BN_RANDHALFTABSIZE 16535 /* Powers of two give streaking */
BN_EXPORT extern int bn_randhalftabsize;
/**
* The actual table of random floating point numbers with values in
* the closed interval (i.e. inclusive) -0.5 to +0.5 range.
*
* For benchmarking purposes, this table is zeroed.
*/
BN_EXPORT extern float bn_rand_halftab[BN_RANDHALFTABSIZE];
/**
* random numbers between the closed interval -0.5 to 0.5 inclusive,
* except when benchmark flag is set, when this becomes a constant 0.0
*
* @param _p float pointer type initialized by bn_rand_init()
*
*/
#define bn_rand_half(_p) \
((++(_p) >= &bn_rand_halftab[bn_randhalftabsize] || \
(_p) < bn_rand_halftab) ? \
*((_p) = bn_rand_halftab) : *(_p))
/**
* initialize the seed for the large random number table (halftab)
*
* @param _p float pointer to be initialized, used for bn_rand0to1()
* and bn_rand_half()
* @param _seed Integer SEED for offset in the table.
*
*/
#define bn_rand_init(_p, _seed) \
(_p) = &bn_rand_halftab[ \
(int)(\
(bn_rand_halftab[(_seed)%bn_randhalftabsize] + 0.5) * \
(bn_randhalftabsize-1)) ]
/**
* random numbers in the closed interval 0.0 to 1.0 range (inclusive)
* except when benchmarking, when this is always 0.5
*
* @param _q float pointer type initialized by bn_rand_init()
*
*/
#define bn_rand0to1(_q) (bn_rand_half(_q)+0.5)
#define BN_SINTABSIZE 2048
#define bn_tab_sin(_a) (((_a) > 0) ? \
(bn_sin_table[(int)((0.5+ (_a)*(BN_SINTABSIZE / M_2PI)))&(BN_SINTABSIZE-1)]) :\
(-bn_sin_table[(int)((0.5- (_a)*(BN_SINTABSIZE / M_2PI)))&(BN_SINTABSIZE-1)]))
/**
* table of floating point sine values in the closed (i.e. inclusive)
* interval -1.0 to 1.0 range.
*/
BN_EXPORT extern const float bn_sin_table[BN_SINTABSIZE];
/**
*@brief
* For benchmarking purposes, make the random number table predictable.
* Setting to all zeros keeps dithered values at their original values.
*/
BN_EXPORT extern void bn_mathtab_constant(void);
__END_DECLS
#endif /* BN_RAND_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-68
View File
@@ -1,68 +0,0 @@
/* R A N D M T . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_rmt
*
* @brief
* Mersenne Twister random number generation as defined by MT19937.
*
* Generates one pseudorandom real number (double) which is uniformly
* distributed on [0, 1]-interval, for each call.
*
* @par Usage:
@code
double d;
bn_randmt_seed(integer_seed);
while (NEED_MORE_RAND_NUMBERS) {
d = bn_randmt();
}
@endcode
*
*/
/** @{ */
/** @file randmt.h */
#ifndef BN_RANDMT_H
#define BN_RANDMT_H
#include "common.h"
#include "bn/defines.h"
__BEGIN_DECLS
BN_EXPORT extern double bn_randmt(void);
BN_EXPORT extern void bn_randmt_seed(unsigned long seed);
__END_DECLS
#endif /* BN_RANDMT_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-81
View File
@@ -1,81 +0,0 @@
/* B N _ S T R . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_str
*
* @brief
* LIBBN encode/decode string routines.
*
*/
/** @{ */
/** @file bn/str.h */
#ifndef BN_STR_H
#define BN_STR_H
#include "common.h"
#include "vmath.h"
#include "bu/vls.h"
#include "bn/defines.h"
__BEGIN_DECLS
/**
* @brief Support routines for the math functions
*/
/* XXX Really need a decode_array function that uses atof(),
* XXX so that junk like leading { and commas between inputs
* XXX don't spoil the conversion.
*/
BN_EXPORT extern int bn_decode_mat(mat_t m,
const char *str);
BN_EXPORT extern int bn_decode_quat(quat_t q,
const char *str);
BN_EXPORT extern int bn_decode_vect(vect_t v,
const char *str);
BN_EXPORT extern int bn_decode_hvect(hvect_t v,
const char *str);
BN_EXPORT extern void bn_encode_mat(struct bu_vls *vp,
const mat_t m);
BN_EXPORT extern void bn_encode_quat(struct bu_vls *vp,
const quat_t q);
BN_EXPORT extern void bn_encode_vect(struct bu_vls *vp,
const vect_t v);
BN_EXPORT extern void bn_encode_hvect(struct bu_vls *vp,
const hvect_t v);
__END_DECLS
#endif /* BN_STR_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-494
View File
@@ -1,494 +0,0 @@
/* T A B D A T A . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_tabdata
*
* @brief
* Routines for processing tables (curves) of data with one independent
* parameter which is common to many sets of dependent data values.
*
* Data structures to assist with recording many sets of data sampled
* along the same set of independent variables.
*
* The overall notion is that each sample should be as compact as
* possible (an array of measurements), with all the context stored in
* one place.
*
* These structures and support routines apply to any measured "curve"
* or "function" or "table" with one independent variable and one or
* more scalar dependent variable(s).
*
* The context is kept in an 'bn_table' structure, and the data for
* one particular sample are kept in an 'bn_tabdata' structure.
*
* The contents of the sample in val[j] are interpreted in the
* interval (wavel[j]..wavel[j+1]). This value could be power,
* albedo, absorption, refractive index, or any other
* wavelength-specific parameter.
*
* For example, if the val[] array contains power values, then val[j]
* contains the integral of the power from wavel[j] to wavel[j+1]
*
* As an example, assume nwave=2, wavel[0]=500, wavel[1]=600, wavel[2]=700.
* Then val[0] would contain data for the 500 to 600nm interval,
* and val[1] would contain data for the 600 to 700nm interval.
* There would be no storage allocated for val[2] -- don't use it!
* There are several interpretations of this:
* 1) val[j] stores the total (integral, area) value for the interval, or
* 2) val[j] stores the average value across the interval.
*
* The intervals need not be uniformly spaced; it is acceptable to
* increase wavelength sampling density around "important"
* frequencies.
*
* Operates on bn_table (independent var) and
* bn_tabdata (dependent variable) structures.
*
* One application is for storing spectral curves, see spectrum.c
*
* @par Inspired by -
* Roy Hall and his book "Illumination and Color in Computer
*@n Generated Imagery", Springer Verlag, New York, 1989.
*@n ISBN 0-387-96774-5
*
* With thanks to Russ Moulton Jr, EOSoft Inc. for his "rad.c" module.
*/
/** @{ */
/* @file bn/tabdata.h */
#ifndef BN_TABDATA_H
#define BN_TABDATA_H
#include "common.h"
#include "bn/defines.h"
#include "bu/magic.h"
#include "bu/vls.h"
__BEGIN_DECLS
struct bn_table {
uint32_t magic;
size_t nx;
fastf_t x[1]; /**< @brief array of nx+1 wavelengths, dynamically sized */
};
#define BN_CK_TABLE(_p) BU_CKMAG(_p, BN_TABLE_MAGIC, "bn_table")
#define BN_TABLE_NULL ((struct bn_table *)NULL)
/* Gets an bn_table, with x[] having size _nx+1 */
#ifndef NO_BOMBING_MACROS
# define BN_GET_TABLE(_table, _nx) { \
if ((_nx) < 1) bu_bomb("RT_GET_TABLE() _nx < 1\n"); \
_table = (struct bn_table *)bu_calloc(1, \
sizeof(struct bn_table) + sizeof(fastf_t)*(_nx), \
"struct bn_table"); \
_table->magic = BN_TABLE_MAGIC; \
_table->nx = (_nx); }
#else
# define BN_GET_TABLE(_table, _nx) { \
_table = (struct bn_table *)bu_calloc(1, \
sizeof(struct bn_table) + sizeof(fastf_t)*(_nx), \
"struct bn_table"); \
_table->magic = BN_TABLE_MAGIC; \
_table->nx = (_nx); }
#endif
struct bn_tabdata {
uint32_t magic;
size_t ny;
const struct bn_table *table; /**< @brief Up pointer to definition of X axis */
fastf_t y[1]; /**< @brief array of ny samples, dynamically sized */
};
#define BN_CK_TABDATA(_p) BU_CKMAG(_p, BN_TABDATA_MAGIC, "bn_tabdata")
#define BN_TABDATA_NULL ((struct bn_tabdata *)NULL)
#define BN_SIZEOF_TABDATA_Y(_tabdata) sizeof(fastf_t)*((_tabdata)->ny)
#define BN_SIZEOF_TABDATA(_table) (sizeof(struct bn_tabdata) + \
sizeof(fastf_t)*((_table)->nx-1))
/* Gets an bn_tabdata, with y[] having size _ny */
#define BN_GET_TABDATA(_data, _table) { \
BN_CK_TABLE(_table);\
_data = (struct bn_tabdata *)bu_calloc(1, \
BN_SIZEOF_TABDATA(_table), "struct bn_tabdata"); \
_data->magic = BN_TABDATA_MAGIC; \
_data->ny = (_table)->nx; \
_data->table = (_table); }
/*
* Routines
*/
BN_EXPORT extern void bn_table_free(struct bn_table *tabp);
BN_EXPORT extern void bn_tabdata_free(struct bn_tabdata *data);
BN_EXPORT extern void bn_ck_table(const struct bn_table *tabp);
/*
*@brief
* Set up an independent "table margin" from 'first' to 'last',
* inclusive, using 'num' uniformly spaced samples. Num >= 1.
*/
BN_EXPORT extern struct bn_table *bn_table_make_uniform(size_t num,
double first,
double last);
/*
*@brief
* Sum the values from two data tables.
*/
BN_EXPORT extern void bn_tabdata_add(struct bn_tabdata *out,
const struct bn_tabdata *in1,
const struct bn_tabdata *in2);
/*
*@brief
* Element-by-element multiply the values from two data tables.
*/
BN_EXPORT extern void bn_tabdata_mul(struct bn_tabdata *out,
const struct bn_tabdata *in1,
const struct bn_tabdata *in2);
/*
*@brief
* Element-by-element multiply the values from three data tables.
*/
BN_EXPORT extern void bn_tabdata_mul3(struct bn_tabdata *out,
const struct bn_tabdata *in1,
const struct bn_tabdata *in2,
const struct bn_tabdata *in3);
/*
*@brief
* Element-by-element multiply the values from three data tables and a scalar.
*
* out += in1 * in2 * in3 * scale
*/
BN_EXPORT extern void bn_tabdata_incr_mul3_scale(struct bn_tabdata *out,
const struct bn_tabdata *in1,
const struct bn_tabdata *in2,
const struct bn_tabdata *in3,
double scale);
/*
*@brief
* Element-by-element multiply the values from two data tables and a scalar.
*
* out += in1 * in2 * scale
*/
BN_EXPORT extern void bn_tabdata_incr_mul2_scale(struct bn_tabdata *out,
const struct bn_tabdata *in1,
const struct bn_tabdata *in2,
double scale);
/*
*@brief
* Multiply every element in a data table by a scalar value 'scale'.
*/
BN_EXPORT extern void bn_tabdata_scale(struct bn_tabdata *out,
const struct bn_tabdata *in1,
double scale);
/*
*@brief
* Scale the independent axis of a table by 'scale'.
*/
BN_EXPORT extern void bn_table_scale(struct bn_table *tabp,
double scale);
/*
*@brief
* Multiply every element in data table in2 by a scalar value 'scale',
* add it to the element in in1, and store in 'out'.
* 'out' may overlap in1 or in2.
*/
BN_EXPORT extern void bn_tabdata_join1(struct bn_tabdata *out,
const struct bn_tabdata *in1,
double scale,
const struct bn_tabdata *in2);
/*
*@brief
* Multiply every element in data table in2 by a scalar value 'scale2',
* plus in3 * scale3, and
* add it to the element in in1, and store in 'out'.
* 'out' may overlap in1 or in2.
*/
BN_EXPORT extern void bn_tabdata_join2(struct bn_tabdata *out,
const struct bn_tabdata *in1,
double scale2,
const struct bn_tabdata *in2,
double scale3,
const struct bn_tabdata *in3);
BN_EXPORT extern void bn_tabdata_blend2(struct bn_tabdata *out,
double scale1,
const struct bn_tabdata *in1,
double scale2,
const struct bn_tabdata *in2);
BN_EXPORT extern void bn_tabdata_blend3(struct bn_tabdata *out,
double scale1,
const struct bn_tabdata *in1,
double scale2,
const struct bn_tabdata *in2,
double scale3,
const struct bn_tabdata *in3);
/*
*@brief
* Following interpretation #1, where y[j] stores the total (integral
* or area) value within the interval, return the area under the whole curve.
* This is simply totaling up the areas from each of the intervals.
*/
BN_EXPORT extern double bn_tabdata_area1(const struct bn_tabdata *in);
/*
*@brief
* Following interpretation #2, where y[j] stores the average
* value for the interval, return the area under
* the whole curve. Since the interval spacing need not be uniform,
* sum the areas of the rectangles.
*/
BN_EXPORT extern double bn_tabdata_area2(const struct bn_tabdata *in);
/*
*@brief
* Following interpretation #1, where y[j] stores the total (integral
* or area) value within the interval, return the area under the whole curve.
* This is simply totaling up the areas from each of the intervals.
* The curve value is found by multiplying corresponding entries from
* in1 and in2.
*/
BN_EXPORT extern double bn_tabdata_mul_area1(const struct bn_tabdata *in1,
const struct bn_tabdata *in2);
/*
*@brief
* Following interpretation #2,
* return the area under the whole curve.
* The curve value is found by multiplying corresponding entries from
* in1 and in2.
*/
BN_EXPORT extern double bn_tabdata_mul_area2(const struct bn_tabdata *in1,
const struct bn_tabdata *in2);
/*
*@brief
* Return the value of the curve at independent parameter value 'wl'.
* Linearly interpolate between values in the input table.
* Zero is returned for values outside the sampled range.
*/
BN_EXPORT extern fastf_t bn_table_lin_interp(const struct bn_tabdata *samp,
double wl);
/*
*@brief
* Given a set of sampled data 'olddata', resample it for different
* spacing, by linearly interpolating the values when an output span
* is entirely contained within an input span, and by taking the
* maximum when an output span covers more than one input span.
*
* This assumes interpretation (2) of the data, i.e. that the values
* are the average value across the interval.
*/
BN_EXPORT extern struct bn_tabdata *bn_tabdata_resample_max(const struct bn_table *newtable,
const struct bn_tabdata *olddata);
/*
*@brief
* Given a set of sampled data 'olddata', resample it for different
* spacing, by linearly interpolating the values when an output span
* is entirely contained within an input span, and by taking the
* average when an output span covers more than one input span.
*
* This assumes interpretation (2) of the data, i.e. that the values
* are the average value across the interval.
*/
BN_EXPORT extern struct bn_tabdata *bn_tabdata_resample_avg(const struct bn_table *newtable,
const struct bn_tabdata *olddata);
/*
*@brief
* Write out the table structure in an ASCII file,
* giving the number of values (minus 1), and the
* actual values.
*/
BN_EXPORT extern int bn_table_write(const char *filename,
const struct bn_table *tabp);
/*
*@brief
* Allocate and read in the independent variable values from an ASCII file,
* giving the number of samples (minus 1), and the
* actual values.
*/
BN_EXPORT extern struct bn_table *bn_table_read(const char *filename);
BN_EXPORT extern void bn_pr_table(const char *title,
const struct bn_table *tabp);
BN_EXPORT extern void bn_pr_tabdata(const char *title,
const struct bn_tabdata *data);
/*
*@brief
* Write out a given data table into an ASCII file,
* suitable for input to GNUPLOT.
*
* (set term postscript)
* (set output "|print-postscript")
* (plot "filename" with lines)
*/
BN_EXPORT extern int bn_print_table_and_tabdata(const char *filename,
const struct bn_tabdata *data);
/*
*@brief
* Read in a file which contains two columns of numbers, the first
* column being the wavelength, the second column being the sample value
* at that wavelength.
*
* A new bn_table structure and one bn_tabdata structure
* are created, a pointer to the bn_tabdata structure is returned.
* The final wavelength is guessed at.
*/
BN_EXPORT extern struct bn_tabdata *bn_read_table_and_tabdata(const char *filename);
BN_EXPORT extern struct bn_tabdata *bn_tabdata_binary_read(const char *filename,
size_t num,
const struct bn_table *tabp);
/*
*@brief
* Allocate storage for, and initialize, an array of 'num' data table
* structures.
* This subroutine is provided because the bn_tabdata structures
* are variable length.
*/
BN_EXPORT extern struct bn_tabdata *bn_tabdata_malloc_array(const struct bn_table *tabp,
size_t num);
BN_EXPORT extern void bn_tabdata_copy(struct bn_tabdata *out,
const struct bn_tabdata *in);
BN_EXPORT extern struct bn_tabdata *bn_tabdata_dup(const struct bn_tabdata *in);
/*
*@brief
* For a given table, allocate and return a tabdata structure
* with all elements initialized to 'val'.
*/
BN_EXPORT extern struct bn_tabdata *bn_tabdata_get_constval(double val,
const struct bn_table *tabp);
/*
*@brief
* Set all the tabdata elements to 'val'
*/
BN_EXPORT extern void bn_tabdata_constval(struct bn_tabdata *data,
double val);
/*
*@brief
* Convert an bn_tabdata/bn_table pair into a Tcl compatible string
* appended to a VLS. It will have form:
* x {...} y {...} nx # ymin # ymax #
*/
BN_EXPORT extern void bn_tabdata_to_tcl(struct bu_vls *vp,
const struct bn_tabdata *data);
/*
*@brief
* Given an array of (x, y) pairs, build the relevant bn_table and
* bn_tabdata structures.
*
* The table is terminated by an x value <= 0.
* Consistent with the interpretation of the spans,
* invent a final span ending x value.
*/
BN_EXPORT extern struct bn_tabdata *bn_tabdata_from_array(const double *array);
/*
*@brief
* Shift the data by a constant offset in the independent variable
* (often frequency), interpolating new sample values.
*/
BN_EXPORT extern void bn_tabdata_freq_shift(struct bn_tabdata *out,
const struct bn_tabdata *in,
double offset);
/*
*@brief
* Returns number of sample points between 'low' and 'hi', inclusive.
*/
BN_EXPORT extern size_t bn_table_interval_num_samples(const struct bn_table *tabp,
double low,
double hi);
/*
*@brief
* Remove all sampling points between subscripts i and j, inclusive.
* Don't bother freeing the tiny bit of storage at the end of the array.
* Returns number of points removed.
*/
BN_EXPORT extern size_t bn_table_delete_sample_pts(struct bn_table *tabp,
size_t i,
size_t j);
/*
*@brief
* A new table is returned which has sample points at places from
* each of the input tables.
*/
BN_EXPORT extern struct bn_table *bn_table_merge2(const struct bn_table *a,
const struct bn_table *b);
/*
*@brief
* Create a filter to accept power in a given band.
* The first and last filter values will be in the range 0..1,
* while all the internal filter values will be 1.0,
* and all samples outside the given band will be 0.0.
*
*
* @return NULL if given band does not overlap input spectrum
* @return tabdata*
*/
BN_EXPORT extern struct bn_tabdata *bn_tabdata_mk_linear_filter(const struct bn_table *spectrum,
double lower_wavelen,
double upper_wavelen);
__END_DECLS
#endif /* BN_TABDATA_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-138
View File
@@ -1,138 +0,0 @@
/* T O L . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_tol
*
* @brief Support for uniform tolerances
*
* A handy way of passing around the tolerance information needed to
* perform approximate floating-point calculations on geometry.
*
* dist & dist_sq establish the distance tolerance.
*
* If two points are closer together than dist, then they are to be
* considered the same point.
*
* For example:
@code
point_t a, b;
vect_t diff;
VSUB2(diff, a, b);
if (MAGNITUDE(diff) < tol->dist) a & b are the same.
or, more efficiently:
if (MAQSQ(diff) < tol->dist_sq)
@endcode
* perp & para establish the angular tolerance.
*
* If two rays emanate from the same point, and their dot product is
* nearly one, then the two rays are the same, while if their dot
* product is nearly zero, then they are perpendicular.
*
* For example:
@code
vect_t a, b;
if (fabs(VDOT(a, b)) >= tol->para) a & b are parallel
if (fabs(VDOT(a, b)) <= tol->perp) a & b are perpendicular
@endcode
*
*@note
* tol->dist_sq = tol->dist * tol->dist;
*@n tol->para = 1 - tol->perp;
*/
/** @{ */
/** @file bn/tol.h */
#ifndef BN_TOL_H
#define BN_TOL_H
#include "common.h"
#include "bn/defines.h"
#include "bu/magic.h"
__BEGIN_DECLS
struct bn_tol {
uint32_t magic;
double dist; /**< @brief >= 0 */
double dist_sq; /**< @brief dist * dist */
double perp; /**< @brief nearly 0 */
double para; /**< @brief nearly 1 */
};
/**
* asserts the validity of a bn_tol struct.
*/
#define BN_CK_TOL(_p) BU_CKMAG(_p, BN_TOL_MAGIC, "bn_tol")
/**
* initializes a bn_tol struct to zero without allocating any memory.
*/
#define BN_TOL_INIT(_p) { \
(_p)->magic = BN_TOL_MAGIC; \
(_p)->dist = 0.0; \
(_p)->dist_sq = 0.0; \
(_p)->perp = 0.0; \
(_p)->para = 1.0; \
}
/**
* macro suitable for declaration statement zero-initialization of a
* bn_tol struct.
*/
#define BN_TOL_INIT_ZERO { BN_TOL_MAGIC, 0.0, 0.0, 0.0, 1.0 }
/**
* returns truthfully whether a bn_tol struct has been initialized.
*/
#define BN_TOL_IS_INITIALIZED(_p) (((struct bn_tol *)(_p) != (struct bn_tol *)0) && LIKELY((_p)->magic == BN_TOL_MAGIC))
/**
* replaces the hard coded tolerance value
*/
#define BN_TOL_DIST 0.0005
/**
* returns truthfully whether a given dot-product of two unspecified
* vectors are within a specified parallel tolerance.
*/
#define BN_VECT_ARE_PARALLEL(_dot, _tol) \
(((_dot) <= -SMALL_FASTF) ? (NEAR_EQUAL((_dot), -1.0, (_tol)->perp)) : (NEAR_EQUAL((_dot), 1.0, (_tol)->perp)))
/**
* returns truthfully whether a given dot-product of two unspecified
* vectors are within a specified perpendicularity tolerance.
*/
#define BN_VECT_ARE_PERP(_dot, _tol) \
(((_dot) < 0) ? ((-(_dot))<=(_tol)->perp) : ((_dot) <= (_tol)->perp))
__END_DECLS
#endif /* BN_TOL_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-94
View File
@@ -1,94 +0,0 @@
/* V E C T F O N T . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BN_VECTFONT_H
#define BN_VECTFONT_H
#include "common.h"
#include "bn/defines.h"
__BEGIN_DECLS
/** @addtogroup bn_vfont
*
* @brief
* Terminal Independent Graphics Display Package.
*
* Mike Muuss July 31, 1978
*
* This routine is used to plot a string of ASCII symbols
* on the plot being generated, using a built-in set of fonts
* drawn as vector lists.
*
* Internally, the basic font resides in a 10x10 unit square.
* Externally, each character can be thought to occupy one square
* plotting unit; the 'scale'
* parameter allows this to be changed as desired, although scale
* factors less than 10.0 are unlikely to be legible.
*
* The vector font table here was provided courtesy of Dr. Bruce
* Henrikson and Dr. Stephen Wolff, US Army Ballistic Research
* Laboratory, Summer of 1978. They had developed it for their
* remote Houston Instruments pen plotter package for the
* GE Tymeshare system.
*
* Used by LIBPLOT3 and LIBRT for simple vector fonts.
*
* Vector font definitions, for TIG-PACK fonts.
*/
/** @{ */
/** @file bn/vectfont.h */
/*
* Motion encoding macros
*
* All characters reference absolute points within a 10 x 10 square
*/
#define brt(x, y) (11*x+y)
#define drk(x, y) -(11*x+y)
#define VFONT_LAST -128 /**< @brief 0200 Marks end of stroke list */
#define NEGY -127 /**< @brief 0201 Denotes negative y stroke */
#define bneg(x, y) NEGY, brt(x, y)
#define dneg(x, y) NEGY, drk(x, y)
int *tp_getchar(const unsigned char *c);
/*
* Once-only setup routine
* Used by libplot3/symbol.c, so it can't be static.
* DEPRECATED: libplot3 has been merged into libbn, so this no longer needs to be public.
*/
BN_EXPORT extern void tp_setup(void);
/** @} */
__END_DECLS
#endif /* BN_VECTFONT_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-136
View File
@@ -1,136 +0,0 @@
/* V E R T _ T R E E . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_vtree
*
* @brief
* Vertex tree support
*
* Routines to manage a binary search tree of vertices.
*
* The actual vertices are stored in an array
* for convenient use by routines such as "mk_bot".
* The binary search tree stores indices into the array.
*
*/
/** @{ */
/** @file vert_tree.h */
#ifndef BN_VERT_TREE_H
#define BN_VERT_TREE_H
#include "common.h"
#include "bn/defines.h"
#include "bu/magic.h"
__BEGIN_DECLS
/**
* packaging structure
* holds all the required info for a single vertex tree
*/
struct vert_root {
uint32_t magic;
int tree_type; /**< @brief vertices or vertices with normals */
union vert_tree *the_tree; /**< @brief the actual vertex tree */
fastf_t *the_array; /**< @brief the array of vertices */
size_t curr_vert; /**< @brief the number of vertices currently in the array */
size_t max_vert; /**< @brief the current maximum capacity of the array */
};
#define TREE_TYPE_VERTS 1
#define TREE_TYPE_VERTS_AND_NORMS 2
#define VERT_BLOCK 512 /**< @brief number of vertices to malloc per call when building the array */
#define BN_CK_VERT_TREE(_p) BU_CKMAG(_p, VERT_TREE_MAGIC, "vert_tree")
/**
*@brief
* routine to create a vertex tree.
*
* Possible refinements include specifying an initial size
*/
BN_EXPORT extern struct vert_root *create_vert_tree(void);
/**
*@brief
* routine to create a vertex tree.
*
* Possible refinements include specifying an initial size
*/
BN_EXPORT extern struct vert_root *create_vert_tree_w_norms(void);
/**
*@brief
* Routine to free a vertex tree and all associated dynamic memory
*/
BN_EXPORT extern void free_vert_tree(struct vert_root *tree_root);
/**
*@brief
* Routine to add a vertex to the current list of part vertices.
* The array is re-alloc'd if needed.
* Returns index into the array of vertices where this vertex is stored
*/
BN_EXPORT extern size_t Add_vert(double x,
double y,
double z,
struct vert_root *tree_root,
fastf_t local_tol_sq);
/**
*@brief
* Routine to add a vertex and a normal to the current list of part vertices.
* The array is re-alloc'd if needed.
* Returns index into the array of vertices where this vertex and normal is stored
*/
BN_EXPORT extern size_t Add_vert_and_norm(double x,
double y,
double z,
double nx,
double ny,
double nz,
struct vert_root *tree_root,
fastf_t local_tol_sq);
/**
*@brief
* Routine to free the binary search tree and reset the current number of vertices.
* The vertex array is left untouched, for re-use later.
*/
BN_EXPORT extern void clean_vert_tree(struct vert_root *tree_root);
__END_DECLS
#endif /* BN_VERT_TREE_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-295
View File
@@ -1,295 +0,0 @@
/* V L I S T . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BN_VLIST_H
#define BN_VLIST_H
#include "common.h"
#include "vmath.h"
#include "bu/magic.h"
#include "bu/list.h"
#include "bn/defines.h"
__BEGIN_DECLS
/*----------------------------------------------------------------------*/
/** @addtogroup bn_vlist
*
* @brief
* Definitions for handling lists of vectors (really vertices, or
* points) and polygons in 3-space. Intended for common handling of
* wireframe display information, in the full resolution that is
* calculated in.
*
* On 32-bit machines, BN_VLIST_CHUNK of 35 results in bn_vlist
* structures just less than 1k bytes.
*
* The head of the doubly linked list can be just a "struct bu_list"
* head.
*
* To visit all the elements in the vlist:
* for (BU_LIST_FOR(vp, bn_vlist, hp)) {
* register int i;
* register int nused = vp->nused;
* register int *cmd = vp->cmd;
* register point_t *pt = vp->pt;
* for (i = 0; i < nused; i++, cmd++, pt++) {
* access(*cmd, *pt);
* access(vp->cmd[i], vp->pt[i]);
* }
* }
*/
/** @{ */
/** @file bn/vlist.h */
#define BN_VLIST_CHUNK 35 /**< @brief 32-bit mach => just less than 1k */
struct bn_vlist {
struct bu_list l; /**< @brief magic, forw, back */
size_t nused; /**< @brief elements 0..nused active */
int cmd[BN_VLIST_CHUNK]; /**< @brief VL_CMD_* */
point_t pt[BN_VLIST_CHUNK]; /**< @brief associated 3-point/vect */
};
#define BN_VLIST_NULL ((struct bn_vlist *)0)
#define BN_CK_VLIST(_p) BU_CKMAG((_p), BN_VLIST_MAGIC, "bn_vlist")
/* should these be enum? -Erik */
/* Values for cmd[] */
#define BN_VLIST_LINE_MOVE 0
#define BN_VLIST_LINE_DRAW 1
#define BN_VLIST_POLY_START 2 /**< @brief pt[] has surface normal */
#define BN_VLIST_POLY_MOVE 3 /**< @brief move to first poly vertex */
#define BN_VLIST_POLY_DRAW 4 /**< @brief subsequent poly vertex */
#define BN_VLIST_POLY_END 5 /**< @brief last vert (repeats 1st), draw poly */
#define BN_VLIST_POLY_VERTNORM 6 /**< @brief per-vertex normal, for interpolation */
#define BN_VLIST_TRI_START 7 /**< @brief pt[] has surface normal */
#define BN_VLIST_TRI_MOVE 8 /**< @brief move to first triangle vertex */
#define BN_VLIST_TRI_DRAW 9 /**< @brief subsequent triangle vertex */
#define BN_VLIST_TRI_END 10 /**< @brief last vert (repeats 1st), draw poly */
#define BN_VLIST_TRI_VERTNORM 11 /**< @brief per-vertex normal, for interpolation */
#define BN_VLIST_POINT_DRAW 12 /**< @brief Draw a single point */
#define BN_VLIST_POINT_SIZE 13 /**< @brief specify point pixel size */
#define BN_VLIST_LINE_WIDTH 14 /**< @brief specify line pixel width */
#define BN_VLIST_CMD_MAX 14 /**< @brief Max command number */
/**
* Applications that are going to use BN_ADD_VLIST and BN_GET_VLIST
* are required to execute this macro once, on their _free_hd:
* BU_LIST_INIT(&_free_hd);
*
* Note that BN_GET_VLIST and BN_FREE_VLIST are non-PARALLEL.
*/
#define BN_GET_VLIST(_free_hd, p) {\
(p) = BU_LIST_FIRST(bn_vlist, (_free_hd)); \
if (BU_LIST_IS_HEAD((p), (_free_hd))) { \
BU_ALLOC((p), struct bn_vlist); \
(p)->l.magic = BN_VLIST_MAGIC; \
} else { \
BU_LIST_DEQUEUE(&((p)->l)); \
} \
(p)->nused = 0; \
}
/** Place an entire chain of bn_vlist structs on the freelist _free_hd */
#define BN_FREE_VLIST(_free_hd, hd) { \
BU_CK_LIST_HEAD((hd)); \
BU_LIST_APPEND_LIST((_free_hd), (hd)); \
}
#define BN_ADD_VLIST(_free_hd, _dest_hd, pnt, draw) { \
register struct bn_vlist *_vp; \
BU_CK_LIST_HEAD(_dest_hd); \
_vp = BU_LIST_LAST(bn_vlist, (_dest_hd)); \
if (BU_LIST_IS_HEAD(_vp, (_dest_hd)) || _vp->nused >= BN_VLIST_CHUNK) { \
BN_GET_VLIST(_free_hd, _vp); \
BU_LIST_INSERT((_dest_hd), &(_vp->l)); \
} \
VMOVE(_vp->pt[_vp->nused], (pnt)); \
_vp->cmd[_vp->nused++] = (draw); \
}
/** Set a point size to apply to the vlist elements that follow. */
#define BN_VLIST_SET_POINT_SIZE(_free_hd, _dest_hd, _size) { \
struct bn_vlist *_vp; \
BU_CK_LIST_HEAD(_dest_hd); \
_vp = BU_LIST_LAST(bn_vlist, (_dest_hd)); \
if (BU_LIST_IS_HEAD(_vp, (_dest_hd)) || _vp->nused >= BN_VLIST_CHUNK) { \
BN_GET_VLIST(_free_hd, _vp); \
BU_LIST_INSERT((_dest_hd), &(_vp->l)); \
} \
_vp->pt[_vp->nused][0] = (_size); \
_vp->cmd[_vp->nused++] = BN_VLIST_POINT_SIZE; \
}
/** Set a line width to apply to the vlist elements that follow. */
#define BN_VLIST_SET_LINE_WIDTH(_free_hd, _dest_hd, _width) { \
struct bn_vlist *_vp; \
BU_CK_LIST_HEAD(_dest_hd); \
_vp = BU_LIST_LAST(bn_vlist, (_dest_hd)); \
if (BU_LIST_IS_HEAD(_vp, (_dest_hd)) || _vp->nused >= BN_VLIST_CHUNK) { \
BN_GET_VLIST(_free_hd, _vp); \
BU_LIST_INSERT((_dest_hd), &(_vp->l)); \
} \
_vp->pt[_vp->nused][0] = (_width); \
_vp->cmd[_vp->nused++] = BN_VLIST_LINE_WIDTH; \
}
BN_EXPORT extern int bn_vlist_cmd_cnt(struct bn_vlist *vlist);
BN_EXPORT extern int bn_vlist_bbox(struct bn_vlist *vp, point_t *bmin, point_t *bmax);
/**
* For plotting, a way of separating plots into separate color vlists:
* blocks of vlists, each with an associated color.
*/
struct bn_vlblock {
uint32_t magic;
size_t nused;
size_t max;
long *rgb; /**< @brief rgb[max] variable size array */
struct bu_list *head; /**< @brief head[max] variable size array */
struct bu_list *free_vlist_hd; /**< @brief where to get/put free vlists */
};
#define BN_CK_VLBLOCK(_p) BU_CKMAG((_p), BN_VLBLOCK_MAGIC, "bn_vlblock")
/**
* Convert a string to a vlist.
*
* 'scale' is the width, in mm, of one character.
*
* @param vhead vhead
* @param free_hd source of free vlists
* @param string string of chars to be plotted
* @param origin lower left corner of 1st char
* @param rot Transform matrix (WARNING: may xlate)
* @param scale scale factor to change 1x1 char sz
*
*/
BN_EXPORT extern void bn_vlist_3string(struct bu_list *vhead,
struct bu_list *free_hd,
const char *string,
const point_t origin,
const mat_t rot,
double scale);
/**
* Convert string to vlist in 2D
*
* A simpler interface, for those cases where the text lies in the X-Y
* plane.
*
* @param vhead vhead
* @param free_hd source of free vlists
* @param string string of chars to be plotted
* @param x lower left corner of 1st char
* @param y lower left corner of 1st char
* @param scale scale factor to change 1x1 char sz
* @param theta degrees ccw from X-axis
*
*/
BN_EXPORT extern void bn_vlist_2string(struct bu_list *vhead,
struct bu_list *free_hd,
const char *string,
double x,
double y,
double scale,
double theta);
/**
* Returns the description of a vlist cmd. Caller is responsible
* for freeing the returned string.
*/
BN_EXPORT extern const char *bn_vlist_get_cmd_description(int cmd);
/**
* Validate an bn_vlist chain for having reasonable values inside.
* Calls bu_bomb() if not.
*
* Returns -
* npts Number of point/command sets in use.
*/
BN_EXPORT extern int bn_ck_vlist(const struct bu_list *vhead);
/**
* Duplicate the contents of a vlist. Note that the copy may be more
* densely packed than the source.
*/
BN_EXPORT extern void bn_vlist_copy(struct bu_list *vlists,
struct bu_list *dest,
const struct bu_list *src);
/**
* Convert a vlist chain into a blob of network-independent binary,
* for transmission to another machine.
*
* The result is stored in a vls string, so that both the address and
* length are available conveniently.
*/
BN_EXPORT extern void bn_vlist_export(struct bu_vls *vls,
struct bu_list *hp,
const char *name);
/**
* Convert a blob of network-independent binary prepared by
* vls_vlist() and received from another machine, into a vlist chain.
*/
BN_EXPORT extern void bn_vlist_import(struct bu_list *vlists,
struct bu_list *hp,
struct bu_vls *namevls,
const unsigned char *buf);
BN_EXPORT extern void bn_vlist_cleanup(struct bu_list *hd);
BN_EXPORT extern struct bn_vlblock *bn_vlblock_init(struct bu_list *free_vlist_hd, /* where to get/put free vlists */
int max_ent);
BN_EXPORT extern void bn_vlblock_free(struct bn_vlblock *vbp);
BN_EXPORT extern struct bu_list *bn_vlblock_find(struct bn_vlblock *vbp,
int r,
int g,
int b);
BN_EXPORT void bn_vlist_rpp(struct bu_list *vlists, struct bu_list *hd, const point_t minn, const point_t maxx);
/** @} */
__END_DECLS
#endif /* BN_VLIST_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-402
View File
@@ -1,402 +0,0 @@
/* W A V E L E T . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bn_wavelet
*
* @brief
* This is a standard wavelet library that takes a given data buffer of some data
* type and then performs a wavelet transform on that data.
*
* The transform
* operations available are to either decompose or reconstruct a signal into its
* corresponding wavelet form based on the haar wavelet.
*
* Wavelet decompose/reconstruct operations
*
* - bn_wlt_haar_1d_double_decompose(tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_1d_float_decompose (tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_1d_char_decompose (tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_1d_short_decompose (tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_1d_int_decompose (tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_1d_long_decompose (tbuffer, buffer, dimen, channels, limit)
*
* - bn_wlt_haar_1d_double_reconstruct(tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_1d_float_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_1d_char_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_1d_short_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_1d_int_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_1d_long_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
*
* - bn_wlt_haar_2d_double_decompose(tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_2d_float_decompose (tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_2d_char_decompose (tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_2d_short_decompose (tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_2d_int_decompose (tbuffer, buffer, dimen, channels, limit)
* - bn_wlt_haar_2d_long_decompose (tbuffer, buffer, dimen, channels, limit)
*
* - bn_wlt_haar_2d_double_reconstruct(tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_2d_float_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_2d_char_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_2d_short_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_2d_int_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
* - bn_wlt_haar_2d_long_reconstruct (tbuffer, buffer, dimen, channels, sub_sz, limit)
*
* - bn_wlt_haar_2d_double_decompose2(tbuffer, buffer, width, height, channels, limit)
* - bn_wlt_haar_2d_float_decompose2 (tbuffer, buffer, width, height, channels, limit)
* - bn_wlt_haar_2d_char_decompose2 (tbuffer, buffer, width, height, channels, limit)
* - bn_wlt_haar_2d_short_decompose2 (tbuffer, buffer, width, height, channels, limit)
* - bn_wlt_haar_2d_int_decompose2 (tbuffer, buffer, width, height, channels, limit)
* - bn_wlt_haar_2d_long_decompose2 (tbuffer, buffer, width, height, channels, limit)
*
* - bn_wlt_haar_2d_double_reconstruct2(tbuffer, buffer, width, height, channels, sub_sz, limit)
* - bn_wlt_haar_2d_float_reconstruct2 (tbuffer, buffer, width, height, channels, sub_sz, limit)
* - bn_wlt_haar_2d_char_reconstruct2 (tbuffer, buffer, width, height, channels, sub_sz, limit)
* - bn_wlt_haar_2d_short_reconstruct2 (tbuffer, buffer, width, height, channels, sub_sz, limit)
* - bn_wlt_haar_2d_int_reconstruct2 (tbuffer, buffer, width, height, channels, sub_sz, limit)
* - bn_wlt_haar_2d_long_reconstruct2 (tbuffer, buffer, width, height, channels, sub_sz, limit)
*
*
* For greatest accuracy, it is preferable to convert everything to "double"
* and decompose/reconstruct with that. However, there are useful
* properties to performing the decomposition and/or reconstruction in
* various data types (most notably char).
*
* Rather than define all of these routines explicitly, we define
* 2 macros "decompose" and "reconstruct" which embody the structure of
* the function (which is common to all of them). We then instantiate
* these macros once for each of the data types. It's ugly, but it
* assures that a change to the structure of one operation type
* (decompose or reconstruct) occurs for all data types.
*
*
*
*
* bn_wlt_haar_1d_*_decompose(tbuffer, buffer, dimen, channels, limit)
* @par Parameters:
* - tbuffer a temporary data buffer 1/2 as large as "buffer". See (1) below.
* - buffer pointer to the data to be decomposed
* - dimen the number of samples in the data buffer
* - channels the number of values per sample
* - limit the extent of the decomposition
*
* Perform a Haar wavelet decomposition on the data in buffer "buffer". The
* decomposition is done "in place" on the data, hence the values in "buffer"
* are not preserved, but rather replaced by their decomposition.
* The number of original samples in the buffer (parameter "dimen") and the
* decomposition limit ("limit") must both be a power of 2 (e.g. 512, 1024).
* The buffer is decomposed into "average" and "detail" halves until the
* size of the "average" portion reaches "limit". Simultaneous
* decomposition of multi-plane (e.g. pixel) data, can be performed by
* indicating the number of planes in the "channels" parameter.
*
* (1) The process requires a temporary buffer which is 1/2 the size of the
* longest span to be decomposed. If the "tbuffer" argument is non-null then
* it is a pointer to a temporary buffer. If the pointer is NULL, then a
* local temporary buffer will be allocated (and freed).
*
* @par Examples:
@code
double dbuffer[512], cbuffer[256];
...
bn_wlt_haar_1d_double_decompose(cbuffer, dbuffer, 512, 1, 1);
@endcode
*
* performs complete decomposition on the data in array "dbuffer".
*
@code
double buffer[3][512]; /_* 512 samples, 3 values/sample (e.g. RGB?)*_/
double tbuffer[3][256]; /_* the temporary buffer *_/
...
bn_wlt_haar_1d_double_decompose(tbuffer, buffer, 512, 3, 1);
@endcode
*
* This will completely decompose the data in buffer. The first sample will
* be the average of all the samples. Alternatively:
*
* bn_wlt_haar_1d_double_decompose(tbuffer, buffer, 512, 3, 64);
*
* decomposes buffer into a 64-sample "average image" and 3 "detail" sets.
*
* bn_wlt_haar_1d_*_reconstruct(tbuffer, buffer, dimen, channels, sub_sz, limit)
*
*/
/** @{ */
/** @file wavelet.h */
#ifndef BN_WAVELET_H
#define BN_WAVELET_H
#include "common.h"
#include <stdio.h> /* For FILE */
#include "bn/defines.h"
__BEGIN_DECLS
#define CK_POW_2(dimen) { \
register size_t j; \
register size_t ok; \
for (ok=0, j=0; j < sizeof(size_t) * 8; j++) { \
if ((size_t)(1<<j) == dimen) { ok = 1; break; } \
} \
if (! ok) { \
bu_log("%s:%d value %ld should be power of 2 (2^%ld)\n", \
__FILE__, __LINE__, (long)dimen, (long)j); \
bu_bomb("CK_POW_2"); \
} \
}
BN_EXPORT extern void bn_wlt_haar_1d_double_decompose(double *tbuf,
double *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_double_reconstruct(double *tbuf,
double *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_float_decompose(float *tbuf,
float *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_float_reconstruct(float *tbuf,
float *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_char_decompose(char *tbuf,
char *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_char_reconstruct(char *tbuf, char *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_short_decompose(short *tbuf, short *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_short_reconstruct(short *tbuf, short *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_int_decompose(int *tbuf, int *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_int_reconstruct(int *tbuf,
int *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_long_decompose(long *tbuf, long *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_1d_long_reconstruct(long *tbuf, long *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_double_decompose(double *tbuf,
double *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_double_reconstruct(double *tbuf,
double *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_float_decompose(float *tbuf,
float *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_float_reconstruct(float *tbuf,
float *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_char_decompose(char *tbuf,
char *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_char_reconstruct(char *tbuf,
char *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_short_decompose(short *tbuf,
short *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_short_reconstruct(short *tbuf,
short *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_int_decompose(int *tbuf,
int *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_int_reconstruct(int *tbuf,
int *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_long_decompose(long *tbuf,
long *buf,
size_t dimen,
size_t depth,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_long_reconstruct(long *tbuf,
long *buf,
size_t dimen,
size_t depth,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_double_decompose2(double *tbuf,
double *buf,
size_t dimen,
size_t width,
size_t height,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_double_reconstruct2(double *tbuf,
double *buf,
size_t dimen,
size_t width,
size_t height,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_float_decompose2(float *tbuf,
float *buf,
size_t dimen,
size_t width,
size_t height,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_float_reconstruct2(float *tbuf,
float *buf,
size_t dimen,
size_t width,
size_t height,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_char_decompose2(char *tbuf,
char *buf,
size_t dimen,
size_t width,
size_t height,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_char_reconstruct2(char *tbuf,
char *buf,
size_t dimen,
size_t width,
size_t height,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_short_decompose2(short *tbuf,
short *buf,
size_t dimen,
size_t width,
size_t height,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_short_reconstruct2(short *tbuf,
short *buf,
size_t dimen,
size_t width,
size_t height,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_int_decompose2(int *tbuf,
int *buf,
size_t dimen,
size_t width,
size_t height,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_int_reconstruct2(int *tbuf,
int *buf,
size_t dimen,
size_t width,
size_t height,
size_t subimage_size,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_long_decompose2(long *tbuf,
long *buf,
size_t dimen,
size_t width,
size_t height,
size_t limit);
BN_EXPORT extern void bn_wlt_haar_2d_long_reconstruct2(long *tbuf,
long *buf,
size_t dimen,
size_t width,
size_t height,
size_t subimage_size,
size_t limit);
__END_DECLS
#endif /* BN_WAVELET_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
+64
View File
@@ -0,0 +1,64 @@
/* B O T . H
* BRL-CAD
*
* Copyright (c) 2001-2013 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 g_ */
/** @{ */
/** @file bot.h
*
* Header file for the "bot" specific structure. This is shared between
* the bot, and ars at the moment.
*/
/** @} */
struct bot_specific {
unsigned char bot_mode;
unsigned char bot_orientation;
unsigned char bot_flags;
size_t bot_ntri;
fastf_t *bot_thickness;
struct bu_bitv *bot_facemode;
genptr_t bot_facelist; /* head of linked list */
genptr_t *bot_facearray; /* head of face array */
size_t bot_tri_per_piece; /* log # tri per piece. 1 << bot_ltpp is tri per piece */
void *tie; /* FIXME: horrible blind cast, points to one in rt_bot_internal */
};
RT_EXPORT extern void rt_bot_prep_pieces(struct bot_specific *bot,
struct soltab *stp,
size_t ntri,
const struct bn_tol *tol);
RT_EXPORT extern size_t rt_botface(struct soltab *stp,
struct bot_specific *bot,
fastf_t *ap,
fastf_t *bp,
fastf_t *cp,
size_t face_no,
const struct bn_tol *tol);
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
+1261 -708
View File
File diff suppressed because it is too large Load Diff
-82
View File
@@ -1,82 +0,0 @@
/* B R E S O U R C E . H
* BRL-CAD
*
* Copyright (c) 2015 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.
*/
/** @file bresource.h
*
* BRL-CAD private system compatibility wrapper header that provides
* declarations for standard system RESOURCE LIMIT routines.
*
* This header is commonly used in lieu of including the following:
* sys/resource.h sys/time.h sys/wait.h
*
* This header does not belong to any BRL-CAD library but may used by
* all of them. Consider this header PRIVATE and subject to change,
* NOT TO BE USED BY THIRD PARTIES.
*
* The following preprocessor variables control header inclusions:
* HAVE_SYS_TIME_H
* HAVE_SYS_RESOURCE_H
* HAVE_SYS_WAIT_H
*/
#ifndef BRESOURCE_H
#define BRESOURCE_H
/* intentionally not included for header independence */
/* #include "common.h" */
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
/* this ugly hack overcomes a c89 + -pedantic-errors bug in glibc <2.9
* where it raises a warning for a trailing comma when including the
* sys/resource.h system header.
*
* need a better solution that preserves pedantic c89 compilation,
* ideally without resorting to a sys/resource.h compilation feature
* test (which will vary with build flags).
*/
#if !defined(__USE_GNU) && defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ < 9)
# define __USE_GNU 1
# define DEFINED_USE_GNU 1
#endif
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
#ifdef DEFINED_USE_GNU
# undef __USE_GNU
# undef DEFINED_USE_GNU
#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#endif /* BRESOURCE_H */
/*
* Local Variables:
* tab-width: 8
* mode: C
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
+8 -8
View File
@@ -1,7 +1,7 @@
/* B R L C A D . H
* BRL-CAD
*
* Copyright (c) 2004-2014 United States Government as represented by
* Copyright (c) 2004-2013 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
@@ -29,8 +29,8 @@
*
*/
#ifndef BRLCAD_H
#define BRLCAD_H
#ifndef __BRLCAD_H__
#define __BRLCAD_H__
#include "common.h"
@@ -51,13 +51,13 @@
#include "bn.h"
/* database format storage types */
#include "rt/db4.h"
#include "db.h"
/* raytrace interface constructs */
#include "raytrace.h"
/* trimmed nurb routines */
#include "rt/nurb.h"
#include "nurb.h"
/* the write-only database library interface */
#include "wdb.h"
@@ -65,13 +65,13 @@
/* in-memory representations of the database geometry objects. these
* are subject to change and should not be relied upon.
*/
#include "rt/geom.h"
#include "rtgeom.h"
/* database object functions
*/
#include "rt/func.h"
#include "rtfunc.h"
#endif /* BRLCAD_H */
#endif /* __BRLCAD_H__ */
/** @} */
/*
* Local Variables:
-108
View File
@@ -1,108 +0,0 @@
/* B R L C A D _ I D E N T . H
* BRL-CAD
*
* Copyright (c) 2007-2013 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.
*/
/** @file brlcad_version.h
*
* PRIVATE container header for determining compile-time information
* about BRL-CAD.
*
* External applications should NOT use or include this file. They
* should use the library-specific LIBRARY_version() functions.
* (e.g. bu_version())
*
*/
#ifndef BRLCAD_IDENT_H
#define BRLCAD_IDENT_H
#include "common.h"
/* for snprintf */
#include <stdio.h>
/* for strlen */
#include <string.h>
#include "brlcad_version.h"
/* Compilation Settings */
/**
* Compilation date, updated every time a build pass occurs.
*/
static const char *BRLCAD_DATE = BRLCAD_COMPILE_DATE;
/**
* Compilation host, updated every time a build pass occurs.
*/
static const char *BRLCAD_HOST = BRLCAD_COMPILE_HOST;
/**
* Compilation user, updated every time a build pass occurs.
*/
static const char *BRLCAD_USER = BRLCAD_COMPILE_USER;
/**
* Compilation count, updated every time a build pass occurs.
*/
static const int BRLCAD_COUNT = BRLCAD_COMPILE_COUNT;
/**
* Provides the release identifier details along with basic
* configuration and compilation information.
*/
static const char *
brlcad_ident(const char *title)
{
static char ident[1024] = {0};
size_t isize = 0;
/* header */
snprintf(ident, 1024, "BRL-CAD Release %s", brlcad_version());
/* optional title */
isize = strlen(ident);
if (title)
snprintf(ident + isize, 1024 - isize, " %s\n", title);
/* compile info */
isize = strlen(ident);
snprintf(ident + isize, 1024 - isize,
" %s, Compilation %d\n"
" %s@%s\n",
BRLCAD_DATE, BRLCAD_COUNT,
BRLCAD_USER, BRLCAD_HOST
);
return ident;
}
#endif /* BRLCAD_IDENT_H */
/*
* Local Variables:
* tab-width: 8
* mode: C
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
+127 -53
View File
@@ -1,7 +1,7 @@
/* B R L C A D _ V E R S I O N . H
* BRL-CAD
*
* Copyright (c) 2007-2014 United States Government as represented by
* Copyright (c) 2007-2013 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
@@ -17,7 +17,6 @@
* License along with this file; see the file named COPYING for more
* information.
*/
/** @file brlcad_version.h
*
* PRIVATE container header for determining compile-time version
@@ -29,86 +28,161 @@
*
*/
#ifndef BRLCAD_VERSION_H
#define BRLCAD_VERSION_H
#include "common.h"
/* for snprintf */
#include <stdio.h>
/* for strlen */
#include <string.h>
/**************************************************/
/* Compile-time version information (discouraged) */
/**************************************************/
/* FIXED VALUES */
/**
* Compile-time macro for testing whether the current compilation
* matches or precedes a given version triplet. Returns false if the
* triplet come after the current compilation version, true otherwise.
* Conventional use allows calling code to support multiple API
* versions simultaneously, particularly with respect to deprecation
* changes (see CHANGES).
* MAJOR.minor.patch version number
*
@code
#if BRLCAD_API(7,24,6)
... code that worked in 7.24.6 API and prior ...
#else
... current API ...
* should be an unquoted integer
*/
#ifndef BRLCAD_MAJOR
static const int BRLCAD_MAJOR =
#include "conf/MAJOR"
-0; /* in case file is empty */
#endif
@endcode
*/
#define BRLCAD_API(_major, _minor, _patch) \
(((_major) < BRLCAD_VERSION_MAJOR) || \
((_major) == BRLCAD_VERSION_MAJOR && (_minor) < BRLCAD_VERSION_MINOR) || \
((_major) == BRLCAD_VERSION_MAJOR && (_minor) == BRLCAD_VERSION_MINOR && (_patch) <= BRLCAD_VERSION_PATCH))
/*********************************************/
/* Run-time version information (encouraged) */
/*********************************************/
/**
* Run-time integer of the MAJOR.minor.patch version number.
* major.MINOR.patch version number
*
* should be an unquoted integer
*/
static const int BRLCAD_MAJOR = BRLCAD_VERSION_MAJOR;
#ifndef BRLCAD_MINOR
static const int BRLCAD_MINOR =
#include "conf/MINOR"
-0; /* in case file is empty */
#endif
/**
* Run-time integer of the major.MINOR.patch version number.
* major.minor.PATCH version number
*
* should be an unquoted integer
*/
static const int BRLCAD_MINOR = BRLCAD_VERSION_MINOR;
#ifndef BRLCAD_PATCH
static const int BRLCAD_PATCH =
#include "conf/PATCH"
-0; /* in case file is empty */
#endif
/* DYNAMIC VALUES */
/**
* Run-time integer of the major.minor.PATCH version number.
* compilation count, updated every time a build pass occurs
*
* should be an unquoted integer
*/
static const int BRLCAD_PATCH = BRLCAD_VERSION_PATCH;
/* helper macros to turn a preprocessor value into a string */
#define NUMHASH(x) #x
#define NUM2STR(x) NUMHASH(x)
#ifndef BRLCAD_COUNT
static const int BRLCAD_COUNT =
#include "conf/COUNT"
-0; /* in case file is empty */
#endif
/**
* Run-time string of the "MAJOR.MINOR.PATCH" version number.
* compilation date, updated every time a build pass occurs
*
* should be a quoted value
*/
static char BRLCAD_VERSION[32] = NUM2STR(BRLCAD_VERSION_MAJOR) "." NUM2STR(BRLCAD_VERSION_MINOR) "." NUM2STR(BRLCAD_VERSION_PATCH);
__BEGIN_DECLS
#ifndef BRLCAD_DATE
static const char BRLCAD_DATE[256] = {
#include "conf/DATE"
};
#endif
/**
* Provides the version string in MAJOR.MINOR.PATCH triplet form.
* compilation host, updated every time a build pass occurs
*
* should be a quoted value
*/
static inline const char *
#ifndef BRLCAD_HOST
static const char BRLCAD_HOST[256] = {
#include "conf/HOST"
};
#endif
/**
* configured installation path, updated every time a build pass
* occurs. should be a quoted value
*/
#ifndef BRLCAD_PATH
static const char BRLCAD_PATH[256] = {
#include "conf/PATH"
};
#endif
/**
* compilation user, updated every time a build pass occurs.
* should be a quoted value
*/
#ifndef BRLCAD_USER
static const char BRLCAD_USER[256] = {
#include "conf/USER"
};
#endif
static const char *brlcad_ident(const char *title);
/**
* provides the version string in MAJOR.MINOR.PATCH triplet form.
*/
static const char *
brlcad_version(void)
{
return BRLCAD_VERSION;
static char version[32] = {0};
if (version[0] == 0) {
snprintf(version, 32, "%d.%d.%d", BRLCAD_MAJOR, BRLCAD_MINOR, BRLCAD_PATCH);
/* quell use warning, does nothing useful except initialize
* the brlcad_ident string. it MUST come after setting version
*/
(void)brlcad_ident(NULL);
}
return version;
}
__END_DECLS
/**
* provides the release identifier details along with basic
* configuration and compilation information.
*/
static const char *
brlcad_ident(const char *title)
{
static char ident[1024] = {0};
if (ident[0] == 0) {
/* header */
size_t isize = 0;
snprintf(ident, 1024, "BRL-CAD Release %s", brlcad_version());
/* optional title */
isize = strlen(ident);
if (title)
snprintf(ident + isize, 1024 - isize, " %s\n", title);
/* compile info */
isize = strlen(ident);
snprintf(ident + isize, 1024 - isize,
" %s, Compilation %d\n"
" %s@%s:%s\n",
BRLCAD_DATE, BRLCAD_COUNT,
BRLCAD_USER, BRLCAD_HOST, BRLCAD_PATH
);
}
return ident;
}
#endif /* BRLCAD_VERSION_H */
/*
* Local Variables:
+8 -19
View File
@@ -1,7 +1,7 @@
/* B S O C K E T . H
/* B S E L E C T . H
* BRL-CAD
*
* Copyright (c) 2011-2014 United States Government as represented by
* Copyright (c) 2011-2013 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
@@ -17,13 +17,13 @@
* License along with this file; see the file named COPYING for more
* information.
*/
/** @file bsocket.h
/** @file bselect.h
*
* BRL-CAD private system compatibility wrapper header that provides
* declarations for native and standard system select() routines.
*
* This header is commonly used in lieu of including the following:
* sys/select.h, winsock2.h (select, fd_set)
* This header is commonly used in leu of including the following:
* sys/select.h
*
* This header does not belong to any BRL-CAD library but may used by
* all of them. Consider this header PRIVATE and subject to change,
@@ -31,8 +31,8 @@
*
*/
#ifndef BSOCKET_H
#define BSOCKET_H
#ifndef __BSELECT_H__
#define __BSELECT_H__
#include "common.h"
@@ -40,17 +40,6 @@
# include <sys/select.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
/* Windows Sockets provides select() and friends */
#if defined(_WIN32) && !defined(__CYGWIN__)
# ifndef _WINSOCKAPI_
# include <winsock2.h>
# endif
#endif
/* compatibility for pedantic bug/limitation in gcc 4.6.2, need to
* mark macros as extensions else they may emit "ISO C forbids
* braced-groups within expressions" warnings.
@@ -74,7 +63,7 @@
#endif /* GCC_PREREQ */
#endif /* BSOCKET_H */
#endif /* __BSELECT_H__ */
/*
* Local Variables:
+6201 -47
View File
File diff suppressed because it is too large Load Diff
-46
View File
@@ -1,46 +0,0 @@
set(bu_headers
avs.h
bitv.h
cmd.h
color.h
cv.h
debug.h
defines.h
endian.h
file.h
getopt.h
hash.h
hist.h
list.h
log.h
magic.h
malloc.h
mapped_file.h
mime.h
observer.h
opt.h
parallel.h
parse.h
path.h
ptbl.h
rb.h
simd.h
sort.h
str.h
time.h
units.h
version.h
vfont.h
vlb.h
vls.h
)
install(FILES ${bu_headers} DESTINATION ${INCLUDE_DIR}/brlcad/bu)
CMAKEFILES(${bu_headers})
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8
-259
View File
@@ -1,259 +0,0 @@
/* A V S . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_AVS_H
#define BU_AVS_H
#include "common.h"
#include <stddef.h> /* for size_t */
#include "bu/defines.h"
#include "bu/magic.h"
#include "bu/vls.h"
__BEGIN_DECLS
/*----------------------------------------------------------------------*/
/** @addtogroup bu_avs
*
* @brief
* Routines to manage attribute/value sets.
*/
/** @{ */
/** @file bu/avs.h */
/** for attr and avs use.
*/
typedef enum {
BU_ATTR_CREATED,
BU_ATTR_MODIFIED
} bu_attr_time_t;
/**
* These strings may or may not be individually allocated, it depends
* on usage.
*/
/* FIXME: can this be made to include a union (or a struct pointer) to
* allow for a binary attr? if so, some (if not all) attr functions
* will need to be modified; maybe add an artificial const string
* value to indicate the binary attr which will probably never be
* allowed to be changed other than programmatically (don't list,
* i.e., keep them hidden? no, we will at least want to show a date
* and time for the time stamp) */
struct bu_attribute_value_pair {
const char *name; /**< attribute name */
const char *value; /**< attribute value */
#if defined(USE_BINARY_ATTRIBUTES)
/* trying a solution to include binary attributes */
unsigned int binvaluelen;
const unsigned char *binvalue;
#endif
};
/**
* A variable-sized attribute-value-pair array.
*
* avp points to an array of [max] slots. The interface routines will
* realloc to extend as needed.
*
* In general, each of the names and values is a local copy made with
* bu_strdup(), and each string needs to be freed individually.
* However, if a name or value pointer is between readonly_min and
* readonly_max, then it is part of a big malloc block that is being
* freed by the caller, and should not be individually freed.
*/
struct bu_attribute_value_set {
uint32_t magic;
size_t count; /**< # valid entries in avp */
size_t max; /**< # allocated slots in avp */
void *readonly_min;
void *readonly_max;
struct bu_attribute_value_pair *avp; /**< array[max] */
};
typedef struct bu_attribute_value_set bu_avs_t;
#define BU_AVS_NULL ((struct bu_attribute_value_set *)0)
/**
* assert the integrity of a non-head node bu_attribute_value_set struct.
*/
#define BU_CK_AVS(_ap) BU_CKMAG(_ap, BU_AVS_MAGIC, "bu_attribute_value_set")
/**
* initialize a bu_attribute_value_set struct without allocating any memory.
*/
#define BU_AVS_INIT(_ap) { \
(_ap)->magic = BU_AVS_MAGIC; \
(_ap)->count = (_ap)->max = 0; \
(_ap)->readonly_min = (_ap)->readonly_max = (_ap)->avp = NULL; \
}
/**
* macro suitable for declaration statement initialization of a
* bu_attribute_value_set struct. does not allocate memory.
*/
#define BU_AVS_INIT_ZERO { BU_AVS_MAGIC, 0, 0, NULL, NULL, NULL }
/**
* returns truthfully whether a bu_attribute_value_set has been initialized via
* BU_AVS_INIT() or BU_AVS_INIT_ZERO.
*/
#define BU_AVS_IS_INITIALIZED(_ap) (((struct bu_attribute_value_set *)(_ap) != BU_AVS_NULL) && LIKELY((_ap)->magic == BU_AVS_MAGIC))
/**
* For loop iterator for avs structures.
*
* Provide an attribute value pair struct pointer and an attribute
* value set, and this will iterate over all entries. iteration order
* is not defined but should iterate over each AVS entry once.
*
* Example Use:
@code
void
print_avs(struct bu_attribute_value_set *avs) {
struct bu_attribute_value_pair *avpp;
for (BU_AVS_FOR(avpp, avs)) {
bu_log("key=%s, value=%s\n", avpp->name, avpp->value);
}
}
@endcode
*
*/
#define BU_AVS_FOR(_pp, _avp) \
(_pp) = ((const void *)(_avp) != (const void *)NULL) ? ((_avp)->count > 0 ? &(_avp)->avp[(_avp)->count-1] : NULL) : NULL; ((const void *)(_pp) != (const void *)NULL) && ((const void *)(_avp) != (const void *)NULL) && (_avp)->avp && (_pp) >= (_avp)->avp; (_pp)--
/**
* Some (but not all) attribute name and value string pointers are
* taken from an on-disk format bu_external block, while others have
* been bu_strdup()ed and need to be freed. This macro indicates
* whether the pointer needs to be freed or not.
*/
#define AVS_IS_FREEABLE(_avsp, _p) \
((_avsp)->readonly_max == NULL \
|| (const void *)(_p) < (_avsp)->readonly_min \
|| (const void *)(_p) > (_avsp)->readonly_max)
/**
* Initialize avs with storage for len entries.
*/
BU_EXPORT extern void bu_avs_init(struct bu_attribute_value_set *avp,
size_t len,
const char *str);
/**
* Initialize an empty avs.
*/
BU_EXPORT extern void bu_avs_init_empty(struct bu_attribute_value_set *avp);
/**
* Allocate storage for a new attribute/value set, with at least 'len'
* slots pre-allocated.
*/
BU_EXPORT extern struct bu_attribute_value_set *bu_avs_new(size_t len,
const char *str);
/**
* If the given attribute exists it will receive the new value,
* otherwise the set will be extended to have a new attribute/value
* pair.
*
* Returns -
* 0 some error occurred
* 1 existing attribute updated with new value
* 2 set extended with new attribute/value pair
*/
BU_EXPORT extern int bu_avs_add(struct bu_attribute_value_set *avp,
const char *attribute,
const char *value);
/**
* Add a bu_vls string as an attribute to a given attribute set,
* updating the value if it already exists.
*/
BU_EXPORT extern int bu_avs_add_vls(struct bu_attribute_value_set *avp,
const char *attribute,
const struct bu_vls *value_vls);
/**
* Add a name/value pair even if the name already exists in the set.
*/
BU_EXPORT extern void bu_avs_add_nonunique(struct bu_attribute_value_set *avsp,
const char *attribute,
const char *value);
/**
* Take all the attributes from 'src' and merge them into 'dest' by
* replacing an attribute if it already exists in the set.
*/
BU_EXPORT extern void bu_avs_merge(struct bu_attribute_value_set *dest,
const struct bu_attribute_value_set *src);
/**
* Get the value of a given attribute from an attribute set. The
* behavior is not currently well-defined for AVS containing
* non-unique attributes, but presently returns the first encountered.
* Returns NULL if the requested attribute is not present in the set.
*/
BU_EXPORT extern const char *bu_avs_get(const struct bu_attribute_value_set *avp,
const char *attribute);
/**
* Remove all occurrences of an attribute from the provided attribute
* set.
*
* @return
* -1 attribute not found in set
* @return
* 0 OK
*/
BU_EXPORT extern int bu_avs_remove(struct bu_attribute_value_set *avp,
const char *attribute);
/**
* Release all attributes in the provided attribute set.
*/
BU_EXPORT extern void bu_avs_free(struct bu_attribute_value_set *avp);
/**
* Print all attributes in an attribute set in "name = value" form,
* using the provided title.
*/
BU_EXPORT extern void bu_avs_print(const struct bu_attribute_value_set *avp,
const char *title);
/** @} */
__END_DECLS
#endif /* BU_AVS_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-438
View File
@@ -1,438 +0,0 @@
/* B I T V . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_BITV_H
#define BU_BITV_H
#include "common.h"
#include "bu/defines.h"
#include "bu/magic.h"
#include "bu/list.h"
#include "bu/vls.h"
__BEGIN_DECLS
/*----------------------------------------------------------------------*/
/** @addtogroup bu_bitv
*
* @brief
* Routines for managing efficient high-performance bit vectors of
* arbitrary length.
*
* The basic type "bitv_t" is defined in include/bu.h; it is the
* widest integer datatype for which efficient hardware support
* exists. BU_BITV_SHIFT and BU_BITV_MASK are also defined in bu.h
*
* These bit vectors are "little endian", bit 0 is in the right hand
* side of the [0] word.
*
*/
/** @{*/
/** @file bu/bitv.h */
/**
* bitv_t should be a fast integer type for implementing bit vectors.
*
* On many machines, this is a 32-bit "long", but on some machines a
* compiler/vendor-specific type such as "long long" or even 'char'
* can give access to faster integers.
*
* THE SIZE OF bitv_t MUST MATCH BU_BITV_SHIFT.
*/
typedef unsigned char bitv_t;
/**
* Bit vector shift size
*
* Should equal to: log2(sizeof(bitv_t)*8.0). Using bu_bitv_shift()
* will return a run-time computed shift size if the size of a bitv_t
* changes. Performance impact is rather minimal for most models but
* disabled for a handful of primitives that heavily rely on bit
* vectors.
*
* (8-bit type: 3, 16-bit type: 4, 32-bit type: 5, 64-bit type: 6)
*/
#ifdef CHAR_BIT
# if CHAR_BIT == 8
# define BU_BITV_SHIFT 3
# elif CHAR_BIT == 16
# define BU_BITV_SHIFT 4
# elif CHAR_BIT == 32
# define BU_BITV_SHIFT 5
# elif CHAR_BIT == 64
# define BU_BITV_SHIFT 6
# endif
#else
# define BU_BITV_SHIFT bu_bitv_shift()
#endif
/** Bit vector mask */
#define BU_BITV_MASK ((1<<BU_BITV_SHIFT)-1)
/**
* Bit vector data structure.
*
* bu_bitv uses a little-endian encoding, placing bit 0 on the right
* side of the 0th word.
*
* This is done only because left-shifting a 1 can be done in an
* efficient word-length-independent manner; going the other way would
* require a compile-time constant with only the sign bit set, and an
* unsigned right shift, which some machines don't have in hardware,
* or an extra subtraction.
*
* Application code should *never* peek at the bit-buffer; use the
* macros. The external hex form is most significant byte first (bit
* 0 is at the right). Note that MUVES does it differently.
*/
struct bu_bitv {
struct bu_list l; /**< linked list for caller's use */
size_t nbits; /**< actual size of bits[], in bits */
bitv_t bits[2]; /**< variable size array */
};
typedef struct bu_bitv bu_bitv_t;
#define BU_BITV_NULL ((struct bu_bitv *)0)
/**
* asserts the integrity of a non-head node bu_bitv struct.
*/
#define BU_CK_BITV(_bp) BU_CKMAG(_bp, BU_BITV_MAGIC, "bu_bitv")
/**
* initializes a bu_bitv struct without allocating any memory. this
* macro is not suitable for initializing a head list node.
*/
#define BU_BITV_INIT(_bp) { \
BU_LIST_INIT_MAGIC(&(_bp)->l, BU_BITV_MAGIC); \
(_bp)->nbits = 0; \
(_bp)->bits[0] = 0; \
(_bp)->bits[1] = 0; \
}
/**
* macro suitable for declaration statement initialization of a bu_bitv
* struct. does not allocate memory. not suitable for a head node.
*/
#define BU_BITV_INIT_ZERO { {BU_BITV_MAGIC, BU_LIST_NULL, BU_LIST_NULL}, 0, {0, 0} }
/**
* returns truthfully whether a bu_bitv has been initialized
*/
#define BU_BITV_IS_INITIALIZED(_bp) (((struct bu_bitv *)(_bp) != BU_BITV_NULL) && LIKELY((_bp)->l.magic == BU_BITV_MAGIC))
/**
* returns floor(log2(sizeof(bitv_t)*8.0)), i.e. the number of bits
* required with base-2 encoding to index any bit in an array of
* length sizeof(bitv_t)*8.0 bits long. users should not call this
* directly, instead calling the BU_BITV_SHIFT macro instead.
*/
BU_EXPORT extern size_t bu_bitv_shift(void);
/**
* Convert a number of words into the corresponding (bitv_t type) size
* as a bit-vector size.
*/
#define BU_WORDS2BITS(_nw) ((size_t)(_nw>0?_nw:0)*sizeof(bitv_t)*8)
/**
* Convert a bit-vector (stored in a bitv_t array) size into the
* corresponding word size.
*/
#define BU_BITS2WORDS(_nb) (((size_t)(_nb>0?_nb:0)+BU_BITV_MASK)>>BU_BITV_SHIFT)
/**
* Convert a bit-vector (stored in a bitv_t array) size into the
* corresponding total memory size (in bytes) of the bitv_t array.
*/
#define BU_BITS2BYTES(_nb) (BU_BITS2WORDS(_nb)*sizeof(bitv_t))
#if 1
#define BU_BITTEST(_bv, bit) \
(((_bv)->bits[(bit)>>BU_BITV_SHIFT] & (((bitv_t)1)<<((bit)&BU_BITV_MASK)))!=0)
#else
static __inline__ int BU_BITTEST(volatile void * addr, int nr)
{
int oldbit;
__asm__ __volatile__(
"btl %2, %1\n\tsbbl %0, %0"
:"=r" (oldbit)
:"m" (addr), "Ir" (nr));
return oldbit;
}
#endif
#define BU_BITSET(_bv, bit) \
((_bv)->bits[(bit)>>BU_BITV_SHIFT] |= (((bitv_t)1)<<((bit)&BU_BITV_MASK)))
#define BU_BITCLR(_bv, bit) \
((_bv)->bits[(bit)>>BU_BITV_SHIFT] &= ~(((bitv_t)1)<<((bit)&BU_BITV_MASK)))
/**
* zeros all of the internal storage bytes in a bit vector array
*/
#define BU_BITV_ZEROALL(_bv) \
{ \
if (LIKELY((_bv) && (_bv)->nbits != 0)) { \
unsigned char *bvp = (unsigned char *)(_bv)->bits; \
size_t nbytes = BU_BITS2BYTES((_bv)->nbits); \
do { \
*bvp++ = (unsigned char)0; \
} while (--nbytes != 0); \
} \
}
/* This is not done by default for performance reasons */
#ifdef NO_BOMBING_MACROS
# define BU_BITV_BITNUM_CHECK(_bv, _bit) (void)(_bv)
#else
# define BU_BITV_BITNUM_CHECK(_bv, _bit) /* Validate bit number */ \
if (UNLIKELY(((unsigned)(_bit)) >= (_bv)->nbits)) {\
bu_log("BU_BITV_BITNUM_CHECK bit number (%u) out of range (0..%u)\n", \
((unsigned)(_bit)), (_bv)->nbits); \
bu_bomb("process self-terminating\n");\
}
#endif
#ifdef NO_BOMBING_MACROS
# define BU_BITV_NBITS_CHECK(_bv, _nbits) (void)(_bv)
#else
# define BU_BITV_NBITS_CHECK(_bv, _nbits) /* Validate number of bits */ \
if (UNLIKELY(((unsigned)(_nbits)) > (_bv)->nbits)) {\
bu_log("BU_BITV_NBITS_CHECK number of bits (%u) out of range (> %u)", \
((unsigned)(_nbits)), (_bv)->nbits); \
bu_bomb("process self-terminating"); \
}
#endif
/**
* Macros to efficiently find all the ONE bits in a bit vector.
* Counts words down, counts bits in words going up, for speed &
* portability. It does not matter if the shift causes the sign bit
* to smear to the right.
*
* @par Example:
@code
BU_BITV_LOOP_START(bv) {
fiddle(BU_BITV_LOOP_INDEX);
} BU_BITV_LOOP_END;
@endcode
*
*/
#define BU_BITV_LOOP_START(_bv) \
{ \
int _wd; /* Current word number */ \
BU_CK_BITV(_bv); \
for (_wd=BU_BITS2WORDS((_bv)->nbits)-1; _wd>=0; _wd--) { \
int _b; /* Current bit-in-word number */ \
bitv_t _val; /* Current word value */ \
if ((_val = (_bv)->bits[_wd])==0) continue; \
for (_b=0; _b < BU_BITV_MASK+1; _b++, _val >>= 1) { \
if (!(_val & 1)) continue;
/**
* This macro is valid only between a BU_BITV_LOOP_START/LOOP_END
* pair, and gives the bit number of the current iteration.
*/
#define BU_BITV_LOOP_INDEX ((_wd << BU_BITV_SHIFT) | _b)
/**
* Paired with BU_BITV_LOOP_START()
*/
#define BU_BITV_LOOP_END \
} /* end for (_b) */ \
} /* end for (_wd) */ \
} /* end block */
/**
* Allocate storage for a new bit vector of at least 'nbits' in
* length. The bit vector itself is guaranteed to be initialized to
* all zero.
*/
BU_EXPORT extern struct bu_bitv *bu_bitv_new(size_t nbits);
/**
* Release all internal storage for this bit vector.
*
* It is the caller's responsibility to not use the pointer 'bv' any
* longer. It is the caller's responsibility to dequeue from any
* linked list first.
*/
BU_EXPORT extern void bu_bitv_free(struct bu_bitv *bv);
/**
* Set all the bits in the bit vector to zero.
*
* Also available as a BU_BITV_ZEROALL macro if you don't desire the
* pointer checking.
*/
BU_EXPORT extern void bu_bitv_clear(struct bu_bitv *bv);
/**
* TBD
*/
BU_EXPORT extern void bu_bitv_or(struct bu_bitv *ov, const struct bu_bitv *iv);
/**
* TBD
*/
BU_EXPORT extern void bu_bitv_and(struct bu_bitv *ov, const struct bu_bitv *iv);
/**
* Print the bits set in a bit vector.
*/
BU_EXPORT extern void bu_bitv_vls(struct bu_vls *v, const struct bu_bitv *bv);
/**
* Print the bits set in a bit vector. Use bu_vls stuff, to make only
* a single call to bu_log().
*/
BU_EXPORT extern void bu_pr_bitv(const char *str, const struct bu_bitv *bv);
/**
* Convert a bit vector to an ascii string of hex digits. The string
* is from MSB to LSB (bytes and bits).
*/
BU_EXPORT extern void bu_bitv_to_hex(struct bu_vls *v, const struct bu_bitv *bv);
/**
* Convert a string of HEX digits (as produced by bu_bitv_to_hex) into
* a bit vector.
*/
BU_EXPORT extern struct bu_bitv *bu_hex_to_bitv(const char *str);
/**
* Convert a bit vector to an ascii string of binary digits in the GCC
* format ("0bn..."). The string is from MSB to LSB (bytes and bits).
*/
BU_EXPORT extern void bu_bitv_to_binary(struct bu_vls *v, const struct bu_bitv *bv);
/**
* Convert a string of BINARY digits (as produced by
* bu_bitv_to_binary) into a bit vector.
*/
BU_EXPORT extern struct bu_bitv *bu_binary_to_bitv(const char *str);
/**
* Convert a string of BINARY digits (as produced by
* bu_bitv_to_binary) into a bit vector. The "nbytes" argument may be
* zero if the user has no minimum length preference.
*/
BU_EXPORT extern struct bu_bitv *bu_binary_to_bitv2(const char *str, const int nbytes);
/**
* Compare two bit vectors for equality. They are considered equal iff
* their lengths and each bit are equal. Returns 1 for true, zero for
* false.
*/
BU_EXPORT extern int bu_bitv_compare_equal(const struct bu_bitv *, const struct bu_bitv *);
/**
* Compare two bit vectors for equality. They are considered equal iff
* their non-zero bits are equal (leading zero bits are ignored so
* lengths are not considered explicitly). Returns 1 for true, 0 for
* false.
*/
BU_EXPORT extern int bu_bitv_compare_equal2(const struct bu_bitv *, const struct bu_bitv *);
/**
* Make a copy of a bit vector
*/
BU_EXPORT extern struct bu_bitv *bu_bitv_dup(const struct bu_bitv *bv);
/**
* Convert a string of hex characters to an equivalent string of
* binary characters.
*
* The input hex string may have an optional prefix of '0x' or '0X' in
* which case the resulting binary string will be prefixed with '0b'.
*
* The input string is expected to represent an integral number of
* bytes but will have leading zeroes prepended as necessary to fulfill
* that requirement.
*
* Returns BRLCAD_OK for success, BRLCAD_ERROR for errors.
*/
BU_EXPORT extern int bu_hexstr_to_binstr(const char *hexstr, struct bu_vls *b);
/**
* Convert a string of binary characters to an equivalent string of
* hex characters.
*
* The input binary string may have an optional prefix of '0b' or '0B'
* in which case the resulting hex string will be prefixed with '0x'.
*
* The input string is expected to represent an integral number of
* bytes but will have leading zeroes prepended as necessary to fulfill
* that requirement.
*
* Returns BRLCAD_OK for success, BRLCAD_ERROR for errors.
*
*/
BU_EXPORT extern int bu_binstr_to_hexstr(const char *binstr, struct bu_vls *h);
/** @brief Bit field printing implementation. */
/**
* Format a value a la the %b format of the kernel's printf
*
* @param vls variable length string to put output in
* @param s title string
* @param v the integer with the bits in it
* @param bits a string which starts with the desired base (8 or 16)
* as \\010 or \\020, followed by
* words preceded with embedded low-value bytes indicating
* bit number plus one,
* in little-endian order, e.g.:
* "\010\2Bit_one\1BIT_zero"
*/
BU_EXPORT extern void bu_vls_printb(struct bu_vls *vls,
const char *s, unsigned long v,
const char *bits);
/**
* Format and print, like bu_vls_printb().
*/
BU_EXPORT extern void bu_printb(const char *s,
unsigned long v,
const char *bits);
/** @} */
__END_DECLS
#endif /* BU_BITV_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-163
View File
@@ -1,163 +0,0 @@
/* C O L O R . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_COLOR_H
#define BU_COLOR_H
#include "common.h"
#include "bu/defines.h"
#include "bu/magic.h"
__BEGIN_DECLS
/*----------------------------------------------------------------------*/
/** @addtogroup bu_color
* @brief
* Support for storing and manipulating color data.
*/
/** @{ */
/** @file bu/color.h */
#define RED 0
#define GRN 1
#define BLU 2
#define HUE 0
#define SAT 1
#define VAL 2
#define ACHROMATIC -1.0
struct bu_color
{
uint32_t buc_magic;
fastf_t buc_rgb[3];
};
typedef struct bu_color bu_color_t;
#define BU_COLOR_NULL ((struct bu_color *) 0)
/**
* asserts the integrity of a bu_color struct.
*/
#define BU_CK_COLOR(_c) BU_CKMAG(_c, BU_COLOR_MAGIC, "bu_color")
/**
* initializes a bu_bitv struct without allocating any memory.
*/
#define BU_COLOR_INIT(_c) { \
(_c)->buc_magic = BU_COLOR_MAGIC; \
(_c)->buc_rgb[0] = (_c)->buc_rgb[1] = (_c)->buc_rgb[2] = 0; \
}
/**
* macro suitable for declaration statement initialization of a bu_color
* struct. does not allocate memory.
*/
#define BU_COLOR_INIT_ZERO { BU_COLOR_MAGIC, {0, 0, 0} }
/**
* returns truthfully whether a bu_color has been initialized
*/
#define BU_COLOR_IS_INITIALIZED(_c) (((struct bu_color *)(_c) != BU_COLOR_NULL) && LIKELY((_c)->magic == BU_COLOR_MAGIC))
/**
* Function to generate random color
*
* TODO - multiple possibilities here - truly random color,
* or "constrained" random aka the BRLCADWrapper:getRandomColor
* function. Need a function that provides flexibility. Possible
* calling syntax:
@code
* bu_color_rand(cp, NULL, NULL, NULL, 0); #generate a totally random color value
* bu_color_rand(cp, NULL, rgb_seed, NULL, COLOR_SET_R); #randomize the R value only, else use rgb_seed values
* bu_color_rand(cp, NULL, rgb_seed, NULL, COLOR_GOLDEN); #use the golden ratio constraining technique
* bu_color_rand(cp, NULL, NULL, hsv_seed, COLOR_GOLDEN); #use the golden ratio constraining technique with an hsv input
* bu_color_rand(cp, seed, NULL, NULL, 0); #randomize, using bu_color seed
@endcode
* Passing multiple seeds would be an error - the multiple slots are for formatting convenience. May be
* better to use just one bu_color seed and make callers pre-package it - not sure yet. If we go that
* route, we'll have to implement the unimplemented utility functions below.
*
*/
#if 0
#define COLOR_SET_R 0x1
#define COLOR_SET_G 0x2
#define COLOR_SET_B 0x4
#define COLOR_SET_RGB 0x7 /* Either 0x0 or 0x7 will do this - default behavior */
#define COLOR_GOLDEN 0x8 /* Needs seed color */
BU_EXPORT extern int bu_color_rand(struct bu_color *cp,
const struct bu_color *seed,
const unsigned char *seed_rgb,
const fastf_t *seed_hsv,
int flags);
#endif
/**
* Convert between RGB and HSV color models
*
* R, G, and B are in {0, 1, ..., 255},
*
* H is in [0.0, 360.0), and S and V are in [0.0, 1.0],
*
* unless S = 0.0, in which case H = ACHROMATIC.
*
* These two routines are adapted from:
* pp. 592-3 of J.D. Foley, A. van Dam, S.K. Feiner, and J.F. Hughes,
* _Computer graphics: principles and practice_, 2nd ed., Addison-Wesley,
* Reading, MA, 1990.
*/
BU_EXPORT extern void bu_rgb_to_hsv(unsigned char *rgb, fastf_t *hsv);
BU_EXPORT extern int bu_hsv_to_rgb(fastf_t *hsv, unsigned char *rgb);
/**
* Utility functions to convert between various containers
* for color handling
*/
BU_EXPORT extern int bu_str_to_rgb(char *str, unsigned char *rgb);
BU_EXPORT extern int bu_color_from_rgb_floats(struct bu_color *cp, fastf_t *rgb);
BU_EXPORT extern int bu_color_to_rgb_floats(struct bu_color *cp, fastf_t *rgb);
BU_EXPORT extern int bu_color_from_rgb_chars(struct bu_color *cp, unsigned char *rgb);
BU_EXPORT extern int bu_color_to_rgb_chars(struct bu_color *cp, unsigned char *rgb);
/* UNIMPLEMENTED
*
* BU_EXPORT extern int bu_color_from_hsv_floats(struct bu_color *cp, fastf_t *hsv);
* BU_EXPORT extern int bu_color_to_hsv_floats(struct bu_color *cp, fastf_t *hsv);
*/
/** @} */
__END_DECLS
#endif /* BU_COLOR_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-524
View File
@@ -1,524 +0,0 @@
/* C V . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_CV_H
#define BU_CV_H
#include "common.h"
#include <stddef.h> /* for size_t */
#include <limits.h> /* for CHAR_MAX */
#include "bu/defines.h"
__BEGIN_DECLS
/*----------------------------------------------------------------------*/
/** @addtogroup bu_conv
*
* @brief
* Routines to translate data formats.
*
* The data formats are:
*
* \li Host/Network is the data in host format or local format
* \li signed/unsigned Is the data signed?
* \li char/short/int/long/double
* Is the data 8bits, 16bits, 32bits, 64bits
* or a double?
*
* The method of conversion is to convert up to double then back down the
* the expected output format.
*
* Also included are library routines for conversion between the local host 64-bit
* ("double precision") representation, and 64-bit IEEE double
* precision representation, in "network order", i.e., big-endian, the
* MSB in byte [0], on the left.
*
* As a quick review, the IEEE double precision format is as follows:
* sign bit, 11 bits of exponent (bias 1023), and 52 bits of mantissa,
* with a hidden leading one (0.1 binary).
*
* When the exponent is 0, IEEE defines a "denormalized number", which
* is not supported here.
*
* When the exponent is 2047 (all bits set), and:
* all mantissa bits are zero,
* value is infinity*sign,
* mantissa is non-zero, and:
* msb of mantissa=0: signaling NAN
* msb of mantissa=1: quiet NAN
*
* Note that neither the input or output buffers need be word aligned,
* for greatest flexibility in converting data, even though this
* imposes a speed penalty here.
*
* These subroutines operate on a sequential block of numbers, to save
* on subroutine linkage execution costs, and to allow some hope for
* vectorization.
*
* On brain-damaged machines like the SGI 3-D, where type "double"
* allocates only 4 bytes of space, these routines *still* return 8
* bytes in the IEEE buffer.
*
* The base64 encoding algorithm is an adaptation of the libb64 project - for
* details, see http://sourceforge.net/projects/libb64
*/
/** @{*/
/** @file bu/cv.h */
/** @}*/
/** @ingroup bu_conv */
/** @defgroup bu_conv_network_sizes Network Data Sizes */
/** @addtogroup bu_conv_network_sizes
* Sizes of "network" format data. We use the same convention as the
* TCP/IP specification, namely, big-Endian, IEEE format, twos
* complement. This is the BRL-CAD external data representation
* (XDR). See also the support routines in libbu/xdr.c
*/
/** @{*/
#define SIZEOF_NETWORK_SHORT 2 /* htons(), bu_gshort(), bu_pshort() */
#define SIZEOF_NETWORK_LONG 4 /* htonl(), bu_glong(), bu_plong() */
#define SIZEOF_NETWORK_FLOAT 4 /* htonf() */
#define SIZEOF_NETWORK_DOUBLE 8 /* htond() */
/** @}*/
/** @ingroup bu_conv */
/** @defgroup bu_cv_masks Conversion Bit Masks */
/** @addtogroup bu_cv_masks
* Mask definitions for CV
*/
/** @{*/
#define CV_CHANNEL_MASK 0x00ff
#define CV_HOST_MASK 0x0100
#define CV_SIGNED_MASK 0x0200
#define CV_TYPE_MASK 0x1c00 /* 0001 1100 0000 0000 */
#define CV_CONVERT_MASK 0x6000 /* 0110 0000 0000 0000 */
/** @}*/
/** @ingroup bu_conv */
/** @defgroup bu_cv_defs Conversion Defines */
/** @addtogroup bu_cv_defs
* Various convenience definitions for CV
*/
/** @{*/
#define CV_TYPE_SHIFT 10
#define CV_CONVERT_SHIFT 13
#define CV_8 0x0400
#define CV_16 0x0800
#define CV_32 0x0c00
#define CV_64 0x1000
#define CV_D 0x1400
#define CV_CLIP 0x0000
#define CV_NORMAL 0x2000
#define CV_LIT 0x4000
/** deprecated */
#define END_NOTSET 0
#define END_BIG 1 /* PowerPC/MIPS */
#define END_LITTLE 2 /* Intel */
#define END_ILL 3 /* PDP-11 */
#define END_CRAY 4 /* Old Cray */
/** deprecated */
#define IND_NOTSET 0
#define IND_BIG 1
#define IND_LITTLE 2
#define IND_ILL 3
#define IND_CRAY 4
/** @}*/
/** @addtogroup bu_conv */
/** @{*/
/**
* provide for 64-bit network/host conversions using ntohl()
*/
#ifndef HAVE_NTOHLL
# define ntohll(_val) ((bu_byteorder() == BU_LITTLE_ENDIAN) ? \
((((uint64_t)ntohl((_val))) << 32) + ntohl((_val) >> 32)) : \
(_val)) /* sorry pdp-endian */
#endif
#ifndef HAVE_HTONLL
# define htonll(_val) ntohll(_val)
#endif
/**
* convert from one format to another.
*
* @param in input pointer
* @param out output pointer
* @param count number of entries to convert
* @param size size of output buffer
* @param infmt input format
* @param outfmt output format
*
*/
BU_EXPORT extern size_t bu_cv(void *out, char *outfmt, size_t size, void *in, char *infmt, size_t count);
/**
* Sets a bit vector after parsing an input string.
*
* Set up the conversion tables/flags for vert.
*
* @param in format description.
*
* @return a 32 bit vector.
*
* Format description:
* [channels][h|n][s|u] c|s|i|l|d|8|16|32|64 [N|C|L]
*
* @n channels must be null or 1
* @n Host | Network
* @n signed | unsigned
* @n char | short | integer | long | double | number of bits of integer
* @n Normalize | Clip | low-order
*/
BU_EXPORT extern int bu_cv_cookie(const char *in);
/**
* It is always more efficient to handle host data, rather than
* network. If host and network formats are the same, and the request
* was for network format, modify the cookie to request host format.
*/
BU_EXPORT extern int bu_cv_optimize(int cookie);
/**
* Returns the number of bytes each "item" of type "cookie" occupies.
*/
BU_EXPORT extern size_t bu_cv_itemlen(int cookie);
/**
* convert with cookie
*
* @param in input pointer
* @param incookie input format cookie.
* @param count number of entries to convert.
* @param out output pointer.
* @param outcookie output format cookie.
* @param size size of output buffer in bytes;
*
*
* A worst case would be: ns16 on vax to ns32
@code
ns16 -> hs16
-> hd
-> hs32
-> ns32
@endcode
* The worst case is probably the easiest to deal with because all
* steps are done. The more difficult cases are when only a subset of
* steps need to be done.
*
* @par Method:
@code
HOSTDBL defined as true or false
if ! hostother then
hostother = (Endian == END_BIG) ? SAME : DIFFERENT;
fi
if (infmt == double) then
if (HOSTDBL == SAME) {
inIsHost = host;
fi
else
if (hostother == SAME) {
inIsHost = host;
fi
fi
if (outfmt == double) then
if (HOSTDBL == SAME) {
outIsHost == host;
else
if (hostother == SAME) {
outIsHost = host;
fi
fi
if (infmt == outfmt) {
if (inIsHost == outIsHost) {
copy(in, out)
exit
else if (inIsHost == net) {
ntoh?(in, out);
exit
else
hton?(in, out);
exit
fi
fi
while not done {
from = in;
if (inIsHost == net) {
ntoh?(from, t1);
from = t1;
fi
if (infmt != double) {
if (outIsHost == host) {
to = out;
else
to = t2;
fi
castdbl(from, to);
from = to;
fi
if (outfmt == double) {
if (outIsHost == net) {
hton?(from, out);
fi
else
if (outIsHost == host) {
dblcast(from, out);
else
dblcast(from, t3);
hton?(t3, out);
fi
fi
done
@endcode
*/
BU_EXPORT extern size_t bu_cv_w_cookie(void *out, int outcookie, size_t size, void *in, int incookie, size_t count);
/** @} */
/** @ingroup bu_conv */
/** @defgroup bu_cv_b64 Base64 Encoding and Decoding */
/** @addtogroup bu_cv_b64
* Functions for b64 encoding and decoding.
*/
/** @{*/
/**
* Encode null terminated input char array to b64.
*
* Caller is responsible for freeing memory allocated to
* hold output buffer.
*/
BU_EXPORT extern signed char *bu_b64_encode(const signed char *input);
/**
* Encode length_in blocks in char array input to b64.
*
* Caller is responsible for freeing memory allocated to
* hold output buffer.
*/
BU_EXPORT extern signed char *bu_b64_encode_block(const signed char* input, size_t length_in);
/**
* Decode null terminated b64 array to output_buffer.
*
* Caller is responsible for freeing memory allocated to
* hold output buffer.
*/
BU_EXPORT extern int bu_b64_decode(signed char **output_buffer, const signed char *input);
/**
* Decode length_in blocks in b64 array input to output_buffer.
*
* Caller is responsible for freeing memory allocated to
* hold output buffer.
*/
BU_EXPORT extern int bu_b64_decode_block(signed char **output_buffer, const signed char* input, size_t length_in);
/** @}*/
/** @ingroup bu_conv */
/** @defgroup bu_hton Network Byte-order Conversion */
/** @addtogroup bu_hton
* Network to host and host to network conversion routines.
*
* It is assumed that these routines will only be called if there is
* real work to do - there is no checking to see if it is reasonable
* to do any conversions.
*/
/** @ingroup bu_hton */
/** @defgroup bu_htond Network Conversion - Doubles */
/** @ingroup bu_hton */
/** @defgroup bu_htonf Network Conversion - Floats */
/** @ingroup bu_hton */
/** @defgroup bu_htons Network Conversion - Signed Short */
/** @addtogroup bu_htond
* @brief Convert doubles to host/network format.
*/
/** @{*/
BU_EXPORT extern void bu_cv_htond(unsigned char *out,
const unsigned char *in,
size_t count);
BU_EXPORT extern void bu_cv_ntohd(unsigned char *out,
const unsigned char *in,
size_t count);
/** @}*/
/** @addtogroup bu_htonf
* @brief convert floats to host/network format
*/
/** @{*/
BU_EXPORT extern void bu_cv_htonf(unsigned char *out,
const unsigned char *in,
size_t count);
BU_EXPORT extern void bu_cv_ntohf(unsigned char *out,
const unsigned char *in,
size_t count);
/** @}*/
/** @addtogroup bu_htons
* @brief Network to Host Signed Short
*
* @param in generic pointer for input.
* @param count number of shorts to be generated.
* @param out short pointer for output
* @param size number of bytes of space reserved for out.
*
* @return number of conversions done.
*/
/** @{*/
BU_EXPORT extern size_t bu_cv_ntohss(signed short *in, /* FIXME: in/out right? */
size_t count,
void *out,
size_t size);
BU_EXPORT extern size_t bu_cv_ntohus(unsigned short *,
size_t,
void *,
size_t);
BU_EXPORT extern size_t bu_cv_ntohsl(signed long int *,
size_t,
void *,
size_t);
BU_EXPORT extern size_t bu_cv_ntohul(unsigned long int *,
size_t,
void *,
size_t);
BU_EXPORT extern size_t bu_cv_htonss(void *,
size_t,
signed short *,
size_t);
BU_EXPORT extern size_t bu_cv_htonus(void *,
size_t,
unsigned short *,
size_t);
BU_EXPORT extern size_t bu_cv_htonsl(void *,
size_t,
long *,
size_t);
BU_EXPORT extern size_t bu_cv_htonul(void *,
size_t,
unsigned long *,
size_t);
/** @}*/
/*
* DEPRECATED.
*
* Routines to implement an external data representation (XDR)
* compatible with the usual InterNet standards, e.g.:
* big-endian, twos-complement fixed point, and IEEE floating point.
*
* Routines to insert/extract short/long's into char arrays,
* independent of machine byte order and word-alignment.
* Uses encoding compatible with routines found in libpkg,
* and BSD system routines htonl(), htons(), ntohl(), ntohs().
*
*/
/*
* DEPRECATED: use ntohll()
* Macro version of library routine bu_glonglong()
* The argument is expected to be of type "unsigned char *"
*/
#define BU_GLONGLONG(_cp) \
((((uint64_t)((_cp)[0])) << 56) | \
(((uint64_t)((_cp)[1])) << 48) | \
(((uint64_t)((_cp)[2])) << 40) | \
(((uint64_t)((_cp)[3])) << 32) | \
(((uint64_t)((_cp)[4])) << 24) | \
(((uint64_t)((_cp)[5])) << 16) | \
(((uint64_t)((_cp)[6])) << 8) | \
((uint64_t)((_cp)[7])))
/*
* DEPRECATED: use ntohl()
* Macro version of library routine bu_glong()
* The argument is expected to be of type "unsigned char *"
*/
#define BU_GLONG(_cp) \
((((uint32_t)((_cp)[0])) << 24) | \
(((uint32_t)((_cp)[1])) << 16) | \
(((uint32_t)((_cp)[2])) << 8) | \
((uint32_t)((_cp)[3])))
/*
* DEPRECATED: use ntohs()
* Macro version of library routine bu_gshort()
* The argument is expected to be of type "unsigned char *"
*/
#define BU_GSHORT(_cp) \
((((uint16_t)((_cp)[0])) << 8) | \
(_cp)[1])
/*
* DEPRECATED: use ntohs()
*/
DEPRECATED BU_EXPORT extern uint16_t bu_gshort(const unsigned char *msgp);
/*
* DEPRECATED: use ntohl()
*/
DEPRECATED BU_EXPORT extern uint32_t bu_glong(const unsigned char *msgp);
/*
* DEPRECATED: use htons()
*/
DEPRECATED BU_EXPORT extern unsigned char *bu_pshort(unsigned char *msgp, uint16_t s);
/*
* DEPRECATED: use htonl()
*/
DEPRECATED BU_EXPORT extern unsigned char *bu_plong(unsigned char *msgp, uint32_t l);
/*
* DEPRECATED: use htonll()
*/
DEPRECATED BU_EXPORT extern unsigned char *bu_plonglong(unsigned char *msgp, uint64_t l);
__END_DECLS
#endif /* BU_CV_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-100
View File
@@ -1,100 +0,0 @@
/* D E B U G . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_DEBUG_H
#define BU_DEBUG_H
#include "common.h"
#include "bu/defines.h"
__BEGIN_DECLS
/** @addtogroup bu_debug Debugging
*
* @brief
* Debugging definitions.
*
*/
/** @{ */
/** @file bu/debug.h */
/**
* controls the libbu debug level
*/
BU_EXPORT extern int bu_debug;
/**
* Section for BU_DEBUG values
*
* These can be set from the command-line of RT-compatible programs
* using the "-!" option.
*
* These definitions are each for one bit.
*/
#define BU_DEBUG_OFF 0 /* No debugging */
#define BU_DEBUG_COREDUMP 0x00000001 /* bu_bomb() should dump core on exit */
#define BU_DEBUG_MEM_CHECK 0x00000002 /* Mem barrier & leak checking */
#define BU_DEBUG_MEM_LOG 0x00000004 /* Print all dynamic memory operations */
#define BU_DEBUG_UNUSED_0 0x00000008 /* unused */
#define BU_DEBUG_PARALLEL 0x00000010 /* Parallel debug logging */
#define BU_DEBUG_MEM_QCHECK 0x00000020 /* Fast mem leak checking (won't work with corruption) */
#define BU_DEBUG_BACKTRACE 0x00000040 /* Log backtrace details during abnormal exit */
#define BU_DEBUG_ATTACH 0x00000080 /* Waits for a debugger to attach during a crash */
#define BU_DEBUG_MATH 0x00000100 /* Fundamental math routines (plane.c, mat.c) */
#define BU_DEBUG_PTBL 0x00000200 /* bu_ptbl_*() logging */
#define BU_DEBUG_AVS 0x00000400 /* bu_avs_*() logging */
#define BU_DEBUG_MAPPED_FILE 0x00000800 /* bu_mapped_file logging */
#define BU_DEBUG_PATHS 0x00001000 /* File and path debug logging */
#define BU_DEBUG_UNUSED_1 0x00002000 /* unused */
#define BU_DEBUG_UNUSED_2 0x00004000 /* unused */
#define BU_DEBUG_UNUSED_3 0x00008000 /* unused */
#define BU_DEBUG_TABDATA 0x00010000 /* LIBBN: tabdata */
#define BU_DEBUG_UNUSED_4 0x00020000 /* unused */
#define BU_DEBUG_UNUSED_5 0x00040000 /* unused */
#define BU_DEBUG_UNUSED_6 0x00080000 /* unused */
/* Format string for bu_printb() */
#define BU_DEBUG_FORMAT \
"\020\
\025TABDATA\
\015?\
\014MAPPED_FILE\013AVS\012PTBL\011MATH\010?\7?\6MEM_QCHECK\5PARALLEL\
\4?\3MEM_LOG\2MEM_CHECK\1COREDUMP"
/** @} */
__END_DECLS
#endif /* BU_DEBUG_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-344
View File
@@ -1,344 +0,0 @@
/* D E F I N E S . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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 bu_defines
*
* @brief
* These are definitions specific to libbu, used throughout the library.
*
*/
/** @{ */
/** @file bu/defines.h */
#ifndef BU_DEFINES_H
#define BU_DEFINES_H
#include "common.h"
#include <stddef.h>
#include <sys/types.h>
#ifndef BU_EXPORT
# if defined(BU_DLL_EXPORTS) && defined(BU_DLL_IMPORTS)
# error "Only BU_DLL_EXPORTS or BU_DLL_IMPORTS can be defined, not both."
# elif defined(BU_DLL_EXPORTS)
# define BU_EXPORT __declspec(dllexport)
# elif defined(BU_DLL_IMPORTS)
# define BU_EXPORT __declspec(dllimport)
# else
# define BU_EXPORT
# endif
#endif
/* NOTE: do not rely on these values */
#define BRLCAD_OK 0
#define BRLCAD_ERROR 1
/**
* @def BU_DIR_SEPARATOR
* the default directory separator character
*/
#ifdef DIR_SEPARATOR
# define BU_DIR_SEPARATOR DIR_SEPARATOR
#else
# ifdef DIR_SEPARATOR_2
# define BU_DIR_SEPARATOR DIR_SEPARATOR_2
# else
# ifdef _WIN32
# define BU_DIR_SEPARATOR '\\'
# else
# define BU_DIR_SEPARATOR '/'
# endif /* _WIN32 */
# endif /* DIR_SEPARATOR_2 */
#endif /* DIR_SEPARATOR */
/**
* Maximum length of a filesystem path. Typically defined in a system
* file but if it isn't set, we create it.
*/
#ifndef MAXPATHLEN
# ifdef PATH_MAX
# define MAXPATHLEN PATH_MAX
# else
# ifdef _MAX_PATH
# define MAXPATHLEN _MAX_PATH
# else
# define MAXPATHLEN 1024
# endif
# endif
#endif
/**
* set to the path list separator character
*/
#if defined(PATH_SEPARATOR)
# define BU_PATH_SEPARATOR PATH_SEPARATOR
#else
# if defined(_WIN32)
# define BU_PATH_SEPARATOR ';'
# else
# define BU_PATH_SEPARATOR ':'
# endif /* _WIN32 */
#endif /* PATH_SEPARATOR */
/**
* @def BU_FLSTR
*
* Macro for getting a concatenated string of the current file and
* line number. Produces something of the form: "filename.c"":""1234"
*/
#define bu_cpp_str(s) # s
#define bu_cpp_xstr(s) bu_cpp_str(s)
#define bu_cpp_glue(a, b) a ## b
#define bu_cpp_xglue(a, b) bu_cpp_glue(a, b)
#define BU_FLSTR __FILE__ ":" bu_cpp_xstr(__LINE__)
/**
* shorthand declaration of a printf-style functions
*/
#if !defined(_BU_ATTR_PRINTF12)
#define _BU_ATTR_PRINTF12 __attribute__ ((__format__ (__printf__, 1, 2)))
#endif
#if !defined(_BU_ATTR_PRINTF23)
#define _BU_ATTR_PRINTF23 __attribute__ ((__format__ (__printf__, 2, 3)))
#endif
#if !defined(_BU_ATTR_SCANF23)
#define _BU_ATTR_SCANF23 __attribute__ ((__format__ (__scanf__, 2, 3)))
#endif
/**
* shorthand declaration of a function that doesn't return
*/
#define _BU_ATTR_NORETURN __attribute__ ((__noreturn__))
/* For the moment, we need to specially flag some functions
* for clang. It's not clear if we will always need to do
* this, but for now this suppresses a lot of noise in the
* reports */
#ifdef __clang__
# define _BU_ATTR_ANALYZE_NORETURN __attribute__((analyzer_noreturn))
#else
# define _BU_ATTR_ANALYZE_NORETURN
#endif
/**
* shorthand declaration of a function that should always be inline
*/
#define _BU_ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
/**
* If we're compiling strict, turn off "format string vs arguments"
* checks - BRL-CAD customizes the arguments to some of these
* function types (adding bu_vls support) and that is a problem with
* strict checking.
*/
#if defined(STRICT_FLAGS)
# undef _BU_ATTR_PRINTF12
# undef _BU_ATTR_PRINTF23
# undef _BU_ATTR_SCANF23
# undef _BU_ATTR_NORETURN
# define _BU_ATTR_PRINTF12
# define _BU_ATTR_PRINTF23
# define _BU_ATTR_SCANF23
# define _BU_ATTR_NORETURN
#endif
/**
* This macro is used to take the 'C' function name, and convert it at
* compile time to the FORTRAN calling convention.
*
* Lower case, with a trailing underscore.
*/
#define BU_FORTRAN(lc, uc) lc ## _
/**
* @def BU_ASSERT(eqn)
* Quick and easy macros to generate an informative error message and
* abort execution if the specified condition does not hold true.
*
* @def BU_ASSERT_PTR(eqn)
* Quick and easy macros to generate an informative error message and
* abort execution if the specified condition does not hold true.
*
* @def BU_ASSERT_LONG(eqn)
* Quick and easy macros to generate an informative error message and
* abort execution if the specified condition does not hold true.
*
* @def BU_ASSERT_DOUBLE(eqn)
* Quick and easy macros to generate an informative error message and
* abort execution if the specified condition does not hold true.
*
* Example: BU_ASSERT_LONG(j+7, <, 42);
*/
#ifdef NO_BOMBING_MACROS
# define BU_ASSERT(_equation) (void)(_equation)
#else
# define BU_ASSERT(_equation) \
if (UNLIKELY(!(_equation))) { \
bu_log("BU_ASSERT(" #_equation ") failed, file %s, line %d\n", \
__FILE__, __LINE__); \
bu_bomb("BU_ASSERT failure\n"); \
}
#endif
#ifdef NO_BOMBING_MACROS
# define BU_ASSERT_PTR(_lhs, _relation, _rhs) (void)(_lhs); (void)(_rhs)
#else
# define BU_ASSERT_PTR(_lhs, _relation, _rhs) \
if (UNLIKELY(!((_lhs) _relation (_rhs)))) { \
bu_log("BU_ASSERT_PTR(" #_lhs #_relation #_rhs ") failed, lhs=%p, rhs=%p, file %s, line %d\n", \
(void *)(_lhs), (void *)(_rhs), \
__FILE__, __LINE__); \
bu_bomb("BU_ASSERT_PTR failure\n"); \
}
#endif
#ifdef NO_BOMBING_MACROS
# define BU_ASSERT_LONG(_lhs, _relation, _rhs) (void)(_lhs); (void)(_rhs)
#else
# define BU_ASSERT_LONG(_lhs, _relation, _rhs) \
if (UNLIKELY(!((_lhs) _relation (_rhs)))) { \
bu_log("BU_ASSERT_LONG(" #_lhs #_relation #_rhs ") failed, lhs=%ld, rhs=%ld, file %s, line %d\n", \
(long)(_lhs), (long)(_rhs), \
__FILE__, __LINE__); \
bu_bomb("BU_ASSERT_LONG failure\n"); \
}
#endif
#ifdef NO_BOMBING_MACROS
# define BU_ASSERT_SIZE_T(_lhs, _relation, _rhs) (void)(_lhs); (void)(_rhs)
#else
# define BU_ASSERT_SIZE_T(_lhs, _relation, _rhs) \
if (UNLIKELY(!((_lhs) _relation (_rhs)))) { \
bu_log("BU_ASSERT_SIZE_T(" #_lhs #_relation #_rhs ") failed, lhs=%zd, rhs=%zd, file %s, line %d\n", \
(size_t)(_lhs), (size_t)(_rhs), \
__FILE__, __LINE__); \
bu_bomb("BU_ASSERT_SIZE_T failure\n"); \
}
#endif
#ifdef NO_BOMBING_MACROS
# define BU_ASSERT_SSIZE_T(_lhs, _relation, _rhs) (void)(_lhs); (void)(_rhs)
#else
# define BU_ASSERT_SSIZE_T(_lhs, _relation, _rhs) \
if (UNLIKELY(!((_lhs) _relation (_rhs)))) { \
bu_log("BU_ASSERT_SSIZE_T(" #_lhs #_relation #_rhs ") failed, lhs=%zd, rhs=%zd, file %s, line %d\n", \
(ssize_t)(_lhs), (ssize_t)(_rhs), \
__FILE__, __LINE__); \
bu_bomb("BU_ASSERT_SSIZE_T failure\n"); \
}
#endif
#ifdef NO_BOMBING_MACROS
# define BU_ASSERT_DOUBLE(_lhs, _relation, _rhs) (void)(_lhs); (void)(_rhs)
#else
# define BU_ASSERT_DOUBLE(_lhs, _relation, _rhs) \
if (UNLIKELY(!((_lhs) _relation (_rhs)))) { \
bu_log("BU_ASSERT_DOUBLE(" #_lhs #_relation #_rhs ") failed, lhs=%lf, rhs=%lf, file %s, line %d\n", \
(double)(_lhs), (double)(_rhs), \
__FILE__, __LINE__); \
bu_bomb("BU_ASSERT_DOUBLE failure\n"); \
}
#endif
/**
* fastf_t - Intended to be the fastest floating point data type on
* the current machine, with at least 64 bits of precision. On 16 and
* 32 bit machines, this is typically "double", but on 64 bit machines,
* it is often "float". Virtually all floating point variables (and
* more complicated data types, like vect_t and mat_t) are defined as
* fastf_t. The one exception is when a subroutine return is a
* floating point value; that is always declared as "double".
*
* TODO: If used pervasively, it should eventually be possible to make
* fastf_t a GMP C++ type for fixed-precision computations.
*/
typedef double fastf_t;
/**
* Definitions about limits of floating point representation
* Eventually, should be tied to type of hardware (IEEE, IBM, Cray)
* used to implement the fastf_t type.
*
* MAX_FASTF - Very close to the largest value that can be held by a
* fastf_t without overflow. Typically specified as an integer power
* of ten, to make the value easy to spot when printed. TODO: macro
* function syntax instead of constant (DEPRECATED)
*
* SQRT_MAX_FASTF - sqrt(MAX_FASTF), or slightly smaller. Any number
* larger than this, if squared, can be expected to * produce an
* overflow. TODO: macro function syntax instead of constant
* (DEPRECATED)
*
* SMALL_FASTF - Very close to the smallest value that can be
* represented while still being greater than zero. Any number
* smaller than this (and non-negative) can be considered to be
* zero; dividing by such a number can be expected to produce a
* divide-by-zero error. All divisors should be checked against
* this value before actual division is performed. TODO: macro
* function syntax instead of constant (DEPRECATED)
*
* SQRT_SMALL_FASTF - sqrt(SMALL_FASTF), or slightly larger. The
* value of this is quite a lot larger than that of SMALL_FASTF. Any
* number smaller than this, when squared, can be expected to produce
* a zero result. TODO: macro function syntax instead of constant
* (DEPRECATED)
*
*/
#if defined(vax)
/* DEC VAX "D" format, the most restrictive */
# define MAX_FASTF 1.0e37 /* Very close to the largest number */
# define SQRT_MAX_FASTF 1.0e18 /* This squared just avoids overflow */
# define SMALL_FASTF 1.0e-37 /* Anything smaller is zero */
# define SQRT_SMALL_FASTF 1.0e-18 /* This squared gives zero */
#else
/* IBM format, being the next most restrictive format */
# define MAX_FASTF 1.0e73 /* Very close to the largest number */
# define SQRT_MAX_FASTF 1.0e36 /* This squared just avoids overflow */
# define SMALL_FASTF 1.0e-77 /* Anything smaller is zero */
# if defined(aux)
# define SQRT_SMALL_FASTF 1.0e-40 /* _doprnt error in libc */
# else
# define SQRT_SMALL_FASTF 1.0e-39 /* This squared gives zero */
# endif
#endif
/** DEPRECATED, do not use */
#define SMALL SQRT_SMALL_FASTF
/** @} */
#endif /* BU_DEFINES_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-74
View File
@@ -1,74 +0,0 @@
/* E N D I A N . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_ENDIAN_H
#define BU_ENDIAN_H
#include "common.h"
#include "bu/defines.h"
__BEGIN_DECLS
/** @addtogroup bu_endian
* @brief
* Run-time byte order detection.
*
*/
/** @{ */
/** @file bu/endian.h */
typedef enum {
BU_LITTLE_ENDIAN = 1234, /* LSB first: i386, VAX order */
BU_BIG_ENDIAN = 4321, /* MSB first: 68000, IBM, network order */
BU_PDP_ENDIAN = 3412 /* LSB first in word, MSW first in long */
} bu_endian_t;
/**
* returns the platform byte ordering (e.g., big-/little-endian)
*/
BU_EXPORT extern bu_endian_t bu_byteorder(void);
/** @} */
/**
* Get the current operating host's name. This is usually also the
* network name of the current host. The name is written into the
* provided hostname buffer of at least len size. The hostname is
* always null-terminated and should be sized accordingly.
*/
BU_EXPORT extern int bu_gethostname(char *hostname, size_t len);
__END_DECLS
#endif /* BU_ENDIAN_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-523
View File
@@ -1,523 +0,0 @@
/* F I L E . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_FILE_H
#define BU_FILE_H
#include "common.h"
#include <stdio.h> /* For FILE */
#include <sys/types.h> /* for off_t */
#include <stddef.h> /* for size_t */
#include <stdlib.h> /* for getenv */
#ifdef HAVE_DLFCN_H
# include <dlfcn.h> /* for RTLD_* */
#endif
#include "bu/defines.h"
#include "bu/magic.h"
#include "bu/mime.h"
#include "bu/vls.h"
__BEGIN_DECLS
/** @addtogroup bu_file
*
* @brief
* Support routines for identifying properties of files and
* directories such as whether they exist or are the same as another
* given file.
*
*/
/** @{ */
/** @file bu/file.h */
/**
* Returns truthfully whether the given file path exists or not. An
* empty or NULL path name is treated as a non-existent file and, as
* such, will return false. If fd is non-NULL, it will be set to an
* open file descriptor for the provided path.
*
* @return >0 The given filename exists.
* @return 0 The given filename does not exist.
*/
BU_EXPORT extern int bu_file_exists(const char *path, int *fd);
/**
* Returns truthfully as to whether the two provided filenames are the
* same file. If either file does not exist, the result is false. If
* either filename is empty or NULL, it is treated as non-existent
* and, as such, will also return false.
*/
BU_EXPORT extern int bu_same_file(const char *fn1, const char *fn2);
/**
* returns truthfully as to whether or not the two provided file
* descriptors are the same file. if either file does not exist, the
* result is false.
*/
BU_EXPORT extern int bu_same_fd(int fd1, int fd2);
/**
* returns truthfully if current user can read the specified file or
* directory.
*/
BU_EXPORT extern int bu_file_readable(const char *path);
/**
* returns truthfully if current user can write to the specified file
* or directory.
*/
BU_EXPORT extern int bu_file_writable(const char *path);
/**
* returns truthfully if current user can run the specified file or
* directory.
*/
BU_EXPORT extern int bu_file_executable(const char *path);
/**
* Returns truthfully whether the given file path is a directory. An
* empty or NULL path name is treated as a non-existent directory and,
* as such, will return false.
*
* @return >0 The given filename is a directory
* @return 0 The given filename is not a directory.
*/
BU_EXPORT extern int bu_file_directory(const char *path);
/**
* Returns truthfully whether the given file path is a symbolic link.
* An empty or NULL path name is treated as a non-existent link and,
* as such, will return false.
*
* @return >0 The given filename is a symbolic link
* @return 0 The given filename is not a symbolic link.
*/
BU_EXPORT extern int bu_file_symbolic(const char *path);
/**
* forcibly attempts to delete a specified file. if the file can be
* deleted by relaxing file permissions, they will be changed in order
* to delete the file.
*
* returns truthfully if the specified file was deleted.
*/
BU_EXPORT extern int bu_file_delete(const char *path);
#if 0
/**
* TODO - currently unimplemented
*
* matches a filepath pattern to directory entries. if non-NULL,
* matching paths are dynamically allocated, stored into the provided
* 'matches' array, and followed by a terminating NULL entry.
*
* If '*matches' is NULL, the caller is expected to free the matches
* array with bu_free_argv() If '*matches' is non-NULL (i.e., string
* array is already allocated or on the stack), the caller is expected
* to ensure adequate entries are allocated and call bu_free_array()
* to clean up. If 'matches' is NULL, no entries will be allocated or
* stored, but the number of matches will still be returned.
*
* Example:
*
* char **my_matches = NULL;
* bu_file_glob("src/libbu/[a-e]*.c", &my_matches);
*
* This will allocate an array for storing glob matches, filling in
* the array with all of the directory entries starting with 'a'
* through 'e' and ending with a '.c' suffix in the src/libbu
* directory.
*
* returns the number of matches
*/
BU_EXPORT extern size_t bu_file_glob(const char *pattern, char ***matches);
#endif
/** @brief Functions generated by the mime.cmake script */
/**
* Functions generated by the mime.cmake script - see the generated
* files mime.c and mime.h for the resulting C code and mime types.
*
* Standard types are maintained in misc/mime.types - that file
* is a copy of the Apache file and is not changed locally:
* http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
*
* Customizations for BRL-CAD are maintained in misc/mime_cad.types
* and any types not covered by the standard mime set (such as
* the majority of geometry formats) are added there instead of
* changing mime.types.
*/
/**
* Use the file extension to attempt to determine the media type
* of the file within the specified context.
*
* returns -1 if no match was found, or an integer if a result
* was found. It is the responsibility of the caller to cast
* the return int to the correct mime_CONTEXT_t type.
*/
BU_EXPORT extern int bu_file_mime(const char *ext, mime_context_t context);
/**
* Given a mime type and a context, return the file extension(s)
* associated with that type.
*
* returns NULL if no match was found, or a comma separated string
* containing the extensions if a result was found.
* It is the responsibility of the caller to free the returned string.
*/
BU_EXPORT extern const char *bu_file_mime_ext(int t, mime_context_t context);
/**
* Given a mime type and a context, return a human readable string
* spelling out the type (corresponding to the enum string in
* source code.)
*
* returns NULL if no match was found, or a string if a result was found.
* It is the responsibility of the caller to free the returned string.
*/
BU_EXPORT extern const char *bu_file_mime_str(int t, mime_context_t context);
/**
* Given a string produced by bu_file_mime_str, convert it back into
* integer form.
*
* returns -1 if no match was found, or an integer if a result
* was found. It is the responsibility of the caller to cast
* the return int to the correct mime_CONTEXT_t type.
*/
BU_EXPORT extern int bu_file_mime_int(const char *str);
/**
* Functionality for accessing all files in a directory.
*/
/**
* Returns the number of directory entries for a given path matching
* an optional glob pattern. If the caller provides a pointer to an
* argv-style 'files' array, this function will allocate the array
* with dynamically allocated strings for any matching file(s).
*
* It is the caller's responsibility to free a non-NULL 'files' array
* with bu_free_argv().
*/
BU_EXPORT extern size_t bu_dir_list(const char *path, const char *pattern, char ***files);
/**
* Call canonicalization routines to both expand and validate
* a path name.
*
* Returns a pointer to the canonical path. If resolved_path is
* NULL, caller is responsible for freeing the returned path
* via bu_free. If supplying a result string, the string must hold
* at least MAXPATHLEN characters.
*/
BU_EXPORT extern char * bu_realpath(const char *path, char *resolved_path);
/**
* TODO - is this bu_realpath?
*
* Call canonicalization routines to both expand and validate
* a path name.
*
* returns a pointer to the canonical path. Caller must free
* the path.
*/
/*BU_EXPORT extern char * bu_path_canonicalize(const char *path);*/
/**
* @brief
* Support routines to provide the executable code with information
* about executable name used to invoke the current program.
*
*/
/**
* DEPRECATED: This routine is replaced by bu_getcwd().
* Do not use.
*
* returns the full path to argv0, regardless of how the application
* was invoked.
*
* this routine will return "(BRL-CAD)" if argv[0] cannot be
* identified but should never return NULL. this routine is not
* thread-safe.
*/
BU_EXPORT extern const char *bu_argv0_full_path(void);
/**
* Get the name of the running application. application codes should
* call bu_setprogname() first to ensure that the program name is
* stored appropriately on platforms that do not have an intrinsic
* method for tracking the program name automatically.
*
* while this routine is thread-safe and reentrant, the static string
* returned is shared amongst all threads.
*/
BU_EXPORT extern const char *bu_getprogname(void);
/**
* Set the name of the running application. This isn't strictly
* necessary on platforms that have an intrinsic method for tracking
* the program name automatically, but is still recommended for
* portability and is necessary on some strict modes of compilation.
*
* while the implementation relies on a static string shared across
* all threads, this routine is thread-safe and reentrant.
*/
BU_EXPORT extern void bu_setprogname(const char *path);
/**
* Routine for getting the current working directory full pathname.
*/
BU_EXPORT extern char *bu_getcwd(char *buf, size_t size);
/**
* returns the first USER path match to a given executable name.
*
* Routine to provide BSD "which" functionality, locating binaries of
* specified programs from the user's PATH. This is useful to locate
* binaries and resources at run-time.
*
* caller should not free the result, though it will not be preserved
* between calls either. the caller should strdup the result if they
* need to keep it around.
*
* routine will return NULL if the executable command cannot be found.
*/
BU_EXPORT extern const char *bu_which(const char *cmd);
/**
* returns the first SYSTEM path match to a given executable cmd name.
*
* Routine to provide BSD "whereis" functionality, locating binaries
* of specified programs from the SYSTEM path. This is useful to
* locate binaries and resources at run-time.
*
* caller should not free the result, though it will not be preserved
* between calls either. the caller should strdup the result if they
* need to keep it around.
*
* routine will return NULL if the executable command cannot be found.
*/
BU_EXPORT extern const char *bu_whereis(const char *cmd);
/**
* @brief
* Routine to open a temporary file.
*
* Create a temporary file. The first readable/writable directory
* will be used, searching TMPDIR/TEMP/TMP environment variable
* directories followed by default system temp directories and
* ultimately trying the current directory.
*
* This routine is guaranteed to return a new unique file or return
* NULL on failure. The temporary file will be automatically unlinked
* on application exit. It is the caller's responsibility to set file
* access settings, preserve file contents, or destroy file contents
* if the default behavior is non-optimal.
*
* The name of the temporary file will be copied into a user-provided
* (filepath) buffer if it is a non-NULL pointer and of a sufficient
* (len) length to contain the filename.
*
* This routine is NOT thread-safe.
*
* Typical Use:
@code
FILE *fp;
char filename[MAXPATHLEN];
fp = bu_temp_file(&filename, MAXPATHLEN); // get file name
...
fclose(fp); // close the file when you're done
...
fp = bu_temp_file(NULL, 0); // don't need file name
bu_fchmod(fileno(fp), 0777);
...
rewind(fp);
while (fputc(0, fp) == 0);
fclose(fp);
@endcode
*/
BU_EXPORT extern FILE *bu_temp_file(char *filepath, size_t len);
/**
* @brief Wrapper around fchmod.
*
* Portable wrapper for setting a file descriptor's permissions ala
* fchmod().
*/
BU_EXPORT extern int bu_fchmod(int fd, unsigned long pmode);
/**@brief BRL-CAD specific path queries */
/**
* @brief
* Report the relative paths being used to hold BRL-CAD applications,
* libraries, and data.
*
* Recognized keys include:
*
* Key | Looks Up
* ------- | ----------------------------------------
* bin | Directory containing binary applications
* lib | Directory containing libraries
* include | Directory containing headers
* data | Directory containing shared data
* share | Directory containing shared data
* doc | Directory containing documentation
* man | Directory containing Unix man pages
*
* @return
* A STATIC buffer is returned. It is the caller's responsibility to
* call bu_strdup() or make other provisions to save the returned
* string, before calling again.
*/
BU_EXPORT extern const char *bu_brlcad_dir(const char *dirkey, int fail_quietly);
/**
* @brief
* Locate where the BRL-CAD applications and libraries are installed.
*
* The BRL-CAD root is searched for in the following order of
* precedence by testing for the rhs existence if provided or the
* directory existence otherwise:
*
* BRLCAD_ROOT environment variable if set
* BRLCAD_ROOT compile-time path
* run-time path identification
* /usr/brlcad static path
* current directory
*
* @return
* A STATIC buffer is returned. It is the caller's responsibility to
* call bu_strdup() or make other provisions to save the returned
* string, before calling again.
*/
BU_EXPORT extern const char *bu_brlcad_root(const char *rhs, int fail_quietly);
/**
* @brief
* Locate where the BRL-CAD data resources are installed.
*
* The BRL-CAD data resources are searched for in the following order
* of precedence by testing for the existence of rhs if provided or
* the directory existence otherwise:
*
* BRLCAD_DATA environment variable if set
* BRLCAD_DATA compile-time path
* bu_brlcad_root/DATA_DIR path
* bu_brlcad_root/share path
* current directory
*
* A STATIC buffer is returned. It is the caller's responsibility to
* call bu_strdup() or make other provisions to save the returned
* string, before calling again.
*/
BU_EXPORT extern const char *bu_brlcad_data(const char *rhs, int fail_quietly);
/**
*
* Routines for managing signals. In particular, provide a common
* means to temporarily buffer processing a signal during critical
* write operations.
*
*/
/**
* Defer signal processing and interrupts before critical sections.
*
* Signal processing for a variety of signals that would otherwise
* disrupt the logic of an application are put on hold until
* bu_restore_interrupts() is called.
*
* If an interrupt signal is received while suspended, it will be
* raised when/if interrupts are restored.
*
* Returns 0 on success.
* Returns non-zero on error (with perror set if signal() failure).
*/
BU_EXPORT extern int bu_suspend_interrupts(void);
/**
* Resume signal processing and interrupts after critical sections.
*
* If a signal was raised since bu_suspend_interrupts() was called,
* the previously installed signal handler will be immediately called
* albeit only once even if multiple signals were received.
*
* Returns 0 on success.
* Returns non-zero on error (with perror set if signal() failure).
*/
BU_EXPORT extern int bu_restore_interrupts(void);
/** @brief Dynamic Library functionality */
#ifdef HAVE_DLOPEN
# define BU_RTLD_LAZY RTLD_LAZY
# define BU_RTLD_NOW RTLD_NOW
# define BU_RTLD_GLOBAL RTLD_GLOBAL
# define BU_RTLD_LOCAL RTLD_LOCAL
#else
# define BU_RTLD_LAZY 1
# define BU_RTLD_NOW 2
# define BU_RTLD_GLOBAL 0x100
# define BU_RTLD_LOCAL 0
#endif
BU_EXPORT extern void *bu_dlopen(const char *path, int mode);
BU_EXPORT extern void *bu_dlsym(void *path, const char *symbol);
BU_EXPORT extern int bu_dlclose(void *handle);
BU_EXPORT extern const char *bu_dlerror(void);
/** NEW: Do not use. */
BU_EXPORT extern int bu_fseek(FILE *stream, off_t offset, int origin);
/** NEW: Do not use. */
BU_EXPORT extern off_t bu_ftell(FILE *stream);
/** @} */
__END_DECLS
#endif /* BU_FILE_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-91
View File
@@ -1,91 +0,0 @@
/* G E T O P T . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_GETOPT_H
#define BU_GETOPT_H
#include "common.h"
#include "bu/defines.h"
__BEGIN_DECLS
/** @addtogroup bu_getopt
* @brief
* Special portable re-entrant version of getopt.
*
* Everything is prefixed with bu_, to distinguish it from the various
* getopt routines found in libc.
*
* Important note -
* If bu_getopt() is going to be used more than once, it is necessary
* to reinitialize bu_optind=1 before beginning on the next argument
* list.
*/
/** @{ */
/** @file bu/getopt.h */
/**
* for bu_getopt(). set to zero to suppress errors.
*/
BU_EXPORT extern int bu_opterr;
/**
* for bu_getopt(). current index into parent argv vector.
*/
BU_EXPORT extern int bu_optind;
/**
* for bu_getopt(). current option being checked for validity.
*/
BU_EXPORT extern int bu_optopt;
/**
* for bu_getopt(). current argument associated with current option.
*/
BU_EXPORT extern char *bu_optarg;
/**
* Get option letter from argument vector.
*
* returns the next known option character in ostr. If bu_getopt()
* encounters a character not found in ostr or if it detects a missing
* option argument, it returns `?' (question mark). If ostr has a
* leading `:' then a missing option argument causes `:' to be
* returned instead of `?'. In either case, the variable bu_optopt is
* set to the character that caused the error. The bu_getopt()
* function returns -1 when the argument list is exhausted.
*/
BU_EXPORT extern int bu_getopt(int nargc, char * const nargv[], const char *ostr);
/** @} */
__END_DECLS
#endif /* BU_GETOPT_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-312
View File
@@ -1,312 +0,0 @@
/* H A S H . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_HASH_H
#define BU_HASH_H
#include "common.h"
#include "bu/defines.h"
__BEGIN_DECLS
/** @addtogroup bu_hash
* @brief
* An implementation of hash tables.
*/
/** @{ */
/** @file bu/hash.h */
/**
* A hash entry
*/
struct bu_hash_entry {
uint32_t magic;
unsigned char *key;
unsigned char *value;
int key_len;
struct bu_hash_entry *next;
};
typedef struct bu_hash_entry bu_hash_entry_t;
#define BU_HASH_ENTRY_NULL ((struct bu_hash_entry *)0)
/**
* asserts the integrity of a non-head node bu_hash_entry struct.
*/
#define BU_CK_HASH_ENTRY(_ep) BU_CKMAG(_ep, BU_HASH_ENTRY_MAGIC, "bu_hash_entry")
/**
* initializes a bu_hash_entry struct without allocating any memory.
*/
#define BU_HASH_ENTRY_INIT(_h) { \
(_h)->magic = BU_HASH_ENTRY_MAGIC; \
(_h)->key = (_h)->value = NULL; \
(_h)->key_len = 0; \
(_h)->next = NULL; \
}
/**
* macro suitable for declaration statement initialization of a
* bu_hash_entry struct. does not allocate memory.
*/
#define BU_HASH_ENTRY_INIT_ZERO { BU_HASH_ENTRY_MAGIC, NULL, NULL, 0, NULL }
/**
* returns truthfully whether a bu_hash_entry has been initialized.
*/
#define BU_HASH_ENTRY_IS_INITIALIZED(_h) (((struct bu_hash_entry *)(_h) != BU_HASH_ENTRY_NULL) && LIKELY((_h)->magic == BU_HASH_ENTRY_MAGIC))
/**
* A table of hash entries
*/
struct bu_hash_tbl {
uint32_t magic;
unsigned long mask;
unsigned long num_lists;
unsigned long num_entries;
struct bu_hash_entry **lists;
};
typedef struct bu_hash_tbl bu_hash_tbl_t;
#define BU_HASH_TBL_NULL ((struct bu_hash_tbl *)0)
/**
* asserts the integrity of a non-head node bu_hash_tbl struct.
*/
#define BU_CK_HASH_TBL(_hp) BU_CKMAG(_hp, BU_HASH_TBL_MAGIC, "bu_hash_tbl")
/**
* initializes a bu_hash_tbl struct without allocating any memory.
*/
#define BU_HASH_TBL_INIT(_h) { \
(_h)->magic = BU_HASH_TBL_MAGIC; \
(_h)->mask = (_h)->num_lists = (_h)->num_entries = 0; \
(_h)->lists = NULL; \
}
/**
* macro suitable for declaration statement initialization of a
* bu_hash_tbl struct. does not allocate memory.
*/
#define BU_HASH_TBL_INIT_ZERO { BU_HASH_TBL_MAGIC, 0, 0, 0, NULL }
/**
* returns truthfully whether a bu_hash_tbl has been initialized.
*/
#define BU_HASH_TBL_IS_INITIALIZED(_h) (((struct bu_hash_tbl *)(_h) != BU_HASH_TBL_NULL) && LIKELY((_h)->magic == BU_HASH_TBL_MAGIC))
/**
* A hash table entry record
*/
struct bu_hash_record {
uint32_t magic;
const struct bu_hash_tbl *tbl;
unsigned long index;
struct bu_hash_entry *hsh_entry;
};
typedef struct bu_hash_record bu_hash_record_t;
#define BU_HASH_RECORD_NULL ((struct bu_hash_record *)0)
/**
* asserts the integrity of a non-head node bu_hash_record struct.
*/
#define BU_CK_HASH_RECORD(_rp) BU_CKMAG(_rp, BU_HASH_RECORD_MAGIC, "bu_hash_record")
/**
* initializes a bu_hash_record struct without allocating any memory.
*/
#define BU_HASH_RECORD_INIT(_h) { \
(_h)->magic = BU_HASH_RECORD_MAGIC; \
(_h)->tbl = NULL; \
(_h)->index = 0; \
(_h)->hsh_entry = NULL; \
}
/**
* macro suitable for declaration statement initialization of a
* bu_hash_record struct. does not allocate memory.
*/
#define BU_HASH_RECORD_INIT_ZERO { BU_HASH_RECORD_MAGIC, NULL, 0, NULL }
/**
* returns truthfully whether a bu_hash_record has been initialized.
*/
#define BU_HASH_RECORD_IS_INITIALIZED(_h) (((struct bu_hash_record *)(_h) != BU_HASH_RECORD_NULL) && LIKELY((_h)->magic == BU_HASH_RECORD_MAGIC))
/**
* the hashing function
*/
BU_EXPORT extern unsigned long bu_hash(const unsigned char *str, size_t len);
/**
* Create an empty hash table
*
* The input is the number of desired hash bins. This number will be
* rounded up to the nearest power of two.
*/
BU_EXPORT extern struct bu_hash_tbl *bu_hash_tbl_create(unsigned long tbl_size);
/**
* Find the hash table entry corresponding to the provided key
*
* @param[in] hsh_tbl - The hash table to look in
* @param[in] key - the key to look for
* @param[in] key_len - the length of the key in bytes
*
* Output:
* @param[out] prev - the previous hash table entry (non-null for entries that not the first in hash bin)
* @param[out] idx - the index of the hash bin for this key
*
* @return
* the hash table entry corresponding to the provided key, or NULL if
* not found.
*/
BU_EXPORT extern struct bu_hash_entry *bu_hash_tbl_find(const struct bu_hash_tbl *hsh_tbl,
const unsigned char *key,
int key_len,
struct bu_hash_entry **prev,
unsigned long *idx);
/**
* Set the value for a hash table entry
*
* Note that this is just a pointer copy, the hash table does not
* maintain its own copy of this value.
*/
BU_EXPORT extern void bu_set_hash_value(struct bu_hash_entry *hsh_entry,
unsigned char *value);
/**
* get the value pointer stored for the specified hash table entry
*/
BU_EXPORT extern unsigned char *bu_get_hash_value(const struct bu_hash_entry *hsh_entry);
/**
* get the key pointer stored for the specified hash table entry
*/
BU_EXPORT extern unsigned char *bu_get_hash_key(const struct bu_hash_entry *hsh_entry);
/**
* Add an new entry to a hash table
*
* @param[in] hsh_tbl - the hash table to accept the new entry
* @param[in] key - the key (any byte string)
* @param[in] key_len - the number of bytes in the key
*
* @param[out] new_entry - a flag, non-zero indicates that a new entry
* was created. zero indicates that an entry already exists with the
* specified key and key length
*
* @return
* a hash table entry. If "new" is non-zero, a new, empty entry is
* returned. if "new" is zero, the returned entry is the one matching
* the specified key and key_len.
*/
BU_EXPORT extern struct bu_hash_entry *bu_hash_tbl_add(struct bu_hash_tbl *hsh_tbl,
const unsigned char *key,
int key_len,
int *new_entry);
/**
* Print the specified hash table to stderr.
*
* (Note that the keys and values are printed as pointers)
*/
BU_EXPORT extern void bu_hash_tbl_print(const struct bu_hash_tbl *hsh_tbl,
const char *str);
/**
* Free all the memory associated with the specified hash table.
*
* Note that the keys are freed (they are copies), but the "values"
* are not freed. (The values are merely pointers)
*/
BU_EXPORT extern void bu_hash_tbl_free(struct bu_hash_tbl *hsh_tbl);
/**
* get the "first" entry in a hash table
*
* @param[in] hsh_tbl - the hash table of interest
* @param[in] rec - an empty "bu_hash_record" structure for use by this routine and "bu_hash_tbl_next"
*
* @return
* the first non-null entry in the hash table, or NULL if there are no
* entries (Note that the order of entries is not likely to have any
* significance)
*/
BU_EXPORT extern struct bu_hash_entry *bu_hash_tbl_first(const struct bu_hash_tbl *hsh_tbl,
struct bu_hash_record *rec);
/**
* get the "next" entry in a hash table
*
* input:
* rec - the "bu_hash_record" structure that was passed to
* "bu_hash_tbl_first"
*
* return:
* the "next" non-null hash entry in this hash table
*/
BU_EXPORT extern struct bu_hash_entry *bu_hash_tbl_next(struct bu_hash_record *rec);
/**
* Pass each table entry to a supplied function, along with an
* additional argument (which may be NULL).
*
* Returns when func returns !0 or every entry has been visited.
*
* Example, freeing all memory associated with a table whose values
* are dynamically allocated ints:
@code
static int
free_entry(struct bu_hash_entry *entry, void *UNUSED(arg))
{
bu_free(bu_get_hash_value(entry), "table value");
return 0;
}
bu_hash_table_traverse(table, free_entry, NULL);
bu_hash_table_free(table);
@endcode
*
* @return
* If func returns !0 for an entry, that entry is returned.
* Otherwise NULL is returned.
*/
BU_EXPORT extern struct bu_hash_entry *bu_hash_tbl_traverse(struct bu_hash_tbl *hsh_tbl, int (*func)(struct bu_hash_entry *, void *), void *func_arg);
/** @} */
__END_DECLS
#endif /* BU_HASH_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-141
View File
@@ -1,141 +0,0 @@
/* H I S T . H
* BRL-CAD
*
* Copyright (c) 2004-2014 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.
*/
#ifndef BU_HIST_H
#define BU_HIST_H
#include "common.h"
#include <stddef.h> /* for size_t */
#include "bu/defines.h"
#include "bu/magic.h"
__BEGIN_DECLS
/** @addtogroup bu_hist
*
* @brief
* General purpose histogram handling routines.
*
* The subroutine bu_hist_range() is used to record items that may
* extend across multiple "bin"s.
*
*/
/** @{ */
/** @file bu/hist.h */
/**
* histogram support
*/
struct bu_hist {
uint32_t magic; /**< magic # for id/check */
fastf_t hg_min; /**< minimum value */
fastf_t hg_max; /**< maximum value */
fastf_t hg_clumpsize; /**< (max-min+1)/nbins+1 */
size_t hg_nsamples; /**< total number of samples spread into histogram */
size_t hg_nbins; /**< # of bins in hg_bins[] */
long *hg_bins; /**< array of counters */
};
typedef struct bu_hist bu_hist_t;
#define BU_HIST_NULL ((struct bu_hist *)0)
/**
* assert the integrity of a bu_hist struct.
*/
#define BU_CK_HIST(_p) BU_CKMAG(_p, BU_HIST_MAGIC, "struct bu_hist")
/**
* initialize a bu_hist struct without allocating any memory.
*/
#define BU_HIST_INIT(_hp) { \
(_hp)->magic = BU_HIST_MAGIC; \
(_hp)->hg_min = (_hp)->hg_max = (_hp)->hg_clumpsize = 0.0; \
(_hp)->hg_nsamples = (_hp)->hg_nbins = 0; \
(_hp)->hg_bins = NULL; \
}
/**
* macro suitable for declaration statement initialization of a
* bu_hist struct. does not allocate memory.
*/
#define BU_HIST_INIT_ZERO {BU_HIST_MAGIC, 0.0, 0.0, 0.0, 0, 0, NULL}
/**
* returns truthfully whether a bu_hist has been initialized via
* BU_HIST_INIT() or BU_HIST_INIT_ZERO.
*/
#define BU_HIST_IS_INITIALIZED(_hp) (((struct bu_hist *)(_hp) != BU_HIST_NULL) && LIKELY((_hp)->magic == BU_HIST_MAGIC))
#define BU_HIST_TALLY(_hp, _val) { \
if ((_val) <= (_hp)->hg_min) { \
(_hp)->hg_bins[0]++; \
} else if ((_val) >= (_hp)->hg_max) { \
(_hp)->hg_bins[(_hp)->hg_nbins]++; \
} else { \
(_hp)->hg_bins[(int)(((_val)-(_hp)->hg_min)/(_hp)->hg_clumpsize)]++; \
} \
(_hp)->hg_nsamples++; }
#define BU_HIST_TALLY_MULTIPLE(_hp, _val, _count) { \
int __count = (_count); \
if ((_val) <= (_hp)->hg_min) { \
(_hp)->hg_bins[0] += __count; \
} else if ((_val) >= (_hp)->hg_max) { \
(_hp)->hg_bins[(_hp)->hg_nbins] += __count; \
} else { \
(_hp)->hg_bins[(int)(((_val)-(_hp)->hg_min)/(_hp)->hg_clumpsize)] += __count; \
} \
(_hp)->hg_nsamples += __count; }
/* hist.c */
/* These are a set of data histogramming routines. */
BU_EXPORT extern void bu_hist_free(struct bu_hist *histp);
/**
* Initialize a bu_hist structure.
*
* It is expected that the structure is junk upon entry.
*/
BU_EXPORT extern void bu_hist_init(struct bu_hist *histp, fastf_t min, fastf_t max, size_t nbins);
BU_EXPORT extern void bu_hist_range(struct bu_hist *hp, fastf_t low, fastf_t high);
/**
* Print a histogram.
*/
BU_EXPORT extern void bu_hist_pr(const struct bu_hist *histp, const char *title);
/** @} */
__END_DECLS
#endif /* BU_HIST_H */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/

Some files were not shown because too many files have changed in this diff Show More