[
https://issues.apache.org/jira/browse/MATH-780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13258362#comment-13258362
]
Andrew Willis edited comment on MATH-780 at 4/20/12 4:42 PM:
-------------------------------------------------------------
The code in BSPMesh2.java produces the following error when I run it. If you
comment in the line that re-assigns the coordinate data to be cubeCoords1, then
the code works fine. The only difference in the two data sets is that one
coordinate has changed by a small amount.
Exception in thread "main" java.lang.ClassCastException:
org.apache.commons.math3.geometry.partitioning.BoundaryAttribute cannot be cast
to java.lang.Boolean
at
org.apache.commons.math3.geometry.euclidean.twod_exact.PolygonsSet.computeGeometricalProperties(PolygonsSet.java:135)
at
org.apache.commons.math3.geometry.partitioning.AbstractRegion.getSize(AbstractRegion.java:380)
at
org.apache.commons.math3.geometry.euclidean.threed_exact.PolyhedronsSet$FacetsContributionVisitor.addContribution(PolyhedronsSet.java:171)
at
org.apache.commons.math3.geometry.euclidean.threed_exact.PolyhedronsSet$FacetsContributionVisitor.visitInternalNode(PolyhedronsSet.java:153)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:262)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:261)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:261)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:263)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:261)
at
org.apache.commons.math3.geometry.euclidean.threed_exact.PolyhedronsSet.computeGeometricalProperties(PolyhedronsSet.java:118)
at
org.apache.commons.math3.geometry.partitioning.AbstractRegion.getSize(AbstractRegion.java:380)
at datastructures.j3d.bsptree.BSPMesh.<init>(BSPMesh.java:130)
at datastructures.j3d.bsptree.BSPMesh2.main(BSPMesh2.java:206)
was (Author: arwillis):
This code produces the following error:
Exception in thread "main" java.lang.ClassCastException:
org.apache.commons.math3.geometry.partitioning.BoundaryAttribute cannot be cast
to java.lang.Boolean
at
org.apache.commons.math3.geometry.euclidean.twod_exact.PolygonsSet.computeGeometricalProperties(PolygonsSet.java:135)
at
org.apache.commons.math3.geometry.partitioning.AbstractRegion.getSize(AbstractRegion.java:380)
at
org.apache.commons.math3.geometry.euclidean.threed_exact.PolyhedronsSet$FacetsContributionVisitor.addContribution(PolyhedronsSet.java:171)
at
org.apache.commons.math3.geometry.euclidean.threed_exact.PolyhedronsSet$FacetsContributionVisitor.visitInternalNode(PolyhedronsSet.java:153)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:262)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:261)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:261)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:263)
at
org.apache.commons.math3.geometry.partitioning.BSPTree.visit(BSPTree.java:261)
at
org.apache.commons.math3.geometry.euclidean.threed_exact.PolyhedronsSet.computeGeometricalProperties(PolyhedronsSet.java:118)
at
org.apache.commons.math3.geometry.partitioning.AbstractRegion.getSize(AbstractRegion.java:380)
at datastructures.j3d.bsptree.BSPMesh.<init>(BSPMesh.java:130)
at datastructures.j3d.bsptree.BSPMesh2.main(BSPMesh2.java:206)
> BSPTree class and recovery of a Euclidean 3D BRep
> -------------------------------------------------
>
> Key: MATH-780
> URL: https://issues.apache.org/jira/browse/MATH-780
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.0
> Environment: Linux
> Reporter: Andrew Willis
> Labels: BSPTree, euclidean.threed
> Attachments: BSPMesh2.java
>
>
> New to the work here. Thanks for your efforts on this code.
> I create a BSPTree from a BoundaryRep (Brep) my test Brep is a tetrahedron as
> represented by a float array containing 4 3D points (x,y,z) order and an
> array of indices (4 triplets for the 4 faces of the tet). I construct a
> BSPMesh() as shown in the code below. I can construct the PolyhedronsSet()
> however, when I interrogate the shape (with getSize() or getBoundarySize() I
> get infinity back as a result). When I try to get back the BRep (by
> traversing the BSPTree resulting from PolyhedronsSet.getTree(true) and
> getting the PolygonsSet() associated with each 3D SubPlane, I get a null
> vertex back and strange values.
> Any ideas?
> public class BSPMesh {
> public BSPMesh(float[] coords, int[] indices) {
> double size;
> setBoundingBox(coords);
> ArrayList<SubHyperplane<Euclidean3D>> subHyperplaneList = new
> ArrayList();
> for (int idx = 0; idx < indices.length; idx += 3) {
> int idxA = indices[idx] * 3;
> int idxB = indices[idx + 1] * 3;
> int idxC = indices[idx + 2] * 3;
> Vector3D v_1 = new Vector3D(coords[idxA], coords[idxA + 1],
> coords[idxA + 2]);
> Vector3D v_2 = new Vector3D(coords[idxB], coords[idxB + 1],
> coords[idxB + 2]);
> Vector3D v_3 = new Vector3D(coords[idxC], coords[idxC + 1],
> coords[idxC + 2]);
> Vector3D[] vertices = {v_1, v_2, v_3};
> Plane polyPlane = new Plane(v_1, v_2, v_3);
> ArrayList<SubHyperplane<Euclidean2D>> lines = new ArrayList();
> Vector2D[] projPts = new Vector2D[vertices.length];
> for (int ptIdx=0; ptIdx < projPts.length; ptIdx++) {
> projPts[ptIdx] = polyPlane.toSubSpace(vertices[ptIdx]);
> }
> SubLine lineInPlane = null;
> for (int ptIdx=0; ptIdx < projPts.length; ptIdx++) {
> lineInPlane = new SubLine(projPts[ptIdx],
> projPts[(ptIdx+1)%projPts.length]);
> lines.add(lineInPlane);
> }
> Region<Euclidean2D> polyRegion = new PolygonsSet(lines);
> SubPlane polygon = new SubPlane(polyPlane, polyRegion);
> size = polyRegion.getSize(); // correct size here
> Vector3D[][] verticesTest = getVertices(polygon); // correctly
> retrieves the BRep for each face
> subHyperplaneList.add(polygon);
> }
> PolyhedronsSet polyhedronsSet = new PolyhedronsSet(subHyperplaneList);
> BSPTree<Euclidean3D> myTree = polyhedronsSet.getTree(true);
> size = polyhedronsSet.getSize(); // strange Inf returned
> size = polyhedronsSet2.getBoundarySize(); // strange Inf
> returned
> // Member variable and other code for extracting the BRep not
> included here... can include if desired
> //tree = myTree;
> //Vector3D[][] vertices = getVertices((SubPlane) ((BoundaryAttribute)
> tree.getAttribute()).getPlusOutside()); // strange values returned here
> System.out.println("END");
> }
> public static void main(String[] args) {
> float[] tetCoords = {1, 0, 0,
> 2, 0, 0,
> 1, 1, 0,
> 1, 0, 1};
> int[] tetIndices = {0, 1, 2,
> 0, 1, 3,
> 0, 2, 3,
> 2, 1, 3};
> BSPMesh blah = new BSPMesh(tetCoords, tetIndices);
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira