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();
}
}
}
}
}
}
}
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;
}
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;
}
Aggregations