assert(minICount >=1); int[] vertexIndices = iInfo.getVertexIndices(); if (vertexIndices == null) { vertexIndices = new int[1]; iInfo.setVertexIndices(vertexIndices); } vertexIndices[0] = minICount - 1;
    boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo,  int flags, Point3d iPnt) {	double sdist[] = new double[1];	double minDist = Double.MAX_VALUE;	double x = 0, y = 0, z = 0;        int count = 0;        int minICount = 0;         	int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ?		 initialVertexIndex : initialCoordIndex);	Point3d pnt = new Point3d();    	switch (pickShape.getPickType()) {	case PickShape.PICKRAY:	    PickRay pickRay= (PickRay) pickShape;	    while (i < validVertexCount) {		getVertexData(i++, pnt);                count++;                if (intersectPntAndRay(pnt, pickRay.origin,				       pickRay.direction, sdist)) {		    if (flags == 0) {			return true;		    }		    if (sdist[0] < minDist) {			minDist = sdist[0];                        minICount = count;			x = pnt.x;			y = pnt.y;			z = pnt.z;		    }		}	    }	    break;	case PickShape.PICKSEGMENT:	    PickSegment pickSegment = (PickSegment) pickShape;	    Vector3d dir = 		new Vector3d(pickSegment.end.x - pickSegment.start.x, 			     pickSegment.end.y - pickSegment.start.y,			     pickSegment.end.z - pickSegment.start.z);	    while (i < validVertexCount) {		getVertexData(i++, pnt);                count++;		if (intersectPntAndRay(pnt, pickSegment.start, 					dir, sdist) &&		    (sdist[0] <= 1.0)) {		    if (flags == 0) {			return true;		    }		    if (sdist[0] < minDist) {			minDist = sdist[0];                        minICount = count;			x = pnt.x;			y = pnt.y;			z = pnt.z;		    }		}	    }	    break;	case PickShape.PICKBOUNDINGBOX:	case PickShape.PICKBOUNDINGSPHERE:	case PickShape.PICKBOUNDINGPOLYTOPE:	    Bounds bounds = ((PickBounds) pickShape).bounds;	    while (i < validVertexCount) {		getVertexData(i++, pnt);                count++;		if (bounds.intersect(pnt)) {		    if (flags == 0) {			return true;		    }		    sdist[0] = pickShape.distance(pnt);		    if (sdist[0] < minDist) {			minDist = sdist[0];                        minICount = count;			x = pnt.x;			y = pnt.y;			z = pnt.z;		    }		}	    }	    break;	case PickShape.PICKCYLINDER:	    PickCylinder pickCylinder= (PickCylinder) pickShape;	    while (i < validVertexCount) {		getVertexData(i++, pnt);                count++;		if (intersectCylinder(pnt, pickCylinder, sdist)) {		    if (flags == 0) {			return true;		    }		    if (sdist[0] < minDist) {			minDist = sdist[0];                        minICount = count;			x = pnt.x;			y = pnt.y;			z = pnt.z;		    }		}	    }	    break;	case PickShape.PICKCONE:	    PickCone pickCone= (PickCone) pickShape;	    while (i < validVertexCount) {		getVertexData(i++, pnt);                count++;		if (intersectCone(pnt, pickCone, sdist)) {		    if (flags == 0) {			return true;		    }		    if (sdist[0] < minDist) {			minDist = sdist[0];                        minICount = count;			x = pnt.x;			y = pnt.y;			z = pnt.z;		    }		}	    }	    break;	case PickShape.PICKPOINT:	    // Should not happen since API already check for this	    throw new IllegalArgumentException(J3dI18N.getString("PointArrayRetained0"));	default:	    throw new RuntimeException ("PickShape not supported for intersection"); 	} 	if (minDist < Double.MAX_VALUE) {            assert(minICount >=1);            int[] vertexIndices = iInfo.getVertexIndices();            if (vertexIndices == null) {                vertexIndices = new int[1];                iInfo.setVertexIndices(vertexIndices);            }            vertexIndices[0] = minICount - 1;	    iPnt.x = x;	    iPnt.y = y;	    iPnt.z = z;	    return true;	}	return false;    }