├── tools ├── qslim │ ├── Makefile.dep │ ├── qvis_obj.sh │ ├── qslim_obj.sh │ ├── Makefile │ ├── qslim.cxx │ └── qslim.h ├── cluster │ ├── Makefile │ └── QCluster.txt └── filters │ ├── smfcat.cxx │ ├── cmdline.h │ ├── smf2flat.cxx │ ├── smf2ldmesh.cxx │ ├── smf2iv.cxx │ ├── smf2ply.cxx │ ├── smfclean.cxx │ ├── smfboundary.cxx │ ├── Makefile │ ├── smf2c.cxx │ ├── cmdline.cxx │ └── smfmeasure.cxx ├── libgfx ├── gfx-config.vc ├── doc │ ├── gui-layout.gif │ ├── gui-redbox.gif │ ├── mat3.html │ ├── mat2.html │ ├── vec2.html │ ├── license.html │ ├── cdoc.css │ ├── vec4.html │ ├── geom3d.html │ ├── vec3.html │ ├── index.html │ └── mat4.html ├── src │ ├── geom3d.cxx │ ├── geom4d.cxx │ ├── Makefile.vc │ ├── Makefile │ ├── symmat4.cxx │ ├── symmat3.cxx │ ├── baseball.cxx │ ├── mat3.cxx │ ├── mat2.cxx │ ├── time.cxx │ └── wintools.cxx ├── tests │ ├── test1.sc │ ├── Makefile.vc │ ├── Makefile │ ├── t-script.cxx │ ├── t-vec.cxx │ ├── t-glext.cxx │ └── t-img.cxx ├── configure.bat ├── include │ └── gfx │ │ ├── wintools.h │ │ ├── glext.h │ │ ├── mfc.h │ │ ├── gl.h │ │ ├── geom4d.h │ │ ├── trackball.h │ │ ├── gltools.h │ │ ├── arcball.h │ │ ├── baseball.h │ │ ├── array.h │ │ ├── config.h.in │ │ ├── config.h │ │ ├── gfx.h │ │ ├── config-vc.h │ │ ├── geom3d.h │ │ └── intvec.h ├── gfx-config.in ├── vc-config.in └── vc6 │ └── libgfx.dsw ├── mixkit ├── mix-config.in ├── configure.in ├── src │ ├── MxMat2.h │ ├── MxMath.h │ ├── MxBlock3.h │ ├── MxTimer.h │ ├── mixio.h │ ├── MxVec2.h │ ├── MxVec4.h │ ├── MxMat3.h │ ├── MxGUI.h │ ├── MxVec3.h │ ├── MxGLUtils.h │ ├── MxCamera.h │ ├── MxString.h │ ├── MxMat4.h │ ├── MxStdSlim.cxx │ ├── MxBlock2.h │ ├── MxCmdParser.h │ ├── MxCamera.cxx │ ├── MxGeom2D.h │ ├── MxManipulator.h │ ├── MxRaster.h │ ├── Makefile │ ├── MxFeatureFilter.h │ ├── MxEdgeFilter.h │ ├── MxGLDebug.cxx │ ├── MxStack.h │ ├── MxStdSlim.h │ ├── MxFrame.h │ ├── mixmsg.h │ ├── MxQMetric.h │ ├── mixcfg.h.in │ ├── MxMatrix.h │ ├── MxGeom3D.h │ ├── MxGeom2D.cxx │ ├── MxHeap.h │ ├── MxDualSlim.h │ ├── MxFitFrame.h │ ├── MxGLUtils.cxx │ ├── MxDynBlock.h │ ├── MxQMetric.cxx │ ├── stdmix.h │ ├── MxPropSlim.h │ ├── MxStdGUI.h │ ├── MxDualModel.h │ ├── MxFitFrame-vis.cxx │ ├── MxMatrix.cxx │ ├── MxGeom3D.cxx │ ├── MxSMF.h │ ├── MxCmdParser.cxx │ └── MxHeap.cxx ├── build │ ├── mkconf │ ├── mkconf-n32 │ ├── copywrite │ └── mix-config.in └── COPYING.txt ├── examples ├── Makefile ├── smfview.cxx ├── propvis.cxx └── propslim.cxx ├── COPYING.txt ├── .gitignore └── win32 └── SlimKit.dsw /tools/qslim/Makefile.dep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libgfx/gfx-config.vc: -------------------------------------------------------------------------------- 1 | vc: 2 | MAKEFLAGS=""; nmake /nologo /f Makefile.vc 3 | -------------------------------------------------------------------------------- /libgfx/doc/gui-layout.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/qslim/HEAD/libgfx/doc/gui-layout.gif -------------------------------------------------------------------------------- /libgfx/doc/gui-redbox.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/qslim/HEAD/libgfx/doc/gui-redbox.gif -------------------------------------------------------------------------------- /tools/qslim/qvis_obj.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep "^[vf] " $1 | \ 3 | sed -e "s/^f *\([0-9][0-9]*\)\/[^ ]* *\([0-9][0-9]*\)\/[^ ]* *\([0-9][0-9]*\)\/.*/f \1 \2 \3/g" | \ 4 | ./qvis -t 1000 - 5 | -------------------------------------------------------------------------------- /mixkit/mix-config.in: -------------------------------------------------------------------------------- 1 | MIX_ROOT = @MIX_ROOT@ 2 | LIBMIX = -lmix -lgfx 3 | 4 | include $(MIX_ROOT)/../libgfx/gfx-config 5 | 6 | CFLAGS += -I$(MIX_ROOT)/src 7 | CXXFLAGS += -I$(MIX_ROOT)/src 8 | LDFLAGS += -L$(MIX_ROOT)/src 9 | -------------------------------------------------------------------------------- /mixkit/configure.in: -------------------------------------------------------------------------------- 1 | dnl Process this file with 'autoconf' to produce a 'configure' script 2 | dnl $Id: configure.in,v 1.1 2000/11/20 20:37:04 garland Exp $ 3 | AC_REVISION($Revision: 1.1 $) 4 | AC_INIT(src/stdmix.h) 5 | 6 | MIX_ROOT=`pwd` 7 | AC_SUBST(MIX_ROOT) 8 | 9 | AC_OUTPUT(mix-config) 10 | -------------------------------------------------------------------------------- /tools/qslim/qslim_obj.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INPUT=$1 3 | OUTPUT=$2 4 | shift 5 | shift 6 | grep "^[vf] " $INPUT | \ 7 | sed -e "s/^f *\([0-9][0-9]*\)\/[^ ]* *\([0-9][0-9]*\)\/[^ ]* *\([0-9][0-9]*\)\/.*/f \1 \2 \3/g" | \ 8 | `dirname $0`/qslim $@ -M smf -o .qvis_obj.smf - 9 | cat .qvis_obj.smf | grep "^[vf]" > $OUTPUT 10 | -------------------------------------------------------------------------------- /libgfx/src/geom3d.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Handy 3D geometrical primitives 4 | 5 | $Id: geom3d.cxx,v 1.2 2001/03/02 03:56:43 garland Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | #include 11 | 12 | -------------------------------------------------------------------------------- /libgfx/src/geom4d.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Handy 4D geometrical primitives 4 | 5 | $Id: geom4d.cxx,v 1.1 2002/05/19 18:14:46 yuanzhou Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | #include 11 | 12 | -------------------------------------------------------------------------------- /tools/cluster/Makefile: -------------------------------------------------------------------------------- 1 | include ../../mixkit/mix-config 2 | 3 | SRCS = qcluster.cxx 4 | OBJS = $(SRCS:.cxx=.o) 5 | 6 | qcluster : qcluster.o ../../mixkit/src/libmix.a 7 | $(CXX) -o qcluster qcluster.o $(LDFLAGS) $(LIBMIX) -lm 8 | 9 | depend: 10 | $(CXX_DEPEND) $(SRCS) > Makefile.dep 11 | 12 | clean: 13 | -$(RM) -f qcluster $(OBJS) 14 | -cat /dev/null > Makefile.dep 15 | 16 | -include Makefile.dep 17 | -------------------------------------------------------------------------------- /libgfx/tests/test1.sc: -------------------------------------------------------------------------------- 1 | # This is a test script meant to be fed to t-script. It is not meant as an 2 | # exhaustive test, but mainly as a demonstration. 3 | # 4 | # $Id: test1.sc,v 1.1 2000/09/06 21:43:25 garland Exp $ 5 | # 6 | 7 | echo The following sum should be 15 8 | add 1 2 3 4 5 9 | 10 | echo 11 | echo The following average should be 3.5 12 | avg 3 8 2 1 13 | 14 | echo 15 | echo The following is the vector [1 0 0] 16 | vec3 1 0 0 17 | 18 | -------------------------------------------------------------------------------- /mixkit/src/MxMat2.h: -------------------------------------------------------------------------------- 1 | #ifndef MXMAT2_INCLUDED // -*- C++ -*- 2 | #define MXMAT2_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | 2x2 Matrix class 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxMat2.h,v 1.10 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | 19 | // MXMAT2_INCLUDED 20 | #endif 21 | -------------------------------------------------------------------------------- /libgfx/src/Makefile.vc: -------------------------------------------------------------------------------- 1 | include ../vc-config 2 | 3 | VEC_SRCS = mat2.cxx mat3.cxx mat4.cxx quat.cxx symmat3.cxx 4 | GEO_SRCS = geom3d.cxx 5 | IMG_SRCS = raster.cxx raster-pnm.cxx raster-tiff.cxx raster-jpeg.cxx \ 6 | raster-png.cxx 7 | MISC_SRCS = time.cxx script.cxx 8 | GUI_SRCS = gui.cxx gltools.cxx baseball.cxx trackball.cxx arcball.cxx 9 | 10 | SRCS = $(VEC_SRCS) $(GEO_SRCS) $(IMG_SRCS) $(MISC_SRCS) $(GUI_SRCS) 11 | OBJS = $(SRCS:.cxx=.obj) 12 | 13 | libgfx.lib: $(OBJS) 14 | lib /nologo /OUT:libgfx.lib $(OBJS) 15 | 16 | clean: 17 | del $(OBJS) libgfx.lib 18 | -------------------------------------------------------------------------------- /mixkit/src/MxMath.h: -------------------------------------------------------------------------------- 1 | #ifndef MXMATH_INCLUDED // -*- C++ -*- 2 | #define MXMATH_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Standard math include file for the MixKit library. 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxMath.h,v 1.17 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | 18 | // MXMATH_INCLUDED 19 | #endif 20 | -------------------------------------------------------------------------------- /libgfx/configure.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM This script writes an appropriate gfx-config file for VC++ 4 | REM development systems. At this point, the configuration process is 5 | REM trivial. Eventually, it would probably be good to actually look at 6 | REM the state of the machine. 7 | 8 | set LOCAL=c:\usr\local 9 | if NOT "%1"=="" set LOCAL=%1 10 | 11 | echo LIBGFX = \> gfxloc 12 | chdir >> gfxloc 13 | 14 | echo LOCAL = %LOCAL% >> gfxloc 15 | rem echo e:\local >> gfxloc 16 | 17 | copy gfxloc+vc-config.in vc-config 18 | del gfxloc 19 | 20 | copy gfx-config.vc gfx-config 21 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | include ../mixkit/mix-config 2 | 3 | PROGS = propslim 4 | GUI_PROGS = smfview propvis 5 | 6 | all: $(PROGS) $(GUI_PROGS) 7 | 8 | propslim: propslim.o ../mixkit/src/libmix.a 9 | $(CXX) -o propslim propslim.o $(LDFLAGS) $(LIBMIX) -lm 10 | 11 | smfview : smfview.o ../mixkit/src/libmix.a 12 | $(CXX) -o smfview smfview.o $(LDFLAGS) $(LIBMIX) $(GUI_LIBS) -lm 13 | $(FLTKCONFIG) --post smfview 14 | 15 | propvis : propvis.o ../mixkit/src/libmix.a 16 | $(CXX) -o propvis propvis.o $(LDFLAGS) $(LIBMIX) $(GUI_LIBS) -lm 17 | $(FLTKCONFIG) --post propvis 18 | 19 | -include Makefile.dep 20 | -------------------------------------------------------------------------------- /mixkit/src/MxBlock3.h: -------------------------------------------------------------------------------- 1 | #ifndef MXBLOCK3_INCLUDED // -*- C++ -*- 2 | #define MXBLOCK3_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxBlock3 provides typed access to 3D data blocks. 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxBlock3.h,v 1.6 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxBlock.h" 18 | 19 | // MXBLOCK3_INCLUDED 20 | #endif 21 | -------------------------------------------------------------------------------- /mixkit/build/mkconf: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | CC=cc 4 | CXX=CC 5 | export CC 6 | export CXX 7 | 8 | CFLAGS="-O2" 9 | CXXFLAGS="-O2" 10 | SITE_CFLAGS="-fullwarn -mips2 -xansi" 11 | SITE_CXXFLAGS="-MDupdate Makefile.dep ${SITE_CFLAGS}" 12 | SITE_LDFLAGS="-mips2" 13 | 14 | export CFLAGS 15 | export CXXFLAGS 16 | export SITE_CFLAGS 17 | export SITE_CXXFLAGS 18 | export SITE_LDFLAGS 19 | 20 | XF="--with-xformslib=${LOCAL}/lib --with-xformsincl=${LOCAL}/include" 21 | 22 | # Don't use Facilities's X libraries! 23 | X="--x-includes=/usr/include --x-libraries=/usr/lib" 24 | 25 | ./configure $X $XF --enable-safety=0 $* 26 | -------------------------------------------------------------------------------- /mixkit/src/MxTimer.h: -------------------------------------------------------------------------------- 1 | #ifndef MXTIMER_INCLUDED // -*- C++ -*- 2 | #define MXTIMER_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxTimer 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxTimer.h,v 1.4.8.1 2002/01/31 18:38:37 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #define MXTIME(t, cmd) { t=get_cpu_time(); cmd; t=get_cpu_time() - t; } 18 | 19 | // MXTIMER_INCLUDED 20 | #endif 21 | -------------------------------------------------------------------------------- /libgfx/include/gfx/wintools.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXWINTOOLS_INCLUDED // -*- C++ -*- 2 | #define GFXWINTOOLS_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Support code for handling various tasks under Win32 10 | 11 | $Id: wintools.h,v 1.1 2002/03/19 20:46:55 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include 16 | 17 | extern HGLRC create_glcontext(HDC dc); 18 | extern int set_pixel_format(HDC dc); 19 | 20 | // GFXWINTOOLS_INCLUDED 21 | #endif 22 | -------------------------------------------------------------------------------- /mixkit/src/mixio.h: -------------------------------------------------------------------------------- 1 | #ifndef MIXIO_INCLUDED // -*- C++ -*- 2 | #define MIXIO_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Standard IO header for MixKit programs. It deals with things like 10 | the unpleasantness of multiple IO packages in VC++. 11 | 12 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 13 | 14 | $Id: mixio.h,v 1.5 2000/11/27 19:18:36 garland Exp $ 15 | 16 | ************************************************************************/ 17 | 18 | #include 19 | 20 | // MIXIO_INCLUDED 21 | #endif 22 | -------------------------------------------------------------------------------- /mixkit/src/MxVec2.h: -------------------------------------------------------------------------------- 1 | #ifndef MXVEC2_INCLUDED // -*- C++ -*- 2 | #define MXVEC2_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | 2D Vector class 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxVec2.h,v 1.11 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | 19 | #ifdef MXGL_INCLUDED 20 | inline void glV(const Vec2& v) { glVertex2d(v[X], v[Y]); } 21 | #endif 22 | 23 | // MXVEC2_INCLUDED 24 | #endif 25 | -------------------------------------------------------------------------------- /examples/smfview.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | SMFView 4 | 5 | This is a simple example program which will display an SMF model and 6 | allow the user to interact with it. It can also be used as a simple 7 | prototype for writing more complex interactive programs. 8 | 9 | $Id: smfview.cxx,v 1.7 2000/02/11 19:41:29 garland Exp $ 10 | 11 | ************************************************************************/ 12 | 13 | #include 14 | #include 15 | 16 | MxStdGUI gui; 17 | 18 | main(int argc, char **argv) 19 | { 20 | gui.initialize(argc, argv); 21 | return gui.run(); 22 | } 23 | -------------------------------------------------------------------------------- /libgfx/src/Makefile: -------------------------------------------------------------------------------- 1 | include ../gfx-config 2 | 3 | VEC_SRCS = mat2.cxx mat3.cxx mat4.cxx quat.cxx symmat3.cxx 4 | GEO_SRCS = geom3d.cxx 5 | IMG_SRCS = raster.cxx raster-pnm.cxx raster-tiff.cxx raster-jpeg.cxx \ 6 | raster-png.cxx 7 | MISC_SRCS = time.cxx script.cxx 8 | GUI_SRCS = gui.cxx gltools.cxx baseball.cxx trackball.cxx arcball.cxx 9 | 10 | SRCS = $(VEC_SRCS) $(GEO_SRCS) $(IMG_SRCS) $(MISC_SRCS) $(GUI_SRCS) 11 | OBJS = $(SRCS:.cxx=.o) 12 | 13 | libgfx.a: $(OBJS) 14 | $(AR) cru libgfx.a $(OBJS) 15 | $(RANLIB) libgfx.a 16 | 17 | tags: $(SRCS) ../include/gfx/*.h 18 | ctags $(SRCS) ../include/gfx/*.h 19 | 20 | clean: 21 | -$(RM) $(OBJS) libgfx.a 22 | 23 | depend: 24 | $(CXX_DEPEND) $(SRCS) > Makefile.dep 25 | 26 | -include Makefile.dep 27 | -------------------------------------------------------------------------------- /mixkit/src/MxVec4.h: -------------------------------------------------------------------------------- 1 | #ifndef MXVEC4_INCLUDED // -*- C++ -*- 2 | #define MXVEC4_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | 4D Vector class 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxVec4.h,v 1.11 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | 19 | #ifdef MXGL_INCLUDED 20 | inline void glV(const Vec4& v) { glVertex4d(v[X], v[Y], v[Z], v[W]); } 21 | inline void glC(const Vec4& v) { glColor4d(v[X], v[Y], v[Z], v[W]); } 22 | #endif 23 | 24 | // MXVEC4_INCLUDED 25 | #endif 26 | -------------------------------------------------------------------------------- /tools/qslim/Makefile: -------------------------------------------------------------------------------- 1 | include ../../mixkit/mix-config 2 | 3 | SRCS = cmdline.cxx main.cxx output.cxx qslim.cxx 4 | QVIS_SRCS = cmdline.cxx main.cxx output.cxx qvis.cxx 5 | OBJS = $(SRCS:.cxx=.o) 6 | QVIS_OBJS = $(QVIS_SRCS:.cxx=.o) 7 | 8 | all: qslim qvis 9 | 10 | qslim : $(OBJS) ../../mixkit/src/libmix.a 11 | $(CXX) -o qslim $(OBJS) $(LDFLAGS) $(LIBMIX) -lm -lfltk_gl 12 | # Alec ^ 13 | 14 | qvis : $(QVIS_OBJS) ../../mixkit/src/libmix.a 15 | $(CXX) -o qvis $(QVIS_OBJS) $(LDFLAGS) $(LIBMIX) $(GUI_LIBS) -lm -lfltk_gl 16 | # Alec ^ 17 | $(FLTKCONFIG) --post qvis 18 | 19 | clean: 20 | -$(RM) -f $(OBJS) qslim qvis 21 | -cat /dev/null > Makefile.dep 22 | 23 | 24 | depend: 25 | $(CXX_DEPEND) $(SRCS) $(QVIS_SRCS) > Makefile.dep 26 | 27 | -include Makefile.dep 28 | -------------------------------------------------------------------------------- /libgfx/include/gfx/glext.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXGLEXT_INCLUDED // -*- C++ -*- 2 | #define GFXGLEXT_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Include the standard OpenGL Extension headers, if available. 10 | 11 | $Id: glext.h,v 1.1 2001/10/15 16:57:23 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include "gl.h" 16 | 17 | #if defined(HAVE_GL_GLEXT_H) 18 | # include 19 | #endif 20 | 21 | #if defined(HAVE_GL_GLXEXT_H) 22 | # include 23 | #endif 24 | 25 | #if defined(HAVE_GL_WGLEXT_H) 26 | # include 27 | #endif 28 | 29 | // GFXGLEXT_INCLUDED 30 | #endif 31 | -------------------------------------------------------------------------------- /libgfx/include/gfx/mfc.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXMFC_INCLUDED // -*- C++ -*- 2 | #define GFXMFC_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Support code for using MFC. At the moment, this just makes sure that 10 | we include the right headers. 11 | 12 | $Id: mfc.h,v 1.1 2002/03/19 20:46:55 garland Exp $ 13 | 14 | ************************************************************************/ 15 | 16 | #ifndef _MBCS 17 | #define _MBCS 18 | #endif 19 | 20 | #ifndef _AFXDLL 21 | #define _AFXDLL 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | #include "wintools.h" 28 | 29 | // GFXMFC_INCLUDED 30 | #endif 31 | -------------------------------------------------------------------------------- /mixkit/src/MxMat3.h: -------------------------------------------------------------------------------- 1 | #ifndef MXMAT3_INCLUDED // -*- C++ -*- 2 | #define MXMAT3_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | 3x3 Matrix class 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxMat3.h,v 1.11 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | 19 | extern bool jacobi(const Mat3& m, Vec3& vals, Vec3 vecs[3]); 20 | extern bool jacobi(const Mat3& m, double *vals, double *vecs); 21 | 22 | extern bool fast_jacobi(const Mat3& m, Vec3& vals, Vec3 vecs[3]); 23 | 24 | // MXMAT3_INCLUDED 25 | #endif 26 | -------------------------------------------------------------------------------- /mixkit/src/MxGUI.h: -------------------------------------------------------------------------------- 1 | #ifndef MXGUI_INCLUDED // -*- C++ -*- 2 | #define MXGUI_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | The MxGUI package implements a baseline GUI framework for use in 10 | MixKit-based applications. Only a very specific kind of interface 11 | is supported: one where the application window consists primarily of 12 | an OpenGL drawing canvas. 13 | 14 | Copyright (C) 1999 Michael Garland. See "COPYING.txt" for details. 15 | 16 | $Id: MxGUI.h,v 1.8 2000/11/20 20:36:38 garland Exp $ 17 | 18 | ************************************************************************/ 19 | 20 | #include 21 | 22 | // MXGUI_INCLUDED 23 | #endif 24 | -------------------------------------------------------------------------------- /mixkit/src/MxVec3.h: -------------------------------------------------------------------------------- 1 | #ifndef MXVEC3_INCLUDED // -*- C++ -*- 2 | #define MXVEC3_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | 3D Vector class 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxVec3.h,v 1.10 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | 19 | #ifdef MXGL_INCLUDED 20 | inline void glV(const Vec3& v) { glVertex3d(v[X], v[Y], v[Z]); } 21 | inline void glN(const Vec3& v) { glNormal3d(v[X], v[Y], v[Z]); } 22 | inline void glC(const Vec3& v) { glColor3d(v[X], v[Y], v[Z]); } 23 | #endif 24 | 25 | 26 | // MXVEC3_INCLUDED 27 | #endif 28 | -------------------------------------------------------------------------------- /libgfx/tests/Makefile.vc: -------------------------------------------------------------------------------- 1 | include ../vc-config 2 | 3 | SRCS = t-vec.cxx t-img.cxx t-gui.cxx t-glimg.cxx t-script.cxx 4 | OBJS = $(SRCS:.cxx=.obj) 5 | ALL = $(SRCS:.cxx=.exe) 6 | 7 | all: $(ALL) 8 | 9 | t-vec.exe: t-vec.obj 10 | $(LINK) /out:"t-vec.exe" t-vec.obj $(LDFLAGS) libgfx.lib 11 | 12 | t-script.exe: t-script.obj 13 | $(LINK) /out:"t-script.exe" t-script.obj $(LDFLAGS) libgfx.lib 14 | 15 | t-img.exe: t-img.obj 16 | $(LINK) /out:"t-img.exe" t-img.obj $(LDFLAGS) libgfx.lib $(IMG_LIBS) 17 | 18 | t-gui.exe: t-gui.obj 19 | $(LINK) /out:"t-gui.exe" t-gui.obj $(LDFLAGS) libgfx.lib $(GUI_LIBS) $(IMG_LIBS) 20 | 21 | t-glimg.exe: t-glimg.obj 22 | $(LINK) /out:"t-glimg.exe" t-glimg.obj $(LDFLAGS) libgfx.lib $(GUI_LIBS) $(IMG_LIBS) 23 | 24 | $(ALL): ../src/libgfx.lib 25 | 26 | clean: 27 | del $(ALL) $(OBJS) 28 | -------------------------------------------------------------------------------- /tools/filters/smfcat.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smfcat 4 | 5 | This is a particularly simple filter, much like the Unix "cat" filter. 6 | It reads all the specified inputs, concatenates them into a single 7 | model, and outputs the results in a canonical form. 8 | 9 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 10 | 11 | $Id: smfcat.cxx,v 1.2 1998/04/20 16:13:30 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include 16 | #include "cmdline.h" 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | MxStdModel *m = process_cmdline(argc, argv); 21 | if( !m ) return 0; 22 | 23 | output_final_model(m); 24 | delete m; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /mixkit/build/mkconf-n32: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | if test -z "$LOCAL"; then 4 | LOCAL=$HOME 5 | fi 6 | 7 | CC="cc -n32" 8 | CXX="CC -n32" 9 | export CC 10 | export CXX 11 | 12 | 13 | CFLAGS="-O2" 14 | CXXFLAGS="-O2" 15 | # -fullwarn with this compiler gets us a *load* of notes 16 | SITE_CFLAGS="-mips3 -xansi" 17 | SITE_CXXFLAGS="-MDupdate Makefile.dep ${SITE_CFLAGS}" 18 | SITE_LDFLAGS="-mips3" 19 | 20 | # Must use mips3 instead of mips4 to maintain support of R4K-series boxes 21 | 22 | export CFLAGS 23 | export CXXFLAGS 24 | export SITE_CFLAGS 25 | export SITE_CXXFLAGS 26 | export SITE_LDFLAGS 27 | 28 | XF="--with-xformslib=${LOCAL}/lib32 --with-xformsincl=${LOCAL}/include" 29 | 30 | # Don't use Facilities's X libraries! 31 | X="--x-includes=/usr/include --x-libraries=/usr/lib32" 32 | 33 | ./configure $X $XF --enable-safety=0 $* 34 | -------------------------------------------------------------------------------- /mixkit/src/MxGLUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef MXGLUTILS_INCLUDED // -*- C++ -*- 2 | #define MXGLUTILS_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxGLUtils 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxGLUtils.h,v 1.3 1999/12/08 17:18:15 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxGL.h" 18 | 19 | extern GLenum mxgl_matrix_for_mode(GLenum mode); 20 | 21 | extern int mxgl_unproject_pixel(int *pixel, double *world, double z=0.0); 22 | 23 | extern void mxgl_begin_pick(int *where, double rad, GLuint *buffer, int size); 24 | extern unsigned int mxgl_complete_pick(GLuint *buffer); 25 | 26 | // MXGLUTILS_INCLUDED 27 | #endif 28 | -------------------------------------------------------------------------------- /libgfx/include/gfx/gl.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXGL_INCLUDED // -*- C++ -*- 2 | #define GFXGL_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Include standard OpenGL headers. This process is complicated by the 10 | fact that the Win32 OpenGL headers require that be 11 | included before they are. 12 | 13 | $Id: gl.h,v 1.3 2002/01/24 17:43:59 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "gfx.h" 18 | 19 | #if defined(WIN32) 20 | # include 21 | #endif 22 | 23 | #if defined(__APPLE__) 24 | # include 25 | # include 26 | #else 27 | # include 28 | # include 29 | #endif 30 | 31 | // GFXGL_INCLUDED 32 | #endif 33 | -------------------------------------------------------------------------------- /mixkit/src/MxCamera.h: -------------------------------------------------------------------------------- 1 | #ifndef MXCAMERA_INCLUDED // -*- C++ -*- 2 | #define MXCAMERA_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxCamera 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxCamera.h,v 1.3 1998/10/26 21:08:44 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxGL.h" 18 | #include "MxGeom3D.h" 19 | 20 | class MxCamera 21 | { 22 | public: 23 | 24 | double fovy, aspect; 25 | double znear, zfar; 26 | Vec3 from, at, up; 27 | 28 | void look_at(const MxBounds&, double ratio=1.333333); 29 | 30 | void apply(); 31 | void apply(GLenum mode); 32 | }; 33 | 34 | 35 | 36 | // MXCAMERA_INCLUDED 37 | #endif 38 | -------------------------------------------------------------------------------- /mixkit/src/MxString.h: -------------------------------------------------------------------------------- 1 | #ifndef MXSTRING_INCLUDED // -*- C++ -*- 2 | #define MXSTRING_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | String class 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxString.h,v 1.5 1998/10/26 21:09:31 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxBlock.h" 18 | 19 | class MxString : public MxBlock 20 | { 21 | public: 22 | MxString(unsigned int n) : MxBlock(n) { } 23 | MxString(const char *str) 24 | { int len=strlen(str)+1; init_block(len); bitcopy(str, len); } 25 | 26 | bool operator==(const char *s) const { return !strcmp(*this, s); } 27 | }; 28 | 29 | // MXSTRING_INCLUDED 30 | #endif 31 | -------------------------------------------------------------------------------- /libgfx/include/gfx/geom4d.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXGEOM4D_INCLUDED 2 | #define GFXGEOM4D_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Handy 4D geometrical primitives 10 | 11 | $Id: geom4d.h,v 1.4 2002/06/06 15:14:14 yuanzhou Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | template 16 | inline Vec tet_raw_normal(const Vec& v1, const Vec& v2, const Vec& v3, const Vec& v4) 17 | { 18 | return cross(v2-v1, v3-v1, v4-v1); 19 | } 20 | 21 | 22 | template 23 | inline Vec tet_normal(const Vec& v1, const Vec& v2, const Vec& v3, const Vec& v4) 24 | { 25 | Vec n = tet_raw_normal(v1, v2, v3, v4); 26 | unitize(n); 27 | return n; 28 | } 29 | 30 | // GFXGEOM4D_INCLUDED 31 | #endif 32 | -------------------------------------------------------------------------------- /libgfx/gfx-config.in: -------------------------------------------------------------------------------- 1 | # $Id: gfx-config.in,v 1.9 2002/06/13 18:34:59 garland Exp $ 2 | 3 | CC = @CC@ 4 | CXX = @CXX@ 5 | RANLIB = @RANLIB@ 6 | RM = @RM@ 7 | FLTKCONFIG = @FLTKCONFIG@ 8 | 9 | WIN_FLAGS = @X_CFLAGS@ 10 | WIN_LFLAGS = @X_LIBS@ 11 | CFLAGS = @CFLAGS@ $(WIN_FLAGS) 12 | CXXFLAGS = @CXXFLAGS@ $(WIN_FLAGS) 13 | LDFLAGS = @LDFLAGS@ $(WIN_LFLAGS) 14 | 15 | WIN_LIBS = @X_PRE_LIBS@ @X_CORE@ @X_EXTRA_LIBS@ 16 | WIN_DLIBS = @X_PRE_LIBS@ @X_DCORE@ @X_EXTRA_LIBS@ 17 | IMG_LIBS = @IMG_LIBS@ 18 | GL_LIBS = @GL_LIBS@ 19 | FLTK_LIBS = @FLTK_LIBS@ 20 | GUI_LIBS = $(FLTK_LIBS) $(IMG_LIBS) $(GL_LIBS) $(WIN_LIBS) 21 | 22 | CC_DEPEND = @CC_DEPEND@ $(CFLAGS) 23 | CXX_DEPEND = @CXX_DEPEND@ $(CXXFLAGS) 24 | 25 | .SUFFIXES: 26 | .SUFFIXES: .fl .c .cc .cxx .o 27 | 28 | .c.o: 29 | $(CC) -c $(CFLAGS) $< 30 | 31 | .cxx.o: 32 | $(CXX) -c $(CXXFLAGS) $< 33 | 34 | .fl.cxx: 35 | fluid -c $< 36 | 37 | .fl.h: 38 | fluid -c $< 39 | -------------------------------------------------------------------------------- /COPYING.txt: -------------------------------------------------------------------------------- 1 | SlimKit -- Surface modeling tools for simplification and related tasks 2 | Copyright (C) 1998 Michael Garland. 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | The complete text of the GNU General Public License can be 19 | found in the accompanying file GPL.txt. 20 | -------------------------------------------------------------------------------- /libgfx/include/gfx/trackball.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXTRACKBALL_INCLUDED // -*- C++ -*- 2 | #define GFXTRACKBALL_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Virtual trackball rotation control. 10 | 11 | $Id: trackball.h,v 1.7 2002/03/12 17:52:14 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include "baseball.h" 16 | 17 | extern void trackball(Quat& q, float p1x, float p1y, float p2x, float p2y); 18 | 19 | class Trackball : public Baseball 20 | { 21 | public: 22 | Quat lastquat; 23 | 24 | public: 25 | Trackball(); 26 | 27 | virtual void update_animation(); 28 | virtual bool mouse_down(int *where, int which); 29 | virtual bool mouse_up(int *where, int which); 30 | virtual bool mouse_drag(int *where, int *last, int which); 31 | }; 32 | 33 | // GFXTRACKBALL_INCLUDED 34 | #endif 35 | -------------------------------------------------------------------------------- /libgfx/include/gfx/gltools.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXGLTOOLS_INCLUDED // -*- C++ -*- 2 | #define GFXGLTOOLS_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Handy functions for common OpenGL tasks 10 | 11 | $Id: gltools.h,v 1.3 2000/05/23 19:23:40 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include "gl.h" 16 | #include "vec3.h" 17 | 18 | 19 | extern GLuint opengl_pick_nil; 20 | extern GLuint opengl_pick_zmax; 21 | 22 | extern void begin_opengl_pick(int *ctr, double radius, GLuint *buf, int size); 23 | extern GLuint complete_opengl_pick(GLuint *buffer); 24 | 25 | extern void check_opengl_errors(const char *msg=NULL); 26 | 27 | extern void camera_lookat(const Vec3& min, const Vec3& max, double aspect); 28 | 29 | extern int unproject_pixel(int *pixel, double *world, double z=0.0); 30 | 31 | // GFXGLTOOLS_INCLUDED 32 | #endif 33 | -------------------------------------------------------------------------------- /mixkit/src/MxMat4.h: -------------------------------------------------------------------------------- 1 | #ifndef MXMAT4_INCLUDED // -*- C++ -*- 2 | #define MXMAT4_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | 4x4 Matrix class 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxMat4.h,v 1.12 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | 19 | extern bool jacobi(const Mat4& m, Vec4& vals, Vec4 vecs[4]); 20 | 21 | #ifdef MXGL_INCLUDED 22 | inline void glGetMatrix(Mat4& m, GLenum which=GL_MODELVIEW_MATRIX) 23 | { Mat4 tmp; glGetDoublev(which, &tmp(0,0)); m=transpose(tmp); } 24 | 25 | inline void glLoadMatrix(const Mat4& m) 26 | { Mat4 tmp = transpose(m); glLoadMatrixd(&tmp(0,0)); } 27 | 28 | inline void glMultMatrix(const Mat4& m) 29 | { Mat4 tmp = transpose(m); glMultMatrixd(&tmp(0,0)); } 30 | #endif 31 | 32 | // MXMAT4_INCLUDED 33 | #endif 34 | -------------------------------------------------------------------------------- /mixkit/build/copywrite: -------------------------------------------------------------------------------- 1 | #! /usr/local/bin/perl -wi~ 2 | # 3 | # This script will stamp a copyright notice on each file listed on the 4 | # command line. It will overwrite the file with the newly stamped version, 5 | # leaving a copy of the original contents in a backup file. Files without 6 | # both a pre-existing notice and RCS tag will *not* be tagged. 7 | # 8 | # $Id: copywrite,v 1.4 1998/10/28 15:16:28 garland Exp $ 9 | # 10 | 11 | $notice = 12 | 'Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details.'; 13 | 14 | $stamped = ""; 15 | 16 | while(<>) 17 | { 18 | if( /^(.*)Copyright/ ) 19 | { 20 | $leader = $1; 21 | # replace existing notice, if appropriate 22 | if( /Michael Garland/ ) 23 | { 24 | print STDERR "$ARGV\n"; 25 | print "$leader$notice\n"; 26 | } 27 | else 28 | { 29 | print; 30 | } 31 | $stamped = $ARGV; 32 | } 33 | elsif( $stamped ne $ARGV && /^(.*)\$Id/ ) 34 | { 35 | # place notice just before RCS revision tag 36 | print STDERR "$ARGV\n"; 37 | print "$1$notice\n"; 38 | print "$1\n"; 39 | print; 40 | $stamped = $ARGV; 41 | } 42 | else 43 | { 44 | print; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mixkit/src/MxStdSlim.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Surface simplification using quadric error metrics 4 | 5 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 6 | 7 | $Id: MxStdSlim.cxx,v 1.4 1999/01/08 18:56:30 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include "stdmix.h" 12 | #include "MxStdSlim.h" 13 | 14 | MxStdSlim::MxStdSlim(MxStdModel *m0) 15 | : heap(64) 16 | { 17 | m = m0; 18 | 19 | // Externally visible variables 20 | placement_policy = MX_PLACE_OPTIMAL; 21 | weighting_policy = MX_WEIGHT_AREA; 22 | boundary_weight = 1000.0; 23 | compactness_ratio = 0.0; 24 | meshing_penalty = 1.0; 25 | local_validity_threshold = 0.0; 26 | vertex_degree_limit = 24; 27 | will_join_only = false; 28 | 29 | valid_faces = 0; 30 | valid_verts = 0; 31 | is_initialized = false; 32 | 33 | uint i; 34 | for(i=0; iface_count(); i++) if(m->face_is_valid(i)) valid_faces++; 35 | for(i=0; ivert_count(); i++) if(m->vertex_is_valid(i)) valid_verts++; 36 | } 37 | -------------------------------------------------------------------------------- /mixkit/src/MxBlock2.h: -------------------------------------------------------------------------------- 1 | #ifndef MXBLOCK2_INCLUDED // -*- C++ -*- 2 | #define MXBLOCK2_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxBlock2 provides typed access to 2D data blocks. 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxBlock2.h,v 1.10.2.1 2004/07/01 18:38:41 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxBlock.h" 18 | 19 | template 20 | class MxBlock2 : public MxBlock 21 | { 22 | private: 23 | int W, H; 24 | 25 | protected: 26 | MxBlock2() { } 27 | 28 | public: 29 | MxBlock2(int w, int h) : MxBlock(w*h) { W=w; H=h; } 30 | 31 | T& operator()(int i, int j) { return (*this)[j*W+i]; } 32 | const T& operator()(int i, int j) const { return (*this)[j*W+i]; } 33 | 34 | int width() const { return W; } 35 | int height() const { return H; } 36 | 37 | void resize(int w, int h) { W=w; H=h; MxBlock::resize_block(w*h); } 38 | }; 39 | 40 | // MXBLOCK2_INCLUDED 41 | #endif 42 | -------------------------------------------------------------------------------- /libgfx/src/symmat4.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | 4X4 Symmetric Matrix class 4 | 5 | $Id: symmat4.cxx,v 1.3 2003/06/30 10:26:52 garland Exp $ 6 | 7 | ************************************************************************/ 8 | #include 9 | 10 | SymMat4 SymMat4::I() 11 | { 12 | SymMat4 A; 13 | A(0,0) = A(1,1) = A(2,2) = A(3,3) = 1; 14 | return A; 15 | } 16 | 17 | Mat4 SymMat4::fullmatrix() const 18 | { 19 | Mat4 temp; 20 | for (int i=0; i<4; i++) 21 | for (int j=0; j<4; j++) 22 | temp(i,j) = (*this) (i,j); 23 | return temp; 24 | } 25 | 26 | SymMat4 SymMat4::outer_product(const Vec4& v) 27 | { 28 | SymMat4 tmp; 29 | for(int i=0; i<4; i++) 30 | for(int j=0; j<4; j++) 31 | tmp(i,j)=v[i]*v[j]; 32 | return tmp; 33 | } 34 | 35 | SymMat4 operator* (const SymMat4& n, const SymMat4& m) 36 | { 37 | SymMat4 temp; 38 | for (int i=0; i<4; i++) 39 | for(int j=0; j<4; j++) 40 | temp(i,j)=n.row(i) * m.col(j); 41 | return temp; 42 | } 43 | 44 | double invert(Mat4& m_inv, const SymMat4& m) 45 | { 46 | return invert(m_inv, m.fullmatrix()); 47 | } 48 | -------------------------------------------------------------------------------- /mixkit/build/mix-config.in: -------------------------------------------------------------------------------- 1 | # $Id: mix-config.in,v 1.10 1999/12/15 21:25:16 garland Exp $ 2 | 3 | CC = @CC@ 4 | CXX = @CXX@ 5 | RANLIB = @RANLIB@ 6 | RM = @RM@ 7 | 8 | MIX_ROOT = @MIX_ROOT@ 9 | MIX_DEFS = @MIX_DEFS@ 10 | 11 | X_CFLAGS = @X_CFLAGS@ 12 | X_LDFLAGS = @X_LIBS@ 13 | X_EXTRA_LIBS = @X_EXTRA_LIBS@ 14 | X_PRE_LIBS = @X_PRE_LIBS@ 15 | X_LIBS = $(X_PRE_LIBS) -lX11 -lXext $(X_EXTRA_LIBS) 16 | 17 | IMG_LIBS = @IMG_LIBS@ 18 | GL_LIBS = @GL_LIBS@ 19 | 20 | SITE_CFLAGS = @SITE_CFLAGS@ 21 | SITE_CXXFLAGS = @SITE_CXXFLAGS@ 22 | SITE_LDFLAGS = @SITE_LDFLAGS@ 23 | 24 | CFLAGS = @CFLAGS@ 25 | CXXFLAGS = @CXXFLAGS@ 26 | 27 | 28 | ALL_CFLAGS = $(CFLAGS) $(SITE_CFLAGS) @X_CFLAGS@ @CPPFLAGS@ $(MIX_DEFS) 29 | ALL_CXXFLAGS = $(CXXFLAGS) $(SITE_CXXFLAGS) @X_CFLAGS@ @CPPFLAGS@ $(MIX_DEFS) 30 | LDFLAGS = $(SITE_LDFLAGS) @LDFLAGS@ 31 | 32 | PERL = @PERL@ 33 | PERL_CORE = @PERL_CORE@ 34 | PYTHON = @PYTHON@ 35 | PYTHON_LIB = @PYTHON_LIB@ 36 | PYTHON_INCLUDE = @PYTHON_INCLUDE@ 37 | 38 | .SUFFIXES: 39 | .SUFFIXES: .c .cc .cxx .o 40 | 41 | .c.o: 42 | $(CC) -c $(ALL_CFLAGS) $< 43 | 44 | .cxx.o: 45 | $(CXX) -c $(ALL_CXXFLAGS) $< 46 | 47 | CLEAN = ($(RM) -fr ii_files ptrepository ; $(RM) -f *.o) 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # use glob syntax. 2 | syntax: glob 3 | # Compiled Object files 4 | *.slo 5 | *.lo 6 | *.o 7 | *.obj 8 | 9 | # Precompiled Headers 10 | *.gch 11 | *.pch 12 | 13 | # Compiled Dynamic libraries 14 | *.so 15 | *.dylib 16 | *.dll 17 | 18 | # Fortran module files 19 | *.mod 20 | 21 | # Compiled Static libraries 22 | *.lai 23 | *.la 24 | *.a 25 | *.lib 26 | 27 | # Executables 28 | *.exe 29 | *.out 30 | *.app 31 | 32 | 33 | *.so 34 | *.so.[0123456789] 35 | *.so.[0123456789].[0123456789] 36 | *.o 37 | *.a 38 | *~ 39 | *.swp 40 | *.swo 41 | .DS_Store 42 | 43 | libgfx/config.log 44 | mixkit/config.status 45 | tools/filters/ply2smf 46 | tools/filters/smf2c 47 | tools/filters/smf2flat 48 | tools/filters/smf2iv 49 | tools/filters/smf2ldmesh 50 | tools/filters/smf2ply 51 | tools/filters/smfboundary 52 | tools/filters/smfcat 53 | tools/filters/smfclean 54 | tools/filters/smfedgelist 55 | tools/filters/smferror 56 | tools/filters/smfmeasure 57 | tools/filters/smfquadric 58 | tools/filters/smfrefine 59 | tools/filters/smfsphere 60 | tools/filters/smfstitch 61 | tools/qslim/qslim 62 | tools/qslim/qvis 63 | libgfx/config.status 64 | libgfx/gfx-config 65 | mixkit/config.log 66 | mixkit/mix-config 67 | -------------------------------------------------------------------------------- /mixkit/src/MxCmdParser.h: -------------------------------------------------------------------------------- 1 | #ifndef MXCMDPARSER_INCLUDED // -*- C++ -*- 2 | #define MXCMDPARSER_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxCmdParser 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxCmdParser.h,v 1.5 1998/10/26 21:08:45 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxDynBlock.h" 18 | #include "MxAsp.h" 19 | 20 | typedef MxDynBlock MxCmdPhrase; 21 | 22 | class MxCmd 23 | { 24 | public: 25 | char *op; 26 | MxDynBlock phrases; 27 | 28 | MxCmd(int N) : phrases(N) { op=NULL; } 29 | }; 30 | 31 | class MxCmdParser 32 | { 33 | private: 34 | MxCmd cmd; 35 | MxAspStore store; 36 | 37 | public: 38 | bool will_ignore_unknown; 39 | 40 | public: 41 | MxCmdParser(); 42 | 43 | MxAspStore *asp_store() { return &store; } 44 | 45 | void parse_line(char *, void *closure=NULL); 46 | 47 | virtual bool execute_command(const MxCmd& cmd, void *closure=NULL); 48 | }; 49 | 50 | // MXCMDPARSER_INCLUDED 51 | #endif 52 | -------------------------------------------------------------------------------- /libgfx/doc/mat3.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: Matrix Math 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Matrix Math

