[vtkusers] extreme points

Andrej Gluhov realandron at gmail.com
Wed Feb 2 06:56:15 EST 2011


How to obtain the extreme points of open loop? Is there an alternative to my
version? It is crash with Exception :(
private void FindDifferentSidePoints(vtkPolyData polyData, double[] bounds,
out double[] firstPoint, out double[] lastPoint, out int firstPointID, out
int lastPointID)
        {
            firstPoint = null;
            lastPoint = null;

            firstPointID = 0;
            lastPointID = 0;

            int numberOfCells = polyData.GetNumberOfCells();
            for (int j = 0; j < numberOfCells; j++)
            {
                if (firstPoint == null)
                {
                    double[] point =
polyData.GetCell(j).GetPoints().GetPoint(0);
                    if (point[1] == bounds[2] || point[1] == bounds[3])
                    {
                        firstPoint = point;
                        firstPointID = polyData.GetCell(j).GetPointId(0);
                    }
                    if (firstPoint == null)
                    {
                        point = polyData.GetCell(j).GetPoints().GetPoint(1);
                        if (point[1] == bounds[2] || point[1] == bounds[3])
                        {
                            firstPoint = point;
                            firstPointID =
polyData.GetCell(j).GetPointId(1);
                        }
                    }
                }
                if (firstPoint != null && lastPoint == null)
                {
                    double[] point =
polyData.GetCell(j).GetPoints().GetPoint(0);
                    if (point[1] == bounds[3] && Math.Abs(point[0] -
firstPoint[0]) > 5 && point[1] != firstPoint[1] ||
                        point[1] == bounds[2] && (Math.Abs(point[0] -
firstPoint[0]) > 5) && point[1] != firstPoint[1])
                    {
                        lastPoint = point;
                        lastPointID = polyData.GetCell(j).GetPointId(0);
                    }
                    if (lastPoint == null)
                    {
                        point = polyData.GetCell(j).GetPoints().GetPoint(1);
                        if (point[1] == bounds[3] && Math.Abs(point[0] -
firstPoint[0]) > 5 && point[1] != firstPoint[1] ||
                            point[1] == bounds[2] && (Math.Abs(point[0] -
firstPoint[0]) > 5) && point[1] != firstPoint[1])
                        {
                            lastPoint = point;
                            lastPointID = polyData.GetCell(j).GetPointId(1);
                        }
                    }
                }
            }
        }

-- 
С Уважением,
Андрей.
Best regards, Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110202/3c6c3f6e/attachment.htm>


More information about the vtkusers mailing list