コード例 #1
0
ファイル: RTree.c プロジェクト: javierab/T1Alg
int recDelete(rect *r, node *n, int pos){
    int i,j;
    node *n1, *n2;
    if(n->leaf){
    	for(i = 0; i < n->size; ++i)
    		if(n->values[i]->child == pos){
            	deleteValue(n, i);
            	writeNode(n);
    			return TRUE;
    		}
    	return FALSE;
    }

    for(i = 0; i < n->size; ++i)
        if(intersect(r, n->values[i]->r)){
            n1 = readNode(n->values[i]->child);

            if(recDelete(r, n1, pos)){
            	n->values[i]->r = dupRect(n1->MBR);
                if(n1->size < b )
                	underflow(n, n1, i);
                else{
                	refreshMBR(n);
                	writeNode(n);
    				freeNode(n1);
                }
                return TRUE;
            }
            else
                freeNode(n1);

        }
    return FALSE;

}
コード例 #2
0
ファイル: JsonTextWriter.cpp プロジェクト: alesapin/lspl
void JsonTextWriter::writeToStream( const Text & text, std::ostream & os ) {
	os << "{\n\tconfig: ";
	writeConfig( text.getConfig(), os );
	os << ",\n\tcontent: '" << text.getContent() << "',\n\tnodes: [\n\t\t";

	uint nodesCount = text.getNodes().size();
	if ( nodesCount > 0 ) {
		writeNode( *text.getNodes().at( 0 ), os );
		for ( uint i = 1; i < nodesCount; ++ i ) {
			os << ",\n\t\t";
			writeNode( *text.getNodes().at( i ), os );
		}
	}

	os << "\n\t],\n\tannotations: [\n\t\t";

	for ( uint i = 0; i < nodesCount; ++ i ) {
		const Node & node = *text.getNodes().at( i );

		for ( uint j = 0; j < node.getTransitionCount(); ++ j ) {
			if ( i != 0 || j != 0 )
				os << ",\n\t\t";
			writeAnnotation( *node.getTransition( j ), os );
		}
	}

	os << "\n\t]\n}";
}
コード例 #3
0
ファイル: BSPFile.cpp プロジェクト: TheRyaz/c_reading
void BSPFile::writeNode( ChunkOutputStream* out, const BSPNode* nodeIn ) 
{
	Debug::println( "bsp: Writing node of {0} polygons", nodeIn->polygons() );

	out->beginChunk( "node" );

	out->writeFloat( nodeIn->plane().x );
	out->writeFloat( nodeIn->plane().y );
	out->writeFloat( nodeIn->plane().z );
	out->writeFloat( nodeIn->plane().w );

	int childFlags = 0;
	if ( nodeIn->positive() )
		childFlags |= 1;
	if ( nodeIn->negative() )
		childFlags |= 2;
	out->writeInt( childFlags );

	if ( nodeIn->positive() )
		writeNode( out, nodeIn->positive() );
	if ( nodeIn->negative() )
		writeNode( out, nodeIn->negative() );

	out->writeInt( nodeIn->polygons() );
	for ( int i = 0; i < nodeIn->polygons(); ++i )
		out->writeInt( m_tree->getPolygonIndex(&nodeIn->getPolygon(i)) );

	out->endChunk();
}
コード例 #4
0
ファイル: btree.cpp プロジェクト: heavilessrose/my-sync
void Btree<T>::cutNode(T& x,
                      unsigned xRST,
                      unsigned ptr,
                      unsigned pos,
                      T& y,
                      unsigned &yRST)
