Search in sources :

Example 11 with Boundable

use of maspack.geometry.Boundable in project artisynth_core by artisynth.

the class SurfaceMeshContourIxer method getAllMIPs.

/**
 * Return an unordered list of MeshIntersectionPoints representing all
 * edge/face collisions between the lists of BVs nodes0 and nodes1.
 *
 * New MeshIntersectionPoints are generated and appended to allMips.
 * All Faces are assumed to be triangular! Undetermined behaviour if not the case.
 *
 * @param allMips Initialized ArrayList of MeshIntersectionPoints
 * @param nodes0 first list of BVs from BVTree.intersectTree
 * @param nodes1 second list of BVs from BVTree.intersectTree (same length as nodes0)
 *
 * @throws DegeneratePairCaseException if a degenerate case is detected.
 *           Points of those faces are perturbed before this exception is re-thrown
 */
protected void getAllMIPs(ArrayList<IntersectionPoint> allMips, ArrayList<BVNode> nodes0, ArrayList<BVNode> nodes1) throws DegeneratePairCaseException {
    assert nodes0.size() == nodes1.size();
    for (int i = 0; i < nodes0.size(); i++) {
        BVNode n0 = nodes0.get(i);
        BVNode n1 = nodes1.get(i);
        for (Boundable b0 : n0.getElements()) {
            for (Boundable b1 : n1.getElements()) {
                if (b0 instanceof Face && b1 instanceof Face) {
                    Face f0 = (Face) b0;
                    Face f1 = (Face) b1;
                    int numFound = 0;
                    numFound += doFaceFaceCollision(allMips, f0, f1, true);
                    numFound += doFaceFaceCollision(allMips, f1, f0, false);
                    if (myHandleDegen) {
                        if (numFound != 0 && numFound != 2) {
                            perturbVertices(f0);
                            perturbVertices(f1);
                            // System.out.println("Found " + numFound + " ixps");
                            throw new DegeneratePairCaseException();
                        }
                    }
                }
            }
        }
    }
}
Also used : BVNode(maspack.geometry.BVNode) Boundable(maspack.geometry.Boundable) Face(maspack.geometry.Face) IntersectionPoint(maspack.collision.IntersectionPoint)

Example 12 with Boundable

use of maspack.geometry.Boundable in project artisynth_core by artisynth.

the class MFreeModel3d method updateBVHierarchies.

private void updateBVHierarchies() {
    if (myElementTree == null) {
        myElementTree = new AABBTree();
        Boundable[] elements = new Boundable[numElements()];
        for (int i = 0; i < elements.length; i++) {
            elements[i] = myElements.get(i);
        }
        myElementTree.build(elements, numElements());
    } else {
        myElementTree.update();
    }
    if (myNodeTree == null) {
        myNodeTree = new AABBTree();
        Boundable[] nodes = new Boundable[numNodes()];
        for (int i = 0; i < nodes.length; i++) {
            nodes[i] = (MFreeNode3d) myNodes.get(i);
        }
        myNodeTree.build(nodes, numNodes());
    } else {
        myNodeTree.update();
    }
    myBVTreeValid = true;
}
Also used : AABBTree(maspack.geometry.AABBTree) Boundable(maspack.geometry.Boundable) Point(artisynth.core.mechmodels.Point)

Example 13 with Boundable

use of maspack.geometry.Boundable in project artisynth_core by artisynth.

the class MFreeModel3d method findDependentNodesAtRest.

/**
 * Finds nodes containing the given point at rest
 * @param pnt point to find nodes for
 * @param out output list of nodes influencing region
 * @return number of nodes found
 */
public int findDependentNodesAtRest(Point3d pnt, List<FemNode3d> out) {
    AABBTree nodeTree = myRestNodeTree;
    if (nodeTree == null) {
        nodeTree = buildRestNodeTree(myNodes);
        myRestNodeTree = nodeTree;
    }
    ArrayList<BVNode> bvNodes = new ArrayList<BVNode>(16);
    nodeTree.intersectPoint(bvNodes, pnt);
    if (bvNodes.size() == 0) {
        return 0;
    }
    int count = 0;
    for (BVNode n : bvNodes) {
        Boundable[] elements = n.getElements();
        for (int i = 0; i < elements.length; i++) {
            RestNode rnode = (RestNode) elements[i];
            FemNode3d node = rnode.getNode();
            if (((MFreeNode3d) node).isInDomain(pnt, 0)) {
                out.add(node);
                ++count;
            }
        }
    }
    return count;
}
Also used : AABBTree(maspack.geometry.AABBTree) BVNode(maspack.geometry.BVNode) ArrayList(java.util.ArrayList) FemNode3d(artisynth.core.femmodels.FemNode3d) Boundable(maspack.geometry.Boundable) Point(artisynth.core.mechmodels.Point)

Aggregations

Boundable (maspack.geometry.Boundable)13 BVNode (maspack.geometry.BVNode)11 ArrayList (java.util.ArrayList)10 Point (artisynth.core.mechmodels.Point)6 BVTree (maspack.geometry.BVTree)5 AABBTree (maspack.geometry.AABBTree)4 Vector3d (maspack.matrix.Vector3d)4 Face (maspack.geometry.Face)3 Point3d (maspack.matrix.Point3d)3 FemNode3d (artisynth.core.femmodels.FemNode3d)2 IOException (java.io.IOException)2 LineSegment (maspack.geometry.LineSegment)2 Vertex3d (maspack.geometry.Vertex3d)2 Matrix3d (maspack.matrix.Matrix3d)2 Point2d (maspack.matrix.Point2d)2 SVDecomposition3d (maspack.matrix.SVDecomposition3d)2 SymmetricMatrix3d (maspack.matrix.SymmetricMatrix3d)2 FemElement3d (artisynth.core.femmodels.FemElement3d)1 IntersectionPoint (maspack.collision.IntersectionPoint)1 PolygonalMesh (maspack.geometry.PolygonalMesh)1