Exemplo n.º 1
0
//------------------------------------------------------------------------------
void NewickTreeWriterGTP::WriteGTP ()
{
	cur = t->GetRoot();

    while (cur)
    {
        if (cur->GetChild())
        {
            WriteLeftParenthesis ();
            stk.push (cur);
            cur = cur->GetChild();
        }
        else
        {
            WriteLeaf ();
            while (!stk.empty() && (cur->GetSibling() == NULL))
            {
                WriteRightParenthesis ();
                cur = stk.top();
                WriteInternal ();
                stk.pop();
            }
            if (stk.empty())
                cur = NULL;
            else
            {
                WriteSiblingSymbol ();
                cur = cur->GetSibling();
            }
        }
    }
    WriteEndOfTree ();
}
Exemplo n.º 2
0
/*
==================
WriteDrawNodes_r
==================
*/
void WriteDrawNodes_r (node_t *node)
{
  dnode_t	*n;
  int		i;

  // emit a node	
  if (numnodes == MAX_MAP_NODES)
    Error ("numnodes == MAX_MAP_NODES");
  n = &dnodes[numnodes];
  numnodes++;

  VectorCopy (node->mins, n->mins);
  VectorCopy (node->maxs, n->maxs);

  n->planenum = node->outputplanenum;
  n->firstface = node->firstface;
  n->numfaces = node->numfaces;

  //
  // recursively output the other nodes
  //	
	
  for (i=0 ; i<2 ; i++)
    {
      if (node->children[i]->planenum == -1)
	{
	  if (node->children[i]->contents == CONTENTS_SOLID)
	    n->children[i] = -1;
	  else
	    {
	      n->children[i] = -(numleafs + 1);
	      WriteLeaf (node->children[i]);
	    }
	}
      else
	{
	  n->children[i] = numnodes;	
	  WriteDrawNodes_r (node->children[i]);
	}
    }
}
Exemplo n.º 3
0
/*
==================
WriteDrawNodes
==================
*/
void WriteDrawNodes (node_t *headnode)
{
  int		i;
  int		start;
  dmodel_t	*bm;

#if 0
  if (headnode->contents < 0)
    Error ("FinishBSPModel: empty model");
#endif

  // emit a model
  if (nummodels == MAX_MAP_MODELS)
    Error ("nummodels == MAX_MAP_MODELS");
  bm = &dmodels[nummodels];
  nummodels++;
	
  bm->headnode[0] = numnodes;
  bm->firstface = firstface;
  bm->numfaces = numfaces - firstface;	
  firstface = numfaces;
	
  start = numleafs;

  if (headnode->contents < 0)	
    WriteLeaf (headnode);
  else
    WriteDrawNodes_r (headnode);
  bm->visleafs = numleafs - start;
	
  for (i=0 ; i<3 ; i++)
    {
      bm->mins[i] = headnode->mins[i] + SIDESPACE + 1;	// remove the padding
      bm->maxs[i] = headnode->maxs[i] - SIDESPACE - 1;
    }
  // FIXME: are all the children decendant of padded nodes?
}