//
// Purpose: divides the node accessed by index ptr that contains
// item x and index xRST at index pos.  The new nodes are accessed
// by pointers ptr and yRST.  The median element is y.
//
// Parameters:
//
//    input: x - the inserted data
//           xRST - the inserted index associated with item x
//           ptr - the index to the manipulated node
//           pos - the index of the dividing line
//
//    output:
//           y - the new median
//           yRST - the index to the other node.
//
{
   unsigned median, i;
   Bstruct<T> *buf1, *buf2;

   buf1 = new Bstruct<T>;
   buf2 = new Bstruct<T>;
   readNode(buf1, ptr);
   // calculate the median element which also determines if
   // the new inserted item x is placed in the new left or the
   // new right nodes
   median = (pos <= BTREE_MIN) ? BTREE_MIN : BTREE_MIN + 1;
   // create a new tree node and put it on the right
   yRST = getNodeIndex();
   for (i = 0; i <= BTREE_MAX; i++)
     buf2->nodeLink[i] = BTREE_NIL;
   numNodes++;

   // loop to move half of the keys
   for (i = median + 1; i <= BTREE_MAX; i++) {
     buf2->data[i - median] = buf1->data[i];
     buf2->nodeLink[i - median] = buf1->nodeLink[i];
   }
   buf2->count = BTREE_MAX - median;
   buf1->count = median;
   // push in the new data
   if (pos <= BTREE_MIN)
     pushIn(x, xRST, buf1, pos);
   else
     pushIn(x, xRST, buf2, pos - median);
   y = buf1->data[buf1->count];
   buf2->nodeLink[0] = buf1->nodeLink[buf1->count--];
   writeNode(buf1, ptr);
   writeNode(buf2, yRST);
   delete buf1;
   delete buf2;
}
コード例 #5
0
ファイル: btree.cpp プロジェクト: heavilessrose/my-sync
void Btree<T>::recDelete(T& x,
                         unsigned ptr,
                         Boolean& found)
//
//
// Purpose: function that performs node deletion.
//
//  Parameters:
//
//    input: x - the data to be removed
//           ptr - the
//
//    output:
//           found - flag that indicates whether item x was found
//
{
    Bstruct<T> *buf, *buf2;
    unsigned i;

    if (ptr == BTREE_NIL)
       found = FALSE;
    else {
      buf = new Bstruct<T>;
      readNode(buf, ptr);
      // search for x in the current node
      found = (searchNode(x, buf, i)) ? TRUE : FALSE;
      // found an element that matches item x?
      if (found) {
        // does ptr point to a leaf node?
        if (buf->nodeLink[i - 1] == BTREE_NIL) {
          // remove element at index i
          trim(buf, i);
          writeNode(buf, ptr);
        }
        else {
          // replace data[i] with its successor in node ptr
          successor(buf, i);
          writeNode(buf, ptr);
          recDelete(buf->data[i], buf->nodeLink[i], found);
        }
      }
      else
        recDelete(x, buf->nodeLink[i], found);

      if (buf->nodeLink[i] != BTREE_NIL) {
        buf2 = new Bstruct<T>;
        readNode(buf2, buf->nodeLink[i]);
        if (buf2->count < BTREE_MIN) {
          restore(buf, i);
          writeNode(buf, ptr);
        }
        delete buf2;
      }
      delete buf;
    }
}
コード例 #6
0
ファイル: DFXML.c プロジェクト: apache/incubator-corinthia
static void writeElement(Serialization *serialization, DFNode *element, int depth)
{
    const TagDecl *tagDecl = DFNameMapNameForTag(serialization->doc->map,element->tag);
    assert(tagDecl != NULL);
    const NamespaceDecl *nsDecl = DFNameMapNamespaceForID(serialization->doc->map,tagDecl->namespaceID);
    assert(nsDecl != NULL);

    const xmlChar *prefix = (const xmlChar *)nsDecl->prefix;
    const xmlChar *localName = (const xmlChar *)tagDecl->localName;

    if (serialization->indent && (element->parent != element->doc->docNode))
        xmlTextWriterWriteRawLen(serialization->writer,INDENT,1+depth);

    if (serialization->html || (tagDecl->namespaceID == serialization->defaultNS))
        xmlTextWriterStartElement(serialization->writer,localName);
    else
        xmlTextWriterStartElementNS(serialization->writer,prefix,localName,NULL);

    if ((element->parent == serialization->doc->docNode) && !serialization->html)
        writeNamespaceDeclarations(serialization,element);

    writeAttributes(serialization,element);

    // Check if all children are text nodes. If this is true; we should treat them as if they are a single text
    // node, and not do any indentation.
    int allChildrenText = 1;
    for (DFNode *child = element->first; child != NULL; child = child->next) {
        if (child->tag != DOM_TEXT)
            allChildrenText = 0;
    }

    if (allChildrenText) {
        int oldIndent = serialization->indent;
        serialization->indent = 0;
        for (DFNode *child = element->first; child != NULL; child = child->next)
            writeNode(serialization,child,depth+2);
        serialization->indent = oldIndent;
    }
    else {
        for (DFNode *child = element->first; child != NULL; child = child->next)
            writeNode(serialization,child,depth+2);
    }

    if (serialization->indent && (element->first != NULL) && !allChildrenText) {
        if ((element->first != element->last) ||
            (element->first->tag != DOM_TEXT))
        xmlTextWriterWriteRawLen(serialization->writer,INDENT,1+depth);
    }

    if (serialization->html && (element->first == NULL) && HTML_requiresCloseTag(element->tag)) {
        xmlTextWriterWriteString(serialization->writer,(xmlChar *)"");
    }

    xmlTextWriterEndElement(serialization->writer);
}
コード例 #7
0
void TOutline::writeNode(TNode *node, opstream &op) {
   uchar more = (node->next != 0) ? 1 : 0;
   uchar expand = (node->expanded) ? 1 : 0;

   op << more;
   op << expand;
   op << getNumChildren(node);
   op.writeString(node->text);

   if (node->childList != 0)
      writeNode(node->childList, op);

   if (node->next != 0)
      writeNode(node->next, op);
}
コード例 #8
0
ファイル: Document.cpp プロジェクト: dgault/bioformats
 void
 writeNode(Node&                  node,
           std::ostream&          stream,
           const WriteParameters& params)
 {
   writeNode(*(node.get()), stream, params);
 }
