Why not just use an array?
All you have to do is create an angle value either 0,90,180 or, 270, and then test if the "cells" around the object match up.
Just remember that the array coordinates would be multiplied by the grid size. IE array at x1,y1 would be x32, y32 if the individual cells are 32x32.
So you would check if array at this x, and this y has a value of 0, and the value of this x +1, and this y is 180 then you would have two pipes horizontally.