Skip to content

Commit

Permalink
extruded polygon
Browse files Browse the repository at this point in the history
* finish implementation of extruded polygon

* draw side faces

* closes #8
  • Loading branch information
tpmccauley committed Sep 5, 2023
1 parent 5f20568 commit bbb5b3c
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion lib/draw_solid_methods/draw_ExtrudedPolygon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,53 @@ def defineFaces(entities, args)
face = entities.add_face points

end
end


def makeSideFaces(a, b, entities)

vertices = Array.new

(0..a.length-1).each do |ai|

if ai < a.length-1
vertices = [a[ai], b[ai], b[ai+1], a[ai+1]]
else
vertices = [a[ai], b[ai], b[0], a[0]]
end

face = entities.add_face vertices

end
end


def connectFaces(entities, args)

zpoints = Array.new

args["ZXYSection"].each do |zxy|

points = Array.new

args["XYPoint"].each do |xy|

x = xy["x"]*zxy["scale"] + zxy["x"]
y = xy["y"]*zxy["scale"] + zxy["y"]

point = Geom::Point3d.new(x, y, zxy["z"])
points << point
end

zpoints << points

end

(0..zpoints.length-2).each do |p|
makeSideFaces(zpoints[p], zpoints[p+1], entities)
end
end


def reverseFacesIfInward(entities)
for e in entities
Expand All @@ -35,8 +80,9 @@ def reverseFacesIfInward(entities)
group = entities.add_group
entities = group.entities
defineFaces entities, args
connectFaces entities, args

#reverseFacesIfInward(entities)
reverseFacesIfInward(entities)

group

Expand Down

0 comments on commit bbb5b3c

Please sign in to comment.