예제 #1
0
bool Box<DATA>::encloses
  (
  const Box<DATA>& ar_Box
  )
  {
  return (encloses(ar_Box.upperBound) && encloses(ar_Box.lowerBound));
  }
예제 #2
0
void OctTree::handleObjectPlacement(OctTree::ObjType * obj) {
    int whereIsObj;
    BoundingBox objbox = boundingBox.boundingBoxForCollideable(obj);
    /// Remove object and try the parent.
    if (parent != NULL
     && boundingBox.numCornersContained(objbox) != kNumNodes) {
        remove(obj);
        parent->handleObjectPlacement(obj);
    }
    /// We need to rebase and then add the object.
    else {
     
        /// First, if the do not enclode the object, then
        while (boundingBox.numCornersContained(objbox) != kNumNodes) {
            whereIsObj = whichChildForPoint(obj->getPosition());
            rebase((~whereIsObj) & (kNumNodes - 1));
        }
        
        UTIL_ASSERT(encloses(obj->getPosition()));
        UTIL_ASSERT(boundingBox.numCornersContained(objbox) == kNumNodes);
        BoundingBox childbox = boundingBoxForChild(whichChildForPoint(
         obj->getPosition()));
        
        /// We pass it onto the child
        if (!objectLiesOnChildBoundaries(obj) && (activeChildren != 0
         || numDirectlyHeldObjects() > getMaxLeafObjects())
         && (GUtils::norm(getBoundingBox().getDimensions()) / 2.0) > kMinLeafDim
         && childbox.numCornersContained(objbox) == kNumNodes) {
            remove(obj);
            
            whereIsObj = whichChildForPoint(obj->getPosition());
            UTIL_ASSERT(0 <= whereIsObj && whereIsObj < kNumNodes);
            if (children[whereIsObj] == NULL) {
                children[whereIsObj] = createChild(whereIsObj);
            }
            
            //setChildActive(whereIsObj, true);
            children[whereIsObj]->insert(obj);
        }
        /// We keep it to ourselves
        else {
            UTIL_ASSERT(encloses(obj->getPosition()));
            UTIL_ASSERT(boundingBox.numCornersContained(objbox) == kNumNodes);
            add(obj);
            updateActiveStates(this);
            obj->setPositionChanged(false);
        }
    }
     
}
예제 #3
0
	bool encloses(BasicVector<T, 2> v) const {
		return encloses(v.x, v.y);
	}
예제 #4
0
bool OctTree::encloses(OctTree::ObjType * obj) {
    Vec pos = obj->getPosition();
    return obj != NULL && encloses(pos);
}
예제 #5
0
static void removeEnclosedDoubleSofts(struct rbTree *vertexTree, struct rbTree *edgeTree, 
	int maxBleedOver, double singleExonMaxOverlap)
/* Move double-softs that overlap spliced things to a very great extent into
 * the spliced things. Also remove tiny double-softs (no more than 2*maxBleedOver). */
{
/* Traverse graph and build up range tree covering spliced exons.  For each 
 * range of overlapping exons, assemble a singly-linked list of all exons in 
 * the range */
struct rbTree *rangeTree = rangeTreeNew(0);
struct slRef *edgeRef, *edgeRefList = rbTreeItems(edgeTree);
int removedCount = 0;
for (edgeRef = edgeRefList; edgeRef != NULL; edgeRef = edgeRef->next)
    {
    struct edge *edge = edgeRef->val;
    struct vertex *start = edge->start;
    struct vertex *end = edge->end;
    if (start->type == ggHardStart || end->type == ggHardEnd)
	{
	rangeTreeAddValList(rangeTree, start->position, end->position, edge);
	}
    }

/* Traverse graph yet one more time looking for doubly-soft exons
 * that are overlapping the spliced exons. */
for (edgeRef = edgeRefList; edgeRef != NULL; edgeRef = edgeRef->next)
    {
    struct edge *edge = edgeRef->val;
    struct vertex *start = edge->start;
    struct vertex *end = edge->end;
    if (start->type == ggSoftStart && end->type == ggSoftEnd)
        {
	int s = start->position;
	int e = end->position;
	int size = e - s;
	if (size <= maxBleedOver+maxBleedOver)
	     {
	     /* Tiny case, just remove edge and forget it. */
	     verbose(3, "Removing tiny double-soft edge from %d to %d\n", s, e);
	     rbTreeRemove(edgeTree, edge);
	     ++removedCount;
	     }
	else
	     {
	     /* Normal case, look for exon list that encloses us, and
	      * if any single exon in that list encloses us, merge into it. */
	     int splicedOverlap = rangeTreeOverlapSize(rangeTree, s, e);
	     if (splicedOverlap > 0 && splicedOverlap > singleExonMaxOverlap*size)
	         {
		 if (!trustedEdge(edge))
		     {
		     /* Once we find a range that overlaps the doubly-soft edge, find 
		      * (half-hard or better) edge from that range that encloses the 
		      * doubly soft edge. */
		     struct range *r = rangeTreeMaxOverlapping(rangeTree, s, e);
		     struct edge *nextEdge, *edgeList = r->val;
		     struct edge *enclosingEdge = NULL;
		     for (nextEdge = edgeList; edgeList != NULL; edgeList = edgeList->next)
			 {
			 if (encloses(nextEdge, edge))
			     {
			     enclosingEdge = nextEdge;
			     }
			 }
		     if (enclosingEdge != NULL) 
			 {
			 enclosingEdge->evList = slCat(enclosingEdge->evList, edge->evList);
			 edge->evList = NULL;
			 verbose(3, "Removing doubly-soft edge %d-%d, reassigning to %d-%d\n",
				 s, e, enclosingEdge->start->position, 
				 enclosingEdge->end->position);
			 rbTreeRemove(edgeTree, edge);
			 ++removedCount;
			 }
		     }
		 }
	     }
	}
    }

/* Clean up and go home. */
if (removedCount > 0)
    removeUnusedVertices(vertexTree, edgeTree);
for (edgeRef = edgeRefList; edgeRef != NULL; edgeRef = edgeRef->next)
    {
    struct edge *nextEdge, *edge = edgeRef->val;
    while (edge != NULL) 
	{
	nextEdge = edge->next;
	edge->next = NULL;
	edge = nextEdge;
	}
    }
slFreeList(&edgeRefList);
rbTreeFree(&rangeTree);
}