Просмотр исходного кода

Merge branch 'master' of github.com:libigl/libigl

Former-commit-id: 36418ed8b85ae685a4fb80aad6ca062b686a7afb
Alec Jacobson 9 лет назад
Родитель
Сommit
cc990a459b
100 измененных файлов с 2 добавлено и 11508 удалено
  1. 2 2
      README.md
  2. 0 20
      examples/Makefile
  3. 0 252
      examples/Makefile.conf
  4. 0 29
      examples/MatlabWorkspace/Makefile
  5. 0 13
      examples/MatlabWorkspace/README
  6. 0 32
      examples/MatlabWorkspace/example.cpp
  7. 0 7
      examples/MatlabWorkspace/example.dmat
  8. 0 21
      examples/ReAntTweakBar/Makefile
  9. 0 29
      examples/ReAntTweakBar/README
  10. 0 381
      examples/ReAntTweakBar/example.cpp
  11. 0 21
      examples/affine/Makefile
  12. 0 8
      examples/affine/README
  13. 0 33
      examples/affine/example.cpp
  14. 0 25
      examples/ambient-occlusion/Makefile
  15. 0 411
      examples/ambient-occlusion/example.cpp
  16. 0 24
      examples/arap/Makefile
  17. 0 750
      examples/arap/example.cpp
  18. 0 47
      examples/bbw/Makefile
  19. 0 112
      examples/bbw/README
  20. 0 272
      examples/bbw/example.cpp
  21. 0 19
      examples/bbw/examples/armadillo.bf
  22. 0 1
      examples/bbw/examples/armadillo.obj.REMOVED.git-id
  23. 0 36
      examples/bbw/examples/armadillo.tgf
  24. 0 1
      examples/bbw/examples/brick.obj.REMOVED.git-id
  25. 0 4
      examples/bbw/examples/brick.tgf
  26. 0 13
      examples/bbw/examples/gargoyle-skeleton-4-points.tgf
  27. 0 1
      examples/bbw/examples/gargoyle.obj.REMOVED.git-id
  28. 0 8
      examples/bbw/examples/toy.tgf
  29. 0 236
      examples/beach-balls/BeachBall.cpp
  30. 0 61
      examples/beach-balls/BeachBall.h
  31. 0 32
      examples/beach-balls/Makefile
  32. 0 272
      examples/beach-balls/example.cpp
  33. 0 32
      examples/camera/Makefile
  34. 0 697
      examples/camera/example.cpp
  35. 0 20
      examples/colored-mesh/Makefile
  36. 0 602
      examples/colored-mesh/example.cpp
  37. 0 33
      examples/components/Makefile
  38. 0 1095
      examples/components/example.cpp
  39. 0 21
      examples/convertmesh/Makefile
  40. 0 31
      examples/convertmesh/convertmesh.cpp
  41. 0 21
      examples/dmat/Makefile
  42. 0 22
      examples/dmat/README
  43. 0 18
      examples/dmat/example.cpp
  44. 0 7
      examples/dmat/example.dmat
  45. 0 21
      examples/eigen-gotchas/Makefile
  46. 0 227
      examples/eigen-gotchas/example.cpp
  47. 0 22
      examples/embree/Makefile
  48. 0 481
      examples/embree/example.cpp
  49. 0 21
      examples/file_contents_as_string/Makefile
  50. 0 14
      examples/file_contents_as_string/README
  51. 0 26
      examples/file_contents_as_string/example.cpp
  52. 0 32
      examples/flare-eyes/Makefile
  53. 0 739
      examples/flare-eyes/example.cpp
  54. 0 21
      examples/get_seconds/Makefile
  55. 0 20
      examples/get_seconds/README
  56. 0 24
      examples/get_seconds/example.cpp
  57. 0 23
      examples/glslversion/Makefile
  58. 0 15
      examples/glslversion/README
  59. 0 22
      examples/glslversion/example.cpp
  60. 0 24
      examples/glut_speed_test/Makefile
  61. 0 67
      examples/glut_speed_test/example.cpp
  62. 0 21
      examples/harwell_boeing/Makefile
  63. 0 2
      examples/harwell_boeing/README
  64. 0 45
      examples/harwell_boeing/example.cpp
  65. 0 22
      examples/hello-world/example.cpp
  66. 0 28
      examples/intersections/Makefile
  67. 0 8
      examples/intersections/README.md
  68. 0 705
      examples/intersections/example.cpp
  69. 0 21
      examples/is_dir/Makefile
  70. 0 18
      examples/is_dir/README
  71. 0 18
      examples/is_dir/example.cpp
  72. 0 21
      examples/marching_cubes/Makefile
  73. 0 73
      examples/marching_cubes/example.cpp
  74. 0 21
      examples/meshio/Makefile
  75. 0 9
      examples/meshio/README
  76. 0 33
      examples/meshio/cube.obj
  77. 0 65
      examples/meshio/example.cpp
  78. 0 88
      examples/meshio/torus.obj
  79. 0 21
      examples/mode/Makefile
  80. 0 9
      examples/mode/README
  81. 0 34
      examples/mode/example.cpp
  82. 0 23
      examples/multi-viewport/Makefile
  83. 0 544
      examples/multi-viewport/example.cpp
  84. 0 35
      examples/patches/Makefile
  85. 0 856
      examples/patches/example.cpp
  86. 0 20
      examples/patches/example.sln
  87. 0 150
      examples/patches/example.vcxproj
  88. 0 158
      examples/patches/example.vcxproj.filters
  89. 0 21
      examples/path_tests/Makefile
  90. 0 20
      examples/path_tests/README
  91. 0 26
      examples/path_tests/example.cpp
  92. 0 15
      examples/path_tests/example.php
  93. 0 21
      examples/pathinfo/Makefile
  94. 0 16
      examples/pathinfo/README
  95. 0 39
      examples/pathinfo/example.cpp
  96. 0 17
      examples/pathinfo/example.php
  97. 0 46
      examples/pathinfo/input.txt
  98. 0 32
      examples/randomly-sample-mesh/Makefile
  99. 0 611
      examples/randomly-sample-mesh/example.cpp
  100. 0 25
      examples/render_to_png/Makefile

+ 2 - 2
README.md

@@ -154,7 +154,7 @@ git pull
 git submodule update -- recursive
 git submodule update -- recursive
 ```
 ```
 
 
-## Unit testing 
+## Unit testing
 
 
 Libigl maintains [separate
 Libigl maintains [separate
 repository](https://github.com/libigl/libigl-unit-tests) for unit testing.
 repository](https://github.com/libigl/libigl-unit-tests) for unit testing.
@@ -229,6 +229,6 @@ page](https://github.com/libigl/libigl/issues).
 ## Copyright
 ## Copyright
 2015 Alec Jacobson, Daniele Panozzo, Christian Schüller, Olga Diamanti, Qingnan
 2015 Alec Jacobson, Daniele Panozzo, Christian Schüller, Olga Diamanti, Qingnan
 Zhou, Nico Pietroni, Stefan Brugger, Kenshi Takayama, Wenzel Jakob, Nikolas De
 Zhou, Nico Pietroni, Stefan Brugger, Kenshi Takayama, Wenzel Jakob, Nikolas De
-Giorgis, Luigi Rocca, Leonardo Sacht, Olga Sorkine-Hornung, and others.
+Giorgis, Luigi Rocca, Leonardo Sacht, Kevin Walliman, Olga Sorkine-Hornung, and others.
 
 
 Please see individual files for appropriate copyright notices.
 Please see individual files for appropriate copyright notices.

+ 0 - 20
examples/Makefile

@@ -1,20 +0,0 @@
-.PHONY: all
-.NOTPARALLEL: all
-
-DIRS=$(wildcard */)
-
-
-all: $(DIRS) 
-	for p in  $(DIRS); \
-	do \
-	echo "cd $$p" ; \
-	$(MAKE) -C $$p; \
-	done
-	
-clean: $(DIRS) 
-	for p in  $(DIRS); \
-	do \
-	echo "cd $$p" ; \
-	$(MAKE) -C $$p clean; \
-	done
-	#$(MAKE) -C $$p || exit $$?; \#$(MAKE) -C $$p || exit $$?; \

+ 0 - 252
examples/Makefile.conf

@@ -1,252 +0,0 @@
-#############################################################################
-# FLAGS
-#############################################################################
-UNAME := $(shell uname)
-
-THIS_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
-
-GG=g++
-#GG=clang++
-#GG=/usr/bin/g++     17s
-#GG=/usr/bin/clang++ 14s
-#GG=g++-mp-4.3       15.5s
-#GG=g++-mp-4.7       19.9s
-
-CFLAGS += -Wall
-CFLAGS += -std=c++11
-
-ifeq ($(UNAME), Linux)
-	DEFAULT_PREFIX=/usr/local/
-else
-	DEFAULT_PREFIX=/usr/local/
-	# I guess arch only works in Mac OSX
-	AFLAGS+=-arch x86_64 -m64 -march=corei7-avx
-endif
-
-# Default parameters for the IGL group members based on there computer's
-# username
-ifndef IGL_USERNAME
-	IGL_USERNAME := $(shell whoami)
-endif
-
-ifeq ($(IGL_USERNAME),whitinge)
-	DEFAULT_PREFIX=/usr/local/
-	MOSEKPLATFORM=osx64x86
-	MOSEKVERSION=7
-	IGL_WITH_TETGEN=1
-	IGL_WITH_MOSEK=1
-	IGL_WITH_BBW=1
-	IGL_WITH_SVD3X3=1
-	IGL_WITH_PNG=1
-	# I don't use llvm
-#AFLAGS = -m64 -march="corei7-avx"
-	# msse4.2 is necessary for me to get embree to compile correctly
-	AFLAGS=-m64 -msse4.2
-	OPENMP=-fopenmp
-	EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
-endif
-
-ifeq ($(IGL_USERNAME),ajx)
-        LIBIGL_USE_STATIC_LIBRARY=1
-	MOSEKPLATFORM=osx64x86
-	MOSEKVERSION=7
-	IGL_WITH_VIEWER=1
-	IGL_WITH_TETGEN=1
-	IGL_WITH_BOOLEAN=1
-	IGL_WITH_EMBREE=1
-	IGL_WITH_MATLAB=1
-	IGL_WITH_MOSEK=1
-	IGL_WITH_CGAL=1
-	IGL_WITH_BBW=1
-	IGL_WITH_SVD3X3=1
-	IGL_WITH_PNG=1
-	IGL_WITH_XML=1
-	IGL_WITH_BOOST=1
-	# I don't use llvm
-#AFLAGS = -m64 -march="corei7-avx"
-	# msse4.2 is necessary for me to get embree to compile correctly
-	AFLAGS=-m64 -msse4.2
-	#OPENMP=-fopenmp
-	EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
-	#EIGEN3_INC=-I/Users/ajx/Documents/eigen -I/Users/ajx/Documents/eigen/unsupported
-endif
-
-ifeq ($(IGL_USERNAME),alecjaco)
-	DEFAULT_PREFIX=/home1/alecjaco/
-	#MOSEKPLATFORM=linux64x86
-	IGL_WITH_TETGEN=1
-	IGL_WITH_MATLAB=0
-	#IGL_WITH_MOSEK=1
-	OPENGL_INC=-I$(DEFAULT_PREFIX)/include
-	OPENGL_LIB=-lGL -lGLU
-	# Glut is needed only for examples
-	GLUT_LIB=-lglut
-	ANTTWEAKBAR_LIB=-lAntTweakBar
-	OPENMP=-fopenmp
-endif
-
-ifeq ($(IGL_USERNAME),jacobson)
-	CFLAGS+=
-endif
-
-ifeq ($(IGL_USERNAME),sorkineo)
-	MOSEKPLATFORM=osx64x86
-	IGL_WITH_TETGEN=1
-	IGL_WITH_MATLAB=0
-	IGL_WITH_MOSEK=1
-	IGL_WITH_PNG=0
-endif
-
-ifeq ($(IGL_USERNAME),jalec_linux)
-	MOSEKPLATFORM=linux64x86
-	IGL_WITH_TETGEN=1
-	IGL_WITH_MATLAB=0
-	IGL_WITH_MOSEK=1
-	OPENGL_LIB=-lGL -lGLU
-	# Glut is needed only for examples
-	GLUT_LIB=-lglut
-	ANTTWEAKBAR_LIB=-lAntTweakBar
-	IGL_WITH_PNG=1
-	OPENMP=-fopenmp
-endif
-
-ifeq ($(IGL_USERNAME),daniele)
-	IGL_WITH_MATLAB=0
-	IGL_WITH_XML=1
-	AFLAGS=-m64
-	GG=g++-4.8 -Wfatal-errors
-	EIGEN3_INC=-I/usr/local/include/eigen3
-endif
-
-ifeq ($(IGL_USERNAME),olkido)
-    IGL_WITH_MATLAB=1
-	IGL_WITH_COMISO=1
-	IGL_WITH_XML=1
-	COMISO=/Users/olkido/Documents/igl/MIQ/src/CoMISo
-	  IGL_WITH_XML=1
-    AFLAGS= -m64
-    IGL_WITH_EMBREE=1
-    IGL_WITH_PNG=1
-	IGL_WITH_VIEWER=1
-	MATLAB=/Applications/MATLAB_R2014b.app/
-endif
-
-ifeq ($(IGL_USERNAME),chrsch)
-  ifeq ($(UNAME), Linux)
-    DEFAULT_PREFIX=/usr
-    IGL_WITH_XML=1
-    IGL_WITH_TETGEN=0
-    IGL_WITH_MATLAB=0
-    IGL_WITH_PNG=0
-    IGL_WITH_MOSEK=0
-    #MOSEKPLATFORM=linux64x86
-    OPENGL_LIB=-lGL -lGLU
-    # Glut is needed only for examples
-    GLUT_LIB=-lglut
-    ANTTWEAKBAR_LIB=-lAntTweakBar
-    OPENMP=-fopenmp
-    AFLAGS = -Wfatal-errors
-  else
-    IGL_WITH_XML=1
-    IGL_WITH_TETGEN=0
-    IGL_WITH_MATLAB=0
-    IGL_WITH_PNG=0
-    IGL_WITH_MOSEK=0
-    OPENGL_INC=-I$(DEFAULT_PREFIX)/include
-    OPENGL_LIB=-lGL -lGLU
-    # Glut is needed only for examples
-    GLUT_LIB=-lglut
-    ANTTWEAKBAR_LIB=-lAntTweakBar
-    OPENMP=-fopenmp
-    AFLAGS=-m64
-  endif
-endif
-
-ifeq ($(IGL_USERNAME),stefanmessmer)
-	GG=clang++
-	IGL_WITH_TETGEN=0
-	IGL_WITH_EMBREE=0
-	IGL_WITH_MATLAB=0
-	IGL_WITH_MOSEK=0
-	IGL_WITH_BBW=1
-	IGL_WITH_PNG=0
-	IGL_WITH_XML=0
-	IGL_WITH_BOOST=0
-	IGL_WITH_SVD3X3=1
-	#OPENGL_INC=-I$(DEFAULT_PREFIX)/include
-	#OPENGL_LIB=-lGL -lGLU
-	# Glut is needed only for examples
-	#GLUT_LIB=-lglut
-	#ANTTWEAKBAR_LIB=-lAntTweakBar
-	OPENPMP = -openmp
-	AFLAGS = -DIGL_NO_MOSEK -DIGL_NO_ANTTWEAKBAR -DIGL_NO_OPENGL -arch armv7s -arch armv7 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
-	AFLAGS_SIMULATOR = -DIGL_NO_MOSEK -DIGL_NO_ANTTWEAKBAR -DIGL_NO_OPENG -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk
-endif
-
-ifeq ($(IGL_USERNAME),wenzel)
-	IGL_WITH_TETGEN=0
-	IGL_WITH_MATLAB=0
-	IGL_WITH_MOSEK=0
-	OPENGL_LIB=-lGL -lGLU
-	GLUT_LIB=-lglut
-	ANTTWEAKBAR_LIB=-lAntTweakBar
-	IGL_WITH_PNG=1
-	OPENMP=-fopenmp
-	CFLAGS += -msse4 -D__SSE4__ -DIGL_NO_MOSEK
-endif
-
-#############################################################################
-# DEFAULTS (USUALLY TO SOMETHING THAT WORKS FOR SURE ON MAC OS X
-#############################################################################
-
-ifndef OPENGL_LIB
-	OPENGL_LIB=-framework OpenGL
-endif
-ifndef GLUT_LIB
-	GLUT_LIB=-framework GLUT
-endif
-# Eigen dependency
-ifndef EIGEN3_INC
-	EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
-endif
-
-LIBIGL=$(THIS_DIR)/../
-LIBIGL_INC=-I$(LIBIGL)/include
-
-ifndef ANTTWEAKBAR_INC
-	ANTTWEAKBAR_INC=-I$(LIBIGL)/external/AntTweakBar/include
-endif
-ifndef ANTTWEAKBAR_LIB
-	# AntTweakBar needs AppKit on mac os x
-	ANTTWEAKBAR_LIB=-L$(LIBIGL)/external/AntTweakBar/lib -lAntTweakBar -framework AppKit -liglanttweakbar
-endif
-
-ifndef SINGULAR_VALUE_DECOMPOSITION_INC
-	SINGULAR_VALUE_DECOMPOSITION_INC=\
-	-I$(LIBIGL)/external/Singular_Value_Decomposition/
-endif
-
-ifndef TETGEN
-# By default I'm using the libigl version. Adjust accordingly
-	TETGEN=$(LIBIGL)/external/tetgen
-	TETGEN_LIB=-L$(TETGEN) -ligltetgen -ltet 
-	TETGEN_INC=-I$(TETGEN)
-endif
-
-ifndef EMBREE
-	EMBREE=$(LIBIGL)/external/embree
-	EMBREE_INC=-I$(EMBREE)/ -I$(EMBREE)/include
-	EMBREE_LIB=-L$(EMBREE)/build -lembree -lsys
-endif
-ifndef YIMG
-	YIMG=$(LIBIGL)/external/yimg
-	YIMG_LIB=-L$(YIMG) -lyimg -lz -L/usr/X11/lib -L$(DEFAULT_PREFIX)/lib -lpng -bind_at_load
-	YIMG_INC=-I/usr/X11/include -I$(YIMG) 
-endif
-
-ifdef LIBIGL_USE_STATIC_LIBRARY
-	CFLAGS += -DIGL_STATIC_LIBRARY
-	LIBIGL_LIB=-L$(LIBIGL)/lib -ligl -liglopengl2 -liglopengl
-endif
-
-OPTFLAGS+=-O3 -DNDEBUG $(OPENMP)

+ 0 - 29
examples/MatlabWorkspace/Makefile

@@ -1,29 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-LIBIGL_LIB+=-liglmatlab
-
-MATLAB_INC=-I$(MATLAB)/extern/include/
-MATLAB_LIB=-L$(MATLAB)/bin/maci64 -lmx -lmat
-
-LIB+=$(LIBIGL_LIB) $(MATLAB_LIB)
-INC+=$(LIBIGL_INC) $(EIGEN3_INC) $(MATLAB_INC)
-
-CFLAGS += -g
-
-ifeq ($(IGL_WITH_MATLAB),1)
-	EXAMPLE=example
-endif
-
-all: $(EXAMPLE)
-
-example: example.o
-	g++ -o example example.o $(LIB)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -o $@ -c $< $(INC)
-
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 13
examples/MatlabWorkspace/README

@@ -1,13 +0,0 @@
-This is a simple example program that shows how to use the MatlabWorkspace
-class of the igl library
-
-
-To Build:
-  make
-
-To Run:
-  ./example [input.dmat] [output.mat]
-
-Example Run #1:
-  Issuing:
-    ./example example.dmat output.mat

+ 0 - 32
examples/MatlabWorkspace/example.cpp

@@ -1,32 +0,0 @@
-#include <Eigen/Core>
-
-#include <igl/readDMAT.h>
-#include <cstdio>
-
-#ifdef IGL_STATIC_LIBRARY
-#  define IGL_HEADER_ONLY
-#  define IGL_HEADER_ONLY_WAS_NOT_DEFINED
-#endif
-#include <igl/matlab/MatlabWorkspace.h>
-#include <igl/on_boundary.h>
-#ifndef IGL_STATIC_LIBRARY_WAS_NOT_DEFINED
-#  undef IGL_HEADER_ONLY
-#endif
-
-int main(int argc, char * argv[])
-{
-  using namespace igl;
-  using namespace Eigen;
-  if(argc <= 2)
-  {
-    printf("USAGE:\n  ./example [input.dmat] [output.mat]\n");
-    return 1;
-  }
-  MatrixXd M;
-  readDMAT(argv[1],M);
-  igl::matlab::MatlabWorkspace mat;
-  mat.save(M,"M");
-  mat.write(argv[2]);
-
-  return 0;
-}

+ 0 - 7
examples/MatlabWorkspace/example.dmat

@@ -1,7 +0,0 @@
-3 2
-1
-4
-2
-5
-3
-6

+ 0 - 21
examples/ReAntTweakBar/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-inc=$(LIBIGL_INC) $(ANTTWEAKBAR_INC)
-lib=$(LIBIGL_LIB) $(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB)
-CFLAGS+=-g
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 29
examples/ReAntTweakBar/README

@@ -1,29 +0,0 @@
-ReAntTweakBar is a minimal wrapper for the AntTweakBar library that allows
-"bars" to be saved and load from disk. Changing your existing app that users
-AntTweakBar to use ReAntTweakBar is trivial.
-
-This directory should contain:
-  README
-  example.cpp
-  example  (option example binary)
-  temp.rbr (optional example ReAntTweakBar output)
-
-Many (but not all) variable types are supported. I'll try to keep track them
-here:
-  TW_TYPE_BOOLCPP
-  TW_TYPE_QUAT4F
-  TW_TYPE_COLOR4F
-  TW_TYPE_COLOR3F
-  TW_TYPE_DIR3F
-  TW_TYPE_BOOL32
-  TW_TYPE_INT32
-  TW_TYPE_FLOAT
-  TW_TYPE_DOUBLE
-  and
-  custom TwTypes made with TwDefineEnum
-
-I'm working on adding the rest on an as-needed basis. Adding a new type only
-requires changes in a few places...
-
-Look in example.cpp for an example of how to compile with ReAntTweakBar and use
-it.

+ 0 - 381
examples/ReAntTweakBar/example.cpp

@@ -1,381 +0,0 @@
-/*
-  This is an example program that came with AntTweakBar modified to use ReAntTweakBar
-
-  On mac os x compile with:
-
-  g++ -c example.cpp -o example.o
-  g++ -o example example.o -framework OpenGL -framework GLUT -lAntTweakBar
-  rm *.o
-
-*/
-
-#ifdef __APPLE__
-#define _MACOSX
-#endif
-// ORIGINAL COPYRIGHT INFO
-//  ---------------------------------------------------------------------------
-//
-//  @file       TwSimpleGLUT.c
-//  @brief      A simple example that uses AntTweakBar with OpenGL and GLUT.
-//
-//              AntTweakBar: http://www.antisphere.com/Wiki/tools:anttweakbar
-//              OpenGL:      http://www.opengl.org
-//              GLUT:        http://opengl.org/resources/libraries/glut
-//
-//  @author     Philippe Decaudin - http://www.antisphere.com
-//  @date       2006/05/20
-//
-//  Compilation:
-//  http://www.antisphere.com/Wiki/tools:anttweakbar:examples#twsimpleglut
-//
-//  ---------------------------------------------------------------------------
-
-
-#include <igl/anttweakbar/ReAntTweakBar.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-
-#if defined(_WIN32) || defined(_WIN64)
-//  MiniGLUT.h is provided to avoid the need of having GLUT installed to
-//  recompile this example. Do not use it in your own programs, better
-//  install and use the actual GLUT library SDK.
-#   define USE_MINI_GLUT
-#endif
-
-#if defined(USE_MINI_GLUT)
-#   include "../src/MiniGLUT.h"
-#elif defined(_MACOSX)
-#   include <GLUT/glut.h>
-#else
-#   include <GL/glut.h>
-#endif
-
-#define REBAR_NAME "temp.rbr"
-
-
-// This example displays one of the following shapes
-typedef enum { SHAPE_TEAPOT=1, SHAPE_TORUS, SHAPE_CONE, SHAPE_SPHERE } Shape;
-#define NUM_SHAPES 4
-Shape g_CurrentShape = SHAPE_TORUS;
-// Shapes scale
-float g_Zoom = 1.0f;
-// Shape orientation (stored as a quaternion)
-float g_Rotation[] = { 0.0f, 0.0f, 0.0f, 1.0f };
-// Auto rotate
-int g_AutoRotate = 0;
-int g_RotateTime = 0;
-float g_RotateStart[] = { 0.0f, 0.0f, 0.0f, 1.0f };
-// Shapes material
-float g_MatAmbient[] = { 0.5f, 0.0f, 0.0f, 1.0f };
-float g_MatDiffuse[] = { 1.0f, 1.0f, 0.0f, 1.0f };
-// Light parameter
-double g_LightMultiplier = 1.0f;
-float g_LightDirection[] = { -0.57735f, -0.57735f, -0.57735f };
-
-igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
-
-// Routine to set a quaternion from a rotation axis and angle
-// ( input axis = float[3] angle = float  output: quat = float[4] )
-void SetQuaternionFromAxisAngle(const float *axis, float angle, float *quat)
-{
-  float sina2, norm;
-  sina2 = (float)sin(0.5f * angle);
-  norm = (float)sqrt(axis[0]*axis[0] + axis[1]*axis[1] + axis[2]*axis[2]);
-  quat[0] = sina2 * axis[0] / norm;
-  quat[1] = sina2 * axis[1] / norm;
-  quat[2] = sina2 * axis[2] / norm;
-  quat[3] = (float)cos(0.5f * angle);
-
-}
-
-
-// Routine to convert a quaternion to a 4x4 matrix
-// ( input: quat = float[4]  output: mat = float[4*4] )
-void ConvertQuaternionToMatrix(const float *quat, float *mat)
-{
-  float yy2 = 2.0f * quat[1] * quat[1];
-  float xy2 = 2.0f * quat[0] * quat[1];
-  float xz2 = 2.0f * quat[0] * quat[2];
-  float yz2 = 2.0f * quat[1] * quat[2];
-  float zz2 = 2.0f * quat[2] * quat[2];
-  float wz2 = 2.0f * quat[3] * quat[2];
-  float wy2 = 2.0f * quat[3] * quat[1];
-  float wx2 = 2.0f * quat[3] * quat[0];
-  float xx2 = 2.0f * quat[0] * quat[0];
-  mat[0*4+0] = - yy2 - zz2 + 1.0f;
-  mat[0*4+1] = xy2 + wz2;
-  mat[0*4+2] = xz2 - wy2;
-  mat[0*4+3] = 0;
-  mat[1*4+0] = xy2 - wz2;
-  mat[1*4+1] = - xx2 - zz2 + 1.0f;
-  mat[1*4+2] = yz2 + wx2;
-  mat[1*4+3] = 0;
-  mat[2*4+0] = xz2 + wy2;
-  mat[2*4+1] = yz2 - wx2;
-  mat[2*4+2] = - xx2 - yy2 + 1.0f;
-  mat[2*4+3] = 0;
-  mat[3*4+0] = mat[3*4+1] = mat[3*4+2] = 0;
-  mat[3*4+3] = 1;
-}
-
-
-// Routine to multiply 2 quaternions (ie, compose rotations)
-// ( input q1 = float[4] q2 = float[4]  output: qout = float[4] )
-void MultiplyQuaternions(const float *q1, const float *q2, float *qout)
-{
-  float qr[4];
-	qr[0] = q1[3]*q2[0] + q1[0]*q2[3] + q1[1]*q2[2] - q1[2]*q2[1];
-	qr[1] = q1[3]*q2[1] + q1[1]*q2[3] + q1[2]*q2[0] - q1[0]*q2[2];
-	qr[2] = q1[3]*q2[2] + q1[2]*q2[3] + q1[0]*q2[1] - q1[1]*q2[0];
-	qr[3]  = q1[3]*q2[3] - (q1[0]*q2[0] + q1[1]*q2[1] + q1[2]*q2[2]);
-  qout[0] = qr[0]; qout[1] = qr[1]; qout[2] = qr[2]; qout[3] = qr[3];
-}
-
-
-// Callback function called by GLUT to render screen
-void Display(void)
-{
-  float v[4]; // will be used to set light paramters
-  float mat[4*4]; // rotation matrix
-
-  // Clear frame buffer
-  glClearColor(0, 0, 0, 1);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  glEnable(GL_DEPTH_TEST);
-  glDisable(GL_CULL_FACE);
-  glEnable(GL_NORMALIZE);
-
-  // Set light
-  glEnable(GL_LIGHTING);
-  glEnable(GL_LIGHT0);
-  v[0] = v[1] = v[2] = g_LightMultiplier*0.4f; v[3] = 1.0f;
-  glLightfv(GL_LIGHT0, GL_AMBIENT, v);
-  v[0] = v[1] = v[2] = g_LightMultiplier*0.8f; v[3] = 1.0f;
-  glLightfv(GL_LIGHT0, GL_DIFFUSE, v);
-  v[0] = -g_LightDirection[0]; v[1] = -g_LightDirection[1]; v[2] = -g_LightDirection[2]; v[3] = 0.0f;
-  glLightfv(GL_LIGHT0, GL_POSITION, v);
-
-  // Set material
-  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, g_MatAmbient);
-  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, g_MatDiffuse);
-
-  // Rotate and draw shape
-  glPushMatrix();
-  glTranslatef(0.5f, -0.3f, 0.0f);
-  if( g_AutoRotate )
-  {
-    float axis[3] = { 0, 1, 0 };
-    float angle = (float)(glutGet(GLUT_ELAPSED_TIME)-g_RotateTime)/1000.0f;
-    float quat[4];
-    SetQuaternionFromAxisAngle(axis, angle, quat);
-    MultiplyQuaternions(g_RotateStart, quat, g_Rotation);
-  }
-  ConvertQuaternionToMatrix(g_Rotation, mat);
-  glMultMatrixf(mat);
-  glScalef(g_Zoom, g_Zoom, g_Zoom);
-  glCallList(g_CurrentShape);
-  glPopMatrix();
-
-  // Draw tweak bars
-  TwDraw();
-
-  // Present frame buffer
-  glutSwapBuffers();
-
-  // Recall Display at next frame
-  glutPostRedisplay();
-}
-
-
-// Callback function called by GLUT when window size changes
-void Reshape(int width, int height)
-{
-  // Set OpenGL viewport and camera
-  glViewport(0, 0, width, height);
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  gluPerspective(40, (double)width/height, 1, 10);
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-  gluLookAt(0,0,5, 0,0,0, 0,1,0);
-  glTranslatef(0, 0.6f, -1);
-
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-}
-
-
-// Function called at exit
-void Terminate(void)
-{
-  rebar.save(REBAR_NAME);
-
-  glDeleteLists(SHAPE_TEAPOT, NUM_SHAPES);
-
-  TwTerminate();
-}
-
-
-//  Callback function called when the 'AutoRotate' variable value of the tweak bar has changed
-void TW_CALL SetAutoRotateCB(const void *value, void *clientData)
-{
-  (void)clientData; // unused
-
-  g_AutoRotate = *(const int *)(value); // copy value to g_AutoRotate
-  if( g_AutoRotate!=0 )
-  {
-    // init rotation
-    g_RotateTime = glutGet(GLUT_ELAPSED_TIME);
-    g_RotateStart[0] = g_Rotation[0];
-    g_RotateStart[1] = g_Rotation[1];
-    g_RotateStart[2] = g_Rotation[2];
-    g_RotateStart[3] = g_Rotation[3];
-
-    // make Rotation variable read-only
-    TwDefine(" TweakBar/ObjRotation readonly ");
-  }
-  else
-    // make Rotation variable read-write
-    TwDefine(" TweakBar/ObjRotation readwrite ");
-}
-
-
-//  Callback function called by the tweak bar to get the 'AutoRotate' value
-void TW_CALL GetAutoRotateCB(void *value, void *clientData)
-{
-  (void)clientData; // unused
-  *(int *)(value) = g_AutoRotate; // copy g_AutoRotate to value
-}
-
-
-// Main
-int main(int argc, char *argv[])
-{
-  float axis[] = { 0.7f, 0.7f, 0.0f }; // initial model rotation
-  float angle = 0.8f;
-
-  // Initialize AntTweakBar
-  // (note that AntTweakBar could also be intialized after GLUT, no matter)
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-
-  // Initialize GLUT
-  glutInit(&argc, argv);
-  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
-  glutInitWindowSize(640, 480);
-  glutCreateWindow("AntTweakBar simple example using GLUT");
-  glutCreateMenu(NULL);
-
-  // Set GLUT callbacks
-  glutDisplayFunc(Display);
-  glutReshapeFunc(Reshape);
-  atexit(Terminate);  // Called after glutMainLoop ends
-
-  // Set GLUT event callbacks
-  // - Directly redirect GLUT mouse button events to AntTweakBar
-  glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT);
-  // - Directly redirect GLUT mouse motion events to AntTweakBar
-  glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
-  // - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion)
-  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
-  // - Directly redirect GLUT key events to AntTweakBar
-  glutKeyboardFunc((GLUTkeyboardfun)TwEventKeyboardGLUT);
-  // - Directly redirect GLUT special key events to AntTweakBar
-  glutSpecialFunc((GLUTspecialfun)TwEventSpecialGLUT);
-  // - Send 'glutGetModifers' function pointer to AntTweakBar;
-  //   required because the GLUT key event functions do not report key modifiers states.
-  TwGLUTModifiersFunc(glutGetModifiers);
-
-  // Create some 3D objects (stored in display lists)
-  glNewList(SHAPE_TEAPOT, GL_COMPILE);
-  glutSolidTeapot(1.0);
-  glEndList();
-  glNewList(SHAPE_TORUS, GL_COMPILE);
-  glutSolidTorus(0.3, 1.0, 16, 32);
-  glEndList();
-  glNewList(SHAPE_CONE, GL_COMPILE);
-  glutSolidCone(1.0, 1.5, 64, 4);
-  glEndList();
-  glNewList(SHAPE_SPHERE, GL_COMPILE);
-  glutSolidSphere(1.0, 50, 40);
-  glEndList();
-
-  // Create a tweak bar
-  rebar.TwNewBar("TweakBar");
-  TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar with GLUT and OpenGL.' "); // Message added to the help bar.
-  TwDefine(" TweakBar size='200 400' color='96 216 224' "); // change default tweak bar size and color
-
-  // Add 'g_Zoom' to 'bar': this is a modifable (RW) variable of type TW_TYPE_FLOAT. Its key shortcuts are [z] and [Z].
-  rebar.TwAddVarRW("Zoom", TW_TYPE_FLOAT, &g_Zoom,
-             " min=0.01 max=2.5 step=0.01 keyIncr=z keyDecr=Z help='Scale the object (1=original size).' ");
-
-  // Add 'g_Rotation' to 'bar': this is a variable of type TW_TYPE_QUAT4F which defines the object's orientation
-  rebar.TwAddVarRW("ObjRotation", TW_TYPE_QUAT4F, &g_Rotation,
-             " label='Object rotation' open help='Change the object orientation.' ");
-
-  // Add callback to toggle auto-rotate mode (callback functions are defined above).
-  rebar.TwAddVarCB("AutoRotate", TW_TYPE_BOOL32, SetAutoRotateCB, GetAutoRotateCB, NULL,
-             " label='Auto-rotate' key=space help='Toggle auto-rotate mode.' ");
-
-  // Add 'g_LightMultiplier' to 'bar': this is a variable of type TW_TYPE_FLOAT. Its key shortcuts are [+] and [-].
-  rebar.TwAddVarRW("Multiplier", TW_TYPE_DOUBLE, &g_LightMultiplier,
-             " label='Light booster' min=0.1 max=4 step=0.02 keyIncr='+' keyDecr='-' help='Increase/decrease the light power.' ");
-
-  // Add 'g_LightDirection' to 'bar': this is a variable of type TW_TYPE_DIR3F which defines the light direction
-  rebar.TwAddVarRW("Light Dir", TW_TYPE_DIR3F, &g_LightDirection,
-             " label='Light direction' open help='Change the light direction.' ");
-
-  // Add 'g_MatAmbient' to 'bar': this is a variable of type TW_TYPE_COLOR3F (3 floats color, alpha is ignored)
-  // and is inserted into a group named 'Material'.
-  rebar.TwAddVarRW("Ambient", TW_TYPE_COLOR3F, &g_MatAmbient, " group='Material' ");
-
-  // Add 'g_MatDiffuse' to 'bar': this is a variable of type TW_TYPE_COLOR3F (3 floats color, alpha is ignored)
-  // and is inserted into group 'Material'.
-  rebar.TwAddVarRW("Diffuse", TW_TYPE_COLOR3F, &g_MatDiffuse, " group='Material' ");
-
-  // Add the enum variable 'g_CurrentShape' to 'bar'
-  // (before adding an enum variable, its enum type must be declared to AntTweakBar as follow)
-  {
-    // ShapeEV associates Shape enum values with labels that will be displayed instead of enum values
-    TwEnumVal shapeEV[NUM_SHAPES] = { {SHAPE_TEAPOT, "Teapot"}, {SHAPE_TORUS, "Torus"}, {SHAPE_CONE, "Cone"} , {SHAPE_SPHERE, "Sphere"}};
-    // Create a type for the enum shapeEV
-    TwType shapeType = igl::anttweakbar::ReTwDefineEnum("ShapeType", shapeEV, NUM_SHAPES);
-    // add 'g_CurrentShape' to 'bar': this is a variable of type ShapeType. Its key shortcuts are [<] and [>].
-    rebar.TwAddVarRW("Shape", shapeType, &g_CurrentShape, " keyIncr='<' keyDecr='>' help='Change object shape.' ");
-  }
-
-  // Store time
-  g_RotateTime = glutGet(GLUT_ELAPSED_TIME);
-  // Init rotation
-  SetQuaternionFromAxisAngle(axis, angle, g_Rotation);
-  SetQuaternionFromAxisAngle(axis, angle, g_RotateStart);
-
-  FILE * fp = fopen(REBAR_NAME,"r");
-  if(fp != NULL)
-  {
-    fclose(fp);
-    if(rebar.load(REBAR_NAME))
-    {
-      printf("ReAntTweakBar reloaded successfully from %s.\n",REBAR_NAME);
-    }else
-    {
-      printf("ReAntTweakBar failed to load from %s.\n",REBAR_NAME);
-    }
-  }else
-  {
-    printf("%s ReAntTweakBar file does not exist (yet).\n",REBAR_NAME);
-  }
-
-  // Call the GLUT main loop
-  glutMainLoop();
-
-  return 0;
-}
-

+ 0 - 21
examples/affine/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-all: example
-
-# Shared flags etc.
-include ../Makefile.conf
-
-.PHONY: example
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC) $(EIGEN3_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 8
examples/affine/README

@@ -1,8 +0,0 @@
-A small program showing how .translate and .rotate affect eigen's Affine matrix class
-
-
-Compile with:
-  make
-
-Run with:
-  ./example

+ 0 - 33
examples/affine/example.cpp

@@ -1,33 +0,0 @@
-#include <Eigen/Geometry>
-#include <iostream>
-using namespace std;
-
-typedef Eigen::Transform<double,3,Eigen::Affine> Tform3;
-typedef Eigen::Vector3d Vec3;
-typedef Eigen::Quaterniond Quat;
-
-int main(int argc, char * argv[])
-{
-  Tform3 T;
-  T =Tform3::Identity();
-  cout<<"T =Tform3::Identity();"<<endl;
-  cout<<"T=["<<endl<<T.affine().matrix()<<endl<<"];"<<endl;
-  cout<<"T.translate(Vec3(1,2,3));"<<endl;
-  T.translate(Vec3(1,2,3));
-  cout<<"T=["<<endl<<T.affine().matrix()<<endl<<"];"<<endl;
-  cout<<"T.rotate(Quat(0,1,0,0));"<<endl;
-  T.rotate(Quat(0,1,0,0));
-  cout<<"T=["<<endl<<T.affine().matrix()<<endl<<"];"<<endl;
-  cout<<endl;
-
-  T =Tform3::Identity();
-  cout<<"T =Tform3::Identity();"<<endl;
-  cout<<"T=["<<endl<<T.affine().matrix()<<endl<<"];"<<endl;
-  cout<<"T.rotate(Quat(0,1,0,0));"<<endl;
-  T.rotate(Quat(0,1,0,0));
-  cout<<"T=["<<endl<<T.affine().matrix()<<endl<<"];"<<endl;
-  cout<<"T.translate(Vec3(1,2,3));"<<endl;
-  T.translate(Vec3(1,2,3));
-  cout<<"T=["<<endl<<T.affine().matrix()<<endl<<"];"<<endl;
-  cout<<endl;
-}

+ 0 - 25
examples/ambient-occlusion/Makefile

@@ -1,25 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-LIBIGL_LIB+=-liglembree
-
-all: example
-
-.PHONY: example
-
-EMBREE=$(LIBIGL)/external/embree
-EMBREE_INC=-I$(EMBREE)/ -I$(EMBREE)/include
-EMBREE_LIB=-L$(EMBREE)/build -lembree -lsys
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(EMBREE_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB) $(EMBREE_LIB)
-
-example: example.o
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) $(LIB) -o example example.o 
-
-example.o: example.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c example.cpp -o example.o $(INC)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 411
examples/ambient-occlusion/example.cpp

@@ -1,411 +0,0 @@
-#include <igl/opengl/OpenGL_convenience.h>
-#include <igl/per_face_normals.h>
-#include <igl/per_vertex_normals.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/quat_to_mat.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/readOBJ.h>
-#include <igl/readDMAT.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/readWRL.h>
-#include <igl/trackball.h>
-#include <igl/list_to_matrix.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/material_colors.h>
-#include <igl/barycenter.h>
-#include <igl/matlab_format.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-#include <igl/pathinfo.h>
-#include <igl/embree/EmbreeIntersector.h>
-#include <igl/embree/ambient_occlusion.h>
-
-#ifdef __APPLE__
-#  include <GLUT/glut.h>
-#else
-#  include <GL/glut.h>
-#endif
-
-#include <Eigen/Core>
-
-#include <vector>
-#include <iostream>
-#include <algorithm>
-
-// Width and height of window
-int width,height;
-// Rotation of scene
-float scene_rot[4] = {0,0,0,1};
-// information at mouse down
-float down_scene_rot[4] = {0,0,0,1};
-bool trackball_on = false;
-int down_mouse_x,down_mouse_y;
-// Position of light
-float light_pos[4] = {0.1,0.1,-0.9,0};
-// Vertex positions, normals, colors and centroid
-Eigen::MatrixXd V,N,C,mid;
-// Faces
-Eigen::MatrixXi F;
-// Bounding box diagonal length
-double bbd;
-igl::embree::EmbreeIntersector ei;
-// Running ambient occlusion
-Eigen::VectorXd S;
-int tot_num_samples = 0;
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
-bool lights_on = true;
-Eigen::Vector4f color(0.4,0.8,0.3,1.0);
-double ao_factor = 1.0;
-bool ao_normalize = false;
-bool ao_on = true;
-double light_intensity = 1.0;
-
-void reshape(int width,int height)
-{
-  using namespace std;
-  // Save width and height
-  ::width = width;
-  ::height = height;
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-}
-
-// Set up igl::opengl2::projection and model view of scene
-void push_scene()
-{
-  using namespace igl;
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  gluPerspective(45,(double)width/(double)height,1e-2,100);
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-  gluLookAt(0,0,3,0,0,0,0,1,0);
-  glPushMatrix();
-  float mat[4*4];
-  quat_to_mat(scene_rot,mat);
-  glMultMatrixf(mat);
-}
-
-void pop_scene()
-{
-  glPopMatrix();
-}
-
-// Scale and shift for object
-void push_object()
-{
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-mid(0,0),-mid(0,1),-mid(0,2));
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  float amb[4];
-  amb[0] = amb[1] = amb[2] = light_intensity;
-  amb[3] = 1.0;
-  float diff[4] = {0.0,0.0,0.0,0.0};
-  diff[0] = diff[1] = diff[2] = (1.0 - light_intensity/0.4);;
-  diff[3] = 1.0;
-  float zeros[4] = {0.0,0.0,0.0,0.0};
-  float pos[4];
-  copy(light_pos,light_pos+4,pos);
-  glLightfv(GL_LIGHT0,GL_AMBIENT,amb);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,diff);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos);
-  pos[0] *= -1;
-  pos[1] *= -1;
-  pos[2] *= -1;
-  glLightfv(GL_LIGHT1,GL_AMBIENT,amb);
-  glLightfv(GL_LIGHT1,GL_DIFFUSE,diff);
-  glLightfv(GL_LIGHT1,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT1,GL_POSITION,pos);
-}
-
-const float back[4] = {30.0/255.0,30.0/255.0,50.0/255.0,0};
-void display()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  if(!trackball_on && tot_num_samples < 10000)
-  {
-    if(S.size() == 0)
-    {
-      S.resize(V.rows());
-      S.setZero();
-    }
-    VectorXd Si;
-    const int num_samples = 20;
-    igl::embree::ambient_occlusion(ei,V,N,num_samples,Si);
-    S *= (double)tot_num_samples;
-    S += Si*(double)num_samples;
-    tot_num_samples += num_samples;
-    S /= (double)tot_num_samples;
-  }
-
-  // Convert to 1-intensity
-  C.conservativeResize(S.rows(),3);
-  if(ao_on)
-  {
-    C<<S,S,S;
-    C.array() = (1.0-ao_factor*C.array());
-  }else
-  {
-    C.setConstant(1.0);
-  }
-  if(ao_normalize)
-  {
-    C.col(0) *= ((double)C.rows())/C.col(0).sum();
-    C.col(1) *= ((double)C.rows())/C.col(1).sum();
-    C.col(2) *= ((double)C.rows())/C.col(2).sum();
-  }
-  C.col(0) *= color(0);
-  C.col(1) *= color(1);
-  C.col(2) *= color(2);
-
-  glClearColor(back[0],back[1],back[2],0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  // All smooth points
-  glEnable( GL_POINT_SMOOTH );
-
-  glDisable(GL_LIGHTING);
-  if(lights_on)
-  {
-    lights();
-  }
-  push_scene();
-  glEnable(GL_DEPTH_TEST);
-  glDepthFunc(GL_LEQUAL);
-  glEnable(GL_NORMALIZE);
-  glEnable(GL_COLOR_MATERIAL);
-  glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-  push_object();
-
-  // Draw the model
-  // Set material properties
-  glEnable(GL_COLOR_MATERIAL);
-  igl::opengl2::draw_mesh(V,F,N,C);
-
-  pop_object();
-
-  // Draw a nice floor
-  glPushMatrix();
-  const double floor_offset =
-    -2./bbd*(V.col(1).maxCoeff()-mid(1));
-  glTranslated(0,floor_offset,0);
-  const float GREY[4] = {0.5,0.5,0.6,1.0};
-  const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  igl::opengl2::draw_floor(GREY,DARK_GREY);
-  glPopMatrix();
-
-  pop_scene();
-
-  igl::opengl::report_gl_error();
-
-  TwDraw();
-  glutSwapBuffers();
-  glutPostRedisplay();
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  switch(glutState)
-  {
-    case 1:
-      // up
-      glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
-      trackball_on = false;
-      break;
-    case 0:
-      // down
-      if(!tw_using)
-      {
-        glutSetCursor(GLUT_CURSOR_CYCLE);
-        // collect information for trackball
-        trackball_on = true;
-        copy(scene_rot,scene_rot+4,down_scene_rot);
-        down_mouse_x = mouse_x;
-        down_mouse_y = mouse_y;
-      }
-    break;
-  }
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-
-
-  if(trackball_on)
-  {
-    // Rotate according to trackball
-    trackball<float>(
-      width,
-      height,
-      2,
-      down_scene_rot,
-      down_mouse_x,
-      down_mouse_y,
-      mouse_x,
-      mouse_y,
-      scene_rot);
-  }else
-  {
-    TwEventMouseMotionGLUT(mouse_x, mouse_y);
-  }
-}
-
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  switch(key)
-  {
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-
-}
-
-
-int main(int argc, char * argv[])
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  // init mesh
-  string filename = "../shared/beast.obj";
-  if(argc < 2)
-  {
-    cerr<<"Usage:"<<endl<<"    ./example input.obj"<<endl;
-    cout<<endl<<"Opening default mesh..."<<endl;
-  }else
-  {
-    // Read and prepare mesh
-    filename = argv[1];
-  }
-
-  // dirname, basename, extension and filename
-  string d,b,ext,f;
-  pathinfo(filename,d,b,ext,f);
-  // Convert extension to lower case
-  transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-  vector<vector<double > > vV,vN,vTC;
-  vector<vector<int > > vF,vFTC,vFN;
-  if(ext == "obj")
-  {
-    // Convert extension to lower case
-    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
-    {
-      return 1;
-    }
-  }else if(ext == "off")
-  {
-    // Convert extension to lower case
-    if(!igl::readOFF(filename,vV,vF,vN))
-    {
-      return 1;
-    }
-  }else if(ext == "wrl")
-  {
-    // Convert extension to lower case
-    if(!igl::readWRL(filename,vV,vF))
-    {
-      return 1;
-    }
-  //}else
-  //{
-  //  // Convert extension to lower case
-  //  MatrixXi T;
-  //  if(!igl::readMESH(filename,V,T,F))
-  //  {
-  //    return 1;
-  //  }
-  //  //if(F.size() > T.size() || F.size() == 0)
-  //  {
-  //    boundary_facets(T,F);
-  //  }
-  }
-  if(vV.size() > 0)
-  {
-    if(!list_to_matrix(vV,V))
-    {
-      return 1;
-    }
-    polygon_mesh_to_triangle_mesh(vF,F);
-  }
-
-  // Compute normals, centroid, colors, bounding box diagonal
-  per_vertex_normals(V,F,N);
-  mid = 0.5*(V.colwise().maxCoeff() + V.colwise().minCoeff());
-  bbd = (V.colwise().maxCoeff() - V.colwise().minCoeff()).maxCoeff();
-
-  // Init embree
-  ei.init(V.cast<float>(),F.cast<int>());
-
-  // Init glut
-  glutInit(&argc,argv);
-
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("TweakBar");
-  rebar.TwAddVarRW("scene_rot", TW_TYPE_QUAT4F, &scene_rot, "");
-  rebar.TwAddVarRW("lights_on", TW_TYPE_BOOLCPP, &lights_on, "key=l");
-  rebar.TwAddVarRW("color", TW_TYPE_COLOR4F, color.data(), "colormode=hls");
-  rebar.TwAddVarRW("ao_factor", TW_TYPE_DOUBLE, &ao_factor, "min=0 max=1 step=0.2 keyIncr=] keyDecr=[ ");
-  rebar.TwAddVarRW("ao_normalize", TW_TYPE_BOOLCPP, &ao_normalize, "key=n");
-  rebar.TwAddVarRW("ao_on", TW_TYPE_BOOLCPP, &ao_on, "key=a");
-  rebar.TwAddVarRW("light_intensity", TW_TYPE_DOUBLE, &light_intensity, "min=0 max=0.4 step=0.1 keyIncr=} keyDecr={ ");
-  rebar.load(REBAR_NAME);
-
-  glutInitDisplayString( "rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
-  glutCreateWindow("ambient-occlusion");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
-  glutMainLoop();
-  return 0;
-}

+ 0 - 24
examples/arap/Makefile

@@ -1,24 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(YIMG_INC) $(SINGULAR_VALUE_DECOMPOSITION_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB) $(YIMG_LIB) 
-
-example: example.o
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) $(LIB) -o example $^
-
-%.o: %.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-%.o: %.cpp %.h
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 750
examples/arap/example.cpp

@@ -1,750 +0,0 @@
-#include <igl/Camera.h>
-#include <igl/opengl/OpenGL_convenience.h>
-#include <igl/PI.h>
-#include <igl/STR.h>
-#include <igl/arap.h>
-#include <igl/barycenter.h>
-#include <igl/cotmatrix.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/get_seconds.h>
-#include <igl/harmonic.h>
-#include <igl/invert_diag.h>
-#include <igl/jet.h>
-#include <igl/list_to_matrix.h>
-#include <igl/massmatrix.h>
-#include <igl/material_colors.h>
-#include <igl/matlab_format.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/partition.h>
-#include <igl/pathinfo.h>
-#include <igl/per_face_normals.h>
-#include <igl/per_vertex_normals.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/quat_to_mat.h>
-#include <igl/readDMAT.h>
-#include <igl/readMESH.h>
-#include <igl/readOBJ.h>
-#include <igl/readOFF.h>
-#include <igl/readWRL.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/snap_to_fixed_up.h>
-#include <igl/trackball.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/writeDMAT.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-
-#ifdef __APPLE__
-#  include <GLUT/glut.h>
-#else
-#  include <GL/glut.h>
-#endif
-
-#include <Eigen/Core>
-
-#include <vector>
-#include <iostream>
-#include <algorithm>
-
-struct State
-{
-  igl::Camera camera;
-} s;
-enum RotationType
-{
-  ROTATION_TYPE_IGL_TRACKBALL = 0,
-  ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
-  NUM_ROTATION_TYPES = 2,
-} rotation_type;
-bool is_rotating = false;
-int down_x,down_y;
-igl::Camera down_camera;
-bool is_animating = false;
-double animation_start_time = 0;
-double ANIMATION_DURATION = 0.5;
-Eigen::Quaterniond animation_from_quat;
-Eigen::Quaterniond animation_to_quat;
-// Use vector for range-based `for`
-std::vector<State> undo_stack;
-std::vector<State> redo_stack;
-bool paused = false;
-double t = 0;
-double pause_time = 0.0;
-
-void push_undo()
-{
-  undo_stack.push_back(s);
-  // Clear
-  redo_stack = std::vector<State>();
-}
-
-void undo()
-{
-  using namespace std;
-  if(!undo_stack.empty())
-  {
-    redo_stack.push_back(s);
-    s = undo_stack.front();
-    undo_stack.pop_back();
-  }
-}
-
-void redo()
-{
-  using namespace std;
-  if(!redo_stack.empty())
-  {
-    undo_stack.push_back(s);
-    s = redo_stack.front();
-    redo_stack.pop_back();
-  }
-}
-
-void TW_CALL set_rotation_type(const void * value, void * clientData)
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-  const RotationType old_rotation_type = rotation_type;
-  rotation_type = *(const RotationType *)(value);
-  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
-    old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
-  {
-    push_undo();
-    animation_from_quat = s.camera.m_rotation_conj;
-    snap_to_fixed_up(animation_from_quat,animation_to_quat);
-    // start animation
-    animation_start_time = get_seconds();
-    is_animating = true;
-  }
-}
-
-void TW_CALL get_rotation_type(void * value, void *clientData)
-{
-  RotationType * rt = (RotationType *)(value);
-  *rt = rotation_type;
-}
-
-// Width and height of window
-int width,height;
-// Position of light
-float light_pos[4] = {0.1,0.1,-0.9,0};
-// Vertex positions, normals, colors and centroid
-Eigen::MatrixXd V,U,N,C,mid;
-Eigen::VectorXi S;
-igl::ARAPData arap_data;
-Eigen::MatrixXi F,T;
-int selected_col = 0;
-// Faces
-// Bounding box diagonal length
-double bbd;
-int tot_num_samples = 0;
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
-
-int num_in_selection(const Eigen::VectorXi & S)
-{
-  int count = 0;
-  for(int v = 0;v<S.rows(); v++)
-  {
-    if(S(v) >= 0)
-    {
-      count++;
-    }
-  }
-  return count;
-}
-
-bool init_arap()
-{
-  using namespace igl;
-  using namespace Eigen;
-  using namespace std;
-  VectorXi b(num_in_selection(S));
-  assert(S.rows() == V.rows());
-  C.resize(S.rows(),3);
-  MatrixXd bc = MatrixXd::Zero(b.size(),S.maxCoeff()+1);
-  MatrixXi * Ele;
-  if(T.rows()>0)
-  {
-    Ele = &T;
-  }else
-  {
-    Ele = &F;
-  }
-  // get b from S
-  {
-    int bi = 0;
-    for(int v = 0;v<S.rows(); v++)
-    {
-      if(S(v) >= 0)
-      {
-        b(bi) = v;
-        bc(bi,S(v)) = 1;
-        bi++;
-        switch(S(v))
-        {
-          case 0:
-            C.row(v) = RowVector3d(0.039,0.31,1);
-            break;
-          case 1:
-            C.row(v) = RowVector3d(1,0.41,0.70);
-            break;
-          default:
-            C.row(v) = RowVector3d(0.4,0.8,0.3);
-            break;
-        }
-      }else
-      {
-        C.row(v) = RowVector3d(
-          GOLD_DIFFUSE[0],
-          GOLD_DIFFUSE[1],
-          GOLD_DIFFUSE[2]);
-      }
-    }
-  }
-  // Store current mesh
-  U = V;
-  VectorXi _S;
-  VectorXd _D;
-  MatrixXd W;
-  if(!harmonic(V,*Ele,b,bc,1,W))
-  {
-    return false;
-  }
-  arap_data.with_dynamics = true;
-  arap_data.h = 0.05;
-  //arap_data.max_iter = 100;
-  //partition(W,100,arap_data.G,_S,_D);
-  return arap_precomputation(V,*Ele,V.cols(),b,arap_data);
-}
-
-bool update_arap()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  MatrixXd bc(num_in_selection(S),V.cols());
-  // get b from S
-  {
-    if(!paused)
-    {
-      t = get_seconds()-pause_time;
-    }
-    int bi = 0;
-    for(int v = 0;v<S.rows(); v++)
-    {
-      if(S(v) >= 0)
-      {
-        bc.row(bi) = V.row(v);
-        switch(S(v))
-        {
-          case 0:
-          {
-            const double r = mid(0)*0.25;
-            bc(bi,0) += r*cos(0.5*t*2.*PI);
-            bc(bi,1) -= r+r*sin(0.5*t*2.*PI);
-            break;
-          }
-          case 1:
-          {
-            const double r = mid(1)*0.15;
-            bc(bi,1) += r+r*cos(0.15*t*2.*PI);
-            bc(bi,2) -= r*sin(0.15*t*2.*PI);
-
-            //// Pull-up
-            //bc(bi,0) += 0.42;//mid(0)*0.5;
-            //bc(bi,1) += 0.55;//mid(0)*0.5;
-            //// Bend
-            //Vector3d t(-1,0,0);
-            //Quaterniond q(AngleAxisd(PI/1.5,Vector3d(0,1.0,0.1).normalized()));
-            //const Vector3d a = bc.row(bi);
-            //bc.row(bi) = (q*(a-t) + t) + Vector3d(1.5,0.1,0.9);
-
-
-            break;
-          }
-          default:
-          break;
-        }
-        bi++;
-      }
-    }
-  }
-  if(!arap_solve(bc,arap_data,U))
-  {
-    cerr<<"arap_solve failed."<<endl;
-    return false;
-  }
-  per_face_normals(U,F,N);
-  return true;
-}
-
-void reshape(int width,int height)
-{
-  using namespace std;
-  // Save width and height
-  ::width = width;
-  ::height = height;
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-  // Set aspect for all cameras
-  s.camera.m_aspect = (double)width/(double)height;
-  for(auto & s : undo_stack)
-  {
-    s.camera.m_aspect = (double)width/(double)height;
-  }
-  for(auto & s : redo_stack)
-  {
-    s.camera.m_aspect = (double)width/(double)height;
-  }
-}
-
-void push_scene()
-{
-  using namespace igl;
-  using namespace std;
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  auto & camera = s.camera;
-  gluPerspective(camera.m_angle,camera.m_aspect,camera.m_near,camera.m_far);
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    camera.eye()(0), camera.eye()(1), camera.eye()(2),
-    camera.at()(0), camera.at()(1), camera.at()(2),
-    camera.up()(0), camera.up()(1), camera.up()(2));
-}
-
-void pop_scene()
-{
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-// Scale and shift for object
-void push_object()
-{
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-mid(0,0),-mid(0,1),-mid(0,2));
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  //glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  float amb[4];
-  amb[0] = amb[1] = amb[2] = 0;
-  amb[3] = 1.0;
-  float diff[4] = {0.0,0.0,0.0,0.0};
-  diff[0] = diff[1] = diff[2] = (1.0 - 0/0.4);;
-  diff[3] = 1.0;
-  float zeros[4] = {0.0,0.0,0.0,0.0};
-  float pos[4];
-  copy(light_pos,light_pos+4,pos);
-  glLightfv(GL_LIGHT0,GL_AMBIENT,amb);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,diff);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos);
-  pos[0] *= -1;
-  pos[1] *= -1;
-  pos[2] *= -1;
-  glLightfv(GL_LIGHT1,GL_AMBIENT,amb);
-  glLightfv(GL_LIGHT1,GL_DIFFUSE,diff);
-  glLightfv(GL_LIGHT1,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT1,GL_POSITION,pos);
-}
-
-//const float back[4] = {30.0/255.0,30.0/255.0,50.0/255.0,0};
-const float back[4] = {255.0/255.0,255.0/255.0,255.0/255.0,0};
-void display()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  // Update
-  update_arap();
-
-  glClearColor(back[0],back[1],back[2],0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  if(is_animating)
-  {
-    double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
-    if(t > 1)
-    {
-      t = 1;
-      is_animating = false;
-    }
-    const Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
-    s.camera.orbit(q.conjugate());
-  }
-
-  glDisable(GL_LIGHTING);
-  lights();
-  push_scene();
-  glEnable(GL_DEPTH_TEST);
-  glDepthFunc(GL_LESS);
-  glEnable(GL_NORMALIZE);
-  push_object();
-
-  // Draw the model
-  // Set material properties
-  //glDisable(GL_COLOR_MATERIAL);
-  //glMaterialfv(GL_FRONT, GL_AMBIENT,  GOLD_AMBIENT);
-  //glMaterialfv(GL_FRONT, GL_DIFFUSE,  GOLD_DIFFUSE  );
-  //glMaterialfv(GL_FRONT, GL_SPECULAR, GOLD_SPECULAR);
-  //glMaterialf (GL_FRONT, GL_SHININESS, 128);
-  //glMaterialfv(GL_BACK, GL_AMBIENT,  SILVER_AMBIENT);
-  //glMaterialfv(GL_BACK, GL_DIFFUSE,  FAST_GREEN_DIFFUSE  );
-  //glMaterialfv(GL_BACK, GL_SPECULAR, SILVER_SPECULAR);
-  //glMaterialf (GL_BACK, GL_SHININESS, 128);
-  glEnable(GL_COLOR_MATERIAL);
-
-  igl::opengl2::draw_mesh(U,F,N,C);
-  glDisable(GL_COLOR_MATERIAL);
-
-  pop_object();
-
-
-  // Draw a nice floor
-  glPushMatrix();
-  const double floor_offset =
-    -2./bbd*(V.col(1).maxCoeff()-mid(1));
-  glTranslated(0,floor_offset,0);
-  //const float GREY[4] = {0.5,0.5,0.6,1.0};
-  //const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-
-  //draw_floor(GREY,DARK_GREY);
-  igl::opengl2::draw_floor();
-  glPopMatrix();
-
-  pop_scene();
-
-  igl::opengl::report_gl_error();
-
-  TwDraw();
-  glutSwapBuffers();
-  //if(is_animating)
-  //{
-    glutPostRedisplay();
-  //}
-}
-
-void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  GLint viewport[4];
-  glGetIntegerv(GL_VIEWPORT,viewport);
-  if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
-  {
-    static double mouse_scroll_y = 0;
-    const double delta_y = 0.125*direction;
-    mouse_scroll_y += delta_y;
-    TwMouseWheel(mouse_scroll_y);
-    return;
-  }
-  push_undo();
-  auto & camera = s.camera;
-  if(wheel==0)
-  {
-    // factor of zoom change
-    double s = (1.-0.01*direction);
-    //// FOV zoom: just widen angle. This is hardly ever appropriate.
-    //camera.m_angle *= s;
-    //camera.m_angle = min(max(camera.m_angle,1),89);
-    camera.push_away(s);
-  }else
-  {
-    // Dolly zoom:
-    camera.dolly_zoom((double)direction*1.0);
-  }
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  switch(glutButton)
-  {
-    case GLUT_RIGHT_BUTTON:
-    case GLUT_LEFT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
-          is_rotating = false;
-          break;
-        case 0:
-          // down
-          if(!tw_using)
-          {
-            glutSetCursor(GLUT_CURSOR_CYCLE);
-            // collect information for trackball
-            is_rotating = true;
-            down_camera = s.camera;
-            down_x = mouse_x;
-            down_y = mouse_y;
-          }
-          break;
-      }
-      break;
-    }
-    // Scroll down
-    case 3:
-    {
-      mouse_wheel(0,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll up
-    case 4:
-    {
-      mouse_wheel(0,1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll left
-    case 5:
-    {
-      mouse_wheel(1,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll right
-    case 6:
-    {
-      mouse_wheel(1,1,mouse_x,mouse_y);
-      break;
-    }
-  }
-  glutPostRedisplay();
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace Eigen;
-
-  if(is_rotating)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    Quaterniond q;
-    auto & camera = s.camera;
-    switch(rotation_type)
-    {
-      case ROTATION_TYPE_IGL_TRACKBALL:
-      {
-        // Rotate according to trackball
-        igl::trackball<double>(
-          width,
-          height,
-          2.0,
-          down_camera.m_rotation_conj.coeffs().data(),
-          down_x,
-          down_y,
-          mouse_x,
-          mouse_y,
-          q.coeffs().data());
-          break;
-      }
-      case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
-      {
-        // Rotate according to two axis valuator with fixed up vector
-        two_axis_valuator_fixed_up(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-        break;
-      }
-      default:
-        break;
-    }
-    camera.orbit(q.conjugate());
-  }else
-  {
-    TwEventMouseMotionGLUT(mouse_x, mouse_y);
-  }
-  glutPostRedisplay();
-}
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  switch(key)
-  {
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    case ' ':
-      {
-        static double pause_start,pause_stop;
-        paused = !paused;
-        if(paused)
-        {
-          pause_start = get_seconds();
-        }else
-        {
-          pause_stop = get_seconds();
-          pause_time += (pause_stop-pause_start);
-        }
-        break;
-      }
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-
-  glutPostRedisplay();
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  // init mesh
-  string filename = "../shared/decimated-knight.obj";
-  string sfilename = "../shared/decimated-knight-selection.dmat";
-  //string filename = "../shared/decimated-knight.mesh";
-  //string sfilename = "../shared/decimated-knight-1-selection.dmat";
-  if(argc < 3)
-  {
-    cerr<<"Usage:"<<endl<<"    ./example input.obj selection.dmat"<<endl;
-    cout<<endl<<"Opening default mesh..."<<endl;
-  }else
-  {
-    // Read and prepare mesh
-    filename = argv[1];
-    sfilename = argv[2];
-  }
-  string d,b,ext,f;
-  pathinfo(filename,d,b,ext,f);
-  // Convert extension to lower case
-  transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-
-  vector<vector<double > > vV,vN,vTC;
-  vector<vector<int > > vF,vTF,vFN;
-  // Convert extension to lower case
-  if(ext == "obj")
-  {
-    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vTF,vFN))
-    {
-      return 1;
-    }
-  }else if(ext == "mesh")
-  {
-    if(!igl::readMESH(filename,V,T,F))
-    {
-      return 1;
-    }
-  }else
-  {
-    return 1;
-  }
-  if(vV.size() > 0)
-  {
-    if(!list_to_matrix(vV,V))
-    {
-      cerr<<"Bad V"<<endl;
-      return 1;
-    }
-    polygon_mesh_to_triangle_mesh(vF,F);
-  }
-  per_face_normals(V,F,N);
-
-  if(!readDMAT(sfilename,S))
-  {
-    return 1;
-  }
-
-  // Compute normals, centroid, colors, bounding box diagonal
-  mid = 0.5*(V.colwise().maxCoeff() + V.colwise().minCoeff());
-  bbd = (V.colwise().maxCoeff() - V.colwise().minCoeff()).maxCoeff();
-
-  // Init glut
-  glutInit(&argc,argv);
-
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("TweakBar");
-  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
-    s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  s.camera.push_away(3);
-  s.camera.dolly_zoom(25-s.camera.m_angle);
-  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString(
-     "RotationType",
-    "igl_trackball,two-a...-fixed-up");
-  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
-    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  rebar.load(REBAR_NAME);
-
-  glutInitDisplayString( "rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
-  glutCreateWindow("colored-mesh");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc(
-    [](int x, int y)
-    {
-      TwEventMouseMotionGLUT(x,y);
-      glutPostRedisplay();
-    });
-  static std::function<void(int)> timer_bounce;
-  auto timer = [] (int ms) {
-    timer_bounce(ms);
-  };
-  timer_bounce = [&] (int ms) {
-    glutTimerFunc(ms, timer, ms);
-    glutPostRedisplay();
-  };
-  glutTimerFunc(500, timer, 500);
-
-  if(!init_arap())
-  {
-    cerr<<"Initializing arap failed."<<endl;
-    return 1;
-  }
-
-  glutMainLoop();
-  return 0;
-}

+ 0 - 47
examples/bbw/Makefile

@@ -1,47 +0,0 @@
-include ../Makefile.conf
-
-CXX=g++
-
-LIBIGL_LIB+=-liglmosek -liglbbw -ligltetgen
-
-ifdef IGL_NO_MOSEK
-CFLAGS+=-DIGL_NO_MOSEK
-else
-# Adjust your mosek paths etc. accordingly
-ifndef MOSEKPLATFORM
-  MOSEKPLATFORM=osx64x86
-endif
-ifndef MOSEKVERSION
-  MOSEKVERSION=6
-endif
-MOSEK=/usr/local/mosek
-MOSEK_INC=-I$(MOSEK)/$(MOSEKVERSION)/tools/platform/$(MOSEKPLATFORM)/h
-MOSEK_LIB=-L$(MOSEK)/$(MOSEKVERSION)/tools/platform/$(MOSEKPLATFORM)/bin -lmosek64
-INC+=$(MOSEK_INC)
-endif
-
-INC=-I. ${EIGEN3_INC} ${LIBIGL_INC} ${TETGEN_INC} ${MOSEK_INC} 
-LIB=${TETGEN_LIB} ${MOSEK_LIB} ${OPENGL_LIB} ${GLUT_LIB} ${LIBIGL_LIB} 
-
-# Make file for bbw_demo
-.PHONY: all
-all: bbw_demo
-
-CPP_FILES=$(wildcard ./*.cpp)
-OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o))) 
-
-bbw_demo: obj $(OBJ_FILES)
-	$(CXX) -o bbw_demo $(CFLAGS) $(AFLAGS) $(OPENMP) $(OBJ_FILES) $(LIB)
-
-obj:
-	mkdir -p obj
-
-obj/%.o: %.cpp %.h
-	$(CXX) $(CFLAGS) $(AFLAGS) $(OPENMP) -o $@ -c $< $(INC)
-obj/%.o: %.cpp
-	$(CXX) $(CFLAGS) $(AFLAGS) $(OPENMP) -o $@ -c $< $(INC)
-
-.PHONY: clean
-clean:
-	rm -f $(OBJ_FILES)
-	rm -f bbw_demo

+ 0 - 112
examples/bbw/README

@@ -1,112 +0,0 @@
-This is a small program that illustrates how to compute Bounded Biharmonic
-Weights (BBW) for a given surface mesh and skeleton description. This only
-supports point handles and skeleton trees (bones). Cages are not supported.
-This program only computes and outputs the weight function values. You should
-be able to load them into matlab or maya or whatever.
-
-This demo (main.cpp) is really just a skeleton of function calls that load the
-input and writes the output. The real "meat" of the bbw demo is conducted in
-the bbw function of libigl. If you only want to look at that implementation,
-then download libigl and jump to libigl/include/igl/mosek/bbw.h and
-libigl/include/igl/mosek/bbw.cpp
-
-= Dependencies =
-
-The dependencies are:
-  libigl
-    eigen3
-    tetgen
-    mosek
-    libigl_tetgen
-    libigl_mosek
-
-  = libigl =
-  libigl is our groups internal library. The library functions as an inlined
-  header library and simultaneously a static library.
-  http://igl.ethz.ch/projects/libigl/
-
-  This demo depends on the libigl_tetgen and libigl_mosek extras that come with
-  libigl. You will have to edit your libigl Makefile.conf accordingly: set
-  IGL_WITH_TETGEN=1 and IGL_WITH_MOSEK=1 and then build the main libigl library
-  and the extras with:
-  
-  make lib
-  make extras
-  
-    = Eigen3 =
-    The libigl dependencies rely on a depracted version of the Sparse Matrix
-    suite in eigen 3. Thus you need the correct version of eigen. It's not
-    clear how much longer this will work with the current version of Eigen.
-  
-    = Mosek =
-    Mosek is free for academics and has its own installation instructions.
-    Adjust the makefile accordingly.
-  
-    = Tetgen =
-    Tetgen is also free and easy to install. Be sure to compile the library
-    version, i.e.: 
-      make tetlib
-  
-    To make life a little easier, libigl include a working version of tetgen in
-    libigl/external/tetgen/. You can go there and compile libtet.a or download
-    the tetgen source and do that on your own. Whatever.
-
-= COMPILE =
-
-First install the dependencies (eigen, tetgen, mosek, libigl).  If your on a
-mac, and why wouldn't you be, then you *should* with any luck and by the grace
-of God be able to compile with:
-
-  make
-
-= RUN =
-
-Then run an example with:
-
-  ./bbw_demo examples/brick.obj examples/brick.tgf
-
-This will produce at least 2 files:
-
-  examples/brick-volume.mesh  Tetrahedral mesh over which weights were computed
-  examples/brick-volume.dmat  Coefficients of weights defined over .mesh
-
-= File Formats =
-
-See libigl/file-formats/index.html
-
-= Zip =
-Package up this demo using:
-
-zip -9 -r -x=*/.hg/* -x=*un~  bbw_demo_3d.zip ../bbw
-
-= Contact =
-
-You can try to email Alec Jacobson (alecjacobson@gmail.com) with questions.
-Especially regarding the algorithm described in "Bounded biharmonic weights for
-real-time deformation" by [Jacobson et al. 2011].  However, please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-please
-try to solve compilation troubles on your own. I didn't intend for this code to
-be machine independent or even necessarily easy to compile. This is a quick and
-dirty demo because so many people requested it.
-
-Sometime in the not too distant future I still plan to release a *nice* 3d, C++
-demo. 
-
-Love,
-Alec

+ 0 - 272
examples/bbw/example.cpp

@@ -1,272 +0,0 @@
-
-#include <igl/pathinfo.h>
-#include <igl/readOBJ.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/faces_first.h>
-#include <igl/readTGF.h>
-#include <igl/launch_medit.h>
-#include <igl/boundary_conditions.h>
-#include <igl/writeDMAT.h>
-#include <igl/writeMESH.h>
-#include <igl/normalize_row_sums.h>
-#include <igl/bbw/bbw.h>
-#include <igl/tetgen/mesh_with_skeleton.h>
-
-#include <Eigen/Dense>
-
-#include <iostream>
-#include <string>
-
-// Whether medit program is install
-//#define WITH_MEDIT
-
-const char * USAGE=
-"Usage:\n"
-"  ./bbw_demo shape{.obj|.off|.mesh} skeleton{.tgf|.bf}\n"
-;
-
-// Read a surface mesh from a {.obj|.off|.mesh} files
-// Inputs:
-//   mesh_filename  path to {.obj|.off|.mesh} file
-// Outputs:
-//   V  #V by 3 list of mesh vertex positions
-//   F  #F by 3 list of triangle indices
-// Returns true only if successfuly able to read file
-bool load_mesh_from_file(
-  const std::string mesh_filename,
-  Eigen::MatrixXd & V,
-  Eigen::MatrixXi & F)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  string dirname, basename, extension, filename;
-  pathinfo(mesh_filename,dirname,basename,extension,filename);
-  transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
-  bool success = false;
-  if(extension == "obj")
-  {
-    success = readOBJ(mesh_filename,V,F);
-  }else if(extension == "off")
-  {
-    success = readOFF(mesh_filename,V,F);
-  }else if(extension == "mesh")
-  {
-    // Unused Tets read from .mesh file
-    MatrixXi Tets;
-    success = readMESH(mesh_filename,V,Tets,F);
-    // We're not going to use any input tets. Only the surface
-    if(Tets.size() > 0 && F.size() == 0)
-    {
-      // If Tets read, but no faces then use surface of tet volume
-    }else
-    {
-      // Rearrange vertices so that faces come first
-      VectorXi IM;
-      faces_first(V,F,IM);
-      // Dont' bother reordering Tets, but this is how one would:
-      //Tets = 
-      //  Tets.unaryExpr(bind1st(mem_fun( static_cast<VectorXi::Scalar&
-      //  (VectorXi::*)(VectorXi::Index)>(&VectorXi::operator())),
-      //  &IM)).eval();
-      // Don't throw away any interior vertices, since user may want weights
-      // there
-    }
-  }else
-  {
-    cerr<<"Error: Unknown shape file format extension: ."<<extension<<endl;
-    return false;
-  }
-  return success;
-}
-
-// Load a skeleton (bones, points and cage edges) from a {.bf|.tgf} file
-//
-// Inputs:
-//   skel_filename  path to skeleton {.bf|.tgf} file
-// Outputs:
-//  C  # vertices by 3 list of vertex positions
-//  P  # point-handles list of point handle indices
-//  BE # bone-edges by 2 list of bone-edge indices
-//  CE # cage-edges by 2 list of cage-edge indices
-bool load_skeleton_from_file(
-  const std::string skel_filename,
-  Eigen::MatrixXd & C,
-  Eigen::VectorXi & P,
-  Eigen::MatrixXi & BE,
-  Eigen::MatrixXi & CE)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  string dirname, basename, extension, filename;
-  pathinfo(skel_filename,dirname,basename,extension,filename);
-  transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
-  bool success = false;
-  if(extension == "tgf")
-  {
-    // Phony space for unused all edges and pseudo edges
-    MatrixXi E;
-    MatrixXi PE;
-    success = readTGF(skel_filename,C,E,P,BE,CE,PE);
-  }else
-  {
-    cerr<<"Error: Unknown skeleton file format extension: ."<<extension<<endl;
-    return false;
-  }
-  return success;
-}
-
-// Writes output files to /path/to/input/mesh-skeleton.dmat,
-// mesh-volume.dmat, mesh-volume.mesh if input mesh was
-// located at /path/to/input/mesh.obj and input skeleton was at
-// /other/path/to/input/skel.tgf
-// 
-// Writes:
-////   mesh.dmat  dense weights matrix corresponding to original input
-////     vertices V
-//   mesh-volume.dmat  dense weights matrix corresponding to all
-//     vertices in tet mesh used for computation VV
-//   mesh-volume.mesh  Tet mesh used for computation
-//
-// Inputs:
-//   mesh_filename  path to {.obj|.off|.mesh} file
-//   skel_filename  path to skeleton {.bf|.tgf} file
-//   V  #V by 3 list of original mesh vertex positions
-//   F  #F by 3 list of original triangle indices
-//   VV  #VV by 3 list of tet-mesh vertex positions
-//   TT  #TT by 4 list of tetrahedra indices
-//   FF  #FF by 3 list of surface triangle indices
-//   W   #VV by #W weights matrix
-// Returns true on success
-bool save_output(
-  const std::string mesh_filename,
-  const std::string /*skel_filename*/,
-  const Eigen::MatrixXd & V,
-  const Eigen::MatrixXi & /*F*/,
-  const Eigen::MatrixXd & VV,
-  const Eigen::MatrixXi & TT,
-  const Eigen::MatrixXi & FF,
-  const Eigen::MatrixXd & W)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  // build filename prefix out of input base names
-  string prefix = "";
-  {
-    string dirname, basename, extension, filename;
-    pathinfo(mesh_filename,dirname,basename,extension,filename);
-    transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
-    prefix += dirname + "/" + filename;
-  }
-
-  //{
-  //  string dirname, basename, extension, filename;
-  //  pathinfo(skel_filename,dirname,basename,extension,filename);
-  //  transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
-  //  prefix += "-" + filename;
-  //}
-
-  // Keep track if any fail
-  bool success = true;
-  //// Weights matrix for just V. Assumes V prefaces VV
-  //MatrixXd WV = W.block(0,0,V.rows(),W.cols());
-  //// write dmat
-  //success &= writeDMAT(prefix + ".dmat",WV);
-  // write volume weights dmat
-  success &= writeDMAT(prefix + "-volume.dmat",W);
-  // write volume mesh
-  success &= writeMESH(prefix + "-volume.mesh",VV,TT,FF);
-  //// write surface OBJ with pseudocolor
-  return success;
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  string mesh_filename = "examples/brick.obj";
-  string skeleton_filename = "examples/brick.tgf";
-  if(argc<3)
-  {
-    cerr<<USAGE<<endl;
-    cout<<endl<<"Using defaults..."<<endl;
-  }else
-  {
-    mesh_filename = argv[1];
-    skeleton_filename = argv[2];
-  }
-
-  // #V by 3 list of mesh vertex positions
-  MatrixXd V;
-  // #F by 3 list of triangle indices
-  MatrixXi F;
-  // load mesh from .obj, .off or .mesh
-  if(!load_mesh_from_file(mesh_filename,V,F))
-  {
-    return 1;
-  }
-  // "Skeleton" (handles) descriptors:
-  // List of control and joint (bone endpoint) positions
-  MatrixXd C;
-  // List of point handles indexing C
-  VectorXi P;
-  // List of bone edges indexing C
-  MatrixXi BE;
-  // List of cage edges indexing *P*
-  MatrixXi CE;
-  // load skeleton (.tgf or .bf)
-  if(!load_skeleton_from_file(skeleton_filename,C,P,BE,CE))
-  {
-    return 1;
-  }
-
-  // Mesh with samples on skeleton
-  // New vertices of tet mesh, V prefaces VV
-  MatrixXd VV;
-  // Tetrahedra
-  MatrixXi TT;
-  // New surface faces FF
-  MatrixXi FF;
-  if(!igl::tetgen::mesh_with_skeleton(V,F,C,P,BE,CE,10,VV,TT,FF))
-  {
-    return 1;
-  }
-#ifdef WITH_MEDIT
-  // If you have medit installed then it's convenient to visualize the tet mesh
-  // at this point
-  launch_medit(VV,TT,FF,false);
-#endif
-  // Compute boundary conditions (aka fixed value constraints)
-  // List of boundary indices (aka fixed value indices into VV)
-  VectorXi b;
-  // List of boundary conditions of each weight function
-  MatrixXd bc;
-  if(!boundary_conditions(VV,TT,C,P,BE,CE,b,bc))
-  {
-    return 1;
-  }
-
-  cout<<"b=["<<b<<"];"<<endl;
-  cout<<"bc=["<<bc<<"];"<<endl;
-
-  // compute BBW 
-  // Default bbw data and flags
-  igl::bbw::BBWData bbw_data;
-  bbw_data.qp_solver = igl::bbw::QP_SOLVER_IGL_ACTIVE_SET;
-  //bbw_data.qp_solver = igl::bbw::QP_SOLVER_MOSEK;
-  // Weights matrix
-  MatrixXd W;
-  if(!igl::bbw::bbw(VV,TT,b,bc,bbw_data,W))
-  {
-    return 1;
-  }
-  // Normalize weights to sum to one
-  normalize_row_sums(W,W);
-  // Save output
-  save_output(mesh_filename,skeleton_filename,V,F,VV,TT,FF,W);
-  return 0;
-}

+ 0 - 19
examples/bbw/examples/armadillo.bf

@@ -1,19 +0,0 @@
-0 -1 0.129257 0.422406 0.196763 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-1 -1 -0.152254 0.423852 0.169958 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
--1 -1 -0.0109722 0.173294 -0.0092734 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
--1 -1 -0.00468155 -0.13266 -0.125831 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-2 2 -0.0026014 0.097823 0.152078 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-3 2 -0.153069 -0.030196 0.021722 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-4 2 0.180203 -0.027431 0.0197277 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-5 3 -0.0956565 -0.008814 -0.004997 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-6 3 0.102697 0.001587 0.002381 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-13 5 -0.145449 0.018419 0.0492195 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-15 6 0.132523 0.037847 0.109096 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-7 7 -0.092032 -0.170904 0.0771798 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-10 8 0.119696 -0.165775 0.0816835 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-14 9 -0.071846 0.102468 0.0987159 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-16 10 0.055387 0.053723 0.10658 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-8 11 0.050883 -0.223767 -0.103315 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-11 12 -0.025665 -0.231096 -0.0767775 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-9 15 -0.070583 0.002246 0.0876127 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 
-12 16 0.079788 -0.001878 0.0786744 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 

+ 0 - 1
examples/bbw/examples/armadillo.obj.REMOVED.git-id

@@ -1 +0,0 @@
-fbec5d216516015b925b9fd2cb46a8ca91b45995

+ 0 - 36
examples/bbw/examples/armadillo.tgf

@@ -1,36 +0,0 @@
-   1 -0.0109722   0.173294 -0.0092734          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0    1 
-   2 -0.00468155   -0.13266  -0.125831          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0    3 
-   3 -0.0135736   0.271117   0.142805          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0    4 
-   4  -0.100338  -0.141474  -0.130828          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0    5 
-   5   -0.19237  -0.312378 -0.0536482          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0    6 
-   6  -0.141487  -0.536145  -0.156963          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0    7 
-   7   -0.21207  -0.533899 -0.0693503          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0    8 
-   8  0.0980157  -0.131073   -0.12345          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0    9 
-   9   0.217712  -0.296848 -0.0417665          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   10 
-  10   0.192047  -0.527944  -0.118544          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   11 
-  11   0.271835  -0.529822 -0.0398696          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   12 
-  12  -0.164041   0.143098  0.0124486          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   13 
-  13   -0.30949   0.161517  0.0616681          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   14 
-  14  -0.381336   0.263985   0.160384          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   15 
-  15   0.169231   0.145863  0.0104543          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   16 
-  16   0.301754    0.18371    0.11955          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   17 
-  17   0.357141   0.237433    0.22613          0          0          0 6.9532605e-310 2.3525269e-314 3.1373169e-321 2.1368449e-314 2.1219958e-314 6.953223e-310          1 2.1368449e-314 7.9050503e-323 2.1447907e-314          0   18 
-  18   0.129257   0.422406   0.196763          0 1.7604077e-310          0          1          1          1          0          0          0          1   1.078406    1.05751     1.1997          0   36 
-  19  -0.152254   0.423852   0.169958 2.1219958e-314 5.7559406e-09 3.9642947e-07          1          1          1          0          0          0          1   0.881232   1.047886   1.174727          0   37 
-#
-  15   16 1 0 0 0 34
-   8    9 1 0 0 0 29
-   2    8 1 0 0 0 25
-   2    4 1 0 0 0 24
-  13   14 1 0 0 0 33
-   6    7 1 0 0 0 28
-  16   17 1 0 0 0 35
-   4    5 1 0 0 0 26
-   9   10 1 0 0 0 30
-   5    6 1 0 0 0 27
-   1    3 1 0 0 0 19
-   1   15 1 0 0 0 20
-   1   12 1 0 0 0 22
-  10   11 1 0 0 0 31
-  12   13 1 0 0 0 32
-#

+ 0 - 1
examples/bbw/examples/brick.obj.REMOVED.git-id

@@ -1 +0,0 @@
-34a3aac9ef5d09124a85c97d0f135e3c24f32e85

+ 0 - 4
examples/bbw/examples/brick.tgf

@@ -1,4 +0,0 @@
-   1          4        0.5        0.5 6.9532423e-310 6.9532423e-310 6.9532423e-310          1          1          1          0          0          0          1      4.125     1.1875        1.5          0    1 
-   2          0        0.5        0.5 9.8813129e-324          0 2.1219958e-314          1          1          1          0          0          0          1 0.040798319 0.48263485  3.1593933          0    3 
-#
-#

+ 0 - 13
examples/bbw/examples/gargoyle-skeleton-4-points.tgf

@@ -1,13 +0,0 @@
-1 0.281152 0.703812 0.17955 0.281152 0.703812 0.17955 1 1 1 0 0 0 1 0 0 0 
-2 0.279014 0.78407 0.281131 0.279014 0.78407 0.281131 1 1 1 0 0 0 1 0 0 0 
-3 0.283274 0.798735 0.427544 0.283274 0.798735 0.427544 1 1 1 0 0 0 1 0 0 0 
-4 0.289027 0.352549 0.175056 0.289027 0.352549 0.175056 1 1 1 0 0 0 1 0 0 0 
-5 0.533399 0.97653 0.053801 0.533399 0.97653 0.053801 1 1 1 0 0 0 1 0 0 0 
-6 0.0164236 0.986867 0.0583015 0.0164236 0.986867 0.0583015 1 1 1 0 0 0 1 0 0 0 
-7 0.371475 0.764257 0.180104 1.02184e-193 1.2683e-314 -9.18791e-189 1 1 1 0 0 0 1 0.998461 0.98759 1.1801 
-8 0.205292 0.774223 0.177497 2.5518e-300 1.2683e-314 -9.18791e-189 1 1 1 0 0 0 1 1.02601 0.988331 1.1775 
-#
-1 4 1 1 0
-1 2 1 1 0
-2 3 1 1 0
-#

+ 0 - 1
examples/bbw/examples/gargoyle.obj.REMOVED.git-id

@@ -1 +0,0 @@
-67232d7546e073aef29d1008e4d71bac5d3801d0

+ 0 - 8
examples/bbw/examples/toy.tgf

@@ -1,8 +0,0 @@
-   1 0.022050698  0.2184666 0.048204916          0          1          0          1          1          1          0          0          0          1          1          1          1          0    1 
-   2 -0.00082061799 0.078092507 0.016942195          0       1440        874          1          1          1          0          0          0          1 0.99682216 0.89773834 0.97767308          0    2 
-   3 0.0026832858 -0.027061348 -0.0057913033          0          1          0          1          1          1          0          0          0          1   1.002247 0.89798112 0.97790599          0    4 
-   4 0.19749935 -0.54836793 -0.11514182          0 1.7604077e-310          0          1          1          1          0          0          0          1  1.1906136 0.18666707  1.0466804          0    6 
-#
-   1    2 1 1 0 0 3
-   2    3 1 1 0 0 5
-#

+ 0 - 236
examples/beach-balls/BeachBall.cpp

@@ -1,236 +0,0 @@
-#include "BeachBall.h"
-
-
-#include <igl/opengl2/draw_beach_ball.h>
-#include <igl/quat_to_mat.h>
-#include <igl/opengl2/unproject_to_zero_plane.h>
-#include <igl/opengl2/unproject.h>
-#include <igl/opengl2/project.h>
-#include <igl/quat_mult.h>
-#include <igl/quat_conjugate.h>
-#include <igl/trackball.h>
-#include <igl/mat_to_quat.h>
-
-#include <OpenGL/GL.h>
-
-#include <iostream>
-#include <cmath>
-
-BeachBall::BeachBall():
-  radius(1),
-  is_hover(false),
-  is_down(false),
-  trackball_on(false),
-  down_x(-1),
-  down_y(-1)
-{
-  r[0]=r[1]=r[2]=0;r[3]=1;
-  t[0]=t[1]=t[2]=0;t[3]=0;
-}
-
-void BeachBall::pushmv() const
-{
-  glPushMatrix();
-  glLoadIdentity();
-  glMultMatrixd(mv);
-}
-void BeachBall::popmv() const
-{
-  glPopMatrix();
-}
-
-void BeachBall::push() const
-{
-  using namespace igl;
-  glPushMatrix();
-  // Translate to relative origin
-  glTranslated(t[0],t[1],t[2]);
-  // Rotate to relative orientation
-  double mat[4*4]; quat_to_mat(r,mat); glMultMatrixd(mat);
-}
-void BeachBall::pop() const
-{
-  glPopMatrix();
-}
-
-void BeachBall::draw()
-{
-  using namespace std;
-  using namespace igl;
-  // Keep track of relative identity (modelview) matrix at draw call
-  glGetDoublev(GL_MODELVIEW_MATRIX,mv);
-  push();
-  // Dim if hovered over
-  float ld[4];
-  glGetLightfv(GL_LIGHT0,GL_DIFFUSE,ld);
-  if(is_hover)
-  {
-    float ld_hover[4];
-    ld_hover[0] = 0.5*ld[0];
-    ld_hover[1] = 0.5*ld[1];
-    ld_hover[2] = 0.5*ld[2];
-    ld_hover[3] = 0.5*ld[3];
-    glLightfv(GL_LIGHT0,GL_DIFFUSE,ld_hover);
-  }
-  // Adjust scale only after setting origin
-  glPushMatrix();
-  glScaled(radius,radius,radius);
-  // draw oriented glyph 
-  igl::opengl2::draw_beach_ball();
-  // Pop scale
-  glPopMatrix();
-  // Reset lighting
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,ld);
-  // Reset relative identity
-  pop();
-}
-
-bool BeachBall::in(const int x,const int y) const
-{
-  using namespace igl;
-  using namespace std;
-  pushmv();
-  push();
-  // Now origin is center of object
-  double obj[3];
-  // Check if igl::opengl2::unprojected screen point is nearby
-  igl::opengl2::unproject_to_zero_plane(x,y, &obj[0], &obj[1], &obj[2]);
-  bool near = (obj[0]*obj[0] + obj[1]*obj[1] + obj[2]*obj[2])<radius*radius;
-  pop();
-  popmv();
-  return near;
-}
-
-bool BeachBall::hover(const int x,const int y)
-{
-  return is_hover = in(x,y);
-}
-
-bool BeachBall::down(const int x,const int y)
-{
-  using namespace std;
-  using namespace igl;
-  is_down = in(x,y);
-  if(is_down)
-  {
-    copy(r,r+4,down_r);
-    copy(t,t+4,down_t);
-    down_x = x;
-    down_y = y;
-    trackball_on = true;
-  }
-  return is_down;
-}
-
-bool BeachBall::drag(const int x,const int y)
-{
-  using namespace igl;
-  using namespace std;
-  if(!is_down)
-  {
-    return false;
-  }
-  if(trackball_on)
-  {
-    // Pick up origin location
-    pushmv();
-    push();
-    double origin[3];
-    igl::opengl2::project(0,0,0,&origin[0],&origin[1],&origin[2]);
-    pop();
-    popmv();
-    double rot[4];
-    int VP[4];
-    glGetIntegerv(GL_VIEWPORT,VP);
-    trackball<double>(
-      VP[2],
-      VP[3],
-      2,
-            (down_x-origin[0]+VP[2]/2),
-      VP[3]-(down_y-origin[1]+VP[3]/2),
-            (     x-origin[0]+VP[2]/2),
-      VP[3]-(     y-origin[1]+VP[3]/2),
-      rot);
-    {
-      // We've computed change in rotation according to this view:
-      // R = mv * r, R' = rot * (mv * r)
-      // But we only want new value for r:
-      // R' = mv * r'
-      // mv * r' = rot * (mv * r)
-      // r' = mv* * rot * sr * r
-      // Convert modelview matrix to quaternion
-      double sr_conj[4],scene_rot[4],t1[4],t2[4];
-      mat4_to_quat(mv,scene_rot);
-      //cout<<"::sr: "<<
-      //  BeachBall::scene_rot[0]<<" "<<
-      //  BeachBall::scene_rot[1]<<" "<<
-      //  BeachBall::scene_rot[2]<<" "<<
-      //  BeachBall::scene_rot[3]<<" "<<
-      //  endl;
-      //cout<<"  sr: "<<
-      //  scene_rot[0]<<" "<<
-      //  scene_rot[1]<<" "<<
-      //  scene_rot[2]<<" "<<
-      //  scene_rot[3]<<" "<<
-      //  endl;
-      // Normalize to unit quaternion (rotation only)
-      double len = 
-        sqrt(scene_rot[0]*scene_rot[0]+
-        scene_rot[1]*scene_rot[1]+
-        scene_rot[2]*scene_rot[2]+
-        scene_rot[3]*scene_rot[3]);
-      for(int j = 0;j<4;j++)
-      {
-        scene_rot[j] /= len;
-      }
-      // TODO: Just use Eigen::Quaterniond
-      quat_conjugate(scene_rot,sr_conj);
-      quat_mult<double>(sr_conj,rot,t1);
-      quat_mult<double>(t1,scene_rot,t2);
-      quat_mult<double>(t2,down_r,r);
-
-    }
-  }else
-  {
-    // We want that origin follows mouse move. First define plane we
-    // igl::opengl2::projecteing screen mouse movement to as perpendicular plan passing
-    // through this origin.
-    pushmv();
-    // down_t igl::opengl2::projected to screen to get depth value
-    double p[3];
-    igl::opengl2::project(down_t[0],down_t[1],down_t[2],&p[0],&p[1],&p[2]);
-    // igl::opengl2::unprojected down_x,down_y with down_t depth
-    double du[3];
-    igl::opengl2::unproject(down_x,down_y,p[2],&du[0],&du[1],&du[2]);
-    // igl::opengl2::unprojected x,y with down_t depth
-    double u[3];
-    igl::opengl2::unproject(x,y,p[2],&u[0], &u[1], &u[2]);
-    popmv();
-    // Then move this origin according to igl::opengl2::project mouse displacment
-    t[0] = down_t[0] + (u[0]-du[0]);
-    t[1] = down_t[1] + (u[1]-du[1]);
-    t[2] = down_t[2] + (u[2]-du[2]);
-  }
-  return is_down;
-}
-
-bool BeachBall::right_down(const int x,const int y)
-{
-  using namespace std;
-  using namespace igl;
-  is_down = in(x,y);
-  if(is_down)
-  {
-    copy(r,r+4,down_r);
-    copy(t,t+4,down_t);
-    down_x = x;
-    down_y = y;
-  }
-  return is_down;
-}
-
-bool BeachBall::up(const int /*x*/,const int /*y*/)
-{
-  trackball_on = false;
-  return is_down = false;
-}

+ 0 - 61
examples/beach-balls/BeachBall.h

@@ -1,61 +0,0 @@
-#ifndef BEACHBALL_H
-#define BEACHBALL_H
-class BeachBall
-{
-  public:
-    static double * scene_rot;
-  public:
-    // Rigid transformation: rotation as quaternion
-    double r[4];
-    // Rigid transformation: translation as quaternion
-    double t[4];
-    double radius;
-  protected:
-    bool is_hover;
-    bool is_down;
-    // trackball
-    bool trackball_on;
-    // Rigid transformation at down
-    double down_r[4];
-    double down_t[4];
-    // query position at down
-    int down_x;
-    int down_y;
-    // modelview matrix at draw 
-    double mv[16];
-  public:
-    BeachBall();
-    // Push the latest modelview matrix seen at draw time onto the stack
-    void pushmv() const;
-    // Pop the stack
-    void popmv() const;
-    // Push rigid transformation onto the stack
-    void push() const;
-    // Pop the stack
-    void pop() const;
-    // Draw and cache the modelview matrix
-    void draw();
-    // Return whether (x,y) in screenspace is "inside" (hitting)
-    bool in(const int x,const int y) const;
-    // Called on passive mouse move to (x,y)
-    //
-    // Return whether (x,y) is hovering over, set is_hover accordingly
-    bool hover(const int x,const int y);
-    // Called on mouse down at (x,y)
-    //
-    // Return whether (x,y) is down, set is_down accordingly
-    bool down(const int x,const int y);
-    // Called on mouse drag to (x,y)
-    //
-    // Returns whether still is_down
-    bool drag(const int x,const int y);
-    // Called on right mouse down at (x,y)
-    //
-    // Return whether (x,y) is down, set is_down accordingly
-    bool right_down(const int x,const int y);
-    // Called on mouse up at (x,y)
-    //
-    // Returns whether still is_down
-    bool up(const int x,const int y);
-};
-#endif

+ 0 - 32
examples/beach-balls/Makefile

@@ -1,32 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: obj example
-
-.PHONY: example
-
-CFLAGS+=-g -std=c++11
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(GLUT_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB)
-
-CPP_FILES=$(wildcard ./*.cpp)
-OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o))) 
-
-example: obj $(OBJ_FILES)
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -o example $(OBJ_FILES) $(LIB)
-
-obj:
-	mkdir -p obj
-
-obj/%.o: %.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-obj/%.o: %.cpp %.h
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-clean:
-	rm -f $(OBJ_FILES)
-	rm -f example

+ 0 - 272
examples/beach-balls/example.cpp

@@ -1,272 +0,0 @@
-#include "BeachBall.h"
-
-#include <igl/quat_to_mat.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/trackball.h>
-#include <igl/canonical_quaternions.h>
-#include <igl/PI.h>
-
-#include <GLUT/GLUT.h>
-
-#include <iostream>
-#include <algorithm>
-#include <vector>
-#include <cmath>
-
-double back[3] = {85.0/255.0,85.0/255.0,85.0/255.0};
-double width,height;
-double scene_rot[4] = {0,0,0,1};
-double * BeachBall::scene_rot = NULL;
-double down_scene_rot[4] = {0,0,0,1};
-int down_mouse_x=-1,down_mouse_y=-1;
-bool trackball_on = false;
-const float light_pos[4] = {-0.2, -0.1, 1,0};
-
-std::vector<BeachBall> balls;
-float plane[4] = {0,0,1,1.5};
-
-int display_count = 0;
-
-void push_scene()
-{
-  using namespace igl;
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  //gluOrtho2D(0,width,0,height);
-  gluPerspective(15,(double)width/(double)height,1e-2,300);
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-  glPushMatrix();
-  gluLookAt(0,0,20,0,0,0,0,1,0);
-  double mat[4*4];
-  quat_to_mat(scene_rot,mat);
-  glMultMatrixd(mat);
-}
-
-void lights()
-{
-  using namespace std;
-  using namespace igl;
-
-  glEnable(GL_LIGHTING);
-  float ones[4] = {1.0,1.0,1.0,1.0};
-  glLightfv(GL_LIGHT0,GL_AMBIENT,ones);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,ones);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,ones);
-  glLightfv(GL_LIGHT0,GL_POSITION,light_pos);
-  glEnable(GL_LIGHT0);
-}
-
-void pop_scene()
-{
-  glPopMatrix();
-}
-
-void display()
-{
-  using namespace std;
-  using namespace igl;
-
-  glEnable(GL_BLEND);
-  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
-  if(true || display_count==0 || display_count==200)
-  {
-    glClearColor(back[0],back[1],back[2],0);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-    glEnable(GL_DEPTH_TEST);
-    
-    lights();
-    push_scene();
-
-    //// Normal list
-    //for(int i = 0;i<(int)balls.size();i++)
-    //{
-    //  balls[i].draw();
-    //}
-
-    // single root
-    balls[0].draw();
-    balls[0].push();
-    for(int i = 1;i<(int)balls.size();i++)
-    {
-      balls[i].radius = 0.5;
-      balls[i].draw();
-    }
-    balls[0].pop();
-
-  // Draw floor
-    glEnable(GL_COLOR_MATERIAL);
-    glEnable(GL_POLYGON_OFFSET_FILL);
-    glPolygonOffset(10.0,1);
-    float size = 10;
-    glBegin(GL_QUADS);
-    glNormal3f(0,0,1);
-    glColor4f(0,0.2,0.8,0.5);
-    glVertex4f(-size,-size,-plane[3],1);
-    glColor4f(0,0,1,0.5);
-    glVertex4f( size,-size,-plane[3],1);
-    glColor4f(0.0,0.1,0.5,0.5);
-    glVertex4f( size, size,-plane[3],1);
-    //glColor4f(back[0],back[1],back[2],1);
-    glColor4f(0.0,0.1,0.5,0.5);
-    glVertex4f(-size, size,-plane[3],1);
-    glEnd();
-    glDisable(GL_POLYGON_OFFSET_FILL);
-    pop_scene();
-  }
-
-
-  //// Animation
-  //for(int i = 0;i<(int)balls.size();i++)
-  //{
-  //  balls[i].r[0] += cos(double(i*display_count)/1000.0) + sin(double(display_count)/1000.0);
-  //  balls[i].r[1] += sin(double(2*i*display_count)/1000.0) + cos(double(2*display_count)/1000.0);
-  //  balls[i].r[2] += cos(double(3*i*display_count)/1000.0) + sin(double(3*display_count)/1000.0);
-  //  balls[i].r[3] += sin(double(4*i*display_count)/1000.0) + cos(double(4*display_count)/1000.0);
-  //  double len = 
-  //    sqrt(balls[i].r[0]*balls[i].r[0]+
-  //    balls[i].r[1]*balls[i].r[1]+
-  //    balls[i].r[2]*balls[i].r[2]+
-  //    balls[i].r[3]*balls[i].r[3]);
-  //  for(int j = 0;j<4;j++)
-  //  {
-  //    balls[i].r[j] /= len;
-  //  }
-  //}
-
-  igl::opengl::report_gl_error();
-  glutSwapBuffers();
-  glutPostRedisplay();
-
-  display_count++;
-}
-
-void reshape(int width, int height)
-{
-  using namespace std;
-  ::width = width;
-  ::height = height;
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  glViewport(0,0,width,height);
-}
-
-void key(unsigned char key, int /*mouse_x*/, int /*mouse_y*/)
-{
-  using namespace std;
-
-  switch(key)
-  {
-    case char(27):
-      exit(0);
-    default:
-      cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-  }
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  mouse_y = height-mouse_y;
-  using namespace std;
-  push_scene();
-  if(glutState==1)
-  {
-    for(int i = 0;i<(int)balls.size();i++)
-    {
-      balls[i].up(mouse_x,mouse_y);
-      balls[i].hover(mouse_x,mouse_y);
-    }
-    trackball_on = false;
-  }else if(glutState==0)
-  {
-    // down
-    bool any = false;
-    for(int i = 0;!any && i<(int)balls.size();i++)
-    {
-      if(glutButton==0)
-      {
-        any |= balls[i].down(mouse_x,mouse_y);
-      }else if(glutButton==2)
-      {
-        any |= balls[i].right_down(mouse_x,mouse_y);
-      }
-    }
-    trackball_on = !any;
-    copy(scene_rot,scene_rot+4,down_scene_rot);
-    down_mouse_x = mouse_x;
-    down_mouse_y = mouse_y;
-  }
-  pop_scene();
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  mouse_y = height-mouse_y;
-  using namespace std;
-  using namespace igl;
-  if(trackball_on)
-  {
-    trackball<double>(
-      width,
-      height,
-      2,
-      down_scene_rot,
-      down_mouse_x,
-      height-down_mouse_y,
-      mouse_x,
-      height-mouse_y,
-      scene_rot);
-  }
-  push_scene();
-  for(int i = 0;i<(int)balls.size();i++)
-  {
-    balls[i].drag(mouse_x,mouse_y);
-  }
-  pop_scene();
-
-}
-
-void mouse_move(int mouse_x, int mouse_y)
-{
-  mouse_y = height-mouse_y;
-  push_scene();
-  bool any = false;
-  for(int i = 0;!any && i<(int)balls.size();i++)
-  {
-    any |= balls[i].hover(mouse_x,mouse_y);
-  }
-  pop_scene();
-}
-
-
-int main(int argc,char * argv[])
-{
-  using namespace igl;
-  using namespace std;
-  glutInit(&argc,argv);
-  glutInitDisplayString( "rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH),glutGet(GLUT_SCREEN_HEIGHT)/2);
-  glutCreateWindow(__FILE__);
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc(mouse_move);
-
-  //copy(XZ_PLANE_QUAT_D,XZ_PLANE_QUAT_D+4,scene_rot);
-
-  balls.push_back(BeachBall());
-  const int children = 10;
-  for(int i = 1;i<=children;i++)
-  {
-    balls.push_back(BeachBall());
-    balls[i].t[0] = 2.5*sin(double(i)*2.0*PI/double(children));
-    balls[i].t[1] = 2.5*cos(double(i)*2.0*PI/double(children));
-  }
-  BeachBall::scene_rot = scene_rot;
-
-  glutMainLoop();
-  return 0;
-}

+ 0 - 32
examples/camera/Makefile

@@ -1,32 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: obj example
-
-.PHONY: example
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(GLUT_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB)
-
-CPP_FILES=$(wildcard ./*.cpp)
-OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o))) 
-
-CFLAGS+=-std=c++11 -g -O0
-
-example: obj $(OBJ_FILES)
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -o example $(OBJ_FILES) $(LIB)
-
-obj:
-	mkdir -p obj
-
-obj/%.o: %.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-obj/%.o: %.cpp %.h
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-clean:
-	rm -f $(OBJ_FILES)
-	rm -f example

+ 0 - 697
examples/camera/example.cpp

@@ -1,697 +0,0 @@
-
-#include <igl/Viewport.h>
-#include <igl/Camera.h>
-#include <igl/matlab_format.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-#include <igl/trackball.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/PI.h>
-#include <igl/EPS.h>
-#include <igl/get_seconds.h>
-#include <igl/material_colors.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/readOFF.h>
-#include <igl/per_face_normals.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/opengl2/project.h>
-#include <igl/opengl2/unproject.h>
-
-#include <Eigen/Core>
-#include <Eigen/Geometry>
-
-#ifdef __APPLE__
-#include <GLUT/glut.h>
-#else
-#include <GL/glut.h>
-#endif
-
-#ifndef GLUT_WHEEL_UP
-#define GLUT_WHEEL_UP    3
-#endif
-#ifndef GLUT_WHEEL_DOWN
-#define GLUT_WHEEL_DOWN  4
-#endif
-#ifndef GLUT_WHEEL_RIGHT
-#define GLUT_WHEEL_RIGHT 5
-#endif
-#ifndef GLUT_WHEEL_LEFT
-#define GLUT_WHEEL_LEFT  6
-#endif
-#ifndef GLUT_ACTIVE_COMMAND
-#define GLUT_ACTIVE_COMMAND 8
-#endif
-
-#include <vector>
-#include <stack>
-#include <iostream>
-#include <algorithm>
-
-
-enum RotationType
-{
-  ROTATION_TYPE_IGL_TRACKBALL = 0,
-  ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
-  NUM_ROTATION_TYPES = 2,
-} rotation_type = ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP;
-
-enum CenterType
-{
-  CENTER_TYPE_ORBIT = 0,
-  CENTER_TYPE_FPS  = 1,
-  NUM_CENTER_TYPES = 2,
-} center_type = CENTER_TYPE_ORBIT;
-
-int width,height;
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar;
-struct State
-{
-  std::vector<igl::Camera> cameras;
-  std::vector<GLuint> tex_ids;
-  std::vector<GLuint> fbo_ids;
-  std::vector<GLuint> dfbo_ids;
-  State():cameras(4),
-    tex_ids(cameras.size()),
-    fbo_ids(cameras.size()),
-    dfbo_ids(cameras.size())
-    {}
-} s;
-const Eigen::Vector4d back(1,1,1,1);
-std::stack<State> undo_stack;
-bool is_rotating = false;
-igl::Camera down_camera;
-int down_x,down_y;
-std::stack<State> redo_stack;
-Eigen::MatrixXd V,N;
-Eigen::MatrixXi F;
-Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
-
-void push_undo()
-{
-  undo_stack.push(s);
-  // Clear
-  redo_stack = std::stack<State>();
-}
-
-void undo()
-{
-  if(!undo_stack.empty())
-  {
-    redo_stack.push(s);
-    s = undo_stack.top();
-    undo_stack.pop();
-  }
-}
-
-void redo()
-{
-  if(!redo_stack.empty())
-  {
-    undo_stack.push(s);
-    s = redo_stack.top();
-    redo_stack.pop();
-  }
-}
-
-void print(const igl::Camera & camera)
-{
-  using namespace std;
-  cout<<
-    "rotation:    "<<camera.m_rotation_conj.conjugate().coeffs().transpose()<<endl<<
-    "translation: "<<camera.m_translation.transpose()<<endl<<
-    "eye:         "<<camera.eye().transpose()<<endl<<
-    "at:          "<<camera.at().transpose()<<endl<<
-    "up:          "<<camera.up().transpose()<<endl<<
-    endl;
-}
-
-void init_cameras()
-{
-  using namespace Eigen;
-  using namespace std;
-  s.cameras[0].look_at(
-    Vector3d(0,0,1),
-    Vector3d(0,0,0),
-    Vector3d(0,1,0));
-  s.cameras[1].look_at(
-    Vector3d(0,0,-1),
-    Vector3d(0,0,0),
-    Vector3d(0,1,0));
-  s.cameras[2].look_at(
-    Vector3d(-2,0,0),
-    Vector3d(0,0,0),
-    Vector3d(0,1,0));
-  s.cameras[3].look_at(
-    Vector3d(3,0,0),
-    Vector3d(0,0,0),
-    Vector3d(0,1,0));
-}
-
-bool init_render_to_texture(
-  const int width, 
-  const int height, 
-  GLuint & tex_id, 
-  GLuint & fbo_id, 
-  GLuint & dfbo_id)
-{
-  using namespace igl;
-  using namespace std;
-  // Set up a "render-to-texture" frame buffer and texture combo
-  glDeleteTextures(1,&tex_id);
-  glDeleteFramebuffersEXT(1,&fbo_id);
-  glDeleteFramebuffersEXT(1,&dfbo_id);
-  // http://www.opengl.org/wiki/Framebuffer_Object_Examples#Quick_example.2C_render_to_texture_.282D.29
-  glGenTextures(1, &tex_id);
-  glBindTexture(GL_TEXTURE_2D, tex_id);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-  //NULL means reserve texture memory, but texels are undefined
-  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
-  glBindTexture(GL_TEXTURE_2D, 0);
-  //-------------------------
-  glGenFramebuffersEXT(1, &fbo_id);
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id);
-  //Attach 2D texture to this FBO
-  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex_id, 0);
-  glGenRenderbuffersEXT(1, &dfbo_id);
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, dfbo_id);
-  glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
-  //-------------------------
-  //Attach depth buffer to FBO
-  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, dfbo_id);
-  //-------------------------
-  //Does the GPU support current FBO configuration?
-  GLenum status;
-  status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-  switch(status)
-  {
-    case GL_FRAMEBUFFER_COMPLETE_EXT:
-      break;
-    default:
-      return false;
-  }
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-  return true;
-}
-
-void reshape(int width, int height)
-{
-  ::width = width;
-  ::height = height;
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-}
-
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  using namespace Eigen;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  float WHITE[4] =  {0.8,0.8,0.8,1.};
-  float GREY[4] =  {0.4,0.4,0.4,1.};
-  float BLACK[4] =  {0.,0.,0.,1.};
-  Vector4f pos = light_pos;
-  glLightfv(GL_LIGHT0,GL_AMBIENT,GREY);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,BLACK);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos.data());
-}
-
-void draw_scene(const igl::Camera & v_camera,
-  const bool render_to_texture,
-  const GLuint & v_tex_id, 
-  const GLuint & v_fbo_id, 
-  const GLuint & v_dfbo_id)
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-
-  if(render_to_texture)
-  {
-    // render to framebuffer
-    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, v_fbo_id);
-    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, v_dfbo_id);
-    glClearColor(back(0),back(1),back(2),1);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  }
-
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  glMultMatrixd(v_camera.projection().data());
-  //{
-  //  Matrix4d m;
-  //  glGetDoublev(GL_PROJECTION_MATRIX,m.data());
-  //  cout<<matlab_format(m,"Camera")<<endl;
-  //}
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    v_camera.eye()(0), v_camera.eye()(1), v_camera.eye()(2),
-    v_camera.at()(0), v_camera.at()(1), v_camera.at()(2),
-    v_camera.up()(0), v_camera.up()(1), v_camera.up()(2));
-  //glLoadIdentity();
-  //glMultMatrixd(v_camera.inverse().matrix().data());
-
-  for(int c = 0;c<(int)s.cameras.size();c++)
-  {
-    auto & camera = s.cameras[c];
-    if(&v_camera == &camera)
-    {
-      continue;
-    }
-    // draw camera
-    glPushMatrix();
-    glMultMatrixd(camera.affine().matrix().data());
-    // eye
-    glColor4f(0,0,0,1);
-    glPointSize(10.f);
-    glBegin(GL_POINTS);
-    glVertex3f(0,0,0);
-    glEnd();
-    // frustrum
-    const Vector3d u = camera.unit_plane();
-    glBegin(GL_LINES);
-    for(int x = -1;x<=1;x+=2)
-    {
-      for(int y = -1;y<=1;y+=2)
-      {
-        glVertex3f(0,0,0);
-        glVertex3f(x*u(0),y*u(1),u(2));
-      }
-    }
-    glEnd();
-    const Vector3d n = u*(camera.m_near-FLOAT_EPS);
-    glBegin(GL_QUADS);
-      glVertex3f( n(0),-n(1),n(2));
-      glVertex3f(-n(0),-n(1),n(2));
-      glVertex3f(-n(0), n(1),n(2));
-      glVertex3f( n(0), n(1),n(2));
-    glEnd();
-    for(int pass = 0;pass<2;pass++)
-    {
-      switch(pass)
-      {
-        case 1:
-          glColor4f(1,1,1,0.5);
-          glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
-          //glEnable(GL_BLEND);
-          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
-          glEnable(GL_TEXTURE_2D);
-          glBindTexture(GL_TEXTURE_2D,s.tex_ids[c]);
-          break;
-        default:
-        case 0:
-          glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
-          glColor4f(0,0,0,1);
-          break;
-      }
-      glBegin(GL_QUADS);
-        glTexCoord2d(1,0);
-        glVertex3f( 0.5*u(0),-0.5*u(1),0.5*u(2));
-        glTexCoord2d(0,0);
-        glVertex3f(-0.5*u(0),-0.5*u(1),0.5*u(2));
-        glTexCoord2d(0,1);
-        glVertex3f(-0.5*u(0), 0.5*u(1),0.5*u(2));
-        glTexCoord2d(1,1);
-        glVertex3f( 0.5*u(0), 0.5*u(1),0.5*u(2));
-      glEnd();
-      switch(pass)
-      {
-        case 1:
-          glBindTexture(GL_TEXTURE_2D, 0);
-          glDisable(GL_TEXTURE_2D);
-          glDisable(GL_BLEND);
-          break;
-        default:
-          break;
-      }
-    }
-
-    glPopMatrix();
-  }
-
-  // Set material properties
-  lights();
-  glEnable(GL_LIGHTING);
-  glDisable(GL_COLOR_MATERIAL);
-  glMaterialfv(GL_FRONT, GL_AMBIENT,  GOLD_AMBIENT);
-  glMaterialfv(GL_FRONT, GL_DIFFUSE,  GOLD_DIFFUSE  );
-  glMaterialfv(GL_FRONT, GL_SPECULAR, GOLD_SPECULAR);
-  glMaterialf (GL_FRONT, GL_SHININESS, 128);
-  glMaterialfv(GL_BACK, GL_AMBIENT,  SILVER_AMBIENT);
-  glMaterialfv(GL_BACK, GL_DIFFUSE,  FAST_GREEN_DIFFUSE  );
-  glMaterialfv(GL_BACK, GL_SPECULAR, SILVER_SPECULAR);
-  glMaterialf (GL_BACK, GL_SHININESS, 128);
-  igl::opengl2::draw_mesh(V,F,N);
-  glDisable(GL_LIGHTING);
-  glEnable(GL_COLOR_MATERIAL);
-  //glLineWidth(3.f);
-  //glColor4f(1,0,1,1);
-  //glutWireCube(0.25);
-  //glColor4f(1,0.5,0.5,1);
-  ////glutWireSphere(0.125,20,20);
-  {
-    glPushMatrix();
-    glTranslated(0,-1,0);
-    igl::opengl2::draw_floor();
-    glPopMatrix();
-  }
-  
-  // Axes
-  for(int d = 0;d<3;d++)
-  {
-    glColor4f(d==0,d==1,d==2,1);
-    glBegin(GL_LINES);
-    glVertex3f(0,0,0);
-    glVertex3f(d==0,d==1,d==2);
-    glEnd();
-  }
-
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-  igl::opengl::report_gl_error();
-
-  if(render_to_texture)
-  {
-    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-  }
-}
-
-void display()
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  glClearColor(back(0),back(1),back(2),0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  glEnable(GL_DEPTH_TEST);
-
-  // Update aspect ratios (may have changed since undo/redo)
-  {
-    const double aspect = (double)width/(double)height;
-    for(int c = 0;c<(int)s.cameras.size();c++)
-    {
-      auto & camera = s.cameras[c];
-      auto & tex_id = s.tex_ids[c];
-      auto & fbo_id = s.fbo_ids[c];
-      auto & dfbo_id = s.dfbo_ids[c];
-      if(aspect != camera.m_aspect)
-      {
-        cout<<"Initializing camera #"<<c<<"..."<<endl;
-        camera.m_aspect = aspect;
-        bool ret = init_render_to_texture(width,height,tex_id,fbo_id,dfbo_id);
-        assert(ret);
-      }
-      draw_scene(camera,true,tex_id,fbo_id,dfbo_id);
-    }
-  }
-  {
-    auto & camera = s.cameras[0];
-    draw_scene(camera,false,0,0,0);
-  }
-
-
-  TwDraw();
-  glutSwapBuffers();
-}
-
-
-void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  GLint viewport[4];
-  glGetIntegerv(GL_VIEWPORT,viewport);
-  if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
-  {
-    static double mouse_scroll_y = 0;
-    const double delta_y = 0.125*direction;
-    mouse_scroll_y += delta_y;
-    TwMouseWheel(mouse_scroll_y);
-    return;
-  }
-
-  auto & camera = s.cameras[0];
-  switch(center_type)
-  {
-    case CENTER_TYPE_ORBIT:
-      if(wheel==0)
-      {
-        // factor of zoom change
-        double s = (1.-0.01*direction);
-        //// FOV zoom: just widen angle. This is hardly ever appropriate.
-        //camera.m_angle *= s;
-        //camera.m_angle = min(max(camera.m_angle,1),89);
-        camera.push_away(s);
-      }else
-      {
-        // Dolly zoom:
-        camera.dolly_zoom((double)direction*1.0);
-      }
-      break;
-    default:
-    case CENTER_TYPE_FPS:
-      // Move `eye` and `at` 
-      camera.dolly((wheel==0?Vector3d(0,0,1):Vector3d(-1,0,0))*0.1*direction);
-      break;
-  }
-  glutPostRedisplay();
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  switch(glutButton)
-  {
-    case GLUT_RIGHT_BUTTON:
-    case GLUT_LEFT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_INHERIT);
-          is_rotating = false;
-          break;
-        case 0:
-          if(!tw_using)
-          {
-            push_undo();
-            glutSetCursor(GLUT_CURSOR_CYCLE);
-            // collect information for trackball
-            is_rotating = true;
-            down_camera = s.cameras[0];
-            down_x = mouse_x;
-            down_y = mouse_y;
-          }
-        break;
-      }
-      break;
-    }
-#ifdef GLUT_WHEEL_DOWN
-    // Scroll down
-    case GLUT_WHEEL_DOWN:
-    {
-      mouse_wheel(0,-1,mouse_x,mouse_y);
-      break;
-    }
-#endif
-#ifdef GLUT_WHEEL_UP
-    // Scroll up
-    case GLUT_WHEEL_UP:
-    {
-      mouse_wheel(0,1,mouse_x,mouse_y);
-      break;
-    }
-#endif
-#ifdef GLUT_WHEEL_LEFT
-    // Scroll left
-    case GLUT_WHEEL_LEFT:
-    {
-      mouse_wheel(1,-1,mouse_x,mouse_y);
-      break;
-    }
-#endif
-#ifdef GLUT_WHEEL_RIGHT
-    // Scroll right
-    case GLUT_WHEEL_RIGHT:
-    {
-      mouse_wheel(1,1,mouse_x,mouse_y);
-      break;
-    }
-#endif
-  }
-  glutPostRedisplay();
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  /*bool tw_using =*/ TwMouseMotion(mouse_x,mouse_y);
-
-  if(is_rotating)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    auto & camera = s.cameras[0];
-    Quaterniond q;
-    switch(rotation_type)
-    {
-      case ROTATION_TYPE_IGL_TRACKBALL:
-      {
-        // Rotate according to trackball
-        igl::trackball(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-          break;
-      }
-      case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
-      {
-        // Rotate according to two axis valuator with fixed up vector 
-        two_axis_valuator_fixed_up(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-        break;
-      }
-      default:
-        break;
-    }
-    switch(center_type)
-    {
-      default:
-      case CENTER_TYPE_ORBIT:
-        camera.orbit(q.conjugate());
-        break;
-      case CENTER_TYPE_FPS:
-        camera.turn_eye(q.conjugate());
-        break;
-    }
-  }
-  glutPostRedisplay();
-}
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  int mod = glutGetModifiers();
-  switch(key)
-  {
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    case 'o':
-    case 'O':
-      {
-        s.cameras[0].m_orthographic ^= true;
-        break;
-      }
-    case 'z':
-    case 'Z':
-      if(mod & GLUT_ACTIVE_COMMAND)
-      {
-        if(mod & GLUT_ACTIVE_SHIFT)
-        {
-          redo();
-        }else
-        {
-          undo();
-        }
-        break;
-      }
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-  glutPostRedisplay();
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-
-  // print key commands
-  cout<<"[Command+Z]         Undo."<<endl;
-  cout<<"[Shift+Command+Z]   Redo."<<endl;
-  cout<<"[^C,ESC]            Exit."<<endl;
-
-  if(!readOFF("../shared/cheburashka.off",V,F))
-  {
-    cerr<<"Failed to read in mesh..."<<endl;
-    return 1;
-  }
-  V.rowwise() -= V.colwise().minCoeff().eval();
-  per_face_normals(V,F,N);
-
-  // Init glut
-  glutInit(&argc,argv);
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("bar");
-  TwDefine("bar label='camera' size='200 550' text=light alpha='200' color='68 68 68'");
-  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString(
-      "RotationType","igl_trackball,two_axis_fixed_up");
-  rebar.TwAddVarRW("rotation_type", RotationTypeTW,&rotation_type,
-    "keyIncr=] keyDecr=[");
-  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString(
-      "CenterType","orbit,fps");
-  rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
-    "keyIncr={ keyDecr=}");
-  rebar.TwAddVarRW("rotation", TW_TYPE_QUAT4D,s.cameras[0].m_rotation_conj.coeffs().data(),"");
-  rebar.load(REBAR_NAME);
-  init_cameras();
-
-  // Init antweakbar
-  glutInitDisplayString( "rgba depth double samples>=8");
-  // Top right corner
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
-  glutInitWindowPosition(glutGet(GLUT_SCREEN_WIDTH)/2.0,-1);
-  glutCreateWindow("camera");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
-  glutMotionFunc(mouse_drag);
-
-  glutMainLoop();
-
-  return 0;
-}

+ 0 - 20
examples/colored-mesh/Makefile

@@ -1,20 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(EMBREE_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB) $(EMBREE_LIB)
-
-example: example.o
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) $(LIB) -o example example.o 
-
-example.o: example.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c example.cpp -o example.o $(INC)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 602
examples/colored-mesh/example.cpp

@@ -1,602 +0,0 @@
-#include <igl/opengl/OpenGL_convenience.h>
-#include <igl/per_face_normals.h>
-#include <igl/per_vertex_normals.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/quat_to_mat.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/readOBJ.h>
-#include <igl/readDMAT.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/jet.h>
-#include <igl/readWRL.h>
-#include <igl/trackball.h>
-#include <igl/list_to_matrix.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/snap_to_fixed_up.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/material_colors.h>
-#include <igl/barycenter.h>
-#include <igl/matlab_format.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-#include <igl/pathinfo.h>
-#include <igl/Camera.h>
-#include <igl/get_seconds.h>
-
-#ifdef __APPLE__
-#  include <GLUT/glut.h>
-#else
-#  include <GL/glut.h>
-#endif
-
-#include <Eigen/Core>
-
-#include <vector>
-#include <iostream>
-#include <algorithm>
-
-struct State
-{
-  igl::Camera camera;
-} s;
-enum RotationType
-{
-  ROTATION_TYPE_IGL_TRACKBALL = 0,
-  ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
-  NUM_ROTATION_TYPES = 2,
-} rotation_type;
-bool is_rotating = false;
-int down_x,down_y;
-igl::Camera down_camera;
-bool is_animating = false;
-double animation_start_time = 0;
-double ANIMATION_DURATION = 0.5;
-Eigen::Quaterniond animation_from_quat;
-Eigen::Quaterniond animation_to_quat;
-// Use vector for range-based `for`
-std::vector<State> undo_stack;
-std::vector<State> redo_stack;
-
-void push_undo()
-{
-  undo_stack.push_back(s);
-  // Clear
-  redo_stack = std::vector<State>();
-}
-
-void undo()
-{
-  using namespace std;
-  if(!undo_stack.empty())
-  {
-    redo_stack.push_back(s);
-    s = undo_stack.front();
-    undo_stack.pop_back();
-  }
-}
-
-void redo()
-{
-  using namespace std;
-  if(!redo_stack.empty())
-  {
-    undo_stack.push_back(s);
-    s = redo_stack.front();
-    redo_stack.pop_back();
-  }
-}
-
-void TW_CALL set_rotation_type(const void * value, void * clientData)
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-  const RotationType old_rotation_type = rotation_type;
-  rotation_type = *(const RotationType *)(value);
-  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
-    old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
-  {
-    push_undo();
-    animation_from_quat = s.camera.m_rotation_conj;
-    snap_to_fixed_up(animation_from_quat,animation_to_quat);
-    // start animation
-    animation_start_time = get_seconds();
-    is_animating = true;
-  }
-}
-
-void TW_CALL get_rotation_type(void * value, void *clientData)
-{
-  RotationType * rt = (RotationType *)(value);
-  *rt = rotation_type;
-}
-
-// Width and height of window
-int width,height;
-// Position of light
-float light_pos[4] = {0.1,0.1,-0.9,0};
-// Vertex positions, normals, colors and centroid
-Eigen::MatrixXd V,N,C,Z,mid;
-int selected_col = 0;
-// Faces
-Eigen::MatrixXi F;
-// Bounding box diagonal length
-double bbd;
-// Running ambient occlusion
-Eigen::VectorXd S;
-int tot_num_samples = 0;
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
-
-void reshape(int width,int height)
-{
-  using namespace std;
-  // Save width and height
-  ::width = width;
-  ::height = height;
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-  // Set aspect for all cameras
-  s.camera.m_aspect = (double)width/(double)height;
-  for(auto & s : undo_stack)
-  {
-    s.camera.m_aspect = (double)width/(double)height;
-  }
-  for(auto & s : redo_stack)
-  {
-    s.camera.m_aspect = (double)width/(double)height;
-  }
-}
-
-void push_scene()
-{
-  using namespace igl;
-  using namespace std;
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  auto & camera = s.camera;
-  gluPerspective(camera.m_angle,camera.m_aspect,camera.m_near,camera.m_far);
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    camera.eye()(0), camera.eye()(1), camera.eye()(2),
-    camera.at()(0), camera.at()(1), camera.at()(2),
-    camera.up()(0), camera.up()(1), camera.up()(2));
-}
-
-void pop_scene()
-{
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-// Scale and shift for object
-void push_object()
-{
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-mid(0,0),-mid(0,1),-mid(0,2));
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  float amb[4];
-  amb[0] = amb[1] = amb[2] = 0;
-  amb[3] = 1.0;
-  float diff[4] = {0.0,0.0,0.0,0.0};
-  diff[0] = diff[1] = diff[2] = (1.0 - 0/0.4);;
-  diff[3] = 1.0;
-  float zeros[4] = {0.0,0.0,0.0,0.0};
-  float pos[4];
-  copy(light_pos,light_pos+4,pos);
-  glLightfv(GL_LIGHT0,GL_AMBIENT,amb);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,diff);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos);
-  pos[0] *= -1;
-  pos[1] *= -1;
-  pos[2] *= -1;
-  glLightfv(GL_LIGHT1,GL_AMBIENT,amb);
-  glLightfv(GL_LIGHT1,GL_DIFFUSE,diff);
-  glLightfv(GL_LIGHT1,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT1,GL_POSITION,pos);
-}
-
-const float back[4] = {30.0/255.0,30.0/255.0,50.0/255.0,0};
-void display()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  glClearColor(back[0],back[1],back[2],0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  if(is_animating)
-  {
-    double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
-    if(t > 1)
-    {
-      t = 1;
-      is_animating = false;
-    }
-    const Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
-    s.camera.orbit(q.conjugate());
-  }
-
-  glDisable(GL_LIGHTING);
-  lights();
-  push_scene();
-  glEnable(GL_DEPTH_TEST);
-  glDepthFunc(GL_LEQUAL);
-  glEnable(GL_NORMALIZE);
-  glEnable(GL_COLOR_MATERIAL);
-  glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-  push_object();
-
-  // Draw the model
-  // Set material properties
-  glEnable(GL_COLOR_MATERIAL);
-  igl::opengl2::draw_mesh(V,F,N,C);
-
-  pop_object();
-
-  // Draw a nice floor
-  glPushMatrix();
-  const double floor_offset =
-    -2./bbd*(V.col(1).maxCoeff()-mid(1));
-  glTranslated(0,floor_offset,0);
-  const float GREY[4] = {0.5,0.5,0.6,1.0};
-  const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  igl::opengl2::draw_floor(GREY,DARK_GREY);
-  glPopMatrix();
-
-  pop_scene();
-
-  igl::opengl::report_gl_error();
-
-  TwDraw();
-  glutSwapBuffers();
-  if(is_animating)
-  {
-    glutPostRedisplay();
-  }
-}
-
-void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  GLint viewport[4];
-  glGetIntegerv(GL_VIEWPORT,viewport);
-  if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
-  {
-    static double mouse_scroll_y = 0;
-    const double delta_y = 0.125*direction;
-    mouse_scroll_y += delta_y;
-    TwMouseWheel(mouse_scroll_y);
-    return;
-  }
-  push_undo();
-  auto & camera = s.camera;
-  if(wheel==0)
-  {
-    // factor of zoom change
-    double s = (1.-0.01*direction);
-    //// FOV zoom: just widen angle. This is hardly ever appropriate.
-    //camera.m_angle *= s;
-    //camera.m_angle = min(max(camera.m_angle,1),89);
-    camera.push_away(s);
-  }else
-  {
-    // Dolly zoom:
-    camera.dolly_zoom((double)direction*1.0);
-  }
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  switch(glutButton)
-  {
-    case GLUT_RIGHT_BUTTON:
-    case GLUT_LEFT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
-          is_rotating = false;
-          break;
-        case 0:
-          // down
-          if(!tw_using)
-          {
-            glutSetCursor(GLUT_CURSOR_CYCLE);
-            // collect information for trackball
-            is_rotating = true;
-            down_camera = s.camera;
-            down_x = mouse_x;
-            down_y = mouse_y;
-          }
-        break;
-      }
-      break;
-    }
-    // Scroll down
-    case 3:
-    {
-      mouse_wheel(0,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll up
-    case 4:
-    {
-      mouse_wheel(0,1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll left
-    case 5:
-    {
-      mouse_wheel(1,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll right
-    case 6:
-    {
-      mouse_wheel(1,1,mouse_x,mouse_y);
-      break;
-    }
-  }
-  glutPostRedisplay();
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace Eigen;
-
-  if(is_rotating)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    Quaterniond q;
-    auto & camera = s.camera;
-    switch(rotation_type)
-    {
-      case ROTATION_TYPE_IGL_TRACKBALL:
-      {
-        // Rotate according to trackball
-        igl::trackball<double>(
-          width,
-          height,
-          2.0,
-          down_camera.m_rotation_conj.coeffs().data(),
-          down_x,
-          down_y,
-          mouse_x,
-          mouse_y,
-          q.coeffs().data());
-          break;
-      }
-      case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
-      {
-        // Rotate according to two axis valuator with fixed up vector
-        two_axis_valuator_fixed_up(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-        break;
-      }
-      default:
-        break;
-    }
-    camera.orbit(q.conjugate());
-  }else
-  {
-    TwEventMouseMotionGLUT(mouse_x, mouse_y);
-  }
-  glutPostRedisplay();
-}
-
-
-
-void initC(
-  const Eigen::MatrixXd & Z,
-  const int selected_col,
-  Eigen::MatrixXd & C)
-{
-  using namespace igl;
-  C.resize(Z.rows(),3);
-  const double min_z = Z.minCoeff();
-  const double max_z = Z.maxCoeff();
-  for(int r = 0;r<Z.rows();r++)
-  {
-    jet((Z(r,selected_col)-min_z)/(max_z-min_z),C(r,0),C(r,1),C(r,2));
-  }
-}
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  switch(key)
-  {
-    case '.':
-      selected_col = (selected_col+1)%Z.cols();
-      initC(Z,selected_col,C);
-      break;
-    case ',':
-      selected_col = (selected_col+Z.cols()-1)%Z.cols();
-      initC(Z,selected_col,C);
-      break;
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-
-  glutPostRedisplay();
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  // init mesh
-  string filename = "../shared/beast.obj";
-  string cfilename = "../shared/beast-xyz.dmat";
-  if(argc < 3)
-  {
-    cerr<<"Usage:"<<endl<<"    ./example input.obj color.dmat"<<endl;
-    cout<<endl<<"Opening default mesh..."<<endl;
-  }else
-  {
-    // Read and prepare mesh
-    filename = argv[1];
-    cfilename = argv[2];
-  }
-
-  // dirname, basename, extension and filename
-  string d,b,ext,f;
-  pathinfo(filename,d,b,ext,f);
-  // Convert extension to lower case
-  transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-  vector<vector<double > > vV,vN,vTC;
-  vector<vector<int > > vF,vFTC,vFN;
-  if(ext == "obj")
-  {
-    // Convert extension to lower case
-    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
-    {
-      return 1;
-    }
-  }else if(ext == "off")
-  {
-    // Convert extension to lower case
-    if(!igl::readOFF(filename,vV,vF,vN))
-    {
-      return 1;
-    }
-  }else if(ext == "wrl")
-  {
-    // Convert extension to lower case
-    if(!igl::readWRL(filename,vV,vF))
-    {
-      return 1;
-    }
-  //}else
-  //{
-  //  // Convert extension to lower case
-  //  MatrixXi T;
-  //  if(!igl::readMESH(filename,V,T,F))
-  //  {
-  //    return 1;
-  //  }
-  //  //if(F.size() > T.size() || F.size() == 0)
-  //  {
-  //    boundary_facets(T,F);
-  //  }
-  }
-  if(vV.size() > 0)
-  {
-    if(!list_to_matrix(vV,V))
-    {
-      return 1;
-    }
-    polygon_mesh_to_triangle_mesh(vF,F);
-  }
-  if(!readDMAT(cfilename,Z))
-  {
-    return 1;
-  }
-
-  // Compute normals, centroid, colors, bounding box diagonal
-  per_vertex_normals(V,F,N);
-  mid = 0.5*(V.colwise().maxCoeff() + V.colwise().minCoeff());
-  bbd = (V.colwise().maxCoeff() - V.colwise().minCoeff()).maxCoeff();
-  initC(Z,selected_col,C);
-
-  // Init glut
-  glutInit(&argc,argv);
-
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("TweakBar");
-  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
-    s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  s.camera.push_away(3);
-  s.camera.dolly_zoom(25-s.camera.m_angle);
-  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
-    "igl_trackball,two-a...-fixed-up");
-  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
-    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  rebar.load(REBAR_NAME);
-
-  glutInitDisplayString("rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
-  glutCreateWindow("colored-mesh");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc(
-    [](int x, int y)
-    {
-      TwEventMouseMotionGLUT(x,y);
-      glutPostRedisplay();
-    });
-  static std::function<void(int)> timer_bounce;
-  auto timer = [] (int ms) {
-    timer_bounce(ms);
-  };
-  timer_bounce = [&] (int ms) {
-    glutTimerFunc(ms, timer, ms);
-    glutPostRedisplay();
-  };
-  glutTimerFunc(500, timer, 500);
-
-  glutMainLoop();
-  return 0;
-}

+ 0 - 33
examples/components/Makefile

@@ -1,33 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-LIBIGL_LIB+=-liglembree 
-
-all: obj example
-
-.PHONY: example
-
-CFLAGS+=-g -std=c++11
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(GLUT_INC) $(EMBREE_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB) $(EMBREE_LIB)
-
-CPP_FILES=$(wildcard ./*.cpp)
-OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o))) 
-
-example: obj $(OBJ_FILES)
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -o example $(OBJ_FILES) $(LIB)
-
-obj:
-	mkdir -p obj
-
-obj/%.o: %.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-obj/%.o: %.cpp %.h
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-clean:
-	rm -f $(OBJ_FILES)
-	rm -f example

+ 0 - 1095
examples/components/example.cpp

@@ -1,1095 +0,0 @@
-#include <igl/C_STR.h>
-#include <igl/Camera.h>
-#include <igl/REDRUM.h>
-#include <igl/components.h>
-#include <igl/opengl/create_shader_program.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/get_seconds.h>
-#include <igl/hsv_to_rgb.h>
-#include <igl/opengl/init_render_to_texture.h>
-#include <igl/jet.h>
-#include <igl/per_face_normals.h>
-#include <igl/randperm.h>
-#include <igl/read_triangle_mesh.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/rgb_to_hsv.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/snap_to_fixed_up.h>
-#include <igl/trackball.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/write_triangle_mesh.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-
-#include <Eigen/Core>
-#include <Eigen/Geometry>
-
-#ifdef __APPLE__
-#include <GLUT/glut.h>
-#else
-#include <GL/glut.h>
-#endif
-
-#ifndef GLUT_WHEEL_UP
-#define GLUT_WHEEL_UP    3
-#endif
-#ifndef GLUT_WHEEL_DOWN
-#define GLUT_WHEEL_DOWN  4
-#endif
-#ifndef GLUT_WHEEL_RIGHT
-#define GLUT_WHEEL_RIGHT 5
-#endif
-#ifndef GLUT_WHEEL_LEFT
-#define GLUT_WHEEL_LEFT  6
-#endif
-#ifndef GLUT_ACTIVE_COMMAND
-#define GLUT_ACTIVE_COMMAND 8
-#endif
-
-#include <ctime>
-#include <string>
-#include <vector>
-#include <stack>
-#include <iostream>
-
-int cc_hover = -1;
-
-Eigen::MatrixXd V;
-Eigen::VectorXd Vmid,Vmin,Vmax;
-double bbd = 1.0;
-Eigen::MatrixXi F;
-Eigen::VectorXi CC;
-Eigen::MatrixXd N;
-struct State
-{
-  igl::Camera camera;
-  Eigen::VectorXf I;
-  Eigen::Matrix<GLubyte,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> selected;
-  GLuint mask_id;
-} s;
-std::string out_filename;
-
-GLuint pick_tex = 0;
-GLuint pick_fbo = 0;
-GLuint pick_dfbo = 0;
-
-// See README for descriptions
-enum RotationType
-{
-  ROTATION_TYPE_IGL_TRACKBALL = 0,
-  ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
-  NUM_ROTATION_TYPES = 2,
-} rotation_type;
-
-enum CenterType
-{
-  CENTER_TYPE_ORBIT = 0,
-  CENTER_TYPE_FPS  = 1,
-  NUM_CENTER_TYPES = 2,
-} center_type = CENTER_TYPE_ORBIT;
-
-
-std::stack<State> undo_stack;
-std::stack<State> redo_stack;
-
-bool wireframe_visible = false;
-bool fill_visible = true;
-
-bool is_rotating = false;
-int down_x,down_y;
-igl::Camera down_camera;
-
-bool is_animating = false;
-double animation_start_time = 0;
-double ANIMATION_DURATION = 0.5;
-Eigen::Quaterniond animation_from_quat;
-Eigen::Quaterniond animation_to_quat;
-
-int width,height;
-Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
-
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar;
-
-// Forward
-void init_components();
-void init_relative();
-
-void push_undo()
-{
-  undo_stack.push(s);
-  // Clear
-  redo_stack = std::stack<State>();
-}
-
-void TW_CALL set_rotation_type(const void * value, void * clientData)
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-  const RotationType old_rotation_type = rotation_type;
-  rotation_type = *(const RotationType *)(value);
-  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
-    old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
-  {
-    animation_from_quat = s.camera.m_rotation_conj;
-    snap_to_fixed_up(animation_from_quat,animation_to_quat);
-    // start animation
-    animation_start_time = get_seconds();
-    is_animating = true;
-  }
-}
-void TW_CALL get_rotation_type(void * value, void *clientData)
-{
-  RotationType * rt = (RotationType *)(value);
-  *rt = rotation_type;
-}
-
-void reshape(int width, int height)
-{
-  ::width = width;
-  ::height = height;
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-  s.camera.m_aspect = (double)width/(double)height;
-  igl::opengl::init_render_to_texture(width,height, pick_tex, pick_fbo, pick_dfbo);
-  igl::opengl::report_gl_error("init_render_to_texture: ");
-  glutPostRedisplay();
-}
-
-void push_scene()
-{
-  using namespace igl;
-  using namespace std;
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  auto & camera = s.camera;
-  glMultMatrixd(camera.projection().data());
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    camera.eye()(0), camera.eye()(1), camera.eye()(2),
-    camera.at()(0), camera.at()(1), camera.at()(2),
-    camera.up()(0), camera.up()(1), camera.up()(2));
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-Vmid(0),-Vmid(1),-Vmid(2));
-}
-
-void pop_scene()
-{
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-}
-
-void draw_mesh(
-  const Eigen::MatrixXd & V,
-  const Eigen::MatrixXi & F,
-  const Eigen::MatrixXd & N,
-  const Eigen::VectorXf & S,
-  const GLuint & S_loc)
-{
-  using namespace Eigen;
-  using namespace std;
-  static Matrix<float,Dynamic,3,RowMajor> VR,NR;
-  static Matrix<int,Dynamic,3,RowMajor> FR;
-  static Matrix<float,Dynamic,1,ColMajor> SR;
-  static GLuint ibo,vbo,sbo,nbo;
-  static bool scene_dirty = true;
-  if(scene_dirty)
-  {
-    VR.resize(F.rows()*3,3);
-    NR.resize(F.rows()*3,3);
-    SR.resize(F.rows()*3,1);
-    FR.resize(F.rows(),3);
-    for(int f = 0;f<F.rows();f++)
-    {
-      for(int c = 0;c<3;c++)
-      {
-        VR.row(3*f+c) = V.row(F(f,c)).cast<float>();
-        SR(3*f+c) = S(F(f,c));
-        NR.row(3*f+c) = N.row(f).cast<float>();
-        FR(f,c) = 3*f+c;
-      }
-    }
-
-    glGenBuffers(1,&ibo);
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,ibo);
-    glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(GLuint)*FR.size(),FR.data(),GL_STATIC_DRAW);
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
-    glGenBuffers(1,&vbo);
-    glGenBuffers(1,&nbo);
-    glGenBuffers(1,&sbo);
-
-    glBindBuffer(GL_ARRAY_BUFFER,vbo);
-    glBufferData(GL_ARRAY_BUFFER,sizeof(float)*VR.size(),VR.data(),GL_STATIC_DRAW);
-    glBindBuffer(GL_ARRAY_BUFFER,nbo);
-    glBufferData(GL_ARRAY_BUFFER,sizeof(float)*NR.size(),NR.data(),GL_STATIC_DRAW);
-
-    glBindBuffer(GL_ARRAY_BUFFER,sbo);
-    glBufferData(GL_ARRAY_BUFFER,sizeof(float)*SR.size(),SR.data(),GL_STATIC_DRAW);
-    igl::opengl::report_gl_error("glBindBuffer: ");
-
-    scene_dirty = false;
-  }
-
-  glEnableClientState(GL_VERTEX_ARRAY);
-  glBindBuffer(GL_ARRAY_BUFFER,vbo);
-  glVertexPointer(3,GL_FLOAT,0,0);
-  glEnableClientState(GL_NORMAL_ARRAY);
-  glBindBuffer(GL_ARRAY_BUFFER,nbo);   
-  glNormalPointer(GL_FLOAT,0,0);
-
-  glBindBuffer(GL_ARRAY_BUFFER,sbo);   
-  glVertexAttribPointer(S_loc, 1, GL_FLOAT, GL_FALSE, 0, 0);
-  glEnableVertexAttribArray(S_loc);
-
-  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,ibo);
-  glDrawElements(GL_TRIANGLES,FR.size(),GL_UNSIGNED_INT,0);
-  glBindBuffer(GL_ARRAY_BUFFER,0);
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  using namespace Eigen;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  float WHITE[4] = {1,1,1,1.};
-  float BLACK[4] = {0.,0.,0.,1.};
-  Vector4f pos = light_pos;
-  glLightfv(GL_LIGHT0,GL_AMBIENT,BLACK);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,BLACK);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos.data());
-  //glEnable(GL_LIGHT1);
-  //pos(0) *= -1;
-  //pos(1) *= -1;
-  //pos(2) *= -1;
-  //glLightfv(GL_LIGHT1,GL_AMBIENT,BLACK);
-  //glLightfv(GL_LIGHT1,GL_DIFFUSE,NEAR_BLACK);
-  //glLightfv(GL_LIGHT1,GL_SPECULAR,BLACK);
-  //glLightfv(GL_LIGHT1,GL_POSITION,pos.data());
-}
-
-template <int Rows, int Cols>
-GLuint generate_1d_texture(
-  const Eigen::Matrix<GLubyte,Rows,Cols,Eigen::RowMajor> & colors)
-{
-  assert(colors.cols() == 3 && "Seems colors.cols() must be 3");
-  GLuint tex_id = 0;
-  glGenTextures(1,&tex_id);
-  glBindTexture(GL_TEXTURE_1D,tex_id);
-  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-  glTexImage1D(GL_TEXTURE_1D, 0, colors.cols(),colors.rows(),
-    0,GL_RGB, GL_UNSIGNED_BYTE,
-    colors.data());
-  igl::opengl::report_gl_error("glTexImage1D: ");
-  glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-  glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-  glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
-  igl::opengl::report_gl_error("texture: ");
-  return tex_id;
-}
- 
-GLuint color_shader(const size_t max_ids, GLuint & scalar_loc, GLuint & tex_id)
-{
-  std::string vertex_shader = R"(
-#version 120
-attribute float scalar_in;
-varying float scalar_out;
-void main()
-{
-  scalar_out = scalar_in;
-  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-}
-)";
-  std::string fragment_shader = R"(
-#version 120
-varying float scalar_out;
-uniform float cmin;
-uniform float cmax;
-uniform sampler1D color_map;
-void main()
-{
-  float scalar_normalized = max(min((scalar_out-cmin)/(cmax-cmin),1.0),0.0);
-  gl_FragColor = texture1D(color_map,scalar_normalized);
-}
-)";
-  Eigen::Matrix<GLubyte,Eigen::Dynamic,3,Eigen::RowMajor> colors(max_ids,3);
-  for(size_t id = 0;id<max_ids;id++)
-  {
-    size_t index = id;
-    size_t re = (index)%(256*256);
-    colors(id,0) = (index-re)/(256*256);
-    index = re;
-    re = index%(256);
-    colors(id,1) = (index-re)/(256);
-    colors(id,2) = re;
-  }
-  tex_id = generate_1d_texture(colors);
-  return igl::opengl::create_shader_program(
-    vertex_shader.c_str(), 
-    fragment_shader.c_str(),
-    {{"scalar_in",scalar_loc}}
-    );
-}
-
-
-void display()
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  glClearColor(0.8,0.8,0.8,0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  if(is_animating)
-  {
-    double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
-    if(t > 1)
-    {
-      t = 1;
-      is_animating = false;
-    }
-    Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
-    auto & camera = s.camera;
-    switch(center_type)
-    {
-      default:
-      case CENTER_TYPE_ORBIT:
-        camera.orbit(q.conjugate());
-        break;
-      case CENTER_TYPE_FPS:
-        camera.turn_eye(q.conjugate());
-        break;
-    }
-  }
-
-  glEnable(GL_DEPTH_TEST);
-  glEnable(GL_NORMALIZE);
-  lights();
-  push_scene();
-
-
-  const auto & color_components_shader = [](
-     const GLuint scalar_loc,
-     GLuint & tex_id)->GLuint
-  {
-  std::string vertex_shader = R"(
-#version 120
-attribute float scalar_in;
-varying vec3 normal;
-varying float scalar_out;
-void main()
-{
-  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-  normal = normalize(gl_NormalMatrix * gl_Normal);
-  scalar_out = scalar_in;
-}
-)";
-  std::string fragment_shader = R"(
-#version 120
-varying vec3 normal;
-varying float scalar_out;
-uniform float cmin;
-uniform float cmax;
-uniform float cc_hover;
-uniform sampler1D color_map;
-uniform sampler1D selected_mask;
-void main()
-{
-  float scalar_normalized = max(min((scalar_out-cmin)/(cmax-cmin),1.0),0.0);
-  vec4 texture_color = texture1D(color_map,scalar_normalized);
-  bool is_selected = texture1D(selected_mask,scalar_normalized).x > 0.5;
-  const vec4 selected_color = vec4(1,0.2,0.2,1);
-  if(scalar_out==cc_hover)
-  {
-    texture_color = 0.5*(texture_color + selected_color);
-  }
-  if(is_selected)
-  {
-    texture_color = selected_color;
-  }
-  const float num_lights = 1.0;
-  vec4 diffuse = (1.0/num_lights)*(gl_LightSource[0].diffuse);
-  vec4 ambient = vec4(0,0,0,0);
-  ambient += (1.0/num_lights)*(gl_FrontMaterial.ambient * gl_LightSource[0].ambient);
-  ambient += (1.0/num_lights)*(gl_LightModel.ambient * gl_FrontMaterial.ambient);
-  vec4 color = ambient;
-  // Phong
-  vec3 lightDir = normalize(vec3(gl_LightSource[0].position));
-  vec3 halfVector = gl_LightSource[0].halfVector.xyz;
-  vec3 n = normalize(normal);
-  float NdotL = max(abs(dot(n.xyz,lightDir)), 0.0);  
-  vec4 specular = vec4(0.0,0.0,0.0,0.0);
-  if (NdotL > 0.0) {
-      color += diffuse * NdotL;
-      vec3 halfV = normalize(halfVector);
-      float NdotHV = max(abs(dot(n,halfV)),0.0);
-      specular += gl_FrontMaterial.specular * gl_LightSource[0].specular * pow(NdotHV, gl_FrontMaterial.shininess);
-  }
-  gl_FragColor = color * texture_color + specular;
-}
-
-)";
-
-    typedef Matrix<GLubyte,64,3,RowMajor> Matrix64_3_R_ubyte;
-    typedef Matrix<float,64,3,RowMajor> Matrix64_3_R_float;
-    Matrix64_3_R_ubyte colors;
-    {
-      Matrix64_3_R_float rgb = (Matrix64_3_R_ubyte()<<
-        255,   0,   0,
-        255,  24,   0,
-        255,  48,   0,
-        255,  72,   0,
-        255,  96,   0,
-        255, 120,   0,
-        255, 143,   0,
-        255, 167,   0,
-        255, 191,   0,
-        255, 215,   0,
-        255, 239,   0,
-        247, 255,   0,
-        223, 255,   0,
-        199, 255,   0,
-        175, 255,   0,
-        151, 255,   0,
-        128, 255,   0,
-        104, 255,   0,
-         80, 255,   0,
-         56, 255,   0,
-         32, 255,   0,
-          8, 255,   0,
-          0, 255,  16,
-          0, 255,  40,
-          0, 255,  64,
-          0, 255,  88,
-          0, 255, 112,
-          0, 255, 135,
-          0, 255, 159,
-          0, 255, 183,
-          0, 255, 207,
-          0, 255, 231,
-          0, 255, 255,
-          0, 231, 255,
-          0, 207, 255,
-          0, 183, 255,
-          0, 159, 255,
-          0, 135, 255,
-          0, 112, 255,
-          0,  88, 255,
-          0,  64, 255,
-          0,  40, 255,
-          0,  16, 255,
-          8,   0, 255,
-         32,   0, 255,
-         56,   0, 255,
-         80,   0, 255,
-        104,   0, 255,
-        128,   0, 255,
-        151,   0, 255,
-        175,   0, 255,
-        199,   0, 255,
-        223,   0, 255,
-        247,   0, 255,
-        255,   0, 239,
-        255,   0, 215,
-        255,   0, 191,
-        255,   0, 167,
-        255,   0, 143,
-        255,   0, 120,
-        255,   0,  96,
-        255,   0,  72,
-        255,   0,  48,
-        255,   0,  24).finished().cast<float>()/255.f;
-
-      Matrix64_3_R_float H;
-      rgb_to_hsv(rgb,H);
-      H.col(1) *= 0.1;
-      H.col(2) = (H.col(2).array() + 0.1*(1.-H.col(2).array())).eval();
-      hsv_to_rgb(H,rgb);
-      colors = (rgb*255.).cast<GLubyte>();
-    }
-
-    tex_id = generate_1d_texture(colors);
-
-    GLuint prog_id = igl::opengl::create_shader_program(
-      vertex_shader.c_str(), 
-      fragment_shader.c_str(),
-      {{"scalar_in",scalar_loc}}
-      );
-    igl::opengl::report_gl_error("create_shader_program: ");
-    return prog_id;
-  };
-  static GLuint scalar_loc = 1;
-  static GLuint tex_id = 0;
-  static GLuint color_components_prog = 
-    color_components_shader(scalar_loc,tex_id);
-
-  // Set material properties
-  glEnable(GL_COLOR_MATERIAL);
-  glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-  glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,(const GLfloat[]){1,1,1,1});
-  if(wireframe_visible)
-  {
-    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
-    if(fill_visible)
-    {
-      glColor3f(0,0,0);
-      glUseProgram(0);
-      draw_mesh(V,F,N,s.I,scalar_loc);
-    }else
-    {
-      glUseProgram(color_components_prog);
-      igl::opengl::report_gl_error("UseProgram: ");
-      draw_mesh(V,F,N,s.I,scalar_loc);
-    }
-  }
-
-  glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
-
-  glPushAttrib(GL_ALL_ATTRIB_BITS);
-  glUseProgram(color_components_prog);
-    igl::opengl::report_gl_error("use: ");
-  glUniform1f(glGetUniformLocation(color_components_prog,"cmin"),s.I.minCoeff());
-  glUniform1f(glGetUniformLocation(color_components_prog,"cmax"),s.I.maxCoeff());
-  //glUniform1f(glGetUniformLocation(color_components_prog,"cc_selected"),cc_selected);
-  glUniform1f(glGetUniformLocation(color_components_prog,"cc_hover"),cc_hover);
-  glActiveTexture(GL_TEXTURE0);
-  glBindTexture(GL_TEXTURE_1D, tex_id);
-  glUniform1i(glGetUniformLocation(color_components_prog,"color_map"),0);
-  glActiveTexture(GL_TEXTURE1);
-  glBindTexture(GL_TEXTURE_1D, s.mask_id);
-  glUniform1i(glGetUniformLocation(color_components_prog,"selected_mask"),1);
-
-    igl::opengl::report_gl_error("unif: ");
-  if(fill_visible)
-  {
-    glEnable(GL_POLYGON_OFFSET_FILL); // Avoid Stitching!
-    glPolygonOffset(1.0, 0);
-  }
-  draw_mesh(V,F,N,s.I,scalar_loc);
-  glPopAttrib();
-  glUseProgram(0);
-
-  // Draw a nice floor
-  glPushMatrix();
-  const double floor_offset =
-    -2./bbd*(V.col(1).maxCoeff()-Vmid(1));
-  glTranslated(0,floor_offset,0);
-  const float GREY[4] = {0.5,0.5,0.6,1.0};
-  const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  igl::opengl2::draw_floor(GREY,DARK_GREY);
-  glPopMatrix();
-
-  pop_scene();
-
-  TwDraw();
-  glutSwapBuffers();
-  if(is_animating)
-  {
-    glutPostRedisplay();
-  }
-}
-
-void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  GLint viewport[4];
-  glGetIntegerv(GL_VIEWPORT,viewport);
-  if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
-  {
-    static double mouse_scroll_y = 0;
-    const double delta_y = 0.125*direction;
-    mouse_scroll_y += delta_y;
-    TwMouseWheel(mouse_scroll_y);
-    return;
-  }
-
-  auto & camera = s.camera;
-  switch(center_type)
-  {
-    case CENTER_TYPE_ORBIT:
-      if(wheel==0)
-      {
-        // factor of zoom change
-        double s = (1.-0.01*direction);
-        //// FOV zoom: just widen angle. This is hardly ever appropriate.
-        //camera.m_angle *= s;
-        //camera.m_angle = min(max(camera.m_angle,1),89);
-        camera.push_away(s);
-      }else
-      {
-        // Dolly zoom:
-        camera.dolly_zoom((double)direction*1.0);
-      }
-      break;
-    default:
-    case CENTER_TYPE_FPS:
-      // Move `eye` and `at`
-      camera.dolly((wheel==0?Vector3d(0,0,1):Vector3d(-1,0,0))*0.1*direction);
-      break;
-  }
-  glutPostRedisplay();
-}
-
-bool pick(const int x, const int y, int & cc_selected)
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  static GLuint scalar_loc = 1;
-  static GLuint tex_id = 0;
-  static const size_t max_ids = s.I.maxCoeff()+1;
-  static GLuint color_shader_prog = color_shader(max_ids,scalar_loc,tex_id);
-  const int pick_s = 0;
-  const int pick_w = pick_s;
-  GLint old_vp[4];
-  glGetIntegerv(GL_VIEWPORT,old_vp);
-  const double pick_ratio = double(pick_w)/double(old_vp[2]);
-  // ceil, cause might otherwise round down to 0
-  const int pick_h = ceil(double(old_vp[3])*pick_ratio);
-  glViewport(
-    x-pick_w,
-    old_vp[3]-y-pick_h,2*pick_w+1,2*pick_h+1);
-  glMatrixMode(GL_PROJECTION);
-  Matrix4d proj;
-  glGetDoublev(GL_PROJECTION_MATRIX,proj.data());
-  glPushMatrix();
-  glLoadIdentity();
-  gluPickMatrix(
-    x,
-    old_vp[3]-y, 
-    pick_w*2+1,
-    pick_h*2+1,
-    old_vp);
-  glMultMatrixd(proj.data());
-  glMatrixMode(GL_MODELVIEW);
-  // Activate color shader
-  glUseProgram(color_shader_prog);
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,pick_fbo);
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,pick_dfbo);
-  // Clear screen
-  glClearColor(0,0,0,0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  glPushAttrib(GL_ALL_ATTRIB_BITS);
-  glEnable(GL_TEXTURE_1D);
-  glBindTexture(GL_TEXTURE_1D, tex_id);
-  glUniform1f(glGetUniformLocation(color_shader_prog,"cmin"),s.I.minCoeff());
-  glUniform1f(glGetUniformLocation(color_shader_prog,"cmax"),s.I.maxCoeff());
-  draw_mesh(V,F,N,s.I,scalar_loc);
-  glPopAttrib();
-
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glViewport(old_vp[0],old_vp[1],old_vp[2],old_vp[3]);
-
-  Matrix<GLubyte,1,4> pixel;
-  glReadPixels(x,old_vp[3]-y,1,1,GL_RGBA,GL_UNSIGNED_BYTE,pixel.data());
-
-  glUseProgram(0);
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,0);
-
-  if(pixel(3) == 0)
-  {
-    cc_selected = -1;
-    return false;
-  }
-  cc_selected = pixel(0)*256*256+pixel(1)*256+pixel(2);
-  return true;
-}
-
-void regenerate_mask()
-{
-  if(glIsTexture(s.mask_id))
-  {
-    glDeleteTextures(1,&s.mask_id);
-  }
-  s.mask_id = generate_1d_texture(s.selected);
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  int mod = glutGetModifiers();
-  switch(glutButton)
-  {
-    case GLUT_RIGHT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_INHERIT);
-          is_rotating = false;
-          break;
-        case 0:
-          glutSetCursor(GLUT_CURSOR_CYCLE);
-          // collect information for trackball
-          is_rotating = true;
-          down_camera = s.camera;
-          down_x = mouse_x;
-          down_y = mouse_y;
-        break;
-      }
-      break;
-    }
-    case GLUT_LEFT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_INHERIT);
-          is_rotating = false;
-          break;
-        case 0:
-          if(!tw_using)
-          {
-            push_scene();
-            int cc_selected=-1;
-            if(pick(mouse_x,mouse_y,cc_selected))
-            {
-              push_undo();
-              if(!(mod & GLUT_ACTIVE_SHIFT))
-              {
-                s.selected.setConstant(0);
-              }
-              s.selected(cc_selected,0) = 255;
-              regenerate_mask();
-            }else
-            {
-              glutSetCursor(GLUT_CURSOR_CYCLE);
-              // collect information for trackball
-              is_rotating = true;
-              down_camera = s.camera;
-              down_x = mouse_x;
-              down_y = mouse_y;
-            }
-            pop_scene();
-          }
-        break;
-      }
-      break;
-    }
-    // Scroll down
-    case GLUT_WHEEL_DOWN:
-    {
-      mouse_wheel(0,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll up
-    case GLUT_WHEEL_UP:
-    {
-      mouse_wheel(0,1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll left
-    case GLUT_WHEEL_LEFT:
-    {
-      mouse_wheel(1,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll right
-    case GLUT_WHEEL_RIGHT:
-    {
-      mouse_wheel(1,1,mouse_x,mouse_y);
-      break;
-    }
-  }
-  glutPostRedisplay();
-}
-
-void mouse_move(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  bool tw_using = TwMouseMotion(mouse_x,mouse_y);
-  push_scene();
-  pick(mouse_x,mouse_y,cc_hover);
-  pop_scene();
-  glutPostRedisplay();
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  bool tw_using = TwMouseMotion(mouse_x,mouse_y);
-
-  if(is_rotating)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    Quaterniond q;
-    auto & camera = s.camera;
-    switch(rotation_type)
-    {
-      case ROTATION_TYPE_IGL_TRACKBALL:
-      {
-        // Rotate according to trackball
-        igl::trackball<double>(
-          width,
-          height,
-          2.0,
-          down_camera.m_rotation_conj.coeffs().data(),
-          down_x,
-          down_y,
-          mouse_x,
-          mouse_y,
-          q.coeffs().data());
-          break;
-      }
-      case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
-      {
-        // Rotate according to two axis valuator with fixed up vector
-        two_axis_valuator_fixed_up(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-        break;
-      }
-      default:
-        break;
-    }
-    switch(center_type)
-    {
-      default:
-      case CENTER_TYPE_ORBIT:
-        camera.orbit(q.conjugate());
-        break;
-      case CENTER_TYPE_FPS:
-        camera.turn_eye(q.conjugate());
-        break;
-    }
-  }
-  glutPostRedisplay();
-}
-
-void init_relative()
-{
-  using namespace Eigen;
-  using namespace igl;
-  per_face_normals(V,F,N);
-  Vmax = V.colwise().maxCoeff();
-  Vmin = V.colwise().minCoeff();
-  Vmid = 0.5*(Vmax + Vmin);
-  bbd = (Vmax-Vmin).norm();
-}
-
-void init_components()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  components(F,CC);
-  s.I = CC.cast<float>();
-  s.selected = Matrix<GLubyte,Dynamic,Dynamic>::Zero(s.I.maxCoeff()+1,3);
-  cout<<"s.selected: "<<s.selected.rows()<<endl;
-  regenerate_mask();
-}
-
-void undo()
-{
-  using namespace std;
-  if(!undo_stack.empty())
-  {
-    redo_stack.push(s);
-    s = undo_stack.top();
-    undo_stack.pop();
-  }
-  regenerate_mask();
-}
-
-void redo()
-{
-  using namespace std;
-  if(!redo_stack.empty())
-  {
-    undo_stack.push(s);
-    s = redo_stack.top();
-    redo_stack.pop();
-  }
-  regenerate_mask();
-}
-
-bool save(const std::string & out_filename)
-{
-  using namespace std;
-  using namespace igl;
-  if(write_triangle_mesh(out_filename,V,F))
-  {
-    cout<<GREENGIN("Saved mesh to `"<<out_filename<<"` successfully.")<<endl;
-    return true;
-  }else
-  {
-    cout<<REDRUM("Failed to save mesh to `"<<out_filename<<"`.")<<endl;
-    return false;
-  }
-}
-
-void TW_CALL saveCB(void * /*clientData*/)
-{
-  save(out_filename);
-}
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  int mod = glutGetModifiers();
-  switch(key)
-  {
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    case 'z':
-    case 'Z':
-      if(mod & GLUT_ACTIVE_COMMAND)
-      {
-        if(mod & GLUT_ACTIVE_SHIFT)
-        {
-          redo();
-        }else
-        {
-          undo();
-        }
-      }else
-      {
-        Quaterniond q;
-        snap_to_canonical_view_quat(s.camera.m_rotation_conj,1.0,q);
-        switch(center_type)
-        {
-          default:
-          case CENTER_TYPE_ORBIT:
-            s.camera.orbit(q.conjugate());
-            break;
-          case CENTER_TYPE_FPS:
-            s.camera.turn_eye(q.conjugate());
-            break;
-        }
-      }
-      break;
-    case 'u':
-        mouse_wheel(0, 1,mouse_x,mouse_y);
-        break;
-    case 'j':
-        mouse_wheel(0,-1,mouse_x,mouse_y);
-        break;
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-
-  glutPostRedisplay();
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  string filename = "../shared/truck.obj";
-  switch(argc)
-  {
-    case 3:
-      out_filename = argv[2];
-    case 2:
-      // Read and prepare mesh
-      filename = argv[1];
-      break;
-    default:
-      cerr<<"Usage:"<<endl<<"    ./example input.obj (output.obj)"<<endl;
-      cout<<endl<<"Opening default mesh..."<<endl;
-      break;
-  }
-
-  // print key commands
-  cout<<"[Click] and [drag]  Rotate model using trackball."<<endl;
-  cout<<"[Z,z]               Snap rotation to canonical view."<<endl;
-  cout<<"[Command+Z]         Undo."<<endl;
-  cout<<"[Shift+Command+Z]   Redo."<<endl;
-  cout<<"[^C,ESC]            Exit."<<endl;
-
-  read_triangle_mesh(filename,V,F);
-
-
-  // Init glut
-  glutInit(&argc,argv);
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("bar");
-  TwDefine("bar label='Components' size='200 550' text=light alpha='200' color='68 68 68'");
-  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
-    s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
-    "igl_trackball,two-axis-valuator-fixed-up");
-  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
-    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("CenterType","orbit,fps");
-  rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
-    "keyIncr={ keyDecr=}");
-
-  rebar.TwAddVarRW("wireframe_visible",TW_TYPE_BOOLCPP,&wireframe_visible,"key=l");
-  rebar.TwAddVarRW("fill_visible",TW_TYPE_BOOLCPP,&fill_visible,"key=f");
-  if(out_filename != "")
-  {
-    rebar.TwAddButton("save",
-      saveCB,NULL,
-      C_STR("label='Save to `"<<out_filename<<"`' "<<
-      "key=s"));
-  }
-  rebar.load(REBAR_NAME);
-
-
-  animation_from_quat = Quaterniond(1,0,0,0);
-  s.camera.m_rotation_conj = animation_from_quat;
-  animation_start_time = get_seconds();
-
-  glutInitDisplayString( "rgba depth double samples>=8");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
-  glutCreateWindow("components");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc(mouse_move);
-
-  init_components();
-  init_relative();
-  regenerate_mask();
-
-  std::cout<<"OpenGL version: "<<glGetString(GL_VERSION)<<std::endl;
-  glutMainLoop();
-
-  return 0;
-}

+ 0 - 21
examples/convertmesh/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: convertmesh
-
-.PHONY: convertmesh
-
-INC=$(LIBIGL_INC) $(EIGEN3_INC) 
-LIB=$(LIBIGL_LIB) 
-OPTFLAGS+=-O3 -DNDEBUG $(OPENMP)
-
-convertmesh: convertmesh.o
-	g++ $(OPTFLAGS) $(AFLAGS) $(CFLAGS) $(LIB) -o convertmesh convertmesh.o 
-
-convertmesh.o: convertmesh.cpp
-	g++ $(OPTFLAGS) $(AFLAGS) $(CFLAGS) -c convertmesh.cpp -o convertmesh.o $(INC)
-clean:
-	rm -f convertmesh.o
-	rm -f convertmesh

+ 0 - 31
examples/convertmesh/convertmesh.cpp

@@ -1,31 +0,0 @@
-#include <igl/read_triangle_mesh.h>
-#include <igl/write_triangle_mesh.h>
-#include <string>
-#include <iostream>
-int main(int argc, char * argv[])
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  MatrixXd V;
-  MatrixXi F;
-  string in,out;
-  switch(argc)
-  {
-    case 3:
-      in = argv[1];
-      out = argv[2];
-      break;
-    default:
-      cerr<<R"(
-USAGE:
-  convertmesh input.[mesh|obj|off|ply|stl|wrl] output.[mesh|obj|off|ply|stl|wrl]
-
-  Note: .ply and .stl outputs are binary.
-)";
-    return EXIT_FAILURE;
-  }
-  return 
-    read_triangle_mesh(in,V,F) && write_triangle_mesh(out,V,F,false) ? 
-    EXIT_SUCCESS : EXIT_FAILURE;
-}

+ 0 - 21
examples/dmat/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC) $(EIGEN3_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 22
examples/dmat/README

@@ -1,22 +0,0 @@
-This is a simple example program that shows how to use the readDMAT and
-writeDMAT functions of the igl library
-
-
-To Build:
-  make
-
-To Run:
-  ./example [input path] [output path]
-
-Example Run #1:
-  Issuing:
-    ./example example.dmat output.dmat
-    cat output.dmat
-  should produce:
-    3 2
-    1
-    4
-    2
-    5
-    3
-    6

+ 0 - 18
examples/dmat/example.cpp

@@ -1,18 +0,0 @@
-#include <Eigen/Core>
-#include <igl/readDMAT.h>
-#include <igl/writeDMAT.h>
-using namespace igl;
-#include <cstdio>
-
-int main(int argc, char * argv[])
-{
-  if(argc <= 2)
-  {
-    printf("USAGE:\n  ./example [input path] [output path]\n");
-    return 1;
-  }
-  Eigen::MatrixXd M;
-  readDMAT(argv[1],M);
-  writeDMAT(argv[2],M);
-  return 0;
-}

+ 0 - 7
examples/dmat/example.dmat

@@ -1,7 +0,0 @@
-3 2
-1
-4
-2
-5
-3
-6

+ 0 - 21
examples/eigen-gotchas/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g
-INC=$(LIBIGL_INC) $(EIGEN3_INC)
-LIB=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(LIB)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(INC)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 227
examples/eigen-gotchas/example.cpp

@@ -1,227 +0,0 @@
-// Make an effort to verify bugs/gotchas for column and row major
-//#define EIGEN_DEFAULT_TO_ROW_MAJOR
-
-#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
-#define EIGEN_IM_MAD_AS_HELL_AND_IM_NOT_GOING_TO_TAKE_IT_ANYMORE
-#include <Eigen/Sparse>
-using namespace Eigen;
-
-#include <cstdio>
-#include <iostream>
-using namespace std;
-
-#include <igl/print_ijv.h>
-using namespace igl;
-
-#if EIGEN_VERSION_AT_LEAST(3,0,92)
-#  warning these gotchas have not been verified for your Eigen Version
-#else
-// Eigen fails to notice at compile time that the inneriterator used to loop
-// over the contents of a sparsematrix of type T is a different type
-//
-// http://www.alecjacobson.com/weblog/?p=2216
-void wrong_sparsematrix_inner_iterator_type()
-{
-  // Fill 10 by 10 matrix with 0.5*(1:10) along the diagonal
-  SparseMatrix<double> A(10,10);
-  A.reserve(10);
-  for(int i = 0;i<10;i++)
-  {
-    A.insert(i,i) = (double)i/2.0;
-  }
-  A.finalize();
-  cout<<"AIJV=["<<endl;print_ijv(A,1);cout<<endl<<"];"<<endl<<
-    "A=sparse(AIJV(:,1),AIJV(:,2),AIJV(:,3),"<<
-    A.rows()<<","<<A.cols()<<");"<<endl;
-
-  // Traverse A as *int*
-  for(int k = 0;k<A.outerSize();k++)
-  {
-    // Each entry seems to be cast to int and if it's cast to zero then it's as
-    // if it wasn't even there
-    for (SparseMatrix<int>::InnerIterator it(A,k); it; ++it)
-    {
-      printf("A(%d,%d) = %d\n",it.row(),it.col(),it.value());
-    }
-  }
-}
-
-// Eigen can't handle .transpose within expression on right hand side of =
-// operator
-//
-// Temporary solution: Never use Something.transpose() in expression. Always
-// first compute Something into a matrix:
-//   SparseMatrix S = Something;
-// then compute tranpose
-//   SparseMatrix ST = Something.transpose();
-// then continue
-void sparsematrix_transpose_in_rhs_aliasing()
-{
-  SparseMatrix<double> A(7,2);
-  A.reserve(4);
-  A.insert(0,0) = -0.5;
-  A.insert(2,0) = -0.5;
-  A.insert(4,1) = -0.5;
-  A.insert(6,1) = -0.5;
-  A.finalize();
-  cout<<"AIJV=["<<endl;print_ijv(A,1);cout<<endl<<"];"<<endl<<
-    "A=sparse(AIJV(:,1),AIJV(:,2),AIJV(:,3),"<<
-    A.rows()<<","<<A.cols()<<");"<<endl;
-
-  SparseMatrix<double> B(2,7);
-  B.reserve(4);
-  B.insert(0,0) = -0.5;
-  B.insert(0,2) = -0.5;
-  B.insert(1,4) = -0.5;
-  B.insert(1,6) = -0.5;
-  B.finalize();
-  cout<<"BIJV=["<<endl;print_ijv(B,1);cout<<endl<<"];"<<endl<<
-    "B=sparse(BIJV(:,1),BIJV(:,2),BIJV(:,3),"<<
-    B.rows()<<","<<B.cols()<<");"<<endl;
-
-  SparseMatrix<double> C;
-
-  // Should be empty but isn't
-  C = A-B.transpose();
-  cout<<"C = A - B.transpose();"<<endl;
-  cout<<"CIJV=["<<endl;print_ijv(C,1);cout<<endl<<"];"<<endl<<
-    "C=sparse(CIJV(:,1),CIJV(:,2),CIJV(:,3),"<<
-    C.rows()<<","<<C.cols()<<");"<<endl;
-
-  // Should be empty but isn't
-  C = A-B.transpose().eval();
-  cout<<"C = A - B.transpose().eval();"<<endl;
-  cout<<"CIJV=["<<endl;print_ijv(C,1);cout<<endl<<"];"<<endl<<
-    "C=sparse(CIJV(:,1),CIJV(:,2),CIJV(:,3),"<<
-    C.rows()<<","<<C.cols()<<");"<<endl;
-
-  // This works
-  SparseMatrix<double> BT = B.transpose();
-  C = A-BT;
-  cout<<"C = A - BT;"<<endl;
-  cout<<"CIJV=["<<endl;print_ijv(C,1);cout<<endl<<"];"<<endl<<
-    "C=sparse(CIJV(:,1),CIJV(:,2),CIJV(:,3),"<<
-    C.rows()<<","<<C.cols()<<");"<<endl;
-}
-
-// Eigen claims the sparseLLT can be constructed using a SparseMatrix but
-// at runtime crashes unless it is given exclusively the lower triangle
-// 
-// Temporary solution, replace:
-// SparseLLT<SparseMatrix<T> > A_LLT(A);
-// with:
-// SparseLLT<SparseMatrix<T> > A_LLT(A.template triangularView<Eigen::Lower>());
-//
-void sparsellt_needs_triangular_view()
-{
-  // Succeeds
-  SparseMatrix<double> A(2,2);
-  A.reserve(4);
-  A.insert(0,0) = 1;
-  A.insert(0,1) = -0.5;
-  A.insert(1,0) = -0.5;
-  A.insert(1,1) = 1;
-  A.finalize();
-  cout<<"AIJV=["<<endl;print_ijv(A,1);cout<<endl<<"];"<<endl<<
-    "A=sparse(AIJV(:,1),AIJV(:,2),AIJV(:,3),"<<
-    A.rows()<<","<<A.cols()<<");"<<endl;
-  SparseLLT<SparseMatrix<double> > A_LLT(A.triangularView<Eigen::Lower>());
-  SparseMatrix<double> A_L = A_LLT.matrixL();
-  cout<<"A_LIJV=["<<endl;print_ijv(A_L,1);cout<<endl<<"];"<<endl<<
-    "A_L=sparse(A_LIJV(:,1),A_LIJV(:,2),A_LIJV(:,3),"<<
-    A_L.rows()<<","<<A_L.cols()<<");"<<endl;
-
-  //Crashes
-  SparseMatrix<double> B(2,2);
-  B.reserve(4);
-  B.insert(0,0) = 1;
-  B.insert(0,1) = -0.5;
-  B.insert(1,0) = -0.5;
-  B.insert(1,1) = 1;
-  B.finalize();
-  cout<<"BIJV=["<<endl;print_ijv(B,1);cout<<endl<<"];"<<endl<<
-    "B=sparse(BIJV(:,1),BIJV(:,2),BIJV(:,3),"<<
-    B.rows()<<","<<B.cols()<<");"<<endl;
-  SparseLLT<SparseMatrix<double> > B_LLT(B);
-}
-
-void sparsematrix_nonzeros_after_expression()
-{
-  SparseMatrix<double> A(2,2);
-  A.reserve(4);
-  A.insert(0,0) = 1;
-  A.insert(0,1) = -0.5;
-  A.insert(1,0) = -0.5;
-  A.insert(1,1) = 1;
-  A.finalize();
-  cout<<"AIJV=["<<endl;print_ijv(A,1);cout<<endl<<"];"<<endl<<
-    "A=sparse(AIJV(:,1),AIJV(:,2),AIJV(:,3),"<<
-    A.rows()<<","<<A.cols()<<");"<<endl;
-  // Succeeds
-  SparseMatrix<double> AmA = A-A;
-  cout<<"(AmA).nonZeros(): "<<AmA.nonZeros()<<endl;
-  // Succeeds
-  cout<<"(A-A).eval().nonZeros(): "<<(A-A).eval().nonZeros()<<endl;
-  // Crashes
-  cout<<"(A-A).nonZeros(): "<<(A-A).nonZeros()<<endl;
-}
-
-// Eigen's SparseLLT's succeeded() method claims to return whether LLT
-// computation was successful. Instead it seems its value is meaningless
-//
-// Temporary solution: Check for presence NaNs in matrixL()
-// bool succeeded = (A_LLT.matrixL()*0).eval().nonZeros() == 0;
-void sparsellt_succeeded_is_meaningless()
-{
-  // Should succeed
-  SparseMatrix<double> A(2,2);
-  A.reserve(4);
-  A.insert(0,0) = 1;
-  A.insert(0,1) = -0.5;
-  A.insert(1,0) = -0.5;
-  A.insert(1,1) = 1;
-  A.finalize();
-  cout<<"AIJV=["<<endl;print_ijv(A,1);cout<<endl<<"];"<<endl<<
-    "A=sparse(AIJV(:,1),AIJV(:,2),AIJV(:,3),"<<
-    A.rows()<<","<<A.cols()<<");"<<endl;
-  SparseLLT<SparseMatrix<double> > A_LLT(A.triangularView<Eigen::Lower>());
-  cout<<"A_LLT.succeeded(): "<<(A_LLT.succeeded()?"TRUE":"FALSE")<<endl;
-  SparseMatrix<double> A_L = A_LLT.matrixL();
-  // See sparsematrix_nonzeros_after_expression
-  cout<<"(A_L*0).eval().nonZeros(): "<<(A_L*0).eval().nonZeros()<<endl;
-
-  cout<<"A_LIJV=["<<endl;print_ijv(A_L,1);cout<<endl<<"];"<<endl<<
-    "A_L=sparse(A_LIJV(:,1),A_LIJV(:,2),A_LIJV(:,3),"<<
-    A_L.rows()<<","<<A_L.cols()<<");"<<endl;
-
-  // Should not succeed
-  SparseMatrix<double> B(2,2);
-  B.reserve(4);
-  B.insert(0,0) = -1;
-  B.insert(0,1) = 0.5;
-  B.insert(1,0) = 0.5;
-  B.insert(1,1) = -1;
-  B.finalize();
-  cout<<"BIJV=["<<endl;print_ijv(B,1);cout<<endl<<"];"<<endl<<
-    "B=sparse(BIJV(:,1),BIJV(:,2),BIJV(:,3),"<<
-    B.rows()<<","<<B.cols()<<");"<<endl;
-  SparseLLT<SparseMatrix<double> > B_LLT(B.triangularView<Eigen::Lower>());
-  cout<<"B_LLT.succeeded(): "<<(B_LLT.succeeded()?"TRUE":"FALSE")<<endl;
-  SparseMatrix<double> B_L = B_LLT.matrixL();
-  // See sparsematrix_nonzeros_after_expression
-  cout<<"(B_L*0).eval().nonZeros(): "<<(B_L*0).eval().nonZeros()<<endl;
-  cout<<"B_LIJV=["<<endl;print_ijv(B_L,1);cout<<endl<<"];"<<endl<<
-    "B_L=sparse(B_LIJV(:,1),B_LIJV(:,2),B_LIJV(:,3),"<<
-    B_L.rows()<<","<<B_L.cols()<<");"<<endl;
-}
-#endif
-
-int main(int argc, char * argv[])
-{
-  //wrong_sparsematrix_inner_iterator_type();
-  //sparsematrix_transpose_in_rhs_aliasing();
-  //sparsellt_needs_triangular_view();
-  //sparsematrix_nonzeros_after_expression();
-  //sparsellt_succeeded_is_meaningless();
-  return 0;
-}

+ 0 - 22
examples/embree/Makefile

@@ -1,22 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(EMBREE_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB) $(EMBREE_LIB)
-
-CFLAGS+=-g
-
-example: example.o
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) $(LIB) -o example example.o 
-
-example.o: example.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c example.cpp -o example.o $(INC)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 481
examples/embree/example.cpp

@@ -1,481 +0,0 @@
-#include <igl/opengl/OpenGL_convenience.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/per_face_normals.h>
-#include <igl/quat_to_mat.h>
-#include <igl/read_triangle_mesh.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/trackball.h>
-#include <igl/opengl2/unproject.h>
-#include <igl/embree/EmbreeIntersector.h>
-
-#ifdef __APPLE__
-#  include <GLUT/glut.h>
-#else
-#  include <GL/glut.h>
-#endif
-#include <Eigen/Core>
-
-#include <vector>
-#include <iostream>
-
-// Width and height of window
-int width,height;
-// Rotation of scene
-float scene_rot[4] = {0,0,0,1};
-// information at mouse down
-float down_scene_rot[4] = {0,0,0,1};
-bool trackball_on = false;
-int down_mouse_x,down_mouse_y;
-// Position of light
-float light_pos[4] = {0.1,0.1,-0.9,0};
-// Vertex positions, normals, colors and centroid
-Eigen::MatrixXd V,N,C,mean;
-// Bounding box diagonal length
-double bbd;
-// Faces
-Eigen::MatrixXi F;
-// Embree intersection structure
-igl::embree::EmbreeIntersector ei;
-// Hits collected
-std::vector<igl::embree::Hit > hits;
-// Ray information, "projection screen" corners
-Eigen::Vector3f win_s,s,d,dir,NW,NE,SE,SW;
-// Textures and framebuffers for "projection screen"
-GLuint tex_id = 0, fbo_id = 0, dfbo_id = 0;
-
-// Initialize textures and framebuffers. Must be called if window changes
-// dimension
-void init_texture()
-{
-  using namespace igl;
-  using namespace std;
-  // Set up a "render-to-texture" frame buffer and texture combo
-  glDeleteTextures(1,&tex_id);
-  glDeleteFramebuffersEXT(1,&fbo_id);
-  glDeleteFramebuffersEXT(1,&dfbo_id);
-  // http://www.opengl.org/wiki/Framebuffer_Object_Examples#Quick_example.2C_render_to_texture_.282D.29
-  glGenTextures(1, &tex_id);
-  glBindTexture(GL_TEXTURE_2D, tex_id);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-  //NULL means reserve texture memory, but texels are undefined
-  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
-  glBindTexture(GL_TEXTURE_2D, 0);
-  //-------------------------
-  glGenFramebuffersEXT(1, &fbo_id);
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id);
-  //Attach 2D texture to this FBO
-  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex_id, 0);
-  glGenRenderbuffersEXT(1, &dfbo_id);
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, dfbo_id);
-  glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
-  //-------------------------
-  //Attach depth buffer to FBO
-  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, dfbo_id);
-  //-------------------------
-  //Does the GPU support current FBO configuration?
-  GLenum status;
-  status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-  switch(status)
-  {
-    case GL_FRAMEBUFFER_COMPLETE_EXT:
-      break;
-    default:
-      cout<<"error"<<endl;
-  }
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-}
-
-void reshape(int width,int height)
-{
-  using namespace std;
-  // Save width and height
-  ::width = width;
-  ::height = height;
-  // Re-initialize textures and frame bufferes
-  init_texture();
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  glViewport(0,0,width,height);
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  float ones[4] = {1.0,1.0,1.0,1.0};
-  float zeros[4] = {0.0,0.0,0.0,0.0};
-  float pos[4];
-  copy(light_pos,light_pos+4,pos);
-  glLightfv(GL_LIGHT0,GL_AMBIENT,zeros);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,ones);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos);
-  pos[0] *= -1;
-  pos[1] *= -1;
-  pos[2] *= -1;
-  glLightfv(GL_LIGHT1,GL_AMBIENT,zeros);
-  glLightfv(GL_LIGHT1,GL_DIFFUSE,ones);
-  glLightfv(GL_LIGHT1,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT1,GL_POSITION,pos);
-}
-
-// Set up igl::opengl2::projection and model view of scene
-void push_scene()
-{
-  using namespace igl;
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  gluPerspective(45,(double)width/(double)height,1e-2,100);
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-  gluLookAt(0,0,3,0,0,0,0,1,0);
-  glPushMatrix();
-  float mat[4*4];
-  quat_to_mat(scene_rot,mat);
-  glMultMatrixf(mat);
-}
-
-void pop_scene()
-{
-  glPopMatrix();
-}
-
-// Scale and shift for object
-void push_object()
-{
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-mean(0,0),-mean(0,1),-mean(0,2));
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-const float back[4] = {190.0/255.0,190.0/255.0,190.0/255.0,0};
-void display()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  glClearColor(back[0],back[1],back[2],0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  // All smooth points
-  glEnable( GL_POINT_SMOOTH );
-
-  lights();
-  push_scene();
-  glEnable(GL_DEPTH_TEST);
-  glDepthFunc(GL_LEQUAL);
-  glEnable(GL_NORMALIZE);
-  glEnable(GL_COLOR_MATERIAL);
-  glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-  push_object();
-
-  if(trackball_on)
-  {
-    // Draw a "laser" line
-    glLineWidth(3.0);
-    glDisable(GL_LIGHTING);
-    glEnable(GL_DEPTH_TEST);
-    glBegin(GL_LINES);
-    glColor3f(1,0,0);
-    glVertex3fv(s.data());
-    glColor3f(1,0,0);
-    glVertex3fv(d.data());
-    glEnd();
-
-    // Draw the start and end points used for ray
-    glPointSize(10.0);
-    glBegin(GL_POINTS);
-    glColor3f(1,0,0);
-    glVertex3fv(s.data());
-    glColor3f(0,0,1);
-    glVertex3fv(d.data());
-    glEnd();
-  }
-
-  // Draw the model
-  glEnable(GL_LIGHTING);
-  igl::opengl2::draw_mesh(V,F,N,C);
-
-  // Draw all hits
-  glBegin(GL_POINTS);
-  glColor3f(0,0.2,0.2);
-  for(vector<igl::embree::Hit>::iterator hit = hits.begin();
-      hit != hits.end();
-      hit++)
-  {
-    const double w0 = (1.0-hit->u-hit->v);
-    const double w1 = hit->u;
-    const double w2 = hit->v;
-    VectorXd hitP =
-      w0 * V.row(F(hit->id,0)) +
-      w1 * V.row(F(hit->id,1)) +
-      w2 * V.row(F(hit->id,2));
-    glVertex3dv(hitP.data());
-  }
-  glEnd();
-
-  pop_object();
-
-  // Draw a nice floor
-  glPushMatrix();
-  glEnable(GL_LIGHTING);
-  glTranslated(0,-1,0);
-  igl::opengl2::draw_floor();
-  glPopMatrix();
-
-  // draw a transparent "projection screen" show model at time of hit (aka
-  // mouse down)
-  push_object();
-  if(trackball_on)
-  {
-    glColor4f(0,0,0,1.0);
-    glPointSize(10.0);
-    glBegin(GL_POINTS);
-    glVertex3fv(SW.data());
-    glVertex3fv(SE.data());
-    glVertex3fv(NE.data());
-    glVertex3fv(NW.data());
-    glEnd();
-
-    glDisable(GL_LIGHTING);
-    glEnable(GL_TEXTURE_2D);
-    glBindTexture(GL_TEXTURE_2D, tex_id);
-    glColor4f(1,1,1,0.7);
-    glBegin(GL_QUADS);
-    glTexCoord2d(0,0);
-    glVertex3fv(SW.data());
-    glTexCoord2d(1,0);
-    glVertex3fv(SE.data());
-    glTexCoord2d(1,1);
-    glVertex3fv(NE.data());
-    glTexCoord2d(0,1);
-    glVertex3fv(NW.data());
-    glEnd();
-    glBindTexture(GL_TEXTURE_2D, 0);
-    glDisable(GL_TEXTURE_2D);
-  }
-  pop_object();
-  pop_scene();
-
-  // Draw a faint point over mouse
-  if(!trackball_on)
-  {
-    glDisable(GL_LIGHTING);
-    glDisable(GL_COLOR_MATERIAL);
-    glDisable(GL_DEPTH_TEST);
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glColor4f(1.0,0.3,0.3,0.6);
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
-    gluOrtho2D(0,width,0,height);
-    glMatrixMode(GL_MODELVIEW);
-    glLoadIdentity();
-    glPointSize(20.0);
-    glBegin(GL_POINTS);
-    glVertex2fv(win_s.data());
-    glEnd();
-  }
-  igl::opengl::report_gl_error();
-
-  glutSwapBuffers();
-  glutPostRedisplay();
-}
-
-// Initialize colors to a boring green
-void init_C()
-{
-  C.col(0).setConstant(0.4);
-  C.col(1).setConstant(0.8);
-  C.col(2).setConstant(0.3);
-}
-
-void mouse_move(int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  init_C();
-  glutSetCursor(GLUT_CURSOR_CROSSHAIR);
-  // Push scene and object
-  push_scene();
-  push_object();
-  // Unproject mouse at 0 depth and some positive depth
-  win_s = Vector3f(mouse_x,height-mouse_y,0);
-  Vector3f win_d(mouse_x,height-mouse_y,1);
-  igl::opengl2::unproject(win_s,s);
-  igl::opengl2::unproject(win_d,d);
-  pop_object();
-  pop_scene();
-  igl::opengl::report_gl_error();
-  // Shoot ray at igl::opengl2::unprojected mouse in view direction
-  dir = d-s;
-  int num_rays_shot;
-  ei.intersectRay(s,dir,hits,num_rays_shot);
-  for(vector<igl::embree::Hit>::iterator hit = hits.begin();
-      hit != hits.end();
-      hit++)
-  {
-    // Change color of hit faces
-    C(hit->id,0) = 1;
-    C(hit->id,1) = 0.4;
-    C(hit->id,2) = 0.4;
-  }
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  switch(glutState)
-  {
-    case 1:
-      // up
-      glutSetCursor(GLUT_CURSOR_CROSSHAIR);
-      trackball_on = false;
-      hits.clear();
-      init_C();
-      break;
-    case 0:
-      // be sure this has been called recently
-      mouse_move(mouse_x,mouse_y);
-      // down
-      glutSetCursor(GLUT_CURSOR_CYCLE);
-      // collect information for trackball
-      trackball_on = true;
-      copy(scene_rot,scene_rot+4,down_scene_rot);
-      down_mouse_x = mouse_x;
-      down_mouse_y = mouse_y;
-      // Collect "projection screen" locations
-      push_scene();
-      push_object();
-      // igl::opengl2::unproject corners of window
-      const double depth = 0.999;
-      Vector3d win_NW(    0,height,depth);
-      Vector3d win_NE(width,height,depth);
-      Vector3d win_SE(width,0,depth);
-      Vector3d win_SW(0,0,depth);
-      igl::opengl2::unproject(win_NW,NW);
-      igl::opengl2::unproject(win_NE,NE);
-      igl::opengl2::unproject(win_SE,SE);
-      igl::opengl2::unproject(win_SW,SW);
-      // render to framebuffer
-      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id);
-      glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, dfbo_id);
-      glClearColor(0,0,0,1);
-      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-      // Render the model ---> to the framebuffer attached to the "projection
-      // screen" texture
-      glEnable(GL_COLOR_MATERIAL);
-      glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-      glEnable(GL_LIGHTING);
-      glEnable(GL_DEPTH_TEST);
-      igl::opengl2::draw_mesh(V,F,N,C);
-      pop_object();
-      pop_scene();
-      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-      glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-    break;
-  }
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-
-  if(trackball_on)
-  {
-    // Rotate according to trackball
-    trackball<float>(
-      width,
-      height,
-      2,
-      down_scene_rot,
-      down_mouse_x,
-      down_mouse_y,
-      mouse_x,
-      mouse_y,
-      scene_rot);
-  }
-}
-
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  switch(key)
-  {
-    // Ctrl-c and esc exit
-    case char(3):
-    case char(27):
-      exit(0);
-    default:
-      cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-  }
-
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  // init mesh
-  string filename = "../shared/decimated-knight.obj";
-  if(argc < 2)
-  {
-    cerr<<"Usage:"<<endl<<"    ./example input.obj"<<endl;
-    cout<<endl<<"Opening default mesh..."<<endl;
-  }else
-  {
-    // Read and prepare mesh
-    filename = argv[1];
-  }
-  if(!read_triangle_mesh(filename,V,F))
-  {
-    return 1;
-  }
-  // Compute normals, centroid, colors, bounding box diagonal
-  per_face_normals(V,F,N);
-  normalize_row_lengths(N,N);
-  mean = V.colwise().mean();
-  C.resize(F.rows(),3);
-  init_C();
-  bbd =
-    (V.colwise().maxCoeff() -
-    V.colwise().minCoeff()).maxCoeff();
-
-  // Init embree
-  ei.init(V.cast<float>(),F.cast<int>());
-
-  // Init glut
-  glutInit(&argc,argv);
-  glutInitDisplayString( "rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
-  glutCreateWindow("embree");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc(mouse_move);
-  glutMainLoop();
-  return 0;
-}

+ 0 - 21
examples/file_contents_as_string/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 14
examples/file_contents_as_string/README

@@ -1,14 +0,0 @@
-This is a simple example program that shows how to use the
-file_contents_as_string function in the igl library.
-
-
-To Build:
-  make
-
-To Run:
-  ./example [path_1] [path_2] ... [path_n]
-
-Example Run #1:
-  Issuing:
-    ./example example.cpp | diff - example.cpp
-  Should produce no differences

+ 0 - 26
examples/file_contents_as_string/example.cpp

@@ -1,26 +0,0 @@
-#include <igl/file_contents_as_string.h>
-using namespace igl;
-#include <cstdio>
-#include <string>
-using namespace std;
-
-int main(int argc, char * argv[])
-{
-  if(argc <= 1)
-  {
-    printf("USAGE:\n  ./example [path_1] [path_2] ... [path_n]\n");
-    return 1;
-  }
-  // loop over arguments
-  for(int i = 1; i < argc; i++)
-  {
-    string content;
-    bool success = file_contents_as_string(argv[i],content);
-    if(!success)
-    {
-      return 1;
-    }
-    printf("%s",content.c_str());
-  }
-  return 0;
-}

+ 0 - 32
examples/flare-eyes/Makefile

@@ -1,32 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: obj example
-
-.PHONY: example
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(MATLAB_INC) $(GLUT_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB) $(MATLAB_LIB) $(CARBON_LIB)
-
-CPP_FILES=$(wildcard ./*.cpp)
-OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o))) 
-
-CFLAGS+=-g -std=c++11
-
-example: obj $(OBJ_FILES)
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -o example $(OBJ_FILES) $(LIB)
-
-obj:
-	mkdir -p obj
-
-obj/%.o: %.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-obj/%.o: %.cpp %.h
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-clean:
-	rm -f $(OBJ_FILES)
-	rm -f example

+ 0 - 739
examples/flare-eyes/example.cpp

@@ -1,739 +0,0 @@
-#include <igl/Camera.h>
-#include <igl/PI.h>
-#include <igl/REDRUM.h>
-#include <igl/STR.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/get_seconds.h>
-#include <igl/opengl2/lens_flare.h>
-#include <igl/list_to_matrix.h>
-#include <igl/material_colors.h>
-#include <igl/pathinfo.h>
-#include <igl/per_face_normals.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/quat_to_mat.h>
-#include <igl/readMESH.h>
-#include <igl/readOBJ.h>
-#include <igl/readOFF.h>
-#include <igl/readWRL.h>
-#include <igl/opengl/render_to_tga.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/snap_to_fixed_up.h>
-#include <igl/trackball.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-
-#include <Eigen/Core>
-#include <Eigen/Geometry>
-
-#ifdef __APPLE__
-#include <GLUT/glut.h>
-#else
-#include <GL/glut.h>
-#endif
-
-#ifndef GLUT_WHEEL_UP
-#define GLUT_WHEEL_UP    3
-#endif
-#ifndef GLUT_WHEEL_DOWN
-#define GLUT_WHEEL_DOWN  4
-#endif
-#ifndef GLUT_WHEEL_RIGHT
-#define GLUT_WHEEL_RIGHT 5
-#endif
-#ifndef GLUT_WHEEL_LEFT
-#define GLUT_WHEEL_LEFT  6
-#endif
-#ifndef GLUT_ACTIVE_COMMAND
-#define GLUT_ACTIVE_COMMAND 8
-#endif
-
-#include <string>
-#include <vector>
-#include <iomanip>
-#include <stack>
-#include <iostream>
-
-bool eyes_visible = true;
-double x=6,y=232,z=61;
-
-std::vector<igl::opengl2::Flare> flares;
-std::vector<GLuint> shine_ids;
-std::vector<GLuint> flare_ids;
-int shine_tic = 0;
-
-GLuint list_id = 0;
-Eigen::MatrixXd V,N;
-Eigen::VectorXd Vmid,Vmin,Vmax;
-double bbd = 1.0;
-Eigen::MatrixXi F;
-struct State
-{
-  igl::Camera camera;
-} s;
-
-// See README for descriptions
-enum RotationType
-{
-  ROTATION_TYPE_IGL_TRACKBALL = 0,
-  ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
-  NUM_ROTATION_TYPES = 2,
-} rotation_type;
-
-std::stack<State> undo_stack;
-std::stack<State> redo_stack;
-
-bool is_rotating = false;
-int down_x,down_y;
-igl::Camera down_camera;
-bool render_to_tga_on_next = false;
-int render_count = 0;
-
-int width,height;
-Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
-
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar;
-
-bool is_animating = false;
-double animation_start_time = 0;
-double ANIMATION_DURATION = 0.5;
-Eigen::Quaterniond animation_from_quat;
-Eigen::Quaterniond animation_to_quat;
-
-void push_undo()
-{
-  undo_stack.push(s);
-  // Clear
-  redo_stack = std::stack<State>();
-}
-
-void TW_CALL set_rotation_type(const void * value, void * clientData)
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-  const RotationType old_rotation_type = rotation_type;
-  rotation_type = *(const RotationType *)(value);
-  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
-    old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
-  {
-    push_undo();
-    animation_from_quat = s.camera.m_rotation_conj;
-    snap_to_fixed_up(animation_from_quat,animation_to_quat);
-    // start animation
-    animation_start_time = get_seconds();
-    is_animating = true;
-  }
-}
-void TW_CALL get_rotation_type(void * value, void *clientData)
-{
-  RotationType * rt = (RotationType *)(value);
-  *rt = rotation_type;
-}
-
-void reshape(int width, int height)
-{
-  ::width = width;
-  ::height = height;
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-  s.camera.m_aspect = (double)width/(double)height;
-}
-
-void push_scene()
-{
-  using namespace igl;
-  using namespace std;
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  auto & camera = s.camera;
-  glMultMatrixd(camera.projection().data());
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    camera.eye()(0), camera.eye()(1), camera.eye()(2),
-    camera.at()(0), camera.at()(1), camera.at()(2),
-    camera.up()(0), camera.up()(1), camera.up()(2));
-}
-
-void push_object()
-{
-  using namespace igl;
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-Vmid(0),-Vmid(1),-Vmid(2));
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-void pop_scene()
-{
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  using namespace Eigen;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  float WHITE[4] =  {0.8,0.8,0.8,1.};
-  float GREY[4] =  {0.2,0.2,0.2,1.};
-  float BLACK[4] =  {0.,0.,0.,1.};
-  Vector4f pos = light_pos;
-  glLightfv(GL_LIGHT0,GL_AMBIENT,GREY);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,GREY);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos.data());
-  pos(0) *= -1;
-  pos(1) *= -1;
-  pos(2) *= -1;
-  glLightfv(GL_LIGHT1,GL_AMBIENT,GREY);
-  glLightfv(GL_LIGHT1,GL_DIFFUSE,WHITE);
-  glLightfv(GL_LIGHT1,GL_SPECULAR,BLACK);
-  glLightfv(GL_LIGHT1,GL_POSITION,pos.data());
-}
-
-void init_flare()
-{
-}
-
-void draw_flare()
-{
-  using namespace igl;
-  using namespace Eigen;
-  glPushMatrix();
-  glScaled(bbd*0.5,bbd*0.5,bbd*0.5);
-  glScaled(0.2,0.2,0.2);
-  Vector3f light(0,0,0);
-  igl::opengl2::lens_flare_draw(flares,shine_ids,flare_ids,light,1.0,shine_tic);
-  glPopMatrix();
-}
-
-void draw_eyes()
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-#define NUM_LEDS 2
-  Vector3d LED_pos[NUM_LEDS];
-  LED_pos[0] = Vector3d( x,y,z);
-  LED_pos[1] = Vector3d(-x,y,z);
-  enum LEDMethod
-  {
-    LED_METHOD_COLORED_CIRCLE = 0,
-    LED_METHOD_OUTLINED_CIRCLE = 1,
-    LED_METHOD_TEXTURE_FLARE = 2
-  } method = LED_METHOD_TEXTURE_FLARE;
-
-
-  for(int l = 0;l<NUM_LEDS;l++)
-  {
-    glPushMatrix();
-    glTranslated(LED_pos[l](0), LED_pos[l](1), LED_pos[l](2));
-    const double r = 2.0;
-    const float color[4] = {1,0,0,1};
-    glScaled(r,r,r);
-    switch(method)
-    {
-      case LED_METHOD_COLORED_CIRCLE:
-      {
-        glEnable(GL_COLOR_MATERIAL);
-        glColorMaterial(GL_FRONT,GL_AMBIENT);
-        glColor4fv(color);
-        glBegin(GL_TRIANGLE_FAN);
-        glVertex3d(0,0,0);
-        for(double theta = 0;theta<2.*PI;theta+=2.*PI/15.)
-        {
-          glVertex3d(cos(theta),sin(theta),0);
-        }
-        glEnd();
-        break;
-      }
-      case LED_METHOD_OUTLINED_CIRCLE:
-      {
-        glEnable(GL_COLOR_MATERIAL);
-        glDisable(GL_LIGHTING);
-        glColorMaterial(GL_FRONT,GL_DIFFUSE);
-        glBegin(GL_TRIANGLE_FAN);
-        glColor4fv(color);
-        glVertex3d(0,0,0);
-        glColor4f(0,0,0,1);
-        for(double theta = 0;theta<2.*PI;theta+=2.*PI/15.)
-        {
-          glVertex3d(cos(theta),sin(theta),0);
-        }
-        glEnd();
-        break;
-      }
-      case LED_METHOD_TEXTURE_FLARE:
-      {
-        draw_flare();
-        break;
-      }
-    }
-    glPopMatrix();
-  }
-}
-
-void display()
-{
-  using namespace igl;
-  using namespace Eigen;
-  using namespace std;
-  glClearColor(0.03,0.03,0.04,0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  if(is_animating)
-  {
-    double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
-    if(t > 1)
-    {
-      t = 1;
-      is_animating = false;
-    }
-    Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
-    auto & camera = s.camera;
-    camera.orbit(q.conjugate());
-  }
-
-  glEnable(GL_DEPTH_TEST);
-  glEnable(GL_BLEND);
-  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-  glEnable(GL_NORMALIZE);
-  lights();
-  push_scene();
-
-
-
-  if(list_id == 0)
-  {
-    list_id = glGenLists(1);
-    glNewList(list_id,GL_COMPILE);
-
-    push_object();
-    // Set material properties
-    glDisable(GL_COLOR_MATERIAL);
-    const float NEAR_BLACK[4] = {0.1,0.1,0.1,1.0};
-    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,  NEAR_BLACK);
-    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,  MIDNIGHT_BLUE_DIFFUSE);
-    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SILVER_SPECULAR);
-    glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 128);
-    igl::opengl2::draw_mesh(V,F,N);
-    pop_object();
-    // Draw a nice floor
-    glPushMatrix();
-    const double floor_offset =
-      -2./bbd*(V.col(1).maxCoeff()-Vmid(1));
-    glTranslated(0,floor_offset,0);
-    const float GREY[4] = {0.5,0.5,0.6,1.0};
-    const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-    igl::opengl2::draw_floor(GREY,DARK_GREY);
-    glPopMatrix();
-
-    glEndList();
-  }
-  glCallList(list_id);
-
-
-  push_object();
-  if(eyes_visible)
-  {
-    draw_eyes();
-  }
-  pop_object();
-
-  pop_scene();
-
-  igl::opengl::report_gl_error();
-
-  if(render_to_tga_on_next)
-  {
-    GLint viewport[4];
-    glGetIntegerv(GL_VIEWPORT,viewport);
-    igl::opengl::render_to_tga(
-      STR("./"<< "flare-eyes-" << setw(4) << setfill('0') << render_count++ << ".tga"),
-      viewport[2],viewport[3],true);
-    //render_to_tga_on_next = false;
-  }
-
-  TwDraw();
-  glutSwapBuffers();
-  glutPostRedisplay();
-}
-
-void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  GLint viewport[4];
-  glGetIntegerv(GL_VIEWPORT,viewport);
-  if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
-  {
-    static double mouse_scroll_y = 0;
-    const double delta_y = 0.125*direction;
-    mouse_scroll_y += delta_y;
-    TwMouseWheel(mouse_scroll_y);
-    return;
-  }
-  push_undo();
-
-  auto & camera = s.camera;
-  if(wheel==0)
-  {
-    // factor of zoom change
-    double s = (1.-0.01*direction);
-    //// FOV zoom: just widen angle. This is hardly ever appropriate.
-    //camera.m_angle *= s;
-    //camera.m_angle = min(max(camera.m_angle,1),89);
-    camera.push_away(s);
-  }else
-  {
-    // Dolly zoom:
-    camera.dolly_zoom((double)direction*1.0);
-  }
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  switch(glutButton)
-  {
-    case GLUT_RIGHT_BUTTON:
-    case GLUT_LEFT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_INHERIT);
-          is_rotating = false;
-          break;
-        case 0:
-          if(!tw_using)
-          {
-            push_undo();
-            glutSetCursor(GLUT_CURSOR_CYCLE);
-            // collect information for trackball
-            is_rotating = true;
-            down_camera = s.camera;
-            down_x = mouse_x;
-            down_y = mouse_y;
-          }
-        break;
-      }
-      break;
-    }
-#ifdef GLUT_WHEEL_DOWN
-    // Scroll down
-    case GLUT_WHEEL_DOWN:
-    {
-      mouse_wheel(0,-1,mouse_x,mouse_y);
-      break;
-    }
-#endif
-#ifdef GLUT_WHEEL_UP
-    // Scroll up
-    case GLUT_WHEEL_UP:
-    {
-      mouse_wheel(0,1,mouse_x,mouse_y);
-      break;
-    }
-#endif
-#ifdef GLUT_WHEEL_LEFT
-    // Scroll left
-    case GLUT_WHEEL_LEFT:
-    {
-      mouse_wheel(1,-1,mouse_x,mouse_y);
-      break;
-    }
-#endif
-#ifdef GLUT_WHEEL_RIGHT
-    // Scroll right
-    case GLUT_WHEEL_RIGHT:
-    {
-      mouse_wheel(1,1,mouse_x,mouse_y);
-      break;
-    }
-#endif
-  }
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  /*bool tw_using =*/ TwMouseMotion(mouse_x,mouse_y);
-
-  if(is_rotating)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    Quaterniond q;
-    auto & camera = s.camera;
-    switch(rotation_type)
-    {
-      case ROTATION_TYPE_IGL_TRACKBALL:
-      {
-        // Rotate according to trackball
-        igl::trackball<double>(
-          width,
-          height,
-          2.0,
-          down_camera.m_rotation_conj.coeffs().data(),
-          down_x,
-          down_y,
-          mouse_x,
-          mouse_y,
-          q.coeffs().data());
-          break;
-      }
-      case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
-      {
-        // Rotate according to two axis valuator with fixed up vector
-        two_axis_valuator_fixed_up(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-        break;
-      }
-      default:
-        break;
-    }
-    camera.orbit(q.conjugate());
-  }
-}
-
-void init_relative()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  per_face_normals(V,F,N);
-  Vmax = V.colwise().maxCoeff();
-  Vmin = V.colwise().minCoeff();
-  Vmid = 0.5*(Vmax + Vmin);
-  bbd = (Vmax-Vmin).norm();
-}
-
-
-void undo()
-{
-  using namespace std;
-  if(!undo_stack.empty())
-  {
-    redo_stack.push(s);
-    s = undo_stack.top();
-    undo_stack.pop();
-  }
-}
-
-void redo()
-{
-  using namespace std;
-  if(!redo_stack.empty())
-  {
-    undo_stack.push(s);
-    s = redo_stack.top();
-    redo_stack.pop();
-  }
-}
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  int mod = glutGetModifiers();
-  switch(key)
-  {
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    case 'z':
-    case 'Z':
-      if(mod & GLUT_ACTIVE_COMMAND)
-      {
-        if(mod & GLUT_ACTIVE_SHIFT)
-        {
-          redo();
-        }else
-        {
-          undo();
-        }
-        break;
-      }else
-      {
-        push_undo();
-        Quaterniond q;
-        snap_to_canonical_view_quat(s.camera.m_rotation_conj,1.0,q);
-        s.camera.orbit(q.conjugate());
-        break;
-      }
-    case ' ':
-      render_to_tga_on_next = !render_to_tga_on_next;
-      break;
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  string filename = "../shared/beast.obj";
-  if(argc < 2)
-  {
-    cerr<<"Usage:"<<endl<<"    ./example input.obj"<<endl;
-    cout<<endl<<"Opening default mesh..."<<endl;
-  }else
-  {
-    // Read and prepare mesh
-    filename = argv[1];
-  }
-
-  // print key commands
-  cout<<"[Click] and [drag]  Rotate model using trackball."<<endl;
-  cout<<"[Z,z]               Snap rotation to canonical view."<<endl;
-  cout<<"[⌘ Z]               Undo."<<endl;
-  cout<<"[⇧ ⌘ Z]             Redo."<<endl;
-  cout<<"[^C,ESC]            Exit."<<endl;
-
-  // dirname, basename, extension and filename
-  string d,b,ext,f;
-  pathinfo(filename,d,b,ext,f);
-  // Convert extension to lower case
-  transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-  vector<vector<double > > vV,vN,vTC;
-  vector<vector<int > > vF,vFTC,vFN;
-  if(ext == "obj")
-  {
-    // Convert extension to lower case
-    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
-    {
-      return 1;
-    }
-  }else if(ext == "off")
-  {
-    // Convert extension to lower case
-    if(!igl::readOFF(filename,vV,vF,vN))
-    {
-      return 1;
-    }
-  }else if(ext == "wrl")
-  {
-    // Convert extension to lower case
-    if(!igl::readWRL(filename,vV,vF))
-    {
-      return 1;
-    }
-  //}else
-  //{
-  //  // Convert extension to lower case
-  //  MatrixXi T;
-  //  if(!igl::readMESH(filename,V,T,F))
-  //  {
-  //    return 1;
-  //  }
-  //  //if(F.size() > T.size() || F.size() == 0)
-  //  {
-  //    boundary_facets(T,F);
-  //  }
-  }
-  if(vV.size() > 0)
-  {
-    if(!list_to_matrix(vV,V))
-    {
-      return 1;
-    }
-    polygon_mesh_to_triangle_mesh(vF,F);
-  }
-
-  init_relative();
-
-  // Init glut
-  glutInit(&argc,argv);
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("TweakBar");
-  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
-    s.camera.m_rotation_conj.coeffs().data(),"open readonly=true");
-  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
-    "igl_trackball,two-axis-valuator-fixed-up");
-  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
-    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  rebar.TwAddVarRW( "x",TW_TYPE_DOUBLE, &x,"");
-  rebar.TwAddVarRW( "y",TW_TYPE_DOUBLE, &y,"");
-  rebar.TwAddVarRW( "z",TW_TYPE_DOUBLE, &z,"");
-  rebar.TwAddVarRW( "eyes_visible",TW_TYPE_BOOLCPP, &eyes_visible,"key=e");
-  rebar.load(REBAR_NAME);
-
-  animation_from_quat = Quaterniond(1,0,0,0);
-  s.camera.m_rotation_conj = animation_from_quat;
-  animation_start_time = get_seconds();
-
-
-
-  // Init antweakbar
-  glutInitDisplayString( "rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
-  glutCreateWindow("upright");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
-  // Init flares
-  igl::opengl2::lens_flare_load_textures(shine_ids,flare_ids);
-  const float RED[3] = {1,0,0};
-  const float GREEN[3] = {0,1,0};
-  const float BLUE[3] = {0,0,1};
-  //lens_flare_create(RED,GREEN,BLUE,flares);
-  flares.resize(4);
-  flares[0] = igl::opengl2::Flare(-1, 1.0f, 1.*0.1f,  RED, 1.0);
-  flares[1] = igl::opengl2::Flare(-1, 1.0f, 1.*0.15f, GREEN, 1.0);
-  flares[2] = igl::opengl2::Flare(-1, 1.0f, 1.*0.35f, BLUE, 1.0);
-  flares[3] = igl::opengl2::Flare( 2, 1.0f, 1.*0.1f, BLUE, 0.4);
-
-  glutMainLoop();
-
-  return 0;
-}

+ 0 - 21
examples/get_seconds/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g -Wall
-inc=$(LIBIGL_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 20
examples/get_seconds/README

@@ -1,20 +0,0 @@
-Simple program showing how to use get_seconds from the igl library
-
-Compile with:
-  make
-
-Run with:
-  ./example
-which should produces something similar to:
-  start: 0.001414s
-  1.00141s - 0.001414s = 1s
-  2.00141s - 0.001414s = 2s
-  3.00142s - 0.001414s = 3s
-  4.00141s - 0.001414s = 4s
-  5.00141s - 0.001414s = 5s
-  6.00141s - 0.001414s = 6s
-  7.00141s - 0.001414s = 7s
-  8.00141s - 0.001414s = 8s
-  9.00141s - 0.001414s = 9s
-  10.0014s - 0.001414s = 10s
-  end: 10.0014s

+ 0 - 24
examples/get_seconds/example.cpp

@@ -1,24 +0,0 @@
-#include <igl/get_seconds.h>
-#include <cstdio>
-#include <cmath>
-
-int main(int argc, char * argv[])
-{
-  using namespace igl;
-  using namespace std;
-  double start = get_seconds();
-  printf("start: %lgs\n",start);
-  double lap = start;
-  double now;
-  do
-  {
-    now = get_seconds();
-    if((now-lap)>=1.0)
-    {
-      printf("%lgs - %lgs = %lgs\n",now,start,now-start);
-      lap = now-((now-start)-floor(now-start));
-    }
-  }while((now - start)<10.0);
-  printf("end: %lgs\n",now);
-  return 0;
-}

+ 0 - 23
examples/glslversion/Makefile

@@ -1,23 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-igl_lib=../../
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC)
-lib=$(OPENGL_LIB) $(GLUT_LIB) $(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 15
examples/glslversion/README

@@ -1,15 +0,0 @@
-This is a simple example program that creates a dummy GLUT window to get a
-valid opengl context then print the glsl version string
-
-
-To Build:
-  make
-
-To Run:
-  ./example
-
-Example Run #1:
-  Issuing:
-    ./example
-  should produce something like:
-    GL_SHADING_LANGUAGE_VERSION: 1.20

+ 0 - 22
examples/glslversion/example.cpp

@@ -1,22 +0,0 @@
-#ifdef __APPLE__
-#  include <GLUT/glut.h>
-#else
-#  include <GL/glut.h>
-#endif
-#include <cstdio>
-
-int main(int argc,char * argv[])
-{
-  // Make GLUT window just to get a valid OpenGL context
-  glutInit(&argc,argv);
-  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
-  glutInitWindowSize(640, 480);
-  glutCreateWindow("Dummy");
-  glutCreateMenu(NULL);
-
-  printf("GL_VERSION: %s\n", 
-    glGetString(GL_VERSION));
-  printf("GL_SHADING_LANGUAGE_VERSION: %s\n", 
-    glGetString(GL_SHADING_LANGUAGE_VERSION));
-  return 0;
-}

+ 0 - 24
examples/glut_speed_test/Makefile

@@ -1,24 +0,0 @@
-.PHONY: all
-
-all: example
-
-# Shared flags etc.
-include ../Makefile.conf
-
-.PHONY: example
-
-igl_lib=../../
-
-CFLAGS+=-g -Wall 
-INC=$(LIBIGL_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(LIB)
-
-example.o: example.cpp
-	g++ $(CFLAGS) $(deps) -c example.cpp -o example.o $(INC)
-
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 67
examples/glut_speed_test/example.cpp

@@ -1,67 +0,0 @@
-#include <igl/get_seconds.h>
-using namespace igl;
-#include <cstdio>
-#include <cmath>
-using namespace std;
-
-#if defined(__APPLE__)
-#   include <GLUT/glut.h>
-#else
-#   include <GL/glut.h>
-#endif
-
-const int width = 1088;
-const int height = 612;
-int frame_counter = 0;
-double start_time;
-// number of frames before computing fps
-const int frames_per_lap = 1000;
-
-void Display(void)
-{
-  // Clear the screen with current background color
-  glClearColor(
-    fabs(sin(get_seconds())),
-    fabs(sin(get_seconds()/3)),
-    fabs(sin(get_seconds()/7)),
-    0.0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  // Present frame buffer
-  glutSwapBuffers();
-  // Recall Display at next frame
-  glutPostRedisplay();
-
-  frame_counter++;
-  if(frame_counter == frames_per_lap)
-  {
-    double elapsed_time = get_seconds()-start_time;
-    printf("%g fps: %d frames in %g seconds\n",
-      (double)frame_counter/elapsed_time,frame_counter,elapsed_time);
-    // reset frame counter and timer
-    start_time = get_seconds();
-    frame_counter = 0;
-  }
-}
-
-int main(int argc,char * argv[])
-{
-  // Initialize GLUT
-  glutInit(&argc, argv);
-  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
-  glutInitWindowSize(width, height);
-  // Center window
-  glutInitWindowPosition(
-      glutGet(GLUT_SCREEN_WIDTH)/2-glutGet(GLUT_INIT_WINDOW_WIDTH)/2,
-      glutGet(GLUT_SCREEN_HEIGHT)/2-glutGet(GLUT_INIT_WINDOW_HEIGHT)/2);
-  glutCreateWindow("");
-  glutCreateMenu(NULL);
-  // Set GLUT callbacks
-  glutDisplayFunc(Display);
-  //glutReshapeFunc(Reshape);
-
-  // initialize timer
-  start_time = get_seconds();
-  // Call the GLUT main loop
-  glutMainLoop();
-  return 0;
-}

+ 0 - 21
examples/harwell_boeing/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g
-INC=$(LIBIGL_INC) $(EIGEN3_INC)
-LIB=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(LIB)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(INC)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 2
examples/harwell_boeing/README

@@ -1,2 +0,0 @@
-Demonstrates how to use igl/harwell_boeing which computes indices and values of compressed column storage:
-http://eigen.tuxfamily.org/api/classEigen_1_1SparseMatrix.html

+ 0 - 45
examples/harwell_boeing/example.cpp

@@ -1,45 +0,0 @@
-#define IGL_HEADER_ONLY
-#include <igl/harwell_boeing.h>
-#include <iostream>
-
-template <typename T>
-void print(T & v)
-{
-  std::cout<<v<<" ";
-}
-
-#include <cstdio>
-#include <vector>
-#include <algorithm>
-int main(int argc,char * argv[])
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-  SparseMatrix<double> A(5,5);
-  A.insert(0,1) = 3;
-  A.insert(1,0) = 22;
-  A.insert(1,4) = 17;
-  A.insert(2,0) = 7;
-  A.insert(2,1) = 5;
-  A.insert(2,3) = 1;
-  A.insert(4,2) = 14;
-  A.insert(4,4) = 8;
-
-  vector<double> V;
-  vector<int> R,C;
-
-  int nr;
-  harwell_boeing(A,nr,V,R,C);
-  cout<<"V=[";
-  for_each(V.begin(),V.end(),&print<double>);
-  cout<<"];"<<endl;
-  cout<<"R=[";
-  for_each(R.begin(),R.end(),&print<int>);
-  cout<<"];"<<endl;
-  cout<<"C=[";
-  for_each(C.begin(),C.end(),&print<int>);
-  cout<<"];"<<endl;
-
-  return 0;
-}

+ 0 - 22
examples/hello-world/example.cpp

@@ -1,22 +0,0 @@
-// Compile with GCC:
-// g++ -I/usr/local/igl/igl_lib/include -DIGL_HEADER_ONLY \
-//   -I/opt/local/include/eigen3 example.cpp -o example
-// Run with:
-// ./example ../shared/TinyTorus.obj
-#include <Eigen/Dense>
-#include <igl/readOBJ.h>
-#include <iostream>
-int main(int argc, char * argv[])
-{
-  if(argc>1)
-  {
-    Eigen::MatrixXd V;
-    Eigen::MatrixXi F;
-    igl::readOBJ(argv[1],V,F);
-    std::cout<<"Hello, mesh with "<<V.rows()<<" vertices!"<<std::endl;
-  }else{
-    std::cout<<"Hello, world!"<<std::endl;
-  }
-  return 0;
-}
-

+ 0 - 28
examples/intersections/Makefile

@@ -1,28 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-LIBIGL_LIB+=-liglcgal
-
-all: example
-
-.PHONY: example
-
-CGAL=/opt/local/
-CGAL_LIB=-L$(CGAL)/lib -lCGAL -lCGAL_Core -lgmp -lmpfr -lboost_thread-mt -lboost_system-mt
-CGAL_INC=-I$(CGAL)/include -I/usr/include/
-# This is absolutely necessary for Exact Construction
-CGAL_FLAGS=-frounding-math -fsignaling-nans 
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(EMBREE_INC) $(CGAL_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB) $(EMBREE_LIB) $(CGAL_LIB)
-CFLAGS+=$(CGAL_FLAGS)
-
-example: example.o
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) $(LIB) -o example example.o 
-
-example.o: example.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c example.cpp -o example.o $(INC)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 8
examples/intersections/README.md

@@ -1,8 +0,0 @@
-To compute and visualize all facets participating in self-intersections issue:
-
-    ./example input.obj
-
-To compute and visualize all facets participating in intersections between mesh
-A and mesh B (ignoring self-intersections in each) issue:
-
-    ./example A.obj B.obj

+ 0 - 705
examples/intersections/example.cpp

@@ -1,705 +0,0 @@
-#include <igl/Camera.h>
-#include <igl/opengl/OpenGL_convenience.h>
-#include <igl/barycenter.h>
-#include <igl/cat.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/get_seconds.h>
-#include <igl/jet.h>
-#include <igl/list_to_matrix.h>
-#include <igl/material_colors.h>
-#include <igl/matlab_format.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/pathinfo.h>
-#include <igl/per_face_normals.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/quat_to_mat.h>
-#include <igl/readDMAT.h>
-#include <igl/readMESH.h>
-#include <igl/readOBJ.h>
-#include <igl/readOFF.h>
-#include <igl/readWRL.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/snap_to_fixed_up.h>
-#include <igl/trackball.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/writeOBJ.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-#include <igl/cgal/remesh_self_intersections.h>
-#include <igl/cgal/intersect_other.h>
-
-#ifdef __APPLE__
-#  include <GLUT/glut.h>
-#else
-#  include <GL/glut.h>
-#endif
-
-#include <Eigen/Core>
-
-#include <vector>
-#include <iostream>
-#include <algorithm>
-
-struct State
-{
-  igl::Camera camera;
-} s;
-enum RotationType
-{
-  ROTATION_TYPE_IGL_TRACKBALL = 0,
-  ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
-  NUM_ROTATION_TYPES = 2,
-} rotation_type;
-bool is_rotating = false;
-int down_x,down_y;
-igl::Camera down_camera;
-bool is_animating = false;
-double animation_start_time = 0;
-double ANIMATION_DURATION = 0.5;
-Eigen::Quaterniond animation_from_quat;
-Eigen::Quaterniond animation_to_quat;
-// Use vector for range-based `for`
-std::vector<State> undo_stack;
-std::vector<State> redo_stack;
-
-void push_undo()
-{
-  undo_stack.push_back(s);
-  // Clear
-  redo_stack = std::vector<State>();
-}
-
-void undo()
-{
-  using namespace std;
-  if(!undo_stack.empty())
-  {
-    redo_stack.push_back(s);
-    s = undo_stack.front();
-    undo_stack.pop_back();
-  }
-}
-
-void redo()
-{
-  using namespace std;
-  if(!redo_stack.empty())
-  {
-    undo_stack.push_back(s);
-    s = redo_stack.front();
-    redo_stack.pop_back();
-  }
-}
-
-void TW_CALL set_rotation_type(const void * value, void * clientData)
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-  const RotationType old_rotation_type = rotation_type;
-  rotation_type = *(const RotationType *)(value);
-  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
-    old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
-  {
-    push_undo();
-    animation_from_quat = s.camera.m_rotation_conj;
-    snap_to_fixed_up(animation_from_quat,animation_to_quat);
-    // start animation
-    animation_start_time = get_seconds();
-    is_animating = true;
-  }
-}
-
-void TW_CALL get_rotation_type(void * value, void *clientData)
-{
-  RotationType * rt = (RotationType *)(value);
-  *rt = rotation_type;
-}
-
-// Width and height of window
-int width,height;
-// Position of light
-float light_pos[4] = {0.1,0.1,-0.9,0};
-// V,U  Vertex positions
-// C,D  Colors
-// N,W  Normals
-// mid  combined "centroid"
-Eigen::MatrixXd V,N,C,Z,mid,U,W,D,VU;
-// F,G  faces
-Eigen::MatrixXi F,G;
-bool has_other = false;
-bool show_A = true;
-bool show_B = true;
-int selected_col = 0;
-// Bounding box diagonal length
-double bbd;
-// Running ambient occlusion
-Eigen::VectorXd S;
-int tot_num_samples = 0;
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
-
-void reshape(int width,int height)
-{
-  using namespace std;
-  // Save width and height
-  ::width = width;
-  ::height = height;
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-  // Set aspect for all cameras
-  s.camera.m_aspect = (double)width/(double)height;
-  for(auto & s : undo_stack)
-  {
-    s.camera.m_aspect = (double)width/(double)height;
-  }
-  for(auto & s : redo_stack)
-  {
-    s.camera.m_aspect = (double)width/(double)height;
-  }
-}
-
-void push_scene()
-{
-  using namespace igl;
-  using namespace std;
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  auto & camera = s.camera;
-  gluPerspective(camera.m_angle,camera.m_aspect,camera.m_near,camera.m_far);
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    camera.eye()(0), camera.eye()(1), camera.eye()(2),
-    camera.at()(0), camera.at()(1), camera.at()(2),
-    camera.up()(0), camera.up()(1), camera.up()(2));
-}
-
-void pop_scene()
-{
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-// Scale and shift for object
-void push_object()
-{
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-mid(0,0),-mid(0,1),-mid(0,2));
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  float amb[4];
-  amb[0] = amb[1] = amb[2] = 0;
-  amb[3] = 1.0;
-  float diff[4] = {0.0,0.0,0.0,0.0};
-  diff[0] = diff[1] = diff[2] = (1.0 - 0/0.4);;
-  diff[3] = 1.0;
-  float zeros[4] = {0.0,0.0,0.0,0.0};
-  float pos[4];
-  copy(light_pos,light_pos+4,pos);
-  glLightfv(GL_LIGHT0,GL_AMBIENT,amb);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,diff);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos);
-  pos[0] *= -1;
-  pos[1] *= -1;
-  pos[2] *= -1;
-  glLightfv(GL_LIGHT1,GL_AMBIENT,amb);
-  glLightfv(GL_LIGHT1,GL_DIFFUSE,diff);
-  glLightfv(GL_LIGHT1,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT1,GL_POSITION,pos);
-}
-
-const float back[4] = {30.0/255.0,30.0/255.0,50.0/255.0,0};
-void display()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  glClearColor(back[0],back[1],back[2],0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  if(is_animating)
-  {
-    double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
-    if(t > 1)
-    {
-      t = 1;
-      is_animating = false;
-    }
-    const Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
-    s.camera.orbit(q.conjugate());
-  }
-
-  glDisable(GL_LIGHTING);
-  lights();
-  push_scene();
-  glEnable(GL_DEPTH_TEST);
-  glDepthFunc(GL_LEQUAL);
-  glEnable(GL_NORMALIZE);
-  glEnable(GL_COLOR_MATERIAL);
-  glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-  push_object();
-
-  // Draw the model
-  // Set material properties
-  glEnable(GL_COLOR_MATERIAL);
-
-  const auto draw = [](
-    const MatrixXd & V,
-    const MatrixXi & F,
-    const MatrixXd & N,
-    const MatrixXd & C)
-  {
-    glEnable(GL_COLOR_MATERIAL);
-    glEnable(GL_POLYGON_OFFSET_FILL); // Avoid Stitching!
-    glPolygonOffset(1.0,1);
-    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-    igl::opengl2::draw_mesh(V,F,N,C);
-    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
-    glDisable(GL_COLOR_MATERIAL);
-    const float black[4] = {0,0,0,1};
-    glColor4fv(black);
-    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,  black);
-    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,  black);
-    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
-    glLightfv(GL_LIGHT0, GL_AMBIENT, black);
-    glLightfv(GL_LIGHT0, GL_DIFFUSE, black);
-    glLineWidth(1.0);
-    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-    igl::opengl2::draw_mesh(V,F,N,C);
-    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-    glEnable(GL_COLOR_MATERIAL);
-  };
-  if(show_A)
-  {
-    draw(V,F,N,C);
-  }
-  if(show_B)
-  {
-    draw(U,G,W,D);
-  }
-
-  pop_object();
-
-  // Draw a nice floor
-  glPushMatrix();
-  const double floor_offset =
-    -2./bbd*(VU.col(1).maxCoeff()-mid(1));
-  glTranslated(0,floor_offset,0);
-  const float GREY[4] = {0.5,0.5,0.6,1.0};
-  const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  igl::opengl2::draw_floor(GREY,DARK_GREY);
-  glPopMatrix();
-
-  pop_scene();
-
-  igl::opengl::report_gl_error();
-
-  TwDraw();
-  glutSwapBuffers();
-  if(is_animating)
-  {
-    glutPostRedisplay();
-  }
-}
-
-void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  GLint viewport[4];
-  glGetIntegerv(GL_VIEWPORT,viewport);
-  if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
-  {
-    static double mouse_scroll_y = 0;
-    const double delta_y = 0.125*direction;
-    mouse_scroll_y += delta_y;
-    TwMouseWheel(mouse_scroll_y);
-    return;
-  }
-  push_undo();
-  auto & camera = s.camera;
-  if(wheel==0)
-  {
-    // factor of zoom change
-    double s = (1.-0.01*direction);
-    //// FOV zoom: just widen angle. This is hardly ever appropriate.
-    //camera.m_angle *= s;
-    //camera.m_angle = min(max(camera.m_angle,1),89);
-    camera.push_away(s);
-  }else
-  {
-    // Dolly zoom:
-    camera.dolly_zoom((double)direction*1.0);
-  }
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  switch(glutButton)
-  {
-    case GLUT_RIGHT_BUTTON:
-    case GLUT_LEFT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
-          is_rotating = false;
-          break;
-        case 0:
-          // down
-          if(!tw_using)
-          {
-            glutSetCursor(GLUT_CURSOR_CYCLE);
-            // collect information for trackball
-            is_rotating = true;
-            down_camera = s.camera;
-            down_x = mouse_x;
-            down_y = mouse_y;
-          }
-        break;
-      }
-      break;
-    }
-    // Scroll down
-    case 3:
-    {
-      mouse_wheel(0,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll up
-    case 4:
-    {
-      mouse_wheel(0,1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll left
-    case 5:
-    {
-      mouse_wheel(1,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll right
-    case 6:
-    {
-      mouse_wheel(1,1,mouse_x,mouse_y);
-      break;
-    }
-  }
-  glutPostRedisplay();
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace Eigen;
-
-  if(is_rotating)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    Quaterniond q;
-    auto & camera = s.camera;
-    switch(rotation_type)
-    {
-      case ROTATION_TYPE_IGL_TRACKBALL:
-      {
-        // Rotate according to trackball
-        igl::trackball<double>(
-          width,
-          height,
-          2.0,
-          down_camera.m_rotation_conj.coeffs().data(),
-          down_x,
-          down_y,
-          mouse_x,
-          mouse_y,
-          q.coeffs().data());
-          break;
-      }
-      case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
-      {
-        // Rotate according to two axis valuator with fixed up vector
-        two_axis_valuator_fixed_up(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-        break;
-      }
-      default:
-        break;
-    }
-    camera.orbit(q.conjugate());
-  }else
-  {
-    TwEventMouseMotionGLUT(mouse_x, mouse_y);
-  }
-  glutPostRedisplay();
-}
-
-
-
-void color_selfintersections(
-  const Eigen::MatrixXd & V,
-  const Eigen::MatrixXi & F,
-  Eigen::MatrixXd & C)
-{
-  using namespace igl;
-  using namespace igl::cgal;
-  using namespace Eigen;
-  using namespace std;
-  MatrixXd SV;
-  MatrixXi SF,IF;
-  VectorXi J,IM;
-  RemeshSelfIntersectionsParam params;
-  params.detect_only = false;
-  remesh_self_intersections(V,F,params,SV,SF,IF,J,IM);
-  writeOBJ("FUCK.obj",SV,SF);
-  C.resize(F.rows(),3);
-  C.col(0).setConstant(0.4);
-  C.col(1).setConstant(0.8);
-  C.col(2).setConstant(0.3);
-  for(int f = 0;f<IF.rows();f++)
-  {
-    C.row(IF(f,0)) = RowVector3d(1,0.4,0.4);
-    C.row(IF(f,1)) = RowVector3d(1,0.4,0.4);
-  }
-}
-
-void color_intersections(
-  const Eigen::MatrixXd & V,
-  const Eigen::MatrixXi & F,
-  const Eigen::MatrixXd & U,
-  const Eigen::MatrixXi & G,
-  Eigen::MatrixXd & C,
-  Eigen::MatrixXd & D)
-{
-  using namespace igl;
-  using namespace igl::cgal;
-  using namespace Eigen;
-  MatrixXi IF;
-  const bool first_only = false;
-  intersect_other(V,F,U,G,first_only,IF);
-  C.resize(F.rows(),3);
-  C.col(0).setConstant(0.4);
-  C.col(1).setConstant(0.8);
-  C.col(2).setConstant(0.3);
-  D.resize(G.rows(),3);
-  D.col(0).setConstant(0.4);
-  D.col(1).setConstant(0.3);
-  D.col(2).setConstant(0.8);
-  for(int f = 0;f<IF.rows();f++)
-  {
-    C.row(IF(f,0)) = RowVector3d(1,0.4,0.4);
-    D.row(IF(f,1)) = RowVector3d(0.8,0.7,0.3);
-  }
-}
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  switch(key)
-  {
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-
-  glutPostRedisplay();
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  // init mesh
-  string filename = "../shared/truck.obj";
-  string filename_other = "";
-  switch(argc)
-  {
-    case 3:
-      // Read and prepare mesh
-      filename_other = argv[2];
-      has_other=true;
-      // fall through
-    case 2:
-      // Read and prepare mesh
-      filename = argv[1];
-      break;
-    default:
-    cerr<<"Usage:"<<endl<<"    ./example input.obj [other.obj]"<<endl;
-    cout<<endl<<"Opening default mesh..."<<endl;
-  }
-
-  const auto read = []
-    (const string & filename, MatrixXd & V, MatrixXi & F, MatrixXd & N) -> bool
-  {
-    // dirname, basename, extension and filename
-    string d,b,ext,f;
-    pathinfo(filename,d,b,ext,f);
-    // Convert extension to lower case
-    transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-    vector<vector<double > > vV,vN,vTC;
-    vector<vector<int > > vF,vFTC,vFN;
-    if(ext == "obj")
-    {
-      // Convert extension to lower case
-      if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
-      {
-        return false;
-      }
-    }else if(ext == "off")
-    {
-      // Convert extension to lower case
-      if(!igl::readOFF(filename,vV,vF,vN))
-      {
-        return false;
-      }
-    }else if(ext == "wrl")
-    {
-      // Convert extension to lower case
-      if(!igl::readWRL(filename,vV,vF))
-      {
-        return false;
-      }
-    //}else
-    //{
-    //  // Convert extension to lower case
-    //  MatrixXi T;
-    //  if(!igl::readMESH(filename,V,T,F))
-    //  {
-    //    return false;
-    //  }
-    //  //if(F.size() > T.size() || F.size() == 0)
-    //  {
-    //    boundary_facets(T,F);
-    //  }
-    }
-    if(vV.size() > 0)
-    {
-      if(!list_to_matrix(vV,V))
-      {
-        return false;
-      }
-      polygon_mesh_to_triangle_mesh(vF,F);
-    }
-    // Compute normals, centroid, colors, bounding box diagonal
-    per_face_normals(V,F,N);
-    return true;
-  };
-
-  if(!read(filename,V,F,N))
-  {
-    return 1;
-  }
-  if(has_other)
-  {
-    if(!read(argv[2],U,G,W))
-    {
-      return 1;
-    }
-    cat(1,V,U,VU);
-    color_intersections(V,F,U,G,C,D);
-  }else
-  {
-    VU = V;
-    color_selfintersections(V,F,C);
-  }
-  mid = 0.5*(VU.colwise().maxCoeff() + VU.colwise().minCoeff());
-  bbd = (VU.colwise().maxCoeff() - VU.colwise().minCoeff()).maxCoeff();
-
-  // Init glut
-  glutInit(&argc,argv);
-
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("TweakBar");
-  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
-    s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  s.camera.push_away(3);
-  s.camera.dolly_zoom(25-s.camera.m_angle);
-  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
-    "igl_trackball,two-a...-fixed-up");
-  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
-    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  if(has_other)
-  {
-    rebar.TwAddVarRW("show_A",TW_TYPE_BOOLCPP,&show_A, "key=a",false);
-    rebar.TwAddVarRW("show_B",TW_TYPE_BOOLCPP,&show_B, "key=b",false);
-  }
-  rebar.load(REBAR_NAME);
-
-  glutInitDisplayString("rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
-  glutCreateWindow("mesh-intersections");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc(
-    [](int x, int y)
-    {
-      TwEventMouseMotionGLUT(x,y);
-      glutPostRedisplay();
-    });
-  static std::function<void(int)> timer_bounce;
-  auto timer = [] (int ms) {
-    timer_bounce(ms);
-  };
-  timer_bounce = [&] (int ms) {
-    glutTimerFunc(ms, timer, ms);
-    glutPostRedisplay();
-  };
-  glutTimerFunc(500, timer, 500);
-
-  glutMainLoop();
-  return 0;
-}

+ 0 - 21
examples/is_dir/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 18
examples/is_dir/README

@@ -1,18 +0,0 @@
-This is a simple example program that shows how to use the is_dir function of
-is_dir.h in the igl library.
-
-
-To Build:
-  make
-
-To Run:
-  ./example [path_1] [path_2] ... [path_n]
-
-Example Run #1:
-  Issuing:
-    ./example . .. example.cpp non-existant-file
-  should produce:
-    is_dir(.) --> TRUE
-    is_dir(..) --> TRUE
-    is_dir(example.cpp) --> FALSE
-    is_dir(non-existant-file) --> FALSE

+ 0 - 18
examples/is_dir/example.cpp

@@ -1,18 +0,0 @@
-#include <igl/is_dir.h>
-using namespace igl;
-#include <cstdio>
-
-int main(int argc, char * argv[])
-{
-  if(argc <= 1)
-  {
-    printf("USAGE:\n  ./example [path_1] [path_2] ... [path_n]\n");
-    return 1;
-  }
-  // loop over arguments
-  for(int i = 1; i < argc; i++)
-  {
-    printf("is_dir(%s) --> %s\n",argv[i],(is_dir(argv[i])?"TRUE":"FALSE"));
-  }
-  return 0;
-}

+ 0 - 21
examples/marching_cubes/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-all: example
-
-.PHONY: example
-
-# Shared flags etc.
-include ../Makefile.conf
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC) $(EIGEN3_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 73
examples/marching_cubes/example.cpp

@@ -1,73 +0,0 @@
-#include <igl/marching_cubes.h>
-#include <iostream>
-#include <cstdio>
-
-#include "igl/MCTables.hh"
-
-typedef float ScalarType;
-typedef unsigned IndexType;
-int main(int argc, char * argv[])
-{
-  Eigen::Matrix<ScalarType, 1, 3> bb_min, bb_max;
-  bb_min<<0.,0.,0.;
-  bb_max<<1.,1.,1.;
-  
-  //diagonal
-  Eigen::Matrix<ScalarType, 1, 3> diff = bb_max - bb_min;
-  
-  
-  //center of the sphere
-  Eigen::Matrix<ScalarType, 1, 3> center = 0.5 * (bb_min + bb_max);
-  
-  IndexType xres, yres, zres;
-  xres = yres = zres = 10;
-  ScalarType radius = 0.42;
-
-  //steps in x,y,z direction
-  ScalarType dx = diff[0] / (ScalarType)(xres-1);
-  ScalarType dy = diff[1] / (ScalarType)(yres-1);
-  ScalarType dz = diff[2] / (ScalarType)(zres-1);
-  
-  
-  Eigen::Matrix<ScalarType, Eigen::Dynamic, 3> points(xres*yres*zres,3);
-  Eigen::Matrix<ScalarType, Eigen::Dynamic, 1> values(xres*yres*zres,1);
-  
-  Eigen::Matrix<ScalarType, Eigen::Dynamic, 3> vertices;
-  
-  Eigen::Matrix<IndexType, Eigen::Dynamic, 3> faces;
-
-  std::cerr<<"Sphere -- construct grid"<<std::endl;
-  for (unsigned int x=0; x<xres; ++x)
-    for (unsigned int y=0; y<yres; ++y)
-      for (unsigned int z=0; z<zres; ++z)
-      {
-        int index = x + y*xres + z*xres*yres;
-        points.row(index) = bb_min + 
-        ScalarType(x)*Eigen::Matrix<ScalarType, 1, 3>(dx,0.,0.) + 
-        ScalarType(y)*Eigen::Matrix<ScalarType, 1, 3>(0.,dy,0.) + 
-        ScalarType(z)*Eigen::Matrix<ScalarType, 1, 3>(0.,0.,dz);
-        
-        values[index] = (points.row(index) - center).squaredNorm() - radius*radius;
-      }
-  
-  
-  std::cerr<<"Sphere -- marching cubes"<<std::endl;
-  igl::marching_cubes(values, 
-                      points, 
-                      xres, 
-                      yres, 
-                      zres, 
-                      vertices,
-                      faces);
-
-  std::cerr<<"Sphere -- saving"<<std::endl;
-  FILE * fid = fopen("sphere.obj","w");
-  for (unsigned i = 0; i<vertices.rows(); ++i)
-    fprintf(fid,"v %.10g %.10g %.10g\n",vertices(i,0),vertices(i,1),vertices(i,2));
-  for (unsigned i = 0; i<faces.rows(); ++i)
-    fprintf(fid,"f %d %d %d\n",faces(i,0)+1,faces(i,1)+1,faces(i,2)+1);
-  fclose(fid);
-
-  std::cerr<<"Sphere -- done."<<std::endl;
-  return 0;
-}

+ 0 - 21
examples/meshio/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC) $(EIGEN3_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 9
examples/meshio/README

@@ -1,9 +0,0 @@
-This is a simple example program that shows how to use the mesh IO functions of
-readOBJ.h etc. in the igl library.
-
-
-To Build:
-  make
-
-To Run:
-  ./example [path_1] [path_2] ... [path_n]

+ 0 - 33
examples/meshio/cube.obj

@@ -1,33 +0,0 @@
-# cube.obj
-#
- 
-g cube
- 
-v  0.0  0.0  0.0
-v  0.0  0.0  1.0
-v  0.0  1.0  0.0
-v  0.0  1.0  1.0
-v  1.0  0.0  0.0
-v  1.0  0.0  1.0
-v  1.0  1.0  0.0
-v  1.0  1.0  1.0
-
-vn  0.0  0.0  1.0
-vn  0.0  0.0 -1.0
-vn  0.0  1.0  0.0
-vn  0.0 -1.0  0.0
-vn  1.0  0.0  0.0
-vn -1.0  0.0  0.0
- 
-f  1//2  7//2  5//2
-f  1//2  3//2  7//2 
-f  1//6  4//6  3//6 
-f  1//6  2//6  4//6 
-f  3//3  8//3  7//3 
-f  3//3  4//3  8//3 
-f  5//5  7//5  8//5 
-f  5//5  8//5  6//5 
-f  1//4  5//4  6//4 
-f  1//4  6//4  2//4 
-f  2//1  6//1  8//1 
-f  2//1  8//1  4//1 

+ 0 - 65
examples/meshio/example.cpp

@@ -1,65 +0,0 @@
-#include <igl/readOBJ.h>
-#include <iostream>
-
-#include <cstdio>
-#include <vector>
-#include <algorithm>
-#include <functional>
-
-#include <Eigen/Dense>
-
-using namespace igl;
-using namespace std;
-using namespace Eigen;
-
-// Template:
-//   T  type that can be safely cast to float
-// Inputs:
-//   vv  vector of vectors of type T
-template <typename T>
-void print_vector_of_vectors_as_floats(const std::vector<std::vector<T > > & vv)
-{
-  for(int i = 0;i<vv.size();i++)
-  {
-    for(int j = 0;j<vv[i].size();j++)
-    {
-      printf("%g ",(float)(vv[i][j]));
-    }
-    printf("\n");
-  }
-}
-
-int main(int argc, char * argv[])
-{
-  if(argc <= 1)
-  {
-    printf("USAGE:\n  ./example [path_1] [path_2] ... [path_n]\n");
-    return 1;
-  }
-  vector<std::vector<double> > V,TC,N;
-  vector<std::vector<int> > F,FTC,FN;
-  // loop over arguments
-  for(int i = 1; i < argc; i++)
-  {
-    if(i != 1)
-    {
-      printf("-----------------------------------------------------------\n");
-    }
-    readOBJ(argv[i],V,TC,N,F,FTC,FN);
-    cout<<"V=[";  print_vector_of_vectors_as_floats(V);  cout<<"];"<<endl;
-    cout<<"TC=["; print_vector_of_vectors_as_floats(TC); cout<<"];"<<endl;
-    cout<<"N=[";  print_vector_of_vectors_as_floats(N);  cout<<"];"<<endl;
-    cout<<"F=[";  print_vector_of_vectors_as_floats(F);  cout<<"];"<<endl;
-    cout<<"FTC=[";print_vector_of_vectors_as_floats(FTC);cout<<"];"<<endl;
-    cout<<"FN=["; print_vector_of_vectors_as_floats(FN); cout<<"];"<<endl;
-    // Eigen (V,F) style
-    MatrixXd EV;
-    MatrixXi EF;
-    readOBJ(argv[i],EV,EF);
-    cout<<"EV=["<<EV<<"];"<<endl;
-    cout<<"EF=["<<EF<<"];"<<endl;
-  }
-
-
-  return 0;
-}

+ 0 - 88
examples/meshio/torus.obj

@@ -1,88 +0,0 @@
-####
-#
-# OBJ File Generated by Meshlab
-#
-####
-# Object TinyTorus.obj
-#
-# Vertices: 24
-# Faces: 48
-#
-####
-v -2.000000 0.000000 0.000000
-v -3.000000 0.000000 -1.000000
-v -4.000000 0.000000 -0.000001
-v -3.000000 0.000000 1.000000
-v -1.000000 -1.732050 0.000000
-v -1.500000 -2.598080 -1.000000
-v -2.000000 -3.464100 -0.000001
-v -1.500000 -2.598080 1.000000
-v 1.000000 -1.732050 0.000000
-v 1.500000 -2.598080 -1.000000
-v 2.000000 -3.464100 -0.000001
-v 1.500000 -2.598080 1.000000
-v 2.000000 0.000000 0.000000
-v 3.000000 0.000000 -1.000000
-v 4.000000 0.000000 -0.000001
-v 3.000000 0.000000 1.000000
-v 1.000000 1.732050 0.000000
-v 1.500000 2.598080 -1.000000
-v 2.000000 3.464100 -0.000001
-v 1.500000 2.598080 1.000000
-v -1.000000 1.732050 0.000000
-v -1.500000 2.598080 -1.000000
-v -2.000000 3.464100 -0.000001
-v -1.500000 2.598080 1.000000
-# 24 vertices, 0 vertices normals
-
-f 2 1 6
-f 5 6 1
-f 3 2 7
-f 6 7 2
-f 4 3 8
-f 7 8 3
-f 1 4 5
-f 8 5 4
-f 6 5 10
-f 9 10 5
-f 7 6 11
-f 10 11 6
-f 8 7 12
-f 11 12 7
-f 5 8 9
-f 12 9 8
-f 10 9 14
-f 13 14 9
-f 11 10 15
-f 14 15 10
-f 12 11 16
-f 15 16 11
-f 9 12 13
-f 16 13 12
-f 14 13 18
-f 17 18 13
-f 15 14 19
-f 18 19 14
-f 16 15 20
-f 19 20 15
-f 13 16 17
-f 20 17 16
-f 18 17 22
-f 21 22 17
-f 19 18 23
-f 22 23 18
-f 20 19 24
-f 23 24 19
-f 17 20 21
-f 24 21 20
-f 22 21 2
-f 1 2 21
-f 23 22 3
-f 2 3 22
-f 24 23 4
-f 3 4 23
-f 21 24 1
-f 4 1 24
-# 48 faces, 0 coords texture
-
-# End of File

+ 0 - 21
examples/mode/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC) $(EIGEN3_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 9
examples/mode/README

@@ -1,9 +0,0 @@
-This is a simple example program that shows how to use the mode function on
-eigen matrices like matlab's mode(X,dim) function
-
-
-To Build:
-  make
-
-To Run:
-  ./example

+ 0 - 34
examples/mode/example.cpp

@@ -1,34 +0,0 @@
-// g++ -o main main.cpp -I. -I/usr/local/include/eigen3
-#include <igl/mode.h>
-#include <Eigen/Core>
-#include <iostream>
-
-using namespace std;
-using namespace igl;
-using namespace Eigen;
-
-
-template <class T>
-void matlab_print(const string name, const T & X)
-{
-  cout<<name<<"=["<<endl<<X<<endl<<"];"<<endl;
-}
-
-int main(int argc, char * argv[])
-{
-  Eigen::MatrixXd X(3,4);
-  X << 
-    3,5,4,5,
-    1,2,4,2,
-    1,1,2,5;
-  matlab_print("X",X);
-
-  // Sorted output matrix
-  Eigen::Matrix<double,Dynamic,1> M1;
-  mode(X,1,M1);
-  matlab_print("M1",M1);
-
-  Eigen::Matrix<double,Dynamic,1> M2;
-  mode(X,2,M2);
-  matlab_print("M2",M2);
-}

+ 0 - 23
examples/multi-viewport/Makefile

@@ -1,23 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-
-all: example 
-
-.PHONY:  example
-
-include ../Makefile.conf
-
-CFLAGS+=-std=c++11 -g -Wno-deprecated-declarations
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB)
-
-example: example.o
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -o example example.o $(LIB)
-
-example.o: example.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c example.cpp -o example.o $(INC)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 544
examples/multi-viewport/example.cpp

@@ -1,544 +0,0 @@
-#include <igl/Camera.h>
-#include <igl/EPS.h>
-#include <igl/opengl/OpenGL_convenience.h>
-#include <igl/STR.h>
-#include <igl/Viewport.h>
-#include <igl/canonical_quaternions.h>
-#include <igl/opengl2/draw_beach_ball.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/per_face_normals.h>
-#include <igl/opengl2/project.h>
-#include <igl/quat_to_mat.h>
-#include <igl/read_triangle_mesh.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/trackball.h>
-#include <igl/opengl2/unproject.h>
-#include <igl/opengl2/unproject_to_zero_plane.h>
-
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#  include <OpenGL/glu.h>
-#  include <GLUT/glut.h>
-#else
-#  include <GL/glut.h>
-#endif
-#include <Eigen/Core>
-
-#include <vector>
-#include <iostream>
-#include <string>
-#include <algorithm>
-#define IGL_HEADER_ONLY
-#include <igl/opengl2/draw_floor.h>
-
-#define NUM_VIEWPORTS 4
-class AugViewport : public igl::Viewport
-{
-  public:
-    igl::Camera camera;
-} viewports[NUM_VIEWPORTS];
-double horiz = 0.5;
-double vert = 0.5;
-bool horiz_on = false, vert_on = false;
-
-// Width and height of window
-int width,height;
-// information at mouse down
-igl::Camera down_camera;
-bool trackball_on = false;
-int down_mouse_x,down_mouse_y,move_x,move_y;
-int down_vp;
-// Position of light
-float light_pos[4] = {0.1,0.1,-0.9,0};
-// Vertex positions, normals, colors and centroid
-Eigen::MatrixXd V,N,C,mean;
-// Bounding box diagonal length
-double bbd;
-// Faces
-Eigen::MatrixXi F;
-Eigen::Vector3d ball;
-
-
-void init_viewports()
-{
-  using namespace igl;
-  using namespace std;
-  for(auto & vp : viewports)
-  {
-    vp.camera.push_away(5.);
-  }
-  viewports[0].camera.dolly_zoom(0.-viewports[0].camera.m_angle);
-  viewports[1].camera.dolly_zoom(0.-viewports[1].camera.m_angle);
-  viewports[2].camera.dolly_zoom(0.-viewports[2].camera.m_angle);
-  viewports[3].camera.dolly_zoom(25.-viewports[3].camera.m_angle);
-  // Above view
-  double XZ_PLANE_QUAT_D_FLIP[4];
-  copy(XZ_PLANE_QUAT_D,XZ_PLANE_QUAT_D+4,XZ_PLANE_QUAT_D_FLIP);
-  XZ_PLANE_QUAT_D_FLIP[0] *= -1.0;
-  // Straight on
-  copy(
-    XZ_PLANE_QUAT_D_FLIP,
-    XZ_PLANE_QUAT_D_FLIP+4,
-    viewports[0].camera.m_rotation_conj.coeffs().data());
-  // Left side view
-  copy(
-    XY_PLANE_QUAT_D,
-    XY_PLANE_QUAT_D+4,
-    viewports[1].camera.m_rotation_conj.coeffs().data());
-  copy(
-    CANONICAL_VIEW_QUAT_D[14],
-    CANONICAL_VIEW_QUAT_D[14]+4,
-    viewports[2].camera.m_rotation_conj.coeffs().data());
-  // Straight on
-  copy(
-    XY_PLANE_QUAT_D,
-    XY_PLANE_QUAT_D+4,
-    viewports[3].camera.m_rotation_conj.coeffs().data());
-}
-
-const double BAR_THICKNESS = 3.0;
-void clamp(const double horiz, const double vert, double & eff_h, double & eff_v)
-{
-  eff_h = horiz;
-  eff_v = vert;
-  const double MIN_H = (BAR_THICKNESS/2.0)/(double)height;
-  const double MIN_V = (BAR_THICKNESS/2.0)/(double)width;
-  eff_h = eff_h < MIN_H ? MIN_H : eff_h;
-  eff_v = eff_v < MIN_V ? MIN_V : eff_v;
-  eff_h = eff_h > (1.0-MIN_H) ? (1.0-MIN_H) : eff_h;
-  eff_v = eff_v > (1.0-MIN_V) ? (1.0-MIN_V) : eff_v;
-}
-
-// Viewports are arranged like planar quadrants (CCW)
-// /-----.-----\
-// |  1  |  0  |
-// -------------
-// |  2  |  3  |
-// \-----.-----/
-void reshape_viewports()
-{
-  // Make horiz and vert sane
-  horiz = (horiz < 0 ? 0 : horiz);
-  vert = (vert < 0 ? 0 : vert);
-  horiz = (horiz > 1 ? 1 : horiz);
-  vert = (vert > 1 ? 1 : vert);
-  // Make effective horiz and vert even saner
-  double eff_h,eff_v;
-  clamp(horiz,vert,eff_h,eff_v);
-  viewports[0].reshape(eff_v*width,eff_h*height,(1.-eff_v)*width,(1.-eff_h)*height);
-  viewports[1].reshape(         0,eff_h*height,     eff_v*width,(1.-eff_h)*height);
-  viewports[2].reshape(         0,           0,     eff_v*width,eff_h*height);
-  viewports[3].reshape(eff_v*width,           0,(1.-eff_v)*width,eff_h*height);
-  for(auto & vp : viewports)
-  {
-    vp.camera.m_aspect = (double)vp.width/(double)vp.height;
-  }
-}
-
-void reshape(int width,int height)
-{
-  using namespace std;
-  // Save width and height
-  ::width = width;
-  ::height = height;
-  reshape_viewports();
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  float ones[4] = {1.0,1.0,1.0,1.0};
-  float zeros[4] = {0.0,0.0,0.0,0.0};
-  float pos[4];
-  copy(light_pos,light_pos+4,pos);
-  glLightfv(GL_LIGHT0,GL_AMBIENT,zeros);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,ones);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos);
-  pos[0] *= -1;
-  pos[1] *= -1;
-  pos[2] *= -1;
-  glLightfv(GL_LIGHT1,GL_AMBIENT,zeros);
-  glLightfv(GL_LIGHT1,GL_DIFFUSE,ones);
-  glLightfv(GL_LIGHT1,GL_SPECULAR,zeros);
-  glLightfv(GL_LIGHT1,GL_POSITION,pos);
-}
-
-// Set up igl::opengl2::projection and model view of scene
-void push_scene(const AugViewport & vp)
-{
-  using namespace igl;
-  using namespace std;
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  auto & camera = vp.camera;
-  glMultMatrixd(camera.projection().data());
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    camera.eye()(0), camera.eye()(1), camera.eye()(2),
-    camera.at()(0), camera.at()(1), camera.at()(2),
-    camera.up()(0), camera.up()(1), camera.up()(2));
-}
-
-void pop_scene()
-{
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-}
-
-// Scale and shift for object
-void push_object()
-{
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-mean(0,0),-mean(0,1),-mean(0,2));
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-const float back[4] = {190.0/255.0,190.0/255.0,190.0/255.0,0};
-void display()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  glClearColor(back[0],back[1],back[2],0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  // All smooth points
-  glEnable( GL_POINT_SMOOTH );
-
-  // Flashlights
-  lights();
-  for(int vp = 0;vp<NUM_VIEWPORTS;vp++)
-  {
-    if(
-      viewports[vp].width <= 0 ||
-      viewports[vp].height <= 0)
-    {
-      continue;
-    }
-    glViewport(
-      viewports[vp].x,
-      viewports[vp].y,
-      viewports[vp].width,
-      viewports[vp].height);
-    push_scene(viewports[vp]);
-    glEnable(GL_DEPTH_TEST);
-    glDepthFunc(GL_LEQUAL);
-    glEnable(GL_NORMALIZE);
-    glEnable(GL_COLOR_MATERIAL);
-    glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-    push_object();
-    // Draw the model
-    glEnable(GL_LIGHTING);
-    igl::opengl2::draw_mesh(V,F,N,C);
-    pop_object();
-
-    // Draw a nice floor
-    glPushMatrix();
-    glCullFace(GL_BACK);
-    glEnable(GL_CULL_FACE);
-    glEnable(GL_LIGHTING);
-    glTranslated(0,-1,0);
-    if(igl::opengl2::project(Vector3d(0,0,0))(2) - igl::opengl2::project(Vector3d(0,1,0))(2) > -FLOAT_EPS)
-    {
-      igl::opengl2::draw_floor_outline();
-    }
-    igl::opengl2::draw_floor();
-    glPopMatrix();
-    glDisable(GL_CULL_FACE);
-
-    // Draw a ball at the mouse
-    if(!horiz_on && !vert_on && !trackball_on)
-    {
-      glPushMatrix();
-      glTranslated(ball(0),ball(1),ball(2));
-      glScaled(0.1,0.1,0.1);
-      igl::opengl2::draw_beach_ball();
-      glPopMatrix();
-    }
-
-    pop_scene();
-  }
-
-  // Screen space
-  glDisable(GL_DEPTH_TEST);
-  glDisable(GL_LIGHTING);
-  glViewport(0,0,width,height);
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  gluOrtho2D(0,width,0,height);
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-
-  // Display mouse position at cursor
-  string str;
-  void * font = GLUT_BITMAP_HELVETICA_18;
-  glColor3f(1,0,0);
-  glRasterPos2d(move_x+18,height-move_y+18);
-  str = STR("("<<move_x<<","<<move_y<<")");
-  for_each(str.begin(),str.end(),bind1st(ptr_fun(&glutBitmapCharacter),font));
-  glColor3f(0,0,1);
-  glRasterPos2d(move_x+18,height-move_y-1.5*18);
-  for_each(str.begin(),str.end(),bind1st(ptr_fun(&glutBitmapCharacter),font));
-
-  double eff_h,eff_v;
-  clamp(horiz,vert,eff_h,eff_v);
-  glLineWidth(BAR_THICKNESS);
-  glColor3f(0.5,0.5,0.5);
-  glBegin(GL_LINES);
-  glVertex2f(0,eff_h*height);
-  glVertex2f(width,eff_h*height);
-  glVertex2f(eff_v*width,0);
-  glVertex2f(eff_v*width,height);
-  glEnd();
-
-  glLineWidth(BAR_THICKNESS/3.0);
-  glColor3f(0.8,0.8,0.8);
-  glBegin(GL_LINES);
-  glVertex2f(0,eff_h*height);
-  glVertex2f(width,eff_h*height);
-  glVertex2f(eff_v*width,0);
-  glVertex2f(eff_v*width,height);
-  glEnd();
-
-
-  igl::opengl::report_gl_error();
-
-  glutSwapBuffers();
-}
-
-// Initialize colors to a boring green
-void init_C()
-{
-  C.col(0).setConstant(0.4);
-  C.col(1).setConstant(0.8);
-  C.col(2).setConstant(0.3);
-}
-
-const double SNAP_DIST = 10;
-void mouse_move(int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  move_x = mouse_x;
-  move_y = mouse_y;
-  const int in_vp = find_if(viewports,viewports+NUM_VIEWPORTS,
-    [&mouse_x,&mouse_y](const AugViewport & vp) -> bool
-    {return vp.inside(mouse_x,height-mouse_y);})-viewports;
-  if(in_vp < NUM_VIEWPORTS)
-  {
-    if(
-      viewports[in_vp].width > 0 &&
-      viewports[in_vp].height > 0)
-    {
-      glViewport(
-        viewports[in_vp].x,
-        viewports[in_vp].y,
-        viewports[in_vp].width,
-        viewports[in_vp].height);
-      push_scene(viewports[in_vp]);
-      Vector3d screen_ball(mouse_x,height-mouse_y,0);
-      igl::opengl2::unproject_to_zero_plane(screen_ball,ball);
-      pop_scene();
-    }
-  }
-  if( (fabs((height-mouse_y) - horiz*height) < 2.*SNAP_DIST)
-   && (fabs(mouse_x - vert*width) < 2.*SNAP_DIST))
-  {
-    glutSetCursor(GLUT_CURSOR_TOP_LEFT_CORNER);
-  } else if( fabs((height-mouse_y) - horiz*height) < SNAP_DIST)
-  {
-    glutSetCursor(GLUT_CURSOR_UP_DOWN);
-  } else if( fabs(mouse_x - vert*width) < SNAP_DIST)
-  {
-    glutSetCursor(GLUT_CURSOR_LEFT_RIGHT);
-  } else
-  {
-    glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
-  }
-  glutPostRedisplay();
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  switch(glutState)
-  {
-    case 1:
-      // up
-      glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
-      trackball_on = false;
-      break;
-    case 0:
-      horiz_on = vert_on = false;
-      if( (fabs((height-mouse_y) - horiz*height) < 2.*SNAP_DIST)
-          && (fabs(mouse_x - vert*width) < 2.*SNAP_DIST))
-      {
-        glutSetCursor(GLUT_CURSOR_TOP_LEFT_CORNER);
-        horiz_on = vert_on = true;
-      } else if( fabs((height-mouse_y) - horiz*height) < SNAP_DIST)
-      {
-        glutSetCursor(GLUT_CURSOR_UP_DOWN);
-        horiz_on = true;
-      } else if( fabs(mouse_x - vert*width) < SNAP_DIST)
-      {
-        glutSetCursor(GLUT_CURSOR_LEFT_RIGHT);
-        vert_on = true;
-      } else
-      {
-        down_vp = find_if(viewports,viewports+NUM_VIEWPORTS,
-          [&mouse_x,&mouse_y](const AugViewport & vp) -> bool
-          {return vp.inside(mouse_x,height-mouse_y);})-viewports;
-        // down
-        if(down_vp < NUM_VIEWPORTS)
-        {
-          glutSetCursor(GLUT_CURSOR_CYCLE);
-          // collect information for trackball
-          trackball_on = true;
-          down_camera = viewports[down_vp].camera;
-          down_mouse_x = mouse_x;
-          down_mouse_y = mouse_y;
-        }
-      }
-    break;
-  }
-  glutPostRedisplay();
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  mouse_move(mouse_x,mouse_y);
-
-  if(horiz_on)
-  {
-    glutSetCursor(GLUT_CURSOR_UP_DOWN);
-    horiz = (double)(height-mouse_y)/(double)height;
-    reshape_viewports();
-  }
-  if(vert_on)
-  {
-    if(horiz_on)
-    {
-      glutSetCursor(GLUT_CURSOR_TOP_LEFT_CORNER);
-    }else
-    {
-      glutSetCursor(GLUT_CURSOR_LEFT_RIGHT);
-    }
-    vert = (double)mouse_x/(double)width;
-    reshape_viewports();
-  }
-  if(trackball_on)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    // Rotate according to trackball
-    trackball<double>(
-      viewports[down_vp].width,
-      viewports[down_vp].height,
-      2.0,
-      down_camera.m_rotation_conj.coeffs().data(),
-      viewports[down_vp].mouse_x(down_mouse_x),
-      viewports[down_vp].mouse_y(down_mouse_y,height),
-      viewports[down_vp].mouse_x(mouse_x),
-      viewports[down_vp].mouse_y(mouse_y,height),
-      viewports[down_vp].camera.m_rotation_conj.coeffs().data());
-  }
-  glutPostRedisplay();
-}
-
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  switch(key)
-  {
-    // Ctrl-c and esc exit
-    case char(3):
-    case char(27):
-      exit(0);
-    case 'Z':
-    {
-      const int in_vp = find_if(viewports,viewports+NUM_VIEWPORTS,
-          [&mouse_x,&mouse_y](const AugViewport & vp) -> bool
-          {return vp.inside(mouse_x,height-mouse_y);})-viewports;
-      if(in_vp < NUM_VIEWPORTS)
-      {
-        igl::snap_to_canonical_view_quat(
-          viewports[in_vp].camera.m_rotation_conj.coeffs().data(),
-          1.0,
-          viewports[in_vp].camera.m_rotation_conj.coeffs().data());
-      }
-      break;
-    }
-    default:
-      cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-  }
-
-  glutPostRedisplay();
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-
-  // init mesh
-  string filename = "/usr/local/igl/libigl/examples/shared/decimated-knight.obj" ;
-  if(argc > 1)
-  {
-    filename = argv[1];
-  }
-
-  if(!read_triangle_mesh(filename,V,F))
-  {
-    return 1;
-  }
-  // Compute normals, centroid, colors, bounding box diagonal
-  per_face_normals(V,F,N);
-  normalize_row_lengths(N,N);
-  mean = V.colwise().mean();
-  C.resize(F.rows(),3);
-  init_C();
-  bbd =
-    (V.colwise().maxCoeff() -
-    V.colwise().minCoeff()).maxCoeff();
-
-
-  // Init viewports
-  init_viewports();
-
-  // Init glut
-  glutInit(&argc,argv);
-  glutInitDisplayString( "rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
-  glutCreateWindow("multi-viewport");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc(mouse_move);
-  glutMainLoop();
-  return 0;
-}

+ 0 - 35
examples/patches/Makefile

@@ -1,35 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-ifdef LIBIGL_USE_STATIC_LIBRARY
-	LIBIGL_LIB+=-liglembree
-endif
-
-all: obj example
-
-.PHONY: example
-
-CFLAGS+=-g -std=c++11
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(GLUT_INC) $(EMBREE_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB) $(EMBREE_LIB)
-
-CPP_FILES=$(wildcard ./*.cpp)
-OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o))) 
-
-example: obj $(OBJ_FILES)
-	g++ $(OPTFLAGS) $(OPENMP) $(AFLAGS) $(CFLAGS) -o example $(OBJ_FILES) $(LIB)
-
-obj:
-	mkdir -p obj
-
-obj/%.o: %.cpp
-	g++ $(OPTFLAGS) $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-obj/%.o: %.cpp %.h
-	g++ $(OPTFLAGS) $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-clean:
-	rm -f $(OBJ_FILES)
-	rm -f example

+ 0 - 856
examples/patches/example.cpp

@@ -1,856 +0,0 @@
-#include <igl/C_STR.h>
-#include <igl/Camera.h>
-#include <igl/REDRUM.h>
-#include <igl/bfs_orient.h>
-#include <igl/components.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/get_seconds.h>
-#include <igl/jet.h>
-#include <igl/list_to_matrix.h>
-#include <igl/material_colors.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/orient_outward.h>
-#include <igl/pathinfo.h>
-#include <igl/per_face_normals.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/quat_to_mat.h>
-#include <igl/randperm.h>
-#include <igl/readMESH.h>
-#include <igl/readOBJ.h>
-#include <igl/readOFF.h>
-#include <igl/readPLY.h>
-#include <igl/readWRL.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/snap_to_fixed_up.h>
-#include <igl/trackball.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/unique_simplices.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/write_triangle_mesh.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-#include <igl/embree/reorient_facets_raycast.h>
-
-#include <Eigen/Core>
-#include <Eigen/Geometry>
-
-#ifdef __APPLE__
-#include <GLUT/glut.h>
-#else
-#include <GL/glut.h>
-#endif
-
-#ifndef GLUT_WHEEL_UP
-#define GLUT_WHEEL_UP    3
-#endif
-#ifndef GLUT_WHEEL_DOWN
-#define GLUT_WHEEL_DOWN  4
-#endif
-#ifndef GLUT_WHEEL_RIGHT
-#define GLUT_WHEEL_RIGHT 5
-#endif
-#ifndef GLUT_WHEEL_LEFT
-#define GLUT_WHEEL_LEFT  6
-#endif
-#ifndef GLUT_ACTIVE_COMMAND
-#define GLUT_ACTIVE_COMMAND 8
-#endif
-
-#include <ctime>
-#include <string>
-#include <vector>
-#include <stack>
-#include <iostream>
-
-int cc_selected = -1;
-
-Eigen::MatrixXd V;
-Eigen::VectorXd Vmid,Vmin,Vmax;
-double bbd = 1.0;
-Eigen::MatrixXi F;
-Eigen::VectorXi CC;
-struct State
-{
-  igl::Camera camera;
-  Eigen::MatrixXd N;
-  Eigen::MatrixXd C;
-} s;
-std::string out_filename;
-
-// See README for descriptions
-enum RotationType
-{
-  ROTATION_TYPE_IGL_TRACKBALL = 0,
-  ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
-  NUM_ROTATION_TYPES = 2,
-} rotation_type;
-
-enum CenterType
-{
-  CENTER_TYPE_ORBIT = 0,
-  CENTER_TYPE_FPS  = 1,
-  NUM_CENTER_TYPES = 2,
-} center_type = CENTER_TYPE_ORBIT;
-
-enum OrientMethod
-{
-  ORIENT_METHOD_OUTWARD = 0,
-  ORIENT_METHOD_AO = 1,
-  NUM_ORIENT_METHODS = 2,
-} orient_method = ORIENT_METHOD_AO;
-
-std::stack<State> undo_stack;
-std::stack<State> redo_stack;
-
-bool wireframe_visible = false;
-bool fill_visible = true;
-
-bool is_rotating = false;
-int down_x,down_y;
-igl::Camera down_camera;
-
-bool is_animating = false;
-double animation_start_time = 0;
-double ANIMATION_DURATION = 0.5;
-Eigen::Quaterniond animation_from_quat;
-Eigen::Quaterniond animation_to_quat;
-
-int width,height;
-Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
-
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar;
-
-// Forward
-void init_patches();
-void init_relative();
-
-void push_undo()
-{
-  undo_stack.push(s);
-  // Clear
-  redo_stack = std::stack<State>();
-}
-
-void TW_CALL set_orient_method(const void * value, void * clientData)
-{
-  const OrientMethod old_orient_method = orient_method;
-  orient_method = *(const OrientMethod *)value;
-  if(orient_method != old_orient_method)
-  {
-    init_patches();
-    init_relative();
-  }
-}
-
-void TW_CALL get_orient_method(void * value, void *clientData)
-{
-  OrientMethod * om = (OrientMethod *)(value);
-  *om = orient_method;
-}
-
-void TW_CALL set_rotation_type(const void * value, void * clientData)
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-  const RotationType old_rotation_type = rotation_type;
-  rotation_type = *(const RotationType *)(value);
-  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
-    old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
-  {
-    push_undo();
-    animation_from_quat = s.camera.m_rotation_conj;
-    snap_to_fixed_up(animation_from_quat,animation_to_quat);
-    // start animation
-    animation_start_time = get_seconds();
-    is_animating = true;
-  }
-}
-void TW_CALL get_rotation_type(void * value, void *clientData)
-{
-  RotationType * rt = (RotationType *)(value);
-  *rt = rotation_type;
-}
-
-void reshape(int width, int height)
-{
-  ::width = width;
-  ::height = height;
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-  s.camera.m_aspect = (double)width/(double)height;
-}
-
-void push_scene()
-{
-  using namespace igl;
-  using namespace std;
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  auto & camera = s.camera;
-  glMultMatrixd(camera.projection().data());
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    camera.eye()(0), camera.eye()(1), camera.eye()(2),
-    camera.at()(0), camera.at()(1), camera.at()(2),
-    camera.up()(0), camera.up()(1), camera.up()(2));
-}
-void push_object()
-{
-  using namespace igl;
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-Vmid(0),-Vmid(1),-Vmid(2));
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-void pop_scene()
-{
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  using namespace Eigen;
-  glEnable(GL_LIGHTING);
-  //glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  float WHITE[4] = {1,1,1,1.};
-  float GREY[4] = {0.4,0.4,0.4,1.};
-  float BLACK[4] = {0.,0.,0.,1.};
-  float NEAR_BLACK[4] =  {0.1,0.1,0.1,1.};
-  Vector4f pos = light_pos;
-  glLightfv(GL_LIGHT0,GL_AMBIENT,BLACK);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,BLACK);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos.data());
-  //glEnable(GL_LIGHT1);
-  //pos(0) *= -1;
-  //pos(1) *= -1;
-  //pos(2) *= -1;
-  //glLightfv(GL_LIGHT1,GL_AMBIENT,BLACK);
-  //glLightfv(GL_LIGHT1,GL_DIFFUSE,NEAR_BLACK);
-  //glLightfv(GL_LIGHT1,GL_SPECULAR,BLACK);
-  //glLightfv(GL_LIGHT1,GL_POSITION,pos.data());
-}
-
-void display()
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  glClearColor(1,1,1,0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  if(is_animating)
-  {
-    double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
-    if(t > 1)
-    {
-      t = 1;
-      is_animating = false;
-    }
-    Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
-    auto & camera = s.camera;
-    switch(center_type)
-    {
-      default:
-      case CENTER_TYPE_ORBIT:
-        camera.orbit(q.conjugate());
-        break;
-      case CENTER_TYPE_FPS:
-        camera.turn_eye(q.conjugate());
-        break;
-    }
-  }
-
-  glEnable(GL_DEPTH_TEST);
-  glEnable(GL_NORMALIZE);
-  lights();
-  push_scene();
-  push_object();
-
-  // Set material properties
-  glEnable(GL_COLOR_MATERIAL);
-  glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-  if(wireframe_visible)
-  {
-    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
-    if(fill_visible)
-    {
-      glColor3f(0,0,0);
-      igl::opengl2::draw_mesh(V,F,s.N);
-    }else
-    {
-      igl::opengl2::draw_mesh(V,F,s.N,s.C);
-    }
-
-    // visualize selected patch
-    glLineWidth(10);
-    glBegin(GL_TRIANGLES);
-    glColor3d(0, 0, 0);
-    // loop over faces
-    for(int i = 0; i<F.rows();i++)
-    {
-      if (CC(i) != cc_selected) continue;
-      // loop over corners of triangle
-      for(int j = 0;j<3;j++)
-      {
-        glVertex3d(V(F(i,j),0),V(F(i,j),1),V(F(i,j),2));
-      }
-    }
-    glEnd();
-    glLineWidth(1);
-    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
-    glBegin(GL_TRIANGLES);
-    glColor3d(1, 0, 0);
-    // loop over faces
-    for(int i = 0; i<F.rows();i++)
-    {
-      if (CC(i) != cc_selected) continue;
-      // loop over corners of triangle
-      glNormal3d(s.N(i,0),s.N(i,1),s.N(i,2));
-      for(int j = 0;j<3;j++)
-      {
-        glVertex3d(V(F(i,j),0),V(F(i,j),1),V(F(i,j),2));
-      }
-    }
-    glEnd();
-  }
-  glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
-  if(fill_visible)
-  {
-    glEnable(GL_POLYGON_OFFSET_FILL); // Avoid Stitching!
-    glPolygonOffset(1.0, 0);
-    igl::opengl2::draw_mesh(V,F,s.N,s.C);
-  }
-
-  pop_object();
-
-  // Draw a nice floor
-  glPushMatrix();
-  const double floor_offset =
-    -2./bbd*(V.col(1).maxCoeff()-Vmid(1));
-  glTranslated(0,floor_offset,0);
-  const float GREY[4] = {0.5,0.5,0.6,1.0};
-  const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  igl::opengl2::draw_floor(GREY,DARK_GREY);
-  glPopMatrix();
-
-  pop_scene();
-
-  igl::opengl::report_gl_error();
-
-  TwDraw();
-  glutSwapBuffers();
-  glutPostRedisplay();
-}
-
-void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  GLint viewport[4];
-  glGetIntegerv(GL_VIEWPORT,viewport);
-  if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
-  {
-    static double mouse_scroll_y = 0;
-    const double delta_y = 0.125*direction;
-    mouse_scroll_y += delta_y;
-    TwMouseWheel(mouse_scroll_y);
-    return;
-  }
-  push_undo();
-
-  auto & camera = s.camera;
-  switch(center_type)
-  {
-    case CENTER_TYPE_ORBIT:
-      if(wheel==0)
-      {
-        // factor of zoom change
-        double s = (1.-0.01*direction);
-        //// FOV zoom: just widen angle. This is hardly ever appropriate.
-        //camera.m_angle *= s;
-        //camera.m_angle = min(max(camera.m_angle,1),89);
-        camera.push_away(s);
-      }else
-      {
-        // Dolly zoom:
-        camera.dolly_zoom((double)direction*1.0);
-      }
-      break;
-    default:
-    case CENTER_TYPE_FPS:
-      // Move `eye` and `at`
-      camera.dolly((wheel==0?Vector3d(0,0,1):Vector3d(-1,0,0))*0.1*direction);
-      break;
-  }
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  switch(glutButton)
-  {
-    case GLUT_RIGHT_BUTTON:
-    case GLUT_LEFT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_INHERIT);
-          is_rotating = false;
-          break;
-        case 0:
-          if(!tw_using)
-          {
-            push_undo();
-            glutSetCursor(GLUT_CURSOR_CYCLE);
-            // collect information for trackball
-            is_rotating = true;
-            down_camera = s.camera;
-            down_x = mouse_x;
-            down_y = mouse_y;
-          }
-        break;
-      }
-      break;
-      // Scroll down
-      case GLUT_WHEEL_DOWN:
-      {
-        mouse_wheel(0,-1,mouse_x,mouse_y);
-        break;
-      }
-      // Scroll up
-      case GLUT_WHEEL_UP:
-      {
-        mouse_wheel(0,1,mouse_x,mouse_y);
-        break;
-      }
-      // Scroll left
-      case GLUT_WHEEL_LEFT:
-      {
-        mouse_wheel(1,-1,mouse_x,mouse_y);
-        break;
-      }
-      // Scroll right
-      case GLUT_WHEEL_RIGHT:
-      {
-        mouse_wheel(1,1,mouse_x,mouse_y);
-        break;
-      }
-    }
-  }
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  bool tw_using = TwMouseMotion(mouse_x,mouse_y);
-
-  if(is_rotating)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    Quaterniond q;
-    auto & camera = s.camera;
-    switch(rotation_type)
-    {
-      case ROTATION_TYPE_IGL_TRACKBALL:
-      {
-        // Rotate according to trackball
-        igl::trackball<double>(
-          width,
-          height,
-          2.0,
-          down_camera.m_rotation_conj.coeffs().data(),
-          down_x,
-          down_y,
-          mouse_x,
-          mouse_y,
-          q.coeffs().data());
-          break;
-      }
-      case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
-      {
-        // Rotate according to two axis valuator with fixed up vector
-        two_axis_valuator_fixed_up(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-        break;
-      }
-      default:
-        break;
-    }
-    switch(center_type)
-    {
-      default:
-      case CENTER_TYPE_ORBIT:
-        camera.orbit(q.conjugate());
-        break;
-      case CENTER_TYPE_FPS:
-        camera.turn_eye(q.conjugate());
-        break;
-    }
-  }
-}
-
-void init_relative()
-{
-  using namespace Eigen;
-  using namespace igl;
-  per_face_normals(V,F,s.N);
-  normalize_row_lengths(s.N,s.N);
-  Vmax = V.colwise().maxCoeff();
-  Vmin = V.colwise().minCoeff();
-  Vmid = 0.5*(Vmax + Vmin);
-  bbd = (Vmax-Vmin).norm();
-}
-
-void randomly_color(
-  const Eigen::VectorXi & CC,
-  Eigen::MatrixXd & C)
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  VectorXi I;
-  srand ( unsigned ( time(0) ) );
-  double num_cc = (double)CC.maxCoeff()+1.0;
-  randperm(num_cc,I);
-  C.resize(CC.rows(),3);
-  for(int f = 0;f<CC.rows();f++)
-  {
-    jet(
-      (double)I(CC(f))/num_cc,
-      C(f,0),
-      C(f,1),
-      C(f,2));
-  }
-}
-
-void TW_CALL randomize_colors(void * /*clientData*/)
-{
-  push_undo();
-  randomly_color(CC,s.C);
-}
-
-void init_patches()
-{
-  using namespace Eigen;
-  using namespace igl;
-  using namespace std;
-  {
-    VectorXi VCC;
-    components(F,VCC);
-    cout<<"There are "<<VCC.maxCoeff()+1<<" connected components of vertices."<<endl;
-  }
-  bfs_orient(F,F,CC);
-  VectorXi I;
-  switch(orient_method)
-  {
-    case ORIENT_METHOD_AO:
-    {
-      cout<<"orient_outward_ao()"<<endl;
-      igl::embree::reorient_facets_raycast(V,F,F,I);
-      break;
-    }
-    case ORIENT_METHOD_OUTWARD:
-    default:
-      cout<<"orient_outward()"<<endl;
-      orient_outward(V,F,CC,F,I);
-      break;
-  }
-  double num_cc = (double)CC.maxCoeff()+1.0;
-  cout<<"There are "<<num_cc<<" 'manifold/orientable' patches of faces."<<endl;
-}
-
-void undo()
-{
-  using namespace std;
-  if(!undo_stack.empty())
-  {
-    redo_stack.push(s);
-    s = undo_stack.top();
-    undo_stack.pop();
-  }
-}
-
-void redo()
-{
-  using namespace std;
-  if(!redo_stack.empty())
-  {
-    undo_stack.push(s);
-    s = redo_stack.top();
-    redo_stack.pop();
-  }
-}
-
-bool save(const std::string & out_filename)
-{
-  using namespace std;
-  using namespace igl;
-  if(write_triangle_mesh(out_filename,V,F))
-  {
-    cout<<GREENGIN("Saved mesh to `"<<out_filename<<"` successfully.")<<endl;
-    return true;
-  }else
-  {
-    cout<<REDRUM("Failed to save mesh to `"<<out_filename<<"`.")<<endl;
-    return false;
-  }
-}
-
-void TW_CALL saveCB(void * /*clientData*/)
-{
-  save(out_filename);
-}
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  int mod = glutGetModifiers();
-  switch(key)
-  {
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    case 'I':
-    case 'i':
-      {
-        push_undo();
-        s.N *= -1.0;
-        F = F.rowwise().reverse().eval();
-        break;
-      }
-    case 'z':
-    case 'Z':
-      if(mod & GLUT_ACTIVE_COMMAND)
-      {
-        if(mod & GLUT_ACTIVE_SHIFT)
-        {
-          redo();
-        }else
-        {
-          undo();
-        }
-      }else
-      {
-        push_undo();
-        Quaterniond q;
-        snap_to_canonical_view_quat(s.camera.m_rotation_conj,1.0,q);
-        switch(center_type)
-        {
-          default:
-          case CENTER_TYPE_ORBIT:
-            s.camera.orbit(q.conjugate());
-            break;
-          case CENTER_TYPE_FPS:
-            s.camera.turn_eye(q.conjugate());
-            break;
-        }
-      }
-      break;
-    case 'u':
-        mouse_wheel(0, 1,mouse_x,mouse_y);
-        break;
-    case 'j':
-        mouse_wheel(0,-1,mouse_x,mouse_y);
-        break;
-    case 'n':
-      cc_selected = (cc_selected + 1) % (CC.maxCoeff() + 2);
-      cout << "selected cc: " << cc_selected << endl;
-      glutPostRedisplay();
-      break;
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  string filename = "../shared/truck.obj";
-  switch(argc)
-  {
-    case 3:
-      out_filename = argv[2];
-    case 2:
-      // Read and prepare mesh
-      filename = argv[1];
-      break;
-    default:
-      cerr<<"Usage:"<<endl<<"    ./example input.obj (output.obj)"<<endl;
-      cout<<endl<<"Opening default mesh..."<<endl;
-      break;
-  }
-
-  // print key commands
-  cout<<"[Click] and [drag]  Rotate model using trackball."<<endl;
-  cout<<"[Z,z]               Snap rotation to canonical view."<<endl;
-  cout<<"[Command+Z]         Undo."<<endl;
-  cout<<"[Shift+Command+Z]   Redo."<<endl;
-  cout<<"[^C,ESC]            Exit."<<endl;
-
-  // dirname, basename, extension and filename
-  string d,b,ext,f;
-  pathinfo(filename,d,b,ext,f);
-  // Convert extension to lower case
-  transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-  vector<vector<double > > vV,vN,vTC;
-  vector<vector<int > > vF,vFTC,vFN;
-  if(ext == "obj")
-  {
-    // Convert extension to lower case
-    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
-    {
-      return 1;
-    }
-  }else if(ext == "off")
-  {
-    // Convert extension to lower case
-    if(!igl::readOFF(filename,vV,vF,vN))
-    {
-      return 1;
-    }
-  }else if(ext == "ply")
-  {
-    // Convert extension to lower case
-    if(!igl::readPLY(filename,vV,vF,vN,vTC))
-    {
-      return 1;
-    }
-  }else if(ext == "wrl")
-  {
-    // Convert extension to lower case
-    if(!igl::readWRL(filename,vV,vF))
-    {
-      return 1;
-    }
-  //}else
-  //{
-  //  // Convert extension to lower case
-  //  MatrixXi T;
-  //  if(!igl::readMESH(filename,V,T,F))
-  //  {
-  //    return 1;
-  //  }
-  //  //if(F.size() > T.size() || F.size() == 0)
-  //  {
-  //    boundary_facets(T,F);
-  //  }
-  }
-  if(vV.size() > 0)
-  {
-    if(!list_to_matrix(vV,V))
-    {
-      return 1;
-    }
-    polygon_mesh_to_triangle_mesh(vF,F);
-  }
-  MatrixXi F_unique;
-  unique_simplices(F, F_unique);
-  F = F_unique;
-
-  init_patches();
-  init_relative();
-  randomly_color(CC,s.C);
-
-  // Init glut
-  glutInit(&argc,argv);
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("bar");
-  TwDefine("bar label='Patches' size='200 550' text=light alpha='200' color='68 68 68'");
-  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
-    s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
-    "igl_trackball,two-axis-valuator-fixed-up");
-  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
-    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("CenterType","orbit,fps");
-  rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
-    "keyIncr={ keyDecr=}");
-  TwType OrientMethodTW = igl::anttweakbar::ReTwDefineEnumFromString("OrientMethod",
-    "outward,ambient-occlusion");
-  rebar.TwAddVarCB( "orient_method", OrientMethodTW,
-    set_orient_method,get_orient_method,NULL,"keyIncr=< keyDecr=>");
-
-  rebar.TwAddVarRW("wireframe_visible",TW_TYPE_BOOLCPP,&wireframe_visible,"key=l");
-  rebar.TwAddVarRW("fill_visible",TW_TYPE_BOOLCPP,&fill_visible,"key=f");
-  rebar.TwAddButton("randomize_colors",randomize_colors,NULL,"key=c");
-  if(out_filename != "")
-  {
-    rebar.TwAddButton("save",
-      saveCB,NULL,
-      C_STR("label='Save to `"<<out_filename<<"`' "<<
-      "key=s"));
-  }
-  rebar.load(REBAR_NAME);
-
-
-  animation_from_quat = Quaterniond(1,0,0,0);
-  s.camera.m_rotation_conj = animation_from_quat;
-  animation_start_time = get_seconds();
-
-  // Init antweakbar
-#ifdef __APPLE__
-  glutInitDisplayString( "rgba depth double samples>=8");
-#else
-  glutInitDisplayString( "rgba depth double ");   // samples>=8 somehow not supported on Kenshi's machines...?
-#endif
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
-  glutCreateWindow("patches");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
-  glutMainLoop();
-
-  return 0;
-}

+ 0 - 20
examples/patches/example.sln

@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{7F5B7683-7531-481C-8997-6221D7170894}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{7F5B7683-7531-481C-8997-6221D7170894}.Debug|Win32.ActiveCfg = Debug|Win32
-		{7F5B7683-7531-481C-8997-6221D7170894}.Debug|Win32.Build.0 = Debug|Win32
-		{7F5B7683-7531-481C-8997-6221D7170894}.Release|Win32.ActiveCfg = Release|Win32
-		{7F5B7683-7531-481C-8997-6221D7170894}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal

+ 0 - 150
examples/patches/example.vcxproj

@@ -1,150 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{7F5B7683-7531-481C-8997-6221D7170894}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>example</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
-    <WholeProgramOptimization>false</WholeProgramOptimization>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>C:\Users\kenshi\dev\igl_hg\ext_toolboxes\embree-1.1beta\common;$(IncludePath)</IncludePath>
-    <OutDir>$(ProjectDir)\</OutDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>C:\Users\kenshi\dev\igl_hg\ext_toolboxes\embree-1.1beta\common;$(IncludePath)</IncludePath>
-    <OutDir>$(ProjectDir)\</OutDir>
-    <TargetName>$(ProjectName)d</TargetName>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>EIGEN_DONT_ALIGN_STATICALLY;IGL_HEADER_ONLY;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
-      <AdditionalIncludeDirectories>..\..\external\embree;..\..\external\embree\embree;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <OpenMPSupport>true</OpenMPSupport>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>glew32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>Disabled</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>EIGEN_DONT_ALIGN_STATICALLY;IGL_HEADER_ONLY;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
-      <AdditionalIncludeDirectories>..\..\external\embree;..\..\external\embree\embree;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <OpenMPSupport>true</OpenMPSupport>
-      <WholeProgramOptimization>false</WholeProgramOptimization>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>false</OptimizeReferences>
-      <AdditionalDependencies>glew32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\external\embree\embree\builders\heuristic_binning.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\builders\heuristic_spatial.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\builders\primrefgen.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\builders\splitter.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\builders\splitter_fallback.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\builders\splitter_parallel.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh2\bvh2.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh2\bvh2_intersector1.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh2\bvh2_intersector4.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh2\bvh2_intersector8.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4i\bvh4i.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4i\bvh4i_intersector1.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb_builder.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb_intersector1.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb_intersector4.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb_intersector8.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector1.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector1_avx.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector4_chunk.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector4_hybrid.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector4_single.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector8_chunk.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector8_hybrid.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector8_single.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh8\bvh8.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\bvh8\bvh8_intersector1.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\common\accel.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\common\alloc.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\common\registry_accel.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\common\registry_builder.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\common\registry_intersector.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\common\stat.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\embree.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\geometry\triangle_mesh.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\geometry\virtual_scene.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\filename.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\platform.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\stl\string.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\sync\condition.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\sync\mutex.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\sysinfo.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\taskscheduler.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\taskscheduler_mic.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\taskscheduler_sys.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\sys\thread.cpp" />
-    <ClCompile Include="example.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\..\include\igl\embree\orient_outward_ao.h" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>

+ 0 - 158
examples/patches/example.vcxproj.filters

@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <ClCompile Include="example.cpp" />
-    <ClCompile Include="..\..\external\embree\embree\builders\primrefgen.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\builders\splitter.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\builders\splitter_fallback.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\builders\splitter_parallel.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\builders\heuristic_binning.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\builders\heuristic_spatial.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh2\bvh2_intersector4.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh2\bvh2_intersector8.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh2\bvh2.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh2\bvh2_intersector1.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector4_chunk.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector4_hybrid.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector4_single.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector8_chunk.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector8_hybrid.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector8_single.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector1.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4\bvh4_intersector1_avx.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4i\bvh4i.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4i\bvh4i_intersector1.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb_intersector1.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb_intersector4.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb_intersector8.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh4mb\bvh4mb_builder.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh8\bvh8.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\bvh8\bvh8_intersector1.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\common\registry_intersector.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\common\stat.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\common\accel.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\common\alloc.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\common\registry_accel.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\common\registry_builder.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\geometry\virtual_scene.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\geometry\triangle_mesh.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\taskscheduler.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\taskscheduler_mic.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\taskscheduler_sys.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\thread.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\filename.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\platform.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\sysinfo.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\stl\string.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\sync\mutex.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\sys\sync\condition.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\external\embree\embree\embree.cpp">
-      <Filter>embree</Filter>
-    </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <Filter Include="igl">
-      <UniqueIdentifier>{53eff656-6473-409c-9ad5-cac1983d91e1}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="embree">
-      <UniqueIdentifier>{6a04be79-a793-4c4a-a5c0-5d40f1f2ca7f}</UniqueIdentifier>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\..\include\igl\embree\orient_outward_ao.h" />
-  </ItemGroup>
-</Project>

+ 0 - 21
examples/path_tests/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-CFLAGS+=-g -Wall
-inc=$(LIBIGL_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 20
examples/path_tests/README

@@ -1,20 +0,0 @@
-This is a simple example program that shows how to use the is_dir, is_file,
-file_exists, is_readable, is_writable, functions of the igl library
-
-
-To Build:
-  make
-
-To Run:
-  ./example [path_1] [path_2] ... [path_n]
-
-Example Run #1:
-  Issuing:
-    touch not-writable
-    touch not-readable
-    chmod u-r not-readable 
-    chmod u-w not-writable 
-    ./example       / . .. example.cpp non-existant-file not-readable not-writable > output
-    php example.php / . .. example.cpp non-existant-file not-readable not-writable > php-output
-    diff php-output output
-  should produce no differences

+ 0 - 26
examples/path_tests/example.cpp

@@ -1,26 +0,0 @@
-#include <igl/file_exists.h>
-#include <igl/is_dir.h>
-#include <igl/is_file.h>
-#include <igl/is_readable.h>
-#include <igl/is_writable.h>
-using namespace igl;
-#include <cstdio>
-
-int main(int argc, char * argv[])
-{
-  if(argc <= 1)
-  {
-    printf("USAGE:\n  ./example [path_1] [path_2] ... [path_n]\n");
-    return 1;
-  }
-  // loop over arguments
-  for(int i = 1; i < argc; i++)
-  {
-    printf("file_exists(%s) --> %s\n",argv[i],(file_exists(argv[i])?"TRUE":"FALSE"));
-    printf("is_dir(%s) --> %s\n",argv[i],(is_dir(argv[i])?"TRUE":"FALSE"));
-    printf("is_file(%s) --> %s\n",argv[i],(is_file(argv[i])?"TRUE":"FALSE"));
-    printf("is_readable(%s) --> %s\n",argv[i],(is_readable(argv[i])?"TRUE":"FALSE"));
-    printf("is_writable(%s) --> %s\n",argv[i],(is_writable(argv[i])?"TRUE":"FALSE"));
-  }
-  return 0;
-}

+ 0 - 15
examples/path_tests/example.php

@@ -1,15 +0,0 @@
-<?php
-  if($argc <= 1)
-  {
-    printf("USAGE:\n  php example.php [path_1] [path_2] ... [path_n]\n");
-    return 1;
-  }
-  for($i = 1; $i < $argc; $i++)
-  {
-    printf("file_exists(%s) --> %s\n",$argv[$i],(file_exists($argv[$i])?"TRUE":"FALSE"));
-    printf("is_dir(%s) --> %s\n",$argv[$i],(is_dir($argv[$i])?"TRUE":"FALSE"));
-    printf("is_file(%s) --> %s\n",$argv[$i],(is_file($argv[$i])?"TRUE":"FALSE"));
-    printf("is_readable(%s) --> %s\n",$argv[$i],(is_readable($argv[$i])?"TRUE":"FALSE"));
-    printf("is_writable(%s) --> %s\n",$argv[$i],(is_writable($argv[$i])?"TRUE":"FALSE"));
-  }
-?>

+ 0 - 21
examples/pathinfo/Makefile

@@ -1,21 +0,0 @@
-.PHONY: all
-
-all: example
-
-# Shared flags etc.
-include ../Makefile.conf
-
-.PHONY: example
-
-CFLAGS+=-g -Wall 
-inc=$(LIBIGL_INC)
-lib=$(LIBIGL_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib) 
-
-example.o: example.cpp
-	g++ $(CFLAGS) $(deps) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 16
examples/pathinfo/README

@@ -1,16 +0,0 @@
-This pair of .cpp and .php programs demonstrate the use of pathinfo. 
-
-To compile:
-  make
-
-To run C++
-  ./example
-
-To run php:
-  php example.php
-
-To run test:
-  ./example > c++_output.txt
-  php example.php > php_output.txt
-  # should find 0 differences
-  diff c++_output.txt php_output.txt

+ 0 - 39
examples/pathinfo/example.cpp

@@ -1,39 +0,0 @@
-#define VERBOSE
-#include <igl/pathinfo.h>
-#include <igl/C_STR.h>
-using namespace igl;
-#include <string>
-#include <cstdio>
-#include <iostream>
-#include <fstream>
-using namespace std;
-
-int main(int argc, char * argv[])
-{
-  ifstream fin("input.txt");
-  if (fin.is_open() == false)
-  {
-    // error
-    return 1;
-  }
-
-  const char * format = "%-25s | %-10s %-10s %-10s %-10s\n";
-  printf(format,
-    "input",
-    "dirname",
-    "basename",
-    "extension",
-    "filename");
-  string line;
-  while( getline(fin, line) )
-  {
-    string dirname,basename,extension,filename;
-    pathinfo(line,dirname,basename,extension,filename);
-    printf(format,
-      C_STR("\""<<line<<"\""),
-      C_STR("\""<<dirname<<"\""),
-      C_STR("\""<<basename<<"\""),
-      C_STR("\""<<extension<<"\""),
-      C_STR("\""<<filename<<"\""));
-  }
-}

+ 0 - 17
examples/pathinfo/example.php

@@ -1,17 +0,0 @@
-<?php
-  $file_handle = fopen("input.txt", "rb");
-  while (!feof($file_handle) )
-  {
-    $string = trim(fgets($file_handle));
-    if(!feof($file_handle) )
-    {
-      $p = pathinfo($string);
-      echo "$string -> ".
-        $p['dirname'].",".
-        $p['basename'].",".
-        $p['extension'].",".
-        $p['filename']."\n";
-    }
-  }
-  fclose($file_handle);
-?>

+ 0 - 46
examples/pathinfo/input.txt

@@ -1,46 +0,0 @@
-/
-//
-/foo
-/foo/
-/foo//
-/foo/./
-/foo/bar
-/foo/bar.
-/foo/bar.txt
-/foo/bar.txt.zip
-/foo/bar.dir/
-/foo/bar.dir/file
-/foo/bar.dir/file.txt
-
-foo
-foo/
-foo/bar
-foo/bar.txt
-foo/bar.txt.zip
-foo/bar.dir/
-foo/bar.dir/file
-foo/bar.dir/file.txt
-.bar
-foo.
-./foo
-./foo/
-./foo/bar
-./foo/bar.txt
-./foo/bar.txt.zip
-./foo/bar.dir/
-./foo/bar.dir/file
-./foo/bar.dir/file.txt
-./.bar
-~/foo.
-~/foo
-~/foo/
-~/foo/bar
-~/foo/bar.txt
-~/foo/bar.txt.zip
-~/foo/bar.dir/
-~/foo/bar.dir/file
-~/foo/bar.dir/file.txt
-~/.bar
-~/foo.
-.
-..

+ 0 - 32
examples/randomly-sample-mesh/Makefile

@@ -1,32 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: obj example
-
-.PHONY: example
-
-INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC) $(GLUT_INC)
-LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB)
-
-CPP_FILES=$(wildcard ./*.cpp)
-OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o))) 
-
-CFLAGS+=-std=c++11
-
-example: obj $(OBJ_FILES)
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -o example $(OBJ_FILES) $(LIB)
-
-obj:
-	mkdir -p obj
-
-obj/%.o: %.cpp
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-obj/%.o: %.cpp %.h
-	g++ $(OPENMP) $(AFLAGS) $(CFLAGS) -c $< -o $@ $(INC)
-
-clean:
-	rm -f $(OBJ_FILES)
-	rm -f example

+ 0 - 611
examples/randomly-sample-mesh/example.cpp

@@ -1,611 +0,0 @@
-#include <igl/Camera.h>
-#include <igl/REDRUM.h>
-#include <igl/opengl2/draw_floor.h>
-#include <igl/opengl2/draw_mesh.h>
-#include <igl/get_seconds.h>
-#include <igl/list_to_matrix.h>
-#include <igl/material_colors.h>
-#include <igl/pathinfo.h>
-#include <igl/per_face_normals.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/quat_to_mat.h>
-#include <igl/random_points_on_mesh.h>
-#include <igl/readMESH.h>
-#include <igl/readOBJ.h>
-#include <igl/readOFF.h>
-#include <igl/readWRL.h>
-#include <igl/opengl/report_gl_error.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/snap_to_fixed_up.h>
-#include <igl/trackball.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/anttweakbar/ReAntTweakBar.h>
-
-#include <Eigen/Core>
-#include <Eigen/Geometry>
-
-#ifdef __APPLE__
-#include <GLUT/glut.h>
-#else
-#include <GL/glut.h>
-#endif
-
-#ifndef GLUT_WHEEL_UP
-#define GLUT_WHEEL_UP    3
-#endif
-#ifndef GLUT_WHEEL_DOWN
-#define GLUT_WHEEL_DOWN  4
-#endif
-#ifndef GLUT_WHEEL_RIGHT
-#define GLUT_WHEEL_RIGHT 5
-#endif
-#ifndef GLUT_WHEEL_LEFT
-#define GLUT_WHEEL_LEFT  6
-#endif
-#ifndef GLUT_ACTIVE_COMMAND
-#define GLUT_ACTIVE_COMMAND 8
-#endif
-
-#include <string>
-#include <vector>
-#include <stack>
-#include <iostream>
-
-
-Eigen::MatrixXd V,N,S;
-Eigen::VectorXd Vmid,Vmin,Vmax;
-double bbd = 1.0;
-Eigen::MatrixXi F;
-struct State
-{
-  igl::Camera camera;
-} s;
-
-// See README for descriptions
-enum RotationType
-{
-  ROTATION_TYPE_IGL_TRACKBALL = 0,
-  ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
-  NUM_ROTATION_TYPES = 2,
-} rotation_type;
-
-std::stack<State> undo_stack;
-std::stack<State> redo_stack;
-
-bool is_rotating = false;
-int down_x,down_y;
-igl::Camera down_camera;
-
-bool is_animating = false;
-double animation_start_time = 0;
-double ANIMATION_DURATION = 0.5;
-Eigen::Quaterniond animation_from_quat;
-Eigen::Quaterniond animation_to_quat;
-
-int width,height;
-Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
-
-#define REBAR_NAME "temp.rbr"
-igl::anttweakbar::ReTwBar rebar;
-
-void push_undo()
-{
-  undo_stack.push(s);
-  // Clear
-  redo_stack = std::stack<State>();
-}
-
-// No-op setter, does nothing
-void TW_CALL no_op(const void * /*value*/, void * /*clientData*/)
-{
-}
-
-void TW_CALL set_rotation_type(const void * value, void * clientData)
-{
-  using namespace Eigen;
-  using namespace std;
-  using namespace igl;
-  const RotationType old_rotation_type = rotation_type;
-  rotation_type = *(const RotationType *)(value);
-  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
-    old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
-  {
-    push_undo();
-    animation_from_quat = s.camera.m_rotation_conj;
-    snap_to_fixed_up(animation_from_quat,animation_to_quat);
-    // start animation
-    animation_start_time = get_seconds();
-    is_animating = true;
-  }
-}
-void TW_CALL get_rotation_type(void * value, void *clientData)
-{
-  RotationType * rt = (RotationType *)(value);
-  *rt = rotation_type;
-}
-
-void reshape(int width, int height)
-{
-  ::width = width;
-  ::height = height;
-  glViewport(0,0,width,height);
-  // Send the new window size to AntTweakBar
-  TwWindowSize(width, height);
-  s.camera.m_aspect = (double)width/(double)height;
-}
-
-void push_scene()
-{
-  using namespace igl;
-  using namespace std;
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  auto & camera = s.camera;
-  gluPerspective(camera.m_angle,camera.m_aspect,camera.m_near,camera.m_far);
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-  gluLookAt(
-    camera.eye()(0), camera.eye()(1), camera.eye()(2),
-    camera.at()(0), camera.at()(1), camera.at()(2),
-    camera.up()(0), camera.up()(1), camera.up()(2));
-}
-
-void push_object()
-{
-  using namespace igl;
-  glPushMatrix();
-  glScaled(2./bbd,2./bbd,2./bbd);
-  glTranslated(-Vmid(0),-Vmid(1),-Vmid(2));
-}
-
-void pop_object()
-{
-  glPopMatrix();
-}
-
-void pop_scene()
-{
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-}
-
-// Set up double-sided lights
-void lights()
-{
-  using namespace std;
-  using namespace Eigen;
-  glEnable(GL_LIGHTING);
-  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHT1);
-  float WHITE[4] =  {0.8,0.8,0.8,1.};
-  float GREY[4] =  {0.4,0.4,0.4,1.};
-  float BLACK[4] =  {0.,0.,0.,1.};
-  Vector4f pos = light_pos;
-  glLightfv(GL_LIGHT0,GL_AMBIENT,GREY);
-  glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE);
-  glLightfv(GL_LIGHT0,GL_SPECULAR,BLACK);
-  glLightfv(GL_LIGHT0,GL_POSITION,pos.data());
-  pos(0) *= -1;
-  pos(1) *= -1;
-  pos(2) *= -1;
-  glLightfv(GL_LIGHT1,GL_AMBIENT,GREY);
-  glLightfv(GL_LIGHT1,GL_DIFFUSE,WHITE);
-  glLightfv(GL_LIGHT1,GL_SPECULAR,BLACK);
-  glLightfv(GL_LIGHT1,GL_POSITION,pos.data());
-}
-
-void display()
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  glClearColor(1,1,1,0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  if(is_animating)
-  {
-    double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
-    if(t > 1)
-    {
-      t = 1;
-      is_animating = false;
-    }
-    Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
-    auto & camera = s.camera;
-    camera.orbit(q.conjugate());
-  }
-
-  glEnable(GL_DEPTH_TEST);
-  glEnable(GL_NORMALIZE);
-  lights();
-  push_scene();
-  push_object();
-
-  // Set material properties
-  glDisable(GL_COLOR_MATERIAL);
-  glMaterialfv(GL_FRONT, GL_AMBIENT,  GOLD_AMBIENT);
-  glMaterialfv(GL_FRONT, GL_DIFFUSE,  GOLD_DIFFUSE  );
-  glMaterialfv(GL_FRONT, GL_SPECULAR, GOLD_SPECULAR);
-  glMaterialf (GL_FRONT, GL_SHININESS, 128);
-  glMaterialfv(GL_BACK, GL_AMBIENT,  SILVER_AMBIENT);
-  glMaterialfv(GL_BACK, GL_DIFFUSE,  FAST_GREEN_DIFFUSE  );
-  glMaterialfv(GL_BACK, GL_SPECULAR, SILVER_SPECULAR);
-  glMaterialf (GL_BACK, GL_SHININESS, 128);
-
-
-  igl::opengl2::draw_mesh(V,F,N);
-
-  glPointSize(3.);
-  glEnable(GL_POINT_SMOOTH);
-  glColor4f(0,0.5,1,1);
-  glDisable(GL_LIGHTING);
-  glBegin(GL_POINTS);
-  for(int s = 0;s<S.rows();s++)
-  {
-    glVertex3d(S(s,0),S(s,1),S(s,2));
-  }
-  glEnd();
-
-  pop_object();
-
-  // Draw a nice floor
-  glPushMatrix();
-  const double floor_offset =
-    -2./bbd*(V.col(1).maxCoeff()-Vmid(1));
-  glTranslated(0,floor_offset,0);
-  const float GREY[4] = {0.5,0.5,0.6,1.0};
-  const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  igl::opengl2::draw_floor(GREY,DARK_GREY);
-  glPopMatrix();
-
-  pop_scene();
-
-  igl::opengl::report_gl_error();
-
-  TwDraw();
-  glutSwapBuffers();
-  glutPostRedisplay();
-}
-
-void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  GLint viewport[4];
-  glGetIntegerv(GL_VIEWPORT,viewport);
-  if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
-  {
-    static double mouse_scroll_y = 0;
-    const double delta_y = 0.125*direction;
-    mouse_scroll_y += delta_y;
-    TwMouseWheel(mouse_scroll_y);
-    return;
-  }
-  push_undo();
-
-  auto & camera = s.camera;
-  if(wheel==0)
-  {
-    // factor of zoom change
-    double s = (1.-0.01*direction);
-    //// FOV zoom: just widen angle. This is hardly ever appropriate.
-    //camera.m_angle *= s;
-    //camera.m_angle = min(max(camera.m_angle,1),89);
-    camera.push_away(s);
-  }else
-  {
-    // Dolly zoom:
-    camera.dolly_zoom((double)direction*1.0);
-  }
-}
-
-void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
-  switch(glutButton)
-  {
-    case GLUT_RIGHT_BUTTON:
-    case GLUT_LEFT_BUTTON:
-    {
-      switch(glutState)
-      {
-        case 1:
-          // up
-          glutSetCursor(GLUT_CURSOR_INHERIT);
-          is_rotating = false;
-          break;
-        case 0:
-          if(!tw_using)
-          {
-            push_undo();
-            glutSetCursor(GLUT_CURSOR_CYCLE);
-            // collect information for trackball
-            is_rotating = true;
-            down_camera = s.camera;
-            down_x = mouse_x;
-            down_y = mouse_y;
-          }
-        break;
-      }
-      break;
-    }
-    // Scroll down
-    case 3:
-    {
-      mouse_wheel(0,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll up
-    case 4:
-    {
-      mouse_wheel(0,1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll left
-    case 5:
-    {
-      mouse_wheel(1,-1,mouse_x,mouse_y);
-      break;
-    }
-    // Scroll right
-    case 6:
-    {
-      mouse_wheel(1,1,mouse_x,mouse_y);
-      break;
-    }
-  }
-}
-
-void mouse_drag(int mouse_x, int mouse_y)
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-
-  if(is_rotating)
-  {
-    glutSetCursor(GLUT_CURSOR_CYCLE);
-    Quaterniond q;
-    auto & camera = s.camera;
-    switch(rotation_type)
-    {
-      case ROTATION_TYPE_IGL_TRACKBALL:
-      {
-        // Rotate according to trackball
-        igl::trackball<double>(
-          width,
-          height,
-          2.0,
-          down_camera.m_rotation_conj.coeffs().data(),
-          down_x,
-          down_y,
-          mouse_x,
-          mouse_y,
-          q.coeffs().data());
-          break;
-      }
-      case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
-      {
-        // Rotate according to two axis valuator with fixed up vector
-        two_axis_valuator_fixed_up(
-          width, height,
-          2.0,
-          down_camera.m_rotation_conj,
-          down_x, down_y, mouse_x, mouse_y,
-          q);
-        break;
-      }
-      default:
-        break;
-    }
-    camera.orbit(q.conjugate());
-  }
-}
-
-void init_relative()
-{
-  using namespace Eigen;
-  using namespace igl;
-  per_face_normals(V,F,N);
-  Vmax = V.colwise().maxCoeff();
-  Vmin = V.colwise().minCoeff();
-  Vmid = 0.5*(Vmax + Vmin);
-  bbd = (Vmax-Vmin).norm();
-}
-
-void init_samples()
-{
-  using namespace Eigen;
-  using namespace igl;
-  const int n = V.rows()*10;
-  SparseMatrix<double> B;
-  VectorXi FI;
-  random_points_on_mesh(n,V,F,B,FI);
-  S = B*V;
-}
-
-void undo()
-{
-  using namespace std;
-  if(!undo_stack.empty())
-  {
-    redo_stack.push(s);
-    s = undo_stack.top();
-    undo_stack.pop();
-  }
-}
-
-void redo()
-{
-  using namespace std;
-  if(!redo_stack.empty())
-  {
-    undo_stack.push(s);
-    s = redo_stack.top();
-    redo_stack.pop();
-  }
-}
-
-void key(unsigned char key, int mouse_x, int mouse_y)
-{
-  using namespace std;
-  using namespace igl;
-  using namespace Eigen;
-  int mod = glutGetModifiers();
-  const bool command_down = GLUT_ACTIVE_COMMAND & mod;
-  const bool shift_down = GLUT_ACTIVE_SHIFT & mod;
-  switch(key)
-  {
-    // ESC
-    case char(27):
-      rebar.save(REBAR_NAME);
-    // ^C
-    case char(3):
-      exit(0);
-    case 'z':
-    case 'Z':
-      if(command_down)
-      {
-        if(shift_down)
-        {
-          redo();
-        }else
-        {
-          undo();
-        }
-        break;
-      }else
-      {
-        push_undo();
-        Quaterniond q;
-        snap_to_canonical_view_quat(s.camera.m_rotation_conj,1.0,q);
-        s.camera.orbit(q.conjugate());
-      }
-    default:
-      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
-      {
-        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
-      }
-  }
-
-}
-
-int main(int argc, char * argv[])
-{
-  using namespace std;
-  using namespace Eigen;
-  using namespace igl;
-  string filename = "../shared/cheburashka.off";
-  if(argc < 2)
-  {
-    cerr<<"Usage:"<<endl<<"    ./example input.obj"<<endl;
-    cout<<endl<<"Opening default mesh..."<<endl;
-  }else
-  {
-    // Read and prepare mesh
-    filename = argv[1];
-  }
-
-  // print key commands
-  cout<<"[Click] and [drag]  Rotate model using trackball."<<endl;
-  cout<<"[Z,z]               Snap rotation to canonical view."<<endl;
-  cout<<"[⌘ Z]               Undo."<<endl;
-  cout<<"[⇧ ⌘ Z]             Redo."<<endl;
-  cout<<"[^C,ESC]            Exit."<<endl;
-
-  // dirname, basename, extension and filename
-  string d,b,ext,f;
-  pathinfo(filename,d,b,ext,f);
-  // Convert extension to lower case
-  transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-  vector<vector<double > > vV,vN,vTC;
-  vector<vector<int > > vF,vFTC,vFN;
-  if(ext == "obj")
-  {
-    // Convert extension to lower case
-    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
-    {
-      return 1;
-    }
-  }else if(ext == "off")
-  {
-    // Convert extension to lower case
-    if(!igl::readOFF(filename,vV,vF,vN))
-    {
-      return 1;
-    }
-  }else if(ext == "wrl")
-  {
-    // Convert extension to lower case
-    if(!igl::readWRL(filename,vV,vF))
-    {
-      return 1;
-    }
-  //}else
-  //{
-  //  // Convert extension to lower case
-  //  MatrixXi T;
-  //  if(!igl::readMESH(filename,V,T,F))
-  //  {
-  //    return 1;
-  //  }
-  //  //if(F.size() > T.size() || F.size() == 0)
-  //  {
-  //    boundary_facets(T,F);
-  //  }
-  }
-  if(vV.size() > 0)
-  {
-    if(!list_to_matrix(vV,V))
-    {
-      return 1;
-    }
-    polygon_mesh_to_triangle_mesh(vF,F);
-  }
-
-  init_relative();
-  init_samples();
-
-  // Init glut
-  glutInit(&argc,argv);
-  if( !TwInit(TW_OPENGL, NULL) )
-  {
-    // A fatal error occured
-    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
-    return 1;
-  }
-  // Create a tweak bar
-  rebar.TwNewBar("TweakBar");
-  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
-    s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
-    "igl_trackball,two-a...-fixed-up");
-  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
-    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  rebar.load(REBAR_NAME);
-
-  // Init antweakbar
-  glutInitDisplayString( "rgba depth double samples>=8 ");
-  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
-  glutCreateWindow("upright");
-  glutDisplayFunc(display);
-  glutReshapeFunc(reshape);
-  glutKeyboardFunc(key);
-  glutMouseFunc(mouse);
-  glutMotionFunc(mouse_drag);
-  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
-  glutMainLoop();
-
-  return 0;
-}

+ 0 - 25
examples/render_to_png/Makefile

@@ -1,25 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-LIBIGL_LIB+=-liglpng
-
-# YIMG dependency
-
-all: example
-
-.PHONY: example
-
-IGL=../../
-
-inc=$(LIBIGL_INC) $(YIMG_INC) $(EIGEN3_INC)
-lib=$(LIBIGL_LIB) $(OPENGL_LIB) $(GLUT_LIB) $(YIMG_LIB)
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

Некоторые файлы не были показаны из-за большого количества измененных файлов