Hello Lindsey,

The code that performs unprojection of a cell is listed below.   
Closest tile vertices are the three nodes that define a triangle.   
Closest tile areas are used to define a barycentric coordinate 
(http://en.wikipedia.org/wiki/Barycentric_coordinates_(mathematics) 
) within the triangle.  As the triangle changes in shape, the  
barycentric coordinate maintains the same position relative to the  
nodes that form the triangle.

"cdistance" was used in the past, but it was not placing the cell in  
the correct location.  It was replaced by "signedDistanceAboveSurface"  
which is the distance, parallel to the direction of the tile's normal  
vector, of the cell from the barycentric coordinate within the  
triangle.  "signedDistanceAboveSurface" is positive when the cell is  
above the surface and negative when then the cell is under the surface.

If you just want to know the distance of the cell from the surface,  
look at "signedDistanceAboveSurface".

John



/**
  * Unproject an inside triangle projection.
  */
bool
CellProjection::unprojectInsideTriangle(const CoordinateFile& cf,
                                         const TopologyFile& tf,
                                         const bool  
pasteOntoSurfaceFlag,
                                         float xyzOut[3]) const
{
    const float* v1 = cf.getCoordinate(closestTileVertices[0]);
    const float* v2 = cf.getCoordinate(closestTileVertices[1]);
    const float* v3 = cf.getCoordinate(closestTileVertices[2]);

    const TopologyHelper* th = tf.getTopologyHelper(false, true, false);
    if ((th->getNodeHasNeighbors(closestTileVertices[0]) == false) ||
        (th->getNodeHasNeighbors(closestTileVertices[1]) == false) ||
        (th->getNodeHasNeighbors(closestTileVertices[2]) == false)) {
       return false;
    }

    float t1[3], t2[3], t3[3];
    for (int i = 0; i < 3; i++) {
       t1[i] = closestTileAreas[0] * v3[i];
       t2[i] = closestTileAreas[1] * v1[i];
       t3[i] = closestTileAreas[2] * v2[i];
    }

    const float area = closestTileAreas[0] + closestTileAreas[1]
                     + closestTileAreas[2];

    float projection[3] = { 0.0, 0.0, 0.0 };
    if (area != 0) {
       for (int i = 0; i < 3; i++) {
          projection[i] = (t1[i] + t2[i] + t3[i]) / area;
       }
    }
    //
    // Note: that does caret4 style clockwise orientation
    //
    float tileNormal[3];
    MathUtilities::computeNormal((float*)v3, (float*)v2, (float*)v1,  
tileNormal);

    for (int j = 0; j < 3; j++) {
       if (pasteOntoSurfaceFlag) {
          xyzOut[j] = projection[j];
       }
       else if (signedDistanceAboveSurface != 0.0) {
          xyzOut[j] = projection[j] + tileNormal[j] *  
signedDistanceAboveSurface;
       }
       else {
          xyzOut[j] = projection[j] + cdistance[j];
       }
    }

    return true;
}



On Sep 29, 2009, at 7:50 PM, Lindsey Leigland wrote:

> Hello,
>
> I am trying to determine the distance between a contour cell and the  
> fiducial surface I created from a number of contours.  (I have  
> marked an area within one of my 2D contours and am trying to  
> determine the area’s coordinates in terms of the 3D surface and/or  
> the distance from the 3D surface).
>
> In the cell projection file, a field called “cdistance” is followed  
> by 3 numbers, but I wasn’t sure what these numbers represent, or if  
> they could help me determine the distance from the surface to my  
> contour cell.  I also wasn’t sure what the numbers were following  
> the “closest tile vertices” or “closest tile areas” fields.
>
> If anyone had any information that could help, I would greatly  
> appreciate it.
>
> Thank you,
> Lindsey
>
> Lindsey Leigland
> Departments of Behavioral Neuroscience and the Advanced Imaging  
> Research Center
> Oregon Health & Science University L452
> 3181 SW Sam Jackson Park Road
> Portland, OR 97220
> Phone: 503-418-8835
> Fax: 503-418-1543
>
> _______________________________________________
> caret-users mailing list
> caret-users@brainvis.wustl.edu
> http://brainvis.wustl.edu/mailman/listinfo/caret-users


_______________________________________________
caret-users mailing list
caret-users@brainvis.wustl.edu
http://brainvis.wustl.edu/mailman/listinfo/caret-users

Reply via email to