Ejemplo n.º 1
0
void locateNovelFeatures(ImageList* novelImages, GraphDiscription graphTemplate, GraphDiscription bunchGraph, JetMasks masks, char* imageDir, char* outputDir, JetDisplacementEstimator dispEst){
    ImageList *subject, *replicate;
    int i;

    for(subject = novelImages; subject != NULL; subject = subject->next_subject){
        for(replicate = subject; replicate != NULL; replicate = replicate->next_replicate){
            Image novel = readRawImage(makePath(imageDir,replicate->filename));
            int *verts = (int*)malloc(sizeof(int)*bunchGraph->numVert);
            printf("Fitting graph for image: %s |", replicate->filename); fflush(stdout);
            for(i = 0; i < bunchGraph->numVert; i++){
                printf("#"); fflush(stdout);
                guessVertexLocation(i, i, graphTemplate, bunchGraph);

                graphTemplate->verts[i].x = graphTemplate->verts[i].x;
                graphTemplate->verts[i].y = graphTemplate->verts[i].y;

                LocatePoint( &(graphTemplate->verts[i].x),  &(graphTemplate->verts[i].y), bunchGraph->bunch[i], novel, masks, dispEst);
                verts[i] = i;
            }
            printf("|\n"); fflush(stdout);

            permuteArray(verts, bunchGraph->numVert);
            freeImage(novel);
            saveGraphDiscription(makePath(outputDir,replicate->filename),graphTemplate);
        }
    }
}
Ejemplo n.º 2
0
CSceneObject* COctree::TraceRay(const CRay& Ray, CVector3& NearestPoint, float& NearestDistance)
{
    // Get the ray origin and direction
    Origin    = Ray.Origin;
    Direction = Ray.Direction;

    // We start at the root node
    COctreeNode* pCurrentNode = m_pRootNode;

    // Locate the starting point leaf node
    while (!pCurrentNode->IsLeaf())
    {
        pCurrentNode = LocatePoint(Child nodes...);
    }

    // Initialize the nearest object and nearest distance
    CSceneObject* pNearestObject = NULL;
    NearestDistance = infinity;

    // Declare variables for intersection testing
    float Distance;
    CVector3 Point;

    // Begin testing for intersections
    do
    {
        // Test all objects of this node for intersection
        for (all objects in this leaf node)
        {
            if (Objectintersected && Distance < NearestDistance)
            {
                pNearestObject   = pCurrentObject;   
                NearestDistance  = Distance;
                NearestPoint     = Point;
            }
        }

        // If we have an intersection, return it
        if (pNearestObject)
            return pNearestObject;

        // If the ray intersects the top plane
        if (Direction.Y > 0)
        {
            // Compute the intersection point
            Point = ...;

            // If the intersection is within our boundaries
            if (We intersect the top plane within our boundaries)
            {
                pCurrentNode = pCurrentNode->TopNeighbor;

                while (!pCurrentNode.IsLeaf())
                {
                    if (Point.X > pCurrentNode->m_Center.Z)
                    {
                        if (Point.Z > pCurrentNode->m_Center.Z)
                        {
                            pCurrentNode = pCurrentNode->m_pNeighbor...
                            break;
                        }
                        else
                        {
                            pCurrentNode = pCurrentNode->m_pNeighbor...
                            break;
                        }
                    }
                    else
                    {
                        ... Same as above 
                    }
                }