spec/solid_spec.rb in triangular-0.0.1 vs spec/solid_spec.rb in triangular-0.0.2
- old
+ new
@@ -77,9 +77,132 @@
end
it "should return a Polyline" do
@solid.slice_at_z(0).should be_a Polyline
end
+ end
+
+ describe "#get_bounds" do
+ before do
+ @solid = Solid.parse(<<-EOD)
+ solid y-axis-spacer
+ facet normal 0.0 0.0 -1.0
+ outer loop
+ vertex -16.5 0.0 -0.75
+ vertex 0.0 -9.5 -0.75
+ vertex 0.0 0.0 -0.75
+ endloop
+ endfacet
+ facet normal -0.0 1.0 0.0
+ outer loop
+ vertex 0.0 -1.87 0.0
+ vertex 16.5 -1.87 -0.13
+ vertex 0.0 1.87 -0.13
+ endloop
+ endfacet
+ endsolid y-axis-spacer
+ EOD
+ end
+ it "should return an array" do
+ @solid.get_bounds.should be_a Array
+ end
+ it "should return a point with the smallest bounds" do
+ @solid.get_bounds[0].x.should == -16.5
+ @solid.get_bounds[0].y.should == -9.5
+ @solid.get_bounds[0].z.should == -0.75
+ end
+
+ it "should return a point with the largest bounds" do
+ @solid.get_bounds[1].x.should == 16.5
+ @solid.get_bounds[1].y.should == 1.87
+ @solid.get_bounds[1].z.should == 0.0
+ end
+ end
+
+ describe "#translate!" do
+ before do
+ @solid = Solid.parse(<<-EOD)
+ solid y-axis-spacer
+ facet normal 0.0 0.0 -1.0
+ outer loop
+ vertex -16.5 0.0 -0.75
+ vertex 0.0 -9.5 -0.75
+ vertex 0.0 0.0 -0.75
+ endloop
+ endfacet
+ facet normal -0.0 1.0 0.0
+ outer loop
+ vertex 0.0 -1.87 0.0
+ vertex 16.5 -1.87 -0.13
+ vertex 0.0 1.87 -0.13
+ endloop
+ endfacet
+ endsolid y-axis-spacer
+ EOD
+ end
+
+ it "should call translate on each of it's Facets" do
+ @solid.facets[0].should_receive(:translate!).with(16.5, 9.5, 0.75)
+ @solid.facets[1].should_receive(:translate!).with(16.5, 9.5, 0.75)
+
+ @solid.translate!(16.5, 9.5, 0.75)
+ end
+ end
+
+ describe "#align_to_origin!" do
+ before do
+ @solid = Solid.parse(<<-EOD)
+ solid y-axis-spacer
+ facet normal 0.0 0.0 -1.0
+ outer loop
+ vertex -16.5 0.0 5.0
+ vertex 0.0 -9.5 10.0
+ vertex 0.0 0.0 5.0
+ endloop
+ endfacet
+ facet normal -0.0 1.0 0.0
+ outer loop
+ vertex 0.0 -1.87 5.0
+ vertex 16.5 -1.87 11.0
+ vertex 0.0 1.87 6.0
+ endloop
+ endfacet
+ endsolid y-axis-spacer
+ EOD
+ end
+
+ it "should translate solid so the lowermost XYZ edges are all 0.0" do
+ @solid.should_receive(:translate!).with(16.5, 9.5, -5.0)
+ @solid.align_to_origin!
+ end
+ end
+
+ describe "#center!" do
+ before do
+ @solid = Solid.parse(<<-EOD)
+ solid y-axis-spacer
+ facet normal 0.0 0.0 -1.0
+ outer loop
+ vertex -16.5 0.0 5.0
+ vertex 0.0 -9.5 10.0
+ vertex 0.0 0.0 5.0
+ endloop
+ endfacet
+ facet normal -0.0 1.0 0.0
+ outer loop
+ vertex 0.0 -1.87 5.0
+ vertex 17.5 -1.87 11.0
+ vertex 0.0 1.5 6.0
+ endloop
+ endfacet
+ endsolid y-axis-spacer
+ EOD
+ end
+
+ it "should translate solid so the lowermost XYZ edges are all 0.0" do
+ @solid.should_receive(:translate!).with(-0.5, 4.0, -8.0)
+ @solid.center!
+ end
end
end
\ No newline at end of file