From 6fddb0f2c9f60714089389350e001f6f765d2405 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Tue, 11 Jun 2019 00:22:09 -0400 Subject: Script to extract test data from OBJ spec. --- doc/OBJ.spec | 100 +++++++++++++++++++++++----------------------- test-data/extract-data.sh | 10 +++++ 2 files changed, 60 insertions(+), 50 deletions(-) create mode 100755 test-data/extract-data.sh diff --git a/doc/OBJ.spec b/doc/OBJ.spec index 09b6e72..13f49a5 100644 --- a/doc/OBJ.spec +++ b/doc/OBJ.spec @@ -915,41 +915,41 @@ This is a cube with negative vertex reference numbers. Each element references the vertices stored immediately above it in the file. Note that vertices are not shared. -v 0.000000 2.000000 2.000000 -v 0.000000 0.000000 2.000000 -v 2.000000 0.000000 2.000000 -v 2.000000 2.000000 2.000000 -f -4 -3 -2 -1 - -v 2.000000 2.000000 0.000000 -v 2.000000 0.000000 0.000000 -v 0.000000 0.000000 0.000000 -v 0.000000 2.000000 0.000000 -f -4 -3 -2 -1 - -v 2.000000 2.000000 2.000000 -v 2.000000 0.000000 2.000000 -v 2.000000 0.000000 0.000000 -v 2.000000 2.000000 0.000000 -f -4 -3 -2 -1 - -v 0.000000 2.000000 0.000000 -v 0.000000 2.000000 2.000000 -v 2.000000 2.000000 2.000000 -v 2.000000 2.000000 0.000000 -f -4 -3 -2 -1 - -v 0.000000 2.000000 0.000000 -v 0.000000 0.000000 0.000000 -v 0.000000 0.000000 2.000000 -v 0.000000 2.000000 2.000000 -f -4 -3 -2 -1 - -v 0.000000 0.000000 2.000000 -v 0.000000 0.000000 0.000000 -v 2.000000 0.000000 0.000000 -v 2.000000 0.000000 2.000000 -f -4 -3 -2 -1 + v 0.000000 2.000000 2.000000 + v 0.000000 0.000000 2.000000 + v 2.000000 0.000000 2.000000 + v 2.000000 2.000000 2.000000 + f -4 -3 -2 -1 + + v 2.000000 2.000000 0.000000 + v 2.000000 0.000000 0.000000 + v 0.000000 0.000000 0.000000 + v 0.000000 2.000000 0.000000 + f -4 -3 -2 -1 + + v 2.000000 2.000000 2.000000 + v 2.000000 0.000000 2.000000 + v 2.000000 0.000000 0.000000 + v 2.000000 2.000000 0.000000 + f -4 -3 -2 -1 + + v 0.000000 2.000000 0.000000 + v 0.000000 2.000000 2.000000 + v 2.000000 2.000000 2.000000 + v 2.000000 2.000000 0.000000 + f -4 -3 -2 -1 + + v 0.000000 2.000000 0.000000 + v 0.000000 0.000000 0.000000 + v 0.000000 0.000000 2.000000 + v 0.000000 2.000000 2.000000 + f -4 -3 -2 -1 + + v 0.000000 0.000000 2.000000 + v 0.000000 0.000000 0.000000 + v 2.000000 0.000000 0.000000 + v 2.000000 0.000000 2.000000 + f -4 -3 -2 -1 @@ -2358,21 +2358,21 @@ references itself as the trace object. This example describes a 2 x 2 square. It is mapped with a 1 x 1 square texture. The texture is stretched to fit the square exactly. -mtllib master.mtl - -v 0.000000 2.000000 0.000000 -v 0.000000 0.000000 0.000000 -v 2.000000 0.000000 0.000000 -v 2.000000 2.000000 0.000000 -vt 0.000000 1.000000 0.000000 -vt 0.000000 0.000000 0.000000 -vt 1.000000 0.000000 0.000000 -vt 1.000000 1.000000 0.000000 -# 4 vertices - -usemtl wood -f 1/1 2/2 3/3 4/4 -# 1 element + mtllib master.mtl + + v 0.000000 2.000000 0.000000 + v 0.000000 0.000000 0.000000 + v 2.000000 0.000000 0.000000 + v 2.000000 2.000000 0.000000 + vt 0.000000 1.000000 0.000000 + vt 0.000000 0.000000 0.000000 + vt 1.000000 0.000000 0.000000 + vt 1.000000 1.000000 0.000000 + # 4 vertices + + usemtl wood + f 1/1 2/2 3/3 4/4 + # 1 element 5. Approximation technique for a surface diff --git a/test-data/extract-data.sh b/test-data/extract-data.sh new file mode 100755 index 0000000..a0e5af8 --- /dev/null +++ b/test-data/extract-data.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# This script extracts examples from OBJ.spec for testing purposes. + +IFS='' read -r -d '' prog <<'EOF' +BEGINFILE { g=0; } + /^ (v[tnp]? [^is]|#|mtllib\b|g\b)/ {if(!inside){ g++; inside=1; }} + /^[^ ]/{inside=0;} { if(inside) {print $0 > sprintf("%02d",g) ".obj"}} +EOF +awk "$prog" ../doc/OBJ.spec -- cgit v1.2.3