Skip to content
Permalink
Browse files

Enhance indexing of linear constraints

  • Loading branch information...
gwlucastrig committed Sep 5, 2019
1 parent 159bf71 commit 1a907092fde8cbe242111106879ce09b187def1e
@@ -3,6 +3,8 @@
build/
pmd_results.html
nb*.xml
test*.png
test*.jpg;
nbproject
target
analysis/doc
@@ -30,6 +30,8 @@
*/
package org.tinfour.common;

import java.awt.geom.AffineTransform;
import java.awt.geom.Path2D;
import java.util.List;

/**
@@ -190,4 +192,16 @@
*/
boolean isPointInsideConstraint(double x, double y);



/**
* Gets a Java Path2D based on the geometry of the constraint mapped through
* an optional affine transform.
*
* @param transform a valid transform, or the null to use the identity
* transform.
* @return a valid instance of a Java Path2D
*/
Path2D getPath2D(AffineTransform transform);

}
@@ -426,14 +426,31 @@ Vertex splitEdge(
IQuadEdge eInput,
double zSplit,
boolean restoreConformity);



/**
* Gets the region constraint associated with the edge, if any. If the edge is
* on the border of a region, this method will return the constraint to its
* immediate left side.
*
* @param edge a valid edge instance.
* @return if a region constraint is associated with the edge, a valid
* instance; otherwise, a null.
*/
IConstraint getRegionConstraint(IQuadEdge edge);


/**
* Gets the border constraint associated with the edge.
* Gets the linear constraint associated with the edge, if any.
* In some cases, a linear constraint may lie within a constrained
* region, but it will not lie on the border of a constrained
* region.
*
* @param edge a valid edge instance.
* @return if a border constraint is associated with the edge, a valid
* @return if a linear constraint is associated with the edge, a valid
* instance; otherwise, a null.
*/
IConstraint getBorderConstraint(IQuadEdge edge) ;
IConstraint getLinearConstraint(IQuadEdge edge);



}
@@ -175,6 +175,15 @@
* @return true if the edge is a member of an region; otherwise false.
*/
boolean isConstrainedRegionMember();

/**
* Indicates whether the edge is a member of a linear constraint, In some
* cases, a linear constraint member edge may lie within a constrained region
* but will not lie on one of its borders.
*
* @return true if the edge is a member of an region; otherwise false.
*/
boolean isLinearConstraintMember();

/**
* Indicates whether the edge is in the interior of a constrained region.
@@ -30,6 +30,8 @@
*/
package org.tinfour.common;

import java.awt.geom.AffineTransform;
import java.awt.geom.Path2D;
import java.util.ArrayList;
import java.util.List;

@@ -133,4 +135,36 @@ public boolean isValid(){
return list.size()>=2;
}


