     int x = index % width;
     int y = index / width;
 
+    unsigned char constraintValue =
+        tex2D<unsigned char>(constraints, x + 0.5f, y + 0.5f);
+    if (constraintValue)
+    {
+      EvalResult result(x, y, constraintViolationCost);
+      return result;
+    }
+
     float distanceToAnchor = lineLength(x, y);
 
     float cost = occupancyForLabelArea(x, y) + 1e-3f * distanceToAnchor +

  costEvaluator.anchorY = anchorY * heightFactor;
  costEvaluator.occupancy =
      thrust::raw_pointer_cast(occupancySummedAreaTable.data());
  costEvaluator.halfLabelWidth = labelWidthInPixel * 0.5f * widthFactor;
  costEvaluator.halfLabelHeight = labelHeightInPixel * 0.5f * heightFactor;


  float anchorX;
  float anchorY;

  cudaTextureObject_t constraints;
  const float *occupancy;

  const float constraintViolationCost = 1e100f;

  __device__ float lineLength(int x, int y) const
  {
