From 041ab041ae06d490245055882dfad97703b90be1 Mon Sep 17 00:00:00 2001 From: Mike Skalnik Date: Thu, 17 Jan 2013 14:15:01 -0800 Subject: [PATCH] Add binary & ascii STLs and OBJs --- lib/linguist/blob_helper.rb | 7 +++ samples/Binary/cube.stl | Bin 0 -> 684 bytes samples/Text/cube.obj | 33 ++++++++++++++ samples/Text/cube.stl | 86 ++++++++++++++++++++++++++++++++++++ test/test_blob.rb | 6 +++ 5 files changed, 132 insertions(+) create mode 100644 samples/Binary/cube.stl create mode 100644 samples/Text/cube.obj create mode 100644 samples/Text/cube.stl diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index d7f56de5..8c91dd94 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -142,6 +142,13 @@ module Linguist ['.png', '.jpg', '.jpeg', '.gif'].include?(extname) end + # Public: Is the blob a support 3D model format? + # + # Return true or false + def solid? + ['.stl', '.obj'].include?(extname) + end + MEGABYTE = 1024 * 1024 # Public: Is the blob too big to load? diff --git a/samples/Binary/cube.stl b/samples/Binary/cube.stl new file mode 100644 index 0000000000000000000000000000000000000000..f4d2a2679c8cd6b7afb7672f0153d910f0a91932 GIT binary patch literal 684 zcmb_Z%L#)(6nq7E3brFLc*#K!(nu;0gtU-qyad4lEXQMZoIJ-}7QAFZdCGj=%r;%y zJu3U#DR!md!|^?t&EZ*ZW}Kgw*JySR-}8jIFNw@CgmMOyz;HCU&|PYIEHypkcgEl* zzM*?Sd${859@2F`Y{+@fkzokM9Nci*>W79$it^sn!Z}0j$^+Us=!_mh#mVvCbL1Fm b^w>zm2zk=`h;tm<-8>Qo)ABaeNMC*d5@?zI literal 0 HcmV?d00001 diff --git a/samples/Text/cube.obj b/samples/Text/cube.obj new file mode 100644 index 00000000..5da92710 --- /dev/null +++ b/samples/Text/cube.obj @@ -0,0 +1,33 @@ +# test_file +v -18.500000 -24.500000 31.000000 +v -18.500000 -24.500000 -0.001000 +v 12.500000 -24.500000 -0.001000 +v 12.500000 -24.500000 31.000000 +v -18.500000 6.500000 31.000000 +v -18.500000 6.500000 -0.001000 +v 12.500000 6.500000 31.000000 +v 12.500000 6.500000 -0.001000 +vn 0.000000 -1.000000 0.000000, +vn 0.000000 -1.000000 0.000000, +vn -1.000000 0.000000 0.000000, +vn -1.000000 0.000000 0.000000, +vn 0.000000 1.000000 0.000000, +vn 0.000000 1.000000 0.000000, +vn 1.000000 0.000000 0.000000, +vn 1.000000 0.000000 0.000000, +vn 0.000000 0.000000 -1.000000, +vn 0.000000 0.000000 -1.000000, +vn 0.000000 0.000000 1.000000, +vn 0.000000 0.000000 1.000000, +f 1//1 2//1 3//1 +f 1//4 3//4 4//4 +f 5//7 6//7 2//7 +f 5//10 2//10 1//10 +f 6//13 5//13 7//13 +f 6//16 7//16 8//16 +f 7//19 4//19 3//19 +f 7//22 3//22 8//22 +f 8//25 3//25 2//25 +f 8//28 2//28 6//28 +f 5//31 1//31 4//31 +f 5//34 4//34 7//34 diff --git a/samples/Text/cube.stl b/samples/Text/cube.stl new file mode 100644 index 00000000..cd20b5c5 --- /dev/null +++ b/samples/Text/cube.stl @@ -0,0 +1,86 @@ +solid + facet normal 0.000000E+00 -1.000000E+00 0.000000E+00 + outer loop + vertex -1.850000E+01 -2.450000E+01 3.100000E+01 + vertex -1.850000E+01 -2.450000E+01 -1.000000E-03 + vertex 1.250000E+01 -2.450000E+01 -1.000000E-03 + endloop + endfacet + facet normal 0.000000E+00 -1.000000E+00 0.000000E+00 + outer loop + vertex -1.850000E+01 -2.450000E+01 3.100000E+01 + vertex 1.250000E+01 -2.450000E+01 -1.000000E-03 + vertex 1.250000E+01 -2.450000E+01 3.100000E+01 + endloop + endfacet + facet normal -1.000000E+00 0.000000E+00 0.000000E+00 + outer loop + vertex -1.850000E+01 6.500000E+00 3.100000E+01 + vertex -1.850000E+01 6.500000E+00 -1.000000E-03 + vertex -1.850000E+01 -2.450000E+01 -1.000000E-03 + endloop + endfacet + facet normal -1.000000E+00 0.000000E+00 0.000000E+00 + outer loop + vertex -1.850000E+01 6.500000E+00 3.100000E+01 + vertex -1.850000E+01 -2.450000E+01 -1.000000E-03 + vertex -1.850000E+01 -2.450000E+01 3.100000E+01 + endloop + endfacet + facet normal 0.000000E+00 1.000000E+00 0.000000E+00 + outer loop + vertex -1.850000E+01 6.500000E+00 -1.000000E-03 + vertex -1.850000E+01 6.500000E+00 3.100000E+01 + vertex 1.250000E+01 6.500000E+00 3.100000E+01 + endloop + endfacet + facet normal 0.000000E+00 1.000000E+00 0.000000E+00 + outer loop + vertex -1.850000E+01 6.500000E+00 -1.000000E-03 + vertex 1.250000E+01 6.500000E+00 3.100000E+01 + vertex 1.250000E+01 6.500000E+00 -1.000000E-03 + endloop + endfacet + facet normal 1.000000E+00 0.000000E+00 0.000000E+00 + outer loop + vertex 1.250000E+01 6.500000E+00 3.100000E+01 + vertex 1.250000E+01 -2.450000E+01 3.100000E+01 + vertex 1.250000E+01 -2.450000E+01 -1.000000E-03 + endloop + endfacet + facet normal 1.000000E+00 0.000000E+00 0.000000E+00 + outer loop + vertex 1.250000E+01 6.500000E+00 3.100000E+01 + vertex 1.250000E+01 -2.450000E+01 -1.000000E-03 + vertex 1.250000E+01 6.500000E+00 -1.000000E-03 + endloop + endfacet + facet normal 0.000000E+00 0.000000E+00 -1.000000E+00 + outer loop + vertex 1.250000E+01 6.500000E+00 -1.000000E-03 + vertex 1.250000E+01 -2.450000E+01 -1.000000E-03 + vertex -1.850000E+01 -2.450000E+01 -1.000000E-03 + endloop + endfacet + facet normal 0.000000E+00 0.000000E+00 -1.000000E+00 + outer loop + vertex 1.250000E+01 6.500000E+00 -1.000000E-03 + vertex -1.850000E+01 -2.450000E+01 -1.000000E-03 + vertex -1.850000E+01 6.500000E+00 -1.000000E-03 + endloop + endfacet + facet normal 0.000000E+00 0.000000E+00 1.000000E+00 + outer loop + vertex -1.850000E+01 6.500000E+00 3.100000E+01 + vertex -1.850000E+01 -2.450000E+01 3.100000E+01 + vertex 1.250000E+01 -2.450000E+01 3.100000E+01 + endloop + endfacet + facet normal 0.000000E+00 0.000000E+00 1.000000E+00 + outer loop + vertex -1.850000E+01 6.500000E+00 3.100000E+01 + vertex 1.250000E+01 -2.450000E+01 3.100000E+01 + vertex 1.250000E+01 6.500000E+00 3.100000E+01 + endloop + endfacet +endsolid diff --git a/test/test_blob.rb b/test/test_blob.rb index 966c2743..3569a8ec 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -132,6 +132,12 @@ class TestBlob < Test::Unit::TestCase assert !blob("Binary/octocat.psd").image? end + def test_solid + assert blob("Binary/cube.stl").solid? + assert blob("Text/cube.stl").solid? + assert blob("Text/cube.obj").solid? + end + def test_viewable assert blob("Text/README").viewable? assert blob("Ruby/foo.rb").viewable?