commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Willis (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-780) BSPTree class and recovery of a Euclidean 3D BRep
Date Fri, 20 Apr 2012 16:10:40 GMT

    [ https://issues.apache.org/jira/browse/MATH-780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13258342#comment-13258342
] 

Andrew Willis commented on MATH-780:
------------------------------------

Looks like I had an index flipped resulting in an improperly oriented face for the tetrahedron.
I did get the tetrahedron to work. However, I am now struggling with getting a cube to work
and I have verified the normals/orientations of the planes to be correct.
                
> 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
>
> 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

        

Mime
View raw message