├── .gitignore ├── README.md ├── gaps ├── LICENSE.txt ├── Makefile ├── README.txt ├── apps │ ├── Makefile │ ├── img2img │ │ ├── Makefile │ │ ├── img2img.cpp │ │ └── img2img.vcxproj │ ├── scn2cam │ │ ├── Makefile │ │ └── scn2cam.cpp │ ├── scn2grd │ │ ├── Makefile │ │ └── scn2grd.cpp │ ├── scn2img │ │ ├── Makefile │ │ └── scn2img.cpp │ ├── scn2scn │ │ ├── Makefile │ │ └── scn2scn.cpp │ ├── scninfo │ │ ├── Makefile │ │ ├── scninfo.cpp │ │ └── scninfo.vcxproj │ └── scnview │ │ ├── Makefile │ │ ├── scnview.cpp │ │ └── scnview.vcxproj ├── docs │ ├── Makefile │ ├── headers │ │ ├── R2Shapes.header │ │ ├── R3Graphics.header │ │ ├── R3Shapes.header │ │ └── RNBasics.header │ ├── index.html │ ├── makeall │ ├── makepkg │ └── makepkg.awk ├── makefiles │ ├── Makefile.apps │ ├── Makefile.pkgs │ └── Makefile.std ├── pkgs │ ├── Makefile │ ├── R2Shapes │ │ ├── Makefile │ │ ├── R2Affine.cpp │ │ ├── R2Affine.h │ │ ├── R2Align.cpp │ │ ├── R2Align.h │ │ ├── R2Arc.cpp │ │ ├── R2Arc.h │ │ ├── R2Box.cpp │ │ ├── R2Box.h │ │ ├── R2Circle.cpp │ │ ├── R2Circle.h │ │ ├── R2Cont.cpp │ │ ├── R2Cont.h │ │ ├── R2Crdsys.cpp │ │ ├── R2Crdsys.h │ │ ├── R2Curve.cpp │ │ ├── R2Curve.h │ │ ├── R2Diad.cpp │ │ ├── R2Diad.h │ │ ├── R2Dist.cpp │ │ ├── R2Dist.h │ │ ├── R2Draw.cpp │ │ ├── R2Draw.h │ │ ├── R2Grid.cpp │ │ ├── R2Grid.h │ │ ├── R2Halfspace.cpp │ │ ├── R2Halfspace.h │ │ ├── R2Image.cpp │ │ ├── R2Image.h │ │ ├── R2Io.cpp │ │ ├── R2Io.h │ │ ├── R2Isect.cpp │ │ ├── R2Isect.h │ │ ├── R2Kdtree.cpp │ │ ├── R2Kdtree.h │ │ ├── R2Line.cpp │ │ ├── R2Line.h │ │ ├── R2Parall.cpp │ │ ├── R2Parall.h │ │ ├── R2Perp.cpp │ │ ├── R2Perp.h │ │ ├── R2Point.cpp │ │ ├── R2Point.h │ │ ├── R2Polygon.cpp │ │ ├── R2Polygon.h │ │ ├── R2Polyline.cpp │ │ ├── R2Polyline.h │ │ ├── R2Ray.cpp │ │ ├── R2Ray.h │ │ ├── R2Relate.cpp │ │ ├── R2Relate.h │ │ ├── R2Shape.cpp │ │ ├── R2Shape.h │ │ ├── R2Shapes.cpp │ │ ├── R2Shapes.h │ │ ├── R2Shapes.vcxproj │ │ ├── R2Shapes.vcxproj.filters │ │ ├── R2Solid.cpp │ │ ├── R2Solid.h │ │ ├── R2Span.cpp │ │ ├── R2Span.h │ │ ├── R2Vector.cpp │ │ ├── R2Vector.h │ │ ├── R2Xform.cpp │ │ ├── R2Xform.h │ │ ├── R3Matrix.cpp │ │ └── R3Matrix.h │ ├── R3Graphics │ │ ├── Makefile │ │ ├── R2Texture.cpp │ │ ├── R2Texture.h │ │ ├── R2Viewport.cpp │ │ ├── R2Viewport.h │ │ ├── R3AreaLight.cpp │ │ ├── R3AreaLight.h │ │ ├── R3Brdf.cpp │ │ ├── R3Brdf.h │ │ ├── R3Camera.cpp │ │ ├── R3Camera.h │ │ ├── R3DirectionalLight.cpp │ │ ├── R3DirectionalLight.h │ │ ├── R3Frustum.cpp │ │ ├── R3Frustum.h │ │ ├── R3Graphics.cpp │ │ ├── R3Graphics.h │ │ ├── R3Graphics.vcxproj │ │ ├── R3Graphics.vcxproj.filters │ │ ├── R3Light.cpp │ │ ├── R3Light.h │ │ ├── R3Material.cpp │ │ ├── R3Material.h │ │ ├── R3PointLight.cpp │ │ ├── R3PointLight.h │ │ ├── R3Scene.cpp │ │ ├── R3Scene.h │ │ ├── R3SceneElement.cpp │ │ ├── R3SceneElement.h │ │ ├── R3SceneNode.cpp │ │ ├── R3SceneNode.h │ │ ├── R3SceneReference.cpp │ │ ├── R3SceneReference.h │ │ ├── R3SpotLight.cpp │ │ ├── R3SpotLight.h │ │ ├── R3Viewer.cpp │ │ ├── R3Viewer.h │ │ ├── json.cpp │ │ └── json.h │ ├── R3Shapes │ │ ├── Makefile │ │ ├── R3Affine.cpp │ │ ├── R3Affine.h │ │ ├── R3Align.cpp │ │ ├── R3Align.h │ │ ├── R3Base.cpp │ │ ├── R3Base.h │ │ ├── R3Box.cpp │ │ ├── R3Box.h │ │ ├── R3CatmullRomSpline.cpp │ │ ├── R3CatmullRomSpline.h │ │ ├── R3Circle.cpp │ │ ├── R3Circle.h │ │ ├── R3Cone.cpp │ │ ├── R3Cone.h │ │ ├── R3Cont.cpp │ │ ├── R3Cont.h │ │ ├── R3Crdsys.cpp │ │ ├── R3Crdsys.h │ │ ├── R3Curve.cpp │ │ ├── R3Curve.h │ │ ├── R3Cylinder.cpp │ │ ├── R3Cylinder.h │ │ ├── R3Dist.cpp │ │ ├── R3Dist.h │ │ ├── R3Draw.cpp │ │ ├── R3Draw.h │ │ ├── R3Ellipse.cpp │ │ ├── R3Ellipse.h │ │ ├── R3Ellipsoid.cpp │ │ ├── R3Ellipsoid.h │ │ ├── R3Grid.cpp │ │ ├── R3Grid.h │ │ ├── R3Halfspace.cpp │ │ ├── R3Halfspace.h │ │ ├── R3Isect.cpp │ │ ├── R3Isect.h │ │ ├── R3Kdtree.cpp │ │ ├── R3Kdtree.h │ │ ├── R3Line.cpp │ │ ├── R3Line.h │ │ ├── R3Mesh.cpp │ │ ├── R3Mesh.h │ │ ├── R3MeshProperty.cpp │ │ ├── R3MeshProperty.h │ │ ├── R3MeshPropertySet.cpp │ │ ├── R3MeshPropertySet.h │ │ ├── R3MeshSearchTree.cpp │ │ ├── R3MeshSearchTree.h │ │ ├── R3OrientedBox.cpp │ │ ├── R3OrientedBox.h │ │ ├── R3Parall.cpp │ │ ├── R3Parall.h │ │ ├── R3Perp.cpp │ │ ├── R3Perp.h │ │ ├── R3PlanarGrid.cpp │ │ ├── R3PlanarGrid.h │ │ ├── R3Plane.cpp │ │ ├── R3Plane.h │ │ ├── R3Point.cpp │ │ ├── R3Point.h │ │ ├── R3Polyline.cpp │ │ ├── R3Polyline.h │ │ ├── R3Quaternion.cpp │ │ ├── R3Quaternion.h │ │ ├── R3Ray.cpp │ │ ├── R3Ray.h │ │ ├── R3Rectangle.cpp │ │ ├── R3Rectangle.h │ │ ├── R3Relate.cpp │ │ ├── R3Relate.h │ │ ├── R3Shape.cpp │ │ ├── R3Shape.h │ │ ├── R3Shapes.cpp │ │ ├── R3Shapes.h │ │ ├── R3Shapes.vcxproj │ │ ├── R3Shapes.vcxproj.filters │ │ ├── R3Solid.cpp │ │ ├── R3Solid.h │ │ ├── R3Span.cpp │ │ ├── R3Span.h │ │ ├── R3Sphere.cpp │ │ ├── R3Sphere.h │ │ ├── R3Surface.cpp │ │ ├── R3Surface.h │ │ ├── R3Triad.cpp │ │ ├── R3Triad.h │ │ ├── R3Triangle.cpp │ │ ├── R3Triangle.h │ │ ├── R3TriangleArray.cpp │ │ ├── R3TriangleArray.h │ │ ├── R3Vector.cpp │ │ ├── R3Vector.h │ │ ├── R3Xform.cpp │ │ ├── R3Xform.h │ │ ├── R4Matrix.cpp │ │ ├── R4Matrix.h │ │ ├── ply.cpp │ │ └── ply.h │ ├── RNBasics │ │ ├── Makefile │ │ ├── RNArray.I │ │ ├── RNArray.cpp │ │ ├── RNArray.h │ │ ├── RNBase.cpp │ │ ├── RNBase.h │ │ ├── RNBasics.cpp │ │ ├── RNBasics.h │ │ ├── RNBasics.vcxproj │ │ ├── RNBasics.vcxproj.filters │ │ ├── RNCompat.h │ │ ├── RNError.cpp │ │ ├── RNError.h │ │ ├── RNExtern.h │ │ ├── RNFile.cpp │ │ ├── RNFile.h │ │ ├── RNFlags.cpp │ │ ├── RNFlags.h │ │ ├── RNGrfx.I │ │ ├── RNGrfx.cpp │ │ ├── RNGrfx.h │ │ ├── RNHeap.cpp │ │ ├── RNHeap.h │ │ ├── RNIntval.cpp │ │ ├── RNIntval.h │ │ ├── RNMap.I │ │ ├── RNMap.cpp │ │ ├── RNMap.h │ │ ├── RNMem.cpp │ │ ├── RNMem.h │ │ ├── RNQueue.I │ │ ├── RNQueue.cpp │ │ ├── RNQueue.h │ │ ├── RNRgb.cpp │ │ ├── RNRgb.h │ │ ├── RNScalar.cpp │ │ ├── RNScalar.h │ │ ├── RNSvd.cpp │ │ ├── RNSvd.h │ │ ├── RNTime.cpp │ │ ├── RNTime.h │ │ ├── RNType.cpp │ │ └── RNType.h │ ├── fglut │ │ ├── AUTHORS │ │ ├── Makefile │ │ ├── README │ │ ├── cygwin_config.h │ │ ├── fglut.c │ │ ├── fglut.h │ │ ├── fglut.sln │ │ ├── fglut.vcxproj │ │ ├── fglut.vcxproj.filters │ │ ├── freeglut.h │ │ ├── freeglut_callbacks.c │ │ ├── freeglut_cursor.c │ │ ├── freeglut_display.c │ │ ├── freeglut_ext.c │ │ ├── freeglut_ext.h │ │ ├── freeglut_font.c │ │ ├── freeglut_font_data.c │ │ ├── freeglut_gamemode.c │ │ ├── freeglut_geometry.c │ │ ├── freeglut_glutfont_definitions.c │ │ ├── freeglut_init.c │ │ ├── freeglut_input_devices.c │ │ ├── freeglut_internal.h │ │ ├── freeglut_joystick.c │ │ ├── freeglut_main.c │ │ ├── freeglut_menu.c │ │ ├── freeglut_misc.c │ │ ├── freeglut_overlay.c │ │ ├── freeglut_spaceball.c │ │ ├── freeglut_state.c │ │ ├── freeglut_std.h │ │ ├── freeglut_stroke_mono_roman.c │ │ ├── freeglut_stroke_roman.c │ │ ├── freeglut_structure.c │ │ ├── freeglut_teapot.c │ │ ├── freeglut_teapot_data.h │ │ ├── freeglut_videoresize.c │ │ ├── freeglut_window.c │ │ ├── glut.h │ │ ├── linux_config.h │ │ └── mac_config.h │ ├── gaps.h │ ├── jpeg │ │ ├── Makefile │ │ ├── README │ │ ├── jcapimin.c │ │ ├── jcapistd.c │ │ ├── jccoefct.c │ │ ├── jccolor.c │ │ ├── jcdctmgr.c │ │ ├── jchuff.c │ │ ├── jchuff.h │ │ ├── jcinit.c │ │ ├── jcmainct.c │ │ ├── jcmarker.c │ │ ├── jcmaster.c │ │ ├── jcomapi.c │ │ ├── jconfig.h │ │ ├── jcparam.c │ │ ├── jcphuff.c │ │ ├── jcprepct.c │ │ ├── jcsample.c │ │ ├── jctrans.c │ │ ├── jdapimin.c │ │ ├── jdapistd.c │ │ ├── jdatadst.c │ │ ├── jdatasrc.c │ │ ├── jdcoefct.c │ │ ├── jdcolor.c │ │ ├── jdct.h │ │ ├── jddctmgr.c │ │ ├── jdhuff.c │ │ ├── jdhuff.h │ │ ├── jdinput.c │ │ ├── jdmainct.c │ │ ├── jdmarker.c │ │ ├── jdmaster.c │ │ ├── jdmerge.c │ │ ├── jdphuff.c │ │ ├── jdpostct.c │ │ ├── jdsample.c │ │ ├── jdtrans.c │ │ ├── jerror.c │ │ ├── jerror.h │ │ ├── jfdctflt.c │ │ ├── jfdctfst.c │ │ ├── jfdctint.c │ │ ├── jidctflt.c │ │ ├── jidctfst.c │ │ ├── jidctint.c │ │ ├── jidctred.c │ │ ├── jinclude.h │ │ ├── jmemmgr.c │ │ ├── jmemnobs.c │ │ ├── jmemsys.h │ │ ├── jmorecfg.h │ │ ├── jpeg.vcxproj │ │ ├── jpeg.vcxproj.filters │ │ ├── jpegint.h │ │ ├── jpeglib.h │ │ ├── jquant1.c │ │ ├── jquant2.c │ │ ├── jutils.c │ │ ├── jversion.h │ │ └── libjpeg.doc │ └── png │ │ ├── Makefile │ │ ├── PNG-LICENSE.txt │ │ ├── PNG-README.txt │ │ ├── ZLIB_README.txt │ │ ├── adler32.c │ │ ├── compress.c │ │ ├── config.h │ │ ├── crc32.c │ │ ├── crc32.h │ │ ├── deflate.c │ │ ├── deflate.h │ │ ├── example.c │ │ ├── gzclose.c │ │ ├── gzguts.h │ │ ├── gzlib.c │ │ ├── gzread.c │ │ ├── gzwrite.c │ │ ├── infback.c │ │ ├── inffast.c │ │ ├── inffast.h │ │ ├── inffixed.h │ │ ├── inflate.c │ │ ├── inflate.h │ │ ├── inftrees.c │ │ ├── inftrees.h │ │ ├── minigzip.c │ │ ├── png.c │ │ ├── png.h │ │ ├── png.vcxproj │ │ ├── png.vcxproj.filters │ │ ├── pngconf.h │ │ ├── pngerror.c │ │ ├── pngget.c │ │ ├── pngmem.c │ │ ├── pngpread.c │ │ ├── pngpriv.h │ │ ├── pngread.c │ │ ├── pngrio.c │ │ ├── pngrtran.c │ │ ├── pngrutil.c │ │ ├── pngset.c │ │ ├── pngtest.c │ │ ├── pngtrans.c │ │ ├── pngwio.c │ │ ├── pngwrite.c │ │ ├── pngwtran.c │ │ ├── pngwutil.c │ │ ├── trees.c │ │ ├── trees.h │ │ ├── uncompr.c │ │ ├── zconf.h │ │ ├── zlib.h │ │ ├── zutil.c │ │ └── zutil.h └── vc │ ├── Makefile │ ├── README.txt │ ├── glut │ ├── GL │ │ └── glut.h │ ├── README-win32.txt │ ├── glut.def │ ├── glut32.dll │ └── glut32.lib │ ├── makefiles │ ├── Makefile.apps │ ├── Makefile.pkgs │ └── Makefile.std │ └── vc.sln └── metadata ├── ModelCategoryMapping.csv ├── houseAnnoMturk.csv ├── models.csv ├── opengl_lights.txt └── suncgModelLights.json /.gitignore: -------------------------------------------------------------------------------- 1 | gaps/pkgs/*/*.o 2 | gaps/apps/*/*.o 3 | gaps/lib/*/*.a 4 | gaps/bin/*/* 5 | -------------------------------------------------------------------------------- /gaps/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 Thomas Funkhouser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gaps/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for GAPS 3 | # 4 | 5 | 6 | 7 | # 8 | # Make targets 9 | # 10 | 11 | opt: 12 | $(MAKE) target "TARGET=$@" 13 | 14 | debug: 15 | $(MAKE) target "TARGET=$@" 16 | 17 | mesa: 18 | $(MAKE) target "TARGET=$@" 19 | 20 | clean: 21 | $(MAKE) target "TARGET=$@" 22 | 23 | release: pkgs apps docs makefiles vc 24 | mkdir -p release 25 | cp README.txt release 26 | cp LICENSE.txt release 27 | cp Makefile release 28 | cp -r makefiles release 29 | $(MAKE) target "TARGET=$@" 30 | 31 | target: 32 | cd pkgs; $(MAKE) $(TARGET) 33 | cd apps; $(MAKE) $(TARGET) 34 | cd vc; $(MAKE) $(TARGET) 35 | # cd docs; $(MAKE) $(TARGET) 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /gaps/README.txt: -------------------------------------------------------------------------------- 1 | GAPS Users - 2 | 3 | This directory contains all code for the GAPS software library. 4 | There are several subdirectories: 5 | 6 | pkgs - source and include files for all packages (software libraries). 7 | apps - source files for several application and example programs. 8 | makefiles - unix-style make file definitions 9 | vc - visual studio solution files 10 | lib - archive library (.lib) files (created during compilation). 11 | bin - executable files (created during compilation). 12 | 13 | If you are using linux or cygwin and have gcc and OpenGL development 14 | libraries installed, or if you are using MAC OS X with the xcode 15 | development environment, you should be able to compile all the code by 16 | typing "make clean; make" in this directory. If you are using Windows 17 | Visual Studio 10 or later, then you should be able to open the 18 | solution file vc.sln in the vc subdirectory and then "Rebuild 19 | Solution." For other development platforms, you should edit the shared 20 | compilation settings in the makefiles/Makefiles.std to meet your needs. 21 | 22 | To write a program that uses the GAPS pkgs, then you should include 23 | "-I XXX/gaps/pkgs" in your compile flags (CFLAGS) and "-L 24 | XXX/gaps/lib" in your link flags (LDFLAGS), where XXX is the directory 25 | where you installed the gaps software. 26 | 27 | The software is distributed under the MIT license (see LICENSE.txt) 28 | and thus can be used for any purpose without warranty, any liability, 29 | or any suport of any kind. 30 | 31 | - Tom Funkhouser 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /gaps/apps/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for GAPS apps 3 | # 4 | 5 | opt: 6 | $(MAKE) target "TARGET=$@" 7 | 8 | debug: 9 | $(MAKE) target "TARGET=$@" 10 | 11 | mesa: 12 | $(MAKE) target "TARGET=$@" 13 | 14 | clean: 15 | $(MAKE) target "TARGET=$@" 16 | 17 | release: 18 | mkdir -p ../release/apps 19 | cp Makefile ../release/apps 20 | $(MAKE) target "TARGET=$@" 21 | 22 | target: 23 | cd img2img; $(MAKE) $(TARGET) 24 | cd scninfo; $(MAKE) $(TARGET) 25 | cd scn2scn; $(MAKE) $(TARGET) 26 | cd scn2cam; $(MAKE) $(TARGET) 27 | cd scn2img; $(MAKE) $(TARGET) 28 | cd scnview; $(MAKE) $(TARGET) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /gaps/apps/img2img/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Package name and list of source files. 3 | # 4 | 5 | NAME=img2img 6 | CCSRCS=$(NAME).cpp 7 | 8 | 9 | # 10 | # Dependency libraries 11 | # 12 | 13 | PKG_LIBS=-lR2Shapes -lRNBasics -ljpeg -lpng 14 | 15 | 16 | # 17 | # R3 application makefile 18 | # 19 | 20 | include ../../makefiles/Makefile.apps 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /gaps/apps/img2img/img2img.cpp: -------------------------------------------------------------------------------- 1 | // Source file for the GLUT programs 2 | 3 | 4 | // RING include files 5 | 6 | #include "R2Shapes/R2Shapes.h" 7 | 8 | 9 | 10 | int main(int argc, char **argv) 11 | { 12 | // Check arguments 13 | if (argc != 3) { 14 | fprintf(stderr, "Usage: img2img inputfile outputfile\n"); 15 | return 1; 16 | } 17 | 18 | // Read and write image file 19 | R2Image image; 20 | if (!image.Read(argv[1])) return -1; 21 | if (!image.Write(argv[2])) return -1; 22 | return 0; 23 | } 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /gaps/apps/scn2cam/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Application name and list of source files. 3 | # 4 | 5 | NAME=scn2cam 6 | CCSRCS=$(NAME).cpp 7 | 8 | 9 | # 10 | # Dependency libraries 11 | # 12 | 13 | PKG_LIBS=-lR3Graphics -lR3Shapes -lR2Shapes -lRNBasics -ljpeg -lpng 14 | 15 | 16 | # 17 | # R3 application makefile 18 | # 19 | 20 | include ../../makefiles/Makefile.apps 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /gaps/apps/scn2grd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Application name and list of source files. 3 | # 4 | 5 | NAME=scn2grd 6 | CCSRCS=$(NAME).cpp 7 | 8 | 9 | 10 | # 11 | # Dependency libraries 12 | # 13 | 14 | PKG_LIBS=-lR3Graphics -lR3Shapes -lR2Shapes -lRNBasics -ljpeg -lpng 15 | 16 | 17 | # 18 | # R3 application makefile 19 | # 20 | 21 | include ../../makefiles/Makefile.apps 22 | 23 | 24 | -------------------------------------------------------------------------------- /gaps/apps/scn2img/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Application name and list of source files. 3 | # 4 | 5 | NAME=scn2img 6 | CCSRCS=$(NAME).cpp 7 | 8 | 9 | # 10 | # Dependency libraries 11 | # 12 | 13 | PKG_LIBS=-lR3Graphics -lR3Shapes -lR2Shapes -lRNBasics -ljpeg -lpng 14 | 15 | 16 | # 17 | # R3 application makefile 18 | # 19 | 20 | include ../../makefiles/Makefile.apps 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /gaps/apps/scn2scn/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Application name and list of source files. 3 | # 4 | 5 | NAME=scn2scn 6 | CCSRCS=$(NAME).cpp 7 | 8 | 9 | 10 | # 11 | # Dependency libraries 12 | # 13 | 14 | PKG_LIBS=-lR3Graphics -lR3Shapes -lR2Shapes -lRNBasics -ljpeg -lpng 15 | 16 | 17 | # 18 | # R3 application makefile 19 | # 20 | 21 | include ../../makefiles/Makefile.apps 22 | 23 | 24 | -------------------------------------------------------------------------------- /gaps/apps/scninfo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Application name and list of source files. 3 | # 4 | 5 | NAME=scninfo 6 | CCSRCS=$(NAME).cpp 7 | 8 | 9 | # 10 | # Dependency libraries 11 | # 12 | 13 | PKG_LIBS=-lR3Graphics -lR3Shapes -lR2Shapes -lRNBasics -ljpeg -lpng 14 | 15 | 16 | # 17 | # R3 application makefile 18 | # 19 | 20 | include ../../makefiles/Makefile.apps 21 | 22 | 23 | -------------------------------------------------------------------------------- /gaps/apps/scnview/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Application name and list of source files. 3 | # 4 | 5 | NAME=scnview 6 | CCSRCS=$(NAME).cpp 7 | 8 | 9 | # 10 | # Dependency libraries 11 | # 12 | 13 | PKG_LIBS=-lR3Graphics -lR3Shapes -lR2Shapes -lRNBasics -ljpeg -lpng 14 | 15 | 16 | # 17 | # R3 application makefile 18 | # 19 | 20 | include ../../makefiles/Makefile.apps 21 | 22 | 23 | -------------------------------------------------------------------------------- /gaps/docs/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for GAPS docs 3 | # 4 | 5 | opt: 6 | ./makeall 7 | 8 | debug: 9 | ./makeall 10 | 11 | release: 12 | mkdir -p ../release/docs 13 | cp Makefile ../release/docs 14 | cp makeall ../release/docs 15 | cp makepkg ../release/docs 16 | cp makepkg.awk ../release/docs 17 | cp -r headers ../release/docs 18 | cp ./*.html ../release/docs 19 | 20 | clean: 21 | - rm -f *~ *.html 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /gaps/docs/headers/R2Shapes.header: -------------------------------------------------------------------------------- 1 |

Description:

2 | 3 | The R2Shapes package supports basics 2D geometry classes. 4 | It contains classes representing 2D primitives 5 | (such as vectors, points, etc.). It also contains 6 | classes for 2D transformations (such as 3x3 matrices, etc.) and 7 | higher level 2D shapes (such as polygons, boxes, circles, etc). 8 |

9 | For all pairs of 2D primitives (and many 2D shapes), functions are 10 | provided for computing the relationships between them. For instance, 11 | there are functions to compute the distance between primitives 12 | (R2Distance), check for intersections (R2Intersects), check whether 13 | one primitive contains another (R2Contains), compute whether 14 | primitives are perpendicular (R2Perpendicular), and check whether 15 | primitives are parallel (R2Parallel). 16 |

17 | 18 |


List of Classes:

19 |
20 | 21 |
2D Primitives: 22 |
23 |
R2Vector - 2D vector. 24 |
R2Point - 2D point. 25 |
R2Line - 2D infinite line. 26 |
R2Ray - 2D ray. 27 |
R2Span - 2D line segment. 28 |
R2Halfspace - 2D halfspace. 29 |
  30 |
31 | 32 |
2D Shapes: 33 |
34 |
R2Shape - abstract 2D shape. 35 |
R2Curve - abstract 2D curve. 36 |
R2Arc - circular arc. 37 |
R2Solid - abstract 2D filled shape. 38 |
R2Box - axis-aligned, 2D rectangle. 39 |
R2Circle - 2D circle. 40 |
R2Grid - regularly sampled 2D scalar grid. 41 |
  42 |
43 | 44 |
2D Transformations: 45 |
46 |
R2Transformation - abstract 2D transformation. 47 |
R2Affine - 2D affine transformation. 48 |
R3Matrix - 3x3 matrix. 49 |
  50 |
51 |
52 |

53 | 54 | 55 | 56 |


List of Functions:

57 | 58 |
59 |
2D Relationships: 60 |
61 |
R2Distance - returns distance between two primitives. 62 |
R2Intersects - returns whether two primitives intersect. 63 |
R2Contains - returns whether one primitive contains another. 64 |
R2Inside - returns whether one primitive is contained by another. 65 |
R2Parallel - returns whether one primitive is parallel to another. 66 |
R2Perpendicular - returns whether one primitive is perpendicular to another. 67 |
  68 |
69 |
70 |

71 | 72 | 73 | 74 |


Example:

75 | 76 | Click this to see a sample program. 77 |

78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /gaps/docs/headers/R3Graphics.header: -------------------------------------------------------------------------------- 1 |


Description:

2 | 3 | The R3Graphics package supports classes for basic computer graphics: 4 | 3D viewing, camera control, surface material properties, lighting, and scene graphs. 5 |

6 | 7 | 8 |


List of Classes:

9 | 10 |
11 |
Camera and viewport control: 12 |
13 |
R2Viewport - 2D screen viewport. 14 |
R3Camera - 3D camera (view frustum). 15 |
R3Viewer - Mapping from 3D camera to 2D viewport. 16 |
  17 |
18 | 19 |
Surface material properties: 20 |
21 |
R3Brdf - 3D bidirection reflectance distribution function. 22 |
R2Texture - 2D surface texture. 23 |
R3Material - 3D material properties (brdf, texture, and texture transformation). 24 |
R3Model - a set of 3D triangles with material properties. 25 |
  26 |
27 | 28 |
Lights: 29 |
30 |
R3Light - Light abstract class. 31 |
R3DirectionalLight - Directional light. 32 |
R3PointLight - Point light. 33 |
R3SpotLight - Spot light. 34 |
  35 |
36 | 37 |
Scene graphs: 38 |
39 |
R3Scene - scene graph. 40 |
R3SceneNode - scene graph node. 41 |
  42 |
43 |
44 |

45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /gaps/docs/headers/RNBasics.header: -------------------------------------------------------------------------------- 1 |


Description:

2 | 3 | The RNBasics package supports simple data types (RNScalar, RNInterval, 4 | RNArray, RNQueue, RNHeap) and support several OS-dependent functions 5 | (RNTime, RNMem, RNError). 6 | 7 | The RNArray, RNQueue, and RNHeap classes are implemented as templates 8 | that store collections of a specified data type (like STL classes). 9 | The storage allocation for these containers is dynamic -- it expands 10 | and contracts as entries are inserted and removed. Once a container 11 | has been constructed, entries and the data stored in them can be 12 | accessed, rearranged, or modified via member functions or iteration 13 | macros. For example, an array of three strings could be constructed 14 | and manipulated as follows: 15 | 16 |
17 |     // Construct the array
18 |     RNArray<char *> array;   // Creates an empty array
19 |     array.Insert("String1");       // Insert the 1st string
20 |     array.Insert("String2");       // Insert the 2nd string
21 |     array.Insert("String3");       // Insert the 3rd string
22 | 
23 |     // Access entries
24 |     char *data;
25 |     data = array.Head();           // data == "String1"
26 |     data = array.Tail();           // data == "String3"
27 |     data = array.Kth(0);           // data == "String1"
28 |     data = array.Kth(1);           // data == "String2"
29 |     data = array[1];               // data == "String2"
30 | 
31 |     // Access all entries
32 |     for (int i = 0; i < array.NEntries(); i++) {
33 |       char *data = array[i]
34 |       printf("%s/n", data);       
35 |     }
36 | 
37 |     // Manipulate the array
38 |     array.Reverse();               // Reverse the order of entries
39 |     array.RemoveKth(1);            // Remove the 2nd entry (first entry is at index 0)
40 |     array.InsertKth("String2", 1); // Re-insert string in 2nd entry
41 | 
42 |

43 | 44 | Other support functions include: 45 | 46 |

53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /gaps/docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | GAPS Documentation 3 | 4 | 5 | 6 |

GAPS

7 | 8 |

GAPS is a software toolkit for geometric analysis of 3D scenes.

9 | 10 |

It contains the following four packages ...

11 | 17 | 18 |

.. and several example applications:

19 | 31 | 32 |

Please view the README file for more information about compiling and linking.

33 | 34 |
35 |
funk@cs.princeton.edu
36 | 37 | 38 | -------------------------------------------------------------------------------- /gaps/docs/makeall: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | for pkg in RNBasics R2Shapes R3Shapes R3Graphics; do 4 | echo $pkg 5 | ./makepkg $pkg 6 | done 7 | 8 | -------------------------------------------------------------------------------- /gaps/docs/makepkg: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # usage : makepkg name 3 | 4 | # Create header 5 | echo "" > $1.html 6 | echo "" >> $1.html 7 | echo " $1 Package " >> $1.html 8 | echo "" >> $1.html 9 | echo "" >> $1.html 10 | echo "

$1 Package

" >> $1.html 11 | echo >> $1.html 12 | echo >> $1.html 13 | echo >> $1.html 14 | 15 | # Create description 16 | if [ -e headers/$1.header ]; then 17 | # Read description, list of classes, and examples from header 18 | cat headers/$1.header >> $1.html 19 | fi 20 | 21 | # Create class members 22 | awk -f makepkg.awk ../pkgs/$1/*.h >> $1.html 23 | sed -e "s/RNFoobar/$1/g" < $1.html > $1.html.new 24 | mv $1.html.new $1.html 25 | echo >> $1.html 26 | echo >> $1.html 27 | echo >> $1.html 28 | 29 | # Create trailer 30 | echo "
" >> $1.html 31 | echo 'Click this to go back to list of GAPS packages.' >> $1.html 32 | echo "

" >> $1.html 33 | echo "" >> $1.html 34 | echo "

funk@cs.princeton.edu
" >> $1.html 35 | echo >> $1.html 36 | echo "" >> $1.html 37 | echo >> $1.html 38 | echo >> $1.html 39 | echo >> $1.html 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /gaps/docs/makepkg.awk: -------------------------------------------------------------------------------- 1 | # Make html file with class documentation 2 | # NOTE: Does not insert inherited members 3 | 4 | $0~"class " && $0~"{" { 5 | # Parse package name and class name 6 | pkg_name = "RNFoobar"; 7 | class_name = $2; 8 | 9 | # Print class name 10 | printf "

%s

\n\n", 11 | class_name, pkg_name, class_name, class_name; 12 | 13 | # Print base classes 14 | printf "
\n"; 15 | printf "

Base Classes:

\n"; 16 | printf "
\n"; 17 | printf "

Public Base Classes:

\n"; 18 | printf "
\n"; 19 | found = 0; 20 | split($0, s0); 21 | for (i = 3; i <= NF; i++) { 22 | if (s0[i] == "public") { 23 | printf "
%s\n", $(i+1), $(i+1) 24 | found = 1; 25 | } 26 | } 27 | if (!found) printf "
\tNone\n"; 28 | printf "
\n"; 29 | printf "

\n"; 30 | 31 | # Print member functions 32 | printf "

Member Functions:

\n"; 33 | printf "
\n"; 34 | active = 0; 35 | first = 1; 36 | } 37 | 38 | $0~"};" { 39 | if (!first) printf "
\n"; 40 | printf "
\n"; 41 | printf "\n\n\n\n"; 42 | printf "

\n"; 43 | active = 0; 44 | } 45 | 46 | { 47 | sub("\r$", ""); 48 | if ($1 == "public:") { 49 | active = 1; 50 | } 51 | else if (($1 == "protected:") || ($1 == "private:")) { 52 | active = 0; 53 | } 54 | else if (active) { 55 | if ($1 == "//") { 56 | split($0, s0) 57 | if (!first) printf "\n"; 58 | printf "

"; 59 | for (i = 2; i <= NF; i++) printf " %s", s0[i]; 60 | printf ":

