This is still a work in progress, but I invite comment. I can think of several ways it might yet be improved:
isWalkable is a not quite the right test; doors are walkable but should probably still modify the wall shape.
tree trunks and walls are both not walkable, so this will cause them to modify each other's shapes
it's possible that the mask should be larger, to have more bits per neighboring tile. This could be used to have different overrides for a smooth/constructed wall next to another smooth/constructed wall and a wall next to raw stone.
This is still a work in progress, but I invite comment. I can think of several ways it might yet be improved: