|
Java example source code file (NestedLoops.java)
The NestedLoops.java Java example source code/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.math3.geometry.euclidean.twod; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.commons.math3.exception.MathIllegalArgumentException; import org.apache.commons.math3.exception.util.LocalizedFormats; import org.apache.commons.math3.geometry.Point; import org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet; import org.apache.commons.math3.geometry.partitioning.Region; import org.apache.commons.math3.geometry.partitioning.RegionFactory; import org.apache.commons.math3.geometry.partitioning.SubHyperplane; /** This class represent a tree of nested 2D boundary loops. * <p>This class is used for piecewise polygons construction. * Polygons are built using the outline edges as * representative of boundaries, the orientation of these lines are * meaningful. However, we want to allow the user to specify its * outline loops without having to take care of this orientation. This * class is devoted to correct mis-oriented loops.<p> * <p>Orientation is computed assuming the piecewise polygon is finite, * i.e. the outermost loops have their exterior side facing points at * infinity, and hence are oriented counter-clockwise. The orientation of * internal loops is computed as the reverse of the orientation of * their immediate surrounding loop.</p> * @since 3.0 */ class NestedLoops { /** Boundary loop. */ private Vector2D[] loop; /** Surrounded loops. */ private List<NestedLoops> surrounded; /** Polygon enclosing a finite region. */ private Region<Euclidean2D> polygon; /** Indicator for original loop orientation. */ private boolean originalIsClockwise; /** Tolerance below which points are considered identical. */ private final double tolerance; /** Simple Constructor. * <p>Build an empty tree of nested loops. This instance will become * the root node of a complete tree, it is not associated with any * loop by itself, the outermost loops are in the root tree child * nodes.</p> * @param tolerance tolerance below which points are considered identical * @since 3.3 */ NestedLoops(final double tolerance) { this.surrounded = new ArrayList<NestedLoops>(); this.tolerance = tolerance; } /** Constructor. * <p>Build a tree node with neither parent nor children * @param loop boundary loop (will be reversed in place if needed) * @param tolerance tolerance below which points are considered identical * @exception MathIllegalArgumentException if an outline has an open boundary loop * @since 3.3 */ private NestedLoops(final Vector2D[] loop, final double tolerance) throws MathIllegalArgumentException { if (loop[0] == null) { throw new MathIllegalArgumentException(LocalizedFormats.OUTLINE_BOUNDARY_LOOP_OPEN); } this.loop = loop; this.surrounded = new ArrayList<NestedLoops>(); this.tolerance = tolerance; // build the polygon defined by the loop final ArrayList<SubHyperplane Other Java examples (source code examples)Here is a short list of links related to this Java NestedLoops.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.