/**
* Gets a Java Path2D based on the geometry of the constraint mapped through
* an optional affine transform.
*
* @param transform a valid transform, or the null to use the identity
* transform.
* @return a valid instance of a Java Path2D
*/
@Override
public Path2D getPath2D(AffineTransform transform) {
AffineTransform af = transform;
if (transform == null) {
af = new AffineTransform();
}
double[] c = new double[4];
Path2D path = new Path2D.Double();
boolean moveFlag = true;
for (Vertex v : list) {
c[0] = v.x;
c[1] = v.y;
af.transform(c, 0, c, 2, 1);
if (moveFlag) {
moveFlag = false;
path.moveTo(c[2], c[3]);
} else {
path.lineTo(c[2], c[3]);
}
}
return path;
}

}
@@ -255,6 +255,7 @@ public boolean isValid() {
* transform.
* @return a valid instance of a Java Path2D
*/
@Override
public Path2D getPath2D(AffineTransform transform) {
AffineTransform af = transform;
if (transform == null) {
@@ -29,6 +29,9 @@
*/
package org.tinfour.common;

import java.awt.geom.AffineTransform;
import java.awt.geom.Path2D;

/**
* Provides methods and elements for a simple representation of a triangle based
* on IQuadEdge edges.
@@ -90,10 +93,9 @@ public IQuadEdge getEdgeC() {

/**
* Gets vertex A of the triangle. The method names used in this class follow
* the conventions of trigonometry. Vertices are labeled so that vertex A
* is opposite edge a, vertex B is opposite edge b, etc. This approach
* is slightly different than that used in other parts of the
* Tinfour API.
* the conventions of trigonometry. Vertices are labeled so that vertex A is
* opposite edge a, vertex B is opposite edge b, etc. This approach is
* slightly different than that used in other parts of the Tinfour API.
*
* @return a valid vertex
*/
@@ -103,10 +105,9 @@ public Vertex getVertexA() {

/**
* Gets vertex B of the triangle. The method names used in this class follow
* the conventions of trigonometry. Vertices are labeled so that vertex A
* is opposite edge a, vertex B is opposite edge b, etc. This approach
* is slightly different than that used in other parts of the
* Tinfour API.
* the conventions of trigonometry. Vertices are labeled so that vertex A is
* opposite edge a, vertex B is opposite edge b, etc. This approach is
* slightly different than that used in other parts of the Tinfour API.
*
* @return a valid vertex
*/
@@ -116,22 +117,20 @@ public Vertex getVertexB() {

/**
* Gets vertex A of the triangle. The method names used in this class follow
* the conventions of trigonometry. Vertices are labeled so that vertex A
* is opposite edge a, vertex B is opposite edge b, etc. This approach
* is slightly different than that used in other parts of the
* Tinfour API.
* the conventions of trigonometry. Vertices are labeled so that vertex A is
* opposite edge a, vertex B is opposite edge b, etc. This approach is
* slightly different than that used in other parts of the Tinfour API.
*
* @return a valid vertex
*/
public Vertex getVertexC() {
return edgeB.getA();
}


/**
* Gets the area of the triangle. This value is positive if the triangle is
* given in counterclockwise order and negative if it is given in clockwise
* order. A value of zero indicates a degenerate triangle.
* order. A value of zero indicates a degenerate triangle.
*
* @return a valid floating point number.
*/
@@ -146,48 +145,53 @@ public double getArea() {
/**
* Gets the polygon-based constraint that contains this triangle, if any.
* <p>
* <strong>Under Construction</strong>This method is not yet complete.
* Because the Tinfour implementation does not yet record which side
* of an edge an region-based constraint lies on, there are cases involving
* constraint borders that will not be accurately detected.
* It can only reliably report membership when a triangle has at least
* one edge that is entirely inside a constraint area
* <strong>Under Construction</strong>This method is not yet complete. Because
* the Tinfour implementation does not yet record which side of an edge an
* region-based constraint lies on, there are cases involving constraint
* borders that will not be accurately detected. It can only reliably report
* membership when a triangle has at least one edge that is entirely inside a
* constraint area
*
* @return if the triangle is enclosed by a constraint, a valid instance;
* otherwise, a null.
*/
public IConstraint getContainingRegion() {
// The triangle is an interior triangle if any one edge is
// unambiguously in the interior of the constraint or if
// all three edges are borders of the constraint

IQuadEdge a = getEdgeA();
IQuadEdge b = getEdgeB();
IQuadEdge c = getEdgeC();

if (a.isConstrainedRegionInterior()) {
int index = a.getConstraintIndex();
return tin.getConstraint(index);
}
if (b.isConstrainedRegionInterior()) {
int index = b.getConstraintIndex();
return tin.getConstraint(index);
}
if (c.isConstrainedRegionInterior()) {
int index = c.getConstraintIndex();
return tin.getConstraint(index);
}
// asspciated with a region
return tin.getRegionConstraint(edgeA);
}

// Check for the special case where all three edges
// are borders. We only need to look at one of them,
// since the values should be consistent for each.
IConstraint aCon = tin.getBorderConstraint(a);
if(aCon!=null){
return aCon;
/**
* Gets a Java Path2D based on the geometry of the triangle mapped through an
* optional affine transform.
*
* @param transform a valid transform, or the null to use the identity
* transform.
* @return a valid instance of a Java Path2D
*/
public Path2D getPath2D(AffineTransform transform) {
AffineTransform af = transform;
if (transform == null) {
af = new AffineTransform();
}


return null;
double[] c = new double[12];

Vertex A = edgeA.getA();
Vertex B = edgeB.getA();
Vertex C = edgeC.getA();
c[0] = A.getX();
c[1] = A.getY();
c[2] = B.getX();
c[3] = B.getY();
c[4] = C.getX();
c[5] = C.getY();
af.transform(c, 0, c, 6, 3);

Path2D path = new Path2D.Double();
path.moveTo(c[6], c[7]);
path.lineTo(c[8], c[9]);
path.lineTo(c[10], c[11]);
path.closePath();
return path;
}

}

0 comments on commit 1a90709

Please sign in to comment.
You can’t perform that action at this time.