def trigger_click(self, _):
    (entity, _) = self.get_selected_entities()
    if (getattr(self.contours, 'contour_set', None) is not None):
        contour_set = self.contours.contour_set
        (vertices, cells, values) = ([], [], [])
        count = 0
        for (segs, level) in zip(contour_set.allsegs, contour_set.levels):
            for poly in segs:
                n_v = len(poly)
                vertices.append(poly)
                cells.append(np.c_[(np.arange(count, ((count + n_v) - 1)), np.arange((count + 1), (count + n_v)))])
                values.append((np.ones(n_v) * level))
                count += n_v
        if vertices:
            vertices = np.vstack(vertices)
            if self.z_value.value:
                vertices = np.c_[(vertices, np.hstack(values))]
            elif isinstance(entity, (Points, Curve, Surface)):
                z_interp = LinearNDInterpolator(entity.vertices[:, :2], entity.vertices[:, 2])
                vertices = np.c_[(vertices, z_interp(vertices))]
            else:
                vertices = np.c_[(vertices, (np.ones(vertices.shape[0]) * entity.origin['z']))]
            curves = [child for child in self.ga_group.children if (child.name == self.export_as.value)]
            if any(curves):
                curve = curves[0]
                for child in curve.children:
                    self.workspace.remove_entity(child)
                curve.vertices = vertices
                curve.cells = np.vstack(cells).astype('uint32')
            else:
                curve = Curve.create(self.workspace, name=string_name(self.export_as.value), vertices=vertices, cells=np.vstack(cells).astype('uint32'), parent=self.ga_group)
            curve.add_data({self.contours.value: {'values': np.hstack(values)}})
            if self.live_link.value:
                self.live_link_output(self.export_directory.selected_path, self.ga_group)
            self.workspace.finalize()
def trigger_click(self, _):
    (entity, _) = self.get_selected_entities()
    if (getattr(self.contours, 'contour_set', None) is not None):
        contour_set = self.contours.contour_set
        (vertices, cells, values) = ([], [], [])
        count = 0
        for (segs, level) in zip(contour_set.allsegs, contour_set.levels):
            for poly in segs:
                n_v = len(poly)
                vertices.append(poly)
                cells.append(np.c_[(np.arange(count, ((count + n_v) - 1)), np.arange((count + 1), (count + n_v)))])
                values.append((np.ones(n_v) * level))
                count += n_v
        if vertices:
            vertices = np.vstack(vertices)
            if self.z_value.value:
                vertices = np.c_[(vertices, np.hstack(values))]
            elif isinstance(entity, (Points, Curve, Surface)):
                z_interp = LinearNDInterpolator(entity.vertices[:, :2], entity.vertices[:, 2])
                vertices = np.c_[(vertices, z_interp(vertices))]
            else:
                vertices = np.c_[(vertices, (np.ones(vertices.shape[0]) * entity.origin['z']))]
            curves = [child for child in self.ga_group.children if (child.name == self.export_as.value)]
            if any(curves):
                curve = curves[0]
                for child in curve.children:
                    self.workspace.remove_entity(child)
                curve.vertices = vertices
                curve.cells = np.vstack(cells).astype('uint32')
            else:
                curve = Curve.create(self.workspace, name=string_name(self.export_as.value), vertices=vertices, cells=np.vstack(cells).astype('uint32'), parent=self.ga_group)
            curve.add_data({self.contours.value: {'values': np.hstack(values)}})
            if self.live_link.value:
                self.live_link_output(self.export_directory.selected_path, self.ga_group)
            self.workspace.finalize()