16 | 17 |

class Mat3

18 | 19 |

This class implements a 3x3 real-valued matrix. 20 | Individual elements are represented with double precision 21 | floating point numbers. To use the Mat3 class you must include the 22 | header 23 |

24 |     #include <gfx/mat3.h>
25 | 
26 | 27 |

Constructor Methods

28 | 29 |

The Mat3 class defines the following set of constructors: 30 | 31 |

32 |     // Initialize all elements to 0
33 |     Mat3();
34 | 
35 |     // Initialize rows with given vectors
36 |     Mat3(const Vec3& r0,const Vec3& r1,const Vec3& r2);
37 | 
38 |     // Copy values from A
39 |     Mat3(const Mat3& A); 
40 | 
41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /mixkit/src/MxCamera.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | MxCamera 4 | 5 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 6 | 7 | $Id: MxCamera.cxx,v 1.3 1998/10/26 21:08:44 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include "stdmix.h" 12 | #include "MxCamera.h" 13 | 14 | 15 | 16 | void MxCamera::look_at(const MxBounds& bounds, double ratio) 17 | { 18 | double d = 3*bounds.radius / tan(60*M_PI/180.0); 19 | 20 | at = bounds.center; 21 | from = at; 22 | 23 | from[Z] += d; 24 | 25 | up[X] = 0; up[Y] = 1; up[Z] = 0; 26 | 27 | fovy = 60.0; 28 | aspect = ratio; 29 | 30 | znear = d/20; 31 | zfar = 10*d; 32 | } 33 | 34 | void MxCamera::apply() 35 | { 36 | gluPerspective(fovy, aspect, znear, zfar); 37 | gluLookAt(from[X], from[Y], from[Z], 38 | at[X], at[Y], at[Z], 39 | up[X], up[Y], up[Z]); 40 | } 41 | 42 | void MxCamera::apply(GLenum mode) 43 | { 44 | GLint last_mode; glGetIntegerv(GL_MATRIX_MODE, &last_mode); 45 | glMatrixMode(mode); 46 | apply(); 47 | glMatrixMode((GLenum)last_mode); 48 | } 49 | -------------------------------------------------------------------------------- /mixkit/src/MxGeom2D.h: -------------------------------------------------------------------------------- 1 | #ifndef MXGEOM2D_INCLUDED // -*- C++ -*- 2 | #define MXGEOM2D_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Handy 2D geometrical primitives 10 | 11 | Copyright (C) 1999 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxGeom2D.h,v 1.1 1999/05/12 17:58:12 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | extern float *mx2d_segment_normal(float *n, const float *v1, const float *v2); 18 | extern float *mx2d_segment_line(float *p, const float *v1, const float *v2); 19 | 20 | extern float mx2d_triangle_area(const float *, const float *,const float *); 21 | extern bool mx2d_is_ccw(const float *a, const float *b, const float *c); 22 | 23 | inline bool mx2d_is_rightof(const float *x, const float *a, const float *b) 24 | { return mx2d_is_ccw(x, b, a); } 25 | inline bool mx2d_is_leftof(const float *x, const float *a, const float *b) 26 | { return mx2d_is_ccw(x, a, b); } 27 | 28 | extern bool mx2d_in_circle(const float *, const float *, 29 | const float *, const float *); 30 | 31 | 32 | // MXGEOM2D_INCLUDED 33 | #endif 34 | -------------------------------------------------------------------------------- /tools/filters/cmdline.h: -------------------------------------------------------------------------------- 1 | #ifndef CMDLINE_INCLUDED // -*- C++ -*- 2 | #define CMDLINE_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Command line interface for the SMF filters. 10 | 11 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 12 | 13 | $Id: cmdline.h,v 1.8 2000/11/20 20:58:59 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef HAVE_UNISTD_H 21 | # include 22 | #else 23 | # include 24 | #endif 25 | 26 | typedef void (*option_processor)(int, char *optarg); 27 | 28 | extern MxStdModel *process_cmdline(int argc, char *argv[], 29 | const char *options=NULL, 30 | option_processor proc=NULL); 31 | 32 | extern void process_cmdline_only(int argc, char *argv[], 33 | const char *options=NULL, 34 | option_processor proc=NULL); 35 | 36 | extern MxStdModel *read_model_from_file(const char *filename, 37 | MxSMFReader *smf=NULL, 38 | MxStdModel *m=NULL); 39 | 40 | extern void output_final_model(MxStdModel *, bool was_modified=false); 41 | 42 | // CMDLINE_INCLUDED 43 | #endif 44 | -------------------------------------------------------------------------------- /libgfx/src/symmat3.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | SymMat3 SymMat3::I() 7 | { 8 | SymMat3 A; 9 | A(0,0) = A(1,1) = A(2,2) = 1; 10 | return A; 11 | } 12 | 13 | Mat3 SymMat3::fullmatrix() const 14 | { 15 | Mat3 A; 16 | 17 | for(int i=0; i 10 | 11 | CC = cl /nologo 12 | CXX = cl /nologo 13 | LINK = link /nologo 14 | 15 | # This is the complete list of Win32 libraries. We only need a subset 16 | # of them. 17 | # 18 | # WIN_LIBS = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib \ 19 | # advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \ 20 | # odbc32.lib odbccp32.lib 21 | 22 | WIN_LIBS = $(winlibs) 23 | IMG_LIBS = libtiff_d.lib libpng_d.lib libjpeg_d.lib 24 | GL_LIBS = opengl32.lib glu32.lib 25 | GUI_LIBS = $(IMG_LIBS) fltk_d.lib wsock32.lib $(GL_LIBS) $(WIN_LIBS) 26 | 27 | BASEFLAGS = $(cflags) $(cdebug) $(cvars) /MLd -D "_DEBUG" \ 28 | -I "$(LIBGFX)/include" -I "$(LOCAL)/include" 29 | 30 | CFLAGS = $(BASEFLAGS) 31 | CXXFLAGS = $(BASEFLAGS) /GX 32 | LDFLAGS = /libpath:"$(LOCAL)/lib" /libpath:"$(LIBGFX)/src" 33 | 34 | .SUFFIXES: 35 | .SUFFIXES: .c .cc .cxx .obj 36 | 37 | .c.obj: 38 | $(CC) /c $(CFLAGS) $< 39 | 40 | .cxx.obj: 41 | $(CXX) /c $(CXXFLAGS) $< 42 | -------------------------------------------------------------------------------- /libgfx/tests/Makefile: -------------------------------------------------------------------------------- 1 | # Include the 'gfx-config' file to get all the correct build settings 2 | include ../gfx-config 3 | 4 | SRCS = t-vec.cxx t-img.cxx t-gui.cxx t-glimg.cxx t-script.cxx t-glext.cxx 5 | ALL = $(SRCS:.cxx=) 6 | 7 | all: $(ALL) 8 | 9 | t-vec: t-vec.cxx 10 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) -lgfx -lm 11 | 12 | t-script: t-script.cxx 13 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) -lgfx -lm 14 | 15 | t-img: t-img.cxx 16 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) -lgfx $(IMG_LIBS) -lm 17 | 18 | # 19 | # GUI programs should make the appropriate post-build call to 20 | # $(FLTKCONFIG). On most platforms, this does nothing, but under 21 | # Mac OS X, it is essential to make GUI programs launch correctly. 22 | # 23 | 24 | t-gui: t-gui.cxx 25 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) -lgfx $(GUI_LIBS) -lm 26 | $(FLTKCONFIG) --post $@ 27 | 28 | t-glext: t-glext.cxx 29 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) -lgfx $(GUI_LIBS) -lm 30 | $(FLTKCONFIG) --post $@ 31 | 32 | t-glimg: t-glimg.cxx 33 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) -lgfx $(GUI_LIBS) -lm 34 | $(FLTKCONFIG) --post $@ 35 | 36 | # This is just a standard mechanism to correctly track the dependencies 37 | # of the source files. 38 | # 39 | depend: 40 | $(CXX_DEPEND) $(SRCS) > Makefile.dep 41 | 42 | -include Makefile.dep 43 | -------------------------------------------------------------------------------- /libgfx/doc/mat2.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: Matrix Math 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Matrix Math

