blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
61d6cf8d6c9a8a5764c1591fe64e6d44e825680f
c0dffa026eb98d46c9c48d54dc8fd33062667bb3
/f9_os/inc/os/devices/stm32f7_uart.cpp
fbd0278bfb23ad2838ddcd11ad8d4bc12129859b
[ "Apache-2.0" ]
permissive
weimingtom/arm-cortex-v7-unix
322b7f339a62a016393d5dba44b290116ff5d23b
cd499fa94d6ee6cd78a31387f3512d997335df52
refs/heads/master
2022-06-02T21:37:11.113487
2017-07-21T13:14:42
2017-07-21T13:14:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
450
cpp
stm32f7_uart.cpp
//#include "stm32f7_uart.hpp" //UART_HandleTypeDef huart1; //DMA_HandleTypeDef hdma_usart1_tx; #if 0 int uartputc(int c) { while(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_TXE) == 0); huart1.Instance->TDR = c & 0xFF; while(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_TC) == 0); return c & 0xFF; } #endif #if 0 static os::device::stm32f7_uart usart1(1); extern "C" void USART1_IRQHandler() { os::device::stm32f7_uart::isr_handler(usart1); } #endif
bc58de5dd2659d26a2df93cb77c1ace110935b0a
c92fd29132b276988a132f7e2887677e879f0ed7
/Code/170222/Score.h
a59bf787c8d0098d9153f8d5ddd2ba54f315cfb7
[]
no_license
Kucladell/Friseven
3f199bc956bc692ac7a2e623cefd3e798fd65e08
b1af0c7d2ab1f7da528ee384b01298347f594ce8
refs/heads/master
2020-09-26T19:06:00.001646
2017-03-01T04:27:08
2017-03-01T04:27:08
66,899,352
0
0
null
null
null
null
UTF-8
C++
false
false
491
h
Score.h
#pragma once #include <iomanip> #include <iostream> #include <fstream> #include <string> struct Score { std::string name; int credit; float grade; std::string gradeText; bool isMajor; Score(std::string name, int credit, float grade, std::string gradetext, bool isMajor); void Print(); void input(LinkedList<Score>& data); void output(const LinkedList<Score>& data ); void calculate(LinkedList<Score>& data); void saveHTML(const LinkedList<Score>& data, std::string fileName); };
b92c5799ee1330dd417313c1d142e9278dfe2c79
7efaa0e97588a3c677b22e9e1220f72e37063e07
/src/sst/elements/vanadis/inst/vgpr2fp.h
8808e56c944653df9b63fdf3a690954ba64f1554
[ "BSD-3-Clause" ]
permissive
amroawad2/sst-elements
6e3e67e47fa5a891cdb3d68cc2d0728b9a1abcf2
dd1bf1d32dd2b4800a92b93103e297224bcdb120
refs/heads/master
2021-06-25T20:53:03.966249
2020-12-21T02:10:35
2020-12-21T02:10:35
133,526,382
0
0
NOASSERTION
2019-05-09T15:33:43
2018-05-15T14:14:02
C++
UTF-8
C++
false
false
3,004
h
vgpr2fp.h
#ifndef _H_VANADIS_GPR_2_FP #define _H_VANADIS_GPR_2_FP #include "inst/vinst.h" #include "inst/vregfmt.h" namespace SST { namespace Vanadis { class VanadisGPR2FPInstruction : public VanadisInstruction { public: VanadisGPR2FPInstruction( const uint64_t addr, const uint32_t hw_thr, const VanadisDecoderOptions* isa_opts, const uint16_t fp_dest, const uint16_t int_src, VanadisRegisterFormat fp_w ) : VanadisInstruction(addr, hw_thr, isa_opts, 1, 0, 1, 0, 0, ( (fp_w == VANADIS_FORMAT_FP64 || fp_w == VANADIS_FORMAT_INT64) && ( VANADIS_REGISTER_MODE_FP32 == isa_opts->getFPRegisterMode() ) ) ? 2 : 1, 0, ( (fp_w == VANADIS_FORMAT_FP64 || fp_w == VANADIS_FORMAT_INT64) && ( VANADIS_REGISTER_MODE_FP32 == isa_opts->getFPRegisterMode() ) ) ? 2 : 1), move_width(fp_w) { isa_int_regs_in[0] = int_src; if( ( (fp_w == VANADIS_FORMAT_FP64 || fp_w == VANADIS_FORMAT_INT64) && ( VANADIS_REGISTER_MODE_FP32 == isa_opts->getFPRegisterMode() ) ) ) { isa_fp_regs_out[0] = fp_dest; isa_fp_regs_out[1] = fp_dest + 1; } else { isa_fp_regs_out[0] = fp_dest; } } virtual VanadisGPR2FPInstruction* clone() { return new VanadisGPR2FPInstruction( *this ); } virtual VanadisFunctionalUnitType getInstFuncType() const { return INST_INT_ARITH; } virtual const char* getInstCode() const { switch( move_width ) { case VANADIS_FORMAT_INT32: case VANADIS_FORMAT_FP32: return "GPR2FP32"; case VANADIS_FORMAT_INT64: case VANADIS_FORMAT_FP64: return "GPR2FP64"; } } virtual void printToBuffer(char* buffer, size_t buffer_size) { snprintf(buffer, buffer_size, "%s fp-dest isa: %" PRIu16 " phys: %" PRIu16 " <- int-src: isa: %" PRIu16 " phys: %" PRIu16 "\n", getInstCode(), isa_fp_regs_out[0], phys_fp_regs_out[0], isa_int_regs_in[0], phys_int_regs_in[0] ); } virtual void execute( SST::Output* output, VanadisRegisterFile* regFile ) { output->verbose(CALL_INFO, 16, 0, "Execute (addr=0x%llx) %s fp-dest isa: %" PRIu16 " phys: %" PRIu16 " <- int-src: isa: %" PRIu16 " phys: %" PRIu16 "\n", getInstructionAddress(), getInstCode(), isa_fp_regs_out[0], phys_fp_regs_out[0], isa_int_regs_in[0], phys_int_regs_in[0] ); switch( move_width ) { case VANADIS_FORMAT_INT32: case VANADIS_FORMAT_FP32: { const int32_t v = regFile->getIntReg<int32_t>( phys_int_regs_in[0] ); regFile->setFPReg<int32_t>( phys_fp_regs_out[0], v ); } break; case VANADIS_FORMAT_INT64: case VANADIS_FORMAT_FP64: { if( VANADIS_REGISTER_MODE_FP32 == isa_options->getFPRegisterMode() ) { const int64_t v = regFile->getIntReg<int64_t>( phys_int_regs_in[0] ); fractureToRegisters<int64_t>( regFile, phys_fp_regs_out[0], phys_fp_regs_out[1], v ); } else { const int64_t v = regFile->getIntReg<int64_t>( phys_int_regs_in[0] ); regFile->setFPReg<int64_t>( phys_fp_regs_out[0], v ); } } break; } markExecuted(); } protected: VanadisRegisterFormat move_width; }; } } #endif
729bb6e8beacbe3a8c7926a09c043ae8472ccd23
36c00fe2afff4818c937e312ce0c6a79f35e2a77
/7-kyu/see-you-next-happy-year-/c++/solution.cpp
5ecf494cd8ad2c1b5ea1e125836a5459356518f1
[]
no_license
p-lots/codewars
0a67b6ee4c91180ff78c648421b9d2d64463ddc3
535faeee475c6b398124d6f5002b0e111406e8bb
refs/heads/master
2023-08-23T22:14:33.635011
2023-08-23T13:30:37
2023-08-23T13:30:37
195,320,309
0
0
null
2023-05-09T19:25:50
2019-07-05T01:40:15
Python
UTF-8
C++
false
false
515
cpp
solution.cpp
#include <vector> bool isHappyYear(unsigned short int year) { std::vector<int> year_vec; while (year > 0) { year_vec.push_back(year % 10); year /= 10; } for (const auto &n : year_vec) { if (std::count(year_vec.begin(), year_vec.end(), n) > 1) return false; } return true; } unsigned short int nextHappyYear (unsigned short int year) { if (isHappyYear(year)) year++; while (!isHappyYear(year)) { year++; } return year; }
907ca9c52c3ec50ae10e68c3bc08402ac3ce7180
b0037831a6dc021c1c9c67f2b0511d750f33a91e
/Project4/Project4/源.cpp
07e22109f8baa399a035790cec1470bd96b9f49d
[]
no_license
477918269/C-cpp
a01b47b55bb8b0b6d88f5efb8eda4925fe43cc95
a2a1a435fe030bfc76ef8e960949aacbc84edf6c
refs/heads/master
2022-03-03T23:20:34.542904
2019-10-13T15:05:05
2019-10-13T15:05:05
163,571,435
1
0
null
null
null
null
UTF-8
C++
false
false
769
cpp
源.cpp
#include "stdio.h" #include "stdlib.h" void fun1(){ int *data = malloc(sizeof(int)* 4); data[0] = 1; data[1] = 2; data[2] = 3; data[3] = 4; printf("%d\t%d\n", *data, *(data + 1)); } void fun2(){ void *data = malloc(sizeof(int)* 4); *(int*)(data + sizeof(int)* 0) = 1; *(int*)(data + sizeof(int)* 1) = 2; *(int*)(data + sizeof(int)* 2) = 3; *(int*)(data + sizeof(int)* 3) = 4; printf("%d\t%d\n", *(int*)data, *(int*)(data + sizeof(int)* 3)); } void fun3(){ int i; void *data = malloc(sizeof(int)* 4); int *data2 = malloc(sizeof(int)* 4); printf("\n"); for (i = 0; i < 4; i++) { printf("test1:%d\n", data + i); } printf("\n"); for (i = 0; i < 4; i++) { printf("test2:%d\n", data2 + i); } } int main(){ fun1(); fun2(); fun3(); return 0; }
53056090d61d8a44f629bce35e8d68d5f864a5bc
8e734cf429e5aeeef3a479da01ef9017204f8e60
/Skystone/Components/Render/SpriteAnimator.h
2e2f6a8210ce01d1b743f58f9c52faab894be616
[]
no_license
kgwong/ProjectSkystone
e559f2dea5e4d4f5c9b2e4fd385e375d91e39a7e
dcf1970c36714464b7850ed74ecaf39f2a63d414
refs/heads/master
2021-01-21T13:52:35.712255
2016-06-04T06:59:29
2016-06-04T06:59:29
44,451,311
1
0
null
null
null
null
UTF-8
C++
false
false
892
h
SpriteAnimator.h
#ifndef SPRITE_ANIMATOR_H #define SPRITE_ANIMATOR_H #include "RenderComponent.h" #include "Resources/SpriteSheet.h" #include "GameTypes/Axis.h" class SpriteRenderer; class SpriteAnimator : public RenderComponent { public: SpriteAnimator(GameObject& owner, SpriteRenderer* renderer); virtual ~SpriteAnimator(); virtual void start(Scene& scene); virtual void render(GameWindow& gameWindow, float percBehind); //-1 means loop forever void setTimesToPlay(int numLoops); void setSpriteSheet(const std::string& relPath); void setSpriteSheet(SpriteSheet* spriteSheet); void setSpriteIndex(int index); void flip(Axis axis); void setFlipHorz(bool value); void setFlipVert(bool value); void setRotation(double degrees); private: SpriteRenderer* spriteRenderer_; SpriteSheet* spriteSheet_; int loopCount_; int currFrameIndex_; int msOnFrame_; }; #endif //SPRITE_ANIMATOR_H
1df7b28eb28fc3079f097a618cc310ebb243c216
08e506bfd24e05ff4f2c27d4e97ce98591a8954b
/poj/3183.cpp
8d524a90e655c5e15ab7f35afbe9b71c8a2dd1b0
[ "MIT" ]
permissive
331072838/poj
808c901eb402e669d14a05de93e75c25260f11b8
80cccc7287f23d33cde75b51a78a04bdb75408cb
refs/heads/master
2021-09-19T16:07:15.386778
2018-07-29T09:14:29
2018-07-29T09:14:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
325
cpp
3183.cpp
#include<stdio.h> int main() { int n,i,j,r,stump; scanf("%d",&n); r=0; stump=0; for (i=0;i<n;i++) { scanf("%d",&j); if (j>stump) r=0; else { if (r==0) { printf("%d\n",i); r=1; } if (j==stump) r=0; } stump=j; } if (r==0) printf("%d\n",i); return 0; }
9dbca7cd1c8a1aab42dfbd5670bfe28e3d6e712f
34c54b791e4c6843a7dae05716e1c91419b15677
/Day26.cpp
253ab52802253b2aa2b3cfef28cf41da9924cec1
[]
no_license
semihalperenkayaalti/HackerRank30daysofcode
e9fec4be5c0bd0fab8fb8a0fd2a0f818c37dda16
afb9c6e0bb84f82e459ff6e0120a1ad209b102e4
refs/heads/master
2020-06-07T09:13:41.264703
2019-06-26T21:19:57
2019-06-26T21:19:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
665
cpp
Day26.cpp
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int firstDay, firstMonth, firstYear, dueDay, dueMonth, dueYear; cin >> firstDay >> firstMonth >> firstYear >> dueDay >> dueMonth >> dueYear; //if returned early if(dueYear > firstYear || (dueYear > firstYear && dueMonth > firstMonth)){ cout << "0"; return 0; } //if returned late cout << (firstYear <= dueYear ?(firstMonth <= dueMonth ? (firstDay <= dueDay ? 0 : 15 * (firstDay-dueDay)): 500*(firstMonth-dueMonth)):10000); return 0; }
e4356d650c7d9eaa4d1e056a2dcead4745b9587e
8ebf4049ef5db02df19c978dabee3c53e5ef565c
/parser/src/slr.h
e25bc1bf4cd92056ff74005fd426582a04c8ae5c
[]
no_license
vicvon/crowbar
9ab99eedb2c47b171e27f688e6c799abc2d63610
7fca7d2504bda95ae9bd40476b8258bd5377605e
refs/heads/master
2021-01-01T04:01:38.622034
2017-03-07T03:11:52
2017-03-07T03:11:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,875
h
slr.h
#ifndef SLR_H #define SLR_H #include <set> #include <string> #include <vector> #include <map> #include <stack> #include <utility> #include <iostream> #include "bnf_rule.h" #include "../../lexer/src/lex.h" #include "../../lexer/src/util.h" using namespace std; namespace ENUM { enum ActionType { ACTION_SHIFT, ACTION_REDUCE, ACTION_ACCEPT, ACTION_ERROR }; } class SLR { public: SLR(); ~SLR(); void build_from_bnf_rules(vector<BnfRule> bnf_rules); void just_read_bnf_rules(vector<BnfRule> bnf_rules); void parse(Lex &lexer); void print_table_hard_code(ostream& out); void add_goto_table(int from, bool is_terminal, string type, string value ,int to); void add_action_table(int state, string input_string, ENUM::ActionType type, int state_no, int rule_pos); private: struct Item { int rule_pos; int dot_pos; Item(int r, int d); }; struct State { int no; set<Item> kernel; set<Item> item; State(); State(int _no, set<Item> _kernel, set<Item> _item); }; struct Action { ENUM::ActionType type; int state_no; int rule_pos; Action(); Action(const Action& another); Action& operator =(const Action& another); Action(ENUM::ActionType _type); Action(ENUM::ActionType _type, int _state_no, int _rule_pos); }; int _state_count; vector<BnfRule> _bnf_rules; set< set<Item> > _only_item_states; vector< State > _states; map< pair<set<Item>, BnfRule::Symbol>, set<Item> > _goto_map; map< set<Item>, int > _all_item_state_no_map; set< string > _terminal_set; set< BnfRule::Symbol > _nonterminal_set; map< int, map<BnfRule::Symbol, int> > _goto_table; map< int, map<string, Action> > _action_table; set<Item> _goto(set<Item> I, BnfRule::Symbol X); set<Item> _closure(set<Item> I); void _construct_terminal_and_nonterminal_set(); void _construct_states(); void _construct_action_table(); void _print_bnf_rule(); void _print_specific_bnf_rule(int rule_pos); void _print_item(Item item); void _print_state(State state); void _print_state_transition(); void _print_first_follow(); void _print_action_table(); void _print_goto_table(); void _print_terminal_and_nonterminal_set(); void _print_to_yacc_output(); map<BnfRule::Symbol, bool> _nullable_map; map<BnfRule::Symbol, set<string> > _first_map; map< vector<BnfRule::Symbol>, set<string> > _first_vec_map; map<BnfRule::Symbol, set<string> > _follow_map; bool _nullable(BnfRule::Symbol symbol); set<string> _first_vec(vector<BnfRule::Symbol> symbol_vec); set<string> _first(BnfRule::Symbol symbol); set<string> _follow(BnfRule::Symbol symbol); void _calculate_follow(); bool _has_calculate_follow; friend bool operator < (const Item& one, const Item& another); friend bool operator== (const Item& one, const Item& another); }; #endif
f4aec3358182018b5cdd5654e86e844bf2fef812
7e9a73cf9e01b353945b53c91556536641a02137
/tdutils/td/utils/port/detail/ThreadPthread.h
c86935b3e63b2f775a0911387e0ed07f1dac8e0e
[ "JSON", "LicenseRef-scancode-unknown-license-reference", "BSL-1.0" ]
permissive
tdlib/td
a3036bf50a834f68337f8dc451165d4dd474b6e1
470c36ceef780ff6189bbd8e2f889941ca828247
refs/heads/master
2023-09-04T01:37:21.754421
2023-08-24T09:21:04
2023-08-24T09:21:04
115,883,761
6,323
1,497
BSL-1.0
2023-09-04T19:10:38
2017-12-31T20:23:47
C++
UTF-8
C++
false
false
2,888
h
ThreadPthread.h
// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #pragma once #include "td/utils/port/config.h" #ifdef TD_THREAD_PTHREAD #include "td/utils/common.h" #include "td/utils/Destructor.h" #include "td/utils/invoke.h" #include "td/utils/MovableValue.h" #include "td/utils/port/detail/ThreadIdGuard.h" #include "td/utils/port/thread_local.h" #include "td/utils/Slice.h" #include "td/utils/Status.h" #include <tuple> #include <type_traits> #include <utility> #if TD_OPENBSD || TD_SOLARIS #include <pthread.h> #endif #include <sys/types.h> #if TD_LINUX || TD_FREEBSD || TD_NETBSD #define TD_HAVE_THREAD_AFFINITY 1 #endif namespace td { namespace detail { class ThreadPthread { public: ThreadPthread() = default; ThreadPthread(const ThreadPthread &) = delete; ThreadPthread &operator=(const ThreadPthread &) = delete; ThreadPthread(ThreadPthread &&other) noexcept : is_inited_(std::move(other.is_inited_)), thread_(other.thread_) { } ThreadPthread &operator=(ThreadPthread &&other) noexcept { join(); is_inited_ = std::move(other.is_inited_); thread_ = other.thread_; return *this; } template <class Function, class... Args> explicit ThreadPthread(Function &&f, Args &&...args) { auto func = create_destructor([args = std::make_tuple(decay_copy(std::forward<Function>(f)), decay_copy(std::forward<Args>(args))...)]() mutable { invoke_tuple(std::move(args)); clear_thread_locals(); }); do_pthread_create(&thread_, nullptr, run_thread, func.release()); is_inited_ = true; } ~ThreadPthread() { join(); } void set_name(CSlice name); void join(); void detach(); static unsigned hardware_concurrency(); using id = pthread_t; id get_id() noexcept { return thread_; } static void send_real_time_signal(id thread_id, int real_time_signal_number); #if TD_HAVE_THREAD_AFFINITY static Status set_affinity_mask(id thread_id, uint64 mask); static uint64 get_affinity_mask(id thread_id); #endif private: MovableValue<bool> is_inited_; pthread_t thread_; template <class T> std::decay_t<T> decay_copy(T &&v) { return std::forward<T>(v); } static int do_pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); static void *run_thread(void *ptr) { ThreadIdGuard thread_id_guard; auto func = unique_ptr<Destructor>(static_cast<Destructor *>(ptr)); return nullptr; } }; namespace this_thread_pthread { ThreadPthread::id get_id(); } // namespace this_thread_pthread } // namespace detail } // namespace td #endif
8c57a21b9db58d8110d8d70581340c44015bce3e
e79b9ca3529d77b63247b0d0d4f82f14ab85fc1f
/led_string/led_string.sdk/SDK/SDK_Export/oled_project/src/GraphicsDisplay.h
0d458b51811c2792e53b1843689a1be062ed08d5
[ "MIT" ]
permissive
SiaFahim/fpga
cb435e9f04147369f58f2e628fb2fe5399256ac7
ab58ffc8b4bd1e520c69acd7a52070c28e2163d3
refs/heads/master
2021-01-23T01:35:28.310908
2014-04-02T22:21:34
2014-04-02T22:21:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
367
h
GraphicsDisplay.h
/* * GraphicsDisplay.h * * Created on: Jan 5, 2014 * Author: DGronlund */ #ifndef GRAPHICSDISPLAY_H_ #define GRAPHICSDISPLAY_H_ class GraphicsDisplay { private: bool** pixels; int width; int height; public: GraphicsDisplay(int, int); virtual ~GraphicsDisplay(); void pixelSet(int, int, bool); void spi_flush(); }; #endif /* GRAPHICSDISPLAY_H_ */
6a4b8d9c2f448c6c0557f6b81c6083e8e7ac81fe
afde9a797303f0035df169868dd3fd12b54b0543
/lib/builddrawlist.h
c20089fd5f41413342d6c13606c5b67339834c36
[]
no_license
ninjapanzer/St-Vincent-College-Driving-Simulator-CS355-Fall
6645b0ee95b9f250ff20f066920feddcc7a4f5a4
76e7b0ec901e27d7fe8716c30006cb08ad1b0467
refs/heads/master
2016-08-08T14:04:31.578867
2009-11-29T21:58:17
2009-11-29T21:58:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,501
h
builddrawlist.h
//Author: Paul Scarrone //Class to complete a draw list of objects from a single vector array //Depends upon <iostream> "coordstructs.h" "linkedlist.h" using namespace std; //Creates a doubly linked list in the exact draw order of both sides of the road surface class BuildDrawList: public CalculateNormals, public ParseVector { private: CoordBlock* localCoordBlock; //pointer of CoordBlock to create an alias for the passed in coordArray long size; float surfaceZ; protected: DoubleLinked<CoordBlock> list; //linked list used to store draw order DoubleLinked<CoordBlock> rightList; DoubleLinked<CoordBlock> leftList; public: BuildDrawList(){} template<int N> //stl to grab the index of a passed array BuildDrawList(CoordBlock (&coordArray)[N]) { this->SetNormalDistance(25); this->surfaceZ = -.00000001f; this->SetDiffuseColor(dbRGB(0,0,0)); this->localCoordBlock = new CoordBlock[N]; for (int i = 1; i<N-1; i++) { this->localCoordBlock[i] = coordArray[i]; } for (int i = 1; i<N-1; i++) { this->CompleteVertexBlockRight(i); } for (int i = 1; i<N-1; i++) { this->CompleteVertexBlockLeft(i); } } BuildDrawList(DoubleLinked<CoordBlock> &list) { this->SetNormalDistance(.5f); this->surfaceZ = -.00001f; this->SetDiffuseColor(dbRGB(255,255,0)); this->size = list.GetSize(); this->localCoordBlock = new CoordBlock[size]; for (long i = 0; i<size/2; i++) { this->localCoordBlock[i] = list.pop_front(); } } void SetSurfaceZ(float z){this->surfaceZ = z;} void ClearList() { for(long i = 0; !(this->list.empty()); i++) { this->list.pop_front(); } } void CompletePolygonRight() { this->ClearList(); for (long i = 0; i<this->size; i++) { this->CompleteVertexBlockRight(i); } this->list.CopyList(rightList); } void CompletePolygonLeft() { this->ClearList(); for (long i = 0; i<size; i++) { this->CompleteVertexBlockLeft(i); } this->list.CopyList(leftList); } //push items in the drawing list for polygons on the right side of the vector void CompleteVertexBlockRight(int i) { CoordBlock firstNormal; //storage for a normal in format coordblock CoordBlock secondNormal; //storage for a normal in format coordblock //single line to calculate a normal in vertex 3d format and convert to coodblock format calculation for first is x-1, x, x+1 positions firstNormal = this->CompleteCoordBlock(this->GetRightNormal(this->localCoordBlock[i-1].vertex, this->localCoordBlock[i].vertex,this->localCoordBlock[i+1].vertex)); //single line to calculate a normal in vertex 3d format and convert to coodblock format calculation for first is x, x+1, x+2 positions secondNormal = this->CompleteCoordBlock(this->GetRightNormal(this->localCoordBlock[i].vertex, this->localCoordBlock[i+1].vertex,this->localCoordBlock[i+2].vertex)); //(1)push Second Normal to the List this->list.push_back(secondNormal); //(2)push First Normal to the List this->list.push_back(firstNormal); //(3)push Second Center to the List this->list.push_back(this->CompleteCoordBlock(this->localCoordBlock[i+1].vertex)); //(4)push First normal point to list this->list.push_back(firstNormal); //(5)push First Center to the List this->list.push_back(this->CompleteCoordBlock(this->localCoordBlock[i].vertex)); //(6)push Second Center to the List this->list.push_back(this->CompleteCoordBlock(this->localCoordBlock[i+1].vertex)); } //push items in the drawing list for polygons on the left side of the vector void CompleteVertexBlockLeft(int i) { CoordBlock firstNormal; //storage for a normal in format coordblock CoordBlock secondNormal; //storage for a normal in format coordblock Vertex3d test; //single line to calculate a normal in vertex 3d format and convert to coodblock format calculation for first is x-1, x, x+1 positions firstNormal = this->CompleteCoordBlock(this->GetLeftNormal(this->localCoordBlock[i-1].vertex, this->localCoordBlock[i].vertex,this->localCoordBlock[i+1].vertex)); //single line to calculate a normal in vertex 3d format and convert to coodblock format calculation for first is x, x+1, x+2 positions secondNormal = this->CompleteCoordBlock(this->GetLeftNormal(this->localCoordBlock[i].vertex, this->localCoordBlock[i+1].vertex,this->localCoordBlock[i+2].vertex)); //(1)push Second Center to the List this->list.push_back(this->CompleteCoordBlock(this->localCoordBlock[i+1].vertex)); //(2)push First Center to the List this->list.push_back(this->CompleteCoordBlock(this->localCoordBlock[i].vertex)); //(3)push Second Normal to the List this->list.push_back(secondNormal); //(4)push First Center to the list this->list.push_back(this->CompleteCoordBlock(this->localCoordBlock[i].vertex)); //(5)push First Normal to the List this->list.push_back(firstNormal); //(6)push Second Normal to the List this->list.push_back(secondNormal); } //pass the list object to calling function by reference void GetCoordBlock(DoubleLinked<CoordBlock> (&list2)) { this->list.CopyList(list2); } //takes in one point and creates a FVF coord block from it Vertex3d to CoordBlock CoordBlock CompleteCoordBlock(Vertex3d inputVertex) { CoordBlock tempCoordBlock; tempCoordBlock.SetDiffuseColor(this->diffuseColor); inputVertex.z = this->surfaceZ; tempCoordBlock.CompleteCoordBlock(inputVertex); return tempCoordBlock; } };
7317864d5e6c2b47747f354c162060891671a17a
867040dcc598170096799175c189583a7c891897
/Hemautomation/hub_new/hub_new.ino
e6a3a36b943b2f40213622e1a08359651acf3337
[]
no_license
sockur/ArduinoKod
f5eb6629515048edf65cc767ab4d3353d2e0357b
cc67e8becc3eccfabf49ab436a64de6883d7bd9f
refs/heads/master
2021-01-10T03:36:15.182351
2015-12-09T00:38:04
2015-12-09T00:38:04
47,657,542
0
0
null
null
null
null
UTF-8
C++
false
false
4,726
ino
hub_new.ino
#include <VirtualWire.h> #include <SPI.h> #include <Ethernet.h> #include <PubSubClient.h> // Update these with values suitable for your network. byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; IPAddress server(192, 168, 1, 34); EthernetClient ethClient; PubSubClient mqttClient(ethClient); float temp; boolean firstTime = true; int i; unsigned long timeLast = 0; unsigned long timeDiff = 0; typedef struct { int roomId; //node ID (1xx, 2xx, 3xx); 1xx = basement, 2xx = main floor, 3xx = outside int deviceId; //sensor ID (2, 3, 4, 5) int sensorId; int msgId; unsigned long data1_millisecs; //uptime in ms int data2; //sensor data? int data2_factor; int data3; //battery condition? int data3_factor; } msg_t; msg_t msg; // Acknowledge message type typedef struct { int deviceId; int msgId; } ack_t; ack_t ack; void initVirtualWire(){ vw_set_tx_pin(3); vw_set_rx_pin(4); vw_setup(2000); vw_rx_start(); } void setup(){ Serial.begin(9600); mqttClient.setServer(server, 1883); mqttClient.setCallback(callback); initVirtualWire(); if (Ethernet.begin(mac) == 0){ Serial.println("Failed to configure Ethernet using DHCP"); return; } delay(1500); } void loop(){ if (!mqttClient.connected()) { reconnect(); } mqttClient.loop(); uint8_t buf[VW_MAX_MESSAGE_LEN]; // uint8_t buflen ; uint8_t buflen = VW_MAX_MESSAGE_LEN; if (firstTime == true){ Serial.print("buflen1:"); Serial.println(buflen); firstTime = false; } if( vw_get_message(buf, &buflen) ) { Serial.print("buflen:"); Serial.println(buflen); if (buflen == sizeof(msg_t)) { // The right amount of data was received memcpy( &msg, buf, sizeof(msg)); // copy the received data into the struct Serial.print("msg.deviceId: "); Serial.println(msg.deviceId); Serial.print("msg.msgId: "); Serial.println(msg.msgId); ack.deviceId = msg.deviceId; ack.msgId = msg.msgId; Serial.print("ack.deviceId: "); Serial.println(ack.deviceId); Serial.print("ack.msgId: "); Serial.println(ack.msgId); Serial.print("sizeof ack "); Serial.println(sizeof(ack)); vw_send((uint8_t *)&ack, sizeof(ack)); // vw_send((uint8_t *)&message, sizeof(message)); vw_wait_tx(); timeDiff = msg.data1_millisecs - timeLast; Serial.print(F("identifier = ")); // Serial.println( msg.roomId); // Serial.println( msg.arduinoId); Serial.println( msg.sensorId); Serial.print("Time diff: "); Serial.println( timeDiff); Serial.print( "msgId:"); Serial.println( msg.msgId); Serial.println( msg.data2); Serial.println( msg.data2_factor); float factor = msg.data2_factor; if (factor == 0.0){ factor = 1.0; } float temp = msg.data2; temp = temp / factor; Serial.print( "temp : "); Serial.println(temp); char temperature[10]; dtostrf(temp,4,3,temperature); //buildTopic(); // mqttClient.publish("/home/1/ard1/p2/state",temperature); // String topicStr = buildTopic(); int topicLength = topicStr.length()+1; char topic[topicLength]; topicStr.toCharArray(topic, topicLength); mqttClient.publish(topic,temperature); timeLast = msg.data1_millisecs; } //delay(000); } } String buildTopic(){ // "/home/1/ard1/p2/state" // String topic = "/home/" + msg.roomId; String topic = "/home/"; topic = topic + msg.roomId; topic = topic + "/ard"; topic = topic + msg.deviceId; topic = topic + "/p"; topic = topic + msg.sensorId; topic = topic + "/state"; return topic; } void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i=0;i<length;i++) { Serial.print((char)payload[i]); } Serial.println(); } void reconnect() { // Loop until we're reconnected while (!mqttClient.connected()) { Serial.print("Attempting MQTT connection..."); // Attempt to connect if (mqttClient.connect("arduinoClient")) { Serial.println("connected"); // Once connected, publish an announcement... mqttClient.publish("outTopic","hello world"); // ... and resubscribe mqttClient.subscribe("inTopic"); } else { Serial.print("failed, rc="); Serial.print(mqttClient.state()); Serial.println(" try again in 5 seconds"); // Wait 5 seconds before retrying delay(5000); } } }
ae5547866368ade37cd261dfd6e2165ac401d6a1
bc1e0e56cd6cc337d4d60a1040d87c8634e4f99e
/src/map/map-sector-database-hashmap-impl.cpp
413afb6179a8b9d65c2d0418e23e258c1c826d62
[]
no_license
spacekitcat/isometric-sdl-demo
dfbda7e1806417fa7c85d030ca62939b9eaf4b10
a1e3aefb0f6dd145e4804319660bdef73a4bfc98
refs/heads/main
2023-08-13T22:35:41.421884
2021-10-09T16:41:16
2021-10-09T16:41:16
380,589,963
1
0
null
null
null
null
UTF-8
C++
false
false
430
cpp
map-sector-database-hashmap-impl.cpp
#include "map-sector-database-hashmap-impl.hpp" MapSectorDatabaseHashmapImpl::MapSectorDatabaseHashmapImpl() {} MapSectorDatabaseHashmapImpl::~MapSectorDatabaseHashmapImpl() {} void MapSectorDatabaseHashmapImpl::put( std::string key, std::shared_ptr<IsometricTileMapSector> sector) { _map[key] = sector; } std::shared_ptr<IsometricTileMapSector> MapSectorDatabaseHashmapImpl::get(std::string key) { return _map[key]; }
b8157aa81b8005a7570efbd240f10b32b974cf0e
136ef215ae05f74d31dab2336979a94dfe960992
/019-debouncing/019-debouncing-con-delay/019-debouncing1-delay.ino
c82dcbc9e7e14cfefcf2fc895eceb6b9b5a1c0bd
[]
no_license
zmaker/arduino_cookbook
5ff4791ebce916e35060f2e9a7c26a014adeb26c
a972470c10f2c283d66aad8f389acf117a25f01e
refs/heads/master
2023-08-30T21:08:28.290973
2023-08-28T11:14:41
2023-08-28T11:14:41
135,202,699
196
134
null
2020-05-27T17:53:02
2018-05-28T19:46:44
C++
UTF-8
C++
false
false
150
ino
019-debouncing1-delay.ino
void setup() { pinMode(7, INPUT); Serial.begin(9600); } void loop() { if (digitalRead(7)) { delay(200); Serial.println("B1"); } }
008f790ac72389889c6086c7e9b469a613322ddc
ffff32a60cfbc310c51413cd4fb053a0672b382f
/renderer/primary_surface.cpp
743862935f10b9e969996800a649413fa54c2c88
[ "MIT" ]
permissive
jdmclark/jkgfxmod
99f2c751d57d468dedc6d117c89e0091d31814e1
6612413810129ebeae2affeb956d0a5fdb41dd0e
refs/heads/master
2022-08-20T11:55:24.079818
2021-07-19T06:30:29
2021-07-19T06:30:29
175,068,739
71
13
MIT
2022-07-15T03:58:07
2019-03-11T19:19:32
C++
UTF-8
C++
false
false
1,623
cpp
primary_surface.cpp
#include "primary_surface.hpp" #include "base/log.hpp" #include "common/error_reporter.hpp" #include "dxguids.hpp" #include "renderer.hpp" jkgm::primary_surface::primary_surface(renderer *r) : DirectDrawSurface_impl("primary") , r(r) { } ULONG WINAPI jkgm::primary_surface::AddRef() { // Primary surface is managed by the renderer. Refcount is intentionally not used. return 1000; } ULONG WINAPI jkgm::primary_surface::Release() { // Primary surface is managed by the renderer. Refcount is intentionally not used. return 1000; } HRESULT WINAPI jkgm::primary_surface::Blt(LPRECT a, LPDIRECTDRAWSURFACE b, LPRECT c, DWORD d, LPDDBLTFX e) { // Intentionally ignored return DD_OK; } HRESULT WINAPI jkgm::primary_surface::Flip(LPDIRECTDRAWSURFACE a, DWORD b) { r->present_game(); return DD_OK; } HRESULT WINAPI jkgm::primary_surface::GetAttachedSurface(LPDDSCAPS a, LPDIRECTDRAWSURFACE *b) { if(a->dwCaps & DDSCAPS_BACKBUFFER) { *b = r->get_directdraw_backbuffer_surface(); return DD_OK; } report_unimplemented_function( str(fmt("DirectDrawSurface(primary)::GetAttachedSurface(", a->dwCaps, ")"))); } HRESULT WINAPI jkgm::primary_surface::GetBltStatus(DWORD a) { return DD_OK; } HRESULT WINAPI jkgm::primary_surface::GetFlipStatus(DWORD a) { return DD_OK; } HRESULT WINAPI jkgm::primary_surface::GetSurfaceDesc(LPDDSURFACEDESC a) { // Jedi Knight only asks for the surface caps and the number of back buffers a->dwBackBufferCount = 1; a->ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE; return DD_OK; }
93b43f59f294099897ddf9b47d420d31838cbb9b
a71e120698165b95c6c3f4cdb9b8ec1e5e118170
/Validation/VstMathUtils/src/matrix.cc
d7b697570bc010b4d766cdf19c12fa31f667195e
[]
no_license
peiffer/usercode
173d69b64e2a4f7082c9009f84336aa7c45f32c5
7558c340d4cda8ec5a5b00aabcf94d5b3591e178
refs/heads/master
2021-01-14T14:27:32.667867
2016-09-06T13:59:05
2016-09-06T13:59:05
57,212,842
0
0
null
2016-04-27T12:47:54
2016-04-27T12:47:54
null
UTF-8
C++
false
false
7,409
cc
matrix.cc
/********************************** Implementation of a simple matrix class Bruce Knuteson 2003 **********************************/ #include "Validation/VstMathUtils/interface/matrix.hh" #include <vector> #include <iostream> #include <iomanip> #include <cmath> #include <cassert> using namespace std; #ifdef __MAKECINT__ #pragma link C++ class vector<double>; #pragma link C++ class vector<vector<double> >; #endif /***** Constructors *****/ matrix::matrix(size_type n, size_type m): data(n) { for(size_type i=0; i<n; i++) data[i] = vector<double>(m,0.); } matrix::matrix(const data_t & _data): data(_data) { } /***** Accessors *****/ matrix::size_type matrix::nrows() const { return data.size(); } matrix::size_type matrix::ncols() const { if(data.empty()) return 0; return data[0].size(); } vector<double> & matrix::operator[](matrix::size_type row) { return data[row]; } const vector<double> & matrix::operator[](matrix::size_type row) const { return data[row]; } /***** Modifiers *****/ void matrix::resize(matrix::size_type n, matrix::size_type m) { if(n<0) n=0; if(m<0) m=0; matrix::size_type n0 = nrows(); matrix::size_type m0 = ncols(); if(n0>n) for(matrix::size_type j=n0-1; j>=n; j--) data.pop_back(); if(n0<n) for(matrix::size_type j=n0; j<n; j++) data.push_back(vector<double>(m0)); //data.resize(n); for(matrix::size_type i=0; i<n; i++) { if(m0>m) for(matrix::size_type j=m0-1; j>=m; j--) data[i].pop_back(); if(m0<m) for(matrix::size_type j=m0; j<m; j++) data[i].push_back(0.); //data[i].resize(m); } } matrix & matrix::operator=(matrix rhs) { this->resize(rhs.nrows(), rhs.ncols()); for(matrix::size_type i=0; i<nrows(); i++) data[i] = rhs.data[i]; return *this; } void matrix::deletecolumn(matrix::size_type n) { for(matrix::size_type i=0; i<this->nrows(); i++) for(matrix::size_type j=n; j<this->ncols()-1; j++) data[i][j] = data[i][j+1]; this->resize(this->nrows(),this->ncols()-1); } void matrix::deleterow(matrix::size_type n) { for(matrix::size_type i=n; i<this->nrows()-1; i++) this->data[i]=this->data[i+1]; this->resize(this->nrows()-1,this->ncols()); } /***** Methods *****/ void matrix::print(std::ostream & fout) { for(matrix::size_type i=0; i<this->nrows(); i++) { for(matrix::size_type j=0; j<this->ncols(); j++) fout << this->data[i][j] << "\t"; fout << endl; } } vector<double> matrix::getEigenvalues() { matrix temp = *this; assert(nrows()==ncols()); // works only when nrows() == ncols() matrix::size_type nvars = nrows(); vector<double> ansEigenvalues(nvars); matrix ansEigenvectors(nvars,nvars); jacobi(temp, nvars, ansEigenvalues, ansEigenvectors); return(ansEigenvalues); } matrix matrix::power(double n) const { if(n==1) return(*this); matrix ans; assert(nrows()==ncols()); // inversion works only when nrows() == ncols() matrix::size_type nvars = this->nrows(); ans.resize(nvars,nvars); matrix temp(nvars, nvars); for(matrix::size_type j=0; j<nvars; j++) for(matrix::size_type k=0; k<nvars; k++) temp[j][k] = this->data[j][k]; vector<double> ansEigenvalues(nvars); matrix ansEigenvectors(nvars,nvars); jacobi(temp, nvars, ansEigenvalues, ansEigenvectors); for(matrix::size_type j=0; j<nvars; j++) for(matrix::size_type k=0; k<nvars; k++) { ans[j][k]=0.; for(matrix::size_type l=0; l<nvars; l++) { ans[j][k]+= ansEigenvectors[j][l]*ansEigenvectors[k][l]* pow(ansEigenvalues[l],n); } } return ans; } double matrix::det() { matrix::size_type nvars = this->nrows(); // inversion works only when nrows() == ncols() matrix temp(nvars, nvars); for(matrix::size_type j=0; j<nvars; j++) for(matrix::size_type k=0; k<nvars; k++) temp[j][k] = this->data[j][k]; vector<double> ansEigenvalues(nvars); matrix ansEigenvectors(nvars,nvars); jacobi(temp, nvars, ansEigenvalues, ansEigenvectors); double ans = 1.; for(matrix::size_type l=0; l<nvars; l++) ans *= ansEigenvalues[l]; return ans; } matrix matrix::safeInverse(double & determinant) { matrix temp = *this; assert(this->ncols()==this->nrows()); if(ncols()==0) { determinant = 1.; return(*this); } matrix::size_type nvars = this->ncols(); vector<double> ansEigenvalues(nvars); matrix ansEigenvectors(nvars,nvars); jacobi(temp, nvars, ansEigenvalues, ansEigenvectors); double maxEigenvalue = 1.; for(matrix::size_type j=0; j<nvars; j++) if(ansEigenvalues[j]>maxEigenvalue) maxEigenvalue = ansEigenvalues[j]; for(matrix::size_type j=0; j<nvars; j++) if(ansEigenvalues[j]<maxEigenvalue*1.e-16) ansEigenvalues[j]=maxEigenvalue*1.e-16; // all eigenvalues should be positive; any negative eigenvalues are assumed to result from roundoff error from zero determinant = 1.; for(matrix::size_type j=0; j<nvars; j++) determinant *= ansEigenvalues[j]; matrix inv = matrix(nvars,nvars); for(matrix::size_type j=0; j<nvars; j++) for(matrix::size_type k=0; k<nvars; k++) { inv[j][k]=0.; for(matrix::size_type l=0; l<nvars; l++) { inv[j][k]+= ansEigenvectors[j][l]*ansEigenvectors[k][l]* pow(ansEigenvalues[l],-1.); } } return(inv); } std::vector< std::vector<double> > matrix::toSTLVector() { return(data); } #define NRANSI #define ROTATE(a,i,j,k,l) g=a[i][j];h=a[k][l];a[i][j]=g-s*(h+g*tau);\ a[k][l]=h+s*(g-h*tau); void jacobi(matrix & a, matrix::size_type n, vector<double> & d, matrix & v) { matrix aa = a; int i; size_t j,iq; double tresh,theta,tau,t,sm,s,h,g,c; vector<double> b(n); vector<double> z(n); for (matrix::size_type ip=0;ip<n;ip++) { for (iq=0;iq<n;iq++) v[ip][iq]=0.0; v[ip][ip]=1.0; } for (matrix::size_type ip=0;ip<n;ip++) { b[ip]=d[ip]=a[ip][ip]; z[ip]=0.0; } int nrot=0; for (i=0;i<50;i++) { sm=0.0; for (matrix::size_type ip=0;ip<n-1;ip++) { for (matrix::size_type iq=ip+1;iq<n;iq++) sm += fabs(a[ip][iq]); } if (sm == 0.0) { return; } if (i < 4) tresh=0.2*sm/(n*n); else tresh=0.0; for (matrix::size_type ip=0;ip<n-1;ip++) { for (matrix::size_type iq=ip+1;iq<n;iq++) { g=100.0*fabs(a[ip][iq]); if (i > 4 && (double)(fabs(d[ip])+g) == (double)fabs(d[ip]) && (double)(fabs(d[iq])+g) == (double)fabs(d[iq])) a[ip][iq]=0.0; else if (fabs(a[ip][iq]) > tresh) { h=d[iq]-d[ip]; if ((double)(fabs(h)+g) == (double)fabs(h)) t=(a[ip][iq])/h; else { theta=0.5*h/(a[ip][iq]); t=1.0/(fabs(theta)+sqrt(1.0+theta*theta)); if (theta < 0.0) t = -t; } c=1.0/sqrt(1+t*t); s=t*c; tau=s/(1.0+c); h=t*a[ip][iq]; z[ip] -= h; z[iq] += h; d[ip] -= h; d[iq] += h; a[ip][iq]=0.0; for (j=0;j<=ip-1;j++) { ROTATE(a,j,ip,j,iq) } for (j=ip+1;j<=iq-1;j++) { ROTATE(a,ip,j,j,iq) } for (j=iq+1;j<n;j++) { ROTATE(a,ip,j,iq,j) } for (j=0;j<n;j++) { ROTATE(v,j,ip,j,iq) } ++(nrot); } } } for (matrix::size_type ip=0;ip<n;ip++) { b[ip] += z[ip]; d[ip]=b[ip]; z[ip]=0.0; } } cout << "Too many iterations in routine jacobi" << endl; cout << "This is the offending matrix:" << endl; aa.print(); exit(1); } #undef ROTATE #undef NRANSI
36a4d91edc255d5ed533963e846f29e7bfc01013
d9c3d703811620b58ad62be1ee30763d0cff859f
/Fade/Fade.ino
17a1616213b710bf1b2705c545f2ab95c379c747
[]
no_license
jackrayner/arduino-projects
114b49ddb1ee1b7426996795dbf396d2af732a55
6d8e6ee05609d25f9405443dee491fdef91aecf7
refs/heads/main
2023-07-13T20:09:17.681110
2021-08-27T00:32:47
2021-08-27T00:32:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
987
ino
Fade.ino
int red = 9; int green = 11; int blue = 10; int brightness = 0; int fadeAmount = 5; void setup() { // declare pin 9 to be an output: pinMode(green, OUTPUT); pinMode(red, OUTPUT); pinMode(blue, OUTPUT); } colours = {red, green, blue, raspberry, cyan, magenta, yellow, white}; void loop() { for colour in colours } void loop() { RGB_color(255, 0, 0); // Red delay(1000); RGB_color(0, 255, 0); // Green delay(1000); RGB_color(0, 0, 255); // Blue delay(1000); RGB_color(255, 255, 125); // Raspberry delay(1000); RGB_color(0, 255, 255); // Cyan delay(1000); RGB_color(255, 0, 255); // Magenta delay(1000); RGB_color(255, 255, 0); // Yellow delay(1000); RGB_color(255, 255, 255); // White delay(1000); } void RGB_color(int red_light_value, int green_light_value, int blue_light_value) { analogWrite(red_light_pin, red_light_value); analogWrite(green_light_pin, green_light_value); analogWrite(blue_light_pin, blue_light_value); }
486319c34fc4434c5a11e98800d1aa54d506d7b0
97b606b776e41d6fe6860df59145736c528ae1a9
/3ds/mesh/mesh3dsobject.h
27e81131d713abb51085e11baea1b602fc7f1099
[]
no_license
MORTAL2000/UniversityRacer
e982423bf61b78e2b7b87adb50ccacc06684fdce
491eec5236a1e3da06b5d4879e7682d53f713c8c
refs/heads/master
2021-04-28T22:04:25.703355
2011-12-13T08:21:52
2011-12-13T08:21:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,286
h
mesh3dsobject.h
#ifndef MESH3DSOBJECT_H #define MESH3DSOBJECT_H #include <map> #include <string> #include <vector> #include "../chunk/chunk.h" struct Mesh3DSVertex { float x , y , z; }; struct Mesh3DSTextureCoord { float u , v; }; struct Mesh3DSFace { int a , b , c; }; struct Mesh3DSMatrix { float m[4][4]; }; /***/ class Mesh3DSObject { public: /***/ Mesh3DSObject(const std::string &nname , Model3DSChunk c); /***/ Mesh3DSObject(const Mesh3DSObject &mesh); /***/ ~Mesh3DSObject(); void operator=(const Mesh3DSObject &mesh); const std::string &Name(); Mesh3DSMatrix Matrix(); // adds last row (0,0,0,1) const std::vector<Mesh3DSVertex> &Vertices(); const std::vector<Mesh3DSTextureCoord> &TextureCoords(); const std::vector<Mesh3DSFace> &Faces(); const std::map<std::string , std::vector<int> > &Materials(); private: void ParseLocalCoordinateSystem(Model3DSChunk c); void ParseVertices(Model3DSChunk c); void ParseTextureCoords(Model3DSChunk c); void ParseFaces(Model3DSChunk c); void ParseFacesMaterials(Model3DSChunk c); std::string name; Mesh3DSMatrix matrix; std::vector<Mesh3DSVertex> vertices; std::vector<Mesh3DSTextureCoord> texturecoords; std::vector<Mesh3DSFace> faces; std::map<std::string , std::vector<int> > material_faces; }; #endif
88f9933f9546b43a666633a519305eb6bade1ba0
b3a693cb2c15f95133876f74a640ec585b7a0f62
/CB/LPU/Session10/dnf.cpp
0270abd7e8275ebeaf97c035f529bb8f598ddf67
[]
no_license
singhsanket143/CppCompetitiveRepository
1a7651553ef69fa407d85d789c7c342f9a4bd8e9
6e69599ff57e3c9dce4c4d35e60c744f8837c516
refs/heads/master
2022-06-23T01:42:38.811581
2022-06-16T13:17:15
2022-06-16T13:17:15
138,698,312
349
148
null
2021-03-06T18:46:58
2018-06-26T07:06:16
C++
UTF-8
C++
false
false
498
cpp
dnf.cpp
#include <iostream> using namespace std; void dnf(int *arr, int n) { int start = 0, mid = 0, end = n-1; while(mid <= end) { if(arr[mid]==1) { mid++; } else if(arr[mid] == 2) { swap(arr[mid], arr[end]); end--; } else { swap(arr[start], arr[mid]); start++; mid++; } } } int main(int argc, char const *argv[]) { int n; cin>>n; int *arr = new int[n]; for(int i=0;i<n;i++) { cin>>arr[i]; } dnf(arr, n); for(int i=0;i<n;i++) { cout<<arr[i]<<" "; } return 0; }
f6a651826e8bd5760d86588b748405cd90f7cf49
b0126a613e3d547adb00df65a137a37ace60a92f
/project/code/model/one element of db/source/Publication.cpp
7bb6089714c2b6eccad994c4a438ea4cb1a8309d
[]
no_license
AJIOB/uni_courseWork_3
df000bd349528e0ed4bd30b8113c14efe1dcbeeb
de921039da982b44cf978a8f397909f7c752f121
refs/heads/master
2021-01-17T09:03:18.139441
2017-06-21T09:41:05
2017-06-21T09:41:05
83,974,479
0
0
null
null
null
null
UTF-8
C++
false
false
8,492
cpp
Publication.cpp
#include "../headers/Publication.h" #include "../../dbs/headers/PublicationDBClass.h" std::ostream& OneElementOf::operator<<(std::ostream& s, const Publication& that) { s << "ISBN: " << that.cl_ISBN.GetAsString() << std::endl; s << "Название издания: " << that.cl_name << std::endl; s << "Авторы: " << that.cl_authors << std::endl; s << "Год издания: " << that.cl_yearOfPublication <<std::endl; auto parent = that.GetConnectedCountryDB(); if (parent) { s << (parent->GetInfo(that.cl_ISBN)); } if (that.cl_userTags.size() > 0) { s << "Пользовательские метки:" <<std::endl; s << that.cl_userTags; } /* int index = that.GetConnectedCopiesDB()->FindByISBN(that.cl_ISBN); if (index < 0) { s << "В библиотеке отсутствуют экземпляры данной книги" << std::endl; } else { s << that.GetConnectedCopiesDB()[0][index] << std::endl; }*/ return s; } std::istream& OneElementOf::operator>>(std::istream& s, Publication& that) { do { OutputConsole("Введите ISBN:"); Stream::Input(that.cl_ISBN); if (that.GetConnectedCountryDB()) { that.GetConnectedCountryDB()->AddByISBN(that.cl_ISBN); } if (!(that.cl_parent) || (that.cl_parent->FindByISBN(that.cl_ISBN) < 0)) { break; } if (Stream::GetOnlyYN("Данное издание уже имеется. Отменить ввод?") == 'Y') { throw RepeatException(); } } while (true); OutputConsole("Введите название издания:"); Stream::Input(that.cl_name); OutputConsole("Введите авторов:"); Stream::Input(that.cl_authors); OutputConsole("Введите год издания:"); Stream::Input(that.cl_yearOfPublication); return s; } void OneElementOf::Publication::BWrite(const bString& bInfo, strPos& it) { Publication buffer(cl_parent); buffer.cl_ISBN = ISBNClass(bInfo, it); buffer.cl_name = BStringIO::ReadBInfo<std::string>(bInfo, it); buffer.cl_authors = BStringIO::ReadBInfo<std::string>(bInfo, it); buffer.cl_yearOfPublication = BStringIO::ReadBInfo<uli>(bInfo, it); buffer.cl_userTags.BWrite(bInfo, it); (*this) = buffer; } CountryDBClass* OneElementOf::Publication::GetConnectedCountryDB() const { if (!cl_parent) { return nullptr; } return (cl_parent->cl_connected_CountryDB); } /* CopiesDBClass* OneElementOf::Publication::GetConnectedCopiesDB() const { return cl_parent->cl_connected_CopiesDB; }*/ OneElementOf::Publication::Publication(void* parent) { cl_yearOfPublication = 0; cl_parent = reinterpret_cast<PublicationDBClass*> (parent); //cl_countryISBNPart = -1; } OneElementOf::Publication::Publication(const Publication& that) { (*this) = that; } OneElementOf::Publication::Publication(const bString& bInfo, strPos& it, void* parent) { cl_parent = reinterpret_cast<PublicationDBClass*> (parent); BWrite(bInfo, it); } OneElementOf::Publication::~Publication() { } OneElementOf::Publication& OneElementOf::Publication::operator=(const Publication& that) { cl_ISBN = that.cl_ISBN; cl_name = that.cl_name; cl_authors = that.cl_authors; cl_yearOfPublication = that.cl_yearOfPublication; cl_userTags = that.cl_userTags; cl_parent = that.cl_parent; return (*this); } ISBNClass OneElementOf::Publication::GetISBN() const { return cl_ISBN; } std::string OneElementOf::Publication::GetName() const { return cl_name; } std::string OneElementOf::Publication::GetAuthor() const { return cl_authors; } uli OneElementOf::Publication::GetYearOfPublication() const { return cl_yearOfPublication; } MyContainer<std::string> OneElementOf::Publication::GetUserTags() const { return cl_userTags; } bString OneElementOf::Publication::BRead() const { return (cl_ISBN.BRead() + BStringIO::MakeBString(cl_name) + BStringIO::MakeBString(cl_authors) + BStringIO::MakeBString(cl_yearOfPublication) + cl_userTags.BRead()); } bool OneElementOf::Publication::EqualByISBN(const Publication& that) const { return (cl_ISBN == that.cl_ISBN); } bool OneElementOf::Publication::operator==(const Publication& that) const { return EqualByISBN(that); } bool OneElementOf::Publication::operator<(const Publication& that) const { return (cl_ISBN < that.cl_ISBN); } bool OneElementOf::Publication::operator>(const Publication& that) const { return (cl_ISBN > that.cl_ISBN); } bool OneElementOf::Publication::InputNewISBN() { Publication buffer(*this); do { do { OutputConsole("Введите новое название издания."); Stream::Input(buffer.cl_ISBN); if (cl_parent->FindByISBN(buffer.cl_ISBN) < 0) { break; } OutputConsole("Извините, введенный вами номер уже присутствует или вы ввели старый ISBN номер. Пожалуйста, повторите ввод."); } while (true); OutputConsole("Измененный элемент:"); std::cout << buffer; } while (Stream::GetOnlyYN("Всё ли введено правильно?") == 'N'); (*this) = buffer; return true; } bool OneElementOf::Publication::InputNewName() { Publication buffer(*this); do { OutputConsole("Введите новое название издания."); Stream::Input(buffer.cl_name); OutputConsole("Измененный элемент:"); std::cout << buffer; } while (Stream::GetOnlyYN("Всё ли введено правильно?") == 'N'); (*this) = buffer; return true; } bool OneElementOf::Publication::InputNewAuthor() { Publication buffer(*this); do { OutputConsole("Введите новых авторов."); Stream::Input(buffer.cl_authors); OutputConsole("Измененный элемент:"); std::cout << buffer; } while (Stream::GetOnlyYN("Всё ли введено правильно?") == 'N'); (*this) = buffer; return true; } bool OneElementOf::Publication::InputNewYear() { Publication buffer(*this); do { OutputConsole("Введите новый год издания."); Stream::Input(buffer.cl_yearOfPublication); OutputConsole("Измененный элемент:"); std::cout << buffer; } while (Stream::GetOnlyYN("Всё ли введено правильно?") == 'N'); (*this) = buffer; return true; } bool OneElementOf::Publication::WorkWithTags() { return cl_userTags.OperationsWithElements(); } bool OneElementOf::Publication::UpdateMe() { ClearConsole(); bool isUpdated = false; do { std::cout << "Выберите, пожалуйста, что вы хотите сделать:" << std::endl; std::cout << "1) Просмотреть текущий элемент" << std::endl; std::cout << "2) Изменить ISBN издания" << std::endl; std::cout << "3) Изменить название издания" << std::endl; std::cout << "4) Изменить авторов" << std::endl; std::cout << "5) Изменить год издания" << std::endl; std::cout << "6) Поработать с пользовательскими метками" << std::endl; std::cout << "0) Назад" << std::endl; std::cout << "Пожалуйста, сделайте свой выбор" << std::endl; auto k = Stream::Get(); switch (k) { case '0': return isUpdated; case '1': std::cout << *this << std::endl; break; case '2': if (this->InputNewISBN()) isUpdated = true; break; case '3': if (this->InputNewName()) isUpdated = true; break; case '4': if (this->InputNewAuthor()) isUpdated = true; break; case '5': if (this->InputNewYear()) isUpdated = true; break; case '6': if (this->WorkWithTags()) isUpdated = true; break; default: OutputWarning("Извините, такого варианта не существует. Пожалуйста, повторите выбор"); } PauseConsole(); ClearConsole(); } while (true); } /* void OneElementOf::Publication::InputElem(bool ISBNIsGettedByParametr, const ISBNClass ISBN) { if (!ISBNIsGettedByParametr) { OutputConsole("Введите ISBN:"); Stream::Input(this->cl_ISBN); } else { cl_ISBN = ISBN; } this->GetConnectedCountryDB()->AddByISBN(this->cl_ISBN); OutputConsole("Введите название издания:"); Stream::Input(this->cl_name); OutputConsole("Введите авторов:"); Stream::Input(this->cl_authors); OutputConsole("Введите год издания:"); Stream::Input(this->cl_yearOfPublication); } */
2e7e9f12b68000ec56552041f5c89b7c5543021b
35e4cd883280f94e2aa4be0be9b574292155c8b6
/SearchRoute.cpp
c335d5678e95a3c9d2d34404d7ac574bc681c6b3
[]
no_license
Harryx2019/Bus-Management-System
c40955005ff904d655042b1be67b4ee44da30ee8
467bf5ed5ab5c894b1ea42057cce6084b422ada2
refs/heads/master
2022-11-12T05:27:30.641076
2020-07-01T07:21:39
2020-07-01T07:21:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,197
cpp
SearchRoute.cpp
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include "model.h" #include "Stack.h"//广度优先搜素辅助栈结构 #include "LoadMapData.h" #include "SearchBus.h" #include "SearchStation.h" #include "SearchRoute.h" int SearchRoute(BusMap &Map) { system("cls"); char *startStation=(char *)malloc(sizeof(char)*20); char *endStation=(char *)malloc(sizeof(char)*20); int nStartStation,nEndStation; printf("\n===== 查询路线信息 =====\n"); printf("提示:1.查询路线信息起始站点和终止站点必须为已存在站点\n"); printf(" 2.查询路线信息会显示从起始站点到终止站点只用换乘一次的路线\n\n"); printf("请输入要查询的路线起始站点:"); scanf("%s",startStation); nStartStation=FindStation(Map,startStation); if(nStartStation==NONE) { printf("站点[%s]不存在!\n",startStation); return NONE; } printf("请输入要查询的路线目标站点:"); scanf("%s",endStation); nEndStation=FindStation(Map,endStation); if(nEndStation==NONE) { printf("站点[%s]不存在!\n",endStation); return NONE; } if(QueryRoute(Map,nStartStation,nEndStation)==NONE) return NONE; printf("输入任何键退出[查询路线信息]功能\n"); getch(); system("cls"); return 1; } int QueryRoute(BusMap &Map,int nStartStation,int nEndStation) { //初始化path 路径数组 //path结构为 bus-station-bus-station int i; int initialPathNum=3,initialPathStationNum=20; int **path=(int**)malloc(sizeof(int*)*initialPathNum); int *pathStationNum=(int*)malloc(sizeof(int)*initialPathNum); for(i=0; i<initialPathNum; i++) path[i]=(int*)malloc(sizeof(int)*initialPathStationNum*2); path[0][0]=-1; path[0][1]=nStartStation; //初始化站点栈辅助数组 int *stationInStack=(int*)malloc(sizeof(int)*Map.station_num); for(i=0; i<Map.station_num; i++) stationInStack[i]=0; //初始化route status Station *pStation; Route *pRoute; for(i=0; i<Map.station_num; i++) { pStation=&Map.stations[i]; pRoute=pStation->routes; while(pRoute!=NULL) { pRoute->staus=0; pRoute=pRoute->next; } } //初始化栈结构 Stack stationStack,busStack; InitStack(stationStack); InitStack(busStack); //nStartStation入栈 PushStack(stationStack,nStartStation); PushStack(busStack,-1); stationInStack[nStartStation]=1; int j,k,nStation; int flag=0,pathNum=0; while(EmptyStack(stationStack)==false) { nStation=GetTopStack(stationStack);//栈顶元素出栈 if(nStation==nEndStation)//找到一条路径 { if(flag==0) { printf("\n[%s]-[%s]之间存在路线\n",Map.stations[nStartStation].station,Map.stations[nEndStation].station); flag=1; } pathNum++; if(pathNum>initialPathNum)//扩容 { initialPathNum+=2; path=(int**)realloc(path,sizeof(int*)*initialPathNum); for(i=pathNum-1; i<initialPathNum; i++) { path[i]=(int*)malloc(sizeof(int)*initialPathStationNum*2); path[i][0]=-1; path[i][1]=nStartStation; } pathStationNum=(int*)realloc(pathStationNum,sizeof(int)*initialPathNum); } //将栈内站点依次输入path[pathNum]数组 pathStationNum[pathNum-1]=GetStackNum(stationStack); if(pathStationNum[pathNum-1]>initialPathStationNum) path[pathNum-1]=(int*)realloc(path[pathNum-1],sizeof(int)*pathStationNum[pathNum-1]*2); i=pathNum-1; path[i][0]=-1; path[i][1]=nStartStation; for(k=1,j=2; k<pathStationNum[pathNum-1]; k++,j+=2) { path[i][j]=GetStackElement(busStack,k); path[i][j+1]=GetStackElement(stationStack,k); } //nEndStation出栈 PopStack(stationStack); PopStack(busStack); stationInStack[nEndStation]=0; //更新route status updateRouteStatus(Map,nEndStation,stationInStack); } else { pStation=&Map.stations[nStation]; pRoute=pStation->routes; while(pRoute!=NULL) { i=pRoute->station; if(stationInStack[i]==0 && pRoute->staus==0) { //入栈 PushStack(stationStack,i); PushStack(busStack,pRoute->bus); stationInStack[i]=1; pRoute->staus=1; break; } pRoute=pRoute->next; } if(pRoute==NULL)//该节点没有符合要求的后续节点 { //nStation出栈 PopStack(stationStack); PopStack(busStack); stationInStack[nStation]=0; updateRouteStatus(Map,nStation,stationInStack); } } } if(flag==1) PrintRoute(Map,nStartStation,nEndStation,pathNum,pathStationNum,path); else if(flag==0) { printf("[%s]-[%s]之间不存在路线!\n\n",Map.stations[nStartStation].station,Map.stations[nEndStation].station); return NONE; } return 1; } void PrintRoute(BusMap Map,int nStartStation,int nEndStation,int pathNum,int *pathStationNum,int **path) { printf("\n--------------------------------------\n"); int i,j,k; int num=0;//只需换乘一次路线数 int *transferBusOnceRoutes=(int*)malloc(sizeof(int)*(pathNum)); int inBus=-1,flag;//flag为换乘标志 for(i=0; i<pathNum; i++) { inBus=path[i][2]; flag=0; for(k=1,j=2; k<pathStationNum[i]; k++,j+=2) { if(path[i][j]!=inBus)//判断换乘次数 { if(flag==1)//已经换乘一次 { transferBusOnceRoutes[i]=-1; flag=2; break; } else { inBus=path[i][j]; flag=1; } } } if(flag!=2)//至多换乘一次 { transferBusOnceRoutes[i]=i; num++; } } char *start=Map.stations[nStartStation].station; char *end=Map.stations[nEndStation].station; printf("从[%s]-[%s] 共找到 [%d]条至多换乘一次的线路:\n",start,end,num); int traverserNum=1; for(i=0; i<pathNum; i++) { if(transferBusOnceRoutes[i]!=-1) { printf("\n--------------------------------------\n\n"); inBus=path[i][2]; printf("路线[%d]: %s----[乘坐:%s]----",traverserNum,start,Map.buses[inBus].name); traverserNum++; for(k=1,j=2; k<pathStationNum[i]; k++,j+=2) { if(path[i][j]!=inBus) { inBus=path[i][j]; printf("----[换乘:%s]----",Map.buses[inBus].name); } printf("->%s",Map.stations[path[i][j+1]].station); } printf("\n"); } } printf("\n--------------------------------------\n\n"); } void updateRouteStatus(BusMap &Map,int station,int *stationInStack) { Station *pStation=&Map.stations[station]; Route *pRoute=pStation->routes; while(pRoute!=NULL) { if(stationInStack[pRoute->station]==0) pRoute->staus=0; pRoute=pRoute->next; } int i; for(i=0; i<Map.station_num && i!=station; i++) { pStation=&Map.stations[i]; pRoute=pStation->routes; while(pRoute!=NULL) { if(pRoute->station==station && stationInStack[i]==0) pRoute->staus=0; pRoute=pRoute->next; } } }
cbfd772305477ae0018af25cd34ccdeff3117f37
8034a82dfb0987d22a84bafbb101e026481bb23a
/src/win/WebviewContainer.cpp
abaddf4427493f4766eb925769854b64e8ceef04
[]
no_license
PatchLion/simple_share_image_library
a1a5100c08b81d382668531bacd64a8530767263
48804707188e3937379a143866a3a954111749d4
refs/heads/master
2021-06-11T10:16:42.994122
2017-01-12T12:29:50
2017-01-12T12:29:50
47,523,680
0
0
null
null
null
null
UTF-8
C++
false
false
3,076
cpp
WebviewContainer.cpp
#include "WebviewContainer.h" #include <QtCore/QTimer> #include "SharePublicFuncDefine.h" #include "ShareMacroDefine.h" #include <QtNetwork/QNetworkAccessManager> #include <QtWebKitWidgets/QWebPage> CWebviewContainer::CWebviewContainer(QWidget* pParent) : QWebView(pParent) { connect(this, &QWebView::loadFinished, this, &CWebviewContainer::onLoadFinished); connect(this, &QWebView::loadProgress, this, &CWebviewContainer::onPageLoadProcess); qRegisterMetaType<ShareLibrary::EPageLoadResult>("ShareLibrary::EPageLoadResult"); setTimeOutInterval(DEFAULT_TIMEOUT_INTERVAL); m_loadTimer.setSingleShot(true); connect(&m_loadTimer, &QTimer::timeout, this, &CWebviewContainer::onLoadTimeOut); } CWebviewContainer::~CWebviewContainer() { disconnect(this); } void CWebviewContainer::loadUrl(const QString& strUrl) { QUrl url(strUrl); /* if (url.isValid()) {*/ QNetworkRequest request(url); if ("HTTPS" == url.scheme().toUpper()) { ShareLibrary::createSSLRequest(request, url); } else { request.setUrl(url); } startLoadTimer(); load(request); /* } else { onPageLoadFinished(ShareLibrary::Result_InvaildURL); }*/ } QString CWebviewContainer::urlString() const { return url().isEmpty() ? "" : url().toDisplayString(); } void CWebviewContainer::clearCookie() { if (page() && page()->networkAccessManager()) { page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar); } } QString CWebviewContainer::pagePlainText() const { if (page() && page()->currentFrame()) { return page()->currentFrame()->toHtml(); } return ""; } void CWebviewContainer::onLoadFinished(bool bOK) { if (bOK) { onPageLoadFinished(ShareLibrary::Result_Success); } /* else { onPageLoadFinished(ShareLibrary::Result_OtherError); }*/ if (page() && page()->mainFrame()) { page()->mainFrame()->setScrollBarValue(Qt::Vertical, page()->mainFrame()->scrollBarMinimum(Qt::Vertical)); page()->mainFrame()->setScrollBarValue(Qt::Horizontal, page()->mainFrame()->scrollBarMinimum(Qt::Horizontal)); //page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); //page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); } } void CWebviewContainer::onSslErrors( QNetworkReply *reply, const QList<QSslError> &errors ) { //onPageLoadFinished(ShareLibrary::Result_SSLError); for (int nIndex = 0; nIndex < errors.size(); nIndex++) { qDebug() << errors[nIndex].errorString(); } reply->ignoreSslErrors(errors); } void CWebviewContainer::onPageLoadFinished(ShareLibrary::EPageLoadResult eResult) { stopLoadTimer(); emit pageLoadFinished(eResult); } void CWebviewContainer::startLoadTimer() { if (m_loadTimer.isActive()) { m_loadTimer.stop(); } m_loadTimer.start(); } void CWebviewContainer::stopLoadTimer() { if (m_loadTimer.isActive()) { m_loadTimer.stop(); } } void CWebviewContainer::onPageLoadProcess(int process) { emit pageLoadProcess(process); } void CWebviewContainer::onLoadTimeOut() { stopLoadTimer(); onPageLoadFinished(ShareLibrary::Result_TimeOut); }
d55cc156533bdcb26ff01cb31c4cb99fab2748b0
6e57bdc0a6cd18f9f546559875256c4570256c45
/packages/apps/Bluetooth/jni/IUserManager.h
2164d9aa5e53d0cef8a3e7552bc33063fe7e78b1
[]
no_license
dongdong331/test
969d6e945f7f21a5819cd1d5f536d12c552e825c
2ba7bcea4f9d9715cbb1c4e69271f7b185a0786e
refs/heads/master
2023-03-07T06:56:55.210503
2020-12-07T04:15:33
2020-12-07T04:15:33
134,398,935
2
1
null
2022-11-21T07:53:41
2018-05-22T10:26:42
null
UTF-8
C++
false
false
1,310
h
IUserManager.h
/* * Copyright (C) 2015 The Android Open Source Project * * 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. */ #ifndef IUSERMANAGER_H_ #define IUSERMANAGER_H_ #include <binder/IInterface.h> #include <binder/Parcel.h> #include <inttypes.h> #include <utils/Errors.h> #include <utils/Vector.h> namespace android { /* * Communication channel to UserManager */ class IUserManager : public IInterface { public: // must be kept in sync with IUserManager.aidl enum { GET_CREDENTIAL_OWNER_PROFILE = IBinder::FIRST_CALL_TRANSACTION + 0, GET_PROFILE_PARENT_ID, }; virtual int32_t getCredentialOwnerProfile(int32_t user_id) = 0; virtual int32_t getProfileParentId(int32_t user_handle) = 0; DECLARE_META_INTERFACE(UserManager); }; }; // namespace android #endif // IUSERMANAGER_H_
fd124202d992ca6bf56453fbf1f99632359601ce
48b317e77e7f39d192a2bfd4958595976897439d
/code/Game/World/MessageDispatcher.cpp
b0ce2b05f0cccad2dadcfe10e7e797b013d996f4
[]
no_license
Syrdni/AiBattle
9292625e7608c2801d1239aaf6eff4e85c5832ab
859eb2e1ddb214411a782cd6e255e82f61a7a803
refs/heads/master
2020-07-18T19:51:20.464896
2019-04-03T08:22:55
2019-04-03T08:22:55
206,303,058
0
0
null
null
null
null
UTF-8
C++
false
false
692
cpp
MessageDispatcher.cpp
#include "MessageDispatcher.h" void MessageDispatcher::OnLoad() { localTick = 0; } void MessageDispatcher::DispatchMessage(const Ptr<Entity>& receiver, const Ptr<Message>& message, int delay) { if (delay <= 0) { receiver->OnReceiveMessage(message); } else { MessageContainer msgC; msgC.message = message; msgC.receiver = receiver; msgC.timeToSend = localTick + delay * EntityManager::TickRate; this->pending.Add(msgC); } } void MessageDispatcher::FixedUpdate() { localTick++; for (int i = 0; i < pending.Size(); i++) { auto& item = pending[i]; if (item.timeToSend <= localTick) { item.receiver->OnReceiveMessage(item.message); pending.Erase(i); } } }
98eadef8d6931398e6d74f49a3c20c7d297ae190
89a08cabcf3e87f0a0946597d94b8e5129ccb1ef
/MediaCaptureReader/MediaCaptureReader/MediaCaptureReader.Shared/WinRTBuffer.h
7b25bbeb6d28b402a79a9bc314f901b6e1efd201
[ "Apache-2.0" ]
permissive
AcropolisA/MediaReader
fda0baa9957a53c2b573e57757e27c40b2490165
07262c20d45b351f4a7c29919f6010b4950b7b16
refs/heads/master
2021-06-05T23:31:17.823575
2016-09-12T12:36:46
2016-09-12T12:36:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,037
h
WinRTBuffer.h
#pragma once namespace MediaCaptureReader { class WinRTBuffer WrlSealed : public MW::RuntimeClass < MW::RuntimeClassFlags<MW::RuntimeClassType::WinRtClassicComMix>, AWSS::IBuffer, MW::CloakedIid<WSS::IBufferByteAccess>, MW::FtmBase // if cross-process support is needed, replace with IMarshal from RoGetBufferMarshaler() > { InspectableClass(L"MediaCaptureReader.WinRTBuffer", TrustLevel::BaseTrust); public: WinRTBuffer( _In_reads_(_Inexpressible_) unsigned char *buffer, _In_ unsigned long capacity ) : _buffer(buffer) , _capacity(capacity) { } void Close() { auto lock = _lock.LockExclusive(); _buffer = nullptr; _capacity = 0; } // // IBuffer // IFACEMETHOD(get_Capacity)(_Out_ unsigned int *pValue) override { auto lock = _lock.LockShared(); *pValue = _capacity; return S_OK; } IFACEMETHOD(get_Length)(_Out_ unsigned int *pValue) override { auto lock = _lock.LockShared(); *pValue = _capacity; return S_OK; } IFACEMETHOD(put_Length)(_In_ unsigned int value) override { return OriginateError(E_ACCESSDENIED); } // // IBufferByteAccess // IFACEMETHOD(Buffer)(_Outptr_result_buffer_(_Inexpressible_("size given by different API")) unsigned char **ppValue) override { auto lock = _lock.LockShared(); *ppValue = nullptr; if (_buffer == nullptr) { return OriginateError(RO_E_CLOSED); } *ppValue = _buffer; return S_OK; } private: virtual ~WinRTBuffer() { } unsigned char *_buffer; unsigned long _capacity; mutable MWW::SRWLock _lock; }; }
0af25b4efc2a54e804401fcb213e2e21def5c045
77affc8438ff3dc90b2b93e8dd6e965f9879e4a8
/asg4/src/env/stp_env.hpp
e494b7ffe9b309a2713948d3a75b74e0c17146cd
[]
no_license
YouruiGuo/search-C
61b37a9825c3e3a0144fedd5bed3b940799c5a93
3b6103cf90ef7875407ada024f146e10ff6fcf07
refs/heads/master
2020-04-27T18:33:46.137888
2019-04-18T17:06:09
2019-04-18T17:06:09
174,576,738
0
0
null
null
null
null
UTF-8
C++
false
false
7,215
hpp
stp_env.hpp
// // stp_env.hpp // search-C // // Created by Yourui Guo on 2019-03-08. // Copyright © 2019 Yourui Guo. All rights reserved. // #ifndef stp_env_h #define stp_env_h #include <iostream> #include <algorithm> #include <vector> #include <string> #include <fstream> #include <sstream> #include <iterator> #include <map> #include "state.hpp" using namespace std; /* class Action { private: int action; public: Action(int a); ~Action(); int getAction(); void setAction(int a); }; Action::Action(int a) { action = a; } Action::~Action(){} int Action::getAction() { return action; } void Action::setAction(int a) { action = a; } */ class Stp_env { private: unsigned int size; State start_state; State goal_state; //std::vector<int> aacs, issuccess, statehash, empty; public: std::map<unsigned long long, int> hashtable; std::vector<StateInfo> allStates; Stp_env(); Stp_env(State s, State g); ~Stp_env(); bool isSuccess(State st); int getEmpty(State st); bool isRepeat(Action prev, Action curr); unsigned long long getStateHash(State st); void getActions(State st, std::vector<Action> *actions); int applyActionCopy(Action a, State s); void applyAction(Action a, State *s); void undoAction(Action a, State *s); int cost(State prev, State curr); unsigned int getSize(); int getHashIndex(unsigned long long i); State getStart(); State getGoal(); State applyActionBFS(Action a, State st); void setStart(State s); }; Stp_env::Stp_env(){} Stp_env::~Stp_env(){} Stp_env::Stp_env(State s, State g) { size = 4; start_state = s; goal_state = g; //StateInfo start = StateInfo(s); //StateInfo goal = StateInfo(g); allStates.push_back(s); unsigned long long svalue = getStateHash(s); hashtable[svalue] = 0; allStates.push_back(g); unsigned long long gvalue = getStateHash(g); hashtable[gvalue] = 1; } void Stp_env::setStart(State s) { start_state = s; } unsigned int Stp_env::getSize() { return size; } State Stp_env::getStart() { return start_state; } State Stp_env::getGoal() { return goal_state; } int Stp_env::getHashIndex(unsigned long long i) { return hashtable[i]; } bool Stp_env::isSuccess(State st) { std::vector<int> issuccess = st.getState(); for (std::vector<int>::size_type i = 0; i < size*size; ++i) { // cout << issuccess[i] << ' '; if (issuccess[i] != (int)i) { return false; } } // cout << endl; return true; } bool Stp_env::isRepeat(Action prev, Action curr) { if (abs(prev.getAction() - curr.getAction()) == 2) { return true; } return false; } unsigned long long Stp_env::getStateHash(State st) { std::vector<int> statehash = st.getState(); unsigned long long value = 0; for (std::vector<int>::size_type i = 0; i < size*size; ++i) { value = value << 4; if (statehash[i] != -1) { value += statehash[i]; } } return value; } int Stp_env::getEmpty(State st) { std::vector<int> empty = st.getState(); for (std::vector<int>::size_type i = 0; i < size*size; ++i) { if (empty[i] == 0) { return (int)i; } } return -1; } void Stp_env::getActions(State st, std::vector<Action> *actions) { //const std::vector<int> &s = st.getState(); // std::vector<Action> actions; actions->clear(); int empty = getEmpty(st); int row = (int)(empty/size); int col = (int)(empty%size); if (row == 0) actions->push_back(Action(2)); else if (row == (int)size-1) actions->push_back(Action(0)); else{ actions->push_back(Action(0)); actions->push_back(Action(2)); } if (col == 0) actions->push_back(Action(1)); else if (col == (int)size-1) actions->push_back(Action(3)); else { actions->push_back(Action(1)); actions->push_back(Action(3)); } } int Stp_env::applyActionCopy(Action a, State st) { std::vector<int> aacs = st.getState(); int empty = getEmpty(st); int row = (int)(empty/size); int col = (int)(empty%size); if(a.getAction() == 0) { aacs[row*size+col] = aacs[(row-1)*size+col]; aacs[(row-1)*size+col] = 0; } else if (a.getAction() == 1) { aacs[row*size+col] = aacs[row*size+col+1]; aacs[row*size+col+1] = 0; } else if (a.getAction() == 2) { aacs[row*size+col] = aacs[(row+1)*size+col]; aacs[(row+1)*size+col] = 0; } else if (a.getAction() == 3) { aacs[row*size+col] = aacs[row*size+col-1]; aacs[row*size+col-1] = 0; } State new_st = State(aacs); unsigned long long hv = getStateHash(new_st); allStates.push_back(StateInfo(new_st)); hashtable[hv] = (int)allStates.size()-1; return hashtable[hv]; } State Stp_env::applyActionBFS(Action a, State st) { std::vector<int> aacs = st.getState(); int empty = getEmpty(st); int row = (int)(empty/size); int col = (int)(empty%size); if(a.getAction() == 0) { aacs[row*size+col] = aacs[(row-1)*size+col]; aacs[(row-1)*size+col] = 0; } else if (a.getAction() == 1) { aacs[row*size+col] = aacs[row*size+col+1]; aacs[row*size+col+1] = 0; } else if (a.getAction() == 2) { aacs[row*size+col] = aacs[(row+1)*size+col]; aacs[(row+1)*size+col] = 0; } else if (a.getAction() == 3) { aacs[row*size+col] = aacs[row*size+col-1]; aacs[row*size+col-1] = 0; } return State(aacs); } void Stp_env::applyAction(Action a, State *st) {//// std::vector<int> aacs = st->getState(); int empty = getEmpty(*st); int row = (int)(empty/size); int col = (int)(empty%size); if(a.getAction() == 0) { aacs[row*size+col] = aacs[(row-1)*size+col]; aacs[(row-1)*size+col] = 0; } else if (a.getAction() == 1) { aacs[row*size+col] = aacs[row*size+col+1]; aacs[row*size+col+1] = 0; } else if (a.getAction() == 2) { aacs[row*size+col] = aacs[(row+1)*size+col]; aacs[(row+1)*size+col] = 0; } else if (a.getAction() == 3) { aacs[row*size+col] = aacs[row*size+col-1]; aacs[row*size+col-1] = 0; } st->setState(aacs); } void Stp_env::undoAction(Action a, State *st) { std::vector<int> aacs = st->getState(); int empty = getEmpty(*st); int row = (int)(empty/size); int col = (int)(empty%size); if(a.getAction() == 0) { // down aacs[row*size+col] = aacs[(row+1)*size+col]; aacs[(row+1)*size+col] = 0; } else if (a.getAction() == 1) { // left aacs[row*size+col] = aacs[row*size+col-1]; aacs[row*size+col-1] = 0; } else if (a.getAction() == 2) { // up aacs[row*size+col] = aacs[(row-1)*size+col]; aacs[(row-1)*size+col] = 0; } else if (a.getAction() == 3) { // right aacs[row*size+col] = aacs[row*size+col+1]; aacs[row*size+col+1] = 0; } st->setState(aacs); } int Stp_env::cost(State prev, State curr) { return 1; } #endif /* stp_env_h */
8350d43573c7bd78d276e1e1e2b92f89d30c9f09
251aa1249861d13ed6a5bbf3920e1580cf6fcb15
/sticher/MainForm.h
5dedecadc1d5ad8ba07de8219a8725de7d6cd01b
[]
no_license
rodrigomas/autostitcher
98071ff37013e433e03c3f884fde817fc4d229ed
e6e0b33c2fd964fc1c2d3e6e3434b1c4cd60d4eb
refs/heads/master
2021-01-01T20:14:21.857137
2013-05-07T17:55:51
2013-05-07T17:55:51
98,795,903
0
0
null
null
null
null
UTF-8
C++
false
false
24,413
h
MainForm.h
#pragma once #include <opencv2/stitching/stitcher.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> #include <fstream> #include "Utils.h" #include "ProgressDialog.h" #using <mscorlib.dll> namespace sticher { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::IO; using namespace System::Drawing; /// <summary> /// Summary for MainForm /// </summary> public ref class MainForm : public System::Windows::Forms::Form { public: MainForm(void) { InitializeComponent(); // //TODO: Add the constructor code here // MaxFrame = Int32::MaxValue; } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~MainForm() { if (components) { delete components; } } private: System::Windows::Forms::Button^ AddSeq; protected: private: System::Windows::Forms::Button^ RemSeq; private: System::Windows::Forms::Button^ Clear; private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::ListView^ ItensBox; private: System::Windows::Forms::ColumnHeader^ PathHeader; private: System::Windows::Forms::ColumnHeader^ CntHeader; private: System::Windows::Forms::GroupBox^ groupBox1; private: System::Windows::Forms::CheckBox^ Undistort; private: System::Windows::Forms::CheckBox^ Stabilize; private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::NumericUpDown^ FrameID; private: System::Windows::Forms::GroupBox^ groupBox2; private: System::Windows::Forms::Label^ label3; private: System::Windows::Forms::ComboBox^ VideoFormat; private: System::Windows::Forms::CheckBox^ MotionVideo; private: System::Windows::Forms::CheckBox^ ExportVideo; private: System::Windows::Forms::GroupBox^ groupBox3; private: System::Windows::Forms::TextBox^ textBox2; private: System::Windows::Forms::Label^ label5; private: System::Windows::Forms::Label^ label4; private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Button^ Export; private: System::Windows::Forms::Button^ About; private: System::ComponentModel::BackgroundWorker^ ExportWorker; private: System::Windows::Forms::OpenFileDialog^ OpenDialog; private: System::Windows::Forms::SaveFileDialog^ SaveDialog; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; int MaxFrame; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->AddSeq = (gcnew System::Windows::Forms::Button()); this->RemSeq = (gcnew System::Windows::Forms::Button()); this->Clear = (gcnew System::Windows::Forms::Button()); this->label1 = (gcnew System::Windows::Forms::Label()); this->ItensBox = (gcnew System::Windows::Forms::ListView()); this->PathHeader = (gcnew System::Windows::Forms::ColumnHeader()); this->CntHeader = (gcnew System::Windows::Forms::ColumnHeader()); this->groupBox1 = (gcnew System::Windows::Forms::GroupBox()); this->Undistort = (gcnew System::Windows::Forms::CheckBox()); this->Stabilize = (gcnew System::Windows::Forms::CheckBox()); this->label2 = (gcnew System::Windows::Forms::Label()); this->FrameID = (gcnew System::Windows::Forms::NumericUpDown()); this->groupBox2 = (gcnew System::Windows::Forms::GroupBox()); this->label3 = (gcnew System::Windows::Forms::Label()); this->VideoFormat = (gcnew System::Windows::Forms::ComboBox()); this->MotionVideo = (gcnew System::Windows::Forms::CheckBox()); this->ExportVideo = (gcnew System::Windows::Forms::CheckBox()); this->groupBox3 = (gcnew System::Windows::Forms::GroupBox()); this->button1 = (gcnew System::Windows::Forms::Button()); this->textBox2 = (gcnew System::Windows::Forms::TextBox()); this->label5 = (gcnew System::Windows::Forms::Label()); this->label4 = (gcnew System::Windows::Forms::Label()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->Export = (gcnew System::Windows::Forms::Button()); this->About = (gcnew System::Windows::Forms::Button()); this->ExportWorker = (gcnew System::ComponentModel::BackgroundWorker()); this->OpenDialog = (gcnew System::Windows::Forms::OpenFileDialog()); this->SaveDialog = (gcnew System::Windows::Forms::SaveFileDialog()); this->groupBox1->SuspendLayout(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->FrameID))->BeginInit(); this->groupBox2->SuspendLayout(); this->groupBox3->SuspendLayout(); this->SuspendLayout(); // // AddSeq // this->AddSeq->Location = System::Drawing::Point(12, 275); this->AddSeq->Name = L"AddSeq"; this->AddSeq->Size = System::Drawing::Size(25, 23); this->AddSeq->TabIndex = 1; this->AddSeq->Text = L"+"; this->AddSeq->UseVisualStyleBackColor = true; this->AddSeq->Click += gcnew System::EventHandler(this, &MainForm::AddSeq_Click); // // RemSeq // this->RemSeq->Enabled = false; this->RemSeq->Location = System::Drawing::Point(43, 275); this->RemSeq->Name = L"RemSeq"; this->RemSeq->Size = System::Drawing::Size(25, 23); this->RemSeq->TabIndex = 2; this->RemSeq->Text = L"-"; this->RemSeq->UseVisualStyleBackColor = true; this->RemSeq->Click += gcnew System::EventHandler(this, &MainForm::RemSeq_Click); // // Clear // this->Clear->Location = System::Drawing::Point(411, 275); this->Clear->Name = L"Clear"; this->Clear->Size = System::Drawing::Size(75, 23); this->Clear->TabIndex = 3; this->Clear->Text = L"Clear"; this->Clear->UseVisualStyleBackColor = true; this->Clear->Click += gcnew System::EventHandler(this, &MainForm::Clear_Click); // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(12, 15); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(96, 13); this->label1->TabIndex = 5; this->label1->Text = L"Video Sequencies:"; // // ItensBox // this->ItensBox->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(2) {this->PathHeader, this->CntHeader}); this->ItensBox->HeaderStyle = System::Windows::Forms::ColumnHeaderStyle::Nonclickable; this->ItensBox->Location = System::Drawing::Point(12, 31); this->ItensBox->Name = L"ItensBox"; this->ItensBox->Size = System::Drawing::Size(474, 238); this->ItensBox->TabIndex = 6; this->ItensBox->UseCompatibleStateImageBehavior = false; this->ItensBox->View = System::Windows::Forms::View::Details; this->ItensBox->SelectedIndexChanged += gcnew System::EventHandler(this, &MainForm::ItensBox_SelectedIndexChanged); // // PathHeader // this->PathHeader->Text = L"Parh"; this->PathHeader->Width = 378; // // CntHeader // this->CntHeader->Text = L"Count"; // // groupBox1 // this->groupBox1->Controls->Add(this->Undistort); this->groupBox1->Controls->Add(this->Stabilize); this->groupBox1->Controls->Add(this->label2); this->groupBox1->Controls->Add(this->FrameID); this->groupBox1->Location = System::Drawing::Point(12, 304); this->groupBox1->Name = L"groupBox1"; this->groupBox1->Size = System::Drawing::Size(137, 119); this->groupBox1->TabIndex = 7; this->groupBox1->TabStop = false; this->groupBox1->Text = L"Production Properties"; // // Undistort // this->Undistort->AutoSize = true; this->Undistort->Location = System::Drawing::Point(16, 93); this->Undistort->Name = L"Undistort"; this->Undistort->Size = System::Drawing::Size(68, 17); this->Undistort->TabIndex = 4; this->Undistort->Text = L"Undistort"; this->Undistort->UseVisualStyleBackColor = true; // // Stabilize // this->Stabilize->AutoSize = true; this->Stabilize->Location = System::Drawing::Point(16, 70); this->Stabilize->Name = L"Stabilize"; this->Stabilize->Size = System::Drawing::Size(65, 17); this->Stabilize->TabIndex = 3; this->Stabilize->Text = L"Stabilize"; this->Stabilize->UseVisualStyleBackColor = true; // // label2 // this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(13, 27); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(92, 13); this->label2->TabIndex = 2; this->label2->Text = L"Frame Reference:"; // // FrameID // this->FrameID->Location = System::Drawing::Point(16, 44); this->FrameID->Name = L"FrameID"; this->FrameID->Size = System::Drawing::Size(89, 20); this->FrameID->TabIndex = 1; // // groupBox2 // this->groupBox2->Controls->Add(this->label3); this->groupBox2->Controls->Add(this->VideoFormat); this->groupBox2->Controls->Add(this->MotionVideo); this->groupBox2->Controls->Add(this->ExportVideo); this->groupBox2->Location = System::Drawing::Point(155, 314); this->groupBox2->Name = L"groupBox2"; this->groupBox2->Size = System::Drawing::Size(158, 109); this->groupBox2->TabIndex = 9; this->groupBox2->TabStop = false; this->groupBox2->Text = L"Video Export"; // // label3 // this->label3->AutoSize = true; this->label3->Location = System::Drawing::Point(6, 64); this->label3->Name = L"label3"; this->label3->Size = System::Drawing::Size(47, 13); this->label3->TabIndex = 5; this->label3->Text = L"Formats:"; // // VideoFormat // this->VideoFormat->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList; this->VideoFormat->Enabled = false; this->VideoFormat->FormattingEnabled = true; this->VideoFormat->Items->AddRange(gcnew cli::array< System::Object^ >(4) {L"1920x1080", L"1280x720", L"720x468", L"640x480"}); this->VideoFormat->Location = System::Drawing::Point(7, 79); this->VideoFormat->Name = L"VideoFormat"; this->VideoFormat->Size = System::Drawing::Size(145, 21); this->VideoFormat->TabIndex = 12; // // MotionVideo // this->MotionVideo->AutoSize = true; this->MotionVideo->Enabled = false; this->MotionVideo->Location = System::Drawing::Point(7, 43); this->MotionVideo->Name = L"MotionVideo"; this->MotionVideo->Size = System::Drawing::Size(91, 17); this->MotionVideo->TabIndex = 11; this->MotionVideo->Text = L"Motion Based"; this->MotionVideo->UseVisualStyleBackColor = true; // // ExportVideo // this->ExportVideo->AutoSize = true; this->ExportVideo->Location = System::Drawing::Point(6, 19); this->ExportVideo->Name = L"ExportVideo"; this->ExportVideo->Size = System::Drawing::Size(86, 17); this->ExportVideo->TabIndex = 10; this->ExportVideo->Text = L"Export Video"; this->ExportVideo->UseVisualStyleBackColor = true; this->ExportVideo->CheckedChanged += gcnew System::EventHandler(this, &MainForm::ExportVideo_CheckedChanged); // // groupBox3 // this->groupBox3->Controls->Add(this->button1); this->groupBox3->Controls->Add(this->textBox2); this->groupBox3->Controls->Add(this->label5); this->groupBox3->Controls->Add(this->label4); this->groupBox3->Controls->Add(this->textBox1); this->groupBox3->Location = System::Drawing::Point(319, 323); this->groupBox3->Name = L"groupBox3"; this->groupBox3->Size = System::Drawing::Size(167, 100); this->groupBox3->TabIndex = 10; this->groupBox3->TabStop = false; this->groupBox3->Text = L"Cluster Options "; // // button1 // this->button1->Location = System::Drawing::Point(76, 60); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(75, 23); this->button1->TabIndex = 16; this->button1->Text = L"Connect"; this->button1->UseVisualStyleBackColor = true; // // textBox2 // this->textBox2->Location = System::Drawing::Point(110, 34); this->textBox2->Name = L"textBox2"; this->textBox2->Size = System::Drawing::Size(41, 20); this->textBox2->TabIndex = 15; this->textBox2->Text = L"8888"; // // label5 // this->label5->AutoSize = true; this->label5->Location = System::Drawing::Point(107, 14); this->label5->Name = L"label5"; this->label5->Size = System::Drawing::Size(29, 13); this->label5->TabIndex = 14; this->label5->Text = L"Port:"; // // label4 // this->label4->AutoSize = true; this->label4->Location = System::Drawing::Point(6, 16); this->label4->Name = L"label4"; this->label4->Size = System::Drawing::Size(65, 13); this->label4->TabIndex = 13; this->label4->Text = L"Manager IP:"; // // textBox1 // this->textBox1->Location = System::Drawing::Point(9, 32); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(89, 20); this->textBox1->TabIndex = 0; this->textBox1->Text = L"192.168.0.1"; // // Export // this->Export->Location = System::Drawing::Point(369, 429); this->Export->Name = L"Export"; this->Export->Size = System::Drawing::Size(117, 23); this->Export->TabIndex = 11; this->Export->Text = L"Export/Submit"; this->Export->UseVisualStyleBackColor = true; this->Export->Click += gcnew System::EventHandler(this, &MainForm::Export_Click); // // About // this->About->Location = System::Drawing::Point(12, 429); this->About->Name = L"About"; this->About->Size = System::Drawing::Size(75, 23); this->About->TabIndex = 12; this->About->Text = L"About"; this->About->UseVisualStyleBackColor = true; this->About->Click += gcnew System::EventHandler(this, &MainForm::About_Click); // // ExportWorker // this->ExportWorker->WorkerReportsProgress = true; this->ExportWorker->WorkerSupportsCancellation = true; this->ExportWorker->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &MainForm::ExportWorker_DoWork); this->ExportWorker->ProgressChanged += gcnew System::ComponentModel::ProgressChangedEventHandler(this, &MainForm::ExportWorker_ProgressChanged); this->ExportWorker->RunWorkerCompleted += gcnew System::ComponentModel::RunWorkerCompletedEventHandler(this, &MainForm::ExportWorker_RunWorkerCompleted); // // OpenDialog // this->OpenDialog->DefaultExt = L"exr"; this->OpenDialog->Filter = L"OpenEXR Files (*.exr)|*.exr|JPEG Files (*.jpg)|*.jpg"; // // SaveDialog // this->SaveDialog->DefaultExt = L"exr"; this->SaveDialog->Filter = L"OpenEXR (*.exr)|*.exr"; // // MainForm // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(498, 464); this->Controls->Add(this->About); this->Controls->Add(this->Export); this->Controls->Add(this->groupBox3); this->Controls->Add(this->groupBox2); this->Controls->Add(this->groupBox1); this->Controls->Add(this->ItensBox); this->Controls->Add(this->label1); this->Controls->Add(this->Clear); this->Controls->Add(this->RemSeq); this->Controls->Add(this->AddSeq); this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog; this->Name = L"MainForm"; this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; this->Text = L"Auto-Sticher "; this->groupBox1->ResumeLayout(false); this->groupBox1->PerformLayout(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->FrameID))->EndInit(); this->groupBox2->ResumeLayout(false); this->groupBox2->PerformLayout(); this->groupBox3->ResumeLayout(false); this->groupBox3->PerformLayout(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void Clear_Click(System::Object^ sender, System::EventArgs^ e) { Windows::Forms::DialogResult result1 = MessageBox::Show( L"Do you really want to remove all elements?", L"Auto Video Sticher", MessageBoxButtons::YesNo); if( result1 == Windows::Forms::DialogResult::Yes) { ItensBox->Items->Clear(); MaxFrame = 0; FrameID->Value = 0; FrameID->Maximum = 0; } } private: System::Void ItensBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { RemSeq->Enabled = ItensBox->SelectedItems->Count != 0; } private: System::Void ExportVideo_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { MotionVideo->Enabled = ExportVideo->Checked; VideoFormat->Enabled = ExportVideo->Checked && !MotionVideo->Checked; } private: System::Void About_Click(System::Object^ sender, System::EventArgs^ e) { MessageBox::Show( L"Auto Video Sticher v0.1.0.2\n\nDeveloped By: Rodrigo Marques", L"Auto Video Sticher"); } private: System::Void AddSeq_Click(System::Object^ sender, System::EventArgs^ e) { if(OpenDialog->ShowDialog() == Windows::Forms::DialogResult::OK) { String^ FileName = OpenDialog->FileName; String^ Dir = System::IO::Path::GetDirectoryName(FileName); String^ Ext = Path::GetExtension(FileName); ListViewItem^ it = gcnew ListViewItem(); it->Text = FileName; DirectoryInfo ^ di = gcnew DirectoryInfo(Dir); array<FileInfo ^> ^ aryFiles = di->GetFiles(L"*" + Ext, SearchOption::AllDirectories); it->SubItems->Add(aryFiles->Length.ToString()); ItensBox->Items->Add(it); if( aryFiles->Length < MaxFrame ) { MaxFrame = aryFiles->Length; if( FrameID->Value > MaxFrame ) { FrameID->Value = MaxFrame; } FrameID->Maximum = MaxFrame; } } } private: System::Void RemSeq_Click(System::Object^ sender, System::EventArgs^ e) { if(ItensBox->SelectedItems->Count != 0) { for (int i = ItensBox->SelectedItems->Count - 1; i >= 0 ; i--) { ItensBox->Items->Remove(ItensBox->SelectedItems[i]); } RecomputeMax(); } } private: System::String^ ExportFileName; private: System::Collections::Generic::List<String^>^ SeqFiles; private: int FrameBase; private: ProgressDialog^ pbDialog; private: System::Void Export_Click(System::Object^ sender, System::EventArgs^ e) { using namespace std; using namespace cv; if( ItensBox->Items->Count == 0 ) return; if(SaveDialog->ShowDialog() != Windows::Forms::DialogResult::OK) return; SeqFiles = GetAllFiles(); ExportFileName = System::IO::Path::GetFileNameWithoutExtension(SaveDialog->FileName); MaxFrame = GetMaxFrameID(); if( FrameID->Value > MaxFrame ) FrameID->Value = MaxFrame; FrameBase = (int)FrameID->Value; if( pbDialog != nullptr) { pbDialog = gcnew ProgressDialog(); } pbDialog->MainLabel->Text = "Starting Stiting..."; pbDialog->Progress->Value = 0; pbDialog->CloseBtn->Click += gcnew System::EventHandler(this, &MainForm::Cancel_Click); pbDialog->Show(); ExportWorker->RunWorkerAsync(); } private: System::Void Cancel_Click(System::Object^ sender, System::EventArgs^ e) { ExportWorker->CancelAsync(); if( pbDialog != nullptr) { pbDialog->Close(); pbDialog = nullptr; } } private: System::Boolean GenerateParameters(System::Collections::Generic::List<String^>^ files, int FrameID, std::vector<std::vector<cv::Rect>>& rois ) { using namespace std; using namespace cv; Stitcher stitcher = Stitcher::createDefault(true); vector<Mat> imgs; LoadImages(files, FrameID, imgs); Stitcher::Status status = stitcher.estimateTransform(imgs, rois); if (status != Stitcher::OK) { System::String^ Error = ""; Error = "Can't stitch images, error code = " + Int32(status).ToString(); MessageBox::Show( Error, L"Auto Video Sticher"); //cout << "Can't stitch images, error code = " << int(status) << endl; return false; } return true; } private: void LoadImages(System::Collections::Generic::List<String^>^ files, int FrameID, std::vector<cv::Mat> &imgs ) { for(register int i = 0; i < files->Count; i++) { String^ FileName = files[i]; System::String^ Dir = System::IO::Path::GetDirectoryName(FileName); String^ Ext = Path::GetExtension(FileName); DirectoryInfo ^ di = gcnew DirectoryInfo(Dir); array<FileInfo ^> ^ aryFiles = di->GetFiles(L"*" + Ext, SearchOption::AllDirectories); int j = 0; for each(FileInfo ^ fle in aryFiles) { if( j == FrameID ) { std::string filename; MarshalString(fle->FullName, filename); cv::Mat img = cv::imread(filename); if (img.empty()) { System::String^ Error = ""; Error = "Can't read image '" + fle->FullName + "'"; MessageBox::Show( Error, L"Auto Video Sticher"); break; } imgs.push_back(img); break; } j++; } } } private: System::Int32 GetMaxFrameID() { int minimum = Int32::MaxValue; for each ( ListViewItem^ it in ItensBox->Items ) { Int32 v = System::Int32::Parse(it->SubItems[0]->Text); if( v < minimum ) { minimum = v; } } return minimum; } private: void RecomputeMax() { int minimum = Int32::MaxValue; for each ( ListViewItem^ it in ItensBox->Items ) { Int32 v = System::Int32::Parse(it->SubItems[0]->Text); if( v < minimum ) { minimum = v; } } MaxFrame = minimum; if(FrameID->Value > MaxFrame) { FrameID->Value = MaxFrame; } FrameID->Maximum = MaxFrame; } private: System::Collections::Generic::List<String^>^ GetAllFiles() { System::Collections::Generic::List<String^>^ files = gcnew System::Collections::Generic::List<String^>(); for(register int i = 0; i < ItensBox->Items->Count; i++) { files->Add(ItensBox->Items[i]->Text); } return files; } private: System::Void ExportWorker_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) { using namespace std; using namespace cv; System::String^ Dir = System::IO::Path::GetDirectoryName(ExportFileName); vector<vector<Rect>> rois; // Compute Base if( GenerateParameters(SeqFiles, FrameBase, rois) ) { System::String^ Error = ""; Error = "Can't stitch images, error code = "; MessageBox::Show( Error, L"Auto Video Sticher"); return; } for(register int i = 0; i < MaxFrame ; i++) { Stitcher stitcher = Stitcher::createDefault(true); vector<Mat> imgs; Mat pano; LoadImages(SeqFiles, i, imgs); Stitcher::Status status = stitcher.stitch(imgs, rois, pano); if (status != Stitcher::OK) { System::String^ Error = ""; Error = "Can't stitch images, error code = " + Int32(status).ToString(); MessageBox::Show( Error, L"Auto Video Sticher"); //cout << "Can't stitch images, error code = " << int(status) << endl; //return -1; continue; } System::String^ FinalName = System::IO::Path::Combine(Dir, System::String::Format("{0}{1:00000}.exr", ExportFileName, i)); string filename; MarshalString(FinalName, filename); imwrite(filename, pano); } } private: System::Void ExportWorker_RunWorkerCompleted(System::Object^ sender, System::ComponentModel::RunWorkerCompletedEventArgs^ e) { if(pbDialog != nullptr) { pbDialog->Close(); // pbDialog->Dispose(); pbDialog = nullptr; } } private: System::Void ExportWorker_ProgressChanged(System::Object^ sender, System::ComponentModel::ProgressChangedEventArgs^ e) { if(pbDialog != nullptr) { String^ Val = (String^)e->UserState; if( pbDialog->MainLabel->Text != Val) { //pbDialog->LogBox->Items->Add() pbDialog->MainLabel->Text = Val; } if(pbDialog->Progress->Value != e->ProgressPercentage) { pbDialog->Progress->Value = e->ProgressPercentage; ///pbDialog->LogBox->Items->Add } } } }; }
6c1a9d0ed2e8c92f4d05de2d9334f1ec6b2188c5
05569ef4785c267e1815c6ef10b759f947e28bcc
/final/atm.cpp
fd50784be1a7a949d23577de07d216c98476a5ba
[]
no_license
nadavshalev/OS102
36a5d44ec72977366288473aa20f310c1ee055bf
04cac3daa58b01b08ca0858ba5f14d751719e767
refs/heads/master
2020-09-30T02:06:30.460583
2020-01-19T20:02:18
2020-01-19T20:02:18
227,173,868
0
0
null
null
null
null
UTF-8
C++
false
false
6,659
cpp
atm.cpp
#include "atm.h" //******************************************** // function name: runATM // Description: read atm file and exec each line //******************************************** void* runATM(void *argin){ // get input arguments struct atmArgs *arg; arg = (struct atmArgs *) argin; // open file for stream ifstream file(arg->filePath); string str; while (getline(file, str)) { usleep(100000); // split line to arguments string* args = tokenize(str, ' '); string cmd = args[0]; // exec cmd runCmd(cmd, args, (*arg->accounts), (*arg->atmID), (*arg->strLog)); } pthread_exit(NULL); } //******************************************** // function name: runCmd // Description: exec commands //******************************************** void runCmd(string cmd, string* args, list <Account*>& accounts, int atmID, stringstream& strLog){ int accID = stoi(args[1]); /************************* Open *************************/ if (cmd == "O") { // check if eccount already exist if(findAccount(accounts, accID) != NULL){ pthread_mutex_lock(&logLock); strLog << "Error " << atmID << "‫‪: Your‬‬ ‫‪transaction‬‬ ‫‪failed‬‬ ‫–‬ ‫‪account‬‬ ‫‪with‬‬ ‫‪the‬‬ ‫‪same‬‬ ‫‪id‬‬ ‫‪exists‬‬\n"; pthread_mutex_unlock(&logLock); return; } // create new account Account* acc = new Account(accID, args[2], stoi(args[3])); // push and resort the account's list pthread_mutex_lock(&accountListLock); accounts.push_back(acc); accounts.sort(compare); pthread_mutex_unlock(&accountListLock); pthread_mutex_lock(&logLock); strLog << atmID << "‫‪‫‪: New Account‬‬ id is ‫"<< accID << "‫‪ with‬‬ ‫‪password‬‬ ‫" << args[2] << " ‫‪and‬‬ ‫‪initial‬‬ ‫‪balance‬‬ ‫" << stoi(args[3]) << "\n"; pthread_mutex_unlock(&logLock); return; } // verify account axist and correct password Account* acc = findAccount(accounts, accID); if(acc == NULL){ pthread_mutex_lock(&logLock); strLog << "‫‪Error‬‬ ‫‪" << atmID << "‫‪:‬‬ ‫‪Your‬‬ ‫‪transaction‬‬ ‫‪failed‬‬ ‫–‬ ‫‪account‬‬ ‫‪id‬‬ ‫"<< accID << " ‫‪does‬‬ ‫‪not‬‬ ‫‪exist‬‬\n"; pthread_mutex_unlock(&logLock); return; } if(acc->password_ != args[2]){ pthread_mutex_lock(&logLock); strLog << "‫‪Error‬‬ ‫‪" << atmID << "‫‪:‬‬ ‫‪Your‬‬ ‫‪transaction‬‬ ‫‪failed‬‬ ‫–‬ ‫‪‫‪password‬‬ ‫‪for‬‬ ‫‪account‬‬ ‫‪id‬‬ ‫"<< accID << " ‫‪‫‪is‬‬ ‫‪incorrect‬‬\n"; pthread_mutex_unlock(&logLock); return; } /************************* Deposit ************************/ if (cmd == "D") { int amount = stoi(args[3]); int result = acc->deposit(amount); pthread_mutex_lock(&logLock); strLog << atmID << "‫‪‫‪: Account‬‬ ‫"<< accID << " ‫‪new‬‬ ‫‪balance‬‬ ‫‪is‬‬ ‫" << result << " after " << amount << "$‬‬ ‫‪was‬‬ deposited\n"; pthread_mutex_unlock(&logLock); } /************************* Withdrew ************************/ else if (cmd == "W") { int amount = stoi(args[3]); int result = acc->withdrew(amount); if (result == -1){ pthread_mutex_lock(&logLock); strLog << "‫‪Error‬‬ ‫‪" << atmID << "‫‪:‬‬ ‫‪Your‬‬ ‫‪transaction‬‬ ‫‪failed‬‬ ‫–‬ ‫‪‫‪‫‪balance‬‬ ‫‪is‬‬ ‫‪lower‬‬ ‫‪than‬‬ ‫"<< amount << "\n"; pthread_mutex_unlock(&logLock); } else{ pthread_mutex_lock(&logLock); strLog << atmID << "‫‪‫‪: Account‬‬ ‫"<< accID << " ‫‪new‬‬ ‫‪balance‬‬ ‫‪is‬‬ ‫" << result << " after " << amount << "$‬‬ ‫‪was‬‬ ‫‪withdrew‬‬\n"; pthread_mutex_unlock(&logLock); } } /************************* Acount val ************************/ else if (cmd == "B") { int amount = acc->getAmount(); pthread_mutex_lock(&logLock); strLog << atmID << "‫‪‫‪: Account‬‬ ‫"<< accID << " ‫‪balance‬‬ ‫‪is‬‬ ‫" << amount << "\n"; pthread_mutex_unlock(&logLock); } /************************ Transaction *************************/ else if (cmd == "T") { // check if account 2 is axist Account* acc2 = findAccount(accounts, stoi(args[3])); if(acc2 == NULL){ pthread_mutex_lock(&logLock); strLog << "‫‪Error‬‬ ‫‪" << atmID << "‫‪:‬‬ ‫‪Your‬‬ ‫‪transaction‬‬ ‫‪failed‬‬ ‫–‬ ‫‪account‬‬ ‫‪id‬‬ ‫"<< accID << " ‫‪does‬‬ ‫‪not‬‬ ‫‪exist‬‬\n"; pthread_mutex_unlock(&logLock); return; } int amount = stoi(args[4]); bool result = acc->toAccount(amount, *acc2); if (result){ pthread_mutex_lock(&logLock); strLog << atmID << ": Transfer " << amount << " from account " << accID << " to account " << args[3] << " new account balance is " << acc->amount_ << " new target account balance is " << acc2->amount_ << "\n"; pthread_mutex_unlock(&logLock); } else{ pthread_mutex_lock(&logLock); strLog << "‫‪Error‬‬ ‫‪" << atmID << "‫‪:‬‬ ‫‪Your‬‬ ‫‪transaction‬‬ ‫‪failed‬‬ ‫–‬ ‫‪‫‪‫‪balance‬‬ ‫‪is‬‬ ‫‪lower‬‬ ‫‪than‬‬ ‫"<< amount << "\n"; pthread_mutex_unlock(&logLock); } } /************************ Command not exist *************************/ else { // do nothing... } } //******************************************** // function name: tokenize // Description: split to argunents //******************************************** string* tokenize(string const &str, const char delim) { size_t start; size_t end = 0; int count = 0; string* spString = new string[5]; while (count < 5 && ((start = str.find_first_not_of(delim, end)) != string::npos)) { end = str.find(delim, start); spString[count] = str.substr(start, end - start); count++; } return spString; } //******************************************** // function name: findAccount // Description: find account in the list // Retuen: pointer to the account //******************************************** Account* findAccount(list <Account*>& accounts, int id){ list <Account*> :: iterator it; for(it = accounts.begin(); it != accounts.end(); ++it){ if ((*it)->id_ == id) return (*it); } return NULL; }
15a741d094b631aaa14f18eeea1e588890a3234b
2013e024e03b233f6f19c9e225c13090a7414e74
/nytl/fwd/span.hpp
9a2faabca5076ca5e758ea1077d7c36a254f22a2
[ "BSL-1.0" ]
permissive
salom12/nytl
3223a553cab656d8d75e35c786011fc9a327891d
3689a4f6db7d5f847a01c52a8e5d0996f3b7c137
refs/heads/master
2020-03-22T07:26:23.332046
2018-05-26T21:31:55
2018-05-26T21:52:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
384
hpp
span.hpp
// Copyright (c) 2017-2018 nyorain // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt #pragma once #ifndef NYTL_INCLUDE_FWD_SPAN #define NYTL_INCLUDE_FWD_SPAN #include <cstdlib> // std::size_t namespace nytl { template<typename T, std::size_t N = 0> class Span; } #endif //header guard
c779088430e1c838c2abf818eea29c243dc1e77e
d06120aaff28e4e90f891201a9278fc339566a8d
/monopoly/Classes/Land/Jail.h
40d3db35b2efd2cf8fd2eb04ecc1b4fc1d7ca2a8
[ "MIT" ]
permissive
li-letian/Monopoly
7b8d9372bb1fe1ad6565205ce9014b67b468e9d1
6427672842ed94bb4dad585206ec08ec9a5f7a4d
refs/heads/master
2022-11-13T03:44:57.776063
2020-06-21T14:21:18
2020-06-21T14:21:18
261,958,000
4
3
MIT
2020-06-13T15:54:52
2020-05-07T05:30:03
C++
UTF-8
C++
false
false
331
h
Jail.h
#ifndef _JAIL_H_ #define _JAIL_H_ #include "cocos2d.h" #include "Land.h" #include "Common/CommonMethod.h" #include "Character/Character.h" #include<string> USING_NS_CC; class Jail : public Land { protected: public: virtual bool onLand(Character* standing) override; static Jail* create(int index); }; #endif // !_JAIL_H_
d560e709d2928726173818bf7b6190064093e20e
ba9d425fd2da1f10bb01f7ae0a3b46e0d459067a
/problem045/main.cpp
efca5efdc8792d982bbf9cd1398b6d951909f212
[]
no_license
koeleck/euler
445415571c136f4df3933d9925df6a5e207bdd59
5b92b2d953b37f09cef839ed3346a6df8e743dc8
refs/heads/master
2021-03-22T03:03:18.199215
2015-08-02T19:40:03
2015-08-02T19:40:03
39,467,094
0
0
null
null
null
null
UTF-8
C++
false
false
1,819
cpp
main.cpp
#include <iostream> #include <vector> std::vector<unsigned long long int> computeTriangleNumbers(const unsigned long long int max) { std::vector<unsigned long long int> result{1}; unsigned long long int cur = 1; for (unsigned long int n = 1; cur < max; ++n) { cur = cur + n + 1; result.emplace_back(cur); } return result; } std::vector<unsigned long long int> computePentagonalNumbers(const unsigned long long int max) { std::vector<unsigned long long int> result{1}; unsigned long long int cur = 1; for (unsigned long int n = 1; cur < max; ++n) { cur = cur + 3 * n + 1; result.emplace_back(cur); } return result; } std::vector<unsigned long long int> computeHexagonalNumbers(const unsigned long long int max) { std::vector<unsigned long long int> result{1}; unsigned long long int cur = 1; for (unsigned long int n = 1; cur < max; ++n) { cur = cur + 4 * n + 1; result.emplace_back(cur); } return result; } bool hasNumber(const std::vector<unsigned long long int>& numbers, const unsigned long long int n) { const auto it = std::lower_bound(numbers.begin(), numbers.end(), n); if (it == numbers.end()) { std::cerr << "need more numbers\n"; return false; } return *it == n; } int main() { constexpr unsigned long long int m = 99999999999; const auto tri = computeTriangleNumbers(m); const auto pent = computePentagonalNumbers(m); const auto hex = computeHexagonalNumbers(m); auto it = std::lower_bound(tri.begin(), tri.end(), 40755); for (++it; it != tri.end(); ++it) { const auto t = *it; if (hasNumber(pent, t) && hasNumber(hex, t)) { std::cout << "result: " << t << '\n'; return 0; } } }
5f4aef96349f2fab01b061bde07f66b704932e59
9f65b341f176aead0aa6f3de881db793ced46a9d
/cpp/FE.cpp
e3681d601aa43f1b1f397740970ebc05d418cc84
[]
no_license
itsjustwinds/study-path
2e66c0d85a431983e60ffde126131cb3dd8e865b
5bfd3cc1c4d3f0b20c2bbc852f43dfbf3d726507
refs/heads/master
2020-05-30T07:51:30.320218
2020-04-05T11:29:02
2020-04-05T11:29:02
189,585,900
0
1
null
null
null
null
UTF-8
C++
false
false
838
cpp
FE.cpp
#include<bits/stdc++.h> #define maxn 1005 using namespace std; int a[maxn],n,dd[maxn],trace[maxn]; vector<int> dem; int main() { freopen("FE.inp","r",stdin); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for (int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+n+1); int now=1; for (int i=2;i<=n+1;i++) if (a[i]==a[i-1]) { now++; } else { if (dd[now]==0) { dem.push_back(now); trace[now]=a[i-1]; } dd[now]++; now=1; } for (int i=0;i<(int)dem.size();i++) { int v=dem[i]; if (dd[v]==1) { cout<<trace[v]; return 0; } } return 0; }
5e84714cf68d37b13f5b5466f930e0b3d0db8883
2ed9ed857b646c9ee68abf57fc0db6b5e1827e35
/pbinfo/590.cpp
d41f99c80e118371bb9b48e85715e4d956d9d02c
[]
no_license
Ca3zsar/Code-Problems
56c2eeb9a33b2b66d54dbe59b3a6955b2db4e866
1592cfddcfaa7c6dfd32732532a98b9acd4b90f5
refs/heads/master
2022-11-10T05:10:19.747918
2020-06-27T12:43:43
2020-06-27T12:43:43
275,247,465
0
0
null
null
null
null
UTF-8
C++
false
false
1,199
cpp
590.cpp
#include <bits/stdc++.h> #define triplu tuple<int,int,int> using namespace std; ifstream fin("prim.in"); ofstream fout("prim.out"); int n,m,a,b,cost,d[101],d2[101],ra,rb,total,x[101][101]; vector<triplu>v; int get_root(int nod) { if(nod==d[nod])return nod; d[nod]=get_root(d[nod]); return d[nod]; } int main() { fin>>n>>m; for(int i=1;i<=n;i++)d[i]=i; for(;m;m--) { fin>>a>>b>>cost; x[a][b]=x[b][a]=1; v.push_back(make_tuple(cost,a,b)); } sort(v.begin(),v.end()); for(auto vec:v) { tie(cost,a,b)=vec; ra=get_root(a); rb=get_root(b); if(ra==rb) { x[b][a]=0; x[a][b]=0; continue; } d[rb]=ra; d2[b]=a; total+=cost; } queue<int>q; q.push(1); while(q.size()) { int ps=q.front(); q.pop(); for(int i=1;i<=n;i++) { if(x[ps][i]) { x[ps][i]=0; x[i][ps]=0; d2[i]=ps; q.push(i); } } } fout<<total<<'\n'; for(int i=1;i<=n;i++)fout<<d2[i]<<' '; return 0; }
9fa8e1385589e7cbbd9110ff443c60c76fae3973
803e2cc1ee6e0ea49b7e9963d738473ea07e7e89
/Raycasting engine/src/Map.cpp
ae7f502ba68be158c53d3b9c2c9a3084ee6faf6a
[]
no_license
Gonadaie/Raycasting-engine
a27a54e1874bf2d6ffaa2c09da24ea13e69e53aa
f9a511317a886e9d4099a5f287bf9a52d7dc32b2
refs/heads/master
2020-05-23T03:55:57.298162
2018-01-26T18:19:51
2018-01-26T18:19:51
84,747,410
0
0
null
null
null
null
UTF-8
C++
false
false
8,009
cpp
Map.cpp
#include "Map.h" #include <iostream> #include <fstream> #include "constants.h" #include <math.h> #include "trigo_functions.h" using namespace std; Map::Map(){ renderingRect = {0, 0, 4, 4}; } Map::~Map(){ for(unsigned int i = 0; i < width; ++i){ delete cells[i]; cells[i] = NULL; } delete[] cells; cells = NULL; } bool Map::loadMap(char* path){ ifstream file; file.open(path, ios::in); if(file == NULL){ cerr << "Error : Could not load " << path << endl; return false; } else{ file >> width; file >> height; unsigned int cellSize; file >> cellSize; //initialize each row cells = new unsigned int*[width]; //initialize each column for(unsigned int i = 0; i < width; ++i){ cells[i] = new unsigned int[height]; } for(unsigned int i = 0; i < height; ++i){ for(unsigned int j = 0; j < width; ++j){ file >> cells[j][i]; } } cout << path << " has been loaded" << endl; file.close(); return true; } } void Map::render(SDL_Renderer* renderer, SDL_Rect* miniMap, Entity* player){ //SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); //SDL_RenderFillRect(renderer, miniMap); SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0x00, 0xFF); for(unsigned int i = 0; i < width; ++i){ for(unsigned int j = 0; j < height; ++j){ if(cells[i][j] == 1001){ renderingRect = {miniMap->x + i*PIXELSIZE, miniMap->y + j*PIXELSIZE, PIXELSIZE, PIXELSIZE}; SDL_RenderFillRect(renderer, &renderingRect); } } } SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0xFF, 0xFF); renderingRect = {(int)(miniMap->x + player->getXX()), (int)(miniMap->y + player->getYY()), PIXELSIZE, PIXELSIZE}; SDL_RenderFillRect(renderer, &renderingRect); renderingRect = {(int)((miniMap->x + player->getXX())+PIXELSIZE*cos(-player->getAngle()*3.14f/180)), (int)((miniMap->y + player->getYY())+PIXELSIZE*sin(-player->getAngle()*3.14f/180)), PIXELSIZE, PIXELSIZE}; SDL_RenderFillRect(renderer, &renderingRect); } int Map::getCellAt(int x, int y){ //cerr << x << " : " << y << endl; if(0 <= x && x < width && 0 <= y && y < height) return cells[x][y]; else return -1; } bool Map::isFacingWall(float ox, float oy, bool right, bool up, bool vertical){ if(vertical){ if(right){ if(up) return getCellAt(ox, oy) == 1001; else return getCellAt(ox, oy) == 1001; } else{ if(up) return getCellAt(ox-1, oy) == 1001; else return getCellAt(ox-1, oy) == 1001; } } else{ if(right){ if(up) return getCellAt(ox, oy-1) == 1001; else return getCellAt(ox, oy) == 1001; } else{ if(up) return getCellAt(ox, oy-1) == 1001; else return getCellAt(ox, oy) == 1001; } } } float Map::findDistance(float ox, float oy, float angle){ float cell[2] = {ox, oy}; angle = -angle; float distX = cos(angle*PI/180)*0.01f; float distY = sin(angle*PI/180)*0.01f; while(getCellAt((unsigned int)cell[0], (unsigned int)cell[1]) != 1001){ cell[0] += distX; cell[1] += distY; if((int)cell[0] >= width || (int)cell[0] < 0 || (int)cell[1] >= height || (int)cell[1] < 0) return -1; } return sqrt((cell[0]-ox)*(cell[0]-ox) + (cell[1]-oy)*(cell[1]-oy)); } float Map::findNearestWall(float ox, float oy, float& ix, float& iy, float angle){ //Variables float vPointX = ox; float vPointY = oy; float vDistanceX, vDistanceY; float hPointX = ox; float hPointY = oy; float hDistanceX, hDistanceY; float verticalDistanceFound = -1; float horizontalDistanceFound = -1; //If not 0 < angle < 360 then correct the angle value updateAngle(angle); float initialAngle = angle; bool up = (angle >= 0 && angle < 180); bool right = !(angle >= 90 && angle < 270); if(up){ if(!right) angle -= 90; } else{ if(!right) angle -= 180; else angle -= 270; } updateAngle(angle); //Conversion from degrees to radians --> cos() sin() tan() take an angle in radians angle = degreesToRadians(angle); //float distanceCorrection = getDistanceCorrection(angle, right, up); // --- Find nearest intersections --- // //Vertical if(right){ vPointX = trunc(ox) + 1; vDistanceX = vPointX - ox; if(up){ vDistanceY = vDistanceX * tan(angle); vPointY = oy - vDistanceY; vDistanceY = tan(angle); } else{ vDistanceY = vDistanceX / tan(angle); vPointY = oy + vDistanceY; vDistanceY = 1 / tan(angle); } } else{ vPointX = trunc(ox); vDistanceX = ox - vPointX; if(up){ vDistanceY = vDistanceX / tan(angle); vPointY = oy - vDistanceY; vDistanceY = 1 / tan(angle); } else{ vDistanceY = vDistanceX * tan(angle); vPointY = oy + vDistanceY; vDistanceY = tan(angle); } } //Horizontal if(up){ hPointY = trunc(oy); hDistanceY = oy - hPointY; if(right){ hDistanceX = hDistanceY / tan(angle); hPointX = ox + hDistanceX; hDistanceX = 1 / tan(angle); } else{ hDistanceX = hDistanceY * tan(angle); hPointX = ox - hDistanceX; hDistanceX = tan(angle); } } else{ hPointY = trunc(oy) + 1; hDistanceY = hPointY - oy; if(right){ hDistanceX = hDistanceY * tan(angle); hPointX = ox + hDistanceX; hDistanceX = tan(angle); } else{ hDistanceX = hDistanceY / tan(angle); hPointX = ox - hDistanceX; hDistanceX = 1 / tan(angle); } } //cerr << "vPointX : " << vPointX << " vPointY : " << vPointY << endl; while(!isFacingWall(vPointX, vPointY, right, up, true)){ //cerr << "vx : " << vPointX << " vy : " << vPointY << endl; //cerr << "vDistX : " << vDistanceX << " vDistY : " << vDistanceY << endl; //Vertical if(right){ ++vPointX; if(up) vPointY -= vDistanceY; else vPointY += vDistanceY; } else{ --vPointX; if(up) vPointY -= vDistanceY; else vPointY += vDistanceY; } if(vPointX < 0 || vPointX >= width || vPointY < 0 || vPointY >= height) break; } while(!isFacingWall(hPointX, hPointY, right, up, false)){ //Horizontal if(up){ --hPointY; if(right) hPointX += hDistanceX; else hPointX -= hDistanceX; } else{ ++hPointY; if(right) hPointX += hDistanceX; else hPointX -= hDistanceX; } if(hPointX < 0 || hPointX >= width || hPointY < 0 || hPointY >= height) break; } if(isFacingWall(vPointX, vPointY, right, up, true)) verticalDistanceFound = distanceBetween(ox, oy, vPointX, vPointY); if(isFacingWall(hPointX, hPointY, right, up, false)) horizontalDistanceFound = distanceBetween(ox, oy, hPointX, hPointY); if(verticalDistanceFound != -1 && horizontalDistanceFound != -1){ verticalDistanceFound = distanceBetween(ox, oy, vPointX, vPointY); horizontalDistanceFound = distanceBetween(ox, oy, hPointX, hPointY); if(min(verticalDistanceFound, horizontalDistanceFound) == verticalDistanceFound){ ix = vPointX; iy = vPointY; return verticalDistanceFound; } else{ ix = hPointX; iy = hPointY; return horizontalDistanceFound; } } else{ if(verticalDistanceFound != -1 && horizontalDistanceFound == -1){ ix = vPointX; iy = vPointY; return verticalDistanceFound; } if(verticalDistanceFound == -1 && horizontalDistanceFound != -1){ ix = hPointX; iy = hPointY; return horizontalDistanceFound; } } return -1; }
93f148a930a6d938fa56981bec3b81c804b6d415
17bf8eca8ece516e65118a91d60134092a8f68e4
/C++/451. Sort Characters By Frequency/sol.cpp
640d931f7b35bf64fed6506224fb54bfc65dd78f
[]
no_license
HaelC/LeetCode
a433bb49e62a3b331982cb6fa337a72726c45a11
549c0217e771726611287f7bcd43c704190a60f1
refs/heads/master
2022-12-29T16:53:56.159942
2020-10-11T05:50:25
2020-10-11T05:50:25
177,907,987
1
0
null
null
null
null
UTF-8
C++
false
false
737
cpp
sol.cpp
class myCompare { public: bool operator()(pair<char, int> p1, pair<char, int> p2) { return p1.second < p2.second; } }; class Solution { public: string frequencySort(string s) { unordered_map<char, int> count; for (char c : s) { count[c]++; } priority_queue<pair<char, int>, vector<pair<char, int>>, myCompare> pq; for (auto p : count) { pq.push(p); } string result = ""; while (!pq.empty()) { char c = pq.top().first; int cnt = pq.top().second; pq.pop(); for (int i = 0; i < cnt; i++) { result += c; } } return result; } };
5f5b7191e3d2f261ca381aa032b5e37f516421cb
8881ec4b35654b2ead0cf078fb3b39affe41b8a5
/src/DetectorMessenger.cc
f2d2b63b63e622d489d9cd34be94d88c85b6f9ef
[]
no_license
swissco67/fastrad
38915a14882440454d20776a0392ee5a3e8caae2
f3eee7f2b69ccd866e132abf0b6f50aa0dfaa95f
refs/heads/master
2020-09-15T14:19:03.241842
2019-11-22T22:58:21
2019-11-22T22:58:21
223,473,748
0
0
null
null
null
null
UTF-8
C++
false
false
2,851
cc
DetectorMessenger.cc
/**************************************************************** * DetectorMessenger.cc * Implementation file for class: DetectorMessenger * (Geant4 compatible class) * * Project: Ht * * * Neither the authors of this software system, nor their employing * institutes,nor the agencies providing financial support for this * work make any representation or warranty, express or implied, * regarding this software system or assume any liability for its * use. * * * Creation: 2019/11/22 by Fastrad ((C) 2019) * Last Modified: *****************************************************************/ #include "DetectorMessenger.hh" #include "G4ios.hh" #include "G4Tokenizer.hh" #include <iomanip> #include <sstream> //--------------------------------------------------------------------- DetectorMessenger::DetectorMessenger(DetectorConstruction* pGeom) : pDetectorConstruction_(pGeom) { geomDir_ = new G4UIdirectory("/geom/"); geomDir_->SetGuidance("Shielding Thickness Control"); magnDir_ = new G4UIdirectory("/magn/"); magnDir_->SetGuidance("Magnetic Filed Intensity Control."); detCmd_ = new G4UIcmdWithAString("/geom/detector",this); detCmd_->SetGuidance("Select a type of detection"); detCmd_->SetGuidance("Dose"); detCmd_->SetGuidance("LET"); detCmd_->SetGuidance("Nuclear interactions"); detCmd_->SetCandidates(" dose let interactions Dose Let Interactions DOSE LET INTERACTIONS "); detCmd_->AvailableForStates(G4State_PreInit,G4State_Idle); magnCmd_ = new G4UIcmdWithADoubleAndUnit("/magn/setField",this); magnCmd_->SetGuidance("Define Magnetic Field Intensity."); magnCmd_->SetGuidance("Magnetic field will be in X direction."); magnCmd_->SetParameterName("Bx",false); magnCmd_->SetDefaultUnit("tesla"); magnCmd_->SetUnitCategory("Magnetic flux density"); magnCmd_->AvailableForStates(G4State_PreInit,G4State_Idle); updateCmd_ = new G4UIcmdWithoutParameter("/geom/update",this); updateCmd_->SetGuidance("Update Geometry."); updateCmd_->SetGuidance("This command MUST be applied before \"beamOn\" "); updateCmd_->SetGuidance("if you changed geometrical value(s)."); updateCmd_->AvailableForStates(G4State_Idle); } DetectorMessenger::~DetectorMessenger() { delete magnCmd_; } void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) { if ( command == magnCmd_ ) { pDetectorConstruction_ ->SetMagneticField(magnCmd_->GetNewDoubleValue(newValue)); } if ( command == updateCmd_ ) { pDetectorConstruction_->UpdateGeometry(); } if ( command == detCmd_ ) { pDetectorConstruction_->SetDetection(newValue); } }
c8c96833ebc4567213b92e7c0320ed16a3b01e4d
eb88a6353d04dcf8fffc560eb089ab6939e84123
/Win32Project1/Win32Project1.cpp
a8ed091ffef51d02b0d767d5e830e065e584e8b7
[]
no_license
uchitacchin/CsCallDll
a65a9f8a5466fc8ca4e817ad725e52ab1027cf62
6d99129cebacef170c43c4a87b8fec348fb063af
refs/heads/master
2020-05-07T09:22:13.072974
2019-04-09T13:32:54
2019-04-09T13:32:54
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,388
cpp
Win32Project1.cpp
// Win32Project1.cpp : DLL アプリケーション用にエクスポートされる関数を定義します。 // #include "stdafx.h" extern "C" __declspec(dllexport) int FunctionName(int x, int y) { return x + y; } // //class CTest //{ //public: // int Add(int x, int y) // { // return x + y; // } // //}; // wrap_native_class_for_mgd_consumption.cpp // compile with: /clr /LD //#include <windows.h> #include <vcclr.h> #using <System.dll> using namespace System; namespace Hello { class UnmanagedClass { public: LPCWSTR GetPropertyA() { return 0; } void MethodB(LPCWSTR) {} int Add(int x, int y) { return x + y; } }; public ref class ManagedClass { public: // Allocate the native object on the C++ Heap via a constructor ManagedClass() : m_Impl(new UnmanagedClass) {} // Deallocate the native object on a destructor ~ManagedClass() { delete m_Impl; } protected: // Deallocate the native object on the finalizer just in case no destructor is called !ManagedClass() { delete m_Impl; } public: property String ^ get_PropertyA { String ^ get() { return gcnew String(m_Impl->GetPropertyA()); } } void MethodB(String ^ theString) { pin_ptr<const WCHAR> str = PtrToStringChars(theString); m_Impl->MethodB(str); } int Add(int x, int y) { return m_Impl->Add(x, y); } private: UnmanagedClass * m_Impl; }; }
a31cdc26a9843b809018e0c29f6fa3326874dd5e
2eeab40a405a7b27a52386f52f6f9753672cde78
/OJ_Codes/hacker_cup/2021/2A.cpp
398a3aa50992c5c66ba5bcf6041d69a372489c9c
[]
no_license
rifatr/Competitive-Programming
c562c56f5090b9b76510d8c57e74a2c90d723643
e802d9e73624607904223fddf7f29950fa429341
refs/heads/master
2023-05-24T02:02:56.062656
2023-05-22T08:08:02
2023-05-22T08:08:02
611,465,080
1
0
null
null
null
null
UTF-8
C++
false
false
2,055
cpp
2A.cpp
#include "bits/stdc++.h" #define ll long long #define pb push_back #define ff first #define ss second #define yes cout << "YES\n" #define no cout << "NO\n" #define Case(i) cout << "Case #" << int(i) << ": " #define lop(n) for (int i = 0; i < n; i++) #define lopj(n) for (int j = 0; j < n; j++) #define all(x) x.begin(), x.end() #define sortd(x) sort(x.rbegin(), x.rend()) #define bitcount(x) __builtin_popcount(x) #define vin vector <int> #define vll vector <ll> #define pll pair <ll, ll> #define pii pair <int, int> #define vpii vector <pii> #ifndef ONLINE_JUDGE #include <debug.hpp> #else #define dbg(x) #define ddbg(x) #define dbg2(x, y) #define dbg3(x, y, z) #endif #define sob template < typename T #define sb2 template < typename T, typename TT sob > void print(T x) {std::cout << x << '\n';} sb2 > void print(T x, TT y) {std::cout << x << ' ' << y << '\n';} sb2 > void print(std::pair <T, TT> x) {std::cout << x.ff << ' ' << x.ss << '\n';} sob > void print(std::vector <T> v) {for (auto z : v) std::cout << z << ' '; std::cout << '\n';} sob > void print(T x[], int n) {for (int i = 0; i++ < n;) std::cout << *x++ << (i < n ? ' ' : '\n');} using namespace std; const int N = 1e6 + 10; multiset <pii> a, b; int md[N], of[N], n, m; vpii uu; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int tc, t = 1; cin >> tc; while (tc--) { a.clear(); b.clear(); cin >> m >> n; lop(n) { cin >> md[i]; a.insert({md[i], 0}); } int ans = 0; for (int round = 0; round < m; round++) { lop(n) { cin >> of[i]; auto it = a.lower_bound({of[i], 0}); if (it -> ff == of[i]) { b.insert(*it); a.erase(it); } else { uu.pb({of[i], i}); } } while (uu.size()) { if (a.begin() -> ss) { ans++; } b.insert({uu.back(). ff, uu.back().ff != md[uu.back().ss]}); a.erase(a.begin()); uu.pop_back(); } a = b; b.clear(); } Case(t++); print(ans); } return 0; }
b28b5d5c8c9ab6f188cb4f0eb8a0818b347cfcf3
4f1e906c09f32b9dfe28168448b5a9546d05f6a1
/software/urho3d/game/iceweasel/src/Math.cpp
f1b887c369fcc29d589fe727ef6d8013bc916e54
[]
no_license
TheComet/iceweasel
76c2269ac42d35808b9c78ec9726850d270df0b2
6a386d0a2dfc0ec1695bc786c7b9140abad89e9e
refs/heads/master
2021-09-26T12:46:07.580197
2018-10-30T11:48:20
2018-10-30T11:48:20
62,078,010
11
2
null
null
null
null
UTF-8
C++
false
false
267
cpp
Math.cpp
#include "iceweasel/Math.h" // ---------------------------------------------------------------------------- float Math::Wrap180(float angle) { while(angle < -180.0f) angle += 360.0f; while(angle > 180.0f) angle -= 360.0f; return angle; }
d1a38dcd6c81ce4055a6d28f0094096276683ca8
4bcc9806152542ab43fc2cf47c499424f200896c
/tensorflow/lite/delegates/gpu/common/transformations/add_quant_adjustments.h
6eb4aaaf029e6e0358b3a87d88a8f94692d99523
[ "Apache-2.0", "LicenseRef-scancode-generic-cla", "BSD-2-Clause" ]
permissive
tensorflow/tensorflow
906276dbafcc70a941026aa5dc50425ef71ee282
a7f3934a67900720af3d3b15389551483bee50b8
refs/heads/master
2023-08-25T04:24:41.611870
2023-08-25T04:06:24
2023-08-25T04:14:08
45,717,250
208,740
109,943
Apache-2.0
2023-09-14T20:55:50
2015-11-07T01:19:20
C++
UTF-8
C++
false
false
1,802
h
add_quant_adjustments.h
/* Copyright 2020 The TensorFlow Authors. All 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. ==============================================================================*/ #ifndef TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TRANSFORMATIONS_ADD_QUANT_ADJUSTMENTS_H_ #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TRANSFORMATIONS_ADD_QUANT_ADJUSTMENTS_H_ #include <memory> #include "tensorflow/lite/delegates/gpu/common/model_transformer.h" namespace tflite { namespace gpu { // This pass is used to support inference on quantized models with the GPU // delegate. // // When delegating quantized models, we still run float-point inference on GPU // under-the-hood. This is done by dequantizing inputs (at runtime) & constants // (during delegation). // However, intermediate tensors can still deviate from the original quantized // inference, since activations may not follow the attributes set by the // original quantizion parameters. // To prevent this, we add "QuantizeAndDequantize" nodes for each node-output // that was originally fixed-point: // op1 -> op2 // becomes // op1 -> QuantizeAndDequantize -> op2 std::unique_ptr<NodeTransformation> NewAddQuantAdjustments(); } // namespace gpu } // namespace tflite #endif // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TRANSFORMATIONS_ADD_QUANT_ADJUSTMENTS_H_
c32975085e1bfddd9c17bb846aac822b967c4191
9a3bd642e50f0f954749e5be67d59460ece5be82
/OLDfilez/sorce_workfiles_outdateddec5/main_010.17.cpp
f2c9e1d3c30d5998fa5f8601187a97dd73fabd71
[]
no_license
zeplaz/railhubz
6d4da4e5c02a8c467d5f81c9c84caa04617388bf
607ff22c9bf42b7692f66eeb33e2b2abb97b0aad
refs/heads/master
2022-03-20T20:19:09.593530
2022-02-10T01:07:57
2022-02-10T01:07:57
160,031,932
1
0
null
2022-02-12T19:57:30
2018-12-02T09:27:09
C++
UTF-8
C++
false
false
3,399
cpp
main_010.17.cpp
#include <SFML/Graphics.hpp> #include <SFML/Window.hpp> #include <SFML/System.hpp> #include <SFML/OpenGL.hpp> #include "enity_2test.h" #include "Sym_Map.h" #include "Defined_train_path.h" #include "Base_TSym_entity.h" int main () { int total_ent_count; time_t* main_runtime_o; *main_runtime_o = clock(); //enity_1test takez: /* (time_t* cur_time, int& Total_enty, sf::Vector2f(x,y), startlocation, endlocation) //entity_2_takes; (time_t* cur_time,int total_enty,sf::Vector2f(x,y)); */ //create other needed obejc float x; float y; x=300.f; y=200.f; enity_2test* tst_e1_0 = new enity_1test(main_runtime_o,sf:Vector2f(x,y),total_ent_count); x=40.f; y=70.f; enity_2test* tst_e1_1 = new enity_1test(main_runtime_o,sf:Vector2f(x,y),total_ent_count); x=30.f; y=250.f; enity_2test* tst_e1_2 = new enity_1test(main_runtime_o,sf:Vector2f(x,y),total_ent_count); x=200.f; y=10.f; enity_2test* tst_e1_3 = new enity_1test(main_runtime_o,sf:Vector2f(x,y),total_ent_count); x=400.f; y=30.f; enity_2test* tst_e1_4 = new enity_1test(main_runtime_o,sf:Vector2f(x,y),total_ent_count); /* enity_1test tst_e1_1(); enity_1test tst_e1_2(); enity_1test tst_e1_3(); enity_1test tst_e1_4(); */ //inlization regisation. int entitycount; //std::list<int> enity_1_id_list; std::list<int> enity_2_idlist; sym_manger->Register_entity(tst_e2_0); sym_manger->Register_entity(tst_e2_1); sym_manger->Register_entity(tst_e2_2); sym_manger->Register_entity(tst_e2_3); sym_manger->Register_entity(tst_e2_4); enity_2_id_list.push(tst_e2_0->get_id()); enity_2_id_list.push(tst_e2_1->get_id()); enity_2_id_list.push(tst_e2_2->get_id()); enity_2_id_list.push(tst_e2_3->get_id()); enity_2_id_list.push(tst_e2_4->get_id()); /// Defined_train_path* sher_tro; sher_tro->addhubtoPath(tst_e2_0); sher_tro->addhubtoPath(tst_e2_2); sher_tro->addhubtoPath(tst_e2_3); Defined_train_path* tor_sher; tor_sher->addhubtoPath(tst_e2_0); tor_sher->addhubtoPath(tst_e2_2); tor_sher->addhubtoPath(tst_e2_3); //load data into train int priority01= 1; int priorty02 =3; int priorty03=5; /* tst_e1_0->load_data(priority01,sher_tro); tst_e1_1->load_data(priorty02,tor_sher); tst_e1_2->load_data(priorty03,sher_tro); tst_e1_3->load_data(priorty02,tor_sher); */ //create window and framez sf::RenderWindow window (sf::VideoMode(700,600), "Test_hub1"); window.setFramerateLimit(60); //work /// MAINLOOP while (window.isOpen()) { sf::Event prevent; while (window.pollEvent(prevent)) { {if (prevent.type ==sf::Event::Closed) window.close(); } {if (prevent.type == sf::Event::Resized) glViewport(0, 0, prevent.size.width, prevent.size.height); } } // itraor processing // clear and draw window.clear(); //draw itorarrs for (std::list<int>::iterator it = enity_2_id_list.begin(); it != enity_2_id_list.end(); it++) { enity_2test* tmp_prt_enity2; tmp_prt_enity2 =sym_manger->get_entity_via_id(it); tmp_prt_enity2->draw(window); } window.display(); } // cleanup sym_manger->removeenity(tst_e2_0); sym_manger->removeenity(tst_e2_1); sym_manger->removeenity(tst_e2_2); sym_manger->removeenity(tst_e2_3); sym_manger->removeenity(tst_e2_4); return 0; }
0296e88847f766480a3bc775064dbd0432275483
d3cfaa7be41b70205e027d718f5546723f59906d
/LeetCode/0845. Longest Mountain in Array.cpp
41166f7cc747afc9d1331f0b7b4155024f8893f1
[]
no_license
15757170756/All-Code-I-Have-Done
8836c11ad1648f06cb815ab76f3378cddc41ac63
e8985935efa641e68b76c231dddaf6326e3f3f98
refs/heads/master
2022-12-12T10:01:26.132458
2021-09-02T13:34:00
2021-09-02T13:34:09
111,758,971
9
3
null
2022-12-07T23:30:17
2017-11-23T03:31:03
Jupyter Notebook
UTF-8
C++
false
false
1,672
cpp
0845. Longest Mountain in Array.cpp
/* 845. Longest Mountain in Array User Accepted: 944 User Tried: 1188 Total Accepted: 953 Total Submissions: 3308 Difficulty: Medium Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] (Note that B could be any subarray of A, including the entire array A.) Given an array A of integers, return the length of the longest mountain. Return 0 if there is no mountain. Example 1: Input: [2,1,4,7,3,2,5] Output: 5 Explanation: The largest mountain is [1,4,7,3,2] which has length 5. Example 2: Input: [2,2,2] Output: 0 Explanation: There is no mountain. Note: 0 <= A.length <= 10000 0 <= A[i] <= 10000 */ //two pointers class Solution { public: int longestMountain(vector<int>& A) { int ans = 0; for (int k = 1, i = k, j = k, n = (int)A.size(); k < n - 1; ++k, i = k, j = k) { while (i > 0 && A[i - 1] < A[i]) --i; while (j < n - 1 && A[j] > A[j + 1]) ++j; if (i != k && j != k) ans = max(ans, j - i + 1); } return ans; } }; //O(n^2)time complex //Submission Result: Accepted int longestMountain(vector<int> A) { int N = A.size(), res = 0; vector<int> up(N, 0), down(N, 0); for (int i = N - 2; i >= 0; --i) if (A[i] > A[i + 1]) down[i] = down[i + 1] + 1; for (int i = 0; i < N; ++i) { if (i > 0 && A[i] > A[i - 1]) up[i] = up[i - 1] + 1; if (up[i] && down[i]) res = max(res, up[i] + down[i] + 1); } return res; } //O(n) time complex,O(n) space complex //Submission Result: Accepted
a4dd6aa0770bca407dabf9a0bf0a274ad0f09de5
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/angle/src/tests/gl_tests/SRGBTextureTest.cpp
961ec37ae66ab11be9da50c95863e994e69a6c7b
[ "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
22,282
cpp
SRGBTextureTest.cpp
// // Copyright 2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "test_utils/ANGLETest.h" #include "test_utils/gl_raii.h" namespace angle { // These two colors are equivelent in different colorspaces constexpr GLColor kLinearColor(64, 127, 191, 255); constexpr GLColor kNonlinearColor(13, 54, 133, 255); class SRGBTextureTest : public ANGLETest<> { protected: SRGBTextureTest() { setWindowWidth(128); setWindowHeight(128); setConfigRedBits(8); setConfigGreenBits(8); setConfigBlueBits(8); setConfigAlphaBits(8); } void testSetUp() override { constexpr char kVS[] = "precision highp float;\n" "attribute vec4 position;\n" "varying vec2 texcoord;\n" "\n" "void main()\n" "{\n" " gl_Position = vec4(position.xy, 0.0, 1.0);\n" " texcoord = (position.xy * 0.5) + 0.5;\n" "}\n"; constexpr char kFS[] = "precision highp float;\n" "uniform sampler2D tex;\n" "varying vec2 texcoord;\n" "\n" "void main()\n" "{\n" " gl_FragColor = texture2D(tex, texcoord);\n" "}\n"; mProgram = CompileProgram(kVS, kFS); ASSERT_NE(0u, mProgram); mTextureLocation = glGetUniformLocation(mProgram, "tex"); ASSERT_NE(-1, mTextureLocation); } void testTearDown() override { glDeleteProgram(mProgram); } GLenum getSRGBA8TextureInternalFormat() const { return getClientMajorVersion() >= 3 ? GL_SRGB8_ALPHA8 : GL_SRGB_ALPHA_EXT; } GLenum getSRGBA8TextureFormat() const { return getClientMajorVersion() >= 3 ? GL_RGBA : GL_SRGB_ALPHA_EXT; } GLenum getSRGB8TextureInternalFormat() const { return getClientMajorVersion() >= 3 ? GL_SRGB8 : GL_SRGB_EXT; } GLenum getSRGB8TextureFormat() const { return getClientMajorVersion() >= 3 ? GL_RGB : GL_SRGB_EXT; } GLuint mProgram = 0; GLint mTextureLocation = -1; }; class SRGBTextureTestES3 : public SRGBTextureTest {}; // GenerateMipmaps should generate INVALID_OPERATION in ES 2.0 / WebGL 1.0 with EXT_sRGB. // https://bugs.chromium.org/p/chromium/issues/detail?id=769989 TEST_P(SRGBTextureTest, SRGBValidation) { // TODO(fjhenigman): Figure out why this fails on Ozone Intel. ANGLE_SKIP_TEST_IF(IsOzone() && IsIntel() && IsOpenGLES()); bool supported = IsGLExtensionEnabled("GL_EXT_sRGB") || getClientMajorVersion() == 3; GLuint tex = 0; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); GLubyte pixel[3] = {0}; glTexImage2D(GL_TEXTURE_2D, 0, getSRGB8TextureInternalFormat(), 1, 1, 0, getSRGB8TextureFormat(), GL_UNSIGNED_BYTE, pixel); if (supported) { EXPECT_GL_NO_ERROR(); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSRGB8TextureFormat(), GL_UNSIGNED_BYTE, pixel); EXPECT_GL_NO_ERROR(); // Mipmap generation always generates errors for SRGB unsized in ES2 or SRGB8 sized in ES3. glGenerateMipmap(GL_TEXTURE_2D); EXPECT_GL_ERROR(GL_INVALID_OPERATION); } else { EXPECT_GL_ERROR(GL_INVALID_ENUM); } glDeleteTextures(1, &tex); } TEST_P(SRGBTextureTest, SRGBAValidation) { // TODO(fjhenigman): Figure out why this fails on Ozone Intel. ANGLE_SKIP_TEST_IF(IsOzone() && IsIntel() && IsOpenGLES()); bool supported = IsGLExtensionEnabled("GL_EXT_sRGB") || getClientMajorVersion() == 3; GLuint tex = 0; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); GLubyte pixel[4] = {0}; glTexImage2D(GL_TEXTURE_2D, 0, getSRGBA8TextureInternalFormat(), 1, 1, 0, getSRGBA8TextureFormat(), GL_UNSIGNED_BYTE, pixel); if (supported) { EXPECT_GL_NO_ERROR(); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSRGBA8TextureFormat(), GL_UNSIGNED_BYTE, pixel); EXPECT_GL_NO_ERROR(); glGenerateMipmap(GL_TEXTURE_2D); if (getClientMajorVersion() < 3) { EXPECT_GL_ERROR(GL_INVALID_OPERATION); } else { EXPECT_GL_NO_ERROR(); } } else { EXPECT_GL_ERROR(GL_INVALID_ENUM); } glDeleteTextures(1, &tex); } // Test that sized SRGBA formats allow generating mipmaps TEST_P(SRGBTextureTestES3, SRGBASizedValidation) { // TODO(fjhenigman): Figure out why this fails on Ozone Intel. ANGLE_SKIP_TEST_IF(IsOzone() && IsIntel() && IsOpenGLES()); GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex); GLubyte pixel[4] = {0}; glTexImage2D(GL_TEXTURE_2D, 0, getSRGBA8TextureInternalFormat(), 1, 1, 0, getSRGBA8TextureFormat(), GL_UNSIGNED_BYTE, pixel); EXPECT_GL_NO_ERROR(); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel); EXPECT_GL_NO_ERROR(); glGenerateMipmap(GL_TEXTURE_2D); EXPECT_GL_NO_ERROR(); } TEST_P(SRGBTextureTest, SRGBARenderbuffer) { bool supported = IsGLExtensionEnabled("GL_EXT_sRGB") || getClientMajorVersion() == 3; GLuint rbo = 0; glGenRenderbuffers(1, &rbo); glBindRenderbuffer(GL_RENDERBUFFER, rbo); glRenderbufferStorage(GL_RENDERBUFFER, GL_SRGB8_ALPHA8_EXT, 1, 1); if (supported) { EXPECT_GL_NO_ERROR(); } else { EXPECT_GL_ERROR(GL_INVALID_ENUM); // Make sure the rbo has a size for future tests glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8_OES, 1, 1); EXPECT_GL_NO_ERROR(); } GLuint fbo = 0; glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); EXPECT_GL_NO_ERROR(); GLint colorEncoding = 0; glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT, &colorEncoding); if (supported) { EXPECT_GL_NO_ERROR(); EXPECT_EQ(GL_SRGB_EXT, colorEncoding); } else { EXPECT_GL_ERROR(GL_INVALID_ENUM); } glDeleteFramebuffers(1, &fbo); glDeleteRenderbuffers(1, &rbo); } // Verify that if the srgb decode extension is available, srgb textures are too TEST_P(SRGBTextureTest, SRGBDecodeExtensionAvailability) { bool hasSRGBDecode = IsGLExtensionEnabled("GL_EXT_texture_sRGB_decode"); if (hasSRGBDecode) { bool hasSRGBTextures = IsGLExtensionEnabled("GL_EXT_sRGB") || getClientMajorVersion() >= 3; EXPECT_TRUE(hasSRGBTextures); } } // Test basic functionality of SRGB decode using the texture parameter TEST_P(SRGBTextureTest, SRGBDecodeTextureParameter) { // TODO(fjhenigman): Figure out why this fails on Ozone Intel. ANGLE_SKIP_TEST_IF(IsOzone() && IsIntel() && IsOpenGLES()); ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_sRGB_decode")); GLColor linearColor = kLinearColor; GLColor srgbColor = kNonlinearColor; GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexImage2D(GL_TEXTURE_2D, 0, getSRGBA8TextureInternalFormat(), 1, 1, 0, getSRGBA8TextureFormat(), GL_UNSIGNED_BYTE, &linearColor); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); ASSERT_GL_NO_ERROR(); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, srgbColor, 1.0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, linearColor, 1.0); } // Test basic functionality of SRGB override using the texture parameter TEST_P(SRGBTextureTest, SRGBOverrideTextureParameter) { ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_format_sRGB_override")); GLColor linearColor = kLinearColor; GLColor srgbColor = kNonlinearColor; GLenum internalFormat = getClientMajorVersion() >= 3 ? GL_RGBA8 : GL_RGBA; GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &linearColor); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_NONE); ASSERT_GL_NO_ERROR(); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, linearColor, 1.0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_SRGB); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, srgbColor, 1.0); } // Test that all supported formats can be overridden TEST_P(SRGBTextureTestES3, SRGBOverrideFormats) { ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_format_sRGB_override")); constexpr GLenum possibleFormats[] = {GL_RGB8, GL_RGBA8, GL_COMPRESSED_RGB8_ETC2, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_RGBA_ASTC_4x4, GL_COMPRESSED_RGBA_ASTC_5x4, GL_COMPRESSED_RGBA_ASTC_5x5, GL_COMPRESSED_RGBA_ASTC_6x5, GL_COMPRESSED_RGBA_ASTC_6x6, GL_COMPRESSED_RGBA_ASTC_8x5, GL_COMPRESSED_RGBA_ASTC_8x6, GL_COMPRESSED_RGBA_ASTC_8x8, GL_COMPRESSED_RGBA_ASTC_10x5, GL_COMPRESSED_RGBA_ASTC_10x6, GL_COMPRESSED_RGBA_ASTC_10x8, GL_COMPRESSED_RGBA_ASTC_10x10, GL_COMPRESSED_RGBA_ASTC_12x10, GL_COMPRESSED_RGBA_ASTC_12x12, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_R8, GL_RG8, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT}; for (GLenum format : possibleFormats) { GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexStorage2D(GL_TEXTURE_2D, 1, format, 4, 4); GLenum error = glGetError(); if (error == GL_INVALID_ENUM) { // Format is not supported, we don't require the sRGB counterpart to be supported either continue; } else { ASSERT_EQ(static_cast<GLenum>(GL_NO_ERROR), error); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_NONE); ASSERT_GL_NO_ERROR(); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); drawQuad(mProgram, "position", 0.5f); ASSERT_GL_NO_ERROR(); // Discard result, we are only checking that we don't try to reinterpret to an unsupported // format } } // Test interaction between sRGB_override and sampler objects TEST_P(SRGBTextureTestES3, SRGBOverrideTextureParameterWithSampler) { ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_format_sRGB_override")); GLColor linearColor = kLinearColor; GLColor srgbColor = kNonlinearColor; GLenum internalFormat = getClientMajorVersion() >= 3 ? GL_RGBA8 : GL_RGBA; GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &linearColor); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_NONE); ASSERT_GL_NO_ERROR(); GLSampler sampler; glBindSampler(0, sampler.get()); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, linearColor, 1.0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_SRGB); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, srgbColor, 1.0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_NONE); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, linearColor, 1.0); } // Test that SRGB override is a noop when used on a nonlinear texture format // EXT_texture_format_sRGB_override spec says: // "If the internal format is not one of the above formats, then // the value of TEXTURE_FORMAT_SRGB_OVERRIDE_EXT is ignored." TEST_P(SRGBTextureTestES3, SRGBOverrideTextureParameterNoop) { ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_format_sRGB_override")); ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_sRGB")); GLColor linearColor = kLinearColor; GLColor srgbColor = kNonlinearColor; GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexImage2D(GL_TEXTURE_2D, 0, getSRGBA8TextureInternalFormat(), 1, 1, 0, getSRGBA8TextureFormat(), GL_UNSIGNED_BYTE, &linearColor); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_NONE); ASSERT_GL_NO_ERROR(); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, srgbColor, 1.0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_SRGB); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, srgbColor, 1.0); } // Test basic functionality of SRGB decode using the sampler parameter TEST_P(SRGBTextureTestES3, SRGBDecodeSamplerParameter) { ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_sRGB_decode")); GLColor linearColor = kLinearColor; GLColor srgbColor = kNonlinearColor; GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexImage2D(GL_TEXTURE_2D, 0, getSRGBA8TextureInternalFormat(), 1, 1, 0, getSRGBA8TextureFormat(), GL_UNSIGNED_BYTE, &linearColor); ASSERT_GL_NO_ERROR(); GLSampler sampler; glBindSampler(0, sampler.get()); glSamplerParameteri(sampler.get(), GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, srgbColor, 1.0); glSamplerParameteri(sampler.get(), GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, linearColor, 1.0); } // Toggle between GL_DECODE_EXT and GL_SKIP_DECODE_EXT of sampler parameter // GL_TEXTURE_SRGB_DECODE_EXT TEST_P(SRGBTextureTestES3, SRGBDecodeSamplerParameterToggle) { ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_sRGB_decode")); GLColor linearColor = kLinearColor; GLColor srgbColor = kNonlinearColor; GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexImage2D(GL_TEXTURE_2D, 0, getSRGBA8TextureInternalFormat(), 1, 1, 0, getSRGBA8TextureFormat(), GL_UNSIGNED_BYTE, &linearColor); ASSERT_GL_NO_ERROR(); GLSampler sampler; glBindSampler(0, sampler.get()); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); for (int i = 0; i < 4; i++) { // Toggle betwee decode and skip decode and verify pixel value GLint decode = ((i & 1) == 0) ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT; angle::GLColor &expectedColor = ((i & 1) == 0) ? srgbColor : linearColor; glSamplerParameteri(sampler.get(), GL_TEXTURE_SRGB_DECODE_EXT, decode); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, expectedColor, 1.0); } } // Test that sampler state overrides texture state for srgb decode TEST_P(SRGBTextureTestES3, SRGBDecodeTextureAndSamplerParameter) { ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_sRGB_decode")); GLColor linearColor = kLinearColor; GLColor srgbColor = kNonlinearColor; GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexImage2D(GL_TEXTURE_2D, 0, getSRGBA8TextureInternalFormat(), 1, 1, 0, getSRGBA8TextureFormat(), GL_UNSIGNED_BYTE, &linearColor); ASSERT_GL_NO_ERROR(); GLSampler sampler; glBindSampler(0, sampler.get()); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); glSamplerParameteri(sampler.get(), GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, srgbColor, 1.0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); glSamplerParameteri(sampler.get(), GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, linearColor, 1.0); } // Test that srgb decode state takes priority over srgb override state TEST_P(SRGBTextureTestES3, SRGBDecodeOverridePriority) { ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_sRGB_decode")); ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_format_sRGB_override")); GLColor linearColor = kLinearColor; GLenum internalFormat = getClientMajorVersion() >= 3 ? GL_RGBA8 : GL_RGBA; GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &linearColor); ASSERT_GL_NO_ERROR(); glUseProgram(mProgram); glUniform1i(mTextureLocation, 0); glDisable(GL_DEPTH_TEST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_SRGB); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); drawQuad(mProgram, "position", 0.5f); EXPECT_PIXEL_COLOR_NEAR(0, 0, linearColor, 1.0); } // Test that mipmaps are generated correctly for sRGB textures TEST_P(SRGBTextureTestES3, GenerateMipmaps) { ANGLE_SKIP_TEST_IF(IsOpenGL() && ((IsIntel() && IsOSX()) || IsAMD())); auto createAndReadBackTexture = [this](GLenum internalFormat, const GLColor &color) { constexpr GLsizei width = 128; constexpr GLsizei height = 128; std::array<GLColor, width * height> buf; std::fill(buf.begin(), buf.end(), color); // Set up-left region of the texture as red color. // In order to make sure bi-linear interpolation operates on different colors, red region // is 1 pixel smaller than a quarter of the full texture on each side. constexpr GLsizei redWidth = width / 2 - 1; constexpr GLsizei redHeight = height / 2 - 1; std::array<GLColor, redWidth * redHeight> redBuf; std::fill(redBuf.begin(), redBuf.end(), GLColor::red); GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex.get()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf.data()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, redWidth, redHeight, GL_RGBA, GL_UNSIGNED_BYTE, redBuf.data()); glGenerateMipmap(GL_TEXTURE_2D); constexpr GLsizei drawWidth = 32; constexpr GLsizei drawHeight = 32; glViewport(0, 0, drawWidth, drawHeight); drawQuad(mProgram, "position", 0.5f); std::array<GLColor, drawWidth * drawHeight> result; glReadPixels(0, 0, drawWidth, drawHeight, GL_RGBA, GL_UNSIGNED_BYTE, result.data()); EXPECT_GL_NO_ERROR(); return result; }; GLColor srgbaColor(0, 63, 127, 255); auto srgbaReadback = createAndReadBackTexture(GL_SRGB8_ALPHA8, srgbaColor); GLColor linearColor(0, 13, 54, 255); auto rgbaReadback = createAndReadBackTexture(GL_RGBA8, linearColor); ASSERT_EQ(srgbaReadback.size(), rgbaReadback.size()); for (size_t i = 0; i < srgbaReadback.size(); i++) { constexpr double tolerence = 7.0; EXPECT_COLOR_NEAR(srgbaReadback[i], rgbaReadback[i], tolerence); } } // Test that generated mip levels are correct for solid color textures TEST_P(SRGBTextureTestES3, GenerateMipmapsSolid) { GLColor color(7, 7, 7, 7); std::array<GLColor, 4 * 4> buf; std::fill(buf.begin(), buf.end(), color); GLTexture tex; glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf.data()); glGenerateMipmap(GL_TEXTURE_2D); ASSERT_GL_NO_ERROR(); GLFramebuffer fb; glBindFramebuffer(GL_READ_FRAMEBUFFER, fb); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 1); ASSERT_GL_NO_ERROR(); EXPECT_PIXEL_COLOR_NEAR(0, 0, color, 1); } ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(SRGBTextureTest); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SRGBTextureTestES3); ANGLE_INSTANTIATE_TEST_ES3(SRGBTextureTestES3); } // namespace angle
5a35e76655c3a4eb1116fe23648d9df1b4dcb1a3
144e5ddf006b252cc9b353d41944bdf7e69cf06c
/pdf/pdf_view_web_plugin_unittest.cc
b010445d9b7868a32fe8f9ca701be1f406187909
[ "BSD-3-Clause" ]
permissive
wzis/chromium
6501d10b8239a7289e91b37ea0b4cf6a2120cf36
2de45c79a6fdc461a168158a9001cd9a20f2b9a8
refs/heads/master
2023-03-24T18:11:08.835171
2021-04-29T12:04:55
2021-04-29T12:04:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,493
cc
pdf_view_web_plugin_unittest.cc
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "pdf/pdf_view_web_plugin.h" #include <memory> #include <utility> #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/web/web_plugin_params.h" #include "ui/gfx/geometry/rect.h" namespace chrome_pdf { namespace { class FakeContainerWrapper final : public PdfViewWebPlugin::ContainerWrapper { public: FakeContainerWrapper() = default; FakeContainerWrapper(const FakeContainerWrapper&) = delete; FakeContainerWrapper& operator=(const FakeContainerWrapper&) = delete; ~FakeContainerWrapper() override = default; // PdfViewWebPlugin::ContainerWrapper: void Invalidate() override {} float DeviceScaleFactor() const override { return device_scale_; } blink::WebPluginContainer* Container() override { return nullptr; } void set_device_scale(float device_scale) { device_scale_ = device_scale; } private: float device_scale_ = 1.0f; }; } // namespace class PdfViewWebPluginTest : public testing::Test { public: // Custom deleter for `plugin_`. PdfViewWebPlugin must be destroyed by // PdfViewWebPlugin::Destroy() instead of its destructor. struct PluginDeleter { void operator()(PdfViewWebPlugin* ptr) { ptr->Destroy(); } }; PdfViewWebPluginTest() = default; PdfViewWebPluginTest(const PdfViewWebPluginTest&) = delete; PdfViewWebPluginTest& operator=(const PdfViewWebPluginTest&) = delete; ~PdfViewWebPluginTest() override = default; void SetUp() override { plugin_ = std::unique_ptr<PdfViewWebPlugin, PluginDeleter>( new PdfViewWebPlugin(blink::WebPluginParams())); auto wrapper = std::make_unique<FakeContainerWrapper>(); wrapper_ptr_ = wrapper.get(); plugin_->InitializeForTesting(std::move(wrapper)); } void TearDown() override { plugin_.reset(); wrapper_ptr_ = nullptr; } void TestUpdateGeometrySetsPluginRect(float device_scale, const gfx::Rect& window_rect, const gfx::Rect& expected_plugin_rect) { // The plugin container's device scale must be set before calling // UpdateGeometry(). ASSERT_TRUE(wrapper_ptr_); wrapper_ptr_->set_device_scale(device_scale); plugin_->UpdateGeometry(window_rect, window_rect, window_rect, /*is_visible=*/true); EXPECT_EQ(expected_plugin_rect, plugin_->GetPluginRectForTesting()) << "Failure at device scale of " << device_scale << ", window rect of " << window_rect.ToString(); } FakeContainerWrapper* wrapper_ptr_; std::unique_ptr<PdfViewWebPlugin, PluginDeleter> plugin_; }; TEST_F(PdfViewWebPluginTest, UpdateGeometrySetsPluginRect) { struct UpdateGeometryParams { // The plugin container's device scale. float device_scale; // The window area. gfx::Rect window_rect; // The expected plugin rect. gfx::Rect expected_plugin_rect; }; static constexpr UpdateGeometryParams kUpdateGeometryParams[] = { {1.0f, gfx::Rect(3, 4, 5, 6), gfx::Rect(3, 4, 5, 6)}, {2.0f, gfx::Rect(5, 6, 7, 8), gfx::Rect(10, 12, 14, 16)}, }; for (const auto& params : kUpdateGeometryParams) { TestUpdateGeometrySetsPluginRect(params.device_scale, params.window_rect, params.expected_plugin_rect); } } } // namespace chrome_pdf
ec6b26bb697b6f830a342ddd8ed9f6027f4b86ca
4cb0f2cfb9ec3ec8c851f83ff3ea73ca5a62aa70
/democodebase/pt/d3d9/rendering/source/material_collection.cpp
0f5c7d1a8b62f6a20d35edc783d362b9c1f4fcfe
[]
no_license
Codarki/Pyrotech_2016
99733bb543621d755dc0451cee86e3988021a1e2
5e7a71b9ec751061285f3f784e861ac8f2726ee1
refs/heads/main
2023-05-30T08:11:30.626406
2021-06-24T23:13:53
2021-06-24T23:13:53
380,065,207
0
0
null
null
null
null
UTF-8
C++
false
false
8,468
cpp
material_collection.cpp
#include "material_collection.h" #include "material.h" #include "pt/exceptions/path_file_context.h" #include "pt/any_error.h" #include "pt/config_node.h" #include "pt/log.h" #include "pt/parameter_node_utility.h" #include "pt/format.h" #include "pt/path.h" #include "pt/boost/path.h" #include "pt/directory_iterator.h" #include "pt/boost/filesystem/convenience.h" namespace pt { namespace d3d9 { namespace rendering { namespace source { // material_collection void material_collection::add(pt::path const& path) { try { config_node config(path); for (auto const& child_config : config) { if (child_config.key() == "material") { material_builder builder = create_material_builder(child_config, m_shaders); m_builders.insert(m_builders.end(), builder); } else if (child_config.key() == "light_shader_instances") { for (auto const& light_shader_instance_config : child_config) { assert(light_shader_instance_config.key() == "light_shader_instance"); light_material_builder builder = create_light_material_builder( light_shader_instance_config, m_light_shaders); m_light_builders.push_back(builder); } } } } catch (pt::exceptions::contextual_exception& e) { //auto context = path_file_context e.attach_context(new pt::exceptions::path_file_context(path)); throw; } } std::shared_ptr<material const> material_collection::get( std::string const& name) const { for (auto const& material : m_materials) { if (material->name() == name) return material; } throw any_error(format("Material \"%1%\" not found.") % name); } std::shared_ptr<material> material_collection::populate( parameter_collection const& p3d_parameters, parameter_collection const& shared_parameters, graphics_device& device) { std::shared_ptr<material> result; if (p3d_parameters.empty()) { material_builder* builder = get_builder_by_name("default"); builder->build(parameter_collection(), shared_parameters, device); result = builder->built_material(); } for (auto const& node : p3d_parameters) { if (node->name() == "p3d material") { if (result) { log("multimaterial.."); continue; } std::string p3d_mat_name = constant_value<std::string>(*node); material_builder* builder = get_builder_by_p3d_name(p3d_mat_name); if (!builder) { builder = get_builder_by_name("default"); assert(builder); } //hackkkk if (!builder->built_material()) { builder->build(node->children(), shared_parameters, device); result = builder->built_material(); assert(result); m_materials.push_back(result); } else { result = builder->built_material(); } } } assert(result); return result; } std::shared_ptr<material> material_collection::populate(std::string const& name, parameter_collection const& parameters, parameter_collection const& shared_parameters, graphics_device& device) { std::shared_ptr<material> result; material_builder* builder = get_builder_by_name(name); assert(builder); builder->build(parameters, shared_parameters, device); result = builder->built_material(); assert(result); m_materials.push_back(result); return result; } std::shared_ptr<light_material> material_collection::populate_light( parameter_collection const& p3d_parameters, parameter_collection const& shared_parameters, graphics_device& device) { std::shared_ptr<light_material> result; assert(!p3d_parameters.empty()); //if (p3d_parameters.empty()) //{ // light_material_builder* builder = get_light_builder_by_name("default"); // builder->build(parameter_collection(), shared_parameters, device); // result = builder->built_material(); //} for (auto const& node : p3d_parameters) { if (node->name() == "light_shader_instance_name") { if (result) { log("multimaterial.."); continue; } std::string light_material_name = constant_value<std::string>(*node); light_material_builder* builder = get_light_builder_by_name(light_material_name); if (!builder) { builder = get_light_builder_by_name("default_point_light"); assert(builder); } //hackkkk if (!builder->built_material()) { builder->build(node->children(), shared_parameters, device); result = builder->built_material(); assert(result); m_light_materials.push_back(result); } else { result = builder->built_material(); } } } assert(result); return result; } /// Returns material builder which has p3d material linked as source. material_builder* material_collection::get_builder_by_p3d_name( std::string const& name) { for (auto& builder : m_builders) { if (builder.p3d_material_name() == name) return &builder; } log(format("Warning: Material linked to p3d material \"%1%\" not found.") % name); return 0; } /// Returns material builder which builds materials with \a name. material_builder* material_collection::get_builder_by_name( std::string const& name) { for (auto& builder : m_builders) { log(format("Material builder: \"%1%\"") % builder.name()); if (builder.name() == name) return &builder; } log(format("Warning: Material builder for material \"%1%\" not found.") % name); return 0; } /// Returns light material builder which builds materials with \a name. light_material_builder* material_collection::get_light_builder_by_name( std::string const& name) { for (auto& builder : m_light_builders) { log(format("Light material builder: \"%1%\"") % builder.name()); if (builder.name() == name) return &builder; } log(format("Warning: Light material builder for material \"%1%\" not found.") % name); return 0; } std::shared_ptr<material> material_collection::try_get(std::string const& name) { for (auto const& material_ptr : m_materials) { if (material_ptr->name() == name) return material_ptr; } return nullptr; } // free functions namespace { /// Recursively loads material descriptions under \a path into \a materials. void load_materials(boost::filesystem::path const& path, material_collection& materials) { // directory_iterator default construction yields past-the-end pt::directory_iterator end_iter; log(format("load_materials path: \"%1%\" ") % path.string()); for (pt::directory_iterator itr(path); itr != end_iter; ++itr) { log(format("->: \"%1%\" ") % itr->string()); //const std::string *str = (const std::string *)&(*itr); //if (strncmp(str->c_str(), "data/materials", strlen("data/materials")) != 0) //{ // log("break;"); // break; //} if (boost::filesystem::is_directory(*itr)) { load_materials(*itr, materials); continue; } if (itr->extension() == ".xml") { materials.add(pt::path(itr->string())); } } } } // anonymous namespace /// Returns all materials under \a path. std::unique_ptr<material_collection> load_materials(pt::path const& path) { auto new_materials = std::make_unique<material_collection>(); load_materials(boost::filesystem::path(path.string()), *new_materials); return new_materials; } }}}} // namespace pt::d3d9::rendering::source
cbca153c111019d09de0b3c0e59068ef0105b295
b6ed93d36e53f20e9d5a082146c8eb86a8812175
/FinalProject/disease.cpp
73ea32210ed11bad2f0cbb1a6f9b2ec1655b8bdc
[]
no_license
Jphsx/PHSX815
964c9b058b95ad61963baaaa9f1949c6ddca9e72
9143d17cb0b14c4d408c868c61f0f6e663b05245
refs/heads/master
2021-01-10T15:54:33.561758
2017-01-28T02:15:59
2017-01-28T02:15:59
50,152,615
0
0
null
2016-02-09T09:37:23
2016-01-22T02:41:57
C++
UTF-8
C++
false
false
597
cpp
disease.cpp
#include "disease.h" disease::disease(int mode, double parameter, double infectedDays){ if(mode == 0){ SpatiallyCertain = true; SpatiallyProbable = false; criticalAngle = parameter; } else{ SpatiallyCertain = false; SpatiallyProbable = true; resolutionParameter = parameter; } daysOfInfection = infectedDays; } double disease::getInfectionProbability(double angle){ if(SpatiallyCertain){ if(angle <= criticalAngle) return 1; else return 0; } else{ return exp(-0.5*pow(angle/resolutionParameter,2) ); } } double disease::getDaysOfInfection(){ return daysOfInfection; }
aa29117622eeddf5c5ee84b82ed0afc0d1799429
f7f09782d15ee7bdd14e637bd717dfb8327bc57c
/2014Train/TreeDivide/C.cpp
b1e281cc75ba4d7c390ad48f2047d642fa42f981
[]
no_license
whywhyzhang/ACM-ICPC-Code
14f3f6b0532c18da9694d7f70914a97e0983913f
d15bd475774ff104ebfe9504f8ea0acffdb5ddb0
refs/heads/master
2022-12-09T06:27:14.893967
2017-03-09T14:31:49
2017-03-09T14:31:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,459
cpp
C.cpp
// ━━━━━━神兽出没━━━━━━ // ┏┓ ┏┓ // ┏┛┻━━━━━━━┛┻┓ // ┃ ┃ // ┃ ━ ┃ // ████━████ ┃ // ┃ ┃ // ┃ ┻ ┃ // ┃ ┃ // ┗━┓ ┏━┛ // ┃ ┃ // ┃ ┃ // ┃ ┗━━━┓ // ┃ ┣┓ // ┃ ┏┛ // ┗┓┓┏━━━━━┳┓┏┛ // ┃┫┫ ┃┫┫ // ┗┻┛ ┗┻┛ // // ━━━━━━感觉萌萌哒━━━━━━ // Author : WhyWhy // Created Time : 2015年11月04日 星期三 21时38分20秒 // File Name : C.cpp #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <time.h> #pragma comment(linker,"/STACK:102400000,102400000") using namespace std; const int MaxN=100005; const int mod=1000000+3; struct Edge { int to,next; }; Edge E[MaxN<<1]; int head[MaxN],Ecou; long long v[MaxN]; bool vis[MaxN]; int sumnode; int rsize[MaxN]; int cen,minncen; int N,K; int rem1,rem2; void addEdge(int u,int v) { E[Ecou].to=v; E[Ecou].next=head[u]; head[u]=Ecou++; } int dfsCen(int u,int pre) { int ret=1,maxn=0,t; for(int i=head[u];i!=-1;i=E[i].next) if(!vis[E[i].to] && E[i].to!=pre) { t=dfsCen(E[i].to,u); maxn=max(maxn,t); ret+=t; } maxn=max(maxn,sumnode-ret); if(maxn<minncen) { minncen=maxn; cen=u; } return ret; } int getCenter(int u) { minncen=0x3f3f3f3f; dfsCen(u,-1); return cen; } int nvis[1000006],flag=1; int trem[1000006]; int num[MaxN],nid[MaxN],len; long long INV[1000006]; long long inv(long long a,long long m) { if(INV[a]) return INV[a]; if(a==1) return 1; INV[a]=inv(m%a,m)*(m-m/a)%m; return INV[a]; } int dfsCal(int u,int pre,long long k) { (k*=v[u])%=mod; num[len]=k; nid[len++]=u; int ret=1; for(int i=head[u];i!=-1;i=E[i].next) if(!vis[E[i].to] && E[i].to!=pre) ret+=dfsCal(E[i].to,u,k); return ret; } void update(int a,int b) { if(a>b) swap(a,b); if(rem1==-1 || a<rem1 || (a==rem1 && b<rem2)) { rem1=a; rem2=b; } } void calc(int u) { long long t,temp; int a,b; ++flag; nvis[1]=flag; trem[1]=u; for(int i=head[u],j=0;i!=-1;i=E[i].next) if(!vis[E[i].to]) { len=0; rsize[j++]=dfsCal(E[i].to,u,1); for(int k=0;k<len;++k) { t=inv((num[k]*v[u])%mod,mod); if(nvis[temp=(t*K)%mod]==flag) update(nid[k],trem[temp]); } for(int k=0;k<len;++k) { if(nvis[num[k]]!=flag) { nvis[num[k]]=flag; trem[num[k]]=nid[k]; } else trem[num[k]]=min(trem[num[k]],nid[k]); } } } void getans(int u) { int c=getCenter(u); vis[c]=1; calc(c); for(int i=head[c],j=0;i!=-1;i=E[i].next) if(!vis[E[i].to]) { sumnode=rsize[j++]; getans(E[i].to); } } int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int a,b; while(~scanf("%d %d",&N,&K)) { Ecou=0; for(int i=1;i<=N;++i) scanf("%I64d",v+i),head[i]=-1,vis[i]=0; //for(int i=1;i<=N;++i) scanf("%lld",v+i); for(int i=1;i<N;++i) { scanf("%d %d",&a,&b); addEdge(a,b); addEdge(b,a); } rem1=-1; sumnode=N; getans(1); if(-1==rem1) puts("No solution"); else printf("%d %d\n",rem1,rem2); } return 0; }
4966478ba689bbed9b19151959ec1daf12d93ef6
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_2463486_0/C++/petrzlen/Fair-and-Square.cpp
9b69687ebfff2062176dcfe012f946214824635c
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,278
cpp
Fair-and-Square.cpp
#include <iostream> #include <vector> #include <cstdio> #include <algorithm> #include <set> #include <string> #include <map> #include <cmath> using namespace std; #define REP(i, to) for(int i=0; i<to; i++) typedef long long int LLI; string toDigits(LLI n){ string result; while(n>0){ result += (char)('0' + (n%10)); n /= 10; } reverse(result.begin(), result.end()); return result; } bool isPalindrome(LLI n){ string D = toDigits(n); REP(i, D.size()/2) if(D[i] != D[D.size()-1-i]) return false; return true; } struct classcomp{ bool operator() (const string& s1, const string& s2) const{ if(s1.size() != s2.size()) return s1.size() < s2.size(); return s1 < s2; } }; int main() { map<string, int, classcomp> M; int id=1; for(LLI s=1 ; s <= 10000000 ; s++){ if(isPalindrome(s) && isPalindrome(s*s)){ M[toDigits(s*s)]=id++; //cout << s << "=>" << s*s << endl; } } M["12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"]=id++; int T; cin >> T; REP(t, T){ string A, B; cin >> A >> B; cout << "Case #" << t+1 << ": " << M.upper_bound(B)->second - M.lower_bound(A)->second << endl; } return 0; }
72dd14e7fad79ad724067a3501f5c863f24a1f7f
a4b7ff2e44c4582d6c39ae09714ed7a2bd977eb2
/soa/service/rest_service_endpoint.h
94f2066886accd5dfe1665c32000bea85a3dded8
[ "Apache-2.0" ]
permissive
datacratic/DasDB
01f122911e644038d891a70a09d0411acbd5030b
5ccc1fc7c6c69c97e3dae0e02bb4009f95908d3b
refs/heads/master
2021-01-23T14:57:12.091421
2014-08-13T14:05:30
2014-08-13T14:05:30
22,917,273
3
1
null
null
null
null
UTF-8
C++
false
false
10,094
h
rest_service_endpoint.h
/* json_service_endpoint.h -*- C++ -*- Jeremy Barnes, 9 November 2012 Copyright (c) 2012 Datacratic. All rights reserved. */ #ifndef __service__zmq_json_endpoint_h__ #define __service__zmq_json_endpoint_h__ #include "zmq_endpoint.h" #include "jml/utils/vector_utils.h" #include "http_named_endpoint.h" namespace Datacratic { /*****************************************************************************/ /* REST REQUEST */ /*****************************************************************************/ struct RestRequest { RestRequest() { } RestRequest(const HttpHeader & header, const std::string & payload) : header(header), verb(header.verb), resource(header.resource), params(header.queryParams), payload(payload) { } RestRequest(const std::string & verb, const std::string & resource, const RestParams & params, const std::string & payload) : verb(verb), resource(resource), params(params), payload(payload) { } HttpHeader header; std::string verb; std::string resource; RestParams params; std::string payload; }; std::ostream & operator << (std::ostream & stream, const RestRequest & request); /*****************************************************************************/ /* REST SERVICE ENDPOINT */ /*****************************************************************************/ /** This class exposes an API for a given service via: - zeromq - http It allows both synchronous and asynchronous responses. The location of the endpoints are published via a configuration service (usually Zookeeper). */ struct RestServiceEndpoint: public MessageLoop { /** Start the service with the given parameters. If the ports are given, then the service will bind to those specific ports for the given endpoints, and so no service discovery will need to be done. */ RestServiceEndpoint(std::shared_ptr<zmq::context_t> context); virtual ~RestServiceEndpoint(); void shutdown(); /** Defines a connection: either a zeromq connection (identified by its zeromq identifier) or an http connection (identified by its connection handler object). */ struct ConnectionId { /// Don't initialize for now ConnectionId() { } /// Initialize for zeromq ConnectionId(const std::string & zmqAddress, const std::string & requestId, RestServiceEndpoint * endpoint) : itl(new Itl(zmqAddress, requestId, endpoint)) { } /// Initialize for http ConnectionId(std::shared_ptr<HttpNamedEndpoint::RestConnectionHandler> http, const std::string & requestId, RestServiceEndpoint * endpoint) : itl(new Itl(http, requestId, endpoint)) { } struct Itl { Itl(std::shared_ptr<HttpNamedEndpoint::RestConnectionHandler> http, const std::string & requestId, RestServiceEndpoint * endpoint) : requestId(requestId), http(http), endpoint(endpoint), responseSent(false), startDate(Date::now()), chunkedEncoding(false), keepAlive(true) { } Itl(const std::string & zmqAddress, const std::string & requestId, RestServiceEndpoint * endpoint) : zmqAddress(zmqAddress), requestId(requestId), http(0), endpoint(endpoint), responseSent(false), startDate(Date::now()), chunkedEncoding(false), keepAlive(true) { } ~Itl() { if (!responseSent) throw ML::Exception("no response sent on connection"); } std::string zmqAddress; std::string requestId; std::shared_ptr<HttpNamedEndpoint::RestConnectionHandler> http; RestServiceEndpoint * endpoint; bool responseSent; Date startDate; bool chunkedEncoding; bool keepAlive; /** Data that is maintained with the connection. This is where control data required for asynchronous or long-running connections can be put. */ std::vector<std::shared_ptr<void> > piggyBack; }; std::shared_ptr<Itl> itl; void sendResponse(int responseCode, const char * response, const std::string & contentType) const { return sendResponse(responseCode, std::string(response), contentType); } /** Send the given response back on the connection. */ void sendResponse(int responseCode, const std::string & response, const std::string & contentType) const; /** Send the given response back on the connection. */ void sendResponse(int responseCode, const Json::Value & response, const std::string & contentType = "application/json") const; void sendResponse(int responseCode) const { return sendResponse(responseCode, "", ""); } void sendRedirect(int responseCode, const std::string & location) const; /** Send an HTTP-only response with the given headers. If it's not an HTTP connection, this will fail. */ void sendHttpResponse(int responseCode, const std::string & response, const std::string & contentType, const RestParams & headers) const; enum { UNKNOWN_CONTENT_LENGTH = -1, CHUNKED_ENCODING = -2 }; /** Send an HTTP-only response header. This will not close the connection. A contentLength of -1 means don't send it (for when the content length is not known ahead of time). A contentLength of -2 means used HTTP chunked transfer encoding */ void sendHttpResponseHeader(int responseCode, const std::string & contentType, ssize_t contentLength, const RestParams & headers = RestParams()) const; /** Send a payload (or a chunk of a payload) for an HTTP connection. */ void sendPayload(const std::string & payload); /** Finish the response, recycling or closing the connection. */ void finishResponse(); /** Send the given error string back on the connection. */ void sendErrorResponse(int responseCode, const std::string & error, const std::string & contentType) const; void sendErrorResponse(int responseCode, const char * error, const std::string & contentType) const { sendErrorResponse(responseCode, std::string(error), "application/json"); } void sendErrorResponse(int responseCode, const Json::Value & error) const; }; void init(std::shared_ptr<ConfigurationService> config, const std::string & endpointName, double maxAddedLatency = 0.005, int numThreads = 1); /** Bind to TCP/IP ports. There is one for zeromq and one for http. */ std::pair<std::string, std::string> bindTcp(PortRange const & zmqRange = PortRange(), PortRange const & httpRange = PortRange(), std::string host = ""); /** Bind to a fixed URI for the HTTP endpoint. This will throw an exception if it can't bind. example address: "*:4444", "localhost:8888" */ std::string bindFixedHttpAddress(std::string host, int port) { return httpEndpoint.bindTcpFixed(host, port); } std::string bindFixedHttpAddress(std::string address) { return httpEndpoint.bindTcpAddress(address); } /// Request handler function type typedef std::function<void (ConnectionId connection, RestRequest request)> OnHandleRequest; OnHandleRequest onHandleRequest; /** Handle a request. Default implementation defers to onHandleRequest. Otherwise this method should be overridden. */ virtual void handleRequest(const ConnectionId & connection, const RestRequest & request) const; ZmqNamedEndpoint zmqEndpoint; HttpNamedEndpoint httpEndpoint; std::function<void (const ConnectionId & conn, const RestRequest & req) > logRequest; std::function<void (const ConnectionId & conn, int code, const std::string & resp, const std::string & contentType) > logResponse; void doHandleRequest(const ConnectionId & connection, const RestRequest & request) { if (logRequest) logRequest(connection, request); handleRequest(connection, request); } // Create a random request ID for an HTTP request std::string getHttpRequestId() const; /** Log all requests and responses to the given stream. This function will overwrite logRequest and logResponse with new handlers. */ void logToStream(std::ostream & stream); }; } // namespace Datacratic #endif /* __service__zmq_json_endpoint_h__ */
a17146f3061dff9f0058fe5a2c0077c7becf26db
6f32307e81d264da66e47311faba4f54236b988e
/LoveLiveWallpaper/src/Vector.cpp
0db33cd7199bfc915140e02e9e4abd2712a176b5
[ "MIT" ]
permissive
Juvwxyz/LoveLiveWallpaper
60883f435b92b4e789026656afd10929ba094dfb
a0eeac941b5ccd53af538192cb92b7df049839c4
refs/heads/master
2023-03-15T17:37:02.955884
2020-05-14T13:10:23
2020-05-14T13:10:23
256,424,461
4
1
null
null
null
null
UTF-8
C++
false
false
1,680
cpp
Vector.cpp
#include "Vector.h" #include "Matrix.h" using namespace ::DirectX; namespace LLWP { Vector::Vector(float a, float b, float c): vec{ a, b, c, 1 } { } Vector::Vector(DirectX::FXMVECTOR& v) : vec(v) { } float Vector::x() const { return DirectX::XMVectorGetX(vec); } float Vector::y() const { return DirectX::XMVectorGetY(vec); } float Vector::z() const { return DirectX::XMVectorGetZ(vec); } Vector::operator DirectX::XMVECTOR() const { return vec; } Vector Vector::operator+(const Vector& right) { return XMVectorAdd(vec, right.vec); } Vector& Vector::operator+=(const Vector& d) { vec = XMVectorAdd(vec, d.vec); return *this; } Vector& Vector::operator*=(float s) { vec = XMVectorScale(vec, s); return *this; } Vector& Vector::operator*=(const Matrix& m) { vec = XMVector3Transform(vec, m); return *this; } Vector Vector::operator*(const Matrix& m) { return DirectX::XMVector3Transform(*this, m); } Vector Vector::operator*(float f) { return DirectX::XMVectorScale(*this, f); } Vector Vector::operator*(const Vector& v) { return DirectX::XMVectorMultiply(*this, v); } Vector Vector::operator-() { return XMVectorScale(vec, -1); } Vector::~Vector() { } Vector operator/(float f, Vector vec) { return Vector{ f / vec.x(), f / vec.y(), f / vec.z() }; } Vector operator/(Vector vec, float f) { return XMVectorScale(vec, 1.f / f); } }
de2eaa0d7f9656e7d61f12b9792fe73316e8b8e2
c8fcc1acf73585045a5c7213cfb9f90e4c1e809e
/POJ/2376.cpp
ffb3b7eeaff1881d6aeee36c448cfabe36707355
[]
no_license
Jonariguez/ACM_Code
6db4396b20d0b0aeef30e4d47b51fb5e3ec48e03
465a11746d577197772f64aa11209eebd5bfcdd3
refs/heads/master
2020-03-24T07:09:53.482953
2018-11-19T09:21:33
2018-11-19T09:21:33
142,554,816
3
0
null
null
null
null
GB18030
C++
false
false
1,886
cpp
2376.cpp
/**************** *PID:poj2376 *Auth:Jonariguez ***************** 贪心 先安排第一个牛,然后找下一个出了目前范围的牛,此时 找到之前的结束最后的牛(用优先队列维护)来接上 接不上则无解 */ #include <stdio.h> #include <string.h> #include <math.h> #include <queue> #include <vector> #include <algorithm> using namespace std; const int maxn=25000+10; struct pp{ int x,y; bool operator < (const pp &r) const { return y<r.y; } }s[maxn]; int cmp(const pp &a,const pp &b){ // if(a.x==b.x) // return a.y>b.y; return a.x<b.x; } int main() { int i,j,res,n,T; scanf("%d%d",&n,&T); for(i=0;i<n;i++) scanf("%d%d",&s[i].x,&s[i].y); sort(s,s+n,cmp); // for(i=0;i<n;i++) // printf("%d %d\n",s[i].x,s[i].y); priority_queue<pp> que; if(s[0].x!=1){ //最小的不是总1开始的则无解 printf("-1\n");return 0; } res=1; int now=s[0].y; //先选第一个 int flag=1; for(i=1;i<n;i++){ if(s[i].x<=now+1) //还在上一个牛的范围内或相邻一个 que.push(s[i]); else { pp u; if(que.empty()){ //中间需要牛时并没有牛则无解 flag=0;break; } u=que.top();que.pop(); if(u.y<s[i].x-1){ flag=0;break; } now=u.y; que.push(s[i]); res++; } } if(!flag) printf("-1\n"); else { if(now!=T){ if(que.empty()) printf("-1\n"); //最后没能达到最后则无解 else { pp u=que.top(); if(u.y!=T) printf("-1\n"); //加上之后仍不到则无解 else printf("%d\n",res+1); } }else printf("%d\n",res); } return 0; }
e038e5fec3902725bcc087e6f0f668cabd860ed5
e45026c3d9aeec954bc6a52729e0166212471859
/luogu/p1141/p1141.cpp
5a5c9c52850e9730e513dca1f874cfb2e8f5ab8e
[]
no_license
refervl/PracticeCode
1b972e6d264e9862afef927f6f5bc7b1a4f5f78f
25688ba710f3b47c364b20fcb0f7b07deb2587c6
refs/heads/master
2020-07-06T21:00:52.922996
2019-08-24T14:00:56
2019-08-24T14:00:56
203,136,354
0
0
null
null
null
null
UTF-8
C++
false
false
1,359
cpp
p1141.cpp
#include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<queue> using namespace std; #define _for(i,a,b) for(int (i) = (a);i<(b);++i) #define _rep(i,a,b) for(int (i)= (a);i<=(b);++i) #define LL long long #define INI(x) memset(x,0,sizeof(x)) struct point{ int x,y; }; queue<point> q; int way[5][3] = {{1,0},{-1,0},{0,1},{0,-1}}; char map[1005][1005]; int v[1005][1005],ans[1005][1005],ans1[1000005]; int main(){ INI(map); INI(ans); INI(ans1); int n,m; int p=1; scanf("%d%d",&n,&m); _rep(i,1,n) _rep(j,1,n) scanf("%c",&map[i][j]); _rep(i,1,n) _rep(j,1,n) printf("%c",map[i][j]); _for(i,0,m){int x1,y1; scanf("%d%d",&x1,&y1); if(ans[x1][y1]!=0) {printf("%d\n",ans1[ans[x1][y1]]+1);continue;} point P; P.x = x1;P.y = y1; int count = 0; q.push(P); v[P.x][P.y]= 1; ans[P.x][P.y]=p; while(!q.empty()){ point tt = q.front(),t1; q.pop(); _for(i,0,4){ if(map[tt.x+way[i][0]][tt.y+way[i][1]]==map[tt.x][tt.y]) continue; if(tt.x+way[i][0]>n||tt.x+way[i][0]<=0) continue; if(tt.y+way[i][1]>n||tt.y+way[i][1]<=0) continue; if(v[tt.x+way[i][0]][tt.y+way[i][1]]!=0) continue; t1.x = tt.x+way[i][0];t1.y = tt.y+way[i][1]; count++; v[t1.x][t1.y]= 1; ans[t1.x][t1.y] = p; q.push(t1); } } ans1[p++] = count; printf("%d\n",count+1); } return 0; }
3115b667fbc2fa9ce2c860db17bb24c636eea1b6
a57acc31981ecce13e8a16db0de3b2b54a10169a
/module03/ex01/main.cpp
14868942663bfb7999a74e1881a8e73376f73bb7
[]
no_license
alan-pires/CPP
3ce86e8adabad3b373b67c04d2ed4dd4f48cd32a
82b0bb9e8126e3f43ebbb15aba0f65d12e2ca635
refs/heads/main
2023-03-18T14:19:04.682436
2021-01-28T13:51:40
2021-01-28T13:51:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,822
cpp
main.cpp
/* ************************************************************************** */ /* */ /* :::::::: */ /* main.cpp :+: :+: */ /* +:+ */ /* By: qli <qli@student.codam.nl> +#+ */ /* +#+ */ /* Created: 2020/11/28 20:31:44 by qli #+# #+# */ /* Updated: 2020/11/28 20:31:44 by qli ######## odam.nl */ /* */ /* ************************************************************************** */ #include <iostream> #include "FragTrap.hpp" #include "ScavTrap.hpp" int main() { { FragTrap fragTrap("human"); FragTrap fragTrap1 = fragTrap; fragTrap1.rangedAttack("unicorn"); fragTrap1.meleeAttack("dog"); fragTrap1.takeDamage(10); fragTrap1.beRepaired(10); fragTrap1.beRepaired(60); fragTrap1.vaulthunter_dot_exe("cat"); fragTrap1.vaulthunter_dot_exe("fish"); fragTrap1.vaulthunter_dot_exe("rabbit"); fragTrap1.vaulthunter_dot_exe("dolphin"); fragTrap1.vaulthunter_dot_exe("octopus"); } std::cout << "------------------------------------------" << std::endl; { ScavTrap scavTrap("human2"); ScavTrap scavTrap1 = scavTrap; scavTrap1.rangedAttack("unicorn"); scavTrap1.meleeAttack("dog"); scavTrap1.takeDamage(10); scavTrap1.beRepaired(10); scavTrap1.beRepaired(60); scavTrap1.challengeNewcomer(); scavTrap1.challengeNewcomer(); scavTrap1.challengeNewcomer(); } return 0; }
7f45167c7fa30b702f733c923281fa205614957b
8ebf327f53c2e26a937fca97384388e260af617f
/src/Random.h
316ddc9785449ab901f2d7e6593c87046ff8f713
[]
no_license
bratek20/RCG
0369432c04060d17d013c0ff440fe287d09b6456
930f8c15f700260c7fbdd5a53fea42a107aaa95e
refs/heads/master
2020-04-27T13:28:26.645702
2019-06-11T13:40:40
2019-06-11T13:40:40
174,371,250
0
0
null
null
null
null
UTF-8
C++
false
false
658
h
Random.h
#ifndef RANDOM_H #define RANDOM_H #include <random> #include <glm/glm.hpp> #include <memory> class Triangle; using TrianglePtr = const Triangle*; class Random { static std::default_random_engine generator; public: static float uniform(float a = 0.0f, float b = 1.0f); static bool tossCoin(float winProbability); static glm::vec3 vectorOnHemisphereUniform(glm::vec3 normal = glm::vec3(0, 1, 0)); static glm::vec3 vectorOnHemisphereCos(glm::vec3 normal = glm::vec3(0, 1, 0)); static glm::vec3 pointInTriangle(TrianglePtr triangle); private: static glm::vec3 rotateToGlobalSpace(glm::vec3 vec, glm::vec3 globalNormal); }; #endif
9cdea828531d9519530d2f54a7cd3342217a5bd0
fce9da7922fead6082fde2f2e31dc1df07d756e4
/ABC/116/D/main.cpp
0b087c827f546385417326a08734d6a7563e4613
[]
no_license
kraquos/AtCoder
df0a82171cbe04a193e0fa312899c1c05d28c23d
4b73be2ba56b510f3349dc3e48276720e8980a0e
refs/heads/master
2020-06-11T10:03:54.909914
2019-09-09T07:56:28
2019-09-09T07:56:28
193,923,921
0
0
null
null
null
null
UTF-8
C++
false
false
1,378
cpp
main.cpp
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <queue> #define rep(i,n) for(int i=0;i<n;i++) #define ll long long int #define MAX 1000000007 using namespace std; bool comp(pair<ll,ll> a, pair<ll,ll> b){ return a.second > b.second; } int main(void){ ll n,k; cin>>n>>k; vector<pair<ll,ll> > sushi(n); rep(i,n)cin>>sushi[i].first>>sushi[i].second; sort(sushi.begin(), sushi.end(),comp); //rep(i,n)cout<<sushi[i].first<<","<<sushi[i].second<<endl; //最初のポイントの計算 ll ans=0,base=0; ll num[n+1]; rep(i,n)num[i+1]=0; rep(i,k){ base+=sushi[i].second; num[sushi[i].first]++; } ll kind=0; rep(i,n) if(num[i+1]!=0)kind++; ans=base+kind*kind; //kind種類の寿司が入ってる時の最大値 ll pivot=k; //i個目を抜いて新しい種類を入れて高いスコアが出せるか for(int i=k-1;i>-1;i--){ //2個以上でなければ取る意味ない if(num[sushi[i].first]>=2){ for(;pivot<n;pivot++){ //新しい種類しか取る必要なし if(num[sushi[pivot].first]==0){ base = base-sushi[i].second+sushi[pivot].second; kind++; //cout<<"base: "<<base<<",kind: "<<kind<<endl; if(ans < base+kind*kind)ans = base+kind*kind; num[sushi[i].first]--; num[sushi[pivot].first]++; pivot++; break; } } } } cout<<ans<<endl; return 0; }
2906cb385fae9c4dddc32fdc0e87f48b459313a0
a8ee46d4e8ad7f02f92a49b0dec6b694122b9e9a
/Dll_export_1/a_dll.cpp
23038ee9bebd1b6a2906b9e343e89425e4297745
[]
no_license
wolflog/Develop
6ddc03224a71169d2900d2fe1835d71c333f790a
c884050621f8ab03c1d1dfdb19fa8ce1a46bf685
refs/heads/master
2021-06-09T14:12:17.306275
2016-12-05T15:29:19
2016-12-05T15:29:19
75,639,185
0
0
null
null
null
null
UTF-8
C++
false
false
98
cpp
a_dll.cpp
#include "a_dll.h" YL_FIRST_API int first_test_dll_fuction(int a, int b) { return a > b? a:b; }
be88daa3bf695b3e28f9d896620e6575a977e09e
73c8a3179b944b63b2a798542896e4cdf0937b6e
/UVA/MischeavousChildren.cpp
cd5c9e067fafd9732f6e7e482a57f6b0291029d0
[ "Apache-2.0" ]
permissive
aajjbb/contest-files
c151f1ab9b562ca91d2f8f4070cb0aac126a188d
71de602a798b598b0365c570dd5db539fecf5b8c
refs/heads/master
2023-07-23T19:34:12.565296
2023-07-16T00:57:55
2023-07-16T00:57:59
52,963,297
2
4
null
2017-08-03T20:12:19
2016-03-02T13:05:25
C++
UTF-8
C++
false
false
1,069
cpp
MischeavousChildren.cpp
#include <bits/stdc++.h> template<typename T> T gcd(T a, T b) { if(!b) return a; return gcd(b, a % b); } template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } int in() { int x; scanf("%d", &x); return x; } using namespace std; #ifdef ONLINE_JUDGE #define debug(args...) #else #define debug(args...) fprintf(stderr,args) #endif typedef long long Int; typedef unsigned long long uInt; typedef unsigned uint; int N; string S; Int fat(int x) { Int ans = 1LL; for (int i = 2; i <= x; i++) { ans *= (Int) i; } return ans; } int main(void) { cin >> N; for (int t = 1; t <= N; t++) { cin >> S; vector<int> seen(26, 0); for (int i = 0; i < (int) S.size(); i++) { seen[S[i] - 'A'] += 1; } Int ans = fat(S.size()); for (int i = 0; i < 26; i++) { if (seen[i] >= 2) { ans /= fat(seen[i]); } } cout << "Data set " << t << ": " << ans << "\n"; } return 0; }
30c0488d12dc17b62d59b3b229b669be29fce12b
2b3993ba8056a3fee109e0088cc8b6a547a10301
/RegistryTime/DateTimeDlg.cpp
79703167c25ad1523f359ccba6d0f8f0fefbf20e
[]
no_license
RickLeinecker/RegistryTime
e8e7b78065fdef266600f596abf4dc367adff5c4
53725c9b4d721e06a456af4e25e910ec090adaa9
refs/heads/master
2020-08-16T22:30:24.196375
2019-10-16T14:05:10
2019-10-16T14:05:10
215,562,823
0
0
null
null
null
null
UTF-8
C++
false
false
1,883
cpp
DateTimeDlg.cpp
// DateTimeDlg.cpp : implementation file // #include "stdafx.h" #include "RegistryTime.h" #include "DateTimeDlg.h" #include "afxdialogex.h" // CDateTimeDlg dialog IMPLEMENT_DYNAMIC(CDateTimeDlg, CDialogEx) CDateTimeDlg::CDateTimeDlg(CWnd* pParent /*=NULL*/) : CDialogEx(CDateTimeDlg::IDD, pParent) { } CDateTimeDlg::~CDateTimeDlg() { } void CDateTimeDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CDateTimeDlg, CDialogEx) ON_BN_CLICKED(IDCANCEL, &CDateTimeDlg::OnBnClickedCancel) ON_BN_CLICKED(IDOK, &CDateTimeDlg::OnBnClickedOk) ON_WM_TIMER() ON_WM_PAINT() END_MESSAGE_MAP() // CDateTimeDlg message handlers void CDateTimeDlg::OnBnClickedCancel() { // TODO: Add your control notification handler code here CDialogEx::OnCancel(); } void CDateTimeDlg::OnBnClickedOk() { CDateTimeCtrl *dtp1 = (CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER1); CDateTimeCtrl *dtp2 = (CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER2); SYSTEMTIME _st1; dtp1->GetTime(&_st1); SYSTEMTIME _st2; dtp2->GetTime(&_st2); // int month, day, year, hour, minute, second; month = _st1.wMonth; day = _st1.wDay; year = _st1.wYear; hour = _st2.wHour; minute = _st2.wMinute; second = _st2.wSecond; st2.wMonth = month; st2.wDay = day; st2.wYear = year; st2.wHour = hour; st2.wMinute = minute; st2.wSecond = second; CDialogEx::OnOK(); } void CDateTimeDlg::OnTimer(UINT_PTR nIDEvent) { KillTimer(nIDEvent); CDateTimeCtrl *dtp1 = (CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER1); CDateTimeCtrl *dtp2 = (CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER2); dtp1->SetTime(st); dtp2->SetTime(st); CDialogEx::OnTimer(nIDEvent); } void CDateTimeDlg::OnPaint() { CPaintDC dc(this); // device context for painting SetTimer(1, 200, NULL); }
76c89e2ea273015dfcf5137b49144a5bcf8dc73f
fb153a2975b9c084d01b268bbdec506ffa133092
/SortingAlgorithms.cpp
2b6e55516b14b5a7e7e58ccb374c10fbf7dca50e
[]
no_license
olcayakman/CS202-studies
ec787ea7b8a5d7d01599678e63d0359c6a8c3435
ebc019c57c51d645b8e34bd6229dbbcf35e3619c
refs/heads/master
2020-08-06T02:09:45.295632
2019-10-04T12:58:16
2019-10-04T12:58:16
212,794,990
0
0
null
null
null
null
UTF-8
C++
false
false
387
cpp
SortingAlgorithms.cpp
/** * SortingALgorithms class implementation file. * @author Olcay * @version 04.10.2019 */ #include "SortingAlgorithms.h" #include <iostream> using namespace std; void SortingAlgorithms::selectionSort(int arr[], int arrSize) { for (int last = arrSize - 1; last >= 1; --last) { int max = utilities.findMaxIndex(arr, arrSize); swap(arr[max], arr[last]); } }
419ba6e6bb749acb35bc9f6c1726158a98322ac7
362bec098e4f192016afb7e417285493ef9d8892
/libvast/src/system/spawn_sink.cpp
d818925bac3a6383431f9e2c4fc89c4087ed4775
[ "BSD-3-Clause" ]
permissive
knapperzbusch/vast
4c30a8d5dadde74ceeea493e21ccfa63b4a35008
9d2af995254519b47febe2062adbc55965055cbe
refs/heads/master
2023-04-07T07:46:37.386419
2020-03-03T14:57:14
2020-03-03T14:57:14
223,018,439
0
2
BSD-3-Clause
2023-04-01T20:24:38
2019-11-20T20:09:07
C++
UTF-8
C++
false
false
3,793
cpp
spawn_sink.cpp
/****************************************************************************** * _ _____ __________ * * | | / / _ | / __/_ __/ Visibility * * | |/ / __ |_\ \ / / Across * * |___/_/ |_/___/ /_/ Space and Time * * * * This file is part of VAST. It is subject to the license terms in the * * LICENSE file found in the top-level directory of this distribution and at * * http://vast.io/license. No part of VAST, including this file, may be * * copied, modified, propagated, or distributed except according to the terms * * contained in the LICENSE file. * ******************************************************************************/ #include "vast/system/spawn_sink.hpp" #include <string> #include <caf/actor.hpp> #include <caf/expected.hpp> #include <caf/local_actor.hpp> #include <caf/settings.hpp> #include "vast/config.hpp" #include "vast/defaults.hpp" #include "vast/detail/make_io_stream.hpp" #include "vast/detail/unbox_var.hpp" #include "vast/format/ascii.hpp" #include "vast/format/csv.hpp" #include "vast/format/json.hpp" #include "vast/format/zeek.hpp" #include "vast/system/node.hpp" #include "vast/system/sink.hpp" #include "vast/system/spawn_arguments.hpp" #ifdef VAST_HAVE_PCAP #include "vast/format/pcap.hpp" #endif // VAST_HAVE_PCAP namespace vast::system { namespace { template <class Writer, class Defaults> maybe_actor spawn_generic_sink(caf::local_actor* self, spawn_arguments& args) { if (!args.empty()) return unexpected_arguments(args); std::string category = Defaults::category; VAST_UNBOX_VAR(out, detail::make_output_stream<Defaults>(args.invocation.options)); return self->spawn(sink<Writer>, Writer{std::move(out)}, 0u); } } // namespace <anonymous> maybe_actor spawn_pcap_sink([[maybe_unused]] caf::local_actor* self, [[maybe_unused]] spawn_arguments& args) { using defaults_t = defaults::export_::pcap; std::string category = defaults_t::category; #ifndef VAST_HAVE_PCAP return make_error(ec::unspecified, "not compiled with pcap support"); #else // VAST_HAVE_PCAP if (!args.empty()) return unexpected_arguments(args); format::pcap::writer writer{ caf::get_or(args.invocation.options, category + ".write", defaults_t::write), caf::get_or(args.invocation.options, category + ".flush-interval", defaults_t::flush_interval)}; return self->spawn(sink<format::pcap::writer>, std::move(writer), 0u); #endif // VAST_HAVE_PCAP } maybe_actor spawn_zeek_sink(caf::local_actor* self, spawn_arguments& args) { using defaults_t = defaults::export_::zeek; std::string category = defaults_t::category; if (!args.empty()) return unexpected_arguments(args); format::zeek::writer writer{ get_or(args.invocation.options, category + ".write", defaults_t::write)}; return self->spawn(sink<format::zeek::writer>, std::move(writer), 0u); } maybe_actor spawn_ascii_sink(caf::local_actor* self, spawn_arguments& args) { auto f = spawn_generic_sink<format::ascii::writer, defaults::export_::ascii>; return f(self, args); } maybe_actor spawn_csv_sink(caf::local_actor* self, spawn_arguments& args) { auto f = spawn_generic_sink<format::csv::writer, defaults::export_::csv>; return f(self, args); } maybe_actor spawn_json_sink(caf::local_actor* self, spawn_arguments& args) { auto f = spawn_generic_sink<format::json::writer, defaults::export_::json>; return f(self, args); } } // namespace vast::system
e2c05ecf5d0c6bb6cc97baefc3cea15e28b60f26
3a0e06c5ff680fe2bb316551204684b3478c1015
/Engine/Math/Geometry/Disc.hpp
a4220bc348ff9256dedffa38aaba9a26461b2280
[]
no_license
itsdrell/Strawberry
3fdb37a0300506780ca94959dae68010d5d6f122
e852a67a161e5b026b039e0794209d517d7a84bc
refs/heads/master
2022-05-10T18:51:56.767445
2022-05-08T04:21:27
2022-05-08T04:21:27
168,198,048
0
0
null
null
null
null
WINDOWS-1258
C++
false
false
1,164
hpp
Disc.hpp
#pragma once #include "Engine/Math/Vectors/Vector2.hpp" class Disc2 { public: // Constructors /Decon ~Disc2() {} Disc2() {} Disc2(const Disc2& copyFrom); explicit Disc2(float initialX, float initialY, float initialRadius); explicit Disc2(const Vector2& initialCenter, float initialRadius); // Mutators void StretchToIncludePoint(float x, float y); // expand radius if (x,y) is outside void StretchToIncludePoint(const Vector2& point); // expand radius if point outside void AddPaddingToRadius(float paddingRadius); void Translate(const Vector2& translation); // move the center void Translate(float translationX, float translationY); // move the center // Accessors /queries bool IsPointInside(float x, float y) const; // is (x,y) within disc’s interior? bool IsPointInside(const Vector2& point) const; // is “point” within disc’s interior? // Operators void operator+=(const Vector2& translation); // move void operator-=(const Vector2& antiTranslation); Disc2 operator+(const Vector2& translation) const; // create a moved copy Disc2 operator-(const Vector2& antiTranslation) const; public: Vector2 center; float radius; };
0dd8302a92cbe4ea2abf2b807318a876511c2584
b19f30140cef064cbf4b18e749c9d8ebdd8bf27f
/D3DGame_181018_052_1_Scattering/Components/UIModelTransform.cpp
081a45f66364502d5b04b8c01ef550091e3a630a
[]
no_license
evehour/SGADHLee
675580e199991916cf3134e7c61749b0a0bfa070
0ebbedf5d0692b782e2e5f9a372911c65f98ddc4
refs/heads/master
2020-03-25T13:22:42.597811
2019-01-03T07:05:54
2019-01-03T07:05:54
143,822,128
0
0
null
null
null
null
UTF-8
C++
false
false
1,134
cpp
UIModelTransform.cpp
#include "stdafx.h" #include "UIModelTransform.h" #include "./Objects/GameModel.h" UIModelTransform::UIModelTransform() : targetObject(nullptr) { this->uiType = ComponentUI::UIType::UIModelTransform; } UIModelTransform::~UIModelTransform() { } void UIModelTransform::Update() { if (targetObject == nullptr || containUIName.length() < 1) return; vS = targetObject->Scale(); vR = targetObject->Rotation(); vT = targetObject->Position(); } void UIModelTransform::Render() { if (targetObject == nullptr || containUIName.length() < 1) return; ImGui::Begin(containUIName.c_str()); { //if (ImGui::CollapsingHeader("Transform :: Model")) ImGui::Text("Transform :: Model"); { ImGui::SliderFloat3("Scale##UITr", (float *)&vS, 0.0001f, 100.0f); ImGui::SliderFloat3("Rotation##UITr", (float *)&vR, -Math::PI, Math::PI); ImGui::SliderFloat3("Position##UITr", (float *)&vT, -1000.0f, 1000.0f); targetObject->Scale(vS); targetObject->Rotation(vR); targetObject->Position(vT); } ImGui::Separator(); } ImGui::End(); } void UIModelTransform::ChangeTarget(GameModel * target) { targetObject = target; }
5dacc369024c5788c6a5df5dbb8227cba006560c
9067b0571e62632e1d2eaa06eaa7c8c9608427f4
/Week15(Calculator)/stack.cpp
6f81e8776170395234ebe4a89e7fd726a29cc78e
[]
no_license
khsu95/CPP
40bf1b1166d555b05f0169d16c65dd3dc170d764
beb3728985230dbfc344615630996c51bb75a5ec
refs/heads/main
2023-03-13T18:27:46.238464
2021-03-06T05:19:49
2021-03-06T05:19:49
345,012,412
0
0
null
null
null
null
UTF-8
C++
false
false
503
cpp
stack.cpp
#include"stack.h" #include<iostream> #include<string.h> Stack::Stack() { stack[0] = eos; } void Stack::push(int* ptop, precedence token) { if (*ptop >= (MAX_SIZE - 1)) cout<<"Stack is full\n"; stack[++(*ptop)] = token; } void Stack::push(double op) { _stack[++(this->index)] = op; } precedence Stack::pop(int* ptop) { if (*ptop == -1) { printf("Stack is empty\n Your input is wrong\n"); return eos; } return stack[(*ptop)--]; } double Stack::pop() { return _stack[(this->index)--]; }
c1e735857c90d3db65c4d0f4bd85ccb62f3cf22a
127fd33172f3823d46274281e3cdbc3adf3656a7
/hashCache.h
e8997d5533cd98e2a5afcff8964d3fc296904cfe
[]
no_license
mou23/HashCache
38e1e79565f9284973b257ad0df2b0342d0d300d
c9bb8bb921bdd12c1e5a502f605d16d0effbad05
refs/heads/master
2021-09-03T03:38:20.336026
2018-01-05T07:37:43
2018-01-05T07:37:43
116,355,162
0
0
null
null
null
null
UTF-8
C++
false
false
4,138
h
hashCache.h
#ifndef _HASHCACHE_H_ #define _HASHCACHE_H_ #include<string> #include<vector> #include"hashFunction.h" #include"caching.h" //#define maximumBucketSize 8 #define cacheSize 3 using namespace std; int *counter,numberOfBucket=8; //int *localDepth,globalDepth=2; template<class K,class V> class HashCache{ private: Node<K,V>*table; void deleteValue(K key,int hashValue); public: HashCache(); void setCachingAlgorithm(CachingAlgorithm algorithm); void insertElement(K key,V value); Node<K,V>* searchElement(K searchKey); void deleteElement(K key); void displayHashTable(); ~HashCache(); }; //constructor template<class K,class V> HashCache<K,V>::HashCache() { counter=new int[numberOfBucket]; //counts the number of element in a linked list //localDepth=new int[maximumBucketSize]; //for dynamic hashing table=new Node<K,V>[numberOfBucket]; for(int i=0;i<numberOfBucket;i++){ counter[i]=0; //localDepth[i]=2; } algorithmChoosed=Least_Frequently_Used; } //choosing caching algorithm template<class K,class V> void HashCache<K,V>::setCachingAlgorithm(CachingAlgorithm algorithm) { algorithmChoosed=algorithm; } // insert element into the hash table template<class K,class V> void HashCache<K,V>::insertElement(K key,V value) { int hashValue=findHashValue(key); Node<K,V>*newNode=new Node<K,V>[1]; newNode->value=value; newNode->key=key; if(searchElement(key)==NULL){ if(table[hashValue].next==NULL){ table[hashValue].next=newNode; } else{ Node<K,V>*currentNode=table[hashValue].next; while(currentNode->next!=NULL){ currentNode=currentNode->next; } currentNode->next=newNode; } counter[hashValue]++; mergeSort(&table[hashValue].next); /*if(counter[hashValue]>cacheSize){ extendHashTable(hashValue); }*/ if(counter[hashValue]>cacheSize ){ table[hashValue].next=table[hashValue].next->next; counter[hashValue]--; } } } template<class K,class V> void HashCache<K,V>::deleteElement(K key) { if(searchElement(key)!=NULL) deleteValue(key,findHashValue(key)); } //print all the contents of the hash table template<class K,class V> void HashCache<K,V>::displayHashTable() { for(int i=0;i<numberOfBucket;i++){ cout<<"values in bucket "<<i+1<<':'<<endl; Node<K,V>*currentNode=table[i].next; while(currentNode!=NULL){ cout<<currentNode->key<<' '<<currentNode->value<<endl; currentNode=currentNode->next; } cout<<endl; } } template<class K,class V> Node<K,V>* HashCache<K,V>::searchElement(K searchKey) { int hashValue=findHashValue(searchKey); Node<K,V>*currentNode=table[hashValue].next; while(currentNode!=NULL){ if(currentNode->key==searchKey){ (currentNode->totalAccess)++; time_t now=time(NULL); currentNode->accessTime=*localtime(&now); mergeSort(&table[hashValue].next); return currentNode; } currentNode=currentNode->next; } return NULL; } //delete a specified value from the hash table template<class K,class V> void HashCache<K,V>::deleteValue(K key,int hashValue) { if(table[hashValue].next->key==key){ table[hashValue].next=table[hashValue].next->next; } else{ Node<K,V>* currentNode=table[hashValue].next; while(currentNode->next!=NULL){ if(currentNode->next->key==key){ currentNode->next=currentNode->next->next; break; } currentNode=currentNode->next; } } counter[hashValue]--; } // destructor template<class K,class V> HashCache<K,V>::~HashCache() { for(int i=0;i<numberOfBucket;i++){ while(table[i].next!=NULL){ K key =table[i].next->key; deleteValue(key,i); } } delete[]table; delete[]counter; //delete[]localDepth; } #endif
a08a42f5648627645ccb58cf1415a71fab5cbc89
61456f36bc796cd8b4e5ebe489bc6e4c019363ad
/CompuCell3D/core/CompuCell3D/steppables/PDESolvers/OpenCL/OpenCLHelper.h
2bce6450c7bf942402f5014c38c848279e834e9b
[]
no_license
insafbk/CompuCell3D
f3556be82d10e71b6993a68e9a3fee552d10eb16
4c8b3b38f6fb9b96de7b7c13575ef0738f53dbc0
refs/heads/master
2023-01-03T08:55:37.934247
2020-08-22T18:13:13
2020-08-22T18:13:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,863
h
OpenCLHelper.h
#ifndef OPENCL_HELPER_H #define OPENCL_HELPER_H // 2012 Mitja: // #include <CL/opencl.h> #if defined (__APPLE__) || defined(MACOSX) #include <OpenCL/opencl.h> #else #include <CL/opencl.h> #endif #include <cassert> namespace CompuCell3D { class OpenCLHelper { cl_context context;//device's context cl_command_queue commandQueue; cl_uint numDevices; cl_device_id *devices; cl_uint deviceUsed; cl_platform_id platform; size_t maxWorkGroupSize; static cl_int GetPlatformID(cl_platform_id& clSelectedPlatformID, int &platformInd, int platfrormHint=-1); void BuildExecutable(cl_program program)const; cl_program CreateProgramWithSource(cl_uint /* count */, const char ** /* strings */, cl_int * /* errcode_ret */)const; public: explicit OpenCLHelper(int gpuDeviceIndex, int platformHint=-1); ~OpenCLHelper(); static const char* ErrorString(cl_int error); static char *FileContents(const char *filename, int *length); //simple, synchronous write (from host to device) template <class T> cl_int WriteBuffer(cl_mem buffer, T const *h_arr, size_t arrLen)const { cl_int res=clEnqueueWriteBuffer(commandQueue, buffer, CL_TRUE, 0, sizeof(T)*arrLen, h_arr, 0, NULL, NULL); //cerr<<"sizeof(T)="<<sizeof(T)<<", arrLen="<<arrLen<<endl; assert(res==CL_SUCCESS); return res; } //simple, synchronous copying (on device) template <class T> cl_int CopyBuffer(cl_mem src_buffer, cl_mem dst_buffer, size_t arrLen)const { cl_int res=clEnqueueCopyBuffer(commandQueue, src_buffer, dst_buffer, 0, 0, sizeof(T)*arrLen, 0, NULL, NULL); //cerr<<"sizeof(T)="<<sizeof(T)<<", arrLen="<<arrLen<<endl; assert(res==CL_SUCCESS); clEnqueueBarrier(commandQueue);//TODO: can be optimize with events probably return res; } //simple, synchronous read (from device to host) template <class T> cl_int ReadBuffer(cl_mem buffer, T *h_arr, size_t arrLen)const{ cl_int res=clEnqueueReadBuffer(commandQueue, buffer, CL_TRUE, 0, sizeof(T)*arrLen, h_arr, 0, NULL, NULL); assert(res==CL_SUCCESS); return res; } size_t getMaxWorkGroupSize()const{return maxWorkGroupSize;} cl_int EnqueueNDRangeKernel(cl_kernel /* kernel */, cl_uint /* work_dim */, const size_t * /* global_work_size */, const size_t * /* local_work_size */ )const; cl_mem CreateBuffer(cl_mem_flags memFlags, size_t sizeInBytes, void const *hostPtr=NULL)const; bool LoadProgram(const char *filePath[], size_t sourcesCount, cl_program &program)const; void Finish(); cl_context getContext()const {return context;} cl_device_id getDevice()const{return devices[deviceUsed];} cl_command_queue getCommandQueue() const{return commandQueue;} }; }//namespace CompuCell3D #endif
248047afba482557ea15deb6f13a6b1b86fddca9
e2b7245e17a81a6e1c2feb88d220b80f36abecd9
/Examen progra 4/Ejercicio1.cpp
f79cf05b6569368bf67899151d7bcfdb5f3f2a29
[]
no_license
danielmr28/Laboratorios
8efa0e5e173d1bcbdc4aef7708e37fa86af9b3a2
cf85bb183a63742cdbb774e1e4ffab675d2d9e02
refs/heads/master
2022-11-15T08:00:23.421949
2020-07-12T04:06:49
2020-07-12T04:06:49
262,451,758
0
0
null
null
null
null
UTF-8
C++
false
false
726
cpp
Ejercicio1.cpp
#include <iostream> using namespace std; int main() { char frase[100]; int i=0; cout << " Ingrese la frase: " << endl; cin.getline (frase, 100); while(frase[i]!='\0'){ if (frase[i]=='M'||frase[i]=='m') frase[i]='0'; if (frase[i]=='U'||frase[i]=='u') frase[i]='1'; if (frase[i]=='R'||frase[i]=='r') frase[i]='2'; if (frase[i]=='C'||frase[i]=='c') frase[i]='3'; if (frase[i]=='I'||frase[i]=='i') frase[i]='4'; if (frase[i]=='E'||frase[i]=='e') frase[i]='5'; if (frase[i]=='L'||frase[i]=='l') frase[i]='6'; if (frase[i]=='A'||frase[i]=='a') frase[i]='7'; if (frase[i]=='G'||frase[i]=='g') frase[i]='8'; if (frase[i]=='O'||frase[i]=='o') frase[i]='9'; i++; } cout << "La frase en cogido murcielago es: "<< frase; }
e042ba69133d03adf8c4f39bcd215af700aa386b
5a02f06d58b318051931771b2f6da5a5a52ca5f2
/src/Tests.cpp
cdb3bb6f189a7e11b3dbe642f5ba3c93de72ee9f
[]
no_license
mineawesomeman/JankMonopoly
448230314cb46697d52d6ff9c628b2191d9e1887
5dec2a6fe88f9a90fed99dfa11ae4f53ad84021c
refs/heads/main
2023-06-20T20:24:18.358161
2021-07-30T19:39:58
2021-07-30T19:39:58
391,171,505
0
0
null
null
null
null
UTF-8
C++
false
false
2,158
cpp
Tests.cpp
/* * Tests.cpp * * Created on: Mar 18, 2021 * Author: daraw */ #include "Tests.h" #include "Player.h" #include "Board.h" #include "Production.h" #include "Definitions.h" #include <iostream> Tests::Tests() { // TODO Auto-generated constructor stub } Tests::~Tests() { // TODO Auto-generated destructor stub } bool Tests::test() { printf("Testing Space Functions\n"); fflush(stdout); bool ok1 = testSpace(); printf("Testing Board Functions\n"); fflush(stdout); bool ok2 = testBoard(); printf("Testing Player Functions\n"); fflush(stdout); bool ok3 = testPlayer(); fflush(stdout); return ok1 && ok2 && ok3; } bool Tests::testSpace() { Space* sp = new Space(STREET,-1,(char*)"test"); if (sp->getHouseCount() != 0 || sp->getOwner() != -1) return false; sp->setOwner(0); sp->buildHouses(3); if (sp->getHouseCount() != 3 || sp->getOwner() != 0) return false; sp->sellHouses(2); if (sp->getHouseCount() != 1 || sp->getOwner() != 0) return false; printf("testSpace passed\n"); return true; } bool Tests::testBoard() { Board* bd = new Board(); Space* sp = bd->getSpace(0); if (sp->getType() != GO || sp->getSpaceNum() != 0 || sp->getHouseCount() != 0 || sp->getOwner() != -1) return false; printf("testBoard passed\n"); return true; } bool Tests::testPlayer() { Player* p = new Player (-1); Space* sp = new Space (STREET,6,(char*)"test"); Space* sp2 = new Space (RAILROAD,5,(char*)"test choo choo"); if (p->hasProperty(6) || p->hasProperty(5)) return false; p->buyProperty(sp); p->buyProperty(sp2); if (!p->hasProperty(6) || !p->hasProperty(5)) return false; if (p->getMoney() != 800-120) return false; if (p->getPosition() != 0) return false; p->move(6); p->gainMoney(69); if (p->getPosition() != 6) return false; if (p->getMoney() != 800-120+69) return false; p->loseMoney(420); if (p->getMoney() != 800-120+69-420) return false; p->sellProperty(sp2); if (p->getMoney() != 800-120+69-420+50) return false; if (p->hasProperty(5)) return false; printf("testPlayer passed\n"); return true; }
3e34e4009e842c2e4ba79de1f6d7ca4ef61f1311
efb6dee9804f4504101ae4e37e13056c0507cfde
/Task00/test.cpp
31bd8d164de11ab1ca4aceb429ba94375a3bfeff
[]
no_license
lukasas111/TD_seq_cpp_code-trainings-
3c4fbcb4601a52f50c08bddfcffb17a89eab99ca
9b0d8cb719cfd9113fce46069098f2680a40ca38
refs/heads/master
2020-03-21T15:04:20.685647
2018-06-29T17:03:31
2018-06-29T17:03:31
138,692,799
0
0
null
null
null
null
UTF-8
C++
false
false
4,246
cpp
test.cpp
//======== //this is template aimed at reading bitfinex prices //https://api.bitfinex.com/v2/candles/trade:15m:tBTCUSD/hist?limit=5 //example: http://www.cplusplus.com/reference/string/string/substr/ //cd c:\sources\test //g++ test.cpp -o test.exe //test.exe //============================================= #include <iostream> #include <fstream> #include <cstring> #include <string> #include <sstream> // needed for conversion of strings to doubles and other types //looking for workaround: #include <iterator> #include <vector> #include <iomanip> using namespace std; //============================================= int main () { //first we need to read a file string data; ifstream infile; infile.open("prices.txt"); infile >> data; // write the data at the screen. cout << data << endl << endl; infile.close(); //============================================= //take out initial and final brackets size_t pos = data.find("]]"); data = data.substr (2, pos-2); cout << data << endl << endl; //what is remainging length of string data size_t postemp = pos-3; //============================================= // cut remaining strings into strings of each candle string candle [999]; int i = 0; while( data.length() >75) { size_t pos = data.find("],["); candle[i] = data.substr (0, pos); data = data.substr (pos+3 , postemp); postemp = postemp - (pos+2); cout << candle[i] << endl; cout << pos << endl; cout << data << endl; cout << data.length() << endl; ++i; } candle[i] =data; //============================================= // only for testing // for (int j = 0; j < (i+1) ; j++) { // cout << candle[j] << endl; //} //============================================= // what next? int k; string candle2 [i+1][6]; //loop to count candles int j = 0; //cout << i << endl; int n = i+1; while (j < n ) { //this one? data = candle[j].substr(0); //cout << data << endl; //internal loop to count commas k=0; while (k < 5) { pos = data.find(","); candle2[j][k] = data.substr (0, pos); //cout << candle2[j][k] << endl; data = data.substr (pos+1); ++k; } candle2[j][k] = data; //cout << candle2[j][k] << endl; ++j; } //============================================= // only for testing for (int j = 0; j < (i+1) ; j++) { cout << "candle[" << j << "] is: " << candle2[j][0] << " " << candle2[j][1] << " " << candle2[j][2] << " " << candle2[j][3] << " " << candle2[j][4] << " " <<candle2[j][5] << endl; } //============================================= //write to csv //https://waterprogramming.wordpress.com/2016/08/12/a-quick-example-code-to-write-data-to-a-csv-file-in-c/ //============================================= // open a file in write mode. ofstream outfile; outfile.open("pricedata.csv", ios::trunc); // write the file headers outfile << "Time" << "," << "Open" << "," << "Close" << "," << "High" << "," << "Low" << "," << "Volume" << endl; //convert strings to integers [try1] //cout << candle2[i][0] << endl; j = i; while (j> -1) { char myArray[candle2[j][0].size()+1]; strcpy(myArray, candle2[j][0].c_str()); char myArray1[candle2[j][1].size()+1]; strcpy(myArray1, candle2[j][1].c_str()); char myArray2[candle2[j][2].size()+1]; strcpy(myArray2, candle2[j][2].c_str()); char myArray3[candle2[j][3].size()+1]; strcpy(myArray3, candle2[j][3].c_str()); char myArray4[candle2[j][4].size()+1]; strcpy(myArray4, candle2[j][4].c_str()); char myArray5[candle2[j][5].size()+1]; strcpy(myArray5, candle2[j][5].c_str()); outfile << myArray << "," << myArray1 << "," << myArray2 << "," << myArray3 << "," << myArray4 << "," << myArray5 << endl; --j; } // close the opened file. outfile.close(); //============================================= //g++ test.cpp -o test.exe //test.exe return 0; }
fc1d36762a4c960d0afc0887b7bf07e7c70581d3
b7e97047616d9343be5b9bbe03fc0d79ba5a6143
/test/protocols/ligand_docking/Transform.cxxtest.hh
45139f5d4e3486ed4f549e6d51ab2ae3872f19da
[]
no_license
achitturi/ROSETTA-main-source
2772623a78e33e7883a453f051d53ea6cc53ffa5
fe11c7e7cb68644f404f4c0629b64da4bb73b8f9
refs/heads/master
2021-05-09T15:04:34.006421
2018-01-26T17:10:33
2018-01-26T17:10:33
119,081,547
1
3
null
null
null
null
UTF-8
C++
false
false
4,766
hh
Transform.cxxtest.hh
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*- // vi: set ts=2 noet: // // (c) Copyright Rosetta Commons Member Institutions. // (c) This file is part of the Rosetta software suite and is made available under license. // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. // (c) For more information, see http://www.rosettacommons.org. Questions about this can be // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu. // Test headers #include <cxxtest/TestSuite.h> #include <test/core/init_util.hh> #include <test/UTracer.hh> #include <protocols/jd2/JobDistributor.hh> #include <protocols/jd2/Job.hh> #include <core/chemical/ChemicalManager.hh> #include <core/chemical/ResidueTypeSet.hh> #include <core/conformation/Residue.hh> #include <core/pose/Pose.hh> #include <core/conformation/UltraLightResidue.hh> #include <protocols/qsar/scoring_grid/GridManager.hh> #include <core/pose/util.hh> #include <protocols/rigid/RB_geometry.hh> #include <protocols/ligand_docking/Transform.hh> #include <numeric/xyz.functions.hh> #include <numeric/random/random.hh> //Auto Headers #include <core/import_pose/import_pose.hh> #include <utility/vector1.hh> //#include <test/core/init_util.hh> static basic::Tracer TR("protocols.ligand_docking.StartFrom.cxxtest"); class TransformTests : public CxxTest::TestSuite { public: void setUp() { core_init_with_additional_options("-extra_res_fa protocols/ligand_docking/ZNx.params protocols/ligand_docking/7cpa.params"); // Residue definitions can't be supplied on the command line b/c // the ResidueTypeSet is already initialized. // using namespace core::chemical; // utility::vector1< std::string > params_files; // ResidueTypeSetCOP const_residue_set = ChemicalManager::get_instance()->residue_type_set( FA_STANDARD ); // ResidueTypeSet & residue_set = const_cast< ResidueTypeSet & >(*const_residue_set); // if ( !residue_set.has_name("ZNx") ) params_files.push_back("protocols/ligand_docking/ZNx.params"); // if ( !residue_set.has_name("CP1") ) params_files.push_back("protocols/ligand_docking/7cpa.params"); // residue_set.read_files_for_custom_residue_types(params_files); } void tearDown() {} //inline void core_init_with_additional_options( std::string const & commandline_in ); void test_initial_perturb() { using namespace protocols::ligand_docking; numeric::random::rg().set_seed( "mt19937", time(0) ); core::pose::Pose pose; core::import_pose::pose_from_file( pose, "protocols/ligand_docking/7cpa_7cpa_native.pdb" , core::import_pose::PDB_file); Transform mover; core::Size chain_id=core::pose::get_chain_id_from_chain('X', pose); core::Size begin=pose.conformation().chain_begin(chain_id); core::conformation::UltraLightResidue test_ligand(pose.residue(begin).get_self_ptr()); core::conformation::UltraLightResidue start_ligand(test_ligand); core::Vector start_center(start_ligand.center()); //Test initial perturb of residue core::Size rejected = 0; core::Size accepted = 0; for ( core::Size i=0; i <= 500; i++ ) { mover.randomize_ligand(test_ligand, 5, 360); core::Real distance = test_ligand.center().distance(start_center); if ( distance > 5.0 ) { rejected++; } else { accepted++; } test_ligand = start_ligand; } TS_ASSERT_EQUALS(rejected, 0.0); //Test conformer change of residue rejected = 0; accepted = 0; core::Real deviation = 0; mover.setup_conformers(pose, begin); for ( core::Size i=0; i <= 500; i++ ) { mover.change_conformer(test_ligand); core::Real distance = test_ligand.center().distance(start_center); if ( distance > 5.0 ) { rejected++; } else { accepted++; } TR << "conformer distance: " << distance << std::endl; deviation = 0; utility::vector1<core::PointPosition > target_coords = start_ligand.coords_vector(); utility::vector1<core::PointPosition > copy_coords = test_ligand.coords_vector(); for ( core::Size i=1; i <= copy_coords.size(); ++i ) { core::Real deviation_x = ((copy_coords[i][0]-target_coords[i][0]) * (copy_coords[i][0]-target_coords[i][0])); core::Real deviation_y = ((copy_coords[i][1]-target_coords[i][1]) * (copy_coords[i][1]-target_coords[i][1])); core::Real deviation_z = ((copy_coords[i][2]-target_coords[i][2]) * (copy_coords[i][2]-target_coords[i][2])); core::Real total_dev = deviation_x + deviation_y + deviation_z; deviation += total_dev; } deviation /= (core::Real)copy_coords.size(); deviation = sqrt(deviation); TR << "RMSD: " << deviation << std::endl; test_ligand = start_ligand; } TS_ASSERT_EQUALS(rejected, 0.0); } };
e96af339180f0e2757a0083e2a0faa3a9d1e6b10
3f148b1ad8a4bda468cbf8663d0012608d406c3d
/proyectoFinal/proyectoFinal/FriasCarrilloJuan_PROYECTO_FINAL_GPO4.cpp
2e3e2923479115a17a5e582732811ee8c04cf99b
[]
no_license
RKJFC/JuanFriasProyectoGPO4
63bd769e244f092271a1052c8aa1868de274018f
ab679fd83cd2b5e1838cd70bd2ad174e05757dc9
refs/heads/master
2020-09-04T22:18:41.009656
2019-11-20T18:36:45
2019-11-20T18:36:45
219,907,053
0
0
null
null
null
null
ISO-8859-1
C++
false
false
47,376
cpp
FriasCarrilloJuan_PROYECTO_FINAL_GPO4.cpp
//Semestre 2020 - 1 //************************************************************// //************************************************************// //************** Alumno (s): *********************************// //************* Proyecto Final ******// //********* Laboratorio Computación Gráfica - GPO4 *****// //********** Frías Carrillo Juan **********// //************************************************************// #include "texture.h" #include "figuras.h" #include "Camera.h" //#include "cmodel/CModel.h" //NEW//////////////////NEW//////////////////NEW//////////////////NEW//////////////// static GLuint ciudad_display_list; //Display List for the Monito int w = 500, h = 500; int frame=0,time,timebase=0; int deltaTime = 0; char s[30]; CCamera objCamera; //Create objet Camera GLfloat g_lookupdown = 0.0f; // Look Position In The Z-Axis (NEW) int font=(int)GLUT_BITMAP_HELVETICA_18; //GLfloat Diffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; // Diffuse Light Values GLfloat Diffuse[]= { 0.5f, 0.5f, 0.5f, 1.0f }; // Diffuse Light Values GLfloat Specular[] = { 1.0, 1.0, 1.0, 1.0 }; // Specular Light Values GLfloat Position[]= { 0.0f, 7.0f, -5.0f, 0.0f }; // Light Position GLfloat Position2[]= { 0.0f, 0.0f, -5.0f, 1.0f }; // Light Position GLfloat LampDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; // Diffuse Light Values GLfloat LampSpecular[] = { 1.0, 1.0, 1.0, 1.0 }; // Specular Light Values GLfloat LampPosition[] = { 0.0f, 65.0f, 0.0f, 1.0f }; // Light Position /////////////////////// TEXTURA DE CASA ///////////////////7//// CTexture cielosol; CTexture ladrillos; CTexture pasto; CTexture puerta; CTexture reja; CTexture wood; CTexture sofa; CTexture al; CTexture lampara; CTexture whiteWood; CTexture bed; ////////////////// TEXTURAS EXTERIORES CASA ///////////////////// CFiguras sky; CFiguras pared; CFiguras pastof; CFiguras pisof; CFiguras cilindro; CFiguras plano; CFiguras mi_figura; CTexture cabañapiso; CTexture pisosala; CTexture cabañamadera; CTexture cabañabarda; CTexture cabañaventana; CTexture cabañapuerta; CTexture cabañateja; CTexture escalon; CTexture arbol; CTexture arbol1; CTexture arbol2; CTexture arbol3; CTexture cercaJardin; CFiguras prisma; CFiguras fig1; ///////////////////////// TEXTURA INTERIOR CASA ////////////////// CTexture estufaFront; CTexture estufaUp; CTexture estufaLat; CTexture fregaderoUp; CTexture fregaderoLat; CTexture fregaderofront; CTexture refrigerador; CTexture alacenaLat; CTexture cocinaintegral; CTexture mesacocinaFront; CTexture mesacocinaLat; CTexture television; CTexture alfombraPB; CTexture alfombraPA; CTexture librero; CTexture librerolat; ////////////////////////// TEXTURA ANIMACION /////////////////////// CTexture moltres; CTexture articuno; //////////////////////// MODELOS /////////////////////////////// //CModel Avion; //CModel silla; ////// VARIABLES DE ANIMACION SUPERMAN ///// float rotVent = 0.0; float movMoltres = 0.0; float movarticuno = -2.0; float articunoX = 30.0; float articunoY = 35.0; float v = 5.0; float gravedad = 9.81; float t; float supermanX = 53.0; float supermanY = 80.0; float supermanZ = 50.0; float supermanrot = 45.0; float art_fanimacion = false; float art_fanimacion2 = false; bool picada_articuno; /////// VARIABLE ANIMACION VENTILADOR ////// bool ventiladorgira = false; bool movMoltresDel = false; GLuint createDL() { GLuint ciudadDL; //GLuint cieloDL; ciudadDL = glGenLists(1); glNewList(ciudadDL,GL_COMPILE); glEndList(); return(ciudadDL); } ///// FUNCIONES DE MODELOS ///// void lamp() { glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); glLightfv(GL_LIGHT1, GL_DIFFUSE, LampDiffuse); glLightfv(GL_LIGHT1, GL_SPECULAR, LampSpecular); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); glPushMatrix(); glBindTexture(GL_TEXTURE_2D, lampara.GLindex); glColor3f(1.0, 1.0, 1.0); plano.plano(20.0, 60.0); //plano 1 glRotatef(45, 0, 1, 0); plano.plano(20.0, 60.0); //plano 2 glRotatef(90, 0, 1, 0); plano.plano(20.0, 60.0); //plano 3 glRotatef(135, 0, 1, 0); plano.plano(20.0, 60.0); //plano 4 glRotatef(180, 0, 1, 0); plano.plano(20.0, 60.0); //plano 5 glRotatef(225, 0, 1, 0); plano.plano(20.0, 60.0); //plano 6 glRotatef(270, 0, 1, 0); plano.plano(20.0, 60.0); //plano 7 glRotatef(315, 0, 1, 0); plano.plano(20.0, 60.0); //plano 8 glPopMatrix(); glDisable(GL_ALPHA_TEST); } void silla() { glColor3f(0.4, 0.2, 0.0); glPushMatrix(); glTranslatef(0.0, 16.0, 0.0); prisma.prisma(12.0, 2.0, 12.0, whiteWood.GLindex); //Base glTranslatef(5.0, -8.5, 5.0); prisma.prisma(2.0, 15.0, 2.0, whiteWood.GLindex); //pata 1 glTranslatef(-10.0, 0.0, 0.0); prisma.prisma(2.0, 15.0, 2.0, whiteWood.GLindex); //pata 2 glTranslatef(0.0, 0.0, -10.0); prisma.prisma(2.0, 15.0, 2.0, whiteWood.GLindex); //pata 3 glTranslatef(10.0, 0.0, 0.0); prisma.prisma(2.0, 15.0, 2.0, whiteWood.GLindex); //pata 4 glTranslatef(0.0, 17.0, 0.0); prisma.prisma(2.0, 15.0, 2.0, whiteWood.GLindex); //parte_respaldo glTranslatef(0.0, 0.0, 5.0); prisma.prisma(2.0, 15.0, 4.0, whiteWood.GLindex); //parte_respaldo glTranslatef(0.0, 0.0, 5.0); prisma.prisma(2.0, 15.0, 2.0, whiteWood.GLindex); //parte_respaldo glTranslatef(0.0, 8.5, -5.0); prisma.prisma(2.0, 2.0, 12.0, whiteWood.GLindex); //parte_respaldo glPopMatrix(); } void ventilador() { glPushMatrix(); //Ventilador de techo glTranslatef(0.0, 0.0, 0.0); glColor3f(1.0, 1.0, 1.0); glTranslatef(0.0, 97.0, 0.0); glRotatef(rotVent, 0.0, 1.0, 0.0); cilindro.cilindro(5.0, 3.0, 10, al.GLindex); glColor3f(1.0, 1.0, 1.0); glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(0.0, 1.25, 0.0); prisma.prisma(35.0, 1.0, 5.0, al.GLindex); glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(0.0, 0.0, 0.0); prisma.prisma(35.0, 1.0, 5.0, al.GLindex); glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(0.0, 0.0, 0.0); prisma.prisma(35.0, 1.0, 5.0, al.GLindex); glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(0.0, 0.0, 0.0); prisma.prisma(35.0, 1.0, 5.0, al.GLindex); glPopMatrix(); } void cama() { glPushMatrix(); //Cama glTranslatef(0.0, 2.5, 0.0); prisma.prisma(60.0, 5.0, 35.0, wood.GLindex); //Base glTranslatef(0.0, 6.5, 0.0); prisma.prisma(59.0, 8.0, 34.0, bed.GLindex); //Colchon glTranslatef(31.5, 0.0, 0.0); prisma.prisma(3.0, 18.0, 35.0, wood.GLindex); //Cabecera glTranslatef(-63.0, -3.0, 0.0); prisma.prisma(3.0, 12.0, 35.0, wood.GLindex); //Piecera //cobija glTranslatef(24.5, 7.05, 17.0); glRotatef(-90.0, 1.0, 0.0, 0.0); glColor3f(0.0, 0.0, 1.0); glBindTexture(GL_TEXTURE_2D, sofa.GLindex); plano.plano(45.0, 34.1); glTranslatef(0.0, 34.05, 0.0); glRotatef(-90.0, 1.0, 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, sofa.GLindex); plano.plano(45.0, 8.05); glTranslatef(0.0, 8.0, -34.1); glRotatef(180.0, 1.0, 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, sofa.GLindex); plano.plano(45.0, 8.05); glRotatef(-90.0, 1.0, 0.0, 0.0); glRotatef(-90.0, 0.0, 1.0, 0.0); glTranslatef(4.0, 0.0, 22.55); glBindTexture(GL_TEXTURE_2D, sofa.GLindex); plano.plano(8.05, 34.1); glPopMatrix(); } ////////////////////////////////////////////// CARGA DE TEXTURAS ///////////////////////////////////////////////// void InitGL ( GLvoid ) // Inicializamos parametros { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Negro de fondo glEnable(GL_TEXTURE_2D); glShadeModel (GL_SMOOTH); //Para construir la figura comentar esto /*glLightfv(GL_LIGHT1, GL_POSITION, Position); glLightfv(GL_LIGHT1, GL_DIFFUSE, Diffuse);*/ //glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, Position2); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable ( GL_COLOR_MATERIAL ); //glEnable(GL_CULL_FACE); //glCullFace(GL_BACK); //glPolygonMode(GL_BACK, GL_LINE); glClearDepth(1.0f); // Configuramos Depth Buffer glEnable(GL_DEPTH_TEST); // Habilitamos Depth Testing glDepthFunc(GL_LEQUAL); // Tipo de Depth Testing a realizar glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); cielosol.LoadTGA("text/cielo.tga"); cielosol.BuildGLTexture(); cielosol.ReleaseImage(); ladrillos.LoadBMP("text/pisoE.bmp"); ladrillos.BuildGLTexture(); ladrillos.ReleaseImage(); pasto.LoadTGA("text/pasto.tga"); pasto.BuildGLTexture(); pasto.ReleaseImage(); puerta.LoadBMP("texturas/door.bmp"); puerta.BuildGLTexture(); puerta.ReleaseImage(); wood.LoadTGA("text/wood.tga"); wood.BuildGLTexture(); wood.ReleaseImage(); lampara.LoadTGA("text/lampara.tga"); lampara.BuildGLTexture(); lampara.ReleaseImage(); bed.LoadTGA("text/bed.tga"); bed.BuildGLTexture(); bed.ReleaseImage(); //sofa.LoadTGA("text/peluche.tga"); //sofa.BuildGLTexture(); //sofa.ReleaseImage(); //al.LoadTGA("text/aluminum.tga"); //al.BuildGLTexture(); //al.ReleaseImage(); whiteWood.LoadTGA("texturas/wood1.tga"); whiteWood.BuildGLTexture(); whiteWood.ReleaseImage(); pisosala.LoadTGA("texturas/pisosala.tga"); pisosala.BuildGLTexture(); pisosala.ReleaseImage(); cabañamadera.LoadTGA("texturas/cabañamadera.tga"); cabañamadera.BuildGLTexture(); cabañamadera.ReleaseImage(); cabañapiso.LoadTGA("texturas/cabañapiso.tga"); cabañapiso.BuildGLTexture(); cabañapiso.ReleaseImage(); cabañabarda.LoadBMP("texturas/cabañabarda.bmp"); cabañabarda.BuildGLTexture(); cabañabarda.ReleaseImage(); cabañaventana.LoadTGA("texturas/ventanaDoble.tga"); cabañaventana.BuildGLTexture(); cabañaventana.ReleaseImage(); cabañapuerta.LoadTGA("texturas/cabañapuerta.tga"); cabañapuerta.BuildGLTexture(); cabañapuerta.ReleaseImage(); cabañateja.LoadBMP("texturas/cabañateja.bmp"); cabañateja.BuildGLTexture(); cabañateja.ReleaseImage(); escalon.LoadBMP("texturas/escalon.bmp"); escalon.BuildGLTexture(); escalon.ReleaseImage(); arbol.LoadTGA("texturas/arbol.tga"); arbol.BuildGLTexture(); arbol.ReleaseImage(); arbol1.LoadTGA("texturas/arbol1.tga"); arbol1.BuildGLTexture(); arbol1.ReleaseImage(); arbol2.LoadTGA("texturas/arbol2.tga"); arbol2.BuildGLTexture(); arbol2.ReleaseImage(); arbol3.LoadTGA("texturas/arbol3.tga"); arbol3.BuildGLTexture(); arbol3.ReleaseImage(); //// CARGA TEXTURAS INTERIOR //// cercaJardin.LoadTGA("texturas/cercaJardin.tga"); cercaJardin.BuildGLTexture(); cercaJardin.ReleaseImage(); estufaFront.LoadTGA("texturas/estufaRot.tga"); estufaFront.BuildGLTexture(); estufaFront.ReleaseImage(); estufaUp.LoadTGA("texturas/estufaUp.tga"); estufaUp.BuildGLTexture(); estufaUp.ReleaseImage(); estufaLat.LoadTGA("texturas/estufaLat.tga"); estufaLat.BuildGLTexture(); estufaLat.ReleaseImage(); fregaderoUp.LoadTGA("texturas/fregaderoUp.tga"); fregaderoUp.BuildGLTexture(); fregaderoUp.ReleaseImage(); fregaderoLat.LoadTGA("texturas/fregaderoLat.tga"); fregaderoLat.BuildGLTexture(); fregaderoLat.ReleaseImage(); fregaderofront.LoadTGA("texturas/fregaderofront.tga"); fregaderofront.BuildGLTexture(); fregaderofront.ReleaseImage(); refrigerador.LoadTGA("texturas/refrigerador.tga"); refrigerador.BuildGLTexture(); refrigerador.ReleaseImage(); cocinaintegral.LoadTGA("texturas/alacena.tga"); cocinaintegral.BuildGLTexture(); cocinaintegral.ReleaseImage(); alacenaLat.LoadTGA("texturas/alacenaLat.tga"); alacenaLat.BuildGLTexture(); alacenaLat.ReleaseImage(); mesacocinaFront.LoadTGA("texturas/mesacocinaFront.tga"); mesacocinaFront.BuildGLTexture(); mesacocinaFront.ReleaseImage(); mesacocinaLat.LoadTGA("texturas/mesacocinaLat.tga"); mesacocinaLat.BuildGLTexture(); mesacocinaLat.ReleaseImage(); alfombraPB.LoadTGA("texturas/alfombraPB.tga"); alfombraPB.BuildGLTexture(); alfombraPB.ReleaseImage(); alfombraPA.LoadTGA("texturas/alfombraPA.tga"); alfombraPA.BuildGLTexture(); alfombraPA.ReleaseImage(); television.LoadTGA("texturas/television.tga"); television.BuildGLTexture(); television.ReleaseImage(); librero.LoadTGA("texturas/librero.tga"); librero.BuildGLTexture(); librero.ReleaseImage(); librerolat.LoadTGA("texturas/librerolat.tga"); librerolat.BuildGLTexture(); librerolat.ReleaseImage(); ////// TEXTURAS ANIMACION ///// moltres.LoadTGA("Texturas/Moltres.tga"); moltres.BuildGLTexture(); moltres.ReleaseImage(); articuno.LoadTGA("Texturas/Articuno.tga"); articuno.BuildGLTexture(); articuno.ReleaseImage(); //chair._3dsLoad("Silla.3DS"); //END NEW////////////////////////////// objCamera.Position_Camera(0.0f, 2.0f, 10.0f, 0.0f, -2.0f, 0.0f, 0.0f, 1.0f, 0.0f); //camara: posicion, vista, up. Por terna de vectores en 3d ////NEW Crear una lista de dibujo //ciudad_display_list = createDL(); } void pintaTexto(float x, float y, float z, void *font,char *string) { char *c; //Almacena los caracteres a escribir glRasterPos3f(x, y, z); //Posicion apartir del centro de la ventana //glWindowPos2i(150,100); for (c=string; *c != '\0'; c++) //Condicion de fin de cadena { glutBitmapCharacter(font, *c); //imprime } } //////////////////////////////////////// COLOCACION DE MODELOS CON SUS TEXTURAS //////////////////////////// void estufa() { //- Derecha, Atrás, Izq, Frente, Abajo, Arriba glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(3.0, 7.0, 7.0); mi_figura.mueble(estufaLat.GLindex, estufaLat.GLindex, estufaLat.GLindex, estufaFront.GLindex, estufaLat.GLindex, estufaUp.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void fregadero() { //- Derecha, Atrás, Izq, Frente, Abajo, Arriba glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(3.0, 7.0, 7.0); mi_figura.mueble(fregaderoLat.GLindex, fregaderoLat.GLindex, fregaderofront.GLindex, fregaderoLat.GLindex, fregaderoLat.GLindex, fregaderoUp.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void refrigeradormodelo() { //- Derecha, Atrás, Izq, Frente, Abajo, Arriba glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(3.0, 7.0, 7.0); mi_figura.mueble(fregaderoLat.GLindex, fregaderoLat.GLindex, fregaderoLat.GLindex, refrigerador.GLindex, fregaderoLat.GLindex, fregaderoLat.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void cocinaintegralmodelo() { //- Derecha, Atrás, Izq, Frente, Abajo, Arriba glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(3.0, 7.0, 7.0); mi_figura.mueble(cocinaintegral.GLindex, alacenaLat.GLindex, alacenaLat.GLindex, alacenaLat.GLindex, alacenaLat.GLindex, alacenaLat.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void mesacocina() { //- Derecha, Atrás, Izq, Frente, Abajo, Arriba glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(3.0, 7.0, 7.0); mi_figura.mueble(mesacocinaLat.GLindex, mesacocinaLat.GLindex, mesacocinaLat.GLindex, mesacocinaFront.GLindex, mesacocinaLat.GLindex, mesacocinaLat.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void alfombramodelo() { //Alfombra glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(2.0, 4.0, 0.0); mi_figura.plano(alfombraPB.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void alfombramodelo2() { //Alfombra glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(2.0, 4.0, 0.0); mi_figura.plano(alfombraPA.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void televisionmodelo() { //Television glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(2.0, 4.0, 0.0); mi_figura.plano(television.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void libreromodelo() { //- Derecha, Atrás, Izq, Frente, Abajo, Arriba glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(3.0, 7.0, 7.0); mi_figura.mueble(librerolat.GLindex, librerolat.GLindex, librerolat.GLindex, librero.GLindex, librerolat.GLindex, librerolat.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void moltresmodelo() { //Moltres glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(2.0, 4.0, 0.0); mi_figura.plano(moltres.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void articunomodelo() { //Articuno glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); //glScalef(2.0, 4.0, 0.0); mi_figura.plano(articuno.GLindex); glDisable(GL_LIGHTING); glPopMatrix(); } void Techo() { glPushMatrix(); //piso glBindTexture(GL_TEXTURE_2D, cabañapiso.GLindex); glBegin(GL_POLYGON); glNormal3f(1.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(0, 0.0, 0);//1 glTexCoord2f(1.0f, 0.0f); glVertex3f(20, 0.0, 0);//2 glTexCoord2f(1.0f, 4.0f); glVertex3f(20, 0.0, -20);//3 glTexCoord2f(0.0f, 4.0f); glVertex3f(0, 0.0, -20); glEnd(); // Frente glBindTexture(GL_TEXTURE_2D, whiteWood.GLindex); glBegin(GL_TRIANGLES); glNormal3f(1.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(0, 0.0, 0);//1 glTexCoord2f(0.0f, 8.0f); glVertex3f(20, 0.0, 0);//2 glTexCoord2f(0.5f, 4.0f); glVertex3f(10, 10.0, 0);//3 glEnd(); //Atras glTranslatef(0, 0, -20); glBindTexture(GL_TEXTURE_2D, whiteWood.GLindex); glBegin(GL_TRIANGLES); glNormal3f(1.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(0, 0.0, 0);//1 glTexCoord2f(0.0f, 8.0f); glVertex3f(20, 0.0, 0);//2 glTexCoord2f(0.5f, 4.0f); glVertex3f(10, 10.0, 0);//3 glEnd(); //Techo izquierdo glTranslatef(0, 0, -1); glColor3f(1.0, 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, cabañateja.GLindex); glBegin(GL_POLYGON); glNormal3f(1.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(0, 0, 0);//1 glTexCoord2f(1.0f, 0.0f); glVertex3f(10, 10.0, 0);//2 glTexCoord2f(1.0f, 1.0f); glVertex3f(10, 10.0, 22);//3 glTexCoord2f(0.0f, 1.0f); glVertex3f(0, 0.0, 22);//4 glEnd(); //Techo derecho glBegin(GL_POLYGON); glNormal3f(1.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(10, 10.0, 0);//1 glTexCoord2f(1.0f, 0.0f); glVertex3f(20, 0.0, 0);//2 glTexCoord2f(1.0f, 1.0f); glVertex3f(20, 0.0, 22);//3 glTexCoord2f(0.0f, 1.0f); glVertex3f(10, 10.0, 22);//4 glEnd(); glPopMatrix(); } void barandal() { //BARANDAL 1 glPushMatrix(); glTranslatef(-9.75, 1.75, 10 + 2); glColor3f(0.8, 0.8, 0.8); glScalef(0.5, 0.5, 4.0); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //soporte 1 glPushMatrix(); glTranslatef(-9.75, 0.25, 10 + 2); glRotatef(90, 1, 0, 0); glColor3f(0.8, 0.8, 0.8); glScalef(0.5, 0.5, 2.5); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //soporte 2 glPushMatrix(); glTranslatef(-9.75, 0.25, 10 + 2 + 1.75); glRotatef(90, 1, 0, 0); glColor3f(0.8, 0.8, 0.8); glScalef(0.5, 0.5, 2.5); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //BARANDAL 2 glPushMatrix(); glTranslatef(-10 + 1.5, 1.75, 10 + 2 + 1.75); glColor3f(0.8, 0.8, 0.8); glScalef(3.0, 0.5, 0.5); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //soporte 3 glPushMatrix(); glTranslatef(-10 + 2.75, 0.25, 10 + 2 + 1.75); glRotatef(90, 1, 0, 0); glColor3f(0.8, 0.8, 0.8); glScalef(0.5, 0.5, 2.5); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //BARANDAL 3 glPushMatrix(); glTranslatef(-1.5, 1.75, 10 + 2 + 1.75); glColor3f(0.8, 0.8, 0.8); glScalef(3.0, 0.5, 0.5); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //soporte 4 glPushMatrix(); glTranslatef(-3 + 0.25, 0.25, 10 + 2 + 1.75); glRotatef(90, 1, 0, 0); glColor3f(0.8, 0.8, 0.8); glScalef(0.5, 0.5, 2.5); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //soporte 5 glPushMatrix(); glTranslatef(-0.25, 0.25, 10 + 2 + 1.75); glRotatef(90, 1, 0, 0); glColor3f(0.8, 0.8, 0.8); glScalef(0.5, 0.5, 2.5); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //BARANDAL 4 glPushMatrix(); glTranslatef(-0.25, 1.75, 10 + 2); glColor3f(0.8, 0.8, 0.8); glScalef(0.5, 0.5, 4.0); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); //soporte 6 glPushMatrix(); glTranslatef(-0.25, 0.25, 10 + 2); glRotatef(90, 1, 0, 0); glColor3f(0.8, 0.8, 0.8); glScalef(0.5, 0.5, 2.5); fig1.cabañapris3(cabañamadera.GLindex, cabañamadera.GLindex); glPopMatrix(); } void tree(GLint text) { glDisable(GL_LIGHTING); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); glPushMatrix(); glBindTexture(GL_TEXTURE_2D, text); glBegin(GL_QUADS); //plano glColor3f(1.0, 1.0, 1.0); glNormal3f(0.0f, 0.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-10.0, 0.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f(10.0, 0.0, 0.0); glTexCoord2f(1.0f, 1.0f); glVertex3f(10.0, 20.0, 0.0); glTexCoord2f(0.0f, 1.0f); glVertex3f(-10.0, 20.0, 0.0); glEnd(); glPopMatrix(); glPushMatrix(); glRotatef(45, 0, 1, 0); glBegin(GL_QUADS); //plano glColor3f(1.0, 1.0, 1.0); glNormal3f(0.0f, 0.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-10.0, 0.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f(10.0, 0.0, 0.0); glTexCoord2f(1.0f, 1.0f); glVertex3f(10.0, 20.0, 0.0); glTexCoord2f(0.0f, 1.0f); glVertex3f(-10.0, 20.0, 0.0); glEnd(); glPopMatrix(); glPushMatrix(); glRotatef(-45, 0, 1, 0); glBegin(GL_QUADS); //plano glColor3f(1.0, 1.0, 1.0); glNormal3f(0.0f, 0.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-10.0, 0.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f(10.0, 0.0, 0.0); glTexCoord2f(1.0f, 1.0f); glVertex3f(10.0, 20.0, 0.0); glTexCoord2f(0.0f, 1.0f); glVertex3f(-10.0, 20.0, 0.0); glEnd(); glPopMatrix(); glPushMatrix(); glRotatef(90, 0, 1, 0); glBegin(GL_QUADS); //plano glColor3f(1.0, 1.0, 1.0); glNormal3f(0.0f, 0.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-10.0, 0.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f(10.0, 0.0, 0.0); glTexCoord2f(1.0f, 1.0f); glVertex3f(10.0, 20.0, 0.0); glTexCoord2f(0.0f, 1.0f); glVertex3f(-10.0, 20.0, 0.0); glEnd(); glPopMatrix(); glDisable(GL_ALPHA_TEST); glEnable(GL_LIGHTING); } void cabaña() { glDisable(GL_LIGHTING); //cabañapiso glPushMatrix(); glTranslatef(0, -2, 0); glColor3f(1.0, 1.0, 1.0); glScalef(20.0, 2.0, 20.0); fig1.cabañapris(pisosala.GLindex, cabañabarda.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(-5, -2, 10 + 2); glColor3f(0.8, 0.8, 0.8); glScalef(10.0, 2.0, 4.0); fig1.cabañapris3(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); //Piso entrada glPushMatrix(); glTranslatef(5, -2.25, 10 + 1.5); glColor3f(0.8, 0.8, 0.8); glScalef(5.0, 1.5, 3.0); fig1.cabañapris3(cabañabarda.GLindex, whiteWood.GLindex); glPopMatrix(); //Techo entrada glPushMatrix(); glTranslatef(2.0, 8.5, 10 + 3.0); glColor3f(1.0, 1.0, 1.0); glScalef(0.3, 0.3, 0.15); Techo(); glPopMatrix(); //Viga izquierda glPushMatrix(); glTranslatef(5 - 2.25, 3.5, 10 + 2.75); glColor3f(1.0, 1.0, 1.0); glScalef(0.5, 10.0, 0.5); fig1.cabañapris3(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); //Viga derecha glPushMatrix(); glTranslatef(5 + 2.25, 3.5, 10 + 2.75); glColor3f(1.0, 1.0, 1.0); glScalef(0.5, 10.0, 0.5); fig1.cabañapris3(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); //Barandales glPushMatrix(); barandal(); glPopMatrix(); //escaleras glPushMatrix(); glTranslatef(-5.0, -2.25, 14.55); glColor3f(0.7, 0.7, 0.7); glScalef(4.0, 1.5, 1.0); fig1.cabañapris1(whiteWood.GLindex, whiteWood.GLindex); glPushMatrix(); glTranslatef(0, -0.25, 1); glScalef(1.0, 0.5, 1.0); fig1.cabañapris1(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); glPopMatrix(); //Muro Izquierdo glPushMatrix(); glTranslatef(-9.75, 4 + 5, 0); glColor3f(1.0, 1.0, 1.0); glScalef(0.5, 20.0, 19.5); fig1.cabañapris4(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); //Vigas exteriores /*glPushMatrix(); glTranslatef(-9.5, 4.0, 8); glColor3f(1.0, 1.0, 1.0); glScalef(1.0, 10.0, 1.0); fig1.cabañapris3(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(9.5, 4.0, -9.5); glColor3f(1.0, 1.0, 1.0); glScalef(1.0, 10.0, 1.0); fig1.cabañapris3(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(9.5, 4.0, -1.0); glColor3f(1.0, 1.0, 1.0); glScalef(1.0, 10.0, 1.0); fig1.cabañapris3(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(9.5, 4.0, 8); glColor3f(1.0, 1.0, 1.0); glScalef(1.0, 10.0, 1.0); fig1.cabañapris3(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix();*/ //Muro Trasero glPushMatrix(); glTranslatef(0, 4 + 5, -9.75); glRotatef(180, 0, 1, 0); glColor3f(1.0, 1.0, 1.0); glScalef(19.5, 20.0, 0.5); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); fig1.cabañapris2(whiteWood.GLindex, whiteWood.GLindex); glDisable(GL_ALPHA_TEST); glPopMatrix(); //Muro Derecho inferior 1 glPushMatrix(); glTranslatef(9.75, 4, 5); glRotatef(180, 0, 0, 1); glColor3f(1.0, 1.0, 1.0); glScalef(0.5, 10.0, 10); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); fig1.cabañapris5(cabañaventana.GLindex, cabañaventana.GLindex); glDisable(GL_ALPHA_TEST); glPopMatrix(); //Muro Derecho inferior 2 glPushMatrix(); glTranslatef(9.75, 4, -5); glRotatef(180, 0, 0, 1); glColor3f(1.0, 1.0, 1.0); glScalef(0.5, 10.0, 10); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); fig1.cabañapris5(cabañaventana.GLindex, cabañaventana.GLindex); glDisable(GL_ALPHA_TEST); glPopMatrix(); //Muro Derecho superior glPushMatrix(); glTranslatef(9.75, 4 + 5 + 5, 0); glRotatef(180, 0, 0, 1); glColor3f(1.0, 1.0, 1.0); glScalef(0.5, 10.0, 20); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); fig1.cabañapris5(whiteWood.GLindex, whiteWood.GLindex); glDisable(GL_ALPHA_TEST); glPopMatrix(); //Muro Frente izquierdo glPushMatrix(); glTranslatef(-5.0, 4, 9.75); glRotatef(180, 0, 0, 1); glColor3f(1.0, 1.0, 1.0); glScalef(10.0, 10.0, 0.5); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); fig1.cabañapris2(cabañaventana.GLindex, cabañaventana.GLindex); glDisable(GL_ALPHA_TEST); glPopMatrix(); //Muro frente centro glPushMatrix(); glTranslatef(1.25, 4, 9.75); glColor3f(1.0, 1.0, 1.0); glScalef(2.5, 10.0, 0.5); fig1.cabañapris2(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); //puerta glPushMatrix(); glTranslatef(5, 4, 9.75); glColor3f(1.0, 1.0, 1.0); glScalef(5.0, 10.0, 0.25); fig1.cabañapris3(puerta.GLindex, puerta.GLindex); glPopMatrix(); //Muro frente derecho glPushMatrix(); glTranslatef(8.75, 4, 9.75); glColor3f(1.0, 1.0, 1.0); glScalef(2.5, 10.0, 0.5); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); fig1.cabañapris2(whiteWood.GLindex, whiteWood.GLindex); glDisable(GL_ALPHA_TEST); glPopMatrix(); //Muro frente superior glPushMatrix(); glTranslatef(0, 4 + 10, 9.75); glRotatef(180, 0, 1, 0); glColor3f(1.0, 1.0, 1.0); glScalef(19.5, 10.0, 0.5); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1); fig1.cabañapris2(whiteWood.GLindex, whiteWood.GLindex); glDisable(GL_ALPHA_TEST); glPopMatrix(); //Techo glPushMatrix(); glTranslatef(-10, 19, 10); glColor3f(1.0, 1.0, 1.0); Techo(); glPopMatrix(); //Segundo piso glPushMatrix(); glTranslatef(2.5, 10, 0); glColor3f(0.8, 0.4, 0.0); glScalef(14.75, 1.0, 19.5); fig1.cabañapris(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(-7.25, 10, -7.5); glScalef(4.75, 1.0, 4.75); fig1.cabañapris(whiteWood.GLindex, whiteWood.GLindex); glPopMatrix(); //Escaleras glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(-10 + 2.75, 0, 5.25); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glTranslatef(0, 1.0, -1.0); fig1.prisma(4.75, 1.0, 1.0, escalon.GLindex); glPopMatrix(); //Fin Escalera /*VERJAS*/ glPushMatrix(); glTranslatef(-35, -3, 20); glPushMatrix(); //arbustos izquierdos glTranslatef(8, 0.0, -2.0); glScalef(0.3, 0.3, 0.3); tree(arbol2.GLindex); glTranslatef(10.0, 0.0, -30.0); glPushMatrix(); glScalef(2.5, 4.0, 2.5); tree(arbol.GLindex); glTranslatef(0, 0.0, -20.0); tree(arbol1.GLindex); glPopMatrix(); glTranslatef(-10.0, 0.0, -90.0); tree(arbol2.GLindex); glPopMatrix(); glScalef(1.1, 1.0, 0.7); glPushMatrix(); //verja izquierda glTranslatef(4.0, -0.7, -1.0); glRotatef(90.0, 0.0, 1.0, 0.0); glScalef(0.3, 0.3, 0.0); fig1.cerca(cercaJardin.GLindex); glPushMatrix(); glTranslatef(19.44, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(38.9, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(58.44, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(77.9, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(97.4, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(116.8, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(136.2, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(155.6, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(175.1, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(194.5, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPopMatrix(); glTranslatef(47.0, 0.0, 0.0); glPushMatrix(); //arbustos derechos glTranslatef(1.0, 0.0, -2.0); glScalef(0.3, 0.3, 0.3); tree(arbol2.GLindex); glTranslatef(0.0, 0.0, -30.0); tree(arbol3.GLindex); glTranslatef(0.0, 0.0, -30.0); tree(arbol3.GLindex); glTranslatef(0.0, 0.0, -30.0); tree(arbol3.GLindex); glTranslatef(0.0, 0.0, -30.0); tree(arbol3.GLindex); glTranslatef(0.0, 0.0, -30.0); tree(arbol3.GLindex); glTranslatef(0.0, 0.0, -30.0); tree(arbol2.GLindex); glPopMatrix(); glPushMatrix(); //verja derecha glTranslatef(4.0, -0.7, -1.0); glRotatef(90.0, 0.0, 1.0, 0.0); glScalef(0.3, 0.3, 0.0); fig1.cerca(cercaJardin.GLindex); glPushMatrix(); glTranslatef(19.44, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(38.9, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(58.44, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(77.9, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(97.4, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(116.8, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(136.2, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(155.6, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(175.1, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(194.5, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPopMatrix(); glTranslatef(-58.0, 0.0, -2.0); glRotatef(-90.0, 0.0, 1.0, 0.0); glPushMatrix(); //verja frontal glTranslatef(4.0, -0.7, -1.0); glRotatef(90.0, 0.0, 1.0, 0.0); glScalef(0.3, 0.3, 0.0); glPushMatrix(); glTranslatef(58.44, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(77.9, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(97.4, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(116.8, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(136.2, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(175.1, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(194.5, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPopMatrix(); glTranslatef(-65.0, 0.0, 0.5); glPushMatrix(); //verja trasera glTranslatef(4.0, -0.7, -1.0); glRotatef(90.0, 0.0, 1.0, 0.0); glScalef(0.3, 0.3, 0.0); glPushMatrix(); glTranslatef(58.44, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(77.9, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(97.4, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(116.8, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(136.2, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(155.6, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(175.1, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(194.5, 0.0, 0.0); fig1.cerca(cercaJardin.GLindex); glPopMatrix(); glPopMatrix(); glPopMatrix(); /**FIN VERJAS*/ ///// MUEBLES INTERIOR PLANTA BAJA //// //Estufa glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(8.3, 0.8, 0); glScalef(2, 3.5, 3.0); //glRotatef(-90.0, 0.0, 0.0, 1.0); estufa(); glPopMatrix(); //Fregadero glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(8.3, 0.8, 5.5); glScalef(2.0, 3.5, 6.0); glRotatef(90.0, 0.0, 1.0, 0.0); fregadero(); glPopMatrix(); //Refrigerador glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(-3.5, 2.05, 3.8); glScalef(2.0, 6.0, 3.0); glRotatef(180, 0.0, 1.0, 0.0); refrigeradormodelo(); glPopMatrix(); //Cocina Integral glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(0.0, 5.5, -8.5); glScalef(6.5, 3.0, 2.0); //glRotatef(-90.0, 0.0, 0.0, 1.0); cocinaintegralmodelo(); glPopMatrix(); //Mesa Cocina glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(8.3, 0.8, -5.5); glScalef(2, 3.5, 5.5); //glRotatef(-90.0, 0.0, 0.0, 1.0); mesacocina(); glPopMatrix(); //AlfombraPB glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(1.0, -0.9, -6.5); glScalef(0.40, 0.25, 0.25); glRotatef(90.0, 1.0, 0.0, 0.0); alfombramodelo(); glPopMatrix(); //Moltres glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(-30.0+movMoltres, 35.0, 0.0); glScalef(0.80, 0.50, 0.50); //glRotatef(90.0, 1.0, 0.0, 0.0); moltresmodelo(); glPopMatrix(); //Articuno glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(articunoX, articunoY, movarticuno); glScalef(0.40, 0.25, 0.25); //glRotatef(90.0, 1.0, 0.0, 0.0); articunomodelo(); glPopMatrix(); ///// MUEBLES INTERIOR PLANTA ALTA //// //AlfombraPB glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(0.0, 10.7, -2.0); glScalef(0.25, 0.40, 0.50); glRotatef(90.0, 1.0, 0.0, 0.0); alfombramodelo2(); glPopMatrix(); //Librero glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(6.5, 14.0, -8.5); glScalef(4.0, 7.0, 3.0); glRotatef(90, 0.0, 1.0, 0.0); libreromodelo(); glPopMatrix(); glEnable(GL_LIGHTING); } void display ( void ) // Creamos la funcion donde se dibuja { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glPushMatrix(); glRotatef(g_lookupdown,1.0f,0,0); gluLookAt( objCamera.mPos.x, objCamera.mPos.y, objCamera.mPos.z, objCamera.mView.x, objCamera.mView.y, objCamera.mView.z, objCamera.mUp.x, objCamera.mUp.y, objCamera.mUp.z); glPushMatrix(); glPushMatrix(); //Creamos cielo glDisable(GL_LIGHTING); glTranslatef(0, 0, 0); glColor3f(1.0, 1.0, 1.0); sky.skybox(850.0, 600.0, 600.0, cielosol.GLindex, cielosol.GLindex); glEnable(GL_LIGHTING); glPopMatrix(); glTranslatef(0, 64.0, 0); //Inicia estructura de la casa glPushMatrix(); glTranslatef(0, -256.0 + 30.0, 0); glScalef(10, 10 , 10); cabaña(); glPopMatrix(); //Inicia pasto glPushMatrix(); glDisable(GL_LIGHTING); glTranslatef(-(75.0 + 175.0), -256.0, 0.0); glColor3f(1.0, 1.0, 1.0); pastof.piso(350.0, 0.5, 600.0, pasto.GLindex); //PASTO 1 glEnable(GL_LIGHTING); glPopMatrix(); glPushMatrix(); glDisable(GL_LIGHTING); glTranslatef(0.0, -256.0, -(150.0 + 50.0)); glColor3f(1.0, 1.0, 1.0); pastof.piso(150.0, 0.5, 200.0, pasto.GLindex); //PASTO 2 glEnable(GL_LIGHTING); glPopMatrix(); glPushMatrix(); glDisable(GL_LIGHTING); glTranslatef(75.0 + 175.0, -256.0, 0.0); glColor3f(1.0, 1.0, 1.0); pastof.piso(350.0, 0.5, 600.0, pasto.GLindex); //PASTO 3 glEnable(GL_LIGHTING); glPopMatrix(); glPushMatrix(); glDisable(GL_LIGHTING); glTranslatef(0.0, -256.0, 150.0 + 50.0); glColor3f(1.0, 1.0, 1.0); pastof.piso(150.0, 0.5, 200.0, pasto.GLindex); //PASTO 4 glEnable(GL_LIGHTING); glPopMatrix(); //Finaliza pasto //ladrillos de entrada glPushMatrix(); glDisable(GL_LIGHTING); glTranslatef(50, -256.0 + 0.25, 250.0 + 10.0); pisof.piso(40.0, 0.5, 35.0, ladrillos.GLindex); glTranslatef(0.0, 0.0, -47.5); pisof.piso(40.0, 0.5, 35.0, ladrillos.GLindex); glTranslatef(0.0, 0.0, -47.5); pisof.piso(40.0, 0.5, 35.0, ladrillos.GLindex); glEnable(GL_LIGHTING); glPopMatrix(); //fin ladrillos de entrada ///////////// MODELADO DE OBJETOS COMO SILLAS; MESA Y CAMA //////////////////// /////// CAMA ////////// glPushMatrix(); glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(-40, -120.0, 70.0); glScalef(1.0, 1.5, 1.0); cama(); glPopMatrix(); ////// VENTILADOR ////// glPushMatrix(); //glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(0, -187.0, 0.0); glScalef(1.0, 1.5, 1.0); ventilador(); glPopMatrix(); // // glPushMatrix(); //Sillon individual // glTranslatef(55.0, 7.5, -45.0); // glRotatef(135.0, 0.0, 1.0, 0.0); // glColor3f(0.2, 0.1, 0.0); // prisma.prisma(20.0, 5.0, 20.0, sofa.GLindex); //Base // glTranslatef(0.0, 7.5, 7.5); // prisma.prisma(20.0, 10.0, 5.0, sofa.GLindex); //Respaldo // glTranslatef(12.5, -2.5, -7.5); // prisma.prisma(5.0, 15.0, 20.0, sofa.GLindex); //Coderas // glTranslatef(-25.0, 0.0, 0.0); // prisma.prisma(5.0, 15.0, 20.0, sofa.GLindex); //Coderas // glTranslatef(-1.25, -10.0, 8.75); // glColor3f(0.88, 0.88, 0.88); // prisma.prisma(2.5, 5.0, 2.5, al.GLindex); //Pata 1 // glTranslatef(0.0, 0.0, -17.5); // prisma.prisma(2.5, 5.0, 2.5, al.GLindex); //Pata 2 // glTranslatef(27.5, 0.0, 0.0); // prisma.prisma(2.5, 5.0, 2.5, al.GLindex); //Pata 3 // glTranslatef(0.0, 0.0, 17.5); // prisma.prisma(2.5, 5.0, 2.5, al.GLindex); //Pata 4 // glColor3f(0.0, 0.4, 0.8); // glTranslatef(-13.75, 15.0, -6.00); // prisma.prisma(20.0, 15.0, 2.5, sofa.GLindex); //Cojin 1 // glColor3f(1.0, 0.0, 0.0); // glPopMatrix(); //glPushMatrix(); //Ventilador de techo //glTranslatef(0.0, 0.0, 0.0); //glColor3f(1.0, 1.0, 1.0); //glTranslatef(0.0, 97.0, 0.0); //glRotatef(rotVent, 0.0, 1.0, 0.0); //cilindro.cilindro(5.0, 3.0, 10, al.GLindex); //glColor3f(1.0, 1.0, 1.0); //glRotatef(90.0, 0.0, 1.0, 0.0); //glTranslatef(0.0, 1.25, 0.0); //prisma.prisma(35.0, 1.0, 5.0, al.GLindex); //glRotatef(90.0, 0.0, 1.0, 0.0); //glTranslatef(0.0, 0.0, 0.0); //prisma.prisma(35.0, 1.0, 5.0, al.GLindex); //glRotatef(90.0, 0.0, 1.0, 0.0); //glTranslatef(0.0, 0.0, 0.0); //prisma.prisma(35.0, 1.0, 5.0, al.GLindex); //glRotatef(90.0, 0.0, 1.0, 0.0); //glTranslatef(0.0, 0.0, 0.0); //prisma.prisma(35.0, 1.0, 5.0, al.GLindex); //glPopMatrix(); // glPushMatrix(); //Mueble TV // glColor3f(0.6, 0.6, 0.6); // glTranslatef(-37.5, 0.75, -55.0); // prisma.prisma(39.0, 1.5, 15.0, wood.GLindex); //Base 1 // glTranslatef(0.0, 0.75 + 11.0 + 0.75, 0.0); // prisma.prisma(39.0, 1.5, 15.0, wood.GLindex); //base 2 // glTranslatef(0.0, 12.5, 0.0); // prisma.prisma(39.0, 1.5, 15.0, wood.GLindex); //Base 3 // glTranslatef(0.0, 12.5, 0.0); // prisma.prisma(39.0, 1.5, 15.0, wood.GLindex); //Base 4 // glTranslatef(-18.75, -18.75, 0.0); // prisma.prisma(1.5, 39.0, 15.0, wood.GLindex); //Pata 1 // glTranslatef(12.5, 0.0, 0.0); // prisma.prisma(1.5, 39.0, 15.0, wood.GLindex); //Pata 2 // glTranslatef(12.5, 0.0, 0.0); // prisma.prisma(1.5, 39.0, 15.0, wood.GLindex); //Pata 3 // glTranslatef(12.5, 0.0, 0.0); // prisma.prisma(1.5, 39.0, 15.0, wood.GLindex); //Pata 4 // glPopMatrix(); glPushMatrix(); //Mueble ESTUDIO glColor3f(0.8, 0.4, 0.0); glTranslatef(7.0, -107.0, -85.0); glRotatef(270.0, 0.0, 1.0, 0.0); prisma.prisma(15.0, 27.0, 3.0, whiteWood.GLindex); //1 glTranslatef(0.0, 15.0, 18.5); prisma.prisma(15.0, 3.0, 40.0, whiteWood.GLindex); //2 glTranslatef(0.0, -15.0, 18.5); prisma.prisma(15.0, 27.0, 3.0, whiteWood.GLindex); //3 glTranslatef(0.0, 0.0, -26.0); prisma.prisma(15.0, 3.0, 20.0, whiteWood.GLindex); //4 glTranslatef(0.0, -8.0, 8.5); prisma.prisma(15.0, 13.0, 3.0, whiteWood.GLindex); //5 glPopMatrix(); //////////////// COLOCACION DE SILLAS /////////// glPushMatrix(); glTranslatef(-30.0, -120.0, -65.0); glRotatef(270.0, 0.0, 1.0, 0.0); silla(); glPopMatrix(); glPopMatrix(); glPushMatrix(); glTranslatef(5.0, -55.0, -50.0); glRotatef(-125.0, 0.0, 1.0, 0.0); silla(); glPopMatrix(); glPopMatrix(); glPopMatrix(); ///// NO BORRAR glutSwapBuffers ( ); //// NO BORRAR } //////////////////////////////////////////7/// FUNCION PARA ANIMACION //////////////////// void animacion() { ////////////////////////// INICIO ANIMACION VENTILADOR ///////////// if(ventiladorgira) { rotVent += 1.5; } ////////////////////////// FINAL ANIMACION VENTILADOR ///////////////// ////////////////////////// INICIO ANIMACION MOLTRES ///////////// if (movMoltresDel) { movMoltres += 0.01; } ////////////////////////// FINAL ANIMACION MOLTRES ///////////////// ////////////////////////// INICIO ANIMACION ARTICUNO ///////////// if (art_fanimacion) { movarticuno += 0.01; } if (art_fanimacion2) { movarticuno -= 0.01; } if (picada_articuno) { t += 0.1; articunoX = v*t*cos(45); articunoY = v*t*sin(45) - 0.5*gravedad*(t*t); } ////////////////////////// FINAL ANIMACION ARTICUNO ///////////////// glutPostRedisplay(); ///// NO BORRAR } void reshape ( int width , int height ) // Creamos funcion Reshape { if (height==0) // Prevenir division entre cero { height=1; } glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); // Seleccionamos Projection Matrix glLoadIdentity(); // Tipo de Vista glFrustum (-0.1, 0.1,-0.1, 0.1, 0.1, 900.0); glMatrixMode(GL_MODELVIEW); // Seleccionamos Modelview Matrix glLoadIdentity(); } ///////////////////////////////// TECLAS DE MOVIMIENTO Y ACTIVACION DE ANIMACIONES ///////////////////// void keyboard ( unsigned char key, int x, int y ) // Create Keyboard Function { switch ( key ) { case 'w': //Movimientos de camara case 'W': objCamera.Move_Camera( CAMERASPEED + 0.5); break; case 's': case 'S': objCamera.Move_Camera(-(CAMERASPEED + 0.5)); break; case 'a': case 'A': objCamera.Strafe_Camera(-(CAMERASPEED + 0.5)); break; case 'd': case 'D': objCamera.Strafe_Camera( CAMERASPEED + 0.5); break; /////////////////////////Para Activar animación de ventilador ///////////////////// case '3': ventiladorgira = true; break; /////////////////////////Para Activar animación de Moltres ///////////////////// case '4': movMoltresDel = true; break; /////////////////////////Para Activar animación de Articuno ///////////////////// case '5': art_fanimacion2 = true; //movarticuno = 0; //picada_articuno = true; break; case '6': //art_fanimacion2 = true; //movarticuno = 0; picada_articuno = true; break; //////////////////////////////////////////////////////////////////////////////////////// case 27: // Cuando Esc es presionado... exit ( 0 ); // Salimos del programa break; default: // Cualquier otra break; } glutPostRedisplay(); } void arrow_keys ( int a_keys, int x, int y ) // Funcion para manejo de teclas especiales (arrow keys) { switch ( a_keys ) { case GLUT_KEY_PAGE_UP: objCamera.UpDown_Camera(CAMERASPEED + 0.2); break; case GLUT_KEY_PAGE_DOWN: objCamera.UpDown_Camera(-CAMERASPEED - 0.2); break; case GLUT_KEY_UP: // Presionamos tecla ARRIBA... g_lookupdown -= 2.0f; break; case GLUT_KEY_DOWN: // Presionamos tecla ABAJO... g_lookupdown += 2.0f; break; case GLUT_KEY_LEFT: objCamera.Rotate_View(-CAMERASPEED); break; case GLUT_KEY_RIGHT: objCamera.Rotate_View( CAMERASPEED); break; default: break; } glutPostRedisplay(); } int main ( int argc, char** argv ) // Main Function { glutInit (&argc, argv); // Inicializamos OpenGL glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); // Display Mode (Clores RGB y alpha | Buffer Doble ) glutInitWindowSize (640, 480); // Tamaño de la Ventana glutInitWindowPosition (0, 0); //Posicion de la Ventana glutCreateWindow ("Proyecto Final - Frías Carrillo Juan - GPO4"); // Nombre de la Ventana //glutFullScreen ( ); // Full Screen InitGL (); // Parametros iniciales de la aplicacion glutDisplayFunc ( display ); //Indicamos a Glut función de dibujo glutReshapeFunc ( reshape ); //Indicamos a Glut función en caso de cambio de tamano glutKeyboardFunc ( keyboard ); //Indicamos a Glut función de manejo de teclado glutSpecialFunc ( arrow_keys ); //Otras glutIdleFunc ( animacion ); glutMainLoop ( ); // return 0; }
2c1c0b925c39ff951319b40b5a0daa41e7fcfe76
3faf8eb9c6201d7091fa63169dd74462095f5ef2
/src/LightField.h
ee2f94511c4ca04d58a1117eafa3c9e0b453780d
[]
no_license
evgeny-t/imagestack
c1ab04a73cd85e648269c50b3f7c27d5e48bd0a8
09d565e864ff60354780401a08f70bfcd833fccd
refs/heads/master
2020-12-30T09:26:32.931340
2015-05-01T05:56:59
2015-05-01T05:56:59
34,891,298
2
0
null
null
null
null
UTF-8
C++
false
false
3,595
h
LightField.h
#ifndef IMAGESTACK_LIGHTFIELD_H #define IMAGESTACK_LIGHTFIELD_H namespace ImageStack { // a LightField is an image which assumes u and v are rolled up into x // and y, like an image of the lenslets in a plenoptic camera class LightField { public: LightField(Image im, int uSize_, int vSize_) : image(im), uSize(uSize_), vSize(vSize_) { assert(im.width % uSize == 0, "width is not a multiple of lenslet width\n"); assert(im.height % vSize == 0, "height is not a multiple of lenslet height\n"); xSize = im.width / uSize; ySize = im.height / vSize; } float &operator()(int x, int y, int u, int v, int c) { return image(x*uSize + u, y*vSize + v, c); } float &operator()(int x, int y, int u, int v, int t, int c) { return image(x*uSize + u, y*vSize + v, t, c); } // quadrilinear 4D sampling (quadriLanczos3 too expensive, 6^4=1296) // x,y,u,v follow the same coordinate conventions as // operator() void sample4D(float x, float y, float u, float v, int t, float *result) { int ix[2], iy[2], iu[2], iv[2]; // integer indices float wx[2], wy[2], wu[2], wv[2]; // weighting factors if ((x < 0 || y < 0 || x > xSize-1 || y > ySize-1) || (u < 0 || v < 0 || u > uSize-1 || v > vSize-1)) { // out of bounds, so return zero for (int c = 0; c < image.channels; c++) { result[c] = 0; } return; } ix[0] = (int)(floor(x)); iy[0] = (int)(floor(y)); iu[0] = (int)(floor(u)); iv[0] = (int)(floor(v)); // clamp against bounds ix[0] = clamp(ix[0],0,xSize-1); iy[0] = clamp(iy[0],0,ySize-1); iu[0] = clamp(iu[0],0,uSize-1); iv[0] = clamp(iv[0],0,vSize-1); ix[1] = ix[0]+1; iy[1] = iy[0]+1; iu[1] = iu[0]+1; iv[1] = iv[0]+1; // clamp against bounds ix[1] = min(ix[1],xSize-1); iy[1] = min(iy[1],ySize-1); iu[1] = min(iu[1],uSize-1); iv[1] = min(iv[1],vSize-1); // calculate the weights for quadrilinear wx[1] = x-ix[0]; wy[1] = y-iy[0]; wu[1] = u-iu[0]; wv[1] = v-iv[0]; wx[0] = 1-wx[1]; wy[0] = 1-wy[1]; wu[0] = 1-wu[1]; wv[0] = 1-wv[1]; // do the computation for (int c = 0; c < image.channels; c++) { result[c] = 0; } for (int i = 0; i < 2; i++) { // go through iu for (int j = 0; j < 2; j++) { // go through ix for (int k = 0; k < 2; k++) { // go through iv for (int l = 0; l < 2; l++) { // go through iy for (int c = 0; c < image.channels; c++) { result[c] += ((*this)(ix[j],iy[l],iu[i],iv[k],t,c) * wx[j]*wy[l]*wu[i]*wv[k]); } } } } } } void sample4D(float x, float y, float u, float v, float *result) { sample4D(x,y,u,v,0,result); } Image image; int uSize, vSize; int xSize, ySize; }; class LFFocalStack : public Operation { public: void help(); bool test(); void parse(vector<string> args); static Image apply(LightField im, float minAlpha, float maxAlpha, float deltaAlpha); }; class LFPoint : public Operation { public: void help(); bool test(); void parse(vector<string> args); static void apply(LightField lf, float x, float y, float z); }; } #endif
efa6079f6ba1786520957cabd6a431afb87d4d89
ec606498d8c4ff237058ad4588c96c564911c938
/src/SDF/ConnectedFace.hpp
4f23a66cc636f18da3e833c714d61a1560e34a3c
[]
no_license
yanchian/XuXu
9377b456d83c923486470673c6c681c6acf4c7d6
d7cc130c219ef775c47bb7f6cb26d06e0214df14
refs/heads/main
2023-03-21T16:06:51.869100
2021-03-17T03:57:08
2021-03-17T03:57:08
348,165,893
0
0
null
null
null
null
UTF-8
C++
false
false
4,001
hpp
ConnectedFace.hpp
#pragma once #include <vector> #include <iostream> // Forward declarations template<typename T> class ConnectedEdge; template<typename T> class ConnectedVertex; template<typename T> class Polyhedron; template<typename T> class ScanConvertiblePolyhedron; /** A face which stores adjacency relations with edges. * * Once initialised, the face is guaranteed to have three vertices and three edges. * * \tparam T The numeric type used in representing points. */ template<typename T> class ConnectedFace { public: typedef Vector<T, 3> Point; typedef ConnectedEdge<T> Edge; typedef ConnectedVertex<T> Vertex; typedef std::vector<Edge*> EdgeContainer; typedef std::vector<Vertex*> VertexContainer; private: EdgeContainer edges_; VertexContainer vertices_; Point normal_; //@{ // Computed variables T area_; //@} public: ConnectedFace<T>() : vertices_(3), edges_(3) { } //! Once all the adjacency relations are filled, we can populate the computed variables void init(); //@{ // Accessor functions for the vertices associated with this face. // // Once initialised, it may be assumed that the edge has exactly three vertices size_t vertices() const { return vertices_.size(); } typename VertexContainer::iterator verticesBegin() { return vertices_.begin(); } typename VertexContainer::iterator verticesEnd() { return vertices_.end(); } typename VertexContainer::const_iterator verticesBegin() const { return vertices_.begin(); } typename VertexContainer::const_iterator verticesEnd() const { return vertices_.end(); } Vertex const * vertex(const int i) const { return vertices_[i]; } Vertex*& vertex(const int i) { return vertices_[i]; } //@} //@{ // Accessor functions for the vertices associated with this face. // // Once initialised, it may be assumed that the edge has exactly three edges. size_t edges() const { return edges_.size(); } typename EdgeContainer::iterator edgesBegin() { return edges_.begin(); } typename EdgeContainer::iterator edgesEnd() { return edges_.end(); } typename EdgeContainer::const_iterator edgesBegin() const { return edges_.begin(); } typename EdgeContainer::const_iterator edgesEnd() const { return edges_.end(); } Edge const * edge(const int i) const { return edges_[i]; } Edge*& edge(const int i) { return edges_[i]; } //@} //@{ // Accessors for computed variables Point normal() const { return normal_; } void normal(const Point& p) { normal_ = p; } T area() const { return area_; } //@} /** Get the angle around a vertex. * * \param a Pointer to the vertex around which we want the angle. */ T angle(const Vertex * const a) const; /** Get the midpoint of the edge opposite a. */ T oppositeMidpoint(const Vertex * const a) const; /** Find the vertex opposite an edge. * * \param edge An edge which is associated with this face. * \return A pointer to the vertex on this edge which is not on the given edge. */ const Vertex* oppositeVertex(const Edge * const edge) const; /** The distance to the face assuming p is within the characteristic polyhedron. * * If p is not inside the polyhedron, the distance may be an underestimate. * * \param p A point inside the characteristic polyhedron. */ T characteristicDistance(Point p) const; /** Constructs the characteristic polyhedron for this face. * * * \param range How far (as a scalar) the polyhedron extends from the boundary. The sign determines whether the characteristic polyhedron for positive or negative distances is returned. * \return A polyhedron with nine edges if the face is locally closed (joins two faces); an empty polyhedron otherwise. */ Polyhedron<T> createCharacteristicPolyhedron(const T range) const; /** Constructs the scannable polyhedron for this face. * * \return Same polyhedron as createCharacteristicPolyhedron along with a distance function to the face. */ ScanConvertiblePolyhedron<T> createScannableCharacteristicPolyhedron(const T range) const; };
2ab4c3a4ddafd5df4a96190869d08d8aa1acf043
fe6e47273fed2ed22a2443637805c51ee3b09a7c
/Command/Command.cpp
b1c79558a837de1dbf51cc03185294291484202f
[]
no_license
hljgirl/DesignPatterns
303f209d9b8b86ecb9bec834e14cd7725f1eaca8
ea8e4b6a63080453ac6d2da0c044c61a70008162
refs/heads/master
2021-01-02T09:23:57.940239
2017-08-10T08:58:33
2017-08-10T08:58:33
99,206,422
0
0
null
null
null
null
UTF-8
C++
false
false
138
cpp
Command.cpp
#include "stdafx.h" #include "Command.h" Command::Command(RunnerClub* runnerClub):_runnerClub(runnerClub) { } Command::~Command() { }
068d883a40a75dcc8861fc029b0db6bd834251b7
325977b462657720c8df5fcd394b1179477494e8
/object3dwindow.h
d0711e28746b5ea25a5cb88aafe8bd442f75e053
[]
no_license
jakubpradzynski/azariah
f2a19338c729eccdc061ba9f47b7e343e4d2f1ef
030aed32fe5dd52f07a18d59986ef6d1ff238c17
refs/heads/master
2020-03-22T08:24:51.220533
2018-09-11T16:14:29
2018-09-11T16:14:29
139,764,856
0
0
null
null
null
null
UTF-8
C++
false
false
375
h
object3dwindow.h
#ifndef OBJECT3DWINDOW_H #define OBJECT3DWINDOW_H #include <QWidget> #include <iostream> namespace Ui { class Object3DWindow; } class Object3DWindow : public QWidget { Q_OBJECT public: explicit Object3DWindow(QWidget *parent = 0); ~Object3DWindow(); void start(const char *pathToFile); private: Ui::Object3DWindow *ui; }; #endif // OBJECT3DWINDOW_H
48550e4ad896be6cfb9e4b84ec1288c7812414bc
9b7a6a7ceed99f121623d75b46514e060ce84096
/include/yama/shorthand.hpp
db76d7256ab82adecc0776d8ec891c13010307ea
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
iboB/yama
16831001e68487ae3a898af423334fd20a158f73
cc47134777187048ad850505f1327e1ee578232a
refs/heads/master
2022-10-09T00:38:18.178326
2022-09-26T17:20:28
2022-09-26T17:20:28
79,384,127
12
2
NOASSERTION
2019-08-04T15:31:13
2017-01-18T21:04:10
C++
UTF-8
C++
false
false
269
hpp
shorthand.hpp
// Copyright (c) Borislav Stanimirov // SPDX-License-Identifier: MIT // #pragma once #if !defined(YAMA_NO_SHORTHAND) #if !defined(YAMA_PREFERRRED_TYPE) #define YAMA_PREFFERED_TYPE float #endif namespace yama { using preferred_type = YAMA_PREFFERED_TYPE; } #endif
d9cee96a8638d48901865f056dc4255b0d9e18b1
6b847c6638d0021155991817b1b326644bf254cf
/src/interface.cc
4ab36bbbb9899d899ae04a0233c02a7d0e6f04bc
[]
no_license
jagd/ariadne_expr
185daf8631ef536ef4c4f5a40004d9f5403d966b
859871dc91e385338901c152a48ff60d840a8ee9
refs/heads/master
2022-01-16T08:16:40.934136
2015-10-15T07:57:28
2015-10-15T07:57:28
197,926,274
0
0
null
null
null
null
UTF-8
C++
false
false
2,988
cc
interface.cc
#include "interface.h" #include "parser.h" #include "ast.h" #include <sstream> #include <utility> #include <string> #include <parameter.h> // ariadne code struct ExpressionImpl { std::unique_ptr<Ast> ast_; bool hasError_; std::string msg_; }; Expression::Expression() : impl_(std::make_shared<ExpressionImpl>()) { impl_->hasError_ = true; impl_->msg_ = "no expression is given"; } Expression::Expression(const std::string &expr) : impl_(std::make_shared<ExpressionImpl>()) { parse(expr); } bool Expression::parse(const std::string &expr) { std::istringstream s(expr); auto p = Parser(s); impl_->ast_ = p.parseExpr(); if (impl_->ast_) { if (!p.eof()) { impl_->hasError_ = true; impl_->msg_ = "unprocessed components on the end, " "maybe there is more than one expression given"; return false; } impl_->hasError_ = false; impl_->msg_ = "no error"; } else { impl_->hasError_ = true; impl_->msg_ = p.msg(); } return !impl_->hasError_; } Expression::operator bool() const { return !impl_->hasError_; } std::set<std::string> Expression::symbols() const { impl_->hasError_ = false; return ::symbols(impl_->ast_); } const std::string Expression::msg() const { return impl_->msg_; } std::pair<std::shared_ptr<parameter>, std::string> Expression::eval(const Expression::Dict &dict) { std::shared_ptr<parameter> rp; impl_->hasError_ = false; if (!impl_->ast_) { impl_->hasError_ = true; impl_->msg_ ="parse failed or no given expression"; return std::make_pair(rp, impl_->msg_); } Ast::Dict d; for (const auto &i : dict) { switch (i.second->getType()) { case PT_REAL: d[i.first] = Ast::make(i.second->getValueReal()); break; case PT_STRING: d[i.first] = Ast::makeString(i.second->getValueString()); break; // case PT_BOOL:break; default: impl_->hasError_ = true; impl_->msg_ = "unrecognizable parameter type"; return std::make_pair(rp, impl_->msg_); } } auto r = ::eval(impl_->ast_, d, impl_->msg_ ); if (!r) { if (impl_->ast_) { impl_->hasError_ = true; return std::make_pair(rp, impl_->msg_); } } switch (r->t) { case Ast::T::NUMBER: rp = std::make_shared<parameter>(PT_REAL); rp->setValueReal(r->num); break; case Ast::T::STRING: rp = std::make_shared<parameter>(PT_STRING); rp->setValueString(r->str); break; case Ast::T::BOOLEAN: rp = std::make_shared<parameter>(PT_REAL); rp->setValueReal(r->b); break; default: break; } return std::make_pair(rp, impl_->msg_); }
7149572ed14149e9e8943676bb682150cfd3337d
10ddfb2d43a8ec5d47ce35dc0b8acf4fd58dea94
/C++/invert-binary-tree.cpp
f08fa7b42a15a0e60591b8ae8f0d67a5de7ca284
[ "MIT" ]
permissive
kamyu104/LeetCode-Solutions
f54822059405ef4df737d2e9898b024f051fd525
4dc4e6642dc92f1983c13564cc0fd99917cab358
refs/heads/master
2023-09-02T13:48:26.830566
2023-08-28T10:11:12
2023-08-28T10:11:12
152,631,182
4,549
1,651
MIT
2023-05-31T06:10:33
2018-10-11T17:38:35
C++
UTF-8
C++
false
false
1,886
cpp
invert-binary-tree.cpp
// Time: O(n) // Space: O(h) /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ // Time: O(n) // Space: O(w), w is the max number of nodes of the levels. // BFS solution. class Solution { public: TreeNode* invertTree(TreeNode* root) { if (root != nullptr) { queue<TreeNode*> nodes; nodes.emplace(root); while (!nodes.empty()) { auto node = nodes.front(); nodes.pop(); swap(node->left, node->right); if (node->left != nullptr) { nodes.emplace(node->left); } if (node->right != nullptr) { nodes.emplace(node->right); } } } return root; } }; // Time: O(n) // Space: O(h) // Stack solution. class Solution2 { public: TreeNode* invertTree(TreeNode* root) { if (root != nullptr) { stack<TreeNode*> nodes; nodes.emplace(root); while (!nodes.empty()) { auto node = nodes.top(); nodes.pop(); swap(node->left, node->right); if (node->left != nullptr) { nodes.emplace(node->left); } if (node->right != nullptr) { nodes.emplace(node->right); } } } return root; } }; // Time: O(n) // Space: O(h) // DFS, Recursive solution. class Solution3 { public: TreeNode* invertTree(TreeNode* root) { if (root != nullptr) { swap(root->left, root->right); invertTree(root->left); invertTree(root->right); } return root; } };
47e313e2b5cfb7366a800012382cdb7dbf5cd1a7
6c7a957fe0d5d7d43b5739b5b2660b0637f3bc9a
/Tema4/problema3.cpp
0b6c7891c84b348a39bef5aa44f11ff3a8d97de7
[]
no_license
Starnox/Bac
36daa296578bd99b7ef35c6730318e348b817529
98e302ee0d446cd0d3005eeb6755225ae201e6d9
refs/heads/master
2021-06-25T11:50:04.527571
2021-04-20T07:17:22
2021-04-20T07:17:22
221,260,147
0
0
null
null
null
null
UTF-8
C++
false
false
697
cpp
problema3.cpp
//#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #include <bits/stdc++.h> #include <cstring> using namespace std; // CHECK THE LIMITS typedef long long ll; static const int NMAX = 1e5; int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } char s[25][25]; char first[405]; char second[405]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,k; cin >> n; for(int i =0; i < n; ++i) { cin >> s[i]; cin.get(); } cin >> k; for(int i = 0; i< n; ++i) { if(strlen(s[i]) == k) { strcat(first,s[i]); strcat(first," "); } else { strcat(second,s[i]); strcat(second," "); } } strcat(first,second); cout << first; return 0; }
48d8f4b3f0756a42c68b4f3a43ebc1609880e2c2
4df53d4396ef3ebd4b87353f392162dd266cb819
/src/26.cpp
e0ac9c75021e877fe4c58e6bef9b5cd19fb9de3f
[]
no_license
NearXdu/huawei
14c635cc23ffe0845ca58c0cf48e40d23fa6df1e
571927a25f3e429ffd760ee5f37521ab2e101f28
refs/heads/master
2020-04-05T13:05:16.305389
2017-06-30T08:28:10
2017-06-30T08:28:10
95,072,828
10
2
null
null
null
null
UTF-8
C++
false
false
684
cpp
26.cpp
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(int argc,char **argv) { string raw; while(getline(cin,raw)) { vector<string>sorted(26); for(int i=0;i<raw.size();++i) { if(std::isalpha(raw[i])) { if(raw[i]>='a'&&raw[i]<='z') { sorted[raw[i]-'a']+=raw[i]; } else { sorted[raw[i]-'A']+=raw[i]; } } } string tmp; for(int i=0;i<sorted.size();++i) { tmp+=sorted[i]; } int count=0; for(int i=0;i<raw.size();++i) { if(std::isalpha(raw[i])) { cout<<tmp[count++]; } else { cout<<raw[i]; } } cout<<endl; } return 0; }
49d0ea803b63f6970545423f819fe61a1fc2b303
689878216addb2a55ae0ee15df4d433e799228d4
/controller.hpp
18cf245a5e2b309248058bbc400c0782786bd638
[ "Apache-2.0" ]
permissive
eddiejames/phosphor-usbd
14a690c6d882dd5c071203c680432618ee4894ee
61ce952dce43237e37f98b2a913dc1e6ee384358
refs/heads/main
2023-07-09T10:26:53.511003
2021-08-10T19:56:00
2021-08-10T19:56:00
381,129,343
0
0
null
null
null
null
UTF-8
C++
false
false
691
hpp
controller.hpp
#include <xyz/openbmc_project/State/USB/server.hpp> #include <sdbusplus/bus.hpp> namespace phosphor { namespace usbd { namespace fs = std::filesystem; using ControllerInherit = sdbusplus::server::object::object<sdbusplus::xyz::openbmc_project::State::server::USB>; class Controller : ControllerInherit { public: Controller(const fs::path& path, sdbusplus::bus::bus &bus, const char *objPath) : ControllerInherit(bus, objPath), path(path), bus(bus) { discoverInitialState(); } State Status(State state) override; private: void discoverInitialState(); const fs::path path; sdbusplus::bus::bus &bus; }; } // namespace usbd } // namespace phosphor
652d686dde218c709a9fa5b52fcfec0dcf83ef03
35731244794c4b9d70a3070124c94446b0a9adf4
/PEA3/PEA3.cpp
f1381d6c594a6e5e795ea87cf97f7676ffec823d
[]
no_license
kbrzezinska/projects-in-C-
706e5d44836157e81e9564f2587576a2a377e0ef
ccb40e7cb8d894029978ddcdca8c6d6cd994b0b9
refs/heads/master
2021-02-05T19:32:59.652992
2020-02-28T18:00:03
2020-02-28T18:00:03
243,823,337
0
0
null
null
null
null
UTF-8
C++
false
false
709
cpp
PEA3.cpp
// PEA3.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <ctime>; #include "genetyczny.h" #include "Menu.h" #include <ctime> #include "stdlib.h" int _tmain(int argc, _TCHAR* argv[]) { srand(time(0)); Menu m = Menu(); /*Genetic g = Genetic(); string s = "tsp_10.txt"; string ss = "rbg403.atsp"; g.download(ss); //g.pobierz(s); g.stop = 60*6; g.population = 10; g.geneticAlg(); cout << g.bestCost << endl; cout << double(g.bestCost - 2465) / double(2465) << endl; g.geneticAlg(); cout << g.bestCost << endl; cout << double(g.bestCost - 2465) / double(2465) << endl; */ return 0; }
b25dcde613991f7616c99c7b923cb8f2d628b989
1ab6a152184bc9fe36a111e4f7be85eeac19ed97
/code/util/fileUtil.h
92873a5d2ba4045b91f0ec6226c395fbb1b023a7
[]
no_license
WangShanyue/X86ToMips
a8ee562776a07982c39741ad63a8f40f11e645f4
2a92ca690b6f914f84820cd988dcc51db7773f24
refs/heads/master
2020-04-23T06:36:56.508471
2018-12-25T06:28:26
2018-12-25T06:28:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
451
h
fileUtil.h
// // Created by cyw35 on 2018/12/25. // #ifndef X86TOMIPS_FILEUTILL_H #define X86TOMIPS_FILEUTILL_H #include<iostream> #include <fstream> #include <sstream> #include <cstdlib> #include <cassert> #include <string> #include <map> #include <vector> #include <cstring> using namespace std; //文件处理类 class fileUtil { vector<string> readTxt(string file); void writeTxt(char *file, string content); }; #endif //X86TOMIPS_FILEUTILL_H
c1579f305bfbc511520aaf79ea06c3e0a8dbd4f8
e9f6461fea7045bb07fc2be09ae1a9ec609b50f0
/2011/server_src/Frame/MD5.h
ccc32d77c2194eac802f1801e8435cec3fb77660
[]
no_license
cash2one/important-files
bd1a88ea30e3ff16b4fbba6b4939ab6b13f5a6c8
12aebeae6322fafb89869ab15eac588420cbb004
refs/heads/master
2021-01-15T23:20:54.484632
2012-09-19T04:21:08
2012-09-19T04:21:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,326
h
MD5.h
/* MD5.H - header file for MD5C.C */ /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ #ifndef PROTOTYPES #define PROTOTYPES 1 #endif #pragma warning(disable:4996) #include <string> /* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; /* UINT2 defines a two byte word */ typedef unsigned short int UINT2; /* UINT4 defines a four byte word */ typedef unsigned long int UINT4; /* PROTO_LIST is defined depending on how PROTOTYPES is defined above. If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it returns an empty list. */ #if PROTOTYPES #define PROTO_LIST(list) list #else #define PROTO_LIST(list) () #endif /* MD5 context. */ typedef struct { UINT4 state[4]; /* state (ABCD) */ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX; void MD5Init(MD5_CTX *); void MD5Update(MD5_CTX *, unsigned char *, unsigned int); void MD5Final(unsigned char [16], MD5_CTX *); #include <windows.h> #include <tchar.h> namespace i8desk { void __stdcall MD5Encode(const void* data, size_t ByteLen, LPTSTR md5) { MD5_CTX context = {0}; unsigned char digest[16] = {0}; MD5Init(&context); MD5Update(&context, (unsigned char*)data, ByteLen); MD5Final(digest, &context); for (size_t idx = 0; idx<16; idx++) { _stprintf(&(md5[2 * idx]), TEXT("%02x"), digest[idx]); } } unsigned long g_Crc32Table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL }; void CalcCrc32(unsigned char byte, unsigned long& dwCrc32) { dwCrc32 = ((dwCrc32) >> 8) ^ g_Crc32Table[(byte) ^ ((dwCrc32) & 0x000000FF)]; } unsigned long __stdcall CalBlockCrc(char* data, size_t length) { unsigned char* pdata = (unsigned char*)data; unsigned long crc(0xffffffff); while(length--) crc = (crc >> 8) ^ g_Crc32Table[(crc & 0xFF) ^ *pdata++]; return crc^0xffffffff; } }
a85b94265a2eccacc857dc43e8f0f26bd5ba14cb
e31e59c4c0097f163d892b698c01dbabaa0f26bf
/torch/csrc/jit/python_compiled_function.h
24847df590f81337ba049f736a31c2e3a0ad3362
[ "BSD-2-Clause" ]
permissive
aszenz/pytorch
f76d35eadd5fd05f651eeab69fb4563782b6cd12
5b2204beedef764a21586c886cc599de67f7b5de
refs/heads/master
2020-04-03T15:03:07.389441
2018-10-30T08:56:59
2018-10-30T08:56:59
155,348,066
0
0
NOASSERTION
2018-10-30T08:13:39
2018-10-30T08:13:39
null
UTF-8
C++
false
false
170
h
python_compiled_function.h
#pragma once #include "torch/csrc/jit/pybind.h" #include <tuple> namespace torch { namespace jit { namespace python { void initCompilerMixin(PyObject *module); }}}
e89131050bb2d63fcd90e9b4d29c59e2c0cf9f5a
e64392aad7be42a24278dcfd350f5e06e3fdef21
/include/std/Array.h
142d01a69f98b916cc8e8681ba5951b57054d784
[]
no_license
vehar/TurtlOS
05bf0fad3ca9b284fd694214045fa7cfd43d375d
76c73b3abae5c7564f695a9532e35931020c7131
refs/heads/master
2023-03-15T21:51:18.416519
2014-04-09T06:16:29
2014-04-09T06:16:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,429
h
Array.h
#ifndef INC_ARRAY_HPP #define INC_ARRAY_HPP #if _MSC_VER > 1000 #pragma once #endif #ifndef __cplusplus #error "This C++ header was included in C file" #endif /// Represents a generic Array template <class T, unsigned SIZE> class Array { public: /// Array iterator class It { friend class Array<T, SIZE> ; private: /// Index of element unsigned mIndex; /// Constructor It(const unsigned index) : mIndex(index) { } public: /// Destructor ~It() { } /// Comparison operator bool operator ==(const It& it) const { return mIndex == it.mIndex; } /// Comparison operator bool operator !=(const It& it) const { return mIndex != it.mIndex; } /// Moves to next item It operator ++() { ++mIndex; return (*this); } /// Moves to previous item It operator --() { --mIndex; return (*this); } }; /// Constructor Array() : _count(0) { } /// Destructor ~Array() { } /// Returns the size of the list int Count() const { return _count; } /// Clears the Array void Clear() { _count = 0; } /// Checks if Array is empty bool IsEmpty() const { return !_count; } /// Checks if Array is full bool IsFull() const { return _count >= SIZE; } /// Returns iterator that points to the first item in the Array It First() const { return It(0); } /// Returns iterator that points to the last item in the Array It Last() const { return It(_count - 1); } /// Returns iterator that represents the end of the Array It End() const { return It(_count); } /// Appends an item to the back of the Array /// @param item Item to append void Append(const T& item) { assert(!IsFull()); _data[_count++] = item; } /// Inserts an item on a specified position /// @param index Position to insert at /// @param item Item to insert void Insert(const It it, const T& item) { assert(!IsFull()); assert(it.mIndex <= _count); for (unsigned i = _count; i > it.mIndex; --i) { _data[i] = _data[i - 1]; } _count++; _data[it.mIndex] = item; } /// Removes an item on a specified position /// @param index Position to remove at void RemoveAt(const It it) { assert(it.mIndex < _count); for (unsigned i = it.mIndex + 1; i < _count; ++i) { _data[i - 1] = _data[i]; } _count--; } /// Finds first occurrence of an item /// @param item Item to find /// @returns Iterator pointing to found item or End if not found It FindFirst(const T& item) const { for (unsigned i = 0; i < _count; ++i) { if (_data[i] == item) { return It(i); } } return It(_count); } /// @param it Iterator /// @returns Constant item at iterator position T& operator[](const It& it) { assert(it.mIndex < _count); return _data[it.mIndex]; } /// @param it Iterator /// @returns An item at iterator position const T& operator[](const It& it) const { assert(it.mIndex < _count); return _data[it.mIndex]; } private: /// Items count unsigned _count; /// Data buffer T _data[SIZE]; }; #endif // INC_ARRAY_HPP
5525f1f06945da79adb0ab51a357e6c84b6cdad6
aecb05939172464d69029dacbd6b5673867fb062
/Comet/Animation.h
24230f238b5853c4f06d592495f25652825afe2f
[]
no_license
MegaMilkX/Comet
d84cd393de594624ecd91e8071f2b06b48cab96f
4b6889ad0017f1a9e564840c43f344a3b65823eb
refs/heads/master
2021-01-09T23:42:03.415250
2015-05-16T22:50:50
2015-05-16T22:50:50
26,982,001
1
0
null
null
null
null
UTF-8
C++
false
false
3,627
h
Animation.h
#pragma once #include "Resource.h" #include <fbxsdk.h> #include <fbxsdk\fileio\fbxiosettings.h> #include "math3f.h" #include <vector> #include <algorithm> #include <memory> #include "Node.h" namespace Comet { class Key { public: enum INTERPOLATIONMODE { CONSTANT, LINEAR, CUBIC }; Key(int t, float v) : time(t), value(v), mode(CONSTANT){} int Time() const { return time; } float Value() const { return value; } bool operator<(const Key &k) {return (time < k.Time());} private: int time; float value; INTERPOLATIONMODE mode; }; class Curve { public: ~Curve() { for (unsigned int i = 0; i < curves.size(); ++i) delete curves[i]; } void SetKey(int time, float value) { timeline.push_back(Key(time, value)); std::sort(timeline.begin(), timeline.end()); } //TODO: NOT IMPLEMENTED void RemoveKey(int time){} virtual float Evaluate(float time, Node* node = 0) { Key a(0,0), b(0,0); for (unsigned int i = 0; i < timeline.size(); ++i) { if (timeline[i].Time() > time) { b = timeline[i]; break; } a = timeline[i]; b = a; } if (a.Time() == b.Time()) return a.Value(); float valdiff = b.Value() - a.Value(); float weight = (time - a.Time()) / (float)(b.Time() - a.Time()); return a.Value() + valdiff * smoothstep(0.0f, 1.0f, weight); } Curve* GetCurve(int i){ return curves[i]; } protected: std::vector<Key> timeline; std::vector<Curve*> curves; }; class TranslationCurve : public Curve { public: TranslationCurve() { curves.push_back(new Curve()); curves.push_back(new Curve()); curves.push_back(new Curve()); } float Evaluate(float time, Node* node) { node->SetPosition(vec3f(curves[0]->Evaluate(time), curves[1]->Evaluate(time), curves[2]->Evaluate(time))); return 0.0f; } }; class RotationCurve : public Curve { public: RotationCurve() { curves.push_back(new Curve()); curves.push_back(new Curve()); curves.push_back(new Curve()); } float Evaluate(float time, Node* node) { float x = curves[0]->Evaluate(time); float y = curves[1]->Evaluate(time); float z = curves[2]->Evaluate(time); float c1 = cos(y * 0.5f); float c2 = cos(z * 0.5f); float c3 = cos(x * 0.5f); float s1 = sin(y * 0.5f); float s2 = sin(z * 0.5f); float s3 = sin(x * 0.5f); quat q; q.x = s1*s2*c3+c1*c2*s3; q.y = s1*c2*c3+c1*s2*s3; q.z = c1*s2*c3-s1*c2*s3; q.w = c1*c2*c3-s1*s2*s3; node->SetRotation(q); return 0.0f; } }; class ScaleCurve : public Curve { public: ScaleCurve() { curves.push_back(new Curve()); curves.push_back(new Curve()); curves.push_back(new Curve()); } float Evaluate(float time, Node* node) { node->Scale(vec3f(curves[0]->Evaluate(time), curves[1]->Evaluate(time), curves[2]->Evaluate(time))); return 0.0f; } }; //Animation track resource class Animation : public Resource { public: Animation(); ~Animation(); void Load(std::string path); void MakeDefault() { } void Unload(); // void SetLength(int l){ length = l; } int GetLength(){ return length; } template<typename T> Curve* NewCurve() { curves.push_back(new T()); return curves[curves.size() - 1]; } int GetCurveCount(){ return curves.size(); } Curve* GetCurve(int i){ return curves[i]; } private: std::vector<Curve*> curves; std::vector<std::shared_ptr<Animation>> animations; int length; void _ProcessNode(FbxNode* node, FbxAnimLayer* layer); void _GetKeys(FbxAnimCurveNode* curve, Curve* dst, int n, bool toRadians = false); }; }
b4133e39db69189f8b6f962ed138738e349963ae
cff366a360ad7d0e17ad0ab13831fa7203ed1b2d
/C++/ConsoleTricks/src/Sprite.h
6e5b3fafab0dbb5b0853f581dbda9a9a729b2e0d
[]
no_license
tcstrength/projects
c2bf6c4dfc5023483eff939a9860bf3f66833205
995fae7d94e8e2ec3e3cf40d04d43121f3cbaa02
refs/heads/master
2021-10-25T11:43:03.781429
2019-04-03T23:39:10
2019-04-03T23:39:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
395
h
Sprite.h
#ifndef SPRITE_H #define SPRITE_H #include "Screen.h" class Sprite { public: Sprite(const std::vector<std::string>& data); void render(Screen& screen); uint getPosX() const; void setPosX(const uint& posX); uint getPosY() const; void setPosY(const uint& posY); private: std::vector<std::string> m_data; uint m_posX; uint m_posY; }; #endif // SPRITE_H
f92e42547d69a9506f7fe6d9017e524d7cda936d
b60f7f4a4883f0fe177a09a3ca97b52d1a584d90
/server/BINARIZADO/machine_events.cpp
f10737c2d1d1ea210a095d0c357ae7899e0495cd
[]
no_license
dirgnisally/basedatos2
c904eee99c2cfb8bc21339ad0daf52832850bd2a
0da8c2464d1d180b331c750b0eabdccfb0df685a
refs/heads/master
2020-03-18T13:45:24.242130
2018-07-20T19:48:30
2018-07-20T19:48:30
134,806,228
0
0
null
null
null
null
UTF-8
C++
false
false
4,404
cpp
machine_events.cpp
#include <iostream> #include <string> #include <cmath> #include <limits> #include <map> #include <unordered_map> #include <fstream> #include <cstdio> #include <string.h> #include <cstdlib> #include <vector> using namespace std; struct MachineEvents{ long time; //Integer long machineId; //Integer char eventType; //Integer char platformId[45]; //String 44 espacios float cpus; //Float float memory; //Float bool active; //Para saber si el registro fue borrado(false) o no(true) MachineEvents(){ time = -1; machineId = -1; active = true; } }; void split(vector<string> &v, const string& s, const char& c) { string buff = ""; for(auto n:s){ if(n != c) buff += n; else { v.push_back(buff); buff = ""; } } v.push_back(buff); } /* 13 10 1 44 4 7 12583(machine id unico) 37780 */ void sizeAtrib(string file) { long tie, job, sizeUser = 0, sizeName = 0, sizeLogical = 0, size; long cont = 0; ifstream read(file.c_str()); string linea; vector<string> palabras; vector<long> tam(6,0); //map<string, int> jobId; map<string, int> machineId; getline(read, linea); while(!read.eof()) { palabras.clear(); split(palabras, linea, ','); for(int i = 0; i < 6; ++i){ size = palabras[i].size(); if(size > tam[i]) tam[i] = size; } //jobId[palabras[2]] = 0; machineId[palabras[1]] = 0; cont++; if(cont % 10000 == 0){ cout << cont << endl; } getline(read, linea); } for(int i = 0; i < 6; ++i) cout << tam[i] << endl; cout << machineId.size() << " " << cont << endl; read.close(); } void createBinaryAndIndex(string file) { long pos = 0; ifstream read(file.c_str()); string linea; vector<string> palabras; //unordered_map<long, vector<long> > jobId; // Guarda los jobId con los registros unordered_map<long, vector<long> > machineId; // Guarda los machineId con los registros //unordered_map<long, vector<long> > taskIndex; // Guarda los taskIndex con los registros FILE *binary; binary = fopen("machine_events.bin","wb"); for(long i = 0; i < 37780; ++i){ getline(read, linea); palabras.clear(); split(palabras, linea, ','); MachineEvents machineEvents; pos = ftell(binary); if(palabras[0].size() != 0) machineEvents.time = atol(palabras[0].c_str()); if(palabras[1].size() != 0) machineEvents.machineId = atol(palabras[1].c_str()); if(palabras[2].size() != 0) machineEvents.eventType = palabras[2][0]; strcpy(machineEvents.platformId, palabras[3].c_str()); if(palabras[4].size() != 0) machineEvents.cpus = atof(palabras[4].c_str()); if(palabras[5].size() != 0) machineEvents.memory = atof(palabras[5].c_str()); fwrite (&machineEvents , sizeof(machineEvents), 1, binary); //jobId[taskEvents.jobId].push_back(pos); machineId[machineEvents.machineId].push_back(pos); //taskIndex[taskEvents.taskIndex].push_back(pos); if(i % 20000 == 0) cout << i << endl; } //cout << jobId.size() << endl; //" " << machineId.size() << " " << taskIndex.size() << endl; read.close(); fclose(binary); /* ofstream esJob("jobId.key"); esJob << 144648282 << endl; for(auto it1 = jobId.begin(); it1 != jobId.end(); ++it1){ esJob << it1->first; for(int i = 0; i < it1->second.size(); ++i) esJob << " " << it1->second[i]; esJob << endl; } esJob.close();*/ ofstream esMa("machineId.key"); esMa << 37780 << endl; for(auto it1 = machineId.begin(); it1 != machineId.end(); ++it1){ esMa << it1->first; for(int i = 0; i < it1->second.size(); ++i) esMa << " " << it1->second[i]; esMa << endl; } esMa.close(); /* ofstream esTa("taskIndex.key"); esTa << 144648282 << endl; for(auto it1 = taskIndex.begin(); it1 != taskIndex.end(); ++it1){ esTa << it1->first; for(int i = 0; i < it1->second.size(); ++i) esTa << " " << it1->second[i]; esTa << endl; } esTa.close(); */ } int main() { createBinaryAndIndex("machine_events.csv"); return 0; }
367e34efd1ddbb60e7b577dcb701847396550e5f
16addc5cd60d79c5309e63bb582fe1870155ef59
/Castlevania_Game/Dagger.h
3b918d3683a34a0d93a6ed03aa6854a11a16ce44
[]
no_license
tienthanght96/Directx_Game_2016
3b2e2f6182e89de9aea9d83a969a09b8ae50cf59
98e6cdabdcbc0dc26d61d81bf51a2d9638314923
refs/heads/master
2021-01-12T05:23:19.279433
2017-01-03T13:52:52
2017-01-03T13:52:52
77,919,338
0
0
null
null
null
null
UTF-8
C++
false
false
837
h
Dagger.h
#pragma once #include "CObject.h" #include "Box.h" #include "SweptAABB.h" #define DAGGER_SPRITE "Resources\\Sprites\\Weapons\\Dagger\\DaggerSheet.png" #define DAGGER_SHEET "Resources\\Sprites\\Weapons\\Dagger\\DaggerSheet" #define DAGGER_ANIMATE_RATE 8 #define GRAVITY 0.00048828125F #define DAGGER_X 0.1825F #define DAGGER "Dagger" #define DAGGER_WIDTH 32 #define DAGGER_HEIGHT 18 class Dagger : public M2DXAnimatedSprite, CObject { public: Dagger(int X, int Y, bool AD); ~Dagger(); void Update(int deltaTime, CObject* simon); void Draw() override; protected: string getNextFrame() override { return DAGGER; }; int getAnimateRate() override { return DAGGER_ANIMATE_RATE; } private: D3DXVECTOR2 velocity; SweptAABB *swept = new SweptAABB(); void updateInfor(); void updatePosition(CObject* simon, int deltaTime); };
2ce30480d7cdde9fd9b543ea5964d69816b995cf
7fae527bf3468cd93c7642f176df0b5720fc581f
/Framework/src/Mesh.cpp
bd02f9b861bd84f5c7ecb3406eb41ed1481342d8
[]
no_license
jparimaa/myvk
bf325d6b357ecd87bc7bc54e71835eab503dbdd2
b52043f2c566863ddbfdb433f2f7b1d301046117
refs/heads/master
2021-07-04T08:31:02.515972
2019-05-14T09:52:21
2019-05-14T09:52:21
105,790,146
2
1
null
2018-11-06T17:34:19
2017-10-04T16:17:18
C++
UTF-8
C++
false
false
894
cpp
Mesh.cpp
#include "Mesh.h" #include "Common.h" #include <stdexcept> #include <utility> namespace fw { Mesh::Vertices Mesh::getVertices() const { Vertices vertices; vertices.reserve(positions.size()); for (unsigned int i = 0; i < positions.size(); ++i) { Vertex v; v.position = positions[i]; v.normal = normals[i]; if (!tangents.empty()) { v.tangent = tangents[i]; } if (!uvs.empty()) { v.uv = uvs[i]; } vertices.push_back(std::move(v)); } return vertices; } std::string Mesh::getFirstTextureOfType(aiTextureType type) const { std::string ret = ""; try { ret = materials.at(type).at(0); } catch (const std::out_of_range& /*e*/) { printError("Mesh has no texture for the requested type"); } return ret; } } // namespace fw
c6e5438ec549d2a5999247bdd33bd53049f9f6db
d85978556a8e57fe33fedfc9b2c7ff38d0cb6e8b
/A Chessboard Game/A Chessboard Game.cpp
59a5665d7248692663fb09adac55a268b4671eca
[]
no_license
Lianghe-Chen/hackerrank-2
c9ee73df5b6f13e92f057281c12789a61bec8554
1d7aa60f9c02e2130da1ac7482bd3c9ae1de8a83
refs/heads/master
2022-03-27T03:10:02.998643
2019-12-12T01:00:29
2019-12-12T01:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
326
cpp
A Chessboard Game.cpp
#include <iostream> using namespace std; int main() { int t; cin >> t; for (int x, y; cin >> x >> y; ) { int r1 = x % 4, r2 = y % 4; if ((r1 == 1 || r1 == 2) && (r2 == 1 || r2 == 2)) { cout << "Second\n"; } else { cout << "First\n"; } } return 0; }
882c6ac44a0e559991576e43e510d3b69e84d285
ceeb04e3e5a04d1567c6df13d0f18dc4578f5f7b
/C语言实现多态诸葛亮的锦囊妙计/诸葛亮的锦囊妙计.cpp
034955bd96d66514b60e41b8fc27a48f3df0b216
[]
no_license
ahangshizz/Learningrecord
ca74784b2158f9d448e823279a4a7e4586c3cd59
47ee426d7b3ee77d1c518a37d47e7aaa57a74a07
refs/heads/master
2022-02-28T17:10:26.688422
2019-09-15T02:18:29
2019-09-15T02:18:29
177,227,190
0
0
null
null
null
null
GB18030
C++
false
false
1,574
cpp
诸葛亮的锦囊妙计.cpp
#define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; //抽象层 //打开锦囊的方法 typedef void (TIPS)(void); struct tip { char from[64]; char to[64]; TIPS*tp; }; //创建锦囊的方法 struct tip* creat_tip( char const*from, char const*to, TIPS*tp) { struct tip* temp = (struct tip*)malloc(sizeof(struct tip)); if (temp == NULL) { return NULL; } strcpy(temp->from, from); strcpy(temp->to, to); temp->tp = tp; return temp; } //打开锦囊的构架函数 void open_tips(struct tip*tip_p) { cout << "打开了锦囊" << endl; cout << "此锦囊是由" << tip_p->from << "写给" << tip_p->to << "的." << endl; cout << "内容是" << endl; tip_p->tp(); } //销毁锦囊 void destory(struct tip*tp) { if (tp != NULL) { free(tp); tp = NULL; } } //实现层 void tip1_func(void) { cout << "到东吴找乔国公" << endl; } void tip2_func(void) { cout << "刘备乐不思蜀,就说曹贼大军压境" << endl; } void tip3_func(void) { cout << "被追杀就找孙夫人帮忙" << endl; } int main() { //创建三个锦囊 struct tip*tip1 = creat_tip("诸葛亮", "赵云", tip1_func); struct tip*tip2 = creat_tip("诸葛亮", "赵云", tip2_func); struct tip*tip3 = creat_tip("诸葛亮", "赵云", tip3_func); //拆锦囊 cout << "赵云来到东吴" << endl; open_tips(tip1); cout << "到了年底" << endl; open_tips(tip2); cout << "被人追杀时" << endl; open_tips(tip3); //释放 destory(tip1); destory(tip2); destory(tip3); return 0; }
0a8203ffb9cd50e8784907cdb38efbccda626781
a5a0be53e13091e7b63991057e8b95fca7201f0b
/Mario 2D/Mario 2D/Mario 2D/FPS.h
d93c17b743b66b551b687f468e06506d31863586
[]
no_license
doanhtdpl/mario-uit
7924b288b1f2bc281daa7df0dabfc0eb1484542e
ac673408f71ac4d9e45f888e26d6692de0184c58
refs/heads/master
2020-06-04T13:00:43.127215
2013-10-31T03:19:54
2013-10-31T03:19:54
40,475,116
0
0
null
null
null
null
UTF-8
C++
false
false
503
h
FPS.h
#ifndef FPS__H #define FPS__H #include <Windows.h> #include "Device.h" #define DEFAULT_LIMIT_FPS 25 class CFps { protected: int m_iLimitFps; int m_iLimitFrameDt; int m_iFrameDt; private: long m_iStartTime; public: // Singleton static CFps * s_pInstance; static CFps * GetInstance(); // Contructor CFps(); ~CFps(); void SetLimitFps(unsigned int limitFps); void BeginCounter(); void EndCounter(); int GetFrameDt(); int GetRuntimeFps(); }; #endif
895936d33fefbb9ff00c5f0a8a4c31207bc74234
2a1999fa13337bae62bdb81f8d0379ef29a9d36e
/Ativar sensor de laser/laser.ino
dfdf2410d1d6d5eb4aa152020c7ad51570f1e56f
[]
no_license
gabrielbastoos/arduino-projects
80f6545402362788d6fbdadb7a9cc4686a642389
26845b3e0c00330c07503e3e6f9ee1c9b16feae9
refs/heads/master
2021-01-10T11:09:16.995416
2015-10-18T22:22:17
2015-10-18T22:22:17
44,426,200
0
0
null
null
null
null
UTF-8
C++
false
false
471
ino
laser.ino
int led=11; int lightPin = 0; char leitura; void setup(){ Serial.begin(9600); pinMode(led,OUTPUT); digitalWrite(led,LOW); } void loop(){ Serial.println(analogRead(lightPin)); //Write the value of the photoresistor to the serial monitor. delay(500); while(Serial.available()>0) { leitura=Serial.read(); if(leitura=='l'){ //L digitalWrite(led,HIGH); } } if(leitura=='d'){ digitalWrite(led,LOW); } }
f8e0422d26509a67b260515140c7d35e70adffcf
e7f8c7fbfe0c36aeaea110eba524c210403b63de
/src/Utils/clock.h
5e9774b18b522afaa440f08c2767bb528a9daea4
[ "MIT" ]
permissive
Nelarius/PBGI
182b1e15c478af88f5cb99abf935e05742401500
edd91f69ab4f26dc297d0679d8628d812c866122
refs/heads/master
2020-05-29T11:40:22.919161
2016-03-29T15:48:51
2016-03-29T15:48:51
54,681,470
0
0
null
2016-03-24T23:44:53
2016-03-24T23:44:52
C++
UTF-8
C++
false
false
417
h
clock.h
#pragma once #include <chrono> //----------------------------------------------------------------------------- // Class Clock //----------------------------------------------------------------------------- class Clock { public: Clock() = default; ~Clock() = default; double getElapsedTime(); void sleep(float t); void reset(); private: std::chrono::steady_clock::time_point m_start; };
64da54cc7b555b3e38b9b20afb6504fa57583fd3
a1a13311376367fa5a7cfeef6035b92d62aa5d1e
/OOP-Cpp/4-1IO-test.cpp
0bb3835439cdd06f7985383936c170c1e05df579
[ "MIT" ]
permissive
Sprinter1999/PlayGround
31936194ff0b363027769ab09df5003451117c0c
cb6f2668ec8b747684255cf0a3cb07436aaf8830
refs/heads/master
2022-08-13T23:44:59.761820
2022-07-28T03:46:44
2022-07-28T03:46:44
223,189,297
0
1
null
null
null
null
GB18030
C++
false
false
1,253
cpp
4-1IO-test.cpp
/* @作业要求: 编写 C++程序完成猜价格游戏的以下功能: (1) 假定有一件商品,程序用随机数指定该商品的价格(1-1000 的整数); (2) 提示用户猜价格,并输入:若用户猜的价格比商品价格高或低,对用户作出 相应的提示; (3) 直到猜对为止,并给出提示。 (提示及要求:1,要求使用 C++的输入输出方式(cin, cout),不能使用 C 语 言的 printf 等;2,注意检查输入的合法性) */ #include<iostream> #include<ctime> #include<stdlib.h> using namespace std; int main() { srand((unsigned)time(NULL)); int price=rand()%1000+1; //@refer to //https://blog.csdn.net/cmm0401/article/details/54599083 int cprice; int judge=0; cout<<"请输入价格(1-1000的整数):"<<endl; cin>>cprice; while(judge!=1) { if(cprice==price) { judge=1; cout<<"恭喜,您输入的价格正确"<<endl; } if(cprice>price) { judge=0; cout<<"您输入的价格比正确价格高,请重新输入:"<<endl; cin>>cprice; } if(cprice<price) { judge=0; cout<<"您输入的价格比正确价格低,请重新输入:"<<endl; cin>>cprice; } } system("pause"); return 0; }
f67e27818838f011f88849e2f14bae559feeabe8
66e7a9d4c67701f644945f6a98bde877728046a2
/osl/src/liboslexec/debug.cpp
a608388427d6ed733f802f655e1ce5c519932f2a
[ "BSD-3-Clause" ]
permissive
BRL-CAD/osl
196f7b14e0bff13c2fcfc16d18c425a4aaa3618b
df77f166e66e154c7da05ba4f73f25ee9229393b
refs/heads/master
2023-02-23T17:56:32.656986
2011-08-24T12:59:45
2011-08-24T12:59:45
333,447,185
0
0
null
null
null
null
UTF-8
C++
false
false
2,826
cpp
debug.cpp
/* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved. 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 Sony Pictures Imageworks 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 OWNER 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 <cmath> #include "genclosure.h" #include "oslops.h" #include "oslclosure.h" #include <cmath> #ifdef OSL_NAMESPACE namespace OSL_NAMESPACE { #endif namespace OSL { namespace pvt { /// Debug closure /// /// This is going to be used for mask AOV's and similar /// purposes. A tag (string) is always associated with /// this closure, that "selects: the channel where the /// weight should be sent. class DebugClosure : public ClosurePrimitive { public: ustring m_tag; DebugClosure () : ClosurePrimitive (Debug) { } bool mergeable (const ClosurePrimitive *other) const { const DebugClosure *comp = (const DebugClosure *)other; return m_tag == comp->m_tag && ClosurePrimitive::mergeable(other); } size_t memsize () const { return sizeof(*this); } const char *name () const { return "debug"; } void print_on (std::ostream &out) const { out << name() << " (\"" << m_tag.c_str() << "\")"; } }; ClosureParam closure_debug_params[] = { CLOSURE_STRING_PARAM(DebugClosure, m_tag), CLOSURE_STRING_KEYPARAM("label"), CLOSURE_FINISH_PARAM(DebugClosure) }; CLOSURE_PREPARE(closure_debug_prepare, DebugClosure) }; // namespace pvt }; // namespace OSL #ifdef OSL_NAMESPACE }; // end namespace OSL_NAMESPACE #endif
7153c09d2d406796d24cf16c832ab154fe207dc6
98e6c125bc326236bc463b7e08b4012712a69e27
/test_opencv.cpp
19e96a75e6af23d7280a0b731fd5c16eb5dcf2a7
[]
no_license
libuqima/OCR_Learning
a39689232b59cfb2a5fce6d7b4d31a2096492745
fe6117e7a4d811c77b718d2d12aa5e3a73ac47fb
refs/heads/master
2020-06-13T13:03:39.744466
2019-07-01T13:13:12
2019-07-01T13:13:12
194,664,266
2
0
null
null
null
null
GB18030
C++
false
false
3,816
cpp
test_opencv.cpp
#include "opencv2/imgproc.hpp" #include "opencv2/core.hpp" #include "opencv2/highgui.hpp" #include "opencv2/videoio.hpp" #include <fcntl.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <iostream> #include "tesseract/baseapi.h" #include "leptonica/allheaders.h" using namespace cv; using namespace std; void drawText(Mat & image); int main() { FILE file; Mat img = imread("/mnt/d/ziti.jpg", CV_LOAD_IMAGE_UNCHANGED); printf("可以\n"); if(img.empty()) { printf("fail"); return 0; } Mat gray,img2; cvtColor(img,gray,CV_BGR2GRAY); //Sobel(gray,sobel,CV_8U,1,0,3); Mat binary; threshold(gray,binary,0,255,THRESH_OTSU|THRESH_BINARY); Mat rec4 = getStructuringElement(MORPH_RECT,Size(30,5)); Mat rec1 = getStructuringElement(MORPH_RECT,Size(1,1)); Mat rec3 = getStructuringElement(MORPH_RECT,Size(2,2)); Mat rec2 = getStructuringElement(MORPH_RECT,Size(5,5)); Mat dilate0; erode(binary,dilate0,rec4); /* Mat dilate1; erode(dilate0,dilate1,rec1); Mat erode1; erode(dilate1,erode1,rec2); Mat dilate2; dilate(erode1,dilate2,rec3); Mat erode2; erode(dilate2,erode2,rec3);*/ vector<RotatedRect> rects; vector<vector<Point>> counts; vector<Vec4i> hierarchy; printf("有输出\n"); Mat erode2; bitwise_not(dilate0,erode2); findContours(erode2,counts,hierarchy,CV_RETR_LIST ,CHAIN_APPROX_SIMPLE,Point(0,0)); for(int i =0; i<counts.size();i++) { //printf("有输出\n"); if(contourArea(counts[i])<500) continue; Rect rect1=boundingRect(counts[i]); char ch[256]; sprintf(ch,"%d",i); string str=ch; cout<<"hierarchy num" <<str<<" :"<<endl<<hierarchy[i]<<endl<<endl; //RotatedRect rect = minAreaRect(counts[i]); //int width = rect.boundingRect().width; //int heigh = rect.boundingRect().height; // Point2f P[4]; // rect.points(P); /* for (int j = 0; j <= 3; j++) { line(img, P[j], P[(j + 1) % 4], Scalar(0,255,0), 2); }*/ rectangle(binary,rect1,Scalar(0,255,0),2); char file_name[20]; sprintf(file_name,"/mnt/d/p/out%d.txt",i); int fd = open(file_name,O_RDWR |O_CREAT); if(fd < 0) { printf("open file"); exit(1); } char name[20]; sprintf(name,"/mnt/d/p/%d.tif",i); img(rect1).copyTo(img2); imwrite(name,img2); // waitKey(15); char *outText; tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI(); if (api->Init(NULL, "chi_sim")) { printf("Init fail\n"); } Pix *image = pixRead(name); api->SetImage(image); outText = api->GetUTF8Text(); if(write(fd,outText,strlen(outText))<0) { printf("write fail\n\r"); } delete [] outText; close(fd); } //printf("youshuchu\n"); imwrite("/mnt/d/p/img.jpg",img); imwrite("/mnt/d/p/gray.jpg",gray); imwrite("/mnt/d/p/binary.jpg",binary); // imwrite("/mnt/d/p/dilate1.jpg",dilate1); imwrite("/mnt/d/p/erode0.jpg",dilate0); // imwrite("/mnt/d/p/erode1.jpg",erode1); imwrite("/mnt/d/p/erode2.jpg",erode2); // imwrite("/mnt/d/p/dilate2.jpg",dilate2); //imwrite("/mnt/d/p/new.jpg", img); waitKey(0); return 0; } void drawText(Mat & image) { putText(image, "Hello OpenCV", Point(20, 50), FONT_HERSHEY_COMPLEX, 1, // font face and scale Scalar(255, 255, 255), // white 1, LINE_AA); // line thickness and type }
d3f77258b77c50e74773eee9f87b59899830d747
c87095bd13b9080224324b3a6dd4fd538912d97e
/OpenGL/Particles/particle.h
b75b94d4f64853ff39a12c7b10428d00d8400339
[ "MIT" ]
permissive
Agrelimos/tutorials
6a0a8ef6652a44bd5a35b59bf192326c831367ff
7d2953b8fbb5c56a921a17e7e3cac3d1f4fbb41b
refs/heads/master
2020-04-01T05:26:56.560609
2018-10-13T18:45:56
2018-10-13T18:45:56
152,903,588
0
0
MIT
2018-10-13T18:44:42
2018-10-13T18:44:42
null
UTF-8
C++
false
false
1,787
h
particle.h
#ifndef PARTICLE_H #define PARTICLE_H #include <stdio.h> #include "vector.h" #include "gl_texture.h" // Creates an ARGB color #define ARGB(A, R, G, B) ( (int)((A & 0xFF) << 24 | \ (R & 0xFF) << 16 | \ (G & 0xFF) << 8 | \ (B & 0xFF)) ) // Gets the A, R, G, and B from an ARGB color #define GET_A(c) ((c >> 24) & 0xFF) #define GET_R(c) ((c >> 16) & 0xFF) #define GET_G(c) ((c >> 8) & 0xFF) #define GET_B(c) (c & 0xFF) // Returns a random percent between 0 - 1 #define RAND_PERCENT() ((rand() & 0x7FFF) / ((float)0x7FFF)) // Returns a random number between (and including) "min" and "max" // Assumes "min" < "max" #define RAND(min, max) (min + (max - min) * RAND_PERCENT()) // The gravity that effects every particle // This number was reached by the "what looks good" method %) const float kParticleGravity = -9.81f / 10.0f; // The particle class CParticle { public: CParticle(); // Default constructor // This initializes a particle bool init(const CPos &pos, const CVector &vel, float lifeSpan, float size, float angle = 0.0f, int color = 0xFFFFFFFF, const char *texName = NULL); void process(float dt); // Moves the particle each frame void render(); // Renders the particle to screen // If the a particle's life is greater than zero, it's considered active // otherwise it's deactivate bool isAlive() { return (mLife > 0.0f); } private: CPos mPos; // World position CVector mVel; // Velocity int mColor; // ARGB color of particle float mSize; // Width/Height dimensions of the particle float mLife; // Life span of particle in seconds float mAngle; // Angle, in degrees, to rotate the texture's UVs every second CGLTexture mTexture; // The texture }; #endif