コード例 #9
0
ファイル: Document.cpp プロジェクト: dgault/bioformats
 void
 writeNode(Node&                          node,
           const boost::filesystem::path& file,
           const WriteParameters&         params)
 {
   writeNode(*(node.get()), file, params);
 }
コード例 #10
0
ファイル: octtree.c プロジェクト: koukou73gr/seiscomp3
int writeNode(FILE *fpio, OctNode* node) {

    int istat;
    int istat_cum;
    int ix, iy, iz;

    float value;

    value = (float) node->value;
    istat = fwrite(&value, sizeof (float), 1, fpio); /* node value */
    istat += fwrite(&(node->isLeaf), sizeof (char), 1, fpio); /* leaf flag, 1=leaf */

    if (istat < 2)
        return (-1);

    if (node->isLeaf)
        return (1);

    istat_cum = 1;
    for (ix = 0; ix < 2; ix++) {
        for (iy = 0; iy < 2; iy++) {
            for (iz = 0; iz < 2; iz++) {
                if (node->child[ix][iy][iz] != NULL) {
                    istat = writeNode(fpio, node->child[ix][iy][iz]);
                    if (istat < 0)
                        return (-1);
                    istat_cum += istat;
                }
            }
        }
    }

    return (istat_cum);

}
コード例 #11
0
ファイル: octtree.c プロジェクト: koukou73gr/seiscomp3
int writeTree3D(FILE *fpio, Tree3D* tree) {

    int istat;
    int istat_cum;
    int ix, iy, iz;

    istat = fwrite(&(tree->data_code), sizeof (int), 1, fpio);
    istat += fwrite(&(tree->numx), sizeof (int), 1, fpio);
    istat += fwrite(&(tree->numy), sizeof (int), 1, fpio);
    istat += fwrite(&(tree->numz), sizeof (int), 1, fpio);
    istat += fwrite(&(tree->orig), sizeof (Vect3D), 1, fpio);
    istat += fwrite(&(tree->ds), sizeof (Vect3D), 1, fpio);
    istat += fwrite(&(tree->integral), sizeof (double), 1, fpio);

    if (istat < 6)
        return (-1);

    istat_cum = 0;
    for (ix = 0; ix < tree->numx; ix++) {
        for (iy = 0; iy < tree->numy; iy++) {
            for (iz = 0; iz < tree->numz; iz++) {
                istat = writeNode(fpio, tree->nodeArray[ix][iy][iz]);
                if (istat < 0)
                    return (-1);
                istat_cum += istat;
            }
        }
    }

    return (istat_cum);

}
コード例 #12
0
ファイル: Document.cpp プロジェクト: dgault/bioformats
 void
 writeDocument(Document&              document,
               std::ostream&          stream,
               const WriteParameters& params)
 {
   writeNode(*(document.get()), stream, params);
 }
