def findRightNormal(newNode, centroidNormals) :
    minDist = sys.float_info.max
    rightNormal = Vector_3()
    for newCentroid in centroidNormals : 
        newDist = squared_distance(newNode, newCentroid[0])
        if newDist < minDist : 
            minDist = newDist
            rightNormal = newCentroid[1]
    return rightNormal
def lineFitFunc(lineDirection, pointStd, pointTest) : 
    newLine = Line_3(pointStd, Vector_3(lineDirection[0], lineDirection[1], lineDirection[2]))
    return [squared_distance(x, newLine) for x in pointTest]
 planeNormal = findRightNormal(newNode[1], centroidNormals)
 sqLen = math.sqrt(planeNormal.squared_length())
 cosinXY = abs(planeNormal.z()) / sqLen
 cosinXZ = abs(planeNormal.y()) / sqLen
 cosinYZ = abs(planeNormal.x()) / sqLen
 if cosinXY == 0 and cosinXZ == 0 and cosinYZ == 0 : 
     areaMap[newNode[0]] = 0
     continue
 planeQuery = Plane_3(newNode[1], planeNormal)
 newIntersections = [newObj.get_Point_3() for newObj in [intersection(planeQuery, newSegment) for newSegment in SurfaceInfo] if (not newObj.empty()) and newObj.is_Point_3()]
 if len(newIntersections) == 0 : 
     print 'big opps!'
 allCrossSectionPoints = []
 maxDist = newNode[2] * 1.2
 for newPt in newIntersections : 
     if squared_distance(newPt, newNode[1]) > maxDist : continue
     if cosinXY != 0 : 
         allCrossSectionPoints.append(Point_2(newPt.x(), newPt.y()))
     elif cosinXZ != 0 : 
         allCrossSectionPoints.append(Point_2(newPt.x(), newPt.z()))
     else : 
         allCrossSectionPoints.append(Point_2(newPt.y(), newPt.z()))
 convexPoints = []
 CGAL_Convex_hull_2.convex_hull_2(allCrossSectionPoints, convexPoints)
 AAA = Polygon_2(convexPoints)
 AAA.edges_circulator
 convexArea = abs(Polygon_2(convexPoints).area())
 if cosinXY != 0 : convexArea /= cosinXY
 elif cosinXZ != 0 : convexArea /= cosinXZ
 else : convexArea /= cosinYZ
 areaMap[newNode[0]] = int(math.sqrt(convexArea / math.pi) * pixelWidth + 0.5)