⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsv.cpp

📁 模糊聚類分析源碼。包含教學文件
💻 CPP
字号:
/*    Context       : Fuzzy Clustering Algorithms  Author        : Frank Hoeppner, see also AUTHORS file   Description   : implementation of main program xsv                    History       :      Comment       :     This file was generated automatically. DO NOT EDIT.  Copyright     : Copyright (C) 1999-2000 Frank Hoeppner    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*//*  The University of Applied Sciences Oldenburg/Ostfriesland/Wilhelmshaven  hereby disclaims all copyright interests in the program package `fc'   (tool package for fuzzy cluster analysis) written by Frank Hoeppner.    Prof. Haass, President of Vice, 2000-Mar-10*/#ifndef xsv_SOURCE#define xsv_SOURCE/* configuration include */#ifdef HAVE_CONFIG_H/*//FILETREE_IFDEF HAVE_CONFIG_H*/#include "config.h"/*//FILETREE_ENDIF*/#endif/* necessary includes */#include <iostream.h>#include "algorithm.cpp"#include "Analysis.cpp"#include "stlstream.cpp"#include "Tuple.cpp"#include "DataView.cpp"#include "ReadDDLStream.cpp"#include "WriteDDLStream.cpp"#include "StoreAnalysis.cpp"#include "CheckAnalysis.cpp"#include "CmdLine.cpp"#include "TurnIntoPointMap.cpp"#include "Chars.hpp"/* private typedefs *//* private functions *//* data */typedef Tuple<3,real_type> point_3d_type;DataView< point_3d_type > g_dataview;int g_time(0),    g_last_time(0),    g_data_dimension(2),    g_analysis_counter(0);real_type g_inter_data_distance,          g_sum_of_inter_data_distances(0);bool g_done;#define BUTTON_XSV_READ_INPUT_STREAM 1Chars<100> g_window_title("DDL Stream Visualization");ReadDDLStream<full_analysis_type>* g_read;TurnIntoPointMap<full_analysis_type>* g_turn;/* implementation */void read_and_store_new_analysis  (  istream& is  )  {  (*g_read)(cin);  ++g_analysis_counter;  g_sum_of_inter_data_distances +=     g_read->analysis().option().inter_data_distance();  g_inter_data_distance =     g_sum_of_inter_data_distances / g_analysis_counter;  g_data_dimension =     max(g_data_dimension,g_read->analysis().option().data_dimension());  invariant(!g_turn->pointmap().data().empty(),"non empty data set",SOURCELOC);   int last_time( (*(--(g_turn->pointmap().data().end()))).first );  if (g_last_time != last_time) // time has increased        { // set to last time     g_time = last_time;    g_last_time = last_time;    }  point_3d_type point,lower,upper;  g_dataview.reset_bbox();  matrix_set(lower,g_turn->pointmap().bbox().lowerBound);  matrix_set(upper,g_turn->pointmap().bbox().upperBound);    point = lower; point[AXIS_X] = upper[AXIS_X]; g_dataview.set_red(point);  point = lower; point[AXIS_Y] = upper[AXIS_Y]; g_dataview.set_green(point);  point = lower; point[AXIS_Z] = upper[AXIS_Z]; g_dataview.set_blue(point);  matrix_set_combi(point,0.5,upper,0.5,lower);  g_dataview.set_focus(point); }void display_map(const basic_pointmap_type::display_tuple_set_type& a_map,bool cross)  {  if (a_map.empty()) return; // quick exit  basic_pointmap_type::display_tuple_set_type::const_iterator i;  point_3d_type p1,p2;  TData color, intensity, size; // scaled or normalized values  for (i=a_map.begin();i!=a_map.end();++i)    {    // length+1 instead of 360 since 360=red=0 looks similar but is not similar in data    color = 360.0*((*i)(AXIS_C) - g_turn->pointmap().bbox().minimum(AXIS_C))/(g_turn->pointmap().bbox().length(AXIS_C)+1);    intensity = 0.3+0.7*((*i)(AXIS_I) - g_turn->pointmap().bbox().minimum(AXIS_I))/g_turn->pointmap().bbox().length(AXIS_I);    size = g_inter_data_distance * 0.5 *            pow( (*i)(AXIS_S), 1.0/g_data_dimension );    display_color_hsv(color,1.0,intensity);    p1(AXIS_X) = (*i)(AXIS_X);    p1(AXIS_Y) = (*i)(AXIS_Y);    p1(AXIS_Z) = (*i)(AXIS_Z);    p2(AXIS_X) = p1(AXIS_X)+(*i)(AXIS_DX);    p2(AXIS_Y) = p1(AXIS_Y)+(*i)(AXIS_DY);    p2(AXIS_Z) = p1(AXIS_Z)+(*i)(AXIS_DZ);       if (cross)      { g_dataview.display_point(p1,size); }    else // ball      { g_dataview.display_ball(p1,size); }    if (p1!=p2)      { g_dataview.display_line(p1,p2,0); }    }  }void display_scene()  {  if (g_time<0) return; // quick exit  display_list_begin(g_time+1); // display list always +1  basic_pointmap_type::time_map_type::const_iterator i;  i = g_turn->pointmap().grid().find(g_time);  if (i!=g_turn->pointmap().grid().end()) display_map((*i).second,true);  i = g_turn->pointmap().data().find(g_time);  if (i!=g_turn->pointmap().data().end()) display_map((*i).second,true);  i = g_turn->pointmap().prototypes().find(g_time);  if (i!=g_turn->pointmap().prototypes().end()) display_map((*i).second,true);  display_list_end();  }void exit_handler()  {   // before we exit we close the DDL stream  cout << KEYWORD_CLOSE << endl;  }void button_handler(int a_button)  {  switch (a_button)    {    case BUTTON_XSV_READ_INPUT_STREAM :      if (!g_done)         {        read_and_store_new_analysis(cin);        g_done = (is_followed_by(cin,KEYWORD_CLOSE,false)) || (cin.eof());        }      g_dataview.application_button_state(BUTTON_XSV_READ_INPUT_STREAM)        = (g_done) ? ButtonPassive : ButtonOff;      display_scene();      break;    }  }void display()  {  if (g_time>=0) display_list(g_time+1);  }  void time_handler(float t)  {  if ((int)t != g_time)    {    g_time = (int)t;    display_scene();    }  }  int main  (  int argc,  char **argv  )  {  InitialLog Entry("xsv.id","xsv.log");  g_turn = pointmap(ptmap_nop());  g_read = ddlread(cmdline(argc,argv,store(FC_STORE_ALL,ddlwrite(cout,g_turn,false))),true);  g_done = false;  read_until(cin,KEYWORD_DDL);  cout << KEYWORD_DDL << endl;  g_dataview.registrate_button_handler(button_handler);  g_dataview.registrate_display_func(display);  g_dataview.registrate_time_handler(time_handler);  g_dataview.registrate_exit_handler(exit_handler);  g_dataview.registrate_button(  0,  0, 199, 19,"Clustering Control",    ButtonPassive,0);  g_dataview.registrate_button(  0, 20,  99, 19,"ddl input",    ButtonOff,BUTTON_XSV_READ_INPUT_STREAM);  #ifdef OPENGL  g_dataview.display(370,220,g_window_title());  #else  cerr << "no OpenGL functionality found by ./configure. Exiting." << endl;  #endif  return 0;  }/* template instantiation */#include "matvecop.cpp"#include "DataView.cpp"#include "Box.cpp"template class DataView<point_3d_type>;#endif /* xsv_SOURCE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -