text
stringlengths
8
6.88M
/****************************************************************************/ /* C++ library for creating a level (i.e., strongly connected component) */ /* Written by SCHULZ Quentin, quentin.schulz@utbm.fr , Nov. 2013 */ /****************************************************************************/ #ifndef LEVEL_H #define LEVEL_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <fstream> #include <vector> #include "vertex.hpp" using namespace std; class Level{ private: /*All vertices contained in this strongly connected component*/ vector<Vertex*> lvl; /*Distance between two different strongly connected components*/ int distance; /*Allow a strongly connected components to be marked (useful when traversing a game)*/ bool marked; public: Level(); Level(Level& l); ~Level(); /*Look for vertex in the level **vertex is the vertex to be searched for **return true if in otherwise return false*/ bool contains(Vertex* vertex); /*Set the list of vertices in the level **stack is the whole set of vertices in the game **current is the vertex from which we apply the algorithm*/ void getLevel(vector<Vertex*>& stack, Vertex* current); /*Return the strongly connected component with all of its vertices*/ vector<Vertex*> getLevel(); friend ostream& operator<<(ostream& o, Level const& level); /*Set distance between two strongly connected components*/ void setDistance(int dis); int getDistance(); /*Allow a strongly connected components to be marked (useful when traversing a game)*/ void setMarked(bool _marked); bool isMarked(); }; #endif
#include "graph.h" #include <memory> namespace POICS{ NodeSet::NodeSet(int _num_nodes, int _num_score_elmts): num_nodes(_num_nodes), num_score_elmts(_num_score_elmts){ int n = _num_nodes*_num_score_elmts; scores = new double[n]; std::fill_n(scores, n, 0.0); } NodeSet::~NodeSet(){ delete[] scores; } void NodeSet::init(int _num_nodes, int _num_score_elmts){ if (scores == NULL){ num_nodes = _num_nodes; num_score_elmts = _num_score_elmts; int n = _num_nodes*_num_score_elmts; scores = new double[n]; std::fill_n(scores, n, 0.0); } } double NodeSet::getScoreElement(int node_id, int score_elmt_id) const{ return scores[node_id*num_score_elmts + score_elmt_id]; } double NodeSet::getScore(int node_id) const{ double sum = 0; for (int i = 0; i < num_score_elmts; ++i){ sum += getScoreElement(node_id, i) / num_score_elmts; } return sum; } void NodeSet::setScore(int node_id, int score_elmt_id, double score){ scores[node_id*num_score_elmts + score_elmt_id] = score; } EdgeSet::EdgeSet(int _num_nodes): num_nodes(_num_nodes){ edges = new double[_num_nodes * _num_nodes]; } void EdgeSet::init(int _num_nodes){ if (edges == NULL){ num_nodes = _num_nodes; edges = new double[_num_nodes * _num_nodes]; } } EdgeSet::~EdgeSet(){ delete[] edges; } void EdgeSet::addEdge(int node1, int node2, double length){ edges[node1 * num_nodes + node2] = length; } void EdgeSet::addEdgeSymmetric(int node1, int node2, double length){ edges[node1 * num_nodes + node2] = length; edges[node2 * num_nodes + node1] = length; } double EdgeSet::getLength(int node1, int node2) const{ return edges[node1 * num_nodes + node2]; } }
#include "CustomSplitForTree.h" using namespace std; QStringList splitForTree(QString stringTree){ QString st = stringTree; auto i = 0; QStringList out={}; QString tmp=""; for(;i<st.length();i++){ if (st[i] == ')' || st[i] == '(') out.push_back(QString(st[i])); else { for (; st[i]!=')' && st[i]!='(' ;i++){ tmp.push_back(st[i]); } out.push_back(tmp); out.push_back(QString(st[i])); tmp.clear(); } } return out; }
/* * SPDX-FileCopyrightText: 2008 Till Harbaum <till@harbaum.org> * * SPDX-License-Identifier: GPL-3.0-or-later */ #include "osm_api.h" #include "osm_api_p.h" #include "appdata.h" #include "diff.h" #include "map.h" #include "misc.h" #include "net_io.h" #include "notifications.h" #include "osm.h" #include "osm2go_platform.h" #include "project.h" #include "settings.h" #include "uicontrol.h" #include <algorithm> #include <cassert> #include <cstring> #include <curl/curl.h> #include <curl/easy.h> #include <filesystem> #include <map> #include <memory> #include <sys/stat.h> #include <unistd.h> #include "osm2go_annotations.h" #include <osm2go_cpp.h> #include <osm2go_i18n.h> #include <osm2go_stl.h> #define COLOR_ERR "red" #define COLOR_OK "darkgreen" bool osm_download(osm2go_platform::Widget *parent, project_t *project) { printf("download osm for %s ...\n", project->name.c_str()); settings_t::ref settings = settings_t::instance(); const std::string &defaultServer = settings->server; if(unlikely(!project->rserver.empty())) { if(api_adjust(project->rserver)) { message_dlg(_("Server changed"), trstring("It seems your current project uses an outdated " "server/protocol. It has thus been changed to:\n\n%1").arg(project->rserver), parent); } /* server url should not end with a slash */ if(unlikely(ends_with(project->rserver, '/'))) { printf("removing trailing slash\n"); project->rserver.erase(project->rserver.size() - 1); } if(project->rserver == defaultServer) project->rserver.clear(); } const std::string url = project->server(defaultServer) + "/map?bbox=" + project->bounds.print(); /* Download the new file to a new name. If something goes wrong then the * old file will still be in place to be opened. */ const char *updatefn = "update.osm"; const std::string update = project->path + updatefn; unlinkat(project->dirfd, updatefn, 0); if(unlikely(!net_io_download_file(parent, url, update, project->name, true))) return false; if(unlikely(!std::filesystem::is_regular_file(update))) return false; // if the project's gzip setting and the download one don't match change the project const bool wasGzip = ends_with(project->osmFile, ".gz"); // check the contents of the new file osm2go_platform::MappedFile osmData(update); if(unlikely(!osmData)) { error_dlg(trstring("Error accessing the downloaded file:\n\n%1").arg(update), parent); unlink(update.c_str()); return false; } const bool isGzip = check_gzip(osmData.data(), osmData.length()); osmData.reset(); /* if there's a new file use this from now on */ printf("download ok, replacing previous file\n"); if(wasGzip != isGzip) { const std::string oldfname = (project->osmFile[0] == '/' ? std::string() : project->path) + project->osmFile; std::string newfname = oldfname; if(wasGzip) newfname.erase(newfname.size() - 3); else newfname += ".gz"; rename(update.c_str(), newfname.c_str()); // save the project before deleting the old file so that a valid file is always found if(newfname.compare(0, project->path.size(), project->path) == 0) newfname.erase(0, project->path.size()); project->osmFile = newfname; project->save(parent); // now remove the old file unlink(oldfname.c_str()); } else if(project->osmFile[0] == '/') { rename(update.c_str(), project->osmFile.c_str()); } else { const std::string fname = project->path + project->osmFile; rename(update.c_str(), fname.c_str()); } return true; } namespace { struct curl_data_t { explicit curl_data_t(char *p = nullptr, curl_off_t l = 0) : ptr(p), len(l) {} char *ptr; long len; }; size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) { curl_data_t *p = static_cast<curl_data_t *>(stream); // printf("request to read %zu items of size %zu, pointer = %p\n", // nmemb, size, p->ptr); if(nmemb * size > static_cast<size_t>(p->len)) nmemb = p->len/size; memcpy(ptr, p->ptr, size*nmemb); p->ptr += size*nmemb; p->len -= size*nmemb; return nmemb; } size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) { std::string *p = static_cast<std::string *>(stream); p->append(static_cast<char *>(ptr), size * nmemb); return nmemb; } #define MAX_TRY 5 CURL * curl_custom_setup(const std::string &credentials) { /* get a curl handle */ CURL *curl = curl_easy_init(); if(curl == nullptr) return curl; /* we want to use our own write function */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); /* some servers don't like requests that are made without a user-agent field, so we provide one */ curl_easy_setopt(curl, CURLOPT_USERAGENT, PACKAGE "-libcurl/" VERSION); /* set user name and password for the authentication */ curl_easy_setopt(curl, CURLOPT_USERPWD, credentials.c_str()); #ifndef CURL_SSLVERSION_MAX_DEFAULT #define CURL_SSLVERSION_MAX_DEFAULT 0 #endif curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1 | CURL_SSLVERSION_MAX_DEFAULT); return curl; } bool osm_update_item(osm_upload_context_t &context, xmlChar *xml_str, const char *url, item_id_t *id) { char buffer[CURL_ERROR_SIZE]; std::unique_ptr<CURL, curl_deleter> &curl = context.curl; CURLcode res; /* specify target URL, and note that this URL should include a file name, not only a directory */ curl_easy_setopt(curl.get(), CURLOPT_URL, url); /* enable uploading */ curl_easy_setopt(curl.get(), CURLOPT_UPLOAD, 1L); /* we want to use our own read function */ curl_easy_setopt(curl.get(), CURLOPT_READFUNCTION, read_callback); std::unique_ptr<curl_slist, curl_slist_deleter> slist(curl_slist_append(nullptr, "Expect:")); curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER, slist.get()); curl_data_t read_data_init(reinterpret_cast<char *>(xml_str)); read_data_init.len = read_data_init.ptr != nullptr ? strlen(read_data_init.ptr) : 0; curl_data_t read_data = read_data_init; std::string write_data; /* now specify which file to upload */ curl_easy_setopt(curl.get(), CURLOPT_READDATA, &read_data); /* provide the size of the upload */ curl_easy_setopt(curl.get(), CURLOPT_INFILESIZE, read_data.len); /* we pass our 'chunk' struct to the callback function */ curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &write_data); curl_easy_setopt(curl.get(), CURLOPT_ERRORBUFFER, buffer); for(int retry = MAX_TRY; retry >= 0; retry--) { if(retry != MAX_TRY) context.append(trstring("Retry %1/%2 ").arg(MAX_TRY - retry).arg(MAX_TRY - 1)); read_data = read_data_init; write_data.clear(); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl.get()); long response; curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &response); if(unlikely(res != 0)) { context.append(trstring("failed: %1\n").arg(buffer), COLOR_ERR); } else if(unlikely(response != 200)) { context.append(trstring("failed, code: %1 %2\n").arg(response).arg(http_message(response)), COLOR_ERR); /* if it's neither "ok" (200), nor "internal server error" (500) */ /* then write the message to the log */ if(response != 500 && !write_data.empty()) { context.append(_("Server reply: ")); context.append_str(write_data.c_str(), COLOR_ERR); context.append_str("\n"); } } else if(unlikely(!id)) { context.append(_("ok\n"), COLOR_OK); } else { /* this will return the id on a successful create */ printf("request to parse successful reply '%s' as an id\n", write_data.c_str()); *id = strtoull(write_data.c_str(), nullptr, 10); context.append(trstring("ok: #%1\n").arg(*id), COLOR_OK); } /* don't retry unless we had an "internal server error" */ if(response != 500) return((res == 0)&&(response == 200)); } return false; } bool osm_post_xml(osm_upload_context_t &context, const xmlString &xml_str, int len, const char *url, std::string &write_data) { char buffer[CURL_ERROR_SIZE]; std::unique_ptr<CURL, curl_deleter> &curl = context.curl; CURLcode res; // drop now unneeded values from the previous transfers curl_easy_setopt(curl.get(), CURLOPT_READFUNCTION, nullptr); curl_easy_setopt(curl.get(), CURLOPT_READDATA, nullptr); curl_easy_setopt(curl.get(), CURLOPT_INFILESIZE, -1); curl_easy_setopt(curl.get(), CURLOPT_UPLOAD, 0); /* specify target URL, and note that this URL should include a file name, not only a directory */ curl_easy_setopt(curl.get(), CURLOPT_URL, url); /* no read function required */ curl_easy_setopt(curl.get(), CURLOPT_POST, 1); curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDS, xml_str.get()); curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDSIZE, len); std::unique_ptr<curl_slist, curl_slist_deleter> slist(curl_slist_append(nullptr, "Expect:")); curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER, slist.get()); curl_easy_setopt(curl.get(), CURLOPT_ERRORBUFFER, buffer); /* we pass our 'chunk' struct to the callback function */ curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &write_data); for(int retry = MAX_TRY; retry >= 0; retry--) { if(retry != MAX_TRY) context.append(trstring("Retry %1/%2 ").arg(MAX_TRY - retry).arg(MAX_TRY - 1)); write_data.clear(); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl.get()); long response; curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &response); if(unlikely(res != 0)) context.append(trstring("failed: %1\n").arg(buffer), COLOR_ERR); else if(unlikely(response != 200)) context.append(trstring("failed, code: %1 %2\n").arg(response).arg(http_message(response)), COLOR_ERR); else context.append(_("ok\n"), COLOR_OK); /* don't retry unless we had an "internal server error" */ if(response != 500) return((res == 0)&&(response == 200)); } return false; } /** * @brief upload one object to the OSM server * @returns if object has been updated */ bool upload_object(osm_upload_context_t &context, base_object_t *obj, bool is_new) { /* make sure gui gets updated */ osm2go_platform::process_events(); assert(obj->flags & OSM_FLAG_DIRTY); std::string url = context.urlbasestr + obj->apiString() + '/'; if(is_new) { url += "create"; context.append(trstring("New %1 ").arg(obj->apiString())); } else { url += obj->id_string(); context.append(trstring("Modified %1 #%2 ").arg(obj->apiString()).arg(obj->id)); } /* upload this object */ xmlString xml_str(obj->generate_xml(context.changeset)); if(likely(xml_str)) { printf("uploading %s " ITEM_ID_FORMAT " to %s\n", obj->apiString(), obj->id, url.c_str()); item_id_t tmp; if(osm_update_item(context, xml_str.get(), url.c_str(), is_new ? &obj->id : &tmp)) { if(!is_new) obj->version = tmp; context.project->data_dirty = true; return true; } } return false; } template<typename T> struct upload_objects { osm_upload_context_t &context; std::map<item_id_t, T *> &map; const bool is_new; upload_objects(osm_upload_context_t &co, std::map<item_id_t, T*> &m, bool n) : context(co), map(m), is_new(n) {} void operator()(T *obj); }; template<typename T> void upload_objects<T>::operator()(T *obj) { item_id_t oldid = obj->id; if (upload_object(context, obj, is_new)) context.osm->unmark_dirty(obj); if(oldid != obj->id) { map.erase(oldid); map[obj->id] = obj; } } template<typename T> static void upload_modified(osm_upload_context_t &co, trstring::native_type_arg header, std::map<item_id_t, T*> &m, const osm_t::dirty_t::counter<T> &counter) { if(counter.changed.empty() && counter.added.empty()) return; co.append(header); std::for_each(counter.added.begin(), counter.added.end(), upload_objects<T>(co, m, true)); std::for_each(counter.changed.begin(), counter.changed.end(), upload_objects<T>(co, m, false)); } void log_deletion(osm_upload_context_t &context, const base_object_t *obj) { assert(obj->isDeleted()); context.append(trstring("Deleted %1 #%2 (version %3)\n").arg(obj->apiString()).arg(obj->id) .arg(obj->version)); } struct osm_delete_objects_final { osm_upload_context_t &context; explicit osm_delete_objects_final(osm_upload_context_t &c) : context(c) {} template<typename T ENABLE_IF_CONVERTIBLE(T *, base_object_t *)> void operator()(T *o) { log_deletion(context, o); context.osm->wipe(o); } }; /** * @brief upload the given osmChange document * @param context the context pointer * @param doc the document to upload * @param server_reply the data returned from the server will be stored here * @returns if the operation was successful */ bool osmchange_upload(osm_upload_context_t &context, xmlDocGuard &doc, std::string &server_reply) { /* make sure gui gets updated */ osm2go_platform::process_events(); const std::string url = context.urlbasestr + "changeset/" + context.changeset + "/upload"; xmlChar *xml_str = nullptr; int len = 0; xmlDocDumpFormatMemoryEnc(doc.get(), &xml_str, &len, "UTF-8", 1); xmlString xml(xml_str); bool ret = osm_post_xml(context, xml, len, url.c_str(), server_reply); if(ret) context.project->data_dirty = true; return ret; } bool osm_create_changeset(osm_upload_context_t &context) { bool result = false; /* make sure gui gets updated */ osm2go_platform::process_events(); const std::string url = context.urlbasestr + "changeset/create"; context.append(_("Create changeset ")); /* create changeset request */ xmlString xml_str(osm_generate_xml_changeset(context.comment, context.src)); if(xml_str) { printf("creating changeset %s from address %p\n", url.c_str(), xml_str.get()); item_id_t changeset; if(osm_update_item(context, xml_str.get(), url.c_str(), &changeset)) { context.changeset = std::to_string(changeset); result = true; } } return result; } bool osm_close_changeset(osm_upload_context_t &context) { assert(!context.changeset.empty()); /* make sure gui gets updated */ osm2go_platform::process_events(); const std::string url = context.urlbasestr + "changeset/" + context.changeset + "/close"; context.append(_("Close changeset ")); return osm_update_item(context, nullptr, url.c_str(), nullptr); } } // namespace void osm_upload_context_t::upload(const osm_t::dirty_t &dirty, osm2go_platform::Widget *parent) { append(trstring("Log generated by %1 v%2 using API 0.6\n").arg(PACKAGE).arg(VERSION)); append(trstring("User comment: %1\n").arg(comment)); if (!src.empty()) append(trstring("User source: %1\n").arg(src)); settings_t::ref settings = settings_t::instance(); if(api_adjust(project->rserver)) { append(trstring("Server URL adjusted to %1\n").arg(project->rserver)); if(likely(project->rserver == settings->server)) project->rserver.clear(); } append(trstring("Uploading to %1\n").arg(project->server(settings->server))); /* get a curl handle */ curl.reset(curl_custom_setup(settings->username + ':' + settings->password)); if(unlikely(!curl)) { append(_("CURL init error\n")); } else if(likely(osm_create_changeset(*this))) { /* check for dirty entries */ upload_modified(*this, _("Uploading nodes:\n"), osm->nodes, dirty.nodes); upload_modified(*this, _("Uploading ways:\n"), osm->ways, dirty.ways); upload_modified(*this, _("Uploading relations:\n"), osm->relations, dirty.relations); if(!dirty.relations.deleted.empty() || !dirty.ways.deleted.empty() || !dirty.nodes.deleted.empty()) { append(_("Deleting objects:\n")); xmlDocGuard doc(osmchange_init()); osmchange_delete(dirty, xmlDocGetRootElement(doc.get()), changeset.c_str()); printf("deleting objects on server\n"); append(_("Uploading object deletions ")); // deletion was successful, remove the objects std::string server_reply; if(osmchange_upload(*this, doc, server_reply)) { osm_delete_objects_final finfc(*this); std::for_each(dirty.relations.deleted.begin(), dirty.relations.deleted.end(), finfc); std::for_each(dirty.ways.deleted.begin(), dirty.ways.deleted.end(), finfc); std::for_each(dirty.nodes.deleted.begin(), dirty.nodes.deleted.end(), finfc); } else { append(_("Server reply: ")); append_str(server_reply.c_str(), COLOR_ERR); append_str("\n"); } } /* close changeset */ osm_close_changeset(*this); curl.reset(); append(_("Upload done.\n")); } if(project->data_dirty) { append(_("Server data has been modified.\nDownloading updated osm data ...\n")); bool reload_map = osm_download(parent, project.get()); if(likely(reload_map)) { append(_("Download successful!\nThe map will be reloaded.\n")); project->data_dirty = false; } else append(_("Download failed!\n")); project->save(parent); if(likely(reload_map)) { /* this kind of rather brute force reload is useful as the moment */ /* after the upload is a nice moment to bring everything in sync again. */ /* we basically restart the entire map with fresh data from the server */ /* and the diff will hopefully be empty (if the upload was successful) */ append(_("Reloading map ...\n")); if(unlikely(!project->osm->is_clean(false))) append(_("*** DIFF IS NOT CLEAN ***\nSomething went wrong during " "upload,\nproceed with care!\n"), COLOR_ERR); /* redraw the entire map by destroying all map items and redrawing them */ append(_("Cleaning up ...\n")); project->diff_save(); appdata.map->clear(map_t::MAP_LAYER_OBJECTS_ONLY); append(_("Loading OSM ...\n")); if(project->parse_osm()) { append(_("Applying diff ...\n")); diff_restore(project, appdata.uicontrol.get()); append(_("Painting ...\n")); appdata.map->paint(); } else { append(_("OSM data is empty\n"), COLOR_ERR); } append(_("Done!\n")); } } /* tell the user that he can stop waiting ... */ append(_("Process finished.\n")); } void osm_upload(appdata_t &appdata) { project_t::ref project = appdata.project; if(unlikely(project->osm->uploadPolicy == osm_t::Upload_Blocked)) { printf("Upload prohibited"); return; } /* upload config and confirmation dialog */ /* count objects */ const osm_t::dirty_t &dirty = project->osm->modified(); if(dirty.empty()) { appdata.uicontrol->showNotification(_("No changes present"), MainUi::Brief); return; } dirty.nodes.debug ("nodes: "); dirty.ways.debug ("ways: "); dirty.relations.debug("relations:"); osm_upload_dialog(appdata, dirty); }
#include <iostream> #include <string> using namespace std; //动态分配的数组,new出来在堆上 void dynamicArray(){ size_t size = 10; //当size为0时,new一个动态数组依然成功,但是返回的指针不指向任何对象,不能用*操作 int *a1 = new int[size]; //未初始化的数组,内置无初始化,类调默认构造 int *a2 = new int[size](); //初始化后的数组,内置为0,类调默认构造 const string *s = new const string[10](); //const动态数组的定义,由于内容const所以必须初始化,若为类对象则必须有默认构造 for(int i = 0;i < 10;i++) cout<<a2[i]<<endl; delete[] a1, a2, s; //new出来的必须delete,否则内存泄露 } int main2(){ dynamicArray(); getchar(); return 0; }
#include "iostream" using namespace std; /** * @brief Clase Node_Rr : Estructura de datos : Nodo Simpre * */ class Node_Rr{ private: string memory_address; /**< dirección de memoria */ string name; /**< nombre */ string value; /**< valor*/ string type; /**< tipo */ public: Node_Rr *siguiente; /**< Nodo siguiente*/ /** * @brief Metodó para obtener la dirección de memoria de un nodo * * @return const string */ const string &getMemory_address() const { return memory_address; } /** * @brief Metodó para asignar la direccion de memoria * * @param memory_address */ void setMemory_address(const string &memory_address) { Node_Rr::memory_address = memory_address; } /** * @brief Metodó para obtener la direccion de memoria * * @return const string */ const string &getName() const { return name; } /** * @brief Metodó para asignar el nombre * * @param name */ void setName(const string &name) { Node_Rr::name = name; } /** * @brief Metodó para obtener el valor de un nodo * * @return const string */ const string &getValue() const { return value; } /** * @brief Metodó para asignar el valor de un nodo * * @param value */ void setValue(const string &value) { Node_Rr::value = value; } /** * @brief Metodó para obtener el tipo de dato del nodo * * @return const string */ const string &getType() const { return type; } /** * @brief Metodó para asignar el tipo de un nodo * * @param type */ void setType(const string &type) { Node_Rr::type = type; } /** * @brief Metodó para obtener el nodo siguiente * * @return Node_Rr */ Node_Rr *getSiguiente() const { return siguiente; } /** * @brief Metodó para asignar el nodo siguiente * * @param siguiente */ void setSiguiente(Node_Rr *siguiente) { Node_Rr::siguiente = siguiente; } /** * @brief Metodó para crear un nodo con su informacion respectiva * * @param m direccion de memoria * @param n nombre * @param v valor * @param t tipo */ Node_Rr(string m, string n ,string v ,string t){ this->siguiente=NULL; this->memory_address=m; this->name=n; this->value=v; this->type=t; } };
#include <cstdio> #include <iostream> using namespace std; typedef long long ll; const int maxn = 105; // 第i个点左边的标记下标为i,右边的标记下标为i+1 int n, energy[maxn], dp[2 * maxn][2 * maxn] = { 0 }, ans = 0; // #define DEBUG int main() { #ifdef DEBUG freopen("d:\\.in", "r", stdin); freopen("d:\\.out", "w", stdout); #endif cin >> n; for (int i = 0; i < n; ++i) cin >> energy[i]; for (int len = 2; len <= n; ++len) for (int i = 0, j = i + len - 1; j < 2 * n; ++i, ++j) for (int k = i; k < j; ++k) dp[i][j] = max(dp[i][j], dp[i][k] + dp[k + 1][j] + energy[i % n] * energy[(k + 1) % n] * energy[(j + 1) % n]); for (int i = 0; i < n; ++i) ans = max(ans, dp[i][i + n - 1]); cout << ans; return 0; }
/* * File: StataHeader.h * Author: adrianmo * */ #ifndef STATAHEADER_H #define STATAHEADER_H #include <string> #include <stdint.h> #include <map> #include <sstream> using namespace std; #define ST_STRL 32768 #define ST_DOUBLE 65526 #define ST_FLOAT 65527 #define ST_LONG 65528 #define ST_INT 65529 #define ST_BYTE 65530 enum release { R119, R118, R117, R115, R114, R113, R112 }; enum byteOrder { LSF , MSF }; class StataHeader { public: StataHeader(); StataHeader(const StataHeader& orig); uint32_t variables; uint64_t observations; std::string ts; std::string datalabel; enum release fileRelease; enum byteOrder fileByteorder; virtual ~StataHeader(); string showHeader(); private: }; #endif /* STATAHEADER_H */
#include <iostream> using namespace std; int main() { char str[20]; cin >> str; str[4] = '\0' str[7] = '\0' cout << str << "years " << str + 5 << "month " << str + 8 << "days" << endl; return 0; }
#include "uart.h" #include <stdio.h> static void uart_in_hook(struct avr_irq_t * irq, uint32_t value, void * param) { uart* p = (uart*)param; p->fifo_buffer.push(value); } uart::uart(struct avr_t* avr){ // disable the stdio dump, as we are sending binary there uint32_t f = 0; avr_ioctl(avr, AVR_IOCTL_UART_GET_FLAGS('0'), &f); f &= ~AVR_UART_FLAG_STDIO; avr_ioctl(avr, AVR_IOCTL_UART_SET_FLAGS('0'), &f); irq = avr_io_getirq(avr, AVR_IOCTL_UART_GETIRQ('0'), UART_IRQ_OUTPUT); avr_irq_register_notify(irq, uart_in_hook, this); } uart::~uart(){ } int uart::is_empty(){ return fifo_buffer.empty(); } char uart::read_char(){ if(is_empty()) return 0; char p = fifo_buffer.front(); fifo_buffer.pop(); return p; }
/*! * \file KaiXinApp_GetProfileDetail.cpp * \author pengzhixiong@GoZone * \date 2010-10-8 * \brief 解析与UI: 获取用户信息详情 * * \ref CopyRight * =======================================================================<br> * Copyright ? 2010-2012 GOZONE <br> * All Rights Reserved.<br> * The file is generated by Kaixin_Component Wizard for Tranzda Mobile Platform <br> * =======================================================================<br> */ #include "KaiXinAPICommon.h" void* KaiXinAPI_GetProfileDetail_JsonParse(char *text) { cJSON *json; cJSON *pTemp0; tResponseGetProfileDetail* Response = new tResponseGetProfileDetail; memset(Response, 0 , sizeof(tResponseGetProfileDetail)); json = cJSON_Parse(text); pTemp0 = cJSON_GetObjectItem(json,"ret"); if (pTemp0) { Response->ret = pTemp0->valueint; } //Success if(Response->ret == 1) { pTemp0 = cJSON_GetObjectItem(json, "uid"); if(pTemp0) { STRCPY_Ex(Response->uid, pTemp0->valuestring); } pTemp0 = cJSON_GetObjectItem(json, "n"); if(pTemp0) { Response->n = pTemp0->valueint; } pTemp0 = cJSON_GetObjectItem(json, "friends"); if(pTemp0) { int nSize1 = 0, i = 0; nSize1 = cJSON_GetArraySize(pTemp0); Response->nSize_friends = nSize1; if( nSize1 != 0 ) { Response->friends = NULL; Response->friends = (GetProfileDetail_friends*) malloc(sizeof( GetProfileDetail_friends ) * nSize1 ); memset(Response->friends, 0 , sizeof(GetProfileDetail_friends) * nSize1 ); } for ( i = 0; i < nSize1; i++ ) { cJSON *Item1 = NULL, *pTemp1 = NULL; Item1 = cJSON_GetArrayItem(pTemp0,i); pTemp1 = cJSON_GetObjectItem(Item1, "fuid"); if(pTemp1) { Response->friends[i].fuid = pTemp1->valueint; //STRCPY_Ex(Response->friends[i].fuid, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "fname"); if(pTemp1) { STRCPY_Ex(Response->friends[i].fname, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "gender"); if(pTemp1) { Response->friends[i].gender = pTemp1->valueint; } pTemp1 = cJSON_GetObjectItem(Item1, "online"); if(pTemp1) { Response->friends[i].online = pTemp1->valueint; } pTemp1 = cJSON_GetObjectItem(Item1, "py"); if(pTemp1) { int nSize2 = 0, j = 0; nSize2 = cJSON_GetArraySize(pTemp1); Response->friends[i].nSize_py = nSize2; if( nSize2 != 0 ) { Response->friends[i].py = NULL; Response->friends[i].py = (GetProfileDetail_py*) malloc(sizeof( GetProfileDetail_py ) * nSize2 ); memset(Response->friends[i].py, 0 , sizeof(GetProfileDetail_py) * nSize2 ); } for ( j = 0; j < nSize2; j++ ) { cJSON *Item2 = NULL, *pTemp2 = NULL; Item2 = cJSON_GetArrayItem(pTemp1,j); pTemp2 = cJSON_GetObjectItem(Item2, "py"); if(pTemp2) { STRCPY_Ex(Response->friends[i].py[j].py, pTemp2->valuestring); } } } pTemp1 = cJSON_GetObjectItem(Item1, "fpy"); if(pTemp1) { int nSize2 = 0, j = 0; nSize2 = cJSON_GetArraySize(pTemp1); Response->friends[i].nSize_fpy = nSize2; if( nSize2 != 0 ) { Response->friends[i].fpy = NULL; Response->friends[i].fpy = (GetProfileDetail_fpy*) malloc(sizeof( GetProfileDetail_fpy ) * nSize2 ); memset(Response->friends[i].fpy, 0 , sizeof(GetProfileDetail_fpy) * nSize2 ); } for ( j = 0; j < nSize2; j++ ) { cJSON *Item2 = NULL, *pTemp2 = NULL; Item2 = cJSON_GetArrayItem(pTemp1,j); pTemp2 = cJSON_GetObjectItem(Item2, "fpy"); if(pTemp2) { STRCPY_Ex(Response->friends[i].fpy[j].fpy, pTemp2->valuestring); } } } pTemp1 = cJSON_GetObjectItem(Item1, "birthday"); if(pTemp1) { STRCPY_Ex(Response->friends[i].birthday, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "birthdaynew"); if(pTemp1) { STRCPY_Ex(Response->friends[i].birthdaynew, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "stateid"); if(pTemp1) { Response->friends[i].stateid = pTemp1->valueint; } pTemp1 = cJSON_GetObjectItem(Item1, "state"); if(pTemp1) { STRCPY_Ex(Response->friends[i].state, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "statetime"); if(pTemp1) { Response->friends[i].statetime = pTemp1->valueint; } pTemp1 = cJSON_GetObjectItem(Item1, "flogo"); if(pTemp1) { STRCPY_Ex(Response->friends[i].flogo, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "flogo90"); if(pTemp1) { STRCPY_Ex(Response->friends[i].flogo90, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "city"); if(pTemp1) { STRCPY_Ex(Response->friends[i].city, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "hometown"); if(pTemp1) { STRCPY_Ex(Response->friends[i].hometown, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "interest"); if(pTemp1) { STRCPY_Ex(Response->friends[i].interest, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "mobile"); if(pTemp1) { STRCPY_Ex(Response->friends[i].mobile, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "tel"); if(pTemp1) { STRCPY_Ex(Response->friends[i].tel, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "qq"); if(pTemp1) { STRCPY_Ex(Response->friends[i].qq, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "msn"); if(pTemp1) { STRCPY_Ex(Response->friends[i].msn, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "address"); if(pTemp1) { STRCPY_Ex(Response->friends[i].address, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "zip"); if(pTemp1) { STRCPY_Ex(Response->friends[i].zip, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "email"); if(pTemp1) { STRCPY_Ex(Response->friends[i].email, pTemp1->valuestring); } pTemp1 = cJSON_GetObjectItem(Item1, "education"); if(pTemp1) { int nSize2 = 0, j = 0; nSize2 = cJSON_GetArraySize(pTemp1); Response->friends[i].nSize_education = nSize2; if( nSize2 != 0 ) { Response->friends[i].education = NULL; Response->friends[i].education = (GetProfileDetail_education*) malloc(sizeof( GetProfileDetail_education ) * nSize2 ); memset(Response->friends[i].education, 0 , sizeof(GetProfileDetail_education) * nSize2 ); } for ( j = 0; j < nSize2; j++ ) { cJSON *Item2 = NULL, *pTemp2 = NULL; Item2 = cJSON_GetArrayItem(pTemp1,j); pTemp2 = cJSON_GetObjectItem(Item2, "school"); if(pTemp2) { STRCPY_Ex(Response->friends[i].education[j].school, pTemp2->valuestring); } pTemp2 = cJSON_GetObjectItem(Item2, "class"); if(pTemp2) { STRCPY_Ex(Response->friends[i].education[j].classEx, pTemp2->valuestring); } pTemp2 = cJSON_GetObjectItem(Item2, "year"); if(pTemp2) { //Response->friends[i].education[j].year = pTemp2->valueint; STRCPY_Ex(Response->friends[i].education[j].year, pTemp2->valuestring); } } } pTemp1 = cJSON_GetObjectItem(Item1, "career"); if(pTemp1) { int nSize2 = 0, j = 0; nSize2 = cJSON_GetArraySize(pTemp1); Response->friends[i].nSize_career = nSize2; if( nSize2 != 0 ) { Response->friends[i].career = NULL; Response->friends[i].career = (GetProfileDetail_career*) malloc(sizeof( GetProfileDetail_career ) * nSize2 ); memset(Response->friends[i].career, 0 , sizeof(GetProfileDetail_career) * nSize2 ); } for ( j = 0; j < nSize2; j++ ) { cJSON *Item2 = NULL, *pTemp2 = NULL; Item2 = cJSON_GetArrayItem(pTemp1,j); pTemp2 = cJSON_GetObjectItem(Item2, "company"); if(pTemp2) { STRCPY_Ex(Response->friends[i].career[j].company, pTemp2->valuestring); } pTemp2 = cJSON_GetObjectItem(Item2, "dept"); if(pTemp2) { STRCPY_Ex(Response->friends[i].career[j].dept, pTemp2->valuestring); } pTemp2 = cJSON_GetObjectItem(Item2, "beginyear"); if(pTemp2) { //Response->friends[i].career[j].beginyear = pTemp2->valueint; STRCPY_Ex(Response->friends[i].career[j].beginyear, pTemp2->valuestring); } pTemp2 = cJSON_GetObjectItem(Item2, "beginmonth"); if(pTemp2) { //Response->friends[i].career[j].beginmonth = pTemp2->valueint; STRCPY_Ex(Response->friends[i].career[j].beginmonth, pTemp2->valuestring); } pTemp2 = cJSON_GetObjectItem(Item2, "endyear"); if(pTemp2) { //Response->friends[i].career[j].endyear = pTemp2->valueint; STRCPY_Ex(Response->friends[i].career[j].endyear, pTemp2->valuestring); } pTemp2 = cJSON_GetObjectItem(Item2, "endmonth"); if(pTemp2) { //Response->friends[i].career[j].endmonth = pTemp2->valueint; STRCPY_Ex(Response->friends[i].career[j].endmonth, pTemp2->valuestring); } } } } } } //Failue else { //pTemp0 = cJSON_GetObjectItem(json,"msg"); //if (pTemp0) //{ // strcpy(Response->msg, pTemp0 ->valuestring); //} } cJSON_Delete(json); return Response; } // 构造函数 TGetProfileDetailForm::TGetProfileDetailForm(TApplication* pApp):TWindow(pApp) { Response = NULL; pUserImageBmp = NULL; m_BackBtn = -1; Create(APP_KA_ID_UserInfoDetailForm); } // 析构函数 TGetProfileDetailForm::~TGetProfileDetailForm(void) { if( Response ) { delete Response; Response = NULL; } if( pUserImageBmp != NULL) { pUserImageBmp->Destroy(); pUserImageBmp = NULL; } } // 窗口事件处理 Boolean TGetProfileDetailForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; break; } case EVENT_WinClose: { _OnWinClose(pApp, pEvent); break; } case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); TRectangle rcBack(5, 142, 310, 314); this->GetBounds(&rcBack); // 擦除 dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_title_bg), 0, 0, SCR_W, GUI_API_STYLE_ALIGNMENT_LEFT); //dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_bottom_bg), 0, rcBack.Bottom()-68, //320, GUI_API_STYLE_ALIGNMENT_LEFT|GUI_API_STYLE_ALIGNMENT_TOP); pEraseEvent->result = 1; bHandled = TRUE; } break; case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); break; } case EVENT_KeyCommand: { // 抓取右软键事件 if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) { // 模拟退出按钮选中消息 HitControl(m_BackBtn); bHandled = TRUE; } } break; default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; } // 窗口初始化 Boolean TGetProfileDetailForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { //init login form int iRet = eFailed; Response = NULL; iRet = KaiXinAPI_JsonParse(KX_GetProfileDetail, (void **)&Response); m_BackBtn = SetAppBackButton(this); SetAppTilte(this, APP_KA_ID_STRING_DetailInfo); if(iRet == eSucceed) { _SetDataToCtrls(pApp); _SetCoolBarList(pApp); } return TRUE; } // 关闭窗口时,保存设置信息 Boolean TGetProfileDetailForm::_OnWinClose(TApplication * pApp, EventType * pEvent) { return TRUE; } // 控件点击事件处理 Boolean TGetProfileDetailForm::_OnCtrlSelectEvent(TApplication * pApp, EventType * pEvent) { Boolean bHandled; bHandled = FALSE; if(m_BackBtn == pEvent->sParam1) { bHandled = TRUE; this->CloseWindow(); return bHandled; } switch(pEvent->sParam1) { case 0: { break; } default: break; } return bHandled; } void TGetProfileDetailForm::_SetDataToCtrls(TApplication* pApp) { if(this->Response && Response->nSize_friends != 0) { TFont objFontType; TUChar pszState[1024] = {0}; TUChar pszStateTime[32] = {0}; TUChar pszLogoPath[256] = {0}; TUChar pszUserName[32] = {0}; TRectangle Rc_Temp; TRectangle rect; //用户头像 TMaskButton* pHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_UserDetailHeadMaskButton)); if(pHeadMBtn) { TRectangle rc; TBitmap* pDownLoadBitmap = NULL; TUString::StrUtf8ToStrUnicode(pszLogoPath, (Char*)KaiXinUserInfo.logoPath); pDownLoadBitmap = LoadImgByPath(pszLogoPath); pHeadMBtn->GetBounds(&rc); pHeadMBtn->SetEnabled(FALSE); pHeadMBtn->SetCaption(TUSTR_Kx_NULL,0,0); if(pDownLoadBitmap != NULL) { pUserImageBmp = TBitmap::Create(PHOTO_W, PHOTO_H, pDownLoadBitmap->GetDepth()); pUserImageBmp->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); pHeadMBtn->SetImage(pUserImageBmp,(rc.Width()-pUserImageBmp->GetWidth())/2, (rc.Height()-pUserImageBmp->GetHeight())/2); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } else { const TBitmap * pBmp = TResource::LoadConstBitmap(APP_KA_ID_BITMAP_Default); pHeadMBtn->GetBounds(&rc); pHeadMBtn->SetEnabled(FALSE); pHeadMBtn->SetCaption(TUSTR_Kx_NULL,0,0); pHeadMBtn->SetImage(pBmp,(rc.Width()-pBmp->GetWidth())/2, (rc.Height()-pBmp->GetHeight())/2); } } //用户名 TRichView *pUserName = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_NameLbl)); if(pUserName) { TUString::StrUtf8ToStrUnicode(pszUserName , (const Char *)Response->friends[0].fname); objFontType = pUserName->GetFont(); objFontType.Create(FONT_LARGE_NAME, FONT_LARGE_NAME); pUserName->SetFont(objFontType); pUserName->SetColor(CTL_COLOR_TYPE_FORE, RGB(67, 67, 135)); pUserName->SetTransparent(TRUE); pUserName->SetCaption(pszUserName, FALSE); pUserName->SetEnabled(TRUE); } //用户状态 TPanel*pPanel = static_cast<TPanel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_StateContPanel)); TRichView* pRichView = new TRichView(); Int32 nRichViewId = 0; if(pRichView->Create(pPanel)) { TRectangle obBtnRec(0,0,0,0); pPanel->GetBounds(&obBtnRec); obBtnRec.SetX(0); obBtnRec.SetY(0); pRichView->SetBounds(&obBtnRec); TUString::StrUtf8ToStrUnicode(pszState, (Char*)Response->friends[0].state); objFontType = pRichView->GetFont(); objFontType.Create(FONT_STATE, FONT_STATE); pRichView->SetFont(objFontType); pRichView->SetCaption(pszState,FALSE); pRichView->SetEnabled(FALSE); pRichView->SetWordWrapAttr(TRUE); pRichView->SetTransparent(TRUE); pRichView->SetScrollBarMode(CTL_SCL_MODE_NONE); pRichView->SetUnderLine(TRUE); Int32 nLineCount = pRichView->GetLinesCount(); if(nLineCount <7) nLineCount = 7; pRichView->SetMaxVisibleLines(nLineCount, TRUE); } //状态更新时间 TRichView* pStateTime = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_StateTimeLbl)); if(pStateTime) { objFontType = pStateTime->GetFont(); objFontType.Create(FONT_OTHER_INFO, FONT_OTHER_INFO); pStateTime->SetFont(objFontType); pStateTime->SetColor(CTL_COLOR_TYPE_FORE, RGB_COLOR_GRAY); pStateTime->SetTransparent(TRUE); //pStateTime->SetCaption(pszStateTime, FALSE); pStateTime->SetEnabled(TRUE); if(strcmp(Response->friends[0].state,"")==0) { TUString::StrCat(pszStateTime, TUSTR_Kx_Left_Parenthesis); TUString::StrCat(pszStateTime, TResource::LoadConstString(APP_KA_ID_STRING_NoState)); TUString::StrCat(pszStateTime, TUSTR_Kx_Right_Parenthesis); pStateTime->SetCaption(pszStateTime, FALSE); } else { TUChar* pszDateTime = NULL; cUnixTime_ConvertUnixTimeToFormatString( Response->friends[0].statetime, KX_TIME_FORMAT_YY_MM_DD, &pszDateTime ); if(pszDateTime != NULL) { TUString::StrCat(pszStateTime, TUSTR_Kx_Left_Parenthesis); TUString::StrCat(pszStateTime, pszDateTime); TUString::StrCat(pszStateTime, TUSTR_Kx_Right_Parenthesis); } pStateTime->SetCaption(pszStateTime, FALSE); if(pszDateTime != NULL) { delete pszDateTime; pszDateTime = NULL; } } } //Set InfoCoolBar Ctrls data //基本信息 objFontType.Create(14, 14); /*"性别"*/ TLabel* pGenderLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_GenderLbl)); TLabel* pGenderValueLble = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_GenderValueLbl)); if(pGenderLbl) { pGenderLbl->SetFont(objFontType); pGenderLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pGenderValueLble) { pGenderValueLble->SetFont(objFontType); if(Response->friends[0].gender == 1) { pGenderValueLble->SetCaption(TResource::LoadConstString(APP_KA_ID_STRING_Female),FALSE); } else { pGenderValueLble->SetCaption(TResource::LoadConstString(APP_KA_ID_STRING_Male),FALSE); } } /*"出生日期"*/ TUChar pszBirthdayValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszBirthdayValue , (const Char *)Response->friends[0].birthday); TLabel* pBirthdayLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_BirthdayLbl)); TLabel* pBirthdayValueLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_BirthdayValueLbl)); if(pBirthdayLbl) { pBirthdayLbl->SetFont(objFontType); pBirthdayLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pBirthdayValueLbl) { pBirthdayValueLbl->SetFont(objFontType); pBirthdayValueLbl->SetCaption(pszBirthdayValue,FALSE); } /*"现居住地"*/ TUChar pszCityValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszCityValue , (const Char *)Response->friends[0].city); TLabel* pCityLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CityLbl)); TRichView* pCityValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CityValueView)); if(pCityLbl) { pCityLbl->SetFont(objFontType); pCityLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pCityValueView) { pCityValueView->SetCaption(pszCityValue,FALSE); pCityValueView->SetFont(objFontType); pCityValueView->SetWordWrapAttr(TRUE); pCityValueView->SetTransparent(TRUE); pCityValueView->SetEnabled(FALSE); pCityValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pCityValueView->SetMaxVisibleLines(pCityValueView->GetLinesCount(), TRUE); pCityValueView->GetBounds(&Rc_Temp); } /*" 家乡"*/ TUChar pszHomeTownValue[256*3] = {0}; TUString::StrUtf8ToStrUnicode(pszHomeTownValue , (const Char *)Response->friends[0].hometown); TLabel* pHomeTownLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_HomeTownLbl)); TRichView* pHomeTownValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_HomeTownValueView)); if(pHomeTownLbl) { pHomeTownLbl->SetFont(objFontType); pHomeTownLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pHomeTownValueView) { pHomeTownValueView->SetCaption(pszHomeTownValue,FALSE); pHomeTownValueView->SetFont(objFontType); pHomeTownValueView->SetWordWrapAttr(TRUE); pHomeTownValueView->SetTransparent(TRUE); pHomeTownValueView->SetEnabled(FALSE); pHomeTownValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pHomeTownValueView->SetMaxVisibleLines(pHomeTownValueView->GetLinesCount(), TRUE); pHomeTownValueView->GetBounds(&Rc_Temp); } /*"兴趣爱好"*/ TUChar pszInterestValue[1024*3] = {0}; TUString::StrUtf8ToStrUnicode(pszInterestValue , (const Char *)Response->friends[0].interest); TLabel* pInterestLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_InterestLbl)); TRichView* pInterestValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_InterestValueView)); if(pInterestLbl) { pInterestLbl->SetFont(objFontType); pInterestLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pInterestValueView) { pInterestValueView->SetCaption(pszInterestValue,FALSE); pInterestValueView->SetFont(objFontType); pInterestValueView->SetWordWrapAttr(TRUE); pInterestValueView->SetTransparent(TRUE); pInterestValueView->SetEnabled(FALSE); pInterestValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pInterestValueView->SetMaxVisibleLines(pInterestValueView->GetLinesCount(), TRUE); pInterestValueView->GetBounds(&Rc_Temp); } //其他信息 /*"手机"*/ TUChar pszMobileValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszMobileValue , (const Char *)Response->friends[0].mobile); TLabel* pMobileLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MobileLbl)); TRichView* pMobileValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MobileValueView)); if(pMobileLbl) { pMobileLbl->SetFont(objFontType); pMobileLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pMobileValueView) { pMobileValueView->SetCaption(pszMobileValue,FALSE); pMobileValueView->SetFont(objFontType); pMobileValueView->SetWordWrapAttr(TRUE); pMobileValueView->SetTransparent(TRUE); pMobileValueView->SetEnabled(FALSE); pMobileValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pMobileValueView->SetMaxVisibleLines(pMobileValueView->GetLinesCount(), TRUE); pMobileValueView->GetBounds(&Rc_Temp); } /*"电话"*/ TUChar pszTelValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszTelValue , (const Char *)Response->friends[0].tel); TLabel* pTelLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_TelLbl)); TRichView* pTelValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_TelValueView)); if(pTelLbl) { pTelLbl->SetFont(objFontType); pTelLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pTelValueView) { pTelValueView->SetCaption(pszTelValue,FALSE); pTelValueView->SetFont(objFontType); pTelValueView->SetWordWrapAttr(TRUE); pTelValueView->SetTransparent(TRUE); pTelValueView->SetEnabled(FALSE); pTelValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pTelValueView->SetMaxVisibleLines(pTelValueView->GetLinesCount(), TRUE); pTelValueView->GetBounds(&Rc_Temp); } /*"QQ号"*/ TUChar pszQQValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszQQValue , (const Char *)Response->friends[0].qq); TLabel* pQQLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_QQLbl)); TRichView* pQQValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_QQValueView)); if(pQQLbl) { pQQLbl->SetFont(objFontType); pQQLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pQQValueView) { pQQValueView->SetCaption(pszQQValue,FALSE); pQQValueView->SetFont(objFontType); pQQValueView->SetWordWrapAttr(TRUE); pQQValueView->SetTransparent(TRUE); pQQValueView->SetEnabled(FALSE); pQQValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pQQValueView->SetMaxVisibleLines(pQQValueView->GetLinesCount(), TRUE); pQQValueView->GetBounds(&Rc_Temp); } /*"MSN账号"*/ TUChar pszMSNValue[128] = {0}; TUString::StrUtf8ToStrUnicode(pszMSNValue , (const Char *)Response->friends[0].msn); TLabel* pMSNLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MSNLbl)); TRichView* pMSNValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MSNValueView)); if(pMSNLbl) { pMSNLbl->SetFont(objFontType); pMSNLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pMSNValueView) { pMSNValueView->SetCaption(pszMSNValue,FALSE); pMSNValueView->SetFont(objFontType); pMSNValueView->SetWordWrapAttr(TRUE); pMSNValueView->SetTransparent(TRUE); pMSNValueView->SetEnabled(FALSE); pMSNValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pMSNValueView->SetMaxVisibleLines(pMSNValueView->GetLinesCount(), TRUE); } /*"地址"*/ TUChar pszAddressValue[1024] = {0}; TUString::StrUtf8ToStrUnicode(pszAddressValue , (const Char *)Response->friends[0].address); TLabel* pAddressLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_AddressLbl)); TRichView* pAddressValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_AddressValueView)); if(pAddressLbl) { pAddressLbl->SetFont(objFontType); pAddressLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pAddressValueView) { pAddressValueView->SetCaption(pszAddressValue,FALSE); pAddressValueView->SetFont(objFontType); pAddressValueView->SetWordWrapAttr(TRUE); pAddressValueView->SetTransparent(TRUE); pAddressValueView->SetEnabled(FALSE); pAddressValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pAddressValueView->SetMaxVisibleLines(pAddressValueView->GetLinesCount(), TRUE); pAddressValueView->GetBounds(&Rc_Temp); } /*"邮编"*/ TUChar pszZipValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszZipValue , (const Char *)Response->friends[0].zip); TLabel* pZipLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_ZipLbl)); TRichView* pZipValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_ZipValueView)); if(pZipLbl) { pZipLbl->SetFont(objFontType); pZipLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pZipValueView) { pZipValueView->SetCaption(pszZipValue,FALSE); pZipValueView->SetFont(objFontType); pZipValueView->SetWordWrapAttr(TRUE); pZipValueView->SetTransparent(TRUE); pZipValueView->SetEnabled(FALSE); pZipValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pZipValueView->SetMaxVisibleLines(pZipValueView->GetLinesCount(), TRUE); pZipValueView->GetBounds(&Rc_Temp); } /*"电子邮件"*/ TUChar pszEmailValue[128] = {0}; TUString::StrUtf8ToStrUnicode(pszEmailValue , (const Char *)Response->friends[0].email); TLabel* pEmailLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EmailLbl)); TRichView* pEmailValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EmailValueView)); if(pEmailLbl) { pEmailLbl->SetFont(objFontType); pEmailLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pEmailValueView) { pEmailValueView->SetCaption(pszEmailValue,FALSE); pEmailValueView->SetFont(objFontType); pEmailValueView->SetWordWrapAttr(TRUE); pEmailValueView->SetTransparent(TRUE); pEmailValueView->SetEnabled(FALSE); pEmailValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pEmailValueView->SetMaxVisibleLines(pEmailValueView->GetLinesCount(), TRUE); pEmailValueView->GetBounds(&Rc_Temp); } /*"教育背景"*/ TUChar pszEduValue[1024] = {0}; for(int i=0; i<Response->friends[0].nSize_education; i++) { TUChar pszTemp[128*3] = {0}; TUChar pszYear[32] = {0}; //院校名 TUString::StrUtf8ToStrUnicode(pszTemp , (const Char *)Response->friends[0].education[i].school); TUString::StrCat(pszEduValue,pszTemp); TUString::StrCat(pszEduValue, TUSTR_Kx_Empty_Cell); //班级 TUString::StrUtf8ToStrUnicode(pszTemp , (const Char *)Response->friends[0].education[i].classEx); TUString::StrCat(pszEduValue,pszTemp); TUString::StrCat(pszEduValue, TUSTR_Kx_Empty_Cell); //届 TUString::StrUtf8ToStrUnicode(pszYear , (const Char *)Response->friends[0].education[i].year); TUString::StrCat(pszEduValue,pszYear); TUString::StrCat(pszEduValue, (const TUChar*)TUSTR_Kx_Newline_Character); } TLabel* pEduLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EduLbl)); TRichView* pEduValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EduValueView)); if(pEduLbl) { pEduLbl->SetFont(objFontType); pEduLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pEduValueView) { pEduValueView->SetCaption(pszEduValue,FALSE); pEduValueView->SetFont(objFontType); pEduValueView->SetWordWrapAttr(TRUE); pEduValueView->SetTransparent(TRUE); pEduValueView->SetEnabled(FALSE); pEduValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pEduValueView->SetMaxVisibleLines(pEduValueView->GetLinesCount(), TRUE); pEduValueView->GetBounds(&Rc_Temp); } /*"工作经历"*/ TUChar pszCareerValue[1024] = {0}; for(int i=0; i<Response->friends[0].nSize_career; i++) { TUChar pszTemp[128*3] = {0}; TUChar pszYear[8] = {0}; TUChar pszMonth[8] = {0}; //公司名 TUString::StrUtf8ToStrUnicode(pszTemp , (const Char *)Response->friends[0].career[i].company); TUString::StrCat(pszCareerValue,pszTemp); TUString::StrCat(pszCareerValue, TUSTR_Kx_Empty_Cell); //部门名 TUString::StrUtf8ToStrUnicode(pszTemp , (const Char *)Response->friends[0].career[i].dept); TUString::StrCat(pszCareerValue,pszTemp); TUString::StrCat(pszCareerValue, TUSTR_Kx_Empty_Cell); //开始年月 TUString::StrUtf8ToStrUnicode(pszYear , (const Char *)Response->friends[0].career[i].beginyear); TUString::StrCat(pszCareerValue,pszYear); TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Year)); TUString::StrUtf8ToStrUnicode(pszMonth , (const Char *)Response->friends[0].career[i].beginmonth); TUString::StrCat(pszCareerValue,pszMonth); TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Month)); //分隔符- TUString::StrCat(pszCareerValue, TUSTR_Kx_Separator); //结束年月 TUString::StrUtf8ToStrUnicode(pszYear , (const Char *)Response->friends[0].career[i].endyear); if(TUString::StrLen(pszYear)==0) { TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Now)); } else { TUString::StrCat(pszCareerValue,pszYear); TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Year)); TUString::StrUtf8ToStrUnicode(pszMonth , (const Char *)Response->friends[0].career[i].endmonth); TUString::StrCat(pszCareerValue,pszMonth); TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Month)); } TUString::StrCat(pszCareerValue, (const TUChar*)TUSTR_Kx_Newline_Character); } TLabel* pCareerLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CareerLbl)); TRichView* pCareerValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CareerValueView)); if(pCareerLbl) { pCareerLbl->SetFont(objFontType); pCareerLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pCareerValueView) { pCareerValueView->SetCaption(pszCareerValue,FALSE); pCareerValueView->SetFont(objFontType); pCareerValueView->SetWordWrapAttr(TRUE); pCareerValueView->SetTransparent(TRUE); pCareerValueView->SetEnabled(FALSE); pCareerValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pCareerValueView->SetMaxVisibleLines(pCareerValueView->GetLinesCount(), TRUE); pCareerValueView->GetBounds(&Rc_Temp); } } } Int32 TGetProfileDetailForm::_SetCoolBarList(TApplication* pApp) { TBarRowList *lpRowList = NULL; TBarRow *lpRow = NULL; TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_InfoCoolBarList)); if (pCoolBarList) { #if 0 TRectangle rc; Int32 oldTop = 0; pCoolBarList->GetBounds(&rc); oldTop = rc.Y(); pCoolBarList->SetBounds(RC_LIST_NORMAL); pCoolBarList->GetBounds(&rc); rc.SetRect(rc.X(),oldTop,rc.Width(),rc.Height()); pCoolBarList->SetBounds(&rc); #endif TBarListItem* lpItem = NULL; lpRowList = pCoolBarList->Rows(); if (lpRowList) { lpRowList->BeginUpdate(); for(int i=0; i < lpRowList->Count(); i++) { lpRow = lpRowList->GetRow(i); if(lpRow) { for(int j = 0; j < lpRow->Count(); j++) { lpItem = lpRow->GetItem(j); if(lpItem) { Int32 ItemHeight = 60;//设置详情列表默认高度为60 lpItem->SetCaption(NULL); lpItem->SetIndicatorType(itNone); lpItem->SetHeight(ItemHeight); } } } } //取第一行的特别item,调整高度 lpRow = lpRowList->GetRow(0); if(lpRow) { TRectangle Rc_Temp; //HomeTown lpItem = lpRow->GetItem(3); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_HomeTownValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } } //取第二行的特别item,调整高度 lpRow = lpRowList->GetRow(1); if(lpRow) { TRectangle Rc_Temp; //MSN lpItem = lpRow->GetItem(3); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MSNValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } //email lpItem = lpRow->GetItem(6); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EmailValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } //教育背景 lpItem = lpRow->GetItem(7); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EduValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } //工作经历 lpItem = lpRow->GetItem(8); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CareerValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } } lpRowList->EndUpdate(); } } return TRUE; }
#include "FFVideoPlyer.h" #include <QFileDialog> #include <QMessageBox> #include <iostream> #include <list> #include "MyFFmpeg.h" #include <WinUser.h> #include <QMenuBar> #include <QTextCodec> #include <QTextStream> #include <QtCore> #include <QSound> #include<QRadioButton> #include"safety.h" #pragma comment(lib, "User32.lib") using namespace std; vector<QRadioButton*> radioGroup; FFVideoPlyer::FFVideoPlyer(QWidget *parent) : QMainWindow(parent),ui(new Ui::FFVideoPlyerClass) { ui->setupUi(this); // QStatusBar* status = new QStatusBar(this); MSafety *safe=new MSafety(); m_ffmpeg=new MyFFmpeg(); m_Thread=new PlayThread(m_ffmpeg); m_Thread->start(); imgThread=new imgDealThread(m_ffmpeg,ui->spinBoxFPS,ui->checkDeal); imgThread->start(); showTimer=new QTimer(); connect(showTimer, SIGNAL(timeout()), this, SLOT(showInfo())); connect(imgThread,SIGNAL(dectSignal()),this,SLOT(dectSlot())); showTimer->start(250); ui->openGLWidget->setImgTread(imgThread); #ifndef MDEBUG ui->btn_openImg->setVisible(false); ui->btn_openVideo->setVisible(false); ui->btn_REC->setVisible(false); #endif radioGroup.push_back(ui->radioButton_1); radioGroup.push_back(ui->radioButton_2); radioGroup.push_back(ui->radioButton_3); radioGroup.push_back(ui->radioButton_4); radioGroup.push_back(ui->radioButton_5); radioGroup.push_back(ui->radioButton_6); radioGroup.push_back(ui->radioButton_7); radioGroup.push_back(ui->radioButton_8); radioGroup.push_back(ui->radioButton_9); QMenu *serralMenu = menuBar()->addMenu(QString::fromLocal8Bit("选项")); QAction *actionSave = new QAction(QStringLiteral("保存当前设置"), this); serralMenu->addAction(actionSave); connect(actionSave, SIGNAL(triggered()), this, SLOT(saveSettings())); readSettings(); } FFVideoPlyer::~FFVideoPlyer() { // delete showTimer; // delete m_Thread; // delete imgThread; // delete m_ffmpeg;不要加析构函数,否者无法彻底退出程序 // delete ui; } void FFVideoPlyer::on_btn_openURL_clicked() { QString url=ui->lineEditURL->text(); if (url.isEmpty()) { return; } // if(m_ffmpeg->m_isPlay) // { // disconnect(showTimer, SIGNAL(timeout()), this, SLOT(showInfo())); // delete m_ffmpeg; // delete m_Thread; // delete imgThread; // delete showTimer; // m_ffmpeg=new MyFFmpeg(); // m_Thread=new PlayThread(m_ffmpeg); // m_Thread->start(); // imgThread=new imgDealThread(m_ffmpeg); // imgThread->start(); // showTimer=new QTimer(); // connect(showTimer, SIGNAL(timeout()), this, SLOT(showInfo())); // showTimer->start(250); // } if(m_ffmpeg->OpenVideo( url.toLocal8Bit().data() ) ==0) { ui->btn_openURL->setEnabled(false); ui->spinBoxFPS->setMaximum((int)(m_ffmpeg->m_FPS.num/m_ffmpeg->m_FPS.den)); imgThread->spotP.x=m_ffmpeg->m_width*BLOOD_X; imgThread->spotP.y=m_ffmpeg->m_height*BLOOD_Y; } } void FFVideoPlyer::showInfo() { if(m_ffmpeg->m_FPS.den) ui->label_FPS->setText(QString::fromUtf8("FPS:")+QString::number((double)(m_ffmpeg->m_FPS.num/m_ffmpeg->m_FPS.den))); ui->label_cache->setText(QString::fromLocal8Bit("缓存帧:")+QString::number(m_ffmpeg->rgbList.size())); } void FFVideoPlyer::on_btn_REC_clicked() { if(imgThread==NULL) return; if(ui->btn_REC->text()=="REC") { imgThread->saveFlag=true; ui->btn_REC->setText("stop"); } else if(ui->btn_REC->text()=="stop") { imgThread->saveFlag=false; ui->btn_REC->setText("REC"); } } void FFVideoPlyer::on_checkShow_clicked() { imgThread->pushShowPic=ui->checkShow->checkState(); } void FFVideoPlyer::on_btn_openVideo_clicked() { QString filename = QFileDialog::getOpenFileName(this,tr("Open video"),"..", tr("Video File (*.flv *.rmvb *.avi)")); if (filename.isEmpty()) return; int ret=m_ffmpeg->OpenVideo( filename.toLocal8Bit().data() ); if(!ret) { imgThread->spotP.x=m_ffmpeg->m_width*BLOOD_X; imgThread->spotP.y=m_ffmpeg->m_height*BLOOD_Y; } } void FFVideoPlyer::on_btn_openImg_clicked() { QString filename = QFileDialog::getOpenFileName(this, tr("Open Image"), "..", tr("Image File (*.jpg *.png *.bmp)")); if (filename.isEmpty()) return; std::string name = string((const char *)filename.toLocal8Bit()); imgThread->picDetect(name); } void FFVideoPlyer::dectSlot() { // char key; // if(ui->radioButton_1->isChecked()) // key='1'; // else if(ui->radioButton_2->isChecked()) // key='2'; // else if(ui->radioButton_3->isChecked()) // key='3'; // else if(ui->radioButton_4->isChecked()) // key='4'; // else if(ui->radioButton_5->isChecked()) // key='5'; // else if(ui->radioButton_6->isChecked()) // key='6'; // else if(ui->radioButton_7->isChecked()) // key='7'; // else if(ui->radioButton_8->isChecked()) // key='8'; // else if(ui->radioButton_9->isChecked()) // key='9'; // keybd_event(key,0,0,0); // keybd_event(key,0,KEYEVENTF_KEYUP,0); QSound::play(":/res/sound/8859.wav"); } void FFVideoPlyer::saveSettings() { // QSound::play(LOSE_SOUND); QFile file("param.info"); if (file.open(QFile::WriteOnly))//|QFile::Text { QTextStream out(&file); out << ui->lineEditURL->text() << endl; out << ui->spinBoxFPS->value() << endl; out << ui->radioButton_1->isChecked()<<endl; out << ui->radioButton_2->isChecked()<<endl; out << ui->radioButton_3->isChecked()<<endl; out << ui->radioButton_4->isChecked()<<endl; out << ui->radioButton_5->isChecked()<<endl; out << ui->radioButton_6->isChecked()<<endl; out << ui->radioButton_7->isChecked()<<endl; out << ui->radioButton_8->isChecked()<<endl; out << ui->radioButton_9->isChecked()<<endl; file.close(); } } void FFVideoPlyer::readSettings() { QFile file("param.info"); if (file.open(QFile::ReadOnly))//|QFile::Text { QString url=(QString)(file.readLine()); if(!url.isEmpty()) url.remove(url.size()-1,1); ui->lineEditURL->setText(url); ui->spinBoxFPS->setValue(((QString)(file.readLine())).toInt()); if(((QString)(file.readLine())).toInt()) ui->radioButton_1->setChecked(true); if(((QString)(file.readLine())).toInt()) ui->radioButton_2->setChecked(true); if(((QString)(file.readLine())).toInt()) ui->radioButton_3->setChecked(true); if(((QString)(file.readLine())).toInt()) ui->radioButton_4->setChecked(true); if(((QString)(file.readLine())).toInt()) ui->radioButton_5->setChecked(true); if(((QString)(file.readLine())).toInt()) ui->radioButton_6->setChecked(true); if(((QString)(file.readLine())).toInt()) ui->radioButton_7->setChecked(true); if(((QString)(file.readLine())).toInt()) ui->radioButton_8->setChecked(true); if(((QString)(file.readLine())).toInt()) ui->radioButton_9->setChecked(true); file.close(); } } void FFVideoPlyer::on_btn_UP_clicked() { if(imgThread->spotP.y>0) --imgThread->spotP.y; } void FFVideoPlyer::on_btn_Down_clicked() { if(imgThread->spotP.y<m_ffmpeg->m_height-1) ++imgThread->spotP.y; } void FFVideoPlyer::on_btn_Left_clicked() { if(imgThread->spotP.x>0) --imgThread->spotP.x; } void FFVideoPlyer::on_btn_Right_clicked() { if(imgThread->spotP.x<m_ffmpeg->m_width-1) ++imgThread->spotP.x; }
#ifndef SHADERTYPE_H #define SHADERTYPE_H namespace revel { namespace renderer { enum class ShaderType { VERTEX, FRAGMENT, GEOMETRY, TESS_EVALUATION, TESS_CONTROL, UNKNOWN }; } // ::revel::renderer } // ::revel #endif // SHADERTYPE_H
/*! * \file * \author David Saxon * \brief Inline definitions for internal UTF-8 utility functions. * * \copyright Copyright (c) 2018, The Arcane Initiative * All rights reserved. * * \license BSD 3-Clause License * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef DEUS_UNICODEVIEWIMPL_UTF8UTIL_INL_ #define DEUS_UNICODEVIEWIMPL_UTF8UTIL_INL_ namespace deus { DEUS_VERSION_NS_BEGIN namespace utf8_inl { // this performs the same functionality as size_of_symbol, expect it just // returns the number of bytes of the symbol contained at the start of the given // data. This means internal functions can use this version the avoid any extra // overhead and/or cyclic calls DEUS_FORCE_INLINE std::size_t bytes_in_symbol(const char* symbol_data) { if((*symbol_data & 0x80) == 0) { return 1; } if((*symbol_data & 0xE0) == 0xC0) { return 2; } if((*symbol_data & 0xF0) == 0xE0) { return 3; } return 4; } static std::vector<unsigned char> build_jump_table() { std::vector<unsigned char> jump_table(16, 1); jump_table[12] = 2; jump_table[13] = 2; jump_table[14] = 3; jump_table[15] = 4; return jump_table; } // table that can be used to look up how many bytes to jump to the next symbol // for the given bytes static std::vector<unsigned char> g_jump_table = build_jump_table(); } // namespace utf8_inl DEUS_VERSION_NS_END } // namespace deus #endif
// // Created by Terry on 15/9/11. // #ifndef AI_WORD_H #define AI_WORD_H #include "utfstring.h" #include <string> using namespace std; class word { public: utfstring *utfword; char *word_type; bool is_new_char; double word_probability; public: word(utfstring *a_utfword); word(utfstring *a_utfword, char *a_word_type, double a_word_probability); ~word(); }; #endif //AI_WORD_H
#include<bits/stdc++.h> using namespace std; bool compare(pair<int,double> a,pair<int,double> b) { return a.second > b.second; } double knapsack(int n,int W,int* weight,int* value) { if(n==0 || W==0) { return 0; } double* temp = new double[n]; for(int i=0;i<n;i++) { temp[i]=(double)value[i]/weight[i]; } vector<pair<int,double>> temp2(n); for(int i=0;i<n;i++) { temp2[i]=make_pair(weight[i],temp[i]); } sort(temp2.begin(),temp2.end(),compare); double total = 0; for(int i=0;i<n;i++) { if(temp2[i].first <= W) { double ani = temp2[i].first*temp2[i].second; W = W - temp2[i].first; total+=ani; } else { double ani = temp2[i].second*W; W=0; total+=ani; break; } } return total; } int main() { int n,W; cin >> n; int* value = new int[n]; int* weight = new int[n]; cin >> W; for(int i=0;i<n;i++) { cin >> weight[i]; } for(int i=0;i<n;i++) { cin >> value[i]; } cout << knapsack(n,W,weight,value) << endl; }
//inicializace knihoven #include <ThingSpeak.h> #include <ESP8266WiFi.h> #include <Wire.h> #include <HTU21D.h> HTU21D myHTU21D(HTU21D_RES_RH12_TEMP14); //jménoa heslo k wifi const char* ssid = "IoT"; const char* pass = "17091991"; //číslo kanálu na thingspeaku najdete jako channel ID, jeto 6 místné číslo, to napište místo nul unsigned long myChannelNumber = 1327277; //API Keys - Write API Key (16 znaků) const char* myWriteAPIKey = "2O02CL15KHBU7RY0"; //definujeme si jednu sekundu, tedy 1000 ms const int second = 1000; //definujeme si interval prodlevy - číslem násobíme sekundu, tj. kolik sekund chceme čekat //minimální prodleva je 20s, menší prodlevu thingspeak neumožňuje unsigned const int interval = 20*second; /*teď ještě knihovna WiFiClient pro vytvoření klienta * klient je to, co se připojí k zařízení * když třeba hledáte něco na googlu, tak vy jste klient * v našem případě je klient thingspeak a připojuje se na naše zařízení, uvidíte níže v kódu */ WiFiClient client; //metoda připojení k wifi, vrací logickou hodnotu, kterou informuje o úspěšnosti připojení boolean connectWiFi(){ //vypíše na seriovy monitor že probíhá inicializace wifi Serial.println("Connecting to WiFi."); delay(10); //nastavení persistence - zařízení nebude hledat již použité WiFi sítě WiFi.persistent(false); //připojí se k wifi s daným ssid a heslem WiFi.begin(ssid, pass); //čítač opakování připojení int count = 0; //cyklus běží, dokud status wifi není "připojeno", jakmile se připojí, vyskočí z cyklu while (WiFi.status() != WL_CONNECTED) { //pokud je počet opakování připojení menší než 15 if(count < 15){ //vypíše tečku na seriový monitor, tečka znamená neúspěšné připojení, progress Serial.print("."); //počká půl sekundy delay(500); } else{ //jinak vypíše že připojení selhalo Serial.println(""); Serial.println("Connection to WiFi failed. :( "); //ukončí metodu a vrátí false return false; } //inkrementuje čítač count++; } //informuje o úspěšném připojení Serial.println(""); Serial.println("WiFi connection successful. :) "); //ukončí metodu a vrátí true return true; } //metoda pro odeslání hodnot na thingspeak, vrací logickou hodnotu o povedeném nebo nepovedeném odeslání boolean sendToThingspeak(){ // write to the ThingSpeak channel, proměnná x je hodnota číselného kodu http, jímž se ověřuje správnost odesílacího požadavku int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); if(x == 200){ Serial.println("Channel update successful."); return true; } else{ Serial.println("Problem updating channel. HTTP error code " + String(x)); return false; } } void setup() { //inicializace sériové komunikace pro stavové hlášení Serial.begin(9600); delay(2000); Serial.println("Sériová komunikace funguje"); //kontroluje, že je čidlo správně zapojené a funguje while (myHTU21D.begin() != true) { Serial.println(F("HTU21D, SHT21 snímač selhal nebo není připojen")); delay(5000); } Serial.println(F("HTU21D, SHT21 snímač je aktivní")); //nastavíme wifi jako klienta, zde je klientem myšleno naše zařízení, které se připojuje k síti wifi jako klient WiFi.mode(WIFI_STA); //a inicializujeme thingspeak, abychom s ním mohli komunikovat, předáváme mu wifi klienta ThingSpeak.begin(client); //připojíme se k wifi connectWiFi(); } void loop() { //pokud je wifi odpojena, znovu ji připojíme if(WiFi.status() != WL_CONNECTED){ connectWiFi(); } //z čidel si do proměnných načteme hodnoty float teplota = myHTU21D.readTemperature(); float vlhkost = myHTU21D.readHumidity(); ThingSpeak.setField(1, teplota); ThingSpeak.setField(2, vlhkost); //odešleme hodnoty polí na thingspeak sendToThingspeak(); //počká interval delay(interval); }
#include "platform.h" #include "script-functype.h" #include <map> #include <string.h> #include <math.h> #include <stdio.h> #include <ctype.h> namespace Script { namespace mdpx { #define DEFINE_FUNC(__params, __type, __name) s_fnmap[ std::string(#__name) ] = s_efnmap[__type] = FuncInfo{#__name, __type, FUNCTION ## __params} ; #define DEFINE_OP(__params, __type, __name) s_fnmap[ std::string(#__name) ] = s_efnmap[__type] = FuncInfo{#__name, __type, FUNCTION ## __params} ; #define DEFINE_TOKEN(__token, __type, __name) s_fnmap[ std::string(#__name) ] = s_efnmap[__type] = FuncInfo{#__name, __type, __token} ; struct FuncInfo { const char *name; FuncType type; TokenType token; }; static std::map<std::string, FuncInfo> s_fnmap; static std::map<FuncType, FuncInfo> s_efnmap; const char * GetFuncName(FuncType fn) { auto it = s_efnmap.find(fn); if (it != s_efnmap.end()) { return it->second.name; } return "<unknown>"; } static void AddAlias(const char *a, const char *b) { auto it = s_fnmap.find(b); if (it != s_fnmap.end()) { FuncInfo fi = it->second; s_fnmap[a] = fi; } } static void RegisterFunctions( ) { if (!s_fnmap.empty()) return; DEFINE_OP(2,FN_ASSIGN, =) DEFINE_OP(2,FN_MULTIPLY, *) DEFINE_OP(2,FN_DIVIDE , /) DEFINE_OP(2,FN_MODULO , %) DEFINE_OP(2,FN_ADD , + ) DEFINE_OP(2,FN_SUB , - ) DEFINE_OP(2,FN_BITWISE_AND , & ) DEFINE_OP(2,FN_BITWISE_OR , | ) DEFINE_FUNC(2,FN_BITWISE_AND , bitwise_and ) DEFINE_FUNC(2,FN_BITWISE_OR , bitwise_or ) DEFINE_FUNC(1,FN_UMINUS , _uminus ) DEFINE_FUNC(1,FN_UPLUS , _uplus ) DEFINE_FUNC(3, EFN_IF,_if) DEFINE_FUNC(2,EFN_LOGICAL_AND, _and) DEFINE_FUNC(2,EFN_LOGICAL_OR,_or) DEFINE_FUNC(2,EFN_LOOP, loop) DEFINE_FUNC(1,EFN_WHILE, while) DEFINE_FUNC(1,EFN_NOT,_not) DEFINE_FUNC(2,EFN_EQUAL,_equal) DEFINE_FUNC(2,EFN_NOTEQ,_noteq) DEFINE_FUNC(2,EFN_BELOW,_below) DEFINE_FUNC(2,EFN_ABOVE,_above) DEFINE_FUNC(2,EFN_BELEQ,_beleq) DEFINE_FUNC(2,EFN_ABOEQ,_aboeq) DEFINE_FUNC(2,EFN_SET,_set) DEFINE_FUNC(2,EFN_MOD,_mod) DEFINE_FUNC(2,EFN_MULOP, _mulop) DEFINE_FUNC(2,EFN_DIVOP, _divop) DEFINE_FUNC(2,EFN_OROP, _orop) DEFINE_FUNC(2,EFN_ANDOP, _andop) DEFINE_FUNC(2,EFN_ADDOP, _addop) DEFINE_FUNC(2,EFN_SUBOP, _subop) DEFINE_FUNC(2,EFN_MODOP, _modop) DEFINE_FUNC(1,EFN_SIN,sin) DEFINE_FUNC(1,EFN_COS,cos) DEFINE_FUNC(1,EFN_TAN,tan) DEFINE_FUNC(1,EFN_ASIN,asin) DEFINE_FUNC(1,EFN_ACOS,acos) DEFINE_FUNC(1,EFN_ATAN,atan) DEFINE_FUNC(2,EFN_ATAN2,atan2) DEFINE_FUNC(1,EFN_SQR,sqr) DEFINE_FUNC(1,EFN_SQRT,sqrt) DEFINE_FUNC(2,EFN_POW,pow) DEFINE_FUNC(2,EFN_POWOP, _powop) DEFINE_FUNC(1,EFN_EXP,exp) DEFINE_FUNC(1,EFN_LOG,log) DEFINE_FUNC(1,EFN_LOG10,log10) DEFINE_FUNC(1,EFN_ABS,abs) DEFINE_FUNC(2,EFN_MIN,min) DEFINE_FUNC(2,EFN_MAX,max) DEFINE_FUNC(1,EFN_SIGN,sign) DEFINE_FUNC(1,EFN_RAND,rand) DEFINE_FUNC(1,EFN_FLOOR,floor) DEFINE_FUNC(1,EFN_CEIL,ceil) DEFINE_FUNC(1,EFN_INVSQRT, invsqrt) DEFINE_FUNC(2,EFN_SIGMOID, sigmoid) DEFINE_FUNC(2,EFN_BAND, band) DEFINE_FUNC(2,EFN_BOR, bor) DEFINE_FUNC(2,EFN_ASSERT_EQUALS, assert_equals) DEFINE_FUNC(2,EFN_EXEC2, exec2) DEFINE_FUNC(3,EFN_EXEC3, exec3) DEFINE_FUNC(1,EFN_MEM, _mem) DEFINE_FUNC(1,EFN_GMEM, _gmem) DEFINE_FUNC(1,EFN_FREEMBUF, freembuf) DEFINE_FUNC(3,EFN_MEMCPY, memcpy) DEFINE_FUNC(3,EFN_MEMSET, memset) DEFINE_TOKEN(IDENTIFIER,EFN_CONSTANT, constant) DEFINE_TOKEN(IDENTIFIER,EFN_REGISTER, register) DEFINE_TOKEN(IDENTIFIER,EFN_REGISTER_ASSIGNMENT, register_assignment) DEFINE_TOKEN(IDENTIFIER,EFN_BLOCK_STATEMENT, block_statement) AddAlias("if","_if"); AddAlias("bnot","_not"); AddAlias("assign","_set"); AddAlias("equal","_equal"); AddAlias("below","_below"); AddAlias("above","_above"); AddAlias("megabuf","_mem"); AddAlias("gmegabuf","_gmem"); AddAlias("int","floor"); } bool LookupFunction(const char *name, FuncType *type, TokenType *token) { RegisterFunctions(); auto it = s_fnmap.find(name); if (it == s_fnmap.end()) { // try lowercase... std::string lower(name); for (size_t i=0; i < lower.size(); i++) { lower[i] = std::tolower(lower[i]); } it = s_fnmap.find(lower); if (it == s_fnmap.end()) { *type = (FuncType)0; *token = (TokenType)0; return false; } } FuncInfo fi = (*it).second; *token = fi.token; *type = fi.type; return true; } }} // nseel
#include "Patcher_ShowCombatPower.h" #include "../Addr.h" #include "../FileSystem.h" //----------------------------------------------------------------------------- // Static variable initialization bool CPatcher_ShowCombatPower::showMaxHP = false; bool CPatcher_ShowCombatPower::showCombatPower = false; wchar_t CPatcher_ShowCombatPower::dataStrNull[1] = L""; wchar_t CPatcher_ShowCombatPower::dataBuf[256]; LPBYTE CPatcher_ShowCombatPower::addrCStringTConstr = NULL; LPBYTE CPatcher_ShowCombatPower::addrCStringTEquals = NULL; LPBYTE CPatcher_ShowCombatPower::addrGetCombatPower = NULL; LPBYTE CPatcher_ShowCombatPower::addrGetLifeMax = NULL; LPBYTE CPatcher_ShowCombatPower::addrTargetReturn = NULL; //----------------------------------------------------------------------------- // Constructor CPatcher_ShowCombatPower::CPatcher_ShowCombatPower( void ) { patchname = "Show Combat Power/Max HP"; addrCStringTConstr = CAddr::Addr(CStringTUni_Constr); addrCStringTEquals = CAddr::Addr(CStringTUni_Equals); addrGetCombatPower = CAddr::Addr(IParameterBase2_GetCombatPower); addrGetLifeMax = CAddr::Addr(IParameterBase2_GetLifeMax); if (!addrCStringTConstr || !addrCStringTEquals || !addrGetCombatPower || !addrGetLifeMax) { WriteLog("Patch initialization failed: %s.\n", patchname.c_str()); WriteLog(" Missing dependency.\n"); return; } // Patch mp1 // We have to be careful here not to conflict with the Enable Name Coloring patch-- // it modifies the same function up through +6C vector<WORD> patch1; vector<WORD> backup1; backup1 += 0x8B, 0xCF, // +6D: MOV ECX, EDI 0x84, 0xC0, // +6F: JZ SHORT +1A 0x74, 0x1A, 0x8D, 0x45, 0x08, // +71: LEA EAX, [EBP+08h] 0x50, 0xE8, -1, -1, -1, -1, // +75: CALL NEAR xxxxxxxx (addrTarget2) 0x8B, 0x16, // +7A: MOV EDX, [ESI] 0x83, 0x65, 0xFC, 0x00; // +7C: AND [EBP-04h], 0 patch1 += -1, -1, -1, -1, // +6F: JZ => NOP 0x90, 0x90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1; MemoryPatch mp1( NULL, patch1, backup1 ); if (!mp1.Search( L"Pleione.dll" )) { WriteLog("Patch initialization failed: %s.\n", patchname.c_str()); return; } // Patch mp2 // The second target address is obtained from a CALL instruction in Patch 1, // so we check Patch 1's key first to make sure we get a valid address! //DWORD offset = (*(LPDWORD)(mp1.GetAddr() - 0x6D + 0x76)); // addrTarget1+0x75: CALL NEAR addrTarget2 // LPBYTE addrTarget2 = (LPBYTE)(mp1.GetAddr() - 0x6D + 0x7A + offset); // addr is relative to the next instruction LPBYTE addrTarget2 = (LPBYTE)(0x6392876E); // shame on me //addrTargetReturn = addrTarget2 + 0xA8; addrTargetReturn = (LPBYTE)(0x639287E6); vector<WORD> patch2; vector<WORD> backup2; backup2 += 0x0F, 0x84, 0xAD, 0x00, 0x00, 0x00, // +1A: JZ NEAR +0xC3 0x8B, 0xCE, // +20: MOV ECX, ESI 0x90, 0xE8, -1, -1, -1, -1, // +22: CALL xxxxxxxx (core::ICharacter::IsNamedNPC) 0x84, 0xC0, // +28: TEST AL, AL 0x0F, 0x85, 0x9D, 0x00, 0x00, 0x00, // +2A: JZ NEAR +0xB3 0x8B, 0x06, // +30: MOV ECX, [ESI] 0x8B, 0xCE, // +32: MOV ECX, ESI 0xFF, 0x90, 0x08, 0x02, 0x00, 0x00, // +34: CALL DWORD PTR [EAX+1A8h] 0x84, 0xC0, // +3A: TEST AL, AL 0x0F, 0x85, 0x8B, 0x00, 0x00, 0x00; // +3C: JNZ NEAR +0xA1 patch2 += 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, // +1A: JZ patchCP1 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, // +2A: JZ patchCP1 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0x01FF, 0x01FF, 0x01FF, 0x01FF; // +3C: JNZ patchCP1 MemoryPatch mp2( addrTarget2, patch2, backup2 ); mp2.PatchRelativeAddress( 0x01, (LPBYTE)patchCP1 ); // Patch mp3 // Not to be confused with anything audio-related LPBYTE addrTarget3 = (LPBYTE)0x639287BA; vector<WORD> patch3; vector<WORD> backup3; backup3 += 0x75, 0x2A; // +7C: JNZ SHORT +2Ah patch3 += -1, 0xD4; // +7C: JNZ SHORT -42h (destination: +3Ch) MemoryPatch mp3( addrTarget3, patch3, backup3 ); // Patch mp4 // Not to be confused with anything video-related LPBYTE addrTarget4 = (LPBYTE)0x639287DD; vector<WORD> patch4; vector<WORD> backup4; backup4 += 0x8D, 0x4D, 0xF0, // +9F: LEA ECX, [EBP-10h] 0x90, 0xE8, -1, -1, -1, -1; // +A2: CALL xxxxxxxx (esl::CStringT::operator=(wchar_t const*)) patch4 += 0xE9, 0x01FF, 0x01FF, 0x01FF, 0x01FF, // +9F: JMP patchCP2 0x90, 0x90, 0x90, 0x90; // +A4: NOP (x4) MemoryPatch mp4( addrTarget4, patch4, backup4 ); mp4.PatchRelativeAddress( 0x01, (LPBYTE)patchCP2 ); // Add and check all of our patches! patches += mp1; patches += mp2; patches += mp3; patches += mp4; if (CheckPatches()) WriteLog("Patch initialization successful: %s.\n", patchname.c_str()); else WriteLog("Patch initialization failed: %s.\n", patchname.c_str()); } //----------------------------------------------------------------------------- // Hook functions /* patchCP1 performs the initialization necessary to get us the character name * prefix CStringT object. We jump to it for all cases where we do NOT want to * show BOSS, AWFUL, etc. relative CP -- players, NPCs, etc. * For normal enemies we should never get here. */ NAKED void CPatcher_ShowCombatPower::patchCP1(void) { __asm { LEA ECX, DWORD PTR SS:[EBP-10h] // [EBP-10h] is the CStringT object for the text prefixing the character name CALL addrCStringTConstr // No arguments -- init to "" AND DWORD PTR SS:[EBP-4h], 0 // The Pleione code does this after initializing the CStringT...? PUSH offset dataStrNull JMP patchCP2 } } /* patchCP2 takes the string prefix on the stack, gets the target CP, * formats it with our formatting function, and fills our CStringT object * with the formatted text. */ NAKED void CPatcher_ShowCombatPower::patchCP2(void) { __asm { MOV ECX, ESI // ESI holds the "this" pointer... but what object are we? MOV EAX, DWORD PTR DS:[ECX] // EAX = vftable CALL DWORD PTR DS:[EAX+4Ch] // Returns the target ICharacter? (not 100% sure on that) MOV ECX, EAX // ECX should be our target ICharacter object now CALL addrGetCombatPower SUB ESP, 8h // Allocate stack space for the CP value FSTP QWORD PTR SS:[ESP] // Store the CP value on the stack CALL addrGetLifeMax SUB ESP, 8h // Allocate stack space for the HP value FSTP QWORD PTR SS:[ESP] // Store the HP value on the stack PUSH offset dataBuf // Push the buffer to hold CP value CALL patchCPFormat // Call our formatting function. The string arg was pushed // either by the Pleione code (for enemies-- <mini>BOSS </mini> // or whatever) or by patchCP1. PUSH offset dataBuf // Our buffer was now filled with the formatted string LEA ECX, DWORD PTR SS:[EBP-10h] // Put the CStringT object into the "this" register... CALL addrCStringTEquals // and set its text to our formatted string! JMP addrTargetReturn; // Jump back to Pleione code. } } /* patchCPFormat takes our string prefix, the CP value, and writes * into the buffer a complete prefix including both. */ void __stdcall CPatcher_ShowCombatPower::patchCPFormat(wchar_t * buff,double h,double f,wchar_t* str) { if (showMaxHP && showCombatPower) { if (wcscmp(str, L"") == 0) { swprintf_s(buff, 255, L"<mini>EVEN</mini> %.2f\n<mini>MaxHP</mini> %.2f\n<mini>NAME</mini> ", f, h); } else { swprintf_s(buff, 255, L"%s%.2f\n<mini>MaxHP</mini> %.2f\n<mini>NAME</mini> ", str, f, h); } } else if (!showMaxHP && showCombatPower) { if (wcscmp(str, L"") == 0) { swprintf_s(buff, 255, L"<mini>EVEN</mini> %.2f ", f); } else { swprintf_s(buff, 255, L"%s%.2f ", str, f); } } else if (!showCombatPower && showMaxHP) { swprintf_s(buff, 255, L"<mini>MaxHP</mini> %.2f ", h); } } //----------------------------------------------------------------------------- // Menu Functions bool CPatcher_ShowCombatPower::Toggle(int stat) { switch (stat) { case 0: if (showCombatPower) { showCombatPower = false; if (!showCombatPower && !showMaxHP) return Uninstall(); } else { showCombatPower = true; return Install(); } break; case 1: if (showMaxHP) { showMaxHP = false; if (!showCombatPower && !showMaxHP) return Uninstall(); } else { showMaxHP = true; return Install(); } break; default: break; } return false; } bool CPatcher_ShowCombatPower::IsInstalled(int stat) { switch (stat) { case 0: return installed && showCombatPower; break; case 1: return installed && showMaxHP; break; default: break; } return false; } //----------------------------------------------------------------------------- // INI Functions bool CPatcher_ShowCombatPower::ReadINI( void ) { showMaxHP = ReadINI_Bool(L"ShowMaxHP"); showCombatPower = ReadINI_Bool(L"ShowCombatPower"); if ( showCombatPower || showMaxHP ) return Install(); return true; } bool CPatcher_ShowCombatPower::WriteINI( void ) { WriteINI_Bool( L"ShowCombatPower", IsInstalled(0) ); WriteINI_Bool(L"ShowMaxHP", IsInstalled(1)); return true; }
#ifndef PLAYER_H #define PLAYER_H #include "raylib.h" class Player{ public: Vector2 prev, pos, vel, acc; bool grounded; Rectangle rect; Player(Vector2 _pos); void refreshRect(); float bottom(); void handleEvents(); void update(float gravity); void draw(); }; #endif
#pragma once #include "datatypes.hpp" namespace roboshape { void invert_normals(pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr &output_normals, std::vector<roboshape::Primitive> &primitive_borders, uint32_t primitive_border_index) { auto current_primitive_borders = primitive_borders[primitive_border_index]; for(uint32_t vertex_index = current_primitive_borders.first ; vertex_index <= current_primitive_borders.last ; ++vertex_index) { pcl::PointXYZRGBNormal& point_normal = (*output_normals)[vertex_index]; point_normal.normal_x = - point_normal.normal_x; point_normal.normal_y = - point_normal.normal_y; point_normal.normal_z = - point_normal.normal_z; } } boost::optional<uint32_t> viewpoint_normal_consistency(pcl::PointXYZ viewpoint, pcl::PointCloud<pcl::PointXYZ>::Ptr &point_cloud, std::vector<roboshape::Primitive> &primitive_borders, pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr &output_normals) { pcl::KdTreeFLANN<pcl::PointXYZ> kdtree; kdtree.setInputCloud(point_cloud); int K = 5; std::vector<int> pointIdxNKNSearch(K); std::vector<float> pointNKNSquaredDistance(K); if ( kdtree.nearestKSearch(viewpoint, K, pointIdxNKNSearch, pointNKNSquaredDistance) > 0 ) { size_t closest_to_viewpoint = pointIdxNKNSearch[0]; auto border_index_opt = roboshape::get_primitive_border_index(closest_to_viewpoint, primitive_borders); if(border_index_opt) { uint32_t border_index = *border_index_opt; cout << "Primitive index of point closest to viewpoint: " << border_index << std::endl; pcl::PointXYZRGBNormal& closest_to_viewpoint_pointnormal = (*output_normals)[closest_to_viewpoint]; Eigen::Vector3f closest_to_viewpoint_normal_eigen(closest_to_viewpoint_pointnormal.normal_x, closest_to_viewpoint_pointnormal.normal_y, closest_to_viewpoint_pointnormal.normal_z); Eigen::Vector3f closest_to_viewpoint_eigen(closest_to_viewpoint_pointnormal.x, closest_to_viewpoint_pointnormal.y, closest_to_viewpoint_pointnormal.z); Eigen::Vector3f viewpoint_eigen(viewpoint.x, viewpoint.y, viewpoint.z); Eigen::Vector3f desired_directional_normal = viewpoint_eigen - closest_to_viewpoint_eigen; if (desired_directional_normal.adjoint() * closest_to_viewpoint_normal_eigen < 0.0) { // negative inner product and thus wrong direction, need to invert all normals in primitive invert_normals(output_normals, primitive_borders, border_index); } } return border_index_opt; } return {}; } void detect_bordering_points( pcl::PointCloud<pcl::PointXYZ>::Ptr &point_cloud, std::vector<roboshape::Primitive> &primitive_borders, std::map<uint32_t, std::vector<roboshape::BorderingPoint>> &bordering_points) { cout << "Begin detection of bordering points..." << std::endl; pcl::KdTreeFLANN<pcl::PointXYZ> kdtree; std::set<uint32_t> processed_points; kdtree.setInputCloud(point_cloud); pcl::PointXYZ searchPoint; int K = 5; std::vector<int> pointIdxNKNSearch(K); std::vector<float> pointNKNSquaredDistance(K); for(uint32_t primitive_index = 0 ; primitive_index < primitive_borders.size() ; ++primitive_index) { std::set<uint32_t> borders = primitive_borders[primitive_index].borders; // for each border get the closest node such that it's not in the border for(uint32_t const& border_point : borders) { if(processed_points.find(border_point) != processed_points.end()) { pcl::PointXYZ point_in_border = (*point_cloud)[border_point]; auto total_found = kdtree.nearestKSearch(point_in_border, K, pointIdxNKNSearch, pointNKNSquaredDistance); if(total_found > 0) { bool found = false; for(uint32_t current_neighbour = 0 ; !found && current_neighbour < total_found ; current_neighbour++) { if(processed_points.find(current_neighbour) != processed_points.end()) { auto current_index = pointIdxNKNSearch[current_neighbour]; auto primitive_of_index_opt = roboshape::get_primitive_border_index(current_index, primitive_borders); if(primitive_of_index_opt){ found = *primitive_of_index_opt != primitive_index; if(found){ auto current_bordering_point = roboshape::BorderingPoint(border_point, primitive_index, current_index, *primitive_of_index_opt); if(bordering_points.find(primitive_index) == bordering_points.end()){ bordering_points[primitive_index] = std::vector<roboshape::BorderingPoint>(); } bordering_points[primitive_index].push_back(current_bordering_point); // neigubours are symmetric/commutative: neighbour(a, b) = neighbour(b, a) auto reverse_bordering_point = roboshape::BorderingPoint(current_index, *primitive_of_index_opt, border_point, primitive_index); if(bordering_points.find(*primitive_of_index_opt) == bordering_points.end()){ bordering_points[*primitive_of_index_opt] = std::vector<roboshape::BorderingPoint>(); } bordering_points[*primitive_of_index_opt].push_back(reverse_bordering_point); processed_points.insert(*primitive_of_index_opt); } } processed_points.insert(current_neighbour); } } } } processed_points.insert(border_point); } } cout << "... end of detection of bordering points" << std::endl; } void make_smooth_manifold(pcl::PolygonMesh &polygon_mesh, pcl::PointCloud<pcl::PointXYZ>::Ptr &point_cloud, std::vector<roboshape::Primitive> &primitive_borders, pcl::PointXYZ viewpoint, pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr &output_normals) { std::map<uint32_t, std::vector<roboshape::BorderingPoint>> bordering_points; detect_bordering_points(point_cloud, primitive_borders, bordering_points); cout << "Bordering points: " << bordering_points.size() << std::endl; roboshape::Mesh::VertexIndices vertex_indices; roboshape::Mesh mesh; generate_mesh(polygon_mesh, *point_cloud, mesh, vertex_indices); std::set<uint32_t> primiteves_processed; std::stack<uint32_t> primitives_to_process; boost::optional<uint32_t> border_index_opt = viewpoint_normal_consistency(viewpoint, point_cloud, primitive_borders, output_normals); if(border_index_opt) { uint32_t border_index = *border_index_opt; primitives_to_process.push(border_index); while(!primitives_to_process.empty()) { auto current_border_index = primitives_to_process.top(); //cout << "Processing primitive: " << current_border_index << std::endl; primiteves_processed.insert(current_border_index); primitives_to_process.pop(); auto bordering_points_interator = bordering_points.find(current_border_index); if(bordering_points_interator != bordering_points.end()) { std::vector<roboshape::BorderingPoint> bordering_points = (*bordering_points_interator).second; //cout << "Total number of borders: " << bordering_points.size() << std::endl; for(roboshape::BorderingPoint bordering_point : bordering_points) { if(primiteves_processed.find(bordering_point.destination_primitive) == primiteves_processed.end()){ // get normal from source primitive auto source_normal = (*output_normals)[bordering_point.source_point]; auto destination_normal = (*output_normals)[bordering_point.destination_point]; Eigen::Vector3f source_normal_eig(source_normal.normal_x, source_normal.normal_y, source_normal.normal_z); Eigen::Vector3f destination_normal_eig(destination_normal.normal_x, destination_normal.normal_y, destination_normal.normal_z); if(source_normal_eig.adjoint() * destination_normal_eig < 0.0) { invert_normals(output_normals, primitive_borders, bordering_point.destination_primitive); } primitives_to_process.push(bordering_point.destination_primitive); } } } } } } pcl::PolygonMesh::Ptr laplacian_smoothing(pcl::PolygonMesh::Ptr mesh) { cout << "Starting Laplacian Smoothing..." << std::endl; pcl::PolygonMesh::Ptr smoothed_mesh (new pcl::PolygonMesh()); pcl::MeshSmoothingLaplacianVTK vtk; vtk.setInputMesh(mesh); vtk.setNumIter(20000); vtk.setConvergence(0.0001); vtk.setRelaxationFactor(0.0001); vtk.setFeatureEdgeSmoothing(true); vtk.setFeatureAngle(M_PI / 5); vtk.setBoundarySmoothing(true); vtk.process(*smoothed_mesh); cout << "... end of Laplacian Smoothing." << std::endl; return smoothed_mesh; } void extract_point_index_to_normals(pcl::PolygonMesh &polygon_mesh, pcl::PointCloud<pcl::PointXYZ> &point_cloud, std::shared_ptr<std::map<uint32_t, std::vector<Eigen::Vector3f>>> point_index_to_normals) { roboshape::Mesh::VertexIndices vertex_indices; roboshape::Mesh mesh; roboshape::generate_mesh(polygon_mesh, point_cloud, mesh, vertex_indices); for(uint32_t point_index = 0 ; point_index < vertex_indices.size() ; ++point_index) { auto outgoing_half_edges = mesh.getOutgoingHalfEdgeAroundVertexCirculator(vertex_indices[point_index]); auto outgoing_half_edges_end = outgoing_half_edges; boost::optional<Eigen::Vector3f> previous_vector = {}; do { roboshape::Mesh::HalfEdgeIndex target_edge = outgoing_half_edges.getTargetIndex(); pcl::PointXYZ origin = mesh.getVertexDataCloud()[mesh.getOriginatingVertexIndex(target_edge).get()]; pcl::PointXYZ terminating = mesh.getVertexDataCloud()[mesh.getTerminatingVertexIndex(target_edge).get()]; Eigen::Vector3f origin_vector(origin.x, origin.y, origin.z); Eigen::Vector3f terminating_vector(terminating.x, terminating.y, terminating.z); Eigen::Vector3f current_vector = terminating_vector - origin_vector; if(previous_vector) { Eigen::Vector3f normal = (*previous_vector).cross(current_vector); normal.normalize(); auto vertices_iterator = point_index_to_normals->find(point_index); if (vertices_iterator == point_index_to_normals->end()) { (*point_index_to_normals)[point_index] = { normal }; } else { vertices_iterator->second.push_back(normal); } } previous_vector = current_vector; } while (++outgoing_half_edges != outgoing_half_edges_end); } } void extract_normals(pcl::PolygonMesh &mesh, pcl::PointCloud<pcl::PointXYZ> &point_cloud, pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr &output_normals) { cout << "Starting normal extraction..." << std::endl; std::shared_ptr<std::map<uint32_t, std::vector<Eigen::Vector3f>>> point_index_to_normals (new std::map<uint32_t, std::vector<Eigen::Vector3f>>); extract_point_index_to_normals(mesh, point_cloud, point_index_to_normals); for(uint32_t point_index = 0 ; point_index < mesh.cloud.data.size() ; ++point_index) { auto normals_iterator = point_index_to_normals->find(point_index); if(normals_iterator != point_index_to_normals->end()) { Eigen::Vector3f sum_of_normals = Eigen::Vector3f::Zero(); for(auto const& normal : normals_iterator->second){ sum_of_normals = sum_of_normals + normal; } sum_of_normals.normalize(); pcl::PointXYZRGBNormal point_normal = pcl::PointXYZRGBNormal(); uint8_t r = 0, g = 0, b = 100; uint32_t rgb = ((uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b); point_normal.rgb = *reinterpret_cast<float*>(&rgb); point_normal.normal_x = sum_of_normals[0]; point_normal.normal_y = sum_of_normals[1]; point_normal.normal_z = sum_of_normals[2]; pcl::PointXYZ point = point_cloud.points[point_index]; point_normal.x = point.x; point_normal.y = point.y; point_normal.z = point.z; output_normals->points.push_back(point_normal); } } cout << "... end of normal extraction." << std::endl; } }
#include <iostream> #include <vector> #include <fstream> using namespace std; struct A { int x; string str; friend ostream & operator <<(ostream & os, A &a){ return os<<a.x<<a.str; } friend istream & operator >>(istream & is, A &a){ return is>>a.x>>a.str; } char* serialize(A &a) { char* s=new char[(a.str).size()]; for(int i=0; i<(a.str).size(); i++){ s[i]=a.str[i]; } return s; } }; void save_array(vector<A> &vt,const char * file) { ofstream of(file,ios::binary); size_t size_v; for(int i=0;i<vt.size();i++){ size_v=vt[i].str.size(); of.write((char*)&vt[i].x, sizeof(int)); of.write((char*)&size_v,sizeof(size_t)); of.write(vt[i].str.c_str(),size_v); } of.close(); } void load_array(vector <A> &vt, const char* file) { ifstream ifs(file,ios:: binary); A s; char * vt_b; size_t size_v; while(ifs.read((char*)&s.x, sizeof(int))){ ifs.read((char*)&size_v,sizeof(size_t)); vt_b=new char[size_v + 1]; ifs.read(vt_b,size_v); vt_b[size_v]=0; s.str=vt_b; vt.push_back(s); } ifs.close(); } int main() { A a; vector <A> va; load_array(va,"out.bin"); for(int i=0; i<va.size(); i++){ cout<<va[i]<<endl; } int n; cin>>n; while(n!=0){ cin>>a; va.push_back(a); n--; } save_array(va,"out.bin"); for(int i=0; i<va.size(); i++){ cout<<va[i]<<endl; } return 0; }
#ifndef GLOBAL_FUNCTIONS #define GLOBAL_FUNCTIONS #define _USE_MATH_DEFINES #include <math.h> #include <vector> #include "../include/GLSLProgram.h" #include "../libs/glm/glm/gtx/rotate_vector.hpp" #include "GlobalConstants.h" static struct GlobalFunctions { void rotateXPointVector(std::vector<PointVector>& vector) { for (int i = 0; i < vector.size(); i++) { vector[i].setVec3(glm::rotateX(vector[i].getVec3(), globalConstants.DEFAULT_ROTATION * ((float)M_PI / 180)), 1); } } void rotateYPointVector(std::vector<PointVector>& vector) { for (int i = 0; i < vector.size(); i++) { vector[i].setVec3(glm::rotateY(vector[i].getVec3(), globalConstants.DEFAULT_ROTATION * ((float)M_PI / 180)), 1); } } void rotateZPointVector(std::vector<PointVector>& vector) { for (int i = 0; i < vector.size(); i++) { vector[i].setVec3(glm::rotateZ(vector[i].getVec3(), globalConstants.DEFAULT_ROTATION * ((float)M_PI / 180)), 1); } } void rotateXGlmVector(std::vector<glm::vec3>& vector) { for (int i = 0; i < vector.size(); i++) { vector[i] = glm::rotateX(vector[i], globalConstants.DEFAULT_ROTATION * ((float)M_PI / 180)); } } void rotateYGlmVector(std::vector<glm::vec3>& vector) { for (int i = 0; i < vector.size(); i++) { vector[i] = glm::rotateY(vector[i], globalConstants.DEFAULT_ROTATION * ((float)M_PI / 180)); } } void rotateZGlmVector(std::vector<glm::vec3>& vector) { for (int i = 0; i < vector.size(); i++) { vector[i] = glm::rotateZ(vector[i], globalConstants.DEFAULT_ROTATION * ((float)M_PI / 180)); } } void translatePointVector(std::vector<PointVector>& vector, PointVector trans) { for (int i = 0; i < vector.size(); i++) { vector[i] = vector[i] + trans; } } void translateGlmVector(std::vector<glm::vec3>& vector, glm::vec3 trans) { for (int i = 0; i < vector.size(); i++) { vector[i] = vector[i] + trans; } } glm::vec3 mixGlmVector(glm::vec3 v) { return glm::vec3(v.z, v.x, v.y); } } globalFunctions; #endif // !GLOBAL_FUNCTIONS
/*********************************************************************** created: Fri Jul 8 2005 author: Paul D Turner <paul@cegui.org.uk> *************************************************************************/ /*************************************************************************** * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************/ #include "CEGUI/WindowRendererSets/Core/TabButton.h" #include "CEGUI/falagard/WidgetLookManager.h" #include "CEGUI/falagard/WidgetLookFeel.h" #include "CEGUI/widgets/TabButton.h" #include "CEGUI/widgets/TabControl.h" namespace CEGUI { const String FalagardTabButton::TypeName("Core/TabButton"); //----------------------------------------------------------------------------// FalagardTabButton::FalagardTabButton(const String& type) : WindowRenderer(type, "TabButton") { } //----------------------------------------------------------------------------// void FalagardTabButton::createRenderGeometry() { TabButton* w = static_cast<TabButton*>(d_window); TabControl* tc = w->getParent() ? dynamic_cast<TabControl*>(w->getParent()->getParent()) : nullptr; String prefix((tc && tc->getTabPanePosition() == TabControl::TabPanePosition::Bottom) ? "Bottom" : "Top"); String state; if (w->isEffectiveDisabled()) state = "Disabled"; else if (w->isSelected()) state = "Selected"; else if (w->isPushed()) state = "Pushed"; else if (w->isHovering()) state = "Hover"; else if (w->isFocused()) state = "Focused"; else state = "Normal"; const WidgetLookFeel& wlf = getLookNFeel(); if (!wlf.isStateImageryPresent(prefix + state)) { state = "Normal"; if (!wlf.isStateImageryPresent(prefix + state)) prefix = ""; } wlf.getStateImagery(prefix + state).render(*w); } //----------------------------------------------------------------------------// Sizef FalagardTabButton::getContentSize() const { if (!d_window->getGUIContextPtr()) return Sizef(0.f, 0.f); TabControl* tc = d_window->getParent() ? dynamic_cast<TabControl*>(d_window->getParent()->getParent()) : nullptr; if (!tc) return Sizef(0.f, 0.f); const WidgetLookFeel& lnf = getLookNFeel(); String state((tc->getTabPanePosition() == TabControl::TabPanePosition::Bottom) ? "Bottom" : "Top"); state += "Normal"; if (!lnf.isStateImageryPresent(state)) state = "Normal"; // Find a text component responsible for a text //!!!FIXME: duplicated code, see FalagardTooltip::getTextComponentExtents! const auto& layerSpecs = lnf.getStateImagery(state).getLayerSpecifications(); for (auto& layerSpec : layerSpecs) { const auto& sectionSpecs = layerSpec.getSectionSpecifications(); for (auto& sectionSpec : sectionSpecs) { const auto& texts = lnf.getImagerySection(sectionSpec.getSectionName()).getTextComponents(); if (!texts.empty()) return texts.front().getTextExtent(*d_window); } } return Sizef(0.f, 0.f); } }
#include <cybermed/cybCore.h> #include <cybermed/cybViewMono.h> #include <cybermed/cybMouseInterator.h> #include <cybermed/cybOBB.h> #include <cybermed/cybCollisionManager.h> #include <cybermed/mf/mfReaderModel.h> #include <string> #include <cstring> #include <iostream> #include <unistd.h> #include <sys/time.h> using namespace std; struct timeval inicio, fim; double total; int main(int argv, char **argc) { string s1 = "medulanova.wrl"; //model name char* filename = const_cast<char*>(s1.c_str()); int numLayer = 1; //number of layers used in this application int numInterator = 1; CybDataObtainer<cybSurfaceTriTraits> data(numLayer, numInterator); // Transfer the OF data to the CybParameters structure CybViewMono view; // Monoscopic Visualization CybInterator* interator = CybMouseInterator::getInterator(); //Access the parameters information of scene and graphical objects CybParameters *cybCore = CybParameters::getInstance(); // ============= // Read Mesh File mfReaderModel<cybSurfaceTriTraits> in; sMesh *mesh = new sMesh[numLayer]; in.read(&mesh[0], filename); //data.readColor(filename, 0); data.loadModel(mesh); //=========== //Load the model from VRML file (layerID, fileName) //data.loadModel(0, filename); string s2 = "esfera.wrl"; char *aux = const_cast<char*>(s2.c_str()); data.loadInteratorModel(0,0, aux); data.startInterator(0,0); interator->setColor(0,1,0,1); //Initialize the meshes parameters data.startParameters(numLayer); //Set the object color (layerID, r, g, b,a) cybCore->setColor(0,1,1,0.7,1); //Set the window name string s3 = "Teste"; char *aux2 = const_cast<char*>(s3.c_str()); view.setWindowName(aux2); //Create a material property context, used by collision, haptics and deformation cybCore->createMaterialPropertyContext(numLayer); cout << "antes da obb" << endl; //Creating the OBBs CybOBB *caixaInter = new CybOBB(0,0,true, true); gettimeofday(&inicio, NULL); CybOBB *caixaModel = new CybOBB(0,0,false, true); gettimeofday(&fim, NULL); total = (fim.tv_sec - inicio.tv_sec) * 1000000 + (fim.tv_usec - inicio.tv_usec); cout << "A construcao da OBB levou " << total << " microssegundos." << endl; cout << "Passei dos construtores" << endl; //caixaInter->describeBox(); caixaModel->describeBox(); caixaInter->addTest(caixaModel); caixaModel->addTest(caixaInter); cout << "depois da OBB" << endl; //Creating the Collision Manager objects. CybCollisionManager* colMan1 = new CybCollisionManager(caixaInter, true); CybCollisionManager* colMan2 = new CybCollisionManager(caixaModel, false); //Initializing boxes and managers caixaInter->init(); caixaModel->init(); colMan1->init(); colMan2->init(); cout << "passei da aguias" << endl; //Initializing visualization view.init(); }
#if !defined(REALTIMECLOCK_H) #define REALTIMECLOCK_H #include "LocalTypes.h" #include "RtcTime.h" #include "RtcAlarm.h" class I2CBus; namespace rtc { enum class RtcClockState { Unknown, Running, TimeInvalid }; class RealTimeClock { public: virtual bool Initialize() = 0; virtual void Shutdown() = 0; virtual RtcClockState GetClockState() const = 0; virtual void GetDateTime(RtcDateTime& value) const = 0; virtual void SetDateTime(const RtcDateTime& value) = 0; // Temperature function virtual float GetTemperature() const = 0; // Alarm functions virtual void SetAlarm(AlarmId id, const RtcAlarm& alarm) = 0; virtual void GetAlarm(AlarmId id, RtcAlarm& alarm) const = 0; virtual void SetAlarmInterruptState(AlarmInterruptState firstAlarmState, AlarmInterruptState secondAlarmState) = 0; virtual AlarmInterruptStatus GetAlarmInterruptStatus() const = 0; virtual AlarmTriggerState GetAlarmTriggerState() const = 0; }; } //namespace rtc #endif //REALTIMECLOCK_H
/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter <wolti@sil.at> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * File: $Id: mbfuncholding.c,v 1.12 2007/02/18 23:48:22 wolti Exp $ */ /* ----------------------- System includes ----------------------------------*/ #include "stdlib.h" #include "string.h" /* ----------------------- Platform includes --------------------------------*/ #include "port.h" /* ----------------------- Modbus includes ----------------------------------*/ #include "mb.h" #include "mbframe.h" #include "mbproto.h" #include "mbconfig.h" /* ----------------------- Defines ------------------------------------------*/ #define MB_PDU_FUNC_READ_ADDR_OFF ( MB_PDU_DATA_OFF + 0) #define MB_PDU_FUNC_READ_REGCNT_OFF ( MB_PDU_DATA_OFF + 2 ) #define MB_PDU_FUNC_READ_SIZE ( 4 ) #define MB_PDU_FUNC_READ_REGCNT_MAX ( 0x007D ) #define MB_PDU_FUNC_WRITE_ADDR_OFF ( MB_PDU_DATA_OFF + 0) #define MB_PDU_FUNC_WRITE_VALUE_OFF ( MB_PDU_DATA_OFF + 2 ) #define MB_PDU_FUNC_WRITE_SIZE ( 4 ) #define MB_PDU_FUNC_WRITE_MUL_ADDR_OFF ( MB_PDU_DATA_OFF + 0 ) #define MB_PDU_FUNC_WRITE_MUL_REGCNT_OFF ( MB_PDU_DATA_OFF + 2 ) #define MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF ( MB_PDU_DATA_OFF + 4 ) #define MB_PDU_FUNC_WRITE_MUL_VALUES_OFF ( MB_PDU_DATA_OFF + 5 ) #define MB_PDU_FUNC_WRITE_MUL_SIZE_MIN ( 5 ) #define MB_PDU_FUNC_WRITE_MUL_REGCNT_MAX ( 0x0078 ) #define MB_PDU_FUNC_READWRITE_READ_ADDR_OFF ( MB_PDU_DATA_OFF + 0 ) #define MB_PDU_FUNC_READWRITE_READ_REGCNT_OFF ( MB_PDU_DATA_OFF + 2 ) #define MB_PDU_FUNC_READWRITE_WRITE_ADDR_OFF ( MB_PDU_DATA_OFF + 4 ) #define MB_PDU_FUNC_READWRITE_WRITE_REGCNT_OFF ( MB_PDU_DATA_OFF + 6 ) #define MB_PDU_FUNC_READWRITE_BYTECNT_OFF ( MB_PDU_DATA_OFF + 8 ) #define MB_PDU_FUNC_READWRITE_WRITE_VALUES_OFF ( MB_PDU_DATA_OFF + 9 ) #define MB_PDU_FUNC_READWRITE_SIZE_MIN ( 9 ) /* ----------------------- Static functions ---------------------------------*/ eMBException prveMBError2Exception( eMBErrorCode eErrorCode ); /* ----------------------- Start implementation -----------------------------*/ #if MB_FUNC_WRITE_HOLDING_ENABLED > 0 eMBException eMBFuncWriteHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) { USHORT usRegAddress; eMBException eStatus = MB_EX_NONE; eMBErrorCode eRegStatus; if( *usLen == ( MB_PDU_FUNC_WRITE_SIZE + MB_PDU_SIZE_MIN ) ) { usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_ADDR_OFF] << 8 ); usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_ADDR_OFF + 1] ); usRegAddress++; /* Make callback to update the value. */ eRegStatus = eMBRegHoldingCB( &pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF], usRegAddress, 1, MB_REG_WRITE ); /* If an error occured convert it into a Modbus exception. */ if( eRegStatus != MB_ENOERR ) { eStatus = prveMBError2Exception( eRegStatus ); } } else { /* Can't be a valid request because the length is incorrect. */ eStatus = MB_EX_ILLEGAL_DATA_VALUE; } return eStatus; } #endif #if MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED > 0 eMBException eMBFuncWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) { USHORT usRegAddress; USHORT usRegCount; UCHAR ucRegByteCount; eMBException eStatus = MB_EX_NONE; eMBErrorCode eRegStatus; if( *usLen >= ( MB_PDU_FUNC_WRITE_MUL_SIZE_MIN + MB_PDU_SIZE_MIN ) ) { usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_ADDR_OFF] << 8 ); usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_ADDR_OFF + 1] ); usRegAddress++; usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_REGCNT_OFF] << 8 ); usRegCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_REGCNT_OFF + 1] ); ucRegByteCount = pucFrame[MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF]; if( ( usRegCount >= 1 ) && ( usRegCount <= MB_PDU_FUNC_WRITE_MUL_REGCNT_MAX ) && ( ucRegByteCount == ( UCHAR ) ( 2 * usRegCount ) ) ) { /* Make callback to update the register values. */ eRegStatus = eMBRegHoldingCB( &pucFrame[MB_PDU_FUNC_WRITE_MUL_VALUES_OFF], usRegAddress, usRegCount, MB_REG_WRITE ); /* If an error occured convert it into a Modbus exception. */ if( eRegStatus != MB_ENOERR ) { eStatus = prveMBError2Exception( eRegStatus ); } else { /* The response contains the function code, the starting * address and the quantity of registers. We reuse the * old values in the buffer because they are still valid. */ *usLen = MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF; } } else { eStatus = MB_EX_ILLEGAL_DATA_VALUE; } } else { /* Can't be a valid request because the length is incorrect. */ eStatus = MB_EX_ILLEGAL_DATA_VALUE; } return eStatus; } #endif #if MB_FUNC_READ_HOLDING_ENABLED > 0 eMBException eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) { USHORT usRegAddress; USHORT usRegCount; UCHAR *pucFrameCur; eMBException eStatus = MB_EX_NONE; eMBErrorCode eRegStatus; if( *usLen == ( MB_PDU_FUNC_READ_SIZE + MB_PDU_SIZE_MIN ) ) { usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF] << 8 ); usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF + 1] ); usRegAddress++; usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF] << 8 ); usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); /* Check if the number of registers to read is valid. If not * return Modbus illegal data value exception. */ if( ( usRegCount >= 1 ) && ( usRegCount <= MB_PDU_FUNC_READ_REGCNT_MAX ) ) { /* Set the current PDU data pointer to the beginning. */ pucFrameCur = &pucFrame[MB_PDU_FUNC_OFF]; *usLen = MB_PDU_FUNC_OFF; /* First byte contains the function code. */ *pucFrameCur++ = MB_FUNC_READ_HOLDING_REGISTER; *usLen += 1; /* Second byte in the response contain the number of bytes. */ *pucFrameCur++ = ( UCHAR ) ( usRegCount * 2 ); *usLen += 1; /* Make callback to fill the buffer. */ eRegStatus = eMBRegHoldingCB( pucFrameCur, usRegAddress, usRegCount, MB_REG_READ ); /* If an error occured convert it into a Modbus exception. */ if( eRegStatus != MB_ENOERR ) { eStatus = prveMBError2Exception( eRegStatus ); } else { *usLen += usRegCount * 2; } } else { eStatus = MB_EX_ILLEGAL_DATA_VALUE; } } else { /* Can't be a valid request because the length is incorrect. */ eStatus = MB_EX_ILLEGAL_DATA_VALUE; } return eStatus; } #endif #if MB_FUNC_READWRITE_HOLDING_ENABLED > 0 eMBException eMBFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) { USHORT usRegReadAddress; USHORT usRegReadCount; USHORT usRegWriteAddress; USHORT usRegWriteCount; UCHAR ucRegWriteByteCount; UCHAR *pucFrameCur; eMBException eStatus = MB_EX_NONE; eMBErrorCode eRegStatus; if( *usLen >= ( MB_PDU_FUNC_READWRITE_SIZE_MIN + MB_PDU_SIZE_MIN ) ) { usRegReadAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_READ_ADDR_OFF] << 8U ); usRegReadAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_READ_ADDR_OFF + 1] ); usRegReadAddress++; usRegReadCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_READ_REGCNT_OFF] << 8U ); usRegReadCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_READ_REGCNT_OFF + 1] ); usRegWriteAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_WRITE_ADDR_OFF] << 8U ); usRegWriteAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_WRITE_ADDR_OFF + 1] ); usRegWriteAddress++; usRegWriteCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_WRITE_REGCNT_OFF] << 8U ); usRegWriteCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_WRITE_REGCNT_OFF + 1] ); ucRegWriteByteCount = pucFrame[MB_PDU_FUNC_READWRITE_BYTECNT_OFF]; if( ( usRegReadCount >= 1 ) && ( usRegReadCount <= 0x7D ) && ( usRegWriteCount >= 1 ) && ( usRegWriteCount <= 0x79 ) && ( ( 2 * usRegWriteCount ) == ucRegWriteByteCount ) ) { /* Make callback to update the register values. */ eRegStatus = eMBRegHoldingCB( &pucFrame[MB_PDU_FUNC_READWRITE_WRITE_VALUES_OFF], usRegWriteAddress, usRegWriteCount, MB_REG_WRITE ); if( eRegStatus == MB_ENOERR ) { /* Set the current PDU data pointer to the beginning. */ pucFrameCur = &pucFrame[MB_PDU_FUNC_OFF]; *usLen = MB_PDU_FUNC_OFF; /* First byte contains the function code. */ *pucFrameCur++ = MB_FUNC_READWRITE_MULTIPLE_REGISTERS; *usLen += 1; /* Second byte in the response contain the number of bytes. */ *pucFrameCur++ = ( UCHAR ) ( usRegReadCount * 2 ); *usLen += 1; /* Make the read callback. */ eRegStatus = eMBRegHoldingCB( pucFrameCur, usRegReadAddress, usRegReadCount, MB_REG_READ ); if( eRegStatus == MB_ENOERR ) { *usLen += 2 * usRegReadCount; } } if( eRegStatus != MB_ENOERR ) { eStatus = prveMBError2Exception( eRegStatus ); } } else { eStatus = MB_EX_ILLEGAL_DATA_VALUE; } } return eStatus; } #endif
/* Copyright (c) 2019 Stefan Kremser This software is licensed under the MIT License. See the license file for details. Source: github.com/spacehuhn/SimpleCLI */ #include "cmd_error.h" #include <stdlib.h> // malloc, memcpy #include <string.h> // strlen, strcpy // ===== CMD Parse Error ===== // // Constructors cmd_error* cmd_error_create(int mode, cmd* command, arg* argument, word_node* data) { cmd_error* e = (cmd_error*)malloc(sizeof(cmd_error)); e->mode = mode; e->command = command; e->argument = argument; e->data = NULL; e->next = NULL; if (data && (data->len > 0)) { e->data = (char*)malloc(data->len + 1); memcpy(e->data, data->str, data->len); e->data[data->len] = '\0'; } return e; } cmd_error* cmd_error_create_null_ptr(cmd* c) { return cmd_error_create(CMD_NULL_PTR, c, NULL, NULL); }; cmd_error* cmd_error_create_empty_line(cmd* c) { return cmd_error_create(CMD_EMPTY_LINE, c, NULL, NULL); } cmd_error* cmd_error_create_parse_success(cmd* c) { return cmd_error_create(CMD_PARSE_SUCCESS, c, NULL, NULL); } cmd_error* cmd_error_create_not_found(cmd* c, word_node* cmd_name) { return cmd_error_create(CMD_NOT_FOUND, c, NULL, cmd_name); } cmd_error* cmd_error_create_unknown_arg(cmd* c, word_node* arg_name) { return cmd_error_create(CMD_UNKOWN_ARG, c, NULL, arg_name); } cmd_error* cmd_error_create_missing_arg(cmd* c, arg* a) { return cmd_error_create(CMD_MISSING_ARG, c, a, NULL); } cmd_error* cmd_error_create_unclosed_quote(cmd* c, arg* a, word_node* arg_value) { return cmd_error_create(CMD_UNCLOSED_QUOTE, c, a, arg_value); } // Copy Constructors cmd_error* cmd_error_copy(cmd_error* e) { if (!e) return NULL; cmd_error* ne = (cmd_error*)malloc(sizeof(cmd_error)); ne->mode = e->mode; ne->command = e->command; ne->argument = e->argument; ne->data = e->data; ne->next = e->next; if (ne->data) { ne->data = (char*)malloc(strlen(e->data) + 1); strcpy(ne->data, e->data); } return ne; } cmd_error* cmd_error_copy_rec(cmd_error* e) { if (!e) return NULL; cmd_error* ne = cmd_error_copy(e); ne->next = cmd_error_copy_rec(e->next); return ne; } // Destructors cmd_error* cmd_error_destroy(cmd_error* e) { if (e) { if (e->data) free(e->data); free(e); } return NULL; } cmd_error* cmd_error_destroy_rec(cmd_error* e) { if (e) { cmd_error_destroy_rec(e->next); cmd_error_destroy(e); } return NULL; } // Push cmd_error* cmd_error_push(cmd_error* l, cmd_error* e, int max_size) { if (max_size < 1) { cmd_error_destroy_rec(l); cmd_error_destroy(e); return NULL; } if (!l) return e; cmd_error* h = l; int i = 1; while (h->next) { h = h->next; ++i; } h->next = e; // Remove first element if list is too big if (i > max_size) { cmd_error* ptr = l; l = l->next; cmd_error_destroy(ptr); } return l; }
/* Copyright (c) 2005-2023, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TESTCELLPOPULATIONWRITERS_HPP_ #define TESTCELLPOPULATIONWRITERS_HPP_ #include <cxxtest/TestSuite.h> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include "ArchiveOpener.hpp" #include "AbstractCellBasedTestSuite.hpp" #include "FileComparison.hpp" #include "DifferentiatedCellProliferativeType.hpp" #include "CellLabel.hpp" // Cell population writers #include "BoundaryNodeWriter.hpp" #include "CellPopulationAdjacencyMatrixWriter.hpp" #include "CellPopulationAreaWriter.hpp" #include "CellPopulationElementWriter.hpp" #include "HeterotypicBoundaryLengthWriter.hpp" #include "NodeLocationWriter.hpp" #include "NodeVelocityWriter.hpp" #include "RadialCellDataDistributionWriter.hpp" #include "VertexIntersectionSwapLocationsWriter.hpp" #include "VertexT1SwapLocationsWriter.hpp" #include "VertexT2SwapLocationsWriter.hpp" #include "VertexT3SwapLocationsWriter.hpp" #include "VoronoiDataWriter.hpp" // Files to create populations #include "HoneycombVertexMeshGenerator.hpp" #include "HoneycombMeshGenerator.hpp" #include "PottsMeshGenerator.hpp" #include "CellsGenerator.hpp" #include "FixedG1GenerationalCellCycleModel.hpp" #include "MeshBasedCellPopulation.hpp" #include "MeshBasedCellPopulationWithGhostNodes.hpp" #include "CaBasedCellPopulation.hpp" #include "NodeBasedCellPopulation.hpp" #include "NodeBasedCellPopulationWithBuskeUpdate.hpp" #include "NodeBasedCellPopulationWithParticles.hpp" #include "PottsBasedCellPopulation.hpp" #include "VertexBasedCellPopulation.hpp" #include "PetscSetupAndFinalize.hpp" // Note that high level tests of all cell writers can be found in the // TestMeshBasedCellPopulation::TestMeshBasedCellPopulationWriteResultsToFile class TestCellPopulationWriters : public AbstractCellBasedTestSuite { public: void TestBoundaryNodeWriter() { EXIT_IF_PARALLEL; // Create a simple 3D MeshBasedCellPopulation std::vector<Node<3>*> nodes; nodes.push_back(new Node<3>(0, true, 0.0, 0.0, 0.0)); nodes.push_back(new Node<3>(1, true, 1.0, 1.0, 0.0)); nodes.push_back(new Node<3>(2, true, 1.0, 0.0, 1.0)); nodes.push_back(new Node<3>(3, true, 0.0, 1.0, 1.0)); nodes.push_back(new Node<3>(4, false, 0.5, 0.5, 0.5)); MutableMesh<3,3> mesh(nodes); std::vector<CellPtr> cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 3> cells_generator; cells_generator.GenerateBasic(cells, mesh.GetNumNodes()); MeshBasedCellPopulation<3> cell_population(mesh, cells); // Create an output directory for the writer std::string output_directory = "TestBoundaryNodeWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a BoundaryNodeWriter and test that the correct output is generated BoundaryNodeWriter<3,3> boundary_writer; boundary_writer.OpenOutputFile(output_file_handler); boundary_writer.WriteTimeStamp(); boundary_writer.Visit(&cell_population); boundary_writer.WriteNewline(); boundary_writer.CloseFile(); FileComparison(results_dir + "results.vizboundarynodes", "cell_based/test/data/TestCellPopulationWriters/results.vizboundarynodes").CompareFiles(); // Test that we can append to files boundary_writer.OpenOutputFileForAppend(output_file_handler); boundary_writer.WriteTimeStamp(); boundary_writer.Visit(&cell_population); boundary_writer.WriteNewline(); boundary_writer.CloseFile(); FileComparison(results_dir + "results.vizboundarynodes", "cell_based/test/data/TestCellPopulationWriters/results.vizboundarynodes_twice").CompareFiles(); } void TestBoundaryNodeWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "BoundaryNodeWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_population_writer = new BoundaryNodeWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_population_writer; delete p_population_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_population_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_population_writer_2; delete p_population_writer_2; } } void TestCellPopulationAdjacencyMatrixWriter() { EXIT_IF_PARALLEL; // Test with a MeshBasedCellPopulation HoneycombMeshGenerator tet_generator(5, 5, 0); MutableMesh<2,2>* p_tet_mesh = tet_generator.GetMesh(); std::vector<CellPtr> mesh_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> mesh_based_cells_generator; mesh_based_cells_generator.GenerateBasic(mesh_based_cells, p_tet_mesh->GetNumNodes()); MeshBasedCellPopulation<2> mesh_based_cell_population(*p_tet_mesh, mesh_based_cells); // Label a subset of the cells boost::shared_ptr<AbstractCellProperty> p_label(mesh_based_cell_population.GetCellPropertyRegistry()->Get<CellLabel>()); mesh_based_cell_population.GetCellUsingLocationIndex(0)->AddCellProperty(p_label); mesh_based_cell_population.GetCellUsingLocationIndex(1)->AddCellProperty(p_label); // Create an output directory for the writer std::string output_directory = "TestCellPopulationAdjacencyMatrixWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a CellPopulationAreaWriter and test that the correct output is generated CellPopulationAdjacencyMatrixWriter<2,2> adjacency_writer; adjacency_writer.OpenOutputFile(output_file_handler); adjacency_writer.WriteTimeStamp(); adjacency_writer.Visit(&mesh_based_cell_population); adjacency_writer.WriteNewline(); adjacency_writer.CloseFile(); FileComparison(results_dir + "cellpopulationadjacency.dat", "cell_based/test/data/TestCellPopulationWriters/cellpopulationadjacency.dat").CompareFiles(); // Test that we can append to files adjacency_writer.OpenOutputFileForAppend(output_file_handler); adjacency_writer.WriteTimeStamp(); adjacency_writer.Visit(&mesh_based_cell_population); adjacency_writer.WriteNewline(); adjacency_writer.CloseFile(); FileComparison(results_dir + "cellpopulationadjacency.dat", "cell_based/test/data/TestCellPopulationWriters/cellpopulationadjacency_twice.dat").CompareFiles(); // Coverage of the Visit() method when called on a CaBasedCellPopulation { PottsMeshGenerator<2> ca_based_generator(5, 0, 0, 5, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 5); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); location_indices.push_back(17); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); TS_ASSERT_THROWS_NOTHING(adjacency_writer.Visit(&ca_based_cell_population)); } // Coverage of the Visit() method when called on a NodeBasedCellPopulation { std::vector<Node<2>* > node_based_nodes; node_based_nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); node_based_nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> node_based_mesh; node_based_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, node_based_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(node_based_mesh, node_based_cells); TS_ASSERT_THROWS_NOTHING(adjacency_writer.Visit(&node_based_cell_population)); // Tidy up delete node_based_nodes[0]; delete node_based_nodes[1]; } // Coverage of the Visit() method when called on a PottsBasedCellPopulation { PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); TS_ASSERT_THROWS_NOTHING(adjacency_writer.Visit(&potts_based_cell_population)); } // Coverage of the Visit() method when called on a VertexBasedCellPopulation { HoneycombVertexMeshGenerator vertex_based_generator(4, 6); MutableVertexMesh<2,2>* p_vertex_based_mesh = vertex_based_generator.GetMesh(); std::vector<CellPtr> vertex_based_cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> vertex_based_cells_generator; vertex_based_cells_generator.GenerateBasic(vertex_based_cells, p_vertex_based_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> vertex_based_cell_population(*p_vertex_based_mesh, vertex_based_cells); boost::shared_ptr<AbstractCellProperty> p_new_label(vertex_based_cell_population.GetCellPropertyRegistry()->Get<CellLabel>()); vertex_based_cell_population.GetCellUsingLocationIndex(3)->AddCellProperty(p_new_label); vertex_based_cell_population.GetCellUsingLocationIndex(4)->AddCellProperty(p_new_label); vertex_based_cell_population.GetCellUsingLocationIndex(5)->AddCellProperty(p_new_label); vertex_based_cell_population.GetCellUsingLocationIndex(6)->AddCellProperty(p_new_label); TS_ASSERT_THROWS_NOTHING(adjacency_writer.Visit(&vertex_based_cell_population)); } } void TestCellPopulationAdjacencyMatrixWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "CellPopulationAdjacencyMatrixWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_population_writer = new CellPopulationAdjacencyMatrixWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_population_writer; delete p_population_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_population_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_population_writer_2; delete p_population_writer_2; } } void TestCellPopulationAreaWriter() { EXIT_IF_PARALLEL; // Create a simple 3D MeshBasedCellPopulation std::vector<Node<3>*> nodes; nodes.push_back(new Node<3>(0, true, 0.0, 0.0, 0.0)); nodes.push_back(new Node<3>(1, true, 1.0, 1.0, 0.0)); nodes.push_back(new Node<3>(2, true, 1.0, 0.0, 1.0)); nodes.push_back(new Node<3>(3, true, 0.0, 1.0, 1.0)); nodes.push_back(new Node<3>(4, false, 0.5, 0.5, 0.5)); MutableMesh<3,3> mesh(nodes); std::vector<CellPtr> cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 3> cells_generator; cells_generator.GenerateBasic(cells, mesh.GetNumNodes()); MeshBasedCellPopulation<3> cell_population(mesh, cells); cell_population.CreateVoronoiTessellation(); // Create an output directory for the writer std::string output_directory = "TestCellPopulationAreaWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a CellPopulationAreaWriter and test that the correct output is generated CellPopulationAreaWriter<3,3> area_writer; area_writer.OpenOutputFile(output_file_handler); area_writer.WriteTimeStamp(); area_writer.Visit(&cell_population); area_writer.WriteNewline(); area_writer.CloseFile(); FileComparison(results_dir + "cellpopulationareas.dat", "cell_based/test/data/TestCellPopulationWriters/cellpopulationareas.dat").CompareFiles(); // Test that we can append to files area_writer.OpenOutputFileForAppend(output_file_handler); area_writer.WriteTimeStamp(); area_writer.Visit(&cell_population); area_writer.WriteNewline(); area_writer.CloseFile(); FileComparison(results_dir + "cellpopulationareas.dat", "cell_based/test/data/TestCellPopulationWriters/cellpopulationareas_twice.dat").CompareFiles(); CellPopulationAreaWriter<2,2> area_writer_2d; // Test the correct exception is thrown if using a NodeBasedCellPopulation std::vector<Node<2>* > node_based_nodes; node_based_nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); node_based_nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> nodes_only_mesh; nodes_only_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, nodes_only_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(nodes_only_mesh, node_based_cells); TS_ASSERT_THROWS_THIS(area_writer_2d.Visit(&node_based_cell_population), "CellPopulationAreaWriter cannot be used with a NodeBasedCellPopulation"); // Tidy up for (unsigned i=0; i<node_based_nodes.size(); i++) { delete node_based_nodes[i]; } // Test the correct exception is thrown if using a CaBasedCellPopulation PottsMeshGenerator<2> ca_based_generator(4, 0, 0, 4, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 4); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); TS_ASSERT_THROWS_THIS(area_writer_2d.Visit(&ca_based_cell_population), "CellPopulationAreaWriter cannot be used with a CaBasedCellPopulation"); // Test the correct exception is thrown if using a PottsBasedCellPopulation PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); TS_ASSERT_THROWS_THIS(area_writer_2d.Visit(&potts_based_cell_population), "CellPopulationAreaWriter cannot be used with a PottsBasedCellPopulation"); // Test the correct exception is thrown if using a PottsBasedCellPopulation HoneycombVertexMeshGenerator vertex_based_generator(4, 6); MutableVertexMesh<2,2>* p_vertex_mesh = vertex_based_generator.GetMesh(); std::vector<CellPtr> vertex_based_cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> vertex_based_cells_generator; vertex_based_cells_generator.GenerateBasic(vertex_based_cells, p_vertex_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> vertex_cell_population(*p_vertex_mesh, vertex_based_cells); TS_ASSERT_THROWS_THIS(area_writer_2d.Visit(&vertex_cell_population), "CellPopulationAreaWriter cannot be used with a VertexBasedCellPopulation"); } void TestCellPopulationAreaWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "CellPopulationAreaWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_population_writer = new CellPopulationAreaWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_population_writer; delete p_population_writer; } PetscTools::Barrier(); // Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_population_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_population_writer_2; delete p_population_writer_2; } } void TestCellPopulationElementWriter() { EXIT_IF_PARALLEL; // Create a simple 2D VertexBasedCellPopulation HoneycombVertexMeshGenerator generator(4, 6); MutableVertexMesh<2,2>* p_mesh = generator.GetMesh(); std::vector<CellPtr> cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, p_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> cell_population(*p_mesh, cells); // Create an output directory for the writer std::string output_directory = "TestCellPopulationElementWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a CellPopulationElementWriter and test that the correct output is generated CellPopulationElementWriter<2,2> element_writer; element_writer.OpenOutputFile(output_file_handler); element_writer.WriteTimeStamp(); element_writer.Visit(&cell_population); element_writer.WriteNewline(); element_writer.CloseFile(); FileComparison(results_dir + "results.vizelements", "cell_based/test/data/TestCellPopulationWriters/results.vizelements").CompareFiles(); // Test that we can append to files element_writer.OpenOutputFileForAppend(output_file_handler); element_writer.WriteTimeStamp(); element_writer.Visit(&cell_population); element_writer.WriteNewline(); element_writer.CloseFile(); FileComparison(results_dir + "results.vizelements", "cell_based/test/data/TestCellPopulationWriters/results.vizelements_twice").CompareFiles(); // Test the correct exception is thrown if using a NodeBasedCellPopulation std::vector<Node<2>* > nodes; nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> nodes_only_mesh; nodes_only_mesh.ConstructNodesWithoutMesh(nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, nodes_only_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(nodes_only_mesh, node_based_cells); TS_ASSERT_THROWS_THIS(element_writer.Visit(&node_based_cell_population), "CellPopulationElementWriter cannot be used with a NodeBasedCellPopulation"); for (unsigned i=0; i<nodes.size(); i++) { delete nodes[i]; } // Test the correct exception is thrown if using a CaBasedCellPopulation PottsMeshGenerator<2> ca_based_generator(4, 0, 0, 4, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 4); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); TS_ASSERT_THROWS_THIS(element_writer.Visit(&ca_based_cell_population), "CellPopulationElementWriter cannot be used with a CaBasedCellPopulation"); } void TestCellPopulationElementWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "CellPopulationElementWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_population_writer = new CellPopulationElementWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_population_writer; delete p_population_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_population_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_population_writer_2; delete p_population_writer_2; } } void TestHeterotypicBoundaryLengthWriter() { EXIT_IF_PARALLEL; // Test with a MeshBasedCellPopulationWithGhostNodes { // Create a simple 2D cell population (use ghost nodes to avoid infinite edge lengths in the Voronoi tessellation) HoneycombMeshGenerator generator(5, 3, 2); MutableMesh<2,2>* p_mesh = generator.GetMesh(); std::vector<unsigned> location_indices = generator.GetCellLocationIndices(); std::vector<CellPtr> cells; CellsGenerator<FixedG1GenerationalCellCycleModel,2> cells_generator; cells_generator.GenerateGivenLocationIndices(cells, location_indices); MeshBasedCellPopulationWithGhostNodes<2> cell_population(*p_mesh, cells, location_indices); cell_population.InitialiseCells(); // Label a subset of the cells boost::shared_ptr<AbstractCellProperty> p_label(cell_population.GetCellPropertyRegistry()->Get<CellLabel>()); cell_population.GetCellUsingLocationIndex(20)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(21)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(22)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(23)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(24)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(32)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(39)->AddCellProperty(p_label); /* * In this case, the group of labelled cells 0, 1, 2, 3, 4, 8 share 11 edges * with unlabelled cells, while the isolated labelled cell 11 shares 4 edges * with unlabelled cells. * * Thus there are 15 edges shared between labelled and unlabelled cells. * There are 30 shared edges in total (regardless of label). * Each edge has length 1/sqrt(3) = 0.577350. * * Thus the total length is 30/sqrt(3) and the heterotypic boundary * length is 15/sqrt(3) = 8.660254. * * This can be verified by eyeballing the output file. */ // Create an output directory for the writer std::string output_directory = "TestHeterotypicBoundaryLengthWriterMesh"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a BoundaryNodeWriter and test that the correct output is generated HeterotypicBoundaryLengthWriter<2,2> labelled_boundary_writer; labelled_boundary_writer.OpenOutputFile(output_file_handler); labelled_boundary_writer.WriteTimeStamp(); labelled_boundary_writer.Visit(&cell_population); labelled_boundary_writer.WriteNewline(); labelled_boundary_writer.CloseFile(); FileComparison(results_dir + "heterotypicboundary.dat", "cell_based/test/data/TestCellPopulationWriters/heterotypicboundary.dat_mesh").CompareFiles(); } // Test with a NodeBasedCellPopulation { // Create a simple 2D cell population std::vector<Node<2>* > nodes; for (unsigned j=0; j<4; j++) { for (unsigned i=0; i<6; i++) { unsigned node_index = i + 6*j; nodes.push_back(new Node<2>(node_index, false, (double)i, (double)j)); } } NodesOnlyMesh<2> mesh; mesh.ConstructNodesWithoutMesh(nodes, 1.5); for (unsigned index=0; index<mesh.GetNumNodes(); index++) { mesh.GetNode(index)->SetRadius(0.6); } std::vector<CellPtr> cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes()); NodeBasedCellPopulation<2> cell_population(mesh, cells); cell_population.InitialiseCells(); // Label a subset of the cells boost::shared_ptr<AbstractCellProperty> p_label(cell_population.GetCellPropertyRegistry()->Get<CellLabel>()); cell_population.GetCellUsingLocationIndex(0)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(6)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(9)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(10)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(11)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(12)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(15)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(16)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(17)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(19)->AddCellProperty(p_label); /* * In this case, the group of labelled cells 0, 1, 12 share 4 edges with * unlabelled cells; the group of labelled cells 9, 10, 11, 15, 16, 17 * share 8 edges with unlabelled cells; and the isolated labelled cell 19 * shares 3 edges with unlabelled cells. * Thus there are 15 edges shared between labelled and unlabelled cells. * * In total there are 38 shared edges (regardless of label). * * Since each cell's radius is set to 0.6 and neighbours are a distance * 1.0 apart, the approximate shared edge is given by sqrt(11)/5 = 0.663324. * * Thus the total length is 38*sqrt(11)/5 = 25.206348 and the heterotypic * boundary length is 15*sqrt(11)/5 = 9.949874. * * This can be verified by eyeballing the output file. */ // Create an output directory for the writer std::string output_directory = "TestHeterotypicBoundaryLengthWriterNode"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a BoundaryNodeWriter and test that the correct output is generated HeterotypicBoundaryLengthWriter<2,2> labelled_boundary_writer; labelled_boundary_writer.OpenOutputFile(output_file_handler); labelled_boundary_writer.WriteTimeStamp(); labelled_boundary_writer.Visit(&cell_population); labelled_boundary_writer.WriteNewline(); labelled_boundary_writer.CloseFile(); FileComparison(results_dir + "heterotypicboundary.dat", "cell_based/test/data/TestCellPopulationWriters/heterotypicboundary.dat_node").CompareFiles(); // Avoid memory leak for (unsigned i=0; i<nodes.size(); i++) { delete nodes[i]; } } // Test with a PottsBasedCellPopulation { // Create a simple 2D cell population PottsMeshGenerator<2> generator(9, 3, 3, 6, 3, 2); PottsMesh<2>* p_mesh = generator.GetMesh(); std::vector<CellPtr> cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, p_mesh->GetNumElements()); PottsBasedCellPopulation<2> cell_population(*p_mesh, cells); cell_population.InitialiseCells(); // Label a subset of the cells boost::shared_ptr<AbstractCellProperty> p_label(cell_population.GetCellPropertyRegistry()->Get<CellLabel>()); cell_population.GetCellUsingLocationIndex(0)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(1)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(4)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(5)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(8)->AddCellProperty(p_label); /* * In this case, the group of labelled cells 0, 1, 4, 5 share 3 'long' edges * and 3 'short' edges with unlabelled cells. * * Thus there are 6 edges shared between labelled and unlabelled cells. * * In total there are 6 'long' edges and 6 'short' edges, thus 12 shared * edges in total (regardless of label). 'Long' edges have length 3 and * 'short' edges have length 2. * * Thus the total length is 6*3 + 6*2 = 30 and the heterotypic boundary * length is 3*3 + 3*2 = 15. * * Note the number of cell pairs is 12 and the number of heterotypic * cell pairs is 6. * * This can be verified by eyeballing the output file. */ // Create an output directory for the writer std::string output_directory = "TestHeterotypicBoundaryLengthWriterPotts"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a BoundaryNodeWriter and test that the correct output is generated HeterotypicBoundaryLengthWriter<2,2> labelled_boundary_writer; labelled_boundary_writer.OpenOutputFile(output_file_handler); labelled_boundary_writer.WriteTimeStamp(); labelled_boundary_writer.Visit(&cell_population); labelled_boundary_writer.WriteNewline(); labelled_boundary_writer.CloseFile(); FileComparison(results_dir + "heterotypicboundary.dat", "cell_based/test/data/TestCellPopulationWriters/heterotypicboundary.dat_potts").CompareFiles(); } // Test with a CaBasedCellPopulation { // Create a simple 2D cell population PottsMeshGenerator<2> generator(3, 0, 0, 3, 0, 0); PottsMesh<2>* p_mesh = generator.GetMesh(); std::vector<unsigned> location_indices; for (unsigned i=0; i<p_mesh->GetNumNodes(); i++) { location_indices.push_back(i); } std::vector<CellPtr> cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, location_indices.size()); CaBasedCellPopulation<2> cell_population(*p_mesh, cells, location_indices); cell_population.InitialiseCells(); // Label a subset of the cells boost::shared_ptr<AbstractCellProperty> p_label(cell_population.GetCellPropertyRegistry()->Get<CellLabel>()); cell_population.GetCellUsingLocationIndex(0)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(1)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(4)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(5)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(8)->AddCellProperty(p_label); /* * In this case, the group of labelled cells 0, 1, 4, 5 share 6 edges * edges with unlabelled cells. * * Thus there are 5 edges shared between labelled and unlabelled cells. * * In total there are 12 shared edges in total (regardless of label). * All edges have length 1. * * Thus the total length is 12 and the heterotypic boundary * length is 5. Note the number of associated neighbour connections is the same. * * This can be verified by eyeballing the output file. */ // Create an output directory for the writer std::string output_directory = "TestHeterotypicBoundaryLengthWriterCa"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a BoundaryNodeWriter and test that the correct output is generated HeterotypicBoundaryLengthWriter<2,2> labelled_boundary_writer; labelled_boundary_writer.OpenOutputFile(output_file_handler); labelled_boundary_writer.WriteTimeStamp(); labelled_boundary_writer.Visit(&cell_population); labelled_boundary_writer.WriteNewline(); labelled_boundary_writer.CloseFile(); FileComparison(results_dir + "heterotypicboundary.dat", "cell_based/test/data/TestCellPopulationWriters/heterotypicboundary.dat_ca").CompareFiles(); } // Test with a VertexBasedCellPopulation { // Create a simple 2D cell population HoneycombVertexMeshGenerator generator(4, 4); MutableVertexMesh<2,2>* p_mesh = generator.GetMesh(); std::vector<CellPtr> cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, p_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> cell_population(*p_mesh, cells); cell_population.InitialiseCells(); // Label a subset of the cells boost::shared_ptr<AbstractCellProperty> p_label(cell_population.GetCellPropertyRegistry()->Get<CellLabel>()); cell_population.GetCellUsingLocationIndex(1)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(4)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(7)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(8)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(9)->AddCellProperty(p_label); cell_population.GetCellUsingLocationIndex(12)->AddCellProperty(p_label); /* * In this case, the group of labelled cells 1, 4, 8, 9, 12 share 9 edges * with unlabelled cells, while the isolated labelled cell 7 shares 3 edges * with unlabelled cells. * * Thus there are 12 edges shared between labelled and unlabelled cells. * There are 33 shared edges in total (regardless of label). * Each edge has length 1/sqrt(3) = 0.577350. * * Thus the total length is 33/sqrt(3) = 19.052558 and the heterotypic boundary * length is 12/sqrt(3) = 6.928203. * * This can be verified by eyeballing the output file. */ // Create an output directory for the writer std::string output_directory = "TestHeterotypicBoundaryLengthWriterVertex"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a BoundaryNodeWriter and test that the correct output is generated HeterotypicBoundaryLengthWriter<2,2> labelled_boundary_writer; labelled_boundary_writer.OpenOutputFile(output_file_handler); labelled_boundary_writer.WriteTimeStamp(); labelled_boundary_writer.Visit(&cell_population); labelled_boundary_writer.WriteNewline(); labelled_boundary_writer.CloseFile(); FileComparison(results_dir + "heterotypicboundary.dat", "cell_based/test/data/TestCellPopulationWriters/heterotypicboundary.dat_vertex").CompareFiles(); // Test that we can append to files labelled_boundary_writer.OpenOutputFileForAppend(output_file_handler); labelled_boundary_writer.WriteTimeStamp(); labelled_boundary_writer.Visit(&cell_population); labelled_boundary_writer.WriteNewline(); labelled_boundary_writer.CloseFile(); FileComparison(results_dir + "heterotypicboundary.dat", "cell_based/test/data/TestCellPopulationWriters/heterotypicboundary.dat_vertex_twice").CompareFiles(); } } void TestHeterotypicBoundaryLengthWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "HeterotypicBoundaryLengthWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_population_writer = new HeterotypicBoundaryLengthWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_population_writer; delete p_population_writer; } PetscTools::Barrier(); // Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_population_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_population_writer_2; delete p_population_writer_2; } } void TestNodeLocationWriter() { EXIT_IF_PARALLEL; // Create a simple 3D NodeBasedCellPopulation std::vector<Node<3>* > nodes; nodes.push_back(new Node<3>(0, false)); nodes.push_back(new Node<3>(1, false, 1.0, 1.0, 1.0)); NodesOnlyMesh<3> mesh; mesh.ConstructNodesWithoutMesh(nodes, 1.5); std::vector<CellPtr> cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 3> generator; generator.GenerateBasic(cells, mesh.GetNumNodes()); NodeBasedCellPopulation<3> cell_population(mesh, cells); // Create an output directory for the writer std::string output_directory = "TestNodeLocationWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a NodeLocationWriter and test that the correct output is generated NodeLocationWriter<3,3> location_writer; location_writer.OpenOutputFile(output_file_handler); location_writer.WriteTimeStamp(); location_writer.Visit(&cell_population); location_writer.WriteNewline(); location_writer.CloseFile(); FileComparison(results_dir + "results.viznodes", "cell_based/test/data/TestCellPopulationWriters/results.viznodes").CompareFiles(); // Test that we can append to files location_writer.OpenOutputFileForAppend(output_file_handler); location_writer.WriteTimeStamp(); location_writer.Visit(&cell_population); location_writer.WriteNewline(); location_writer.CloseFile(); FileComparison(results_dir + "results.viznodes", "cell_based/test/data/TestCellPopulationWriters/results.viznodes_twice").CompareFiles(); // Avoid memory leaks delete nodes[0]; delete nodes[1]; } void TestNodeLocationWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "NodeLocationWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_population_writer = new NodeLocationWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_population_writer; delete p_population_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_population_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_population_writer_2; delete p_population_writer_2; } } void TestNodeVelocityWriterWithMeshBasedCellPopulation() { EXIT_IF_PARALLEL; // Set up SimulationTime (needed to avoid tripping an assertion when accessing the time step) SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // Create a simple 3D MeshBasedCellPopulation std::vector<Node<3>*> mesh_based_nodes; mesh_based_nodes.push_back(new Node<3>(0, true, 0.0, 0.0, 0.0)); mesh_based_nodes.push_back(new Node<3>(1, true, 1.0, 1.0, 0.0)); mesh_based_nodes.push_back(new Node<3>(2, true, 1.0, 0.0, 1.0)); mesh_based_nodes.push_back(new Node<3>(3, true, 0.0, 1.0, 1.0)); mesh_based_nodes.push_back(new Node<3>(4, false, 0.5, 0.5, 0.5)); MutableMesh<3,3> mesh_based_mesh(mesh_based_nodes); std::vector<CellPtr> mesh_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 3> mesh_based_cells_generator; mesh_based_cells_generator.GenerateBasic(mesh_based_cells, mesh_based_mesh.GetNumNodes()); MeshBasedCellPopulation<3> mesh_based_cell_population(mesh_based_mesh, mesh_based_cells); // Call ClearAppliedForce() on each node (needed to avoid tripping an assertion when accessing node attributes) for (AbstractMesh<3,3>::NodeIterator node_iter = mesh_based_cell_population.rGetMesh().GetNodeIteratorBegin(); node_iter != mesh_based_cell_population.rGetMesh().GetNodeIteratorEnd(); ++node_iter) { node_iter->ClearAppliedForce(); } // Add a non-zero force to some nodes c_vector<double, 3> force_on_node_2; force_on_node_2[0] = 11.0; force_on_node_2[1] = 1.3; force_on_node_2[2] = 3.7; mesh_based_cell_population.GetNode(2)->AddAppliedForceContribution(force_on_node_2); c_vector<double, 3> force_on_node_3; force_on_node_3[0] = 4.5; force_on_node_3[1] = 5.9; force_on_node_3[2] = 0.6; mesh_based_cell_population.GetNode(3)->AddAppliedForceContribution(force_on_node_3); // Create an output directory for the writer std::string mesh_based_output_directory = "TestNodeVelocityWriterWithMeshBasedCellPopulation"; OutputFileHandler mesh_based_output_file_handler(mesh_based_output_directory, false); std::string mesh_based_results_dir = mesh_based_output_file_handler.GetOutputDirectoryFullPath(); // Create a NodeNelocityWriter and test that the correct output is generated NodeVelocityWriter<3,3> mesh_based_writer; mesh_based_writer.OpenOutputFile(mesh_based_output_file_handler); mesh_based_writer.WriteTimeStamp(); mesh_based_writer.Visit(&mesh_based_cell_population); mesh_based_writer.WriteNewline(); mesh_based_writer.CloseFile(); FileComparison(mesh_based_results_dir + "nodevelocities.dat", "cell_based/test/data/TestCellPopulationWriters/nodevelocities_mesh.dat").CompareFiles(); } void TestNodeVelocityWriterWithNodeBasedCellPopulation() { EXIT_IF_PARALLEL; // Set up SimulationTime (needed to avoid tripping an assertion when accessing the time step) SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // Create a simple 3D NodeBasedCellPopulation std::vector<Node<3>* > node_based_nodes; node_based_nodes.push_back(new Node<3>(0, false, 0.0, 0.0, 0.0)); node_based_nodes.push_back(new Node<3>(1, false, 1.0, 1.0, 1.0)); NodesOnlyMesh<3> node_based_mesh; node_based_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 3> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, node_based_mesh.GetNumNodes()); NodeBasedCellPopulation<3> node_based_cell_population(node_based_mesh, node_based_cells); // Call ClearAppliedForce() on each node (needed to avoid tripping an assertion when accessing node attributes) for (AbstractMesh<3,3>::NodeIterator node_iter = node_based_cell_population.rGetMesh().GetNodeIteratorBegin(); node_iter != node_based_cell_population.rGetMesh().GetNodeIteratorEnd(); ++node_iter) { node_iter->ClearAppliedForce(); } // Create an output directory for the writer std::string node_based_output_directory = "TestNodeVelocityWriterWithNodeBasedCellPopulation"; OutputFileHandler node_based_output_file_handler(node_based_output_directory, false); std::string node_based_results_dir = node_based_output_file_handler.GetOutputDirectoryFullPath(); // Create a NodeNelocityWriter and test that the correct output is generated NodeVelocityWriter<3,3> node_based_writer; node_based_writer.OpenOutputFile(node_based_output_file_handler); node_based_writer.WriteTimeStamp(); node_based_writer.Visit(&node_based_cell_population); node_based_writer.WriteNewline(); node_based_writer.CloseFile(); // At this time step, the node velocity components should all be zero FileComparison(node_based_results_dir + "nodevelocities.dat", "cell_based/test/data/TestCellPopulationWriters/nodevelocities_node.dat").CompareFiles(); // Now increment time and add a non-zero force for each node SimulationTime::Instance()->IncrementTimeOneStep(); c_vector<double, 3> force_on_node_0; force_on_node_0[0] = 1.0; force_on_node_0[1] = 2.0; force_on_node_0[2] = 3.0; node_based_cell_population.GetNode(0)->AddAppliedForceContribution(force_on_node_0); c_vector<double, 3> force_on_node_1; force_on_node_1[0] = 4.0; force_on_node_1[1] = 5.0; force_on_node_1[2] = 6.0; node_based_cell_population.GetNode(1)->AddAppliedForceContribution(force_on_node_1); // Test that we can append to files node_based_writer.OpenOutputFileForAppend(node_based_output_file_handler); node_based_writer.WriteTimeStamp(); node_based_writer.Visit(&node_based_cell_population); node_based_writer.WriteNewline(); node_based_writer.CloseFile(); // At the next time step, the node velocity components should be increasing positive integers FileComparison(node_based_results_dir + "nodevelocities.dat", "cell_based/test/data/TestCellPopulationWriters/nodevelocities_node_twice.dat").CompareFiles(); // Avoid memory leaks delete node_based_nodes[0]; delete node_based_nodes[1]; } void TestNodeVelocityWriterWithVertexBasedCellPopulation() { EXIT_IF_PARALLEL; // Set up SimulationTime (needed to avoid tripping an assertion when accessing the time step) SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // Create a simple 2D VertexBasedCellPopulation HoneycombVertexMeshGenerator vertex_based_generator(4, 6); MutableVertexMesh<2,2>* p_vertex_based_mesh = vertex_based_generator.GetMesh(); std::vector<CellPtr> vertex_based_cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> vertex_based_cells_generator; vertex_based_cells_generator.GenerateBasic(vertex_based_cells, p_vertex_based_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> vertex_based_cell_population(*p_vertex_based_mesh, vertex_based_cells); // Call ClearAppliedForce() on each node (needed to avoid tripping an assertion when accessing node attributes) for (AbstractMesh<2,2>::NodeIterator node_iter = vertex_based_cell_population.rGetMesh().GetNodeIteratorBegin(); node_iter != vertex_based_cell_population.rGetMesh().GetNodeIteratorEnd(); ++node_iter) { node_iter->ClearAppliedForce(); } // Add a non-zero force to some nodes c_vector<double, 2> force_on_node_0; force_on_node_0[0] = 0.01; force_on_node_0[1] = 14.8; vertex_based_cell_population.GetNode(0)->AddAppliedForceContribution(force_on_node_0); c_vector<double, 2> force_on_node_2; force_on_node_2[0] = 3.96; force_on_node_2[1] = 12.6; vertex_based_cell_population.GetNode(2)->AddAppliedForceContribution(force_on_node_2); // Create an output directory for the writer std::string vertex_based_output_directory = "TestNodeVelocityWriterWithVertexBasedCellPopulation"; OutputFileHandler vertex_based_output_file_handler(vertex_based_output_directory, false); std::string vertex_based_results_dir = vertex_based_output_file_handler.GetOutputDirectoryFullPath(); // Create a NodeNelocityWriter and test that the correct output is generated NodeVelocityWriter<2,2> vertex_based_writer; vertex_based_writer.OpenOutputFile(vertex_based_output_file_handler); vertex_based_writer.WriteTimeStamp(); vertex_based_writer.Visit(&vertex_based_cell_population); vertex_based_writer.WriteNewline(); vertex_based_writer.CloseFile(); FileComparison(vertex_based_results_dir + "nodevelocities.dat", "cell_based/test/data/TestCellPopulationWriters/nodevelocities_vertex.dat").CompareFiles(); } void TestNodeVelocityWriterExceptions() { EXIT_IF_PARALLEL; // Test the correct exception is thrown if using a CaBasedCellPopulation PottsMeshGenerator<2> ca_based_generator(4, 0, 0, 4, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 4); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); NodeVelocityWriter<2,2> node_velocity_writer; TS_ASSERT_THROWS_THIS(node_velocity_writer.Visit(&ca_based_cell_population), "NodeVelocityWriter cannot be used with a CaBasedCellPopulation"); // Test the correct exception is thrown if using a PottsBasedCellPopulation PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); TS_ASSERT_THROWS_THIS(node_velocity_writer.Visit(&potts_based_cell_population), "NodeVelocityWriter cannot be used with a PottsBasedCellPopulation"); } void TestNodeVelocityWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "NodeVelocityWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_population_writer = new NodeVelocityWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_population_writer; delete p_population_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_population_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_population_writer_2; delete p_population_writer_2; } } void TestRadialCellDataDistributionWriter() { EXIT_IF_PARALLEL; // Test with a VerexBasedCellPopulation HoneycombVertexMeshGenerator generator(4, 4); MutableVertexMesh<2,2>* p_mesh = generator.GetMesh(); std::vector<CellPtr> cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, p_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> cell_population(*p_mesh, cells); double value = 0.0; for (AbstractCellPopulation<2>::Iterator cell_iter=cell_population.Begin(); cell_iter!=cell_population.End(); ++cell_iter) { cell_iter->GetCellData()->SetItem("this average", value); value += 1.0; } // Create an output directory for the writer std::string output_directory = "TestRadialCellDataDistributionWriterVertex"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a RadialCellDataDistributionWriter and test that the correct output is generated RadialCellDataDistributionWriter<2,2> radial_writer; radial_writer.SetVariableName("this average"); radial_writer.SetNumRadialBins(3); radial_writer.OpenOutputFile(output_file_handler); radial_writer.WriteTimeStamp(); radial_writer.Visit(&cell_population); radial_writer.WriteNewline(); radial_writer.CloseFile(); FileComparison(results_dir + "radial_dist.dat", "cell_based/test/data/TestCellPopulationWriters/radial_dist.dat").CompareFiles(); // Test that we can append to files radial_writer.OpenOutputFileForAppend(output_file_handler); radial_writer.WriteTimeStamp(); radial_writer.Visit(&cell_population); radial_writer.WriteNewline(); radial_writer.CloseFile(); FileComparison(results_dir + "radial_dist.dat", "cell_based/test/data/TestCellPopulationWriters/radial_dist_twice.dat").CompareFiles(); ///\todo Improve tests below (#2847) // Test with a MeshBasedCellPopulation { HoneycombMeshGenerator tet_generator(5, 5, 0); MutableMesh<2,2>* p_tet_mesh = tet_generator.GetMesh(); std::vector<CellPtr> mesh_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> mesh_based_cells_generator; mesh_based_cells_generator.GenerateBasic(mesh_based_cells, p_tet_mesh->GetNumNodes()); MeshBasedCellPopulation<2> mesh_based_cell_population(*p_tet_mesh, mesh_based_cells); for (AbstractCellPopulation<2>::Iterator cell_iter=mesh_based_cell_population.Begin(); cell_iter!=mesh_based_cell_population.End(); ++cell_iter) { cell_iter->GetCellData()->SetItem("this average", 1.0); } radial_writer.Visit(&mesh_based_cell_population); } // Test with a CaBasedCellPopulation { PottsMeshGenerator<2> ca_based_generator(5, 0, 0, 5, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 5); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); location_indices.push_back(17); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); for (AbstractCellPopulation<2>::Iterator cell_iter=ca_based_cell_population.Begin(); cell_iter!=ca_based_cell_population.End(); ++cell_iter) { cell_iter->GetCellData()->SetItem("this average", 1.0); } radial_writer.Visit(&ca_based_cell_population); } // Test with a NodeBasedCellPopulation { std::vector<Node<2>* > node_based_nodes; node_based_nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); node_based_nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> node_based_mesh; node_based_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, node_based_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(node_based_mesh, node_based_cells); for (AbstractCellPopulation<2>::Iterator cell_iter=node_based_cell_population.Begin(); cell_iter!=node_based_cell_population.End(); ++cell_iter) { cell_iter->GetCellData()->SetItem("this average", 1.0); } TS_ASSERT_THROWS_NOTHING(radial_writer.Visit(&node_based_cell_population)); // Tidy up delete node_based_nodes[0]; delete node_based_nodes[1]; } // Test with a PottsBasedCellPopulation { PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); for (AbstractCellPopulation<2>::Iterator cell_iter=potts_based_cell_population.Begin(); cell_iter!=potts_based_cell_population.End(); ++cell_iter) { cell_iter->GetCellData()->SetItem("this average", 1.0); } TS_ASSERT_THROWS_NOTHING(radial_writer.Visit(&potts_based_cell_population)); } } void TestRadialCellDataDistributionWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "RadialCellDataDistributionWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_cell_writer = new RadialCellDataDistributionWriter<2,2>(); static_cast<RadialCellDataDistributionWriter<2,2>*>(p_cell_writer)->SetVariableName("radial average"); static_cast<RadialCellDataDistributionWriter<2,2>*>(p_cell_writer)->SetNumRadialBins(5); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_cell_writer; delete p_cell_writer; } PetscTools::Barrier(); // Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_cell_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_cell_writer_2; typedef RadialCellDataDistributionWriter<2,2> RadialWriter; TS_ASSERT_EQUALS(static_cast<RadialWriter*>(p_cell_writer_2)->GetVariableName(), "radial average"); TS_ASSERT_EQUALS(static_cast<RadialWriter*>(p_cell_writer_2)->GetNumRadialBins(), 5u); delete p_cell_writer_2; } } void TestVertexT1SwapLocationsWriter() { EXIT_IF_PARALLEL; // Create a simple 2D VertexBasedCellPopulation HoneycombVertexMeshGenerator generator(4, 6); MutableVertexMesh<2,2>* p_mesh = generator.GetMesh(); std::vector<CellPtr> cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, p_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> cell_population(*p_mesh, cells); // Create an output directory for the writer std::string output_directory = "TestVertexT1SwapLocationsWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a VertexT1SwapLocationsWriter and test that the correct output is generated VertexT1SwapLocationsWriter<2,2> t1_swaps_writer; t1_swaps_writer.OpenOutputFile(output_file_handler); t1_swaps_writer.WriteTimeStamp(); t1_swaps_writer.Visit(&cell_population); t1_swaps_writer.WriteNewline(); t1_swaps_writer.CloseFile(); FileComparison(results_dir + "T1SwapLocations.dat", "cell_based/test/data/TestCellPopulationWriters/T1SwapLocations.dat").CompareFiles(); // Test that we can append to files t1_swaps_writer.OpenOutputFileForAppend(output_file_handler); t1_swaps_writer.WriteTimeStamp(); t1_swaps_writer.Visit(&cell_population); t1_swaps_writer.WriteNewline(); t1_swaps_writer.CloseFile(); FileComparison(results_dir + "T1SwapLocations.dat", "cell_based/test/data/TestCellPopulationWriters/T1SwapLocations_twice.dat").CompareFiles(); { // Coverage of the Visit() method when called on a MeshBasedCellPopulation HoneycombMeshGenerator tet_generator(5, 5, 0); MutableMesh<2,2>* p_tet_mesh = tet_generator.GetMesh(); std::vector<CellPtr> mesh_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> mesh_based_cells_generator; mesh_based_cells_generator.GenerateBasic(mesh_based_cells, p_tet_mesh->GetNumNodes()); MeshBasedCellPopulation<2> mesh_based_cell_population(*p_tet_mesh, mesh_based_cells); TS_ASSERT_THROWS_NOTHING(t1_swaps_writer.Visit(&mesh_based_cell_population)); } { // Coverage of the Visit() method when called on a CaBasedCellPopulation PottsMeshGenerator<2> ca_based_generator(5, 0, 0, 5, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 5); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); location_indices.push_back(17); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); TS_ASSERT_THROWS_NOTHING(t1_swaps_writer.Visit(&ca_based_cell_population)); } { // Coverage of the Visit() method when called on a NodeBasedCellPopulation std::vector<Node<2>* > node_based_nodes; node_based_nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); node_based_nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> node_based_mesh; node_based_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, node_based_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(node_based_mesh, node_based_cells); TS_ASSERT_THROWS_NOTHING(t1_swaps_writer.Visit(&node_based_cell_population)); // Tidy up delete node_based_nodes[0]; delete node_based_nodes[1]; } { // Coverage of the Visit() method when called on a PottsBasedCellPopulation PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); TS_ASSERT_THROWS_NOTHING(t1_swaps_writer.Visit(&potts_based_cell_population)); } } void TestVertexT1SwapLocationsWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "VertexT1SwapLocationsWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_cell_writer = new VertexT1SwapLocationsWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_cell_writer; delete p_cell_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_cell_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_cell_writer_2; delete p_cell_writer_2; } } void TestVertexT2SwapLocationsWriter() { EXIT_IF_PARALLEL; // Create a simple 2D VertexBasedCellPopulation HoneycombVertexMeshGenerator generator(4, 6); MutableVertexMesh<2,2>* p_mesh = generator.GetMesh(); std::vector<CellPtr> cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, p_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> cell_population(*p_mesh, cells); // Create an output directory for the writer std::string output_directory = "TestVertexT2SwapLocationsWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a VertexT2SwapLocationsWriter and test that the correct output is generated VertexT2SwapLocationsWriter<2,2> t2_swaps_writer; t2_swaps_writer.OpenOutputFile(output_file_handler); t2_swaps_writer.WriteTimeStamp(); t2_swaps_writer.Visit(&cell_population); t2_swaps_writer.WriteNewline(); t2_swaps_writer.CloseFile(); FileComparison(results_dir + "T2SwapLocations.dat", "cell_based/test/data/TestCellPopulationWriters/T2SwapLocations.dat").CompareFiles(); // Test that we can append to files t2_swaps_writer.OpenOutputFileForAppend(output_file_handler); t2_swaps_writer.WriteTimeStamp(); t2_swaps_writer.Visit(&cell_population); t2_swaps_writer.WriteNewline(); t2_swaps_writer.CloseFile(); FileComparison(results_dir + "T2SwapLocations.dat", "cell_based/test/data/TestCellPopulationWriters/T2SwapLocations_twice.dat").CompareFiles(); { // Coverage of the Visit() method when called on a MeshBasedCellPopulation HoneycombMeshGenerator tet_generator(5, 5, 0); MutableMesh<2,2>* p_tet_mesh = tet_generator.GetMesh(); std::vector<CellPtr> mesh_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> mesh_based_cells_generator; mesh_based_cells_generator.GenerateBasic(mesh_based_cells, p_tet_mesh->GetNumNodes()); MeshBasedCellPopulation<2> mesh_based_cell_population(*p_tet_mesh, mesh_based_cells); TS_ASSERT_THROWS_NOTHING(t2_swaps_writer.Visit(&mesh_based_cell_population)); } { // Coverage of the Visit() method when called on a CaBasedCellPopulation PottsMeshGenerator<2> ca_based_generator(5, 0, 0, 5, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 5); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); location_indices.push_back(17); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); TS_ASSERT_THROWS_NOTHING(t2_swaps_writer.Visit(&ca_based_cell_population)); } { // Coverage of the Visit() method when called on a NodeBasedCellPopulation std::vector<Node<2>* > node_based_nodes; node_based_nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); node_based_nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> node_based_mesh; node_based_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, node_based_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(node_based_mesh, node_based_cells); TS_ASSERT_THROWS_NOTHING(t2_swaps_writer.Visit(&node_based_cell_population)); // Tidy up delete node_based_nodes[0]; delete node_based_nodes[1]; } { // Coverage of the Visit() method when called on a PottsBasedCellPopulation PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); TS_ASSERT_THROWS_NOTHING(t2_swaps_writer.Visit(&potts_based_cell_population)); } } void TestVertexT2SwapLocationsWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "VertexT2SwapLocationsWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_cell_writer = new VertexT2SwapLocationsWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_cell_writer; delete p_cell_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_cell_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_cell_writer_2; delete p_cell_writer_2; } } void TestVertexT3SwapLocationsWriter() { EXIT_IF_PARALLEL; // Create a simple 2D VertexBasedCellPopulation HoneycombVertexMeshGenerator generator(4, 6); MutableVertexMesh<2,2>* p_mesh = generator.GetMesh(); std::vector<CellPtr> cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, p_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> cell_population(*p_mesh, cells); // Create an output directory for the writer std::string output_directory = "TestVertexT2SwapLocationsWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a VertexT1SwapLocationsWriter and test that the correct output is generated VertexT3SwapLocationsWriter<2,2> t3_swaps_writer; t3_swaps_writer.OpenOutputFile(output_file_handler); t3_swaps_writer.WriteTimeStamp(); t3_swaps_writer.Visit(&cell_population); t3_swaps_writer.WriteNewline(); t3_swaps_writer.CloseFile(); FileComparison(results_dir + "T3SwapLocations.dat", "cell_based/test/data/TestCellPopulationWriters/T3SwapLocations.dat").CompareFiles(); // Test that we can append to files t3_swaps_writer.OpenOutputFileForAppend(output_file_handler); t3_swaps_writer.WriteTimeStamp(); t3_swaps_writer.Visit(&cell_population); t3_swaps_writer.WriteNewline(); t3_swaps_writer.CloseFile(); FileComparison(results_dir + "T3SwapLocations.dat", "cell_based/test/data/TestCellPopulationWriters/T3SwapLocations_twice.dat").CompareFiles(); { // Coverage of the Visit() method when called on a MeshBasedCellPopulation HoneycombMeshGenerator tet_generator(5, 5, 0); MutableMesh<2,2>* p_tet_mesh = tet_generator.GetMesh(); std::vector<CellPtr> mesh_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> mesh_based_cells_generator; mesh_based_cells_generator.GenerateBasic(mesh_based_cells, p_tet_mesh->GetNumNodes()); MeshBasedCellPopulation<2> mesh_based_cell_population(*p_tet_mesh, mesh_based_cells); TS_ASSERT_THROWS_NOTHING(t3_swaps_writer.Visit(&mesh_based_cell_population)); } { // Coverage of the Visit() method when called on a CaBasedCellPopulation PottsMeshGenerator<2> ca_based_generator(5, 0, 0, 5, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 5); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); location_indices.push_back(17); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); TS_ASSERT_THROWS_NOTHING(t3_swaps_writer.Visit(&ca_based_cell_population)); } { // Coverage of the Visit() method when called on a NodeBasedCellPopulation std::vector<Node<2>* > node_based_nodes; node_based_nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); node_based_nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> node_based_mesh; node_based_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, node_based_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(node_based_mesh, node_based_cells); TS_ASSERT_THROWS_NOTHING(t3_swaps_writer.Visit(&node_based_cell_population)); // Tidy up delete node_based_nodes[0]; delete node_based_nodes[1]; } { // Coverage of the Visit() method when called on a PottsBasedCellPopulation PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); TS_ASSERT_THROWS_NOTHING(t3_swaps_writer.Visit(&potts_based_cell_population)); } } void TestVertexT3SwapLocationsWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "VertexT3SwapLocationsWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_cell_writer = new VertexT3SwapLocationsWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_cell_writer; delete p_cell_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_cell_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_cell_writer_2; delete p_cell_writer_2; } } void TestVertexIntersectionSwapLocationsWriter() { EXIT_IF_PARALLEL; // Create a simple 2D VertexBasedCellPopulation HoneycombVertexMeshGenerator generator(4, 6); MutableVertexMesh<2,2>* p_mesh = generator.GetMesh(); std::vector<CellPtr> cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator; cells_generator.GenerateBasic(cells, p_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> cell_population(*p_mesh, cells); // Create an output directory for the writer std::string output_directory = "TestVertexIntersectionSwapLocationsWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a VertexIntersectionSwapLocationsWriter and test that the correct output is generated VertexIntersectionSwapLocationsWriter<2,2> intersection_swaps_writer; intersection_swaps_writer.OpenOutputFile(output_file_handler); intersection_swaps_writer.WriteTimeStamp(); intersection_swaps_writer.Visit(&cell_population); intersection_swaps_writer.WriteNewline(); intersection_swaps_writer.CloseFile(); FileComparison(results_dir + "IntersectionSwapLocations.dat", "cell_based/test/data/TestCellPopulationWriters/IntersectionSwapLocations.dat").CompareFiles(); // Test that we can append to files intersection_swaps_writer.OpenOutputFileForAppend(output_file_handler); intersection_swaps_writer.WriteTimeStamp(); intersection_swaps_writer.Visit(&cell_population); intersection_swaps_writer.WriteNewline(); intersection_swaps_writer.CloseFile(); FileComparison(results_dir + "IntersectionSwapLocations.dat", "cell_based/test/data/TestCellPopulationWriters/IntersectionSwapLocations_twice.dat").CompareFiles(); { // Coverage of the Visit() method when called on a MeshBasedCellPopulation HoneycombMeshGenerator tet_generator(5, 5, 0); MutableMesh<2,2>* p_tet_mesh = tet_generator.GetMesh(); std::vector<CellPtr> mesh_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> mesh_based_cells_generator; mesh_based_cells_generator.GenerateBasic(mesh_based_cells, p_tet_mesh->GetNumNodes()); MeshBasedCellPopulation<2> mesh_based_cell_population(*p_tet_mesh, mesh_based_cells); TS_ASSERT_THROWS_NOTHING(intersection_swaps_writer.Visit(&mesh_based_cell_population)); } { // Coverage of the Visit() method when called on a CaBasedCellPopulation PottsMeshGenerator<2> ca_based_generator(5, 0, 0, 5, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 5); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); location_indices.push_back(17); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); TS_ASSERT_THROWS_NOTHING(intersection_swaps_writer.Visit(&ca_based_cell_population)); } { // Coverage of the Visit() method when called on a NodeBasedCellPopulation std::vector<Node<2>* > node_based_nodes; node_based_nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); node_based_nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> node_based_mesh; node_based_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, node_based_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(node_based_mesh, node_based_cells); TS_ASSERT_THROWS_NOTHING(intersection_swaps_writer.Visit(&node_based_cell_population)); // Tidy up delete node_based_nodes[0]; delete node_based_nodes[1]; } { // Coverage of the Visit() method when called on a PottsBasedCellPopulation PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); TS_ASSERT_THROWS_NOTHING(intersection_swaps_writer.Visit(&potts_based_cell_population)); } } void TestVertexIntersectionSwapLocationsWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "VertexIntersectionSwapLocationsWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_cell_writer = new VertexIntersectionSwapLocationsWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_cell_writer; delete p_cell_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_cell_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_cell_writer_2; delete p_cell_writer_2; } } void TestVoronoiDataWriter() { EXIT_IF_PARALLEL; // Create a simple 3D MeshBasedCellPopulation std::vector<Node<3>*> nodes; nodes.push_back(new Node<3>(0, true, 0.0, 0.0, 0.0)); nodes.push_back(new Node<3>(1, true, 1.0, 1.0, 0.0)); nodes.push_back(new Node<3>(2, true, 1.0, 0.0, 1.0)); nodes.push_back(new Node<3>(3, true, 0.0, 1.0, 1.0)); nodes.push_back(new Node<3>(4, false, 0.5, 0.5, 0.5)); MutableMesh<3,3> mesh(nodes); std::vector<CellPtr> cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 3> cells_generator; cells_generator.GenerateBasic(cells, mesh.GetNumNodes()); MeshBasedCellPopulation<3> cell_population(mesh, cells); cell_population.CreateVoronoiTessellation(); // Create an output directory for the writer std::string output_directory = "TestVoronoiDataWriter"; OutputFileHandler output_file_handler(output_directory, false); std::string results_dir = output_file_handler.GetOutputDirectoryFullPath(); // Create a VoronoiDataWriter and test that the correct output is generated VoronoiDataWriter<3,3> voronoi_writer; voronoi_writer.OpenOutputFile(output_file_handler); voronoi_writer.WriteTimeStamp(); voronoi_writer.Visit(&cell_population); voronoi_writer.WriteNewline(); voronoi_writer.CloseFile(); FileComparison(results_dir + "voronoi.dat", "cell_based/test/data/TestCellPopulationWriters/voronoi.dat").CompareFiles(); // Test that we can append to files voronoi_writer.OpenOutputFileForAppend(output_file_handler); voronoi_writer.WriteTimeStamp(); voronoi_writer.Visit(&cell_population); voronoi_writer.WriteNewline(); voronoi_writer.CloseFile(); FileComparison(results_dir + "voronoi.dat", "cell_based/test/data/TestCellPopulationWriters/voronoi_twice.dat").CompareFiles(); VoronoiDataWriter<2,2> voronoi_writer_2d; // Test the correct exception is thrown if using a NodeBasedCellPopulation std::vector<Node<2>* > node_based_nodes; node_based_nodes.push_back(new Node<2>(0, false, 0.0, 0.0)); node_based_nodes.push_back(new Node<2>(1, false, 1.0, 1.0)); NodesOnlyMesh<2> nodes_only_mesh; nodes_only_mesh.ConstructNodesWithoutMesh(node_based_nodes, 1.5); std::vector<CellPtr> node_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> node_based_generator; node_based_generator.GenerateBasic(node_based_cells, nodes_only_mesh.GetNumNodes()); NodeBasedCellPopulation<2> node_based_cell_population(nodes_only_mesh, node_based_cells); TS_ASSERT_THROWS_THIS(voronoi_writer_2d.Visit(&node_based_cell_population), "VoronoiDataWriter cannot be used with a NodeBasedCellPopulation"); // Tidy up for (unsigned i=0; i<node_based_nodes.size(); i++) { delete node_based_nodes[i]; } // Test the correct exception is thrown if using a CaBasedCellPopulation PottsMeshGenerator<2> ca_based_generator(4, 0, 0, 4, 0, 0); PottsMesh<2>* p_ca_based_mesh = ca_based_generator.GetMesh(); std::vector<CellPtr> ca_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> ca_based_cells_generator; ca_based_cells_generator.GenerateBasic(ca_based_cells, 4); std::vector<unsigned> location_indices; location_indices.push_back(7); location_indices.push_back(11); location_indices.push_back(12); location_indices.push_back(13); CaBasedCellPopulation<2> ca_based_cell_population(*p_ca_based_mesh, ca_based_cells, location_indices); TS_ASSERT_THROWS_THIS(voronoi_writer_2d.Visit(&ca_based_cell_population), "VoronoiDataWriter cannot be used with a CaBasedCellPopulation"); // Test the correct exception is thrown if using a PottsBasedCellPopulation PottsMeshGenerator<2> potts_based_generator(4, 1, 2, 4, 1, 2); PottsMesh<2>* p_potts_based_mesh = potts_based_generator.GetMesh(); std::vector<CellPtr> potts_based_cells; CellsGenerator<FixedG1GenerationalCellCycleModel, 2> potts_based_cells_generator; potts_based_cells_generator.GenerateBasic(potts_based_cells, p_potts_based_mesh->GetNumElements()); PottsBasedCellPopulation<2> potts_based_cell_population(*p_potts_based_mesh, potts_based_cells); TS_ASSERT_THROWS_THIS(voronoi_writer_2d.Visit(&potts_based_cell_population), "VoronoiDataWriter cannot be used with a PottsBasedCellPopulation"); // Test the correct exception is thrown if using a PottsBasedCellPopulation HoneycombVertexMeshGenerator vertex_based_generator(4, 6); MutableVertexMesh<2,2>* p_vertex_mesh = vertex_based_generator.GetMesh(); std::vector<CellPtr> vertex_based_cells; boost::shared_ptr<AbstractCellProperty> p_diff_type(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>()); CellsGenerator<FixedG1GenerationalCellCycleModel, 2> vertex_based_cells_generator; vertex_based_cells_generator.GenerateBasic(vertex_based_cells, p_vertex_mesh->GetNumElements(), std::vector<unsigned>(), p_diff_type); VertexBasedCellPopulation<2> vertex_cell_population(*p_vertex_mesh, vertex_based_cells); TS_ASSERT_THROWS_THIS(voronoi_writer_2d.Visit(&vertex_cell_population), "VoronoiDataWriter cannot be used with a VertexBasedCellPopulation"); } void TestVoronoiDataWriterArchiving() { // The purpose of this test is to check that archiving can be done for this class OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "VoronoiDataWriter.arch"; { AbstractCellBasedWriter<2,2>* const p_population_writer = new VoronoiDataWriter<2,2>(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_population_writer; delete p_population_writer; } PetscTools::Barrier(); //Processes read after last process has (over-)written archive { AbstractCellBasedWriter<2,2>* p_population_writer_2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_population_writer_2; delete p_population_writer_2; } } }; #endif /*TESTCELLPOPULATIONWRITERS_HPP_*/
#ifndef GAMEMANAGER_H #define GAMEMANAGER_H #include "Game.h" #include <QList> #include <QPair> typedef QMap <int, Game> PlayingGames; typedef QMap <QString, Game> OpenedGames; class GameManager { public: GameManager(); void addPlayingGame(int id, ClientIterator firstPlayer, ClientIterator secondPlayer, int time); void removeGame(int id); Game getGame(int id) const; Game getGameAt(int at) const; int playingGamesCount() const; int openedGamesCount() const; void addOpenedGame(const QString &login, ClientIterator owner, int pos, int time); Game getOpenedGame(const QString &login); QList <QString> getOpenedGamesLogins() const; QList <Game> getOpenedGames() const; private: PlayingGames m_playingGames; OpenedGames m_openedGames; }; #endif // GAMEMANAGER_H
#include<bits/stdc++.h> using namespace std; bool ispalindrome(string s) { int i = 0, j = s.size() -1; while(i<j){ if(s[i]!=s[j])return false; i++,j--; } return true; } int main(){ int n, m; cin >> n >> m; vector<string>s(n); unordered_map<string,int>m1; for(int i = 0; i < n; i++){ cin >> s[i]; if(m1.find(s[i]) == m1.end()){ m1[s[i]]=0; } m1[s[i]]++; } string front; string back; string middle; string ans; for(int i = 0; i < n; i++){ string curr = s[i]; string rev = s[i]; reverse(rev.begin(),rev.end()); if(m1[curr] > 0 && (m1.find(rev)!=m1.end()&&m1[rev]>0) &&curr!=rev ){ m1[curr]--; m1[rev]--; front = curr+front; back = back + rev; } if(m1[curr] > 1 &&curr==rev ){ m1[curr]--; m1[rev]--; front = curr+front; back = back + rev; } } for(int i = 0; i < n; i++){ if(m1[s[i]] > 0 && ispalindrome(s[i])){ middle = s[i]; break; } } ans = front + middle + back; cout << ans.size() << endl; cout << ans << endl; return 0; }
class Solution { private: int recu(TreeNode *root, int value) { if (root == nullptr) return 0; int new_val = value * 10 + root->val; if (root->left == nullptr && root->right == nullptr) return new_val; return recu(root->left, new_val) + recu(root->right, new_val); } public: int sumNumbers(TreeNode* root) { return recu(root, 0); } };
#ifndef _RIFLEMAN_H #define _RIFLEMAN_H #include "../../FrameWork/Animation.h" #include "../../FrameWork/IComponent.h" #include "../../FrameWork/Scene/PlayScene.h" #include "../Enemies/BaseEnemy.h" #include "../../FrameWork/GameTime.h" #include "../../FrameWork/StopWatch.h" #include "../Object/Explosion.h" #include "../../FrameWork/Collision/CollisionBody.h" using namespace std; #define RIFLEMAN_HITPOINT 1 #define RIFLEMAN_SCORE 500 #define RIFLEMAN_SHOOTING_DELAY 250.0f #define RIFLEMAN_BULLET_BURST_DELAY 3050.0f #define RIFLEMAN_ANIMATION_SPEED 0.4755f class Rifleman : public BaseEnemy { public: /* @status: NORMAL cho lính đứng bắn, HIDDEN cho lính núp @pos: vị trí @x, y: tọa độ của pos */ Rifleman(eStatus status, GVector2 pos); Rifleman(eStatus status, float x, float y); ~Rifleman(); void init(); void update(float); void draw(LPD3DXSPRITE, Viewport*); void release(); float getShootingAngle(); void setShootingAngle(double); void die(); void shoot(); void onCollisionBegin(CollisionEventArg*); void onCollisionEnd(CollisionEventArg*); float checkCollision(BaseObject*, float); IComponent* getComponent(string); void checkifOutofScreen(); private: map<string, IComponent*> _listComponent; map<int, Animation*> _animations; BaseObject *_explosion; float _shootingAngle; StopWatch *_stopwatch; StopWatch *_loopwatch; StopWatch *_shootingWatch; void calculateShootingAngle(); void calculatingShootingDirection(); void changeShootingStance(); }; #endif
/************************************************************************* > File Name : SecCertificateRequestErrorVerfication.cpp > Author : YangShuai > Created Time: 2016年08月17日 星期三 16时17分12秒 > Description : ************************************************************************/ #include<cstring> #include<time.h> #include"Primitive.h" #include"PrimitiveTools.h" Result Sec_CertificateRequsetError_Verification(CertificateRequestError& cert_request_error){ Result res = SUCCESS; vector<Certificate> chain; vector<Cme_Permissions> permissions; vector<GeographicRegion> scopes; vector<Time32> last_crl_times; vector<Time32> next_crl_times; vector<bool> verified; //步骤 c), 欧标中没有使用hash224签名算法,这里就跳过检查这一项 Identifier_Type identifier_type; Data identifier; vector<Certificate> certs; switch(cert_request_error.signer.type){ case CERTIFICATE_DIGEST_WITH_SHA256: identifier_type = ID_CERTID8; identifier.init(8); memcpy(identifier.buf, cert_request_error.signer.u.digest.hashedid8, 8); break; case CERTIFICATE: identifier_type = ID_CERTIFICATE_CHAIN; certs.push_back(cert_request_error.signer.u.certificate); break; case CERTIFICATE_CHAIN: identifier_type = ID_CERTIFICATE_CHAIN; certs = cert_request_error.signer.u.certificates; break; default: ERROR_PRINT("不支持的签发者类型"); return FAILURE; } if(res = Cme_Construct_CertificateChain(identifier_type, identifier, certs, false, MAX_CERT_CHAIN_LEN, chain, permissions, scopes, last_crl_times, next_crl_times, verified)){ ERROR_PRINT("构造证书链失败"); return res; } time_t now = time(NULL); for(auto next_time : next_crl_times){ if(next_time < now){ ERROR_PRINT("overdue CRL"); return OVERDUE_CRL; } } if(res = Sec_Check_CertificateChainConsistency(chain, permissions, scopes)){ return res; } Data tbs_data(11); Digest digest; memcpy(tbs_data.buf, cert_request_error.request_hash, 10); *(tbs_data.buf + 10) = cert_request_error.reason; u8 digest_temp[32]; digest.caculate(tbs_data); digest.get_digest(digest_temp); if(res = Sec_Verify_ChainAndSignature(chain, verified, digest_temp, &cert_request_error.signature)){ ERROR_PRINT("验证证书链签名失败"); return res; } return res; }
#pragma once #include <landstalker-lib/patches/game_patch.hpp> #include <landstalker-lib/constants/offsets.hpp> #include <landstalker-lib/constants/item_codes.hpp> #include "../../logic_model/hint_source.hpp" #include "../../logic_model/randomizer_world.hpp" class PatchRecordBookSaveOnUse : public GamePatch { private: bool _consumable_record_book = false; static constexpr uint32_t MAP_ENTRANCE_POSITION_ADDRESS = 0xFF0018; public: explicit PatchRecordBookSaveOnUse(bool consumable_record_book) : _consumable_record_book(consumable_record_book) {} void inject_code(md::ROM& rom, World& world) override { // Inject a function on map load which stores where the charracter was on map entrance md::Code func; { func.jsr(0x1A510); // CheckSacredTreeFlags func.movew(addr_(0xFF1204), addr_(MAP_ENTRANCE_POSITION_ADDRESS)); func.movew(addr_(0xFF5400), addr_(MAP_ENTRANCE_POSITION_ADDRESS + 2)); } func.rts(); uint32_t func_addr = rom.inject_code(func); rom.set_code(0x19B5C, md::Code().jmp(func_addr)); // Inject the actual saving function which uses the stored position uint32_t func_use_record_book = inject_use_record_book_function(rom); world.item(ITEM_RECORD_BOOK)->pre_use_address(func_use_record_book); } private: uint32_t inject_use_record_book_function(md::ROM& rom) const { // -------- Function to save game using record book -------- // On record book use, set stored position and map as current to fool the save_game function, then call it // to save the game with this map and position. Then, restore Nigel's position and map as if nothing happened. md::Code func_use_record_book; func_use_record_book.movem_to_stack({ reg_D0, reg_D1 }, {}); if(_consumable_record_book) { func_use_record_book.moveb(reg_D0, addr_(0xFF1152)); func_use_record_book.jsr(0x8B98); // ConsumeItem } func_use_record_book.movew(addr_(0xFF1204), reg_D0); func_use_record_book.movew(addr_(0xFF5400), reg_D1); func_use_record_book.movew(addr_(MAP_ENTRANCE_POSITION_ADDRESS), addr_(0xFF1204)); func_use_record_book.movew(addr_(MAP_ENTRANCE_POSITION_ADDRESS+2), addr_(0xFF5400)); func_use_record_book.trap(0, { 0x00, 0x07 }); // Play save game music func_use_record_book.jsr(0x29046); // Sleep_0 for 0x17 frames func_use_record_book.add_word(0x0000); func_use_record_book.jsr(0x852); // Restore BGM func_use_record_book.jsr(0x1592); // Save game to SRAM func_use_record_book.movew(reg_D0, addr_(0xFF1204)); func_use_record_book.movew(reg_D1, addr_(0xFF5400)); func_use_record_book.movem_from_stack({ reg_D0, reg_D1 }, {}); func_use_record_book.jmp(offsets::PROC_ITEM_USE_RETURN_SUCCESS); return rom.inject_code(func_use_record_book); } };
/* * UAE - The Un*x Amiga Emulator * * cpuopti.c - Small optimizer for cpu*.s files * Based on work by Tauno Taipaleenmaki * * Copyright 1996 Bernd Schmidt */ #include "sysconfig.h" #include "sysdeps.h" #include <ctype.h> struct line { struct line *next, *prev; int delet; char *data; }; struct func { struct line *first_line, *last_line; int initial_offset; }; static void oops(void) { fprintf(stderr, "Corrupted assembly file!\n"); abort(); } /* Not strictly true to definition, as it only checks for match/no match, not for ordering */ static int mystrncmp(const char* a, const char* b, int len) { int biswhite=0; while (len) { if (isspace(*a)) { if (!biswhite) { biswhite=isspace(*b++); while (isspace(*b)) b++; } if (!biswhite) return -1; } else { biswhite=0; if (*a!=*b++) return -1; } a++; len--; } return 0; } static char * match(struct line *l, const char *m) { char *str = l->data; int len = strlen(m); while (isspace(*str)) str++; if (mystrncmp(str, m, len) != 0) return NULL; return str + len; } static int insn_references_reg (struct line *l, char *reg) { if (reg[0] != 'e') { fprintf(stderr, "Unknown register?!?\n"); abort(); } if (strstr (l->data, reg) != 0) return 1; if (strstr (l->data, reg+1) != 0) return 1; if (strcmp (reg, "eax") == 0 && (strstr (l->data, "%al") != 0 || strstr (l->data, "%ah") != 0)) return 1; if (strcmp (reg, "ebx") == 0 && (strstr (l->data, "%bl") != 0 || strstr (l->data, "%bh") != 0)) return 1; if (strcmp (reg, "ecx") == 0 && (strstr (l->data, "%cl") != 0 || strstr (l->data, "%ch") != 0)) return 1; if (strcmp (reg, "edx") == 0 && (strstr (l->data, "%dl") != 0 || strstr (l->data, "%dh") != 0)) return 1; return 0; } static void do_function(struct func *f) { int v; int pops_at_end = 0; struct line *l, *l1, *fl, *l2; char *s, *s2; int in_pop_area = 1; f->initial_offset = 0; l = f->last_line; fl = f->first_line; if (!match(l,"ret")) oops(); while (!match(fl, "op_")) fl = fl->next; fl = fl->next; /* Try reordering the insns at the end of the function so that the * pops are all at the end. */ l2 = l->prev; /* Tolerate one stack adjustment */ if (match (l2, "addl $") && strstr(l2->data, "esp") != 0) l2 = l2->prev; for (;;) { char *forbidden_reg; struct line *l3, *l4; while (match (l2, "popl %")) l2 = l2->prev; l3 = l2; for (;;) { forbidden_reg = match (l3, "popl %"); if (forbidden_reg) break; if (l3 == fl) goto reordered; /* Jumps and labels put an end to our attempts... */ if (strstr (l3->data, ".L") != 0) goto reordered; /* Likewise accesses to the stack pointer... */ if (strstr (l3->data, "esp") != 0) goto reordered; /* Function calls... */ if (strstr (l3->data, "call") != 0) goto reordered; l3 = l3->prev; } if (l3 == l2) abort(); for (l4 = l2; l4 != l3; l4 = l4->prev) { /* The register may not be referenced by any of the insns that we * move the popl past */ if (insn_references_reg (l4, forbidden_reg)) goto reordered; } l3->prev->next = l3->next; l3->next->prev = l3->prev; l2->next->prev = l3; l3->next = l2->next; l2->next = l3; l3->prev = l2; } reordered: l = l->prev; s = match (l, "addl $"); s2 = match (fl, "subl $"); l1 = l; if (s == 0) { char *t = match (l, "popl %"); if (t != 0 && (strcmp (t, "ecx") == 0 || strcmp (t, "edx") == 0)) { s = "4,%esp"; l = l->prev; t = match (l, "popl %"); if (t != 0 && (strcmp (t, "ecx") == 0 || strcmp (t, "edx") == 0)) { s = "8,%esp"; l = l->prev; } } } else { l = l->prev; } if (s && s2) { int v = 0; if (strcmp (s, s2) != 0) { fprintf (stderr, "Stack adjustment not matching.\n"); return; } while (isdigit(*s)) { v = v * 10 + (*s) - '0'; s++; } if (strcmp (s, ",%esp") != 0) { fprintf (stderr, "Not adjusting the stack pointer.\n"); return; } f->initial_offset = v; fl->delet = 3; fl = fl->next; l1->delet = 2; l1 = l1->prev; while (l1 != l) { l1->delet = 1; l1 = l1->prev; } } while (in_pop_area) { char *popm, *pushm; popm = match (l, "popl %"); pushm = match (fl, "pushl %"); if (popm && pushm && strcmp(pushm, popm) == 0) { pops_at_end++; fl->delet = l->delet = 1; } else in_pop_area = 0; l = l->prev; fl = fl->next; } if (f->initial_offset) f->initial_offset += 4 * pops_at_end; } static void output_function(struct func *f) { struct line *l = f->first_line; while (l) { switch (l->delet) { case 1: break; case 0: printf("%s\n", l->data); break; case 2: if (f->initial_offset) printf("\taddl $%d,%%esp\n", f->initial_offset); break; case 3: if (f->initial_offset) printf("\tsubl $%d,%%esp\n", f->initial_offset); break; } l = l->next; } } int main(int argc, char **argv) { FILE *infile = stdin; char tmp[4096]; #ifdef __mc68000__ if(system("perl machdep/cpuopti")==-1) { perror("perl machdep/cpuopti"); return 10; } else return 0; #endif /* For debugging... */ if (argc == 2) infile = fopen (argv[1], "r"); for(;;) { char *s; if ((fgets(tmp, 4095, infile)) == NULL) break; s = strchr (tmp, '\n'); if (s != NULL) *s = 0; if (mystrncmp(tmp, ".globl op_", 10) == 0) { struct line *first_line = NULL, *prev = NULL; struct line **nextp = &first_line; struct func f; int nr_rets = 0; int can_opt = 1; do { struct line *current; if (strcmp (tmp, "#APP") != 0 && strcmp (tmp, "#NO_APP") != 0) { current = *nextp = (struct line *)malloc(sizeof (struct line)); nextp = &current->next; current->prev = prev; prev = current; current->next = NULL; current->delet = 0; current->data = my_strdup (tmp); if (match (current, "movl %esp,%ebp") || match (current, "enter")) { fprintf (stderr, "GCC failed to eliminate fp: %s\n", first_line->data); can_opt = 0; } if (match (current, "ret")) nr_rets++; } if ((fgets(tmp, 4095, infile)) == NULL) oops(); s = strchr (tmp, '\n'); if (s != NULL) *s = 0; } while (strncmp (tmp,".Lfe", 4) != 0); f.first_line = first_line; f.last_line = prev; if (nr_rets == 1 && can_opt) do_function(&f); /*else fprintf(stderr, "Too many RET instructions: %s\n", first_line->data);*/ output_function(&f); } printf("%s\n", tmp); } return 0; }
// C++ for the Windows Runtime vv1.0.170303.6 // Copyright (c) 2017 Microsoft Corporation. All rights reserved. #pragma once WINRT_EXPORT namespace winrt { namespace ABI::Windows::System::UserProfile { struct IAdvertisingManagerForUser; struct IAdvertisingManagerStatics; struct IAdvertisingManagerStatics2; struct IDiagnosticsSettings; struct IDiagnosticsSettingsStatics; struct IFirstSignInSettings; struct IFirstSignInSettingsStatics; struct IGlobalizationPreferencesStatics; struct ILockScreenImageFeedStatics; struct ILockScreenStatics; struct IUserInformationStatics; struct IUserProfilePersonalizationSettings; struct IUserProfilePersonalizationSettingsStatics; struct AdvertisingManagerForUser; struct DiagnosticsSettings; struct FirstSignInSettings; struct UserProfilePersonalizationSettings; } namespace Windows::System::UserProfile { struct IAdvertisingManagerForUser; struct IAdvertisingManagerStatics; struct IAdvertisingManagerStatics2; struct IDiagnosticsSettings; struct IDiagnosticsSettingsStatics; struct IFirstSignInSettings; struct IFirstSignInSettingsStatics; struct IGlobalizationPreferencesStatics; struct ILockScreenImageFeedStatics; struct ILockScreenStatics; struct IUserInformationStatics; struct IUserProfilePersonalizationSettings; struct IUserProfilePersonalizationSettingsStatics; struct AdvertisingManager; struct AdvertisingManagerForUser; struct DiagnosticsSettings; struct FirstSignInSettings; struct GlobalizationPreferences; struct LockScreen; struct UserInformation; struct UserProfilePersonalizationSettings; } namespace Windows::System::UserProfile { template <typename T> struct impl_IAdvertisingManagerForUser; template <typename T> struct impl_IAdvertisingManagerStatics; template <typename T> struct impl_IAdvertisingManagerStatics2; template <typename T> struct impl_IDiagnosticsSettings; template <typename T> struct impl_IDiagnosticsSettingsStatics; template <typename T> struct impl_IFirstSignInSettings; template <typename T> struct impl_IFirstSignInSettingsStatics; template <typename T> struct impl_IGlobalizationPreferencesStatics; template <typename T> struct impl_ILockScreenImageFeedStatics; template <typename T> struct impl_ILockScreenStatics; template <typename T> struct impl_IUserInformationStatics; template <typename T> struct impl_IUserProfilePersonalizationSettings; template <typename T> struct impl_IUserProfilePersonalizationSettingsStatics; } namespace Windows::System::UserProfile { enum class AccountPictureKind { SmallImage = 0, LargeImage = 1, Video = 2, }; enum class SetAccountPictureResult { Success = 0, ChangeDisabled = 1, LargeOrDynamicError = 2, VideoFrameSizeError = 3, FileSizeError = 4, Failure = 5, }; enum class SetImageFeedResult { Success = 0, ChangeDisabled = 1, UserCanceled = 2, }; } }
/* * Copyright (C) 2007-2015 Frank Mertens. * * Use of this source is governed by a BSD-style license that can be * found in the LICENSE file. * */ #include <flux/syntax/SyntaxDebugFactory> #include <flux/syntax/syntax> namespace flux { namespace syntax { int RuleNode::matchNext(ByteArray *text, int i, Token *parentToken, SyntaxState *state) const { Ref<Token> token = state->produceToken(scope_->id(), id_, scope_->name(), name_); if (parentToken) parentToken->appendChild(token); int i0 = i; i = (entry()) ? entry()->matchNext(text, i, token, state) : i; if (token) { if (i != -1) token->setRange(i0, i); else token->unlink(); } return i; } int InvokeNode::matchNext(ByteArray *text, int i, Token *parentToken, SyntaxState *state) const { int i0 = i; Token *lastChildSaved = parentToken->lastChild(); if (coverage()) { i = coverage()->matchNext(text, i, parentToken, state); rollBack(parentToken, lastChildSaved); if (i == -1) return i; } Ref<SyntaxState> childState = LinkNode::rule()->scope()->createState(state->tokenFactory_); i = RefNode::matchNext(text->select(i0, coverage() ? i : text->count()), 0, parentToken, childState); if (childState->hint_) { state->hint_ = childState->hint_; state->hintOffset_ = childState->hintOffset_ + i0; } if (i == -1) return i; if (i0 != 0) { i += i0; for ( Token *token = lastChildSaved ? lastChildSaved->nextSibling() : parentToken->firstChild(); token; token = token->nextSibling() ) shiftTree(token, i0); } return i; } void InvokeNode::shiftTree(Token *root, int delta) { root->setRange(root->i0() + delta, root->i1() + delta); for (Token *token = root->firstChild(); token; token = token->nextSibling()) shiftTree(token, delta); } NODE DefinitionNode::KEYWORD(const char *keywords) { Ref<KeywordMap> map = KeywordMap::create(); const char *pos = keywords; while (*pos) { if ((*pos == ' ') || (*pos == '\t')) { ++pos; continue; } int len = 0; while (true) { char ch = *(pos + len); if ((ch == ' ') || (ch == '\t') || (ch == '\0')) break; ++len; } int keyword = keywordCount_; keywordCount_ += keywordByName_->insert(pos, len, keyword, &keyword); map->insert(pos, len, keyword); pos += len; } return debug(new KeywordNode(map, caseSensitive_), "Keyword"); } void DefinitionNode::LINK() { if (LinkNode::rule_) return; while (unresolvedLinkHead_) { unresolvedLinkHead_->rule_ = ruleByName(unresolvedLinkHead_->ruleName_); unresolvedLinkHead_ = unresolvedLinkHead_->unresolvedNext_; } while (unresolvedKeywordHead_) { unresolvedKeywordHead_->keyword_ = keywordByName(unresolvedKeywordHead_->keywordName_); unresolvedKeywordHead_ = unresolvedKeywordHead_->unresolvedKeywordNext_; } if (!LinkNode::ruleName_) FLUX_DEBUG_ERROR("Missing entry rule declaration"); LinkNode::rule_ = ruleByName(LinkNode::ruleName_); } Ref<SyntaxState> DefinitionNode::find(ByteArray *text, int i, TokenFactory *tokenFactory) const { Ref<SyntaxState> state = createState(tokenFactory); while (text->has(i)) { int h = matchNext(text, i, 0, state); if (h == -1) state->rootToken_ = 0; else break; ++i; } return state; } Ref<SyntaxState> DefinitionNode::match(ByteArray *text, int i, TokenFactory *tokenFactory) const { Ref<SyntaxState> state = createState(tokenFactory); int h = i < 0 ? 0 : i; h = matchNext(text, h, 0, state); if ( (h == -1) || (i < 0 && h < text->count()) ) state->rootToken_ = 0; return state; } const DefinitionNode *DefinitionNode::resolveScope(const char *&name) const { const DefinitionNode *scope = this; int k = 0; const char *p0 = name; const char *p = p0; while (true) { char ch = *(p++); if (!ch) break; k = (ch == ':') ? k + 1 : 0; if (k == 2) { Ref<const DefinitionNode> childScope; if (!scope->scopeByName_->lookup(p0, p - p0 - k, &childScope)) FLUX_DEBUG_ERROR(Format("Undefined scope '%%'") << name); scope = childScope; p0 = p; k = 0; } } name = p0; return scope; } int DefinitionNode::syntaxError(ByteArray *text, int index, SyntaxState *state) const { FLUX_DEBUG_ERROR("Unhandled syntax error"); return -1; } int DefinitionNode::errorCallBack(Object *self, ByteArray *text, int index, Token *parentToken, SyntaxState *state) { DefinitionNode *definition = cast<DefinitionNode>(self); return definition->syntaxError(text, index, state); } }} // namespace flux::syntax
// This MFC Samples source code demonstrates using MFC Microsoft Office Fluent User Interface // (the "Fluent UI") and is provided only as referential material to supplement the // Microsoft Foundation Classes Reference and related electronic documentation // included with the MFC C++ library software. // License terms to copy, use or distribute the Fluent UI are available separately. // To learn more about our Fluent UI licensing program, please visit // http://msdn.microsoft.com/officeui. // // Copyright (C) Microsoft Corporation // All rights reserved. // asmodeling.h : main header file for the asmodeling application // #pragma once #ifndef __AFXWIN_H__ #error "include 'stdafx.h' before including this file for PCH" #endif #include "resource.h" // main symbols // CasmodelingApp: // See asmodeling.cpp for the implementation of this class // struct Levels{ CString Level5; CString Level6; CString Level7; CString Level8; }; struct PMedia { CString extinction; CString scattering; CString alaph; }; struct Render { CString CurrentView; CString width; CString height; struct Levels RenderInterval; CString RotAngle; }; struct Light{ CString LightType; CString LightIntensityR; CString LightX; CString LightY; CString LightZ; }; struct Volume{ CString BoxSize; CString TransX; CString TransY; CString TransZ; CString VolumeInitialLevel; CString VolumeMaxLevel; struct Levels VolInterval; }; struct LBFGSB{ CString disturb; CString EpsG; CString EpsF; CString EpsX; CString MaxIts; CString m; CString ConstrainType; CString LowerBound; CString UpperBound; }; struct xmlStruct { struct PMedia PMedia; struct Render Render; struct Light Light; struct Volume Volume; struct LBFGSB LBFGSB; }; class CasmodelingApp : public CWinAppEx { public: CasmodelingApp(); // Overrides public: virtual BOOL InitInstance(); // Implementation UINT m_nAppLook; BOOL m_bHiColorIcons; CString rootPath; struct xmlStruct currentXML; virtual void PreLoadState(); virtual void LoadCustomState(); virtual void SaveCustomState(); afx_msg void OnAppAbout(); afx_msg void OnSetRoot(); DECLARE_MESSAGE_MAP() }; extern CasmodelingApp theApp;
#include "ArduinoCommHandler.h" #include <Wire.h> float x1 = 0.0; byte* x1Pointer =(byte*) &x1; //ukazatel na float pretypovany na ukazatel na byte (prvni byte floatu) float x2 = 0.0; byte* x2Pointer =(byte*) &x2; //ukazatel na float pretypovany na ukazatel na byte (prvni byte floatu) float x3 = 0.0; byte* x3Pointer =(byte*) &x3; //ukazatel na float pretypovany na ukazatel na byte (prvni byte floatu) byte x4 = 0; void transmitCommand(uint8_t command) { Wire.beginTransmission(4); // transmit to device #4 Wire.write(command); Wire.endTransmission(); // stop transmitting } void transmitFullThrottleEngines() { Serial.println(F("Transmitting command full throttle.")); transmitCommand(0); } void transmitStopEngines() { Serial.println(F("Transmitting command stop.")); transmitCommand(1); } void transmitDirection(int8_t x, int8_t y) { Serial.print(F("Transmitting direction x: ")); Serial.print(x); Serial.print(F(" y: ")); Serial.println(y); Wire.beginTransmission(4); // transmit to device #4 Wire.write(3); Wire.write(x); Wire.write(y); Wire.endTransmission(); // stop transmitting }
// // Copyright (C) 2017 Ruslan Manaev (manavrion@yandex.com) // This file is part of the Modern Expert System // #include "pch.h" #include "program_layer.h" #include "nlohmann/json.hpp" #include "utility/logger.h" using namespace concurrency; using namespace mes_core; using namespace modern_expert_system; using namespace nlohmann; using namespace std; using namespace Windows::Foundation; using namespace Windows::Storage; const string kSettingsFileName = "settings.json"; const string kProjectFilePrefix = "project"; const string kProjectFileSuffix = ".mesproj"; const string kDefaultProjectName = "Новый проект "; const string kDefaultProjectAbstract = "Короткое описание проекта"; const string kDefaultProjectDescription = "Расширенное описание проекта"; // static mutex ProgramLayer::ThreadSync; // static FileStorage ProgramLayer::SettingsStorage(kSettingsFileName); // static Settings ProgramLayer::SettingsObject; // static unique_ptr<ProjectSaver> ProgramLayer::Saver; // Program life // static IAsyncOperation<ProjectStore^>^ ProgramLayer::StartProgramAsync() { return create_async([]() -> ProjectStore^ { unique_lock<mutex> autoLock(ThreadSync); LogInfo("Start mes"); LoadSettings(); Saver.reset(new ProjectSaver()); return OpenCurrentProject(); }); } // static IAsyncAction^ ProgramLayer::ShutdownProgramAsync() { return create_async([]() { unique_lock<mutex> autoLock(ThreadSync); LogInfo("Shutdown"); SaveSettings(); Saver->Wait(); Saver.reset(); LogInfo("Done!\n"); LoggerShutdown(); }); } // static IAsyncOperation<ProjectStore^>^ ProgramLayer::NewProjectAsync() { return create_async([]() -> ProjectStore^ { unique_lock<mutex> autoLock(ThreadSync); LogInfo("Create new project"); Saver->Wait(); return OpenProject(CreateProject()); }); } // static IAsyncOperation<ProjectStore^>^ ProgramLayer::ImportProjectAsync(string json) { return create_async([=]() -> ProjectStore^ { unique_lock<mutex> autoLock(ThreadSync); LogInfo("Import project"); Saver->Wait(); auto project = CreateProject(); // FIX project = json::parse(json); return OpenProject(project); }); } Windows::Foundation::IAsyncAction^ ProgramLayer::Save(ProjectStore^ project) { auto projectCopy = (*project).get(); return create_async([=]() { unique_lock<mutex> autoLock(ThreadSync); LogInfo("Save project"); //Saver->Save(move(projectCopy)); }); } // Internal // static ProjectStore^ ProgramLayer::OpenCurrentProject() { string projectFileName; Project project; LogInfo("Detect current project"); if (SettingsObject.IsCurrentProjectExist()) { projectFileName = SettingsObject.GetCurrentProjectFileName(); //LogInfo(string("Current project is ") + project.GetFile()); } if (projectFileName.empty() || !FileStorage(projectFileName).IsFileExist()) { project = ProgramLayer::CreateProject(); LogInfo(string("Create and save project ") + projectFileName); FileStorage projectStorage(projectFileName); projectStorage.SaveObject(&project); LogInfo(string("Set current project ") + projectFileName); //TODO SettingsObject.SetCurrentProject(projectFileName); SaveSettings(); } else { LogInfo(string("Load project ") + projectFileName); FileStorage projectStorage(projectFileName); //projectStorage.LoadObject(&project); //project.SetFile(projectFileName); } return ref new ProjectStore(move(project)); } // static ProjectStore^ ProgramLayer::OpenProject(Project project) { //LogInfo(string("Open project ") + project.GetFile()); //FileStorage projectStorage(project.GetFile()); //projectStorage.SaveObject(&project); //SettingsObject.SetCurrentProject(project); SaveSettings(); return ref new ProjectStore(move(project)); } // static Project ProgramLayer::CreateProject() { Project project; /*string projectFile = kProjectFilePrefix + kProjectFileSuffix; string projectName = kDefaultProjectName; int index = 0; while (FileStorage::IsFileExist(projectFile)) { index++; projectFile = kProjectFilePrefix + to_wstring(index) + kProjectFileSuffix; projectName = kDefaultProjectName + to_wstring(index); if (index > 1e9) { LogFatal("Error: Unbreakable cycle"); } } project.SetFile(move(projectFile)); project.SetName(move(projectName)); project.SetAbstract(kDefaultProjectAbstract); project.SetDescription(kDefaultProjectDescription); LogInfo(string("Create project ") + project.GetFile());*/ return move(project); } // static void ProgramLayer::LoadSettings() { LogInfo("Load settings"); //SettingsStorage.LoadObject(&SettingsObject); } // static void ProgramLayer::SaveSettings() { LogInfo("Save settings"); SettingsStorage.SaveObject(&SettingsObject); }
#ifndef __PRODUCER_PARAMS_H__ #define __PRODUCER_PARAMS_H__ #include <stdint.h> #include <string> using namespace std; class CProducerParam { public: CProducerParam(); ~CProducerParam(); bool initial(string &strConfDir); bool get_hostip(); public: string m_strBusiSvrPath; string m_strBroker; string m_strTopic; string m_strMonitorHost; int32_t m_nMonitorPort; int32_t m_nPartition; int32_t m_nRecvBufSize; string m_strHostIp; }; #endif //__PRODUCER_PARAMS_H__
#include<iostream> #include<map> using namespace std; // // map查找和统计 // find(key) // count(key) void printMap(map<int,int> &m) { for(map<int,int>::iterator it = m.begin();it!=m.end();it++) { cout<<"key:"<<(*it).first<<" value:"<<it->second<<endl; } cout<<endl; } void test01() { //创建map容器 //默认构造 map<int,int> m; m.insert(pair<int,int>(1,10)); m.insert(pair<int,int>(4,40)); m.insert(pair<int,int>(2,20)); m.insert(pair<int,int>(3,30)); printMap(m); // find(key)查找 //返回值是表示位置的迭代器 map<int,int>::iterator pos = m.find(4); if(pos!=m.end()) { cout<<"查找到了元素key="<<(*pos).first<<" value="<<(*pos).second<<endl; } else { cout<<"未找到元素"<<endl; } // count()统计 //返回值是一个整数 //因为map容器中不允许有重复key,所以返回值是0或1 //multimap容器允许有重复key,则可以返回0和正整数 int num; num = m.count(3); cout<<"num = "<<num<<endl; } int main() { test01(); return 0; }
#include <iostream> using namespace std; void unique(int a[],int n){ int xorsum=0; for(int i=0;i<n;i++){ xorsum=xorsum^a[i]; } cout<<xorsum; } int main() { int a[]={1,2,3,3,1}; int n=sizeof(a)/sizeof(a[0]); unique(a,n); return 0; }
#ifndef __QUATERNION_H__ #define __QUATERNION_H__ #include "types.h" #include "vector3.h" namespace physics { class Quaternion { public: ffloat r; ffloat i; ffloat j; ffloat k; public: Quaternion() : r(0), i(0), j(0), k(0) { } Quaternion(const ffloat _r, const ffloat _i, const ffloat _j, const ffloat _k) : r(_r), i(_i), j(_j), k(_k) { } Quaternion(const Quaternion &other) { r = other.r; i = other.i; j = other.j; k = other.k; } public: const static Quaternion zero; Quaternion &operator=(const Quaternion &other) { r = other.r; i = other.i; j = other.j; k = other.k; return *this; } bool operator==(const Quaternion &other) { return ((r == other.r) && (i == other.i) && (j == other.j) && (k == other.k)); } bool operator!=(const Quaternion &other) { return ((r != other.r) && (i != other.i) && (j != other.j) && (k != other.k)); } void set(const ffloat _r, const ffloat _i, const ffloat _j, const ffloat _k) { r = _r; i = _i; j = _j; k = _k; } static Quaternion product(const Quaternion &A, const Quaternion &B) { ffloat r = A.r * B.r - A.i * B.i - A.j * B.j - A.k * B.k; ffloat i = A.r * B.i + A.i * B.r + A.j * B.k - A.k * B.j; ffloat j = A.r * B.j + A.j * B.r + A.k * B.i - A.i * B.k; ffloat k = A.r * B.k + A.k * B.r + A.i * B.j - A.j * B.i; return Quaternion(r, i, j, k); } void operator*=(const Quaternion &other) { *this = product(*this, other); } Quaternion operator*(const Quaternion &other) { return product(*this, other); } void normalise() { ffloat mag = r * r + i * i + j * j + k * k; if (mag == ffzero) { r = ffone; return; } ffloat den = ffsqrt(mag); if (den == ffzero) { r = ffone; return; } ffloat f = ffone / den; r *= f; i *= f; j *= f; k *= f; } // 将给定的矢量添加到此四元数中。按给定的数量缩放。 这用于通过旋转和时间更新方向四元数。 void addScaledVector(const Vector3 &v, ffloat scale) { Quaternion q(ffzero, v.x * scale, v.y * scale, v.z * scale); q *= *this; r += q.r * ffhalf; i += q.i * ffhalf; j += q.j * ffhalf; k += q.k * ffhalf; } void rotateByVector(const Vector3 &v) { Quaternion q(ffzero, v.x, v.y, v.z); (*this) *= q; } Vector3 toEulerAngles() { ffloat sinr_cosp = fftwo * (r * i + j * k); ffloat cosr_cosp = ffone - fftwo * (i * i + j * j); ffloat x = ffatan2(sinr_cosp, cosr_cosp); ffloat y; ffloat sinp = fftwo * (r * j - k * i); // use 90 degrees if out of range if (ffabs(sinp) >= ffone) { if (sinp > 0) y = ffhalf_pi; else y = -ffhalf_pi; } else { y = ffasin(sinp); } ffloat siny_cosp = fftwo * (r * k + i * j); ffloat cosy_cosp = ffone - fftwo * (j * j + k * k); ffloat z = ffatan2(siny_cosp, cosy_cosp); return Vector3(fftodeg(x), fftodeg(y), fftodeg(z)); } void toAxisAngle(Vector3 &axis, ffloat &angle) { axis.set(i, j, k); axis.normalise(); angle = fftwo * ffacos(r); angle = fftodeg(angle); } ffloat getAngle() { return fftodeg(fftwo * ffacos(r)); } static Quaternion fromVectorToVector(const Vector3 &from, const Vector3 &to) { Quaternion ret; Vector3 h = from + to; h.normalise(); ret.r = from.dot(h); ret.i = from.y * h.z - from.z * h.y; ret.j = from.z * h.x - from.x * h.z; ret.k = from.x * h.y - from.y * h.x; return ret; } static Quaternion fromEulerAngles(const Vector3 &v) { ffloat radX = fftorad(v.x * ffhalf); ffloat radY = fftorad(v.y * ffhalf); ffloat radZ = fftorad(v.z * ffhalf); ffloat cr = ffcos(radX); ffloat sr = ffsin(radX); ffloat cy = ffcos(radZ); ffloat sy = ffsin(radZ); ffloat cp = ffcos(radY); ffloat sp = ffsin(radY); ffloat r = cy * cp * cr + sy * sp * sr; ffloat i = cy * cp * sr - sy * sp * cr; ffloat j = sy * cp * sr + cy * sp * cr; ffloat k = sy * cp * cr - cy * sp * sr; return Quaternion(r, i, j, k); } static Quaternion fromAxisAngle(const Vector3 &axis, const ffloat angle) { ffloat rad = fftorad(angle); ffloat half = rad * ffhalf; ffloat s = ffsin(half); ffloat r = ffcos(half); ffloat i = axis.x * s; ffloat j = axis.y * s; ffloat k = axis.z * s; return Quaternion(r, i, j, k); } Vector3 operator*(const Vector3 &v) { Quaternion qv; qv.r = ffzero; qv.i = v.x; qv.j = v.y; qv.k = v.z; Quaternion qConj; qConj.r = r; qConj.i = -i; qConj.j = -j; qConj.k = -k; qv = (*this) * (qv); qv *= qConj; return Vector3(qv.i, qv.j, qv.k); } void inspect(const char *pszTag = "") const { printf("[%s] Quaternion: %.5f %.5f %.5f %.5f\r\n", pszTag, r.to_d(), i.to_d(), j.to_d(), k.to_d()); } }; } #endif
// This file is part of Cantera. See License.txt in the top-level directory or // at https://cantera.org/license.txt for license and copyright information. #ifndef CT_EIGEN_SPARSE_H #define CT_EIGEN_SPARSE_H #include "cantera/base/config.h" #if CT_USE_SYSTEM_EIGEN #include <Eigen/Sparse> #else #include "cantera/ext/Eigen/Sparse" #endif namespace Cantera { typedef std::vector<Eigen::Triplet<double>> SparseTriplets; } #endif
#include <iostream> #include <ios> #include <fstream> int main(int argc, char **argv) { std::ios::sync_with_stdio(false); if (argc != 2) { return 0; } std::ifstream f(argv[1]); while (true) { int x; f >> x; if (f.fail()) { break; } if (x < 0 || x > 100) { std::cout << "This program is for humans\n"; } else if (x >= 0 && x <= 2) { std::cout << "Still in Mama's arms\n"; } else if (x >= 3 && x <= 4) { std::cout << "Preschool Maniac\n"; } else if (x >= 5 && x <= 11) { std::cout << "Elementary school\n"; } else if (x >= 12 && x <= 14) { std::cout << "Middle school\n"; } else if (x >= 15 && x <= 18) { std::cout << "High school\n"; } else if (x >= 19 && x <= 22) { std::cout << "College\n"; } else if (x >= 23 && x <= 65) { std::cout << "Working for the man\n"; } else if (x >= 66 && x <= 100) { std::cout << "The Golden Years\n"; } } return 0; }
#include <iostream> using namespace std; void printArr(int *arr, int arrSize){ for(int i=0; i<arrSize; ++i, arr++){ cout << *arr << '\t'; } cout << endl; } void printArrVer2(int *arr, int arrSize){ for(int i=0; i<arrSize; ++i){ cout << *(arr+i) << '\t'; } cout << endl; } int sumOfArray(int *arr, int arrSize){ int sum = 0; for(int i=0; i<arrSize; i++){ sum+=*arr++; } return sum; } int sumOfArrayVer2(int *arr, int arrSize){ int sum = 0; for(int i=0; i<arrSize; i++){ sum+=*(arr+i); } return sum; } int main() { int a[] = {1,4,3,2}; printArr(a, 4); printArrVer2(a, 4); cout << sumOfArray(a, 4) << endl; cout << sumOfArrayVer2(a, 4) << endl; return 0; }
// C++ for the Windows Runtime vv1.0.170303.6 // Copyright (c) 2017 Microsoft Corporation. All rights reserved. #pragma once #include "../base.h" #include "Windows.ApplicationModel.UserDataTasks.0.h" #include "Windows.Foundation.0.h" #include "Windows.System.0.h" #include "Windows.Foundation.1.h" #include "Windows.Foundation.Collections.1.h" WINRT_EXPORT namespace winrt { namespace ABI::Windows::ApplicationModel::UserDataTasks { struct __declspec(uuid("7c6585d1-e0d4-4f99-aee2-bc2d5ddadf4c")) __declspec(novtable) IUserDataTask : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Id(hstring * value) = 0; virtual HRESULT __stdcall get_ListId(hstring * value) = 0; virtual HRESULT __stdcall get_RemoteId(hstring * value) = 0; virtual HRESULT __stdcall put_RemoteId(hstring value) = 0; virtual HRESULT __stdcall get_CompletedDate(Windows::Foundation::IReference<Windows::Foundation::DateTime> ** value) = 0; virtual HRESULT __stdcall put_CompletedDate(Windows::Foundation::IReference<Windows::Foundation::DateTime> * value) = 0; virtual HRESULT __stdcall get_Details(hstring * value) = 0; virtual HRESULT __stdcall put_Details(hstring value) = 0; virtual HRESULT __stdcall get_DetailsKind(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskDetailsKind * value) = 0; virtual HRESULT __stdcall put_DetailsKind(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskDetailsKind value) = 0; virtual HRESULT __stdcall get_DueDate(Windows::Foundation::IReference<Windows::Foundation::DateTime> ** value) = 0; virtual HRESULT __stdcall put_DueDate(Windows::Foundation::IReference<Windows::Foundation::DateTime> * value) = 0; virtual HRESULT __stdcall get_Kind(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskKind * value) = 0; virtual HRESULT __stdcall get_Priority(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskPriority * value) = 0; virtual HRESULT __stdcall put_Priority(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskPriority value) = 0; virtual HRESULT __stdcall get_RecurrenceProperties(Windows::ApplicationModel::UserDataTasks::IUserDataTaskRecurrenceProperties ** value) = 0; virtual HRESULT __stdcall put_RecurrenceProperties(Windows::ApplicationModel::UserDataTasks::IUserDataTaskRecurrenceProperties * value) = 0; virtual HRESULT __stdcall get_RegenerationProperties(Windows::ApplicationModel::UserDataTasks::IUserDataTaskRegenerationProperties ** value) = 0; virtual HRESULT __stdcall put_RegenerationProperties(Windows::ApplicationModel::UserDataTasks::IUserDataTaskRegenerationProperties * value) = 0; virtual HRESULT __stdcall get_Reminder(Windows::Foundation::IReference<Windows::Foundation::DateTime> ** value) = 0; virtual HRESULT __stdcall put_Reminder(Windows::Foundation::IReference<Windows::Foundation::DateTime> * value) = 0; virtual HRESULT __stdcall get_Sensitivity(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskSensitivity * value) = 0; virtual HRESULT __stdcall put_Sensitivity(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskSensitivity value) = 0; virtual HRESULT __stdcall get_Subject(hstring * value) = 0; virtual HRESULT __stdcall put_Subject(hstring value) = 0; virtual HRESULT __stdcall get_StartDate(Windows::Foundation::IReference<Windows::Foundation::DateTime> ** value) = 0; virtual HRESULT __stdcall put_StartDate(Windows::Foundation::IReference<Windows::Foundation::DateTime> * value) = 0; }; struct __declspec(uuid("382da5fe-20b5-431c-8f42-a5d292ec930c")) __declspec(novtable) IUserDataTaskBatch : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Tasks(Windows::Foundation::Collections::IVectorView<Windows::ApplicationModel::UserDataTasks::UserDataTask> ** value) = 0; }; struct __declspec(uuid("49412e39-7c1d-4df1-bed3-314b7cbf5e4e")) __declspec(novtable) IUserDataTaskList : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Id(hstring * value) = 0; virtual HRESULT __stdcall get_UserDataAccountId(hstring * value) = 0; virtual HRESULT __stdcall get_DisplayName(hstring * value) = 0; virtual HRESULT __stdcall put_DisplayName(hstring value) = 0; virtual HRESULT __stdcall get_SourceDisplayName(hstring * value) = 0; virtual HRESULT __stdcall get_OtherAppReadAccess(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskListOtherAppReadAccess * value) = 0; virtual HRESULT __stdcall put_OtherAppReadAccess(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskListOtherAppReadAccess value) = 0; virtual HRESULT __stdcall get_OtherAppWriteAccess(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskListOtherAppWriteAccess * value) = 0; virtual HRESULT __stdcall put_OtherAppWriteAccess(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskListOtherAppWriteAccess value) = 0; virtual HRESULT __stdcall get_LimitedWriteOperations(Windows::ApplicationModel::UserDataTasks::IUserDataTaskListLimitedWriteOperations ** value) = 0; virtual HRESULT __stdcall get_SyncManager(Windows::ApplicationModel::UserDataTasks::IUserDataTaskListSyncManager ** value) = 0; virtual HRESULT __stdcall abi_RegisterSyncManagerAsync(Windows::Foundation::IAsyncAction ** result) = 0; virtual HRESULT __stdcall abi_GetTaskReader(Windows::ApplicationModel::UserDataTasks::IUserDataTaskReader ** result) = 0; virtual HRESULT __stdcall abi_GetTaskReaderWithOptions(Windows::ApplicationModel::UserDataTasks::IUserDataTaskQueryOptions * options, Windows::ApplicationModel::UserDataTasks::IUserDataTaskReader ** value) = 0; virtual HRESULT __stdcall abi_GetTaskAsync(hstring userDataTask, Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTask> ** operation) = 0; virtual HRESULT __stdcall abi_SaveTaskAsync(Windows::ApplicationModel::UserDataTasks::IUserDataTask * userDataTask, Windows::Foundation::IAsyncAction ** action) = 0; virtual HRESULT __stdcall abi_DeleteTaskAsync(hstring userDataTaskId, Windows::Foundation::IAsyncAction ** action) = 0; virtual HRESULT __stdcall abi_DeleteAsync(Windows::Foundation::IAsyncAction ** asyncAction) = 0; virtual HRESULT __stdcall abi_SaveAsync(Windows::Foundation::IAsyncAction ** asyncAction) = 0; }; struct __declspec(uuid("7aa267f2-6078-4183-919e-4f29f19cfae9")) __declspec(novtable) IUserDataTaskListLimitedWriteOperations : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_TryCompleteTaskAsync(hstring userDataTaskId, Windows::Foundation::IAsyncOperation<hstring> ** operation) = 0; virtual HRESULT __stdcall abi_TryCreateOrUpdateTaskAsync(Windows::ApplicationModel::UserDataTasks::IUserDataTask * userDataTask, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; virtual HRESULT __stdcall abi_TryDeleteTaskAsync(hstring userDataTaskId, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; virtual HRESULT __stdcall abi_TrySkipOccurrenceAsync(hstring userDataTaskId, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; }; struct __declspec(uuid("8e591a95-1dcf-469f-93ec-ba48bb553c6b")) __declspec(novtable) IUserDataTaskListSyncManager : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_LastAttemptedSyncTime(Windows::Foundation::DateTime * value) = 0; virtual HRESULT __stdcall put_LastAttemptedSyncTime(Windows::Foundation::DateTime value) = 0; virtual HRESULT __stdcall get_LastSuccessfulSyncTime(Windows::Foundation::DateTime * value) = 0; virtual HRESULT __stdcall put_LastSuccessfulSyncTime(Windows::Foundation::DateTime value) = 0; virtual HRESULT __stdcall get_Status(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncStatus * value) = 0; virtual HRESULT __stdcall put_Status(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncStatus value) = 0; virtual HRESULT __stdcall abi_SyncAsync(Windows::Foundation::IAsyncOperation<bool> ** result) = 0; virtual HRESULT __stdcall add_SyncStatusChanged(Windows::Foundation::TypedEventHandler<Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncManager, Windows::Foundation::IInspectable> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_SyncStatusChanged(event_token token) = 0; }; struct __declspec(uuid("8451c914-e60b-48a9-9211-7fb8a56cb84c")) __declspec(novtable) IUserDataTaskManager : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_RequestStoreAsync(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskStoreAccessType accessType, Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskStore> ** operation) = 0; virtual HRESULT __stdcall get_User(Windows::System::IUser ** value) = 0; }; struct __declspec(uuid("b35539f8-c502-47fc-a81e-100883719d55")) __declspec(novtable) IUserDataTaskManagerStatics : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_GetDefault(Windows::ApplicationModel::UserDataTasks::IUserDataTaskManager ** result) = 0; virtual HRESULT __stdcall abi_GetForUser(Windows::System::IUser * user, Windows::ApplicationModel::UserDataTasks::IUserDataTaskManager ** result) = 0; }; struct __declspec(uuid("959f27ed-909a-4d30-8c1b-331d8fe667e2")) __declspec(novtable) IUserDataTaskQueryOptions : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_SortProperty(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskQuerySortProperty * value) = 0; virtual HRESULT __stdcall put_SortProperty(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskQuerySortProperty value) = 0; virtual HRESULT __stdcall get_Kind(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskQueryKind * value) = 0; virtual HRESULT __stdcall put_Kind(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskQueryKind value) = 0; }; struct __declspec(uuid("03e688b1-4ccf-4500-883b-e76290cfed63")) __declspec(novtable) IUserDataTaskReader : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_ReadBatchAsync(Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskBatch> ** result) = 0; }; struct __declspec(uuid("73df80b0-27c6-40ce-b149-9cd41485a69e")) __declspec(novtable) IUserDataTaskRecurrenceProperties : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Unit(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceUnit * value) = 0; virtual HRESULT __stdcall put_Unit(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceUnit value) = 0; virtual HRESULT __stdcall get_Occurrences(Windows::Foundation::IReference<int32_t> ** value) = 0; virtual HRESULT __stdcall put_Occurrences(Windows::Foundation::IReference<int32_t> * value) = 0; virtual HRESULT __stdcall get_Until(Windows::Foundation::IReference<Windows::Foundation::DateTime> ** value) = 0; virtual HRESULT __stdcall put_Until(Windows::Foundation::IReference<Windows::Foundation::DateTime> * value) = 0; virtual HRESULT __stdcall get_Interval(int32_t * value) = 0; virtual HRESULT __stdcall put_Interval(int32_t value) = 0; virtual HRESULT __stdcall get_DaysOfWeek(Windows::Foundation::IReference<winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskDaysOfWeek> ** value) = 0; virtual HRESULT __stdcall put_DaysOfWeek(Windows::Foundation::IReference<winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskDaysOfWeek> * value) = 0; virtual HRESULT __stdcall get_WeekOfMonth(Windows::Foundation::IReference<winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskWeekOfMonth> ** value) = 0; virtual HRESULT __stdcall put_WeekOfMonth(Windows::Foundation::IReference<winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskWeekOfMonth> * value) = 0; virtual HRESULT __stdcall get_Month(Windows::Foundation::IReference<int32_t> ** value) = 0; virtual HRESULT __stdcall put_Month(Windows::Foundation::IReference<int32_t> * value) = 0; virtual HRESULT __stdcall get_Day(Windows::Foundation::IReference<int32_t> ** value) = 0; virtual HRESULT __stdcall put_Day(Windows::Foundation::IReference<int32_t> * value) = 0; }; struct __declspec(uuid("92ab0007-090e-4704-bb5c-84fc0b0d9c31")) __declspec(novtable) IUserDataTaskRegenerationProperties : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Unit(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationUnit * value) = 0; virtual HRESULT __stdcall put_Unit(winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationUnit value) = 0; virtual HRESULT __stdcall get_Occurrences(Windows::Foundation::IReference<int32_t> ** value) = 0; virtual HRESULT __stdcall put_Occurrences(Windows::Foundation::IReference<int32_t> * value) = 0; virtual HRESULT __stdcall get_Until(Windows::Foundation::IReference<Windows::Foundation::DateTime> ** value) = 0; virtual HRESULT __stdcall put_Until(Windows::Foundation::IReference<Windows::Foundation::DateTime> * value) = 0; virtual HRESULT __stdcall get_Interval(int32_t * value) = 0; virtual HRESULT __stdcall put_Interval(int32_t value) = 0; }; struct __declspec(uuid("f06a9cb0-f1db-45ba-8a62-086004c0213d")) __declspec(novtable) IUserDataTaskStore : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_CreateListAsync(hstring name, Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskList> ** operation) = 0; virtual HRESULT __stdcall abi_CreateListInAccountAsync(hstring name, hstring userDataAccountId, Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskList> ** result) = 0; virtual HRESULT __stdcall abi_FindListsAsync(Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::ApplicationModel::UserDataTasks::UserDataTaskList>> ** operation) = 0; virtual HRESULT __stdcall abi_GetListAsync(hstring taskListId, Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskList> ** operation) = 0; }; } namespace ABI { template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTask> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTask; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskBatch> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskBatch; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskList> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskList; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskListLimitedWriteOperations> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskListLimitedWriteOperations; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncManager> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskListSyncManager; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskManager> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskManager; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskQueryOptions> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskQueryOptions; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskReader> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskReader; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceProperties> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskRecurrenceProperties; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationProperties> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskRegenerationProperties; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskStore> { using default_interface = Windows::ApplicationModel::UserDataTasks::IUserDataTaskStore; }; } namespace Windows::ApplicationModel::UserDataTasks { template <typename D> struct WINRT_EBO impl_IUserDataTask { hstring Id() const; hstring ListId() const; hstring RemoteId() const; void RemoteId(hstring_view value) const; Windows::Foundation::IReference<Windows::Foundation::DateTime> CompletedDate() const; void CompletedDate(const optional<Windows::Foundation::DateTime> & value) const; hstring Details() const; void Details(hstring_view value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskDetailsKind DetailsKind() const; void DetailsKind(Windows::ApplicationModel::UserDataTasks::UserDataTaskDetailsKind value) const; Windows::Foundation::IReference<Windows::Foundation::DateTime> DueDate() const; void DueDate(const optional<Windows::Foundation::DateTime> & value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskKind Kind() const; Windows::ApplicationModel::UserDataTasks::UserDataTaskPriority Priority() const; void Priority(Windows::ApplicationModel::UserDataTasks::UserDataTaskPriority value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceProperties RecurrenceProperties() const; void RecurrenceProperties(const Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceProperties & value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationProperties RegenerationProperties() const; void RegenerationProperties(const Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationProperties & value) const; Windows::Foundation::IReference<Windows::Foundation::DateTime> Reminder() const; void Reminder(const optional<Windows::Foundation::DateTime> & value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskSensitivity Sensitivity() const; void Sensitivity(Windows::ApplicationModel::UserDataTasks::UserDataTaskSensitivity value) const; hstring Subject() const; void Subject(hstring_view value) const; Windows::Foundation::IReference<Windows::Foundation::DateTime> StartDate() const; void StartDate(const optional<Windows::Foundation::DateTime> & value) const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskBatch { Windows::Foundation::Collections::IVectorView<Windows::ApplicationModel::UserDataTasks::UserDataTask> Tasks() const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskList { hstring Id() const; hstring UserDataAccountId() const; hstring DisplayName() const; void DisplayName(hstring_view value) const; hstring SourceDisplayName() const; Windows::ApplicationModel::UserDataTasks::UserDataTaskListOtherAppReadAccess OtherAppReadAccess() const; void OtherAppReadAccess(Windows::ApplicationModel::UserDataTasks::UserDataTaskListOtherAppReadAccess value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskListOtherAppWriteAccess OtherAppWriteAccess() const; void OtherAppWriteAccess(Windows::ApplicationModel::UserDataTasks::UserDataTaskListOtherAppWriteAccess value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskListLimitedWriteOperations LimitedWriteOperations() const; Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncManager SyncManager() const; Windows::Foundation::IAsyncAction RegisterSyncManagerAsync() const; Windows::ApplicationModel::UserDataTasks::UserDataTaskReader GetTaskReader() const; Windows::ApplicationModel::UserDataTasks::UserDataTaskReader GetTaskReader(const Windows::ApplicationModel::UserDataTasks::UserDataTaskQueryOptions & options) const; Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTask> GetTaskAsync(hstring_view userDataTask) const; Windows::Foundation::IAsyncAction SaveTaskAsync(const Windows::ApplicationModel::UserDataTasks::UserDataTask & userDataTask) const; Windows::Foundation::IAsyncAction DeleteTaskAsync(hstring_view userDataTaskId) const; Windows::Foundation::IAsyncAction DeleteAsync() const; Windows::Foundation::IAsyncAction SaveAsync() const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskListLimitedWriteOperations { Windows::Foundation::IAsyncOperation<hstring> TryCompleteTaskAsync(hstring_view userDataTaskId) const; Windows::Foundation::IAsyncOperation<bool> TryCreateOrUpdateTaskAsync(const Windows::ApplicationModel::UserDataTasks::UserDataTask & userDataTask) const; Windows::Foundation::IAsyncOperation<bool> TryDeleteTaskAsync(hstring_view userDataTaskId) const; Windows::Foundation::IAsyncOperation<bool> TrySkipOccurrenceAsync(hstring_view userDataTaskId) const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskListSyncManager { Windows::Foundation::DateTime LastAttemptedSyncTime() const; void LastAttemptedSyncTime(const Windows::Foundation::DateTime & value) const; Windows::Foundation::DateTime LastSuccessfulSyncTime() const; void LastSuccessfulSyncTime(const Windows::Foundation::DateTime & value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncStatus Status() const; void Status(Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncStatus value) const; Windows::Foundation::IAsyncOperation<bool> SyncAsync() const; event_token SyncStatusChanged(const Windows::Foundation::TypedEventHandler<Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncManager, Windows::Foundation::IInspectable> & handler) const; using SyncStatusChanged_revoker = event_revoker<IUserDataTaskListSyncManager>; SyncStatusChanged_revoker SyncStatusChanged(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncManager, Windows::Foundation::IInspectable> & handler) const; void SyncStatusChanged(event_token token) const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskManager { Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskStore> RequestStoreAsync(Windows::ApplicationModel::UserDataTasks::UserDataTaskStoreAccessType accessType) const; Windows::System::User User() const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskManagerStatics { Windows::ApplicationModel::UserDataTasks::UserDataTaskManager GetDefault() const; Windows::ApplicationModel::UserDataTasks::UserDataTaskManager GetForUser(const Windows::System::User & user) const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskQueryOptions { Windows::ApplicationModel::UserDataTasks::UserDataTaskQuerySortProperty SortProperty() const; void SortProperty(Windows::ApplicationModel::UserDataTasks::UserDataTaskQuerySortProperty value) const; Windows::ApplicationModel::UserDataTasks::UserDataTaskQueryKind Kind() const; void Kind(Windows::ApplicationModel::UserDataTasks::UserDataTaskQueryKind value) const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskReader { Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskBatch> ReadBatchAsync() const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskRecurrenceProperties { Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceUnit Unit() const; void Unit(Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceUnit value) const; Windows::Foundation::IReference<int32_t> Occurrences() const; void Occurrences(const optional<int32_t> & value) const; Windows::Foundation::IReference<Windows::Foundation::DateTime> Until() const; void Until(const optional<Windows::Foundation::DateTime> & value) const; int32_t Interval() const; void Interval(int32_t value) const; Windows::Foundation::IReference<winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskDaysOfWeek> DaysOfWeek() const; void DaysOfWeek(const optional<winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskDaysOfWeek> & value) const; Windows::Foundation::IReference<winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskWeekOfMonth> WeekOfMonth() const; void WeekOfMonth(const optional<winrt::Windows::ApplicationModel::UserDataTasks::UserDataTaskWeekOfMonth> & value) const; Windows::Foundation::IReference<int32_t> Month() const; void Month(const optional<int32_t> & value) const; Windows::Foundation::IReference<int32_t> Day() const; void Day(const optional<int32_t> & value) const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskRegenerationProperties { Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationUnit Unit() const; void Unit(Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationUnit value) const; Windows::Foundation::IReference<int32_t> Occurrences() const; void Occurrences(const optional<int32_t> & value) const; Windows::Foundation::IReference<Windows::Foundation::DateTime> Until() const; void Until(const optional<Windows::Foundation::DateTime> & value) const; int32_t Interval() const; void Interval(int32_t value) const; }; template <typename D> struct WINRT_EBO impl_IUserDataTaskStore { Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskList> CreateListAsync(hstring_view name) const; Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskList> CreateListAsync(hstring_view name, hstring_view userDataAccountId) const; Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::ApplicationModel::UserDataTasks::UserDataTaskList>> FindListsAsync() const; Windows::Foundation::IAsyncOperation<Windows::ApplicationModel::UserDataTasks::UserDataTaskList> GetListAsync(hstring_view taskListId) const; }; } namespace impl { template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTask> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTask; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTask<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskBatch> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskBatch; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskBatch<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskList> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskList; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskList<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskListLimitedWriteOperations> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskListLimitedWriteOperations; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskListLimitedWriteOperations<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskListSyncManager> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskListSyncManager; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskListSyncManager<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskManager> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskManager; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskManager<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskManagerStatics> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskManagerStatics; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskManagerStatics<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskQueryOptions> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskQueryOptions; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskQueryOptions<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskReader> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskReader; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskReader<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskRecurrenceProperties> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskRecurrenceProperties; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskRecurrenceProperties<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskRegenerationProperties> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskRegenerationProperties; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskRegenerationProperties<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::IUserDataTaskStore> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::IUserDataTaskStore; template <typename D> using consume = Windows::ApplicationModel::UserDataTasks::impl_IUserDataTaskStore<D>; }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTask> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTask; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTask"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskBatch> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskBatch; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskBatch"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskList> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskList; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskList"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskListLimitedWriteOperations> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskListLimitedWriteOperations; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskListLimitedWriteOperations"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncManager> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskListSyncManager; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskListSyncManager"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskManager> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskManager; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskManager"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskQueryOptions> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskQueryOptions; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskQueryOptions"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskReader> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskReader; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskReader"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceProperties> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskRecurrenceProperties; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskRecurrenceProperties"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationProperties> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskRegenerationProperties; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskRegenerationProperties"; } }; template <> struct traits<Windows::ApplicationModel::UserDataTasks::UserDataTaskStore> { using abi = ABI::Windows::ApplicationModel::UserDataTasks::UserDataTaskStore; static constexpr const wchar_t * name() noexcept { return L"Windows.ApplicationModel.UserDataTasks.UserDataTaskStore"; } }; } }
//--------------------------------------------------------------------------- #ifndef StrategyH #define StrategyH //--------------------------------------------------------------------------- using namespace std; #include <vector> #include "..\..\Common\sitHoldem.h" #include "..\..\..\util\clTree.h" #include "HandsGroupEX.h" #include "CalcSitEV.h" #include "..\..\..\util\Clasters.h" #define TREE_FOR_CALC 1 class clCalcParam0 { public: clCalcParam0() { _ptr = NULL; } clCalcParam0(byte *val) { _ptr = val; } void ClearEV(int cnB); void ClearEVAndSetWeight(int cnB); static int SizeParam(int cnB) { return 3 * sizeof(int) + 2 * cnB * sizeof(tpFloat0); } static int SizeParamForCalc(int cnB) { return 3 * sizeof(int) + 3 * cnB * sizeof(tpFloat0); } void GetWeight(int cnB, tpFloat0 *w); tpFloat0 *GetWeightForCalc(int cnB) { return ((tpFloat0 *)(_ptr + 12 + 2*cnB*sizeof(tpFloat0))); } void GetWeightStrat(int cnB, tpFloat0 *w); void AddResEV(int cnB, tpFloat0 res, tpFloat0 *w, tpFloat0 *ev, tpFloat0 k, tpFloat0 kOpp); void AddResEVForCalc(int cnB, tpFloat0 res, tpFloat0 *w, tpFloat0 *ev, tpFloat0 k, tpFloat0 kOpp); unsigned int &CnCalc() { return *((unsigned int *)_ptr); } tpFloat0 &WeightCalc() { return *((tpFloat0 *)(_ptr + 4)); } tpFloat0 &AverRes() { return *((tpFloat0 *)(_ptr + 8)); } tpFloat0 *BeginEV() { return ((tpFloat0 *)(_ptr + 12)); } tpFloat0 *BeginPart(int cn) { return ((tpFloat0 *)(_ptr + 12+cn*sizeof(tpFloat0))); } tpFloat0 AbsEV(int nb) { tpFloat0 w = WeightCalc(); return (w > DOUBLE_0) ? (BeginEV()[nb]+AverRes()) / w : 0; } void ChangeStratWeight(int cnB, tpFloat0 m); void SetParam(int cnB, tpFloat0 *w, int cn); byte *_ptr; }; class clAtrTreeStrat { public: clAtrTreeStrat() { Clear(); _sitRes = NULL; _verTree = 0; _statCn = 0; } void ClearEV(int cnB); void Clear() { _sitA.Clear(); } size_t CnClasters() { return (_sizeParam==0)? 0 : _param.size() / _sizeParam; } size_t SizeInFile(); void WriteFile(int handle); void ReadFile(int handle); void operator = (clAtrTreeStrat &atr); clCalcParam0 CalcParam(int nbCls) { return &_param[nbCls*_sizeParam]; } int GetNbForCls(int nb); clSitHoldem _sitA; byte _sizeParam,_verTree; vector <byte> _param; vector <short> _vectInd; tpSitRes *_sitRes; void *_strat; int *_ptrIndex; double _statCn; }; class clTreeStrat : public clTree < clAtrTreeStrat > { friend class clStrategy; public: int AddBranch(clSitHoldem &sit); clTreeStrat *Branch(int nb) { return (clTreeStrat *)clTree < clAtrTreeStrat >::Branch(nb); } clTreeStrat *AddBranch() { clTreeStrat *node = (clTreeStrat *)clTree < clAtrTreeStrat >::AddBranch(); node->AtrTree()->_verTree = AtrTree()->_verTree; return node; } int Indicator() { return AtrTree()->_sitA.Indicator(); } void ClearEV(); void ClearStatWeight(); inline int GetNbCls(tpCardsGame &cards, int ind); int GetNbCls(tpHand &hand,tpCard *board); clDoubleCP Result(tpCardsGame &cards) { return CalcSitEV(AtrTree()->_sitA, &cards, AtrTree()->_sitRes); } clDoubleCP CalcEV(int nbH, tpCardsGame &cards, tpFloat0 kH, tpFloat0 kOpp); vector <clDoubleCP> CalcEV(int nbH, int dim, tpCardsGame *cards, vector <tpFloat0> &kH, tpFloat0 kOpp); clDoubleCP CalcEVForCalc(int nbH, tpCardsGame &cards, tpFloat0 kH, tpFloat0 kOpp); tpDis GetDis() { return AtrTree()->_sitA.GetLastAct()->_dis; } tpDis GetStratDis(clSitHoldem &sit); clAnsiString NameForNode(); clSitHoldem &GetSit() { return AtrTree()->_sitA; } void CalcWeightStat(); clTreeStrat *FindBranch(tpDis dis); clTreeStrat *FindEqBranch(tpDis dis); clTreeStrat *FindBranch(enNameTrade trade); clTreeStrat *FindSitNode(clSitHoldem &sit); // точная последовательность решений clTreeStrat *FindBeforeEqualDis(clSitHoldem &sit); // возвращаем последний узел, где еще примерно соответствует sit void GetGH(clSitHoldem &sit, clHandsGroupEx *ghH); clTreeStrat *GetStratEndedNode(tpCardsGame &cards); clTreeStrat *GetStratBranch(tpCardsGame &cards, clHandsGroupEx *ghH); int SetNbNode(int nb); bool EndedNode() { return CnBranch() == 0; } tpFloat0 EVNabor(tpCardsGame &cards, int nb); void ChangeStratWeight(tpFloat0 m); void ChangeStatWeight(tpFloat0 m); void ChangeGHAll(int nb, tpCard *board, clHandsGroupEx &ghH); clDoubleCP CalcTreeVect(int nbH, vector <tpCardsGame> &vectCards, vector <tpFloat0> &vectkH, tpFloat0 kOpp); private: // clTreeStrat *FindSitNode(clSitHoldem &sit, int ind, int nbA); size_t CnClasters() { return AtrTree()->CnClasters(); } // clClasterS &Claster(int nb) { return AtrTree()->_vectCls[nb]; } clCalcParam0 FindClaster(clSitHoldem &sit); // clClasterS *FindClaster(int nbHand) { return &AtrTree()->_vectCls[nbHand]; } int CnPlayer() { return AtrTree()->_sitA.CnPlayer(); } enNameTrade PokerStreet() { return AtrTree()->_sitA.NameTrade(); } int BetPlayer() { int ind = Indicator(); return AtrTree()->_sitA.BetPl(ind); } int BetPlayerOrBB() { int bet = BetPlayer(); return (bet < AtrTree()->_sitA.BigBlind()) ? AtrTree()->_sitA.BigBlind() : bet; } void ReCalcWeight(clHandsGroupEx **arrH,bool stratB); // void CalcWeightStrat(clHandsGroupEx **arrH); double ChangeGH(int nb, clHandsGroupEx *gh, clHandsGroupEx *ghIn, bool stratB); // double ChangeStratGH(int nb, clHandsGroupEx *gh, clHandsGroupEx *ghIn); void GetGHSit(clSitHoldem &sit, int ind, int nbA, clHandsGroupEx *ghH); void SetNbNodeA(int &nb); size_t SetStartParam(int cnClsFlop, int cnClsTurn, int cnClsRiver, int *indFlop, int *indTurn, int *indRiver, bool mem); void SetIndexForNabor(int *indFlop, int *indTurn, int *indRiver); // int _nbNode; }; struct tpArrResBranch8 { tpArrResBranch8() { _cn = 0; } void MultMoney(double k) { for (int i = 0; i < _cn; i++) _dis[i]._money = _dis[i]._money*k + 0.5; } tpDis _dis[MAX_CN_BRANCH]; double _ev[MAX_CN_BRANCH], _weight[MAX_CN_BRANCH]; int _cn,_cnCalc; }; class clStrategy { friend class clStrategyPlay; friend class clHistCalc; public: clStrategy() { _indFlop = _indTurn = _indRiver = NULL; } ~clStrategy() { if (_indFlop != NULL) free(_indFlop); if (_indTurn != NULL) free(_indTurn); if (_indRiver != NULL) free(_indRiver); } void CreateLimit(int lev); void CreateAF(clStacks stack); size_t CreateNL(clStacks stack,bool mem); void WriteFile(int handle); void ReadFile(int handle); void CalcEV(int cnCalc); void CalcEVStart(int cnCalc); void CalcEVStartVectHero(int cnCalc, int dim); //void CalcEVThread(int cnCalc); void InitMemory(); void ReCalcWeight(); void CalcWeightStrat(); tpDis GetDis(clSitHoldem &sit, tpArrResBranch8 *arr=NULL); void CreateTreeNL(clSitHoldem &sit); void CreateTreeNL(clSitHoldem &sit0, clSitHoldem &sit); void CalcNesh(int cnCalc); void CalcNeshVectHero(int cnCalc, int dim); void SetStartParam(clSitHoldem &sit, bool setPar); bool IsHandsIn() { return _handsIn[0]._vect.size() > 0; } clTreeStrat _tree; clAnsiString _nameFileFlop, _nameFileTurn, _nameFileRiver; clHandsGroupEx _handsIn[CN_PLAYER]; private: bool ReadIndex(); size_t SetStartParam(bool mem); bool SetIndexForNabor(); static void ClearIntPtr(int *&ptr) { if (ptr != NULL){ free(ptr); ptr = NULL; } } int *_indFlop, *_indTurn, *_indRiver; }; typedef int(*tpFuncBuildTree)(clSitHoldem &, tpDis *, tpDis *); class clBuildTreeNLInfoStreet { public: clBuildTreeNLInfoStreet() { _isFold = _isCall = _isAllIn = true; _func = NULL; } int GetInfo(clSitHoldem &sit, tpDis *arrDis); int GetInfo(clSitHoldem &sit, tpDis *arrDis, tpDis disH); bool _isFold, _isCall, _isAllIn; double _kBank; vector <double> _firstWord, _firstRound, _secondRound, _replay; // положительные в ВВ отрицательные в pot tpFuncBuildTree _func; }; struct tpBuildTreeNLInfo { clBuildTreeNLInfoStreet &operator [](int nb) { return _infS[nb]; } clBuildTreeNLInfoStreet _infS[5]; }; //void CreateInf(clBuildTreeNLInfoStreet &inf, double k, int bankBB); void BuildTreeNLAuto(clTreeStrat *ptrT, clSitHoldem &sit, tpBuildTreeNLInfo &inf, clSitHoldem *sitH, int nbA,int start); extern size_t glCn0, glCn1; //--------------------------------------------------------------------------------------------------------------------------------------------------- #endif
/* Copyright (c) 2005-2023, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "DiffusionForce.hpp" #include "NodeBasedCellPopulation.hpp" //Static constant is instantiated here. template<unsigned DIM> const double DiffusionForce<DIM>::msBoltzmannConstant = 4.97033568e-7; template<unsigned DIM> DiffusionForce<DIM>::DiffusionForce() : AbstractForce<DIM>(), mAbsoluteTemperature(296.0), // default to room temperature mViscosity(3.204e-6) // default to viscosity of water at room temperature in (using 10 microns and hours) { } template<unsigned DIM> DiffusionForce<DIM>::~DiffusionForce() { } template<unsigned DIM> void DiffusionForce<DIM>::SetAbsoluteTemperature(double newValue) { assert(newValue > 0.0); mAbsoluteTemperature = newValue; } template<unsigned DIM> double DiffusionForce<DIM>::GetAbsoluteTemperature() { return mAbsoluteTemperature; } template<unsigned DIM> void DiffusionForce<DIM>::SetViscosity(double newValue) { assert(newValue > 0.0); mViscosity = newValue; } template<unsigned DIM> double DiffusionForce<DIM>::GetViscosity() { return mViscosity; } template<unsigned DIM> double DiffusionForce<DIM>::GetDiffusionScalingConstant() { return msBoltzmannConstant*mAbsoluteTemperature/(6.0*mViscosity*M_PI); } template<unsigned DIM> void DiffusionForce<DIM>::AddForceContribution(AbstractCellPopulation<DIM>& rCellPopulation) { double dt = SimulationTime::Instance()->GetTimeStep(); // Iterate over the nodes for (typename AbstractMesh<DIM, DIM>::NodeIterator node_iter = rCellPopulation.rGetMesh().GetNodeIteratorBegin(); node_iter != rCellPopulation.rGetMesh().GetNodeIteratorEnd(); ++node_iter) { // Get the index, radius and damping constant of this node unsigned node_index = node_iter->GetIndex(); double node_radius = node_iter->GetRadius(); // If the node radius is zero, then it has not been set... if (node_radius == 0.0) { // ...so throw an exception to avoid dividing by zero when we compute diffusion_constant below EXCEPTION("SetRadius() must be called on each Node before calling DiffusionForce::AddForceContribution() to avoid a division by zero error"); } double nu = dynamic_cast<AbstractOffLatticeCellPopulation<DIM>*>(&rCellPopulation)->GetDampingConstant(node_index); /* * Compute the diffusion coefficient D as D = k*T/(6*pi*eta*r), where * * k = Boltzmann's constant, * T = absolute temperature, * eta = dynamic viscosity, * r = cell radius. */ double diffusion_const_scaling = GetDiffusionScalingConstant(); double diffusion_constant = diffusion_const_scaling/node_radius; c_vector<double, DIM> force_contribution; for (unsigned i=0; i<DIM; i++) { /* * The force on this cell is scaled with the timestep such that when it is * used in the discretised equation of motion for the cell, we obtain the * correct formula * * x_new = x_old + sqrt(2*D*dt)*W * * where W is a standard normal random variable. */ double xi = RandomNumberGenerator::Instance()->StandardNormalRandomDeviate(); force_contribution[i] = (nu*sqrt(2.0*diffusion_constant*dt)/dt)*xi; } node_iter->AddAppliedForceContribution(force_contribution); } } template<unsigned DIM> void DiffusionForce<DIM>::OutputForceParameters(out_stream& rParamsFile) { *rParamsFile << "\t\t\t<AbsoluteTemperature>" << mAbsoluteTemperature << "</AbsoluteTemperature> \n"; *rParamsFile << "\t\t\t<Viscosity>" << mViscosity << "</Viscosity> \n"; // Call direct parent class AbstractForce<DIM>::OutputForceParameters(rParamsFile); } // Explicit instantiation template class DiffusionForce<1>; template class DiffusionForce<2>; template class DiffusionForce<3>; // Serialization for Boost >= 1.36 #include "SerializationExportWrapperForCpp.hpp" EXPORT_TEMPLATE_CLASS_SAME_DIMS(DiffusionForce)
// ============================================================== // RTL generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and OpenCL // Version: 2019.2 // Copyright (C) 1986-2019 Xilinx, Inc. All Rights Reserved. // // =========================================================== #include "checkAxis_2.h" #include "AESL_pkg.h" using namespace std; namespace ap_rtl { const sc_logic checkAxis_2::ap_const_logic_1 = sc_dt::Log_1; const sc_logic checkAxis_2::ap_const_logic_0 = sc_dt::Log_0; const sc_lv<56> checkAxis_2::ap_ST_fsm_state1 = "1"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state2 = "10"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state3 = "100"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state4 = "1000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state5 = "10000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state6 = "100000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state7 = "1000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state8 = "10000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state9 = "100000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state10 = "1000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state11 = "10000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state12 = "100000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state13 = "1000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state14 = "10000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state15 = "100000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state16 = "1000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state17 = "10000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state18 = "100000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state19 = "1000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state20 = "10000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state21 = "100000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state22 = "1000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state23 = "10000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state24 = "100000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state25 = "1000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state26 = "10000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state27 = "100000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state28 = "1000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state29 = "10000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state30 = "100000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state31 = "1000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state32 = "10000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state33 = "100000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state34 = "1000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state35 = "10000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state36 = "100000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state37 = "1000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state38 = "10000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state39 = "100000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state40 = "1000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state41 = "10000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state42 = "100000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state43 = "1000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state44 = "10000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state45 = "100000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state46 = "1000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state47 = "10000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state48 = "100000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state49 = "1000000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state50 = "10000000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state51 = "100000000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state52 = "1000000000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state53 = "10000000000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state54 = "100000000000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state55 = "1000000000000000000000000000000000000000000000000000000"; const sc_lv<56> checkAxis_2::ap_ST_fsm_state56 = "10000000000000000000000000000000000000000000000000000000"; const sc_lv<32> checkAxis_2::ap_const_lv32_0 = "00000000000000000000000000000000"; const sc_lv<32> checkAxis_2::ap_const_lv32_B = "1011"; const sc_lv<32> checkAxis_2::ap_const_lv32_12 = "10010"; const sc_lv<32> checkAxis_2::ap_const_lv32_19 = "11001"; const sc_lv<32> checkAxis_2::ap_const_lv32_1D = "11101"; const sc_lv<32> checkAxis_2::ap_const_lv32_21 = "100001"; const sc_lv<32> checkAxis_2::ap_const_lv32_34 = "110100"; const sc_lv<32> checkAxis_2::ap_const_lv32_E = "1110"; const sc_lv<32> checkAxis_2::ap_const_lv32_15 = "10101"; const sc_lv<32> checkAxis_2::ap_const_lv32_30 = "110000"; const sc_lv<32> checkAxis_2::ap_const_lv32_3 = "11"; const sc_lv<32> checkAxis_2::ap_const_lv32_4 = "100"; const sc_lv<1> checkAxis_2::ap_const_lv1_0 = "0"; const sc_lv<32> checkAxis_2::ap_const_lv32_7 = "111"; const sc_lv<32> checkAxis_2::ap_const_lv32_F = "1111"; const sc_lv<32> checkAxis_2::ap_const_lv32_2D = "101101"; const sc_lv<32> checkAxis_2::ap_const_lv32_31 = "110001"; const sc_lv<32> checkAxis_2::ap_const_lv32_35 = "110101"; const sc_lv<32> checkAxis_2::ap_const_lv32_36 = "110110"; const sc_lv<32> checkAxis_2::ap_const_lv32_37 = "110111"; const sc_lv<64> checkAxis_2::ap_const_lv64_0 = "0000000000000000000000000000000000000000000000000000000000000000"; const sc_lv<3> checkAxis_2::ap_const_lv3_0 = "000"; const sc_lv<32> checkAxis_2::ap_const_lv32_8 = "1000"; const sc_lv<32> checkAxis_2::ap_const_lv32_16 = "10110"; const sc_lv<32> checkAxis_2::ap_const_lv32_1A = "11010"; const sc_lv<32> checkAxis_2::ap_const_lv32_1E = "11110"; const sc_lv<32> checkAxis_2::ap_const_lv32_C = "1100"; const sc_lv<32> checkAxis_2::ap_const_lv32_13 = "10011"; const sc_lv<32> checkAxis_2::ap_const_lv32_17 = "10111"; const sc_lv<32> checkAxis_2::ap_const_lv32_2E = "101110"; const sc_lv<32> checkAxis_2::ap_const_lv32_22 = "100010"; const sc_lv<32> checkAxis_2::ap_const_lv32_2 = "10"; const sc_lv<23> checkAxis_2::ap_const_lv23_0 = "00000000000000000000000"; const sc_lv<3> checkAxis_2::ap_const_lv3_4 = "100"; const sc_lv<3> checkAxis_2::ap_const_lv3_1 = "1"; const sc_lv<8> checkAxis_2::ap_const_lv8_FF = "11111111"; const sc_lv<32> checkAxis_2::ap_const_lv32_80000000 = "10000000000000000000000000000000"; const sc_lv<9> checkAxis_2::ap_const_lv9_181 = "110000001"; const sc_lv<8> checkAxis_2::ap_const_lv8_7F = "1111111"; const sc_lv<1> checkAxis_2::ap_const_lv1_1 = "1"; const sc_lv<32> checkAxis_2::ap_const_lv32_1F = "11111"; const sc_lv<32> checkAxis_2::ap_const_lv32_18 = "11000"; const sc_lv<32> checkAxis_2::ap_const_lv32_4E = "1001110"; const sc_lv<30> checkAxis_2::ap_const_lv30_0 = "000000000000000000000000000000"; const sc_lv<2> checkAxis_2::ap_const_lv2_0 = "00"; const sc_lv<4> checkAxis_2::ap_const_lv4_0 = "0000"; const sc_lv<64> checkAxis_2::ap_const_lv64_1 = "1"; const sc_lv<3> checkAxis_2::ap_const_lv3_7 = "111"; const sc_lv<2> checkAxis_2::ap_const_lv2_1 = "1"; const sc_lv<5> checkAxis_2::ap_const_lv5_4 = "100"; const sc_lv<5> checkAxis_2::ap_const_lv5_5 = "101"; const sc_lv<5> checkAxis_2::ap_const_lv5_2 = "10"; const sc_lv<5> checkAxis_2::ap_const_lv5_3 = "11"; const bool checkAxis_2::ap_const_boolean_1 = true; checkAxis_2::checkAxis_2(sc_module_name name) : sc_module(name), mVcdFile(0) { honeybee_faddfsubbkb_U1 = new honeybee_faddfsubbkb<1,4,32,32,32>("honeybee_faddfsubbkb_U1"); honeybee_faddfsubbkb_U1->clk(ap_clk); honeybee_faddfsubbkb_U1->reset(ap_rst); honeybee_faddfsubbkb_U1->din0(grp_fu_148_p0); honeybee_faddfsubbkb_U1->din1(grp_fu_148_p1); honeybee_faddfsubbkb_U1->opcode(grp_fu_148_opcode); honeybee_faddfsubbkb_U1->ce(ap_var_for_const0); honeybee_faddfsubbkb_U1->dout(grp_fu_148_p2); honeybee_faddfsubbkb_U2 = new honeybee_faddfsubbkb<1,4,32,32,32>("honeybee_faddfsubbkb_U2"); honeybee_faddfsubbkb_U2->clk(ap_clk); honeybee_faddfsubbkb_U2->reset(ap_rst); honeybee_faddfsubbkb_U2->din0(grp_fu_154_p0); honeybee_faddfsubbkb_U2->din1(grp_fu_154_p1); honeybee_faddfsubbkb_U2->opcode(grp_fu_154_opcode); honeybee_faddfsubbkb_U2->ce(ap_var_for_const0); honeybee_faddfsubbkb_U2->dout(grp_fu_154_p2); honeybee_faddfsubbkb_U3 = new honeybee_faddfsubbkb<1,4,32,32,32>("honeybee_faddfsubbkb_U3"); honeybee_faddfsubbkb_U3->clk(ap_clk); honeybee_faddfsubbkb_U3->reset(ap_rst); honeybee_faddfsubbkb_U3->din0(grp_fu_160_p0); honeybee_faddfsubbkb_U3->din1(grp_fu_160_p1); honeybee_faddfsubbkb_U3->opcode(grp_fu_160_opcode); honeybee_faddfsubbkb_U3->ce(ap_var_for_const0); honeybee_faddfsubbkb_U3->dout(grp_fu_160_p2); honeybee_fmul_32ncud_U4 = new honeybee_fmul_32ncud<1,3,32,32,32>("honeybee_fmul_32ncud_U4"); honeybee_fmul_32ncud_U4->clk(ap_clk); honeybee_fmul_32ncud_U4->reset(ap_rst); honeybee_fmul_32ncud_U4->din0(grp_fu_166_p0); honeybee_fmul_32ncud_U4->din1(grp_fu_166_p1); honeybee_fmul_32ncud_U4->ce(ap_var_for_const0); honeybee_fmul_32ncud_U4->dout(grp_fu_166_p2); honeybee_fmul_32ncud_U5 = new honeybee_fmul_32ncud<1,3,32,32,32>("honeybee_fmul_32ncud_U5"); honeybee_fmul_32ncud_U5->clk(ap_clk); honeybee_fmul_32ncud_U5->reset(ap_rst); honeybee_fmul_32ncud_U5->din0(grp_fu_171_p0); honeybee_fmul_32ncud_U5->din1(grp_fu_171_p1); honeybee_fmul_32ncud_U5->ce(ap_var_for_const0); honeybee_fmul_32ncud_U5->dout(grp_fu_171_p2); honeybee_fmul_32ncud_U6 = new honeybee_fmul_32ncud<1,3,32,32,32>("honeybee_fmul_32ncud_U6"); honeybee_fmul_32ncud_U6->clk(ap_clk); honeybee_fmul_32ncud_U6->reset(ap_rst); honeybee_fmul_32ncud_U6->din0(grp_fu_175_p0); honeybee_fmul_32ncud_U6->din1(grp_fu_175_p1); honeybee_fmul_32ncud_U6->ce(ap_var_for_const0); honeybee_fmul_32ncud_U6->dout(grp_fu_175_p2); honeybee_fdiv_32ndEe_U7 = new honeybee_fdiv_32ndEe<1,12,32,32,32>("honeybee_fdiv_32ndEe_U7"); honeybee_fdiv_32ndEe_U7->clk(ap_clk); honeybee_fdiv_32ndEe_U7->reset(ap_rst); honeybee_fdiv_32ndEe_U7->din0(reg_210); honeybee_fdiv_32ndEe_U7->din1(reg_242); honeybee_fdiv_32ndEe_U7->ce(ap_var_for_const0); honeybee_fdiv_32ndEe_U7->dout(grp_fu_179_p2); honeybee_sitofp_3eOg_U8 = new honeybee_sitofp_3eOg<1,4,32,32>("honeybee_sitofp_3eOg_U8"); honeybee_sitofp_3eOg_U8->clk(ap_clk); honeybee_sitofp_3eOg_U8->reset(ap_rst); honeybee_sitofp_3eOg_U8->din0(grp_fu_183_p0); honeybee_sitofp_3eOg_U8->ce(ap_var_for_const0); honeybee_sitofp_3eOg_U8->dout(grp_fu_183_p1); honeybee_fcmp_32nfYi_U9 = new honeybee_fcmp_32nfYi<1,2,32,32,1>("honeybee_fcmp_32nfYi_U9"); honeybee_fcmp_32nfYi_U9->clk(ap_clk); honeybee_fcmp_32nfYi_U9->reset(ap_rst); honeybee_fcmp_32nfYi_U9->din0(grp_fu_186_p0); honeybee_fcmp_32nfYi_U9->din1(grp_fu_186_p1); honeybee_fcmp_32nfYi_U9->ce(ap_var_for_const0); honeybee_fcmp_32nfYi_U9->opcode(grp_fu_186_opcode); honeybee_fcmp_32nfYi_U9->dout(grp_fu_186_p2); honeybee_fcmp_32nfYi_U10 = new honeybee_fcmp_32nfYi<1,2,32,32,1>("honeybee_fcmp_32nfYi_U10"); honeybee_fcmp_32nfYi_U10->clk(ap_clk); honeybee_fcmp_32nfYi_U10->reset(ap_rst); honeybee_fcmp_32nfYi_U10->din0(grp_fu_190_p0); honeybee_fcmp_32nfYi_U10->din1(grp_fu_190_p1); honeybee_fcmp_32nfYi_U10->ce(ap_var_for_const0); honeybee_fcmp_32nfYi_U10->opcode(grp_fu_190_opcode); honeybee_fcmp_32nfYi_U10->dout(grp_fu_190_p2); honeybee_fcmp_32nfYi_U11 = new honeybee_fcmp_32nfYi<1,2,32,32,1>("honeybee_fcmp_32nfYi_U11"); honeybee_fcmp_32nfYi_U11->clk(ap_clk); honeybee_fcmp_32nfYi_U11->reset(ap_rst); honeybee_fcmp_32nfYi_U11->din0(grp_fu_194_p0); honeybee_fcmp_32nfYi_U11->din1(grp_fu_194_p1); honeybee_fcmp_32nfYi_U11->ce(ap_var_for_const0); honeybee_fcmp_32nfYi_U11->opcode(grp_fu_194_opcode); honeybee_fcmp_32nfYi_U11->dout(grp_fu_194_p2); honeybee_fcmp_32nfYi_U12 = new honeybee_fcmp_32nfYi<1,2,32,32,1>("honeybee_fcmp_32nfYi_U12"); honeybee_fcmp_32nfYi_U12->clk(ap_clk); honeybee_fcmp_32nfYi_U12->reset(ap_rst); honeybee_fcmp_32nfYi_U12->din0(grp_fu_198_p0); honeybee_fcmp_32nfYi_U12->din1(grp_fu_198_p1); honeybee_fcmp_32nfYi_U12->ce(ap_var_for_const0); honeybee_fcmp_32nfYi_U12->opcode(grp_fu_198_opcode); honeybee_fcmp_32nfYi_U12->dout(grp_fu_198_p2); honeybee_fcmp_32nfYi_U13 = new honeybee_fcmp_32nfYi<1,2,32,32,1>("honeybee_fcmp_32nfYi_U13"); honeybee_fcmp_32nfYi_U13->clk(ap_clk); honeybee_fcmp_32nfYi_U13->reset(ap_rst); honeybee_fcmp_32nfYi_U13->din0(grp_fu_202_p0); honeybee_fcmp_32nfYi_U13->din1(grp_fu_202_p1); honeybee_fcmp_32nfYi_U13->ce(ap_var_for_const0); honeybee_fcmp_32nfYi_U13->opcode(grp_fu_202_opcode); honeybee_fcmp_32nfYi_U13->dout(grp_fu_202_p2); honeybee_fcmp_32nfYi_U14 = new honeybee_fcmp_32nfYi<1,2,32,32,1>("honeybee_fcmp_32nfYi_U14"); honeybee_fcmp_32nfYi_U14->clk(ap_clk); honeybee_fcmp_32nfYi_U14->reset(ap_rst); honeybee_fcmp_32nfYi_U14->din0(grp_fu_206_p0); honeybee_fcmp_32nfYi_U14->din1(grp_fu_206_p1); honeybee_fcmp_32nfYi_U14->ce(ap_var_for_const0); honeybee_fcmp_32nfYi_U14->opcode(grp_fu_206_opcode); honeybee_fcmp_32nfYi_U14->dout(grp_fu_206_p2); SC_METHOD(thread_ap_clk_no_reset_); dont_initialize(); sensitive << ( ap_clk.pos() ); SC_METHOD(thread_add_ln339_1_fu_1146_p2); sensitive << ( zext_ln339_1_fu_1142_p1 ); SC_METHOD(thread_add_ln339_fu_803_p2); sensitive << ( zext_ln339_fu_799_p1 ); SC_METHOD(thread_add_ln82_1_fu_1284_p2); sensitive << ( add_ln82_reg_1708 ); sensitive << ( zext_ln82_fu_1280_p1 ); SC_METHOD(thread_add_ln82_2_fu_1299_p2); sensitive << ( k_assign_reg_136 ); SC_METHOD(thread_add_ln82_3_fu_1317_p2); sensitive << ( add_ln82_reg_1708 ); sensitive << ( sext_ln82_fu_1313_p1 ); SC_METHOD(thread_add_ln82_fu_1262_p2); sensitive << ( shl_ln_fu_1254_p3 ); sensitive << ( p_Val2_5_fu_1112_p3 ); SC_METHOD(thread_and_ln49_1_fu_505_p2); sensitive << ( tmp_2_reg_1450 ); sensitive << ( and_ln49_reg_1533 ); SC_METHOD(thread_and_ln49_2_fu_849_p2); sensitive << ( or_ln49_2_fu_835_p2 ); sensitive << ( or_ln49_3_fu_844_p2 ); SC_METHOD(thread_and_ln49_3_fu_855_p2); sensitive << ( grp_fu_186_p2 ); sensitive << ( and_ln49_2_fu_849_p2 ); SC_METHOD(thread_and_ln49_4_fu_515_p2); sensitive << ( tmp_8_reg_1455 ); sensitive << ( and_ln49_reg_1533 ); SC_METHOD(thread_and_ln49_5_fu_865_p2); sensitive << ( or_ln49_3_fu_844_p2 ); sensitive << ( or_ln49_4_fu_861_p2 ); SC_METHOD(thread_and_ln49_6_fu_871_p2); sensitive << ( grp_fu_190_p2 ); sensitive << ( and_ln49_5_fu_865_p2 ); SC_METHOD(thread_and_ln49_7_fu_950_p2); sensitive << ( and_ln49_3_fu_855_p2 ); sensitive << ( and_ln49_6_fu_871_p2 ); SC_METHOD(thread_and_ln49_fu_393_p2); sensitive << ( or_ln49_fu_377_p2 ); sensitive << ( or_ln49_1_fu_388_p2 ); SC_METHOD(thread_and_ln50_1_fu_525_p2); sensitive << ( tmp_s_reg_1480 ); sensitive << ( and_ln50_reg_1539 ); SC_METHOD(thread_and_ln50_2_fu_917_p2); sensitive << ( or_ln50_2_fu_895_p2 ); sensitive << ( or_ln50_3_fu_911_p2 ); SC_METHOD(thread_and_ln50_3_fu_923_p2); sensitive << ( grp_fu_194_p2 ); sensitive << ( and_ln50_2_fu_917_p2 ); SC_METHOD(thread_and_ln50_4_fu_535_p2); sensitive << ( tmp_6_reg_1485 ); sensitive << ( and_ln50_reg_1539 ); SC_METHOD(thread_and_ln50_fu_439_p2); sensitive << ( or_ln50_fu_423_p2 ); sensitive << ( or_ln50_1_fu_434_p2 ); SC_METHOD(thread_and_ln51_10_fu_1011_p2); sensitive << ( and_ln51_6_fu_983_p2 ); sensitive << ( and_ln51_9_fu_1005_p2 ); SC_METHOD(thread_and_ln51_11_fu_1023_p2); sensitive << ( or_ln51_6_fu_1017_p2 ); sensitive << ( or_ln50_4_fu_962_p2 ); SC_METHOD(thread_and_ln51_12_fu_1029_p2); sensitive << ( and_ln51_11_fu_1023_p2 ); sensitive << ( and_ln51_7_fu_989_p2 ); SC_METHOD(thread_and_ln51_1_fu_545_p2); sensitive << ( tmp_7_reg_1510 ); sensitive << ( and_ln51_reg_1545 ); SC_METHOD(thread_and_ln51_2_fu_555_p2); sensitive << ( tmp_4_reg_1515 ); sensitive << ( and_ln51_reg_1545 ); SC_METHOD(thread_and_ln51_3_fu_939_p2); sensitive << ( or_ln51_3_reg_1666 ); sensitive << ( or_ln51_2_fu_935_p2 ); SC_METHOD(thread_and_ln51_4_fu_944_p2); sensitive << ( grp_fu_198_p2 ); sensitive << ( and_ln51_3_fu_939_p2 ); SC_METHOD(thread_and_ln51_5_fu_978_p2); sensitive << ( or_ln51_3_reg_1666 ); sensitive << ( or_ln51_4_fu_974_p2 ); SC_METHOD(thread_and_ln51_6_fu_983_p2); sensitive << ( grp_fu_202_p2 ); sensitive << ( and_ln51_5_fu_978_p2 ); SC_METHOD(thread_and_ln51_7_fu_989_p2); sensitive << ( and_ln49_7_fu_950_p2 ); sensitive << ( and_ln51_4_fu_944_p2 ); SC_METHOD(thread_and_ln51_8_fu_999_p2); sensitive << ( or_ln50_3_fu_911_p2 ); sensitive << ( or_ln51_5_fu_995_p2 ); SC_METHOD(thread_and_ln51_9_fu_1005_p2); sensitive << ( grp_fu_206_p2 ); sensitive << ( and_ln51_8_fu_999_p2 ); SC_METHOD(thread_and_ln51_fu_485_p2); sensitive << ( or_ln51_fu_469_p2 ); sensitive << ( or_ln51_1_fu_480_p2 ); SC_METHOD(thread_ap_CS_fsm_state1); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state12); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state13); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state15); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state16); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state19); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state20); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state22); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state23); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state24); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state26); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state27); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state3); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state30); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state31); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state34); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state35); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state4); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state46); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state47); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state49); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state5); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state50); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state53); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state54); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state55); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state56); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state8); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state9); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_done); sensitive << ( ap_start ); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); SC_METHOD(thread_ap_idle); sensitive << ( ap_start ); sensitive << ( ap_CS_fsm_state1 ); SC_METHOD(thread_ap_ready); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); SC_METHOD(thread_ap_return); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); sensitive << ( collisions_0_reg_124 ); sensitive << ( ap_return_preg ); SC_METHOD(thread_bitcast_ln22_1_fu_501_p1); sensitive << ( xor_ln22_reg_1557 ); SC_METHOD(thread_bitcast_ln22_fu_491_p1); sensitive << ( reg_210 ); SC_METHOD(thread_bitcast_ln49_1_fu_265_p1); sensitive << ( edge_p2_x ); SC_METHOD(thread_bitcast_ln49_2_fu_565_p1); sensitive << ( p_a_reg_1574 ); SC_METHOD(thread_bitcast_ln49_4_fu_618_p1); sensitive << ( p_a_1_reg_1580 ); SC_METHOD(thread_bitcast_ln49_fu_258_p1); sensitive << ( edge_p1_x ); SC_METHOD(thread_bitcast_ln50_1_fu_291_p1); sensitive << ( edge_p2_y ); SC_METHOD(thread_bitcast_ln50_2_fu_647_p1); sensitive << ( p_a_2_reg_1586 ); SC_METHOD(thread_bitcast_ln50_fu_284_p1); sensitive << ( edge_p1_y ); SC_METHOD(thread_bitcast_ln51_1_fu_317_p1); sensitive << ( edge_p2_z ); SC_METHOD(thread_bitcast_ln51_2_fu_676_p1); sensitive << ( p_a_5_reg_1604 ); SC_METHOD(thread_bitcast_ln51_3_fu_693_p1); sensitive << ( reg_251 ); SC_METHOD(thread_bitcast_ln51_4_fu_741_p1); sensitive << ( p_a_4_reg_1598 ); SC_METHOD(thread_bitcast_ln51_5_fu_770_p1); sensitive << ( p_a_3_reg_1592 ); SC_METHOD(thread_bitcast_ln51_fu_310_p1); sensitive << ( edge_p1_z ); SC_METHOD(thread_collisions_1_fu_1344_p3); sensitive << ( and_ln51_12_reg_1703 ); sensitive << ( collisions_0_reg_124 ); sensitive << ( collisions_fu_1338_p2 ); SC_METHOD(thread_collisions_fu_1338_p2); sensitive << ( or_ln98_fu_1332_p2 ); sensitive << ( shl_ln97_fu_1293_p2 ); SC_METHOD(thread_grp_fu_148_opcode); sensitive << ( ap_start ); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( ap_CS_fsm_state16 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( ap_CS_fsm_state23 ); sensitive << ( ap_CS_fsm_state27 ); sensitive << ( ap_CS_fsm_state31 ); SC_METHOD(thread_grp_fu_148_p0); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( edge_p2_x ); sensitive << ( reg_210 ); sensitive << ( reg_223 ); sensitive << ( R_z_reg_1551 ); sensitive << ( ap_CS_fsm_state16 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( ap_CS_fsm_state23 ); sensitive << ( ap_CS_fsm_state27 ); sensitive << ( ap_CS_fsm_state31 ); SC_METHOD(thread_grp_fu_148_p1); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( edge_p1_x ); sensitive << ( reg_223 ); sensitive << ( reg_242 ); sensitive << ( R_z_reg_1551 ); sensitive << ( bitcast_ln22_1_fu_501_p1 ); sensitive << ( ap_CS_fsm_state16 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( ap_CS_fsm_state23 ); sensitive << ( ap_CS_fsm_state27 ); sensitive << ( ap_CS_fsm_state31 ); SC_METHOD(thread_grp_fu_154_opcode); sensitive << ( ap_start ); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state23 ); sensitive << ( ap_CS_fsm_state27 ); sensitive << ( ap_CS_fsm_state31 ); SC_METHOD(thread_grp_fu_154_p0); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( edge_p2_y ); sensitive << ( reg_230 ); sensitive << ( reg_242 ); sensitive << ( reg_251 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state23 ); sensitive << ( ap_CS_fsm_state27 ); sensitive << ( ap_CS_fsm_state31 ); SC_METHOD(thread_grp_fu_154_p1); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( edge_p1_y ); sensitive << ( edge_p1_z ); sensitive << ( reg_236 ); sensitive << ( tmp_24_i_i_reg_1424 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state23 ); sensitive << ( ap_CS_fsm_state27 ); sensitive << ( ap_CS_fsm_state31 ); SC_METHOD(thread_grp_fu_160_opcode); sensitive << ( ap_start ); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state27 ); SC_METHOD(thread_grp_fu_160_p0); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( edge_p2_z ); sensitive << ( reg_223 ); sensitive << ( reg_236 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state27 ); SC_METHOD(thread_grp_fu_160_p1); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( edge_p1_z ); sensitive << ( reg_230 ); sensitive << ( ap_CS_fsm_state50 ); sensitive << ( ap_CS_fsm_state27 ); SC_METHOD(thread_grp_fu_166_p0); sensitive << ( reg_210 ); sensitive << ( tmp_19_i_i_reg_1414 ); sensitive << ( ap_CS_fsm_state13 ); sensitive << ( ap_CS_fsm_state20 ); sensitive << ( ap_CS_fsm_state24 ); sensitive << ( ap_CS_fsm_state47 ); SC_METHOD(thread_grp_fu_166_p1); sensitive << ( reg_210 ); sensitive << ( T_reg_1567 ); sensitive << ( ap_CS_fsm_state13 ); sensitive << ( ap_CS_fsm_state20 ); sensitive << ( ap_CS_fsm_state24 ); sensitive << ( ap_CS_fsm_state47 ); SC_METHOD(thread_grp_fu_171_p0); sensitive << ( reg_210 ); sensitive << ( tmp_21_i_i_reg_1419 ); sensitive << ( ap_CS_fsm_state20 ); sensitive << ( ap_CS_fsm_state24 ); sensitive << ( ap_CS_fsm_state47 ); SC_METHOD(thread_grp_fu_171_p1); sensitive << ( edge_p1_x ); sensitive << ( reg_210 ); sensitive << ( T_reg_1567 ); sensitive << ( ap_CS_fsm_state20 ); sensitive << ( ap_CS_fsm_state24 ); sensitive << ( ap_CS_fsm_state47 ); SC_METHOD(thread_grp_fu_175_p0); sensitive << ( reg_210 ); sensitive << ( tmp_24_i_i_reg_1424 ); sensitive << ( ap_CS_fsm_state20 ); sensitive << ( ap_CS_fsm_state47 ); SC_METHOD(thread_grp_fu_175_p1); sensitive << ( edge_p1_y ); sensitive << ( T_reg_1567 ); sensitive << ( ap_CS_fsm_state20 ); sensitive << ( ap_CS_fsm_state47 ); SC_METHOD(thread_grp_fu_183_p0); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( k_assign_reg_136 ); SC_METHOD(thread_grp_fu_186_opcode); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_186_p0); sensitive << ( edge_p1_x ); sensitive << ( p_a_reg_1574 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_186_p1); sensitive << ( edge_p2_x ); sensitive << ( reg_210 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_190_opcode); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_190_p0); sensitive << ( edge_p1_x ); sensitive << ( p_a_1_reg_1580 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_190_p1); sensitive << ( edge_p2_x ); sensitive << ( reg_210 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_194_opcode); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_194_p0); sensitive << ( edge_p1_y ); sensitive << ( p_a_2_reg_1586 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_194_p1); sensitive << ( edge_p2_y ); sensitive << ( reg_242 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_198_opcode); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_198_p0); sensitive << ( edge_p1_y ); sensitive << ( p_a_5_reg_1604 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_198_p1); sensitive << ( edge_p2_y ); sensitive << ( reg_251 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_202_opcode); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_202_p0); sensitive << ( edge_p1_z ); sensitive << ( p_a_4_reg_1598 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_202_p1); sensitive << ( edge_p2_z ); sensitive << ( reg_251 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_206_opcode); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_206_p0); sensitive << ( edge_p1_z ); sensitive << ( p_a_3_reg_1592 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_grp_fu_206_p1); sensitive << ( edge_p2_z ); sensitive << ( reg_242 ); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( ap_CS_fsm_state3 ); SC_METHOD(thread_i_fu_347_p2); sensitive << ( k_assign_reg_136 ); SC_METHOD(thread_icmp_ln49_1_fu_272_p2); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( trunc_ln49_fu_261_p1 ); SC_METHOD(thread_icmp_ln49_2_fu_382_p2); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); sensitive << ( tmp_1_fu_362_p4 ); SC_METHOD(thread_icmp_ln49_3_fu_278_p2); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( trunc_ln49_1_fu_268_p1 ); SC_METHOD(thread_icmp_ln49_4_fu_600_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( tmp_3_fu_568_p4 ); SC_METHOD(thread_icmp_ln49_5_fu_606_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( trunc_ln49_2_fu_578_p1 ); SC_METHOD(thread_icmp_ln49_6_fu_612_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( tmp_V_fu_586_p4 ); SC_METHOD(thread_icmp_ln49_7_fu_839_p2); sensitive << ( tmp_V_1_reg_1615 ); sensitive << ( ap_CS_fsm_state55 ); SC_METHOD(thread_icmp_ln49_8_fu_635_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( tmp_9_fu_621_p4 ); SC_METHOD(thread_icmp_ln49_9_fu_641_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( trunc_ln49_4_fu_631_p1 ); SC_METHOD(thread_icmp_ln49_fu_371_p2); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); sensitive << ( tmp_fu_353_p4 ); SC_METHOD(thread_icmp_ln50_1_fu_298_p2); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( trunc_ln50_fu_287_p1 ); SC_METHOD(thread_icmp_ln50_2_fu_428_p2); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); sensitive << ( tmp_12_fu_408_p4 ); SC_METHOD(thread_icmp_ln50_3_fu_304_p2); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( trunc_ln50_1_fu_294_p1 ); SC_METHOD(thread_icmp_ln50_4_fu_664_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( tmp_13_fu_650_p4 ); SC_METHOD(thread_icmp_ln50_5_fu_670_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( trunc_ln50_2_fu_660_p1 ); SC_METHOD(thread_icmp_ln50_6_fu_899_p2); sensitive << ( ap_CS_fsm_state55 ); sensitive << ( tmp_V_2_fu_881_p4 ); SC_METHOD(thread_icmp_ln50_7_fu_905_p2); sensitive << ( ap_CS_fsm_state55 ); sensitive << ( tmp_V_3_fu_891_p1 ); SC_METHOD(thread_icmp_ln50_fu_417_p2); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); sensitive << ( tmp_11_fu_399_p4 ); SC_METHOD(thread_icmp_ln51_10_fu_787_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( tmp_22_fu_773_p4 ); SC_METHOD(thread_icmp_ln51_11_fu_793_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( trunc_ln51_5_fu_783_p1 ); SC_METHOD(thread_icmp_ln51_1_fu_324_p2); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( trunc_ln51_fu_313_p1 ); SC_METHOD(thread_icmp_ln51_2_fu_474_p2); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); sensitive << ( tmp_16_fu_454_p4 ); SC_METHOD(thread_icmp_ln51_3_fu_330_p2); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( trunc_ln51_1_fu_320_p1 ); SC_METHOD(thread_icmp_ln51_4_fu_711_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( tmp_17_fu_679_p4 ); SC_METHOD(thread_icmp_ln51_5_fu_717_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( trunc_ln51_2_fu_689_p1 ); SC_METHOD(thread_icmp_ln51_6_fu_723_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( tmp_18_fu_697_p4 ); SC_METHOD(thread_icmp_ln51_7_fu_729_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( trunc_ln51_3_fu_707_p1 ); SC_METHOD(thread_icmp_ln51_8_fu_758_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( tmp_20_fu_744_p4 ); SC_METHOD(thread_icmp_ln51_9_fu_764_p2); sensitive << ( ap_CS_fsm_state54 ); sensitive << ( trunc_ln51_4_fu_754_p1 ); SC_METHOD(thread_icmp_ln51_fu_463_p2); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); sensitive << ( tmp_15_fu_445_p4 ); SC_METHOD(thread_icmp_ln92_fu_341_p2); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( k_assign_reg_136 ); SC_METHOD(thread_isNeg_1_fu_1152_p3); sensitive << ( add_ln339_1_fu_1146_p2 ); SC_METHOD(thread_isNeg_fu_809_p3); sensitive << ( add_ln339_fu_803_p2 ); SC_METHOD(thread_mantissa_V_1_fu_1128_p4); sensitive << ( tmp_V_3_fu_891_p1 ); SC_METHOD(thread_mantissa_V_fu_1042_p4); sensitive << ( tmp_V_1_reg_1615 ); SC_METHOD(thread_or_ln49_1_fu_388_p2); sensitive << ( icmp_ln49_3_reg_1445 ); sensitive << ( icmp_ln49_2_fu_382_p2 ); SC_METHOD(thread_or_ln49_2_fu_835_p2); sensitive << ( icmp_ln49_4_reg_1621 ); sensitive << ( icmp_ln49_5_reg_1626 ); SC_METHOD(thread_or_ln49_3_fu_844_p2); sensitive << ( icmp_ln49_6_reg_1631 ); sensitive << ( icmp_ln49_7_fu_839_p2 ); SC_METHOD(thread_or_ln49_4_fu_861_p2); sensitive << ( icmp_ln49_8_reg_1636 ); sensitive << ( icmp_ln49_9_reg_1641 ); SC_METHOD(thread_or_ln49_fu_377_p2); sensitive << ( icmp_ln49_1_reg_1440 ); sensitive << ( icmp_ln49_fu_371_p2 ); SC_METHOD(thread_or_ln50_1_fu_434_p2); sensitive << ( icmp_ln50_3_reg_1475 ); sensitive << ( icmp_ln50_2_fu_428_p2 ); SC_METHOD(thread_or_ln50_2_fu_895_p2); sensitive << ( icmp_ln50_4_reg_1646 ); sensitive << ( icmp_ln50_5_reg_1651 ); SC_METHOD(thread_or_ln50_3_fu_911_p2); sensitive << ( icmp_ln50_7_fu_905_p2 ); sensitive << ( icmp_ln50_6_fu_899_p2 ); SC_METHOD(thread_or_ln50_4_fu_962_p2); sensitive << ( and_ln50_3_fu_923_p2 ); sensitive << ( xor_ln49_fu_956_p2 ); SC_METHOD(thread_or_ln50_5_fu_968_p2); sensitive << ( xor_ln49_fu_956_p2 ); sensitive << ( xor_ln50_fu_929_p2 ); SC_METHOD(thread_or_ln50_fu_423_p2); sensitive << ( icmp_ln50_1_reg_1470 ); sensitive << ( icmp_ln50_fu_417_p2 ); SC_METHOD(thread_or_ln51_1_fu_480_p2); sensitive << ( icmp_ln51_3_reg_1505 ); sensitive << ( icmp_ln51_2_fu_474_p2 ); SC_METHOD(thread_or_ln51_2_fu_935_p2); sensitive << ( icmp_ln51_4_reg_1656 ); sensitive << ( icmp_ln51_5_reg_1661 ); SC_METHOD(thread_or_ln51_3_fu_735_p2); sensitive << ( icmp_ln51_7_fu_729_p2 ); sensitive << ( icmp_ln51_6_fu_723_p2 ); SC_METHOD(thread_or_ln51_4_fu_974_p2); sensitive << ( icmp_ln51_8_reg_1672 ); sensitive << ( icmp_ln51_9_reg_1677 ); SC_METHOD(thread_or_ln51_5_fu_995_p2); sensitive << ( icmp_ln51_10_reg_1682 ); sensitive << ( icmp_ln51_11_reg_1687 ); SC_METHOD(thread_or_ln51_6_fu_1017_p2); sensitive << ( or_ln50_5_fu_968_p2 ); sensitive << ( and_ln51_10_fu_1011_p2 ); SC_METHOD(thread_or_ln51_fu_469_p2); sensitive << ( icmp_ln51_1_reg_1500 ); sensitive << ( icmp_ln51_fu_463_p2 ); SC_METHOD(thread_or_ln98_fu_1332_p2); sensitive << ( collisions_0_reg_124 ); sensitive << ( shl_ln98_fu_1326_p2 ); SC_METHOD(thread_p_Result_1_fu_1120_p3); sensitive << ( p_Val2_s_fu_877_p1 ); SC_METHOD(thread_p_Result_s_fu_1035_p3); sensitive << ( p_Val2_1_reg_1610 ); SC_METHOD(thread_p_Val2_1_fu_582_p1); sensitive << ( reg_210 ); SC_METHOD(thread_p_Val2_4_fu_1099_p3); sensitive << ( isNeg_reg_1692 ); sensitive << ( zext_ln662_fu_1085_p1 ); sensitive << ( tmp_24_fu_1089_p4 ); SC_METHOD(thread_p_Val2_5_fu_1112_p3); sensitive << ( p_Val2_4_fu_1099_p3 ); sensitive << ( p_Result_s_fu_1035_p3 ); sensitive << ( result_V_1_fu_1106_p2 ); SC_METHOD(thread_p_Val2_s_fu_877_p1); sensitive << ( reg_242 ); SC_METHOD(thread_p_a_1_fu_519_p3); sensitive << ( edge_p1_x ); sensitive << ( edge_p2_x ); sensitive << ( and_ln49_4_fu_515_p2 ); SC_METHOD(thread_p_a_2_fu_529_p3); sensitive << ( edge_p1_y ); sensitive << ( edge_p2_y ); sensitive << ( and_ln50_1_fu_525_p2 ); SC_METHOD(thread_p_a_3_fu_539_p3); sensitive << ( edge_p1_y ); sensitive << ( edge_p2_y ); sensitive << ( and_ln50_4_fu_535_p2 ); SC_METHOD(thread_p_a_4_fu_549_p3); sensitive << ( edge_p1_z ); sensitive << ( edge_p2_z ); sensitive << ( and_ln51_1_fu_545_p2 ); SC_METHOD(thread_p_a_5_fu_559_p3); sensitive << ( edge_p1_z ); sensitive << ( edge_p2_z ); sensitive << ( and_ln51_2_fu_555_p2 ); SC_METHOD(thread_p_a_fu_509_p3); sensitive << ( edge_p1_x ); sensitive << ( edge_p2_x ); sensitive << ( and_ln49_1_fu_505_p2 ); SC_METHOD(thread_r_V_1_fu_1071_p2); sensitive << ( zext_ln682_fu_1051_p1 ); sensitive << ( zext_ln1287_fu_1061_p1 ); SC_METHOD(thread_r_V_2_fu_1190_p2); sensitive << ( mantissa_V_1_fu_1128_p4 ); sensitive << ( sext_ln1311_5_fu_1182_p1 ); SC_METHOD(thread_r_V_3_fu_1196_p2); sensitive << ( zext_ln682_1_fu_1138_p1 ); sensitive << ( zext_ln1287_1_fu_1186_p1 ); SC_METHOD(thread_r_V_fu_1065_p2); sensitive << ( mantissa_V_fu_1042_p4 ); sensitive << ( sext_ln1311_4_fu_1058_p1 ); SC_METHOD(thread_result_V_1_fu_1106_p2); sensitive << ( p_Val2_4_fu_1099_p3 ); SC_METHOD(thread_select_ln1312_fu_1224_p3); sensitive << ( isNeg_1_fu_1152_p3 ); sensitive << ( zext_ln662_1_fu_1210_p1 ); sensitive << ( tmp_25_fu_1214_p4 ); SC_METHOD(thread_select_ln59_fu_1246_p3); sensitive << ( p_Result_1_fu_1120_p3 ); sensitive << ( sub_ln82_fu_1236_p2 ); sensitive << ( trunc_ln82_1_fu_1242_p1 ); SC_METHOD(thread_sext_ln1311_1_fu_1055_p1); sensitive << ( ush_reg_1697 ); SC_METHOD(thread_sext_ln1311_2_fu_1166_p1); sensitive << ( sub_ln1311_1_fu_1160_p2 ); SC_METHOD(thread_sext_ln1311_3_fu_1178_p1); sensitive << ( ush_1_fu_1170_p3 ); SC_METHOD(thread_sext_ln1311_4_fu_1058_p1); sensitive << ( ush_reg_1697 ); SC_METHOD(thread_sext_ln1311_5_fu_1182_p1); sensitive << ( ush_1_fu_1170_p3 ); SC_METHOD(thread_sext_ln1311_fu_823_p1); sensitive << ( sub_ln1311_fu_817_p2 ); SC_METHOD(thread_sext_ln82_fu_1313_p1); sensitive << ( tmp_26_fu_1305_p3 ); SC_METHOD(thread_shl_ln82_1_fu_1272_p3); sensitive << ( trunc_ln82_2_fu_1268_p1 ); SC_METHOD(thread_shl_ln97_fu_1293_p2); sensitive << ( zext_ln97_fu_1289_p1 ); SC_METHOD(thread_shl_ln98_fu_1326_p2); sensitive << ( zext_ln98_fu_1322_p1 ); SC_METHOD(thread_shl_ln_fu_1254_p3); sensitive << ( select_ln59_fu_1246_p3 ); SC_METHOD(thread_sub_ln1311_1_fu_1160_p2); sensitive << ( tmp_V_2_fu_881_p4 ); SC_METHOD(thread_sub_ln1311_fu_817_p2); sensitive << ( tmp_V_fu_586_p4 ); SC_METHOD(thread_sub_ln82_fu_1236_p2); sensitive << ( trunc_ln82_fu_1232_p1 ); SC_METHOD(thread_tmp_11_fu_399_p4); sensitive << ( bitcast_ln50_reg_1460 ); SC_METHOD(thread_tmp_12_fu_408_p4); sensitive << ( bitcast_ln50_1_reg_1465 ); SC_METHOD(thread_tmp_13_fu_650_p4); sensitive << ( bitcast_ln50_2_fu_647_p1 ); SC_METHOD(thread_tmp_15_fu_445_p4); sensitive << ( bitcast_ln51_reg_1490 ); SC_METHOD(thread_tmp_16_fu_454_p4); sensitive << ( bitcast_ln51_1_reg_1495 ); SC_METHOD(thread_tmp_17_fu_679_p4); sensitive << ( bitcast_ln51_2_fu_676_p1 ); SC_METHOD(thread_tmp_18_fu_697_p4); sensitive << ( bitcast_ln51_3_fu_693_p1 ); SC_METHOD(thread_tmp_1_fu_362_p4); sensitive << ( bitcast_ln49_1_reg_1435 ); SC_METHOD(thread_tmp_20_fu_744_p4); sensitive << ( bitcast_ln51_4_fu_741_p1 ); SC_METHOD(thread_tmp_22_fu_773_p4); sensitive << ( bitcast_ln51_5_fu_770_p1 ); SC_METHOD(thread_tmp_24_fu_1089_p4); sensitive << ( r_V_1_fu_1071_p2 ); SC_METHOD(thread_tmp_25_fu_1214_p4); sensitive << ( r_V_3_fu_1196_p2 ); SC_METHOD(thread_tmp_26_fu_1305_p3); sensitive << ( add_ln82_2_fu_1299_p2 ); SC_METHOD(thread_tmp_27_fu_1077_p3); sensitive << ( r_V_fu_1065_p2 ); SC_METHOD(thread_tmp_31_fu_1202_p3); sensitive << ( r_V_2_fu_1190_p2 ); SC_METHOD(thread_tmp_3_fu_568_p4); sensitive << ( bitcast_ln49_2_fu_565_p1 ); SC_METHOD(thread_tmp_9_fu_621_p4); sensitive << ( bitcast_ln49_4_fu_618_p1 ); SC_METHOD(thread_tmp_V_1_fu_596_p1); sensitive << ( p_Val2_1_fu_582_p1 ); SC_METHOD(thread_tmp_V_2_fu_881_p4); sensitive << ( p_Val2_s_fu_877_p1 ); SC_METHOD(thread_tmp_V_3_fu_891_p1); sensitive << ( p_Val2_s_fu_877_p1 ); SC_METHOD(thread_tmp_V_fu_586_p4); sensitive << ( p_Val2_1_fu_582_p1 ); SC_METHOD(thread_tmp_fu_353_p4); sensitive << ( bitcast_ln49_reg_1430 ); SC_METHOD(thread_trunc_ln49_1_fu_268_p1); sensitive << ( bitcast_ln49_1_fu_265_p1 ); SC_METHOD(thread_trunc_ln49_2_fu_578_p1); sensitive << ( bitcast_ln49_2_fu_565_p1 ); SC_METHOD(thread_trunc_ln49_4_fu_631_p1); sensitive << ( bitcast_ln49_4_fu_618_p1 ); SC_METHOD(thread_trunc_ln49_fu_261_p1); sensitive << ( bitcast_ln49_fu_258_p1 ); SC_METHOD(thread_trunc_ln50_1_fu_294_p1); sensitive << ( bitcast_ln50_1_fu_291_p1 ); SC_METHOD(thread_trunc_ln50_2_fu_660_p1); sensitive << ( bitcast_ln50_2_fu_647_p1 ); SC_METHOD(thread_trunc_ln50_fu_287_p1); sensitive << ( bitcast_ln50_fu_284_p1 ); SC_METHOD(thread_trunc_ln51_1_fu_320_p1); sensitive << ( bitcast_ln51_1_fu_317_p1 ); SC_METHOD(thread_trunc_ln51_2_fu_689_p1); sensitive << ( bitcast_ln51_2_fu_676_p1 ); SC_METHOD(thread_trunc_ln51_3_fu_707_p1); sensitive << ( bitcast_ln51_3_fu_693_p1 ); SC_METHOD(thread_trunc_ln51_4_fu_754_p1); sensitive << ( bitcast_ln51_4_fu_741_p1 ); SC_METHOD(thread_trunc_ln51_5_fu_783_p1); sensitive << ( bitcast_ln51_5_fu_770_p1 ); SC_METHOD(thread_trunc_ln51_fu_313_p1); sensitive << ( bitcast_ln51_fu_310_p1 ); SC_METHOD(thread_trunc_ln82_1_fu_1242_p1); sensitive << ( select_ln1312_fu_1224_p3 ); SC_METHOD(thread_trunc_ln82_2_fu_1268_p1); sensitive << ( k_assign_reg_136 ); SC_METHOD(thread_trunc_ln82_fu_1232_p1); sensitive << ( select_ln1312_fu_1224_p3 ); SC_METHOD(thread_ush_1_fu_1170_p3); sensitive << ( add_ln339_1_fu_1146_p2 ); sensitive << ( isNeg_1_fu_1152_p3 ); sensitive << ( sext_ln1311_2_fu_1166_p1 ); SC_METHOD(thread_ush_fu_827_p3); sensitive << ( isNeg_fu_809_p3 ); sensitive << ( add_ln339_fu_803_p2 ); sensitive << ( sext_ln1311_fu_823_p1 ); SC_METHOD(thread_xor_ln22_fu_495_p2); sensitive << ( bitcast_ln22_fu_491_p1 ); SC_METHOD(thread_xor_ln49_fu_956_p2); sensitive << ( and_ln49_7_fu_950_p2 ); SC_METHOD(thread_xor_ln50_fu_929_p2); sensitive << ( and_ln50_3_fu_923_p2 ); SC_METHOD(thread_zext_ln1287_1_fu_1186_p1); sensitive << ( sext_ln1311_3_fu_1178_p1 ); SC_METHOD(thread_zext_ln1287_fu_1061_p1); sensitive << ( sext_ln1311_1_fu_1055_p1 ); SC_METHOD(thread_zext_ln339_1_fu_1142_p1); sensitive << ( tmp_V_2_fu_881_p4 ); SC_METHOD(thread_zext_ln339_fu_799_p1); sensitive << ( tmp_V_fu_586_p4 ); SC_METHOD(thread_zext_ln662_1_fu_1210_p1); sensitive << ( tmp_31_fu_1202_p3 ); SC_METHOD(thread_zext_ln662_fu_1085_p1); sensitive << ( tmp_27_fu_1077_p3 ); SC_METHOD(thread_zext_ln682_1_fu_1138_p1); sensitive << ( mantissa_V_1_fu_1128_p4 ); SC_METHOD(thread_zext_ln682_fu_1051_p1); sensitive << ( mantissa_V_fu_1042_p4 ); SC_METHOD(thread_zext_ln82_fu_1280_p1); sensitive << ( shl_ln82_1_fu_1272_p3 ); SC_METHOD(thread_zext_ln97_fu_1289_p1); sensitive << ( add_ln82_1_fu_1284_p2 ); SC_METHOD(thread_zext_ln98_fu_1322_p1); sensitive << ( add_ln82_3_fu_1317_p2 ); SC_METHOD(thread_ap_NS_fsm); sensitive << ( ap_start ); sensitive << ( ap_CS_fsm ); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( icmp_ln92_fu_341_p2 ); SC_THREAD(thread_ap_var_for_const0); ap_CS_fsm = "00000000000000000000000000000000000000000000000000000001"; ap_return_preg = "0000000000000000000000000000000000000000000000000000000000000000"; static int apTFileNum = 0; stringstream apTFilenSS; apTFilenSS << "checkAxis_2_sc_trace_" << apTFileNum ++; string apTFn = apTFilenSS.str(); mVcdFile = sc_create_vcd_trace_file(apTFn.c_str()); mVcdFile->set_time_unit(1, SC_PS); if (1) { #ifdef __HLS_TRACE_LEVEL_PORT_HIER__ sc_trace(mVcdFile, ap_clk, "(port)ap_clk"); sc_trace(mVcdFile, ap_rst, "(port)ap_rst"); sc_trace(mVcdFile, ap_start, "(port)ap_start"); sc_trace(mVcdFile, ap_done, "(port)ap_done"); sc_trace(mVcdFile, ap_idle, "(port)ap_idle"); sc_trace(mVcdFile, ap_ready, "(port)ap_ready"); sc_trace(mVcdFile, edge_p1_x, "(port)edge_p1_x"); sc_trace(mVcdFile, edge_p1_y, "(port)edge_p1_y"); sc_trace(mVcdFile, edge_p1_z, "(port)edge_p1_z"); sc_trace(mVcdFile, edge_p2_x, "(port)edge_p2_x"); sc_trace(mVcdFile, edge_p2_y, "(port)edge_p2_y"); sc_trace(mVcdFile, edge_p2_z, "(port)edge_p2_z"); sc_trace(mVcdFile, ap_return, "(port)ap_return"); #endif #ifdef __HLS_TRACE_LEVEL_INT__ sc_trace(mVcdFile, ap_CS_fsm, "ap_CS_fsm"); sc_trace(mVcdFile, ap_CS_fsm_state1, "ap_CS_fsm_state1"); sc_trace(mVcdFile, grp_fu_148_p2, "grp_fu_148_p2"); sc_trace(mVcdFile, reg_210, "reg_210"); sc_trace(mVcdFile, ap_CS_fsm_state12, "ap_CS_fsm_state12"); sc_trace(mVcdFile, ap_CS_fsm_state19, "ap_CS_fsm_state19"); sc_trace(mVcdFile, ap_CS_fsm_state26, "ap_CS_fsm_state26"); sc_trace(mVcdFile, ap_CS_fsm_state30, "ap_CS_fsm_state30"); sc_trace(mVcdFile, ap_CS_fsm_state34, "ap_CS_fsm_state34"); sc_trace(mVcdFile, ap_CS_fsm_state53, "ap_CS_fsm_state53"); sc_trace(mVcdFile, grp_fu_166_p2, "grp_fu_166_p2"); sc_trace(mVcdFile, reg_223, "reg_223"); sc_trace(mVcdFile, ap_CS_fsm_state15, "ap_CS_fsm_state15"); sc_trace(mVcdFile, ap_CS_fsm_state22, "ap_CS_fsm_state22"); sc_trace(mVcdFile, ap_CS_fsm_state49, "ap_CS_fsm_state49"); sc_trace(mVcdFile, grp_fu_171_p2, "grp_fu_171_p2"); sc_trace(mVcdFile, reg_230, "reg_230"); sc_trace(mVcdFile, grp_fu_175_p2, "grp_fu_175_p2"); sc_trace(mVcdFile, reg_236, "reg_236"); sc_trace(mVcdFile, grp_fu_154_p2, "grp_fu_154_p2"); sc_trace(mVcdFile, reg_242, "reg_242"); sc_trace(mVcdFile, grp_fu_160_p2, "grp_fu_160_p2"); sc_trace(mVcdFile, reg_251, "reg_251"); sc_trace(mVcdFile, tmp_19_i_i_reg_1414, "tmp_19_i_i_reg_1414"); sc_trace(mVcdFile, ap_CS_fsm_state4, "ap_CS_fsm_state4"); sc_trace(mVcdFile, tmp_21_i_i_reg_1419, "tmp_21_i_i_reg_1419"); sc_trace(mVcdFile, tmp_24_i_i_reg_1424, "tmp_24_i_i_reg_1424"); sc_trace(mVcdFile, bitcast_ln49_fu_258_p1, "bitcast_ln49_fu_258_p1"); sc_trace(mVcdFile, bitcast_ln49_reg_1430, "bitcast_ln49_reg_1430"); sc_trace(mVcdFile, bitcast_ln49_1_fu_265_p1, "bitcast_ln49_1_fu_265_p1"); sc_trace(mVcdFile, bitcast_ln49_1_reg_1435, "bitcast_ln49_1_reg_1435"); sc_trace(mVcdFile, icmp_ln49_1_fu_272_p2, "icmp_ln49_1_fu_272_p2"); sc_trace(mVcdFile, icmp_ln49_1_reg_1440, "icmp_ln49_1_reg_1440"); sc_trace(mVcdFile, icmp_ln49_3_fu_278_p2, "icmp_ln49_3_fu_278_p2"); sc_trace(mVcdFile, icmp_ln49_3_reg_1445, "icmp_ln49_3_reg_1445"); sc_trace(mVcdFile, grp_fu_186_p2, "grp_fu_186_p2"); sc_trace(mVcdFile, tmp_2_reg_1450, "tmp_2_reg_1450"); sc_trace(mVcdFile, grp_fu_190_p2, "grp_fu_190_p2"); sc_trace(mVcdFile, tmp_8_reg_1455, "tmp_8_reg_1455"); sc_trace(mVcdFile, bitcast_ln50_fu_284_p1, "bitcast_ln50_fu_284_p1"); sc_trace(mVcdFile, bitcast_ln50_reg_1460, "bitcast_ln50_reg_1460"); sc_trace(mVcdFile, bitcast_ln50_1_fu_291_p1, "bitcast_ln50_1_fu_291_p1"); sc_trace(mVcdFile, bitcast_ln50_1_reg_1465, "bitcast_ln50_1_reg_1465"); sc_trace(mVcdFile, icmp_ln50_1_fu_298_p2, "icmp_ln50_1_fu_298_p2"); sc_trace(mVcdFile, icmp_ln50_1_reg_1470, "icmp_ln50_1_reg_1470"); sc_trace(mVcdFile, icmp_ln50_3_fu_304_p2, "icmp_ln50_3_fu_304_p2"); sc_trace(mVcdFile, icmp_ln50_3_reg_1475, "icmp_ln50_3_reg_1475"); sc_trace(mVcdFile, grp_fu_194_p2, "grp_fu_194_p2"); sc_trace(mVcdFile, tmp_s_reg_1480, "tmp_s_reg_1480"); sc_trace(mVcdFile, grp_fu_198_p2, "grp_fu_198_p2"); sc_trace(mVcdFile, tmp_6_reg_1485, "tmp_6_reg_1485"); sc_trace(mVcdFile, bitcast_ln51_fu_310_p1, "bitcast_ln51_fu_310_p1"); sc_trace(mVcdFile, bitcast_ln51_reg_1490, "bitcast_ln51_reg_1490"); sc_trace(mVcdFile, bitcast_ln51_1_fu_317_p1, "bitcast_ln51_1_fu_317_p1"); sc_trace(mVcdFile, bitcast_ln51_1_reg_1495, "bitcast_ln51_1_reg_1495"); sc_trace(mVcdFile, icmp_ln51_1_fu_324_p2, "icmp_ln51_1_fu_324_p2"); sc_trace(mVcdFile, icmp_ln51_1_reg_1500, "icmp_ln51_1_reg_1500"); sc_trace(mVcdFile, icmp_ln51_3_fu_330_p2, "icmp_ln51_3_fu_330_p2"); sc_trace(mVcdFile, icmp_ln51_3_reg_1505, "icmp_ln51_3_reg_1505"); sc_trace(mVcdFile, grp_fu_202_p2, "grp_fu_202_p2"); sc_trace(mVcdFile, tmp_7_reg_1510, "tmp_7_reg_1510"); sc_trace(mVcdFile, grp_fu_206_p2, "grp_fu_206_p2"); sc_trace(mVcdFile, tmp_4_reg_1515, "tmp_4_reg_1515"); sc_trace(mVcdFile, ap_CS_fsm_state5, "ap_CS_fsm_state5"); sc_trace(mVcdFile, i_fu_347_p2, "i_fu_347_p2"); sc_trace(mVcdFile, i_reg_1528, "i_reg_1528"); sc_trace(mVcdFile, and_ln49_fu_393_p2, "and_ln49_fu_393_p2"); sc_trace(mVcdFile, and_ln49_reg_1533, "and_ln49_reg_1533"); sc_trace(mVcdFile, icmp_ln92_fu_341_p2, "icmp_ln92_fu_341_p2"); sc_trace(mVcdFile, and_ln50_fu_439_p2, "and_ln50_fu_439_p2"); sc_trace(mVcdFile, and_ln50_reg_1539, "and_ln50_reg_1539"); sc_trace(mVcdFile, and_ln51_fu_485_p2, "and_ln51_fu_485_p2"); sc_trace(mVcdFile, and_ln51_reg_1545, "and_ln51_reg_1545"); sc_trace(mVcdFile, grp_fu_183_p1, "grp_fu_183_p1"); sc_trace(mVcdFile, R_z_reg_1551, "R_z_reg_1551"); sc_trace(mVcdFile, ap_CS_fsm_state8, "ap_CS_fsm_state8"); sc_trace(mVcdFile, xor_ln22_fu_495_p2, "xor_ln22_fu_495_p2"); sc_trace(mVcdFile, xor_ln22_reg_1557, "xor_ln22_reg_1557"); sc_trace(mVcdFile, bitcast_ln22_1_fu_501_p1, "bitcast_ln22_1_fu_501_p1"); sc_trace(mVcdFile, ap_CS_fsm_state16, "ap_CS_fsm_state16"); sc_trace(mVcdFile, grp_fu_179_p2, "grp_fu_179_p2"); sc_trace(mVcdFile, T_reg_1567, "T_reg_1567"); sc_trace(mVcdFile, ap_CS_fsm_state46, "ap_CS_fsm_state46"); sc_trace(mVcdFile, p_a_fu_509_p3, "p_a_fu_509_p3"); sc_trace(mVcdFile, p_a_reg_1574, "p_a_reg_1574"); sc_trace(mVcdFile, ap_CS_fsm_state50, "ap_CS_fsm_state50"); sc_trace(mVcdFile, p_a_1_fu_519_p3, "p_a_1_fu_519_p3"); sc_trace(mVcdFile, p_a_1_reg_1580, "p_a_1_reg_1580"); sc_trace(mVcdFile, p_a_2_fu_529_p3, "p_a_2_fu_529_p3"); sc_trace(mVcdFile, p_a_2_reg_1586, "p_a_2_reg_1586"); sc_trace(mVcdFile, p_a_3_fu_539_p3, "p_a_3_fu_539_p3"); sc_trace(mVcdFile, p_a_3_reg_1592, "p_a_3_reg_1592"); sc_trace(mVcdFile, p_a_4_fu_549_p3, "p_a_4_fu_549_p3"); sc_trace(mVcdFile, p_a_4_reg_1598, "p_a_4_reg_1598"); sc_trace(mVcdFile, p_a_5_fu_559_p3, "p_a_5_fu_559_p3"); sc_trace(mVcdFile, p_a_5_reg_1604, "p_a_5_reg_1604"); sc_trace(mVcdFile, p_Val2_1_fu_582_p1, "p_Val2_1_fu_582_p1"); sc_trace(mVcdFile, p_Val2_1_reg_1610, "p_Val2_1_reg_1610"); sc_trace(mVcdFile, ap_CS_fsm_state54, "ap_CS_fsm_state54"); sc_trace(mVcdFile, tmp_V_1_fu_596_p1, "tmp_V_1_fu_596_p1"); sc_trace(mVcdFile, tmp_V_1_reg_1615, "tmp_V_1_reg_1615"); sc_trace(mVcdFile, icmp_ln49_4_fu_600_p2, "icmp_ln49_4_fu_600_p2"); sc_trace(mVcdFile, icmp_ln49_4_reg_1621, "icmp_ln49_4_reg_1621"); sc_trace(mVcdFile, icmp_ln49_5_fu_606_p2, "icmp_ln49_5_fu_606_p2"); sc_trace(mVcdFile, icmp_ln49_5_reg_1626, "icmp_ln49_5_reg_1626"); sc_trace(mVcdFile, icmp_ln49_6_fu_612_p2, "icmp_ln49_6_fu_612_p2"); sc_trace(mVcdFile, icmp_ln49_6_reg_1631, "icmp_ln49_6_reg_1631"); sc_trace(mVcdFile, icmp_ln49_8_fu_635_p2, "icmp_ln49_8_fu_635_p2"); sc_trace(mVcdFile, icmp_ln49_8_reg_1636, "icmp_ln49_8_reg_1636"); sc_trace(mVcdFile, icmp_ln49_9_fu_641_p2, "icmp_ln49_9_fu_641_p2"); sc_trace(mVcdFile, icmp_ln49_9_reg_1641, "icmp_ln49_9_reg_1641"); sc_trace(mVcdFile, icmp_ln50_4_fu_664_p2, "icmp_ln50_4_fu_664_p2"); sc_trace(mVcdFile, icmp_ln50_4_reg_1646, "icmp_ln50_4_reg_1646"); sc_trace(mVcdFile, icmp_ln50_5_fu_670_p2, "icmp_ln50_5_fu_670_p2"); sc_trace(mVcdFile, icmp_ln50_5_reg_1651, "icmp_ln50_5_reg_1651"); sc_trace(mVcdFile, icmp_ln51_4_fu_711_p2, "icmp_ln51_4_fu_711_p2"); sc_trace(mVcdFile, icmp_ln51_4_reg_1656, "icmp_ln51_4_reg_1656"); sc_trace(mVcdFile, icmp_ln51_5_fu_717_p2, "icmp_ln51_5_fu_717_p2"); sc_trace(mVcdFile, icmp_ln51_5_reg_1661, "icmp_ln51_5_reg_1661"); sc_trace(mVcdFile, or_ln51_3_fu_735_p2, "or_ln51_3_fu_735_p2"); sc_trace(mVcdFile, or_ln51_3_reg_1666, "or_ln51_3_reg_1666"); sc_trace(mVcdFile, icmp_ln51_8_fu_758_p2, "icmp_ln51_8_fu_758_p2"); sc_trace(mVcdFile, icmp_ln51_8_reg_1672, "icmp_ln51_8_reg_1672"); sc_trace(mVcdFile, icmp_ln51_9_fu_764_p2, "icmp_ln51_9_fu_764_p2"); sc_trace(mVcdFile, icmp_ln51_9_reg_1677, "icmp_ln51_9_reg_1677"); sc_trace(mVcdFile, icmp_ln51_10_fu_787_p2, "icmp_ln51_10_fu_787_p2"); sc_trace(mVcdFile, icmp_ln51_10_reg_1682, "icmp_ln51_10_reg_1682"); sc_trace(mVcdFile, icmp_ln51_11_fu_793_p2, "icmp_ln51_11_fu_793_p2"); sc_trace(mVcdFile, icmp_ln51_11_reg_1687, "icmp_ln51_11_reg_1687"); sc_trace(mVcdFile, isNeg_fu_809_p3, "isNeg_fu_809_p3"); sc_trace(mVcdFile, isNeg_reg_1692, "isNeg_reg_1692"); sc_trace(mVcdFile, ush_fu_827_p3, "ush_fu_827_p3"); sc_trace(mVcdFile, ush_reg_1697, "ush_reg_1697"); sc_trace(mVcdFile, and_ln51_12_fu_1029_p2, "and_ln51_12_fu_1029_p2"); sc_trace(mVcdFile, and_ln51_12_reg_1703, "and_ln51_12_reg_1703"); sc_trace(mVcdFile, ap_CS_fsm_state55, "ap_CS_fsm_state55"); sc_trace(mVcdFile, add_ln82_fu_1262_p2, "add_ln82_fu_1262_p2"); sc_trace(mVcdFile, add_ln82_reg_1708, "add_ln82_reg_1708"); sc_trace(mVcdFile, collisions_1_fu_1344_p3, "collisions_1_fu_1344_p3"); sc_trace(mVcdFile, ap_CS_fsm_state56, "ap_CS_fsm_state56"); sc_trace(mVcdFile, collisions_0_reg_124, "collisions_0_reg_124"); sc_trace(mVcdFile, k_assign_reg_136, "k_assign_reg_136"); sc_trace(mVcdFile, grp_fu_148_p0, "grp_fu_148_p0"); sc_trace(mVcdFile, grp_fu_148_p1, "grp_fu_148_p1"); sc_trace(mVcdFile, ap_CS_fsm_state9, "ap_CS_fsm_state9"); sc_trace(mVcdFile, ap_CS_fsm_state23, "ap_CS_fsm_state23"); sc_trace(mVcdFile, ap_CS_fsm_state27, "ap_CS_fsm_state27"); sc_trace(mVcdFile, ap_CS_fsm_state31, "ap_CS_fsm_state31"); sc_trace(mVcdFile, grp_fu_154_p0, "grp_fu_154_p0"); sc_trace(mVcdFile, grp_fu_154_p1, "grp_fu_154_p1"); sc_trace(mVcdFile, grp_fu_160_p0, "grp_fu_160_p0"); sc_trace(mVcdFile, grp_fu_160_p1, "grp_fu_160_p1"); sc_trace(mVcdFile, grp_fu_166_p0, "grp_fu_166_p0"); sc_trace(mVcdFile, grp_fu_166_p1, "grp_fu_166_p1"); sc_trace(mVcdFile, ap_CS_fsm_state13, "ap_CS_fsm_state13"); sc_trace(mVcdFile, ap_CS_fsm_state20, "ap_CS_fsm_state20"); sc_trace(mVcdFile, ap_CS_fsm_state24, "ap_CS_fsm_state24"); sc_trace(mVcdFile, ap_CS_fsm_state47, "ap_CS_fsm_state47"); sc_trace(mVcdFile, grp_fu_171_p0, "grp_fu_171_p0"); sc_trace(mVcdFile, grp_fu_171_p1, "grp_fu_171_p1"); sc_trace(mVcdFile, grp_fu_175_p0, "grp_fu_175_p0"); sc_trace(mVcdFile, grp_fu_175_p1, "grp_fu_175_p1"); sc_trace(mVcdFile, ap_CS_fsm_state35, "ap_CS_fsm_state35"); sc_trace(mVcdFile, grp_fu_183_p0, "grp_fu_183_p0"); sc_trace(mVcdFile, grp_fu_186_p0, "grp_fu_186_p0"); sc_trace(mVcdFile, grp_fu_186_p1, "grp_fu_186_p1"); sc_trace(mVcdFile, ap_CS_fsm_state3, "ap_CS_fsm_state3"); sc_trace(mVcdFile, grp_fu_190_p0, "grp_fu_190_p0"); sc_trace(mVcdFile, grp_fu_190_p1, "grp_fu_190_p1"); sc_trace(mVcdFile, grp_fu_194_p0, "grp_fu_194_p0"); sc_trace(mVcdFile, grp_fu_194_p1, "grp_fu_194_p1"); sc_trace(mVcdFile, grp_fu_198_p0, "grp_fu_198_p0"); sc_trace(mVcdFile, grp_fu_198_p1, "grp_fu_198_p1"); sc_trace(mVcdFile, grp_fu_202_p0, "grp_fu_202_p0"); sc_trace(mVcdFile, grp_fu_202_p1, "grp_fu_202_p1"); sc_trace(mVcdFile, grp_fu_206_p0, "grp_fu_206_p0"); sc_trace(mVcdFile, grp_fu_206_p1, "grp_fu_206_p1"); sc_trace(mVcdFile, trunc_ln49_fu_261_p1, "trunc_ln49_fu_261_p1"); sc_trace(mVcdFile, trunc_ln49_1_fu_268_p1, "trunc_ln49_1_fu_268_p1"); sc_trace(mVcdFile, trunc_ln50_fu_287_p1, "trunc_ln50_fu_287_p1"); sc_trace(mVcdFile, trunc_ln50_1_fu_294_p1, "trunc_ln50_1_fu_294_p1"); sc_trace(mVcdFile, trunc_ln51_fu_313_p1, "trunc_ln51_fu_313_p1"); sc_trace(mVcdFile, trunc_ln51_1_fu_320_p1, "trunc_ln51_1_fu_320_p1"); sc_trace(mVcdFile, tmp_fu_353_p4, "tmp_fu_353_p4"); sc_trace(mVcdFile, icmp_ln49_fu_371_p2, "icmp_ln49_fu_371_p2"); sc_trace(mVcdFile, tmp_1_fu_362_p4, "tmp_1_fu_362_p4"); sc_trace(mVcdFile, icmp_ln49_2_fu_382_p2, "icmp_ln49_2_fu_382_p2"); sc_trace(mVcdFile, or_ln49_fu_377_p2, "or_ln49_fu_377_p2"); sc_trace(mVcdFile, or_ln49_1_fu_388_p2, "or_ln49_1_fu_388_p2"); sc_trace(mVcdFile, tmp_11_fu_399_p4, "tmp_11_fu_399_p4"); sc_trace(mVcdFile, icmp_ln50_fu_417_p2, "icmp_ln50_fu_417_p2"); sc_trace(mVcdFile, tmp_12_fu_408_p4, "tmp_12_fu_408_p4"); sc_trace(mVcdFile, icmp_ln50_2_fu_428_p2, "icmp_ln50_2_fu_428_p2"); sc_trace(mVcdFile, or_ln50_fu_423_p2, "or_ln50_fu_423_p2"); sc_trace(mVcdFile, or_ln50_1_fu_434_p2, "or_ln50_1_fu_434_p2"); sc_trace(mVcdFile, tmp_15_fu_445_p4, "tmp_15_fu_445_p4"); sc_trace(mVcdFile, icmp_ln51_fu_463_p2, "icmp_ln51_fu_463_p2"); sc_trace(mVcdFile, tmp_16_fu_454_p4, "tmp_16_fu_454_p4"); sc_trace(mVcdFile, icmp_ln51_2_fu_474_p2, "icmp_ln51_2_fu_474_p2"); sc_trace(mVcdFile, or_ln51_fu_469_p2, "or_ln51_fu_469_p2"); sc_trace(mVcdFile, or_ln51_1_fu_480_p2, "or_ln51_1_fu_480_p2"); sc_trace(mVcdFile, bitcast_ln22_fu_491_p1, "bitcast_ln22_fu_491_p1"); sc_trace(mVcdFile, and_ln49_1_fu_505_p2, "and_ln49_1_fu_505_p2"); sc_trace(mVcdFile, and_ln49_4_fu_515_p2, "and_ln49_4_fu_515_p2"); sc_trace(mVcdFile, and_ln50_1_fu_525_p2, "and_ln50_1_fu_525_p2"); sc_trace(mVcdFile, and_ln50_4_fu_535_p2, "and_ln50_4_fu_535_p2"); sc_trace(mVcdFile, and_ln51_1_fu_545_p2, "and_ln51_1_fu_545_p2"); sc_trace(mVcdFile, and_ln51_2_fu_555_p2, "and_ln51_2_fu_555_p2"); sc_trace(mVcdFile, bitcast_ln49_2_fu_565_p1, "bitcast_ln49_2_fu_565_p1"); sc_trace(mVcdFile, tmp_3_fu_568_p4, "tmp_3_fu_568_p4"); sc_trace(mVcdFile, trunc_ln49_2_fu_578_p1, "trunc_ln49_2_fu_578_p1"); sc_trace(mVcdFile, tmp_V_fu_586_p4, "tmp_V_fu_586_p4"); sc_trace(mVcdFile, bitcast_ln49_4_fu_618_p1, "bitcast_ln49_4_fu_618_p1"); sc_trace(mVcdFile, tmp_9_fu_621_p4, "tmp_9_fu_621_p4"); sc_trace(mVcdFile, trunc_ln49_4_fu_631_p1, "trunc_ln49_4_fu_631_p1"); sc_trace(mVcdFile, bitcast_ln50_2_fu_647_p1, "bitcast_ln50_2_fu_647_p1"); sc_trace(mVcdFile, tmp_13_fu_650_p4, "tmp_13_fu_650_p4"); sc_trace(mVcdFile, trunc_ln50_2_fu_660_p1, "trunc_ln50_2_fu_660_p1"); sc_trace(mVcdFile, bitcast_ln51_2_fu_676_p1, "bitcast_ln51_2_fu_676_p1"); sc_trace(mVcdFile, bitcast_ln51_3_fu_693_p1, "bitcast_ln51_3_fu_693_p1"); sc_trace(mVcdFile, tmp_17_fu_679_p4, "tmp_17_fu_679_p4"); sc_trace(mVcdFile, trunc_ln51_2_fu_689_p1, "trunc_ln51_2_fu_689_p1"); sc_trace(mVcdFile, tmp_18_fu_697_p4, "tmp_18_fu_697_p4"); sc_trace(mVcdFile, trunc_ln51_3_fu_707_p1, "trunc_ln51_3_fu_707_p1"); sc_trace(mVcdFile, icmp_ln51_7_fu_729_p2, "icmp_ln51_7_fu_729_p2"); sc_trace(mVcdFile, icmp_ln51_6_fu_723_p2, "icmp_ln51_6_fu_723_p2"); sc_trace(mVcdFile, bitcast_ln51_4_fu_741_p1, "bitcast_ln51_4_fu_741_p1"); sc_trace(mVcdFile, tmp_20_fu_744_p4, "tmp_20_fu_744_p4"); sc_trace(mVcdFile, trunc_ln51_4_fu_754_p1, "trunc_ln51_4_fu_754_p1"); sc_trace(mVcdFile, bitcast_ln51_5_fu_770_p1, "bitcast_ln51_5_fu_770_p1"); sc_trace(mVcdFile, tmp_22_fu_773_p4, "tmp_22_fu_773_p4"); sc_trace(mVcdFile, trunc_ln51_5_fu_783_p1, "trunc_ln51_5_fu_783_p1"); sc_trace(mVcdFile, zext_ln339_fu_799_p1, "zext_ln339_fu_799_p1"); sc_trace(mVcdFile, add_ln339_fu_803_p2, "add_ln339_fu_803_p2"); sc_trace(mVcdFile, sub_ln1311_fu_817_p2, "sub_ln1311_fu_817_p2"); sc_trace(mVcdFile, sext_ln1311_fu_823_p1, "sext_ln1311_fu_823_p1"); sc_trace(mVcdFile, icmp_ln49_7_fu_839_p2, "icmp_ln49_7_fu_839_p2"); sc_trace(mVcdFile, or_ln49_2_fu_835_p2, "or_ln49_2_fu_835_p2"); sc_trace(mVcdFile, or_ln49_3_fu_844_p2, "or_ln49_3_fu_844_p2"); sc_trace(mVcdFile, and_ln49_2_fu_849_p2, "and_ln49_2_fu_849_p2"); sc_trace(mVcdFile, or_ln49_4_fu_861_p2, "or_ln49_4_fu_861_p2"); sc_trace(mVcdFile, and_ln49_5_fu_865_p2, "and_ln49_5_fu_865_p2"); sc_trace(mVcdFile, p_Val2_s_fu_877_p1, "p_Val2_s_fu_877_p1"); sc_trace(mVcdFile, tmp_V_2_fu_881_p4, "tmp_V_2_fu_881_p4"); sc_trace(mVcdFile, tmp_V_3_fu_891_p1, "tmp_V_3_fu_891_p1"); sc_trace(mVcdFile, icmp_ln50_7_fu_905_p2, "icmp_ln50_7_fu_905_p2"); sc_trace(mVcdFile, icmp_ln50_6_fu_899_p2, "icmp_ln50_6_fu_899_p2"); sc_trace(mVcdFile, or_ln50_2_fu_895_p2, "or_ln50_2_fu_895_p2"); sc_trace(mVcdFile, or_ln50_3_fu_911_p2, "or_ln50_3_fu_911_p2"); sc_trace(mVcdFile, and_ln50_2_fu_917_p2, "and_ln50_2_fu_917_p2"); sc_trace(mVcdFile, and_ln50_3_fu_923_p2, "and_ln50_3_fu_923_p2"); sc_trace(mVcdFile, or_ln51_2_fu_935_p2, "or_ln51_2_fu_935_p2"); sc_trace(mVcdFile, and_ln51_3_fu_939_p2, "and_ln51_3_fu_939_p2"); sc_trace(mVcdFile, and_ln49_3_fu_855_p2, "and_ln49_3_fu_855_p2"); sc_trace(mVcdFile, and_ln49_6_fu_871_p2, "and_ln49_6_fu_871_p2"); sc_trace(mVcdFile, and_ln49_7_fu_950_p2, "and_ln49_7_fu_950_p2"); sc_trace(mVcdFile, xor_ln49_fu_956_p2, "xor_ln49_fu_956_p2"); sc_trace(mVcdFile, xor_ln50_fu_929_p2, "xor_ln50_fu_929_p2"); sc_trace(mVcdFile, or_ln51_4_fu_974_p2, "or_ln51_4_fu_974_p2"); sc_trace(mVcdFile, and_ln51_5_fu_978_p2, "and_ln51_5_fu_978_p2"); sc_trace(mVcdFile, and_ln51_4_fu_944_p2, "and_ln51_4_fu_944_p2"); sc_trace(mVcdFile, or_ln51_5_fu_995_p2, "or_ln51_5_fu_995_p2"); sc_trace(mVcdFile, and_ln51_8_fu_999_p2, "and_ln51_8_fu_999_p2"); sc_trace(mVcdFile, and_ln51_6_fu_983_p2, "and_ln51_6_fu_983_p2"); sc_trace(mVcdFile, and_ln51_9_fu_1005_p2, "and_ln51_9_fu_1005_p2"); sc_trace(mVcdFile, or_ln50_5_fu_968_p2, "or_ln50_5_fu_968_p2"); sc_trace(mVcdFile, and_ln51_10_fu_1011_p2, "and_ln51_10_fu_1011_p2"); sc_trace(mVcdFile, or_ln51_6_fu_1017_p2, "or_ln51_6_fu_1017_p2"); sc_trace(mVcdFile, or_ln50_4_fu_962_p2, "or_ln50_4_fu_962_p2"); sc_trace(mVcdFile, and_ln51_11_fu_1023_p2, "and_ln51_11_fu_1023_p2"); sc_trace(mVcdFile, and_ln51_7_fu_989_p2, "and_ln51_7_fu_989_p2"); sc_trace(mVcdFile, mantissa_V_fu_1042_p4, "mantissa_V_fu_1042_p4"); sc_trace(mVcdFile, sext_ln1311_1_fu_1055_p1, "sext_ln1311_1_fu_1055_p1"); sc_trace(mVcdFile, sext_ln1311_4_fu_1058_p1, "sext_ln1311_4_fu_1058_p1"); sc_trace(mVcdFile, zext_ln682_fu_1051_p1, "zext_ln682_fu_1051_p1"); sc_trace(mVcdFile, zext_ln1287_fu_1061_p1, "zext_ln1287_fu_1061_p1"); sc_trace(mVcdFile, r_V_fu_1065_p2, "r_V_fu_1065_p2"); sc_trace(mVcdFile, tmp_27_fu_1077_p3, "tmp_27_fu_1077_p3"); sc_trace(mVcdFile, r_V_1_fu_1071_p2, "r_V_1_fu_1071_p2"); sc_trace(mVcdFile, zext_ln662_fu_1085_p1, "zext_ln662_fu_1085_p1"); sc_trace(mVcdFile, tmp_24_fu_1089_p4, "tmp_24_fu_1089_p4"); sc_trace(mVcdFile, p_Val2_4_fu_1099_p3, "p_Val2_4_fu_1099_p3"); sc_trace(mVcdFile, p_Result_s_fu_1035_p3, "p_Result_s_fu_1035_p3"); sc_trace(mVcdFile, result_V_1_fu_1106_p2, "result_V_1_fu_1106_p2"); sc_trace(mVcdFile, mantissa_V_1_fu_1128_p4, "mantissa_V_1_fu_1128_p4"); sc_trace(mVcdFile, zext_ln339_1_fu_1142_p1, "zext_ln339_1_fu_1142_p1"); sc_trace(mVcdFile, add_ln339_1_fu_1146_p2, "add_ln339_1_fu_1146_p2"); sc_trace(mVcdFile, sub_ln1311_1_fu_1160_p2, "sub_ln1311_1_fu_1160_p2"); sc_trace(mVcdFile, isNeg_1_fu_1152_p3, "isNeg_1_fu_1152_p3"); sc_trace(mVcdFile, sext_ln1311_2_fu_1166_p1, "sext_ln1311_2_fu_1166_p1"); sc_trace(mVcdFile, ush_1_fu_1170_p3, "ush_1_fu_1170_p3"); sc_trace(mVcdFile, sext_ln1311_3_fu_1178_p1, "sext_ln1311_3_fu_1178_p1"); sc_trace(mVcdFile, sext_ln1311_5_fu_1182_p1, "sext_ln1311_5_fu_1182_p1"); sc_trace(mVcdFile, zext_ln682_1_fu_1138_p1, "zext_ln682_1_fu_1138_p1"); sc_trace(mVcdFile, zext_ln1287_1_fu_1186_p1, "zext_ln1287_1_fu_1186_p1"); sc_trace(mVcdFile, r_V_2_fu_1190_p2, "r_V_2_fu_1190_p2"); sc_trace(mVcdFile, tmp_31_fu_1202_p3, "tmp_31_fu_1202_p3"); sc_trace(mVcdFile, r_V_3_fu_1196_p2, "r_V_3_fu_1196_p2"); sc_trace(mVcdFile, zext_ln662_1_fu_1210_p1, "zext_ln662_1_fu_1210_p1"); sc_trace(mVcdFile, tmp_25_fu_1214_p4, "tmp_25_fu_1214_p4"); sc_trace(mVcdFile, select_ln1312_fu_1224_p3, "select_ln1312_fu_1224_p3"); sc_trace(mVcdFile, trunc_ln82_fu_1232_p1, "trunc_ln82_fu_1232_p1"); sc_trace(mVcdFile, p_Result_1_fu_1120_p3, "p_Result_1_fu_1120_p3"); sc_trace(mVcdFile, sub_ln82_fu_1236_p2, "sub_ln82_fu_1236_p2"); sc_trace(mVcdFile, trunc_ln82_1_fu_1242_p1, "trunc_ln82_1_fu_1242_p1"); sc_trace(mVcdFile, select_ln59_fu_1246_p3, "select_ln59_fu_1246_p3"); sc_trace(mVcdFile, shl_ln_fu_1254_p3, "shl_ln_fu_1254_p3"); sc_trace(mVcdFile, p_Val2_5_fu_1112_p3, "p_Val2_5_fu_1112_p3"); sc_trace(mVcdFile, trunc_ln82_2_fu_1268_p1, "trunc_ln82_2_fu_1268_p1"); sc_trace(mVcdFile, shl_ln82_1_fu_1272_p3, "shl_ln82_1_fu_1272_p3"); sc_trace(mVcdFile, zext_ln82_fu_1280_p1, "zext_ln82_fu_1280_p1"); sc_trace(mVcdFile, add_ln82_1_fu_1284_p2, "add_ln82_1_fu_1284_p2"); sc_trace(mVcdFile, zext_ln97_fu_1289_p1, "zext_ln97_fu_1289_p1"); sc_trace(mVcdFile, add_ln82_2_fu_1299_p2, "add_ln82_2_fu_1299_p2"); sc_trace(mVcdFile, tmp_26_fu_1305_p3, "tmp_26_fu_1305_p3"); sc_trace(mVcdFile, sext_ln82_fu_1313_p1, "sext_ln82_fu_1313_p1"); sc_trace(mVcdFile, add_ln82_3_fu_1317_p2, "add_ln82_3_fu_1317_p2"); sc_trace(mVcdFile, zext_ln98_fu_1322_p1, "zext_ln98_fu_1322_p1"); sc_trace(mVcdFile, shl_ln98_fu_1326_p2, "shl_ln98_fu_1326_p2"); sc_trace(mVcdFile, or_ln98_fu_1332_p2, "or_ln98_fu_1332_p2"); sc_trace(mVcdFile, shl_ln97_fu_1293_p2, "shl_ln97_fu_1293_p2"); sc_trace(mVcdFile, collisions_fu_1338_p2, "collisions_fu_1338_p2"); sc_trace(mVcdFile, grp_fu_148_opcode, "grp_fu_148_opcode"); sc_trace(mVcdFile, grp_fu_154_opcode, "grp_fu_154_opcode"); sc_trace(mVcdFile, grp_fu_160_opcode, "grp_fu_160_opcode"); sc_trace(mVcdFile, grp_fu_186_opcode, "grp_fu_186_opcode"); sc_trace(mVcdFile, grp_fu_190_opcode, "grp_fu_190_opcode"); sc_trace(mVcdFile, grp_fu_194_opcode, "grp_fu_194_opcode"); sc_trace(mVcdFile, grp_fu_198_opcode, "grp_fu_198_opcode"); sc_trace(mVcdFile, grp_fu_202_opcode, "grp_fu_202_opcode"); sc_trace(mVcdFile, grp_fu_206_opcode, "grp_fu_206_opcode"); sc_trace(mVcdFile, ap_return_preg, "ap_return_preg"); sc_trace(mVcdFile, ap_NS_fsm, "ap_NS_fsm"); #endif } } checkAxis_2::~checkAxis_2() { if (mVcdFile) sc_close_vcd_trace_file(mVcdFile); delete honeybee_faddfsubbkb_U1; delete honeybee_faddfsubbkb_U2; delete honeybee_faddfsubbkb_U3; delete honeybee_fmul_32ncud_U4; delete honeybee_fmul_32ncud_U5; delete honeybee_fmul_32ncud_U6; delete honeybee_fdiv_32ndEe_U7; delete honeybee_sitofp_3eOg_U8; delete honeybee_fcmp_32nfYi_U9; delete honeybee_fcmp_32nfYi_U10; delete honeybee_fcmp_32nfYi_U11; delete honeybee_fcmp_32nfYi_U12; delete honeybee_fcmp_32nfYi_U13; delete honeybee_fcmp_32nfYi_U14; } void checkAxis_2::thread_ap_var_for_const0() { ap_var_for_const0 = ap_const_logic_1; } void checkAxis_2::thread_ap_clk_no_reset_() { if ( ap_rst.read() == ap_const_logic_1) { ap_CS_fsm = ap_ST_fsm_state1; } else { ap_CS_fsm = ap_NS_fsm.read(); } if ( ap_rst.read() == ap_const_logic_1) { ap_return_preg = ap_const_lv64_0; } else { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_ln92_fu_341_p2.read(), ap_const_lv1_1))) { ap_return_preg = collisions_0_reg_124.read(); } } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state56.read())) { collisions_0_reg_124 = collisions_1_fu_1344_p3.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state4.read())) { collisions_0_reg_124 = ap_const_lv64_0; } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state56.read())) { k_assign_reg_136 = i_reg_1528.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state4.read())) { k_assign_reg_136 = ap_const_lv3_0; } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { R_z_reg_1551 = grp_fu_183_p1.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state46.read())) { T_reg_1567 = grp_fu_179_p2.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state55.read())) { add_ln82_reg_1708 = add_ln82_fu_1262_p2.read(); and_ln51_12_reg_1703 = and_ln51_12_fu_1029_p2.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_ln92_fu_341_p2.read(), ap_const_lv1_0))) { and_ln49_reg_1533 = and_ln49_fu_393_p2.read(); and_ln50_reg_1539 = and_ln50_fu_439_p2.read(); and_ln51_reg_1545 = and_ln51_fu_485_p2.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state4.read())) { bitcast_ln49_1_reg_1435 = bitcast_ln49_1_fu_265_p1.read(); bitcast_ln49_reg_1430 = bitcast_ln49_fu_258_p1.read(); bitcast_ln50_1_reg_1465 = bitcast_ln50_1_fu_291_p1.read(); bitcast_ln50_reg_1460 = bitcast_ln50_fu_284_p1.read(); bitcast_ln51_1_reg_1495 = bitcast_ln51_1_fu_317_p1.read(); bitcast_ln51_reg_1490 = bitcast_ln51_fu_310_p1.read(); icmp_ln49_1_reg_1440 = icmp_ln49_1_fu_272_p2.read(); icmp_ln49_3_reg_1445 = icmp_ln49_3_fu_278_p2.read(); icmp_ln50_1_reg_1470 = icmp_ln50_1_fu_298_p2.read(); icmp_ln50_3_reg_1475 = icmp_ln50_3_fu_304_p2.read(); icmp_ln51_1_reg_1500 = icmp_ln51_1_fu_324_p2.read(); icmp_ln51_3_reg_1505 = icmp_ln51_3_fu_330_p2.read(); tmp_19_i_i_reg_1414 = grp_fu_148_p2.read(); tmp_21_i_i_reg_1419 = grp_fu_154_p2.read(); tmp_24_i_i_reg_1424 = grp_fu_160_p2.read(); tmp_2_reg_1450 = grp_fu_186_p2.read(); tmp_4_reg_1515 = grp_fu_206_p2.read(); tmp_6_reg_1485 = grp_fu_198_p2.read(); tmp_7_reg_1510 = grp_fu_202_p2.read(); tmp_8_reg_1455 = grp_fu_190_p2.read(); tmp_s_reg_1480 = grp_fu_194_p2.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { i_reg_1528 = i_fu_347_p2.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { icmp_ln49_4_reg_1621 = icmp_ln49_4_fu_600_p2.read(); icmp_ln49_5_reg_1626 = icmp_ln49_5_fu_606_p2.read(); icmp_ln49_6_reg_1631 = icmp_ln49_6_fu_612_p2.read(); icmp_ln49_8_reg_1636 = icmp_ln49_8_fu_635_p2.read(); icmp_ln49_9_reg_1641 = icmp_ln49_9_fu_641_p2.read(); icmp_ln50_4_reg_1646 = icmp_ln50_4_fu_664_p2.read(); icmp_ln50_5_reg_1651 = icmp_ln50_5_fu_670_p2.read(); icmp_ln51_10_reg_1682 = icmp_ln51_10_fu_787_p2.read(); icmp_ln51_11_reg_1687 = icmp_ln51_11_fu_793_p2.read(); icmp_ln51_4_reg_1656 = icmp_ln51_4_fu_711_p2.read(); icmp_ln51_5_reg_1661 = icmp_ln51_5_fu_717_p2.read(); icmp_ln51_8_reg_1672 = icmp_ln51_8_fu_758_p2.read(); icmp_ln51_9_reg_1677 = icmp_ln51_9_fu_764_p2.read(); isNeg_reg_1692 = add_ln339_fu_803_p2.read().range(8, 8); or_ln51_3_reg_1666 = or_ln51_3_fu_735_p2.read(); p_Val2_1_reg_1610 = p_Val2_1_fu_582_p1.read(); tmp_V_1_reg_1615 = tmp_V_1_fu_596_p1.read(); ush_reg_1697 = ush_fu_827_p3.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read())) { p_a_1_reg_1580 = p_a_1_fu_519_p3.read(); p_a_2_reg_1586 = p_a_2_fu_529_p3.read(); p_a_3_reg_1592 = p_a_3_fu_539_p3.read(); p_a_4_reg_1598 = p_a_4_fu_549_p3.read(); p_a_5_reg_1604 = p_a_5_fu_559_p3.read(); p_a_reg_1574 = p_a_fu_509_p3.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state12.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state19.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state26.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state30.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state34.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state53.read()))) { reg_210 = grp_fu_148_p2.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state26.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state15.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state22.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state49.read()))) { reg_223 = grp_fu_166_p2.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state26.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state22.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state49.read()))) { reg_230 = grp_fu_171_p2.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state22.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state49.read()))) { reg_236 = grp_fu_175_p2.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state26.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state30.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state34.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state53.read()))) { reg_242 = grp_fu_154_p2.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state30.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state53.read()))) { reg_251 = grp_fu_160_p2.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state15.read())) { xor_ln22_reg_1557 = xor_ln22_fu_495_p2.read(); } } void checkAxis_2::thread_add_ln339_1_fu_1146_p2() { add_ln339_1_fu_1146_p2 = (!ap_const_lv9_181.is_01() || !zext_ln339_1_fu_1142_p1.read().is_01())? sc_lv<9>(): (sc_bigint<9>(ap_const_lv9_181) + sc_biguint<9>(zext_ln339_1_fu_1142_p1.read())); } void checkAxis_2::thread_add_ln339_fu_803_p2() { add_ln339_fu_803_p2 = (!ap_const_lv9_181.is_01() || !zext_ln339_fu_799_p1.read().is_01())? sc_lv<9>(): (sc_bigint<9>(ap_const_lv9_181) + sc_biguint<9>(zext_ln339_fu_799_p1.read())); } void checkAxis_2::thread_add_ln82_1_fu_1284_p2() { add_ln82_1_fu_1284_p2 = (!add_ln82_reg_1708.read().is_01() || !zext_ln82_fu_1280_p1.read().is_01())? sc_lv<32>(): (sc_biguint<32>(add_ln82_reg_1708.read()) + sc_biguint<32>(zext_ln82_fu_1280_p1.read())); } void checkAxis_2::thread_add_ln82_2_fu_1299_p2() { add_ln82_2_fu_1299_p2 = (!ap_const_lv3_7.is_01() || !k_assign_reg_136.read().is_01())? sc_lv<3>(): (sc_bigint<3>(ap_const_lv3_7) + sc_biguint<3>(k_assign_reg_136.read())); } void checkAxis_2::thread_add_ln82_3_fu_1317_p2() { add_ln82_3_fu_1317_p2 = (!add_ln82_reg_1708.read().is_01() || !sext_ln82_fu_1313_p1.read().is_01())? sc_lv<32>(): (sc_biguint<32>(add_ln82_reg_1708.read()) + sc_bigint<32>(sext_ln82_fu_1313_p1.read())); } void checkAxis_2::thread_add_ln82_fu_1262_p2() { add_ln82_fu_1262_p2 = (!shl_ln_fu_1254_p3.read().is_01() || !p_Val2_5_fu_1112_p3.read().is_01())? sc_lv<32>(): (sc_biguint<32>(shl_ln_fu_1254_p3.read()) + sc_biguint<32>(p_Val2_5_fu_1112_p3.read())); } void checkAxis_2::thread_and_ln49_1_fu_505_p2() { and_ln49_1_fu_505_p2 = (and_ln49_reg_1533.read() & tmp_2_reg_1450.read()); } void checkAxis_2::thread_and_ln49_2_fu_849_p2() { and_ln49_2_fu_849_p2 = (or_ln49_2_fu_835_p2.read() & or_ln49_3_fu_844_p2.read()); } void checkAxis_2::thread_and_ln49_3_fu_855_p2() { and_ln49_3_fu_855_p2 = (and_ln49_2_fu_849_p2.read() & grp_fu_186_p2.read()); } void checkAxis_2::thread_and_ln49_4_fu_515_p2() { and_ln49_4_fu_515_p2 = (and_ln49_reg_1533.read() & tmp_8_reg_1455.read()); } void checkAxis_2::thread_and_ln49_5_fu_865_p2() { and_ln49_5_fu_865_p2 = (or_ln49_4_fu_861_p2.read() & or_ln49_3_fu_844_p2.read()); } void checkAxis_2::thread_and_ln49_6_fu_871_p2() { and_ln49_6_fu_871_p2 = (and_ln49_5_fu_865_p2.read() & grp_fu_190_p2.read()); } void checkAxis_2::thread_and_ln49_7_fu_950_p2() { and_ln49_7_fu_950_p2 = (and_ln49_3_fu_855_p2.read() & and_ln49_6_fu_871_p2.read()); } void checkAxis_2::thread_and_ln49_fu_393_p2() { and_ln49_fu_393_p2 = (or_ln49_fu_377_p2.read() & or_ln49_1_fu_388_p2.read()); } void checkAxis_2::thread_and_ln50_1_fu_525_p2() { and_ln50_1_fu_525_p2 = (and_ln50_reg_1539.read() & tmp_s_reg_1480.read()); } void checkAxis_2::thread_and_ln50_2_fu_917_p2() { and_ln50_2_fu_917_p2 = (or_ln50_2_fu_895_p2.read() & or_ln50_3_fu_911_p2.read()); } void checkAxis_2::thread_and_ln50_3_fu_923_p2() { and_ln50_3_fu_923_p2 = (and_ln50_2_fu_917_p2.read() & grp_fu_194_p2.read()); } void checkAxis_2::thread_and_ln50_4_fu_535_p2() { and_ln50_4_fu_535_p2 = (and_ln50_reg_1539.read() & tmp_6_reg_1485.read()); } void checkAxis_2::thread_and_ln50_fu_439_p2() { and_ln50_fu_439_p2 = (or_ln50_fu_423_p2.read() & or_ln50_1_fu_434_p2.read()); } void checkAxis_2::thread_and_ln51_10_fu_1011_p2() { and_ln51_10_fu_1011_p2 = (and_ln51_6_fu_983_p2.read() & and_ln51_9_fu_1005_p2.read()); } void checkAxis_2::thread_and_ln51_11_fu_1023_p2() { and_ln51_11_fu_1023_p2 = (or_ln51_6_fu_1017_p2.read() & or_ln50_4_fu_962_p2.read()); } void checkAxis_2::thread_and_ln51_12_fu_1029_p2() { and_ln51_12_fu_1029_p2 = (and_ln51_11_fu_1023_p2.read() & and_ln51_7_fu_989_p2.read()); } void checkAxis_2::thread_and_ln51_1_fu_545_p2() { and_ln51_1_fu_545_p2 = (and_ln51_reg_1545.read() & tmp_7_reg_1510.read()); } void checkAxis_2::thread_and_ln51_2_fu_555_p2() { and_ln51_2_fu_555_p2 = (and_ln51_reg_1545.read() & tmp_4_reg_1515.read()); } void checkAxis_2::thread_and_ln51_3_fu_939_p2() { and_ln51_3_fu_939_p2 = (or_ln51_2_fu_935_p2.read() & or_ln51_3_reg_1666.read()); } void checkAxis_2::thread_and_ln51_4_fu_944_p2() { and_ln51_4_fu_944_p2 = (and_ln51_3_fu_939_p2.read() & grp_fu_198_p2.read()); } void checkAxis_2::thread_and_ln51_5_fu_978_p2() { and_ln51_5_fu_978_p2 = (or_ln51_4_fu_974_p2.read() & or_ln51_3_reg_1666.read()); } void checkAxis_2::thread_and_ln51_6_fu_983_p2() { and_ln51_6_fu_983_p2 = (and_ln51_5_fu_978_p2.read() & grp_fu_202_p2.read()); } void checkAxis_2::thread_and_ln51_7_fu_989_p2() { and_ln51_7_fu_989_p2 = (and_ln51_4_fu_944_p2.read() & and_ln49_7_fu_950_p2.read()); } void checkAxis_2::thread_and_ln51_8_fu_999_p2() { and_ln51_8_fu_999_p2 = (or_ln51_5_fu_995_p2.read() & or_ln50_3_fu_911_p2.read()); } void checkAxis_2::thread_and_ln51_9_fu_1005_p2() { and_ln51_9_fu_1005_p2 = (and_ln51_8_fu_999_p2.read() & grp_fu_206_p2.read()); } void checkAxis_2::thread_and_ln51_fu_485_p2() { and_ln51_fu_485_p2 = (or_ln51_fu_469_p2.read() & or_ln51_1_fu_480_p2.read()); } void checkAxis_2::thread_ap_CS_fsm_state1() { ap_CS_fsm_state1 = ap_CS_fsm.read()[0]; } void checkAxis_2::thread_ap_CS_fsm_state12() { ap_CS_fsm_state12 = ap_CS_fsm.read()[11]; } void checkAxis_2::thread_ap_CS_fsm_state13() { ap_CS_fsm_state13 = ap_CS_fsm.read()[12]; } void checkAxis_2::thread_ap_CS_fsm_state15() { ap_CS_fsm_state15 = ap_CS_fsm.read()[14]; } void checkAxis_2::thread_ap_CS_fsm_state16() { ap_CS_fsm_state16 = ap_CS_fsm.read()[15]; } void checkAxis_2::thread_ap_CS_fsm_state19() { ap_CS_fsm_state19 = ap_CS_fsm.read()[18]; } void checkAxis_2::thread_ap_CS_fsm_state20() { ap_CS_fsm_state20 = ap_CS_fsm.read()[19]; } void checkAxis_2::thread_ap_CS_fsm_state22() { ap_CS_fsm_state22 = ap_CS_fsm.read()[21]; } void checkAxis_2::thread_ap_CS_fsm_state23() { ap_CS_fsm_state23 = ap_CS_fsm.read()[22]; } void checkAxis_2::thread_ap_CS_fsm_state24() { ap_CS_fsm_state24 = ap_CS_fsm.read()[23]; } void checkAxis_2::thread_ap_CS_fsm_state26() { ap_CS_fsm_state26 = ap_CS_fsm.read()[25]; } void checkAxis_2::thread_ap_CS_fsm_state27() { ap_CS_fsm_state27 = ap_CS_fsm.read()[26]; } void checkAxis_2::thread_ap_CS_fsm_state3() { ap_CS_fsm_state3 = ap_CS_fsm.read()[2]; } void checkAxis_2::thread_ap_CS_fsm_state30() { ap_CS_fsm_state30 = ap_CS_fsm.read()[29]; } void checkAxis_2::thread_ap_CS_fsm_state31() { ap_CS_fsm_state31 = ap_CS_fsm.read()[30]; } void checkAxis_2::thread_ap_CS_fsm_state34() { ap_CS_fsm_state34 = ap_CS_fsm.read()[33]; } void checkAxis_2::thread_ap_CS_fsm_state35() { ap_CS_fsm_state35 = ap_CS_fsm.read()[34]; } void checkAxis_2::thread_ap_CS_fsm_state4() { ap_CS_fsm_state4 = ap_CS_fsm.read()[3]; } void checkAxis_2::thread_ap_CS_fsm_state46() { ap_CS_fsm_state46 = ap_CS_fsm.read()[45]; } void checkAxis_2::thread_ap_CS_fsm_state47() { ap_CS_fsm_state47 = ap_CS_fsm.read()[46]; } void checkAxis_2::thread_ap_CS_fsm_state49() { ap_CS_fsm_state49 = ap_CS_fsm.read()[48]; } void checkAxis_2::thread_ap_CS_fsm_state5() { ap_CS_fsm_state5 = ap_CS_fsm.read()[4]; } void checkAxis_2::thread_ap_CS_fsm_state50() { ap_CS_fsm_state50 = ap_CS_fsm.read()[49]; } void checkAxis_2::thread_ap_CS_fsm_state53() { ap_CS_fsm_state53 = ap_CS_fsm.read()[52]; } void checkAxis_2::thread_ap_CS_fsm_state54() { ap_CS_fsm_state54 = ap_CS_fsm.read()[53]; } void checkAxis_2::thread_ap_CS_fsm_state55() { ap_CS_fsm_state55 = ap_CS_fsm.read()[54]; } void checkAxis_2::thread_ap_CS_fsm_state56() { ap_CS_fsm_state56 = ap_CS_fsm.read()[55]; } void checkAxis_2::thread_ap_CS_fsm_state8() { ap_CS_fsm_state8 = ap_CS_fsm.read()[7]; } void checkAxis_2::thread_ap_CS_fsm_state9() { ap_CS_fsm_state9 = ap_CS_fsm.read()[8]; } void checkAxis_2::thread_ap_done() { if (((esl_seteq<1,1,1>(ap_const_logic_0, ap_start.read()) && esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read())) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_ln92_fu_341_p2.read(), ap_const_lv1_1)))) { ap_done = ap_const_logic_1; } else { ap_done = ap_const_logic_0; } } void checkAxis_2::thread_ap_idle() { if ((esl_seteq<1,1,1>(ap_const_logic_0, ap_start.read()) && esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()))) { ap_idle = ap_const_logic_1; } else { ap_idle = ap_const_logic_0; } } void checkAxis_2::thread_ap_ready() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_ln92_fu_341_p2.read(), ap_const_lv1_1))) { ap_ready = ap_const_logic_1; } else { ap_ready = ap_const_logic_0; } } void checkAxis_2::thread_ap_return() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_ln92_fu_341_p2.read(), ap_const_lv1_1))) { ap_return = collisions_0_reg_124.read(); } else { ap_return = ap_return_preg.read(); } } void checkAxis_2::thread_bitcast_ln22_1_fu_501_p1() { bitcast_ln22_1_fu_501_p1 = xor_ln22_reg_1557.read(); } void checkAxis_2::thread_bitcast_ln22_fu_491_p1() { bitcast_ln22_fu_491_p1 = reg_210.read(); } void checkAxis_2::thread_bitcast_ln49_1_fu_265_p1() { bitcast_ln49_1_fu_265_p1 = edge_p2_x.read(); } void checkAxis_2::thread_bitcast_ln49_2_fu_565_p1() { bitcast_ln49_2_fu_565_p1 = p_a_reg_1574.read(); } void checkAxis_2::thread_bitcast_ln49_4_fu_618_p1() { bitcast_ln49_4_fu_618_p1 = p_a_1_reg_1580.read(); } void checkAxis_2::thread_bitcast_ln49_fu_258_p1() { bitcast_ln49_fu_258_p1 = edge_p1_x.read(); } void checkAxis_2::thread_bitcast_ln50_1_fu_291_p1() { bitcast_ln50_1_fu_291_p1 = edge_p2_y.read(); } void checkAxis_2::thread_bitcast_ln50_2_fu_647_p1() { bitcast_ln50_2_fu_647_p1 = p_a_2_reg_1586.read(); } void checkAxis_2::thread_bitcast_ln50_fu_284_p1() { bitcast_ln50_fu_284_p1 = edge_p1_y.read(); } void checkAxis_2::thread_bitcast_ln51_1_fu_317_p1() { bitcast_ln51_1_fu_317_p1 = edge_p2_z.read(); } void checkAxis_2::thread_bitcast_ln51_2_fu_676_p1() { bitcast_ln51_2_fu_676_p1 = p_a_5_reg_1604.read(); } void checkAxis_2::thread_bitcast_ln51_3_fu_693_p1() { bitcast_ln51_3_fu_693_p1 = reg_251.read(); } void checkAxis_2::thread_bitcast_ln51_4_fu_741_p1() { bitcast_ln51_4_fu_741_p1 = p_a_4_reg_1598.read(); } void checkAxis_2::thread_bitcast_ln51_5_fu_770_p1() { bitcast_ln51_5_fu_770_p1 = p_a_3_reg_1592.read(); } void checkAxis_2::thread_bitcast_ln51_fu_310_p1() { bitcast_ln51_fu_310_p1 = edge_p1_z.read(); } void checkAxis_2::thread_collisions_1_fu_1344_p3() { collisions_1_fu_1344_p3 = (!and_ln51_12_reg_1703.read()[0].is_01())? sc_lv<64>(): ((and_ln51_12_reg_1703.read()[0].to_bool())? collisions_fu_1338_p2.read(): collisions_0_reg_124.read()); } void checkAxis_2::thread_collisions_fu_1338_p2() { collisions_fu_1338_p2 = (or_ln98_fu_1332_p2.read() | shl_ln97_fu_1293_p2.read()); } void checkAxis_2::thread_grp_fu_148_opcode() { if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1)) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state16.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state31.read()))) { grp_fu_148_opcode = ap_const_lv2_1; } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state23.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read()))) { grp_fu_148_opcode = ap_const_lv2_0; } else { grp_fu_148_opcode = "XX"; } } void checkAxis_2::thread_grp_fu_148_p0() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state31.read()))) { grp_fu_148_p0 = reg_210.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state16.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state23.read()))) { grp_fu_148_p0 = reg_223.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read())) { grp_fu_148_p0 = R_z_reg_1551.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read())) { grp_fu_148_p0 = edge_p2_x.read(); } else { grp_fu_148_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_148_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state31.read())) { grp_fu_148_p1 = reg_242.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state23.read())) { grp_fu_148_p1 = reg_223.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state16.read())) { grp_fu_148_p1 = bitcast_ln22_1_fu_501_p1.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read()))) { grp_fu_148_p1 = R_z_reg_1551.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read()))) { grp_fu_148_p1 = edge_p1_x.read(); } else { grp_fu_148_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_154_opcode() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { grp_fu_154_opcode = ap_const_lv2_1; } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state23.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state31.read()))) { grp_fu_154_opcode = ap_const_lv2_0; } else { grp_fu_154_opcode = "XX"; } } void checkAxis_2::thread_grp_fu_154_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state31.read())) { grp_fu_154_p0 = reg_251.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read())) { grp_fu_154_p0 = reg_242.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state23.read()))) { grp_fu_154_p0 = reg_230.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read())) { grp_fu_154_p0 = edge_p2_y.read(); } else { grp_fu_154_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_154_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state31.read())) { grp_fu_154_p1 = tmp_24_i_i_reg_1424.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read())) { grp_fu_154_p1 = edge_p1_z.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state23.read())) { grp_fu_154_p1 = reg_236.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read()))) { grp_fu_154_p1 = edge_p1_y.read(); } else { grp_fu_154_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_160_opcode() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { grp_fu_160_opcode = ap_const_lv2_1; } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read()))) { grp_fu_160_opcode = ap_const_lv2_0; } else { grp_fu_160_opcode = "XX"; } } void checkAxis_2::thread_grp_fu_160_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read())) { grp_fu_160_p0 = reg_236.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read())) { grp_fu_160_p0 = reg_223.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read())) { grp_fu_160_p0 = edge_p2_z.read(); } else { grp_fu_160_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_160_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state27.read())) { grp_fu_160_p1 = reg_230.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state50.read()))) { grp_fu_160_p1 = edge_p1_z.read(); } else { grp_fu_160_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_166_p0() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state24.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state47.read()))) { grp_fu_166_p0 = tmp_19_i_i_reg_1414.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state13.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state20.read()))) { grp_fu_166_p0 = reg_210.read(); } else { grp_fu_166_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_166_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state47.read())) { grp_fu_166_p1 = T_reg_1567.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state24.read())) { grp_fu_166_p1 = reg_210.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state13.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state20.read()))) { grp_fu_166_p1 = ap_const_lv32_0; } else { grp_fu_166_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_171_p0() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state24.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state47.read()))) { grp_fu_171_p0 = tmp_21_i_i_reg_1419.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state20.read())) { grp_fu_171_p0 = reg_210.read(); } else { grp_fu_171_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_171_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state47.read())) { grp_fu_171_p1 = T_reg_1567.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state24.read())) { grp_fu_171_p1 = reg_210.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state20.read())) { grp_fu_171_p1 = edge_p1_x.read(); } else { grp_fu_171_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_175_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state47.read())) { grp_fu_175_p0 = tmp_24_i_i_reg_1424.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state20.read())) { grp_fu_175_p0 = reg_210.read(); } else { grp_fu_175_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_175_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state47.read())) { grp_fu_175_p1 = T_reg_1567.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state20.read())) { grp_fu_175_p1 = edge_p1_y.read(); } else { grp_fu_175_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_183_p0() { grp_fu_183_p0 = esl_zext<32,3>(k_assign_reg_136.read()); } void checkAxis_2::thread_grp_fu_186_opcode() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_186_opcode = ap_const_lv5_5; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_186_opcode = ap_const_lv5_4; } else { grp_fu_186_opcode = (sc_lv<5>) ("XXXXX"); } } void checkAxis_2::thread_grp_fu_186_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_186_p0 = p_a_reg_1574.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_186_p0 = edge_p1_x.read(); } else { grp_fu_186_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_186_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_186_p1 = reg_210.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_186_p1 = edge_p2_x.read(); } else { grp_fu_186_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_190_opcode() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_190_opcode = ap_const_lv5_3; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_190_opcode = ap_const_lv5_2; } else { grp_fu_190_opcode = (sc_lv<5>) ("XXXXX"); } } void checkAxis_2::thread_grp_fu_190_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_190_p0 = p_a_1_reg_1580.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_190_p0 = edge_p1_x.read(); } else { grp_fu_190_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_190_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_190_p1 = reg_210.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_190_p1 = edge_p2_x.read(); } else { grp_fu_190_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_194_opcode() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_194_opcode = ap_const_lv5_5; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_194_opcode = ap_const_lv5_4; } else { grp_fu_194_opcode = (sc_lv<5>) ("XXXXX"); } } void checkAxis_2::thread_grp_fu_194_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_194_p0 = p_a_2_reg_1586.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_194_p0 = edge_p1_y.read(); } else { grp_fu_194_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_194_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_194_p1 = reg_242.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_194_p1 = edge_p2_y.read(); } else { grp_fu_194_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_198_opcode() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_198_opcode = ap_const_lv5_3; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_198_opcode = ap_const_lv5_2; } else { grp_fu_198_opcode = (sc_lv<5>) ("XXXXX"); } } void checkAxis_2::thread_grp_fu_198_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_198_p0 = p_a_5_reg_1604.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_198_p0 = edge_p1_y.read(); } else { grp_fu_198_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_198_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_198_p1 = reg_251.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_198_p1 = edge_p2_y.read(); } else { grp_fu_198_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_202_opcode() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_202_opcode = ap_const_lv5_5; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_202_opcode = ap_const_lv5_4; } else { grp_fu_202_opcode = (sc_lv<5>) ("XXXXX"); } } void checkAxis_2::thread_grp_fu_202_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_202_p0 = p_a_4_reg_1598.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_202_p0 = edge_p1_z.read(); } else { grp_fu_202_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_202_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_202_p1 = reg_251.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_202_p1 = edge_p2_z.read(); } else { grp_fu_202_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_206_opcode() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_206_opcode = ap_const_lv5_3; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_206_opcode = ap_const_lv5_2; } else { grp_fu_206_opcode = (sc_lv<5>) ("XXXXX"); } } void checkAxis_2::thread_grp_fu_206_p0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_206_p0 = p_a_3_reg_1592.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_206_p0 = edge_p1_z.read(); } else { grp_fu_206_p0 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_grp_fu_206_p1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state54.read())) { grp_fu_206_p1 = reg_242.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { grp_fu_206_p1 = edge_p2_z.read(); } else { grp_fu_206_p1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void checkAxis_2::thread_i_fu_347_p2() { i_fu_347_p2 = (!k_assign_reg_136.read().is_01() || !ap_const_lv3_1.is_01())? sc_lv<3>(): (sc_biguint<3>(k_assign_reg_136.read()) + sc_biguint<3>(ap_const_lv3_1)); } void checkAxis_2::thread_icmp_ln49_1_fu_272_p2() { icmp_ln49_1_fu_272_p2 = (!trunc_ln49_fu_261_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln49_fu_261_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln49_2_fu_382_p2() { icmp_ln49_2_fu_382_p2 = (!tmp_1_fu_362_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_1_fu_362_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln49_3_fu_278_p2() { icmp_ln49_3_fu_278_p2 = (!trunc_ln49_1_fu_268_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln49_1_fu_268_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln49_4_fu_600_p2() { icmp_ln49_4_fu_600_p2 = (!tmp_3_fu_568_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_3_fu_568_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln49_5_fu_606_p2() { icmp_ln49_5_fu_606_p2 = (!trunc_ln49_2_fu_578_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln49_2_fu_578_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln49_6_fu_612_p2() { icmp_ln49_6_fu_612_p2 = (!tmp_V_fu_586_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_V_fu_586_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln49_7_fu_839_p2() { icmp_ln49_7_fu_839_p2 = (!tmp_V_1_reg_1615.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(tmp_V_1_reg_1615.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln49_8_fu_635_p2() { icmp_ln49_8_fu_635_p2 = (!tmp_9_fu_621_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_9_fu_621_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln49_9_fu_641_p2() { icmp_ln49_9_fu_641_p2 = (!trunc_ln49_4_fu_631_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln49_4_fu_631_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln49_fu_371_p2() { icmp_ln49_fu_371_p2 = (!tmp_fu_353_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_fu_353_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln50_1_fu_298_p2() { icmp_ln50_1_fu_298_p2 = (!trunc_ln50_fu_287_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln50_fu_287_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln50_2_fu_428_p2() { icmp_ln50_2_fu_428_p2 = (!tmp_12_fu_408_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_12_fu_408_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln50_3_fu_304_p2() { icmp_ln50_3_fu_304_p2 = (!trunc_ln50_1_fu_294_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln50_1_fu_294_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln50_4_fu_664_p2() { icmp_ln50_4_fu_664_p2 = (!tmp_13_fu_650_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_13_fu_650_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln50_5_fu_670_p2() { icmp_ln50_5_fu_670_p2 = (!trunc_ln50_2_fu_660_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln50_2_fu_660_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln50_6_fu_899_p2() { icmp_ln50_6_fu_899_p2 = (!tmp_V_2_fu_881_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_V_2_fu_881_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln50_7_fu_905_p2() { icmp_ln50_7_fu_905_p2 = (!tmp_V_3_fu_891_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(tmp_V_3_fu_891_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln50_fu_417_p2() { icmp_ln50_fu_417_p2 = (!tmp_11_fu_399_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_11_fu_399_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln51_10_fu_787_p2() { icmp_ln51_10_fu_787_p2 = (!tmp_22_fu_773_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_22_fu_773_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln51_11_fu_793_p2() { icmp_ln51_11_fu_793_p2 = (!trunc_ln51_5_fu_783_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln51_5_fu_783_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln51_1_fu_324_p2() { icmp_ln51_1_fu_324_p2 = (!trunc_ln51_fu_313_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln51_fu_313_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln51_2_fu_474_p2() { icmp_ln51_2_fu_474_p2 = (!tmp_16_fu_454_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_16_fu_454_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln51_3_fu_330_p2() { icmp_ln51_3_fu_330_p2 = (!trunc_ln51_1_fu_320_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln51_1_fu_320_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln51_4_fu_711_p2() { icmp_ln51_4_fu_711_p2 = (!tmp_17_fu_679_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_17_fu_679_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln51_5_fu_717_p2() { icmp_ln51_5_fu_717_p2 = (!trunc_ln51_2_fu_689_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln51_2_fu_689_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln51_6_fu_723_p2() { icmp_ln51_6_fu_723_p2 = (!tmp_18_fu_697_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_18_fu_697_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln51_7_fu_729_p2() { icmp_ln51_7_fu_729_p2 = (!trunc_ln51_3_fu_707_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln51_3_fu_707_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln51_8_fu_758_p2() { icmp_ln51_8_fu_758_p2 = (!tmp_20_fu_744_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_20_fu_744_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln51_9_fu_764_p2() { icmp_ln51_9_fu_764_p2 = (!trunc_ln51_4_fu_754_p1.read().is_01() || !ap_const_lv23_0.is_01())? sc_lv<1>(): sc_lv<1>(trunc_ln51_4_fu_754_p1.read() == ap_const_lv23_0); } void checkAxis_2::thread_icmp_ln51_fu_463_p2() { icmp_ln51_fu_463_p2 = (!tmp_15_fu_445_p4.read().is_01() || !ap_const_lv8_FF.is_01())? sc_lv<1>(): sc_lv<1>(tmp_15_fu_445_p4.read() != ap_const_lv8_FF); } void checkAxis_2::thread_icmp_ln92_fu_341_p2() { icmp_ln92_fu_341_p2 = (!k_assign_reg_136.read().is_01() || !ap_const_lv3_4.is_01())? sc_lv<1>(): sc_lv<1>(k_assign_reg_136.read() == ap_const_lv3_4); } void checkAxis_2::thread_isNeg_1_fu_1152_p3() { isNeg_1_fu_1152_p3 = add_ln339_1_fu_1146_p2.read().range(8, 8); } void checkAxis_2::thread_isNeg_fu_809_p3() { isNeg_fu_809_p3 = add_ln339_fu_803_p2.read().range(8, 8); } void checkAxis_2::thread_mantissa_V_1_fu_1128_p4() { mantissa_V_1_fu_1128_p4 = esl_concat<24,1>(esl_concat<1,23>(ap_const_lv1_1, tmp_V_3_fu_891_p1.read()), ap_const_lv1_0); } void checkAxis_2::thread_mantissa_V_fu_1042_p4() { mantissa_V_fu_1042_p4 = esl_concat<24,1>(esl_concat<1,23>(ap_const_lv1_1, tmp_V_1_reg_1615.read()), ap_const_lv1_0); } void checkAxis_2::thread_or_ln49_1_fu_388_p2() { or_ln49_1_fu_388_p2 = (icmp_ln49_3_reg_1445.read() | icmp_ln49_2_fu_382_p2.read()); } void checkAxis_2::thread_or_ln49_2_fu_835_p2() { or_ln49_2_fu_835_p2 = (icmp_ln49_5_reg_1626.read() | icmp_ln49_4_reg_1621.read()); } void checkAxis_2::thread_or_ln49_3_fu_844_p2() { or_ln49_3_fu_844_p2 = (icmp_ln49_7_fu_839_p2.read() | icmp_ln49_6_reg_1631.read()); } void checkAxis_2::thread_or_ln49_4_fu_861_p2() { or_ln49_4_fu_861_p2 = (icmp_ln49_9_reg_1641.read() | icmp_ln49_8_reg_1636.read()); } void checkAxis_2::thread_or_ln49_fu_377_p2() { or_ln49_fu_377_p2 = (icmp_ln49_1_reg_1440.read() | icmp_ln49_fu_371_p2.read()); } void checkAxis_2::thread_or_ln50_1_fu_434_p2() { or_ln50_1_fu_434_p2 = (icmp_ln50_3_reg_1475.read() | icmp_ln50_2_fu_428_p2.read()); } void checkAxis_2::thread_or_ln50_2_fu_895_p2() { or_ln50_2_fu_895_p2 = (icmp_ln50_5_reg_1651.read() | icmp_ln50_4_reg_1646.read()); } void checkAxis_2::thread_or_ln50_3_fu_911_p2() { or_ln50_3_fu_911_p2 = (icmp_ln50_7_fu_905_p2.read() | icmp_ln50_6_fu_899_p2.read()); } void checkAxis_2::thread_or_ln50_4_fu_962_p2() { or_ln50_4_fu_962_p2 = (and_ln50_3_fu_923_p2.read() | xor_ln49_fu_956_p2.read()); } void checkAxis_2::thread_or_ln50_5_fu_968_p2() { or_ln50_5_fu_968_p2 = (xor_ln49_fu_956_p2.read() | xor_ln50_fu_929_p2.read()); } void checkAxis_2::thread_or_ln50_fu_423_p2() { or_ln50_fu_423_p2 = (icmp_ln50_1_reg_1470.read() | icmp_ln50_fu_417_p2.read()); } void checkAxis_2::thread_or_ln51_1_fu_480_p2() { or_ln51_1_fu_480_p2 = (icmp_ln51_3_reg_1505.read() | icmp_ln51_2_fu_474_p2.read()); } void checkAxis_2::thread_or_ln51_2_fu_935_p2() { or_ln51_2_fu_935_p2 = (icmp_ln51_5_reg_1661.read() | icmp_ln51_4_reg_1656.read()); } void checkAxis_2::thread_or_ln51_3_fu_735_p2() { or_ln51_3_fu_735_p2 = (icmp_ln51_7_fu_729_p2.read() | icmp_ln51_6_fu_723_p2.read()); } void checkAxis_2::thread_or_ln51_4_fu_974_p2() { or_ln51_4_fu_974_p2 = (icmp_ln51_9_reg_1677.read() | icmp_ln51_8_reg_1672.read()); } void checkAxis_2::thread_or_ln51_5_fu_995_p2() { or_ln51_5_fu_995_p2 = (icmp_ln51_11_reg_1687.read() | icmp_ln51_10_reg_1682.read()); } void checkAxis_2::thread_or_ln51_6_fu_1017_p2() { or_ln51_6_fu_1017_p2 = (or_ln50_5_fu_968_p2.read() | and_ln51_10_fu_1011_p2.read()); } void checkAxis_2::thread_or_ln51_fu_469_p2() { or_ln51_fu_469_p2 = (icmp_ln51_1_reg_1500.read() | icmp_ln51_fu_463_p2.read()); } void checkAxis_2::thread_or_ln98_fu_1332_p2() { or_ln98_fu_1332_p2 = (collisions_0_reg_124.read() | shl_ln98_fu_1326_p2.read()); } void checkAxis_2::thread_p_Result_1_fu_1120_p3() { p_Result_1_fu_1120_p3 = p_Val2_s_fu_877_p1.read().range(31, 31); } void checkAxis_2::thread_p_Result_s_fu_1035_p3() { p_Result_s_fu_1035_p3 = p_Val2_1_reg_1610.read().range(31, 31); } void checkAxis_2::thread_p_Val2_1_fu_582_p1() { p_Val2_1_fu_582_p1 = reg_210.read(); } void checkAxis_2::thread_p_Val2_4_fu_1099_p3() { p_Val2_4_fu_1099_p3 = (!isNeg_reg_1692.read()[0].is_01())? sc_lv<32>(): ((isNeg_reg_1692.read()[0].to_bool())? zext_ln662_fu_1085_p1.read(): tmp_24_fu_1089_p4.read()); } void checkAxis_2::thread_p_Val2_5_fu_1112_p3() { p_Val2_5_fu_1112_p3 = (!p_Result_s_fu_1035_p3.read()[0].is_01())? sc_lv<32>(): ((p_Result_s_fu_1035_p3.read()[0].to_bool())? result_V_1_fu_1106_p2.read(): p_Val2_4_fu_1099_p3.read()); } void checkAxis_2::thread_p_Val2_s_fu_877_p1() { p_Val2_s_fu_877_p1 = reg_242.read(); } void checkAxis_2::thread_p_a_1_fu_519_p3() { p_a_1_fu_519_p3 = (!and_ln49_4_fu_515_p2.read()[0].is_01())? sc_lv<32>(): ((and_ln49_4_fu_515_p2.read()[0].to_bool())? edge_p1_x.read(): edge_p2_x.read()); } void checkAxis_2::thread_p_a_2_fu_529_p3() { p_a_2_fu_529_p3 = (!and_ln50_1_fu_525_p2.read()[0].is_01())? sc_lv<32>(): ((and_ln50_1_fu_525_p2.read()[0].to_bool())? edge_p1_y.read(): edge_p2_y.read()); } void checkAxis_2::thread_p_a_3_fu_539_p3() { p_a_3_fu_539_p3 = (!and_ln50_4_fu_535_p2.read()[0].is_01())? sc_lv<32>(): ((and_ln50_4_fu_535_p2.read()[0].to_bool())? edge_p1_y.read(): edge_p2_y.read()); } void checkAxis_2::thread_p_a_4_fu_549_p3() { p_a_4_fu_549_p3 = (!and_ln51_1_fu_545_p2.read()[0].is_01())? sc_lv<32>(): ((and_ln51_1_fu_545_p2.read()[0].to_bool())? edge_p1_z.read(): edge_p2_z.read()); } void checkAxis_2::thread_p_a_5_fu_559_p3() { p_a_5_fu_559_p3 = (!and_ln51_2_fu_555_p2.read()[0].is_01())? sc_lv<32>(): ((and_ln51_2_fu_555_p2.read()[0].to_bool())? edge_p1_z.read(): edge_p2_z.read()); } void checkAxis_2::thread_p_a_fu_509_p3() { p_a_fu_509_p3 = (!and_ln49_1_fu_505_p2.read()[0].is_01())? sc_lv<32>(): ((and_ln49_1_fu_505_p2.read()[0].to_bool())? edge_p1_x.read(): edge_p2_x.read()); } void checkAxis_2::thread_r_V_1_fu_1071_p2() { r_V_1_fu_1071_p2 = (!zext_ln1287_fu_1061_p1.read().is_01())? sc_lv<79>(): zext_ln682_fu_1051_p1.read() << (unsigned short)zext_ln1287_fu_1061_p1.read().to_uint(); } void checkAxis_2::thread_r_V_2_fu_1190_p2() { r_V_2_fu_1190_p2 = (!sext_ln1311_5_fu_1182_p1.read().is_01())? sc_lv<25>(): mantissa_V_1_fu_1128_p4.read() >> (unsigned short)sext_ln1311_5_fu_1182_p1.read().to_uint(); } void checkAxis_2::thread_r_V_3_fu_1196_p2() { r_V_3_fu_1196_p2 = (!zext_ln1287_1_fu_1186_p1.read().is_01())? sc_lv<79>(): zext_ln682_1_fu_1138_p1.read() << (unsigned short)zext_ln1287_1_fu_1186_p1.read().to_uint(); } void checkAxis_2::thread_r_V_fu_1065_p2() { r_V_fu_1065_p2 = (!sext_ln1311_4_fu_1058_p1.read().is_01())? sc_lv<25>(): mantissa_V_fu_1042_p4.read() >> (unsigned short)sext_ln1311_4_fu_1058_p1.read().to_uint(); } void checkAxis_2::thread_result_V_1_fu_1106_p2() { result_V_1_fu_1106_p2 = (!ap_const_lv32_0.is_01() || !p_Val2_4_fu_1099_p3.read().is_01())? sc_lv<32>(): (sc_biguint<32>(ap_const_lv32_0) - sc_biguint<32>(p_Val2_4_fu_1099_p3.read())); } void checkAxis_2::thread_select_ln1312_fu_1224_p3() { select_ln1312_fu_1224_p3 = (!isNeg_1_fu_1152_p3.read()[0].is_01())? sc_lv<55>(): ((isNeg_1_fu_1152_p3.read()[0].to_bool())? zext_ln662_1_fu_1210_p1.read(): tmp_25_fu_1214_p4.read()); } void checkAxis_2::thread_select_ln59_fu_1246_p3() { select_ln59_fu_1246_p3 = (!p_Result_1_fu_1120_p3.read()[0].is_01())? sc_lv<30>(): ((p_Result_1_fu_1120_p3.read()[0].to_bool())? sub_ln82_fu_1236_p2.read(): trunc_ln82_1_fu_1242_p1.read()); } void checkAxis_2::thread_sext_ln1311_1_fu_1055_p1() { sext_ln1311_1_fu_1055_p1 = esl_sext<32,9>(ush_reg_1697.read()); } void checkAxis_2::thread_sext_ln1311_2_fu_1166_p1() { sext_ln1311_2_fu_1166_p1 = esl_sext<9,8>(sub_ln1311_1_fu_1160_p2.read()); } void checkAxis_2::thread_sext_ln1311_3_fu_1178_p1() { sext_ln1311_3_fu_1178_p1 = esl_sext<32,9>(ush_1_fu_1170_p3.read()); } void checkAxis_2::thread_sext_ln1311_4_fu_1058_p1() { sext_ln1311_4_fu_1058_p1 = esl_sext<25,9>(ush_reg_1697.read()); } void checkAxis_2::thread_sext_ln1311_5_fu_1182_p1() { sext_ln1311_5_fu_1182_p1 = esl_sext<25,9>(ush_1_fu_1170_p3.read()); } void checkAxis_2::thread_sext_ln1311_fu_823_p1() { sext_ln1311_fu_823_p1 = esl_sext<9,8>(sub_ln1311_fu_817_p2.read()); } void checkAxis_2::thread_sext_ln82_fu_1313_p1() { sext_ln82_fu_1313_p1 = esl_sext<32,7>(tmp_26_fu_1305_p3.read()); } void checkAxis_2::thread_shl_ln82_1_fu_1272_p3() { shl_ln82_1_fu_1272_p3 = esl_concat<2,4>(trunc_ln82_2_fu_1268_p1.read(), ap_const_lv4_0); } void checkAxis_2::thread_shl_ln97_fu_1293_p2() { shl_ln97_fu_1293_p2 = (!zext_ln97_fu_1289_p1.read().is_01())? sc_lv<64>(): ap_const_lv64_1 << (unsigned short)zext_ln97_fu_1289_p1.read().to_uint(); } void checkAxis_2::thread_shl_ln98_fu_1326_p2() { shl_ln98_fu_1326_p2 = (!zext_ln98_fu_1322_p1.read().is_01())? sc_lv<64>(): ap_const_lv64_1 << (unsigned short)zext_ln98_fu_1322_p1.read().to_uint(); } void checkAxis_2::thread_shl_ln_fu_1254_p3() { shl_ln_fu_1254_p3 = esl_concat<30,2>(select_ln59_fu_1246_p3.read(), ap_const_lv2_0); } void checkAxis_2::thread_sub_ln1311_1_fu_1160_p2() { sub_ln1311_1_fu_1160_p2 = (!ap_const_lv8_7F.is_01() || !tmp_V_2_fu_881_p4.read().is_01())? sc_lv<8>(): (sc_biguint<8>(ap_const_lv8_7F) - sc_biguint<8>(tmp_V_2_fu_881_p4.read())); } void checkAxis_2::thread_sub_ln1311_fu_817_p2() { sub_ln1311_fu_817_p2 = (!ap_const_lv8_7F.is_01() || !tmp_V_fu_586_p4.read().is_01())? sc_lv<8>(): (sc_biguint<8>(ap_const_lv8_7F) - sc_biguint<8>(tmp_V_fu_586_p4.read())); } void checkAxis_2::thread_sub_ln82_fu_1236_p2() { sub_ln82_fu_1236_p2 = (!ap_const_lv30_0.is_01() || !trunc_ln82_fu_1232_p1.read().is_01())? sc_lv<30>(): (sc_biguint<30>(ap_const_lv30_0) - sc_biguint<30>(trunc_ln82_fu_1232_p1.read())); } void checkAxis_2::thread_tmp_11_fu_399_p4() { tmp_11_fu_399_p4 = bitcast_ln50_reg_1460.read().range(30, 23); } void checkAxis_2::thread_tmp_12_fu_408_p4() { tmp_12_fu_408_p4 = bitcast_ln50_1_reg_1465.read().range(30, 23); } void checkAxis_2::thread_tmp_13_fu_650_p4() { tmp_13_fu_650_p4 = bitcast_ln50_2_fu_647_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_15_fu_445_p4() { tmp_15_fu_445_p4 = bitcast_ln51_reg_1490.read().range(30, 23); } void checkAxis_2::thread_tmp_16_fu_454_p4() { tmp_16_fu_454_p4 = bitcast_ln51_1_reg_1495.read().range(30, 23); } void checkAxis_2::thread_tmp_17_fu_679_p4() { tmp_17_fu_679_p4 = bitcast_ln51_2_fu_676_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_18_fu_697_p4() { tmp_18_fu_697_p4 = bitcast_ln51_3_fu_693_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_1_fu_362_p4() { tmp_1_fu_362_p4 = bitcast_ln49_1_reg_1435.read().range(30, 23); } void checkAxis_2::thread_tmp_20_fu_744_p4() { tmp_20_fu_744_p4 = bitcast_ln51_4_fu_741_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_22_fu_773_p4() { tmp_22_fu_773_p4 = bitcast_ln51_5_fu_770_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_24_fu_1089_p4() { tmp_24_fu_1089_p4 = r_V_1_fu_1071_p2.read().range(55, 24); } void checkAxis_2::thread_tmp_25_fu_1214_p4() { tmp_25_fu_1214_p4 = r_V_3_fu_1196_p2.read().range(78, 24); } void checkAxis_2::thread_tmp_26_fu_1305_p3() { tmp_26_fu_1305_p3 = esl_concat<3,4>(add_ln82_2_fu_1299_p2.read(), ap_const_lv4_0); } void checkAxis_2::thread_tmp_27_fu_1077_p3() { tmp_27_fu_1077_p3 = r_V_fu_1065_p2.read().range(24, 24); } void checkAxis_2::thread_tmp_31_fu_1202_p3() { tmp_31_fu_1202_p3 = r_V_2_fu_1190_p2.read().range(24, 24); } void checkAxis_2::thread_tmp_3_fu_568_p4() { tmp_3_fu_568_p4 = bitcast_ln49_2_fu_565_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_9_fu_621_p4() { tmp_9_fu_621_p4 = bitcast_ln49_4_fu_618_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_V_1_fu_596_p1() { tmp_V_1_fu_596_p1 = p_Val2_1_fu_582_p1.read().range(23-1, 0); } void checkAxis_2::thread_tmp_V_2_fu_881_p4() { tmp_V_2_fu_881_p4 = p_Val2_s_fu_877_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_V_3_fu_891_p1() { tmp_V_3_fu_891_p1 = p_Val2_s_fu_877_p1.read().range(23-1, 0); } void checkAxis_2::thread_tmp_V_fu_586_p4() { tmp_V_fu_586_p4 = p_Val2_1_fu_582_p1.read().range(30, 23); } void checkAxis_2::thread_tmp_fu_353_p4() { tmp_fu_353_p4 = bitcast_ln49_reg_1430.read().range(30, 23); } void checkAxis_2::thread_trunc_ln49_1_fu_268_p1() { trunc_ln49_1_fu_268_p1 = bitcast_ln49_1_fu_265_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln49_2_fu_578_p1() { trunc_ln49_2_fu_578_p1 = bitcast_ln49_2_fu_565_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln49_4_fu_631_p1() { trunc_ln49_4_fu_631_p1 = bitcast_ln49_4_fu_618_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln49_fu_261_p1() { trunc_ln49_fu_261_p1 = bitcast_ln49_fu_258_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln50_1_fu_294_p1() { trunc_ln50_1_fu_294_p1 = bitcast_ln50_1_fu_291_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln50_2_fu_660_p1() { trunc_ln50_2_fu_660_p1 = bitcast_ln50_2_fu_647_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln50_fu_287_p1() { trunc_ln50_fu_287_p1 = bitcast_ln50_fu_284_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln51_1_fu_320_p1() { trunc_ln51_1_fu_320_p1 = bitcast_ln51_1_fu_317_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln51_2_fu_689_p1() { trunc_ln51_2_fu_689_p1 = bitcast_ln51_2_fu_676_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln51_3_fu_707_p1() { trunc_ln51_3_fu_707_p1 = bitcast_ln51_3_fu_693_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln51_4_fu_754_p1() { trunc_ln51_4_fu_754_p1 = bitcast_ln51_4_fu_741_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln51_5_fu_783_p1() { trunc_ln51_5_fu_783_p1 = bitcast_ln51_5_fu_770_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln51_fu_313_p1() { trunc_ln51_fu_313_p1 = bitcast_ln51_fu_310_p1.read().range(23-1, 0); } void checkAxis_2::thread_trunc_ln82_1_fu_1242_p1() { trunc_ln82_1_fu_1242_p1 = select_ln1312_fu_1224_p3.read().range(30-1, 0); } void checkAxis_2::thread_trunc_ln82_2_fu_1268_p1() { trunc_ln82_2_fu_1268_p1 = k_assign_reg_136.read().range(2-1, 0); } void checkAxis_2::thread_trunc_ln82_fu_1232_p1() { trunc_ln82_fu_1232_p1 = select_ln1312_fu_1224_p3.read().range(30-1, 0); } void checkAxis_2::thread_ush_1_fu_1170_p3() { ush_1_fu_1170_p3 = (!isNeg_1_fu_1152_p3.read()[0].is_01())? sc_lv<9>(): ((isNeg_1_fu_1152_p3.read()[0].to_bool())? sext_ln1311_2_fu_1166_p1.read(): add_ln339_1_fu_1146_p2.read()); } void checkAxis_2::thread_ush_fu_827_p3() { ush_fu_827_p3 = (!isNeg_fu_809_p3.read()[0].is_01())? sc_lv<9>(): ((isNeg_fu_809_p3.read()[0].to_bool())? sext_ln1311_fu_823_p1.read(): add_ln339_fu_803_p2.read()); } void checkAxis_2::thread_xor_ln22_fu_495_p2() { xor_ln22_fu_495_p2 = (bitcast_ln22_fu_491_p1.read() ^ ap_const_lv32_80000000); } void checkAxis_2::thread_xor_ln49_fu_956_p2() { xor_ln49_fu_956_p2 = (and_ln49_7_fu_950_p2.read() ^ ap_const_lv1_1); } void checkAxis_2::thread_xor_ln50_fu_929_p2() { xor_ln50_fu_929_p2 = (and_ln50_3_fu_923_p2.read() ^ ap_const_lv1_1); } void checkAxis_2::thread_zext_ln1287_1_fu_1186_p1() { zext_ln1287_1_fu_1186_p1 = esl_zext<79,32>(sext_ln1311_3_fu_1178_p1.read()); } void checkAxis_2::thread_zext_ln1287_fu_1061_p1() { zext_ln1287_fu_1061_p1 = esl_zext<79,32>(sext_ln1311_1_fu_1055_p1.read()); } void checkAxis_2::thread_zext_ln339_1_fu_1142_p1() { zext_ln339_1_fu_1142_p1 = esl_zext<9,8>(tmp_V_2_fu_881_p4.read()); } void checkAxis_2::thread_zext_ln339_fu_799_p1() { zext_ln339_fu_799_p1 = esl_zext<9,8>(tmp_V_fu_586_p4.read()); } void checkAxis_2::thread_zext_ln662_1_fu_1210_p1() { zext_ln662_1_fu_1210_p1 = esl_zext<55,1>(tmp_31_fu_1202_p3.read()); } void checkAxis_2::thread_zext_ln662_fu_1085_p1() { zext_ln662_fu_1085_p1 = esl_zext<32,1>(tmp_27_fu_1077_p3.read()); } void checkAxis_2::thread_zext_ln682_1_fu_1138_p1() { zext_ln682_1_fu_1138_p1 = esl_zext<79,25>(mantissa_V_1_fu_1128_p4.read()); } void checkAxis_2::thread_zext_ln682_fu_1051_p1() { zext_ln682_fu_1051_p1 = esl_zext<79,25>(mantissa_V_fu_1042_p4.read()); } void checkAxis_2::thread_zext_ln82_fu_1280_p1() { zext_ln82_fu_1280_p1 = esl_zext<32,6>(shl_ln82_1_fu_1272_p3.read()); } void checkAxis_2::thread_zext_ln97_fu_1289_p1() { zext_ln97_fu_1289_p1 = esl_zext<64,32>(add_ln82_1_fu_1284_p2.read()); } void checkAxis_2::thread_zext_ln98_fu_1322_p1() { zext_ln98_fu_1322_p1 = esl_zext<64,32>(add_ln82_3_fu_1317_p2.read()); } void checkAxis_2::thread_ap_NS_fsm() { switch (ap_CS_fsm.read().to_uint64()) { case 1 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { ap_NS_fsm = ap_ST_fsm_state2; } else { ap_NS_fsm = ap_ST_fsm_state1; } break; case 2 : ap_NS_fsm = ap_ST_fsm_state3; break; case 4 : ap_NS_fsm = ap_ST_fsm_state4; break; case 8 : ap_NS_fsm = ap_ST_fsm_state5; break; case 16 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_ln92_fu_341_p2.read(), ap_const_lv1_1))) { ap_NS_fsm = ap_ST_fsm_state1; } else { ap_NS_fsm = ap_ST_fsm_state6; } break; case 32 : ap_NS_fsm = ap_ST_fsm_state7; break; case 64 : ap_NS_fsm = ap_ST_fsm_state8; break; case 128 : ap_NS_fsm = ap_ST_fsm_state9; break; case 256 : ap_NS_fsm = ap_ST_fsm_state10; break; case 512 : ap_NS_fsm = ap_ST_fsm_state11; break; case 1024 : ap_NS_fsm = ap_ST_fsm_state12; break; case 2048 : ap_NS_fsm = ap_ST_fsm_state13; break; case 4096 : ap_NS_fsm = ap_ST_fsm_state14; break; case 8192 : ap_NS_fsm = ap_ST_fsm_state15; break; case 16384 : ap_NS_fsm = ap_ST_fsm_state16; break; case 32768 : ap_NS_fsm = ap_ST_fsm_state17; break; case 65536 : ap_NS_fsm = ap_ST_fsm_state18; break; case 131072 : ap_NS_fsm = ap_ST_fsm_state19; break; case 262144 : ap_NS_fsm = ap_ST_fsm_state20; break; case 524288 : ap_NS_fsm = ap_ST_fsm_state21; break; case 1048576 : ap_NS_fsm = ap_ST_fsm_state22; break; case 2097152 : ap_NS_fsm = ap_ST_fsm_state23; break; case 4194304 : ap_NS_fsm = ap_ST_fsm_state24; break; case 8388608 : ap_NS_fsm = ap_ST_fsm_state25; break; case 16777216 : ap_NS_fsm = ap_ST_fsm_state26; break; case 33554432 : ap_NS_fsm = ap_ST_fsm_state27; break; case 67108864 : ap_NS_fsm = ap_ST_fsm_state28; break; case 134217728 : ap_NS_fsm = ap_ST_fsm_state29; break; case 268435456 : ap_NS_fsm = ap_ST_fsm_state30; break; case 536870912 : ap_NS_fsm = ap_ST_fsm_state31; break; case 1073741824 : ap_NS_fsm = ap_ST_fsm_state32; break; case 2147483648 : ap_NS_fsm = ap_ST_fsm_state33; break; case 4294967296 : ap_NS_fsm = ap_ST_fsm_state34; break; case 8589934592 : ap_NS_fsm = ap_ST_fsm_state35; break; case 17179869184 : ap_NS_fsm = ap_ST_fsm_state36; break; case 34359738368 : ap_NS_fsm = ap_ST_fsm_state37; break; case 68719476736 : ap_NS_fsm = ap_ST_fsm_state38; break; case 137438953472 : ap_NS_fsm = ap_ST_fsm_state39; break; case 274877906944 : ap_NS_fsm = ap_ST_fsm_state40; break; case 549755813888 : ap_NS_fsm = ap_ST_fsm_state41; break; case 1099511627776 : ap_NS_fsm = ap_ST_fsm_state42; break; case 2199023255552 : ap_NS_fsm = ap_ST_fsm_state43; break; case 4398046511104 : ap_NS_fsm = ap_ST_fsm_state44; break; case 8796093022208 : ap_NS_fsm = ap_ST_fsm_state45; break; case 17592186044416 : ap_NS_fsm = ap_ST_fsm_state46; break; case 35184372088832 : ap_NS_fsm = ap_ST_fsm_state47; break; case 70368744177664 : ap_NS_fsm = ap_ST_fsm_state48; break; case 140737488355328 : ap_NS_fsm = ap_ST_fsm_state49; break; case 281474976710656 : ap_NS_fsm = ap_ST_fsm_state50; break; case 562949953421312 : ap_NS_fsm = ap_ST_fsm_state51; break; case 1125899906842624 : ap_NS_fsm = ap_ST_fsm_state52; break; case 2251799813685248 : ap_NS_fsm = ap_ST_fsm_state53; break; case 4503599627370496 : ap_NS_fsm = ap_ST_fsm_state54; break; case 9007199254740992 : ap_NS_fsm = ap_ST_fsm_state55; break; case 18014398509481984 : ap_NS_fsm = ap_ST_fsm_state56; break; case 36028797018963968 : ap_NS_fsm = ap_ST_fsm_state5; break; default : ap_NS_fsm = (sc_lv<56>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); break; } } }
#include <iostream> using namespace std; class Complex { public: double real, imag; void Print() { cout << real << "," << imag ; } Complex(double r,double i):real(r),imag(i) { } Complex AddOne() { this->real ++; //等价于 real ++; this->Print(); //等价于 Print return * this; } }; int main() { Complex c1(1,1),c2(0,0); c2 = c1.AddOne(); return 0; } //输出 2,1
// Utilities for interacting with a spectrum shield #include "WProgram.h" #include "spectrum.h" const byte c_pinSpectrumStrobe = 4; const byte c_pinSpectrumReset = 5; const byte c_apinSpectrumLeft = 0; const byte c_apinSpectrumRight = 1; int rgSpectrum[c_cBands]; void SetupSpectrum() { // Set the pin modes pinMode(c_pinSpectrumStrobe, OUTPUT); pinMode(c_pinSpectrumStrobe, OUTPUT); // Initialize the spectrum analyzer digitalWrite(c_pinSpectrumStrobe, LOW); delay(1); digitalWrite(c_pinSpectrumReset, HIGH); delay(1); digitalWrite(c_pinSpectrumStrobe, HIGH); delay(1); digitalWrite(c_pinSpectrumStrobe, LOW); delay(1); digitalWrite(c_pinSpectrumReset, LOW); delay(5); } void SampleSpectrum() { for(byte iBand = 0; iBand < c_cBands; iBand++) { int bandValue = 0; // Read both the left and right channel twice and take the average bandValue = analogRead(c_apinSpectrumLeft); bandValue += analogRead(c_apinSpectrumRight); bandValue += analogRead(c_apinSpectrumLeft); bandValue += analogRead(c_apinSpectrumRight); bandValue = bandValue >> 2; rgSpectrum[iBand] = bandValue; // Cycle to the next band digitalWrite(c_pinSpectrumStrobe, HIGH); digitalWrite(c_pinSpectrumStrobe, LOW); } } int ReadBand(int iBand) { int rawValue = 0; if (iBand < 0) { return -1; } if (iBand >= c_cBands) { return -1; } rawValue = rgSpectrum[iBand]; if (rawValue < 100) { return 0; } if (rawValue < 200) { return 1; } else if (rawValue < 300) { return 2; } else if (rawValue < 400) { return 3; } else if (rawValue < 500) { return 4; } else if (rawValue < 600) { return 5; } else if (rawValue < 700) { return 6; } else if (rawValue < 800) { return 7; } else if (rawValue < 900) { return 8; } else { return 9; } }
// This file has been generated by Py++. #ifndef Vertex_hpp__pyplusplus_wrapper #define Vertex_hpp__pyplusplus_wrapper void register_Vertex_class(); #endif//Vertex_hpp__pyplusplus_wrapper
#include<bits/stdc++.h> #include<string.h> using namespace std; void removeConsecutiveDuplicates(char *s) { if(*s == '\0') return ; if( *s == *(s+1) ) { int i; for(i = 1 ; s[i] != '\0'; ++i){ s[i-1] = s[i]; } s[i-1] = s[i]; removeConsecutiveDuplicates(s); } removeConsecutiveDuplicates(s+1); } int main() { ifstream fin("Input.txt", ios::in); char str[5000]; //cin>>str; while(!fin.eof()) fin>>str; removeConsecutiveDuplicates(str); for(int i = 0 ; str[i] != '\0'; i++) cout<<str[i]; return 0; }
// C++ for the Windows Runtime vv1.0.170303.6 // Copyright (c) 2017 Microsoft Corporation. All rights reserved. #pragma once #include "Windows.UI.Xaml.Interop.2.h" WINRT_EXPORT namespace winrt { namespace Windows::UI::Xaml::Interop { template <typename H> struct impl_BindableVectorChangedEventHandler : implements<impl_BindableVectorChangedEventHandler<H>, abi<BindableVectorChangedEventHandler>>, H { impl_BindableVectorChangedEventHandler(H && handler) : H(std::forward<H>(handler)) {} HRESULT __stdcall abi_Invoke(impl::abi_arg_in<Windows::UI::Xaml::Interop::IBindableObservableVector> vector, impl::abi_arg_in<Windows::Foundation::IInspectable> e) noexcept override { try { (*this)(*reinterpret_cast<const Windows::UI::Xaml::Interop::IBindableObservableVector *>(&vector), *reinterpret_cast<const Windows::Foundation::IInspectable *>(&e)); return S_OK; } catch (...) { return impl::to_hresult(); } } }; template <typename H> struct impl_NotifyCollectionChangedEventHandler : implements<impl_NotifyCollectionChangedEventHandler<H>, abi<NotifyCollectionChangedEventHandler>>, H { impl_NotifyCollectionChangedEventHandler(H && handler) : H(std::forward<H>(handler)) {} HRESULT __stdcall abi_Invoke(impl::abi_arg_in<Windows::Foundation::IInspectable> sender, impl::abi_arg_in<Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgs> e) noexcept override { try { (*this)(*reinterpret_cast<const Windows::Foundation::IInspectable *>(&sender), *reinterpret_cast<const Windows::UI::Xaml::Interop::NotifyCollectionChangedEventArgs *>(&e)); return S_OK; } catch (...) { return impl::to_hresult(); } } }; } namespace Windows::UI::Xaml::Interop { struct WINRT_EBO NotifyCollectionChangedEventArgs : Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgs { NotifyCollectionChangedEventArgs(std::nullptr_t) noexcept {} NotifyCollectionChangedEventArgs(Windows::UI::Xaml::Interop::NotifyCollectionChangedAction action, const Windows::UI::Xaml::Interop::IBindableVector & newItems, const Windows::UI::Xaml::Interop::IBindableVector & oldItems, int32_t newIndex, int32_t oldIndex); }; } }
#include "DupRemove.h" void dupRemove(LinkedList list) { list.dupRemove(); cout << "Hi!" << "\n"; list.data(); } void DupRemove::run() { LinkedList list; list.data(); //cout << "Type in a key and I, the almighty Levi will remove it from the linked list.\n"; //getline(cin, input); string input; do { cout << "Press Enter and I, the almighty Levi shall remove the duplicates in this list"; getline(cin, input); } while (input.length() != 0); dupRemove(list); }
#include "tracker.h" #include "nn_matching.h" #include "linear_assignment.h" using namespace std; //#define MY_inner_DEBUG #ifdef MY_inner_DEBUG #include <string> #include <iostream> #endif tracker::tracker(/*NearNeighborDisMetric *metric,*/ float max_cosine_distance, int nn_budget, float max_iou_distance, int max_age, int n_init) { // 使用nn_match的NearNeighborDisMetric(包含partial_fit/distance) // 在match阶段,将distance封装成gated_metric,进行外观信息(深度特征)与运动信息(马氏距离)的计算 this->nnDisMetr_ptr = new NearNeighborDisMetric(NearNeighborDisMetric::METRIC_TYPE::cosine, max_cosine_distance, nn_budget); this->max_iou_distance = max_iou_distance; this->max_age = max_age; this->n_init = n_init; this->tracks.clear(); this->_next_idx = 0; } tracker::~tracker() { delete this->nnDisMetr_ptr; } void tracker::predict(){ // 依次对trk中所有的子trk遍历,逐个预测 for(Track& track:tracks) track.PredictTrack(); } void tracker::update(const DETECTIONS &detections, IDDistributor* IDdis, int index, const HRYTCalibrater cali, const object::TransferType worldtype) { // 一、进行检测结果和跟踪结果的匹配 TRACHER_MATCHD res; _match(detections, res); // 二、根据匹配情况进行后续的追踪器相应模块的更新操作 // (1)针对matched,要用检测结果去更新相应的tracker参数 vector<MATCH_DATA>& matches = res.matches; for(MATCH_DATA& data:matches) { int track_idx = data.first; int detection_idx = data.second; tracks[track_idx].UpdateTrack(detections[detection_idx], cali, worldtype); } // (2)针对unmatched_tracks,如果这个trk是还没有经过确认的,直接从trk列表中删除; // 如果这个是之前经过确认的,但是已经连续max_age帧(程序中设置为10)没能匹配检测结果了,也认为这个trk无效了,需要从trk列表中删除。 vector<int>& unmatched_tracks = res.unmatched_tracks; for(int& track_idx:unmatched_tracks) { this->tracks[track_idx].mark_missed(); } // (3)针对unmatched_detections,要为其创建新的tracker。 vector<int>& unmatched_detections = res.unmatched_detections; for(int& detection_idx:unmatched_detections) { this->_initiate_track(detections[detection_idx], IDdis, index); } vector<Track>::iterator it; vector<int> eraseID; for(it = tracks.begin(); it != tracks.end();) { if((*it).is_deleted()) { eraseID.push_back(it->track_id()); // need to push back first // it = tracks.erase(it); } else{ if(it == tracks.end()) break; ++it; } } IDdis->erase(index, eraseID); #ifdef USE_FEATURE // 三、更新已经确认的trk的特征集模块 // 使用active_targets保存confirmed的track的id // active_targets对应的feature(之前每帧只要能匹配上,都会把与之匹配的det的feature保存下来),用于更新kalman滤波的distance metric vector<int> active_targets; vector<TRACKER_DATA> tid_features; for (Track& track:tracks) { if(track.is_confirmed() == false) continue; active_targets.push_back(track.track_id()); tid_features.push_back(std::make_pair(track.track_id(), track.features())); } // 并且使用partial_fit更新feature集,只保留budget数量的feature,且根据active_targets中的id去掉更改状态的feature集 this->nnDisMetr_ptr->partial_fit(tid_features, active_targets); #endif } // 进行检测结果和跟踪结果的匹配 // 确认trk的状态tentative、confirmed、deleted,级联匹配、iou匹配 void tracker::_match(const DETECTIONS &detections, TRACHER_MATCHD &res) { // 将已经存在tracks分为confirmed_tracks和unconfirmed_tracks vector<int> confirmed_tracks; vector<int> unconfirmed_tracks; int idx = 0; for(Track& t:tracks) { if(t.is_confirmed()) confirmed_tracks.push_back(idx); else unconfirmed_tracks.push_back(idx); idx++; } // 针对之前confirmed_tracks,将它们与当前检测结果detections进行级联匹配 TRACHER_MATCHD matcha = linear_assignment::getInstance()->matching_cascade( this, &tracker::gated_matric, this->nnDisMetr_ptr->mating_threshold, this->max_age, this->tracks, detections, confirmed_tracks); // unconfirmed_tracks和unmatched_tracks一起组成iou_track_candidates vector<int> iou_track_candidates; iou_track_candidates.assign(unconfirmed_tracks.begin(), unconfirmed_tracks.end()); vector<int>::iterator it; for(it = matcha.unmatched_tracks.begin(); it != matcha.unmatched_tracks.end();) { int idx = *it; if(tracks[idx].time_since_update() == 1) { //push into unconfirmed iou_track_candidates.push_back(idx); it = matcha.unmatched_tracks.erase(it); continue; } ++it; } // iou_track_candidates与unmatched_detections进行iou匹配 TRACHER_MATCHD matchb = linear_assignment::getInstance()->min_cost_matching( this, &tracker::iou_cost, this->max_iou_distance, this->tracks, detections, iou_track_candidates, matcha.unmatched_detections); // 合并上述两步的匹配结果,get result: res.matches.assign(matcha.matches.begin(), matcha.matches.end()); res.matches.insert(res.matches.end(), matchb.matches.begin(), matchb.matches.end()); //unmatched_tracks; res.unmatched_tracks.assign( matcha.unmatched_tracks.begin(), matcha.unmatched_tracks.end()); res.unmatched_tracks.insert( res.unmatched_tracks.end(), matchb.unmatched_tracks.begin(), matchb.unmatched_tracks.end()); res.unmatched_detections.assign( matchb.unmatched_detections.begin(), matchb.unmatched_detections.end()); } void tracker::_initiate_track(const DETECTION_ROW &detection, IDDistributor* IDdis, int index) { this->_next_idx = IDdis->get(index); this->tracks.push_back(Track(detection, this->_next_idx, this->n_init, this->max_age)); // 初始化一个新的tracker } DYNAMICM tracker::gated_matric(std::vector<Track> &tracks, const DETECTIONS &dets, const std::vector<int>& track_indices, const std::vector<int>& detection_indices) { #ifdef USE_FEATURE // 外观信息约束——计算当前每个新检测结果的深度特征features与这一level中每个trk已经保存的特征集targets之间的余弦距离矩阵 FEATURESS features(detection_indices.size(), feature_dims); int pos = 0; for(int i:detection_indices) { features.row(pos++) = dets[i].feature; } targets.clear(); for(int i:track_indices) { targets.push_back(tracks[i].track_id()); } DYNAMICM cost_matrix = this->nnDisMetr_ptr->distance(features, targets); // 真正开始计算余弦距离 #else DYNAMICM cost_matrix = Eigen::MatrixXf::Zero(track_indices.size(), detection_indices.size()); #endif // 运动信息约束——Mahalanobis distance距离 linear_assignment::getInstance()->gate_cost_matrix(cost_matrix, tracks, dets, track_indices, detection_indices); return cost_matrix; // 此时的cost_matrix包含了以上两个信息 } DYNAMICM tracker::iou_cost(std::vector<Track> &tracks, const DETECTIONS &dets, const std::vector<int>& track_indices, const std::vector<int>& detection_indices){ // 计算iou_track_candidates和unmatched_detections里的框两两之间的iou,经由1-iou的到cost_matric //!!!python diff: track_indices && detection_indices will never be None. // if(track_indices.empty() == true) { // for(size_t i = 0; i < tracks.size(); i++) { // track_indices.push_back(i); // } // } // if(detection_indices.empty() == true) { // for(size_t i = 0; i < dets.size(); i++) { // detection_indices.push_back(i); // } // } int rows = track_indices.size(); int cols = detection_indices.size(); DYNAMICM cost_matrix = Eigen::MatrixXf::Zero(rows, cols); for(int i = 0; i < rows; i++) { int track_idx = track_indices[i]; if(tracks[track_idx].time_since_update() > 1) { cost_matrix.row(i) = Eigen::RowVectorXf::Constant(cols, INFTY_COST); continue; } DETECTBOX bbox = tracks[track_idx].to_tlwh(); int csize = detection_indices.size(); DETECTBOXSS candidates(csize, 4); for(int k = 0; k < csize; k++) candidates.row(k) = dets[detection_indices[k]].tlwh; // 经由1-iou得到cost_matric(阈值处理) Eigen::RowVectorXf rowV = (1. - iou(bbox, candidates).array()).matrix().transpose(); cost_matrix.row(i) = rowV; } return cost_matrix; } Eigen::VectorXf tracker::iou(DETECTBOX& bbox, DETECTBOXSS& candidates) { float bbox_tl_1 = bbox[0]; float bbox_tl_2 = bbox[1]; float bbox_br_1 = bbox[0] + bbox[2]; float bbox_br_2 = bbox[1] + bbox[3]; float area_bbox = bbox[2] * bbox[3]; Eigen::Matrix<float, -1, 2> candidates_tl; Eigen::Matrix<float, -1, 2> candidates_br; candidates_tl = candidates.leftCols(2) ; candidates_br = candidates.rightCols(2) + candidates_tl; int size = int(candidates.rows()); // Eigen::VectorXf area_intersection(size); // Eigen::VectorXf area_candidates(size); Eigen::VectorXf res(size); for(int i = 0; i < size; i++) { float tl_1 = std::max(bbox_tl_1, candidates_tl(i, 0)); float tl_2 = std::max(bbox_tl_2, candidates_tl(i, 1)); float br_1 = std::min(bbox_br_1, candidates_br(i, 0)); float br_2 = std::min(bbox_br_2, candidates_br(i, 1)); float w = br_1 - tl_1; w = (w < 0? 0: w); float h = br_2 - tl_2; h = (h < 0? 0: h); float area_intersection = w * h; float area_candidates = candidates(i, 2) * candidates(i, 3); res[i] = area_intersection/(area_bbox + area_candidates - area_intersection); } //#ifdef MY_inner_DEBUG // std::cout << res << std::endl; //#endif return res; }
#include <ivex/Extraction.hpp> #include <catch2/catch.hpp> using namespace ivex; TEST_CASE("Extraction") { // Empty }
class ISplitter { public: virtual void split()=0; virtual ~ISplitter(){} }; class BinarySplitter:public ISplitter { }; class TxtSplitter:public ISplitter { }; class PictureSplitter:public ISplitter { }; class VideoSplitter:public ISplitter { };
#include "MaximumProductSubarray.hpp" using namespace std; int MaximumProductSubarray::maxProduct(vector<int> &nums) { int n = nums.size(); if (n == 0) return 0; vector<int> a(n, 0); vector<int> b(n, 0); a[0] = b[0] = nums[0]; for (int i = 1; i < n; i++) { int v1 = nums[i]; int v2 = a[i - 1] * nums[i]; int v3 = b[i - 1] * nums[i]; a[i] = max(v1, max(v2, v3)); b[i] = min(v1, min(v2, v3)); } int ret = a[0]; for (int i = 1; i < n; i++) ret = max(ret, a[i]); return ret; }
#include "edge.hpp" #include "node.hpp" #include "graphwidget.hpp" #include <QtGui/QGraphicsScene> #include <QtGui/QGraphicsSceneMouseEvent> #include <QtGui/QPainter> #include <QtGui/QStyleOption> Node::Node(GraphWidget *graphWidget, qreal radius) : m_graphWidget(graphWidget) , m_radius(radius) { setFlag(ItemIsMovable); setFlag(ItemSendsGeometryChanges); setFlag(ItemIsSelectable); setAcceptHoverEvents(true); setCacheMode(DeviceCoordinateCache); setZValue(10); // higher than the edge } void Node::addEdge(Edge *edge) { edgeList << edge; edge->adjust(); } void Node::removeEdge(Edge* edge) { edgeList.removeAll(edge); } QList<Edge *> Node::edges() const { return edgeList; } Edge* Node::edgeTo(const Node* n) const { for (int i = 0; i < edgeList.size(); ++i) { Edge* e = edgeList.at(i); if (e->destNode() == n) return e; } return 0; } QRectF Node::boundingRect() const { const qreal adjust = 0; return QRectF( -m_radius - adjust, -m_radius - adjust, m_radius*2 + adjust, m_radius*2 + adjust); } QPainterPath Node::shape() const { QPainterPath path; path.addEllipse(-m_radius, -m_radius, m_radius*2, m_radius*2); return path; } void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem* option, QWidget *) { if (isSelected()) { painter->setBrush(Qt::red); } else if (option->state & QStyle::State_MouseOver) { painter->setBrush(Qt::green); } else { painter->setBrush(Qt::yellow); } painter->setPen(QPen(Qt::black, 0)); painter->drawEllipse(QRectF( -m_radius, -m_radius, m_radius*2, m_radius*2)); } QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) { switch (change) { case ItemPositionChange: { foreach (Edge *edge, edgeList) edge->adjust(); const QPointF old_pos = pos(); const QPointF new_pos = value.toPointF(); m_graphWidget->itemMoved(old_pos, new_pos); break; } default: break; }; return QGraphicsItem::itemChange(change, value); } void Node::mousePressEvent(QGraphicsSceneMouseEvent *event) { update(); QGraphicsItem::mousePressEvent(event); } void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { update(); QGraphicsItem::mouseReleaseEvent(event); }
#include <iostream> using namespace std; int i = 0; int fun(int n) { static int k=2; k++ return (++k)*(n++); } int main() { int k=5; { int i = 2; k+=fun(i); } k+=fun(i); cout<<k<<endl; return 0; }
#pragma once #include <QOpenGLWidget> #include <QVector3D> #include <QPushButton> #include <QRadioButton> #include "polygon3p.h" class MyGLWidget : public QOpenGLWidget { Q_OBJECT QPushButton *makeNew = nullptr; QRadioButton *onlyVisible = nullptr; QVector<polygon3p> endPolygons{}; QVector<polygon3p> startPolygons{}; bool drawOnlyVisible = false; QVector3D colors[5] = {{1.0, 0.0, 0.0},//1. red {0.0, 1.0, 0.0},// 2. green {0.0, 0.0, 1.0},// 3. blue {0.0, 0.0, 0.0},// 4. black {1.0, 1.0, 1.0}};//5. white void scene(); void drawPolygon(const polygon3p &p); public: MyGLWidget(QWidget *parent = nullptr); ~MyGLWidget() override; void setPolygons(const QVector<polygon3p> &start, const QVector<polygon3p> &end); protected: void initializeGL() override; void resizeGL(int w, int h) override; void paintGL() override; void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); signals: void generatePyramid(); private slots: void upd(); };
#include "PosicionUsuario.hpp" PosicionUsuario::PosicionUsuario(double* lat,double* lon ,int* id ) {//Contructor lat es latitud lon longitud id es idusuario latitud = *lat; longitud = *lon; usuario_id = *id; } PosicionUsuario::PosicionUsuario(std::string* rpl){ Json::Reader readerJson; Json::Value posicion; // Se realiza la conversión del archivo Json a Objeto if(!readerJson.parse(*rpl,posicion)) // Se verifica que se realice correctamente la conversion { std::cout << "Error en la conversión de documento Json a Objeto Json\n" << readerJson.getFormattedErrorMessages(); } // Se obtiene el valor de cada par "clave":"valor", se convierte a string y luego al correspondiente // tipo de dato ,-75.5714428 latitud = std::stod(posicion.get("latitud", "\"6.2652965\"" ).asString()); longitud = std::stod(posicion.get("longitud", "\"-75.5714428\"" ).asString()); usuario_id = std::stoi(posicion.get("idUsuario", "Not Found" ).asString()); } // Retorna la posición en formato Json void PosicionUsuario::getPosicionUsuarioJson(std::string* posJson) { Json::Value root; // Objeto que almacena la estructura Json Json::FastWriter writer; //Conversor de Objeto Json a String Json // En el objeto json se crean campos "clave":"valor" root["idUsuario"] = usuario_id; root["longitud"] = longitud; root["latitud"] = latitud; // Se convierte el Objeto Json a formato String *posJson = writer.write(root); } // Actualiza la posición bool PosicionUsuario::actualizarPosicion(PosicionUsuario* posActualizar){ longitud = posActualizar->getLongitud(); latitud = posActualizar->getLatitud(); return true; } int PosicionUsuario::getIdUsuario(){ return usuario_id; } double PosicionUsuario::getLatitud(){ return latitud; } double PosicionUsuario::getLongitud(){ return longitud; } /*PosicionJugador::~PosicionJugador() { }*/
#include<stdio.h> #include<stdlib.h> /* 13130110075_Í▄Ë╬practice1 2ú« Implement priority queue. */ typedef struct Node{ int key; int value; struct Node* next; }; int showQueue(Node*); Node* insert(Node*,Node*); Node* maximum(Node*); Node* extract_max(Node**); Node* increase_key(Node*,Node*,int); Node* getNode(Node*,int); int main(){ Node* head=(Node*)malloc(sizeof(Node)); head->next=NULL; head->value=0; head->key=1; showQueue(head); printf("how many node entry (key,value) will you input ?\n"); int num=0; scanf("%d",&num); int i=0; for(;i<num;++i){ Node* node=(Node*)malloc(sizeof(Node)); node->next=NULL; printf("(key,value)= ?\n"); scanf("%d %d",&(node->key),&(node->value)); head=insert(head,node); } showQueue(head); Node* max=maximum(head); printf("\n--------------test maximum\nmax entry is (key, value)=(%d , %d)\n",max->key,max->value); printf("please input x->key and k \n------------test increased key\n"); int xk,k; scanf("%d %d",&xk,&k); Node* x=getNode(head,xk); if(x==NULL){ printf("--------> get x Node failed\n"); exit(0); } head=increase_key(head,x,k); showQueue(head); printf("\n\n------test extract max\n"); Node* emax=extract_max(&head); printf(" the extracted max entry is (%d,%d), the rest queue is \n",emax->key,emax->value); showQueue(head); system("PAUSE"); return 0; } Node* getNode(Node* head,int key){ if(head==NULL) return NULL; if(head->key==key) return head; while(head->next!=NULL) { head=head->next; if(head->key==key) return head; } return NULL; } int showQueue(Node* head){// show the infomation include head node if(head==NULL) return -1; while(head->next!=NULL){ printf("key= %d ,value= %d \n",head->key,head->value); head=head->next; } printf("key= %d ,value= %d \n",head->key,head->value); return 1; } // ascending return head of priority queue Node* insert(Node* head,Node* node){ if(head==NULL||node==NULL) return NULL; Node* h=head;// h is for save the head of queue Node* temp=head; if(node->key>head->key){// node is the head of the queue node->next=head; return node; } while(head->next!=NULL){ temp=head; head=head->next; if(node->key>head->key){ node->next=head; temp->next=node; return h; } } head->next=node;// node is the tail of the queue return h; } Node* maximum(Node* head){ if(head==NULL) return NULL; return head; } Node* extract_max(Node** head){// return the hightest key and delete it Node* temp=*head; (*head)=(*head)->next; return temp; } Node* increase_key(Node* head,Node* x,int key){// x->key will turn into key if(key<(x->key)) { printf("illegel key \n"); return NULL; } Node* h=head; x->key=key; if(head==x) return head;// if x if the head ,do nothing ! because key is the max while(head->next!=NULL){ if(head->next==x) { head->next = head->next->next;//delete x break; } head=head->next; } h=insert(h,x); return h; }
#include<bits/stdc++.h> using namespace std; #define ll long long double area, r; int main() { ll m, n,i ,j, p; cin>>n>>m; vector<pair<double, ll>>v; for(i=0;i<n;i++) { double x, y; cin>>x>>y>>p; v.push_back({ sqrt(x*x+y*y) , p}); } sort(v.begin(), v.end()); for(i=0;i<n;i++) { if(m>=1000000)break; m+=v[i].second; r=v[i].first; } if(m>=1000000)printf("%.10llf\n", r); else cout<<-1<<endl; }
#pragma once #include<iostream> #include<windows.h> #include<map> #include<functional> #include<string> #include<sstream> #include<memory> class WindowManager; class Window; class winApp; enum fullScreen { WINDOW, FULLSCREEN }; class WindowManager { public: static Window & Instance(); static Window * pointer(); static winApp & App(); static winApp * App_pointer(); static void setInst(Window *); static void setApp(winApp *); private: static Window* instance; static winApp* app; static void unsetInst() { if (nullptr != instance) { delete instance; } instance = nullptr; } static void unsetApp() { if (nullptr != app) { delete app; } app = nullptr; } }; class Window{ friend void WindowsLoop(); public: Window(LPCWSTR className, LPCWSTR title, int width, int height, int bits, fullScreen fullscreenflag) :className(className), title(title), width(width), height(height), bits(bits), fullscreen(fullscreenflag) { WindowManager::setInst(this); } Window() { WindowManager::setInst(this); } virtual ~Window() { KillWindow(); } BOOL Create3DWindow(); virtual void KillWindow(); virtual void ReSizeScene(); static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); void setFPS(int fps) { if (0==fps) { refreshRate = 0; } refreshRate = (100 / fps)*10; } void SetKeyFunction(int key, void(*fp)()) { keyEvent[key] = fp; } void SetKeyFunction(char key, void(*fp)()) { keyEvent[toupper(key)] = fp; } void SetKeyDownEvent(int key, void(*fp)()) { keyDownEvent[key] = fp; } void SetKeyDownEvent(char key, void(*fp)()) { keyDownEvent[toupper(key)] = fp; } int GetKey(int key) { return keys[key]; } int GetWidth() { return width; } int GetHeight() { return height; } HDC GetHDC() { return hDC; } HDC hDC = NULL; //渲染描述表句柄 HWND hWnd = NULL; HBITMAP screen_hb = NULL; // DIB HBITMAP screen_ob = NULL; // 老的 BITMAP HINSTANCE hInstance = NULL; int bits = 32; bool keys[256]; // 保存键盘按键的数组 LPCWSTR title = L"DefaultTitle", className = L"DefaultClassName"; int width = 800, height = 600; fullScreen fullscreen = WINDOW; bool active = TRUE; virtual void befShowWindow() {}; private: DWORD tPre = 0; unsigned int refreshRate = 0; std::map<int, std::function<void()>> keyEvent; std::map<int, std::function<void()>> keyDownEvent; void Window::ReSizeScene(WORD, WORD); virtual void SwapBuf(); }; class winApp { public: winApp() { WindowManager::setApp(this); } virtual ~winApp() {} virtual void DrawScene() {}; virtual void initialization() {}; virtual void initData() {}; virtual void ReSizeScene() {}; inline void SetKeyFunction(int key, void(*fp)()) { (WindowManager::Instance()).SetKeyFunction(key, fp); } inline void SetKeyFunction(char key, void(*fp)()) { (WindowManager::Instance()).SetKeyFunction(key, fp); } inline void SetKeyDownEvent(int key, void(*fp)()) { (WindowManager::Instance()).SetKeyDownEvent(key, fp); } inline void SetKeyDownEvent(char key, void(*fp)()) { (WindowManager::Instance()).SetKeyDownEvent(key, fp); } };
#include "drake/examples/allegro_hand/allegro_common.h" namespace drake { namespace examples { namespace allegro_hand { const double AllegroHandMotionState::velocity_thresh_ = 0.07; void SetPositionControlledGains(Eigen::VectorXd* Kp, Eigen::VectorXd* Ki, Eigen::VectorXd* Kd) { *Kp = Eigen::VectorXd::Ones(kAllegroNumJoints) * 0.05; *Kd = Eigen::VectorXd::Constant(Kp->size(), 5e-3); (*Kp)[0] = 0.08; *Ki = Eigen::VectorXd::Zero(kAllegroNumJoints); } std::map<std::string, int> GetJointNameMapping() { std::map<std::string, int> joint_name_mapping; // Thumb finger joint_name_mapping["joint_12"] = 0; joint_name_mapping["joint_13"] = 1; joint_name_mapping["joint_14"] = 2; joint_name_mapping["joint_15"] = 3; // Index finger joint_name_mapping["joint_0"] = 4; joint_name_mapping["joint_1"] = 5; joint_name_mapping["joint_2"] = 6; joint_name_mapping["joint_3"] = 7; // Middle finger joint_name_mapping["joint_4"] = 8; joint_name_mapping["joint_5"] = 9; joint_name_mapping["joint_6"] = 10; joint_name_mapping["joint_7"] = 11; // Ring finger joint_name_mapping["joint_8"] = 12; joint_name_mapping["joint_9"] = 13; joint_name_mapping["joint_10"] = 14; joint_name_mapping["joint_11"] = 15; return joint_name_mapping; } // TODO (WenzhenYuan-TRI): Merge this function with the updated functions in // multibody plant (#9455) void GetControlPortMapping( const multibody::multibody_plant::MultibodyPlant<double>& plant, MatrixX<double>* Px, MatrixX<double>* Py) { std::map<std::string, int> joint_name_mapping = GetJointNameMapping(); const int num_plant_positions = plant.num_positions(); // Projection matrix. We include "all" dofs in the hand. // x_tilde = Px * x; where: x is the state in the MBP; x_tilde is the state // in the desired order. Px->resize(kAllegroNumJoints * 2, plant.num_multibody_states()); Px->setZero(); for (std::map<std::string, int>::iterator it = joint_name_mapping.begin(); it != joint_name_mapping.end(); it++) { const auto& joint = plant.GetJointByName(it->first); const int q_index = joint.position_start(); const int v_index = joint.velocity_start(); (*Px)(it->second, q_index) = 1.0; (*Px)(kAllegroNumJoints + it->second, num_plant_positions + v_index) = 1.0; } // Build the projection matrix Py for the PID controller. Maps u_c from the // controller into u for the MBP, that is, u = Py * u_c where: // u_c is the output from the PID controller in our prefered order. // u is the output as require by the MBP. Py->resize(plant.num_actuated_dofs(), kAllegroNumJoints); Py->setZero(); for (multibody::JointActuatorIndex actuator_index(0); actuator_index < plant.num_actuated_dofs(); ++actuator_index) { const auto& actuator = plant.tree().get_joint_actuator(actuator_index); const auto& joint = actuator.joint(); if (joint_name_mapping.find(joint.name()) != joint_name_mapping.end()) (*Py)(actuator_index, joint_name_mapping[joint.name()]) = 1.0; } } AllegroHandMotionState::AllegroHandMotionState() : finger_num_(allegro_num_joints_ / 4), is_joint_stuck_(allegro_num_joints_), is_finger_stuck_(finger_num_) {} void AllegroHandMotionState::Update( const lcmt_allegro_status& allegro_state_msg) { const lcmt_allegro_status status = allegro_state_msg; const double* ptr = &(status.joint_velocity_estimated[0]); const Eigen::ArrayXd joint_velocity = Eigen::Map<const Eigen::ArrayXd>(ptr, allegro_num_joints_); const Eigen::ArrayXd torque_command = Eigen::Map<const Eigen::ArrayXd>( &(status.joint_torque_commanded[0]), allegro_num_joints_); is_joint_stuck_ = joint_velocity.abs() < velocity_thresh_; // Detect whether the joint is moving in the opposite direction of the // command. If yes, it is most likely the joint is stuck. Eigen::Array<bool, Eigen::Dynamic, 1> motor_reverse = (joint_velocity * torque_command) < -0.001; is_joint_stuck_ += motor_reverse; is_finger_stuck_.setZero(); if (is_joint_stuck_.segment<4>(0).all()) is_finger_stuck_(0) = true; if (is_joint_stuck_.segment<3>(5).all()) is_finger_stuck_(1) = true; if (is_joint_stuck_.segment<3>(9).all()) is_finger_stuck_(2) = true; if (is_joint_stuck_.segment<3>(13).all()) is_finger_stuck_(3) = true; if (motor_reverse.segment<3>(5).any()) is_finger_stuck_(1) = true; if (motor_reverse.segment<3>(9).any()) is_finger_stuck_(2) = true; if (motor_reverse.segment<3>(13).any()) is_finger_stuck_(3) = true; } Eigen::Vector4d AllegroHandMotionState::FingerGraspJointPosition( int finger_index) const { Eigen::Vector4d position; // The numbers corresponds to the joint positions when the hand grasps a // medium size object, such as the mug. The final positions of the joints // are usually larger than the preset values, so that the fingers continously // apply force on the object. if (finger_index == 0) position << 1.396, 0.85, 0, 1.3; else if (finger_index == 1) position << 0.08, 0.9, 0.75, 1.5; else if (finger_index == 2) position << 0.1, 0.9, 0.75, 1.5; else position << 0.12, 0.9, 0.75, 1.5; return position; } Eigen::Vector4d AllegroHandMotionState::FingerOpenJointPosition( int finger_index) const { Eigen::Vector4d position; // The preset postion of the joints when the hand is open. The thumb joints // are not at 0 positions, so that it starts from the lower limit, and faces // upward. position.setZero(); if (finger_index == 0) position << 0.263, 1.1, 0, 0; return position; } } // namespace allegro_hand } // namespace examples } // namespace drake
#include<bits/stdc++.h> #include<stdio.h> using namespace std; #define ll long long int main() { ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; cin>>n; for(i=0; i<n; i++) { cin>>k>>x; cout<<(x+9*(k-1) )<<endl; } return 0; }
#include "stdafx.h" #include "Casa.h" void Casa::actualizarMatrizModelo() { modelo = mat4(1.0f); modelo = translate(modelo, coordenadas); modelo = rotate(modelo, -1.5708f, vec3(0.0f, -0.10f, 0.0f)); modelo = scale(modelo, vec3(10.0f, 6.0f, 6.0f)); } vec3 Casa::getCoordenadas() { return coordenadas; } Casa::Casa() { //=============================== C A S A ========================================== // //Techo vertices.push_back({ vec4(-0.5f, 0.8f, -0.7f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.8f, -0.7f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.8f, 0.5f, -0.7f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.8f, 0.5f, -0.7f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, 0.8f, -2.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.8f, -2.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.8f, 0.5f, -2.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.8f, 0.5f, -2.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, 0.8f, -0.7f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, 0.8f, -2.0f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.8f, 0.5f, -2.0f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.8f, 0.5f, -0.7f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.8f, -0.7f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.8f, -2.0f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.8f, 0.5f, -2.0f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.8f, 0.5f, -0.7f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, 0.8f, -0.7f, 1.0f), vec4(0.7f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, 0.8f, -2.0f, 1.0f), vec4(0.7f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.8f, -2.0f, 1.0f), vec4(0.7f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.8f, -0.7f, 1.0f), vec4(0.7f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.8f, 0.5f, -0.7f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.8f, 0.5f, -2.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.8f, 0.5f, -2.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.8f, 0.5f, -0.7f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f) }); //base vertices.push_back({ vec4(-0.5f, 0.5f, -0.7f, 1.0f), vec4(1.0f, 0.7f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.5f, -0.7f, 1.0f), vec4(1.0f, 0.7f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, -0.5f, -0.7f, 1.0f), vec4(1.0f, 0.7f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, -0.5f, -0.7f, 1.0f), vec4(1.0f, 0.7f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, 0.5f, -2.0f, 1.0f), vec4(1.0f, 0.7f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.5f, -2.0f, 1.0f), vec4(1.0f, 0.7f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, -0.5f, -2.0f, 1.0f), vec4(1.0f, 0.7f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, -0.5f, -2.0f, 1.0f), vec4(1.0f, 0.7f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, 0.5f, -0.7f, 1.0f), vec4(1.0f, 0.5f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, 0.5f, -2.0f, 1.0f), vec4(1.0f, 0.5f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, -0.5f, -2.0f, 1.0f), vec4(1.0f, 0.5f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, -0.5f, -0.7f, 1.0f), vec4(1.0f, 0.5f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.5f, -0.7f, 1.0f), vec4(1.0f, 0.5f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, 0.5f, -2.0f, 1.0f), vec4(1.0f, 0.5f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, -0.5f, -2.0f, 1.0f), vec4(1.0f, 0.5f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, -0.5f, -0.7f, 1.0f), vec4(1.0f, 0.5f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, -0.5f, -0.7f, 1.0f), vec4(1.0f, 0.3f, 0.0f, 1.0f) }); vertices.push_back({ vec4(0.5f, -0.5f, -2.0f, 1.0f), vec4(1.0f, 0.3f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, -0.5f, -2.0f, 1.0f), vec4(1.0f, 0.3f, 0.0f, 1.0f) }); vertices.push_back({ vec4(-0.5f, -0.5f, -0.7f, 1.0f), vec4(1.0f, 0.3f, 0.0f, 1.0f) }); /* HITBOX //izquierda vertices.push_back({ vec4(-0.8f, 0.8f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, 0.8f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, -0.5f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(-0.8f, -0.5f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); //derecha vertices.push_back({ vec4(-0.8f, 0.8f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, 0.8f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, -0.5f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(-0.8f, -0.5f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); //arriba vertices.push_back({ vec4(-0.8f, 0.8f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, 0.8f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, 0.8f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(-0.8f, 0.8f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); //abajo vertices.push_back({ vec4(-0.8f, -0.5f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, -0.5f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, -0.5f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(-0.8f, -0.5f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); //atras vertices.push_back({ vec4(-0.8f, 0.8f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(-0.8f, 0.8f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(-0.8f, -0.5f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(-0.8f, -0.5f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); //enfrente vertices.push_back({ vec4(0.8f, 0.8f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, 0.8f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, -0.5f, -0.7f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) }); vertices.push_back({ vec4(0.8f, -0.5f, -2.0f, 1.0f),vec4((float(rand() % 101)) / 100,(float(rand() % 101)) / 100,(float(rand() % 101)) / 100, 0.0f) });*/ actualizarMatrizModelo(); }
#include <bits/stdc++.h> using namespace std; int main(){ int t; scanf("%d",&t); while (t--){ int n; scanf("%d",&n); int a[n]; for (int i=0;i<n;i++){ scanf("%d",&a[i]); } long long int sum = 0; int c =1; for (int i=0;i<n;i++){ sum+=((c-n)*a[i]); c+=2; } cout << sum << endl; } return 0; }
#include "patch_secret_arg.hpp" #include <landstalker-lib/model/world.hpp> #include <landstalker-lib/model/map.hpp> #include <landstalker-lib/model/entity.hpp> #include <landstalker-lib/model/item.hpp> #include <landstalker-lib/tools/game_text.hpp> #include <landstalker-lib/constants/entity_type_codes.hpp> #include <landstalker-lib/constants/map_codes.hpp> #include <landstalker-lib/constants/item_codes.hpp> #include <landstalker-lib/constants/offsets.hpp> #include "../../assets/secret_arg_music_bank.bin.hxx" #include "../../constants/rando_constants.hpp" #include "../../logic_model/randomizer_world.hpp" // =========================== GNOME HANDLING =========================== constexpr uint8_t GNOME_TEXT = 0x1A; // Replaces Ludwig static ByteArray gnome_text_map_ids_table; static ByteArray gnome_command_words_table; static uint32_t inject_func_gnome_text(md::ROM& rom, uint32_t gnome_map_ids_addr, uint32_t gnome_command_words_block) { md::Code func; func.movem_to_stack({ reg_D0, reg_D1, reg_D2 }, { reg_A0 }); { func.movew(addr_(0xFF1206), reg_D2); func.movew(0x0001, reg_D0); func.lea(gnome_map_ids_addr, reg_A0); func.label("loop_start"); { func.movew(addr_(reg_A0), reg_D1); func.bmi("return"); // D1 = 0xFFFF, reached end of list without finding the appropriate map func.cmpw(reg_D1, reg_D2); func.bne("map_not_found"); { // Right map found func.lea(gnome_command_words_block, reg_A0); func.jsr(0x253F8); // RunTextCmd function func.trap(0, { 0x00, 0x74 }); func.bra("return"); } func.label("map_not_found"); // Not the right map, point on next value and loop back func.adda(0x2, reg_A0); func.addqw(0x4, reg_D0); func.bra("loop_start"); } } func.label("return"); func.movem_from_stack({ reg_D0, reg_D1, reg_D2 }, { reg_A0 }); func.rts(); return rom.inject_code(func); } static void add_gnome_text(Map* map, World& world, const Flag& gnome_flag, const std::string& text) { gnome_text_map_ids_table.add_word(map->id()); map->speaker_ids().emplace_back(GNOME_TEXT); uint16_t text_id = world.first_empty_game_string_id(0x4D); world.game_strings()[text_id] = text; gnome_command_words_table.add_word(0x1400 | (gnome_flag.byte << 3) | gnome_flag.bit); gnome_command_words_table.add_word(0xE000 | ((text_id - 0x4D) & 0x1FFF)); } // =========================== WORLD EDITS =========================== static MapPalette* build_blue_palace_palette(World& world) { MapPalette* pal = new MapPalette(*world.map_palette(31)); pal->at(0) = Color(0x20, 0x20, 0xC0); pal->at(1) = Color(0x60, 0x60, 0xC0); pal->at(2) = Color(0xA0, 0xA0, 0xC0); pal->at(4) = Color(0x40, 0x00, 0x40); pal->at(11) = Color(0x80, 0x80, 0x00); pal->at(12) = Color(0xC0, 0xE0, 0x00); world.add_map_palette(pal); return pal; } static MapPalette* build_blue_shrine_palette(World& world) { MapPalette* pal = new MapPalette(*world.map(MAP_LAKE_SHRINE_SAVE_ROOM)->palette()); pal->at(1) = Color(0x20, 0x20, 0x60); pal->at(2) = Color(0x20, 0x40, 0x80); pal->at(3) = Color(0x40, 0x60, 0xA0); pal->at(5) = Color(0x20, 0x20, 0x40); pal->at(8) = Color(0x20, 0x60, 0x80); world.add_map_palette(pal); return pal; } static void add_foxy_in_knt(RandomizerWorld& world) { Map* map = world.map(MAP_PILLAR_HALLWAY_TO_NOLE); Entity* foxy = new Entity({ .type_id = ENTITY_NPC_MAGIC_FOX, .position = Position(0x10, 0x2A, 0), .orientation = ENTITY_ORIENTATION_SW }); map->add_entity(foxy); world.add_custom_dialogue_raw(foxy, "Foxy: What you are about to\naccomplish is grand, but can\nyou feel there is more to it?\x1e\n" "This island hides a bigger\nmystery, something that has\nyet to be solved...\x1e\n" "Perhaps you should take a\ncloser look at the\ncrypt of Mercator.\x03"); } static Map* add_room_1(RandomizerWorld& world, MapPalette* pal) { // Modify the first room of the Crypt as the entrance of the ARG dungeon Map* map = world.map(MAP_SECRET_1); map->clear_entities(); map->layout(world.map(MAP_KN_PALACE_124)->layout()); map->blockset(world.map(MAP_KN_PALACE_124)->blockset()); map->palette(pal); map->background_music(10); world.map_connection(MAP_CRYPT_MAIN_HALL, map->id()).position_for_map(map->id(), 27, 23); // Add a Nole NPC explaining the riddle Entity* nole_npc = new Entity({ .type_id = ENEMY_NOLE, .position = Position(0x13, 0x19, 0x2, true, true, false), .orientation = ENTITY_ORIENTATION_SE, .palette = 1 }); nole_npc->fightable(false); nole_npc->behavior_id(0); nole_npc->remove_when_flag_is_set(FLAG_ALL_VALID_EQUIPMENTS); map->add_entity(nole_npc); world.add_custom_dialogue_raw(nole_npc, "Nole: A LONG TIME AGO, A DRAGON\nNAMED GOLA CAST A SPELL ON ME.\x1e\n" "I KNOW YOU DEFEATED ME IN\nMANY OTHER WORLDS, AS MY CURSE\nIS TO SEE AND REMEMBER THEM ALL.\x1e\n" "ONLY YOU CAN END THIS, BUT\nTO GO ANY FURTHER, YOU WILL NEED\nTHE RIGHT TOOLS FOR THE JOB.\x03"); // Add boulders that "explain" the equipments to put on Entity* first_boulder = new Entity({ .type_id = ENTITY_SMALL_GRAY_BOULDER, .position = Position(0x0F, 0x15, 0x7, true), .palette = 2 }); map->add_entity(first_boulder); map->add_entity(new Entity({ .type_id = ENTITY_SMALL_RED_BOULDER, .position = Position(0x10, 0x15, 0x7, true), .palette = 1, .entity_to_use_tiles_from = first_boulder })); map->add_entity(new Entity({ .type_id = ENTITY_SMALL_GRAY_BOULDER, .position = Position(0x13, 0x15, 0x7), .palette = 2, .entity_to_use_tiles_from = first_boulder })); map->add_entity(new Entity({ .type_id = ENTITY_SMALL_GRAY_BOULDER, .position = Position(0x15, 0x15, 0x7, true), .palette = 2, .entity_to_use_tiles_from = first_boulder })); map->add_entity(new Entity({ .type_id = ENTITY_SMALL_GRAY_BOULDER, .position = Position(0x16, 0x15, 0x7, true), .palette = 2, .entity_to_use_tiles_from = first_boulder })); map->add_entity(new Entity({ .type_id = ENTITY_SMALL_RED_BOULDER, .position = Position(0x19, 0x15, 0x7), .palette = 1, .entity_to_use_tiles_from = first_boulder })); // Add a blocking platform that disappears when riddle is solved Entity* blocking_platform = new Entity({ .type_id = ENTITY_LARGE_DARK_PLATFORM, .position = Position(0x10, 0x1C, 0x1, true, true, false), .palette = 0 }); blocking_platform->remove_when_flag_is_set(FLAG_ALL_VALID_EQUIPMENTS); map->add_entity(blocking_platform); return map; } static Map* add_room_2(RandomizerWorld& world, MapPalette* pal) { Map* map = world.map(MAP_SECRET_2); map->visited_flag(Flag(0xC0, 0)); map->layout(world.map(MAP_KN_PALACE_116)->layout()); map->blockset(world.map(MAP_KN_PALACE_116)->blockset()); map->palette(pal); map->background_music(10); Entity* spell_book = new Entity({ .type_id = 0xC0 + ITEM_SPELL_BOOK, .position = Position(0x10, 0x19, 0x1, true, true, false), .liftable = true }); map->add_entity(spell_book); Entity* death_statue = new Entity({ .type_id = 0xC0 + ITEM_DEATH_STATUE, .position = Position(0x10, 0x13, 0x1, true, true, false), .liftable = true }); map->add_entity(death_statue); return map; } static Map* add_room_3(RandomizerWorld& world, MapPalette* pal) { Map* map = world.map(MAP_SECRET_3); map->visited_flag(Flag(0xC0, 0)); map->layout(world.map(MAP_KN_PALACE_130)->layout()); map->blockset(world.map(MAP_KN_PALACE_130)->blockset()); map->palette(pal); map->background_music(10); Entity* blocking_platform = new Entity({ .type_id = ENTITY_LARGE_DARK_PLATFORM, .position = Position(0x25, 0x1F, 0x1, true, true, false), .palette = 0 }); map->add_entity(blocking_platform); Entity* blocking_platform_2 = new Entity({ .type_id = ENTITY_LARGE_DARK_PLATFORM, .position = Position(0x25, 0x17, 0x1, true, true, false), .palette = 0, .entity_to_use_tiles_from = blocking_platform }); map->add_entity(blocking_platform_2); Entity* gnome_1 = new Entity({ .type_id = ENTITY_NPC_GNOME, .position = Position(0x25, 0x1C, 0x2), .orientation = ENTITY_ORIENTATION_SE, .palette = 3 }); gnome_1->only_when_flag_is_set(FLAG_FOUND_GNOME_1); map->add_entity(gnome_1); Entity* gnome_2 = new Entity({ .type_id = ENTITY_NPC_GNOME, .position = Position(0x29, 0x17, 0x2), .orientation = ENTITY_ORIENTATION_SW, .palette = 3, .entity_to_use_tiles_from = gnome_1 }); gnome_2->only_when_flag_is_set(FLAG_FOUND_GNOME_2); map->add_entity(gnome_2); Entity* gnome_3 = new Entity({ .type_id = ENTITY_NPC_GNOME, .position = Position(0x26, 0x23, 0x2), .orientation = ENTITY_ORIENTATION_NE, .palette = 3 }); gnome_3->only_when_flag_is_set(FLAG_FOUND_GNOME_3); map->add_entity(gnome_3); Entity* gnome_4 = new Entity({ .type_id = ENTITY_NPC_GNOME, .position = Position(0x28, 0x20, 0x2), .orientation = ENTITY_ORIENTATION_NW, .palette = 3, .entity_to_use_tiles_from = gnome_3 }); gnome_4->only_when_flag_is_set(FLAG_FOUND_GNOME_4); map->add_entity(gnome_4); // Add a Foxy NPC explaining the riddle Entity* foxy_npc = new Entity({ .type_id = ENTITY_NPC_MAGIC_FOX, .position = Position(0x25, 0x1A, 0x2), .orientation = ENTITY_ORIENTATION_SE, .palette = 1 }); map->add_entity(foxy_npc); world.add_custom_dialogue_raw(foxy_npc, "Foxy: As you have heard\nfrom our mutual friend Nole,\x1e\n" "he needs someone strong enough\nto break Gola's curse\nonce and for all.\x1e\n" "Four gnomes happen to have left\nGreenmaze and are causing\na ruckus in Mercator.\x1e\n" "Bring them all back,\nand you shall pass...\x03"); return map; } static void add_gnomes_in_mercator(World& world) { // Underground traders shop Entity* gnome_1 = new Entity({ .type_id = ENTITY_NPC_GNOME, .position = Position(0x21, 0x26, 0x1), .orientation = ENTITY_ORIENTATION_NW, .palette = 3, .talkable = true, .dialogue = 1 }); gnome_1->remove_when_flag_is_set(FLAG_FOUND_GNOME_1); world.map(0x294)->add_entity(gnome_1); add_gnome_text(world.map(0x294), world, FLAG_FOUND_GNOME_1, "Gnome: Ahah, you found me!\nI was thinking about opening\na shop in here...\x03"); // Mercator dungeon depths Entity* gnome_2 = new Entity({ .type_id = ENTITY_NPC_GNOME, .position = Position(0x23, 0x1B, 0x1, true, true), .orientation = ENTITY_ORIENTATION_SW, .palette = 3, .talkable = true, .dialogue = 3 }); gnome_2->remove_when_flag_is_set(FLAG_FOUND_GNOME_2); world.map(0x051)->add_entity(gnome_2); add_gnome_text(world.map(0x051), world, FLAG_FOUND_GNOME_2, "Gnome: Ahah, you found me!\nThese smashing and spinning\nboulders are so much fun!\x03"); // Mercator castle kitchen Entity* gnome_3 = new Entity({ .type_id = ENTITY_NPC_GNOME, .position = Position(0x17, 0x13, 0x0), .orientation = ENTITY_ORIENTATION_NW, .palette = 3, .talkable = true, .dialogue = 4 }); gnome_3->remove_when_flag_is_set(FLAG_FOUND_GNOME_3); world.map(0x045)->add_entity(gnome_3); // VARIANT of map 44! add_gnome_text(world.map(0x044), world, FLAG_FOUND_GNOME_3, "Gnome: Ahah, you found me!\nI came here because of the smell,\nand stayed for the taste.\x03"); // Top of mercator castle walls Map* mercator_castle_court = world.map(0x020); // Fix improper palette use to free palette #3 for(Entity* entity : mercator_castle_court->entities()) { if(entity->palette() == 3) entity->palette(1); } // Add the gnome Entity* gnome_4 = new Entity({ .type_id = ENTITY_NPC_GNOME, .position = Position(0x1F, 0x2E, 0xC), .orientation = ENTITY_ORIENTATION_NW, .palette = 3, .talkable = true, .dialogue = 1 }); gnome_4->remove_when_flag_is_set(FLAG_FOUND_GNOME_4); mercator_castle_court->add_entity(gnome_4); add_gnome_text(mercator_castle_court, world, FLAG_FOUND_GNOME_4, "Gnome: Ahah, you found me!\nThe view here sure is something.\nDid you find all my friends?\x03"); gnome_text_map_ids_table.add_word(0xFFFF); } static Map* add_room_4(RandomizerWorld& world, MapPalette* pal) { Map* map = world.map(MAP_SECRET_4); map->visited_flag(Flag(0xC0, 0)); map->layout(world.map(MAP_KN_PALACE_138)->layout()); map->blockset(world.map(MAP_KN_PALACE_138)->blockset()); map->palette(pal); map->background_music(10); Entity* platform = new Entity({ .type_id = ENTITY_LARGE_DARK_PLATFORM, .position = Position(0x14, 0x1D, 0x0, true, true, true), .palette = 0 }); map->add_entity(platform); Entity* npc_pockets = new Entity({ .type_id = ENTITY_NPC_POCKETS, .position = Position(0x14, 0x17, 0x0, false, false, false), .orientation = ENTITY_ORIENTATION_NW, .palette = 1, .talkable = true }); map->add_entity(npc_pockets); world.add_custom_dialogue_raw(npc_pockets, "Pockets: Hello Nigel! I heard\nthere was a secret temple being\nuncovered here, so I came.\x1e\n" "There are ancient writings on this\npillar, but I'm no archeologist...\x03"); return map; } static Map* add_room_5(RandomizerWorld& world, MapPalette* pal) { Map* map = world.map(MAP_SECRET_5); map->visited_flag(Flag(0xC0, 0)); map->layout(world.map(MAP_LAKE_SHRINE_347)->layout()); map->blockset(world.map(MAP_LAKE_SHRINE_347)->blockset()); map->palette(pal); map->background_music(10); for(uint8_t z = 0x2 ; z <= 0x6 ; z += 0x2) { map->add_entity(new Entity({ .type_id = ENTITY_ROCK, .position = Position(0x13, 0x19, z), .palette = 0 })); } for(uint8_t x = 0x13; x <= 0x1F ; x += 0xC) { for(uint8_t y = 0x13; y <= 0x1F ; y += 0xC) { map->add_entity(new Entity({ .type_id = 0xC0 + ITEM_GOLDEN_STATUE, .position = Position(x, y, 0x1F, true, true), .palette = 1, .liftable = true })); } } map->global_entity_mask_flags().emplace_back(GlobalEntityMaskFlag(FLAG_SOLVED_ROCKS_RIDDLE, 0)); return map; } static Map* add_room_6(RandomizerWorld& world, MapPalette* pal) { Map* map = world.map(MAP_SECRET_6); map->layout(world.map(MAP_LAKE_SHRINE_319)->layout()); map->blockset(world.map(MAP_LAKE_SHRINE_319)->blockset()); map->visited_flag(FLAG_SOLVED_ROCKS_RIDDLE); map->palette(pal); map->background_music(10); // Add a Nole NPC explaining the riddle Entity* nole_npc = new Entity({ .type_id = ENEMY_NOLE, .position = Position(0x13, 0x19, 0x5, false), .orientation = ENTITY_ORIENTATION_SE, .palette = 1 }); nole_npc->fightable(false); nole_npc->behavior_id(0); map->add_entity(nole_npc); world.add_custom_dialogue_raw(nole_npc, "Nole: AT LAST, YOU ARE READY\nFOR THE FINAL TRIAL. TO KNOW\nWHAT TO DO,\x1e\n" "YOU WILL HAVE TO TALK TO HER.\nSHE HAS THE ANSWER ON HOW TO\nREACH THE HEART OF GOLA.\x1e\n" "PREPARE WELL BEFORE GOING THERE,\nSINCE IT WILL BE HARDER\nTHAN ANYTHING YOU EVER FACED.\x03"); return map; } static void add_statue_dialogues(RandomizerWorld& world) { const std::string PREFIX_STRING = "Goddess: I shall give you one,\nand only one word...\x1e\nThis word is \""; const std::string SUFFIX_STRING = "\".\x03"; const std::vector<std::string> WORDS = { "OPEN", "YOUR", "EYES", "TOWARDS", "MIRROR", "INSIDE", "MASSAN", "CAVE" }; // Set all Goddess Statues in the game to give a hint std::vector<Entity*> statues; statues.emplace_back(world.map(MAP_DESTEL_WELL_290)->entity(0)); // Destel Well exit statue statues.emplace_back(world.map(MAP_486)->entity(0)); // Mountainous Area bridge statue statues.emplace_back(world.map(MAP_576)->entity(2)); // Center of Greenmaze statue statues.emplace_back(world.map(MAP_THIEVES_HIDEOUT_220)->entity(0)); // Thieves Hideout statue statues.emplace_back(world.map(MAP_KN_PALACE_117)->entity(3)); // King Nole's Palace statue statues.emplace_back(world.map(MAP_KN_CAVE_148)->entity(1)); // King Nole's Cave statue statues.emplace_back(world.map(MAP_KN_LABYRINTH_367)->entity(10)); // King Nole's Labyrinth statue statues.emplace_back(world.map(MAP_522)->entity(0)); // Lake Shrine volcano statue for(size_t i=0 ; i<statues.size() ; ++i) world.add_custom_dialogue_raw(statues[i], PREFIX_STRING + WORDS[i] + SUFFIX_STRING); // Useless unreachable statue Map* map_lake_shrine_fountain = world.map(MAP_LAKE_SHRINE_342); Entity* invisible_cube = new Entity({ .type_id = ENTITY_INVISIBLE_CUBE, .position = Position(0x19, 0x18, 0x3, true), .talkable = true, .dialogue = (uint8_t)map_lake_shrine_fountain->speaker_ids().size() }); map_lake_shrine_fountain->add_entity(invisible_cube); world.add_custom_dialogue_raw(invisible_cube, "If only I could get closer to hear\nwhat the goddess has to say...\x03"); } void PatchSecretARG::alter_world(World& w) { RandomizerWorld& world = reinterpret_cast<RandomizerWorld&>(w); add_foxy_in_knt(world); MapPalette* blue_palace_palette = build_blue_palace_palette(world); MapPalette* blue_shrine_palette = build_blue_shrine_palette(world); _room_1 = add_room_1(world, blue_palace_palette); _room_2 = add_room_2(world, blue_palace_palette); _room_1->fall_destination(_room_2->id()); _room_3 = add_room_3(world, blue_palace_palette); world.map_connections().emplace_back(MapConnection(_room_2->id(), 18, 15, _room_3->id(), 40, 37)); add_gnomes_in_mercator(world); _room_4 = add_room_4(world, blue_palace_palette); world.map_connections().emplace_back(MapConnection(_room_3->id(), 37, 26, _room_4->id(), 26, 19)); _room_5 = add_room_5(world, blue_shrine_palette); world.map_connections().emplace_back(MapConnection(_room_4->id(), 21, 21, _room_5->id(), 25, 34, 2)); _room_6 = add_room_6(world, blue_shrine_palette); world.map_connections().emplace_back(MapConnection(_room_5->id(), 19, 25, _room_6->id(), 34, 25, 4)); add_statue_dialogues(world); } // =========================== CODE INJECTIONS =========================== static void add_teleport_to_golas_heart(md::ROM& rom, World& world) { md::Code func_pre_use; func_pre_use.cmpiw(MAP_MASSAN_CAVE_806, addr_(0xFF1204)); func_pre_use.bne("regular_test"); { func_pre_use.cmpiw(0x2514, addr_(0xFF5400)); func_pre_use.bne("regular_test"); { func_pre_use.jmp(offsets::PROC_ITEM_USE_RETURN_SUCCESS_HAS_POST_USE); } } func_pre_use.label("regular_test"); func_pre_use.jmp(world.item(ITEM_GOLA_EYE)->pre_use_address()); // Regular Gola's Eye test world.item(ITEM_GOLA_EYE)->pre_use_address(rom.inject_code(func_pre_use)); // --------------------------------------------------------------------------------------- md::Code func_post_use; func_post_use.cmpiw(MAP_MASSAN_CAVE_806, addr_(0xFF1204)); func_post_use.beq("tp_to_golas_heart"); { func_post_use.jmp(world.item(ITEM_GOLA_EYE)->post_use_address()); // Regular Gola's Eye test } func_post_use.label("tp_to_golas_heart"); func_post_use.movem_to_stack({ reg_D0_D7 }, { reg_A0_A6 }); { func_post_use.trap(0, { 0x00, 0x07 }); // Play save game music func_post_use.jsr(0x29046); // Sleep_0 for 0x17 frames func_post_use.add_word(0x0000); func_post_use.jsr(0x852); // Restore BGM func_post_use.jsr(0x1592); // Save game to SRAM func_post_use.andib(0xF0, addr_(0xFF1052)); // Remove Spell Book func_post_use.addib(0x01, addr_(0xFF1052)); // ^^^ func_post_use.andib(0x0F, addr_(0xFF1051)); // Remove Record Book func_post_use.addib(0x10, addr_(0xFF1051)); // ^^^ func_post_use.movew(0x2F11, addr_(0xFF5400)); func_post_use.movew(0x0708, addr_(0xFF5402)); // Reset subtiles position func_post_use.moveb(0x88, addr_(0xFF5404)); // Orientation func_post_use.trap(0, { 0x00, 0x4D }); func_post_use.jsr(0x44C); func_post_use.movew(MAP_GOLAS_HEART_1, reg_D0); // Set MapID to Gola's Heart map func_post_use.movew(0x0000, addr_(0xFF5412)); // Reset player height func_post_use.moveb(0x00, addr_(0xFF5422)); // Reset ground height func_post_use.moveb(0x00, addr_(0xFF5439)); // ^ func_post_use.jsr(0x1586E); func_post_use.jsr(0x434); func_post_use.clrb(reg_D0); func_post_use.jsr(0x2824); func_post_use.jsr(0x410); func_post_use.jsr(0x8EB4); } func_post_use.movem_from_stack({ reg_D0_D7 }, { reg_A0_A6 }); func_post_use.rts(); world.item(ITEM_GOLA_EYE)->post_use_address(rom.inject_code(func_post_use)); } static void add_equipment_riddle_check(md::ROM& rom) { // Function to set a flag if all the right equipments are equipped md::Code func; { func.cmpiw(MAP_CRYPT_656, addr_(0xFF1204)); func.bne("no"); func.btst(FLAG_ALL_VALID_EQUIPMENTS.bit, addr_(0xFF1000 + FLAG_ALL_VALID_EQUIPMENTS.byte)); func.bne("no"); func.cmpil(0x02000710, addr_(0xFF114E)); func.bne("no"); { // If good equipments are equipped in the right room, set a permanent flag and play a sound func.bset(FLAG_ALL_VALID_EQUIPMENTS.bit, addr_(0xFF1000 + FLAG_ALL_VALID_EQUIPMENTS.byte)); func.movew(0xFFFF, addr_(0xFF5800)); func.trap(0, { 0x00, 0x74 }); } func.label("no"); func.moveb(addr_(0xFF114F), reg_D0); // instruction replaced by the JSR func.rts(); } uint32_t func_addr = rom.inject_code(func); rom.set_code(0x76EE, md::Code().jsr(func_addr)); } static void add_gnome_riddle_check(md::ROM& rom, Map* map) { md::Code func_init_map; { // Remove the Foxy if all gnomes have been found func_init_map.btst(FLAG_FOUND_GNOME_1.bit, addr_(0xFF1000 + FLAG_FOUND_GNOME_1.byte)); func_init_map.beq("ret"); func_init_map.btst(FLAG_FOUND_GNOME_2.bit, addr_(0xFF1000 + FLAG_FOUND_GNOME_2.byte)); func_init_map.beq("ret"); func_init_map.btst(FLAG_FOUND_GNOME_3.bit, addr_(0xFF1000 + FLAG_FOUND_GNOME_3.byte)); func_init_map.beq("ret"); func_init_map.btst(FLAG_FOUND_GNOME_4.bit, addr_(0xFF1000 + FLAG_FOUND_GNOME_4.byte)); func_init_map.beq("ret"); func_init_map.movew(0xFFFF, addr_(0xFF5780)); } func_init_map.label("ret"); func_init_map.rts(); map->map_setup_addr(rom.inject_code(func_init_map)); } void PatchSecretARG::inject_code(md::ROM& rom, World& world) { add_equipment_riddle_check(rom); add_gnome_riddle_check(rom, _room_3); add_teleport_to_golas_heart(rom, world); // Replace Ludwig text script by the gnome text function uint32_t gnome_text_map_ids_addr = rom.inject_bytes(gnome_text_map_ids_table); uint32_t gnome_dialogue_commands_block = rom.inject_bytes(gnome_command_words_table); uint32_t func_gnome_text = inject_func_gnome_text(rom, gnome_text_map_ids_addr, gnome_dialogue_commands_block); rom.set_code(0x267D8, md::Code().jmp(func_gnome_text)); }
#ifndef SERVERWORKER_H #define SERVERWORKER_H #pragma once // #include "server_worker_base.h" #include <rpos/robot_platforms/slamware_core_platform.h> #include <sensor_msgs/LaserScan.h> #include <std_srvs/Empty.h> #include <std_msgs/Float64.h> #include <nav_msgs/GetMap.h> #include <nav_msgs/Path.h> #include <geometry_msgs/Twist.h> #include <nav_msgs/Odometry.h> ////////////////////////////////////////////////////////////////////////// class ServerRobotPoseWorker { public: typedef rpos::robot_platforms::SlamwareCorePlatform slamware_platform_t; public: ServerRobotPoseWorker( const std::string& wkName , const boost::chrono::milliseconds& triggerInterval ); virtual ~ServerRobotPoseWorker(); protected: virtual void doPerform(slamware_platform_t& pltfm); private: ros::Publisher pubRobotPose_; }; ////////////////////////////////////////////////////////////////////////// class ServerLaserScanWorker { public: typedef rpos::robot_platforms::SlamwareCorePlatform slamware_platform_t; public: ServerLaserScanWorker( const std::string& wkName , const boost::chrono::milliseconds& triggerInterval ); virtual ~ServerLaserScanWorker(); protected: virtual void doPerform(slamware_platform_t& pltfm); private: void fillRangeMinMaxInMsg_(const std::vector<rpos::core::LaserPoint> & laserPoints , sensor_msgs::LaserScan& msgScan ) const; float calcAngleInNegativePiToPi_(float angle) const; std::uint32_t calcCompensateDestIndexBySrcAngle_(float srcAngle , bool isAnglesReverse ) const; bool isSrcAngleMoreCloseThanOldSrcAngle_(float srcAngle, float destAngle, float oldSrcAngle) const; void compensateAndfillRangesInMsg_(const std::vector<rpos::core::LaserPoint> & laserPoints , sensor_msgs::LaserScan& msgScan ) const; private: std::uint32_t compensatedAngleCnt_; float absAngleIncrement_; ros::Publisher pubLaserScan_; }; #endif
#include <iostream> #include <string> #include <map> using namespace std; int main() { int t; int odd = 0; int *n; int index = 0; int flag = 0; int lastIndex = -1; string s; map<char, int> word; map<char, int>::iterator p; cin >> t; for(int i = 0; i < t ; i++) { odd = 0; cin >> s; n = new int[s.length()]; word.clear(); index = 0; lastIndex = -1; for(int j = 0; s[j] != NULL ; j++) { if(word.find(s[j]) == word.end()) { word.insert(pair<char, int> (s[j], 1)); } else { word.at(s[j]) += 1; } } p = word.begin(); while(p != word.end()) { if(p->second % 2 != 0) { odd++; } if(odd == 2) { //cannot contain 2 odd time occuring characters flag = 1; break; } p++; } if(flag == 1) { cout << -1 << endl; flag = 0; continue; } //palindrome exists for(int j = 0; j < s.length(); j++) { if(j == lastIndex) { continue; } if(index == (s.length() - 1 - index) || index == (s.length() - 2 - index)) { break; } n[index] = j + 1; word.at(s[j]) -= 1; for(int k = j + 1; k < s.length(); k++) { if(word.at(s[j]) > 0) { if(s[k] == s[j]) { n[s.length() - 1 - index] = k + 1; word.at(s[j]) -= 1; lastIndex = k; index++; break; } } } } for(int j = 0; j < s.length(); j++) { cout << n[j] << " "; } cout << endl; delete n; } return 0; }
/** * REXUS PIOneERS - Pi_1 * pipes.h * Purpose: Class definition for implementation of pipes class for data * communication between processes * * @author David Amison * @version 1.0 10/10/2017 */ #ifndef PIPES_H #define PIPES_H #include <string> #include <cstring> #include <stdint.h> #include <error.h> // For errno namespace comms { class Pipe { public: /** * Default constructor for the Pipe class. Created all pipes ready for * communication. */ Pipe(); /** * Get the read file descriptor * @return Read file descriptor based on the process we are in. Returns -1 if * processes are yet to be forked. */ int getReadfd(); /** * Get the write file descriptor * @return Write file descriptor based on the process we are in. Returns -1 if * processes are yet to be forked. */ int getWritefd(); /** * Class specific implementation of the fork() system call. Splits the processes * and deals with closing unneeded pipes in both the parent and child process. * * @return pid of the forked process as with fork(), 0 if we are in the child * process, >0 otherwise */ int Fork(); /** * Writes binary data to the pipe. * * @param data: Buffer array containing the data * @param n: Number of bytes to write (i.e. size of data array) * @return The number of bytes written or an error code: * -1: Process not yet forked * -2: Pipe unavailbale * -3: Error while writing */ int binwrite(const void* data, int n); /** * Read binary data from the pipe. * * @param data: Buffer to store the data * @param n: Maximum number of bytes to read (i.e. size of data buffer) * @return Number of bytes read (0 if pipe has no data for reading) or an error code: * -1: Process not yet forked * -2: Pipe unavailable * -3: Error while reading */ int binread(void* data, int n); /** * Closes all the file descriptors */ void close_pipes(); /** * Does noting */ ~Pipe(); private: int m_pipes1[2]; int m_pipes2[2]; int m_par_read; int m_par_write; int m_ch_read; int m_ch_write; int m_pid = -1; // 0 => child, >0 => parent }; class PipeException { public: PipeException(std::string error) { m_error = error + " :" + std::strerror(errno); } const char * what() { return m_error.c_str(); } private: std::string m_error; }; } #endif /* PIPES_H */
#include <irtkImage.h> #include <abcdPointDistanceMap.h> char *input_name = NULL, *output_name = NULL; char *pointFileName = NULL; void usage() { cerr << "Usage: mask_point_distance_map [in] [out] <options>\n"; cerr << "Where <options> are one or more of the following:\n"; cerr << "\t -pointsFile file VTK format file containing world coordinate location(s)" << endl; cerr << "\t -point_i a b c Image coordinates of a single point."<< endl; cerr << "\t -point_w x y z World coordinates of a single point."<< endl; exit(1); } int main(int argc, char *argv[]) { int ok, i; double pt[3]; // Check command line if (argc < 3) { usage(); } // Read input and output names input_name = argv[1]; argc--; argv++; output_name = argv[1]; argc--; argv++; abcdPointDistanceMap<irtkGreyPixel> ptDmap; irtkGreyImage *input = new irtkGreyImage(input_name); irtkGreyImage *output = new irtkGreyImage(input_name); ptDmap.SetInput(input); ptDmap.SetOutput(output); while (argc > 1) { ok = false; if ((ok == false) && (strcmp(argv[1], "-pointsFile") == 0)) { argc--; argv++; pointFileName = argv[1]; argc--; argv++; ok = true; } if ((ok == false) && (strcmp(argv[1], "-point_i") == 0)) { argc--; argv++; ptDmap.addSeedPointI(atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); argc -= 3; argv += 3; ok = true; } if ((ok == false) && (strcmp(argv[1], "-point_w") == 0)) { argc--; argv++; ptDmap.addSeedPointW(atof(argv[1]), atof(argv[2]), atof(argv[3])); argc -= 3; argv += 3; ok = true; } if (ok == false) { cerr << "Unknown option: " << argv[1] << endl; usage(); } } if (pointFileName != NULL){ vtkPolyDataReader *pd_reader = vtkPolyDataReader::New(); pd_reader->SetFileName(pointFileName); pd_reader->Modified(); pd_reader->Update(); vtkPolyData *pd = pd_reader->GetOutput(); for (i = 0; i < pd->GetNumberOfPoints(); ++i){ pd->GetPoint(i, pt); ptDmap.addSeedPointW(pt[0], pt[1], pt[2]); } } if (ptDmap.GetNumberOfSeedPoints() < 1){ cerr << "mask_point_distance_map : Need at least one seed point" << endl; exit(1); } ptDmap.Run(); output->Write(output_name); }
/* Copyright (c) 2005-2023, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TESTSIMPLECELLCYCLEMODELS_HPP_ #define TESTSIMPLECELLCYCLEMODELS_HPP_ #include <cxxtest/TestSuite.h> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <fstream> #include "AbstractCellBasedTestSuite.hpp" #include "AlwaysDivideCellCycleModel.hpp" #include "ApcOneHitCellMutationState.hpp" #include "ApcTwoHitCellMutationState.hpp" #include "ApoptoticCellProperty.hpp" #include "BernoulliTrialCellCycleModel.hpp" #include "BetaCateninOneHitCellMutationState.hpp" #include "CellCycleTimesGenerator.hpp" #include "CellLabel.hpp" #include "CheckReadyToDivideAndPhaseIsUpdated.hpp" #include "ContactInhibitionCellCycleModel.hpp" #include "DifferentiatedCellProliferativeType.hpp" #include "ExponentialG1GenerationalCellCycleModel.hpp" #include "FileComparison.hpp" #include "FixedG1GenerationalCellCycleModel.hpp" #include "FixedSequenceCellCycleModel.hpp" #include "GammaG1CellCycleModel.hpp" #include "NoCellCycleModel.hpp" #include "OutputFileHandler.hpp" #include "SimpleOxygenBasedCellCycleModel.hpp" #include "SmartPointers.hpp" #include "StemCellProliferativeType.hpp" #include "StochasticOxygenBasedCellCycleModel.hpp" #include "TransitCellProliferativeType.hpp" #include "UniformCellCycleModel.hpp" #include "UniformG1GenerationalCellCycleModel.hpp" #include "WildTypeCellMutationState.hpp" #include "BiasedBernoulliTrialCellCycleModel.hpp" #include "LabelDependentBernoulliTrialCellCycleModel.hpp" //This test is always run sequentially (never in parallel) #include "FakePetscSetup.hpp" class TestSimpleCellCycleModels : public AbstractCellBasedTestSuite { public: void TestNoCellCycleModel() { // Test constructor TS_ASSERT_THROWS_NOTHING(NoCellCycleModel cell_cycle_model); // Test methods NoCellCycleModel* p_model = new NoCellCycleModel; TS_ASSERT_DELTA(p_model->GetAverageStemCellCycleTime(), DBL_MAX, 1e-6); TS_ASSERT_DELTA(p_model->GetAverageTransitCellCycleTime(), DBL_MAX, 1e-6); TS_ASSERT_EQUALS(p_model->ReadyToDivide(), false); // Test the cell-cycle model works correctly with a cell MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); CellPtr p_cell(new Cell(p_healthy_state, p_model)); p_cell->SetCellProliferativeType(p_stem_type); p_cell->InitialiseCellCycleModel(); SimulationTime* p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(10.0, 10); for (unsigned i = 0; i < 10; i++) { p_simulation_time->IncrementTimeOneStep(); TS_ASSERT_EQUALS(p_cell->ReadyToDivide(), false); } } void TestAlwaysDivideCellCycleModel() { // Test constructor TS_ASSERT_THROWS_NOTHING(AlwaysDivideCellCycleModel cell_cycle_model); // Test methods AlwaysDivideCellCycleModel* p_model = new AlwaysDivideCellCycleModel; TS_ASSERT_DELTA(p_model->GetAverageStemCellCycleTime(), DBL_MAX, 1e-6); TS_ASSERT_DELTA(p_model->GetAverageTransitCellCycleTime(), DBL_MAX, 1e-6); TS_ASSERT_EQUALS(p_model->ReadyToDivide(), true); // Test the cell-cycle model works correctly with a cell MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); CellPtr p_cell(new Cell(p_healthy_state, p_model)); p_cell->SetCellProliferativeType(p_stem_type); p_cell->InitialiseCellCycleModel(); SimulationTime* p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(10.0, 10); for (unsigned i = 0; i < 10; i++) { p_simulation_time->IncrementTimeOneStep(); TS_ASSERT_EQUALS(p_cell->ReadyToDivide(), true); } } void TestFixedSequenceCellCycleModelMethods() { CellCycleTimesGenerator* p_cell_cycle_times_generator = CellCycleTimesGenerator::Instance(); // Set up the required singleton // Make sure we can generate this model TS_ASSERT_THROWS_NOTHING(FixedSequenceCellCycleModel cell_model); MAKE_PTR(WildTypeCellMutationState, p_healthy_state); // Get a pointer to a cell cycle model of this kind FixedSequenceCellCycleModel* p_stem_model = new FixedSequenceCellCycleModel; // Test set and get method for the rate parameter TS_ASSERT_DELTA(p_stem_model->GetRate(), 0.5, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 2.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 2.0, 1e-10); p_stem_model->SetRate(10.0); TS_ASSERT_DELTA(p_stem_model->GetRate(), 10.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 0.1, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 0.1, 1e-10); p_stem_model->SetRate(0.25); TS_ASSERT_DELTA(p_stem_model->GetRate(), 0.25, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 4.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 4.0, 1e-10); p_stem_model->SetRate(0.25); p_cell_cycle_times_generator->SetRandomSeed(0); TS_ASSERT_THROWS_THIS(p_cell_cycle_times_generator->GetNextCellCycleTime(), "When using FixedSequenceCellCycleModel one must call CellCycleTimesGenerator::Instance()->GenerateCellCycleTimeSequence()" " before the start of the simulation."); p_cell_cycle_times_generator->GenerateCellCycleTimeSequence(); TS_ASSERT_THROWS_THIS(p_stem_model->SetTransitCellG1Duration(8.0), "This cell cycle model does not differentiate stem cells and transit cells, please use SetRate() instead"); TS_ASSERT_THROWS_THIS(p_stem_model->SetStemCellG1Duration(8.0), "This cell cycle model does not differentiate stem cells and transit cells, please use SetRate() instead"); TS_ASSERT_THROWS_THIS(p_stem_model->SetRate(8.0), "You cannot reset the rate after cell cycle times are created."); TS_ASSERT_THROWS_THIS(p_cell_cycle_times_generator->GenerateCellCycleTimeSequence(), "Trying to generate the cell cycle times twice. Need to call CellCycleTimesGenerator::Destroy() first."); // When we set the rate parameter we also reset the TransitCellG1Duration and StemCellG1Duration such that // average cell cycle times are calculated correctly TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 4.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 4.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetAverageTransitCellCycleTime(), 14.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetAverageStemCellCycleTime(), 14.0, 1e-10); // Make a stem cell with the model MAKE_PTR(StemCellProliferativeType, p_stem_type); CellPtr p_stem_cell(new Cell(p_healthy_state, p_stem_model)); p_stem_cell->SetCellProliferativeType(p_stem_type); p_stem_cell->InitialiseCellCycleModel(); // Make another cell cycle model of this kind and give it to a transit cell FixedSequenceCellCycleModel* p_transit_model = new FixedSequenceCellCycleModel; MAKE_PTR(TransitCellProliferativeType, p_transit_type); CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->SetCellProliferativeType(p_transit_type); // And finally a cell cycle model for a differentiated cell FixedSequenceCellCycleModel* p_diff_model = new FixedSequenceCellCycleModel; MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); // The random times should be the same across platforms (We won't bother testing the distributions) double exponentially_generated_g1 = 3.4590; TS_ASSERT_DELTA(p_stem_model->GetG1Duration(), exponentially_generated_g1, 1e-4); TS_ASSERT_EQUALS(p_diff_model->GetG1Duration(), DBL_MAX); SimulationTime* p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(14.0, 100); for (unsigned i = 0; i < 100; i++) { p_simulation_time->IncrementTimeOneStep(); // The actual testing of the cell cycle model // The numbers for the G1 durations below are taken from the first random number generated CheckReadyToDivideAndPhaseIsUpdated(p_stem_model, exponentially_generated_g1); CheckReadyToDivideAndPhaseIsUpdated(p_diff_model, 132); // any old number } // Check that cell division correctly resets the cell cycle phase TS_ASSERT_EQUALS(p_stem_cell->ReadyToDivide(), true); TS_ASSERT_EQUALS(p_stem_model->GetCurrentCellCyclePhase(), G_TWO_PHASE); p_stem_model->ResetForDivision(); TS_ASSERT_EQUALS(p_stem_model->GetCurrentCellCyclePhase(), M_PHASE); FixedSequenceCellCycleModel* p_stem_model2 = static_cast<FixedSequenceCellCycleModel*>(p_stem_model->CreateCellCycleModel()); TS_ASSERT_EQUALS(p_stem_model2->GetCurrentCellCyclePhase(), M_PHASE); CellPtr p_stem_cell2(new Cell(p_healthy_state, p_stem_model2)); p_stem_cell2->SetCellProliferativeType(p_stem_type); TS_ASSERT_EQUALS(p_stem_model2->GetCurrentCellCyclePhase(), M_PHASE); CellCycleTimesGenerator::Destroy(); } void TestArchiveFixedSequenceCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "FixedSequenceCellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test = 0.0; double fixed_sequence_test_number = 0.0; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(2.0, 4); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new FixedSequenceCellCycleModel; static_cast<FixedSequenceCellCycleModel*>(p_model)->SetRate(13.42); CellCycleTimesGenerator* p_cell_cycle_times_generator = CellCycleTimesGenerator::Instance(); p_cell_cycle_times_generator->SetRandomSeed(12u); p_cell_cycle_times_generator->GenerateCellCycleTimeSequence(); p_cell_cycle_times_generator->GetNextCellCycleTime(); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; fixed_sequence_test_number = p_cell_cycle_times_generator->GetNextCellCycleTime(); delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); CellCycleTimesGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); TS_ASSERT_DELTA(CellCycleTimesGenerator::Instance()->GetNextCellCycleTime(), fixed_sequence_test_number, 1e-6); // Check private data has been restored correctly TS_ASSERT_DELTA(static_cast<FixedSequenceCellCycleModel*>(p_model2)->GetRate(), 13.42, 1e-12); // Avoid memory leaks delete p_model2; CellCycleTimesGenerator::Destroy(); } } void TestCellCycleTimesGeneratorSingleton() { // how to test this: first, test that it is a singleton, then a test for all methods, then a test for fixed sequence { CellCycleTimesGenerator::Instance(); CellCycleTimesGenerator::Instance()->SetRate(298.0); } { CellCycleTimesGenerator::Instance(); TS_ASSERT_DELTA(CellCycleTimesGenerator::Instance()->GetRate(), 298.0, 1e-7) } // well, looks like it's a singleton, why not test the methods next CellCycleTimesGenerator::Instance()->SetRate(87.0); TS_ASSERT_DELTA(CellCycleTimesGenerator::Instance()->GetRate(), 87.0, 1e-7); CellCycleTimesGenerator::Destroy(); TS_ASSERT_DELTA(CellCycleTimesGenerator::Instance()->GetRate(), 1.0 / 2.0, 1e-7); CellCycleTimesGenerator::Instance()->SetRate(45.0); TS_ASSERT_EQUALS(CellCycleTimesGenerator::Instance()->GetRandomSeed(), 0u); CellCycleTimesGenerator::Instance()->SetRandomSeed(78u); TS_ASSERT_EQUALS(CellCycleTimesGenerator::Instance()->GetRandomSeed(), 78u); CellCycleTimesGenerator::Instance()->GenerateCellCycleTimeSequence(); std::vector<double> random_sequence; for (unsigned index = 0u; index < 10; index++) { double next_random_number = CellCycleTimesGenerator::Instance()->GetNextCellCycleTime(); random_sequence.push_back(next_random_number); if (index > 0) { assert(next_random_number != random_sequence[index - 1]); } } CellCycleTimesGenerator::Destroy(); CellCycleTimesGenerator::Instance()->SetRate(45.0); CellCycleTimesGenerator::Instance()->SetRandomSeed(78u); RandomNumberGenerator::Instance()->Reseed(12u); CellCycleTimesGenerator::Instance()->GenerateCellCycleTimeSequence(); RandomNumberGenerator::Instance()->Reseed(13u); for (unsigned index = 0u; index < 10; index++) { unsigned my_seed = 13u * index; RandomNumberGenerator::Instance()->Reseed(my_seed); double my_rate = double(index) * 0.5 + 1.0; //make sure we don't accidentally set a rate of 0, gives nasty boost errors. RandomNumberGenerator::Instance()->ExponentialRandomDeviate(my_rate); double next_cell_cycle_time = CellCycleTimesGenerator::Instance()->GetNextCellCycleTime(); TS_ASSERT_DELTA(next_cell_cycle_time, random_sequence[index], 1e-7); } CellCycleTimesGenerator::Destroy(); } void TestBernoulliTrialCellCycleModel() { TS_ASSERT_THROWS_NOTHING(BernoulliTrialCellCycleModel cell_model3); BernoulliTrialCellCycleModel* p_diff_model = new BernoulliTrialCellCycleModel; BernoulliTrialCellCycleModel* p_transit_model = new BernoulliTrialCellCycleModel; TS_ASSERT_DELTA(p_transit_model->GetDivisionProbability(), 0.1, 1e-9); TS_ASSERT_DELTA(p_transit_model->GetMinimumDivisionAge(), 1.0, 1e-9); // Change parameters for this model p_transit_model->SetDivisionProbability(0.5); p_transit_model->SetMinimumDivisionAge(0.1); TS_ASSERT_DELTA(p_transit_model->GetDivisionProbability(), 0.5, 1e-9); TS_ASSERT_DELTA(p_transit_model->GetMinimumDivisionAge(), 0.1, 1e-9); MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(TransitCellProliferativeType, p_transit_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->SetCellProliferativeType(p_transit_type); p_transit_cell->InitialiseCellCycleModel(); CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); SimulationTime* p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; p_simulation_time->SetEndTimeAndNumberOfTimeSteps(10.0, num_steps); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); // The division time below is taken from the first random number generated if (i < 33) { TS_ASSERT_EQUALS(p_transit_cell->ReadyToDivide(), false); } else { TS_ASSERT_EQUALS(p_transit_cell->ReadyToDivide(), true); } TS_ASSERT_EQUALS(p_diff_cell->ReadyToDivide(), false); } TS_ASSERT_DELTA(p_transit_model->GetAge(), p_simulation_time->GetTime(), 1e-9); TS_ASSERT_DELTA(p_diff_model->GetAge(), p_simulation_time->GetTime(), 1e-9); // Check that cell division correctly resets the cell cycle phase CellPtr p_transit_cell2 = p_transit_cell->Divide(); BernoulliTrialCellCycleModel* p_transit_model2 = static_cast<BernoulliTrialCellCycleModel*>(p_transit_cell2->GetCellCycleModel()); TS_ASSERT_EQUALS(p_transit_model2->ReadyToDivide(), false); TS_ASSERT_DELTA(p_transit_model2->GetDivisionProbability(), 0.5, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetMinimumDivisionAge(), 0.1, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetAverageTransitCellCycleTime(), 2.0, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetAverageStemCellCycleTime(), 2.0, 1e-9); } void TestLabelDepedendentBernoulliTrialCellCycleModel() { TS_ASSERT_THROWS_NOTHING(LabelDependentBernoulliTrialCellCycleModel cell_model); LabelDependentBernoulliTrialCellCycleModel* p_diff_model = new LabelDependentBernoulliTrialCellCycleModel; LabelDependentBernoulliTrialCellCycleModel* p_transit_model = new LabelDependentBernoulliTrialCellCycleModel; TS_ASSERT_DELTA(p_transit_model->GetDivisionProbability(), 0.1, 1e-9); TS_ASSERT_DELTA(p_transit_model->GetLabelledDivisionProbability(), 0.1, 1e-9); TS_ASSERT_DELTA(p_transit_model->GetMinimumDivisionAge(), 1.0, 1e-9); // Change parameters for this model p_transit_model->SetDivisionProbability(0.2); p_transit_model->SetLabelledDivisionProbability(0.5); p_transit_model->SetMinimumDivisionAge(0.1); TS_ASSERT_DELTA(p_transit_model->GetDivisionProbability(), 0.2, 1e-9); TS_ASSERT_DELTA(p_transit_model->GetLabelledDivisionProbability(), 0.5, 1e-9); TS_ASSERT_DELTA(p_transit_model->GetMinimumDivisionAge(), 0.1, 1e-9); MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(TransitCellProliferativeType, p_transit_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); MAKE_PTR(CellLabel, p_label); CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->AddCellProperty(p_label); p_transit_cell->SetCellProliferativeType(p_transit_type); p_transit_cell->InitialiseCellCycleModel(); CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); SimulationTime* p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; p_simulation_time->SetEndTimeAndNumberOfTimeSteps(10.0, num_steps); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); // The division time below is taken from the first random number generated if (i < 33) { TS_ASSERT_EQUALS(p_transit_cell->ReadyToDivide(), false); } else { TS_ASSERT_EQUALS(p_transit_cell->ReadyToDivide(), true); } TS_ASSERT_EQUALS(p_diff_cell->ReadyToDivide(), false); } TS_ASSERT_DELTA(p_transit_model->GetAge(), p_simulation_time->GetTime(), 1e-9); TS_ASSERT_DELTA(p_diff_model->GetAge(), p_simulation_time->GetTime(), 1e-9); // Check that cell division correctly resets the cell cycle phase CellPtr p_transit_cell2 = p_transit_cell->Divide(); LabelDependentBernoulliTrialCellCycleModel* p_transit_model2 = static_cast<LabelDependentBernoulliTrialCellCycleModel*>(p_transit_cell2->GetCellCycleModel()); TS_ASSERT_EQUALS(p_transit_model2->ReadyToDivide(), false); TS_ASSERT_DELTA(p_transit_model2->GetDivisionProbability(), 0.2, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetLabelledDivisionProbability(), 0.5, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetMinimumDivisionAge(), 0.1, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetAverageTransitCellCycleTime(), 5.0, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetAverageStemCellCycleTime(), 5.0, 1e-9); } void TestFixedG1GenerationalCellCycleModel() { TS_ASSERT_THROWS_NOTHING(FixedG1GenerationalCellCycleModel model3); FixedG1GenerationalCellCycleModel* p_stem_model = new FixedG1GenerationalCellCycleModel; MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); MAKE_PTR(TransitCellProliferativeType, p_transit_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_stem_cell(new Cell(p_healthy_state, p_stem_model)); p_stem_cell->SetCellProliferativeType(p_stem_type); p_stem_cell->InitialiseCellCycleModel(); SimulationTime* p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; //Per cycle unsigned num_cycles = 2; p_simulation_time->SetEndTimeAndNumberOfTimeSteps( num_cycles * (p_stem_model->GetStemCellG1Duration() + p_stem_model->GetSG2MDuration()), num_cycles * num_steps); TS_ASSERT_EQUALS(p_stem_model->GetCurrentCellCyclePhase(), M_PHASE); TS_ASSERT_EQUALS(p_stem_model->GetGeneration(), 0u); TS_ASSERT_EQUALS(p_stem_model->GetMaxTransitGenerations(), 3u); TS_ASSERT_EQUALS(p_stem_model->CanCellTerminallyDifferentiate(), true); p_stem_model->SetMaxTransitGenerations(6); TS_ASSERT_EQUALS(p_stem_model->GetMaxTransitGenerations(), 6u); p_stem_model->SetMaxTransitGenerations(3); TS_ASSERT_EQUALS(p_stem_cell->GetCellProliferativeType(), p_stem_type); FixedG1GenerationalCellCycleModel* p_transit_model = new FixedG1GenerationalCellCycleModel; CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->SetCellProliferativeType(p_transit_type); p_transit_cell->InitialiseCellCycleModel(); TS_ASSERT_EQUALS(p_transit_cell->GetCellProliferativeType(), p_transit_type); TS_ASSERT_EQUALS(p_transit_model->GetGeneration(), 0u); FixedG1GenerationalCellCycleModel* p_diff_model = new FixedG1GenerationalCellCycleModel; CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); TS_ASSERT_EQUALS(p_diff_cell->GetCellProliferativeType(), p_diff_type); TS_ASSERT_EQUALS(p_diff_model->GetGeneration(), 0u); // First cycle for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); CheckReadyToDivideAndPhaseIsUpdated(p_stem_model, p_stem_model->GetStemCellG1Duration()); CheckReadyToDivideAndPhaseIsUpdated(p_transit_model, p_transit_model->GetTransitCellG1Duration()); CheckReadyToDivideAndPhaseIsUpdated(p_diff_model, 100); } TS_ASSERT_DELTA(p_stem_model->GetAge(), p_simulation_time->GetTime(), 1e-9); TS_ASSERT_DELTA(p_transit_model->GetAge(), p_simulation_time->GetTime(), 1e-9); TS_ASSERT_DELTA(p_diff_model->GetAge(), p_simulation_time->GetTime(), 1e-9); double hepa_one_cell_birth_time = p_simulation_time->GetTime(); FixedG1GenerationalCellCycleModel* p_hepa_one_model = new FixedG1GenerationalCellCycleModel; // Change G1 duration for this model p_hepa_one_model->SetStemCellG1Duration(8.0); p_hepa_one_model->SetTransitCellG1Duration(8.0); CellPtr p_hepa_one_cell(new Cell(p_healthy_state, p_hepa_one_model)); p_hepa_one_cell->SetCellProliferativeType(p_stem_type); p_hepa_one_cell->InitialiseCellCycleModel(); // Second cycle for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); CheckReadyToDivideAndPhaseIsUpdated(p_hepa_one_model, 8.0); } TS_ASSERT_DELTA(p_hepa_one_model->GetAge() + hepa_one_cell_birth_time, p_simulation_time->GetTime(), 1e-9); // Test get and set methods TS_ASSERT_DELTA(p_stem_model->GetSDuration(), 5.0, 1e-9); TS_ASSERT_DELTA(p_stem_model->GetG2Duration(), 4.0, 1e-9); TS_ASSERT_DELTA(p_stem_model->GetMDuration(), 1.0, 1e-9); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 2.0, 1e-9); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 14.0, 1e-9); p_stem_model->SetSDuration(7.4); p_stem_model->SetG2Duration(1.4); p_stem_model->SetMDuration(0.72); p_stem_model->SetTransitCellG1Duration(9.4); p_stem_model->SetStemCellG1Duration(9.4); TS_ASSERT_DELTA(p_stem_model->GetSDuration(), 7.4, 1e-9); TS_ASSERT_DELTA(p_stem_model->GetG2Duration(), 1.4, 1e-9); TS_ASSERT_DELTA(p_stem_model->GetMDuration(), 0.72, 1e-9); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 9.4, 1e-9); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 9.4, 1e-9); } void TestUniformG1GenerationalCellCycleModel() { TS_ASSERT_THROWS_NOTHING(UniformG1GenerationalCellCycleModel cell_model3); UniformG1GenerationalCellCycleModel* p_stem_model = new UniformG1GenerationalCellCycleModel; // Change G1 duration for this model p_stem_model->SetStemCellG1Duration(1.0); UniformG1GenerationalCellCycleModel* p_transit_model = new UniformG1GenerationalCellCycleModel; // Change G1 duration for this model p_transit_model->SetTransitCellG1Duration(1.0); UniformG1GenerationalCellCycleModel* p_diff_model = new UniformG1GenerationalCellCycleModel; MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); MAKE_PTR(TransitCellProliferativeType, p_transit_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_stem_cell(new Cell(p_healthy_state, p_stem_model)); p_stem_cell->SetCellProliferativeType(p_stem_type); p_stem_cell->InitialiseCellCycleModel(); CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->SetCellProliferativeType(p_transit_type); p_transit_cell->InitialiseCellCycleModel(); CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); SimulationTime* p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; p_simulation_time->SetEndTimeAndNumberOfTimeSteps( 4.0 * (p_stem_model->GetStemCellG1Duration() + p_stem_model->GetSG2MDuration()), 2 * num_steps); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); // The numbers for the G1 durations below are taken from the first three // random numbers generated CheckReadyToDivideAndPhaseIsUpdated(p_stem_model, 3.19525); CheckReadyToDivideAndPhaseIsUpdated(p_transit_model, 2.18569); CheckReadyToDivideAndPhaseIsUpdated(p_diff_model, 132); // any old number } UniformG1GenerationalCellCycleModel* p_hepa_one_model = new UniformG1GenerationalCellCycleModel; // Change G1 duration for this model p_hepa_one_model->SetStemCellG1Duration(1.0); CellPtr p_hepa_one_cell(new Cell(p_healthy_state, p_hepa_one_model)); p_hepa_one_cell->SetCellProliferativeType(p_stem_type); p_hepa_one_cell->InitialiseCellCycleModel(); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); CheckReadyToDivideAndPhaseIsUpdated(p_hepa_one_model, 3.86076); } } void TestUniformCellCycleModel() { TS_ASSERT_THROWS_NOTHING(UniformCellCycleModel cell_model3); UniformCellCycleModel* p_stem_model = new UniformCellCycleModel; // Change min and max cell cycle duration for this model p_stem_model->SetMinCellCycleDuration(18.0); p_stem_model->SetMaxCellCycleDuration(20.0); UniformCellCycleModel* p_transit_model = new UniformCellCycleModel; // Use default min and max cell cycle duration for this model p_transit_model->SetMinCellCycleDuration(12.0); p_transit_model->SetMaxCellCycleDuration(14.0); UniformCellCycleModel* p_diff_model = new UniformCellCycleModel; MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); MAKE_PTR(TransitCellProliferativeType, p_transit_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_stem_cell(new Cell(p_healthy_state, p_stem_model)); p_stem_cell->SetCellProliferativeType(p_stem_type); p_stem_cell->InitialiseCellCycleModel(); CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->SetCellProliferativeType(p_transit_type); p_transit_cell->InitialiseCellCycleModel(); CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); SimulationTime* p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; p_simulation_time->SetEndTimeAndNumberOfTimeSteps( 4.0 * (p_stem_model->GetAverageStemCellCycleTime()), 2 * num_steps); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); // The numbers for the cell cycle durations below are taken from the first three // random numbers generated CheckReadyToDivideIsUpdated(p_stem_model, 19.09763); CheckReadyToDivideIsUpdated(p_transit_model, 13.18569); CheckReadyToDivideIsUpdated(p_diff_model, 132); // any old number } // Check with a mutation. UniformCellCycleModel* p_hepa_one_model = new UniformCellCycleModel; // Use default Min and Max cell cycle duration for this model p_hepa_one_model->SetMinCellCycleDuration(14.0); p_hepa_one_model->SetMaxCellCycleDuration(16.0); CellPtr p_hepa_one_cell(new Cell(p_healthy_state, p_hepa_one_model)); p_hepa_one_cell->SetCellProliferativeType(p_stem_type); p_hepa_one_cell->InitialiseCellCycleModel(); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); CheckReadyToDivideIsUpdated(p_hepa_one_model, 15.43038); } } void TestGammaG1CellCycleModel() { TS_ASSERT_THROWS_NOTHING(GammaG1CellCycleModel cell_model); MAKE_PTR(WildTypeCellMutationState, p_healthy_state); GammaG1CellCycleModel* p_stem_model = new GammaG1CellCycleModel; p_stem_model->SetShape(3.517); p_stem_model->SetScale(2.986); TS_ASSERT_DELTA(p_stem_model->GetShape(), 3.517, 1e-4); TS_ASSERT_DELTA(p_stem_model->GetScale(), 2.986, 1e-4); MAKE_PTR(StemCellProliferativeType, p_stem_type); CellPtr p_stem_cell(new Cell(p_healthy_state, p_stem_model)); p_stem_cell->SetCellProliferativeType(p_stem_type); p_stem_cell->InitialiseCellCycleModel(); GammaG1CellCycleModel* p_transit_model = new GammaG1CellCycleModel; p_transit_model->SetShape(3.5); p_transit_model->SetScale(2.9); MAKE_PTR(TransitCellProliferativeType, p_transit_type); CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->SetCellProliferativeType(p_transit_type); p_transit_cell->InitialiseCellCycleModel(); GammaG1CellCycleModel* p_diff_model = new GammaG1CellCycleModel; p_diff_model->SetShape(3.5); p_diff_model->SetScale(2.9); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); TS_ASSERT_DELTA(p_stem_model->GetG1Duration(), 3.6104, 1e-4); TS_ASSERT_DELTA(p_transit_model->GetG1Duration(), 3.8511, 1e-4); TS_ASSERT_EQUALS(p_diff_model->GetG1Duration(), DBL_MAX); SimulationTime* p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(14.0, 100); for (unsigned i = 0; i < 100; i++) { p_simulation_time->IncrementTimeOneStep(); // The numbers for the G1 durations below are taken from the first three random numbers generated CheckReadyToDivideAndPhaseIsUpdated(p_stem_model, 3.61046); CheckReadyToDivideAndPhaseIsUpdated(p_transit_model, 3.8511); CheckReadyToDivideAndPhaseIsUpdated(p_diff_model, 132); // any old number } // Check that cell division correctly resets the cell cycle phase TS_ASSERT_EQUALS(p_stem_cell->ReadyToDivide(), true); TS_ASSERT_EQUALS(p_stem_model->GetCurrentCellCyclePhase(), G_TWO_PHASE); p_stem_model->ResetForDivision(); TS_ASSERT_EQUALS(p_stem_model->GetCurrentCellCyclePhase(), M_PHASE); GammaG1CellCycleModel* p_stem_model2 = static_cast<GammaG1CellCycleModel*>(p_stem_model->CreateCellCycleModel()); TS_ASSERT_EQUALS(p_stem_model2->GetCurrentCellCyclePhase(), M_PHASE); CellPtr p_stem_cell2(new Cell(p_healthy_state, p_stem_model2)); p_stem_cell2->SetCellProliferativeType(p_stem_type); TS_ASSERT_EQUALS(p_stem_model2->GetCurrentCellCyclePhase(), M_PHASE); } void TestExponentialG1GenerationalCellCycleModel() { // Make sure we can generate this model TS_ASSERT_THROWS_NOTHING(ExponentialG1GenerationalCellCycleModel cell_model); MAKE_PTR(WildTypeCellMutationState, p_healthy_state); // Get a pointer to a cell cycle model of this kind ExponentialG1GenerationalCellCycleModel* p_stem_model = new ExponentialG1GenerationalCellCycleModel; // Test set and get method for the rate parameter TS_ASSERT_DELTA(p_stem_model->GetRate(), 0.5, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 14.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 2.0, 1e-10); p_stem_model->SetStemCellG1Duration(8.0); TS_ASSERT_DELTA(p_stem_model->GetRate(), 0.125, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 8.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 2.0, 1e-10); p_stem_model->SetTransitCellG1Duration(0.1); TS_ASSERT_DELTA(p_stem_model->GetRate(), 10.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 8.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 0.1, 1e-10); p_stem_model->SetRate(0.25); TS_ASSERT_DELTA(p_stem_model->GetRate(), 0.25, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 4.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 4.0, 1e-10); // When we set the rate parameter we also reset the TransitCellG1Duration and StemCellG1Duration such that // average cell cycle times are calculated correctly TS_ASSERT_DELTA(p_stem_model->GetStemCellG1Duration(), 4.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetTransitCellG1Duration(), 4.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetAverageTransitCellCycleTime(), 14.0, 1e-10); TS_ASSERT_DELTA(p_stem_model->GetAverageStemCellCycleTime(), 14.0, 1e-10); // Make a stem cell with the model MAKE_PTR(StemCellProliferativeType, p_stem_type); CellPtr p_stem_cell(new Cell(p_healthy_state, p_stem_model)); p_stem_cell->SetCellProliferativeType(p_stem_type); p_stem_cell->InitialiseCellCycleModel(); // Make another cell cycle model of this kind and give it to a transit cell ExponentialG1GenerationalCellCycleModel* p_transit_model = new ExponentialG1GenerationalCellCycleModel; p_transit_model->SetRate(1.0); MAKE_PTR(TransitCellProliferativeType, p_transit_type); CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->SetCellProliferativeType(p_transit_type); p_transit_cell->InitialiseCellCycleModel(); // And finally a cell cycle model for a differentiated cell ExponentialG1GenerationalCellCycleModel* p_diff_model = new ExponentialG1GenerationalCellCycleModel; p_diff_model->SetRate(200.0); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); // The random times should be the same across platforms (We won't bother testing the distributions) double exponentially_generated_g1 = 3.4590; TS_ASSERT_DELTA(p_stem_model->GetG1Duration(), exponentially_generated_g1, 1e-4); double second_exponentially_generated_g1 = 1.3666; TS_ASSERT_DELTA(p_transit_model->GetG1Duration(), second_exponentially_generated_g1, 1e-4); TS_ASSERT_EQUALS(p_diff_model->GetG1Duration(), DBL_MAX); SimulationTime* p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(14.0, 100); for (unsigned i = 0; i < 100; i++) { p_simulation_time->IncrementTimeOneStep(); // The actual testing of the cell cycle model // The numbers for the G1 durations below are taken from the first two random numbers generated CheckReadyToDivideAndPhaseIsUpdated(p_stem_model, exponentially_generated_g1); CheckReadyToDivideAndPhaseIsUpdated(p_transit_model, second_exponentially_generated_g1); CheckReadyToDivideAndPhaseIsUpdated(p_diff_model, 132); // any old number } // Check that cell division correctly resets the cell cycle phase TS_ASSERT_EQUALS(p_stem_cell->ReadyToDivide(), true); TS_ASSERT_EQUALS(p_stem_model->GetCurrentCellCyclePhase(), G_TWO_PHASE); p_stem_model->ResetForDivision(); TS_ASSERT_EQUALS(p_stem_model->GetCurrentCellCyclePhase(), M_PHASE); ExponentialG1GenerationalCellCycleModel* p_stem_model2 = static_cast<ExponentialG1GenerationalCellCycleModel*>(p_stem_model->CreateCellCycleModel()); TS_ASSERT_EQUALS(p_stem_model2->GetCurrentCellCyclePhase(), M_PHASE); CellPtr p_stem_cell2(new Cell(p_healthy_state, p_stem_model2)); p_stem_cell2->SetCellProliferativeType(p_stem_type); TS_ASSERT_EQUALS(p_stem_model2->GetCurrentCellCyclePhase(), M_PHASE); } void TestSimpleOxygenBasedCellCycleModel() { // Check that mCurrentHypoxiaOnsetTime and mCurrentHypoxicDuration are updated correctly SimulationTime* p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(3.0, 3); SimpleOxygenBasedCellCycleModel* p_model = new SimpleOxygenBasedCellCycleModel; p_model->SetDimension(2); p_model->SetStemCellG1Duration(8.0); p_model->SetTransitCellG1Duration(8.0); MAKE_PTR(WildTypeCellMutationState, p_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_cell(new Cell(p_state, p_model)); p_cell->SetCellProliferativeType(p_stem_type); p_cell->InitialiseCellCycleModel(); // Set up oxygen_concentration double lo_oxygen_concentration = 0.0; double hi_oxygen_concentration = 1.0; p_cell->GetCellData()->SetItem("oxygen", lo_oxygen_concentration); p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentHypoxicDuration(), 0.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentHypoxiaOnsetTime(), 0.0, 1e-12); p_simulation_time->IncrementTimeOneStep(); // t=1.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentHypoxicDuration(), 1.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentHypoxiaOnsetTime(), 0.0, 1e-12); p_cell->GetCellData()->SetItem("oxygen", hi_oxygen_concentration); p_simulation_time->IncrementTimeOneStep(); // t=2.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentHypoxicDuration(), 0.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentHypoxiaOnsetTime(), 2.0, 1e-12); p_cell->GetCellData()->SetItem("oxygen", lo_oxygen_concentration); p_simulation_time->IncrementTimeOneStep(); // t=3.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentHypoxicDuration(), 1.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentHypoxiaOnsetTime(), 2.0, 1e-12); // Set up SimulationTime SimulationTime::Destroy(); p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; p_simulation_time->SetStartTime(0.0); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(4.0 * 18.0, num_steps); TS_ASSERT_THROWS_NOTHING(SimpleOxygenBasedCellCycleModel model); // Create cell-cycle models and cells SimpleOxygenBasedCellCycleModel* p_hepa_one_model = new SimpleOxygenBasedCellCycleModel; p_hepa_one_model->SetDimension(2); CellPtr p_hepa_one_cell(new Cell(p_state, p_hepa_one_model)); p_hepa_one_cell->SetCellProliferativeType(p_stem_type); p_hepa_one_cell->GetCellData()->SetItem("oxygen", hi_oxygen_concentration); p_hepa_one_cell->InitialiseCellCycleModel(); SimpleOxygenBasedCellCycleModel* p_diff_model = new SimpleOxygenBasedCellCycleModel; p_diff_model->SetDimension(2); // Coverage TS_ASSERT_DELTA(p_diff_model->GetCriticalHypoxicDuration(), 2.0, 1e-6); p_diff_model->SetCriticalHypoxicDuration(0.5); TS_ASSERT_DELTA(p_diff_model->GetCriticalHypoxicDuration(), 0.5, 1e-6); CellPtr p_diff_cell(new Cell(p_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->InitialiseCellCycleModel(); p_diff_cell->GetCellData()->SetItem("oxygen", hi_oxygen_concentration); // Check that the cell cycle phase and ready to divide // are updated correctly TS_ASSERT_EQUALS(p_hepa_one_model->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_hepa_one_model->GetCurrentCellCyclePhase(), M_PHASE); TS_ASSERT_EQUALS(p_diff_model->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_diff_model->GetCurrentCellCyclePhase(), G_ZERO_PHASE); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); // Note that we need to pass in the updated G1 duration CheckReadyToDivideAndPhaseIsUpdated(p_hepa_one_model, p_hepa_one_model->GetG1Duration()); } TS_ASSERT_DELTA(p_hepa_one_model->GetAge(), p_simulation_time->GetTime(), 1e-9); TS_ASSERT_EQUALS(p_hepa_one_model->ReadyToDivide(), true); // Check that cell division correctly resets the cell cycle phase TS_ASSERT_EQUALS(p_hepa_one_cell->ReadyToDivide(), true); CellPtr p_hepa_one_cell2 = p_hepa_one_cell->Divide(); SimpleOxygenBasedCellCycleModel* p_hepa_one_model2 = static_cast<SimpleOxygenBasedCellCycleModel*>(p_hepa_one_cell2->GetCellCycleModel()); TS_ASSERT_EQUALS(p_hepa_one_model2->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_hepa_one_model2->GetCurrentCellCyclePhase(), M_PHASE); // Set up SimulationTime SimulationTime::Destroy(); p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetStartTime(0.0); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(2.0 * p_hepa_one_model2->GetCriticalHypoxicDuration(), num_steps); // Create a cell with a simple oxygen-based cell-cycle model SimpleOxygenBasedCellCycleModel* p_cell_model = new SimpleOxygenBasedCellCycleModel; p_cell_model->SetDimension(2); CellPtr p_apoptotic_cell(new Cell(p_state, p_cell_model)); p_apoptotic_cell->SetCellProliferativeType(p_stem_type); // Set up oxygen_concentration p_apoptotic_cell->GetCellData()->SetItem("oxygen", lo_oxygen_concentration); // Force the cell to be apoptotic for (unsigned i = 0; i < num_steps; i++) { TS_ASSERT(!(p_apoptotic_cell->HasCellProperty<ApoptoticCellProperty>()) || p_simulation_time->GetTime() >= p_cell_model->GetCriticalHypoxicDuration()); p_simulation_time->IncrementTimeOneStep(); // Note that we need to pass in the updated G1 duration p_apoptotic_cell->ReadyToDivide(); } // Test that the cell is updated to be apoptotic TS_ASSERT_EQUALS(p_apoptotic_cell->HasCellProperty<ApoptoticCellProperty>(), true); TS_ASSERT_EQUALS(p_cell_model->GetCurrentHypoxicDuration(), 2.04); } void TestContactInhibitionCellCycleModel() { // Check that mQuiescentVolumeFraction and mEquilibriumVolume are updated correctly SimulationTime* p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(3.0, 3); ContactInhibitionCellCycleModel* p_model = new ContactInhibitionCellCycleModel; p_model->SetDimension(2); p_model->SetStemCellG1Duration(8.0); p_model->SetTransitCellG1Duration(8.0); TS_ASSERT_THROWS_THIS(p_model->UpdateCellCyclePhase(), "The member variables mQuiescentVolumeFraction and mEquilibriumVolume have not yet been set."); p_model->SetQuiescentVolumeFraction(0.5); p_model->SetEquilibriumVolume(1.0); // Set the birth time such that at t=0, the cell has just entered G1 phase p_model->SetBirthTime(-1.0); MAKE_PTR(WildTypeCellMutationState, p_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_cell(new Cell(p_state, p_model)); p_cell->SetCellProliferativeType(p_stem_type); p_cell->InitialiseCellCycleModel(); double lo_volume = 0.0; double hi_volume = 1.0; p_cell->GetCellData()->SetItem("volume", lo_volume); p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentQuiescentDuration(), 0.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentQuiescentOnsetTime(), 0.0, 1e-12); p_simulation_time->IncrementTimeOneStep(); // t=1.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentQuiescentDuration(), 1.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentQuiescentOnsetTime(), 0.0, 1e-12); p_cell->GetCellData()->SetItem("volume", hi_volume); p_simulation_time->IncrementTimeOneStep(); // t=2.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentQuiescentDuration(), 0.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentQuiescentOnsetTime(), 2.0, 1e-12); p_cell->GetCellData()->SetItem("volume", lo_volume); p_simulation_time->IncrementTimeOneStep(); // t=3.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentQuiescentDuration(), 1.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentQuiescentOnsetTime(), 2.0, 1e-12); // Set up SimulationTime SimulationTime::Destroy(); p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; p_simulation_time->SetStartTime(0.0); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(1.0 * 24.0, num_steps); // Create cell-cycle models and cells ContactInhibitionCellCycleModel* p_hepa_one_model = new ContactInhibitionCellCycleModel; p_hepa_one_model->SetDimension(2); p_hepa_one_model->SetBirthTime(0.0); p_hepa_one_model->SetQuiescentVolumeFraction(0.5); p_hepa_one_model->SetEquilibriumVolume(1.0); CellPtr p_hepa_one_cell(new Cell(p_state, p_hepa_one_model)); p_hepa_one_cell->SetCellProliferativeType(p_stem_type); // Set up cell volume p_hepa_one_cell->GetCellData()->SetItem("volume", hi_volume); p_hepa_one_cell->InitialiseCellCycleModel(); ContactInhibitionCellCycleModel* p_diff_model = new ContactInhibitionCellCycleModel; p_diff_model->SetDimension(2); p_diff_model->SetQuiescentVolumeFraction(0.5); p_diff_model->SetEquilibriumVolume(1.0); CellPtr p_diff_cell(new Cell(p_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->GetCellData()->SetItem("volume", hi_volume); p_diff_cell->InitialiseCellCycleModel(); // Check that the cell cycle phase and ready to divide are updated correctly TS_ASSERT_EQUALS(p_hepa_one_model->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_hepa_one_model->GetCurrentCellCyclePhase(), M_PHASE); TS_ASSERT_EQUALS(p_diff_model->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_diff_model->GetCurrentCellCyclePhase(), G_ZERO_PHASE); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); // Note that we need to pass in the updated G1 duration CheckReadyToDivideAndPhaseIsUpdated(p_hepa_one_model, p_hepa_one_model->GetG1Duration()); } TS_ASSERT_DELTA(p_hepa_one_model->GetAge(), p_simulation_time->GetTime(), 1e-9); // Check that cell division correctly resets the cell cycle phase TS_ASSERT_EQUALS(p_hepa_one_cell->ReadyToDivide(), true); CellPtr p_hepa_one_cell2 = p_hepa_one_cell->Divide(); ContactInhibitionCellCycleModel* p_hepa_one_model2 = static_cast<ContactInhibitionCellCycleModel*>(p_hepa_one_cell2->GetCellCycleModel()); TS_ASSERT_EQUALS(p_hepa_one_model->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_hepa_one_model->GetCurrentCellCyclePhase(), M_PHASE); TS_ASSERT_EQUALS(p_hepa_one_model2->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_hepa_one_model2->GetCurrentCellCyclePhase(), M_PHASE); } void TestBiasedBernoulliTrialCellCycleModel() { BiasedBernoulliTrialCellCycleModel* p_diff_model = new BiasedBernoulliTrialCellCycleModel; p_diff_model->SetDimension(2); p_diff_model->SetBirthTime(0.0); BiasedBernoulliTrialCellCycleModel* p_transit_model = new BiasedBernoulliTrialCellCycleModel; p_transit_model->SetDimension(2); p_transit_model->SetBirthTime(0.0); TS_ASSERT_DELTA(p_transit_model->GetMaxDivisionProbability(), 0.1, 1e-9); TS_ASSERT_DELTA(p_transit_model->GetMinimumDivisionAge(), 1.0, 1e-9); // Change parameters for this model p_transit_model->SetMaxDivisionProbability(1.0); p_transit_model->SetMinimumDivisionAge(0.1); TS_ASSERT_DELTA(p_transit_model->GetMaxDivisionProbability(), 1.0, 1e-9); TS_ASSERT_DELTA(p_transit_model->GetMinimumDivisionAge(), 0.1, 1e-9); MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(TransitCellProliferativeType, p_transit_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_transit_cell(new Cell(p_healthy_state, p_transit_model)); p_transit_cell->SetCellProliferativeType(p_transit_type); p_transit_cell->GetCellData()->SetItem("bias", 0.9); p_transit_cell->InitialiseCellCycleModel(); CellPtr p_diff_cell(new Cell(p_healthy_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->GetCellData()->SetItem("bias", 0.2); p_diff_cell->InitialiseCellCycleModel(); SimulationTime* p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; p_simulation_time->SetEndTimeAndNumberOfTimeSteps(10.0, num_steps); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); // The division time below is taken from the first random number generated if (i < 16) { TS_ASSERT_EQUALS(p_transit_cell->ReadyToDivide(), false); } else { TS_ASSERT_EQUALS(p_transit_cell->ReadyToDivide(), true); } TS_ASSERT_EQUALS(p_diff_cell->ReadyToDivide(), false); } TS_ASSERT_DELTA(p_transit_model->GetAge(), p_simulation_time->GetTime(), 1e-9); TS_ASSERT_DELTA(p_diff_model->GetAge(), p_simulation_time->GetTime(), 1e-9); // Check that cell division correctly resets the cell cycle phase CellPtr p_transit_cell2 = p_transit_cell->Divide(); BiasedBernoulliTrialCellCycleModel* p_transit_model2 = static_cast<BiasedBernoulliTrialCellCycleModel*>(p_transit_cell2->GetCellCycleModel()); TS_ASSERT_EQUALS(p_transit_model2->ReadyToDivide(), false); TS_ASSERT_DELTA(p_transit_model2->GetMaxDivisionProbability(), 1.0, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetMinimumDivisionAge(), 0.1, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetAverageTransitCellCycleTime(), 1.0, 1e-9); TS_ASSERT_DELTA(p_transit_model2->GetAverageStemCellCycleTime(), 1.0, 1e-9); } void TestStochasticOxygenBasedCellCycleModel() { // Check that mCurrentHypoxiaOnsetTime and mCurrentHypoxicDuration are updated correctly SimulationTime* p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(3.0, 3); StochasticOxygenBasedCellCycleModel* p_model = new StochasticOxygenBasedCellCycleModel; p_model->SetDimension(2); p_model->SetStemCellG1Duration(8.0); p_model->SetTransitCellG1Duration(8.0); // Coverage TS_ASSERT_DELTA(p_model->GetHypoxicConcentration(), 0.4, 1e-6); TS_ASSERT_DELTA(p_model->GetQuiescentConcentration(), 1.0, 1e-6); TS_ASSERT_DELTA(p_model->GetCriticalHypoxicDuration(), 2.0, 1e-6); p_model->SetHypoxicConcentration(0.5); p_model->SetQuiescentConcentration(0.5); p_model->SetCriticalHypoxicDuration(3.0); TS_ASSERT_DELTA(p_model->GetHypoxicConcentration(), 0.5, 1e-6); TS_ASSERT_DELTA(p_model->GetQuiescentConcentration(), 0.5, 1e-6); TS_ASSERT_DELTA(p_model->GetCriticalHypoxicDuration(), 3.0, 1e-6); MAKE_PTR(WildTypeCellMutationState, p_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); // Set up oxygen_concentration double lo_oxygen_concentration = 0.0; double hi_oxygen_concentration = 1.0; CellPtr p_cell(new Cell(p_state, p_model)); p_cell->SetCellProliferativeType(p_stem_type); p_cell->GetCellData()->SetItem("oxygen", lo_oxygen_concentration); p_cell->InitialiseCellCycleModel(); p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentHypoxicDuration(), 0.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentHypoxiaOnsetTime(), 0.0, 1e-12); p_simulation_time->IncrementTimeOneStep(); // t=1.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentHypoxicDuration(), 1.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentHypoxiaOnsetTime(), 0.0, 1e-12); p_cell->GetCellData()->SetItem("oxygen", hi_oxygen_concentration); p_simulation_time->IncrementTimeOneStep(); // t=2.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentHypoxicDuration(), 0.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentHypoxiaOnsetTime(), 2.0, 1e-12); p_cell->GetCellData()->SetItem("oxygen", lo_oxygen_concentration); p_simulation_time->IncrementTimeOneStep(); // t=3.0 p_model->ReadyToDivide(); TS_ASSERT_DELTA(p_model->GetCurrentHypoxicDuration(), 1.0, 1e-12); TS_ASSERT_DELTA(p_model->GetCurrentHypoxiaOnsetTime(), 2.0, 1e-12); // Set up simulation time SimulationTime::Destroy(); p_simulation_time = SimulationTime::Instance(); unsigned num_steps = 100; p_simulation_time->SetStartTime(0.0); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(4.0 * 18.0, num_steps); TS_ASSERT_THROWS_NOTHING(StochasticOxygenBasedCellCycleModel model); // Create cell-cycle model StochasticOxygenBasedCellCycleModel* p_hepa_one_model = new StochasticOxygenBasedCellCycleModel; p_hepa_one_model->SetDimension(2); StochasticOxygenBasedCellCycleModel* p_diff_model = new StochasticOxygenBasedCellCycleModel; p_diff_model->SetDimension(2); // Create cell CellPtr p_hepa_one_cell(new Cell(p_state, p_hepa_one_model)); p_hepa_one_cell->SetCellProliferativeType(p_stem_type); p_hepa_one_cell->GetCellData()->SetItem("oxygen", hi_oxygen_concentration); p_hepa_one_cell->InitialiseCellCycleModel(); CellPtr p_diff_cell(new Cell(p_state, p_diff_model)); p_diff_cell->SetCellProliferativeType(p_diff_type); p_diff_cell->GetCellData()->SetItem("oxygen", hi_oxygen_concentration); p_diff_cell->InitialiseCellCycleModel(); // Check that the cell cycle phase and ready to divide // are updated correctly TS_ASSERT_EQUALS(p_hepa_one_model->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_hepa_one_model->GetCurrentCellCyclePhase(), M_PHASE); TS_ASSERT_EQUALS(p_diff_model->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_diff_model->GetCurrentCellCyclePhase(), G_ZERO_PHASE); for (unsigned i = 0; i < num_steps; i++) { p_simulation_time->IncrementTimeOneStep(); // Note that we need to pass in the updated G1 duration CheckReadyToDivideAndPhaseIsUpdated(p_hepa_one_model, p_hepa_one_model->GetG1Duration(), p_hepa_one_model->GetG2Duration()); } TS_ASSERT_DELTA(p_hepa_one_model->GetAge(), p_simulation_time->GetTime(), 1e-9); TS_ASSERT_EQUALS(p_hepa_one_model->ReadyToDivide(), true); // Coverage TS_ASSERT_EQUALS(p_hepa_one_cell->ReadyToDivide(), true); p_hepa_one_cell->Divide(); // Check that cell division correctly resets the cell cycle phase StochasticOxygenBasedCellCycleModel* p_hepa_one_model2 = static_cast<StochasticOxygenBasedCellCycleModel*>(p_hepa_one_model->CreateCellCycleModel()); CellPtr p_hepa_one_cell2(new Cell(p_state, p_hepa_one_model2)); p_hepa_one_cell2->SetCellProliferativeType(p_stem_type); p_hepa_one_cell2->GetCellData()->SetItem("oxygen", hi_oxygen_concentration); p_hepa_one_cell2->InitialiseCellCycleModel(); TS_ASSERT_EQUALS(p_hepa_one_model2->ReadyToDivide(), false); TS_ASSERT_EQUALS(p_hepa_one_model2->GetCurrentCellCyclePhase(), M_PHASE); // Set up SimulationTime SimulationTime::Destroy(); p_simulation_time = SimulationTime::Instance(); p_simulation_time->SetStartTime(0.0); p_simulation_time->SetEndTimeAndNumberOfTimeSteps(2.0 * p_hepa_one_model2->GetCriticalHypoxicDuration(), num_steps); // Create a cell with a simple oxygen-based cell-cycle model StochasticOxygenBasedCellCycleModel* p_cell_model = new StochasticOxygenBasedCellCycleModel; p_cell_model->SetDimension(2); CellPtr p_apoptotic_cell(new Cell(p_state, p_cell_model)); p_apoptotic_cell->SetCellProliferativeType(p_stem_type); p_apoptotic_cell->GetCellData()->SetItem("oxygen", lo_oxygen_concentration); p_apoptotic_cell->InitialiseCellCycleModel(); // Force the cell to be apoptotic for (unsigned i = 0; i < num_steps; i++) { TS_ASSERT(!(p_apoptotic_cell->HasCellProperty<ApoptoticCellProperty>()) || p_simulation_time->GetTime() >= p_cell_model->GetCriticalHypoxicDuration()); p_simulation_time->IncrementTimeOneStep(); // Note that we need to pass in the updated G1 duration p_apoptotic_cell->ReadyToDivide(); } // Test that the cell is updated to be apoptotic TS_ASSERT_EQUALS(p_apoptotic_cell->HasCellProperty<ApoptoticCellProperty>(), true); TS_ASSERT_EQUALS(p_cell_model->GetCurrentHypoxicDuration(), 2.04); StochasticOxygenBasedCellCycleModel* p_cell_model2 = new StochasticOxygenBasedCellCycleModel; p_cell_model2->SetDimension(2); // Coverage p_cell_model2->SetMinimumGapDuration(1e20); TS_ASSERT_DELTA(p_cell_model2->GetMinimumGapDuration(), 1e20, 1e-4); CellPtr p_cell2(new Cell(p_state, p_cell_model2)); p_cell2->SetCellProliferativeType(p_stem_type); p_cell2->InitialiseCellCycleModel(); TS_ASSERT_DELTA(p_cell_model2->GetG2Duration(), 1e20, 1e-4); } void TestArchiveAlwaysDivideCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "AlwaysDivideCellCycleModel.arch"; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new AlwaysDivideCellCycleModel; p_model->SetDimension(2); p_model->SetBirthTime(-1.0); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; // Check private data has been restored correctly TS_ASSERT_DELTA(p_model2->GetBirthTime(), -1.0, 1e-12); TS_ASSERT_DELTA(p_model2->GetAge(), 1.0, 1e-12); TS_ASSERT_EQUALS(p_model2->GetDimension(), 2u); TS_ASSERT_EQUALS(p_model2->ReadyToDivide(), true); // Avoid memory leaks delete p_model2; } } void TestArchiveNoCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "NoCellCycleModel.arch"; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new NoCellCycleModel; p_model->SetDimension(2); p_model->SetBirthTime(-1.0); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; // Check private data has been restored correctly TS_ASSERT_DELTA(p_model2->GetBirthTime(), -1.0, 1e-12); TS_ASSERT_DELTA(p_model2->GetAge(), 1.0, 1e-12); TS_ASSERT_EQUALS(p_model2->GetDimension(), 2u); TS_ASSERT_EQUALS(p_model2->ReadyToDivide(), false); // Avoid memory leaks delete p_model2; } } void TestArchiveBernoulliTrialCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "BernoulliTrialCellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test = 0.0; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new BernoulliTrialCellCycleModel; p_model->SetDimension(2); p_model->SetBirthTime(-1.0); static_cast<BernoulliTrialCellCycleModel*>(p_model)->SetDivisionProbability(0.5); static_cast<BernoulliTrialCellCycleModel*>(p_model)->SetMinimumDivisionAge(0.1); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; // Check private data has been restored correctly TS_ASSERT_DELTA(p_model2->GetBirthTime(), -1.0, 1e-12); TS_ASSERT_DELTA(p_model2->GetAge(), 1.0, 1e-12); TS_ASSERT_EQUALS(p_model2->GetDimension(), 2u); TS_ASSERT_DELTA(static_cast<BernoulliTrialCellCycleModel*>(p_model2)->GetDivisionProbability(), 0.5, 1e-9); TS_ASSERT_DELTA(static_cast<BernoulliTrialCellCycleModel*>(p_model2)->GetMinimumDivisionAge(), 0.1, 1e-9); TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); // Avoid memory leaks delete p_model2; } } void TestArchiveBiasedBernoulliTrialCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "BiasedBernoulliTrialCellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test = 0.0; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new BiasedBernoulliTrialCellCycleModel; p_model->SetDimension(2); p_model->SetBirthTime(-1.0); static_cast<BiasedBernoulliTrialCellCycleModel*>(p_model)->SetMaxDivisionProbability(0.4); static_cast<BiasedBernoulliTrialCellCycleModel*>(p_model)->SetMinimumDivisionAge(0.7); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; // Check private data has been restored correctly TS_ASSERT_DELTA(p_model2->GetBirthTime(), -1.0, 1e-12); TS_ASSERT_DELTA(p_model2->GetAge(), 1.0, 1e-12); TS_ASSERT_EQUALS(p_model2->GetDimension(), 2u); TS_ASSERT_DELTA(static_cast<BiasedBernoulliTrialCellCycleModel*>(p_model2)->GetMaxDivisionProbability(), 0.4, 1e-9); TS_ASSERT_DELTA(static_cast<BiasedBernoulliTrialCellCycleModel*>(p_model2)->GetMinimumDivisionAge(), 0.7, 1e-9); TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); // Avoid memory leaks delete p_model2; } } void TestArchiveLabelDependentBernoulliTrialCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "LabelDependentBernoulliTrialCellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test = 0.0; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new LabelDependentBernoulliTrialCellCycleModel; p_model->SetDimension(2); p_model->SetBirthTime(-1.0); static_cast<LabelDependentBernoulliTrialCellCycleModel*>(p_model)->SetDivisionProbability(0.4); static_cast<LabelDependentBernoulliTrialCellCycleModel*>(p_model)->SetLabelledDivisionProbability(0.5); static_cast<LabelDependentBernoulliTrialCellCycleModel*>(p_model)->SetMinimumDivisionAge(0.7); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; // Check private data has been restored correctly TS_ASSERT_DELTA(p_model2->GetBirthTime(), -1.0, 1e-12); TS_ASSERT_DELTA(p_model2->GetAge(), 1.0, 1e-12); TS_ASSERT_EQUALS(p_model2->GetDimension(), 2u); TS_ASSERT_DELTA(static_cast<LabelDependentBernoulliTrialCellCycleModel*>(p_model2)->GetDivisionProbability(), 0.4, 1e-9); TS_ASSERT_DELTA(static_cast<LabelDependentBernoulliTrialCellCycleModel*>(p_model2)->GetLabelledDivisionProbability(), 0.5, 1e-9); TS_ASSERT_DELTA(static_cast<LabelDependentBernoulliTrialCellCycleModel*>(p_model2)->GetMinimumDivisionAge(), 0.7, 1e-9); TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); // Avoid memory leaks delete p_model2; } } void TestArchiveFixedG1GenerationalCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "FixedG1GenerationalCellCycleModel.arch"; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new FixedG1GenerationalCellCycleModel; p_model->SetDimension(2); p_model->SetBirthTime(-1.0); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; // Check private data has been restored correctly TS_ASSERT_DELTA(p_model2->GetBirthTime(), -1.0, 1e-12); TS_ASSERT_DELTA(p_model2->GetAge(), 1.0, 1e-12); TS_ASSERT_EQUALS(static_cast<AbstractPhaseBasedCellCycleModel*>(p_model2)->GetCurrentCellCyclePhase(), M_PHASE); TS_ASSERT_EQUALS(p_model2->GetDimension(), 2u); // Avoid memory leaks delete p_model2; } } void TestArchiveUniformG1GenerationalCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "UniformG1GenerationalCellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test = 0.0; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(2.0, 4); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new UniformG1GenerationalCellCycleModel; p_model->SetDimension(2); static_cast<UniformG1GenerationalCellCycleModel*>(p_model)->SetTransitCellG1Duration(1.0); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); // Avoid memory leaks delete p_model2; } } void TestArchiveUniformCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "UniformCellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test = 0.0; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(2.0, 4); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new UniformCellCycleModel; p_model->SetDimension(2); dynamic_cast<UniformCellCycleModel*>(p_model)->SetMinCellCycleDuration(1.0); dynamic_cast<UniformCellCycleModel*>(p_model)->SetMaxCellCycleDuration(2.0); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; TS_ASSERT_EQUALS(p_model2->GetDimension(), 2u); TS_ASSERT_DELTA(dynamic_cast<UniformCellCycleModel*>(p_model2)->GetMinCellCycleDuration(), 1.0, 1e-5); TS_ASSERT_DELTA(dynamic_cast<UniformCellCycleModel*>(p_model2)->GetMaxCellCycleDuration(), 2.0, 1e-5); TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); // Avoid memory leaks delete p_model2; } } void TestArchiveGammaG1CellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "GammaG1CellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test = 0.0; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(2.0, 4); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new GammaG1CellCycleModel; static_cast<GammaG1CellCycleModel*>(p_model)->SetShape(2.45); static_cast<GammaG1CellCycleModel*>(p_model)->SetScale(13.42); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); // Check private data has been restored correctly TS_ASSERT_DELTA(static_cast<GammaG1CellCycleModel*>(p_model2)->GetShape(), 2.45, 1e-12); TS_ASSERT_DELTA(static_cast<GammaG1CellCycleModel*>(p_model2)->GetScale(), 13.42, 1e-12); // Avoid memory leaks delete p_model2; } } void TestArchiveExponentialG1GenerationalCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "ExponentialG1GenerationalCellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test = 0.0; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(2.0, 4); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new ExponentialG1GenerationalCellCycleModel; static_cast<ExponentialG1GenerationalCellCycleModel*>(p_model)->SetRate(13.42); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); // Check private data has been restored correctly TS_ASSERT_DELTA(static_cast<ExponentialG1GenerationalCellCycleModel*>(p_model2)->GetRate(), 13.42, 1e-12); // Avoid memory leaks delete p_model2; } } void TestArchiveSimpleOxygenBasedCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "SimpleOxygenBasedCellCycleModel.arch"; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new SimpleOxygenBasedCellCycleModel; p_model->SetDimension(3); static_cast<SimpleOxygenBasedCellCycleModel*>(p_model)->SetHypoxicConcentration(0.8); static_cast<SimpleOxygenBasedCellCycleModel*>(p_model)->SetQuiescentConcentration(0.7); static_cast<SimpleOxygenBasedCellCycleModel*>(p_model)->SetCriticalHypoxicDuration(2.5); static_cast<SimpleOxygenBasedCellCycleModel*>(p_model)->SetCurrentHypoxiaOnsetTime(3.1); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; TS_ASSERT_DELTA(static_cast<SimpleOxygenBasedCellCycleModel*>(p_model2)->GetHypoxicConcentration(), 0.8, 1e-6); TS_ASSERT_DELTA(static_cast<SimpleOxygenBasedCellCycleModel*>(p_model2)->GetQuiescentConcentration(), 0.7, 1e-6); TS_ASSERT_DELTA(static_cast<SimpleOxygenBasedCellCycleModel*>(p_model2)->GetCriticalHypoxicDuration(), 2.5, 1e-6); TS_ASSERT_DELTA(static_cast<SimpleOxygenBasedCellCycleModel*>(p_model2)->GetCurrentHypoxiaOnsetTime(), 3.1, 1e-6); // Avoid memory leaks delete p_model2; } } void TestArchiveStochasticOxygenBasedCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "StochasticOxygenBasedCellCycleModel.arch"; // We will also test that the random number generator is archived correctly double random_number_test; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new StochasticOxygenBasedCellCycleModel; p_model->SetDimension(3); static_cast<StochasticOxygenBasedCellCycleModel*>(p_model)->SetHypoxicConcentration(0.8); static_cast<StochasticOxygenBasedCellCycleModel*>(p_model)->SetQuiescentConcentration(0.7); static_cast<StochasticOxygenBasedCellCycleModel*>(p_model)->SetCriticalHypoxicDuration(2.5); static_cast<StochasticOxygenBasedCellCycleModel*>(p_model)->SetCurrentHypoxiaOnsetTime(3.1); static_cast<StochasticOxygenBasedCellCycleModel*>(p_model)->GenerateStochasticG2Duration(); TS_ASSERT_DELTA(static_cast<StochasticOxygenBasedCellCycleModel*>(p_model)->GetG2Duration(), 3.0822, 1e-4); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); random_number_test = RandomNumberGenerator::Instance()->ranf(); RandomNumberGenerator::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; TS_ASSERT_DELTA(static_cast<StochasticOxygenBasedCellCycleModel*>(p_model2)->GetG2Duration(), 3.0822, 1e-4); TS_ASSERT_DELTA(static_cast<StochasticOxygenBasedCellCycleModel*>(p_model2)->GetHypoxicConcentration(), 0.8, 1e-6); TS_ASSERT_DELTA(static_cast<StochasticOxygenBasedCellCycleModel*>(p_model2)->GetQuiescentConcentration(), 0.7, 1e-6); TS_ASSERT_DELTA(static_cast<StochasticOxygenBasedCellCycleModel*>(p_model2)->GetCriticalHypoxicDuration(), 2.5, 1e-6); TS_ASSERT_DELTA(static_cast<StochasticOxygenBasedCellCycleModel*>(p_model2)->GetCurrentHypoxiaOnsetTime(), 3.1, 1e-6); TS_ASSERT_DELTA(RandomNumberGenerator::Instance()->ranf(), random_number_test, 1e-6); // Avoid memory leaks delete p_model2; } } void TestArchiveContactInhibitionCellCycleModel() { OutputFileHandler handler("archive", false); std::string archive_filename = handler.GetOutputDirectoryFullPath() + "ContactInhibitionCellCycleModel.arch"; { // We must set up SimulationTime to avoid memory leaks SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1); // As usual, we archive via a pointer to the most abstract class possible AbstractCellCycleModel* const p_model = new ContactInhibitionCellCycleModel(); p_model->SetDimension(1); p_model->SetBirthTime(-1.5); static_cast<ContactInhibitionCellCycleModel*>(p_model)->SetQuiescentVolumeFraction(0.5); static_cast<ContactInhibitionCellCycleModel*>(p_model)->SetEquilibriumVolume(1.0); std::ofstream ofs(archive_filename.c_str()); boost::archive::text_oarchive output_arch(ofs); output_arch << p_model; delete p_model; SimulationTime::Destroy(); } { // We must set SimulationTime::mStartTime here to avoid tripping an assertion SimulationTime::Instance()->SetStartTime(0.0); AbstractCellCycleModel* p_model2; std::ifstream ifs(archive_filename.c_str(), std::ios::binary); boost::archive::text_iarchive input_arch(ifs); input_arch >> p_model2; TS_ASSERT_EQUALS(p_model2->GetDimension(), 1u); TS_ASSERT_DELTA(p_model2->GetBirthTime(), -1.5, 1e-12); TS_ASSERT_DELTA(p_model2->GetAge(), 1.5, 1e-12); TS_ASSERT_EQUALS(static_cast<AbstractPhaseBasedCellCycleModel*>(p_model2)->GetCurrentCellCyclePhase(), M_PHASE); TS_ASSERT_DELTA(static_cast<ContactInhibitionCellCycleModel*>(p_model2)->GetQuiescentVolumeFraction(), 0.5, 1e-6); TS_ASSERT_DELTA(static_cast<ContactInhibitionCellCycleModel*>(p_model2)->GetEquilibriumVolume(), 1.0, 1e-6); // Avoid memory leaks delete p_model2; } } void TestCellCycleModelOutputParameters() { std::string output_directory = "TestCellCycleModelOutputParameters"; OutputFileHandler output_file_handler(output_directory, false); // Test with NoCellCycleModel NoCellCycleModel no_model; TS_ASSERT_EQUALS(no_model.GetIdentifier(), "NoCellCycleModel"); out_stream no_model_parameter_file = output_file_handler.OpenOutputFile("no_model_results.parameters"); no_model.OutputCellCycleModelParameters(no_model_parameter_file); no_model_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("no_model_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/no_model_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with BernoulliTrialCellCycleModel BernoulliTrialCellCycleModel random_division_cell_cycle_model; TS_ASSERT_EQUALS(random_division_cell_cycle_model.GetIdentifier(), "BernoulliTrialCellCycleModel"); out_stream random_division_parameter_file = output_file_handler.OpenOutputFile("random_division_results.parameters"); random_division_cell_cycle_model.OutputCellCycleModelParameters(random_division_parameter_file); random_division_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("random_division_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/random_division_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with BiasedBernoulliTrialCellCycleModel BiasedBernoulliTrialCellCycleModel biased_random_division_cell_cycle_model; TS_ASSERT_EQUALS(biased_random_division_cell_cycle_model.GetIdentifier(), "BiasedBernoulliTrialCellCycleModel"); out_stream biased_random_division_parameter_file = output_file_handler.OpenOutputFile("biased_random_division_results.parameters"); biased_random_division_cell_cycle_model.OutputCellCycleModelParameters(biased_random_division_parameter_file); biased_random_division_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("biased_random_division_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/biased_random_division_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with LabelDependentBernoulliTrialCellCycleModel LabelDependentBernoulliTrialCellCycleModel label_random_division_cell_cycle_model; TS_ASSERT_EQUALS(label_random_division_cell_cycle_model.GetIdentifier(), "LabelDependentBernoulliTrialCellCycleModel"); out_stream label_random_division_parameter_file = output_file_handler.OpenOutputFile("label_random_division_results.parameters"); label_random_division_cell_cycle_model.OutputCellCycleModelParameters(label_random_division_parameter_file); label_random_division_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("label_random_division_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/label_random_division_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with FixedG1GenerationalCellCycleModel FixedG1GenerationalCellCycleModel fixed_duration_generation_based_cell_cycle_model; TS_ASSERT_EQUALS(fixed_duration_generation_based_cell_cycle_model.GetIdentifier(), "FixedG1GenerationalCellCycleModel"); out_stream fixed_duration_generation_based_parameter_file = output_file_handler.OpenOutputFile("fixed_duration_generation_based_results.parameters"); fixed_duration_generation_based_cell_cycle_model.OutputCellCycleModelParameters(fixed_duration_generation_based_parameter_file); fixed_duration_generation_based_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("fixed_duration_generation_based_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/fixed_duration_generation_based_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with UniformG1GenerationalCellCycleModel UniformG1GenerationalCellCycleModel uniform_distributed_generation_based_cell_cycle_model; TS_ASSERT_EQUALS(uniform_distributed_generation_based_cell_cycle_model.GetIdentifier(), "UniformG1GenerationalCellCycleModel"); out_stream uniform_distributed_generation_based_parameter_file = output_file_handler.OpenOutputFile("uniform_distributed_generation_based_results.parameters"); uniform_distributed_generation_based_cell_cycle_model.OutputCellCycleModelParameters(uniform_distributed_generation_based_parameter_file); uniform_distributed_generation_based_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("uniform_distributed_generation_based_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/uniform_distributed_generation_based_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with UniformCellCycleModel UniformCellCycleModel uniform_distributed_cell_cycle_model; TS_ASSERT_EQUALS(uniform_distributed_cell_cycle_model.GetIdentifier(), "UniformCellCycleModel"); out_stream uniform_distributed_parameter_file = output_file_handler.OpenOutputFile("uniform_distributed_results.parameters"); uniform_distributed_cell_cycle_model.OutputCellCycleModelParameters(uniform_distributed_parameter_file); uniform_distributed_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("uniform_distributed_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/uniform_distributed_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with SimpleOxygenBasedCellCycleModel SimpleOxygenBasedCellCycleModel simple_oxygen_based_cell_cycle_model; TS_ASSERT_EQUALS(simple_oxygen_based_cell_cycle_model.GetIdentifier(), "SimpleOxygenBasedCellCycleModel"); out_stream simple_oxygen_based_parameter_file = output_file_handler.OpenOutputFile("simple_oxygen_based_results.parameters"); simple_oxygen_based_cell_cycle_model.OutputCellCycleModelParameters(simple_oxygen_based_parameter_file); simple_oxygen_based_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("simple_oxygen_based_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/simple_oxygen_based_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with StochasticOxygenBasedCellCycleModel StochasticOxygenBasedCellCycleModel stochastic_oxygen_based_cell_cycle_model; TS_ASSERT_EQUALS(stochastic_oxygen_based_cell_cycle_model.GetIdentifier(), "StochasticOxygenBasedCellCycleModel"); out_stream stochastic_oxygen_based_parameter_file = output_file_handler.OpenOutputFile("stochastic_oxygen_based_results.parameters"); stochastic_oxygen_based_cell_cycle_model.OutputCellCycleModelParameters(stochastic_oxygen_based_parameter_file); stochastic_oxygen_based_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("stochastic_oxygen_based_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/stochastic_oxygen_based_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with ContactInhibitionCellCycleModel ContactInhibitionCellCycleModel contact_inhibition_cell_cycle_model; contact_inhibition_cell_cycle_model.SetQuiescentVolumeFraction(0.5); contact_inhibition_cell_cycle_model.SetEquilibriumVolume(1.0); TS_ASSERT_EQUALS(contact_inhibition_cell_cycle_model.GetIdentifier(), "ContactInhibitionCellCycleModel"); out_stream contact_inhibition_parameter_file = output_file_handler.OpenOutputFile("contact_inhibition_results.parameters"); contact_inhibition_cell_cycle_model.OutputCellCycleModelParameters(contact_inhibition_parameter_file); contact_inhibition_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("contact_inhibition_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/contact_inhibition_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with GammaG1CellCycleModel GammaG1CellCycleModel gamma_distributed_cell_cycle_model; gamma_distributed_cell_cycle_model.SetShape(0.85); gamma_distributed_cell_cycle_model.SetScale(1.23); TS_ASSERT_EQUALS(gamma_distributed_cell_cycle_model.GetIdentifier(), "GammaG1CellCycleModel"); out_stream gamma_distributed_parameter_file = output_file_handler.OpenOutputFile("gamma_distributed_results.parameters"); gamma_distributed_cell_cycle_model.OutputCellCycleModelParameters(gamma_distributed_parameter_file); gamma_distributed_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("gamma_distributed_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/gamma_distributed_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with ExponentialG1GenerationalCellCycleModel ExponentialG1GenerationalCellCycleModel exponential_cell_cycle_model; exponential_cell_cycle_model.SetRate(1.23); TS_ASSERT_EQUALS(exponential_cell_cycle_model.GetIdentifier(), "ExponentialG1GenerationalCellCycleModel"); out_stream exponential_parameter_file = output_file_handler.OpenOutputFile("exponential_results.parameters"); exponential_cell_cycle_model.OutputCellCycleModelParameters(exponential_parameter_file); exponential_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("exponential_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/exponential_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with FixedSequenceCellCycleModel FixedSequenceCellCycleModel fixed_sequence_cell_cycle_model; fixed_sequence_cell_cycle_model.SetRate(1.23); TS_ASSERT_EQUALS(fixed_sequence_cell_cycle_model.GetIdentifier(), "FixedSequenceCellCycleModel"); out_stream fixed_sequence_parameter_file = output_file_handler.OpenOutputFile("fixed_sequence_results.parameters"); fixed_sequence_cell_cycle_model.OutputCellCycleModelParameters(fixed_sequence_parameter_file); fixed_sequence_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("fixed_sequence_results.parameters"); FileFinder reference_file("cell_based/test/data/TestCellCycleModels/fixed_sequence_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } // Test with AlwaysDivideCellCycleModel AlwaysDivideCellCycleModel always_divide_cell_cycle_model; TS_ASSERT_EQUALS(always_divide_cell_cycle_model.GetIdentifier(), "AlwaysDivideCellCycleModel"); out_stream always_divide_parameter_file = output_file_handler.OpenOutputFile("always_divide_results.parameters"); always_divide_cell_cycle_model.OutputCellCycleModelParameters(always_divide_parameter_file); always_divide_parameter_file->close(); { FileFinder generated_file = output_file_handler.FindFile("always_divide_results.parameters"); //The model does not have any parameters and therefore it is compared to NoCellCycleModel FileFinder reference_file("cell_based/test/data/TestCellCycleModels/no_model_results.parameters", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated_file, reference_file); TS_ASSERT(comparer.CompareFiles()); } CellCycleTimesGenerator::Destroy(); } void TestUniformG1GenerationalCellCycleModelNoGenerations() { UniformG1GenerationalCellCycleModel* p_stem_model = new UniformG1GenerationalCellCycleModel; // Change G1 duration for this model p_stem_model->SetStemCellG1Duration(1.0); // Change number of generations p_stem_model->SetMaxTransitGenerations(0); MAKE_PTR(WildTypeCellMutationState, p_healthy_state); MAKE_PTR(StemCellProliferativeType, p_stem_type); MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type); CellPtr p_stem_cell(new Cell(p_healthy_state, p_stem_model)); p_stem_cell->SetCellProliferativeType(p_stem_type); p_stem_cell->SetBirthTime(-4.0 * (p_stem_model->GetStemCellG1Duration() + p_stem_model->GetSG2MDuration())); p_stem_cell->InitialiseCellCycleModel(); p_stem_cell->ReadyToDivide(); // Run reset for division on cell cycle model p_stem_cell->GetCellCycleModel()->ResetForDivision(); // Check that it is still a stem cell TS_ASSERT(p_stem_cell->GetCellProliferativeType()->IsType<StemCellProliferativeType>()); } }; #endif /*TESTSIMPLECELLCYCLEMODELS_HPP_*/
#include <fstream> #include <string> #include <map> #include <algorithm> #include "checker.h" #include "exception.h" #include "pseudoformatter.h" void Checker::check_if_declaration_block_is_over() { if( env.section.top() != S_CODE && ( env.declaration_depth.size() == 0 || env.declaration_depth.top() < lines[token->line_index].expected_depth)) { switch(token->type) { case TT_KEYWORD_DECLARING_VARBLOCK: case TT_KEYWORD_DECLARING_FUNC: case TT_VARBLOCK: case TT_TYPEBLOCK: case TT_PASBRACKET_OPEN: case TT_KEYWORD: case TT_LABEL: case TT_KEYWORD_WITH_FOLLOWING_OPERATION: case TT_KEYWORD_WITH_FOLLOWING_OPERATION_AFTER_BRACE: env.section.top() = S_CODE; break; } } }; bool Checker::try_bind_to_title() { if(file_language.first != L_PASCAL) return true; if(env.section.top() == S_CODE) { switch(token->type) { case TT_KEYWORD_DECLARING_VARBLOCK: case TT_KEYWORD_DECLARING_FUNC: case TT_VARBLOCK: case TT_TYPEBLOCK: case TT_PASBRACKET_OPEN: // if(env.title_opened_at_depth.size() != 0) // { // if(env.title_opened_at_depth.top() == -1) // env.title_opened_at_depth.top() = lines[token->line_index].expected_depth; // return env.title_opened_at_depth.top() == lines[token->line_index].expected_depth; // } break; } } return false; } void Checker::try_add_indent() { if(!next_is_blockbracket(true)) { env.expected_depth++; env.close_on_end.top()++; } env.indented_operation_expected = false; } void Checker::calculate_expected_depth() { env.expected_depth = 0; env.expected_extra_depth = 0; token = tokens.begin(); while(token != tokens.end()) { int line_index = token->line_index; if(env.indented_operation_expected) try_add_indent(); lines[line_index].expected_depth = env.expected_depth; lines[line_index].expected_extra_depth = env.expected_extra_depth; for(; token->line_index == line_index && token != tokens.end(); ++token) { if(env.indented_operation_expected) try_add_indent(); check_if_declaration_block_is_over(); //bool bound = try_bind_to_title(); switch(token->type) { case TT_WHITESPACE: if(token->start == 0 && token->line.size() != lines[line_index].size) { lines[line_index].depth_by_fact = token->line.size(); prefix_preprocessing(); } break; case TT_VARBLOCK: case TT_TYPEBLOCK: if(env.braces_opened == 0) env.section.top() = token->type == TT_VARBLOCK ? S_VAR : S_TYPE; //for next env.expected_depth++; env.expected_extra_depth++; //for current if(token->start == lines[line_index].depth_by_fact) lines[line_index].expected_extra_depth++; break; case TT_IDENTIFIER: if(env.section.top() == S_TYPE) env.list_of_names[token->line] = NT_CLASS; if(env.section.top() != S_CODE) //pascal declaration block { int e_d = lines[line_index].expected_depth; if(env.declaration_depth.size() == 0 || env.declaration_depth.top() != e_d) { env.declaration_depth.push(e_d); } } break; case TT_SEMICOLON: if(env.section.top() != S_CODE) { int e_d = lines[line_index].expected_depth; if(env.declaration_depth.size() != 0 && env.declaration_depth.top() == e_d) { env.declaration_depth.pop(); } } if(env.braces_opened == 0) env.close_opened_statements(); break; case TT_CBRACKET_OPEN: case TT_PASBRACKET_OPEN: case TT_KEYWORD_DECLARING_VARBLOCK: env.section.push(token->type == TT_KEYWORD_DECLARING_VARBLOCK ? S_VAR : S_CODE); //for current if(token->start == lines[line_index].depth_by_fact) lines[line_index].expected_extra_depth++; env.open_blockbracket(); break; case TT_CBRACKET_CLOSE: case TT_PASBRACKET_CLOSE: env.section.pop(); //for current if(token->start == lines[line_index].depth_by_fact) lines[line_index].expected_depth--; env.close_blockbracket(); break; case TT_CASE: env.case_unmatched = true; break; case TT_OF: if(env.case_unmatched) { env.case_unmatched = false; env.section.push(S_CODE); env.open_blockbracket(); } break; case TT_FUNCTION: break; case TT_KEYWORD_DECLARING_FUNC: //env.create_title(); env.section.top() = S_CODE; break; case TT_LABEL: case TT_SWITCH_LABELS: break; case TT_BRACE: if(token->line[0] == '(') { env.expected_depth++; env.braces_opened++; } else { env.expected_depth--; env.braces_opened--; } if(env.braces_opened == 0 && env.indented_operation_expected_after_braces) { env.indented_operation_expected_after_braces = false; env.indented_operation_expected = true; } break; case TT_KEYWORD_WITH_FOLLOWING_OPERATION: env.indented_operation_expected = true; if(keyword_equal("else")) { env.close_opened_statements(); env.close_on_end.top() = env.if_depth.top().first - lines[token->line_index].expected_depth; lines[token->line_index].expected_depth = env.if_depth.top().first; env.if_depth.pop(); env.expected_depth = lines[token->line_index].expected_depth; } break; case TT_KEYWORD_WITH_FOLLOWING_OPERATION_AFTER_BRACE: env.indented_operation_expected_after_braces = true; break; } if(keyword_equal("if")) { env.if_depth.push(std::make_pair(lines[token->line_index].expected_depth, false)); } } } } bool Checker::is_pascal_functional_begin() { return token->type == TT_PASBRACKET_OPEN && ( try_bind_to_title() || lines[token->line_index].expected_depth == 0); }
#pragma once #include <QString> #include "FunctionTreeNodeWithOperand.h" #include "FunctionTreeNodeWithOperation.h" class Function { private: QString functionString; FunctionTreeNode* functionTreeRoot; void plotTreeFromFunctionString(); bool isElementLeftBracketSymbol(QChar element); bool isElementRightBracketSymbol(QChar element); bool isElementOperationSymbol(QChar element); public: Function(QString functionString); ~Function(); QString getDerivative(QChar derivativeBasis); QString simplify(); QMap<QString, int> finalConvertion(QString string); };
#include "Task.h" #include "../pathfinding/pathfinder.h" #include "../config/Config.h" using namespace Task; EntityManager* Action::entityManager = NULL; LevelManager* Action::levelManager = NULL; void Action::preRun() { if (entityName != "") entity = &entityManager->getEntity(entityName); if (targetName != "") target = &entityManager->getEntity(targetName); //grid = levelManager->getLevel(0); grid = levelManager->getObsMap(); init(); } bool Action::getResult() { return result; }
#include <stdio.h> #include <stdlib.h> typedef struct { int num; double fact; }numbers_t; int is_prime(int num, int i)//i is a divisor { if (i == 1) { return 1; } else if (num%i==0) { return 0; } else { is_prime(num, i + 1); } } double fact(int num) { if (num == 1) { return 1; } else { return(num * fact(num - 1)); } } int main() { int m, n; int i ; int k=0; int prime; numbers_t *odd; printf("Enter the value of m:"); scanf("%d", &m); printf("Enter the value of n:"); scanf("%d", &n); odd = (numbers_t *)malloc((m / 2 + 1) * sizeof(numbers_t)); for ( i = 1; i < m; i++) { if (i%2==1) { odd[k].num == i; odd[k].fact = fact(i); k++; } } printf("ODD NUMBERS\n"); for ( i = 0; i < k; i++) { printf(" %d %0.2f\n", odd[i].num, odd[i].fact); } system("PAUSE"); return 0; }
/* 1953. 탈주범 검거 다시풀기 */ #include <iostream> #include <vector> #include <queue> using namespace std; typedef pair<int, int> pii; typedef long long ll; int T, N, M, R, C, L, board[50][50], cnt = 0; bool visited[50][50]; bool dir[4]; int dr[4] = {-1,0,1,0}; int dc[4] = {0,1,0,-1}; bool movable(int dir, int t) { if(dir == 0 && (t == 1 || t == 2 || t == 5 || t == 6)) return true; if(dir == 1 && (t == 1 || t == 3 || t == 6 || t == 7)) return true; if(dir == 2 && (t == 1 || t == 2 || t == 4 || t == 7)) return true; if(dir == 3 && (t == 1 || t == 3 || t == 4 || t == 5)) return true; return false; } void make_direction(int t) { memset(dir, false, sizeof(dir)); if(t == 2) { dir[0] = true; dir[2] = true; } if(t == 3) { dir[1] = true; dir[3] = true; } if(t == 4) { dir[0] = true; dir[1] = true; } if(t == 5) { dir[1] = true; dir[2] = true; } if(t == 6) { dir[3] = true; dir[2] = true; } if(t == 7) { dir[0] = true; dir[3] = true; } } void bfs() { queue<pii> q; q.push(make_pair(R, C)); visited[R][C] = true; cnt = 1; int t = 1; while(!q.empty()) { if(t == L) return; int size = q.size(); for(int i = 0; i < size; i++) { int r = q.front().first; int c = q.front().second; q.pop(); if(r == 2 && c == 4) cout << "dfd"; int type = board[r][c]; if(type == 1) memset(dir, true, sizeof(dir)); else make_direction(type); for(int i = 0; i < 4; i++) { if(!dir[i]) continue; int nr = r + dr[i]; int nc = c + dc[i]; if(nr < 0 || nr > N-1 || nc < 0 || nc > M-1 || visited[nr][nc] || board[nr][nc] == 0) continue; if(movable(i, board[nr][nc])) { visited[nr][nc] = true; q.push(make_pair(nr, nc)); cnt++; } } } t++; } } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> T; for(int t = 1; t <= T; t++) { cin >> N >> M >> R >> C >> L; for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) cin >> board[i][j]; memset(visited, false, sizeof(visited)); bfs(); cout << endl; for(int i = 0; i < N; i++) { for(int j = 0; j < M; j++) cout << visited[i][j] << ' '; cout << endl; } printf("#%d %d", t, cnt); } return 0; }
// Copyright (c) 2019, Alliance for Sustainable Energy, LLC // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AIRFLOWNETWORK_TRANSPORT_HPP #define AIRFLOWNETWORK_TRANSPORT_HPP #include <string> #include <vector> #include <type_traits> #include <iostream> #include "filters.hpp" namespace airflownetwork { namespace transport { template <typename L, typename M, typename K> void matrix(const K& key, M& matrix, L& links) { for (auto& link : links) { // Compute the inefficiency double ineff = 1.0; for (auto& filter : link.filters[key]) { // Expect filters found via a key, get the combined efficiency with a schedule value double eff = filter.efficiency * filter.control; if (eff == 1.0) { // Nothing is going to be transported // link.active = false; goto inactive; } ineff *= (1.0 - eff); } if (link.nf == 1) { if (link.flow > 0.0) { matrix.coeffRef(link.node0.index, link.node0.index) -= link.flow; // This is a diagonal entry matrix.coeffRef(link.node1.index, link.node0.index) += link.flow * ineff; } else if (link.flow < 0) { matrix.coeffRef(link.node0.index, link.node1.index) -= link.flow * ineff; matrix.coeffRef(link.node1.index, link.node1.index) += link.flow; // This is a diagonal entry } } else if (link.nf == 2) { // This is not tested yet if (link.flow0 > 0.0) { matrix.coeffRef(link.node0.index, link.node0.index) -= link.flow0; // This is a diagonal entry matrix.coeffRef(link.node1.index, link.node0.index) += link.flow0 * ineff; } if (link.flow1 > 0.0) { matrix.coeffRef(link.node0.index, link.node1.index) += link.flow1 * ineff; matrix.coeffRef(link.node1.index, link.node1.index) -= link.flow1; // This is a diagonal entry } } inactive:; } } template <typename M, typename V> void explicit_euler(double h, M& matrix, V& G0, V& R0, V& A0, V& A, V& C) { C = (A0.cwiseProduct(C) + h *(matrix*C - R0.cwiseProduct(C) + G0)).cwiseQuotient(A); } template <typename S, typename M, typename V> void implicit_euler(S &solver, double h, M& matrix, V& G, V& R, V& A0, V& A, V& C) { // Set up matrix *= -h; matrix += (A + h*R).asDiagonal(); solver.compute(matrix); // Solve G *= h; G += A.cwiseProduct(C); C = solver.solve(G); } template <typename S, typename M, typename V> void crank_nicolson(S& solver, double h, M& matrix, V& G0, V& G, V& R0, V& R, V& A0, V& A, V& C) { h *= 0.5; V hH = h * (matrix * C - R0.cwiseProduct(C) + G0); // Set up matrix *= -h; matrix += (A + h * R).asDiagonal(); solver.compute(matrix); // Solve G *= h; G += A0.cwiseProduct(C); G += hH; C = solver.solve(G); } } } #endif // !AIRFLOWNETWORK_TRANSPORT_HPP
#pragma once #include <iostream> #include <string> using namespace std; class Node { public: // 생성자 Node(string w = "", string m = "", Node* l = nullptr, Node* r = nullptr) : word(w), mean(m), left(l), right(r) { } // 단어설정 : 단어, 뜻을 입력 bool setKeyword(string w, string m) { word = w; mean = m; }; // 단어 반환 string getWord() { return word; }; // 뜻 반환 string getMean() { return mean; }; // 왼쪽 노드 반환 Node* getLeftNode() { return left; }; // 오른쪽 노드 반환 Node* getRightNdoe() { return right; }; // 왼쪽 노드 설정 : 입력받은 노드를 왼쪽 자식노드로 이용 bool setLeftNode(Node* n) { left = n; }; // 오른쪽 노드 설정 : 입력받은 노드를 오른쪽 자식노드로 이용 bool setRightNode(Node* n) { right = n; }; private: string word, mean; // 단어, 뜻 Node* left; // 왼쪽노드 Node* right; // 오른쪽노드 }; class Dictionary { public: Dictionary() : root(NULL) {}; // 데이터 중복 여부 확인 bool searchData(string d); // 데이터 추가 bool insertData(string d); // 데이터 삭제 bool removeData(string d); // 중위순회하며 데이터 출력 : 정렬된 순서로 출력하기 위함 void inorderPrint(); private: Node* root; };
#include <iostream> #include <fstream> #include <algorithm> #include <vector> void printVec(std::vector<std::string> vec){ for (size_t i = 0; i < vec.size(); i++){ std::cout << vec[i] << std::endl; } } int main(int argc, char ** argv){ std::vector<std::string> vec; std::string str; std::ifstream file; if(argc == 1){ while(!std::cin.eof()){ std::getline(std::cin, str); vec.push_back(str); std::sort(vec.begin(), vec.end()); printVec(vec); vec.clear(); } }else{ for (int i = 1; i < argc; i++){ file.open(argv[i]); if(file.fail()){ std::cerr << "fail to open file" << std::endl; exit(EXIT_FAILURE); } while(!file.eof()){ std::getline(file, str); vec.push_back(str); } file.close(); std::sort(vec.begin(), vec.end()); printVec(vec); vec.clear(); } } return 0; }
// This file has been generated by Py++. #include "boost/python.hpp" #include "generators/include/python_CEGUI.h" #include "MCLGridRef.pypp.hpp" namespace bp = boost::python; void register_MCLGridRef_class(){ { //::CEGUI::MCLGridRef typedef bp::class_< CEGUI::MCLGridRef > MCLGridRef_exposer_t; MCLGridRef_exposer_t MCLGridRef_exposer = MCLGridRef_exposer_t( "MCLGridRef", "*!\n\ \n\ Simple grid index structure.\n\ *\n", bp::init< CEGUI::uint, CEGUI::uint >(( bp::arg("r"), bp::arg("c") )) ); bp::scope MCLGridRef_scope( MCLGridRef_exposer ); MCLGridRef_exposer.def( bp::self != bp::self ); MCLGridRef_exposer.def( bp::self < bp::self ); MCLGridRef_exposer.def( bp::self <= bp::self ); { //::CEGUI::MCLGridRef::operator= typedef ::CEGUI::MCLGridRef & ( ::CEGUI::MCLGridRef::*assign_function_type )( ::CEGUI::MCLGridRef const & ) ; MCLGridRef_exposer.def( "assign" , assign_function_type( &::CEGUI::MCLGridRef::operator= ) , ( bp::arg("rhs") ) , bp::return_self< >() , "operators\n" ); } MCLGridRef_exposer.def( bp::self == bp::self ); MCLGridRef_exposer.def( bp::self > bp::self ); MCLGridRef_exposer.def( bp::self >= bp::self ); MCLGridRef_exposer.def_readwrite( "column", &CEGUI::MCLGridRef::column ); MCLGridRef_exposer.def_readwrite( "row", &CEGUI::MCLGridRef::row ); } }
#ifndef FU_GEN_PIPELINE_EDGE_H #define FU_GEN_PIPELINE_EDGE_H class IPipelineEdgeListener { public: virtual void OnClicked() = 0; virtual void OnEndpointDeleted() = 0; virtual void OnDeleted() = 0; // IPipelineEdgeListener() {} virtual ~IPipelineEdgeListener() {} }; class FuGenPipelineEdge; class IPipelineEdgeModel { public: // virtual void SetPipelineEdge(FuGenPipelineEdge *pipeline_edge) = 0; // IPipelineEdgeModel() {} // virtual ~IPipelineEdgeModel() {} }; #include <QGraphicsLineItem> #include <QGraphicsSceneMouseEvent> #include <QPainter> #include <QStyleOptionGraphicsItem> #include <QWidget> #include "FuGenPipelineNode.h" #include <list> #include <iostream> class FuGenPipelineEdge : public QGraphicsLineItem { private: // std::list<IPipelineEdgeListener *> Listeners; // class EndpointListener : public IPipelineNodeListener { private: bool IsBegin; FuGenPipelineEdge *Edge; // bool NodeDeleted = false; // public: // bool IsDeleted() { return NodeDeleted; } // virtual void OnClicked() override {} // virtual void OnPositionChanged(int x,int y) override { if(IsBegin) {Edge->RefreshBeginPosition(x,y);} else {Edge->RefreshEndPosition(x,y);} } // virtual void OnDeleted() override { NodeDeleted = true; Edge->NotifyEndpointDeleted(); } // EndpointListener(FuGenPipelineEdge *edge,bool is_begin,FuGenPipelineNode *end_point) :Edge(edge),IsBegin(is_begin) { end_point->AddListener(this); //std::cout << "Created " << this << std::endl; } // virtual ~EndpointListener() override { //std::cout << "Deleted " << this << std::endl; } }; // FuGenPipelineNode *BeginNode; FuGenPipelineNode *EndNode; // EndpointListener BeginListener; EndpointListener EndListener; // IPipelineEdgeModel *EdgeModel; // void NotifyEndpointDeleted() { for(IPipelineEdgeListener *Listener : Listeners) { Listener->OnEndpointDeleted(); } } // void RefreshBeginPosition(int x,int y) { if(!EndListener.IsDeleted()) { setLine(QLineF(QPointF(x,y),EndNode->GetCenter())); } } // void RefreshEndPosition(int x,int y) { if(!BeginListener.IsDeleted()) { setLine(QLineF(BeginNode->GetCenter(),QPointF(x,y))); } } // protected: // virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; // virtual void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget) override; // public: // void SetModel(IPipelineEdgeModel *new_model) { EdgeModel = new_model; EdgeModel->SetPipelineEdge(this); } // IPipelineEdgeModel *GetModel() { return EdgeModel; } // void AddListener(IPipelineEdgeListener *new_listener) { Listeners.push_back(new_listener); } // void RemoveListener(IPipelineEdgeListener *removable_listener) { Listeners.remove(removable_listener); } // FuGenPipelineEdge(FuGenPipelineNode *begin_node,FuGenPipelineNode *end_node); // virtual ~FuGenPipelineEdge() override; /* * End of class */ }; #endif // FU_GEN_PIPELINE_EDGE_H
/// @file Logging.h /// /// Wrapper for log4cxx /// /// @copyright (c) 2012 CSIRO /// Australia Telescope National Facility (ATNF) /// Commonwealth Scientific and Industrial Research Organisation (CSIRO) /// PO Box 76, Epping NSW 1710, Australia /// atnf-enquiries@csiro.au /// /// This file is part of the ASKAP software distribution. /// /// The ASKAP software distribution 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 /// /// @author Craig Haskins <Craig.Haskins@csiro.au> /// #ifndef __IOC_LOGGING_H__ #define __IOC_LOGGING_H__ #ifdef __cplusplus namespace askap { namespace ioclog { #endif #ifdef ASKAP_PACKAGE_NAME #define PACKAGE_NAME ASKAP_PACKAGE_NAME #ifndef LOGGER_PREFIX #define LOGGER_PREFIX "askap." #endif #else #ifndef LOGGER_PREFIX #define LOGGER_PREFIX "epics." #endif #endif #ifndef PACKAGE_NAME #define PACKAGE_NAME "unknown" #endif typedef enum { LOG_LEVEL_OFF, LOG_LEVEL_FATAL, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_TRACE, LOG_LEVEL_COUNT } IocLogLevel; typedef struct _IOC_LOG { int (*configure)(const char *logConfig); int (*isLevelEnabled)(IocLogLevel level, const char*logger); void (*forcedLog)(const char *logger, IocLogLevel level, const char* file, const char *func, const int line, const char* fmt, ...); void (*pushContext)(const char* fmt, ...); void (*popContext)(); } IOC_LOG; #ifdef __cplusplus } } #endif #ifdef __cplusplus #include <log4cxx/logger.h> #include <log4cxx/ndc.h> namespace askap { namespace ioclog { typedef log4cxx::LoggerPtr IocLogger; inline std::string loggerName(const std::string& inname) { const std::string name(LOGGER_PREFIX); if (inname.length() > 0) { if (inname[0] == '.') { return (name + std::string(PACKAGE_NAME) + inname); } else { return (name + inname); } } return (name + std::string(PACKAGE_NAME)); } #define CREATE_IOC_LOGGER(logName) log4cxx::Logger::getLogger(askap::ioclog::loggerName(logName)) #define CREATE_NAMED_LOGGER(namedLogger, logName) \ static askap::ioclog::IocLogger namedLogger = CREATE_IOC_LOGGER(logName) #define CREATE_LOGGER(logName) CREATE_NAMED_LOGGER(LOGGER, logName) #define LOG_PUSH_CONTEXT(fmt, ...) log_push_context(fmt, ##__VA_ARGS__) #define LOG_POP_CONTEXT() log_pop_context() #define LOG_TRACE(fmt, ...) LOG_TRACE2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_DEBUG(fmt, ...) LOG_DEBUG2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_INFO(fmt, ...) LOG_INFO2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_WARN(fmt, ...) LOG_WARN2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_ERROR(fmt, ...) LOG_ERROR2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_FATAL(fmt, ...) LOG_FATAL2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_MSG(level, logger, fmt, ...) if (LOG4CXX_UNLIKELY(logger->is##level##Enabled())) {\ askap::ioclog::log_msg(logger, log4cxx::Level::get##level(),\ LOG4CXX_LOCATION, fmt, ##__VA_ARGS__); \ } #define LOG_TRACE2(logger, fmt, ...) LOG_MSG(Trace, logger, fmt, ##__VA_ARGS__) #define LOG_DEBUG2(logger, fmt, ...) LOG_MSG(Debug, logger, fmt, ##__VA_ARGS__) #define LOG_INFO2(logger, fmt, ...) LOG_MSG(Info, logger, fmt, ##__VA_ARGS__) #define LOG_WARN2(logger, fmt, ...) LOG_MSG(Warn, logger, fmt, ##__VA_ARGS__) #define LOG_ERROR2(logger, fmt, ...) LOG_MSG(Error, logger, fmt, ##__VA_ARGS__) #define LOG_FATAL2(logger, fmt, ...) LOG_MSG(Fatal, logger, fmt, ##__VA_ARGS__) ///@ brief Scoped Log Context /// /// Creating an instance of the LogContext class will /// push the supplied string (printf formatted) onto the /// current thread's logging context. When the instance goes /// out of scope, the context will be popped automatically /// class LogContext { public: LogContext(const char *fmt, ...); ~LogContext(); }; /// @brief initialise logging /// /// initialise logging /// /// @param cfgFile full path to config file. If omitted or NULL /// then environment variable IOC_LOG_CONFIG is /// used or finally ioc.log_cfg from the current directory int log_init(const char* cfgFile=NULL); /// @brief set log level of root logger /// /// @param level level to set root logger to /// void set_log_level(IocLogLevel level); log4cxx::LevelPtr level_num_to_ptr(IocLogLevel level); int level_ptr_to_num(log4cxx::LevelPtr level); /// @brief log a message using log4cxx location info /// /// @param logger /// @param level /// @param loc /// @param fmt /// void log_msg(askap::ioclog::IocLogger logger, log4cxx::Level *level,\ const log4cxx::spi::LocationInfo &loc, const char *fmt, ...); /// @brief log a message using C-style file, function name & line number /// /// @param logger /// @param level /// @param file /// @param line /// @param fmt /// void log_msg(const char *logger, IocLogLevel level, const char* file, const char* func, const int line, const char* fmt, ...); /// @brief push a logging context onto the current threads stack /// /// @param fmt /// void log_push_context(const char *fmt, ...); /// @brief pop a logging context off the current thread /// void log_pop_context(); } } #else //cplusplus #define CREATE_LOGGER(name) static char *LOGGER = LOGGER_PREFIX PACKAGE_NAME name #define CREATE_NAMED_LOGGER(logger, name) static char *logger = LOGGER_PREFIX PACKAGE_NAME name extern IOC_LOG *IocLog; #define LOG_PUSH_CONTEXT(fmt, ...) IocLog->pushContext(fmt, ##__VA_ARGS__) #define LOG_POP_CONTEXT() IocLog->popContext() #define LOG_MSG(level, logger, fmt, ...) if(IocLog->isLevelEnabled(LOG_LEVEL_##level, logger)) \ IocLog->forcedLog(logger, LOG_LEVEL_##level, \ __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__) #define LOG_TRACE(fmt, ...) LOG_TRACE2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_DEBUG(fmt, ...) LOG_DEBUG2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_INFO(fmt, ...) LOG_INFO2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_WARN(fmt, ...) LOG_WARN2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_ERROR(fmt, ...) LOG_ERROR2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_FATAL(fmt, ...) LOG_FATAL2(LOGGER, fmt, ##__VA_ARGS__) #define LOG_TRACE2(logger, fmt, ...) LOG_MSG(TRACE, logger, fmt, ##__VA_ARGS__) #define LOG_DEBUG2(logger, fmt, ...) LOG_MSG(DEBUG, logger, fmt, ##__VA_ARGS__) #define LOG_INFO2(logger, fmt, ...) LOG_MSG(INFO, logger, fmt, ##__VA_ARGS__) #define LOG_WARN2(logger, fmt, ...) LOG_MSG(WARN, logger, fmt, ##__VA_ARGS__) #define LOG_ERROR2(logger, fmt, ...) LOG_MSG(ERROR, logger, fmt, ##__VA_ARGS__) #define LOG_FATAL2(logger, fmt, ...) LOG_MSG(FATAL, logger, fmt, ##__VA_ARGS__) #endif #endif
//------------------------------------------------------------------------------ // OrbitState //------------------------------------------------------------------------------ // GMAT: General Mission Analysis Tool. // // Copyright (c) 2002 - 2015 United States Government as represented by the // Administrator of the National Aeronautics and Space Administration. // All Other Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // You may not use this file except in compliance with the License. // You may obtain a copy of the License at: // http://www.apache.org/licenses/LICENSE-2.0. // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either // express or implied. See the License for the specific language // governing permissions and limitations under the License. // // Author: Wendy Shoan, NASA/GSFC // Created: 2016.05.04 // /** * Implementation of the OrbitState class */ //------------------------------------------------------------------------------ #include <cmath> // for INFINITY #include "gmatdefs.hpp" #include "OrbitState.hpp" #include "RealUtilities.hpp" #include "GmatConstants.hpp" #include "Rmatrix33.hpp" #include "StateConversionUtil.hpp" #include "TATCException.hpp" #include "MessageInterface.hpp" //------------------------------------------------------------------------------ // static data //------------------------------------------------------------------------------ // None //------------------------------------------------------------------------------ // public methods //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // OrbitState() //------------------------------------------------------------------------------ /** * Default constructor. * */ //--------------------------------------------------------------------------- OrbitState::OrbitState() : mu (3.986004415e+5) { currentState.Set(7100.0, 0.0, 2000.0, 0.0, 7.4, 1.0); } //------------------------------------------------------------------------------ // OrbitState(const OrbitState &copy) //------------------------------------------------------------------------------ /** * Copy constructor. * * @param copy the OrbitState object to copy * */ //--------------------------------------------------------------------------- OrbitState::OrbitState(const OrbitState &copy) : currentState (copy.currentState), mu (copy.mu) { } //------------------------------------------------------------------------------ // OrbitState& operator=(const OrbitState &copy) //------------------------------------------------------------------------------ /** * The operator= for OrbitState. * * @param copy the OrbitState object to copy * */ //--------------------------------------------------------------------------- OrbitState& OrbitState::operator=(const OrbitState &copy) { if (&copy == this) return *this; currentState = copy.currentState; mu = copy.mu; return *this; } //------------------------------------------------------------------------------ // ~OrbitState() //------------------------------------------------------------------------------ /** * Destructor. * */ //--------------------------------------------------------------------------- OrbitState::~OrbitState() { } //------------------------------------------------------------------------------ // void SetKeplerianState(Real SMA, Real ECC, // Real INC, Real RAAN, // Real AOP, Real TA); //------------------------------------------------------------------------------ /** * Sets the keplerian state, element by element. * * @param SMA semimajor axis * @param ECC eccentricity * @param INC inclination * @param RAAN right ascension of the ascending node * @param AOP argument of periapsis * @param TA true anomaly * */ //--------------------------------------------------------------------------- void OrbitState::SetKeplerianState(Real SMA, Real ECC, Real INC, Real RAAN, Real AOP, Real TA) { // Sets the Keplerian state // Angles are in radians, SMA unit should be consistent with gravParam currentState = ConvertKeplerianToCartesian(SMA,ECC,INC,RAAN,AOP,TA); } //------------------------------------------------------------------------------ // void SetKeplerianVectorState(const Rvector6 &kepl) //------------------------------------------------------------------------------ /** * Sets the keplerian state, as a 6-element vector. * * @param kepl keplerian state * */ //--------------------------------------------------------------------------- void OrbitState::SetKeplerianVectorState(const Rvector6 &kepl) { // Sets Keplerian state given states in an array // Angles are in radians, SMA unit should be consistent with gravParam currentState = ConvertKeplerianToCartesian(kepl(0),kepl(1),kepl(2), kepl(3),kepl(4),kepl(5)); } //------------------------------------------------------------------------------ // void SetCartesianState(const Rvector6 &cart) //------------------------------------------------------------------------------ /** * Sets the cartesian state, as a 6-element vector. * * @param cart cartesian state * */ //--------------------------------------------------------------------------- void OrbitState::SetCartesianState(const Rvector6 &cart) { // Sets the cartesian state // Units should be consistent with gravParam currentState = cart; } //------------------------------------------------------------------------------ // void SetGravityParameter(Real toGrav) //------------------------------------------------------------------------------ /** * Sets the gravity parameter. * * @param toGrav gravity parameter * */ //--------------------------------------------------------------------------- void OrbitState::SetGravityParameter(Real toGrav) { mu = toGrav; } //------------------------------------------------------------------------------ // Rvector6 GetKeplerianState() //------------------------------------------------------------------------------ /** * Returns the keplerian state as a 6-element vector * * @return keplerian state * */ //--------------------------------------------------------------------------- Rvector6 OrbitState::GetKeplerianState() { // Returns the Keplerian state // Angles are in radians, SMA unit is consistent with g return ConvertCartesianToKeplerian(currentState); } //------------------------------------------------------------------------------ // Rvector6 GetCartesianState() //------------------------------------------------------------------------------ /** * Returns the cartesian state as a 6-element vector * * @return cartesian state * */ //--------------------------------------------------------------------------- Rvector6 OrbitState::GetCartesianState() { // Returns the Cartesian state // Units are consistent with g return currentState; } //------------------------------------------------------------------------------ // protected methods //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // Rvector6 ConvertKeplerianToCartesian(Real a, Real e, // Real i, Real Om, // Real om, Real nu) //------------------------------------------------------------------------------ /** * Converts the keplerian state to a cartesian state. * * @param a semimajor axis * @param e eccentricity * @param i inclination * @param Om right ascension of the ascending node * @param om argument of periapsis * @param nu true anomaly * * @return the cartesian state as a 6-element vector * */ //--------------------------------------------------------------------------- Rvector6 OrbitState::ConvertKeplerianToCartesian(Real a, Real e, Real i, Real Om, Real om, Real nu) { // C++ code should be borrowed from GMAT state converter // To start, coding as is. To use GMAT conversion utility, // we will need other body data (flattening, etc.) Rvector6 kepl(a, e, i * GmatMathConstants::DEG_PER_RAD, Om * GmatMathConstants::DEG_PER_RAD, om * GmatMathConstants::DEG_PER_RAD, nu * GmatMathConstants::DEG_PER_RAD); // conversion utility requires degrees Rvector6 cartesian = StateConversionUtil::KeplerianToCartesian(mu, kepl); // Real p = a*(1-e*e); // Real r = p/(1+e*GmatMathUtil::Cos(nu)); // Rvector3 rv(r*GmatMathUtil::Cos(nu), // r*GmatMathUtil::Sin(nu), // 0.0); // in PQW frame // Real gp = GmatMathUtil::Sqrt(mu/p); // Rvector3 vv(-GmatMathUtil::Sin(nu), e+GmatMathUtil::Cos(nu), 0.0); // vv = gp * vv; // // // // now rotate // // // Real cO = GmatMathUtil::Cos(Om); // Real sO = GmatMathUtil::Sin(Om); // Real co = GmatMathUtil::Cos(om); // Real so = GmatMathUtil::Sin(om); // Real ci = GmatMathUtil::Cos(i); // Real si = GmatMathUtil::Sin(i); // Rmatrix33 R(cO*co-sO*so*ci, -cO*so-sO*co*ci, sO*si, // sO*co+cO*so*ci, -sO*so+cO*co*ci, -cO*si, // so*si, co*si, ci); // Rvector3 rvCart = R * rv; // Rvector3 vvCart = R * vv; // Rvector6 cartesian(rv(0), rv(1), rv(2), vv(0), vv(1), vv(2)); return cartesian; } //------------------------------------------------------------------------------ // Rvector6 ConvertCartesianToKeplerian(const Rvector6 &cart) //------------------------------------------------------------------------------ /** * Converts the cartesian state to a keplerian state. * * @param cart cartesian state * * @return the keplerian state as a 6-element vector * */ Rvector6 OrbitState::ConvertCartesianToKeplerian(const Rvector6 &cart) { Rvector6 kepl = StateConversionUtil::CartesianToKeplerian(mu, cart); // conversion utility reports degrees kepl[2] *= GmatMathConstants::RAD_PER_DEG; kepl[3] *= GmatMathConstants::RAD_PER_DEG; kepl[4] *= GmatMathConstants::RAD_PER_DEG; kepl[5] *= GmatMathConstants::RAD_PER_DEG; // // Converts from Keplerian to Cartesian // Real SMA, ECC, INC, RAAN, AOP, TA; // Rvector6 kepl; // // // C++ code should be borrowed from GMAT state converter // // To start, coding as is. To use GMAT conversion utility, // // we will need other body data (flattening, etc.) // // Rvector3 rv(cart(0), cart(1), cart(2)); // position // Rvector3 vv(cart(3), cart(4), cart(5)); // velocity // // Real r = rv.GetMagnitude(); // magnitude of position vector // Real v = vv.GetMagnitude(); // magnitude of velocity vector // // Rvector3 hv = Cross(rv,vv); // orbit angular momentum vector // Real h = hv.GetMagnitude(); // // Rvector3 kv(0.0, 0.0, 1.0); // Inertial z axis // // vector in direction of RAAN, zero vector if equatorial orbit // Rvector3 nv = Cross(kv,hv); // Real n = nv.GetMagnitude(); // // // Calculate eccentricity vector and eccentricity // Rvector3 ev = (v*v - mu/r)*rv/mu - (rv*vv)*vv/mu; // ECC = ev.GetMagnitude(); // Real E = v*v/2 - mu/r; // Orbit Energy // // // Check eccentrity for parabolic orbit // if (GmatMathUtil::Abs(1 - ECC) < 2*GmatRealConstants::REAL_EPSILON) // { // throw TATCException("Orbit is nearly parabolic ad state conversion " // "routine is new numerical singularity\n"); // } // // // Check Energy for parabolic orbit // if (GmatMathUtil::Abs(E) < 2 * GmatRealConstants::REAL_EPSILON) // { // throw TATCException("Orbit is nearly parabolic ad state conversion " // "routine is new numerical singularity\n"); // } // // // Determine SMA depending on orbit type // SMA = INFINITY; // if (ECC != 1.0) // SMA = -mu/2/E; // // // Determine Inclination // INC = GmatMathUtil::ACos(hv(3)/h); // // // === Elliptic equatorial // if (INC <= 1.0e-11 && ECC > 1.0e-11) // { // RAAN = 0; // // // Determine AOP // AOP = GmatMathUtil::ACos(ev(1)/ECC); // if (ev(2) < 0.0) // AOP = GmatMathConstants::TWO_PI - AOP; // // // Determine TA // TA = GmatMathUtil::ACos(ev*rv)/ECC/r; // if ((rv*vv) < 0.0 ) // TA = GmatMathConstants::TWO_PI - TA; // } // // === Circular Inclined // else if (INC >= 1.0e-11 && ECC <= 1.0e-11) // { // // Determine RAAN // RAAN = GmatMathUtil::ACos(nv(1)/n); // if (nv(2) < 0.0) // RAAN = GmatMathConstants::TWO_PI - RAAN; // // // Determine AOP // AOP = 0; // // // Determine TA // TA = GmatMathUtil::ACos((nv/n)*(rv/r)); // if (rv(3) < 0.0) // TA = GmatMathConstants::TWO_PI - TA; // } // // // === Circular equatorial // else if (INC <= 1.0e-11 && ECC <= 1.0e-11) // { // RAAN = 0; // AOP = 0; // TA = GmatMathUtil::ACos(rv(1)/r); // if (rv(2) < 0.0) // TA = GmatMathConstants::TWO_PI - TA; // } // else // Not a special case // { // // Determine RAAN // RAAN = GmatMathUtil::ACos(nv(1)/n); // if (nv(2) < 0.0) // RAAN = GmatMathConstants::TWO_PI - RAAN; // // // Determine AOP // AOP = GmatMathUtil::ACos((nv/n)*(ev/ECC)); // if (ev(3) < 0.0) // AOP = GmatMathConstants::TWO_PI - AOP; // // // Determine TA // TA = GmatMathUtil::ACos((ev/ECC)*(rv/r)); // if ((rv*vv) < 0.0) // TA = GmatMathConstants::TWO_PI - TA; // } // // kepl.Set(SMA, ECC, INC, RAAN, AOP, TA); return kepl; }
#include <vector> #include <string> #include <algorithm> using namespace std; int solution(int n, vector<vector<int>> board) { int answer = 0; /*숫자 1부터 n*n의 숫자까지의 좌표값을 담아줄 배열 arr을 만들어 준다. arr[0][0]과 arr[0][1]은 처음 시작점을 나타내주기 위해 0,0 으로 설정한다*/ int arr[n*n+1][2]; arr[0][0] = 0; arr[0][1] = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ arr[board[i][j]][0] = i; arr[board[i][j]][1] = j; } } /*arr배열을 훑으며 1부터 n*n까지의 숫자들을 순회한다. 숫자 a에서 a+1까지 이동하는데 생기는 총 입력 횟수는 (해당 열에서 열로 가는 최단거리)+(해당 행에서 행으로 가는 최단거리)+1 이다*/ for(int a = 0; a < n*n; a++){ answer += min(abs(arr[a][0]-arr[a+1][0]), n - max(arr[a][0], arr[a+1][0]) + min(arr[a][0], arr[a+1][0])); answer += min(abs(arr[a][1]-arr[a+1][1]), n - max(arr[a][1], arr[a+1][1]) + min(arr[a][1], arr[a+1][1])); answer += 1; } return answer; }
#include "parser.h" #include "ast.h" #include "ast_format.h" #include "token.h" #include <optional> #include <variant> #include <spdlog/spdlog.h> namespace wcc { static void syntax_error(const char* got_before, const char* expected, const char* got_after, size_t line, size_t pos) { spdlog::error("Syntax error: Expected {} after {}, but got {}", expected, got_before, got_after); spdlog::error("At: {}:{}", line, pos); } static bool parse_str_field(Tokenizer& tokenizer, AstVariable& field) { Token token = tokenizer.get(); if (token.id != TOKENID::IDENTIFIER) { spdlog::error("Syntax error: Expected structure field declaration (type " "identifier), but got {}", TOKENID_STR[underlay_cast(token.id)]); spdlog::error("At: {}:{}", token.line, token.pos); return false; } std::optional type_opt = lookup_type(token.value); if (!type_opt.has_value()) { spdlog::error("Syntax error: Expected structure field declaration (type " "identifier), unkown type \"{}\"", token.value); spdlog::error("At: {}:{}", token.line, token.pos); return false; } field.type = *type_opt; token = tokenizer.get(); if (token.id != TOKENID::IDENTIFIER) { spdlog::error( "Syntax error: Expected structure field name (identifier), but got {}", TOKENID_STR[underlay_cast(token.id)]); spdlog::error("At: {}:{}", token.line, token.pos); return false; } field.name = token.value; token = tokenizer.get(); if (token.id != TOKENID::SEMICOLON) { spdlog::error("Syntax error: Expected semicolon after structure field " "declaration. but got {}", TOKENID_STR[underlay_cast(token.id)]); spdlog::error("At: {}:{}", token.line, token.pos); return false; } spdlog::debug("Parsed structure field: Type:{}, Name:{}", LANG_TYPE_STR[underlay_cast(field.type)], field.name); return true; } static bool parse_strdecl(Tokenizer& tokenizer, AstStruct& str) { while (1) { if (tokenizer.peek().id == TOKENID::BLOCK_END) { tokenizer.get(); if (const auto token = tokenizer.get(); token.id != TOKENID::SEMICOLON) { spdlog::error("Syntax error: Structure declaration must end with " "semicolon, but got: {}", TOKENID_STR[underlay_cast(token.id)]); return false; } break; } str.fields.emplace_back(); AstVariable& field = str.fields.back(); const auto res = parse_str_field(tokenizer, field); if (!res) return false; } return true; } static bool parse_func_params(Tokenizer& tokenizer, ASTNode& node) { Token token; while (1) { ASTNode& param = node.add(ASTID::vardecl); param.value = AstVariable(); token = tokenizer.get(); if (token.id != TOKENID::IDENTIFIER) { spdlog::error("Syntax error: Expected type name, got {}", TOKENID_STR[underlay_cast(token.id)]); spdlog::error("At: {}:{}", token.line, token.pos); return false; } std::optional type = lookup_type(token.value); if (!type.has_value()) { spdlog::error("Unknown type \"{}\"", token.value); spdlog::error("At: {}:{}", token.line, token.pos); return false; } token = tokenizer.get(); AstVariable& var = std::get<AstVariable>(param.value); var.type = type.value(); if (token.id == TOKENID::IDENTIFIER) { var.name = token.value; token = tokenizer.get(); } spdlog::debug("Parsed func param type: {}, name: {}", LANG_TYPE_STR[underlay_cast(var.type)], var.name); if (token.id == TOKENID::COMMA) continue; if (token.id != TOKENID::PAREN_CLOSE) { spdlog::error("Syntax error: Expected closing parenthesis ')', got {}", TOKENID_STR[underlay_cast(token.id)]); spdlog::error("At: {}:{}", token.line, token.pos); return false; } break; } return true; } static bool parse_code_block(Tokenizer& tokenizer, ASTNode& node); static bool parse_funcdecl(Tokenizer& tokenizer, ASTNode& node) { AstFunction& func = std::get<AstFunction>(node.value); Token token = tokenizer.get(); if (token.id != TOKENID::PAREN_OPEN) { spdlog::error("Syntax error: Expected argument list, got {}", TOKENID_STR[underlay_cast(token.id)]); spdlog::error("At: {}:{}", token.line, token.pos); return false; } if (tokenizer.peek().id == TOKENID::PAREN_CLOSE) { tokenizer.get(); } else { const auto parse_res = parse_func_params(tokenizer, node); if (!parse_res) return false; } token = tokenizer.get(); if (token.id != TOKENID::BLOCK_BEGIN) { spdlog::error( "Syntax error: Expected function body after header, but got {}", TOKENID_STR[underlay_cast(token.id)]); return false; } return parse_code_block(tokenizer, node); } static bool is_stdop(const Token token) { switch (token.id) { case TOKENID::OP_NEG: case TOKENID::OP_NEQ: case TOKENID::OP_MOD: case TOKENID::OP_XOR: case TOKENID::OP_LOGIC_AND: case TOKENID::OP_ANDEQ: case TOKENID::OP_AND: case TOKENID::OP_LOGIC_OR: case TOKENID::OP_OREQ: case TOKENID::OP_OR: case TOKENID::OP_MUL: case TOKENID::OP_MULEQ: case TOKENID::OP_DIVEQ: case TOKENID::OP_DIV: case TOKENID::OP_MINUS: case TOKENID::OP_ACCESS: case TOKENID::OP_PLUS: case TOKENID::OP_EQ: case TOKENID::OP_LS: case TOKENID::OP_LSE: case TOKENID::OP_GR: case TOKENID::OP_GRE: case TOKENID::OP_DOT: return true; default: return false; } return false; } static std::optional<std::string> get_function_symbol_name(Token t) { if (is_stdop(t)) return STDOP_FUNC_STR[underlay_cast(t.id)]; if (t.id != TOKENID::IDENTIFIER) return std::nullopt; return t.value; } static bool parse_statement_list(Tokenizer& tokenizer, ASTNode& node) { if (!(node.id == ASTID::stmt && std::holds_alternative<AstStmt>(node.value))) { spdlog::critical("Internal error: Expected AstFunctionCall node as " "argument in parse_statement_list, but got {}", node); return false; } AstStmt& stmt_node = std::get<AstStmt>(node.value); if (stmt_node.type != StmtType::call) { spdlog::critical("Internal error: Expected AstFunctionCall node as " "argument in parse_statement_list, but got {}", node); return false; } AstFunctionCall& call = std::get<AstFunctionCall>(std::get<AstStmt>(node.value).value); Token tok = tokenizer.peek(); if (tok.id == TOKENID::PAREN_CLOSE) return true; while (1) { tok = tokenizer.get(); if (tok.id != TOKENID::IDENTIFIER) { spdlog::error("Syntax error: expected argument identifier in call " "parenthesis, but got {}", TOKENID_STR[underlay_cast(tok.id)]); spdlog::error("At: {}:{}", tok.line, tok.pos); return false; } call.args.emplace_back(AstStmt{ .type = StmtType::varref, .value = AstSymRef{ .name = tok.value } }); tok = tokenizer.get(); if (tok.id == TOKENID::PAREN_CLOSE) break; if (tok.id != TOKENID::COMMA) { spdlog::error("Syntax error: expected comma separated list of arguments"); spdlog::error("At: {}:{}", tok.line, tok.pos); return false; } } return true; } // TODO: inline this manually, it doesnt make sense as a separate function. static std::optional<SymbolName> parse_statement_symbol(Tokenizer& tokenizer) { Token symtok = tokenizer.get(); if (symtok.id != TOKENID::IDENTIFIER) return std::nullopt; return SymbolName(symtok.value); } static size_t get_precedence(const Token t) { switch(t.id) { default: return 0; } } static unsigned get_operator_precedence(Token t) { if (t.id == TOKENID::OP_MUL) return 1; return 0; } static bool maybe_fix_precedence_(ASTNode& opnode) { auto& this_stmt = std::get<AstStmt>(opnode.value); if (this_stmt.type != StmtType::call) return true; auto& this_opcall = std::get<AstFunctionCall>(this_stmt.value); if (!is_stdop(this_opcall.from_token)) return true; auto& rhs_stmt = this_opcall.args.back(); if (rhs_stmt.type != StmtType::call) return true; auto& rhs_opcall = std::get<AstFunctionCall>(rhs_stmt.value); if (!is_stdop(rhs_opcall.from_token)) return true; if (get_operator_precedence(this_opcall.from_token) <= get_operator_precedence(rhs_opcall.from_token)) return true; if (rhs_opcall.args.size() != 2) { spdlog::critical("Internal error: we expected stdop to have 2 args"); return false; } std::swap(rhs_opcall.args.front(), rhs_opcall.args.back()); AstStmt rhs_of_rhs = std::move(rhs_opcall.args.back()); rhs_opcall.args.pop_back(); AstStmt rhs_of_this = std::move(this_opcall.args.back()); this_opcall.args.pop_back(); std::swap(this_stmt, rhs_of_this); // Function calls (std::variants) of the statement struct just got swapped. // We have to retake the value because It changed (we move-assigned variants). // We reassign the references by shadowing { auto& this_opcall = std::get<AstFunctionCall>(this_stmt.value); auto& rhs_opcall = std::get<AstFunctionCall>(rhs_of_this.value); rhs_opcall.args.emplace_back(std::move(rhs_of_rhs)); this_opcall.args.emplace_back(std::move(rhs_of_this)); } return true; } /* * Statement grammar: * * stmt: sym * stmt: sym '(' arglist ')' * stmt: stmt op stmt [Note, translated to: op(stmt, stmt)] * stmt: stmt ';' * stmt: 'return' stmt * * arglist: stmt * arglist: stmt ',' stmt * */ static bool parse_statement(Tokenizer& tokenizer, ASTNode& node) { ASTNode& this_node = node.add(ASTID::stmt); this_node.value = AstStmt(); AstStmt& stmt = std::get<AstStmt>(this_node.value); std::optional<SymbolName> opt_sym; if (opt_sym = parse_statement_symbol(tokenizer); !opt_sym.has_value()) { return false; } spdlog::debug("Parsing symbol: {}", opt_sym.value()); if (opt_sym.value() == "return") { stmt.type = StmtType::ret; return parse_statement(tokenizer, this_node); } if (tokenizer.peek().id == TOKENID::PAREN_OPEN) { tokenizer.get(); stmt.type = StmtType::call; stmt.value = AstFunctionCall{ .name = opt_sym.value(), .from_token = TOKENID::IDENTIFIER }; if (!parse_statement_list(tokenizer, this_node)) return false; } else { stmt.type = StmtType::varref; stmt.value = AstSymRef{ .name = opt_sym.value() }; } if (is_stdop(tokenizer.peek())) { const Token optok = tokenizer.get(); SymbolName func_name = STDOP_FUNC_STR[underlay_cast(optok.id)]; ASTNode opnode(ASTID::stmt); opnode.value = AstStmt(); AstStmt& opnode_stmt = std::get<AstStmt>(opnode.value); opnode_stmt.type = StmtType::call; opnode_stmt.value = AstFunctionCall{ .name = std::move(func_name), .from_token = optok }; auto& opnode_call = std::get<AstFunctionCall>(opnode_stmt.value); opnode_call.args.emplace_back(stmt); // TODO: remove node as a arg to parse_statement so we dont have to do this. ASTNode node_for_rhs; if (!parse_statement(tokenizer, node_for_rhs)) return false; if (node_for_rhs.nodes.size() != 1) { spdlog::critical( "Internal error: We expect parsing rhs of stdop to get only one child"); return false; } auto &rhs_stmt = std::get<AstStmt>(node_for_rhs.nodes[0]->value); opnode_call.args.emplace_back(std::move(rhs_stmt)); // Rotate tree because we found stdop after identifier. // The identifier should be the lhs arg. std::swap(this_node, opnode); maybe_fix_precedence_(this_node); return true; } if (tokenizer.peek().id != TOKENID::SEMICOLON) { spdlog::error("Syntax error: missing semicolon?"); return false; } tokenizer.get(); return true; } static bool parse_code_block(Tokenizer& tokenizer, ASTNode& node) { Token token; while (1) { // TODO: This is temporary hack to make parse_statement start from the // begining of the line. Tokenizer beginState = tokenizer; token = tokenizer.get(); switch (token.id) { case TOKENID::BLOCK_END: return true; case TOKENID::IDENTIFIER: { if (token.value == "struct") { token = tokenizer.get(); if (token.id != TOKENID::IDENTIFIER) { syntax_error("struct", "identifier", TOKENID_STR[underlay_cast(token.id)], token.line, token.pos); return false; } Token next_token = tokenizer.get(); if (next_token.id == TOKENID::BLOCK_BEGIN) { ASTNode& str_node = node.add(ASTID::strdecl); str_node.value = AstStruct(); AstStruct& str = std::get<AstStruct>(str_node.value); str.name = token.value; return parse_strdecl(tokenizer, str); } syntax_error("struct", "identifier", TOKENID_STR[underlay_cast(token.id)], token.line, token.pos); } else if (const auto opt_type = lookup_type(token.value); opt_type.has_value()) { Token symbol_name = tokenizer.get(); if (symbol_name.id != TOKENID::IDENTIFIER) { spdlog::error("Syntax error: Expected variable or function name " "after type identifier {}", token.value); spdlog::error("At: {}:{}", token.line, token.pos); return false; } if (tokenizer.peek().id == TOKENID::PAREN_OPEN) { ASTNode& func_node = node.add(ASTID::funcdecl); func_node.value = AstFunction(); AstFunction& func = std::get<AstFunction>(func_node.value); func.return_type = opt_type.value(); func.name = symbol_name.value; return parse_funcdecl(tokenizer, func_node); } else if (tokenizer.peek().id == TOKENID::SEMICOLON) { ASTNode& vardecl_node = node.add(ASTID::vardecl); vardecl_node.value = AstVariable(); AstVariable& vardecl = std::get<AstVariable>(vardecl_node.value); vardecl.type = opt_type.value(); vardecl.name = symbol_name.value; spdlog::debug("Parsed variable declaration: {}", vardecl.name); tokenizer.get(); continue; } spdlog::error( "Syntax error: Expected function or variable declaration."); spdlog::error("At: {}:{}", token.line, token.pos); return false; } tokenizer = beginState; if (!parse_statement(tokenizer, node)) return false; continue; } default: spdlog::error( "Unsupported token in code block at {}:{}", token.line, token.pos); return false; } } return true; } AST Parser::buildAST() { AST ast; ASTNode& ast_root = ast.root; while (1) { Token token; token = tokenizer.peek(); spdlog::debug("Token: {}", ASTID_STR[underlay_cast(token.id)]); if (token.id == TOKENID::END) break; const auto parse_res = parse_code_block(this->tokenizer, ast_root); if (!parse_res) break; } return ast; } }
#include <iostream> using namespace std; void mergesort(int*, int, int, int(*)(int, int)); // 합병 정렬 함수 int compare(int, int); // 합병 정렬의 비교 콜백으로 사용할 함수 int main(void) { int arr[] = { 4, 7, 2, 1, 9, 5, 10, 8, 6, 3 }; // 무작위 배열 정의 int i, size = sizeof(arr) / sizeof(int); mergesort(arr, 0, size - 1, compare); // 배열 정렬 cout << arr[0]; // 정렬된 배열 값 출력 for (i = 1; i < size; i++) cout << ", " << arr[i]; cout << endl; return 0; } void mergesort(int* arr, int p, int q, int (*compare)(int, int)) { int i, j, k, t; int size = q - p + 1; int* buffer; if (p < q) // 원소의 개수가 2개 이상일 경우 실행 { k = (p + q) / 2; mergesort(arr, p, k, compare); // arr[p]~arr[k] 에 대한 함수 재귀 호출 mergesort(arr, k + 1, q, compare); // arr[k+1]~arr[q] 에 대한 함수 재귀 호출 buffer = new int[size]; // 합병을 위한 임시 배열 생성 // arr[p]~arr[k]와 arr[k+1]~arr[q] 합병 for (i = p, j = k + 1, t = 0; t < size; ++t) { if (!(i > k) && (j > q || compare(arr[i], arr[j]) > 0)) buffer[t] = arr[i++]; else buffer[t] = arr[j++]; } for (t = 0; t < size; ++t) arr[p + t] = buffer[t]; // 임시 배열의 값을 배열로 복사 delete[] buffer; } } int compare(int a, int b) { return (int)(a < b); }
#ifndef ROSE_AsmFunctionIndex_H #define ROSE_AsmFunctionIndex_H #include <algorithm> #include <ostream> #include <vector> #include "callbacks.h" /** Functions indexed by entry address. * * This class is designed to be a highly-configurable way to print a table describing known functions. The way it works is * the user adds functions to the AsmFunctionIndex object (explicitly, or by having this object traverse an AST), and then * prints the object to an std::ostream. The index contains a list of functions to be included in the index, but it also * contains a list of callbacks responsible for printing the table column headers and data. * * For instance, to print an index of all functions sorted by function name and using the default table style, simply invoke * this code: * @code * #include <AsmFunctionIndex.h> * * SgProject *project = ...; * std::cout <<AsmFunctionIndex(project).sort_by_name(); * @endcode * * If you want a list of functions sorted by decreasing size in bytes, you could do this: * @code * std::cout <<AsmFunctionIndex(project).sort_by_byte_size().reverse(); * @endcode * * Here's an example of augmenting the function index so that it always sorts the functions by entry address and it prints an * extra column named "Hash" that consists of the first 16 characters of some computed function hash. * @code * class MyFunctionIndex: public AsmFunctionIndex { * public: * struct HashCallback: public OutputCallback { * HashCallback(): OutputCallback("Hash", 16) {} * virtual bool operator()(bool enabled, const DataArgs &args) { * if (enabled) * args.output <<data_prefix <<std::setw(width) <<function_hash(args.func).substr(0,16); * return enabled; * } * } hashCallback; * * MyFunctionIndex(SgNode *ast): AsmFunctionIndex(ast) { * sort_by_entry_addr(); * output_callbacks.before(&nameCallback, &hashCallback); * } * }; * * std::cout <<MyFuncitonIndex(project); * @endcode * * The output might look something like this: * <pre> */ class AsmFunctionIndex { /************************************************************************************************************************** * The main public members **************************************************************************************************************************/ public: /** Constructs an empty index. */ AsmFunctionIndex() { init(); } /** Constructs an index from an AST. */ AsmFunctionIndex(SgNode *ast) { init(); add_functions(ast); } virtual ~AsmFunctionIndex() {} /** Adds a function to the end of this index. The function is added regardless of whether it already exists. */ virtual void add_function(SgAsmFunction*); /** Adds functions to this index. The specified AST is traversed and all SgAsmFunction nodes are added to this index. All * encountered functions are added to the index in the order they are encountered regardless of whether they already * exist. */ virtual void add_functions(SgNode *ast); /** Clears the index. Removes all functions from the index, but does not change any callback lists. */ virtual void clear() { functions.clear(); } /** Determines if an index is empty. Returns true if the index contains no functions, false otherwise. */ virtual bool empty() const { return functions.empty(); } /** Returns the number of functions in the index. */ virtual size_t size() const { return functions.size(); } /************************************************************************************************************************** * Functors for sorting * These are expected to be commonly used, so we define them here for convenience. The generic sorting method is defined * below. **************************************************************************************************************************/ public: /** Functor for sorting by function entry virtual address. */ struct SortByEntryAddr { bool operator()(SgAsmFunction *a, SgAsmFunction *b) { return a->get_entry_va() < b->get_entry_va(); } bool unique(SgAsmFunction *a, SgAsmFunction *b) { return a->get_entry_va() != b->get_entry_va(); } }; /** Functor for sorting by function beginning address. */ struct SortByBeginAddr { bool operator()(SgAsmFunction *a, SgAsmFunction *b) { return val(a)<val(b); } bool unique(SgAsmFunction *a, SgAsmFunction *b) { return val(a)!=val(b); } rose_addr_t val(SgAsmFunction *x) { rose_addr_t lo; x->get_extent(NULL, &lo); return lo; } }; /** Functor for sorting by number of instructions in function. */ struct SortByInsnsSize { bool operator()(SgAsmFunction *a, SgAsmFunction *b) { return val(a) < val(b); } bool unique(SgAsmFunction *a, SgAsmFunction *b) { return val(a) != val(b); } size_t val(SgAsmFunction *x) { return SageInterface::querySubTree<SgAsmInstruction>(x).size(); } }; /** Functor for sorting by number of bytes in function. Bytes are counted only once no matter in how many overlapping * instructions and/or data blocks they appear. */ struct SortByBytesSize { bool operator()(SgAsmFunction *a, SgAsmFunction *b) { return val(a) < val(b); } bool unique(SgAsmFunction *a, SgAsmFunction *b) { return val(a) != val(b); } size_t val(SgAsmFunction *x) { ExtentMap extent; x->get_extent(&extent); return extent.size(); } }; /** Functor to sort functions by name. */ struct SortByName { bool operator()(SgAsmFunction *a, SgAsmFunction *b) { return a->get_name().compare(b->get_name()) < 0; } bool unique(SgAsmFunction *a, SgAsmFunction *b) { return 0 != a->get_name().compare(b->get_name()); } }; /************************************************************************************************************************** * Sorting methods **************************************************************************************************************************/ public: /** Sort the functions in the index. The supplied functor takes two SgAsmFunction pointers as arguments and returns true * if the first argument goes before the second argument in the specific strict weak ordering it defines, and false * otherwise. If @p unique is defined, then a final pass is made over the functions and any adjacent functions for which * the Comparator::unique() method, which takes two SgAsmFunction pointer arguments, returns false will cause the second * argument to be removed from the index. */ template<class Comparator> AsmFunctionIndex& sort(Comparator comp, bool unique=false) { std::stable_sort(functions.begin(), functions.end(), comp); if (unique) { Functions newlist; for (Functions::iterator fi=functions.begin(); fi!=functions.end(); fi++) { if (newlist.empty() || comp.unique(newlist.back(), *fi)) newlist.push_back(*fi); } if (newlist.size()!=functions.size()) functions = newlist; } return *this; } /** Specific sorting method. This method is expected to be commonly used, so we define it here for convenience. If some * other sorting method is needed, see the generic sort() method. * @{ */ AsmFunctionIndex& sort_by_entry_addr(bool unique=false) { return sort(SortByEntryAddr(), unique); } AsmFunctionIndex& sort_by_begin_addr(bool unique=false) { return sort(SortByBeginAddr(), unique); } AsmFunctionIndex& sort_by_ninsns(bool unique=false) { return sort(SortByInsnsSize(), unique); } AsmFunctionIndex& sort_by_nbytes(bool unique=false) { return sort(SortByBytesSize(), unique); } AsmFunctionIndex& sort_by_name(bool unique=false) { return sort(SortByName(), unique); } /** @} */ /** Reverse the order of the functions. This is typically called after sorting. */ AsmFunctionIndex& reverse() { std::reverse(functions.begin(), functions.end()); return *this; } /************************************************************************************************************************** * Footnotes **************************************************************************************************************************/ public: class Footnotes { public: Footnotes() { set_footnote_title("== Footnotes =="); } /** Adds a footnote to the table. Footnotes are printed at the end of the table by the ShowFootnotes callback * class. Footnotes are numbered starting at one rather than zero, and this function returns the footnote number. * Calling this function with an empty @p text argument will reserve a footnote number but will not print the footnote * in the final output. * * The first line of the footnote is prefixed by the string "Footnote *N: " and subsequent lines are indented by the * length of the prefix. */ size_t add_footnote(const std::string &text); /** Change the text associated with a footnote. The footnote must already exist, and the footnote @p idx is the value * returned by a previous call to add_footnote(). Setting @p text to the empty string causes the footnote to not * appear in the final output, but other footnotes are not renumbered to close the gap (because their references might * have already been printed. See also, add_footnote(). */ void change_footnote(size_t idx, const std::string &text); /** Get the string for a footnote. The footnote must already exist and @p idx is a footnote number returned by a previous * call to add_footnote(). */ const std::string& get_footnote(size_t idx) const; /** Returns the number of footnotes. Footnotes are numbered starting at one. The return value includes empty footnotes * that won't be printed by the final output. */ size_t size() const { return footnotes.size(); } /** Change the footnote title string. The title string is printed before the first footnote if there are any footnotes * with a non-empty string. */ void set_footnote_title(const std::string &title); /** Get the footnote title. The default title is "== Footnotes ==". */ const std::string& get_footnote_title() const; /** Set the footnote prefix string. This string is printed before every line of the footnote area. The default is the * empty string. */ void set_footnote_prefix(const std::string &prefix) { footnote_prefix = prefix; } /** Get the footnote prefix string. This string is printed before every line of the footnote area. */ const std::string& get_footnote_prefix() const { return footnote_prefix; } /** Generates a footnote name from a footnote index. The default is to return the index prefixed by an asterisk. */ std::string get_footnote_name(size_t idx) const; /** Print non-empty footnotes. */ void print(std::ostream&) const; /** Print non-empty footnotes. */ friend std::ostream& operator<<(std::ostream &o, const Footnotes *footnotes) { footnotes->print(o); return o; } protected: std::vector<std::string> footnotes; /**< List of footnotes. Elmt zero is an optional footnote title string.*/ std::string footnote_prefix; /**< String to emit before every footnote line. */ }; /************************************************************************************************************************** * Output methods **************************************************************************************************************************/ public: /** Prints a function index to an output stream. */ virtual void print(std::ostream&) const; friend std::ostream& operator<<(std::ostream&, const AsmFunctionIndex&); /************************************************************************************************************************** * Output callback base classes **************************************************************************************************************************/ public: /** Base class for printing table cells. * * Three kinds of callback are defined: * <ol> * <li>A callback to print the table heading and separator</li> * <li>A callback to print the data content</li> * <li>A callback invoked before and after the entire table</li> * </ol> * * Subclasses almost always override the data content callback, but seldom override the others. The default heading and * separator callback knows how to print a properly formatted column heading, and the default before and after callback * does nothing, but could be used to print keys, footnotes, etc. * * If a callback has no column name and zero width, then its header and content callback is not invoked; its content * callback is still invoked but should not produce any output. */ class OutputCallback { public: /** Base class for callback arguments. */ struct GeneralArgs { GeneralArgs(const AsmFunctionIndex *index, std::ostream &output, Footnotes *footnotes) : index(index), output(output), footnotes(footnotes) {} const AsmFunctionIndex *index; /**< Index object being printed. */ std::ostream &output; /**< Stream to which index is being printed. */ Footnotes *footnotes; /**< Footnotes (newly created for each index output). */ }; /** Arguments for before-and after. */ struct BeforeAfterArgs: public GeneralArgs { BeforeAfterArgs(const AsmFunctionIndex *index, std::ostream &output, Footnotes *footnotes, int when) : GeneralArgs(index, output, footnotes), when(when) {} int when; /**< Zero implies before table, one implies after table. */ }; /** Arguments for column heading callbacks. If @p set is non-NUL then instead of printing the column name it should * print a separator line using the @p sep character. */ struct HeadingArgs: public GeneralArgs { HeadingArgs(const AsmFunctionIndex *index, std::ostream &output, Footnotes *footnotes, char sep='\0') : GeneralArgs(index, output, footnotes), sep(sep) {} char sep; /**< If non-NUL, then print a line of these characters. */ }; /** Arguments for column cells. */ struct DataArgs: public GeneralArgs { DataArgs(const AsmFunctionIndex *index, std::ostream &output, Footnotes *footnotes, SgAsmFunction *func, size_t rowid) : GeneralArgs(index, output, footnotes), func(func), rowid(rowid) {} SgAsmFunction *func; size_t rowid; }; /** Constructor. Every column must have a name and non-zero width. If a column is given a description then the column * name will reference a footnote containing the description. The footnote is added by the default HeadingArgs * callback, so subclasses should take care to add their own footnote if necessary. */ OutputCallback(const std::string &name, size_t width, const std::string description="") : name(name), desc(description), width(width), header_prefix(" "), separator_prefix(" "), data_prefix(" ") { assert(width>0 || name.empty()); } virtual ~OutputCallback() {} /** Set prefix characters. */ void set_prefix(const std::string &header, const std::string &separator=" ", const std::string &data=" "); /** Callback for before and after the table. The default does nothing, but subclasses can override this to do things * like print descriptions, footnotes, etc. */ virtual bool operator()(bool enabled, const BeforeAfterArgs&); /** Callback to print a column heading. The base class implementation prints the column name using the specified column * width. Subclasses probably don't need to override this method. */ virtual bool operator()(bool enabled, const HeadingArgs&); /** Callback to print data for a table cell. The base class implementation prints white space only, so subclasses * almost certainly want to override this method. */ virtual bool operator()(bool enabled, const DataArgs&); protected: std::string center(const std::string&, size_t width); /**< Center @p s in a string of length @p width. */ std::string name; /**< Column name used when printing table headers. */ std::string desc; /**< Optional description to appear in footnote. */ size_t width; /**< Minimum width of column header or data. */ std::string header_prefix; /**< Character(s) to print before headings. */ std::string separator_prefix; /**< Character(s) to print before line separators. */ std::string data_prefix; /**< Character(s) to print before data cells. */ }; /************************************************************************************************************************** * Predefined output callbacks **************************************************************************************************************************/ public: /** Print index row numbers. */ class RowIdCallback: public OutputCallback { public: RowIdCallback(): OutputCallback("Num", 4) {} virtual bool operator()(bool enabled, const DataArgs&); } rowIdCallback; /** Print function entry address. */ class EntryAddrCallback: public OutputCallback { public: EntryAddrCallback(): OutputCallback("Entry-Addr", 10) {} virtual bool operator()(bool enabled, const DataArgs&); } entryAddrCallback; /** Print function minimum address. */ class BeginAddrCallback: public OutputCallback { public: BeginAddrCallback(): OutputCallback("Begin-Addr", 10) {} virtual bool operator()(bool enabled, const DataArgs&); } beginAddrCallback; /** Print function ending address. */ class EndAddrCallback: public OutputCallback { public: EndAddrCallback(): OutputCallback("End-Addr", 10) {} virtual bool operator()(bool enabled, const DataArgs&); } endAddrCallback; /** Print number of instructions in function. */ class SizeInsnsCallback: public OutputCallback { public: SizeInsnsCallback(): OutputCallback("Insns", 5) {} virtual bool operator()(bool enabled, const DataArgs&); } sizeInsnsCallback; /** Print function size in bytes. */ class SizeBytesCallback: public OutputCallback { public: SizeBytesCallback(): OutputCallback("Bytes", 6) { set_prefix("/", "-", "/"); } virtual bool operator()(bool enabled, const DataArgs&); } sizeBytesCallback; /** Print function reason bits. */ class ReasonCallback: public OutputCallback { public: ReasonCallback(): OutputCallback("Reason", 1) {} // width will be overridden in the callback virtual bool operator()(bool enabled, const HeadingArgs&); virtual bool operator()(bool enabled, const DataArgs&); } reasonCallback; /** Print calling convention. */ class CallingConventionCallback: public OutputCallback { public: CallingConventionCallback(): OutputCallback("Kind", 8) {} virtual bool operator()(bool enabled, const DataArgs&); } callingConventionCallback; /** Function name. Prints function name if known, nothing otherwise. */ class NameCallback: public OutputCallback { public: NameCallback(): OutputCallback("Name", 32) {} virtual bool operator()(bool enabled, const DataArgs&); } nameCallback; /** Footnotes at the end of the table. */ class FootnotesCallback: public OutputCallback { public: FootnotesCallback(): OutputCallback("", 0) {} // not a table column virtual bool operator()(bool enabled, const BeforeAfterArgs&); } footnotesCallback; /************************************************************************************************************************** * Miscellaneous **************************************************************************************************************************/ protected: typedef std::vector<SgAsmFunction*> Functions; Functions functions; /**< Functions in index order. */ /** Initializes the callback lists. This is invoked by the default constructor. */ virtual void init(); /** List of callbacks to be invoked when printing columns. */ ROSE_Callbacks::List<OutputCallback> output_callbacks; }; #endif
// SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2021 YADRO #pragma once #include "variable.hpp" /** * @brief Parsers of the non-volatile partition on BIOS flash. */ namespace nvram { /** * @brief Parse dump of firmware volume with NV variables. * * @param[in] file Path to the file to parse * * @return array of UEFI variables * * @throw std::system_error in case of file IO errors * @throw std::runtime_error in case of format errors */ Variables parseVolume(const std::filesystem::path& file); /** * @brief Parse NVRAM dump. * * @param[in] data Pointer to the buffer to parse * @param[in] size Size of the buffer in bytes * * @return array of UEFI variables * * @throw std::runtime_error in case of format errors */ Variables parseNvram(const uint8_t* data, size_t size); } // namespace nvram
//--------------------------------------------------------------------------- #ifndef Unit7H #define Unit7H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <ExtCtrls.hpp> #include <jpeg.hpp> #include <Menus.hpp> //--------------------------------------------------------------------------- class Tviewer : public TForm { __published: // IDE-managed Components TImage *Image1; TBevel *Bevel1; TShape *Shape4; TShape *Shape2; TShape *Shape3; TShape *Shape5; TMainMenu *MainMenu1; TMenuItem *Opzioni1; TMenuItem *Esci1; TShape *Shape6; void __fastcall Esci1Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall Tviewer(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE Tviewer *viewer; //--------------------------------------------------------------------------- #endif
// MFCSingleToolBarView.cpp : implementation of the CMFCSingleToolBarView class // #include "stdafx.h" // SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail // and search filter handlers and allows sharing of document code with that project. #ifndef SHARED_HANDLERS #include "MFCSingleToolBar.h" #endif #include "MFCSingleToolBarDoc.h" #include "MFCSingleToolBarView.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMFCSingleToolBarView IMPLEMENT_DYNCREATE(CMFCSingleToolBarView, CListView) BEGIN_MESSAGE_MAP(CMFCSingleToolBarView, CListView) ON_WM_STYLECHANGED() ON_WM_CONTEXTMENU() ON_WM_RBUTTONUP() //--以下是自己的 ON_WM_MOUSEMOVE() ON_COMMAND(IDM_POINT, &CMFCSingleToolBarView::OnPoint) ON_COMMAND(IDM_RECTANGLE, &CMFCSingleToolBarView::OnRectangle) ON_COMMAND(IDM_LINE, &CMFCSingleToolBarView::OnLine) ON_COMMAND(IDM_ELLIPSE, &CMFCSingleToolBarView::OnEllipse) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_COMMAND(IDM_SETTING, &CMFCSingleToolBarView::OnSetting) ON_COMMAND(IDM_CHOOSE_COLOR, &CMFCSingleToolBarView::OnChooseColor) ON_WM_ERASEBKGND() ON_WM_ERASEBKGND() END_MESSAGE_MAP() // CMFCSingleToolBarView construction/destruction CMFCSingleToolBarView::CMFCSingleToolBarView() : m_firstPoint(0)//可以传0 , m_lineWith(1) , m_lineStyle(0) , m_color(RGB(255,0,0)) { // TODO: add construction code here } CMFCSingleToolBarView::~CMFCSingleToolBarView() { } BOOL CMFCSingleToolBarView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CListView::PreCreateWindow(cs); } void CMFCSingleToolBarView::OnInitialUpdate() { CListView::OnInitialUpdate(); // TODO: You may populate your ListView with items by directly accessing // its list control through a call to GetListCtrl(). } void CMFCSingleToolBarView::OnRButtonUp(UINT /* nFlags */, CPoint point) { ClientToScreen(&point); OnContextMenu(this, point); } void CMFCSingleToolBarView::OnContextMenu(CWnd* /* pWnd */, CPoint point) { #ifndef SHARED_HANDLERS theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); #endif } // CMFCSingleToolBarView diagnostics #ifdef _DEBUG void CMFCSingleToolBarView::AssertValid() const { CListView::AssertValid(); } void CMFCSingleToolBarView::Dump(CDumpContext& dc) const { CListView::Dump(dc); } CMFCSingleToolBarDoc* CMFCSingleToolBarView::GetDocument() const // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCSingleToolBarDoc))); return (CMFCSingleToolBarDoc*)m_pDocument; } #endif //_DEBUG // CMFCSingleToolBarView message handlers void CMFCSingleToolBarView::OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct) { //TODO: add code to react to the user changing the view style of your window CListView::OnStyleChanged(nStyleType,lpStyleStruct); } //---------我的代码 状态栏显示鼠标位置 void CMFCSingleToolBarView::OnMouseMove(UINT nFlags, CPoint point) { CString str; //str.Format(_T("x=%d,y=%d"),point.x,point.y); str.Format(L"x=%d,y=%d",point.x,point.y); //CMFCStatusBar statusBar= ((CMainFrame*)AfxGetMainWnd())->m_wndStatusBar;//默认是protected 可以修改为public,后报错 //statusBar.SetWindowTextW(str); //int index =statusBar.CommandToIndex(ID_SEPARATOR);//在ManFrm.h中有定义 //statusBar.SetPaneText(index,str,TRUE); //这里不能使用((CMainFrame*)GetParent(),要使用(CMainFrame*)AfxGetMainWnd() //((CMainFrame*)AfxGetMainWnd())->SetMessageText(str);//OK, //((CMainFrame*)AfxGetMainWnd())->GetMessageBar()->SetWindowText(str);//OK ((CMainFrame*)AfxGetMainWnd())->GetDescendantWindow(AFX_IDW_STATUS_BAR)->SetWindowTextW(str);//OK,CMMFCStatusBar,Create方法中默认ID CListView::OnMouseMove(nFlags, point); } void CMFCSingleToolBarView::OnPoint() { m_drawType = T_POINT; } void CMFCSingleToolBarView::OnRectangle() { m_drawType = T_RECTANGLE; } void CMFCSingleToolBarView::OnLine() { m_drawType = T_LINE; } void CMFCSingleToolBarView::OnEllipse() { m_drawType = T_ELLIPSE; } void CMFCSingleToolBarView::OnLButtonDown(UINT nFlags, CPoint point) { m_firstPoint=point; //CListView::OnLButtonDown(nFlags, point);//要注释它,要不然,不会响应OnLButtonUp } void CMFCSingleToolBarView::OnLButtonUp(UINT nFlags, CPoint point) { CClientDC dc(this); //PS_SOLID -- 0 还要对应界面的tab order //PS_DASH 1 //PS_DOT 2 CPen pen(m_lineStyle,m_lineWith,m_color); dc.SelectObject(&pen); CBrush * brush =CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)); dc.SelectObject(brush); //不知道修改了什么???,第一次菜单是但灰的,最开始是好的 switch (m_drawType) { case T_POINT: dc.SetPixel(m_firstPoint.x,m_firstPoint.y,RGB(255,0,0)); break; case T_LINE: dc.MoveTo(m_firstPoint); dc.LineTo(point); break; case T_ELLIPSE: dc.Ellipse(CRect(m_firstPoint,point)); break; case T_RECTANGLE: dc.Rectangle(CRect(m_firstPoint,point)); break; default: MessageBox(L"请在菜单中选择要画的图形"); } CListView::OnLButtonUp(nFlags, point); } void CMFCSingleToolBarView::OnSetting() { DrawSettingDlg dlg; dlg.m_nLineWidth=m_lineWith; //保存上次设置的值 dlg.m_lineStyle=m_lineStyle; if(IDOK==dlg.DoModal()) { m_lineWith=dlg.m_nLineWidth; m_lineStyle=dlg.m_lineStyle; Invalidate();//重画, 这里不会调用OnDraw,是因为Frame中有以WM_PAINT消息做处理 /* //这里测试时不把VS和弹出对框,挡在窗口前面 CClientDC dc(this); dc.SelectObject(&m_font); LOGFONT t_font; m_font.GetLogFont(&t_font); CString strFont=t_font.lfFaceName; dc.TextOut(200,200,strFont); */ } } void CMFCSingleToolBarView::OnChooseColor() { CMFCColorDialog dlg;//颜色选择话框 dlg.SetCurrentColor(m_color);//修改颜色 if(IDOK==dlg.DoModal()) { m_color=dlg.GetColor();//得到颜色 } } void CMFCSingleToolBarView::OnDraw(CDC* pDC)//自己加的,没用的被Frame给拦截了 { pDC->SelectObject(&m_font); LOGFONT t_font; m_font.GetLogFont(&t_font); CString strFont=t_font.lfFaceName; pDC->TextOutW(20,20,strFont); } //----------背景擦除消息,用于显示图片 BOOL CMFCSingleToolBarView::OnEraseBkgnd(CDC* pDC) { CBitmap map; BOOL isOK=map.LoadBitmap(IDB_BITMAP1); // jpg格式会失败 CDC dcCompatible; dcCompatible.CreateCompatibleDC(pDC); dcCompatible.SelectObject(&map); CRect rect; GetClientRect(&rect); pDC->BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);//1:1 BITMAP map_data; map.GetBitmap(&map_data); pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,map_data.bmWidth,map_data.bmHeight,SRCCOPY);//缩放大小 return TRUE; //return CListView::OnEraseBkgnd(pDC); }
#include <iostream> #include <fstream> using namespace std; ifstream f("date.in"); struct Node { double x; double y; bool convex; bool principal; Node(double a = 0, double b = 0): x(a), y(b), convex(true), principal(true) {}; }; struct Edge { Node A; Node B; }; bool peSegment(Node A, Node B, Node C) { if (B.x <= max(A.x, C.x) && B.x >= min(A.x, C.x) && B.y <= max(A.y, C.y) && B.y >= min(A.y, C.y)) return true; return false; } int orientare(Node A, Node B, Node C) { int rez = (B.y - A.y) * (C.x - B.x) - (B.x - A.x) * (C.y - B.y); if (rez == 0) return 0; else if (rez > 0) return 1; // clockwise else return 2; // counter-clockwise } int intersectie(Edge d1, Edge d2) { double a1, b1, c1; double a2, b2, c2; // primul edge scris cu ecuatia dreptei a1x + b1x = c1 a1 = d1.B.y - d1.A.y; b1 = d1.A.x - d1.B.x; c1 = a1 * (d1.A.x) + b1 * (d1.A.y); // al doilea edge scris cu ecuatia dreptei a2x + b2x = c2 a2 = d2.B.y - d2.A.y; b2 = d2.A.x - d2.B.x; c2 = a2 * (d2.A.x) + b2 * (d2.A.y); double delta = a1 * b2 - a2 * b1; // |a1 b1| delta e determinant // |a2 b2| if (delta == 0) { //cazul in care matricea extinsa are rang 1 =====> segmentele pe aceeasi dreapta double detMatExtinsa[3]; detMatExtinsa[0] = a1 * b2 - a2 * b1; detMatExtinsa[1] = a1 * (-c2) - a2 * (-c1); detMatExtinsa[2] = b1 * (-c2) - b2 * (-c1); if (!detMatExtinsa[0] && !detMatExtinsa[1] && !detMatExtinsa[2]) { //cazurile in care intersectia reprezinta un segment (punctele sunt coliniare) if (peSegment(d1.A, d2.A, d1.B) && peSegment(d2.A, d1.B, d2.B)) return 1; else if (peSegment(d1.A, d2.B, d1.B) && peSegment(d2.B, d1.B, d2.A)) return 1; else if (peSegment(d1.B, d2.A, d1.A) && peSegment(d2.A, d1.A, d2.B)) return 1; else if (peSegment(d1.B, d2.B, d1.A) && peSegment(d2.B, d1.A, d2.A)) return 1; else if (peSegment(d1.A, d2.A, d1.B) && peSegment(d1.A, d2.B, d1.B)) return 1; else if (peSegment(d2.A, d1.A, d2.B) && peSegment(d2.A, d1.B, d2.B)) return 1; else return 0; } // cazul cand segmentele sunt paralele else return 0; } else { //cand au orientari diferite double x = (b2 * c1 - b1 * c2) / delta; double y = (a1 * c2 - a2 * c1) / delta; Node crossPoint(x, y); if (peSegment(d1.A, crossPoint, d1.B) && peSegment(d2.A, crossPoint, d2.B)) return 1; //cand cele doua drepte se intersecteaza intr-un singur punct return 0; } } float sign (Node A, Node B, Node C) { return (A.x - C.x) * (B.y - C.y) - (B.x - C.x) * (A.y - C.y); } bool PointInTriangle (Node pt, Node V1, Node V2, Node V3) { float d1, d2, d3; bool has_neg, has_pos; d1 = sign(pt, V1, V2); d2 = sign(pt, V2, V3); d3 = sign(pt, V3, V1); has_neg = (d1 < 0) && (d2 < 0) && (d3 < 0); has_pos = (d1 > 0) && (d2 > 0) && (d3 > 0); return (has_neg || has_pos); } int main() { int i, j, n; double x, y; f >> n; Node* noduri = new Node[n]; Edge* muchii = new Edge[n]; for (i = 0; i < n; i++) { f >> x >> y; noduri[i].x = x; noduri[i].y = y; } //formam edge-urile for (i = 0; i < n - 1; i++) { muchii[i].A = noduri[i]; muchii[i].B = noduri[i + 1]; } muchii[n - 1].A = noduri[n - 1]; muchii[n - 1].B = noduri[0]; // CONVEX SAU CONCAV for (i = 0; i < n; i++) { if (orientare(noduri[i], noduri[(i+1)%(n)], noduri[(i+2)%(n)]) == 1) noduri[(i+1)%n].convex = false; } for (i = 0; i < n; i++) { if (noduri[i].convex == true) cout << "Nodul " << i << " este convex" << endl; else cout << "Nodul " << i << " este concav" << endl; } // PRINCIPAL SAU NU int suma; Edge _muchie; // CAZ PENTRU NODUL 0 suma = 0; _muchie.A = noduri[n-1]; _muchie.B = noduri[1]; for (j = 0; j < n; j++) suma += intersectie(_muchie, muchii[j]); if (suma > 4) noduri[0].principal = false; // CAZ PENTRU NODUL N-1 suma = 0; _muchie.A = noduri[n-2]; _muchie.B = noduri[0]; for (j = 0; j < n; j++) suma += intersectie(_muchie, muchii[j]); if (suma > 4) noduri[n-1].principal = false; // RESTUL for (i = 1; i < n-1; i++) { suma = 0; _muchie.A = noduri[i-1]; _muchie.B = noduri[i+1]; for (j = 0; j < n; j++) suma += intersectie(_muchie, muchii[j]); if (suma > 4) noduri[i].principal = false; } for (i = 0; i < n-1; i++) for (j = 0; j < n; j++) { if (j!= i && j!= i+1 && j!= i+2) { if (PointInTriangle(noduri[j], noduri[i], noduri[(i+1)%n],noduri[(i+2)%n])==true) noduri[(i+1)%n].principal = false; } } for (i = 0; i < n; i++) if (noduri[i].principal == true) cout << "Nodul " << i << " este principal" << endl; else cout << "Nodul " << i << " nu este principal" << endl; delete noduri; delete muchii; return 0; };
// C++ for the Windows Runtime vv1.0.170303.6 // Copyright (c) 2017 Microsoft Corporation. All rights reserved. #pragma once #include "../base.h" #include "Windows.Devices.Spi.Provider.0.h" #include "Windows.Foundation.1.h" WINRT_EXPORT namespace winrt { namespace ABI::Windows::Devices::Spi::Provider { struct __declspec(uuid("f6034550-a542-4ec0-9601-a4dd68f8697b")) __declspec(novtable) IProviderSpiConnectionSettings : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_ChipSelectLine(int32_t * value) = 0; virtual HRESULT __stdcall put_ChipSelectLine(int32_t value) = 0; virtual HRESULT __stdcall get_Mode(winrt::Windows::Devices::Spi::Provider::ProviderSpiMode * value) = 0; virtual HRESULT __stdcall put_Mode(winrt::Windows::Devices::Spi::Provider::ProviderSpiMode value) = 0; virtual HRESULT __stdcall get_DataBitLength(int32_t * value) = 0; virtual HRESULT __stdcall put_DataBitLength(int32_t value) = 0; virtual HRESULT __stdcall get_ClockFrequency(int32_t * value) = 0; virtual HRESULT __stdcall put_ClockFrequency(int32_t value) = 0; virtual HRESULT __stdcall get_SharingMode(winrt::Windows::Devices::Spi::Provider::ProviderSpiSharingMode * value) = 0; virtual HRESULT __stdcall put_SharingMode(winrt::Windows::Devices::Spi::Provider::ProviderSpiSharingMode value) = 0; }; struct __declspec(uuid("66456b5a-0c79-43e3-9f3c-e59780ac18fa")) __declspec(novtable) IProviderSpiConnectionSettingsFactory : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Create(int32_t chipSelectLine, Windows::Devices::Spi::Provider::IProviderSpiConnectionSettings ** value) = 0; }; struct __declspec(uuid("c1686504-02ce-4226-a385-4f11fb04b41b")) __declspec(novtable) ISpiControllerProvider : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_GetDeviceProvider(Windows::Devices::Spi::Provider::IProviderSpiConnectionSettings * settings, Windows::Devices::Spi::Provider::ISpiDeviceProvider ** result) = 0; }; struct __declspec(uuid("0d1c3443-304b-405c-b4f7-f5ab1074461e")) __declspec(novtable) ISpiDeviceProvider : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_DeviceId(hstring * value) = 0; virtual HRESULT __stdcall get_ConnectionSettings(Windows::Devices::Spi::Provider::IProviderSpiConnectionSettings ** value) = 0; virtual HRESULT __stdcall abi_Write(uint32_t __bufferSize, uint8_t * buffer) = 0; virtual HRESULT __stdcall abi_Read(uint32_t __bufferSize, uint8_t * buffer) = 0; virtual HRESULT __stdcall abi_TransferSequential(uint32_t __writeBufferSize, uint8_t * writeBuffer, uint32_t __readBufferSize, uint8_t * readBuffer) = 0; virtual HRESULT __stdcall abi_TransferFullDuplex(uint32_t __writeBufferSize, uint8_t * writeBuffer, uint32_t __readBufferSize, uint8_t * readBuffer) = 0; }; struct __declspec(uuid("96b461e2-77d4-48ce-aaa0-75715a8362cf")) __declspec(novtable) ISpiProvider : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_GetControllersAsync(Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Devices::Spi::Provider::ISpiControllerProvider>> ** result) = 0; }; } namespace ABI { template <> struct traits<Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings> { using default_interface = Windows::Devices::Spi::Provider::IProviderSpiConnectionSettings; }; } namespace Windows::Devices::Spi::Provider { template <typename D> struct WINRT_EBO impl_IProviderSpiConnectionSettings { int32_t ChipSelectLine() const; void ChipSelectLine(int32_t value) const; Windows::Devices::Spi::Provider::ProviderSpiMode Mode() const; void Mode(Windows::Devices::Spi::Provider::ProviderSpiMode value) const; int32_t DataBitLength() const; void DataBitLength(int32_t value) const; int32_t ClockFrequency() const; void ClockFrequency(int32_t value) const; Windows::Devices::Spi::Provider::ProviderSpiSharingMode SharingMode() const; void SharingMode(Windows::Devices::Spi::Provider::ProviderSpiSharingMode value) const; }; template <typename D> struct WINRT_EBO impl_IProviderSpiConnectionSettingsFactory { Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings Create(int32_t chipSelectLine) const; }; template <typename D> struct WINRT_EBO impl_ISpiControllerProvider { Windows::Devices::Spi::Provider::ISpiDeviceProvider GetDeviceProvider(const Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings & settings) const; }; template <typename D> struct WINRT_EBO impl_ISpiDeviceProvider { hstring DeviceId() const; Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings ConnectionSettings() const; void Write(array_view<const uint8_t> buffer) const; void Read(array_view<uint8_t> buffer) const; void TransferSequential(array_view<const uint8_t> writeBuffer, array_view<uint8_t> readBuffer) const; void TransferFullDuplex(array_view<const uint8_t> writeBuffer, array_view<uint8_t> readBuffer) const; }; template <typename D> struct WINRT_EBO impl_ISpiProvider { Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Devices::Spi::Provider::ISpiControllerProvider>> GetControllersAsync() const; }; } namespace impl { template <> struct traits<Windows::Devices::Spi::Provider::IProviderSpiConnectionSettings> { using abi = ABI::Windows::Devices::Spi::Provider::IProviderSpiConnectionSettings; template <typename D> using consume = Windows::Devices::Spi::Provider::impl_IProviderSpiConnectionSettings<D>; }; template <> struct traits<Windows::Devices::Spi::Provider::IProviderSpiConnectionSettingsFactory> { using abi = ABI::Windows::Devices::Spi::Provider::IProviderSpiConnectionSettingsFactory; template <typename D> using consume = Windows::Devices::Spi::Provider::impl_IProviderSpiConnectionSettingsFactory<D>; }; template <> struct traits<Windows::Devices::Spi::Provider::ISpiControllerProvider> { using abi = ABI::Windows::Devices::Spi::Provider::ISpiControllerProvider; template <typename D> using consume = Windows::Devices::Spi::Provider::impl_ISpiControllerProvider<D>; }; template <> struct traits<Windows::Devices::Spi::Provider::ISpiDeviceProvider> { using abi = ABI::Windows::Devices::Spi::Provider::ISpiDeviceProvider; template <typename D> using consume = Windows::Devices::Spi::Provider::impl_ISpiDeviceProvider<D>; }; template <> struct traits<Windows::Devices::Spi::Provider::ISpiProvider> { using abi = ABI::Windows::Devices::Spi::Provider::ISpiProvider; template <typename D> using consume = Windows::Devices::Spi::Provider::impl_ISpiProvider<D>; }; template <> struct traits<Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings> { using abi = ABI::Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings; static constexpr const wchar_t * name() noexcept { return L"Windows.Devices.Spi.Provider.ProviderSpiConnectionSettings"; } }; } }