Skip to content
Carsten Arnholm edited this page Sep 11, 2017 · 2 revisions

fill2d

The boolean operator <fill2d> fills any internal holes in a 2d shape. The result is a new 2d shape. It works similar to hull2d, but where hull2d leaves a convex shape as a result, fill2d leaves the original outer contour untouched, even if it is concave.

The following example first shows creation of a 2d shape with holes, extruded to create a 3d solid. Scroll down to see the same shape processed with fill2d.

<?xml version="1.0" encoding="utf-8"?>
<xcsg version="1.0">
	<metadata>
		<software name="angelcad" version="v1.0-01"/>
		<model name="fill2d" created="2017-09-11T17:36:44"/>
	</metadata>
	<linear_extrude dz="1">
		<difference2d>
			<union2d>
				<polygon>
					<vertices>
						<vertex x="0" y="0"/>
						<vertex x="100" y="0"/>
						<vertex x="50" y="100"/>
					</vertices>
				</polygon>
				<square size="80" center="false"/>
			</union2d>
			<union2d>
				<polygon>
					<vertices>
						<vertex x="40" y="20"/>
						<vertex x="80" y="20"/>
						<vertex x="70" y="50"/>
					</vertices>
				</polygon>
				<circle r="40"/>
				<circle r="10">
					<tmatrix>
						<trow c0="1" c1="0" c2="0" c3="30"/>
						<trow c0="0" c1="1" c2="0" c3="50"/>
						<trow c0="0" c1="0" c2="1" c3="0"/>
						<trow c0="0" c1="0" c2="0" c3="1"/>
					</tmatrix>
				</circle>
			</union2d>
		</difference2d>
	</linear_extrude>
</xcsg>

Concave shape with internal holes:

Now apply the <fill2d> operator to the above 2d shape, before extruding:

<?xml version="1.0" encoding="utf-8"?>
<xcsg version="1.0">
	<metadata>
		<software name="angelcad" version="v1.0-01"/>
		<model name="fill2d" created="2017-09-11T17:39:46"/>
	</metadata>
	<linear_extrude dz="1">
		<fill2d>
			<difference2d>
				<union2d>
					<polygon>
						<vertices>
							<vertex x="0" y="0"/>
							<vertex x="100" y="0"/>
							<vertex x="50" y="100"/>
						</vertices>
					</polygon>
					<square size="80" center="false"/>
				</union2d>
				<union2d>
					<polygon>
						<vertices>
							<vertex x="40" y="20"/>
							<vertex x="80" y="20"/>
							<vertex x="70" y="50"/>
						</vertices>
					</polygon>
					<circle r="40"/>
					<circle r="10">
						<tmatrix>
							<trow c0="1" c1="0" c2="0" c3="30"/>
							<trow c0="0" c1="1" c2="0" c3="50"/>
							<trow c0="0" c1="0" c2="1" c3="0"/>
							<trow c0="0" c1="0" c2="0" c3="1"/>
						</tmatrix>
					</circle>
				</union2d>
			</difference2d>
		</fill2d>
	</linear_extrude>
</xcsg>

Concave shape with internal holes filled:

Clone this wiki locally