16 | 17 |

class Mat2

18 | 19 |

This class implements a 2x2 real-valued matrix. 20 | Individual elements are represented with double precision 21 | floating point numbers. To use the Mat2 class you must include the 22 | header 23 |

24 |     #include <gfx/mat2.h>
25 | 
26 | 27 |

Constructor Methods

28 | 29 |

The Mat2 class defines the following set of constructors: 30 | 31 |

32 |     // Initialize all elements to 0
33 |     Mat2();
34 |     
35 |     // Initialize row 0 to [a b] and row 1 to [c d]
36 |     Mat2(double a, double b, double c, double d);
37 |     
38 |     // Initialize rows with given vectors
39 |     Mat2(const Vec2 &r0,const Vec2 &r1);
40 | 
41 |     // Copy values from A
42 |     Mat2(const Mat2 &A);
43 | 
44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /tools/filters/smf2flat.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smf2flat 4 | 5 | A conversion filter which outputs models in a FLAT SMF format: 6 | 7 | (1) Only 'v' and 'f' commands are allowed 8 | (2) The first line of the file looks like: 9 | #FLAT 10 | 11 | This restricted form of SMF is much easier to parse. It's intended for 12 | use in systems where you want to hack in support for SMF tools, but don't 13 | want to support the full format. 14 | 15 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 16 | 17 | $Id: smf2flat.cxx,v 1.1 1999/03/24 15:20:21 garland Exp $ 18 | 19 | ************************************************************************/ 20 | 21 | #include 22 | #include "cmdline.h" 23 | 24 | static 25 | void output_flat(MxStdModel *m) 26 | { 27 | cout << "#FLAT " << m->vert_count() << " " << m->face_count() << endl; 28 | 29 | for(uint i=0; ivert_count(); i++) 30 | cout << m->vertex(i) << endl; 31 | for(uint j=0; jface_count(); j++) 32 | cout << m->face(j) << endl; 33 | } 34 | 35 | int main(int argc, char *argv[]) 36 | { 37 | MxStdModel *m = process_cmdline(argc, argv); 38 | if( !m ) return 0; 39 | 40 | output_flat(m); 41 | delete m; 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /libgfx/src/baseball.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Common code for ball-based rotation controllers. 4 | 5 | $Id: baseball.cxx,v 1.2 2003/08/13 15:40:32 garland Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | Baseball::Baseball() 14 | { 15 | curquat = Quat::ident(); 16 | 17 | trans=0.0; 18 | ctr=0.0; 19 | radius=1; 20 | } 21 | 22 | void Baseball::apply_transform() 23 | { 24 | glMatrixMode(GL_MODELVIEW); 25 | glPushMatrix(); 26 | glTranslated(trans[0], trans[1], trans[2]); 27 | glTranslated(ctr[0], ctr[1], ctr[2]); 28 | 29 | const Mat4 M=unit_quat_to_matrix(curquat); 30 | glMultMatrixd(M); 31 | 32 | glTranslated(-ctr[0], -ctr[1], -ctr[2]); 33 | } 34 | 35 | void Baseball::unapply_transform() 36 | { 37 | glMatrixMode(GL_MODELVIEW); 38 | glPopMatrix(); 39 | } 40 | 41 | void Baseball::write(std::ostream& out) 42 | { 43 | out << "baseball "; 44 | out << curquat << " " << trans << " " << ctr << " " << radius << std::endl; 45 | } 46 | 47 | void Baseball::read(std::istream& in) 48 | { 49 | std::string name; 50 | 51 | in >> name; 52 | in >> curquat >> trans >> ctr >> radius; 53 | } 54 | -------------------------------------------------------------------------------- /mixkit/src/MxRaster.h: -------------------------------------------------------------------------------- 1 | #ifndef MXRASTER_INCLUDED // -*- C++ -*- 2 | #define MXRASTER_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxRaster 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxRaster.h,v 1.15 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | 19 | typedef ByteRaster MxRaster; 20 | 21 | //////////////////////////////////////////////////////////////////////// 22 | // 23 | // OpenGL support 24 | // 25 | #ifdef MXGL_INCLUDED 26 | inline void glTexImage(const MxRaster& tex, GLenum target=GL_TEXTURE_2D) 27 | { 28 | glTexImage2D(target, 0, 3, tex.width(), tex.height(), 29 | 0, GL_RGB, GL_UNSIGNED_BYTE, tex.head()); 30 | } 31 | 32 | inline void gluMipmaps(const MxRaster& tex, GLenum target=GL_TEXTURE_2D) 33 | { 34 | gluBuild2DMipmaps(target, 3, tex.width(), tex.height(), 35 | GL_RGB, GL_UNSIGNED_BYTE, tex.head()); 36 | } 37 | 38 | inline void glTexImage(const MxRaster *tex, GLenum target=GL_TEXTURE_2D) 39 | { glTexImage(*tex, target); } 40 | inline void gluMipmaps(const MxRaster *tex, GLenum target=GL_TEXTURE_2D) 41 | { gluMipmaps(*tex, target); } 42 | #endif 43 | 44 | // MXRASTER_INCLUDED 45 | #endif 46 | -------------------------------------------------------------------------------- /libgfx/include/gfx/arcball.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXARCBALL_INCLUDED // -*- C++ -*- 2 | #define GFXARCBALL_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Arcball rotation control. 10 | 11 | $Id: arcball.h,v 1.7 2003/08/13 15:40:31 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include "baseball.h" 16 | 17 | class Arcball : public Baseball 18 | { 19 | private: 20 | Vec2 ball_ctr; 21 | double ball_radius; 22 | 23 | Quat q_now, q_down, q_drag; // Quaternions describing rotation 24 | Vec3 v_from, v_to; // 25 | 26 | bool is_dragging; 27 | 28 | protected: 29 | Vec3 proj_to_sphere(const Vec2&); 30 | void update(); 31 | 32 | 33 | public: 34 | Arcball(); 35 | 36 | virtual void update_animation(); 37 | virtual bool mouse_down(int *where, int which); 38 | virtual bool mouse_up(int *where, int which); 39 | virtual bool mouse_drag(int *where, int *last, int which); 40 | 41 | virtual void apply_transform(); 42 | virtual void get_transform(Vec3 & c, Vec3 &t, Quat & q); 43 | virtual void set_transform(const Vec3 & c, const Vec3 & t, const Quat & q); 44 | 45 | virtual void write(std::ostream&); 46 | virtual void read(std::istream&); 47 | }; 48 | 49 | 50 | 51 | // GFXARCBALL_INCLUDED 52 | #endif 53 | -------------------------------------------------------------------------------- /tools/filters/smf2ldmesh.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smf2ldmesh 4 | 5 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 6 | 7 | $Id: smf2ldmesh.cxx,v 1.2 1998/04/20 16:13:28 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include 12 | #include "cmdline.h" 13 | 14 | static 15 | void output_ldmesh(MxStdModel *m, ostream& out) 16 | { 17 | out << "LASER DESIGN MESH FILE" << endl; 18 | out << "VERTICES " << m->vert_count() << endl; 19 | out << "POLYGONS " << m->face_count() << endl; 20 | out << "MIN -1000000.000000 -1000000.000000 -1000000.000000" << endl; 21 | out << "MAX 1000000.000000 1000000.000000 1000000.000000" << endl; 22 | 23 | uint i; 24 | 25 | out.unsetf(ios::scientific); 26 | out.setf(ios::fixed); 27 | out.precision(6); 28 | 29 | for(i=0; ivert_count(); i++) 30 | { 31 | float *v = m->vertex(i); 32 | out << "X" << v[X] << "Y" << v[Y] << "Z" << v[Z] << endl; 33 | } 34 | 35 | for(i=0; iface_count(); i++) 36 | { 37 | MxFace& f = m->face(i); 38 | out << f[0] << " " << f[1] << " " << f[2] << endl; 39 | } 40 | } 41 | 42 | int main(int argc, char *argv[]) 43 | { 44 | MxStdModel *m = process_cmdline(argc, argv); 45 | if( !m ) return 1; 46 | 47 | output_ldmesh(m, cout); 48 | delete m; 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /tools/filters/smf2iv.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smf2iv 4 | 5 | This filter converts SMF files to OpenInventor files. Currently, only 6 | the geometry is emitted. Any surface attributes are lost. 7 | 8 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 9 | 10 | $Id: smf2iv.cxx,v 1.1 1998/11/06 19:42:44 garland Exp $ 11 | 12 | ************************************************************************/ 13 | 14 | #include 15 | #include "cmdline.h" 16 | 17 | static 18 | void output_iv(MxStdModel *m) 19 | { 20 | uint i; 21 | 22 | cout << "#Inventor V2.0 ascii" << endl; 23 | 24 | cout << "Separator {" << endl 25 | << "Coordinate3 {" << endl 26 | << "point [" << endl; 27 | 28 | for(i=0; ivert_count(); i++) 29 | cout << " " << m->vertex(i)[0] << " " 30 | << m->vertex(i)[1] << " " 31 | << m->vertex(i)[2] << "," << endl; 32 | 33 | cout << "]"<< endl << "}" << endl; 34 | cout << "IndexedFaceSet {" << endl 35 | << "coordIndex [" << endl; 36 | 37 | for(i=0; iface_count(); i++) 38 | cout << " " 39 | << m->face(i)[0] << ", " 40 | << m->face(i)[1] << ", " 41 | << m->face(i)[2] << ", " 42 | << "-1," << endl; 43 | 44 | cout << "]}}" << endl; 45 | } 46 | 47 | int main(int argc, char *argv[]) 48 | { 49 | MxStdModel *m = process_cmdline(argc, argv); 50 | if( !m ) return 0; 51 | 52 | output_iv(m); 53 | delete m; 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /tools/filters/smf2ply.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smf2ply 4 | 5 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 6 | 7 | $Id: smf2ply.cxx,v 1.2 1998/04/20 16:13:29 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include 12 | #include "cmdline.h" 13 | 14 | static 15 | void output_ply(MxStdModel *m) 16 | { 17 | cout << "ply" << endl; 18 | cout << "format ascii 1.0" << endl; 19 | cout << "comment Generated from SMF model by smf2ply" << endl; 20 | 21 | cout << "element vertex " << m->vert_count() << endl; 22 | cout << "property float x" << endl; 23 | cout << "property float y" << endl; 24 | cout << "property float z" << endl; 25 | cout << "element face " << m->face_count() << endl; 26 | cout << "property list uchar int vertex_indices" << endl; 27 | cout << "end_header" << endl; 28 | 29 | uint i; 30 | 31 | for(i=0; ivert_count(); i++) 32 | cout << m->vertex(i)[0] << " " 33 | << m->vertex(i)[1] << " " 34 | << m->vertex(i)[2] << endl; 35 | 36 | for(i=0; iface_count(); i++) 37 | cout << "3 " 38 | << m->face(i)[0] << " " 39 | << m->face(i)[1] << " " 40 | << m->face(i)[2] << endl; 41 | } 42 | 43 | int main(int argc, char *argv[]) 44 | { 45 | MxStdModel *m = process_cmdline(argc, argv); 46 | if( !m ) return 0; 47 | 48 | output_ply(m); 49 | delete m; 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /mixkit/src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for building the MixKit library 3 | # $Id: Makefile,v 1.50.2.1 2001/09/21 16:18:23 garland Exp $ 4 | # 5 | 6 | include ../../libgfx/gfx-config 7 | 8 | CORE_SRCS = mixmsg.cxx MxCmdParser.cxx MxAsp.cxx 9 | 10 | MATH_SRCS = MxMat3-jacobi.cxx MxMat4-jacobi.cxx \ 11 | MxGeom3D.cxx MxTriProject.cxx MxFrame.cxx MxFitFrame.cxx \ 12 | MxFitFrame-2.cxx MxGeom2D.cxx mixmops.cxx 13 | 14 | MODEL_SRCS = MxBlockModel.cxx MxStdModel.cxx MxSMF.cxx MxQMetric3.cxx \ 15 | MxQSlim.cxx MxStdSlim.cxx MxQMetric.cxx MxPropSlim.cxx \ 16 | MxDualModel.cxx MxFaceTree.cxx MxFaceTree-2.cxx MxDualSlim.cxx \ 17 | MxEdgeFilter.cxx MxFeatureFilter.cxx 18 | 19 | DATA_SRCS = MxHeap.cxx 20 | 21 | # These modules require OpenGL or Mesa 22 | GL_SRCS = MxCamera.cxx MxQVis3.cxx \ 23 | MxStdRender.cxx MxGLDebug.cxx MxGLUtils.cxx MxFitFrame-vis.cxx 24 | 25 | # These modules require the FLTK toolkit 26 | GUI_SRCS = MxStdGUI.cxx 27 | 28 | SRCS = $(CORE_SRCS) $(MATH_SRCS) $(MODEL_SRCS) $(DATA_SRCS) \ 29 | $(GL_SRCS) $(GUI_SRCS) 30 | 31 | OBJS = $(SRCS:.cxx=.o) 32 | 33 | ######################################################################## 34 | 35 | libmix.a: $(OBJS) 36 | $(AR) cru libmix.a $(OBJS) 37 | $(RANLIB) libmix.a 38 | 39 | clean: 40 | -$(RM) -f $(OBJS) libmix.a 41 | 42 | depend: 43 | $(CXX_DEPEND) $(SRCS) > Makefile.dep 44 | 45 | 46 | -include Makefile.dep 47 | #sinclude Makefile.dep # Alternative syntax for some makes 48 | -------------------------------------------------------------------------------- /mixkit/src/MxFeatureFilter.h: -------------------------------------------------------------------------------- 1 | #ifndef MXFEATUREFILTER_INCLUDED // -*- C++ -*- 2 | #define MXFEATUREFILTER_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxFeatureFilter 10 | 11 | Michael Garland, 1999 12 | 13 | $Id: MxFeatureFilter.h,v 1.1 1999/07/14 19:40:53 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxGeom3D.h" 18 | #include "MxStdModel.h" 19 | #include "MxDualModel.h" 20 | 21 | class MxFeatureFilter 22 | { 23 | protected: 24 | MxStdModel *m; 25 | MxDualModel *dual; 26 | 27 | MxBlock flabel; 28 | MxFaceList splitter; 29 | MxDynBlock planes; 30 | 31 | protected: 32 | void clear_labels(); 33 | 34 | uint split_edge_with_plane(uint i, uint j, float *p); 35 | void slice_model(MxPlane3& p); 36 | uint classify_point(float *v); 37 | uint classify_face(uint f); 38 | 39 | void compute_contour_target(uint f, float *vnew, MxEdgeList& contour); 40 | void contract_contour(MxEdgeList& contour, float *vnew); 41 | 42 | public: 43 | MxFeatureFilter(MxStdModel *m0); 44 | 45 | uint splitter_count() const { return splitter.length(); } 46 | void clear_splitters() { splitter.reset(); planes.reset(); } 47 | uint add_splitter(uint i); 48 | 49 | MxDualModel *extract_features(); 50 | void remove_feature(uint f, MxEdgeList& contour); 51 | }; 52 | 53 | // MXFEATUREFILTER_INCLUDED 54 | #endif 55 | -------------------------------------------------------------------------------- /mixkit/src/MxEdgeFilter.h: -------------------------------------------------------------------------------- 1 | #ifndef MXEDGEFILTER_INCLUDED // -*- C++ -*- 2 | #define MXEDGEFILTER_INCLUDED 3 | 4 | /************************************************************************ 5 | 6 | MxEdgeFilter 7 | 8 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 9 | 10 | $Id: MxEdgeFilter.h,v 1.2 1998/10/26 21:08:50 garland Exp $ 11 | 12 | ************************************************************************/ 13 | 14 | #include "MxStdModel.h" 15 | #include "MxHeap.h" 16 | 17 | class MxRankedEdge : public MxEdge, public MxHeapable 18 | { 19 | public: 20 | MxRankedEdge(MxVertexID v1, MxVertexID v2) : MxEdge(v1,v2) { } 21 | }; 22 | 23 | class MxEdgeFilter 24 | { 25 | private: 26 | MxHeap heap; 27 | MxDynBlock update_list; 28 | 29 | bool filter1(); 30 | 31 | protected: 32 | MxStdModel *m; 33 | 34 | MxRankedEdge *create_edge(MxVertexID, MxVertexID, bool will_rank=true); 35 | void collect_edges(); 36 | void collect_star_for_update(MxVertexID); 37 | void rank_and_update_edge(MxRankedEdge *); 38 | 39 | MxVertexID split_edge(MxRankedEdge *); 40 | 41 | virtual float compute_edge_rank(MxRankedEdge *); 42 | virtual void filter_target_edge(MxRankedEdge *); 43 | 44 | public: 45 | uint original_edge_count; 46 | uint current_edge_count; 47 | 48 | public: 49 | MxEdgeFilter(MxStdModel *m0); 50 | 51 | void initialize(); 52 | bool filter(uint target); 53 | bool filter_above_rank(float); 54 | }; 55 | 56 | // MXEDGEFILTER_INCLUDED 57 | #endif 58 | -------------------------------------------------------------------------------- /mixkit/src/MxGLDebug.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | MxGLDebug 4 | 5 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 6 | 7 | $Id: MxGLDebug.cxx,v 1.3 1998/10/26 21:08:55 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include "stdmix.h" 12 | #include "MxGL.h" 13 | 14 | void mxgl_report_stack_depth() 15 | { 16 | GLint depth; 17 | 18 | glGetIntegerv(GL_PROJECTION_STACK_DEPTH, &depth); 19 | cerr << " Projection stack depth = " << depth; 20 | glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &depth); 21 | cerr << " (" << depth << " max)" << endl; 22 | 23 | glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth); 24 | cerr << " ModelView stack depth = " << depth; 25 | glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &depth); 26 | cerr << " (" << depth << " max)" << endl; 27 | 28 | glGetIntegerv(GL_TEXTURE_STACK_DEPTH, &depth); 29 | cerr << " Texture stack depth = " << depth; 30 | glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &depth); 31 | cerr << " (" << depth << " max)" << endl; 32 | } 33 | 34 | 35 | void mxgl_check_errors(const char *msg) 36 | { 37 | bool stack_error = false; 38 | 39 | for(GLenum err=glGetError(); err!=GL_NO_ERROR; err=glGetError()) 40 | { 41 | cerr << "GL ERROR "; 42 | if( msg ) cerr << msg; 43 | cerr << ": " << (const char *)gluErrorString(err) << endl; 44 | 45 | if( err==GL_STACK_OVERFLOW || err==GL_STACK_UNDERFLOW ) 46 | stack_error = true; 47 | } 48 | 49 | if( stack_error ) mxgl_report_stack_depth(); 50 | } 51 | -------------------------------------------------------------------------------- /libgfx/include/gfx/baseball.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXBASEBALL_INCLUDED // -*- C++ -*- 2 | #define GFXBASEBALL_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Common base class for ball-based rotators (e.g., Trackball & Arcball). 10 | 11 | $Id: baseball.h,v 1.2 2003/08/13 15:40:32 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include "quat.h" 16 | 17 | class Baseball 18 | { 19 | public: 20 | Vec3 ctr; // Describes bounding sphere of object 21 | double radius; // 22 | 23 | Quat curquat; // Current rotation of object 24 | Vec3 trans; // Current translation of object 25 | 26 | public: 27 | Baseball(); 28 | 29 | // Required initialization method 30 | template 31 | void bounding_sphere(const TVec3& v, T r) { ctr=v; radius=r; } 32 | 33 | // Standard event interface provide by all Ball controllers 34 | virtual void update_animation() = 0; 35 | virtual bool mouse_down(int *where, int which) = 0; 36 | virtual bool mouse_up(int *where, int which) = 0; 37 | virtual bool mouse_drag(int *where, int *last, int which) = 0; 38 | 39 | // Interface for use during drawing to apply appropriate transformation 40 | virtual void apply_transform(); 41 | virtual void unapply_transform(); 42 | 43 | // Interface for reading/writing transform 44 | virtual void write(std::ostream&); 45 | virtual void read(std::istream&); 46 | }; 47 | 48 | // GFXBASEBALL_INCLUDED 49 | #endif 50 | -------------------------------------------------------------------------------- /libgfx/doc/vec2.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: Vector Math 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Vector Math

16 | 17 |

class Vec2

18 | 19 |

This class implements a 2-dimensional real-valued vector. 20 | Individual elements are represent with double precision 21 | floating point numbers. To use the Vec2 class you must 22 | include the header 23 |

24 |     #include <gfx/vec2.h>
25 | 
26 | 27 |

Constructor Methods

28 | 29 |

The Vec2 class defines the following set of constructors: 30 | 31 |

32 |     Vec2();                    // Initializes vector to (0 0).
33 |     Vec2(double x, double y);  // Initializes vector to (x y).
34 |     Vec2(double s);            // Initializes vector to (s s)
35 | 
36 |     Vec2(const Vec2& v);       // 
37 |     Vec2(const float  v[2]);   // These copy values from v
38 |     Vec2(const double v[2]);   // 
39 | 
40 | 41 |

Specialized Functions

42 | 43 |

Beyond the standard functions supported by all vector classes, the 44 | Vec2 class provides the following additional function: 45 |