コード例 #13
0
ファイル: DFXML.c プロジェクト: flyonok/DocFormats
void DFSerializeXMLBuffer(DFDocument *doc, NamespaceID defaultNS, int indent, DFBuffer *buf)
{
    xmlOutputBufferPtr output = xmlOutputBufferCreateIO(StringBufferWrite,
                                                        StringBufferClose,
                                                        buf,
                                                        NULL);
    xmlTextWriterPtr writer = xmlNewTextWriter(output);

    int html = 0;
    for (DFNode *child = doc->docNode->first; child != NULL; child = child->next) {
        if (child->tag == HTML_HTML)
            html = 1;
    }

    Serialization serialization;
    bzero(&serialization,sizeof(serialization));
    serialization.ic = iconv_open("UTF-8","UTF-16LE");
    if (serialization.ic == ((iconv_t)-1)) {
        fprintf(stderr,"FATAL: Can't open iconv descriptor\n");
        abort();
    }
    serialization.writer = writer;
    serialization.doc = doc;
    serialization.defaultNS = defaultNS;
    serialization.html = html;
    serialization.indent = indent;
    writeNode(&serialization,doc->docNode,0);
    iconv_close(serialization.ic);
    xmlFreeTextWriter(writer);
}
コード例 #14
0
ファイル: JsonDetail.cpp プロジェクト: argarak/vcmi
void JsonWriter::writeEntry(JsonVector::const_iterator entry)
{
	if (!entry->meta.empty())
		out << prefix << " // " << entry->meta << "\n";
	out << prefix;
	writeNode(*entry);
}
コード例 #15
0
ファイル: xnode.C プロジェクト: viatsko/parser3
// Attr setAttributeNode(in Attr newAttr) raises(DOMException);
// Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException);
static void _setAttributeNode(Request& r, MethodParams& params) {
	VXnode& vnode=GET_SELF(r, VXnode);
	VXdoc& vxdoc=vnode.get_vxdoc();
	xmlNode& element=get_self_element(vnode);
	xmlDoc& xmldoc=vxdoc.get_xmldoc();

	xmlAttr& newAttr=as_attr(params, 0, "newAttr must be ATTRIBUTE node");

	if(newAttr.doc!=&xmldoc)
		throw Exception("xml.dom",
			0,
			"WRONG_DOCUMENT_ERR");

	if(newAttr.parent)
		throw Exception("xml.dom",
			0,
			"INUSE_ATTRIBUTE_ERR");
	
	if(xmlNode* retNode=pa_getAttributeNodeNS(element, newAttr.name, pa_xmlGetNsURI((xmlNode*)&newAttr))) {
		// write out result
		writeNode(r, vxdoc, retNode);
		xmlUnlinkNode(retNode);
	}

	pa_addAttributeNode(element, newAttr);
}	
コード例 #16
0
ファイル: Document.cpp プロジェクト: dgault/bioformats
 void
 writeDocument(Document&                      document,
               const boost::filesystem::path& file,
               const WriteParameters&         params)
 {
   writeNode(*(document.get()), file, params);
 }
コード例 #17
0
bool Writer::writeNode(Lattice *lattice, const Node *node,
                       StringBuffer *os) const {
  switch (node->stat) {
    case MECAB_BOS_NODE:
      return writeNode(lattice, bos_format_.get(), node, os);
    case MECAB_EOS_NODE:
      return writeNode(lattice, eos_format_.get(), node, os);
    case MECAB_UNK_NODE:
      return writeNode(lattice, unk_format_.get(), node, os);
    case MECAB_NOR_NODE:
      return writeNode(lattice, node_format_.get(), node, os);
    case MECAB_EON_NODE:
      return writeNode(lattice, eon_format_.get(), node, os);
  }
  return true;
}
コード例 #18
0
ファイル: Document.cpp プロジェクト: dgault/bioformats
 void
 writeDocument(Document&              document,
               std::string&           text,
               const WriteParameters& params)
 {
   writeNode(*(document.get()), text, params);
 }
コード例 #19
0
ファイル: Document.cpp プロジェクト: dgault/bioformats
 void
 writeNode(Node&                  node,
           std::string&           text,
           const WriteParameters& params)
 {
   writeNode(*(node.get()), text, params);
 }
コード例 #20
0
ファイル: xnode.C プロジェクト: viatsko/parser3
// Node replaceChild(in Node newChild,in Node oldChild) raises(DOMException);
static void _replaceChild(Request& r, MethodParams& params) {
	xmlNode& newChild=as_node(params, 0, "newChild must be node");
	xmlNode& oldChild=as_node(params, 1, "oldChild must be node");

	VXnode& vnode=GET_SELF(r, VXnode);
	VXdoc& vxdoc=vnode.get_vxdoc();
	xmlDoc& xmldoc=vxdoc.get_xmldoc();
	xmlNode& selfNode=vnode.get_xmlnode();

	if(newChild.doc!=&xmldoc)
		throw Exception("xml.dom",
			0,
			"WRONG_DOCUMENT_ERR");
	if(oldChild.doc!=&xmldoc)
		throw Exception("xml.dom",
			0,
			"WRONG_DOCUMENT_ERR");

	if(oldChild.parent!=&selfNode)
		throw Exception("xml.dom",
			0,
			"NOT_FOUND_ERR");

	xmlNode* refChild=oldChild.next;
	xmlUnlinkNode(&oldChild);
	xmlNode* retNode;
	if(refChild)
		retNode=xmlAddPrevSibling(refChild, &newChild);
	else
		retNode=xmlAddChild(&selfNode, &newChild);

	// write out result
	writeNode(r, vxdoc, retNode);
}
コード例 #21
0
ファイル: xdoc.C プロジェクト: viatsko/parser3
// DocumentFragment createDocumentFragment()
static void _createDocumentFragment(Request& r, MethodParams&) {
	VXdoc& vdoc=GET_SELF(r, VXdoc);
	xmlDoc& xmldoc=vdoc.get_xmldoc();

	xmlNode *node=xmlNewDocFragment(&xmldoc);
	writeNode(r, vdoc, node);
}
コード例 #22
0
ファイル: GraphIO_gexf.cpp プロジェクト: lncosie/ogdf
static void writeGraph(
	std::ostream &out,
	const Graph &G, const GraphAttributes *GA)
{
	const std::string dir =
		(GA && !GA->directed()) ? "undirected" : "directed";
	GraphIO::indent(out, 1) << "<graph "
	                        << "mode=\"static\" "
	                        << "defaultedgetype=\"" << dir << "\""
	                        << ">\n";

	if(GA) {
		defineAttributes(out, 2, *GA);
	}

	GraphIO::indent(out, 2) << "<nodes>\n";

	for(node v : G.nodes) {
		writeNode(out, 3, GA, v);
	}
	GraphIO::indent(out, 2) << "</nodes>\n";

	gexf::writeEdges(out, G, GA);

	GraphIO::indent(out, 1) << "</graph>\n";
}
コード例 #23
0
ファイル: ReaderWriterOBJ.cpp プロジェクト: joevandyk/osg
 virtual WriteResult writeObject(const osg::Object& obj,std::ostream& fout,const Options* options=NULL) const 
 {
     const osg::Node* node = dynamic_cast<const osg::Node*>(&obj);
     if (node)
         return writeNode(*node, fout, options);
     else 
         return WriteResult(WriteResult::FILE_NOT_HANDLED); 
 }
コード例 #24
0
ファイル: xdoc.C プロジェクト: viatsko/parser3
// Comment createComment(in DOMString data)
static void _createComment(Request& r, MethodParams& params) {
	xmlChar* data=as_xmlchar(r, params, 0, XML_DATA_MUST_BE_STRING);

	VXdoc& vdoc=GET_SELF(r, VXdoc);

	xmlNode *node=xmlNewComment(data);
	writeNode(r, vdoc, node);
}
コード例 #25
0
	//------------------------------
	bool SceneGraphWriter::writeNodes( const COLLADAFW::NodePointerArray& nodesToWriter )
	{
		for ( size_t i = 0, count = nodesToWriter.getCount(); i < count; ++i)
		{
			writeNode(nodesToWriter[i]);
		}
		return true;
	}
コード例 #26
0
ファイル: linklinstruct.c プロジェクト: b3h3moth/L-LP
/* Write the LLS on the screen */
void writeNode(typeList lis) {
    if (emptyList(lis))
        printf("\n");
    else {
        writeDataType(lis->data);
        writeNode(lis->next);
    }
}
コード例 #27
0
ファイル: RTree.c プロジェクト: javierab/T1Alg
void underflow(node *n, node *n1, int i){

    int j, sibling;
    node *n2;

	if(n->size == i + 1){
		n2 = readNode(n->values[i-1]->child);
		sibling = i-1;
	}
	else{
		n2 = readNode(n->values[i+1]->child);
		sibling = i+1;
	}
	if(n2->size > b){
		n1->values[n1->size++] = n2->values[--(n2->size)];
		refreshMBR(n1);
		refreshMBR(n2);

		freeRect(n->values[i]->r);
		n->values[i]->r = dupRect(n1->MBR);

		freeRect(n->values[sibling]->r);
		n->values[sibling]->r = dupRect(n2->MBR);

		refreshMBR(n);
		writeNode(n);

		writeNode(n1);
		freeNode(n1);

		writeNode(n2);
		freeNode(n2);

	}
	else{
		n2 = merge(n1,n2);
        freeNodeVal(n->values[i]);
        n->values[i] = new(nodeVal);
		n->values[i]->child = n2->address;
        n->values[i]->r=dupRect(n2->MBR);
		deleteValue(n, sibling);
        writeNode(n);

		freeNode(n2);
	}
}
コード例 #28
0
bool Writer::writeUser(Lattice *lattice, StringBuffer *os) const {
  if (!writeNode(lattice, bos_format_.get(), lattice->bos_node(), os)) {
    return false;
  }
  const Node *node = 0;
  for (node = lattice->bos_node()->next; node->next; node = node->next) {
    const char *fmt = (node->stat == MECAB_UNK_NODE ? unk_format_.get() :
                       node_format_.get());
    if (!writeNode(lattice, fmt, node, os)) {
      return false;
    }
  }
  if (!writeNode(lattice, eos_format_.get(), node, os)) {
    return false;
  }
  return true;
}
コード例 #29
0
 virtual WriteResult writeNode( const osg::Node& node, const std::string& file, const Options* options ) const
 {
     std::string ext = osgDB::getLowerCaseFileExtension(file);
     if ( ext=="assimp" ) return writeNode(node, osgDB::getNameLessExtension(file), options);
     
     // TODO
     return WriteResult::FILE_NOT_HANDLED;
 }
コード例 #30
0
ファイル: DOMWriter.cpp プロジェクト: Victorcasas/georest
void DOMWriter::writeNode(const std::string& systemId, const Node* pNode)
{
	Poco::FileOutputStream ostr(systemId);
	if (ostr.good())
		writeNode(ostr, pNode);
	else 
		throw Poco::CreateFileException(systemId);
}