Not even Debian is maintaining a vds package anymore. This one is an easy embedding in librt - strip down, clean up and move.

svn:revision:77313
svn:branch:trunk
svn:account:starseeker
This commit is contained in:
Clifford Yapp committed 2020-10-01 21:17:30 +00:00
1 parent 40bfac7303
commit a6c2c7236a
19 files changed
+196 -639

No files matched your search

-11
View File
@@ -671,17 +671,6 @@ first for a system version if BRLCAD_BUNDLED_LIBS is also AUTO.
Aliases: ENABLE_SCL, ENABLE_STEP, ENABLE_STEP_CLASS_LIBRARIES
--- BRLCAD_VDS ---
Option for enabling and disabling compilation of the libvds triangle
simplification library provided with BRL-CAD's source code. Default
is AUTO, responsive to the toplevel BRLCAD_BUNDLED_LIBS option and
testing first for a system version if BRLCAD_BUNDLED_LIBS is also
AUTO.
Aliases: ENABLE_VDS
--- BRLCAD_OSG ---
Option for enabling and disabling compilation of the OpenSceneGraph
Vendored
-4
View File
@@ -174,10 +174,6 @@ do
shift;;
--disable-step-class-libraries) options="$options -DBRLCAD_SC=SYSTEM";
shift;;
--enable-vds) options="$options -DBRLCAD_VDS=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";
+1
View File
@@ -70,6 +70,7 @@ set(embedded_licenses
tkcon.txt
tri_pt.txt
uce_dirent.txt
vds.txt
whereami.txt
winmmap.txt
x24.txt
+3
View File
@@ -26,3 +26,6 @@ Copyright:
SUCH DAMAGES.
Note: the polyview example is not included with the BRL-CAD copy of libvds.
file:/src/librt/vds/vds.h
file:/src/librt/vds/vds.c
-1
View File
@@ -9,7 +9,6 @@ set(other_licenses
libpng.txt
libregex.txt
libutahrle.txt
libvds.txt
libz.txt
linenoise.txt
OpenNURBS.txt
-1
View File
@@ -46,7 +46,6 @@ set(cmake_ignore_files
FindTCL.cmake
FindUTAHRLE.cmake
FindUUID.cmake
FindVDS.cmake
FindWix.cmake
FindX11.cmake
FindXMLLINT.cmake
-60
View File
@@ -1,60 +0,0 @@
# F I N D V D S . C M A K E
# BRL-CAD
#
# Copyright (c) 2013-2020 United States Government as represented by
# the U.S. Army Research Laboratory.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# 3. The name of the author may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
###
# - Find View Dependent Simplification library
#
# The following variables are set:
#
# VDS_INCLUDE_DIRS - where to find vds.h, etc.
# VDS_LIBRARIES - List of libraries when using vds.
# VDS_FOUND - True if vds found.
find_path(VDS_INCLUDE_DIR vds.h)
find_library(VDS_LIBRARY NAMES vds vdslib)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VDS DEFAULT_MSG VDS_LIBRARY VDS_INCLUDE_DIR)
IF (VDS_FOUND)
set(VDS_INCLUDE_DIRS ${VDS_INCLUDE_DIR})
set(VDS_LIBRARIES ${VDS_LIBRARY})
endif()
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8
-2
View File
@@ -43,7 +43,6 @@ target_link_libraries(BrlcadCore
regex-static
librt-static
libbrep-static
vds-static
libwdb-static
libnmg-static
poly2tri-static
@@ -124,7 +123,6 @@ target_link_libraries(brlcad
regex-static
librt-static
libbrep-static
vds-static
libwdb-static
libnmg-static
poly2tri-static
+1 -4
View File
@@ -38,7 +38,7 @@ if(NOT DEFINED BRLCAD_BUILDTEST_EXTERNALS)
set(CREO_DEFS "-DPRO_MACHINE=36 -DPRO_OS=4 -DPRO_USE_VAR_ARGS -D_USING_V100_SDK71_")
# BRL-CAD definitions
set(BRLCAD_DEFS "-DHAVE_CONFIG_H -DBRLCAD_DLL -DBRLCADBUILD -DBU_DLL_IMPORTS -DBN_DLL_IMPORTS -DNMG_DLL_IMPORTS -DBG_DLL_IMPORTS -DBREP_DLL_IMPORTS -DRT_DLL_IMPORTS -DWDB_DLL_IMPORTS -DTIE_DLL_IMPORTS -DDB5_DLL_IMPORTS -DVDS_DLL_IMPORTS -DGDIAM_DLL_IMPORTS -DON_DLL_IMPORTS -DLZ4_DLL_IMPORT=1")
set(BRLCAD_DEFS "-DHAVE_CONFIG_H -DBRLCAD_DLL -DBRLCADBUILD -DBU_DLL_IMPORTS -DBN_DLL_IMPORTS -DNMG_DLL_IMPORTS -DBG_DLL_IMPORTS -DBREP_DLL_IMPORTS -DRT_DLL_IMPORTS -DWDB_DLL_IMPORTS -DTIE_DLL_IMPORTS -DDB5_DLL_IMPORTS -DGDIAM_DLL_IMPORTS -DON_DLL_IMPORTS")
# These settings are global to all the configs.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CREO_DEFS} ${BRLCAD_DEFS}" CACHE STRING "" FORCE)
@@ -211,7 +211,6 @@ if(NOT DEFINED BRLCAD_BUILDTEST_EXTERNALS)
openNURBS
poly2tri
regex_brl
vds
z_brl1
)
set(BRLCAD_STATIC_LIBS)
@@ -371,9 +370,7 @@ else(NOT DEFINED BRLCAD_BUILDTEST_EXTERNALS)
set_property(TARGET creo-brl APPEND PROPERTY COMPILE_DEFINITIONS "WDB_DLL_IMPORTS")
set_property(TARGET creo-brl APPEND PROPERTY COMPILE_DEFINITIONS "TIE_DLL_IMPORTS")
set_property(TARGET creo-brl APPEND PROPERTY COMPILE_DEFINITIONS "GDIAM_DLL_IMPORTS")
set_property(TARGET creo-brl APPEND PROPERTY COMPILE_DEFINITIONS "VDS_DLL_IMPORTS")
set_property(TARGET creo-brl APPEND PROPERTY COMPILE_DEFINITIONS "ON_DLL_IMPORTS")
set_property(TARGET creo-brl APPEND PROPERTY COMPILE_DEFINITIONS "LZ4_DLL_IMPORT=1")
endif(HIDE_INTERNAL_SYMBOLS)
# Distcheck file list
-2
View File
@@ -36,10 +36,8 @@ else(NOT DEFINED BRLCAD_BUILDTEST_EXTERNALS)
set_property(TARGET g-sat APPEND PROPERTY COMPILE_DEFINITIONS "WDB_DLL_IMPORTS")
set_property(TARGET g-sat APPEND PROPERTY COMPILE_DEFINITIONS "TIE_DLL_IMPORTS")
set_property(TARGET g-sat APPEND PROPERTY COMPILE_DEFINITIONS "GDIAM_DLL_IMPORTS")
set_property(TARGET g-sat APPEND PROPERTY COMPILE_DEFINITIONS "VDS_DLL_IMPORTS")
set_property(TARGET g-sat APPEND PROPERTY COMPILE_DEFINITIONS "ON_DLL_IMPORTS")
set_property(TARGET g-sat APPEND PROPERTY COMPILE_DEFINITIONS "TINYCTHREAD_DLL_IMPORTS")
set_property(TARGET g-sat APPEND PROPERTY COMPILE_DEFINITIONS "LZ4_DLL_IMPORT=1")
endif(HIDE_INTERNAL_SYMBOLS)
CMAKEFILES(${g_sat_srcs} shim.h)
-1
View File
@@ -41,7 +41,6 @@ else(NOT DEFINED BRLCAD_BUILDTEST_EXTERNALS)
set_property(TARGET ug-g APPEND PROPERTY COMPILE_DEFINITIONS "WDB_DLL_IMPORTS")
set_property(TARGET ug-g APPEND PROPERTY COMPILE_DEFINITIONS "TIE_DLL_IMPORTS")
set_property(TARGET ug-g APPEND PROPERTY COMPILE_DEFINITIONS "GDIAM_DLL_IMPORTS")
set_property(TARGET ug-g APPEND PROPERTY COMPILE_DEFINITIONS "VDS_DLL_IMPORTS")
set_property(TARGET ug-g APPEND PROPERTY COMPILE_DEFINITIONS "ON_DLL_IMPORTS")
set_property(TARGET ug-g APPEND PROPERTY COMPILE_DEFINITIONS "TINYCTHREAD_DLL_IMPORTS")
set_property(TARGET ug-g APPEND PROPERTY COMPILE_DEFINITIONS "LZ4_DLL_IMPORT=1")
+6 -8
View File
@@ -19,8 +19,8 @@ endif (BRLCAD_ENABLE_OPENCL)
# locally used but not needed by users of the library
set(RT_LOCAL_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/vds
${REGEX_INCLUDE_DIRS}
${VDS_INCLUDE_DIRS}
${GDIAM_INCLUDE_DIRS}
)
@@ -219,6 +219,7 @@ set(LIBRT_SOURCES
transform.c
tree.c
uv.c
vds/vds.c
vers.c
vlist.c
vshoot.c
@@ -362,24 +363,18 @@ if(BRLCAD_ENABLE_SPR)
set(SPR_LIB libSPR)
endif(BRLCAD_ENABLE_SPR)
BRLCAD_ADDLIB(librt "${LIBRT_SOURCES}" "${OPENCL_LIBS};${GDIAM_LIBRARY};${VDS_LIBRARY};libbrep;libnmg;libbg;libbn;libbu;${OPENNURBS_LIBRARIES};${P2T_LIBRARY};${SPR_LIB};${REGEX_LIBRARIES};${WINSOCK_LIB};${RPCRT_LIB};${STDCXX_LIBRARIES}")
BRLCAD_ADDLIB(librt "${LIBRT_SOURCES}" "${OPENCL_LIBS};${GDIAM_LIBRARY};libbrep;libnmg;libbg;libbn;libbu;${OPENNURBS_LIBRARIES};${REGEX_LIBRARIES};${WINSOCK_LIB};${RPCRT_LIB};${STDCXX_LIBRARIES}")
set_target_properties(librt PROPERTIES VERSION 20.0.1 SOVERSION 20)
if(HIDE_INTERNAL_SYMBOLS)
set_property(TARGET librt APPEND PROPERTY COMPILE_DEFINITIONS "TIE_DLL_EXPORTS")
set_property(TARGET librt APPEND PROPERTY COMPILE_DEFINITIONS "DB5_DLL_EXPORTS")
if(TARGET vds OR HIDE_INTERNAL_SYMBOLS_EXT)
set_property(TARGET librt APPEND PROPERTY COMPILE_DEFINITIONS "VDS_DLL_IMPORTS")
endif(TARGET vds OR HIDE_INTERNAL_SYMBOLS_EXT)
if(TARGET gdiam OR HIDE_INTERNAL_SYMBOLS_EXT)
set_property(TARGET librt APPEND PROPERTY COMPILE_DEFINITIONS "GDIAM_DLL_IMPORTS")
endif(TARGET gdiam OR HIDE_INTERNAL_SYMBOLS_EXT)
if (TARGET librt-obj)
set_property(TARGET librt-obj APPEND PROPERTY COMPILE_DEFINITIONS "TIE_DLL_EXPORTS")
set_property(TARGET librt-obj APPEND PROPERTY COMPILE_DEFINITIONS "DB5_DLL_EXPORTS")
if(TARGET vds OR HIDE_INTERNAL_SYMBOLS_EXT)
set_property(TARGET librt-obj APPEND PROPERTY COMPILE_DEFINITIONS "VDS_DLL_IMPORTS")
endif(TARGET vds OR HIDE_INTERNAL_SYMBOLS_EXT)
if(TARGET gdiam OR HIDE_INTERNAL_SYMBOLS_EXT)
set_property(TARGET librt-obj APPEND PROPERTY COMPILE_DEFINITIONS "GDIAM_DLL_IMPORTS")
endif(TARGET gdiam OR HIDE_INTERNAL_SYMBOLS_EXT)
@@ -405,6 +400,9 @@ add_subdirectory(tests)
CMAKEFILES(
CMakeLists.txt
db_fp.cpp
vds/README
vds/COPYING
vds/vds.h
)
# Local Variables:
File renamed without changes.
File renamed without changes.
+112 -329
View File
@@ -1,3 +1,35 @@
/***************************************************************************\
Copyright 1999 The University of Virginia.
All Rights Reserved.
Permission to use, copy, modify and distribute this software and its
documentation without fee, and without a written agreement, is
hereby granted, provided that the above copyright notice and the
complete text of this comment appear in all copies, and provided that
the University of Virginia and the original authors are credited in
any publications arising from the use of this software.
IN NO EVENT SHALL THE UNIVERSITY OF VIRGINIA OR THE AUTHOR OF THIS
SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE
UNIVERSITY OF VIRGINIA AND/OR THE AUTHOR OF THIS SOFTWARE HAVE BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
The author of the vdslib software library may be contacted at:
US Mail: Dr. David Patrick Luebke
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Phone: (804)924-1021
EMail: luebke@cs.virginia.edu
\*****************************************************************************/
/**
* @memo Routines for constructing the VDSlib vertex tree.
* @name Building the vertex tree
@@ -45,12 +77,13 @@
*/
/*@{*/
#include <assert.h>
#include "common.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vmath.h"
#include "vds.h"
#define MAJOR 1
@@ -66,7 +99,6 @@
#define VDS_DEBUG(x) printf x
#else
#define VDS_DEBUG(x)
#define NDEBUG /* disable asserts */
#endif
/**
@@ -135,68 +167,68 @@ extern void vdsComputeTriNodes(vdsNode *node, vdsNode *root);
extern "C" {
#endif
#define VEC3_EQUAL(a,b) ((a)[0]==(b)[0]&&(a)[1]==(b)[1]&&(a)[2]==(b)[2])
#define VEC3_EQUAL(a,b) (NEAR_EQUAL((a)[0],(b)[0], SMALL_FASTF) && NEAR_EQUAL((a)[1],(b)[1], SMALL_FASTF) && NEAR_EQUAL((a)[2],(b)[2],SMALL_FASTF))
#define VEC3_COPY(dst,src) ((dst)[0]=(src)[0], \
(dst)[1]=(src)[1], \
(dst)[2]=(src)[2])
(dst)[1]=(src)[1], \
(dst)[2]=(src)[2])
#define VEC3_ADD(dst,a,b) {(dst)[0]=(a)[0]+(b)[0];\
(dst)[1]=(a)[1]+(b)[1];\
(dst)[2]=(a)[2]+(b)[2];}
(dst)[1]=(a)[1]+(b)[1];\
(dst)[2]=(a)[2]+(b)[2];}
#define VEC3_SUBTRACT(dst,a,b) {(dst)[0]=(a)[0]-(b)[0];\
(dst)[1]=(a)[1]-(b)[1];\
(dst)[2]=(a)[2]-(b)[2];}
(dst)[1]=(a)[1]-(b)[1];\
(dst)[2]=(a)[2]-(b)[2];}
#define VEC3_SCALE(dst,scal,vec) {(dst)[0]=(vec)[0]*(scal);\
(dst)[1]=(vec)[1]*(scal);\
(dst)[2]=(vec)[2]*(scal);}
(dst)[1]=(vec)[1]*(scal);\
(dst)[2]=(vec)[2]*(scal);}
#define VEC3_AVERAGE(dst,a,b) {(dst)[0]=((a)[0]+(b)[0])/2.0;\
(dst)[1]=((a)[1]+(b)[1])/2.0;\
(dst)[2]=((a)[2]+(b)[2])/2.0;}
(dst)[1]=((a)[1]+(b)[1])/2.0;\
(dst)[2]=((a)[2]+(b)[2])/2.0;}
#define VEC3_DOT(_v0, _v1) ((_v0)[0] * (_v1)[0] + \
(_v0)[1] * (_v1)[1] + \
(_v0)[2] * (_v1)[2])
(_v0)[1] * (_v1)[1] + \
(_v0)[2] * (_v1)[2])
#define VEC3_CROSS(dst,a,b) {(dst)[0]=(a)[1]*(b)[2]-(a)[2]*(b)[1];\
(dst)[1]=(a)[2]*(b)[0]-(a)[0]*(b)[2];\
(dst)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0];}
(dst)[1]=(a)[2]*(b)[0]-(a)[0]*(b)[2];\
(dst)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0];}
#define VEC3_LENGTH_SQUARED(v) ((v)[0]*(v)[0] + (v)[1]*(v)[1] + (v)[2]*(v)[2])
#define VEC3_LENGTH(v) (sqrt(VEC3_LENGTH_SQUARED(v)))
#define VEC3_DISTANCE_SQUARED(a,b) (((a)[0]-(b)[0])*((a)[0]-(b)[0]) + \
((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \
((a)[2]-(b)[2])*((a)[2]-(b)[2]))
((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \
((a)[2]-(b)[2])*((a)[2]-(b)[2]))
#define VEC3_DISTANCE(a,b) (sqrt(VEC3_DISTANCE_SQUARED((a),(b))))
#define VEC3_NORMALIZE(v) {static vdsFloat _n; \
_n = 1.0/sqrt((v)[0]*(v)[0] + \
(v)[1]*(v)[1] + \
(v)[2]*(v)[2]); \
(v)[0]*=_n; \
(v)[1]*=_n; \
(v)[2]*=_n;}
_n = 1.0/sqrt((v)[0]*(v)[0] + \
(v)[1]*(v)[1] + \
(v)[2]*(v)[2]); \
(v)[0]*=_n; \
(v)[1]*=_n; \
(v)[2]*=_n;}
#define VEC3_FIND_MAX(dst,a,b) {(dst)[0]=(a)[0]>(b)[0]?(a)[0]:(b)[0];\
(dst)[1]=(a)[1]>(b)[1]?(a)[1]:(b)[1];\
(dst)[2]=(a)[2]>(b)[2]?(a)[2]:(b)[2];}
(dst)[1]=(a)[1]>(b)[1]?(a)[1]:(b)[1];\
(dst)[2]=(a)[2]>(b)[2]?(a)[2]:(b)[2];}
#define VEC3_FIND_MIN(dst,a,b) {(dst)[0]=(a)[0]<(b)[0]?(a)[0]:(b)[0];\
(dst)[1]=(a)[1]<(b)[1]?(a)[1]:(b)[1];\
(dst)[2]=(a)[2]<(b)[2]?(a)[2]:(b)[2];}
(dst)[1]=(a)[1]<(b)[1]?(a)[1]:(b)[1];\
(dst)[2]=(a)[2]<(b)[2]?(a)[2]:(b)[2];}
#define BYTE3_EQUAL(a,b) ((a)[0]==(b)[0]&&(a)[1]==(b)[1]&&(a)[2]==(b)[2])
#define BYTE3_COPY(dst,src) ((dst)[0]=(src)[0], \
(dst)[1]=(src)[1], \
(dst)[2]=(src)[2])
(dst)[1]=(src)[1], \
(dst)[2]=(src)[2])
#ifdef __cplusplus
}
@@ -220,7 +252,6 @@ static int openflag = 0;
*/
void vdsBeginVertexTree()
{
assert(openflag == 0);
openflag = 1;
}
@@ -230,7 +261,6 @@ void vdsBeginVertexTree()
*/
void vdsBeginGeometry()
{
assert(openflag == 1);
maxnodes = 1024;
nodearray = (vdsNode *) calloc(maxnodes, sizeof(vdsNode));
vdsNumnodes = 0;
@@ -252,7 +282,6 @@ void vdsBeginGeometry()
*/
vdsNode *vdsEndGeometry()
{
assert(openflag == 1);
/* Tighten nodearray and triarray to free up unused memory */
nodearray = (vdsNode *) realloc(nodearray, vdsNumnodes * sizeof(vdsNode));
triarray = (vdsTri *) realloc(triarray, vdsNumtris * sizeof(vdsTri));
@@ -297,7 +326,6 @@ void vdsNewObject()
*/
vdsNode *vdsAddNode(vdsFloat x, vdsFloat y, vdsFloat z)
{
assert(openflag == 1);
nodearray[vdsNumnodes].coord[0] = x;
nodearray[vdsNumnodes].coord[1] = y;
nodearray[vdsNumnodes].coord[2] = z;
@@ -330,16 +358,12 @@ vdsNode *vdsAddNode(vdsFloat x, vdsFloat y, vdsFloat z)
* and vdsEndGeometry().
*/
vdsTri *vdsAddTri(int v0, int v1, int v2,
vdsVec3 n0, vdsVec3 n1, vdsVec3 n2,
vdsByte3 c0, vdsByte3 c1, vdsByte3 c2)
vdsVec3 n0, vdsVec3 n1, vdsVec3 n2,
vdsByte3 c0, vdsByte3 c1, vdsByte3 c2)
{
assert(openflag == 1);
triarray[vdsNumtris].corners[0].index = v0 + curroffset;
triarray[vdsNumtris].corners[1].index = v1 + curroffset;
triarray[vdsNumtris].corners[2].index = v2 + curroffset;
assert(v0 + curroffset < vdsNumnodes); /* Sanity check */
assert(v1 + curroffset < vdsNumnodes); /* Sanity check */
assert(v2 + curroffset < vdsNumnodes); /* Sanity check */
VEC3_COPY(triarray[vdsNumtris].normal[0], n0);
VEC3_COPY(triarray[vdsNumtris].normal[1], n1);
VEC3_COPY(triarray[vdsNumtris].normal[2], n2);
@@ -370,18 +394,14 @@ vdsTri *vdsAddTri(int v0, int v1, int v2,
* This pointer is only valid until the vdsEndVertexTree() call.
*/
vdsNode *vdsClusterNodes(int nnodes, vdsNode **nodes,
vdsFloat x, vdsFloat y, vdsFloat z)
vdsFloat x, vdsFloat y, vdsFloat z)
{
int i;
vdsNode *parent = (vdsNode *) calloc(1, sizeof(vdsNode));
assert(nnodes <= VDS_MAXDEGREE);
assert(nodes[0] != NULL);
parent->children = nodes[0];
parent->children->parent = parent;
for (i = 1; i < nnodes; i++) {
assert(nodes[i] != NULL);
assert(nodes[i]->parent == NULL);
nodes[i]->parent = parent;
nodes[i - 1]->sibling = nodes[i];
}
@@ -393,76 +413,6 @@ vdsNode *vdsClusterNodes(int nnodes, vdsNode **nodes,
return parent;
}
/*
* Function: idEqual
* Description: Returns 1 if the two given vdsNodeIds are equal, 0 otherwise
*/
static int idEqual(vdsNodeId n1, vdsNodeId n2)
{
if (n1.depth != n2.depth) {
return 0;
} else {
if (n1.path != n2.path) {
return 0;
} else {
return 1;
}
}
}
/*
* Function: assignNodeIds
* Description: Recursively descends vertex tree, assigning node paths & depths
* and initializing node->status to Inactive (since 0 == Boundary
* for speed reasons).
* Arguments: node - the node rooting the given subtree
* nodeId - the node id of the given node
* idArray - array in which we put ids of leaf nodes
*/
static int assignNodeIds(vdsNode *node, vdsNodeId nodeId, vdsNodeId *idArray)
{
int i, j;
vdsNode *child;
vdsNodeId childId;
static int maxdepth = 0;
static int maxdegree = 0;
node->status = Inactive;
node->depth = nodeId.depth;
j = 0;
child = node->children;
while (child != NULL) {
childId.depth = nodeId.depth + 1;
PATH_COPY(childId.path, nodeId.path);
PATH_SET_BRANCH(childId.path, nodeId.depth, j);
assignNodeIds(child, childId, idArray);
j++;
child = child->sibling;
}
/*
* If this is a leaf node (i.e., a vertex in original model) store its
* NodeId in idArray[]. Later we will convert tri->corners to reference
* these nodes by NodeId rather than index in nodearray[].
*/
if (j == 0) {
int index = node - nodearray; /* pointer arithmetic */
assert(index < vdsNumnodes);
idArray[index] = nodeId;
}
if (j > maxdegree) {
maxdegree = j;
}
if (nodeId.depth > maxdepth) {
maxdepth = nodeId.depth;
}
assert (maxdegree <= VDS_MAXDEGREE);
assert(maxdepth <= VDS_MAXDEPTH);
return maxdepth;
}
/*
* Function: verifyRootedTree
* Description: Verifies that all the leaf nodes in nodearray belong to a
@@ -597,102 +547,6 @@ static vdsNode *moveTrisToNodes(vdsNode *N)
return N;
}
/*
* Function: computeInternalBounds
* Description: Recursively descends the vertex tree, computing each node's
* bounding sphere from its children's bounds.
* Algorithm: Computes the center of the new bounding sphere by averaging
* the centers of the child spheres. For each child sphere,
* find the distance from its center to the averaged parent
* center, plus the radius of the child sphere. The maximum of
* these is used as the radius for the parent sphere.
* XXX: This is certainly suboptimal. Perhaps I should modify and use
* the Graphics Gems code for finding tightly-enclosing spheres?
*/
static void computeInternalBounds(vdsNode *node)
{
vdsNode *child = node->children;
int numchildren = 0;
vdsFloat maxdist = 0;
vdsVec3 center = {0, 0, 0};
/* If node is a leaf, just return */
if (child == NULL) {
return;
}
while (child != NULL) {
computeInternalBounds(child); /* Recurse to compute child sphere */
VEC3_ADD(center, center, child->bound.center);
child = child->sibling;
numchildren++;
}
VEC3_SCALE(center, 1.0 / (vdsFloat)numchildren, center);
child = node->children;
while (child != NULL) {
vdsFloat dist =
VEC3_DISTANCE(center, child->bound.center) + child->bound.radius;
if (dist > maxdist) {
maxdist = dist;
}
child = child->sibling;
}
VEC3_COPY(node->bound.center, center);
node->bound.radius = maxdist;
}
/* Recursively assign bounding volumes to each node.
*
* Algorithm: For the moment, uses a very simple, crude way of estimating
* bounding spheres: spins through triarray and for each leaf
* node, computes an axis-aligned bounding box that completely
* contains all triangles associated with that node. From this
* AABB bounding spheres are calculated for each leaf node, then
* a recursive postorder traversal builds bounding spheres for
* the internal nodes of the vertex tree.
*/
static void assignNodeBounds(vdsNode *root)
{
typedef struct {
vdsVec3 min, max;
} Box;
Box *boxes;
int i, j, k;
boxes = (Box *) malloc(vdsNumnodes * sizeof(Box));
for (i = 0; i < vdsNumnodes; i++) {
VEC3_COPY(boxes[i].min, nodearray[i].coord);
VEC3_COPY(boxes[i].max, nodearray[i].coord);
}
for (i = 0; i < vdsNumtris; i++) { /* iterate over tris */
vdsTri *t = &triarray[i];
vdsNode *c0 = &nodearray[t->corners[0].index];
vdsNode *c1 = &nodearray[t->corners[1].index];
vdsNode *c2 = &nodearray[t->corners[2].index];
for (j = 0; j < 3; j++) { /* iterate over corners of tri */
int cindex = t->corners[j].index;
vdsNode *corner = &nodearray[cindex];
/* Some effort wasted here testing each corner against itself: */
VEC3_FIND_MAX(boxes[cindex].max, boxes[cindex].max, c0->coord);
VEC3_FIND_MIN(boxes[cindex].min, boxes[cindex].min, c0->coord);
VEC3_FIND_MAX(boxes[cindex].max, boxes[cindex].max, c1->coord);
VEC3_FIND_MIN(boxes[cindex].min, boxes[cindex].min, c1->coord);
VEC3_FIND_MAX(boxes[cindex].max, boxes[cindex].max, c2->coord);
VEC3_FIND_MIN(boxes[cindex].min, boxes[cindex].min, c2->coord);
}
}
/* Calculate bounding spheres from leaf nodes' bounding boxes */
for (i = 0; i < vdsNumnodes; i++) {
vdsNode *N = &nodearray[i];
VEC3_AVERAGE(N->bound.center, boxes[i].min, boxes[i].max);
N->bound.radius = VEC3_DISTANCE(boxes[i].min, boxes[i].max) / 2.0;
}
free(boxes);
/* Recursively calculate internal node bounds from leaf bounds */
computeInternalBounds(root);
}
/** Finalize the VDS vertex tree.
* After all geometry has been added and all leaf nodes (created
@@ -717,19 +571,21 @@ static void assignNodeBounds(vdsNode *root)
vdsNode *vdsEndVertexTree()
{
vdsNode *root;
#ifdef VDS_DEBUGPRINT
vdsNodeId rootId = {0, 0};
#endif
vdsNodeId *ids;
int maxdepth;
int i, j;
int i;
assert(openflag == 1);
root = &nodearray[0];
while (root->parent != NULL) {
root = root->parent;
}
VDS_DEBUG(("Assigning node ids..."));
ids = (vdsNodeId *) calloc(vdsNumnodes, sizeof(vdsNodeId));
maxdepth = assignNodeIds(root, rootId, ids);
#ifdef VDS_DEBUGPRINT
int maxdepth = assignNodeIds(root, rootId, ids);
#endif
VDS_DEBUG(("Done.\n"));
VDS_DEBUG(("Verifying that all nodes form a single rooted tree..."));
verifyRootedTree(root);
@@ -752,17 +608,9 @@ vdsNode *vdsEndVertexTree()
c1 = T->corners[1].index;
c2 = T->corners[2].index;
assert(c0 < vdsNumnodes && c0 >= 0);
assert(c1 < vdsNumnodes && c1 >= 0);
assert(c2 < vdsNumnodes && c2 >= 0);
T->corners[0].id = ids[c0];
T->corners[1].id = ids[c1];
T->corners[2].id = ids[c2];
assert(! idEqual(T->corners[0].id, T->corners[1].id) &&
! idEqual(T->corners[1].id, T->corners[2].id) &&
! idEqual(T->corners[2].id, T->corners[0].id));
}
free(ids);
VDS_DEBUG(("Done.\n"));
@@ -770,7 +618,7 @@ vdsNode *vdsEndVertexTree()
computeSubtris(root);
VDS_DEBUG(("Done.\n"));
VDS_DEBUG(("Reallocating nodes and copying triangles into node->subtris "
"fields..."));
"fields..."));
root = moveTrisToNodes(root); /* Note: reallocates all nodes */
free(nodearray);
VDS_DEBUG(("Done.\n"));
@@ -779,8 +627,9 @@ vdsNode *vdsEndVertexTree()
free(triarray); /* nodearray still holds leaf nodes */
root->status = Boundary; /* root initially on boundary */
root->next = root->prev = root; /* root always on boundary path */
#ifdef VDS_DEBUGPRINT
VDS_DEBUG(("Done.\nVertex tree complete! Maximum depth = %d\n", maxdepth));
#endif
openflag = 0;
return root;
}
@@ -809,13 +658,13 @@ vdsNode *vdsEndVertexTree()
The author of the vdslib software library may be contacted at:
US Mail: Dr. David Patrick Luebke
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Phone: (804)924-1021
Phone: (804)924-1021
EMail: luebke@cs.virginia.edu
EMail: luebke@cs.virginia.edu
\*****************************************************************************/
/*
@@ -847,11 +696,9 @@ vdsNode *vdsClusterOctree(vdsNode **nodes, int nnodes, int depth)
int i, j;
vdsVec3 min, max, center, average = {0, 0, 0};
assert(depth < VDS_MAXDEPTH);
/* Overestimate array size needs for childnodes now; shrink later */
for (i = 0; i < 8; i++) {
childnodes[i] = (vdsNode **) malloc(sizeof(vdsNode *) * nnodes);
assert(childnodes[i] != NULL);
}
/* Find the min and max bounds of nodes, and accumulate average coord */
VEC3_COPY(min, nodes[0]->coord);
@@ -897,7 +744,7 @@ vdsNode *vdsClusterOctree(vdsNode **nodes, int nnodes, int depth)
/* Resize childnodes arrays to use only as much space as necessary */
for (i = 0; i < 8; i++) {
childnodes[i] = (vdsNode **)
realloc(childnodes[i], sizeof(vdsNode *) * nchildnodes[i]);
realloc(childnodes[i], sizeof(vdsNode *) * nchildnodes[i]);
}
/* Recurse or store non-empty children */
for (i = 0; i < 8; i++) {
@@ -914,7 +761,7 @@ vdsNode *vdsClusterOctree(vdsNode **nodes, int nnodes, int depth)
}
/* Finally, cluster nonempty children; this node is the resulting parent */
thisnode = vdsClusterNodes(nchildren, children,
average[0], average[1], average[2]);
average[0], average[1], average[2]);
for (i = 0; i < 8; i++) {
if (nchildnodes[i]) {
free(childnodes[i]);
@@ -1057,16 +904,11 @@ void vdsFoldNode(vdsNode *node)
vdsTri *t;
int i;
assert(node->status == Active);
/* Activate node and deactivate children */
node->status = Boundary;
child = node->children;
assert(child != NULL);
prev = child->prev; /* Set prev to first child's prev */
while (child != NULL) {
assert(child->status == Boundary);
child->status = Inactive;
next = child->next; /* Set next to last child's next */
child = child->sibling; /* Advance to next child */
@@ -1103,8 +945,6 @@ void vdsUnfoldNode(vdsNode *node)
vdsTri *t;
int i;
assert(node->status == Boundary);
if (child == NULL) {
return; /* Node is a leaf, leave on boundary */
}
@@ -1117,7 +957,6 @@ void vdsUnfoldNode(vdsNode *node)
prev->next = child;
prev = child;
assert(child->status == Inactive);
child->status = Boundary;
child = child->sibling; /* Advance to next child */
}
@@ -1146,7 +985,6 @@ void vdsFoldSubtree(vdsNode *node)
{
vdsNode *child = node->children;
assert(node->status == Active);
while (child != NULL) {
if (child->status == Active) {
vdsFoldSubtree(child);
@@ -1172,7 +1010,6 @@ void vdsUnfoldAncestors(vdsNode *node)
{
vdsNode *parent = node->parent;
assert(node->status == Inactive);
if (parent != NULL) {
if (parent->status == Boundary) {
vdsUnfoldNode(parent);
@@ -1228,7 +1065,6 @@ void vdsAdjustTreeBoundary(vdsNode *root, vdsFoldCriterion foldtest, void *udata
current = current->children;
} else {
/* No folds or unfolds, move on to next node on the boundary */
assert(current->next != NULL);
current = current->next;
}
} while (current != root);
@@ -1293,13 +1129,13 @@ void vdsAdjustTreeTopDown(vdsNode *node, vdsFoldCriterion foldtest, void *udata)
The author of the vdslib software library may be contacted at:
US Mail: Dr. David Patrick Luebke
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Phone: (804)924-1021
Phone: (804)924-1021
EMail: luebke@cs.virginia.edu
EMail: luebke@cs.virginia.edu
\*****************************************************************************/
/**
@@ -1342,7 +1178,6 @@ static vdsNode *firstActiveAncestor(vdsNodeId id, vdsNode *proxy)
proxy = proxy->sibling;
whichchild --;
}
assert(proxy != NULL);
}
return proxy; /* proxy->status is now Boundary */
}
@@ -1389,7 +1224,7 @@ void vdsUpdateTriProxies(vdsTri *t)
* of a node. NULL if the node is to be assumed visible.
*/
void vdsRenderTree(vdsNode *node, vdsRenderFunction render,
vdsVisibilityFunction visible, void *udata)
vdsVisibilityFunction visible, void *udata)
{
vdsNode *child;
@@ -1440,13 +1275,13 @@ void vdsRenderTree(vdsNode *node, vdsRenderFunction render,
The author of the vdslib software library may be contacted at:
US Mail: Dr. David Patrick Luebke
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Phone: (804)924-1021
Phone: (804)924-1021
EMail: luebke@cs.virginia.edu
EMail: luebke@cs.virginia.edu
\*****************************************************************************/
/**
@@ -1475,7 +1310,6 @@ vdsNode *vdsFindNode(vdsNodeId id, vdsNode *root)
tmp = tmp->children;
while (whichchild > 0) {
assert(tmp != NULL);
tmp = tmp->sibling;
--whichchild;
}
@@ -1503,7 +1337,6 @@ vdsNodeId vdsFindCommonId(vdsNodeId id1, vdsNodeId id2, int maxdepth)
maxcommondepth = (id1.depth < id2.depth) ? id1.depth : id2.depth;
maxcommondepth = (maxdepth < maxcommondepth) ? maxdepth : maxcommondepth;
assert(maxcommondepth <= VDS_MAXDEPTH);
common.depth = 0;
for (i = 0; i < maxcommondepth; i++) {
@@ -1577,28 +1410,6 @@ void vdsPrintNodeId(const vdsNodeId *id)
}
}
/** Print a vdsNodeID to a string.
* Prints the node ID (depth & path down the vertex tree) in
* human-readable form to the given string <b>str</b>. The caller
* must ensure that <b>str</b> points to VDS_MAXDEPTH+1 allocated
* bytes. The returned <b>str</b> is null-terminated.
*/
void vdsSprintNodeId(char *str, const vdsNodeId *id)
{
int i;
vdsNodePath tmppath = id->path;
if (id->depth == 0) {
strcpy(str, "<root>");
} else {
for (i = 0; i < id->depth; i++) {
str[i] = (tmppath & VDS_BITMASK) + '0';
tmppath >>= VDS_NUMBITS;
}
str[i] = '\0';
}
}
/** Gather statistics for a vertex tree.
* Recursively counts the number of nodes, the number of
* leaf nodes (i.e., vertices from the original model), and the
@@ -1695,13 +1506,13 @@ void vdsFreeTree(vdsNode *node)
The author of the vdslib software library may be contacted at:
US Mail: Dr. David Patrick Luebke
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Phone: (804)924-1021
Phone: (804)924-1021
EMail: luebke@cs.virginia.edu
EMail: luebke@cs.virginia.edu
\*****************************************************************************/
/**
@@ -1739,16 +1550,15 @@ vdsNode *vdsReadTree(FILE *f, vdsNodeDataReader readdata)
{
int major, minor;
int numnodes, numverts, numtris;
vdsNode *root, *currentnode, *lastnode, *parent;
vdsNode *root;
assert(f != NULL);
if (fscanf(f, "VDS Vertex Tree file format version %d.%d\n",
&major, &minor) != 2) {
&major, &minor) != 2) {
fprintf(stderr, "Error reading line 1 of input file.\n");
exit(1);
}
if (fscanf(f, "Total nodes: %d\nVertices: %d\nTriangles: %d\n",
&numnodes, &numverts, &numtris) != 3) {
&numnodes, &numverts, &numtris) != 3) {
fprintf(stderr, "Error reading lines 2-4 of input file.\n");
exit(1);
}
@@ -1774,7 +1584,6 @@ static vdsNode *readChildren(FILE *f, vdsNode *parent, vdsNodeDataReader get)
{
vdsNode *node, *firstnode;
assert(parent != NULL);
firstnode = readNode(f, get);
node = firstnode;
while (node != NULL) {
@@ -1808,12 +1617,10 @@ static vdsNode *readNode(FILE *f, vdsNodeDataReader getdata)
int numchildren, numsubtris;
node = (vdsNode *) calloc(1, sizeof(vdsNode));
assert(node != NULL);
node->status = Inactive;
fread(&node->bound, sizeof(vdsBoundingVolume), 1, f);
fread(&node->coord, sizeof(vdsVec3), 1, f);
fread(&numchildren, sizeof(numchildren), 1, f);
assert(numchildren <= VDS_MAXDEGREE);
/* if numchildren is 0, set node->children NULL, otherwise to non-NULL */
node->children = (numchildren == 0 ? NULL : (vdsNode *) 0x1);
/* Read sibling pointer (actually we just care if it's NULL or not) */
@@ -1828,7 +1635,7 @@ static vdsNode *readNode(FILE *f, vdsNodeDataReader getdata)
fread(&numsubtris, sizeof(numsubtris), 1, f);
node->nsubtris = numsubtris;
node = (vdsNode *) realloc(node, sizeof(vdsNode) +
numsubtris * sizeof(vdsTri));
numsubtris * sizeof(vdsTri));
fread(&node->subtris[0], sizeof(vdsTri), numsubtris, f);
/* Now get the associated node data if user has provided a function */
if (getdata == NULL) {
@@ -1854,9 +1661,7 @@ static vdsNode *readNode(FILE *f, vdsNodeDataReader getdata)
void vdsWriteTree(FILE *f, vdsNode *root, vdsNodeDataWriter writedata)
{
int numnodes, numverts, numtris;
vdsNode *child;
assert(f != NULL);
fprintf(f, "VDS Vertex Tree file format version %d.%d\n", MAJOR, MINOR);
vdsStatTree(root, &numnodes, &numverts, &numtris);
fprintf(f, "Total nodes: %d\n", numnodes);
@@ -1900,7 +1705,7 @@ static void writeChildren(FILE *f, vdsNode *parent, vdsNodeDataWriter put)
static void writeNode(FILE *f, vdsNode *node, vdsNodeDataWriter putdata)
{
vdsNode *child;
int i, numchildren = 0, numsubtris = node->nsubtris;
int numchildren = 0, numsubtris = node->nsubtris;
fwrite(&node->bound, sizeof(vdsBoundingVolume), 1, f);
fwrite(&node->coord, sizeof(vdsVec3), 1, f);
@@ -1909,7 +1714,6 @@ static void writeNode(FILE *f, vdsNode *node, vdsNodeDataWriter putdata)
numchildren ++;
child = child->sibling;
}
assert(numchildren <= VDS_MAXDEGREE);
fwrite(&numchildren, sizeof(numchildren), 1, f);
/* Write the sibling pointer (actually we just care if it's NULL or not) */
fwrite(&node->sibling, sizeof(node->sibling), 1, f);
@@ -1925,34 +1729,13 @@ static void writeNode(FILE *f, vdsNode *node, vdsNodeDataWriter putdata)
}
/*@}*/
/***************************************************************************\
Copyright 1999 The University of Virginia.
All Rights Reserved.
Permission to use, copy, modify and distribute this software and its
documentation without fee, and without a written agreement, is
hereby granted, provided that the above copyright notice and the
complete text of this comment appear in all copies, and provided that
the University of Virginia and the original authors are credited in
any publications arising from the use of this software.
IN NO EVENT SHALL THE UNIVERSITY OF VIRGINIA OR THE AUTHOR OF THIS
SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE
UNIVERSITY OF VIRGINIA AND/OR THE AUTHOR OF THIS SOFTWARE HAVE BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
The author of the vdslib software library may be contacted at:
US Mail: Dr. David Patrick Luebke
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Phone: (804)924-1021
EMail: luebke@cs.virginia.edu
\*****************************************************************************/
/*
* Local Variables:
* tab-width: 8
* mode: C
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
+73 -90
View File
@@ -1,3 +1,36 @@
/***************************************************************************\
Copyright 1999 The University of Virginia.
All Rights Reserved.
Permission to use, copy, modify and distribute this software and its
documentation without fee, and without a written agreement, is
hereby granted, provided that the above copyright notice and the
complete text of this comment appear in all copies, and provided that
the University of Virginia and the original authors are credited in
any publications arising from the use of this software.
IN NO EVENT SHALL THE UNIVERSITY OF VIRGINIA
OR THE AUTHOR OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE UNIVERSITY OF VIRGINIA AND/OR THE
AUTHOR OF THIS SOFTWARE HAVE BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
The author of the vdslib software library may be contacted at:
US Mail: Dr. David Patrick Luebke
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Phone: (804)924-1021
EMail: luebke@cs.virginia.edu
\*****************************************************************************/
/**
* Note: This is just an unofficial overview of the basics of what libvds
* is/does and how to use it. It is not guaranteed to be complete or accurate!
@@ -72,30 +105,6 @@
#ifndef _VDS_H
#define _VDS_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
# define COMPILER_DLLEXPORT __declspec(dllexport)
# define COMPILER_DLLIMPORT __declspec(dllimport)
#else
# define COMPILER_DLLEXPORT __attribute__ ((visibility ("default")))
# define COMPILER_DLLIMPORT __attribute__ ((visibility ("default")))
#endif
#ifndef VDS_EXPORT
# if defined(VDS_DLL_EXPORTS) && defined(VDS_DLL_IMPORTS)
# error "Only VDS_DLL_EXPORTS or VDS_DLL_IMPORTS can be defined, not both."
# elif defined(VDS_DLL_EXPORTS)
# define VDS_EXPORT COMPILER_DLLEXPORT
# elif defined(VDS_DLL_IMPORTS)
# define VDS_EXPORT COMPILER_DLLIMPORT
# else
# define VDS_EXPORT
# endif
#endif
#include <stdio.h>
/** VDS_MAXDEGREE defines the maximum degree of vertex tree nodes */
@@ -177,9 +186,9 @@ typedef union {
*/
typedef struct _vdsTri {
vdsTriCorner corners[3]; /* leaf nodes corresponding to *
* 3 original corner vertices */
* 3 original corner vertices */
struct _vdsNode *proxies[3]; /* nodes representing corners; *
* i.e., the FAA of each corner */
* i.e., the FAA of each corner */
struct _vdsNode *node; /* smallest node containing tri */
vdsVec3 normal[3]; /* normal for the tri */
vdsByte3 color[3]; /* RGB for the tri's corners */
@@ -199,10 +208,10 @@ typedef struct _vdsNode {
vdsNodeStatus status; /* is node currently active? */
vdsBoundingVolume bound; /* bounding volume of triangles *
* supported by the node */
* supported by the node */
vdsVec3 coord; /* coordinate of node's proxy */
vdsTri *vistris; /* linked list of visible tris *
* contained by this node */
* contained by this node */
vdsNodeData data; /* auxiliary node data */
struct _vdsNode *next; /* next node in boundary path */
struct _vdsNode *prev; /* prev node in boundary path */
@@ -241,44 +250,44 @@ typedef vdsNodeData (*vdsNodeDataReader) (FILE *f);
*/
/* Routines for maintaining the vertex tree (dynamic.c) */
VDS_EXPORT extern void vdsAdjustTreeBoundary(vdsNode *, vdsFoldCriterion, void *);
VDS_EXPORT extern void vdsAdjustTreeTopDown(vdsNode *, vdsFoldCriterion, void *);
extern void vdsAdjustTreeBoundary(vdsNode *, vdsFoldCriterion, void *);
extern void vdsAdjustTreeTopDown(vdsNode *, vdsFoldCriterion, void *);
/* Low-level vertex tree maintainance routines; not need by most users: */
VDS_EXPORT extern void vdsFoldNode(vdsNode *);
VDS_EXPORT extern void vdsUnfoldNode(vdsNode *);
VDS_EXPORT extern void vdsFoldSubtree(vdsNode *);
extern void vdsFoldNode(vdsNode *);
extern void vdsUnfoldNode(vdsNode *);
extern void vdsFoldSubtree(vdsNode *);
/* Routines for rendering the vertex tree (render.c) */
VDS_EXPORT extern void vdsUpdateTriProxies(vdsTri *t);
VDS_EXPORT extern void vdsRenderTree(vdsNode *node, vdsRenderFunction render,
vdsVisibilityFunction visible, void *udata);
extern void vdsUpdateTriProxies(vdsTri *t);
extern void vdsRenderTree(vdsNode *node, vdsRenderFunction render,
vdsVisibilityFunction visible, void *udata);
/* Routines for building the vertex tree (build.c) */
VDS_EXPORT extern void vdsBeginVertexTree();
VDS_EXPORT extern void vdsBeginGeometry();
VDS_EXPORT extern vdsNode *vdsAddNode(vdsFloat x, vdsFloat y, vdsFloat z);
VDS_EXPORT extern vdsTri *vdsAddTri(int v0, int v1, int v2,
vdsVec3 n0, vdsVec3 n1, vdsVec3 n2,
vdsByte3 c0, vdsByte3 c1, vdsByte3 c2);
VDS_EXPORT extern void vdsNewObject();
VDS_EXPORT extern vdsNode *vdsEndGeometry();
VDS_EXPORT extern vdsNode *vdsClusterNodes(int nnodes, vdsNode **nodes,
vdsFloat x, vdsFloat y, vdsFloat z);
VDS_EXPORT extern vdsNode *vdsEndVertexTree();
extern void vdsBeginVertexTree();
extern void vdsBeginGeometry();
extern vdsNode *vdsAddNode(vdsFloat x, vdsFloat y, vdsFloat z);
extern vdsTri *vdsAddTri(int v0, int v1, int v2,
vdsVec3 n0, vdsVec3 n1, vdsVec3 n2,
vdsByte3 c0, vdsByte3 c1, vdsByte3 c2);
extern void vdsNewObject();
extern vdsNode *vdsEndGeometry();
extern vdsNode *vdsClusterNodes(int nnodes, vdsNode **nodes,
vdsFloat x, vdsFloat y, vdsFloat z);
extern vdsNode *vdsEndVertexTree();
/* Routines for reading and writing the vertex tree (file.c) */
VDS_EXPORT extern vdsNode *vdsReadTree(FILE *f, vdsNodeDataReader readdata);
VDS_EXPORT extern void vdsWriteTree(FILE *f, vdsNode *root, vdsNodeDataWriter writedata);
extern vdsNode *vdsReadTree(FILE *f, vdsNodeDataReader readdata);
extern void vdsWriteTree(FILE *f, vdsNode *root, vdsNodeDataWriter writedata);
/* Assorted useful routines (util.c) */
VDS_EXPORT extern vdsNode *vdsFindNode(vdsNodeId id, vdsNode *root);
VDS_EXPORT extern void vdsPrintNodeId(const vdsNodeId *id);
VDS_EXPORT extern void vdsSprintNodeId(char *str, const vdsNodeId *id);
VDS_EXPORT extern void vdsStatTree(vdsNode *root, int *nodes, int *leaves, int *tris);
VDS_EXPORT extern void vdsFreeTree(vdsNode *node);
extern vdsNode *vdsFindNode(vdsNodeId id, vdsNode *root);
extern void vdsPrintNodeId(const vdsNodeId *id);
extern void vdsSprintNodeId(char *str, const vdsNodeId *id);
extern void vdsStatTree(vdsNode *root, int *nodes, int *leaves, int *tris);
extern void vdsFreeTree(vdsNode *node);
/* (cluster.c) */
VDS_EXPORT extern vdsNode *vdsClusterOctree(vdsNode **nodes, int nnodes, int depth);
extern vdsNode *vdsClusterOctree(vdsNode **nodes, int nnodes, int depth);
/*
* The following macros relate to the maximum degree of the vertex tree,
@@ -312,42 +321,16 @@ VDS_EXPORT extern vdsNode *vdsClusterOctree(vdsNode **nodes, int nnodes, int dep
# error "Only values of 2, 4, and 8 supported for VDS_MAXDEGREE"
#endif
#ifdef __cplusplus
}
#endif
#endif /* _VDS_H */
/*@}*/
/***************************************************************************\
Copyright 1999 The University of Virginia.
All Rights Reserved.
Permission to use, copy, modify and distribute this software and its
documentation without fee, and without a written agreement, is
hereby granted, provided that the above copyright notice and the
complete text of this comment appear in all copies, and provided that
the University of Virginia and the original authors are credited in
any publications arising from the use of this software.
IN NO EVENT SHALL THE UNIVERSITY OF VIRGINIA
OR THE AUTHOR OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE UNIVERSITY OF VIRGINIA AND/OR THE
AUTHOR OF THIS SOFTWARE HAVE BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
The author of the vdslib software library may be contacted at:
US Mail: Dr. David Patrick Luebke
Department of Computer Science
Thornton Hall, University of Virginia
Charlottesville, VA 22903
Phone: (804)924-1021
EMail: luebke@cs.virginia.edu
\*****************************************************************************/
/*
* Local Variables:
* tab-width: 8
* mode: C
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
-19
View File
@@ -782,25 +782,6 @@ if(BRLCAD_ENABLE_GECODE)
endif(BRLCAD_GECODE_BUILD)
endif(BRLCAD_ENABLE_GECODE)
# VDSlib - A View-Dependent Simplification and Rendering Library For
# the moment, this is marked NOSYS - it's possible that some Debian
# systems would have 0.9 of vdslib installed, but it's unmaintained
# and we're likely to be making changes. If our own copy of VDSlib
# ever spins back off into its own project, revisit the NOSYS
set(libvds_DESCRIPTION "
Option for enabling and disabling compilation of the libvds triangle
simplification library provided with BRL-CAD's source code. Default
is AUTO, responsive to the toplevel BRLCAD_BUNDLED_LIBS option and
testing first for a system version if BRLCAD_BUNDLED_LIBS is also
AUTO.
")
THIRD_PARTY(libvds VDS vds libvds_DESCRIPTION ALIASES ENABLE_VDS FLAGS NOSYS)
set(LIBVDS_INCLUDE_DIR "${BRLCAD_SOURCE_DIR}/src/other/libvds" CACHE STRING "Directory containing libvds headers." FORCE)
mark_as_advanced(LIBVDS_INCLUDE_DIR)
SetTargetFolder(vds "Third Party Libraries")
SetTargetFolder(vds-static "Third Party Libraries")
# OpenSceneGraph Libraries
set(openscenegraph_DESCRIPTION "
Option for enabling and disabling compilation of the OpenSceneGraph
-7
View File
@@ -1,7 +0,0 @@
set(libvds_ignore_files
CMakeLists.txt
COPYING
README
vds.c
vds.h
)
-100
View File
@@ -1,100 +0,0 @@
##########################################################################
# Copyright 2011 United States Government as represented by the U.S.
# Army Research Laboratory.
#
# Copyright 1999 The University of Virginia.
# All Rights Reserved.
#
# Permission to use, copy, modify and distribute this software and its
# documentation without fee, and without a written agreement, is
# hereby granted, provided that the above copyright notice and the
# complete text of this comment appear in all copies, and provided that
# the University of Virginia and the original authors are credited in
# any publications arising from the use of this software.
#
# IN NO EVENT SHALL THE UNIVERSITY OF VIRGINIA OR ANY AUTHOR OF THIS
# SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
# ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
# IF THE UNIVERSITY OF VIRGINIA AND/OR THE AUTHOR OF THIS SOFTWARE
# HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#
##########################################################################
# This file contains the top level CMakeLists.txt logic for the
# BRL-CAD software package.
# Minimum required version of CMake
cmake_minimum_required(VERSION 3.1.3)
# set CMake project name
project(VDS)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if (NOT BIN_DIR)
set(BIN_DIR bin)
endif (NOT BIN_DIR)
if (NOT INCLUDE_DIR)
set(INCLUDE_DIR include)
endif (NOT INCLUDE_DIR)
if (NOT LIB_DIR)
set(LIB_DIR lib)
endif (NOT LIB_DIR)
if (NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif (NOT DEFINED BUILD_SHARED_LIBS)
if (NOT DEFINED BUILD_STATIC_LIBS)
set(BUILD_STATIC_LIBS OFF)
endif (NOT DEFINED BUILD_STATIC_LIBS)
include(CheckLibraryExists)
check_library_exists(m cos "" HAVE_M_LIBRARY)
if (HAVE_M_LIBRARY)
set(SYS_LIBS ${SYS_LIBS} m)
endif (HAVE_M_LIBRARY)
if (BUILD_SHARED_LIBS)
add_library(vds SHARED vds.c)
if (SYS_LIBS)
target_link_libraries(vds ${SYS_LIBS})
endif (SYS_LIBS)
if (MSVC)
set_property(TARGET vds APPEND PROPERTY COMPILE_DEFINITIONS "VDS_DLL_EXPORTS")
endif (MSVC)
install(TARGETS vds
RUNTIME DESTINATION ${BIN_DIR}
LIBRARY DESTINATION ${LIB_DIR}
ARCHIVE DESTINATION ${LIB_DIR})
endif (BUILD_SHARED_LIBS)
if (BUILD_STATIC_LIBS)
add_library(vds-static STATIC vds.c)
if (CMAKE_CL_64)
set_target_properties(vds-static PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
endif (CMAKE_CL_64)
if (MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(vds-static PROPERTIES PREFIX "lib")
else (MSVC)
set_target_properties(vds-static PROPERTIES OUTPUT_NAME "vds")
endif (MSVC)
install(TARGETS vds-static
RUNTIME DESTINATION ${BIN_DIR}
LIBRARY DESTINATION ${LIB_DIR}
ARCHIVE DESTINATION ${LIB_DIR})
endif (BUILD_STATIC_LIBS)
if (NOT SKIP_INSTALL_HEADERS)
install(FILES vds.h DESTINATION ${INCLUDE_DIR})
endif (NOT SKIP_INSTALL_HEADERS)
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8