46 |     Vec2 perp(const Vec2 &v);
47 | 
48 | that returns a new vector which is perpendicular to the given vector. 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /examples/propvis.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | PropVis 4 | 5 | $Id: propvis.cxx,v 1.2.6.1 2002/01/31 18:36:27 garland Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | class GUI : public MxStdGUI 16 | { 17 | public: 18 | MxPropSlim *slim; 19 | 20 | GUI() { slim=NULL; } 21 | 22 | virtual bool key_press(int key); 23 | virtual void draw_custom_contents(); 24 | }; 25 | 26 | GUI gui; 27 | 28 | bool GUI::key_press(int c) 29 | { 30 | switch( c ) 31 | { 32 | case 'g': slim->decimate(slim->valid_faces - 100); break; 33 | case 'G': slim->decimate(slim->valid_faces - 1000); break; 34 | case 'h': slim->decimate(1000); break; 35 | 36 | default: return false; 37 | } 38 | 39 | canvas->redraw(); 40 | return true; 41 | } 42 | 43 | void GUI::draw_custom_contents() 44 | { 45 | MxStdModel *m = model(); 46 | 47 | status("%uv : %uf", 48 | slim?slim->valid_verts:m->vert_count(), 49 | slim?slim->valid_faces:m->face_count()); 50 | } 51 | 52 | main(int argc, char **argv) 53 | { 54 | gui.initialize(argc, argv); 55 | 56 | MxStdModel *m = gui.model(); 57 | 58 | cerr << "+ Initializing decimator ..."; 59 | cerr.flush(); 60 | gui.slim = new MxPropSlim(m); 61 | gui.slim->boundary_weight = 1000; 62 | gui.slim->initialize(); 63 | cerr << " done" << endl; 64 | cerr << "+ Quadric dimension: " << gui.slim->dim() << endl; 65 | 66 | return gui.run(); 67 | } 68 | 69 | -------------------------------------------------------------------------------- /examples/propslim.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | PropSlim 4 | 5 | $Id: propslim.cxx,v 1.2 1998/10/13 21:47:16 garland Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | static MxStdModel *m; 16 | static uint face_target; 17 | 18 | static 19 | void startup_and_input(int argc, char **argv) 20 | { 21 | MxSMFReader smf; 22 | m = smf.read(cin); 23 | 24 | face_target = atoi(argv[1]); 25 | } 26 | 27 | static 28 | void output_final_model() 29 | { 30 | m->compact_vertices(); 31 | MxSMFWriter smfout; 32 | smfout.write(cout, *m); 33 | } 34 | 35 | main(int argc, char **argv) 36 | { 37 | double input_time, init_time, slim_time, output_time; 38 | 39 | 40 | MXTIME(input_time, startup_and_input(argc, argv)); 41 | MxPropSlim slim(m); 42 | 43 | MXTIME(init_time, slim.initialize()); 44 | MXTIME(slim_time, slim.decimate(face_target)); 45 | MXTIME(output_time, output_final_model()); 46 | 47 | cerr << "+ Running time" << endl; 48 | cerr << " Setup : " << input_time << " sec" << endl; 49 | cerr << " PSlim init : " << init_time << " sec" << endl; 50 | cerr << " PSlim run : " << slim_time << " sec" << endl; 51 | cerr << " Output : " << output_time << " sec" << endl; 52 | cerr << endl; 53 | cerr << " PSlim Total : " << init_time+slim_time << endl; 54 | cerr << " Total : " 55 | << input_time+init_time+slim_time+output_time < 21 | class MxStack : private MxDynBlock 22 | { 23 | public: 24 | MxStack(unsigned int n) : MxDynBlock(n) 25 | { } 26 | MxStack(const T& val, unsigned int n) : MxDynBlock(n) 27 | { push(val); } 28 | 29 | T& top() { return this->last(); } 30 | const T& top() const { return this->last(); } 31 | 32 | bool is_empty() { return this->length()==0; } 33 | 34 | T& pop() { return this->drop(); } 35 | 36 | void push(const T& val) { this->add(val); } 37 | // 38 | // NOTE: In this code, it is *crucial* that we do the add() and 39 | // assignment in separate steps. The obvious alternative 40 | // is something like { add(top()); }. But this is subtly 41 | // broken! The top() will grab a pointer into the block, 42 | // but the add() may reallocate the block before doing the 43 | // assignment. Thus, the pointer will become invalid. 44 | void push() { this->add(); this->top() = (*this)[this->length()-2]; } 45 | }; 46 | 47 | // MXSTACK_INCLUDED 48 | #endif 49 | -------------------------------------------------------------------------------- /libgfx/src/mat3.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | 3x3 Matrix class 4 | 5 | $Id: mat3.cxx,v 1.3 2001/11/19 16:08:30 garland Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | #include 11 | 12 | Mat3 Mat3::I() { return Mat3(Vec3(1,0,0), Vec3(0,1,0), Vec3(0,0,1)); } 13 | 14 | Mat3 &Mat3::diag(double d) 15 | { 16 | *this = 0.0; 17 | row[0][0] = row[1][1] = row[2][2] = d; 18 | return *this; 19 | } 20 | 21 | Mat3 diag(const Vec3& v) 22 | { 23 | return Mat3(Vec3(v[0],0,0), Vec3(0,v[1],0), Vec3(0,0,v[2])); 24 | } 25 | 26 | Mat3 Mat3::outer_product(const Vec3& v) 27 | { 28 | Mat3 A; 29 | double x=v[0], y=v[1], z=v[2]; 30 | 31 | A(0,0) = x*x; A(0,1) = x*y; A(0,2) = x*z; 32 | A(1,0)=A(0,1); A(1,1) = y*y; A(1,2) = y*z; 33 | A(2,0)=A(0,2); A(2,1)=A(1,2); A(2,2) = z*z; 34 | 35 | return A; 36 | } 37 | 38 | Mat3 Mat3::outer_product(const Vec3& u, const Vec3& v) 39 | { 40 | Mat3 A; 41 | 42 | for(int i=0; i<3; i++) 43 | for(int j=0; j<3; j++) 44 | A(i, j) = u[i]*v[j]; 45 | 46 | return A; 47 | } 48 | 49 | Mat3 operator*(const Mat3& n, const Mat3& m) 50 | { 51 | Mat3 A; 52 | 53 | for(int i=0;i<3;i++) 54 | for(int j=0;j<3;j++) 55 | A(i,j) = n[i]*m.col(j); 56 | 57 | return A; 58 | } 59 | 60 | Mat3 adjoint(const Mat3& m) 61 | { 62 | return Mat3(m[1]^m[2], 63 | m[2]^m[0], 64 | m[0]^m[1]); 65 | } 66 | 67 | double invert(Mat3& inv, const Mat3& m) 68 | { 69 | Mat3 A = adjoint(m); 70 | double d = A[0] * m[0]; 71 | 72 | if( d==0.0 ) 73 | return 0.0; 74 | 75 | inv = transpose(A) / d; 76 | return d; 77 | } 78 | -------------------------------------------------------------------------------- /mixkit/src/MxStdSlim.h: -------------------------------------------------------------------------------- 1 | #ifndef MXSTDSLIM_INCLUDED // -*- C++ -*- 2 | #define MXSTDSLIM_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Core simplification interface. The MxStdSlim class defines the 10 | interface which all simplification classes conform to. 11 | 12 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 13 | 14 | $Id: MxStdSlim.h,v 1.4 1998/11/19 01:57:34 garland Exp $ 15 | 16 | ************************************************************************/ 17 | 18 | #include "MxStdModel.h" 19 | #include "MxHeap.h" 20 | 21 | #define MX_PLACE_ENDPOINTS 0 22 | #define MX_PLACE_ENDORMID 1 23 | #define MX_PLACE_LINE 2 24 | #define MX_PLACE_OPTIMAL 3 25 | 26 | #define MX_WEIGHT_UNIFORM 0 27 | #define MX_WEIGHT_AREA 1 28 | #define MX_WEIGHT_ANGLE 2 29 | #define MX_WEIGHT_AVERAGE 3 30 | #define MX_WEIGHT_AREA_AVG 4 31 | #define MX_WEIGHT_RAWNORMALS 5 32 | 33 | class MxStdSlim 34 | { 35 | protected: 36 | MxStdModel *m; 37 | MxHeap heap; 38 | 39 | public: 40 | unsigned int valid_verts; 41 | unsigned int valid_faces; 42 | bool is_initialized; 43 | 44 | int placement_policy; 45 | int weighting_policy; 46 | bool will_join_only; 47 | 48 | double boundary_weight; 49 | double compactness_ratio; 50 | double meshing_penalty; 51 | double local_validity_threshold; 52 | uint vertex_degree_limit; 53 | 54 | public: 55 | MxStdSlim(MxStdModel *m0); 56 | 57 | virtual void initialize() = 0; 58 | virtual bool decimate(uint) = 0; 59 | 60 | MxStdModel& model() { return *m; } 61 | }; 62 | 63 | // MXSTDSLIM_INCLUDED 64 | #endif 65 | -------------------------------------------------------------------------------- /mixkit/src/MxFrame.h: -------------------------------------------------------------------------------- 1 | #ifndef MXFRAME_INCLUDED // -*- C++ -*- 2 | #define MXFRAME_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxFrame 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxFrame.h,v 1.7 1998/10/26 21:08:54 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #define MXFRAME_UAXIS 0 18 | #define MXFRAME_VAXIS 1 19 | #define MXFRAME_NORMAL 2 20 | 21 | class MxFrame 22 | { 23 | private: 24 | double v0[3]; // origin of local frame 25 | double axes[3][3]; // unit axis vectors of local frame 26 | double d0; // together with axis(2), defines base plane 27 | 28 | public: 29 | MxFrame(); 30 | MxFrame(double *c); 31 | MxFrame(double *c, double *u0, double *u1, double *u2); 32 | 33 | MxFrame(const MxFrame& f) { *this = f; } 34 | MxFrame& operator=(const MxFrame& f); 35 | 36 | double *origin() { return v0; } 37 | const double *origin() const { return v0; } 38 | double *axis(uint i) { AssertBound(i<3); return axes[i]; } 39 | const double *axis(uint i) const { AssertBound(i<3); return axes[i]; } 40 | double plane_offset() const { return d0; } 41 | void plane_offset(double d) { d0 = d; } 42 | 43 | double *to_frame(const double *, double *) const; 44 | double *from_frame(const double *, double *) const; 45 | double *compute_xform_toframe(double *) const; 46 | double *compute_xform_fromframe(double *) const; 47 | 48 | double dist_to_plane(const double *) const; 49 | 50 | void align_axis(uint i, const double *v); 51 | }; 52 | 53 | // MXFRAME_INCLUDED 54 | #endif 55 | -------------------------------------------------------------------------------- /tools/filters/smfclean.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smfclean 4 | 5 | This filter tries to remove unwanted degeneracies from the input model. 6 | Supported cleanups: 7 | 8 | (1) Remove degenerate faces 9 | (2) Remove unused vertices 10 | 11 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 12 | 13 | $Id: smfclean.cxx,v 1.5 1998/08/03 13:15:04 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | #include 19 | #include "cmdline.h" 20 | 21 | static 22 | void clean(MxStdModel *m) 23 | { 24 | static double zero[] = {0.0, 0.0, 0.0}; 25 | uint degenerate_face_count = 0; 26 | uint unused_vertex_count = 0; 27 | 28 | for(MxFaceID f=0; fface_count(); f++) 29 | { 30 | double n[3]; 31 | 32 | m->compute_face_normal(f, n); 33 | if( m->face_is_valid(f) && mxv_equal(n, zero, 3) ) 34 | { 35 | degenerate_face_count++; 36 | m->face_mark_invalid(f); 37 | } 38 | } 39 | 40 | for(MxVertexID v=0; vvert_count(); v++) 41 | { 42 | if( m->vertex_is_valid(v) && m->neighbors(v).length() == 0 ) 43 | { 44 | unused_vertex_count++; 45 | m->vertex_mark_invalid(v); 46 | } 47 | } 48 | 49 | cerr << "Removal totals:" << endl; 50 | cerr << " " << degenerate_face_count << " degenerate faces" << endl; 51 | cerr << " " << unused_vertex_count << " unused vertices" << endl; 52 | } 53 | 54 | #ifndef FILTER_PROCEDURE 55 | int main(int argc, char *argv[]) 56 | { 57 | MxStdModel *m = process_cmdline(argc, argv); 58 | 59 | if( !m ) return 0; 60 | 61 | clean(m); 62 | 63 | 64 | output_final_model(m, true); 65 | 66 | delete m; 67 | return 0; 68 | } 69 | #endif 70 | -------------------------------------------------------------------------------- /libgfx/src/mat2.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | 2x2 Matrix class 4 | 5 | $Id: mat2.cxx,v 1.4 2001/02/08 21:28:53 garland Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | #include 11 | 12 | Mat2 Mat2::I() { return Mat2(1,0, 0,1); } 13 | 14 | Mat2 &Mat2::diag(double d) 15 | { 16 | row[0][0] = d; row[0][1] = 0; 17 | row[1][0] = 0; row[1][1] = d; 18 | 19 | return *this; 20 | } 21 | 22 | Mat2 operator*(const Mat2 &n, const Mat2& m) 23 | { 24 | Mat2 A; 25 | int i,j; 26 | 27 | for(i=0;i<2;i++) 28 | for(j=0;j<2;j++) 29 | A(i,j) = n[i]*m.col(j); 30 | 31 | return A; 32 | } 33 | 34 | double invert(Mat2 &inv, const Mat2 &m) 35 | { 36 | double d = det(m); 37 | 38 | if( d==0.0 ) 39 | return 0.0; 40 | 41 | inv(0, 0) = m(1,1)/d; 42 | inv(0, 1) = -m(0,1)/d; 43 | inv(1, 0) = -m(1,0)/d; 44 | inv(1, 1) = m(0,0)/d; 45 | 46 | return d; 47 | } 48 | 49 | bool eigenvalues(const Mat2& M, Vec2& evals) 50 | { 51 | double B = -M(0,0)-M(1,1); 52 | double C = det(M); 53 | 54 | double dis = B*B - 4.0*C; 55 | if( dis template to provide 10 | convenient 2-D and 3-D arrays. 11 | 12 | NOTE: This package used to provide array and varray templates 13 | that were alternatives to the STL vector template. Its purpose was 14 | to support some legacy code written in the days when few compilers 15 | understood STL. Now that STL support is common, that code has been 16 | removed. 17 | 18 | $Id: array.h,v 1.15 2002/05/20 15:27:03 garland Exp $ 19 | 20 | ************************************************************************/ 21 | 22 | #include "gfx.h" 23 | #include 24 | 25 | template 26 | class array2 : public std::vector 27 | { 28 | private: 29 | int W, H; 30 | 31 | protected: 32 | array2() { } 33 | 34 | public: 35 | array2(int w, int h) : std::vector(w*h), W(w), H(h) { } 36 | 37 | T& operator()(int i, int j) { return (*this)[j*W+i]; } 38 | const T& operator()(int i, int j) const { return (*this)[j*W+i]; } 39 | 40 | int width() const { return W; } 41 | int height() const { return H; } 42 | }; 43 | 44 | template 45 | class array3 : public std::vector 46 | { 47 | private: 48 | int W, H, D; 49 | 50 | protected: 51 | array3() { } 52 | 53 | public: 54 | array3(int w, int h, int d) : std::vector(w*h*d), W(w), H(h), D(d) { } 55 | 56 | T& operator()(int i, int j, int k) { return (*this)[k*W*H + j*W+i]; } 57 | const T& operator()(int i,int j,int k) const {return (*this)[k*W*H+j*W+i];} 58 | 59 | int width() const { return W; } 60 | int height() const { return H; } 61 | int depth() const { return D; } 62 | }; 63 | 64 | // GFXARRAY_INCLUDED 65 | #endif 66 | -------------------------------------------------------------------------------- /mixkit/src/mixmsg.h: -------------------------------------------------------------------------------- 1 | #ifndef MIXMSG_INCLUDED // -*- C++ -*- 2 | #define MIXMSG_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MixKit error reporting and message notification support. 10 | 11 | This module is meant to provide a small but reasonably flexible way of 12 | reporting errors and other interesting events to the user. 13 | 14 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 15 | 16 | $Id: mixmsg.h,v 1.4 1999/01/22 17:25:37 garland Exp $ 17 | 18 | ************************************************************************/ 19 | 20 | // 21 | // Message severity levels 22 | // 23 | enum MxSeverityLevel 24 | { 25 | MXMSG_FATAL = 0, 26 | MXMSG_ASSERT, 27 | MXMSG_ERROR, 28 | MXMSG_WARN, 29 | MXMSG_NOTE, 30 | MXMSG_DEBUG, 31 | MXMSG_TRACE 32 | }; 33 | 34 | class MxMsgInfo 35 | { 36 | public: 37 | MxSeverityLevel severity; 38 | const char *message; 39 | const char *context; 40 | const char *filename; 41 | int line; 42 | }; 43 | 44 | typedef bool (*mxmsg_handler)(MxMsgInfo *); 45 | 46 | extern void mxmsg_signal(MxSeverityLevel severity, 47 | const char *msg, const char *context=NULL, 48 | const char *filename=NULL, 49 | int line=0); 50 | extern void mxmsg_signalf(MxSeverityLevel severity, const char *format, ...); 51 | 52 | 53 | extern bool mxmsg_default_handler(MxMsgInfo *); 54 | extern void mxmsg_set_handler(mxmsg_handler h=mxmsg_default_handler); 55 | 56 | extern MxSeverityLevel mxmsg_severity_level(); 57 | extern void mxmsg_severity_level(MxSeverityLevel); 58 | extern const char *mxmsg_severity_name(MxSeverityLevel); 59 | 60 | extern MxSeverityLevel mxmsg_lethality_level(); 61 | extern void mxmsg_lethality_level(MxSeverityLevel); 62 | 63 | extern void mxmsg_indent(uint i=1); 64 | extern void mxmsg_dedent(uint i=1); 65 | 66 | // MIXMSG_INCLUDED 67 | #endif 68 | -------------------------------------------------------------------------------- /mixkit/src/MxQMetric.h: -------------------------------------------------------------------------------- 1 | #ifndef MXQMETRIC_INCLUDED // -*- C++ -*- 2 | #define MXQMETRIC_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | n-D Quadric Error Metric 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxQMetric.h,v 1.5 1998/10/26 21:09:17 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxQMetric3.h" 18 | #include "MxVector.h" 19 | #include "MxMatrix.h" 20 | 21 | class MxQuadric 22 | { 23 | private: 24 | MxMatrix A; 25 | MxVector b; 26 | double c; 27 | 28 | double r; 29 | 30 | public: 31 | MxQuadric(unsigned int N) : A(N), b(N) { clear(); } 32 | MxQuadric(const MxVector& p1, const MxVector& p2, const MxVector& p3, 33 | double area=1.0); 34 | MxQuadric(const MxQuadric3&, unsigned int N); 35 | MxQuadric(const MxQuadric& Q) 36 | : A(Q.A.dim()), b(Q.b.dim()) { *this = Q; } 37 | 38 | const MxMatrix& tensor() const { return A; } 39 | const MxVector& vector() const { return b; } 40 | double offset() const { return c; } 41 | double area() const { return r; } 42 | MxMatrix& homogeneous(MxMatrix& H) const; 43 | 44 | void clear(double val=0.0) { A=val; b=val; c=val; r=val; } 45 | MxQuadric& operator=(const MxQuadric& Q) 46 | { A=Q.A; b=Q.b; c=Q.c; r=Q.r; return *this; } 47 | MxQuadric& operator+=(const MxQuadric& Q) 48 | { A+=Q.A; b+=Q.b; c+=Q.c; r+=Q.r; return *this; } 49 | MxQuadric& operator-=(const MxQuadric& Q) 50 | { A-=Q.A; b-=Q.b; c-=Q.c; r-=Q.r; return *this; } 51 | MxQuadric& operator*=(double s) 52 | { A*=s; b*=s; c*=s; return *this; } 53 | 54 | double evaluate(const MxVector& v) const; 55 | double operator()(const MxVector& v) const { return evaluate(v); } 56 | 57 | bool optimize(MxVector& v) const; 58 | }; 59 | 60 | // MXQMETRIC_INCLUDED 61 | #endif 62 | -------------------------------------------------------------------------------- /libgfx/tests/t-script.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Test the libgfx scripting facility. 4 | 5 | by Michael Garland, 2000. 6 | 7 | $Id: t-script.cxx,v 1.7 2002/12/20 19:07:03 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | // usage: add * 18 | // Adds all numbers listed on the line and prints the result 19 | // 20 | // usage: avg * 21 | // Averages all numbers listed on the line and prints the result 22 | // 23 | int proc_add(const CmdLine &cmd) 24 | { 25 | std::vector values; 26 | double sum = 0.0; 27 | 28 | cmd.collect_as_numbers(values); 29 | std::vector::size_type count; 30 | for(count=0; count0 ) 34 | sum /= (double)count; 35 | 36 | cout << sum << endl; 37 | return SCRIPT_OK; 38 | } 39 | 40 | // usage: vec3 41 | // Constructs a 3-vector and prints the result 42 | int proc_vec3(const CmdLine &cmd) 43 | { 44 | if( cmd.argcount() != 3 ) return SCRIPT_ERR_SYNTAX; 45 | 46 | Vec3 v; 47 | cmd.collect_as_numbers(v, 3); 48 | 49 | cout << v << endl; 50 | return SCRIPT_OK; 51 | } 52 | 53 | // usage: echo 54 | // Prints all the text following the command name verbatim 55 | int proc_echo(const CmdLine &cmd) 56 | { 57 | cout << cmd.argline() << endl; 58 | return SCRIPT_OK; 59 | } 60 | 61 | int main(int argc, char *argv[]) 62 | { 63 | CmdEnv env; 64 | 65 | env.register_command("add", proc_add); 66 | env.register_command("avg", proc_add); 67 | env.register_command("echo", proc_echo); 68 | env.register_command("vec3", proc_vec3); 69 | 70 | for(int i=1; i */ 22 | #undef HAVE_UNISTD_H 23 | 24 | /* Stuff determining the presence of support for alloca() */ 25 | #undef HAVE_ALLOCA_H 26 | #undef HAVE_ALLOCA 27 | 28 | /* Define if ANSI Standard C++ Library iostreams are available and */ 29 | /* you want to use them. */ 30 | #undef MIX_ANSI_IOSTREAMS 31 | 32 | /* 33 | Global safety policy for MixKit software. 34 | 35 | Safety levels: 36 | 37 | -2 Reckless 38 | -1 Optimized 39 | 0 Normal 40 | 1 Cautious 41 | 2 Paranoid 42 | 43 | */ 44 | #ifndef SAFETY 45 | #define SAFETY 0 46 | #endif 47 | 48 | /* Define if Sam Leffler's libtiff is available */ 49 | #undef MIX_HAVE_LIBTIFF 50 | 51 | /* Define if libpng is available */ 52 | #undef MIX_HAVE_LIBPNG 53 | 54 | /* Define if the Independent JPEG Group's libjpeg is available */ 55 | #undef MIX_HAVE_LIBJPEG 56 | 57 | /* ***** OpenGL configuration section ***** */ 58 | 59 | /* Define to the name of OpenGL implementation (e.g., "OpenGL" or "Mesa") */ 60 | #undef MIX_HAVE_OPENGL 61 | 62 | /* Define if glPolygonOffsetEXT is available */ 63 | #undef MIX_HAVE_POLYOFFSET_EXT 64 | 65 | /* Define if glPolygonOffset is available */ 66 | #undef MIX_HAVE_POLYOFFSET 67 | 68 | /* Define if glDrawArraysEXT is available */ 69 | #undef MIX_HAVE_VERTARRAYS 70 | -------------------------------------------------------------------------------- /libgfx/tests/t-vec.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Test various vector math facilities provided by libgfx. 4 | 5 | by Michael Garland, 2000. 6 | 7 | $Id: t-vec.cxx,v 1.5 2002/03/12 19:49:12 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | void test_intvec() 21 | { 22 | cout << "Testing IntVec types" << endl; 23 | 24 | class Normal : public IntVec 25 | { 26 | public: 27 | Normal(const Vec3& v) { (*this) = v; } 28 | 29 | Vec3 unpack() const { return Vec3((*this)[0],(*this)[1],(*this)[2]); } 30 | void pack(const Vec3& v) 31 | { set(0, v[0]); set(1, v[1]); set(2, v[2]); } 32 | 33 | Normal& operator=(const Vec3& v) { pack(v); return *this; } 34 | }; 35 | 36 | Normal n = Vec3(1.0, 0.4, -1.0); 37 | cout << " n = " << n.unpack() << endl; 38 | 39 | n.set(0, -1.0); n.set(1, 0.4); n.set(2, 1); 40 | cout << " n = " << n[0] << " " << n[1] << " " << n[2] << endl; 41 | 42 | 43 | typedef IntVec3 byteColor; 44 | byteColor rgb(0.8, 0.2, 0.2); 45 | cout << " rgb = " << rgb.unpack() << endl; 46 | } 47 | 48 | template 49 | void test_vector() 50 | { 51 | Vec u = 0; 52 | Vec v = 0; 53 | 54 | u[0] = 1; 55 | v[1] = 1; 56 | 57 | Vec x = u * 2.0; 58 | Vec y = v / 2.0; 59 | 60 | cout << " x = " << x << endl; 61 | cout << " y = " << y << endl; 62 | } 63 | 64 | main() 65 | { 66 | cout << "+ Testing class Vec2" << endl; 67 | test_vector(); 68 | 69 | cout << "+ Testing class Vec3" << endl; 70 | test_vector(); 71 | 72 | cout << "+ Testing class Vec4" << endl; 73 | test_vector(); 74 | 75 | test_intvec(); 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /mixkit/src/MxMatrix.h: -------------------------------------------------------------------------------- 1 | #ifndef MXMATRIX_INCLUDED // -*- C++ -*- 2 | #define MXMATRIX_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Generic n-dimensional matrix class 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxMatrix.h,v 1.8 1998/10/26 21:09:10 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxVector.h" 18 | 19 | #define __T float 20 | #include "mixmops.h" 21 | 22 | #define __T double 23 | #include "mixmops.h" 24 | 25 | //////////////////////////////////////////////////////////////////////// 26 | // 27 | // Matrix class 28 | // 29 | 30 | #include "MxBlock2.h" 31 | 32 | class MxMatrix : public MxBlock2 33 | { 34 | public: 35 | MxMatrix(unsigned int n) : MxBlock2(n,n) { *this = 0.0; } 36 | MxMatrix(const MxMatrix& m) : MxBlock2(m.dim(),m.dim()) {copy(m);} 37 | 38 | MxMatrix& operator=(const MxMatrix& m) { copy(m); return *this; } 39 | MxMatrix& operator=(double d) { mxm_set(*this, d, dim()); return *this; } 40 | 41 | unsigned int dim() const { return width(); } 42 | 43 | MxMatrix& operator+=(const MxMatrix& m) 44 | { mxm_addinto(*this, m, dim()); return *this; } 45 | MxMatrix& operator-=(const MxMatrix& m) 46 | { mxm_subfrom(*this, m, dim()); return *this; } 47 | MxMatrix& operator*=(double d) {mxm_scale(*this, d, dim()); return *this;} 48 | MxMatrix& operator/=(double d) {mxm_invscale(*this,d,dim());return *this;} 49 | 50 | 51 | MxVector operator*(const MxVector& v) const 52 | { MxVector r(dim()); mxm_xform(r, *this, v, dim()); return r; } 53 | 54 | double invert(MxMatrix& inv) const {return mxm_invert(inv, *this, dim());} 55 | }; 56 | 57 | 58 | inline ostream& operator<<(ostream& out, const MxMatrix& a) 59 | { 60 | return mxm_write(out, a, a.dim()); 61 | } 62 | 63 | // MXMATRIX_INCLUDED 64 | #endif 65 | -------------------------------------------------------------------------------- /mixkit/src/MxGeom3D.h: -------------------------------------------------------------------------------- 1 | #ifndef MXGEOM3D_INCLUDED // -*- C++ -*- 2 | #define MXGEOM3D_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Handy 3D geometrical primitives 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxGeom3D.h,v 1.14 2000/12/14 17:47:43 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | #include "MxVec3.h" 19 | #include "MxVec4.h" 20 | 21 | extern double triangle_project_point(const Vec3& v0, const Vec3& v1, 22 | const Vec3& v2, const Vec3& v, 23 | Vec3 *bary=NULL); 24 | 25 | extern void mx3d_box_corners(const Vec3& min, const Vec3& max, Vec3 *v); 26 | 27 | class MxBounds 28 | { 29 | public: 30 | 31 | bool is_initialized; 32 | Vec3 min, max; 33 | Vec3 center; 34 | double radius; 35 | unsigned int points; 36 | 37 | void reset(); 38 | void add_point(const double *v, bool will_update=true); 39 | void add_point(const float *v, bool will_update=true); 40 | void complete(); 41 | void merge(const MxBounds&); 42 | 43 | MxBounds() { reset(); } 44 | }; 45 | 46 | class MxPlane3 47 | { 48 | private: 49 | float p[4]; 50 | 51 | public: 52 | MxPlane3() { } 53 | MxPlane3(const float *p0) { for(uint i=0; i<4; i++) p[i]=p0[i]; } 54 | MxPlane3(const MxPlane3& n) { *this = n; } 55 | 56 | inline MxPlane3& operator=(const MxPlane3& n); 57 | 58 | operator const float*() const { return p; } 59 | operator float*() { return p; } 60 | 61 | #ifdef __GNUC__ 62 | float& operator[](int i) { return p[i]; } 63 | const float& operator[](int i) const { return p[i]; } 64 | #endif 65 | }; 66 | 67 | inline MxPlane3& MxPlane3::operator=(const MxPlane3& n) 68 | { 69 | for(uint i=0; i<4; i++) p[i]=n.p[i]; 70 | return *this; 71 | } 72 | 73 | // MXGEOM3D_INCLUDED 74 | #endif 75 | -------------------------------------------------------------------------------- /libgfx/vc6/libgfx.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "libgfx"=.\libgfx\libgfx.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "tglimg"=.\tglimg\tglimg.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | Begin Project Dependency 27 | Project_Dep_Name libgfx 28 | End Project Dependency 29 | }}} 30 | 31 | ############################################################################### 32 | 33 | Project: "tgui"=.\tgui\tgui.dsp - Package Owner=<4> 34 | 35 | Package=<5> 36 | {{{ 37 | }}} 38 | 39 | Package=<4> 40 | {{{ 41 | Begin Project Dependency 42 | Project_Dep_Name libgfx 43 | End Project Dependency 44 | }}} 45 | 46 | ############################################################################### 47 | 48 | Project: "tscript"=.\tscript\tscript.dsp - Package Owner=<4> 49 | 50 | Package=<5> 51 | {{{ 52 | }}} 53 | 54 | Package=<4> 55 | {{{ 56 | Begin Project Dependency 57 | Project_Dep_Name libgfx 58 | End Project Dependency 59 | }}} 60 | 61 | ############################################################################### 62 | 63 | Project: "tvec"=.\tvec\tvec.dsp - Package Owner=<4> 64 | 65 | Package=<5> 66 | {{{ 67 | }}} 68 | 69 | Package=<4> 70 | {{{ 71 | Begin Project Dependency 72 | Project_Dep_Name libgfx 73 | End Project Dependency 74 | }}} 75 | 76 | ############################################################################### 77 | 78 | Global: 79 | 80 | Package=<5> 81 | {{{ 82 | }}} 83 | 84 | Package=<3> 85 | {{{ 86 | }}} 87 | 88 | ############################################################################### 89 | 90 | -------------------------------------------------------------------------------- /mixkit/src/MxGeom2D.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Handy 2D geometrical primitives 4 | 5 | Copyright (C) 1999 Michael Garland. See "COPYING.txt" for details. 6 | 7 | $Id: MxGeom2D.cxx,v 1.1 1999/05/12 17:58:13 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include "stdmix.h" 12 | #include "MxMath.h" 13 | #include "MxGeom2D.h" 14 | #include "MxVector.h" 15 | 16 | // Returns TWICE the signed area of triangle ABC 17 | static 18 | inline float triArea(const float *a, const float *b, const float *c) 19 | { 20 | return (b[X] - a[X])*(c[Y] - a[Y]) - (b[Y] - a[Y])*(c[X] - a[X]); 21 | } 22 | 23 | // This computes the signed area of the oriented triangle ABC. 24 | // The area is positive when ABC is oriented counterclockwise. 25 | // 26 | float mx2d_triangle_area(const float *a, const float *b, const float *c) 27 | { 28 | return 0.5*triArea(a,b,c); 29 | } 30 | 31 | bool mx2d_is_ccw(const float *a, const float *b, const float *c) 32 | { 33 | return triArea(a, b, c) > 0; 34 | } 35 | 36 | // This returns true if the d lies within the circle defined by a,b,c. 37 | // See Delaunay triangulator by Lischinski in Graphics Gems IV and 38 | // Guibas & Stolfi paper in ACM Trans. on Graphics 1985. 39 | // 40 | bool mx2d_in_circle(const float *a, const float *b, 41 | const float *c, const float *d) 42 | { 43 | return (a[0]*a[0] + a[1]*a[1]) * triArea(b, c, d) - 44 | (b[0]*b[0] + b[1]*b[1]) * triArea(a, c, d) + 45 | (c[0]*c[0] + c[1]*c[1]) * triArea(a, b, d) - 46 | (d[0]*d[0] + d[1]*d[1]) * triArea(a, b, c) > FEQ_EPS; 47 | } 48 | 49 | float *mx2d_segment_normal(float *n, const float *v1, const float *v2) 50 | { 51 | n[X] = v1[Y] - v2[Y]; 52 | n[Y] = v2[X] - v1[X]; 53 | mxv_unitize(n, 2); 54 | return n; 55 | } 56 | 57 | float *mx2d_segment_line(float *p, const float *v1, const float *v2) 58 | { 59 | mx2d_segment_normal(p, v1, v2); 60 | p[2] = -p[X]*v1[X] -p[Y]*v1[Y]; 61 | return p; 62 | } 63 | -------------------------------------------------------------------------------- /libgfx/src/time.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Routines for measuring time. 4 | 5 | $Id: time.cxx,v 1.1 2000/04/26 18:56:26 garland Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | 11 | #if defined(WIN32) 12 | #define WIN32_LEAN_AND_MEAN 13 | #include 14 | 15 | // Only Windows NT supports getting proper time usage information. 16 | // In Windows 95, we have to settle for measuring real time. 17 | double get_cpu_time() 18 | { 19 | FILETIME start, end, kernel, user; 20 | 21 | if( !GetThreadTimes(GetCurrentThread(), &start, &end, &kernel, &user) ) 22 | { 23 | // We're running under Windows 95 instead of NT. 24 | // Just get the current time and be done with it. 25 | SYSTEMTIME now; 26 | GetSystemTime(&now); 27 | SystemTimeToFileTime(&now, &user); 28 | } 29 | 30 | // Convert into something we can do math on 31 | LARGE_INTEGER i; 32 | i.LowPart = user.dwLowDateTime; 33 | i.HighPart = user.dwHighDateTime; 34 | 35 | #ifdef __GNUC__ 36 | 37 | // The Win32 headers shipped with GCC don't define the QuadPart 38 | // accessor for the LARGE_INTEGER type. So we have to build it 39 | // directly. 40 | long long quad = i.HighPart; 41 | quad = (quad << 32) + i.LowPart; 42 | return (double)quad / 1e7; 43 | #else 44 | // Convert to seconds and return 45 | return (double)(i.QuadPart) / 1e7; 46 | #endif 47 | } 48 | 49 | #elif defined(HAVE_GETRUSAGE) 50 | #include 51 | #include 52 | 53 | double get_cpu_time() 54 | { 55 | struct rusage t; 56 | 57 | getrusage(RUSAGE_SELF, &t); 58 | 59 | return (double)t.ru_utime.tv_sec + (double)t.ru_utime.tv_usec/1000000; 60 | } 61 | 62 | #elif defined(HAVE_TIMES) 63 | // Alec 64 | #include 65 | 66 | double get_cpu_time() 67 | { 68 | struct tms t; 69 | 70 | times(&t); 71 | 72 | return (double)(t.tms_utime) / (double)CLK_TCK; 73 | } 74 | 75 | #else 76 | 77 | #error "No supported timing mechanism available." 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /libgfx/tests/t-glext.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Test the availability of various OpenGL extensions 4 | 5 | by Michael Garland, 2001. 6 | 7 | $Id: t-glext.cxx,v 1.1 2001/10/16 14:23:14 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | class GUI : public MxGUI 19 | { 20 | public: 21 | 22 | virtual void setup_for_drawing(); 23 | }; 24 | 25 | GUI gui; 26 | 27 | static void dump_string(ostream &out, const string& str) 28 | { 29 | const char *ws = " \t\n\r"; 30 | string::size_type start, end; 31 | 32 | start = 0; 33 | end = str.find_first_of(ws, start); 34 | 35 | while( end!=string::npos ) 36 | { 37 | out << " " << str.substr(start, end-start) << endl; 38 | start = str.find_first_not_of(ws, end); 39 | end = str.find_first_of(ws, start); 40 | } 41 | } 42 | 43 | void GUI::setup_for_drawing() 44 | { 45 | ofstream log("glext.txt"); 46 | 47 | string gl_extensions = (char *)glGetString(GL_EXTENSIONS); 48 | 49 | log << "OpenGL extensions" << endl 50 | << "-----------------" << endl; 51 | dump_string(log, gl_extensions); 52 | log << endl << endl; 53 | 54 | 55 | #ifdef HAVE_GL_WGLEXT_H 56 | PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = 57 | (PFNWGLGETEXTENSIONSSTRINGARBPROC) 58 | wglGetProcAddress("wglGetExtensionsStringARB"); 59 | 60 | if( !wglGetExtensionsStringARB ) 61 | { 62 | log << "Couldn't find wglGetExtensionsStringARB." << endl; 63 | exit(-1); 64 | } 65 | else 66 | { 67 | string wgl_extensions = wglGetExtensionsStringARB(wglGetCurrentDC()); 68 | 69 | log << "WGL extensions" << endl 70 | << "--------------" << endl; 71 | dump_string(log, wgl_extensions); 72 | } 73 | #endif 74 | 75 | exit(0); 76 | } 77 | 78 | main(int argc, char **argv) 79 | { 80 | gui.initialize(argc, argv); 81 | return gui.run(); 82 | } 83 | -------------------------------------------------------------------------------- /tools/cluster/QCluster.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------ 2 | QCluster Hierarchical Face Clustering 3 | Version 1.0 4 | July 4, 2004 5 | 6 | Michael Garland 7 | 8 | 9 | Copyright (C) 1998-2002 Michael Garland. See "COPYING.txt" for details. 10 | 11 | 12 | For the latest version and up-to-date information, please visit 13 | http://www.uiuc.edu/~garland/software/qslim.html 14 | 15 | 16 | Michael Garland 17 | Department of Computer Science 18 | University of Illinois at Urbana-Champaign 19 | 201 North Goodwin Avenue 20 | Urbana, IL 61801 21 | 22 | ------------------------------------------------------------------------ 23 | 24 | 25 | The QCluster program is a new component of the QSlim 2.1 surface 26 | simplification package. Rather than simplifying the geometry by iterative 27 | contraction, it iteratively merges adjacent sets of faces. This produces a 28 | binary hierarchy of "face clusters". The underlying error metric is in 29 | essence a dual form of the quadric error metric used by QSlim. 30 | 31 | 32 | RUNNING QCLUSTER 33 | ---------------- 34 | 35 | The standard QCluster executable is a non-interactive program called 36 | 'qcluster' which you invoke using a command of the form: 37 | 38 | qcluster 39 | 40 | When clustering is complete, it will output the resulting hierarchy. 41 | 42 | 43 | The output file consists of a sequence of dual contraction records. Every 44 | face cluster is given an integer ID. Initially, each face of the input model 45 | is a singleton cluster and is assigned a number from 1..n. A subsequent 46 | contraction record will create a new node numbered by the next available 47 | identifier. Each contraction record consists of the following items: 48 | 49 | f^ -- IDs of clusters being merged 50 | fo -- Origin of local frame for this cluster 51 | fe -- Three axes of local frame 52 | fn -- Normal of least-squares best fitting plane 53 | fd -- offset for least-squares best plane 54 | fx -- Corners of oriented bbox (in LOCAL FRAME) 55 | -------------------------------------------------------------------------------- /libgfx/doc/license.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: License 9 | 10 | 11 | 12 | 13 | 14 | 15 |

License

16 | 17 | 18 |

Copyright Notice 19 |

20 | Copyright © 1999–2001 Michael Garland. All rights reserved. 21 |
22 | 23 |

Terms and Conditions 24 | 25 |

Permission is hereby granted, free of charge, to any person obtaining a 26 | copy of this software and associated documentation files (the 27 | "Software"), to deal in the Software without restriction, including 28 | without limitation the rights to use, copy, modify, merge, publish, 29 | distribute, and/or sell copies of the Software, and to permit persons 30 | to whom the Software is furnished to do so, provided that the above 31 | copyright notice(s) and this permission notice appear in all copies of 32 | the Software and that both the above copyright notice(s) and this 33 | permission notice appear in supporting documentation. 34 | 35 |

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 36 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 37 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 38 | OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 39 | HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 40 | INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 41 | FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 42 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 43 | WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 44 | 45 |

Except as contained in this notice, the name of a copyright holder 46 | shall not be used in advertising or otherwise to promote the sale, use 47 | or other dealings in this Software without prior written authorization 48 | of the copyright holder. 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /mixkit/src/MxHeap.h: -------------------------------------------------------------------------------- 1 | #ifndef MXHEAP_INCLUDED // -*- C++ -*- 2 | #define MXHEAP_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Heap 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxHeap.h,v 1.11 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxDynBlock.h" 18 | 19 | class MxHeapable 20 | { 21 | private: 22 | float import; 23 | int token; 24 | 25 | public: 26 | MxHeapable() { not_in_heap(); heap_key(0.0f); } 27 | 28 | inline bool is_in_heap() { return token != -47; } 29 | inline void not_in_heap() { token = -47; } 30 | inline int get_heap_pos() { return token; } 31 | inline void set_heap_pos(int t) { token=t; } 32 | 33 | inline void heap_key(float k) { import=k; } 34 | inline float heap_key() const { return import; } 35 | }; 36 | 37 | 38 | class MxHeap : private MxDynBlock 39 | { 40 | private: 41 | void place(MxHeapable *x, unsigned int i); 42 | void swap(unsigned int i, unsigned int j); 43 | 44 | unsigned int parent(unsigned int i) { return (i-1)/2; } 45 | unsigned int left(unsigned int i) { return 2*i+1; } 46 | unsigned int right(unsigned int i) { return 2*i+2; } 47 | 48 | void upheap(unsigned int i); 49 | void downheap(unsigned int i); 50 | 51 | 52 | 53 | public: 54 | MxHeap() : MxDynBlock(8) { } 55 | MxHeap(unsigned int n) : MxDynBlock(n) { } 56 | 57 | void insert(MxHeapable *t) { insert(t, t->heap_key()); } 58 | void insert(MxHeapable *, float); 59 | void update(MxHeapable *t) { update(t, t->heap_key()); } 60 | void update(MxHeapable *, float); 61 | 62 | unsigned int size() const { return length(); } 63 | MxHeapable *item(uint i) { return (*this)[i]; } 64 | const MxHeapable *item(uint i) const { return (*this)[i]; } 65 | MxHeapable *extract(); 66 | MxHeapable *top() { return (length()<1 ? (MxHeapable *)NULL : item(0)); } 67 | MxHeapable *remove(MxHeapable *); 68 | }; 69 | 70 | // MXHEAP_INCLUDED 71 | #endif 72 | -------------------------------------------------------------------------------- /tools/filters/smfboundary.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smfboundary 4 | 5 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 6 | 7 | $Id: smfboundary.cxx,v 1.1 1998/10/27 01:24:18 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include 12 | #include 13 | 14 | #include "cmdline.h" 15 | 16 | static double threshold = 0; 17 | 18 | static char *options = "t:h"; 19 | static char *usage_string = 20 | "-t Set proximity threshold\n" 21 | "\n"; 22 | 23 | static 24 | void process_options(int opt, char *optarg) 25 | { 26 | switch( opt ) 27 | { 28 | case 't': threshold = atof(optarg); break; 29 | case 'h': 30 | cerr << endl << usage_string << endl; 31 | break; 32 | } 33 | } 34 | 35 | static 36 | bool vertex_is_open(MxStdModel *m, uint v) 37 | { 38 | static MxVertexList star; 39 | 40 | star.reset(); 41 | m->collect_vertex_star(v, star); 42 | 43 | return (star.length() - m->neighbors(v).length()) > 0; 44 | } 45 | 46 | static 47 | bool is_nonedge_pair(MxStdModel *m, uint i, uint j) 48 | { 49 | static MxFaceList edges; 50 | 51 | edges.reset(); 52 | m->collect_edge_neighbors(i, j, edges); 53 | return edges.length() == 0; 54 | } 55 | 56 | void output_boundary_verts(MxStdModel *m, ostream& out) 57 | { 58 | MxVertexID i,j; 59 | 60 | for(i=0; ivert_count(); i++) 61 | m->vertex_mark(i, vertex_is_open(m,i)); 62 | 63 | 64 | for(i = 0; ivert_count(); i++) 65 | { 66 | if( !m->vertex_mark(i) ) continue; 67 | 68 | for(j=i+1; jvert_count(); j++) 69 | { 70 | if( !m->vertex_mark(j) ) continue; 71 | if( !is_nonedge_pair(m, i, j) ) continue; 72 | 73 | if( mxv_L2(m->vertex(i), m->vertex(j), 3) < threshold ) 74 | out << "e " << i+1 << " " << j+1 << endl; 75 | } 76 | } 77 | } 78 | 79 | int main(int argc, char *argv[]) 80 | { 81 | MxStdModel *m = process_cmdline(argc, argv, options, process_options); 82 | if( !m ) return 0; 83 | 84 | 85 | threshold *= threshold; 86 | 87 | output_final_model(m); 88 | output_boundary_verts(m, cout); 89 | 90 | delete m; 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /win32/SlimKit.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "MixKit"=..\mixkit\MixKit.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "QSlim"=.\QSlim\QSlim.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | Begin Project Dependency 27 | Project_Dep_Name libgfx 28 | End Project Dependency 29 | Begin Project Dependency 30 | Project_Dep_Name MixKit 31 | End Project Dependency 32 | }}} 33 | 34 | ############################################################################### 35 | 36 | Project: "QVis"=.\QVis\QVis.dsp - Package Owner=<4> 37 | 38 | Package=<5> 39 | {{{ 40 | }}} 41 | 42 | Package=<4> 43 | {{{ 44 | Begin Project Dependency 45 | Project_Dep_Name libgfx 46 | End Project Dependency 47 | Begin Project Dependency 48 | Project_Dep_Name MixKit 49 | End Project Dependency 50 | }}} 51 | 52 | ############################################################################### 53 | 54 | Project: "SMFView"=.\SMFView\SMFView.dsp - Package Owner=<4> 55 | 56 | Package=<5> 57 | {{{ 58 | }}} 59 | 60 | Package=<4> 61 | {{{ 62 | Begin Project Dependency 63 | Project_Dep_Name libgfx 64 | End Project Dependency 65 | Begin Project Dependency 66 | Project_Dep_Name MixKit 67 | End Project Dependency 68 | }}} 69 | 70 | ############################################################################### 71 | 72 | Project: "libgfx"=..\libgfx\vc6\libgfx\libgfx.dsp - Package Owner=<4> 73 | 74 | Package=<5> 75 | {{{ 76 | }}} 77 | 78 | Package=<4> 79 | {{{ 80 | }}} 81 | 82 | ############################################################################### 83 | 84 | Global: 85 | 86 | Package=<5> 87 | {{{ 88 | }}} 89 | 90 | Package=<3> 91 | {{{ 92 | }}} 93 | 94 | ############################################################################### 95 | 96 | -------------------------------------------------------------------------------- /libgfx/doc/cdoc.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Stylesheet for code documentation 3 | * 4 | * $Id: cdoc.css,v 1.2 2001/10/02 16:09:20 garland Exp $ 5 | */ 6 | 7 | BODY { 8 | font-family: "Times New Roman", "Times", serif; 9 | background-color: white; 10 | color: black; 11 | } 12 | 13 | @media screen { 14 | BODY { 15 | margin-left: 11.11%; 16 | margin-right: 11.11%; 17 | } 18 | 19 | /* To be used for floating navbars */ 20 | DIV.navbar { 21 | font-family: Arial Narrow; 22 | display: block; 23 | text-align: left; 24 | float: right; 25 | padding-bottom: 2pt; 26 | padding-left: 2pt; 27 | border-left: thin dashed black; 28 | border-bottom: thin dashed black; 29 | } 30 | } 31 | 32 | @media print { 33 | /* IE often prints Web pages in excessively large fonts */ 34 | BODY { font-size: 10pt; } 35 | 36 | /* Navbars should not be printed */ 37 | DIV.navbar { display: none } 38 | 39 | /* H2 headers are used as the top-level elements for separate sections */ 40 | H2 { page-break-before: always } 41 | } 42 | 43 | H1, H2, H3, H4, H5, H6 { clear: both; font-family: Arial, sans-serif; } 44 | H1 { font-size: 249% } 45 | H2 { font-size: 172%; } 46 | H3 { font-size: 144%; } 47 | H4 { font-size: 120%; margin-bottom: 0.5em; } 48 | H5,H6 { font-size: 100%; margin-bottom: 0.2em; } 49 | 50 | H1, H2, H3, H4 { 51 | color: #4444aa; 52 | background-color: #cccccc; 53 | padding-top: 4px; 54 | padding-left: 4px; 55 | padding-right: 4px; 56 | padding-bottom: 4px; 57 | } 58 | 59 | H1,H2 { margin-left: -1.5em; } 60 | H3 { margin-left: -0.75em; } 61 | 62 | P { text-indent: 0pt; } 63 | P.indent { text-indent: 1em; } 64 | P.justify { text-align: justify; } 65 | 66 | PRE.code { margin-left: 2em } 67 | 68 | /* The standard size scale */ 69 | .min5 { font-size: 40%; } 70 | .min4 { font-size: 48%; } 71 | .min3 { font-size: 58%; } 72 | .min2 { font-size: 69%; } 73 | .min1 { font-size: 83%; } 74 | .min0 { font-size: 100%; } 75 | .mag0 { font-size: 100%; } 76 | .mag1 { font-size: 120%; } 77 | .mag2 { font-size: 144%; } 78 | .mag3 { font-size: 172%; } 79 | .mag4 { font-size: 207%; } 80 | .mag5 { font-size: 249%; } 81 | 82 | /* Link styles */ 83 | A { text-decoration: none } 84 | A:active {color: red} 85 | A:hover {color: red} 86 | A:visited {color: purple} 87 | -------------------------------------------------------------------------------- /libgfx/include/gfx/config.h.in: -------------------------------------------------------------------------------- 1 | /* This -*- C -*- file is meant to be processed by the configure script */ 2 | 3 | /* Define this if your compiler doesn't support the new C++ 'bool' type */ 4 | #undef HAVE_BOOL 5 | 6 | /* Define if your system supports rint() */ 7 | #undef HAVE_RINT 8 | 9 | /* Define if your system supports getrusage() */ 10 | #undef HAVE_GETRUSAGE 11 | 12 | /* Define if your system does not support getrusage() but supports times() */ 13 | #undef HAVE_TIMES 14 | 15 | /* Define if your system supports random() as opposed to just rand() */ 16 | #undef HAVE_RANDOM 17 | 18 | /* Define if the STL hash_map template is available */ 19 | #undef HAVE_HASH_MAP 20 | 21 | /* Define if the STL hash_set template is available */ 22 | #undef HAVE_HASH_SET 23 | 24 | /* GCC v3 puts hash_map and hash_set in an 'ext' directory */ 25 | #undef HAVE_EXT_HASH_MAP 26 | #undef HAVE_EXT_HASH_SET 27 | 28 | /* Define if the STL valarray template is available */ 29 | #undef HAVE_VALARRAY 30 | 31 | /* Define if the ANSI standard is available */ 32 | #undef HAVE_SSTREAM 33 | 34 | /* Define if the pre-ANSI is available */ 35 | #undef HAVE_STRSTREAM 36 | 37 | /* ***** GUI & Image configuration section ***** */ 38 | 39 | /* Define if the FLTK GUI toolkit is available */ 40 | #undef HAVE_FLTK 41 | 42 | /* Define if FLTK OpenGL support is available */ 43 | #undef HAVE_FLTK_GL 44 | 45 | /* Define if Sam Leffler's libtiff is available */ 46 | #undef HAVE_LIBTIFF 47 | 48 | /* Define the libtiff LZW is available */ 49 | #undef HAVE_LIBTIFF_LZW 50 | 51 | /* Define if libpng is available */ 52 | #undef HAVE_LIBPNG 53 | 54 | /* Define if the Independent JPEG Group's libjpeg is available */ 55 | #undef HAVE_LIBJPEG 56 | 57 | /* ***** OpenGL configuration section ***** */ 58 | 59 | /* Define to the name of OpenGL implementation (e.g., "OpenGL" or "Mesa") */ 60 | #undef HAVE_OPENGL 61 | 62 | /* Define if glPolygonOffsetEXT is available */ 63 | #undef HAVE_POLYOFFSET_EXT 64 | 65 | /* Define if glPolygonOffset is available */ 66 | #undef HAVE_POLYOFFSET 67 | 68 | /* Define if header is available */ 69 | #undef HAVE_GL_GLEXT_H 70 | 71 | /* Define if header is available */ 72 | #undef HAVE_GL_GLXEXT_H 73 | 74 | /* Define if header is available */ 75 | #undef HAVE_GL_WGLEXT_H 76 | -------------------------------------------------------------------------------- /libgfx/doc/vec4.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: Vector Math 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Vector Math

16 | 17 |

class Vec4

18 | 19 |

This class implements a 4-dimensional real-valued vector. 20 | Individual elements are represent with double precision 21 | floating point numbers. To use the Vec4 class you must 22 | include the header 23 |

24 |     #include <gfx/vec4.h>
25 | 
26 | 27 |

Constructor Methods

28 | 29 |

The Vec4 class defines the following set of constructors: 30 | 31 |

32 |     Vec4();                                        // Initializes vector to (0 0 0 0).
33 |     Vec4(double x, double y, double z, double w);  // Initializes vector to (x y z w).
34 |     Vec3(double s);                                // Initializes vector to (s s s s)
35 | 
36 |     Vec4(const Vec4& v);                           // 
37 |     Vec4(const float  v[4]);                       // These copy values from v
38 |     Vec4(const double v[4]);                       // 
39 | 
40 |     Vec4(const Vec3& v, double w);                 // Initializes vector to (v[0] v[1] v[2] w)
41 | 
42 | 43 |

Specialized Functions

44 | 45 |

In addition to the standard functions provided by all vector classes, 46 | the Vec4 class defines certain specialized functions which 47 | operate only on 4-D vectors. 48 | 49 |

The cross product of three 4-vectors u, v, w is a 50 | fourth vector which is perpendicular to all of u, v, w. 51 | It can be computed with the function call 52 | 53 |

54 |     t = cross(u, v, w);
55 | 
56 | 57 |

Since 4-D vectors are frequently 58 | used to represent 3-D homogeneous 59 | coordinates, a projection function is provided. 60 |

61 |     Vec3 proj(const Vec4& v);
62 | 
63 | This routine takes a homogeneous vector (x y z w) and returns the 64 | corresponding 3-vector (x/w y/w z/w). If w is 0 then 65 | the vector (x y z) is returned. 66 | -------------------------------------------------------------------------------- /mixkit/src/MxDualSlim.h: -------------------------------------------------------------------------------- 1 | #ifndef MXDUALSLIM_INCLUDED // -*- C++ -*- 2 | #define MXDUALSLIM_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxDualSlim 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxDualSlim.h,v 1.6 2000/03/09 18:00:54 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxDualModel.h" 18 | #include "MxFaceTree.h" 19 | #include "MxQMetric3.h" 20 | #include "MxHeap.h" 21 | 22 | #define MX_SHAPE_ANY 0 23 | #define MX_SHAPE_REGULAR 1 24 | 25 | class MxDualSlimEdge : public MxHeapable { public: uint id; }; 26 | 27 | class MxDualSlimNode 28 | { 29 | public: 30 | MxQuadric3 Q_dir; // Error form for normal orientation 31 | MxQuadric3 Q_fit; // Error form for planarity 32 | 33 | MxFaceList faces; // All the faces in this cluster 34 | 35 | float perimeter; // The length of the cluster's perimeter 36 | uint nverts; // The number of vertices in this cluster 37 | }; 38 | 39 | class MxDualSlim 40 | { 41 | private: 42 | MxHeap heap; 43 | MxBlock target_edges; 44 | MxBlock face_nodes; 45 | 46 | protected: 47 | MxStdModel *m; 48 | MxDualModel *dual; 49 | MxFaceTree *tree; 50 | 51 | private: 52 | void initialize_node(uint); 53 | 54 | protected: 55 | MxDualSlimEdge *get_edge(uint i) { return &target_edges(i); } 56 | const MxDualSlimEdge *get_edge(uint i) const { return &target_edges(i); } 57 | 58 | void update_frame_bounds(MxFaceCluster&, const MxFaceList&); 59 | void update_node_bounds(uint); 60 | void compute_edge_info(MxDualSlimEdge *e); 61 | void contract(MxDualSlimEdge *e); 62 | 63 | public: 64 | bool weight_by_area; 65 | uint shape_policy; 66 | uint root_cluster_count; 67 | bool will_maintain_bounds; 68 | 69 | public: 70 | MxDualSlim(MxStdModel *m0, MxDualModel *d0, MxFaceTree *t0); 71 | 72 | MxDualSlimNode& node_info(uint i) { return face_nodes(i); } 73 | const MxDualSlimNode& node_info(uint i) const { return face_nodes(i); } 74 | 75 | void initialize(); 76 | bool aggregate(uint target); 77 | bool limit_aggregate(float maxerr); 78 | }; 79 | 80 | 81 | 82 | 83 | // MXDUALSLIM_INCLUDED 84 | #endif 85 | -------------------------------------------------------------------------------- /libgfx/doc/geom3d.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: 3-D Geometric Procedures 9 | 10 | 11 | 12 | 13 | 14 | 15 |

3-D Geometric Procedures

16 | 17 |

Triangles are a very common modeling primitive in many graphics 18 | applications. The libgfx library provides a package of routines for 19 | computing various geometric properties of triangles. 20 | To use this package you must include the standard header file 21 |

22 |     #include <gfx/geom3d.h>
23 | 
24 | Note that all of these functions assume that the corners of the triangle are 25 | listed in counter-clockwise order around the outward pointing normal. 26 | 27 |

You can compute the (signed) area of a triangle using the following 28 | function. Note that the area will be negative if the vertices are listed in 29 | clockwise order. 30 |

31 |     double triangle_area(const Vec3&, const Vec3&, const Vec3&);
32 | 
33 | 34 |

The following functions compute the plane defined by a triangle, and the 35 | corresponding normal vector. The standard versions always use unit normal 36 | vectors while the "raw" versions will use unscaled normals. 37 |

38 |     Vec3 triangle_normal(const Vec3&, const Vec3&, const Vec3&);
39 |     Vec4 triangle_plane(const Vec3&, const Vec3&, const Vec3&);
40 | 
41 |     Vec3 triangle_raw_normal(const Vec3&, const Vec3&, const Vec3&);
42 |     Vec4 triangle_raw_plane(const Vec3&, const Vec3&, const Vec3&);
43 | 
44 | 45 | 46 |

For some meshing applications, it may on occasion be necessary to assess 47 | the aspect ratio of a triangle. 48 |

49 |     double triangle_compactness(const Vec3&, const Vec3&, const Vec3&);
50 | 
51 | This function computes the "compactness" of a triangle. The returned value 52 | will be between 0 and 1, with 0 meaning a degenerate (area=0) triangle and 1 53 | meaning an equilateral triangle. The formula used, originally suggested by 54 | Andre Gueziec, is 4*sqrt(3) * Area / (L1 + L2 + L3) where Li is the squared 55 | length of side i of the triangle. 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /libgfx/include/gfx/config.h: -------------------------------------------------------------------------------- 1 | /* include/gfx/config.h. Generated by configure. */ 2 | /* This -*- C -*- file is meant to be processed by the configure script */ 3 | 4 | /* Define this if your compiler doesn't support the new C++ 'bool' type */ 5 | #define HAVE_BOOL 1 6 | 7 | /* Define if your system supports rint() */ 8 | #define HAVE_RINT 1 9 | 10 | /* Define if your system supports getrusage() */ 11 | /* #undef HAVE_GETRUSAGE */ 12 | 13 | /* Define if your system does not support getrusage() but supports times() */ 14 | #define HAVE_TIMES 1 15 | 16 | /* Define if your system supports random() as opposed to just rand() */ 17 | /* #undef HAVE_RANDOM */ 18 | 19 | /* Define if the STL hash_map template is available */ 20 | /* #undef HAVE_HASH_MAP */ 21 | 22 | /* Define if the STL hash_set template is available */ 23 | /* #undef HAVE_HASH_SET */ 24 | 25 | /* GCC v3 puts hash_map and hash_set in an 'ext' directory */ 26 | #define HAVE_EXT_HASH_MAP 1 27 | #define HAVE_EXT_HASH_SET 1 28 | 29 | /* Define if the STL valarray template is available */ 30 | #define HAVE_VALARRAY 1 31 | 32 | /* Define if the ANSI standard is available */ 33 | #define HAVE_SSTREAM 1 34 | 35 | /* Define if the pre-ANSI is available */ 36 | #define HAVE_STRSTREAM 1 37 | 38 | /* ***** GUI & Image configuration section ***** */ 39 | 40 | /* Define if the FLTK GUI toolkit is available */ 41 | #define HAVE_FLTK 1 42 | 43 | /* Define if FLTK OpenGL support is available */ 44 | #define HAVE_FLTK_GL 1 45 | 46 | /* Define if Sam Leffler's libtiff is available */ 47 | #define HAVE_LIBTIFF 1 48 | 49 | /* Define the libtiff LZW is available */ 50 | /* #undef HAVE_LIBTIFF_LZW */ 51 | 52 | /* Define if libpng is available */ 53 | #define HAVE_LIBPNG 0 54 | 55 | /* Define if the Independent JPEG Group's libjpeg is available */ 56 | #define HAVE_LIBJPEG 1 57 | 58 | /* ***** OpenGL configuration section ***** */ 59 | 60 | /* Define to the name of OpenGL implementation (e.g., "OpenGL" or "Mesa") */ 61 | #define HAVE_OPENGL "OpenGL" 62 | 63 | /* Define if glPolygonOffsetEXT is available */ 64 | /* #undef HAVE_POLYOFFSET_EXT */ 65 | 66 | /* Define if glPolygonOffset is available */ 67 | #define HAVE_POLYOFFSET 1 68 | 69 | /* Define if header is available */ 70 | /* #undef HAVE_GL_GLEXT_H */ 71 | 72 | /* Define if header is available */ 73 | /* #undef HAVE_GL_GLXEXT_H */ 74 | 75 | /* Define if header is available */ 76 | /* #undef HAVE_GL_WGLEXT_H */ 77 | -------------------------------------------------------------------------------- /libgfx/doc/vec3.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: Vector Math 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Vector Math

16 | 17 |

class Vec3

18 | 19 |

This class implements a 3-dimensional real-valued vector. 20 | Individual elements are represent with double precision 21 | floating point numbers. To use the Vec3 class you must 22 | include the header 23 |

24 |     #include <gfx/vec3.h>
25 | 
26 | 27 |

Constructor Methods

28 | 29 |

The Vec3 class defines the following set of constructors: 30 | 31 |

32 |     Vec3();                              // Initializes vector to (0 0 0).
33 |     Vec3(double x, double y, double z);  // Initializes vector to (x y z).
34 |     Vec3(double s);                      // Initializes vector to (s s s)
35 | 
36 |     Vec3(const Vec3& v);                 // 
37 |     Vec3(const float  v[3]);             // These copy values from v
38 |     Vec3(const double v[3]);             // 
39 | 
40 |     Vec3(const Vec2& v, double z);       // Initializes vector to (v[0] v[1] z)
41 | 
42 | 43 |

Specialized Functions

44 | 45 |

In addition to the standard functions provided by all vector classes, 46 | the Vec3 class defines certain specialized functions which 47 | operate only on 3-D vectors. 48 | 49 |

The cross product of two vectors v, w is a third 50 | vector which is perpendicular to both v and w. 51 | It can be computed with either a function call or an overloaded 52 | operator 53 | 54 |

55 |     u = cross(v, w);   // Equivalent ways of computing
56 |     u = v ^ w;         //    the cross product of v and w.
57 | 
58 | 59 |

Since 3-D vectors may be used to represent 2-D homogeneous 60 | coordinates, a projection function is provided. 61 |

62 |     Vec2 proj(const Vec3& v);
63 | 
64 | This routine takes a homogeneous vector (x y w) and returns the 65 | corresponding 2-D vector (x/w y/w). If w is 0 then 66 | the vector (x y) is returned. 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /mixkit/COPYING.txt: -------------------------------------------------------------------------------- 1 | MixKit -- Code library for multiresolution surface modeling 2 | Copyright (C) 1998-2000 Michael Garland. 3 | 4 | This library is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Library General Public License (subject 6 | to the clarifications and exceptions outlined below) as published by 7 | the Free Software Foundation; either version 2 of the License, or (at 8 | your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 | USA 19 | 20 | The complete text of the GNU Library General Public License can be 21 | found in the accompanying file LGPL.txt. 22 | 23 | ------------------------------------------------------------------------ 24 | Clarifications/Exceptions 25 | ------------------------------------------------------------------------ 26 | 27 | (1) If you link the MixKit library with other files to produce an 28 | executable, this does not by itself cause the resulting executable to 29 | be covered by the GNU General Public License. This includes static 30 | linking of the library. Your use of that executable is in no way 31 | restricted on account of linking the MixKit library code into it. 32 | This exception DOES NOT invalidate any other reasons why the 33 | executable file might be covered by the GNU General Public License 34 | 35 | (2) A few pieces of code in this library have been adapted from other 36 | sources and may be distributed under terms other than the LGPL. 37 | Further details can be found in the relevant files. 38 | 39 | - MxTriProject.cxx contains code which is copyrighted by 40 | Hugues Hoppe and is free for non-commercial use only. 41 | 42 | - The getopt* files were taken from the GNU C Library v2.0.4 43 | and are copyrighted by the FSF. They are still covered by 44 | the LGPL. 45 | 46 | - MxMat[34]-jacobi.cxx are both derived in part from Numerical 47 | Recipes in C. They are free for non-commercial use only. 48 | 49 | - The intersection code in MxFitFrame-2.cxx was written by 50 | David Eberly, but it may be freely distributed. 51 | -------------------------------------------------------------------------------- /libgfx/src/wintools.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Support code for handling various tasks under Win32 4 | 5 | $Id: wintools.cxx,v 1.1 2002/03/19 20:47:22 garland Exp $ 6 | 7 | ************************************************************************/ 8 | 9 | #include 10 | 11 | HGLRC create_glcontext(HDC dc) 12 | { 13 | HGLRC context = wglCreateContext(dc); 14 | if( context ) 15 | { 16 | if( !wglMakeCurrent(dc, context) ) 17 | { 18 | // Destroy context if it fails to bind 19 | wglDeleteContext(context); 20 | context = NULL; 21 | } 22 | } 23 | 24 | return context; 25 | } 26 | 27 | int set_pixel_format(HDC dc) 28 | { 29 | PIXELFORMATDESCRIPTOR pixelDesc; 30 | 31 | // 32 | // These are the important fields of the PFD 33 | // 34 | pixelDesc.nSize = sizeof(PIXELFORMATDESCRIPTOR); 35 | pixelDesc.nVersion = 1; 36 | 37 | pixelDesc.dwFlags = 38 | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | 39 | PFD_DOUBLEBUFFER | PFD_STEREO_DONTCARE; 40 | pixelDesc.iPixelType = PFD_TYPE_RGBA; 41 | pixelDesc.cColorBits = 24; 42 | pixelDesc.iLayerType = PFD_MAIN_PLANE; 43 | 44 | // 45 | // According to the docs, these can be/are ignored. 46 | // 47 | pixelDesc.cRedBits = 8; 48 | pixelDesc.cRedShift = 16; 49 | pixelDesc.cGreenBits = 8; 50 | pixelDesc.cGreenShift = 8; 51 | pixelDesc.cBlueBits = 8; 52 | pixelDesc.cBlueShift = 0; 53 | pixelDesc.cAlphaBits = 0; 54 | pixelDesc.cAlphaShift = 0; 55 | pixelDesc.cAccumBits = 0; 56 | pixelDesc.cAccumRedBits = 0; 57 | pixelDesc.cAccumGreenBits = 0; 58 | pixelDesc.cAccumBlueBits = 0; 59 | pixelDesc.cAccumAlphaBits = 0; 60 | pixelDesc.cDepthBits = 32; 61 | pixelDesc.cStencilBits = 0; 62 | pixelDesc.cAuxBuffers = 0; 63 | pixelDesc.bReserved = 0; 64 | pixelDesc.dwLayerMask = 0; 65 | pixelDesc.dwVisibleMask = 0; 66 | pixelDesc.dwDamageMask = 0; 67 | 68 | 69 | int pixel_format = ChoosePixelFormat(dc, &pixelDesc); 70 | if( !pixel_format ) 71 | { 72 | // Try and guess a decent default pixel format 73 | pixel_format = 1; 74 | if( !DescribePixelFormat(dc, pixel_format, 75 | sizeof(PIXELFORMATDESCRIPTOR), &pixelDesc) ) 76 | return NULL; 77 | } 78 | 79 | if( !SetPixelFormat(dc, pixel_format, &pixelDesc) ) 80 | return NULL; 81 | 82 | return pixel_format; 83 | } 84 | -------------------------------------------------------------------------------- /libgfx/tests/t-img.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | The images produced by this test are checkboard gradients. They 4 | ramp from black in the upper left corner to full color in the lower 5 | right corner. 6 | 7 | by Michael Garland, 1999. 8 | 9 | $Id: t-img.cxx,v 1.2 2000/08/19 03:37:26 garland Exp $ 10 | 11 | ************************************************************************/ 12 | 13 | #include 14 | #include 15 | 16 | static 17 | void grayscale_test() 18 | { 19 | ByteRaster img(256, 256, 1); 20 | 21 | int i, j, c; 22 | 23 | for(i=0; i 14 | #include 15 | #include "qslim.h" 16 | 17 | static ostream& vfcount(ostream& out, uint v, uint f) 18 | { 19 | return out << "(" << v << "v/" << f << "f)"; 20 | } 21 | 22 | void startup_and_input(int argc, char **argv) 23 | { 24 | smf = new MxSMFReader; 25 | 26 | process_cmdline(argc, argv); 27 | if( m->face_count() == 0 ) 28 | { 29 | smf->read(cin, m); 30 | } 31 | 32 | output_preamble(); 33 | } 34 | 35 | int main(int argc, char **argv) 36 | { 37 | double input_time, init_time, slim_time, output_time; 38 | 39 | // Process command line and read input model(s) 40 | // 41 | TIMING(input_time, startup_and_input(argc, argv)); 42 | 43 | if(!be_quiet) cerr << "+ Initial model "; 44 | if(!be_quiet) vfcount(cerr, m->vert_count(), m->face_count()) << endl; 45 | 46 | // Initial simplification process. Collect contractions and build heap. 47 | // 48 | TIMING(init_time, slim_init()); 49 | 50 | // Decimate model until target is reached 51 | // 52 | TIMING(slim_time, slim->decimate(face_target)); 53 | 54 | if(!be_quiet) cerr << "+ Simplified model "; 55 | if(!be_quiet) vfcount(cerr, slim->valid_verts, slim->valid_faces) << endl; 56 | 57 | // Output the result 58 | // 59 | TIMING(output_time, output_final_model()); 60 | 61 | if( !be_quiet ) 62 | { 63 | cerr << endl << endl; 64 | cerr << "+ Running time" << endl; 65 | cerr << " Setup : " << input_time << " sec" << endl; 66 | cerr << " QSlim init : " << init_time << " sec" << endl; 67 | cerr << " QSlim run : " << slim_time << " sec" << endl; 68 | cerr << " Output : " << output_time << " sec" << endl; 69 | cerr << endl; 70 | cerr << " Total : " 71 | << input_time+init_time+slim_time+output_time <valid_faces << " " << init_time+slim_time << endl; 76 | } 77 | 78 | slim_cleanup(); 79 | 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /mixkit/src/MxFitFrame.h: -------------------------------------------------------------------------------- 1 | #ifndef MXFITFRAME_INCLUDED // -*- C++ -*- 2 | #define MXFITFRAME_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxFitFrame 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxFitFrame.h,v 1.9 1999/05/12 17:58:57 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxFrame.h" 18 | #include "MxQMetric3.h" 19 | 20 | #ifdef min 21 | # undef min 22 | #endif 23 | #ifdef max 24 | # undef max 25 | #endif 26 | 27 | class MxFitFrame : public MxFrame 28 | { 29 | private: 30 | double vmin[3], vmax[3]; // Bounding box in local frame 31 | double axis_evals[3]; // Eigenvalues from prin. component analysis 32 | 33 | double normal_accum[3], avg_normal[3]; 34 | 35 | public: 36 | MxFitFrame(); 37 | MxFitFrame(double *c, double *u0, double *u1, double *u2); 38 | MxFitFrame(const MxQuadric3&, uint nverts); 39 | 40 | double *min() { return vmin; } 41 | const double *min() const { return vmin; } 42 | double *max() { return vmax; } 43 | const double *max() const { return vmax; } 44 | 45 | double *normal() { return avg_normal; } 46 | const double *normal() const { return avg_normal; } 47 | double *total_normal() { return normal_accum; } 48 | const double *total_normal() const { return normal_accum; } 49 | 50 | void set_normal(const double *); 51 | void add_normal(const double *); 52 | void clear_normal(); 53 | void finalize_normal(); 54 | 55 | bool compute_frame(const MxQuadric3&, uint nverts); 56 | bool compute_frame(const float *, const float *, const float *); 57 | void reset_bounds(); 58 | void accumulate_bounds(const MxFitFrame&); 59 | void accumulate_bounds(const float *, uint npoint=1); 60 | void accumulate_bounds(const double *, uint npoint=1); 61 | 62 | bool check_intersection(const MxFitFrame&) const; 63 | void worldspace_corners(Vec3 *) const; 64 | 65 | double compute_closest_distance(const double *v, double *w=NULL) const; 66 | double compute_closest_sqrdistance(const double *v, double *w=NULL) const; 67 | double compute_max_distance(const double *v) const; 68 | double compute_max_sqrdistance(const double *v) const; 69 | void compute_distance_bounds(const MxFitFrame&,double *,double *) const; 70 | }; 71 | 72 | extern void mx_draw_fitframe(const MxFitFrame&, float rgbscale=1.0f); 73 | 74 | // MXFITFRAME_INCLUDED 75 | #endif 76 | -------------------------------------------------------------------------------- /mixkit/src/MxGLUtils.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | MxGLUtils 4 | 5 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 6 | 7 | $Id: MxGLUtils.cxx,v 1.7 2000/02/24 23:07:02 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include "stdmix.h" 12 | #include "MxGLUtils.h" 13 | 14 | GLenum mxgl_matrix_for_mode(GLenum mode) 15 | { 16 | switch( mode ) 17 | { 18 | case GL_MODELVIEW: return GL_MODELVIEW_MATRIX; 19 | case GL_PROJECTION: return GL_PROJECTION_MATRIX; 20 | case GL_TEXTURE: return GL_TEXTURE_MATRIX; 21 | } 22 | 23 | return GL_FALSE; 24 | } 25 | 26 | int mxgl_unproject_pixel(int *pixel, double *world, double z) 27 | { 28 | GLdouble modelMatrix[16]; 29 | GLdouble projMatrix[16]; 30 | GLint viewport[4]; 31 | 32 | glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); 33 | glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); 34 | glGetIntegerv(GL_VIEWPORT, viewport); 35 | 36 | // Notice that we have to correct the y pixel coordinate. GL 37 | // assigns the origin to the lower left corner, while FLTK assigns 38 | // the origin to the upper left corner. 39 | return gluUnProject(pixel[0], viewport[3]-pixel[1], z, 40 | modelMatrix, projMatrix, viewport, 41 | world, world+1, world+2); 42 | } 43 | 44 | const unsigned int MXGL_PICK_NIL=(~0); 45 | const unsigned int MXGL_PICK_ZMAX=(~0); 46 | 47 | void mxgl_begin_pick(int *where, double radius, GLuint *buffer, int size) 48 | { 49 | GLint vp[4]; 50 | 51 | glMatrixMode(GL_PROJECTION); 52 | glPushMatrix(); // Save the current transformation 53 | glLoadIdentity(); 54 | glGetIntegerv(GL_VIEWPORT, vp); 55 | glSelectBuffer(size, buffer); 56 | glRenderMode(GL_SELECT); 57 | 58 | gluPickMatrix(where[0], vp[3] - where[1], radius, radius, vp); 59 | glInitNames(); 60 | glPushName(MXGL_PICK_NIL); 61 | } 62 | 63 | 64 | unsigned int mxgl_complete_pick(GLuint *buffer) 65 | { 66 | glFlush(); 67 | 68 | GLint nhits = glRenderMode(GL_RENDER); 69 | GLuint hit = MXGL_PICK_NIL; 70 | GLuint zmin = MXGL_PICK_ZMAX; 71 | GLuint *ptr = buffer; 72 | 73 | for(uint i=0; i 21 | class MxDynBlock : public MxBlock 22 | { 23 | private: 24 | int fill; 25 | 26 | public: 27 | MxDynBlock(int n=2) : MxBlock(n) { fill=0; } 28 | 29 | int length() const { return fill; } 30 | int total_space() const { return MxBlock::length(); } 31 | 32 | int last_id() const { return fill-1; } 33 | T& last() { return (*this)[last_id()]; } 34 | const T& last() const { return (*this)[last_id()]; } 35 | 36 | void room_for(int len) 37 | { 38 | if( length()resize(len); 39 | fill = len; 40 | } 41 | 42 | T& add() 43 | { 44 | if( length()==total_space() ) this->resize(total_space() * 2); 45 | fill++; 46 | return last(); 47 | } 48 | 49 | void add(const T& t) { add() = t; } 50 | 51 | void reset() { fill = 0; } 52 | T& drop() { return (*this)[--fill]; } 53 | void drop(int d) { fill -= d; } 54 | 55 | void remove(int i) { (*this)[i] = (*this)[--fill]; } 56 | void remove_inorder(int i) 57 | { memmove(&(*this)[i], &(*this)[i+1], (--fill - i)*sizeof(T)); } 58 | 59 | // Restricted STL-like interface for interoperability with 60 | // STL-based code. Overrides select MxBlock<> definitions and 61 | // introduces some additional std::vector-like methods. 62 | // 63 | int size() const { return length(); } 64 | 65 | typename MxBlock::iterator end() { return this->begin()+size(); } 66 | typename MxBlock::const_iterator end() const { return this->begin()+size(); } 67 | 68 | void push_back(const T& t) { add(t); } 69 | }; 70 | 71 | template 72 | class MxSizedDynBlock : public MxDynBlock 73 | { 74 | public: MxSizedDynBlock(uint n=T_SIZE) : MxDynBlock(n) { } 75 | }; 76 | 77 | template 78 | inline bool varray_find(const MxDynBlock& A, const T& t, uint *index=NULL) 79 | { 80 | for(unsigned int i=0; i 19 | using namespace std; 20 | #include 21 | 22 | #ifdef UINT_MAX 23 | # define MXID_NIL UINT_MAX 24 | #else 25 | # define MXID_NIL 0xffffffffU 26 | #endif 27 | 28 | #if !defined(HAVE_UINT) && !defined(uint) 29 | typedef unsigned int uint; 30 | #endif 31 | 32 | #if !defined(HAVE_USHORT) && !defined(ushort) 33 | typedef unsigned short ushort; 34 | #endif 35 | 36 | #ifdef MIN 37 | #undef MIN 38 | #endif 39 | #ifdef MAX 40 | #undef MAX 41 | #endif 42 | 43 | #define MIN(a,b) (((a)>(b))?(b):(a)) 44 | #define MAX(a,b) (((a)>(b))?(a):(b)) 45 | 46 | #ifndef ABS 47 | # define ABS(x) (((x)<0)?-(x):(x)) 48 | #endif 49 | 50 | #ifndef MIX_NO_AXIS_NAMES 51 | enum Axis {X=0, Y=1, Z=2, W=3}; 52 | #endif 53 | 54 | inline bool streq(const char *a, const char *b) { return !strcmp(a,b); } 55 | 56 | //////////////////////////////////////////////////////////////////////// 57 | // 58 | // Optimization control, debugging, and error reporting facilities 59 | // 60 | 61 | // 62 | // Safety levels: 63 | // 64 | // -2 Reckless 65 | // -1 Optimized 66 | // 0 Normal 67 | // 1 Cautious 68 | // 2 Paranoid 69 | // 70 | #ifndef SAFETY 71 | // Default safety policy is to take the middle of the road 72 | #define SAFETY 0 73 | #endif 74 | 75 | #include "mixmsg.h" 76 | 77 | #define fatal_error(s) mxmsg_signal(MXMSG_FATAL, s, NULL, __FILE__, __LINE__) 78 | 79 | #ifdef assert 80 | # undef assert 81 | #endif 82 | 83 | #if SAFETY >= 0 84 | # define assert(i) (i)?((void)NULL):mxmsg_signal(MXMSG_ASSERT, # i, \ 85 | NULL, __FILE__, __LINE__) 86 | # define CAREFUL(x) x 87 | #else 88 | # define assert(i) 89 | # define CAREFUL(x) 90 | #endif 91 | 92 | #if SAFETY==2 93 | # define SanityCheck(t) assert(t) 94 | # define PARANOID(x) x 95 | #else 96 | # define SanityCheck(t) 97 | # define PARANOID(x) 98 | #endif 99 | 100 | #if SAFETY > 0 101 | # define AssertBound(t) assert(t) 102 | # define PRECAUTION(x) x 103 | #else 104 | # define AssertBound(t) 105 | # define PRECAUTION(x) 106 | #endif 107 | 108 | // STDMIX_INCLUDED 109 | #endif 110 | -------------------------------------------------------------------------------- /libgfx/include/gfx/gfx.h: -------------------------------------------------------------------------------- 1 | #ifndef GFX_INCLUDED // -*- C++ -*- 2 | #define GFX_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Main header file for the libgfx graphics library. 10 | 11 | $Id: gfx.h,v 1.7 2002/09/11 18:51:19 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #if defined(HAVE_CONFIG_H) 16 | # include "config.h" 17 | #elif defined(_MSC_VER) 18 | # include "config-vc.h" 19 | #endif 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | //////////////////////////////////////////////////////////////////////// 27 | // 28 | // Standards notwithstanding, not all platforms define exactly the 29 | // same things in their header files. We try to compensate here. 30 | // 31 | 32 | #if !defined(HAVE_BOOL) 33 | typedef int bool; 34 | const bool false = 0; 35 | const bool true = 1; 36 | #endif 37 | 38 | // Microsoft doesn't define std::min() & std::max() because it conflicts with 39 | // , and their _MIN/_MAX macro workarounds don't add the std:: 40 | // namespace qualification. These macros provide a uniform way of getting 41 | // around this problem. 42 | // 43 | #if defined(_MSC_VER) 44 | # define MIN(a,b) std::_cpp_min(a,b) 45 | # define MAX(a,b) std::_cpp_max(a,b) 46 | #else 47 | # define MIN(a,b) std::min(a,b) 48 | # define MAX(a,b) std::max(a,b) 49 | #endif 50 | 51 | #ifndef M_PI 52 | # define M_PI 3.14159265358979323846264338327950288419716939937510582097494459 53 | #endif 54 | 55 | #if !defined(HUGE) && defined(HUGE_VAL) 56 | # define HUGE HUGE_VAL 57 | #endif 58 | 59 | #if !defined(HAVE_RINT) 60 | inline double rint(double x) { return floor(x + 0.5); } 61 | #endif 62 | 63 | //////////////////////////////////////////////////////////////////////// 64 | // 65 | // 66 | // 67 | 68 | #if defined(HAVE_RANDOM) 69 | inline double random1() { return (double)random() / (double)LONG_MAX; } 70 | inline char random_byte() { return (char)(random() & 0xff); } 71 | #else 72 | inline double random1() { return (double)rand() / (double)RAND_MAX; } 73 | inline char random_byte() { return (char)(rand() & 0xff); } 74 | #endif 75 | 76 | const double FEQ_EPS = 1e-6; 77 | const double FEQ_EPS2 = 1e-12; 78 | 79 | inline bool FEQ(double a, double b, double e=FEQ_EPS) {return fabs(a-b) edge_list; 39 | 40 | 41 | MxBlock edge_links; // 1 per vertex 42 | MxBlock __quadrics; // 1 per vertex 43 | 44 | // 45 | // Temporary variables used by methods 46 | MxVertexList star, star2; 47 | MxPairContraction conx_tmp; 48 | 49 | protected: 50 | uint compute_dimension(MxStdModel *); 51 | void pack_to_vector(MxVertexID, MxVector&); 52 | void unpack_from_vector(MxVertexID, MxVector&); 53 | uint prop_count(); 54 | void pack_prop_to_vector(MxVertexID, MxVector&, uint); 55 | void unpack_prop_from_vector(MxVertexID, MxVector&, uint); 56 | 57 | void compute_face_quadric(MxFaceID, MxQuadric&); 58 | void collect_quadrics(); 59 | 60 | void create_edge(MxVertexID, MxVertexID); 61 | void collect_edges(); 62 | void constrain_boundaries(); 63 | void discontinuity_constraint(MxVertexID, MxVertexID, const MxFaceList&); 64 | void compute_edge_info(edge_info *); 65 | void finalize_edge_update(edge_info *); 66 | void compute_target_placement(edge_info *); 67 | 68 | void apply_contraction(const MxPairContraction&, edge_info *); 69 | void update_pre_contract(const MxPairContraction&); 70 | 71 | public: 72 | bool will_decouple_quadrics; 73 | 74 | public: 75 | MxPropSlim(MxStdModel *); 76 | 77 | uint dim() const { return D; } 78 | 79 | void consider_color(bool will=true); 80 | void consider_texture(bool will=true); 81 | void consider_normals(bool will=true); 82 | 83 | uint quadric_count() const { return __quadrics.length(); } 84 | MxQuadric& quadric(uint i) { return *(__quadrics(i)); } 85 | const MxQuadric& quadric(uint i) const { return *(__quadrics(i)); } 86 | 87 | 88 | void initialize(); 89 | bool decimate(uint); 90 | 91 | }; 92 | 93 | // MXPROPSLIM_INCLUDED 94 | #endif 95 | -------------------------------------------------------------------------------- /libgfx/include/gfx/config-vc.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Visual C++ 5/6 configuration header. 4 | Manually generated from config.h.in. 5 | 6 | ************************************************************************/ 7 | 8 | /* Define this if your compiler doesn't support the new C++ 'bool' type */ 9 | #define HAVE_BOOL 1 10 | 11 | /* Define if your system supports rint() */ 12 | /* #define HAVE_RINT 1 */ 13 | 14 | /* Define if your system supports getrusage() */ 15 | /* #undef HAVE_GETRUSAGE */ 16 | 17 | /* Define if your system does not support getrusage() but supports times() */ 18 | /* #undef HAVE_TIMES */ 19 | 20 | /* Define if your system supports random() as opposed to just rand() */ 21 | /* #undef HAVE_RANDOM */ 22 | 23 | /* Define if the STL hash_map template is available */ 24 | /* #undef HAVE_HASH_MAP */ 25 | 26 | /* Define if the STL hash_set template is available */ 27 | /*#undef HAVE_HASH_SET */ 28 | 29 | /* GCC v3 puts hash_map and hash_set in an 'ext' directory */ 30 | /* #undef HAVE_EXT_HASH_MAP */ 31 | /* #undef HAVE_EXT_HASH_SET */ 32 | 33 | /* Define if the STL valarray template is available */ 34 | #define HAVE_VALARRAY 1 35 | 36 | /* Define if the ANSI standard is available */ 37 | #define HAVE_SSTREAM 1 38 | 39 | /* Define if the pre-ANSI is available */ 40 | /* #undef HAVE_STRSTREAM */ 41 | 42 | /* Define if the FLTK GUI toolkit is available */ 43 | #define HAVE_FLTK 1 44 | 45 | /* Define if FLTK OpenGL support is available */ 46 | #define HAVE_FLTK_GL 1 47 | 48 | /* Define if Sam Leffler's libtiff is available */ 49 | #define HAVE_LIBTIFF 1 50 | 51 | /* Define if libpng is available */ 52 | #define HAVE_LIBPNG 1 53 | 54 | /* Define if the Independent JPEG Group's libjpeg is available */ 55 | #define HAVE_LIBJPEG 1 56 | 57 | /* ***** OpenGL configuration section ***** */ 58 | 59 | /* Define to the name of OpenGL implementation (e.g., "OpenGL" or "Mesa") */ 60 | #define HAVE_OPENGL "OpenGL" 61 | 62 | /* Define if glPolygonOffsetEXT is available */ 63 | /* #undef HAVE_POLYOFFSET_EXT */ 64 | 65 | /* Define if glPolygonOffset is available */ 66 | #define HAVE_POLYOFFSET 1 67 | 68 | /* Define if header is available */ 69 | #define HAVE_GL_GLEXT_H 1 70 | 71 | /* Define if header is available */ 72 | /* #undef HAVE_GL_GLXEXT_H */ 73 | 74 | /* Define if header is available */ 75 | #define HAVE_GL_WGLEXT_H 1 76 | 77 | /* Visual C++ gets confused by too many casting and [] operators */ 78 | #define HAVE_CASTING_LIMITS 1 79 | 80 | #if defined(_DEBUG) && defined(_MSC_VER) 81 | // STL makes Visual C++ complain about identifiers longer than 255 82 | // characters. Unfortunately, this may limit the debugability of 83 | // code that uses STL. 84 | #pragma warning (disable : 4786) 85 | #endif 86 | -------------------------------------------------------------------------------- /libgfx/doc/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: A Library for Writing Graphics Programs 9 | 10 | 11 | 12 | 13 | 14 | 15 |

libgfx: A Graphics Library

16 | 17 |

This software and associated documentation files are 18 | Copyright © 1999–2001 Michael Garland. 19 | Please see the accompanying License 20 | for details. 21 | 22 | 23 |

Contents

24 | 25 | 61 | 62 | 63 |

Introduction

64 | 65 |

The purpose of this library is to simplify the creation of computer 66 | graphics software. Specifically, it is targeted towards 67 | cross-platform development using the 68 | OpenGL rendering API and the 69 | FLTK interface toolkit. 70 | It is derived from the MixKit library I 72 | developed for supporting polygonal 73 | surface 74 | simplification. 75 | This is not a full-fledged graphics engine. Rather it 76 | provides facilities which are useful in the majority of graphics 77 | programs. 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /mixkit/src/MxStdGUI.h: -------------------------------------------------------------------------------- 1 | #ifndef MXSTDGUI_INCLUDED // -*- C++ -*- 2 | #define MXSTDGUI_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | GUI framework for building applications that use MxStdModel surface 10 | model objects. 11 | 12 | Copyright (C) 1999 Michael Garland. See "COPYING.txt" for details. 13 | 14 | $Id: MxStdGUI.h,v 1.10 2000/12/14 17:49:11 garland Exp $ 15 | 16 | ************************************************************************/ 17 | 18 | #include "MxGL.h" 19 | #include "MxGUI.h" 20 | #include "MxAsp.h" 21 | #include "MxStdModel.h" 22 | 23 | #include "MxGeom3D.h" 24 | #include 25 | #include "MxCamera.h" 26 | 27 | class MxStdGUI : public MxGUI 28 | { 29 | private: 30 | uint selection_state; 31 | 32 | protected: 33 | MxDynBlock models; 34 | uint current; 35 | 36 | MxBounds bounds; 37 | Arcball arcball; 38 | MxCamera camera; 39 | 40 | uint pick_something(int *where, double radius, uint mode); 41 | void begin_redraw(); 42 | void end_redraw(); 43 | void default_colors(); 44 | 45 | public: 46 | // Inherited application methods overridden here 47 | virtual void initialize(int argc, char **argv, 48 | Fl_Menu_Item *layout=NULL, 49 | int xw=640, int yw=480); 50 | 51 | // Inherited GUI methods that are overridden here 52 | // 53 | virtual void setup_for_drawing(); 54 | virtual void draw_contents(); 55 | virtual bool mouse_down(int *where, int which); 56 | virtual bool mouse_up(int *where, int which); 57 | virtual bool mouse_drag(int *where, int *last, int which); 58 | virtual void cmdline_file(const char *file); 59 | 60 | // New GUI methods that may be overriden by the application 61 | // 62 | virtual void draw_custom_contents(MxStdModel *) { } 63 | 64 | public: 65 | // Public interface introduced in this class 66 | // 67 | MxStdGUI(); 68 | 69 | void asp_setup(MxAspStore *store); 70 | 71 | void attach_model(MxStdModel *m0) { attach_models(&m0); } 72 | void attach_models(MxStdModel **m0, uint count=1); 73 | void select_model(uint); 74 | MxStdModel *model() { return models(current); } 75 | MxStdModel *model(uint i) { return models(i); } 76 | 77 | uint pick_face(int *where); 78 | uint pick_vertex(int *where); 79 | 80 | uint selected_vertex, selected_face; 81 | 82 | bool will_draw_surface; 83 | bool will_draw_mesh; 84 | bool will_draw_points; 85 | bool will_draw_texture; 86 | bool will_draw_color; 87 | bool will_light_scene; 88 | bool will_smooth_lines; 89 | 90 | double surface_color[3]; 91 | double background_color[3]; 92 | double mesh_color[3]; 93 | double line_width; 94 | }; 95 | 96 | // MXSTDGUI_INCLUDED 97 | #endif 98 | -------------------------------------------------------------------------------- /tools/filters/Makefile: -------------------------------------------------------------------------------- 1 | include ../../mixkit/mix-config 2 | 3 | COMMON_SRCS = cmdline.cxx 4 | COMMON_OBJS = $(COMMON_SRCS:.cxx=.o) 5 | ALL_SRCS = $(COMMON_SRCS) smfclean.cxx smfstitch.cxx smfcat.cxx \ 6 | smfmeasure.cxx smfedgelist.cxx \ 7 | smf2ply.cxx smf2ldmesh.cxx smf2c.cxx smfsphere.cxx smfrefine.cxx \ 8 | smfquadric.cxx smfboundary.cxx smferror.cxx ply2smf.cxx \ 9 | smf2iv.cxx smf2flat.cxx 10 | PROGS = smfclean smfstitch smfcat smfmeasure smfedgelist \ 11 | smf2ply smf2ldmesh smf2c smfsphere smfrefine smfquadric \ 12 | smfboundary smferror ply2smf smf2iv smf2flat 13 | 14 | all: $(PROGS) 15 | 16 | qsmooth: qsmooth.o $(COMMON_OBJS) 17 | $(CXX) -o qsmooth qsmooth.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 18 | 19 | smfclean: smfclean.o $(COMMON_OBJS) 20 | $(CXX) -o smfclean smfclean.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 21 | 22 | smfstitch: smfstitch.o $(COMMON_OBJS) 23 | $(CXX) -o smfstitch smfstitch.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 24 | 25 | smfcat: smfcat.o $(COMMON_OBJS) 26 | $(CXX) -o smfcat smfcat.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 27 | 28 | smfmeasure: smfmeasure.o $(COMMON_OBJS) 29 | $(CXX) -o smfmeasure smfmeasure.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 30 | 31 | smfedgelist: smfedgelist.o $(COMMON_OBJS) 32 | $(CXX) -o smfedgelist smfedgelist.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 33 | 34 | smf2ply: smf2ply.o $(COMMON_OBJS) 35 | $(CXX) -o smf2ply smf2ply.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 36 | 37 | smf2ldmesh: smf2ldmesh.o $(COMMON_OBJS) 38 | $(CXX) -o smf2ldmesh smf2ldmesh.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 39 | 40 | smf2c: smf2c.o $(COMMON_OBJS) 41 | $(CXX) -o smf2c smf2c.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 42 | 43 | smf2iv: smf2iv.o $(COMMON_OBJS) 44 | $(CXX) -o smf2iv smf2iv.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 45 | 46 | smf2flat: smf2flat.o $(COMMON_OBJS) 47 | $(CXX) -o smf2flat smf2flat.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 48 | 49 | smfsphere: smfsphere.o $(COMMON_OBJS) 50 | $(CXX) -o smfsphere smfsphere.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 51 | 52 | smfrefine: smfrefine.o $(COMMON_OBJS) 53 | $(CXX) -o smfrefine smfrefine.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 54 | 55 | smfquadric: smfquadric.o $(COMMON_OBJS) 56 | $(CXX) -o smfquadric smfquadric.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 57 | 58 | smfboundary: smfboundary.o $(COMMON_OBJS) 59 | $(CXX) -o smfboundary smfboundary.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 60 | 61 | smferror: smferror.o $(COMMON_OBJS) 62 | $(CXX) -o smferror smferror.o $(COMMON_OBJS) $(LDFLAGS) $(LIBMIX) -lm 63 | 64 | ply2smf: ply2smf.o plyfile.o 65 | $(CXX) -o ply2smf ply2smf.o plyfile.o $(LDFLAGS) $(LIBMIX) -lm 66 | 67 | strip: 68 | strip $(PROGS) 69 | 70 | clean: 71 | -$(RM) -f $(ALL_SRCS:.cxx=.o) $(PROGS) 72 | 73 | depend: 74 | $(CXX_DEPEND) $(ALL_SRCS) > Makefile.dep 75 | 76 | -include Makefile.dep 77 | -------------------------------------------------------------------------------- /tools/filters/smf2c.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smf2c 4 | 5 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 6 | 7 | $Id: smf2c.cxx,v 1.2 2000/06/09 20:38:38 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include 12 | #include "cmdline.h" 13 | 14 | static 15 | void output_c(MxStdModel *m, ostream& out) 16 | { 17 | uint i; 18 | 19 | out << "#define vert_count " << m->vert_count() << endl; 20 | out << "static" << endl 21 | << "float v[vert_count][3] = {" << endl; 22 | 23 | for(i=0; ivert_count(); i++) 24 | { 25 | out << " {" << m->vertex(i)[X] 26 | << ", " << m->vertex(i)[Y] 27 | << ", " << m->vertex(i)[Z] 28 | << "}," << endl; 29 | } 30 | out << "};" << endl; 31 | 32 | if( m->normal_binding() != MX_UNBOUND ) 33 | { 34 | out << endl; 35 | out << "#define normal_count " << m->normal_count() << endl; 36 | out << "static" << endl 37 | << "float n[normal_count][3] = {" << endl; 38 | for(i=0; inormal_count(); i++) 39 | { 40 | out << " {" << m->normal(i)[X] 41 | << ", " << m->normal(i)[Y] 42 | << ", " << m->normal(i)[Z] 43 | << "}," << endl; 44 | } 45 | out << "};" << endl; 46 | } 47 | 48 | out << endl; 49 | out << "#define face_count " << m->face_count() << endl; 50 | out << "static" << endl 51 | << "unsigned int f[face_count][3] = {" << endl; 52 | for(i=0; iface_count(); i++) 53 | { 54 | out << " {" << m->face(i)[0] 55 | << ", " << m->face(i)[1] 56 | << ", " << m->face(i)[2] 57 | << "}," << endl; 58 | } 59 | out << "};" << endl; 60 | 61 | out << endl; 62 | out << "glBegin(GL_TRIANGLES);" << endl; 63 | out << " for(uint i=0; inormal_binding() == MX_PERFACE) 66 | out << " glNormal3fv(n[i]);" << endl; 67 | if( m->normal_binding() == MX_PERVERTEX ) 68 | out << " glNormal3fv(n[f[i][0]]);" << endl; 69 | out << " glVertex3fv(v[f[i][0]]);" << endl; 70 | if( m->normal_binding() == MX_PERVERTEX ) 71 | out << " glNormal3fv(n[f[i][1]]);" << endl; 72 | out << " glVertex3fv(v[f[i][1]]);" << endl; 73 | if( m->normal_binding() == MX_PERVERTEX ) 74 | out << " glNormal3fv(n[f[i][2]]);" << endl; 75 | out << " glVertex3fv(v[f[i][2]]);" << endl; 76 | out << " }" << endl; 77 | out << "glEnd();" << endl; 78 | } 79 | 80 | int main(int argc, char *argv[]) 81 | { 82 | MxStdModel *m = process_cmdline(argc, argv); 83 | if( !m ) return 1; 84 | 85 | if( m->normal_binding() == MX_UNBOUND ) 86 | { 87 | m->normal_binding(MX_PERFACE); 88 | m->synthesize_normals(); 89 | } 90 | 91 | output_c(m, cout); 92 | delete m; 93 | return 0; 94 | } 95 | -------------------------------------------------------------------------------- /tools/qslim/qslim.h: -------------------------------------------------------------------------------- 1 | #ifndef QSLIM_INCLUDED // -*- C++ -*- 2 | #define QSLIM_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | QSlim header file 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: qslim.h,v 1.17.2.1 2002/01/31 19:53:14 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include 18 | #include 19 | 20 | #define QSLIM_VERSION 2100 21 | #define QSLIM_VERSION_STRING "2.1" 22 | 23 | typedef MxDynBlock QSlimLog; 24 | 25 | enum OutputFormat { SMF, PM, MMF, LOG, IV, VRML }; 26 | 27 | //////////////////////////////////////////////////////////////////////// 28 | // 29 | // Globally visible (configuration) variables 30 | // 31 | 32 | extern unsigned int face_target; 33 | extern bool will_use_fslim; 34 | extern int placement_policy; 35 | extern double boundary_weight; 36 | extern int weighting_policy; 37 | extern bool will_record_history; 38 | extern double compactness_ratio; 39 | extern double meshing_penalty; 40 | extern bool will_join_only; 41 | extern bool be_quiet; 42 | extern OutputFormat output_format; 43 | extern char *output_filename; 44 | 45 | extern MxSMFReader *smf; 46 | extern MxStdModel *m; 47 | extern MxStdModel *m_orig; 48 | extern MxQSlim *slim; 49 | extern MxEdgeQSlim *eslim; 50 | extern MxFaceQSlim *fslim; 51 | extern QSlimLog *history; 52 | extern MxDynBlock *target_edges; 53 | 54 | extern bool (*unparsed_hook)(char *, int, char*[], MxStdModel&); 55 | 56 | //////////////////////////////////////////////////////////////////////// 57 | // 58 | // Command line parsing and application initialization 59 | // 60 | 61 | extern void process_cmdline(int argc, char **argv); 62 | extern void slim_init(); 63 | extern void slim_cleanup(); 64 | extern void input_file(const char *); 65 | extern void defer_file_inclusion(char *); 66 | extern void include_deferred_files(); 67 | extern void slim_history_callback(const MxPairContraction&,float); 68 | 69 | //////////////////////////////////////////////////////////////////////// 70 | // 71 | // Output routines 72 | // 73 | extern bool select_output_format(const char *); 74 | extern void output_preamble(); 75 | extern void output_current_model(); 76 | extern void output_final_model(); 77 | 78 | extern void output_iv(ostream&); 79 | extern void output_vrml(ostream&); 80 | extern void output_regressive_mmf(ostream&); 81 | extern void output_regressive_log(ostream&); 82 | extern void output_progressive_pm(ostream&); 83 | 84 | //////////////////////////////////////////////////////////////////////// 85 | // 86 | // Other relevant things 87 | // 88 | extern const char *slim_copyright_notice; 89 | extern const char *slim_version_string; 90 | extern void slim_print_banner(ostream&); 91 | 92 | // QSLIM_INCLUDED 93 | #endif 94 | -------------------------------------------------------------------------------- /tools/filters/cmdline.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Command line processing for the standard SMF filters. 4 | 5 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 6 | 7 | $Id: cmdline.cxx,v 1.8 2000/11/20 20:58:59 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "cmdline.h" 16 | 17 | static char *base_options="o:"; 18 | 19 | static char *output_filename = NULL; 20 | 21 | MxStdModel *read_model_from_file(const char *filename, 22 | MxSMFReader *smf, 23 | MxStdModel *m) 24 | { 25 | bool local_smfreader = false; 26 | 27 | if( !smf ) 28 | { 29 | smf = new MxSMFReader; 30 | local_smfreader = true; 31 | } 32 | 33 | if( !strcmp(filename, "-")) 34 | m = smf->read(cin, m); 35 | else 36 | { 37 | ifstream in(filename); 38 | if( !in.good() ) fatal_error("Failed to open input file"); 39 | m = smf->read(in, m); 40 | } 41 | 42 | if( local_smfreader ) delete smf; 43 | 44 | return m; 45 | } 46 | 47 | void process_cmdline_only(int argc, char *argv[], 48 | const char *user_options, option_processor proc) 49 | { 50 | char *options = base_options; 51 | 52 | if( user_options ) 53 | { 54 | int base_len = strlen(base_options); 55 | int user_len = strlen(user_options); 56 | 57 | options = new char[base_len + user_len + 1]; 58 | strcpy(options, user_options); 59 | strcpy(options+user_len, base_options); 60 | options[base_len+user_len] = '\0'; 61 | } 62 | 63 | int opt; 64 | 65 | while( (opt = getopt(argc, argv, options)) != EOF ) 66 | { 67 | switch( opt ) 68 | { 69 | case 'o': 70 | output_filename = optarg; 71 | break; 72 | 73 | default: 74 | if( proc ) 75 | (*proc)(opt, optarg); 76 | break; 77 | } 78 | } 79 | } 80 | 81 | MxStdModel *process_cmdline(int argc, char *argv[], 82 | const char *user_options, option_processor proc) 83 | { 84 | process_cmdline_only(argc, argv, user_options, proc); 85 | 86 | MxSMFReader smf; 87 | MxStdModel *m = new MxStdModel(64, 64); 88 | 89 | if( optind==argc ) 90 | smf.read(cin, m); 91 | 92 | for(; optindface_count() == 0 && m->vert_count() == 0 ) 96 | { 97 | cerr << argv[0] << ": Input model is empty." << endl; 98 | delete m; 99 | m = NULL; 100 | } 101 | 102 | return m; 103 | } 104 | 105 | void output_final_model(MxStdModel *m, bool was_modified) 106 | { 107 | if( was_modified ) 108 | m->compact_vertices(); 109 | 110 | MxSMFWriter writer; 111 | 112 | if( !output_filename ) 113 | writer.write(cout, *m); 114 | else 115 | { 116 | ofstream out(output_filename); 117 | writer.write(out, *m); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /libgfx/doc/mat4.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | libgfx: Matrix Math 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Matrix Math

16 | 17 |

class Mat4

18 | 19 | 20 |

This class implements a 4x4 real-valued matrix. 21 | Individual elements are represented with double precision 22 | floating point numbers. To use the Mat4 class you must include the 23 | header 24 |

25 |     #include <gfx/mat4.h>
26 | 
27 | 28 |

Constructor Methods

29 | 30 |

The Mat4 class defines the following set of constructors: 31 | 32 |

33 |     // Initialize all elements to 0
34 |     Mat4();
35 | 
36 |     // Initialize rows with given vectors
37 |     Mat4(const Vec4& r0,const Vec4& r1,const Vec4& r2,const Vec4& r3);
38 | 
39 |     // Copy values from A
40 |     Mat4(const Mat4& A);
41 | 
42 | 43 | 44 |

Transformation Functions

45 | 46 |

Because 4x4 matrices are commonly used to represent linear homogeneous 47 | transformations in computer graphics, the matrix package provides several 48 | functions to construct transformation matrices. The operation of these 49 | functions is based directly on the definition of the corresponding 50 | transformations as used in OpenGL. The resulting matrices should be 51 | equivalent to those produced by OpenGL, to the extent allowed by limited 52 | floating point accuracy. 53 | 54 |

55 |     // Construct translation, scaling, and rotation matrices.
56 |     Mat4 translation_matrix(const Vec3& delta);
57 |     Mat4 scaling_matrix(const Vec3& scale);
58 |     Mat4 rotation_matrix_deg(double theta, const Vec3& axis);
59 |     Mat4 rotation_matrix_rad(double theta, const Vec3& axis);
60 | 
61 |     // Construct a perspective projection matrix.
62 |     // Direct analog of gluPerspective()
63 |     Mat4 perspective_matrix(double fovy, double aspect,
64 |                             double zmin=0.0, double zmax=0.0);
65 | 
66 |     // Construct a viewing transformation.
67 |     // Direct analog of gluLookAt()
68 |     Mat4 lookat_matrix(const Vec3& from, const Vec3& at, const Vec3& up);
69 | 
70 |     // Construct a viewport mapping.
71 |     // Direct analog of glViewport().
72 |     Mat4 viewport_matrix(double w, double h);
73 | 
74 | 75 | Note that the rotation_matrix() function comes in two forms, once 76 | which expects an angle in radians and one which expects an angle in 77 | degrees. The type of angle expected is made explicit in the function 78 | name (i.e., _rad and _deg suffixes) in an attempt to avoid 79 | confusion. 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /mixkit/src/MxDualModel.h: -------------------------------------------------------------------------------- 1 | #ifndef MXDUALMODEL_INCLUDED // -*- C++ -*- 2 | #define MXDUALMODEL_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxDualModel 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxDualModel.h,v 1.9 1999/07/13 17:14:34 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | #include "MxStdModel.h" 18 | 19 | typedef MxSizedDynBlock MxDualEdgeList; 20 | 21 | class MxDualEdge : public MxEdge 22 | { 23 | public: 24 | float border_length; // Length of the border between clusters 25 | }; 26 | 27 | class MxDualContraction 28 | { 29 | public: 30 | uint n1, n2; 31 | MxDualEdgeList dead_edges; 32 | }; 33 | 34 | class MxDualModel 35 | { 36 | private: 37 | MxDynBlock edges; // All the edges of the model 38 | MxBlock edge_links; // Edge links for each node 39 | 40 | MxBlock node_labels; // Each node is labeled 41 | MxBlock node_marks; // Each node has a mark 42 | 43 | void update_border_lengths(const MxDualContraction&); 44 | 45 | protected: 46 | MxStdModel *m; 47 | 48 | void collect_edges(); 49 | 50 | public: 51 | MxDualModel(MxStdModel *); 52 | 53 | 54 | //////////////////////////////////////////////////////////////////////// 55 | // Fundamental operations 56 | // 57 | uint& node_label(uint i) { return node_labels(i); } 58 | uint node_label(uint i) const { return node_labels(i); } 59 | 60 | bool node_is_valid(uint i) const { return node_labels(i) == i; } 61 | uint node_ancestor(uint i) const 62 | { 63 | while(!node_is_valid(i)) i = node_label(i); 64 | return i; 65 | } 66 | 67 | uint node_mark(uint i) const { return node_marks(i); } 68 | void node_mark(uint i, uint m) { node_marks(i) = m; } 69 | void mark_node_neighbors(uint n, uint mark); 70 | 71 | MxDualEdgeList& node_edges(uint i) { return edge_links(i); } 72 | const MxDualEdgeList& node_edges(uint i) const { return edge_links(i); } 73 | 74 | uint edge_count() const { return edges.length(); } 75 | MxDualEdge& edge(uint i) { return edges(i); } 76 | const MxDualEdge& edge(uint i) const { return edges(i); } 77 | 78 | //////////////////////////////////////////////////////////////////////// 79 | // Dual contraction merges sets of faces 80 | // 81 | void contract(MxDualContraction&); 82 | 83 | //////////////////////////////////////////////////////////////////////// 84 | // Calculations which tie dual graph to original mesh 85 | // 86 | bool meshedge_is_boundary(const MxEdge& e, uint n1); 87 | bool meshedge_is_boundary(const MxEdge& e, uint n1, uint n2); 88 | void compute_mesh_boundary(uint n1, MxEdgeList& edges); 89 | void compute_mesh_boundary(uint n1, uint n2, MxEdgeList& edges); 90 | }; 91 | 92 | // MXDUALMODEL_INCLUDED 93 | #endif 94 | -------------------------------------------------------------------------------- /libgfx/include/gfx/geom3d.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXGEOM3D_INCLUDED 2 | #define GFXGEOM3D_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Handy 3D geometrical primitives 10 | 11 | $Id: geom3d.h,v 1.5 2002/05/20 15:25:46 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | // 16 | // Computing properties of triangles 17 | // 18 | 19 | template 20 | inline Vec triangle_raw_normal(const Vec& v1, const Vec& v2, const Vec& v3) 21 | { 22 | return cross(v2-v1, v3-v1); 23 | } 24 | 25 | template 26 | inline typename Vec::value_type 27 | triangle_area(const Vec& v1,const Vec& v2,const Vec& v3) 28 | { 29 | return 0.5 * norm(triangle_raw_normal(v1, v2, v3)); 30 | } 31 | 32 | template 33 | inline Vec triangle_normal(const Vec& v1, const Vec& v2, const Vec& v3) 34 | { 35 | Vec n = triangle_raw_normal(v1, v2, v3); 36 | unitize(n); 37 | return n; 38 | } 39 | 40 | template 41 | inline Plane triangle_plane(const Vec& v1, const Vec& v2, const Vec& v3) 42 | { 43 | Vec n = triangle_normal(v1, v2, v3); 44 | return Plane(n, -(n*v1)); 45 | } 46 | 47 | template 48 | inline Plane triangle_raw_plane(const Vec& v1, const Vec& v2, const Vec& v3) 49 | { 50 | Vec n = triangle_raw_normal(v1, v2, v3); 51 | return Plane(n, -(n*v1)); 52 | } 53 | 54 | template< class Vec> 55 | inline typename Vec::value_type 56 | triangle_compactness(const Vec& v1, const Vec& v2, const Vec& v3) 57 | { 58 | const double FOUR_ROOT3 = 6.928203230275509; 59 | 60 | return FOUR_ROOT3 * triangle_area(v1, v2, v3) / 61 | ( norm2(v2 - v1) + norm2(v3 - v2) + norm2(v1 - v3) ); 62 | } 63 | 64 | // 65 | // Operations with axis-aligned bounding boxes 66 | // 67 | 68 | template 69 | void compute_bbox(Vec& min, Vec& max, const List& items) 70 | { 71 | typedef typename List::const_iterator iterator; 72 | 73 | if( items.size()==0 ) min = max = 0; 74 | else min = max = items[0]; 75 | 76 | for(iterator i=items.begin(); i!=items.end(); i++) 77 | { 78 | const Vec& v = *i; 79 | for(int j=0; j max[j] ) max[j] = v[j]; 83 | } 84 | } 85 | } 86 | 87 | template 88 | bool is_inside_bbox(const Vec& p, const Vec& min, Vec& max) 89 | { 90 | for(int i=0; imax[i] ) 92 | return false; 93 | 94 | return true; 95 | } 96 | 97 | template 98 | Vec clamp_to_bbox(Vec p, const Vec& min, const Vec& max) 99 | { 100 | for(int i=0; imax[i]) p[i]=max[i]; 104 | } 105 | 106 | return p; 107 | } 108 | 109 | // GFXGEOM3D_INCLUDED 110 | #endif 111 | -------------------------------------------------------------------------------- /mixkit/src/MxFitFrame-vis.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | Frame visualization functions. 4 | 5 | This code requires OpenGL. It is included here, separately from the 6 | other MxFitFrame code, so that command line programs do not need to 7 | link OpenGL libraries. 8 | 9 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 10 | 11 | $Id: MxFitFrame-vis.cxx,v 1.3 2000/11/27 19:19:19 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include "stdmix.h" 16 | #include "MxGL.h" 17 | #include "MxFitFrame.h" 18 | 19 | static 20 | void draw_box(const double *min, const double *max) 21 | { 22 | glBegin(GL_LINE_LOOP); 23 | glV(min[X],min[Y],min[Z]); glV(min[X],max[Y],min[Z]); 24 | glV(max[X],max[Y],min[Z]); glV(max[X],min[Y],min[Z]); 25 | glEnd(); 26 | 27 | glBegin(GL_LINE_LOOP); 28 | glV(min[X],min[Y],max[Z]); glV(min[X],max[Y],max[Z]); 29 | glV(max[X],max[Y],max[Z]); glV(max[X],min[Y],max[Z]); 30 | glEnd(); 31 | 32 | glBegin(GL_LINES); 33 | glV(min[X],min[Y],min[Z]); glV(min[X],min[Y],max[Z]); 34 | glV(min[X],max[Y],min[Z]); glV(min[X],max[Y],max[Z]); 35 | glV(max[X],max[Y],min[Z]); glV(max[X],max[Y],max[Z]); 36 | glV(max[X],min[Y],min[Z]); glV(max[X],min[Y],max[Z]); 37 | glEnd(); 38 | } 39 | 40 | static 41 | void draw_base_plane(const double *min, const double *max) 42 | { 43 | glBegin(GL_LINES); 44 | // glV(0.0f, 0.0f, 0.0f); glV(0.0f, 0.0f, 0.2f); 45 | // glV(0.0f, 0.0f, 0.0f); glV(0.1f, 0.0f, 0.0f); 46 | // glV(0.0f, 0.0f, 0.0f); glV(0.0f, 0.1f, 0.0f); 47 | glV(0.0f, 0.0f, 0.0f); glVertex2d(min[X], min[Y]); 48 | glV(0.0f, 0.0f, 0.0f); glVertex2d(max[X], min[Y]); 49 | glV(0.0f, 0.0f, 0.0f); glVertex2d(max[X], max[Y]); 50 | glV(0.0f, 0.0f, 0.0f); glVertex2d(min[X], max[Y]); 51 | glEnd(); 52 | 53 | glBegin(GL_LINE_LOOP); 54 | glVertex2d(min[X], min[Y]); 55 | glVertex2d(max[X], min[Y]); 56 | glVertex2d(max[X], max[Y]); 57 | glVertex2d(min[X], max[Y]); 58 | glEnd(); 59 | } 60 | 61 | void mx_draw_fitframe(const MxFitFrame& n, float rgbscale) 62 | { 63 | glC(0.2*rgbscale, 0.8*rgbscale, 0.2*rgbscale); 64 | 65 | glPushAttrib(GL_LIGHTING_BIT | GL_LINE_BIT | GL_ENABLE_BIT); 66 | glEnable(GL_LINE_SMOOTH); 67 | glDisable(GL_LIGHTING); 68 | glLineWidth(1.2); 69 | 70 | const Vec4 r1(Vec3(n.axis(0)), 0); 71 | const Vec4 r2(Vec3(n.axis(1)), 0); 72 | const Vec4 r3(Vec3(n.axis(2)), 0); 73 | const Vec4 r4(Vec3(n.origin()), 1); 74 | Mat4 R(r1, r2, r3, r4); 75 | 76 | R = transpose(R); 77 | 78 | 79 | glPushMatrix(); 80 | glMultMatrix(R); 81 | draw_base_plane(n.min(), n.max()); 82 | draw_box(n.min(), n.max()); 83 | glPopMatrix(); 84 | 85 | // glBegin(GL_LINES); 86 | // glC(0.8*rgbscale, 0.8*rgbscale, 0.2*rgbscale); 87 | // glV3(n.origin()); 88 | // glV(Vec3(n.origin()) + 0.2*Vec3(n.normal())); 89 | // glEnd(); 90 | 91 | glPopAttrib(); 92 | } 93 | -------------------------------------------------------------------------------- /mixkit/src/MxMatrix.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | NxN Matrix class 4 | 5 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 6 | 7 | $Id: MxMatrix.cxx,v 1.4 1998/10/26 21:09:09 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include "stdmix.h" 12 | #include "MxMatrix.h" 13 | 14 | // Originally from Paul's matrix library. 15 | // 16 | // Returns determinant of a, and b=a inverse. 17 | // If matrix is singular, returns 0 and leaves trash in b. 18 | // 19 | // Uses Gaussian elimination with partial pivoting. 20 | 21 | #define SWAP(a, b, t) {t = a; a = b; b = t;} 22 | static double internal_invert(MxMatrix& A, MxMatrix& B) 23 | { 24 | uint N = A.dim(); 25 | uint i, j, k; 26 | double max, t, det, pivot; 27 | 28 | /*---------- forward elimination ----------*/ 29 | 30 | for (i=0; i max) { 39 | max = fabs(A(k, i)); 40 | j = k; 41 | } 42 | if (max<=0.) return 0.; /* if no nonzero pivot, PUNT */ 43 | if (j!=i) { /* swap rows i and j */ 44 | for (k=i; k0; i--) { /* eliminate in column i, above diag */ 70 | for (j=0; j max[X] ) max[X] = v[X]; 57 | if( v[Y] > max[Y] ) max[Y] = v[Y]; 58 | if( v[Z] > max[Z] ) max[Z] = v[Z]; 59 | } 60 | 61 | if( will_update ) 62 | { 63 | center += Vec3(v); 64 | points++; 65 | } 66 | } 67 | 68 | void MxBounds::add_point(const float *v, bool will_update) 69 | { 70 | if( !is_initialized ) 71 | { 72 | min[X] = max[X] = v[X]; 73 | min[Y] = max[Y] = v[Y]; 74 | min[Z] = max[Z] = v[Z]; 75 | is_initialized = true; 76 | } 77 | else 78 | { 79 | if( v[X] < min[X] ) min[X] = v[X]; 80 | if( v[Y] < min[Y] ) min[Y] = v[Y]; 81 | if( v[Z] < min[Z] ) min[Z] = v[Z]; 82 | 83 | if( v[X] > max[X] ) max[X] = v[X]; 84 | if( v[Y] > max[Y] ) max[Y] = v[Y]; 85 | if( v[Z] > max[Z] ) max[Z] = v[Z]; 86 | } 87 | 88 | if( will_update ) 89 | { 90 | center += Vec3(v); 91 | points++; 92 | } 93 | } 94 | 95 | void MxBounds::complete() 96 | { 97 | center /= (double)points; 98 | 99 | Vec3 R1 = max-center; 100 | Vec3 R2 = min-center; 101 | 102 | radius = MAX(norm(R1), norm(R2)); 103 | } 104 | 105 | void MxBounds::merge(const MxBounds& b) 106 | { 107 | add_point(b.min, false); 108 | add_point(b.max, false); 109 | points += b.points; 110 | 111 | Vec3 dC = b.center - center; 112 | double dist = norm(dC); 113 | 114 | if( dist + b.radius > radius ) 115 | { 116 | // New sphere does not lie within old sphere 117 | center += b.center; 118 | center /= 2; 119 | 120 | dist /= 2; 121 | radius = MAX(dist+radius, dist+b.radius); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /tools/filters/smfmeasure.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | smfmeasure 4 | 5 | This filter makes various measurements on the model, and outputs 6 | the results. It does *not* output a new model, only the model 7 | measurements. 8 | 9 | Copyright (C) 1998 Michael Garland, All Rights Reserved. 10 | 11 | $Id: smfmeasure.cxx,v 1.3 1998/06/18 12:11:44 garland Exp $ 12 | 13 | ************************************************************************/ 14 | 15 | #include 16 | #include 17 | #include 18 | #include "cmdline.h" 19 | 20 | 21 | static uint edge_count = 0; 22 | static double min_area = HUGE; 23 | static double max_area = 0; 24 | static double total_area = 0; 25 | static double min_edge = HUGE; 26 | static double max_edge = 0; 27 | static MxBounds bounds; 28 | 29 | static 30 | void measure_model(MxStdModel *m) 31 | { 32 | uint i, j; 33 | 34 | // Compute [min,max] face areas 35 | for(i=0; iface_count(); i++) 36 | { 37 | double a = m->compute_face_area(i); 38 | if( amax_area ) max_area = a; 40 | total_area += a; 41 | } 42 | 43 | // Compute [min,max] edge length 44 | MxVertexList star; 45 | 46 | for(i=0; ivert_count(); i++) 47 | { 48 | star.reset(); 49 | m->collect_vertex_star(i, star); 50 | 51 | for(j=0; jvertex(i), m->vertex(star[j]), 3); 56 | if( e2max_edge ) max_edge = e2; 58 | } 59 | } 60 | min_edge = sqrt(min_edge); 61 | max_edge = sqrt(max_edge); 62 | 63 | // Compute bounding box 64 | for(i=0; ivert_count(); i++) 65 | bounds.add_point(m->vertex(i)); 66 | bounds.complete(); 67 | } 68 | 69 | static 70 | void report_measurements(MxStdModel *m) 71 | { 72 | cout << endl; 73 | cout << "vertices = " << m->vert_count() << endl; 74 | cout << "faces = " << m->face_count() 75 | << "\t\t[" 76 | << (float)m->face_count() / (float)m->vert_count() 77 | << "v]" << endl; 78 | cout << "edges = " << edge_count 79 | << "\t\t[" 80 | << (float)edge_count / (float)m->vert_count() 81 | << "v]" << endl; 82 | 83 | cout << endl; 84 | cout << "BB min = " << bounds.min << endl; 85 | cout << "BB max = " << bounds.max << endl; 86 | cout << "BB ctr = " << (bounds.max+bounds.min)/2 << endl; 87 | cout << "BS ctr = " << bounds.center << endl; 88 | cout << "BS rad = " << bounds.radius << endl; 89 | 90 | cout << endl; 91 | cout << "min area = " << min_area << endl; 92 | cout << "max area = " << max_area << endl; 93 | cout << "tot area = " << total_area << endl; 94 | cout << "min edge = " << min_edge << endl; 95 | cout << "max edge = " << max_edge << endl; 96 | } 97 | 98 | int main(int argc, char *argv[]) 99 | { 100 | MxStdModel *m = process_cmdline(argc, argv); 101 | if( !m ) return 0; 102 | 103 | measure_model(m); 104 | report_measurements(m); 105 | 106 | delete m; 107 | return 0; 108 | } 109 | -------------------------------------------------------------------------------- /mixkit/src/MxSMF.h: -------------------------------------------------------------------------------- 1 | #ifndef MXSMF_INCLUDED // -*- C++ -*- 2 | #define MXSMF_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | MxSMF 10 | 11 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 12 | 13 | $Id: MxSMF.h,v 1.20 2000/11/20 20:36:38 garland Exp $ 14 | 15 | ************************************************************************/ 16 | 17 | 18 | // Interim reader based on SMF 1.0 19 | // This reader is designed to create MxStdModel models 20 | 21 | #include "MxCmdParser.h" 22 | #include "MxStack.h" 23 | #include "MxStdModel.h" 24 | #include "MxMat4.h" 25 | 26 | class MxSMFReader : private MxCmdParser 27 | { 28 | public: 29 | typedef void (MxSMFReader::*read_cmd)(int argc, 30 | char *argv[], 31 | MxStdModel& m); 32 | struct cmd_entry { char *name; read_cmd cmd; }; 33 | 34 | private: 35 | MxStack vfirst_stack; 36 | MxStack vcorrect_stack; 37 | MxStack vx_stack; 38 | MxStack tx_stack; 39 | unsigned int next_vertex; 40 | unsigned int next_face; 41 | 42 | unsigned int quad_count; // # of quadrilaterals in input 43 | unsigned int poly_count; // # of 5+ sided polygons in input 44 | 45 | char *line_buffer; 46 | 47 | static cmd_entry read_cmds[]; 48 | 49 | private: 50 | bool execute_command(const MxCmd&, void *closure); 51 | void define_avars(); 52 | void update_avars(); 53 | 54 | protected: 55 | void v_xform(Vec3& v); 56 | void t_xform(Vec2& v); 57 | unsigned int vid_xform(int id); 58 | 59 | void vertex(int argc, char *argv[], MxStdModel&); 60 | void face(int argc, char *argv[], MxStdModel&); 61 | 62 | void prop_bind(int argc, char *argv[], MxStdModel&); 63 | void prop_normal(int argc, char *argv[], MxStdModel&); 64 | void prop_color(int argc, char *argv[], MxStdModel&); 65 | void prop_texcoord(int argc, char *argv[], MxStdModel&); 66 | void read_texture(int argc, char *argv[], MxStdModel&); 67 | 68 | void begin(int argc, char *argv[], MxStdModel&); 69 | void end(int argc, char *argv[], MxStdModel&); 70 | void trans(int argc, char *argv[], MxStdModel&); 71 | void rot(int argc, char *argv[], MxStdModel&); 72 | void scale(int argc, char *argv[], MxStdModel&); 73 | void t_trans(int argc, char *argv[], MxStdModel&); 74 | void t_scale(int argc, char *argv[], MxStdModel&); 75 | 76 | public: 77 | MxSMFReader(); 78 | ~MxSMFReader(); 79 | 80 | bool (*unparsed_hook)(char *cmd, int argc, char *argv[], MxStdModel& m); 81 | 82 | MxAspStore *asp_store() { return this->MxCmdParser::asp_store(); } 83 | 84 | MxStdModel *read(istream& in, MxStdModel *model=NULL); 85 | void parse_line(char *, MxStdModel&); 86 | }; 87 | 88 | class MxSMFWriter 89 | { 90 | public: 91 | MxSMFWriter(); 92 | 93 | void (*vertex_annotate)(ostream&, const MxStdModel&, MxVertexID); 94 | void (*face_annotate)(ostream&, const MxStdModel&, MxVertexID); 95 | 96 | void write(ostream& out, MxStdModel& m); 97 | }; 98 | 99 | // MXSMF_INCLUDED 100 | #endif 101 | -------------------------------------------------------------------------------- /mixkit/src/MxCmdParser.cxx: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | 3 | MxCmdParser 4 | 5 | Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. 6 | 7 | $Id: MxCmdParser.cxx,v 1.5 1998/10/26 21:08:44 garland Exp $ 8 | 9 | ************************************************************************/ 10 | 11 | #include "stdmix.h" 12 | #include "mixio.h" 13 | #include "MxCmdParser.h" 14 | 15 | #include "MxDynBlock.h" 16 | #include 17 | 18 | typedef MxDynBlock string_list; 19 | 20 | #define MXCMD_PHRASE_SEPARATOR ';' 21 | 22 | static 23 | char *trimleft(char *line) 24 | { 25 | if( !line ) return NULL; 26 | while(isspace(*line)) line++; 27 | return line; 28 | } 29 | 30 | static 31 | char *shift_token(char *line) 32 | { 33 | if( !line ) return NULL; 34 | 35 | char *rest = NULL; 36 | 37 | while( *line && !isspace(*line) ) line++; 38 | 39 | if( *line ) rest = line+1; 40 | 41 | *line = '\0'; 42 | 43 | return trimleft(rest); 44 | } 45 | 46 | static 47 | char *shift_phrase(char *line) 48 | { 49 | if( !line ) return NULL; 50 | 51 | char *rest = NULL; 52 | 53 | while( *line && *line != MXCMD_PHRASE_SEPARATOR ) line++; 54 | 55 | if( *line ) rest = line+1; 56 | 57 | *line = '\0'; 58 | 59 | return trimleft(rest); 60 | } 61 | 62 | MxCmdParser::MxCmdParser() 63 | : cmd(16) 64 | { 65 | will_ignore_unknown = true; 66 | } 67 | 68 | void MxCmdParser::parse_line(char *line, void *closure) 69 | { 70 | uint i,j; 71 | 72 | line = trimleft(line); 73 | 74 | if(!line[0] || line[0] == '#') return; // Ignore comments and empty lines 75 | 76 | // Extract operator 77 | // 78 | char *op = line; line = shift_token(line); 79 | 80 | // Extract phrases 81 | // 82 | string_list phrases; 83 | 84 | while( line ) 85 | { 86 | phrases.add(line); 87 | line = shift_phrase(line); 88 | } 89 | 90 | cmd.phrases.reset(); 91 | cmd.op = op; 92 | 93 | // Extract args in phrases 94 | // 95 | string_list args; 96 | 97 | for(i=0; iset_heap_pos(i); 25 | } 26 | 27 | void MxHeap::swap(unsigned int i, unsigned int j) 28 | { 29 | MxHeapable *tmp = ref(i); 30 | 31 | place(ref(j), i); 32 | place(tmp, j); 33 | } 34 | 35 | void MxHeap::upheap(unsigned int i) 36 | { 37 | MxHeapable *moving = ref(i); 38 | uint index = i; 39 | uint p = parent(i); 40 | 41 | while( index>0 && moving->heap_key() > ref(p)->heap_key() ) 42 | { 43 | place(ref(p), index); 44 | index = p; 45 | p = parent(p); 46 | } 47 | 48 | if( index != i ) 49 | place(moving, index); 50 | } 51 | 52 | void MxHeap::downheap(unsigned int i) 53 | { 54 | MxHeapable *moving = ref(i); 55 | uint index = i; 56 | uint l = left(i); 57 | uint r = right(i); 58 | uint largest; 59 | 60 | while( lheap_key() < ref(r)->heap_key() ) 63 | largest = r; 64 | else 65 | largest = l; 66 | 67 | if( moving->heap_key() < ref(largest)->heap_key() ) 68 | { 69 | place(ref(largest), index); 70 | index = largest; 71 | l = left(index); 72 | r = right(index); 73 | } 74 | else 75 | break; 76 | } 77 | 78 | if( index != i ) 79 | place(moving, index); 80 | } 81 | 82 | //////////////////////////////////////////////////////////////////////// 83 | // 84 | // Exported interface to the heap 85 | // 86 | 87 | void MxHeap::insert(MxHeapable *t, float v) 88 | { 89 | t->heap_key(v); 90 | 91 | add(t); 92 | unsigned int i = last_id(); 93 | t->set_heap_pos(i); 94 | 95 | upheap(i); 96 | } 97 | 98 | void MxHeap::update(MxHeapable *t, float v) 99 | { 100 | SanityCheck( t->is_in_heap() ); 101 | t->heap_key(v); 102 | 103 | unsigned int i = t->get_heap_pos(); 104 | 105 | if( i>0 && v>ref(parent(i))->heap_key() ) 106 | upheap(i); 107 | else 108 | downheap(i); 109 | } 110 | 111 | MxHeapable *MxHeap::extract() 112 | { 113 | if( length() < 1 ) return NULL; 114 | 115 | swap(0, length()-1); 116 | MxHeapable *dead=drop(); 117 | 118 | downheap(0); 119 | dead->not_in_heap(); 120 | return dead; 121 | } 122 | 123 | MxHeapable *MxHeap::remove(MxHeapable *t) 124 | { 125 | if( !t->is_in_heap() ) return NULL; 126 | 127 | int i = t->get_heap_pos(); 128 | swap(i, length()-1); 129 | drop(); 130 | t->not_in_heap(); 131 | 132 | if( ref(i)->heap_key() < t->heap_key() ) 133 | downheap(i); 134 | else 135 | upheap(i); 136 | 137 | return t; 138 | } 139 | -------------------------------------------------------------------------------- /libgfx/include/gfx/intvec.h: -------------------------------------------------------------------------------- 1 | #ifndef GFXINTVEC_INCLUDED // -*- C++ -*- 2 | #define GFXINTVEC_INCLUDED 3 | #if !defined(__GNUC__) 4 | # pragma once 5 | #endif 6 | 7 | /************************************************************************ 8 | 9 | Generic class for representing packed integer vectors. 10 | 11 | For signed types (e.g., short) the elements of the vector are 12 | assumed to fall in the range [-1, 1]. For unsigned types the 13 | elements of the vector are assumed to fall in the range [0, 1]. 14 | 15 | Note that ANSI C defines the maximum values of integer types in 16 | . 17 | 18 | $Id: intvec.h,v 1.7 2002/07/30 22:21:47 zelinka Exp $ 19 | 20 | ************************************************************************/ 21 | 22 | #include "gfx.h" 23 | 24 | template 25 | class IntVec 26 | { 27 | private: 28 | T data[N]; 29 | 30 | // These are the routines used by all other methods to convert 31 | // between the internal integral representation and the external 32 | // floating point representation. 33 | // 34 | static inline T _fromflt(double x) 35 | { return (T)rint((x>1.0f?1.0f:x)*(double)T_MAX); } 36 | static inline double _toflt(T s) { return (double)s/(double)T_MAX; } 37 | 38 | protected: 39 | operator T*() { return data; } 40 | operator const T*() const { return data; } 41 | 42 | public: 43 | IntVec() { *this = 0.0; } 44 | 45 | double operator[](int i) const { return _toflt(data[i]); } 46 | void set(int i, double x) { data[i] = _fromflt(x); } 47 | 48 | IntVec& operator=(const IntVec& v) 49 | { for(int i=0; i byteColor; 70 | // 71 | 72 | #include "vec3.h" 73 | 74 | template 75 | class IntVec3 : public IntVec 76 | { 77 | public: 78 | IntVec3() { *this = 0.0; } 79 | IntVec3(double x, double y, double z) { pack(Vec3(x, y, z)); } 80 | template IntVec3(const TVec3& v) { pack(v[0], v[1], v[2]); } 81 | 82 | Vec3 unpack() const { return Vec3((*this)[0],(*this)[1],(*this)[2]); } 83 | void pack(const Vec3& v) 84 | { this->set(0, v[0]); this->set(1, v[1]); this->set(2, v[2]); } 85 | void pack(double x, double y, double z) 86 | { this->set(0,x); this->set(1,y); this->set(2,z); } 87 | 88 | IntVec3& operator=(const Vec3& v) { pack(v); return *this; } 89 | }; 90 | 91 | // GFXINTVEC_INCLUDED 92 | #endif 93 | --------------------------------------------------------------------------------