Finds a valid (existing) trinagle adjacent to a given invalid cell

@param minInvalidCell minimum bounding box invalid cell
@return a valid triangle adjacent to the invalid cell
17165
private Triangle findValidTriangle(Vector2i minInvalidCell) {
        // If the invalid cell is the minimal one in the grid we are forced to search the
        // triangulation for a trinagle at that location
        if (minInvalidCell.getX() == 0 && minInvalidCell.getY() == 0)
            return indexDelaunay.find(middleOfCell(minInvalidCell.getX(), minInvalidCell.getY()), null);
        else
            // Otherwise we can take an adjacent cell triangle that is still valid
            return grid[Math.min(0, minInvalidCell.getX())][Math.min(0, minInvalidCell.getY())];
    }
702
public static Geometry computeBoundingCircle(Geometry geometry) {
        if (geometry == null) {
            return null;
        }
        return new MinimumBoundingCircle(geometry).getCircle();
    }
1175763
public boolean intersects(Geometry geometry) {
		if (geometry == null || isEmpty() || geometry.isEmpty()) {
			return false;
		}

		if (geometry.getNumGeometries() > 1) {
			for (int n = 0; n < geometry.getNumGeometries(); n++) {
				if (intersects(geometry.getGeometryN(n))) {
					return true;
				}
			}
		} else {
			final Coordinate[] coords = geometry.getCoordinates();
			if (coords.length > 1 && coordinates.length > 1) {
				for (int i = 0; i < coordinates.length - 1; i++) {
					for (int j = 0; j < coords.length - 1; j++) {
						if (Mathlib.lineIntersects(coordinates[i], coordinates[i + 1], coords[j], coords[j + 1])) {
							return true;
						}
					}
					if (Mathlib.touches(geometry, coordinates[i])) {
						return true;
					}
				}
			} else {
				// TODO implement me
			}
		}

		return false;
	}
1027087
function isValidDiagonal (data, a, b) {
  return !intersectsPolygon(data, a, a.i, b.i) &&
    locallyInside(data, a, b) && locallyInside(data, b, a) &&
    middleInside(data, a, a.i, b.i)
}
162146
boolean isCornerValidOrigin( Node candidate ) {
		candidate.putEdgesIntoList(edgeList);
		if( edgeList.size() != 2 ) {
			throw new RuntimeException("BUG! Should be a corner and have two edges");
		}

		Node a = edgeList.get(0);
		Node b = edgeList.get(1);

		// Find the average angle from the two vectors defined by the two connected nodes
		double dirA = Math.atan2(a.y-candidate.y, a.x-candidate.x);
		double dirB = Math.atan2(b.y-candidate.y, b.x-candidate.x);

		double dirAB = UtilAngle.boundHalf(dirA+UtilAngle.distanceCCW(dirA,dirB)/2.0);

		// Find the acute angle between the corner's orientation and the vector
		double acute = UtilAngle.distHalf(dirAB,candidate.orientation);

		return acute < Math.PI/4.0;
	}
1313800
private List<Triangle> findConnectedTriangles(Vector3 point) {

		// Getting one of the neigh
		Triangle triangle = find(point);

		// Validating find results.
		if (!triangle.isCorner(point)) {
			System.err.println("findConnectedTriangles: Could not find connected vertices since the first found triangle doesn't" +
					" share the given point.");
			return null;
		}

		return findTriangleNeighborhood(triangle, point);
	}
271918
def _find_valid_block(self, table, worksheet, flags, units, used_cells, start_pos, end_pos):
        '''
        
        '''
        for row_index in range(len(table)):
            if row_index < start_pos[0] or row_index > end_pos[0]:
                continue
            convRow = table[row_index]
            used_row = used_cells[row_index]
            for column_index, conv in enumerate(convRow):
                if (column_index < start_pos[1] or column_index > end_pos[1] or used_row[column_index]):
                    continue
                # Is non empty cell?
                if not is_empty_cell(conv):
                    block_start, block_end = self._find_block_bounds(table, used_cells,
                            (row_index, column_index), start_pos, end_pos)
                    if (block_end[0] > block_start[0] and
                        block_end[1] > block_start[1]):
                        try:
                            return TableBlock(table, used_cells, block_start, block_end, worksheet,
                                flags, units, self.assume_complete_blocks, self.max_title_rows)
                        except InvalidBlockError:
                            pass
                        # Prevent infinite loops if something goes wrong
                        used_cells[row_index][column_index] = True
749203
def _validate_simple_fault_geometry(self, node, _float_re):
        
        try:
            # Parse the geometry
            coords = split_coords_2d(~node.LineString.posList)
            trace = geo.Line([geo.Point(*p) for p in coords])
        except ValueError:
            # If the geometry cannot be created then use the LogicTreeError
            # to point the user to the incorrect node. Hence, if trace is
            # compiled successfully then len(trace) is True, otherwise it is
            # False
            trace = []
        if len(trace):
            return
        raise LogicTreeError(
            node, self.filename,
            "'simpleFaultGeometry' node is not valid")
1065778
private Vector3 middleOfCell(int x_index, int y_index) {
        float middleXCell = (float) (indexRegion.minX() + x_index * x_size + x_size / 2);
        float middleYCell = (float) (indexRegion.minY() + y_index * y_size + y_size / 2);
        return new Vector3(middleXCell, middleYCell, 0);
    }
