  We present a new algorithm to sample the constrained eigenvalues of the
initial shear field associated with Gaussian statistics, called the `peak/dip
excursion-set-based' algorithm, at positions which correspond to peaks or dips
of the correlated density field. The computational procedure is based on a new
formula which extends Doroshkevich's unconditional distribution for the
eigenvalues of the linear tidal field, to account for the fact that halos and
voids may correspond to maxima or minima of the density field. The ability to
differentiate between random positions and special points in space around which
halos or voids may form (peaks/dips), encoded in the new formula and reflected
in the algorithm, naturally leads to a straightforward implementation of an
excursion set model for peaks and dips in Gaussian random fields - one of the
key advantages of this sampling procedure. In addition, it offers novel
insights into the statistical description of the cosmic web. As a first
physical application, we show how the standard distributions of shear
ellipticity and prolateness in triaxial models of structure formation are
modified by the constraint. In particular, we provide a new expression for the
conditional distribution of shape parameters given the density peak constraint,
which generalizes some previous literature work. The formula has important
implications for the modeling of non-spherical dark matter halo shapes, in
relation to their initial shape distribution. We also test and confirm our
theoretical predictions for the individual distributions of eigenvalues
subjected to the extremum constraint, along with other directly related
conditional probabilities. Finally, we indicate how the proposed sampling
procedure naturally integrates into the standard excursion set model,
potentially solving some of its well-known problems, and into the ellipsoidal
collapse framework. (abridged)