\n"; 61 | printf "
\n"; 62 | first = 0; 63 | } 64 | else { 65 | print "
" $0; 66 | } 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /gaps/makefiles/Makefile.apps: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for GAPS applications 3 | # 4 | 5 | 6 | 7 | # 8 | # Before this Makefile is included ... 9 | # $(NAME) should be module name 10 | # $(CCSRCS) should list C++ source files 11 | # $(CSRCS) should list C source files 12 | # 13 | # For example ... 14 | # NAME=foo 15 | # CCSRCS=$(NAME).cpp \ 16 | # foo1.cpp foo2.cpp foo3.cpp 17 | # CSRCS=foo4.c foo5.c 18 | # 19 | 20 | 21 | # 22 | # Set up compiler options, etc. 23 | # 24 | 25 | include ../../makefiles/Makefile.std 26 | 27 | 28 | 29 | 30 | # 31 | # Set up target app 32 | # 33 | 34 | EXE = $(EXE_DIR)/$(NAME) 35 | 36 | 37 | 38 | # 39 | # Set up link options 40 | # 41 | 42 | BASE_LDFLAGS=$(USER_LDFLAGS) -L$(LIB_DIR) 43 | DEBUG_LDFLAGS=$(BASE_LDFLAGS) -g 44 | OPT_LDFLAGS=$(BASE_LDFLAGS) -O 45 | LDFLAGS=$(DEBUG_LDFLAGS) 46 | 47 | 48 | # 49 | # Set up libs 50 | # 51 | 52 | ifeq ("$(findstring CYGWIN,$(OS))", "CYGWIN") 53 | #OPENGL_LIBS=-lglut32 -lglu32 -lopengl32 54 | OPENGL_LIBS=-lfglut -lglu32 -lopengl32 -lwinmm -lgdi32 55 | else ifeq ("$(OS)","Darwin") 56 | OPENGL_LIBS=-framework GLUT -framework opengl 57 | else 58 | #OPENGL_LIBS=-lglut -lGLU -lGL -lX11 -lm 59 | OPENGL_LIBS=-lfglut -lGLU -lGL -lX11 -lm 60 | endif 61 | LIBS=$(PKG_LIBS) $(USER_LIBS) $(OPENGL_LIBS) 62 | 63 | 64 | 65 | # 66 | # Make targets 67 | # 68 | 69 | opt: 70 | $(MAKE) $(EXE) "CFLAGS=$(OPT_CFLAGS)" "LDFLAGS=$(OPT_LDFLAGS)" 71 | 72 | debug: 73 | $(MAKE) $(EXE) "CFLAGS=$(DEBUG_CFLAGS)" "LDFLAGS=$(DEBUG_LDFLAGS)" 74 | 75 | mesa: 76 | $(MAKE) $(EXE) "CFLAGS=$(OPT_CFLAGS) -DUSE_MESA" "LDFLAGS=$(OPT_LDFLAGS) -lOSMesa" 77 | 78 | $(EXE): $(OBJS) $(LIB_DIR)/*.a 79 | mkdir -p $(EXE_DIR) 80 | $(CC) -o $(EXE) $(LDFLAGS) $(USER_OBJS) $(OBJS) $(LIBS) 81 | 82 | release: 83 | mkdir -p $(RELEASE_DIR)/apps 84 | mkdir $(RELEASE_DIR)/apps/$(NAME)1 85 | cp *\.[!o]* $(RELEASE_DIR)/apps/$(NAME)1 86 | cp Makefile $(RELEASE_DIR)/apps/$(NAME)1 87 | cp $(NAME).vcxproj $(RELEASE_DIR)/apps/$(NAME)1 88 | rm -r -f $(RELEASE_DIR)/apps/$(NAME) 89 | mv $(RELEASE_DIR)/apps/$(NAME)1 $(RELEASE_DIR)/apps/$(NAME) 90 | 91 | clean: 92 | - rm -f *~ *.o $(EXE) 93 | 94 | 95 | 96 | # 97 | # Dependencies 98 | # 99 | 100 | PKG_LIBS += $(foreach pkg, $(PKG_DEPENDENCIES), -l$(pkg)) 101 | PKG_LIST=$(subst -l,,$(PKG_LIBS)) 102 | $(OBJS) : Makefile $(wildcard *.h) $(foreach pkg, $(PKG_LIST), ../../pkgs/$(pkg)/*.h) $(USER_DEPENDENCIES) 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /gaps/makefiles/Makefile.pkgs: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for GAPS packages 3 | # 4 | 5 | 6 | 7 | # 8 | # Before this Makefile is included ... 9 | # $(NAME) should be module name 10 | # $(CCSRCS) should list C++ source files 11 | # $(CSRCS) should list C source files 12 | # 13 | # For example ... 14 | # NAME=foo 15 | # CCSRCS=$(NAME).cpp \ 16 | # foo1.cpp foo2.cpp foo3.cpp 17 | # CSRCS=foo4.c foo5.c 18 | # 19 | 20 | 21 | # 22 | # Set up compiler options, etc. 23 | # 24 | 25 | include ../../makefiles/Makefile.std 26 | 27 | 28 | 29 | # 30 | # Set up target name 31 | # 32 | 33 | LIB=$(LIB_DIR)/lib$(NAME).a 34 | 35 | 36 | 37 | # 38 | # Make targets 39 | # 40 | 41 | opt: 42 | $(MAKE) $(LIB) "CFLAGS=$(OPT_CFLAGS)" 43 | 44 | debug: 45 | $(MAKE) $(LIB) "CFLAGS=$(DEBUG_CFLAGS)" 46 | 47 | $(LIB): $(CCSRCS) $(CSRCS) $(OSRCS) $(OBJS) $(DEPENDENCIES) 48 | mkdir -p $(LIB_DIR) 49 | rm -f $(LIB) 50 | ar ur $(LIB) $(OBJS) $(USER_OBJS) 51 | 52 | release: 53 | mkdir -p $(RELEASE_DIR)/pkgs 54 | mkdir $(RELEASE_DIR)/pkgs/$(NAME)1 55 | cp *\.[!o]* $(RELEASE_DIR)/pkgs/$(NAME)1 56 | cp Makefile $(RELEASE_DIR)/pkgs/$(NAME)1 57 | cp $(NAME).vcxproj $(RELEASE_DIR)/pkgs/$(NAME)1 58 | rm -r -f $(RELEASE_DIR)/pkgs/$(NAME) 59 | mv $(RELEASE_DIR)/pkgs/$(NAME)1 $(RELEASE_DIR)/pkgs/$(NAME) 60 | 61 | clean: 62 | - rm -f *~ *.o $(LIB) 63 | 64 | 65 | 66 | # 67 | # Dependencies 68 | # 69 | 70 | $(OBJS) : Makefile *.h $(foreach pkg, $(PKG_DEPENDENCIES), ../$(pkg)/*.h) $(USER_DEPENDENCIES) 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /gaps/makefiles/Makefile.std: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile setup for GAPS 3 | # 4 | 5 | 6 | 7 | # 8 | # Targets 9 | # 10 | 11 | OBJS=$(CCSRCS:.cpp=.o) $(CSRCS:.c=.o) 12 | INCS=$(HSRCS) $(CCSRCS:.cpp=.h) $(CSRCS:.c=.h) 13 | 14 | 15 | 16 | # 17 | # Get the operating system and architecture type 18 | # 19 | 20 | OS=$(shell uname -s) 21 | ARCH=$(shell uname -m) 22 | 23 | 24 | 25 | # 26 | # C flags 27 | # 28 | 29 | #ifeq ("$(findstring CYGWIN,$(OS))", "CYGWIN") 30 | #OS_CFLAGS=-Wl,-stack_size,0x100000000 31 | #endif 32 | 33 | CC=g++ 34 | BASE_CFLAGS=$(USER_CFLAGS) $(OS_CFLAGS) -Wall -I. -I../../pkgs 35 | DEBUG_CFLAGS=$(BASE_CFLAGS) -g 36 | OPT_CFLAGS=$(BASE_CFLAGS) -O3 -DNDEBUG 37 | CFLAGS=$(DEBUG_CFLAGS) 38 | 39 | #ifeq ("$(OS)","Darwin") 40 | # BASE_CFLAGS=$(USER_CFLAGS) $(OS_CFLAGS) -Wall -I. -I../../pkgs -Wno-deprecated-declarations 41 | #endif 42 | 43 | 44 | 45 | # 46 | # Directories 47 | # 48 | 49 | RELEASE_DIR=../../release 50 | EXE_DIR=../../bin/$(ARCH) 51 | LIB_DIR=../../lib/$(ARCH) 52 | 53 | 54 | 55 | # 56 | # Default rules 57 | # 58 | 59 | .SUFFIXES: .cpp .C .c .o 60 | 61 | .cpp.o: 62 | $(CC) $(CFLAGS) -c $< 63 | 64 | .C.o: 65 | $(CC) $(CFLAGS) -c $< 66 | 67 | .c.o: 68 | gcc $(CFLAGS) -c $< 69 | 70 | -------------------------------------------------------------------------------- /gaps/pkgs/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for GAPS pkgs 3 | # 4 | 5 | 6 | # 7 | # Library file names 8 | # 9 | 10 | ARCH=$(shell uname -m) 11 | LIB_DIR=../lib/$(ARCH) 12 | LIB=$(LIB_DIR)/libgaps.a 13 | PKG_LIBS= \ 14 | $(LIB_DIR)/libR3Graphics.a \ 15 | $(LIB_DIR)/libR3Shapes.a \ 16 | $(LIB_DIR)/libR2Shapes.a \ 17 | $(LIB_DIR)/libRNBasics.a \ 18 | $(LIB_DIR)/libjpeg.a \ 19 | $(LIB_DIR)/libpng.a 20 | 21 | 22 | # 23 | # Make targets 24 | # 25 | 26 | opt: 27 | $(MAKE) target "TARGET=$@" 28 | rm -f $(LIB) 29 | ar ur $(LIB) $(PKG_LIBS) 30 | 31 | debug: 32 | $(MAKE) target "TARGET=$@" 33 | rm -f $(LIB) 34 | ar ur $(LIB) $(PKG_LIBS) 35 | 36 | mesa: 37 | $(MAKE) opt 38 | 39 | clean: 40 | $(MAKE) target "TARGET=$@" 41 | 42 | release: 43 | mkdir -p ../release/pkgs 44 | cp Makefile ../release/pkgs 45 | $(MAKE) target "TARGET=$@" 46 | 47 | target: 48 | cd RNBasics; $(MAKE) $(TARGET) 49 | cd R2Shapes; $(MAKE) $(TARGET) 50 | cd R3Shapes; $(MAKE) $(TARGET) 51 | cd R3Graphics; $(MAKE) $(TARGET) 52 | cd fglut; $(MAKE) $(TARGET) 53 | cd jpeg; $(MAKE) $(TARGET) 54 | cd png; $(MAKE) $(TARGET) 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Package name 3 | # 4 | 5 | NAME=R2Shapes 6 | 7 | 8 | 9 | # 10 | # List of source files 11 | # 12 | 13 | CCSRCS=R2Shapes.cpp \ 14 | R2Draw.cpp R2Io.cpp R2Kdtree.cpp \ 15 | R2Dist.cpp R2Cont.cpp R2Isect.cpp R2Parall.cpp R2Perp.cpp R2Relate.cpp R2Align.cpp \ 16 | R2Grid.cpp \ 17 | R2Polyline.cpp R2Arc.cpp R2Curve.cpp \ 18 | R2Polygon.cpp R2Circle.cpp R2Box.cpp R2Solid.cpp \ 19 | R2Shape.cpp \ 20 | R2Affine.cpp R2Xform.cpp R2Crdsys.cpp R2Diad.cpp R3Matrix.cpp \ 21 | R2Halfspace.cpp R2Span.cpp R2Ray.cpp R2Line.cpp R2Point.cpp R2Vector.cpp \ 22 | R2Image.cpp 23 | 24 | 25 | # 26 | # Dependencies 27 | # 28 | 29 | PKG_DEPENDENCIES = RNBasics jpeg png 30 | 31 | 32 | 33 | # 34 | # PKG makefile 35 | # 36 | 37 | include ../../makefiles/Makefile.pkgs 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Align.h: -------------------------------------------------------------------------------- 1 | // Include file for alignment utility functions 2 | 3 | 4 | 5 | // Functions to align RNArray of points 6 | 7 | R2Point R2Centroid(const RNArray& points, const RNScalar *weights = NULL); 8 | R2Diad R2PrincipleAxes(const R2Point& centroid, const RNArray& points, const RNScalar *weights = NULL, RNScalar *variances = NULL); 9 | RNLength R2AverageDistance(const R2Point& center, const RNArray& points, const RNScalar *weights = NULL); 10 | R2Affine R2NormalizationTransformation(const RNArray& points, 11 | RNBoolean align_center = TRUE, RNBoolean align_rotation = TRUE, int align_scale = 1); 12 | RNScalar R2AlignError(const RNArray& points1, const RNArray& points2, 13 | const R3Matrix& matrix = R3identity_matrix, const RNScalar* weights = NULL); 14 | R3Matrix R2AlignPoints(const RNArray& points1, const RNArray& poitns2, const RNScalar* weights = NULL, 15 | RNBoolean align_center = TRUE, RNBoolean align_rotation = TRUE, int align_scale = 1); 16 | 17 | 18 | 19 | // Functions to align C array of points 20 | 21 | R2Point R2Centroid(int npoints, R2Point *points, const RNScalar *weights = NULL); 22 | R2Diad R2PrincipleAxes(const R2Point& centroid, int npoints, R2Point *points, const RNScalar *weights = NULL, RNScalar *variances = NULL); 23 | RNLength R2AverageDistance(const R2Point& center, int npoints, R2Point *points, const RNScalar *weights = NULL); 24 | R2Affine R2NormalizationTransformation(int npoints, R2Point *points, 25 | RNBoolean align_center = TRUE, RNBoolean align_rotation = TRUE, int align_scale = 1); 26 | RNScalar R2AlignError(int npoints, R2Point *points1, R2Point *points2, 27 | const R3Matrix& matrix = R3identity_matrix, RNScalar* weights = NULL); 28 | R3Matrix R2AlignPoints(int npoints, R2Point *points1, R2Point *points2, const RNScalar* weights = NULL, 29 | RNBoolean align_center = TRUE, RNBoolean align_rotation = TRUE, int align_scale = 1); 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Circle.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R2 circle class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R2InitCircle(); 8 | void R2StopCircle(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R2Circle : public R2Solid { 15 | public: 16 | // Constructor functions 17 | R2Circle(void); 18 | R2Circle(const R2Circle& circle); 19 | R2Circle(const R2Point& center, RNLength radius); 20 | 21 | // Circle property functions/operators 22 | const R2Point& Center(void) const; 23 | const RNLength Radius(void) const; 24 | const RNBoolean IsEmpty(void) const; 25 | const RNBoolean IsFinite(void) const; 26 | 27 | // Shape property functions/operators 28 | virtual const RNBoolean IsPoint(void) const; 29 | virtual const RNBoolean IsLinear(void) const ; 30 | virtual const RNBoolean IsConvex(void) const ; 31 | virtual const RNArea Area(void) const; 32 | virtual const R2Point Centroid(void) const; 33 | virtual const R2Shape& BShape(void) const; 34 | virtual const R2Box BBox(void) const; 35 | virtual const R2Circle BCircle(void) const; 36 | 37 | // Manipulation functions/operators 38 | virtual void Empty(void); 39 | virtual void Translate(const R2Vector& vector); 40 | virtual void Reposition(const R2Point& center); 41 | virtual void Resize(RNLength radius); 42 | virtual void Transform(const R2Transformation& transformation); 43 | 44 | // Draw functions/operators 45 | virtual void Draw(const R2DrawFlags draw_flags = R2_DEFAULT_DRAW_FLAGS) const; 46 | 47 | private: 48 | R2Point center; 49 | RNLength radius; 50 | }; 51 | 52 | 53 | 54 | /* Public variables */ 55 | 56 | extern const R2Circle R2null_circle; 57 | extern const R2Circle R2zero_circle; 58 | extern const R2Circle R2unit_circle; 59 | extern const R2Circle R2infinite_circle; 60 | 61 | extern const int R2circle_npoints; 62 | extern RNAngle R2circle_angles[]; 63 | extern R2Point R2circle_points[]; 64 | 65 | 66 | 67 | /* Inline functions */ 68 | 69 | inline const R2Point& R2Circle:: 70 | Center(void) const 71 | { 72 | // Return circle center 73 | return center; 74 | } 75 | 76 | 77 | 78 | inline const RNLength R2Circle:: 79 | Radius(void) const 80 | { 81 | // Return circle radius 82 | return radius; 83 | } 84 | 85 | 86 | 87 | inline const RNBoolean R2Circle:: 88 | IsEmpty(void) const 89 | { 90 | // Return whether the circle is null 91 | return (radius < 0.0); 92 | } 93 | 94 | 95 | 96 | inline const RNBoolean R2Circle:: 97 | IsFinite(void) const 98 | { 99 | // Return whether the circle has finite radius 100 | return RNIsFinite(radius); 101 | } 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Crdsys.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the GAPS coordinatesystem class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | const R2CoordSystem R2xy_coordinate_system(R2Point(0.0, 0.0), R2Diad(R2Vector(1.0, 0.0), R2Vector(0.0, 1.0))); 14 | 15 | 16 | 17 | /* Public functions */ 18 | 19 | int R2InitCoordinateSystem() 20 | { 21 | /* Return success */ 22 | return TRUE; 23 | } 24 | 25 | 26 | 27 | void R2StopCoordinateSystem() 28 | { 29 | } 30 | 31 | 32 | 33 | R2CoordSystem:: 34 | R2CoordSystem(void) 35 | { 36 | } 37 | 38 | 39 | 40 | R2CoordSystem:: 41 | R2CoordSystem(const R2CoordSystem& cs) 42 | : origin(cs.origin), 43 | axes(cs.axes) 44 | { 45 | } 46 | 47 | 48 | 49 | R2CoordSystem:: 50 | R2CoordSystem(const R2Point& origin, const R2Diad& axes) 51 | : origin(origin), 52 | axes(axes) 53 | { 54 | } 55 | 56 | 57 | 58 | const R3Matrix R2CoordSystem:: 59 | Matrix(void) const 60 | { 61 | // Return matrix (std -> cs) 62 | R3Matrix m(R3identity_matrix); 63 | m.Translate(origin.Vector()); 64 | m.Transform(axes.Matrix()); 65 | return m; 66 | } 67 | 68 | 69 | 70 | const R3Matrix R2CoordSystem:: 71 | InverseMatrix(void) const 72 | { 73 | // Return matrix (cs -> std) 74 | R3Matrix m(axes.InverseMatrix()); 75 | m.Translate(-origin.Vector()); 76 | return m; 77 | } 78 | 79 | 80 | 81 | void R2CoordSystem:: 82 | SetOrigin(const R2Point& origin) 83 | { 84 | // Set origin 85 | this->origin = origin; 86 | } 87 | 88 | 89 | 90 | void R2CoordSystem:: 91 | SetAxes(const R2Diad& axes) 92 | { 93 | // Set axes 94 | this->axes = axes; 95 | } 96 | 97 | 98 | 99 | void R2CoordSystem:: 100 | Translate(const R2Vector& offset) 101 | { 102 | // Translate origin 103 | origin.Translate(offset); 104 | } 105 | 106 | 107 | 108 | void R2CoordSystem:: 109 | Rotate(RNAngle radians) 110 | { 111 | // Rotate axes only 112 | axes.Rotate(radians); 113 | // Normalize to avoid accumulation of error ??? 114 | axes.Normalize(); 115 | } 116 | 117 | 118 | 119 | void R2CoordSystem:: 120 | Mirror (const R2Line& line) 121 | { 122 | // Mirror origin and axes 123 | origin.Mirror(line); 124 | axes.Mirror(line); 125 | } 126 | 127 | 128 | 129 | void R2CoordSystem:: 130 | Transform (const R2Transformation& transformation) 131 | { 132 | // Transform origin and axes 133 | origin.Transform(transformation); 134 | axes.Transform(transformation); 135 | // Normalize to avoid accumulation of error ??? 136 | axes.Normalize(); 137 | } 138 | 139 | 140 | 141 | void R2CoordSystem:: 142 | InverseTransform (const R2Transformation& transformation) 143 | { 144 | // Transform origin and axes 145 | origin.InverseTransform(transformation); 146 | axes.InverseTransform(transformation); 147 | // Normalize to avoid accumulation of error ??? 148 | axes.Normalize(); 149 | } 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Crdsys.h: -------------------------------------------------------------------------------- 1 | /* Include file for the GAPS coordinate system class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R2InitCoordinateSystem(); 8 | void R2StopCoordinateSystem(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R2CoordSystem /* : public R2Base */ { 15 | public: 16 | // Constructor functions 17 | R2CoordSystem(void); 18 | R2CoordSystem(const R2CoordSystem& cs); 19 | R2CoordSystem(const R2Point& origin, const R2Diad& axes); 20 | 21 | // Property functions/operators 22 | const R2Point& Origin(void) const; 23 | const R2Diad& Axes(void) const; 24 | const R3Matrix Matrix(void) const; 25 | const R3Matrix InverseMatrix(void) const; 26 | const RNBoolean operator==(const R2CoordSystem& cs) const; 27 | const RNBoolean operator!=(const R2CoordSystem& cs) const; 28 | 29 | // Manipulation functions/operators 30 | void Translate(const R2Vector& offset); 31 | void Rotate(RNAngle radians); 32 | void Mirror(const R2Line& line); 33 | void Transform(const R2Transformation& transformation); 34 | void InverseTransform(const R2Transformation& transformation); 35 | void SetOrigin(const R2Point& origin); 36 | void SetAxes(const R2Diad& axes); 37 | 38 | // Draw functions/operators 39 | void Draw(void) const; 40 | void Outline(void) const; 41 | 42 | private: 43 | R2Point origin; 44 | R2Diad axes; 45 | }; 46 | 47 | 48 | 49 | /* Public variables */ 50 | 51 | extern const R2CoordSystem R2xy_coordinate_system; 52 | 53 | 54 | 55 | /* Inline functions */ 56 | 57 | inline const R2Point& R2CoordSystem:: 58 | Origin(void) const 59 | { 60 | // Return origin 61 | return origin; 62 | } 63 | 64 | 65 | 66 | inline const R2Diad& R2CoordSystem:: 67 | Axes(void) const 68 | { 69 | // Return axes diad 70 | return axes; 71 | } 72 | 73 | 74 | 75 | inline const RNBoolean R2CoordSystem:: 76 | operator==(const R2CoordSystem& cs) const 77 | { 78 | // Return whether coordinate system is equal 79 | return (origin == cs.origin) && (axes == cs.axes); 80 | } 81 | 82 | 83 | 84 | inline const RNBoolean R2CoordSystem:: 85 | operator!=(const R2CoordSystem& cs) const 86 | { 87 | // Return whether coordinate system is not equal 88 | return !(*this == cs); 89 | } 90 | 91 | 92 | 93 | inline void R2CoordSystem:: 94 | Outline(void) const 95 | { 96 | // Draw coordinate system 97 | Draw(); 98 | } 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Curve.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R2 curve class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | /* Public functions */ 12 | 13 | int 14 | R2InitCurve() 15 | { 16 | /* Return success */ 17 | return TRUE; 18 | } 19 | 20 | 21 | 22 | void 23 | R2StopCurve() 24 | { 25 | } 26 | 27 | 28 | 29 | R2Curve:: 30 | R2Curve(void) 31 | { 32 | } 33 | 34 | 35 | 36 | R2Curve:: 37 | ~R2Curve(void) 38 | { 39 | } 40 | 41 | 42 | 43 | const RNBoolean R2Curve:: 44 | IsCurve(void) const 45 | { 46 | // All curve shapes are curves 47 | return TRUE; 48 | } 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Curve.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R2 curve class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R2InitCurve(); 8 | void R2StopCurve(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R2Curve : public R2Shape { 15 | public: 16 | // Constructors/destructors ??? 17 | R2Curve(void); 18 | ~R2Curve(void); 19 | 20 | // Shape property functions/operators 21 | const RNBoolean IsCurve(void) const; 22 | 23 | // Curve property functions/operators 24 | // virtual const R2Point Start(void) const = 0; 25 | // virtual const R2Point End(void) const = 0; 26 | }; 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Diad.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the GAPS diad class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | const R2Diad R2xy_diad(R2Vector(1.0, 0.0), R2Vector(0.0, 1.0)); 14 | 15 | 16 | 17 | /* Public functions */ 18 | 19 | int R2InitDiad() 20 | { 21 | /* Return success */ 22 | return TRUE; 23 | } 24 | 25 | 26 | 27 | void R2StopDiad() 28 | { 29 | } 30 | 31 | 32 | 33 | R2Diad:: 34 | R2Diad(void) 35 | { 36 | } 37 | 38 | 39 | 40 | R2Diad:: 41 | R2Diad(const R2Diad& diad) 42 | { 43 | axis[0] = diad.axis[0]; 44 | axis[1] = diad.axis[1]; 45 | } 46 | 47 | 48 | 49 | R2Diad:: 50 | R2Diad(const R2Vector& xaxis, const R2Vector& yaxis) 51 | { 52 | // Just checking ... 53 | assert(xaxis.IsNormalized()); 54 | assert(yaxis.IsNormalized()); 55 | assert(R2Perpendicular(xaxis, yaxis)); 56 | 57 | // Assign axes 58 | axis[0] = xaxis; 59 | axis[1] = yaxis; 60 | } 61 | 62 | 63 | 64 | const R3Matrix R2Diad:: 65 | Matrix(void) const 66 | { 67 | // Return change of basis matrix (std -> diad) 68 | return R3Matrix(axis[0].X(), axis[1].X(), 0.0, 69 | axis[0].Y(), axis[1].Y(), 0.0, 70 | 0.0, 0.0, 1.0); 71 | } 72 | 73 | 74 | 75 | const R3Matrix R2Diad:: 76 | InverseMatrix(void) const 77 | { 78 | // Return change of basis matrix (diad -> std) 79 | return R3Matrix(axis[0].X(), axis[0].Y(), 0.0, 80 | axis[1].X(), axis[1].Y(), 0.0, 81 | 0.0, 0.0, 1.0); 82 | } 83 | 84 | 85 | 86 | void R2Diad:: 87 | Normalize(void) 88 | { 89 | // Normalize each axis 90 | axis[0].Normalize(); 91 | axis[1].Normalize(); 92 | } 93 | 94 | 95 | 96 | void R2Diad:: 97 | Rotate(RNAngle radians) 98 | { 99 | // Mirror each axis 100 | axis[0].Rotate(radians); 101 | axis[1].Rotate(radians); 102 | } 103 | 104 | 105 | 106 | void R2Diad:: 107 | Mirror(const R2Line& line) 108 | { 109 | // Mirror each axis 110 | axis[0].Mirror(line); 111 | axis[1].Mirror(line); 112 | } 113 | 114 | 115 | 116 | void R2Diad:: 117 | Transform(const R2Transformation& transformation) 118 | { 119 | // Transform each axis 120 | axis[0].Transform(transformation); 121 | axis[1].Transform(transformation); 122 | } 123 | 124 | 125 | 126 | void R2Diad:: 127 | InverseTransform(const R2Transformation& transformation) 128 | { 129 | // Transform each axis 130 | axis[0].InverseTransform(transformation); 131 | axis[1].InverseTransform(transformation); 132 | } 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Diad.h: -------------------------------------------------------------------------------- 1 | /* Include file for the GAPS diad class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R2InitDiad(); 8 | void R2StopDiad(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R2Diad /* : public R2Base */ { 15 | public: 16 | // Constructor functions 17 | R2Diad(void); 18 | R2Diad(const R2Diad& diad); 19 | R2Diad(const R2Vector& xaxis, const R2Vector& yaxis); 20 | 21 | // Property functions/operators 22 | const R3Matrix Matrix(void) const; 23 | const R3Matrix InverseMatrix(void) const; 24 | const R2Vector& Axis(RNDimension dim) const; 25 | const R2Vector& operator[](RNDimension dim) const; 26 | const RNBoolean operator==(const R2Diad& diad) const; 27 | const RNBoolean operator!=(const R2Diad& diad) const; 28 | 29 | // Manipulation functions/operators 30 | void Normalize(void); 31 | void Rotate(RNAngle radians); 32 | void Mirror(const R2Line& line); 33 | void Transform(const R2Transformation& transformation); 34 | void InverseTransform(const R2Transformation& transformation); 35 | R2Diad& operator=(const R2Diad& diad); 36 | 37 | // Draw functions/operators 38 | void Draw(void) const; 39 | void Outline(void) const; 40 | 41 | private: 42 | R2Vector axis[2]; 43 | }; 44 | 45 | 46 | 47 | /* Public variables */ 48 | 49 | extern const R2Diad R2xy_diad; 50 | 51 | 52 | 53 | /* Inline functions */ 54 | 55 | inline const R2Vector& R2Diad:: 56 | Axis(RNDimension dim) const 57 | { 58 | // Return axis vector 59 | assert((dim >= RN_X) && (dim <= RN_Y)); 60 | return axis[dim]; 61 | } 62 | 63 | 64 | 65 | inline const R2Vector& R2Diad:: 66 | operator[](RNDimension dim) const 67 | { 68 | // Return axis vector 69 | return Axis(dim); 70 | } 71 | 72 | 73 | 74 | inline const RNBoolean R2Diad:: 75 | operator==(const R2Diad& diad) const 76 | { 77 | // Return whether diad is equal 78 | // We can check only one of the three since everything is orthonormal 79 | return (axis[0] == diad.axis[0]); 80 | } 81 | 82 | 83 | 84 | inline const RNBoolean R2Diad:: 85 | operator!=(const R2Diad& diad) const 86 | { 87 | // Return whether diad is not equal 88 | return !(*this == diad); 89 | } 90 | 91 | 92 | 93 | inline void R2Diad:: 94 | Outline(void) const 95 | { 96 | // Draw diad 97 | Draw(); 98 | } 99 | 100 | 101 | 102 | inline R2Diad& R2Diad:: 103 | operator=(const R2Diad& diad) 104 | { 105 | axis[0] = diad.axis[0]; 106 | axis[1] = diad.axis[1]; 107 | return *this; 108 | } 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Draw.h: -------------------------------------------------------------------------------- 1 | /* Include file for R2 draw utility */ 2 | 3 | 4 | 5 | inline void 6 | R2LoadPoint(const R2Point& point) 7 | { 8 | // Load vertex 9 | R2LoadPoint(point.Coords()); 10 | } 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Halfspace.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the GAPS halfspace class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | const R2Halfspace R2null_halfspace(0.0, 0.0, 0.0); 14 | const R2Halfspace R2posx_halfspace(1.0, 0.0, 0.0); 15 | const R2Halfspace R2posy_halfspace(0.0, 1.0, 0.0); 16 | const R2Halfspace R2negx_halfspace(-1.0, 0.0, 0.0); 17 | const R2Halfspace R2negy_halfspace(0.0, -1.0, 0.0); 18 | 19 | 20 | 21 | /* Public functions */ 22 | 23 | int 24 | R2InitHalfspace() 25 | { 26 | /* Return success */ 27 | return TRUE; 28 | } 29 | 30 | 31 | 32 | void 33 | R2StopHalfspace() 34 | { 35 | } 36 | 37 | 38 | 39 | R2Halfspace:: 40 | R2Halfspace (void) 41 | { 42 | } 43 | 44 | 45 | 46 | R2Halfspace:: 47 | R2Halfspace (const R2Halfspace& halfspace) 48 | : line(halfspace.line) 49 | { 50 | } 51 | 52 | 53 | 54 | R2Halfspace:: 55 | R2Halfspace(RNScalar a, RNScalar b, RNScalar c) 56 | : line(a, b, c) 57 | { 58 | } 59 | 60 | 61 | 62 | R2Halfspace:: 63 | R2Halfspace(const RNScalar a[3]) 64 | : line(a) 65 | { 66 | } 67 | 68 | 69 | 70 | R2Halfspace:: 71 | R2Halfspace(const R2Point& point, const R2Vector& normal) 72 | : line(point, R2Vector(-normal.Y(), normal.X())) 73 | { 74 | } 75 | 76 | 77 | 78 | R2Halfspace:: 79 | R2Halfspace(const R2Point& point1, const R2Point& point2) 80 | : line(point1, point2) 81 | { 82 | } 83 | 84 | 85 | 86 | R2Halfspace:: 87 | R2Halfspace(const R2Line& line, int ) 88 | : line(line) 89 | { 90 | } 91 | 92 | 93 | 94 | void R2Halfspace:: 95 | Mirror (const R2Line& line) 96 | { 97 | // Mirror halfspace with respect to line 98 | this->line.Mirror(line); 99 | } 100 | 101 | 102 | 103 | void R2Halfspace:: 104 | Transform (const R2Transformation& transformation) 105 | { 106 | // Transform halfspace 107 | line.Transform(transformation); 108 | } 109 | 110 | 111 | 112 | void R2Halfspace:: 113 | InverseTransform (const R2Transformation& transformation) 114 | { 115 | // Transform halfspace 116 | line.InverseTransform(transformation); 117 | } 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Io.h: -------------------------------------------------------------------------------- 1 | /* Include file for input/output utility */ 2 | 3 | 4 | 5 | /* Function declarations */ 6 | 7 | RNArray *R2ReadSpans(RNArray& spans, const char *filename); 8 | RNArray *R2ReadWiseFile(RNArray& spans, const char *filename); 9 | RNArray *R2ReadXFigFile(RNArray& spans, const char *filename); 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Kdtree.h: -------------------------------------------------------------------------------- 1 | // Include file for KDTree class 2 | 3 | #ifndef __R2KDTREE__H__ 4 | #define __R2KDTREE__H__ 5 | 6 | 7 | 8 | // Node declaration 9 | 10 | template 11 | class R2KdtreeNode; 12 | 13 | 14 | 15 | // Class declaration 16 | 17 | template 18 | class R2Kdtree { 19 | public: 20 | // Constructor/destructors 21 | R2Kdtree(const R2Box& bbox, int position_offset = 0); 22 | R2Kdtree(const RNArray& points, int position_offset = 0); 23 | R2Kdtree(const RNArray& points, R2Point (*position_callback)(PtrType, void *), void *data); 24 | ~R2Kdtree(void); 25 | 26 | // Property functions 27 | const R2Box& BBox(void) const; 28 | int NNodes(void) const; 29 | 30 | // Search for closest to a point 31 | PtrType FindClosest(PtrType point, RNLength min_distance = 0, RNLength max_distance = RN_INFINITY, RNLength *closest_distance = NULL) const; 32 | PtrType FindClosest(const R2Point& position, RNLength min_distance = 0, RNLength max_distance = RN_INFINITY, RNLength *closest_distance = NULL) const; 33 | 34 | // Search for all within some distance to a point 35 | int FindAll(PtrType point, RNLength min_distance, RNLength max_distance, RNArray& points) const; 36 | int FindAll(const R2Point& position, RNLength min_distance, RNLength max_distance, RNArray& points) const; 37 | 38 | public: 39 | // Internal search functions 40 | void FindClosest(R2KdtreeNode *node, const R2Box& node_box, const R2Point& position, 41 | RNLength min_distance_squared, RNLength max_distance_squared, 42 | PtrType& closest_point, RNLength& closest_distance_squared) const; 43 | void FindAll(R2KdtreeNode *node, const R2Box& node_box, const R2Point& position, 44 | RNLength min_distance_squared, RNLength max_distance_squared, RNArray& points) const; 45 | 46 | // Internal manipulation functions 47 | void InsertPoints(R2KdtreeNode *node, const R2Box& node_box, PtrType *points, int npoints); 48 | int PartitionPoints(PtrType *points, int npoints, RNDimension dim, int imin, int imax); 49 | 50 | // Internal visualization functions 51 | void Outline(R2KdtreeNode *node, const R2Box& bbox) const; 52 | void Outline(void) const; 53 | 54 | // Internal debugging functions 55 | void PrintDebugInfo(void) const; 56 | int PrintBalance(R2KdtreeNode *node, int depth) const; 57 | 58 | // Internal point extraction function 59 | const R2Point Position(PtrType point) const { 60 | if (position_offset >= 0) return *((R2Point *) ((unsigned char *) point + position_offset)); 61 | else if (position_callback) return (*position_callback)(point, position_callback_data); 62 | else { fprintf(stderr, "Invalid position callback\n"); abort(); return R2null_point; } 63 | } ; 64 | 65 | public: 66 | // Internal data 67 | R2Box bbox; 68 | int position_offset; 69 | R2Point (*position_callback)(PtrType, void *); 70 | void *position_callback_data; 71 | R2KdtreeNode *root; 72 | int nnodes; 73 | }; 74 | 75 | 76 | 77 | // Include templated definitions 78 | 79 | #include "R2Kdtree.cpp" 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Parall.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS parallel utility */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | RNBoolean R2Parallel(const R2Vector& vector1, const R2Vector& vector2) 12 | { 13 | // Return whether two vectors are coincident (or anti-coincident) 14 | if ((RNIsEqual(vector1.X(), vector2.X())) && 15 | (RNIsEqual(vector1.Y(), vector2.Y()))) return TRUE; 16 | if ((RNIsEqual(vector1.X(), -vector2.X())) && 17 | (RNIsEqual(vector1.Y(), -vector2.Y()))) return TRUE; 18 | return FALSE; 19 | } 20 | 21 | 22 | 23 | RNBoolean R2Parallel(const R2Vector& vector, const R2Line& line) 24 | { 25 | // Return whether vector and line are parallel 26 | return R2Parallel(vector, line.Vector()); 27 | } 28 | 29 | 30 | 31 | RNBoolean R2Parallel(const R2Vector& vector, const R2Ray& ray) 32 | { 33 | // Return whether vector and ray are parallel 34 | return R2Parallel(vector, ray.Vector()); 35 | } 36 | 37 | 38 | 39 | RNBoolean R2Parallel(const R2Vector& vector, const R2Span& span) 40 | { 41 | // Return whether vector and span are parallel 42 | return R2Parallel(vector, span.Vector()); 43 | } 44 | 45 | 46 | 47 | RNBoolean R2Parallel(const R2Line& line1, const R2Line& line2) 48 | { 49 | // Return whether line1 and line2 are parallel 50 | return R2Parallel(line1.Vector(), line2.Vector()); 51 | } 52 | 53 | 54 | 55 | RNBoolean R2Parallel(const R2Line& line, const R2Ray& ray) 56 | { 57 | // Return whether line and ray are parallel 58 | return R2Parallel(line.Vector(), ray.Vector()); 59 | } 60 | 61 | 62 | 63 | RNBoolean R2Parallel(const R2Line& line, const R2Span& span) 64 | { 65 | // Return whether line and span are parallel 66 | return R2Parallel(line.Vector(), span.Vector()); 67 | } 68 | 69 | 70 | 71 | RNBoolean R2Parallel(const R2Ray& ray1, const R2Ray& ray2) 72 | { 73 | // Return whether ray1 and ray2 are parallel 74 | return R2Parallel(ray1.Vector(), ray2.Vector()); 75 | } 76 | 77 | 78 | 79 | RNBoolean R2Parallel(const R2Ray& ray, const R2Span& span) 80 | { 81 | // Return whether ray and span are parallel 82 | return R2Parallel(ray.Vector(), span.Vector()); 83 | } 84 | 85 | 86 | 87 | RNBoolean R2Parallel(const R2Span& span1, const R2Span& span2) 88 | { 89 | // Return whether span1 and span2 are parallel 90 | return R2Parallel(span1.Vector(), span2.Vector()); 91 | } 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Parall.h: -------------------------------------------------------------------------------- 1 | /* Include file for GAPS parallel utility */ 2 | 3 | 4 | 5 | /* Function declarations */ 6 | 7 | RNBoolean R2Parallel(const R2Vector& vector1, const R2Vector& vector2); 8 | RNBoolean R2Parallel(const R2Vector& vector, const R2Line& line); 9 | RNBoolean R2Parallel(const R2Vector& vector, const R2Ray& ray); 10 | RNBoolean R2Parallel(const R2Vector& vector, const R2Span& span); 11 | 12 | RNBoolean R2Parallel(const R2Line& line, const R2Vector& vector); 13 | RNBoolean R2Parallel(const R2Line& line1, const R2Line& line2); 14 | RNBoolean R2Parallel(const R2Line& line, const R2Ray& ray); 15 | RNBoolean R2Parallel(const R2Line& line, const R2Span& span); 16 | 17 | RNBoolean R2Parallel(const R2Ray& ray, const R2Vector& vector); 18 | RNBoolean R2Parallel(const R2Ray& ray, const R2Line& line); 19 | RNBoolean R2Parallel(const R2Ray& ray1, const R2Ray& ray2); 20 | RNBoolean R2Parallel(const R2Ray& ray, const R2Span& span); 21 | 22 | RNBoolean R2Parallel(const R2Span& span, const R2Vector& vector); 23 | RNBoolean R2Parallel(const R2Span& span, const R2Line& line); 24 | RNBoolean R2Parallel(const R2Span& span, const R2Ray& ray); 25 | RNBoolean R2Parallel(const R2Span& span1, const R2Span& span2); 26 | 27 | 28 | 29 | /* Inline functions */ 30 | 31 | inline RNBoolean R2Parallel(const R2Line& line, const R2Vector& vector) 32 | { 33 | // Parallel is commutative 34 | return R2Parallel(vector, line); 35 | } 36 | 37 | 38 | 39 | inline RNBoolean R2Parallel(const R2Ray& ray, const R2Vector& vector) 40 | { 41 | // Parallel is commutative 42 | return R2Parallel(vector, ray); 43 | } 44 | 45 | 46 | 47 | inline RNBoolean R2Parallel(const R2Ray& ray, const R2Line& line) 48 | { 49 | // Parallel is commutative 50 | return R2Parallel(line, ray); 51 | } 52 | 53 | 54 | 55 | inline RNBoolean R2Parallel(const R2Span& span, const R2Vector& vector) 56 | { 57 | // Parallel is commutative 58 | return R2Parallel(vector, span); 59 | } 60 | 61 | 62 | 63 | inline RNBoolean R2Parallel(const R2Span& span, const R2Line& line) 64 | { 65 | // Parallel is commutative 66 | return R2Parallel(line, span); 67 | } 68 | 69 | 70 | 71 | inline RNBoolean R2Parallel(const R2Span& span, const R2Ray& ray) 72 | { 73 | // Parallel is commutative 74 | return R2Parallel(ray, span); 75 | } 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Perp.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS perpendicular utility */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | RNBoolean R2Perpendicular(const R2Vector& vector1, const R2Vector& vector2) 12 | { 13 | // Normalized vectors ??? 14 | // Return whether vector1 and vector2 are perpendicular 15 | return RNIsZero(vector1.Dot(vector2)); 16 | } 17 | 18 | 19 | 20 | RNBoolean R2Perpendicular(const R2Vector& vector, const R2Line& line) 21 | { 22 | // Return whether vector and line are perpendicular 23 | return R2Perpendicular(vector, line.Vector()); 24 | } 25 | 26 | 27 | 28 | RNBoolean R2Perpendicular(const R2Vector& vector, const R2Ray& ray) 29 | { 30 | // Return whether vector and ray are perpendicular 31 | return R2Perpendicular(vector, ray.Vector()); 32 | } 33 | 34 | 35 | 36 | RNBoolean R2Perpendicular(const R2Vector& vector, const R2Span& span) 37 | { 38 | // Return whether vector and span are perpendicular 39 | return R2Perpendicular(vector, span.Vector()); 40 | } 41 | 42 | 43 | 44 | RNBoolean R2Perpendicular(const R2Line& line1, const R2Line& line2) 45 | { 46 | // Return whether line1 and line2 are perpendicular 47 | return R2Perpendicular(line1.Vector(), line2.Vector()); 48 | } 49 | 50 | 51 | 52 | RNBoolean R2Perpendicular(const R2Line& line, const R2Ray& ray) 53 | { 54 | // Return whether line and ray are perpendicular 55 | return R2Perpendicular(line.Vector(), ray.Vector()); 56 | } 57 | 58 | 59 | 60 | RNBoolean R2Perpendicular(const R2Line& line, const R2Span& span) 61 | { 62 | // Return whether line and span are perpendicular 63 | return R2Perpendicular(line.Vector(), span.Vector()); 64 | } 65 | 66 | 67 | 68 | RNBoolean R2Perpendicular(const R2Ray& ray1, const R2Ray& ray2) 69 | { 70 | // Return whether ray1 and ray2 are perpendicular 71 | return R2Perpendicular(ray1.Vector(), ray2.Vector()); 72 | } 73 | 74 | 75 | 76 | RNBoolean R2Perpendicular(const R2Ray& ray, const R2Span& span) 77 | { 78 | // Return whether ray and span are perpendicular 79 | return R2Perpendicular(ray.Vector(), span.Vector()); 80 | } 81 | 82 | 83 | 84 | RNBoolean R2Perpendicular(const R2Span& span1, const R2Span& span2) 85 | { 86 | // Return whether span1 and span2 are perpendicular 87 | return R2Perpendicular(span1.Vector(), span2.Vector()); 88 | } 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Perp.h: -------------------------------------------------------------------------------- 1 | /* Include file for GAPS perpendicular utility */ 2 | 3 | 4 | 5 | /* Function declarations */ 6 | 7 | RNBoolean R2Perpendicular(const R2Vector& vector1, const R2Vector& vector2); 8 | RNBoolean R2Perpendicular(const R2Vector& vector, const R2Line& line); 9 | RNBoolean R2Perpendicular(const R2Vector& vector, const R2Ray& ray); 10 | RNBoolean R2Perpendicular(const R2Vector& vector, const R2Span& span); 11 | 12 | RNBoolean R2Perpendicular(const R2Line& line, const R2Vector& vector); 13 | RNBoolean R2Perpendicular(const R2Line& line1, const R2Line& line2); 14 | RNBoolean R2Perpendicular(const R2Line& line, const R2Ray& ray); 15 | RNBoolean R2Perpendicular(const R2Line& line, const R2Span& span); 16 | 17 | RNBoolean R2Perpendicular(const R2Ray& ray, const R2Vector& vector); 18 | RNBoolean R2Perpendicular(const R2Ray& ray, const R2Line& line); 19 | RNBoolean R2Perpendicular(const R2Ray& ray1, const R2Ray& ray2); 20 | RNBoolean R2Perpendicular(const R2Ray& ray, const R2Span& span); 21 | 22 | RNBoolean R2Perpendicular(const R2Span& span, const R2Vector& vector); 23 | RNBoolean R2Perpendicular(const R2Span& span, const R2Line& line); 24 | RNBoolean R2Perpendicular(const R2Span& span, const R2Ray& ray); 25 | RNBoolean R2Perpendicular(const R2Span& span1, const R2Span& span2); 26 | 27 | 28 | 29 | /* Inline functions */ 30 | 31 | inline RNBoolean R2Perpendicular(const R2Line& line, const R2Vector& vector) 32 | { 33 | // Perpendicular is commutative 34 | return R2Perpendicular(vector, line); 35 | } 36 | 37 | 38 | 39 | inline RNBoolean R2Perpendicular(const R2Ray& ray, const R2Vector& vector) 40 | { 41 | // Perpendicular is commutative 42 | return R2Perpendicular(vector, ray); 43 | } 44 | 45 | 46 | 47 | inline RNBoolean R2Perpendicular(const R2Ray& ray, const R2Line& line) 48 | { 49 | // Perpendicular is commutative 50 | return R2Perpendicular(line, ray); 51 | } 52 | 53 | 54 | 55 | inline RNBoolean R2Perpendicular(const R2Span& span, const R2Vector& vector) 56 | { 57 | // Perpendicular is commutative 58 | return R2Perpendicular(vector, span); 59 | } 60 | 61 | 62 | 63 | inline RNBoolean R2Perpendicular(const R2Span& span, const R2Line& line) 64 | { 65 | // Perpendicular is commutative 66 | return R2Perpendicular(line, span); 67 | } 68 | 69 | 70 | 71 | inline RNBoolean R2Perpendicular(const R2Span& span, const R2Ray& ray) 72 | { 73 | // Perpendicular is commutative 74 | return R2Perpendicular(ray, span); 75 | } 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Polyline.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R2 polyline class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R2InitPolyline(); 8 | void R2StopPolyline(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R2Polyline : public R2Curve { 15 | public: 16 | // Constructor functions 17 | R2Polyline(void); 18 | R2Polyline(const R2Polyline& polyline); 19 | R2Polyline(const RNArray& points); 20 | R2Polyline(const R2Point *points, int npoints); 21 | ~R2Polyline(void); 22 | 23 | // Polyline property functions/operators 24 | const int NPoints(void) const; 25 | const R2Point& Point(int k) const; 26 | const RNBoolean IsEmpty(void) const; 27 | const RNBoolean IsFinite(void) const; 28 | const R2Point& operator[](int k) const; 29 | const R2Point ClosestPoint(const R2Point& point) const; 30 | 31 | // Shape property functions/operators 32 | virtual const RNBoolean IsPoint(void) const; 33 | virtual const RNBoolean IsLinear(void) const ; 34 | virtual const RNLength Length(void) const; 35 | virtual const R2Point Centroid(void) const; 36 | virtual const R2Shape& BShape(void) const; 37 | virtual const R2Box BBox(void) const; 38 | virtual const R2Circle BCircle(void) const; 39 | 40 | // Point properties 41 | R2Vector Normal(int k, RNLength radius = 0) const; 42 | R2Line Tangent(int k, RNLength radius = 0) const; 43 | RNAngle InteriorAngle(int k, RNLength radius = 0) const; 44 | RNScalar Curvature(int k, RNLength radius = 0) const; 45 | 46 | // Manipulation functions/operators 47 | virtual void Empty(void); 48 | virtual void Transform(const R2Transformation& transformation); 49 | 50 | // Draw functions/operators 51 | virtual void Draw(const R2DrawFlags draw_flags = R2_DEFAULT_DRAW_FLAGS) const; 52 | virtual void Print(FILE *fp = stdout) const; 53 | 54 | private: 55 | R2Point *points; 56 | int npoints; 57 | R2Box bbox; 58 | }; 59 | 60 | 61 | 62 | /* Inline functions */ 63 | 64 | inline const int R2Polyline:: 65 | NPoints(void) const 66 | { 67 | // Return number of points 68 | return npoints; 69 | } 70 | 71 | 72 | 73 | inline const R2Point& R2Polyline:: 74 | Point(int k) const 75 | { 76 | // Return Kth point 77 | return points[k]; 78 | } 79 | 80 | 81 | 82 | inline const RNBoolean R2Polyline:: 83 | IsEmpty(void) const 84 | { 85 | // Return whether the polyline is null 86 | return (npoints == 0); 87 | } 88 | 89 | 90 | 91 | inline const RNBoolean R2Polyline:: 92 | IsFinite(void) const 93 | { 94 | // Return whether the polyline has finite extent 95 | return bbox.IsFinite(); 96 | } 97 | 98 | 99 | 100 | 101 | inline const R2Point& R2Polyline:: 102 | operator[](int k) const 103 | { 104 | // Return Kth point 105 | return Point(k); 106 | } 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Ray.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the GAPS ray class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | const R2Ray R2null_ray(0.0, 0.0, 0.0, 0.0); 14 | const R2Ray R2posx_ray(0.0, 0.0, 1.0, 0.0); 15 | const R2Ray R2posy_ray(0.0, 0.0, 0.0, 1.0); 16 | const R2Ray R2negx_ray(0.0, 0.0, -1.0, 0.0); 17 | const R2Ray R2negy_ray(0.0, 0.0, 0.0, -1.0); 18 | 19 | 20 | 21 | /* Public functions */ 22 | 23 | int R2InitRay() 24 | { 25 | /* Return success */ 26 | return TRUE; 27 | } 28 | 29 | 30 | 31 | void R2StopRay() 32 | { 33 | } 34 | 35 | 36 | 37 | R2Ray:: 38 | R2Ray(void) 39 | { 40 | } 41 | 42 | 43 | 44 | R2Ray:: 45 | R2Ray(const R2Ray& ray) 46 | : line(ray.line), 47 | start(ray.start) 48 | { 49 | } 50 | 51 | 52 | 53 | R2Ray:: 54 | R2Ray(const R2Point& point, const R2Vector& vector, RNBoolean normalized) 55 | : line(point, vector, normalized), 56 | start(point) 57 | { 58 | } 59 | 60 | 61 | 62 | R2Ray:: 63 | R2Ray(const R2Point& point1, const R2Point& point2) 64 | : line(point1, point2), 65 | start(point1) 66 | { 67 | } 68 | 69 | 70 | 71 | R2Ray:: 72 | R2Ray(RNCoord x1, RNCoord y1, RNCoord x2, RNCoord y2) 73 | : line(x1, y1, x2, y2), 74 | start(x1, y1) 75 | { 76 | } 77 | 78 | 79 | 80 | const R2Point R2Ray:: 81 | Point(RNScalar t) const 82 | { 83 | // Return point along span 84 | return (Start() + Vector() * t); 85 | } 86 | 87 | 88 | 89 | const RNScalar R2Ray:: 90 | T(const R2Point& point) const 91 | { 92 | // Return parametric value of closest point on ray 93 | RNScalar denom = Vector().Dot(Vector()); 94 | if (RNIsZero(denom)) return 0.0; 95 | R2Vector topoint = point - Start(); 96 | return (Vector().Dot(topoint) / denom); 97 | } 98 | 99 | 100 | 101 | void R2Ray:: 102 | Mirror (const R2Line& mirror) 103 | { 104 | // Mirror ray across line 105 | line.Mirror(mirror); 106 | start.Mirror(mirror); 107 | } 108 | 109 | 110 | 111 | void R2Ray:: 112 | Project (const R2Line& target) 113 | { 114 | // Project ray onto target line 115 | line.Project(target); 116 | start.Project(target); 117 | } 118 | 119 | 120 | 121 | void R2Ray:: 122 | Transform (const R2Transformation& transformation) 123 | { 124 | // Transform line and point 125 | line.Transform(transformation); 126 | start.Transform(transformation); 127 | } 128 | 129 | 130 | 131 | void R2Ray:: 132 | InverseTransform (const R2Transformation& transformation) 133 | { 134 | // Transform line and point 135 | line.InverseTransform(transformation); 136 | start.InverseTransform(transformation); 137 | } 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Relate.h: -------------------------------------------------------------------------------- 1 | /* Include file for R2 miscelleaneous relationship utility */ 2 | 3 | 4 | 5 | /* Miscellaneous relationship function declarations */ 6 | 7 | RNAngle R2InteriorAngle(const R2Vector& vector1, const R2Vector& vector2); 8 | RNAngle R2InteriorAngle(const R2Vector& vector, const R2Line& line); 9 | RNAngle R2InteriorAngle(const R2Vector& vector, const R2Ray& ray); 10 | RNAngle R2InteriorAngle(const R2Vector& vector, const R2Span& span); 11 | 12 | RNArea R2IntersectionArea(const R2Box& box1, const R2Box& box2); 13 | RNArea R2IntersectionArea(const R2Circle& circle1, const R2Circle& circle2); 14 | 15 | RNBoolean R2Abuts(const R2Box& box1, const R2Box& box2); 16 | 17 | int R2Splits(const R2Line& line, const R2Span& span); 18 | int R2Splits(const R2Line& line, const R2Span& span, R2Span *below_result, R2Span *above_result = NULL); 19 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Shape.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R2 shape class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | /* Public draw flags */ 12 | 13 | const R2DrawFlags R2_EDGES_DRAW_FLAG (0x001); 14 | const R2DrawFlags R2_SURFACES_DRAW_FLAG (0x002); 15 | const R2DrawFlags R2_NULL_DRAW_FLAGS (0x000); 16 | const R2DrawFlags R2_EVERYTHING_DRAW_FLAGS (0xFFF); 17 | const R2DrawFlags R2_DEFAULT_DRAW_FLAGS (R2_EVERYTHING_DRAW_FLAGS); 18 | 19 | 20 | 21 | /* Public functions */ 22 | 23 | int 24 | R2InitShape() 25 | { 26 | /* Return success */ 27 | return TRUE; 28 | } 29 | 30 | 31 | 32 | void 33 | R2StopShape() 34 | { 35 | } 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Shape.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R2 shape class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R2InitShape(); 8 | void R2StopShape(); 9 | 10 | 11 | 12 | /* Draw flags definition */ 13 | 14 | typedef RNFlags R2DrawFlags; 15 | extern const R2DrawFlags R2_EDGES_DRAW_FLAG; 16 | extern const R2DrawFlags R2_SURFACES_DRAW_FLAG; 17 | extern const R2DrawFlags R2_NULL_DRAW_FLAGS; 18 | extern const R2DrawFlags R2_EVERYTHING_DRAW_FLAGS; 19 | extern const R2DrawFlags R2_DEFAULT_DRAW_FLAGS; 20 | 21 | 22 | 23 | /* Class definition */ 24 | 25 | class R2Shape /* : public R2Base */ { 26 | public: 27 | // Constructors/destructors 28 | virtual ~R2Shape(void) {}; 29 | 30 | // Draw functions/operators 31 | virtual void Draw(const R2DrawFlags draw_flags = R2_DEFAULT_DRAW_FLAGS) const = 0; 32 | void Outline(void) const { Draw(R2_EDGES_DRAW_FLAG); }; 33 | }; 34 | 35 | 36 | 37 | /* Shape type enumeration ??? */ 38 | 39 | enum { 40 | R2_POINT_CLASS_ID = 1, 41 | R2_LINE_CLASS_ID = 2, 42 | R2_RAY_CLASS_ID = 3, 43 | R2_SPAN_CLASS_ID = 4, 44 | R2_POLYGON_CLASS_ID = 6 45 | }; 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Shapes.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS shapes module */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes.h" 8 | 9 | 10 | 11 | /* Private variables */ 12 | 13 | static int R2shapes_active_count = 0; 14 | 15 | 16 | 17 | int R2InitShapes(void) 18 | { 19 | // Check whether are already initialized 20 | if ((R2shapes_active_count++) > 0) return TRUE; 21 | 22 | // Initialize dependencies 23 | if (!RNInitBasics()) return FALSE; 24 | 25 | // Initialize submodules 26 | if (!R2InitCircle()) return FALSE; 27 | 28 | // return OK status 29 | return TRUE; 30 | } 31 | 32 | 33 | 34 | void R2StopShapes(void) 35 | { 36 | // Check whether have been initialized 37 | if ((--R2shapes_active_count) > 0) return; 38 | 39 | // Stop submodules 40 | R2StopCircle(); 41 | 42 | // Stop dependencies 43 | RNStopBasics(); 44 | } 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Shapes.h: -------------------------------------------------------------------------------- 1 | /* Include file for R2 shapes module */ 2 | 3 | #ifndef __R2__SHAPES__H__ 4 | #define __R2__SHAPES__H__ 5 | 6 | 7 | 8 | /* Dependency include files */ 9 | 10 | #include "RNBasics/RNBasics.h" 11 | 12 | 13 | 14 | /* Class declarations */ 15 | 16 | class R2Vector; 17 | class R2Point; 18 | class R2Line; 19 | class R2Ray; 20 | class R2Span; 21 | class R2Halfspace; 22 | class R3Matrix; 23 | class R2Diad; 24 | class R2CoordSystem; 25 | class R2Transformation; 26 | class R2Affine; 27 | class R2Arc; 28 | class R2Polyline; 29 | class R2Box; 30 | class R2Circle; 31 | class R2Polygon; 32 | class R2Grid; 33 | 34 | 35 | 36 | /* Image include files */ 37 | 38 | #include "R2Shapes/R2Image.h" 39 | 40 | 41 | 42 | /* Primitive shape include files */ 43 | 44 | #include "R2Shapes/R2Vector.h" 45 | #include "R2Shapes/R2Point.h" 46 | #include "R2Shapes/R2Line.h" 47 | #include "R2Shapes/R2Ray.h" 48 | #include "R2Shapes/R2Span.h" 49 | #include "R2Shapes/R2Halfspace.h" 50 | 51 | 52 | 53 | /* Transformation include files */ 54 | 55 | #include "R2Shapes/R3Matrix.h" 56 | #include "R2Shapes/R2Diad.h" 57 | #include "R2Shapes/R2Crdsys.h" 58 | #include "R2Shapes/R2Xform.h" 59 | #include "R2Shapes/R2Affine.h" 60 | 61 | 62 | 63 | /* Abstract shape include file */ 64 | 65 | #include "R2Shapes/R2Shape.h" 66 | 67 | 68 | 69 | /* Solid shapes include files */ 70 | 71 | #include "R2Shapes/R2Solid.h" 72 | #include "R2Shapes/R2Box.h" 73 | #include "R2Shapes/R2Circle.h" 74 | #include "R2Shapes/R2Polygon.h" 75 | 76 | 77 | 78 | /* Curve shapes include files */ 79 | 80 | #include "R2Shapes/R2Curve.h" 81 | #include "R2Shapes/R2Arc.h" 82 | #include "R2Shapes/R2Polyline.h" 83 | 84 | 85 | 86 | /* Solid shapes include files */ 87 | 88 | #include "R2Shapes/R2Grid.h" 89 | 90 | 91 | 92 | /* Shape relationship include files */ 93 | 94 | #include "R2Shapes/R2Perp.h" 95 | #include "R2Shapes/R2Parall.h" 96 | #include "R2Shapes/R2Dist.h" 97 | #include "R2Shapes/R2Cont.h" 98 | #include "R2Shapes/R2Isect.h" 99 | #include "R2Shapes/R2Relate.h" 100 | #include "R2Shapes/R2Align.h" 101 | 102 | 103 | 104 | /* Closest point search include files */ 105 | 106 | #include "R2Shapes/R2Kdtree.h" 107 | 108 | 109 | 110 | /* Shape utility include files */ 111 | 112 | #include "R2Shapes/R2Draw.h" 113 | #include "R2Shapes/R2Io.h" 114 | 115 | 116 | 117 | /* Initialization functions */ 118 | 119 | int R2InitShapes(void); 120 | void R2StopShapes(void); 121 | 122 | 123 | 124 | #endif 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Solid.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R2 solid class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | /* Public functions */ 12 | 13 | int 14 | R2InitSolid() 15 | { 16 | /* Return success */ 17 | return TRUE; 18 | } 19 | 20 | 21 | 22 | void 23 | R2StopSolid() 24 | { 25 | } 26 | 27 | 28 | 29 | R2Solid:: 30 | R2Solid(void) 31 | { 32 | } 33 | 34 | 35 | 36 | R2Solid:: 37 | ~R2Solid(void) 38 | { 39 | } 40 | 41 | 42 | 43 | const RNBoolean R2Solid:: 44 | IsSolid(void) const 45 | { 46 | // All solid shapes are solids 47 | return TRUE; 48 | } 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Solid.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R2 solid class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R2InitSolid(); 8 | void R2StopSolid(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R2Solid : public R2Shape { 15 | public: 16 | // Constructors/destructors ??? 17 | R2Solid(void); 18 | ~R2Solid(void); 19 | 20 | // Shape property functions/operators 21 | const RNBoolean IsSolid(void) const; 22 | }; 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Xform.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R2 transformation class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R2Shapes/R2Shapes.h" 8 | 9 | 10 | 11 | /* Public functions */ 12 | 13 | int 14 | R2InitTransformation() 15 | { 16 | /* Return success */ 17 | return TRUE; 18 | } 19 | 20 | 21 | 22 | void 23 | R2StopTransformation() 24 | { 25 | } 26 | 27 | 28 | 29 | R2Transformation:: 30 | ~R2Transformation(void) 31 | { 32 | } 33 | 34 | 35 | 36 | const RNBoolean R2Transformation:: 37 | IsMirrored(void) const 38 | { 39 | // Return whether transformation is mirrored (default is FALSE) 40 | return FALSE; 41 | } 42 | 43 | 44 | 45 | const RNBoolean R2Transformation:: 46 | IsLinear(void) const 47 | { 48 | // Return whether transformation is linear (default is FALSE) 49 | return FALSE; 50 | } 51 | 52 | 53 | 54 | const RNBoolean R2Transformation:: 55 | IsAffine(void) const 56 | { 57 | // Return whether transformation is affine (default is FALSE) 58 | return FALSE; 59 | } 60 | 61 | 62 | 63 | const RNBoolean R2Transformation:: 64 | IsIsotropic(void) const 65 | { 66 | // Return whether transformation is isotropic (default is FALSE) 67 | return FALSE; 68 | } 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /gaps/pkgs/R2Shapes/R2Xform.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R2 transformation class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R2InitTransformation(); 8 | void R2StopTransformation(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R2Transformation /* : public R2Base */ { 15 | public: 16 | // Destructor function 17 | virtual ~R2Transformation(void); 18 | 19 | // Property functions/operators 20 | virtual const RNBoolean IsMirrored(void) const; 21 | virtual const RNBoolean IsLinear(void) const; 22 | virtual const RNBoolean IsAffine(void) const; 23 | virtual const RNBoolean IsIsotropic(void) const; 24 | 25 | // Application functions/operators 26 | virtual void Apply(R2Vector& vector) const = 0; 27 | virtual void Apply(R2Point& point) const = 0; 28 | virtual void Apply(R2Transformation& transformation) const = 0; 29 | virtual void Apply(R2Affine& affine) const = 0; 30 | virtual void ApplyInverse(R2Vector& vector) const = 0; 31 | virtual void ApplyInverse(R2Point& point) const = 0; 32 | virtual void ApplyInverse(R2Transformation& transformation) const = 0; 33 | virtual void ApplyInverse(R2Affine& affine) const = 0; 34 | 35 | // Manipulation functions/operators 36 | virtual void Reset(const R2Transformation& transformation) = 0; 37 | virtual void Transform(const R2Transformation& transformation) = 0; 38 | virtual void InverseTransform(const R2Transformation& transformation) = 0; 39 | 40 | // Draw functions/operators 41 | virtual void Load(void) const = 0; 42 | virtual void Draw(void) const = 0; 43 | virtual void Push(void) const = 0; 44 | virtual void Pop(void) const = 0; 45 | }; 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Package name 3 | # 4 | 5 | NAME=R3Graphics 6 | 7 | 8 | 9 | # 10 | # List of source files 11 | # 12 | 13 | CCSRCS=$(NAME).cpp \ 14 | R3Scene.cpp R3SceneNode.cpp R3SceneElement.cpp R3SceneReference.cpp \ 15 | R3Viewer.cpp R3Frustum.cpp R3Camera.cpp R2Viewport.cpp \ 16 | R3AreaLight.cpp R3SpotLight.cpp R3PointLight.cpp R3DirectionalLight.cpp R3Light.cpp \ 17 | R3Material.cpp R3Brdf.cpp R2Texture.cpp \ 18 | json.cpp 19 | 20 | 21 | 22 | # 23 | # Dependencies 24 | # 25 | 26 | PKG_DEPENDENCIES = R3Shapes R2Shapes RNBasics 27 | 28 | 29 | 30 | # 31 | # PKG makefile 32 | # 33 | 34 | include ../../makefiles/Makefile.pkgs 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R2Viewport.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the viewport class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Graphics.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | R2Viewport R2default_viewport(0, 0, 128, 128); 14 | 15 | 16 | 17 | int R3InitViewport() 18 | { 19 | /* Return OK status */ 20 | return TRUE; 21 | } 22 | 23 | 24 | 25 | void R3StopViewport() 26 | { 27 | } 28 | 29 | 30 | 31 | R2Viewport:: 32 | R2Viewport(void) 33 | { 34 | } 35 | 36 | 37 | 38 | R2Viewport:: 39 | R2Viewport (int xmin, int ymin, int width, int height) 40 | : xmin(xmin), 41 | ymin(ymin), 42 | width(width), 43 | height(height) 44 | { 45 | } 46 | 47 | 48 | 49 | void R2Viewport:: 50 | Move(int xmin, int ymin) 51 | { 52 | // Set viewport variables 53 | this->xmin = xmin; 54 | this->ymin = ymin; 55 | } 56 | 57 | 58 | 59 | void R2Viewport:: 60 | Resize(int width, int height) 61 | { 62 | // Set viewport variables 63 | this->width = width; 64 | this->height = height; 65 | } 66 | 67 | 68 | 69 | void R2Viewport:: 70 | Resize(int xmin, int ymin, int width, int height) 71 | { 72 | // Set viewport variables 73 | this->xmin = xmin; 74 | this->ymin = ymin; 75 | this->width = width; 76 | this->height = height; 77 | } 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R3DirectionalLight.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 light class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitDirectionalLight(); 8 | void R3StopDirectionalLight(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3DirectionalLight : public R3Light { 15 | public: 16 | // Constructor functions 17 | R3DirectionalLight(void); 18 | R3DirectionalLight(const R3DirectionalLight& light); 19 | R3DirectionalLight(const R3Vector& direction, const RNRgb& color, 20 | RNScalar intensity = 1.0, RNBoolean active = TRUE); 21 | 22 | // Property functions/operators 23 | const R3Vector& Direction(void) const; 24 | 25 | // Manipulation functions/operations 26 | virtual void SetDirection(const R3Vector& direction); 27 | virtual void Transform(const R3Transformation& transformation); 28 | 29 | // Geometry evaluation functions 30 | virtual RNScalar IntensityAtPoint(const R3Point& point) const; 31 | virtual R3Vector DirectionFromPoint(const R3Point& point) const; 32 | virtual RNScalar RadiusOfInfluence(RNScalar intensity) const; 33 | virtual R3Sphere SphereOfInfluence(RNScalar intensity) const; 34 | 35 | // Reflection evaluation functions 36 | virtual RNRgb Reflection(const R3Brdf& brdf, const R3Point& eye, 37 | const R3Point& point, const R3Vector& normal) const; 38 | virtual RNRgb DiffuseReflection(const R3Brdf& brdf, 39 | const R3Point& point, const R3Vector& normal) const; 40 | virtual RNRgb SpecularReflection(const R3Brdf& brdf, const R3Point& eye, 41 | const R3Point& point, const R3Vector& normal) const; 42 | 43 | // Draw functions/operations 44 | virtual void Draw(int i) const; 45 | 46 | // Class type definitions 47 | RN_CLASS_TYPE_DECLARATIONS(R3DirectionalLight); 48 | 49 | private: 50 | R3Vector direction; 51 | }; 52 | 53 | 54 | 55 | /* Public variables */ 56 | 57 | extern R3DirectionalLight R3null_directional_light; 58 | extern R3DirectionalLight R3default_directional_light; 59 | 60 | 61 | 62 | /* Inline functions */ 63 | 64 | inline const R3Vector& R3DirectionalLight:: 65 | Direction(void) const 66 | { 67 | // Return direction 68 | return direction; 69 | } 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R3Frustum.h: -------------------------------------------------------------------------------- 1 | // Include file for R3 view frustum class 2 | 3 | 4 | 5 | //////////////////////////////////////////////////////////////////////// 6 | // Class definition 7 | //////////////////////////////////////////////////////////////////////// 8 | 9 | struct R3Frustum { 10 | public: 11 | // Constructor 12 | R3Frustum(void); 13 | R3Frustum(const R3Camera& camera); 14 | R3Frustum(const R3Point& viewpoint, const R3Vector& towards, 15 | const R3Vector& up, RNAngle xfov, RNAngle yfov, 16 | RNLength neardist, RNLength fardist); 17 | 18 | // Property functions 19 | const R3Camera& Camera(void) const; 20 | const R3Halfspace& Halfspace(int dir, int dim) const; 21 | 22 | // Manipulation functions 23 | void SetCamera(const R3Camera& camera); 24 | 25 | // Intersection/containment functions 26 | RNBoolean Intersects(const R3Point& point) const; 27 | RNBoolean Intersects(const R3Span& span) const; 28 | RNBoolean Intersects(const R3Box& box) const; 29 | RNBoolean Contains(const R3Point& point) const; 30 | RNBoolean Contains(const R3Span& span) const; 31 | RNBoolean Contains(const R3Box& box) const; 32 | 33 | // Draw function 34 | void Draw(void) const; 35 | 36 | public: 37 | R3Camera camera; 38 | R3Halfspace halfspaces[2][3]; 39 | }; 40 | 41 | 42 | 43 | // Inline functions 44 | 45 | inline const R3Camera& R3Frustum:: 46 | Camera(void) const 47 | { 48 | // Return camera 49 | return camera; 50 | } 51 | 52 | 53 | 54 | inline const R3Halfspace& R3Frustum:: 55 | Halfspace(int dir, int dim) const 56 | { 57 | // Return halfspace 58 | return halfspaces[dir][dim]; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R3Graphics.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS graphics module */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Graphics.h" 8 | 9 | 10 | 11 | /* Private variables */ 12 | 13 | static int R3graphics_active_count = 0; 14 | 15 | 16 | 17 | int R3InitGraphics(void) 18 | { 19 | // Check whether are already initialized 20 | if ((R3graphics_active_count++) > 0) return TRUE; 21 | 22 | // Initialize dependencies 23 | if (!R3InitShapes()) return FALSE; 24 | 25 | // Initialize submodules 26 | if (!R3InitMaterial()) return FALSE; 27 | 28 | // return OK status 29 | return TRUE; 30 | } 31 | 32 | 33 | 34 | void R3StopGraphics(void) 35 | { 36 | // Check whether have been initialized 37 | if ((--R3graphics_active_count) > 0) return; 38 | 39 | // Stop submodules 40 | R3StopMaterial(); 41 | 42 | // Stop dependencies 43 | R3StopShapes(); 44 | } 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R3Graphics.h: -------------------------------------------------------------------------------- 1 | /* Include file for R3 graphics module */ 2 | 3 | #ifndef __R3__GRAPHICS__H__ 4 | #define __R3__GRAPHICS__H__ 5 | 6 | 7 | 8 | /* Class declarations */ 9 | 10 | class R3Scene; 11 | class R3SceneNode; 12 | class R3SceneElement; 13 | 14 | 15 | 16 | /* Dependency include files */ 17 | 18 | #include "R3Shapes/R3Shapes.h" 19 | 20 | 21 | 22 | /* Material include files */ 23 | 24 | #include "R3Graphics/R3Brdf.h" 25 | #include "R3Graphics/R2Texture.h" 26 | #include "R3Graphics/R3Material.h" 27 | 28 | 29 | 30 | /* Light include files */ 31 | 32 | #include "R3Graphics/R3Light.h" 33 | #include "R3Graphics/R3DirectionalLight.h" 34 | #include "R3Graphics/R3PointLight.h" 35 | #include "R3Graphics/R3SpotLight.h" 36 | #include "R3Graphics/R3AreaLight.h" 37 | 38 | 39 | 40 | /* Viewing include files */ 41 | 42 | #include "R3Graphics/R2Viewport.h" 43 | #include "R3Graphics/R3Camera.h" 44 | #include "R3Graphics/R3Frustum.h" 45 | #include "R3Graphics/R3Viewer.h" 46 | 47 | 48 | 49 | /* Scene include files */ 50 | 51 | #include "R3Graphics/R3SceneReference.h" 52 | #include "R3Graphics/R3SceneElement.h" 53 | #include "R3Graphics/R3SceneNode.h" 54 | #include "R3Graphics/R3Scene.h" 55 | 56 | 57 | 58 | /* Initialization functions */ 59 | 60 | int R3InitGraphics(void); 61 | void R3StopGraphics(void); 62 | 63 | 64 | 65 | #endif 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R3PointLight.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 point light class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitPointLight(); 8 | void R3StopPointLight(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3PointLight : public R3Light { 15 | public: 16 | // Constructor functions 17 | R3PointLight(void); 18 | R3PointLight(const R3PointLight& light); 19 | R3PointLight(const R3Point& position, const RNRgb& color, 20 | RNScalar intensity = 1.0, RNBoolean active = TRUE, 21 | RNScalar ca = 0, RNScalar la = 0, RNScalar qa = 1); 22 | 23 | // Property functions/operators 24 | const R3Point& Position(void) const; 25 | const RNScalar ConstantAttenuation(void) const; 26 | const RNScalar LinearAttenuation(void) const; 27 | const RNScalar QuadraticAttenuation(void) const; 28 | 29 | // Manipulation functions/operations 30 | virtual void SetPosition(const R3Point& position); 31 | virtual void SetConstantAttenuation(RNScalar ca); 32 | virtual void SetLinearAttenuation(RNScalar la); 33 | virtual void SetQuadraticAttenuation(RNScalar qa); 34 | virtual void Transform(const R3Transformation& transformation); 35 | 36 | // Geometry evaluation functions 37 | virtual RNScalar IntensityAtPoint(const R3Point& point) const; 38 | virtual R3Vector DirectionFromPoint(const R3Point& point) const; 39 | virtual RNScalar RadiusOfInfluence(RNScalar intensity) const; 40 | virtual R3Sphere SphereOfInfluence(RNScalar intensity) const; 41 | 42 | // Reflection evaluation functions 43 | virtual RNRgb Reflection(const R3Brdf& brdf, const R3Point& eye, 44 | const R3Point& point, const R3Vector& normal) const; 45 | virtual RNRgb DiffuseReflection(const R3Brdf& brdf, 46 | const R3Point& point, const R3Vector& normal) const; 47 | virtual RNRgb SpecularReflection(const R3Brdf& brdf, const R3Point& eye, 48 | const R3Point& point, const R3Vector& normal) const; 49 | 50 | // Draw functions/operations 51 | virtual void Draw(int i) const; 52 | 53 | // Class type definitions 54 | RN_CLASS_TYPE_DECLARATIONS(R3PointLight); 55 | 56 | private: 57 | R3Point position; 58 | RNScalar constant_attenuation; 59 | RNScalar linear_attenuation; 60 | RNScalar quadratic_attenuation; 61 | }; 62 | 63 | 64 | 65 | /* Public variables */ 66 | 67 | extern R3PointLight R3null_point_light; 68 | 69 | 70 | 71 | /* Inline functions */ 72 | 73 | inline const R3Point& R3PointLight:: 74 | Position(void) const 75 | { 76 | // Return position 77 | return position; 78 | } 79 | 80 | 81 | 82 | inline const RNScalar R3PointLight:: 83 | ConstantAttenuation(void) const 84 | { 85 | // Return constant coefficient of attenuation 86 | return constant_attenuation; 87 | } 88 | 89 | 90 | 91 | inline const RNScalar R3PointLight:: 92 | LinearAttenuation(void) const 93 | { 94 | // Return linear coefficient of attenuation 95 | return linear_attenuation; 96 | } 97 | 98 | 99 | 100 | inline const RNScalar R3PointLight:: 101 | QuadraticAttenuation(void) const 102 | { 103 | // Return quadratic coefficient of attenuation 104 | return quadratic_attenuation; 105 | } 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R3SceneElement.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 scene element class */ 2 | 3 | 4 | 5 | /* Class definitions */ 6 | 7 | class R3SceneElement { 8 | public: 9 | // Constructor functions 10 | R3SceneElement(R3Material *material = NULL); 11 | R3SceneElement(const R3SceneElement& element); 12 | ~R3SceneElement(void); 13 | 14 | // Property functions 15 | const R3Box& BBox(void) const; 16 | const R3Point Centroid(void) const; 17 | const RNInterval NFacets(void) const; 18 | const RNLength Length(void) const; 19 | const RNArea Area(void) const; 20 | const RNVolume Volume(void) const; 21 | 22 | // Access functions 23 | R3Material *Material(void) const; 24 | int NShapes(void) const; 25 | R3Shape *Shape(int k) const; 26 | R3SceneNode *Node(void) const; 27 | 28 | // Manipulation function 29 | void SetMaterial(R3Material *material); 30 | void InsertShape(R3Shape *shape); 31 | void RemoveShape(R3Shape *shape); 32 | void Transform(const R3Transformation& transformation); 33 | 34 | // Query functions 35 | RNLength Distance(const R3Point& point) const; 36 | RNBoolean FindClosest(const R3Point& point, R3Shape **hit_shape = NULL, 37 | R3Point *hit_point = NULL, R3Vector *hit_normal = NULL, RNLength *hit_d = NULL, 38 | RNLength min_distance = 0, RNLength max_distance = RN_INFINITY) const; 39 | RNBoolean Intersects(const R3Ray& ray, R3Shape **hit_shape = NULL, 40 | R3Point *hit_point = NULL, R3Vector *hit_normal = NULL, RNScalar *hit_t = NULL, 41 | RNScalar min_t = 0.0, RNScalar max_t = RN_INFINITY) const; 42 | 43 | // Draw functions 44 | void Draw(const R3DrawFlags draw_flags = R3_DEFAULT_DRAW_FLAGS, 45 | const RNArray *materials = NULL) const; 46 | 47 | public: 48 | // Internal update functions 49 | void InvalidateBBox(void); 50 | void UpdateBBox(void); 51 | 52 | private: 53 | friend class R3SceneNode; 54 | R3SceneNode *node; 55 | R3Material *material; 56 | RNArray shapes; 57 | unsigned int opengl_id; 58 | R3Box bbox; 59 | }; 60 | 61 | 62 | 63 | /* Inline functions */ 64 | 65 | inline R3Material *R3SceneElement:: 66 | Material(void) const 67 | { 68 | // Return material 69 | return material; 70 | } 71 | 72 | 73 | 74 | inline int R3SceneElement:: 75 | NShapes(void) const 76 | { 77 | // Return number of shapes 78 | return shapes.NEntries(); 79 | } 80 | 81 | 82 | 83 | inline R3Shape *R3SceneElement:: 84 | Shape(int k) const 85 | { 86 | // Return shape 87 | return shapes[k]; 88 | } 89 | 90 | 91 | 92 | inline const R3Box& R3SceneElement:: 93 | BBox(void) const 94 | { 95 | // Return bounding box 96 | if (bbox[0][0] == FLT_MAX) 97 | ((R3SceneElement *) this)->UpdateBBox(); 98 | return bbox; 99 | } 100 | 101 | 102 | 103 | inline R3SceneNode *R3SceneElement:: 104 | Node(void) const 105 | { 106 | // Return node 107 | return node; 108 | } 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R3SceneReference.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R3 scene reference class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Graphics.h" 8 | 9 | 10 | 11 | /* Member functions */ 12 | 13 | R3SceneReference:: 14 | R3SceneReference(R3Scene *referenced_scene) 15 | : referenced_scene(referenced_scene), 16 | materials(), 17 | info(), 18 | name(NULL), 19 | data(NULL) 20 | { 21 | } 22 | 23 | 24 | 25 | R3SceneReference:: 26 | R3SceneReference(R3Scene *referenced_scene, const RNArray& materials) 27 | : referenced_scene(referenced_scene), 28 | materials(), 29 | info(), 30 | name(NULL), 31 | data(NULL) 32 | { 33 | // Copy pointers to materials 34 | this->materials = materials; 35 | } 36 | 37 | 38 | 39 | R3SceneReference:: 40 | ~R3SceneReference(void) 41 | { 42 | // Delete name 43 | if (name) free(name); 44 | } 45 | 46 | 47 | 48 | const R3Box& R3SceneReference:: 49 | BBox(void) const 50 | { 51 | // Return bounding box 52 | if (!referenced_scene) return R3null_box; 53 | return referenced_scene->BBox(); 54 | } 55 | 56 | 57 | 58 | const R3Point R3SceneReference:: 59 | Centroid(void) const 60 | { 61 | // Return centroid 62 | if (!referenced_scene) return R3zero_point; 63 | return referenced_scene->Centroid(); 64 | } 65 | 66 | 67 | 68 | const RNInterval R3SceneReference:: 69 | NFacets(void) const 70 | { 71 | // Return nfacets 72 | if (!referenced_scene) return RNzero_interval; 73 | return referenced_scene->NFacets(); 74 | } 75 | 76 | 77 | 78 | const RNLength R3SceneReference:: 79 | Length(void) const 80 | { 81 | // Return length 82 | if (!referenced_scene) return 0; 83 | return referenced_scene->Length(); 84 | } 85 | 86 | 87 | 88 | const RNArea R3SceneReference:: 89 | Area(void) const 90 | { 91 | // Return area 92 | if (!referenced_scene) return 0; 93 | return referenced_scene->Area(); 94 | } 95 | 96 | 97 | 98 | const RNVolume R3SceneReference:: 99 | Volume(void) const 100 | { 101 | // Return volume 102 | if (!referenced_scene) return 0; 103 | return referenced_scene->Volume(); 104 | } 105 | 106 | 107 | 108 | const R3Point R3SceneReference:: 109 | ClosestPoint(const R3Point& point) const 110 | { 111 | // Return closest point 112 | if (!referenced_scene) return R3zero_point; 113 | return referenced_scene->ClosestPoint(point); 114 | } 115 | 116 | 117 | 118 | void R3SceneReference:: 119 | InsertInfo(const char *key, const char *value) 120 | { 121 | // Insert key-value pair 122 | info.Insert(key, value); 123 | } 124 | 125 | 126 | 127 | void R3SceneReference:: 128 | ReplaceInfo(const char *key, const char *value) 129 | { 130 | // Replace key-value pair 131 | info.Replace(key, value); 132 | } 133 | 134 | 135 | 136 | void R3SceneReference:: 137 | RemoveInfo(const char *key) 138 | { 139 | // Insert key-value pair 140 | info.Remove(key); 141 | } 142 | 143 | 144 | 145 | void R3SceneReference:: 146 | Draw(const R3DrawFlags draw_flags, const RNArray *mats) const 147 | { 148 | // Check scene 149 | if (!referenced_scene) return; 150 | 151 | // Draw scene with materials 152 | referenced_scene->Root()->Draw(draw_flags, &materials); 153 | } 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Graphics/R3SpotLight.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 light class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitSpotLight(); 8 | void R3StopSpotLight(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3SpotLight : public R3PointLight { 15 | public: 16 | // Constructor functions 17 | R3SpotLight(void); 18 | R3SpotLight(const R3SpotLight& light); 19 | R3SpotLight(const R3Point& position, const R3Vector& direction, 20 | const RNRgb& color, RNScalar dropoffrate = 0.0, RNAngle cutoffangle = 0.785398, 21 | RNScalar intensity = 1.0, RNBoolean active = TRUE, 22 | RNScalar ca = 0, RNScalar la = 0, RNScalar qa = 1); 23 | 24 | // Property functions/operators 25 | const R3Vector& Direction(void) const; 26 | const RNScalar DropOffRate(void) const; 27 | const RNAngle CutOffAngle(void) const; 28 | 29 | // Manipulation functions/operations 30 | virtual void SetDirection(const R3Vector& direction); 31 | virtual void SetDropOffRate(RNScalar dropoffrate); 32 | virtual void SetCutOffAngle(RNAngle cutoffangle); 33 | virtual void Transform(const R3Transformation& transformation); 34 | 35 | // Evaluation functions 36 | virtual RNScalar IntensityAtPoint(const R3Point& point) const; 37 | 38 | // Draw functions/operations 39 | virtual void Draw(int i) const; 40 | 41 | // Class type definitions 42 | RN_CLASS_TYPE_DECLARATIONS(R3SpotLight); 43 | 44 | private: 45 | R3Vector direction; 46 | RNScalar dropoffrate; 47 | RNAngle cutoffangle; 48 | }; 49 | 50 | 51 | 52 | /* Public variables */ 53 | 54 | extern R3SpotLight R3null_spot_light; 55 | 56 | 57 | 58 | /* Inline functions */ 59 | 60 | inline const R3Vector& R3SpotLight:: 61 | Direction(void) const 62 | { 63 | // Return direction 64 | return direction; 65 | } 66 | 67 | 68 | 69 | inline const RNScalar R3SpotLight:: 70 | DropOffRate(void) const 71 | { 72 | // Return drop off rate 73 | return dropoffrate; 74 | } 75 | 76 | 77 | 78 | inline const RNAngle R3SpotLight:: 79 | CutOffAngle(void) const 80 | { 81 | // Return cut off angle 82 | return cutoffangle; 83 | } 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Package name 3 | # 4 | 5 | NAME=R3Shapes 6 | 7 | 8 | 9 | # 10 | # List of source files 11 | # 12 | 13 | CCSRCS=$(NAME).cpp \ 14 | R3Draw.cpp \ 15 | R3MeshSearchTree.cpp R3MeshPropertySet.cpp R3MeshProperty.cpp \ 16 | R3Isect.cpp R3Cont.cpp R3Dist.cpp R3Parall.cpp R3Perp.cpp R3Relate.cpp R3Align.cpp R3Kdtree.cpp \ 17 | R3CatmullRomSpline.cpp R3Polyline.cpp R3Curve.cpp \ 18 | R3Mesh.cpp R3Rectangle.cpp R3Ellipse.cpp R3Circle.cpp R3TriangleArray.cpp R3Triangle.cpp R3Surface.cpp \ 19 | R3Ellipsoid.cpp R3Sphere.cpp R3Cone.cpp R3Cylinder.cpp R3OrientedBox.cpp R3Box.cpp R3Solid.cpp \ 20 | R3Shape.cpp \ 21 | R3Affine.cpp R3Xform.cpp R3Crdsys.cpp R3Triad.cpp R3Quaternion.cpp R4Matrix.cpp \ 22 | R3PlanarGrid.cpp R3Grid.cpp \ 23 | R3Halfspace.cpp R3Plane.cpp R3Span.cpp R3Ray.cpp R3Line.cpp R3Point.cpp R3Vector.cpp \ 24 | R3Base.cpp \ 25 | ply.cpp 26 | 27 | 28 | # 29 | # Dependencies 30 | # 31 | 32 | PKG_DEPENDENCIES = R2Shapes RNBasics 33 | 34 | 35 | 36 | # 37 | # PKG makefile 38 | # 39 | 40 | include ../../makefiles/Makefile.pkgs 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Align.h: -------------------------------------------------------------------------------- 1 | // Include file for alignment utility functions 2 | 3 | 4 | 5 | // Functions to align RNArray of points 6 | 7 | R3Point R3Centroid(const RNArray& points, const RNScalar *weights = NULL); 8 | R3Triad R3PrincipleAxes(const R3Point& centroid, const RNArray& points, const RNScalar *weights = NULL, RNScalar *variances = NULL); 9 | RNLength R3AverageDistance(const R3Point& center, const RNArray& points, const RNScalar *weights = NULL); 10 | R3Affine R3NormalizationTransformation(const RNArray& points, 11 | RNBoolean align_center = TRUE, RNBoolean align_rotation = TRUE, int align_scale = 1); 12 | RNScalar R3AlignError(const RNArray& points1, const RNArray& points2, 13 | const R4Matrix& matrix = R4identity_matrix, const RNScalar* weights = NULL); 14 | R4Matrix R3AlignPoints(const RNArray& points1, const RNArray& points2, const RNScalar *weights = NULL, 15 | RNBoolean align_center = TRUE, RNBoolean align_rotation = TRUE, int align_scale = 1); 16 | 17 | 18 | 19 | // Functions to align C array of points 20 | 21 | R3Point R3Centroid(int npoints, R3Point *points, const RNScalar *weights = NULL); 22 | R3Triad R3PrincipleAxes(const R3Point& centroid, int npoints, R3Point *points, const RNScalar *weights = NULL, RNScalar *variances = NULL); 23 | RNLength R3AverageDistance(const R3Point& center, int npoints, R3Point *points, const RNScalar *weights = NULL); 24 | R3Affine R3NormalizationTransformation(int npoints, R3Point *points, 25 | RNBoolean align_center = TRUE, RNBoolean align_rotation = TRUE, int align_scale = 1); 26 | RNScalar R3AlignError(int npoints, R3Point *points1, R3Point *points2, 27 | const R4Matrix& matrix = R4identity_matrix, const RNScalar* weights = NULL); 28 | R4Matrix R3AlignPoints(int npoints, R3Point *points1, R3Point *points2, const RNScalar* weights = NULL, 29 | RNBoolean align_center = TRUE, RNBoolean align_rotation = TRUE, int align_scale = 1); 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Base.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS basics */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Shapes/R3Shapes.h" 8 | 9 | 10 | 11 | 12 | /* Public draw flags */ 13 | 14 | #if FALSE 15 | 16 | const R3DrawFlags R3_EDGES_DRAW_FLAG (0x001); 17 | const R3DrawFlags R3_SURFACES_DRAW_FLAG (0x002); 18 | const R3DrawFlags R3_SURFACE_NORMALS_DRAW_FLAG (0x010); 19 | const R3DrawFlags R3_SURFACE_TEXTURE_DRAW_FLAG (0x020); 20 | const R3DrawFlags R3_VERTEX_NORMALS_DRAW_FLAG (0x100); 21 | const R3DrawFlags R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG (0x200); 22 | 23 | const R3DrawFlags R3_NULL_DRAW_FLAGS (0x000); 24 | const R3DrawFlags R3_EVERYTHING_DRAW_FLAGS (0xFFF); 25 | const R3DrawFlags R3_DEFAULT_DRAW_FLAGS (R3_EVERYTHING_DRAW_FLAGS & 26 | ~R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG & 27 | ~R3_EDGES_DRAW_FLAG); 28 | #endif 29 | 30 | 31 | 32 | int R3InitBase() 33 | { 34 | /* Return OK status */ 35 | return TRUE; 36 | } 37 | 38 | 39 | 40 | void R3StopBase() 41 | { 42 | } 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Base.h: -------------------------------------------------------------------------------- 1 | /* Include file for GAPS basic stuff */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitBase(); 8 | void R3StopBase(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3Base {}; 15 | 16 | 17 | 18 | /* Draw flags definition */ 19 | 20 | typedef RNFlags R3DrawFlags; 21 | #define R3_NULL_DRAW_FLAGS (0x000) 22 | #define R3_EDGES_DRAW_FLAG (0x001) 23 | #define R3_SURFACES_DRAW_FLAG (0x002) 24 | #define R3_SURFACE_NORMALS_DRAW_FLAG (0x010) 25 | #define R3_SURFACE_TEXTURE_DRAW_FLAG (0x020) 26 | #define R3_SURFACE_MATERIAL_DRAW_FLAG (0x040) 27 | #define R3_VERTEX_NORMALS_DRAW_FLAG (0x100) 28 | #define R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG (0x200) 29 | #define R3_EVERYTHING_DRAW_FLAGS (0x373) 30 | #define R3_DEFAULT_DRAW_FLAGS (R3_EVERYTHING_DRAW_FLAGS & ~R3_EDGES_DRAW_FLAG) 31 | 32 | #define R3_VERTEX_SHARED_FLAG (0x1000) 33 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3CatmullRomSpline.h: -------------------------------------------------------------------------------- 1 | /* Include file for the Catmull Rom spline class */ 2 | 3 | 4 | 5 | /* Class definition */ 6 | 7 | class R3CatmullRomSpline : public R3Polyline { 8 | public: 9 | // Constructor functions 10 | R3CatmullRomSpline(void); 11 | R3CatmullRomSpline(const R3CatmullRomSpline& curve); 12 | R3CatmullRomSpline(const RNArray& points, RNScalar tao = 0.5); 13 | R3CatmullRomSpline(const R3Point *points, int npoints, RNScalar tao = 0.5); 14 | R3CatmullRomSpline(const R3Point *points, const RNScalar *parameters, int npoints, RNScalar tao = 0.5); 15 | virtual ~R3CatmullRomSpline(void); 16 | 17 | // Spline properties 18 | int Order(void) const; 19 | 20 | // Vertex properties 21 | virtual R3Vector VertexDerivative(int k) const; 22 | 23 | // Point access 24 | virtual R3Point PointPosition(RNScalar u) const; 25 | virtual R3Vector PointDerivative(RNScalar u) const; 26 | 27 | // Draw functions 28 | virtual void Outline(const R3DrawFlags flags = R3_DEFAULT_DRAW_FLAGS) const; 29 | virtual void Outline(RNScalar sample_spacing) const; 30 | 31 | public: 32 | // Utility functions 33 | RNScalar BlendingWeight(RNScalar t, int k) const; 34 | RNScalar BlendingWeightDerivative(RNScalar t, int k) const; 35 | R3Point PhantomVertexPosition(int i, int j) const; 36 | 37 | private: 38 | // Upkeep functions 39 | virtual void UpdateBBox(void); 40 | 41 | private: 42 | RNScalar tao; 43 | }; 44 | 45 | 46 | 47 | /* Inline functions */ 48 | 49 | inline int R3CatmullRomSpline:: 50 | Order(void) const 51 | { 52 | // Return order of polynomial 53 | return 3; 54 | } 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Crdsys.h: -------------------------------------------------------------------------------- 1 | /* Include file for the GAPS coordinate system class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitCoordinateSystem(); 8 | void R3StopCoordinateSystem(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3CoordSystem /* : public R3Base */ { 15 | public: 16 | // Constructor functions 17 | R3CoordSystem(void); 18 | R3CoordSystem(const R3CoordSystem& cs); 19 | R3CoordSystem(const R3Point& origin, const R3Triad& axes); 20 | 21 | // Property functions/operators 22 | const R3Point& Origin(void) const; 23 | const R3Triad& Axes(void) const; 24 | const R4Matrix Matrix(void) const; 25 | const R4Matrix InverseMatrix(void) const; 26 | const RNBoolean operator==(const R3CoordSystem& cs) const; 27 | const RNBoolean operator!=(const R3CoordSystem& cs) const; 28 | 29 | // Manipulation functions/operators 30 | void Translate(const R3Vector& offset); 31 | void Rotate(RNAxis axis, RNAngle radians); 32 | void Rotate(const R3Vector& axis, RNAngle radians); 33 | void Rotate(const R3Vector& from, const R3Vector& to); 34 | void Mirror(const R3Plane& plane); 35 | void Transform(const R3Transformation& transformation); 36 | void InverseTransform(const R3Transformation& transformation); 37 | void SetOrigin(const R3Point& origin); 38 | void SetAxes(const R3Triad& axes); 39 | void Reset(const R3Point& origin, const R3Triad& axes); 40 | 41 | // Draw functions/operators 42 | void Draw(void) const; 43 | void Outline(void) const; 44 | 45 | private: 46 | R3Point origin; 47 | R3Triad axes; 48 | }; 49 | 50 | 51 | 52 | /* Public variables */ 53 | 54 | extern const R3CoordSystem R3xyz_coordinate_system; 55 | 56 | 57 | 58 | /* Inline functions */ 59 | 60 | inline const R3Point& R3CoordSystem:: 61 | Origin(void) const 62 | { 63 | // Return origin 64 | return origin; 65 | } 66 | 67 | 68 | 69 | inline const R3Triad& R3CoordSystem:: 70 | Axes(void) const 71 | { 72 | // Return axes triad 73 | return axes; 74 | } 75 | 76 | 77 | 78 | inline const RNBoolean R3CoordSystem:: 79 | operator==(const R3CoordSystem& cs) const 80 | { 81 | // Return whether coordinate system is equal 82 | return (origin == cs.origin) && (axes == cs.axes); 83 | } 84 | 85 | 86 | 87 | inline const RNBoolean R3CoordSystem:: 88 | operator!=(const R3CoordSystem& cs) const 89 | { 90 | // Return whether coordinate system is not equal 91 | return !(*this == cs); 92 | } 93 | 94 | 95 | 96 | inline void R3CoordSystem:: 97 | Outline(void) const 98 | { 99 | // Draw coordinate system 100 | Draw(); 101 | } 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Curve.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R3 curve class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Shapes/R3Shapes.h" 8 | 9 | 10 | 11 | /* Public functions */ 12 | 13 | int 14 | R3InitCurve() 15 | { 16 | /* Return success */ 17 | return TRUE; 18 | } 19 | 20 | 21 | 22 | void 23 | R3StopCurve() 24 | { 25 | } 26 | 27 | 28 | 29 | R3Curve:: 30 | R3Curve(void) 31 | { 32 | } 33 | 34 | 35 | 36 | R3Curve:: 37 | ~R3Curve(void) 38 | { 39 | } 40 | 41 | 42 | 43 | const R3Point R3Curve:: 44 | StartPosition(void) const 45 | { 46 | // Return position at start of curve 47 | return PointPosition(StartParameter()); 48 | } 49 | 50 | 51 | 52 | const R3Point R3Curve:: 53 | EndPosition(void) const 54 | { 55 | // Return position at end of curve 56 | return PointPosition(EndParameter()); 57 | } 58 | 59 | 60 | 61 | R3Vector R3Curve:: 62 | PointDirection(RNScalar u) const 63 | { 64 | // Return tangent direction of curve at parametric value u 65 | R3Vector direction = PointDerivative(u); 66 | direction.Normalize(); 67 | return direction; 68 | } 69 | 70 | 71 | 72 | const RNBoolean R3Curve:: 73 | IsCurve(void) const 74 | { 75 | // All curve shapes are curves 76 | return TRUE; 77 | } 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Curve.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 curve class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitCurve(); 8 | void R3StopCurve(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3Curve : public R3Shape { 15 | public: 16 | // Constructors/destructors ??? 17 | R3Curve(void); 18 | virtual ~R3Curve(void); 19 | 20 | // Curve properties 21 | virtual const RNScalar StartParameter(void) const = 0; 22 | virtual const RNScalar EndParameter(void) const = 0; 23 | virtual const R3Point StartPosition(void) const; 24 | virtual const R3Point EndPosition(void) const; 25 | 26 | // Point access 27 | virtual R3Point PointPosition(RNScalar u) const = 0; 28 | virtual R3Vector PointDerivative(RNScalar u) const = 0; 29 | virtual R3Vector PointDirection(RNScalar u) const; 30 | 31 | // Shape property functions/operators 32 | const RNBoolean IsCurve(void) const; 33 | }; 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Draw.h: -------------------------------------------------------------------------------- 1 | /* Include file for R3 draw utility */ 2 | 3 | 4 | 5 | /* Inline macros */ 6 | 7 | #define R3LoadRgb RNLoadRgb 8 | 9 | 10 | 11 | /* Inline functions */ 12 | 13 | inline void 14 | R3LoadNormal(const R3Vector& normal) 15 | { 16 | // Load normal vector 17 | R3LoadNormal(normal.Coords()); 18 | } 19 | 20 | 21 | 22 | inline void 23 | R3LoadPoint(const R3Point& point) 24 | { 25 | // Load vertex 26 | R3LoadPoint(point.Coords()); 27 | } 28 | 29 | 30 | 31 | inline void 32 | R3LoadTextureCoords(const R2Point& texcoords) 33 | { 34 | // Set texture coordinate (within R3BeginXXX and R3EndXXX) 35 | R3LoadTextureCoords(texcoords.Coords()); 36 | } 37 | 38 | 39 | 40 | inline void 41 | R3DrawText(const R3Point& p, const char *str) 42 | { 43 | // Draw text at point 44 | R3DrawText(p.X(), p.Y(), p.Z(), str); 45 | } 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Halfspace.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the GAPS halfspace class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Shapes/R3Shapes.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | const R3Halfspace R3null_halfspace(0.0, 0.0, 0.0, 0.0); 14 | const R3Halfspace R3posx_halfspace(1.0, 0.0, 0.0, 0.0); 15 | const R3Halfspace R3posy_halfspace(0.0, 1.0, 0.0, 0.0); 16 | const R3Halfspace R3posz_halfspace(0.0, 0.0, 1.0, 0.0); 17 | const R3Halfspace R3negx_halfspace(-1.0, 0.0, 0.0, 0.0); 18 | const R3Halfspace R3negy_halfspace(0.0, -1.0, 0.0, 0.0); 19 | const R3Halfspace R3negz_halfspace(0.0, 0.0, -1.0, 0.0); 20 | 21 | 22 | 23 | /* Public functions */ 24 | 25 | int 26 | R3InitHalfspace() 27 | { 28 | /* Return success */ 29 | return TRUE; 30 | } 31 | 32 | 33 | 34 | void 35 | R3StopHalfspace() 36 | { 37 | } 38 | 39 | 40 | 41 | R3Halfspace:: 42 | R3Halfspace (void) 43 | { 44 | } 45 | 46 | 47 | 48 | R3Halfspace:: 49 | R3Halfspace (const R3Halfspace& halfspace) 50 | : plane(halfspace.plane) 51 | { 52 | } 53 | 54 | 55 | 56 | R3Halfspace:: 57 | R3Halfspace(RNScalar a, RNScalar b, RNScalar c, RNScalar d) 58 | : plane(a, b, c, d) 59 | { 60 | } 61 | 62 | 63 | 64 | R3Halfspace:: 65 | R3Halfspace(const RNScalar a[4]) 66 | : plane(a) 67 | { 68 | } 69 | 70 | 71 | 72 | R3Halfspace:: 73 | R3Halfspace(const R3Vector& normal, RNScalar d) 74 | : plane(normal, d) 75 | { 76 | } 77 | 78 | 79 | 80 | R3Halfspace:: 81 | R3Halfspace(const R3Point& point, const R3Vector& normal) 82 | : plane(point, normal) 83 | { 84 | } 85 | 86 | 87 | 88 | R3Halfspace:: 89 | R3Halfspace(const R3Point& point, const R3Line& line) 90 | : plane(point, line) 91 | { 92 | } 93 | 94 | 95 | 96 | R3Halfspace:: 97 | R3Halfspace(const R3Point& point, const R3Vector& vector1, const R3Vector& vector2) 98 | : plane(point, vector1, vector2) 99 | { 100 | } 101 | 102 | 103 | 104 | R3Halfspace:: 105 | R3Halfspace(const R3Point& point1, const R3Point& point2, const R3Point& point3) 106 | : plane(point1, point2, point3) 107 | { 108 | } 109 | 110 | 111 | 112 | R3Halfspace:: 113 | R3Halfspace(const R3Plane& plane, int ) 114 | : plane(plane) 115 | { 116 | } 117 | 118 | 119 | 120 | void R3Halfspace:: 121 | Mirror (const R3Plane& plane) 122 | { 123 | // Mirror halfspace with respect to plane 124 | this->plane.Mirror(plane); 125 | } 126 | 127 | 128 | 129 | void R3Halfspace:: 130 | Transform (const R3Transformation& transformation) 131 | { 132 | // Transform halfspace 133 | plane.Transform(transformation); 134 | } 135 | 136 | 137 | 138 | void R3Halfspace:: 139 | InverseTransform (const R3Transformation& transformation) 140 | { 141 | // Transform halfspace 142 | plane.InverseTransform(transformation); 143 | } 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3MeshPropertySet.h: -------------------------------------------------------------------------------- 1 | // Include file for mesh property set 2 | 3 | 4 | 5 | // Class definition 6 | 7 | struct R3MeshPropertySet { 8 | public: 9 | // Constructor/destructor 10 | R3MeshPropertySet(R3Mesh *mesh = NULL); 11 | ~R3MeshPropertySet(void); 12 | 13 | // Property set info 14 | R3Mesh *Mesh(void) const; 15 | 16 | // Property access functions 17 | int NProperties(void) const; 18 | R3MeshProperty *Property(int k) const; 19 | R3MeshProperty *Property(const char *name) const; 20 | int PropertyIndex(R3MeshProperty *property) const; 21 | int PropertyIndex(const char *property_name) const; 22 | R3MeshProperty *operator[](int k) const; 23 | 24 | // Property manipulation functions 25 | void Empty(void); 26 | void SortByName(void); 27 | void Insert(R3MeshProperty *property); 28 | void Insert(R3MeshPropertySet *set); 29 | void Remove(R3MeshProperty *property); 30 | void Remove(R3MeshPropertySet *set); 31 | void Remove(const char *name); 32 | void Remove(int k); 33 | void Reset(R3Mesh *mesh); 34 | 35 | // Input/output functions 36 | int Read(const char *filename); 37 | int ReadARFF(const char *filename); 38 | int ReadToronto(const char *filename); 39 | int ReadProperty(const char *filename); 40 | int Write(const char *filename) const; 41 | int WriteARFF(const char *filename) const; 42 | int WriteValues(const char *filename) const; 43 | 44 | public: 45 | R3Mesh *mesh; 46 | RNArray properties; 47 | }; 48 | 49 | 50 | 51 | // Inline functions 52 | 53 | inline R3Mesh *R3MeshPropertySet:: 54 | Mesh(void) const 55 | { 56 | // Return mesh 57 | return mesh; 58 | } 59 | 60 | 61 | 62 | inline int R3MeshPropertySet:: 63 | NProperties(void) const 64 | { 65 | // Return the number of properties 66 | return properties.NEntries(); 67 | } 68 | 69 | 70 | 71 | inline R3MeshProperty *R3MeshPropertySet:: 72 | Property(int k) const 73 | { 74 | // Return Kth property 75 | return properties.Kth(k); 76 | } 77 | 78 | 79 | 80 | inline R3MeshProperty *R3MeshPropertySet:: 81 | Property(const char *property_name) const 82 | { 83 | // Return Kth property 84 | int index = PropertyIndex(property_name); 85 | if (index < 0) return NULL; 86 | else return Property(index); 87 | } 88 | 89 | 90 | 91 | inline R3MeshProperty *R3MeshPropertySet:: 92 | operator[](int k) const 93 | { 94 | // Return kth property 95 | return Property(k); 96 | } 97 | 98 | 99 | 100 | inline void R3MeshPropertySet:: 101 | Insert(R3MeshPropertySet *set) 102 | { 103 | // Insert all properties in set 104 | for (int i = 0; i < set->NProperties(); i++) { 105 | Insert(set->Property(i)); 106 | } 107 | } 108 | 109 | 110 | inline void R3MeshPropertySet:: 111 | Remove(R3MeshPropertySet *set) 112 | { 113 | // Remove all properties in set 114 | for (int i = 0; i < set->NProperties(); i++) { 115 | Remove(set->Property(i)); 116 | } 117 | } 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Polyline.h: -------------------------------------------------------------------------------- 1 | /* Include file for the Catmull Rom spline class */ 2 | 3 | 4 | 5 | /* Class definition */ 6 | 7 | class R3Polyline : public R3Curve { 8 | public: 9 | // Constructor functions 10 | R3Polyline(void); 11 | R3Polyline(const R3Polyline& polyline); 12 | R3Polyline(const RNArray& points); 13 | R3Polyline(const R3Point *points, int npoints); 14 | R3Polyline(const R3Point *points, const RNScalar *parameters, int npoints); 15 | virtual ~R3Polyline(void); 16 | 17 | // Curve properties 18 | virtual const RNScalar StartParameter(void) const; 19 | virtual const RNScalar EndParameter(void) const; 20 | virtual const R3Point StartPosition(void) const; 21 | virtual const R3Point EndPosition(void) const; 22 | 23 | // Shape property functions/operators 24 | virtual const RNBoolean IsPoint(void) const; 25 | virtual const RNBoolean IsLinear(void) const; 26 | virtual const RNBoolean IsPlanar(void) const; 27 | virtual const RNLength Length(void) const; 28 | virtual const R3Point Centroid(void) const; 29 | virtual const R3Shape& BShape(void) const; 30 | virtual const R3Box BBox(void) const; 31 | 32 | // Vertex properties 33 | const int NVertices(void) const; 34 | R3Point VertexPosition(int k) const; 35 | RNScalar VertexParameter(int k) const; 36 | virtual R3Vector VertexDirection(int k) const; 37 | virtual R3Vector VertexDerivative(int k) const; 38 | virtual void *VertexData(int k) const; 39 | virtual int VertexIndex(RNScalar u) const; 40 | 41 | // Point access 42 | virtual R3Point PointPosition(RNScalar u) const; 43 | virtual R3Vector PointDerivative(RNScalar u) const; 44 | 45 | // Manipulation functions 46 | virtual void Transform(const R3Transformation& transformation); 47 | virtual void SetVertexPosition(int k, const R3Point& position); 48 | virtual void SetVertexParameter(int k, RNScalar u); 49 | virtual void SetVertexData(int k, void *data); 50 | 51 | // Draw functions 52 | virtual void Draw(const R3DrawFlags flags = R3_DEFAULT_DRAW_FLAGS) const; 53 | virtual void Outline(const R3DrawFlags flags = R3_DEFAULT_DRAW_FLAGS) const; 54 | 55 | private: 56 | R3Point *vertex_positions; 57 | RNScalar *vertex_parameters; 58 | void **vertex_datas; 59 | int nvertices; 60 | 61 | protected: 62 | virtual void UpdateBBox(void); 63 | R3Box bbox; 64 | }; 65 | 66 | 67 | 68 | /* Inline functions */ 69 | 70 | inline const int R3Polyline:: 71 | NVertices(void) const 72 | { 73 | // Return number of vertices 74 | return nvertices; 75 | } 76 | 77 | 78 | 79 | inline R3Point R3Polyline:: 80 | VertexPosition(int i) const 81 | { 82 | // Return position of ith vertex 83 | assert((i >= 0) && (i < nvertices)); 84 | return vertex_positions[i]; 85 | } 86 | 87 | 88 | 89 | inline RNScalar R3Polyline:: 90 | VertexParameter(int i) const 91 | { 92 | // Return parameter of ith vertex 93 | assert((i >= 0) && (i < nvertices)); 94 | if (vertex_parameters) return vertex_parameters[i]; 95 | else return i; 96 | } 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Ray.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the GAPS ray class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Shapes/R3Shapes.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | const R3Ray R3null_ray(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 14 | const R3Ray R3posx_ray(0.0, 0.0, 0.0, 1.0, 0.0, 0.0); 15 | const R3Ray R3posy_ray(0.0, 0.0, 0.0, 0.0, 1.0, 0.0); 16 | const R3Ray R3posz_ray(0.0, 0.0, 0.0, 0.0, 0.0, 1.0); 17 | const R3Ray R3negx_ray(0.0, 0.0, 0.0, -1.0, 0.0, 0.0); 18 | const R3Ray R3negy_ray(0.0, 0.0, 0.0, 0.0, -1.0, 0.0); 19 | const R3Ray R3negz_ray(0.0, 0.0, 0.0, 0.0, 0.0, -1.0); 20 | 21 | 22 | 23 | /* Public functions */ 24 | 25 | int R3InitRay() 26 | { 27 | /* Return success */ 28 | return TRUE; 29 | } 30 | 31 | 32 | 33 | void R3StopRay() 34 | { 35 | } 36 | 37 | 38 | 39 | R3Ray:: 40 | R3Ray(void) 41 | { 42 | } 43 | 44 | 45 | 46 | R3Ray:: 47 | R3Ray(const R3Ray& ray) 48 | : line(ray.line) 49 | { 50 | } 51 | 52 | 53 | 54 | R3Ray:: 55 | R3Ray(const R3Point& point, const R3Vector& vector, RNBoolean normalized) 56 | : line(point, vector, normalized) 57 | { 58 | } 59 | 60 | 61 | 62 | R3Ray:: 63 | R3Ray(const R3Point& point1, const R3Point& point2) 64 | : line(point1, point2) 65 | { 66 | } 67 | 68 | 69 | 70 | R3Ray:: 71 | R3Ray(RNCoord x1, RNCoord y1, RNCoord z1, RNCoord x2, RNCoord y2, RNCoord z2) 72 | : line(x1, y1, z1, x2, y2, z2) 73 | { 74 | } 75 | 76 | 77 | 78 | const R3Point R3Ray:: 79 | Point(RNScalar t) const 80 | { 81 | // Return point along span 82 | return (Start() + Vector() * t); 83 | } 84 | 85 | 86 | 87 | const RNScalar R3Ray:: 88 | T(const R3Point& point) const 89 | { 90 | // Return parametric value of closest point on ray 91 | if (IsZero()) return 0.0; 92 | RNScalar denom = Vector().Dot(Vector()); 93 | assert(RNIsNotZero(denom)); 94 | R3Vector topoint = point - Start(); 95 | return (Vector().Dot(topoint) / denom); 96 | } 97 | 98 | 99 | 100 | void R3Ray:: 101 | Transform (const R3Transformation& transformation) 102 | { 103 | // Transform line 104 | line.Transform(transformation); 105 | } 106 | 107 | 108 | 109 | void R3Ray:: 110 | InverseTransform (const R3Transformation& transformation) 111 | { 112 | // Transform line 113 | line.InverseTransform(transformation); 114 | } 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Relate.h: -------------------------------------------------------------------------------- 1 | /* Include file for R3 miscelleaneous relationship utility */ 2 | 3 | 4 | 5 | /* Miscellaneous relationship function declarations */ 6 | 7 | R3Point R3Interpolate(const R3Point& point1, const R3Point& point2, RNScalar t1, RNScalar t2, RNScalar t); 8 | 9 | RNAngle R3InteriorAngle(const R3Vector& vector1, const R3Vector& vector2); 10 | RNAngle R3InteriorAngle(const R3Vector& vector, const R3Line& line); 11 | RNAngle R3InteriorAngle(const R3Vector& vector, const R3Ray& ray); 12 | RNAngle R3InteriorAngle(const R3Vector& vector, const R3Span& span); 13 | RNAngle R3InteriorAngle(const R3Vector& vector, const R3Plane& plane); 14 | 15 | RNBoolean R3Abuts(const R3Box& box1, const R3Box& box2); 16 | 17 | int R3Splits(const R3Plane& plane, const R3Span& span); 18 | int R3Splits(const R3Plane& plane, const R3Span& span, R3Span *below_result, R3Span *above_result = NULL); 19 | int R3Splits(const R3Plane& plane, const R3Triangle& triangle); 20 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Shapes.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS shapes module */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Shapes.h" 8 | 9 | 10 | 11 | /* Public 3DR variables -- must be set by the application ??? */ 12 | 13 | #if (RN_3D_GRFX == RN_3DR) 14 | R3dHandle_t R3dr_rc = NULL; 15 | G3dHandle_t R3dr_gc = NULL; 16 | #endif 17 | 18 | 19 | 20 | /* Private variables */ 21 | 22 | static int R3shapes_active_count = 0; 23 | 24 | 25 | 26 | int R3InitShapes(void) 27 | { 28 | // Check whether are already initialized 29 | if ((R3shapes_active_count++) > 0) return TRUE; 30 | 31 | // Initialize dependencies 32 | if (!R2InitShapes()) return FALSE; 33 | 34 | // Initialize submodules 35 | if (!R3InitCircle()) return FALSE; 36 | 37 | // return OK status 38 | return TRUE; 39 | } 40 | 41 | 42 | 43 | void R3StopShapes(void) 44 | { 45 | // Check whether have been initialized 46 | if ((--R3shapes_active_count) > 0) return; 47 | 48 | // Stop submodules 49 | R3StopCircle(); 50 | 51 | // Stop dependencies 52 | R2StopShapes(); 53 | } 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Solid.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R3 solid class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Shapes/R3Shapes.h" 8 | 9 | 10 | 11 | /* Public functions */ 12 | 13 | int 14 | R3InitSolid() 15 | { 16 | /* Return success */ 17 | return TRUE; 18 | } 19 | 20 | 21 | 22 | void 23 | R3StopSolid() 24 | { 25 | } 26 | 27 | 28 | 29 | R3Solid:: 30 | R3Solid(void) 31 | { 32 | } 33 | 34 | 35 | 36 | R3Solid:: 37 | ~R3Solid(void) 38 | { 39 | } 40 | 41 | 42 | 43 | const RNBoolean R3Solid:: 44 | IsSolid(void) const 45 | { 46 | // All solid shapes are solids 47 | return TRUE; 48 | } 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Solid.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 solid class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitSolid(); 8 | void R3StopSolid(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3Solid : public R3Shape { 15 | public: 16 | // Constructors/destructors ??? 17 | R3Solid(void); 18 | ~R3Solid(void); 19 | 20 | // Shape property functions/operators 21 | const RNBoolean IsSolid(void) const; 22 | }; 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Sphere.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 sphere class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitSphere(); 8 | void R3StopSphere(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3Sphere : public R3Solid { 15 | public: 16 | // Constructor functions 17 | R3Sphere(void); 18 | R3Sphere(const R3Sphere& sphere); 19 | R3Sphere(const R3Point& center, RNLength radius); 20 | 21 | // Sphere property functions/operators 22 | const R3Point& Center(void) const; 23 | const RNLength Radius(void) const; 24 | const RNBoolean IsEmpty(void) const; 25 | const RNBoolean IsFinite(void) const; 26 | 27 | // Shape property functions/operators 28 | virtual const RNBoolean IsPoint(void) const; 29 | virtual const RNBoolean IsLinear(void) const ; 30 | virtual const RNBoolean IsPlanar(void) const ; 31 | virtual const RNBoolean IsConvex(void) const ; 32 | virtual const RNInterval NFacets(void) const; 33 | virtual const RNArea Area(void) const; 34 | virtual const RNVolume Volume(void) const; 35 | virtual const R3Point Centroid(void) const; 36 | virtual const R3Point ClosestPoint(const R3Point& point) const; 37 | virtual const R3Point FurthestPoint(const R3Point& point) const; 38 | virtual const R3Shape& BShape(void) const; 39 | virtual const R3Box BBox(void) const; 40 | virtual const R3Sphere BSphere(void) const; 41 | 42 | // Manipulation functions/operators 43 | virtual void Empty(void); 44 | virtual void Translate(const R3Vector& vector); 45 | virtual void Reposition(const R3Point& center); 46 | virtual void Resize(RNLength radius); 47 | virtual void Transform(const R3Transformation& transformation); 48 | 49 | // Draw functions/operators 50 | virtual void Draw(const R3DrawFlags draw_flags = R3_DEFAULT_DRAW_FLAGS) const; 51 | 52 | // Standard shape definitions 53 | RN_CLASS_TYPE_DECLARATIONS(R3Sphere); 54 | R3_SHAPE_RELATIONSHIP_DECLARATIONS(R3Sphere); 55 | 56 | 57 | private: 58 | R3Point center; 59 | RNLength radius; 60 | }; 61 | 62 | 63 | 64 | /* Public variables */ 65 | 66 | extern const R3Sphere R3null_sphere; 67 | extern const R3Sphere R3zero_sphere; 68 | extern const R3Sphere R3unit_sphere; 69 | extern const R3Sphere R3infinite_sphere; 70 | 71 | 72 | 73 | /* Inline functions */ 74 | 75 | inline const R3Point& R3Sphere:: 76 | Center(void) const 77 | { 78 | // Return sphere center 79 | return center; 80 | } 81 | 82 | 83 | 84 | inline const RNLength R3Sphere:: 85 | Radius(void) const 86 | { 87 | // Return sphere radius 88 | return radius; 89 | } 90 | 91 | 92 | 93 | inline const RNBoolean R3Sphere:: 94 | IsEmpty(void) const 95 | { 96 | // Return whether the sphere is null 97 | return (radius < 0.0); 98 | } 99 | 100 | 101 | 102 | inline const RNBoolean R3Sphere:: 103 | IsFinite(void) const 104 | { 105 | // Return whether the sphere has finite radius 106 | return RNIsFinite(radius); 107 | } 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Surface.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R3 surface class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Shapes/R3Shapes.h" 8 | 9 | 10 | 11 | /* Public functions */ 12 | 13 | int 14 | R3InitSurface() 15 | { 16 | /* Return success */ 17 | return TRUE; 18 | } 19 | 20 | 21 | 22 | void 23 | R3StopSurface() 24 | { 25 | } 26 | 27 | 28 | 29 | R3Surface:: 30 | R3Surface(void) 31 | { 32 | } 33 | 34 | 35 | 36 | R3Surface:: 37 | ~R3Surface(void) 38 | { 39 | } 40 | 41 | 42 | 43 | const RNBoolean R3Surface:: 44 | IsSurface(void) const 45 | { 46 | // All surface shapes are surfaces 47 | return TRUE; 48 | } 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Surface.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 surface class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitSurface(); 8 | void R3StopSurface(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3Surface : public R3Shape { 15 | public: 16 | // Constructors/destructors ??? 17 | R3Surface(void); 18 | ~R3Surface(void); 19 | 20 | // Shape property functions/operators 21 | const RNBoolean IsSurface(void) const; 22 | }; 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Triad.h: -------------------------------------------------------------------------------- 1 | /* Include file for the GAPS triad class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitTriad(); 8 | void R3StopTriad(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3Triad /* : public R3Base */ { 15 | public: 16 | // Constructor functions 17 | R3Triad(void); 18 | R3Triad(const R3Triad& triad); 19 | R3Triad(const R3Vector& xaxis, const R3Vector& yaxis, const R3Vector& zaxis); 20 | R3Triad(const R3Vector& towards, const R3Vector& up); 21 | 22 | // Property functions/operators 23 | const R4Matrix Matrix(void) const; 24 | const R4Matrix InverseMatrix(void) const; 25 | const R3Vector& Axis(RNDimension dim) const; 26 | const R3Vector& operator[](RNDimension dim) const; 27 | const RNBoolean operator==(const R3Triad& triad) const; 28 | const RNBoolean operator!=(const R3Triad& triad) const; 29 | 30 | // Manipulation functions/operators 31 | void Normalize(void); 32 | void Rotate(RNAxis axis, RNAngle radians); 33 | void Rotate(const R3Vector& vector, RNAngle radians); 34 | void Rotate(const R3Vector& from, const R3Vector& to); 35 | void Mirror(const R3Plane& plane); 36 | void Transform(const R3Transformation& transformation); 37 | void InverseTransform(const R3Transformation& transformation); 38 | R3Triad& operator=(const R3Triad& triad); 39 | 40 | // Draw functions/operators 41 | void Draw(void) const; 42 | void Outline(void) const; 43 | 44 | private: 45 | R3Vector axis[3]; 46 | }; 47 | 48 | 49 | 50 | /* Public variables */ 51 | 52 | extern const R3Triad R3xyz_triad; 53 | 54 | 55 | 56 | /* Inline functions */ 57 | 58 | inline const R3Vector& R3Triad:: 59 | Axis(RNDimension dim) const 60 | { 61 | // Return axis vector 62 | assert((dim >= RN_X) && (dim <= RN_Z)); 63 | return axis[dim]; 64 | } 65 | 66 | 67 | 68 | inline const R3Vector& R3Triad:: 69 | operator[](RNDimension dim) const 70 | { 71 | // Return axis vector 72 | return Axis(dim); 73 | } 74 | 75 | 76 | 77 | inline const RNBoolean R3Triad:: 78 | operator==(const R3Triad& triad) const 79 | { 80 | // Return whether triad is equal 81 | // We can check only two of the three since everything is orthonormal 82 | return ((axis[0] == triad.axis[0]) && (axis[1] == triad.axis[1])); 83 | } 84 | 85 | 86 | 87 | inline const RNBoolean R3Triad:: 88 | operator!=(const R3Triad& triad) const 89 | { 90 | // Return whether triad is not equal 91 | return !(*this == triad); 92 | } 93 | 94 | 95 | 96 | inline void R3Triad:: 97 | Outline(void) const 98 | { 99 | // Draw triad 100 | Draw(); 101 | } 102 | 103 | 104 | 105 | inline R3Triad& R3Triad:: 106 | operator=(const R3Triad& triad) 107 | { 108 | axis[0] = triad.axis[0]; 109 | axis[1] = triad.axis[1]; 110 | axis[2] = triad.axis[2]; 111 | return *this; 112 | } 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Xform.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the R3 transformation class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "R3Shapes/R3Shapes.h" 8 | 9 | 10 | 11 | /* Public functions */ 12 | 13 | int 14 | R3InitTransformation() 15 | { 16 | /* Return success */ 17 | return TRUE; 18 | } 19 | 20 | 21 | 22 | void 23 | R3StopTransformation() 24 | { 25 | } 26 | 27 | 28 | 29 | R3Transformation:: 30 | ~R3Transformation(void) 31 | { 32 | } 33 | 34 | 35 | 36 | const RNBoolean R3Transformation:: 37 | IsIdentity(void) const 38 | { 39 | // Return whether transformation is identity (default is FALSE) 40 | return FALSE; 41 | } 42 | 43 | 44 | 45 | const RNBoolean R3Transformation:: 46 | IsMirrored(void) const 47 | { 48 | // Return whether transformation is mirrored (default is FALSE) 49 | return FALSE; 50 | } 51 | 52 | 53 | 54 | const RNBoolean R3Transformation:: 55 | IsLinear(void) const 56 | { 57 | // Return whether transformation is linear (default is FALSE) 58 | return FALSE; 59 | } 60 | 61 | 62 | 63 | const RNBoolean R3Transformation:: 64 | IsAffine(void) const 65 | { 66 | // Return whether transformation is affine (default is FALSE) 67 | return FALSE; 68 | } 69 | 70 | 71 | 72 | const RNBoolean R3Transformation:: 73 | IsIsotropic(void) const 74 | { 75 | // Return whether transformation is isotropic (default is FALSE) 76 | return FALSE; 77 | } 78 | 79 | 80 | 81 | const RNScalar R3Transformation:: 82 | ScaleFactor(void) const 83 | { 84 | // Return identity scaling 85 | return 1.0; 86 | } 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /gaps/pkgs/R3Shapes/R3Xform.h: -------------------------------------------------------------------------------- 1 | /* Include file for the R3 transformation class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int R3InitTransformation(); 8 | void R3StopTransformation(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class R3Transformation /* : public R3Base */ { 15 | public: 16 | // Destructor function 17 | virtual ~R3Transformation(void); 18 | 19 | // Property functions/operators 20 | virtual const RNBoolean IsIdentity(void) const; 21 | virtual const RNBoolean IsMirrored(void) const; 22 | virtual const RNBoolean IsLinear(void) const; 23 | virtual const RNBoolean IsAffine(void) const; 24 | virtual const RNBoolean IsIsotropic(void) const; 25 | 26 | // Application functions/operators 27 | virtual void Apply(R3Vector& vector) const = 0; 28 | virtual void Apply(R3Point& point) const = 0; 29 | virtual void Apply(R3Transformation& transformation) const = 0; 30 | virtual void Apply(R3Affine& affine) const = 0; 31 | virtual void ApplyInverse(R3Vector& vector) const = 0; 32 | virtual void ApplyInverse(R3Point& point) const = 0; 33 | virtual void ApplyInverse(R3Transformation& transformation) const = 0; 34 | virtual void ApplyInverse(R3Affine& affine) const = 0; 35 | virtual void ApplyInverseTranspose(R3Vector& vector) const = 0; 36 | virtual void ApplyTranspose(R3Vector& vector) const = 0; 37 | 38 | // Manipulation functions/operators 39 | virtual void Reset(const R3Transformation& transformation) = 0; 40 | virtual void Transform(const R3Transformation& transformation) = 0; 41 | virtual void InverseTransform(const R3Transformation& transformation) = 0; 42 | 43 | // Draw functions/operators 44 | virtual void Load(void) const = 0; 45 | virtual void Draw(void) const = 0; 46 | virtual void Push(void) const = 0; 47 | virtual void Pop(void) const = 0; 48 | 49 | // Do not use these ??? 50 | virtual const RNScalar ScaleFactor(void) const; 51 | }; 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Package name 3 | # 4 | 5 | NAME=RNBasics 6 | 7 | 8 | 9 | # 10 | # List of source files 11 | # 12 | 13 | CCSRCS=$(NAME).cpp \ 14 | RNTime.cpp \ 15 | RNGrfx.cpp RNRgb.cpp \ 16 | RNMap.cpp RNHeap.cpp RNQueue.cpp RNArray.cpp \ 17 | RNSvd.cpp RNIntval.cpp RNScalar.cpp \ 18 | RNType.cpp \ 19 | RNFlags.cpp \ 20 | RNFile.cpp RNMem.cpp \ 21 | RNError.cpp \ 22 | RNBase.cpp 23 | 24 | 25 | 26 | # 27 | # PKG makefile 28 | # 29 | 30 | include ../../makefiles/Makefile.pkgs 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNBase.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS base class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "RNBasics.h" 8 | 9 | 10 | 11 | /* Global variables */ 12 | 13 | RNMark RNmark = 1; 14 | 15 | 16 | 17 | int RNInitBase() 18 | { 19 | /* Return OK status */ 20 | return TRUE; 21 | } 22 | 23 | 24 | 25 | void RNStopBase() 26 | { 27 | } 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNBase.h: -------------------------------------------------------------------------------- 1 | /* Include file for GAPS basics */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int RNInitBase(); 8 | void RNStopBase(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class RNBase {}; 15 | 16 | 17 | 18 | /* TRUE/FALSE constant definitions */ 19 | 20 | typedef int RNBoolean; 21 | #ifndef TRUE 22 | #define TRUE 1 23 | #endif 24 | #ifndef FALSE 25 | #define FALSE 0 26 | #endif 27 | 28 | 29 | 30 | /* Programming convenience macros */ 31 | 32 | #define brcase break; case 33 | 34 | 35 | 36 | /* Standard types */ 37 | 38 | typedef int RNMark; 39 | 40 | 41 | 42 | /* Global variables */ 43 | 44 | extern RNMark RNmark; 45 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNBasics.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS basics module */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "RNBasics.h" 8 | 9 | 10 | 11 | /* Private variables */ 12 | 13 | static int RNbasics_active_count = 0; 14 | 15 | 16 | 17 | int RNInitBasics(void) 18 | { 19 | // Check whether are already initialized 20 | if ((RNbasics_active_count++) > 0) return TRUE; 21 | 22 | // Initialize submodules 23 | RNSeedRandomScalar(); 24 | 25 | // Return OK status 26 | return TRUE; 27 | } 28 | 29 | 30 | 31 | void RNStopBasics(void) 32 | { 33 | // Check whether have been initialized 34 | if ((--RNbasics_active_count) > 0) return; 35 | 36 | // Stop submodules 37 | // ??? 38 | } 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNBasics.h: -------------------------------------------------------------------------------- 1 | /* Include file for GAPS basics module */ 2 | 3 | #ifndef __RN__BASICS__H__ 4 | #define __RN__BASICS__H__ 5 | 6 | 7 | 8 | /* Compatability switch include files */ 9 | 10 | #include "RNCompat.h" 11 | 12 | 13 | 14 | /* External include files */ 15 | 16 | #include "RNExtern.h" 17 | 18 | 19 | 20 | /* Base class for GAPS modules */ 21 | 22 | #include "RNBase.h" 23 | 24 | 25 | 26 | /* Error reporting include files */ 27 | 28 | #include "RNError.h" 29 | 30 | 31 | 32 | /* Memory management include files */ 33 | 34 | #include "RNMem.h" 35 | 36 | 37 | 38 | /* File management include files */ 39 | 40 | #include "RNFile.h" 41 | 42 | 43 | 44 | /* Basic bitflags include files */ 45 | 46 | #include "RNFlags.h" 47 | 48 | 49 | 50 | /* Class type include files */ 51 | 52 | #include "RNType.h" 53 | 54 | 55 | 56 | /* Math include files */ 57 | 58 | #include "RNScalar.h" 59 | #include "RNIntval.h" 60 | 61 | 62 | 63 | /* Dynamic array include files */ 64 | 65 | #include "RNArray.h" 66 | #include "RNQueue.h" 67 | #include "RNHeap.h" 68 | #include "RNMap.h" 69 | 70 | 71 | 72 | /* Graphics utility include files */ 73 | 74 | #include "RNGrfx.h" 75 | #include "RNRgb.h" 76 | 77 | 78 | 79 | /* OS utility include files */ 80 | 81 | #include "RNTime.h" 82 | 83 | 84 | 85 | /* SVD stuff */ 86 | 87 | #include "RNSvd.h" 88 | 89 | 90 | 91 | /* Initialization functions */ 92 | 93 | int RNInitBasics(void); 94 | void RNStopBasics(void); 95 | 96 | 97 | 98 | #endif 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNError.h: -------------------------------------------------------------------------------- 1 | /* Include file for GAPS error utility */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int RNInitError(); 8 | void RNStopError(); 9 | 10 | 11 | 12 | /* Error file functions */ 13 | 14 | void RNSetErrorFile(FILE *fp); 15 | void RNSetErrorLevel(int level); 16 | 17 | 18 | 19 | /* Error reporting functions */ 20 | 21 | void RNAbort(const char *fmt, ...); 22 | void RNFail(const char *fmt, ...); 23 | void RNWarning(const char *fmt, ...); 24 | 25 | 26 | 27 | /* Define my own assert function */ 28 | 29 | #ifdef assert 30 | # undef assert 31 | #endif 32 | 33 | #ifdef NDEBUG 34 | #define assert(__x__) 35 | #else 36 | #define assert(__x__) \ 37 | if (!(__x__)) RNAbort("Assertion error %s at line %d in file %s", #__x__, __LINE__, __FILE__) 38 | #endif 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNExtern.h: -------------------------------------------------------------------------------- 1 | /* Include file for external stuff */ 2 | 3 | 4 | 5 | /* Usual C include files */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | 18 | /* Standard library include files */ 19 | 20 | #include 21 | #include 22 | 23 | 24 | 25 | /* Machine dependent include files */ 26 | 27 | #if (RN_OS == RN_WINDOWS) 28 | # include 29 | # include 30 | #else 31 | # include 32 | # include 33 | # include 34 | #endif 35 | 36 | 37 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNFile.cpp: -------------------------------------------------------------------------------- 1 | // Source file for file management utilities 2 | 3 | 4 | // Include files 5 | #include "RNBasics.h" 6 | 7 | 8 | 9 | //////////////////////////////////////////////////////////////////////// 10 | // FILE EXISTANCE FUNCTIONS 11 | //////////////////////////////////////////////////////////////////////// 12 | 13 | RNBoolean 14 | RNFileExists(const char *filename) 15 | { 16 | // Return whether or not file exists (and is readable) 17 | FILE *fp = fopen(filename, "rb"); 18 | if (!fp) return FALSE; 19 | fclose(fp); 20 | return TRUE; 21 | } 22 | 23 | 24 | 25 | //////////////////////////////////////////////////////////////////////// 26 | // FILE I/O UTILITY FUNCTIONS 27 | //////////////////////////////////////////////////////////////////////// 28 | 29 | int 30 | RNFileSeek(FILE *fp, unsigned long long offset, int whence) 31 | { 32 | #if (RN_OS == RN_WINDOWS) 33 | if (_fseek64(fp, offset, whence) == 0) return 1; 34 | else return 0; 35 | #else 36 | // Linux/unix/cygwin etc. 37 | if (fseeko(fp, offset, whence) == 0) return 1; 38 | else return 0; 39 | #endif 40 | } 41 | 42 | 43 | 44 | unsigned long long 45 | RNFileTell(FILE *fp) 46 | { 47 | #if (RN_OS == RN_WINDOWS) 48 | return _ftell64(fp); 49 | #else 50 | // Linux/unix/cygwin etc. 51 | return ftello(fp); 52 | #endif 53 | } 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNFile.h: -------------------------------------------------------------------------------- 1 | // Include file for file management utilities 2 | 3 | 4 | 5 | //////////////////////////////////////////////////////////////////////// 6 | // File existance funcitons 7 | //////////////////////////////////////////////////////////////////////// 8 | 9 | RNBoolean RNFileExists(const char *filename); 10 | 11 | 12 | 13 | //////////////////////////////////////////////////////////////////////// 14 | // File seek funcitons 15 | //////////////////////////////////////////////////////////////////////// 16 | 17 | int RNFileSeek(FILE *fp, unsigned long long offset, int whence); 18 | unsigned long long RNFileTell(FILE *fp); 19 | 20 | 21 | 22 | //////////////////////////////////////////////////////////////////////// 23 | // File seek constants 24 | //////////////////////////////////////////////////////////////////////// 25 | 26 | #define RN_FILE_SEEK_SET SEEK_SET 27 | #define RN_FILE_SEEK_CUR SEEK_CUR 28 | #define RN_FILE_SEEK_END SEEK_END 29 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNFlags.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the GAPS flags class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "RNBasics.h" 8 | 9 | 10 | 11 | /* Public functions */ 12 | 13 | int 14 | RNInitFlags() 15 | { 16 | /* Return success */ 17 | return TRUE; 18 | } 19 | 20 | 21 | 22 | void 23 | RNStopFlags() 24 | { 25 | } 26 | 27 | 28 | 29 | RNFlags:: 30 | RNFlags(void) 31 | : flags(0) 32 | { 33 | } 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNFlags.h: -------------------------------------------------------------------------------- 1 | /* Include file for the GAPS flags class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int RNInitFlags(); 8 | void RNStopFlags(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class RNFlags /* : public RNBase */ { 15 | public: 16 | // Constructor functions 17 | RNFlags(void); 18 | RNFlags(unsigned long flags); 19 | 20 | // Type conversions 21 | operator unsigned long(void) const; 22 | 23 | // Relationship functions/operators 24 | int Intersects(const RNFlags flags) const; 25 | int Contains(const RNFlags flags) const; 26 | int operator[](const RNFlags flags) const; 27 | 28 | // Manipulation functions/operators 29 | void Add(const RNFlags flags); 30 | void Remove(const RNFlags flags); 31 | void Intersect(const RNFlags flags); 32 | void Reset(unsigned long flags); 33 | 34 | private: 35 | unsigned long flags; 36 | }; 37 | 38 | 39 | 40 | /* Flag mask definitions */ 41 | 42 | #define RN_NO_FLAGS 0x00000000 43 | #define RN_NULL_FLAGS 0x00000000 44 | #define RN_ALL_FLAGS 0xFFFFFFFF 45 | 46 | 47 | 48 | /* Inline functions */ 49 | 50 | inline RNFlags:: 51 | RNFlags(unsigned long flags) 52 | : flags(flags) 53 | { 54 | } 55 | 56 | 57 | 58 | inline RNFlags::operator 59 | unsigned long(void) const 60 | { 61 | // Convert RNFlags to unsigned long 62 | return flags; 63 | } 64 | 65 | 66 | 67 | inline int RNFlags:: 68 | Intersects(const RNFlags flags) const 69 | { 70 | // Return whether has a property 71 | return (this->flags & flags) ? 1 : 0; 72 | } 73 | 74 | 75 | 76 | inline int RNFlags:: 77 | Contains(const RNFlags flags) const 78 | { 79 | // Return whether contains all properties 80 | return ((this->flags & flags) == flags); 81 | } 82 | 83 | 84 | 85 | inline int RNFlags:: 86 | operator[] (const RNFlags flags) const 87 | { 88 | // Return whether flags intersect 89 | return this->Intersects(flags); 90 | } 91 | 92 | 93 | 94 | inline void RNFlags:: 95 | Add(const RNFlags flags) 96 | { 97 | // Union this set of flags with ones passed in 98 | this->flags |= flags; 99 | } 100 | 101 | 102 | 103 | inline void RNFlags:: 104 | Remove(const RNFlags flags) 105 | { 106 | // Diff this set of flags with ones passed in 107 | this->flags &= ~flags; 108 | } 109 | 110 | 111 | 112 | inline void RNFlags:: 113 | Intersect(const RNFlags flags) 114 | { 115 | // Intersect this set of flags with ones passed in 116 | this->flags &= flags; 117 | } 118 | 119 | 120 | 121 | inline void RNFlags:: 122 | Reset(unsigned long flags) 123 | { 124 | // Set flags 125 | this->flags = flags; 126 | } 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNHeap.h: -------------------------------------------------------------------------------- 1 | // Include file for a heap 2 | 3 | #ifndef __RN__HEAP__H__ 4 | #define __RN__HEAP__H__ 5 | 6 | 7 | 8 | // Class definition 9 | 10 | template 11 | class RNHeap { 12 | public: 13 | // Constructor functions 14 | RNHeap(RNScalar (*value_callback)(PtrType, void *), 15 | PtrType **(*entry_callback)(PtrType, void *) = NULL, 16 | void *callback_data = NULL, int least_first = TRUE); 17 | RNHeap(PtrType base, RNScalar *value_ptr, PtrType **entry_ptr = NULL, int least_first = TRUE); 18 | RNHeap(int value_offset, int entry_offset = -1, int least_first = TRUE); 19 | ~RNHeap(void); 20 | 21 | // Data access functions 22 | int IsEmpty(void) const; 23 | int NEntries(void) const; 24 | PtrType Kth(int k) const; 25 | PtrType operator[](int k) const; 26 | PtrType Peek(void) const; 27 | 28 | // Manipulation functions 29 | void Empty(void); 30 | void Sort(int n = -1); 31 | void Truncate(int n, RNBoolean sort = TRUE); 32 | void Remove(PtrType data); 33 | void Update(PtrType data); 34 | void Push(PtrType data); 35 | PtrType Pop(void); 36 | 37 | // Debug functions 38 | int IsValid(void); 39 | 40 | protected: 41 | // Update functions 42 | RNScalar Value(int i) const; 43 | int Compare(int i, int j) const; 44 | void Swap(int i, int j); 45 | void Sort(int n, int left, int right); 46 | int BubbleUp(int i); 47 | int BubbleDown(int i); 48 | 49 | private: 50 | PtrType *entries; 51 | int nentries; 52 | int nallocated; 53 | int value_offset; 54 | int entry_offset; 55 | RNScalar (*value_callback)(PtrType, void *); 56 | PtrType **(*entry_callback)(PtrType, void *); 57 | void *callback_data; 58 | int least_first; 59 | }; 60 | 61 | 62 | 63 | // Include files 64 | 65 | #include "RNHeap.cpp" 66 | 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNMap.I: -------------------------------------------------------------------------------- 1 | #ifndef __RN_MAP__ 2 | #define __RN_MAP__ 3 | 4 | 5 | 6 | /* Member functions */ 7 | 8 | template 9 | RNMap:: 10 | RNMap(void) 11 | { 12 | // Allocate map 13 | m = new std::map >(); 14 | } 15 | 16 | 17 | 18 | template 19 | RNMap:: 20 | RNMap(int (*compare_function)(KeyType, KeyType)) 21 | { 22 | // Allocate map 23 | RNMapComparator c(compare_function); 24 | m = new std::map >( c ); 25 | } 26 | 27 | 28 | 29 | template 30 | RNMap:: 31 | RNMap(const RNMap& src) 32 | { 33 | // Copy map 34 | m = new std::map >( *(src.m) ); 35 | } 36 | 37 | 38 | 39 | template 40 | RNMap:: 41 | ~RNMap(void) 42 | { 43 | // Delete map 44 | delete m; 45 | } 46 | 47 | 48 | 49 | 50 | template 51 | int RNMap:: 52 | NEntries(void) const 53 | { 54 | // Return number of entries in map 55 | return (int) m->size(); 56 | } 57 | 58 | 59 | 60 | 61 | template 62 | RNBoolean RNMap:: 63 | Find(KeyType key, ValueType *value) const 64 | { 65 | // Return value associated with key, or NULL if not found 66 | typename std::map >::iterator it = m->find(key); 67 | if (it == m->end()) return FALSE; 68 | if (value) *value = it->second; 69 | return TRUE; 70 | } 71 | 72 | 73 | 74 | template 75 | void RNMap:: 76 | Empty(void) 77 | { 78 | // Remove all entries 79 | m->clear(); 80 | } 81 | 82 | 83 | 84 | template 85 | void RNMap:: 86 | Insert(KeyType key, ValueType value) 87 | { 88 | // Insert entry into map 89 | (*m)[key] = value; 90 | } 91 | 92 | 93 | 94 | template 95 | void RNMap:: 96 | Replace(KeyType key, ValueType value) 97 | { 98 | // Replace entry in map 99 | (*m)[key] = value; 100 | } 101 | 102 | 103 | 104 | 105 | template 106 | void RNMap:: 107 | Remove(KeyType key) 108 | { 109 | // Remove entry from map 110 | typename std::map >::iterator it = m->find(key); 111 | if (it != m->end()) m->erase(it); 112 | } 113 | 114 | 115 | 116 | template 117 | RNMap& RNMap:: 118 | operator=(const RNMap& src) 119 | { 120 | // Replace map 121 | delete m; 122 | m = new std::map >( *(src.m) ); 123 | return *this; 124 | } 125 | 126 | 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNMap.cpp: -------------------------------------------------------------------------------- 1 | #ifndef __RN_MAP__C__ 2 | #define __RN_MAP__C__ 3 | 4 | 5 | 6 | // Include files 7 | 8 | #include "RNBasics.h" 9 | 10 | 11 | 12 | // Member functions 13 | 14 | template 15 | RNMap:: 16 | RNMap(void) 17 | { 18 | // Allocate map 19 | m = new std::map >(); 20 | } 21 | 22 | 23 | 24 | template 25 | RNMap:: 26 | RNMap(int (*compare_function)(KeyType, KeyType)) 27 | { 28 | // Allocate map 29 | RNMapComparator c(compare_function); 30 | m = new std::map >( c ); 31 | } 32 | 33 | 34 | 35 | template 36 | RNMap:: 37 | RNMap(const RNMap& src) 38 | { 39 | // Copy map 40 | m = new std::map >( *(src.m) ); 41 | } 42 | 43 | 44 | 45 | template 46 | RNMap:: 47 | ~RNMap(void) 48 | { 49 | // Delete map 50 | delete m; 51 | } 52 | 53 | 54 | 55 | 56 | template 57 | int RNMap:: 58 | NEntries(void) const 59 | { 60 | // Return number of entries in map 61 | return (int) m->size(); 62 | } 63 | 64 | 65 | 66 | 67 | template 68 | RNBoolean RNMap:: 69 | Find(KeyType key, ValueType *value) const 70 | { 71 | // Return value associated with key, or NULL if not found 72 | typename std::map >::iterator it = m->find(key); 73 | if (it == m->end()) return FALSE; 74 | if (value) *value = it->second; 75 | return TRUE; 76 | } 77 | 78 | 79 | 80 | template 81 | void RNMap:: 82 | Empty(void) 83 | { 84 | // Remove all entries 85 | m->clear(); 86 | } 87 | 88 | 89 | 90 | template 91 | void RNMap:: 92 | Insert(KeyType key, ValueType value) 93 | { 94 | // Insert entry into map 95 | (*m)[key] = value; 96 | } 97 | 98 | 99 | 100 | template 101 | void RNMap:: 102 | Replace(KeyType key, ValueType value) 103 | { 104 | // Replace entry in map 105 | (*m)[key] = value; 106 | } 107 | 108 | 109 | 110 | 111 | template 112 | void RNMap:: 113 | Remove(KeyType key) 114 | { 115 | // Remove entry from map 116 | typename std::map >::iterator it = m->find(key); 117 | if (it != m->end()) m->erase(it); 118 | } 119 | 120 | 121 | 122 | template 123 | RNMap& RNMap:: 124 | operator=(const RNMap& src) 125 | { 126 | // Replace map 127 | delete m; 128 | m = new std::map >( *(src.m) ); 129 | return *this; 130 | } 131 | 132 | 133 | 134 | #endif 135 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNMap.h: -------------------------------------------------------------------------------- 1 | /* Include file for the GAPS map class */ 2 | 3 | #ifndef __RN__MAP__H__ 4 | #define __RN__MAP__H__ 5 | 6 | 7 | 8 | /* Library initialization functions */ 9 | 10 | int RNInitMap(); 11 | void RNStopMap(); 12 | 13 | 14 | 15 | /* Support class */ 16 | 17 | template 18 | struct RNMapComparator { 19 | public: 20 | RNMapComparator(int (*compare_function)(KeyType, KeyType) = NULL) : compare_function(compare_function) {}; 21 | bool operator()(KeyType a, KeyType b) const { 22 | if (compare_function) { return ((*compare_function)(a, b) < 0) ? true: false; } 23 | else { return a < b; } 24 | }; 25 | private: 26 | int (*compare_function)(KeyType, KeyType); 27 | }; 28 | 29 | 30 | 31 | /* Class definition */ 32 | 33 | template 34 | class RNMap { 35 | public: 36 | // Constructor/destructor functions 37 | RNMap(void); 38 | RNMap(int (*compare)(KeyType, KeyType)); 39 | RNMap(const RNMap& map); 40 | ~RNMap(void); 41 | 42 | // Property functions/operations 43 | int NEntries(void) const; 44 | 45 | // Data access functions/operators 46 | RNBoolean Find(KeyType key, ValueType *value = NULL) const; 47 | 48 | // Manipulation functions 49 | void Empty(void); 50 | void Insert(KeyType key, ValueType value); 51 | void Replace(KeyType key, ValueType value); 52 | void Remove(KeyType key); 53 | 54 | // Manipulation operators 55 | RNMap& operator=(const RNMap& map); 56 | 57 | private: 58 | std::map > *m; 59 | }; 60 | 61 | 62 | 63 | 64 | /* Templated member functions */ 65 | 66 | #include "RNMap.cpp" 67 | 68 | 69 | 70 | /* A useful derived class definition */ 71 | 72 | template 73 | class RNSymbolTable : public RNMap { 74 | public: 75 | // Constructor/destructor functions 76 | RNSymbolTable(void) : RNMap() {}; 77 | }; 78 | 79 | 80 | 81 | #endif 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNMem.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS mem utility */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "RNBasics.h" 8 | 9 | 10 | 11 | int RNInitMem() 12 | { 13 | /* Return OK status */ 14 | return TRUE; 15 | } 16 | 17 | 18 | 19 | void RNStopMem() 20 | { 21 | } 22 | 23 | 24 | 25 | #if FALSE 26 | 27 | void *operator new(size_t size) 28 | { 29 | // Allocate size bytes 30 | void *data = (void *) malloc(size); 31 | if (!data) RNAbort("Unable to allocate %d bytes", size); 32 | return data; 33 | } 34 | 35 | 36 | 37 | void *operator new(size_t size, size_t extra) 38 | { 39 | // Allocate (size+extra) bytes 40 | void *data = (void *) malloc(size+extra); 41 | if (!data) RNAbort("Unable to allocate %d bytes", size+extra); 42 | return (void *) data; 43 | } 44 | 45 | 46 | 47 | void operator delete(void *data) 48 | { 49 | // Check arguments 50 | assert(data); 51 | 52 | // Free allocated bytes 53 | free(data); 54 | } 55 | 56 | #endif 57 | 58 | 59 | 60 | void RNSwap(void *node1, void *node2, void *buffer, int size) 61 | { 62 | // Check arguments 63 | assert(node1); 64 | assert(node2); 65 | assert(size > 0); 66 | 67 | // Find suitable swap buffer 68 | void *swap = buffer; 69 | char swap_buffer[RN_SWAP_BUFFER_SIZE]; 70 | if (buffer == NULL) { 71 | swap = (void *) swap_buffer; 72 | if (size > RN_SWAP_BUFFER_SIZE) { 73 | swap = (void *) malloc(size); 74 | if (!swap) { 75 | RNFail("Unable to allocate swap buffer"); 76 | return; 77 | } 78 | } 79 | } 80 | 81 | // Swap two buffers 82 | RNCopy(node1, swap, size); 83 | RNCopy(node2, node1, size); 84 | RNCopy(swap, node2, size); 85 | 86 | // Free swap buffer 87 | if (buffer == NULL) { 88 | if (size > RN_SWAP_BUFFER_SIZE) { 89 | free(swap); 90 | } 91 | } 92 | } 93 | 94 | 95 | 96 | void RNCopy(const void *src, void *dst, int size) 97 | { 98 | // Check arguments 99 | assert(src); 100 | assert(dst); 101 | assert(size > 0); 102 | 103 | // Copy buffer 104 | // bcopy(src, dst, size); 105 | memcpy(dst, src, size); 106 | } 107 | 108 | 109 | 110 | void RNZero(void *data, int size) 111 | { 112 | // Check arguments 113 | assert(data); 114 | assert(size > 0); 115 | 116 | // Zero buffer 117 | // bzero(data, size); 118 | memset(data, 0, size); 119 | } 120 | 121 | 122 | 123 | int RNCompare(const void *src1, const void *src2, int size) 124 | { 125 | // Check arguments 126 | assert(src1); 127 | assert(src2); 128 | assert(size > 0); 129 | 130 | // Compare buffers 131 | // return bcmp(src1, src2, size); 132 | return memcmp(src1, src2, size); 133 | } 134 | 135 | 136 | 137 | 138 | long RNMaxMemoryUsage(void) 139 | { 140 | # if (RN_OS == RN_WINDOWS) 141 | RNAbort("Not implemented"); 142 | return -1; 143 | #else 144 | struct rusage usage; 145 | if (getrusage(RUSAGE_SELF, &usage) == -1) return -1; 146 | return usage.ru_maxrss; 147 | # endif 148 | } 149 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNMem.h: -------------------------------------------------------------------------------- 1 | /* Include file for GAPS mem utility */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int RNInitMem(); 8 | void RNStopMem(); 9 | 10 | 11 | 12 | /* Memory allocation/deallocation functions */ 13 | 14 | #if FALSE 15 | 16 | void *operator new(size_t size); 17 | void *operator new(size_t size, size_t extra); 18 | void operator delete(void *data); 19 | 20 | #endif 21 | 22 | 23 | 24 | /* Standard memory manipulation functions */ 25 | 26 | #define RN_SWAP_BUFFER_SIZE 1024 27 | void RNSwap(void *node1, void *node2, void *buffer, int size); 28 | void RNCopy(const void *src, void *dst, int size); 29 | void RNZero(void *data, int size); 30 | int RNCompare(const void *src1, const void *src2, int size); 31 | 32 | 33 | 34 | /* Memory usage statistics */ 35 | 36 | long RNMaxMemoryUsage(void); 37 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNRgb.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for the RN RGB color class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "RNBasics.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | RNRgb RNnull_rgb(0.0, 0.0, 0.0); 14 | RNRgb RNblack_rgb(0.0, 0.0, 0.0); 15 | RNRgb RNgray_rgb(0.5, 0.5, 0.5); 16 | RNRgb RNred_rgb(1.0, 0.0, 0.0); 17 | RNRgb RNgreen_rgb(0.0, 1.0, 0.0); 18 | RNRgb RNblue_rgb(0.0, 0.0, 1.0); 19 | RNRgb RNyellow_rgb(1.0, 1.0, 0.0); 20 | RNRgb RNcyan_rgb(0.0, 1.0, 1.0); 21 | RNRgb RNmagenta_rgb(1.0, 0.0, 1.0); 22 | RNRgb RNwhite_rgb(1.0, 1.0, 1.0); 23 | 24 | 25 | 26 | /* Public functions */ 27 | 28 | int 29 | RNInitRgb() 30 | { 31 | /* Return success */ 32 | return TRUE; 33 | } 34 | 35 | 36 | 37 | void 38 | RNStopRgb() 39 | { 40 | } 41 | 42 | 43 | 44 | RNRgb:: 45 | RNRgb(void) 46 | { 47 | } 48 | 49 | 50 | 51 | RNRgb:: 52 | RNRgb(const RNRgb& rgb) 53 | { 54 | c[0] = rgb.c[0]; 55 | c[1] = rgb.c[1]; 56 | c[2] = rgb.c[2]; 57 | } 58 | 59 | 60 | 61 | RNRgb:: 62 | RNRgb(RNScalar red, RNScalar green, RNScalar blue) 63 | { 64 | c[0] = red; 65 | c[1] = green; 66 | c[2] = blue; 67 | } 68 | 69 | 70 | 71 | RNRgb:: 72 | RNRgb(const RNScalar array[3]) 73 | { 74 | c[0] = array[0]; 75 | c[1] = array[1]; 76 | c[2] = array[2]; 77 | } 78 | 79 | 80 | 81 | const RNBoolean RNRgb:: 82 | operator==(const RNRgb& rgb) const 83 | { 84 | // Return whether rgb is equal 85 | return ((c[0] == rgb.c[0]) && (c[1] == rgb.c[1]) && (c[2] == rgb.c[2])); 86 | } 87 | 88 | 89 | 90 | const RNBoolean RNRgb:: 91 | operator!=(const RNRgb& rgb) const 92 | { 93 | // Return whether rgb is not equal 94 | return ((c[0] != rgb.c[0]) || (c[1] != rgb.c[1]) || (c[2] != rgb.c[2])); 95 | } 96 | 97 | 98 | 99 | RNRgb& RNRgb:: 100 | operator=(const RNRgb& rgb) 101 | { 102 | c[0] = rgb.c[0]; 103 | c[1] = rgb.c[1]; 104 | c[2] = rgb.c[2]; 105 | return *this; 106 | } 107 | 108 | 109 | 110 | RNRgb& RNRgb:: 111 | operator+=(const RNRgb& rgb) 112 | { 113 | c[0] += rgb.c[0]; 114 | c[1] += rgb.c[1]; 115 | c[2] += rgb.c[2]; 116 | return *this; 117 | } 118 | 119 | 120 | 121 | RNRgb& RNRgb:: 122 | operator-=(const RNRgb& rgb) 123 | { 124 | c[0] -= rgb.c[0]; 125 | c[1] -= rgb.c[1]; 126 | c[2] -= rgb.c[2]; 127 | return *this; 128 | } 129 | 130 | 131 | 132 | RNRgb& RNRgb:: 133 | operator*=(const RNRgb& rgb) 134 | { 135 | c[0] *= rgb.c[0]; 136 | c[1] *= rgb.c[1]; 137 | c[2] *= rgb.c[2]; 138 | return *this; 139 | } 140 | 141 | 142 | 143 | RNRgb& RNRgb:: 144 | operator*=(RNScalar a) 145 | { 146 | c[0] *= a; 147 | c[1] *= a; 148 | c[2] *= a; 149 | return *this; 150 | } 151 | 152 | 153 | 154 | RNRgb& RNRgb:: 155 | operator/=(RNScalar a) 156 | { 157 | // assert(!zero(a)); 158 | c[0] /= a; 159 | c[1] /= a; 160 | c[2] /= a; 161 | return *this; 162 | } 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNSvd.h: -------------------------------------------------------------------------------- 1 | // Include file for SVD functions 2 | 3 | 4 | 5 | // Function to perform singular value decomposition 6 | 7 | extern void RNSvdDecompose(int m, int n, 8 | const RNScalar *a, 9 | RNScalar *u, RNScalar *w, RNScalar *vt); 10 | 11 | 12 | 13 | // Function to perform back substitution 14 | 15 | extern void RNSvdBacksubstitute(int m, int n, 16 | const RNScalar *u, const RNScalar *w, const RNScalar *vt, const RNScalar *b, 17 | RNScalar *x, RNScalar eps = RN_EPSILON); 18 | 19 | 20 | 21 | // Function to solve system of equations by SVD and back substitution 22 | 23 | extern void RNSvdSolve(int m, int n, 24 | const RNScalar *a, const RNScalar *b, 25 | RNScalar *x, RNScalar eps = RN_EPSILON); 26 | 27 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNTime.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS real wallclock time class */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "RNBasics.h" 8 | 9 | 10 | 11 | int RNInitTime() 12 | { 13 | /* Return OK status */ 14 | return TRUE; 15 | } 16 | 17 | 18 | 19 | void RNStopTime() 20 | { 21 | } 22 | 23 | 24 | 25 | RNTime:: 26 | RNTime(void) 27 | { 28 | # if (RN_OS == RN_WINDOWS) 29 | QueryPerformanceFrequency(&timefreq); 30 | # endif 31 | } 32 | 33 | 34 | 35 | RNTime:: 36 | RNTime(const RNTime& tm) 37 | : timevalue(tm.timevalue) 38 | { 39 | # if (RN_OS == RN_WINDOWS) 40 | timefreq = timefreq; 41 | # endif 42 | } 43 | 44 | 45 | 46 | RNScalar RNTime:: 47 | operator- (const RNTime& tm) const 48 | { 49 | /* Return the difference between this and tm times (in seconds) */ 50 | # if (RN_OS == RN_WINDOWS) 51 | return ((RNScalar) this->timevalue.QuadPart - (RNScalar) tm.timevalue.QuadPart) / ((RNScalar) this->timefreq.QuadPart); 52 | # elif (RN_OS == OLD_RN_WINDOWS) 53 | return (RNScalar) (this->timevalue - tm.timevalue) / 1.0E3; 54 | # else 55 | return (RNScalar) (this->timevalue.tv_sec - tm.timevalue.tv_sec + 56 | 1.0E-6F * (this->timevalue.tv_usec - tm.timevalue.tv_usec)); 57 | # endif 58 | } 59 | 60 | 61 | 62 | RNScalar RNTime:: 63 | Elapsed (const RNTime& tm) const 64 | { 65 | // Return number of seconds elapsed between times 66 | RNScalar delta = *this - tm; 67 | assert(delta >= 0.0); 68 | return delta; 69 | } 70 | 71 | 72 | 73 | RNScalar RNTime:: 74 | Elapsed (void) const 75 | { 76 | // Return number of seconds elapsed since time 77 | RNTime tm; tm.Read(); 78 | return tm.Elapsed(*this); 79 | } 80 | 81 | 82 | 83 | RNTime 84 | RNCurrentTime(void) 85 | { 86 | RNTime tm; 87 | tm.Read(); 88 | return tm; 89 | } 90 | 91 | 92 | 93 | 94 | #if (RN_OS != RN_WINDOWS) 95 | # include 96 | #endif 97 | 98 | void 99 | RNSleep(RNScalar seconds) 100 | { 101 | #if (RN_OS == RN_IRIX) 102 | sginap((long) (seconds * CLK_TCK)); 103 | #elif (RN_OS == RN_WINDOWS) 104 | Sleep((unsigned long) (1000 * seconds)); 105 | #elif (RN_OS == RN_LINUX) 106 | usleep((unsigned long) (1000000 * seconds)); 107 | #else 108 | RNAbort("Not implemented"); 109 | #endif 110 | } 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNTime.h: -------------------------------------------------------------------------------- 1 | /* Include file for GAPS wallclock time class */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int RNInitTime(); 8 | void RNStopTime(); 9 | 10 | 11 | 12 | /* Class definition */ 13 | 14 | class RNTime /* : public RNBase */ { 15 | public: 16 | // Constructor functions 17 | RNTime(void); 18 | RNTime(const RNTime& tm); 19 | 20 | // Relationship functions/operators 21 | RNScalar Elapsed(const RNTime& tm) const; 22 | RNScalar Elapsed(void) const; 23 | 24 | // Arithmetic operators 25 | RNScalar operator-(const RNTime& tm) const; 26 | 27 | // Manipulation functions/operators 28 | void Read(void); 29 | 30 | private: 31 | # if (RN_OS == RN_WINDOWS) 32 | LARGE_INTEGER timefreq; 33 | LARGE_INTEGER timevalue; 34 | # elif (RN_OS == OLD_RN_WINDOWS) 35 | DWORD timevalue; 36 | # else 37 | struct timeval timevalue; 38 | # endif 39 | }; 40 | 41 | 42 | 43 | /* Public functions */ 44 | 45 | RNTime RNCurrentTime(void); 46 | void RNSleep(RNScalar seconds); 47 | 48 | 49 | 50 | /* Inline functions */ 51 | 52 | inline void RNTime:: 53 | Read (void) 54 | { 55 | /* Read the current time */ 56 | # if (RN_OS == RN_WINDOWS) 57 | QueryPerformanceCounter(&timevalue); 58 | # elif (RN_OS == OLD_RN_WINDOWS) 59 | timevalue = GetTickCount(); 60 | # else 61 | gettimeofday(&timevalue, NULL); 62 | # endif 63 | } 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNType.cpp: -------------------------------------------------------------------------------- 1 | /* Source file for GAPS class types */ 2 | 3 | 4 | 5 | /* Include files */ 6 | 7 | #include "RNBasics.h" 8 | 9 | 10 | 11 | /* Public variables */ 12 | 13 | const RNClassType RNnull_class_type(RN_NULL_CLASS_ID, ""); 14 | 15 | 16 | 17 | /* Private variables */ 18 | 19 | static RNClassID RNnclass_ids = 0; 20 | 21 | 22 | 23 | int RNInitClassType() 24 | { 25 | /* Return OK status */ 26 | return TRUE; 27 | } 28 | 29 | 30 | 31 | void RNStopClassType() 32 | { 33 | } 34 | 35 | 36 | 37 | RNClassType:: 38 | RNClassType(RNClassID id, const char *name) 39 | { 40 | // Initialize class type 41 | this->id = id; 42 | if (!name) this->name = NULL; 43 | else { 44 | this->name = new char[strlen(name) + 1]; 45 | assert(this->name); 46 | strcpy(this->name, name); 47 | } 48 | } 49 | 50 | 51 | 52 | RNClassType:: 53 | RNClassType(const char *name) 54 | { 55 | // Initialize class type 56 | id = ++RNnclass_ids; 57 | if (!name) this->name = NULL; 58 | else { 59 | this->name = new char[strlen(name) + 1]; 60 | assert(this->name); 61 | strcpy(this->name, name); 62 | } 63 | } 64 | 65 | 66 | 67 | RNClassType:: 68 | ~RNClassType(void) 69 | { 70 | // Free name 71 | if (name) delete [] name; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /gaps/pkgs/RNBasics/RNType.h: -------------------------------------------------------------------------------- 1 | /* Include file GAPS class type identifier */ 2 | 3 | 4 | 5 | /* Initialization functions */ 6 | 7 | int RNInitClassType(); 8 | void RNStopClassType(); 9 | 10 | 11 | 12 | /* Type definitions */ 13 | 14 | typedef int RNClassID; 15 | 16 | 17 | 18 | /* Class definition */ 19 | 20 | class RNClassType { 21 | public: 22 | // Constructor functions 23 | RNClassType(RNClassID id, const char *name); 24 | RNClassType(const char *name); 25 | ~RNClassType(void); 26 | 27 | // Property functions 28 | const RNClassID ID(void) const; 29 | const char *Name(void) const; 30 | 31 | private: 32 | RNClassID id; 33 | char *name; 34 | }; 35 | 36 | 37 | 38 | /* Public constants */ 39 | 40 | #define RN_UNKNOWN_CLASS_ID (-1) 41 | #define RN_NULL_CLASS_ID (0) 42 | 43 | 44 | 45 | /* Public variables */ 46 | 47 | extern const RNClassType RNnull_class_type; 48 | 49 | 50 | 51 | /* Useful macros */ 52 | 53 | #define RN_CLASS_TYPE_DECLARATIONS(__class) \ 54 | virtual const RNClassID ClassID(void) const; \ 55 | virtual const char *ClassName(void) const; \ 56 | virtual const RNClassType& ClassType(void) const; \ 57 | static const RNClassID CLASS_ID(void); \ 58 | static const char * CLASS_NAME(void); \ 59 | static const RNClassType& CLASS_TYPE(void) 60 | 61 | #define RN_CLASS_TYPE_DEFINITIONS(__class) \ 62 | const RNClassType __class ## _class_type ( #__class ); \ 63 | const RNClassID __class::ClassID(void) const { return CLASS_ID(); } \ 64 | const char *__class::ClassName(void) const { return CLASS_NAME(); } \ 65 | const RNClassType& __class::ClassType(void) const { return CLASS_TYPE(); } \ 66 | const RNClassID __class::CLASS_ID(void) { return CLASS_TYPE().ID(); } \ 67 | const char * __class::CLASS_NAME(void) { return CLASS_TYPE().Name(); } \ 68 | const RNClassType& __class::CLASS_TYPE(void) { return __class ## _class_type; } 69 | 70 | 71 | 72 | 73 | /* Inline functions */ 74 | 75 | inline const RNClassID RNClassType:: 76 | ID(void) const 77 | { 78 | // Return class id 79 | return id; 80 | } 81 | 82 | 83 | 84 | inline const char *RNClassType:: 85 | Name(void) const 86 | { 87 | // Return class name 88 | return name; 89 | } 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/AUTHORS: -------------------------------------------------------------------------------- 1 | Pawel W. Olszta 2 | the person to be blamed for freeglut 3 | 4 | Andreas Umbach 5 | the first person to contribute to the freeglut project, 6 | contributed the cube and sphere geometry code 7 | 8 | Steve Baker 9 | joystick code (from his great PLIB), numerous hints 10 | tips on the freeglut usability 11 | and for taking the project over when Pawel bowed out 12 | 13 | Christopher John Purnell 14 | Don Heyse 15 | Dave McClurg 16 | John F. Fay 17 | Norman Vine 18 | Daniel Wagner 19 | Sven Panne 20 | contributing the project, using the product, and generally keeping it going 21 | 22 | Brian Paul 23 | Eric Sandall 24 | giving us the oomph! to make an official release 25 | 26 | James 'J.C.' Jones 27 | designing the new website 28 | 29 | ...and all the opengl-gamedev-l people that made Pawel start this project :) 30 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for freeglut library 3 | # 4 | 5 | 6 | 7 | # 8 | # Package name and list of source files. 9 | # 10 | 11 | NAME=fglut 12 | FGLUT_CSRCS = \ 13 | freeglut_callbacks.c \ 14 | freeglut_cursor.c \ 15 | freeglut_display.c \ 16 | freeglut_ext.c \ 17 | freeglut_font.c \ 18 | freeglut_glutfont_definitions.c \ 19 | freeglut_font_data.c \ 20 | freeglut_stroke_roman.c \ 21 | freeglut_stroke_mono_roman.c \ 22 | freeglut_gamemode.c \ 23 | freeglut_geometry.c \ 24 | freeglut_init.c \ 25 | freeglut_input_devices.c \ 26 | freeglut_spaceball.c \ 27 | freeglut_joystick.c \ 28 | freeglut_main.c \ 29 | freeglut_menu.c \ 30 | freeglut_misc.c \ 31 | freeglut_overlay.c \ 32 | freeglut_state.c \ 33 | freeglut_structure.c \ 34 | freeglut_teapot.c \ 35 | freeglut_videoresize.c \ 36 | freeglut_window.c 37 | 38 | ifeq ("$(shell uname -s)", "Darwin") 39 | CSRCS = $(NAME).c 40 | else 41 | CSRCS=$(FGLUT_CSRCS) 42 | endif 43 | 44 | 45 | 46 | # 47 | # R3 library makefile 48 | # 49 | 50 | include ../../makefiles/Makefile.pkgs 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/README: -------------------------------------------------------------------------------- 1 | 2 | BRIEF OVERVIEW 3 | ============== 4 | 5 | This is the freeglut package. 6 | 7 | Freeglut, the Free openGL Utility Toolkit, is meant to be a free alter- 8 | native to Mark Kilgard's GLUT library. It is distributed under an X-Consor- 9 | tium style license (see COPYING for details), to offer you a chance to use 10 | and/or modify the source. 11 | 12 | It makes use of OpenGL, GLU, and pthreads-win32 libraries. The library does 13 | not make use of any GLUT code and is not 100% compatible. Code recompilation 14 | and/or slight modifications might be required for your applications to work 15 | with freeglut. 16 | 17 | 18 | PORTS 19 | ===== 20 | 21 | Both X11 and Win32 ports are in an advanced alpha stage, which means that 22 | they provide limited functionality of GLUT API 3. There is an investigation 23 | en course to check if the BeOS port could be easily done using the current 24 | freeglut structure. 25 | 26 | 27 | INSTALLATION 28 | ============ 29 | 30 | Use the following commands to build from scratch on a *nix X11 platform: 31 | 32 | ./autogen.sh 33 | ./configure 34 | make 35 | 36 | The first command is only needed after a fresh checkout, a source distribution 37 | already contains all necessary files for the last two steps. 38 | 39 | 40 | CONTRIBUTING 41 | ============ 42 | 43 | Bug and missing features patches are certainly welcome. Just as comments 44 | and FREEGLUT API 1 propositions are. 45 | 46 | Just please to make the fixes look visually just as the rest of the code 47 | does (tabs converted 4 white spaces). Comments are really welcome, as I 48 | believe it would be nice for people fresh new to OpenGL see how the things 49 | are done... 50 | 51 | 52 | WEB SITE AND CONTACTING THE AUTHOR 53 | ================================== 54 | 55 | Freeglut project has moved to the SourceForge: 56 | http://freeglut.sourceforge.net 57 | 58 | 59 | THE HOPE 60 | ======== 61 | 62 | Hope you find my work somehow useful. 63 | Pawel W. Olszta, 64 | 65 | 66 | PASSING THE BATON 67 | ================= 68 | 69 | In late December 2000, Pawel decided that he no longer 70 | wished to maintain freeglut because he has moved out of 71 | the graphics field. I volunteered to take over from him 72 | and have been running the project since Jan 13th 2001. 73 | 74 | I'm also the author and maintainer of the PLIB library suite 75 | and 'freeglut' really fits in well with that work. 76 | 77 | I just hope I can live up to Pawel's high standards. Pawel 78 | remains on the active developers list. 79 | 80 | Steve Baker 81 | http://plib.sourceforge.net 82 | 83 | 84 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/fglut.c: -------------------------------------------------------------------------------- 1 | // Source file for fglut package stand-in 2 | 3 | 4 | 5 | // These are never used. They are just dummy functions 6 | // to compile and link when the native glut is used, and 7 | // thus the rest of the code in the fglut package is not 8 | // compiled 9 | 10 | 11 | 12 | int R3InitGlut(void) 13 | { 14 | // return OK status 15 | return 1; 16 | } 17 | 18 | 19 | 20 | void R3StopGlut(void) 21 | { 22 | } 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/fglut.h: -------------------------------------------------------------------------------- 1 | // OpenGL GLUT include file 2 | 3 | 4 | // External include files 5 | 6 | #ifdef __APPLE__ 7 | // Use the native glut on mac 8 | # include "GLUT/glut.h" 9 | #else 10 | // Use this implementation 11 | # include "fglut/glut.h" 12 | #endif 13 | 14 | 15 | 16 | /* Initialization functions */ 17 | 18 | int R3InitGlut(void); 19 | void R3StopGlut(void); 20 | 21 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/fglut.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fglut", "fglut.vcxproj", "{245FD70C-6B13-4581-B674-838551C69144}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {245FD70C-6B13-4581-B674-838551C69144}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {245FD70C-6B13-4581-B674-838551C69144}.Debug|Win32.Build.0 = Debug|Win32 14 | {245FD70C-6B13-4581-B674-838551C69144}.Release|Win32.ActiveCfg = Release|Win32 15 | {245FD70C-6B13-4581-B674-838551C69144}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/freeglut.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREEGLUT_H__ 2 | #define __FREEGLUT_H__ 3 | 4 | /* 5 | * freeglut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | #include "freeglut_ext.h" 19 | 20 | /*** END OF FILE ***/ 21 | 22 | #endif /* __FREEGLUT_H__ */ 23 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/freeglut_overlay.c: -------------------------------------------------------------------------------- 1 | /* 2 | * freeglut_overlay.c 3 | * 4 | * Overlay management functions (as defined by GLUT API) 5 | * 6 | * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. 7 | * Written by Pawel W. Olszta, 8 | * Creation date: Thu Dec 16 1999 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a 11 | * copy of this software and associated documentation files (the "Software"), 12 | * to deal in the Software without restriction, including without limitation 13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 | * and/or sell copies of the Software, and to permit persons to whom the 15 | * Software is furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included 18 | * in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 24 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | #include "freeglut.h" 29 | #include "freeglut_internal.h" 30 | 31 | /* 32 | * NOTE: functions declared in this file probably will not be implemented. 33 | */ 34 | 35 | /* -- INTERFACE FUNCTIONS -------------------------------------------------- */ 36 | 37 | void FGAPIENTRY glutEstablishOverlay( void ) { /* Not implemented */ } 38 | void FGAPIENTRY glutRemoveOverlay( void ) { /* Not implemented */ } 39 | void FGAPIENTRY glutUseLayer( GLenum layer ) { /* Not implemented */ } 40 | void FGAPIENTRY glutPostOverlayRedisplay( void ) { /* Not implemented */ } 41 | void FGAPIENTRY glutPostWindowOverlayRedisplay( int ID ) { /* Not implemented */ } 42 | void FGAPIENTRY glutShowOverlay( void ) { /* Not implemented */ } 43 | void FGAPIENTRY glutHideOverlay( void ) { /* Not implemented */ } 44 | 45 | /*** END OF FILE ***/ 46 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/freeglut_videoresize.c: -------------------------------------------------------------------------------- 1 | /* 2 | * freeglut_videoresize.c 3 | * 4 | * Video resize functions (as defined by GLUT API) 5 | * 6 | * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. 7 | * Written by Pawel W. Olszta, 8 | * Creation date: Thu Dec 16 1999 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a 11 | * copy of this software and associated documentation files (the "Software"), 12 | * to deal in the Software without restriction, including without limitation 13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 | * and/or sell copies of the Software, and to permit persons to whom the 15 | * Software is furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included 18 | * in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 24 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | #include "freeglut.h" 29 | #include "freeglut_internal.h" 30 | 31 | /* 32 | * NOTE: functions declared in this file probably will not be implemented. 33 | */ 34 | 35 | /* -- INTERFACE FUNCTIONS -------------------------------------------------- */ 36 | 37 | int FGAPIENTRY glutVideoResizeGet( GLenum eWhat ) { return( 0x00 ); } 38 | void FGAPIENTRY glutSetupVideoResizing( void ) { /* Not implemented */ } 39 | void FGAPIENTRY glutStopVideoResizing( void ) { /* Not implemented */ } 40 | void FGAPIENTRY glutVideoResize( int x, int y, int w, int h ) { /* Not implemented */ } 41 | void FGAPIENTRY glutVideoPan( int x, int y, int w, int h ) { /* Not implemented */ } 42 | 43 | /*** END OF FILE ***/ 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /gaps/pkgs/fglut/glut.h: -------------------------------------------------------------------------------- 1 | #ifndef __GLUT_H__ 2 | #define __GLUT_H__ 3 | 4 | /* 5 | * glut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | 19 | /*** END OF FILE ***/ 20 | 21 | #endif /* __GLUT_H__ */ 22 | -------------------------------------------------------------------------------- /gaps/pkgs/gaps.h: -------------------------------------------------------------------------------- 1 | // Include file for gaps packages 2 | 3 | #ifndef __GAPS__H__ 4 | #define __GAPS__H__ 5 | 6 | 7 | // Include all packages 8 | 9 | #include "RNBasics/RNBasics.h" 10 | #include "R2Shapes/R2Shapes.h" 11 | #include "R3Shapes/R3Shapes.h" 12 | #include "R3Graphics/R3Graphics.h" 13 | 14 | 15 | #endif 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /gaps/pkgs/jpeg/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Package name 3 | # 4 | 5 | NAME=jpeg 6 | 7 | 8 | 9 | # 10 | # List of source files 11 | # 12 | 13 | # library object files common to compression and decompression 14 | COMSRCS= jcomapi.c jutils.c jerror.c jmemmgr.c jmemnobs.c 15 | 16 | # compression library object files 17 | CLIBSRCS= jcapimin.c jcapistd.c jctrans.c jcparam.c \ 18 | jdatadst.c jcinit.c jcmaster.c jcmarker.c jcmainct.c \ 19 | jcprepct.c jccoefct.c jccolor.c jcsample.c jchuff.c \ 20 | jcphuff.c jcdctmgr.c jfdctfst.c jfdctflt.c \ 21 | jfdctint.c 22 | 23 | # decompression library object files 24 | DLIBSRCS= jdapimin.c jdapistd.c jdtrans.c jdatasrc.c \ 25 | jdmaster.c jdinput.c jdmarker.c jdhuff.c jdphuff.c \ 26 | jdmainct.c jdcoefct.c jdpostct.c jddctmgr.c \ 27 | jidctfst.c jidctflt.c jidctint.c jidctred.c \ 28 | jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c 29 | 30 | # JPEG library source files 31 | CSRCS=$(CLIBSRCS) $(DLIBSRCS) $(COMSRCS) 32 | 33 | 34 | 35 | # 36 | # GAPS library makefile 37 | # 38 | 39 | include ../../makefiles/Makefile.pkgs 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /gaps/pkgs/jpeg/jchuff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jchuff.h 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains declarations for Huffman entropy encoding routines 9 | * that are shared between the sequential encoder (jchuff.c) and the 10 | * progressive encoder (jcphuff.c). No other modules need to see these. 11 | */ 12 | 13 | /* The legal range of a DCT coefficient is 14 | * -1024 .. +1023 for 8-bit data; 15 | * -16384 .. +16383 for 12-bit data. 16 | * Hence the magnitude should always fit in 10 or 14 bits respectively. 17 | */ 18 | 19 | #if BITS_IN_JSAMPLE == 8 20 | #define MAX_COEF_BITS 10 21 | #else 22 | #define MAX_COEF_BITS 14 23 | #endif 24 | 25 | /* Derived data constructed for each Huffman table */ 26 | 27 | typedef struct { 28 | unsigned int ehufco[256]; /* code for each symbol */ 29 | char ehufsi[256]; /* length of code for each symbol */ 30 | /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ 31 | } c_derived_tbl; 32 | 33 | /* Short forms of external names for systems with brain-damaged linkers. */ 34 | 35 | #ifdef NEED_SHORT_EXTERNAL_NAMES 36 | #define jpeg_make_c_derived_tbl jMkCDerived 37 | #define jpeg_gen_optimal_table jGenOptTbl 38 | #endif /* NEED_SHORT_EXTERNAL_NAMES */ 39 | 40 | /* Expand a Huffman table definition into the derived format */ 41 | EXTERN(void) jpeg_make_c_derived_tbl 42 | JPP((j_compress_ptr cinfo, jboolean isDC, int tblno, 43 | c_derived_tbl ** pdtbl)); 44 | 45 | /* Generate an optimal table definition given the specified counts */ 46 | EXTERN(void) jpeg_gen_optimal_table 47 | JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); 48 | -------------------------------------------------------------------------------- /gaps/pkgs/jpeg/jcinit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jcinit.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains initialization logic for the JPEG compressor. 9 | * This routine is in charge of selecting the modules to be executed and 10 | * making an initialization call to each one. 11 | * 12 | * Logically, this code belongs in jcmaster.c. It's split out because 13 | * linking this routine implies linking the entire compression library. 14 | * For a transcoding-only application, we want to be able to use jcmaster.c 15 | * without linking in the whole library. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | 22 | 23 | /* 24 | * Master selection of compression modules. 25 | * This is done once at the start of processing an image. We determine 26 | * which modules will be used and give them appropriate initialization calls. 27 | */ 28 | 29 | GLOBAL(void) 30 | jinit_compress_master (j_compress_ptr cinfo) 31 | { 32 | /* Initialize master control (includes parameter checking/processing) */ 33 | jinit_c_master_control(cinfo, FALSE /* full compression */); 34 | 35 | /* Preprocessing */ 36 | if (! cinfo->raw_data_in) { 37 | jinit_color_converter(cinfo); 38 | jinit_downsampler(cinfo); 39 | jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); 40 | } 41 | /* Forward DCT */ 42 | jinit_forward_dct(cinfo); 43 | /* Entropy encoding: either Huffman or arithmetic coding. */ 44 | if (cinfo->arith_code) { 45 | ERREXIT(cinfo, JERR_ARITH_NOTIMPL); 46 | } else { 47 | if (cinfo->progressive_mode) { 48 | #ifdef C_PROGRESSIVE_SUPPORTED 49 | jinit_phuff_encoder(cinfo); 50 | #else 51 | ERREXIT(cinfo, JERR_NOT_COMPILED); 52 | #endif 53 | } else 54 | jinit_huff_encoder(cinfo); 55 | } 56 | 57 | /* Need a full-image coefficient buffer in any multi-pass mode. */ 58 | jinit_c_coef_controller(cinfo, 59 | (jboolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); 60 | jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); 61 | 62 | jinit_marker_writer(cinfo); 63 | 64 | /* We can now tell the memory manager to allocate virtual arrays. */ 65 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); 66 | 67 | /* Write the datastream header (SOI) immediately. 68 | * Frame and scan headers are postponed till later. 69 | * This lets application insert special markers after the SOI. 70 | */ 71 | (*cinfo->marker->write_file_header) (cinfo); 72 | } 73 | -------------------------------------------------------------------------------- /gaps/pkgs/jpeg/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.h. Generated automatically by configure. */ 2 | /* jconfig.cfg --- source file edited by configure script */ 3 | /* see jconfig.doc for explanations */ 4 | 5 | #define HAVE_PROTOTYPES 6 | #define HAVE_UNSIGNED_CHAR 7 | #define HAVE_UNSIGNED_SHORT 8 | #undef void 9 | #undef const 10 | #undef CHAR_IS_UNSIGNED 11 | #define HAVE_STDDEF_H 12 | #define HAVE_STDLIB_H 13 | #undef NEED_BSD_STRINGS 14 | #undef NEED_SYS_TYPES_H 15 | #undef NEED_FAR_POINTERS 16 | #undef NEED_SHORT_EXTERNAL_NAMES 17 | #undef INCOMPLETE_TYPES_BROKEN 18 | 19 | -------------------------------------------------------------------------------- /gaps/pkgs/jpeg/jmemnobs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jmemnobs.c 3 | * 4 | * Copyright (C) 1992-1996, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file provides a really simple implementation of the system- 9 | * dependent portion of the JPEG memory manager. This implementation 10 | * assumes that no backing-store files are needed: all required space 11 | * can be obtained from malloc(). 12 | * This is very portable in the sense that it'll compile on almost anything, 13 | * but you'd better have lots of main memory (or virtual memory) if you want 14 | * to process big images. 15 | * Note that the max_memory_to_use option is ignored by this implementation. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | #include "jmemsys.h" /* import the system-dependent declarations */ 22 | 23 | #ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ 24 | extern void * malloc JPP((size_t size)); 25 | extern void free JPP((void *ptr)); 26 | #endif 27 | 28 | 29 | /* 30 | * Memory allocation and freeing are controlled by the regular library 31 | * routines malloc() and free(). 32 | */ 33 | 34 | GLOBAL(void *) 35 | jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) 36 | { 37 | return (void *) malloc(sizeofobject); 38 | } 39 | 40 | GLOBAL(void) 41 | jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) 42 | { 43 | free(object); 44 | } 45 | 46 | 47 | /* 48 | * "Large" objects are treated the same as "small" ones. 49 | * NB: although we include FAR keywords in the routine declarations, 50 | * this file won't actually work in 80x86 small/medium model; at least, 51 | * you probably won't be able to process useful-size images in only 64KB. 52 | */ 53 | 54 | GLOBAL(void FAR *) 55 | jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) 56 | { 57 | return (void FAR *) malloc(sizeofobject); 58 | } 59 | 60 | GLOBAL(void) 61 | jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) 62 | { 63 | free(object); 64 | } 65 | 66 | 67 | /* 68 | * This routine computes the total memory space available for allocation. 69 | * Here we always say, "we got all you want bud!" 70 | */ 71 | 72 | GLOBAL(long) 73 | jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, 74 | long max_bytes_needed, long already_allocated) 75 | { 76 | return max_bytes_needed; 77 | } 78 | 79 | 80 | /* 81 | * Backing store (temporary file) management. 82 | * Since jpeg_mem_available always promised the moon, 83 | * this should never be called and we can just error out. 84 | */ 85 | 86 | GLOBAL(void) 87 | jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, 88 | long total_bytes_needed) 89 | { 90 | ERREXIT(cinfo, JERR_NO_BACKING_STORE); 91 | } 92 | 93 | 94 | /* 95 | * These routines take care of any system-dependent initialization and 96 | * cleanup required. Here, there isn't any. 97 | */ 98 | 99 | GLOBAL(long) 100 | jpeg_mem_init (j_common_ptr cinfo) 101 | { 102 | return 0; /* just set max_memory_to_use to 0 */ 103 | } 104 | 105 | GLOBAL(void) 106 | jpeg_mem_term (j_common_ptr cinfo) 107 | { 108 | /* no work */ 109 | } 110 | -------------------------------------------------------------------------------- /gaps/pkgs/jpeg/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-1998, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "6b 27-Mar-1998" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" 15 | -------------------------------------------------------------------------------- /gaps/pkgs/png/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Package name 3 | # 4 | 5 | NAME=png 6 | 7 | 8 | 9 | # 10 | # List of source files 11 | # 12 | 13 | # JPEG library source files 14 | PNG_CSRCS = \ 15 | png.c \ 16 | pngset.c \ 17 | pngget.c \ 18 | pngrutil.c \ 19 | pngtrans.c \ 20 | pngwutil.c \ 21 | pngread.c \ 22 | pngrio.c \ 23 | pngwio.c \ 24 | pngwrite.c \ 25 | pngrtran.c \ 26 | pngwtran.c \ 27 | pngmem.c \ 28 | pngerror.c \ 29 | pngpread.c 30 | 31 | ZLIB_CSRCS = \ 32 | adler32.c \ 33 | compress.c \ 34 | crc32.c \ 35 | deflate.c \ 36 | gzclose.c \ 37 | gzlib.c \ 38 | gzread.c \ 39 | gzwrite.c \ 40 | infback.c \ 41 | inffast.c \ 42 | inflate.c \ 43 | inftrees.c \ 44 | trees.c \ 45 | uncompr.c \ 46 | zutil.c 47 | 48 | CSRCS = $(PNG_CSRCS) $(ZLIB_CSRCS) 49 | 50 | 51 | 52 | # 53 | # GAPS library makefile 54 | # 55 | 56 | include ../../makefiles/Makefile.pkgs 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /gaps/pkgs/png/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 79 | (sourceLen >> 25) + 13; 80 | } 81 | -------------------------------------------------------------------------------- /gaps/pkgs/png/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the header file. */ 5 | #define HAVE_DLFCN_H 1 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #define HAVE_INTTYPES_H 1 9 | 10 | /* Define to 1 if you have the `m' library (-lm). */ 11 | /* #undef HAVE_LIBM */ 12 | 13 | /* Define to 1 if you have the `z' library (-lz). */ 14 | #define HAVE_LIBZ 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_MALLOC_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #define HAVE_MEMORY_H 1 21 | 22 | /* Define to 1 if you have the `memset' function. */ 23 | #define HAVE_MEMSET 1 24 | 25 | /* Define to 1 if you have the `pow' function. */ 26 | #define HAVE_POW 1 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_STDINT_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_STDLIB_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_STRINGS_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_STRING_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_SYS_STAT_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_SYS_TYPES_H 1 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_UNISTD_H 1 48 | 49 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 50 | */ 51 | #define LT_OBJDIR ".libs/" 52 | 53 | /* Name of package */ 54 | #define PACKAGE "libpng" 55 | 56 | /* Define to the address where bug reports for this package should be sent. */ 57 | #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" 58 | 59 | /* Define to the full name of this package. */ 60 | #define PACKAGE_NAME "libpng" 61 | 62 | /* Define to the full name and version of this package. */ 63 | #define PACKAGE_STRING "libpng 1.4.4" 64 | 65 | /* Define to the one symbol short name of this package. */ 66 | #define PACKAGE_TARNAME "libpng" 67 | 68 | /* Define to the home page for this package. */ 69 | #define PACKAGE_URL "" 70 | 71 | /* Define to the version of this package. */ 72 | #define PACKAGE_VERSION "1.4.4" 73 | 74 | /* Define to 1 if you have the ANSI C header files. */ 75 | #define STDC_HEADERS 1 76 | 77 | /* Define to 1 if your declares `struct tm'. */ 78 | /* #undef TM_IN_SYS_TIME */ 79 | 80 | /* Version number of package */ 81 | #define VERSION "1.4.4" 82 | 83 | /* Define to empty if `const' does not conform to ANSI C. */ 84 | /* #undef const */ 85 | 86 | /* Define to `unsigned int' if does not define. */ 87 | /* #undef size_t */ 88 | -------------------------------------------------------------------------------- /gaps/pkgs/png/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /gaps/pkgs/png/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /gaps/pkgs/png/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /gaps/pkgs/png/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (Bytef*)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /gaps/vc/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for GAPS visual studio release 3 | # 4 | 5 | 6 | # 7 | # Set up options, etc. 8 | # 9 | 10 | RELEASE_DIR=../release 11 | 12 | 13 | 14 | # 15 | # Make targets 16 | # 17 | 18 | opt: 19 | 20 | debug: 21 | 22 | release: 23 | mkdir -p $(RELEASE_DIR)/vc 24 | cp vc.sln $(RELEASE_DIR)/vc 25 | cp -r glut $(RELEASE_DIR)/vc 26 | mkdir -p $(RELEASE_DIR)/bin 27 | mkdir -p $(RELEASE_DIR)/lib 28 | mkdir -p $(RELEASE_DIR)/bin/win32 29 | mkdir -p $(RELEASE_DIR)/lib/win32 30 | cp glut/glut32.dll $(RELEASE_DIR)/bin/win32 31 | cp glut/glut32.lib $(RELEASE_DIR)/lib/win32 32 | cp Makefile $(RELEASE_DIR)/vc 33 | cp README.txt $(RELEASE_DIR)/vc 34 | 35 | clean: 36 | - rm -f -r Debug Release ../bin/win32/*.exe ../bin/win32/*.ilk ../bin/win32/*.pdb ../lib/win32/*.lib vc.ncb vc.suo vc.sdf *~ 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /gaps/vc/README.txt: -------------------------------------------------------------------------------- 1 | To compile, you should be able to open vc.sln and "Rebuild Solution. 2 | 3 | ------------------------------------------------------------------------ 4 | 5 | This file contains notes about settings made when creating the vc.sln file. 6 | 7 | All: 8 | General: Output Directory = $(SolutionDir)/$(ConfigurationName)/$(ProjectName) 9 | General: Intermediate Directory = $(SolutionDir)/$(ConfigurationName)/$(ProjectName) 10 | Input: Additional Dependencies = R3Graphics.lib R3Shapes.lib R2Shapes.lib RNBasics.lib jpeg.lib glut32.lib glu32.lib opengl32.lib 11 | C/C++: General: Additional Include Directories = ../../pkgs 12 | C/C++: Advanced: Comple as C++ Code (Set TP explicitly) --- except jpeg, png, fglut 13 | C/C++: Advanced: Disable Specific warnings 4244, 4267, 4996 14 | 15 | For pkgs: 16 | Librarian: General: Output File = ../../lib/win32/${ProjectName}.lib 17 | 18 | For apps: 19 | Linker: General:Additional Library Directories = ../../lib/win32 20 | Linker: General: Output file = ../../bin/win32/$(ProjectName).exe 21 | -------------------------------------------------------------------------------- /gaps/vc/glut/glut.def: -------------------------------------------------------------------------------- 1 | DESCRIPTION 'OpenGL Utility Toolkit for Win32' 2 | 3 | VERSION 3.7 4 | 5 | EXPORTS 6 | 7 | glutAddMenuEntry 8 | glutAddSubMenu 9 | glutAttachMenu 10 | glutBitmapCharacter 11 | glutBitmapLength 12 | glutBitmapWidth 13 | glutButtonBoxFunc 14 | glutChangeToMenuEntry 15 | glutChangeToSubMenu 16 | glutCopyColormap 17 | glutCreateMenu 18 | __glutCreateMenuWithExit 19 | glutCreateSubWindow 20 | glutCreateWindow 21 | __glutCreateWindowWithExit 22 | glutDestroyMenu 23 | glutDestroyWindow 24 | glutDetachMenu 25 | glutDeviceGet 26 | glutDialsFunc 27 | glutDisplayFunc 28 | glutEnterGameMode 29 | glutEntryFunc 30 | glutEstablishOverlay 31 | glutExtensionSupported 32 | glutForceJoystickFunc 33 | glutFullScreen 34 | glutGameModeGet 35 | glutGameModeString 36 | glutGet 37 | glutGetColor 38 | glutGetMenu 39 | glutGetModifiers 40 | glutGetWindow 41 | glutHideOverlay 42 | glutHideWindow 43 | glutIconifyWindow 44 | glutIdleFunc 45 | glutIgnoreKeyRepeat 46 | glutInit 47 | __glutInitWithExit 48 | glutInitDisplayMode 49 | glutInitDisplayString 50 | glutInitWindowPosition 51 | glutInitWindowSize 52 | glutJoystickFunc 53 | glutKeyboardFunc 54 | glutKeyboardUpFunc 55 | glutLayerGet 56 | glutLeaveGameMode 57 | glutMainLoop 58 | glutMenuStateFunc 59 | glutMenuStatusFunc 60 | glutMotionFunc 61 | glutMouseFunc 62 | glutOverlayDisplayFunc 63 | glutPassiveMotionFunc 64 | glutPopWindow 65 | glutPositionWindow 66 | glutPostOverlayRedisplay 67 | glutPostRedisplay 68 | glutPostWindowOverlayRedisplay 69 | glutPostWindowRedisplay 70 | glutPushWindow 71 | glutRemoveMenuItem 72 | glutRemoveOverlay 73 | glutReportErrors 74 | glutReshapeFunc 75 | glutReshapeWindow 76 | glutSetColor 77 | glutSetCursor 78 | glutSetIconTitle 79 | glutSetKeyRepeat 80 | glutSetMenu 81 | glutSetWindow 82 | glutSetWindowTitle 83 | glutSetupVideoResizing 84 | glutShowOverlay 85 | glutShowWindow 86 | glutSolidCone 87 | glutSolidCube 88 | glutSolidDodecahedron 89 | glutSolidIcosahedron 90 | glutSolidOctahedron 91 | glutSolidSphere 92 | glutSolidTeapot 93 | glutSolidTetrahedron 94 | glutSolidTorus 95 | glutSpaceballButtonFunc 96 | glutSpaceballMotionFunc 97 | glutSpaceballRotateFunc 98 | glutSpecialFunc 99 | glutSpecialUpFunc 100 | glutStopVideoResizing 101 | glutStrokeCharacter 102 | glutStrokeLength 103 | glutStrokeWidth 104 | glutSwapBuffers 105 | glutTabletButtonFunc 106 | glutTabletMotionFunc 107 | glutTimerFunc 108 | glutUseLayer 109 | glutVideoPan 110 | glutVideoResize 111 | glutVideoResizeGet 112 | glutVisibilityFunc 113 | glutWarpPointer 114 | glutWindowStatusFunc 115 | glutWireCone 116 | glutWireCube 117 | glutWireDodecahedron 118 | glutWireIcosahedron 119 | glutWireOctahedron 120 | glutWireSphere 121 | glutWireTeapot 122 | glutWireTetrahedron 123 | glutWireTorus 124 | ; __glutSetFCB 125 | ; __glutGetFCB 126 | 127 | -------------------------------------------------------------------------------- /gaps/vc/glut/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinytangent/SUNCGtoolbox/4322dcf88c6ac82ef7471e76eea5ebd9db4e4f04/gaps/vc/glut/glut32.dll -------------------------------------------------------------------------------- /gaps/vc/glut/glut32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinytangent/SUNCGtoolbox/4322dcf88c6ac82ef7471e76eea5ebd9db4e4f04/gaps/vc/glut/glut32.lib -------------------------------------------------------------------------------- /gaps/vc/makefiles/Makefile.apps: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for GAPS applications 3 | # 4 | 5 | 6 | 7 | # 8 | # Before this Makefile is included ... 9 | # $(NAME) should be module name 10 | # $(CCSRCS) should list C++ source files 11 | # 12 | # For example ... 13 | # NAME=foo 14 | # CCSRCS=$(NAME).C \ 15 | # foo1.C foo2.C foo3.C 16 | # 17 | 18 | 19 | # 20 | # Set up compiler options, etc. 21 | # 22 | 23 | include ../../scripts/Makefile.std 24 | 25 | 26 | 27 | # 28 | # Set up target executable 29 | # 30 | 31 | EXE=$(EXE_DIR)/$(NAME).exe 32 | 33 | 34 | 35 | # 36 | # Set up link options 37 | # 38 | 39 | BASE_LDFLAGS=$(USER_LDFLAGS) /link /libpath:$(LIB_DIR) 40 | DEBUG_LDFLAGS=$(BASE_LDFLAGS) -Zi 41 | OPT_LDFLAGS=$(BASE_LDFLAGS) -Ox 42 | LDFLAGS=$(DEBUG_LDFLAGS) 43 | 44 | 45 | 46 | # 47 | # Set up libs 48 | # 49 | 50 | OPENGL_LIBS=glut32.lib glu32.lib opengl32.lib 51 | STD_LIBS =wsock32.lib user32.lib gdi32.lib advapi32.lib 52 | LIBS=$(USER_LIBS) $(PKG_LIBS) $(OPENGL_LIBS) $(STD_LIBS) 53 | 54 | 55 | 56 | # 57 | # Make targets 58 | # 59 | 60 | opt: 61 | $(MAKE) $(EXE) "CFLAGS=$(OPT_CFLAGS)" "LDFLAGS=$(OPT_LDFLAGS)" 62 | 63 | debug: 64 | $(MAKE) $(EXE) "CFLAGS=$(DEBUG_CFLAGS)" "LDFLAGS=$(DEBUG_LDFLAGS)" 65 | 66 | $(EXE): $(OBJS) $(LIBDIR) 67 | mkdir -p $(EXE_DIR) 68 | $(CC) -o $(EXE) $(OBJS) $(LDFLAGS) $(LIBS) 69 | 70 | release: 71 | mkdir -p $(RELEASE_DIR)/apps 72 | mkdir $(RELEASE_DIR)/apps/$(NAME)1 73 | cp *.[cCIh] $(RELEASE_DIR)/apps/$(NAME)1 74 | cp Makefile $(RELEASE_DIR)/apps/$(NAME)1 75 | rm -r -f $(RELEASE_DIR)/apps/$(NAME) 76 | mv $(RELEASE_DIR)/apps/$(NAME)1 $(RELEASE_DIR)/apps/$(NAME) 77 | 78 | clean: 79 | - rm -f *~ *.obj $(EXE) 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /gaps/vc/makefiles/Makefile.pkgs: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for GAPS packages 3 | # 4 | 5 | 6 | 7 | # 8 | # Before this Makefile is included ... 9 | # $(NAME) should be module name 10 | # $(CCSRCS) should list C++ source files 11 | # $(CSRCS) should list C source files 12 | # 13 | # For example ... 14 | # NAME=foo 15 | # CCSRCS=$(NAME).C \ 16 | # foo1.C foo2.C foo3.C 17 | # CSRCS=foo4.c foo5.c 18 | # 19 | 20 | 21 | # 22 | # Set up compiler options, etc. 23 | # 24 | 25 | include ../../scripts/Makefile.std 26 | 27 | 28 | 29 | # 30 | # Set up target name 31 | # 32 | 33 | LIB=${LIB_DIR}/$(NAME).lib 34 | 35 | 36 | 37 | # 38 | # Make targets 39 | # 40 | 41 | opt: 42 | $(MAKE) $(LIB) "CFLAGS=$(OPT_CFLAGS)" 43 | 44 | debug: 45 | $(MAKE) $(LIB) "CFLAGS=$(DEBUG_CFLAGS)" 46 | 47 | $(LIB): $(CCSRCS) $(CSRCS) $(OSRCS) $(OBJS) 48 | mkdir -p $(LIB_DIR) 49 | lib /OUT:$(LIB) $(OBJS) 50 | 51 | release: 52 | mkdir -p $(RELEASE_DIR)/pkgs 53 | mkdir $(RELEASE_DIR)/pkgs/$(NAME)1 54 | cp *.[cCIh] $(RELEASE_DIR)/pkgs/$(NAME)1 55 | cp Makefile $(RELEASE_DIR)/pkgs/$(NAME)1 56 | rm -r -f $(RELEASE_DIR)/pkgs/$(NAME) 57 | mv $(RELEASE_DIR)/pkgs/$(NAME)1 $(RELEASE_DIR)/pkgs/$(NAME) 58 | 59 | clean: 60 | - rm -f *~ *.obj $(LIB) 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /gaps/vc/makefiles/Makefile.std: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile setup for GAPS 3 | # 4 | 5 | 6 | 7 | # 8 | # Targets 9 | # 10 | 11 | OBJS=$(CCSRCS:.C=.obj) $(CCSRCS:.c=.obj) 12 | INCS=$(HSRCS) $(CCSRCS:.C=.h) 13 | 14 | 15 | 16 | # 17 | # C flags 18 | # 19 | 20 | CC=cl 21 | BASE_CFLAGS=$(USER_CFLAGS) /TP /W3 -I. -I../../pkgs 22 | DEBUG_CFLAGS=-Zi $(BASE_CFLAGS) 23 | OPT_CFLAGS=-Ox -DNDEBUG $(BASE_CFLAGS) 24 | CFLAGS=$(DEBUG_CFLAGS) 25 | 26 | 27 | 28 | # 29 | # Directories 30 | # 31 | 32 | RELEASE_DIR=../../release 33 | EXE_DIR=../../bin/win32 34 | LIB_DIR=../../lib/win32 35 | 36 | 37 | 38 | # 39 | # Default rules 40 | # 41 | 42 | .SUFFIXES: .c .C .obj 43 | 44 | .C.obj: 45 | $(CC) $(CFLAGS) -c $< 46 | 47 | .c.obj: 48 | $(CC) $(CFLAGS) -c $< 49 | 50 | 51 | --------------------------------------------------------------------------------