605272
public ValidatorBuilderInteger<PARENT> range(int min, int max) {

    return range(new Range<>(Integer.valueOf(min), Integer.valueOf(max)));
  }
212240
function findCell(cells, c) {
  var lo = 0
    , hi = cells.length-1
    , r  = -1
  while (lo <= hi) {
    var mid = (lo + hi) >> 1
      , s   = compareCells(cells[mid], c)
    if(s <= 0) {
      if(s === 0) {
        r = mid
      }
      lo = mid + 1
    } else if(s > 0) {
      hi = mid - 1
    }
  }
  return r
}
695691
public static GeometryValidationState validate(Geometry geometry) {
		validationContext.clear();
		if (Geometry.LINE_STRING.equals(geometry.getGeometryType())) {
			IndexedLineString lineString = helper.createLineString(geometry);
			validateLineString(lineString);
		} else if (Geometry.LINEAR_RING.equals(geometry.getGeometryType())) {
			IndexedLinearRing ring = helper.createLinearRing(geometry);
			validateLinearRing(ring);
		} else if (Geometry.POLYGON.equals(geometry.getGeometryType())) {
			IndexedPolygon polygon = helper.createPolygon(geometry);
			validatePolygon(polygon);
		} else if (Geometry.MULTI_LINE_STRING.equals(geometry.getGeometryType())) {
			IndexedMultiLineString multiLineString = helper.createMultiLineString(geometry);
			validateMultiLineString(multiLineString);
		} else if (Geometry.MULTI_POLYGON.equals(geometry.getGeometryType())) {
			IndexedMultiPolygon multiPolygon = helper.createMultiPolygon(geometry);
			validateMultiPolygon(multiPolygon);
		}
		return validationContext.getState();
	}
1048066
function validateNode(opts: Options) {
    const isRow = node => node.type === opts.typeRow;
    const isCell = node => node.type === opts.typeCell;
    const countCells = row => row.nodes.count(isCell);

    return node => {
        if (node.type !== opts.typeTable) {
            return undefined;
        }

        const rows = node.nodes.filter(isRow);
        const maxColumns = Math.max(
            // Minimum 1 column
            1,
            rows.map(countCells).max()
        );
        const rowsMissingColumns = rows.filter(
            row => countCells(row) < maxColumns
        );

        if (rowsMissingColumns.isEmpty()) {
            return undefined;
        }

        return change => {
            rowsMissingColumns.forEach(row => {
                const numberOfCellsToAdd = maxColumns - row.nodes.size;
                const cells = Array.from({ length: numberOfCellsToAdd }).map(
                    () => createCell(opts)
                );
                cells.forEach(cell =>
                    change.insertNodeByKey(row.key, row.nodes.size, cell, {
                        normalize: false
                    })
                );
            });
        };
    };
}
228071
public Rule TableCell() {
        return Sequence(
                NodeSequence(
                        push(new TableCellNode()),
                        TestNot(Sp(), Optional(':'), Sp(), OneOrMore('-'), Sp(), Optional(':'), Sp(), FirstOf('|', Newline())),
                        Optional(Sp(), TestNot('|'), NotNewline()),
                        OneOrMore(
                                TestNot('|'), TestNot(Sp(), Newline()), Inline(),
                                addAsChild(),
                                Optional(Sp(), Test('|'), Test(Newline()))
                        )
                ),
                ZeroOrMore('|'),
                ((TableCellNode) peek()).setColSpan(Math.max(1, matchLength()))
        );
    }
862886
function tril(A, k) {
    if (k === void 0) { k = 0; }
    if (A.shape.length !== 2) {
        throw new Error('Input is not matrix');
    }
    var copyA = A.clone();
    for (var i = 0; i < copyA.shape[0]; i++) {
        for (var j = 0; j < copyA.shape[1]; j++) {
            if (i < j - k) {
                copyA.set(i, j, 0);
            }
        }
    }
    return copyA;
}
1091691
private CellPosition getCellPosition(final FieldAccessor accessor, final XlsCell anno) throws AnnotationInvalidException {

        if(Utils.isNotEmpty(anno.address())) {
            try {
                return CellPosition.of(anno.address());
            } catch(IllegalArgumentException e) {
                throw new AnnotationInvalidException(anno, MessageBuilder.create("anno.attr.invalidAddress")
                        .var("property", accessor.getNameWithClass())
                        .varWithAnno("anno", XlsCell.class)
                        .var("attrName", "address")
                        .var("attrValue", anno.address())
                        .format());
            }

        } else {
            if(anno.row() < 0) {
                throw new AnnotationInvalidException(anno, MessageBuilder.create("anno.attr.min")
                        .var("property", accessor.getNameWithClass())
                        .varWithAnno("anno", XlsCell.class)
                        .var("attrName", "row")
                        .var("attrValue", anno.row())
                        .var("min", 0)
                        .format());
            }

            if(anno.column() < 0) {
                throw new AnnotationInvalidException(anno, MessageBuilder.create("anno.attr.min")
                        .var("property", accessor.getNameWithClass())
                        .varWithAnno("anno", XlsCell.class)
                        .var("attrName", "column")
                        .var("attrValue", anno.column())
                        .var("min", 0)
                        .format());

            }

            return CellPosition.of(anno.row(), anno.column());
        }

    }
1200496
public ValidatorBuilderLong<PARENT> range(long min, long max) {

    return range(new Range<>(Long.valueOf(min), Long.valueOf(max)));
  }