📄 ghmm_gmldatanode.cpp
字号:
/* * authors: Wasinee Rungsarityotin (rungsari@molgen.mpg.de) * file : $Source: /cvsroot/ghmm/ghmm/ghmm++/GHMM_GMLDataNode.cpp,v $ * $Id: GHMM_GMLDataNode.cpp,v 1.2 2003/04/24 17:23:57 wasinee Exp $ * * * Copyright (C) 1998-2001, ZAIK/ZPR, Universit鋞 zu K鰈n * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */#include <xmlio/XMLIO_Document.h>#include <xmlio/XMLIO_Element.h>#include "ghmm++/GHMM_GMLDataNode.h"#include "ghmm++/GHMM_DiscreteModel.h"#include "ghmm++/GHMM_StateT.hh"#ifdef HAVE_NAMESPACESusing namespace std;#endifGHMM_GMLDataNode::GHMM_GMLDataNode(GHMM_GMLState *my_state, const char *keyvalue){ state = my_state; tag = "data"; this->keyvalue = string(keyvalue); attributes["key"] = keyvalue; xmlio_indent_type = XMLIO_INDENT_BOTH;}const int GHMM_GMLDataNode::XMLIO_writeContent(XMLIO_Document& writer){ int total_bytes = 0; int i, result; writer.changeIndent(2); if (keyvalue == "label") { result = writer.writef("%s",state->label.c_str()); if (result < 0) return result; total_bytes += result; } /* discrete model */ if (state->c_sdstate) { if (keyvalue == "emissions") { //GHMM_Alphabet* alphabet = state->getModel()->getAlphabet(); GHMM_DiscreteModel* model = (GHMM_DiscreteModel*) state->getModel(); for (i = 0; i < model->c_model->M - 1; ++i) { result += writer.writef("%.2f, ",state->c_sdstate->b[i]); // space is important } result += writer.writef("%.2f",state->c_sdstate->b[i]); total_bytes += result; } } if (keyvalue == "ngeom") { XMLIO_Element pos_element; char tmp[15]; sprintf(tmp, "%5.2f", state->get2DPosition(0)); pos_element.attributes["x"]=tmp; sprintf(tmp, "%5.2f", state->get2DPosition(1)); pos_element.attributes["y"]=tmp; pos_element.tag = "pos"; result = writer.writeElement(&pos_element); if (result < 0) return result; total_bytes += result; } return total_bytes;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -