blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
sequencelengths
1
1
author_id
stringlengths
0
158
80a35e8b74153c33bd0f6fb8cbc777fb01cc15d0
8adafe96914bf039cb0455f3f84c04d5e782bd60
/practise/src/leetcode/power_of_four.h
6f90a3e910ff013ddcfba735df5e495267f54953
[]
no_license
sryanyuan/cpp11_practise
1e7d78341349b91773fa8d667bd9ac83e51ea5d0
0ead6d5d2f16bd344fee92668fd5b364439a86ac
refs/heads/master
2021-06-25T13:51:29.957869
2019-04-10T04:08:47
2019-04-10T04:08:47
133,794,224
0
0
null
null
null
null
UTF-8
C++
false
false
686
h
#ifndef _INC_POWER_OF_FOUR_ #define _INC_POWER_OF_FOUR_ class PowerOfFour { public: static void test() { auto ret = uselog(16); } static bool uselog(int num) { // logca = logdc/logda if (num <= 0) { return false; } auto ret = log10(num) / log10(4); int nret = int(ret); return ((long double)(nret) - ret) == 0; } static bool main(int num) { if (num <= 0) { return false; } if ((num & (num - 1)) == 0) { // Power of 2 if ((num - 1) % 3 == 0) { return true; } } return false; } }; #endif
60bc33c5ee66fa103ceba2fab74b2c7ef3de8030
54c1a2c4dcea4e678ce94e24f23aa53c37f6474c
/latihan1.cpp
31383cdcc9e1e0f90766f8aa60994e61a1ac3b3b
[]
no_license
arjuna14/praktikum4
2976312b067ed5c1203bfa02d1431a63e3c6882d
a878d56a580a719686ce878304129cb0fda4ff29
refs/heads/master
2020-04-05T16:20:03.105359
2018-11-10T18:11:31
2018-11-10T18:11:31
157,004,667
0
0
null
null
null
null
UTF-8
C++
false
false
559
cpp
#include<iostream> using namespace std; int main () { cout<< " ______________________________________________________________"<<endl; cout<< "|Algoritma Mencari Nilai Terbesar Dari Bilangan Yang Diinputkan|"<<endl; cout<< "|______________________________________________________________|"<<endl; int max,A; max=0; do{ cout<< "masukin nilai yang ingin di masukan :"; cin >> A; if (max<A) max=A; } while (A!=0); cout<< "hasilnya = " <<max<< endl; return 0; cout<< "Terima Kasih"<<endl; }
c117ada0336af696f942e999ee037609f7bb8ffa
cfe6c3cf4f3d851ba2a6d3ac6055e537a3598141
/IGME.740.01-GameGraphicsProgramming/Submissions/Milestone 2/Tower/DSEngine/DSEngineFramework/DSFXAudio2.cpp
323799f092093b009a05751d63cb54de08ba6835
[]
no_license
shurunxuan/GDD_Assignments
c7b859e885d07c1d6aac112468b66c014a3a2537
7fca0f7378e10f0781d3e732a1b843799975e234
refs/heads/master
2022-06-23T16:27:40.756001
2020-05-10T08:40:13
2020-05-10T08:40:13
262,743,627
0
0
null
null
null
null
UTF-8
C++
false
false
3,358
cpp
#include "DSFXAudio2.h" #include "DSFLogging.h" DSFXAudio2* FXAudio2 = nullptr; DSFXAudio2::DSFXAudio2() { FXAudio2 = this; xAudio2 = nullptr; masterVoice = nullptr; CoInitializeEx(nullptr, COINIT_MULTITHREADED); } DSFXAudio2::~DSFXAudio2() { SAFE_RELEASE(xAudio2); // TODO: Maybe masterVoice need to be destroyed. } void DSFXAudio2::Init() { HRESULT hr = CreateXAudio2Engine(); if (SUCCEEDED(hr)) hr = CreateMasteringVoice(); if (SUCCEEDED(hr)) LOG_TRACE << "DS Engine Framework for XAudio2 Initialized!"; } HRESULT DSFXAudio2::CreateXAudio2Engine() { HRESULT hr = XAudio2Create(&xAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR); XAUDIO2_DEBUG_CONFIGURATION debugConfig = {}; debugConfig.TraceMask |= XAUDIO2_LOG_DETAIL | XAUDIO2_LOG_WARNINGS | XAUDIO2_LOG_TIMING | XAUDIO2_LOG_MEMORY | XAUDIO2_LOG_STREAMING; xAudio2->SetDebugConfiguration(&debugConfig); LOG_TRACE << "XAudio2 Engine Created."; return hr; } HRESULT DSFXAudio2::CreateMasteringVoice() { HRESULT hr = xAudio2->CreateMasteringVoice(&masterVoice); XAUDIO2_VOICE_DETAILS voiceDetails = {}; masterVoice->GetVoiceDetails(&voiceDetails); LOG_TRACE << "Mastering voice created with " << GetMasteringVoiceChannel() << " channel(s), sample rate " << GetMasteringVoiceSampleRate() << "Hz."; return hr; } unsigned int DSFXAudio2::GetMasteringVoiceSampleRate() const { XAUDIO2_VOICE_DETAILS voiceDetails = {}; masterVoice->GetVoiceDetails(&voiceDetails); return voiceDetails.InputSampleRate; } unsigned int DSFXAudio2::GetMasteringVoiceChannel() const { XAUDIO2_VOICE_DETAILS voiceDetails = {}; masterVoice->GetVoiceDetails(&voiceDetails); return voiceDetails.InputChannels; } HRESULT DSFXAudio2::CreateSourceVoice(IXAudio2SourceVoice** ppSourceVoice, int channels, int sampleRate, int bytesPerSample, IXAudio2VoiceCallback* pCallback) const { WAVEFORMATEXTENSIBLE wfx; memset(&wfx, 0, sizeof(WAVEFORMATEXTENSIBLE)); wfx.Format.wFormatTag = WAVE_FORMAT_PCM; wfx.Format.nSamplesPerSec = sampleRate; wfx.Format.nChannels = channels; wfx.Format.wBitsPerSample = bytesPerSample * 8; wfx.Format.nBlockAlign = wfx.Format.nChannels * bytesPerSample; wfx.Format.nAvgBytesPerSec = wfx.Format.nSamplesPerSec * wfx.Format.nBlockAlign; wfx.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); wfx.Samples.wValidBitsPerSample = wfx.Format.wBitsPerSample; masterVoice->GetChannelMask(&wfx.dwChannelMask); wfx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; const HRESULT hr = xAudio2->CreateSourceVoice(ppSourceVoice, reinterpret_cast<WAVEFORMATEX*>(&wfx), 0, 2, pCallback); if (FAILED(hr)) LOG_ERROR << "Failed to create source voice"; return hr; } DSFVoiceCallback::DSFVoiceCallback() : bufferEvent(CreateEvent(nullptr, FALSE, FALSE, nullptr)), streamEvent(CreateEvent(nullptr, FALSE, FALSE, nullptr)) { } DSFVoiceCallback::~DSFVoiceCallback() { CloseHandle(bufferEvent); CloseHandle(streamEvent); } void DSFVoiceCallback::OnStreamEnd() { SetEvent(streamEvent); } void DSFVoiceCallback::OnVoiceProcessingPassEnd() { } void DSFVoiceCallback::OnVoiceProcessingPassStart(UINT32 samples) { } void DSFVoiceCallback::OnBufferEnd(void* context) { SetEvent(bufferEvent); } void DSFVoiceCallback::OnBufferStart(void* context) { } void DSFVoiceCallback::OnLoopEnd(void* context) { } void DSFVoiceCallback::OnVoiceError(void* context, HRESULT Error) { }
d6c9bbfbe12d742ddae3132d5039901211c83115
5da61c393b65b5b06ec684242adb457d25f1f4a2
/src/Models/demandmodel.h
c4138b99f95307a491a94b6e0ee7b7b6058086c6
[ "MIT" ]
permissive
MehmetMelihKosucu/EPANET_3-PMX
cb74d1480f61f42dd59dfa509e140dc098385c38
e4674330225288c8ba29c23928ce8c82f38a7c9f
refs/heads/main
2023-06-10T13:46:40.996311
2023-06-02T01:28:32
2023-06-02T01:28:32
581,764,129
1
0
MIT
2023-06-02T00:58:06
2022-12-24T08:34:48
C++
UTF-8
C++
false
false
2,941
h
/* EPANET 3.1.1 Pressure Management Extension * * Copyright (c) 2016 Open Water Analytics * Licensed under the terms of the MIT License (see the LICENSE file for details). * */ //! \file demandmodel.h //! \brief Describes the DemandModel class and its sub-classes. #ifndef DEMANDMODEL_H_ #define DEMANDMODEL_H_ #include <string> class Junction; //! \class DemandModel //! \brief The interface for a pressure-dependent demand model. //! //! DemandModel is an abstract class from which a concrete demand //! model is derived. Four such models are currently available - //! Fixed, Constrained, Power, and Logistic. class DemandModel { public: DemandModel(); DemandModel(double expon_); virtual ~DemandModel() = 0; static DemandModel* factory(const std::string model, double expon_); /// Finds demand flow and its derivative as a function of head. virtual double findDemand(Junction* junc, double h, double& dqdh); /// Changes fixed grade status depending on pressure deficit. virtual bool isPressureDeficient(Junction* junc) { return false; } protected: double expon; }; //----------------------------------------------------------------------------- //! \class FixedDemandModel //! \brief A demand model where demands are fixed independent of pressure. //----------------------------------------------------------------------------- class FixedDemandModel : public DemandModel { public: FixedDemandModel(); }; //----------------------------------------------------------------------------- //! \class ConstrainedDemandModel //! \brief A demand model where demands are reduced based on available pressure. //----------------------------------------------------------------------------- class ConstrainedDemandModel : public DemandModel { public: ConstrainedDemandModel(); bool isPressureDeficient(Junction* junc); double findDemand(Junction* junc, double p, double& dqdh); }; //----------------------------------------------------------------------------- //! \class PowerDemandModel //! \brief A demand model where demand varies as a power function of pressure. //----------------------------------------------------------------------------- class PowerDemandModel : public DemandModel { public: PowerDemandModel(double expon_); double findDemand(Junction* junc, double p, double& dqdh); }; //----------------------------------------------------------------------------- //! \class LogisticDemandModel //! \brief A demand model where demand is a logistic function of pressure. //----------------------------------------------------------------------------- class LogisticDemandModel : public DemandModel { public: LogisticDemandModel(double expon_); double findDemand(Junction* junc, double p, double& dqdh); private: double a, b; // logistic function coefficients void setCoeffs(double pMin, double pFull); }; #endif
004d0dfc9488c6119b7f36d42963bf53ab4e8b43
0b791f7cddb05d576bd566afc1db8bbda7714e42
/SDK/include/OGRE/Physics/NxOgreSceneLink.h
c541551a9b2a199a970f13af6db215cd4c57792a
[]
no_license
widVE/FionaOgre
2c046a170c494c567659f9a6930254b43aa565ca
8b7ca341c21065b019288510fa965b3c3e2ab275
refs/heads/master
2020-06-28T00:22:25.639777
2020-06-24T12:01:00
2020-06-24T12:01:00
200,090,803
0
0
null
null
null
null
UTF-8
C++
false
false
2,451
h
/** This file is part of NxOgre. Copyright (c) 2009 Robin Southern, http://www.nxogre.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef NXOGRE_SCENELINK_H #define NXOGRE_SCENELINK_H #include "NxOgreStable.h" #include "NxOgreCommon.h" #include "NxOgreScene.h" namespace NxOgre { /*! class. SceneLink */ class NxOgrePublicClass SceneLink : public BigClassAllocatable, public TimeListener { public: // Functions SceneLink(PrincipalScene*, AuxiliaryScene*); virtual ~SceneLink(); virtual bool advance(float deltaTime, const Enums::Priority&) = 0; protected: // Variables PrincipalScene* mPrincipal; AuxiliaryScene* mAuxiliary; }; // class SceneLink } // namespace NxOgre #endif
61787f3c6279fbeedc486ba223a4b7c56e11858d
af69e335fc0ff9632964d061833713b672abad01
/Temp/StagingArea/Data/il2cppOutput/mscorlib_System_IO_SynchronizedWriter1722853220.h
1ac829df936c3dcd9814d1df2062935766dac464
[]
no_license
PruthvishMShirur/Solar-System
ca143ab38cef582705f0beb76f7fef8b28e25ef9
5cf3eaa66949801aa9a34cd3cf80eeefa64d2342
refs/heads/master
2023-05-26T17:53:37.489349
2021-06-16T19:56:48
2021-06-16T19:56:48
377,611,177
0
0
null
null
null
null
UTF-8
C++
false
false
1,573
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "mscorlib_System_IO_TextWriter3478189236.h" // System.IO.TextWriter struct TextWriter_t3478189236; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.IO.SynchronizedWriter struct SynchronizedWriter_t1722853220 : public TextWriter_t3478189236 { public: // System.IO.TextWriter System.IO.SynchronizedWriter::writer TextWriter_t3478189236 * ___writer_2; // System.Boolean System.IO.SynchronizedWriter::neverClose bool ___neverClose_3; public: inline static int32_t get_offset_of_writer_2() { return static_cast<int32_t>(offsetof(SynchronizedWriter_t1722853220, ___writer_2)); } inline TextWriter_t3478189236 * get_writer_2() const { return ___writer_2; } inline TextWriter_t3478189236 ** get_address_of_writer_2() { return &___writer_2; } inline void set_writer_2(TextWriter_t3478189236 * value) { ___writer_2 = value; Il2CppCodeGenWriteBarrier(&___writer_2, value); } inline static int32_t get_offset_of_neverClose_3() { return static_cast<int32_t>(offsetof(SynchronizedWriter_t1722853220, ___neverClose_3)); } inline bool get_neverClose_3() const { return ___neverClose_3; } inline bool* get_address_of_neverClose_3() { return &___neverClose_3; } inline void set_neverClose_3(bool value) { ___neverClose_3 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
fb0242bd2bfcc1d5dc56ebdf32592974f075a02a
fa134e5f64c51ccc1c2cac9b9cb0186036e41563
/GT/FPSFormView.h
88ef8bcbe53399aeaa2ca416f722c0947cf8223a
[]
no_license
dlsyaim/gradthes
70b626f08c5d64a1d19edc46d67637d9766437a6
db6ba305cca09f273e99febda4a8347816429700
refs/heads/master
2016-08-11T10:44:45.165199
2010-07-19T05:44:40
2010-07-19T05:44:40
36,058,688
0
1
null
null
null
null
GB18030
C++
false
false
1,164
h
#pragma once #include "afxwin.h" #include <olectl.h> #include <ole2.h> // CFPSFormView 窗体视图 /* * FPS is the abbreviation for 'Flight Path Set' */ class CGTDoc; class CFPSFormView : public CFormView { DECLARE_DYNCREATE(CFPSFormView) protected: CFPSFormView(); // 动态创建所使用的受保护的构造函数 virtual ~CFPSFormView(); public: enum { IDD = IDD_FLIGHT_PATH_SET_FORMVIEW }; CGTDoc* GetDocument() const; #ifdef _DEBUG virtual void AssertValid() const; #ifndef _WIN32_WCE virtual void Dump(CDumpContext& dc) const; #endif #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: double mapLongitude; double mapLatitude; double jointZCoordinate; CStatic m_Map; afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); private: // Operations HBITMAP LoadAnImage(CString fileName); public: afx_msg void OnBnClickedLoadMapButton(); }; #ifndef _DEBUG // debug version in FPSFormView.cpp inline CGTDoc* CFPSFormView::GetDocument() const { return reinterpret_cast<CGTDoc*>(m_pDocument); } #endif
[ "[email protected]@3a95c3f6-2b41-11df-be6c-f52728ce0ce6" ]
[email protected]@3a95c3f6-2b41-11df-be6c-f52728ce0ce6
57dc254ec2ca782822dd449dd6db0f10a9a88364
51122b7cd153803da740b5839df5a71579639b8e
/VoidEngine/EngineCore/include/core/physics/colliders/SphereCollider.h
c63045644d6da5ed8ee8cd06bc93c0ba48888a75
[]
no_license
MrLever/VoidEngine
7b570a1e302f6c0e1108e7f851b1e29aa9541230
a302c531f8928c8ff7de8cf70b2c3dc242da5585
refs/heads/master
2022-11-27T00:52:22.031866
2020-06-25T01:19:28
2020-06-25T01:19:28
158,166,694
0
1
null
2020-06-25T01:19:30
2018-11-19T05:28:57
C++
UTF-8
C++
false
false
782
h
#pragma once //STD Headers //Library Headers //Void Engine Headers #include "core/physics/colliders/Collider.h" #include "core/physics/components/ColliderComponent.h" namespace core { class SphereCollider : public Collider { /** * Declare custom RTTI support */ ENABLE_RTTI(SphereCollider) public: /** * Constructor */ SphereCollider(); /** * Destructor */ ~SphereCollider() override; /** * Set's up sphere collision volume */ void Initialize() override; /** * Radius Accessor */ float GetRadius() const; /** * Defines how to draw collision volume */ void Draw(std::shared_ptr<ShaderProgram> shader, const glm::mat4& transform); private: /** Radius of the collision sphere */ float Radius; }; }
8237cc9b01e365f9112ec7e2ff8e4b75087f837e
e3063fccaaed7d0e9a763c495e4d787a6dbb9056
/Samples/Scripts/Layout/samples/sample1/Msvc60/CLIENT.H
b90ea4985572b972983457c15d299ce65616cc13
[]
no_license
VB6Hobbyst7/PLayouts
dedce6e1ce2f0884c3cbe4a929c39f93dfd3bdc6
012d506f20c97948053411c29bdecc4739f8a510
refs/heads/master
2021-09-04T20:00:39.905993
2017-12-03T03:07:05
2017-12-03T03:07:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,786
h
////////////////////////////////////////////////////////////////////////////// // // CLIENT.H : Main header file for the CLIENT application // ////////////////////////////////////////////////////////////////////////////// // This is a part of the PADS-PowerPCB OLE Automation server SAMPLE1 sample. // Copyright (C) 2003 Mentor Graphics Corp. // All rights reserved. // // This source code is only intended as a supplement to the PADS-PowerPCB OLE // Automation Server API Help file. ////////////////////////////////////////////////////////////////////////////// #if !defined(AFX_CLIENT_H__EFD42728_D443_11D0_BCBF_444553540000__INCLUDED_) #define AFX_CLIENT_H__EFD42728_D443_11D0_BCBF_444553540000__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif #include "resource.h" // main symbols ///////////////////////////////////////////////////////////////////////////// // CClientApp: // See client.cpp for the implementation of this class // class CClientApp : public CWinApp { public: CClientApp(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CClientApp) public: virtual BOOL InitInstance(); //}}AFX_VIRTUAL // Implementation //{{AFX_MSG(CClientApp) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. #endif // !defined(AFX_CLIENT_H__EFD42728_D443_11D0_BCBF_444553540000__INCLUDED_)
88616145c688ab50780340c5c3453ef6cf002ec5
df1279323e3216076f514ea9e93c330c7f77675f
/Tai-tai/trackwidget.cpp
522409d2ca51ba608334c0c101fd67458fad52fc
[]
no_license
AntonGulkevich/Tai-tai
4a35ac13249d881a88022237b33cefa3a4d6c452
ba66ed8af934dbcb6191bf69cadc41e2ffdf94e4
refs/heads/master
2021-01-23T13:59:08.490243
2015-08-18T12:43:16
2015-08-18T12:43:16
31,409,723
3
0
null
null
null
null
UTF-8
C++
false
false
621
cpp
#include "trackwidget.h" TrackWidget::TrackWidget(QWidget *parent) : QWidget(parent) { mpos=parent->pos(); canMove= false; } void TrackWidget::mousePressEvent(QMouseEvent *event){ if(event->button() == Qt::LeftButton) { mpos = event->pos(); canMove = true; } } void TrackWidget::mouseReleaseEvent(QMouseEvent *event){ if (event->button() == Qt::LeftButton && canMove) { canMove = false; } } void TrackWidget::mouseMoveEvent(QMouseEvent *event){ if((event->buttons() & Qt::LeftButton) && canMove){ parentWidget()->move(event->globalPos()-mpos); } }
c89989f07fec43d790a6a41808a3aa46debffd9a
b1841dd9dda5cbb4ba3dc6c46a0fa13d93600868
/MapSplice_multi_threads_2.0.1.9/src/MapSplice/read_block.h
808daf71ebb87472bba8d46fa888ef5e8af2070d
[ "Artistic-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
bioinfo-incliva/docker-mapsplice
25fac9a9dd3bcb039409b5ce90b879a5090c1538
2f8e6f1e912f4bddc46ab9dffc36e1689a5072ad
refs/heads/master
2023-02-02T14:50:27.350922
2020-12-21T18:10:34
2020-12-21T18:10:34
323,396,204
0
0
null
null
null
null
UTF-8
C++
false
false
3,219
h
#ifndef READS_FILE_H #define READS_FILE_H #include <string> #include <fstream> #include <iostream> #include <stdlib.h> #include <vector> #include <map> inline string int_to_str(int numerical) { char c[100]; sprintf(c,"%d",numerical); string str(c); return str; } inline char complement(int i) { static const int b2c_size = 20; static const char b2c[] = {'T','N','G','N','N','N','C','N','N','N','N','N','N','N','N','N','N','N','N','A'}; static const char b2cl[] = {'t','n','g','n','n','n','c','n','n','n','n','n','n','n','n','n','n','n','n','a'}; if (i - 'A' >= 0 && i - 'A' < b2c_size) return b2c[i - 'A']; else if (i - 'a' >= 0 && i - 'a' < b2c_size) return b2cl[i - 'a']; else return 'N'; } inline string revcomp(const string& s) { string r; transform(s.begin(), s.end(), back_inserter(r), complement); reverse(r.begin(), r.end()); return r; } struct Read_Block { public: Read_Block(bool _paired) { paired = _paired; } ~Read_Block() { clear(); } string get_read_id() { return read_id; } string get_seg_seq(int seg_no) { return read_seq[seg_no-1]; } string get_revcom_seg_seq(int seg_no) { return read_seq_revcom[seg_no-1]; } string get_seg_qual(int seg_no) { return read_quality[seg_no-1]; } string get_revcom_seg_qual(int seg_no) { return read_quality_revcom[seg_no-1]; } int get_seg_len(int seg_no) { return (int)(read_seq[seg_no - 1 ].length()); } int get_seg_len(int seg_no1, int seg_no2) { if(seg_no1 < 1 || seg_no2 < 1 || seg_no1 > (int)seg_num || seg_no2 > (int)seg_num) return 0; if(seg_no1 == (int)seg_num || seg_no2 == (int)seg_num) return (abs(seg_no1 - seg_no2)) * get_seg_len(1) + get_seg_len(seg_num); else return (abs(seg_no1 - seg_no2) + 1) * get_seg_len(1); } /////////size_t version string get_seg_seq(size_t seg_no) { return read_seq[seg_no-1]; } string get_revcom_seg_seq(size_t seg_no) { return read_seq_revcom[seg_no-1]; } string get_seg_qual(size_t seg_no) { return read_quality[seg_no-1]; } string get_revcom_seg_qual(size_t seg_no) { return read_quality_revcom[seg_no-1]; } int get_seg_len(size_t seg_no) { return (int)(read_seq[seg_no - 1 ].length()); } int get_seg_len(size_t seg_no1, size_t seg_no2) { if(seg_no1 < 1 || seg_no2 < 1 || seg_no1 > seg_num || seg_no2 > seg_num) return 0; if(seg_no1 == seg_num || seg_no2 == seg_num) return (abs((int)seg_no1 - (int)seg_no2)) * get_seg_len(1) + get_seg_len(seg_num); else return (abs((int)seg_no1 - (int)seg_no2) + 1) * get_seg_len(1); } void clear() { read_id.clear(); read_strand.clear(); read_seq.clear(); read_seq_revcom.clear(); read_quality.clear(); read_quality_revcom.clear(); seg_num=0; } void set_seg_num() { seg_num = read_seq.size(); } int get_seg_num() { return (int)seg_num; } void get_full_read_seq() { for(size_t i = 0; i < read_seq.size(); i++) { full_read_seq.append(read_seq[i]); } } string read_id; string read_strand; string full_read_seq; vector<string> read_seq; vector<string> read_seq_revcom; vector<string> read_quality; vector<string> read_quality_revcom; size_t seg_num; bool paired; }; #endif
3773053f17e924005423fd3e804be7dd269aa9b5
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function13766/function13766_schedule_14/function13766_schedule_14_wrapper.cpp
6aee67b85b8389c7c66eccc56bab3aff3b4e3bb8
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
1,219
cpp
#include "Halide.h" #include "function13766_schedule_14_wrapper.h" #include "tiramisu/utils.h" #include <cstdlib> #include <iostream> #include <time.h> #include <fstream> #include <chrono> #define MAX_RAND 200 int main(int, char **){ Halide::Buffer<int32_t> buf00(64, 128, 64); Halide::Buffer<int32_t> buf01(64, 64); Halide::Buffer<int32_t> buf02(64, 128); Halide::Buffer<int32_t> buf03(64, 64, 64); Halide::Buffer<int32_t> buf04(64, 128, 64); Halide::Buffer<int32_t> buf0(64, 64, 128, 64); init_buffer(buf0, (int32_t)0); auto t1 = std::chrono::high_resolution_clock::now(); function13766_schedule_14(buf00.raw_buffer(), buf01.raw_buffer(), buf02.raw_buffer(), buf03.raw_buffer(), buf04.raw_buffer(), buf0.raw_buffer()); auto t2 = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = t2 - t1; std::ofstream exec_times_file; exec_times_file.open("../data/programs/function13766/function13766_schedule_14/exec_times.txt", std::ios_base::app); if (exec_times_file.is_open()){ exec_times_file << diff.count() * 1000000 << "us" <<std::endl; exec_times_file.close(); } return 0; }
a3cf72d585399e0f4300d0e209035aaaca7233ac
904fa0107d14c9f7554b4f4866ecb1a8f6f1abef
/hphp/runtime/test/vasm-xls-test.cpp
95ca682980302ca9d37eb10631025ac7bd52f9bd
[ "Zend-2.0", "PHP-3.01", "BSD-3-Clause" ]
permissive
sunnygkp10/hhvm
70be2a674e0e1a961bc73f217fb352efa698817b
86b27dd81c2ff15e9e9e7e7bd7e1ada9debb5702
refs/heads/master
2020-12-24T23:55:04.772689
2015-08-13T18:23:03
2015-08-13T18:30:47
40,675,812
1
1
null
2015-08-13T18:43:17
2015-08-13T18:43:16
null
UTF-8
C++
false
false
2,878
cpp
/* +----------------------------------------------------------------------+ | HipHop for PHP | +----------------------------------------------------------------------+ | Copyright (c) 2010-2015 Facebook, Inc. (http://www.facebook.com) | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [email protected] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ #include "hphp/runtime/vm/jit/abi.h" #include "hphp/runtime/vm/jit/abi-x64.h" #include "hphp/runtime/vm/jit/containers.h" #include "hphp/runtime/vm/jit/vasm.h" #include "hphp/runtime/vm/jit/vasm-emit.h" #include "hphp/runtime/vm/jit/vasm-gen.h" #include "hphp/runtime/vm/jit/vasm-instr.h" #include "hphp/runtime/vm/jit/vasm-print.h" #include "hphp/runtime/vm/jit/vasm-text.h" #include "hphp/runtime/vm/jit/vasm-unit.h" #include <gtest/gtest.h> namespace HPHP { namespace jit { using namespace reg; template<class T> uint64_t test_const(T val) { using testfunc = double (*)(); static const Abi test_abi = { .gpUnreserved = RegSet{}, .gpReserved = x64::abi().gp(), .simdUnreserved = RegSet{xmm0}, .simdReserved = x64::abi().simd() - RegSet{xmm0}, .calleeSaved = x64::kCalleeSaved, .sf = x64::abi().sf }; static uint8_t code[1000]; CodeBlock main; main.init(code, sizeof(code), "test"); Vasm vasm; Vtext text { main }; auto& unit = vasm.unit(); auto& v = vasm.main(); unit.entry = v; v << copy{v.cns(val), Vreg{xmm0}}; v << ret{RegSet{xmm0}}; optimizeX64(vasm.unit(), test_abi); emitX64(unit, text, nullptr); union { double d; uint64_t c; } u; u.d = ((testfunc)code)(); return u.c; } TEST(Vasm, XlsByteXmm) { EXPECT_EQ(test_const(false), 0); EXPECT_EQ(test_const(true), 1); // DataType is actually mapped to uint64_t constants, for some reason, // but if that changes we still want to test them as bytes here. EXPECT_EQ(test_const(KindOfUninit), 0); EXPECT_EQ(test_const(KindOfArray), KindOfArray); } TEST(Vasm, XlsIntXmm) { EXPECT_EQ(test_const(uint32_t(1234)), 1234); EXPECT_EQ(test_const(uint32_t(0)), 0); // 32-bit constants are unsigned. make sure not sign-extended EXPECT_EQ(test_const(uint32_t(0xffffffff)), 0xffffffffl); EXPECT_EQ(test_const(uint32_t(0x80000000)), 0x80000000l); } }}
0d981b04c773769e0a3211d7298df616e72733ae
019c446b2c8f8e902226851db1b31eb1e3c850d5
/oneEngine/oneGame/source/engine-common/entities/CLoadingScreen.h
5448ab170518d6f8ce4269ef1eb702a80e36c24a
[ "BSD-3-Clause", "FTL" ]
permissive
skarik/1Engine
cc9b6f7cf81903b75663353926a23224b81d1389
9f53b4cb19a6b8bb3bf2e3a4104c73614ffd4359
refs/heads/master
2023-09-04T23:12:50.706308
2023-08-29T05:28:21
2023-08-29T05:28:21
109,445,379
9
2
BSD-3-Clause
2021-08-30T06:48:27
2017-11-03T21:41:51
C++
UTF-8
C++
false
false
1,215
h
#ifndef ENGINE_COMMON_C_LOADING_SCREEN_H_ #define ENGINE_COMMON_C_LOADING_SCREEN_H_ #include "core/containers/arsingleton.h" #include "engine/behavior/CGameBehavior.h" class CLoadScreenInjector; class CLoadingScreen : public CGameBehavior { private: ENGCOM_API static CLoadingScreen* m_Active; public: // Active() : Get the currently active loading screen in the scene. // Returns NULL if there is no loading screen active. static CLoadingScreen * Active ( void ) { return m_Active; } public: ENGCOM_API explicit CLoadingScreen ( void ); ENGCOM_API ~CLoadingScreen ( void ); // 1Engine update override ENGCOM_API void Update ( void ) override; // loadStep() : Call for each step of the loading // Will update the loading screen whenever this is called. ENGCOM_API void loadStep ( void ); // loadSetDone() : Sets the loading as done // The loading screen will fade out and delete itself. ENGCOM_API void loadSetDone ( void ); private: // Screen injector - renders loading screen CLoadScreenInjector* m_injector; // Current alpha (fades out when done loading) Real m_alpha; // Is loading done? bool m_loadingDone; }; #endif//ENGINE_COMMON_C_LOADING_SCREEN_H_
4953c61b2ead864aba7035170272171140b19cbe
d9a2c70f950043153c4cc0e11101129a3ef9ef40
/Mamba/framework/src/main/cpp/video/videoutils/PixelTransUtilsJni.cpp
06bcf149cd990a34b95bba5f8bb73e8998b23453
[]
no_license
mowenli/MambaProject
3d9e907a4ea622fb1d1bca9e2bba9a8fe9ee7fc5
2caabf4624138e4024b9208a1078baa52e9cf7fd
refs/heads/master
2021-09-15T13:46:07.817675
2018-06-03T06:22:25
2018-06-03T06:22:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
499
cpp
// // Created by jakechen on 2017/6/30. // #include "PixelTransUtilsJni.h" JNI(void, rgbaToYuv)(JNIEnv *env, jclass type, jbyteArray src_, jint width, jint height, jbyteArray dest_) { jbyte *src = env->GetByteArrayElements(src_, NULL); jbyte *dest = env->GetByteArrayElements(dest_, NULL); rgbaToYuv((unsigned char *) src, width, height, (unsigned char *) dest); env->ReleaseByteArrayElements(src_, src, 0); env->ReleaseByteArrayElements(dest_, dest, 0); }
e0dc3f0f9c28a3226ff0a151e36dbcd5fa42952c
96d6f3b30731c6e42f7f1df6465606906a7bebfd
/src/Tracker.cpp
cd1dd3f9e3c2eacf2a9ee49b726367ef8f50fb79
[]
no_license
Sammy1Am/VestaBlindNode
1921a2a2d002dc09a6e3d98bf5812d808460ccfa
494dc0ec02c6fa0442fc5f1cdffd3ac6898cfb9e
refs/heads/master
2022-04-02T07:51:24.921846
2020-02-07T21:00:01
2020-02-07T21:00:01
239,021,388
1
0
null
null
null
null
UTF-8
C++
false
false
2,766
cpp
#include <Tracker.h> namespace vesta { #define NUM_DEVICES_TO_TRACK 2 #define VESTA_TRACKER_JSON_DOC_SIZE 107 + (34 * NUM_DEVICES_TO_TRACK) uint8_t trackingFilter[NUM_DEVICES_TO_TRACK][MAC_ADDRESS_LENGTH] = { {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05}}; // Since we know how many devices we're planning to track and what data we're including, // we can use a Static document StaticJsonDocument<VESTA_TRACKER_JSON_DOC_SIZE> trackerJsonDoc; JsonObject s_wifi; WiFiClient *trackerClient; HTTPClient hc; void Tracker::setup_tracker(WiFiClient *client) { trackerClient = client; initJson(); } void Tracker::initJson() { s_wifi = trackerJsonDoc.createNestedObject("s").createNestedObject("wifi"); trackerJsonDoc["d"] = VestaConfig::getConfig()->hostname; trackerJsonDoc["f"] = TRACKER_FAMILY_NAME; } void Tracker::spottedDevice(uint8_t macAddress[], signed int rssi) { char mac[18] = {0}; sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]); s_wifi[mac] = rssi; } bool Tracker::passesFilter(uint8_t macAddress[]) { for (int f = 0; f < NUM_DEVICES_TO_TRACK; f++) { bool filterPass = true; for (int p = 0; p < MAC_ADDRESS_LENGTH; p++) { if (trackingFilter[f][p] != macAddress[p]) { filterPass = false; break; } } if (filterPass) { return true; Serial.println("It passed!"); } } return false; } bool Tracker::hasReportAvailable() { Serial.printf("Tracker has %u records to report.\n", s_wifi.size()); return s_wifi.size() > 0; } void Tracker::sendReport() { char buffer[VESTA_TRACKER_JSON_DOC_SIZE]; serializeJson(trackerJsonDoc, buffer); hc.begin(*trackerClient, VestaConfig::getConfig()->mqtt_server, 8005, "/passive"); hc.addHeader("Content-Type", "application/json"); int httpCode = hc.POST((uint8_t *)buffer, strlen(buffer)); // httpCode will be negative on error if (httpCode > 0) { // HTTP header has been send and Server response header has been handled Serial.printf("[HTTP] POST code: %d\n", httpCode); // file found at server if (httpCode == HTTP_CODE_OK) { const String &payload = hc.getString(); Serial.print("server responded:\n<<"); Serial.print(payload); Serial.println(">>"); } } else { Serial.printf("[HTTP] POST failed, error: %s\n", hc.errorToString(httpCode).c_str()); } hc.end(); // Clear doc and release memory, then re-initialize trackerJsonDoc.clear(); initJson(); } } // namespace vesta
8049a93f284639b2be1fdeba2fd98dd648b0c831
182e3209cfa49dc3e49e218315689f45c84db203
/Contest3/ex18.cpp
fb5269177352be75d8028db9b10991f17a7d7388
[]
no_license
domiee13/CTDL-GT
a5a014ac984e250f577047ee3fc9890bb21dfc3d
fed87cdc67353a35d63c733022d0650b6d35175e
refs/heads/master
2021-05-24T10:56:08.573543
2021-03-26T15:26:02
2021-03-26T15:26:02
253,528,463
0
0
null
null
null
null
UTF-8
C++
false
false
1,662
cpp
// Hoàng yêu thích các số may mắn. Ta biết rằng một số là số may mắn nếu biểu diễn thập phân của nó chỉ chứa các chữ số may mắn là 4 và 7. Ví dụ, các số 47, 744, 4 là số may mắn và 5, 17, 467 không phải. Hoàng muốn tìm số may mắn bé nhất có tổng các chữ số bằng n. Hãy giúp anh ấy // Dữ liệu vào: Dòng đầu ghi số bộ test, mỗi bộ test có một dòng chứa số nguyên n (1 ≤ n ≤ 10^6) — tổng các chữ số của số may mắn cần tìm. // Kết quả: In ra trên 1 dòng số may mắn bé nhất, mà tổng các chữ số bằng n. Nếu không tồn tại số thỏa mãn, in ra -1. #include <bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; while(t--){ long n; cin>>n; int d4=0,d7=0; //so cac so 4 va so cac so 7 int res4 = 1e5, res7 = 1e5; for(long i = n;i>=0;i--){ if(n>=4*i && (n-4*i)%7==0){ d4 = i; d7 = (n-4*i)/7; if(res4+res7>d4+d7){ res4=d4; res7 = d7; } else if(res4+res7==d4+d7){ if(res4>d4){ res4 = d4; res7 = d7; } } } } if(4*res4+7*res7==n){ for(int i = 0;i<res4;i++){ cout<<4; } for(int i = 0;i<res7;i++){ cout<<7; } cout<<endl; } else cout<<-1<<endl; } return 0; }
da143d272376fbcb446f60887315db4405e96ade
ad934eeba2ac2a3c1d49b02af864790ece137034
/Training/[kuangbin带你飞]专题二十二 区间DP/hdu2476String painter.cpp
b6f75a7b631eacd4c6aecbf8e259c709e28c0579
[]
no_license
xiang578/acm-icpc
19b3d8c7771b935293749f5ccad0591cde8fc896
6f2fdfc62bd689842c80b1caee2d4caf8162d72f
refs/heads/master
2022-01-12T12:28:43.381927
2022-01-12T04:20:44
2022-01-12T04:20:44
39,777,634
0
0
null
null
null
null
UTF-8
C++
false
false
1,580
cpp
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <string> #include <cmath> #include <stdlib.h> #include <time.h> using namespace std; #define rep(i,a,n) for(int i=a;i<n;i++) #define per(i,a,n) for(int i=n-1;i>=a;i--) #define pb push_back typedef vector<int> VI; typedef long long ll; const ll mod=1000000007; const int N=2048; int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int dp[200][200],n,i,j,k,ans[200]; char a[200],b[200]; while(~scanf("%s",a)) { scanf("%s",b); n=strlen(b); memset(dp,0,sizeof(dp)); for(i=0;i<n;i++) for(j=i;j<n;j++) dp[i][j]=j-i+1; for(i=n-1;i>=0;i--) { for(j=i+1;j<n;j++) { dp[i][j]=dp[i+1][j]+1; for(k=i+1; k<=j; k++) { if(b[i]==b[k]) dp[i][j]=min(dp[i][j],dp[i+1][k]+dp[k+1][j]); } } } for(i=0; i<n; i++) ans[i]=dp[0][i]; for(i=0;i<n;i++) { if(a[i]==b[i]) { if(i==0) ans[i]=0; else ans[i]=ans[i-1]; } else { for(j=0;j<i;j++) ans[i]=min(ans[i],ans[j]+dp[j+1][i]); } } printf("%d\n",ans[n-1]); } return 0; }
1fde05890210d7b9d61f0ddd20f7d25e8768d86a
82343bf15e8e14fa72a25f118a0b3992ac1eb638
/umap.cpp
744f8ef85b388184a6ca6dc3621295ef4b93e331
[]
no_license
dopleref/cpp-imp
93dfa6028f4ae3fc297c3029ed29ca52455ff729
3ee71f82fe645e9d7b040eb177a5011ee6c7675b
refs/heads/master
2021-05-16T15:07:23.179200
2018-01-25T11:43:56
2018-01-25T11:43:56
118,905,851
0
0
null
null
null
null
UTF-8
C++
false
false
988
cpp
#include <iostream> #include <map> #include <string> using namespace std; int main() { map<string, int> myFirstMap = {{"Mother", 37}, {"Father", 40}, {"Brother", 15}, {"Sister", 20}}; if (myFirstMap.find("Boris") != myFirstMap.end()) cout << "find Boris" << endl; if (myFirstMap.find("Father") != myFirstMap.end()) cout << "find Father" << endl; cout << "undef val: " << myFirstMap["Boris"] << endl; for (auto it = myFirstMap.begin(); it != myFirstMap.end(); ++it) { cout << it->first << " : " << it->second << endl; } char c; map<char, int> mySecondMap; for (int i = 0, c = 'a'; i < 5; ++i, ++c) { mySecondMap.insert(pair<char, int>(c, i)); } for (auto it = mySecondMap.begin(); it != mySecondMap.end(); ++it) { cout << (*it).first << " : " << (*it).second << endl; } return 0; }
9ed5e5a061fc1795a8c58b9389b42750a359029b
4b26202aa3e245e67f47d6ee85a77ab4c1d3d52d
/One_hot/test_run_dir/gcd.GCDTester1810643262/VGCD.cpp
c4dc319964e12aa9b228cfcb9ee0116ac2ca4189
[]
no_license
Jagpreet-Sifive/Chisel1
afb1bc1b03d9658b899753a49c945030c9004532
468d797bc12a383b371747b09f0ab7c2372cdaa4
refs/heads/master
2020-06-14T00:16:08.724812
2019-07-23T11:17:47
2019-07-23T11:17:47
194,832,699
2
0
null
null
null
null
UTF-8
C++
false
false
6,907
cpp
// Verilated -*- C++ -*- // DESCRIPTION: Verilator output: Design implementation internals // See VGCD.h for the primary calling header #include "VGCD.h" #include "VGCD__Syms.h" //-------------------- // STATIC VARIABLES //-------------------- VL_CTOR_IMP(VGCD) { VGCD__Syms* __restrict vlSymsp = __VlSymsp = new VGCD__Syms(this, name()); VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Reset internal values // Reset structure values _ctor_var_reset(); } void VGCD::__Vconfigure(VGCD__Syms* vlSymsp, bool first) { if (0 && first) {} // Prevent unused this->__VlSymsp = vlSymsp; } VGCD::~VGCD() { delete __VlSymsp; __VlSymsp=NULL; } //-------------------- void VGCD::eval() { VL_DEBUG_IF(VL_DBG_MSGF("+++++TOP Evaluate VGCD::eval\n"); ); VGCD__Syms* __restrict vlSymsp = this->__VlSymsp; // Setup global symbol table VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; #ifdef VL_DEBUG // Debug assertions _eval_debug_assertions(); #endif // VL_DEBUG // Initialize if (VL_UNLIKELY(!vlSymsp->__Vm_didInit)) _eval_initial_loop(vlSymsp); // Evaluate till stable int __VclockLoop = 0; QData __Vchange = 1; do { VL_DEBUG_IF(VL_DBG_MSGF("+ Clock loop\n");); vlSymsp->__Vm_activity = true; _eval(vlSymsp); if (VL_UNLIKELY(++__VclockLoop > 100)) { // About to fail, so enable debug to see what's not settling. // Note you must run make with OPT=-DVL_DEBUG for debug prints. int __Vsaved_debug = Verilated::debug(); Verilated::debug(1); __Vchange = _change_request(vlSymsp); Verilated::debug(__Vsaved_debug); VL_FATAL_MT(__FILE__,__LINE__,__FILE__,"Verilated model didn't converge"); } else { __Vchange = _change_request(vlSymsp); } } while (VL_UNLIKELY(__Vchange)); } void VGCD::_eval_initial_loop(VGCD__Syms* __restrict vlSymsp) { vlSymsp->__Vm_didInit = true; _eval_initial(vlSymsp); vlSymsp->__Vm_activity = true; // Evaluate till stable int __VclockLoop = 0; QData __Vchange = 1; do { _eval_settle(vlSymsp); _eval(vlSymsp); if (VL_UNLIKELY(++__VclockLoop > 100)) { // About to fail, so enable debug to see what's not settling. // Note you must run make with OPT=-DVL_DEBUG for debug prints. int __Vsaved_debug = Verilated::debug(); Verilated::debug(1); __Vchange = _change_request(vlSymsp); Verilated::debug(__Vsaved_debug); VL_FATAL_MT(__FILE__,__LINE__,__FILE__,"Verilated model didn't DC converge"); } else { __Vchange = _change_request(vlSymsp); } } while (VL_UNLIKELY(__Vchange)); } //-------------------- // Internal Methods VL_INLINE_OPT void VGCD::_sequent__TOP__1(VGCD__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::_sequent__TOP__1\n"); ); VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body // ALWAYS at GCD.v:68 if (vlTOPp->io_loadingValues) { vlTOPp->GCD__DOT__y = vlTOPp->io_value2; } else { if ((1U & (~ (IData)(vlTOPp->GCD__DOT___T_17)))) { vlTOPp->GCD__DOT__y = (0xffffU & vlTOPp->GCD__DOT___T_21); } } // ALWAYS at GCD.v:68 if (vlTOPp->io_loadingValues) { vlTOPp->GCD__DOT__x = vlTOPp->io_value1; } else { if (vlTOPp->GCD__DOT___T_17) { vlTOPp->GCD__DOT__x = (0xffffU & vlTOPp->GCD__DOT___T_18); } } vlTOPp->io_outputValid = (0U == (IData)(vlTOPp->GCD__DOT__y)); vlTOPp->io_outputGCD = vlTOPp->GCD__DOT__x; vlTOPp->GCD__DOT___T_17 = ((IData)(vlTOPp->GCD__DOT__x) > (IData)(vlTOPp->GCD__DOT__y)); vlTOPp->GCD__DOT___T_18 = (0x1ffffU & ((IData)(vlTOPp->GCD__DOT__x) - (IData)(vlTOPp->GCD__DOT__y))); vlTOPp->GCD__DOT___T_21 = (0x1ffffU & ((IData)(vlTOPp->GCD__DOT__y) - (IData)(vlTOPp->GCD__DOT__x))); } void VGCD::_settle__TOP__2(VGCD__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::_settle__TOP__2\n"); ); VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body vlTOPp->io_outputGCD = vlTOPp->GCD__DOT__x; vlTOPp->io_outputValid = (0U == (IData)(vlTOPp->GCD__DOT__y)); vlTOPp->GCD__DOT___T_17 = ((IData)(vlTOPp->GCD__DOT__x) > (IData)(vlTOPp->GCD__DOT__y)); vlTOPp->GCD__DOT___T_18 = (0x1ffffU & ((IData)(vlTOPp->GCD__DOT__x) - (IData)(vlTOPp->GCD__DOT__y))); vlTOPp->GCD__DOT___T_21 = (0x1ffffU & ((IData)(vlTOPp->GCD__DOT__y) - (IData)(vlTOPp->GCD__DOT__x))); } void VGCD::_eval(VGCD__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::_eval\n"); ); VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body if (((IData)(vlTOPp->clock) & (~ (IData)(vlTOPp->__Vclklast__TOP__clock)))) { vlTOPp->_sequent__TOP__1(vlSymsp); vlTOPp->__Vm_traceActivity = (2U | vlTOPp->__Vm_traceActivity); } // Final vlTOPp->__Vclklast__TOP__clock = vlTOPp->clock; } void VGCD::_eval_initial(VGCD__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::_eval_initial\n"); ); VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body vlTOPp->__Vclklast__TOP__clock = vlTOPp->clock; } void VGCD::final() { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::final\n"); ); // Variables VGCD__Syms* __restrict vlSymsp = this->__VlSymsp; VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; } void VGCD::_eval_settle(VGCD__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::_eval_settle\n"); ); VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body vlTOPp->_settle__TOP__2(vlSymsp); } VL_INLINE_OPT QData VGCD::_change_request(VGCD__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::_change_request\n"); ); VGCD* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body // Change detection QData __req = false; // Logically a bool return __req; } #ifdef VL_DEBUG void VGCD::_eval_debug_assertions() { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::_eval_debug_assertions\n"); ); // Body if (VL_UNLIKELY((clock & 0xfeU))) { Verilated::overWidthError("clock");} if (VL_UNLIKELY((reset & 0xfeU))) { Verilated::overWidthError("reset");} if (VL_UNLIKELY((io_loadingValues & 0xfeU))) { Verilated::overWidthError("io_loadingValues");} } #endif // VL_DEBUG void VGCD::_ctor_var_reset() { VL_DEBUG_IF(VL_DBG_MSGF("+ VGCD::_ctor_var_reset\n"); ); // Body clock = VL_RAND_RESET_I(1); reset = VL_RAND_RESET_I(1); io_value1 = VL_RAND_RESET_I(16); io_value2 = VL_RAND_RESET_I(16); io_loadingValues = VL_RAND_RESET_I(1); io_outputGCD = VL_RAND_RESET_I(16); io_outputValid = VL_RAND_RESET_I(1); GCD__DOT__x = VL_RAND_RESET_I(16); GCD__DOT__y = VL_RAND_RESET_I(16); GCD__DOT___T_17 = VL_RAND_RESET_I(1); GCD__DOT___T_18 = VL_RAND_RESET_I(17); GCD__DOT___T_21 = VL_RAND_RESET_I(17); __Vm_traceActivity = VL_RAND_RESET_I(32); }
823c3f7ce1cbb892e0670a4f50ec1a3a078f9dd3
b19d78c5b0c65ecb03a705450a4b2bab64635813
/DrawCarWheelTest/Wheel.cpp
e5e923376e9c32e22ce67e3231987def12613395
[]
no_license
yszc-wy/DrawCarWheelTest
f2638d051be4214ad588cd3df015f1f6661d8364
67714842ade022d77b25f6d7fcca2d251c951ef4
refs/heads/master
2023-03-14T02:02:40.037902
2021-02-26T09:15:21
2021-02-26T09:15:21
342,513,662
2
0
null
null
null
null
GB18030
C++
false
false
43,132
cpp
#include "Wheel.h" #include <iostream> #include <fstream> #include <sstream> #include <cmath> #include <algorithm> #include <memory> #include "qstring.h" #include "qmessagebox.h" #include "qiterator.h" #include "FilePath.h" #include "StandardFlangeTreadMsg.h" namespace Wheel { //const unsigned int COLUMN=496; //const unsigned int PLIECOUNT=44; //const unsigned int ROW = PLIECOUNT *2; // //const float STARTSAMPLEPLIE = 29; //const float ENDSAMPLEPLIE = 115; //const float SAMPLESPACING = 1;//mm // //const float PIR = 3.1415926; //const unsigned int CIRCLECOUNT = 629; //float sampleSourceMsg[COLUMN][ROW]; //const unsigned int STANDARDPILECOUNT = 131; //float standardWheelMsg[STANDARDPILECOUNT]; const float WheelFlangeTread::kPIR = 3.1415926; const float WheelFlangeTread::kFitBeginNode = 31.0f;//从32开始拟合,32之前的不变,一直拟合到surveyTreadBegin const float WheelFlangeTread::kFitEndNode = 108.0f;//从surveyTreadEnd拟合到108.0f结束 const float WheelFlangeTread::kSurveyTreadBegin = 50; const float WheelFlangeTread::kSurveyTreadEnd = 80; const float WheelFlangeTread::kStandardTreadRadius = 393.6; //后面要改! const float WheelFlangeTread::kStandardFlangeTreadWidth = 135; const float WheelFlangeTread::kSpreadCircumferenceLength = 600; //展开的圆周宽度 const int WheelFlangeTread::kFloatPlantSection = 720; //Wheel::Wheel(/*const std::string &sampleDataPath, const std::string &type*/) //{ // std::ifstream file("./Resources/CadMsg/SurveyTreadData.txt"); // if (!file.is_open()) { // QString error = "ERROR::WHEEL::SOURCEMSG::UNABLE TO OPEN FILE"; // QMessageBox::warning(NULL, "ERROR!", error, QMessageBox::Ok); // //std::cout << "Unable to open sourceMsg file"<<std::endl; // } // float count; // float *p = &sampleSourceMsg[0][0]; // while (file>>count) // { // *p = count; // ++p; // } // file.close(); // // file.open("./Resources/CadMsg/StandardTreadData.txt"); // if (!file.is_open()) { // QString error = "ERROR::WHEEL::STANDARDMSG::UNABLE TO OPEN FILE"; // QMessageBox::warning(NULL, "ERROR!", error, QMessageBox::Ok); // //std::cout << "Unable to open file" << std::endl; // } // float pile; // float r; // p = &standardWheelMsg[0]; // while (file >> pile >> r) // { // *p = r; // ++p; // } // file.close(); // // std::vector<glm::vec2> otherData; // // //NJ840-2L // //NJ840-4L // //SH13LA // //SH840-4L // //SH840-135 // file.open("./Resources/CadMsg/SH840-135.txt"); // if (!file.is_open()) { // QString error = "ERROR::WHEEL::FLOATPLATE::UNABLE TO OPEN FILE"; // QMessageBox::warning(NULL, "ERROR!", error, QMessageBox::Ok); // //std::cout << "Unable to open file" << std::endl; // } // float x, y; // while (file >> x >> y) // { // otherData.push_back(glm::vec2(x, y)); // } // file.close(); // // std::map<float, std::vector<Polar>> sampleData;//规范化(除0排序)后的采样数据 // // InitSurveyTreadData(sampleData); // // std::map<float, std::vector<Polar>> standardDrawData;//标准0.01角度的绘图数据,用标准轮数据初始化 // // InitStandardTreadData(standardDrawData); // // LoadPoint(sampleData, standardDrawData,otherData); //} Range WheelFlangeTread::get_survey_tread_range() const { return this->survey_tread_range; } //const std::vector<glm::vec2>& Wheel::GetAverRadius() const //{ // return averRadius; //} WheelFlangeTread::WheelFlangeTread(const QVector<QVector2D>& originSurveyFlange, const QMap<float, QVector<float>>& surveyTread/*, const QString type*/) { this->survey_tread_range.SetRange(surveyTread.firstKey(), surveyTread.lastKey()); //std::cout << "TreadStart:" << this->survey_tread_range.GetStart() << " SurveyTreadEnd:" << this->survey_tread_range.GetEnd() << std::endl; //this->InitAverRadius(surveyTread); QVector<QVector2D> surveyFlange = originSurveyFlange; this->InitSurveyFlange(surveyFlange); std::vector<QVector2D> standardOutsideTread; this->InitStandardOutsideTread(standardOutsideTread); //std::map<float, std::vector<Polar>> flangeTread; this->InitFlangeTread(/*flangeTread, */surveyFlange, surveyTread, standardOutsideTread);//拼接拟合flange和tread,再与OutsideTread拟合 this->InitFlangeTreadRRange(); //std::vector<QVector2D> floatPlant; //this->InitFloatPlateData(/*floatPlant, */type); //this->LoadPoint(/*flangeTread, *//*floatPlant*/); } //void Wheel::InitAverRadius(const QMap<float, QVector<float>>& surveyTread) //{ // int section = surveyTread.begin().value().size(); // float unitRadian = 2 * PIR / (float)section; // QMap<float, QVector<float>>::const_iterator map_iterator; // auto begin = surveyTread.constBegin(); // auto end = surveyTread.constEnd(); // for (map_iterator = begin; map_iterator != end; ++map_iterator) // { // glm::vec2 averPoint; // averPoint.x = map_iterator.key(); // double sum = 0; // for (int j = 0; j != section; ++j)//多少截面 // { // sum += map_iterator.value()[j]; // } // averPoint.y = sum / section; // this->averRadius.push_back(averPoint); // //std::cout << averPoint.y << std::endl; // //std::cout << "AverRadius.x:" << averPoint.x << "AverRadius.y:" << averPoint.y << std::endl; // } //} void WheelFlangeTread::InitSurveyFlange(QVector<QVector2D>& surveyFlange) { float dx = 0 - surveyFlange[0].x(); int id = -1; int surveyFlangeSize = surveyFlange.size(); for (int i = 0; i != surveyFlangeSize; ++i) { surveyFlange[i].setX(surveyFlange[i].x() + dx);//平移X校准 if (surveyFlange[i].x() >= survey_tread_range.GetStart())//截断超范围数据 { id = i; break; } } surveyFlange.erase(surveyFlange.begin() + id, surveyFlange.end()); } void WheelFlangeTread::InitStandardOutsideTread(std::vector<QVector2D> &standardOutsideTread)//读取外踏面数据 { std::ifstream file; file.open(FilePath::kStandardOutsideTreadPath); if (!file.is_open()) { QString error = "ERROR::WHEEL::STANDARDOUTSIDETREAD::UNABLE TO OPEN FILE"; QMessageBox::warning(NULL, "ERROR!", error, QMessageBox::Ok); //std::cout << "Unable to open file" << std::endl; } float x, y; float realTread; file >> realTread; float dy = kStandardTreadRadius - realTread;//半径校准 while (file >> x >> y) { if (x <= this->survey_tread_range.GetEnd())//截断超范围数据 { continue; } standardOutsideTread.push_back(QVector2D(x, y + dy));//调整参照半径 } file.close(); } const std::map<float, std::vector<Polar>>& WheelFlangeTread::get_flange_tread() const { return this->flange_tread; } //void Wheel::InitFloatPlateData(/*std::vector<QVector2D> &floatPlant,*/QString type) //{ // std::ifstream file; // QString directory = FilePath::kFloatPlateDirectory + type + ".txt"; // file.open(directory.toStdString()); // if (!file.is_open()) { // QString error = "ERROR::WHEEL::FLOATPLATE::UNABLE TO OPEN FILE,MAY BE THIS FLOAT PLANT TYPE IS UNFINED"; // QMessageBox::warning(NULL, "ERROR!", error, QMessageBox::Ok); // //std::cout << "Unable to open file" << std::endl; // } // float x, y; // float realTread; // file >> realTread; // float dy = STANDARDTREADRADIUS - realTread; // while (file >> x >> y) // { // this->floatPlant.push_back(QVector2D(x, y + dy)); // } // file.close(); //} void WheelFlangeTread::InitFlangeTread(/*std::map<float, std::vector<Polar>> &flangeTread,*/const QVector<QVector2D>& surveyFlange, const QMap<float, QVector<float> >& surveyTread, const std::vector<QVector2D> & standardOutsideTread) { int section = surveyTread.begin().value().size(); float unitRadian = 2 * kPIR / (float)section; int fitFlangePointSize = 0;//需要拟合操作的点数量 int fitFlangePointBeginI = 0; bool first = true; int surveyFlangeCircleSize = surveyFlange.size(); for (int i = 0; i != surveyFlangeCircleSize; ++i)//将激光数据导入轮缘踏面数据集_SurveyFlangeTread { float radian = 0; std::vector<Polar> circlePoint; for (int j = 0; j != section; ++j)//多少截面 { circlePoint.push_back(Polar(surveyFlange[i].y(), radian)); radian += unitRadian; } if (surveyFlange[i].x() > kFitBeginNode) { if (first) { first = false; fitFlangePointBeginI = i; } ++fitFlangePointSize; } this->flange_tread.insert({ surveyFlange[i].x(),circlePoint }); //surveyFlange[i].x<=50mm } //将SurveyTread导入FlangeTread,x范围surveyTreadBegin-surveyTreadEnd QMap<float, QVector<float>>::const_iterator map_iterator; auto begin = surveyTread.constBegin(); auto end = surveyTread.constEnd(); for (map_iterator = begin; map_iterator != end; ++map_iterator) { const QVector<float>& r = map_iterator.value(); float radian = 0; std::vector<Polar> circlePoint; for (int j = 0; j != section; ++j)//多少截面 { circlePoint.push_back(Polar(r[j], radian)); radian += unitRadian; } this->flange_tread.insert({ map_iterator.key(),circlePoint }); } //QList<float>::iterator p = surveyTread.begin(); //float radian = 0; //std::vector<Polar> circlePoint; //for (int i = 0; i != section; ++i)//多少截面 //{ // circlePoint.push_back(Polar(*p, radian)); // ++p; // radian += unitRadian; //} //flangeTread.insert({ 70.0f ,circlePoint }); float surveyTreadMinX = surveyTread.firstKey(); float surveyTreadMaxX = surveyTread.lastKey(); //拟合左侧激光到踏面数据 //获取激光的最大x值的y值 float nearY = surveyFlange[surveyFlangeCircleSize - 1].y(); std::vector<Polar>& leftTread = this->flange_tread[surveyTreadMinX];//SurveyTread最左边的一圈点 for (int i = 0; i != section; ++i)//拟合 { float dr = leftTread[i].r - nearY; float ddr = dr / fitFlangePointSize; float k = 0; for (int j = fitFlangePointBeginI; j != surveyFlangeCircleSize; ++j)//拟合到SurveyFlange末尾 { this->flange_tread[surveyFlange[j].x()][i].r = surveyFlange[j].y() + ddr*(k++); } } //导入标准外踏面数据,再用tread与其拟合 int standardOutsideTreadCircleSize = standardOutsideTread.size(); int fitOutsideTreadPointSize = 0;//需要拟合操作的点数量 int fitOutsideTreadPointEndI = 0; first = true; for (int i = 0; i != standardOutsideTreadCircleSize; ++i) { float radian = 0; std::vector<Polar> circlePoint; for (int j = 0; j != section; ++j)//多少截面 { circlePoint.push_back(Polar(standardOutsideTread[i].y(), radian)); radian += unitRadian; } if (standardOutsideTread[i].x() < kFitEndNode) { ++fitOutsideTreadPointSize; } else { if (first) { first = false; fitOutsideTreadPointEndI = i; } } this->flange_tread.insert({ standardOutsideTread[i].x(),circlePoint }); //surveyFlange[i].x<=50mm } //拟合右边 nearY = standardOutsideTread[0].y(); std::vector<Polar>& rightTread = this->flange_tread[surveyTreadMaxX];//SurveyTread最右边的一圈点 for (int i = 0; i != section; ++i)//拟合 { float dr = rightTread[i].r - nearY; float ddr = dr / fitOutsideTreadPointSize; float k = 0; for (int j = fitOutsideTreadPointEndI - 1; j >= 0; --j)//拟合到SurveyFlange末尾 { this->flange_tread[standardOutsideTread[j].x()][i].r = standardOutsideTread[j].y() + ddr*(k++); } } } std::vector<glm::vec2> WheelFlangeTread::LoadStandardTread(const DxfReader::StandardFlangeTreadMsgMaker& sft_msg_maker) const { std::vector<glm::vec2> standardTreadMsg; //StandardFlangeTreadMsgMake stmMake(FilePath::kExampleStandardTreadPath); auto begin = this->flange_tread.cbegin(); auto end = this->flange_tread.cend(); for (std::map<float, std::vector<Polar>>::const_iterator i = begin; i != end; ++i)//每一圈 { standardTreadMsg.push_back(glm::vec2(i->first, sft_msg_maker.GetHeight(i->first))); } return standardTreadMsg; } WheelSpreadMsg WheelFlangeTread::LoadSpreadFlangeTreadPoint(/*const StandardFlangeTreadMsgMake& sft_msg_maker*/) const { std::vector<Vertex> vertices; std::vector<unsigned int> indices; //std::vector<glm::vec2> standardTreadMsg; int flangeTreadCircleSize = this->flange_tread.size(); int section = this->flange_tread.begin()->second.size(); //float circumference = 2.0f * PIR* STANDARDTREADRADIUS; float circumference = kSpreadCircumferenceLength; float unitDis = circumference / static_cast<float>(section); float startX = 0; float endX = circumference; // //StandardFlangeTreadMsgMake stmMake(FilePath::kExampleStandardTreadPath); //flangeTread转顶点, //寻找最大和最小Y //bool first = true; //float minY; //float maxY; auto begin = this->flange_tread.cbegin(); auto end = this->flange_tread.cend(); std::vector<Vertex> ciclePoint; Vertex vertex; for (std::map<float, std::vector<Polar>>::const_iterator i = begin; i != end; ++i)//每一圈 { vertex.Normal = glm::vec3(0.0f); for (int j = 0; j != section; ++j) //每一圈上的点 { //if (first) //{ // maxY = i->second[j].r - STANDARDTREADRADIUS;//高度数据除去 // minY = i->second[j].r - STANDARDTREADRADIUS; // first = false; //} //else //{ // if (i->second[j].r > maxY) // { // maxY = i->second[j].r - STANDARDTREADRADIUS; // } // if (i->second[j].r < minY) // { // minY = i->second[j].r - STANDARDTREADRADIUS; // } //} vertex.Position = glm::vec3(startX + j*unitDis, i->second[j].r - kStandardTreadRadius, i->first);//删去了 ciclePoint.push_back(vertex); } //standardTreadMsg.push_back(glm::vec2(i->first, sft_msg_maker.GetMakeZeroHeight(i->first))); vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 ciclePoint.clear(); } //std::cout << "MsgCount:" << standardTreadMsg.size() << std::endl; //test //std::cout << "Msg:" << std::endl; //for (auto i : standardTreadMsg) //{ // std::cout << i.x << " " << i.y << std::endl; //} size_t flangeTreadVerticesSize = vertices.size();//得到flangeTread总共的点数 //flangeTread的indices for (int i = 0; i != flangeTreadCircleSize - 1; ++i)//最后一层不用操作 { int currentMuit = section * i; int nextMuit = section * (i + 1); for (int j = 0; j != section - 1; ++j) //不连接 { //正方形第一个三角形 indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 indices.push_back(nextMuit + (j + 1) % section); //nextMuit + (j + 1) % section indices.push_back(nextMuit + j);//nextMuit + j //正方形第二个三角形 indices.push_back(currentMuit + j); indices.push_back(currentMuit + (j + 1) % section);//currentMuit + (j + 1) % section indices.push_back(nextMuit + (j + 1) % section);//nextMuit + (j + 1) % section } } size_t flangeTreadIndicesSize = indices.size(); //计算flangeTread法向量 glm::vec3 a, b; for (int i = 0; i < flangeTreadIndicesSize; i += 3) { a = vertices[indices[i + 1]].Position - vertices[indices[i]].Position; b = vertices[indices[i + 2]].Position - vertices[indices[i + 1]].Position; vertices[indices[i]].Normal += glm::cross(a, b); vertices[indices[i + 1]].Normal += glm::cross(a, b); vertices[indices[i + 2]].Normal += glm::cross(a, b); } WheelSpreadMsg smg; smg.wheelMsg.SetMsg_Move(std::move(vertices), std::move(indices)); smg.wheelSpreadParm = WheelSpreadParm(0.05, unitDis, Range(startX, endX), this->survey_tread_range, WheelColorContrast(Range(this->flange_tread_r_range.GetMin() - kStandardTreadRadius, this->flange_tread_r_range.GetMax() - kStandardTreadRadius))); return smg; } void WheelFlangeTread::InitFlangeTreadRRange() { bool first = true; float minR; float maxR; auto begin = this->flange_tread.cbegin(); auto end = this->flange_tread.cend(); int section = this->flange_tread.begin()->second.size(); for (std::map<float, std::vector<Polar>>::const_iterator i = begin; i != end; ++i)//每一圈 { for (int j = 0; j != section; ++j) //每一圈上的点 { if (first) { maxR = i->second[j].r; minR = i->second[j].r; first = false; } else { if (i->second[j].r > maxR) { maxR = i->second[j].r; } if (i->second[j].r < minR) { minR = i->second[j].r; } } } } this->flange_tread_r_range = Range(minR, maxR); } Range WheelFlangeTread::get_flange_tread_r_range() const { return this->flange_tread_r_range; } //WheelOpenglMsg Wheel::LoadConnection() //{ // std::vector<Vertex> vertices; // std::vector<unsigned int> indices; // int section = this->flangeTread.begin()->second.size(); // float unitRadian = 2 * PIR / (float)section; // std::vector<Vertex> ciclePoint; // Vertex vertex; // //轮缘踏面第一圈的连接点 // std::map<float, std::vector<Polar>>::iterator firstCircle = this->flangeTread.begin(); // vertex.Normal = glm::vec3(0.0f); // for (int i = 0; i != section; ++i) //每一圈上的点 // { // vertex.Position = glm::vec3(firstCircle->second[i].ConvertToXY(), firstCircle->first); // ciclePoint.push_back(vertex); // } // vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 // ciclePoint.clear(); //} //WheelOpenglMsg Wheel::LoadFloatPlantPoint() //{ // std::vector<Vertex> vertices; // std::vector<unsigned int> indices; // int section = this->flangeTread.begin()->second.size(); // float unitRadian = 2 * PIR / (float)section; // std::vector<Vertex> ciclePoint; // Vertex vertex; // //第一圈的连接点 // std::map<float, std::vector<Polar>>::iterator firstCircle= this->flangeTread.begin(); // vertex.Normal = glm::vec3(0.0f); // for (int i = 0; i != section; ++i) //每一圈上的点 // { // vertex.Position = glm::vec3(firstCircle->second[i].ConvertToXY(), firstCircle->first); // ciclePoint.push_back(vertex); // } // vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 // ciclePoint.clear(); // //// // //floatPlant转顶点 // size_t floatPlantCircleSize = this->floatPlant.size(); // Polar polar; // for (int i = 0; i != floatPlantCircleSize; ++i) // { // //std::vector<Vertex> ciclePoint; // polar.r = this->floatPlant[i].y(); // float radian = 0; // for (int j = 0; j != section; ++j) //每一圈上的点 // { // polar.radian = radian; // vertex.Position = glm::vec3(polar.ConvertToXY(), this->floatPlant[i].x()); // ciclePoint.push_back(vertex); // radian += unitRadian; // } // vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 // ciclePoint.clear(); // } // //第二圈的连接点 // std::map<float, std::vector<Polar>>::reverse_iterator lastCircle = this->flangeTread.rbegin(); // vertex.Normal = glm::vec3(0.0f); // for (int i = 0; i != section; ++i) //每一圈上的点 // { // vertex.Position = glm::vec3(lastCircle->second[i].ConvertToXY(), lastCircle->first); // ciclePoint.push_back(vertex); // } // vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 // ciclePoint.clear(); // //// // //floatPlant的indices // for (int i = 0; i != floatPlantCircleSize + 2 - 1; ++i)//最后一层不要操作 // { // int currentMuit = section*i; // int nextMuit = section * (i + 1); // for (int j = 0; j != section; ++j) // { // //正方形第一个三角形 // indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 // indices.push_back(nextMuit + j); // indices.push_back(nextMuit + (j + 1) % section); // //正方形第二个三角形 // indices.push_back(currentMuit + j); // indices.push_back(nextMuit + (j + 1) % section); // indices.push_back(currentMuit + (j + 1) % section); // } // } // //计算floatPlant法向量 // glm::vec3 a, b; // for (int i = 0; i < indices.size(); i += 3) // { // a = vertices[indices[i + 1]].Position - vertices[indices[i]].Position; // b = vertices[indices[i + 2]].Position - vertices[indices[i + 1]].Position; // vertices[indices[i]].Normal += glm::cross(a, b); // vertices[indices[i + 1]].Normal += glm::cross(a, b); // vertices[indices[i + 2]].Normal += glm::cross(a, b); // } // return WheelOpenglMsg(std::move(vertices), std::move(indices)); //} OpenglObj::OpenglPointMsg WheelFlangeTread::LoadFlangeTreadPoint(/*std::map<float, std::vector<Polar>> &flangeTread,*/ /*std::vector<QVector2D> &floatPlant*/) const { std::vector<Vertex> vertices; std::vector<unsigned int> indices; int flangeTreadCircleSize = this->flange_tread.size(); int section = this->flange_tread.begin()->second.size(); float unitRadian = 2 * kPIR / (float)section; //flangeTread转顶点 auto begin = this->flange_tread.cbegin(); auto end = this->flange_tread.cend(); std::vector<Vertex> ciclePoint; Vertex vertex; for (std::map<float, std::vector<Polar>>::const_iterator i = begin; i != end; ++i)//每一圈 { vertex.Normal = glm::vec3(0.0f); for (int j = 0; j != section; ++j) //每一圈上的点 { vertex.Position = glm::vec3(i->second[j].ConvertToXY(), i->first); ciclePoint.push_back(vertex); } vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 ciclePoint.clear(); } size_t flangeTreadVerticesSize = vertices.size();//得到flangeTread总共的点数 ////floatPlant转顶点 //size_t floatPlantCircleSize = this->floatPlant.size(); //Polar polar; //for (int i = 0; i != floatPlantCircleSize; ++i) //{ // //std::vector<Vertex> ciclePoint; // polar.r = this->floatPlant[i].y(); // Vertex vertex; // float radian = 0; // for (int j = 0; j != section; ++j) //每一圈上的点 // { // polar.radian = radian; // vertex.Position = glm::vec3(polar.ConvertToXY(), this->floatPlant[i].x()); // ciclePoint.push_back(vertex); // radian += unitRadian; // } // vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 // ciclePoint.clear(); //} //flangeTread的indices for (int i = 0; i != flangeTreadCircleSize - 1; ++i)//最后一层不用操作 { int currentMuit = section * i; int nextMuit = section * (i + 1); for (int j = 0; j != section; ++j) { //正方形第一个三角形 indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 indices.push_back(nextMuit + (j + 1) % section); //nextMuit + (j + 1) % section indices.push_back(nextMuit + j);//nextMuit + j //正方形第二个三角形 indices.push_back(currentMuit + j); indices.push_back(currentMuit + (j + 1) % section);//currentMuit + (j + 1) % section indices.push_back(nextMuit + (j + 1) % section);//nextMuit + (j + 1) % section } } size_t flangeTreadIndicesSize = indices.size(); ////floatPlant的indices //for (int i = 0; i != floatPlantCircleSize; ++i) //{ // int currentMuit = section*i + flangeTreadVerticesSize; // int nextMuit = section * (i + 1) + flangeTreadVerticesSize; // if (i != floatPlantCircleSize - 1) // { // for (int j = 0; j != section; ++j) // { // //正方形第一个三角形 // indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 // indices.push_back(nextMuit + j); // indices.push_back(nextMuit + (j + 1) % section); // //正方形第二个三角形 // indices.push_back(currentMuit + j); // indices.push_back(nextMuit + (j + 1) % section); // indices.push_back(currentMuit + (j + 1) % section); // } // } // if (i == 0)//链接flangeTread第一圈 // { // for (int j = 0; j != section; ++j) // { // //正方形第一个三角形 // indices.push_back(j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 // indices.push_back(currentMuit + j); // indices.push_back(currentMuit + (j + 1) % section); // //正方形第二个三角形 // indices.push_back(j); // indices.push_back(currentMuit + (j + 1) % section); // indices.push_back((j + 1) % section); // } // } // else if (i == floatPlantCircleSize - 1)//链接tread最后一圈 // { // nextMuit = section*(flangeTreadCircleSize - 1); // for (int j = 0; j != section; ++j) // { // //正方形第一个三角形 // indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 // indices.push_back(nextMuit + j); // indices.push_back(nextMuit + (j + 1) % section); // //正方形第二个三角形 // indices.push_back(currentMuit + j); // indices.push_back(nextMuit + (j + 1) % section); // indices.push_back(currentMuit + (j + 1) % section); // } // } //} //计算flangeTread法向量 glm::vec3 a, b; for (int i = 0; i < flangeTreadIndicesSize; i += 3) { a = vertices[indices[i + 1]].Position - vertices[indices[i]].Position; b = vertices[indices[i + 2]].Position - vertices[indices[i + 1]].Position; vertices[indices[i]].Normal += glm::cross(a, b); vertices[indices[i + 1]].Normal += glm::cross(a, b); vertices[indices[i + 2]].Normal += glm::cross(a, b); } //计算floatPlant法向量 /*for (int i = flangeTreadIndicesSize; i < indices.size(); i += 3) { a = vertices[indices[i + 1]].Position - vertices[indices[i]].Position; b = vertices[indices[i + 2]].Position - vertices[indices[i + 1]].Position; vertices[indices[i]].Normal += glm::cross(a, b); vertices[indices[i + 1]].Normal += glm::cross(a, b); vertices[indices[i + 2]].Normal += glm::cross(a, b); }*/ return OpenglObj::OpenglPointMsg(std::move(vertices), std::move(indices)); } QVector<QVector2D> WheelFlangeTread::GetSection(float radian) { QVector<QVector2D> oneSection; if (radian < 0 || radian>2 * kPIR) { std::cout << "ERROR::WHEEL::GETSECTION::ILLEGAL RADIAN" << std::endl; } else { int section = this->flange_tread.begin()->second.size(); float unitRadian = 2 * kPIR / (float)section; int id = radian / unitRadian; for (auto i : this->flange_tread) { oneSection.push_back(QVector2D(i.first, i.second[id].r)); } } return oneSection; } std::vector<glm::vec2> InitFloatPlate(const std::string& filePath) { std::vector<glm::vec2> floatPlant; std::ifstream file; std::string directory = filePath; file.open(directory); if (!file.is_open()) { QString error = "ERROR::WHEELDISPLAY::FLOATPLATE::UNABLE TO OPEN FILE,MAY BE THIS FLOAT PLANT TYPE IS UNFINED"; QMessageBox::warning(NULL, "ERROR!", error, QMessageBox::Ok); return floatPlant; //std::cout << "Unable to open file" << std::endl; } float x, y; float realTread; file >> realTread; float dy = WheelFlangeTread::kStandardTreadRadius - realTread;//把所有的floatplate flange tread都校准到标准的半径上来 while (file >> x >> y) { floatPlant.push_back(glm::vec2(x, y + dy)); } file.close(); return floatPlant; } OpenglObj::OpenglPointMsg LoadFloatPlantPoint(const std::vector<glm::vec2>& floatPlant) { std::vector<Vertex> vertices; std::vector<unsigned int> indices; int section = WheelFlangeTread::kFloatPlantSection; float unitRadian = 2 * WheelFlangeTread::kPIR / (float)section; std::vector<Vertex> ciclePoint; Vertex vertex; //floatPlant转顶点 size_t floatPlantCircleSize = floatPlant.size(); Polar polar; for (int i = 0; i != floatPlantCircleSize; ++i) { //std::vector<Vertex> ciclePoint; polar.r = floatPlant[i].y; vertex.Normal = glm::vec3(0.0f); float radian = 0; for (int j = 0; j != section; ++j) //每一圈上的点 { polar.radian = radian; vertex.Position = glm::vec3(polar.ConvertToXY(), floatPlant[i].x); ciclePoint.push_back(vertex); radian += unitRadian; } vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 ciclePoint.clear(); } //floatPlant的indices for (int i = 0; i != floatPlantCircleSize - 1; ++i)//最后一层不要操作 { int currentMuit = section*i; int nextMuit = section * (i + 1); for (int j = 0; j != section; ++j) { //正方形第一个三角形 indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 indices.push_back(nextMuit + j); indices.push_back(nextMuit + (j + 1) % section); //正方形第二个三角形 indices.push_back(currentMuit + j); indices.push_back(nextMuit + (j + 1) % section); indices.push_back(currentMuit + (j + 1) % section); } } //计算floatPlant法向量 glm::vec3 a, b; for (int i = 0; i < indices.size(); i += 3) { a = vertices[indices[i + 1]].Position - vertices[indices[i]].Position; b = vertices[indices[i + 2]].Position - vertices[indices[i + 1]].Position; vertices[indices[i]].Normal += glm::cross(a, b); vertices[indices[i + 1]].Normal += glm::cross(a, b); vertices[indices[i + 2]].Normal += glm::cross(a, b); } return OpenglObj::OpenglPointMsg(std::move(vertices), std::move(indices)); } OpenglObj::OpenglPointMsg LoadConnectionPoint(const std::map<float, std::vector<Polar>>& flangeTread, const std::vector<glm::vec2> & floatPlant) { std::vector<Vertex> vertices; std::vector<unsigned int> indices; int section = flangeTread.begin()->second.size(); float unitRadian = 2 * WheelFlangeTread::kPIR / (float)section; std::vector<Vertex> ciclePoint; Vertex vertex; //轮缘踏面第一圈的连接点 std::map<float, std::vector<Polar>>::const_iterator firstCircle = flangeTread.begin(); vertex.Normal = glm::vec3(0.0f); for (int i = 0; i != section; ++i) //每一圈上的点 { vertex.Position = glm::vec3(firstCircle->second[i].ConvertToXY(), firstCircle->first); ciclePoint.push_back(vertex); } vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 ciclePoint.clear(); //浮板第一圈 size_t floatPlantCircleSize = floatPlant.size(); Polar polar; int firstId = 0; polar.r = floatPlant[firstId].y; float radian = 0; for (int i = 0; i != section; ++i) { polar.radian = radian; vertex.Position = glm::vec3(polar.ConvertToXY(), floatPlant[firstId].x); ciclePoint.push_back(vertex); radian += unitRadian; } vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 ciclePoint.clear(); //浮板第二圈 int lastId = floatPlantCircleSize-1; polar.r = floatPlant[lastId].y; radian = 0; for (int i = 0; i != section; ++i) { polar.radian = radian; vertex.Position = glm::vec3(polar.ConvertToXY(), floatPlant[lastId].x); ciclePoint.push_back(vertex); radian += unitRadian; } vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 ciclePoint.clear(); //轮缘踏面最后一圈的连接点 std::map<float, std::vector<Polar>>::const_reverse_iterator lastCircle = flangeTread.rbegin(); vertex.Normal = glm::vec3(0.0f); for (int i = 0; i != section; ++i) //每一圈上的点 { vertex.Position = glm::vec3(lastCircle->second[i].ConvertToXY(), lastCircle->first); ciclePoint.push_back(vertex); } vertices.insert(vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 ciclePoint.clear(); //连接 for (int i = 0; i != 4; i+=2)//最后一层不要操作,连接0-1,2-3 { int currentMuit = section*i; int nextMuit = section * (i + 1); for (int j = 0; j != section; ++j) { //正方形第一个三角形 indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 indices.push_back(nextMuit + j); indices.push_back(nextMuit + (j + 1) % section); //正方形第二个三角形 indices.push_back(currentMuit + j); indices.push_back(nextMuit + (j + 1) % section); indices.push_back(currentMuit + (j + 1) % section); } } //计算连接法向量 glm::vec3 a, b; for (int i = 0; i < indices.size(); i += 3) { a = vertices[indices[i + 1]].Position - vertices[indices[i]].Position; b = vertices[indices[i + 2]].Position - vertices[indices[i + 1]].Position; vertices[indices[i]].Normal += glm::cross(a, b); vertices[indices[i + 1]].Normal += glm::cross(a, b); vertices[indices[i + 2]].Normal += glm::cross(a, b); } return OpenglObj::OpenglPointMsg(std::move(vertices), std::move(indices)); } //void Wheel::InitStandardTreadData(std::map<float, std::vector<Polar>>& standardDrawData/*,const std::string &type*/) //{ // for (int plie = 0; plie != STANDARDPILECOUNT; ++plie) // { // float radian = 0; // std::vector<Polar> circlePoint; // while (radian < 2 * PIR) // { // circlePoint.push_back(Polar(standardWheelMsg[plie], radian)); // radian += 0.01f; // } // standardDrawData.insert({ plie,circlePoint }); // } //} //void Wheel::InitSurveyTreadData(std::map<float, std::vector<Polar>>& sampleData) //{ // for (int j = 0; j != ROW; j += 2) // { // float plie = STARTSAMPLEPLIE + j; // std::vector<Polar> circlePolarPoint; // for (int i = 0; i != COLUMN; ++i) // { // float x = sampleSourceMsg[i][j]; // float y = sampleSourceMsg[i][j + 1]; // if (x == 0 && y == 0) // { // continue; // } // float r = sqrtf(pow(x, 2) + pow(y, 2)); // float radian = atan2(y, x); // radian = radian < 0 ? (radian + 2 * PIR) : radian; // // sampleSourceMsg[i][j] = r; // sampleSourceMsg[i][j + 1] = radian; // circlePolarPoint.push_back(Polar(r, radian)); // } // sort(circlePolarPoint.begin(), circlePolarPoint.end(), [](const Polar& a, const Polar &b) {return a.radian < b.radian; }); // sampleData.insert({ plie ,circlePolarPoint }); // } //} ////float Wheel::GetAverRadius(float plie, float radian, std::map<float, std::vector<Polar>>& sampleData) ////{ //// //std::cout << "???" << std::endl; //// //二分查找 //// const std::vector<Polar>& thisPlie = sampleData[plie]; //// unsigned int count = thisPlie.size(); //// //// int mid, left = 0, right = count - 1;//闭区间[0, n - 1] //// while (left < right) //// { //// mid = left + ((right + 1 - left) >> 1);//向上取整 //// if (thisPlie[mid].radian < radian) left = mid; //// else right = mid - 1; //// } //// //// int a, b; //// if (thisPlie[left].radian < radian) //// { //// a = left; //// b = (left + 1) % count; //处理好边界 //// } //// else //// { //// a = count - 1; //// b = 0; //// } //// //// //std::cout << "radian:"<<radian<<" " << std::endl; //// return (thisPlie[a].r + thisPlie[b].r) / 2.0f; //// ////} ////void Wheel::LoadPoint(std::map<float, std::vector<Polar>>& sampleData, std::map<float, std::vector<Polar>>& standardDrawData, std::vector<glm::vec2>& otherData) ////{ //// for (int plie = STARTSAMPLEPLIE; plie < ENDSAMPLEPLIE+1; plie += 2)//为stardardDarwData添加采样数据 //// { //// float radian = 0; //// int i = 0; //// while (radian<2*PIR) //// { //// Polar position(GetAverRadius(plie, radian, sampleData),radian); //// standardDrawData[plie][i] = position; //// radian += 0.01f; //// ++i; //// } //// } //// for (int plie = STARTSAMPLEPLIE + 1; plie < ENDSAMPLEPLIE; plie += 2)//平均采样区间未赋值数据 //// { //// float radian = 0; //// int i = 0; //// while (radian<2 * PIR) //// { //// standardDrawData[plie][i].r = (standardDrawData[plie - 1][i].r + standardDrawData[plie + 1][i].r) / 2; //// radian += 0.01f; //// ++i; //// } //// } //// //// //// //// for (int plie = 0; plie != STANDARDPILECOUNT; ++plie) //// { //// std::vector<Vertex> ciclePoint; //// Vertex vertex; //// vertex.Normal = glm::vec3(0.0f); //// for (int i = 0; i != CIRCLECOUNT; ++i) //// { //// vertex.Position = glm::vec3(standardDrawData[plie][i].ConvertToXY(), plie); //// ciclePoint.push_back(vertex); //// } //// this->vertices.insert(this->vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 //// } //// size_t treadVerticesSize = this->vertices.size(); //// //// size_t otherDataSize = otherData.size(); //// for (int i = 0; i != otherDataSize; ++i) //// { //// std::vector<Vertex> ciclePoint; //// Polar polar; //// polar.r = otherData[i].y; //// Vertex vertex; //// //// float radian = 0; //// while (radian<2 * PIR) //// { //// polar.radian = radian; //// vertex.Position = glm::vec3(polar.ConvertToXY(), otherData[i].x); //// ciclePoint.push_back(vertex); //// //// radian += 0.01f; //// } //// //// this->vertices.insert(this->vertices.end(), ciclePoint.begin(), ciclePoint.end());//形成顶点数组 //// } //// //// for (int i = 0; i != STANDARDPILECOUNT-1; ++i)//最后一层不用操作 //// { //// int currentMuit = CIRCLECOUNT * i; //// int nextMuit = CIRCLECOUNT * (i+1); //// for (int j = 0; j != CIRCLECOUNT; ++j) //// { //// //正方形第一个三角形 //// this->indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 //// this->indices.push_back(nextMuit + j); //// this->indices.push_back(nextMuit + (j + 1) % CIRCLECOUNT); //// //正方形第二个三角形 //// this->indices.push_back(currentMuit + j); //// this->indices.push_back(nextMuit + (j + 1)% CIRCLECOUNT); //// this->indices.push_back(currentMuit + (j + 1)% CIRCLECOUNT); //// } //// } //// size_t treadIndicesSize = this->indices.size(); //// //// //// //// //otherData indices //// for (int i = 0; i != otherDataSize; ++i) //// { //// int currentMuit = CIRCLECOUNT*i+ treadVerticesSize; //// int nextMuit = CIRCLECOUNT * (i + 1)+ treadVerticesSize; //// if (i != otherDataSize - 1) //// { //// for (int j = 0; j != CIRCLECOUNT; ++j) //// { //// //正方形第一个三角形 //// this->indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 //// this->indices.push_back(nextMuit + j); //// this->indices.push_back(nextMuit + (j + 1) % CIRCLECOUNT); //// //正方形第二个三角形 //// this->indices.push_back(currentMuit + j); //// this->indices.push_back(nextMuit + (j + 1) % CIRCLECOUNT); //// this->indices.push_back(currentMuit + (j + 1) % CIRCLECOUNT); //// } //// } //// //// if (i == 0)//链接tread第一圈 //// { //// for (int j = 0; j != CIRCLECOUNT; ++j) //// { //// //正方形第一个三角形 //// this->indices.push_back(j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 //// this->indices.push_back(currentMuit + j); //// this->indices.push_back(currentMuit + (j + 1) % CIRCLECOUNT); //// //正方形第二个三角形 //// this->indices.push_back(j); //// this->indices.push_back(currentMuit + (j + 1) % CIRCLECOUNT); //// this->indices.push_back((j + 1) % CIRCLECOUNT); //// } //// } //// else if (i == otherDataSize - 1)//链接tread最后一圈 //// { //// nextMuit = CIRCLECOUNT*(STANDARDPILECOUNT - 1); //// for (int j = 0; j != CIRCLECOUNT; ++j) //// { //// //正方形第一个三角形 //// this->indices.push_back(currentMuit + j); //只需要让其全部按一圈排列就行,无论顺还是逆时针 //// this->indices.push_back(nextMuit + j); //// this->indices.push_back(nextMuit + (j + 1) % CIRCLECOUNT); //// //正方形第二个三角形 //// this->indices.push_back(currentMuit + j); //// this->indices.push_back(nextMuit + (j + 1) % CIRCLECOUNT); //// this->indices.push_back(currentMuit + (j + 1) % CIRCLECOUNT); //// } //// } //// //// } //// //// //计算踏面法向量 //// for (int i = 0; i < treadIndicesSize; i += 3) //// { //// glm::vec3 a, b; //// a = this->vertices[this->indices[i + 1]].Position - this->vertices[this->indices[i]].Position; //// b = this->vertices[this->indices[i + 2]].Position - this->vertices[this->indices[i + 1]].Position; //// //// this->vertices[this->indices[i]].Normal += -glm::cross(a, b); //// this->vertices[this->indices[i + 1]].Normal += -glm::cross(a, b); //// this->vertices[this->indices[i + 2]].Normal += -glm::cross(a, b); //// } //// //// //计算other法向量 //// for (int i = treadIndicesSize; i < this->indices.size(); i += 3) //// { //// glm::vec3 a, b; //// a = this->vertices[this->indices[i + 1]].Position - this->vertices[this->indices[i]].Position; //// b = this->vertices[this->indices[i + 2]].Position - this->vertices[this->indices[i + 1]].Position; //// //// this->vertices[this->indices[i]].Normal += glm::cross(a, b); //// this->vertices[this->indices[i + 1]].Normal += glm::cross(a, b); //// this->vertices[this->indices[i + 2]].Normal += glm::cross(a, b); //// } //// ////} //std::vector<glm::vec3> Wheel::GetPositonArray() //{ // //this->vertices = new float[486 * 88]; // //} //std::vector<unsigned int> Wheel::GetIndicesArray() //{ // //} WheelFlangeTread::~WheelFlangeTread() { //delete[] vertices; //delete[] indices; } //const std::vector<Vertex>& Wheel::GetVertices() const //{ // return vertices; //} //const std::vector<unsigned int>& Wheel::GetIndices() const //{ // return indices; //} //int m, l = 0, r = averSize - 1;//闭区间[0, averSize - 1] //while (l < r) //{ // m = l + ((r + 1 - l) >> 1);//向上取整 // if (averRadius[m].x < width) l = m; // else r = m - 1; //} //if ((l == averSize - 1 && abs(averRadius[l].x - width) <= 0.0001) || (l != averSize - 1 && averRadius[l].x <= width)) //{ // return l; //} //else //return -1; }
54be60b1adb4f18bec1db60f3f8397ea6f13af5e
bc92c058b0c2dd2877648e30156245e36ee571a4
/source/common/xstream/framework/example/bbox_filter/src/method_factory.cpp
ec97ef73e88c60a7220eb80f4da70f13de33356e
[ "BSD-2-Clause" ]
permissive
robort-yuan/AI-EXPRESS
c1783f5f155b918dcc6da11956c842ae5467de8e
56f86d03afbb09f42c21958c8cd9f2f1c6437f48
refs/heads/master
2023-02-09T03:51:44.775020
2021-01-02T15:15:37
2021-01-02T15:15:37
309,591,131
0
0
BSD-2-Clause
2020-12-08T07:48:54
2020-11-03T06:11:06
null
UTF-8
C++
false
false
591
cpp
/** * @file method_factory.cpp * @author your name ([email protected]) * @brief DO NOT MODIFY THIS FILE, WHICH IS AUTO GENERATED BY COMPILER * @version 0.1 * @date 2018-11-23 * * @copyright Copyright (c) 2018 * */ #include <string> #include "hobotxstream/method_factory.h" #include "method/bbox_filter.h" namespace xstream { namespace method_factory { MethodPtr CreateMethod(const std::string &method_name) { if ("BBoxFilter" == method_name) { return MethodPtr(new BBoxFilter()); } else { return MethodPtr(); } } } // namespace method_factory } // namespace xstream
019e8f6e5c7d158a5cb8524f2aad1144aaabcea7
c657239117794e9df2acac79f31c25001729a331
/examples/sample-app2/src/libsum10/sum4.cpp
a138240359749b1d2d0de4a36af68e81e39a6230
[ "MIT" ]
permissive
m1nuz/bump
8a3081c66297645b21cb3504325ced1286b67d68
a6d4fe7d30763368492674a2b815b23ffc75af4d
refs/heads/master
2020-04-04T21:33:10.587634
2019-11-11T23:35:28
2019-11-11T23:35:28
156,290,590
0
0
null
null
null
null
UTF-8
C++
false
false
104
cpp
#include "libsum/sum.h" extern int sum4( const int a, const int b ) noexcept { return a + b + 4; }
cf635c0a8cf8a9807eb2c55fde9e2c96aea5747f
844a8e335ccab4653d4a083d626ef2f6580e7b20
/ThirdParty/SFML/include/SFML/Graphics/Glsl.hpp
acc647cea70b9111c01d66587904d5e8cfb8c105
[ "MIT" ]
permissive
zpervan/GameOfLife
df81267e547137a529884f215fabef17080e67ff
5b9e645e72134b500c9d584092efd60cd530b8f2
refs/heads/main
2023-04-27T02:57:47.021080
2023-04-18T10:04:35
2023-04-19T09:44:07
303,808,018
5
1
null
null
null
null
UTF-8
C++
false
false
7,232
hpp
//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007-2018 Laurent Gomila ([email protected]) // // This software is provided 'as-is', without any express or implied warranty. // In no event will the authors be held liable for any damages arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it freely, // subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; // you must not claim that you wrote the original software. // If you use this software in a product, an acknowledgment // in the product documentation would be appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, // and must not be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // //////////////////////////////////////////////////////////// #ifndef SFML_GLSL_HPP #define SFML_GLSL_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include "include/SFML/Graphics/Color.hpp" #include "include/SFML/Graphics/Transform.hpp" #include "include/SFML/System/Vector2.hpp" #include "include/SFML/System/Vector3.hpp" namespace sf { namespace priv { // Forward declarations template <std::size_t Columns, std::size_t Rows> struct Matrix; template <typename T> struct Vector4; #include "include/SFML/Graphics/Glsl.inl" } // namespace priv //////////////////////////////////////////////////////////// /// \brief Namespace with GLSL types /// //////////////////////////////////////////////////////////// namespace Glsl { //////////////////////////////////////////////////////////// /// \brief 2D float vector (\p vec2 in GLSL) /// //////////////////////////////////////////////////////////// typedef Vector2<float> Vec2; //////////////////////////////////////////////////////////// /// \brief 2D int vector (\p ivec2 in GLSL) /// //////////////////////////////////////////////////////////// typedef Vector2<int> Ivec2; //////////////////////////////////////////////////////////// /// \brief 2D bool vector (\p bvec2 in GLSL) /// //////////////////////////////////////////////////////////// typedef Vector2<bool> Bvec2; //////////////////////////////////////////////////////////// /// \brief 3D float vector (\p vec3 in GLSL) /// //////////////////////////////////////////////////////////// typedef Vector3<float> Vec3; //////////////////////////////////////////////////////////// /// \brief 3D int vector (\p ivec3 in GLSL) /// //////////////////////////////////////////////////////////// typedef Vector3<int> Ivec3; //////////////////////////////////////////////////////////// /// \brief 3D bool vector (\p bvec3 in GLSL) /// //////////////////////////////////////////////////////////// typedef Vector3<bool> Bvec3; #ifdef SFML_DOXYGEN //////////////////////////////////////////////////////////// /// \brief 4D float vector (\p vec4 in GLSL) /// /// 4D float vectors can be implicitly converted from sf::Color /// instances. Each color channel is normalized from integers /// in [0, 255] to floating point values in [0, 1]. /// \code /// sf::Glsl::Vec4 zeroVector; /// sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f); /// sf::Glsl::Vec4 color = sf::Color::Cyan; /// \endcode //////////////////////////////////////////////////////////// typedef implementation - defined Vec4; //////////////////////////////////////////////////////////// /// \brief 4D int vector (\p ivec4 in GLSL) /// /// 4D int vectors can be implicitly converted from sf::Color /// instances. Each color channel remains unchanged inside /// the integer interval [0, 255]. /// \code /// sf::Glsl::Ivec4 zeroVector; /// sf::Glsl::Ivec4 vector(1, 2, 3, 4); /// sf::Glsl::Ivec4 color = sf::Color::Cyan; /// \endcode //////////////////////////////////////////////////////////// typedef implementation - defined Ivec4; //////////////////////////////////////////////////////////// /// \brief 4D bool vector (\p bvec4 in GLSL) /// //////////////////////////////////////////////////////////// typedef implementation - defined Bvec4; //////////////////////////////////////////////////////////// /// \brief 3x3 float matrix (\p mat3 in GLSL) /// /// The matrix can be constructed from an array with 3x3 /// elements, aligned in column-major order. For example, /// a translation by (x, y) looks as follows: /// \code /// float array[9] = /// { /// 1, 0, 0, /// 0, 1, 0, /// x, y, 1 /// }; /// /// sf::Glsl::Mat3 matrix(array); /// \endcode /// /// Mat3 can also be implicitly converted from sf::Transform: /// \code /// sf::Transform transform; /// sf::Glsl::Mat3 matrix = transform; /// \endcode //////////////////////////////////////////////////////////// typedef implementation - defined Mat3; //////////////////////////////////////////////////////////// /// \brief 4x4 float matrix (\p mat4 in GLSL) /// /// The matrix can be constructed from an array with 4x4 /// elements, aligned in column-major order. For example, /// a translation by (x, y, z) looks as follows: /// \code /// float array[16] = /// { /// 1, 0, 0, 0, /// 0, 1, 0, 0, /// 0, 0, 1, 0, /// x, y, z, 1 /// }; /// /// sf::Glsl::Mat4 matrix(array); /// \endcode /// /// Mat4 can also be implicitly converted from sf::Transform: /// \code /// sf::Transform transform; /// sf::Glsl::Mat4 matrix = transform; /// \endcode //////////////////////////////////////////////////////////// typedef implementation - defined Mat4; #else // SFML_DOXYGEN typedef priv::Vector4<float> Vec4; typedef priv::Vector4<int> Ivec4; typedef priv::Vector4<bool> Bvec4; typedef priv::Matrix<3, 3> Mat3; typedef priv::Matrix<4, 4> Mat4; #endif // SFML_DOXYGEN } // namespace Glsl } // namespace sf #endif // SFML_GLSL_HPP //////////////////////////////////////////////////////////// /// \namespace sf::Glsl /// \ingroup graphics /// /// \details The sf::Glsl namespace contains types that match /// their equivalents in GLSL, the OpenGL shading language. /// These types are exclusively used by the sf::Shader class. /// /// Types that already exist in SFML, such as \ref sf::Vector2<T> /// and \ref sf::Vector3<T>, are reused as typedefs, so you can use /// the types in this namespace as well as the original ones. /// Others are newly defined, such as Glsl::Vec4 or Glsl::Mat3. Their /// actual type is an implementation detail and should not be used. /// /// All vector types support a default constructor that /// initializes every component to zero, in addition to a /// constructor with one parameter for each component. /// The components are stored in member variables called /// x, y, z, and w. /// /// All matrix types support a constructor with a float* /// parameter that points to a float array of the appropriate /// size (that is, 9 in a 3x3 matrix, 16 in a 4x4 matrix). /// Furthermore, they can be converted from sf::Transform /// objects. /// /// \see sf::Shader /// ////////////////////////////////////////////////////////////
e0d734d6e6dabdda6ac6e1d742668debac631010
9a97f19fb8c9611c7e9c6a31e307a8ce596dd1f2
/Week4_BGL/POTW/attack_of_the_clones.cpp
39bf10099b716aeae2a93e6fdedf7d6ac835e5bf
[]
no_license
sankiteth/AlgoLab
bd9397efac164b3694ae47a7602a2587f5641126
13caeaf84a35ad773db3da7daae8dcd38328d7b2
refs/heads/master
2021-09-06T18:37:09.093344
2018-02-09T19:49:17
2018-02-09T19:49:17
106,556,655
0
0
null
null
null
null
UTF-8
C++
false
false
2,336
cpp
#include <iostream> #include <vector> #include <algorithm> using namespace std; void func() { int n, m; cin >> n >> m; vector<pair<int, int> > jedi(n+1, pair<int,int>()); for (int i = 1; i <= n; ++i) { int a, b; cin >> a >> b; jedi[i].first = a; jedi[i].second = b; } sort(jedi.begin()+1, jedi.end(), [] (pair<int, int> x, pair<int, int> y) -> bool { return (x.second < y.second); } ); // Only 1 of the wrapped around Jedis can be in the final solution, as // the wrapped around Jedis overlap among themselves. int sol = 0; int farthest = -1; int first = -1; int last = -1; for (int i = 1; i <= n; ++i) { // consider only unwrapped jedis if (jedi[i].first > jedi[i].second) { continue; } // compute best solution without considering wrapped around jedis if (jedi[i].first > farthest) { if (first == -1) { first = i; } last = i; sol++; farthest = jedi[i].second; } } // if the Jedi with earliest finish time is wrapped around, // the final solution might start with the Jedi that finishes before the // finish of first unwrapped Jedi, and starts after the finish of last unwrapped jedi // in the above found solution. if (jedi[1].first > jedi[1].second) { // Find all the wrapped jedi to start with. vector<int> start_wrapped; int i = 1; // Only consider the wrapped Jedis that start // after the finish of last unwrapped Jedi while (jedi[i].first > jedi[i].second) { if (jedi[i].first > jedi[last].second) { start_wrapped.push_back(i); } i++; } for(vector<int>::iterator it=start_wrapped.begin(); it != start_wrapped.end(); ++it) { int wrapped_sol = 1; int limit = jedi[*it].first; farthest = jedi[*it].second; for (int i = (*it) + 1; i <= n; ++i) { // consider only unwrapped jedis if (jedi[i].first > jedi[i].second) { continue; } // compute best solution without considering wrapped around jedis if (jedi[i].first > farthest && jedi[i].second < limit) { wrapped_sol++; farthest = jedi[i].second; } } sol = max(sol, wrapped_sol); } } cout << sol << endl; } int main() { ios_base::sync_with_stdio(false); int t; cin >> t; for (int i = 0; i < t; ++i) { func(); } return 0; }
019a369345a52e3cc8b72c34d2cb3a0d827a7f1b
c977b63a9284bae21ff70f4015881fc78b0752c9
/chapter8/exercise/LA5845/main.cpp
a31954d87a4747766c41e030a8c198c8f1222947
[]
no_license
fogsail/solution-to-ICPC
32e7946371f2ec80a1787d46b74e30b2fc648f31
20680db9d0c23ce33a9e76970b982cfa3b0ea8b2
refs/heads/master
2021-07-16T20:01:51.880864
2020-07-18T12:44:45
2020-07-18T12:44:45
188,792,479
4
1
null
null
null
null
UTF-8
C++
false
false
1,917
cpp
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #include <queue> #include <vector> #include <stack> #include <map> #include <set> #include <sstream> #include <iomanip> #include <cmath> #include <bitset> #include <assert.h> using namespace std; typedef long long llong; typedef set<int>::iterator ssii; #define Cmp(a, b) memcmp(a, b, sizeof(b)) #define Cpy(a, b) memcpy(a, b, sizeof(a)) #define Set(a, v) memset(a, v, sizeof(a)) #define debug(x) cout << #x << ": " << x << endl #define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++) #define _rep(i, l, r) for(int i = (l); i <= (r); i++) #define _for(i, l, r) for(int i = (l); i < (r); i++) #define _forDown(i, l, r) for(int i = (l); i >= r; i--) #define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i]) #define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second) #define debugS(str) cout << "dbg: " << str << endl; #define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); } #define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++) const int maxn = 100000 + 10; int n; class Seg { public: int from, to; bool operator< (const Seg& rhs) const { if(to != rhs.to) return to < rhs.to; else return from < rhs.from; } }; Seg seg[maxn]; int solve() { int ans = 0, last = -1; _for(i, 0, n) { Seg& cur = seg[i]; if(cur.to == last) continue; if(cur.from <= last) { last++; } if(cur.from > last) { ans++; last = cur.to; } } return ans - 1; } int main() { freopen("input.txt", "r", stdin); int T; scanf("%d", &T); while (T--) { scanf("%d", &n); _for(i, 0, n) { scanf("%d%d", &seg[i].from, &seg[i].to); } sort(seg, seg + n); printf("%d\n", solve()); } }
19994605b4c3ba4eb3801d2468a4b5e9e90781c8
e6c9adcd71fb805e09c91d9e1e07f6e7cf0a321a
/headers/mist-v1.6.0/mist/md5.h
dce677534a8bc199e57f1d507ebbad414336f9fb
[ "Apache-2.0", "BSD-2-Clause" ]
permissive
simizlab/atlas-guided-em-algorithm
a1c0f522c2daa0a7e53d0eb02eb7f7a8d73e19b0
54dd2df19f65724b1ac6957c06faca39d5b40215
refs/heads/master
2020-05-24T08:25:14.742300
2019-05-24T06:37:03
2019-05-24T06:37:03
187,184,512
4
0
null
2019-05-18T09:10:21
2019-05-17T09:07:52
C++
SHIFT_JIS
C++
false
false
22,165
h
// // Copyright (c) 2003-2010, MIST Project, Nagoya University // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // 3. Neither the name of the Nagoya University nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // /// @file mist/md5.h //! //! @brief 任意のバイト列のMD5を計算する //! //! - 参考文献 //! - MD2, RFC1319, http://www.ietf.org/rfc/rfc1319.txt //! - MD4, RFC1320, http://www.ietf.org/rfc/rfc1320.txt //! - MD5, RFC1321, http://www.ietf.org/rfc/rfc1321.txt //! #ifndef __INCLUDE_MD5__ #define __INCLUDE_MD5__ #include <cstring> #ifndef __INCLUDE_MIST_CONF_H__ #include "config/mist_conf.h" #endif #ifndef __INCLUDE_MIST_ENDIAN__ #include "config/endian.h" #endif #ifndef __INCLUDE_HASH_ALGORITHM__ #include "hash_algorithm.h" #endif // mist名前空間の始まり _MIST_BEGIN //! @addtogroup hash_group ハッシュ関数 //! @{ /// @brief MD2 を生成するクラス class md2 : public hash_algorithm { private: typedef hash_algorithm base; public: typedef base::size_type size_type; ///< @brief 符号なしの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には size_t 型と同じ typedef base::difference_type difference_type; ///< @brief 符号付きの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には ptrdiff_t 型と同じ typedef base::uint8 uint8; ///< @brief 符号なし8ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned char 型と同じ. typedef base::uint32 uint32; ///< @brief 符号なし32ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned int 型と同じ. typedef base::uint64 uint64; ///< @brief 符号なし64ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned long long int 型と同じ. public: /// @brief bytes[ 0 ] から bytes[ length - 1 ] の length バイトの MD2 を計算する. virtual void compute_hash( const void *bytes, uint64 length ) { size_type len = static_cast< size_type >( length ); length *= 8; const uint8 *data = reinterpret_cast< const uint8 * >( bytes ); size_type R = len % 16; size_type i, j, N16 = len / 16; uint8 pad = static_cast< uint8 >( 16 - R ); uint8 P[ 32 ], *C = P + 16; uint8 S[ 256 ] = { 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 }; // 末尾のパディング用データを作成する memset( P, 0, sizeof( uint8 ) * 32 ); for( i = 0 ; i < R ; i++ ) { P[ i ] = data[ len - R + i ]; } for( ; i < 16 ; i++ ) { P[ i ] = pad; } uint8 L = 0; for( i = 0 ; i < N16 ; i++ ) { for( j = 0 ; j < 16 ; j++ ) { uint8 c = data[ i * 16 + j ]; // RFCのアルゴリズムが間違っている模様 // 付属のサンプルコードのほうに合わせた L = C[ j ] ^= S[ c ^ L ]; } } for( j = 0 ; j < 16 ; j++ ) { uint8 c = P[ j ]; // RFCのアルゴリズムが間違っている模様 // 付属のサンプルコードのほうに合わせた L = C[ j ] ^= S[ c ^ L ]; } uint8 X[ 48 ]; memset( X, 0, sizeof( uint8 ) * 48 ); for( i = 0 ; i < N16 ; i++ ) { for( j = 0 ; j < 16 ; j++ ) { X[ 16 + j ] = data[ i * 16 + j ]; X[ 32 + j ] = X[ 16 + j ] ^ X[ j ]; } size_type t = 0; for( j = 0 ; j < 18 ; j++ ) { for( size_type k = 0 ; k < 48 ; k++ ) { t = X[ k ] ^= S[ t ]; } t = ( t + j ) & 0xff; } } for( i = 0 ; i < 2 ; i++ ) { for( j = 0 ; j < 16 ; j++ ) { X[ 16 + j ] = P[ i * 16 + j ]; X[ 32 + j ] = X[ 16 + j ] ^ X[ j ]; } size_type t = 0; for( j = 0 ; j < 18 ; j++ ) { for( size_type k = 0 ; k < 48 ; k++ ) { t = X[ k ] ^= S[ t ]; } t = ( t + j ) & 0xff; } } memcpy( digest, X, sizeof( uint8 ) * 16 ); } /// @brief ハッシュ関数名を返す virtual const std::string name( ) const{ return( "MD2" ); } /// @brief 空文字のダイジェスト文字列で初期化する md2( ) : base( "8350e5a3e24c153df2275c9f80692773" ){ } /// @brief 指定された文字列のダイジェスト文字列で初期化する md2( const std::string &str ) : base( 16 ) { base::compute_hash( str ); } /// @brief 指定されたバイト列のダイジェスト文字列で初期化する md2( const void *data, uint64 len ) : base( 16 ){ compute_hash( data, len ); } }; /// @brief MD4 を生成するクラス class md4 : public hash_algorithm { private: typedef hash_algorithm base; public: typedef base::size_type size_type; ///< @brief 符号なしの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には size_t 型と同じ typedef base::difference_type difference_type; ///< @brief 符号付きの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には ptrdiff_t 型と同じ typedef base::uint8 uint8; ///< @brief 符号なし8ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned char 型と同じ. typedef base::uint32 uint32; ///< @brief 符号なし32ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned int 型と同じ. typedef base::uint64 uint64; ///< @brief 符号なし64ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned long long int 型と同じ. protected: uint32 R( uint32 a, uint32 s ){ return( ( a << s ) | ( a >> ( 32 - s ) ) ); } void FF( uint32 &a, uint32 b, uint32 c, uint32 d, uint32 xk, uint32 s ) { a = R( a + ( ( b & c ) | ( ~b & d ) ) + xk, s ); } void GG( uint32 &a, uint32 b, uint32 c, uint32 d, uint32 xk, uint32 s ) { a = R( a + ( ( b & c ) | ( b & d ) | ( d & c ) ) + xk + 0x5a827999, s ); } void HH( uint32 &a, uint32 b, uint32 c, uint32 d, uint32 xk, uint32 s ) { a = R( a + ( b ^ c ^ d ) + xk + 0x6ed9eba1, s ); } void ToCurrentEndian( uint32 *x, size_type len ) { for( size_type i = 0 ; i < len ; i++ ) { x[ i ] = to_current_endian( byte_array< uint32 >( x[ i ] ), true ).get_value( ); } } void FromCurrentEndian( uint32 *x, size_type len ) { for( size_type i = 0 ; i < len ; i++ ) { x[ i ] = from_current_endian( byte_array< uint32 >( x[ i ] ), true ).get_value( ); } } void Round( uint32 &a, uint32 &b, uint32 &c, uint32 &d, uint32 x[ 16 ] ) { uint32 A = a; uint32 B = b; uint32 C = c; uint32 D = d; // ワードブロックごとの処理を行う FF( A, B, C, D, x[ 0 ], 3 ); FF( D, A, B, C, x[ 1 ], 7 ); FF( C, D, A, B, x[ 2 ], 11 ); FF( B, C, D, A, x[ 3 ], 19 ); FF( A, B, C, D, x[ 4 ], 3 ); FF( D, A, B, C, x[ 5 ], 7 ); FF( C, D, A, B, x[ 6 ], 11 ); FF( B, C, D, A, x[ 7 ], 19 ); FF( A, B, C, D, x[ 8 ], 3 ); FF( D, A, B, C, x[ 9 ], 7 ); FF( C, D, A, B, x[ 10 ], 11 ); FF( B, C, D, A, x[ 11 ], 19 ); FF( A, B, C, D, x[ 12 ], 3 ); FF( D, A, B, C, x[ 13 ], 7 ); FF( C, D, A, B, x[ 14 ], 11 ); FF( B, C, D, A, x[ 15 ], 19 ); GG( A, B, C, D, x[ 0 ], 3 ); GG( D, A, B, C, x[ 4 ], 5 ); GG( C, D, A, B, x[ 8 ], 9 ); GG( B, C, D, A, x[ 12 ], 13 ); GG( A, B, C, D, x[ 1 ], 3 ); GG( D, A, B, C, x[ 5 ], 5 ); GG( C, D, A, B, x[ 9 ], 9 ); GG( B, C, D, A, x[ 13 ], 13 ); GG( A, B, C, D, x[ 2 ], 3 ); GG( D, A, B, C, x[ 6 ], 5 ); GG( C, D, A, B, x[ 10 ], 9 ); GG( B, C, D, A, x[ 14 ], 13 ); GG( A, B, C, D, x[ 3 ], 3 ); GG( D, A, B, C, x[ 7 ], 5 ); GG( C, D, A, B, x[ 11 ], 9 ); GG( B, C, D, A, x[ 15 ], 13 ); HH( A, B, C, D, x[ 0 ], 3 ); HH( D, A, B, C, x[ 8 ], 9 ); HH( C, D, A, B, x[ 4 ], 11 ); HH( B, C, D, A, x[ 12 ], 15 ); HH( A, B, C, D, x[ 2 ], 3 ); HH( D, A, B, C, x[ 10 ], 9 ); HH( C, D, A, B, x[ 6 ], 11 ); HH( B, C, D, A, x[ 14 ], 15 ); HH( A, B, C, D, x[ 1 ], 3 ); HH( D, A, B, C, x[ 9 ], 9 ); HH( C, D, A, B, x[ 5 ], 11 ); HH( B, C, D, A, x[ 13 ], 15 ); HH( A, B, C, D, x[ 3 ], 3 ); HH( D, A, B, C, x[ 11 ], 9 ); HH( C, D, A, B, x[ 7 ], 11 ); HH( B, C, D, A, x[ 15 ], 15 ); a += A; b += B; c += C; d += D; } public: /// @brief bytes[ 0 ] から bytes[ length - 1 ] の length バイトの MD4 を計算する. virtual void compute_hash( const void *bytes, uint64 length ) { size_type len = static_cast< size_type >( length ); length *= 8; // 出力用のダイジェストバイト列を 32 ビット単位で処理できるようにする uint32 &A = *reinterpret_cast< uint32 * >( digest ); uint32 &B = *reinterpret_cast< uint32 * >( digest + 4 ); uint32 &C = *reinterpret_cast< uint32 * >( digest + 8 ); uint32 &D = *reinterpret_cast< uint32 * >( digest + 12 ); // ダイジェストバイト列の初期化 A = 0x67452301; B = 0xefcdab89; C = 0x98badcfe; D = 0x10325476; size_type i; uint32 x[ 16 ]; uint8 *xx = reinterpret_cast< uint8 * >( x ); const uint8 *data = reinterpret_cast< const uint8 * >( bytes ); // 入力データに対してメッセージ処理を行う for( i = 0 ; i + 64 < len ; i += 64 ) { memcpy( xx, data + i, sizeof( uint8 ) * 64 ); ToCurrentEndian( x, 16 ); Round( A, B, C, D, x ); } size_type rest = len - i; // 最後にバイト長を足す分が存在しなければ,64バイトに拡張して処理する if( rest >= 64 - 8 ) { memcpy( xx, data + i, sizeof( uint8 ) * rest ); memset( xx + rest, 0, sizeof( uint8 ) * ( 64 - rest ) ); // 先頭のビットを 1 にする xx[ rest ] = 0x80; // メッセージ処理を行う ToCurrentEndian( x, 16 ); Round( A, B, C, D, x ); // バイト長の分の処理を行う memset( xx, 0, sizeof( uint8 ) * 64 ); x[ 14 ] = static_cast< uint32 >( length ); x[ 15 ] = static_cast< uint32 >( length >> 32 ); // メッセージ処理を行う Round( A, B, C, D, x ); } else { memcpy( xx, data + i, sizeof( uint8 ) * rest ); memset( xx + rest, 0, sizeof( uint8 ) * ( 64 - rest ) ); // 先頭のビットを 1 にする xx[ rest ] = 0x80; ToCurrentEndian( x, 16 ); // バイト長の分の値を付加する x[ 14 ] = static_cast< uint32 >( length ); x[ 15 ] = static_cast< uint32 >( length >> 32 ); // メッセージ処理を行う Round( A, B, C, D, x ); } FromCurrentEndian( reinterpret_cast< uint32 * >( digest ), 4 ); } /// @brief ハッシュ関数名を返す virtual const std::string name( ) const{ return( "MD4" ); } /// @brief 空文字のダイジェスト文字列で初期化する md4( ) : base( "31d6cfe0d16ae931b73c59d7e0c089c0" ){ } /// @brief 指定された文字列のダイジェスト文字列で初期化する md4( const std::string &str ) : base( 16 ) { base::compute_hash( str ); } /// @brief 指定されたバイト列のダイジェスト文字列で初期化する md4( const void *data, uint64 len ) : base( 16 ){ compute_hash( data, len ); } }; /// @brief MD5 を生成するクラス class md5 : public hash_algorithm { private: typedef hash_algorithm base; public: typedef base::size_type size_type; ///< @brief 符号なしの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には size_t 型と同じ typedef base::difference_type difference_type; ///< @brief 符号付きの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には ptrdiff_t 型と同じ typedef base::uint8 uint8; ///< @brief 符号なし8ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned char 型と同じ. typedef base::uint32 uint32; ///< @brief 符号なし32ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned int 型と同じ. typedef base::uint64 uint64; ///< @brief 符号なし64ビット整数を表す型.内部のハッシュ関数値を計算するのに利用.内部的には unsigned long long int 型と同じ. protected: uint32 R( uint32 a, uint32 s ){ return( ( a << s ) | ( a >> ( 32 - s ) ) ); } void FF( uint32 &a, uint32 b, uint32 c, uint32 d, uint32 xk, uint32 s, uint32 ti ) { a = b + R( a + ( ( b & c ) | ( ~b & d ) ) + xk + ti, s ); } void GG( uint32 &a, uint32 b, uint32 c, uint32 d, uint32 xk, uint32 s, uint32 ti ) { a = b + R( a + ( ( b & d ) | ( ~d & c ) ) + xk + ti, s ); } void HH( uint32 &a, uint32 b, uint32 c, uint32 d, uint32 xk, uint32 s, uint32 ti ) { a = b + R( a + ( b ^ c ^ d ) + xk + ti, s ); } void II( uint32 &a, uint32 b, uint32 c, uint32 d, uint32 xk, uint32 s, uint32 ti ) { a = b + R( a + ( c ^ ( b | ~d ) ) + xk + ti, s ); } void ToCurrentEndian( uint32 *x, size_type len ) { for( size_type i = 0 ; i < len ; i++ ) { x[ i ] = to_current_endian( byte_array< uint32 >( x[ i ] ), true ).get_value( ); } } void FromCurrentEndian( uint32 *x, size_type len ) { for( size_type i = 0 ; i < len ; i++ ) { x[ i ] = from_current_endian( byte_array< uint32 >( x[ i ] ), true ).get_value( ); } } void Round( uint32 &a, uint32 &b, uint32 &c, uint32 &d, uint32 x[ 16 ] ) { uint32 A = a; uint32 B = b; uint32 C = c; uint32 D = d; // ワードブロックごとの処理を行う FF( A, B, C, D, x[ 0 ], 7, 0xd76aa478 ); FF( D, A, B, C, x[ 1 ], 12, 0xe8c7b756 ); FF( C, D, A, B, x[ 2 ], 17, 0x242070db ); FF( B, C, D, A, x[ 3 ], 22, 0xc1bdceee ); FF( A, B, C, D, x[ 4 ], 7, 0xf57c0faf ); FF( D, A, B, C, x[ 5 ], 12, 0x4787c62a ); FF( C, D, A, B, x[ 6 ], 17, 0xa8304613 ); FF( B, C, D, A, x[ 7 ], 22, 0xfd469501 ); FF( A, B, C, D, x[ 8 ], 7, 0x698098d8 ); FF( D, A, B, C, x[ 9 ], 12, 0x8b44f7af ); FF( C, D, A, B, x[ 10 ], 17, 0xffff5bb1 ); FF( B, C, D, A, x[ 11 ], 22, 0x895cd7be ); FF( A, B, C, D, x[ 12 ], 7, 0x6b901122 ); FF( D, A, B, C, x[ 13 ], 12, 0xfd987193 ); FF( C, D, A, B, x[ 14 ], 17, 0xa679438e ); FF( B, C, D, A, x[ 15 ], 22, 0x49b40821 ); GG( A, B, C, D, x[ 1 ], 5, 0xf61e2562 ); GG( D, A, B, C, x[ 6 ], 9, 0xc040b340 ); GG( C, D, A, B, x[ 11 ], 14, 0x265e5a51 ); GG( B, C, D, A, x[ 0 ], 20, 0xe9b6c7aa ); GG( A, B, C, D, x[ 5 ], 5, 0xd62f105d ); GG( D, A, B, C, x[ 10 ], 9, 0x02441453 ); GG( C, D, A, B, x[ 15 ], 14, 0xd8a1e681 ); GG( B, C, D, A, x[ 4 ], 20, 0xe7d3fbc8 ); GG( A, B, C, D, x[ 9 ], 5, 0x21e1cde6 ); GG( D, A, B, C, x[ 14 ], 9, 0xc33707d6 ); GG( C, D, A, B, x[ 3 ], 14, 0xf4d50d87 ); GG( B, C, D, A, x[ 8 ], 20, 0x455a14ed ); GG( A, B, C, D, x[ 13 ], 5, 0xa9e3e905 ); GG( D, A, B, C, x[ 2 ], 9, 0xfcefa3f8 ); GG( C, D, A, B, x[ 7 ], 14, 0x676f02d9 ); GG( B, C, D, A, x[ 12 ], 20, 0x8d2a4c8a ); HH( A, B, C, D, x[ 5 ], 4, 0xfffa3942 ); HH( D, A, B, C, x[ 8 ], 11, 0x8771f681 ); HH( C, D, A, B, x[ 11 ], 16, 0x6d9d6122 ); HH( B, C, D, A, x[ 14 ], 23, 0xfde5380c ); HH( A, B, C, D, x[ 1 ], 4, 0xa4beea44 ); HH( D, A, B, C, x[ 4 ], 11, 0x4bdecfa9 ); HH( C, D, A, B, x[ 7 ], 16, 0xf6bb4b60 ); HH( B, C, D, A, x[ 10 ], 23, 0xbebfbc70 ); HH( A, B, C, D, x[ 13 ], 4, 0x289b7ec6 ); HH( D, A, B, C, x[ 0 ], 11, 0xeaa127fa ); HH( C, D, A, B, x[ 3 ], 16, 0xd4ef3085 ); HH( B, C, D, A, x[ 6 ], 23, 0x04881d05 ); HH( A, B, C, D, x[ 9 ], 4, 0xd9d4d039 ); HH( D, A, B, C, x[ 12 ], 11, 0xe6db99e5 ); HH( C, D, A, B, x[ 15 ], 16, 0x1fa27cf8 ); HH( B, C, D, A, x[ 2 ], 23, 0xc4ac5665 ); II( A, B, C, D, x[ 0 ], 6, 0xf4292244 ); II( D, A, B, C, x[ 7 ], 10, 0x432aff97 ); II( C, D, A, B, x[ 14 ], 15, 0xab9423a7 ); II( B, C, D, A, x[ 5 ], 21, 0xfc93a039 ); II( A, B, C, D, x[ 12 ], 6, 0x655b59c3 ); II( D, A, B, C, x[ 3 ], 10, 0x8f0ccc92 ); II( C, D, A, B, x[ 10 ], 15, 0xffeff47d ); II( B, C, D, A, x[ 1 ], 21, 0x85845dd1 ); II( A, B, C, D, x[ 8 ], 6, 0x6fa87e4f ); II( D, A, B, C, x[ 15 ], 10, 0xfe2ce6e0 ); II( C, D, A, B, x[ 6 ], 15, 0xa3014314 ); II( B, C, D, A, x[ 13 ], 21, 0x4e0811a1 ); II( A, B, C, D, x[ 4 ], 6, 0xf7537e82 ); II( D, A, B, C, x[ 11 ], 10, 0xbd3af235 ); II( C, D, A, B, x[ 2 ], 15, 0x2ad7d2bb ); II( B, C, D, A, x[ 9 ], 21, 0xeb86d391 ); a += A; b += B; c += C; d += D; } public: /// @brief bytes[ 0 ] から bytes[ length - 1 ] の length バイトの MD5 を計算する. virtual void compute_hash( const void *bytes, uint64 length ) { size_type len = static_cast< size_type >( length ); length *= 8; // 出力用のダイジェストバイト列を 32 ビット単位で処理できるようにする uint32 &A = *reinterpret_cast< uint32 * >( digest ); uint32 &B = *reinterpret_cast< uint32 * >( digest + 4 ); uint32 &C = *reinterpret_cast< uint32 * >( digest + 8 ); uint32 &D = *reinterpret_cast< uint32 * >( digest + 12 ); // ダイジェストバイト列の初期化 A = 0x67452301; B = 0xefcdab89; C = 0x98badcfe; D = 0x10325476; size_type i; uint32 x[ 16 ]; uint8 *xx = reinterpret_cast< uint8 * >( x ); const uint8 *data = reinterpret_cast< const uint8 * >( bytes ); // 入力データに対してメッセージ処理を行う for( i = 0 ; i + 64 < len ; i += 64 ) { memcpy( xx, data + i, sizeof( uint8 ) * 64 ); ToCurrentEndian( x, 16 ); Round( A, B, C, D, x ); } size_type rest = len - i; // 最後にバイト長を足す分が存在しなければ,64バイトに拡張して処理する if( rest >= 64 - 8 ) { memcpy( xx, data + i, sizeof( uint8 ) * rest ); memset( xx + rest, 0, sizeof( uint8 ) * ( 64 - rest ) ); // 先頭のビットを 1 にする xx[ rest ] = 0x80; // メッセージ処理を行う ToCurrentEndian( x, 16 ); Round( A, B, C, D, x ); // バイト長の分の処理を行う memset( xx, 0, sizeof( uint8 ) * 64 ); x[ 14 ] = static_cast< uint32 >( length ); x[ 15 ] = static_cast< uint32 >( length >> 32 ); // メッセージ処理を行う Round( A, B, C, D, x ); } else { memcpy( xx, data + i, sizeof( uint8 ) * rest ); memset( xx + rest, 0, sizeof( uint8 ) * ( 64 - rest ) ); // 先頭のビットを 1 にする xx[ rest ] = 0x80; ToCurrentEndian( x, 16 ); // バイト長の分の値を付加する x[ 14 ] = static_cast< uint32 >( length ); x[ 15 ] = static_cast< uint32 >( length >> 32 ); // メッセージ処理を行う Round( A, B, C, D, x ); } FromCurrentEndian( reinterpret_cast< uint32 * >( digest ), 4 ); } /// @brief ハッシュ関数名を返す virtual const std::string name( ) const{ return( "MD5" ); } /// @brief 空文字のダイジェスト文字列で初期化する md5( ) : base( "d41d8cd98f00b204e9800998ecf8427e" ){ } /// @brief 指定された文字列のダイジェスト文字列で初期化する md5( const std::string &str ) : base( 16 ) { base::compute_hash( str ); } /// @brief 指定されたバイト列のダイジェスト文字列で初期化する md5( const void *data, uint64 len ) : base( 16 ){ compute_hash( data, len ); } }; /// @} // ハッシュ関数グループの終わり // mist名前空間の終わり _MIST_END #endif // __INCLUDE_MD5__
ff7e1c45a70a49eee532f8e304d6b4107669a84e
37a4c0452fa4b4413705abcfc930da0024fc6b3f
/human_filter/src/op_filter_tracker.cpp
d4d881ace6075430234feb94c42e1d5169f50e82
[]
no_license
hcr-hsrproject/villa_navigation
1ba18cb2c93b0939740c05460a0a25c9cd5abafe
c237ff321a2b26f770faf58b1366335525002c14
refs/heads/master
2021-05-05T11:36:26.419665
2018-04-20T15:38:39
2018-04-20T15:38:39
118,180,199
0
0
null
null
null
null
UTF-8
C++
false
false
37,305
cpp
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * 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 Willow Garage nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ /* Author: Wim Meeussen */ #include "people_tracking_filter/op_filter_tracker.h" #include "people_tracking_filter/tracker_particle.h" #include "people_tracking_filter/tracker_kalman.h" #include "people_tracking_filter/state_pos_vel.h" #include "people_tracking_filter/rgb.h" #include <people_msgs/PositionMeasurement.h> using namespace std; using namespace tf; using namespace BFL; using namespace message_filters; static const double sequencer_delay = 0.5; //TODO: this is probably too big, it was 0.8 static const unsigned int sequencer_internal_buffer = 100; static const unsigned int sequencer_subscribe_buffer = 10; static const unsigned int num_particles_tracker = 1000; static const double tracker_init_dist = 4.0; bool IsNotInitilized = true; // constructor op_filter_manager::op_filter_manager(ros::NodeHandle nh) : nh_(nh), robot_state_(), filter_counter_(0), edge_leg_iter(0), pub_iters(0), OnceTarget(false) { // initialize // advertise filter output Leg_boxes_pub=nh_.advertise<visualization_msgs::MarkerArray>("/filtered_leg_target", 10); Leg_poses_pub=nh_.advertise<geometry_msgs::PoseArray>("/filtered_leg_poses", 10); human_target_pub=nh_.advertise<visualization_msgs::Marker>("/leg_target", 10); filtered_human_target_pub=nh_.advertise<visualization_msgs::Marker>("/filtered_target", 10); people_measurement_pub_ = nh_.advertise<people_msgs::PositionMeasurement>("people_tracker_measurements", 10); static_belief_map_pub=nh_.advertise<nav_msgs::OccupancyGrid>("/camera_region_map", 10, true); setNavTarget_pub=nh_.advertise<move_base_msgs::MoveBaseActionGoal>("/move_base/move/goal",50,true); openpose_sub=nh_.subscribe<geometry_msgs::PoseArray>("/openpose_pose_array", 10, &op_filter_manager::openpose_pose_callback,this); chair_sub=nh_.subscribe<visualization_msgs::MarkerArray>("/chair_boxes", 10, &op_filter_manager::chair_yolo_callback,this); //people_yolo_sub=nh_.subscribe<visualization_msgs::MarkerArray>("/human_boxes", 10, &op_filter_manager::human_yolo_callback,this); //edge_leg_sub=nh_.subscribe<geometry_msgs::PoseArray>("/edge_leg_detector", 10, &op_filter_manager::edge_leg_callback,this); filter_act_sub=nh_.subscribe<std_msgs::Int8>("/filter_act_cmd", 10, &op_filter_manager::filter_act_callback,this); globalpose_sub=nh_.subscribe<geometry_msgs::PoseStamped>("/global_pose",10,&op_filter_manager::global_pose_callback,this); keyboard_sub=nh_.subscribe<keyboard::Key>("/keyboard/keydown",10, &op_filter_manager::keyboard_callback,this); Scaled_static_map_sub=nh_.subscribe<nav_msgs::OccupancyGrid>("/scaled_static_map", 10, &op_filter_manager::scaled_static_map_callback,this); filter_result_sub=nh_.subscribe<people_msgs::PositionMeasurement>("people_tracker_filter", 10,&op_filter_manager::filter_result_callback,this); wrist_trigger_sub=nh_.subscribe<std_msgs::Int8>("/cmd_trackhuman", 10,&op_filter_manager::wrist_trigger_callback,this); m_service_client = nh_.serviceClient<villa_navi_service::GoTargetPos>("/navi_go_base"); // One_People_pos_pub=nh_.advertise<people_msgs::PositionMeasurement>("/people_tracker_measurements", 0 ); global_pose.resize(3,0.0); leg_target.resize(2,0.0); Head_Pos.resize(2,0.0); filtered_leg_target.resize(2,0.0); NN_laser_target.resize(2,0.0); last_nav_target.resize(2,0.0); //camera region static_belief_map.info.width=30; static_belief_map.info.height= 30; static_belief_map.info.resolution=0.5; static_belief_map.info.origin.position.x=-7.5; static_belief_map.info.origin.position.y=-7.5; belief_size=static_belief_map.info.width*static_belief_map.info.height; static_belief_map.data.resize(static_belief_map.info.width*static_belief_map.info.height); int belief_map_size=static_belief_map.info.width*static_belief_map.info.height; for(int k(0);k<belief_map_size;k++) static_belief_map.data[k]=0.01; } // destructor op_filter_manager::~op_filter_manager() { // delete sequencer // delete all trackers }; void op_filter_manager::joint_states_callback(const sensor_msgs::JointState::ConstPtr& msg) { Head_Pos[0]=msg->position[9]; //pan Head_Pos[1]=msg->position[10]; //tilt } void op_filter_manager::filter_result_callback(const people_msgs::PositionMeasurement::ConstPtr& msg) { ROS_INFO("filter_results callback"); filtered_leg_target[0]=msg->pos.x; filtered_leg_target[1]=msg->pos.y; } void op_filter_manager::edge_leg_callback(const geometry_msgs::PoseArray::ConstPtr& msg) { int num_leg_detected = msg->poses.size(); std::vector<double> tempVec(2,0.0); Cur_leg_human.clear(); for(int i(0);i<num_leg_detected;i++) { geometry_msgs::Vector3Stamped gV, tV; gV.vector.x = msg->poses[i].position.x; gV.vector.y = msg->poses[i].position.y; gV.vector.z = 1.0; gV.header.stamp = ros::Time(); gV.header.frame_id = "/base_range_sensor_link"; listener.transformVector("/map", gV, tV); tempVec[0]=tV.vector.x+global_pose[0]; tempVec[1]=tV.vector.y+global_pose[1]; //distance check between two candidates! bool IsFarEnough = true; bool IsNearfromRobot= false; for(int j(0);j<Cur_leg_human.size();j++) { if(Comparetwopoistions(tempVec,Cur_leg_human[j],0.4)) IsFarEnough=false; } if(Comparetwopoistions(global_pose,tempVec,LASER_Dist_person)) IsNearfromRobot=true; //std::cout<<"here 2"<<std::endl; //add only if candidate pose ins far from 0.75 from previous candidates if(IsFarEnough && IsNearfromRobot) { Cur_leg_human.push_back(tempVec); } } // std::cout<<"here 3"<<std::endl; if(Cur_leg_human.size()>0) { int NearestLegIdx=FindNearesetLegIdx(); std::vector<double> temp_leg_target(2,0.0); temp_leg_target[0]=Cur_leg_human[NearestLegIdx][0]; temp_leg_target[1]=Cur_leg_human[NearestLegIdx][1]; if(Comparetwopoistions(temp_leg_target,filtered_leg_target,1.2)) { std::cout<<"update target - person is in a range"<<std::endl; NN_laser_target[0]=temp_leg_target[0]; NN_laser_target[1]=temp_leg_target[1]; } } } void op_filter_manager::publish_cameraregion() { getCameraregion(); static_belief_map.header.stamp = ros::Time::now(); static_belief_map.header.frame_id = "map"; static_belief_map_pub.publish(static_belief_map); } void op_filter_manager::getCameraregion() { double global_robot_x= global_pose[0]; double global_robot_y= global_pose[1]; double global_robot_theta = global_pose[2]+Head_Pos[0]; visiblie_idx_set.clear(); global_robot_theta=0.0; //Iteration for belief grid for(int i(0);i<static_belief_map.info.width;i++) for(int j(0);j<static_belief_map.info.height;j++) { int belief_map_idx=j*static_belief_map.info.height+i; // double map_ogirin_x = static_belief_map.info.origin.position.x+global_robot_x; // double map_ogirin_y = static_belief_map.info.origin.position.y+global_robot_y; double map_ogirin_x = static_belief_map.info.origin.position.x; double map_ogirin_y = static_belief_map.info.origin.position.y; double trans_vector_x=(i+0.5)*static_belief_map.info.resolution; double trans_vector_y=(j+0.5)*static_belief_map.info.resolution; double rot_trans_vector_x = cos(global_robot_theta)*trans_vector_x-sin(global_robot_theta)*trans_vector_y; double rot_trans_vector_y = sin(global_robot_theta)*trans_vector_x+cos(global_robot_theta)*trans_vector_y; double belief_global_x=map_ogirin_x+rot_trans_vector_x; double belief_global_y=map_ogirin_y+rot_trans_vector_y; //solve bool line1_result =getlinevalue(1,belief_global_x,belief_global_y); bool line2_result =getlinevalue(2,belief_global_x,belief_global_y); if( line1_result && line2_result ) { static_belief_map.data[belief_map_idx]=30; visiblie_idx_set.push_back(belief_map_idx); //save cell_id } else static_belief_map.data[belief_map_idx]=0.0; } } bool op_filter_manager::getlinevalue(int line_type,double input_x, double input_y) { double global_robot_theta = global_pose[2]+Head_Pos[0]; // double global_robot_theta =Camera_angle; double theta_1=-FOVW*MATH_PI/180+global_robot_theta; double theta_2= FOVW*MATH_PI/180+global_robot_theta; double m_1=tan(theta_1); double m_2=tan(theta_2); int isspecial=0; if(theta_1<-MATH_PI/2.0 && theta_2 >-MATH_PI/2.0) { double temp=m_2; isspecial=1; } else if(theta_2> MATH_PI/2.0 && (theta_1 <MATH_PI/2.0)) { isspecial=2; } else if (theta_1<-MATH_PI/2.0 && theta_2 <-MATH_PI/2.0) { isspecial=5; } else if(theta_2< -MATH_PI/2.0) { isspecial=3; } else if(theta_1>MATH_PI/2.0 && theta_2> MATH_PI/2.0) { isspecial=4; } // std::cout<<"camera region section : "<<isspecial<<std::endl; double m=0.0; double coeff_sign=1.0; double global_robot_x= global_pose[0]; double global_robot_y= global_pose[1]; double res =0.0; switch(line_type){ case 1: m=m_1; coeff_sign=-1.0; if(isspecial==0) coeff_sign=-1.0; else if(isspecial==1) coeff_sign=1.0; else if(isspecial==2) coeff_sign=-1.0; else if(isspecial==4) coeff_sign=1.0; else if(isspecial==5) coeff_sign=1.0; break; case 2: m=m_2; coeff_sign=-1.0; if(isspecial==1) coeff_sign=1.0; else if(isspecial==0) coeff_sign=1.0; else if(isspecial==3) coeff_sign=1.0; break; default: std::cout<<"Wrong line type"<<std::endl; m=m_1; } res= m*input_x-m*global_robot_x+global_robot_y-input_y; if(res*coeff_sign>0 || res==0) return true; else return false; } void op_filter_manager::scaled_static_map_callback(const nav_msgs::OccupancyGrid::ConstPtr& msg) { ROS_INFO("map Received"); std::cout <<"static_Width: " << msg->info.width << std::endl; std::cout <<"static_Height: " << msg->info.height << std::endl; std::cout << "static_X origin:" << msg->info.origin.position.x << std::endl; std::cout << "static_Y origin:" << msg->info.origin.position.y << std::endl; std::cout <<"static_Resolution: " << msg->info.resolution << std::endl; // Copy Data; Scaled_map = (*msg); Scaled_map.header.stamp = ros::Time::now(); Scaled_map.header.frame_id = "map"; std::cout<<"Here"<<std::endl; // for(int i(0);i<msg->data.size();i++) // std::cout<<msg->data[i]<<endl; } void op_filter_manager::wrist_trigger_callback(const std_msgs::Int8::ConstPtr& msg) { int ReceivedNum= (int) msg->data; if(ReceivedNum==1) //if wrist is triggered { if(pose_people.size()>0) { leg_target.resize(2,0.0); leg_target[0]=pose_people[0][0]; leg_target[1]=pose_people[0][1]; OnceTarget=true; ROS_INFO("set Target"); std::cout<<"set target : "<<leg_target[0]<<" , "<<leg_target[1]<<std::endl; } } } void op_filter_manager::keyboard_callback(const keyboard::Key::ConstPtr& msg) { ROS_INFO("Received Keyboard"); printf("(key board)\n"); int ReceivedNum= (int) msg->code; std::cout<<msg->code<<std::endl; if(ReceivedNum==116) //if keyboard input is "t" { if(pose_people.size()>0) { leg_target.resize(2,0.0); leg_target[0]=pose_people[0][0]; leg_target[1]=pose_people[0][1]; OnceTarget=true; ROS_INFO("set Target"); std::cout<<"set target : "<<leg_target[0]<<" , "<<leg_target[1]<<std::endl; // ROS_INFO("Filter : Set Target pos X : %.3lf, y : %.3lf", cur_yolo_people[0],cur_yolo_people[1]); } } } // void op_filter_manager::trigger_callback(const keyboard::Key::ConstPtr& msg) // { // ROS_INFO("Received Keyboard"); // printf("(key board)\n"); // int ReceivedNum= (int) msg->code; // std::cout<<msg->code<<std::endl; // if(ReceivedNum==116) //if keyboard input is "t" // { // if(cur_yolo_people.size()>0) // { // leg_target.resize(2,0.0); // leg_target[0]=cur_yolo_people[0][0]; // leg_target[1]=cur_yolo_people[0][1]; // OnceTarget=true; // ROS_INFO("set Target"); // std::cout<<"set target : "<<leg_target[0]<<" , "<<leg_target[1]<<std::endl; // // ROS_INFO("Filter : Set Target pos X : %.3lf, y : %.3lf", cur_yolo_people[0],cur_yolo_people[1]); // } // } // } bool op_filter_manager::check_chair(float x_pos,float y_pos) { //return true if input positions(x_pos,ypos) are close to the chair positions vector<double> tempVec(2,0.0); tempVec[0]=x_pos; tempVec[1]=y_pos; //return true if it is occupied with obstacles if (cur_yolo_chair.size()>0) { for(int i(0);i<cur_yolo_chair.size();i++) { if(Comparetwopoistions(cur_yolo_chair[i],tempVec,0.22)) return true; } } else{ return false; } return false; } bool op_filter_manager::check_staticObs(float x_pos,float y_pos) { //return true if it is occupied with obstacles if (Scaled_map.data.size()>0) { int obs_idx=globalcoord_To_SScaled_map_index(x_pos,y_pos); if(Scaled_map.data[obs_idx]>0) return true; else return false; } } bool op_filter_manager::check_cameraregion(float x_pos,float y_pos) { if(abs(x_pos)<7.0 && abs(y_pos)<7.0) { //return true if it is occupied with obstacles if (static_belief_map.data.size()>0) { int obs_idx=CoordinateTransform_Global2_staticMap(x_pos,y_pos); if(obs_idx<static_belief_map.data.size()){ if(static_belief_map.data[obs_idx]>10.0) return true; else return false; } } } return true; } void op_filter_manager::call_navi_srv() { //m_service_client = n.serviceClient<villa_navi_service::GoTargetPos>("/navi_go_base"); if(!Comparetwopoistions(last_nav_target, filtered_leg_target, 0.5)) { villa_navi_service::GoTargetPos navi_srv; navi_srv.request.x_from_map=filtered_leg_target[0]-0.3; navi_srv.request.y_from_map=filtered_leg_target[1]; navi_srv.request.theta_from_map=0.2; m_service_client.call(navi_srv); last_nav_target[0]=filtered_leg_target[0]-0.3; last_nav_target[1]=filtered_leg_target[1]; } //villa_navi_service::GoTargetPos navi_srv; //navi_srv.request.x_from_map=filtered_leg_target[0]-0.3; //navi_srv.request.y_from_map=filtered_leg_target[1]; //navi_srv.request.theta_from_map=0.2; //m_service_client.call(navi_srv); //last_nav_target[0]=filtered_leg_target[0]-0.3; //last_nav_target[1]=filtered_leg_target[1]; } void op_filter_manager::Publish_nav_target() { if(pub_iters>4000){ if(OnceTarget){ if(Comparetwopoistions(global_pose, filtered_leg_target, 0.4)) return; move_base_msgs::MoveBaseActionGoal Navmsgs; Navmsgs.header.stamp = ros::Time::now(); //ROS_INFO("time"); std::cout<<Navmsgs.header.stamp <<std::endl; //Navmsgs.header.frame_id = "map"; Navmsgs.goal.target_pose.header.frame_id = "map"; Navmsgs.goal.target_pose.pose.position.x=filtered_leg_target[0]-0.3; Navmsgs.goal.target_pose.pose.position.y=filtered_leg_target[1]; Navmsgs.goal.target_pose.pose.position.z=0.5; std::vector<double> GoalVector; GoalVector.resize(2,0.0); GoalVector[0]=filtered_leg_target[0]-0.2; GoalVector[1]=filtered_leg_target[1]; GoalVector[0]=GoalVector[0]-global_pose[0]; GoalVector[1]=GoalVector[1]-global_pose[1]; double temp_yaw =atan(GoalVector[1]/GoalVector[0]); temp_yaw=temp_yaw-global_pose[2]; double temp_roll=0.0; double temp_pitch=0.0; // poses.orientation = tf::transformations.quaternion_from_euler(0.0, 0.0, temp_yaw); geometry_msgs::Quaternion q; double t0 = cos(temp_yaw * 0.5); double t1 = sin(temp_yaw * 0.5); double t2 = cos(temp_roll * 0.5); double t3 = sin(temp_roll * 0.5); double t4 = cos(temp_pitch * 0.5); double t5 = sin(temp_pitch * 0.5); q.w = t0 * t2 * t4 + t1 * t3 * t5; q.x = t0 * t3 * t4 - t1 * t2 * t5; q.y = t0 * t2 * t5 + t1 * t3 * t4; q.z = t1 * t2 * t4 - t0 * t3 * t5; // tf::StampedTransform tfs; // tf::Quaternion head_orientation =tf::createQuaternionFromRPY(0.0, 0.0, temp_yaw); // Navmsgs.goal.target_pose.pose.orientation = head_orientation; Navmsgs.goal.target_pose.pose.orientation.x=q.x; Navmsgs.goal.target_pose.pose.orientation.y=q.y; Navmsgs.goal.target_pose.pose.orientation.z=q.z; Navmsgs.goal.target_pose.pose.orientation.w=q.w; setNavTarget_pub.publish(Navmsgs); ROS_INFO("navgation published"); pub_iters=0; } } pub_iters++; } int op_filter_manager::globalcoord_To_SScaled_map_index(float x_pos,float y_pos) { std::vector<float> cur_coord(2,0.0); //for case of using static map float reference_origin_x =-4; float reference_origin_y =-4; float Grid_STEP=0.5; int num_grid=24; //for case of using static map // double reference_origin_x =-3.5; // double reference_origin_y =-3.5; float temp_x = x_pos-reference_origin_x; float temp_y = y_pos-reference_origin_y; cur_coord[0]= (int) (temp_x/Grid_STEP); cur_coord[1]= (int)(temp_y/Grid_STEP); int robot_pos_id=num_grid*cur_coord[1]+cur_coord[0]; //ROS_INFO("Robot pos ID : %d \n", robot_pos_id); return robot_pos_id; } void op_filter_manager::publish_target() { visualization_msgs::Marker marker_human; marker_human.header.frame_id = "/map"; marker_human.header.stamp = ros::Time::now(); marker_human.id = 0; uint32_t shape = visualization_msgs::Marker::SPHERE; marker_human.type = shape; //filtered_leg_target //publish marker marker_human.pose.position.x = leg_target[0]; marker_human.pose.position.y = leg_target[1]; //marker_human.pose.position.x = NN_laser_target[0]; //marker_human.pose.position.y = NN_laser_target[1]; marker_human.pose.position.z = 1; marker_human.pose.orientation.x = 0.0; marker_human.pose.orientation.y = 0.0; marker_human.pose.orientation.z = 0.0; marker_human.pose.orientation.w = 1.0; double temp_dist,temp_dist2,temp_dist3; temp_dist =0.5; temp_dist2 =0.5; temp_dist3 =0.5; //ROS_INFO("temp dist : %.3lf, temp dist2 : %.3lf, temp dist3 : %.3lf",temp_dist,temp_dist2,temp_dist3); marker_human.scale.x = std::abs(temp_dist); marker_human.scale.y = std::abs(temp_dist2); marker_human.scale.z = std::abs(temp_dist3); marker_human.color.r = 0.0; marker_human.color.g = 0.2; marker_human.color.b = 0.8; marker_human.color.a = 0.85; human_target_pub.publish(marker_human); // human_target_Intcmd_pub.publish(track_cmd); } void op_filter_manager::publish_filtered_target() { visualization_msgs::Marker marker_human; marker_human.header.frame_id = "/map"; marker_human.header.stamp = ros::Time::now(); marker_human.id = 0; uint32_t shape = visualization_msgs::Marker::SPHERE; marker_human.type = shape; //publish marker marker_human.pose.position.x = filtered_leg_target[0]; marker_human.pose.position.y = filtered_leg_target[1]; marker_human.pose.position.z = 1; marker_human.pose.orientation.x = 0.0; marker_human.pose.orientation.y = 0.0; marker_human.pose.orientation.z = 0.0; marker_human.pose.orientation.w = 1.0; double temp_dist,temp_dist2,temp_dist3; temp_dist =0.5; temp_dist2 =0.5; temp_dist3 =0.5; //ROS_INFO("temp dist : %.3lf, temp dist2 : %.3lf, temp dist3 : %.3lf",temp_dist,temp_dist2,temp_dist3); marker_human.scale.x = std::abs(temp_dist); marker_human.scale.y = std::abs(temp_dist2); marker_human.scale.z = std::abs(temp_dist3); marker_human.color.r = 0.0; marker_human.color.g = 0.7; marker_human.color.b = 0.2; marker_human.color.a = 0.85; filtered_human_target_pub.publish(marker_human); // human_target_Intcmd_pub.publish(track_cmd); } int op_filter_manager::FindNearestPoseIdx() { //target should be already set std::vector<double> Distanceset; // Distanceset.resize(Cur_detected_human.size(),0.0); Distanceset.resize(pose_people.size(),0.0); double minDistance=200.0; int minDistance_Idx=0; for(int i(0);i<pose_people.size();i++) { // Distanceset[i]=getDistance(Cur_detected_human[i][0],Cur_detected_human[i][1]); Distanceset[i]=getDistance_from_Vec(global_pose,pose_people[i][0],pose_people[i][1]); if(minDistance>Distanceset[i]) { minDistance=Distanceset[i]; minDistance_Idx=i; } } return minDistance_Idx; } int op_filter_manager::FindNearesetLegIdx() { //target should be already set std::vector<double> Distanceset; Distanceset.resize(Cur_leg_human.size(),0.0); double minDistance=200.0; int minDistance_Idx=0; for(int i(0);i<Cur_leg_human.size();i++) { Distanceset[i]=getDistance_from_Vec(filtered_leg_target,Cur_leg_human[i][0],Cur_leg_human[i][1]); if(minDistance>Distanceset[i]) { minDistance=Distanceset[i]; minDistance_Idx=i; } } return minDistance_Idx; } double op_filter_manager::getDistance_from_Vec(std::vector<double> origin, double _x, double _y) { double temp=0.0; temp=(origin[0]-_x)*(origin[0]-_x); temp+=(origin[1]-_y)*(origin[1]-_y); temp=sqrt(temp); return temp; } void op_filter_manager::filter_act_callback(const std_msgs::Int8::ConstPtr& msg) { if(msg->data==1) { if(cur_yolo_people.size()>0) { leg_target.resize(2,0.0); leg_target[0]=cur_yolo_people[0][0]; leg_target[1]=cur_yolo_people[0][1]; // ROS_INFO("set Target"); std::cout<<leg_target[0]<<", "<<leg_target[1]<<std::endl; // ROS_INFO("Filter : Set Target pos X : %.3lf, y : %.3lf", cur_yolo_people[0],cur_yolo_people[1]); } } } void op_filter_manager::global_pose_callback(const geometry_msgs::PoseStamped::ConstPtr& msg) { global_pose[0]=msg->pose.position.x; global_pose[1]=msg->pose.position.y; tf::StampedTransform baselinktransform; listener.waitForTransform("map", "base_link", ros::Time(0), ros::Duration(2.0)); listener.lookupTransform("map", "base_link", ros::Time(0), baselinktransform); double yaw_tf = tf::getYaw(baselinktransform.getRotation()); global_pose[2]=yaw_tf; } void op_filter_manager::chair_yolo_callback(const visualization_msgs::MarkerArray::ConstPtr& msg) { std::cout<<"chair recieved"<<std::endl; num_of_detected_chair=msg->markers.size(); if(num_of_detected_chair>0) cur_yolo_chair.resize(num_of_detected_chair); else { return; } for(int i(0);i<num_of_detected_chair;i++) { geometry_msgs::Vector3Stamped gV, tV; gV.vector.x = msg->markers[i].pose.position.x; gV.vector.y = msg->markers[i].pose.position.y; gV.vector.z = msg->markers[i].pose.position.z; // std::cout<<"x :"<<_x<<"_y:"<<_y<<"_z:"<<_z<<std::endl; tf::StampedTransform maptransform; listener.waitForTransform("head_rgbd_sensor_rgb_frame", "map", ros::Time(0), ros::Duration(1.0)); gV.header.stamp = ros::Time(); gV.header.frame_id = "/head_rgbd_sensor_rgb_frame"; listener.transformVector(std::string("/map"), gV, tV); cur_yolo_chair[i].resize(2,0.0); cur_yolo_chair[i][0]=tV.vector.x+global_pose[0]; cur_yolo_chair[i][1]=tV.vector.y+global_pose[1]; } } void op_filter_manager::openpose_pose_callback(const geometry_msgs::PoseArray::ConstPtr& msg) { //openpose comes w.r.t map frame //ROS_INFO("openposes callback: poses size : %d ", msg->poses.size()); //human_op_poses_array = *msg; std::vector<double> temp_target(2,0.0); int num_of_detected_human= msg->poses.size(); if(num_of_detected_human>0) { pose_people.resize(num_of_detected_human); for(int i(0);i<num_of_detected_human;i++) { pose_people[i].resize(2,0.0); pose_people[i][0]=msg->poses[i].position.x; pose_people[i][1]=msg->poses[i].position.y; } int NearestPoseIdx=FindNearestPoseIdx(); std::vector<double> temp_target(2,0.0); temp_target[0]=pose_people[NearestPoseIdx][0]; temp_target[1]=pose_people[NearestPoseIdx][1]; if(OnceTarget){ people_msgs::PositionMeasurement pos; pos.header.stamp = ros::Time(); pos.header.frame_id = "/map"; pos.name = "leg_laser"; pos.object_id ="person 0"; pos.pos.x = temp_target[0]; pos.pos.y = temp_target[1]; pos.pos.z = 1.0; pos.reliability = 0.85; pos.covariance[0] = pow(0.01 / pos.reliability, 2.0); pos.covariance[1] = 0.0; pos.covariance[2] = 0.0; pos.covariance[3] = 0.0; pos.covariance[4] = pow(0.01 / pos.reliability, 2.0); pos.covariance[5] = 0.0; pos.covariance[6] = 0.0; pos.covariance[7] = 0.0; pos.covariance[8] = 10000.0; pos.initialization = 0; people_measurement_pub_.publish(pos); } leg_target[0]=temp_target[0]; leg_target[1]=temp_target[1]; } else if(Cur_leg_human.size()>0){ //std::vector<double> temp_target(2,0.0); //temp_target[0]=NN_laser_target[0]; //temp_target[1]=NN_laser_target[1]; //people_msgs::PositionMeasurement pos; //pos.header.stamp = ros::Time(); //pos.header.frame_id = "/map"; //pos.name = "leg_laser"; //pos.object_id ="person 0"; //pos.pos.x = temp_target[0]; //pos.pos.y = temp_target[1]; //pos.pos.z = 1.0; //pos.reliability = 0.85; //pos.covariance[0] = pow(0.01 / pos.reliability, 2.0); //pos.covariance[1] = 0.0; //pos.covariance[2] = 0.0; //pos.covariance[3] = 0.0; //pos.covariance[4] = pow(0.01 / pos.reliability, 2.0); //pos.covariance[5] = 0.0; //pos.covariance[6] = 0.0; //pos.covariance[7] = 0.0; //pos.covariance[8] = 10000.0; //pos.initialization = 0; //people_measurement_pub_.publish(pos); //leg_target[0]=temp_target[0]; //leg_target[1]=temp_target[1]; } else { return; } //if(pose_people.size()>0) //{ //if(Comparetwopoistions(temp_target,leg_target,1.2)) //{ //std::cout<<"update target - person is in a range"<<std::endl; //leg_target[0]=temp_target[0]; //leg_target[1]=temp_target[1]; //} //if(OnceTarget){ //people_msgs::PositionMeasurement pos; //pos.header.stamp = ros::Time(); //pos.header.frame_id = "/map"; //pos.name = "leg_laser"; //pos.object_id ="person 0"; //pos.pos.x = temp_target[0]; //pos.pos.y = temp_target[1]; //pos.pos.z = 1.0; //pos.reliability = 0.85; //pos.covariance[0] = pow(0.01 / pos.reliability, 2.0); //pos.covariance[1] = 0.0; //pos.covariance[2] = 0.0; //pos.covariance[3] = 0.0; //pos.covariance[4] = pow(0.01 / pos.reliability, 2.0); //pos.covariance[5] = 0.0; //pos.covariance[6] = 0.0; //pos.covariance[7] = 0.0; //pos.covariance[8] = 10000.0; //pos.initialization = 0; //people_measurement_pub_.publish(pos); //leg_target[0]=temp_target[0]; //leg_target[1]=temp_target[1]; //} } void op_filter_manager::human_yolo_callback(const visualization_msgs::MarkerArray::ConstPtr& msg) { num_of_detected_human=msg->markers.size(); if(num_of_detected_human>0) cur_yolo_people.resize(num_of_detected_human); else { return; } for(int i(0);i<num_of_detected_human;i++) { //geometry_msgs::Vector3Stamped gV, tV; //gV.vector.x = msg->markers[i].pose.position.x; //gV.vector.y = msg->markers[i].pose.position.y; //gV.vector.z = msg->markers[i].pose.position.z; //std::cout<<"x :"<<_x<<"_y:"<<_y<<"_z:"<<_z<<std::endl; //tf::StampedTransform maptransform; //listener.waitForTransform("head_rgbd_sensor_rgb_frame", "map", ros::Time(0), ros::Duration(1.0)); //gV.header.stamp = ros::Time(); //gV.header.frame_id = "/head_rgbd_sensor_rgb_frame"; //listener.transformVector(std::string("/map"), gV, tV); //cur_yolo_people[i].resize(2,0.0); //cur_yolo_people[i][0]=tV.vector.x+global_pose[0]; //cur_yolo_people[i][1]=tV.vector.y+global_pose[1]; double time_sec = 0.0; geometry_msgs::PoseStamped poseInOriginCoords; geometry_msgs::PoseStamped poseInTargetCoords; //poseInTargetCoords.header.frame_id = target_frame; poseInOriginCoords.header.frame_id = "head_rgbd_sensor_rgb_frame"; poseInOriginCoords.header.stamp= ros::Time::now(); poseInOriginCoords.pose = msg->markers[i].pose; try{ ROS_DEBUG("Transforming received position into map frame"); //listener.waitForTransform(poseInTargetCoords.header.frame_id, BASE_LINK, poseInTargetCoords.header.stamp, ros::Duration(3.0)); listener.waitForTransform("head_rgbd_sensor_rgb_frame", "map", ros::Time(0), ros::Duration(1.0)); listener.transformPose("map", ros::Time(0), poseInOriginCoords, poseInOriginCoords.header.frame_id, poseInTargetCoords); }catch(tf::TransformException ex){ ROS_WARN("Failed transform: %s", ex.what()); continue; } cur_yolo_people[i].resize(2,0.0); cur_yolo_people[i][0]=poseInTargetCoords.pose.position.x; cur_yolo_people[i][1]=poseInTargetCoords.pose.position.y; } //ROS_INFO("yolo size"); // printf("size yolo : %d \n",cur_yolo_people.size()); } // callback for messages void op_filter_manager::callbackRcv(const people_msgs::PositionMeasurement::ConstPtr& msg) { } void op_filter_manager::publish_leg_boxes() { human_leg_boxes_array.markers.clear(); human_leg_poses_array.poses.clear(); if(Cur_leg_human.size()>0) { for(int i(0);i<Cur_leg_human.size();i++) { //geometry_msgsr geometry_msgs::Pose pose_human_leg; pose_human_leg.position.x=Cur_leg_human[i][0]; pose_human_leg.position.y=Cur_leg_human[i][1]; pose_human_leg.position.z=0.5; pose_human_leg.orientation.x=0.0; pose_human_leg.orientation.y=0.0; pose_human_leg.orientation.z=0.0; pose_human_leg.orientation.w=1.0; human_leg_poses_array.poses.push_back(pose_human_leg); //human_leg_poses_array.header.stamp=ros::Time::now(); //visualization_marker visualization_msgs::Marker marker_human_leg; marker_human_leg.header.frame_id = "/map"; marker_human_leg.header.stamp = ros::Time::now(); marker_human_leg.ns = "/human_leg_boxes"; marker_human_leg.id = i; uint32_t shape = visualization_msgs::Marker::SPHERE; marker_human_leg.type = shape; marker_human_leg.pose.position.x = Cur_leg_human[i][0]; marker_human_leg.pose.position.y = Cur_leg_human[i][1]; marker_human_leg.pose.position.z = 1; marker_human_leg.pose.orientation.x = 0.0; marker_human_leg.pose.orientation.y = 0.0; marker_human_leg.pose.orientation.z = 0.0; marker_human_leg.pose.orientation.w = 1.0; double temp_dist,temp_dist2,temp_dist3; temp_dist =0.5; temp_dist2 =0.5; temp_dist3 =0.5; //ROS_INFO("temp dist : %.3lf, temp dist2 : %.3lf, temp dist3 : %.3lf",temp_dist,temp_dist2,temp_dist3); marker_human_leg.scale.x = std::abs(temp_dist); marker_human_leg.scale.y = std::abs(temp_dist2); marker_human_leg.scale.z = std::abs(temp_dist3); marker_human_leg.color.r = 0.83; marker_human_leg.color.g = 0.6; marker_human_leg.color.b = 0.5; marker_human_leg.color.a = 0.85; human_leg_boxes_array.markers.push_back(marker_human_leg); } Leg_boxes_pub.publish(human_leg_boxes_array); human_leg_poses_array.header.stamp=ros::Time::now(); human_leg_poses_array.header.frame_id="map"; Leg_poses_pub.publish(human_leg_poses_array); } } int op_filter_manager::CoordinateTransform_Global2_staticMap(float global_x, float global_y) { double reference_origin_x=static_belief_map.info.origin.position.x; double reference_origin_y=static_belief_map.info.origin.position.y; //Find the coordinate w.r.t map origin double temp_x = global_x - reference_origin_x; double temp_y = global_y - reference_origin_y; //Find the map cell idx for x, y std::vector<int> human_coord(2,0); human_coord[0]= (int) (temp_x/static_belief_map.info.resolution); human_coord[1]= (int) (temp_y/static_belief_map.info.resolution); //Find the map index from cell x, y int static_map_idx= human_coord[0]+static_belief_map.info.width*human_coord[1]; // std::cout<<"map_idx : "<<static_map_idx<<std::endl; return static_map_idx; } bool op_filter_manager::Comparetwopoistions(std::vector<double> pos,std::vector<double> pos2, double criterion) { //return true if there are in criterion distance double temp_dist=0.0; for(int i(0);i<2;i++) { temp_dist+=pow((pos[i]-pos2[i]),2); } temp_dist=sqrt(temp_dist); if(temp_dist<criterion) return true; return false; } // filter loop void op_filter_manager::spin() { ROS_INFO("People tracking manager started."); while (ros::ok()) { publish_leg_boxes(); publish_cameraregion(); publish_target(); publish_filtered_target(); //call_navi_srv(); Publish_nav_target(); // ------ LOCKED ------ boost::mutex::scoped_lock lock(filter_mutex_); lock.unlock(); // ------ LOCKED ------ // sleep usleep(1e6 / freq_); ros::spinOnce(); } }; // ---------- // -- MAIN -- // ---------- int main(int argc, char **argv) { // Initialize ROS ros::init(argc, argv, "op_filter_tracker"); ros::NodeHandle(nh); // create tracker node op_filter_manager op_filter_node(nh); // wait for filter to finish op_filter_node.spin(); // Clean up return 0; }
22025cd97da41d111bdd67cb4de2fc0326ebe917
5cefb7624f97fcf5584930135d043f25de85dead
/ex10_21.cpp
5e818d50419c338a2fc0536ea8a65785666a56fa
[]
no_license
Merg12/Learning_CPP
6b7200c5ee566b0678b08ba8ff16c86d43ced507
0ce00849bab0fd064c75150635ff8220b7955902
refs/heads/master
2020-11-25T06:32:53.076298
2020-04-27T03:54:10
2020-04-27T03:54:10
174,651,837
0
0
null
null
null
null
UTF-8
C++
false
false
458
cpp
#include <iostream> int main() { int localCapture = 4; auto decrementToZero = [&localCapture]() ->int { while(localCapture) { if(localCapture == 0) { return 0; } else { --localCapture; std::cout << localCapture << std::endl; } } return -8; }; std::cout << decrementToZero() << std::endl; }
c85e249bdad4d8054b951acaa1b05acf0e08e852
8647405f234254c910e8d517551e41c348a5558e
/NULL/pic.cpp
3fc481ebb7aff54d120a3568148f68f673be0025
[]
no_license
LiuDongjing/undergraduate_works
156b0e9e1720a3c8790b761dbfca7350c43e7e60
c427025d0596522f0df50076e0cec406bee02751
refs/heads/master
2021-01-18T15:56:23.151119
2018-08-02T09:18:53
2018-08-02T09:18:53
86,696,081
0
0
null
null
null
null
UTF-8
C++
false
false
512
cpp
#include"conio.h> void border(int startx,int starty,int endx,int endy) { register int i; gotoxy(1,1); for(i=0;i<=endx-startx;i++) putch('-'); gotoxy(1,endy-starty); for(i=0;i<=endx-startx;i++) putch('-'); for(i=2;i<=endy-starty;i++){ gotoxy(1,i); putch('1'); gotoxy(endx-startx+1,i); putch('1'); } } main() { void border(int,int,int,int); clrscr(); window(6,8,38,12); border(6,8,38,12); &nbsp; gotoxy(2,2); printf("window 1"); window(8,16,40,24); border(8,16,40,24); gotoxy(3,2); printf("window 2"); getch(); }
97d610f8d75a693ca9d95fdc0fd5ee29bdda5f58
899776d24f3e21a962406fc9d8a27f657a5e4040
/text3d.cpp
eabb3e5810b7606a4b88507b4cc088d7c59975c6
[]
no_license
marcus-elia/integer-sequence-polyhedron
8155f23d95b65efbbb92daaf8d9d569db2302528
56b3327d098ca1442fdd47dbc085fdf3e80411ff
refs/heads/master
2021-01-09T12:29:47.752328
2020-04-28T12:31:39
2020-04-28T12:31:39
242,300,620
0
0
null
null
null
null
UTF-8
C++
false
false
785
cpp
#include "text3d.h" #include "graphics.h" Text3D::Text3D() : DrawableObject() { text = "???"; fontSize = 12; } Text3D::Text3D(point inputCenter, RGBAcolor inputColor, RGBAcolor inputHighlightedColor, std::string inputText,int inputFontSize) : DrawableObject(inputCenter, inputColor, inputHighlightedColor) { text = inputText; fontSize = inputFontSize; } void Text3D::draw() const { glColor3f(color.r, color.g, color.b); glRasterPos3i(center.x - (4 * text.length()), center.y + 7, center.z); for (const char &letter : text) { glutBitmapCharacter(GLUT_BITMAP_8_BY_13, letter); } } void Text3D::move(double delta_x, double delta_y, double delta_z) { center.x += delta_x; center.y += delta_y; center.z += delta_z; }
683e2bd8ba5188ebe5450bc24a8b78b13196b284
a92b18defb50c5d1118a11bc364f17b148312028
/src/prod/src/Naming/EntreeService.ResetPartitionLoadAsyncOperation.cpp
34f9ad9be790c64215c821726db2a3dad59a1dfa
[ "MIT" ]
permissive
KDSBest/service-fabric
34694e150fde662286e25f048fb763c97606382e
fe61c45b15a30fb089ad891c68c893b3a976e404
refs/heads/master
2023-01-28T23:19:25.040275
2020-11-30T11:11:58
2020-11-30T11:11:58
301,365,601
1
0
MIT
2020-11-30T11:11:59
2020-10-05T10:05:53
null
UTF-8
C++
false
false
2,812
cpp
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #include "stdafx.h" namespace Naming { using namespace std; using namespace Common; using namespace Transport; EntreeService::ResetPartitionLoadAsyncOperation::ResetPartitionLoadAsyncOperation( __in GatewayProperties & properties, MessageUPtr && receivedMessage, TimeSpan timeout, AsyncCallback const & callback, AsyncOperationSPtr const & parent) : AdminRequestAsyncOperationBase (properties, std::move(receivedMessage), timeout, callback, parent) { } void EntreeService::ResetPartitionLoadAsyncOperation::OnStartRequest(AsyncOperationSPtr const & thisSPtr) { TimedAsyncOperation::OnStart(thisSPtr); StartRequest(thisSPtr); } void EntreeService::ResetPartitionLoadAsyncOperation::StartRequest(AsyncOperationSPtr const& thisSPtr) { ResetPartitionLoadMessageBody body; if (ReceivedMessage->GetBody(body)) { AsyncOperationSPtr inner = Properties.AdminClient.BeginResetPartitionLoad( body.PartitionId, ActivityHeader, RemainingTime, [this] (AsyncOperationSPtr const& asyncOperation) { OnRequestCompleted(asyncOperation, false /*expectedCompletedSynchronously*/); }, thisSPtr); OnRequestCompleted(inner, true /*expectedCompletedSynchronously*/); } else { this->TryComplete(thisSPtr, ErrorCodeValue::InvalidMessage); } } void EntreeService::ResetPartitionLoadAsyncOperation::OnRequestCompleted( AsyncOperationSPtr const & asyncOperation, bool expectedCompletedSynchronously) { if (asyncOperation->CompletedSynchronously != expectedCompletedSynchronously) { return; } MessageUPtr adminClientReply; ErrorCode error = Properties.AdminClient.EndResetPartitionLoad(asyncOperation); if (error.IsSuccess()) { this->SetReplyAndComplete(asyncOperation->Parent, NamingMessage::GetResetPartitionLoadReply(), error); } else if (IsRetryable(error)) { HandleRetryStart(asyncOperation->Parent); } else { TryComplete(asyncOperation->Parent, error); } } void EntreeService::ResetPartitionLoadAsyncOperation::OnRetry(AsyncOperationSPtr const& thisSPtr) { StartRequest(thisSPtr); } }
a53becce9978774eaa87a32a07ae3cde5cbf4cea
19ab3bf54baf8ef0f38843eb45e2d51e241680dd
/source/core/SignalHandler/plugins/pythoninterpreter/scriptapiadapter.cpp
cdcd33604caed751cc9c083b46a584cdefd85658
[]
no_license
baekanem99/auxilo2
bbe22896c368741c5330b2affc681e8cc980b7ff
9f0d280df681ef455f82785fb1beac741f1da4ea
refs/heads/master
2023-06-26T11:19:56.331493
2018-01-30T05:57:36
2018-01-30T07:12:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
159
cpp
#include "scriptapiadapter.h" namespace PythonPlugin { ScriptApiAdapter::ScriptApiAdapter(SignalHandler::ScriptAPI *api) : api_(api) { } } // Namespace
3bc769e62587d3ec97c8521808fd79aca28da48b
43735399204a7f522f2403e9f65715015e2d974d
/dbcsignaleditor.h
139b0d6e3e3934d1599717492c64ccb87077edc0
[ "MIT" ]
permissive
Jaesin/SavvyCAN
df19e133bad3d3f931ba49fb16ddfe9f66fb5daa
f7bd31ab53c56ac77c4ab4008757b6528ef27a81
refs/heads/master
2021-01-18T14:41:14.561135
2015-11-24T03:05:27
2015-11-24T03:05:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,087
h
#ifndef DBCSIGNALEDITOR_H #define DBCSIGNALEDITOR_H #include <QDialog> #include "dbchandler.h" #include "utility.h" namespace Ui { class DBCSignalEditor; } class DBCSignalEditor : public QDialog { Q_OBJECT public: explicit DBCSignalEditor(DBCHandler *handler, QWidget *parent = 0); void setMessageRef(DBC_MESSAGE *msg); void showEvent(QShowEvent*); ~DBCSignalEditor(); private slots: void clickSignalList(int); void bitfieldClicked(int x, int y); void onValuesCellChanged(int row,int col); void onCustomMenuSignals(QPoint); void onCustomMenuValues(QPoint); void addNewSignal(); void deleteCurrentSignal(); void deleteCurrentValue(); private: Ui::DBCSignalEditor *ui; DBCHandler *dbcHandler; DBC_MESSAGE *dbcMessage; DBC_SIGNAL *currentSignal; bool inhibitCellChanged; void refreshSignalsList(); void fillSignalForm(DBC_SIGNAL *sig); void fillValueTable(DBC_SIGNAL *sig); void closeEvent(QCloseEvent *event); void readSettings(); void writeSettings(); }; #endif // DBCSIGNALEDITOR_H
2cc55c583f4c452fe4fa3ad396628806c477299e
15cda86e752ab9d7a437199b281ab92cbb420d26
/CrackingTheCodingInterview6/01-ArrayAndStrings/project/P1.3.Urlify.h
e9a328a40dddc6e14467563275a7ba66d9e2431e
[]
no_license
christianpopescu/TrainingRepo
831fa2f6ca9c7ba5016361c6ccb8adf30d6b152f
4f5ee51b07c80454827f6a9a65e361eef3549ac3
refs/heads/master
2022-04-13T17:08:42.644844
2020-04-02T09:36:13
2020-04-02T09:36:13
219,164,258
0
0
null
null
null
null
UTF-8
C++
false
false
247
h
#ifndef URLIFY_H #define URLIFY_H #include <string> #include <vector> class Urlify { public: void SetInput(char* in); // pass 0 terminated string void UrlifyString(); protected : char* buf; }; #endif // URLIFY_H
ab6adcb1312aa5cc4b2164585d3132fe3d70a9e9
0871826e400ca13780948b6e122b2f58efe17f9c
/Sobel_benchmark_tile_71_output/systemc/FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1.h
67406809eeb0f2c81836861d1cdf10664c3b15ed
[]
no_license
homidian/OpenVX-kernels-hdl-outputs
4b6159c6497ae4e6507032a0f04d7cd37f5ba3b2
8a8f51eea50860438867fbe786060879b6312c44
refs/heads/master
2021-07-19T08:36:06.846140
2017-10-27T23:17:05
2017-10-27T23:17:05
106,859,595
0
0
null
null
null
null
UTF-8
C++
false
false
6,044
h
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2016.1 // Copyright (C) 1986-2016 Xilinx, Inc. All Rights Reserved. // // ============================================================== #ifndef FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_HH_ #define FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_HH_ #include <systemc> using namespace std; SC_MODULE(FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1) { static const unsigned int DATA_WIDTH = 8; static const unsigned int ADDR_WIDTH = 1; static const unsigned int FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_depth = 2; sc_core::sc_in_clk clk; sc_core::sc_in< sc_dt::sc_logic > reset; sc_core::sc_out< sc_dt::sc_logic > if_empty_n; sc_core::sc_in< sc_dt::sc_logic > if_read_ce; sc_core::sc_in< sc_dt::sc_logic > if_read; sc_core::sc_out< sc_dt::sc_lv<DATA_WIDTH> > if_dout; sc_core::sc_out< sc_dt::sc_logic > if_full_n; sc_core::sc_in< sc_dt::sc_logic > if_write_ce; sc_core::sc_in< sc_dt::sc_logic > if_write; sc_core::sc_in< sc_dt::sc_lv<DATA_WIDTH> > if_din; sc_core::sc_signal< sc_dt::sc_logic > internal_empty_n; sc_core::sc_signal< sc_dt::sc_logic > internal_full_n; sc_core::sc_signal< sc_dt::sc_lv<DATA_WIDTH> > mStorage[FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_depth]; sc_core::sc_signal< sc_dt::sc_uint<ADDR_WIDTH> > mInPtr; sc_core::sc_signal< sc_dt::sc_uint<ADDR_WIDTH> > mOutPtr; sc_core::sc_signal< sc_dt::sc_uint<1> > mFlag_nEF_hint; sc_core::sc_trace_file* mTrace; SC_CTOR(FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1) : mTrace(0) { const char* dump_vcd = std::getenv("AP_WRITE_VCD"); if (dump_vcd && string(dump_vcd) == "1") { std::string tracefn = "sc_trace_" + std::string(name()); mTrace = sc_core::sc_create_vcd_trace_file( tracefn.c_str()); sc_trace(mTrace, clk, "(port)clk"); sc_trace(mTrace, reset, "(port)reset"); sc_trace(mTrace, if_full_n, "(port)if_full_n"); sc_trace(mTrace, if_write_ce, "(port)if_write_ce"); sc_trace(mTrace, if_write, "(port)if_write"); sc_trace(mTrace, if_din, "(port)if_din"); sc_trace(mTrace, if_empty_n, "(port)if_empty_n"); sc_trace(mTrace, if_read_ce, "(port)if_read_ce"); sc_trace(mTrace, if_read, "(port)if_read"); sc_trace(mTrace, if_dout, "(port)if_dout"); sc_trace(mTrace, mInPtr, "mInPtr"); sc_trace(mTrace, mOutPtr, "mOutPtr"); sc_trace(mTrace, mFlag_nEF_hint, "mFlag_nEF_hint"); } mInPtr = 0; mOutPtr = 0; mFlag_nEF_hint = 0; SC_METHOD(proc_read_write); sensitive << clk.pos(); SC_METHOD(proc_dout); sensitive << mOutPtr; for (unsigned i = 0; i < FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_depth; i++) { sensitive << mStorage[i]; } SC_METHOD(proc_ptr); sensitive << mInPtr << mOutPtr<< mFlag_nEF_hint; SC_METHOD(proc_status); sensitive << internal_empty_n << internal_full_n; } ~FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1() { if (mTrace) sc_core::sc_close_vcd_trace_file(mTrace); } void proc_status() { if_empty_n.write(internal_empty_n.read()); if_full_n.write(internal_full_n.read()); } void proc_read_write() { if (reset.read() == sc_dt::SC_LOGIC_1) { mInPtr.write(0); mOutPtr.write(0); mFlag_nEF_hint.write(0); } else { if (if_read_ce.read() == sc_dt::SC_LOGIC_1 && if_read.read() == sc_dt::SC_LOGIC_1 && internal_empty_n.read() == sc_dt::SC_LOGIC_1) { sc_dt::sc_uint<ADDR_WIDTH> ptr; if (mOutPtr.read().to_uint() == (FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_depth-1)) { ptr = 0; mFlag_nEF_hint.write(~mFlag_nEF_hint.read()); } else { ptr = mOutPtr.read(); ptr++; } assert(ptr.to_uint() < FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_depth); mOutPtr.write(ptr); } if (if_write_ce.read() == sc_dt::SC_LOGIC_1 && if_write.read() == sc_dt::SC_LOGIC_1 && internal_full_n.read() == sc_dt::SC_LOGIC_1) { sc_dt::sc_uint<ADDR_WIDTH> ptr; ptr = mInPtr.read(); mStorage[ptr.to_uint()].write(if_din.read()); if (ptr.to_uint() == (FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_depth-1)) { ptr = 0; mFlag_nEF_hint.write(~mFlag_nEF_hint.read()); } else { ptr++; assert(ptr.to_uint() < FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_depth); } mInPtr.write(ptr); } } } void proc_dout() { sc_dt::sc_uint<ADDR_WIDTH> ptr = mOutPtr.read(); if (ptr.to_uint() > FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_depth) { if_dout.write(sc_dt::sc_lv<DATA_WIDTH>()); } else { if_dout.write(mStorage[ptr.to_uint()]); } } void proc_ptr() { if (mInPtr.read() == mOutPtr.read() && mFlag_nEF_hint.read().to_uint()==0) { internal_empty_n.write(sc_dt::SC_LOGIC_0); } else { internal_empty_n.write(sc_dt::SC_LOGIC_1); } if (mInPtr.read() == mOutPtr.read() && mFlag_nEF_hint.read().to_uint()==1) { internal_full_n.write(sc_dt::SC_LOGIC_0); } else { internal_full_n.write(sc_dt::SC_LOGIC_1); } } }; #endif //FIFO_Sobel_vxSobel3x3_tile_grad_y_strm_in_V_pixel_1_HH_
248f3070df647c3c3aba0eb67a198dd82211dcc5
b88bf4a5772cc233e82c28eb45a8706df6a89a3d
/Module08/Module08/main.cpp
fe33384fe924376e7b9c26736a6a195701b069ce
[]
no_license
dfbacon/Cpp_Algo
5c3377adb4f7a42094809a840a8d0740fbf18e0f
d691531ae7b7b37fd48f556f52f367880a6ceb26
refs/heads/master
2020-07-22T03:51:49.021254
2019-12-13T08:21:23
2019-12-13T08:21:23
207,065,810
0
0
null
null
null
null
UTF-8
C++
false
false
2,968
cpp
// // Name: Daniel Bacon // Assignment: Module08 - Ch 10 Exercises #1, 3, 4, 5. Ch 11 Exercises #6 // #include <iostream> /** 10 - 1. Using Big O notation, indicate the time requirement of each of the following tasks in the worst case. Describe any assumptions that you make. Q: After arriving at a party, you shake hands with each person there. A: O(n). Assume shaking each person's hand one time and n is the number of people. Q: Each person in a room shakes hands with everyone else in the room. A: O(n^2). Same assumptions described above. Q: You climb a flight of stairs. A: O(n). n is the number of stairs. Q: You slide down the banister. A: O(1) Q: After entering an elevator, you press a button to choose a floor. A: O(1). Assuming you are only pressing a button. Q: You ride the elevator from the ground floor up to the nth floor. A: O(n). Assuming the elevator stops at all floors. n is the number of floors. Q: You read a book twice. A: 2*O(n) or just O(n). n is the number of pages in the book. ############################################################################## 10 - 3. Using Big O notation, indicate the time requirement of each of the following tasks in the worst case. Q: Computing the sum of the first n even integers by using a for loop. A: O(n) Q: Displaying all n integers in an array. A: O(n) Q: Displaying all n integers in a sorted linked chain A: O(n) Q: Displaying all n names in an array of linked chains A: O(n) Q: Displaying one array element A: O(1) Q: Displaying the last integer in a linked chain A: O(n) Q: Searching an array of n items for a particular value by using a sequential search A: O(n) Q: Searching an array of n items for a particular value by using a binary search A: O(n log n) Q: Adding an item to a stack of n items A: O(1) Q: Adding an item to a bag of n items A: O(1) ############################################################################## 10 - 4. What is the Big O of the algorithm? O(n^2 * 10) or just O(n^2). The inner-most loop runs a constant 10 times for the n number of times that the middle loop runs, which in turn is running n times (the outer loop). For Big O you drop the constants so the constant 10 is dropped leaving the nested loops of O(n^2). ############################################################################## 10 - 5. How many comparisons does f perform? Assuming n is a non-negative integer that is less-than-or-equal-to the size of the array. If this assumption is true, f performs n comparisons. ############################################################################## 11 - 6. How many comparisons would be needed to sort an array containing 25 entries using the bubble sort in: Q: The worst case? O(n^2) A: 625 Q: The best case? O(n) A: 25 */ int main(int argc, const char * argv[]) { return 0; }
d77ee7d5ee2cd7d898bd8947e73df29bf0ec7444
36ac342c1f400f7039b2f05071df3f4770320eb8
/HW1/main.cpp
ca006fb610421576f71f0df9dc4c9703f8b6a34a
[]
no_license
finch185277/Data-Structures-and-Object-oriented-Programming
d0e42b46698191f19866e8af2c7794897ae085d3
e6de39b61e1391233ee0ceb247929dc4245b4702
refs/heads/master
2022-02-23T17:53:09.937466
2019-10-19T06:02:21
2019-10-19T06:02:21
123,578,938
0
1
null
2019-10-19T06:02:22
2018-03-02T12:53:58
C++
UTF-8
C++
false
false
1,036
cpp
#include <bits/stdc++.h> #include "0616214_Date.h" using namespace std; // Driver Program to check your implementation int main() { Date date1(8, 3, 2018); Date date2 = date1.DateAfter(13); Date date3 = date1.DateBefore(25); date1.setDay(25); date2.setMonth(12); date3.setYear(2015); /*****test*****/ // cout << "d1: " << date1.getYear() << "/" << date1.getMonth() << "/" // << date1.getDay() <<endl; // cout << "d2: " << date2.getYear() << "/" << date2.getMonth() << "/" // << date2.getDay() <<endl; // cout << "d3: " << date3.getYear() << "/" << date3.getMonth() << "/" // << date3.getDay() <<endl; // date2.printMonthCalendar(); // test // cout << date2.day() << endl; // cout << "hello" << "\n"; // cout << date3.getDay() << "\n"; cout << date1.numberOfDays() << endl; cout << date2.dayOfWeek() << "\n"; date3.printMonthCalendar(); return 0; }
ebe0b80de1dcd19bc8897ee28755d7b42e7317d3
d1cd0f3830b16fd0a51e583ae5e3d8cb25b532e4
/BeaverTetris/proj.win32/CurrentVictoryConditionDataSource.h
78f68fd7d3b271ee9908c4345094835498ca1379
[]
no_license
sburavtsov/BeaverTetris
f5939afdfe417e1a5601b8e04db7d7b4ef21e5c7
fc28f5746b8c90073d82ca886d4d8e93d144897f
refs/heads/master
2021-01-18T08:55:59.364976
2014-12-18T19:46:51
2014-12-18T19:46:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
895
h
#pragma once #include <string> #include "CurrentLevelDataSource.h" #include "VictoryConditionInterface.h" #include "GameStructures.h" #include "VictoryConditionsFactory.h" class CurrentVictoryConditionDataSource { public: CurrentVictoryConditionDataSource(CurrentLevelDataSource *aCurrentLevelDataSource); ~CurrentVictoryConditionDataSource(void); int getVictoryConditionsCount(void); std::string getVictoryConditionNameForIndex(int aIndex); std::string getVictoryConditionInformationForIndex(int aIndex); void updateCurrentVictoryCondition(); bool winGameResult(); std::string getCurrentLevelName(); int getCurrentLevelAward(); void refreshDataSource(); private: CurrentLevelDataSource *_currentLevelDataSource; VictoryConditionInterface *_currentVictoryCondition; GameLevelInformation _currentLevelInformation; VictoryConditionsFactory *_victoryConditionsFactory; };
a05e2568aa48878c2ffcd71f97ab2af800abde6d
306c60c674af877691e42c28d5249faf27acbef3
/GLL/src/minecraft/player/Player.cpp
cddaf7b2602791eaa03748f73dd273788ba62ebd
[]
no_license
waynezxcv/playMC
f028dd9c89a6fa56d55a1b800437c071522d260c
0cb0723500e7b467c1c3c6c8b7d3e79da14e26fa
refs/heads/master
2020-07-10T17:16:56.989680
2019-09-07T17:35:18
2019-09-07T17:35:18
204,319,687
0
0
null
null
null
null
UTF-8
C++
false
false
23
cpp
#include "Player.hpp"
43a6f89fe1a469c5888a4301470aa4edb314fa07
7bdd4cee3cba43fc7ea851c8250deebfa5dbf832
/build/Android/Debug/app/src/main/include/Fuse.Controls.Native.-c20be635.h
b80b38a584abad1eab40d08cd24a5ec7806c22a3
[]
no_license
chaejaeyoun/App_function_login-Signup
d26ab8aa843320a4e9452d2b3b2842443e59fc95
6c2113adc785d7e22fb0fa498fcf449d0c9e6f2a
refs/heads/master
2020-04-27T05:48:26.173232
2019-03-13T10:42:58
2019-03-13T10:42:58
174,090,861
0
0
null
null
null
null
UTF-8
C++
false
false
691
h
// This file was generated based on /usr/local/share/uno/Packages/Fuse.Controls.Native/1.10.0-rc1/iOS/TextView.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.Object.h> namespace g{namespace Fuse{namespace Controls{namespace Native{namespace iOS{struct TextView;}}}}} namespace g{ namespace Fuse{ namespace Controls{ namespace Native{ namespace iOS{ // public sealed extern class TextView :6 // { uType* TextView_typeof(); void TextView__ctor__fn(TextView* __this); void TextView__New1_fn(TextView** __retval); struct TextView : uObject { void ctor_(); static TextView* New1(); }; // } }}}}} // ::g::Fuse::Controls::Native::iOS
a974f84350f362856da0c76b0b7ce18e16d0e1f0
6a44417fad3906ad14528baa4d4a49261cf942d4
/34_corr_matrix/asset.hpp
f4d2c0e48976d8bbd61ee937ae3649a98725075c
[]
no_license
frankhu311/FT510
3220cd5076b653193d5aeb5e273ad10a6c5cfd76
d07a2c5ec51d29d094b351966e18b93761649c34
refs/heads/master
2023-03-17T23:11:42.950653
2020-08-16T10:27:55
2020-08-16T10:27:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
534
hpp
#ifndef __ASSET_HPP__ #define __ASSET_HPP__ #include <cstdio> #include <cstdlib> #include <string> #include <cmath> #include <algorithm> #include <vector> class Asset { public: std::string name; std::vector<double> price; std::vector<double> ror;//time series rate of return double avr;//average return double sigma;//standard deviation int n;//the number of dates public: Asset(){} ~Asset(){} void calculateROR(); void calculateAvrSigma(); friend Asset* readData(char* s); }; #endif
963940137f07db7eac41bbbc09c1f790dd448458
d7666543209ebfd29299efb11e5d46d7342b330f
/src/IRSwapContract.h
61331aa944133e4bf81a0fc408f88dfbc081041d
[]
no_license
yhicc/FinancialLibrary
b2f6e46dce04d8acaf385cd2e4513134be3d484f
5b244a9f667e971d332bc35626aaaab92a671173
refs/heads/master
2021-01-18T00:48:22.190465
2017-07-07T15:43:53
2017-07-07T15:43:53
25,427,375
5
4
null
null
null
null
UTF-8
C++
false
false
1,469
h
#ifndef IRSWAPCONTRACT_H_INCLUDED_ #define IRSWAPCONTRACT_H_INCLUDED_ #include "BaseContract.h" #include <string> #include <vector> namespace FinLib{ class IRSwapContract : public BaseContract{ private: std::string m_effective_date; std::string m_currency; int m_fixed_or_float_payer; //0 == fixed, 1 == floating double m_notional_amount; double m_contract_term; //1year = 1 double m_payment_period; //6month = 0.5 double m_fixed_rate; double m_spread_on_index_rate; int m_day_count; double m_next_float_rate; int m_contract_info_set_flag; public: IRSwapContract(); virtual ~IRSwapContract(); void SetContractInfo( const std::string &effective_date, const std::string &currency, int fixed_or_float, double notional_amount, double contract_term, double payment_period, double fixed_rate, double spread_on_index_rate, int day_count, double next_float_rate ); double CalcPV( const std::string &valuation_date, const std::vector<int> &index_rate_term, const std::vector<double> &index_rate_value, int index_rate_day_count_basis, // ACT/360 == 360, ACT/365 == 365 int index_rate_compound_period, // PA == 1, SA == 2, Continuous == 0 const std::vector<int> &discount_curve_term, const std::vector<double> &discount_curve_value, int discount_rate_day_count_basis, // ACT/360 == 360, ACT/365 == 365 int discount_rate_compound_period // PA == 1, SA == 2, Continuous == 0 ); }; } #endif
8a29ce15a7421eaa3e8ffc494f19d070efe66bc9
095d246e628d08e9908c8ed7143807e41817b1c5
/WordLab/program/Base/database/database_chinese/GetWord.cpp
fc67670d2f52d4e40dd98007f2ead0670d33fe07
[]
no_license
yhnnd/wordlab
ab77e1b6099b0d519f2173d14ece5283cb766326
8a3563d6e38a4be3f01bde95b8112d75d081d64c
refs/heads/master
2023-09-01T21:32:15.251606
2023-07-19T03:23:48
2023-07-19T03:23:48
183,858,184
1
0
null
null
null
null
UTF-8
C++
false
false
263
cpp
string GetWord(int lth,int lineNumber){ int NOL=0; string line,def; ifstream fin; Library(fin,lth,lang::CH); while(!fin.eof()){ if(getline(fin,line)) NOL++; if(NOL==lineNumber){ def=line.substr(0,lth); break; } } fin.close(); return def; }
606be10ff415c95c9248dbf5623e792bf7f9f6e3
9808c0970f80c3260d1b91a226580aba3e52e2d5
/valdes-engineering/src/thermal/equipment/detector/simulate_measurements/periodic_properties.cpp
e1c4be223a6d4c2d72e421ab57dbb68abdeb43b9
[]
no_license
raymondvaldes/tat
5d519732efb5ed379be1ac2579a6dbf7ac67e52f
0fa3a1902cf81682d741fe0063435c6b61bac148
refs/heads/master
2021-01-18T15:42:09.009818
2015-10-30T16:55:23
2015-10-30T16:55:23
13,633,268
2
0
null
null
null
null
UTF-8
C++
false
false
637
cpp
// // periodic_properties.cpp // tat // // Created by Raymond Valdes on 10/2/15. // Copyright © 2015 Raymond Valdes. All rights reserved. // #include "periodic_properties.hpp" namespace thermal { namespace equipment { namespace detector{ namespace simulate_measurements{ //auto periodic_properties( // math::functions::PeriodicProperties< units::si::electric_potential > const & properties, // units::quantity< units::si::wavelength > const detector_wavelength, // size_t points //) noexcept -> Measurements; } // namespace simulate_measurements } // namespace detector } // namespace equipment } // namespace thermal
ebb8014265f9bbd3b69f737bc210221b74e9ff28
ba5d1d776888be6ae9688d850f0445d80973ee8f
/game/shared/func_ladder.cpp
05f81571fa8bfb48aa7c13de150b0125bfcdf0ff
[ "MIT" ]
permissive
BerntA/tfo-code
eb127b86111dce2b6f66e98c9476adc9ddbbd267
b82efd940246af8fe90cb76fa6a96bba42c277b7
refs/heads/master
2023-08-17T06:57:13.107323
2023-08-09T18:37:54
2023-08-09T18:37:54
41,260,457
16
5
MIT
2023-05-29T23:35:33
2015-08-23T17:52:50
C++
UTF-8
C++
false
false
15,473
cpp
//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // //=============================================================================// #include "cbase.h" #include "func_ladder.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" #if !defined( CLIENT_DLL ) /*static*/ ConVar sv_showladders( "sv_showladders", "0", 0, "Show bbox and dismount points for all ladders (must be set before level load.)\n" ); #endif CUtlVector< CFuncLadder * > CFuncLadder::s_Ladders; //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CFuncLadder::CFuncLadder() : m_bDisabled( false ) { s_Ladders.AddToTail( this ); } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CFuncLadder::~CFuncLadder() { s_Ladders.FindAndRemove( this ); } int CFuncLadder::GetLadderCount() { return s_Ladders.Count(); } CFuncLadder *CFuncLadder::GetLadder( int index ) { if ( index < 0 || index >= s_Ladders.Count() ) return NULL; return s_Ladders[ index ]; } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CFuncLadder::Spawn() { BaseClass::Spawn(); // Entity is symbolid SetSolid( SOLID_NONE ); SetMoveType( MOVETYPE_NONE ); SetCollisionGroup( COLLISION_GROUP_NONE ); //AddFlag( FL_WORLDBRUSH ); SetModelName( NULL_STRING ); // Make entity invisible AddEffects( EF_NODRAW ); // No model but should still network AddEFlags( EFL_FORCE_CHECK_TRANSMIT ); Vector playerMins = VEC_HULL_MIN; Vector playerMaxs = VEC_HULL_MAX; // This will swap them if they are inverted SetEndPoints( m_vecPlayerMountPositionTop, m_vecPlayerMountPositionBottom ); #if !defined( CLIENT_DLL ) trace_t bottomtrace, toptrace; UTIL_TraceHull( m_vecPlayerMountPositionBottom, m_vecPlayerMountPositionBottom, playerMins, playerMaxs, MASK_PLAYERSOLID_BRUSHONLY, NULL, COLLISION_GROUP_PLAYER_MOVEMENT, &bottomtrace ); UTIL_TraceHull( m_vecPlayerMountPositionTop, m_vecPlayerMountPositionTop, playerMins, playerMaxs, MASK_PLAYERSOLID_BRUSHONLY, NULL, COLLISION_GROUP_PLAYER_MOVEMENT, &toptrace ); if ( bottomtrace.startsolid || toptrace.startsolid ) { if ( bottomtrace.startsolid ) { DevMsg( 1, "Warning, funcladder with blocked bottom point (%.2f %.2f %.2f) stuck in (%s)\n", m_vecPlayerMountPositionBottom.GetX(), m_vecPlayerMountPositionBottom.GetY(), m_vecPlayerMountPositionBottom.GetZ(), bottomtrace.m_pEnt ? UTIL_VarArgs( "%s/%s", bottomtrace.m_pEnt->GetClassname(), bottomtrace.m_pEnt->GetEntityName().ToCStr() ) : "NULL" ); } if ( toptrace.startsolid ) { DevMsg( 1, "Warning, funcladder with blocked top point (%.2f %.2f %.2f) stuck in (%s)\n", m_vecPlayerMountPositionTop.GetX(), m_vecPlayerMountPositionTop.GetY(), m_vecPlayerMountPositionTop.GetZ(), toptrace.m_pEnt ? UTIL_VarArgs( "%s/%s", toptrace.m_pEnt->GetClassname(), toptrace.m_pEnt->GetEntityName().ToCStr() ) : "NULL" ); } // Force geometry overlays on, but only if developer 2 is set... if ( developer.GetInt() > 1 ) { m_debugOverlays |= OVERLAY_TEXT_BIT; } } m_vecPlayerMountPositionTop -= GetAbsOrigin(); m_vecPlayerMountPositionBottom -= GetAbsOrigin(); // Compute mins, maxs of points // Vector mins( MAX_COORD_INTEGER, MAX_COORD_INTEGER, MAX_COORD_INTEGER ); Vector maxs( -MAX_COORD_INTEGER, -MAX_COORD_INTEGER, -MAX_COORD_INTEGER ); int i; for ( i = 0; i < 3; i++ ) { if ( m_vecPlayerMountPositionBottom.m_Value[ i ] < mins[ i ] ) { mins[ i ] = m_vecPlayerMountPositionBottom.m_Value[ i ]; } if ( m_vecPlayerMountPositionBottom.m_Value[ i ] > maxs[ i ] ) { maxs[ i ] = m_vecPlayerMountPositionBottom.m_Value[ i ]; } if ( m_vecPlayerMountPositionTop.m_Value[ i ] < mins[ i ] ) { mins[ i ] = m_vecPlayerMountPositionTop.m_Value[ i ]; } if ( m_vecPlayerMountPositionTop.m_Value[ i ] > maxs[ i ] ) { maxs[ i ] = m_vecPlayerMountPositionTop.m_Value[ i ]; } } // Expand mins/maxs by player hull size mins += playerMins; maxs += playerMaxs; UTIL_SetSize( this, mins, maxs ); m_bFakeLadder = HasSpawnFlags(SF_LADDER_DONTGETON); #endif } //----------------------------------------------------------------------------- // Purpose: Called after all entities have spawned or after reload from .sav file //----------------------------------------------------------------------------- void CFuncLadder::Activate() { // Chain to base class BaseClass::Activate(); #if !defined( CLIENT_DLL ) // Re-hook up ladder dismount points SearchForDismountPoints(); // Show debugging UI if it's active if ( sv_showladders.GetBool() ) { m_debugOverlays |= OVERLAY_TEXT_BIT; } #endif } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CFuncLadder::SearchForDismountPoints() { #if !defined( CLIENT_DLL ) CUtlVector< CInfoLadderDismountHandle > allNodes; Vector topPos; Vector bottomPos; GetTopPosition( topPos ); GetBottomPosition( bottomPos ); float dismount_radius = 100.0f; Vector vecBottomToTop = topPos - bottomPos; float ladderLength = VectorNormalize( vecBottomToTop ); float recheck = 40.0f; // add both sets of nodes FindNearbyDismountPoints( topPos, dismount_radius, m_Dismounts ); FindNearbyDismountPoints( bottomPos, dismount_radius, m_Dismounts ); while ( 1 ) { ladderLength -= recheck; if ( ladderLength <= 0.0f ) break; bottomPos += recheck * vecBottomToTop; FindNearbyDismountPoints( bottomPos, dismount_radius, m_Dismounts ); } #endif } void CFuncLadder::SetEndPoints( const Vector& p1, const Vector& p2 ) { m_vecPlayerMountPositionTop = p1; m_vecPlayerMountPositionBottom = p2; if ( m_vecPlayerMountPositionBottom.GetZ() > m_vecPlayerMountPositionTop.GetZ() ) { Vector temp = m_vecPlayerMountPositionBottom; m_vecPlayerMountPositionBottom = m_vecPlayerMountPositionTop; m_vecPlayerMountPositionTop = temp; } #if !defined( CLIENT_DLL) Vector playerMins = VEC_HULL_MIN; Vector playerMaxs = VEC_HULL_MAX; trace_t result; UTIL_TraceHull( m_vecPlayerMountPositionTop + Vector( 0, 0, 4 ), m_vecPlayerMountPositionTop, playerMins, playerMaxs, MASK_PLAYERSOLID_BRUSHONLY, NULL, COLLISION_GROUP_PLAYER_MOVEMENT, &result ); if ( !result.startsolid ) { m_vecPlayerMountPositionTop = result.endpos; } UTIL_TraceHull( m_vecPlayerMountPositionBottom + Vector( 0, 0, 4 ), m_vecPlayerMountPositionBottom, playerMins, playerMaxs, MASK_PLAYERSOLID_BRUSHONLY, NULL, COLLISION_GROUP_PLAYER_MOVEMENT, &result ); if ( !result.startsolid ) { m_vecPlayerMountPositionBottom = result.endpos; } #endif } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CFuncLadder::DrawDebugGeometryOverlays() { #if !defined( CLIENT_DLL ) BaseClass::DrawDebugGeometryOverlays(); Vector playerMins = VEC_HULL_MIN; Vector playerMaxs = VEC_HULL_MAX; Vector topPosition; Vector bottomPosition; GetTopPosition( topPosition ); GetBottomPosition( bottomPosition ); NDebugOverlay::Box( topPosition, playerMins, playerMaxs, 255,0,0,127, 0 ); NDebugOverlay::Box( bottomPosition, playerMins, playerMaxs, 0,0,255,127, 0 ); NDebugOverlay::EntityBounds(this, 200, 180, 63, 63, 0); trace_t bottomtrace; UTIL_TraceHull( m_vecPlayerMountPositionBottom, m_vecPlayerMountPositionBottom, playerMins, playerMaxs, MASK_PLAYERSOLID_BRUSHONLY, NULL, COLLISION_GROUP_PLAYER_MOVEMENT, &bottomtrace ); int c = m_Dismounts.Count(); for ( int i = 0 ; i < c ; i++ ) { CInfoLadderDismount *pt = m_Dismounts[ i ]; if ( !pt ) continue; NDebugOverlay::Box(pt->GetAbsOrigin(),Vector( -16, -16, 0 ), Vector( 16, 16, 8 ), 150,0,0, 63, 0); } #endif } //----------------------------------------------------------------------------- // Purpose: // Input : org - //----------------------------------------------------------------------------- void CFuncLadder::GetTopPosition( Vector& org ) { ComputeAbsPosition( m_vecPlayerMountPositionTop + GetLocalOrigin(), &org ); } //----------------------------------------------------------------------------- // Purpose: // Input : org - //----------------------------------------------------------------------------- void CFuncLadder::GetBottomPosition( Vector& org ) { ComputeAbsPosition( m_vecPlayerMountPositionBottom + GetLocalOrigin(), &org ); } //----------------------------------------------------------------------------- // Purpose: // Input : bottomToTopVec - //----------------------------------------------------------------------------- void CFuncLadder::ComputeLadderDir( Vector& bottomToTopVec ) { Vector top; Vector bottom; GetTopPosition( top ); GetBottomPosition( bottom ); bottomToTopVec = top - bottom; } //----------------------------------------------------------------------------- // Purpose: // Output : int //----------------------------------------------------------------------------- int CFuncLadder::GetDismountCount() const { return m_Dismounts.Count(); } //----------------------------------------------------------------------------- // Purpose: // Input : index - // Output : CInfoLadderDismountHandle //----------------------------------------------------------------------------- CInfoLadderDismount *CFuncLadder::GetDismount( int index ) { if ( index < 0 || index >= m_Dismounts.Count() ) return NULL; return m_Dismounts[ index ]; } //----------------------------------------------------------------------------- // Purpose: // Input : origin - // radius - // list - //----------------------------------------------------------------------------- void CFuncLadder::FindNearbyDismountPoints( const Vector& origin, float radius, CUtlVector< CInfoLadderDismountHandle >& list ) { #if !defined( CLIENT_DLL ) CBaseEntity *pEntity = NULL; while ( (pEntity = gEntList.FindEntityByClassnameWithin( pEntity, "info_ladder_dismount", origin, radius)) != NULL ) { CInfoLadderDismount *landingspot = static_cast< CInfoLadderDismount * >( pEntity ); Assert( landingspot ); // If spot has a target, then if the target is not this ladder, don't add to our list. if ( landingspot->m_target != NULL_STRING ) { if ( landingspot->GetNextTarget() != this ) { continue; } } CInfoLadderDismountHandle handle; handle = landingspot; if ( list.Find( handle ) == list.InvalidIndex() ) { list.AddToTail( handle ); } } #endif } //----------------------------------------------------------------------------- // Purpose: // Input : &inputdata - //----------------------------------------------------------------------------- void CFuncLadder::InputEnable( inputdata_t &inputdata ) { m_bDisabled = false; } //----------------------------------------------------------------------------- // Purpose: // Input : &inputdata - //----------------------------------------------------------------------------- void CFuncLadder::InputDisable( inputdata_t &inputdata ) { m_bDisabled = true; } //----------------------------------------------------------------------------- // Purpose: // Input : *pPlayer - //----------------------------------------------------------------------------- void CFuncLadder::PlayerGotOn( CBasePlayer *pPlayer ) { #if !defined( CLIENT_DLL ) m_OnPlayerGotOnLadder.FireOutput(this, pPlayer); pPlayer->EmitSound( "Ladder.StepRight" ); #endif } //----------------------------------------------------------------------------- // Purpose: // Input : *pPlayer - //----------------------------------------------------------------------------- void CFuncLadder::PlayerGotOff( CBasePlayer *pPlayer ) { #if !defined( CLIENT_DLL ) m_OnPlayerGotOffLadder.FireOutput(this, pPlayer); #endif } //----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CFuncLadder::DontGetOnLadder( void ) const { return m_bFakeLadder; } #if !defined(CLIENT_DLL) const char *CFuncLadder::GetSurfacePropName() { if ( !m_surfacePropName ) return NULL; return m_surfacePropName.ToCStr(); } #endif IMPLEMENT_NETWORKCLASS_ALIASED( FuncLadder, DT_FuncLadder ); BEGIN_NETWORK_TABLE( CFuncLadder, DT_FuncLadder ) #if !defined( CLIENT_DLL ) SendPropVector( SENDINFO( m_vecPlayerMountPositionTop ), SPROP_COORD ), SendPropVector( SENDINFO( m_vecPlayerMountPositionBottom ), SPROP_COORD ), SendPropVector( SENDINFO( m_vecLadderDir ), SPROP_COORD ), SendPropBool( SENDINFO( m_bFakeLadder ) ), // SendPropStringT( SENDINFO(m_surfacePropName) ), #else RecvPropVector( RECVINFO( m_vecPlayerMountPositionTop ) ), RecvPropVector( RECVINFO( m_vecPlayerMountPositionBottom )), RecvPropVector( RECVINFO( m_vecLadderDir )), RecvPropBool( RECVINFO( m_bFakeLadder ) ), #endif END_NETWORK_TABLE() LINK_ENTITY_TO_CLASS( func_useableladder, CFuncLadder ); //--------------------------------------------------------- // Save/Restore //--------------------------------------------------------- BEGIN_DATADESC( CFuncLadder ) DEFINE_KEYFIELD( m_vecPlayerMountPositionTop, FIELD_VECTOR, "point0" ), DEFINE_KEYFIELD( m_vecPlayerMountPositionBottom, FIELD_VECTOR, "point1" ), DEFINE_FIELD( m_vecLadderDir, FIELD_VECTOR ), // DEFINE_FIELD( m_Dismounts, FIELD_UTLVECTOR ), DEFINE_FIELD( m_bFakeLadder, FIELD_BOOLEAN ), DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), #if !defined( CLIENT_DLL ) DEFINE_KEYFIELD( m_surfacePropName,FIELD_STRING, "ladderSurfaceProperties" ), DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), DEFINE_OUTPUT( m_OnPlayerGotOnLadder, "OnPlayerGotOnLadder" ), DEFINE_OUTPUT( m_OnPlayerGotOffLadder, "OnPlayerGotOffLadder" ), #endif END_DATADESC() //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CInfoLadderDismount::DrawDebugGeometryOverlays() { #if !defined( CLIENT_DLL ) BaseClass::DrawDebugGeometryOverlays(); if ( developer.GetBool() ) { NDebugOverlay::Box( GetAbsOrigin(), Vector( -16, -16, 0 ), Vector( 16, 16, 8 ), 127, 127, 127, 127, 0 ); } #endif } #if defined( GAME_DLL ) int CFuncLadder::UpdateTransmitState() { // transmit if in PVS for clientside prediction return SetTransmitState( FL_EDICT_PVSCHECK ); } #endif IMPLEMENT_NETWORKCLASS_ALIASED( InfoLadderDismount, DT_InfoLadderDismount ); BEGIN_NETWORK_TABLE( CInfoLadderDismount, DT_InfoLadderDismount ) END_NETWORK_TABLE() LINK_ENTITY_TO_CLASS( info_ladder_dismount, CInfoLadderDismount ); #if defined(GAME_DLL) const char *FuncLadder_GetSurfaceprops(CBaseEntity *pLadderEntity) { CFuncLadder *pLadder = dynamic_cast<CFuncLadder *>(pLadderEntity); if ( pLadder ) { if ( pLadder->GetSurfacePropName() ) return pLadder->GetSurfacePropName(); } return "ladder"; } #endif
15369aae2c118a16543e376d413acb352469825e
7a6f0bffd3cc7ad45b4ad9b771fd57961f93fb2e
/source/Kairy/Graphics/ShaderProgram.cpp
98a1829345675b0727bda8fa34d12bccc0f7270a
[]
no_license
miosama246/Kairy
74041423bee385af6d16155fafb6ca5dae7c4963
8701218c40f6e3877d40ea725f402bf9a2fb1e31
refs/heads/master
2020-05-31T19:05:30.521549
2015-11-03T17:49:12
2015-11-03T17:49:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,173
cpp
/****************************************************************************** * * Copyright (C) 2015 Nanni * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * *****************************************************************************/ #include <Kairy/Graphics/ShaderProgram.h> #include <Kairy/Graphics/RenderDevice.h> NS_KAIRY_BEGIN //============================================================================= ShaderProgram* ShaderProgram::s_currentProgram = nullptr; //============================================================================= ShaderProgram::ShaderProgram(void) :_initialized(false) #ifndef _3DS , _program(0) #endif // _3DS { } //============================================================================= ShaderProgram::ShaderProgram(const byte* vsh_data, Uint32 vsh_data_size) : ShaderProgram() { load(vsh_data, vsh_data_size); } //============================================================================= ShaderProgram::~ShaderProgram() { unload(); if(_initialized) { #ifdef _3DS shaderProgramFree(&_shaderProgram); #endif // _3DS } if(s_currentProgram == this) { s_currentProgram = nullptr; } } //============================================================================= bool ShaderProgram::load(const byte* vsh_data, Uint32 vsh_data_size) { unload(); if(vsh_data == nullptr || vsh_data_size == 0 || !RenderDevice::getInstance()->isInitialized()) { return false; } #ifdef _3DS _vertexShader = DVLB_ParseFile((u32*)vsh_data, vsh_data_size); if(_vertexShader == nullptr) { return false; } if(!_initialized) { shaderProgramInit(&_shaderProgram); _initialized = true; } shaderProgramSetVsh(&_shaderProgram, &_vertexShader->DVLE[0]); #else constexpr const char* fShaderData = "#version 330 core\n" "in vec4 color;\n" "in vec2 texCoords;\n" "out vec4 outColor;\n" "uniform sampler2D uTexture;\n" "uniform bool textureEnabled = true;\n" "void main() {\n" "if(textureEnabled) {" "outColor = texture(uTexture, texCoords) * color;\n" "} else {\n" "outColor = color;\n" "}\n" "}\n"; const GLint fShaderDataLen = strlen(fShaderData); const char* vShaderData = (const char*)vsh_data; const GLint vShaderDataLen = vsh_data_size; GLuint vshaderId = glCreateShader(GL_VERTEX_SHADER); GLuint fshaderId = glCreateShader(GL_FRAGMENT_SHADER); if (vshaderId == 0) { return false; } if (fshaderId == 0) { return false; } _program = glCreateProgram(); if (_program == 0) { return false; } glShaderSource(fshaderId, 1, &fShaderData, &fShaderDataLen); glShaderSource(vshaderId, 1, &vShaderData, &vShaderDataLen); glCompileShader(fshaderId); glCompileShader(vshaderId); GLint result = 0; glGetShaderiv(vshaderId, GL_COMPILE_STATUS, &result); if (result == GL_FALSE) { return false; } glGetShaderiv(fshaderId, GL_COMPILE_STATUS, &result); if (result == GL_FALSE) { return false; } glAttachShader(_program, vshaderId); glAttachShader(_program, fshaderId); glLinkProgram(_program); glGetProgramiv(_program, GL_LINK_STATUS, &result); if (result == GL_FALSE) { return false; } glValidateProgram(_program); glDeleteShader(vshaderId); glDeleteShader(fshaderId); _initialized = true; #endif // _3DS return true; } //============================================================================= void ShaderProgram::unload() { _locationsMap.clear(); #ifdef _3DS if(_vertexShader) { DVLB_Free(_vertexShader); _vertexShader = nullptr; } if(_initialized) { shaderProgramSetVsh(&_shaderProgram, nullptr); } #else if (_program != 0) { glDeleteProgram(_program); _program = 0; } #endif // _3DS } //============================================================================= void ShaderProgram::use() { if(_initialized && s_currentProgram != this) { #ifdef _3DS shaderProgramUse(&_shaderProgram); #else glUseProgram(_program); #endif // _3DS s_currentProgram = this; } } //============================================================================= int ShaderProgram::getUniformLocation(const std::string& name) const { if(!_initialized) { return -1; } auto it = _locationsMap.find(name); if(it != _locationsMap.end()) { return it->second; } int result; #ifdef _3DS result = shaderInstanceGetUniformLocation(_shaderProgram.vertexShader, name.c_str()); #else result = glGetUniformLocation(_program, name.c_str()); #endif // _3DS if(result >= 0) { _locationsMap[name] = result; } return result; } //============================================================================= void ShaderProgram::setUniform(const std::string& name, float value) { if(s_currentProgram && s_currentProgram->_initialized) { #ifdef _3DS GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)&value, 1); #else glUniform1f(s_currentProgram->getUniformLocation(name), value); #endif // _3DS } } //============================================================================= void ShaderProgram::setUniform(const std::string& name, float x, float y, float z) { if(s_currentProgram && s_currentProgram->_initialized) { #ifdef _3DS float values[] = { x, y, z }; GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)values, 3); #else glUniform3f(s_currentProgram->getUniformLocation(name), x, y, z); #endif // _3DS } } //============================================================================= void ShaderProgram::setUniform(const std::string& name, float x, float y, float z, float w) { if(s_currentProgram && s_currentProgram->_initialized) { #ifdef _3DS float values[] = { x, y, z, w }; GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)values, 4); #else glUniform4f(s_currentProgram->getUniformLocation(name), x, y, z, w); #endif // _3DS } } //============================================================================= void ShaderProgram::setUniform(const std::string& name, const Vec4& v4) { if(s_currentProgram && s_currentProgram->_initialized) { #ifdef _3DS GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)&v4, 4); #else glUniform4f(s_currentProgram->getUniformLocation(name), v4.x, v4.y, v4.z, v4.w); #endif // _3DS } } //============================================================================= void ShaderProgram::setUniform(const std::string& name, const Vec3& v3) { if(s_currentProgram && s_currentProgram->_initialized) { #ifdef _3DS GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)&v3, 3); #else glUniform3f(s_currentProgram->getUniformLocation(name), v3.x, v3.y, v3.z); #endif // _3DS } } //============================================================================= void ShaderProgram::setUniform(const std::string& name, const Transform& t) { if(s_currentProgram && s_currentProgram->_initialized) { float mu[16]; for(int i = 0; i < 4; ++i) { for(int j = 0; j < 4; ++j) { mu[i*4 + j] = t.getValue(3 - j, i); } } #ifdef _3DS GPU_SetFloatUniform(GPU_VERTEX_SHADER, s_currentProgram->getUniformLocation(name), (u32*)mu, 4); #else glUniformMatrix4fv(s_currentProgram->getUniformLocation(name), 1, GL_TRUE, (float*)&t); #endif // _3DS } } //============================================================================= NS_KAIRY_END
d49da7de9d00bae1a044203dbb0f6d10d1530e6e
906e77c7ff16e8a5ffb67995f247ded73a69dd59
/Cpp/SDK/BP_Item_Rifle_M16_classes.h
5b94863aa070214a70ae15ecf92fd6e1b51dbf63
[]
no_license
zH4x-SDK/zPolygon-SDK
d49400829f1d4b7ec63ff6bebd790dd8d96bb8eb
3ff60c347b015d858779b8fd2308239176f1ed01
refs/heads/main
2023-07-25T12:16:54.962926
2021-08-27T14:17:29
2021-08-27T14:17:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,305
h
#pragma once // Name: Polygon, Version: 0.3.13.76 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_Item_Rifle_M16.BP_Item_Rifle_M16_C // 0x0010 (FullSize[0x03F0] - InheritedSize[0x03E0]) class ABP_Item_Rifle_M16_C : public AItem_Weapon_Rifle { public: struct FPointerToUberGraphFrame UberGraphFrame; // 0x03E0(0x0008) (ZeroConstructor, Transient, DuplicateTransient) class UStaticMeshComponent* Sight; // 0x03E8(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NonTransactional, NoDestructor, HasGetValueTypeHash) static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_Item_Rifle_M16.BP_Item_Rifle_M16_C"); return ptr; } void SetSight(); void ReceiveBeginPlay(); void OnSetWeaponModules_Event(); void ExecuteUbergraph_BP_Item_Rifle_M16(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
66f8dd1afb45c02ef1cd90a1241388449cde5eb0
beaf6a2b662acb7edf669f97c8a92b75ae8abc5a
/ex7.cpp
815988fb77b54b66b533f5fef9dae11156866284
[]
no_license
LaisaRuiz/TPA
800d4ff03728bfd282249aec25c7441f3ef208da
14d39f5fdacb879681acfe630bd5718b04a76ed0
refs/heads/master
2020-08-03T08:55:59.071901
2019-12-04T13:18:38
2019-12-04T13:18:38
211,692,082
0
0
null
null
null
null
ISO-8859-1
C++
false
false
578
cpp
/*Programa: Exercício 13 Função: Calcule o salário de um funcionario e o percentual de aumento e seu novo salário Autora: Laisa Cristiana Gonçalves Ruiz Data: 29/09/2019 */ #include <stdio.h> #include <locale.h> #include <windows.h> int main(){ setlocale(LC_ALL,""); float valorsal=0, percentuau=0, total=0; printf("Informe o valor do salário: "); scanf("%f", &valorsal); printf("Informe o percentual de aumento: "); scanf("%f", &percentuau); total = valorsal + (valorsal * (percentuau/100)); printf("O valor do novo salário é: %f", total); }
7ef2df8a0a7d776ebdb0f4975d971210fdedb462
01b1f86aa05da3543a2399ffc34a8ba91183e896
/modules/core/generative/unit/table/sqrt_2o_3.cpp
6cb02f068ec15bae55d4205b77275aaece5c7841
[ "BSL-1.0" ]
permissive
jtlap/nt2
8070b7b3c4b2f47c73fdc7006b0b0eb8bfc8306a
1b97350249a4e50804c2f33e4422d401d930eccc
refs/heads/master
2020-12-25T00:49:56.954908
2015-05-04T12:09:18
2015-05-04T12:09:18
1,045,122
35
7
null
null
null
null
UTF-8
C++
false
false
5,976
cpp
//============================================================================== // Copyright 2003 - 2011 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2013 LRI UMR 8623 CNRS/Univ Paris Sud XI // Copyright 2012 - 2013 MetaScale SAS // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #include <nt2/table.hpp> #include <nt2/include/functions/size.hpp> #include <nt2/include/functions/sqrt_2o_3.hpp> #include <nt2/include/constants/sqrt_2o_3.hpp> #include <nt2/sdk/unit/module.hpp> #include <nt2/sdk/unit/tests/basic.hpp> #include <nt2/sdk/unit/tests/relation.hpp> #include <nt2/sdk/unit/tests/type_expr.hpp> #include <nt2/sdk/unit/tests/exceptions.hpp> #include <boost/dispatch/meta/nth_hierarchy.hpp> NT2_TEST_CASE( hierarchy ) { using boost::mpl::_; using boost::mpl::int_; using boost::dispatch::meta::nth_hierarchy; NT2_TEST_EXPR_TYPE( (nt2::tag::Sqrt_2o_3() ) , (nth_hierarchy<_,int_<0> >) , (nt2::tag::Sqrt_2o_3) ); NT2_TEST_EXPR_TYPE( (nt2::tag::Sqrt_2o_3() ) , (nth_hierarchy<_,int_<1> >) , (nt2::ext::pure_constant_< nt2::tag::Sqrt_2o_3 > ) ); NT2_TEST_EXPR_TYPE( (nt2::tag::Sqrt_2o_3() ) , (nth_hierarchy<_,int_<2> >) , (nt2::ext::constant_< nt2::tag::Sqrt_2o_3 > ) ); NT2_TEST_EXPR_TYPE( (nt2::tag::Sqrt_2o_3() ) , (nth_hierarchy<_,int_<3> >) , (nt2::ext::elementwise_<nt2::tag::Sqrt_2o_3>) ); NT2_TEST_EXPR_TYPE( (nt2::tag::Sqrt_2o_3() ) , (nth_hierarchy<_,int_<4> >) , (nt2::ext::unspecified_<nt2::tag::Sqrt_2o_3>) ); } NT2_TEST_CASE_TPL( _0d_typed, NT2_TYPES ) { using boost::mpl::_; using nt2::meta::as_; using nt2::meta::value_type_; nt2::table< T > x1 = nt2::sqrt_2o_3( as_< T >() ); NT2_TEST_EXPR_TYPE( x1, (value_type_<_>), (T) ); NT2_TEST_EQUAL( nt2::extent(x1), nt2::of_size(1) ); NT2_TEST_EQUAL( x1(1), nt2::Sqrt_2o_3<T>() ); } NT2_TEST_CASE( untyped_square ) { using boost::mpl::_; using nt2::meta::value_type_; nt2::table< double > ref( nt2::of_size(3,3) ); for(int i=1;i<= 3;++i) for(int j=1;j<= 3;++j) ref(i,j) = nt2::Sqrt_2o_3<double>(); nt2::table< double > x0 = nt2::sqrt_2o_3(3); NT2_TEST_EXPR_TYPE( (nt2::sqrt_2o_3( 3 )), (value_type_<_>), (double) ); NT2_TEST_EQUAL( nt2::extent(x0), nt2::of_size(3,3) ); NT2_TEST_EQUAL( x0,ref ); } NT2_TEST_CASE( nd_untyped ) { using boost::mpl::_; using nt2::meta::value_type_; nt2::table< double > ref( nt2::of_size(8,4) ); for(int j=1;j<= 4;++j) for(int i=1;i<= 8;++i) ref(i,j) = nt2::Sqrt_2o_3<double>(); nt2::table< double > x1 = nt2::sqrt_2o_3(8, 4); NT2_TEST_EXPR_TYPE( (nt2::sqrt_2o_3(8,4)), (value_type_<_>), (double) ); NT2_TEST_EQUAL( nt2::extent(x1), nt2::of_size(8,4) ); NT2_TEST_EQUAL(x1,ref); ref.resize( nt2::of_size(1,4) ); for(int j=1;j<= 4;++j) ref(1,j) = nt2::Sqrt_2o_3<double>(); nt2::table< double > x2 = nt2::sqrt_2o_3(1, 4); NT2_TEST_EQUAL( nt2::extent(x2), nt2::of_size(1,4) ); NT2_TEST_EQUAL(x2,ref); ref.resize( nt2::of_size(7,1) ); for(int i=1;i<= 7;++i) ref(i,1) = nt2::Sqrt_2o_3<double>(); nt2::table< double > x3 = nt2::sqrt_2o_3(7,1); NT2_TEST_EQUAL( nt2::extent(x3), nt2::of_size(7,1) ); NT2_TEST_EQUAL(x3,ref); } NT2_TEST_CASE_TPL( nd_typed, NT2_TYPES ) { using boost::mpl::_; using nt2::meta::as_; using nt2::meta::value_type_; nt2::table< T > ref( nt2::of_size(8,8) ); for(int j=1;j<= 8;++j) for(int i=1;i<= 8;++i) ref(i,j) = nt2::Sqrt_2o_3<T>(); nt2::table< T > x1 = nt2::sqrt_2o_3(nt2::of_size(8, 8), as_< T >() ); NT2_TEST_EXPR_TYPE( (nt2::sqrt_2o_3( nt2::of_size(8, 8), as_< T >() )), (value_type_<_>), (T) ); NT2_TEST_EQUAL(x1,ref); nt2::table< T > x2 = nt2::sqrt_2o_3(8, 8, as_< T >() ); NT2_TEST_EQUAL(x2,ref); nt2::table< T > x3 = nt2::sqrt_2o_3(8, as_< T >() ); NT2_TEST_EQUAL(x3,ref); } NT2_TEST_CASE( expr ) { using boost::mpl::_; using nt2::meta::value_type_; nt2::table< double > ref( nt2::of_size(8,8) ); for(int j=1;j<= 8;++j) for(int i=1;i<= 8;++i) ref(i,j) = nt2::Sqrt_2o_3<double>(); nt2::table<int> t1(nt2::of_size(1) ); t1(1) = 8; nt2::table< double > x1 = nt2::sqrt_2o_3( t1 ); NT2_TEST_EXPR_TYPE( (nt2::sqrt_2o_3( t1 )), (value_type_<_>), (double) ); NT2_TEST_EQUAL(x1,ref); nt2::table<int> t2(nt2::of_size(1,2) ); t2(1) = 4; t2(2) = 3; ref.resize( nt2::of_size(4,3) ); for(int j=1;j<= 3;++j) for(int i=1;i<= 4;++i) ref(i,j) = nt2::Sqrt_2o_3<double>(); nt2::table< double > x2 = nt2::sqrt_2o_3( t2 ); NT2_TEST_EQUAL(x2,ref); NT2_TEST_ASSERT( x1 = nt2::sqrt_2o_3(x2) ); } NT2_TEST_CASE_TPL( typed_expr, NT2_TYPES ) { using boost::mpl::_; using nt2::meta::as_; using nt2::meta::value_type_; nt2::table< T > ref( nt2::of_size(8,8) ); for(int j=1;j<= 8;++j) for(int i=1;i<= 8;++i) ref(i,j) = nt2::Sqrt_2o_3<T>(); nt2::table<int> t1(nt2::of_size(1) ); t1(1) = 8; nt2::table< T > x1 = nt2::sqrt_2o_3( t1, as_< T >() ); NT2_TEST_EXPR_TYPE( (nt2::sqrt_2o_3( t1, as_< T >() )), (value_type_<_>), (T) ); NT2_TEST_EQUAL(x1,ref); nt2::table<int> t2(nt2::of_size(1,2) ); t2(1) = 4; t2(2) = 3; ref.resize( nt2::of_size(4,3) ); for(int j=1;j<= 3;++j) for(int i=1;i<= 4;++i) ref(i,j) = nt2::Sqrt_2o_3<T>(); nt2::table< T > x2 = nt2::sqrt_2o_3( t2, as_< T >() ); NT2_TEST_EQUAL(x2,ref); NT2_TEST_ASSERT( x1 = nt2::sqrt_2o_3(x2, as_< T >()) ); }
ec96561627c9ad7ecb97544e238c0fc980d4311d
05172e3c9c7d80cc7b75eb0848c91b53a24158a1
/AVL_Tree_Implementation/node.h
20a34bb55097b17489946310eb56e3dc98e7b242
[]
no_license
binarydevelop/DSA-Implementations
86c5bba96365b6cd4711cbbec198765a5041faec
ddc2e7201e3721c7224075e0b23cd7b1b9c13995
refs/heads/master
2022-12-12T10:33:10.058157
2020-09-07T05:58:40
2020-09-07T05:58:40
267,747,782
0
0
null
null
null
null
UTF-8
C++
false
false
216
h
template<class T> class Node{ private: public: T m_data; Node<T>* m_left; Node<T>* m_right; Node(T data){ m_data =data; m_left=nullptr; m_right=nullptr; } };
a5522b5ecf086465b4c835af6eab6e890e0cd105
233fd424c66fe0d749816422283bb3c036c23b95
/LessonThree/derp.h
0d9725952762aff7e6556b68812ffce0c5b955b1
[]
no_license
kscottz/Over9000Examples
c61b7b153189c73db67953158cbb288321495d9f
36a3684c4b410d3665f7dff56c457efd6fe5764d
refs/heads/master
2021-01-10T21:07:04.385923
2013-01-08T03:39:17
2013-01-08T03:39:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
856
h
#include <iostream> using namespace std; class Position { public: int x; int y; }; //////////////////////////////////////////////////////////// ////////////////////////// THIS IS FRIGGIN MAGIC /////////// //////////////////////////////////////////////////////////// class Derp { public: Position jakes_position; int gravity; Derp(int j_x, int j_y) { gravity = -10; // the center of the earth is -infinity jakes_position.x = j_x; jakes_position.y = j_y; } void makeJakeFall(int time) { jakes_position.y += gravity*time; } void makeJakeGoForward( int distance ) { jakes_position.x += distance; } void whereTheFIsJake(void) { cout << "Jake is at " << "(" << jakes_position.x << "," << jakes_position.y << ")" << endl; } }; ////////////////////////////////////////////////////////////
e14f4dd687192e2e64101972980770b4adeaee79
23c119be42e98e4f946cb29a1722cc90a559d375
/players/cangateway/fg_connector_linux/include/asioconnector.h
a60400de9c06d2179d9eecb790fdd8651d4ea48c
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
PCanyi/ctfairlines
e54d43c4120ee28e150fa5fd8d4bc3f486800bed
aa1e5f396172c6de222335cd42c5752a1980517a
refs/heads/main
2023-01-15T09:43:44.777915
2020-11-21T10:27:33
2020-11-21T10:27:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,601
h
// Copyright (C) 2008,2009,2010 by Philipp Münzel. All rights reserved. // Released under the terms of the license described in license.txt #ifndef ASIOCONNECTOR_H #define ASIOCONNECTOR_H #include "dllexport.h" #include <string> #include <memory> #include <boost/asio.hpp> #include <boost/thread.hpp> #include "canaerotypes.h" #include "connector.h" #include "udpsender.h" #include "udpreceiver.h" namespace SCS { /** * @brief Implementation of the NetworkConnector for CAN Aerospace messages * using the UDPSender and UDPReceiver classes for asynchronous communication. * * Build on top of the boost::asio library using two threads for * asynchronous sending and receiving of UDP messages. * * @note This class is reentrant. There is no guarantee the receiver callback * will be called from the main thread. Receiving callbacks must be thread-safe. * @author (c) 2009,2010 by Philipp Münzel * @version 1.3 */ class DLL_PUBLIC ASIOConnector: public NetworkConnector<can_t> { public: /** * @param host_addr the multicast group to communicate with * @param incoming_port port for incoming messages * @param outgoing_port port for outgoing messages */ ASIOConnector(const std::string& host_addr, int incoming_port, int outgoing_port); /** * Cancel all I/O operations, close sockets and join threads */ ~ASIOConnector(); /** * @note No ownership tranfer, the caller is responsible for cleaning up this instance * @param listener pointer to instance to be notified of arriving messages */ void setListener(BusConnector<can_t>* listener); /** * @param msg pointer to data for sending * @param bytes sizeof data to send */ void send(const void* msg, std::size_t bytes); private: /** * run the service of the receiver thread */ void runIService(); /** * run the service of the sender thread */ void runOService(); /** * callback function that the receiver calls when new data arrives */ void receive(void* msg, std::size_t bytes_recvd); private: boost::asio::io_service m_o_service; boost::asio::io_service m_i_service; std::auto_ptr<UDPSender> m_sender; std::auto_ptr<UDPReceiver> m_receiver; std::auto_ptr<boost::asio::io_service::work> m_o_work; std::auto_ptr<boost::asio::io_service::work> m_i_work; boost::thread m_sender_thread; boost::thread m_receiver_thread; BusConnector<can_t>* m_connector; }; } #endif // ASIOCONNECTOR_H
514f91b2a0b7dd7fabae8ac24d401e8189defd11
9e845c388f03e978da93cc5e49011823ff8244ee
/Binary Tree/10.RightViewofTree.cpp
ab049ee294c9f8b3f8b7b8c2d6c2a5da6f996870
[]
no_license
chatu07/Love-Babbar-450-Programing-Course
b57201b8100c6c61c9c5bdc1fd2a62d30d028731
3e8ba849f1d9d33f5a02cf030be148e8a8bf9844
refs/heads/master
2023-01-31T08:55:57.254507
2020-12-05T14:22:41
2020-12-05T14:22:41
313,627,139
1
0
null
null
null
null
UTF-8
C++
false
false
1,575
cpp
#include<bits/stdc++.h> using namespace std; typedef struct Node{ Node* left; Node* right; int data; Node(int x){ data = x; left = right = NULL; } }Node; void inOrderTraversal(Node* tree){ if(tree){ inOrderTraversal(tree->left); cout<<tree->data<<" "; inOrderTraversal(tree->right); } } void rightView(Node* tree){ if(tree){ cout<<tree->data<<" "; rightView(tree->right); } } queue<Node*> nodes; void printAllRight(Node* tree){ if(tree){ if(tree->right) nodes.push(tree->right); printAllRight(tree->right); printAllRight(tree->left); } if(!nodes.empty()){ cout<<nodes.front()->data<<" "; nodes.pop(); } } int main(){ int n; cin>>n; vector<int> vct(n); for(int i = 0;i<n;i++){ cin>>vct[i]; } queue<Node*> queue; Node *tree = new Node(vct[0]); queue.push(tree); bool flag = false; for(int i = 1;i<n;i+=2){ Node* prev_node = queue.front(); Node* left = new Node(vct[i]); prev_node->left = left; queue.push(left); if(i+1<=n-1){ Node* right = new Node(vct[i+1]); prev_node->right = right; queue.push(right); } queue.pop(); } cout<<"Traversal: "; inOrderTraversal(tree); cout<<endl; cout<<"Right View: "; rightView(tree); cout<<endl; nodes.push(tree); cout<<"All Right elements of Tree: "; printAllRight(tree); return 0; }
992be5744521ee24f7e5645a82033977003636d6
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/com/oleutest/stgbvt/ctolestg/common/inc/ilkbhdr.hxx
52a00e93df64ed8ef7d759f3cc039d05cf5d75fa
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,758
hxx
//+------------------------------------------------------------------------- // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1992 - 1994. // // File: ilkbhdr.hxx // // Contents: ILockBytes file (for testing) and ILockBytesDF class // // Classes: CFileBytes // ILockBytesDF // // History: 30-July-96 NarindK Created // //-------------------------------------------------------------------------- #ifndef __ILKB_HXX__ #define __ILKB_HXX__ #define ULIGetHigh(li) ((li).HighPart) class ILockBytesDF; typedef ILockBytesDF *PILOCKBYTESDF; class CFileBytes; typedef CFileBytes *PCFILEBYTES; // Debug object declaration DH_DECLARE; //+------------------------------------------------------------------------- // Class: CFileBytes // // Synopsis: CFileBytes class, publicly derived from ILockBytes // // Methods: AddRef // CFileBytes // FailWrite0 // Flush // LockRegion // QueryInterface // Release // ReadAt // SetSize // Stat // UnlockRegion // WriteAt // GetSize // // Data: [_ulRef] - Reference count // [_hf] - Handle to file // [_cfail0] - Simulated failure // [_cwrite0] // // History: 06-Nov-92 AlexT Created // 30-July-1996 NarindK Modified for stgbase tests. // //-------------------------------------------------------------------------- class CFileBytes : public ILockBytes { public: CFileBytes(void); ~CFileBytes(void); HRESULT Init (TCHAR *ptcPath, DWORD dwMode); void FailWrite0 (int cFail0); ULARGE_INTEGER GetSize (void); STDMETHOD (QueryInterface)(REFIID riid, LPVOID *ppvObj); STDMETHOD_ (ULONG,AddRef) (void); STDMETHOD_ (ULONG,Release) (void); STDMETHOD(ReadAt) ( ULARGE_INTEGER ulOffset, VOID HUGEP *pv, ULONG cb, ULONG *pcbRead); STDMETHOD(WriteAt) ( ULARGE_INTEGER ulOffset, VOID const HUGEP *pv, ULONG cb, ULONG FAR *pcbWritten); STDMETHOD(LockRegion) ( ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType); STDMETHOD(UnlockRegion) ( ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType); STDMETHOD(Flush) (void); STDMETHOD(SetSize) (ULARGE_INTEGER cb); STDMETHOD(Stat) (STATSTG FAR *pstatstg, DWORD grfStatFlag); private: LONG _ulRef; HFILE _hf; int _cFail0; int _cWrite0; LPSTR _pszFileName; }; //+------------------------------------------------------------------------- // // Class: ILockBytesDF // // Synopsis: Derived class from VirtualDF to gnerate a docfile on custom // ILockBytes. // // Methods: GenerateVirtualDF // GenerateVirtualDFRoot // // History: 2-Aug-96 NarindK Created // // Data: [_pCFileBytes] -Pointer to custom CFileBytes instance // //-------------------------------------------------------------------------- class ILockBytesDF : public VirtualDF { public: // Functions for ILockBytes DocFile tree HRESULT GenerateVirtualDF( ChanceDF *pChanceDF, VirtualCtrNode **ppvcnRoot); HRESULT GenerateVirtualDFRoot( ChanceNode *pcnRoot, CFileBytes *pCFileBytes); CFileBytes *_pCFileBytes; }; #endif // #ifndef __ILKB_HXX__
cadecde4cb17ee394d43e8a2bd26c8434a0eca3e
8ca6edf566885eef4373f3c54882d1e0d271be28
/Source/SixManMorris/Public/SixManMorrisPlayerController.h
5dd5f08e6743a80bcbe8e62f083bff860e64d138
[]
no_license
ALangHung/Six-Man-Morris
4f9de006c20e8d7b4b655fb73655c453e42192ba
2ad02605d88515daef5ede3db765ad0fa7e5fd8f
refs/heads/master
2021-01-12T03:45:40.015376
2017-09-19T06:02:18
2017-09-19T06:02:18
78,262,499
0
0
null
null
null
null
UTF-8
C++
false
false
323
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "GameFramework/PlayerController.h" #include "SixManMorrisPlayerController.generated.h" /** * */ UCLASS() class SIXMANMORRIS_API ASixManMorrisPlayerController : public APlayerController { GENERATED_BODY() };
7982d32c5bb3421d9fbfea0399391e7878cc6bbd
e8de1020c62c0d4c4da27740ffe23e2db8b1f57c
/src/run.cpp
1751cf1367f89120a08db20041e506b1a797942d
[]
no_license
hanifnovrandhita/Rankcluster
5c3d105701979cb70c453dd37a507d3098758775
77299e09d62b95cd047a56d576b5d91f315c2e6f
refs/heads/master
2020-12-31T02:51:06.111554
2014-07-25T00:00:00
2014-07-25T00:00:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,732
cpp
#include "run.h" using namespace Rcpp ; using namespace std ; using namespace Eigen ; RcppExport SEXP semR(SEXP X,SEXP m,SEXP K,SEXP Qsem,SEXP Bsem,SEXP Ql,SEXP Bl,SEXP RjSE,SEXP RjM,SEXP maxTry,SEXP run,SEXP detail) { int g=as<int>(K),runC(as<int>(run)); vector<int> mC=as<vector<int> >(m); SEMparameters param; param.nGibbsSE = as<vector<int> >(RjSE); param.nGibbsM = as<vector<int> >(RjM); param.maxIt = as<int>(Qsem); param.burnAlgo = as<int>(Bsem); param.nGibbsL = as<int>(Ql); param.burnL = as<int>(Bl); param.maxTry = as<int>(maxTry); param.detail = as<bool>(detail); NumericMatrix XR(X); int n(XR.nrow()),col(XR.ncol()); vector<vector<int> > data(n,vector<int> (col)); for(int i(0);i<n;i++) for(int j(0);j<col;j++) data[i][j]=XR[i+j*n]; RankCluster semgibbs(data,g,mC,param); if(!semgibbs.dataOk()) { vector<double> stock(1,2); return List::create(Named("stock")=wrap(stock),Named("indexPb")=wrap(semgibbs.indexPb())); } semgibbs.run(); //multiple run if(runC>1) { RankCluster semgibbsb(data,g,mC,param); double L(-numeric_limits<double>::max()); if(semgibbs.convergence()) L=semgibbs.L(); for(int i(1);i<runC;i++) { semgibbsb.run(); if(semgibbsb.convergence()) { if(semgibbsb.L()>L) { L=semgibbsb.L(); semgibbs=semgibbsb; } } } } if(semgibbs.convergence()) { vector<double> stock(11); stock[0]=1; stock[1]=semgibbs.partial(); stock[2]=semgibbs.L(); stock[3]=semgibbs.bic(); stock[4]=semgibbs.icl(); int d=mC.size(); int n=XR.nrow(); vector<vector<vector<int> > > data(d,vector<vector<int> > (n)); vector<vector<vector<double> > > scorePart(d,vector<vector<double> > (n)); for(int i(0);i<n;i++) { for(int dim(0);dim<d;dim++) { data[dim][i]=semgibbs.rank(dim,i); scorePart[dim][i].resize(mC[dim],1); } } vector<vector<vector<int> > > dataInit(data); if(semgibbs.partial()) { vector<vector<vector<int> > > dataInitSEM(semgibbs.initialPartialRank()); vector<vector<int> > indexPartial=semgibbs.indexPartialData(); vector<vector<vector<double> > > scorePartial(semgibbs.partialRankScore()); for(int dim(0);dim<d;dim++) { int compteur(0); for(vector<int>::iterator it=indexPartial[dim].begin();it!=indexPartial[dim].end();it++) { dataInit[dim][*it]=dataInitSEM[dim][compteur]; scorePart[dim][*it]=scorePartial[dim][compteur]; compteur++; } } } return List::create( //parameters Named("stock")=wrap(stock), Named("referenceRank")=wrap(semgibbs.mu()), Named("p")=wrap(semgibbs.p()), Named("proportion")=wrap(semgibbs.proportion()), Named("cluster")=wrap(semgibbs.z()), Named("tik")=convertMatrix<NumericMatrix,ArrayXXd>(semgibbs.tik()), Named("entropy")=convertvector<NumericVector,ArrayXd>(semgibbs.entropy()), Named("partialRank")=wrap(data), Named("probability")=convertMatrix<NumericMatrix,ArrayXXd>(semgibbs.probability()), //distance Named("distP")=wrap(semgibbs.distP()), Named("distMu")=wrap(semgibbs.distMu()), Named("distProp")=wrap(semgibbs.distProp()), Named("distZ")=wrap(semgibbs.distZ()), Named("distPartialRank")=wrap(semgibbs.distPartialRank()), //initialization Named("initMu")=wrap(semgibbs.initialMu()), Named("initZ")=wrap(semgibbs.initialZ()), Named("initPi")=wrap(semgibbs.initialP()), Named("initPartialRank")=wrap(dataInit), Named("initProportion")=wrap(semgibbs.initialProportion()), Named("scorePartial")=wrap(scorePart)//, //Named("indexPartialData")=wrap(semgibbs.indexPartialData()) ); } else { vector<double> stock(1,0); return List::create(Named("stock")=wrap(stock)); } }
53b3d62ecd079d21d88436e09043c27d1b27ff1a
da304f5e14c24ea676149b57bfd42d9b13a89eac
/ps/boj_cpp/.vscode/1722.cpp
6db81ef2b3c6c0d7780b906f3773ffde897dcd4b
[]
no_license
ggyool/study-alone
bf43f73dc17a5db162bd8d97bff6d8f43b67986f
bfecc2dd9382b8cd16e65c4ba4355940449fca64
refs/heads/master
2022-12-21T19:46:21.772464
2022-01-18T09:24:13
2022-01-18T09:24:13
226,509,991
1
0
null
2022-12-16T15:25:50
2019-12-07T12:33:40
Java
UTF-8
C++
false
false
1,677
cpp
#include <iostream> #include <algorithm> #include <vector> using namespace std; typedef long long ll; ll fact[21]; void findPermutation(int n, ll m, vector<int>& v){ m -= 1; vector<bool> visited(n+1, false); for(int remain=n; remain>=1; --remain){ for(int i=1; i<=remain; ++i){ if(m<i*fact[remain-1]){ m -= (i-1)*fact[remain-1]; // i번째로 작은 수를 찾아야 한다. int cnt = 0; for(int j=1; j<=n; ++j){ if(visited[j]==false) ++cnt; if(cnt==i){ visited[j] = true; v[n-remain] = j; i=10000; break; } } } } } } ll findN(int n, vector<int>& v){ ll ret = 0; // 자신보다 뒤에 작은 숫자가 몇 개 있는지 for(int i=0; i<n-1; ++i){ ll cnt = 0; for(int j=i+1; j<n; ++j){ if(v[j]<v[i]) ++cnt; } ret += cnt*fact[n-i-1]; } return ret+1; } int main(void){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); fact[0] = 1; for(int i=1; i<=20; ++i){ fact[i] = fact[i-1] * i; } int n; ll m; int cmd; cin >> n; cin >> cmd; if(cmd==1){ cin >> m; vector<int> v(n); findPermutation(n, m, v); for(int i=0; i<n; ++i){ cout << v[i] << ' '; } } else{ vector<int> v(n); for(int i=0; i<n; ++i){ cin >> v[i]; } cout << findN(n, v); } return 0; }
cbee267075fe94bb9d33d642c540e8d72f066fc5
4136531814bf6ca4cda2fc062e3691b1f64adca3
/src/soapH.h
4f54d013cee7f7cb703526a26d415be28dd38438
[]
no_license
h-t-ren/enrima-ws-gsoap-client
60b9beff8361bca9193d040fd9b3dd05f6bd1750
1c8fe44272449b506c1da321989fb21cc85019da
refs/heads/master
2021-01-19T08:20:35.008415
2012-01-09T14:03:40
2012-01-09T14:03:40
3,047,730
0
0
null
null
null
null
UTF-8
C++
false
false
71,471
h
/* soapH.h Generated by gSOAP 2.8.3 from enrima.h Copyright(C) 2000-2011, Robert van Engelen, Genivia Inc. All Rights Reserved. The generated code is released under one of the following licenses: 1) GPL or 2) Genivia's license for commercial use. This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. */ #ifndef soapH_H #define soapH_H #include "soapStub.h" #ifndef WITH_NOIDREF #ifdef __cplusplus extern "C" { #endif SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int); SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int); SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*); #ifdef __cplusplus } #endif SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*); SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*); #endif SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*); SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*); SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*); SOAP_FMAC3 void* SOAP_FMAC4 soap_container_id_forward(struct soap*, const char*, void*, size_t, int, int, size_t, unsigned int); SOAP_FMAC3 void SOAP_FMAC4 soap_container_insert(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_byte #define SOAP_TYPE_byte (3) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*); SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*); #ifndef soap_write_byte #define soap_write_byte(soap, data) ( soap_begin_send(soap) || soap_put_byte(soap, data, "byte", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*); #ifndef soap_read_byte #define soap_read_byte(soap, data) ( soap_begin_recv(soap) || !soap_get_byte(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*); #ifndef SOAP_TYPE_int #define SOAP_TYPE_int (1) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*); SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*); #ifndef soap_write_int #define soap_write_int(soap, data) ( soap_begin_send(soap) || soap_put_int(soap, data, "int", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*); #ifndef soap_read_int #define soap_read_int(soap, data) ( soap_begin_recv(soap) || !soap_get_int(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*); #ifndef SOAP_TYPE_double #define SOAP_TYPE_double (35) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_double(struct soap*, double *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_double(struct soap*, const char*, int, const double *, const char*); SOAP_FMAC3 double * SOAP_FMAC4 soap_in_double(struct soap*, const char*, double *, const char*); #ifndef soap_write_double #define soap_write_double(soap, data) ( soap_begin_send(soap) || soap_put_double(soap, data, "double", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_double(struct soap*, const double *, const char*, const char*); #ifndef soap_read_double #define soap_read_double(soap, data) ( soap_begin_recv(soap) || !soap_get_double(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 double * SOAP_FMAC4 soap_get_double(struct soap*, double *, const char*, const char*); #ifndef SOAP_TYPE_ns2__mathType #define SOAP_TYPE_ns2__mathType (25) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns2__mathType(struct soap*, enum ns2__mathType *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__mathType(struct soap*, const char*, int, const enum ns2__mathType *, const char*); SOAP_FMAC3S const char* SOAP_FMAC4S soap_ns2__mathType2s(struct soap*, enum ns2__mathType); SOAP_FMAC3 enum ns2__mathType * SOAP_FMAC4 soap_in_ns2__mathType(struct soap*, const char*, enum ns2__mathType *, const char*); SOAP_FMAC3S int SOAP_FMAC4S soap_s2ns2__mathType(struct soap*, const char*, enum ns2__mathType *); #ifndef soap_write_ns2__mathType #define soap_write_ns2__mathType(soap, data) ( soap_begin_send(soap) || soap_put_ns2__mathType(soap, data, "ns2:mathType", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns2__mathType(struct soap*, const enum ns2__mathType *, const char*, const char*); #ifndef soap_read_ns2__mathType #define soap_read_ns2__mathType(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__mathType(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 enum ns2__mathType * SOAP_FMAC4 soap_get_ns2__mathType(struct soap*, enum ns2__mathType *, const char*, const char*); #ifndef SOAP_TYPE_ns2__entityRole #define SOAP_TYPE_ns2__entityRole (24) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns2__entityRole(struct soap*, enum ns2__entityRole *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__entityRole(struct soap*, const char*, int, const enum ns2__entityRole *, const char*); SOAP_FMAC3S const char* SOAP_FMAC4S soap_ns2__entityRole2s(struct soap*, enum ns2__entityRole); SOAP_FMAC3 enum ns2__entityRole * SOAP_FMAC4 soap_in_ns2__entityRole(struct soap*, const char*, enum ns2__entityRole *, const char*); SOAP_FMAC3S int SOAP_FMAC4S soap_s2ns2__entityRole(struct soap*, const char*, enum ns2__entityRole *); #ifndef soap_write_ns2__entityRole #define soap_write_ns2__entityRole(soap, data) ( soap_begin_send(soap) || soap_put_ns2__entityRole(soap, data, "ns2:entityRole", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns2__entityRole(struct soap*, const enum ns2__entityRole *, const char*, const char*); #ifndef soap_read_ns2__entityRole #define soap_read_ns2__entityRole(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__entityRole(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 enum ns2__entityRole * SOAP_FMAC4 soap_get_ns2__entityRole(struct soap*, enum ns2__entityRole *, const char*, const char*); #ifndef SOAP_TYPE_ns2__setType #define SOAP_TYPE_ns2__setType (23) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns2__setType(struct soap*, enum ns2__setType *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__setType(struct soap*, const char*, int, const enum ns2__setType *, const char*); SOAP_FMAC3S const char* SOAP_FMAC4S soap_ns2__setType2s(struct soap*, enum ns2__setType); SOAP_FMAC3 enum ns2__setType * SOAP_FMAC4 soap_in_ns2__setType(struct soap*, const char*, enum ns2__setType *, const char*); SOAP_FMAC3S int SOAP_FMAC4S soap_s2ns2__setType(struct soap*, const char*, enum ns2__setType *); #ifndef soap_write_ns2__setType #define soap_write_ns2__setType(soap, data) ( soap_begin_send(soap) || soap_put_ns2__setType(soap, data, "ns2:setType", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns2__setType(struct soap*, const enum ns2__setType *, const char*, const char*); #ifndef soap_read_ns2__setType #define soap_read_ns2__setType(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__setType(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 enum ns2__setType * SOAP_FMAC4 soap_get_ns2__setType(struct soap*, enum ns2__setType *, const char*, const char*); #ifndef SOAP_TYPE_ns2__status #define SOAP_TYPE_ns2__status (22) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns2__status(struct soap*, enum ns2__status *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__status(struct soap*, const char*, int, const enum ns2__status *, const char*); SOAP_FMAC3S const char* SOAP_FMAC4S soap_ns2__status2s(struct soap*, enum ns2__status); SOAP_FMAC3 enum ns2__status * SOAP_FMAC4 soap_in_ns2__status(struct soap*, const char*, enum ns2__status *, const char*); SOAP_FMAC3S int SOAP_FMAC4S soap_s2ns2__status(struct soap*, const char*, enum ns2__status *); #ifndef soap_write_ns2__status #define soap_write_ns2__status(soap, data) ( soap_begin_send(soap) || soap_put_ns2__status(soap, data, "ns2:status", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns2__status(struct soap*, const enum ns2__status *, const char*, const char*); #ifndef soap_read_ns2__status #define soap_read_ns2__status(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__status(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 enum ns2__status * SOAP_FMAC4 soap_get_ns2__status(struct soap*, enum ns2__status *, const char*, const char*); #ifndef SOAP_TYPE__ns2__saveModelDescriptionResponse #define SOAP_TYPE__ns2__saveModelDescriptionResponse (21) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out__ns2__saveModelDescriptionResponse(struct soap*, const char*, int, const _ns2__saveModelDescriptionResponse *, const char*); SOAP_FMAC3 _ns2__saveModelDescriptionResponse * SOAP_FMAC4 soap_in__ns2__saveModelDescriptionResponse(struct soap*, const char*, _ns2__saveModelDescriptionResponse *, const char*); #ifndef soap_write__ns2__saveModelDescriptionResponse #define soap_write__ns2__saveModelDescriptionResponse(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:saveModelDescriptionResponse", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read__ns2__saveModelDescriptionResponse #define soap_read__ns2__saveModelDescriptionResponse(soap, data) ( soap_begin_recv(soap) || !soap_get__ns2__saveModelDescriptionResponse(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__saveModelDescriptionResponse * SOAP_FMAC4 soap_get__ns2__saveModelDescriptionResponse(struct soap*, _ns2__saveModelDescriptionResponse *, const char*, const char*); #define soap_new__ns2__saveModelDescriptionResponse(soap, n) soap_instantiate__ns2__saveModelDescriptionResponse(soap, n, NULL, NULL, NULL) #define soap_delete__ns2__saveModelDescriptionResponse(soap, p) soap_delete(soap, p) SOAP_FMAC1 _ns2__saveModelDescriptionResponse * SOAP_FMAC2 soap_instantiate__ns2__saveModelDescriptionResponse(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy__ns2__saveModelDescriptionResponse(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE__ns2__saveModelDescriptionRequest #define SOAP_TYPE__ns2__saveModelDescriptionRequest (20) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out__ns2__saveModelDescriptionRequest(struct soap*, const char*, int, const _ns2__saveModelDescriptionRequest *, const char*); SOAP_FMAC3 _ns2__saveModelDescriptionRequest * SOAP_FMAC4 soap_in__ns2__saveModelDescriptionRequest(struct soap*, const char*, _ns2__saveModelDescriptionRequest *, const char*); #ifndef soap_write__ns2__saveModelDescriptionRequest #define soap_write__ns2__saveModelDescriptionRequest(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:saveModelDescriptionRequest", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read__ns2__saveModelDescriptionRequest #define soap_read__ns2__saveModelDescriptionRequest(soap, data) ( soap_begin_recv(soap) || !soap_get__ns2__saveModelDescriptionRequest(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__saveModelDescriptionRequest * SOAP_FMAC4 soap_get__ns2__saveModelDescriptionRequest(struct soap*, _ns2__saveModelDescriptionRequest *, const char*, const char*); #define soap_new__ns2__saveModelDescriptionRequest(soap, n) soap_instantiate__ns2__saveModelDescriptionRequest(soap, n, NULL, NULL, NULL) #define soap_delete__ns2__saveModelDescriptionRequest(soap, p) soap_delete(soap, p) SOAP_FMAC1 _ns2__saveModelDescriptionRequest * SOAP_FMAC2 soap_instantiate__ns2__saveModelDescriptionRequest(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy__ns2__saveModelDescriptionRequest(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE__ns2__getModelDescriptionResponse #define SOAP_TYPE__ns2__getModelDescriptionResponse (19) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out__ns2__getModelDescriptionResponse(struct soap*, const char*, int, const _ns2__getModelDescriptionResponse *, const char*); SOAP_FMAC3 _ns2__getModelDescriptionResponse * SOAP_FMAC4 soap_in__ns2__getModelDescriptionResponse(struct soap*, const char*, _ns2__getModelDescriptionResponse *, const char*); #ifndef soap_write__ns2__getModelDescriptionResponse #define soap_write__ns2__getModelDescriptionResponse(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:getModelDescriptionResponse", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read__ns2__getModelDescriptionResponse #define soap_read__ns2__getModelDescriptionResponse(soap, data) ( soap_begin_recv(soap) || !soap_get__ns2__getModelDescriptionResponse(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__getModelDescriptionResponse * SOAP_FMAC4 soap_get__ns2__getModelDescriptionResponse(struct soap*, _ns2__getModelDescriptionResponse *, const char*, const char*); #define soap_new__ns2__getModelDescriptionResponse(soap, n) soap_instantiate__ns2__getModelDescriptionResponse(soap, n, NULL, NULL, NULL) #define soap_delete__ns2__getModelDescriptionResponse(soap, p) soap_delete(soap, p) SOAP_FMAC1 _ns2__getModelDescriptionResponse * SOAP_FMAC2 soap_instantiate__ns2__getModelDescriptionResponse(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy__ns2__getModelDescriptionResponse(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE__ns2__getModelDescriptionRequest #define SOAP_TYPE__ns2__getModelDescriptionRequest (18) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out__ns2__getModelDescriptionRequest(struct soap*, const char*, int, const _ns2__getModelDescriptionRequest *, const char*); SOAP_FMAC3 _ns2__getModelDescriptionRequest * SOAP_FMAC4 soap_in__ns2__getModelDescriptionRequest(struct soap*, const char*, _ns2__getModelDescriptionRequest *, const char*); #ifndef soap_write__ns2__getModelDescriptionRequest #define soap_write__ns2__getModelDescriptionRequest(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:getModelDescriptionRequest", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read__ns2__getModelDescriptionRequest #define soap_read__ns2__getModelDescriptionRequest(soap, data) ( soap_begin_recv(soap) || !soap_get__ns2__getModelDescriptionRequest(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__getModelDescriptionRequest * SOAP_FMAC4 soap_get__ns2__getModelDescriptionRequest(struct soap*, _ns2__getModelDescriptionRequest *, const char*, const char*); #define soap_new__ns2__getModelDescriptionRequest(soap, n) soap_instantiate__ns2__getModelDescriptionRequest(soap, n, NULL, NULL, NULL) #define soap_delete__ns2__getModelDescriptionRequest(soap, p) soap_delete(soap, p) SOAP_FMAC1 _ns2__getModelDescriptionRequest * SOAP_FMAC2 soap_instantiate__ns2__getModelDescriptionRequest(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy__ns2__getModelDescriptionRequest(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE__ns2__getModelListResponse #define SOAP_TYPE__ns2__getModelListResponse (17) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out__ns2__getModelListResponse(struct soap*, const char*, int, const _ns2__getModelListResponse *, const char*); SOAP_FMAC3 _ns2__getModelListResponse * SOAP_FMAC4 soap_in__ns2__getModelListResponse(struct soap*, const char*, _ns2__getModelListResponse *, const char*); #ifndef soap_write__ns2__getModelListResponse #define soap_write__ns2__getModelListResponse(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:getModelListResponse", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read__ns2__getModelListResponse #define soap_read__ns2__getModelListResponse(soap, data) ( soap_begin_recv(soap) || !soap_get__ns2__getModelListResponse(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__getModelListResponse * SOAP_FMAC4 soap_get__ns2__getModelListResponse(struct soap*, _ns2__getModelListResponse *, const char*, const char*); #define soap_new__ns2__getModelListResponse(soap, n) soap_instantiate__ns2__getModelListResponse(soap, n, NULL, NULL, NULL) #define soap_delete__ns2__getModelListResponse(soap, p) soap_delete(soap, p) SOAP_FMAC1 _ns2__getModelListResponse * SOAP_FMAC2 soap_instantiate__ns2__getModelListResponse(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy__ns2__getModelListResponse(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_ns2__auditable #define SOAP_TYPE_ns2__auditable (16) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__auditable(struct soap*, const char*, int, const ns2__auditable *, const char*); SOAP_FMAC3 ns2__auditable * SOAP_FMAC4 soap_in_ns2__auditable(struct soap*, const char*, ns2__auditable *, const char*); #ifndef soap_write_ns2__auditable #define soap_write_ns2__auditable(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:auditable", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read_ns2__auditable #define soap_read_ns2__auditable(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__auditable(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__auditable * SOAP_FMAC4 soap_get_ns2__auditable(struct soap*, ns2__auditable *, const char*, const char*); #define soap_new_ns2__auditable(soap, n) soap_instantiate_ns2__auditable(soap, n, NULL, NULL, NULL) #define soap_delete_ns2__auditable(soap, p) soap_delete(soap, p) SOAP_FMAC1 ns2__auditable * SOAP_FMAC2 soap_instantiate_ns2__auditable(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns2__auditable(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_ns2__user #define SOAP_TYPE_ns2__user (15) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__user(struct soap*, const char*, int, const ns2__user *, const char*); SOAP_FMAC3 ns2__user * SOAP_FMAC4 soap_in_ns2__user(struct soap*, const char*, ns2__user *, const char*); #ifndef soap_write_ns2__user #define soap_write_ns2__user(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:user", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read_ns2__user #define soap_read_ns2__user(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__user(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__user * SOAP_FMAC4 soap_get_ns2__user(struct soap*, ns2__user *, const char*, const char*); #define soap_new_ns2__user(soap, n) soap_instantiate_ns2__user(soap, n, NULL, NULL, NULL) #define soap_delete_ns2__user(soap, p) soap_delete(soap, p) SOAP_FMAC1 ns2__user * SOAP_FMAC2 soap_instantiate_ns2__user(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns2__user(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_ns2__iteratorContainer #define SOAP_TYPE_ns2__iteratorContainer (14) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__iteratorContainer(struct soap*, const char*, int, const ns2__iteratorContainer *, const char*); SOAP_FMAC3 ns2__iteratorContainer * SOAP_FMAC4 soap_in_ns2__iteratorContainer(struct soap*, const char*, ns2__iteratorContainer *, const char*); #ifndef soap_write_ns2__iteratorContainer #define soap_write_ns2__iteratorContainer(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:iteratorContainer", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read_ns2__iteratorContainer #define soap_read_ns2__iteratorContainer(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__iteratorContainer(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__iteratorContainer * SOAP_FMAC4 soap_get_ns2__iteratorContainer(struct soap*, ns2__iteratorContainer *, const char*, const char*); #define soap_new_ns2__iteratorContainer(soap, n) soap_instantiate_ns2__iteratorContainer(soap, n, NULL, NULL, NULL) #define soap_delete_ns2__iteratorContainer(soap, p) soap_delete(soap, p) SOAP_FMAC1 ns2__iteratorContainer * SOAP_FMAC2 soap_instantiate_ns2__iteratorContainer(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns2__iteratorContainer(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_ns2__entity #define SOAP_TYPE_ns2__entity (13) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__entity(struct soap*, const char*, int, const ns2__entity *, const char*); SOAP_FMAC3 ns2__entity * SOAP_FMAC4 soap_in_ns2__entity(struct soap*, const char*, ns2__entity *, const char*); #ifndef soap_write_ns2__entity #define soap_write_ns2__entity(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:entity", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read_ns2__entity #define soap_read_ns2__entity(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__entity(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__entity * SOAP_FMAC4 soap_get_ns2__entity(struct soap*, ns2__entity *, const char*, const char*); #define soap_new_ns2__entity(soap, n) soap_instantiate_ns2__entity(soap, n, NULL, NULL, NULL) #define soap_delete_ns2__entity(soap, p) soap_delete(soap, p) SOAP_FMAC1 ns2__entity * SOAP_FMAC2 soap_instantiate_ns2__entity(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns2__entity(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_ns2__set #define SOAP_TYPE_ns2__set (12) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__set(struct soap*, const char*, int, const ns2__set *, const char*); SOAP_FMAC3 ns2__set * SOAP_FMAC4 soap_in_ns2__set(struct soap*, const char*, ns2__set *, const char*); #ifndef soap_write_ns2__set #define soap_write_ns2__set(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:set", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read_ns2__set #define soap_read_ns2__set(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__set(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__set * SOAP_FMAC4 soap_get_ns2__set(struct soap*, ns2__set *, const char*, const char*); #define soap_new_ns2__set(soap, n) soap_instantiate_ns2__set(soap, n, NULL, NULL, NULL) #define soap_delete_ns2__set(soap, p) soap_delete(soap, p) SOAP_FMAC1 ns2__set * SOAP_FMAC2 soap_instantiate_ns2__set(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns2__set(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_ns2__modelRev #define SOAP_TYPE_ns2__modelRev (11) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__modelRev(struct soap*, const char*, int, const ns2__modelRev *, const char*); SOAP_FMAC3 ns2__modelRev * SOAP_FMAC4 soap_in_ns2__modelRev(struct soap*, const char*, ns2__modelRev *, const char*); #ifndef soap_write_ns2__modelRev #define soap_write_ns2__modelRev(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:modelRev", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read_ns2__modelRev #define soap_read_ns2__modelRev(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__modelRev(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__modelRev * SOAP_FMAC4 soap_get_ns2__modelRev(struct soap*, ns2__modelRev *, const char*, const char*); #define soap_new_ns2__modelRev(soap, n) soap_instantiate_ns2__modelRev(soap, n, NULL, NULL, NULL) #define soap_delete_ns2__modelRev(soap, p) soap_delete(soap, p) SOAP_FMAC1 ns2__modelRev * SOAP_FMAC2 soap_instantiate_ns2__modelRev(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns2__modelRev(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_ns2__model #define SOAP_TYPE_ns2__model (10) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns2__model(struct soap*, const char*, int, const ns2__model *, const char*); SOAP_FMAC3 ns2__model * SOAP_FMAC4 soap_in_ns2__model(struct soap*, const char*, ns2__model *, const char*); #ifndef soap_write_ns2__model #define soap_write_ns2__model(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "ns2:model", NULL) || soap_end_send(soap) ) #endif #ifndef soap_read_ns2__model #define soap_read_ns2__model(soap, data) ( soap_begin_recv(soap) || !soap_get_ns2__model(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__model * SOAP_FMAC4 soap_get_ns2__model(struct soap*, ns2__model *, const char*, const char*); #define soap_new_ns2__model(soap, n) soap_instantiate_ns2__model(soap, n, NULL, NULL, NULL) #define soap_delete_ns2__model(soap, p) soap_delete(soap, p) SOAP_FMAC1 ns2__model * SOAP_FMAC2 soap_instantiate_ns2__model(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns2__model(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_xsd__date #define SOAP_TYPE_xsd__date (9) #endif #define soap_default_xsd__date(soap, a) soap_default_std__string(soap, a) #define soap_serialize_xsd__date(soap, a) soap_serialize_std__string(soap, a) SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__date(struct soap*, const char*, int, const std::string*, const char*); SOAP_FMAC3 std::string * SOAP_FMAC4 soap_in_xsd__date(struct soap*, const char*, std::string*, const char*); #ifndef soap_write_xsd__date #define soap_write_xsd__date(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "xsd:date", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__date(struct soap*, const std::string *, const char*, const char*); #ifndef soap_read_xsd__date #define soap_read_xsd__date(soap, data) ( soap_begin_recv(soap) || !soap_get_xsd__date(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 std::string * SOAP_FMAC4 soap_get_xsd__date(struct soap*, std::string *, const char*, const char*); #define soap_new_xsd__date(soap, n) soap_instantiate_xsd__date(soap, n, NULL, NULL, NULL) #define soap_delete_xsd__date(soap, p) soap_delete(soap, p) #define soap_instantiate_xsd__date soap_instantiate_std__string #define soap_copy_xsd__date soap_copy_std__string #ifndef SOAP_TYPE_std__string #define SOAP_TYPE_std__string (8) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_std__string(struct soap*, std::string *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_std__string(struct soap*, const std::string *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_std__string(struct soap*, const char*, int, const std::string*, const char*); SOAP_FMAC3 std::string * SOAP_FMAC4 soap_in_std__string(struct soap*, const char*, std::string*, const char*); #ifndef soap_write_std__string #define soap_write_std__string(soap, data) ( soap_begin_send(soap) || ((data)->soap_serialize(soap), 0) || (data)->soap_put(soap, "string", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_std__string(struct soap*, const std::string *, const char*, const char*); #ifndef soap_read_std__string #define soap_read_std__string(soap, data) ( soap_begin_recv(soap) || !soap_get_std__string(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 std::string * SOAP_FMAC4 soap_get_std__string(struct soap*, std::string *, const char*, const char*); #define soap_new_std__string(soap, n) soap_instantiate_std__string(soap, n, NULL, NULL, NULL) #define soap_delete_std__string(soap, p) soap_delete(soap, p) SOAP_FMAC1 std::string * SOAP_FMAC2 soap_instantiate_std__string(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_std__string(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef WITH_NOGLOBAL #ifndef SOAP_TYPE_SOAP_ENV__Fault #define SOAP_TYPE_SOAP_ENV__Fault (58) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*); SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*); #ifndef soap_write_SOAP_ENV__Fault #define soap_write_SOAP_ENV__Fault(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Fault(soap, data), 0) || soap_put_SOAP_ENV__Fault(soap, data, "SOAP-ENV:Fault", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*); #ifndef soap_read_SOAP_ENV__Fault #define soap_read_SOAP_ENV__Fault(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*); #define soap_new_SOAP_ENV__Fault(soap, n) soap_instantiate_SOAP_ENV__Fault(soap, n, NULL, NULL, NULL) #define soap_delete_SOAP_ENV__Fault(soap, p) soap_delete(soap, p) SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t); #endif #ifndef WITH_NOGLOBAL #ifndef SOAP_TYPE_SOAP_ENV__Reason #define SOAP_TYPE_SOAP_ENV__Reason (57) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*); SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*); #ifndef soap_write_SOAP_ENV__Reason #define soap_write_SOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Reason(soap, data), 0) || soap_put_SOAP_ENV__Reason(soap, data, "SOAP-ENV:Reason", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*); #ifndef soap_read_SOAP_ENV__Reason #define soap_read_SOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*); #define soap_new_SOAP_ENV__Reason(soap, n) soap_instantiate_SOAP_ENV__Reason(soap, n, NULL, NULL, NULL) #define soap_delete_SOAP_ENV__Reason(soap, p) soap_delete(soap, p) SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t); #endif #ifndef WITH_NOGLOBAL #ifndef SOAP_TYPE_SOAP_ENV__Detail #define SOAP_TYPE_SOAP_ENV__Detail (54) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*); SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*); #ifndef soap_write_SOAP_ENV__Detail #define soap_write_SOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Detail(soap, data), 0) || soap_put_SOAP_ENV__Detail(soap, data, "SOAP-ENV:Detail", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*); #ifndef soap_read_SOAP_ENV__Detail #define soap_read_SOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*); #define soap_new_SOAP_ENV__Detail(soap, n) soap_instantiate_SOAP_ENV__Detail(soap, n, NULL, NULL, NULL) #define soap_delete_SOAP_ENV__Detail(soap, p) soap_delete(soap, p) SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t); #endif #ifndef WITH_NOGLOBAL #ifndef SOAP_TYPE_SOAP_ENV__Code #define SOAP_TYPE_SOAP_ENV__Code (52) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*); SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*); #ifndef soap_write_SOAP_ENV__Code #define soap_write_SOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Code(soap, data), 0) || soap_put_SOAP_ENV__Code(soap, data, "SOAP-ENV:Code", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*); #ifndef soap_read_SOAP_ENV__Code #define soap_read_SOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*); #define soap_new_SOAP_ENV__Code(soap, n) soap_instantiate_SOAP_ENV__Code(soap, n, NULL, NULL, NULL) #define soap_delete_SOAP_ENV__Code(soap, p) soap_delete(soap, p) SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t); #endif #ifndef WITH_NOGLOBAL #ifndef SOAP_TYPE_SOAP_ENV__Header #define SOAP_TYPE_SOAP_ENV__Header (51) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*); SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*); #ifndef soap_write_SOAP_ENV__Header #define soap_write_SOAP_ENV__Header(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Header(soap, data), 0) || soap_put_SOAP_ENV__Header(soap, data, "SOAP-ENV:Header", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*); #ifndef soap_read_SOAP_ENV__Header #define soap_read_SOAP_ENV__Header(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*); #define soap_new_SOAP_ENV__Header(soap, n) soap_instantiate_SOAP_ENV__Header(soap, n, NULL, NULL, NULL) #define soap_delete_SOAP_ENV__Header(soap, p) soap_delete(soap, p) SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t); #endif #ifndef SOAP_TYPE___ns1__getModelList #define SOAP_TYPE___ns1__getModelList (50) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default___ns1__getModelList(struct soap*, struct __ns1__getModelList *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize___ns1__getModelList(struct soap*, const struct __ns1__getModelList *); SOAP_FMAC3 int SOAP_FMAC4 soap_out___ns1__getModelList(struct soap*, const char*, int, const struct __ns1__getModelList *, const char*); SOAP_FMAC3 struct __ns1__getModelList * SOAP_FMAC4 soap_in___ns1__getModelList(struct soap*, const char*, struct __ns1__getModelList *, const char*); #ifndef soap_write___ns1__getModelList #define soap_write___ns1__getModelList(soap, data) ( soap_begin_send(soap) || (soap_serialize___ns1__getModelList(soap, data), 0) || soap_put___ns1__getModelList(soap, data, "-ns1:getModelList", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put___ns1__getModelList(struct soap*, const struct __ns1__getModelList *, const char*, const char*); #ifndef soap_read___ns1__getModelList #define soap_read___ns1__getModelList(soap, data) ( soap_begin_recv(soap) || !soap_get___ns1__getModelList(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct __ns1__getModelList * SOAP_FMAC4 soap_get___ns1__getModelList(struct soap*, struct __ns1__getModelList *, const char*, const char*); #define soap_new___ns1__getModelList(soap, n) soap_instantiate___ns1__getModelList(soap, n, NULL, NULL, NULL) #define soap_delete___ns1__getModelList(soap, p) soap_delete(soap, p) SOAP_FMAC1 struct __ns1__getModelList * SOAP_FMAC2 soap_instantiate___ns1__getModelList(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy___ns1__getModelList(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE___ns1__saveModelDescription #define SOAP_TYPE___ns1__saveModelDescription (47) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default___ns1__saveModelDescription(struct soap*, struct __ns1__saveModelDescription *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize___ns1__saveModelDescription(struct soap*, const struct __ns1__saveModelDescription *); SOAP_FMAC3 int SOAP_FMAC4 soap_out___ns1__saveModelDescription(struct soap*, const char*, int, const struct __ns1__saveModelDescription *, const char*); SOAP_FMAC3 struct __ns1__saveModelDescription * SOAP_FMAC4 soap_in___ns1__saveModelDescription(struct soap*, const char*, struct __ns1__saveModelDescription *, const char*); #ifndef soap_write___ns1__saveModelDescription #define soap_write___ns1__saveModelDescription(soap, data) ( soap_begin_send(soap) || (soap_serialize___ns1__saveModelDescription(soap, data), 0) || soap_put___ns1__saveModelDescription(soap, data, "-ns1:saveModelDescription", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put___ns1__saveModelDescription(struct soap*, const struct __ns1__saveModelDescription *, const char*, const char*); #ifndef soap_read___ns1__saveModelDescription #define soap_read___ns1__saveModelDescription(soap, data) ( soap_begin_recv(soap) || !soap_get___ns1__saveModelDescription(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct __ns1__saveModelDescription * SOAP_FMAC4 soap_get___ns1__saveModelDescription(struct soap*, struct __ns1__saveModelDescription *, const char*, const char*); #define soap_new___ns1__saveModelDescription(soap, n) soap_instantiate___ns1__saveModelDescription(soap, n, NULL, NULL, NULL) #define soap_delete___ns1__saveModelDescription(soap, p) soap_delete(soap, p) SOAP_FMAC1 struct __ns1__saveModelDescription * SOAP_FMAC2 soap_instantiate___ns1__saveModelDescription(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy___ns1__saveModelDescription(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE___ns1__getModelDescription #define SOAP_TYPE___ns1__getModelDescription (43) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default___ns1__getModelDescription(struct soap*, struct __ns1__getModelDescription *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize___ns1__getModelDescription(struct soap*, const struct __ns1__getModelDescription *); SOAP_FMAC3 int SOAP_FMAC4 soap_out___ns1__getModelDescription(struct soap*, const char*, int, const struct __ns1__getModelDescription *, const char*); SOAP_FMAC3 struct __ns1__getModelDescription * SOAP_FMAC4 soap_in___ns1__getModelDescription(struct soap*, const char*, struct __ns1__getModelDescription *, const char*); #ifndef soap_write___ns1__getModelDescription #define soap_write___ns1__getModelDescription(soap, data) ( soap_begin_send(soap) || (soap_serialize___ns1__getModelDescription(soap, data), 0) || soap_put___ns1__getModelDescription(soap, data, "-ns1:getModelDescription", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put___ns1__getModelDescription(struct soap*, const struct __ns1__getModelDescription *, const char*, const char*); #ifndef soap_read___ns1__getModelDescription #define soap_read___ns1__getModelDescription(soap, data) ( soap_begin_recv(soap) || !soap_get___ns1__getModelDescription(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct __ns1__getModelDescription * SOAP_FMAC4 soap_get___ns1__getModelDescription(struct soap*, struct __ns1__getModelDescription *, const char*, const char*); #define soap_new___ns1__getModelDescription(soap, n) soap_instantiate___ns1__getModelDescription(soap, n, NULL, NULL, NULL) #define soap_delete___ns1__getModelDescription(soap, p) soap_delete(soap, p) SOAP_FMAC1 struct __ns1__getModelDescription * SOAP_FMAC2 soap_instantiate___ns1__getModelDescription(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy___ns1__getModelDescription(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef WITH_NOGLOBAL #ifndef SOAP_TYPE_PointerToSOAP_ENV__Reason #define SOAP_TYPE_PointerToSOAP_ENV__Reason (60) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *); SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*); #ifndef soap_write_PointerToSOAP_ENV__Reason #define soap_write_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Reason(soap, data), 0) || soap_put_PointerToSOAP_ENV__Reason(soap, data, "SOAP-ENV:Reason", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*); #ifndef soap_read_PointerToSOAP_ENV__Reason #define soap_read_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*); #endif #ifndef WITH_NOGLOBAL #ifndef SOAP_TYPE_PointerToSOAP_ENV__Detail #define SOAP_TYPE_PointerToSOAP_ENV__Detail (59) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *); SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*); #ifndef soap_write_PointerToSOAP_ENV__Detail #define soap_write_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Detail(soap, data), 0) || soap_put_PointerToSOAP_ENV__Detail(soap, data, "SOAP-ENV:Detail", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*); #ifndef soap_read_PointerToSOAP_ENV__Detail #define soap_read_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*); #endif #ifndef WITH_NOGLOBAL #ifndef SOAP_TYPE_PointerToSOAP_ENV__Code #define SOAP_TYPE_PointerToSOAP_ENV__Code (53) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *); SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*); #ifndef soap_write_PointerToSOAP_ENV__Code #define soap_write_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Code(soap, data), 0) || soap_put_PointerToSOAP_ENV__Code(soap, data, "SOAP-ENV:Code", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*); #ifndef soap_read_PointerToSOAP_ENV__Code #define soap_read_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*); #endif #ifndef SOAP_TYPE_PointerTo_ns2__getModelListResponse #define SOAP_TYPE_PointerTo_ns2__getModelListResponse (48) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTo_ns2__getModelListResponse(struct soap*, _ns2__getModelListResponse *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTo_ns2__getModelListResponse(struct soap*, const char *, int, _ns2__getModelListResponse *const*, const char *); SOAP_FMAC3 _ns2__getModelListResponse ** SOAP_FMAC4 soap_in_PointerTo_ns2__getModelListResponse(struct soap*, const char*, _ns2__getModelListResponse **, const char*); #ifndef soap_write_PointerTo_ns2__getModelListResponse #define soap_write_PointerTo_ns2__getModelListResponse(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTo_ns2__getModelListResponse(soap, data), 0) || soap_put_PointerTo_ns2__getModelListResponse(soap, data, "ns2:getModelListResponse", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTo_ns2__getModelListResponse(struct soap*, _ns2__getModelListResponse *const*, const char*, const char*); #ifndef soap_read_PointerTo_ns2__getModelListResponse #define soap_read_PointerTo_ns2__getModelListResponse(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTo_ns2__getModelListResponse(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__getModelListResponse ** SOAP_FMAC4 soap_get_PointerTo_ns2__getModelListResponse(struct soap*, _ns2__getModelListResponse **, const char*, const char*); #ifndef SOAP_TYPE_PointerTo_ns2__saveModelDescriptionResponse #define SOAP_TYPE_PointerTo_ns2__saveModelDescriptionResponse (45) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTo_ns2__saveModelDescriptionResponse(struct soap*, _ns2__saveModelDescriptionResponse *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTo_ns2__saveModelDescriptionResponse(struct soap*, const char *, int, _ns2__saveModelDescriptionResponse *const*, const char *); SOAP_FMAC3 _ns2__saveModelDescriptionResponse ** SOAP_FMAC4 soap_in_PointerTo_ns2__saveModelDescriptionResponse(struct soap*, const char*, _ns2__saveModelDescriptionResponse **, const char*); #ifndef soap_write_PointerTo_ns2__saveModelDescriptionResponse #define soap_write_PointerTo_ns2__saveModelDescriptionResponse(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTo_ns2__saveModelDescriptionResponse(soap, data), 0) || soap_put_PointerTo_ns2__saveModelDescriptionResponse(soap, data, "ns2:saveModelDescriptionResponse", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTo_ns2__saveModelDescriptionResponse(struct soap*, _ns2__saveModelDescriptionResponse *const*, const char*, const char*); #ifndef soap_read_PointerTo_ns2__saveModelDescriptionResponse #define soap_read_PointerTo_ns2__saveModelDescriptionResponse(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTo_ns2__saveModelDescriptionResponse(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__saveModelDescriptionResponse ** SOAP_FMAC4 soap_get_PointerTo_ns2__saveModelDescriptionResponse(struct soap*, _ns2__saveModelDescriptionResponse **, const char*, const char*); #ifndef SOAP_TYPE_PointerTo_ns2__saveModelDescriptionRequest #define SOAP_TYPE_PointerTo_ns2__saveModelDescriptionRequest (44) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTo_ns2__saveModelDescriptionRequest(struct soap*, _ns2__saveModelDescriptionRequest *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTo_ns2__saveModelDescriptionRequest(struct soap*, const char *, int, _ns2__saveModelDescriptionRequest *const*, const char *); SOAP_FMAC3 _ns2__saveModelDescriptionRequest ** SOAP_FMAC4 soap_in_PointerTo_ns2__saveModelDescriptionRequest(struct soap*, const char*, _ns2__saveModelDescriptionRequest **, const char*); #ifndef soap_write_PointerTo_ns2__saveModelDescriptionRequest #define soap_write_PointerTo_ns2__saveModelDescriptionRequest(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTo_ns2__saveModelDescriptionRequest(soap, data), 0) || soap_put_PointerTo_ns2__saveModelDescriptionRequest(soap, data, "ns2:saveModelDescriptionRequest", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTo_ns2__saveModelDescriptionRequest(struct soap*, _ns2__saveModelDescriptionRequest *const*, const char*, const char*); #ifndef soap_read_PointerTo_ns2__saveModelDescriptionRequest #define soap_read_PointerTo_ns2__saveModelDescriptionRequest(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTo_ns2__saveModelDescriptionRequest(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__saveModelDescriptionRequest ** SOAP_FMAC4 soap_get_PointerTo_ns2__saveModelDescriptionRequest(struct soap*, _ns2__saveModelDescriptionRequest **, const char*, const char*); #ifndef SOAP_TYPE_PointerTo_ns2__getModelDescriptionResponse #define SOAP_TYPE_PointerTo_ns2__getModelDescriptionResponse (41) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTo_ns2__getModelDescriptionResponse(struct soap*, _ns2__getModelDescriptionResponse *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTo_ns2__getModelDescriptionResponse(struct soap*, const char *, int, _ns2__getModelDescriptionResponse *const*, const char *); SOAP_FMAC3 _ns2__getModelDescriptionResponse ** SOAP_FMAC4 soap_in_PointerTo_ns2__getModelDescriptionResponse(struct soap*, const char*, _ns2__getModelDescriptionResponse **, const char*); #ifndef soap_write_PointerTo_ns2__getModelDescriptionResponse #define soap_write_PointerTo_ns2__getModelDescriptionResponse(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTo_ns2__getModelDescriptionResponse(soap, data), 0) || soap_put_PointerTo_ns2__getModelDescriptionResponse(soap, data, "ns2:getModelDescriptionResponse", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTo_ns2__getModelDescriptionResponse(struct soap*, _ns2__getModelDescriptionResponse *const*, const char*, const char*); #ifndef soap_read_PointerTo_ns2__getModelDescriptionResponse #define soap_read_PointerTo_ns2__getModelDescriptionResponse(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTo_ns2__getModelDescriptionResponse(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__getModelDescriptionResponse ** SOAP_FMAC4 soap_get_PointerTo_ns2__getModelDescriptionResponse(struct soap*, _ns2__getModelDescriptionResponse **, const char*, const char*); #ifndef SOAP_TYPE_PointerTo_ns2__getModelDescriptionRequest #define SOAP_TYPE_PointerTo_ns2__getModelDescriptionRequest (40) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTo_ns2__getModelDescriptionRequest(struct soap*, _ns2__getModelDescriptionRequest *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTo_ns2__getModelDescriptionRequest(struct soap*, const char *, int, _ns2__getModelDescriptionRequest *const*, const char *); SOAP_FMAC3 _ns2__getModelDescriptionRequest ** SOAP_FMAC4 soap_in_PointerTo_ns2__getModelDescriptionRequest(struct soap*, const char*, _ns2__getModelDescriptionRequest **, const char*); #ifndef soap_write_PointerTo_ns2__getModelDescriptionRequest #define soap_write_PointerTo_ns2__getModelDescriptionRequest(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTo_ns2__getModelDescriptionRequest(soap, data), 0) || soap_put_PointerTo_ns2__getModelDescriptionRequest(soap, data, "ns2:getModelDescriptionRequest", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTo_ns2__getModelDescriptionRequest(struct soap*, _ns2__getModelDescriptionRequest *const*, const char*, const char*); #ifndef soap_read_PointerTo_ns2__getModelDescriptionRequest #define soap_read_PointerTo_ns2__getModelDescriptionRequest(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTo_ns2__getModelDescriptionRequest(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 _ns2__getModelDescriptionRequest ** SOAP_FMAC4 soap_get_PointerTo_ns2__getModelDescriptionRequest(struct soap*, _ns2__getModelDescriptionRequest **, const char*, const char*); #ifndef SOAP_TYPE_PointerTons2__model #define SOAP_TYPE_PointerTons2__model (38) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTons2__model(struct soap*, ns2__model *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTons2__model(struct soap*, const char *, int, ns2__model *const*, const char *); SOAP_FMAC3 ns2__model ** SOAP_FMAC4 soap_in_PointerTons2__model(struct soap*, const char*, ns2__model **, const char*); #ifndef soap_write_PointerTons2__model #define soap_write_PointerTons2__model(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTons2__model(soap, data), 0) || soap_put_PointerTons2__model(soap, data, "ns2:model", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTons2__model(struct soap*, ns2__model *const*, const char*, const char*); #ifndef soap_read_PointerTons2__model #define soap_read_PointerTons2__model(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTons2__model(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__model ** SOAP_FMAC4 soap_get_PointerTons2__model(struct soap*, ns2__model **, const char*, const char*); #ifndef SOAP_TYPE_PointerTons2__user #define SOAP_TYPE_PointerTons2__user (37) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTons2__user(struct soap*, ns2__user *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTons2__user(struct soap*, const char *, int, ns2__user *const*, const char *); SOAP_FMAC3 ns2__user ** SOAP_FMAC4 soap_in_PointerTons2__user(struct soap*, const char*, ns2__user **, const char*); #ifndef soap_write_PointerTons2__user #define soap_write_PointerTons2__user(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTons2__user(soap, data), 0) || soap_put_PointerTons2__user(soap, data, "ns2:user", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTons2__user(struct soap*, ns2__user *const*, const char*, const char*); #ifndef soap_read_PointerTons2__user #define soap_read_PointerTons2__user(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTons2__user(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__user ** SOAP_FMAC4 soap_get_PointerTons2__user(struct soap*, ns2__user **, const char*, const char*); #ifndef SOAP_TYPE_PointerTons2__iteratorContainer #define SOAP_TYPE_PointerTons2__iteratorContainer (34) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTons2__iteratorContainer(struct soap*, ns2__iteratorContainer *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTons2__iteratorContainer(struct soap*, const char *, int, ns2__iteratorContainer *const*, const char *); SOAP_FMAC3 ns2__iteratorContainer ** SOAP_FMAC4 soap_in_PointerTons2__iteratorContainer(struct soap*, const char*, ns2__iteratorContainer **, const char*); #ifndef soap_write_PointerTons2__iteratorContainer #define soap_write_PointerTons2__iteratorContainer(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTons2__iteratorContainer(soap, data), 0) || soap_put_PointerTons2__iteratorContainer(soap, data, "ns2:iteratorContainer", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTons2__iteratorContainer(struct soap*, ns2__iteratorContainer *const*, const char*, const char*); #ifndef soap_read_PointerTons2__iteratorContainer #define soap_read_PointerTons2__iteratorContainer(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTons2__iteratorContainer(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__iteratorContainer ** SOAP_FMAC4 soap_get_PointerTons2__iteratorContainer(struct soap*, ns2__iteratorContainer **, const char*, const char*); #ifndef SOAP_TYPE_PointerTons2__entity #define SOAP_TYPE_PointerTons2__entity (32) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTons2__entity(struct soap*, ns2__entity *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTons2__entity(struct soap*, const char *, int, ns2__entity *const*, const char *); SOAP_FMAC3 ns2__entity ** SOAP_FMAC4 soap_in_PointerTons2__entity(struct soap*, const char*, ns2__entity **, const char*); #ifndef soap_write_PointerTons2__entity #define soap_write_PointerTons2__entity(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTons2__entity(soap, data), 0) || soap_put_PointerTons2__entity(soap, data, "ns2:entity", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTons2__entity(struct soap*, ns2__entity *const*, const char*, const char*); #ifndef soap_read_PointerTons2__entity #define soap_read_PointerTons2__entity(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTons2__entity(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__entity ** SOAP_FMAC4 soap_get_PointerTons2__entity(struct soap*, ns2__entity **, const char*, const char*); #ifndef SOAP_TYPE_PointerTons2__set #define SOAP_TYPE_PointerTons2__set (30) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTons2__set(struct soap*, ns2__set *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTons2__set(struct soap*, const char *, int, ns2__set *const*, const char *); SOAP_FMAC3 ns2__set ** SOAP_FMAC4 soap_in_PointerTons2__set(struct soap*, const char*, ns2__set **, const char*); #ifndef soap_write_PointerTons2__set #define soap_write_PointerTons2__set(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTons2__set(soap, data), 0) || soap_put_PointerTons2__set(soap, data, "ns2:set", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTons2__set(struct soap*, ns2__set *const*, const char*, const char*); #ifndef soap_read_PointerTons2__set #define soap_read_PointerTons2__set(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTons2__set(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__set ** SOAP_FMAC4 soap_get_PointerTons2__set(struct soap*, ns2__set **, const char*, const char*); #ifndef SOAP_TYPE_PointerTons2__modelRev #define SOAP_TYPE_PointerTons2__modelRev (27) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTons2__modelRev(struct soap*, ns2__modelRev *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTons2__modelRev(struct soap*, const char *, int, ns2__modelRev *const*, const char *); SOAP_FMAC3 ns2__modelRev ** SOAP_FMAC4 soap_in_PointerTons2__modelRev(struct soap*, const char*, ns2__modelRev **, const char*); #ifndef soap_write_PointerTons2__modelRev #define soap_write_PointerTons2__modelRev(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTons2__modelRev(soap, data), 0) || soap_put_PointerTons2__modelRev(soap, data, "ns2:modelRev", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTons2__modelRev(struct soap*, ns2__modelRev *const*, const char*, const char*); #ifndef soap_read_PointerTons2__modelRev #define soap_read_PointerTons2__modelRev(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTons2__modelRev(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__modelRev ** SOAP_FMAC4 soap_get_PointerTons2__modelRev(struct soap*, ns2__modelRev **, const char*, const char*); #ifndef SOAP_TYPE_PointerTons2__auditable #define SOAP_TYPE_PointerTons2__auditable (26) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTons2__auditable(struct soap*, ns2__auditable *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTons2__auditable(struct soap*, const char *, int, ns2__auditable *const*, const char *); SOAP_FMAC3 ns2__auditable ** SOAP_FMAC4 soap_in_PointerTons2__auditable(struct soap*, const char*, ns2__auditable **, const char*); #ifndef soap_write_PointerTons2__auditable #define soap_write_PointerTons2__auditable(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerTons2__auditable(soap, data), 0) || soap_put_PointerTons2__auditable(soap, data, "ns2:auditable", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTons2__auditable(struct soap*, ns2__auditable *const*, const char*, const char*); #ifndef soap_read_PointerTons2__auditable #define soap_read_PointerTons2__auditable(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTons2__auditable(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 ns2__auditable ** SOAP_FMAC4 soap_get_PointerTons2__auditable(struct soap*, ns2__auditable **, const char*, const char*); #ifndef SOAP_TYPE__QName #define SOAP_TYPE__QName (5) #endif #define soap_default__QName(soap, a) soap_default_string(soap, a) #define soap_serialize__QName(soap, a) soap_serialize_string(soap, a) SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*); SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*); #ifndef soap_write__QName #define soap_write__QName(soap, data) ( soap_begin_send(soap) || (soap_serialize__QName(soap, data), 0) || soap_put__QName(soap, data, "byte", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*); #ifndef soap_read__QName #define soap_read__QName(soap, data) ( soap_begin_recv(soap) || !soap_get__QName(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*); #ifndef SOAP_TYPE_string #define SOAP_TYPE_string (4) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*); SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*); #ifndef soap_write_string #define soap_write_string(soap, data) ( soap_begin_send(soap) || (soap_serialize_string(soap, data), 0) || soap_put_string(soap, data, "byte", NULL) || soap_end_send(soap) ) #endif SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*); #ifndef soap_read_string #define soap_read_string(soap, data) ( soap_begin_recv(soap) || !soap_get_string(soap, data, NULL, NULL) || soap_end_recv(soap) ) #endif SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*); #ifndef SOAP_TYPE_std__vectorTemplateOfPointerTons2__model #define SOAP_TYPE_std__vectorTemplateOfPointerTons2__model (39) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_std__vectorTemplateOfPointerTons2__model(struct soap*, std::vector<ns2__model * >*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_std__vectorTemplateOfPointerTons2__model(struct soap*, const std::vector<ns2__model * >*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_std__vectorTemplateOfPointerTons2__model(struct soap*, const char*, int, const std::vector<ns2__model * >*, const char*); SOAP_FMAC3 std::vector<ns2__model * >* SOAP_FMAC4 soap_in_std__vectorTemplateOfPointerTons2__model(struct soap*, const char*, std::vector<ns2__model * >*, const char*); #define soap_new_std__vectorTemplateOfPointerTons2__model(soap, n) soap_instantiate_std__vectorTemplateOfPointerTons2__model(soap, n, NULL, NULL, NULL) #define soap_delete_std__vectorTemplateOfPointerTons2__model(soap, p) soap_delete(soap, p) SOAP_FMAC1 std::vector<ns2__model * > * SOAP_FMAC2 soap_instantiate_std__vectorTemplateOfPointerTons2__model(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_std__vectorTemplateOfPointerTons2__model(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_std__vectorTemplateOfint #define SOAP_TYPE_std__vectorTemplateOfint (36) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_std__vectorTemplateOfint(struct soap*, std::vector<int >*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_std__vectorTemplateOfint(struct soap*, const std::vector<int >*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_std__vectorTemplateOfint(struct soap*, const char*, int, const std::vector<int >*, const char*); SOAP_FMAC3 std::vector<int >* SOAP_FMAC4 soap_in_std__vectorTemplateOfint(struct soap*, const char*, std::vector<int >*, const char*); #define soap_new_std__vectorTemplateOfint(soap, n) soap_instantiate_std__vectorTemplateOfint(soap, n, NULL, NULL, NULL) #define soap_delete_std__vectorTemplateOfint(soap, p) soap_delete(soap, p) SOAP_FMAC1 std::vector<int > * SOAP_FMAC2 soap_instantiate_std__vectorTemplateOfint(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_std__vectorTemplateOfint(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_std__vectorTemplateOfPointerTons2__entity #define SOAP_TYPE_std__vectorTemplateOfPointerTons2__entity (33) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_std__vectorTemplateOfPointerTons2__entity(struct soap*, std::vector<ns2__entity * >*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_std__vectorTemplateOfPointerTons2__entity(struct soap*, const std::vector<ns2__entity * >*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_std__vectorTemplateOfPointerTons2__entity(struct soap*, const char*, int, const std::vector<ns2__entity * >*, const char*); SOAP_FMAC3 std::vector<ns2__entity * >* SOAP_FMAC4 soap_in_std__vectorTemplateOfPointerTons2__entity(struct soap*, const char*, std::vector<ns2__entity * >*, const char*); #define soap_new_std__vectorTemplateOfPointerTons2__entity(soap, n) soap_instantiate_std__vectorTemplateOfPointerTons2__entity(soap, n, NULL, NULL, NULL) #define soap_delete_std__vectorTemplateOfPointerTons2__entity(soap, p) soap_delete(soap, p) SOAP_FMAC1 std::vector<ns2__entity * > * SOAP_FMAC2 soap_instantiate_std__vectorTemplateOfPointerTons2__entity(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_std__vectorTemplateOfPointerTons2__entity(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_std__vectorTemplateOfPointerTons2__set #define SOAP_TYPE_std__vectorTemplateOfPointerTons2__set (31) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_std__vectorTemplateOfPointerTons2__set(struct soap*, std::vector<ns2__set * >*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_std__vectorTemplateOfPointerTons2__set(struct soap*, const std::vector<ns2__set * >*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_std__vectorTemplateOfPointerTons2__set(struct soap*, const char*, int, const std::vector<ns2__set * >*, const char*); SOAP_FMAC3 std::vector<ns2__set * >* SOAP_FMAC4 soap_in_std__vectorTemplateOfPointerTons2__set(struct soap*, const char*, std::vector<ns2__set * >*, const char*); #define soap_new_std__vectorTemplateOfPointerTons2__set(soap, n) soap_instantiate_std__vectorTemplateOfPointerTons2__set(soap, n, NULL, NULL, NULL) #define soap_delete_std__vectorTemplateOfPointerTons2__set(soap, p) soap_delete(soap, p) SOAP_FMAC1 std::vector<ns2__set * > * SOAP_FMAC2 soap_instantiate_std__vectorTemplateOfPointerTons2__set(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_std__vectorTemplateOfPointerTons2__set(struct soap*, int, int, void*, size_t, const void*, size_t); #ifndef SOAP_TYPE_std__vectorTemplateOfPointerTons2__modelRev #define SOAP_TYPE_std__vectorTemplateOfPointerTons2__modelRev (28) #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_std__vectorTemplateOfPointerTons2__modelRev(struct soap*, std::vector<ns2__modelRev * >*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_std__vectorTemplateOfPointerTons2__modelRev(struct soap*, const std::vector<ns2__modelRev * >*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_std__vectorTemplateOfPointerTons2__modelRev(struct soap*, const char*, int, const std::vector<ns2__modelRev * >*, const char*); SOAP_FMAC3 std::vector<ns2__modelRev * >* SOAP_FMAC4 soap_in_std__vectorTemplateOfPointerTons2__modelRev(struct soap*, const char*, std::vector<ns2__modelRev * >*, const char*); #define soap_new_std__vectorTemplateOfPointerTons2__modelRev(soap, n) soap_instantiate_std__vectorTemplateOfPointerTons2__modelRev(soap, n, NULL, NULL, NULL) #define soap_delete_std__vectorTemplateOfPointerTons2__modelRev(soap, p) soap_delete(soap, p) SOAP_FMAC1 std::vector<ns2__modelRev * > * SOAP_FMAC2 soap_instantiate_std__vectorTemplateOfPointerTons2__modelRev(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_std__vectorTemplateOfPointerTons2__modelRev(struct soap*, int, int, void*, size_t, const void*, size_t); #endif /* End of soapH.h */
bbffaa8d188a876d907d46d61ea39a9ee7c0fc79
60aa44afe8335be83daecd8e1a3f8f2d6b7900d9
/RocketBehaviour.cpp
7d46ade438b6a2e87d8b648874db95147787c29f
[]
no_license
Thaon/Ferret
422e43044d71a5869773b3fab5c7d233fb9cc9d3
3315aa5a964f430a4165b30e22c243330b553249
refs/heads/master
2016-08-12T11:12:34.350516
2015-11-28T17:00:30
2015-11-28T17:00:30
44,878,799
0
0
null
null
null
null
UTF-8
C++
false
false
1,697
cpp
#include "BehaviourComponent.h" #include "Entity.h" class RocketBehaviour : public BehaviourComponent { glm::vec2 previousPosition; virtual void Start() { GetFontMgr()->addFont("Space", "Fonts/space age.ttf", 24); GetSoundMgr()->add("boop", "Audio/explosion2.wav"); //GetSoundMgr()->getSnd("boop")->loadWAVFile("Audio/explosion2.wav"); //GetSoundMgr()->getSnd("boop")->playAudio(AL_FALSE); } virtual void Update(float deltaTime) { previousPosition = GetTransform()->GetPosition(); if (GetInput()->isKeyDown(VK_RIGHT)) { GetTransform()->SetPosition(1, 0); } if (GetInput()->isKeyDown(VK_LEFT)) { GetTransform()->SetPosition(-1, 0); } if (GetInput()->isKeyDown(VK_UP)) { GetTransform()->SetPosition(0, -1); } if (GetInput()->isKeyDown(VK_DOWN)) { GetTransform()->SetPosition(0, 1); } } virtual void OnCollisionEnter(Entity* other) { if (other->GetName() == "Wall") { //GetFontMgr()->getFont("Space")->printText("Wall!", FTPoint(GetTransform()->GetPosition().x, GetTransform()->GetPosition().y, 1.0f)); GetTransform()->SetPosition(previousPosition); } if (other->GetName() == "test2") { GetFontMgr()->getFont("Space")->printText("Rocket!", FTPoint(GetTransform()->GetPosition().x, GetTransform()->GetPosition().y, 1.0f)); //GetSoundMgr()->getSnd("boop")->playAudio(AL_FALSE); } //GetTransform()->SetPosition(previousPosition); //GetFontMgr()->getFont("Space")->printText("Collision! YEEEEEEEEEEEEEEEEEEEEEE", FTPoint(GetTransform()->GetPosition().x, GetTransform()->GetPosition().y, 1.0f)); //GetSoundMgr()->getSnd("Shot")->playAudio(AL_TRUE); //GetSoundMgr()->getSnd("boop")->playAudio(AL_FALSE); } };
140bef7053101c08879f51d97dcc1cd31bb1f853
08d7b1327cc59d0f5ee20ca36b9bb36d8a8246b0
/src/main.cpp
692ed763c680dee43e15bb82ff09a1a1a31907a3
[]
no_license
sungwook87/jane_ui
d87c56a6d699bdfc6f38d198cf593c886bfc9c5c
1e407c0fe7bcd6fdac2456d74270fd2bd7ab903d
refs/heads/master
2022-12-08T10:16:00.620141
2020-09-07T02:39:50
2020-09-07T02:39:50
278,596,581
0
0
null
null
null
null
UTF-8
C++
false
false
220
cpp
#include <QApplication> #include "UIwindow.h" using namespace ui_server; int main(int argc, char** argv) { QApplication app(argc, argv); UIWindow s(argc, argv); ROS_INFO("hi~ui"); return app.exec(); }
3e9fc37bb38b5bc872ba6af27620efccfd603918
d1197c803204d5cddbc7d1fc6ce97cff3c80b268
/GLutils/GLUtils.cpp
58485deb774360cc7127599a8861af0ccd099bd2
[]
no_license
scarensac/simbicon_qt
dbe87dbdbf0ed83ce7faf788ce25a881031f64a1
d1af64df53eeded51aa4c8e1e2995712bf3841be
refs/heads/master
2022-04-13T11:23:11.429461
2020-03-05T13:49:07
2020-03-05T13:49:07
157,716,794
0
0
null
null
null
null
UTF-8
C++
false
false
13,845
cpp
/* Simbicon 1.5 Controller Editor Framework, Copyright 2009 Stelian Coros, Philippe Beaudoin and Michiel van de Panne. All rights reserved. Web: www.cs.ubc.ca/~van/simbicon_cef This file is part of the Simbicon 1.5 Controller Editor Framework. Simbicon 1.5 Controller Editor Framework 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 3 of the License, or (at your option) any later version. Simbicon 1.5 Controller Editor Framework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Simbicon 1.5 Controller Editor Framework. If not, see <http://www.gnu.org/licenses/>. */ #include ".\glutils.h" #include <math.h> #include <fstream> #include <iostream> #include <iosfwd> #include <fstream> #include <Utils/Image.h> #include <Utils/BMPIO.h> #include <string> //extern unsigned int fontBaseList; GLUtils::GLUtils(void) { } GLUtils::~GLUtils(void) { } /** This method draws a wireframe cube that is defined by the two 3d points */ void GLUtils::drawWireFrameBox(Point3d min, Point3d max){ //now draw the cube that is defined by these two points... glBegin(GL_LINES); glVertex3d(min.x, min.y, min.z); glVertex3d(max.x, min.y, min.z); glVertex3d(max.x, min.y, min.z); glVertex3d(max.x, max.y, min.z); glVertex3d(max.x, max.y, min.z); glVertex3d(min.x, max.y, min.z); glVertex3d(min.x, max.y, min.z); glVertex3d(min.x, min.y, min.z); glVertex3d(min.x, min.y, min.z); glVertex3d(min.x, max.y, min.z); glVertex3d(min.x, max.y, min.z); glVertex3d(min.x, max.y, max.z); glVertex3d(min.x, max.y, max.z); glVertex3d(min.x, min.y, max.z); glVertex3d(min.x, min.y, max.z); glVertex3d(min.x, min.y, min.z); glVertex3d(min.x, min.y, max.z); glVertex3d(max.x, min.y, max.z); glVertex3d(max.x, min.y, max.z); glVertex3d(max.x, max.y, max.z); glVertex3d(max.x, max.y, max.z); glVertex3d(min.x, max.y, max.z); glVertex3d(min.x, max.y, max.z); glVertex3d(min.x, min.y, max.z); glVertex3d(max.x, min.y, min.z); glVertex3d(max.x, max.y, min.z); glVertex3d(max.x, max.y, min.z); glVertex3d(max.x, max.y, max.z); glVertex3d(max.x, max.y, max.z); glVertex3d(max.x, min.y, max.z); glVertex3d(max.x, min.y, max.z); glVertex3d(max.x, min.y, min.z); glEnd(); } /** This method draws a box cube that is defined by the two 3d points */ void GLUtils::drawBox(Point3d min, Point3d max){ //now draw the cube that is defined by these two points... glBegin(GL_QUADS); glNormal3d(0, 0, -1); glVertex3d(min.x, min.y, min.z); glVertex3d(max.x, min.y, min.z); glVertex3d(max.x, max.y, min.z); glVertex3d(min.x, max.y, min.z); glNormal3d(0, 0, 1); glVertex3d(min.x, min.y, max.z); glVertex3d(max.x, min.y, max.z); glVertex3d(max.x, max.y, max.z); glVertex3d(min.x, max.y, max.z); glNormal3d(0, -1, 0); glVertex3d(min.x, min.y, min.z); glVertex3d(max.x, min.y, min.z); glVertex3d(max.x, min.y, max.z); glVertex3d(min.x, min.y, max.z); glNormal3d(0, 1, 0); glVertex3d(min.x, max.y, min.z); glVertex3d(max.x, max.y, min.z); glVertex3d(max.x, max.y, max.z); glVertex3d(min.x, max.y, max.z); glNormal3d(-1, 0, 0); glVertex3d(min.x, min.y, min.z); glVertex3d(min.x, min.y, max.z); glVertex3d(min.x, max.y, max.z); glVertex3d(min.x, max.y, min.z); glNormal3d(1, 0, 0); glVertex3d(max.x, min.y, min.z); glVertex3d(max.x, min.y, max.z); glVertex3d(max.x, max.y, max.z); glVertex3d(max.x, max.y, min.z); glEnd(); /* // sides glBegin (GL_TRIANGLE_STRIP); glNormal3d (-1,0,0); glVertex3d (min.x,min.y,min.z); glVertex3d (min.x,min.y,max.z); glVertex3d (min.x,max.y,min.z); glVertex3d (min.x,max.y,max.z); glNormal3d (0,1,0); glVertex3d (max.x,max.y,min.z); glVertex3d (max.x,max.y,max.z); glNormal3d (1,0,0); glVertex3d (max.x,min.y,min.z); glVertex3d (max.x,min.y,max.z); glNormal3d (0,-1,0); glVertex3d (min.x,min.y,min.z); glVertex3d (min.x,min.y,max.z); glEnd(); // top face glBegin (GL_TRIANGLE_FAN); glNormal3d (0,0,1); glVertex3d (min.x,min.y,max.z); glVertex3d (max.x,min.y,max.z); glVertex3d (max.x,max.y,max.z); glVertex3d (min.x,max.y,max.z); glEnd(); // bottom face glBegin (GL_TRIANGLE_FAN); glNormal3d (0,0,-1); glVertex3d (min.x,min.y,min.z); glVertex3d (min.x,max.y,min.z); glVertex3d (max.x,max.y,min.z); glVertex3d (max.x,min.y,min.z); glEnd(); */ } /** This method draws a sphere of radius r, centered at the origin. It uses nrPoints for the approximation. */ void GLUtils::drawSphere(Point3d origin, double r, int nrPoints){ int j; double i, angle = PI/nrPoints; //this is the normal vector Vector3d n, v; glPushMatrix(); glTranslated(origin.x, origin.y, origin.z); Point3d p, q; glBegin(GL_QUAD_STRIP); p.x = r*cos(-PI/2); p.y = r*sin(-PI/2); p.z = 0; for (i=-PI/2+angle;i<=PI/2;i+=angle) { q.x = r*cos(i); q.y = r*sin(i); q.z = 0; //make sure we compute the normal as well as the node coordinates n = Vector3d(p).toUnit(); glNormal3d(n.x, n.y, n.z); glVertex3d(p.x,p.y,p.z); //make sure we compute the normal as well as the node coordinates n = Vector3d(q).toUnit(); glNormal3d(n.x, n.y, n.z); glVertex3d(q.x,q.y,q.z); for (j=0;j<=2*nrPoints;j++){ //make sure we compute the normal as well as the node coordinates v = Vector3d(q.x * cos(j * angle), q.y, q.x * sin(j * angle)); n = v.unit(); glNormal3d(n.x, n.y, n.z); glVertex3d(v.x, v.y, v.z); //make sure we compute the normal as well as the node coordinates v = Vector3d(p.x * cos(j * angle), p.y, p.x * sin(j * angle)); n = v.unit(); glNormal3d(n.x, n.y, n.z); glVertex3d(v.x, v.y, v.z); } p = q; } glEnd(); glPopMatrix(); } /** This method draws a system of coordinate axes of length n */ void GLUtils::drawAxes(double n){ glBegin(GL_LINES); //draw the axis... glColor3f(1.0f,0.0f,0.0f); glVertex3d(0,0,0); //X axis glVertex3d(n,0,0); glColor3f(0.0f,1.0f,0.0f); glVertex3d(0,0,0); //Y axis glVertex3d(0,n,0); glColor3f(0.0f,0.0f,1.0f); glVertex3d(0,0,0); //Z axis glVertex3d(0,0,n); glEnd(); } /** This method draws a disc of radius r, centered on point org with normal norm */ void GLUtils::drawDisk(double r, Point3d org, Vector3d norm, int nrPoints) { Vector3d n = norm; n.toUnit(); Vector3d x = Vector3d(0,1,0).crossProductWith(n); Vector3d y = Vector3d(1,0,0).crossProductWith(n); if( x.length() < 0.01 ) x = Vector3d(0,0,1).crossProductWith(n); else if( y.length() < 0.01 ) y = Vector3d(0,0,1).crossProductWith(n); x.toUnit(); y.toUnit(); glBegin(GL_TRIANGLE_FAN); glNormal3d( n.x, n.y, n.z ); glVertex3d( org.x, org.y, org.z ); for( int i=0; i<=nrPoints; ++i ) { double theta = (i%nrPoints) / (double)nrPoints * 2.0 * 3.14159265; Point3d p = org + x * cos(theta) * r + y * sin(theta) * r; glVertex3d( p.x, p.y, p.z ); } glEnd(); } /** This method draws a cylinder of thinkness r, along the vector dir. */ void GLUtils::drawCylinder(double r, Vector3d v, Point3d org, int nrPoints){ //we'll start out by getting a vector that is perpendicular to the given vector. Vector3d n; Vector3d axis = v; axis.toUnit(); int i; //try to get a vector that is not colinear to v. if (v.x != 0 || v.y != 0) n = Vector3d(v.x, v.y, v.z + 1); else if (v.y != 0 || v.z != 0) n = Vector3d(v.x, v.y+1, v.z); else n = Vector3d(v.x+1, v.y, v.z); n = n.crossProductWith(v); if (IS_ZERO(v.length()) || IS_ZERO(n.length())) return; (n.toUnit()) *= r; glBegin(GL_TRIANGLE_STRIP); //now, we we'll procede by rotating the vector n around v, and create the cylinder that way. for (i=0;i<=nrPoints;i++){ Vector3d p = n.rotate(2*i*PI/nrPoints, axis); Vector3d normal = p.unit(); glNormal3d(normal.x, normal.y, normal.z); Point3d p1 = org + p; glVertex3d(p1.x, p1.y, p1.z); Point3d p2 = org + v + p; glVertex3d(p2.x, p2.y, p2.z); } glEnd(); } /** This method draws a cone of radius r, along the vector dir, with the center of its base at org. */ void GLUtils::drawCone(double r, Vector3d v, Point3d org, int nrPoints){ //we'll start out by getting a vector that is perpendicular to the given vector. Vector3d n; Vector3d axis = v; axis.toUnit(); int i; //try to get a vector that is not colinear to v. if (v.x != 0 || v.y != 0) n = Vector3d(v.x, v.y, v.z + 1); else if (v.y != 0 || v.z != 0) n = Vector3d(v.x, v.y+1, v.z); else n = Vector3d(v.x+1, v.y, v.z); n = n.crossProductWith(v); if (IS_ZERO(v.length()) || IS_ZERO(n.length())) return; (n.toUnit()) *= r; glBegin(GL_TRIANGLE_FAN); Point3d p2 = org + v; glNormal3d(axis.x, axis.y, axis.z); glVertex3d(p2.x, p2.y, p2.z); //now, we we'll procede by rotating the vector n around v, and creating the cone that way. for (i=0;i<=nrPoints;i++){ Vector3d p = n.rotate(2*i*PI/nrPoints, axis); Vector3d normal = p.unit(); glNormal3d(normal.x, normal.y, normal.z); Point3d p1 = org + p; glVertex3d(p1.x, p1.y, p1.z); } glEnd(); //now we need to draw the bottom of the cone. glBegin(GL_POLYGON); //now, we we'll procede by rotating the vector n around v, and creating the cone that way. for (i=0;i<=nrPoints;i++){ Vector3d p = n.rotate(2*i*PI/nrPoints, axis); Vector3d normal = p.unit(); glNormal3d(normal.x, normal.y, normal.z); Point3d p1 = org + p; glVertex3d(p1.x, p1.y, p1.z); } glEnd(); } /** This method is used to draw an arrow, in the direction pointed by the vector dir, originating at the point org. The thickness of the cylinder used, as well as the length of the arrow head are estimated based on the length of the direction vector. */ void GLUtils::drawArrow(Vector3d dir, Point3d org){ drawCylinder(dir.length()/20, dir*0.8, org); drawCone(dir.length()/10, dir/4, org+dir*0.75); } /** This method is used to draw an arrow, in the direction pointed by the vector dir, originating at the point org. The thickness of the cylinder used, as well as the length of the arrow head are estimated based on the length of the direction vector. */ void GLUtils::drawArrow(Vector3d dir, Point3d org, double scale){ drawCylinder(scale, dir*0.8, org); drawCone(2*scale, dir/(dir.length())*scale*5, org+dir*0.75); } /** This method will take a screenshot of the current scene and it will save it to a file with the given name */ void GLUtils::saveScreenShot(char* fileName, int x, int y, int width, int height){ if (fileName == NULL) return; std::ofstream out(fileName, std::ofstream::binary); if(!out) return; glReadBuffer(GL_BACK); Image *img = new Image(3, width, height, NULL); glReadPixels(x , y, width, height, GL_RGB, GL_UNSIGNED_BYTE, img->getDataPointer()); BMPIO b(fileName); b.writeToFile(img); delete img; } /** This method draws a checker-board pattern (centered at the origin, parallel to the XZ plane) based on the current parameters: int n - the number of squares (we'll assume square checkerboards for now!) double w - the size of each square int the checkerboard double h - the height at which the checkerboard is to be drawn */ void GLUtils::drawCheckerboard(int n, double w, double h){ #define BRIGHT 0.5f #define DARK 0.2f double start = n/2.0 * w; for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ if ((i+j)%2 == 1) glColor3d(BRIGHT, BRIGHT, BRIGHT); else glColor3d(DARK, DARK, DARK); glBegin(GL_QUADS); glVertex3d(-start+i*w,h,-start+j*w); glVertex3d(-start+i*w+w,h,-start+j*w); glVertex3d(-start+i*w+w,h,-start+j*w+w); glVertex3d(-start+i*w,h,-start+j*w+w); glEnd(); } } } /** This method draws a grid pattern (centered at the origin, parallel to the XZ plane) based on the current parameters: int n - the number of squares (we'll assume square grid for now!) double w - the size of each square in the grid double h - the height at which the grid is to be drawn */ void GLUtils::drawGrid(int n, double w, double h){ glColor3d(0.5f, 0.5f, 0.5f); double start = n/2.0 * w; glLineWidth(0.5); for (int i=1;i<n;i++){ glBegin(GL_LINES); glVertex3d(-start+i*w,h,-start); glVertex3d(-start+i*w,h,start); glVertex3d(-start,h,-start+i*w); glVertex3d(start, h,-start+i*w); glEnd(); } glLineWidth(1); //draw a thicker line in the middle now, glColor3d(0.7f, 0.7f, 0.7f); glLineWidth(2); glBegin(GL_LINES); glVertex3d(0,h,-start); glVertex3d(0,h,start); glVertex3d(-start,h,0); glVertex3d(start, h,0); glEnd(); glLineWidth(1); } /** Prints the openGL errors */ int GLUtils::printOglError(char *file, int line){ // // Returns 1 if an OpenGL error occurred, 0 otherwise. // GLenum glErr; int retCode = 0; glErr = glGetError(); while (glErr != GL_NO_ERROR){ std::cerr<<"glError in file "<<std::string(file)<<" line "<<line<<": " <<gluErrorString(glErr)<<std::endl; retCode = 1; glErr = glGetError(); } return retCode; } void GLUtils::drawEllipsoid(unsigned int uiStacks, unsigned int uiSlices, float fA, float fB, float fC) { float tStep = (PI) / (float)uiSlices; float sStep = (PI) / (float)uiStacks; for(float t = -PI/2; t <= (PI/2)+.0001; t += tStep) { glBegin(GL_TRIANGLE_STRIP); for(float s = -PI; s <= PI+.0001; s += sStep) { glVertex3f(fA * cos(t) * cos(s), fB * cos(t) * sin(s), fC * sin(t)); glVertex3f(fA * cos(t+tStep) * cos(s), fB * cos(t+tStep) * sin(s), fC * sin(t+tStep)); } glEnd(); } }
fc5ed3830aa7b4ef296a0de625bcafde3d488144
9b306624ca5f3acb96c82a0c4da5c23091df5dc3
/LinkList.h
b1dd7d928195947ce214ca9414df20a54cc2e660
[]
no_license
nanccc/DTLib
fbf62952a845b1e2916802117f19dac44d837320
86c26f755dd03c9f0d8e46b54104ed512b257461
refs/heads/master
2022-04-10T06:47:31.184078
2020-03-24T09:02:00
2020-03-24T09:02:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,354
h
#ifndef LINKLIST_H #define LINKLIST_H #include "List.h" #include "Exception.h" namespace DTLib { template <typename T> class LinkList : public List<T> { public: LinkList() { m_header.next = nullptr; m_length = 0; m_step = 1; m_current = nullptr; } bool insert(const T &e) override // O(n) { return insert(m_length, e); } bool insert(int i, const T &e) override // O(n) { bool ret = ((0 <= i) && (i <= m_length)); if (ret) { Node *node = create(); if (node != nullptr) { Node *current = position(i); node->value = e; node->next = current->next; current->next = node; ++m_length; } else { THROW_EXCEPTION(NoEnoughMemoryException, "No memory to insert new element ..."); } } return ret; } bool remove(int i) override // O(n) { bool ret = ((0 <= i) && (i < m_length)); if (ret) { Node *current = position(i); Node *toDel = current->next; if (m_current == toDel) { m_current = toDel->next; } current->next = toDel->next; --m_length; destroy(toDel); } return ret; } bool set(int i, const T &e) override // O(n) { bool ret = ((0 <= i) && (i < m_length)); if (ret) { position(i)->next->value = e; } return ret; } virtual T get(int i) const // O(n) { T ret; if (!get(i, ret)) { THROW_EXCEPTION(IndexOutOfBoundsException, "Invalid parameter i to get element ..."); } return ret; } bool get(int i, T &e) const override // O(n) { bool ret = ((0 <= i) && (i < m_length)); if (ret) { e = position(i)->next->value; } return ret; } int find(const T &e) const override // O(n) { int ret = -1; int i = 0; Node *node = m_header.next; while (node) { if (node->value == e) { ret = i; break; } else { node = node->next; ++i; } } return ret; } int length() const override // O(1) { return m_length; } void clear() override // O(n) { while (m_header.next) { Node *toDel = m_header.next; m_header.next = toDel->next; --m_length; destroy(toDel); } m_current = nullptr; } bool move(int i, int step = 1) // O(n) { bool ret = ((0 <= i) && (i < m_length) && (step > 0)); if (ret) { m_current = position(i)->next; m_step = step; } return ret; } bool end() // O(1) { return (m_current == nullptr); } T current() // O(1) { if (!end()) { return m_current->value; } else { THROW_EXCEPTION(InvalidOpertionExcetion, " No value at current posotion ..."); } } bool next() // O(n) { int i = 0; while ((i < m_step) && !end()) { m_current = m_current->next; ++i; } return (i == m_step); } ~LinkList() // O(n) { clear(); } protected: struct Node : public Object { T value; Node *next; }; mutable struct : public Object { char reserved[sizeof (T)]; Node *next; }m_header; int m_length; int m_step; Node *m_current; Node *position(int i) const // O(n) { Node *ret = reinterpret_cast<Node*>(&m_header); for (int p=0; p<i; ++p) { ret = ret->next; } return ret; } virtual Node *create() // N(1) { return new Node(); } virtual void destroy(Node *pn) // N(1) { delete pn; } }; } #endif // LINKLIST_H
a536c3121ea0c7aeac636a0e9771254d1898bc01
5197dc4157d69f0eeda320887dc0abaf311f810b
/sdc_gym/box2d-py-2.3.8/Box2D/Dynamics/Contacts/b2NullContact.h
c607a8a8e378fc6c621ff6cec3f03d1d7e9ba5aa
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Zlib" ]
permissive
ManaliSharma/Autonomous_Vehicle
9086c914a5beb53e68004acebb2b8dc26b4aa241
796c0af5df75a7bb5127369d30e429e9c471ef54
refs/heads/main
2023-02-03T20:40:07.147841
2020-12-19T04:54:37
2020-12-19T04:54:37
320,924,350
2
0
MIT
2020-12-12T21:24:32
2020-12-12T21:08:12
Jupyter Notebook
UTF-8
C++
false
false
1,241
h
/* * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #ifndef B2_NULL_CONTACT_H #define B2_NULL_CONTACT_H #include <Box2D/Dynamics/Contacts/b2Contact.h> class b2NullContact : public b2Contact { public: b2NullContact() {} void Evaluate() {} float32 ComputeTOI(const b2Sweep& sweepA, const b2Sweep& sweepB) const { B2_NOT_USED(sweepA); B2_NOT_USED(sweepB); return 1.0f; } }; #endif
3b054c039ed0f10df2f9962995266d500526f05c
6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849
/sstd_boost/sstd/boost/metaparse/v1/foldl.hpp
5abefd5f67a46df0594f1db9314579b6bfcc2393
[ "BSL-1.0" ]
permissive
KqSMea8/sstd_library
9e4e622e1b01bed5de7322c2682539400d13dd58
0fcb815f50d538517e70a788914da7fbbe786ce1
refs/heads/master
2020-05-03T21:07:01.650034
2019-04-01T00:10:47
2019-04-01T00:10:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,874
hpp
#ifndef BOOST_METAPARSE_V1_FOLDL_HPP #define BOOST_METAPARSE_V1_FOLDL_HPP // Copyright Abel Sinkovics ([email protected]) 2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <sstd/boost/metaparse/v1/accept.hpp> #include <sstd/boost/metaparse/v1/is_error.hpp> #include <sstd/boost/metaparse/v1/get_position.hpp> #include <sstd/boost/metaparse/v1/get_result.hpp> #include <sstd/boost/metaparse/v1/get_remaining.hpp> #include <sstd/boost/mpl/eval_if.hpp> namespace boost { namespace metaparse { namespace v1 { template <class P, class State, class ForwardOp> struct foldl { private: template <class Res> struct apply_unchecked : // foldl never returns error // I need to use apply_wrap, and not apply, because apply would // build a metafunction class from foldl<P, State, ForwardOp> // when ForwardOp is a lambda expression. foldl< P, typename ForwardOp::template apply< typename State::type, typename get_result<Res>::type >, ForwardOp >::template apply< typename get_remaining<Res>::type, typename get_position<Res>::type > {}; template <class S, class Pos> struct next_iteration : accept<typename State::type, S, Pos> {}; public: typedef foldl type; template <class S, class Pos> struct apply : boost::mpl::eval_if< typename is_error<typename P::template apply<S, Pos> >::type, next_iteration<S, Pos>, apply_unchecked<typename P::template apply<S, Pos> > > {}; }; } } } #endif
f04f71bfa924e24c64856f45c04e5ef59ab2d65b
c6f7cfab747c23e52c7810f7bf57644da918f724
/IniParser/ParseHelper.h
66997df198db030794dc983e2165b5c193fc0bc7
[]
no_license
huxia1124/IniParser
c21b3ecabca3eb683295fef51eff9b55cad80254
02b30231d54f9a4820bb971188560e5a9e0d6c1b
refs/heads/master
2021-11-10T23:49:34.520134
2021-10-29T23:00:41
2021-10-29T23:00:41
67,233,675
2
3
null
null
null
null
UTF-8
C++
false
false
2,904
h
#pragma once #include <wtypes.h> #include <tchar.h> #pragma warning(disable:4786) #include <string> #include <map> using namespace std; #ifdef UNICODE #define STLSTRING wstring #else #define STLSTRING string #endif ////////////////////////////////////////////////////////////////////////// // CParseHelper class CParseHelper { private: CParseHelper(); public: virtual ~CParseHelper(); public: static BOOL IsStringLeadWith(LPCTSTR lpszString, LPCTSTR lpszLead); static BOOL IsUnicodeText(LPVOID pText); //Parse (T) static COLORREF ParseColor(LPCTSTR lpszColor); //XXX XXX XXX static COLORREF ParseColor(LPCTSTR lpszColor, COLORREF clrDefault); //XXX XXX XXX static int ParseInt(LPCTSTR lpszInt); //XXX static int ParseInt(LPCTSTR lpszInt, int iDefault); //XXX static INT32 ParseInt32(LPCTSTR lpszInt32); //XXX static INT32 ParseInt32(LPCTSTR lpszInt32, INT32 iDefault); //XXX static double ParseDouble(LPCTSTR lpszDouble); //XXX.xx static double ParseDouble(LPCTSTR lpszDouble, double fDefault); //XXX.xx static BOOL ParseFont(LPCTSTR lpszFont, LOGFONT* lpLogFont); //FontFaceName 12 Bold static BOOL ParseFont(LPCTSTR lpszFont, LPTSTR lpszFaceNameBuf, DWORD cchBufLen, LPINT lpSize, LPBOOL lpBold, LPBOOL lpItalic); static BOOL ParseMargins(LPCTSTR lpszMargins, LPRECT lpMargins); //X,X,X,X static BOOL ParseRect(LPCTSTR lpszMargins, LPRECT lpMargins); //X,X,X,X static SIZE ParseSize(LPCTSTR lpszSize); //X,X static POINT ParsePoint(LPCTSTR lpszPoint); //X,X static BOOL ParseBool(LPCTSTR lpszBool); //true or false static BOOL ParseBool(LPCTSTR lpszBool, BOOL bBoolDefault); //true or false static LONG ParseResFileName(LPCTSTR lpszFileName, LPTSTR lpszBuf, DWORD cchBufSize); //convert AA\BB.bmp to AA_BB_BMP static LPCTSTR GetNextPart(LPCTSTR lpszString, TCHAR chSeparator); static LPCTSTR GetNextPart(LPCTSTR lpszString); //Separated by [Space] or , static DWORD CopyFirstPart(LPTSTR lpszBuf, LPCTSTR lpszString, DWORD dwMaxLen); //Copy the first part of the string, terminated by [Space] or , static DWORD CopyFirstPart(LPTSTR lpszBuf, LPCTSTR lpszString, DWORD dwMaxLen, TCHAR chSeparator); //Copy the first part of the string, terminated by [Space] or , public: static void SizeAbs(SIZE *lpSize); //abs(size.cx), abs(size.cy) static void PointAbs(POINT *lpPoint); //abs(point.x), abs(point.y) static BOOL IsEmptyMargins(LPCRECT lprcMargins); protected: #ifdef UNICODE struct _CNoCaseLess { bool operator()(const wstring& str1, const wstring& str2) const { return _tcsicmp(str1.c_str(), str2.c_str()) < 0; } }; typedef map<wstring, int, _CNoCaseLess> TYPEDINTMAP; TYPEDINTMAP m_mapTypedInt; #else struct _CNoCaseLess { bool operator()(const string& str1, const string& str2) const { return _tcsicmp(str1.c_str(), str2.c_str()) < 0; } }; typedef map<string, int, _CNoCaseLess> TYPEDINTMAP; TYPEDINTMAP m_mapTypedInt; #endif };
553f7fb2e5609d8f1e38ed4f3bae0c7869f3e30b
e9728cb206d02aa093fa63b16a44a64079cb6a93
/corex/src/corex/core/math_functions.hpp
fe3ad1db4f6b730f6f1bf58d8b76814c00a4f7b1
[ "MIT" ]
permissive
seanballais/gwo-visualization
70a45cb65d3bd0ebaa4d7a391d394f2f76f28d87
470561c603236d6a858b78a8585fd0bae71612a5
refs/heads/master
2023-04-21T15:49:53.158801
2021-05-21T12:05:05
2021-05-21T12:05:05
368,853,868
1
0
null
null
null
null
UTF-8
C++
false
false
13,977
hpp
#ifndef COREX_CORE_MATH_FUNCTIONS_HPP #define COREX_CORE_MATH_FUNCTIONS_HPP #include <cassert> #include <cstdlib> #include <limits> #include <type_traits> #include <EASTL/algorithm.h> #include <EASTL/array.h> #include <EASTL/vector.h> #include <EASTL/utility.h> #include <SDL_gpu.h> #include <corex/core/ReturnValue.hpp> #include <corex/core/utils.hpp> #include <corex/core/ds/Line.hpp> #include <corex/core/ds/NPolygon.hpp> #include <corex/core/ds/Point.hpp> #include <corex/core/ds/Polygon.hpp> #include <corex/core/ds/Rectangle.hpp> #include <corex/core/ds/Vec2.hpp> #include <corex/core/ds/VecN.hpp> namespace corex::core { constexpr double pi = 3.14159265358979323846; bool floatEquals(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatAbsEquals(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatRelEquals(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatGreEqual(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatAbsGreEqual(float x, float y, float tolerance = std::numeric_limits<float> ::epsilon()); bool floatRelGreEqual(float x, float y, float tolerance = std::numeric_limits<float> ::epsilon()); bool floatLessEqual(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatAbsLessEqual(float x, float y, float tolerance = std::numeric_limits<float> ::epsilon()); bool floatRelLessEqual(float x, float y, float tolerance = std::numeric_limits<float> ::epsilon()); bool floatGreater(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatAbsGreater(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatRelGreater(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatLessThan(float x, float y, float tolerance = std::numeric_limits<float>::epsilon()); bool floatAbsLessThan(float x, float y, float tolerance = std::numeric_limits<float> ::epsilon()); bool floatRelLessThan(float x, float y, float tolerance = std::numeric_limits<float> ::epsilon()); float setDecPlaces(float n, int32_t numDecPlaces); double setDecPlaces(double n, int32_t numDecPlaces); bool isFloatInclusiveBetween(float a, float val, float b); template <class T> T clamp(T val, T min, T max) { if (val < min) { return min; } else if (val > max) { return max; } return val; } int32_t abs(int32_t n); int32_t factorial(int32_t n); int32_t mod(int32_t x, int32_t divisor); float mod(float x, float divisor); int32_t pow(int32_t base, int32_t exponent); float pow(float base, int32_t exponent); double pow(double base, int32_t exponent); float degreesToRadians(float degrees); float radiansToDegrees(float radians); float distance2D(const Point& start, const Point& end); float lineLength(const Line& line); float lineSlope(const Line& line); Line longestLine(const eastl::vector<Line*> lines); float det3x3(const Vec2& v0, const Vec2& v1, const Vec2& v2); float vec2Magnitude(const Vec2& p); float vec2Angle(const Vec2& p); float dotProduct(const Vec2& p, const Vec2& q); float crossProduct(const Vec2& p, const Vec2& q); float angleBetweenTwoVectors(const Vec2& p, const Vec2& q); Vec2 rotateVec2(const Vec2& p, float angle); Vec2 projectVec2(const Vec2& p, const Vec2& q); Vec2 vec2Perp(const Vec2& p); Vec2 translateVec2(const Vec2& vec, float deltaX, float deltaY); Vec2 minVec2Magnitude(const eastl::vector<Vec2*> vectors); Vec2 maxVec2Magnitude(const eastl::vector<Vec2*> vectors); Vec2 unitVector(const Vec2& vec); Vec2 lineToVec(const Line& line); Vec2 lineDirectionVector(const Line& line); Vec2 lineNormalVector(const Line& line); VecN pairwiseMult(const VecN& p, const VecN& q); VecN pairwiseSubt(const VecN& p, const float& a); VecN pairwiseSubt(const float& a, const VecN& p); VecN vecNAbs(const VecN& vec); Vec2 pairwiseMult(const Vec2& p, const Vec2& q); Vec2 pairwiseSubt(const Vec2& p, const float& a); Vec2 pairwiseSubt(const float& a, const Vec2& p); Vec2 vec2Abs(const Vec2& vec); template <typename... Args> inline constexpr auto rotatePoint(Args&&... args) -> decltype(rotateVec2(eastl::forward<Args>(args)...)) { return rotateVec2(eastl::forward<Args>(args)...); } template <typename... Args> inline constexpr auto projectPoint(Args&&... args) -> decltype(projectVec2(eastl::forward<Args>(args)...)) { return projectVec2(eastl::forward<Args>(args)...); } template <typename... Args> inline constexpr auto translatePoint(Args&&... args) -> decltype(translateVec2(eastl::forward<Args>(args)...)) { return translateVec2(eastl::forward<Args>(args)...); } float signedDistPointToInfLine(const Point& point, const Line& line); Polygon<4> createRectangle(const Point& startingPoint, float width, float height); Polygon<4> createRectangle(const NPolygon& nPolygon); Polygon<4> rotateRectangle(float centerX, float centerY, float width, float height, float angle); Polygon<4> rotateRectangle(const Rectangle& rect); Polygon<4> convertRectangleToPolygon(const Rectangle& rect); bool areTwoRectsIntersecting(const Rectangle& rect0, const Rectangle& rect1); bool areTwoRectsAABBIntersecting(const Rectangle& rect0, const Rectangle& rect1); ReturnValue<Point> intersectionOfTwoInfLines(const Line& line0, const Line& line1); ReturnValue<Point> intersectionOfLineandInfLine(const Line& line, const Line& infLine); ReturnValue<Point> intersectionOfLineAndLine(const Line& line0, const Line& line1); bool areTwoLinesIntersecting(const Line& line0, const Line& line1); NPolygon clippedPolygonFromTwoRects(const Rectangle& targetRect, const Rectangle& clippingRect); Point getRandomPointInTriangle(const Polygon<3>& triangle); Point getPolygonCentroid(const NPolygon& polygon); int32_t getNumNPolygonSides(const NPolygon& polygon); bool isPointWithinNPolygon(const Point& point, const NPolygon& polygon); bool isRectWithinNPolygon(const Rectangle& rect, const NPolygon& polygon); bool isRectWithinNPolygonAABB(const Rectangle& rect, const NPolygon& polygon); bool isRectWithinRectAABB(const Rectangle& insideRect, const Rectangle& outsideRect); bool isRectIntersectingNPolygon(const Rectangle& rect, const NPolygon& polygon); Polygon<4> getIntersectingRectAABB(const Rectangle& rect0, const Rectangle& rect1); eastl::vector<Polygon<3>> earClipTriangulate(NPolygon polygon); eastl::vector<int32_t> findEarVertexIndexes(const NPolygon& polygon); eastl::vector<int32_t> findConvexVertexIndexes(const NPolygon& polygon); eastl::vector<int32_t> findReflexVertexIndexes(const NPolygon& polygon); eastl::vector<float> computePolygonInteriorAngles(const NPolygon& polygon); bool isVertexAnEarInPolygon(const int32_t & vertexIndex, const NPolygon& polygon); template <class P> eastl::array<Point, 3> findConvexHull(const P& polygon) { // Find three vertices that is representative of the polygon's convex hull. // Refer to: https://en.wikipedia.org/wiki/ // Curve_orientation#Practical_considerations auto& vertices = polygon.vertices; auto chVertexIter = eastl::min_element( vertices.begin(), vertices.end(), [](const Point& a, const Point& b) -> bool { return (a.x < b.x) || (a.x == b.x && a.y < b.y); } ); int32_t chVertexIndex = chVertexIter - vertices.begin(); int32_t prevCHVertexIndex = mod(chVertexIndex - 1, vertices.size()); int32_t nextCHVertexIndex = mod(chVertexIndex + 1, vertices.size()); return { vertices[prevCHVertexIndex], vertices[chVertexIndex], vertices[nextCHVertexIndex] }; } template <class P> double getPolygonArea(const P& polygon) { // Let's use the Shoelace algorithm. double area = 0.f; auto& vertices = polygon.vertices; auto convexHull = findConvexHull(polygon); float determinant = det3x3(convexHull[0], convexHull[1], convexHull[2]); for (int32_t i = 0; i < polygon.vertices.size(); i++) { int32_t currVertIndex = 0; int32_t nextVertIndex = 0; if (floatGreEqual(determinant, 0.f)) { // Polygon is oriented counterclockwise when the origin is in the // center. currVertIndex = i; nextVertIndex = mod(currVertIndex + 1, vertices.size()); } else { // Polygon is oriented clockwise when the origin is in the // center. currVertIndex = vertices.size() - (i + 1); nextVertIndex = mod(currVertIndex - 1, vertices.size()); } area += (static_cast<double>(vertices[currVertIndex].x) * static_cast<double>(vertices[nextVertIndex].y)) - (static_cast<double>(vertices[nextVertIndex].x) * static_cast<double>(vertices[currVertIndex].y)); } return fabs(area) / 2.0; } template <uint32_t numVertices> eastl::array<Line, numVertices> convertPolygonToLines(const Polygon<numVertices>& polygon) { // The polygon passed is assumed to contain the points in a consecutive // manner. eastl::array<Line, numVertices> lines; for (int32_t i = 0; i < numVertices; i++) { lines[i] = Line{polygon.vertices[i], polygon.vertices[(i + 1) % numVertices]}; } return lines; } template <uint32_t numVertices> NPolygon convertPolygonToNPolygon(const Polygon<numVertices>& polygon) { NPolygon nPolygon; for (auto& vertex : polygon.vertices) { nPolygon.vertices.push_back(vertex); } return nPolygon; } // Disallow weights that are non-float. template < template<class, class> class V, class T, class VAllocator, template<class, class> class W, class U, class WAllocator > const T& selectRandomItemWithWeights( const V<T, VAllocator>& items, const W<U, WAllocator>& weights) = delete; // We should not allow rvalues for the items parameter, because we're // returning a reference to an item there. template < template<class, class> class V, class T, class VAllocator, template<class, class> class W, class U, class WAllocator > const T& selectRandomItemWithWeights( const V<T, VAllocator>&& items, const W<U, WAllocator>& weights) = delete; template < template<class, class> class V, class T, class VAllocator, template<class, class> class W, class WAllocator > const T& selectRandomItemWithWeights(const V<T, VAllocator>& items, const W<float, WAllocator>& weights) { // Algorithm based on: // https://softwareengineering.stackexchange.com/a/150618/208923 float weightSum = std::accumulate(weights.begin(), weights.end(), 0); std::uniform_real_distribution nDistrib{ 0.f, weightSum }; float n = generateRandomReal(nDistrib); int32_t currIntervalVal = 0; int32_t selectedItemIndex = 0; for (int32_t i = 0; i < weights.size(); i++) { currIntervalVal += weights[i]; if (floatGreEqual(currIntervalVal, n)) { selectedItemIndex = i; break; } } return items[selectedItemIndex]; } template < template<class, class> class V, class T, class VAllocator > const T selectItemRandomly(const V<T, VAllocator>& items) { eastl::vector<float> weights(items.size(), 1.f); return selectRandomItemWithWeights(items, weights); } template <template<class, class> class W, class WAllocator> int32_t selectRandomWeightedIndex(const W<float, WAllocator>& weights) { // Algorithm based on: // https://softwareengineering.stackexchange.com/a/150618/208923 float weightSum = std::accumulate(weights.begin(), weights.end(), 0); std::uniform_real_distribution nDistrib{ 0.f, weightSum }; float n = generateRandomReal(nDistrib); int32_t currIntervalVal = 0; int32_t selectedItemIndex = 0; for (int32_t i = 0; i < weights.size(); i++) { currIntervalVal += weights[i]; if (floatGreEqual(currIntervalVal, n)) { selectedItemIndex = i; break; } } return selectedItemIndex; } template <class RealType> std::normal_distribution<RealType> multiplyDistributions( const std::normal_distribution<RealType>& distribA, const std::normal_distribution<RealType>& distribB) { double newMean = ( ((distribA.mean() * pow(distribB.stddev(), 2)) + ((distribB.mean() * pow(distribA.stddev(), 2)))) / (pow(distribB.stddev(), 2) + pow(distribA.stddev(), 2)) ); double newStdDev = sqrt( (pow(distribA.stddev(), 2) * pow(distribB.stddev(), 2)) / (pow(distribA.stddev(), 2) + pow(distribB.stddev(), 2)) ); return std::normal_distribution<RealType>{ newMean, newStdDev }; } } namespace cx { using namespace corex::core; } #endif
f6bcc7bf97a1cbf92159b02610d0a7897e60883f
385cfbb27ee3bcc219ec2ac60fa22c2aa92ed8a0
/ThirdParty/bullet-2.75/src/BulletMultiThreaded/SpuCollisionObjectWrapper.cpp
182aa26947828c73ffacc59d1435a6bd11451a15
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Zlib", "LicenseRef-scancode-unknown" ]
permissive
palestar/medusa
edbddf368979be774e99f74124b9c3bc7bebb2a8
7f8dc717425b5cac2315e304982993354f7cb27e
refs/heads/develop
2023-05-09T19:12:42.957288
2023-05-05T12:43:35
2023-05-05T12:43:35
59,434,337
35
18
MIT
2018-01-21T01:34:01
2016-05-22T21:05:17
C++
UTF-8
C++
false
false
1,683
cpp
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "SpuCollisionObjectWrapper.h" #include "BulletCollision/CollisionShapes/btCollisionShape.h" SpuCollisionObjectWrapper::SpuCollisionObjectWrapper () { } #ifndef __SPU__ SpuCollisionObjectWrapper::SpuCollisionObjectWrapper (const btCollisionObject* collisionObject) { m_shapeType = collisionObject->getCollisionShape()->getShapeType (); m_collisionObjectPtr = (ppu_address_t)collisionObject; m_margin = collisionObject->getCollisionShape()->getMargin (); } #endif int SpuCollisionObjectWrapper::getShapeType () const { return m_shapeType; } float SpuCollisionObjectWrapper::getCollisionMargin () const { return m_margin; } ppu_address_t SpuCollisionObjectWrapper::getCollisionObjectPtr () const { return m_collisionObjectPtr; }
0b5102e5b13bdb94125a4ee52b07e8c1da323f12
63c3f36d20d8f84ccb607f2dd10281b3eb73f54d
/PoissonDistribution2.cpp
92aaf8b4b0937ba753b30ed289de90f9f8bfec9d
[]
no_license
yodist/10-Days-of-Statistics
0718edd200ee07007cb0018c93bc84f637bbcd16
d86d953a90fddd4ce0314c716ff1a679cf14b6a2
refs/heads/master
2020-12-03T00:04:05.923477
2017-07-02T09:33:12
2017-07-02T09:33:12
95,982,514
1
0
null
null
null
null
UTF-8
C++
false
false
372
cpp
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ double x = 160 + (40 * (0.88 + pow(0.88,2))); double y = 128 + (40 * (1.55 + pow(1.55,2))); printf("%.3f\n",x); printf("%.3f",y); return 0; }
9ec587c5c3dbae3c499cb467165d92f9345ed00d
6e446327e7d7733583e48f66cbd624db08ee0b54
/day6/mainFunctions.cpp
0190880b8b9b2748c3eff7d59b742f4997854e02
[]
no_license
oghenez/100daysofcode
0f43d87b979d555ae59f3af6c73ae29d4c373930
15b2e05ee9c36b1768acb094e491156df061018b
refs/heads/master
2022-01-05T01:42:59.824066
2018-06-14T00:25:41
2018-06-14T00:25:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
632
cpp
#include <iostream> #include <string> #include <sstream> #include <fstream> using namespace std; void xPos(Gameboard board,int row, int column); void xPos(Gameboard board,int row, int column); string winner(Gameboard board); void xPos(Gameboard board,int row, int column) { board.setGameSpace('x',row,column); } void oPos(Gameboard board,int row, int column) { board.setGameSpace('o',row,column); } string winner(Gameboard board){ if(board.isWinner('x')==1){ return "X is the winner"; } else if(board.isWinner('o')==1){ return "O is the winner"; } else{ return "Tie"; } }
c71f90880ecd457c98afb401087053af1b401daa
75a285b8b540cafd0c4e12de6056ab5fa39012e3
/fashion.cpp
ecc120aa8326a7ee0a3123d2243637a5801c3b19
[]
no_license
mirgee/SPOJ
4e97d2aa5d879da54ff4ac5fc4104c0fcdd61c79
e039d1afb6ba05876edefcdd37ef9176eaf99bf3
refs/heads/master
2021-01-09T06:23:49.482320
2017-02-05T09:18:19
2017-02-05T09:18:19
80,980,000
0
0
null
null
null
null
UTF-8
C++
false
false
463
cpp
#include <iostream> #include <algorithm> using namespace std; int main() { int cases,N,sum; cin >> cases; while(cases--) { cin >> N; sum = 0; int* a = new int[N]; int* b = new int[N]; for(int i = 0; i < N; i++) { cin >> a[i]; } for(int i = 0; i < N; i++) { cin >> b[i]; } sort(a, a+N); sort(b, b+N); for(int i = 0; i < N; i++) { sum += (a[i])*(b[i]); } cout << sum << endl; delete[] a; delete[] b; } return 0; }
f5734ba35bc0ccfbef4d56159b8975eb1572ee35
bfc4032b3e1dbadec9291a42d092caadad180731
/MainWindow.h
397dad91b34bd1ef31b7c741a8cd5de64a79f4a9
[ "MIT" ]
permissive
namontec/HumanHashPassword
8506c1576fd0ca161fac5580be1f2c421cfe4d11
746b831fdff69156551bbeea645e280e7843cd5f
refs/heads/master
2021-07-01T19:05:24.964849
2020-09-01T18:06:59
2020-09-01T18:06:59
150,015,403
0
1
null
null
null
null
UTF-8
C++
false
false
683
h
#ifndef WIDGET_H #define WIDGET_H //#include <QWidget> #include <QtWidgets> #include "PasswordWidget.h" #include "PassGenerator.h" class MainWindow : public QWidget { Q_OBJECT public: MainWindow(QWidget *parent = 0); ~MainWindow(); void showWarning(const QString& warningMessage); public slots: void slotGenerate(); void slotGenerateCopy(); private: bool checkPhrase(); private slots: void slotAbout(); void slotAboutQt(); void slotClearAll(); void slotExit(); private: PasswordWidget* passMaster_; PasswordWidget* passConfirm_; PasswordWidget* qledWebSite_; PasswordWidget* editResult_; PassGenerator* passGenerator_; }; #endif // WIDGET_H
0137b45a311b9b418cd55538a672cbd085490110
27652a7c50b1bd06505e91f86cab60df20cd1fc2
/datacapture/passthrough.cpp
2828814dae38418e1d0c3083b7aa3ee975baa37f
[]
no_license
wjq20061111/pcltest
edc6d32a93c09601b87840ef19aacae3adb5e776
db793ca20ada7ccda3bf1947381cc4f980e7831f
refs/heads/master
2021-01-21T20:42:45.429676
2017-06-21T06:39:21
2017-06-21T06:39:21
92,269,837
0
0
null
2017-06-21T06:39:22
2017-05-24T08:38:31
Makefile
UTF-8
C++
false
false
1,646
cpp
#include <iostream> #include <pcl/point_types.h> #include <pcl/point_cloud.h> #include <pcl/filters/passthrough.h> #include <pcl/io/pcd_io.h> #include <pcl/visualization/pcl_visualizer.h> int main (int argc, char** argv) { typedef pcl::PointXYZ PointT; pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT>); pcl::PointCloud<PointT>::Ptr cloud_filtered (new pcl::PointCloud<PointT>); pcl::PCDReader reader; // pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT>), cloud_f (new pcl::PointCloud<PointT>); reader.read ("data_filted.pcd", *cloud); // Create the filtering object pcl::PassThrough<PointT> pass; pass.setInputCloud (cloud); pass.setFilterFieldName ("z"); pass.setFilterLimits (0.0, 1.5); //pass.setFilterLimitsNegative (true); pass.filter (*cloud_filtered); pcl::PCDWriter writer; writer.write<PointT> ("data_passfil.pcd", *cloud_filtered, false); // pcl::visualization::PCLVisualizer viewer ("Viewer"); // //pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> source_cloud_color_handler (source_cloud, 255, 255, 255); // //viewer.addPointCloud (source_cloud, source_cloud_color_handler, "original_cloud"); // viewer.addPointCloud (cloud_filtered, "original_cloud"); // viewer.addCoordinateSystem (1.0, "cloud", 0); // viewer.setBackgroundColor(0.05, 0.05, 0.05, 0); // Setting background to a dark grey // //viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "original_cloud"); // while (!viewer.wasStopped ()) { // Display the visualiser until 'q' key is pressed // viewer.spinOnce (); // } return (0); }
523292125dfdf2cc8e6908d25820f9df574a1950
7a1a247c07e206875ad84662fc38cf8a474a636b
/simulations_eh1/cmark_iccm/obj_dir/Vtb_top__Syms.cpp
d0506fe97d74f6f321db347a8cb8aead953a57e8
[ "MIT" ]
permissive
rawan305/Extending-SweRV-Core
95774d53097ec18a16afb2e150f152240554f5d5
88272e68f8e8acb6c0132ac1f43345152b901421
refs/heads/master
2023-01-19T19:20:29.651059
2020-11-15T15:13:22
2020-11-15T15:13:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
602
cpp
// Verilated -*- C++ -*- // DESCRIPTION: Verilator output: Symbol table implementation internals #include "Vtb_top__Syms.h" #include "Vtb_top.h" #include "Vtb_top___024unit.h" // FUNCTIONS Vtb_top__Syms::Vtb_top__Syms(Vtb_top* topp, const char* namep) // Setup locals : __Vm_namep(namep) , __Vm_activity(false) , __Vm_didInit(false) // Setup submodule names { // Pointer to top level TOPp = topp; // Setup each module's pointers to their submodules // Setup each module's pointer back to symbol table (for public functions) TOPp->__Vconfigure(this, true); }
96505ac211baa4847879b3bf988974b654e2fb95
b1cdd15e53d6cfa6f1bb3156c7f6c6cd8fba6b26
/client/P2P_client.cpp
14cc24ec281a55dc1cf8e593dfc12d17204b9ed2
[]
no_license
derickhaigh/cse514_lab1
b4f87f48018441c9d7a62e143dc6ba46977aee6b
83bacc965be2939828aa371ef85bc023f333cc43
refs/heads/main
2023-03-24T21:40:35.184830
2021-03-24T02:56:32
2021-03-24T02:56:32
349,866,790
0
0
null
null
null
null
UTF-8
C++
false
false
8,200
cpp
#include "P2P_client.h" //#define SERVER_IP "192.168.1.8" //#define SERVER_IP "104.39.105.56" //#define SERVER_IP "128.118.36.57" #define SERVER_HOSTNAME "Server1" #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/stat.h> #include <arpa/inet.h> #include <unistd.h> #include <string.h> #include <string> #include "../shared/P2P_shared.h" #include <dirent.h> // for reading direcories #include <iostream> #define PORT 8080 #define SERVER_HOSTNAME "Server1" #define BUFF_SIZE 1024 #define MAX_FILES 512 #define DEBUG true int main(int argc, char const *argv[]) { //Check if the arguements are included if(argc < 4){ fprintf(stderr,"Usage: %s server_hostname port {data_dir | file1,file2,file3,...}\n",argv[0]); exit(EXIT_FAILURE); } //Get the server hostname char server_host[100]; strcpy(server_host,argv[1]); //Get the destination port uint16_t port = atoi(argv[2]); //Get the field of files to register char* files=(char*) malloc(sizeof(char) * (strlen(argv[3])+1) ); strcpy(files,argv[3]); //Get host IP from the hostname char ip[100]; if(host_lookup(server_host,ip) < 0){ perror("Error in host lookup"); exit(EXIT_FAILURE); } int sock=0; struct sockaddr_in serv_addr; char local_hostname[BUFF_SIZE]; gethostname(local_hostname,BUFF_SIZE-1); if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("\n Socket creation error \n"); return -1; } serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(PORT); // Convert IPv4 and IPv6 addresses from text to binary form if(inet_pton(AF_INET, ip, &serv_addr.sin_addr)<=0) { printf("\nInvalid address/ Address not supported \n"); return -1; } if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { printf("\nConnection Failed \n"); return -1; } //Register available files send_reg_req(files, port, sock); free(files); //Begin the menu loop int choice; while(true){ choice=menu_prompt(); send_message(SERVER_HOSTNAME,PORT,"Test message", strlen("Test message"),sock); } return 0; } int menu_prompt(){ //This would eventually determine the next request being sent int choice = 0; while(choice < 1 || choice > 3){ printf("1) List Available Files\n2) Download File\n3) View Active Downloads\n"); scanf("%d",&choice); printf("\n\n"); } return choice; } int send_message(char* target_host, uint16_t port, char* message, uint32_t message_len, int sock){ int valread; char *hello = "Hello from client"; char buffer[BUFF_SIZE] = {0}; send(sock , message, message_len , 0 ); printf("Hello message sent\n"); valread = read( sock , buffer, 1024); printf("%s\n",buffer ); return 0; } void iterate_dir(DIR *p_dir, std::map<std::string,uint32_t> *file_registry, std::string root_dir){ struct dirent *p_dirent; //Iterate through the directory entries in the current directory while ((p_dirent = readdir(p_dir)) != NULL) { DIR *p_subdir; struct stat st; //Add a / to the directory path just in case if(root_dir.back() != '/'){ root_dir+='/'; } std::string full_path = root_dir+p_dirent->d_name; const char* dir = full_path.c_str(); std::cout<<full_path<<std::endl; if((p_subdir=opendir(dir)) != NULL){ //Don't repeat directories, trying to exclude '.' and '..' and hidden directories like .ssh //as it seems unlikely a user would want to share out their ssh keys if(p_dirent->d_name[0] != '.'){ //We have a directory, use a recursive function to add entries to function iterate_dir(p_subdir, file_registry, root_dir+p_dirent->d_name); closedir(p_subdir); } }else{ //We have a file, create an entry and hash it stat(dir,&st); file_registry->insert(std::pair<std::string,uint32_t>(p_dirent->d_name,st.st_size)); if(DEBUG){ printf("%s : %d \n",p_dirent->d_name,st.st_size); } } } } void send_reg_req(char* files, uint16_t port, int sock){ //Construct a register message //Determine if we have a directory or a list of files //If we can open it as a directory it is, otherwise if is //either a list of files or invalid struct dirent *p_dirent; DIR *p_dir; std::map<std::string,uint32_t> file_registry; if((p_dir=opendir(files)) != NULL){ //We have a directory, use a recursive function to add entries to function iterate_dir(p_dir,&file_registry,files); }else{ //We might have a list of files, iterate through , seperated list and try to get file name and lengths } closedir(p_dir); //Have the file registery, send the message std::cout<<sizeof(file_registry)<<std::endl; register_request reg_req; uint32_t ip; inet_pton(AF_INET,"127.0.0.1",&ip); //need to get actual IP //Create a buffer to hold message // message_type | requester_ip | requester_port | num_files | bitstream of <name length | filename(going to assume no filesnames larger than 50 bytes for now) | file size> // 1 Byte | 10 Bytes | 5 Bytes | 5 Bytes | <5 Bytes, num_files Bytes , 10 Bytes> uint32_t reg_buff_size = (21 + 60*file_registry.size()); void* reg_buff = malloc(reg_buff_size); void* curr_entry = reg_buff; //To get the buffer to work I'm going to convert values to strings and stor the strings //Set the message type in the first chunk of the buffer strncpy((char*)curr_entry,std::to_string(REGISTER).c_str(),1); curr_entry=&(((char *) curr_entry)[1]); //This seems convoluted and there might be a more elegant way to handle this, but I'm making a padded string and inserting the characters into the buffer //Set requester IP std::string ip_string= std::to_string(ip); ip_string = std::string(10-ip_string.size(),'0') + ip_string; std::cout<<ip_string<<std::endl; strncpy((char*)curr_entry,ip_string.c_str(),10); curr_entry=&(((char*) curr_entry)[10]); //Set requester port std::string port_string= std::to_string(port); port_string = std::string(5-port_string.size(),'0') + port_string; std::cout<<port_string<<std::endl; strncpy((char*)curr_entry,port_string.c_str(),5); curr_entry=&(((char*) curr_entry)[5]); //Set number of files std::string num_files_string= std::to_string(file_registry.size()); num_files_string = std::string(5-num_files_string.size(),'0') + num_files_string; std::cout<<num_files_string<<std::endl; strncpy((char*)curr_entry,num_files_string.c_str(),5); curr_entry=&(((char*) curr_entry)[5]); //Start placing the file name/size pairs std::map<std::string,uint32_t>::iterator itr; for(itr = file_registry.begin(); itr != file_registry.end(); itr++){ std::cout<<itr->first<<": "<<itr->second<<std::endl; //Enter size of string uint8_t str_size = itr->first.size(); std::string size_string= std::to_string(str_size); size_string = std::string(5-size_string.size(),'0') + size_string; strncpy((char*)curr_entry,size_string.c_str(),5); curr_entry=&(((char*) curr_entry)[5]); //Cpy str_size chars into buffer //const char* src_str =(char *)&itr->first; strncpy(((char*) curr_entry),itr->first.c_str(),str_size); curr_entry=&(((char*) curr_entry)[str_size]); std::string file_count_string= std::to_string(itr->second); file_count_string = std::string(10-file_count_string.size(),'0') + file_count_string; strncpy((char*)curr_entry,file_count_string.c_str(),10); curr_entry=&(((char*) curr_entry)[5]); } send_message("Server1",8080,(char*)reg_buff, reg_buff_size, sock); }
ad7b34a43cd08c9e4d76a4e1cc394348401b2dde
76ec38eca8790a949523bb16391d6b23601145f1
/Weekly102/FruitIntoBaskets.cpp
ed87be4ed78c35e6d5c278935e0f41ce0b29701d
[]
no_license
tfliao/leetcode
67b7fe5dc515ec310e4230501dc888415a6ca416
fd76561bbb3d887e37bf893d4409d70a0410bc3e
refs/heads/master
2021-05-26T05:22:13.657779
2019-07-07T02:53:53
2019-07-07T04:21:59
127,583,999
1
0
null
null
null
null
UTF-8
C++
false
false
1,017
cpp
class Solution { public: int totalFruit(vector<int>& tree) { map<int, int> last; int first[2] = {0, 0}; int b[2] = {-1, -1}; int best = 0; last[-1] = 0; for (int i=0;i<tree.size();++i) { if (b[0] == tree[i] || b[1] == tree[i]) { // do nothing } else if (b[0] == -1 || last[b[0]] < last[b[1]]) { if (first[1] < last[b[0]]) { first[1] = last[b[0]] + 1; } b[0] = tree[i]; first[0] = i; } else { // if (b[1] == -1 || last[b[1]] <= last[b[0]]) { if (first[0] < last[b[1]]) { first[0] = last[b[1]] + 1; } b[1] = tree[i]; first[1] = i; } last[tree[i]] = i; int len = i - min(first[0], first[1]) + 1; if (len > best) { best = len; } } return best; } };
31c723aabbc3d6c3596277928001e0590a4d8418
2f685bd4e098ff140f470d30eb7772323eff42ae
/CITMS-VTS2010/useragent/generaldef.h
405f3e39734043c8cd4d3de079df82a23b17c34e
[]
no_license
github188/DeviceTelecast
194d6b1486263c1f34d8386747dba63bcc13f6ec
9b6b53ca0728d29136ac2851b944cc60f0d66816
refs/heads/master
2020-04-11T01:28:04.451465
2017-11-24T06:22:29
2017-11-24T06:22:29
null
0
0
null
null
null
null
GB18030
C++
false
false
4,462
h
// ********************************************************************** // 作者: 傅佑铭 // 版本: 1.0 // 日期: 2009-01 ~ 2009-03 // 修改历史记录: // 日期, 作者, 变更内容 // ********************************************************************** #ifndef _GENERAL_DEF_H_ #define _GENERAL_DEF_H_ //当编译器为VC且版本不低于VC6.0时,本文件在编译时只被包含一次 #if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "stdafx.h" #ifdef _DEBUG //#include "..\\utility\\VLD1.9H\\vld.h" #endif #include <string> #include <vector> #include <deque> #include <list> #include <map> #include <set> //#ifndef PERFORMANCE_ANALYSIS //#define PERFORMANCE_ANALYSIS //#endif #ifndef _SENDING_DATA_BLOCK_SIZE_ #define _SENDING_DATA_BLOCK_SIZE_ 1400 #endif //#define PUSH_VIDEO_FILE //#define VIDEO_FILE "hk.264" #define VIDEO_FRAME_INTERVAL 80 namespace ScheduleServer { //参数上下文类型定义 typedef std::map<std::string, std::string> SS_CTX; //设备类型定义 typedef enum { SIPStack = 0, //SIP Server Unknown //未知 }Device_Type; typedef struct tagTIME_INFO { unsigned long year; //[1900,--] unsigned long month; //[1, 12] unsigned long day; //[1, 31] unsigned long hour; //[0, 23] unsigned long minute; //[0, 59] unsigned long second; //[0, 59] tagTIME_INFO() : year(0), month(0), day(0), hour(0), minute(0), second(0) { } } TIME_INFO; //返回值类型定义 typedef enum { SS_NoErr = 0, //函数调用成功 //服务器启动 SS_ServerStartFail, //服务器启动失败 //数据库代理 SS_InvalidDBConnection, //数据库连接失效 SS_UserNameOrPasswdError, //用户名或密码错误 SS_ExecFail, //执行SQL语句失败 SS_QueryFail, //查询记录失败 //通信模块 SS_CreateServerFail, //创建通讯器服务侧失败 SS_InvalidClientConnection, //客户端侧链接不可用 SS_SendSyncSignalFail, //客户端侧发送同步信令失败 SS_SendAsyncSignalFail, //客户端侧发送异步信令失败 SS_SendSyncDataFail, //客户端侧发送同步数据失败 SS_SendAsyncDataFail, //客户端侧发送异步数据失败 //设备接入插件模块加载 SS_LoadDeviceAccessModuleFail, //加载失败 SS_UnloadDeviceAccessModuleFail, //卸载失败 //获取设备接入插件模块指针 SS_GetDeviceAccessModuleFail, //获取设备接入插件指针失败 //UA操作 SS_InsertUAFail, //插入UA失败 SS_InsertMediaDataFail, //插入媒体数据到队列失败 //SIPStack接入 SS_ConnectSIPStackFail, //连接SIPStack失败 SS_DisconnectSIPStackFail, //断开SIPStack失败 //硬件设备巡检 SS_DeviceInspectionFail, //硬件设备巡检失败 //系统会议线程 SS_StartConferenceThreadFail, //启动会议线程失败 //任务线程 SS_StartTaskThreadFail, //启动任务线程失败 SS_AddTaskFail, //添加任务失败 //任务队列 SS_InvalidTask, //错误任务 //查询任务执行结果 SS_QueryTaskResultFail, //查询任务执行结果失败 //更新任务 SS_SyncTaskFail, //更新任务失败 //事件数据操作 SS_FetchUserAgentFail, //获取事件数据失败 //RTP传输 SS_RTPSendSessionUnAvailable, //RTP发送Session不可用 SS_RTPRecvSessionUnAvailable, //RTP接收Session不可用 SS_AddRTPHeaderFail, //添加RTP包头失败 SS_SendPacketFail, //发送RTP包失败 //会议控制 SS_ConferenceControlFail, //会议控制失败 SS_UnknownParticipant, //未知的与会人 SS_ParticipantsExisted, //重复添加与会人员 //SIP消息 SS_ErrorSIPMessage, //错误的SIP消息 //虚拟UA SS_StartVirtualUAThreadFail, //启动虚拟UA线程失败 SS_Unknown_Error //未知错误 }SS_Error; /*typedef struct { SS_Error ret_code; std::string message; }SS_Error_Info; const std::string DEFAULT_SS_ERROR_MESSAGE = "未知错误"; const SS_Error_Info global_ds_error_info_list[] = { {SS_NoErr, "调用成功"}, {SS_InvalidDBConnection, "用户名或密码错误"}, {SS_ExecFail, "执行SQL语句失败"}, {SS_QueryFail, "查询记录失败"}, {SS_Unknown_Error, "未知错误"} };*/ } #endif // _GENERAL_DEF_H_
c04a0dae87fc12a7dff751a962ced2bff412b903
95cba4a9c0d7a4ed37b7db58f9f9deffc6f2489e
/libcomm/WebServer.h
36a3ab59049d8945ba236f2a81ed95955fa77aed
[ "Apache-2.0" ]
permissive
avp-avp/libs
036eea19c008c243047fd0796571897d4513007e
6714ab8ce933146a415c52c264765c00e39efc8b
refs/heads/master
2023-07-20T04:54:48.487159
2023-07-15T14:09:20
2023-07-15T14:09:20
61,615,332
2
1
Apache-2.0
2018-08-20T19:31:19
2016-06-21T08:14:06
C++
UTF-8
C++
false
false
1,295
h
#pragma once #include "SupervisorClient.h" #include "IPListener.h" #include "../libutils/strutils.h" typedef map<CConnection*, string> CConnectionData; #define HTTP_REQUEST_BUFFER_SIZE 4096 class LIBCOMM_API CWebServer : public CSupervisorClient { CIPListener *m_Listener; CConnectionData m_ConnectionData; bool m_OwnSupervisor; protected: CLog* m_webServerLog; CSupervisor* m_Supervisor; public: CWebServer(); ~CWebServer(); string urlDecode(string &SRC); bool ParseHttpRequest(const string &Request, string &method, string &path, string_map &header, string_map &get_params, string_map &post_params); inline bool ParseHttpRequest(const char *request, string &method, string &path, string_map &header, string_map &get_params, string_map &post_params) { string Request = request; return ParseHttpRequest(Request, method, path, header, get_params, post_params); } virtual void OnRecieve(CConnection* Conn); virtual void OnDeleteConnection(CConnection* Conn); virtual void OnRequest(CConnection* Conn, string method, string url, string_map &params); void SetLog(CLog *log) { m_webServerLog = log; }; void SetSupervisor(CSupervisor *supervisor); void Listen(int Port, string Host=""); void SendReply(CConnection* conn, string reply, bool closeConnection = true); };
337e79a1cc79c0f0ce73319b4f5171505ed0fb67
88c73364efda285c1bfb2aded697d12d9ba74405
/include/etl/impl/cudnn/cudnn.hpp
15b287069f4afb8ddec04a1a029fdcbd0b1c7fc4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
bssrdf/etl
7269a299dc7dd157ce2c7a09e6229b9b6805aa99
4471a420d9ccaba337717836e078c1827bacdf0b
refs/heads/master
2021-01-20T14:59:35.534680
2017-05-08T20:29:41
2017-05-08T20:29:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,763
hpp
//======================================================================= // Copyright (c) 2014-2017 Baptiste Wicht // Distributed under the terms of the MIT License. // (See accompanying file LICENSE or copy at // http://opensource.org/licenses/MIT) //======================================================================= /*! * \file * \brief Utility functions for cudnn */ #pragma once #include "cudnn.h" #define cudnn_check(call) \ { \ cudnnStatus_t status = call; \ if (status != CUDNN_STATUS_SUCCESS) { \ std::cerr << "CUDNN error: " << cudnnGetErrorString(status) << " from " << #call << std::endl \ << "from " << __FILE__ << ":" << __LINE__ << std::endl; \ } \ } namespace etl { namespace impl { namespace cudnn { /*! * \brief RTTI helper to manage CUDNN handle */ struct cudnn_handle { cudnnHandle_t handle; ///< The raw cudnn handle /*! * \brief Construct the helper and create the handle directly */ cudnn_handle(){ cudnn_check(cudnnCreate(&handle)); } /*! * \brief Construct the helper from the raw handle * \param handle The raw cudnn handle */ explicit cudnn_handle(cudnnHandle_t handle) : handle(handle) {} cudnn_handle(const cudnn_handle& rhs) = delete; cudnn_handle& operator=(const cudnn_handle& rhs) = delete; cudnn_handle(cudnn_handle&& rhs) noexcept = default; cudnn_handle& operator=(cudnn_handle&& rhs) noexcept = default; /*! * \brief Get the cudnn handle * \return the raw cudnn handle */ cudnnHandle_t get() { return handle; } /*! * \brief Destruct the helper and release the raw cudnn handle */ ~cudnn_handle() { cudnn_check(cudnnDestroy(handle)); } }; #ifndef ETL_CUDNN_LOCAL_HANDLE /*! * \brief Start cudnn and return a RTTI helper over a raw cudnn handle * \return RTTI helper over a raw cudnn handle */ inline cudnn_handle& start_cudnn() { static cudnn_handle handle; return handle; } #else /*! * \brief Start cudnn and return a RTTI helper over a raw cudnn handle * \return RTTI helper over a raw cudnn handle */ inline cudnn_handle start_cudnn() { return {}; } #endif } //end of namespace cudnn } //end of namespace impl } //end of namespace etl
9f6e6fd49a0192708c013995b3db4db2ea0791fa
8c1953056a1a606285d41f46f4cc97f77012cdf8
/browser/branding/shared/pref/uaoverrides.inc
0a068cae51483e90bcbe1e8ceda49e53c613e2c7
[]
no_license
Patclash/palemoon27
26b29ac9b2d7fab01ccfdba8a2ecd7dda240bf6e
0a2ee1ef299e324292d79dbeebb924c815ca81b1
refs/heads/master
2020-06-16T07:49:55.941630
2019-07-05T15:17:35
2019-07-05T15:17:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,218
inc
// ===| Site Specific User Agent Overrides |=================================== #define GUAO_PREF general.useragent.override #define GRE_VERSION @MOZILLA_UAVERSION_U@ #define GRE_VERSION_SLICE Goanna/@GRE_VERSION@ #define GRE_DATE_SLICE Goanna/20170101 #define PM_SLICE PaleMoon/@MOZ_APP_VERSION@ #define GK_VERSION @MOZILLA_COMPATVERSION_U@ #define GK_SLICE Gecko/20100101 #define FX_SLICE Firefox/@GK_VERSION@ #ifdef XP_UNIX #ifndef XP_MACOSX #define OS_SLICE X11; Linux x86_64; #else #define OS_SLICE Macintosh; Intel Mac OS X 10.11; #endif #else #define OS_SLICE Windows NT 6.1; WOW64; #endif // Required for domains that have proven unresponsive to requests from users pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:52.9) @GK_SLICE@ @GRE_VERSION_SLICE@ Firefox/52.9 @PM_SLICE@"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:38.9) @GK_SLICE@ @GRE_VERSION_SLICE@ Firefox/38.9 @PM_SLICE@"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:31.9) @GK_SLICE@ @GRE_VERSION_SLICE@ Firefox/31.9 @PM_SLICE@"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:99.9) @GK_SLICE@ Firefox/99.9 (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:42.0) @GK_SLICE@ Firefox/42.0 @PM_SLICE@"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:42.0) @GK_SLICE@ Firefox/42.0"); pref("@[email protected]","Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"); pref("@[email protected]","Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"); // The never-ending Facebook debacle... pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:99.9) @GK_SLICE@ Firefox/99.9 (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:99.9) @GK_SLICE@ Firefox/99.9 (Pale Moon)"); #ifdef XP_UNIX // Google Fonts forces unicode ranges unless it is being told the browser is Firefox 43 or below. // They do NOT test for unicode-ranges CSS support. pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:43.0) @GK_SLICE@ Firefox/43.0"); #endif // UA-Sniffing domains below are pending responses from their operators - temp workaround pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@"); // For Amazon Prime videos pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ Firefox/45.9 (Pale Moon)"); // Soundcloud uses Firefox-exclusive combinations of code. Never pass Firefox slice. pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); // Daily motion only likes strict Firefox UAs pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:52.0) @GK_SLICE@ Firefox/52.0"); // The following requires native mode. Or it blocks.. "too old firefox", breakage, etc. pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); // UA-Sniffing domains below have indicated no interest in supporting Pale Moon (BOO!) pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:48.0) @GK_SLICE@ Firefox/48.0"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:48.0) @GK_SLICE@ Firefox/48.0"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:38.0) @GK_SLICE@ Firefox/38.0"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:57.0) @GK_SLICE@ Firefox/57.0 (Pale Moon)"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ Firefox/45.9"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ Firefox/45.9"); // UA-sniffing domains that are "app/vendor-specific" and do not like Pale Moon pref("@[email protected]","Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36"); // The following domains do not like the Goanna slice pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@"); pref("@[email protected]","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ @PM_SLICE@"); // ============================================================================
9e81265eb6c54ac41ddbc16c7169bcf944e29510
3b235bd08041d7d84f2fd85b6aea5255783f56b2
/src/HHTT_TMVACycle_SicherungvorOstern.cxx
ec37456d645da3fab8bf62480396dc90cb0c0c6d
[]
no_license
UHHAnalysis/HOTVR_WZH
71bf78be97cea647eb3078b6a9b8e0ab67d3053c
948b160e88c0e96f5b5911cf2e918857ad00d68a
refs/heads/master
2021-01-01T04:45:29.744813
2016-05-19T11:53:43
2016-05-19T11:53:43
58,554,223
0
0
null
null
null
null
UTF-8
C++
false
false
5,946
cxx
// // $Id: TopTagTMVACycle.cxx,v 1.1 2013/05/21 14:40:03 rkogler Exp $ // #include <iostream> // using namespace std; // // Local include(s): // #include "include/HHTT_TMVACycle.h" // #include "include/TMVATreeFiller_hhtt.h" // #include "include/TMVATreeFiller_hhtt_gen.h" // #include "include/TMVATreeFiller_cms.h" // #include "include/TMVATreeFiller_cms_gen.h" // #include "include/TMVATreeFiller_optimalR.h" // #include "include/TMVATreeFiller_optimalR_gen.h" // #include "include/SelectionModules.h" // #include "include/HypothesisHists.h" // #include "include/RocHists.h" // ClassImp( HHTT_TMVACycle ); // HHTT_TMVACycle::HHTT_TMVACycle() // : AnalysisCycle() { // // constructor, declare additional variables that should be // // obtained from the steering-xml file // // set the integrated luminosity per bin for the lumi-yield control plots // SetIntLumiPerBin(250.); // } // HHTT_TMVACycle::~HHTT_TMVACycle() // { // // destructor // } // void HHTT_TMVACycle::BeginCycle() throw( SError ) // { // // Start of the job, general set-up and definition of // // objects are done here // // Important: first call BeginCycle of base class // AnalysisCycle::BeginCycle(); // return; // } // void HHTT_TMVACycle::EndCycle() throw( SError ) // { // // clean-up, info messages and final calculations after the analysis // // call the base cycle class for all standard methods // AnalysisCycle::EndCycle(); // return; // } // void HHTT_TMVACycle::BeginInputData( const SInputData& id ) throw( SError ) // { // // declaration of histograms and selections // // Important: first call BeginInputData of base class // AnalysisCycle::BeginInputData( id ); // // create one selection: select CA-jets // /* Selection* CAJetSel = new Selection("CAJetSelection"); // CAJetSel->addSelectionModule(new NTopJetSelection(1,int_infinity(),200,2.5)); // RegisterSelection(CAJetSel); // */ // // this class fills the tree for the TMVA analysis // /* // int rho[3] = {190, 200, 210}; // for(int i = 0; i < 3; i++) // { // string s_rho = std::to_string(rho[i]); // double theta[3] = {0.5, 0.6, 0.7}; // for(int j = 0; j < 3; j++) // { // string s_theta = std::to_string(theta[j]); // int mu[3] = {15, 20, 25}; // for(int k = 0; k < 3; k++) // { // string s_mu = std::to_string(mu[k]); // string s_name = "WTagTree" + s_rho + s_theta + s_mu; // const char* c_name = s_name.c_str(); // TTree* wtagtree = GetOutputMetadataTree(c_name); // //RegisterHistCollection( new TMVATreeFiller_hhtt_gen("WTagFiller_gen", wtagtree, rho[i], theta[j], mu[k]) ); // RegisterHistCollection( new TMVATreeFiller_hhtt_gen(c_name, wtagtree, rho[i], theta[j], mu[k]) ); // InitHistos(); // return; // } // } // } // */ // //Funktioniert fuer zwei Trees!!!!: // int rho = 200; // double theta = 0.6; // int mu = 15; // TTree * wtagtree = GetOutputMetadataTree("WTagTree"); // RegisterHistCollection( new TMVATreeFiller_hhtt_gen("WTagFiller_gen", wtagtree, rho, theta, mu) ); // InitHistos(); // rho = 190; // theta = 0.5; // mu = 15; // TTree * wtagtree2 = GetOutputMetadataTree("WTagTree_rho190_theta05_mu15"); // RegisterHistCollection( new TMVATreeFiller_hhtt_gen("WTagFiller_gen2", wtagtree2, rho, theta, mu) ); // InitHistos(); // return; // } // void HHTT_TMVACycle::EndInputData( const SInputData& id ) throw( SError ) // { // AnalysisCycle::EndInputData( id ); // return; // } // void HHTT_TMVACycle::BeginInputFile( const SInputData& id ) throw( SError ) // { // // Connect all variables from the Ntuple file with the ones needed for the analysis // // The variables are commonly stored in the BaseCycleContaincer // // important: call to base function to connect all variables to Ntuples from the input tree // AnalysisCycle::BeginInputFile( id ); // return; // } // void HHTT_TMVACycle::ExecuteEvent( const SInputData& id, Double_t weight) throw( SError ) // { // // this is the most important part: here the full analysis happens // // user should implement selections, filling of histograms and results // // first step: call Execute event of base class to perform basic consistency checks // // also, the good-run selection is performed there and the calculator is reset // AnalysisCycle::ExecuteEvent( id, weight ); // //static Selection* CAJetSel = GetSelection("CAJetSelection"); // // BaseHists* TreeFiller = GetHistCollection("TopTagFiller"); // //Funktioniert fuer zwei Trees!!!!: // int rho = 200; // double theta = 0.6; // int mu = 15; // BaseHists* TreeFiller_gen = GetHistCollection("WTagFiller_gen"); // ((RocHists*)TreeFiller_gen)->SetIdVersion(id.GetVersion()); // TreeFiller_gen->Fill(); // rho = 190; // theta = 0.5; // mu = 15; // BaseHists* TreeFiller_gen2 = GetHistCollection("WTagFiller_gen2"); // ((RocHists*)TreeFiller_gen2)->SetIdVersion(id.GetVersion()); // TreeFiller_gen2->Fill(); // return; // /* // int rho[3] = {190, 200, 210}; // for(int i = 0; i < 3; i++) // { // string s_rho = std::to_string(rho[i]); // double theta[3] = {0.5, 0.6, 0.7}; // for(int j = 0; j < 3; j++) // { // string s_theta = std::to_string(theta[j]); // int mu[3] = {15, 20, 25}; // for(int k = 0; k < 3; k++) // { // string s_mu = std::to_string(mu[k]); // string s_name = "WTagTree" + s_rho + s_theta + s_mu; // const char* c_name = s_name.c_str(); // //BaseHists* TreeFiller_gen = GetHistCollection("WTagFiller_gen"); // BaseHists* TreeFiller_gen = GetHistCollection(c_name); // ((RocHists*)TreeFiller_gen)->SetIdVersion(id.GetVersion()); // TreeFiller_gen->Fill(); // return; // } // } // } // */ // }
57eeee806b37ec15880e15eac001456ccffe35ea
010aa4175ee4f08b73baf60d1546bd101edf97ce
/LibDomoticPi/include/MqttAwning.h
bc165ceeef8b482f8e1cc45f686c1dc8665e1d0f
[]
no_license
Ansaya/DomoticPi
5e5ffabde718722642e525afc2ed6b0d42cea0ac
77fae3bcf4dab8b1d0793ebdb6250ebdecb0a64e
refs/heads/master
2020-03-15T08:38:48.830037
2018-11-04T07:54:54
2018-11-04T07:54:54
132,056,010
1
0
null
null
null
null
UTF-8
C++
false
false
1,555
h
#ifndef DOMOTIC_PI_MQTT_AWNING #define DOMOTIC_PI_MQTT_AWNING #include "IOutput.h" #include "MqttComm.h" #include "MqttSubscription.h" #include "OutputFactory.h" #include <mosquitto.h> #include <string> namespace domotic_pi { class MqttAwning : public IOutput, protected OutputFactory { public: /** * @brief Initialize a new mqtt awning * * @param id unique identifier for this module * @param mqttTopic device topic to be used as suffix after cmnd/ and stat/ * @param mqttComm mqtt comm interface to use for the output */ MqttAwning( const std::string& id, const std::string& mqttTopic, std::shared_ptr<MqttComm> mqttComm); MqttAwning(const MqttAwning&) = delete; MqttAwning& operator= (const MqttAwning&) = delete; ~MqttAwning(); void setState(OutState newState) override; void setValue(int newValue) override; rapidjson::Document to_json() const override; private: std::shared_ptr<MqttComm> _mqttComm; const std::string _cmndTopic; const std::string _statTopic; uint8_t _direction; uint8_t _targetValue; MqttSubscription * _statSubscription; #ifdef DOMOTIC_PI_APPLE_HOMEKIT hap::IntCharacteristics_ptr _currentPosition; hap::IntCharacteristics_ptr _targetPosition; hap::IntCharacteristics_ptr _positionState; #endif void _stat_message_cb(const struct mosquitto_message * message); static const bool _factoryRegistration; static std::shared_ptr<MqttAwning> from_json(const rapidjson::Value& config, DomoticNode_ptr parentNode); }; } #endif // !DOMOTIC_PI_MQTT_AWNING
e7900fad103579f04f0d08f173174bb4a9d47977
c1d4b3313aa6e48bebfeb4e3cfb7b5eeb54ced86
/windows/cpp/samples/read_metadata_any_file/main.cpp
fa612dfd09b346e8f9cb51afa8ba219e0d95ec20
[ "MIT" ]
permissive
avblocks/avblocks-samples
447a15eed12d4ac03c929bc7b368fe37fadc0762
7388111a27c8110a9f7222e86e912fe38f444543
refs/heads/main
2021-06-04T13:41:30.387450
2021-02-01T00:28:09
2021-02-01T00:28:09
334,783,633
1
1
null
null
null
null
UTF-8
C++
false
false
3,773
cpp
/* * Copyright (c) 2013 Primo Software. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. */ #include "stdafx.h" #include "AvbUtil.h" #include "util.h" #include "options.h" using namespace primo::codecs; using namespace primo::avblocks; using namespace primo; using namespace std; void savePicture(primo::codecs::MetaPicture* pic, const wstring& baseFilename) { wstring filename(baseFilename); if (0 == strcmp( pic->mimeType(), primo::codecs::MimeType::Jpeg)) { filename += L".jpg"; } else if (0 == strcmp( pic->mimeType(), primo::codecs::MimeType::Png)) { filename += L".png"; } else if (0 == strcmp( pic->mimeType(), primo::codecs::MimeType::Gif)) { filename += L".gif"; } else if (0 == strcmp( pic->mimeType(), primo::codecs::MimeType::Tiff)) { filename += L".tiff"; } else { // unexpected picture mime type return; } ofstream out(filename.c_str(), ios::out | ios::binary | ios::trunc); if (out) { out.write((const char*)pic->data(), pic->dataSize()); } } void savePictures(primo::codecs::Metadata* meta, const wchar_t* inputFile) { if (!meta || meta->pictures()->count() == 0) return; wstring baseFilename(inputFile); baseFilename += L".pic"; MetaPictureList* piclist = meta->pictures(); for (int i=0; i < piclist->count(); ++i) { wostringstream picname; picname << baseFilename << (i+1); savePicture(piclist->at(i), picname.str()); } } void printMetaAttributes(Metadata* meta) { stdout_utf16 mode; wcout << L"Metadata\r\n--------" << endl; MetaAttributeList* attlist = meta->attributes(); wcout << attlist->count() << L" attributes:" << endl; for (int i=0; i < attlist->count(); ++i) { MetaAttribute* attrib = attlist->at(i); wcout << setw(15) << left << attrib->name() << L": " << attrib->value() << endl; } wcout << endl; MetaPictureList* piclist = meta->pictures(); wcout << piclist->count() << L" pictures:" << endl; for (int i=0; i < piclist->count(); ++i) { MetaPicture* pic = piclist->at(i); wcout << L"#" << (i+1) << L" mime: " << pic->mimeType() << L"; size: " << pic->dataSize(); wcout << L"; type: " << getMetaPictureTypeName(pic->pictureType()) << endl; wcout << L"description: " << pic->description() << endl; } wcout << endl; } void printMetadata(MediaInfo* info, const wchar_t* inputFile) { Metadata* meta = NULL; if(info->outputs()->count() > 0) meta = info->outputs()->at(0)->metadata(); if (!meta) { wcout << L"Could not find any metadata." << endl; return; } printMetaAttributes(meta); savePictures(meta, inputFile); } void printError(const primo::error::ErrorInfo* e) { if (primo::error::ErrorFacility::Success == e->facility()) { wcout << L"Success"; } else { if (e->message()) { wcout << e->message() << L", "; } wcout << L"facility:" << e->facility() << L", error:" << e->code(); } wcout << endl; } bool metaInfo(Options& opt) { auto info = primo::make_ref(Library::createMediaInfo()); info->inputs()->at(0)->setFile(opt.avfile.c_str()); if(info->open()) { printMetadata(info.get(), opt.avfile.c_str()); return true; } else { printError(info->error()); return false; } } int wmain(int argc, wchar_t* argv[]) { Options opt; switch(prepareOptions( opt, argc, argv)) { case Command: return 0; case Error: return 1; } Library::initialize(); //Library::setLicense("<license-string>"); bool metaInfoResult = metaInfo(opt); Library::shutdown(); return metaInfoResult ? 0 : 1; }
260e5cdf773dea4931bd9c16ada9154c588eebcd
f36aa3b81bb4c6ad6f985caa59f9546c1396237d
/ring_lib/main.cpp
95ad7696c1078ebc3eaafa4f2e9918586359cb67
[]
no_license
xiaolong1305/ring_test
c6acda99e636d87d08e3edd7af57e93a0728d2c7
5859821408719f164089c66cdc4532811ce3ce84
refs/heads/master
2020-03-28T22:31:22.586187
2018-09-18T06:26:08
2018-09-18T06:26:08
149,239,240
0
0
null
null
null
null
GB18030
C++
false
false
1,829
cpp
#include <cstdio> #include "ring_lib.h" #include "stdlib.h" #include <string.h> #define RINGSIZE 10 uint32_t key[] = { 0x2b7e1516, 0x28aed2a6, 0xabf71588, 0x09cf4f3c }; uint32_t IV[] = { 0x2b7e1516, 0x28aed2a6, 0xabf71588, 0x09cf4f3c }; int main() { icp_qat_fw_la_bulk_req_t msg; icp_qat_fw_la_bulk_req_t *memory_tx; uint8_t *memory_rx; uint32_t off_temp_tx; uint32_t off_temp_rx; int i; uint8_t msg_id; //初始化tx memory memory_tx = (icp_qat_fw_la_bulk_req_t *)malloc(RINGSIZE * MSG_SIZE); memory_rx = (uint8_t *)malloc(RINGSIZE *MSG_RES_SIZE); //配置ring的大小,基地址等信息到bar空间 // 设置base_addrees 和 size initTxRing((uint8_t *)memory_tx, RINGSIZE); initRxRing((uint8_t *)memory_rx, RINGSIZE); memset(memory_rx,0x7f, RINGSIZE *MSG_RES_SIZE); msg_id = 0x00; //msg.comn_mid.src_data_addr while (1) { //init msg initDefaultMsg(&msg, msg_id); off_temp_tx = addMsgToTxRing(&msg); setIV(&msg,IV,sizeof(IV)); setKey(&msg, key, sizeof(key)); //addMsgToTxRing((icp_qat_fw_la_bulk_req_t *)(&0x11)); if (off_temp_tx != 0x1111) { printf("set TX offset 0x%x,msg id is 0x%x\n", off_temp_tx, msg_id); msg_id++; if (msg_id % 2 == 0) { printf("is odd\n"); msg.comn_mid.src_data_addr = 0x80002000; } else { printf("is even\n"); msg.comn_mid.src_data_addr = 0x90002000; } } else { printf("ring is full\n"); } // receive response msg off_temp_rx = getRxRingOff(); // simulate rec msg memset(memory_rx+ off_temp_rx,0x00, MSG_RES_SIZE); // read rx msg off_temp_rx = getMsgFromRxRing(); if (off_temp_rx != 0x1111) { printf("set RX offset 0x%x\n", off_temp_rx); } else { printf("no response receive\n"); } } free(memory_tx); free(memory_rx); //printf("hello from ring_lib!\n"); return 0; }
0089cf6b9e52f5e7f9f793fe8c3906072726e615
c32ee8ade268240a8064e9b8efdbebfbaa46ddfa
/Libraries/m2sdk/C_WrapE_ScriptHintColor.h
251a789d81be5d403771709c7aecd9b8453bab01
[]
no_license
hopk1nz/maf2mp
6f65bd4f8114fdeb42f9407a4d158ad97f8d1789
814cab57dc713d9ff791dfb2a2abeb6af0e2f5a8
refs/heads/master
2021-03-12T23:56:24.336057
2015-08-22T13:53:10
2015-08-22T13:53:10
41,209,355
19
21
null
2015-08-31T05:28:13
2015-08-22T13:56:04
C++
UTF-8
C++
false
false
395
h
// auto-generated file (rttidump-exporter by h0pk1nz) #pragma once #include <ue/sys/lua/C_EnumWrapper.h> /** C_WrapE_ScriptHintColor (VTable=0x01E707E8) */ class C_WrapE_ScriptHintColor : public ue::sys::lua::C_EnumWrapper { public: virtual void vfn_0001_86595CD0() = 0; virtual void vfn_0002_86595CD0() = 0; virtual void vfn_0003_86595CD0() = 0; virtual void vfn_0004_86595CD0() = 0; };
11d3c769d421130e154df5cadb1169c9f081d5c4
24f26275ffcd9324998d7570ea9fda82578eeb9e
/chrome/browser/ui/webui/explore_sites_internals/explore_sites_internals_ui.h
87fa86d06ecfb5e7a51275925c32abde0b41432b
[ "BSD-3-Clause" ]
permissive
Vizionnation/chromenohistory
70a51193c8538d7b995000a1b2a654e70603040f
146feeb85985a6835f4b8826ad67be9195455402
refs/heads/master
2022-12-15T07:02:54.461083
2019-10-25T15:07:06
2019-10-25T15:07:06
217,557,501
2
1
BSD-3-Clause
2022-11-19T06:53:07
2019-10-25T14:58:54
null
UTF-8
C++
false
false
1,527
h
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_WEBUI_EXPLORE_SITES_INTERNALS_EXPLORE_SITES_INTERNALS_UI_H_ #define CHROME_BROWSER_UI_WEBUI_EXPLORE_SITES_INTERNALS_EXPLORE_SITES_INTERNALS_UI_H_ #include <memory> #include "base/macros.h" #include "chrome/browser/ui/webui/explore_sites_internals/explore_sites_internals.mojom.h" #include "chrome/browser/ui/webui/explore_sites_internals/explore_sites_internals_page_handler.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "ui/webui/mojo_web_ui_controller.h" namespace explore_sites { // UI controller for chrome://explore-sites-internals, hooks up a concrete // implementation of explore_sites_internals::mojom::PageHandler to requests for // that page handler that will come from the frontend. class ExploreSitesInternalsUI : public ui::MojoWebUIController { public: explicit ExploreSitesInternalsUI(content::WebUI* web_ui); ~ExploreSitesInternalsUI() override; private: void BindExploreSitesInternalsPageHandler( mojo::PendingReceiver<explore_sites_internals::mojom::PageHandler> receiver); std::unique_ptr<ExploreSitesInternalsPageHandler> page_handler_; ExploreSitesService* explore_sites_service_; DISALLOW_COPY_AND_ASSIGN(ExploreSitesInternalsUI); }; } // namespace explore_sites #endif // CHROME_BROWSER_UI_WEBUI_EXPLORE_SITES_INTERNALS_EXPLORE_SITES_INTERNALS_UI_H_
9ace1b9f303ada9a2bb874dc8453acdced6cbe53
d0bea3e15ef8bc2779328d09d74e23d9296efe06
/Exercise 12.1.3/main.cpp
25124fca42d416b0417a621e777e187c0d8b1c5b
[]
no_license
hbtalha/Book-Cpp-Without-Fear-3rd-Edition-Exercises
0478186c4c8e31fea9b45fe0291a0a52a23d194d
dfa196e90a96718ec48f1b7060dcf4a151f82fec
refs/heads/master
2022-12-25T01:37:18.478123
2020-09-30T14:15:36
2020-09-30T14:15:36
299,940,934
1
0
null
null
null
null
UTF-8
C++
false
false
1,914
cpp
// Write and test a find function for the Btree class. // This function should take a string as input, and return a Boolean value (true or false) depending on whether or not that string is in the tree. // Write a recursive solution. #include <iostream> using namespace std; class Bnode { public: string val; Bnode* pRight; Bnode* pLeft; Bnode( string s) { val = s; pLeft = pRight = nullptr; } }; class Btree { Bnode* root; Bnode* insert_at_sub(string s, Bnode* p); void print_sub(Bnode* p); void seek_sub( string s, Bnode* p); bool found = false; public: Btree () { root = nullptr; } void insert(string s) { root = insert_at_sub(s, root); } void print() { print_sub(root); } void seek(string s); }; Bnode* Btree::insert_at_sub(string s, Bnode* p) { if (!p) { return new Bnode(s); } else if ( s < p->val) { p->pLeft = insert_at_sub(s, p->pLeft); } else if ( s > p->val) { p->pRight = insert_at_sub(s, p->pRight); } return p; } void Btree::print_sub(Bnode* p) { if (p) { print_sub(p->pLeft); cout << p->val << endl; print_sub(p->pRight); } } void Btree::seek(string s) { seek_sub(s, root); if (found == true) cout << endl << "found" << endl; else cout << endl << "not found" << endl; } void Btree::seek_sub(string s, Bnode* p) { if (p) { seek_sub(s, p->pLeft); seek_sub(s, p->pRight); if (s == p->val) { found = true; } } } int main() { Btree my_tree; my_tree.insert("helder"); my_tree.insert("edilson"); my_tree.insert("gelson"); my_tree.insert("wilson"); my_tree.insert("hermes"); my_tree.insert("decio"); my_tree.seek("geson"); return 0; }
a0b2c8f8eb661a74c38aa450ac15f66915ce2fc5
c2ac6ebe60cd6717a869e48ce618ac86f5c37e89
/plugin/src/PluginProcessor.h
fbcce75b9d9e92c896babafeba32b9225768598a
[]
no_license
Spijkervet/juce-simple-eq
0ac833f62ea1da0a6bfa0059f00d99a538338496
da7ecb0d625c20b53fe615692a2464b786a11036
refs/heads/main
2023-06-08T10:12:48.458218
2021-06-20T15:11:46
2021-06-20T15:11:46
378,452,962
2
0
null
null
null
null
UTF-8
C++
false
false
5,129
h
/* ============================================================================== This file contains the basic framework code for a JUCE plugin processor. ============================================================================== */ #pragma once #include <shared_plugin_helpers/shared_plugin_helpers.h> #include <juce_dsp/juce_dsp.h> enum Slope { Slope_12, Slope_24, Slope_36, Slope_48 }; struct ChainSettings { float peakFreq {0}, peakGainInDecibels {0}, peakQuality {1.f}; float lowCutFreq {0}, highCutFreq {0}; Slope lowCutSlope {Slope::Slope_12}, highCutSlope {Slope::Slope_12}; }; ChainSettings getChainSettings(juce::AudioProcessorValueTreeState& apvts); using Filter = juce::dsp::IIR::Filter<float>; using CutFilter = juce::dsp::ProcessorChain<Filter, Filter, Filter, Filter>; using MonoChain = juce::dsp::ProcessorChain<CutFilter, Filter, CutFilter>; enum ChainPositions { LowCut, Peak, HighCut }; using Coefficients = Filter::CoefficientsPtr; void updateCoefficients(Coefficients& old, const Coefficients& replacements); Coefficients makePeakFilter(const ChainSettings& chainSettings, double sampleRate); template <int Index, typename ChainType, typename CoefficientType> void update(ChainType& chain, const CoefficientType& coefficients) { updateCoefficients(chain.template get<Index>().coefficients, coefficients[Index]); chain.template setBypassed<Index>(false); } template <typename ChainType, typename CoefficientType> void updateCutFilter(ChainType& chain, const CoefficientType& coefficients, const Slope& slope) { chain.template setBypassed<0>(true); chain.template setBypassed<1>(true); chain.template setBypassed<2>(true); chain.template setBypassed<3>(true); switch (slope) { case Slope_48: { update<3>(chain, coefficients); } case Slope_36: { update<2>(chain, coefficients); } case Slope_24: { update<1>(chain, coefficients); } case Slope_12: { update<0>(chain, coefficients); } } } inline auto makeLowCutFilter(const ChainSettings& chainSettings, double sampleRate) { return juce::dsp::FilterDesign<float>::designIIRHighpassHighOrderButterworthMethod( chainSettings.lowCutFreq, sampleRate, 2 * (chainSettings.lowCutSlope + 1)); } inline auto makeHighCutFilter(const ChainSettings& chainSettings, double sampleRate) { return juce::dsp::FilterDesign<float>::designIIRLowpassHighOrderButterworthMethod( chainSettings.highCutFreq, sampleRate, 2 * (chainSettings.highCutSlope + 1)); } //============================================================================== /** */ class SimpleEQAudioProcessor : public juce::AudioProcessor { public: //============================================================================== SimpleEQAudioProcessor(); ~SimpleEQAudioProcessor() override; //============================================================================== void prepareToPlay(double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported(const BusesLayout& layouts) const override; #endif void processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) override; //============================================================================== juce::AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const juce::String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram(int index) override; const juce::String getProgramName(int index) override; void changeProgramName(int index, const juce::String& newName) override; //============================================================================== void getStateInformation(juce::MemoryBlock& destData) override; void setStateInformation(const void* data, int sizeInBytes) override; static juce::AudioProcessorValueTreeState::ParameterLayout createParameterLayout(); juce::AudioProcessorValueTreeState apvts { *this, nullptr, "Parameters", createParameterLayout()}; private: MonoChain leftChain, rightChain; void updatePeakFilter(const ChainSettings& chainSettings); void updateLowCutFilters(const ChainSettings& chainSettings); void updateHighCutFilters(const ChainSettings& chainSettings); void updateFilters(); //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SimpleEQAudioProcessor) };
bc1ad53480a27b89d22550e8a7acf841631c7412
8acc14b3407858ba136cd81bdff759071946b4c0
/HellEngine/SpaceOctTree.cpp
490f8cf86d5c5c1441014742f344e5b124b7f3b6
[ "MIT" ]
permissive
BrunoAOR/HellEngine
e36e4ce582f716addf7916d9f7b0200912b19ff7
7a2df1ee430c8fab543ca6e830abb10b3bf2e9bd
refs/heads/master
2021-05-11T19:56:16.428382
2018-05-21T16:19:31
2018-05-21T16:19:31
117,424,897
1
1
null
null
null
null
UTF-8
C++
false
false
6,413
cpp
#include <algorithm> #include "ComponentTransform.h" #include "ComponentType.h" #include "GameObject.h" #include "SpaceOctNode.h" #include "SpaceOctTree.h" SpaceOctTree::SpaceOctTree(): bucketSize(1), maxDepth(5) { } SpaceOctTree::~SpaceOctTree() { CleanUp(); } int SpaceOctTree::Create(float3 minPoint, float3 maxPoint) { CleanUp(); type = OctTreeType::FIXED; if (minPoint.x < maxPoint.x && minPoint.y < maxPoint.y && minPoint.z < maxPoint.z) { minContainedPoint = minPoint; maxContainedPoint = maxPoint; node = new SpaceOctNode(minPoint, maxPoint, this, 1); return 0; } return 1; } int SpaceOctTree::Create(const std::vector<GameObject*>& gameObjects) { CleanUp(); type = OctTreeType::ADAPTIVE; int failCount = 0; for (GameObject* go : gameObjects) { if (go) { if (ComponentTransform* transform = (ComponentTransform*)go->GetComponent(ComponentType::TRANSFORM)) { /* Add gameObject to internal buffer (used if the Tree needs to be recreated upon inserting a new GameObject with Insert method) */ containedGameObjects.push_back(go); /* Determine the minPoint and maxPoint for the node to be created */ AABB goBoundingBox = transform->GetBoundingBox(); float3 goMinPoint = goBoundingBox.minPoint; float3 goMaxPoint = goBoundingBox.maxPoint; minContainedPoint.x = minContainedPoint.x <= goMinPoint.x ? minContainedPoint.x : goMinPoint.x; minContainedPoint.y = minContainedPoint.y <= goMinPoint.y ? minContainedPoint.y : goMinPoint.y; minContainedPoint.z = minContainedPoint.z <= goMinPoint.z ? minContainedPoint.z : goMinPoint.z; maxContainedPoint.x = maxContainedPoint.x >= goMaxPoint.x ? maxContainedPoint.x : goMaxPoint.x; maxContainedPoint.y = maxContainedPoint.y >= goMaxPoint.y ? maxContainedPoint.y : goMaxPoint.y; maxContainedPoint.z = maxContainedPoint.z >= goMaxPoint.z ? maxContainedPoint.z : goMaxPoint.z; } else ++failCount; } } node = new SpaceOctNode(minContainedPoint, maxContainedPoint, this, 1); for (GameObject* go : containedGameObjects) { ComponentTransform* transform = (ComponentTransform*)go->GetComponent(ComponentType::TRANSFORM); failCount += node->Insert(transform) ? 0 : 1; } return failCount; } SpaceOctTree::OctTreeType SpaceOctTree::GetType() { return type; } int SpaceOctTree::Insert(GameObject* gameObject) { if (!gameObject) return 1; int failCount = 1; /* A different vector must be created for ADAPTIVE QuadTree because the Create function calls CleanUp which will clear the containedGameObjects vector. */ std::vector<GameObject*> newGameObjectsVector(containedGameObjects); newGameObjectsVector.push_back(gameObject); switch (type) { case SpaceOctTree::OctTreeType::INVALID: failCount = 1; break; case SpaceOctTree::OctTreeType::FIXED: failCount = InsertFixed(gameObject); break; case SpaceOctTree::OctTreeType::ADAPTIVE: if (gameObject->GetComponent(ComponentType::TRANSFORM)) { failCount = Create(newGameObjectsVector); } break; } LOGGER("SpaceOctTree now contains %i GameObjects.", containedGameObjects.size()); return failCount; } int SpaceOctTree::Insert(std::vector<GameObject*> gameObjects) { int failCount = 0; /* A different vector must be created for ADAPTIVE QuadTree because the Create function calls CleanUp which will clear the containedGameObjects vector. */ std::vector<GameObject*> newGameObjectsVector(containedGameObjects); newGameObjectsVector.insert(newGameObjectsVector.end(), gameObjects.begin(), gameObjects.end()); switch (type) { case SpaceOctTree::OctTreeType::INVALID: failCount = gameObjects.size(); break; case SpaceOctTree::OctTreeType::FIXED: for (GameObject* go : gameObjects) failCount += InsertFixed(go); break; case SpaceOctTree::OctTreeType::ADAPTIVE: failCount = Create(newGameObjectsVector); break; default: failCount = 1; break; } LOGGER("SpaceOctTree now contains %i GameObjects.", containedGameObjects.size()); return failCount; } bool SpaceOctTree::Remove(GameObject* gameObject) { if (type == OctTreeType::INVALID) return false; std::vector<GameObject*>::iterator it = std::find(containedGameObjects.begin(), containedGameObjects.end(), gameObject); if (it == containedGameObjects.end()) return false; containedGameObjects.erase(it); bool result = false; /* If the gameObject WAS previously added to the SpaceOctTree, then it should contain a ComponentTransform */ ComponentTransform* transform = (ComponentTransform*)gameObject->GetComponent(ComponentType::TRANSFORM); assert(transform); /* A different vector must be created for ADAPTIVE OCtTree because the Create function calls CleanUp which will clear the containedGameObjects vector. */ std::vector<GameObject*> newGameObjectsVector(containedGameObjects); switch (type) { case SpaceOctTree::OctTreeType::FIXED: /* The transform should be in the SpaceNode hierarchy */ result = node->Remove(transform); assert(result); break; case SpaceOctTree::OctTreeType::ADAPTIVE: /* Recreate the whole SpaceOctTree. */ result = Create(newGameObjectsVector); break; default: result = false; break; } LOGGER("SpaceQuadTree now contains %i GameObjects.", containedGameObjects.size()); return result; } void SpaceOctTree::DrawTree() { if (type != OctTreeType::INVALID && node) node->DrawNode(); } void SpaceOctTree::CleanUp() { type = OctTreeType::INVALID; containedGameObjects.clear(); if (node != nullptr) { delete node; node = nullptr; } minContainedPoint.x = FLT_MAX; minContainedPoint.y = FLT_MAX; minContainedPoint.z = FLT_MAX; maxContainedPoint.x = FLT_MIN; maxContainedPoint.y = FLT_MIN; maxContainedPoint.z = FLT_MIN; } int SpaceOctTree::InsertFixed(GameObject* gameObject) { ComponentTransform* transform = (ComponentTransform*)gameObject->GetComponent(ComponentType::TRANSFORM); if (!transform) return 1; containedGameObjects.push_back(gameObject); AABB goBoundingBox = transform->GetBoundingBox(); float3 goMinPoint = goBoundingBox.minPoint; float3 goMaxPoint = goBoundingBox.maxPoint; if (goMinPoint.x > maxContainedPoint.x && goMinPoint.y > maxContainedPoint.y && goMinPoint.z > maxContainedPoint.z || goMaxPoint.x < minContainedPoint.x && goMaxPoint.y < minContainedPoint.y && goMaxPoint.z < minContainedPoint.z) return 1; if (node->Insert(transform)) return 0; else return 1; }
49492db87f68f7c1f31d17ed529348810a682d20
cc630743468423ded1d93d076c0d08affec7de55
/src/06/metropolis.hpp
d5568331d8d23552f1437d07c8f0db0bbc860faa
[ "MIT" ]
permissive
kdungs/coursework-computational-physics
d426ca0025044d7bb5b31d8eac8f74717556251c
afa6c6c54dc8cd32d65179afa06a308afe3df693
refs/heads/master
2016-09-06T13:51:10.307514
2014-07-15T14:58:14
2014-07-15T14:58:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,056
hpp
#ifndef __METROPOLIS_HPP__ #define __METROPOLIS_HPP__ #include <algorithm> #include <cmath> #include <functional> #include <fstream> #include <random> #include <string> #include <vector> typedef short Spin; typedef std::vector<Spin> SpinConfiguration; typedef std::function<double(const SpinConfiguration&, const double)> QuantityCalculator; template <typename URNG> SpinConfiguration randomConfiguration(const size_t side_length, URNG &rng) { static std::uniform_int_distribution<Spin> dist(0, 1); SpinConfiguration sc(side_length * side_length); std::generate(std::begin(sc), std::end(sc), [&] () { if (dist(rng) == 1) { return 1; // up } return -1; // down }); return sc; // use return value optimisation } void saveToFile(const std::string &filename, const SpinConfiguration &sc) { const size_t L = std::sqrt(sc.size()); std::ofstream ofs(filename); for (size_t y = 0; y < L; y++) { for (size_t x = 0; x < L; x++) { ofs << sc[y * L + x] << ' '; } ofs << '\n'; } ofs.close(); } double calculateHamiltonian( const SpinConfiguration &sc, const double coupling_x=1, const double coupling_y=1 ) { const size_t side_length = std::sqrt(sc.size()); double energy = 0; for (size_t pos = 0; pos < sc.size(); pos++) { if ((pos + 1) % side_length == 0) { // right edge energy += coupling_x * sc[pos] * sc[pos + 1 - side_length]; } else { energy += coupling_x * sc[pos] * sc[pos + 1]; } if ((pos + side_length) >= sc.size()) { // bottom edge energy += coupling_y * sc[pos] * sc[pos % side_length]; } else { energy += coupling_y * sc[pos] * sc[pos + side_length]; } } return -energy; } double calculateHamiltonianDifference( const SpinConfiguration &sc, const size_t pos, const double coupling_x=1, const double coupling_y=1 ) { const size_t L = std::sqrt(sc.size()), x = pos % L, y = pos / L; Spin top, right, bottom, left; if (y > 0) { top = sc[pos - L]; } else { top = sc[x + (L - 1) * L]; } if (x < L - 1) { right = sc[pos + 1]; } else { right = sc[pos + 1 - L]; } if (y < L - 1) { bottom = sc[pos + L]; } else { bottom = sc[x]; } if (x > 0) { left = sc[pos - 1]; } else { left = sc[pos - 1 + L]; } return 2 * sc[pos] * (coupling_y * top + coupling_x * right + coupling_y * bottom + coupling_x * left); } template <typename URNG> double metropolisStep( const double temperature, const double hamiltonian_before, const size_t pos, SpinConfiguration &sc, URNG &rng, const double coupling_x, const double coupling_y ) { static std::uniform_real_distribution<double> dist_p(0, 1); const double diff = calculateHamiltonianDifference(sc, pos, coupling_x, coupling_y); if (diff > 0 && dist_p(rng) > std::exp(-1. / temperature * diff)) { return hamiltonian_before; // reject flip } sc[pos] *= -1; return hamiltonian_before + diff; } template <typename URNG> double metropolisRandomStep( const double temperature, const double hamiltonian_before, SpinConfiguration &sc, URNG &rng, const double coupling_x, const double coupling_y ) { std::uniform_int_distribution<size_t> dist_pos(0, sc.size() - 1); return metropolisStep(temperature, hamiltonian_before, dist_pos(rng), sc, rng, coupling_x, coupling_y); } template <typename URNG> double metropolisSweep( const double temperature, const double hamiltonian_before, SpinConfiguration &sc, URNG &rng, const double coupling_x, const double coupling_y ) { double hamiltonian = hamiltonian_before; for (size_t pos = 0; pos < sc.size(); pos++) { hamiltonian = metropolisStep(temperature, hamiltonian, pos, sc, rng, coupling_x, coupling_y); } return hamiltonian; } template <typename URNG> double metropolis( const double temperature, const size_t side_length, const unsigned long num_sweeps_burnin, const unsigned long num_sweeps_measurement, QuantityCalculator calculate_quantity, URNG &rng, const double coupling_x=1, const double coupling_y=1, const std::string &filename = std::string() ) { SpinConfiguration sc = randomConfiguration(side_length, rng); double hamiltonian = calculateHamiltonian(sc); for (unsigned long i = 0; i < num_sweeps_burnin; i++) { hamiltonian = metropolisSweep(temperature, hamiltonian, sc, rng, coupling_x, coupling_y); } double quantity = calculate_quantity(sc, hamiltonian); for (unsigned long i = 0; i < num_sweeps_measurement; i++) { hamiltonian = metropolisSweep(temperature, hamiltonian, sc, rng, coupling_x, coupling_y); quantity = calculate_quantity(sc, hamiltonian); } if (filename != "") { saveToFile(filename, sc); } return quantity; } #endif // __METROPOLIS_HPP__
6e1bf16ee32a0d52f794e70c9578c4250f10e09d
d2871fe3d4c0e7bc0936eecb6e5b7153385a2a36
/CIAO/connectors/dds4ccm/tests/Policies/duration.h
abf2962c1a2af79071a0cee6649180de8da9b6c7
[]
no_license
kroeckx/ATCD
a54d070c1d8670591a8561c8f32db8e48671094b
28b1055680abb28bda864bb9b49a811da20fe630
refs/heads/master
2021-01-14T09:10:54.214811
2015-11-07T14:25:07
2015-11-07T15:51:35
45,739,148
1
0
null
2015-11-07T14:14:40
2015-11-07T14:14:40
null
UTF-8
C++
false
false
340
h
#ifndef DURATION_H_ #define DURATION_H_ #include "dds4ccm/idl/dds_rtf2_dcpsC.h" #include "ndds/ndds_cpp.h" #include "dds4ccm/impl/ndds/convertors/Duration_t.h" class Duration { public: Duration (); static bool check (const ::DDS_Duration_t & dds_dur, const ::DDS::Duration_t & dur); }; #endif /* DURATION_H_ */
ba6a2f9572c7d56f96ebcf80741e0278478489c9
5027fe1a0a95f3391566b53fa8c29a2c29e4f04c
/sketchbook/lab1k/lab1k.ino
a4f224e6a06d5461fa6ff07482afd8209de03afd
[]
no_license
chelroot/script
5e79e9609fb602ef63ee33e36262e4d3a79ea28f
e1f915b3b8e834417fdb07d2b6894e22674071e1
refs/heads/master
2020-03-29T01:18:55.090645
2017-12-14T15:02:13
2017-12-14T15:02:13
94,638,883
0
0
null
null
null
null
UTF-8
C++
false
false
599
ino
int ledPin13 = 13; int incomingByte; void setup() { Serial.begin(115200); pinMode(ledPin13, OUTPUT); } void loop() { if (Serial.available() > 0) { incomingByte = Serial.read(); if (incomingByte == 'Q') { digitalWrite(13, HIGH); } if (incomingByte == 'q') { digitalWrite(13, LOW); } if (incomingByte == 'a') { int val; val = digitalRead(13); Serial.print(val);Serial.print(val); Serial.print("qqq"); Serial.println(); Serial.print(val);Serial.print(val); Serial.print("qqq"); Serial.println(); } } }
9cd8ca4d2f610d8b4e193df36596c49c1985eb37
27b35efcb9ac7b30f30640de34a8a2edbf201ff4
/display/editorwindow.cpp
f97c303f22203c0807e6d6eb589e99cce8d35cd7
[]
no_license
Lerian/IHMMapEditor
4b24053415328cd66959457709a00743db0f7c6a
d40f62de3ef5dfe616393a84cf14daf4bbde8c2a
refs/heads/master
2021-01-10T18:23:10.510481
2014-02-23T20:44:13
2014-02-23T20:44:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,214
cpp
#include "display/editorwindow.h" #include "ui_editorwindow.h" #include "graphitem.h" #include <QFileDialog> #include "mapgraphicsview.h" #include "parser.h" #include "map.h" #include "link.h" EditorWindow::EditorWindow(QWidget *parent) : QWidget(parent), ui(new Ui::EditorWindow) { ui->setupUi(this); QGraphicsScene* presentationScene = new QGraphicsScene(this); GraphItem* doorItem = new GraphItem(":/resource/porte.png"); doorItem->setPos(0,20); doorItem->setType("porte"); presentationScene->addItem(doorItem); QGraphicsTextItem* txtPorte = presentationScene->addText("Porte"); txtPorte->setPos(60,0); txtPorte->scale(2,2); GraphItem* elevatorItem = new GraphItem(":/resource/ascenseur.png"); elevatorItem->setPos(0,80); elevatorItem->setType("ascenseur"); presentationScene->addItem(elevatorItem); QGraphicsTextItem* txtElevator = presentationScene->addText("Ascenseur"); txtElevator->setPos(60,60); txtElevator->scale(2,2); GraphItem* stairsItem = new GraphItem(":/resource/escalier.png"); stairsItem->setPos(0,140); stairsItem->setType("escalier"); presentationScene->addItem(stairsItem); QGraphicsTextItem* txtStairs = presentationScene->addText("Escalier"); txtStairs->setPos(60,120); txtStairs->scale(2,2); GraphItem* exitItem = new GraphItem(":/resource/issueSecours.png"); exitItem->setPos(0,200); exitItem->setType("sortieDeSecours"); presentationScene->addItem(exitItem); QGraphicsTextItem* txtExit = presentationScene->addText("Issue de secours"); txtExit->setPos(60,180); txtExit->scale(2,2); GraphItem* qrcodeItem = new GraphItem(":/resource/qrcode.png"); qrcodeItem->setPos(0,260); qrcodeItem->setType("qrcode"); presentationScene->addItem(qrcodeItem); QGraphicsTextItem* txtQRCode = presentationScene->addText("QR Code"); txtQRCode->setPos(60,240); txtQRCode->scale(2,2); GraphItem* wcItem = new GraphItem(":/resource/wc.png"); wcItem->setPos(0,320); wcItem->setType("wc"); presentationScene->addItem(wcItem); QGraphicsTextItem* txtWC = presentationScene->addText("WC"); txtWC->setPos(60,300); txtWC->scale(2,2); GraphItem* wcHItem = new GraphItem(":/resource/wcH.png"); wcHItem->setPos(0,380); wcHItem->setType("wcHandicapes"); presentationScene->addItem(wcHItem); QGraphicsTextItem* txtWCH = presentationScene->addText("WC pour handicapés"); txtWCH->setPos(60,360); txtWCH->scale(2,2); GraphItem* blankItem = new GraphItem(":/resource/blank.png"); blankItem->setPos(0,440); blankItem->setType("neutre"); presentationScene->addItem(blankItem); QGraphicsTextItem* txtblankItem = presentationScene->addText("Point neutre"); txtblankItem->setPos(60,420); txtblankItem->scale(2,2); ui->itemsPresentationArea->setScene(presentationScene); ui->itemsPresentationArea->resize(ui->itemsPresentationArea->scene()->width(),ui->itemsPresentationArea->scene()->height()); } EditorWindow::~EditorWindow() { delete ui; } void EditorWindow::on_newElementButton_clicked() { QString mapFileName = QFileDialog::getOpenFileName(this, "Choisir une image d'arrière plan", "./", "Images (*.png *.jpg *.bmp)"); if(!mapFileName.isEmpty()) { QStringList fileNameParts = mapFileName.split("/"); MapGraphicsView* elementView = new MapGraphicsView(mapFileName); QPixmap pixmap(mapFileName); QGraphicsPixmapItem* background = new QGraphicsPixmapItem(pixmap); QGraphicsScene* elementScene = new QGraphicsScene(0,0,pixmap.width(),pixmap.height()); elementView->setScene(elementScene); elementScene->addItem(background); ui->mapAreaStack->addWidget(elementView); ui->elementsComboBox->addItem(fileNameParts.back()); ui->elementsComboBox->setCurrentIndex(ui->elementsComboBox->count()-1); ui->zoomInButton->setEnabled(true); ui->zoomOutButton->setEnabled(true); ui->removeElementButton->setEnabled(true); } } void EditorWindow::on_zoomInButton_clicked() { MapGraphicsView* currentView = static_cast<MapGraphicsView*>(ui->mapAreaStack->currentWidget()); currentView->scale(1.25,1.25); } void EditorWindow::on_zoomOutButton_clicked() { MapGraphicsView* currentView = static_cast<MapGraphicsView*>(ui->mapAreaStack->currentWidget()); currentView->scale(1/1.25,1/1.25); } void EditorWindow::saveRequested() { Parser p; p.setProjectName(ui->projectNameField->text()); int idLink = 0; Map map; for(int i=0;i < ui->mapAreaStack->count();i++) { MapGraphicsView* currentGraphicView = static_cast<MapGraphicsView*>(ui->mapAreaStack->widget(i)); Floor* currentFloor = currentGraphicView->getFloor(); QGraphicsScene* currentScene = currentGraphicView->scene(); QList<QGraphicsItem*> elements = currentScene->items(); for(int j=0; j < elements.count()-1; j++) { if(elements.at(j)->isEnabled()) { // un point GraphItem* currentItem = dynamic_cast<GraphItem*>(elements.at(j)); currentFloor->addNode(*(currentItem->getNode())); } else { // une ligne entre deux points QGraphicsLineItem* currentItem = dynamic_cast<QGraphicsLineItem*>(elements.at(j)); // création d'un edge Link* currentLink = new Link(); QPointF posPointOrigine = currentItem->line().p1(); QPointF posPointDestination = currentItem->line().p2(); QString origineReference; QString destinationReference; for(int k=0; k < elements.count()-1; k++) { if(elements.at(k)->isEnabled()) { GraphItem* item = dynamic_cast<GraphItem*>(elements.at(k)); if(item->pos() == posPointOrigine) origineReference = item->getNode()->getReference(); else if(item->pos() == posPointDestination) destinationReference = item->getNode()->getReference(); } } currentLink->setOrigine(origineReference); currentLink->setDestination(destinationReference); currentLink->setReference("lk"+QString::number(idLink++)); currentFloor->addLink(*currentLink); } } map.addFloor(*currentFloor); currentFloor->resetNodes(); currentFloor->resetLinks(); } p.saveMap(map); } void EditorWindow::on_removeElementButton_clicked() { ui->mapAreaStack->removeWidget(ui->mapAreaStack->currentWidget()); ui->elementsComboBox->removeItem(ui->elementsComboBox->currentIndex()); if(ui->elementsComboBox->count() == 0) { ui->zoomInButton->setEnabled(false); ui->zoomOutButton->setEnabled(false); ui->removeElementButton->setEnabled(false); } } void EditorWindow::clearProject() { while(ui->mapAreaStack->count() > 0) on_removeElementButton_clicked(); ui->projectNameField->clear(); }
f148984fa14d111459dfed76e34385fbee62f5e4
4795507482657de1a010a6d7ff0b93b21c677c8f
/VSGraphic/VSPartialAnimBlend.cpp
2cfc9cef6e54e88b7fcb49ad33cf22237e79036b
[]
no_license
zengliang466/VSEngine2.1
4b5de9e2cc71d9a54ed8aec9762aa0f474b98eae
3e5a656f75438ffcc4746074fa64a43fac40c0c8
refs/heads/main
2023-06-17T03:07:40.170574
2021-07-12T03:38:22
2021-07-12T03:38:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,143
cpp
#include "VSPartialAnimBlend.h" #include "VSSkeletonMeshNode.h" #include "VSGraphicInclude.h" #include "VSBoneNode.h" #include "VSStream.h" using namespace VSEngine2; IMPLEMENT_RTTI(VSPartialAnimBlend,VSAnimBlendFunction) BEGIN_ADD_PROPERTY(VSPartialAnimBlend,VSAnimBlendFunction) REGISTER_PROPERTY(m_BoneWeight, BoneWeight, VSProperty::F_SAVE_LOAD_CLONE) END_ADD_PROPERTY IMPLEMENT_INITIAL_BEGIN(VSPartialAnimBlend) IMPLEMENT_INITIAL_END #define FAST_BLEND_PARIAL_ANIMITION 2 VSPartialAnimBlend::~VSPartialAnimBlend() { m_BoneWeight.Clear(); } VSPartialAnimBlend::VSPartialAnimBlend() { m_BoneWeight.Clear(); } VSPartialAnimBlend::VSPartialAnimBlend(const VSUsedName & ShowName,VSAnimTree * pAnimTree) :VSAnimBlendFunction(ShowName,pAnimTree) { VSString InputName0 = _T("Child0"); VSInputNode * pInputNode = NULL; pInputNode = VS_NEW VSInputNode(VSPutNode::AVT_ANIM,InputName0,this); VSMAC_ASSERT(pInputNode); m_pInput.AddElement(pInputNode); VSString InputName1 = _T("Child1"); pInputNode = NULL; pInputNode = VS_NEW VSInputNode(VSPutNode::AVT_ANIM,InputName1,this); VSMAC_ASSERT(pInputNode); m_pInput.AddElement(pInputNode); } void VSPartialAnimBlend::AddInputNode() { VSString InputName = _T("Child"); VSString ID = IntToString(m_pInput.GetNum()); InputName += ID; VSInputNode * pInputNode = NULL; pInputNode = VS_NEW VSInputNode(VSPutNode::AVT_ANIM,InputName,this); VSMAC_ASSERT(pInputNode); m_pInput.AddElement(pInputNode); for (unsigned int i = 0; i < m_BoneWeight.GetNum(); i++) { m_BoneWeight[i].Value.AddElement(0.0f); } } void VSPartialAnimBlend::DeleteInputNode() { if (m_pInput.GetNum() > 2) { VSInputNode * pInputNode = m_pInput[m_pInput.GetNum() - 1]; m_pInput.Erase(m_pInput.GetNum() - 1); if (!pInputNode) { return ; } VSMAC_DELETE(pInputNode); for (unsigned int i = 0; i < m_BoneWeight.GetNum(); i++) { m_BoneWeight[i].Value.Erase(m_BoneWeight[i].Value.GetNum() - 1); } } } void VSPartialAnimBlend::AddControllBone(const VSUsedName & BoneName) { VSArray<VSREAL> Temp; Temp.SetBufferNum(m_pInput.GetNum()); for (unsigned int i = 0; i < Temp.GetNum(); i++) { if (i == 0) { Temp[i] = 1.0f; } else { Temp[i] = 0.0f; } } m_BoneWeight.AddElement(BoneName, Temp); } void VSPartialAnimBlend::SetBoneWeight(unsigned int i, const VSUsedName & BoneName, VSREAL Weight) { unsigned int uiIndex = m_BoneWeight.Find(BoneName); if (uiIndex != m_BoneWeight.GetNum()) { if (i >= m_BoneWeight[uiIndex].Value.GetNum()) { return; } m_BoneWeight[uiIndex].Value[i] = Weight; } } bool VSPartialAnimBlend::SetObject(VSObject * pObject) { if (VSAnimFunction::SetObject(pObject)) { ComputeWeight(); #if FAST_BLEND_PARIAL_ANIMITION > 1 m_FastTempMatrix.SetBufferNum(m_BoneOutput.GetNum()); #endif return true; } return false; } bool VSPartialAnimBlend::ComputeOutBoneMatrix(double dAppTime) { if (m_Weight.GetNum() == 0) { VSMAC_ASSERT(0); } for ( unsigned int i = 0 ; i < m_pInput.GetNum() ; i++) { VSInputNode* pInputNode = GetInputNode(i); VSAnimFunction *pAnimBaseFunction = (VSAnimFunction *)pInputNode->GetOutputLink()->GetOwner(); if (!pAnimBaseFunction) { return false; } m_bHaveRootMotion |= (pAnimBaseFunction->m_bHaveRootMotion && m_Weight[i][0] > 0.0f); #if FAST_BLEND_PARIAL_ANIMITION == 0 if (i == 0) { m_RootAtom = pAnimBaseFunction->m_RootAtom * m_Weight[i][0]; } else { m_RootAtom += pAnimBaseFunction->m_RootAtom * m_Weight[i][0]; } #elif FAST_BLEND_PARIAL_ANIMITION == 1 if (i == 0) { m_RootAtom = FastParitialMul(pAnimBaseFunction->m_RootAtom , m_Weight[i][0]); } else { m_RootAtom.FastParitialBlend(pAnimBaseFunction->m_RootAtom , m_Weight[i][0]); } #else if (i == 0) { pAnimBaseFunction->m_RootAtom.GetMatrix(m_FastRootMatrix); m_FastRootMatrix *= m_Weight[i][0]; } else { VSMatrix3X3W Temp; pAnimBaseFunction->m_RootAtom.GetMatrix(Temp); m_FastRootMatrix += Temp * m_Weight[i][0]; } #endif if (m_bOnlyUpdateRootMotion) { continue; } for (unsigned int j = 0; j < m_BoneOutput.GetNum(); j++) { #if FAST_BLEND_PARIAL_ANIMITION == 0 if (i == 0) { m_BoneOutput[j] = pAnimBaseFunction->m_BoneOutput[j] * m_Weight[i][j]; } else { m_BoneOutput[j] += pAnimBaseFunction->m_BoneOutput[j] * m_Weight[i][j]; } #elif FAST_BLEND_PARIAL_ANIMITION == 1 if (i == 0) { m_BoneOutput[j] = FastParitialMul(pAnimBaseFunction->m_BoneOutput[j] , m_Weight[i][j]); } else { m_BoneOutput[j].FastParitialBlend(pAnimBaseFunction->m_BoneOutput[j] , m_Weight[i][j]); } #else if (i == 0) { pAnimBaseFunction->m_BoneOutput[j].GetMatrix(m_FastTempMatrix[j]); m_FastTempMatrix[j] *= m_Weight[i][j]; } else { VSMatrix3X3W Temp; pAnimBaseFunction->m_BoneOutput[j].GetMatrix(Temp); m_FastTempMatrix[j] += Temp * m_Weight[i][j]; } #endif } } #if FAST_BLEND_PARIAL_ANIMITION > 1 if (!m_bOnlyUpdateRootMotion) { for (unsigned int j = 0; j < m_BoneOutput.GetNum(); j++) { m_BoneOutput[j].FromMatrix(m_FastTempMatrix[j]); } } if (m_bOnlyUpdateRootMotion && m_bHaveRootMotion) { m_RootAtom.FromMatrix(m_FastRootMatrix); } #endif return 1; } void VSPartialAnimBlend::ComputeWeight() { const VSSkeletonMeshNode * pMesh = GetSkeletonMeshNode(); VSMAC_ASSERT(pMesh); VSSkeleton * pSkeleton = pMesh->GetSkeleton(); VSMAC_ASSERT(pSkeleton); m_Weight.SetBufferNum(m_pInput.GetNum()); for (unsigned int i = 0; i < m_Weight.GetNum(); i++) { m_Weight[i].SetBufferNum(pSkeleton->GetBoneNum()); if (i == 0) { for (unsigned int j = 0; j < pSkeleton->GetBoneNum(); j++) { m_Weight[i][j] = 1.0f; } } else { for (unsigned int j = 0; j < pSkeleton->GetBoneNum(); j++) { m_Weight[i][j] = 0.0f; } } } for (unsigned int i = 0; i < m_BoneWeight.GetNum(); i++) { VSREAL Sum = 0.0f; for (unsigned int j = 0; j < m_BoneWeight[i].Value.GetNum(); j++) { Sum += m_BoneWeight[i].Value[j]; } for (unsigned int j = 0; j < m_BoneWeight[i].Value.GetNum(); j++) { m_BoneWeight[i].Value[j] /= Sum; } } for (unsigned int i = 0; i < m_BoneWeight.GetNum(); i++) { VSBoneNode * pBone = pSkeleton->GetBoneNode(m_BoneWeight[i].Key); VSArray<VSUsedName> AllBoneName; VSArray<VSBoneNode *> AllBoneArray; pBone->GetAllBoneArray(AllBoneArray); for (unsigned int m = 0; m < AllBoneArray.GetNum(); m++) { AllBoneName.AddElement(AllBoneArray[m]->m_cName); } VSArray<unsigned int> BoneIndex; BoneIndex.SetBufferNum(AllBoneName.GetNum()); for (unsigned int s = 0; s < AllBoneName.GetNum(); s++) { for (unsigned int j = 0; j < pSkeleton->GetBoneNum(); j++) { VSBoneNode * pBone = pSkeleton->GetBoneNode(j); if (pBone->m_cName == AllBoneName[s]) { BoneIndex[s] = j; } } } for (unsigned int s = 0; s < m_Weight.GetNum(); s++) { for (unsigned int j = 0; j < BoneIndex.GetNum(); j++) { m_Weight[s][BoneIndex[j]] = m_BoneWeight[i].Value[s]; } } } } bool VSPartialAnimBlend::ComputePara(double dAppTime) { return true; }
860e30322910b6100b5588a2eef0df60291aa46c
be5694ec40cd97a49fa07ae7d86f25bb74183341
/expression.hpp
bf6bc789789c9aff7ee918a03bb0205ff8d03344
[]
no_license
codezor/Plotscript
ff1355a753fb899026b149f931ed242363aeb127
2d1ee151d59f523428aeae3dd0bc14515bc4e7df
refs/heads/master
2020-04-16T04:58:06.806042
2018-12-06T04:00:32
2018-12-06T04:00:32
165,288,075
0
0
null
null
null
null
UTF-8
C++
false
false
4,470
hpp
/*! \file expression.hpp Defines the Expression type and assiciated functions. */ #ifndef EXPRESSION_HPP #define EXPRESSION_HPP #include <string> #include <vector> #include "atom.hpp" #include "token.hpp" #include <list> #include <map> #include <utility> // forward declare Environment class Environment; /*! \class Expression \brief An expression is a tree of Atoms. An expression is an atom called the head followed by a (possibly empty) list of expressions called the tail. */ class Expression { public: typedef std::vector<Expression>::const_iterator ConstIteratorType; /// Default construct and Expression, whose type in NoneType Expression(); /*! Construct an Expression with given Atom as head an empty tail \param atom the atom to make the head */ Expression(const Atom& a); /// deep-copy construct an expression (recursive) Expression(const Expression& a); /// Construct an expression with Property-list Expression(const Expression& a,std::map<std::string, Expression>& es); /// Construct an expression of a list type; Expression(const std::vector<Expression>& es); /// deep-copy assign an expression (recursive) Expression& operator=(const Expression& a); /// return a reference to the head Atom Atom& head(); /// return a const-reference to the head Atom const Atom& head() const; /// append Atom to tail of the expression void append(const Atom& a); /// return a pointer to the last expression in the tail, or nullptr Expression* tail(); /// return a const-iterator to the beginning of tail ConstIteratorType tailConstBegin() const noexcept; /// return a const-iterator to the tail end ConstIteratorType tailConstEnd() const noexcept; /// returns a property entery Expression getPropertyList(std::string key); /// returns a property entery Expression setPropertyList(const Expression expression_to_add, std::map<std::string, Expression> property) const noexcept; /// returns a DiscretePlot Expression setDiscretePlot(Expression DATA, Expression options); /// returns a continous plot Expression PlotBoardersAndOptions(double xmin, double xmax, double ymin, double ymax, double scaleX, double scaleY, Expression Discrete, Expression options); /// convienience member to determine if head atom is a number bool isHeadNumber() const noexcept; /// convienience member to determine if head atom is a number bool isHeadComplex() const noexcept; /// convienience member to determine if head atom is a symbol bool isHeadSymbol() const noexcept; /// convienience member to determine if head atom is a string bool isHeadString() const noexcept; /// convience method to determine if head atom is a list bool isHeadList() const noexcept; /// convience method to determine if head atom is a list bool isHeadLambda() const noexcept; /// Convience method to determine if properties are empty bool isPropertyListEmpty() const noexcept; /// Evaluate expression using a post-order traversal (recursive) Expression eval(Environment& env); /// equality comparison for two expressions (recursive) bool operator==(const Expression& exp) const noexcept; Expression MakeRange(Expression); private: // the head of the expression Atom m_head; std::map<std::string, Expression> m_propertyList; // the properties of an expression // the tail list is expressed as a vector for access efficiency // and cache coherence, at the cost of wasted memory. std::vector<Expression> m_tail; // convenience typedef typedef std::vector<Expression>::iterator IteratorType; // internal helper methods Expression handle_lookup(const Atom& head, const Environment& env); Expression handle_define(Environment& env); Expression handle_begin(Environment& env); Expression handle_lambda(Environment& env); Expression handle_apply(Environment& env); Expression handle_map(Environment& env); Expression store_lamba(Environment& env, Expression& original); Expression setContinuousPlot(Environment&env); }; /// Render expression to output stream std::ostream& operator<<(std::ostream& out, const Expression& exp); /// inequality comparison for two expressions (recursive) bool operator!=(const Expression& left, const Expression& right) noexcept; #endif
653facab97b0f0dfec3e0c169077e01a5c0742b6
86a9081a05b837ad0f0feaf6e003a1cbb276993f
/cg_exercises-cg_exercise_04/04_bvh_v5/cg_exercise_04/cglib/src/core/obj_mesh.cpp
bdbd63a0e720e04f7b48b96dbf88ca67169acb46
[]
no_license
flex3r/cg_exercises
e2defd27427c251d5f0f567a8d192af8d87bca3c
7c4b699a8211ba66710ac2137f0d460933069331
refs/heads/master
2020-12-11T14:06:15.052585
2018-02-11T13:58:23
2018-02-11T13:58:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,597
cpp
#include <cglib/core/obj_mesh.h> #include <cglib/core/assert.h> #include <fstream> #include <sstream> #include <iostream> #include <algorithm> OBJMaterial::OBJMaterial(const std::string& name_) : name(name_), diffuse(0.8f), ambient(0.2f), specular(0.0f) { } uint32_t OBJSurface::getFaceCount() const { return vertexIndices.size(); } uint32_t OBJModel::getFaceCount() const { uint32_t sum = 0; for(auto i: m_surfaces) sum += i->getFaceCount(); return sum; } uint32_t OBJFile::getFaceCount() const { uint32_t sum = 0; for(auto i: m_models) sum += i.second->getFaceCount(); return sum; } void OBJSurface::buildVertexList(const OBJModel& model, std::vector<glm::vec3>& target) const { target.clear(); target.reserve(vertexIndices.size() * 3); appendToVertexList(model, target); } void OBJSurface::appendToVertexList( const OBJModel& model, std::vector<glm::vec3>& target) const { const std::vector<glm::vec3>& vertices = model.getVertices(); for (const glm::uvec3 &index : vertexIndices) { glm::vec3 v0, v1, v2; v0 = vertices.at(index.x); v1 = vertices.at(index.y); v2 = vertices.at(index.z); target.push_back(v0); target.push_back(v1); target.push_back(v2); } } void OBJSurface::buildNormalList(const OBJModel& model, std::vector<glm::vec3>& target) const { target.clear(); target.reserve(normalIndices.size() * 3); appendToNormalList(model, target); } void OBJSurface::appendToNormalList( const OBJModel& model, std::vector<glm::vec3>& target) const { const std::vector<glm::vec3>& normals = model.getNormals(); for (const glm::uvec3 index : normalIndices) { glm::vec3 n0, n1, n2; n0 = normals.at(index.x); n1 = normals.at(index.y); n2 = normals.at(index.z); target.push_back(n0); target.push_back(n1); target.push_back(n2); } } void OBJSurface::buildTexcoordList(const OBJModel& model, std::vector<glm::vec2>& target) const { target.clear(); target.reserve(texcoordIndices.size() * 3); appendToTexcoordList(model, target); } void OBJSurface::appendToTexcoordList(const OBJModel& model, std::vector<glm::vec2>& target) const { const std::vector<glm::vec2>& texcoords = model.getTexcoords(); for (const glm::uvec3 index : texcoordIndices) { glm::vec2 t0, t1, t2; t0 = texcoords[index.x]; t1 = texcoords[index.y]; t2 = texcoords[index.z]; target.push_back(t0); target.push_back(t1); target.push_back(t2); } } OBJModel::OBJModel(const std::string& name) : m_name(name), m_vertices(), m_normals(), m_texcoords() { } void OBJModel::scale(const glm::vec3& scale) { for (size_t i = 0; i < m_vertices.size(); ++i) { m_vertices[i] *= scale; } } void OBJModel::scale(float scale) { this->scale(glm::vec3(scale)); } void OBJModel::translate(const glm::vec3& vec) { for (size_t i = 0; i < m_vertices.size(); ++i) { m_vertices[i] = m_vertices[i] + vec; } } void OBJModel::getAABB(glm::vec3& minEdge, glm::vec3& maxEdge) const { if (m_vertices.size() == 0) { minEdge = maxEdge = glm::vec3(0); return; } minEdge = glm::vec3(1e37f); maxEdge = glm::vec3(-1e37f); // Search for min and max edge for (size_t i = 0; i < m_vertices.size(); ++i) { const glm::vec3& v = m_vertices[i]; minEdge.x = std::min(minEdge.x, v.x); minEdge.y = std::min(minEdge.y, v.y); minEdge.z = std::min(minEdge.z, v.z); maxEdge.x = std::max(maxEdge.x, v.x); maxEdge.y = std::max(maxEdge.y, v.y); maxEdge.z = std::max(maxEdge.z, v.z); } } const std::string& OBJModel::getName() const { return m_name; } const std::vector<glm::vec3>& OBJModel::getVertices() const { return m_vertices; } std::vector<glm::vec3>& OBJModel::getVertices() { return m_vertices; } const std::vector<glm::vec3>& OBJModel::getNormals() const { return m_normals; } std::vector<glm::vec3>& OBJModel::getNormals() { return m_normals; } const std::vector<glm::vec2>& OBJModel::getTexcoords() const { return m_texcoords; } std::vector<glm::vec2>& OBJModel::getTexcoords() { return m_texcoords; } const std::vector<std::shared_ptr<OBJSurface>>& OBJModel::getSurfaces() const { for(auto i: m_surfaces) { cg_assert(i); } return m_surfaces; } std::shared_ptr<OBJSurface> OBJModel::addSurface(const OBJFile& objFile, uint32_t materialIndex) { auto surf = std::make_shared<OBJSurface>(); m_surfaces.push_back(surf); surf->material = objFile.getMaterial(materialIndex); // Optimize alloc of vector surf->vertexIndices.reserve(32); surf->normalIndices.reserve(32); surf->texcoordIndices.reserve(32); return surf; } OBJFile::OBJFile(bool verbose_, bool try_triangulate_quads_) : m_models(), m_material(), verbose(verbose_), try_triangulate_quads(try_triangulate_quads_) { } OBJFile::~OBJFile() { //Everything is stored in the std::map and std::vector, so it gets removed } namespace { /** * Gets the path of a file. * Example: "/home/test/file.obj" -> "/home/test/" */ std::string getFilePath(const std::string& filename) { size_t pos = filename.rfind("/"); if (pos == std::string::npos) return ""; return filename.substr(0, pos + 1); } /** * Expects input of %d/%d/%d where / and %d can miss. * Writes the parsed data in the result int array. * Set true in rSet array, if the value was in the word. */ inline const char* parseHelper(const char* cursor, const char* endCursor, uint32_t (&result)[3], bool (&rSet)[3]) { result[0] = result[1] = result[2] = 0; rSet[0] = rSet[1] = rSet[2] = false; char* numEnd = (char*) cursor; result[0] = (uint32_t) strtol(cursor, &numEnd, 10); if (numEnd <= endCursor) { rSet[0] = (cursor < numEnd); cursor = numEnd; } if (*cursor == '/') { numEnd = (char*) ++cursor; result[1] = (uint32_t) strtol(cursor, &numEnd, 10); if (numEnd <= endCursor) { rSet[1] = (cursor < numEnd); cursor = numEnd; } if (*cursor == '/') { numEnd = (char*) ++cursor; result[2] = (uint32_t) strtol(cursor, &numEnd, 10); if (numEnd <= endCursor) { rSet[2] = (cursor < numEnd); cursor = numEnd; } } } return cursor; } template <class It> inline It skipws(It cursor, It end) { while (cursor < end && isspace(*cursor)) ++cursor; return cursor; } template <class It> inline It nextws(It cursor, It end) { while (cursor < end && !isspace(*cursor)) ++cursor; return cursor; } template <class It> inline It nextword(It cursor, It end) { return skipws(nextws(cursor, end), end); } template <class It> inline float extract_float(It& cursor, It end) { char* numEnd = (char*) cursor; auto f = (float) strtod(cursor, &numEnd); if (numEnd <= end) cursor = numEnd; return f; } template <class It> inline glm::vec2 extract_vec2(It& cursor, It end) { glm::vec2 r; r.x = extract_float(cursor, end); r.y = extract_float(cursor, end); return r; } template <class It> inline glm::vec3 extract_vec3(It& cursor, It end) { glm::vec3 r; r.x = extract_float(cursor, end); r.y = extract_float(cursor, end); r.z = extract_float(cursor, end); return r; } } // namespace bool OBJFile::loadFile(const std::string& filename, bool abortOnMissingMaterial) { if (verbose) { std::cout << "Loading OBJ file '" << filename.c_str() << "'" << std::endl; } std::ifstream f(filename, std::ios::binary); if (!f.is_open()) { std::cerr << "could not open file '" << filename << "'" << std::endl; return false; } std::string line; std::shared_ptr<OBJModel> currentModel = 0; std::shared_ptr<OBJSurface> currentSurface = 0; uint32_t currentMaterialIndex = 0; int currentVertexOffset = 1; int currentTexcoordOffset = 1; int currentNormalOffset = 1; while (getline(f, line)) { auto* cursor = line.data(); auto* endCursor = cursor + line.size(); // remove '\r' on line end if (cursor < endCursor && endCursor[-1] == '\r') { --endCursor; } cursor = skipws(cursor, endCursor); // skip empty lines if (cursor == endCursor) { continue; } switch (*cursor) { case '#': break; case 'o': { std::string objectName(nextword(cursor, endCursor), endCursor); if(currentModel) { currentVertexOffset += currentModel->getVertices().size(); currentTexcoordOffset += currentModel->getTexcoords().size(); currentNormalOffset += currentModel->getNormals().size(); } currentModel = addModel(objectName); currentSurface = 0; break; } case 'v': { ++cursor; if (!currentModel) currentModel = addDefaultModel(); switch (*cursor++) { case ' ': case '\t': { currentModel->getVertices().push_back(extract_vec3(cursor, endCursor)); break; } case 'n': { currentModel->getNormals().push_back(extract_vec3(cursor, endCursor)); break; } case 't': { currentModel->getTexcoords().push_back(extract_vec2(cursor, endCursor)); break; } } break; } case 'f': { if (!currentSurface) { if (!currentModel) currentModel = addDefaultModel(); if (m_material.size() == 0) addMaterial("default"); currentSurface = currentModel->addSurface(*this, currentMaterialIndex); } // array of vertex, texcoord, normal uint32_t vtn_0[3]; bool vtn_0set[3]; uint32_t vtn_1[3]; bool vtn_1set[3]; uint32_t vtn_2[3]; bool vtn_2set[3]; uint32_t vtn_3[3]; bool vtn_3set[3]; cursor = nextword(cursor, endCursor); cursor = parseHelper(cursor, nextws(cursor, endCursor), vtn_0, vtn_0set); cursor = nextword(cursor, endCursor); cursor = parseHelper(cursor, nextws(cursor, endCursor), vtn_1, vtn_1set); cursor = nextword(cursor, endCursor); cursor = parseHelper(cursor, nextws(cursor, endCursor), vtn_2, vtn_2set); cursor = nextword(cursor, endCursor); cursor = parseHelper(cursor, nextws(cursor, endCursor), vtn_3, vtn_3set); // Expecting that vtn_0set, vtn_1set, vtn_2set are equal (others dont make sense) if (vtn_0set[0]) { currentSurface->vertexIndices.push_back( glm::uvec3(vtn_0[0], vtn_1[0], vtn_2[0]) - glm::uvec3(currentVertexOffset) ); if (try_triangulate_quads && vtn_3set[0]) { currentSurface->vertexIndices.push_back( glm::uvec3(vtn_0[0], vtn_2[0], vtn_3[0]) - glm::uvec3(currentVertexOffset) ); } } if (vtn_0set[1]) { currentSurface->texcoordIndices.push_back( glm::uvec3(vtn_0[1], vtn_1[1], vtn_2[1]) - glm::uvec3(currentTexcoordOffset) ); if (try_triangulate_quads && vtn_3set[1]) { currentSurface->texcoordIndices.push_back( glm::uvec3(vtn_0[1], vtn_2[1], vtn_3[1]) - glm::uvec3(currentTexcoordOffset) ); } } if (vtn_0set[2]) { currentSurface->normalIndices.push_back( glm::uvec3(vtn_0[2], vtn_1[2], vtn_2[2]) - glm::uvec3(currentNormalOffset) ); if (try_triangulate_quads && vtn_3set[2]) { currentSurface->normalIndices.push_back( glm::uvec3(vtn_0[2], vtn_2[2], vtn_3[2]) - glm::uvec3(currentNormalOffset) ); } } break; } case 'm': { auto endofword = nextws(cursor, endCursor); if (std::string(cursor, endofword) != "mtllib") break; cursor = skipws(endofword, endCursor); std::string matFile(cursor, endCursor); // Create relativ Path to this .obj file matFile = getFilePath(filename) + matFile; // Load the material file bool success = loadMaterialFile(matFile); if (verbose && !success) printf("Failed to load material file '%s'\n", matFile.c_str()); if (!success && abortOnMissingMaterial) return false; break; } case 'u': { auto endofword = nextws(cursor, endCursor); if (std::string(cursor, endofword) != "usemtl") break; cursor = skipws(endofword, endCursor); std::string matName(cursor, endCursor); int32_t matIndex = findMaterial(matName); if (verbose && matIndex == -1) printf("Unable to find material '%s'\n", matName.c_str()); if (matIndex == -1) break; currentMaterialIndex = matIndex; } } } if (verbose) { printf("Finished loading '%s'; Stats:\n", filename.c_str()); printf("%u Models\n%u Materials\n", getModelCount(), getMaterialCount()); } return true; } bool OBJFile::loadMaterialFile(const std::string& filename) { if (verbose) printf("Loading material file '%s'\n", filename.c_str()); std::ifstream f(filename, std::ios::binary); if (!f.is_open()) return false; std::string line; std::shared_ptr<OBJMaterial> currentMaterial = 0; while (getline(f, line)) { // remove '\r' on line end if (line.size() > 0 && line[line.size() - 1] == '\r') { line.erase(line.size() - 1); } std::istringstream ss(line); std::string word; ss >> word; if (word.size() == 0) continue; switch (word[0]) { case '#': break; case 'n': { // New material if (word != "newmtl") break; std::string name; ss >> name; if (verbose) printf("Reading material: '%s'\n", name.c_str()); currentMaterial = addMaterial(name); break; } case 'N': { // Shininess if (!currentMaterial) currentMaterial = addDefaultMaterial(); if (word == "Ns") { ss >> currentMaterial->shininess; } // wavefront shininess is from [0, 1000] -> scale for OpenGL //currentMaterial->shininess /= 1000.0f; //currentMaterial->shininess *= 128.0f; break; } case 'K': { if (!currentMaterial) currentMaterial = addDefaultMaterial(); if (word == "Kd") { ss >> currentMaterial->diffuse[0]; ss >> currentMaterial->diffuse[1]; ss >> currentMaterial->diffuse[2]; } else if (word == "Ks") { ss >> currentMaterial->specular[0]; ss >> currentMaterial->specular[1]; ss >> currentMaterial->specular[2]; } else if (word == "Ka") { ss >> currentMaterial->ambient[0]; ss >> currentMaterial->ambient[1]; ss >> currentMaterial->ambient[2]; } break; } default: { // if there are 2 or more words, write them in additional info map std::string value; if (ss.tellg() > 1) { value = line.substr(static_cast<std::size_t>(1 + ss.tellg())); } // when word is map_*, value is a path. replace \ in path by / std::string map_prefix = "map_"; if(word.length() >= map_prefix.length() && std::mismatch(map_prefix.begin(), map_prefix.end(), word.begin()).first == map_prefix.end()) { std::replace(value.begin(), value.end(), '\\', '/'); } if (verbose) printf("additional material info: '%s' = '%s'\n", word.c_str(), value.c_str()); if (!currentMaterial) currentMaterial = addDefaultMaterial(); currentMaterial->additionalInfo.insert(std::make_pair(word, value)); break; } } } return true; } std::shared_ptr<const OBJModel> OBJFile::getModel(size_t index) const { cg_assert(index < m_models.size()); auto iter = m_models.begin(); for (size_t i = 0; i < index; ++i) ++iter; return (iter->second); } std::shared_ptr<OBJModel> OBJFile::getModel(size_t index) { cg_assert(index < m_models.size()); auto iter = m_models.begin(); for (size_t i = 0; i < index; ++i) ++iter; return (iter->second); } std::shared_ptr<const OBJModel> OBJFile::getModel(const std::string& name) const { return (m_models.at(name)); } std::shared_ptr<OBJModel> OBJFile::getModel(const std::string& name) { return (m_models.at(name)); } uint32_t OBJFile::getModelCount() const { return m_models.size(); } std::shared_ptr<const OBJMaterial> OBJFile::getMaterial(uint32_t index) const { cg_assert(index < m_material.size()); return m_material[index]; } std::shared_ptr<OBJMaterial> OBJFile::getMaterial(uint32_t index) { cg_assert(index < m_material.size()); return m_material[index]; } std::shared_ptr<const OBJMaterial> OBJFile::getMaterial(const std::string& name) const { int32_t index = findMaterial(name); if (index == -1) return 0; return m_material[index]; } std::shared_ptr<OBJMaterial> OBJFile::getMaterial(const std::string& name) { int32_t index = findMaterial(name); if (index == -1) return 0; return m_material[index]; } uint32_t OBJFile::getMaterialCount() const { return m_material.size(); } std::shared_ptr<OBJModel> OBJFile::addModel(const std::string& name) { auto p = std::make_shared<OBJModel>(name); m_models[name] = p; return p; } std::shared_ptr<OBJModel> OBJFile::addDefaultModel() { return addModel("default"); } std::shared_ptr<OBJMaterial> OBJFile::addMaterial(const std::string& name) { auto ptr = std::make_shared<OBJMaterial>(name); m_material.push_back(ptr); return ptr; } std::shared_ptr<OBJMaterial> OBJFile::addDefaultMaterial() { return addMaterial("default"); } int32_t OBJFile::findMaterial(const std::string& name) const { // Linear search for (size_t i = 0; i < m_material.size(); ++i) { if (m_material[i]->name == name) return i; } return -1; }
f9faf77045375de98837ce7d8d82e908ad2b65ba
b22588340d7925b614a735bbbde1b351ad657ffc
/athena/TestBeam/TBEvent/TBEvent/TBMWPCRawCont.h
6436db0227b09ec4211304d6a2b8a44de210788a
[]
no_license
rushioda/PIXELVALID_athena
90befe12042c1249cbb3655dde1428bb9b9a42ce
22df23187ef85e9c3120122c8375ea0e7d8ea440
refs/heads/master
2020-12-14T22:01:15.365949
2020-01-19T03:59:35
2020-01-19T03:59:35
234,836,993
1
0
null
null
null
null
UTF-8
C++
false
false
580
h
/* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #include "DataModel/DataVector.h" #include "CLIDSvc/CLASS_DEF.h" #include "TBEvent/TBMWPCRaw.h" #ifndef TBMWPCRAWCONT_H #define TBMWPCRAWCONT_H /** @class TBMWPCRawCont TBMWPCRawCont.h "TBEvent/TBMWPCRawCont.h" @author P.A. Delsart */ class TBMWPCRawCont : public DataVector<TBMWPCRaw> { public: /** Constructor */ TBMWPCRawCont() : DataVector<TBMWPCRaw>() { } /** destructor */ virtual ~TBMWPCRawCont() { } } ; CLASS_DEF( TBMWPCRawCont , 221991264 , 1 ) #endif
5c2720abe5f8a10175f99813080f5482d33183db
7687f9bddf49620a21d7ba3511fd78e93f4af40f
/control/IMU/imu_optimised/imu_optimised.ino
4daed1c3a3c5fdf807698b685b5f3dbeb2e2855d
[ "MIT" ]
permissive
spider-tronix/arboc
46a261a73d6549924bb51bad8e4dce2832f44ede
244b320617b9c99fb8d44a37a527953be376bbd0
refs/heads/master
2022-04-11T10:31:25.954422
2020-03-07T07:35:17
2020-03-07T07:35:17
188,832,282
1
1
null
2019-06-15T15:11:03
2019-05-27T11:41:08
C++
UTF-8
C++
false
false
7,969
ino
// ================================================================ // === IMU 6050 KALMAN FILTER CODE === // === CODE BY MANU AATITYA R P === // === lANGUAGE : ARDUINO === // ================================================================ // This contains the basic code to get values from 2 MPU 6050 simultaneously // =============================================================================== // === NECESSARY VARIABLES AND LIBRARIES INCLUDED === // =============================================================================== #include<Wire.h> # define Number_of_IMU 2 # define TCAADDR 0x70 //Address of Multiplexer extern "C" { include "utility/twi.h" // from Wire library, so we can do bus scanning } // Define necessary variables const int MPU_address[Number_of_IMU] = {0x68 , 0x69}; // I2C address of the MPUs int16_t ax,ay,az,wx,wy,wz; // accelerometer and gyroscope variables // first index is the number of imu's double g_predicted[Number_of_IMU][2][3] = {0}; // g values for accelerometer and gyroscope // first index is the number of imu's double theta_predicted[Number_of_IMU][2][3] = {0}; // theta values of accelerometer and gyroscope double time_step[Number_of_IMU],previous_time[Number_of_IMU],time_elapsed[Number_of_IMU]; // time variables for gyroscope int gyro_count[Number_of_IMU] = {1,1}; // count of gyro values double g[Number_of_IMU][3] = {0}; // Matrix for g values row indicates imu number double theta[Number_of_IMU][3] = {0} ; // final theta values // Kalman Filter Coefficients and Matrices Error Covariance matrices for the filters // first dimension indicates number of imu's double p[Number_of_IMU][3][2][2] = {0}; // Kalman gain coefficients for the filters // Row indicates number of imus's double k[Number_of_IMU][3][2] = {0}; // Bias Variables double bias_x[Number_of_IMU] = {0},bias_y[Number_of_IMU] = {0},bias_z[Number_of_IMU] = {0}; // Kalman Coefficients for Covariance matrices double angle_bias[Number_of_IMU] = {0.001,0.001}; double measurement_bias[Number_of_IMU] = {0.003,0.003}; double covariance_measure[Number_of_IMU] = {0.003,0.003}; // ====================================================================== // === CONFIGURE I2C MULTIPLEXER ROUTINE === // ====================================================================== // Configuring first MPU void configure_multiplexer() { for(int i=0;i < Number_of_IMU;i++) { Wire.begin(); // initialize I2C Wire.beginTransmission(MPU_address[i]); // start test transmission Wire.write(0x6B); // write into register Wire.write(0); // pull down logic Wire.endTransmission(true); // end test transmission } } // ================================================================ // === KALMAN FUNCTION ROUTINE === // ================================================================ // Kalman Function void Kalman(double z[3],double theta_dot[3],double dt,int imu_number) { double angle[3] = {0}; double theta_unbiased[3] = {0}; for(int i =0 ;i<3;i++) { theta_unbiased[i] = theta_dot[i] - bias_x[i]; angle[i] = theta_unbiased[i] * dt; p[imu_number][i][0][0] += dt * (dt*p[imu_number][i][1][1] - p[imu_number][i][0][1] - p[imu_number][i][1][0] + angle_bias[i]); p[imu_number][i][0][1] -= dt * p[imu_number][i][1][1]; p[imu_number][i][1][0] -= dt * p[imu_number][i][1][1]; p[imu_number][i][1][1] += measurement_bias[i] * dt; double S = p[imu_number][i][0][0] + covariance_measure[i]; k[imu_number][i][0] = p[imu_number][i][0][0] / S; k[imu_number][i][1] = p[imu_number][i][1][0] / S; double y = z[i] - angle[i]; angle[i] += k[imu_number][i][0] * y; bias_x[i] = k[imu_number][i][0] * y; p[imu_number][i][0][0] -= k[imu_number][i][0] * p[imu_number][i][0][0]; p[imu_number][i][0][1] -= k[imu_number][i][0] * p[imu_number][i][0][1]; p[imu_number][i][1][0] -= k[imu_number][i][1] * p[imu_number][i][0][0]; p[imu_number][i][1][1] -= k[imu_number][i][1] * p[imu_number][i][0][1]; theta[imu_number][i] = angle[i]; } } // ================================================================ // === DATA RETRIEVAL ROUTINE === // ================================================================ // Function to retrieve data from MPU void getDataFromMPU(const int MPU_address) { int i; Wire.beginTransmission(MPU_address); Wire.write(0x3B); // register to access acceleration x high Wire.endTransmission(false); Wire.requestFrom(MPU_address,6); while(Wire.available() < 6); ax = Wire.read() << 8 | Wire.read(); ay = Wire.read() << 8 | Wire.read(); az = Wire.read() << 8 | Wire.read(); // Leaving Register which gets Temperature values Wire.beginTransmission(MPU_address); Wire.write(0x43); // Register to access gyroscope x high Wire.endTransmission(false); Wire.requestFrom(MPU_address,6); while(Wire.available() < 6); wx = Wire.read() << 8 | Wire.read(); wy = Wire.read() << 8 | Wire.read(); wz = Wire.read() << 8 | Wire.read(); if (MPU_address == 0x68) { // time elapsed since taking gyroscope readings previous_time[0] = time_step[0]; time_step[0] = millis(); time_elapsed[0] = (time_step[0] - previous_time[0] ) / 1000.0; i = 0; } else { // time elapsed since taking gyroscope readings previous_time[1] = time_step[1]; time_step[1] = millis(); time_elapsed[1] = (time_step[1] - previous_time[1] ) / 1000.0; i =1; } // Calculating g values from the raw data obtained from MPU // Accelerometer // sensitivity scale factor of the accelerometer is 16384 counts/g g_predicted[i][0][0] = ax/(16384.0); g_predicted[i][0][1] = ay/(16384.0); g_predicted[i][0][2] = az/(16384.0); // theta values from accelerometer theta_predicted[i][0][0] = (180/3.141592) * atan(g_predicted[i][0][0] / sqrt(square(g_predicted[i][0][1]) + square(g_predicted[i][0][2]))); theta_predicted[i][0][1] = (180/3.141592) * atan(g_predicted[i][0][1] / sqrt(square(g_predicted[i][0][0]) + square(g_predicted[i][0][2]))); theta_predicted[i][0][2] = (180/3.141592) * atan(sqrt(square(g_predicted[i][0][1]) + square(g_predicted[i][0][0])) / g_predicted[i][0][2]); // Gyroscope // Sensitivity scale factor of gyroscope is 131 radians/s g_predicted[i][1][0] = wx / (131.0); g_predicted[i][1][1] = wy / (131.0); g_predicted[i][1][2] = wz / (131.0); // Theta values for gyroscope theta_predicted[i][1][0] = g_predicted[i][1][0]; theta_predicted[i][1][1] = g_predicted[i][1][1]; theta_predicted[i][1][2] = g_predicted[i][1][2]; Kalman(theta_predicted[i][0],theta_predicted[i][1],time_elapsed[i],i); } // ================================================================ // === SETUP ROUTINE === // ================================================================ // Setup loop void setup() { configure_multiplexer(); for(int i=0;i<2;i++) { time_step[i] = millis(); } Serial.begin(9600); // set baud rate to 9600 for serial communication } // ================================================================ // === MAIN ROUTINE === // ================================================================ // Main loop void loop() { Serial.println("MPU 1"); for(int i = 0 ;i < Number_of_IMU ; i++) { Serial.print("MPU"); Serial.println(i+1); getDataFromMPU(MPU_address[i]); } delay(333); // To avoid too much results in the serial monitor Serial.print("RelativeTheta X = "); Serial.print(theta[1][0] - theta[0][0]); Serial.print(" | RelativeTheta_Y = "); Serial.print(theta[1][1] - theta[0][1]); Serial.print(" | RelativeTheta_Z = "); Serial.println(theta[1][2] - theta[0][2]); }
f026d3b0e384954acc85782dffed329bf652f7fb
4fbd844113ec9d8c526d5f186274b40ad5502aa3
/algorithms/cpp/reverse_vowels_of_a_string.cpp
debd1bff5cb3efb53b45760bf1c45d5a8abb8586
[]
no_license
capric8416/leetcode
51f9bdc3fa26b010e8a1e8203a7e1bcd70ace9e1
503b2e303b10a455be9596c31975ee7973819a3c
refs/heads/master
2022-07-16T21:41:07.492706
2020-04-22T06:18:16
2020-04-22T06:18:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
430
cpp
/* Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Example 2: Input: "leetcode" Output: "leotcede" Note: The vowels does not include the letter "y". */ /* ==================== body ==================== */ class Solution { public: string reverseVowels(string s) { } }; /* ==================== body ==================== */
6d773c6e61c6cc170f9475d3ee182f7c73737a31
6c40203055fe652f238fb5f3befaa0d04a788d65
/src/armnn/layers/Pooling2dLayer.cpp
ede37d76049ce9bc1a6047c4d879c9f1bdc27e3c
[ "MIT" ]
permissive
Air000/armnn_s32v
9243f2e8d63b9691b9c7873a54b29ac5a79d2b14
ec3ee60825d6b7642a70987c4911944cef7a3ee6
refs/heads/master
2020-03-27T15:32:37.975405
2018-09-01T14:11:34
2018-09-01T14:11:34
146,724,624
1
1
null
null
null
null
UTF-8
C++
false
false
4,167
cpp
// // Copyright © 2017 Arm Ltd. All rights reserved. // See LICENSE file in the project root for full license information. // #include "Pooling2dLayer.hpp" #include "LayerCloneBase.hpp" #include <armnn/TypesUtils.hpp> #include <backends/WorkloadData.hpp> #include <backends/WorkloadFactory.hpp> namespace armnn { Pooling2dLayer::Pooling2dLayer(const Pooling2dDescriptor& param, const char* name) : LayerWithParameters(1, 1, LayerType::Pooling2d, param, name) { } std::unique_ptr<IWorkload> Pooling2dLayer::CreateWorkload(const Graph& graph, const IWorkloadFactory& factory) const { Pooling2dQueueDescriptor descriptor; return factory.CreatePooling2d(descriptor, PrepInfoAndDesc(descriptor, graph)); } Pooling2dLayer* Pooling2dLayer::Clone(Graph& graph) const { return CloneBase<Pooling2dLayer>(graph, m_Param, GetName()); } void Pooling2dLayer::ValidateTensorShapesFromInputs() { ConditionalThrow<LayerValidationException>(GetInputSlot(0).GetConnection() != nullptr, "Pooling2dLayer: InputSlot must be connected to an OutputSlot"); ConditionalThrow<LayerValidationException>(GetInputSlot(0).GetConnection()->IsTensorInfoSet(), "Pooling2dLayer: TensorInfo must be set on connected InputSlot."); IOutputSlot* input = GetInputSlot(0).GetConnection(); const TensorShape& inputShape = input->GetTensorInfo().GetShape(); // If we support multiple batch dimensions in the future, then this assert will need to change. BOOST_ASSERT_MSG(inputShape.GetNumDimensions() == 4, "Pooling2dLayer will always have 4D input."); unsigned int inWidth = inputShape[3]; unsigned int inHeight = inputShape[2]; unsigned int inChannels = inputShape[1]; unsigned int inBatchSize = inputShape[0]; bool isGlobalPooling = (m_Param.m_StrideX==0 && m_Param.m_StrideY==0); unsigned int outWidth = 1; unsigned int outHeight = 1; if (!isGlobalPooling) { BOOST_ASSERT_MSG(m_Param.m_StrideX!=0 && m_Param.m_StrideY!=0, "Stride can only be zero when performing global pooling"); auto CalcSize = [](auto inSize, auto lowPad, auto highPad, auto poolSize, auto stride, auto padMethod, auto outputShapeRounding) { unsigned int readSize = inSize + lowPad + highPad - poolSize; float div = static_cast<float>(readSize) / static_cast<float>(stride); unsigned int size = 0; switch (outputShapeRounding) { case OutputShapeRounding::Ceiling: size = static_cast<unsigned int>(ceil(div)) + 1; break; case OutputShapeRounding ::Floor: size = static_cast<unsigned int>(floor(div)) + 1; break; default: BOOST_ASSERT_MSG(false, "Unsupported Output Shape Rounding"); } // Make sure that border operations will start from inside the input and not the padded area // This is what both Caffe and CL does... if ((size - 1)*stride >= inSize + lowPad) { --size; } return size; }; outWidth = CalcSize(inWidth, m_Param.m_PadLeft, m_Param.m_PadRight, m_Param.m_PoolWidth, m_Param.m_StrideX, m_Param.m_PaddingMethod, m_Param.m_OutputShapeRounding); outHeight= CalcSize(inHeight, m_Param.m_PadTop, m_Param.m_PadBottom, m_Param.m_PoolHeight, m_Param.m_StrideY, m_Param.m_PaddingMethod, m_Param.m_OutputShapeRounding); } unsigned int outChannels = inChannels; unsigned int outBatchSize = inBatchSize; TensorShape shapeOut({outBatchSize, outChannels, outHeight, outWidth}); ConditionalThrowIfNotEqual<LayerValidationException>( "Pooling2dLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.", GetOutputSlot(0).GetTensorInfo().GetShape(), shapeOut); } } // namespace armnn