1. A pattern inspection apparatus for inspecting a pattern to-be-inspected by using an image of said pattern to-be-inspected and data for fabricating said pattern to-be-inspected, said pattern inspection apparatus comprising: an image generation device configured to generate said image of said pattern to-be-inspected; and a memory storing a plurality of machine readable instructions that when executed perform the steps of: (a) storing in said memory a reference pattern generated from said data, said reference pattern represented by one or both of (i) one or more line segments, and (ii) one or more curves, said reference pattern generated from said data; (b) storing in said memory detected edges of said image; and (c) inspecting said pattern to-be-inspected by using at least one of distances between said detected edges and at least one of said line segments and said curves of said reference pattern to generate defect information, wherein said machine readable instructions, when executed, detect at least one edge of said image by: (i) setting a profile acquisition section by using at least one of said line segments and said curves of said reference pattern, (ii) obtaining a profile of said image of said pattern-to-be-inspected by using said profile acquisition section and said image of said pattern to-be-inspected, and (iii) detecting said edge from said profile of said image of said pattern to-be-inspected.