Esempio n. 1
0
/** Given a subtree nodes, insert all of its elements into tree. */
void InsertNodes(KDTREE *tree, KDNODE *nodes) {
  if (nodes == NULL)
    return;

  KDStore(tree, nodes->Key, nodes->Data);
  InsertNodes(tree, nodes->Left);
  InsertNodes(tree, nodes->Right);
}
Esempio n. 2
0
void
inDOMView::ExpandNode(PRInt32 aRow)
{
  inDOMViewNode* node = nsnull;
  RowToNode(aRow, &node);

  nsCOMArray<nsIDOMNode> kids;
  GetChildNodesFor(node ? node->node : mRootNode,
                   kids);
  PRInt32 kidCount = kids.Count();

  nsTArray<inDOMViewNode*> list(kidCount);

  inDOMViewNode* newNode = nsnull;
  inDOMViewNode* prevNode = nsnull;

  for (PRInt32 i = 0; i < kidCount; ++i) {
    newNode = CreateNode(kids[i], node);
    list.AppendElement(newNode);

    if (prevNode)
      prevNode->next = newNode;
    newNode->previous = prevNode;
    prevNode = newNode;
  }

  InsertNodes(list, aRow+1);

  if (node)
    node->isOpen = PR_TRUE;
}
Esempio n. 3
0
/**
 * This routine deletes a node from Tree.  The node to be	
 * deleted is specified by the Key for the node and the Data	
 * contents of the node.  These two pointers must be identical	
 * to the pointers that were used for the node when it was	
 * originally stored in the tree.  A node will be deleted from	
 * the tree only if its key and data pointers are identical	
 * to Key and Data respectively.  The tree is re-formed by removing
 * the affected subtree and inserting all elements but the root.
 *
 * @param Tree K-D tree to delete node from
 * @param Key key of node to be deleted
 * @param Data data contents of node to be deleted
 *
 * @note Exceptions: none
 *
 * @note History:  3/13/89, DSJ, Created.
 *                7/13/89, DSJ, Specify node indirectly by key and data.
 */
void
KDDelete (KDTREE * Tree, FLOAT32 Key[], void *Data) {
  int Level;
  KDNODE *Current;
  KDNODE *Father;

  /* initialize search at root of tree */
  Father = &(Tree->Root);
  Current = Father->Left;
  Level = NextLevel(Tree, -1);

  /* search tree for node to be deleted */
  while ((Current != NULL) && (!NodeFound (Current, Key, Data))) {
    Father = Current;
    if (Key[Level] < Current->BranchPoint)
      Current = Current->Left;
    else
      Current = Current->Right;

    Level = NextLevel(Tree, Level);
  }

  if (Current != NULL) {         /* if node to be deleted was found */
    if (Current == Father->Left) {
      Father->Left = NULL;
      Father->LeftBranch = Tree->KeyDesc[Level].Min;
    } else {
      Father->Right = NULL;
      Father->RightBranch = Tree->KeyDesc[Level].Max;
    }

    InsertNodes(Tree, Current->Left);
    InsertNodes(Tree, Current->Right);
    FreeSubTree(Current);
  }
}                                /* KDDelete */
Esempio n. 4
0
int main(int argc, char *argv[])

{
	int ntotal,external;
	NodeList hull, intern, boundary, given;

	HNN=MakeHashTable();
	HEL=MakeHashTable();
	HLI=MakeHashTable();
	NEL=MakeListTable();
	CM=MakeQueueTable();

 	SetOptions(argc,argv);

	ReadFiles(argc,argv);
	/* CheckBoundary(); */

	ntotal = CheckInput();
	hull = MakeNodeList(ntotal);
	intern = MakeNodeList(ntotal);

	printf("Making convex hull... %d\n",hull->count);
	ConvexHull(hull,intern);
/*
	CheckConvex(hull,intern);
	PrintNodeList("hull",hull);
	PrintNodeList("intern",intern);
*/

	printf("Making maxi elements...\n");
	MakeMaxiTriang(hull);
	CheckNeibor(-1);

	printf("Inserting convex hull... %d\n",hull->count);
	InsertBoundaryNodes(hull);
	CheckCircumCircle();
	CheckNeibor(-2);

	WriteAll("M_hull.grd",hull);
	CheckNeibor(-3);

	printf("Inserting internal boundary points... %d\n",intern->count);
	InsertBoundaryNodes(intern);
	CheckCircumCircle();
	CheckNeibor(-4);
	WriteAll("M_orgbound.grd",NULL);

	SetResolution(hull);
	CopyBoundaryLine();

	printf("Recovering boundary lines 1...\n");
	RecoverBoundary();
	CheckCircumCircle();
	CheckNeibor(-43);
	WriteAll("M_bndrecover.grd",NULL);

	printf("Refining boundary points 1...\n");
	boundary = RefineBoundary();

	if( boundary ) {
	    printf("Inserting new boundary points... %d\n",boundary->count);
	    InsertBoundaryNodes(boundary);
	    CheckCircumCircle();
	    CheckCircumCircleProperty();
	    CheckNeibor(-5);
	}

	TestVersion();

	printf("Marking external elements...");
	external=MarkExternalElements( hull );
	printf(" %d / %d\n",external,NTotElems);
	WriteGrd("M_finebound.grd");

/*
	printf("Marking outer elements...");
	external=MarkOuterElements();
	printf(" %d / %d\n",external,NTotElems);
	WriteGrd("M_test.grd");
*/

	FreeNodeList(hull);
	FreeNodeList(intern);
	FreeNodeList(boundary);

	given = GivenNodes();
	printf("Inserting internal given points... %d\n",given->count);
	InsertNodes(given);
	FreeNodeList(given);
	CheckCircumCircle();
	CheckNeibor(-44);
	WriteAll("M_given.grd",NULL);

	printf("Recovering boundary lines 2...\n");
	RecoverBoundary();
	CheckCircumCircle();
	CheckNeibor(-45);
	WriteAll("M_intrecover.grd",NULL);

	CheckArea();
	printf("Inserting internal points...\n");
	InsertInternalNodes();
	CheckCircumCircle();
	CheckCircumCircleProperty();
	WriteGrd("M_insert.grd");

	TestVersion();

	CheckArea();
	printf("Refining internal points... %f\n",OpAspect);
	RefineInternalNodes();
	CheckArea();
	CheckCircumCircle();
	CheckCircumCircleProperty();
	WriteGrd("M_refine.grd");

	CheckArea();
	printf("Recovering boundary lines 3...\n");
	RecoverBoundary();
	printf("Recovering fault lines...\n");
	RecoverInternalFault();
	CheckCircumCircle();
	CheckNeibor(-48);
	WriteAll("M_intrecover2.grd",NULL);

	printf("Marking outer elements...");
	external=MarkOuterElements();
	printf(" %d / %d\n",external,NTotElems);
	printf("Marking outer nodes...");
	external=MarkOuterNodes();
	printf(" %d / %d\n",external,NTotNodes);
	WriteGrd("M_test.grd");

	TestVersion();

	CheckArea();
	printf("Smoothing internal points... %f\n",OpSmoothOmega);
	SmoothInternalNodes();
	CheckArea();
	WriteGrd("final.grd");

	return 0;
}