Exemple #1
0
 /*
  * placeNodeInQueue method will look at a node to see if its polygon is free and if so it will add the polygon being held
  *      to a AIPolygonQueue
  * Parameter:	(AIBinaryTreeNode)nodeToPlace is the node that needs its polygon check to see if its free
  * Return:	none
  */
 void placeNodeInQueue(AIBinaryTreeNode nodeToPlace, AIPolygonQueue tempQueue)
 {
     if (nodeToPlace.isFree() == true)
     {
         tempQueue.enqueue(nodeToPlace.getPolygon());
     }
 }
Exemple #2
0
    /* The method of tryGetTwoPolygons attempts to merge two polygons
     * Parameter: AIBinaryTreeNode polygonNode, ref int idCounter
     * Return: bool
     *							true if merge was successful, false otherwise
     */
    bool tryGetTwoPolygons(AIBinaryTreeNode polygonNode, ref int idCounter)
    {
        int[]  indexArrayToUse   = getAllFalseIndices();
        bool[] indexArrayOfBools = getABoolArrayOfFalses(indexArrayToUse.Length);
        int    indexToUse        = -1;

        indexArrayToUse   = getAllFalseIndices();
        indexArrayOfBools = getABoolArrayOfFalses(indexArrayToUse.Length);
        indexToUse        = -1;
        while (allIndicesAreTrue(indexArrayOfBools) == false)
        {
            indexToUse = -1;
            indexToUse = getIndexToUseForEdges(indexArrayOfBools);
            if (indexToUse == -1)
            {
                return(false);
            }
            for (int count = 0; count < polygonNode.getPolygon().getVerticesCount(); count++)
            {
                int secondPolygonStartingIndex = getTwoPolygons(polygonNode.getPolygon(), indexArrayToUse [indexToUse], count);                   // seperates the one polygon into two and returns the stating index of the second polygon
                if (secondPolygonStartingIndex == -1)
                {
                    indexArrayOfBools [indexToUse] = true;
                }
                else
                {
                    if (makeNewPolygons(polygonNode, secondPolygonStartingIndex, polygonNode.getPolygon().getVertices(), ref idCounter) == true)                      // makes two new polygons from the seperated one
                    {
                        usedEdgesForObject [indexArrayToUse [indexToUse]] = true;
                        indexCount++;
                        return(true);
                    }
                }
            }
            indexArrayOfBools [indexToUse] = true;
        }
        return(false);
    }