Search in sources :

Example 1 with TetID

use of maspack.geometry.DistanceGrid.TetID in project artisynth_core by artisynth.

the class DistanceGridSurfCalc method createConnectivity.

private void createConnectivity() {
    myFaceTets = new HashMap<TetFace, TetDesc>();
    ArrayList<HashSet<TetDesc>> nodeTets = new ArrayList<HashSet<TetDesc>>();
    for (int i = 0; i < 8; i++) {
        nodeTets.add(new HashSet<TetDesc>());
    }
    HashMap<TetEdge, HashSet<TetDesc>> edgeTets = new HashMap<TetEdge, HashSet<TetDesc>>();
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            for (int k = -1; k <= 1; k++) {
                for (TetID tetId : TetID.values()) {
                    TetDesc tdesc = new TetDesc(new Vector3i(i, j, k), tetId);
                    Vector3i[] verts = tdesc.getVertices();
                    for (int vi = 0; vi < verts.length; vi++) {
                        int refVtx = findRefVertex(verts[vi]);
                        if (refVtx != -1) {
                            nodeTets.get(refVtx).add(tdesc);
                        }
                    }
                    maybeAddFace(myFaceTets, verts[0], verts[1], verts[2], tdesc);
                    maybeAddFace(myFaceTets, verts[0], verts[2], verts[3], tdesc);
                    maybeAddFace(myFaceTets, verts[2], verts[1], verts[3], tdesc);
                    maybeAddFace(myFaceTets, verts[1], verts[0], verts[3], tdesc);
                    maybeAddEdge(edgeTets, verts[0], verts[1], tdesc);
                    maybeAddEdge(edgeTets, verts[1], verts[2], tdesc);
                    maybeAddEdge(edgeTets, verts[2], verts[0], tdesc);
                    maybeAddEdge(edgeTets, verts[0], verts[3], tdesc);
                    maybeAddEdge(edgeTets, verts[1], verts[3], tdesc);
                    maybeAddEdge(edgeTets, verts[2], verts[3], tdesc);
                }
            }
        }
    }
    myNodeTets = new ArrayList<TetDesc[]>();
    for (int i = 0; i < nodeTets.size(); i++) {
        myNodeTets.add(nodeTets.get(i).toArray(new TetDesc[0]));
    }
    myEdgeTets = new HashMap<TetEdge, TetDesc[]>();
    for (TetEdge edge : edgeTets.keySet()) {
        myEdgeTets.put(edge, edgeTets.get(edge).toArray(new TetDesc[0]));
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TetID(maspack.geometry.DistanceGrid.TetID) Vector3i(maspack.matrix.Vector3i) TetDesc(maspack.geometry.DistanceGrid.TetDesc) HashSet(java.util.HashSet)

Example 2 with TetID

use of maspack.geometry.DistanceGrid.TetID in project artisynth_core by artisynth.

the class DistanceGridSurfCalc method createTetBarycentricMats.

private void createTetBarycentricMats() {
    Matrix3d[] mats = new Matrix3d[6];
    Vector3d v = new Vector3d();
    for (TetID id : TetID.values()) {
        Matrix3d M = new Matrix3d();
        int[] nodeNums = id.getNodes();
        // base node is known to be at zero
        for (int j = 0; j < 3; j++) {
            v.set(DistanceGrid.myBaseQuadCellXyzi[nodeNums[j + 1]]);
            v.scale(0.5);
            M.setColumn(j, v);
        }
        M.invert();
        mats[id.intValue()] = M;
    }
    myTetBarycentricMats = mats;
}
Also used : TetID(maspack.geometry.DistanceGrid.TetID) Matrix3d(maspack.matrix.Matrix3d) Vector3d(maspack.matrix.Vector3d)

Aggregations

TetID (maspack.geometry.DistanceGrid.TetID)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TetDesc (maspack.geometry.DistanceGrid.TetDesc)1 Matrix3d (maspack.matrix.Matrix3d)1 Vector3d (maspack.matrix.Vector3d)1 Vector3i (maspack.matrix.Vector3i)1