blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
8d439b26feec8133bc8e03bd05e212ae2bf1858d
e71d40ad4e76272fca4494c6bcc818050d221090
/Blink/Source/wtf/text/StringBuffer.h
aed2556e6c73f3cdf9ec7b304492c082c8d3b55b
[]
no_license
yuanyan/know-your-chrome
e038e49c160bdf46b28241427e99bf2816fac022
18cace725261122f6903c98bfdcbfa0b370138c3
refs/heads/master
2022-12-29T18:31:42.046729
2013-12-18T11:45:13
2013-12-18T11:45:13
9,907,874
7
7
null
2022-12-18T00:00:55
2013-05-07T08:55:26
C++
UTF-8
C++
false
false
3,003
h
/* * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef StringBuffer_h #define StringBuffer_h #include <wtf/Assertions.h> #include <wtf/unicode/Unicode.h> #include <limits> namespace WTF { template <typename CharType> class StringBuffer { WTF_MAKE_NONCOPYABLE(StringBuffer); public: explicit StringBuffer(unsigned length) : m_length(length) { RELEASE_ASSERT(m_length <= std::numeric_limits<unsigned>::max() / sizeof(CharType)); m_data = static_cast<CharType*>(fastMalloc(m_length * sizeof(CharType))); } ~StringBuffer() { fastFree(m_data); } void shrink(unsigned newLength) { ASSERT(newLength <= m_length); m_length = newLength; } void resize(unsigned newLength) { if (newLength > m_length) { RELEASE_ASSERT(newLength <= std::numeric_limits<unsigned>::max() / sizeof(UChar)); m_data = static_cast<UChar*>(fastRealloc(m_data, newLength * sizeof(UChar))); } m_length = newLength; } unsigned length() const { return m_length; } CharType* characters() { return m_data; } CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < m_length); return m_data[i]; } CharType* release() { CharType* data = m_data; m_data = 0; return data; } private: CharType* m_data; // Pointers first: crbug.com/232031 unsigned m_length; }; } // namespace WTF using WTF::StringBuffer; #endif // StringBuffer_h
[ "yuanyan.cao@gmail.com" ]
yuanyan.cao@gmail.com
c4d7330c9003093f9b92d65ea1423c5a212a679f
26cc428b3d87f0cd0f1a2e6a51e9da25cd0b651a
/inflowPosition/Blasius_15/upwind/0.4/U
c18a66722da6c3ec06d775296e03f6a4ba51d530
[]
no_license
CagriMetin/BlasiusProblem
8f4fe708df8f3332d054b233d99a33fbb3c15c2a
32c4aafd6ddd6ba4c39aef04d01b77a9106125b2
refs/heads/master
2020-12-24T19:37:14.665700
2016-12-27T19:13:04
2016-12-27T19:13:04
57,833,097
0
0
null
null
null
null
UTF-8
C++
false
false
83,188
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "0.4"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 3375 ( (0.17062 0.00600171 0) (0.154088 0.00606111 0) (0.138201 0.00563515 0) (0.123151 0.00502983 0) (0.109348 0.00436188 0) (0.0969612 0.00368494 0) (0.086003 0.00303607 0) (0.0764393 0.002441 0) (0.0682132 0.00191543 0) (0.0612376 0.00146726 0) (0.0553964 0.00109816 0) (0.0505536 0.000804442 0) (0.0465656 0.000578457 0) (0.043291 0.000410172 0) (0.0405979 0.000288784 0) (0.0383693 0.000203939 0) (0.0365056 0.000146483 0) (0.0349253 0.000108804 0) (0.0335638 8.48718e-05 0) (0.0323714 7.01105e-05 0) (0.0313107 6.11936e-05 0) (0.0303542 5.58066e-05 0) (0.0294816 5.24142e-05 0) (0.0286785 5.00526e-05 0) (0.0279339 4.81547e-05 0) (0.0272401 4.64152e-05 0) (0.026591 4.46905e-05 0) (0.0259819 4.29304e-05 0) (0.0254088 4.11335e-05 0) (0.0248686 3.93197e-05 0) (0.0243586 3.75149e-05 0) (0.0238762 3.57432e-05 0) (0.0234193 3.40237e-05 0) (0.022986 3.23698e-05 0) (0.0225745 3.07896e-05 0) (0.0221832 2.92869e-05 0) (0.0218108 2.78626e-05 0) (0.0214559 2.65151e-05 0) (0.0211174 2.52418e-05 0) (0.0207942 2.40388e-05 0) (0.0204854 2.29022e-05 0) (0.0201901 2.18277e-05 0) (0.0199075 2.08111e-05 0) (0.019637 1.98483e-05 0) (0.0193778 1.89355e-05 0) (0.0191293 1.80691e-05 0) (0.0188912 1.72458e-05 0) (0.0186627 1.64624e-05 0) (0.0184436 1.5716e-05 0) (0.0182334 1.50041e-05 0) (0.0180316 1.43241e-05 0) (0.0178381 1.36737e-05 0) (0.0176525 1.30509e-05 0) (0.0174744 1.24537e-05 0) (0.0173036 1.18803e-05 0) (0.0171399 1.1329e-05 0) (0.0169831 1.07983e-05 0) (0.016833 1.02867e-05 0) (0.0166894 9.79287e-06 0) (0.0165521 9.31561e-06 0) (0.0164211 8.85372e-06 0) (0.0162961 8.40608e-06 0) (0.016177 7.97165e-06 0) (0.0160638 7.54943e-06 0) (0.0159564 7.13853e-06 0) (0.0158547 6.73821e-06 0) (0.0157587 6.34798e-06 0) (0.0156682 5.96774e-06 0) (0.0155832 5.59786e-06 0) (0.0155038 5.23919e-06 0) (0.0154298 4.89282e-06 0) (0.0153612 4.55949e-06 0) (0.0152979 4.23838e-06 0) (0.0152401 3.92529e-06 0) (0.0151876 3.61023e-06 0) (0.0151408 3.27454e-06 0) (0.0150998 2.8884e-06 0) (0.0150651 2.41229e-06 0) (0.0150376 1.81711e-06 0) (0.015018 1.14912e-06 0) (0.0150075 5.60348e-07 0) (0.0150068 -4.45797e-08 0) (0.0150136 -6.45056e-07 0) (0.0150263 -1.18001e-06 0) (0.0150438 -1.61534e-06 0) (0.015065 -1.92478e-06 0) (0.0150887 -2.11807e-06 0) (0.015114 -2.21714e-06 0) (0.0151401 -2.23692e-06 0) (0.0151661 -2.19733e-06 0) (0.0151915 -2.10874e-06 0) (0.0152158 -1.98596e-06 0) (0.0152389 -1.84037e-06 0) (0.0152603 -1.6801e-06 0) (0.0152801 -1.5128e-06 0) (0.0152982 -1.3423e-06 0) (0.0153144 -1.1704e-06 0) (0.0153288 -1.01525e-06 0) (0.0153408 -1.03922e-06 0) (0.015364 -2.66277e-06 0) (0.189524 0.00946233 0) (0.187187 0.00996638 0) (0.183248 0.00974352 0) (0.178065 0.00924625 0) (0.172136 0.00861156 0) (0.165808 0.00788617 0) (0.159303 0.00710868 0) (0.152788 0.00631465 0) (0.146398 0.00553398 0) (0.140234 0.00479122 0) (0.134362 0.00410558 0) (0.128823 0.00349026 0) (0.123636 0.00295219 0) (0.118805 0.00249248 0) (0.114321 0.00210757 0) (0.11017 0.00179055 0) (0.10633 0.0015326 0) (0.102779 0.00132429 0) (0.0994934 0.00115646 0) (0.0964497 0.0010209 0) (0.0936255 0.000910576 0) (0.0909997 0.000819797 0) (0.0885534 0.000744069 0) (0.0862691 0.000679956 0) (0.0841314 0.000624879 0) (0.0821265 0.000576929 0) (0.0802421 0.000534698 0) (0.0784674 0.000497143 0) (0.0767928 0.000463487 0) (0.0752099 0.000433134 0) (0.073711 0.000405623 0) (0.0722896 0.000380581 0) (0.0709396 0.000357706 0) (0.0696558 0.000336743 0) (0.0684332 0.000317475 0) (0.0672678 0.000299715 0) (0.0661556 0.000283302 0) (0.0650931 0.000268093 0) (0.0640773 0.000253965 0) (0.0631052 0.000240809 0) (0.0621743 0.000228527 0) (0.0612823 0.000217037 0) (0.060427 0.000206262 0) (0.0596065 0.000196137 0) (0.058819 0.000186602 0) (0.058063 0.000177605 0) (0.0573369 0.000169099 0) (0.0566394 0.000161042 0) (0.0559692 0.000153396 0) (0.0553253 0.000146128 0) (0.0547066 0.000139204 0) (0.0541122 0.000132599 0) (0.0535412 0.000126286 0) (0.0529927 0.000120242 0) (0.0524662 0.000114444 0) (0.0519609 0.000108874 0) (0.0514764 0.000103514 0) (0.0510119 9.83457e-05 0) (0.0505671 9.33547e-05 0) (0.0501416 8.85264e-05 0) (0.0497349 8.38475e-05 0) (0.0493468 7.93057e-05 0) (0.048977 7.48895e-05 0) (0.0486251 7.05883e-05 0) (0.0482911 6.63924e-05 0) (0.0479748 6.22932e-05 0) (0.0476759 5.82832e-05 0) (0.0473945 5.43563e-05 0) (0.0471303 5.05078e-05 0) (0.0468835 4.67335e-05 0) (0.0466539 4.30287e-05 0) (0.0464415 3.93857e-05 0) (0.0462465 3.57901e-05 0) (0.0460689 3.2216e-05 0) (0.0459091 2.86209e-05 0) (0.0457675 2.49414e-05 0) (0.0456447 2.1092e-05 0) (0.0455415 1.69684e-05 0) (0.0454589 1.24723e-05 0) (0.045398 7.58504e-06 0) (0.0453594 2.46574e-06 0) (0.0453447 -2.37818e-06 0) (0.0453525 -6.12163e-06 0) (0.0453763 -8.73019e-06 0) (0.0454124 -1.06718e-05 0) (0.0454576 -1.20676e-05 0) (0.0455093 -1.29455e-05 0) (0.0455649 -1.33569e-05 0) (0.0456226 -1.33601e-05 0) (0.0456808 -1.30537e-05 0) (0.0457381 -1.2508e-05 0) (0.0457935 -1.17989e-05 0) (0.0458464 -1.09843e-05 0) (0.0458963 -1.01057e-05 0) (0.0459428 -9.19898e-06 0) (0.0459858 -8.2871e-06 0) (0.0460251 -7.39069e-06 0) (0.0460609 -6.59174e-06 0) (0.0460926 -6.36744e-06 0) (0.0461346 -8.88931e-06 0) (0.192512 0.00909214 0) (0.193274 0.0100433 0) (0.193396 0.0103797 0) (0.192728 0.0103889 0) (0.19138 0.0101684 0) (0.189471 0.00975644 0) (0.187088 0.00919799 0) (0.18432 0.00854311 0) (0.181258 0.0078376 0) (0.17799 0.00712031 0) (0.174592 0.00642245 0) (0.171127 0.00576693 0) (0.167648 0.00516826 0) (0.164193 0.00463338 0) (0.160792 0.00416316 0) (0.157464 0.00375415 0) (0.154223 0.00340034 0) (0.151077 0.00309461 0) (0.14803 0.00282971 0) (0.145083 0.00259898 0) (0.142236 0.00239663 0) (0.139487 0.00221783 0) (0.136835 0.00205866 0) (0.134276 0.00191599 0) (0.131809 0.00178735 0) (0.12943 0.00167076 0) (0.127136 0.00156465 0) (0.124925 0.00146773 0) (0.122794 0.00137894 0) (0.120739 0.00129738 0) (0.118757 0.0012223 0) (0.116847 0.00115304 0) (0.115005 0.00108901 0) (0.113229 0.0010297 0) (0.111516 0.000974668 0) (0.109864 0.000923498 0) (0.108269 0.000875832 0) (0.106731 0.000831347 0) (0.105247 0.000789753 0) (0.103813 0.00075079 0) (0.10243 0.000714224 0) (0.101094 0.000679846 0) (0.0998046 0.000647467 0) (0.098559 0.000616917 0) (0.0973562 0.000588042 0) (0.0961944 0.000560704 0) (0.0950725 0.000534776 0) (0.093989 0.000510143 0) (0.0929427 0.000486702 0) (0.0919325 0.000464358 0) (0.0909573 0.000443022 0) (0.0900163 0.000422617 0) (0.0891083 0.000403067 0) (0.0882328 0.000384307 0) (0.0873888 0.000366272 0) (0.0865757 0.000348906 0) (0.0857929 0.000332156 0) (0.0850398 0.000315972 0) (0.084316 0.000300307 0) (0.083621 0.00028512 0) (0.0829544 0.00027037 0) (0.0823159 0.00025602 0) (0.0817052 0.000242035 0) (0.0811222 0.000228384 0) (0.0805667 0.000215038 0) (0.0800385 0.000201968 0) (0.0795376 0.000189152 0) (0.0790639 0.000176567 0) (0.0786175 0.000164194 0) (0.0781985 0.000152013 0) (0.0778069 0.000140003 0) (0.0774429 0.000128135 0) (0.0771067 0.000116368 0) (0.0767987 0.00010464 0) (0.0765192 9.28666e-05 0) (0.0762689 8.09431e-05 0) (0.0760484 6.87528e-05 0) (0.0758582 5.61933e-05 0) (0.0756988 4.32143e-05 0) (0.0755702 2.98487e-05 0) (0.0754714 1.62053e-05 0) (0.0753993 2.74256e-06 0) (0.0753578 -9.23217e-06 0) (0.0753483 -1.83167e-05 0) (0.0753623 -2.45066e-05 0) (0.0753941 -2.86268e-05 0) (0.0754391 -3.12682e-05 0) (0.0754936 -3.27359e-05 0) (0.0755545 -3.31851e-05 0) (0.0756191 -3.2818e-05 0) (0.0756855 -3.17978e-05 0) (0.075752 -3.03115e-05 0) (0.0758172 -2.85118e-05 0) (0.0758803 -2.65137e-05 0) (0.0759406 -2.44126e-05 0) (0.0759976 -2.22733e-05 0) (0.076051 -2.01523e-05 0) (0.0761005 -1.81878e-05 0) (0.0761453 -1.69577e-05 0) (0.0761946 -1.75377e-05 0) (0.193552 0.00844998 0) (0.194672 0.00949411 0) (0.195694 0.0100515 0) (0.196405 0.0102973 0) (0.196779 0.0103117 0) (0.196822 0.0101265 0) (0.19653 0.0097772 0) (0.195907 0.00930653 0) (0.194977 0.00875638 0) (0.193777 0.0081642 0) (0.192347 0.00756183 0) (0.190732 0.00697449 0) (0.188971 0.00642015 0) (0.1871 0.00590977 0) (0.18515 0.00544832 0) (0.183147 0.00503621 0) (0.18111 0.0046707 0) (0.179056 0.0043473 0) (0.176994 0.00406074 0) (0.174935 0.00380573 0) (0.172882 0.00357738 0) (0.170842 0.00337142 0) (0.168819 0.00318427 0) (0.166814 0.00301302 0) (0.16483 0.00285534 0) (0.16287 0.00270937 0) (0.160935 0.00257365 0) (0.159027 0.00244701 0) (0.157148 0.0023285 0) (0.155297 0.00221734 0) (0.153477 0.00211287 0) (0.151689 0.00201455 0) (0.149933 0.00192188 0) (0.148209 0.00183443 0) (0.146519 0.0017518 0) (0.144862 0.00167366 0) (0.143239 0.00159967 0) (0.141651 0.00152954 0) (0.140096 0.00146301 0) (0.138576 0.00139982 0) (0.13709 0.00133974 0) (0.135638 0.00128255 0) (0.134219 0.00122806 0) (0.132835 0.00117609 0) (0.131483 0.00112646 0) (0.130165 0.00107901 0) (0.12888 0.0010336 0) (0.127628 0.000990091 0) (0.126409 0.000948346 0) (0.125221 0.000908247 0) (0.124066 0.00086968 0) (0.122942 0.00083254 0) (0.12185 0.000796724 0) (0.120789 0.00076214 0) (0.11976 0.000728699 0) (0.118761 0.000696316 0) (0.117793 0.000664913 0) (0.116857 0.000634415 0) (0.11595 0.000604751 0) (0.115075 0.000575856 0) (0.11423 0.000547667 0) (0.113417 0.000520123 0) (0.112634 0.00049317 0) (0.111882 0.000466754 0) (0.111161 0.000440827 0) (0.110471 0.000415344 0) (0.109813 0.000390262 0) (0.109186 0.000365542 0) (0.108592 0.000341149 0) (0.10803 0.000317045 0) (0.107501 0.00029319 0) (0.107005 0.000269534 0) (0.106543 0.000246011 0) (0.106115 0.000222537 0) (0.105722 0.000199007 0) (0.105365 0.000175308 0) (0.105044 0.000151339 0) (0.104759 0.000127064 0) (0.10451 0.000102572 0) (0.104297 7.81699e-05 0) (0.104119 5.43828e-05 0) (0.103973 3.16424e-05 0) (0.103853 1.03428e-05 0) (0.103758 -8.7505e-06 0) (0.1037 -2.43275e-05 0) (0.103671 -3.56078e-05 0) (0.103666 -4.31551e-05 0) (0.103678 -4.78662e-05 0) (0.103705 -5.0434e-05 0) (0.103743 -5.1389e-05 0) (0.103787 -5.10494e-05 0) (0.103838 -4.97261e-05 0) (0.103891 -4.76774e-05 0) (0.103946 -4.51138e-05 0) (0.104001 -4.22204e-05 0) (0.104055 -3.91307e-05 0) (0.104108 -3.59471e-05 0) (0.104159 -3.28051e-05 0) (0.104206 -3.00145e-05 0) (0.104254 -2.70047e-05 0) (0.194289 0.00794473 0) (0.19527 0.00892283 0) (0.196324 0.00951575 0) (0.197285 0.00983349 0) (0.198109 0.00994609 0) (0.198777 0.00988307 0) (0.199264 0.00967037 0) (0.199547 0.00933997 0) (0.199617 0.00892526 0) (0.19948 0.0084576 0) (0.199147 0.0079649 0) (0.19864 0.00747052 0) (0.197981 0.00699231 0) (0.197194 0.00654245 0) (0.196301 0.00612782 0) (0.195321 0.00575104 0) (0.194272 0.0054116 0) (0.193167 0.00510694 0) (0.192017 0.00483341 0) (0.19083 0.00458699 0) (0.189613 0.00436377 0) (0.18837 0.00416018 0) (0.187105 0.00397316 0) (0.185822 0.00380017 0) (0.184524 0.00363916 0) (0.183213 0.00348847 0) (0.181891 0.0033468 0) (0.180561 0.0032131 0) (0.179225 0.00308653 0) (0.177885 0.00296642 0) (0.176543 0.0028522 0) (0.1752 0.0027434 0) (0.173859 0.0026396 0) (0.17252 0.00254043 0) (0.171186 0.0024456 0) (0.169858 0.00235479 0) (0.168537 0.00226776 0) (0.167225 0.00218427 0) (0.165922 0.00210409 0) (0.164631 0.00202703 0) (0.163351 0.00195289 0) (0.162085 0.00188152 0) (0.160832 0.00181273 0) (0.159594 0.00174639 0) (0.158372 0.00168235 0) (0.157165 0.00162048 0) (0.155977 0.00156064 0) (0.154805 0.00150273 0) (0.153653 0.00144662 0) (0.152519 0.00139222 0) (0.151405 0.00133941 0) (0.150312 0.00128809 0) (0.149239 0.00123818 0) (0.148187 0.00118958 0) (0.147158 0.0011422 0) (0.146151 0.00109596 0) (0.145167 0.00105078 0) (0.144207 0.00100658 0) (0.14327 0.000963291 0) (0.142359 0.000920834 0) (0.141472 0.000879144 0) (0.140612 0.000838153 0) (0.139777 0.000797797 0) (0.13897 0.000758018 0) (0.13819 0.000718756 0) (0.137439 0.00067996 0) (0.136716 0.000641577 0) (0.136022 0.000603561 0) (0.135359 0.000565865 0) (0.134727 0.000528442 0) (0.134127 0.00049124 0) (0.133559 0.000454196 0) (0.133024 0.000417236 0) (0.132523 0.00038027 0) (0.132058 0.000343202 0) (0.131628 0.000305946 0) (0.131234 0.000268462 0) (0.130876 0.000230817 0) (0.130555 0.000193257 0) (0.13027 0.000156283 0) (0.130019 0.000120681 0) (0.129801 8.7391e-05 0) (0.129614 5.70041e-05 0) (0.129454 2.93661e-05 0) (0.129312 4.81038e-06 0) (0.129194 -1.60413e-05 0) (0.129108 -3.2651e-05 0) (0.129047 -4.46553e-05 0) (0.129008 -5.26851e-05 0) (0.128987 -5.76214e-05 0) (0.12898 -6.01617e-05 0) (0.128985 -6.09088e-05 0) (0.129 -6.02942e-05 0) (0.129021 -5.86405e-05 0) (0.129048 -5.62297e-05 0) (0.129078 -5.32714e-05 0) (0.129111 -4.99187e-05 0) (0.129145 -4.62732e-05 0) (0.129179 -4.22335e-05 0) (0.129213 -3.55758e-05 0) (0.19492 0.0075108 0) (0.195726 0.00838443 0) (0.196648 0.00896221 0) (0.197562 0.00930402 0) (0.198421 0.00946343 0) (0.199204 0.00946729 0) (0.199888 0.00933679 0) (0.200452 0.00909738 0) (0.20088 0.00877668 0) (0.201166 0.00840125 0) (0.201313 0.0079952 0) (0.201329 0.00757917 0) (0.201226 0.00716955 0) (0.201017 0.00677815 0) (0.200717 0.00641236 0) (0.200341 0.00607583 0) (0.1999 0.00576933 0) (0.199403 0.00549164 0) (0.198861 0.00524034 0) (0.198277 0.00501243 0) (0.197659 0.00480481 0) (0.197009 0.00461456 0) (0.19633 0.00443904 0) (0.195625 0.00427604 0) (0.194895 0.00412368 0) (0.194142 0.00398047 0) (0.193367 0.00384517 0) (0.192573 0.00371681 0) (0.19176 0.0035946 0) (0.190929 0.0034779 0) (0.190083 0.00336618 0) (0.189222 0.00325899 0) (0.188348 0.00315598 0) (0.187462 0.00305681 0) (0.186565 0.0029612 0) (0.185659 0.0028689 0) (0.184744 0.0027797 0) (0.183823 0.0026934 0) (0.182896 0.0026098 0) (0.181964 0.00252876 0) (0.181029 0.0024501 0) (0.180091 0.0023737 0) (0.179152 0.00229942 0) (0.178213 0.00222714 0) (0.177275 0.00215675 0) (0.176338 0.00208814 0) (0.175405 0.0020212 0) (0.174475 0.00195584 0) (0.17355 0.00189196 0) (0.172631 0.00182948 0) (0.171719 0.00176831 0) (0.170814 0.00170836 0) (0.169918 0.00164956 0) (0.169031 0.00159183 0) (0.168155 0.00153509 0) (0.16729 0.00147928 0) (0.166437 0.0014243 0) (0.165597 0.00137011 0) (0.164772 0.00131662 0) (0.163961 0.00126377 0) (0.163166 0.0012115 0) (0.162387 0.00115974 0) (0.161626 0.00110843 0) (0.160884 0.00105752 0) (0.160161 0.00100695 0) (0.159459 0.000956661 0) (0.158778 0.000906612 0) (0.15812 0.000856751 0) (0.157485 0.000807031 0) (0.156874 0.000757405 0) (0.156289 0.00070782 0) (0.15573 0.000658214 0) (0.155198 0.000608518 0) (0.154696 0.000558657 0) (0.154222 0.000508566 0) (0.153779 0.000458211 0) (0.153366 0.000407636 0) (0.152985 0.000357026 0) (0.152635 0.000306772 0) (0.152316 0.000257526 0) (0.152027 0.000210195 0) (0.151767 0.000165812 0) (0.151535 0.000125233 0) (0.151328 8.90378e-05 0) (0.151146 5.72228e-05 0) (0.150983 2.92534e-05 0) (0.150834 5.23416e-06 0) (0.150704 -1.46379e-05 0) (0.150596 -3.0439e-05 0) (0.15051 -4.21471e-05 0) (0.150441 -5.02126e-05 0) (0.150388 -5.5365e-05 0) (0.150349 -5.82448e-05 0) (0.150322 -5.93641e-05 0) (0.150304 -5.91464e-05 0) (0.150294 -5.78879e-05 0) (0.150291 -5.57859e-05 0) (0.150293 -5.2905e-05 0) (0.150299 -4.88097e-05 0) (0.150306 -4.02251e-05 0) (0.195474 0.00714033 0) (0.19614 0.00791049 0) (0.196924 0.00845651 0) (0.197734 0.00880314 0) (0.198525 0.00898648 0) (0.199274 0.0090298 0) (0.199961 0.00895167 0) (0.200567 0.00877344 0) (0.20108 0.00851853 0) (0.201493 0.0082099 0) (0.201805 0.00786852 0) (0.20202 0.0075126 0) (0.202146 0.00715693 0) (0.202192 0.00681258 0) (0.202168 0.00648697 0) (0.202084 0.00618427 0) (0.20195 0.00590608 0) (0.201774 0.00565214 0) (0.20156 0.00542096 0) (0.201316 0.00521037 0) (0.201044 0.00501794 0) (0.200747 0.00484125 0) (0.200427 0.00467807 0) (0.200086 0.00452641 0) (0.199725 0.00438458 0) (0.199343 0.00425119 0) (0.198943 0.00412507 0) (0.198525 0.00400528 0) (0.198089 0.00389105 0) (0.197636 0.00378173 0) (0.197166 0.00367682 0) (0.19668 0.00357587 0) (0.196179 0.00347852 0) (0.195664 0.00338445 0) (0.195134 0.00329338 0) (0.194591 0.00320507 0) (0.194035 0.00311932 0) (0.193468 0.00303593 0) (0.192889 0.00295473 0) (0.1923 0.00287556 0) (0.191701 0.00279829 0) (0.191093 0.00272279 0) (0.190478 0.00264893 0) (0.189854 0.0025766 0) (0.189224 0.0025057 0) (0.188588 0.00243614 0) (0.187948 0.00236782 0) (0.187302 0.00230066 0) (0.186654 0.00223457 0) (0.186003 0.00216947 0) (0.18535 0.00210529 0) (0.184696 0.00204195 0) (0.184042 0.00197937 0) (0.183388 0.0019175 0) (0.182737 0.00185626 0) (0.182087 0.00179558 0) (0.181441 0.0017354 0) (0.1808 0.00167565 0) (0.180163 0.00161626 0) (0.179533 0.00155719 0) (0.17891 0.00149836 0) (0.178294 0.00143971 0) (0.177688 0.0013812 0) (0.177091 0.00132276 0) (0.176505 0.00126435 0) (0.175932 0.00120591 0) (0.175371 0.00114739 0) (0.174824 0.00108876 0) (0.174292 0.00102997 0) (0.173777 0.000970969 0) (0.173278 0.000911718 0) (0.172798 0.000852164 0) (0.172337 0.000792253 0) (0.171896 0.000731938 0) (0.171476 0.000671195 0) (0.171078 0.000610053 0) (0.170703 0.000548646 0) (0.170351 0.000487263 0) (0.170022 0.000426415 0) (0.169716 0.00036686 0) (0.169432 0.000309571 0) (0.16917 0.000255605 0) (0.16893 0.000205887 0) (0.168711 0.000161062 0) (0.168512 0.000121392 0) (0.168332 8.69703e-05 0) (0.168168 5.75214e-05 0) (0.168019 3.22947e-05 0) (0.167881 1.09943e-05 0) (0.167754 -6.44274e-06 0) (0.167642 -2.03763e-05 0) (0.167545 -3.10684e-05 0) (0.167463 -3.88059e-05 0) (0.167392 -4.4066e-05 0) (0.167333 -4.73467e-05 0) (0.167284 -4.9039e-05 0) (0.167243 -4.94063e-05 0) (0.16721 -4.85196e-05 0) (0.167184 -4.58324e-05 0) (0.167158 -3.81289e-05 0) (0.195964 0.0068215 0) (0.196522 0.00749684 0) (0.197188 0.0080023 0) (0.197895 0.00834201 0) (0.198602 0.00853758 0) (0.199283 0.00860757 0) (0.199921 0.00856798 0) (0.2005 0.00843662 0) (0.201008 0.00823324 0) (0.201438 0.00797754 0) (0.20179 0.00768784 0) (0.202065 0.00738024 0) (0.20227 0.00706812 0) (0.202411 0.00676184 0) (0.202497 0.00646868 0) (0.202536 0.00619315 0) (0.202535 0.00593749 0) (0.202502 0.00570219 0) (0.202442 0.00548653 0) (0.202359 0.00528908 0) (0.202256 0.00510799 0) (0.202137 0.00494135 0) (0.202002 0.00478727 0) (0.201853 0.00464404 0) (0.20169 0.00451017 0) (0.201515 0.00438436 0) (0.201328 0.00426552 0) (0.201128 0.00415276 0) (0.200916 0.00404531 0) (0.200692 0.00394255 0) (0.200457 0.00384396 0) (0.20021 0.00374909 0) (0.199951 0.00365756 0) (0.199681 0.00356905 0) (0.1994 0.00348328 0) (0.199108 0.00339999 0) (0.198806 0.00331897 0) (0.198493 0.00324001 0) (0.19817 0.00316295 0) (0.197837 0.00308763 0) (0.197495 0.00301388 0) (0.197143 0.00294159 0) (0.196783 0.00287063 0) (0.196414 0.00280089 0) (0.196038 0.00273226 0) (0.195653 0.00266463 0) (0.195262 0.00259793 0) (0.194864 0.00253205 0) (0.194459 0.00246692 0) (0.194049 0.00240244 0) (0.193634 0.00233856 0) (0.193214 0.00227518 0) (0.19279 0.00221224 0) (0.192363 0.00214966 0) (0.191932 0.00208738 0) (0.1915 0.00202533 0) (0.191066 0.00196343 0) (0.190631 0.00190163 0) (0.190195 0.00183985 0) (0.18976 0.00177805 0) (0.189327 0.00171615 0) (0.188895 0.00165409 0) (0.188466 0.00159183 0) (0.188041 0.0015293 0) (0.18762 0.00146646 0) (0.187204 0.00140325 0) (0.186794 0.00133962 0) (0.186391 0.00127555 0) (0.185997 0.00121098 0) (0.18561 0.00114588 0) (0.185234 0.00108021 0) (0.184868 0.00101393 0) (0.184513 0.000946999 0) (0.18417 0.000879411 0) (0.183841 0.000811185 0) (0.183525 0.00074241 0) (0.183223 0.000673293 0) (0.182935 0.000604209 0) (0.182662 0.000535747 0) (0.182404 0.000468724 0) (0.18216 0.00040414 0) (0.18193 0.000343048 0) (0.181714 0.000286373 0) (0.181513 0.000234782 0) (0.181326 0.000188643 0) (0.181153 0.000148084 0) (0.180994 0.000112937 0) (0.180847 8.29339e-05 0) (0.180711 5.76869e-05 0) (0.180587 3.64849e-05 0) (0.18047 1.8729e-05 0) (0.180361 4.14966e-06 0) (0.18026 -7.5653e-06 0) (0.180169 -1.67956e-05 0) (0.180088 -2.37981e-05 0) (0.180016 -2.88251e-05 0) (0.179952 -3.21282e-05 0) (0.179895 -3.38126e-05 0) (0.179845 -3.34792e-05 0) (0.179795 -2.90459e-05 0) (0.1964 0.0065415 0) (0.196874 0.00713266 0) (0.197441 0.00759427 0) (0.198056 0.00792006 0) (0.198682 0.00812092 0) (0.199294 0.00821026 0) (0.199875 0.0082012 0) (0.20041 0.00810836 0) (0.200887 0.00794812 0) (0.201302 0.00773725 0) (0.201652 0.00749164 0) (0.201938 0.00722551 0) (0.202165 0.00695094 0) (0.202338 0.00667753 0) (0.202464 0.00641234 0) (0.20255 0.00616009 0) (0.202603 0.00592348 0) (0.202629 0.0057036 0) (0.202632 0.00550042 0) (0.202618 0.00531312 0) (0.202588 0.00514042 0) (0.202547 0.00498086 0) (0.202495 0.00483295 0) (0.202434 0.00469524 0) (0.202365 0.00456645 0) (0.202288 0.00444542 0) (0.202203 0.00433116 0) (0.202112 0.00422284 0) (0.202014 0.00411973 0) (0.201909 0.00402123 0) (0.201798 0.00392682 0) (0.201679 0.00383606 0) (0.201554 0.00374858 0) (0.201422 0.00366404 0) (0.201284 0.00358216 0) (0.201139 0.00350267 0) (0.200986 0.00342536 0) (0.200828 0.00335002 0) (0.200662 0.00327646 0) (0.20049 0.00320451 0) (0.200312 0.00313403 0) (0.200127 0.00306486 0) (0.199935 0.00299688 0) (0.199737 0.00292997 0) (0.199534 0.00286401 0) (0.199324 0.0027989 0) (0.199108 0.00273453 0) (0.198886 0.0026708 0) (0.198659 0.00260764 0) (0.198427 0.00254494 0) (0.19819 0.00248262 0) (0.197947 0.0024206 0) (0.197701 0.0023588 0) (0.19745 0.00229714 0) (0.197195 0.00223555 0) (0.196937 0.00217395 0) (0.196676 0.00211227 0) (0.196411 0.00205043 0) (0.196145 0.00198837 0) (0.195876 0.00192602 0) (0.195606 0.00186331 0) (0.195335 0.00180018 0) (0.195064 0.00173656 0) (0.194793 0.00167241 0) (0.194522 0.00160767 0) (0.194252 0.00154227 0) (0.193984 0.00147619 0) (0.193719 0.00140937 0) (0.193456 0.00134178 0) (0.193197 0.00127337 0) (0.192942 0.00120413 0) (0.192692 0.00113401 0) (0.192448 0.00106302 0) (0.192209 0.000991152 0) (0.191976 0.000918479 0) (0.191751 0.000845138 0) (0.191532 0.000771391 0) (0.191321 0.000697667 0) (0.191117 0.000624596 0) (0.19092 0.000553011 0) (0.190731 0.000483898 0) (0.19055 0.000418279 0) (0.190376 0.000357059 0) (0.190211 0.000300911 0) (0.190054 0.000250236 0) (0.189906 0.000205191 0) (0.189767 0.000165703 0) (0.189637 0.000131553 0) (0.189516 0.000102352 0) (0.189403 7.76261e-05 0) (0.189298 5.69465e-05 0) (0.1892 3.97725e-05 0) (0.189109 2.55043e-05 0) (0.189022 1.37157e-05 0) (0.188941 4.15889e-06 0) (0.188866 -3.41712e-06 0) (0.188796 -9.23795e-06 0) (0.188732 -1.33613e-05 0) (0.188674 -1.55849e-05 0) (0.188613 -1.53364e-05 0) (0.196787 0.00629154 0) (0.197195 0.00680959 0) (0.197682 0.00722777 0) (0.198216 0.00753556 0) (0.198769 0.0077366 0) (0.199316 0.00783962 0) (0.199841 0.00785483 0) (0.20033 0.00779403 0) (0.200772 0.00767066 0) (0.201163 0.0074988 0) (0.201499 0.0072921 0) (0.201781 0.00706302 0) (0.20201 0.00682234 0) (0.202193 0.00657889 0) (0.202334 0.0063394 0) (0.202439 0.00610864 0) (0.202514 0.00588962 0) (0.202564 0.00568392 0) (0.202594 0.00549203 0) (0.202608 0.00531367 0) (0.20261 0.00514809 0) (0.202601 0.00499426 0) (0.202583 0.00485102 0) (0.202559 0.00471723 0) (0.202529 0.00459181 0) (0.202494 0.00447377 0) (0.202454 0.00436224 0) (0.202411 0.00425646 0) (0.202363 0.00415576 0) (0.202312 0.0040596 0) (0.202258 0.00396746 0) (0.2022 0.00387894 0) (0.202138 0.00379367 0) (0.202074 0.00371132 0) (0.202005 0.00363161 0) (0.201934 0.00355429 0) (0.201859 0.00347912 0) (0.201781 0.0034059 0) (0.201699 0.00333446 0) (0.201614 0.0032646 0) (0.201525 0.00319618 0) (0.201433 0.00312906 0) (0.201337 0.00306309 0) (0.201238 0.00299814 0) (0.201135 0.0029341 0) (0.201029 0.00287086 0) (0.200919 0.0028083 0) (0.200805 0.00274632 0) (0.200688 0.00268483 0) (0.200568 0.00262372 0) (0.200444 0.00256291 0) (0.200317 0.00250231 0) (0.200187 0.00244183 0) (0.200053 0.00238137 0) (0.199917 0.00232087 0) (0.199778 0.00226023 0) (0.199636 0.00219939 0) (0.199491 0.00213825 0) (0.199344 0.00207674 0) (0.199195 0.00201479 0) (0.199044 0.00195233 0) (0.198891 0.00188928 0) (0.198737 0.00182558 0) (0.198581 0.00176117 0) (0.198424 0.00169599 0) (0.198267 0.00162998 0) (0.19811 0.00156309 0) (0.197952 0.00149528 0) (0.197795 0.00142651 0) (0.197639 0.00135675 0) (0.197483 0.00128596 0) (0.197329 0.00121414 0) (0.197176 0.00114129 0) (0.197025 0.00106745 0) (0.196876 0.000992703 0) (0.19673 0.000917231 0) (0.196585 0.000841331 0) (0.196443 0.000765457 0) (0.196303 0.000690247 0) (0.196165 0.000616518 0) (0.19603 0.000545212 0) (0.195897 0.000477296 0) (0.195768 0.000413633 0) (0.195642 0.000354887 0) (0.19552 0.000301475 0) (0.195403 0.000253585 0) (0.195292 0.000211193 0) (0.195185 0.000174114 0) (0.195085 0.000142028 0) (0.19499 0.000114534 0) (0.194901 9.11947e-05 0) (0.194818 7.15152e-05 0) (0.19474 5.50517e-05 0) (0.194666 4.14068e-05 0) (0.194597 3.01613e-05 0) (0.194532 2.09387e-05 0) (0.194471 1.34787e-05 0) (0.194412 7.658e-06 0) (0.194358 3.39229e-06 0) (0.194299 1.22961e-08 0) (0.197134 0.00606567 0) (0.197488 0.00652089 0) (0.197908 0.00689806 0) (0.198373 0.00718567 0) (0.19886 0.007383 0) (0.199347 0.00749501 0) (0.19982 0.00752923 0) (0.200264 0.007495 0) (0.200672 0.00740318 0) (0.201037 0.00726546 0) (0.201355 0.0070934 0) (0.201627 0.0068978 0) (0.201853 0.00668822 0) (0.202038 0.00647265 0) (0.202184 0.00625744 0) (0.202298 0.00604725 0) (0.202384 0.00584528 0) (0.202447 0.00565345 0) (0.202491 0.00547267 0) (0.202519 0.00530313 0) (0.202534 0.00514449 0) (0.20254 0.00499611 0) (0.202538 0.00485718 0) (0.202529 0.00472683 0) (0.202516 0.00460418 0) (0.202498 0.00448842 0) (0.202477 0.0043788 0) (0.202453 0.00427466 0) (0.202426 0.00417541 0) (0.202397 0.00408053 0) (0.202367 0.00398958 0) (0.202334 0.00390216 0) (0.2023 0.00381793 0) (0.202264 0.00373658 0) (0.202227 0.00365785 0) (0.202188 0.00358147 0) (0.202148 0.00350725 0) (0.202106 0.00343497 0) (0.202064 0.00336445 0) (0.202019 0.00329553 0) (0.201974 0.00322805 0) (0.201927 0.00316187 0) (0.201878 0.00309684 0) (0.201829 0.00303285 0) (0.201777 0.00296976 0) (0.201724 0.00290747 0) (0.20167 0.00284586 0) (0.201614 0.00278483 0) (0.201557 0.00272427 0) (0.201498 0.0026641 0) (0.201437 0.0026042 0) (0.201374 0.00254448 0) (0.20131 0.00248486 0) (0.201245 0.00242524 0) (0.201177 0.00236553 0) (0.201108 0.00230566 0) (0.201038 0.00224552 0) (0.200966 0.00218504 0) (0.200892 0.00212414 0) (0.200817 0.00206274 0) (0.20074 0.00200076 0) (0.200662 0.00193813 0) (0.200583 0.00187477 0) (0.200503 0.00181061 0) (0.200421 0.00174561 0) (0.200338 0.00167969 0) (0.200255 0.00161281 0) (0.20017 0.00154491 0) (0.200085 0.00147597 0) (0.2 0.00140595 0) (0.199913 0.00133483 0) (0.199826 0.00126261 0) (0.199739 0.0011893 0) (0.199652 0.00111496 0) (0.199564 0.00103971 0) (0.199475 0.000963747 0) (0.199386 0.000887381 0) (0.199297 0.000811077 0) (0.199206 0.000735455 0) (0.199115 0.000661291 0) (0.199022 0.000589465 0) (0.19893 0.000520874 0) (0.198837 0.000456329 0) (0.198745 0.000396465 0) (0.198655 0.000341701 0) (0.198566 0.000292251 0) (0.19848 0.000248127 0) (0.198397 0.000209189 0) (0.198317 0.000175169 0) (0.198241 0.000145712 0) (0.198169 0.000120418 0) (0.1981 9.8855e-05 0) (0.198036 8.06073e-05 0) (0.197975 6.52723e-05 0) (0.197918 5.24629e-05 0) (0.197864 4.18589e-05 0) (0.197812 3.31927e-05 0) (0.197764 2.61995e-05 0) (0.197718 2.05091e-05 0) (0.197666 1.48514e-05 0) (0.197445 0.00585972 0) (0.197755 0.00626115 0) (0.198119 0.00660065 0) (0.198525 0.00686738 0) (0.198953 0.00705825 0) (0.199386 0.00717546 0) (0.19981 0.00722425 0) (0.200213 0.00721181 0) (0.200587 0.00714681 0) (0.200926 0.00703879 0) (0.201225 0.00689746 0) (0.201485 0.00673209 0) (0.201705 0.00655103 0) (0.201888 0.00636147 0) (0.202036 0.00616927 0) (0.202155 0.00597893 0) (0.202248 0.00579369 0) (0.202318 0.00561571 0) (0.20237 0.00544621 0) (0.202407 0.00528573 0) (0.202431 0.00513431 0) (0.202446 0.00499165 0) (0.202452 0.00485723 0) (0.202452 0.00473042 0) (0.202446 0.00461057 0) (0.202437 0.00449703 0) (0.202424 0.00438917 0) (0.202409 0.00428644 0) (0.202391 0.00418833 0) (0.202371 0.00409438 0) (0.20235 0.00400419 0) (0.202328 0.00391739 0) (0.202305 0.00383368 0) (0.202281 0.00375277 0) (0.202256 0.0036744 0) (0.202231 0.00359835 0) (0.202205 0.0035244 0) (0.202179 0.00345237 0) (0.202153 0.00338209 0) (0.202126 0.00331339 0) (0.202099 0.00324613 0) (0.202071 0.00318016 0) (0.202044 0.00311535 0) (0.202016 0.00305158 0) (0.201988 0.00298872 0) (0.201959 0.00292667 0) (0.201931 0.00286532 0) (0.201902 0.00280455 0) (0.201872 0.00274427 0) (0.201843 0.00268438 0) (0.201812 0.00262478 0) (0.201782 0.00256538 0) (0.201751 0.00250608 0) (0.20172 0.00244679 0) (0.201688 0.00238742 0) (0.201655 0.00232788 0) (0.201622 0.00226809 0) (0.201589 0.00220795 0) (0.201554 0.0021474 0) (0.201519 0.00208633 0) (0.201484 0.00202468 0) (0.201447 0.00196237 0) (0.20141 0.00189933 0) (0.201372 0.00183548 0) (0.201334 0.00177077 0) (0.201294 0.00170513 0) (0.201254 0.00163852 0) (0.201213 0.00157088 0) (0.20117 0.00150219 0) (0.201127 0.00143241 0) (0.201083 0.00136153 0) (0.201038 0.00128956 0) (0.200991 0.00121653 0) (0.200944 0.00114251 0) (0.200894 0.00106763 0) (0.200843 0.000992102 0) (0.20079 0.000916251 0) (0.200735 0.000840527 0) (0.200677 0.00076552 0) (0.200617 0.000691952 0) (0.200555 0.000620633 0) (0.20049 0.000552383 0) (0.200424 0.000487949 0) (0.200357 0.000427932 0) (0.20029 0.000372743 0) (0.200222 0.000322608 0) (0.200156 0.000277573 0) (0.200091 0.000237537 0) (0.200028 0.000202278 0) (0.199967 0.00017149 0) (0.199909 0.000144816 0) (0.199853 0.000121868 0) (0.199801 0.000102259 0) (0.19975 8.5614e-05 0) (0.199703 7.158e-05 0) (0.199658 5.98399e-05 0) (0.199615 5.01037e-05 0) (0.199574 4.20672e-05 0) (0.199536 3.52762e-05 0) (0.199491 2.84817e-05 0) (0.197725 0.0056707 0) (0.197998 0.00602607 0) (0.198316 0.00633162 0) (0.198669 0.00657776 0) (0.199046 0.00676037 0) (0.19943 0.00687981 0) (0.19981 0.00693944 0) (0.200174 0.00694463 0) (0.200516 0.00690218 0) (0.200828 0.00681982 0) (0.201108 0.00670558 0) (0.201354 0.00656732 0) (0.201566 0.00641229 0) (0.201745 0.00624687 0) (0.201894 0.00607639 0) (0.202015 0.00590512 0) (0.202112 0.00573626 0) (0.202188 0.00557207 0) (0.202246 0.00541402 0) (0.20229 0.00526291 0) (0.20232 0.00511909 0) (0.202341 0.00498253 0) (0.202354 0.00485299 0) (0.202359 0.00473006 0) (0.202359 0.00461329 0) (0.202355 0.00450219 0) (0.202347 0.00439626 0) (0.202337 0.00429505 0) (0.202324 0.00419812 0) (0.202309 0.00410508 0) (0.202293 0.00401559 0) (0.202275 0.00392932 0) (0.202257 0.00384599 0) (0.202238 0.00376533 0) (0.202219 0.00368713 0) (0.202199 0.00361116 0) (0.202179 0.00353723 0) (0.202159 0.00346517 0) (0.202139 0.00339481 0) (0.202119 0.003326 0) (0.2021 0.00325861 0) (0.20208 0.00319249 0) (0.202061 0.00312752 0) (0.202042 0.00306358 0) (0.202024 0.00300055 0) (0.202005 0.00293834 0) (0.201987 0.00287682 0) (0.20197 0.00281591 0) (0.201952 0.00275549 0) (0.201935 0.00269548 0) (0.201919 0.00263577 0) (0.201902 0.00257627 0) (0.201886 0.0025169 0) (0.20187 0.00245755 0) (0.201854 0.00239815 0) (0.201838 0.0023386 0) (0.201822 0.00227882 0) (0.201807 0.00221872 0) (0.201791 0.00215822 0) (0.201775 0.00209723 0) (0.201759 0.00203569 0) (0.201743 0.00197351 0) (0.201727 0.00191062 0) (0.20171 0.00184696 0) (0.201693 0.00178246 0) (0.201676 0.00171707 0) (0.201658 0.00165073 0) (0.201639 0.00158341 0) (0.201619 0.00151507 0) (0.201599 0.00144569 0) (0.201577 0.00137526 0) (0.201554 0.00130381 0) (0.20153 0.00123136 0) (0.201504 0.00115802 0) (0.201476 0.00108392 0) (0.201446 0.00100928 0) (0.201414 0.000934413 0) (0.201379 0.000859764 0) (0.20134 0.000785881 0) (0.201299 0.00071343 0) (0.201255 0.000643146 0) (0.201208 0.000575774 0) (0.201159 0.000511995 0) (0.201108 0.00045237 0) (0.201056 0.000397294 0) (0.201003 0.000347 0) (0.20095 0.000301559 0) (0.200897 0.000260903 0) (0.200846 0.000224855 0) (0.200796 0.000193154 0) (0.200748 0.000165484 0) (0.200701 0.000141499 0) (0.200657 0.000120845 0) (0.200615 0.000103179 0) (0.200574 8.81667e-05 0) (0.200536 7.55027e-05 0) (0.200499 6.48966e-05 0) (0.200464 5.60316e-05 0) (0.200431 4.84433e-05 0) (0.200391 4.11452e-05 0) (0.197978 0.0054964 0) (0.198219 0.0058123 0) (0.198497 0.00608758 0) (0.198807 0.00631407 0) (0.199138 0.00648741 0) (0.199478 0.00660679 0) (0.199817 0.00667416 0) (0.200145 0.0066934 0) (0.200456 0.00666975 0) (0.200743 0.00660936 0) (0.201004 0.00651883 0) (0.201236 0.00640473 0) (0.201438 0.00627329 0) (0.201612 0.0061301 0) (0.201759 0.00597998 0) (0.20188 0.00582689 0) (0.20198 0.00567391 0) (0.20206 0.00552335 0) (0.202123 0.00537681 0) (0.202171 0.0052353 0) (0.202207 0.0050994 0) (0.202233 0.00496932 0) (0.20225 0.00484504 0) (0.202261 0.00472637 0) (0.202265 0.00461303 0) (0.202265 0.00450466 0) (0.202262 0.00440092 0) (0.202255 0.00430144 0) (0.202245 0.00420587 0) (0.202234 0.0041139 0) (0.202221 0.00402521 0) (0.202206 0.00393953 0) (0.202191 0.00385662 0) (0.202175 0.00377624 0) (0.202158 0.00369819 0) (0.202141 0.00362227 0) (0.202124 0.00354831 0) (0.202107 0.00347614 0) (0.20209 0.00340562 0) (0.202073 0.0033366 0) (0.202057 0.00326895 0) (0.202041 0.00320254 0) (0.202025 0.00313726 0) (0.20201 0.003073 0) (0.201995 0.00300964 0) (0.201981 0.00294707 0) (0.201967 0.00288521 0) (0.201954 0.00282395 0) (0.201941 0.00276319 0) (0.201929 0.00270284 0) (0.201918 0.00264281 0) (0.201907 0.00258301 0) (0.201896 0.00252335 0) (0.201886 0.00246373 0) (0.201877 0.00240408 0) (0.201868 0.00234431 0) (0.20186 0.00228433 0) (0.201851 0.00222406 0) (0.201844 0.00216343 0) (0.201836 0.00210234 0) (0.201829 0.00204074 0) (0.201821 0.00197853 0) (0.201814 0.00191566 0) (0.201807 0.00185206 0) (0.201799 0.00178767 0) (0.201792 0.00172244 0) (0.201784 0.00165632 0) (0.201775 0.00158927 0) (0.201766 0.00152127 0) (0.201756 0.0014523 0) (0.201745 0.00138237 0) (0.201733 0.0013115 0) (0.201719 0.00123975 0) (0.201704 0.00116721 0) (0.201687 0.00109403 0) (0.201667 0.00102044 0) (0.201645 0.000946741 0) (0.20162 0.000873353 0) (0.201593 0.000800789 0) (0.201562 0.000729657 0) (0.201528 0.000660621 0) (0.201491 0.000594353 0) (0.201452 0.000531475 0) (0.20141 0.000472501 0) (0.201367 0.000417811 0) (0.201323 0.000367636 0) (0.201279 0.000322066 0) (0.201234 0.000281065 0) (0.20119 0.000244493 0) (0.201147 0.000212128 0) (0.201106 0.000183698 0) (0.201065 0.000158894 0) (0.201027 0.000137398 0) (0.200989 0.000118893 0) (0.200954 0.000103069 0) (0.20092 8.96361e-05 0) (0.200887 7.83086e-05 0) (0.200856 6.87747e-05 0) (0.200826 6.06146e-05 0) (0.20079 5.31455e-05 0) (0.198206 0.00533519 0) (0.198419 0.00561718 0) (0.198664 0.00586565 0) (0.198935 0.00607381 0) (0.199227 0.00623743 0) (0.199528 0.00635508 0) (0.19983 0.0064277 0) (0.200125 0.00645795 0) (0.200406 0.00644979 0) (0.200669 0.00640806 0) (0.20091 0.00633811 0) (0.201127 0.00624538 0) (0.201319 0.00613517 0) (0.201487 0.00601233 0) (0.20163 0.00588114 0) (0.201751 0.00574523 0) (0.201851 0.00560752 0) (0.201933 0.00547027 0) (0.201999 0.00533517 0) (0.202052 0.00520337 0) (0.202092 0.00507561 0) (0.202122 0.00495231 0) (0.202144 0.00483362 0) (0.202159 0.00471954 0) (0.202167 0.00460994 0) (0.202171 0.00450463 0) (0.202171 0.00440335 0) (0.202167 0.00430585 0) (0.202161 0.00421186 0) (0.202152 0.00412112 0) (0.202141 0.0040334 0) (0.202129 0.00394845 0) (0.202116 0.00386607 0) (0.202103 0.00378606 0) (0.202088 0.00370823 0) (0.202073 0.00363241 0) (0.202058 0.00355845 0) (0.202043 0.0034862 0) (0.202028 0.00341553 0) (0.202013 0.00334629 0) (0.201998 0.00327837 0) (0.201983 0.00321166 0) (0.201969 0.00314604 0) (0.201956 0.00308141 0) (0.201943 0.00301766 0) (0.20193 0.0029547 0) (0.201918 0.00289243 0) (0.201907 0.00283075 0) (0.201896 0.00276958 0) (0.201886 0.00270882 0) (0.201877 0.00264839 0) (0.201868 0.00258819 0) (0.20186 0.00252814 0) (0.201853 0.00246817 0) (0.201846 0.00240817 0) (0.201839 0.00234808 0) (0.201834 0.00228781 0) (0.201828 0.00222728 0) (0.201823 0.00216641 0) (0.201819 0.00210513 0) (0.201815 0.00204337 0) (0.201811 0.00198105 0) (0.201807 0.00191811 0) (0.201803 0.0018545 0) (0.201799 0.00179015 0) (0.201796 0.00172501 0) (0.201792 0.00165905 0) (0.201787 0.00159224 0) (0.201782 0.00152455 0) (0.201776 0.00145598 0) (0.20177 0.00138654 0) (0.201762 0.00131627 0) (0.201753 0.00124522 0) (0.201742 0.0011735 0) (0.20173 0.00110128 0) (0.201715 0.00102877 0) (0.201698 0.000956271 0) (0.201679 0.000884178 0) (0.201656 0.000812965 0) (0.201631 0.000743187 0) (0.201602 0.000675443 0) (0.201571 0.000610341 0) (0.201537 0.000548441 0) (0.201501 0.000490218 0) (0.201464 0.00043603 0) (0.201425 0.000386107 0) (0.201386 0.00034055 0) (0.201346 0.000299351 0) (0.201307 0.000262401 0) (0.201269 0.000229519 0) (0.201231 0.000200468 0) (0.201195 0.000174977 0) (0.20116 0.000152762 0) (0.201126 0.000133531 0) (0.201093 0.000117001 0) (0.201062 0.000102897 0) (0.201032 9.09475e-05 0) (0.201003 8.08591e-05 0) (0.200976 7.22766e-05 0) (0.200941 6.47585e-05 0) (0.198412 0.00518581 0) (0.198602 0.0054386 0) (0.198817 0.00566344 0) (0.199056 0.00585473 0) (0.199312 0.00600862 0) (0.199578 0.00612338 0) (0.199847 0.00619924 0) (0.200111 0.00623794 0) (0.200365 0.00624242 0) (0.200605 0.00621642 0) (0.200827 0.0061642 0) (0.201029 0.00609025 0) (0.20121 0.005999 0) (0.201369 0.00589464 0) (0.201507 0.00578091 0) (0.201626 0.0056611 0) (0.201726 0.00553793 0) (0.201809 0.00541357 0) (0.201878 0.00528972 0) (0.201933 0.00516761 0) (0.201976 0.00504812 0) (0.20201 0.00493179 0) (0.202036 0.00481895 0) (0.202054 0.00470975 0) (0.202066 0.00460419 0) (0.202073 0.0045022 0) (0.202076 0.00440365 0) (0.202075 0.00430837 0) (0.202071 0.00421618 0) (0.202065 0.00412688 0) (0.202057 0.00404028 0) (0.202047 0.00395621 0) (0.202037 0.00387449 0) (0.202025 0.00379495 0) (0.202012 0.00371744 0) (0.201999 0.00364181 0) (0.201985 0.00356793 0) (0.201972 0.00349565 0) (0.201958 0.00342486 0) (0.201944 0.00335545 0) (0.201931 0.0032873 0) (0.201918 0.0032203 0) (0.201905 0.00315436 0) (0.201892 0.00308937 0) (0.20188 0.00302524 0) (0.201869 0.00296188 0) (0.201858 0.00289919 0) (0.201848 0.00283709 0) (0.201838 0.00277549 0) (0.201829 0.0027143 0) (0.201821 0.00265344 0) (0.201813 0.00259282 0) (0.201806 0.00253237 0) (0.201799 0.002472 0) (0.201793 0.00241164 0) (0.201788 0.00235119 0) (0.201783 0.00229059 0) (0.201779 0.00222976 0) (0.201775 0.00216863 0) (0.201772 0.00210711 0) (0.201768 0.00204516 0) (0.201766 0.00198269 0) (0.201763 0.00191966 0) (0.201761 0.00185599 0) (0.201758 0.00179165 0) (0.201756 0.00172659 0) (0.201753 0.00166077 0) (0.20175 0.00159417 0) (0.201746 0.00152677 0) (0.201742 0.00145858 0) (0.201737 0.00138962 0) (0.201731 0.00131992 0) (0.201724 0.00124957 0) (0.201715 0.00117868 0) (0.201705 0.00110739 0) (0.201692 0.00103594 0) (0.201677 0.000964622 0) (0.20166 0.000893792 0) (0.20164 0.000823895 0) (0.201617 0.000755435 0) (0.201592 0.000688954 0) (0.201564 0.000624998 0) (0.201534 0.000564077 0) (0.201501 0.000506625 0) (0.201467 0.000452979 0) (0.201432 0.000403364 0) (0.201396 0.000357892 0) (0.20136 0.000316575 0) (0.201324 0.000279334 0) (0.201289 0.000246022 0) (0.201254 0.000216437 0) (0.20122 0.000190343 0) (0.201188 0.000167485 0) (0.201156 0.000147603 0) (0.201126 0.000130435 0) (0.201096 0.000115726 0) (0.201068 0.000103223 0) (0.201041 9.26581e-05 0) (0.201015 8.37406e-05 0) (0.200982 7.6188e-05 0) (0.198599 0.00504726 0) (0.198768 0.00527485 0) (0.198958 0.00547892 0) (0.199167 0.00565488 0) (0.199393 0.00579932 0) (0.199628 0.00591043 0) (0.199866 0.00598798 0) (0.200102 0.00603304 0) (0.200331 0.0060477 0) (0.200549 0.00603482 0) (0.200752 0.00599777 0) (0.200939 0.00594019 0) (0.201108 0.00586577 0) (0.201259 0.00577805 0) (0.201391 0.0056803 0) (0.201506 0.00557545 0) (0.201604 0.00546598 0) (0.201688 0.00535395 0) (0.201757 0.00524103 0) (0.201814 0.00512848 0) (0.20186 0.00501724 0) (0.201897 0.004908 0) (0.201925 0.00480118 0) (0.201946 0.00469706 0) (0.201961 0.00459577 0) (0.201971 0.00449734 0) (0.201977 0.00440174 0) (0.201979 0.00430889 0) (0.201978 0.00421869 0) (0.201974 0.00413101 0) (0.201968 0.00404572 0) (0.201961 0.00396268 0) (0.201952 0.00388175 0) (0.201942 0.00380281 0) (0.201931 0.00372572 0) (0.201919 0.00365037 0) (0.201907 0.00357664 0) (0.201895 0.00350441 0) (0.201883 0.00343359 0) (0.20187 0.00336405 0) (0.201858 0.00329572 0) (0.201846 0.00322848 0) (0.201834 0.00316225 0) (0.201823 0.00309694 0) (0.201812 0.00303246 0) (0.201801 0.00296872 0) (0.201791 0.00290564 0) (0.201782 0.00284313 0) (0.201773 0.00278111 0) (0.201764 0.0027195 0) (0.201757 0.00265823 0) (0.201749 0.0025972 0) (0.201743 0.00253635 0) (0.201737 0.00247559 0) (0.201731 0.00241485 0) (0.201726 0.00235405 0) (0.201722 0.00229312 0) (0.201718 0.00223199 0) (0.201715 0.00217058 0) (0.201712 0.00210883 0) (0.201709 0.00204668 0) (0.201707 0.00198406 0) (0.201704 0.00192092 0) (0.201702 0.0018572 0) (0.2017 0.00179286 0) (0.201698 0.00172786 0) (0.201696 0.00166217 0) (0.201693 0.00159578 0) (0.20169 0.00152867 0) (0.201686 0.00146085 0) (0.201682 0.00139236 0) (0.201676 0.00132324 0) (0.20167 0.00125357 0) (0.201661 0.00118347 0) (0.201652 0.0011131 0) (0.20164 0.00104268 0) (0.201627 0.000972493 0) (0.201611 0.000902874 0) (0.201592 0.000834232 0) (0.201571 0.000767028 0) (0.201548 0.000701752 0) (0.201522 0.000638896 0) (0.201494 0.000578921 0) (0.201464 0.000522227 0) (0.201433 0.000469129 0) (0.2014 0.000419845 0) (0.201367 0.000374496 0) (0.201334 0.00033311 0) (0.2013 0.000295636 0) (0.201267 0.000261955 0) (0.201234 0.000231898 0) (0.201203 0.000205262 0) (0.201172 0.000181823 0) (0.201142 0.000161344 0) (0.201114 0.000143591 0) (0.201086 0.000128328 0) (0.201059 0.000115323 0) (0.201033 0.000104339 0) (0.201008 9.51379e-05 0) (0.200976 8.753e-05 0) (0.198769 0.00491878 0) (0.198919 0.00512457 0) (0.199086 0.0053104 0) (0.19927 0.0054725 0) (0.199468 0.00560794 0) (0.199676 0.00571495 0) (0.199887 0.00579301 0) (0.200097 0.0058427 0) (0.200302 0.00586547 0) (0.200499 0.00586347 0) (0.200684 0.00583932 0) (0.200856 0.00579594 0) (0.201013 0.00573636 0) (0.201155 0.00566356 0) (0.20128 0.00558035 0) (0.201391 0.00548931 0) (0.201486 0.00539267 0) (0.201568 0.00529237 0) (0.201638 0.00518998 0) (0.201696 0.00508677 0) (0.201743 0.00498372 0) (0.201782 0.00488158 0) (0.201812 0.00478088 0) (0.201836 0.00468199 0) (0.201854 0.00458513 0) (0.201866 0.00449045 0) (0.201874 0.00439799 0) (0.201879 0.00430776 0) (0.20188 0.00421972 0) (0.201878 0.00413382 0) (0.201875 0.00404997 0) (0.201869 0.00396808 0) (0.201862 0.00388807 0) (0.201854 0.00380982 0) (0.201845 0.00373325 0) (0.201835 0.00365826 0) (0.201824 0.00358476 0) (0.201813 0.00351265 0) (0.201802 0.00344183 0) (0.201791 0.00337223 0) (0.20178 0.00330375 0) (0.201769 0.00323632 0) (0.201758 0.00316984 0) (0.201748 0.00310424 0) (0.201738 0.00303943 0) (0.201728 0.00297534 0) (0.201719 0.00291189 0) (0.20171 0.00284899 0) (0.201702 0.00278658 0) (0.201694 0.00272457 0) (0.201687 0.0026629 0) (0.20168 0.00260148 0) (0.201674 0.00254023 0) (0.201668 0.0024791 0) (0.201663 0.002418 0) (0.201659 0.00235686 0) (0.201655 0.00229561 0) (0.201651 0.00223418 0) (0.201648 0.00217251 0) (0.201645 0.00211053 0) (0.201642 0.00204819 0) (0.20164 0.00198542 0) (0.201638 0.00192218 0) (0.201636 0.00185841 0) (0.201634 0.00179407 0) (0.201632 0.00172914 0) (0.20163 0.00166358 0) (0.201627 0.0015974 0) (0.201624 0.00153057 0) (0.20162 0.00146313 0) (0.201616 0.0013951 0) (0.201611 0.00132654 0) (0.201604 0.00125754 0) (0.201597 0.00118822 0) (0.201587 0.00111874 0) (0.201576 0.00104932 0) (0.201563 0.000980206 0) (0.201548 0.000911738 0) (0.201531 0.000844286 0) (0.201511 0.000778269 0) (0.20149 0.000714131 0) (0.201466 0.000652317 0) (0.20144 0.000593246 0) (0.201412 0.000537284 0) (0.201383 0.000484725 0) (0.201352 0.000435781 0) (0.201322 0.000390578 0) (0.20129 0.000349158 0) (0.201259 0.000311494 0) (0.201228 0.000277492 0) (0.201197 0.000247014 0) (0.201168 0.000219887 0) (0.201139 0.000195913 0) (0.20111 0.000174885 0) (0.201083 0.00015659 0) (0.201057 0.000140815 0) (0.201031 0.000127352 0) (0.201006 0.000115991 0) (0.200982 0.000106535 0) (0.200951 9.88451e-05 0) (0.198922 0.00479982 0) (0.199055 0.00498677 0) (0.199203 0.00515662 0) (0.199365 0.00530632 0) (0.199539 0.00543334 0) (0.199722 0.00553602 0) (0.199908 0.00561371 0) (0.200095 0.00566662 0) (0.200278 0.00569573 0) (0.200455 0.00570261 0) (0.200623 0.00568928 0) (0.20078 0.00565804 0) (0.200925 0.00561138 0) (0.201057 0.00555177 0) (0.201175 0.00548162 0) (0.20128 0.00540315 0) (0.201372 0.00531837 0) (0.201452 0.00522904 0) (0.20152 0.00513665 0) (0.201578 0.00504243 0) (0.201626 0.00494738 0) (0.201666 0.00485227 0) (0.201698 0.0047577 0) (0.201723 0.00466411 0) (0.201743 0.00457181 0) (0.201758 0.00448102 0) (0.201768 0.00439187 0) (0.201774 0.00430443 0) (0.201778 0.00421873 0) (0.201778 0.00413477 0) (0.201776 0.00405252 0) (0.201773 0.00397194 0) (0.201767 0.00389297 0) (0.201761 0.00381555 0) (0.201753 0.00373962 0) (0.201745 0.0036651 0) (0.201736 0.00359191 0) (0.201726 0.00352 0) (0.201717 0.00344928 0) (0.201707 0.00337968 0) (0.201697 0.00331113 0) (0.201687 0.00324355 0) (0.201677 0.00317688 0) (0.201668 0.00311103 0) (0.201658 0.00304595 0) (0.20165 0.00298154 0) (0.201641 0.00291776 0) (0.201633 0.00285451 0) (0.201625 0.00279173 0) (0.201618 0.00272935 0) (0.201611 0.0026673 0) (0.201605 0.00260551 0) (0.201599 0.0025439 0) (0.201594 0.00248241 0) (0.20159 0.00242096 0) (0.201585 0.0023595 0) (0.201581 0.00229795 0) (0.201578 0.00223624 0) (0.201575 0.00217432 0) (0.201572 0.00211213 0) (0.20157 0.00204961 0) (0.201567 0.0019867 0) (0.201565 0.00192337 0) (0.201563 0.00185956 0) (0.201561 0.00179524 0) (0.201559 0.00173038 0) (0.201557 0.00166496 0) (0.201555 0.00159899 0) (0.201552 0.00153245 0) (0.201548 0.00146538 0) (0.201544 0.00139781 0) (0.201538 0.00132981 0) (0.201532 0.00126146 0) (0.201525 0.00119289 0) (0.201516 0.00112427 0) (0.201505 0.00105579 0) (0.201493 0.000987712 0) (0.201479 0.000920335 0) (0.201463 0.000854005 0) (0.201444 0.000789106 0) (0.201424 0.000726039 0) (0.201401 0.000665208 0) (0.201377 0.000606994 0) (0.201351 0.000551733 0) (0.201324 0.000499701 0) (0.201296 0.000451101 0) (0.201267 0.000406063 0) (0.201238 0.000364641 0) (0.201209 0.000326826 0) (0.20118 0.000292551 0) (0.201151 0.000261702 0) (0.201123 0.000234133 0) (0.201096 0.000209676 0) (0.201069 0.000188147 0) (0.201044 0.000169357 0) (0.201018 0.000153117 0) (0.200994 0.000139238 0) (0.20097 0.00012754 0) (0.200947 0.000117859 0) (0.200918 0.000110071 0) (0.199061 0.00468954 0) (0.199179 0.00486009 0) (0.199309 0.00501594 0) (0.199451 0.00515459 0) (0.199604 0.00527386 0) (0.199765 0.00537226 0) (0.199929 0.00544906 0) (0.200094 0.00550424 0) (0.200257 0.00553839 0) (0.200416 0.00555263 0) (0.200567 0.00554849 0) (0.20071 0.00552777 0) (0.200842 0.00549245 0) (0.200964 0.00544459 0) (0.201074 0.0053862 0) (0.201173 0.00531921 0) (0.201261 0.00524537 0) (0.201337 0.00516629 0) (0.201404 0.00508334 0) (0.201461 0.00499769 0) (0.201509 0.00491033 0) (0.201549 0.00482206 0) (0.201582 0.0047335 0) (0.201609 0.00464516 0) (0.20163 0.00455741 0) (0.201646 0.00447053 0) (0.201658 0.00438473 0) (0.201666 0.00430013 0) (0.201671 0.00421683 0) (0.201673 0.00413488 0) (0.201673 0.00405429 0) (0.201671 0.00397508 0) (0.201667 0.00389722 0) (0.201662 0.00382068 0) (0.201656 0.00374543 0) (0.201649 0.00367143 0) (0.201642 0.00359862 0) (0.201633 0.00352695 0) (0.201625 0.00345636 0) (0.201616 0.0033868 0) (0.201607 0.00331821 0) (0.201598 0.00325053 0) (0.20159 0.00318369 0) (0.201581 0.00311764 0) (0.201573 0.0030523 0) (0.201565 0.00298761 0) (0.201557 0.00292352 0) (0.20155 0.00285994 0) (0.201542 0.00279683 0) (0.201536 0.0027341 0) (0.20153 0.0026717 0) (0.201524 0.00260955 0) (0.201519 0.0025476 0) (0.201514 0.00248577 0) (0.201509 0.00242401 0) (0.201505 0.00236224 0) (0.201502 0.0023004 0) (0.201499 0.00223844 0) (0.201496 0.00217629 0) (0.201493 0.00211389 0) (0.201491 0.00205121 0) (0.201489 0.00198818 0) (0.201487 0.00192476 0) (0.201485 0.00186092 0) (0.201483 0.00179662 0) (0.201481 0.00173185 0) (0.201478 0.00166658 0) (0.201476 0.00160081 0) (0.201473 0.00153457 0) (0.201469 0.00146786 0) (0.201465 0.00140075 0) (0.20146 0.00133329 0) (0.201454 0.00126557 0) (0.201447 0.00119774 0) (0.201438 0.00112993 0) (0.201428 0.00106236 0) (0.201417 0.000995254 0) (0.201403 0.000928906 0) (0.201388 0.00086363 0) (0.201371 0.000799777 0) (0.201352 0.000737713 0) (0.201331 0.000677805 0) (0.201309 0.000620398 0) (0.201285 0.000565802 0) (0.20126 0.000514274 0) (0.201234 0.000466012 0) (0.201207 0.000421144 0) (0.20118 0.000379738 0) (0.201153 0.000341799 0) (0.201126 0.000307282 0) (0.201099 0.000276098 0) (0.201073 0.000248127 0) (0.201047 0.000223224 0) (0.201022 0.000201231 0) (0.200998 0.000181982 0) (0.200974 0.000165308 0) (0.200951 0.000151045 0) (0.200928 0.000139038 0) (0.200906 0.000129147 0) (0.200878 0.000121249 0) (0.199214 0.00456991 0) (0.199315 0.00472357 0) (0.199427 0.00486478 0) (0.199548 0.00499155 0) (0.199678 0.00510212 0) (0.199815 0.0051952 0) (0.199955 0.00527004 0) (0.200097 0.00532647 0) (0.200238 0.00536478 0) (0.200375 0.00538569 0) (0.200508 0.00539028 0) (0.200634 0.00537986 0) (0.200752 0.00535595 0) (0.200861 0.00532015 0) (0.200961 0.00527407 0) (0.201051 0.00521929 0) (0.201132 0.00515731 0) (0.201204 0.0050895 0) (0.201266 0.0050171 0) (0.201321 0.00494119 0) (0.201367 0.0048627 0) (0.201407 0.00478241 0) (0.20144 0.00470098 0) (0.201467 0.00461895 0) (0.201489 0.00453673 0) (0.201506 0.00445467 0) (0.201519 0.00437303 0) (0.201529 0.00429201 0) (0.201536 0.00421177 0) (0.201539 0.0041324 0) (0.201541 0.004054 0) (0.201541 0.00397659 0) (0.201539 0.00390022 0) (0.201535 0.00382489 0) (0.201531 0.0037506 0) (0.201525 0.00367734 0) (0.201519 0.00360509 0) (0.201512 0.00353381 0) (0.201505 0.00346349 0) (0.201498 0.00339406 0) (0.20149 0.00332551 0) (0.201482 0.00325777 0) (0.201475 0.0031908 0) (0.201467 0.00312455 0) (0.20146 0.00305897 0) (0.201453 0.002994 0) (0.201446 0.00292958 0) (0.201439 0.00286566 0) (0.201433 0.00280218 0) (0.201427 0.00273907 0) (0.201422 0.00267628 0) (0.201417 0.00261375 0) (0.201412 0.00255142 0) (0.201408 0.00248921 0) (0.201404 0.00242709 0) (0.2014 0.00236498 0) (0.201397 0.00230282 0) (0.201394 0.00224057 0) (0.201391 0.00217816 0) (0.201389 0.00211555 0) (0.201387 0.00205269 0) (0.201385 0.00198952 0) (0.201383 0.00192603 0) (0.201381 0.00186216 0) (0.201379 0.0017979 0) (0.201377 0.00173323 0) (0.201375 0.00166814 0) (0.201373 0.00160263 0) (0.20137 0.00153672 0) (0.201366 0.00147045 0) (0.201362 0.00140386 0) (0.201358 0.00133703 0) (0.201352 0.00127004 0) (0.201345 0.00120304 0) (0.201337 0.00113616 0) (0.201328 0.00106961 0) (0.201317 0.0010036 0) (0.201305 0.000938397 0) (0.201291 0.000874295 0) (0.201276 0.000811605 0) (0.201258 0.000750658 0) (0.20124 0.00069178 0) (0.201219 0.000635281 0) (0.201198 0.000581444 0) (0.201175 0.000530506 0) (0.201152 0.000482652 0) (0.201128 0.000438014 0) (0.201103 0.000396667 0) (0.201079 0.000358634 0) (0.201054 0.000323892 0) (0.20103 0.000292377 0) (0.201006 0.000263996 0) (0.200982 0.000238634 0) (0.200959 0.000216157 0) (0.200937 0.000196428 0) (0.200915 0.000179303 0) (0.200894 0.000164643 0) (0.200873 0.000152318 0) (0.200852 0.000142215 0) (0.200826 0.00013424 0) (0.199364 0.00444278 0) (0.199449 0.00458024 0) (0.199541 0.00470736 0) (0.199641 0.00482265 0) (0.199748 0.0049247 0) (0.19986 0.00501239 0) (0.199976 0.00508503 0) (0.200094 0.00514232 0) (0.200211 0.0051843 0) (0.200327 0.00521136 0) (0.200439 0.00522418 0) (0.200546 0.00522364 0) (0.200648 0.00521082 0) (0.200743 0.00518689 0) (0.20083 0.00515308 0) (0.200911 0.00511064 0) (0.200983 0.00506078 0) (0.201049 0.00500464 0) (0.201106 0.00494328 0) (0.201157 0.00487768 0) (0.201201 0.00480868 0) (0.201239 0.00473705 0) (0.201272 0.00466342 0) (0.201299 0.00458836 0) (0.201321 0.00451232 0) (0.201339 0.0044357 0) (0.201353 0.00435881 0) (0.201364 0.0042819 0) (0.201372 0.0042052 0) (0.201378 0.00412886 0) (0.201381 0.00405301 0) (0.201383 0.00397776 0) (0.201382 0.00390317 0) (0.201381 0.00382931 0) (0.201378 0.0037562 0) (0.201374 0.00368387 0) (0.20137 0.00361234 0) (0.201365 0.00354159 0) (0.201359 0.00347162 0) (0.201354 0.00340242 0) (0.201347 0.00333396 0) (0.201341 0.00326622 0) (0.201335 0.00319915 0) (0.201329 0.00313273 0) (0.201323 0.00306691 0) (0.201317 0.00300165 0) (0.201311 0.00293691 0) (0.201306 0.00287263 0) (0.2013 0.00280876 0) (0.201295 0.00274526 0) (0.201291 0.00268206 0) (0.201286 0.00261912 0) (0.201282 0.00255637 0) (0.201279 0.00249377 0) (0.201275 0.00243126 0) (0.201272 0.00236879 0) (0.201269 0.00230629 0) (0.201267 0.00224373 0) (0.201264 0.00218105 0) (0.201262 0.00211821 0) (0.20126 0.00205516 0) (0.201259 0.00199186 0) (0.201257 0.00192828 0) (0.201255 0.0018644 0) (0.201253 0.0018002 0) (0.201252 0.00173565 0) (0.20125 0.00167077 0) (0.201247 0.00160556 0) (0.201244 0.00154004 0) (0.201241 0.00147426 0) (0.201238 0.00140826 0) (0.201233 0.00134212 0) (0.201228 0.00127594 0) (0.201222 0.00120984 0) (0.201214 0.00114398 0) (0.201206 0.00107852 0) (0.201196 0.00101369 0) (0.201185 0.000949711 0) (0.201173 0.000886854 0) (0.201159 0.000825395 0) (0.201144 0.000765626 0) (0.201128 0.000707835 0) (0.20111 0.000652298 0) (0.201091 0.000599267 0) (0.201071 0.000548958 0) (0.20105 0.000501548 0) (0.201029 0.000457166 0) (0.201008 0.000415896 0) (0.200986 0.000377778 0) (0.200964 0.000342809 0) (0.200943 0.000310952 0) (0.200921 0.000282143 0) (0.2009 0.000256295 0) (0.20088 0.000233305 0) (0.20086 0.000213063 0) (0.20084 0.000195454 0) (0.200821 0.000180367 0) (0.200802 0.000167699 0) (0.200783 0.00015736 0) (0.200759 0.000149304 0) (0.199504 0.00432573 0) (0.199572 0.00444912 0) (0.199646 0.00456386 0) (0.199726 0.00466881 0) (0.199811 0.00476285 0) (0.199901 0.00484507 0) (0.199994 0.00491483 0) (0.200089 0.0049718 0) (0.200183 0.00501587 0) (0.200277 0.00504721 0) (0.200369 0.00506622 0) (0.200457 0.00507345 0) (0.200542 0.00506964 0) (0.200621 0.00505563 0) (0.200696 0.00503231 0) (0.200764 0.00500063 0) (0.200827 0.00496154 0) (0.200884 0.00491598 0) (0.200935 0.00486482 0) (0.200981 0.0048089 0) (0.201021 0.00474897 0) (0.201056 0.00468573 0) (0.201086 0.0046198 0) (0.201111 0.00455172 0) (0.201133 0.00448196 0) (0.201151 0.00441093 0) (0.201166 0.004339 0) (0.201177 0.00426645 0) (0.201186 0.00419354 0) (0.201193 0.00412049 0) (0.201197 0.00404747 0) (0.2012 0.00397462 0) (0.201202 0.00390206 0) (0.201202 0.00382989 0) (0.2012 0.00375818 0) (0.201198 0.00368698 0) (0.201196 0.00361634 0) (0.201192 0.00354628 0) (0.201189 0.00347683 0) (0.201184 0.00340799 0) (0.20118 0.00333975 0) (0.201175 0.00327212 0) (0.201171 0.00320506 0) (0.201166 0.00313856 0) (0.201161 0.0030726 0) (0.201156 0.00300714 0) (0.201152 0.00294214 0) (0.201148 0.00287757 0) (0.201143 0.00281338 0) (0.20114 0.00274954 0) (0.201136 0.00268599 0) (0.201132 0.00262269 0) (0.201129 0.00255958 0) (0.201126 0.00249663 0) (0.201124 0.00243378 0) (0.201121 0.00237099 0) (0.201119 0.0023082 0) (0.201117 0.00224536 0) (0.201115 0.00218245 0) (0.201113 0.00211941 0) (0.201112 0.00205621 0) (0.20111 0.00199282 0) (0.201109 0.0019292 0) (0.201107 0.00186534 0) (0.201106 0.00180122 0) (0.201104 0.00173684 0) (0.201103 0.0016722 0) (0.201101 0.00160731 0) (0.201098 0.00154221 0) (0.201095 0.00147693 0) (0.201092 0.00141153 0) (0.201088 0.0013461 0) (0.201084 0.00128073 0) (0.201078 0.00121554 0) (0.201072 0.00115067 0) (0.201065 0.0010863 0) (0.201056 0.0010226 0) (0.201047 0.000959813 0) (0.201036 0.000898158 0) (0.201025 0.000837887 0) (0.201012 0.000779257 0) (0.200998 0.000722523 0) (0.200982 0.000667931 0) (0.200966 0.000615706 0) (0.20095 0.000566046 0) (0.200932 0.000519118 0) (0.200914 0.000475048 0) (0.200896 0.000433927 0) (0.200877 0.000395807 0) (0.200858 0.000360704 0) (0.20084 0.000328606 0) (0.200822 0.000299472 0) (0.200803 0.000273242 0) (0.200786 0.000249843 0) (0.200768 0.000229191 0) (0.200751 0.000211199 0) (0.200734 0.000195781 0) (0.200717 0.00018286 0) (0.200701 0.000172366 0) (0.20068 0.00016428 0) (0.19963 0.00422059 0) (0.199683 0.0043323 0) (0.19974 0.0044367 0) (0.199801 0.00453292 0) (0.199866 0.0046201 0) (0.199935 0.00469746 0) (0.200006 0.00476447 0) (0.200079 0.00482075 0) (0.200152 0.00486613 0) (0.200225 0.00490064 0) (0.200297 0.00492444 0) (0.200366 0.00493789 0) (0.200433 0.00494144 0) (0.200497 0.00493565 0) (0.200556 0.00492118 0) (0.200612 0.00489872 0) (0.200664 0.00486899 0) (0.200711 0.00483273 0) (0.200754 0.00479066 0) (0.200792 0.00474348 0) (0.200826 0.00469184 0) (0.200857 0.00463637 0) (0.200883 0.00457763 0) (0.200906 0.00451615 0) (0.200926 0.0044524 0) (0.200942 0.00438678 0) (0.200956 0.00431969 0) (0.200967 0.00425143 0) (0.200976 0.0041823 0) (0.200983 0.00411255 0) (0.200989 0.00404239 0) (0.200992 0.00397201 0) (0.200995 0.00390155 0) (0.200996 0.00383114 0) (0.200996 0.0037609 0) (0.200996 0.00369092 0) (0.200995 0.00362126 0) (0.200993 0.00355198 0) (0.20099 0.00348312 0) (0.200988 0.00341471 0) (0.200985 0.00334676 0) (0.200982 0.0032793 0) (0.200979 0.00321231 0) (0.200975 0.0031458 0) (0.200972 0.00307975 0) (0.200969 0.00301413 0) (0.200966 0.00294893 0) (0.200963 0.00288411 0) (0.20096 0.00281965 0) (0.200957 0.0027555 0) (0.200954 0.00269163 0) (0.200952 0.002628 0) (0.20095 0.00256457 0) (0.200948 0.0025013 0) (0.200946 0.00243813 0) (0.200944 0.00237504 0) (0.200942 0.00231197 0) (0.200941 0.00224889 0) (0.20094 0.00218576 0) (0.200939 0.00212253 0) (0.200938 0.00205919 0) (0.200937 0.00199571 0) (0.200936 0.00193205 0) (0.200935 0.00186821 0) (0.200933 0.00180417 0) (0.200932 0.00173993 0) (0.200931 0.00167551 0) (0.200929 0.00161092 0) (0.200927 0.0015462 0) (0.200925 0.00148139 0) (0.200923 0.00141655 0) (0.200919 0.00135177 0) (0.200916 0.00128713 0) (0.200911 0.00122276 0) (0.200906 0.00115879 0) (0.2009 0.00109537 0) (0.200893 0.0010327 0) (0.200886 0.000970959 0) (0.200877 0.000910363 0) (0.200868 0.000851134 0) (0.200857 0.000793501 0) (0.200846 0.00073769 0) (0.200833 0.00068392 0) (0.200821 0.000632395 0) (0.200807 0.000583297 0) (0.200793 0.000536781 0) (0.200778 0.000492972 0) (0.200763 0.000451965 0) (0.200748 0.000413822 0) (0.200733 0.000378576 0) (0.200718 0.000346232 0) (0.200703 0.000316774 0) (0.200688 0.000290166 0) (0.200673 0.000266358 0) (0.200659 0.000245292 0) (0.200644 0.000226906 0) (0.20063 0.000211138 0) (0.200616 0.000197931 0) (0.200602 0.000187238 0) (0.200585 0.000179061 0) (0.199743 0.00413309 0) (0.199781 0.0042355 0) (0.199821 0.0043316 0) (0.199865 0.00442071 0) (0.199911 0.00450214 0) (0.19996 0.00457524 0) (0.200011 0.00463954 0) (0.200063 0.00469468 0) (0.200115 0.00474046 0) (0.200167 0.00477679 0) (0.200219 0.00480375 0) (0.20027 0.00482149 0) (0.200319 0.0048303 0) (0.200366 0.00483057 0) (0.20041 0.00482273 0) (0.200452 0.00480731 0) (0.200491 0.00478485 0) (0.200527 0.00475592 0) (0.20056 0.00472111 0) (0.20059 0.004681 0) (0.200617 0.00463616 0) (0.200641 0.00458713 0) (0.200662 0.00453444 0) (0.200681 0.00447856 0) (0.200697 0.00441995 0) (0.200711 0.00435903 0) (0.200723 0.00429617 0) (0.200733 0.00423171 0) (0.200741 0.00416596 0) (0.200748 0.00409919 0) (0.200753 0.00403163 0) (0.200757 0.00396351 0) (0.20076 0.00389501 0) (0.200762 0.00382627 0) (0.200764 0.00375744 0) (0.200764 0.00368864 0) (0.200764 0.00361995 0) (0.200764 0.00355146 0) (0.200763 0.00348322 0) (0.200762 0.0034153 0) (0.200761 0.00334771 0) (0.200759 0.0032805 0) (0.200757 0.00321367 0) (0.200756 0.00314724 0) (0.200754 0.00308119 0) (0.200752 0.00301552 0) (0.20075 0.00295023 0) (0.200749 0.00288527 0) (0.200747 0.00282065 0) (0.200745 0.00275632 0) (0.200744 0.00269225 0) (0.200743 0.00262841 0) (0.200741 0.00256477 0) (0.20074 0.00250128 0) (0.200739 0.00243791 0) (0.200738 0.00237463 0) (0.200738 0.00231139 0) (0.200737 0.00224816 0) (0.200736 0.00218491 0) (0.200736 0.0021216 0) (0.200735 0.00205821 0) (0.200735 0.00199471 0) (0.200734 0.00193109 0) (0.200734 0.00186734 0) (0.200733 0.00180345 0) (0.200733 0.00173942 0) (0.200732 0.00167527 0) (0.200731 0.00161102 0) (0.20073 0.00154671 0) (0.200728 0.00148239 0) (0.200726 0.00141811 0) (0.200724 0.00135397 0) (0.200721 0.00129005 0) (0.200718 0.00122646 0) (0.200714 0.00116335 0) (0.20071 0.00110085 0) (0.200705 0.00103913 0) (0.200699 0.00097837 0) (0.200693 0.000918765 0) (0.200686 0.000860515 0) (0.200678 0.000803825 0) (0.20067 0.000748898 0) (0.20066 0.000695932 0) (0.200651 0.000645114 0) (0.200641 0.00059661 0) (0.20063 0.000550569 0) (0.200619 0.000507112 0) (0.200608 0.000466337 0) (0.200597 0.000428313 0) (0.200585 0.000393086 0) (0.200574 0.000360676 0) (0.200562 0.000331086 0) (0.200551 0.000304299 0) (0.20054 0.000280287 0) (0.200529 0.000259012 0) (0.200518 0.000240434 0) (0.200507 0.00022451 0) (0.200496 0.000211202 0) (0.200485 0.000200477 0) (0.200472 0.000192346 0) (0.199844 0.00406545 0) (0.199867 0.00416118 0) (0.199891 0.0042513 0) (0.199917 0.00433528 0) (0.199945 0.00441253 0) (0.199975 0.0044825 0) (0.200006 0.00454476 0) (0.200037 0.00459898 0) (0.200069 0.00464494 0) (0.200101 0.0046825 0) (0.200133 0.00471165 0) (0.200164 0.00473247 0) (0.200195 0.00474511 0) (0.200224 0.00474983 0) (0.200252 0.00474695 0) (0.200279 0.00473683 0) (0.200304 0.00471991 0) (0.200327 0.00469664 0) (0.200349 0.00466749 0) (0.200369 0.00463295 0) (0.200387 0.00459352 0) (0.200403 0.00454968 0) (0.200418 0.00450189 0) (0.200431 0.00445061 0) (0.200443 0.00439627 0) (0.200453 0.00433927 0) (0.200462 0.00427998 0) (0.20047 0.00421875 0) (0.200476 0.00415589 0) (0.200482 0.00409169 0) (0.200487 0.00402641 0) (0.20049 0.00396028 0) (0.200494 0.00389349 0) (0.200496 0.00382623 0) (0.200498 0.00375866 0) (0.2005 0.00369092 0) (0.200501 0.0036231 0) (0.200502 0.00355533 0) (0.200503 0.00348766 0) (0.200503 0.00342018 0) (0.200503 0.00335293 0) (0.200503 0.00328594 0) (0.200503 0.00321926 0) (0.200503 0.0031529 0) (0.200503 0.00308686 0) (0.200503 0.00302115 0) (0.200502 0.00295577 0) (0.200502 0.00289069 0) (0.200502 0.00282591 0) (0.200502 0.00276141 0) (0.200502 0.00269715 0) (0.200502 0.00263311 0) (0.200501 0.00256926 0) (0.200501 0.00250557 0) (0.200502 0.002442 0) (0.200502 0.00237853 0) (0.200502 0.00231511 0) (0.200502 0.00225173 0) (0.200502 0.00218834 0) (0.200503 0.00212491 0) (0.200503 0.00206144 0) (0.200503 0.0019979 0) (0.200504 0.00193426 0) (0.200504 0.00187054 0) (0.200504 0.00180671 0) (0.200504 0.0017428 0) (0.200504 0.00167882 0) (0.200504 0.00161479 0) (0.200504 0.00155075 0) (0.200503 0.00148676 0) (0.200502 0.00142287 0) (0.200501 0.00135917 0) (0.2005 0.00129575 0) (0.200498 0.00123272 0) (0.200496 0.0011702 0) (0.200494 0.00110833 0) (0.200491 0.00104727 0) (0.200487 0.000987193 0) (0.200484 0.000928267 0) (0.200479 0.000870679 0) (0.200475 0.00081462 0) (0.20047 0.000760276 0) (0.200464 0.000707829 0) (0.200458 0.000657453 0) (0.200452 0.000609305 0) (0.200446 0.000563525 0) (0.200439 0.000520235 0) (0.200432 0.000479531 0) (0.200425 0.000441491 0) (0.200418 0.000406168 0) (0.20041 0.000373594 0) (0.200403 0.000343784 0) (0.200396 0.000316738 0) (0.200389 0.000292443 0) (0.200382 0.000270878 0) (0.200375 0.000252017 0) (0.200368 0.000235833 0) (0.200361 0.000222302 0) (0.200354 0.000211407 0) (0.200345 0.000203182 0) (0.199932 0.00402954 0) (0.19994 0.00412121 0) (0.199948 0.00420761 0) (0.199957 0.00428824 0) (0.199966 0.00436259 0) (0.199976 0.00443017 0) (0.199987 0.00449059 0) (0.199998 0.00454353 0) (0.200009 0.00458877 0) (0.200021 0.00462618 0) (0.200032 0.0046557 0) (0.200044 0.00467737 0) (0.200056 0.0046913 0) (0.200067 0.00469769 0) (0.200078 0.00469679 0) (0.200089 0.00468891 0) (0.200099 0.00467441 0) (0.200109 0.00465368 0) (0.200118 0.00462716 0) (0.200127 0.00459527 0) (0.200135 0.00455846 0) (0.200143 0.00451718 0) (0.20015 0.00447188 0) (0.200157 0.00442296 0) (0.200164 0.00437086 0) (0.200169 0.00431595 0) (0.200175 0.00425861 0) (0.20018 0.00419917 0) (0.200185 0.00413795 0) (0.200189 0.00407525 0) (0.200193 0.00401132 0) (0.200197 0.0039464 0) (0.2002 0.0038807 0) (0.200203 0.00381441 0) (0.200206 0.00374769 0) (0.200209 0.00368069 0) (0.200212 0.00361354 0) (0.200215 0.00354634 0) (0.200217 0.00347917 0) (0.200219 0.00341212 0) (0.200222 0.00334524 0) (0.200224 0.00327857 0) (0.200226 0.00321215 0) (0.200228 0.00314602 0) (0.20023 0.00308017 0) (0.200232 0.00301461 0) (0.200234 0.00294936 0) (0.200235 0.00288439 0) (0.200237 0.0028197 0) (0.200239 0.00275527 0) (0.200241 0.00269107 0) (0.200243 0.00262709 0) (0.200245 0.00256329 0) (0.200246 0.00249965 0) (0.200248 0.00243613 0) (0.20025 0.00237271 0) (0.200252 0.00230935 0) (0.200253 0.00224603 0) (0.200255 0.00218272 0) (0.200257 0.00211939 0) (0.200259 0.00205603 0) (0.20026 0.00199261 0) (0.200262 0.00192913 0) (0.200264 0.00186558 0) (0.200265 0.00180196 0) (0.200267 0.00173828 0) (0.200268 0.00167456 0) (0.200269 0.00161083 0) (0.200271 0.00154712 0) (0.200272 0.0014835 0) (0.200273 0.00142001 0) (0.200274 0.00135676 0) (0.200274 0.00129381 0) (0.200275 0.00123129 0) (0.200275 0.00116932 0) (0.200276 0.00110802 0) (0.200276 0.00104756 0) (0.200275 0.000988079 0) (0.200275 0.000929761 0) (0.200274 0.000872779 0) (0.200274 0.00081731 0) (0.200273 0.000763532 0) (0.200271 0.000711619 0) (0.20027 0.000661736 0) (0.200268 0.000614032 0) (0.200267 0.000568646 0) (0.200265 0.000525696 0) (0.200263 0.000485279 0) (0.200261 0.000447474 0) (0.200258 0.00041234 0) (0.200256 0.000379916 0) (0.200254 0.000350223 0) (0.200251 0.000323271 0) (0.200249 0.000299056 0) (0.200246 0.000277566 0) (0.200244 0.000258784 0) (0.200241 0.00024269 0) (0.200239 0.000229265 0) (0.200236 0.000218485 0) (0.200232 0.000210362 0) (0.199991 5.001e-06 0) (0.199962 1.19186e-05 0) (0.199912 2.06616e-05 0) (0.199844 3.11943e-05 0) (0.19976 4.35355e-05 0) (0.19966 5.77438e-05 0) (0.199544 7.39197e-05 0) (0.199411 9.22066e-05 0) (0.19926 0.000112796 0) (0.199092 0.00013594 0) (0.198904 0.000161962 0) (0.198694 0.000191288 0) (0.19846 0.000224476 0) (0.198199 0.000262272 0) (0.197905 0.000305694 0) (0.197573 0.000356164 0) (0.197195 0.000415734 0) (0.196757 0.000487495 0) (0.196241 0.000576346 0) (0.19562 0.000690638 0) (0.194842 0.000846049 0) (0.193817 0.00107631 0) (0.192335 0.00147032 0) (0.189853 0.00235763 0) (0.188998 0.00505321 0) (0.199991 1.07245e-05 0) (0.199962 2.32033e-05 0) (0.199913 3.752e-05 0) (0.199846 5.37158e-05 0) (0.199762 7.18994e-05 0) (0.199662 9.2233e-05 0) (0.199547 0.000114929 0) (0.199414 0.000140256 0) (0.199265 0.000168549 0) (0.199097 0.000200231 0) (0.19891 0.000235845 0) (0.198702 0.000276094 0) (0.19847 0.000321908 0) (0.19821 0.000374539 0) (0.19792 0.000435712 0) (0.197591 0.00050787 0) (0.197218 0.000594598 0) (0.196788 0.000701378 0) (0.196283 0.000837058 0) (0.19568 0.00101694 0) (0.194937 0.00126998 0) (0.193986 0.0016579 0) (0.19272 0.00233429 0) (0.191025 0.00377876 0) (0.190523 0.00753768 0) (0.199991 1.56222e-05 0) (0.199963 3.24722e-05 0) (0.199914 5.10237e-05 0) (0.199847 7.14635e-05 0) (0.199764 9.39929e-05 0) (0.199666 0.000118867 0) (0.199551 0.000146388 0) (0.199419 0.000176916 0) (0.199271 0.000210891 0) (0.199105 0.000248863 0) (0.198919 0.000291534 0) (0.198713 0.000339815 0) (0.198483 0.00039491 0) (0.198227 0.000458443 0) (0.19794 0.00053266 0) (0.197618 0.000620752 0) (0.197252 0.000727407 0) (0.196833 0.00085979 0) (0.196346 0.00102941 0) (0.195771 0.00125592 0) (0.195078 0.00157538 0) (0.194229 0.00205992 0) (0.193197 0.00286606 0) (0.192072 0.00434918 0) (0.191803 0.00722792 0) (0.199992 2.04699e-05 0) (0.199964 4.18279e-05 0) (0.199915 6.48222e-05 0) (0.199849 8.97748e-05 0) (0.199767 0.000116964 0) (0.199669 0.000146726 0) (0.199555 0.000179452 0) (0.199425 0.000215596 0) (0.199278 0.000255704 0) (0.199114 0.00030046 0) (0.198931 0.000350729 0) (0.198727 0.000407628 0) (0.1985 0.000472636 0) (0.198248 0.000547742 0) (0.197967 0.000635686 0) (0.197652 0.000740349 0) (0.197296 0.000867394 0) (0.196892 0.00102538 0) (0.196427 0.00122783 0) (0.195887 0.0014971 0) (0.195255 0.00187219 0) (0.194518 0.00242431 0) (0.193697 0.00328521 0) (0.192939 0.0046769 0) (0.192827 0.00683889 0) (0.199992 2.54169e-05 0) (0.199964 5.14904e-05 0) (0.199917 7.91245e-05 0) (0.199851 0.000108773 0) (0.19977 0.000140793 0) (0.199673 0.000175606 0) (0.199561 0.000213688 0) (0.199432 0.00025559 0) (0.199287 0.000301967 0) (0.199124 0.000353629 0) (0.198944 0.000411599 0) (0.198743 0.000477193 0) (0.19852 0.000552143 0) (0.198274 0.000638771 0) (0.197999 0.000740257 0) (0.197693 0.00086107 0) (0.19735 0.00100765 0) (0.196963 0.00118959 0) (0.196524 0.00142162 0) (0.196025 0.00172715 0) (0.19546 0.00214453 0) (0.194834 0.00273701 0) (0.194195 0.00360418 0) (0.193689 0.00487262 0) (0.193688 0.00658962 0) (0.199992 3.04525e-05 0) (0.199965 6.13737e-05 0) (0.199918 9.37642e-05 0) (0.199853 0.000128214 0) (0.199773 0.000165171 0) (0.199678 0.000205138 0) (0.199566 0.000248679 0) (0.19944 0.000296439 0) (0.199296 0.000349176 0) (0.199137 0.000407823 0) (0.198959 0.00047355 0) (0.198762 0.000547856 0) (0.198544 0.0006327 0) (0.198303 0.000730692 0) (0.198037 0.000845379 0) (0.197741 0.000981684 0) (0.197412 0.0011466 0) (0.197046 0.00135029 0) (0.196637 0.00160788 0) (0.196182 0.0019423 0) (0.195685 0.00238849 0) (0.195164 0.00299827 0) (0.194675 0.00384058 0) (0.194346 0.00497851 0) (0.19442 0.0063829 0) (0.199992 3.55744e-05 0) (0.199966 7.14613e-05 0) (0.199919 0.000108728 0) (0.199856 0.000148098 0) (0.199777 0.000190111 0) (0.199682 0.00023535 0) (0.199573 0.000284463 0) (0.199448 0.000338185 0) (0.199307 0.000397373 0) (0.19915 0.000463074 0) (0.198976 0.000536592 0) (0.198783 0.000619586 0) (0.198571 0.000714211 0) (0.198337 0.000823312 0) (0.19808 0.000950712 0) (0.197796 0.00110164 0) (0.197484 0.00128338 0) (0.19714 0.00150623 0) (0.196763 0.00178495 0) (0.196355 0.00214074 0) (0.195924 0.00260351 0) (0.195497 0.00321281 0) (0.195131 0.00401223 0) (0.194928 0.00502516 0) (0.195047 0.00619611 0) (0.199992 4.07819e-05 0) (0.199966 8.17444e-05 0) (0.199921 0.000124004 0) (0.199858 0.000168405 0) (0.19978 0.000215582 0) (0.199688 0.000266195 0) (0.19958 0.000320974 0) (0.199457 0.000380736 0) (0.19932 0.000446433 0) (0.199166 0.000519213 0) (0.198996 0.000600498 0) (0.198808 0.000692084 0) (0.198602 0.00079628 0) (0.198376 0.000916103 0) (0.198128 0.00105555 0) (0.197858 0.00122001 0) (0.197563 0.00141677 0) (0.197244 0.00165587 0) (0.1969 0.00195108 0) (0.196539 0.00232101 0) (0.196172 0.00278984 0) (0.195828 0.00338568 0) (0.195559 0.00413291 0) (0.195445 0.00503188 0) (0.195592 0.00602297 0) (0.199992 4.60718e-05 0) (0.199967 9.22093e-05 0) (0.199922 0.000139566 0) (0.199861 0.0001891 0) (0.199785 0.000241536 0) (0.199694 0.000297611 0) (0.199588 0.000358129 0) (0.199468 0.000423987 0) (0.199333 0.00049622 0) (0.199183 0.000576066 0) (0.199017 0.000665045 0) (0.198835 0.000765058 0) (0.198636 0.000878524 0) (0.198419 0.00100856 0) (0.198183 0.00115925 0) (0.197927 0.00133594 0) (0.197651 0.00154572 0) (0.197357 0.00179801 0) (0.197048 0.00210508 0) (0.196731 0.00248253 0) (0.196422 0.00294879 0) (0.19615 0.00352225 0) (0.195959 0.00421365 0) (0.195909 0.0050111 0) (0.196071 0.00585974 0) (0.199992 5.14383e-05 0) (0.199968 0.000102839 0) (0.199924 0.000155388 0) (0.199864 0.000210144 0) (0.199789 0.000267921 0) (0.1997 0.000329528 0) (0.199597 0.00039584 0) (0.19948 0.000467824 0) (0.199348 0.000546588 0) (0.199202 0.000633445 0) (0.199041 0.000729987 0) (0.198865 0.000838191 0) (0.198674 0.000960535 0) (0.198466 0.00110017 0) (0.198242 0.00126113 0) (0.198002 0.00144862 0) (0.197746 0.00166928 0) (0.197478 0.00193162 0) (0.197202 0.00224617 0) (0.196928 0.00262534 0) (0.196672 0.00308229 0) (0.196461 0.00362767 0) (0.19633 0.00426313 0) (0.196326 0.00497115 0) (0.196494 0.00570447 0) (0.199993 5.68734e-05 0) (0.199968 0.000113615 0) (0.199926 0.000171437 0) (0.199867 0.00023149 0) (0.199794 0.000294674 0) (0.199707 0.000361865 0) (0.199607 0.000434002 0) (0.199492 0.000512114 0) (0.199365 0.000597368 0) (0.199223 0.000691134 0) (0.199068 0.000795055 0) (0.198899 0.000911141 0) (0.198715 0.00104188 0) (0.198518 0.00119039 0) (0.198307 0.00136056 0) (0.198083 0.00155729 0) (0.197848 0.00178662 0) (0.197605 0.00205596 0) (0.197362 0.00237395 0) (0.197127 0.00274996 0) (0.196918 0.00319259 0) (0.196758 0.00370666 0) (0.196675 0.00428815 0) (0.196702 0.0049178 0) (0.196871 0.00555626 0) (0.199993 6.23668e-05 0) (0.199969 0.000124511 0) (0.199928 0.000187672 0) (0.199871 0.000253083 0) (0.1998 0.000321722 0) (0.199715 0.000394528 0) (0.199617 0.000472496 0) (0.199506 0.000556707 0) (0.199383 0.000648374 0) (0.199246 0.000748902 0) (0.199097 0.000859958 0) (0.198935 0.000983552 0) (0.19876 0.00112213 0) (0.198574 0.0012787 0) (0.198376 0.00145692 0) (0.198169 0.00166126 0) (0.197954 0.00189707 0) (0.197737 0.00217053 0) (0.197525 0.0024884 0) (0.197327 0.00285727 0) (0.197159 0.00328206 0) (0.19704 0.00376341 0) (0.196993 0.00429408 0) (0.197042 0.00485524 0) (0.197208 0.00541468 0) (0.199993 6.79058e-05 0) (0.19997 0.000135502 0) (0.19993 0.00020405 0) (0.199874 0.000274862 0) (0.199805 0.000348983 0) (0.199723 0.000427412 0) (0.199629 0.00051119 0) (0.199522 0.000601438 0) (0.199402 0.000699401 0) (0.199271 0.000806498 0) (0.199128 0.000924392 0) (0.198974 0.00105505 0) (0.198809 0.00120084 0) (0.198634 0.00136458 0) (0.19845 0.00154963 0) (0.198259 0.00175997 0) (0.198065 0.00200012 0) (0.197873 0.00227506 0) (0.197689 0.00258976 0) (0.197524 0.00294843 0) (0.197391 0.0033531 0) (0.197306 0.00380162 0) (0.197287 0.00428519 0) (0.197351 0.00478651 0) (0.197511 0.0052795 0) (0.199993 7.34751e-05 0) (0.199971 0.000146554 0) (0.199932 0.000220521 0) (0.199878 0.000296754 0) (0.199812 0.000376365 0) (0.199732 0.000460399 0) (0.199641 0.000549937 0) (0.199538 0.000646128 0) (0.199424 0.000750229 0) (0.199298 0.000863657 0) (0.199162 0.000988039 0) (0.199016 0.00112527 0) (0.19886 0.00127758 0) (0.198697 0.00144755 0) (0.198527 0.0016382 0) (0.198353 0.00185293 0) (0.198179 0.00209543 0) (0.19801 0.00236949 0) (0.197853 0.00267851 0) (0.197717 0.00302471 0) (0.197614 0.00340801 0) (0.197557 0.00382448 0) (0.197559 0.00426491 0) (0.197632 0.00471394 0) (0.197785 0.00515061 0) (0.199994 7.90571e-05 0) (0.199972 0.000157631 0) (0.199934 0.000237025 0) (0.199883 0.000318681 0) (0.199818 0.000403762 0) (0.199742 0.000493359 0) (0.199655 0.000588577 0) (0.199556 0.000690581 0) (0.199446 0.000800626 0) (0.199327 0.000920101 0) (0.199198 0.00105057 0) (0.19906 0.00119383 0) (0.198915 0.00135193 0) (0.198763 0.00152718 0) (0.198607 0.00172219 0) (0.19845 0.00193977 0) (0.198295 0.0021828 0) (0.198148 0.00245398 0) (0.198015 0.00275532 0) (0.197905 0.0030875 0) (0.197827 0.00344894 0) (0.197792 0.00383476 0) (0.197809 0.00423597 0) (0.197887 0.0046393 0) (0.198031 0.00502794 0) (0.199994 8.46317e-05 0) (0.199973 0.000168692 0) (0.199937 0.0002535 0) (0.199887 0.000340553 0) (0.199826 0.000431062 0) (0.199753 0.000526148 0) (0.199669 0.000626935 0) (0.199575 0.000734589 0) (0.199471 0.000850345 0) (0.199358 0.000975545 0) (0.199236 0.00111167 0) (0.199107 0.00126038 0) (0.198972 0.0014235 0) (0.198832 0.00160307 0) (0.19869 0.00180124 0) (0.198549 0.00202025 0) (0.198413 0.0022622 0) (0.198286 0.00252882 0) (0.198174 0.00282098 0) (0.198086 0.00313819 0) (0.198029 0.0034779 0) (0.198011 0.00383484 0) (0.19804 0.00420062 0) (0.198119 0.00456397 0) (0.198255 0.00491144 0) (0.199994 9.01763e-05 0) (0.199974 0.00017969 0) (0.19994 0.000269874 0) (0.199892 0.000362274 0) (0.199833 0.000458139 0) (0.199764 0.000558612 0) (0.199684 0.000664825 0) (0.199595 0.000777931 0) (0.199497 0.00089913 0) (0.19939 0.0010297 0) (0.199276 0.00117101 0) (0.199156 0.00132455 0) (0.199031 0.00149194 0) (0.198904 0.00167487 0) (0.198775 0.00187508 0) (0.19865 0.00209423 0) (0.19853 0.00233372 0) (0.198422 0.00259443 0) (0.19833 0.00287636 0) (0.19826 0.00317816 0) (0.19822 0.00349672 0) (0.198216 0.00382675 0) (0.198252 0.00416068 0) (0.198331 0.00448904 0) (0.198457 0.00480108 0) (0.199994 9.56658e-05 0) (0.199976 0.000190573 0) (0.199943 0.000286068 0) (0.199898 0.000383737 0) (0.199842 0.000484857 0) (0.199776 0.000590587 0) (0.1997 0.000702052 0) (0.199616 0.000820383 0) (0.199524 0.000946726 0) (0.199424 0.00108227 0) (0.199318 0.00122828 0) (0.199207 0.00138604 0) (0.199093 0.00155694 0) (0.198977 0.00174233 0) (0.198862 0.00194354 0) (0.198751 0.00216169 0) (0.198647 0.00239757 0) (0.198555 0.00265137 0) (0.19848 0.0029224 0) (0.198427 0.00320877 0) (0.1984 0.00350708 0) (0.198406 0.00381227 0) (0.198447 0.00411768 0) (0.198524 0.00441539 0) (0.198641 0.00469686 0) (0.199995 0.000101074 0) (0.199977 0.000201285 0) (0.199946 0.000301994 0) (0.199903 0.000404821 0) (0.19985 0.000511063 0) (0.199788 0.000621882 0) (0.199717 0.000738392 0) (0.199638 0.000861684 0) (0.199552 0.000992843 0) (0.19946 0.00113296 0) (0.199362 0.00128314 0) (0.19926 0.00144452 0) (0.199156 0.00161819 0) (0.199051 0.0018052 0) (0.198949 0.00200647 0) (0.198851 0.00222266 0) (0.198762 0.00245402 0) (0.198685 0.0027002 0) (0.198625 0.00296001 0) (0.198585 0.00323123 0) (0.19857 0.00351042 0) (0.198582 0.00379289 0) (0.198626 0.00407284 0) (0.1987 0.00434375 0) (0.198807 0.00459879 0) (0.199995 0.000106372 0) (0.199978 0.000211779 0) (0.199949 0.000317588 0) (0.199909 0.000425443 0) (0.19986 0.000536652 0) (0.199801 0.000652373 0) (0.199735 0.000773697 0) (0.199662 0.000901667 0) (0.199582 0.00103729 0) (0.199496 0.00118155 0) (0.199407 0.00133541 0) (0.199314 0.00149979 0) (0.19922 0.00167555 0) (0.199127 0.00186342 0) (0.199036 0.00206395 0) (0.198951 0.0022774 0) (0.198876 0.00250356 0) (0.198812 0.00274168 0) (0.198764 0.00299023 0) (0.198735 0.00324684 0) (0.198728 0.00350814 0) (0.198746 0.00376991 0) (0.19879 0.00402716 0) (0.198861 0.00427454 0) (0.198958 0.00450661 0) (0.199995 0.00011242 0) (0.19998 0.000223785 0) (0.199953 0.000335441 0) (0.199916 0.000449046 0) (0.199871 0.000565913 0) (0.199818 0.000687184 0) (0.199757 0.000813908 0) (0.199691 0.000947059 0) (0.199619 0.00108754 0) (0.199542 0.00123621 0) (0.199462 0.00139382 0) (0.19938 0.00156107 0) (0.199298 0.00173853 0) (0.199217 0.0019266 0) (0.19914 0.00212544 0) (0.19907 0.00233489 0) (0.199008 0.00255436 0) (0.198958 0.00278273 0) (0.198923 0.00301826 0) (0.198904 0.00325851 0) (0.198906 0.00350038 0) (0.198928 0.00374017 0) (0.198972 0.00397376 0) (0.199037 0.00419694 0) (0.199124 0.00440553 0) (0.199996 0.000119274 0) (0.199982 0.000237372 0) (0.199958 0.000355602 0) (0.199926 0.000475634 0) (0.199885 0.000598773 0) (0.199838 0.000726129 0) (0.199785 0.000858688 0) (0.199727 0.000997329 0) (0.199664 0.00114283 0) (0.199597 0.00129585 0) (0.199529 0.00145696 0) (0.199459 0.00162657 0) (0.19939 0.00180493 0) (0.199323 0.00199211 0) (0.19926 0.00218788 0) (0.199204 0.00239172 0) (0.199156 0.00260272 0) (0.19912 0.00281951 0) (0.199095 0.00304027 0) (0.199086 0.00326268 0) (0.199093 0.00348403 0) (0.199116 0.00370123 0) (0.199157 0.00391109 0) (0.199215 0.00411044 0) (0.199289 0.00429624 0) (0.199996 0.000126023 0) (0.199985 0.000250731 0) (0.199964 0.000375395 0) (0.199936 0.000501686 0) (0.199902 0.000630893 0) (0.199861 0.000764077 0) (0.199816 0.000902148 0) (0.199767 0.00104588 0) (0.199714 0.0011959 0) (0.199658 0.00135269 0) (0.199601 0.0015166 0) (0.199544 0.00168778 0) (0.199488 0.0018662 0) (0.199435 0.00205162 0) (0.199386 0.00224352 0) (0.199343 0.00244111 0) (0.199307 0.00264325 0) (0.199282 0.00284849 0) (0.199266 0.00305505 0) (0.199263 0.00326082 0) (0.199273 0.00346348 0) (0.199296 0.00366059 0) (0.199332 0.00384966 0) (0.199381 0.00402837 0) (0.199442 0.00419456 0) (0.199997 0.000132396 0) (0.199987 0.000263337 0) (0.199971 0.000394053 0) (0.199948 0.000526201 0) (0.19992 0.000661037 0) (0.199887 0.000799566 0) (0.199851 0.000942611 0) (0.199811 0.00109083 0) (0.199768 0.0012447 0) (0.199724 0.00140454 0) (0.199679 0.00157046 0) (0.199635 0.00174241 0) (0.199592 0.00192011 0) (0.199551 0.00210307 0) (0.199515 0.00229056 0) (0.199483 0.00248159 0) (0.199459 0.00267496 0) (0.199441 0.0028692 0) (0.199433 0.00306264 0) (0.199434 0.00325345 0) (0.199444 0.00343972 0) (0.199465 0.0036195 0) (0.199495 0.00379093 0) (0.199534 0.00395235 0) (0.199582 0.0041022 0) (0.199998 0.000138036 0) (0.199991 0.000274487 0) (0.199978 0.000410537 0) (0.199961 0.000547821 0) (0.19994 0.000687558 0) (0.199916 0.00083069 0) (0.199888 0.000977958 0) (0.199859 0.00112991 0) (0.199828 0.00128688 0) (0.199796 0.00144904 0) (0.199763 0.00161632 0) (0.199731 0.00178847 0) (0.1997 0.00196503 0) (0.199672 0.00214534 0) (0.199646 0.0023285 0) (0.199625 0.00251347 0) (0.199609 0.00269897 0) (0.199598 0.00288363 0) (0.199594 0.00306591 0) (0.199596 0.00324426 0) (0.199606 0.00341708 0) (0.199622 0.00358285 0) (0.199645 0.00374019 0) (0.199674 0.00388787 0) (0.199709 0.00402481 0) (0.199999 0.000142465 0) (0.199994 0.000283247 0) (0.199986 0.000423483 0) (0.199975 0.000564777 0) (0.199962 0.000708308 0) (0.199947 0.000854962 0) (0.19993 0.0010054 0) (0.199911 0.00116009 0) (0.199892 0.00131925 0) (0.199872 0.00148292 0) (0.199852 0.0016509 0) (0.199832 0.00182281 0) (0.199814 0.00199805 0) (0.199797 0.00217585 0) (0.199782 0.00235524 0) (0.199769 0.00253513 0) (0.19976 0.00271427 0) (0.199754 0.00289136 0) (0.199752 0.00306501 0) (0.199754 0.00323388 0) (0.19976 0.00339664 0) (0.19977 0.00355207 0) (0.199784 0.00369909 0) (0.199802 0.00383682 0) (0.199823 0.00396444 0) (0.199999 0.000145047 0) (0.199998 0.000288377 0) (0.199995 0.000431104 0) (0.199991 0.000574809 0) (0.199987 0.000720642 0) (0.199981 0.000869455 0) (0.199975 0.00102187 0) (0.199968 0.00117828 0) (0.199961 0.00133886 0) (0.199954 0.00150356 0) (0.199946 0.00167211 0) (0.199939 0.00184404 0) (0.199932 0.00201868 0) (0.199925 0.0021952 0) (0.199919 0.00237258 0) (0.199914 0.00254971 0) (0.19991 0.00272537 0) (0.199907 0.00289828 0) (0.199906 0.00306715 0) (0.199906 0.00323074 0) (0.199907 0.00338787 0) (0.19991 0.00353748 0) (0.199914 0.00367866 0) (0.199919 0.00381066 0) (0.199926 0.00393285 0) ) ; boundaryField { top { type zeroGradient; } inlet { type fixedValue; value uniform (0.2 0 0); } outlet { type zeroGradient; } plate { type fixedValue; value uniform (0 0 0); } symmBound { type zeroGradient; } frontAndBack { type empty; } } // ************************************************************************* //
[ "cagri.metin.ege@gmail.com" ]
cagri.metin.ege@gmail.com
81975c29376b7ce1744a24c4eedc9477040c54fd
18b24c656a1033604b8b6020aa140f18f9c8cb7d
/backend/tests/test-bit-get-set.cpp
18dda82fbc00e023005d23061f3aa30a963a09df
[ "MIT" ]
permissive
alan-turing-institute/SHEEP
23a159036503008ed187180d2c6dca55e16e7013
7762d834be184db328bbf17ac352f8e9c50dca8d
refs/heads/master
2023-04-14T16:06:54.150042
2023-04-07T17:43:59
2023-04-07T17:43:59
113,025,590
43
12
MIT
2023-04-07T17:44:00
2017-12-04T09:58:03
C++
UTF-8
C++
false
false
596
cpp
#include <cassert> #include <cstdint> #include <iostream> #include "bits.hpp" int main(void) { uint8_t a(0); int8_t b(0); for (int i = 0; i < 8; i++) { assert(bit(i, a) == 0); assert(bit(i, b) == 0); } set_bit(7, a, 1); assert(bit(7, a) == 1); assert(a == 128); // int8_t, if it is supported, is required to represent // negative numbers using two's complement set_bit(7, b, 1); assert(b == -128); for (int i = 0; i < 8; i++) { set_bit(i, a, 1); set_bit(i, b, 1); } assert(a == 255); assert(b == -1); set_bit(7, b, 0); assert(b == 127); }
[ "nbarlow@turing.ac.uk" ]
nbarlow@turing.ac.uk
fb364d9a2e3b7706de2828a195878be1c7c7b8d7
014999ff6313002f16f4880e15e3b8324b2111f5
/vc/simpletao/util/SocketLib/SocketLibErrors.h
f91794f2bb4a96f4336e49d813ea83e3d57a9dd9
[ "Apache-2.0" ]
permissive
walterfan/snippets
b00c574c4593a6b3dd453419f8b1e501816ac3db
fcfc81903e8775a64add4da509a66f4172155129
refs/heads/master
2023-04-30T04:34:39.515127
2023-02-17T01:45:02
2023-02-17T01:45:02
37,811,920
1
0
Apache-2.0
2023-04-18T22:41:57
2015-06-21T14:30:40
HTML
UTF-8
C++
false
false
4,045
h
// MUD Programming // Ron Penton // (C)2003 // SocketLibErrors.h - This file contains all error-related functions and // definitions. #ifndef SOCKETLIBERRORS_H #define SOCKETLIBERRORS_H // ======================================================================== // Include Files // ======================================================================== #include "SocketLibTypes.h" #include <exception> #include <string> namespace SocketLib { // ======================================================================== // Description: Error codes for the socket library. // ======================================================================== enum Error { // errors that shouldn't happen, so if they do, something is wrong: ESeriousError, // these errors are common ENetworkDown, ENoSocketsAvailable, ENoMemory, EAddressNotAvailable, EAlreadyConnected, ENotConnected, EConnectionRefused, ENetworkUnreachable, ENetworkReset, EHostUnreachable, EHostDown, EConnectionAborted, EConnectionReset, EOperationWouldBlock, // DNS errors EDNSNotFound, EDNSError, ENoDNSData, // These errors are specific errors that should never or rarely occur. EInProgress, EInterrupted, EAccessDenied, EInvalidParameter, EAddressFamilyNotSupported, EProtocolFamilyNotSupported, EProtocolNotSupported, EProtocolNotSupportedBySocket, EOperationNotSupported, EInvalidSocketType, EInvalidSocket, EAddressRequired, EMessageTooLong, EBadProtocolOption, EAddressInUse, ETimedOut, EShutDown, // auxilliary socketlib errors ESocketLimitReached, ENotAvailable, EConnectionClosed }; // ======================================================================== // Description: This translates error codes from the native platoform // format into the SocketLib format // ======================================================================== Error TranslateError( int p_error, bool p_errno ); // ======================================================================== // Description: This function acts as a simple wrapper for retrieving // socket library errors from errno or h_errno. // ======================================================================== Error GetError( bool p_errno = true ); // ======================================================================== // Type: Exception // Purpose: A generic socket exception class that holds an error, and // an optional text string describing the error in more detail // ======================================================================== class Exception : public std::exception { public: // ==================================================================== // Function: Exception // Purpose: To initialize the socket exception with a specific // error code. // ==================================================================== Exception( Error p_code ); // ==================================================================== // Function: Error // Purpose: To retrieve the error code of the socket. // ==================================================================== Error ErrorCode(); // ==================================================================== // Function: PrintError // Purpose: Print the error message to a string // ==================================================================== std::string PrintError(); protected: Error m_code; }; } // end namespace SocketLib #endif
[ "walter.fan@gmail.com" ]
walter.fan@gmail.com
6e9e5a16243e0b2298961abe109390fc2a700e99
772074adf1a56742ec3dbbb3e01e61e1d8c475c7
/week10/example.cpp
df19c25815cedeabf572b96409e4ca6dffaf6d93
[]
no_license
GeorgiMinkov/UP_IS_2019_2020_gr_3
f1c3bbfd5f930cb50c03f79e0d08a6cf6ecb4e0a
d0ebbeac68c1a84081b46abe76ccd9e1b6c094bc
refs/heads/master
2020-08-05T13:24:35.202880
2020-01-16T13:49:04
2020-01-16T13:49:04
212,561,519
1
2
null
null
null
null
UTF-8
C++
false
false
1,682
cpp
#include <iostream> #include <cmath> int fib(int n); int sumOfDigits(int n); int recStrlen(const char*); int reverseHelper(int n, int& count) { if (n < 10) { ++count; return n; } //std::cout << n % 10; return (n % 10) * (int)pow(10,count) + reverseHelper(n / 10, ++count); } int reverse(int n) { int count = 0; return reverseHelper(n, count); } int counterNumber(int num) { return num < 10 ? 1 : 1 + counterNumber(num / 10); } int reverSimple(int num) { if (num < 10) { return num; } return (num % 10) * pow(10, counterNumber(num) - 1) + reverSimple(num / 10); } bool isEqual(const char* str1, const char* str2) { if (*str1 == '\0' && *str2 != '\0' || *str1 != '\0' && *str2 == '\0') { return false; } if (*str1 == '\0' && *str2 == '\0') { return true; } /* if (*str1 != *str2) { return false; }*/ //return true && isEqual(str1 + 1, str2 + 1); // ++str1, ++str2 return *str1 == *str2 && isEqual(str1 + 1, str2 + 1); // ++str1, ++str2 } int main() { int n = 50; //std::cout << fib(n); //std::cout << sumOfDigits(145); char str[] = "asd"; //std::cout << recStrlen(str); //std::cout << reverse(156); //std::cout << reverSimple(156); std::cout << std::boolalpha << isEqual("", ""); } // abc\0 // 1 + rec( bc\0) // 1 + rec( c\0) // 1 + rec( \0)== 0 // 1 + 1 // 1 + 2 // 3 int recStrlen(const char* str) { if( *str == '\0') { return 0; } return 1 + recStrlen(++str); } int sumOfDigits(int n) { if (n < 10) { return n; } return n % 10 + sumOfDigits(n / 10); } // 145 // 5 + sum( 14) // 4 + sum( 1) // 4 + 1 //5 + 4 + 1 int fib(int n) { if (n == 1 || n == 2) { return 1; } return fib(n - 1) + fib(n - 2); }
[ "noreply@github.com" ]
noreply@github.com
c2bc0ef9a709c342beb62266a991f225c4d88a26
96bc11cf05bbeead6ca50dee0076d683dd3dca4b
/struct/01.cpp
e2f2e804b3263ddcbf034e2a605f0089366b0bd1
[]
no_license
nicholasinatel/iot-c--revisao
6ea3a77479605a121d259832c6766c6943b7da7d
0c425ff30a1d1a4a08c7cb01581da52c5a91801c
refs/heads/master
2020-05-04T22:24:20.502497
2019-04-07T14:41:06
2019-04-07T14:41:06
179,511,245
0
0
null
null
null
null
UTF-8
C++
false
false
674
cpp
#include <iostream> #include <cmath> #include <iomanip> using namespace std; struct dados { int idade; float peso; }; int main() { dados atleta[100]; int num; cin >> num; for(int i = 0; i < num; i++){ cin >> atleta[i].idade; cin >> atleta[i].peso; } //atleta.idade = 28; //atleta.peso = 75.4; //cin >> atleta[1].idade; //cin >> atleta[1].peso; for(int i = 0; i < num; i++){ cout << "Idade: " << atleta[i].idade << endl; cout << "Peso: " << atleta[i].peso << endl; } //cout << "Idade: " << atleta[1].idade << endl; //cout << "Peso: " << atleta[1].peso << endl; return 0; }
[ "niku01@gmail.com" ]
niku01@gmail.com
e94659943a3b217f458fb602f4fc1c105a236b9b
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function13721/function13721_schedule_10/function13721_schedule_10_wrapper.cpp
942074388c33d1c4e6e3d575f293e53c43b8c3ad
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
1,558
cpp
#include "Halide.h" #include "function13721_schedule_10_wrapper.h" #include "tiramisu/utils.h" #include <cstdlib> #include <iostream> #include <time.h> #include <fstream> #include <chrono> #define MAX_RAND 200 int main(int, char **){ Halide::Buffer<int32_t> buf00(128, 512); Halide::Buffer<int32_t> buf01(128); Halide::Buffer<int32_t> buf02(1024, 512); Halide::Buffer<int32_t> buf03(1024, 128); Halide::Buffer<int32_t> buf04(128); Halide::Buffer<int32_t> buf05(1024, 128); Halide::Buffer<int32_t> buf06(1024, 128); Halide::Buffer<int32_t> buf07(128, 512); Halide::Buffer<int32_t> buf08(128, 512); Halide::Buffer<int32_t> buf09(1024); Halide::Buffer<int32_t> buf0(1024, 128, 512); init_buffer(buf0, (int32_t)0); auto t1 = std::chrono::high_resolution_clock::now(); function13721_schedule_10(buf00.raw_buffer(), buf01.raw_buffer(), buf02.raw_buffer(), buf03.raw_buffer(), buf04.raw_buffer(), buf05.raw_buffer(), buf06.raw_buffer(), buf07.raw_buffer(), buf08.raw_buffer(), buf09.raw_buffer(), buf0.raw_buffer()); auto t2 = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = t2 - t1; std::ofstream exec_times_file; exec_times_file.open("../data/programs/function13721/function13721_schedule_10/exec_times.txt", std::ios_base::app); if (exec_times_file.is_open()){ exec_times_file << diff.count() * 1000000 << "us" <<std::endl; exec_times_file.close(); } return 0; }
[ "ei_mekki@esi.dz" ]
ei_mekki@esi.dz
5df9c49af918fc4f5ce6be0cd3164dcb97d27310
5de6a61d23c5e9277d6fb0f9d93709c785a9942c
/include/mad/itkMultigridGaussSeidelSmoother.h
85986b7df523c6c8cb3bdf0a46faf7e3bacec7b5
[ "Apache-2.0" ]
permissive
nellogrb/MultigridAnisotropicDiffusion
90e34ccd6ee32c911f8dffc7a81bfab6d473ae0c
9f476c24bd296d801884c6786374adc63f03cabd
refs/heads/master
2020-05-17T10:33:12.669818
2014-11-16T11:03:55
2014-11-16T11:03:55
23,495,206
1
0
null
null
null
null
UTF-8
C++
false
false
4,067
h
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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 __itkMultigridGaussSeidelSmoother_h #define __itkMultigridGaussSeidelSmoother_h #include "itkMultigridSmoother.h" #include "itkStencilImage.h" namespace itk { namespace mad { /** \class MultigridGaussSeidelSmoother * * \brief Gauss Seidel smoother implementation; it is a derived * class of MultigridSmoother. It internally uses a lexicographic * ordering of the points. * * \author Antonello Gerbi * * \ingroup ITKMultigridAnisotropicDiffusion */ template < unsigned int VDimension > class MultigridGaussSeidelSmoother : public MultigridSmoother< VDimension > { public: /** Standard class typedefs. */ typedef double Precision; typedef MultigridGaussSeidelSmoother Self; typedef Image< Precision, VDimension > ImageType; typedef Neighborhood< Precision, VDimension > StencilType; typedef StencilImage< Precision, VDimension > StencilImageType; typedef ImageRegion< VDimension > ImageRegionType; typedef typename ImageType::SpacingType SpacingType; typedef typename ImageType::SizeType SizeType; typedef typename ImageType::IndexType IndexType; typedef typename ImageType::OffsetType OffsetType; typedef typename std::list< OffsetType > OffsetListType; /** Returns the approximated solution to problem \f$ A x = b\f$ after one iteration of the smoother, * starting with inputImage as initial guess, rhsImage as the right hand side \f$ b \f$, and * matrixImage as matrix \f$ A \f$ in StencilImageType format. */ typename ImageType::Pointer SingleIteration( const ImageType * inputImage, const ImageType * rhsImage, const StencilImageType * matrixImage ) const; /** Returns the residual \f$ r = b - A x \f$, where inputImage is the term \f$ x \f$, rhsImage is * \f$ b \f$, and matrixImage the matrix \f$ A \f$. */ typename ImageType::Pointer ComputeResidual( const ImageType * inputImage, const ImageType * rhsImage, const StencilImageType * matrixImage ) const; /** Class constructor */ MultigridGaussSeidelSmoother(); /** Class destructor. */ ~MultigridGaussSeidelSmoother(); private: /** Utility function which returns whether, in lexicographic ordering, offset * left comes before or after offset right. */ inline bool LexOrder( const OffsetType left, const OffsetType right ) const { for ( int i = VDimension - 1; i >= 0; --i ) { if ( left[ i ] < right[ i ] ) return true; else if ( left[ i ] > right[ i ] ) return false; } return false; } /** Purposely not implemented */ MultigridGaussSeidelSmoother( const Self & ); Self & operator= ( const Self & ); }; } // end namespace mad } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkMultigridGaussSeidelSmoother.hxx" #endif #endif /* __itkMultigridGaussSeidelSmoother_h */
[ "antonello.gerbi@gmail.com" ]
antonello.gerbi@gmail.com
16ab04eaf648e60a161d8c56702a4a2d749cf92d
505cb2c5b9b8203e86653f7c84650ca8873e95fc
/maim.cpp
1a92c8764ff75c86127d12366f81923903e1ce3b
[]
no_license
KozhevnikovIvan/lab-3-16.10.17
d6c0e252e53c610979572b90e8ee570b00a619a8
8a620aef5947c175e2a245c80ad84a808b7f5cf0
refs/heads/master
2021-07-11T06:32:32.177639
2017-10-16T11:38:56
2017-10-16T11:38:56
107,119,363
1
0
null
null
null
null
UTF-8
C++
false
false
299
cpp
#include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { string str1 = argv[1]; char symbhol = argv [2][0]; char symbhol2 = argv [3][0]; for (int i=0; i< str1.length(); i++) { if (str1[i]==symbhol) str1[i] = symbhol2; } cout << str1 << endl; }
[ "noreply@github.com" ]
noreply@github.com
526205ec928ab7a20dc562d38be20df1feaa398c
8ec1987551283f3851c507d8b87c37cd073a9e92
/Super/src/Super/Basic/MyCLib.cpp
a36abb91102a1722e692c09bebd3a2faeb568cb0
[]
no_license
Edlward/public
5bab05e745b62087dc60b0979ce71be853f98b73
370bf770d92c1f7b4970b2aa3fb18408e567d275
refs/heads/master
2022-11-17T12:14:55.414823
2020-07-17T19:03:24
2020-07-17T19:03:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
24,264
cpp
#include "MyCLib.h" #include<assert.h> #include<stdlib.h> //#include<iostream> #include <stdio.h> #include <ctype.h> #include <limits.h> #include <math.h> #include "../Basic/SuperTime.h" USING_NAME_SPACE_MAIN //实现1 void* MyMemcpyV1(void *pDst,const void *pSrc,size_t len) { assert((pDst!=NULL)&&(pSrc!=NULL)); //普通断言 //assert(pDst>=pSrc+num||pSrc>pDst+num); //考虑内存重叠的断言 const char *pS =(const char*)(pSrc); char *pD = (char*)(pDst); while(len-->0) { *pD++ = *pS++; } return pDst; } //缺点:没有考虑内存重叠的情况,可以加一个断言换为:assert(des>=src+num||src>dst+num); //实现2:考虑重叠,有重叠情况也复制 void * MyMemcpyV2(void *pDst, const void *pSrc, size_t len) { assert((pDst!=NULL)&&(pSrc!=NULL)); const char *pS =(const char*)(pSrc); char *pD = (char*)(pDst); size_t n = len; if (pD > pS && pD < pS+len) //有内存重叠,从高地址开始复制 { for (size_t i=n-1; i != -1; --i) { pD[i] = pS[i]; } } else { for (size_t i= 0; i < n; i++) { pD[i] = pS[i]; } } return pDst; } //改进循环计数方式 void* MyMemcpy_FastV1(void *pDst,const void *pSrc,size_t len) { assert((pDst!=NULL)&&(pSrc!=NULL)); //添加考虑内存重叠 typedef size_t wordType; const wordType* pS = (const wordType*)pSrc; wordType* pD = (wordType *)pDst; size_t LoopNum = len/sizeof(wordType); for (size_t n=0;n<LoopNum;n++) { *pD++ = *pS++; } LoopNum*=sizeof(wordType); for (size_t n=LoopNum;n<len;n++) { *((char *)pD++) =*((char *)pS++); } return pDst; } // ////结论:比逐字节拷贝快,但是比系统函数慢 //void* MyMemcpy_Fast(void *pDst,const void *pSrc,size_t len) //{ // //assert((pDst!=NULL)&&(pSrc!=NULL)); //添加考虑内存重叠 // typedef int64_t wordType; //typedef lnt64 AlignType; //控制每次拷贝的字长 int64_t比int位快10倍 // wordType * pS = (wordType *)pSrc; // wordType* pD = (wordType *)pDst; // // #define ParallelN (1) //while循环里的并行组数 一般1-4;//经测1最快 // unsigned int wordnum = len/(sizeof(wordType)*ParallelN); // unsigned int slice = len%(sizeof(wordType)*ParallelN); //剩余的按字节拷贝 // while (wordnum) // { // //pD[0] = pS[0]; // //pD[1] = pS[1]; // //pD[2] = pS[2]; // //pD[3] = pS[3]; // //pD+=4; // //pS+=4; // // *pD++ = *pS++; //#if ParallelN>1 // *pD++ = *pS++; //#endif // //#if ParallelN>2 // *pD++ = *pS++; //#endif // //#if ParallelN>3 // *pD++ = *pS++; //#endif // wordnum--; // } // // while (slice--) // { // *((char *)pD++) =*((char *)pS++); // } // return pDst; //} //具体参见 达夫设备(Duff's Device) void* memcpy_duff( char* to,const char* from,size_t count ) { size_t n = (count+7)/8; switch( count%8 ) { case 0: do{ *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++; }while(--n>0); } return to; } //当count==0时,还会至少do一次,实际上是错误的操作。 // void* MyMemsetV1(void *pSrc,int c,size_t len) { const char uc = c; char *su; for(su = (char*)pSrc;0 < len;++su,--len) { *su = uc; } return pSrc; } void* MyMemsetV2(void *pSrc, int c, size_t len) { assert(pSrc!=NULL); char *tmpsrc=(char*)pSrc; const char uc = c; while(len--) { *tmpsrc++ =uc; } return pSrc; } //结论:比逐字节拷贝快,但是比系统函数慢 void* MyMemset_FastV1(void *pSrc,int c,size_t len) { typedef int64_t wordType; //控制每次拷贝的字长 int64_t比int位快1倍 wordType Value; //把char 型字符拼接成wordType,然后可以直接赋值 char* p=(char*)&Value; char uc=c; for (int i=0;i<sizeof(wordType)/sizeof(uc);i++) { *p++=uc; } unsigned int wordnum = len/(sizeof(wordType)); // unsigned int slice = len%(sizeof(wordType)); //剩余的按字节拷贝 wordType * ptmpsrc = (wordType *)pSrc; while (wordnum--) { *ptmpsrc++=Value; } while (slice--) { *((char *)ptmpsrc++)=c; } return pSrc; } //结论:比逐字节拷贝快,但是比系统函数慢 void* MyMemset_FastV2(void *pDst,int c,size_t len) { typedef int64_t wordType; //控制每次拷贝的字长 int64_t比int位快1倍 wordType Value; //把char 型字符拼接成wordType,然后可以直接赋值 char* p=(char*)&Value; char uc=c; for (int i=0;i<sizeof(wordType)/sizeof(uc);i++) { *p++=uc; } char *pBegin; //走到内存地址对齐的位置---待续 for (pBegin =(char*)pDst; ((wordType) pBegin & (sizeof(wordType) - 1)) != 0;++pBegin) { *pBegin=uc; len--; //len<0 考虑 待续 } wordType * ptmpsrc = (wordType *)pBegin; size_t LoopNum = len/sizeof(wordType); for (size_t n=0;n<LoopNum;n++) { *ptmpsrc++ =Value; } LoopNum*=sizeof(wordType); for (size_t n=LoopNum;n<len;n++) { *((char *)ptmpsrc++)=uc; } return pDst; } //glibc2.7 //考虑到效率的因素: //1、len < 8 的时候,按每次一个字节来读写。 //2、len >= 8 的时候,32位机器按每次 4 个字节来读写,64位机器按每次 8 个字节来读写, //连续做 8 次。剩下的接着按 每次 4 或 8 字节读写, 每次 1 字节读写。 //1:先把将要赋值的块的起始地址对齐。见1号while。 //2:有大于等于8个OPSIZ长度未写,一次循环写8个OPSIZ长。 见2号while。 //3:还有小于8个OPSIZ长度未写,一次循环写1个OPSIZ长。 见3号while。 //4:还有小于OPSIZ长度未写,一次循环写1个字节。 见4号while。 void * MyMemset_Fast2(void *dstpp, int c, size_t len) { #define op_t unsigned long int #define OPSIZ (sizeof(op_t)) typedef unsigned char byte; long int dstp = (long int) dstpp; if (len >= 8) { size_t xlen; op_t cccc; cccc = (unsigned char) c; cccc |= cccc << 8; cccc |= cccc << 16; if (OPSIZ > 4) /* Do the shift in two steps to avoid warning if long has 32 bits. */ cccc |= (cccc << 16) << 16; /* There are at least some bytes to set. No need to test for LEN == 0 in this alignment loop. */ while (dstp % OPSIZ != 0) { ((byte *) dstp)[0] = c; dstp += 1; len -= 1; } /* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */ xlen = len / (OPSIZ * 8); while (xlen > 0) { ((op_t *) dstp)[0] = cccc; ((op_t *) dstp)[1] = cccc; ((op_t *) dstp)[2] = cccc; ((op_t *) dstp)[3] = cccc; ((op_t *) dstp)[4] = cccc; ((op_t *) dstp)[5] = cccc; ((op_t *) dstp)[6] = cccc; ((op_t *) dstp)[7] = cccc; dstp += 8 * OPSIZ; xlen -= 1; } len %= OPSIZ * 8; /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */ xlen = len / OPSIZ; while (xlen > 0) { ((op_t *) dstp)[0] = cccc; dstp += OPSIZ; xlen -= 1; } len %= OPSIZ; } /* Write the last few bytes. */ while (len > 0) { ((byte *) dstp)[0] = c; dstp += 1; len -= 1; } return dstpp; } void strcpy1(char * str1,char * str2) { for(;*str1;*str2++=*str1++) ; *str2='\0'; } void MyStrcpy2(char * dest, char * src) { while ('\0' != (*src)) { //后置++优先级高于*,而后置++是先赋值再加1, //因此先赋值的是src原来的字符(*src),一次赋值结束后 //src+1, dest+1 *dest++ = *src++; } //循环跳出来时*src=='\0',将'\0'赋给*dest *dest = *src; return; } //不足:*src要分成两种情况('\0' != *src 和 '\0' == *src)去讨论。 //改进:优化while循环内部的语句作为循环条件。 //不足:假如把dest与src的顺序写反了,程序只会在运行中报错。 //改进:保证src这个源字符串内容不可修改(添加const),这样当写反dest和src时,会在编译时报错。 //不足:上述代码不能作为参数传入函数内部。 //改进:修改函数返回类型为char *,以实现链式访问。 char * MyStrcpy3(char * dest, const char * src) { char * cp = dest; assert((NULL != src) && (NULL != cp)); while (*cp++ = *src++) { ; } return dest; } //字符串的比较:比较两个字符串,若str1<str2,返回-1,若str1>str2,返回1,若str1=str2,返回0 //规则:从两个字符串第一个位置开始比较对应位置上的字符的ASCII码值,直到分出大小 //或者达到某个字符串的结尾,先到达结尾的字符串小。) int MyStrcmp(const char * str1,const char * str2) { int ret; if(str1==NULL || str2==NULL) return 0; //转化为unsigned char 是为了防止溢出 //例如(char)0x7f-(char)0x80=255, (unsigned char)0x7f-(unsigned char)0x80=-1 ret=0; while( ! (ret = *(unsigned char *)str1- *(unsigned char *)str2) && * str1 ) { str1++;//++str1; str2++;//++str2; } if( ret<0) ret=-1; else if(ret>0) ret=1; return ret; } //字符串的连接:将str2连接到str1后面 void MyStrcat(char *str1,char *str2) { for(;*str1;str1++) ; for(;*str2;*str1++=*str2++) ; *str1='\0'; } char* MyStrcat2(char * dest, const char * src) { char * cp = dest; assert((NULL != src) && (NULL != cp)); while ('\0' != *cp) { cp++; } while (*cp++ = *src++) { ; } return dest; } //求字符串长度(不包括'\0') //unsigned int strlen(char *str) //{ // int n=0; // for(;*str;str++) // { // n++; // } // return n; //} int MyStrlen(const char * str) { int len = 0; assert(NULL != str); while ('\0' != *str) { len++; str++; } return len; } int MyStrlen2(const char * start) { const char * end = start; assert(NULL != start); while ('\0' != *end) { end++; } return (end - start); } //递归实现1 int MyStrlen3(const char * str) { assert(NULL != str); if ('\0' == *str) { return 0; } else { return (1 + MyStrlen(str+1)); } } //递归实现2 int MyStrlen4(const char * str) { return assert(NULL != str), '\0' == *str ? 0 : 1 + MyStrlen(str + 1); } //glibc -- strlen源码 具体原理参见网上博文 typedef unsigned long ulong; size_t strlen_glibc(const char * str) { const char * char_ptr; const ulong * longword_ptr; register ulong longword, magic_bits; //数据对齐(data alignment),是指所在的内存地址必须是该数据长度的整数倍,CPU的存取速度就会最快。 //在32位计算机中,一个int型的数据为4个字节,则int型数据的起始地址能被4整除的时候CPU的存取效率比较高。 //CPU的优化规则如下:对于n字节(n = 2, 4, 8...)的元素,它的首地址能被n整除才能获得最好的性能。 //sizeof(ulong) - 1=3 =0x00000003,低2位为1 for (char_ptr = str; ((ulong) char_ptr & (sizeof(ulong) - 1)) != 0; ++char_ptr) { if (*char_ptr == '\0') //在对齐之前就遇到"\0"则可以直接return char_ptr - str; return char_ptr - str; } longword_ptr = (ulong*) char_ptr; magic_bits = 0x7efefeffL; while (1) { longword = *longword_ptr++; if ((((longword + magic_bits) ^ ~longword) & ~magic_bits) != 0) //主要判断word的4个bit中任意一个字节为0 { const char *cp = (const char*) (longword_ptr - 1 ); if (cp[0] == 0) return cp - str; if (cp[1] == 0) return cp - str + 1; if (cp[2] == 0) return cp - str + 2; if (cp[3] == 0) return cp - str + 3; } } } /* //0x7efefeffL=01111110-11111110-11111110-11111111 //为0位置被称为holes位,它们都有一个特征,就是在每个字节的左边,这有什么用呢? 很明显,当右边有进位时, //会修改到这个0,或者这几个0的位置与另外一个数相运算时会被改变。 //~magic_bits的二进制形式为: 10000001-00000001-00000001-00000000,为1的位置正是相应holes的位置, //那么可以得出(((longword + magic_bits) ^ ~longword) & ~magic_bits) != 0的作用是在判断 //((longword + magic_bits) ^ ~longword)中的相应holes为是0还是1,由最后的!=0得知当 //((longword + magic_bits) ^ ~longword)中相应holes位置一个或多个为1时,进入if判断语句块。 //那么现在的问题是((longword + magic_bits) ^ ~longword)是什么意思呢? //我们假设result = longword + magic_bits, 那么result中相应holes位置的值就会根据longword的实际值而设置: //如果longword中某个字节是0,那么与magic_bits对应字节相加就不会产生进位,那么result中相应 //holes位置就不会设置为0; 当longword中某个字节是非零时,结果恰恰相反-- 与magic_bits对应字 //节相加会产生进位,则result中相应holes位置就会设置为1。 //最后一个问题是:result ^ ~longword是什么意思呢? //我们假设a = result ^ ~longword。 //我们举个具体的例子吧,如下(注意:longword中的各个字节的最高位不可能为1,因为ascii码范围是[0-127]) //可以看出a中为1的位的意义就是result相对longword中的未改变的位。就是说result的某一位与 //longword中的相同位相同时,那么在a中的相对位就为1。 //那么if ((a & b) != 0)什么意思呢?检测a中的holes位是1还是0. //现在终于知道只要longword中有一个或几个为0的字节,就可以进入if判断语句块中,这正是strlen所做的 //-- strlen就是为了找到结束符,然后返回长度 ^_^。 */ //glibc2。27的实现 考虑64位系统 size_t strlen_glibc64(const char *str) { const char *char_ptr; const unsigned long int *longword_ptr; unsigned long int longword, himagic, lomagic; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = str; ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0; ++char_ptr) if (*char_ptr == '\0') return char_ptr - str; /* All these elucidatory comments refer to 4-byte longwords, but the theory applies equally well to 8-byte longwords. */ longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ himagic = 0x80808080L; lomagic = 0x01010101L; if (sizeof (longword) > 4) { /* 64-bit version of the magic. */ /* Do the shift in two steps to avoid a warning if long has 32 bits. */ himagic = ((himagic << 16) << 16) | himagic; lomagic = ((lomagic << 16) << 16) | lomagic; } if (sizeof (longword) > 8) abort (); /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ for (;;) { longword = *longword_ptr++; if (((longword - lomagic) & ~longword & himagic) != 0) { /* Which of the bytes was the zero? If none of them were, it was a misfire; continue the search. */ const char *cp = (const char *) (longword_ptr - 1); if (cp[0] == 0) return cp - str; if (cp[1] == 0) return cp - str + 1; if (cp[2] == 0) return cp - str + 2; if (cp[3] == 0) return cp - str + 3; if (sizeof (longword) > 4) { if (cp[4] == 0) return cp - str + 4; if (cp[5] == 0) return cp - str + 5; if (cp[6] == 0) return cp - str + 6; if (cp[7] == 0) return cp - str + 7; } } } } /* atoi函数的介绍,该函数用来解析字符串str,并将str指向的内容转换为int型整数返回。首先该函数可能会丢弃空格字符,直到找到第一个非空格字符为止,然后从该字符开始,取一个可选的正负号,最后转换为int型整数即可。需要注意的是,如果字符串str中包含其他字符,那么这些字符将会被忽略。 算法分析:实现atoi的基本功能是比较简单的,但是当考虑很多特殊情况时,却不是一件容易的事情,比如考虑指针的有效性、空字符串、空白字符、是否是数字字符、是否会溢出、正数还是负数,这些情况都应该考虑到,其次,异常情况下返回0与正常情况下返回0是不一样的,这里用全局变量status来标记当前输入是合法还是非法(也就是正常或者异常)。 */ int MyAtoi(const char * str) { int sign = 1; int64_t ret = 0; //判断指针是否为空 assert(NULL != str); //处理空字符串 if ('\0' == *str) { return 0; } //处理空白字符 while (isspace(*str)) { str++; //出现连续多个空白字符是非法的 if ('\0' == *str) { return 0; } } //处理正负号 if ('+' == *str) { str++; } else if ('-' == *str) { sign = -1; str++; } while (*str) { //处理数字字符 if (isdigit(*str)) { ret = ret * 10 + sign * (*str - '0'); if ((ret > INT_MAX) || (ret < INT_MIN)) { return 0; } str++; } else { return (int)ret; } } return (int)ret; } //vc6下的源码。 atoi 也是调用 atol long __cdecl atol_vc6(const char *nptr) { int c; /* current char */ long total; /* current total */ int sign; /* if '-', then negative, otherwise positive */ /* skip whitespace */ while ( isspace((int)(unsigned char)*nptr) ) ++nptr; c = (int)(unsigned char)*nptr++; sign = c; /* save sign indication */ if (c == '-' || c == '+') c = (int)(unsigned char)*nptr++; /* skip sign */ total = 0; while (isdigit(c)) { total = 10 * total + (c - '0'); /* accumulate digit */ c = (int)(unsigned char)*nptr++; /* get next char */ } if (sign == '-') return -total; else return total; /* return result, negated if necessary */ } /* 算法分析 首先需要判断字符串str1的首字符是否与str2中的首字符相同,如果不相同的话,str1指向的字符向后移动,不断地去比较str1的字符与str2中的首字符,如果一直都不相同的话,就表示str1中找不到包含str2的字符串,如果相同的话,那么str1和str2指向的字符都向后移动,再次判断str2中的字符串是否全都在str1中出现,如果是的话,那么返回str2在str1中的位置,如果不是全都出现的话,那么表示没有找到,返回NULL。需要注意的是,匹配到首个字符时,有可能是连续几个字符相同的情况,这时就需要判断str2中的字符匹配str1时,究竟是str1中的哪个字符才是需要匹配的首个字符。 这里举例说明下,若str1内容为"abcccde",str2内容为"cd",那么指向str1中的第三个字符'c'时,恰巧str2中的首个字符为'c',这时可以认为匹配到首个字符。但是当str1后移一个字符时,即就是'c',而str2后移一个字符,即就是'd',显然不匹配了,但是并不能认为str1中没有匹配str2的项,这就需要在匹配前保存遇到的str2中的首个字符在str1中的位置,方便下一次查找(ps:也就是不需要再次遍历了)。当指向str1中的第二个'c'时,匹配str2中的首个字符'c',此时str1后移一位,即就是'c',而str2后移一个字符,即就是'd',显然不匹配了,由于保存了str1中第二个'c'的位置,那么接下来就可以从str1中的第三个'c'开始匹配,str2中首个字符为'c',str1后移一位,即就是'd',而str2后移一位也是'd',str1再次后移一位得到'e',而str2后移一位得到'\0',查找结束。 */ char * MyStrstr(const char * src, const char * substr) { const char * str1 = src; const char * str2 = substr; assert((NULL != src) && (NULL != substr)); if ('\0' == *str2) { return (char *)src; } else { while ('\0' != *src) { str1 = src; str2 = substr; while (('\0' != *str1) && ('\0' != *str2) && (*str1 == *str2)) { str1++; str2++; } if ('\0' == *str2) { return (char *)src; } else { src++; } } } return NULL; } char * MyStrchr2(const char * src, int ch) { assert(NULL != src); while (('\0' != *src) && (((char)ch) != *src)) { src++; } if (((char)ch) == *src) { return (char *)src; } else { return NULL; } } #include <stdlib.h> #include <stdio.h> #include <memory.h> #include "BasicOperation.h" //自定义的基础操作类 //#include "FastMemcpy_Avx.h" #ifdef UNIT_TEST int Test_MyClib() { const int BUFFER_SIZE=100*1024+7; //SP_ALIGN(32) char buf1[BUFFER_SIZE]; //SP_ALIGN(32) char buf2[BUFFER_SIZE]; //各种基本类型数据相乘效率相对值,越高越快 ret*=b; //float 53 double 53 int 236 unsigned int 151 uint64_t 132 //除法效率ret/=b; //float 27 double 27 int 34 unsigned int 43 int64_t 9.2 uint64_t 9.1 //int64_t比浮点还慢? typedef unsigned int TypeTest; const unsigned int loopNum=1000; TypeTest a=39.99; TypeTest b=20.88; SuperTime time("Test_MyClib"); size_t ret=0; for (int K=0;K<1000*10;K++) { time.getBeginTime(); for (int i=0;i<loopNum;i++) { ret+=(int)memcpy(buf1,buf2,sizeof(buf1)); //375xhz 系统函数 ret+=(int)MyMemcpyV1(buf1,buf2,sizeof(buf1)); //505xHz ret+=(int)MyMemcpyV2(buf1,buf2,sizeof(buf1)); //517xHz ret+=(int)MyMemcpy_FastV1(buf1,buf2,sizeof(buf1)); //512xhz ret+=(int)memcpy_duff(buf1,buf2,sizeof(buf1)); //33xhz //ret+=(int)memcpy_fast(buf1,buf2,sizeof(buf1)); //479xhz //基于AVX 并没有飞快 //基本相近 ret+=(int)memset(buf1,0X99,sizeof(buf1)); ret+=(int)MyMemsetV1(buf1,0X99,sizeof(buf1)); ret+=(int)MyMemsetV2(buf1,0X99,sizeof(buf1)); ret+=(int)MyMemset_FastV1(buf1,0X99,sizeof(buf1)); ret+=(int)MyMemset_FastV2(buf1,0X99,sizeof(buf1)); } time.getEndPrint(100); } std::cout<<"result="<<ret<<std::endl; //print_hex(buf1,BUFFER_SIZE); //float fv=0.99; //memset(&fv,0,sizeof(fv)); //print_hex(&fv,sizeof(fv)); //printf("%lf",fv); return 0; } #endif
[ "yfycp@163.com" ]
yfycp@163.com
84fe3a8acf7930d02a6d0438beb1f3021728a409
f6736a873d511e65327aed7f97d76ad39e5eaa18
/MyStrat.cpp
637668ee02e74e3941e5247753c0a66bcad68603
[]
no_license
pavelborisov/raic_2019
c6839c6938b987504897a9945b2e3534ab135b4e
241f459471ef1b142986fa42c793b37e29ec46ec
refs/heads/master
2020-12-14T04:02:36.565993
2020-01-16T19:30:37
2020-01-16T19:30:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
66,325
cpp
#include "MyStrat.hpp" #include <deque> #include <map> #include <set> #include <optional> #include <queue> #include <functional> #ifdef ENABLE_LOGGING void writeLog(const std::string &str); void renderLine(const P &p1, const P &p2, uint32_t color); void renderPath(const MyLevel &level, const std::vector<int> &nodes); #define WRITE_LOG(x) {std::ostringstream oss; oss << x; writeLog(oss.str());} #else #define writeLog(str); #define renderLine(p1, p2, color); #define WRITE_LOG(x); #define renderPath(l, n); #endif void DistanceMap::compute(const Simulator &sim, IP ip) { w = sim.level->w; h = sim.level->h; distMap.clear(); distMap.resize(w * h, -1); ip.limitWH(w, h); std::deque<IP> pts; pts.push_back(ip); distMap[ip.ind(w)] = 0; while (!pts.empty()) { IP p = pts.front(); pts.pop_front(); double v = distMap[p.ind(w)] + 1; for (int y = p.y - 1; y <= p.y + 1; ++y) { if (sim.level->isValidY(y)) { for (int x = p.x - 1; x <= p.x + 1; ++x) { if (sim.level->isValidX(x)) { int ind = IP(x, y).ind(w); if (distMap[ind] < 0) { Tile t = sim.level->getTile(x, y); if (t != WALL) { distMap[ind] = v; pts.push_back(IP(x, y)); } } } } } } } } void NavMeshV2::compute(const MyLevel &level) { w = level.w; h = level.h; nodes.resize(level.w * level.h); auto canMove = [&level](int x, int y) { return !wall(level.getTile(x, y)) && !wall(level.getTile(x, y + 1)); }; for (int y = 1; y < level.h - 1; ++y) { for (int x = 1; x < level.w - 1; ++x) { if (canMove(x, y)) { std::array<Node, MOM_N> &cellNodes = nodes[IP(x, y).ind(level.w)]; bool onLadder = level.getTile(x, y) == LADDER; bool onLadderUpper = level.getTile(x, y + 1) == LADDER; bool onGround; bool cm_l = canMove(x - 1, y); bool cm_r = canMove(x + 1, y); bool cm_u = canMove(x, y + 1); bool cm_d = canMove(x, y - 1); bool cm_lu = cm_l && cm_u && canMove(x - 1, y + 1); bool cm_ru = cm_r && cm_u && canMove(x + 1, y + 1); bool cm_ld = cm_l && cm_d && canMove(x - 1, y - 1); bool cm_rd = cm_r && cm_d && canMove(x + 1, y - 1); bool isJumppadBelow = jumppad(level.getTile(x, y - 1)); bool isJumppadUpperHalf = jumppad(level.getTile(x, y + 1)); bool isJumppadCurrent = jumppad(level.getTile(x, y)) || isJumppadUpperHalf; bool isJumppadBody = isJumppadBelow || isJumppadCurrent; bool isWallOrLadderAbove = wall(level.getTile(x, y + 2)) || level.getTile(x, y + 2) == LADDER; if (!isJumppadBody || isWallOrLadderAbove) { // move left onGround = wallOrPlatformOrLadder(level.getTile(x, y - 1)) || (cm_l && wallOrPlatform(level.getTile(x - 1, y - 1))) || onLadder; if ((onGround || onLadderUpper) && cm_l) { Node &nd0 = cellNodes[0]; Link l; l.cost = 6; l.targetMomentum = 0; l.targetCanCancel = true; l.deltaPos = -1; nd0.links.push_back(l); } // left down if (!isJumppadBody && cm_ld) { Node &nd0 = cellNodes[0]; Link l; l.cost = 6; l.targetMomentum = 0; l.targetCanCancel = true; l.deltaPos = -1 - level.w; nd0.links.push_back(l); } // move right onGround = wallOrPlatformOrLadder(level.getTile(x, y - 1)) || (cm_r && wallOrPlatform(level.getTile(x + 1, y - 1))) || onLadder; if ((onGround || onLadderUpper) && cm_r) { Node &nd0 = cellNodes[0]; Link l; l.cost = 6; l.targetMomentum = 0; l.targetCanCancel = true; l.deltaPos = 1; nd0.links.push_back(l); } // right down if (!isJumppadBody && cm_rd) { Node &nd0 = cellNodes[0]; Link l; l.cost = 6; l.targetMomentum = 0; l.targetCanCancel = true; l.deltaPos = 1 - level.w; nd0.links.push_back(l); } // moveDown if (!isJumppadBody && !wallOrJumppad(level.getTile(x, y - 1))) { Node &nd0 = cellNodes[0]; Link l; l.cost = 6; l.targetMomentum = 0; l.targetCanCancel = true; l.deltaPos = -level.w; nd0.links.push_back(l); } } // move up if (cm_u) { if (!isJumppadBody) { for (int i = 1; i <= 5; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 6; l.targetMomentum = i - 1; l.targetCanCancel = true; l.deltaPos = level.w; node.links.push_back(l); } } for (int i = 6; i < 16; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 3; l.targetMomentum = onLadderUpper ? 0 : (isJumppadCurrent ? 10 : i - 6); l.targetCanCancel = l.targetMomentum == 0; l.deltaPos = level.w; node.links.push_back(l); } // move left up if (cm_lu) { if (!isJumppadBody) { for (int i = 1; i <= 5; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 6; l.targetMomentum = i - 1; l.targetCanCancel = true; l.deltaPos = -1 + level.w; node.links.push_back(l); } } if (canMove(x - 1, y + 2) && !onLadder && !onLadderUpper) { for (int i = 7; i < 16; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 6; l.targetMomentum = isJumppadUpperHalf ? 10 : (isJumppadCurrent ? 9 : i - 7); l.targetCanCancel = l.targetMomentum == 0; l.deltaPos = -1 + 2 * level.w; node.links.push_back(l); } } } // move right up if (cm_ru) { if (!isJumppadBody) { for (int i = 1; i <= 5; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 6; l.targetMomentum = i - 1; l.targetCanCancel = true; l.deltaPos = 1 + level.w; node.links.push_back(l); } } if (canMove(x + 1, y + 2) && !onLadder && !onLadderUpper) { for (int i = 7; i < 16; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 6; l.targetMomentum = isJumppadUpperHalf ? 10 : (isJumppadCurrent ? 9 : i - 7); l.targetCanCancel = l.targetMomentum == 0; l.deltaPos = +1 + 2 * level.w; node.links.push_back(l); } } } } // stop jumping for (int i = 1; i <= 5; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 1; l.targetMomentum = 0; l.targetCanCancel = true; l.deltaPos = 0; node.links.push_back(l); } // start jumping onGround = wallOrPlatformOrLadder(level.getTile(x, y - 1)) || (cm_l && wallOrPlatform(level.getTile(x - 1, y - 1))) || (cm_r && wallOrPlatform(level.getTile(x + 1, y - 1))) || onLadder; if (onGround) { Node& node = cellNodes[0]; Link l; l.cost = 1; l.targetMomentum = 5; l.targetCanCancel = true; l.deltaPos = 0; node.links.push_back(l); } // hit ceiling bool ceiling = isWallOrLadderAbove || wall(level.getTile(x - 1, y + 2)) || wall(level.getTile(x + 1, y + 2)); if (ceiling && !isJumppadCurrent) { for (int i = 6; i < 16; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 1; l.targetMomentum = 0; l.targetCanCancel = true; l.deltaPos = 0; node.links.push_back(l); } } if (!onLadder && !onLadderUpper) { // jump on jumppad bool isJumppad = false; for (int dy = -1; dy <= 2; ++dy) { for (int dx = -1; dx <= 1; ++dx) { if (level.getTileSafe(IP(x + dx, y + dy)) == JUMP_PAD) { isJumppad = true; break; } } } if (isJumppad) { for (int i = 0; i < 16; ++i) { Node& node = cellNodes[i]; Link l; l.cost = 1; l.targetMomentum = 10; l.targetCanCancel = false; l.deltaPos = 0; node.links.push_back(l); } } } } } } } void DistanceMapV2::compute(const NavMeshV2 &navMesh, const PP &pp) { w = navMesh.w; h = navMesh.h; distMap.clear(); distMap.resize(w * h * MOM_N, 65000); #ifdef ENABLE_LOGGING prevNode.clear(); prevNode.resize(w * h * MOM_N, -1); #endif typedef std::pair<uint16_t , PP> NLink; auto cmp = [](const NLink &l1, const NLink &l2){return l1.first > l2.first;}; std::priority_queue<NLink, std::vector<NLink>, decltype(cmp)> pts(cmp); pts.push(std::make_pair(0, pp)); distMap[pp.ind()] = 0; while (!pts.empty()) { PP p = pts.top().second; pts.pop(); int pInd = p.ind(); uint16_t curDist = distMap[pInd]; const Node &node = navMesh.nodes[p.pos][p.innerInd()]; //LOG("FROM " << p.toString(w) << " d " << curDist); for (const auto &link : node.links) { PP v; v.pos = p.pos + link.deltaPos; v.upMomentum = link.targetMomentum; v.canCancel = link.targetCanCancel; uint16_t newD = curDist + link.cost; int vInd = v.ind(); if (distMap[vInd] > newD) { distMap[vInd] = newD; #ifdef ENABLE_LOGGING prevNode[vInd] = pInd; #endif pts.push(std::make_pair(newD, v)); //LOG("TO " << v.toString(w) << " d " << newD); } } } } void applyMove(const Move &m, MyAction &action) { action.velocity = m.vel; if (m.jump == 1) action.jump = true; else if (m.jump == -1) action.jumpDown = true; } DistanceMapV2 &getDistMap(const MyUnit &u, MyStrat &strat) { PP p = strat.navMesh.makePP(u); int posInd = p.ind(); auto it = strat.distMap.find(posInd); if (it != strat.distMap.end()) { strat.lruCache.erase(it->second.lruCacheIt); strat.lruCache.push_front(posInd); it->second.lruCacheIt = strat.lruCache.begin(); return it->second; } if (strat.lruCache.size() > MAX_DMAPS) { int last = strat.lruCache.back(); strat.lruCache.pop_back(); strat.distMap.erase(last); //LOG("REMOVE CACHE"); } DistanceMapV2 &res = strat.distMap[posInd]; res.compute(strat.navMesh, p); strat.lruCache.push_front(posInd); res.lruCacheIt = strat.lruCache.begin(); //LOG("CASHE SIZE " << strat.lruCache.size()); return res; } DistanceMap &getSimpleDistMap(const IP &p, MyStrat &strat) { int posInd = p.ind(strat.sim.level->w); auto it = strat.simpleDistMap.find(posInd); if (it != strat.simpleDistMap.end()) return it->second; DistanceMap &res = strat.simpleDistMap[posInd]; res.compute(strat.sim, p); return res; } struct DistComputer { DistanceMapV2 &dmap; DistanceMap &sdmap; MyStrat &strat; DistComputer(const MyUnit &unit, MyStrat &strat) : dmap(getDistMap(unit, strat)), sdmap(getSimpleDistMap(unit.pos, strat)), strat(strat) { } double getDist(const P &p, double simpleDistMapCoef) const { double d1 = dmap.getDist(strat.navMesh.makePP(p)); double d2 = sdmap.getDist(p); double dist = d1 * (1.0 - simpleDistMapCoef) + d2; return dist; } double getDistM0(const MyUnit &u, double simpleDistMapCoef) { double dist = dmap.getDistM0(strat.navMesh.makePP(u)) * (1.0 - simpleDistMapCoef) + sdmap.getDist(u.pos); return dist; } }; double getScore(MyStrat &strat, const Simulator &sim, bool isLoosing, double sdScore, std::map<int, int> &curHealth, int curTick, const std::vector<std::pair<P, double/*T*/>> &RLColPoints) { double score = (sim.score[0] - sim.score[1])/10.0 + (sim.selfFire[1] - sim.selfFire[0])/4.0; double s0 = score; double lbScore = 0; // Бонус за то, что аптечка ближе к намшему юниту, чем к врагу //std::set<int> clBoxes; for (const MyLootBox &l : sim.lootBoxes) { if (l.type == MyLootBoxType ::HEALTH_PACK) { double minDist = 1e9; Side side = Side::NONE; int id = -1; double deltaHealth = 0; for (const MyUnit &unit : sim.units) { DistComputer dcomp(unit, strat); double dist = dcomp.getDist(l.pos, sdScore); if (unit.isMine()) dist *= 1.1; if (dist < minDist) { minDist = dist; side = unit.side; id = unit.id; deltaHealth = 100 - curHealth[unit.id]; } } //clBoxes.insert(id); if (side == Side::ME) lbScore += (deltaHealth * 0.1); else lbScore -= (deltaHealth * 0.1); } } if (lbScore > 30) // Слишком много аптечек lbScore = 30; score += lbScore; //WRITE_LOG("++++++++++++ " << lbScore); for (const MyUnit &unit : sim.units) { if (unit.side == Side::ME) { if (isLoosing && unit.weapon.lastFireTick + 500 < sim.curTick) // Может хоть так перестанут боты застревать на карте? (Хотя не, все равно не работает) score += unit.health * 0.5; else score += unit.health; if (unit.weapon) score -= unit.weapon.spread; else score -= 1; if (!unit.action.shoot && unit.weapon && unit.weapon.fireTimerMicrotics <= 100) { score -= 1; } IP ipos = IP(unit.pos); DistComputer dcomp(unit, strat); double magazineRel = 1.0; if (unit.weapon && unit.weapon.weaponType != MyWeaponType ::ROCKET_LAUNCHER) { magazineRel = (double) unit.weapon.magazine / (double) unit.weapon.params->magazineSize; } bool reload = false; if (unit.weapon) { score += 100; reload = unit.weapon.fireTimerMicrotics > unit.weapon.params->fireRateMicrotiks; } else { double wScore = 0; double wCount = 0; for (const MyLootBox &l : sim.lootBoxes) { if (l.type == MyLootBoxType ::WEAPON) { double dist = dcomp.getDist(l.pos, sdScore); wScore += 50.0 / (dist + 1.0); wCount++; } } if (wCount > 0) score += wScore / wCount; // Бежим к оружию } double hpScore = 0; double mineScore = 0; { double hScore = 0; double hCount = 0; double mScore = 0; double mCount = 0; for (const MyLootBox &l : sim.lootBoxes) { if (l.type == MyLootBoxType ::HEALTH_PACK) { double dist = dcomp.getDist(l.pos, sdScore); hScore += 50.0 / (dist + 1.0); hCount++; // Небольшая тяга к аптечкам } else if (l.type == MyLootBoxType ::MINE) { double dist = dcomp.getDist(l.pos, sdScore); mScore += 5.0 / (dist + 1.0); mCount++; // Еще меньшая тяга к минам } } if (hCount > 0) hpScore = hScore / hCount; if (mCount > 0) { if (unit.mines == 0) mineScore = 2 * mScore / mCount; else if (unit.mines == 1) mineScore = mScore / mCount; } mineScore += 5 * std::min(2, unit.mines); } double enScore = 0; if (unit.weapon) { for (const MyUnit &en : sim.units) { if (en.side == Side::EN) { bool enReload = false; if (en.weapon) enReload = en.weapon.fireTimerMicrotics > en.weapon.params->fireRateMicrotiks; double dist = dcomp.getDistM0(en, sdScore); if (reload && !enReload && en.weapon && en.weapon.magazine > 3 && dist < 10) { enScore -= (10 - dist)*2; // Лучше не стоять рядом с врагом при перезарядке // WRITE_LOG("===") } if (unit.health > 80 || unit.health >= en.health || hpScore == 0 /*|| !clBoxes.count(unit.id)*/) // Неплохо бы приблизится к врагу { double keepDist = 0; if ((reload /*|| magazineRel < 0.5*/)) keepDist = 10; // Опять перезарядка if (en.weapon) { const double D = 5; if (dist < D) { bool enCanKill = !enReload && en.weapon.magazine * en.weapon.params->bulletDamage >= unit.health; bool meCanKill = unit.weapon.magazine * unit.weapon.params->bulletDamage >= en.health; if (enCanKill && (!meCanKill || unit.weapon.fireTimerMicrotics >= en.weapon.fireTimerMicrotics)) enScore -= (D - dist)*5; /*WRITE_LOG("KK " << enCanKill << " " << meCanKill << " " << (enCanKill && (!meCanKill || unit.weapon.fireTimerMicrotics >= en.weapon.fireTimerMicrotics))); WRITE_LOG("KKK1 " << en.weapon.magazine << " " << en.weapon.params->bulletDamage << " " << unit.health); WRITE_LOG("KKK2 " << unit.weapon.magazine << " " << unit.weapon.params->bulletDamage << " " << en.health);*/ if (unit.weapon.fireTimerMicrotics >= en.weapon.fireTimerMicrotics + 300) enScore -= (D - dist)*2; else if (unit.weapon.fireTimerMicrotics <= en.weapon.fireTimerMicrotics - 300) enScore += (D - dist)*2; } } //if (keepDist == 0 && en.weapon.weaponType == MyWeaponType ::ROCKET_LAUNCHER) // keepDist = 5; //else if (magazineRel * unit.weapon.params->fireRateMicrotiks < 500) // keepDist = 3; //WRITE_LOG("KD " << keepDist << " " << dist << " " << (50.0 / (std::abs(dist - keepDist) + 5.0)) << " ep " << en.pos << " eh " << en.health); if (keepDist > 0) enScore += 50.0 / (std::abs(dist - keepDist) + 5.0) * (unit.health + 20.0) / (en.health + 20.0); // Если что, то да, обе ветки одинаковые (но всегда они были такими) else enScore += 50.0 / (dist + 5.0) * (unit.health + 20.0) / (en.health + 20.0); } else { enScore -= 50.0 / (dist + 5.0); } } } score += enScore; } for (const MyUnit &en : sim.units) { if (en.side == Side::EN) { if (en.weapon && en.pos.dist(unit.pos) < 5 && dot((unit.pos - en.pos).norm(), en.weapon.lastAngle.norm()) >= 0.5) { if (en.weapon.fireTimerMicrotics <= 100 && (!unit.canJump || !unit.canCancel)) { score -= 10.0; } } } } double rlScore = 0; if (!RLColPoints.empty()) // Держимся подальше от мест, где будут взрываться ракеты { BBox bb = unit.getBBox(); bb.expand(getWeaponParams(MyWeaponType::ROCKET_LAUNCHER)->explRadius + 0.1); for (const auto &p : RLColPoints) { if (p.second < 15 && bb.contains(p.first) && curTick <= (p.second + 1)) { double ticksToExpl = p.second - curTick; rlScore -= 2.0 * std::max(0.0, (10.0 - p.first.dist(unit.getCenter()))) / (ticksToExpl + 1.0); //WRITE_LOG("RL " << ticksToExpl << " t " << p.second << " s " << rlScore << " d " << p.first.dist(unit.getCenter())); //LOG(rlScore); } } } if (enScore < 0 && unit.health < 100) // Бежим к аптечкам { score += hpScore; } score += mineScore; if (curHealth[unit.id] < 100) score += hpScore * (100 - curHealth[unit.id]) / 200.0; score += rlScore; WRITE_LOG("ENS " << enScore << " HPS " << hpScore << " H " << unit.health << " s0 " << s0 << " lb " << lbScore << " rl " << rlScore); } else { score -= unit.health * 0.5; if (unit.weapon) score += unit.weapon.spread * 0.5; else score += 1 * 0.5; } } return score; } const MyUnit *getNearestEnemy(Simulator &sim, MyStrat &strat, const MyUnit &unit, double sdScore) { IP ipos = IP(unit.pos); DistComputer dcomp(unit, strat); const MyUnit *nearestEnemy = nullptr; double dmapDist = 1e9; for (const MyUnit &other : sim.units) { if (other.side != unit.side) { double dist = dcomp.getDistM0(other, sdScore); if (unit.weapon) { /*double dt = dot(unit.weapon.lastAngle, (other.pos - unit.pos).norm()); dist += (1.0 - dt) * 1.0; dist += other.health * 0.1;*/ } if (dist < dmapDist) { dmapDist = dist; nearestEnemy = &other; } } } return nearestEnemy; } void normalizeAim(MyUnit &unit, const P &lowestAngle, const P &largestAngle) // Стараемся сильно не дергать прицел { if (unit.weapon.lastAngle != P(0, 0)) { bool b1 = isAngleLessThan(lowestAngle, unit.weapon.lastAngle.rotate(-unit.weapon.spread)); bool b2 = isAngleLessThan(unit.weapon.lastAngle.rotate(unit.weapon.spread), largestAngle); if (!b1 && !b2) { unit.action.aim = unit.weapon.lastAngle; return; } if (b1 && b2) return; if (b1) { double ang = -unrotate(unit.weapon.lastAngle, lowestAngle).getAngleFast(); //assert(ang > unit.weapon.spread); P newAngle = P(-(ang - unit.weapon.spread) * 0.5); unit.action.aim = unit.weapon.lastAngle.rotate(newAngle); } else if (b2) { double ang = unrotate(unit.weapon.lastAngle, largestAngle).getAngleFast(); //assert(ang > unit.weapon.spread); P newAngle = P((ang - unit.weapon.spread) * 0.5); unit.action.aim = unit.weapon.lastAngle.rotate(newAngle); } } } void normalizeAim(MyUnit &unit, const P &enemyPos) { if (unit.weapon.lastAngle != P(0, 0)) { P center = unit.getCenter(); BBox enBox = BBox::fromBottomCenterAndSize(enemyPos, unit.size); P lowestAngle = (enBox.getCorner(0) - center).norm(); P largestAngle = lowestAngle; for (int i = 1; i < 4; ++i) { P angle = (enBox.getCorner(i) - center).norm(); if (isAngleLessThan(angle, lowestAngle)) lowestAngle = angle; if (isAngleLessThan(largestAngle, angle)) largestAngle = angle; } normalizeAim(unit, lowestAngle, largestAngle); } } bool onLadderOrOnGround(const MyLevel &level, const MyUnit &unit) { bool enOnLadder = level.getTileSafe(IP(unit.pos)) == LADDER || level.getTileSafe(IP(unit.pos.x, unit.pos.y + 1)) == LADDER; if (enOnLadder) return true; if ((unit.pos.y - std::floor(unit.pos.y)) < 0.001) { bool onGround = wallOrPlatform(level.getTileSafe(IP(unit.pos.x, unit.pos.y - 1))) || (wallOrPlatform(level.getTileSafe(IP(unit.pos.x - 1, unit.pos.y - 1))) && level.getTileSafe(IP(unit.pos.x - 1, unit.pos.y)) != WALL) || (wallOrPlatform(level.getTileSafe(IP(unit.pos.x + 1, unit.pos.y - 1))) && level.getTileSafe(IP(unit.pos.x + 1, unit.pos.y)) != WALL) ; return onGround; } return false; } template<int RAYS_N, bool log> void computeFire(Simulator &sim, MyStrat &strat, double sdScore, std::optional<P> enemyPosOpt, int unitId = -1) { for (MyUnit &unit : sim.units) { if (unitId != -1 && unit.id != unitId) continue; if (unit.side == Side::ME && unit.weapon) { const MyUnit *nearestEnemy = getNearestEnemy(sim, strat, unit, sdScore); if (!nearestEnemy) return; P enemyPos = enemyPosOpt ? *enemyPosOpt : nearestEnemy->pos; P aim = (enemyPos - unit.pos).norm(); unit.action.aim = aim; //renderLine(unit.getCenter(), unit.getCenter() + aim * 100, 0xff00ffffu); normalizeAim(unit, enemyPos); //unit.action.aim = (enemyPos - bestMyFirePos).norm(); //unit.action.aim = (nearestEnemy->pos - unit.pos).norm(); unit.action.shoot = false; bool isNearby = unit.pos.dist(nearestEnemy->pos) < 1.5 || (std::abs(unit.pos.x - nearestEnemy->pos.x) < 0.5 && std::abs(unit.pos.y - nearestEnemy->pos.y) < 2.0); if (!nearestEnemy->canJump || !nearestEnemy->canCancel || onLadderOrOnGround(*sim.level, *nearestEnemy) || isNearby) { unit.action.shoot = true; double spread = unit.weapon.spread; if (unit.weapon.fireTimerMicrotics <= sim.level->properties.updatesPerTick) { //const int RAYS_N = 10; P ddir = P(spread * 2.0 / (RAYS_N - 1)); P ray = unit.action.aim.rotate(-spread); P center = unit.getCenter(); MyWeaponParams *wparams = unit.weapon.params; BBox missile = BBox::fromCenterAndHalfSize(center, wparams->bulletSize * 0.5); int myUnitsHits = 0; double enUnitsHits = 0; for (int i = 0; i < RAYS_N; ++i) { P tp = sim.level->bboxWallCollision2(missile, ray); MyUnit *directHitUnit = nullptr; double directHitDist = 1e9; for (MyUnit &mu : sim.units) // direct hit { if (mu.id != unit.id) { auto [isCollided, colP] = mu.getBBox().rayIntersection(center, ray); if (isCollided) { double d1 = tp.dist2(center); double d2 = colP.dist2(center); if (d2 < d1 && d2 < directHitDist) { directHitDist = d2; directHitUnit = &mu; } } } } if (directHitUnit) { if (directHitUnit->isMine()) myUnitsHits++; else { BBox b2 = directHitUnit->getBBox(); double dst = std::max(0.0, std::sqrt(directHitDist) - 1.0); double expD = dst / 10.0; if (expD > 0.4) expD = 0.4; b2.expand(-expD); auto [isCollided, colP] = b2.rayIntersection(center, ray); if (isCollided) { if (dst / unit.weapon.params->bulletSpeed > 0.1) { enUnitsHits += 0.09; } else { enUnitsHits++; } //LOG("EXP " << expD); } else enUnitsHits += 0.09; } } // Explosion damage if (unit.weapon.weaponType == MyWeaponType ::ROCKET_LAUNCHER) { double explRad = wparams->explRadius; for (MyUnit &mu : sim.units) { double dist = tp.maxDist(mu.getCenter()); if (mu.isMine() && dist < (explRad + 1)) { myUnitsHits++; if (log) renderLine(mu.getCenter(), tp, 0xff0000ffu); } else if (mu.isEnemy() && dist < explRad * 0.7) { enUnitsHits++; } } } ray = ray.rotate(ddir); } if (enUnitsHits < 1.0 || (myUnitsHits > 0 && enUnitsHits < RAYS_N * 0.7)) unit.action.shoot = false; if (log) WRITE_LOG("EH " << enUnitsHits << " MH " << myUnitsHits << " F " << unit.action.shoot); } } } if (unit.isMine()) { if (unit.weapon.weaponType == MyWeaponType ::ROCKET_LAUNCHER /*&& nearestEnemy->weapon && nearestEnemy->weapon.weaponType != MyWeaponType::ROCKET_LAUNCHER*/) unit.action.swapWeapon = true; //if (unit.weapon.weaponType == MyWeaponType ::ASSAULT_RIFLE /*&& nearestEnemy->weapon && nearestEnemy->weapon.weaponType != MyWeaponType::ROCKET_LAUNCHER*/) // unit.action.swapWeapon = true; /*if (!unit.action.shoot && unit.weapon && unit.weapon.lastFireTick + 300 < sim.curTick) { unit.action.reload = true; }*/ } } } void renderPathTo(MyStrat &s, const MyUnit &from, const MyUnit &to) { #ifdef ENABLE_LOGGING DistanceMapV2 dmap = getDistMap(from, s); PP p = s.navMesh.makePP(to); std::vector<int> nodes; nodes.push_back(p.ind()); int ind = p.ind(); while(true) { ind = dmap.prevNode[ind]; if (ind == -1) break; nodes.push_back(ind); } renderPath(*s.sim.level, nodes); #endif } void MyStrat::compute(const Simulator &_sim) { // Рандомный коэффицент для склеивания результатов вычисления расстояния для двух разных алгоритмов поиска расстояния до точки // Нужен, так как несмотря на то, что второй алгоритм вычисляет расстояния более точно, он плохо работает для перебираеммых длинных траекторий. double SDMAP_COEF = (sim.getRandom() + 1.0) * 0.5; //LOG(SDMAP_COEF); std::map<int, Move> enemyMoves; if (_sim.curTick > 0) { for (const MyUnit &u : _sim.units) { if (u.isEnemy()) { const MyUnit *oldUnit = this->sim.getUnit(u.id); if (oldUnit) { Move &m = enemyMoves[u.id]; m.vel = (u.pos.x - oldUnit->pos.x) * _sim.level->properties.ticksPerSecond; if (u.pos.y > oldUnit->pos.y) { m.jump = 1; } else if (u.pos.y > oldUnit->pos.y && u.canJump) { m.jump = -1; } } } } } this->sim = _sim; bool isLoosing = sim.score[0] <= sim.score[1]; if (!navMesh.w) { navMesh.compute(*sim.level); } std::map<int, int> curHealth; for (MyUnit &unit : sim.units) { curHealth[unit.id] = unit.health; } std::vector<std::pair<P, double/*T*/>> RLColPoints; for (MyBullet &b : sim.bullets) { if (b.weaponType == MyWeaponType ::ROCKET_LAUNCHER) { BBox bbox = b.getBBox(); P tp = sim.level->bboxWallCollision2(bbox, b.vel); double t = (tp - b.pos).len() / b.params->bulletSpeed * 60; RLColPoints.emplace_back(tp, t); } } std::set<int> mineShoot; for (MyUnit &unit : sim.units) { if (unit.side == Side::ME) { WRITE_LOG("UNIT " << unit.pos << " " << unit.id); double bestScore = -100000; double bestScore0 = -100000; Move bestMove; Move bestMove0; P bestFire = P(0, 0); double friendlyFire = 0; P bestMyFirePos = unit.pos; const MyUnit *nearestEnemy = getNearestEnemy(sim, *this, unit, 0.01); if (nearestEnemy) renderPathTo(*this, unit, *nearestEnemy); P enemyPos = P(0, 0); const int TICKN = 25; int bulletFlyTime = 0; double enemyDist = 1000.0; int ticksToFire = 0; if (nearestEnemy && unit.weapon) { enemyPos = nearestEnemy->pos; enemyDist = enemyPos.dist(unit.pos); bulletFlyTime = std::max(0.0, enemyDist - 1.5) / unit.weapon.params->bulletSpeed*60; ticksToFire = unit.weapon.fireTimerMicrotics / 100; } if (bulletFlyTime >= TICKN) bulletFlyTime = TICKN - 1; { int jumpN = 3; if (unit.canJump) jumpN = 4; // Нужно, чтоб быстрее подниматься по цепочке платформ auto computeMove = [&](const std::string &moveName, std::function<void (MyUnit *simUnit, int tick)> applyMoveFunc){ Simulator sim = _sim; sim.enFireAtCenter = true; sim.score[0] = 0; sim.score[1] = 0; sim.selfFire[0] = 0; sim.selfFire[1] = 0; sim.friendlyFireByUnitId.clear(); P myFirePos = unit.pos; P fireAim = P(0, 0); P p1 = unit.pos; Move firstMove; IP ipos = IP(unit.pos); double score = 0; double coef = 1.0; bool fired = false; int health = unit.health; //std::vector<Simulator> saveSim; for (int tick = 0; tick < TICKN; ++tick) { MyUnit *simUnit = sim.getUnit(unit.id); if (simUnit == nullptr) break; double sdScore = tick < 4 ? 0.01 : SDMAP_COEF; simUnit->action = MyAction(); for (MyUnit &su : sim.units) { su.action = MyAction(); MyAction &action = su.action; action.shoot = true; if (su.weapon) { action.aim = su.weapon.lastAngle; if (tick >= 5 && su.isEnemy()) { const MyUnit *een = getNearestEnemy(sim, *this, su, sdScore); if (een) { action.aim = P(een->pos - su.pos).norm(); } } } if (su.side == Side::ME && su.id != unit.id) { applyMove(myMoves[su.id], action); } else if (tick <= 5 && su.isEnemy()) { Move &em = enemyMoves[su.id]; applyMove(em, su.action); } /*if (su.isEnemy() && su.weapon && su.weapon.fireTimerMicrotics <= 100) { // Check friend for (const MyUnit &oth : sim.units) { if (oth.id != su.id && oth.side == su.side) { P ray = (oth.pos - su.pos); double dist = ray.len(); if (dist < 2) { ray /= dist; double angle = unrotate(su.action.aim, ray).getAngleFast(); if (std::abs(angle) < su.weapon.spread + 0.5 / dist) { su.action.shoot = false; break; } } } } if (su.action.shoot && su.weapon.weaponType == MyWeaponType ::ROCKET_LAUNCHER) { P col = sim.level->rayWallCollision(su.getCenter(), su.action.aim); double dd = col.dist(su.getCenter()); if (dd < 3) { bool anyClose = false; for (const MyUnit &oth : sim.units) { if (oth.isMine()) { if (dd > oth.pos.dist(su.pos) || oth.pos.dist(col) < 4) { anyClose = true; } } } if (!anyClose) su.action.shoot = false; } } }*/ } applyMoveFunc(simUnit, tick); if (tick == 0) { firstMove.vel = simUnit->action.velocity; if (simUnit->action.jump) firstMove.jump = 1; else if (simUnit->action.jumpDown) firstMove.jump = -1; } computeFire<10, false>(sim, *this, sdScore, {}); /*{ for (MyBullet &b : sim.bullets) { BBox bb = b.getBBox(); uint32_t c = b.side == Side::ME ? 0xff0000ffu : 0x0000ffffu; renderLine(bb.getCorner(0), bb.getCorner(2), c); renderLine(bb.getCorner(1), bb.getCorner(3), c); } }*/ if (simUnit->weapon && !fired && simUnit->weapon.fireTimerMicrotics <= sim.level->properties.updatesPerTick && simUnit->action.shoot) { fireAim = simUnit->action.aim; fired = true; } //saveSim.push_back(sim); sim.tick(); { for (MyUnit &u : sim.units) { if (u.isEnemy()) { renderLine(u.pos - P(0.1, 0), u.pos + P(0.1, 0), 0x000000ffu); renderLine(u.pos - P(0, 0.1), u.pos + P(0, 0.1), 0x000000ffu); } } } simUnit = sim.getUnit(unit.id); if (simUnit == nullptr) { score -= 1000; break; } { if (simUnit->health != health) { uint32_t c = simUnit->health < health ? 0xff0000ffu : 0x00ff00ffu; renderLine(simUnit->pos - P(0.1, 0), simUnit->pos + P(0.1, 0), c); renderLine(simUnit->pos - P(0, 0.1), simUnit->pos + P(0, 0.1), c); WRITE_LOG("H t=" << tick << " " << health << " -> " << simUnit->health); health = simUnit->health; } else { uint32_t c = 0x000000ccu; renderLine(simUnit->pos - P(0.05, 0), simUnit->pos + P(0.05, 0), c); renderLine(simUnit->pos - P(0, 0.05), simUnit->pos + P(0, 0.05), c); } } { P p2 = simUnit->pos; renderLine(p1, p2, 0x000000ffu); p1 = p2; } if (tick == bulletFlyTime && nearestEnemy) { MyUnit *newEnemy = sim.getUnit(nearestEnemy->id); if (newEnemy) enemyPos = newEnemy->pos; } if (tick == ticksToFire && nearestEnemy) { myFirePos = simUnit->pos; } /*IP newIpos = IP(unit.pos); if (newIpos != ipos) { if (navMesh.get(newIpos).canWalk) { ipos = newIpos; } }*/ double lscore = getScore(*this, sim, isLoosing, sdScore, curHealth, tick, RLColPoints); if (tick == 0 || tick == 10 || tick == (TICKN - 1)) { WRITE_LOG("LS " << tick << "| " << moveName << " " << lscore << " H " << simUnit->health); } score += lscore * coef; if (tick == 5) { if (score > bestScore0) { bestMove0 = firstMove; bestScore0 = score; } } /*if (tick < 3) coef *= 0.95; else coef *= 0.9;*/ coef *= 0.95; } WRITE_LOG(moveName << " " << score); if (score > bestScore) { bestMove = firstMove; bestFire = fireAim; bestScore = score; friendlyFire = sim.friendlyFireByUnitId[unit.id]; bestMyFirePos = myFirePos; WRITE_LOG("SC " << moveName << " " << score); } }; auto applyMoveFuncByDir = [&](MyUnit *simUnit, int tick, int dir, int jumpS){ if (dir == 0) { simUnit->action.velocity = -sim.level->properties.unitMaxHorizontalSpeed; } else if (dir == 1) { simUnit->action.velocity = sim.level->properties.unitMaxHorizontalSpeed; } if (jumpS == 0) { simUnit->action.jump = true; } else if (jumpS == 1) { simUnit->action.jumpDown = true; } if (jumpS == 3 && tick == 0) { simUnit->action.jump = false; } if (jumpS == 2 || (jumpS == 3 && tick > 0)) { if (dir == 0) { IP ip = IP(simUnit->pos - P(0.5, 0)); if (sim.level->getTileSafe(ip) == WALL || sim.level->getTileSafe(ip.incY()) == WALL) { simUnit->action.jump = true; } } else if (dir == 1) { IP ip = IP(simUnit->pos + P(0.5, 0)); if (sim.level->getTileSafe(ip) == WALL || sim.level->getTileSafe(ip.incY()) == WALL) { simUnit->action.jump = true; } } } }; int bestDir = -1; int bestJumpS = -1; for (int dir = 0; dir < 3; ++dir) { for (int jumpS = 0; jumpS < jumpN; ++jumpS) { std::string moveName; if (dir == 0) { moveName = "left "; } else if (dir == 1) { moveName = "right "; } if (jumpS == 0) { moveName += "up"; } else if (jumpS == 1) { moveName += "down"; } else if (jumpS == 3) { moveName += "downup"; } auto applyMoveFunc = [&](MyUnit *simUnit, int tick){ applyMoveFuncByDir(simUnit, tick, dir, jumpS); }; double oldBestScore = bestScore; computeMove(moveName, applyMoveFunc); if (bestScore > oldBestScore) { bestDir = dir; bestJumpS = jumpS; //LOG("BS " << oldBestScore << " " << bestScore << " " << dir); } }; } if (bestMove0.vel != bestMove.vel) { auto applyMoveFunc = [&](MyUnit *simUnit, int tick){ applyMoveFuncByDir(simUnit, tick, bestDir, bestJumpS); if (tick <= 2) { //LOG("V " << simUnit->action.velocity << " " << bestMove0.vel << " " << bestDir << " " << bestJumpS << " " << bestMove0.vel << " " << bestMove.vel); simUnit->action.velocity = bestMove0.vel; } }; double oldBestScore = bestScore; computeMove("corrected", applyMoveFunc); if (bestScore > oldBestScore) { //LOG("UPD SCORE " << oldBestScore << " " << bestScore); } } } // ============ myMoves[unit.id] = bestMove; unit.action = MyAction(); applyMove(bestMove, unit.action); WRITE_LOG("MOVE " << unit.action.velocity << " " << unit.action.jump << " " << unit.action.jumpDown); // ============ if (nearestEnemy->canJump && onLadderOrOnGround(*sim.level, *nearestEnemy)) enemyPos = nearestEnemy->pos; { renderLine(enemyPos - P(0.5, 0.0), enemyPos + P(0.5, 0.0), 0x00ff00ffu); renderLine(enemyPos - P(0.0, 0.5), enemyPos + P(0.0, 0.5), 0x00ff00ffu); } if (unit.weapon) { if (unit.weapon.fireTimerMicrotics <= sim.level->properties.updatesPerTick) { computeFire<10, true>(sim, *this, 0, enemyPos, unit.id); } else { if (unit.weapon.fireTimerMicrotics > 400) { unit.action.aim = (enemyPos - unit.pos).norm(); } else if (bestFire != P(0, 0)) { unit.action.aim = bestFire; //renderLine(unit.getCenter(), unit.getCenter() + aim * 100, 0xff00ffffu); normalizeAim(unit, enemyPos); } else { unit.action.aim = unit.weapon.lastAngle; } } WRITE_LOG("AIM " << unit.action.aim << " BF " << bestFire << " LA " << unit.weapon.lastAngle << " SC " << sim.score[0] << " " << sim.score[1]); } // Мины... int minesPlanted = 0; for (MyMine &m : sim.mines) { if (m.pos.maxDist(unit.pos) < 0.4) ++minesPlanted; } if (unit.mines > 0 /*&& unit.health <= 20 */ && unit.weapon && unit.weapon.fireTimerMicrotics <= 500 /*&& sim.score[0] > sim.score[1]*/) { double dy = unit.pos.y - std::floor(unit.pos.y); if (dy < 0.4 && wallOrPlatform(sim.level->getTile(IP(P(unit.pos.x, unit.pos.y - 1))))) { int score = -1000; for (MyUnit &u : sim.units) { if (u.id != unit.id) { double dd = u.pos.maxDist(unit.pos); WRITE_LOG("MSCDD " << dd << " " << u.isMine()); if (u.isMine() && dd < (sim.level->properties.mineExplosionParams.radius + sim.level->properties.mineSize.x + 1.0)) { score -= 1000; } else if (u.isEnemy() && dd < (sim.level->properties.mineExplosionParams.radius - (0.4 + std::max(unit.weapon.fireTimerMicrotics/100.0*0.17, dy)))) { if (u.health <= 50 * ((unit.mines + minesPlanted) + (unit.weapon.weaponType == MyWeaponType::ROCKET_LAUNCHER ? 1 : 0))) { score += 1000; score += u.health; } } } } if (score > 0 && minesPlanted > 0) { int curScore = 0; double damage = 50 * ((minesPlanted) + (unit.weapon.weaponType == MyWeaponType::ROCKET_LAUNCHER ? 1 : 0)); for (MyUnit &u : sim.units) { { double dd = u.pos.maxDist(unit.pos); if (u.isMine() && dd < (sim.level->properties.mineExplosionParams.radius + sim.level->properties.mineSize.x + 1.0) && u.health <= damage) { curScore -= 1000; } else if (u.isEnemy() && dd < (sim.level->properties.mineExplosionParams.radius - (0.4 + std::max(unit.weapon.fireTimerMicrotics/100.0*0.17, dy)))) { if (u.health <= damage) { curScore += 1000; curScore += u.health; } } } } if (curScore >= score) { WRITE_LOG("DONT PLANT " << curScore << " " << score); score = 0; } } WRITE_LOG("MSC " << score); //LOG("MSC " << score); if (score > 0 && sim.score[0] + score > sim.score[1] + 10) { LOG("===PLM"); unit.action.plantMine = true; unit.action.jump = false; unit.action.jumpDown = false; unit.action.shoot = false; if (unit.weapon.fireTimerMicrotics <= 200) unit.action.velocity = 0; } } } if (minesPlanted > 0 && unit.weapon.fireTimerMicrotics <= 300) { WRITE_LOG("MPL " << minesPlanted); LOG("MPL " << minesPlanted); int score = -1000; for (MyUnit &u : sim.units) { if (u.id != unit.id) { double dd = u.pos.maxDist(unit.pos); if (u.isMine() && dd < (sim.level->properties.mineExplosionParams.radius + sim.level->properties.mineSize.x + 0.2)) { score -= 1000; } else if (u.isEnemy() && dd < (sim.level->properties.mineExplosionParams.radius - 0.2)) { if (u.health <= 50 * (minesPlanted + (unit.weapon.weaponType == MyWeaponType::ROCKET_LAUNCHER ? 1 : 0))) { score += 1000; score += u.health; } } } } WRITE_LOG("MPSC " << score); LOG("MPSC " << score); if (sim.score[0] + score > sim.score[1] + 10) { unit.action.jump = false; unit.action.jumpDown = false; unit.action.velocity = 0; if (unit.weapon.fireTimerMicrotics <= 100) { for (MyMine &m : sim.mines) { if (m.pos.maxDist(unit.pos) < 0.4) { P aim = (m.getCenter() - unit.getCenter()).norm(); unit.action.aim = aim; unit.action.shoot = true; mineShoot.insert(unit.id); WRITE_LOG("SHOOT"); LOG("SHOOT " << sim.curTick); break; } } } } } } } // Safety check /*for (MyUnit &unit : sim.units) { if (unit.side == Side::ME) { if (unit.weapon.weaponType == MyWeaponType ::ROCKET_LAUNCHER && !mineShoot.count(unit.id) && unit.weapon.fireTimerMicrotics <= 100 && unit.action.shoot) { auto computeSim = [&](int dir, bool fire, Simulator sim){ sim.myRLFireDir = dir; for (int tick = 0; tick < 7; ++tick) { for (MyUnit &u : sim.units) { if (u.id == unit.id) { u.action.shoot = fire; } else if (u.isMine()) { applyMove(myMoves[u.id], u.action); } else { Move &em = enemyMoves[u.id]; applyMove(em, u.action); u.action.shoot = true; const MyUnit *een = getNearestEnemy(sim, *this, u, 0.5); if (een) { u.action.aim = P(een->pos - u.pos).norm(); } } } sim.tick(); } double res = sim.score[0] - sim.score[1]; for (MyUnit &u : sim.units) { if (u.isMine()) res += u.health; else res -= u.health; } return res; }; double scNoShoot = computeSim(-1, false, sim); double scShoot1 = computeSim(0, true, sim); if (scNoShoot > scShoot1) { LOG("DONT SHOOT1 " << sim.curTick << " " << scNoShoot << " " << scShoot1); unit.action.shoot = false; } if (unit.action.shoot) { double scShoot2 = computeSim(1, true, sim); if (scNoShoot > scShoot2) { LOG("DONT SHOOT2 " << sim.curTick << " " << scNoShoot << " " << scShoot2); unit.action.shoot = false; } } } } }*/ }
[ "ud1@mail.ru" ]
ud1@mail.ru
e53f6e3d2792c3ebd613788fe9133a562f0073bd
0116ae427d80bcc86152576a1254c64e6ebc9e1c
/OOTAssignment/Main.cpp
dfb588a0ab430fa764e2fe5b172d006a86677d2a
[]
no_license
JakerzW/OOTAssignment
2564eafb607396105a733991e2ab4813343bf639
80d8a99838a6649d0f4fda036b9d404708541d03
refs/heads/master
2020-03-16T18:45:18.022512
2018-05-18T09:38:21
2018-05-18T09:38:21
132,885,644
0
0
null
null
null
null
UTF-8
C++
false
false
6,728
cpp
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> #include <SDL.h> #include <SDL_ttf.h> #include "ParticleController.h" const int SCREEN_WIDTH = 1000; const int SCREEN_HEIGHT = 600; const int SCREEN_POSX = 50; const int SCREEN_POSY = 50; //Declare all the functions void Delay(float seconds); int main(int argc, char* args[]) { //Defining the window we will render to SDL_Window* window = NULL; //Defining the renderer for rendering to the screen SDL_Renderer* renderer = NULL; //Defining the surface contained by the window SDL_Surface* screenSurface = NULL; //Initialise the font TTF_Font* font = NULL; //Defining surface to hold text SDL_Surface* textSurface = NULL; //Defining the texture used to create the text SDL_Texture* textTexture = NULL; //Declare time floats to calculate the fps float lastTime, currentTime, deltaTime; int currentFps; //Value to store how many frames have passed; int frames; //Exit the program if SDL cannot be initialised if (SDL_Init(SDL_INIT_VIDEO) < 0) { std::cout << "SDL could not initialise." << std::endl; return -1; } if (TTF_Init() < 0) { std::cout << "TTF could not initialise." << std::endl; return -1; } //If no error occurs, carry on with defining the window else { //Create the window window = SDL_CreateWindow("Particle Program", SCREEN_POSX, SCREEN_POSY, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN); //Create the renderer renderer = SDL_CreateRenderer(window, -1, 0); //Set the font font = TTF_OpenFont("../Include/Fonts/arial.ttf", 25); //If the window fails to be created, exit the program if (window == NULL) { std::cout << "Window could not be created." << std::endl; return -1; } //Exit if the Renderer fails to be created else if (renderer == NULL) { std::cout << "Renderer could not be created." << std::endl; return -1; } //Exit if the font does not exist else if (font == NULL) { std::cout << "Could not get font" << std::endl << TTF_GetError(); return -1; } else { //Get the window's surface screenSurface = SDL_GetWindowSurface(window); //Fill the surface in as black SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0, 0, 0)); //Update the surface SDL_UpdateWindowSurface(window); //Create the particle controller to control the way the particles work and react ParticleController pController(renderer, SCREEN_WIDTH, SCREEN_HEIGHT); //Set the initial number of particles pController.SetParticleNum(2000); //Create the particles now the number of particles is set pController.CreateParticles(); //Define the rect to hold the text and FPS val SDL_Rect textRect; textRect.x = 10; textRect.y = 10; textRect.w = 50; textRect.h = 25; //Initialise font colour SDL_Color fontColour = { 0, 255, 255 }; //Initialise the time for calculating the fps lastTime = 0; currentTime = 0; deltaTime = 0; currentFps = 0; frames = 0; //Set the boolean to check if the program should exit bool ProgramActive = true; //The main program procedure while (ProgramActive) { SDL_Event inputEvent; while (SDL_PollEvent(&inputEvent)) { switch (inputEvent.type) { case SDL_KEYDOWN: { std::cout << "Key Pressed" << std::endl; switch (inputEvent.key.keysym.sym) { case SDLK_UP: { if (pController.GetParticleNum() < 10000) { pController.IncreaseParticleNum(); pController.CreateParticles(); } break; } case SDLK_DOWN: { if (pController.GetParticleNum() > 2000) { pController.DecreaseParticleNum(); pController.CreateParticles(); } break; } case SDLK_SPACE: { if (pController.GetState() == Standard) { pController.DivideParticles(); } break; } case SDLK_1: { pController.SetCollidingDivision(0); break; } case SDLK_2: { pController.SetCollidingDivision(1); break; } case SDLK_3: { pController.SetCollidingDivision(2); break; } case SDLK_4: { pController.SetCollidingDivision(3); break; } case SDLK_5: { pController.SetCollidingDivision(4); break; } case SDLK_6: { pController.SetCollidingDivision(5); break; } case SDLK_7: { pController.SetCollidingDivision(6); break; } case SDLK_8: { pController.SetCollidingDivision(7); break; } case SDLK_ESCAPE: { ProgramActive = false; break; } } } } } //Calculate deltaTime for fps currentTime = SDL_GetTicks(); deltaTime = currentTime - lastTime; lastTime = currentTime; currentFps = frames / (currentTime / 1000); //Render fps text to screen std::string fpsPrefix = "FPS: "; std::string fpsText; fpsText = fpsPrefix + std::to_string(currentFps); //Clear the screen SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); if (pController.GetState() == Divided || pController.GetState() == Colliding) { //std::cout << "Particles divided cleanly" << std::endl; pController.DrawDivisions(); } //Perform particle functions pController.MoveParticles(); if (pController.GetState() == Colliding) { pController.CheckCollisions(); } pController.DrawParticles(); //Draw the text textSurface = TTF_RenderText_Solid(font, fpsText.c_str(), fontColour); textTexture = SDL_CreateTextureFromSurface(renderer, textSurface); SDL_RenderCopy(renderer, textTexture, NULL, &textRect); //Render the screen SDL_RenderPresent(renderer); //Update the number of frames frames++; //Delay(0.0125f); } } } //Wait two seconds Delay(0.5f); //Destroy the renderer SDL_DestroyRenderer(renderer); //Free the screen surface SDL_FreeSurface(screenSurface); /*//Free the text surface //SDL_FreeSurface(textSurface); //Destroy text texture //SDL_DestroyTexture(textTexture); //Close the font //TTF_CloseFont(font);*/ //Destroy window SDL_DestroyWindow(window); //Quit SDL subsystems SDL_Quit(); return 0; } //Enter the number of seconds to delay the program void Delay(float seconds) { SDL_Delay(seconds * 1000); }
[ "jakerzw@hotmail.co.uk" ]
jakerzw@hotmail.co.uk
20ff369821ca44c56a7259c53dfef00b874e193e
1c96637c84ed42ac41c5974946ef051e0c32d2da
/16985.cpp
01cd7829578e976a7c6b162654478f9fb1184efe
[]
no_license
Kitsch1/BOJ
55c3bad45b85d3137ff9817eb39e7790d3591ea1
264be65c51958059f359a31be4f0593d4c0b93c4
refs/heads/master
2020-04-14T23:08:38.523715
2019-05-12T07:16:42
2019-05-12T07:16:42
164,191,448
1
0
null
null
null
null
UTF-8
C++
false
false
2,985
cpp
#include <cstdio> #include <queue> #include <vector> #include <cstring> #include <algorithm> using namespace std; const int n = 5; const int h_way[6] = {1,-1,0,0,0,0}; const int r_way[6] = {0,0,1,-1,0,0}; const int c_way[6] = {0,0,0,0,1,-1}; vector<vector<int>> clockwise(vector<vector<int>> &v){ vector<vector<int>> turn_board(n,vector<int>(n)); for(int r=0;r<n;r++){ for(int c=0;c<n;c++){ turn_board[r][c] = v[n-c-1][r]; } } return turn_board; } int bfs(vector<vector<vector<int>>> &changed_maze){ if(changed_maze[0][0][0] == 0) return -1; int dist[5][5][5]; queue<pair<int,pair<int,int>>> q; memset(dist,-1,sizeof(dist)); q.push({0,{0,0}}); dist[0][0][0] = 0; while(!q.empty()){ int h = q.front().first; int r = q.front().second.first; int c = q.front().second.second; q.pop(); for(int i=0;i<6;i++){ int h_next = h + h_way[i]; int r_next = r + r_way[i]; int c_next = c + c_way[i]; if(h_next < 0 || h_next >= n || r_next < 0 || r_next >= n || c_next < 0 || c_next >= n) continue; if(changed_maze[h_next][r_next][c_next] == 1 && dist[h_next][r_next][c_next] == -1){ dist[h_next][r_next][c_next] = dist[h][r][c] + 1; q.push({h_next,{r_next,c_next}}); } } } return dist[n-1][n-1][n-1]; } int main(){ int ans = -1; vector<vector<vector<int>>> first_maze(n); for(int h=0;h<n;h++){ first_maze[h].resize(n,vector<int>(n)); for(int r=0;r<n;r++){ for(int c=0;c<n;c++){ scanf("%d",&first_maze[h][r][c]); } } } vector<int> board_num; for(int i=0;i<5;i++){ board_num.push_back(i); } do{ vector<vector<vector<int>>> changed_maze(n); for(int i=0;i<n;i++){ changed_maze[board_num[i]] = first_maze[i]; } for(int t1=0;t1<4;t1++){ for(int t2=0;t2<4;t2++){ for(int t3=0;t3<4;t3++){ for(int t4=0;t4<4;t4++){ for(int t5=0;t5<4;t5++){ int cur_ans = bfs(changed_maze); if(cur_ans != -1){ if(ans == -1 || ans > cur_ans){ ans = cur_ans; } } changed_maze[4] = clockwise(changed_maze[4]); } changed_maze[3] = clockwise(changed_maze[3]); } changed_maze[2] = clockwise(changed_maze[2]); } changed_maze[1] = clockwise(changed_maze[1]); } changed_maze[0] = clockwise(changed_maze[0]); } }while(next_permutation(board_num.begin(),board_num.end())); printf("%d\n",ans); return 0; }
[ "kitsch94@gmail.com" ]
kitsch94@gmail.com
0d62c1a47ac5707d4cd134f64d7ab96128082a03
07fbf3ab32180d94afb1eadd1a8f8ddd657e8656
/NWNXLib/API/Linux/API/CNWCSoundObject.hpp
da01d1d54a510f3fc46ecf884470f6b6e58550b7
[ "MIT" ]
permissive
ELadner/nwnx-unified
3b322e8722eab70c9c72a45e71013b89dbbf1e89
09f8e8a0c1474e8b16d4746f9cb57ca870a17ce5
refs/heads/master
2021-09-04T08:52:06.521478
2018-01-17T13:04:29
2018-01-17T13:04:29
117,771,934
0
0
null
2018-01-17T02:29:14
2018-01-17T02:29:14
null
UTF-8
C++
false
false
141
hpp
#pragma once #include <cstdint> namespace NWNXLib { namespace API { struct CNWCSoundObject { char dummy[1]; }; } }
[ "liarethnwn@gmail.com" ]
liarethnwn@gmail.com
3c53df12770fe916fd57743f683545a7e6658005
692af5a07aa3f7dde83c9c4793a7297a6ea8780b
/Classes/DemoVideoLayer.cpp
104f167aecb99f9bd5912ab2b4a4ba3b3107656b
[]
no_license
w13315071023/DigitGolf_300
5c7886521a83874602a51e9639607df4e2fd98a5
1ed5158bb593044eddb312d43497afe45b87ee6f
refs/heads/master
2020-09-14T11:49:44.549011
2016-11-03T06:34:30
2016-11-03T06:34:30
66,529,287
1
0
null
null
null
null
IBM852
C++
false
false
4,727
cpp
#include "DemoVideoLayer.h" #include "PostureAnalysisScene.h" #include "DataMager.h" DemoVideoLayer* DemoVideoLayer::create(int Direction) { DemoVideoLayer *pRet = new DemoVideoLayer(); if (pRet && pRet->init(Direction)) { pRet->autorelease(); return pRet; } else { delete pRet; pRet = NULL; return NULL; } } DemoVideoLayer::DemoVideoLayer() { } DemoVideoLayer::~DemoVideoLayer() { if (!m_VideoList.empty()) { for (int i = 0;i < m_VideoList.size(); i++) { av_free(m_VideoList[i]); } m_VideoIndex = 0; } } bool DemoVideoLayer::init(int Direction) { if (!CCLayer::init()) { return false; } printf("│§╩╝╗»DemoVideoLayer\n"); videoStream = -1; pCodecCtx = NULL; pFormatCtx = NULL; packet = AVPacket(); m_BitRate = 18000000; m_Direction = Direction; sprintf(outFilePath, SELFVIDEO, Ext_FrameRate, DataMager::shareDataMager()->m_curGender, DataMager::shareDataMager()->m_curCuetype, Direction); filename = new char[64]; if(Ext_IsDemoVideo) { sprintf(filename, DEMOVIDEO, Ext_FrameRate, DataMager::shareDataMager()->m_curGender, DataMager::shareDataMager()->m_curCuetype, Direction); } else { sprintf(filename, SELFVIDEO, Ext_FrameRate, DataMager::shareDataMager()->m_curGender, DataMager::shareDataMager()->m_curCuetype, Direction); } this->LoadVideo(); this->ShowVideo(); CCSprite* beijing2 = CCSprite::create("VideoUI/beijing2.png"); beijing2->setPosition(ccp(VISIBLEW / 2, VISIBLEH / 2)); this->addChild(beijing2); m_pSprite->setPosition(ccp(VISIBLEW / 2, VISIBLEH / 2)); this->addChild(m_pSprite); if(Direction == FRONT) { CCMenuItemImage* pBaocun = CCMenuItemImage::create( "VideoUI/baocun1.png", "VideoUI/baocun2.png", this, menu_selector(PostureAnalysisScene::CallbackSaveVideo)); pBaocun->setPosition(ccp(VISIBLEW / 2+240, VISIBLEH / 2+200)); pBaocun->setRotationX(180); MyMenu* pMenu = MyMenu::create(pBaocun,NULL); pMenu->setPosition(CCPointZero); this->addChild(pMenu); } this->setRotationX(180); return true; } bool DemoVideoLayer::LoadVideo() { av_register_all(); if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0) { sprintf(filename, DEMOVIDEO, Ext_FrameRate, DataMager::shareDataMager()->m_curGender, DataMager::shareDataMager()->m_curCuetype, m_Direction); if(avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0) { CCLog("open"); return false; } } if (avformat_find_stream_info(pFormatCtx, 0) < 0) { CCLog("find"); return false; } for (int i = 0; i < pFormatCtx->nb_streams; i++) if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { videoStream = i; break; } if (videoStream == -1) { CCLog("videoStream"); return false; } pCodecCtx = pFormatCtx->streams[videoStream]->codec; pCodec = avcodec_find_decoder(pCodecCtx->codec_id); if (pCodec == NULL) { CCLog("pCodec"); return false; } if (avcodec_open2(pCodecCtx, pCodec, 0) < 0) { CCLog("pCodecCtx"); return false; } pFrame = av_frame_alloc(); pFrameRGB = av_frame_alloc(); if ((pFrame == NULL) || (pFrameRGB == NULL)) { CCLog("pFrame||pFrameRGB"); return false; } PictureSize = pCodecCtx->width*pCodecCtx->height*3; pSwsCtx = sws_getCachedContext( pSwsCtx, pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_BGR24, SWS_BICUBIC, NULL, NULL, NULL); if (!pSwsCtx) { CCLog("pSwsCtx"); return false; } while (av_read_frame(pFormatCtx, &packet) >= 0) { if (packet.stream_index == videoStream) { avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet); if (frameFinished) { buf = (uint8_t*)av_malloc(PictureSize); avpicture_fill((AVPicture *)pFrameRGB, buf, AV_PIX_FMT_BGR24, pCodecCtx->width, pCodecCtx->height); pFrameRGB->data[0] += pFrameRGB->linesize[0] * (480 - 1); pFrameRGB->linesize[0] *= -1; pFrameRGB->data[1] += pFrameRGB->linesize[1] * (480 / 2 - 1); pFrameRGB->linesize[1] *= -1; pFrameRGB->data[2] += pFrameRGB->linesize[2] * (480 / 2 - 1); pFrameRGB->linesize[2] *= -1; m_Width = pCodecCtx->width; m_Height = pCodecCtx->height; unsigned char* pVideoRGB24 = buf; m_VideoList.push_back(pVideoRGB24); sws_scale( pSwsCtx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize); } } av_packet_unref(&packet); } m_VideoIndex = 0; Ext_VideoSize = m_VideoList.size(); sws_freeContext(pSwsCtx); pSwsCtx = NULL; av_free(pFrame); av_free(pFrameRGB); avcodec_close(pCodecCtx); avformat_close_input(&pFormatCtx); return true; }
[ "764607625@qq.com" ]
764607625@qq.com
b005f91bc6b353d9091f682a3bb2e6103ff935e8
b308f1edaab2be56eb66b7c03b0bf4673621b62f
/Code/CryEngine/CryCommon/CREIrradianceVolume.h
c1325feef2a93e8a8d53b6b251a07f91a31ef3a2
[]
no_license
blockspacer/project-o
14e95aa2692930ee90d098980a7595759a8a1f74
403ec13c10757d7d948eafe9d0a95a7f59285e90
refs/heads/master
2021-05-31T16:46:36.814786
2011-09-16T14:34:07
2011-09-16T14:34:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,409
h
#ifndef _CREIRRADIANCEVOLUME_ #define _CREIRRADIANCEVOLUME_ #pragma once #include "VertexFormats.h" struct SReflectiveShadowMap { Matrix44A mxLightViewProj; ITexture* pDepthRT; ITexture* pNormalRT; ITexture* pColorRT; SReflectiveShadowMap() { mxLightViewProj.SetIdentity(); pDepthRT = NULL; pNormalRT = NULL; pColorRT = NULL; } void Release(); }; class CREIrradianceVolume : public CRendElementBase { protected: friend struct IIrradianceVolumeRenderNode; friend class CIrradianceVolumeRenderNode; friend class CLightPropagationVolume; friend class CIrradianceVolumesManager; private: // injects single texture or colored shadow map with vertex texture fetching void _injectWithVTF(SReflectiveShadowMap& rCSM); // injects single texture or colored shadow map with render to vertex buffer technique void _injectWithR2VB(SReflectiveShadowMap& rCSM); // injects occlusion from camera depth buffer void _injectOcclusionFromCamera(); protected: // injects single light bool InjectAllLightSources(); // injects single light void InjectLight(const CDLight& rLight); // injects single colored shadow map void InjectColorMap(SReflectiveShadowMap& rCSM); // injects occlusion information from depth buffer void InjectOcclusion(SReflectiveShadowMap& rCSM, bool bCamera); // propagates irradiance void Simulate(); // post-injection phase(injection after simulation) bool Postinject(); // post-injects single ready light void PostnjectLight(const CDLight& rLight); // optimizations for faster deferred rendering void ResolveToVolumeTexture(); // smart downsampling filtering for large RSMs void DownsampleRSM(SReflectiveShadowMap& rSourceRSM, SReflectiveShadowMap& rDestRSM); public: // returns irradiance volume id (might be the same as light id for GI volumes) int GetId() const { return m_nId; } ILightSource* GetAttachedLightSource() { return m_pAttachedLightSource; } void AttachLightSource(ILightSource* pLightSource) { m_pAttachedLightSource = pLightSource; } CREIrradianceVolume(); virtual ~CREIrradianceVolume(); // flags for irradiance volume render element enum EFlags { efGIVolume = 1ul<<0, efHasOcclusion = 1ul<<1, }; enum EStaticProperties { espMaxInjectRSMSize = 384ul, }; // irradiance volume render settings struct Settings { Vec3 m_pos; AABB m_bbox; // BBox Matrix44A m_mat; Matrix44A m_matInv; int m_nGridWidth; // grid dimensions in texels int m_nGridHeight; // grid dimensions in texels int m_nGridDepth; // grid dimensions in texels int m_nNumIterations; // number of iterations to propagate Vec4 m_gridDimensions; // grid size Vec4 m_invGridDimensions; // 1.f / (grid size) Settings(); }; // render colored shadowmap to render virtual void RenderReflectiveShadowMap( SReflectiveShadowMap& rRSM ); // query point light source to render virtual void InsertLight( const CDLight &light ); // propagates irradiance void Evaluate(); // apply irradiance to accumulation RT void DeferredApply(ITexture* pDepthRT, ITexture* pNormalRT); // pass only CREIrradianceVolume::EFlags enum flags combination here void SetNewFlags(uint32 nFlags) { m_nGridFlags = nFlags; } // CREIrradianceVolume::EFlags enum flags returned uint32 GetFlags() const { return m_nGridFlags; } virtual void mfPrepare(bool bCheckOverflow); virtual bool mfPreDraw(SShaderPass *sl); virtual bool mfDraw(CShader* ef, SShaderPass* sfm); virtual float mfDistanceToCameraSquared(Matrix34& matInst); void Invalidate() { m_bIsUpToDate = false; } ITexture* GetLPVTexture(int iTex) { assert(iTex < 3); return m_pVolumeTextures[iTex]; } float GetVisibleDistance() const { return m_fDistance; } float GetIntensity() const { return m_fAmount; } // is it applicable to render in the deferred pass? inline bool IsRenderable() const { return m_bIsRenderable; } virtual Settings* GetFillSettings(); virtual void GetMemoryUsage(ICrySizer *pSizer) const { pSizer->AddObject(this, sizeof(*this)); pSizer->AddContainer(m_lightsToInject[0][0]); pSizer->AddContainer(m_lightsToInject[0][1]); pSizer->AddContainer(m_lightsToInject[1][0]); pSizer->AddContainer(m_lightsToInject[1][1]); pSizer->AddContainer(m_lightsToPostinject[0][0]); pSizer->AddContainer(m_lightsToPostinject[0][1]); pSizer->AddContainer(m_lightsToPostinject[1][0]); pSizer->AddContainer(m_lightsToPostinject[1][1]); } const Settings& GetRenderSettings() const; protected: virtual void UpdateRenderParameters(); virtual void EnableSpecular(const bool bEnabled); void Cleanup(); protected: Settings m_Settings[RT_COMMAND_BUF_COUNT]; int m_nId; // unique ID of the volume(need for RTs) uint32 m_nGridFlags; // grid flags float m_fDistance; // max affected distance float m_fAmount; // affection scaler union { ITexture* m_pRT[3]; CTexture* m_pRTex[3]; }; // grid itself union // volume textures { ITexture* m_pVolumeTextures[3]; CTexture* m_pVolumeTexs[3]; }; #if PS3 union // render to volume texture for PS3 { ITexture* m_p2DVolumeUnwraps[3]; CTexture* m_p2DVolumeUnwrapsTex[3]; }; #endif union // volume texture for fuzzy occlusion from depth buffers { ITexture* m_pOcclusionTexture; CTexture* m_pOcclusionTex; }; SReflectiveShadowMap m_downsampledRSM; // for result of RSM downsampling struct IIrradianceVolumeRenderNode* m_pParent; ILightSource* m_pAttachedLightSource; bool m_bIsRenderable; // is the grid not dark? bool m_bNeedPropagate; // is the grid needs to be propagated bool m_bNeedClear; // is the grid needs to be cleared after past frame bool m_bIsUpToDate; // invalidates dimensions bool m_bHasSpecular; // enables specular int m_nUpdateFrameID; // last frame updated typedef DynArray<CDLight> Lights; Lights m_lightsToInject[RT_COMMAND_BUF_COUNT][2]; // lights in the grid Lights m_lightsToPostinject[RT_COMMAND_BUF_COUNT][2]; // lights in the grid }; #endif // #ifndef _CREIRRADIANCEVOLUME_
[ "joe.marty@foreverinteractive.com" ]
joe.marty@foreverinteractive.com
7f5dcb8d5b4535fd8d21ea95565a2da9a902793f
468e1aebec4e7ede1b917f3b37f1516cc7317340
/stdafx.h
ab517fcd813f0180c9a9c9074416eabd55e3436f
[ "Apache-2.0" ]
permissive
ZaprudnovAA/INN
dc20b250b2e80056328c95a90e9870bb9d53217f
532cac3bb24d1f1f410d9820c1dad1d4b1e7ac48
refs/heads/master
2020-03-19T12:34:40.732500
2018-06-07T20:50:32
2018-06-07T20:50:32
136,527,018
0
0
null
null
null
null
UTF-8
C++
false
false
332
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently #pragma once //#include <string> #include <stdlib.h> #include <math.h> #include <ctime> using namespace std; // TODO: reference additional headers your program requires here
[ "aleksey.zaprudnov@yandex.ru" ]
aleksey.zaprudnov@yandex.ru
0bfd92aafe58e5c04c1fe7e7241c113f6c05040d
2dd571c2d8b30d5d0c4fcb0beaf9e762dbd4174a
/ui_popup/widget.h
9c20c23a9d214fa9086f5bd5fc61a01834160071
[]
no_license
Baiyun-u-smartAI/QT
5e43af83828f12dc2f1048fe73a6822f75600275
58c73820be82fe837f26bc2c81918ea575b4d27a
refs/heads/master
2023-04-27T09:30:39.169330
2023-04-26T01:03:39
2023-04-26T01:03:39
167,105,787
0
0
null
null
null
null
UTF-8
C++
false
false
398
h
#ifndef WIDGET_H #define WIDGET_H #include "pop_up.h" #include <QWidget> QT_BEGIN_NAMESPACE namespace Ui { class Widget; } QT_END_NAMESPACE class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private slots: void on_pushButton_clicked(); private: Ui::Widget *ui; pop_up *ui2; }; #endif // WIDGET_H
[ "noreply@github.com" ]
noreply@github.com
1b9bdd0670cf3a0e0ab70648370181dddc110a44
4547de36c8ab3799dfd5f4f02d092e4b30b84a01
/C/Assignment 2/Assignment 2/Source.cpp
80aa2802b283c9061e507e5fe419128d29125f85
[]
no_license
Tainted-Fool/Portfolio
f5c59c2127b3f2608eb842308225f54013c32f7d
d3166afd9594389128c6eb6fecbea6befde0a3a5
refs/heads/master
2021-01-23T01:07:27.217590
2017-03-24T01:12:04
2017-03-24T01:12:04
85,873,280
0
0
null
null
null
null
UTF-8
C++
false
false
2,223
cpp
/* Author's Name: Lazaro A Herrera Date: June 23, 2014 Program: Assignment 3 College Name: Long Beach City College (LBCC) */ //Libraries #include <iostream> #include <string> #include <iomanip> using namespace std; int main() { //Variables int id = int (); string fname = string (); string lname = string (); char grade = char (); double average = double (); double total = double (); double CS11 = double (); double CS12 = double (); double CS21 = double (); //Heading cout << "======================================" << endl; cout << "Student Grading System (SGS)" << endl; cout << "Long Beach City College" << endl; cout << "Author: Lazaro A Herrera" << endl; cout << "Date: June 23, 2014" << endl; cout << "======================================\n" << endl; //User input cout << "======================================" << endl; cout << "Please enter ID: "; cin >> id; cout << "Please enter First Name: "; cin >> fname; cout << "Please enter Last Name: "; cin >> lname; cout << "Please enter points for CS11: "; cin >> CS11; cout << "Please enter points for CS12: "; cin >> CS12; cout << "Please enter points for CS21: "; cin >> CS21; cout << "======================================\n" << endl; //Processing total = CS11 + CS12 + CS21; average = (CS11 + CS12 + CS21) / 3; if (average >= 90) { grade = 'A'; } else if (average >= 80) { grade = 'B'; } else if (average >= 70) { grade = 'C'; } else if (average >= 60) { grade = 'D'; } else if (average < 60) { grade = 'F'; } //Output cout << fixed << setprecision(2); cout << "======================================" << endl; cout << "ID: " << id << endl; cout << "First Name: " << fname << endl; cout << "Last Name: " << lname << endl; cout << "Total: " << total << endl; cout << "Average: " << average << "%" << endl; cout << "Grade: " << grade << endl; if (average >= 90) { cout << "Comment: Congratulations!" << endl; } else if (average < 60) { cout << "Comment: Maybe this isn't your best subject" << endl; } cout << "======================================\n" << endl; return 0; }
[ "noreply@github.com" ]
noreply@github.com
20a075d6e903686d9a3d13d3aaa4bf1914b7d377
5715eef01e82ea825e5b2e090fbba7cdd4f3bb81
/include/locking/type_traits.hpp
68d9d8ddd80b3283148833a42a5280650000c9bc
[]
no_license
Gregory-Meyer/locking
d408e940ffa89e87c5f128632b408dd0aabc75d0
cf5583082435b1b84ec1573835ec40d9d6d14a0e
refs/heads/master
2020-03-27T08:02:18.058685
2018-08-26T20:37:13
2018-08-26T20:37:13
146,214,684
0
0
null
null
null
null
UTF-8
C++
false
false
2,951
hpp
// BSD 3-Clause License // // Copyright (c) 2018, Gregory Meyer // 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 reproducne the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #ifndef LOCKING_TYPE_TRAITS_HPP #define LOCKING_TYPE_TRAITS_HPP #include <locking/detail/type_traits.hpp> #include <type_traits> namespace locking { // https://en.cppreference.com/w/cpp/named_req/BasicLockable template <typename T> struct IsBasicLockable : detail::IsBasicLockableHelper<T>::Type { }; template <typename T> inline constexpr bool IS_BASIC_LOCKABLE = IsBasicLockable<T>::value; // https://en.cppreference.com/w/cpp/named_req/Lockable template <typename T> struct IsLockable : detail::IsLockableHelper<T>::Type { }; template <typename T> inline constexpr bool IS_LOCKABLE = IsLockable<T>::value; // https://en.cppreference.com/w/cpp/named_req/Mutex template <typename T> struct IsMutex : detail::IsMutexHelper<T>::Type { }; template <typename T> inline constexpr bool IS_MUTEX = IsMutex<T>::value; template <typename T> struct IsArithmetic : detail::IsArithmetic<T> { }; template <typename T> inline constexpr bool IS_ARITHMETIC = IsArithmetic<T>::value; template <typename T> struct IsRatio : detail::IsRatio<T> { }; template <typename T> inline constexpr bool IS_RATIO = IsRatio<T>::value; // https://en.cppreference.com/w/cpp/named_req/Clock template <typename T> struct IsClock : detail::IsClockHelper<T>::Type { }; template <typename T> inline constexpr bool IS_CLOCK = IsClock<T>::value; } // namespace locking #endif
[ "gregjm@umich.edu" ]
gregjm@umich.edu
fc4571bd57a91be76d1a4a0132a3a0f8247a6829
9c7c58220a546d583e22f8737a59e7cc8bb206e6
/Project/MyProject/MyProject/Source/MyProject/Private/BaseFrame/Libs/Render/RenderTargetMgr.cpp
b03b2a7232b9f351f3ac5a2ad2e66eda137b7ead
[]
no_license
SiCoYu/UE
7176f9ece890e226f21cf972e5da4c3c4c4bfe41
31722c056d40ad362e5c4a0cba53b05f51a19324
refs/heads/master
2021-03-08T05:00:32.137142
2019-07-03T12:20:25
2019-07-03T12:20:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
97
cpp
#include "MyProject.h" #include "RenderTargetMgr.h" MY_BEGIN_NAMESPACE(MyNS) MY_END_NAMESPACE
[ "kuangben2001@163.com" ]
kuangben2001@163.com
d03ad08061fdf8ec88f5066317d7488f81903ce4
4e5f65e2d56ba5753cbf85f50e53c8e04e49ba31
/src/XCVML1TailProb_NE1.h
aaa116c136356efd5b7fdc9a4ce8fe391ad437b7
[]
no_license
cran/CvM2SL1Test
6ec004b2cf77c372ada0574749a716bca170a744
29c6466787fd3a865a3d989e6d97c8a6dce88496
refs/heads/master
2020-05-20T01:33:38.715603
2012-01-02T00:00:00
2012-01-02T00:00:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
781
h
/** Class CXCVMTailProb_EQ: Compute the tail probability for given (L1-version) Cramer-von Mises test score for the case m+n is even but m != n. Author: Yuanhui Xiao Revised date: 09/05/2008 Copyright (c) 2008 Yuanhui Xiao */ #include "XCVML1TailProb.h" #include "XFreqFunct.h" #ifndef CXCVMTailProb_NE1_H #define CXCVMTailProb_NE1_H class CXCVMTailProb_NE1 : public CXCVMTailProb { public: CXCVMTailProb_NE1(int nA, int nB); // constructor virtual const double operator()(const double cvm) const; // compute the tail probability for given cvm virtual const double operator()(const int64_t Q) const; // compute the tail frequence for given Q }; #endif
[ "csardi.gabor@gmail.com" ]
csardi.gabor@gmail.com
68a0525a1b5deb089a5d359268d6008b4144adc0
3b722b33cc3d0f1e6c8588c38ebdf6bba49b1cf4
/JanuaryLong/partation3.cpp
5cb64dac0826245d004288c7af9fce4ac2848948
[]
no_license
captabhi/CodechefArchive
beca0b429653786b8b432c009217d6b0e3b64ffd
69877392e9e1784d63be17e414be0d4fdfddcb76
refs/heads/master
2020-08-12T23:48:46.755406
2019-10-13T18:07:03
2019-10-13T18:07:03
214,867,456
0
0
null
null
null
null
UTF-8
C++
false
false
2,751
cpp
#include <bits/stdc++.h> using namespace std; bool isKPartitionPossibleRec(int arr[], int subsetSum[], bool taken[], int subset, int K, int N, int curIdx, int limitIdx) { if (subsetSum[curIdx] == subset) { /* current index (K - 2) represents (K - 1) subsets of equal sum last partition will already remain with sum 'subset'*/ if (curIdx == K - 2) return true; // recursive call for next subsetition return isKPartitionPossibleRec(arr, subsetSum, taken, subset, K, N, curIdx + 1, N - 1); } // start from limitIdx and include elements into current partition for (int i = limitIdx; i >= 0; i--) { // if already taken, continue if (taken[i]) continue; int tmp = subsetSum[curIdx] + arr[i]; // if temp is less than subset then only include the element // and call recursively if (tmp <= subset) { // mark the element and include into current partition sum taken[i] = true; subsetSum[curIdx] += arr[i]; bool nxt = isKPartitionPossibleRec(arr, subsetSum, taken, subset, K, N, curIdx, i - 1); // after recursive call unmark the element and remove from // subsetition sum taken[i] = false; subsetSum[curIdx] -= arr[i]; if (nxt) return true; } } return false; } // Method returns true if arr can be partitioned into K subsets // with equal sum bool isKPartitionPossible(int arr[], int N, int K) { // If K is 1, then complete array will be our answer if (K == 1) return true; // If total number of partitions are more than N, then // division is not possible if (N < K) return false; // if array sum is not divisible by K then we can't divide // array into K partitions int sum = 0; for (int i = 0; i < N; i++) sum += arr[i]; if (sum % K != 0) return false; // the sum of each subset should be subset (= sum / K) int subset = sum / K; int subsetSum[K]; bool taken[N]; // Initialize sum of each subset from 0 for (int i = 0; i < K; i++) subsetSum[i] = 0; // mark all elements as not taken for (int i = 0; i < N; i++) taken[i] = false; // initialize first subsubset sum as last element of // array and mark that as taken subsetSum[0] = arr[N - 1]; taken[N - 1] = true; // call recursive method to check K-substitution condition return isKPartitionPossibleRec(arr, subsetSum, taken, subset, K, N, 0, N - 1); } // Driver code to test above methods int main() { int arr[] = {2, 1, 4, 5, 3, 3}; int N = sizeof(arr) / sizeof(arr[0]); int K = 2; if (isKPartitionPossible(arr, N, K)) cout << "Partitions into equal sum is possible.\n"; else cout << "Partitions into equal sum is not possible.\n"; }
[ "abhishek09021998@gmail.com" ]
abhishek09021998@gmail.com
e5b84c532c87a77dc7d90e434f951af97aa9d8e0
71984558bc6b07a292f330398150b41eb75ab8b5
/src/qt/intro.h
44f0045e056b2df798a6b367348f6f4b59932d78
[ "MIT" ]
permissive
Deviantcoin/Scamar
261fdc52215a445fba04a615f7f4320076b57a95
26819c4776f15578ef7df8900acb67e2f2c9cf8b
refs/heads/master
2020-03-25T10:50:07.515178
2018-08-05T10:00:43
2018-08-05T10:00:43
143,707,201
1
0
MIT
2018-08-06T09:36:16
2018-08-06T09:36:16
null
UTF-8
C++
false
false
1,980
h
// Copyright (c) 2011-2013 The Bitcoin developers // Copyright (c) 2017 The PIVX developers // Copyright (c) 2017 The Scamar developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_QT_INTRO_H #define BITCOIN_QT_INTRO_H #include <QDialog> #include <QMutex> #include <QThread> static const bool DEFAULT_CHOOSE_DATADIR = false; class FreespaceChecker; namespace Ui { class Intro; } /** Introduction screen (pre-GUI startup). Allows the user to choose a data directory, in which the wallet and block chain will be stored. */ class Intro : public QDialog { Q_OBJECT public: explicit Intro(QWidget* parent = 0); ~Intro(); QString getDataDirectory(); void setDataDirectory(const QString& dataDir); /** * Determine data directory. Let the user choose if the current one doesn't exist. * * @returns true if a data directory was selected, false if the user cancelled the selection * dialog. * * @note do NOT call global GetDataDir() before calling this function, this * will cause the wrong path to be cached. */ static bool pickDataDirectory(); /** * Determine default data directory for operating system. */ static QString getDefaultDataDirectory(); signals: void requestCheck(); void stopThread(); public slots: void setStatus(int status, const QString& message, quint64 bytesAvailable); private slots: void on_dataDirectory_textChanged(const QString& arg1); void on_ellipsisButton_clicked(); void on_dataDirDefault_clicked(); void on_dataDirCustom_clicked(); private: Ui::Intro* ui; QThread* thread; QMutex mutex; bool signalled; QString pathToCheck; void startThread(); void checkPath(const QString& dataDir); QString getPathToCheck(); friend class FreespaceChecker; }; #endif // BITCOIN_QT_INTRO_H
[ "utente@jupiter" ]
utente@jupiter
a588a697b44626fd6805a8371d6fbd48ff18681a
cc7ed96be6cac240eb485241d761f6fad094a821
/Network.h
6e6a3fe048e5f75e9c660f62970376b0d3cf4288
[]
no_license
bean-harry/Multi-Agent-Model
a23a5eb5aad344ca98dbf6056bf7135519c4bd1d
20871644fc4c7635424a235bdb7346f273c4e40f
refs/heads/master
2020-03-30T16:35:59.920748
2018-11-23T13:10:08
2018-11-23T13:10:08
151,416,764
0
0
null
2018-11-23T12:13:50
2018-10-03T13:26:44
Makefile
UTF-8
C++
false
false
2,454
h
/* Network.h */ #ifndef DEMO_02_NETWORK #define DEMO_02_NETWORK #include "repast_hpc/SharedContext.h" #include "repast_hpc/SharedNetwork.h" /* Custom Network Components */ template<typename V> class DemoModelCustomEdge : public repast::RepastEdge<V>{ private: int confidence; public: DemoModelCustomEdge(){} DemoModelCustomEdge(V* source, V* target) : repast::RepastEdge<V>(source, target) {} DemoModelCustomEdge(V* source, V* target, double weight) : repast::RepastEdge<V>(source, target, weight) {} DemoModelCustomEdge(V* source, V* target, double weight, int confidence) : repast::RepastEdge<V>(source, target, weight), confidence(confidence) {} DemoModelCustomEdge(boost::shared_ptr<V> source, boost::shared_ptr<V> target) : repast::RepastEdge<V>(source, target) {} DemoModelCustomEdge(boost::shared_ptr<V> source, boost::shared_ptr<V> target, double weight) : repast::RepastEdge<V>(source, target, weight) {} DemoModelCustomEdge(boost::shared_ptr<V> source, boost::shared_ptr<V> target, double weight, int confidence) : repast::RepastEdge<V>(source, target, weight), confidence(confidence) {} int getConfidence(){ return confidence; } void setConfidence(int con){ confidence = con; } }; /* Custom Edge Content */ template<typename V> struct DemoModelCustomEdgeContent : public repast::RepastEdgeContent<V>{ friend class boost::serialization::access; public: int confidence; DemoModelCustomEdgeContent(){} DemoModelCustomEdgeContent(DemoModelCustomEdge<V>* edge): repast::RepastEdgeContent<V>(edge), confidence(edge->getConfidence()){} template<class Archive> void serialize(Archive& ar, const unsigned int version) { repast::RepastEdgeContent<V>::serialize(ar, version); ar & confidence; } }; /* Custome Edge Content Manager */ template<typename V> class DemoModelCustomEdgeContentManager { public: DemoModelCustomEdgeContentManager(){} virtual ~DemoModelCustomEdgeContentManager(){} DemoModelCustomEdge<V>* createEdge(DemoModelCustomEdgeContent<V>& content, repast::Context<V>* context){ return new DemoModelCustomEdge<V>(context->getAgent(content.source), context->getAgent(content.target), content.weight, content.confidence); } DemoModelCustomEdgeContent<V>* provideEdgeContent(DemoModelCustomEdge<V>* edge){ return new DemoModelCustomEdgeContent<V>(edge); } }; #endif
[ "noreply@github.com" ]
noreply@github.com
65d63f730627c09848523eb5fe54bbb12f685b47
a702f4acc7067cbb5cc2b7570e8132ed15e1e495
/src/Human.cpp
77aedbeadb2d63f340475a564453ee220cdb593b
[ "MIT" ]
permissive
kosmaz/ChessGame
0e6dc1777704b6e3ae3195560c64dff96c521f91
a04d924b8c106b5c38e957cb1e36de5f5582e7b3
refs/heads/master
2021-01-12T00:12:43.959348
2017-01-26T12:36:18
2017-01-26T12:36:18
78,683,237
2
0
null
null
null
null
UTF-8
C++
false
false
2,291
cpp
#include "GuiDisplay.hpp" #include "Human.hpp" using namespace std; Human::Human(int color, string name, GuiDisplay* display):Player(color,name),fDisplay(display){} Human::Human(const Human& source):Player(source){} Human::~Human(){} string Human::requestCommand() { string command; #ifdef DEBUG while(!checkCommand(command)) getline(cin,command); if(command.size()==4) { for(int i=0; i<4; ++i) if(isalpha(command.at(i))) if(isupper(command.at(i))) command.at(i)=tolower(command.at(i)); } #else command=fDisplay->requestCommand(); #endif fLast_Command=command; return command; } int Human::requestPromotion() { int promote=-1; #ifdef DEBUG char handle; cout<<"which Piece should this pawn be promoted to?\n\n"; cout<<"1.\tKnight\n"; cout<<"2.\tBishop\n"; cout<<"3.\tRook\n"; cout<<"4.\tQueen\n"; cin>>handle; while(!isdigit(handle) || (handle-49)>4 || (handle-49)<1) cin>>handle; promote=handle-49; #else promote=fDisplay->requestPromotion(); #endif return promote; } bool Human::checkCommand(string& command) { bool valid=false; #ifdef DEBUG if(command.size()==4) { if(isalpha(command.at(0)) && isdigit(command.at(1))) { if((toupper(command.at(0))<='H' && toupper(command.at(0))>='A') && toupper(command.at(2))<='H' && toupper(command.at(2))>='A') if(isdigit(command.at(1)) && isdigit(command.at(3))) if((command.at(1)<='8' && command.at(3)>='1') && (command.at(1)<='8' && command.at(3)>='1')) valid=true; } else if((command.size()==4) && toupper(command.at(0))=='Q' && toupper(command.at(1))=='U' && toupper(command.at(2))=='I' && toupper(command.at(3))=='T') valid=true; } #else chessPiece from((int)command.at(0)-'a',(int)command.at(1)-49,-1); for(vector<chessPiece>::iterator it=fPiece->begin(); it!=fPiece->end(); ++it) if(*it==from) { valid=true; break; } #endif return valid; }
[ "ezenwanne_cosmas@yahoo.com" ]
ezenwanne_cosmas@yahoo.com
65a29fb217a3698ffb13cf8da966636d9ce97cd9
85fab2c72d00d45371605e0949d8fd9caeba55fd
/lab 2/3.cpp
e733439c349c0401a74d8dfe6116b57de3825d9a
[]
no_license
SyedShafkatulHassan/Computer-Algorithms-and-Complexity-Assignmentnt
cecaf2eb779703bd32e701bf0bbf35897a1ba2e5
e5ceb3ab8ea9134ca1516aece17295eb7fc524ff
refs/heads/main
2023-08-06T08:52:39.341308
2021-10-14T09:31:49
2021-10-14T09:31:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,189
cpp
#include <bits/stdc++.h> using namespace std; int A[1000],B[1000]; #define pb push_back; int fib1[10000]= {-1}; int p=0; string d; int dp[1000][1000]; string s1,s2; int main() { int n, arr[1000], k[1000], ami[1000],high,s= -1; memset(ami, -1, sizeof ami); cout<<"Enter total number of element : "; cin >> n; cout<<"Enter elements of array : "; for(int i = 1; i <= n; i++) { cin>>arr[i]; } for(int i = 1; i <= n; i++) { for(int j = i + 1; j <= n; j++) { if(arr[j]>=arr[i]) { if(k[j] < k[i] + 1) { k[j] = k[i] + 1; if(k[j]>high) { high = k[j]; s = j; } ami[j] = i; } } } } int ar[1000]; int o=0; while(s>0) { o++; ar[o]=arr[s]; s = ami[s]; } cout<<"Longest Non-Decreaing Subsequence length is: "; cout<<o<<endl; cout<<"Longest Non-Decreaing Subsequence : "; for(int i=o;i>=1;i--) { cout<<ar[i]<< " "; } }
[ "syedshafkatulhassan@gmail.com" ]
syedshafkatulhassan@gmail.com
5a32f8fd4ba8b51a6ae012cd610f61b4f9f12db3
7d71fa3604d4b0538f19ed284bc5c7d8b52515d2
/Clients/AG/Orig C&P Sources/Source Copy 1/StoneHnd/SCPOLYGO.CPP
56a8959d43af00aba6e2f416f8a67db3abcbf39e
[]
no_license
lineCode/ArchiveGit
18e5ddca06330018e4be8ab28c252af3220efdad
f9cf965cb7946faa91b64e95fbcf8ad47f438e8b
refs/heads/master
2020-12-02T09:59:37.220257
2016-01-20T23:55:26
2016-01-20T23:55:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,330
cpp
/***************************************************************************** File: SCPOLYGO.C $Header: /Projects/Toolbox/ct/SCPOLYGO.CPP 2 5/30/97 8:45a Wmanis $ Contains: Polygon code. Written by: Manis Copyright (c) 1989-94 Stonehand Inc., of Cambridge, MA. All rights reserved. This notice is intended as a precaution against inadvertent publication and does not constitute an admission or acknowledgment that publication has occurred or constitute a waiver of confidentiality. Composition Toolbox software is the proprietary and confidential property of Stonehand Inc. *****************************************************************************/ #include "scpolygo.h" #include "scmem.h" #include "scfileio.h" /* ==================================================================== */ void POLYDuplicate( scVertHandle* dstOutHP, ushort& dstNumVerts, scVertHandle srcOutH, ushort srcNumVerts ) { scVertex* srcVert; scVertex* dstVert; *dstOutHP = (scVertHandle)MEMAllocHnd( (size_t)srcNumVerts * sizeof(scVertex) ); scAutoUnlock h1( *dstOutHP ); scAutoUnlock h2( srcOutH ); dstVert = (scVertex*)*h1; srcVert = (scVertex*)*h2; SCmemcpy( dstVert, srcVert, srcNumVerts * sizeof( scVertex ) ); dstNumVerts = srcNumVerts; } /* ==================================================================== */ ushort POLYCountVerts( const scVertex* verts ) { ushort numVerts; for ( numVerts = 1; verts->fPointType != eFinalPoint; verts++, numVerts++ ) ; return numVerts; } /* ==================================================================== */ MicroPoint POLYMaxDepth( scVertHandle vertH ) { scVertex* verts; MicroPoint maxDepth = LONG_MIN, minHeight = LONG_MAX; scAutoUnlock h( vertH ); verts = (scVertex*)*h; for ( ; verts->fPointType != eFinalPoint; verts++ ) { maxDepth = MAX( maxDepth, verts->y ); minHeight = MIN( minHeight, verts->y ); } return minHeight < 0 ? maxDepth - minHeight : maxDepth; } /* ==================================================================== */ long POLYExternalSize( scVertHandle vertH, long size ) { return size * sizeof( scVertex ); } /* ==================================================================== */ void POLYtoFile( APPCtxPtr ctxPtr, IOFuncPtr writeFunc, scVertHandle vertH, ushort size ) { scVertex* verts; long xsize = POLYExternalSize( vertH, size ); scAutoUnlock h( vertH ); verts = (scVertex*)*h; // SCPIO_WritePolygon( ctxPtr, writeFunc, verts, (size_t)size ); } /* ==================================================================== */ scVertHandle POLYfromFile( APPCtxPtr ctxPtr, IOFuncPtr readFunc, ushort size ) { scVertHandle volatile vertH = 0; scVertex* verts; vertH = (scVertHandle)MEMAllocHnd( (size_t)size * sizeof( scVertex ) ); try { scAutoUnlock h( vertH ); verts = (scVertex*)*h; // SCPIO_ReadPolygon( ctxPtr, readFunc, verts, (size_t)size ); } catch ( ... ) { MEMFreeHnd( vertH ); throw; } return vertH; } /* ==================================================================== */
[ "jim@facetofacesoftware.com" ]
jim@facetofacesoftware.com
e89f0585e0d3cc2cd6497026442c0a4df9653a05
54fe41af3e81784ebecbd0cc6d82cc017726b5a7
/include/model.h
d56b8c6ba9afd06e470684abc0bba5b343efee95
[]
no_license
ilj900/LearnOpenglLessons
5acd7fde3c9d0edd33bd54ae8b6ae8576d557afd
07526902cdf1e79dc974a1d7f77ce76e5c62db33
refs/heads/master
2021-04-18T18:35:03.851687
2019-03-13T19:12:17
2019-03-13T19:12:17
126,241,241
0
0
null
null
null
null
UTF-8
C++
false
false
979
h
#ifndef MODEL_H #define MODEL_H #include <glad.h> #include <assimp/Importer.hpp> #include <assimp/scene.h> #include <assimp/postprocess.h> #include <mesh.h> unsigned int TextureFromFile(std::string path, std::string directory, bool gamma = false); unsigned int loadCubemap(std::string path, std::vector<std::string> faces, bool gamma = false); class Model { public: std::vector<Texture> textures_loaded; std::vector<Mesh> meshes; std::string directory; bool gammaCorrection; Model(std::string path, bool gamma = false); void Draw(std::string shaderName); void DrawTextureless(std::string shaderName); void Draw(std::string shaderName, unsigned int nrOfInstances); private: void loadModel(std::string path); void processNode(aiNode *node, const aiScene *scene); Mesh processMesh(aiMesh *mesh, const aiScene *scene); std::vector<Texture> loadMaterialTextures(aiMaterial *mat, aiTextureType type, std::string typeName); }; #endif
[ "ilj900@gmail.com" ]
ilj900@gmail.com
b541772a479adb931cacd22e0aca84afa896505b
e9a8f00bce09954668fb3f84382bc29397c78965
/src/qt/skullcash.cpp
100b0259824e507f1bd9410e82c3c2ed3a01298c
[ "MIT" ]
permissive
SkullCash/SkullCash
4b7dec25759d9012abfae0f678bcaed982a2d49f
7d8d87b4a6a24e9768d667b45e31d51e5cea1cd1
refs/heads/master
2020-03-23T04:51:38.559112
2018-07-16T08:30:12
2018-07-16T08:30:12
141,109,595
0
0
null
null
null
null
UTF-8
C++
false
false
10,802
cpp
/* * W.J. van der Laan 2011-2012 */ #include <QApplication> #include "skullcashgui.h" #include "clientmodel.h" #include "walletmodel.h" #include "optionsmodel.h" #include "guiutil.h" #include "guiconstants.h" #include "init.h" #include "util.h" #include "wallet.h" #include "ui_interface.h" #include "paymentserver.h" #ifdef Q_OS_MAC #include "macdockiconhandler.h" #endif #include <QMessageBox> #include <QTextCodec> #include <QLocale> #include <QTimer> #include <QTranslator> #include <QSplashScreen> #include <QLibraryInfo> #if defined(SKULL_NEED_QT_PLUGINS) && !defined(_SKULL_QT_PLUGINS_INCLUDED) #define _SKULL_QT_PLUGINS_INCLUDED #define __INSURE__ #include <QtPlugin> Q_IMPORT_PLUGIN(qcncodecs) Q_IMPORT_PLUGIN(qjpcodecs) Q_IMPORT_PLUGIN(qtwcodecs) Q_IMPORT_PLUGIN(qkrcodecs) Q_IMPORT_PLUGIN(qtaccessiblewidgets) #endif // Need a global reference for the notifications to find the GUI static SkullCashGUI *guiref; static QSplashScreen *splashref; static void ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) { // Message from network thread if(guiref) { bool modal = (style & CClientUIInterface::MODAL); // In case of modal message, use blocking connection to wait for user to click a button QMetaObject::invokeMethod(guiref, "message", modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection, Q_ARG(QString, QString::fromStdString(caption)), Q_ARG(QString, QString::fromStdString(message)), Q_ARG(bool, modal), Q_ARG(unsigned int, style)); } else { LogPrintf("%s: %s\n", caption, message); fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str()); } } static bool ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCaption) { if(!guiref) return false; if(nFeeRequired < MIN_TX_FEE || nFeeRequired <= nTransactionFee || fDaemon) return true; bool payFee = false; QMetaObject::invokeMethod(guiref, "askFee", GUIUtil::blockingGUIThreadConnection(), Q_ARG(qint64, nFeeRequired), Q_ARG(bool*, &payFee)); return payFee; } static void InitMessage(const std::string &message) { if(splashref) { splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(232,186,63)); QApplication::instance()->processEvents(); } LogPrintf("init message: %s\n", message); } /* Translate string to current locale using Qt. */ static std::string Translate(const char* psz) { return QCoreApplication::translate("skullcash-core", psz).toStdString(); } /* Handle runaway exceptions. Shows a message box with the problem and quits the program. */ static void handleRunawayException(std::exception *e) { PrintExceptionContinue(e, "Runaway exception"); QMessageBox::critical(0, "Runaway exception", SkullCashGUI::tr("A fatal error occurred. SkullCash can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning)); exit(1); } /* qDebug() message handler --> debug.log */ #if QT_VERSION < 0x050000 void DebugMessageHandler(QtMsgType type, const char * msg) { const char *category = (type == QtDebugMsg) ? "qt" : NULL; LogPrint(category, "GUI: %s\n", msg); } #else void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg) { const char *category = (type == QtDebugMsg) ? "qt" : NULL; LogPrint(category, "GUI: %s\n", msg.toStdString()); } #endif #ifndef SKULL_QT_TEST int main(int argc, char *argv[]) { fHaveGUI = true; // Command-line options take precedence: ParseParameters(argc, argv); #if QT_VERSION < 0x050000 // Internal string conversion is all UTF-8 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForTr()); #endif Q_INIT_RESOURCE(skullcash); QApplication app(argc, argv); // Do this early as we don't want to bother initializing if we are just calling IPC // ... but do it after creating app, so QCoreApplication::arguments is initialized: if (PaymentServer::ipcSendCommandLine()) exit(0); PaymentServer* paymentServer = new PaymentServer(&app); // Install global event filter that makes sure that long tooltips can be word-wrapped app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app)); // Install qDebug() message handler to route to debug.log #if QT_VERSION < 0x050000 qInstallMsgHandler(DebugMessageHandler); #else qInstallMessageHandler(DebugMessageHandler); #endif // Command-line options take precedence: ParseParameters(argc, argv); // ... then skullcash.conf: if (!boost::filesystem::is_directory(GetDataDir(false))) { // This message can not be translated, as translation is not initialized yet // (which not yet possible because lang=XX can be overridden in skullcash.conf in the data directory) QMessageBox::critical(0, "SkullCash", QString("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"]))); return 1; } ReadConfigFile(mapArgs, mapMultiArgs); // Application identification (must be set before OptionsModel is initialized, // as it is used to locate QSettings) app.setOrganizationName("SkullCash"); //XXX app.setOrganizationDomain(""); if(GetBoolArg("-testnet", false)) // Separate UI settings for testnet app.setApplicationName("SkullCash-Qt-testnet"); else app.setApplicationName("SkullCash-Qt"); // ... then GUI settings: OptionsModel optionsModel; // Get desired locale (e.g. "de_DE") from command line or use system locale QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString())); QString lang = lang_territory; // Convert to "de" only by truncating "_DE" lang.truncate(lang_territory.lastIndexOf('_')); QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator; // Load language files for configured locale: // - First load the translator for the base language, without territory // - Then load the more specific locale translator // Load e.g. qt_de.qm if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) app.installTranslator(&qtTranslatorBase); // Load e.g. qt_de_DE.qm if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) app.installTranslator(&qtTranslator); // Load e.g. skullcash_de.qm (shortcut "de" needs to be defined in skullcash.qrc) if (translatorBase.load(lang, ":/translations/")) app.installTranslator(&translatorBase); // Load e.g. skullcash_de_DE.qm (shortcut "de_DE" needs to be defined in skullcash.qrc) if (translator.load(lang_territory, ":/translations/")) app.installTranslator(&translator); // Subscribe to global signals from core uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox); uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee); uiInterface.InitMessage.connect(InitMessage); uiInterface.Translate.connect(Translate); // Show help message immediately after parsing command-line options (for "-lang") and setting locale, // but before showing splash screen. if (mapArgs.count("-?") || mapArgs.count("--help")) { GUIUtil::HelpMessageBox help; help.showOrPrint(); return 1; } #ifdef Q_OS_MAC // on mac, also change the icon now because it would look strange to have a testnet splash (green) and a std app icon (orange) if(GetBoolArg("-testnet", false)) { MacDockIconHandler::instance()->setIcon(QIcon(":icons/skullcash_testnet")); } #endif QSplashScreen splash(QPixmap(":/images/splash"), 0); if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false)) { splash.show(); splashref = &splash; } app.processEvents(); app.setQuitOnLastWindowClosed(false); try { if (fUseBlackTheme) GUIUtil::SetBlackThemeQSS(app); // Regenerate startup link, to fix links to old versions if (GUIUtil::GetStartOnSystemStartup()) GUIUtil::SetStartOnSystemStartup(true); boost::thread_group threadGroup; SkullCashGUI window; guiref = &window; QTimer* pollShutdownTimer = new QTimer(guiref); QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown())); pollShutdownTimer->start(200); if(AppInit2(threadGroup)) { { // Put this in a block, so that the Model objects are cleaned up before // calling Shutdown(). paymentServer->setOptionsModel(&optionsModel); if (splashref) splash.finish(&window); ClientModel clientModel(&optionsModel); WalletModel walletModel(pwalletMain, &optionsModel); window.setClientModel(&clientModel); window.setWalletModel(&walletModel); // If -min option passed, start window minimized. if(GetBoolArg("-min", false)) { window.showMinimized(); } else { window.show(); } // Now that initialization/startup is done, process any command-line // skullcash: URIs QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString))); QTimer::singleShot(100, paymentServer, SLOT(uiReady())); app.exec(); window.hide(); window.setClientModel(0); window.setWalletModel(0); guiref = 0; } // Shutdown the core and its threads, but don't exit SkullCash-Qt here threadGroup.interrupt_all(); threadGroup.join_all(); Shutdown(); } else { threadGroup.interrupt_all(); threadGroup.join_all(); Shutdown(); return 1; } } catch (std::exception& e) { handleRunawayException(&e); } catch (...) { handleRunawayException(NULL); } return 0; } #endif // SKULL_QT_TEST
[ "skullcash@users.noreply.github.com" ]
skullcash@users.noreply.github.com
9cbf7c88bd7c4229fd0cb8d5eb7b0b1eee9bc1ff
2e1bb397e3356dcdc3b3b1f2bfdbb4ee12ebb736
/revision/second1617/q5.cpp
4a5d75b6b9dd3d9143bc553fae5617629ee35da7
[]
no_license
neonestoras/Prog-2-Cpp
b0c2fe168b52b4b011e442a61246572af44000bf
56261427d346b1a3e042305b606dc9c63f716fb9
refs/heads/master
2020-08-31T20:40:22.222448
2020-02-11T00:57:28
2020-02-11T00:57:28
218,780,612
0
0
null
null
null
null
UTF-8
C++
false
false
1,491
cpp
#include <iostream> #include <vector> #include <string> using namespace std; class RNA { private: vector<char> seq; public: RNA(){seq="";} RNA(RNA& in) { for (int i=0;i<in->seq.size();i++) seq.push_back(in->seq[i]); } RNA(string seq_in) { for (int i=0;i<seq_in.size();i++) seq.push_back(seq_in[i]); } ~RNA(){} vector<char> get_sequence() { this->seq; } void set_sequence(string seq_in) { for (int i=0;i<seq_in.size();i++) this->seq.push_back(seq_in[i]); } void set_sequence(vector<char> seq_in) { for (int i=0;i<seq_in.size();i++) this->seq.push_back(seq_in[i]); } void print() { for (int i=0;i<this->seq.size();i++) cout << this->seq[i]; } }; int main() { // Part A RNA rna0("AUG"); RNA rnaN("UAG"); RNA rna1; RNA rna2 = rna0; RNA rna3; RNA rna4; cout << "Part A" << endl; // Part B cout << "Part B" << endl; rna0.print(); rnaN.print(); rna1.print(); rna2.print(); rna3.print(); rna3.set_sequence("GUCUCUACC"); rna4.set_sequence("AAAGACCAU"); // Part C cout << "Part C" << endl; rna2 = rna3; cout << rna0 << endl; cout << rnaN << endl; cout << rna1 << endl; cout << rna2 << endl; cout << rna3 << endl; cout << rna4 << endl; cout << rna0 + rna3 + rnaN << endl; cout << rna0 + rna4 + rnaN << endl; if (rna2 == rna3) cout << "the sequences match" << endl; else cout << "the sequences do not match" << endl; if (rna3 == rna4) cout << "the sequences match" << endl; else cout << "the sequences do not match" << endl; return 0; }
[ "neo_nestoras@hotmail.com" ]
neo_nestoras@hotmail.com
77d1a54fb38671c4ca79b672d925ee7ebbd6e08a
5b7f376a5005fa23e91241daaeb52add4c3d0b5d
/gtest/gtest_error.cpp
9b1c15d15709c75198ecfd6b5b1817a393c9e572
[ "BSD-2-Clause" ]
permissive
KotaHanda/libj
8decfd7d3759ae3f8b28198724818ceb60b23781
3f6e50bf2afde721d84799854a993fa949fa5616
refs/heads/master
2021-01-15T17:28:25.812836
2012-06-19T14:37:04
2012-06-19T14:37:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
958
cpp
// Copyright (c) 2012 Plenluno All rights reserved. #include <gtest/gtest.h> #include <libj/error.h> namespace libj { TEST(GTestError, TestCreate) { Error::CPtr e = Error::create(Status::OK); ASSERT_FALSE(e); e = Error::create(Error::ANY); ASSERT_TRUE(e); } TEST(GTestError, TestMessage) { String::CPtr foo = String::create("foo"); Error::CPtr e = Error::create(Error::ANY, foo); ASSERT_EQ(e->message()->compareTo(foo), 0); } TEST(GTestError, TestToString) { String::CPtr foo = String::create("foo"); Error::CPtr e = Error::create(Error::ANY, foo); ASSERT_EQ(e->toString()->compareTo(foo), 0); } TEST(GTestError, TestInstanceOf) { Error::CPtr e = Error::create(Error::ANY); ASSERT_TRUE(e->instanceof(Type<Error>::id())); ASSERT_TRUE(e->instanceof(Type<Status>::id())); ASSERT_TRUE(e->instanceof(Type<Immutable>::id())); ASSERT_TRUE(e->instanceof(Type<Object>::id())); } } // namespace libj
[ "plenluno@zoho.com" ]
plenluno@zoho.com
344d3cc2387f05c65fd2a48173859ca02625073d
7d820336a93e94ff6065677f8cbdd61edb346821
/vertex_arrays.cpp
7a1363fe1454df478034ae29478063f4853904e5
[]
no_license
pietrik123/freegluttest
d68e2c0a54002ab09c5314e80f6f0ee7be09b468
61fab7255fc30597a055b3ed137a04c6924f8015
refs/heads/main
2023-02-15T04:49:15.899937
2021-01-15T23:08:02
2021-01-15T23:08:02
330,033,931
0
0
null
null
null
null
UTF-8
C++
false
false
2,493
cpp
/* * Draw a red square [(1,1,0),(-1,1,0),(-1,-1,0),(1,-1,0)] and * a green triangle [(4,1,0),(3,3,0),(2,1,0)]. * Place a camera at (0,0,10) and make it look at (0,0,0), oriented along * global Y axis (0,1,0). * Make the camera move away from drawn shapes (each program cycle). * * Do the following transforms: translate square with vector [-1,0,0] * - one time action. * Make it rotate around local Y axis (animated). */ #include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> #include <unistd.h> static float distanceDelta = 0.0; static float angle = 0.0; GLfloat squareData[][3] = { {1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, {-1.0,-1.0, 0.0}, {1.0, -1.0, 0.0} }; GLfloat triangleData[] = { 4.0, 1.0, 0.0, 3.0, 3.0, 0.0, 2.0, 1.0, 0.0 }; void draw() { // clear screen glClear(GL_COLOR_BUFFER_BIT); // enter modelview glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0,0.0,10.0+distanceDelta, 0.0,0.0,0.0, 0.0, 1.0, 0.0); // draw square glPushMatrix(); glTranslatef(-1.0, 0.0, 0.0); glRotatef(45.0 + angle, 0.0, 1.0, 0.0); glBegin(GL_POLYGON); glColor3f(1.0, 0.0, 0.0); for (int i = 0; i < 4; i++) { glVertex3fv(squareData[i]); } glEnd(); glPopMatrix(); // draw triangle glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, triangleData); glBegin(GL_TRIANGLES); glColor3f(0.0, 1.0, 0.0); for (int i = 0; i < 3; i++) { glArrayElement(i); } glEnd(); glDisableClientState(GL_VERTEX_ARRAY); glutSwapBuffers(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei)w, (GLsizei)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // setup perspective : angle, aspect ratio (width and height), // near plane and far plane distance from camera gluPerspective(45.0, 1.0, 9.0, 35.0); glMatrixMode(GL_MODELVIEW); } void idleFunction() { distanceDelta += 0.05; angle += 2.0; glutPostRedisplay(); usleep(20000); } void init() { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_SMOOTH); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow ("Test"); init(); glutDisplayFunc(draw); glutIdleFunc(idleFunction); glutReshapeFunc(reshape); glutMainLoop(); return 0; }
[ "piotrmierzwa042@gmail.com" ]
piotrmierzwa042@gmail.com
0683e28c0e391ac113f483833eaa654abe830221
0f6af1f48db9af617802ca31682129a89ce87c77
/07_amenbo/src/MainScreen.h
6532e1871c75120f727005c9eae0ff22830828e9
[]
no_license
leico/Transfloor_Playwater
d4de2f5ff38dedf86a7ecd450f9b3eda446eae66
f0ec5a43c3a156ed21b914ca1972baa01380f85b
refs/heads/master
2020-04-05T14:04:05.298871
2017-09-20T06:10:31
2017-09-20T06:10:31
94,729,142
0
0
null
null
null
null
UTF-8
C++
false
false
8,145
h
#pragma once #include "TransFloor.h" class MainScreen : public ofBaseApp{ static int width; static int height; ofxOscReceiver receiver; const static std :: string jsonfile; const static std :: string serialfile; const static std :: string kinect1_prefix; KinectCV kinect1; const static std :: string kinect2_prefix; KinectCV kinect2; ofxSimpleTimer<bool> nohuman; void WhiteOut(bool& id); const static int NOHUMAN_TIME = 10000; ofxSimpleTimer<bool> whiteout; void End_WhiteOut(bool& id); const static int WHITEOUT_TIME = 5000; ofxSimpleTimer<bool> forcechange; const static int FORCECHANGE_TIME = 240000; ofTrueTypeFont font; ofxCvGrayscaleImage binaryImage; ofxCvContourFinder contourfinder; bool b_debug; const bool Debug(void); void Debug(const bool debug); const static int SCENE_NUM = 5; int scene; Base *basedraw; void DisplaySetup(void); ofStyle style; void setup_KinectCV(void); void setup_Timer (void); void update_KinectCV(vector<ofxOscMessage>& humans); void SceneChange(const int scene); public: void setup(); void exit(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); int ofGetWidth (void); int ofGetHeight(void); }; inline const bool MainScreen :: Debug(void) { return b_debug; } inline void MainScreen :: Debug(const bool debug){ b_debug = debug; } inline int MainScreen :: ofGetWidth (void){ return width; } inline int MainScreen :: ofGetHeight(void){ return height; } inline void MainScreen :: DisplaySetup(void){ ofSetFrameRate(60); ofSetVerticalSync(true); ofBackground(0); ofSetBackgroundAuto(true); ofFill(); ofSetLineWidth(1); ofEnableBlendMode(OF_BLENDMODE_ALPHA); ofSetCircleResolution(32); } /* =================================================================== * * void WhiteOut(bool& id) * * =================================================================== */ inline void MainScreen :: WhiteOut(bool& id){ nohuman .Stop(); forcechange.Stop(); delete basedraw; basedraw = new class WhiteOut(); DisplaySetup(); basedraw -> setup(); style = ofGetStyle(); whiteout.Start(WHITEOUT_TIME, 1); } /* =================================================================== * * void End_WhiteOut(bool& id) * * =================================================================== */ inline void MainScreen :: End_WhiteOut(bool& id){ scene = (scene + 1) % SCENE_NUM; SceneChange( scene + 1 ); return; } /* =================================================================== * * void setup_KinectCV(void) * * =================================================================== */ inline void MainScreen :: setup_KinectCV(void){ ofxKinect :: listDevices(); { ofxJSON json; if( ( json.open(serialfile) ) && ( ! json.isNull() ) ){ kinect1.setup( json[0].asString() ); kinect2.setup( json[1].asString() ); } else{ ofLogWarning() << "json.open: Can't open serial.json file, use default serial" << std :: endl; kinect1.setup("A00364800479053A"); kinect2.setup("A00363A02391053A"); } if( json.open(jsonfile) ){ ofLogVerbose() << json.getRawString() << endl; kinect1.SettingData( json ); kinect2.SettingData( json ); } else{ ofLogWarning() << "json.open: Can't open serial.json file, use default settings" << std :: endl; } json.clear(); } return; } /* =================================================================== * * void update_KinectCV(vector<ofxOscMessage>& humans) * * =================================================================== */ inline void MainScreen :: update_KinectCV(vector<ofxOscMessage>& humans){ ofPixels& binary = binaryImage.getPixels(); int size = kinect1.Size().x * kinect1.Size().y; { const ofxCvGrayscaleImage& image = kinect1.update_dualscreen(); const ofPixels& pix = image.getPixels(); for(int i = 0 ; i < size ; ++ i) binary[i] = pix[i]; } { const ofxCvGrayscaleImage& image = kinect2.update_dualscreen(); const ofPixels& pix = image.getPixels(); for(int i = 0 ; i < size ; ++ i) binary[size + i] = pix[i]; } contourfinder.findContours(binaryImage, kinect1.MinArea(), kinect1.MaxArea(), 200, false); for(int i = 0, size = contourfinder.blobs.size() ; i < size ; ++ i){ //get contour center position ofPoint pos = contourfinder.blobs.at(i).centroid; //create OSC Message ofxOscMessage m; m.setAddress("/human"); m.addIntArg(pos.x); m.addIntArg(pos.y); m.addIntArg( (pos.y > kinect1.Size().y) ? kinect2.Depth(pos.x, pos.y - kinect1.Size().y) : kinect1.Depth(pos.x, pos.y) ); //store for humans humans.push_back(m); //ofLogWarning() << "nBlobs:" << humans.size(); } } /* =================================================================== * * void setup_Timer(void) * * =================================================================== */ inline void MainScreen :: setup_Timer(void){ nohuman .Setup(true, this, &:: MainScreen :: WhiteOut); whiteout .Setup(true, this, &:: MainScreen :: End_WhiteOut); forcechange.Setup(true, this, &:: MainScreen :: WhiteOut); } /* =================================================================== * * void SceneChage(const int scene) * * =================================================================== */ inline void MainScreen :: SceneChange(const int scene){ switch( scene ){ case 0 : delete basedraw; basedraw = new Blank(); break; //Blank case 1 : delete basedraw; basedraw = new tkm001(); break; //track circles case 2 : delete basedraw; basedraw = new RippleScene(); break; //Ripples case 3 : delete basedraw; basedraw = new takami(); break; //EscapeParticles case 4 : delete basedraw; basedraw = new sinsin(); break; //marumaru case 5 : delete basedraw; basedraw = new AmnbField(); break;//amenbo /* case 0 : delete basedraw; basedraw = new Blank(); break; //Blank case 1 : delete basedraw; basedraw = new tkm001(); break; //track circles case 2 : delete basedraw; basedraw = new RippleScene(); break; //Ripples case 3 : delete basedraw; basedraw = new Relation(); break; //Relation case 4 : delete basedraw; basedraw = new Gravity(); break; //Gravity case 5 : delete basedraw; basedraw = new takami(); break; //EscapeParticles case 6 : delete basedraw; basedraw = new Gushi01(); break; //prrrrrrrroooo case 7 : delete basedraw; basedraw = new tkmOTO(); break; //tkmOTO case 8 : delete basedraw; basedraw = new origami(); break; //origami case 9 : delete basedraw; basedraw = new lines(); break; //lines case 10 : delete basedraw; basedraw = new dot(); break; //tkmOTO case 11 : delete basedraw; basedraw = new nununu(); break; //origami case 12 : delete basedraw; basedraw = new star(); break; //lines case 13 : delete basedraw; basedraw = new Medama(); break; //medama case 14 : delete basedraw; basedraw = new marumaru(); break; //marumaru case 15 : delete basedraw; basedraw = new sinsin(); break; //marumaru */ default : return; } DisplaySetup(); basedraw -> setup(); style = ofGetStyle(); forcechange.Start(FORCECHANGE_TIME, 1); return; }
[ "yoshitaka_12@iamas.ac.jp" ]
yoshitaka_12@iamas.ac.jp
cfbf22755059f0ad099bef40ab12b96bfa1bd4fe
334f2829b3c19140fc729936446539d48d290e55
/14_Check if all internal nodes of BST have only one child without building tree.cp
3d9711287414a1c8a63faf608da38e8fd457bd43
[]
no_license
shuaishuaima/Leetcode
99222254c23e87f59bc2c478536783fb8ddeb30e
c257b23294efcd8618ea44f673265320940109e4
refs/heads/master
2021-01-17T19:10:54.817152
2016-07-23T03:26:23
2016-07-23T03:26:23
63,990,528
0
0
null
2016-07-23T00:26:19
2016-07-23T00:03:42
null
UTF-8
C++
false
false
791
cp
// // main.cpp // leetcode // // Created by Changjie Ma on 3/9/16. // Copyright © 2016 Changjie Ma. All rights reserved. // /* Given preorder traversal array for a binary search tree(BST), without actually building the tree check if all internal nodes of BST have only one child. */ #include <iostream> #include <vector> #include <utility> class Solution { public: bool checkOneChildBST(vector<int>& preorder){ int n = preorder.size(); int maxi = preorder[n-1], mini = preorder[n-1]; for(int i = n-2; i>=0; i--){ if(!(preorder[i]<mini || preorder[i]>maxi)) return false; maxi = max(maxi, preorder[i]); mini = min(mini, preorder[i]); } return true; } };
[ "shuaishuaima@outlook.com" ]
shuaishuaima@outlook.com
ea80b0dbe3b944a473aa6dc83c726e0e955a3e6b
cefd6c17774b5c94240d57adccef57d9bba4a2e9
/WebKit/Source/WebCore/svg/SVGPathStringBuilder.cpp
f30ce00a20d6d528da1e70531992122840720496
[ "BSL-1.0", "BSD-2-Clause", "LGPL-2.0-only", "LGPL-2.1-only" ]
permissive
adzhou/oragle
9c054c25b24ff0a65cb9639bafd02aac2bcdce8b
5442d418b87d0da161429ffa5cb83777e9b38e4d
refs/heads/master
2022-11-01T05:04:59.368831
2014-03-12T15:50:08
2014-03-12T15:50:08
17,238,063
0
1
BSL-1.0
2022-10-18T04:23:53
2014-02-27T05:39:44
C++
UTF-8
C++
false
false
5,202
cpp
/* * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "config.h" #include "SVGPathStringBuilder.h" #include <wtf/text/WTFString.h> namespace WebCore { SVGPathStringBuilder::SVGPathStringBuilder() { } SVGPathStringBuilder::~SVGPathStringBuilder() { } String SVGPathStringBuilder::result() { unsigned size = m_stringBuilder.length(); if (!size) return String(); // Remove trailing space. m_stringBuilder.resize(size - 1); return m_stringBuilder.toString(); } void SVGPathStringBuilder::cleanup() { m_stringBuilder.clear(); } void SVGPathStringBuilder::incrementPathSegmentCount() { } bool SVGPathStringBuilder::continueConsuming() { return true; } static void appendFlag(StringBuilder& stringBuilder, bool flag) { stringBuilder.append(flag ? '1' : '0'); stringBuilder.append(' '); } static void appendNumber(StringBuilder& stringBuilder, float number) { stringBuilder.appendNumber(number); stringBuilder.append(' '); } static void appendPoint(StringBuilder& stringBuilder, const FloatPoint& point) { stringBuilder.appendNumber(point.x()); stringBuilder.append(' '); stringBuilder.appendNumber(point.y()); stringBuilder.append(' '); } void SVGPathStringBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("M "); else m_stringBuilder.appendLiteral("m "); appendPoint(m_stringBuilder, targetPoint); } void SVGPathStringBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("L "); else m_stringBuilder.appendLiteral("l "); appendPoint(m_stringBuilder, targetPoint); } void SVGPathStringBuilder::lineToHorizontal(float x, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("H "); else m_stringBuilder.appendLiteral("h "); appendNumber(m_stringBuilder, x); } void SVGPathStringBuilder::lineToVertical(float y, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("V "); else m_stringBuilder.appendLiteral("v "); appendNumber(m_stringBuilder, y); } void SVGPathStringBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("C "); else m_stringBuilder.appendLiteral("c "); appendPoint(m_stringBuilder, point1); appendPoint(m_stringBuilder, point2); appendPoint(m_stringBuilder, targetPoint); } void SVGPathStringBuilder::curveToCubicSmooth(const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("S "); else m_stringBuilder.appendLiteral("s "); appendPoint(m_stringBuilder, point2); appendPoint(m_stringBuilder, targetPoint); } void SVGPathStringBuilder::curveToQuadratic(const FloatPoint& point1, const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("Q "); else m_stringBuilder.appendLiteral("q "); appendPoint(m_stringBuilder, point1); appendPoint(m_stringBuilder, targetPoint); } void SVGPathStringBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("T "); else m_stringBuilder.appendLiteral("t "); appendPoint(m_stringBuilder, targetPoint); } void SVGPathStringBuilder::arcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) m_stringBuilder.appendLiteral("A "); else m_stringBuilder.appendLiteral("a "); appendNumber(m_stringBuilder, r1); appendNumber(m_stringBuilder, r2); appendNumber(m_stringBuilder, angle); appendFlag(m_stringBuilder, largeArcFlag); appendFlag(m_stringBuilder, sweepFlag); appendPoint(m_stringBuilder, targetPoint); } void SVGPathStringBuilder::closePath() { m_stringBuilder.appendLiteral("Z "); } } // namespace WebCore
[ "adzhou@hp.com" ]
adzhou@hp.com
c6f615e028fbdf50aa3095e4ea1497d9bdf32f39
91ba86070a91cc614e1d336f3b753187ca0f5ade
/ScanLineDepthBuffer/OffscreenBuffer.h
171a86b6943b668f3d175e6e27eb61c272905867
[]
no_license
clearRain/ScanLineDepthBuffer
bae2196ca0defdaf5bc679133d905532d34a06f7
fdf5d8c370039eb94f4f4d95e25521ec7ed4efff
refs/heads/master
2020-04-05T21:36:35.911216
2017-03-11T15:09:34
2017-03-11T15:09:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,604
h
#pragma once #include <vector> #include <Windows.h> #include "Color.h" class OffscreenBuffer { static constexpr INT32 BYTES_PER_PIXEL = 4; public: void Resize(INT32 width, INT32 height); void SetPixel(INT32 x, INT32 y, const Color & color); void SetRow(INT32 y, const std::vector<Color> & row); void OnPaint(HDC hdc, INT32 width, INT32 height); void DebugDrawPoint(INT32 x, INT32 y, const Color & color); void DebugDrawRectangle(RECT rect, const Color & color); void DebugDarwRandomPicture(); INT32 GetWidth() const { return m_width; } INT32 GetHeight() const { return m_height; } private: // Memory Layout: // From top to bottom, from left to right. // // Position (x, y): // // 4 bytes 0 1 2 .. x .. width-1 // 1 byte 0 1 2 3 4 5 6 7 8 .. .. pitch-4 pitch-3 pitch-2 pitch-1 // ---------------------------------------------------------------- // 0 b g r x b g r x b .. .. b g r x // 1 b g r x b g r x b .. .. b g r x // 2 b g r x b g r x b .. .. b g r x // 3 b g r x b g r x b .. .. b g r x // . . // . . // y o // . . // . . // height-1 b g r x b g r x b .. .. b g r x void * m_memory{nullptr}; INT32 m_width{0}; INT32 m_height{0}; INT32 m_pitch{0}; BITMAPINFO m_info{ }; };
[ "jaege@163.com" ]
jaege@163.com
f9ba71b2b28c203abfcd4fcc214af5608c3ef0bf
d2bb8b920f5d1d23f3db2d1256d1fd6213940014
/engine/Engine.Core/src/core/application/Application.h
571b43748f125176f764de7718ed48e371e5619d
[ "MIT" ]
permissive
ZieIony/Ghurund
726672d56838d18b6dd675f304feee1d95a296bd
0ce83cabd91f7ac71286dcd8e12d486bed2d75cf
refs/heads/master
2023-08-17T08:14:19.548027
2022-02-12T16:33:32
2022-02-12T16:34:54
124,959,579
91
9
null
null
null
null
UTF-8
C++
false
false
2,169
h
#pragma once #include "Settings.h" #include "WindowList.h" #include "FeatureCollection.h" #include "core/Noncopyable.h" #include "core/SharedPointer.h" #include "core/Timer.h" #include "core/threading/FunctionQueue.h" #include "core/resource/ResourceManager.h" namespace Ghurund::Core { class Application:public Noncopyable { private: SystemWindowManager windowManager; WindowList windows = windowManager; FunctionQueue functionQueue; bool running = false; Settings settings; ResourceManager resourceManager; Timer timer; FeatureCollection features; void init(); void handleMessages(); void uninit(); protected: virtual void onInit() {}; virtual void onUninit() {}; public: virtual ~Application() {} inline bool isRunning() { return running; } __declspec(property(get = isRunning)) bool Running; void run(const Settings* val = nullptr); inline void quit() { PostQuitMessage(0); } inline const Settings& getSettings() const { return settings; } __declspec(property(get = getSettings)) const Settings& Settings; inline WindowList& getWindows() { return windows; } __declspec(property(get = getWindows)) WindowList& Windows; FunctionQueue& getFunctionQueue() { return functionQueue; } __declspec(property(get = getFunctionQueue)) FunctionQueue& FunctionQueue; inline ResourceManager& getResourceManager() { return resourceManager; } __declspec(property(get = getResourceManager)) ResourceManager& ResourceManager; inline Timer& getTimer() { return timer; } __declspec(property(get = getTimer)) Timer& Timer; inline FeatureCollection& getFeatures() { return features; } __declspec(property(get = getFeatures)) FeatureCollection& Features; }; } namespace Ghurund::Core { template<> const Type& getType<Application>(); }
[ "niewartotupisac@gmail.com" ]
niewartotupisac@gmail.com
5b7cc06eeaad488b82017e95c169b220aee50ac5
856de9cd24cdf320447daba95fc60ea85ee0ddd7
/arduino/arduino.ino
ca21fda3920e52f1693b045177a1aa118c3bbe08
[]
no_license
DanNduati/php-arduino-and-processing
2c45a6e82a15bf3955b6dc607a63cffaf6b3a330
90d8b6e30d576fd1e7db37c866a6de46a159cfc3
refs/heads/master
2021-07-10T19:42:08.667424
2020-06-15T11:03:25
2020-06-15T11:03:25
143,150,328
0
0
null
null
null
null
UTF-8
C++
false
false
670
ino
const int ledPin = 13; int incomingByte; // a variable to store incoming serial data into void setup() { // initialize serial communication: Serial.begin(9600); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); } void loop() { // see if there's incoming serial data: if (Serial.available() > 0) { // read the oldest byte in the serial buffer: incomingByte = Serial.read(); // if it's a capital H (ASCII 72), turn on the LED: if (incomingByte == 'H') { digitalWrite(ledPin, HIGH); } // if it's an L (ASCII 76) turn off the LED: if (incomingByte == 'L') { digitalWrite(ledPin, LOW); } } }
[ "noreply@github.com" ]
noreply@github.com
796bf0e9c2361fa95a79f77cf5ff7dc15e87d5f5
dba68ca53ce02985ed1b49f6813d578d24e94b27
/ProjectsServer/GameServer/FieldServer/TriggerFunctionNGCInflWar.h
56afd8a218758ffbdc76f8ddb4efcc46e5841b9e
[]
no_license
DeathRivals/OpenAo
afd6c1fe6ddc00e3765c290f485805a7b3e0db59
bf6be4ee29b1f08588fe7fd12c02c8df94d705f5
refs/heads/master
2021-02-15T18:23:37.814569
2020-03-04T14:39:38
2020-03-04T14:39:38
244,919,960
2
2
null
2020-03-04T14:22:07
2020-03-04T14:22:07
null
UHC
C++
false
false
4,508
h
// TriggerFunctionNGCInflWar.h: interface for the CTriggerFunctionNGCInflWar class. // /// \brief // 2011-11-07 by hskim, EP4 [트리거 시스템] - NCG 거점전 시스템 /// \author hskim /// \date 2011-11-07 ////////////////////////////////////////////////////////////////////// #if !defined(AFX_TRIGGERFUNCTIONNGCINFLWAR_H__3705FC12_22C8_4256_9ED5_F1527275D0CF__INCLUDED_) #define AFX_TRIGGERFUNCTIONNGCINFLWAR_H__3705FC12_22C8_4256_9ED5_F1527275D0CF__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "TriggerFunction.h" class CTriggerNGCInflWarGroup; class CTriggerFunctionNGCInflWar : public CTriggerFunction { public: CTriggerFunctionNGCInflWar(); virtual ~CTriggerFunctionNGCInflWar(); void OnClear(); void OnDestroy(); BOOL OnCreate(CMapTriggerManager *pMapTriggerManager, MapTriggerID_t MapTriggerID, MapIndex_t MapIndex, ChannelIndex_t MapChannel, FunctionID_t FunctionID, MapTriggerType_t TriggerType); void DoMinutelyWork(ATUM_DATE_TIME *pDateTime); void OnEventSkip(BOOL bCheckCreateCrystal = TRUE); // 2012-12-17 by hskim, NPC 서버 재시작시 - 트리거 시스템 초기화 적용 BOOL OnMonsterCreate(CFieldMonster *pMonster); BOOL OnMonsterDead(CFieldMonster *pMonster); BOOL OnAddDamage(MonIdx_t MonsterIdx, UID32_t CharacterUniqueNumber, UID32_t GuildUniqueNumber, BYTE InfluenceType, float fDamage); public: void SetNGCInflWarInfo(NGCInflWarGroupID_t NGCInflWarGroupID, INT PeriodTime, MonIdx_t BossMonster, INT WinInfluenceWP, INT LossInfluenceWP, INT FirstDamageGuildWP, INT FixedTimeType, INT i_nDestroyCrystalcount); // 2013-07-08 by jhseol, 트리거 시스템 확장 BOOL InsertNGCInflWarMonster(CTriggerNGCInflWarMonsterGroup *pTriggerNGCInflWarGroup); BOOL IsCreatedNGCInflWar() { return m_bCreatedNGCInflWar; } void ResetLocalData(); // 2012-12-17 by hskim, NPC 서버 재시작시 - 트리거 시스템 초기화 적용 void SetNextCreateTime(); void FindFirstDamageUser(); // 누적 데미지 1등 유저 찾기 void FindSequenceAmountAttack(); // 보스 본스터 누적 데미지 내림차순 정렬한 유저 리스트 void FindWinInfluenc(); // 이긴 세력 찾기 // 2013-07-08 by jhseol, 트리거 시스템 확장 void InsertBossMonsterKillInfo(STRIGGER_TRIGGER_OUTPOST_BOSS_KILL_INFO* i_BossKillInfo); void InitBossKillPlayStep(); void CreateCrystalMonster(); void DestroyCrystalMonster(); void CrystalRegen(); BOOL IsPossibleBossAttack(); BOOL OnIsPossibleBossAttack(MonIdx_t MonsterIdx); void RunKeyMonsterKillEvent(MonIdx_t i_nMonsterNum); void InsertCrystalBuff(STRIGGER_CRYSTAL_BUFF *i_CrystalBuff); INT GetDestroyCrystalcount(); // end 2013-07-08 by jhseol, 트리거 시스템 확장 protected: void RunEvent(); void StopEvent(); void CreateAllMonster(); void DestroyAllMonster(); protected: BOOL m_bCreatedNGCInflWar; NGCInflWarGroupID_t m_NGCInflWarGroupID; INT m_PeriodTime; MonIdx_t m_BossMonster; INT m_WinInfluenceWP; INT m_LossInfluenceWP; INT m_FirstDamageGuildWP; INT m_FixedTimeType; mtvectTriggerAttackUserDamage m_mtvectTriggerAttackUserDamage; // 각 데미지 정보 vector<CTriggerNGCInflWarMonsterGroup *> m_vectorTriggerNGCInflWarMonster; // 초기 부팅시 설정되고 변경되지 않는다. 동기화 필요 없음 protected: TimeUnit_t m_NextCreateTick; UID32_t m_FirstCharacterUniqueNumber; // 1등 캐릭터 고유번호 UID32_t m_FirstGuildUniqueNumber; // 1등 길드 길드 번호 BYTE m_WinInfluenceType; // 이긴 세력 타입 BYTE m_DefeatInfluenceType; // 패배 세력 타입 mtvectTriggerAttackUserDamage m_mtvectTriggerDamageSortUser; // 보스 몬스터에 공격한 데미지 순으로 내림차순 정렬 리스트 // 2013-07-08 by jhseol, 트리거 시스템 확장 BOOL m_bPossibleBossAttack; // 보스몬스터 공격 가능 여부 BOOL m_bBeforePossibleBossAttack; // 이전 보스몬스터 공격 가능 여부 BOOL m_bIsBossDestroy; // 보스 파괴 여부 INT m_nDestroyCrystalcount; // 파괴해야 하는 크리스탈의 수 vectorTriggerOutPostBossKillInfo m_vectTriggerNGCInflWarBossKillInfo; mtvectorTriggerOutPostMonsterKillInfo m_mtvectTriggerNGCInflWarMonsterKillInfo; vectorTriggerCrystalBuff m_vectCrystalBuff; // 크리스탈 버프 리스트 // end 2013-07-08 by jhseol, 트리거 시스템 확장 }; #endif // !defined(AFX_TRIGGERFUNCTIONNGCINFLWAR_H__3705FC12_22C8_4256_9ED5_F1527275D0CF__INCLUDED_)
[ "guss@nemerian.fr" ]
guss@nemerian.fr
19c77d1fded6985fa3ed9e93ffc5ba591d283bff
9b29326bc61126226efd24e76c618c8eccbd14d5
/test/itkWASMMeshIOTest.cxx
a1ff406897b3c47dd32e9dd173803e89b4f9ccf8
[ "Apache-2.0" ]
permissive
floryst/itk-js
5ccf2095bc0ddc50373db9a56b98cdcffd56d85d
7b572ff873947778533d125fb3c94f8b461f9520
refs/heads/master
2022-05-06T07:28:20.610621
2022-04-06T18:50:28
2022-04-06T18:50:28
133,382,755
0
0
null
2018-05-14T15:27:58
2018-05-14T15:27:57
null
UTF-8
C++
false
false
2,869
cxx
/*========================================================================= * * Copyright NumFOCUS * * 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.txt * * 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. * *=========================================================================*/ #include "itkWASMMeshIOFactory.h" #include "itkWASMMeshIO.h" #include "itkMeshFileReader.h" #include "itkMeshFileWriter.h" #include "itkTestingMacros.h" #include "itkMesh.h" int itkWASMMeshIOTest(int argc, char * argv[]) { if (argc < 6) { std::cerr << "Missing parameters" << std::endl; std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " InputMesh MeshDirectory ConvertedDirectory MeshZip ConvertedZip" << std::endl; return EXIT_FAILURE; } const char * inputMeshFile = argv[1]; const char * meshDirectory = argv[2]; const char * convertedDirectoryFile = argv[3]; const char * meshZip = argv[4]; const char * convertedZipFile = argv[5]; itk::WASMMeshIOFactory::RegisterOneFactory(); constexpr unsigned int Dimension = 3; using PixelType = unsigned char; using MeshType = itk::Mesh<PixelType, Dimension>; using MeshPointer = MeshType::Pointer; using ReaderType = itk::MeshFileReader<MeshType>; auto meshReader = ReaderType::New(); meshReader->SetFileName(inputMeshFile); ITK_TRY_EXPECT_NO_EXCEPTION(meshReader->Update()); auto inputMesh = meshReader->GetOutput(); auto meshIO = itk::WASMMeshIO::New(); using WriterType = itk::MeshFileWriter<MeshType>; auto wasmWriter = WriterType::New(); //wasmWriter->SetMeshIO( meshIO ); wasmWriter->SetFileName( meshDirectory ); wasmWriter->SetInput( inputMesh ); ITK_TRY_EXPECT_NO_EXCEPTION(wasmWriter->Update()); auto wasmReader = ReaderType::New(); //wasmReader->SetMeshIO( meshIO ); wasmReader->SetFileName( meshDirectory ); ITK_TRY_EXPECT_NO_EXCEPTION(wasmReader->Update()); auto meshWriter = WriterType::New(); meshWriter->SetInput(wasmReader->GetOutput()); meshWriter->SetFileName(convertedDirectoryFile); ITK_TRY_EXPECT_NO_EXCEPTION(meshWriter->Update()); wasmWriter->SetFileName( meshZip ); ITK_TRY_EXPECT_NO_EXCEPTION(wasmWriter->Update()); wasmReader->SetFileName( meshZip ); ITK_TRY_EXPECT_NO_EXCEPTION(wasmReader->Update()); meshWriter->SetFileName(convertedZipFile); ITK_TRY_EXPECT_NO_EXCEPTION(meshWriter->Update()); return EXIT_SUCCESS; }
[ "matt.mccormick@kitware.com" ]
matt.mccormick@kitware.com
4327724f52b5f9d1a74c73d30069c73745301338
3d424a8d682d4e056668b5903206ccc603f6e997
/NeoKad/Kad/KadEngine/JSKadNode.h
41600bc4a910e199db13c8f2f643c0c915744f13
[]
no_license
markus851/NeoLoader
515e238b385354b83bbc4f7399a85524d5b03d12
67c9b642054ead500832406a9c301a7b4cbfffd3
refs/heads/master
2022-04-22T07:51:15.418184
2015-05-08T11:37:53
2015-05-08T11:37:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,484
h
#pragma once #include "../../Common/v8Engine/JSEngine.h" #include "../KadNode.h" #include "../KadOperation.h" class CJSKadNode: public CJSObject { public: static v8::Local<v8::ObjectTemplate> Prepare(); static CJSObject* New(CObject* pObject, CJSScript* pScript) {return new CJSKadNode(pObject->Cast<Type>(), pScript);} v8::Persistent<v8::ObjectTemplate>& GetTemplate() {return m_Template;} virtual CObject* GetObjectPtr() {return m_pNode;} virtual char* GetObjectName() {return Type::StaticName();} virtual void SetOperation(CKadOperation* pOperation) {m_pLookup = CPointer<CKadOperation>(pOperation, true);} typedef CKadNode Type; protected: CJSKadNode(CKadNode* pNode, CJSScript* pScript) : m_pNode(pNode, true) {Instantiate(pScript, false);} static void GetNodeID(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info); static void GetValue(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info); //static void SetValue(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info); static void FxSendMessage(const v8::FunctionCallbackInfo<v8::Value> &args); static void FxValue(const v8::FunctionCallbackInfo<v8::Value> &args); static void GetLookup(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info); static v8::Persistent<v8::ObjectTemplate> m_Template; CPointer<Type> m_pNode; CPointer<CKadOperation> m_pLookup; };
[ "David@X.com" ]
David@X.com
983a6c3dae2b1051d87a283a56cd1ea05cae348f
fa2eed5a25adab9d407024bbd9cdc9e8daecfcce
/ProjetRI/ProjetRI/sources/http.cpp
77c84a77963b5be8526ca43523e1f00a30e0a3a8
[]
no_license
NeilRittner/ProjetRI
89b3d0dc012189da3ede5c83e25b2691bbd0da99
57dc45271414a290307fad439650a5c0dec43a8a
refs/heads/master
2020-04-10T08:59:49.934987
2018-12-16T14:57:25
2018-12-16T14:57:25
160,922,241
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,282
cpp
#include <ctime> #include <sstream> #include <iomanip> #include <iostream> #include "http.h" #include "params.h" #define TAILLE 50 #ifdef _MSC_VER #pragma warning(disable:4996) #endif extern ParamIndex params; void HttpRequest::GetResponse(SOCKET sd) { char buffer[TAILLE + 1]; int nb; // à vous de jouer ... int etat = 0; char search_caract[4]; search_caract[0] = '\r'; search_caract[1] = '\n'; search_caract[2] = '\r'; search_caract[3] = '\n'; while (etat != 4) { nb = recv(sd, buffer, TAILLE, 0); for (size_t i = 0; i <= TAILLE; i++) { if (buffer[i] == search_caract[etat]) { std::cout << etat << std::endl; etat = etat + 1; if (etat == 4) { break; } } else { etat = 0; } } } nb = send(sd, buffer, TAILLE, 0); std::cout << buffer << std::endl; } void HttpRequest::SetHeader(std::string &AnswerBuf, char *httpCode, const char *mime) { std::stringstream header; // GetTime auto t = std::time(nullptr); // Set HTTP header header << "HTTP/1.0 " << httpCode << "\r\n"; header << "Date: " << std::put_time(std::gmtime(&t), "%a, %d %b %Y %H:%M:%S GMT") << "\r\n"; header << "Server: WebSearchServer/1.0" << "\r\n"; header << "Content-Type: " << mime << "\r\n"; header << "\r\n"; AnswerBuf = header.str(); }
[ "neil.rittner@etu.univ-nantes.fr" ]
neil.rittner@etu.univ-nantes.fr
52f9474cb56f37c75252944ae2419c5d9b4a16fb
9545a7b513100e60dbd249bcd10b6ebc71705f17
/2017-2/컴퓨터프로그래밍및실습 (Computer Programming & Lab)/과제 3 (Assignment 3)/분수의 사칙연산 (Arithmetic operation of fractions).cpp
c9dbfc26072e5b8e8bf8a8ecb47c44fd0ca42e8d
[]
no_license
JunKiBeom/HUFS
3a864312f049bcf8cb09160f9dcc6fc50cf5e772
d293d6c63ed2ad6eb18124c9c442d54238c89314
refs/heads/master
2023-06-29T15:51:49.011984
2023-06-11T20:31:48
2023-06-11T20:31:48
173,242,252
0
0
null
null
null
null
UTF-8
C++
false
false
2,065
cpp
#include <iostream> #include <cstring> // strcmp사용 using namespace std; int up, down; // 분자 분모 계산값, 접근의 용이성을 고려하여 전역변수로 선언함 void add(struct num1 a, struct num2 b); void sub(struct num1 a, struct num2 b); void multi(struct num1 a, struct num2 b); void div(struct num1 a, struct num2 b); int GCD(int num1, int num2); struct num1 { int up1; int down1; }; struct num2 { int up2; int down2; }; int main() { char opr[6]; // 연산자 struct num1 a; struct num2 b; cin >> a.up1 >> a.down1; cin >> opr; cin >> b.up2 >> b.down2; if (!strcmp(opr, "add")) // 입력된 연산자 확인 후 함수로 보냄 add(a, b); else if (!strcmp(opr, "sub")) sub(a, b); else if (!strcmp(opr, "multi")) multi(a, b); else if (!strcmp(opr, "div")) div(a, b); int gcd = GCD(up, down); up /= gcd, down /= gcd; if (down == 1) cout << up << endl; // 분모가 1이면 분자만 출력 else cout << up << "/" << down << endl; // 분자 / 분모 출력 } void add(struct num1 a, struct num2 b) // 덧셈 함수 { int upper, lower; // 임시 저장용 upper = (a.up1*b.down2) + (b.up2*a.down1); lower = a.down1*b.down2; up = upper; down = lower; } void sub(struct num1 a, struct num2 b) // 뺄셈함수 { int upper, lower; upper = (a.up1*b.down2) - (b.up2*a.down1); lower = a.down1*b.down2; up = upper; down = lower; } void multi(struct num1 a, struct num2 b) // 곱셈함수 { int upper, lower; upper = a.up1*b.up2; lower = a.down1*b.down2; up = upper; down = lower; } void div(struct num1 a, struct num2 b) // 나눗셈 함수 { int upper, lower; upper = a.up1*b.down2; lower = a.down1*b.up2; up = upper; down = lower; } int GCD(int num1, int num2) // 분자와 분모의 최대공약수 구하기 { int i, temp; if (num1 >= num2) temp = num2; else temp = num1; for (i = temp; i>1; i--) { if (num1%i == 0 && num2%i == 0) break; } return i; }
[ "noreply@github.com" ]
noreply@github.com
942d955789589ae106e69ab31d379fe00f60e586
d2e0fb3fdad7fc2cb70894591d358f40d8db13d2
/kernel/include/dennix/kernel/ext234fs.h
e4bde586ab52e80a934f3b702663f61226fedb51
[ "ISC", "MIT" ]
permissive
dennis95/dennix
54c568485862a0799664033eb0717abb028d3924
f898bb2d27346f6257df1650a002ee929e66e7fa
refs/heads/master
2023-08-17T06:54:17.274650
2023-07-10T16:06:35
2023-07-10T16:06:35
55,073,371
168
15
null
null
null
null
UTF-8
C++
false
false
12,763
h
/* Copyright (c) 2021 Dennis Wölfing * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* kernel/include/dennix/kernel/ext234fs.h * ext2/ext3/ext4 filesystem driver. */ #ifndef KERNEL_EXT234FS_H #define KERNEL_EXT234FS_H #include <dennix/kernel/endian.h> #include <dennix/kernel/filesystem.h> #include <dennix/kernel/hashtable.h> struct SuperBlock { little_uint32_t s_inodes_count; little_uint32_t s_blocks_count; little_uint32_t s_r_blocks_count; little_uint32_t s_free_blocks_count; little_uint32_t s_free_inodes_count; little_uint32_t s_first_data_block; little_uint32_t s_log_block_size; little_uint32_t s_log_frag_size; little_uint32_t s_blocks_per_group; little_uint32_t s_frags_per_group; little_uint32_t s_inodes_per_group; little_uint32_t s_mtime; little_uint32_t s_wtime; little_uint16_t s_mnt_count; little_uint16_t s_max_mnt_count; little_uint16_t s_magic; little_uint16_t s_state; little_uint16_t s_errors; little_uint16_t s_minor_rev_level; little_uint32_t s_lastcheck; little_uint32_t s_checkinterval; little_uint32_t s_creator_os; little_uint32_t s_rev_level; little_uint16_t s_def_resuid; little_uint16_t s_def_resgid; // The following fields are only valid if s_rev_level >= 1. little_uint32_t s_first_ino; little_uint16_t s_inode_size; little_uint16_t s_block_group_nr; little_uint32_t s_feature_compat; little_uint32_t s_feature_incompat; little_uint32_t s_feature_ro_compat; char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; little_uint32_t s_algo_bitmap; little_uint8_t s_prealloc_blocks; little_uint8_t s_prealloc_dir_blocks; little_uint16_t s_reserved_gdt_blocks; char s_journal_uuid[16]; little_uint32_t s_journal_inum; little_uint32_t s_journal_dev; little_uint32_t s_last_orphan; // These fields are new in ext4. little_uint32_t s_hash_seed[4]; little_uint8_t s_def_hash_version; little_uint8_t s_jnl_backup_type; little_uint16_t s_desc_size; little_uint32_t s_default_mount_opts; little_uint32_t s_first_meta_bg; little_uint32_t s_mkfs_time; little_uint32_t s_jnl_blocks[17]; little_uint32_t s_blocks_count_hi; little_uint32_t s_r_blocks_count_hi; little_uint32_t s_free_blocks_count_hi; little_uint16_t s_min_extra_isize; little_uint16_t s_want_extra_isize; little_uint32_t s_flags; little_uint16_t s_raid_stride; little_uint16_t s_mmp_update_interval; little_uint64_t s_mmp_block; little_uint32_t s_raid_stripe_width; little_uint8_t s_log_groups_per_flex; little_uint8_t s_checksum_type; little_uint8_t s_encryption_level; little_uint8_t reserved; little_uint64_t s_kbytes_written; little_uint32_t s_snapshot_inum; little_uint32_t s_snapshot_id; little_uint64_t s_snapshot_r_blocks_count; little_uint32_t s_snapshot_list; little_uint32_t s_error_count; little_uint32_t s_first_error_time; little_uint32_t s_first_error_ino; little_uint64_t s_first_error_block; char s_first_error_func[32]; little_uint32_t s_first_error_line; little_uint32_t s_last_error_time; little_uint32_t s_last_error_ino; little_uint32_t s_last_error_line; little_uint32_t s_last_error_block; char s_last_error_func[32]; char s_mount_opts[64]; little_uint32_t s_usr_quota_inum; little_uint32_t s_grp_quota_inum; little_uint32_t s_overhead_clusters; little_uint32_t s_backup_bgs[2]; little_uint8_t s_encrypt_algos[4]; char s_encrypt_pw_salt[16]; little_uint32_t s_lpf_ino; little_uint32_t s_prj_quota_inum; little_uint32_t s_checksum_seed; little_uint8_t s_wtime_hi; little_uint8_t s_mtime_hi; little_uint8_t s_mkfs_time_hi; little_uint8_t s_lastcheck_hi; little_uint8_t s_first_error_time_hi; little_uint8_t s_last_error_time_hi; little_uint8_t s_first_error_errcode; little_uint8_t s_last_error_errcode; little_uint16_t s_encoding; little_uint16_t s_encoding_flags; char padding[380]; little_uint32_t s_checksum; }; struct Inode { little_uint16_t i_mode; little_uint16_t i_uid; little_uint32_t i_size; little_uint32_t i_atime; little_uint32_t i_ctime; little_uint32_t i_mtime; little_uint32_t i_dtime; little_uint16_t i_gid; little_uint16_t i_links_count; little_uint32_t i_blocks; little_uint32_t i_flags; little_uint32_t i_osd1; little_uint32_t i_block[15]; little_uint32_t i_generation; // The next two are only valid if s_rev_level >= 1. little_uint32_t i_file_acl; little_uint32_t i_size_high; little_uint32_t i_faddr; little_uint8_t i_osd2[12]; little_uint16_t i_extra_isize; little_uint16_t i_checksum_hi; little_uint32_t i_ctime_extra; little_uint32_t i_mtime_extra; little_uint32_t i_atime_extra; little_uint32_t i_crtime; little_uint32_t i_crtime_extra; little_uint32_t i_version_hi; little_uint32_t i_projid; }; struct BlockGroupDescriptor { little_uint32_t bg_block_bitmap; little_uint32_t bg_inode_bitmap; little_uint32_t bg_inode_table; little_uint16_t bg_free_blocks_count; little_uint16_t bg_free_inodes_count; little_uint16_t bg_used_dirs_count; // These fields are new in ext4. little_uint16_t bg_flags; little_uint32_t bg_exclude_bitmap_lo; little_uint16_t bg_block_bitmal_csum_lo; little_uint16_t bg_inode_bitmap_csum_lo; little_uint16_t bg_itable_unused_lo; little_uint16_t bg_checksum; little_uint32_t bg_block_bitmap_hi; little_uint32_t bg_inode_bitmap_hi; little_uint32_t bg_inode_table_hi; little_uint16_t bg_free_blocks_count_hi; little_uint16_t bg_free_inodes_count_hi; little_uint16_t bg_used_dirs_count_hi; little_uint16_t bg_itable_unused_hi; little_uint32_t bg_exclude_bitmap_hi; little_uint16_t bg_block_bitmal_csum_hi; little_uint16_t bg_inode_bitmap_csum_hi; little_uint32_t reserved; }; struct DirectoryEntry { little_uint32_t inode; little_uint16_t rec_len; little_uint8_t name_len; little_uint8_t file_type; char name[]; }; #define INCOMPAT_FILETYPE 0x2 #define INCOMPAT_64BIT 0x80 #define RO_COMPAT_SPARSE_SUPER 0x1 #define RO_COMPAT_LARGE_FILE 0x2 #define RO_COMPAT_EXTRA_ISIZE 0x40 #define SUPPORTED_INCOMPAT_FEATURES (INCOMPAT_FILETYPE | INCOMPAT_64BIT) #define SUPPORTED_RO_FEATURES \ (RO_COMPAT_SPARSE_SUPER | RO_COMPAT_LARGE_FILE | RO_COMPAT_EXTRA_ISIZE) #define STATE_CLEAN 0x1 class Ext234Vnode; class Ext234Fs : public FileSystem { public: Ext234Fs(const Reference<Vnode>& device, const SuperBlock* superBlock, const Reference<Vnode>& mountPoint, bool readonly); ino_t createInode(uint64_t blockGroup, mode_t mode); bool deallocateInode(ino_t ino, bool dir); void dropVnodeReference(ino_t ino); void finishDropVnodeReference(); uint64_t getBlockGroup(ino_t ino); struct timespec getInodeATime(const Inode* inode); struct timespec getInodeCTime(const Inode* inode); struct timespec getInodeMTime(const Inode* inode); uint64_t getInodeSize(const Inode* inode); Reference<Vnode> getRootDir() override; Reference<Ext234Vnode> getVnode(ino_t ino); Reference<Ext234Vnode> getVnodeIfOpen(ino_t ino); bool hasIncompatFeature(uint32_t feature); bool onUnmount() override; bool readInodeData(const Inode* inode, off_t offset, void* buffer, size_t size); bool resizeInode(ino_t ino, Inode* inode, off_t newSize); void setTime(struct timespec* ts, little_uint32_t* time, little_uint32_t* extraTime); int sync(int flags); bool writeInode(const Inode* inode, uint64_t inodeAddress); bool writeInodeData(const Inode* inode, off_t offset, const void* buffer, size_t size); private: uint64_t allocateBlock(uint64_t blockGroup); uint64_t allocateBlockInGroup(uint64_t blockGroup, BlockGroupDescriptor* bg, uint32_t freeBlocks); ino_t allocateInode(uint64_t blockGroup, bool dir); ino_t allocateInodeInGroup(uint64_t blockGroup, BlockGroupDescriptor* bg, uint32_t freeInodes, bool dir); bool deallocateBlock(uint64_t blockNumber); bool decreaseInodeBlockCount(Inode* inode, uint64_t oldBlockCount, uint64_t newBlockCount); uint64_t getBlockCount(uint64_t fileSize); uint64_t getInodeBlockAddress(const Inode* inode, uint64_t block); bool hasReadOnlyFeature(uint32_t feature); bool increaseInodeBlockCount(ino_t ino, Inode* inode, uint64_t oldBlockCount, uint64_t newBlockCount); bool read(void* buffer, size_t size, off_t offset); bool readBlockGroupDesc(uint64_t blockGroup, BlockGroupDescriptor* bg); bool readInode(uint64_t ino, Inode* inode, uint64_t& inodeAddress); bool write(const void* buffer, size_t size, off_t offset); bool writeSuperBlock(); public: uint64_t blockSize; dev_t dev; size_t inodeSize; Reference<Vnode> mountPoint; bool readonly; kthread_mutex_t renameMutex; private: kthread_mutex_t blocksMutex; Reference<Vnode> device; uint64_t groupCount; size_t gdtSize; kthread_mutex_t inodesMutex; size_t openVnodes; SuperBlock superBlock; HashTable<Ext234Vnode, ino_t> vnodes; Ext234Vnode* vnodesBuffer[10000]; kthread_mutex_t vnodesMutex; }; class Ext234Vnode : public Vnode { public: Ext234Vnode(Ext234Fs* fs, ino_t ino, const Inode* inode, uint64_t inodeAddress); ~Ext234Vnode(); int chmod(mode_t mode) override; int chown(uid_t uid, gid_t gid) override; int ftruncate(off_t length) override; Reference<Vnode> getChildNode(const char* name) override; Reference<Vnode> getChildNode(const char* path, size_t length) override; size_t getDirectoryEntries(void** buffer, int flags) override; char* getLinkTarget() override; ino_t hashKey() { return stats.st_ino; } bool isSeekable() override; int link(const char* name, const Reference<Vnode>& vnode) override; off_t lseek(off_t offset, int whence) override; int mkdir(const char* name, mode_t mode) override; int mount(FileSystem* filesystem) override; void onLink() override; bool onUnlink(bool force) override; Reference<Vnode> open(const char* name, int flags, mode_t mode) override; long pathconf(int name) override; short poll() override; ssize_t pread(void* buffer, size_t size, off_t offset, int flags) override; ssize_t pwrite(const void* buffer, size_t size, off_t offset, int flags) override; ssize_t readlink(char* buffer, size_t size) override; void removeReference() const override; int rename(const Reference<Vnode>& oldDirectory, const char* oldName, const char* newName) override; Reference<Vnode> resolve() override; int symlink(const char* linkTarget, const char* name) override; int sync(int flags) override; int unlink(const char* name, int flags) override; int unmount() override; int utimens(struct timespec atime, struct timespec mtime) override; protected: void updateTimestamps(bool access, bool status, bool modification) override; private: bool addChildNode(const char* name, size_t nameLength, ino_t ino, unsigned char dt); uint64_t findDirectoryEntry(const char* name, size_t nameLength, DirectoryEntry* de); Reference<Vnode> getChildNodeUnlocked(const char* path, size_t length); bool isAncestor(const Reference<Vnode>& vnode); int linkUnlocked(const char* name, size_t nameLength, const Reference<Vnode>& vnode); int unlinkUnlocked(const char* name, int flags); bool updateParent(const Reference<Ext234Vnode>& parent); void writeTimestamps(); public: Ext234Vnode* nextInHashTable; private: Ext234Fs* filesystem; Inode inode; uint64_t inodeAddress; bool inodeModified; FileSystem* mounted; }; #endif
[ "denniswoelfing@gmx.de" ]
denniswoelfing@gmx.de
c8a57f6e5e83c42d0e87e469ea2ef0889d85451b
226a1ddbd3342970a7181c1a07b69ba073132204
/Online_of_Baekjoon/DataStructure/q_1935.cpp
e1861088a2c785b9abf85971ecae323dad8178d4
[]
no_license
jig6795/Algorithm
ccef8932dfb9b1d9835bb067b5ff702a7791a05f
8d9d5fadffb7325c3cd9a2b822384d1595ef3c4c
refs/heads/master
2020-07-22T13:59:29.055552
2020-05-12T06:43:14
2020-05-12T06:43:14
207,226,362
0
0
null
null
null
null
UTF-8
C++
false
false
1,691
cpp
// Q1935 // 후위 표기식 2 // 시간복잡도 - O(n) #include <iostream> #include <vector> #include <stack> using namespace std; int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); int testCaseNum = 0; cin >> testCaseNum; cin.ignore(); string str; getline(cin, str); stack<double> st; vector<double> _number(testCaseNum); for(int i=0;i<testCaseNum;i++) { cin >> _number[i]; } double first, second, third; for(int i=0;i<str.length();i++) { //사칙연산은 STACK에서 두 수를 POP해서 계산 후 PUSH if(str[i] == '+') { first = st.top(); st.pop(); second = st.top(); st.pop(); third = second+first; st.push(third); } else if(str[i] == '-') { first = st.top(); st.pop(); second = st.top(); st.pop(); third = second-first; st.push(third); } else if(str[i] == '*') { first = st.top(); st.pop(); second = st.top(); st.pop(); third = second*first; st.push(third); } else if(str[i] == '/') { first = st.top(); st.pop(); second = st.top(); st.pop(); third = second/first; st.push(third); } else { st.push(_number[(int)str[i]-65]); } } //소수점 둘째 자리로 고정하기 cout << fixed; cout.precision(2); cout << st.top(); return 0; }
[ "wjd1rb@gmail.com" ]
wjd1rb@gmail.com
488fbf0659a420aed10227ae5b523bff69dbeb0a
00d66b0743d2a44e3b1173f2c8eda18479f9b0da
/svt/live/devices/space_mouse/live_space_mouse.cpp
373b54368a55aa64ea1696ad5a453dc0048c8b92
[]
no_license
biomachina-lab/Sculptor
f72c8c924423194da847b407d33da1e6be6fd51c
3276b6cf55b681bb8c03ed464727d4f3f576b7f8
refs/heads/master
2021-01-23T18:56:39.440776
2015-01-17T05:05:18
2015-01-17T05:05:18
29,320,420
0
0
null
null
null
null
UTF-8
C++
false
false
20,971
cpp
/*************************************************************************** live_space_mouse.cpp -------------------- begin : 11.04.2001 (linux), 13.09.2005 (win) author : Stefan Birmanns, Maik Boltes email : sculptor@biomachina.org, sculptor@biomachina.org ***************************************************************************/ #include <live.h> #include <svt_matrix4.h> #include <svt_init.h> #include <stdio.h> /****************************************************************************** ** variables ******************************************************************************/ /* Program Specific Includes */ Real32 xpos =0.; Real32 ypos =0.; Real32 zpos =0.; Real32 xrot =0.; Real32 yrot =0.; Real32 zrot =0.; Int16 buttons[10]; Int16 no_trans = 0; Int16 no_rot = 0; Int16 abs_mode = 0; svt_matrix4<Real32> mat; svt_matrix4<Real32> rotx_mat; svt_matrix4<Real32> roty_mat; svt_matrix4<Real32> rotz_mat; Real32 g_aSMMat[4][4]; #ifndef WIN32 #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xos.h> #include <X11/Xatom.h> #include <X11/keysym.h> extern "C" { #include "xdrvlib.h" } /****************************************************************************** ** variables ******************************************************************************/ Display* display; Window win, root; MagellanFloatEvent MagellanEvent; char MagellanBuffer[ 256 ]; XEvent report; double MagellanSensitivity = 1.0f; #define EVENT_MASK ExposureMask | StructureNotifyMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask /****************************************************************************** ** device functions ******************************************************************************/ /* open the device */ extern "C" Int16 devOpen() { if ((display = XOpenDisplay(":0.0")) == NULL) { printf("live_space_mouse: failed to connect to X server!\n"); return 0; } root = XRootWindow(display, DefaultScreen(display)); win = XCreateSimpleWindow( display, root, 0,0, 10,10, 20, BlackPixel(display,DefaultScreen(display)), WhitePixel(display,DefaultScreen(display))); if ( !MagellanInit( display, win ) ) { fprintf( stderr, "live_space_mouse: no space mouse driver is running. Exit ... \n" ); return 0; } XSelectInput( display, win, KeyPressMask | KeyReleaseMask ); mat.setTranslation( 0.0f, 0.0f, 0.0f ); rotx_mat.setTranslation( 0.0f, 0.0f, 0.0f ); roty_mat.setTranslation( 0.0f, 0.0f, 0.0f ); rotz_mat.setTranslation( 0.0f, 0.0f, 0.0f ); return 1; } /* close the device */ extern "C" Int16 devClose() { return 1; } /* update the device data */ extern "C" void devUpdate() { if (XPending(display)) { XNextEvent( display, &report ); switch( report.type ) { case ClientMessage : switch( MagellanTranslateEvent( display, &report, &MagellanEvent, 1.0, 1.0 ) ) { case MagellanInputMotionEvent : MagellanRemoveMotionEvents( display ); if (!abs_mode) { if (!no_trans) { xpos = MagellanEvent.MagellanData[ MagellanX ] / 10000; ypos = MagellanEvent.MagellanData[ MagellanY ] / 10000; zpos = -MagellanEvent.MagellanData[ MagellanZ ] / 10000; } if (!no_rot) { xrot = MagellanEvent.MagellanData[ MagellanA ] / 100.0f; yrot = MagellanEvent.MagellanData[ MagellanB ] / 100.0f; zrot = -MagellanEvent.MagellanData[ MagellanC ] / 100.0f; } } else { mat.loadIdentity(); if (!no_trans) { xpos = MagellanEvent.MagellanData[ MagellanX ] / 100; ypos = MagellanEvent.MagellanData[ MagellanY ] / 100; zpos = -MagellanEvent.MagellanData[ MagellanZ ] / 100; } if (!no_rot) { xrot = MagellanEvent.MagellanData[ MagellanA ]; yrot = MagellanEvent.MagellanData[ MagellanB ]; zrot = -MagellanEvent.MagellanData[ MagellanC ]; } } // init rotation matrices rotx_mat.loadIdentity(); roty_mat.loadIdentity(); rotz_mat.loadIdentity(); rotx_mat.rotate( 0, (xrot*PI)/180.0f ); roty_mat.rotate( 1, (yrot*PI)/180.0f ); rotz_mat.rotate( 2, (zrot*PI)/180.0f ); // multiply them mat *= rotx_mat; mat *= roty_mat; mat *= rotz_mat; // and add translation mat.translate( xpos, ypos, zpos ); break; case MagellanInputButtonPressEvent : buttons[ MagellanEvent.MagellanButton-1 ] = 1; switch ( MagellanEvent.MagellanButton ) { case 2: buttons[0] = (buttons[0]==0) ? 1 : 0; printf("live_space_mouse: Toggle locking picker\n"); break; case 5: MagellanApplicationSensitivity( display, MagellanSensitivity / 2.0 ); MagellanSensitivity = MagellanSensitivity <= 1.0/32.0 ? 1.0/32.0 : MagellanSensitivity/2.0; break; case 6: MagellanApplicationSensitivity( display, MagellanSensitivity * 2.0 ); MagellanSensitivity = MagellanSensitivity >= 32.0 ? 32.0 : MagellanSensitivity*2.0; break; case 7: MagellanApplicationSensitivity( display, 1.0 ); MagellanSensitivity = 1.0; break; }; switch( MagellanEvent.MagellanButton ) { case 5: case 6: case 7: printf("live_space_mouse: Application Sensitivity = %lf \n", MagellanSensitivity ); break; }; break; case MagellanInputButtonReleaseEvent : buttons[ MagellanEvent.MagellanButton-1 ] = 0; switch( MagellanEvent.MagellanButton ) { case 3: if (no_trans) { printf("live_space_mouse: translation enabled!\n"); no_trans = 0; } else { printf("live_space_mouse: translation disabled!\n"); no_trans = 1; } break; case 4: if (no_rot) { printf("live_space_mouse: rotation enabled!\n"); no_rot = 0; } else { printf("live_space_mouse: rotation disabled!\n"); no_rot = 1; } break; case 8: if (abs_mode) { printf("live_space_mouse: relative mode!\n"); abs_mode = 0; } else { printf("live_space_mouse: absolute mode!\n"); abs_mode = 1; } break; } break; default : /* another ClientMessage event */ break; } break; } } } #else char g_aClassName[] = "Live_SPACE_MOUSE"; HINSTANCE g_sHinst; // Main hinstance of app HWND g_sHwnd; // Handle of window //#include <svt_window.h> //extern HWND svt_getHWNDFromWin(svt_win_handle); //system: svt_windows_win32.cpp // SpaceWare Specific Includes extern "C" { #include "si.h" /* Required for any SpaceWare support within an app.*/ #include "siapp.h" /* Required for siapp.lib symbols */ } /****************************************************************************** ** variables ******************************************************************************/ /* Program Specific Includes */ SiHdl devHdl = NULL; /* Handle to Spaceball Device */ double sensitivity = 1.0f; /****************************************************************************** ** device functions ******************************************************************************/ /* open the device */ extern "C" DLLEXPORT Int16 devOpen() { SiOpenData oData; /* OS Independent data to open ball */ /* init the SpaceWare input library */ if (SiInitialize() == SPW_DLL_LOAD_ERROR) { fprintf( stderr, "live_space_mouse: Could not load SiAppDll dll files. Exit ... \n" ); return 0; } SiOpenWinInit(&oData, g_sHwnd); /* svt_getHWNDFromWin(svt_getCurrentWindow()); init Win. platform specific data */ /* open data, which will check for device type and return the device handle to be used by this function */ if ((devHdl = SiOpen("live_space_mouse", SI_ANY_DEVICE, SI_NO_MASK, SI_EVENT, &oData)) == NULL) { SiTerminate(); /* called to shut down the SpaceWare input library */ fprintf( stderr, "live_space_mouse: no space mouse driver is running. Exit ... \n" ); return 0; } mat.setTranslation( 0.0f, 0.0f, 0.0f ); rotx_mat.setTranslation( 0.0f, 0.0f, 0.0f ); roty_mat.setTranslation( 0.0f, 0.0f, 0.0f ); rotz_mat.setTranslation( 0.0f, 0.0f, 0.0f ); printf("live_space_mouse: init space mouse successful\n"); return 1; /* opened device succesfully */ } /* close the device */ extern "C" DLLEXPORT Int16 devClose() { // if (devHdl) // SiClose(devHdl); return 1; } /* update the device data */ extern "C" DLLEXPORT void devUpdate() { int num; /* number of button pressed */ MSG msg; /* incoming message to be evaluated */ BOOL handled; /* is message handled yet */ SiSpwEvent Event; /* SpaceWare Event */ SiGetEventData EData; /* SpaceWare Event Data */ handled = SPW_FALSE; /* init handled */ bool svtScene = false; /* native svt scene or not */ bool msgAvailable; /* is message available */ // to check, if a native svt scene or a device server uses the space mouse device if (svt_getScene()) { svtScene = true; // client-server would hang by waiting for event msgAvailable = GetMessage(&msg, NULL, 0, 0); } else { msgAvailable = PeekMessage(&msg, NULL, 0, 0 , PM_REMOVE); //g_sHwnd PM_REMOVE PM_NOREMOVE } if (msgAvailable) { /* init Window platform specific data for a call to SiGetEvent */ SiGetEventWinInit(&EData, msg.message, msg.wParam, msg.lParam); /* check whether msg was a Spaceball event and process it */ if (SiGetEvent (devHdl, 0, &EData, &Event) == SI_IS_EVENT) { if (Event.type == SI_MOTION_EVENT) { if (!abs_mode) { if (!no_trans) { xpos = Event.u.spwData.mData[SI_TX] / 10000.0f; ypos = Event.u.spwData.mData[SI_TY] / 10000.0f; zpos = -Event.u.spwData.mData[SI_TZ] / 10000.0f; } if (!no_rot) { xrot = Event.u.spwData.mData[SI_RX] / 100.0f; yrot = Event.u.spwData.mData[SI_RY] / 100.0f; zrot = -Event.u.spwData.mData[SI_RZ] / 100.0f; } } else { mat.loadIdentity(); if (!no_trans) { xpos = 2*Event.u.spwData.mData[SI_TX] / 1000.0f; ypos = 2*Event.u.spwData.mData[SI_TY] / 1000.0f; zpos = -2*Event.u.spwData.mData[SI_TZ] / 1000.0f; } if (!no_rot) { xrot = 2*Event.u.spwData.mData[SI_RX] / 10.0f; yrot = 2*Event.u.spwData.mData[SI_RY] / 10.0f; zrot = -2*Event.u.spwData.mData[SI_RZ] / 10.0f; } } // init rotation matrices rotx_mat.loadIdentity(); roty_mat.loadIdentity(); rotz_mat.loadIdentity(); // init rotation matrices rotx_mat.rotate( 0, (sensitivity*xrot*PI)/180.0f ); roty_mat.rotate( 1, (sensitivity*yrot*PI)/180.0f ); rotz_mat.rotate( 2, (sensitivity*zrot*PI)/180.0f ); // multiply them mat *= rotx_mat; mat *= roty_mat; mat *= rotz_mat; // and add translation mat.translate( sensitivity*xpos, sensitivity*ypos, sensitivity*zpos ); } // if (Event.type == SI_ZERO_EVENT) // { // SbZeroEvent(); /* process Spaceball zero event */ // } if (Event.type == SI_BUTTON_EVENT) { /* process Spaceball button press event */ if ((num = SiButtonPressed (&Event)) != SI_NO_BUTTON) { buttons[ num-1 ] = 1; switch ( num ) { //case SI_PICK_BUTTON, SI_RESET_BUTTON, SI_DIALOG_BUTTON: case 2: buttons[0] = (buttons[0]==0) ? 1 : 0; printf("live_space_mouse: Toggle locking picker\n"); break; case 5: sensitivity = sensitivity <= 1.0/32.0 ? 1.0/32.0 : sensitivity/2.0; break; case 6: sensitivity = sensitivity >= 32.0 ? 32.0 : sensitivity*2.0; break; case 7: sensitivity = 1.0; break; }; switch ( num ) { case 5: case 6: case 7: printf("live_space_mouse: Application Sensitivity = %lf \n", sensitivity ); break; } } /* process Spaceball button release event */ if ((num = SiButtonReleased (&Event)) != SI_NO_BUTTON) { buttons[ num-1 ] = 0; switch( num ) { case 3: if (no_trans) { printf("live_space_mouse: translation enabled!\n"); no_trans = 0; } else { printf("live_space_mouse: translation disabled!\n"); no_trans = 1; } break; case 4: if (no_rot) { printf("live_space_mouse: rotation enabled!\n"); no_rot = 0; } else { printf("live_space_mouse: rotation disabled!\n"); no_rot = 1; } break; case 8: if (abs_mode) { printf("live_space_mouse: relative mode!\n"); abs_mode = 0; } else { printf("live_space_mouse: absolute mode!\n"); abs_mode = 1; } break; } } } handled = SPW_TRUE; /* spaceball event handled */ } /* not a Spaceball event, let windows handle it */ if (svtScene && (handled == SPW_FALSE)) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } } #endif /****************************************************************************** ** channel functions ******************************************************************************/ /* chn1 = position of the mouse as a matrix (4x4) */ // nr:button meanings: (channel = nr+1 = button[nr-1]) // 1: pick button from application // 2: lock pick button // 3: toggle enable/disable translation // 4: toggle enable/disable rotation // 5: decrease sensitivity // 6: increase sensitivity // 7: reset sensitivity // 8: toggle absolute mode extern "C" DLLEXPORT UInt16 chnNum() { return 11; } extern "C" DLLEXPORT UInt8 chnType(int chn) { if (chn == 1) return LIVE_CHN_MATRIX; if (chn < 11) return LIVE_CHN_INT; return LIVE_CHN_UNKNOWN; } /* direction is input for all channels */ extern "C" DLLEXPORT UInt8 chnDir(UInt16) { return LIVE_CHN_INPUT; } /* return the integer data (only valid for the buttons) */ extern "C" DLLEXPORT Int16 chnGetDataINT(UInt16 chn) { if (chn == 1 || chn > 11) return 0; return buttons[chn-2]; } /* return the char data (not valid here) */ extern "C" DLLEXPORT char chnGetDataCHAR(UInt16) { return ' '; } /* return the Real32 data (not valid here) */ extern "C" DLLEXPORT Real32 chnGetDataFLOAT(UInt16) { return -1.0f; } /* return the matrix data (only valid for chn1) */ extern "C" DLLEXPORT Real32* chnGetDataMAT(UInt16 chn) { if (chn == 1) { for(int x=0;x<4;x++) for(int y=0;y<4;y++) g_aSMMat[x][y] = mat[y][x]; return (Real32*) g_aSMMat; } else return NULL; } /* the functions for writing data to the device (not valid for a mouse) */ extern "C" DLLEXPORT void chnSetDataINT(UInt16, Int16){}; extern "C" DLLEXPORT void chnSetDataCHAR(UInt16, char){}; extern "C" DLLEXPORT void chnSetDataFLOAT(UInt16, Real32){}; extern "C" DLLEXPORT void chnSetDataMAT(UInt16, Real32*){}; #ifdef WIN32 /////////////////////////////////////////////////////////////////////////////// // window /////////////////////////////////////////////////////////////////////////////// LRESULT CALLBACK __wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, msg, wParam, lParam); } void __createWindow() { WNDCLASS wc; wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION)); wc.lpszMenuName = NULL; wc.lpszClassName = g_aClassName; //wc.hbrBackground = GetStockBrush(WHITE_BRUSH); wc.hInstance = g_sHinst; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = __wndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; if (!RegisterClass(&wc)) { cout << "live_space_mouse: cannot register window class. Fatal Error!" << endl; exit(1); } g_sHwnd = CreateWindow(g_aClassName, "live_space_mouse", WS_MINIMIZE | WS_DISABLED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, g_sHinst, 0 ); // ShowWindow(g_sHwnd, SW_SHOW); } extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { g_sHinst = hInstance; if (dwReason == DLL_PROCESS_ATTACH) { // cout also needed for some waiting time before calling createWindow() cout << "live_space_mouse: init reference window" << endl; __createWindow(); } else if (dwReason == DLL_PROCESS_DETACH) { cout << "live_space_mouse: close reference window" << endl; devClose(); //__exitDI(); } return 1; } #endif
[ "wriggers@biomachina.org" ]
wriggers@biomachina.org
b5e4f20bb846c9ca98e0f939030f2e30364404e7
20a59a738c1d8521dc95c380190b48d7bc3bb0bb
/layouts/aknlayout2/generated/Nhd4_uiaccel/uiaccel_elaf_nhd4_small_pack.cpp
cf2c2127139c69bc1f7afa9ba90e97c699f47715
[]
no_license
SymbianSource/oss.FCL.sf.mw.uiresources
376c0cf0bccf470008ae066aeae1e3538f9701c6
b78660bec78835802edd6575b96897d4aba58376
refs/heads/master
2021-01-13T13:17:08.423030
2010-10-19T08:42:43
2010-10-19T08:42:43
72,681,263
2
0
null
null
null
null
UTF-8
C++
false
false
1,290
cpp
/* * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ // This customisation implements the interface defined in LayoutPack.cdl #include "uiaccel_elaf_nhd4_small_pack.h" namespace UiAccel_Elaf_Nhd4_Small_Pack { _LIT(name,"UiAccel_Elaf_Nhd4_Small_Pack"); SCdlSize const size = { 360, 640 }; TAknLayoutId const id = EAknLayoutIdELAF; #include "aknlayoutscalable_elaf_hnp4_c_nhd4_prt_tch_small.h" CDL_ARRAY_START(TCdlRef, contents) { LOCAL_CDL_REF(AknLayoutScalable_Elaf_hnp4_c_nhd4_prt_tch_Small), } CDL_ARRAY_END(TCdlRef, contents); TAknUiZoom const zoom = EAknUiZoomSmall; TInt const styleHash = 0x0a86a2c2; // screen style NHD4 TInt const priority = 0; TInt const appUid = 0x00000000; const LayoutPack::SCdlImpl KCdlImpl = { LIT_AS_DESC_PTR(name), (const TSize*)&size, &id, &contents, &zoom, &styleHash, &priority, &appUid, }; } // end of namespace UiAccel_Elaf_Nhd4_Small_Pack
[ "kirill.dremov@nokia.com" ]
kirill.dremov@nokia.com
ac8278c0d5235430b80180b33511d19d284749a6
72ef76d8fb65373f5d2b012eb5aa89d64095fba3
/principles/design-pattern/AbstractFactory.cpp
630488b02ea09939321eac8591edd35f2b6192a3
[]
no_license
TwentyFourSevenY/design-pattern
e68ef281c115b1912805b782784f58d2f127ad37
a922433f7db41eb5acb8e8c41b44e9309e2360be
refs/heads/master
2021-06-25T08:41:38.153953
2017-08-18T16:00:53
2017-08-18T16:00:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
169
cpp
// // AbstractFactory.cpp // design-pattern // // Created by Ernest on 5/10/17. // Copyright © 2017 Ernest. All rights reserved. // #include "AbstractFactory.hpp"
[ "iattempt.net@gmail.com" ]
iattempt.net@gmail.com
fa0d17f0dd62991a7015aad8b29d51c37dde7d8a
ff58169fd92e44deae2b546b6b15af2dc6131611
/BinOpOverloadNonMemFunc.CPP
b31f5f275086af28e21100b9495be8c484343680
[]
no_license
sumati-kulkarni/CPP-Programs
9deb53e72a7195ed165974db709f66b3bd6c29ad
5f03149741b772b06ec5258d72207f02cff620cb
refs/heads/master
2021-03-14T05:15:31.256832
2020-03-17T14:59:46
2020-03-17T14:59:46
246,729,279
0
0
null
null
null
null
UTF-8
C++
false
false
918
cpp
/* binary operator overloading implemented as a non-member function */ #include<conio.h> #include<iostream.h> class complex { private: int r,i; public: void read(); void disp(); friend complex operator +(complex,complex); friend complex add(complex,complex); }; void complex::read() { cout<<"\nenter two complex numbers\n"; cin>>r>>i; } void complex::disp() { cout<<"\n\nOUTPUT"; cout<<"\nsum = "<<r<<"+i"<<i; } complex operator +(complex t1,complex t2) { complex t; t.r=t1.r+t2.r; t.i=t1.i+t2.i; return t; } complex add(complex t1,complex t2) { complex t; t.r=t1.r+t2.r; t.i=t1.i+t2.i; return t; } int main() { complex x,y,z; x.read(); y.read(); cout<<"\nusing z=x+y"; z=x+y; z.disp(); cout<<"\n\n\nusing z=add(x,y)"; z=add(x,y); z.disp(); getch(); return 0; }
[ "sumati.kulkarni.90@gmail.com" ]
sumati.kulkarni.90@gmail.com
611e162bcf6350ce756fbadcdd1ef93fb9467352
8f890770bd467cb9526b25315edb53b1cf8ddef6
/Lib/SortLib.h
6b437720484554ee9fb91aa41a3552153b0930ad
[]
no_license
naotaka0608/node-cplus-qsort
85ad33e44d4b486a96dbda5f33c3313f54bac95e
725c71973d36e3fa525fd13cf29f74511b5b9a87
refs/heads/master
2022-11-25T18:49:47.746370
2020-08-02T01:55:29
2020-08-02T01:55:29
284,278,703
0
0
null
null
null
null
UTF-8
C++
false
false
157
h
class SortLib { private: void Swap(int x[], int i, int j); public: SortLib(); ~SortLib(); void QuickSort(int x[], int left, int right); };
[ "" ]
b8330946d59f9f18c088c37100632e1dbd1c9bdb
09af9ed10b43d86bbda1869782523dec6bc6e8f7
/swap/main.cpp
0ccf321f963671c9ca714cd94e37c9d26455a891
[]
no_license
VALIKKKKK/cpp
ef49b462f44e9a1dcaf8903c638e7295f5f5e200
a7a1f4d75abcb5ce7c1b9adeca78d48609dcecc6
refs/heads/master
2020-04-26T11:00:36.714403
2019-04-07T19:31:07
2019-04-07T19:31:07
173,502,354
0
0
null
null
null
null
UTF-8
C++
false
false
334
cpp
#include <iostream> #include <algorithm> using namespace std; int s_swap (int a[],int ,int, bool(*p)(int)) { int sum=0; for(int i=0;i<end;++i) { sum=sum+a[i]; } return sum; } int main() { int (*f)() int a[]={5,1,2,3,4}; cout << psum(c,b)<< endl; cout << psub(b,c)<< endl; return 0; }
[ "kashko2001v@mail.ru" ]
kashko2001v@mail.ru
7a51159205f1e5ecee8852c79b808efb5871d82d
aac8c5cadb249aecedc7b0ccd51010ff5e7bf3b2
/ProjectEuler/23.cpp
8e7550ade52bc183a54c6af00b54c3eb3abc848b
[]
no_license
furkanusta/Competitive-Programming
1b74f1cfc2e6049565d9b31950b325b2b21d2bca
06582650a77ba003cdef31995763100721b399c8
refs/heads/master
2022-05-28T07:18:44.670839
2022-05-19T20:28:11
2022-05-19T20:28:11
37,484,205
1
0
null
null
null
null
UTF-8
C++
false
false
1,130
cpp
/* * Projet Euler * Title: Non-abundant sums * URL: https://projecteuler.net/problem=23 * Author: Furkan Usta * Sat Jun 13 23:28:16 2015 My own solution was a bit long ~5 sec, so I've decided to put someone else's solution credit goes to blazs from discussion thread. */ #include <stdio.h> const int UPPER = 28123; int abundant[UPPER]; int is_abundant(int n); bool is_sum(int n); int main(int argc, char **argv) { int sum = 0; for (int i = 0; i < UPPER; i++) abundant[i] = -1; for (int i = 1; i < UPPER; i++) if (!is_sum(i)) sum += i; printf("%d\n", sum); return 0; } int is_abundant(int n) { int d,sum; if (abundant[n] != -1) return abundant[n]; else { sum = 1; for (d = 2; d*d < n; d++) if (n%d == 0) sum += (d + n/d); // This part really increases the speed if (d*d == n) sum += d; return abundant[n] = sum > n; } } bool is_sum(int n) { for (int p = 1; p <= n/2; p++) if (is_abundant(p) && is_abundant(n-p)) return true; return false; }
[ "furkanusta17@gmail.com" ]
furkanusta17@gmail.com
16e89fd731ce4e1af9fc958c064365554224ccf6
b20203514a73611acd5f226ba4c1668140959e8d
/libagf/src/classifier_obj.h
1bf7fd62300d34ebfbede3bacbcd950d9a7e54d7
[ "MIT" ]
permissive
Edroor/libmsci
978d748e2ec788bc5b28eadf311d4c497d95f705
872dc362292d93ce4966e554494bfa156594c9d9
refs/heads/master
2023-02-22T10:17:52.934272
2021-01-25T05:40:42
2021-01-25T05:40:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,276
h
#ifndef CLASSIFIER_OBJ_H #define CLASSIFIER_OBJ_H 1 #include <stdio.h> #include <gsl/gsl_matrix.h> #include "agf_defs.h" #include "multi_parse.h" namespace libagf { template <typename real, typename cls_t> class binaryclassifier; //"abstract" base class (now supplying default behaviour, so i guess it's //not so abstract after all): template <class real, class cls_t> class classifier_obj { protected: char *name; //the file in which it is contained etc. cls_t ncls; //number of classes dim_ta D; //number of dimensions in test points (for original, non-transformed system only) real **mat; //transformation matrix real *b; //translation vector nel_ta D1; //dimension of transformed system //real *xtran; //transformed feature vector real* do_xtran(real *x); //transforms the feature vector public: classifier_obj(); virtual ~classifier_obj(); //classification returning conditional prob: virtual cls_t classify(real *x, //test point real *p, //returned conditional probabilities real *praw=NULL); //returned "raw" conditional probabilities //classification returning conditional prob: virtual cls_t classify(real *x, //test point real &p, //returned winning conditional probability real *praw=NULL); //returned "raw" conditional probabilities //linear transformation on features (plus translation...): //(transformations are not copied but stored as references) int ltran(real **mat, //tranformation matrix real *b, //constant term dim_ta d1, //first dimension of trans. mat. dim_ta d2, //second " int flag); //transform model? //transform the model: virtual int ltran_model(real **mat, //tranformation matrix real *b, //constant term dim_ta d1, //first dimension of trans. mat. dim_ta d2); //second " //copy transformation from another classifier: int copy_ltran(classifier_obj<real, cls_t> *other); //classification including linear transformation of feature space: cls_t classify_t(real *x, //test point real *p, //returned conditional probabilities real *praw=NULL); //returned "raw" conditional probabilities //classification returning conditional prob: //(including linear transformation of feature space) cls_t classify_t(real *x, //test point real &p, //returned winning conditional probability real *praw=NULL); //returned "raw" conditional probabilities //return list of classes (default is 0..n_cls-1): virtual cls_t class_list(cls_t *cls); //depth of hierarchy (default is 1): virtual int max_depth(int cur=0); virtual cls_t n_class(); //return number of classes (default is ncls) virtual dim_ta n_feat(); //return number of features for transformed problem (default is D1) dim_ta n_feat_t(); //return number of features for non-transformed problem //for use with an external command: //only winning probability is returned: virtual void batch_classify(real **x, //list of test points cls_t *cls, //returned classes real *p, //returned probabilities nel_ta n, //number of test points dim_ta nvar); //number of variables //one probability is returned for each class: virtual void batch_classify(real **x, cls_t *cls, real **p, //pre-allocated matrix of probabilities nel_ta n, dim_ta nvar); //only winning probability is returned: //test point is linearly transformed first void batch_classify_t(real **x, //list of test points cls_t *cls, //returned classes real *p, //returned probabilities nel_ta n, //number of test points dim_ta nvar); //number of variables //one probability is returned for each class: //test point is linearly transformed first void batch_classify_t(real **x, cls_t *cls, real **p, //pre-allocated matrix of probabilities nel_ta n, dim_ta nvar); //we're roping these classes in to do double duty: virtual void print(FILE *fs, //output file stream char *fbase=NULL, //base name of model files int depth=0); //for pretty, indented output //generate commands for training: virtual int commands(multi_train_param &param, //see structure in multi_parse.h cls_t **clist, //list of classes, partitioned if necessary char *fbase); //base name of model files //do this properly: virtual int //returns number of models get_code (int **code, //coding matrix char **model); //list of binary models //for extension to continuum retrievals (setting raw prob.): virtual void set_id(cls_t *id); virtual cls_t collect_binary_classifiers(binaryclassifier<real, cls_t> **list); //load and save files all in one as ASCII: virtual int load(FILE *fs); virtual int save(FILE *fs); //sure, lets do it, a general "training" method: virtual void train(real **train, //features data cls_t *cls, //class labels nel_ta ntrain, //number of samples int type, //what type of training? real *param); //parameters }; //lame, doesn't really do anything, but makes a lot of the methods in //multiclass_hier a lot more elegant: //(need to do the same for the dendrogram...) template <class real, class cls_t> class oneclass:public classifier_obj<real, cls_t> { protected: cls_t cls; public: oneclass(cls_t cl); virtual ~oneclass(); virtual cls_t classify(real *x, real &p, real *praw=NULL); virtual cls_t classify(real *x, real *p, real *praw=NULL); virtual int ltran_model(real **mat, real *b, dim_ta d1, dim_ta d2); virtual cls_t class_list(cls_t *cls); virtual int max_depth(int cur=0); virtual void batch_classify(real **x, cls_t *cls, real *p, nel_ta n, dim_ta nvar); virtual void batch_classify(real **x, cls_t *cls, real **p, nel_ta n, dim_ta nvar); virtual void print(FILE *fs, char *fbase=NULL, int depth=0); virtual int commands(multi_train_param &param, cls_t **clist, char *fbase); virtual int load(FILE *fs); virtual int save(FILE *fs); }; } #endif
[ "petey@peteysoft.org" ]
petey@peteysoft.org
103a8fe9d84ad562b287aac389970539bcb40bd6
76fccfc285e60e37ba315e5b283e220f7538102d
/Xtra/XDK/Include/muiitem.h
8eaed4bbdc668324ef39aad40bd074a7326d45d5
[]
no_license
lb90/walnut-xtra
fad41ecac313200a5fd48be3327398838282dbd6
f68673c8399077e8ac31723f4c44bc2287ceab2c
refs/heads/master
2022-02-18T21:47:09.347873
2019-08-03T16:38:12
2019-08-03T16:38:12
197,606,335
1
0
null
null
null
null
UTF-8
C++
false
false
12,588
h
/* ADOBE SYSTEMS INCORPORATED Copyright 1994 - 2008 Adobe Macromedia Software LLC All Rights Reserved NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms of the Adobe license agreement accompanying it. If you have received this file from a source other than Adobe, then your use, modification, or distribution of it requires the prior written permission of Adobe. */ #ifndef _H_MuiItem #define _H_MuiItem /* ================================================================================ Purpose: Provides access to XSupport library. To use XSupport, you must link the XSupport.lib into your Xtra. Not that XSupport is not available for win16. Header for C++ objects to create, manipulate, and destroy items in an itemArray used in conjunction with muidialog. =================================================================================== */ /////////////////////////////////////////////////////////////////////////////////// // // Description // /////////////////////////////////////////////////////////////////////////////////// /* This file provides wrappers for all of the supported widget types. These give you a simple way to create dialogs programmatically. You need to use these wrappers in order to use MuiDialogWrapper. See the example in the XDK for usage. Each widget object you create will wrap around that data for one MuiDialog item in your item array, which you pass into the dialog on initialization. See MuiInit.T for a full understanding of the data that is being created/modified with the wrapper objects methods described below. The structures created are TMuiItems. */ /////////////////////////////////////////////////////////////////////////////////// // // Includes // /////////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus #include "MuiHelpr.h" #endif // NOTE: If OLDROUTINENAMES if defined Apple declares GetItem and SetItem as macros. #if defined( MACINTOSH ) && OLDROUTINENAMES #ifdef GetItem #undef GetItem #endif #ifdef SetItem #undef SetItem #endif #endif /////////////////////////////////////////////////////////////////////////////////// // // Constants // /////////////////////////////////////////////////////////////////////////////////// // Button Styles, yes it is yet another enumeration enum { kMuiItemNormal = 0, kMuiItemToggle, // Toggle style button kMuiItemCancel, // This button is selected when user hits Escape or Command-Period kMuiItemDefault // This button is selected when user hits Enter or Return }; typedef MoaShort TMuiHelpButtonStyle; enum { kMuiDirectionVertical = 1, kMuiDirectionHorizontal = 0 }; typedef MoaBool TMuiDirection; /////////////////////////////////////////////////////////////////////////////////// // // MuiItemHelp // /////////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus class MuiItemWrapper { protected: friend class MuiDialogWrapper; virtual TMuiItem& GetItemRef( void ); public: MuiItemWrapper( TMuiItem pItem[], MoaLong index, TMuiWindowType type, MoaLong x, MoaLong y, MoaLong width = 0, MoaLong height = 0, MoaBool enabled = TRUE ); // for derived classes MuiItemWrapper( TMuiItem pItem[], MoaLong index ); virtual ~MuiItemWrapper( void ); virtual void SetParameters( MoaLong x, MoaLong y, MoaLong width = 0, MoaLong height = 0, MoaBool enabled = TRUE ); virtual MoaLong GetIndex( void ) const; virtual TMuiWidgetType GetType( void ) const; virtual void SetType( TMuiWidgetType ); virtual const PTMuiItem GetItem( void ) const; virtual void SetItem( PTMuiItem ); // replaces contents virtual MoaLong GetX( void ) const; virtual void SetX( MoaLong ); virtual MoaLong GetY( void ) const; virtual void SetY( MoaLong ); virtual MoaLong GetWidth( void ) const; virtual void SetWidth( MoaLong ); virtual MoaLong GetHeight( void ) const; virtual void SetHeight( MoaLong ); virtual MoaBool GetEnabled( void ); virtual void SetEnabled( MoaBool ); virtual ConstPMoaChar GetTitle( void ); virtual void SetTitle( ConstPMoaChar ); virtual ConstPMoaChar GetTooltip( void ) const; virtual void SetTooltip( ConstPMoaChar ); virtual MoaMmValue& GetMmValue( void ) const; virtual void SetValue( const MoaMmValue& ); virtual MoaBitmap GetBitmapValue( void ) const; virtual void SetValue( MoaBitmap ); virtual MoaBool GetBoolValue( void ) const; virtual void SetValue( MoaBool ); virtual MoaDouble GetDoubleValue( void ) const; virtual void SetValue( MoaDouble ); virtual MoaLong GetIntValue( void ) const; virtual void SetValue( MoaLong ); // default argument is there to maintain compatibility with older less wise code! virtual void GetStringValue( PMoaChar someStringPtr, MoaUlong bufLength = 0 ) const; virtual void SetValue( PMoaChar ); virtual MoaMmValue& GetAttributes( void ) const; virtual void SetAttributes( const MoaMmValue& ); // cast operator calls GetValue virtual operator MoaMmValue& ( void ) const; virtual operator PMoaMmValue ( void ) const; private: TMuiItem& mItem; MoaLong mIndex; }; typedef MuiItemWrapper * PMuiItemWrapper; class MuiItemWindowBegin : public MuiItemWrapper { public: MuiItemWindowBegin( TMuiItem pItem[], MoaLong index ); }; class MuiItemWindowEnd : public MuiItemWrapper { public: MuiItemWindowEnd( TMuiItem pItem[], MoaLong index ); }; class MuiItemTabBegin : public MuiItemWrapper { public: MuiItemTabBegin( TMuiItem pItem[], MoaLong index ); }; class MuiItemTabEnd : public MuiItemWrapper { public: MuiItemTabEnd( TMuiItem pItem[], MoaLong index ); }; class MuiItemGroupBegin : public MuiItemWrapper { public: MuiItemGroupBegin( TMuiItem pItem[], MoaLong index, TMuiDirection dir ); }; class MuiItemGroupEnd : public MuiItemWrapper { public: MuiItemGroupEnd( TMuiItem pItem[], MoaLong index, TMuiDirection dir ); }; class MuiItemButton : public MuiItemWrapper { public: MuiItemButton( TMuiItem pItem[], MoaLong index, ConstPMoaChar title, MoaBool tiny = FALSE, TMuiHelpButtonStyle buttonType = 0 ); }; class MuiItemCheckbox : public MuiItemWrapper { public: MuiItemCheckbox( TMuiItem pItem[], MoaLong index, ConstPMoaChar title, MoaBool selected = FALSE ); }; class MuiItemRadio : public MuiItemWrapper { public: MuiItemRadio( TMuiItem pItem[], MoaLong index, ConstPMoaChar title, MoaBool selected = FALSE ); }; class MuiItemText : public MuiItemWrapper { public: MuiItemText( TMuiItem pItem[], MoaLong index, ConstPMoaChar title, MoaBool editable, MoaBool tiny = FALSE, TMuiSymbol align = kMuiTextAlignDefault ); virtual ~MuiItemText( void ); // overrides virtual ConstPMoaChar GetTitle( void ); virtual void SetTitle( ConstPMoaChar ); protected: PMoaChar mTextString; }; class MuiItemDivider : public MuiItemWrapper { public: MuiItemDivider( TMuiItem pItem[], MoaLong index, TMuiDirection dir ); }; class MuiItemBitmap : public MuiItemWrapper { public: MuiItemBitmap( TMuiItem pItem[], MoaLong index, MoaShort iconID, PMoaBitmap bitmap = NULL ); }; class MuiItemSlider : public MuiItemWrapper { public: MuiItemSlider( TMuiItem pItem[], MoaLong index, MoaLong min, MoaLong max, MoaLong initial, MoaBool showTicks = FALSE, MoaBool showValue = FALSE, MoaLong increment = 0, MoaDouble accel = 0.0f ); MuiItemSlider( TMuiItem pItem[], MoaLong index, MoaDouble min, MoaDouble max, MoaDouble initial, MoaBool showTicks = FALSE, MoaBool showValue = FALSE, MoaDouble increment = 0, MoaDouble accel = 0.0f ); }; class MuiItemPopup : public MuiItemWrapper { public: // Note: when the popup is editable it's value is just like that of edit text (the text) // to retrieve the value index use the GetPopupValueIndex method, this will do the right // thing for you. MuiItemPopup( TMuiItem pItem[], MoaLong index, MoaBool tiny = FALSE, MoaBool editable = FALSE ); MoaError AppendItems( PMoaChar stringArray[], MoaLong count = 1 ); MoaError AppendItems( MoaLong intArray[], MoaLong count = 1); MoaError AppendItems( MoaDouble doubleArray[], MoaLong count = 1 ); /* Extract a value out of the popups list of values, given an index into the list. Useful if you don't want to store a separate list of values, or if the list is changing while the dialog is running. */ MoaError GetPopupValueIndex( MoaLong& index ); // Overrides MoaBool GetEnabled( void ); void SetEnabled( MoaBool ); }; typedef MuiItemPopup * PMuiItemPopup; class MuiItemListBox : public MuiItemWrapper { public: // Note: when the popup is editable it's value is just like that of edit text (the text) // to retrieve the value index use the GetPopupValueIndex method, this will do the right // thing for you. MuiItemListBox( TMuiItem pItem[], MoaLong index, MoaBool tiny = FALSE, MoaBool editable = FALSE ); MoaError AppendItems( PMoaChar stringArray[], MoaLong count = 1 ); MoaError DeleteItems(MoaLong intArray[], MoaLong count = 1); /* Get selected items */ MoaError GetSelection( MoaLong intArray[], MoaLong* count ); // Overrides //MoaBool GetEnabled( void ); //void SetEnabled( MoaBool ); }; typedef MuiItemListBox * PMuiItemListBox; #endif // __cplusplus #ifdef __cplusplus extern "C" { #endif // Dimensions, parameters -- Use this before or after creating item to set parameters. MoaError MuiSetParameters( PTMuiItem pItem, MoaLong x, MoaLong y, MoaLong width, MoaLong height, MoaBool enabled, ConstPMoaChar tooltip = NULL ); // Groups, delimiters -- No destroy method for these MoaError MuiNewWindowBegin( PTMuiItem pItem ); MoaError MuiNewWindowEnd( PTMuiItem pItem ); MoaError MuiNewTabBegin( PTMuiItem pItem ); MoaError MuiNewTabEnd( PTMuiItem pItem ); MoaError MuiNewGroupBegin( PTMuiItem pItem, MoaBool vertical ); MoaError MuiNewGroupEnd( PTMuiItem pItem, MoaBool vertical ); // Buttons -- default param is for Default/Cancel/Toggle item MoaError MuiNewButton( PTMuiItem pItem, ConstPMoaChar title, MoaBool tiny, TMuiHelpButtonStyle buttonType ); MoaError MuiDestroyButton( PTMuiItem pItem ); // Checkbox MoaError MuiNewCheckbox( PTMuiItem pItem, ConstPMoaChar title, MoaBool selected ); MoaError MuiDestroyCheckbox( PTMuiItem pItem ); // Radio MoaError MuiNewRadio( PTMuiItem pItem, ConstPMoaChar title, MoaBool selected ); MoaError MuiDestroyRadio( PTMuiItem pItem ); // Text MoaError MuiNewText( PTMuiItem pItem, ConstPMoaChar title, MoaBool editable, MoaBool tiny, TMuiSymbol align ); MoaError MuiDestroyText( PTMuiItem pItem ); // Dividers MoaError MuiNewDivider( PTMuiItem pItem, MoaBool vertical ); MoaError MuiDestroyDivider( PTMuiItem pItem ); // Bitmaps MoaError MuiNewBitmap( PTMuiItem pItem, MoaShort iconID, PMoaBitmap bitmap ); MoaError MuiDestroyBitmap( PTMuiItem pItem, PMoaBitmap bitmap ); // Sliders MoaError MuiNewIntegerSlider( PTMuiItem pItem, MoaLong min, MoaLong max, MoaLong initial, MoaBool showTicks, MoaBool showValue, MoaLong increment, MoaDouble accel ); MoaError MuiNewFloatSlider( PTMuiItem pItem, MoaDouble min, MoaDouble max, MoaDouble initial, MoaBool showTicks, MoaBool showValue, MoaDouble increment, MoaDouble accel ); MoaError MuiDestroySlider( PTMuiItem pItem ); // Popup menus MoaError MuiNewPopup( PTMuiItem pItem, MoaBool tiny ); MoaError MuiNewEditablePopup( PTMuiItem pItem, MoaBool tiny ); MoaError MuiPopupAddStrings( PTMuiItem pItem, PMoaChar stringArray[], MoaLong count ); MoaError MuiPopupAddIntegers( PTMuiItem pItem, MoaLong intArray[], MoaLong count ); MoaError MuiPopupAddDoubles( PTMuiItem pItem, MoaDouble doubleArray[], MoaLong count ); MoaError MuiPopupGetIndexInRange( PTMuiItem pItem, MoaLong* index ); MoaError MuiPopupSetEnableState( PTMuiItem pItem, MoaBool enabledState ); MoaBool MuiPopupGetEnableState( PTMuiItem pItem ); MoaError MuiDestroyPopup( PTMuiItem pItem ); //list box MoaError MuiNewListBox( PTMuiItem pItem ); MoaError MuiListBoxAddStrings( PTMuiItem pItem, PMoaChar stringArray[], MoaLong count ); MoaError MuiListDeleteItems( PTMuiItem pItem, MoaLong intArray[], MoaLong count ); MoaError MuiListBoxGetSelection( PTMuiItem pItem, MoaLong intArray[], MoaLong* count ); MoaError MuiDestroyListBox( PTMuiItem pItem ); // end all -- this one is basically a switch statement MoaError MuiDestroyItem( PTMuiItem ); #ifdef __cplusplus } #endif #endif // _H_MuiItem // EOF
[ "luca.bacci982@gmail.com" ]
luca.bacci982@gmail.com
68c4d2984ac548807d63be1618a235fabe938481
9438b81a403c48ec1aba89bdda4b0d75abff3c66
/GUI-FSX/C2DGraphics.cpp
f22c46c6b899a8d265aafac1e737b611a5e30806
[ "MIT" ]
permissive
VatConnect/FSX
22a28779430b612bed4b43a8fd3a022c6653685a
a3353b2879ae79f2ec510f2bb8c4fe92c6eb4a2f
refs/heads/master
2020-06-18T19:33:39.829268
2017-05-29T23:10:38
2017-05-29T23:10:38
66,741,608
1
1
null
null
null
null
UTF-8
C++
false
false
12,345
cpp
#include "stdafx.h" #include "C2DGraphics.h" //All methods return 1 if succeeded, 0 if failed C2DGraphics::C2DGraphics() : m_hMasterDC(nullptr), m_pOutputBitmap(nullptr), m_hFont(nullptr), m_hPen(nullptr), m_iPenThickness(0), m_pMasterDevice(nullptr) { m_LineColor = RGB(255,0,0); m_TextColor = RGB(255,255,255); } C2DGraphics::~C2DGraphics() { } //Initialize with (one of) the Direct3D devices. Must be called before any of the other methods. int C2DGraphics::Initialize(IDirect3DDevice9 *pDevice) { //Create a dummy surface to create a compatible master display context -- this is likely to be the same among all devices m_pMasterDevice = pDevice; IDirect3DSurface9* pSurface; if (FAILED(pDevice->CreateOffscreenPlainSurface(4, 4, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT,&pSurface, nullptr))) return 0; HDC hSurfDC; if (FAILED(pSurface->GetDC(&hSurfDC))) { pSurface->Release(); return 0; } m_hMasterDC = CreateCompatibleDC(hSurfDC); //Default bitmap is monochrome, so select in a color one HBITMAP MasterBitmap = CreateCompatibleBitmap (hSurfDC, 4, 4 ); SelectObject(m_hMasterDC, MasterBitmap); pSurface->ReleaseDC(hSurfDC); pSurface->Release(); return 1; } //Load a bitmap from disk. (To reload, first delete the old one then call this). The //Direct3D surface will be invalid until the first time the bitmap is drawn, when //the loaded bitmap gets copied into a newly created surface. This is so bitmaps can //be preloaded before Direct3D graphics are initialized. int C2DGraphics::LoadBitmapFromFile(const WCHAR *Filename, BitmapStruct *pBitmap) { if (!pBitmap || pBitmap->hDC != nullptr || !m_hMasterDC) return 0; //Load it HBITMAP hBitmap = (HBITMAP)LoadImage(nullptr, Filename,IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE); if (hBitmap == nullptr) return 0; //Get its size BITMAP BM; if (!GetObject(hBitmap, sizeof(BITMAP), &BM)) { DeleteObject(hBitmap); return 0; } pBitmap->WidthPix = BM.bmWidth; pBitmap->HeightPix = BM.bmHeight; //Create a device context for it and select the bitmap into it pBitmap->hDC = CreateCompatibleDC(m_hMasterDC); SelectObject(pBitmap->hDC, hBitmap); SetMapMode(pBitmap->hDC, MM_TEXT); return 1; } //Create a new bitmap of given size, given pointer to new bitmap to fill in int C2DGraphics::MakeNewBitmap(int Width, int Height, BitmapStruct *pBitmap) { if (pBitmap->hDC || !m_hMasterDC || pBitmap->pSurface) return 0; pBitmap->bHasTransparency = false; HBITMAP NewBitmap = CreateCompatibleBitmap (m_hMasterDC, Width, Height ); pBitmap->hDC = CreateCompatibleDC (m_hMasterDC); if (!NewBitmap || !pBitmap->hDC) { if (NewBitmap) DeleteObject(NewBitmap); if (pBitmap->hDC) DeleteObject(pBitmap->hDC); return 0; } SelectObject (pBitmap->hDC, NewBitmap ); SetMapMode(pBitmap->hDC, MM_TEXT); pBitmap->WidthPix = Width; pBitmap->HeightPix = Height; pBitmap->pDevice = nullptr; pBitmap->pSurface = nullptr; return 1; } //Set the bitmap's transparency to its top-left (0,0) color. Note this //only works for bitmaps drawn onto other bitmaps. The one drawn to the //Direct3D surface won't show transparencies or alpha. int C2DGraphics::EnableBitmapTransparency(BitmapStruct *pBitmap) { pBitmap->bHasTransparency = true; pBitmap->TransparentColor = GetPixel(pBitmap->hDC, 0, 0); return 1; } //Draw bitmap to the current output bitmap's hDC, optional Alpha blend 0.0-1.0 defaults to 1.0 (none) int C2DGraphics::DrawBitmapToOutputBitmap(BitmapStruct *pBitmap, long X, long Y, float Alpha) { if (!pBitmap->hDC || !m_pOutputBitmap || !m_pOutputBitmap->hDC) return 0; if (Alpha > 0.99f && !pBitmap->bHasTransparency) BitBlt(m_pOutputBitmap->hDC, X, Y, pBitmap->WidthPix, pBitmap->HeightPix, pBitmap->hDC, 0, 0, SRCCOPY); else DrawBitmapIntoRect(pBitmap, X, Y, pBitmap->WidthPix, pBitmap->HeightPix, Alpha); return 1; } //Given the bitmap with already-filled surface, and device to draw it on, do so. If surface created for different //device, reload the surface. Used to re-draw unchanged surface onto back buffer int C2DGraphics::DrawBitmapSurfaceOnDevice(BitmapStruct *pBitmap, IDirect3DDevice9 *pDevice, long ScreenX, long ScreenY) { //Remake surface if it was originally made for different device (or first time drawing) if (pBitmap->pDevice != pDevice) { if (pBitmap->pSurface) { pBitmap->pSurface->Release(); pBitmap->pSurface = nullptr; } pBitmap->pDevice = pDevice; } if (!pBitmap->pSurface) CopyBitmapDCToSurface(pBitmap); //Draw the surface to the backbuffer of the device IDirect3DSurface9 *pBackBuffer = nullptr; if (FAILED(pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer))) return 0; RECT r; r.left = ScreenX; r.top = ScreenY; r.right = ScreenX + pBitmap->WidthPix; r.bottom = ScreenY + pBitmap->HeightPix; pDevice->StretchRect(pBitmap->pSurface, nullptr, pBackBuffer, &r, D3DTEXF_NONE); pBackBuffer->Release(); return 1; } //Copy the bitmap in the hDC of the given bitmap onto its corresponding direct3D surface. This is typically done after //the hDC bitmap is updated. int C2DGraphics::CopyBitmapDCToSurface(BitmapStruct *pBitmap) { if (!pBitmap->pDevice) pBitmap->pDevice = m_pMasterDevice; //See if we need to create a new surface on that device if (!pBitmap->pSurface) { if (FAILED(pBitmap->pDevice->CreateOffscreenPlainSurface(pBitmap->WidthPix, pBitmap->HeightPix, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pBitmap->pSurface, nullptr))) { assert(0); return 0; } } //Copy the hDC bitmap to the surface HDC hDC; if (FAILED(pBitmap->pSurface->GetDC(&hDC))) return 0; BitBlt(hDC, 0, 0, pBitmap->WidthPix, pBitmap->HeightPix, pBitmap->hDC, 0, 0, SRCCOPY); pBitmap->pSurface->ReleaseDC(hDC); return 1; } int C2DGraphics::DeleteBM(BitmapStruct *pBitmap) { if (pBitmap->hDC) { HGDIOBJ hObj = GetCurrentObject(pBitmap->hDC, OBJ_BITMAP); if (hObj) DeleteObject(hObj); DeleteDC(pBitmap->hDC); pBitmap->hDC = nullptr; } if (pBitmap->pDevice) pBitmap->pDevice = nullptr; //we don't own this so didn't addref it if (pBitmap->pSurface) pBitmap->pSurface->Release(); pBitmap->pSurface = nullptr; return 1; } /////////////////////////////////// //Set the text font and size to the given font and characteristics. If okay, returns 1. //If it's not found, returns 2 and sets an existing font that "best matches" the characteristics. //If that fails too, returns 0 int C2DGraphics::FindBestFont(WCHAR *FontName, int PointSize, int bBold, int bItalic, int bUnderline, HFONT *phFont) { //Fill in font characteristics LOGFONT Info; Info.lfHeight = -(MulDiv(PointSize, GetDeviceCaps(m_hMasterDC, LOGPIXELSY), 72)); Info.lfWidth = 0; Info.lfEscapement = 0; Info.lfOrientation = 0; Info.lfWeight = bBold? 700 : 200; Info.lfItalic = (BYTE)bItalic; Info.lfUnderline = (BYTE)bUnderline; Info.lfStrikeOut = false; Info.lfCharSet = DEFAULT_CHARSET; Info.lfOutPrecision = OUT_DEFAULT_PRECIS; //OUT_TT_ONLY_PRECIS; Info.lfClipPrecision = CLIP_DEFAULT_PRECIS; Info.lfQuality = ANTIALIASED_QUALITY; Info.lfPitchAndFamily = (UCHAR)(DEFAULT_PITCH | FF_DONTCARE); wcscpy_s(Info.lfFaceName, 32, FontName); //Try requested font HFONT hFont = CreateFontIndirect(&Info); *phFont = hFont; if (hFont) return 1; //Not found, try any meeting the requirements (sans-seriff) Info.lfPitchAndFamily = (UCHAR)(DEFAULT_PITCH | FF_MODERN | FF_SWISS); Info.lfFaceName[0] = 0; hFont = CreateFontIndirect(&Info); *phFont = hFont; if (!hFont) return 0; return 2; } int C2DGraphics::Shutdown() { if (m_hFont) { DeleteObject(m_hFont); m_hFont = nullptr; } if (m_hMasterDC) { DeleteDC(m_hMasterDC); m_hMasterDC = nullptr; } if (m_hPen) { DeleteObject(m_hPen); m_hPen = nullptr; } return 1; } ////////////////////// //Methods to modify bitmap set with SetOutputBitmap() int C2DGraphics::SetOutputBitmap(BitmapStruct *pBitmap) { m_pOutputBitmap = pBitmap; return 1; } int C2DGraphics::SetTextColor(COLORREF Color) { m_TextColor = Color; return 1; } int C2DGraphics::SetFont(HFONT hFont) { m_hFont = hFont; return 1; } int C2DGraphics::GetFont(HFONT *pFont) { *pFont = m_hFont; return 1; } //Draw given text in font created by SetFont and SetTextColor, onto //current output bitmap int C2DGraphics::DrawTxt(int x, int y, WCHAR *Str) { HDC dc = m_pOutputBitmap->hDC; ::SetTextColor(dc, m_TextColor); SetBkMode(dc, TRANSPARENT); SelectObject(dc, m_hFont); TextOut(dc, x, y, Str, wcslen(Str)); return 1; } int C2DGraphics::FillBitmapWithColor(COLORREF Color) { if (!m_pOutputBitmap->hDC) return 0; HBRUSH Brush = CreateSolidBrush(Color); RECT rect; rect.top = 0; rect.left = 0; rect.bottom = m_pOutputBitmap->HeightPix; rect.right = m_pOutputBitmap->WidthPix; int res = FillRect(m_pOutputBitmap->hDC, &rect, Brush); DeleteObject(Brush); return res; } int C2DGraphics::GetStringPixelSize(WCHAR *Str, int *Width, int *Height) { int len = wcslen(Str); SIZE sz; HFONT hOldFont = (HFONT)SelectObject(m_hMasterDC, m_hFont); if (GetTextExtentPoint32(m_hMasterDC, Str, len, &sz)) { *Width = sz.cx; *Height = sz.cy; } else { *Width = 0; *Height = 0; } SelectObject(m_hMasterDC, hOldFont); return 1; } //Draw given source bitmap into current output bitmap, stretching/compressing as needed to fit into //the given location. Alpha blending between 0.0 (fully transparent) and 1.0 (fully opaque), though //it only applies to bitmaps drawn into other bitmaps. int C2DGraphics::DrawBitmapIntoRect(BitmapStruct *pBitmap, int x, int y,int Width, int Height, float Alpha) { if (m_pOutputBitmap->hDC == 0) return 0; //Get source information BITMAP BitmapInfo; HGDIOBJ hSourceBitmap = GetCurrentObject(pBitmap->hDC, OBJ_BITMAP); if (!hSourceBitmap) return 0; GetObject(hSourceBitmap,sizeof(BITMAP),(LPSTR)&BitmapInfo); HDC hdcSourceDC = pBitmap->hDC; int SrcWidth = BitmapInfo.bmWidth; int SrcHeight = BitmapInfo.bmHeight; SetStretchBltMode(m_pOutputBitmap->hDC, COLORONCOLOR); BOOL bRes; if (Alpha < 0.999f) { BitmapStruct TempBitmap; TempBitmap.hDC = nullptr; if (pBitmap->bHasTransparency) { //Make copy of surface beneath MakeNewBitmap(Width, Height, &TempBitmap); if (TempBitmap.hDC != 0) { bRes = BitBlt(TempBitmap.hDC, 0, 0, Width, Height, pBitmap->hDC, x, y, SRCCOPY); SetStretchBltMode(TempBitmap.hDC, COLORONCOLOR); //Transparent blit to the copy and set the result as the new source -- surface alpha blended with itself will be unchanged. if (TransparentBlt(TempBitmap.hDC, 0, 0, Width, Height, pBitmap->hDC, 0, 0, BitmapInfo.bmWidth, BitmapInfo.bmHeight, pBitmap->TransparentColor)) { hdcSourceDC = TempBitmap.hDC; SrcWidth = Width; SrcHeight = Height; } } } BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.SourceConstantAlpha = (BYTE)(Alpha * 256.0f); bf.AlphaFormat = 0; bRes = AlphaBlend(m_pOutputBitmap->hDC, x, y, Width, Height, hdcSourceDC, 0, 0, SrcWidth, SrcHeight, bf); if (TempBitmap.hDC) DeleteBitmap(&TempBitmap); } else if (pBitmap->bHasTransparency) { bRes = TransparentBlt(m_pOutputBitmap->hDC, x, y, Width, Height, hdcSourceDC, 0, 0, SrcWidth, SrcHeight, pBitmap->TransparentColor); } else { bRes = StretchBlt(m_pOutputBitmap->hDC, x, y, Width, Height, hdcSourceDC, 0, 0, SrcWidth, SrcHeight, SRCCOPY); } if (bRes) return 1; return 0; } int C2DGraphics::SetLineColor(COLORREF LineColor) { if (m_hPen && LineColor != m_LineColor) { DeleteObject(m_hPen); m_hPen = nullptr; } m_LineColor = LineColor; return S_OK; } //Draw line to output bitmap in given thickness, and color as set by SetLineColor. int C2DGraphics::DrawLine(int fx, int fy, int tx, int ty, int Thickness) { //Use cached pen if it's same thickness if (m_hPen && m_iPenThickness != Thickness) { DeleteObject(m_hPen); m_hPen = nullptr; } if (!m_hPen) { m_hPen = CreatePen(PS_SOLID, Thickness, m_LineColor); m_iPenThickness = Thickness; } SelectObject(m_pOutputBitmap->hDC, m_hPen); MoveToEx(m_pOutputBitmap->hDC, fx, fy, nullptr); ::LineTo(m_pOutputBitmap->hDC, tx, ty); return 1; } //Continue line from last DrawLine() using same pen int C2DGraphics::LineTo(int tx, int ty) { ::LineTo(m_pOutputBitmap->hDC, tx, ty); return 1; }
[ "cfcoon@xavius.com" ]
cfcoon@xavius.com
580df55ecdefb2bd6157bba46e418f7a2ad30fe4
f89b1cf00a14d3315be610a1e2ba1a1fd32bb144
/326.cpp
b2b5c4a5d9679c4b5c5b94337c3c437c3c664f07
[]
no_license
IMCG/LeetCode-1
2cf7a7b88a232cbd8cb12ab3b4a6ab818eecfb56
52d327705ad5ad5dd72aa913c041b31ea6f4daaf
refs/heads/master
2020-07-26T07:00:57.770329
2018-12-29T09:04:22
2018-12-29T09:04:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
134
cpp
class Solution { public: bool isPowerOfThree(int n) { return n > 0 && static_cast<int>(pow(3, 19)) % n == 0; } };
[ "kobe.792244049@qq.com" ]
kobe.792244049@qq.com
bfe2e0e608db86b0dea042ce28fb12e0a4822098
7abc9ef2008aa41631f44842995fd6c01fc5ad7c
/sysvar.cpp
784222775f65b97c9c2fb2264c1ee01897526d70
[]
no_license
iit-avionics/manager-arduino
5553505f899796e2080abb693e7c5d40280cd926
8830312ae12677fe77f8a8f28e6e95bb1ddb4b30
refs/heads/master
2021-01-22T01:28:26.893307
2014-06-21T06:18:44
2014-06-21T06:18:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,948
cpp
/*----------------------------------------------------------------------------------*- * 'sysvar.cpp' * SYSVAR library implementation for APPLINK PROTOCOL * Part of the iit-avionics project * All rights reserve. MSU-IIT Iligan City -*----------------------------------------------------------------------------------*/ #include "sysvar.h" SysVar::SysVar(void){ byte i,none[] = {0x00,0x00,0x00,0x00}; app_vars_g[SYS_STATE_G] = AppVar(SYS_STATE_G,READ | WRITE | MGVAR | T_BYTE,S_BYTE); app_vars_g[TIME_G] = AppVar(TIME_G,READ | WRITE | MGVAR | T_BYTE,S_U_LONG); app_vars_g[ERROR_G] = AppVar(ERROR_G,READ | WRITE | MGVAR | T_BYTE,S_BYTE); app_vars_g[MEM_G] = AppVar(MEM_G,READ | MGVAR | T_U_INT,S_U_INT); app_vars_g[RET_ERR_G] = AppVar(RET_ERR_G,READ | MGVAR | T_BYTE,S_BYTE); //initialize values to 0x00 for(i=0;i<MAX_SV_ELEMENTS;i++) app_vars_g[i].SetData(none); } void SysVar::SetError(const byte err){ byte e[] = {err}; app_vars_g[ERROR_G].SetData(e); } void SysVar::SetRetError(const byte err){ byte e[] = {err}; app_vars_g[RET_ERR_G].SetData(e); } AppVar SysVar::Get(const byte index){ return app_vars_g[index]; } AppVar *SysVar::GetBulk(const byte *indices,const byte sz){ byte i; AppVar *var_array = new AppVar[sz]; for(i = 0;i < sz; i++){ var_array[i] = app_vars_g[indices[i]]; } return var_array; } /* byte SysVar::Set(const AppVar v){ byte i = 0; while(i != MAX_SV_ELEMENTS){ if (app_vars_g[i].unique_id == v.unique_id ) break; i++; } if(i == MAX_SV_ELEMENTS){ SetError(ERR_SYS_APPVAR_NOT_DEFINE); }else{ app_vars_g[i].SetData(v.data); } return i; } */ byte SysVar::Set(const byte id,byte* data){ byte i = 0; while(i != MAX_SV_ELEMENTS){ if (app_vars_g[i].unique_id == id ) break; i++; } if(i == MAX_SV_ELEMENTS){ SetError(ERR_SYS_APPVAR_NOT_DEFINE); }else{ app_vars_g[i].SetData(data); } return i; }
[ "kimachesita@gmail.com" ]
kimachesita@gmail.com
fa60e4d8987f2729cf90e1080704fa0443802a24
f3fa968e546b7cd69ea132546290a9639e6d3b40
/5lab/Ray.h
6a19b76a737bb78c3595a3a24c3dafa1ceba2fda
[]
no_license
bkingery/cs455
d6062b89358d4856ea1d26e53ea63c8392d4d278
b2cc7c82b84908a12afa577dab3debbd1249b9a4
refs/heads/master
2016-09-01T21:51:52.580115
2013-04-10T02:01:22
2013-04-10T02:01:22
7,566,822
0
0
null
null
null
null
UTF-8
C++
false
false
502
h
#ifndef __RAY_H #define __RAY_H #include <cml/cml.h> class Ray { private: cml::vector4f start; cml::vector4f direction; public: Ray(){return;}; Ray(cml::vector4f s, cml::vector4f d) : start(s), direction(d) {return;} ~Ray(){return;}; cml::vector4f getStart(){return start;}; cml::vector4f getDirection(){return direction;}; void setStart(cml::vector4f s){this->start = s;}; void setDirection(cml::vector4f d){this->direction = d;}; }; #endif
[ "brian.kingery@gmail.com" ]
brian.kingery@gmail.com
e8ef0cc58afcc7cfe1ebbe99e1362c66db98e92e
127229d88bc6ff4952d0a1a9364dfb63a56ba818
/src/hashing/sha3.cpp
d64d37dc7542ab5f5f8009acd522a06cfb1d6ae8
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
abbyssoul/libsolace
406ddee373d490425a90603fbab5e0105cc2e5e1
390c3094af1837715787c33297720bf514f04710
refs/heads/master
2021-05-22T03:44:18.983398
2021-01-29T02:07:19
2021-01-29T02:07:19
49,950,840
22
5
Apache-2.0
2020-03-17T23:47:32
2016-01-19T12:19:55
C++
UTF-8
C++
false
false
1,581
cpp
/* * Copyright 2016 Ivan Ryabov * * 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. */ /******************************************************************************* * libSolace * @file solace/hashing/sha3.cpp * @brief Implementation of SHA-3 hashing algorithm ******************************************************************************/ #include "solace/hashing/sha3.hpp" using namespace Solace; using namespace Solace::hashing; static const StringLiteral SHA_3_NAME = "SHA3"; Sha3::Sha3() noexcept : _state { {0, 0}, {0}, {0} } { } StringView Sha3::getAlgorithm() const { return SHA_3_NAME; } Sha3::size_type Sha3::getDigestLength() const { return 256; } HashingAlgorithm& Sha3::update(MemoryView SOLACE_UNUSED(input)) { // TODO(abbyssoul): Not implemented yet. return (*this); } MessageDigest Sha3::digest() { byte result[32]; ByteWriter writer{wrapMemory(result)}; for (auto s : _state.state) { writer.writeBE(s); } return MessageDigest(writer.viewWritten()); }
[ "abbyssoul@gmail.com" ]
abbyssoul@gmail.com
8413e9fafd8c8ca6c1fbe9010e068b85def55b46
e83aaf423d3624748522b9adecdeb15659f5bdee
/ditfw-gfx/deps/wxwidgets/include/wx/univ/control.h
e2eceb4b3fa88d65f446b6c1571747f4f0c30331
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
chartly/portfolio
4b432c212968b56d6a1514efe3dae87ae9a0c0e0
bd1782c274604f29f0edaa1407efce2a80d2c58f
refs/heads/master
2021-01-19T18:33:16.143552
2016-11-29T03:03:25
2016-11-29T03:03:25
30,293,065
3
1
null
null
null
null
UTF-8
C++
false
false
3,581
h
///////////////////////////////////////////////////////////////////////////// // Name: wx/univ/control.h // Purpose: universal wxControl: adds handling of mnemonics // Author: Vadim Zeitlin // Modified by: // Created: 14.08.00 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_UNIV_CONTROL_H_ #define _WX_UNIV_CONTROL_H_ class WXDLLIMPEXP_FWD_CORE wxControlRenderer; class WXDLLIMPEXP_FWD_CORE wxInputHandler; class WXDLLIMPEXP_FWD_CORE wxRenderer; // we must include it as most/all control classes derive their handlers from // it #include "wx/univ/inphand.h" #include "wx/univ/inpcons.h" // ---------------------------------------------------------------------------- // wxControlAction: the action is currently just a string which identifies it, // later it might become an atom (i.e. an opaque handler to string). // ---------------------------------------------------------------------------- typedef wxString wxControlAction; // the list of actions which apply to all controls (other actions are defined // in the controls headers) #define wxACTION_NONE wxT("") // no action to perform // ---------------------------------------------------------------------------- // wxControl: the base class for all GUI controls // ---------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxControl : public wxControlBase, public wxInputConsumer { public: wxControl() { Init(); } wxControl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxControlNameStr) { Init(); Create(parent, id, pos, size, style, validator, name); } bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxControlNameStr); // this function will filter out '&' characters and will put the // accelerator char (the one immediately after '&') into m_chAccel virtual void SetLabel(const wxString& label) wxOVERRIDE; // return the current label virtual wxString GetLabel() const wxOVERRIDE { return m_label; } // wxUniversal-specific methods // return the index of the accel char in the label or -1 if none int GetAccelIndex() const { return m_indexAccel; } // return the accel char itself or 0 if none wxChar GetAccelChar() const { return m_indexAccel == -1 ? wxT('\0') : (wxChar)m_label[m_indexAccel]; } virtual wxWindow *GetInputWindow() const wxOVERRIDE { return (wxWindow*)this; } protected: // common part of all ctors void Init(); // set m_label and m_indexAccel and refresh the control to show the new // label (but, unlike SetLabel(), don't call the base class SetLabel() thus // avoiding to change wxControlBase::m_labelOrig) void UnivDoSetLabel(const wxString& label); private: // label and accel info wxString m_label; int m_indexAccel; DECLARE_DYNAMIC_CLASS(wxControl) DECLARE_EVENT_TABLE() WX_DECLARE_INPUT_CONSUMER() }; #endif // _WX_UNIV_CONTROL_H_
[ "the.corbin.hart@gmail.com" ]
the.corbin.hart@gmail.com
6b6ec5175d0c865ef45e560d7593defab4d7d2a4
a160ac566e5f7c38fc9313a20b58030e4c6400e1
/C语言/C语言--行走的小人.cpp
a2d7a4c71427cbabcea8b4bc8cefe2a5a536112d
[]
no_license
sh2268411762/-C-
918be5c517c5e3437fe7228154cde8b06c4a162b
d489bbf3883d28c459472fa505c8b940e765b356
refs/heads/master
2021-05-17T15:26:45.717821
2020-11-06T15:49:15
2020-11-06T15:49:15
250,844,544
1
1
null
null
null
null
UTF-8
C++
false
false
450
cpp
/* #include <stdio.h> #include <stdlib.h> #include <windows.h> int main() { int a, b; a = 0; system("color 0a"); while (a <= 20) { system("cls"); b = 1; while (b <= a) { printf(" "); b++; } printf(" O\n"); b = 1; while (b <= a) { printf(" "); b++; } printf("< H >\n"); b = 1; while (b <= a) { printf(" "); b++; } printf("I I\n"); Sleep(1000); a++; } system("pause"); return 0; } */
[ "2268411762@qq.com" ]
2268411762@qq.com
532fdb3fc0fb0ed0cd7b2763b5a69fa8aa641f1e
9fa292d97ceb374068d355bd41097d0407d68bd3
/3rdParty/include/gpstk/SimpleFilter.hpp
c589f89beecb78a4074c9e496ac5eb53b565fabd
[ "MIT", "Zlib", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown-license-reference" ]
permissive
mfkiwl/rspf_v2.0
4d90153b92cc416663c798e05f87e348ad8792ef
f22d2707b775a4776fc8359a255f39c26ecc96a3
refs/heads/master
2021-05-27T04:36:34.132569
2013-07-16T04:04:12
2013-07-16T04:04:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,419
hpp
#pragma ident "$Id: SimpleFilter.hpp 1308 2008-07-22 20:01:04Z architest $" /** * @file SimpleFilter.hpp * This class filters out satellites with observations grossly out of bounds. */ #ifndef SIMPLEFILTER_HPP #define SIMPLEFILTER_HPP //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 2.1 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008 // //============================================================================ #include "ProcessingClass.hpp" namespace gpstk { /** @addtogroup DataStructures */ //@{ /** This class filters out satellites with observations grossly out of * bounds. * * This class is meant to be used with the GNSS data structures objects * found in "DataStructures" class. * * A typical way to use this class follows: * * @code * RinexObsStream rin("ebre0300.02o"); * * gnssRinex gRin; * SimpleFilter myFilter; * * while(rin >> gRin) * { * gRin >> myFilter; * } * @endcode * * The "SimpleFilter" object will visit every satellite in the GNSS data * structure that is "gRin" and will check that the given code * observations are within some (preassigned) boundaries. * * By default, the algorithm will check C1 observables, the minimum limit * is 15000000.0 meters and the maximum limit is 30000000.0 meters. You * may change all these settings with the appropriate set methods. * * Also, you may set more than one observable to be checked by passing a * "TypeIDSet" object to the appropriate constructors or methods. For * instance: * * @code * TypeIDSet typeSet; * typeSet.insert(TypeID::P1); * typeSet.insert(TypeID::P2); * * myFilter.setFilteredType(typeSet); * @endcode * * Be warned that if a given satellite does not have the observations * required, or if their are out of bounds, the full satellite record * will be summarily deleted from the data structure. * */ class SimpleFilter : public ProcessingClass { public: /// Default constructor. By default, filter C1. SimpleFilter() : minLimit(15000000.0), maxLimit(30000000.0) { setFilteredType(TypeID::C1); setIndex(); }; /** Explicit constructor * * @param type TypeID to be filtered. * @param min Minimum limit (in meters). * @param max Maximum limit (in meters). */ SimpleFilter( const TypeID& type, const double& min, const double& max ) : minLimit(min), maxLimit(max) { setFilteredType(type); setIndex(); }; /** Explicit constructor * * @param type TypeID to be filtered. */ SimpleFilter(const TypeID& type) : minLimit(15000000.0), maxLimit(30000000.0) { setFilteredType(type); setIndex(); }; /** Explicit constructor * * @param typeSet Set of TypeID's to be filtered. * @param min Minimum limit (in meters). * @param max Maximum limit (in meters). */ SimpleFilter( const TypeIDSet& typeSet, const double& min, const double& max ) : filterTypeSet(typeSet), minLimit(min), maxLimit(max) { setIndex(); }; /** Explicit constructor * * @param typeSet Set of TypeID's to be filtered. */ SimpleFilter(const TypeIDSet& typeSet) : filterTypeSet(typeSet), minLimit(15000000.0), maxLimit(30000000.0) { setIndex(); }; /** Returns a satTypeValueMap object, filtering the target * observables. * * @param gData Data object holding the data. */ virtual satTypeValueMap& Process(satTypeValueMap& gData) throw(ProcessingException); /** Method to set the minimum limit. * @param min Minimum limit (in meters). */ virtual SimpleFilter& setMinLimit(const double& min) { minLimit = min; return (*this); }; /// Method to get the minimum limit. virtual double getMinLimit() const { return minLimit; }; /** Method to set the maximum limit. * @param max Maximum limit (in meters). */ virtual SimpleFilter& setMaxLimit(const double& max) { maxLimit = max; return (*this); }; /// Method to get the maximum limit. virtual double getMaxLimit() const { return maxLimit; }; /** Method to add a TypeID to be filtered. * @param type Extra TypeID to be filtered. */ virtual SimpleFilter& addFilteredType(const TypeID& type) { filterTypeSet.insert(type); return (*this); }; /** Method to set a TypeID to be filtered. This method will erase * previous types. * @param type TypeID to be filtered. */ virtual SimpleFilter& setFilteredType(const TypeID& type) { filterTypeSet.clear(); filterTypeSet.insert(type); return (*this); }; /** Method to set the TypeID's to be filtered. This method will erase * previous types. * @param typeSet Set of TypeID's to be filtered. */ virtual SimpleFilter& setFilteredType(const TypeIDSet& typeSet) { filterTypeSet.clear(); filterTypeSet = typeSet; return (*this); }; /// Method to get the set of TypeID's to be filtered. virtual TypeIDSet getFilteredType() const { return filterTypeSet; }; /** Returns a gnnsSatTypeValue object, filtering the target * observables. * * @param gData Data object holding the data. */ virtual gnssSatTypeValue& Process(gnssSatTypeValue& gData) throw(ProcessingException) { Process(gData.body); return gData; }; /** Returns a gnnsRinex object, filtering the target observables. * * @param gData Data object holding the data. */ virtual gnssRinex& Process(gnssRinex& gData) throw(ProcessingException) { Process(gData.body); return gData; }; /// Returns an index identifying this object. virtual int getIndex(void) const; /// Returns a string identifying this object. virtual std::string getClassName(void) const; /// Destructor virtual ~SimpleFilter() {}; protected: /** Checks that the value is within the given limits. * @param value The value to be test * * @return * True if check was OK. */ virtual bool checkValue(const double& value) const { return ( (value>=minLimit) && (value<=maxLimit) ); }; /// Set of types to be filtered TypeIDSet filterTypeSet; /// Minimum value allowed for input data (in meters). double minLimit; /// Maximum value allowed for input data (in meters). double maxLimit; private: /// Initial index assigned to this class. static int classIndex; /// Index belonging to this object. int index; /// Sets the index and increment classIndex. void setIndex(void) { index = classIndex++; }; }; // End of class 'SimpleFilter' //@} } #endif // SIMPLEFILTER_HPP
[ "loongfee@gmail.com" ]
loongfee@gmail.com
0d5d918f320981e9fad34ae16bfb677ca585c864
628c711e801b0ecd2aa026417c212ddc3f29bbe8
/project_main/main.cpp
35b6ee7202d8daeeaaf2cedda7d80bbf7ac33fb7
[]
no_license
KennyTech/csci_3090u_final_project
46d368e1d2b138fb9a509496fbff5fa82d03f5ed
621c9ec10a5cf158aac53f3309771585801ea798
refs/heads/master
2020-05-16T15:30:53.974022
2019-03-30T04:26:47
2019-03-30T04:26:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
27,644
cpp
/* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * PROGRAM: CSCI 3090U Final Graphics Project * PURPOSE: AoL (America Online) Logo Render * AUTHORS: Alvin Lum, Kenny Le * LAST MODIFIED: March 29, 2019 * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * ABOUT * ----------------------------------------------------------------------------------------------------------------------------------------------------- * - This project renders AoL (America Online) Model and Logo (OBJ format) generated through 3DPaint and Blender and applies multiple effects to them * * - This project uses GLFW graphics library framework (instead of GLUT) for more control over main loop and other functionalities to allow * easier expansion in the future. * * - The logos are rotated, scaled, and translated * * - The AoL man moves in a bezier spline * * - Adapts some code from CSCI 3090U Labs and Lectures * * - Adapts some methods and uses several small external libraries from http://www.opengl-tutorial.org/beginners-tutorials/ * - AntTweakBar // External library to create a transparent debug window on top to display variable values * - shader.hpp // Shader * - texture.hpp // Texturer * - controls.hpp // User controls camera: mouse to control camera lookAt, arrow keys to control camera position * - objloader.hpp // OBJ Loader, works with Blender exported models (CSCI 3090U provided objloader did not correctly load Blender exported OBJs) * - vboindexer.hpp // Vertex Buffer Object Indexer (indexes for OBJ) * - quaternion_utils.hpp // Quaternion functions (ie. LookAt, RotateTowards, RotationBetweenVectors) * * - DISCLAIMER: This project is for educational purposes only. No copyright infringement intended. * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * HOW TO RUN * ----------------------------------------------------------------------------------------------------------------------------------------------------- * - Run the program application (.exe) or compile using the NMake files. Alternatively, use CMake or open the solution in Visual Studio and run (Debug) * * - Watch the program interact with objects using multiple effects, then press ESC to exit the program. * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ // Standard #define _USE_MATH_DEFINES // For Pi (radian <-> degree conversions) #include <stdio.h> // Standard #include <stdlib.h> // Standard #include <vector> // Vectors #include <string> // String input/output #include <iostream> // Input/output stream #include <fstream> // File stream #include <cmath> // Math functions #include <wtypes.h> // Get screen resolution to create fullscreen application // Glew #include <GL/glew.h> // GLFW #include <GLFW/glfw3.h> // GLM #define GLM_ENABLE_EXPERIMENTAL #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/quaternion.hpp> #include <glm/gtx/quaternion.hpp> #include <glm/gtx/euler_angles.hpp> #include <glm/gtx/norm.hpp> using namespace glm; // External Libraries #include <AntTweakBar.h> // Tweak parameters on the go UI window #include <common/shader.hpp> // Shader #include <common/texture.hpp> // Texturer #include <common/controls.hpp> // User controls camera: mouse to control camera lookAt, arrow keys to control camera position #include <common/objloader.hpp> // OBJ Loader, works with Blender exported models #include <common/vboindexer.hpp> // Vertex Buffer Object Indexer (indexes for OBJ) #include <common/quaternion_utils.hpp> // Quaternion functions (ie. LookAt, RotateTowards, RotationBetweenVectors) using namespace std; // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * CONFIGURATIONS - Users may edit these configurations for testing * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ bool FULL_SCREEN = false; // Screen Resolution - true for fullscreen, if false then defaults to SCREEN_WIDTH, SCREEN_HEIGHT int SCREEN_WIDTH = 1024; int SCREEN_HEIGHT = 768; bool DEBUG = true; // Print debug diagnostic messages in the console for testing double magnitude = 1.0f; // Magnitude of how fast the Logos rotate, scale, and translate float LIGHT_X = 2.5f; // Light position (X, Y, Z) float LIGHT_Y = 2.5f; float LIGHT_Z = 4.0f; GLclampf BG_RED = 0.00f; // Background Colour - Red, Green, Blue (0.00 to 1.00) GLclampf BG_GREEN = 0.25f; GLclampf BG_BLUE = 0.50f; // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * GLOBAL VARIABLES * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ GLFWwindow* window; GLuint programId; // OBJ vertex buffer objects and textures for Object 1: AoL Logo GLuint positions_vbo1; GLuint textureCoords_vbo1; GLuint normals_vbo1; GLuint indexBuffer1; GLuint texture1; GLuint textureId1; vector<unsigned short> indices1; // OBJ vertex buffer objects and textures for Object 2: AoL Man GLuint positions_vbo2; GLuint textureCoords_vbo2; GLuint normals_vbo2; GLuint indexBuffer2; GLuint texture2; GLuint textureId2; vector<unsigned short> indices2; // Render IDs and handles GLuint MatrixID; GLuint ViewMatrixID; GLuint ModelMatrixID; GLuint vertexPosition_modelspaceID; GLuint vertexUVID; GLuint vertexNormal_modelspaceID; // Perspective projection glm::mat4 projectionMatrix; // Orient everything around our preferred view glm::mat4 viewMatrix; // Light GLuint LightID; glm::vec3 lightPos; // Time (for loop, update) double lastTime; double lastFrameTime; double currentTime; double deltaTime; double elapsedFrames; // Rotation, scaling, translation variables to modify in realtime float rotationAngleDegree = 0.0f; float rotationX = 0.0f; float scalingValue = 0.0f; float translationValue = 0.0f; // Rotation for man model float rotationZ = 0.0f; // Normal mapping GLuint normalTexture; GLuint normalTextureId; // Bezier curve control points (for AoL man travel curve) glm::vec3 controlPoint1(-2.00f, -1.50f, 2.00f); glm::vec3 controlPoint2(2.50f, 2.50f, -0.50f); glm::vec3 controlPoint3(-1.00f, 1.00f, -2.50f); glm::vec3 controlPoint4(2.00f, -2.50f, -0.50f); float manX = 0.0f; float manY = 0.0f; float manZ = 0.0f; // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * FUNCTIONS - Mini functions that the main method uses (other larger functions are in separate .cpp/h and included as a library) * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ // Get the user's screen resolution to allow fullscreen option void getScreenResolution(int& width, int& height) { RECT screen; HWND handle = GetDesktopWindow(); // Get handle of destop window GetWindowRect(handle, &screen); // Get screen width = screen.right; // Adjust width height = screen.bottom; // Adjust height } // Move the AoL Man in a bezier curve path over input of time (t = 0 to 1) void moveBezierPath(float t) { manX = pow(1 - t, 3) * controlPoint1.x + pow(1 - t, 2) * 3 * t * controlPoint2.x + (1 - t) * pow(3 * t, 2) * controlPoint3.x + pow(t, 3) * controlPoint4.x; manY = pow(1 - t, 3) * controlPoint1.y + pow(1 - t, 2) * 3 * t * controlPoint2.y + (1 - t) * pow(3 * t, 2) * controlPoint3.y + pow(t, 3) * controlPoint4.y; manZ = pow(1 - t, 3) * controlPoint1.z + pow(1 - t, 2) * 3 * t * controlPoint2.z + (1 - t) * pow(3 * t, 2) * controlPoint3.z + pow(t, 3) * controlPoint4.z; } // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * CREATE LOGO GEOMETRY - initialize loaded in OBJ geometry * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ static void createLogoGeometry(void) { // Load the UV texture (DDS file is a compressed image file) texture1 = loadDDS("aol_logo_textured_1.DDS"); textureId1 = glGetUniformLocation(programId, "Logo"); normalTexture = loadBMP_custom("Logo_Norm_Map.bmp"); normalTextureId = glGetUniformLocation(programId, "LogoNormal"); // Read aol_logo.obj (vertex positions, uv texture positions, and normals) into vector of vertices to load into buffer for display vector<glm::vec3> positions1; vector<glm::vec2> textures1; vector<glm::vec3> normals1; bool load = loadOBJ("aol_logo_textured_1.obj", positions1, textures1, normals1); vector<glm::vec3> indexed_positions1; vector<glm::vec2> indexed_textures1; vector<glm::vec3> indexed_normals1; indexVBO(positions1, textures1, normals1, indices1, indexed_positions1, indexed_textures1, indexed_normals1); // Load into vertex buffer objects to display glGenBuffers(1, &positions_vbo1); glBindBuffer(GL_ARRAY_BUFFER, positions_vbo1); glBufferData(GL_ARRAY_BUFFER, indexed_positions1.size() * sizeof(glm::vec3), &indexed_positions1[0], GL_STATIC_DRAW); glGenBuffers(1, &textureCoords_vbo1); glBindBuffer(GL_ARRAY_BUFFER, textureCoords_vbo1); glBufferData(GL_ARRAY_BUFFER, indexed_textures1.size() * sizeof(glm::vec2), &indexed_textures1[0], GL_STATIC_DRAW); glGenBuffers(1, &normals_vbo1); glBindBuffer(GL_ARRAY_BUFFER, normals_vbo1); glBufferData(GL_ARRAY_BUFFER, indexed_normals1.size() * sizeof(glm::vec3), &indexed_normals1[0], GL_STATIC_DRAW); // Generate buffer for indices glGenBuffers(1, &indexBuffer1); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer1); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices1.size() * sizeof(unsigned short), &indices1[0] , GL_STATIC_DRAW); } // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * CREATE MAN GEOMETRY - initialize loaded in OBJ geometry * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ static void createManGeometry(void) { // Load the UV texture (DDS file is a compressed image file) texture2 = loadDDS("aol_man_textured_1.DDS"); textureId2 = glGetUniformLocation(programId, "Man"); // Read aol_logo.obj (vertex positions, uv texture positions, and normals) into vector of vertices to load into buffer for display vector<glm::vec3> positions2; vector<glm::vec2> textures2; vector<glm::vec3> normals2; bool load = loadOBJ("aol_man_textured_1.obj", positions2, textures2, normals2); vector<glm::vec3> indexed_positions2; vector<glm::vec2> indexed_textures2; vector<glm::vec3> indexed_normals2; indexVBO(positions2, textures2, normals2, indices2, indexed_positions2, indexed_textures2, indexed_normals2); // Load into vertex buffer objects to display glGenBuffers(1, &positions_vbo2); glBindBuffer(GL_ARRAY_BUFFER, positions_vbo2); glBufferData(GL_ARRAY_BUFFER, indexed_positions2.size() * sizeof(glm::vec3), &indexed_positions2[0], GL_STATIC_DRAW); glGenBuffers(1, &textureCoords_vbo2); glBindBuffer(GL_ARRAY_BUFFER, textureCoords_vbo2); glBufferData(GL_ARRAY_BUFFER, indexed_textures2.size() * sizeof(glm::vec2), &indexed_textures2[0], GL_STATIC_DRAW); glGenBuffers(1, &normals_vbo2); glBindBuffer(GL_ARRAY_BUFFER, normals_vbo2); glBufferData(GL_ARRAY_BUFFER, indexed_normals2.size() * sizeof(glm::vec3), &indexed_normals2[0], GL_STATIC_DRAW); // Generate buffer for indices glGenBuffers(1, &indexBuffer2); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer2); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices2.size() * sizeof(unsigned short), &indices2[0], GL_STATIC_DRAW); } // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * DRAW LOGO - Draw a copy of the logo (create geometry first), bool to make Logo rotate, scale, or translate over time * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ void drawLogo(glm::vec3 position, bool rotating, bool scaling, bool translating) { float velocity = (float)(magnitude * 0.005f * elapsedFrames); // Load texture into buffer glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture1); glUniform1i(textureId1, 0); // Load normal map into buffer glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, normalTexture); glUniform1i(normalTextureId, 0); // Load vertex positions glBindBuffer(GL_ARRAY_BUFFER, positions_vbo1); glEnableVertexAttribArray(0); glVertexAttribPointer(vertexPosition_modelspaceID, 3, GL_FLOAT, GL_FALSE, 0, nullptr); // Load UV texture coordinates glBindBuffer(GL_ARRAY_BUFFER, textureCoords_vbo1); glEnableVertexAttribArray(1); glVertexAttribPointer(vertexUVID, 2, GL_FLOAT, GL_FALSE, 0, nullptr); // Load normals glBindBuffer(GL_ARRAY_BUFFER, normals_vbo1); glEnableVertexAttribArray(2); glVertexAttribPointer(vertexNormal_modelspaceID, 3, GL_FLOAT, GL_FALSE, 0, nullptr); // Index the buffer and draw the triangles loaded from the OBJ model glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer1); // Rotate based on time glm::mat4 RotationMatrix; if (rotating) { rotationX += (float)((M_PI / 2.0f) * deltaTime * (magnitude)); if (rotationX >= 360 * (M_PI / 180)) { rotationX = 0; } rotationAngleDegree = (float)(rotationX * (180 / M_PI)); RotationMatrix = eulerAngleYXZ(rotationX, 0.0f, 0.0f); } else { RotationMatrix = eulerAngleYXZ(0.0f, 0.0f, 0.0f); } // Scale based on abs Sin (0 to 1) glm::mat4 ScalingMatrix; if (scaling) { scalingValue = (float)(abs(sin(velocity)*1.0f)); ScalingMatrix = scale(mat4(), vec3(scalingValue, scalingValue, scalingValue)); } else { ScalingMatrix = scale(mat4(), vec3(1.0f, 1.0f, 1.0f)); } // Translate based on Sin (-1 to 1) glm::mat4 TranslationMatrix; if (translating) { translationValue = (float)(sin(velocity)*1.0f); TranslationMatrix = translate(mat4(), vec3(position.x + translationValue, position.y, position.z)); } else { TranslationMatrix = translate(mat4(), position); } glm::mat4 ModelMatrix = TranslationMatrix * RotationMatrix * ScalingMatrix; glm::mat4 MVP = projectionMatrix * viewMatrix * ModelMatrix; // Send transformation information to current bound shader glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]); glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]); glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &viewMatrix[0][0]); // Draw Logo glDrawElements(GL_TRIANGLES, indices1.size(), GL_UNSIGNED_SHORT, nullptr); } // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * DRAW MAN - Draw a copy of the man (create geometry first), bool to make Man rotate, scale, or translate over time * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ void drawMan(glm::vec3 position, bool rotating, bool scaling, bool translating) { float velocity = (float)(magnitude * 0.005f * elapsedFrames); // Load into buffer glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture2); glUniform1i(textureId2, 0); glBindBuffer(GL_ARRAY_BUFFER, positions_vbo2); glEnableVertexAttribArray(0); glVertexAttribPointer(vertexPosition_modelspaceID, 3, GL_FLOAT, GL_FALSE, 0, nullptr); glBindBuffer(GL_ARRAY_BUFFER, textureCoords_vbo2); glEnableVertexAttribArray(1); glVertexAttribPointer(vertexUVID, 2, GL_FLOAT, GL_FALSE, 0, nullptr); glBindBuffer(GL_ARRAY_BUFFER, normals_vbo2); glEnableVertexAttribArray(2); glVertexAttribPointer(vertexNormal_modelspaceID, 3, GL_FLOAT, GL_FALSE, 0, nullptr); // Index the buffer and draw the triangles loaded from the OBJ model glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer2); // Rotate based on time glm::mat4 RotationMatrix; if (rotating) { rotationZ += (float)((M_PI / 2.0f) * deltaTime * (magnitude*2)); if (rotationZ >= 360 * (M_PI / 180)) { rotationZ = 0; } rotationAngleDegree = (float)(rotationZ * (180 / M_PI)); RotationMatrix = eulerAngleYXZ(0.0f, 0.0f, -rotationZ); } else { RotationMatrix = eulerAngleYXZ(0.0f, 0.0f, 0.0f); } // Scale based on abs Sin (0 to 1) glm::mat4 ScalingMatrix; if (scaling) { float scalingValue = (float)(abs(sin(velocity)*1.0f)); ScalingMatrix = scale(mat4(), vec3(scalingValue, scalingValue, scalingValue)); } else { ScalingMatrix = scale(mat4(), vec3(1.0f, 1.0f, 1.0f)); } // Translate in sin/cos curve glm::mat4 TranslationMatrix; if (translating) { //float manX = (float)(cos(velocity)*0.5f); // AoL man in sin/cos movement //float manY = (float)(sin(velocity)*0.5f); moveBezierPath(abs(sin(velocity*0.25))); // call function to set manX, manY, manZ to part of bezier curve specified in time (sin 0 to 1) TranslationMatrix = translate(mat4(), vec3(manX, manY, manZ)); } else { TranslationMatrix = translate(mat4(), position); } glm::mat4 ModelMatrix = TranslationMatrix * RotationMatrix * ScalingMatrix; glm::mat4 MVP = projectionMatrix * viewMatrix * ModelMatrix; // Send transformation information to current bound shader glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]); glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]); glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &viewMatrix[0][0]); // Draw Man glDrawElements(GL_TRIANGLES, indices2.size(), GL_UNSIGNED_SHORT, nullptr); } // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * INIT WINDOWS - initialize and set up windows and the cursor * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ static int initWindows(int screenWidth, int screenHeight) { // Initialize GLFW and its configurations if (!glfwInit()) { fprintf(stderr, "[WARNING] Failed to initialize GLFW!\n"); getchar(); return -1; // Return error } glfwWindowHint(GLFW_SAMPLES, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); if (FULL_SCREEN) getScreenResolution(screenWidth, screenHeight); // Open window based on screen resolution window = glfwCreateWindow(screenWidth, screenHeight, "CSCI 3090U Graphics Project - America Online Logo", NULL, NULL); if (window == NULL) { fprintf(stderr, "[WARNING] Failed to open GLFW window. This project uses OpenGL 3.3 and some Graphics Cards might not be compatible (ie. older Intel CPUs).\n"); getchar(); glfwTerminate(); return -1; // Return error } glfwMakeContextCurrent(window); // Initialize GLEW glewExperimental = true; if (glewInit() != GLEW_OK) { fprintf(stderr, "[WARNING] Failed to initialize GLEW.\n"); getchar(); glfwTerminate(); return -1; // Return error } // Initialize Tw Bar in Top Left for debug statistics TwInit(TW_OPENGL_CORE, NULL); TwWindowSize(screenWidth, screenHeight); // Ensure we can capture the escape key being pressed below glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); // Hide the mouse and enable unlimited mouvement glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwPollEvents(); // TwBar from external library to display debug variables, refreshes every 0.1 seconds TwBar * EulerGUI = TwNewBar("AoL Logo Variables"); TwSetParam(EulerGUI, NULL, "refresh", TW_PARAM_CSTRING, 1, "0.1"); TwAddVarRW(EulerGUI, "Rotation (deg)", TW_TYPE_FLOAT, &rotationAngleDegree, "step=1.0"); TwAddVarRW(EulerGUI, "Scaling factor", TW_TYPE_FLOAT, &scalingValue, "step=0.01"); TwAddVarRW(EulerGUI, "Translation", TW_TYPE_FLOAT, &translationValue, "step=0.01"); return 0; } // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * RENDER - render setup and constants (ie. background colour) * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ static void render(void) { // Create specified background colour glClearColor(BG_RED, BG_GREEN, BG_BLUE, 1.0); // Use our shader glUseProgram(programId); // Turn on depth buffering glEnable(GL_DEPTH_TEST); // Discards all fragments except for closest to camera glDepthFunc(GL_LESS); // Cull triangles with normals not facing camera view glEnable(GL_CULL_FACE); // Position of our light glUseProgram(programId); LightID = glGetUniformLocation(programId, "LightPosition_worldspace"); lightPos = glm::vec3(LIGHT_X, LIGHT_Y, LIGHT_Z); glUniform3f(LightID, lightPos.x, lightPos.y, lightPos.z); // Handle for model-view-projection MVP (adapted from method in link specified at the top of program) MatrixID = glGetUniformLocation(programId, "MVP"); ViewMatrixID = glGetUniformLocation(programId, "V"); ModelMatrixID = glGetUniformLocation(programId, "M"); // Handle for buffers (adapted from method in link specified at the top of program) vertexPosition_modelspaceID = glGetAttribLocation(programId, "vertexPosition_modelspace"); vertexUVID = glGetAttribLocation(programId, "vertexUV"); vertexNormal_modelspaceID = glGetAttribLocation(programId, "vertexNormal_modelspace"); } // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * UPDATE FUNCTION - Repeatedly run to transform, scale, rotate objects, etc. * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ static void update(void) { // Update time/deltaTime values currentTime = glfwGetTime(); deltaTime = (float)(currentTime - lastFrameTime); lastFrameTime = currentTime; elapsedFrames++; // For scaling/translation/rotation over time // Clear screen so we can swap the buffer and draw new screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Compute matrix from mouse/keyboard input for camera control computeMatricesFromInputs(); //glm::mat4 projectionMatrix = getProjectionMatrix(); //glm::mat4 ViewMatrix = getViewMatrix(); projectionMatrix = glm::perspective(0.75f, 1.25f, 0.1f, 100.0f); viewMatrix = glm::lookAt( glm::vec3(0, 0, 10), // Camera glm::vec3(0, 0, 0), // Look At glm::vec3(0, 1, 0) // Head up ); glm::mat4 modelMatrix = glm::mat4(1.0); glm::mat4 MVP = projectionMatrix * viewMatrix * modelMatrix; // Draw Logos drawLogo(vec3(-1.0f, 1.0f, 0.0f), false, false, false); // Draw a [static] logo in top left drawLogo(vec3(2.0f, 1.0f, 0.0f), true, false, false); // Draw a [rotating] logo in top right drawLogo(vec3(-1.0f, -2.0f, 0.0f), false, true, false); // Draw a [scaling] logo in bottom left drawLogo(vec3(2.0f, -2.0f, 0.0f), false, false, true); // Draw a [translating] logo in bottom right drawMan(vec3(-3.0f, -2.0f, 0.2f), true, false, true); // Draw a [rotating] and [translating] man in bottom right // Draw the Tw Bar window (debug variable display) TwDraw(); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); // Buffer swap glfwSwapBuffers(window); glfwPollEvents(); } // ---------------------------------------------------------------------------------------------------------------------------------------------------- /* * ----------------------------------------------------------------------------------------------------------------------------------------------------- * MAIN FUNCTION * ----------------------------------------------------------------------------------------------------------------------------------------------------- */ int main(void) { // Initialize GLFW Windows initWindows(SCREEN_WIDTH, SCREEN_HEIGHT); // Initialize Vertex and Fragment Shaders programId = LoadShaders("shaders/vertex.glsl", "shaders/fragment.glsl"); // To-do: Normal map shaders for our normal maps // Initialize Rendering render(); // Initialize Logo Geometry createLogoGeometry(); createManGeometry(); // Time computation (adapted from method in link specified at the top of program) lastTime = glfwGetTime(); lastFrameTime = lastTime; // The program will enter this loop and will continue to run and translate/rotate/scale objects over time until ESC key is pressed do{ update(); } while (glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS && glfwWindowShouldClose(window) == 0); // Loop escaped, ending program, clean vertex buffer object, shader, avoid memory leaks glDeleteBuffers(1, &positions_vbo1); glDeleteBuffers(1, &textureCoords_vbo1); glDeleteBuffers(1, &normals_vbo1); glDeleteBuffers(1, &indexBuffer1); glDeleteProgram(programId); glDeleteTextures(1, &texture1); // Close both windows TwTerminate(); glfwTerminate(); return 0; }
[ "ken.le@hotmail.com" ]
ken.le@hotmail.com
ab600b06440272d1070c6c18d1235af10d897df3
825dbfde537faf753581a2ab86d8f536c1125737
/src/gfx/GfxSystem.cpp
4a4311d4cc2f348bb3d34642bd3e6dd2cc9441f6
[ "Zlib" ]
permissive
oceancx/mud
e59a739f69fbb48fc9c7e53f4412ee2c9aabc913
a7ca88d062bf2679e2977b03dc63d6e315912e14
refs/heads/master
2020-03-30T05:42:00.403384
2018-09-23T23:06:31
2018-09-23T23:06:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,532
cpp
// Copyright (c) 2018 Hugo Amiard hugo.amiard@laposte.net // This software is provided 'as-is' under the zlib License, see the LICENSE.txt file. // This notice and the license may not be removed or altered from any source distribution. #include <gfx/Cpp20.h> #ifndef MUD_CPP_20 #include <map> #include <string> #include <fstream> #endif #include <bx/timer.h> #include <bx/file.h> #include <bgfx/bgfx.h> #include <bgfx/platform.h> #ifdef MUD_MODULES module mud.gfx; #else #include <pool/ObjectPool.h> #include <infra/StringConvert.h> #include <math/Image256.h> #include <math/Stream.h> #include <ui/Render/Renderer.h> #include <gfx/Types.h> #include <gfx/GfxSystem.h> #include <gfx/Material.h> #include <gfx/Program.h> #include <gfx/Draw.h> #include <gfx/Viewport.h> #include <gfx/RenderTarget.h> #include <gfx/Scene.h> #include <gfx/Texture.h> #include <gfx/Model.h> #include <gfx/Prefab.h> #include <gfx/Particles.h> #include <gfx/Asset.h> #include <gfx/Asset.impl.h> #include <gfx/Assets.h> #include <gfx/Pipeline.h> #include <gfx/Filter.h> #include <gfx/Skeleton.h> #endif #define MUD_GFX_THREADED namespace mud { GfxContext::GfxContext(GfxSystem& gfx_system, cstring name, int width, int height, bool fullScreen, bool init) : BgfxContext(gfx_system, name, width, height, fullScreen, false) , m_gfx_system(gfx_system) , m_target() { if(init) gfx_system.init(*this); m_target = make_object<RenderTarget>(uvec2(width, height)); } GfxContext::~GfxContext() {} void GfxContext::reset(uint16_t width, uint16_t height) { bgfx::reset(width, height, BGFX_RESET_NONE); m_target = make_object<RenderTarget>(uvec2(width, height)); m_vg_handle = m_reset_vg(); } struct GfxSystem::Impl { std::vector<string> m_resource_paths; std::vector<GfxContext*> m_contexts; std::vector<Scene*> m_scenes; bx::FileReader m_file_reader; bx::FileWriter m_file_writer; unique_ptr<TPool<Mesh>> m_meshes; unique_ptr<TPool<Rig>> m_rigs; unique_ptr<TPool<Animation>> m_animations; unique_ptr<AssetStore<Texture>> m_textures; unique_ptr<AssetStore<Program>> m_programs; unique_ptr<AssetStore<Material>> m_materials; unique_ptr<AssetStore<Model>> m_models; unique_ptr<AssetStore<ParticleGenerator>> m_particles; unique_ptr<AssetStore<Prefab>> m_prefabs; std::vector<Renderer*> m_renderers; Texture* m_white_texture = nullptr; Texture* m_black_texture = nullptr; Texture* m_normal_texture = nullptr; SymbolIndex m_symbols; #ifdef MUD_GFX_THREADED std::vector<bgfx::Encoder*> m_encoders; #endif }; GfxSystem::GfxSystem(array<cstring> resource_paths) : BgfxSystem(resource_paths[0]) , m_impl(make_unique<Impl>()) , m_pipeline(make_unique<Pipeline>(*this)) { Program::ms_gfx_system = this; Material::ms_gfx_system = this; Model::ms_gfx_system = this; for(cstring path : resource_paths) { printf("INFO: resource path: %s\n", path); m_impl->m_resource_paths.push_back(path); } } GfxSystem::~GfxSystem() {} bx::FileReaderI& GfxSystem::file_reader() { return m_impl->m_file_reader; } bx::FileWriterI& GfxSystem::file_writer() { return m_impl->m_file_writer; } TPool<Mesh>& GfxSystem::meshes() { return *m_impl->m_meshes; } TPool<Rig>& GfxSystem::rigs() { return *m_impl->m_rigs; } TPool<Animation>& GfxSystem::animations() { return *m_impl->m_animations; } AssetStore<Texture>& GfxSystem::textures() { return *m_impl->m_textures; } AssetStore<Program>& GfxSystem::programs() { return *m_impl->m_programs; } AssetStore<Material>& GfxSystem::materials() { return *m_impl->m_materials; } AssetStore<Model>& GfxSystem::models() { return *m_impl->m_models; } AssetStore<ParticleGenerator>& GfxSystem::particles() { return *m_impl->m_particles; } AssetStore<Prefab>& GfxSystem::prefabs() { return *m_impl->m_prefabs; } object_ptr<Context> GfxSystem::create_context(cstring name, int width, int height, bool fullScreen) { object_ptr<GfxContext> context = make_object<GfxContext>(*this, name, width, height, fullScreen, !m_initialized); m_impl->m_contexts.push_back(context.get()); return std::move(context); } void GfxSystem::init(GfxContext& context) { BgfxSystem::init(context); m_impl->m_meshes = make_unique<TPool<Mesh>>(); m_impl->m_rigs = make_unique<TPool<Rig>>(); m_impl->m_animations = make_unique<TPool<Animation>>(); m_impl->m_textures = make_unique<AssetStore<Texture>>(*this, "textures/", load_texture); m_impl->m_programs = make_unique<AssetStore<Program>>(*this, "programs/", ".prg"); m_impl->m_materials = make_unique<AssetStore<Material>>(*this, "materials/", ".mtl"); m_impl->m_models = make_unique<AssetStore<Model>>(*this, "models/"); m_impl->m_particles = make_unique<AssetStore<ParticleGenerator>>(*this, "particles/", ".ptc"); m_impl->m_prefabs = make_unique<AssetStore<Prefab>>(*this, "prefabs/", ".pfb"); m_impl->m_white_texture = this->textures().file("white.png"); m_impl->m_black_texture = this->textures().file("black.png"); m_impl->m_normal_texture = this->textures().file("normal.png"); m_pipeline = make_unique<Pipeline>(*this); } void GfxSystem::init_pipeline() { for(auto& block : m_pipeline->m_gfx_blocks) block->init_gfx_block(); static ClearRenderer clear_renderer = { *this, *m_pipeline }; static UnshadedRenderer unshaded_renderer = { *this, *m_pipeline }; static MinimalRenderer minimal_renderer = { *this, *m_pipeline }; UNUSED(minimal_renderer); this->set_renderer(Shading::Unshaded, unshaded_renderer); this->set_renderer(Shading::Clear, clear_renderer); this->create_debug_materials(); } void GfxSystem::add_resource_path(cstring path) { m_impl->m_resource_paths.push_back(m_resource_path + path); } void GfxSystem::set_renderer(Shading shading, Renderer& renderer) { m_impl->m_renderers.resize(max(size_t(shading) + 1, m_impl->m_renderers.size())); m_impl->m_renderers[size_t(shading)] = &renderer; } Renderer& GfxSystem::renderer(Shading shading) { return *m_impl->m_renderers[size_t(shading)]; } GfxContext& GfxSystem::context(size_t index) { return *m_impl->m_contexts[index]; } bool GfxSystem::next_frame() { RenderFrame frame = { m_frame, m_time, m_delta_time, Render::s_render_pass_id }; for(auto& name_program : m_impl->m_programs->m_assets) name_program.second->update(); for(auto& renderer : m_impl->m_renderers) if(renderer) renderer->frame(frame); #ifdef MUD_GFX_THREADED m_num_encoders = min(uint32_t(4U), bgfx::getCaps()->limits.maxEncoders); m_encoders[0] = bgfx::begin(); for(size_t i = 1; i < m_num_encoders; ++i) m_encoders[i] = bgfx::begin(true); #endif for(GfxContext* context : m_impl->m_contexts) for(Viewport* viewport : context->m_viewports) if(viewport->m_active) { Renderer& renderer = this->renderer(viewport->m_shading); this->render(renderer, *context, *viewport, frame); } #ifdef MUD_GFX_THREADED for(size_t i = 1; i < m_num_encoders; ++i) bgfx::end(m_encoders[i]); #endif bool pursue = true; for(GfxContext* context : m_impl->m_contexts) pursue &= context->next_frame(); BgfxSystem::next_frame(); return pursue; } void GfxSystem::render(Renderer& renderer, GfxContext& context, Viewport& viewport, RenderFrame& frame) { Render render(viewport, *context.m_target, frame); render.m_scene.gather_render(render); render.m_viewport.render(render); if(rect_w(viewport.m_rect) != 0 && rect_h(viewport.m_rect) != 0) renderer.render(render); //copy.debug_show_texture(*render.m_target, render.m_environment->m_radiance.m_texture->m_texture, false, false, false, 0); //copy.debug_show_texture(*render.m_target, render.m_environment->m_radiance.m_roughness_array, false, false, false, 1); //copy.debug_show_texture(*render.m_target, bgfx::getTexture(render.m_target->m_effects.last())); } LocatedFile GfxSystem::locate_file(cstring file, array<cstring> extensions) { for(const string& path : m_impl->m_resource_paths) for(size_t i = 0; i < extensions.size(); ++i) if(std::ifstream(path + file + extensions[i]).good()) { return { path.c_str(), file, extensions[i], i }; } return {}; } LocatedFile GfxSystem::locate_file(cstring file) { carray<cstring, 1> exts = { "" }; return this->locate_file(file, exts); } Texture& GfxSystem::default_texture(TextureHint hint) { if(hint == TextureHint::Black) return *m_impl->m_black_texture; else if(hint == TextureHint::White) return *m_impl->m_white_texture; else //if(hint == TextureHint::Normal) return *m_impl->m_normal_texture; } void GfxSystem::create_debug_materials() { Material& debug = this->fetch_material("debug", "unshaded"); debug.m_unshaded_block.m_enabled = true; Material& alpha = this->fetch_material("debug_alpha", "unshaded"); alpha.m_unshaded_block.m_enabled = true; alpha.m_unshaded_block.m_colour = Colour{ 0.2f, 0.2f, 0.2f, 0.1f }; Material& pbr = this->fetch_material("debug_pbr", "pbr/pbr"); pbr.m_pbr_block.m_enabled = true; } Material& GfxSystem::debug_material() { return *this->materials().get("debug_pbr"); } Material& GfxSystem::fetch_material(cstring name, cstring shader, bool builtin) { Program* program = this->programs().file(shader); Material& material = this->materials().fetch(name); material.m_builtin = builtin; material.m_program = program; return material; } Material& GfxSystem::fetch_image256_material(const Image256& image) { string name = "Image256_" + to_string((uintptr_t)&image); Material* material = this->materials().get(name.c_str()); if(!material) { string image_name = "Image256_" + to_string((uintptr_t)&image); auto initializer = [&](Texture& texture) { auto data = image.read(); load_texture_rgba(texture, image.m_width, image.m_height, data); }; Texture& texture = this->textures().fetch(image_name.c_str()); initializer(texture); material = &this->fetch_material(name.c_str(), "unshaded"); material->m_unshaded_block.m_enabled = true; material->m_unshaded_block.m_colour.m_texture = &texture; } return *material; } Model& GfxSystem::fetch_symbol(const Symbol& symbol, const Shape& shape, DrawMode draw_mode) { return m_impl->m_symbols.symbol_model(symbol, shape, draw_mode); } Material& GfxSystem::fetch_symbol_material(const Symbol& symbol, DrawMode draw_mode) { if(symbol.m_image256) return this->fetch_image256_material(*symbol.m_image256); else return m_impl->m_symbols.symbol_material(*this, symbol, draw_mode); } }
[ "hugo.amiard@laposte.net" ]
hugo.amiard@laposte.net
327aaa38ac90af2121c0f90c99b22375506c0cd8
a909df0ba2abf695df4a7d15350312d4c6463c48
/UVa/274.cpp
982b64d562f9e2076dddbd1e61b9338b63c78b7c
[]
no_license
SayaUrobuchi/uvachan
1dadd767a96bb02c7e9449c48e463847480e98ec
c213f5f3dcfc72376913a21f9abe72988a8127a1
refs/heads/master
2023-07-23T03:59:50.638063
2023-07-16T04:31:23
2023-07-16T04:31:23
94,064,326
0
0
null
null
null
null
UTF-8
C++
false
false
1,351
cpp
#include <stdio.h> #include <string.h> int map[101][101]; int mmap[101][101]; int cmap[101][101]; char buf[1005]; int main() { int count, n, m, c, i, j, k; scanf("%d", &count); while(count--) { scanf("%d%d%d", &n, &c, &m); memset(cmap, 0, sizeof(cmap)); cmap[c][c] = 1; while(scanf("%d%d", &i, &j) == 2) { if(i == -1 && j == -1) { break; } cmap[i][j] = 1; } for(k=1; k<=n; k++) { for(i=1; i<=n; i++) { if(cmap[i][k]) { for(j=1; j<=n; j++) { cmap[i][j] |= (cmap[i][k] && cmap[k][j]); } } } } memset(map, 0, sizeof(map)); memset(mmap, 0, sizeof(mmap)); mmap[m][m] = 1; gets(buf); while(gets(buf)) { if(!buf[0]) { break; } sscanf(buf, "%d%d", &i, &j); mmap[i][j] = 1; map[i][j] = 1; } for(k=1; k<=n; k++) { for(i=1; i<=n; i++) { if(mmap[i][k]) { for(j=1; j<=n; j++) { mmap[i][j] |= (mmap[i][k] && mmap[k][j]); map[i][j] |= (map[i][k] && map[k][j] && !cmap[c][i] && !cmap[c][j] && !cmap[c][k]); } } } } for(i=1; i<=n; i++) { if(cmap[c][i] && mmap[m][i]) { break; } } if(i > n) { printf("N "); } else { printf("Y "); } if(map[m][m]) { printf("Y\n"); } else { printf("N\n"); } if(count) { printf("\n"); } } return 0; }
[ "sa072688@gmail.com" ]
sa072688@gmail.com
11793ff8eb8732ce09538e6b9c5089fa12ff192c
6278226a46fe1160b820a23a561e295e8f1404bb
/QTLinuxProj/Handanlty/工程/L12_P2_Gui/class/common/mytableview.h
14d71eecf4ca093f4466c8d350cb6fc3b36b3b25
[]
no_license
qdleepo/ProjectAfcApp
60485b376c347866795f199a117cb5097c6c2c6a
9b5a5d710893cbdec8973fabd3353e011d2ea576
refs/heads/master
2021-05-23T19:10:45.914003
2018-09-23T01:43:37
2018-09-23T01:43:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,885
h
#ifndef MYTABLEVIEW_H #define MYTABLEVIEW_H class QTableView; class QEvent; class QMouseEvent; class QRubberBand; class QTimer; class QResizeEvent; class QTableWidget; class QScrollArea; #include <QPoint> #include <QRect> #include <QWidget> #include <QTime> #include <QScrollBar> #include <QTableView> #include <QMap> #include <QWheelEvent> enum { TABLEVIEW_SELECT_MOVE_TYPE, //移动时触发更新框选区域 TABLEVIEW_SELECT_UP_TYPE //释放时触发更新框选区域 }; class MyTableView; class ScrollController; #if 0 class MyScrollBar: public QScrollBar { Q_OBJECT public: MyScrollBar(Qt::Orientation _orientation,QWidget *parent = 0); ~MyScrollBar(); void enterEvent(QEvent *e); void leaveEvent(QEvent *e); void mousePressEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); MyTableView *m_MyTableView; }; #endif class MyTableView : public QTableView { Q_OBJECT public: MyTableView(QWidget *parent = 0,bool _useMyScroll = false); ~MyTableView(); /*用于框选*/ void mousePressEvent ( QMouseEvent *event ); void mouseMoveEvent ( QMouseEvent * event ); void mouseReleaseEvent ( QMouseEvent *event ); void wheelEvent(QWheelEvent *event); void updateRubberBandForMouseMoveOrWheel(const QPoint &_curPoint); #if 0 void resizeEvent (QResizeEvent *e); #endif void setOriginPoint(const QPoint &paramPoint); void setCurPoint(const QPoint &paramPoint); QPoint originPoint() const; QPoint curPoint() const; void setIsPressed(bool flag); bool isPressed() const; void setSelectedRect(const QRect &rect); QRect selectedRect() const; void updateRubberBandStatus(); void setSelectType(int paramType); QPoint originScrollPoint() const; QPoint curScrollPoint() const; void setOriginScrollPoint(const QPoint &paramPoint); void setCurScrollPoint(const QPoint &paramPoint); QPoint calculateScrollPoint() const; QPoint offsetPointForHeader() const; //void getScreenRowInfo(int &paramFirst, int &paramLength); void screenRowList(int &paramFrom, int &paramLength); //返回当前屏幕行列表 /*用于自适应高度*/ int originTableWidth() const; int originTableHeight() const; int originRowHeight() const; void setOriginTableWidth(int paramOriginTableWidth); void setOriginTableHeight(int paramOriginTableHeight); void setOriginRowHeight(int paramOriginRowHeight); void adjustHeight(); int currHovered() const; void setCurrHovered(int paramCurrHovered); bool isEnableInlineLeaveEventAndSetMouseOver() const; void setIsEnableInlineLeaveEventAndSetMouseOver(bool paramFlag); void setMouseOver(bool _mouseOver,const QModelIndex &index); void clearMouseOverStatus(); void leaveEvent(QEvent *event); void setIsRubberBandShow(bool); bool isRubberBandShow() const; void setVerticalScrollBarVisible(bool); void setHorizontalScrollBarVisible(bool); void setVerticalScrollBarStyleSheet(const QString &paramStyleSheet, int _marginBorder, int _scrollBarWidth, int _scrollHandleWidth); void setHorizontalScrollBarStyleSheet(const QString &paramStyleSheet, int _marginBorder, int _scrollBarWidth, int _scrollHandleWidth); void setVerticalScrollBarValue(int); void setTableViewShowGrid(bool _flag); protected: bool eventFilter(QObject *, QEvent *); public slots: void snapshotRect(); #if 0 void verticalScrollValueChanged(int); void verticalScrollRangeChanged(int,int); void MyVerticalScrollValueChanged(int); #endif signals: void signalMouseOverRow(bool _mouseOver,const QModelIndex &index); void signalDisplayRubberBand(const QRect &); void signalHideRubberBand(); void signalCheckRows(int, int); //void signalsCleanButtonStatus(); void signalKeyPressDelete(); void signalRightClickEmptyArea(const QPoint &); void signalClickEmptyArea(const QPoint &); void signalShowToolTip(int, int, const QPoint &); private: /*用于框选*/ QPoint m_originPoint; QPoint m_curPoint; bool m_isPressed; bool m_isMoved; QRect m_selectedRect; //实际框选矩形 QRect m_selecteDisplaydRect;//实际显示的矩形 QRubberBand *m_rubberBand; QList<int> m_rowList; int m_selectType; bool m_enableUpdate; QPoint m_originScrollPoint; QPoint m_curScrollPoint; int m_maxShake; int m_minTriggerTimeValue; QTime m_triggerTime; int m_horizontalAccumulateShake; int m_verticalAccumulateShake; /*用于自适应高度*/ int m_originTableWidth; int m_originTableHeight; int m_originRowHeight; int m_currHovered; bool m_isEnableInlineLeaveEventAndSetMouseOver; QScrollBar *m_verticalQScrollBar; bool m_isRubberBandShow; ScrollController *m_ScrollController; }; #endif // MYTABLEVIEW_H
[ "695017153.qq.com" ]
695017153.qq.com
e7e37bebafdb8fbc03720e33324a76c80c62297f
6e1d46473b0d98f59a87ee52d4012ba8bc15fc22
/T4C Server/Rain.h
382055bdcfa00d652906ecbd3907e06cbe452db1
[]
no_license
BlackFury/Server-1
3ad544831a294225c9ca7a475a2347a4c6808372
ea0a8b57737f3fcc6406a0fd58fd79a644019d32
refs/heads/master
2022-03-15T21:51:08.729897
2017-05-19T17:43:47
2017-05-19T17:43:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
527
h
#if !defined(AFX_RAIN_H__157E11BF_F932_4E24_807D_63F1A1FF6E03__INCLUDED_) #define AFX_RAIN_H__157E11BF_F932_4E24_807D_63F1A1FF6E03__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "Unit.h" class Rain { public: Rain(); virtual ~Rain(); static Rain *GetInstance(); bool GetState(void); void SetState(short bNewState); void SwitchState(void); void SendRainState( Unit* self ); private: bool bRain; }; #endif // !defined(AFX_RAIN_H__157E11BF_F932_4E24_807D_63F1A1FF6E03__INCLUDED_)
[ "melodiass@com-db.fr" ]
melodiass@com-db.fr
9bc1e23498528f6b4ff86f6cfe1b9bd30129cb22
e7fde5f90908e63c0bf542fd2f15aafc7071e702
/src/Player.cc
58804b054bb542ec0ac39cd510d3b5fcf613234b
[]
no_license
sethhammell/straights
404776e1fbfea4a0e5900aa43842ccec9c9370a2
e6ab87dd96eb2e6c3f795f7783ff3a00dbf0bf87
refs/heads/main
2023-07-20T00:31:44.790675
2021-01-19T10:36:27
2021-01-19T10:36:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,199
cc
#include "Player.h" Player::Player(const Hand &hand, const bool &isHuman, const int &playerNum, const int &score) : hand{hand}, discards{{}}, legalPlays{{}}, score{score}, playerNum{playerNum}, isHuman{isHuman} {} void Player::play(const Card &card, Hand &Clubs, Hand &Diamonds, Hand &Hearts, Hand &Spades){ hand.removeCard(card); if (card.getSuit() == 'C') { if (card.getValue() == 7) Clubs.addCard(card); else if (card.getValue() == Clubs.getBack().getValue() + 1) Clubs.addCard(card); else Clubs.addCardFront(card); } else if (card.getSuit() == 'D') { if (card.getValue() == 7) Diamonds.addCard(card); else if (card.getValue() == Diamonds.getBack().getValue() + 1) Diamonds.addCard(card); else Diamonds.addCardFront(card); } else if (card.getSuit() == 'H') { if (card.getValue() == 7) Hearts.addCard(card); else if (card.getValue() == Hearts.getBack().getValue() + 1) Hearts.addCard(card); else Hearts.addCardFront(card); } else if (card.getSuit() == 'S') { //std::cout << "hi " << card.getValue() << std::endl; if (card.getValue() == 7) Spades.addCard(card); else if (card.getValue() == Spades.getBack().getValue() + 1) Spades.addCard(card); else Spades.addCardFront(card); } } void Player::discard(const Card &card){ hand.removeCard(card); discards.addCard(card); } void Player::calculateLegalPlays(const Hand &Clubs, const Hand &Diamonds, const Hand &Hearts, const Hand &Spades){ legalPlays.emptyHand(); if (Clubs.getSize() == 0 && Diamonds.getSize() == 0 && Hearts.getSize() == 0 && Spades.getSize() == 0) { legalPlays.addCard(Card{'S',7}); } else { if (Clubs.getSize() != 0) { if (hand.isCard(Card{'C',Clubs.getCard(0).getValue() - 1})) legalPlays.addCard(Card{'C',Clubs.getCard(0).getValue() - 1}); if (hand.isCard(Card{'C',Clubs.getBack().getValue() + 1})) legalPlays.addCard(Card{'C',Clubs.getBack().getValue() + 1}); } else if (hand.isCard(Card{'C',7})) legalPlays.addCard(Card{'C',7}); if (Diamonds.getSize() != 0) { if (hand.isCard(Card{'D',Diamonds.getCard(0).getValue() - 1})) legalPlays.addCard(Card{'D',Diamonds.getCard(0).getValue() - 1}); if (hand.isCard(Card{'D',Diamonds.getBack().getValue() + 1})) legalPlays.addCard(Card{'D',Diamonds.getBack().getValue() + 1}); } else if (hand.isCard(Card{'D',7})) legalPlays.addCard(Card{'D',7}); if (Hearts.getSize() != 0) { if (hand.isCard(Card{'H',Hearts.getCard(0).getValue() - 1})) legalPlays.addCard(Card{'H',Hearts.getCard(0).getValue() - 1}); if (hand.isCard(Card{'H',Hearts.getBack().getValue() + 1})) legalPlays.addCard(Card{'H',Hearts.getBack().getValue() + 1}); } else if (hand.isCard(Card{'H',7})) legalPlays.addCard(Card{'H',7}); if (Spades.getSize() != 0) { if (hand.isCard(Card{'S',Spades.getCard(0).getValue() - 1})) legalPlays.addCard(Card{'S',Spades.getCard(0).getValue() - 1}); if (hand.isCard(Card{'S',Spades.getBack().getValue() + 1})) legalPlays.addCard(Card{'S',Spades.getBack().getValue() + 1}); } } } Card Player::computerMove(){ if (legalPlays.getSize() > 0){ //hand.removeCard(legalPlays.getCard(0)); return legalPlays.getCard(0); } else{ //discard(hand.getCard(0)); return hand.getCard(0); } } const bool &Player::getIsHuman() const{ return isHuman; } const int &Player::getScore() const{ return score; } const Hand &Player::getHand() const{ return hand; } const Hand &Player::getDiscards() const{ return discards; } const Hand &Player::getLegalPlays() const{ return legalPlays; } void Player::ragequit(){ isHuman = false; }
[ "noreply@github.com" ]
noreply@github.com
19c9ac0bf1dd6c8103b1069be1581514206eea6d
ceac763a08f25e22f29926e479aae820261ce998
/src/uint256.h
27c7bc12131a5142578e1469a549929b5d055539
[ "MIT" ]
permissive
EroticaCoin/EroticaCore
107f660a733eac9e0b3ef5c2dd2b94e974312a10
e72db2a1be699ed59b9eeaa467f83856ff2f9a03
refs/heads/master
2020-04-27T03:03:24.902591
2019-03-26T14:56:40
2019-03-26T14:56:40
174,013,834
2
3
null
null
null
null
UTF-8
C++
false
false
11,475
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2017 The Erotica developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_UINT256_H #define BITCOIN_UINT256_H #include <assert.h> #include <cstring> #include <stdexcept> #include <stdint.h> #include <string> #include <vector> class uint_error : public std::runtime_error { public: explicit uint_error(const std::string& str) : std::runtime_error(str) {} }; /** Template base class for unsigned big integers. */ template <unsigned int BITS> class base_uint { protected: enum { WIDTH = BITS / 32 }; uint32_t pn[WIDTH]; public: base_uint() { for (int i = 0; i < WIDTH; i++) pn[i] = 0; } base_uint(const base_uint& b) { for (int i = 0; i < WIDTH; i++) pn[i] = b.pn[i]; } bool IsNull() const { for (int i = 0; i < WIDTH; i++) if (pn[i] != 0) return false; return true; } void SetNull() { memset(pn, 0, sizeof(pn)); } base_uint& operator=(const base_uint& b) { for (int i = 0; i < WIDTH; i++) pn[i] = b.pn[i]; return *this; } base_uint(uint64_t b) { pn[0] = (unsigned int)b; pn[1] = (unsigned int)(b >> 32); for (int i = 2; i < WIDTH; i++) pn[i] = 0; } explicit base_uint(const std::string& str); explicit base_uint(const std::vector<unsigned char>& vch); bool operator!() const { for (int i = 0; i < WIDTH; i++) if (pn[i] != 0) return false; return true; } const base_uint operator~() const { base_uint ret; for (int i = 0; i < WIDTH; i++) ret.pn[i] = ~pn[i]; return ret; } const base_uint operator-() const { base_uint ret; for (int i = 0; i < WIDTH; i++) ret.pn[i] = ~pn[i]; ret++; return ret; } double getdouble() const; base_uint& operator=(uint64_t b) { pn[0] = (unsigned int)b; pn[1] = (unsigned int)(b >> 32); for (int i = 2; i < WIDTH; i++) pn[i] = 0; return *this; } base_uint& operator^=(const base_uint& b) { for (int i = 0; i < WIDTH; i++) pn[i] ^= b.pn[i]; return *this; } base_uint& operator&=(const base_uint& b) { for (int i = 0; i < WIDTH; i++) pn[i] &= b.pn[i]; return *this; } base_uint& operator|=(const base_uint& b) { for (int i = 0; i < WIDTH; i++) pn[i] |= b.pn[i]; return *this; } base_uint& operator^=(uint64_t b) { pn[0] ^= (unsigned int)b; pn[1] ^= (unsigned int)(b >> 32); return *this; } base_uint& operator|=(uint64_t b) { pn[0] |= (unsigned int)b; pn[1] |= (unsigned int)(b >> 32); return *this; } base_uint& operator<<=(unsigned int shift); base_uint& operator>>=(unsigned int shift); base_uint& operator+=(const base_uint& b) { uint64_t carry = 0; for (int i = 0; i < WIDTH; i++) { uint64_t n = carry + pn[i] + b.pn[i]; pn[i] = n & 0xffffffff; carry = n >> 32; } return *this; } base_uint& operator-=(const base_uint& b) { *this += -b; return *this; } base_uint& operator+=(uint64_t b64) { base_uint b; b = b64; *this += b; return *this; } base_uint& operator-=(uint64_t b64) { base_uint b; b = b64; *this += -b; return *this; } base_uint& operator*=(uint32_t b32); base_uint& operator*=(const base_uint& b); base_uint& operator/=(const base_uint& b); base_uint& operator++() { // prefix operator int i = 0; while (++pn[i] == 0 && i < WIDTH - 1) i++; return *this; } const base_uint operator++(int) { // postfix operator const base_uint ret = *this; ++(*this); return ret; } base_uint& operator--() { // prefix operator int i = 0; while (--pn[i] == (uint32_t)-1 && i < WIDTH - 1) i++; return *this; } const base_uint operator--(int) { // postfix operator const base_uint ret = *this; --(*this); return ret; } int CompareTo(const base_uint& b) const; bool EqualTo(uint64_t b) const; friend inline const base_uint operator+(const base_uint& a, const base_uint& b) { return base_uint(a) += b; } friend inline const base_uint operator-(const base_uint& a, const base_uint& b) { return base_uint(a) -= b; } friend inline const base_uint operator*(const base_uint& a, const base_uint& b) { return base_uint(a) *= b; } friend inline const base_uint operator/(const base_uint& a, const base_uint& b) { return base_uint(a) /= b; } friend inline const base_uint operator|(const base_uint& a, const base_uint& b) { return base_uint(a) |= b; } friend inline const base_uint operator&(const base_uint& a, const base_uint& b) { return base_uint(a) &= b; } friend inline const base_uint operator^(const base_uint& a, const base_uint& b) { return base_uint(a) ^= b; } friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; } friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; } friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; } friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; } friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; } friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; } friend inline bool operator<(const base_uint& a, const base_uint& b) { return a.CompareTo(b) < 0; } friend inline bool operator>=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) >= 0; } friend inline bool operator<=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) <= 0; } friend inline bool operator==(const base_uint& a, uint64_t b) { return a.EqualTo(b); } friend inline bool operator!=(const base_uint& a, uint64_t b) { return !a.EqualTo(b); } std::string GetHex() const; void SetHex(const char* psz); void SetHex(const std::string& str); std::string ToString() const; std::string ToStringReverseEndian() const; unsigned char* begin() { return (unsigned char*)&pn[0]; } unsigned char* end() { return (unsigned char*)&pn[WIDTH]; } const unsigned char* begin() const { return (unsigned char*)&pn[0]; } const unsigned char* end() const { return (unsigned char*)&pn[WIDTH]; } unsigned int size() const { return sizeof(pn); } uint64_t Get64(int n = 0) const { return pn[2 * n] | (uint64_t)pn[2 * n + 1] << 32; } uint32_t Get32(int n = 0) const { return pn[2 * n]; } /** * Returns the position of the highest bit set plus one, or zero if the * value is zero. */ unsigned int bits() const; uint64_t GetLow64() const { assert(WIDTH >= 2); return pn[0] | (uint64_t)pn[1] << 32; } unsigned int GetSerializeSize(int nType, int nVersion) const { return sizeof(pn); } template <typename Stream> void Serialize(Stream& s, int nType, int nVersion) const { s.write((char*)pn, sizeof(pn)); } template <typename Stream> void Unserialize(Stream& s, int nType, int nVersion) { s.read((char*)pn, sizeof(pn)); } friend class uint160; friend class uint256; friend class uint512; }; /** 160-bit unsigned big integer. */ class uint160 : public base_uint<160> { public: uint160() {} uint160(const base_uint<160>& b) : base_uint<160>(b) {} uint160(uint64_t b) : base_uint<160>(b) {} explicit uint160(const std::string& str) : base_uint<160>(str) {} explicit uint160(const std::vector<unsigned char>& vch) : base_uint<160>(vch) {} }; /** 256-bit unsigned big integer. */ class uint256 : public base_uint<256> { public: uint256() {} uint256(const base_uint<256>& b) : base_uint<256>(b) {} uint256(uint64_t b) : base_uint<256>(b) {} explicit uint256(const std::string& str) : base_uint<256>(str) {} explicit uint256(const std::vector<unsigned char>& vch) : base_uint<256>(vch) {} /** * The "compact" format is a representation of a whole * number N using an unsigned 32bit number similar to a * floating point format. * The most significant 8 bits are the unsigned exponent of base 256. * This exponent can be thought of as "number of bytes of N". * The lower 23 bits are the mantissa. * Bit number 24 (0x800000) represents the sign of N. * N = (-1^sign) * mantissa * 256^(exponent-3) * * Satoshi's original implementation used BN_bn2mpi() and BN_mpi2bn(). * MPI uses the most significant bit of the first byte as sign. * Thus 0x1234560000 is compact (0x05123456) * and 0xc0de000000 is compact (0x0600c0de) * * Bitcoin only uses this "compact" format for encoding difficulty * targets, which are unsigned 256bit quantities. Thus, all the * complexities of the sign bit and using base 256 are probably an * implementation accident. */ uint256& SetCompact(uint32_t nCompact, bool* pfNegative = NULL, bool* pfOverflow = NULL); uint32_t GetCompact(bool fNegative = false) const; uint64_t GetHash(const uint256& salt) const; }; /* uint256 from const char *. * This is a separate function because the constructor uint256(const char*) can result * in dangerously catching uint256(0). */ inline uint256 uint256S(const char* str) { uint256 rv; rv.SetHex(str); return rv; } /* uint256 from std::string. * This is a separate function because the constructor uint256(const std::string &str) can result * in dangerously catching uint256(0) via std::string(const char*). */ inline uint256 uint256S(const std::string& str) { uint256 rv; rv.SetHex(str); return rv; } /** 512-bit unsigned big integer. */ class uint512 : public base_uint<512> { public: uint512() {} uint512(const base_uint<512>& b) : base_uint<512>(b) {} uint512(uint64_t b) : base_uint<512>(b) {} explicit uint512(const std::string& str) : base_uint<512>(str) {} explicit uint512(const std::vector<unsigned char>& vch) : base_uint<512>(vch) {} uint256 trim256() const { uint256 ret; for (unsigned int i = 0; i < uint256::WIDTH; i++) { ret.pn[i] = pn[i]; } return ret; } }; inline uint512 uint512S(const std::string& str) { uint512 rv; rv.SetHex(str); return rv; } #endif // BITCOIN_UINT256_H
[ "ratstang@digis.net" ]
ratstang@digis.net
10b979ae446408c63a6c1848c359c4beb5adfe80
aeadc5df188c3ca1f6be9acefea1d6f0ceeb8b01
/Eye3D/src/render/Texture.h
5d50ecbb17c0954b2b5fff9404c2d88c1921ba71
[]
no_license
Arikes/EyeWorld
56b30df17eded0c94ada14a027bb9efc0f73627a
a33ca994f35e5bb536f21f39aed3436e333a0ce4
refs/heads/master
2020-05-22T08:42:38.535661
2019-06-26T09:40:03
2019-06-26T09:40:03
186,283,347
2
0
null
null
null
null
UTF-8
C++
false
false
236
h
#pragma once #include "../common.h" namespace UxDeepEye { class CTexture { public: CTexture(const char *path); ~CTexture(); GLuint GetTexture(); private: GLuint _textureID; std::string _texturePath; bool _isReady; }; }
[ "liang0035@163.com" ]
liang0035@163.com
7f39127f6dfe59f867ff6a38f2efd31b51339adb
67f988dedfd8ae049d982d1a8213bb83233d90de
/external/chromium/chrome/browser/google/google_url_tracker_unittest.cc
82d518467a99ad9aef3a3c0b87f7ec082a2cbecf
[ "BSD-3-Clause" ]
permissive
opensourceyouthprogramming/h5vcc
94a668a9384cc3096a365396b5e4d1d3e02aacc4
d55d074539ba4555e69e9b9a41e5deb9b9d26c5b
refs/heads/master
2020-04-20T04:57:47.419922
2019-02-12T00:56:14
2019-02-12T00:56:14
168,643,719
1
1
null
2019-02-12T00:49:49
2019-02-01T04:47:32
C++
UTF-8
C++
false
false
40,746
cc
// Copyright (c) 2012 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 "chrome/browser/google/google_url_tracker.h" #include <set> #include <string> #include "base/message_loop.h" #include "chrome/browser/api/infobars/infobar_delegate.h" #include "chrome/browser/google/google_url_tracker_factory.h" #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" #include "chrome/browser/infobars/infobar.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" #include "content/public/browser/notification_service.h" #include "content/public/test/test_browser_thread.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_fetcher.h" #include "testing/gtest/include/gtest/gtest.h" class GoogleURLTrackerTest; namespace { // TestInfoBarDelegate -------------------------------------------------------- class TestInfoBarDelegate : public GoogleURLTrackerInfoBarDelegate { public: TestInfoBarDelegate(GoogleURLTrackerTest* test_harness, InfoBarTabHelper* infobar_helper, GoogleURLTracker* google_url_tracker, const GURL& search_url); virtual ~TestInfoBarDelegate(); private: // GoogleURLTrackerInfoBarDelegate: virtual void Update(const GURL& search_url) OVERRIDE; virtual void Close(bool redo_search) OVERRIDE; GoogleURLTrackerTest* test_harness_; InfoBarTabHelper* infobar_helper_; DISALLOW_COPY_AND_ASSIGN(TestInfoBarDelegate); }; // The member function definitions come after the declaration of // GoogleURLTrackerTest, so they can call members on it. // TestNotificationObserver --------------------------------------------------- class TestNotificationObserver : public content::NotificationObserver { public: TestNotificationObserver(); virtual ~TestNotificationObserver(); virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details); bool notified() const { return notified_; } void clear_notified() { notified_ = false; } private: bool notified_; }; TestNotificationObserver::TestNotificationObserver() : notified_(false) { } TestNotificationObserver::~TestNotificationObserver() { } void TestNotificationObserver::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { notified_ = true; } } // namespace // GoogleURLTrackerTest ------------------------------------------------------- // Ths class exercises GoogleURLTracker. In order to avoid instantiating more // of the Chrome infrastructure than necessary, the GoogleURLTracker functions // are carefully written so that many of the functions which take WebContents*, // NavigationController*, InfoBarTabHelper*, or objects containing such pointers // (e.g. NotificationSource) do not actually dereference the objects, merely use // them for comparisons and lookups, e.g. in |entry_map_|. This then allows the // test code here to not create any of these objects, and instead supply // "pointers" that are actually reinterpret_cast<>()ed magic numbers. Then we // write the necessary stubs/hooks, here and in TestInfoBarDelegate above, to // make everything continue to work. // // Technically, the C++98 spec defines the result of casting // T* -> intptr_t -> T* to be an identity, but intptr_t -> T* -> intptr_t (what // we use here) is "implementation-defined". Since I've never seen a compiler // break this, though, and the result would simply be a failing test rather than // a bug in Chrome, we'll use it anyway. class GoogleURLTrackerTest : public testing::Test { public: // Called by TestInfoBarDelegate::Close(). void OnInfoBarClosed(GoogleURLTrackerInfoBarDelegate* infobar, InfoBarTabHelper* infobar_helper); protected: GoogleURLTrackerTest(); virtual ~GoogleURLTrackerTest(); // testing::Test virtual void SetUp() OVERRIDE; virtual void TearDown() OVERRIDE; net::TestURLFetcher* GetFetcher(); void MockSearchDomainCheckResponse(const std::string& domain); void RequestServerCheck(); void FinishSleep(); void NotifyIPAddressChanged(); GURL fetched_google_url() const { return google_url_tracker_->fetched_google_url(); } void set_google_url(const GURL& url) { google_url_tracker_->google_url_ = url; } GURL google_url() const { return google_url_tracker_->google_url(); } void SetLastPromptedGoogleURL(const GURL& url); GURL GetLastPromptedGoogleURL(); void SetNavigationPending(intptr_t unique_id, bool is_search); void CommitNonSearch(intptr_t unique_id); void CommitSearch(intptr_t unique_id, const GURL& search_url); void DoInstantNavigation(intptr_t unique_id, const GURL& search_url); void CloseTab(intptr_t unique_id); GoogleURLTrackerMapEntry* GetMapEntry(intptr_t unique_id); GoogleURLTrackerInfoBarDelegate* GetInfoBar(intptr_t unique_id); void ExpectDefaultURLs() const; void ExpectListeningForCommit(intptr_t unique_id, bool listening); bool observer_notified() const { return observer_.notified(); } void clear_observer_notified() { observer_.clear_notified(); } private: // Since |infobar_helper| is really a magic number rather than an actual // object, we don't add the created infobar to it. Instead we will simulate // any helper<->infobar interaction necessary. The returned object will be // cleaned up in CloseTab(). GoogleURLTrackerInfoBarDelegate* CreateTestInfoBar( InfoBarTabHelper* infobar_helper, GoogleURLTracker* google_url_tracker, const GURL& search_url); // These are required by the TestURLFetchers GoogleURLTracker will create (see // test_url_fetcher_factory.h). MessageLoop message_loop_; content::TestBrowserThread io_thread_; // Creating this allows us to call // net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(). scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; net::TestURLFetcherFactory fetcher_factory_; content::NotificationRegistrar registrar_; TestNotificationObserver observer_; TestingProfile profile_; scoped_ptr<GoogleURLTracker> google_url_tracker_; // This tracks the different "tabs" a test has "opened", so we can close them // properly before shutting down |google_url_tracker_|, which expects that. std::set<int> unique_ids_seen_; }; void GoogleURLTrackerTest::OnInfoBarClosed( GoogleURLTrackerInfoBarDelegate* infobar, InfoBarTabHelper* infobar_helper) { // First, simulate the InfoBarTabHelper firing INFOBAR_REMOVED. InfoBarRemovedDetails removed_details(infobar, false); GoogleURLTracker::EntryMap::const_iterator i = google_url_tracker_->entry_map_.find(infobar_helper); ASSERT_FALSE(i == google_url_tracker_->entry_map_.end()); GoogleURLTrackerMapEntry* map_entry = i->second; ASSERT_EQ(infobar, map_entry->infobar()); map_entry->Observe(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, content::Source<InfoBarTabHelper>(infobar_helper), content::Details<InfoBarRemovedDetails>(&removed_details)); // Second, simulate the infobar container closing the infobar in response. infobar->InfoBarClosed(); } GoogleURLTrackerTest::GoogleURLTrackerTest() : message_loop_(MessageLoop::TYPE_IO), io_thread_(content::BrowserThread::IO, &message_loop_) { GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(&profile_); } GoogleURLTrackerTest::~GoogleURLTrackerTest() { } void GoogleURLTrackerTest::SetUp() { network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); google_url_tracker_.reset( new GoogleURLTracker(&profile_, GoogleURLTracker::UNIT_TEST_MODE)); google_url_tracker_->infobar_creator_ = base::Bind( &GoogleURLTrackerTest::CreateTestInfoBar, base::Unretained(this)); } void GoogleURLTrackerTest::TearDown() { while (!unique_ids_seen_.empty()) CloseTab(*unique_ids_seen_.begin()); google_url_tracker_.reset(); network_change_notifier_.reset(); } net::TestURLFetcher* GoogleURLTrackerTest::GetFetcher() { // This will return the last fetcher created. If no fetchers have been // created, we'll pass GetFetcherByID() "-1", and it will return NULL. return fetcher_factory_.GetFetcherByID(google_url_tracker_->fetcher_id_ - 1); } void GoogleURLTrackerTest::MockSearchDomainCheckResponse( const std::string& domain) { net::TestURLFetcher* fetcher = GetFetcher(); if (!fetcher) return; fetcher_factory_.RemoveFetcherFromMap(fetcher->id()); fetcher->set_url(GURL(GoogleURLTracker::kSearchDomainCheckURL)); fetcher->set_response_code(200); fetcher->SetResponseString(domain); fetcher->delegate()->OnURLFetchComplete(fetcher); // At this point, |fetcher| is deleted. } void GoogleURLTrackerTest::RequestServerCheck() { if (!registrar_.IsRegistered(&observer_, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, content::Source<Profile>(&profile_))) { registrar_.Add(&observer_, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, content::Source<Profile>(&profile_)); } google_url_tracker_->SetNeedToFetch(); } void GoogleURLTrackerTest::FinishSleep() { google_url_tracker_->FinishSleep(); } void GoogleURLTrackerTest::NotifyIPAddressChanged() { net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); // For thread safety, the NCN queues tasks to do the actual notifications, so // we need to spin the message loop so the tracker will actually be notified. MessageLoop::current()->RunUntilIdle(); } void GoogleURLTrackerTest::SetLastPromptedGoogleURL(const GURL& url) { profile_.GetPrefs()->SetString(prefs::kLastPromptedGoogleURL, url.spec()); } GURL GoogleURLTrackerTest::GetLastPromptedGoogleURL() { return GURL(profile_.GetPrefs()->GetString(prefs::kLastPromptedGoogleURL)); } void GoogleURLTrackerTest::SetNavigationPending(intptr_t unique_id, bool is_search) { if (is_search) { google_url_tracker_->SearchCommitted(); // Note that the call above might not have actually registered a listener // for NOTIFICATION_NAV_ENTRY_PENDING if the searchdomaincheck response was // bogus. } unique_ids_seen_.insert(unique_id); if (google_url_tracker_->registrar_.IsRegistered(google_url_tracker_.get(), content::NOTIFICATION_NAV_ENTRY_PENDING, content::NotificationService::AllBrowserContextsAndSources())) { google_url_tracker_->OnNavigationPending( content::Source<content::NavigationController>( reinterpret_cast<content::NavigationController*>(unique_id)), content::Source<content::WebContents>( reinterpret_cast<content::WebContents*>(unique_id)), reinterpret_cast<InfoBarTabHelper*>(unique_id), unique_id); } } void GoogleURLTrackerTest::CommitNonSearch(intptr_t unique_id) { GoogleURLTrackerMapEntry* map_entry = GetMapEntry(unique_id); if (!map_entry) return; ExpectListeningForCommit(unique_id, false); // The infobar should be showing; otherwise the pending non-search should // have closed it. ASSERT_TRUE(map_entry->has_infobar()); // The pending_id should have been reset to 0 when the non-search became // pending. EXPECT_EQ(0, map_entry->infobar()->pending_id()); // Committing the navigation would close the infobar. map_entry->infobar()->Close(false); } void GoogleURLTrackerTest::CommitSearch(intptr_t unique_id, const GURL& search_url) { DCHECK(search_url.is_valid()); if (google_url_tracker_->registrar_.IsRegistered(google_url_tracker_.get(), content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<content::NavigationController>( reinterpret_cast<content::NavigationController*>(unique_id)))) { google_url_tracker_->OnNavigationCommitted( reinterpret_cast<InfoBarTabHelper*>(unique_id), search_url); } } void GoogleURLTrackerTest::DoInstantNavigation(intptr_t unique_id, const GURL& search_url) { if (!search_url.is_empty()) { google_url_tracker_->SearchCommitted(); // Note that the call above might not have actually registered a listener // for NOTIFICATION_INSTANT_COMMITTED if the searchdomaincheck response was // bogus. } unique_ids_seen_.insert(unique_id); if (google_url_tracker_->registrar_.IsRegistered(google_url_tracker_.get(), chrome::NOTIFICATION_INSTANT_COMMITTED, content::NotificationService::AllBrowserContextsAndSources())) { google_url_tracker_->OnInstantCommitted( content::Source<content::NavigationController>( reinterpret_cast<content::NavigationController*>(unique_id)), content::Source<content::WebContents>( reinterpret_cast<content::WebContents*>(unique_id)), reinterpret_cast<InfoBarTabHelper*>(unique_id), search_url); } } void GoogleURLTrackerTest::CloseTab(intptr_t unique_id) { unique_ids_seen_.erase(unique_id); content::Source<content::WebContents> source( reinterpret_cast<content::WebContents*>(unique_id)); if (google_url_tracker_->registrar_.IsRegistered( google_url_tracker_.get(), content::NOTIFICATION_WEB_CONTENTS_DESTROYED, source)) { google_url_tracker_->OnTabClosed(source); } else { // Closing a tab with an infobar showing would close the infobar. GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(unique_id); if (infobar) infobar->Close(false); } } GoogleURLTrackerMapEntry* GoogleURLTrackerTest::GetMapEntry( intptr_t unique_id) { GoogleURLTracker::EntryMap::const_iterator i = google_url_tracker_->entry_map_.find( reinterpret_cast<InfoBarTabHelper*>(unique_id)); return (i == google_url_tracker_->entry_map_.end()) ? NULL : i->second; } GoogleURLTrackerInfoBarDelegate* GoogleURLTrackerTest::GetInfoBar( intptr_t unique_id) { GoogleURLTrackerMapEntry* map_entry = GetMapEntry(unique_id); return map_entry ? map_entry->infobar() : NULL; } void GoogleURLTrackerTest::ExpectDefaultURLs() const { EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL(), fetched_google_url()); } void GoogleURLTrackerTest::ExpectListeningForCommit(intptr_t unique_id, bool listening) { GoogleURLTrackerMapEntry* map_entry = GetMapEntry(unique_id); if (map_entry) { EXPECT_EQ(listening, google_url_tracker_->registrar_.IsRegistered( google_url_tracker_.get(), content::NOTIFICATION_NAV_ENTRY_COMMITTED, map_entry->navigation_controller_source())); } else { EXPECT_FALSE(listening); } } GoogleURLTrackerInfoBarDelegate* GoogleURLTrackerTest::CreateTestInfoBar( InfoBarTabHelper* infobar_helper, GoogleURLTracker* google_url_tracker, const GURL& search_url) { return new TestInfoBarDelegate(this, infobar_helper, google_url_tracker, search_url); } // TestInfoBarDelegate -------------------------------------------------------- namespace { TestInfoBarDelegate::TestInfoBarDelegate(GoogleURLTrackerTest* test_harness, InfoBarTabHelper* infobar_helper, GoogleURLTracker* google_url_tracker, const GURL& search_url) : GoogleURLTrackerInfoBarDelegate(NULL, google_url_tracker, search_url), test_harness_(test_harness), infobar_helper_(infobar_helper) { } TestInfoBarDelegate::~TestInfoBarDelegate() { } void TestInfoBarDelegate::Update(const GURL& search_url) { set_search_url(search_url); set_pending_id(0); } void TestInfoBarDelegate::Close(bool redo_search) { test_harness_->OnInfoBarClosed(this, infobar_helper_); } } // namespace // Tests ---------------------------------------------------------------------- TEST_F(GoogleURLTrackerTest, DontFetchWhenNoOneRequestsCheck) { ExpectDefaultURLs(); FinishSleep(); // No one called RequestServerCheck() so nothing should have happened. EXPECT_FALSE(GetFetcher()); MockSearchDomainCheckResponse("http://www.google.co.uk/"); ExpectDefaultURLs(); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, UpdateOnFirstRun) { RequestServerCheck(); EXPECT_FALSE(GetFetcher()); ExpectDefaultURLs(); EXPECT_FALSE(observer_notified()); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); // GoogleURL should be updated, becase there was no last prompted URL. EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_TRUE(observer_notified()); } TEST_F(GoogleURLTrackerTest, DontUpdateWhenUnchanged) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); EXPECT_FALSE(GetFetcher()); ExpectDefaultURLs(); EXPECT_FALSE(observer_notified()); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); // GoogleURL should not be updated, because the fetched and prompted URLs // match. EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, DontPromptOnBadReplies) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); EXPECT_FALSE(GetFetcher()); ExpectDefaultURLs(); EXPECT_FALSE(observer_notified()); // Old-style domain string. FinishSleep(); MockSearchDomainCheckResponse(".google.co.in"); EXPECT_EQ(GURL(), fetched_google_url()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_FALSE(observer_notified()); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_TRUE(GetMapEntry(1) == NULL); // Bad subdomain. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://mail.google.com/"); EXPECT_EQ(GURL(), fetched_google_url()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_FALSE(observer_notified()); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_TRUE(GetMapEntry(1) == NULL); // Non-empty path. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.com/search"); EXPECT_EQ(GURL(), fetched_google_url()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_FALSE(observer_notified()); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_TRUE(GetMapEntry(1) == NULL); // Non-empty query. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.com/?q=foo"); EXPECT_EQ(GURL(), fetched_google_url()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_FALSE(observer_notified()); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_TRUE(GetMapEntry(1) == NULL); // Non-empty ref. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.com/#anchor"); EXPECT_EQ(GURL(), fetched_google_url()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_FALSE(observer_notified()); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_TRUE(GetMapEntry(1) == NULL); // Complete garbage. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("HJ)*qF)_*&@f1"); EXPECT_EQ(GURL(), fetched_google_url()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_FALSE(observer_notified()); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_TRUE(GetMapEntry(1) == NULL); } TEST_F(GoogleURLTrackerTest, UpdatePromptedURLOnReturnToPreviousLocation) { SetLastPromptedGoogleURL(GURL("http://www.google.co.jp/")); set_google_url(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, SilentlyAcceptSchemeChange) { // We should auto-accept changes to the current Google URL that merely change // the scheme, regardless of what the last prompted URL was. SetLastPromptedGoogleURL(GURL("http://www.google.co.jp/")); set_google_url(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("https://www.google.co.uk/"); EXPECT_EQ(GURL("https://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("https://www.google.co.uk/"), google_url()); EXPECT_EQ(GURL("https://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_TRUE(observer_notified()); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_TRUE(observer_notified()); } TEST_F(GoogleURLTrackerTest, RefetchOnIPAddressChange) { RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_TRUE(observer_notified()); clear_observer_notified(); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.in/"); EXPECT_EQ(GURL("http://www.google.co.in/"), fetched_google_url()); // Just fetching a new URL shouldn't reset things without a prompt. EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, DontRefetchWhenNoOneRequestsCheck) { FinishSleep(); NotifyIPAddressChanged(); // No one called RequestServerCheck() so nothing should have happened. EXPECT_FALSE(GetFetcher()); MockSearchDomainCheckResponse("http://www.google.co.uk/"); ExpectDefaultURLs(); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, FetchOnLateRequest) { FinishSleep(); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); RequestServerCheck(); // The first request for a check should trigger a fetch if it hasn't happened // already. MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_TRUE(observer_notified()); } TEST_F(GoogleURLTrackerTest, DontFetchTwiceOnLateRequests) { FinishSleep(); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); RequestServerCheck(); // The first request for a check should trigger a fetch if it hasn't happened // already. MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_TRUE(observer_notified()); clear_observer_notified(); RequestServerCheck(); // The second request should be ignored. EXPECT_FALSE(GetFetcher()); MockSearchDomainCheckResponse("http://www.google.co.in/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, SearchingDoesNothingIfNoNeedToPrompt) { RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_TRUE(observer_notified()); clear_observer_notified(); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_TRUE(GetMapEntry(1) == NULL); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, TabClosedOnPendingSearch) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.jp/"), fetched_google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); SetNavigationPending(1, true); GoogleURLTrackerMapEntry* map_entry = GetMapEntry(1); ASSERT_FALSE(map_entry == NULL); EXPECT_FALSE(map_entry->has_infobar()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); CloseTab(1); EXPECT_TRUE(GetMapEntry(1) == NULL); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, TabClosedOnCommittedSearch) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_FALSE(GetInfoBar(1) == NULL); CloseTab(1); EXPECT_TRUE(GetMapEntry(1) == NULL); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, InfoBarClosed) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); ASSERT_FALSE(infobar == NULL); infobar->Close(false); EXPECT_TRUE(GetMapEntry(1) == NULL); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, InfoBarRefused) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); ASSERT_FALSE(infobar == NULL); infobar->Cancel(); EXPECT_TRUE(GetMapEntry(1) == NULL); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, InfoBarAccepted) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); ASSERT_FALSE(infobar == NULL); infobar->Accept(); EXPECT_TRUE(GetMapEntry(1) == NULL); EXPECT_EQ(GURL("http://www.google.co.jp/"), google_url()); EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL()); EXPECT_TRUE(observer_notified()); } TEST_F(GoogleURLTrackerTest, InfoBarForInstant) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); DoInstantNavigation(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_FALSE(GetInfoBar(1) == NULL); } TEST_F(GoogleURLTrackerTest, FetchesCanAutomaticallyCloseInfoBars) { RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse(google_url().spec()); // Re-fetching the accepted URL after showing an infobar for another URL // should close the infobar. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); EXPECT_FALSE(GetInfoBar(1) == NULL); NotifyIPAddressChanged(); MockSearchDomainCheckResponse(google_url().spec()); EXPECT_EQ(google_url(), GetLastPromptedGoogleURL()); EXPECT_TRUE(GetMapEntry(1) == NULL); // As should fetching a URL that differs from the accepted only by the scheme. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); EXPECT_FALSE(GetInfoBar(1) == NULL); NotifyIPAddressChanged(); url_canon::Replacements<char> replacements; const std::string& scheme("https"); replacements.SetScheme(scheme.data(), url_parse::Component(0, scheme.length())); GURL new_google_url(google_url().ReplaceComponents(replacements)); MockSearchDomainCheckResponse(new_google_url.spec()); EXPECT_EQ(new_google_url, GetLastPromptedGoogleURL()); EXPECT_TRUE(GetMapEntry(1) == NULL); // As should re-fetching the last prompted URL. SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); EXPECT_FALSE(GetInfoBar(1) == NULL); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(new_google_url, google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_TRUE(GetMapEntry(1) == NULL); // And one that differs from the last prompted URL only by the scheme. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); EXPECT_FALSE(GetInfoBar(1) == NULL); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("https://www.google.co.uk/"); EXPECT_EQ(new_google_url, google_url()); EXPECT_EQ(GURL("https://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_TRUE(GetMapEntry(1) == NULL); // And fetching a different URL entirely. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); EXPECT_FALSE(GetInfoBar(1) == NULL); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("https://www.google.co.in/"); EXPECT_EQ(new_google_url, google_url()); EXPECT_EQ(GURL("https://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_TRUE(GetMapEntry(1) == NULL); } TEST_F(GoogleURLTrackerTest, ResetInfoBarGoogleURLs) { RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse(google_url().spec()); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); ASSERT_FALSE(infobar == NULL); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); // If while an infobar is showing we fetch a new URL that differs from the // infobar's only by scheme, the infobar should stay showing. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("https://www.google.co.uk/"); EXPECT_EQ(infobar, GetInfoBar(1)); EXPECT_EQ(GURL("https://www.google.co.uk/"), fetched_google_url()); } TEST_F(GoogleURLTrackerTest, NavigationsAfterPendingSearch) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); // A pending non-search after a pending search should delete the map entry. SetNavigationPending(1, true); GoogleURLTrackerMapEntry* map_entry = GetMapEntry(1); ASSERT_FALSE(map_entry == NULL); EXPECT_FALSE(map_entry->has_infobar()); SetNavigationPending(1, false); EXPECT_TRUE(GetMapEntry(1) == NULL); // A pending search after a pending search should leave the map entry alive. SetNavigationPending(1, true); map_entry = GetMapEntry(1); ASSERT_FALSE(map_entry == NULL); EXPECT_FALSE(map_entry->has_infobar()); SetNavigationPending(1, true); ASSERT_EQ(map_entry, GetMapEntry(1)); EXPECT_FALSE(map_entry->has_infobar()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); // Committing this search should show an infobar. CommitSearch(1, GURL("http://www.google.co.uk/search?q=test2")); EXPECT_TRUE(map_entry->has_infobar()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); } TEST_F(GoogleURLTrackerTest, NavigationsAfterCommittedSearch) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); ASSERT_FALSE(infobar == NULL); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); // A pending non-search on a visible infobar should basically do nothing. SetNavigationPending(1, false); ASSERT_EQ(infobar, GetInfoBar(1)); EXPECT_EQ(0, infobar->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); // As should another pending non-search after the first. SetNavigationPending(1, false); ASSERT_EQ(infobar, GetInfoBar(1)); EXPECT_EQ(0, infobar->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); // Committing this non-search should close the infobar. The control flow in // these tests is not really comparable to in the real browser, but at least a // few sanity-checks will be performed. ASSERT_NO_FATAL_FAILURE(CommitNonSearch(1)); EXPECT_TRUE(GetMapEntry(1) == NULL); // A pending search on a visible infobar should cause the infobar to listen // for the search to commit. SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); infobar = GetInfoBar(1); ASSERT_FALSE(infobar == NULL); SetNavigationPending(1, true); ASSERT_EQ(infobar, GetInfoBar(1)); EXPECT_EQ(1, infobar->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); // But a non-search after this should cancel that state. SetNavigationPending(1, false); ASSERT_EQ(infobar, GetInfoBar(1)); EXPECT_EQ(0, infobar->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); // Another pending search after the non-search should put us back into // "waiting for commit" mode. SetNavigationPending(1, true); ASSERT_EQ(infobar, GetInfoBar(1)); EXPECT_EQ(1, infobar->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); // A second pending search after the first should not really change anything. SetNavigationPending(1, true); ASSERT_EQ(infobar, GetInfoBar(1)); EXPECT_EQ(1, infobar->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); // Committing this search should change the visible infobar's search_url. CommitSearch(1, GURL("http://www.google.co.uk/search?q=test2")); ASSERT_EQ(infobar, GetInfoBar(1)); EXPECT_EQ(GURL("http://www.google.co.uk/search?q=test2"), infobar->search_url()); EXPECT_EQ(0, infobar->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); } TEST_F(GoogleURLTrackerTest, MultipleMapEntries) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); GoogleURLTrackerMapEntry* map_entry = GetMapEntry(1); ASSERT_FALSE(map_entry == NULL); EXPECT_FALSE(map_entry->has_infobar()); SetNavigationPending(2, true); CommitSearch(2, GURL("http://www.google.co.uk/search?q=test2")); GoogleURLTrackerInfoBarDelegate* infobar2 = GetInfoBar(2); ASSERT_FALSE(infobar2 == NULL); EXPECT_EQ(GURL("http://www.google.co.uk/search?q=test2"), infobar2->search_url()); SetNavigationPending(3, true); GoogleURLTrackerMapEntry* map_entry3 = GetMapEntry(3); ASSERT_FALSE(map_entry3 == NULL); EXPECT_FALSE(map_entry3->has_infobar()); SetNavigationPending(4, true); CommitSearch(4, GURL("http://www.google.co.uk/search?q=test4")); GoogleURLTrackerInfoBarDelegate* infobar4 = GetInfoBar(4); ASSERT_FALSE(infobar4 == NULL); EXPECT_EQ(GURL("http://www.google.co.uk/search?q=test4"), infobar4->search_url()); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); EXPECT_TRUE(map_entry->has_infobar()); infobar2->Close(false); EXPECT_TRUE(GetMapEntry(2) == NULL); EXPECT_FALSE(observer_notified()); infobar4->Accept(); EXPECT_TRUE(GetMapEntry(1) == NULL); EXPECT_TRUE(GetMapEntry(3) == NULL); EXPECT_TRUE(GetMapEntry(4) == NULL); EXPECT_EQ(GURL("http://www.google.co.jp/"), google_url()); EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL()); EXPECT_TRUE(observer_notified()); } TEST_F(GoogleURLTrackerTest, IgnoreIrrelevantInstantNavigation) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); // Starting a search pending on any tab should cause us to listen for pending // and instant navigations on all tabs, but we should ignore these when they // are for tabs that we don't care about. SetNavigationPending(1, true); EXPECT_FALSE(GetMapEntry(1) == NULL); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(2, false)); DoInstantNavigation(2, GURL()); EXPECT_TRUE(GetMapEntry(2) == NULL); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(2, false)); } TEST_F(GoogleURLTrackerTest, IgnoreIrrelevantNavigation) { SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); RequestServerCheck(); FinishSleep(); MockSearchDomainCheckResponse("http://www.google.co.jp/"); // This tests a particularly gnarly sequence of events that used to cause us // to erroneously listen for a non-search navigation to commit. SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); SetNavigationPending(2, true); CommitSearch(2, GURL("http://www.google.co.uk/search?q=test2")); EXPECT_FALSE(GetInfoBar(1) == NULL); GoogleURLTrackerInfoBarDelegate* infobar2 = GetInfoBar(2); ASSERT_FALSE(infobar2 == NULL); SetNavigationPending(1, true); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); infobar2->Close(false); SetNavigationPending(1, false); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); }
[ "rjogrady@google.com" ]
rjogrady@google.com
835840fbe5eaf6b37b898b5cd0ef5bdfb9c8b4de
08cd9b06ec88022c5058067c17659960e80a553d
/模板/非负整数的高精度加法及大整数存储 高精度加法 洛谷P1601.cpp
36ad7f354ff8e7abde080d09e986265c247c28f0
[]
no_license
tmzengbi/save-code
fe6641b18f488b01241b6112d56249ca00b541b6
fe50f15beca52f3cb47398ac6f116fefbf31fc85
refs/heads/master
2023-08-25T15:17:57.278833
2021-09-18T09:50:39
2021-09-18T09:50:39
298,801,679
1
0
null
null
null
null
UTF-8
C++
false
false
1,247
cpp
#include<iostream> #include<cstdio> #include<cstring> #include<vector> using namespace std; typedef long long ll; struct Bignum { vector<int> num; Bignum(){init();} void init() { num.clear(); } Bignum operator = (long long n) { num.clear(); do { num.push_back(n%10); n/=10; }while(n); return *this; } Bignum operator =(const string& str) { num.clear(); int x,len=(str.length()-1); for(int i=len;i>=0;i--) { x=str[i]-'0'; num.push_back(x); } return *this; } Bignum operator + (const Bignum &b) const { Bignum S; S.num.clear(); for(int i=0,g=0;;i++) { if(g==0&&i>=num.size()&&i>=b.num.size()) break; int x=g; if(i<num.size()) x+=num[i]; if(i<b.num.size()) x+=b.num[i]; S.num.push_back(x%10); g=x/10; } return S; } Bignum operator +=(const Bignum &b) { *this=*this+b;return *this; } }; istream& operator >>(istream &in, Bignum &x) { string s; if(!(in>>s)) return in; x=s; return in; } ostream& operator <<(ostream& out,const Bignum &x) { // out<<x.num.back(); for(int i=x.num.size()-1;i>=0;i--) { char buf[20]; sprintf(buf,"%d",x.num[i]); for(int j=0;j<strlen(buf);j++) out<<buf[j]; } return out; } int main() { Bignum a,b; cin>>a>>b; cout<<a+b; }
[ "2818097988@qq.com" ]
2818097988@qq.com
bcc61b3d9af6434c349f371723bd5e8c4ecfd144
fc3ab2d3883c122d3bd4743687c6828367a1b92e
/CodeForces/cf-790b.cpp
2e62ee4b24715532b27d39d816bf572607b9f51e
[]
no_license
TowhidKhan01/Competitive-Programming
917f3257c7a03843bc8218cbcb8b39cdc48f6c3c
19b4bfc95a7e97954dd56b0d937e55c54465bc5e
refs/heads/master
2022-04-06T04:16:08.405979
2019-02-24T15:29:10
2019-02-24T15:29:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,011
cpp
#include <iostream> #include <cstdio> #include <string> #include <sstream> #include <vector> #include <list> #include <set> #include <map> #include <queue> #include <stack> #include <bitset> #include <numeric> #include <iterator> #include <algorithm> #include <cmath> #include <chrono> #include <cassert> using namespace std; using ll = long long; using ld = long double; using ii = pair<ll, ll>; using vi = vector<ll>; using vb = vector<bool>; using vvi = vector<vi>; using vii = vector<ii>; using vvii = vector<vii>; const int INF = 2000000000; const ll LLINF = 9000000000000000000; int k; using T = pair<ii, pair<ii, ii>>; T combine(T l, T r) { return {{l.first.first+r.first.first, l.first.second+r.first.second}, {{l.second.first.first+r.second.first.first, l.second.first.second+r.second.first.second}, {l.second.second.first+r.second.second.first, l.second.second.second+r.second.second.second}}}; } T addone(T v) { ll tot, vals[5]; tot = v.first.first; vals[0] = v.first.second; vals[1] = v.second.first.first; vals[2] = v.second.first.second; vals[3] = v.second.second.first; vals[4] = v.second.second.second; tot += vals[0]; for (int i = k - 1; i > 0; --i) swap(vals[i], vals[i - 1]); return {{tot, vals[0]}, {{vals[1], vals[2]}, {vals[3], vals[4]}}}; } void pt(char c, int u, T t) { cout << c << ' ' << u << ": ((" << t.first.first << "," << t.first.second; cout << "), ((" << t.second.first.first << ","; cout << t.second.first.second << "),("; cout << t.second.second.first << ","; cout << t.second.second.second << ")))" << endl; } void dfs1(int u, int p, vvi &E, vector<T> &subtree) { subtree[u] = {{0LL, 1LL}, {{0LL, 0LL}, {0LL, 0LL}}}; for (ll v : E[u]) { if (v == p) continue; dfs1(v, u, E, subtree); subtree[u] = combine(subtree[u], addone(subtree[v])); } // pt('s', u, subtree[u]); } void dfs2(int u, int p, vvi &E, vector<T> &subtree, T top, ll &ans) { int N = E[u].size(); vector<T> suffix(N, {{0LL, 0LL}, {{0LL, 0LL}, {0LL, 0LL}}}); for (int i = N - 1; i >= 0; --i) { int v = E[u][i]; if (v != p) suffix[i] = addone(subtree[v]); if (i + 1 < N) suffix[i] = combine(suffix[i], suffix[i + 1]); } // pt('t', u, top); // Ourselves: T self = combine(top, suffix[0]); ans += self.first.first; top = combine(top, {{0LL, 1LL}, {{0LL, 0LL}, {0LL, 0LL}}}); for (int i = 0; i < N; ++i) { if (E[u][i] == p) continue; T down = top; if (i + 1 < N) down = combine(down, suffix[i + 1]); dfs2(E[u][i], u, E, subtree, addone(down), ans); top = combine(top, addone(subtree[E[u][i]])); } } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n >> k; vvi E(n, vi()); for (int i = 1; i < n; ++i) { int a, b; cin >> a >> b; --a; --b; E[a].push_back(b); E[b].push_back(a); } T def = {{0LL, 0LL}, {{0LL, 0LL}, {0LL, 0LL}}}; vector<T> subtree(n, def); dfs1(0, -1, E, subtree); ll ans = 0LL; dfs2(0, -1, E, subtree, def, ans); ans /= 2LL; cout << ans << endl; return 0; }
[ "timonknigge@live.nl" ]
timonknigge@live.nl
859dda1e5f7b002b967a638601b3918f02e2565c
6d2e9d2dc37fb9f2a8cb77eeb926741185e481e7
/bench/labeling/blobs.cpp
ed84c220ad3734a094098866ac8e5e8793e4eaa0
[]
no_license
onvungocminh/The-Dahu-distance
ad41a1412b85bcb00f449a74188f923fa2fd59e3
edbb135c5a5195c9bf591bf409c796c0f45517b7
refs/heads/master
2022-06-17T18:27:39.804634
2020-05-05T19:14:57
2020-05-05T19:14:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
742
cpp
#include <mln/core/image/image2d.hpp> #include <mln/labeling/blobs.hpp> #include <mln/core/neighb2d.hpp> #include <mln/core/grays.hpp> #include <mln/io/imread.hpp> #include <mln/io/imsave.hpp> #include <mln/core/algorithm/transform.hpp> int main(int argc, const char* argv[]) { using namespace mln; if (argc != 3) { std::cerr << "Usage: " << argv[0] << " input.pbm output.tiff" << std::endl; abort(); } image2d<bool> ima; io::imread(argv[1], ima); trace::verbose = true; labeling::blobs(ima, c8, 0u); { image2d<unsigned> out; resize(out, ima).init(0u); labeling::impl::generic::blobs_boundcheck(ima, c8, 0u, out); io::imsave(transform(out, [](unsigned x) -> float { return x; }), argv[2]); } }
[ "movn@lrde.epita.fr" ]
movn@lrde.epita.fr
d48971cf29a21150c3361d4dfd5ff158b09bbe4b
b5d20ba5c51cbbabb8e8f67e64fec5f22abbf5b5
/webrtc/modules/audio_coding/neteq/expand_uma_logger.h
beca915dc4e508ead1318981e98278077efdae8f
[]
no_license
zeiger589/video-chat
1f979e7f1e7ab543d4e36bef09175548c7528ec6
7c233388298057663cfbb65631b0d0d8b80530d4
refs/heads/master
2020-05-17T07:07:53.894612
2019-04-17T16:10:18
2019-04-17T16:10:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,050
h
/* Copyright (c) 2018 The WebRTC 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 in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef MODULES_AUDIO_CODING_NETEQ_EXPAND_UMA_LOGGER_H_ #define MODULES_AUDIO_CODING_NETEQ_EXPAND_UMA_LOGGER_H_ #include <stdint.h> #include <memory> #include <string> #include "absl/types/optional.h" #include "modules/audio_coding/neteq/tick_timer.h" #include "rtc_base/constructor_magic.h" namespace webrtc { // This class is used to periodically log values to a UMA histogram. The caller // is expected to update this class with an incremental sample counter which // counts expand samples. At the end of each logging period, the class will // calculate the fraction of samples that were expand samples during that period // and report that in percent. The logging period must be strictly positive. // Does not take ownership of tick_timer and the pointer must refer to a valid // object that outlives the one constructed. class ExpandUmaLogger { public: ExpandUmaLogger(std::string uma_name, int logging_period_s, const TickTimer* tick_timer); ~ExpandUmaLogger(); // In this call, value should be an incremental sample counter. The sample // rate must be strictly positive. void UpdateSampleCounter(uint64_t value, int sample_rate_hz); private: const std::string uma_name_; const int logging_period_s_; const TickTimer& tick_timer_; std::unique_ptr<TickTimer::Countdown> timer_; absl::optional<uint64_t> last_logged_value_; uint64_t last_value_ = 0; int sample_rate_hz_ = 0; RTC_DISALLOW_COPY_AND_ASSIGN(ExpandUmaLogger); }; } // namespace webrtc #endif // MODULES_AUDIO_CODING_NETEQ_EXPAND_UMA_LOGGER_H_
[ "tuanit96@gmail.com" ]
tuanit96@gmail.com
21ea5baee6f347e94900b0199310639d366cd766
c135ed55969ffc5c041325e1fb027196fd2c2a6a
/BombMgr.cpp
e38e477f9f0cd414b26ee8ef8ae2e9e0c4899fc6
[]
no_license
tako39/ActionGame
08170653b9a8a869f3068bf74a2c3131051e0363
a2e6ab6879c8963da3d9a7c6dfc855f9f8969172
refs/heads/master
2020-04-08T08:10:39.167311
2019-01-21T03:22:12
2019-01-21T03:22:12
159,168,375
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,101
cpp
#include "BombMgr.h" BombMgr::BombMgr() { putSound = LoadSoundMem("sound/put.mp3"); for (int num = 0; num < BOMB_NUM; num++) { bomb[num] = NULL; deleteTime[num] = -5000; explosion[num] = false; } } BombMgr::~BombMgr() { for (int num = 0; num < BOMB_NUM; num++) { delete bomb[num]; } } void BombMgr::Update() { for (int num = 0; num < BOMB_NUM; num++) { if (bomb[num] != NULL) { bomb[num]->Update(); if (bomb[num]->GetExist() == false) { //bomb[num]が存在しないなら explosion[num] = true; //爆発させる } } } } void BombMgr::Draw(const Player& player) { for (int num = 0; num < BOMB_NUM; num++) { if (bomb[num] != NULL) { bomb[num]->Draw(player); } } } void BombMgr::BombSet(const Player& player) { for (int num = 0; num < BOMB_NUM; num++) { //NULLかつ、消費した時間から2秒経ったものを使用 if (bomb[num] == NULL && (GetNowCount() - deleteTime[num] > 2000)) { PlaySoundMem(putSound, DX_PLAYTYPE_BACK); //爆弾の設置音を鳴らす bomb[num] = new Bomb(player); //爆弾を生成する break; } } }
[ "tako_39@docomo.ne.jp" ]
tako_39@docomo.ne.jp
26eee61acc063a99c77ac2ca7553bcd142d3aabc
54e0ffd2fc7a58dd37966d9ac6ab57860e3bc1ac
/source/common/XJDeque.h
b00d53a9031169fc3cdaad7332358d95b8d79b06
[]
no_license
xjsh2017/vicente2018
4fef21671771ea55c96f617cf31cfedefca72495
414de9d7558c03a8666fc23d7dc080be738e21de
refs/heads/master
2020-03-23T16:37:45.389992
2018-08-28T00:09:37
2018-08-28T00:09:37
141,820,732
2
1
null
null
null
null
GB18030
C++
false
false
6,370
h
/******************************************************************** created: 2008/09/18 created: 17:9:2008 15:56 file base: XJDeque file ext: h author: qingch purpose: *********************************************************************/ #ifndef XJDeque_h__ #define XJDeque_h__ #include <deque> #include "XJLock.h" /** * @defgroup CXJDeque 类说明 * @{ */ /** * @brief 通用数据deque,包含互斥锁的封装,支持std::deque的大部分操作(除了各比较操作符) * @author qingch * @version ver1.0 * @date 01/10/08 * * example * @code * * @endcode */ using namespace std; template <class Type> class CXJDeque { public: typedef CXJDeque<Type> _Myt; typedef typename deque<Type>::allocator_type allocator_type; typedef typename deque<Type>::size_type size_type; typedef typename deque<Type>::difference_type difference_type; typedef typename deque<Type>::iterator iterator; typedef typename deque<Type>::const_iterator const_iterator; typedef typename deque<Type>::reverse_iterator reverse_iterator; typedef typename deque<Type>::const_reverse_iterator const_reverse_iterator; typedef typename deque<Type>::reference reference; typedef typename deque<Type>::const_reference const_reference; typedef typename deque<Type>::value_type value_type; public: explicit CXJDeque(const allocator_type& _Al = allocator_type()) : mDeque(_Al),mLock("CXJDeque") { } // explicit CXJDeque(size_type _N, const Type& _V = Type(), // const allocator_type& _Al = allocator_type()) // :mDeque(_N , _V , _Al),mLock("CXJDeque") // { // } // // typedef const_iterator _It; // CXJDeque(_It _F, _It _L, const allocator_type& _Al = allocator_type()) // :mDeque(_F , _L , _Al),mLock("CXJDeque") // { // } ~CXJDeque(void) { } iterator begin(void) { CLockUp locallock(&mLock); return (mDeque.begin()); } const_iterator begin(void) const { return (mDeque.begin()); } iterator end(void) { CLockUp locallock(&mLock); return (mDeque.end()); } const_iterator end(void) const { return (mDeque.end()); } reverse_iterator rbegin() { CLockUp locallock(&mLock); return (mDeque.rbegin()); } const_reverse_iterator rbegin() const { return (mDeque.rbegin()); } reverse_iterator rend() { CLockUp locallock(&mLock); return (mDeque.rend()); } const_reverse_iterator rend() const { return (mDeque.rend()); } void resize(int cSize) { CLockUp locallock(&mLock); mDeque.resize(cSize); } int size(void) const { return (mDeque.size()); } int max_size(void) const { return (mDeque.max_size()); } bool empty(void) const { return (mDeque.empty()); } allocator_type get_allocator() const { return (mDeque.get_allocator()); } // const_reference at(size_type _P) const // { // return (mDeque.at(_P)); // } // // reference at(size_type _P) // { // return (mDeque.at(_P)); // } // // const_reference operator[](size_type _P) const // { // return (mDeque[_P]); // } // // reference operator[](size_type _P) // { // CLockUp locallock(&mLock); // return (mDeque[_P]); // } reference front(void) { CLockUp locallock(&mLock); return (mDeque.front()); } const_reference front(void) const { return (mDeque.front()); } reference back(void) { CLockUp locallock(&mLock); return (mDeque.back()); } const_reference back(void) const { return (mDeque.back()); } void push_front(const Type& element) { CLockUp locallock(&mLock); mDeque.push_front(element); } void pop_front(void) { CLockUp locallock(&mLock); mDeque.pop_front(); } void push_back(const Type& element) { CLockUp locallock(&mLock); mDeque.push_back(element); } void pop_back(void) { CLockUp locallock(&mLock); mDeque.pop_back(); } void assign(const_iterator CIteBegin, const_iterator CIteEnd) { CLockUp locallock(&mLock); mDeque.assign(CIteBegin,CIteEnd); } void assign(size_type cNum, const Type& element) { CLockUp locallock(&mLock); mDeque.assign(cNum,element); } iterator insert(iterator cIte, const Type& element) { CLockUp locallock(&mLock); mDeque.insert(cIte, element); } void insert(iterator cIte, size_type cNum, const Type& element) { CLockUp locallock(&mLock); mDeque.insert(cIte, cNum, element); } void insert(iterator cIte, const_iterator CIteBegin, const_iterator CIteEnd) { CLockUp locallock(&mLock); mDeque.insert(cIte, CIteBegin, CIteEnd); } iterator erase(iterator cIte) { CLockUp locallock(&mLock); mDeque.erase(cIte); } iterator erase(iterator cIteS, iterator cIteE) { CLockUp locallock(&mLock); mDeque.erase(cIteS, cIteE); } void clear(void) { CLockUp locallock(&mLock); mDeque.clear(); } //************************************ // 函 数 名: get_front_pop // 功能概要: 如果队列中有元素则取队列头节点元素,并从队列删除头节点 // 访问权限: public // 返 回 值: bool true:获取成功 false:获取失败 // 参 数: Type & front_element 头节点元素 //************************************ bool get_front_pop(Type& front_element) { CLockUp locallock(&mLock); if (mDeque.empty() == true) { return false; } front_element = mDeque.front(); mDeque.pop_front(); return true; } //************************************ // 函 数 名: get_back_pop // 功能概要: 如果队列中有元素则取队列尾节点元素,并从队列删除尾节点 // 访问权限: public // 返 回 值: bool true:获取成功 false:获取失败 // 参 数: Type & back_element 尾节点元素 //************************************ bool get_back_pop(Type& back_element) { CLockUp locallock(&mLock); if (mDeque.empty() == true) { return false; } back_element = mDeque.back(); mDeque.pop_back(); return true; } private: // _Myt& operator=(const _Myt& _X) // { // } // CXJDeque(const _Myt& _X) // { // } deque<Type> mDeque; CXJLock mLock; }; /** @} */ //OVER #endif // XJDeque_h__
[ "benevo.woo@gmail.com" ]
benevo.woo@gmail.com
7aabd932b28b9d3efb000344c121be9b6764e6cc
5b4525587e9a7c3a35a1db11af3eaad46ff36930
/xvii/1709.cpp
9cc15461dee21a1a573c99d30230fdeeeb0abd41
[]
no_license
fabres21s/UVa_cpp
6086f3c69243af4f738fe84e37c908a3418024e6
8b1205a48baae09d54fb0a3484dc5725fa35e8cd
refs/heads/master
2021-01-15T17:50:20.253357
2017-08-09T03:35:48
2017-08-09T03:35:48
99,761,656
0
0
null
null
null
null
UTF-8
C++
false
false
1,393
cpp
#include <stdlib.h> #include <iostream> #include <math.h> #include <set> #include <list> #include <sstream> #include <string> #include <algorithm> using namespace std; /* 1709 - Amalgamated Artichokes -Proceso matemático Dada una fórmula, encontrar su pico y la máxima diferencia con el punto más bajo */ int main() { int p = 100, a = 7, b = 615, c = 998, d = 801, n = 3; double difMayor = 0, price = 0; double precioMinimo; double precioMaximo; // Scanner input = new Scanner(System.in); while (cin >> p) { //cin >> p; cin >> a; cin >> b; cin >> c; cin >>d; cin >> n; precioMaximo = precioMinimo = p * (sin(a + b) + cos(c + d) + 2); for (int k = 2; k <= n; k++) { price = p * (sin(a * k + b) + cos(c * k + d) + 2); if (price < precioMinimo) { difMayor = max(difMayor, (precioMaximo - price)); precioMinimo = price; } else if (price >= precioMaximo) { precioMinimo = precioMaximo = price; } } printf("%.6f\n",difMayor); difMayor = 0; } return 0; }
[ "fabres21s@gmail.com" ]
fabres21s@gmail.com
faeab0346b1863fbd5b4c9ceff107ec63263dc74
9dfc68af6c2c010a31ff9d3418ccab2f221da448
/serialize/tile.cpp
783a98537a6df48c76e26b1837b3ed37c3cc32e9
[]
no_license
sthalik/floormat
0180219c1a73d89d891d00b0330e154125c109db
125cb3c0feb94e51b830957fb44ccc709b6afa61
refs/heads/master
2023-08-16T12:40:27.569715
2023-07-22T16:56:19
2023-07-22T19:17:41
460,774,854
4
0
null
null
null
null
UTF-8
C++
false
false
2,535
cpp
#include "serialize/tile.hpp" #include "src/tile.hpp" #include "src/global-coords.hpp" #include "serialize/tile-atlas.hpp" #include <tuple> #include <nlohmann/json.hpp> namespace floormat { NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tile_image_proto, atlas, variant) inline void to_json(nlohmann::json& j, const tile_image_ref& val) { j = tile_image_proto(val); } inline void from_json(const nlohmann::json& j, tile_image_ref& val) { val = tile_image_proto(j); } struct local_coords_ final { uint8_t x, y; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(local_coords_, x, y) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(chunk_coords, x, y) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(chunk_coords_, x, y, z) inline void to_json(nlohmann::json& j, global_coords coord) { j = std::tuple<chunk_coords, local_coords, int8_t>{ coord.chunk(), coord.local(), coord.z() }; } inline void from_json(const nlohmann::json& j, global_coords& coord) { std::tuple<chunk_coords, local_coords, int8_t> t = j; auto [ch, pos, z] = t; coord = { ch, pos, z }; } } // namespace floormat using namespace floormat; namespace nlohmann { void adl_serializer<tile_image_ref>::to_json(json& j, const tile_image_ref& val) { using nlohmann::to_json; if (val.atlas) to_json(j, val); else j = nullptr; } void adl_serializer<tile_image_ref>::from_json(const json& j, tile_image_ref& val) { using nlohmann::from_json; if (j.is_null()) val = {}; else from_json(j, val); } void adl_serializer<local_coords>::to_json(json& j, const local_coords& val) { using nlohmann::to_json; to_json(j, local_coords_{val.x, val.y}); } void adl_serializer<local_coords>::from_json(const json& j, local_coords& val) { using nlohmann::from_json; local_coords_ proxy{}; from_json(j, proxy); val = {proxy.x, proxy.y}; } void adl_serializer<chunk_coords>::to_json(json& j, const chunk_coords& val) { using nlohmann::to_json; to_json(j, val); } void adl_serializer<chunk_coords>::from_json(const json& j, chunk_coords& val) { using nlohmann::from_json; from_json(j, val); } void adl_serializer<chunk_coords_>::to_json(json& j, const chunk_coords_& val) { using nlohmann::to_json; to_json(j, val); } void adl_serializer<chunk_coords_>::from_json(const json& j, chunk_coords_& val) { using nlohmann::from_json; from_json(j, val); } void adl_serializer<global_coords>::to_json(json& j, const global_coords& val) { using nlohmann::to_json; to_json(j, val); } void adl_serializer<global_coords>::from_json(const json& j, global_coords& val) { using nlohmann::from_json; from_json(j, val); } } // namespace nlohmann
[ "sthalik@misaki.pl" ]
sthalik@misaki.pl
7f6a4b4593c421eb34bdd5c8f08aa3b77d90b89c
f3ed9c1cc881d01efdd8a760853b18a905b210c3
/Common/ihhprogressbar.h
b1ef5c9a731552ff212d00c9f5ca0d2c0701d4b0
[]
no_license
greenleaf01-dev/vessel_osg
ca7f8ffe6d9ac70103f2eb326d7830489b798496
df29d359fdd030420703801c70398cc6a3f1a6ac
refs/heads/master
2023-05-08T23:46:28.488344
2021-05-30T06:45:56
2021-05-30T06:45:56
334,600,806
1
1
null
null
null
null
GB18030
C++
false
false
1,275
h
#pragma once #include <QObject> class IHHProgressBar { public: virtual ~IHHProgressBar(){} virtual QObject *getObject() = 0; virtual void showProgressBar(QString sMessage, QString sTitle = "") = 0; //显示进度条 sTitle:授课对话框标题用 virtual void updateProgressBar(int value) = 0; //更新进度条信息 virtual void endProgressBar() = 0; //隐藏进度条 //以下函数是备授课切换时调用函数 virtual void setBusyStatus(bool bFlg) = 0; virtual bool getIsBusy() = 0; virtual int getCurProgressValue() = 0; //增加该接口的原因:备授课切换时,如果正好进度条不再发送新的value值,那么切换后,进度值会为0 virtual void setCurProgressValue(int nValue) = 0; virtual void setWidgetVisible(bool bVisible) = 0; //说明:进度条的标题文字是在showProgressBar()时传入,但是备授课切换时,存在接收不到showProgressBar的情况,因此将标题保存 virtual QString getMessage() = 0; virtual QString getTitle() = 0; virtual void setMessage(QString sMessage) = 0; virtual void setTitle(QString sTitle) = 0; }; Q_DECLARE_INTERFACE(IHHProgressBar, "com.hht.qtWhiteBoard.IHHProgressBar/1.0") Q_DECLARE_METATYPE(IHHProgressBar*)
[ "43130324@qq.com" ]
43130324@qq.com
a2e5499a4e1d77279ebd06941194a4468c609a08
06a8d53ba6fd785d3328389216f1cf11f17c491e
/AutoTest.h
385b5a55a502829a5df7046e38e7b389ca61a577
[]
no_license
jassuncao/eparts
19ba775b22ad5aad0eab4e847200fee78b8e7cff
35cf957ce6ca27404b7094d4e74b9a1498a9dd02
refs/heads/master
2021-01-19T08:10:29.105972
2013-02-25T19:17:58
2013-02-25T19:17:58
32,096,380
0
0
null
null
null
null
UTF-8
C++
false
false
1,453
h
#ifndef AUTOTEST_H #define AUTOTEST_H #include <QTest> #include <QList> #include <QString> #include <QSharedPointer> namespace AutoTest { typedef QList<QObject*> TestList; inline TestList& testList() { static TestList list; return list; } inline bool findObject(QObject* object) { TestList& list = testList(); if (list.contains(object)) { return true; } foreach (QObject* test, list) { if (test->objectName() == object->objectName()) { return true; } } return false; } inline void addTest(QObject* object) { TestList& list = testList(); if (!findObject(object)) { list.append(object); } } inline int run(int argc, char *argv[]) { int ret = 0; foreach (QObject* test, testList()) { ret += QTest::qExec(test, argc, argv); } return ret; } } template <class T> class Test { public: QSharedPointer<T> child; Test(const QString& name) : child(new T) { child->setObjectName(name); AutoTest::addTest(child.data()); } }; #define DECLARE_TEST(className) static Test<className> t(#className); #define TEST_MAIN \ int main(int argc, char *argv[]) \ { \ return AutoTest::run(argc, argv); \ } #endif // AUTOTEST_H
[ "joao@joaoassuncao.com" ]
joao@joaoassuncao.com
c85bd9693275f8f1b6719bb98dbc0f20bc0b6a07
9247cc17fbcf5ce96960e1b180d463339f45378d
/.SPOJ/MINCOST/MINCOST/MINCOST.cpp
6903ad8d69ad3ed3760c6130cc2978b8e2cfee41
[ "MIT" ]
permissive
sxweetlollipop2912/MaCode
dbc63da9400e729ce1fb8fdabe18508047d810ef
b8da22d6d9dc4bf82ca016896bf64497ac95febc
refs/heads/master
2022-07-28T03:42:14.703506
2021-12-16T15:44:04
2021-12-16T15:44:04
294,735,840
0
0
null
null
null
null
UTF-8
C++
false
false
2,183
cpp
// AC SPOJ #include <iostream> #include <algorithm> #include <vector> #include <deque> #define maxN 101 #define maxA 1000000001 #define maxD 99999999999 #define never 0 #define inq 1 #define outq 2 typedef int maxn, maxm; typedef long long maxa; maxn n, S, T, par[maxN]; maxm m; maxa capacity[maxN][maxN], cost[maxN][maxN], f[maxN][maxN], dist[maxN], lim, res; std::vector <maxn> ad[maxN]; void Prepare() { std::cin >> n >> m >> lim >> S >> T; --S, --T; for (maxm i = 0; i < m; i++) { maxn u, v; std::cin >> u >> v; --u, --v; std::cin >> cost[u][v] >> capacity[u][v]; capacity[v][u] = capacity[u][v], cost[v][u] = cost[u][v]; ad[u].push_back(v); ad[v].push_back(u); } for (maxn i = 0; i < n; i++) capacity[i][i] = maxA, cost[i][i] = 0; } bool Find_Path(const maxn S, const maxn T) { std::deque <maxn> dq; int color[maxN] = {}; std::fill(dist, dist + n, maxD); dq.push_back(S); dist[S] = 0, color[S] = inq; while (!dq.empty()) { maxn u = dq.front(); dq.pop_front(); color[u] = outq; for (maxn i = 0; i < ad[u].size(); i++) { maxn v = ad[u][i]; maxa duv = ((f[u][v] < 0) ? -1 : 1) * cost[u][v]; if (f[u][v] >= capacity[u][v] || dist[v] <= dist[u] + duv) continue; dist[v] = dist[u] + duv, par[v] = u; if (color[v] == never) dq.push_back(v); if (color[v] == outq) dq.push_front(v); color[v] = inq; } } return dist[T] != maxD; } void Update(const maxn S, const maxn T) { maxa delta = lim; maxn v = T; while (v != S) { delta = std::min(delta, f[par[v]][v] >= 0 ? (capacity[par[v]][v] - f[par[v]][v]) : -f[par[v]][v]); //*********** v = par[v]; } lim -= delta, res += delta * dist[T]; v = T; while (v != S) { f[par[v]][v] += delta; f[v][par[v]] -= delta; v = par[v]; } } bool Process() { res = 0; while (lim && Find_Path(S, T)) Update(S, T); if (lim != 0) return 0; std::cout << res << '\n'; for (maxn u = 0; u < n; u++) for (maxn v = 0; v < n; v++) if (f[u][v] > 0) std::cout << u + 1 << ' ' << v + 1 << ' ' << f[u][v] << '\n'; std::cout << "0 0 0"; return 1; } int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); Prepare(); if (!Process()) std::cout << "-1"; }
[ "thaolygoat@gmail.com" ]
thaolygoat@gmail.com
e97d461b4c40c602bb7940f8f6da99808d457be2
67b450e1e8cb0d5bcafd428a66416f0b13cc1e93
/topics wise codes/data structure/Binary search upper lower.cpp
df44b69298507ece2a292b4c5ecb11499b3694d1
[]
no_license
Musfiqshohan/Competitive-Programming
2b895ba4e78d14d029de8df2f052260bc4b36e9a
aa6865d5b2808222cf6dc62bbc740c0490a857ae
refs/heads/master
2021-05-14T06:54:36.633792
2018-04-07T15:59:48
2018-04-07T15:59:48
116,248,872
0
0
null
null
null
null
UTF-8
C++
false
false
693
cpp
#include<bits/stdc++.h> #define pb push_back #define ms(a,b) memset((a),(b),sizeof(a)) //#define clear(v,n) for(_typeof (n) i=0;i< (n) ; i++) { v.clear(); } #define ll long long #define pii pair<int,int> #define inf 100000000000 using namespace std; vector<int>v; int main() { int n,x,y; scanf("%d",&n); for(int i=0; i<n; i++) { scanf("%d",&x); v.push_back(x); } vector<int>::iterator it1,it2; scanf("%d",&x); it1= lower_bound(v.begin(), v.end(), x); cout<<it1-v.begin()<<endl; /// use -1 for strictly small // // scanf("%d",&y); // it2= upper_bound(v.begin(), v.end(), y); // cout<<it2-v.begin()-1<<endl; return 0; }
[ "musfuq14shohan@gmail.com" ]
musfuq14shohan@gmail.com
926942cab3c23a3bf1d9db618053665773764a5e
fe692881320e10c55962cebd165d478c1434c359
/make/npc/orenpc.cc
27ca80b1e75ecf12c63dcf32c09f13fc4ab6b9bc
[]
no_license
anho9339/chienquoc
130602c90c43053bbc99dfbfbc877de0b2d81dd7
cb5157d5eabcb4bb2ff71c292cfbdd5dc5fbb221
refs/heads/master
2021-07-04T07:51:49.408023
2021-02-01T15:15:58
2021-02-01T15:15:58
222,929,950
1
0
null
null
null
null
UTF-8
C++
false
false
818
cc
inherit RESOURCE; void create() { set_name("%s"); set("time", 1); set_reset_file("/sys/item/stuff"); // 函数:设置刷新文件 set_tool_type(16); // 函数:设置工具类型 set_pf_name("采矿"); // 函数:设置技能名称 set_stuff_number(%d); // 函数:设置资源编号 set_stuff_number2(212); // 函数:附加资源编号 set_tool_level(%d); // 函数:设置工具等级 set_reset_time(%d); // 函数:设置刷新时间 set_skill_exp(0); // 函数:设置采集经验奖励 set_skill_level(%d); // 函数:设置对应的技能等级 set_this_skill(670); // 函数:设置对应的技能类型 set_char_picid(%d); // 函数:设置人物造型 setup(); }
[ "hothienan1993@gmail.com" ]
hothienan1993@gmail.com
e228059b30d12d741c50c9ceab8f424fee5c9adb
6564a369804d8fcead88bc26da8eec0506649f1a
/Hw2/What2return.cpp
36b56b98029613ec35be313b01dcab2e834a63e7
[ "MIT" ]
permissive
zyzkevin/C-Programming-and-Algorithms
91c5afd0b8174ea06945861bf553057e8870de51
be9642b62a3285341990c25bdc3c124c4dd8c38b
refs/heads/master
2022-09-04T21:34:38.752742
2020-05-28T02:41:53
2020-05-28T02:41:53
264,387,753
0
0
null
null
null
null
UTF-8
C++
false
false
405
cpp
#include <iostream> using namespace std; class A { public: int val; A(int // 在此处补充你的代码 i): val (i){ }; A (){ val = 123; }; A & GetObj() { return * this; } }; int main() { int m,n; A a; cout << a.val << endl; while(cin >> m >> n) { a.GetObj() = m; cout << a.val << endl; a.GetObj() = A(n); cout << a.val<< endl; } return 0; }
[ "kevinzyz6@gmail.com" ]
kevinzyz6@gmail.com
b9b379f16a6215d19a515b2b91eaafb5214660bc
45c84e64a486a3c48bd41a78e28252acbc0cc1b0
/src/ash/wm/splitview/split_view_divider.cc
0d96a2f2f8f4ba7f5209c782149c6e502edd8f3d
[ "BSD-3-Clause", "MIT" ]
permissive
stanleywxc/chromium-noupdator
47f9cccc6256b1e5b0cb22c598b7a86f5453eb42
637f32e9bf9079f31430c9aa9c64a75247993a71
refs/heads/master
2022-12-03T22:00:20.940455
2019-10-04T16:29:31
2019-10-04T16:29:31
212,851,250
1
2
MIT
2022-11-17T09:51:04
2019-10-04T15:49:33
null
UTF-8
C++
false
false
17,732
cc
// Copyright 2017 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 "ash/wm/splitview/split_view_divider.h" #include <memory> #include "ash/display/screen_orientation_controller.h" #include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/window_properties.h" #include "ash/screen_util.h" #include "ash/shell.h" #include "ash/wm/desks/desks_util.h" #include "ash/wm/splitview/split_view_constants.h" #include "ash/wm/splitview/split_view_controller.h" #include "ash/wm/splitview/split_view_divider_handler_view.h" #include "ash/wm/splitview/split_view_utils.h" #include "ash/wm/window_util.h" #include "base/sequenced_task_runner.h" #include "base/stl_util.h" #include "ui/aura/scoped_window_targeter.h" #include "ui/aura/window_targeter.h" #include "ui/compositor/layer.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/views/view.h" #include "ui/views/view_targeter_delegate.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" #include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/core/transient_window_manager.h" #include "ui/wm/core/window_util.h" #include "ui/wm/public/activation_client.h" namespace ash { namespace { // The distance to the divider edge in which a touch gesture will be considered // as a valid event on the divider. constexpr int kDividerEdgeInsetForTouch = 8; // The window targeter that is installed on the always on top container window // when the split view mode is active. class AlwaysOnTopWindowTargeter : public aura::WindowTargeter { public: explicit AlwaysOnTopWindowTargeter(aura::Window* divider_window) : divider_window_(divider_window) {} ~AlwaysOnTopWindowTargeter() override = default; private: bool GetHitTestRects(aura::Window* target, gfx::Rect* hit_test_rect_mouse, gfx::Rect* hit_test_rect_touch) const override { if (target == divider_window_) { *hit_test_rect_mouse = *hit_test_rect_touch = gfx::Rect(target->bounds()); hit_test_rect_touch->Inset( gfx::Insets(-kDividerEdgeInsetForTouch, -kDividerEdgeInsetForTouch)); return true; } return aura::WindowTargeter::GetHitTestRects(target, hit_test_rect_mouse, hit_test_rect_touch); } aura::Window* divider_window_; DISALLOW_COPY_AND_ASSIGN(AlwaysOnTopWindowTargeter); }; // The divider view class. Passes the mouse/gesture events to the controller. // Has two child views, one for the divider and one for its white handler. The // bounds and transforms of these two child views can be affected by the // spawning animation and by dragging, but regardless, the controller receives // mouse/gesture events in the bounds of the |DividerView| object itself. class DividerView : public views::View, public views::ViewTargeterDelegate { public: explicit DividerView(SplitViewDivider* divider) : controller_(Shell::Get()->split_view_controller()), divider_(divider) { divider_view_ = new views::View(); divider_view_->SetPaintToLayer(ui::LAYER_SOLID_COLOR); divider_view_->layer()->SetColor(kSplitviewDividerColor); divider_handler_view_ = new SplitViewDividerHandlerView(); AddChildView(divider_view_); AddChildView(divider_handler_view_); SetEventTargeter( std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); } ~DividerView() override = default; void DoSpawningAnimation(int spawn_position) { const gfx::Rect bounds = GetBoundsInScreen(); int divider_signed_offset; // To animate the divider scaling up from nothing, animate its bounds rather // than its transform, mostly because a transform that scales by zero would // be singular. For that bounds animation, express |spawn_position| in local // coordinates by subtracting a coordinate of the origin. Compute // |divider_signed_offset| as described in the comment for // |SplitViewDividerHandlerView::DoSpawningAnimation|. if (IsCurrentScreenOrientationLandscape()) { divider_view_->SetBounds(spawn_position - bounds.x(), 0, 0, bounds.height()); divider_signed_offset = spawn_position - bounds.CenterPoint().x(); } else { divider_view_->SetBounds(0, spawn_position - bounds.y(), bounds.width(), 0); divider_signed_offset = spawn_position - bounds.CenterPoint().y(); } ui::LayerAnimator* divider_animator = divider_view_->layer()->GetAnimator(); ui::ScopedLayerAnimationSettings settings(divider_animator); settings.SetTransitionDuration(kSplitviewDividerSpawnDuration); settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); divider_animator->SchedulePauseForProperties( kSplitviewDividerSpawnDelay, ui::LayerAnimationElement::BOUNDS); divider_view_->SetBounds(0, 0, bounds.width(), bounds.height()); divider_handler_view_->DoSpawningAnimation(divider_signed_offset); } // views::View: void Layout() override { divider_view_->SetBoundsRect(GetLocalBounds()); divider_handler_view_->Refresh(); } bool OnMousePressed(const ui::MouseEvent& event) override { gfx::Point location(event.location()); views::View::ConvertPointToScreen(this, &location); controller_->StartResize(location); OnResizeStatusChanged(); return true; } bool OnMouseDragged(const ui::MouseEvent& event) override { gfx::Point location(event.location()); views::View::ConvertPointToScreen(this, &location); controller_->Resize(location); return true; } void OnMouseReleased(const ui::MouseEvent& event) override { gfx::Point location(event.location()); views::View::ConvertPointToScreen(this, &location); controller_->EndResize(location); OnResizeStatusChanged(); if (event.GetClickCount() == 2) controller_->SwapWindows(); } void OnGestureEvent(ui::GestureEvent* event) override { gfx::Point location(event->location()); views::View::ConvertPointToScreen(this, &location); switch (event->type()) { case ui::ET_GESTURE_TAP: if (event->details().tap_count() == 2) controller_->SwapWindows(); break; case ui::ET_GESTURE_TAP_DOWN: case ui::ET_GESTURE_SCROLL_BEGIN: controller_->StartResize(location); OnResizeStatusChanged(); break; case ui::ET_GESTURE_SCROLL_UPDATE: controller_->Resize(location); break; case ui::ET_GESTURE_END: controller_->EndResize(location); OnResizeStatusChanged(); break; default: break; } event->SetHandled(); } // views::ViewTargeterDelegate: bool DoesIntersectRect(const views::View* target, const gfx::Rect& rect) const override { DCHECK_EQ(target, this); return true; } private: void OnResizeStatusChanged() { // It's possible that when this function is called, split view mode has // been ended, and the divider widget is to be deleted soon. In this case // no need to update the divider layout and do the animation. if (!controller_->InSplitViewMode()) return; // If |divider_view_|'s bounds are animating, it is for the divider spawning // animation. Stop that before animating |divider_view_|'s transform. ui::LayerAnimator* divider_animator = divider_view_->layer()->GetAnimator(); divider_animator->StopAnimatingProperty(ui::LayerAnimationElement::BOUNDS); // Do the divider enlarge/shrink animation when starting/ending dragging. divider_view_->SetBoundsRect(GetLocalBounds()); const gfx::Rect old_bounds = divider_->GetDividerBoundsInScreen(/*is_dragging=*/false); const gfx::Rect new_bounds = divider_->GetDividerBoundsInScreen(controller_->is_resizing()); gfx::Transform transform; transform.Translate(new_bounds.x() - old_bounds.x(), new_bounds.y() - old_bounds.y()); transform.Scale( static_cast<float>(new_bounds.width()) / old_bounds.width(), static_cast<float>(new_bounds.height()) / old_bounds.height()); ui::ScopedLayerAnimationSettings settings(divider_animator); settings.SetTransitionDuration( kSplitviewDividerSelectionStatusChangeDuration); settings.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); settings.SetPreemptionStrategy( ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); divider_view_->SetTransform(transform); divider_handler_view_->Refresh(); } views::View* divider_view_ = nullptr; SplitViewDividerHandlerView* divider_handler_view_ = nullptr; SplitViewController* controller_; SplitViewDivider* divider_; DISALLOW_COPY_AND_ASSIGN(DividerView); }; } // namespace SplitViewDivider::SplitViewDivider(SplitViewController* controller, aura::Window* root_window) : controller_(controller) { Shell::Get()->activation_client()->AddObserver(this); CreateDividerWidget(root_window); aura::Window* always_on_top_container = Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer); split_view_window_targeter_ = std::make_unique<aura::ScopedWindowTargeter>( always_on_top_container, std::make_unique<AlwaysOnTopWindowTargeter>( divider_widget_->GetNativeWindow())); } SplitViewDivider::~SplitViewDivider() { Shell::Get()->activation_client()->RemoveObserver(this); divider_widget_->Close(); split_view_window_targeter_.reset(); for (auto* window : observed_windows_) { window->RemoveObserver(this); ::wm::TransientWindowManager::GetOrCreate(window)->RemoveObserver(this); } observed_windows_.clear(); } // static gfx::Rect SplitViewDivider::GetDividerBoundsInScreen( const gfx::Rect& work_area_bounds_in_screen, bool landscape, int divider_position, bool is_dragging) { const int dragging_diff = (kSplitviewDividerEnlargedShortSideLength - kSplitviewDividerShortSideLength) / 2; if (landscape) { return is_dragging ? gfx::Rect(work_area_bounds_in_screen.x() + divider_position - dragging_diff, work_area_bounds_in_screen.y(), kSplitviewDividerEnlargedShortSideLength, work_area_bounds_in_screen.height()) : gfx::Rect(work_area_bounds_in_screen.x() + divider_position, work_area_bounds_in_screen.y(), kSplitviewDividerShortSideLength, work_area_bounds_in_screen.height()); } else { return is_dragging ? gfx::Rect(work_area_bounds_in_screen.x(), work_area_bounds_in_screen.y() + divider_position - dragging_diff, work_area_bounds_in_screen.width(), kSplitviewDividerEnlargedShortSideLength) : gfx::Rect(work_area_bounds_in_screen.x(), work_area_bounds_in_screen.y() + divider_position, work_area_bounds_in_screen.width(), kSplitviewDividerShortSideLength); } } void SplitViewDivider::DoSpawningAnimation(int spawning_position) { static_cast<DividerView*>(divider_widget_->GetContentsView()) ->DoSpawningAnimation(spawning_position); } void SplitViewDivider::UpdateDividerBounds() { divider_widget_->SetBounds(GetDividerBoundsInScreen(/*is_dragging=*/false)); } gfx::Rect SplitViewDivider::GetDividerBoundsInScreen(bool is_dragging) { const gfx::Rect work_area_bounds_in_screen = screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer( Shell::GetPrimaryRootWindow()->GetChildById( desks_util::GetActiveDeskContainerId())); const int divider_position = controller_->divider_position(); const bool landscape = IsCurrentScreenOrientationLandscape(); return GetDividerBoundsInScreen(work_area_bounds_in_screen, landscape, divider_position, is_dragging); } void SplitViewDivider::SetAlwaysOnTop(bool on_top) { if (on_top) { divider_widget_->SetZOrderLevel(ui::ZOrderLevel::kFloatingUIElement); // Special handling when put divider into always_on_top container. We want // to put it at the bottom so it won't block other always_on_top windows. aura::Window* always_on_top_container = Shell::GetContainer(divider_widget_->GetNativeWindow()->GetRootWindow(), kShellWindowId_AlwaysOnTopContainer); always_on_top_container->StackChildAtBottom( divider_widget_->GetNativeWindow()); } else { divider_widget_->SetZOrderLevel(ui::ZOrderLevel::kNormal); } } void SplitViewDivider::AddObservedWindow(aura::Window* window) { if (!base::Contains(observed_windows_, window)) { window->AddObserver(this); ::wm::TransientWindowManager::GetOrCreate(window)->AddObserver(this); observed_windows_.push_back(window); } } void SplitViewDivider::RemoveObservedWindow(aura::Window* window) { auto iter = std::find(observed_windows_.begin(), observed_windows_.end(), window); if (iter != observed_windows_.end()) { window->RemoveObserver(this); ::wm::TransientWindowManager::GetOrCreate(window)->RemoveObserver(this); observed_windows_.erase(iter); } } void SplitViewDivider::OnWindowDragStarted(aura::Window* dragged_window) { is_dragging_window_ = true; SetAlwaysOnTop(false); // Make sure |divider_widget_| is placed below the dragged window. dragged_window->parent()->StackChildBelow(divider_widget_->GetNativeWindow(), dragged_window); } void SplitViewDivider::OnWindowDragEnded() { is_dragging_window_ = false; SetAlwaysOnTop(true); } void SplitViewDivider::OnWindowDestroying(aura::Window* window) { RemoveObservedWindow(window); } void SplitViewDivider::OnWindowBoundsChanged(aura::Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds, ui::PropertyChangeReason reason) { // We only care about the bounds change of windows in // |transient_windows_observer_|. if (!transient_windows_observer_.IsObserving(window)) return; // |window|'s transient parent must be one of the windows in // |observed_windows_|. aura::Window* transient_parent = nullptr; for (auto* observed_window : observed_windows_) { if (::wm::HasTransientAncestor(window, observed_window)) { transient_parent = observed_window; break; } } DCHECK(transient_parent); gfx::Rect transient_bounds = window->GetBoundsInScreen(); transient_bounds.AdjustToFit(transient_parent->GetBoundsInScreen()); window->SetBoundsInScreen( transient_bounds, display::Screen::GetScreen()->GetDisplayNearestWindow(window)); } void SplitViewDivider::OnWindowActivated(ActivationReason reason, aura::Window* gained_active, aura::Window* lost_active) { if (!is_dragging_window_ && (!gained_active || base::Contains(observed_windows_, gained_active))) { SetAlwaysOnTop(true); } else { // If |gained_active| is not one of the observed windows, or there is one // window that is currently being dragged, |divider_widget_| should not // be placed on top. SetAlwaysOnTop(false); } } void SplitViewDivider::OnTransientChildAdded(aura::Window* window, aura::Window* transient) { // For now, we only care about dialog bubbles type transient child. We may // observe other types transient child window as well if need arises in the // future. views::Widget* widget = views::Widget::GetWidgetForNativeWindow(transient); if (!widget || !widget->widget_delegate()->AsBubbleDialogDelegate()) return; // At this moment, the transient window may not have the valid bounds yet. // Start observe the transient window. transient_windows_observer_.Add(transient); } void SplitViewDivider::OnTransientChildRemoved(aura::Window* window, aura::Window* transient) { if (transient_windows_observer_.IsObserving(transient)) transient_windows_observer_.Remove(transient); } void SplitViewDivider::CreateDividerWidget(aura::Window* root_window) { DCHECK(!divider_widget_); // Native widget owns this widget. divider_widget_ = new views::Widget; views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; params.parent = Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer); params.init_properties_container.SetProperty(kHideInDeskMiniViewKey, true); DividerView* divider_view = new DividerView(this); divider_widget_->set_focus_on_creation(false); divider_widget_->Init(std::move(params)); divider_widget_->SetVisibilityAnimationTransition( views::Widget::ANIMATE_NONE); divider_widget_->SetContentsView(divider_view); divider_widget_->SetBounds(GetDividerBoundsInScreen(false /* is_dragging */)); divider_widget_->Show(); } } // namespace ash
[ "stanley@moon.lan" ]
stanley@moon.lan
75c81286b8d6290fb7c9489587d8a280611ab9ca
6f87cf355458fcc068aff6e521cdc0aa0ab77131
/stone3.h
b88a0025236a2f67e39e41b92a449f016a429367
[]
no_license
linpaul2004/pd2-project3
a6d9e7f961ff9056c8023250927a340632874596
491269034e0068615748800f5b83de79ff52ca97
refs/heads/master
2021-03-22T04:26:47.687166
2015-06-28T14:42:29
2015-06-28T14:42:29
37,527,720
0
0
null
null
null
null
UTF-8
C++
false
false
310
h
#ifndef STONE3_H #define STONE3_H #include "stone1.h" class Stone3: public Stone1 { public: explicit Stone3(QWidget *parent = 0, int loc=0); virtual ~Stone3(); virtual void loadpic(); virtual int type(); virtual bool isChecked(); virtual void setChecked(bool); }; #endif // STONE3_H
[ "linpaul2004@gmail.com" ]
linpaul2004@gmail.com
2878e15efe502ba8a092361c1fbe9019f7766e53
8a50a033d7826fa2d768f6434e5bacfcf907bd5b
/QTR_raw_example/QTR_raw_example.ino
65986f60def380817e2ea6387dd9ec73e3532363
[]
no_license
garmstrong456/Cornell-Robotics-2019
91bba7b4931b7ec951310ef4d65a53a8216ea79e
f781bcedb7b06cbdcfd3057f57d1ed3ac30baa54
refs/heads/master
2020-06-13T06:48:02.096247
2019-07-11T15:03:40
2019-07-11T15:03:40
194,576,911
6
0
null
null
null
null
UTF-8
C++
false
false
919
ino
#include <M5Stack.h> #include "FastLED.h" #include <QTRSensors.h> #define Neopixel_PIN 1 #define NUM_LEDS 7 CRGB leds[NUM_LEDS]; QTRSensors qtr; const uint8_t SensorCount = 3; uint16_t sensorValues[SensorCount]; void setup() { M5.begin(); M5.Lcd.setTextColor(CYAN); M5.Lcd.setTextSize(2); M5.Lcd.setCursor(40,0); M5.Lcd.println("Raw Line Sensor Data"); M5.Lcd.setTextColor(WHITE, BLACK); M5.Lcd.setTextSize(1); FastLED.addLeds<WS2811,Neopixel_PIN,GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); fill_solid(leds, NUM_LEDS, CRGB::Green); FastLED.show(); qtr.setTypeRC(); qtr.setSensorPins((const uint8_t[]){2, 5, 15}, SensorCount); delay(500); } void loop() { qtr.read(sensorValues); M5.Lcd.setCursor(0,25); M5.Lcd.println(" 1 2 3"); M5.Lcd.printf( "%4d %4d %4d", sensorValues[0], sensorValues[1], sensorValues[2]); FastLED.clear(); FastLED.show(); delay(250); }
[ "garmstrong456@gmail.com" ]
garmstrong456@gmail.com
974c422bf6fc57a6d250a4157395a8eca6691f11
1d0d89062a9dae29b533bbbc74437424e398b028
/1546.cpp
97f0ad3acdf1495d55bbd900a854e0d999104ef2
[]
no_license
julioCoutinho/URI
c2e0faa9631544a54646f9f22bf912e1c384df40
87ba271ef66fdefa7a13916abe32c693ce5a2ea8
refs/heads/master
2023-03-18T17:26:57.850169
2021-03-05T19:45:08
2021-03-05T19:45:08
344,890,618
0
0
null
null
null
null
UTF-8
C++
false
false
375
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n,k,x; cin >> n; while(n-->0) { cin >> k; while(k-->0) { cin >> x; if(x == 1) cout << "Rolien" << endl; else if(x == 2) cout << "Naej" << endl; else if(x == 3) cout << "Elehcim" << endl; else cout << "Odranoel" << endl; } } return 0; }
[ "juliocezar0002@gmail.com" ]
juliocezar0002@gmail.com
73420ca07cff76f56dca33c3e02201121e4b566e
26b90f03e3f280a69198212c156ca715d31fa5a7
/src/Level1.cpp
8a415f4505449c2c3d713459b687ee4594804be7
[]
no_license
Athos06/SkyPlatforms
7f8f234ac7a0ebaf51b399a04897d8ad90dfa9bd
d1b79c9a777f378f172ec779fbed4f01eab3bc3c
refs/heads/master
2020-03-16T20:01:59.355471
2018-05-13T09:53:27
2018-05-13T09:53:27
132,943,404
0
0
null
null
null
null
UTF-8
C++
false
false
7,172
cpp
#include "Level1.h" #include "LevelsManager.h" #include "AdvancedOgreFramework.h" #include "AppStateManager.h" #include "DotSceneLoader.h" #include "BtOgrePG.h" #include "BtOgreGP.h" #include "GameManager.h" #include "SavegameLoader.h" #include "CameraController.h" #include "Collectible.h" #include "Player.h" #include "Animations.h" #include "Trap.h" #include "MovingPlatform.h" #include "Effect.h" #include "AudioManager.h" #include "ParticlesEffect.h" #include "GUIManager.h" #include "GUIStateManager.h" #include "LoadingScreen.h" #include "Fader.h" #include "Portal.h" #include "HUD.h" #include "Constants.h" Level1::Level1(){ m_pCamera = 0; m_pSceneMgr = 0; m_pPhysicsMgr = 0; m_pFader = 0; m_bm_bLevelClear = false; m_pLevelProperties = new Level1Properties(); } Level1::~Level1(){ } void Level1::reset(){ //cuando morimos y seleccionamos continuar al resetear el nivel //dependiendo de si el portal esta abierto reproducimos un track u otro //u otro if(m_pLevelProperties->checkWinningCondition()) AudioManager::getSingletonPtr()->playMainTrack("Level1return.ogg"); else AudioManager::getSingletonPtr()->playMainTrack("Level1.ogg"); } void Level1::init(){ m_pLevelProperties->reset(); m_bm_bLevelClear = false; OgreFramework::getSingletonPtr()->m_pLog->logMessage("Creando Level1..."); //precargar de tracks AudioManager::getSingletonPtr()->preLoadTrack("Level1.ogg"); AudioManager::getSingletonPtr()->preLoadTrack("Level1return.ogg"); GUIManager::getSingletonPtr()->m_pLoadingScreen->setCompletePercent(25); OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame(); //reproducir track de intro AudioManager::getSingletonPtr()->playMainTrack("IntroLevel.ogg"); //pantalla de carga GUIManager::getSingletonPtr()->m_pLoadingScreen->setCompletePercent(50); OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame(); m_pSceneMgr = OgreFramework::getSingletonPtr()-> m_pRoot->createSceneManager(Ogre::ST_GENERIC, "gameSceneMgr"); OgreFramework::getSingletonPtr()->m_pActiveSceneMgr = m_pSceneMgr; m_pGameMgr = new GameManager(m_pSceneMgr); m_pFader = new Fader("Overlays/FadeInOut", "Materials/OverlayMaterial"); //iniciar la simulacion de fisicas m_pPhysicsMgr = PhysicsManager::getSingletonPtr(); m_pPhysicsMgr->initPhysics(m_pSceneMgr); /* BtOgre::DebugDrawer* mDebugDrawer = new BtOgre::DebugDrawer(m_pSceneMgr->getRootSceneNode(), PhysicsManager::getSingletonPtr()->getDynamicsWorld()); PhysicsManager::getSingletonPtr()->getDynamicsWorld()->setDebugDrawer(mDebugDrawer); */ createScene(); //pantalla de carga GUIManager::getSingletonPtr()->m_pLoadingScreen->setCompletePercent(70); OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame(); m_pGameMgr->initGameManager(); //pantalla de carga GUIManager::getSingletonPtr()->m_pLoadingScreen->setCompletePercent(100); OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame(); GUIManager::getSingletonPtr()->m_pGUIStateManager->popAllAndPushGUIState (GUIManager::getSingletonPtr()->m_pGUIStateManager->findByName("GUIGame") ); //seleccionamos la interfaz de la intro del nivel1 HUD::getSingletonPtr()->selectIntro(INTRO_LEVEL1); OgreFramework::getSingletonPtr()->m_pAppStateManager-> pushAppState(OgreFramework::getSingletonPtr()-> m_pAppStateManager->findByName("LevelIntroState") ); } void Level1::start(){ AudioManager::getSingletonPtr()->playMainTrack("Level1.ogg"); HUD::getSingletonPtr()->fadeIn(); Fader::getSingletonPtr()->startFadeIn(2); m_pGameMgr->startGame(); } void Level1::exit(){ AudioManager::getSingletonPtr()->unloadMainTrack(); //si hemos pasado el nivel seleccionamos el siguiente nivel //para cuando seleccionamos continuar al terminar el nivel if(m_bm_bLevelClear){ LevelsManager::getSingletonPtr()->selectLevel( LevelsManager::getSingletonPtr()->findByName("Level2")); } //destruir y resetear todo lo usado en el nivel if(m_pGameMgr){ m_pGameMgr->destroy(); delete m_pGameMgr; m_pGameMgr = 0; } //el fader se elimna junto con el resto de effectos //en destroyAllEffects() m_pFader = 0; if(m_pPhysicsMgr) m_pPhysicsMgr->destroyPhysics(); m_pPhysicsMgr = 0; m_pLevelProperties->reset(); HUD::getSingletonPtr()->reset(); Animations::destroyAllAnimations(); Trap::destroyAllTraps(); MovingPlatform::destroyAllPlatforms(); Effect::destroyAllEffects(); ParticlesEffect::destroyAllParticles(); Collectible::destroyAll(); //eliminar el scene manager lo ultimo porque si no elimina todos los nodos //y da error al intentar eliminar los nodos en los destructores de los otros objetos m_pSceneMgr->destroyCamera(m_pCamera); if(m_pSceneMgr){ OgreFramework::getSingletonPtr()->m_pRoot->destroySceneManager(m_pSceneMgr); OgreFramework::getSingletonPtr()->m_pActiveSceneMgr = 0; } } void Level1::createScene(){ //hay que seleccionar el modo de las sombras antes de cargar la escena //porque utilizo logica estatica que de otro modo no tendria sombras m_pSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE); DotSceneLoader loader; loader.parseDotScene("Level1.scene", "General", m_pSceneMgr, m_pPhysicsMgr); //la camara se la pasamos en el .scene, aqui la recuperamos por su nombre //Obviamente es indispensable nombrarla con ese nombre especifico en el .scene m_pCamera = m_pSceneMgr->getCamera("Camera#0"); m_pCamera->setAspectRatio(Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualWidth()) / Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualHeight())); OgreFramework::getSingletonPtr()->m_pViewport->setCamera(m_pCamera); //precarga de efecto de particulas new ParticlesEffect(0, "PickUpStone", Ogre::Vector3::ZERO); } void Level1::update(double deltaTime){ //if(m_pGameMgr) m_pGameMgr->update(deltaTime); Animations::updateEach(deltaTime); Trap::updateEach(deltaTime); MovingPlatform::updateEach(deltaTime); ParticlesEffect::updateEach(deltaTime); } //se llama al superar el nivel void Level1::passLevel(){ m_bm_bLevelClear = true; //se desbloquea el siguiente nivel y se guarda //como desbloqueado en el savegame GameConfig::getSingletonPtr()->levelsLock[1] = true; SavegameLoader loader; loader.write(); } /////////////////////////////////////////////////////// Level1Properties::Level1Properties(){ m_bWin = false; m_counterCondition = 0; m_conditionValue = 4; } bool Level1Properties::checkWinningCondition(){ if(m_counterCondition >= m_conditionValue){ m_bWin = true; //si el portal no esta activado lo activamos //si esta activado no hacemos nada if(!(GameManager::getSingletonPtr() ->m_pPortal->isActive()) ){ GameManager::getSingletonPtr() ->m_pPortal->setActive(true); AudioManager::getSingletonPtr()->playFX("PortalActivated", 0, SECONDARYFX_CHANNEL); AudioManager::getSingletonPtr()->fadeInTrack("Level1return.ogg", 1); HUD::getSingletonPtr()->showOpenMsg(true); //aumento la velocidad de todas las animaciones un 10% Animations::ChangeSpeedAll(0.15); } return true; } return false; } void Level1Properties::reset(){ m_bWin = false; m_counterCondition = 0; m_conditionValue = 4; }
[ "jorge.rosique6@gmail.com" ]
jorge.rosique6@gmail.com
d874d544261af4ee45a55c8f86fe6ac77c2635bd
e763b855be527d69fb2e824dfb693d09e59cdacb
/aws-cpp-sdk-logs/include/aws/logs/model/RejectedLogEventsInfo.h
7bec5f32ab796e8e62075782905f9952bf255cf4
[ "MIT", "Apache-2.0", "JSON" ]
permissive
34234344543255455465/aws-sdk-cpp
47de2d7bde504273a43c99188b544e497f743850
1d04ff6389a0ca24361523c58671ad0b2cde56f5
refs/heads/master
2023-06-10T16:15:54.618966
2018-05-07T23:32:08
2018-05-07T23:32:08
132,632,360
1
0
Apache-2.0
2023-06-01T23:20:47
2018-05-08T15:56:35
C++
UTF-8
C++
false
false
3,229
h
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ #pragma once #include <aws/logs/CloudWatchLogs_EXPORTS.h> namespace Aws { namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace CloudWatchLogs { namespace Model { /** * <p>Represents the rejected events.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/logs-2014-03-28/RejectedLogEventsInfo">AWS * API Reference</a></p> */ class AWS_CLOUDWATCHLOGS_API RejectedLogEventsInfo { public: RejectedLogEventsInfo(); RejectedLogEventsInfo(const Aws::Utils::Json::JsonValue& jsonValue); RejectedLogEventsInfo& operator=(const Aws::Utils::Json::JsonValue& jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The log events that are too new.</p> */ inline int GetTooNewLogEventStartIndex() const{ return m_tooNewLogEventStartIndex; } /** * <p>The log events that are too new.</p> */ inline void SetTooNewLogEventStartIndex(int value) { m_tooNewLogEventStartIndexHasBeenSet = true; m_tooNewLogEventStartIndex = value; } /** * <p>The log events that are too new.</p> */ inline RejectedLogEventsInfo& WithTooNewLogEventStartIndex(int value) { SetTooNewLogEventStartIndex(value); return *this;} /** * <p>The log events that are too old.</p> */ inline int GetTooOldLogEventEndIndex() const{ return m_tooOldLogEventEndIndex; } /** * <p>The log events that are too old.</p> */ inline void SetTooOldLogEventEndIndex(int value) { m_tooOldLogEventEndIndexHasBeenSet = true; m_tooOldLogEventEndIndex = value; } /** * <p>The log events that are too old.</p> */ inline RejectedLogEventsInfo& WithTooOldLogEventEndIndex(int value) { SetTooOldLogEventEndIndex(value); return *this;} /** * <p>The expired log events.</p> */ inline int GetExpiredLogEventEndIndex() const{ return m_expiredLogEventEndIndex; } /** * <p>The expired log events.</p> */ inline void SetExpiredLogEventEndIndex(int value) { m_expiredLogEventEndIndexHasBeenSet = true; m_expiredLogEventEndIndex = value; } /** * <p>The expired log events.</p> */ inline RejectedLogEventsInfo& WithExpiredLogEventEndIndex(int value) { SetExpiredLogEventEndIndex(value); return *this;} private: int m_tooNewLogEventStartIndex; bool m_tooNewLogEventStartIndexHasBeenSet; int m_tooOldLogEventEndIndex; bool m_tooOldLogEventEndIndexHasBeenSet; int m_expiredLogEventEndIndex; bool m_expiredLogEventEndIndexHasBeenSet; }; } // namespace Model } // namespace CloudWatchLogs } // namespace Aws
[ "henso@amazon.com" ]
henso@amazon.com
73d9f0a7b1b51d97584ea64164a8c049a6afaad5
f8aeb4dc615cc186671ee48fa5c8102f32ec6016
/abc/abc081b.cpp
f883e982d794fb72c757dba68f194e6c9e30661a
[]
no_license
UveRedShun/RasenBook
98e18266c03cade0066da88ab3de0f351219337c
51e636c9e04496adb9984bacea47b2024ebd82aa
refs/heads/main
2023-01-14T13:02:08.387618
2020-11-25T14:06:14
2020-11-25T14:06:14
309,426,836
0
0
null
null
null
null
UTF-8
C++
false
false
741
cpp
#include <bits/stdc++.h> using namespace std; int main(){ cout << "正の整数の個数を入力してください" << endl; int N; cin >> N; int i, num; int minCount = 0; //割り切れる最小値 int tmp = 0; //計算途中の仮置き変数 int oddCount = 0; for(i = 0; i < N; i++){ cin >> num; if(num % 2 != 0){ oddCount++; } while(num % 2 == 0){ num /= 2; tmp++; } if(minCount!=0){ minCount = (minCount < tmp) ? minCount : tmp; }else{ minCount = tmp; } tmp = 0; } if(oddCount!=0){ cout << 0 << endl; }else{ cout << minCount << endl; } }
[ "s.ubel.w.w.09@gmail.com" ]
s.ubel.w.w.09@gmail.com
9f91b552f0931df8268f487698932a4c02a58cd8
024a5130b4decf460ad4e2e81dfbce4a8d0d1fe4
/src/StateFirst.hpp
922cee2b7faab8432e5f68c482950d9e50483111
[ "MIT" ]
permissive
matheuscscp/19-hertz
b6bde6c32c32c1e6679565f20ef10b7b27fb1c46
ad4b5fa85e0b6e0b67d0ae7fca04b11465cd7cc7
refs/heads/master
2020-05-27T02:26:18.776550
2017-02-20T03:57:48
2017-02-20T03:57:48
82,514,228
0
0
null
null
null
null
UTF-8
C++
false
false
788
hpp
#ifndef STATEFIRST_HPP #define STATEFIRST_HPP #include <list> #include "State.hpp" #include "Player.hpp" #include "Map.hpp" #include "Ghost.hpp" #include "Animation.hpp" #include "Timer.hpp" #include "Stopwatch.hpp" #include "Audio.hpp" class StateFirst : public State { GAMESTATE private: Sprite* bg; Sprite* spr_ghost; Sprite* spr_ghost_border; Sprite* spr_player_vision; Sprite* spr_player; Animation* anim_player; Animation* anim_player_heart; Player* player; Map* map; std::list<Ghost*> ghosts; Timer timer; Stopwatch stopwatch; Audio* heart_beats[4]; static int level; public: StateFirst(ArgsBase* args); ~StateFirst(); void update(); void render(); private: void renderBorders(); void handleTimerDone(const observer::Event& event, bool& stop); }; #endif
[ "matheuscscp@gmail.com" ]
matheuscscp@gmail.com
270eb2bb57ce19f47b75e1e78bcb6489af4dbb19
8b2671f1376f2b1340d974ebe16822608bb7fa60
/sortmerge.cpp
9694a3d3c8f61722a7efd2bebaed0642eed1b38d
[]
no_license
Omgupta0312/practice-work
53552906c99e122379b34a2d7ab05e0a809b4077
358e3c3271c65e6ffd50666568a34f23aa6b5690
refs/heads/main
2023-07-12T11:23:17.956016
2021-09-05T05:53:14
2021-09-05T05:53:14
364,931,993
0
0
null
null
null
null
UTF-8
C++
false
false
803
cpp
#include <bits/stdc++.h> using namespace std; void mergesort(int a[], int b[], int n, int m) { int i = 0, j = 0; while (i < n && j < m) { if (a[i] <= b[j]) { cout << a[i] << " "; i++; } else { cout << b[j] << " "; j++; } } while (i < n) { cout << a[i] << " "; i++; } while (j < m) { cout << b[j] << " "; j++; } } int main() { int a[] = {1, 23, 4, 45, 334, 56, 65}; int n = sizeof(a) / sizeof(a[0]); sort(a, a + n); int b[] = {26, 34, 56, 44, 37, 8, 6, 8, 79, 32}; int m = sizeof(b) / sizeof(b[0]); sort(b, b + m); mergesort(a, b, n, m); return 0; }
[ "noreply@github.com" ]
noreply@github.com
8356caa1457536bd23e6c62c60d95d4aba08c7f2
03a44baca9e6ed95705432d96ba059f16e62a662
/OtherTrains/2020ccpc_wannafly/day3/4.cpp
151417292b545b4ec6305049bb069a48beae216d
[]
no_license
ytz12345/2019_ICPC_Trainings
5c6e113afb8e910dd91c8340ff43af00a701c7c7
cf0ce781675a7dbc454fd999693239e235fbbe87
refs/heads/master
2020-05-14T08:29:19.671739
2020-04-03T03:21:30
2020-04-03T03:21:30
181,722,314
0
0
null
null
null
null
UTF-8
C++
false
false
1,625
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i, j, k) for (int i = int(j); i <= int(k); ++ i) typedef long long ll; const int N = 1e6 + 7; int pr[N], phi[N]; bool isp[N]; ll mod, pre[N]; map<int, ll> mp; const __int128 one = 1; void sieve() { memset(isp, 1, sizeof(isp)); phi[1] = 1; rep(i, 2, N - 1) { if (isp[i]) { pr[++ pr[0]] = i; phi[i] = i - 1; } rep(j, 1, pr[0]) { if (1ll * i * pr[j] >= N) break; isp[i * pr[j]] = 0; phi[i * pr[j]] = phi[i] * (pr[j] - 1); if (i % pr[j] == 0) { phi[i * pr[j]] = phi[i] * pr[j]; break; } } } rep(i, 1, N - 1) phi[i] %= mod; rep(i, 1, N - 1) pre[i] = (pre[i - 1] + phi[i]) % mod; } ll qpow(ll a, ll b) { ll c = 1; while (b) { if (b & 1) c = c * a % mod; a = a * a % mod; b >>= 1; } return c; } ll f(ll n) { return (one * n * (n + 1) * (2 * n + 1) / 6) % mod; } inline ll calc(ll n) { if (n < N) return pre[n]; if (mp.count(n)) return mp[n]; ll m = sqrt(n + 0.5), ret = (one * n * (n + 1) / 2) % mod; // rep(i, 2, n / m) ret += mod - calc(n / i), ret %= mod; // rep(i, 1, m - 1) ret += 1ll * ((n / i) - (n / (i + 1)) + mod) * calc(i) % mod, ret %= mod; for (ll l = 2, r; l <= n; l = r + 1) { r = n / (n / l); ret += mod - 1ll * (r - l + 1) * calc(n / l) % mod; ret %= mod; } return mp[n] = ret; } int main() { int n; cin >> n >> mod; sieve(); ll ans = 0; for (ll l = 1, r; l <= n; l = r + 1) { r = n / (n / l); //cout << n / l << ' ' << f(n / l) << endl; ans += f(n / l) * (calc(r) - calc(l - 1) + mod) % mod; ans %= mod; } cout << ans << endl; }
[ "yangtiezhi@bytedance.com" ]
yangtiezhi@bytedance.com
39148d78fba22944acb15295ba77accdc1d344ea
85069bd41c473e80f158a72eafe30782b5bb08f7
/src/gui/ImportTrackingKeyDialog.h
c59b47de42e528d6f16d7948b3933db6292cea5f
[ "MIT" ]
permissive
1024UNO/1024.Wallet
682e9ccaf4f4ff978c2302d932d0d17f215b63b2
5950e4662256f564079f03e075ddf1f9d2df97cb
refs/heads/master
2021-04-12T08:29:08.025946
2018-03-28T15:23:29
2018-03-28T15:23:29
126,171,704
0
0
null
null
null
null
UTF-8
C++
false
false
704
h
// Copyright (c) 2011-2016 The Cryptonote developers // Copyright (c) 2015-2016 XDN developers // Copyright (c) 2016-2017 The 1024 developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #pragma once #include <QDialog> namespace Ui { class ImportTrackingKeyDialog; } namespace WalletGui { class ImportTrackingKeyDialog : public QDialog { Q_OBJECT public: ImportTrackingKeyDialog(QWidget* _parent); ~ImportTrackingKeyDialog(); QString getKeyString() const; QString getFilePath() const; private: QScopedPointer<Ui::ImportTrackingKeyDialog> m_ui; Q_SLOT void selectPathClicked(); }; }
[ "36153549+1024UNO@users.noreply.github.com" ]
36153549+1024UNO@users.noreply.github.com
4c90be1d590376889ddf6afc58d6d275d9a74e5e
bc8ca70afc4c3d607e3c2d36761ad685891a30dd
/Online/LeetCode/Practice/SingleNumber/SingleNumber.cpp
2e9f62bdbac840e6d6d36670e0ae8a0956973e56
[]
no_license
rohan-khurana/ProblemSolvingAndStuff
c9f4185151608202d2210ec40e4d1e3153e0ecc1
9a8c01f84c400f18a10eebc2b54c16f70572614d
refs/heads/master
2022-12-26T09:53:25.939064
2020-07-02T17:31:54
2020-07-02T17:31:54
300,852,918
1
0
null
null
null
null
UTF-8
C++
false
false
320
cpp
#include<bits/stdc++.h> using namespace std; int singleNumber(vector<int>& nums) { ios_base::sync_with_stdio(false); cin.tie(NULL); int ans=0; for(auto a: nums){ ans=ans^a; } return ans; } int main(){ vector<int> v{1,2,3,3,2}; cout<<singleNumber(v); return 0; }
[ "46553269+chetan2002@users.noreply.github.com" ]
46553269+chetan2002@users.noreply.github.com
63200a80acbf097de95ad5572e4465155ea56f3d
4fefd88ca3a20d926fd5db93b0a18a1e7c06d4d4
/Crossover2/dialog.h
330573ab6efd56ac881fc18566b7cf16a6645126
[]
no_license
shehryarnaeem/SamplePrograms
d59467680166bfc7c1a8ead7b53ec6b70742c0e4
982b5fa68a8fa741a43c921c60ed9b0dd48b255a
refs/heads/master
2021-01-24T06:49:20.819039
2017-11-09T10:38:17
2017-11-09T10:38:17
93,324,203
0
0
null
null
null
null
UTF-8
C++
false
false
702
h
#ifndef DIALOG_H #define DIALOG_H #include <QDialog> #include<QtWidgets/QApplication> #include<QtWidgets/QMainWindow> #include<QtCharts/QBarSeries> #include<QtCharts/QChartView> #include<QtCharts/QLegend> #include<QtCharts/QBarSet> #include<QVector> #include<Qtcharts/QBarCategoryAxis> #include "mainwindow.h" namespace Ui { class Dialog; } QT_CHARTS_USE_NAMESPACE class Dialog : public QDialog { Q_OBJECT public: QVector<QBarSet*>set; QBarSeries *series; static int count3; QChart *chart; QBarCategoryAxis *axis; QChartView *chartView; explicit Dialog(QWidget *parent = 0,MainWindow *obj=nullptr); ~Dialog(); private: Ui::Dialog *ui; }; #endif // DIALOG_H
[ "heyshutup@gmail.com" ]
heyshutup@gmail.com
e1c27834903aa43441916305e8a8fdbd470d9bc9
4068166c4da937e30e329569f3fcb4ef67ced415
/MapperEx/src/impl/cpp-federates/MapperEx-rti-cpp/src/main/include/USMoneyGram.hpp
549bacadd3e2a7e95ba4ca075c0ca94d4f554c60
[ "MIT" ]
permissive
usnistgov/ucef-samples
9289d3ae2d83f24ffab186153a08dd978517ed83
05d0b15556a55a4b8d54a0d97ea0509c9b112b2f
refs/heads/develop
2023-07-20T06:05:39.644287
2022-02-07T00:56:01
2022-02-07T00:56:01
97,058,709
3
3
MIT
2023-07-16T01:45:21
2017-07-12T22:59:37
Java
UTF-8
C++
false
false
9,570
hpp
/* * Copyright (c) 2008, Institute for Software Integrated Systems, Vanderbilt University * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * */ /* * NOTE: ALL "if" STATEMENTS IN THIS CODE THAT HAD THE FORM: * * if (condition) statement; * * OR * * if (condition) statement1; * else statement2; * * HAVE BEEN CONVERTED TO THE FORMS: * * if (condition) { * statement; * } * * AND * * if (condition) { * statement1; * } else { * statement2; * } * * RESPECTIVELY. THIS IS BECAUSE THE OMNET DEBUGGER APPEARS TO HAVE A PROBLEM * WITH THE NON-BRACED FORMS OF THE IF STATEMENT. *PLEASE* DO NOT CHANGE IT BACK. * -- H.S.N. * */ #ifndef _USMoneyGram_CLASS #define _USMoneyGram_CLASS #include "C2WInteractionRoot.hpp" #include "C2WException.hpp" class USMoneyGram : public C2WInteractionRoot { public: typedef C2WInteractionRoot Super; typedef boost::shared_ptr< USMoneyGram > SP; static StringVector get_parameter_names() { return getDatamemberNames(); } static StringVector get_all_parameter_names() { return getAllDatamemberNames(); } USMoneyGram( void ) { } static SP create( void ) { return SP( new USMoneyGram ); } private: static int &get_dollars_handle_var( void ) { static int dollars_handle; return dollars_handle; } static int &get_id_handle_var( void ) { static int id_handle; return id_handle; } static int &get_receiver_handle_var( void ) { static int receiver_handle; return receiver_handle; } static int &get_sender_handle_var( void ) { static int sender_handle; return sender_handle; } public: static int get_dollars_handle( void ) { return get_dollars_handle_var(); } static int get_id_handle( void ) { return get_id_handle_var(); } static int get_receiver_handle( void ) { return get_receiver_handle_var(); } static int get_sender_handle( void ) { return get_sender_handle_var(); } private: static int &getHandle( void ) { static int handle; return handle; } public: static int get_handle( void ) { return getHandle(); } static std::string get_class_name( void ) { return "USMoneyGram"; } private: static StringVector &getDatamemberNames( void ) { static StringVector datamemberNames; return datamemberNames; } static StringVector &getAllDatamemberNames( void ) { static StringVector allDatamemberNames; return allDatamemberNames; } private: static InteractionRoot::SP factory( void ) { return InteractionRoot::SP( new USMoneyGram() ); } static std::string &getInitErrorMessage( void ) { static std::string initErrorMessage( "Error: USMoneyGram: could not initialize: " ); return initErrorMessage; } protected: static void init( RTI::RTIambassador *rti ); private: static bool &getIsPublished( void ) { static bool isPublished = false; return isPublished; } static std::string &getPublishErrorMessage( void ) { static std::string publishErrorMessage = "Error: USMoneyGram: could not publish: "; return publishErrorMessage; } public: static void publish( RTI::RTIambassador *rti ); private: static std::string &getUnpublishErrorMessage( void ) { static std::string unpublishErrorMessage = "Error: USMoneyGram: could not unpublish: "; return unpublishErrorMessage; } public: static void unpublish( RTI::RTIambassador *rti ); private: static bool &getIsSubscribed( void ) { static bool isSubscribed = false; return isSubscribed; } static std::string &getSubscribeErrorMessage( void ) { static std::string subscribedErrorMessage = "Error: USMoneyGram: could not subscribe: "; return subscribedErrorMessage; } public: static void subscribe( RTI::RTIambassador *rti ); private: static std::string getUnsubscribeErrorMessage( void ) { static std::string unsubscribeErrorMessage = "Error: USMoneyGram: could not unsubscribe: "; return unsubscribeErrorMessage; } public: static void unsubscribe( RTI::RTIambassador *rti ); static bool static_init( void ); static bool match( int handle ) { return handle == get_handle(); } virtual int getClassHandle( void ) const { return get_handle(); } virtual std::string getClassName( void ) const { return get_class_name(); } virtual StringVector getParameterNames( void ) const { return get_parameter_names(); } virtual StringVector getAllParameterNames( void ) const { return get_all_parameter_names(); } virtual void publishInteraction( RTI::RTIambassador *rti ) { publish( rti ); } virtual void subscribeInteraction( RTI::RTIambassador *rti ) { subscribe( rti ); } virtual InteractionRoot::SP clone( void ) { return InteractionRoot::SP( new USMoneyGram( *this ) ); } private: double _dollars; int _id; std::string _receiver; std::string _sender; public: void set_dollars( double dollars ) { _dollars = dollars; } double get_dollars( void ) const { return _dollars; } void set_id( int id ) { _id = id; } int get_id( void ) const { return _id; } void set_receiver( const std::string & receiver ) { _receiver = receiver; } const std::string & get_receiver( void ) const { return _receiver; } void set_sender( const std::string & sender ) { _sender = sender; } const std::string & get_sender( void ) const { return _sender; } USMoneyGram( const RTI::ParameterHandleValuePairSet &datamemberMap ) : Super( datamemberMap ) { } USMoneyGram( const RTI::ParameterHandleValuePairSet &datamemberMap, const RTIfedTime &logicalTime ) : Super( datamemberMap, logicalTime ) { } public: TypeMedley getParameter( const std::string &datamemberName ) const { if ( "dollars" == datamemberName ) { return TypeMedley( get_dollars() ); } else if ( "id" == datamemberName ) { return TypeMedley( get_id() ); } else if ( "receiver" == datamemberName ) { return TypeMedley( get_receiver() ); } else if ( "sender" == datamemberName ) { return TypeMedley( get_sender() ); } else { return Super::getParameter( datamemberName ); } } TypeMedley getParameter( int datamemberHandle ) const { if ( get_dollars_handle() == datamemberHandle ) { return TypeMedley( get_dollars() ); } else if ( get_id_handle() == datamemberHandle ) { return TypeMedley( get_id() ); } else if ( get_receiver_handle() == datamemberHandle ) { return TypeMedley( get_receiver() ); } else if ( get_sender_handle() == datamemberHandle ) { return TypeMedley( get_sender() ); } else { return Super::getParameter( datamemberHandle ); } } protected: virtual bool setParameterAux( int param_handle, const std::string &val ) { bool retval = true; if ( param_handle == get_dollars_handle() ) { set_dollars( TypeMedley( val ) ); } else if ( param_handle == get_id_handle() ) { set_id( TypeMedley( val ) ); } else if ( param_handle == get_receiver_handle() ) { set_receiver( TypeMedley( val ) ); } else if ( param_handle == get_sender_handle() ) { set_sender( TypeMedley( val ) ); } else { retval = Super::setParameterAux( param_handle, val ); } return retval; } virtual bool setParameterAux( const std::string &datamemberName, const std::string &val ) { bool retval = true; if ( "dollars" == datamemberName ) { set_dollars( TypeMedley( val ) ); } else if ( "id" == datamemberName ) { set_id( TypeMedley( val ) ); } else if ( "receiver" == datamemberName ) { set_receiver( TypeMedley( val ) ); } else if ( "sender" == datamemberName ) { set_sender( TypeMedley( val ) ); } else { retval = Super::setParameterAux( datamemberName, val ); } return retval; } virtual bool setParameterAux( const std::string &datamemberName, const TypeMedley &val ) { bool retval = true; if ( "dollars" == datamemberName ) {\ set_dollars( val ); } else if ( "id" == datamemberName ) {\ set_id( val ); } else if ( "receiver" == datamemberName ) {\ set_receiver( val ); } else if ( "sender" == datamemberName ) {\ set_sender( val ); } else { retval = Super::setParameterAux( datamemberName, val ); } return retval; } virtual ParameterHandleValuePairSetSP createDatamemberHandleValuePairSet( RTI::ULong count ); virtual ParameterHandleValuePairSetSP createDatamemberHandleValuePairSet( ) { return createDatamemberHandleValuePairSet( 0 ); } }; typedef USMoneyGram::SP USMoneyGramSP; static bool call_USMoneyGram_static_init = USMoneyGram::static_init(); std::ostream &operator<<( std::ostream &os, USMoneyGram::SP entitySP ); std::ostream &operator<<( std::ostream &os, const USMoneyGram &entity ); #endif
[ "himanshu.neema@vanderbilt.edu" ]
himanshu.neema@vanderbilt.edu