blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
39ccb9a0d8afe2214c66e6c265c75ad72fe4f199
1a9cba53b236b74c3bef5a9f0f7f1b699e0dc77a
/plugins/GSdx/GSDevice7.h
2afbce261feb286bf341feb68d8d3697e42b21c2
[]
no_license
EmulatorArchive/pcsx2-rr
75cd482c7f49bb805ffcfbd2a727dc8c8c0bec4c
d14877c363dcb36bca9fffc91987898626e28d05
refs/heads/master
2020-04-23T21:08:53.767347
2015-03-17T05:17:42
2015-03-17T05:17:42
32,372,289
2
1
null
null
null
null
UTF-8
C++
false
false
1,975
h
GSDevice7.h
/* * Copyright (C) 2007-2009 Gabest * http://www.gabest.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #pragma once #include "GSDevice.h" #include "GSTexture7.h" class GSDevice7 : public GSDevice<GSTexture7> { public: typedef GSTexture7 Texture; private: CComPtr<IDirectDraw7> m_dd; CComPtr<IDirectDrawSurface7> m_primary; CComPtr<IDirectDrawSurface7> m_backbuffer; bool Create(int type, Texture& t, int w, int h, int format); void DoMerge(Texture* st, GSVector4* sr, GSVector4* dr, Texture& dt, bool slbg, bool mmod, GSVector4& c); void DoInterlace(Texture& st, Texture& dt, int shader, bool linear, float yoffset = 0); public: GSDevice7(); virtual ~GSDevice7(); bool Create(HWND hWnd, bool vsync); bool Reset(int w, int h, bool fs); bool IsLost() {return false;} void Present(const CRect& r); void BeginScene() {} void EndScene() {} void Draw(LPCTSTR str) {} bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0) {return false;} void ClearRenderTarget(Texture& t, const GSVector4& c) {} void ClearRenderTarget(Texture& t, DWORD c) {} void ClearDepth(Texture& t, float c) {} void ClearStencil(Texture& t, BYTE c) {} };
8f0cff646ee2726286196358207149fc4ac7143e
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_17074.cpp
19c811b38b82ed11febaa7c98eff66fad7f41e26
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
287
cpp
Kitware_CMake_repos_basic_block_block_17074.cpp
{ ret = __archive_write_output(a, pax->sparse_map.s, archive_strlen(&(pax->sparse_map))); if (ret != ARCHIVE_OK) return (ret); ret = __archive_write_nulls(a, pax->sparse_map_padding); if (ret != ARCHIVE_OK) return (ret); archive_string_empty(&(pax->sparse_map)); }
475d0290bed11da654ca3b749734c09feeb27e44
f22f1c9b9f0265295be7cb83433fcba66b620776
/native/include/src/main/include/jcpp/native/api/io/NativeIOFactory.h
c3418211249e9ac845815c60115027debe811759
[]
no_license
egelor/jcpp-1
63c72c3257b52b37a952344a62fa43882247ba6e
9b5a180b00890d375d2e8a13b74ab5039ac4388c
refs/heads/master
2021-05-09T03:46:22.585245
2015-08-07T16:04:20
2015-08-07T16:04:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,168
h
NativeIOFactory.h
#ifndef JCPP_NATIVE_API_IO_NATIVEIOFACTORY #define JCPP_NATIVE_API_IO_NATIVEIOFACTORY #include "jcpp/native/api/io/NativeFileInputStream.h" #include "jcpp/native/api/io/NativeFileOutputStream.h" #include "jcpp/native/api/NativeString.h" namespace jcpp { namespace native { namespace api { class NativeFactory; } } } namespace jcpp { namespace native { namespace api { namespace io { class JCPP_EXPORT NativeIOFactory { friend class jcpp::native::api::NativeFactory; private: static NativeIOFactory * instance; protected: NativeIOFactory(); static NativeIOFactory * getInstance(); static void setInstance(NativeIOFactory * instance); public: virtual ~NativeIOFactory(); virtual NativeInputStream * getStandardInputStream() = 0; virtual NativeOutputStream * getStandardOutputStream() = 0; virtual NativeOutputStream * getStandardErrorStream() = 0; virtual NativeFileInputStream * createFileInputStream(const NativeString& path) = 0; virtual NativeFileOutputStream * createFileOutputStream(const NativeString& path, jbool append = false) = 0; }; } } } } #endif
8f9138bab6bc10315c28c0245072bee821f5ef9f
fe413f8747ddddc011f4dd6783cc084881da870a
/Code/application/Gui/.svn/text-base/OverviewWindow.cpp.svn-base
293178406310a46b362cc7d2ea1764f4db0855af
[]
no_license
GRSEB9S/opticks-cmake
f070b7ee32e5fff03de673c178cd6894113bc50b
497f89ccbcbf50c83304606eb586302eec3e6651
refs/heads/master
2021-05-27T08:16:26.027755
2011-08-13T06:03:04
2011-08-13T06:03:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,737
OverviewWindow.cpp.svn-base
/* * The information in this file is * Copyright(c) 2007 Ball Aerospace & Technologies Corporation * and is subject to the terms and conditions of the * GNU Lesser General Public License Version 2.1 * The license text is available from * http://www.gnu.org/licenses/lgpl.html */ #include <QtCore/QEvent> #include <QtCore/QFileInfo> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QClipboard> #include <QtGui/QColor> #include <QtGui/QColorDialog> #include <QtGui/QContextMenuEvent> #include <QtGui/QIcon> #include <QtGui/QInputDialog> #include <QtGui/QMenu> #include <QtGui/QVBoxLayout> #include "AnnotationElementAdapter.h" #include "AnnotationLayerAdapter.h" #include "AppVerify.h" #include "DataDescriptorAdapter.h" #include "DataElementImp.h" #include "DesktopServices.h" #include "glCommon.h" #include "Layer.h" #include "LayerList.h" #include "OverviewWindow.h" #include "RasterElement.h" #include "RasterDataDescriptor.h" #include "SpatialDataViewImp.h" #include "SpatialDataWindow.h" #include "TrailObject.h" #include "TrailObjectImp.h" #include "ZoomPanWidget.h" using namespace std; OverviewWindow::OverviewWindow(SpatialDataViewImp* pView, QWidget* parent) : QDialog(parent), mpView(pView), mpOverview(NULL), mpSelectionWidget(NULL), mpTrailLayer(NULL), mpTrail(NULL), mZoomThreshold(100) { // get trail defaults from ConfigurationSettings mTrailColor = SpatialDataWindow::getSettingOverviewTrailColor(); mZoomThreshold = SpatialDataWindow::getSettingOverviewTrailThreshold(); // View widget mpOverview = createOverview(); mpSelectionWidget = new ZoomPanWidget(mpOverview, this); // Overview trail object mpTrail = createSnailTrail(mpOverview); // Context menu Service<DesktopServices> pDesktop; string shortcutContext = "Overview Window"; QAction* pClearAction = new QAction("Clear the Trail", this); pClearAction->setAutoRepeat(false); pDesktop->initializeAction(pClearAction, shortcutContext); addAction(pClearAction); QAction* pSeparatorAction = new QAction(this); pSeparatorAction->setSeparator(true); addAction(pSeparatorAction); QAction* pColorAction = new QAction("Change Trail color...", this); pColorAction->setAutoRepeat(false); pDesktop->initializeAction(pColorAction, shortcutContext); addAction(pColorAction); QAction* pOpacityAction = new QAction("Change Trail opacity...", this); pOpacityAction->setAutoRepeat(false); pDesktop->initializeAction(pOpacityAction, shortcutContext); addAction(pOpacityAction); QAction* pThresholdAction = new QAction("Change zoom threshold...", this); pThresholdAction->setAutoRepeat(false); pDesktop->initializeAction(pThresholdAction, shortcutContext); addAction(pThresholdAction); QAction* pSeparator2Action = new QAction(this); pSeparator2Action->setSeparator(true); addAction(pSeparator2Action); QAction* pSnapshotAction = new QAction("Take a snapshot", this); pSnapshotAction->setAutoRepeat(false); pSnapshotAction->setShortcut(QKeySequence("Ctrl+Shift+C")); pSnapshotAction->setToolTip("Take a snapshot"); pSnapshotAction->setStatusTip("Copies a snapshot of the view into the clipboard"); addAction(pSnapshotAction); // Layout QVBoxLayout* pLayout = new QVBoxLayout(this); pLayout->setMargin(0); pLayout->setSpacing(0); pLayout->addWidget(mpSelectionWidget, 10); // Initialization setModal(false); setContextMenuPolicy(Qt::DefaultContextMenu); setMinimumSize(200, 200); int maxWidth = 400; int maxHeight = 400; setMaximumSize(maxWidth, maxHeight); updateSelectionBox(); if (mpTrail != NULL) { mpTrail->setStencilBufferSize(maxWidth, maxHeight); } const std::vector<LocationType> selectionBox = mpSelectionWidget->getSelection(); updateView(selectionBox); // Set the window icon if (mpView != NULL) { QIcon viewIcon = mpView->windowIcon(); if (viewIcon.isNull() == false) { setWindowIcon(viewIcon); } } // Set the caption of the dialog QString strCaption = "Overview"; if (mpView != NULL) { QString strName = QString::fromStdString(mpView->getName()); if (strName.isEmpty() == false) { QFileInfo fileInfo(strName); QString strFilename = fileInfo.fileName(); if (strFilename.isEmpty() == false) { strCaption += ": " + strFilename; } } } setWindowTitle(strCaption); // Connections VERIFYNR(connect(mpSelectionWidget, SIGNAL(selectionChanged(const std::vector<LocationType>&)), this, SLOT(updateView(const std::vector<LocationType>&)))); VERIFYNR(connect(mpView, SIGNAL(displayAreaChanged()), this, SLOT(updateSelectionBox()))); VERIFYNR(connect(pClearAction, SIGNAL(triggered()), this, SLOT(clearTrail()))); VERIFYNR(connect(pColorAction, SIGNAL(triggered()), this, SLOT(changeTrailColor()))); VERIFYNR(connect(pOpacityAction, SIGNAL(triggered()), this, SLOT(changeTrailOpacity()))); VERIFYNR(connect(pThresholdAction, SIGNAL(triggered()), this, SLOT(changeTrailThreshold()))); VERIFYNR(connect(pSnapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapshot()))); } OverviewWindow::~OverviewWindow() { // Destroy the annotation layer and element if (mpTrailLayer != NULL) { DataElementImp* pElement = dynamic_cast<DataElementImp*>(mpTrailLayer->getDataElement()); mpOverview->deleteLayer(mpTrailLayer); delete pElement; } } bool OverviewWindow::eventFilter(QObject* o, QEvent* e) { if ((e->type() == QEvent::MouseButtonDblClick) || (e->type() == QEvent::Wheel)) { return true; } else if (e->type() == QEvent::ContextMenu) { QContextMenuEvent* pMenuEvent = static_cast<QContextMenuEvent*>(e); contextMenuEvent(pMenuEvent); return true; } return QDialog::eventFilter(o, e); } void OverviewWindow::showEvent(QShowEvent* e) { QDialog::showEvent(e); if (mpSelectionWidget != NULL) { mpSelectionWidget->zoomExtents(); } clearTrail(); emit visibilityChanged(true); } void OverviewWindow::resizeEvent(QResizeEvent* e) { QDialog::resizeEvent(e); if (mpSelectionWidget != NULL) { mpSelectionWidget->zoomExtents(); } clearTrail(); } void OverviewWindow::closeEvent(QCloseEvent* e) { QDialog::closeEvent(e); emit visibilityChanged(false); } void OverviewWindow::contextMenuEvent(QContextMenuEvent* pEvent) { if (pEvent != NULL) { const QPoint& menuPos = pEvent->globalPos(); QMenu::exec(actions(), menuPos); } } SpatialDataViewImp* OverviewWindow::createOverview() { SpatialDataViewImp* pOverview = NULL; if (mpView != NULL) { pOverview = dynamic_cast<SpatialDataViewImp*>(mpView->copy()); VERIFYRV(pOverview != NULL, NULL); pOverview->installEventFilter(this); LayerList* pLayerList = NULL; pLayerList = pOverview->getLayerList(); if (pLayerList != NULL) { // get primary raster layer from data view LayerList* pSDVlist = mpView->getLayerList(); VERIFYRV(pSDVlist != NULL, NULL); DataElement* pPrimElem = pSDVlist->getPrimaryRasterElement(); VERIFYRV(pPrimElem != NULL, NULL); Layer* pPrimLayer = pSDVlist->getLayer(RASTER, pPrimElem); VERIFYRV(pPrimLayer != NULL, NULL); string primName(pPrimLayer->getName()); vector<Layer*> layers; pLayerList->getLayers(layers); for (unsigned int i = 0; i < layers.size(); i++) { Layer* pLayer = NULL; pLayer = layers.at(i); string layerName(pLayer->getName()); if (pLayer->getLayerType()==RASTER && layerName==primName) { pPrimLayer->linkLayer(pLayer); // reset the scale to what is in the model DataElement* pElement = pLayer->getDataElement(); VERIFYRV(pElement != NULL, NULL); const RasterDataDescriptor* pDescriptor = dynamic_cast<const RasterDataDescriptor*>(pElement->getDataDescriptor()); VERIFYRV(pDescriptor != NULL, NULL); pLayer->setYScaleFactor(pDescriptor->getYPixelSize()); pLayer->setXScaleFactor(pDescriptor->getXPixelSize()); } else { pOverview->deleteLayer(pLayer); } } pOverview->resetOrientation(); } } return pOverview; } void OverviewWindow::updateView(const vector<LocationType>& selectionArea) { if ((mpView == NULL) || (selectionArea.size() != 4)) { return; } LayerList* pLayerList = mpView->getLayerList(); VERIFYNRV(pLayerList != NULL); Layer* pLayer = pLayerList->getLayer(RASTER, pLayerList->getPrimaryRasterElement()); VERIFYNRV(pLayer != NULL); LocationType worldLl; LocationType worldUr; pLayer->translateDataToWorld(selectionArea[0].mX, selectionArea[0].mY, worldLl.mX, worldLl.mY); pLayer->translateDataToWorld(selectionArea[2].mX, selectionArea[2].mY, worldUr.mX, worldUr.mY); // Update the view mpView->zoomToBox(worldLl, worldUr); mpView->updateGL(); } void OverviewWindow::updateSelectionBox() { if ((mpView == NULL) || (mpSelectionWidget == NULL)) { return; } // Get the pixel coordinates at the view corners LocationType lowerLeft; LocationType upperLeft; LocationType upperRight; LocationType lowerRight; mpView->getVisibleCorners(lowerLeft, upperLeft, upperRight, lowerRight); // Disconnect the signal to update the view since the values are obtained from the view disconnect(mpSelectionWidget, SIGNAL(selectionChanged(const std::vector<LocationType>&)), this, SLOT(updateView(const std::vector<LocationType>&))); LayerList* pLayerList = mpView->getLayerList(); VERIFYNRV(pLayerList != NULL); Layer* pLayer = pLayerList->getLayer(RASTER, pLayerList->getPrimaryRasterElement()); VERIFYNRV(pLayer != NULL); // Set the selection area vector<LocationType> selectionArea; LocationType dataCoord; pLayer->translateWorldToData(lowerLeft.mX, lowerLeft.mY, dataCoord.mX, dataCoord.mY); selectionArea.push_back(dataCoord); pLayer->translateWorldToData(lowerRight.mX, lowerRight.mY, dataCoord.mX, dataCoord.mY); selectionArea.push_back(dataCoord); pLayer->translateWorldToData(upperRight.mX, upperRight.mY, dataCoord.mX, dataCoord.mY); selectionArea.push_back(dataCoord); pLayer->translateWorldToData(upperLeft.mX, upperLeft.mY, dataCoord.mX, dataCoord.mY); selectionArea.push_back(dataCoord); // update snail trail if zoom factor greater than or equal zoom threshold if ((mpTrail != NULL) && (static_cast<int>(mpView->getZoomPercentage() + 0.5) >= mZoomThreshold)) { // Translate each point into a screen location if (mpOverview != NULL) { mpOverview->translateWorldToScreen(lowerLeft.mX, lowerLeft.mY, lowerLeft.mX, lowerLeft.mY); mpOverview->translateWorldToScreen(lowerRight.mX, lowerRight.mY, lowerRight.mX, lowerRight.mY); mpOverview->translateWorldToScreen(upperLeft.mX, upperLeft.mY, upperLeft.mX, upperLeft.mY); mpOverview->translateWorldToScreen(upperRight.mX, upperRight.mY, upperRight.mX, upperRight.mY); mpTrail->addToStencil(lowerLeft, lowerRight, upperLeft, upperRight); } } mpSelectionWidget->setSelection(selectionArea); // Reconnect the signal to update the view connect(mpSelectionWidget, SIGNAL(selectionChanged(const std::vector<LocationType>&)), this, SLOT(updateView(const std::vector<LocationType>&))); } TrailObjectImp* OverviewWindow::createSnailTrail(SpatialDataViewImp* pOverview) { VERIFYRV(pOverview != NULL, NULL); // Annotation layer DataDescriptorAdapter descriptor("Snail Trail", "AnnotationElement", NULL); mpTrailLayer = new AnnotationLayerAdapter(SessionItemImp::generateUniqueId(), "Snail Trail", new AnnotationElementAdapter(descriptor, SessionItemImp::generateUniqueId())); pOverview->addLayer(mpTrailLayer); TrailObjectImp* pTrailImp(NULL); if (mpTrailLayer != NULL) { TrailObject* pTrail = dynamic_cast<TrailObject*>(mpTrailLayer->addObject(TRAIL_OBJECT)); VERIFYRV(pTrail != NULL, NULL); double minX; double minY; double maxX; double maxY; pOverview->getExtents(minX, minY, maxX, maxY); pTrail->setAlpha(0.3); pTrail->setBoundingBox(LocationType(minX, minY), LocationType(maxX, maxY)); pTrail->setFillStyle(SOLID_FILL); pTrail->setHatchStyle(SOLID); pTrail->setFillState(true); pTrail->setLineState(false); pTrail->setFillColor(mTrailColor); pTrailImp = dynamic_cast<TrailObjectImp*>(pTrail); } return pTrailImp; } void OverviewWindow::changeTrailColor() { QColor oldColor = COLORTYPE_TO_QCOLOR(mTrailColor); QColor newColor = QColorDialog::getColor(oldColor, this); if (newColor.isValid()) { mTrailColor.mRed = newColor.red(); mTrailColor.mGreen = newColor.green(); mTrailColor.mBlue = newColor.blue(); mpTrail->setFillColor(mTrailColor); updateSelectionBox(); } } void OverviewWindow::clearTrail() { if (mpTrail != NULL) { mpTrail->clearStencil(); updateSelectionBox(); } } void OverviewWindow::changeTrailOpacity() { int oldAlpha = static_cast<int>(mTrailColor.mAlpha / 2.550f + 0.5); bool bOk; int newAlpha = QInputDialog::getInteger(this, "Set Overview Trail Opacity", "Set from 0% (transparent) to 100% (opaque)", oldAlpha, 0, 100, 1, &bOk); if (bOk) { newAlpha = static_cast<int>(newAlpha * 2.550f + 0.5); if (newAlpha > 255) { newAlpha = 255; } if (newAlpha < 0) { newAlpha = 0; } mTrailColor.mAlpha = newAlpha; mpTrail->setFillColor(mTrailColor); updateSelectionBox(); } } void OverviewWindow::changeTrailThreshold() { bool bOk; int newZoom = QInputDialog::getInteger(this, "Set Trail Zoom Threshold", "Set lowest zoom percentage for marking Trail.\nThis action will reset the Overview Trail.", mZoomThreshold, 1, 1000, 10, &bOk); if (bOk) { mZoomThreshold = newZoom; clearTrail(); } } void OverviewWindow::takeSnapshot() { View* pView = dynamic_cast<View*>(mpOverview); if (pView != NULL) { QImage image; pView->getCurrentImage(image); if (image.isNull() == false) { QClipboard* pClipboard = QApplication::clipboard(); pClipboard->setImage(image); } } }
ffeb6a730846ae2c4da09f78cdabe917dc7dec61
70418d8faa76b41715c707c54a8b0cddfb393fb3
/1089.cpp
9bcf117c68e9acd16ca98b20b13f242a4582392b
[]
no_license
evandrix/UVa
ca79c25c8bf28e9e05cae8414f52236dc5ac1c68
17a902ece2457c8cb0ee70c320bf0583c0f9a4ce
refs/heads/master
2021-06-05T01:44:17.908960
2017-10-22T18:59:42
2017-10-22T18:59:42
107,893,680
3
1
null
null
null
null
UTF-8
C++
false
false
1,996
cpp
1089.cpp
#include <bits/stdc++.h> using namespace std; #define MP make_pair #define PI pair #define FI first #define SE second #define PB push_back #define SZ size() const double eps = 1e-10; const double pi = acos(-1.); const int mod = 1000000007; const int maxn = 100100; const long long INF = ((1LL) << 60); vector<PI<string, string>> g; vector<string> word, u; map<string, int> dic[22]; long long dis[22][220][220]; void init(int len) { set<string> S; for (int i = 0; i < word.SZ; ++i) if (word[i].SZ >= len) { S.insert(word[i].substr(word[i].SZ - len)); } u = vector<string>(S.begin(), S.end()); dic[len].clear(); for (int i = 0; i < u.SZ; ++i) { dic[len][u[i]] = i; } } void dp(int d) { for (int i = 0; i < u.SZ; ++i) { for (int j = 0; j < u.SZ; ++j) { dis[d][i][j] = INF; } dis[d][i][i] = 0; } for (int i = 0; i < g.SZ; ++i) if (g[i].FI.SZ == d) { int x = dic[d][g[i].FI]; int y = dic[d][g[i].SE]; dis[d][x][y] = min(dis[d][x][y], 1LL); } if (d > 1) { for (int i = 0; i < u.SZ; ++i) for (int j = 0; j < u.SZ; ++j) if (u[i][0] == u[j][0]) { int x = dic[d - 1][u[i].substr(1)]; int y = dic[d - 1][u[j].substr(1)]; dis[d][i][j] = min(dis[d][i][j], dis[d - 1][x][y]); } } for (int k = 0; k < u.SZ; ++k) for (int i = 0; i < u.SZ; ++i) for (int j = 0; j < u.SZ; ++j) { dis[d][i][j] = min(dis[d][i][j], dis[d][i][k] + dis[d][k][j]); } } int main() { int T, cases = 1; int i, j, k, n; string SS, TT, a, b; while (cin >> SS && SS != ".") { cin >> TT >> n; g.clear(); word.clear(); for (i = 0; i < n; ++i) { cin >> a >> b; g.PB(MP(a, b)); word.PB(a); word.PB(b); } word.PB(SS); word.PB(TT); for (i = 1; i <= SS.SZ; ++i) { init(i); dp(i); } i = dic[SS.SZ][SS]; j = dic[SS.SZ][TT]; if (dis[SS.SZ][i][j] == INF) { printf("Case %d: No solution\n", cases++); } else { printf("Case %d: %lld\n", cases++, dis[SS.SZ][i][j]); } } return 0; }
b4a54d3acde448a28bfbe83ef8381414bb3244aa
89df1ea7703a7d64ed2549027353b9f98b800e88
/engine_test/shader_tests/src/graphics/renderer/2D/renderer_2D.h
1f91b7e42dc95ba3acca101fcaf0428797cc1b73
[ "MIT" ]
permissive
llGuy/gamedev
31a3e23f921fbe38af48177710eb7bae661f4cfd
16aa203934fd767926c58558e021630288556399
refs/heads/master
2021-05-04T15:09:33.217825
2019-01-17T23:15:36
2019-01-17T23:15:36
120,221,445
0
0
null
null
null
null
UTF-8
C++
false
false
866
h
renderer_2D.h
#pragma once #include <array> #include <glm/glm.hpp> #include "../../../api/api.h" #include "../../mesh/mesh_handler.h" struct vertex2D { glm::vec2 pos; glm::vec2 tex_coord; }; class renderer_2D { protected: u32 mesh_id; std::unique_ptr<render_func> draw; std::vector<pre_render_ptr> pre_renders; public: virtual auto submit(std::array<vertex2D, 4> const & vertices) -> void = 0; virtual auto render(glsl_program & program, mesh_handler & mh) -> void = 0; virtual auto flush(void) -> void = 0; virtual ~renderer_2D(void) {}; auto set_mesh(u32 mesh_id, mesh_handler & mh) -> void; inline auto submit_pre_render(renderer_pre_render * const pre_render, bool on_heap = true) { pre_renders.push_back(pre_render_ptr{ on_heap, pre_render }); } private: inline auto set_rf(std::unique_ptr<render_func> & func) -> void { draw = std::move(func); } };
172430e5cf6f719f51d241e22480a76cb75119b5
fed9f14edb87cd975ac946e01e063df492a9929a
/src/arc/038/B.cpp
79f651d7ed0306d45086280a26d13f429bc50f5d
[]
no_license
n-inja/kyoupro
ba91dd582488b2a8c7222242801cf3115ed7fd10
44c5a888984764b98e105780ca57d522a47d832d
refs/heads/master
2021-01-01T06:52:59.655419
2020-10-17T13:28:35
2020-10-17T13:28:35
97,537,227
0
0
null
null
null
null
UTF-8
C++
false
false
1,046
cpp
B.cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; int hx[3] = {0, 1, 1}; int hy[3] = {1, 0, 1}; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int h, w; cin >> h >> w; vector<string> mp(h + 1); for (int i = 0; i < h; i++) { cin >> mp[i]; mp[i].push_back('#'); } mp[h] = string(w + 1, '#'); vector<vector<int>> memo(h + 1, vector<int>(w + 1, -1)); function<int(int, int)> dfs; dfs = [&](int i, int j) { if (memo[i][j] >= 0) return memo[i][j]; if (mp[i][j] == '#') return 2; vector<int> s; for (int k = 0; k < 3; k++) { int r = dfs(i + hx[k], j + hy[k]); if (r == 2) continue; s.push_back(r); } if (s.size() == 0) return memo[i][j] = 0; if (*min_element(s.begin(), s.end()) == 0) return memo[i][j] = 1; return memo[i][j] = 0; }; if (dfs(0, 0)) cout << "First" << endl; else cout << "Second" << endl; return 0; }
6c4e80e3124fd8086b6dba4f1e7b71b530741ccc
5a922f5803f004f07746d6f7ddb6d56f2dc59b3e
/VoxViz/GigaVoxels/GigaVoxelsDatabasePager.h
ab9abfc032ab32570ff75def037da1b97ff3ece4
[ "MIT" ]
permissive
ichild1994/VoxVizThesis
a7514b8b7d1d71edcc7d0bf011e8691fc9d0ff1e
43aeb666cc9f5005d9ec5b81acd4cc38aae0e0fd
refs/heads/master
2021-06-22T11:10:14.160772
2017-08-21T17:07:42
2017-08-21T17:07:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,647
h
GigaVoxelsDatabasePager.h
#ifndef GIGA_VOXELS_PAGER_H #define GIGA_VOXELS_PAGER_H #include "GigaVoxels/GigaVoxelsSceneGraph.h" #include "GigaVoxels/GigaVoxelsOctTree.h" #include "GigaVoxels/GigaVoxelsDebugRenderer.h" #include "VoxVizCore/Referenced.h" #include "VoxVizCore/SmartPtr.h" #include <set> #include <list> #include <QtCore/QThread> #include <QtCore/QMutex> #include <QtCore/QWaitCondition> namespace gv { class DatabasePagerThread; class DatabasePager : public vox::Referenced { public: static DatabasePager& instance(); void start(void* pRenderingCtx, int vpWidth, int vpHeight); static void kill(); void requestLoadOctTree(PagedOctTreeNode& node, float distToNearPlane); void mergeHandledRequests(GigaVoxelsDebugRenderer* pDebugRenderer); void unloadStalePagedOctTreeNodes(size_t curFrameIndex, GigaVoxelsDebugRenderer* pDebugRenderer); void getBrickUploadRequests(GigaVoxelsOctTree::UploadRequestList& brickUploadRequestList); enum State { INIT, WAITING, LOADING, EXITING }; void getStatus(DatabasePager::State& state, size_t& numPendingLoad, size_t& numActive, size_t& maxLoadTimeMs, size_t& minLoadTimeMs, float& avgLoadTimeMs) const; protected: DatabasePager(); DatabasePager(const DatabasePager&); ~DatabasePager(); private: DatabasePagerThread* m_pPagerThread; }; } #endif
b1b1a385d5f5c2841d4a13c5d2d3f693c1123052
0bbce01e6175411a6ae100bb88bd57efec776d3f
/main.cpp
bd9fca0a0eeceb6f2deda79a009caa99f836193d
[]
no_license
zoubirabde9a/ZScripts
5566e537b33ae72f7ff325ff73312d9399e1a8a6
0c1f650e099abab048ecd8b6ef7d8878998b1fec
refs/heads/main
2023-06-25T08:50:23.930250
2021-07-25T12:44:17
2021-07-25T12:44:17
389,331,564
0
0
null
null
null
null
UTF-8
C++
false
false
1,396
cpp
main.cpp
#include "ZScriptFunctions.h" #include <stdlib.h> using namespace ZScript; void executeScript(const std::string& text) { std::vector < StmtPtr > stmt; parseBuffer(stmt, text); ZScript::Interpreter interpreter; interpreter.interpret(stmt); } int myFunction(int a, int b) { return a + b - 1; } void interpret(Interpreter &ptr, const std::string &script) { std::vector < StmtPtr > stmt; parseBuffer(stmt, script); ptr.interpret(stmt); } class MyClass { public: MyClass(int a, int b) : a(a), b(b) {} int a; int b; void doSomething() { printf("i did something a=%d, b=%d\n", a, b); } }; int main() { printf("---Test 1---- Simple Scripts \n"); // Simple Scripts executeScript("print 1"); executeScript("var a = 10; print a"); executeScript("var b = 5; var c = 3; print b + c"); printf("---Test 2---- Register C++ Function to Intepreter\n"); // Register C++ Function to Intepreter ZScript::Interpreter interpreter; interpreter.subscribeFunction("myFunction", myFunction); interpret(interpreter, "print myFunction(10, 20)"); printf("---Test 3---- Register C++ Class To Interpreter\n"); // Register C++ Class To Interpreter interpreter.subscribeClass<MyClass>("MyClass") .addFunction("doSomething", &MyClass::doSomething); MyClass foo(2, 5); interpreter.getGlobalEnvironement()->define("foo", &foo); interpret(interpreter, "foo.doSomething()"); getchar(); }
97d9b3d092b852cb7496d35dc92bf857b5851fa8
980d930f35a033bc4225aeae3ac4455395398523
/task 2/main.cpp
cced81547a1a99cc3a0e4c1e3839b35a4bab3a5b
[]
no_license
nazzrrg/diasoft-test-task
a9bc402af874f8afacfe47420cc4e675abcfe894
a8a46dd6fb0fa586fe212937b76095f61f2c22ea
refs/heads/main
2023-08-23T19:47:45.387226
2021-09-18T20:11:25
2021-09-18T20:11:25
407,872,836
0
0
null
null
null
null
UTF-8
C++
false
false
945
cpp
main.cpp
#include <iostream> #include <string> #include <codecvt> #include <locale.h> using namespace std; wstring utf8_to_wstring (const string& str) { wstring_convert<codecvt_utf8<wchar_t>> conv; return conv.from_bytes(str); } string wstring_to_utf8 (const wstring& str) { wstring_convert<codecvt_utf8<wchar_t>> conv; return conv.to_bytes(str); } int main(int argc, char **argv) { locale::global(locale("")); if (argc != 3) { cerr << "Incorrect number of arguments!" << endl; exit(1); } int n = stoi(argv[1]); string str = string(argv[2]); wstring wstr = utf8_to_wstring(str); wstring result; if (n >= wstr.size()) { result = wstring(n - wstr.length(), ' ') + wstr; } else { result = wstr.substr(wstr.length() - n, n); } transform(result.begin(), result.end(), result.begin(), towupper); cout << wstring_to_utf8(result) << endl; return 0; }
30142dd99048526b163848ced6714cdbecc8c6b7
2fcee87709417717620d2ca4131f96e29c0bc320
/Codeforces/Algorithm-Lab/QuickHull.cpp
eaa22da0639966711fc9bc9df86e168d73e32a7d
[]
no_license
Jaminur-Rashid/Problem-Solving
7b502b03c5eea180282adcaad1b74ab526c92f12
c651c9e810dba6a8f4b1ece6a3c27554d4a49ac0
refs/heads/master
2023-07-27T15:22:14.744541
2021-09-09T12:13:13
2021-09-09T12:13:13
404,700,331
1
0
null
null
null
null
UTF-8
C++
false
false
1,784
cpp
QuickHull.cpp
#include<bits/stdc++.h> using namespace std; #define pa pair<int,int> vector< pair<int ,int> >vec,st; int n; //set<pair<int,int> >st; int findSide(int mn,int mx,int indx){ int dist=(((vec[indx].second-vec[mn].second)*(vec[mx].first-vec[mn].first))-((vec[indx].first-vec[mn].first)*(vec[mx].second-vec[mn].second))); if(dist<0){ return -1; } else{ return 1; } //return 0; } int lineDist(int mn,int mx,int indx){ int dist=(((vec[indx].second-vec[mn].second)*(vec[mx].first-vec[mn].first))-((vec[indx].first-vec[mn].first)*(vec[mx].second-vec[mn].second))); return (abs(dist)); } void quickHull(int mn,int mx,int side){ int index=-1; int max_dist=0; for(int i=0;i<n;i++){ int tmp=lineDist(mn,mx,i); int dir=findSide(mn,mx,i); if(dir==side&&tmp>max_dist){ index=i; max_dist=tmp; } cout<<tmp<<" "<<dir<<endl; } if(index==-1){ st.push_back(make_pair(vec[mn].first,vec[mn].second)); st.push_back(make_pair(vec[mx].first,vec[mx].second)); return; } quickHull(index, mn,findSide(mn,mx,index)); quickHull(index,mx,findSide(mn,mx,index)); } void printHull(){ if(n<3){ cout<<"Convex Hull is Not Possible"<<endl; } int min_x=0,max_x=0; for(int i=1;i<n;i++){ if(vec[i].first<vec[min_x].first){ min_x=i; } if(vec[i].first>vec[max_x].first){ max_x=i; } } cout<<vec[min_x].first<<" "<<vec[max_x].first<<endl; quickHull(min_x,max_x,1); quickHull(min_x,max_x,-1); for(int i=0;i<st.size();i++){ cout<<st[i].first<<" "<<st[i].second<<endl; } } int main(){ cin>>n; for(int i=0;i<n;i++){ int x,y; cin>>x>>y; vec.push_back(make_pair(x,y)); } for(int i=0;i<n;i++){ cout<<vec[i].first<<" "<<vec[i].second<<" "<<endl; } printHull(); }
7d0356ba62e1963ac9fd8f6e3b3db9573535b48a
20049d88e2e8f0e1904efc561103c1d84d21507a
/baboshina.elizaveta/A1/circle.cpp
eb549e33720561d4b2f9cc6b544631c2da0ee83d
[]
no_license
gogun/Labs-for-SPbSPU-C-course-during-2019
5442a69152add3e66f02a7541e8dc8dd817f38a1
16ade47b859517a48d0fdb2e9704464bce4cc355
refs/heads/master
2022-01-09T16:02:54.728830
2019-06-06T11:06:33
2019-06-06T11:06:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
737
cpp
circle.cpp
#define _USE_MATH_DEFINES #include "circle.hpp" #include <iostream> #include <cassert> #include <cmath> Circle::Circle(const point_t center, const double radius): center_(center), radius_(radius) { assert(radius > 0); } double Circle::getArea() const { return M_PI * radius_ * radius_; } rectangle_t Circle::getFrameRect() const { return { 2 * radius_, 2 * radius_, center_ }; } void Circle::move(const point_t point) { center_ = point; } void Circle::move(const double x, const double y) { center_.x += x; center_.y += y; } void Circle::getInfo() const { std::cout << "\nRadius of circle is: " << radius_ << std::endl; std::cout << "Center of circle is: x=" << center_.x << " y=" << center_.y << std::endl; }
cb36235df8fb2ec6fd2cb9607a015824d89ef08d
5fff98f4e23d83423b751fc677c318101ff3f3ee
/ps3b/body.hpp
e4a7d453ba39f9b92a3cd0afe127c9bea51923b6
[]
no_license
MichellemBettecourt/SolarSystemSimulation
7ebb6054328a20c697eb920ccf43c2143553bb9c
040700045e5c30b134ae0020337c72b0f3dc9d2c
refs/heads/master
2020-04-17T18:35:35.926939
2019-01-21T15:05:13
2019-01-21T15:05:13
166,832,778
0
0
null
null
null
null
UTF-8
C++
false
false
1,362
hpp
body.hpp
#ifndef BODY_H #define BODY_H #include <iostream> #include <SFML/Graphics.hpp> class Body : public sf::Drawable { public: Body(double w_size, double s) {window_size = w_size; scale = s;}; Body(double window_size, double radius, double x_pos, double y_pos, double x_vel, double y_vel, double grams, std::string filename); void step(std::vector<Body>& planets, unsigned int current_planet, double delta_time); double get_x_coordinate() {return x_coordinate;}; double get_y_coordinate() {return y_coordinate;}; double get_x_velocity() {return x_velocity;}; double get_y_velocity() {return x_velocity;}; double get_mass() {return mass;}; std::string get_filename() {return filename;}; ~Body() {}; friend std::istream& operator>>(std::istream& in, Body& arg); private: double get_hypotenuse(double other_x, double other_y); double get_gravitational_force(double mass1, double mass2, double hypotenuse); double get_netforce(double hypotenuse, double gravitational_force, double this_coordinate, double other_coordinate); virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const; double x_coordinate; double y_coordinate; double x_velocity; double y_velocity; std::string filename; sf::Image image; sf::Texture texture; sf::Sprite sprite; double mass; double scale; double window_size; }; #endif
932fb9f73c840edf6e92c834dc4623349f228cc4
ef1740ee3eba4b76d08ed7d875117c4906abac06
/src/rnaalifold_aln_rgn.cpp
2d41a4a5037af91d2b61cfa3c1a479ae7e6b0ef3
[]
no_license
Rossifumi/lncRNA_2way
30541ba273504dad37b6f709e37dc539e0b6429d
e80af54dbdaaa7285e8ec9535a2bcd90697953db
refs/heads/master
2021-01-19T00:36:56.608989
2016-11-10T14:41:16
2016-11-10T14:41:16
73,081,268
1
0
null
null
null
null
UTF-8
C++
false
false
2,754
cpp
rnaalifold_aln_rgn.cpp
#include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> #include <map> #include <set> #include <stdlib.h> using namespace std; vector<string> tokenize(string input_string, char delimiter) { vector<string> tokens; string::size_type start = 0; string::size_type end = 0; while ((end = input_string.find (delimiter, start)) != string::npos) { { string substring=input_string.substr (start, end-start); if (end != start) tokens.push_back (substring); } start = end + 1; } if (start==end-1) { tokens.push_back(""); } else { string substring=input_string.substr(start, end-start); tokens.push_back(substring); } return tokens; } int main(int argc, char** argv) { ifstream f_seq, f_aln;//, f2, f_ortho; ofstream f_foldin, f_foldout; string line; vector<string> toks; string name; char strand; vector<string> names, rgn2; map<string, string> seq1, seq2; map<string, int> len1, len2; f_seq.open(argv[1], ios::in); while (!f_seq.eof()){ getline(f_seq, line); if (line.compare("")) { if (line[0] == '>') { toks = tokenize(line, '\t'); name = toks[0].substr(1); names.push_back(name); //strand = toks[1][0]; } else { seq1[name] = line; len1[name] = line.length(); } } } f_seq.close(); string rm_cmd; rm_cmd.append("rm -f ").append(argv[3]).append(" ").append(argv[4]); system(rm_cmd.c_str()); string mkdir_cmd; mkdir_cmd.append("mkdir ").append(argv[4]); system(mkdir_cmd.c_str()); string RNAalifold_cmd; RNAalifold_cmd.append("RNAalifold --color in.aln >> ").append(argv[3]); int cc=0; f_aln.open(argv[2], ios::in); f_foldin.open("in.aln", ios::out); while (!f_aln.eof()){ getline(f_aln, line); if (line.compare("")) { toks = tokenize(line, ' '); if (!toks[0].compare("CLUSTAL")) { if (cc > 0) { f_foldout.open(argv[3], ios::app); f_foldout<<"### "<<names[cc-1]<<'\n'; f_foldout.close(); f_foldin.close(); system(RNAalifold_cmd.c_str()); f_foldout.open(argv[3], ios::app); f_foldout<<'\n'; f_foldout.close(); stringstream mv_cmd_ss; mv_cmd_ss<<"mv alirna.ps "<<argv[4]<<"/"<<cc<<".ps"; system(mv_cmd_ss.str().c_str()); f_foldin.open("in.aln", ios::out); } cc++; } } f_foldin<<line<<'\n'; } f_foldout.open(argv[3], ios::app); f_foldout<<"### "<<names[cc-1]<<'\n'; f_foldout.close(); f_foldin.close(); system(RNAalifold_cmd.c_str()); f_foldout.open(argv[3], ios::app); f_foldout<<'\n'; f_foldout.close(); stringstream mv_cmd_ss; mv_cmd_ss<<"mv alirna.ps "<<argv[4]<<"/"<<cc<<".ps"; system(mv_cmd_ss.str().c_str()); f_aln.close(); return 0; }
65b298cb7156124201971ee602b32a17534d0c94
513381a55f06f1016798175ffde872368985c8dd
/Projects/pp1/src/token.h
407879c1545ed5fc4453512c22aa03be4d3ed806
[]
no_license
dikshab/CPSC-221
66096eb378718bd041cc8eaba6133bbca73cae4b
23b6b1eca0ceff50d30cb3e2a19fcc755bed9bdc
refs/heads/master
2021-01-17T19:26:43.955974
2014-11-23T22:22:20
2014-11-23T22:22:20
35,469,310
1
1
null
2015-05-12T05:46:10
2015-05-12T05:46:10
null
UTF-8
C++
false
false
5,689
h
token.h
// token.h --- Simple class for the Token type used to represent // tokens produced as a Tokenizer consumes an input stream, // specifically for the Racka-Bracka-Stack project. // token.h is Copyright (C) 2014 by the University of British // Columbia, Some Rights Reserved. // // This work is licensed under the Creative Commons Attribution 4.0 // International License. To view a copy of this license, visit // http://creativecommons.org/licenses/by/4.0/. #ifndef RACKET_BRACKET_STACK_TOKEN_H_ #define RACKET_BRACKET_STACK_TOKEN_H_ #include <string> #include <ostream> namespace tokenizer { class Tokenizer; // These tokens are not "clever" at all; rely on the associated // tokenizer to work with them. // // Note that EVERY token type must reserve the token_type 0 for the // EOF token representing the end of an input stream. // // Note that two Tokens can be equal even if they come from different // file, line number, and column numbers. Lines and columns are // 1-based, not 0-based. class Token { public: // Constructs a token with the given components that defaults to no // designated source and an empty filename. Token(int token_type, std::string const & token_data, int start_line, int end_line, int start_column, int end_column) : Token(token_type, token_data, nullptr, start_line, end_line, start_column, end_column) { } // Constructs a token with the given components that defaults to an // empty filename. Token(int token_type, std::string const & token_data, Tokenizer const * const source_tokenizer, int start_line, int end_line, int start_column, int end_column) : Token(token_type, token_data, source_tokenizer, "", start_line, end_line, start_column, end_column) { } // Constructs a token with the given components that defaults to no // designated source. Token(int token_type, std::string const & token_data, std::string const & filename, int start_line, int end_line, int start_column, int end_column) : Token(token_type, token_data, nullptr, filename, start_line, end_line, start_column, end_column) { } // Constructs a token with the given components. Token(int token_type, std::string const & token_data, Tokenizer const * const source_tokenizer, std::string const & filename, int start_line, int end_line, int start_column, int end_column) : token_type_(token_type), token_data_(token_data), source_tokenizer_(source_tokenizer), filename_(filename), start_line_(start_line), end_line_(end_line), start_column_(start_column), end_column_(end_column) { } int type() const { return token_type_; } std::string const & data() const { return token_data_; } Tokenizer const * const source_tokenizer() const { return source_tokenizer_; } std::string const & filename() const { return filename_; } int start_line() const { return start_line_; } int end_line() const { return end_line_; } int start_column() const { return start_column_; } int end_column() const { return end_column_; } bool is_eof() const { return token_type_ == kEofToken; } // 0 is always the type of an EOF (end of file) token. static int const kEofToken = 0; private: // Typically, an enum managed by the tokenizer that produced this // token. int const token_type_; // Data associated with this token, e.g., the text of a CDATA in // an XML document, the string representation of an opening // bracket in a Racket document, etc. std::string const token_data_; // The tokenizer that produced this token so that tokenizer can // (if they choose) refuse to handle tokens produced by other // tokenizers. If this is set to nullptr, then the Token records // no source tokenizer. // // Two tokens compare equal if they have the same type, data, and // source tokenizer. (So, for the last: are from the same // tokenizer or were created without a tokenizer stipulated.) Tokenizer const * const source_tokenizer_; // The file and line and column range from which the token is // drawn. (Note: it's conceivable as tokenizers work that a token // could actually come from multiple files. We define correct // behaviour in that case as recording the initial file only.) std::string const filename_; int const start_line_, end_line_; int const start_column_, end_column_; }; // Two Tokens are equal if they have the same type and data and // either come from the same tokenizer source or neither have a // source recorded. // // Note that two Tokens can be equal even if they come from different // file, line number, and column numbers. Lines and columns are // 1-based, not 0-based. inline bool operator==(Token const &lhs, Token const &rhs) { return lhs.type() == rhs.type() && lhs.data() == rhs.data() && lhs.source_tokenizer() == rhs.source_tokenizer(); } inline bool operator!=(Token const &lhs, Token const &rhs) { return !(lhs == rhs); } inline std::ostream& operator<<(std::ostream &os, Token const &token) { os << "[output for testing only: " << "token of type " << token.type() << " with data " << token.data() << " from " << token.source_tokenizer() << " at " << token.filename() << ":" << token.start_line() << ":" << token.start_column() << " to " << token.end_line() << ":" << token.end_column() << "]"; return os; } } // namespace tokenizer #endif // RACKET_BRACKET_STACK_TOKEN_H_
98673e98c91462955c87f372cae8c36b2c7677f3
b1d8bc138254498b0c688283f830600af9bc78fe
/main1.cpp
b6647681188ad5bd3525aa6141895c38a37d9033
[]
no_license
Sawndip2014/SumProductGraphMod
dc7396292da62fb3e50617913cceb333405b87fa
c610d4124eeab127f89df2ff2b460a15ec36645a
refs/heads/master
2021-06-16T02:54:38.868344
2017-05-07T15:02:36
2017-05-07T15:02:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,535
cpp
main1.cpp
/* * File: main1.cpp * Author: mdesana * */ #include "SPGM.h" #include "tests.h" #include "runs.h" #include "LearnSPGM.h" #include <time.h> using namespace std; int main(int argc, char** argv) { Params params; params.LoadFromArgs(argc, argv); // TestMixMaxTreesSPGM(params); if (params.reproducePaperResults) { ReproducePaperResults(params); } else if (params.runAll) { RunAll(params); } else { RunOne(params); // cout << params.ToString() << endl; // // Params p = params; // // p.nInsertions=1; // p.em_theta=false; // p.diricheletPrior=0; // p.uniformWeightPrior=0; // // string trainFile = p.dataFolder + "nltcs.ts.data"; // DataMatrix train; // train.ReadFromCSV(trainFile); // printf("loaded %s train with %d vars %d samples \n", p.filename.c_str(), (int) train.nVars(), (int) train.nData()); // // SPGM spgm; // LearnMixMaxSpanningTreesSPGM(spgm, train, p); // spgm.WriteGraphViz("SPGM_test1"); // // String2File(spgm.ToString(true),"2mt_befEm"); // spgm = spgm.EM(train, train, 100, 3, 0, true, false); //only train W // // String2File(spgm.ToString(true),"2mt_aftEm"); // CPTfactor::Test(); // SPGMnode::Test(); // TestKnapsack(); // RealMatrix::Test(); // RealMatrix::Test(); // SPGM::Test(); // TestCopyConstructor(params); // TestChowLiu(); // TestMixMaxTreesSPGM(params); // params.lambda = 0; // params.nInsertions = 4; // params.verbose = true; // TestMixMaxTreesSPGM(params); // params.verbose = false; // params.lambda = 0; // params.nInsertions = 120; // string trainFile = params.dataFolder + params.filename + ".ts.data"; // Matrix_rowMajor<int> a(4,5); // a.SetVal(1); // a.SetVal(1,2,12); // a.SetVal(0,3,12); // Matrix_rowMajor<int> part = a.GetRowSubset(0,2); // cout<<a.ToString()<<endl; // cout<<part.ToString()<<endl; // params.maxBatchMemSize = 1; // params.nInsertions = 10; // params.K = 2; // params.nIt_struct=10; // params.verbose = true; } }
8335bb868c0fae2e9ea405e5b5a02e42521e1138
88ac9162aa5a561daafc96bcfde66f50684de148
/Work/microblog/common/wbParser/wbParseObj.h
5d6ce773011d86d9485fbb6f6c756c7c732bdc5c
[]
no_license
jielmn/MyStudio
e6d535aa7d8b72476bd9b6084560476ac8671609
f45a90dbd73dbbb65df442639ceceb6149117deb
refs/heads/master
2020-03-19T01:22:19.934472
2018-06-04T01:57:05
2018-06-04T01:57:05
135,540,356
1
0
null
null
null
null
GB18030
C++
false
false
23,874
h
wbParseObj.h
#ifndef __WB_PARSE_OBJ_H__ #define __WB_PARSE_OBJ_H__ #include "wbParseStruct.h" #include "wbParser.h" namespace wbParserNS { class CWBXmlParser { public: /** 解析错误 */ static t_wbParse_Error *parse_error(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_error(wbParserNS::REQOBJ *obj , t_wbParse_Error * ptr, unsigned long *pmemSize=NULL); // 2012-05-08 add by sunfei 用于【获取@、赞、粉丝等初始消息】API static t_wbParse_Keda_Notify *parse_keda_notify(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_notify(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Notify *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Notifies *parse_keda_notifies(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_notifies(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Notifies *ptr, unsigned long *pmemSize=NULL); // 2012-03-16 add by sunfei static t_wbParse_Keda_departmentUsers *parse_keda_departmentUsers(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_departmentUsers(wbParserNS::REQOBJ *obj , t_wbParse_Keda_departmentUsers *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Department *parse_keda_department(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_department(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Department *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Departments *parse_keda_departments(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_departments(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Departments *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_searchDepartment *parse_keda_searchDepartment(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_searchDepartment(wbParserNS::REQOBJ *obj , t_wbParse_Keda_searchDepartment *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_searchUser *parse_keda_searchUser(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_searchUser(wbParserNS::REQOBJ *obj , t_wbParse_Keda_searchUser *ptr, unsigned long *pmemSize=NULL); // add end static t_wbParse_Keda_Messages_Data *parse_keda_messages_data(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_messages_data(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Messages_Data *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Like_Page *parse_keda_likePage(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_likePage(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Like_Page *ptr, unsigned long *pmemSize=NULL); // 2012-03-07 add by sunfei static t_wbParse_Keda_EntUser *parse_keda_entUser(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_entUser(wbParserNS::REQOBJ *obj , t_wbParse_Keda_EntUser *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_EntConfig *parse_keda_entConfig(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_entConfig(wbParserNS::REQOBJ *obj , t_wbParse_Keda_EntConfig *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Result *parse_keda_result(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_result(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Result *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_EntUsers *parse_keda_entUsers(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_entUsers(wbParserNS::REQOBJ *obj , t_wbParse_Keda_EntUsers *ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Page *parse_keda_page(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_page(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Page *ptr, unsigned long *pmemSize=NULL); // add end // 2012-02-29 add by sunfei static t_wbParse_Keda_Users_Data *parse_keda_users_data(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_users_data(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Users_Data * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Users *parse_keda_users(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_users(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Users * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Topic *parse_keda_topic(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_topic(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Topic * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Like *parse_keda_like(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_like(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Like * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_GroupStatistics *parse_keda_groupStatistics(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_groupStatistics(wbParserNS::REQOBJ *obj , t_wbParse_Keda_GroupStatistics * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Group *parse_keda_group(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_group(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Group * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Groups_Data *parse_keda_groups_data(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_groups_data(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Groups_Data * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Groups *parse_keda_groups(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_groups(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Groups * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_GroupCreate *parse_keda_groupcreate(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_groupcreate(wbParserNS::REQOBJ *obj , t_wbParse_Keda_GroupCreate * ptr, unsigned long *pmemSize=NULL); // add end // 2012-03-02 add by sunfei static t_wbParse_Keda_Sender *parse_keda_sender(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_sender(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Sender * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Receiver *parse_keda_receiver(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_receiver(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Receiver * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_PrivateFeed *parse_keda_privateFeed(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_privateFeed(wbParserNS::REQOBJ *obj , t_wbParse_Keda_PrivateFeed * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_PrivateContacter *parse_keda_privateContacter(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_privateContacter(wbParserNS::REQOBJ *obj , t_wbParse_Keda_PrivateContacter * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_PrivCont_Data *parse_keda_privCont_data(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_privCont_data(wbParserNS::REQOBJ *obj , t_wbParse_Keda_PrivCont_Data * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_PrivateContacters *parse_keda_privateContacters(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_privateContacters(wbParserNS::REQOBJ *obj , t_wbParse_Keda_PrivateContacters * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_PrivFeeds_Data *parse_keda_privFeeds_data(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_privFeeds_data(wbParserNS::REQOBJ *obj , t_wbParse_Keda_PrivFeeds_Data * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_PrivateFeeds *parse_keda_privateFeeds(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_privateFeeds(wbParserNS::REQOBJ *obj , t_wbParse_Keda_PrivateFeeds * ptr, unsigned long *pmemSize=NULL); // add end // 2012-01-09 add by sunfei static t_wbParse_Keda_User *parse_keda_user(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_user(wbParserNS::REQOBJ *obj , t_wbParse_Keda_User * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_UserProfile *parse_keda_user_profile(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_user_profile(wbParserNS::REQOBJ *obj , t_wbParse_Keda_UserProfile * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_OnlineState *parse_keda_onlineState(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_onlineState(wbParserNS::REQOBJ *obj , t_wbParse_Keda_OnlineState * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Depts *parse_keda_depts(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_depts(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Depts * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Dept *parse_keda_dept(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_dept(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Dept * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Messages *parse_keda_messages(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_messages(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Messages * ptr, unsigned long *pmemSize=NULL); // ------ static t_wbParse_Keda_Meta *parse_keda_meta(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_meta(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Meta * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_ThreadMessage *parse_keda_threadMessage(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_threadMessage(wbParserNS::REQOBJ *obj , t_wbParse_Keda_ThreadMessage * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_RelatedData *parse_keda_relatedData(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_relatedData(wbParserNS::REQOBJ *obj , t_wbParse_Keda_RelatedData * ptr, unsigned long *pmemSize=NULL); // ------ // ====== static t_wbParse_Keda_SubjectStyleThread *parse_keda_subjectStyleThread(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_subjectStyleThread(wbParserNS::REQOBJ *obj , t_wbParse_Keda_SubjectStyleThread * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_ReplyStyleThread *parse_keda_replyStyleThread(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_replyStyleThread(wbParserNS::REQOBJ *obj , t_wbParse_Keda_ReplyStyleThread * ptr, unsigned long *pmemSize=NULL); // ====== // =-=-=- static t_wbParse_Keda_Subject *parse_keda_subject(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_subject(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Subject * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Replies *parse_keda_replies(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_replies(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Replies * ptr, unsigned long *pmemSize=NULL); // =-=-=- // ===--- static t_wbParse_Keda_Id *parse_keda_id(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_id(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Id * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_ReferencedUserIds *parse_keda_referencedUserIds(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_referencedUserIds(wbParserNS::REQOBJ *obj , t_wbParse_Keda_ReferencedUserIds * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_TopicIds *parse_keda_topicIds(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_topicIds(wbParserNS::REQOBJ *obj , t_wbParse_Keda_TopicIds * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_LikeByIds *parse_keda_likeByIds(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_likeByIds(wbParserNS::REQOBJ *obj , t_wbParse_Keda_LikeByIds * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Picture *parse_keda_picture(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_picture(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Picture * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Pictures *parse_keda_pictures(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_pictures(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Pictures * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Attachment *parse_keda_attachment(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_attachment(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Attachment * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Attachments *parse_keda_attachments(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_attachments(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Attachments * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_FeedMessage *parse_keda_feedMessage(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_feedMessage(wbParserNS::REQOBJ *obj , t_wbParse_Keda_FeedMessage * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_RefReply *parse_keda_refReply(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_refReply(wbParserNS::REQOBJ *obj , t_wbParse_Keda_RefReply * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_Reply *parse_keda_reply(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_reply(wbParserNS::REQOBJ *obj , t_wbParse_Keda_Reply * ptr, unsigned long *pmemSize=NULL); // ===--- static t_wbParse_Keda_UserData *parse_keda_userData(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_userData(wbParserNS::REQOBJ *obj , t_wbParse_Keda_UserData * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_UserEntry *parse_keda_userEntry(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_userEntry(wbParserNS::REQOBJ *obj , t_wbParse_Keda_UserEntry * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_RelatedUsers *parse_keda_relatedUsers(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_relatedUsers(wbParserNS::REQOBJ *obj , t_wbParse_Keda_RelatedUsers * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_GroupData *parse_keda_groupData(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_groupData(wbParserNS::REQOBJ *obj , t_wbParse_Keda_GroupData * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_GroupEntry *parse_keda_groupEntry(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_groupEntry(wbParserNS::REQOBJ *obj , t_wbParse_Keda_GroupEntry * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_RelatedGroups *parse_keda_relatedGroups(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_relatedGroups(wbParserNS::REQOBJ *obj , t_wbParse_Keda_RelatedGroups * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_TopicData *parse_keda_topicData(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_topicData(wbParserNS::REQOBJ *obj , t_wbParse_Keda_TopicData * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_TopicEntry *parse_keda_topicEntry(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_topicEntry(wbParserNS::REQOBJ *obj , t_wbParse_Keda_TopicEntry * ptr, unsigned long *pmemSize=NULL); static t_wbParse_Keda_RelatedTopics *parse_keda_relatedTopics(/*[in]*/wbParserNS::REQOBJ *obj, unsigned long *pmemSize=NULL); static void parse_keda_relatedTopics(wbParserNS::REQOBJ *obj , t_wbParse_Keda_RelatedTopics * ptr, unsigned long *pmemSize=NULL); // add end typedef struct tagXmlChildNamesParam { char * szChildNames[16]; unsigned int dwCnt; tagXmlChildNamesParam() { memset( this, 0, sizeof(*this) ); } }TXmlChildNamesParam, *PTXmlChildNamesParam; // meeting list ( root ) static void parse_keda_meeting_list(wbParserNS::REQOBJ *obj , t_wbParse_m_meeting_list * ptr, unsigned long *pmemSize=NULL); // meeting list' related rooms static void parse_keda_meeting_short_rooms(wbParserNS::REQOBJ *obj , t_wbParse_m_short_rooms * ptr, unsigned long *pmemSize=NULL, const char * szRoomId = NULL); // meeting list' related room static void parse_keda_meeting_short_room( wbParserNS::REQOBJ *obj , t_wbParse_m_short_room * ptr, unsigned long *pmemSize=NULL, const char * szRoomId = NULL ); // meeting list's meetings static void parse_keda_meeting_meetings(wbParserNS::REQOBJ *obj , t_wbParse_m_short_meetings * ptr, unsigned long *pmemSize=NULL); // meeting list's meetings static void parse_keda_meeting_meeting(wbParserNS::REQOBJ *obj , t_wbParse_m_short_meeting * ptr, unsigned long *pmemSize=NULL); // meeting's room ids static void parse_keda_meeting_room_ids(wbParserNS::REQOBJ *obj , t_wbParse_m_room_ids * ptr, unsigned long *pmemSize=NULL); // meeting's room id static void parse_keda_meeting_room_id(wbParserNS::REQOBJ *obj , WBParseINT * ptr, unsigned long *pmemSize=NULL); // meeting info ( root ) static void parse_keda_meeting_info(wbParserNS::REQOBJ *obj , t_wbParse_m_meeting_info * ptr, unsigned long *pmemSize=NULL); // persons static void parse_keda_meeting_persons(wbParserNS::REQOBJ *obj , t_wbParse_m_persons * ptr, unsigned long *pmemSize=NULL); // person static void parse_keda_meeting_person(wbParserNS::REQOBJ *obj , t_wbParse_m_person * ptr, unsigned long *pmemSize=NULL); // room list ( root ) static void parse_keda_m_room_list(wbParserNS::REQOBJ *obj , t_wbParse_m_room_list * ptr, unsigned long *pmemSize=NULL); // rooms static void parse_keda_m_rooms(wbParserNS::REQOBJ *obj , t_wbParse_m_rooms * ptr, unsigned long *pmemSize=NULL); // room static void parse_keda_m_room(wbParserNS::REQOBJ *obj , t_wbParse_m_room * ptr, unsigned long *pmemSize=NULL); // normal room list ( root ) static void parse_keda_m_normal_room_list(wbParserNS::REQOBJ *obj , t_wbParse_m_normal_room_list * ptr, unsigned long *pmemSize=NULL); // normal rooms static void parse_keda_m_short_rooms(wbParserNS::REQOBJ *obj , t_wbParse_m_short_rooms * ptr, unsigned long *pmemSize, const char * szChildName, const TXmlChildNamesParam * pChildAttrs); // normal rooms static void parse_keda_m_short_room(wbParserNS::REQOBJ *obj , t_wbParse_m_short_room * ptr, unsigned long *pmemSize, const TXmlChildNamesParam * pChildAttrs); // room info ( root ) static void parse_keda_room_info(wbParserNS::REQOBJ *obj , t_wbParse_m_room_info * ptr, unsigned long *pmemSize=NULL); // room status ( root ) static void parse_keda_room_status(wbParserNS::REQOBJ *obj , t_wbParse_m_room_status * ptr, unsigned long *pmemSize=NULL); // room list by name ( root ) static void parse_keda_room_by_name(wbParserNS::REQOBJ *obj , t_wbParse_m_short_rooms * ptr, unsigned long *pmemSize=NULL); // template list ( root element ) static void parse_keda_template_list(wbParserNS::REQOBJ *obj , t_wbParse_m_templateList * ptr, unsigned long *pmemSize=NULL); // templates static void parse_keda_templates(wbParserNS::REQOBJ *obj , t_wbParse_m_templates * ptr, unsigned long *pmemSize=NULL); // template static void parse_keda_template(wbParserNS::REQOBJ *obj , t_wbParse_m_template * ptr, unsigned long *pmemSize=NULL); //// <person> //static void parse_keda_m_person(wbParserNS::REQOBJ *obj , t_wbParse_m_person * ptr, unsigned long *pmemSize=NULL); //// <persons> //static void parse_keda_m_persons(wbParserNS::REQOBJ *obj , t_wbParse_m_persons * ptr, unsigned long *pmemSize=NULL); // template info ( root ) static void parse_keda_template_info(wbParserNS::REQOBJ *obj , t_wbParse_m_template_info * ptr, unsigned long *pmemSize=NULL); // notify list ( root element ) static void parse_keda_list_notify_by_max(wbParserNS::REQOBJ *obj , t_wbParse_m_notifys * ptr, unsigned long *pmemSize=NULL); // notify item static void parse_keda_notify_item(wbParserNS::REQOBJ *obj , t_wbParse_m_notify * ptr, unsigned long *pmemSize=NULL); // notify content static void parse_keda_notify_content( wbParserNS::REQOBJ *obj , void * ptr, int nType ); // content-meeting static void parse_keda_notify_content_meeting( wbParserNS::REQOBJ *obj , t_wbParse_m_notify_content_meeting * ptr ); // regular info ( root ) static void parse_keda_regular(wbParserNS::REQOBJ *obj , t_wbParse_m_regular_info * ptr, unsigned long *pmemSize=NULL); // meeting ids static void parse_keda_meeting_ids(wbParserNS::REQOBJ *obj , t_wbParse_m_meeting_ids * ptr, unsigned long *pmemSize=NULL); // meeting id static void parse_keda_meeting_id(wbParserNS::REQOBJ *obj , WBParseINT * ptr, unsigned long *pmemSize=NULL); // app: all notifys ( root ) static void parse_app_all_notifys(wbParserNS::REQOBJ *obj , t_wbParse_app_notifys * ptr, unsigned long *pmemSize=NULL); static void parse_app_notify_item(wbParserNS::REQOBJ *obj , t_wbParse_app_notify * ptr, unsigned long *pmemSize=NULL); // monitor: group ( root ) static void parse_monitor_group(wbParserNS::REQOBJ *obj , t_wbParse_monitor_group * ptr, unsigned long *pmemSize=NULL); static void parse_monitor_devices(wbParserNS::REQOBJ *obj , t_wbParse_monitor_devices * ptr, unsigned long *pmemSize=NULL); static void parse_monitor_device(wbParserNS::REQOBJ *obj , t_wbParse_monitor_device * ptr, unsigned long *pmemSize=NULL); // monitor: groups ( root ) static void parse_monitor_groups(wbParserNS::REQOBJ *obj , t_wbParse_monitor_groups * ptr, unsigned long *pmemSize=NULL); }; } #endif // __WB_PARSE_OBJ_H__
66f3569c5d158b2875843807d363e55e94aa968a
f39a7135ee17138f06e410e1116458ab11e7083c
/CS 240 Projects/Homework8/Homework8/StaticArrayList.cpp
ea732996164ab475fc49698d8e066a3ad75ed059
[]
no_license
sfeye/CS
6f69a76b95b3cec5773a1e804278eeb2bed24c25
ec15141626ad51eb604381bf4aac13011b6f793c
refs/heads/master
2021-07-11T05:41:27.556935
2020-05-02T16:31:23
2020-05-02T16:31:23
130,940,952
0
0
null
null
null
null
UTF-8
C++
false
false
1,954
cpp
StaticArrayList.cpp
//Samuel Feye //03-20-2018 //Professor Klein CS240 //Homework 8 //StaticArrayList.cpp // Copyright © 2018 Sam Feye. All rights reserved. #include<iostream> #include "StaticArrayList.hpp" using namespace std; StaticArrayList::StaticArrayList() { size = 0; } int StaticArrayList::getSize() const { return size; } bool StaticArrayList::insertAt(ElementType elt, int position) { if ((position < 0) || (position > size) || (size >= MAX_SIZE)) return false; for (int i = size; i > position; i--) list[i] = list[i - 1]; list[position] = elt; size++; return true; } bool StaticArrayList::removeAt(ElementType &elt, int position) { if ((position < 0) || (position > size - 1)) return false; elt = list[position]; for (int i = position; i < size; i++) list[i] = list[i + 1]; size--; return true; } void StaticArrayList::deleteList() { size = 0; } bool StaticArrayList::insertSorted(ElementType elt) { if (size >= MAX_SIZE) return false; if(list[0] > elt) { for (int i = 0; i < size; i++) list[i] = list[i+1]; list[0] = elt; size++; return true; } if(list[size-1] < elt) { list[size] = elt; size++; return true; } for (int i = 0; i < size; i++) { if (list[i] < elt && list[i+1] > elt) { for(int j = (i+1); j < size; j++) list[j] = list[j+1]; list[i+1] = elt; } } size++; return true; } bool StaticArrayList::remove(ElementType elt) { bool exists = false; for (int i = 0; i < size; i++) { if (elt == list[i]) { for(int j = i; j < (size - 1); j++) { list[j] = list[j+1]; } size--; return true; } else exists = false; } return exists; }
c70031cd7c4bcbd23bedf514bd67d2871223ca95
ac2735758ad6b71c2faf3fa33d7c1083a28fabb8
/dataset/sorted_source_code/semantic/ImBarD/ImBarD_1_1/main.cpp
8776ed83b02feabb8fa785656db04150c11fc05b
[]
no_license
Darthone/Code-And-Malware-Stylometry
389bcd5644a2f20103f39a374f9a04678b4f63e5
42f2091f50f8782a3a0b20c0d757e9d81edff6d8
refs/heads/master
2020-06-01T06:34:53.177201
2017-06-19T01:03:35
2017-06-19T01:03:35
94,065,628
1
0
null
null
null
null
UTF-8
C++
false
false
5,226
cpp
main.cpp
#include \ <iostream> #include \ <vector> #include \ <algorithm> #include \ <string> #include \ <ctype.h> #include \ <deque> #include \ <queue> #include \ <cstring> #include \ <set> #include \ <list> #include \ <map> #include \ <random> #include \ <unordered_map> #include \ <stdio.h> using namespace O ; typedef long long o ; typedef long double Oo ; typedef O :: oo < int > io ; typedef O :: oo < bool > Io ; typedef O :: oo < lo > Oi ; typedef O :: oo < double > oi ; typedef O :: oo < long long > ii ; typedef O :: oo < O :: oo < int > > Ii ; typedef oo < Ii > OI ; typedef oo < ii > oI ; typedef O :: oo < O :: iI < int , int > > II ; typedef oo < II > Ol ; typedef O :: iI < int , int > ol ; typedef O :: iI < o , o > O0 ; typedef O :: oo < O0 > o0 ; const long long i0 = 07346545007 ; #define \ I0( \ l0 \ ) \ ( \ l0 \ ) \ . \ O1 \ ( \ ) \ , \ ( \ l0 \ ) \ . \ o1 \ ( \ ) #define \ i1( \ l0 \ ) \ ( \ int \ ) \ ( \ l0 \ ) \ . \ I1 \ ( \ ) #define \ l1( \ OOo \ , \ oOo \ , \ iOo \ ) \ for \ ( \ int \ OOo \ = \ oOo \ ; \ OOo \ < \ iOo \ ; \ OOo \ ++ \ ) #define \ IOo \ \ lOo #define \ Ooo \ \ ooo int ioo ( ) { #ifndef \ Ioo loo ( "in\160\165t.t\170t" , "r\164" , Oio ) ; loo ( "\157\165tp\165t.txt" , "w\164" , oio ) ; #endif int iio ; Iio ( "%d" , & iio ) ; l1 ( lio , 0 , iio ) { OIo ( "C\141\163\145 #%d\072 " , lio + 01 ) ; int oIo ; int iIo , IIo , lIo , Olo , iOo , olo ; lo ilo ; Ilo >> oIo >> iIo >> IIo >> lIo >> Olo >> iOo >> olo ; if ( iIo + lIo == 0 ) { if ( Olo > 0 || olo > 0 || iOo != IIo ) { llo << "I\115\120O\123S\111\102\114\105\012" ; continue ; } else { l1 ( OOo , 0 , iOo ) ilo += "BO" ; llo << ilo << O0o ; continue ; } } if ( iIo + iOo == 0 ) { if ( Olo > 0 || IIo > 0 || lIo != olo ) { llo << "IM\120OS\123I\102\114\105\012" ; continue ; } else { l1 ( OOo , 0 , lIo ) ilo += "\131\126" ; llo << ilo << O0o ; continue ; } } if ( iOo + lIo == 0 ) { if ( IIo > 0 || olo > 0 || iIo != Olo ) { llo << "I\115\120OSS\111\102LE\012" ; continue ; } else { l1 ( OOo , 0 , Olo ) ilo += "R\107" ; llo << ilo << O0o ; continue ; } } iIo -= Olo ; lIo -= olo ; iOo -= IIo ; if ( iIo < 0 || lIo < 0 || iOo < 0 ) { llo << "\111MP\117SSIB\114E\012" ; continue ; } if ( iIo == 0 && Olo > 0 ) { llo << "IM\120\117\123\123\111\102\114\105\n" ; continue ; } if ( lIo == 0 && olo > 0 ) { llo << "I\115\120O\123SIB\114\105\012" ; continue ; } if ( iOo == 0 && IIo > 0 ) { llo << "IM\120\117S\123\111BLE\n" ; continue ; } if ( iIo + lIo < iOo || iIo + iOo < lIo || iOo + lIo < iIo ) { llo << "I\115\120\117\123S\111\102LE\012" ; continue ; } int o0o = iIo + lIo + iOo ; ilo = lo ( o0o , '\056' ) ; int i0o = 0 ; if ( 02 * iIo == o0o ) { l1 ( OOo , 0 , iIo ) { ilo [ 02 * OOo ] = '\122' ; } l1 ( OOo , 0 , iIo ) { if ( lIo > 0 ) { ilo [ 02 * OOo + 01 ] = '\131' ; lIo -- ; } else ilo [ 02 * OOo + 01 ] = '\102' ; } } else if ( 02 * iOo == o0o ) { l1 ( OOo , 0 , iOo ) { ilo [ 02 * OOo ] = '\102' ; } l1 ( OOo , 0 , iOo ) { if ( lIo > 0 ) { ilo [ 02 * OOo + 01 ] = '\131' ; lIo -- ; } else ilo [ 02 * OOo + 01 ] = '\122' ; } } else if ( 02 * lIo == o0o ) { l1 ( OOo , 0 , lIo ) { ilo [ 02 * OOo ] = '\131' ; } l1 ( OOo , 0 , lIo ) { if ( iIo > 0 ) { ilo [ 02 * OOo + 01 ] = '\122' ; iIo -- ; } else ilo [ 02 * OOo + 01 ] = '\102' ; } } else { l1 ( OOo , 0 , o0o ) { if ( iIo > 0 ) { ilo [ i0o ] = '\122' ; iIo -- ; } else if ( lIo > 0 ) { ilo [ i0o ] = '\131' ; lIo -- ; } else if ( iOo > 0 ) { ilo [ i0o ] = '\102' ; iOo -- ; } i0o += 02 ; if ( i0o >= o0o ) i0o = 01 ; } } if ( Olo > 0 ) { int I0o = 0 ; while ( ilo [ I0o ] != '\122' ) I0o ++ ; lo l0o = ilo . O1o ( 0 , I0o ) ; lo o1o = ilo . O1o ( I0o ) ; l1 ( OOo , 0 , Olo ) l0o += "RG" ; ilo = l0o + o1o ; } if ( olo > 0 ) { int I0o = 0 ; while ( ilo [ I0o ] != '\131' ) I0o ++ ; lo l0o = ilo . O1o ( 0 , I0o ) ; lo o1o = ilo . O1o ( I0o ) ; l1 ( OOo , 0 , olo ) l0o += "\131V" ; ilo = l0o + o1o ; } if ( IIo > 0 ) { int I0o = 0 ; while ( ilo [ I0o ] != '\102' ) I0o ++ ; lo l0o = ilo . O1o ( 0 , I0o ) ; lo o1o = ilo . O1o ( I0o ) ; l1 ( OOo , 0 , IIo ) l0o += "\102\117" ; ilo = l0o + o1o ; } llo << ilo << O0o ; } }
850465f0a1f187c0446e3cf313116d6dfb2e95c3
284689d6a57f136b3f0ad2b8febba66dec85843f
/VolticRoleplay.Lakeside_County/Dialogs/PoliceDB_mainScreen.hpp
fbe0ef319bb49411c51061df0e06b6983e5ec864
[]
no_license
Bladadah/Roleplay
2b80bb2e832d63a5f658a01474b3f736eeef8c71
81fad3ac28183a23ffca04c2f7a896ab084ccfe9
refs/heads/master
2020-03-12T06:23:32.041030
2018-04-23T19:05:20
2018-04-23T19:05:20
130,484,115
0
0
null
null
null
null
UTF-8
C++
false
false
4,502
hpp
PoliceDB_mainScreen.hpp
class HRP_PoliceDB_mainScreen { idd = 5013; class controls { class RscPicture_1200: RscPicture { idc = 1200; text = "\RedRoleplay_Client2\icons\TabletMain.paa"; x = 0.102969 * safezoneW + safezoneX; y = 0.159 * safezoneH + safezoneY; w = 0.8 * safezoneW; h = 0.7 * safezoneH; }; class Warrant_B: RscButton { idc = 1601; action = "[true] call HRP_fnc_loadWarrantsPage"; colorBackgroundActive[] = {0,0,0,0}; colorBackgroundDisabled[] = {0,0,0,0}; colorDisabled[] = {0,0,0,0}; colorFocused[] = {0,0,0,0}; colorBorder[] = {0,0,0,0}; x = 0.288594 * safezoneW + safezoneX; y = 0.368 * safezoneH + safezoneY; w = 0.1 * safezoneW; h = 0.035 * safezoneH; colorText[] = {0,0,0,0}; colorBackground[] = {0,0,0,0}; colorActive[] = {0,0,0,0}; }; class Vehicle_B: RscButton { idc = 1602; action = "createDialog 'HRP_PoliceDB_Vehicle'"; colorBackgroundActive[] = {0,0,0,0}; colorBackgroundDisabled[] = {0,0,0,0}; colorDisabled[] = {0,0,0,0}; colorFocused[] = {0,0,0,0}; colorBorder[] = {0,0,0,0}; x = 0.288594 * safezoneW + safezoneX; y = 0.412 * safezoneH + safezoneY; w = 0.1 * safezoneW; h = 0.035 * safezoneH; colorText[] = {0,0,0,0}; colorBackground[] = {0,0,0,0}; colorActive[] = {0,0,0,0}; }; class Player_B: RscButton { idc = 1600; action = "createDialog 'HRP_PoliceDB_personLookup'"; colorBackgroundActive[] = {0,0,0,0}; colorBackgroundDisabled[] = {0,0,0,0}; colorDisabled[] = {0,0,0,0}; colorFocused[] = {0,0,0,0}; colorBorder[] = {0,0,0,0}; x = 0.288594 * safezoneW + safezoneX; y = 0.324 * safezoneH + safezoneY; w = 0.1 * safezoneW; h = 0.035 * safezoneH; colorText[] = {0,0,0,0}; colorBackground[] = {0,0,0,0}; colorActive[] = {0,0,0,0}; }; class Off_B: RscButton { idc = 1232; action = "closeDialog 0;"; colorBackgroundActive[] = {0,0,0,0}; colorBackgroundDisabled[] = {0,0,0,0}; colorDisabled[] = {0,0,0,0}; colorFocused[] = {0,0,0,0}; colorBorder[] = {0,0,0,0}; x = 0.492369 * safezoneW + safezoneX; y = 0.7596 * safezoneH + safezoneY; w = 0.02125 * safezoneW; h = 0.0249999 * safezoneH; colorText[] = {0,0,0,0}; colorBackground[] = {0,0,0,0}; colorActive[] = {0,0,0,0}; }; class Corrections_B: RscButton { idc = 1603; action = "[true,1] call HRP_fnc_listInmates"; colorBackgroundActive[] = {0,0,0,0}; colorBackgroundDisabled[] = {0,0,0,0}; colorDisabled[] = {0,0,0,0}; colorFocused[] = {0,0,0,0}; colorBorder[] = {0,0,0,0}; x = 0.286979 * safezoneW + safezoneX; y = 0.457408 * safezoneH + safezoneY; w = 0.1 * safezoneW; h = 0.035 * safezoneH; colorText[] = {0,0,0,0}; colorBackground[] = {0,0,0,0}; colorActive[] = {0,0,0,0}; }; class onDuty_T: RscText { idc = 1000; font = "Metropolis"; style = ST_CENTER; text = "15"; x = 0.412344 * safezoneW + safezoneX; y = 0.401 * safezoneH + safezoneY; w = 0.13 * safezoneW; h = 0.1 * safezoneH; sizeEx = 0.1; colorShadow[] = {0,0,0,0}; }; class currentInmates_T: RscText { idc = 1001; font = "Metropolis"; style = ST_CENTER; text = "15"; x = 0.570833 * safezoneW + safezoneX; y = 0.400926 * safezoneH + safezoneY; w = 0.13 * safezoneW; h = 0.1 * safezoneH; sizeEx = 0.1; colorShadow[] = {0,0,0,0}; }; class threatLevel_T: RscText { idc = 1002; font = "Metropolis"; style = ST_CENTER; text = "Red"; x = 0.413021 * safezoneW + safezoneX; y = 0.600926 * safezoneH + safezoneY; w = 0.13 * safezoneW; h = 0.1 * safezoneH; sizeEx = 0.1; colorShadow[] = {0,0,0,0}; }; class wantedFelons_T: RscText { idc = 1003; font = "Metropolis"; style = ST_CENTER; text = "15"; x = 0.571875 * safezoneW + safezoneX; y = 0.600926 * safezoneH + safezoneY; w = 0.13 * safezoneW; h = 0.1 * safezoneH; sizeEx = 0.1; colorShadow[] = {0,0,0,0}; }; class changeThreatLevel_B: RscButton { idc = 123123; action = "closeDialog 0; [] call HRP_fnc_openChangeThreatLevel"; x = 0.292135 * safezoneW + safezoneX; y = 0.687926 * safezoneH + safezoneY; w = 0.09 * safezoneW; h = 0.04 * safezoneH; colorBackground[] = {0,0,0,0}; colorActive[] = {0,0,0,0}; colorBackgroundActive[] = {0,0,0,0}; colorBackgroundDisabled[] = {0,0,0,0}; colorDisabled[] = {0,0,0,0}; colorFocused[] = {0,0,0,0}; colorBorder[] = {0,0,0,0}; }; }; };
e8c1d47da66939390bcc381b4837c5e08ead27d9
29217bba0162f7a1183f909b17d5612d3194d661
/Laozi/SkinListBox.cpp
95ec8848c0a50b204e016d02db83ee0b680bdaa1
[]
no_license
etoolkit/Laozi
7dda5f31e41349d1c90636f07e63c3fe08eb5b2f
4c843cf2c9e5dfe80decea98b6645f70c4e57d95
refs/heads/master
2023-02-25T18:01:09.517910
2021-01-26T02:06:02
2021-01-26T02:06:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
128
cpp
SkinListBox.cpp
#include "StdAfx.h" #include "SkinListBox.h" CSkinListBox::CSkinListBox(void) { } CSkinListBox::~CSkinListBox(void) { }
e99e3db9ea795082559db309b384e480526511ce
6a8e95b5f3c7f1afc3cc56a7f07050595f67d447
/game_project/game_projectDlg.h
d8d1623f03eb6f2fd00a823456750a5a2f1187a1
[]
no_license
ZzangWoo/GameTeamProject
e92a6d21f5f329cb7938b7f92a64f774243c5279
bff35c2d7b3cc496e75ebdcfea55abd7b7d979ee
refs/heads/master
2020-08-19T10:22:23.643545
2019-10-24T18:44:23
2019-10-24T18:44:23
215,910,310
0
0
null
null
null
null
UHC
C++
false
false
1,114
h
game_projectDlg.h
// game_projectDlg.h : 헤더 파일 // #pragma once #include "ClientSocket.h" #include "afxwin.h" #include "CreateRoomDlg.h" // Cgame_projectDlg 대화 상자 class Cgame_projectDlg : public CDialogEx { // 생성입니다. public: Cgame_projectDlg(CWnd* pParent = NULL); // 표준 생성자입니다. // 대화 상자 데이터입니다. #ifdef AFX_DESIGN_TIME enum { IDD = IDD_CONNECT_DLG }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다. // 구현입니다. protected: HICON m_hIcon; // 생성된 메시지 맵 함수 virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() private: public: //CListBox m_list_msg; //CEdit m_edit_send; //afx_msg void OnClickedBtnSend(); //afx_msg LRESULT OnClientRecv(WPARAM wParam, LPARAM lParam); CString m_serverIP; protected: // afx_msg LRESULT OnClientRecv(WPARAM wParam, LPARAM lParam); public: afx_msg void OnClickedBtnConnect(); CCreateRoomDlg *m_createRoomDlg; CString m_edit_name; };
e9afe9127835906a00684c7f90f3e845cf1648e6
93376006df2e645ae7406ff739aa43643df9b3d5
/CODE/OLD_CRAP/soundengine/Spatializer.hpp
5553ad72c9a3d59e5a588aeca49466b4b33f8f14
[]
no_license
omer4d/OldCodeBackup
fd5f84e660cc91ab32cb08032848f779ced66053
d836c14006fa72f6e660bcf39d2315e69dc292f8
refs/heads/master
2021-01-10T05:54:20.340232
2015-12-13T14:44:10
2015-12-13T14:44:10
47,922,932
0
0
null
null
null
null
UTF-8
C++
false
false
833
hpp
Spatializer.hpp
#ifndef _Spatializer_hpp_ #define _Spatializer_hpp_ #include <fftw3.h> #include "HRTFDB.hpp" #include "CircularArray.hpp" #include "Complex.hpp" #include "Types.hpp" namespace Audio { class Spatializer { int mBuffLen; HRTFDB& mHrtfdb; CircularArray mLeftTail, mRightTail; double* mLeftSigTime; double* mRightSigTime; Complex* mSigFreq; Complex* mResFreq; fftw_plan mPlanForward[2], mPlanBackward[2]; enum { RIGHT_CHAN, LEFT_CHAN }; public: Spatializer(HRTFDB& hrtfdb, int buffLen); ~Spatializer(); void setHrtfdb(HRTFDB& hrtfdb); double* left(); double* right(); void renderTail(int16* buff); void ild(double yaw, double pitch, double& left, double& right); void render(int16* buff, double yaw, double pitch); }; } #endif
ecd0010ce4194f511288c8498f57e63bda1dd19a
7d68c1b1e853f36a0dc1b89cefa52211211e4358
/examples/middleware_async_qt/window.cpp
db1635e2891c5d3ec67081ea9f2ae57b11ea91c3
[ "MIT" ]
permissive
deiflou/uroboros
78efba556b65bb01d72ac18d4e95643b7779fbb5
defd4b02e7498abdd6eb2dd867a1a8e5ceda2820
refs/heads/master
2020-04-25T12:57:26.555284
2020-02-01T19:00:59
2020-02-01T19:00:59
172,793,797
0
0
null
null
null
null
UTF-8
C++
false
false
4,989
cpp
window.cpp
// // MIT License // // Copyright (c) 2019 Deif Lou // // 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 "window.hpp" #include <QVBoxLayout> #include <QHBoxLayout> #include <QSpinBox> #include <QScrollArea> #include <iostream> progress_widget::progress_widget(QWidget * parent) : QWidget(parent) { QVBoxLayout * vertical_layout = new QVBoxLayout; QHBoxLayout * horizontal_layout = new QHBoxLayout; label = new QLabel; progress_bar = new QProgressBar; button = new QPushButton("Cancel"); vertical_layout->setMargin(0); vertical_layout->setSpacing(5); horizontal_layout->setMargin(0); horizontal_layout->setSpacing(5); progress_bar->setRange(0, 100); horizontal_layout->addWidget(progress_bar); horizontal_layout->addWidget(button); vertical_layout->addWidget(label); vertical_layout->addLayout(horizontal_layout); setLayout(vertical_layout); } window::window(store_type & store) : store(store) { QVBoxLayout * vertical_layout = new QVBoxLayout; QHBoxLayout * horizontal_layout = new QHBoxLayout; QPushButton * button = new QPushButton("Add Task"); QSpinBox * spin = new QSpinBox; QScrollArea * scroll_area = new QScrollArea; progress_container = new QWidget; setMinimumSize(500, 400); vertical_layout->setMargin(0); vertical_layout->setSpacing(0); horizontal_layout->setMargin(10); horizontal_layout->setSpacing(5); spin->setRange(1, 10); spin->setValue(5); spin->setSuffix(" seconds"); scroll_area->setWidget(progress_container); scroll_area->setWidgetResizable(true); progress_container->setLayout(new QVBoxLayout); progress_container->layout()->setAlignment(Qt::AlignTop); progress_container->layout()->setMargin(10); progress_container->layout()->setSpacing(5); horizontal_layout->addWidget(button); horizontal_layout->addWidget(spin); vertical_layout->addLayout(horizontal_layout); vertical_layout->addWidget(scroll_area); setLayout(vertical_layout); connect ( button, &QPushButton::clicked, [&store, spin]() { store.dispatch(start_async_task_action_type{spin->value()}); } ); } void window::notify_state_change() { int const size1 = store.state().async_tasks.size(); int const size2 = progress_widgets.size(); int diff = size1 - size2; if (diff > 0) for (int i = 0; i < diff; ++i) { progress_widget * widget = new progress_widget(progress_container); progress_container->layout()->addWidget(widget); progress_widgets.push_back(widget); widget->show(); } else if (diff < 0) while (diff++) { progress_widget * widget = progress_widgets.back(); widget->setParent(nullptr); delete widget; progress_widgets.pop_back(); } else if (size1 == 0) return; for (int i = 0; i < size1; ++i) { progress_widgets[i]->label->setText ( QString("Task id: ") + QString::number(store.state().async_tasks[i].id) ); progress_widgets[i]->progress_bar->setValue ( store.state().async_tasks[i].progress ); } if (diff != 0) for (int i = 0; i < size1; ++i) { int task_id = store.state().async_tasks[i].id; progress_widgets[i]->button->disconnect(); connect ( progress_widgets[i]->button, &QPushButton::clicked, [this, task_id]() { store.dispatch(cancel_async_task_action_type{task_id}); } ); } }
acdd6d32e54f89ead071a8fa754b09b3650b38a8
ca486c4afd78dc3d2c1bc1b919653b77a032c951
/Selfhydro-Sensors/Selfhydro-Sensors/src/analogDigitalConverter.h
c225937a3d37945902514d8067a2be2d7d049c94
[ "Apache-2.0" ]
permissive
selfhydro/selfhydro
c4841a3ee85852712edaee0042fce5a9e8f534a8
a4c0897877fdc10f9b612af1bc4753857d877bfa
refs/heads/master
2022-07-02T22:25:44.737776
2020-05-12T15:46:47
2020-05-12T15:46:47
120,166,236
1
0
null
null
null
null
UTF-8
C++
false
false
514
h
analogDigitalConverter.h
#ifndef ANALOG_DIGITAL_CONVERTER_H #define ANALOG_DIGITAL_CONVERTER_H #include <Arduino.h> #include <Adafruit_MCP3008.h> class AnalogDigitalConverter { #define CS_PIN D8 #define CLOCK_PIN D5 #define MOSI_PIN D7 #define MISO_PIN D6 public: AnalogDigitalConverter() { adc.begin(CLOCK_PIN, MOSI_PIN, MISO_PIN, CS_PIN); } int GetValue(int channel) { return adc.readADC(channel); } private: Adafruit_MCP3008 adc; }; #endif
f8978339ae938ae5aacc8c24b5aedf2912efe1e8
c36c9604d01d234c812dc29eaf03d65debb2add9
/Estantes.cpp
aeca77bc5bba12d0157406b9ec91f3a1421165a1
[]
no_license
Skar241/RepositorioPruebas
27d324b36f2a00c8953c82da7137adb780c7afd1
68a61bce1c9bb2003ae72f43edcce31dd066e174
refs/heads/master
2020-05-17T17:25:18.593241
2015-06-07T01:37:00
2015-06-07T01:37:00
33,100,443
0
0
null
null
null
null
UTF-8
C++
false
false
7,528
cpp
Estantes.cpp
#include "Elementos.h" //falta agregar sombra en orden correcto void Estantes::Init(){ Exterior.LoadTGA("construccion/estantes/estExt.tga"); Exterior.BuildGLTexture(); Exterior.ReleaseImage(); Interior.LoadTGA("construccion/estantes/sombraEst.tga"); Interior.BuildGLTexture(); Interior.ReleaseImage(); PuertaI.LoadTGA("construccion/estantes/puertax-.tga"); PuertaI.BuildGLTexture(); PuertaI.ReleaseImage(); PuertaD.LoadTGA("construccion/estantes/puertax+.tga"); PuertaD.BuildGLTexture(); PuertaD.ReleaseImage(); madera.LoadTGA("construccion/estantes/libmadera.tga"); madera.BuildGLTexture(); madera.ReleaseImage(); maderaclara.LoadTGA("construccion/estantes/maderaclara.tga"); maderaclara.BuildGLTexture(); maderaclara.ReleaseImage(); } //tex1 Front //text2 Right //text3 Back //tex4 Left //text5 Bottom //text6 Top void Estantes::creaEstante1(){ glPushMatrix(); //glRotatef(movEst,0,0,1); glPushMatrix(); //glColor3f(0, 0, 1); glScalef(8.0,4,1.0); poligono.prismaEst(Interior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex);//parte trasera glPopMatrix(); glPushMatrix(); glTranslatef(0.0,2.25,1.5); glPushMatrix(); //glColor3f(0,1,1); glScalef(8.0,0.5,4.0);//glScalef(8.0,4.0,0.5); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Interior.GLindex, Exterior.GLindex);//parte arriba del estante(y+) glPopMatrix(); glTranslatef(4.25,-2.25,0.0); glPushMatrix(); glPushMatrix(); //glColor3f(0,1,0); glScalef(0.5,5.0,4.0); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Interior.GLindex,Exterior.GLindex, Exterior.GLindex);//lado der estante (x+) glPopMatrix(); glTranslatef(-0.25,0,1.88);//para que gire entorno al borde del estante //glRotatef(movDoorD,0,1,0); glTranslatef(-2,0,0);//para construir la puerta //glColor3f(1,0,1); glScalef(4,4,0.25); poligono.prismaEst(PuertaI.GLindex,0,0,0,0,0);// Exterior.GLindex,Interior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex);; //puerta der glPopMatrix(); glTranslatef(-4.25,-2.25,0.0); glPushMatrix(); //glColor3f(1,1,0); glScalef(8.0,0.5,4.0); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Interior.GLindex);//parte baja del estante (y-) glPopMatrix(); glTranslatef(-4.25,2.25,0.0); glPushMatrix(); //glColor3f(1,0,0); glScalef(0.5,5.0,4.0); poligono.prismaEst(Exterior.GLindex, Interior.GLindex,Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex);//parte izq del estante (x-) glPopMatrix(); glTranslatef(0.25,0,1.88);//para que gire entorno al borde del estante //glRotatef(movDoorI,0,1,0); glTranslatef(2,0,0);//para construir la puerta //glColor3f(1,0,1); glScalef(4,4,0.25); glDisable(GL_LIGHTING); poligono.prismaEst(PuertaD.GLindex, 0,0,0,0,0);//Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex); //puerta izquierda glPopMatrix(); //maderas intermedias glPushMatrix(); glTranslatef(0.0,0.75,1.5); //glColor3f(1,1,1); glScalef(8.0,0.25,3.0); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Interior.GLindex, Interior.GLindex);//superior glPopMatrix(); glPushMatrix(); glTranslatef(0.0,-0.75,1.5); glScalef(8.0,0.25,3.0); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Interior.GLindex, Interior.GLindex);//inferior glPopMatrix(); glPopMatrix(); } void Estantes::creaEstante2(){ glPushMatrix(); //glRotatef(movEst,0,0,1); glPushMatrix(); //glColor3f(0, 0, 1); glScalef(8.0,4,1.0); poligono.prismaEst(Interior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex);//parte trasera glPopMatrix(); glPushMatrix(); glTranslatef(0.0,2.25,1.5); glPushMatrix(); //glColor3f(0,1,1); glScalef(8.0,0.5,4.0);//glScalef(8.0,4.0,0.5); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Interior.GLindex, Exterior.GLindex);//parte arriba del estante(y+) glPopMatrix(); glTranslatef(4.25,-2.25,0.0); glPushMatrix(); glPushMatrix(); //glColor3f(0,1,0); glScalef(0.5,5.0,4.0); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex,Interior.GLindex,Exterior.GLindex, Exterior.GLindex);//lado der estante (x+) glPopMatrix(); glTranslatef(-0.25,0,1.88);//para que gire entorno al borde del estante //glRotatef(movDoorD,0,1,0); glTranslatef(-2,0,0);//para construir la puerta //glColor3f(1,0,1); glScalef(4,4,0.25); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Interior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex);; //puerta der glPopMatrix(); glTranslatef(-4.25,-2.25,0.0); glPushMatrix(); //glColor3f(1,1,0); glScalef(8.0,0.5,4.0); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Interior.GLindex);//parte baja del estante (y-) glPopMatrix(); glTranslatef(-4.25,2.25,0.0); glPushMatrix(); //glColor3f(1,0,0); glScalef(0.5,5.0,4.0); poligono.prismaEst(Exterior.GLindex, Interior.GLindex,Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex);//parte izq del estante (x-) glPopMatrix(); glTranslatef(0.25,0,1.88);//para que gire entorno al borde del estante // glRotatef(movDoorI,0,1,0); glTranslatef(2,0,0);//para construir la puerta //glColor3f(1,0,1); glScalef(4,4,0.25); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Interior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex); //puerta izquierda glPopMatrix(); //maderas intermedias glPushMatrix(); glTranslatef(0.0,0.75,1.5); //glColor3f(1,1,1); glScalef(8.0,0.25,3.0); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Interior.GLindex, Interior.GLindex);//superior glPopMatrix(); glPushMatrix(); glTranslatef(0.0,-0.75,1.5); glScalef(8.0,0.25,3.0); poligono.prismaEst(Exterior.GLindex, Exterior.GLindex,Exterior.GLindex, Exterior.GLindex,Interior.GLindex, Interior.GLindex);//inferior glPopMatrix(); glPopMatrix(); } void Estantes::creaLibrero(){ glColor3f(0.3,0.3,0.3); glPushMatrix(); glScalef(12,21,1); poligono.prismaEst(Interior.GLindex, madera.GLindex, madera.GLindex,madera.GLindex, madera.GLindex,maderaclara.GLindex);//parte trasera glPopMatrix(); glTranslatef(0,-10,2.5); for(int i = 0; i<6;i++){ glPushMatrix(); glPushMatrix(); glScalef(12,1,4); poligono.prismaEst(madera.GLindex, madera.GLindex, madera.GLindex,madera.GLindex, maderaclara.GLindex,maderaclara.GLindex);//primer madera (abajo) glPopMatrix(); if(i<5){//para que nos genere i-1 niveles de cilindros, i = num de tarimas glPushMatrix(); glTranslatef(-5.5,0.5,1.5); poligono.cilindro(0.5,3,10,madera.GLindex); glPopMatrix(); glPushMatrix(); glTranslatef(5.5,0.5,1.5); poligono.cilindro(0.5,3,10,madera.GLindex); glPopMatrix(); } glPopMatrix(); glTranslatef(0,4,0); } glColor3f(1,1,1); }
c08ef2b0411947a52a279b154055f2800e056b41
8924ba7719164c962b49c36c05d81d393915d456
/prototypev1/Tests/TestPolyconeContains.cpp
024114b32e881cdc0d1b64a59daa2690f540f7a4
[]
no_license
carlosal1015/VecGeom
23525ff91567d58cfde1aa7c66f9cc508a3b5bbf
12512cd7f67b89f7619a64474080ad24077aba10
refs/heads/master
2020-09-13T17:16:12.770167
2015-06-02T07:26:54
2015-06-02T07:57:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,442
cpp
TestPolyconeContains.cpp
/* * TestPolyconeContains.cpp * * Created on: Nov 18, 2013 * Author: swenzel */ // testing matrix transformations on vectors #include "../TransformationMatrix.h" #include "TGeoMatrix.h" #include "TGeoManager.h" #include "TGeoVolume.h" #include "TGeoShape.h" #include "../Utils.h" #include <iostream> #include "mm_malloc.h" #include "../GlobalDefs.h" #include "../GeoManager.h" #include "../PhysicalTube.h" #include "../TestShapeContainer.h" #include "../SimpleVecNavigator.h" // in order to compare to USolids #include "VUSolid.hh" #include "UTubs.hh" static void cmpresults(double * a1, double * a2, int np, PhysicalVolume const * vol, std::vector<Vector3D> const & points, std::vector<Vector3D> const & dirs) { int counter=0; for( auto i=0; i<np; ++i ) { if( std::abs( a1[i] - a2[i] ) > Utils::GetCarTolerance() ) { counter++; #ifdef SHOWDIFFERENCES std::cerr << i << " " << a1[i] << " " << a2[i] << std::endl; vol->DebugPointAndDirDistanceToIn( points[i], dirs[i] ); #endif } } std::cerr << " have " << counter << " differences " << std::endl; } int main() { Vectors3DSOA points, intermediatepoints; StructOfCoord rpoints, rintermediatepoints; int np = 102400; int NREPS = 1000; points.alloc(np); intermediatepoints.alloc(np); rpoints.alloc(np); rintermediatepoints.alloc(np); double *plainpointarray = (double *) _mm_malloc(3*np*sizeof(double), ALIGNMENT_BOUNDARY); GlobalTypes::SurfaceEnumType * results = (GlobalTypes::SurfaceEnumType * ) malloc( sizeof(GlobalTypes::SurfaceEnumType)*np); VUSolid::EnumInside * resultsUsolid = (VUSolid::EnumInside * ) malloc( sizeof(VUSolid::EnumInside)*np); bool * resultsROOT = (bool *) malloc(sizeof(bool)*np); int RN=100000; StopWatch timer; double * randomnumber = (double*) malloc(sizeof(double)*RN); // generate benchmark cases TransformationMatrix const * identity = new TransformationMatrix(0,0,0,0,0,0); // the world volume is a tube double worldrmax = 100.; double worldrmin = 0.; double worldz = 200.; PhysicalVolume * world = GeoManager::MakePlacedTube( new TubeParameters<>(worldrmin, worldrmax, worldz, 0, M_PI ), IdentityTransformationMatrix ); /* // a small polycone double zplanes[] = {-80, -20, 20, 80 }; double rinner[] = { 0, 0, 0, 0 }; double router[] = { 70, 70, 100, 100 }; int Nz=4; */ // a medium polycone /* double zplanes[] = {-90, -70, -50, -30, -10, 0, 10, 30, 50, 70, 90 }; double rinner[] = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; double router[] = { 70, 70, 100, 100, 70, 70, 70, 100, 100, 70, 70 }; const int Nz=11; */ // a large polycone // for(auto k=5;k<100;k+=5) // { const int Nz=10; double zplanes[Nz]; double rinner[Nz]; double router[Nz]; double scale = 100; for(auto i = 0;i< Nz; i++) { zplanes[i]=-90 + i*(180./(Nz-1)); rinner[i]=0.05*scale; if(i%4==0) router[i]=scale*0.7; if(i%4==1) router[i]=scale*0.7; if(i%4==2) router[i]=scale; if(i%4==3) router[i]=scale; } for(auto k=0;k<RN;k++) randomnumber[k] = zplanes[0] + (zplanes[Nz-1]-zplanes[0])/RN *k; /* // a minimal polycone double zplanes[] = {-80, 80 }; double rinner[] = { 0, 10, }; double router[] = { 50, 80, }; const int Nz=2; */ PolyconeParameters<> * pconp = new PolyconeParameters<>( 0, M_PI, Nz, zplanes, rinner, router ); /* timer.Start(); int s=0; for(auto i=0;i<RN;i++){ s+=pconp->FindZSectionDaniel( randomnumber[i] );} timer.Stop(); double t1=timer.getDeltaSecs(); //std::cerr << k << " " << t1 << std::endl; timer.Start(); int s2=0; for(auto i=0;i<RN;i++){ s2+=pconp->FindZSection( randomnumber[i] );} timer.Stop(); double t2=timer.getDeltaSecs(); //std::cerr << k << " " << t2 << std::endl; timer.Start(); int s3=0; for(auto i=0;i<RN;i++){ s3+=pconp->FindZSectionBS( randomnumber[i] );} timer.Stop(); double t3=timer.getDeltaSecs(); std::cerr << k << " " << t1 << " " << t2 << " " << t3 << " " << s << " " << s2 << " " << s3 << std::endl; std::cerr << pconp->FindZSectionDaniel( 11.34 ) << std::endl; std::cerr << pconp->FindZSection( 11.34 ) << std::endl; */ //} //exit(1); //PolyconeParameters<> * pconp; PhysicalVolume * pcon = GeoManager::MakePlacedPolycone(pconp, IdentityTransformationMatrix, true ); // fill points with no daughter inside; then place daughter world->fillWithRandomPoints(points,np); world->AddDaughter( pcon ); points.toPlainArray(plainpointarray,np); timer.Start(); for(int reps=0 ;reps < NREPS; reps++ ) { for( auto particle = 0; particle < np; ++particle ) results[particle] = pcon->Contains_WithSurface( points.getAsVector(particle) ); } timer.Stop(); double t0 = timer.getDeltaSecs(); std::cerr << t0 << std::endl; timer.Start(); for( int reps=0 ;reps < NREPS; reps++ ) { for( auto particle = 0; particle < np; ++particle ) { Vector3D pos = points.getAsVector(particle); // resultsUsolid[particle] = pcon->GetAsUnplacedUSolid()->Inside( reinterpret_cast<UVector3 const &>( pos )); resultsUsolid[particle] = pcon->GetAsUnplacedUSolid()->Inside( (UVector3 const &) pos ); } } timer.Stop(); double t1 = timer.getDeltaSecs(); std::cerr << t1 << std::endl; timer.Start(); for( int reps=0 ;reps < NREPS; reps++ ) { for( auto particle = 0; particle < np; ++particle ) { Vector3D pos = points.getAsVector(particle); resultsROOT[particle] = pcon->GetAsUnplacedROOTSolid()->Contains( &pos.x ); } } timer.Stop(); double t2 = timer.getDeltaSecs(); std::cerr << t2 << std::endl; int counter[3]={0,0,0}; int counterUSolid[3]={0,0,0}; int counterROOT[3]={0,0,0}; for( auto particle=0; particle<np; ++particle ) { counter[results[particle]]++; counterUSolid[resultsUsolid[particle]]++; counterROOT[(resultsROOT[particle])? 0 : 2]++; } for( auto j=0; j < 3; j++) { std::cerr << counter[j] << " " << counterUSolid[j] << " " << counterROOT[j] << std::endl; } return 1; }
062f875960748f4a3784181d6afbae16f281d8ba
0af9965de7527f4ca341833a5831dacd3fb8373f
/Baekjoon/2738.cpp
a1d0ec2d121352e65158d365329d23e5c89ff078
[]
no_license
pcw109550/problem-solving
e69c6b1896cedf40ec50d24c061541035ba30dfc
333d850a5261b49f32350b6a723c731156b24b8a
refs/heads/master
2022-09-18T08:25:16.940647
2022-09-12T10:29:55
2022-09-12T10:29:55
237,185,788
11
1
null
2022-09-12T10:18:49
2020-01-30T10:05:42
C++
UTF-8
C++
false
false
500
cpp
2738.cpp
#include <bits/stdc++.h> using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, temp; cin >> N >> M; int input[N][M] = {}; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cin >> input[i][j]; } } for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cin >> temp; cout << input[i][j] + temp; if (j != M) { cout << ' '; } } cout << '\n'; } }
63f2181a1334736ddbe7252512a3cfbb70ac85a2
161abc244263a051359e3dfbbb7ce5f2495c11e9
/SFML Graphing Calculator/!includes/Shuntting Yard/ShunttingYard.cpp
63fb55abec9e48ceccced2083af598d7f469bd64
[]
no_license
ggharibian/Graphing-Calculator-C
946e30c518ecd1055d17321f112c9933ab58834b
31287e41098ebd51576c4c2213ad7739d917611d
refs/heads/main
2023-08-17T17:50:41.816360
2021-10-12T10:30:43
2021-10-12T10:30:43
416,179,790
3
0
null
null
null
null
UTF-8
C++
false
false
1,110
cpp
ShunttingYard.cpp
#include "ShunttingYard.h" ShunttingYard::ShunttingYard(Queue<Token*> q) { Stack<Token*> buffer; while (!q.Empty()) { if (q.Front()->typeOf() == VARIABLE || q.Front()->typeOf() == OPERAND) _postfix.Push(q.Pop()); else if (buffer.Empty()) buffer.Push(q.Pop()); else if (q.Front()->precedence() == SixthPrecedence) { buffer.Push(q.Pop()); _postfix.Push(q.Pop()); _postfix.Push(buffer.Pop()); } else if (q.Front()->precedence() == FourthPrecedence) { q.Pop(); while (buffer.Top()->precedence() != FirstPrecedence) { _postfix.Push(buffer.Pop()); } buffer.Pop(); } else if (q.Front()->precedence() == FirstPrecedence || buffer.Top()->precedence() < q.Front()->precedence()) { buffer.Push(q.Pop()); } else if (buffer.Top()->precedence() >= q.Front()->precedence()) { while (!buffer.Empty() && buffer.Top()->precedence() >= q.Front()->precedence()) _postfix.Push(buffer.Pop()); buffer.Push(q.Pop()); } } while (!buffer.Empty()) _postfix.Push(buffer.Pop()); } Queue<Token*> ShunttingYard::getPostFix() { return _postfix; }
ffddac74dd95de353b163be2a6bab1c478981dcd
5cf7765e12dd5f7303c4f2c17c672e8276a056d9
/BehaviorTrees/Game/Source/Logic/Components/AIComponent/Behaviors/ChaseBehavior.h
d480f60263acea1f7a887a7e0e9eeccf7ff2d092
[]
no_license
mylescardiff/BehaviorTrees
000b059b4c3f377ad3033af9905b6801d634b8ed
2a40b6fbd6ffe553d856f3415ff7d4914e2b7cc5
refs/heads/master
2023-01-14T14:21:05.256595
2020-11-23T22:53:11
2020-11-23T22:53:11
315,449,165
0
0
null
null
null
null
UTF-8
C++
false
false
878
h
ChaseBehavior.h
#pragma once /** \file ChaseBehavior.h */ // Created by Myles Cardiff #include <Logic/Components/AIComponent/Behaviors/PathedBehavior.h> #include <Logic/Actor.h> /// <summary> /// Enables this actor to chase another actor /// </summary> class ChaseBehavior : public PathedBehavior { public: /// <summary> /// Explicit Constructor /// </summary> ChaseBehavior(slth::Actor* pActor, float aquireDistance, AIComponent* pOwner); /// <summary> /// XML Based Initializer /// </summary> /// <param name="xmlElement"></param> ChaseBehavior(XmlData* xmlElement, AIComponent* pOwner); /// <summary> /// Run Behavior /// </summary> /// <param name="deltaTime">Frame time</param> virtual Status Run(float deltaTime) override; private: float m_acquireDistance; float m_repathTime; float m_timer; // constants static constexpr float s_kPredictTurns = 1000; };
403a032b26862649b46a2e75fc5f00c9cec19285
83b8a9e0ba13a792f44fca455ba01043b9a81c78
/BOJ_SW_Practice_BruteForce/BOJ_SW_Practice_BruteForce/BOJ_1248.cpp
a40f4541c7fddaa561c1d10ad5826d24a9f8c5fc
[]
no_license
BoGyuPark/VS_BOJ
0799a0c62fd72a6fc1e6f7e34fc539a742c0782b
965973600dedbd5f3032c3adb4b117cc43c62a8f
refs/heads/master
2020-04-14T12:45:53.930735
2019-12-04T03:06:44
2019-12-04T03:06:44
163,849,994
0
0
null
null
null
null
UTF-8
C++
false
false
1,005
cpp
BOJ_1248.cpp
#include<iostream> #include<string> using namespace std; int n, s[11][11], ans[100]; bool check(int index) { int sum = 0; for (int i = index; i >= 0; i--) { sum += ans[i]; if (s[i][index] == 0) { if (sum != 0)return false; } else if (s[i][index] < 0) { if (sum >= 0) return false; } else if (s[i][index] > 0) { if (sum <= 0) return false; } } return true; } bool go(int index) { if (index == n) return true; if (s[index][index] == 0) { ans[index] = 0; return check(index) && go(index + 1); } for (int i = 1; i <= 10; i++) { ans[index] = s[index][index] * i; if (check(index) && go(index + 1)) return true; } return false; } int main() { cin >> n; string str; cin >> str; int cnt = 0; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { if (str[cnt] == '0') { s[i][j] = 0; } else if (str[cnt] == '-') { s[i][j] = -1; } else { s[i][j] = 1; } cnt++; } } go(0); for (int i = 0; i < n; i++) cout << ans[i] << ' '; }
cb97ef0cea2dca81486be12a162261b644c06081
e926bede54cbddf08870036ae478124e0a6cec77
/src/tests/unit_tests/particle_system_solvers_tests.cpp
06a05196428d97e0bdaa6b4991a65c8c583020e9
[ "MIT" ]
permissive
doyubkim/fluid-engine-dev
2d1228c78690191fba8ff2c107af1dd06212ca44
94c300ff5ad8a2f588e5e27e8e9746a424b29863
refs/heads/main
2023-08-14T08:04:43.513360
2022-07-09T06:24:41
2022-07-09T06:24:41
58,299,041
1,725
275
MIT
2022-07-09T06:24:41
2016-05-08T06:05:38
C++
UTF-8
C++
false
false
3,642
cpp
particle_system_solvers_tests.cpp
// Copyright (c) 2018 Doyub Kim // // I am making my contributions/submissions to this project solely in my // personal capacity and am not conveying any rights to any intellectual // property of any third parties. #include <jet/particle_system_solver2.h> #include <jet/particle_system_solver3.h> #include <gtest/gtest.h> using namespace jet; TEST(ParticleSystemSolver2, Constructor) { ParticleSystemSolver2 solver; auto data = solver.particleSystemData(); EXPECT_EQ(0u, data->numberOfParticles()); auto wind = solver.wind(); EXPECT_TRUE(wind != nullptr); auto collider = solver.collider(); EXPECT_EQ(nullptr, collider); } TEST(ParticleSystemSolver2, BasicParams) { ParticleSystemSolver2 solver; solver.setDragCoefficient(6.0); EXPECT_DOUBLE_EQ(6.0, solver.dragCoefficient()); solver.setDragCoefficient(-7.0); EXPECT_DOUBLE_EQ(0.0, solver.dragCoefficient()); solver.setRestitutionCoefficient(0.5); EXPECT_DOUBLE_EQ(0.5, solver.restitutionCoefficient()); solver.setRestitutionCoefficient(8.0); EXPECT_DOUBLE_EQ(1.0, solver.restitutionCoefficient()); solver.setRestitutionCoefficient(-8.0); EXPECT_DOUBLE_EQ(0.0, solver.restitutionCoefficient()); solver.setGravity(Vector2D(2, -10)); EXPECT_EQ(Vector2D(2, -10), solver.gravity()); } TEST(ParticleSystemSolver2, Update) { ParticleSystemSolver2 solver; solver.setGravity(Vector2D(0, -10)); ParticleSystemData2Ptr data = solver.particleSystemData(); ParticleSystemData2::VectorData positions(10); data->addParticles(positions.accessor()); Frame frame(0, 1.0 / 60.0); solver.update(frame); for (size_t i = 0; i < data->numberOfParticles(); ++i) { EXPECT_DOUBLE_EQ(0.0, data->positions()[i].x); EXPECT_NE(0, data->positions()[i].y); EXPECT_DOUBLE_EQ(0.0, data->velocities()[i].x); EXPECT_NE(0, data->velocities()[i].y); } } TEST(ParticleSystemSolver3, Constructor) { ParticleSystemSolver3 solver; auto data = solver.particleSystemData(); EXPECT_EQ(0u, data->numberOfParticles()); auto wind = solver.wind(); EXPECT_TRUE(wind != nullptr); auto collider = solver.collider(); EXPECT_EQ(nullptr, collider); } TEST(ParticleSystemSolver3, BasicParams) { ParticleSystemSolver3 solver; solver.setDragCoefficient(6.0); EXPECT_DOUBLE_EQ(6.0, solver.dragCoefficient()); solver.setDragCoefficient(-7.0); EXPECT_DOUBLE_EQ(0.0, solver.dragCoefficient()); solver.setRestitutionCoefficient(0.5); EXPECT_DOUBLE_EQ(0.5, solver.restitutionCoefficient()); solver.setRestitutionCoefficient(8.0); EXPECT_DOUBLE_EQ(1.0, solver.restitutionCoefficient()); solver.setRestitutionCoefficient(-8.0); EXPECT_DOUBLE_EQ(0.0, solver.restitutionCoefficient()); solver.setGravity(Vector3D(3, -10, 7)); EXPECT_EQ(Vector3D(3, -10, 7), solver.gravity()); } TEST(ParticleSystemSolver3, Update) { ParticleSystemSolver3 solver; solver.setGravity(Vector3D(0, -10, 0)); ParticleSystemData3Ptr data = solver.particleSystemData(); ParticleSystemData3::VectorData positions(10); data->addParticles(positions.accessor()); Frame frame(0, 1.0 / 60.0); solver.update(frame); for (size_t i = 0; i < data->numberOfParticles(); ++i) { EXPECT_DOUBLE_EQ(0.0, data->positions()[i].x); EXPECT_NE(0, data->positions()[i].y); EXPECT_DOUBLE_EQ(0.0, data->positions()[i].z); EXPECT_DOUBLE_EQ(0.0, data->velocities()[i].x); EXPECT_NE(0, data->velocities()[i].y); EXPECT_DOUBLE_EQ(0.0, data->velocities()[i].z); } }
713639ce74a3cee54c508b0d27fa45de1efc00f0
1777b7e6455bf4fae8240a28fcc44340256ca12b
/source/bitmapfilter/paint_saver_test.cpp
83b8ff7a06b7892106ab14f9631a646512f3b1c3
[]
no_license
vidarn/color4d
3444f448cb73f6f2149a8c175f9f7e688877c03d
8f5a40715d4a6f3a74fe75333ae32c58904ce547
refs/heads/master
2021-01-10T02:14:03.309767
2016-01-11T20:44:03
2016-01-11T20:44:03
49,448,413
5
0
null
null
null
null
UTF-8
C++
false
false
5,966
cpp
paint_saver_test.cpp
// this example source code saves out the selected BP texture // in all combinations (bitdepth, rgb, grey) of all registered // bitmap filters #include "c4d_commanddata.h" #include "c4d_resource.h" #include "c4d_general.h" #include "c4d_painter.h" #include "c4d_filterdata.h" #include "lib_description.h" #include "c4d_includes.h" #define ID_BITMAP_SAVER_TEST 200000109 class BitmapSaverTest : public CommandData { INSTANCEOF(BitmapSaverTest, CommandData) public: virtual Bool Execute(BaseDocument* doc); static BitmapSaverTest* Alloc() { return gNew BitmapSaverTest; } }; void CreateImageSaverList(BasePlugin *bp, AtomArray *array) { for (;bp; bp=bp->GetNext()) { if (bp->GetPluginType()==PLUGINTYPE_BITMAPSAVER) { array->Append(bp); } if (bp->GetDown()) CreateImageSaverList(bp->GetDown(),array); } } void ExportImage(PaintTexture *tex,BitmapSaverPlugin *bp, COLORMODE colormode,LONG needbits, SAVEBIT savebits,const String &append) { if (!(bp->GetInfo()&needbits)) return; LONG saveformat = bp->GetID(); String suffix; LONG alpha; bp->BmGetDetails(&alpha,&suffix); // if (suffix!="tif") return; GeData d_filename; tex->GetParameter(DescLevel(ID_PAINTTEXTURE_FILENAME),d_filename,DESCFLAGS_GET_0); Filename fn = d_filename.GetFilename(); fn.ClearSuffix(); if (bp->GetName().ToUpper().FindFirst("QUICKTIME",NULL,0)) fn.SetFile(fn.GetFileString()+String("_QUICK_")+suffix+String("_")+append); else fn.SetFile(fn.GetFileString()+String("_C4D_")+suffix+String("_")+append); fn.SetSuffix(suffix); PaintTexture *copy = (PaintTexture*)tex->GetClone(COPYFLAGS_0,NULL); if (!copy) return; copy->SetColorMode(colormode,FALSE); switch (needbits) { case PLUGINFLAG_BITMAPSAVER_SUPPORT_8BIT: case PLUGINFLAG_BITMAPSAVER_SUPPORT_16BIT: case PLUGINFLAG_BITMAPSAVER_SUPPORT_32BIT: { AutoAlloc<BaseBitmap> merge; if (copy->ReCalc(NULL,0,0,copy->GetBw(),copy->GetBh(),merge,RECALC_NOGRID|RECALC_INITBMP,0)) { BaseContainer data; if (merge->Save(fn,saveformat,&data,savebits|SAVEBIT_ALPHA)!=IMAGERESULT_OK) { GeOutString("Error saving image \""+append+"\"",GEMB_OK); } } } break; case PLUGINFLAG_BITMAPSAVER_SUPPORT_8BIT_LAYERS: case PLUGINFLAG_BITMAPSAVER_SUPPORT_16BIT_LAYERS: case PLUGINFLAG_BITMAPSAVER_SUPPORT_32BIT_LAYERS: { copy->SetParameter(DescLevel(ID_PAINTTEXTURE_FILENAME),fn,DESCFLAGS_SET_0); copy->SetParameter(DescLevel(ID_PAINTTEXTURE_SAVEFORMAT),saveformat,DESCFLAGS_SET_0); BaseContainer bc; bc.SetLong(PAINTER_SAVETEXTURE_FLAGS,PAINTER_SAVEBIT_SAVECOPY); SendPainterCommand(PAINTER_SAVETEXTURE,NULL,copy,&bc); } break; } SendPainterCommand(PAINTER_FORCECLOSETEXTURE,NULL,copy,NULL); } Bool BitmapSaverTest::Execute(BaseDocument *doc) { /* AutoAlloc<BaseBitmap> bmp; bmp->Init(100,100,24); BaseBitmap *a1 = bmp->AddChannel(TRUE,FALSE); BaseBitmap *a2 = bmp->AddChannel(FALSE,FALSE); bmp->Clear(255,128,0); if (a1) { LONG y; UCHAR buf[] = { 128 }; for (y=0;y<100;y++) a1->SetPixelCnt(0,y,100,buf,0,COLORMODE_GRAY,0); } if (a2) { LONG y; UCHAR buf[] = { 255 }; for (y=0;y<100;y++) a2->SetPixelCnt(0,y,100,buf,0,COLORMODE_GRAY,0); } bmp->Save(Filename("G:\\3D\\BP3 test stuff\\format_conversion_test\\test.tif"),FILTER_TIF,NULL,SAVEBIT_32BITCHANNELS|SAVEBIT_GREYSCALE|SAVEBIT_ALPHA); // bmp->Save(Filename("G:\\3D\\BP3 test stuff\\format_conversion_test\\test.tif"),FILTER_TIF,NULL,SAVEBIT_16BITCHANNELS|SAVEBIT_ALPHA); //return TRUE; */ PaintTexture *tex = PaintTexture::GetSelectedTexture(); if (!tex) { GeOutString("No Texture Selected",GEMB_OK); return FALSE; } BasePlugin *bp = GetFirstPlugin(); AutoAlloc<AtomArray> array; CreateImageSaverList(bp,array); LONG i; for (i=0;i<array->GetCount();i++) { BitmapSaverPlugin *bp = (BitmapSaverPlugin*)array->GetIndex(i); ExportImage(tex,bp,COLORMODE_RGB ,PLUGINFLAG_BITMAPSAVER_SUPPORT_8BIT ,SAVEBIT_0 ,"_8Bit_rgb_flat" ); ExportImage(tex,bp,COLORMODE_RGBw,PLUGINFLAG_BITMAPSAVER_SUPPORT_16BIT ,SAVEBIT_16BITCHANNELS ,"16Bit_rgb_flat" ); ExportImage(tex,bp,COLORMODE_RGBf,PLUGINFLAG_BITMAPSAVER_SUPPORT_32BIT ,SAVEBIT_32BITCHANNELS ,"32Bit_rgb_flat" ); ExportImage(tex,bp,COLORMODE_RGB ,PLUGINFLAG_BITMAPSAVER_SUPPORT_8BIT_LAYERS ,SAVEBIT_MULTILAYER ,"_8Bit_rgb_layers" ); ExportImage(tex,bp,COLORMODE_RGBw,PLUGINFLAG_BITMAPSAVER_SUPPORT_16BIT_LAYERS,SAVEBIT_MULTILAYER|SAVEBIT_16BITCHANNELS,"16Bit_rgb_layers"); ExportImage(tex,bp,COLORMODE_RGBf,PLUGINFLAG_BITMAPSAVER_SUPPORT_32BIT_LAYERS,SAVEBIT_MULTILAYER|SAVEBIT_32BITCHANNELS,"32Bit_rgb_layers"); ExportImage(tex,bp,COLORMODE_GRAY,PLUGINFLAG_BITMAPSAVER_SUPPORT_8BIT ,SAVEBIT_GREYSCALE ,"_8Bit_grey_flat" ); ExportImage(tex,bp,COLORMODE_GRAYw,PLUGINFLAG_BITMAPSAVER_SUPPORT_16BIT ,SAVEBIT_GREYSCALE|SAVEBIT_16BITCHANNELS ,"16Bit_grey_flat" ); ExportImage(tex,bp,COLORMODE_GRAYf,PLUGINFLAG_BITMAPSAVER_SUPPORT_32BIT ,SAVEBIT_GREYSCALE|SAVEBIT_32BITCHANNELS ,"32Bit_grey_flat" ); ExportImage(tex,bp,COLORMODE_GRAY,PLUGINFLAG_BITMAPSAVER_SUPPORT_8BIT_LAYERS ,SAVEBIT_GREYSCALE|SAVEBIT_MULTILAYER ,"_8Bit_grey_layers" ); ExportImage(tex,bp,COLORMODE_GRAYw,PLUGINFLAG_BITMAPSAVER_SUPPORT_16BIT_LAYERS,SAVEBIT_GREYSCALE|SAVEBIT_MULTILAYER|SAVEBIT_16BITCHANNELS,"16Bit_grey_layers"); ExportImage(tex,bp,COLORMODE_GRAYf,PLUGINFLAG_BITMAPSAVER_SUPPORT_32BIT_LAYERS,SAVEBIT_GREYSCALE|SAVEBIT_MULTILAYER|SAVEBIT_32BITCHANNELS,"32Bit_grey_layers"); } return TRUE; } Bool RegisterPainterSaveTest() { #ifdef _DEBUG return RegisterCommandPlugin(ID_BITMAP_SAVER_TEST, String("C++ SDK - BitmapSaverTest"), 0, NULL, String("BitmapSaverTest"), BitmapSaverTest::Alloc()); #else return TRUE; #endif }
dbe67df50c54ff8bf54b1c4c0e7fa1abef7762fc
de842f70795c27bebbdb6447a9c92d51ad26a5f4
/sunbeamish.ino
42356f039b238e3d7c9c39432b8d04697bb23b55
[]
no_license
karlsoderby/arduinobasics
ed938fde47f491016fd76fc4c04a31aab7fb55c5
7b6c052c0f1aa1ca01f3a68a8bed16fcbb35e696
refs/heads/master
2020-03-23T12:16:45.153687
2018-07-21T08:17:32
2018-07-21T08:17:32
141,548,874
0
0
null
null
null
null
UTF-8
C++
false
false
284
ino
sunbeamish.ino
int photoPin = A0; int ledPin = 2; int photoValue = 0; void setup() { pinMode(ledPin, OUTPUT); } void loop() { photoValue = analogRead(photoPin); Serial.println(photoValue); if(photoValue > 700) { digitalWrite(ledPin, HIGH); delay(3000); digitalWrite(ledPin, LOW); } }
0049c7441d041a7fa054e915cbeabeb48769c61d
9272c1cb5e356063896b0f91c483ba15c36d33c3
/tools/lint/Ytest.cpp
ac98204143f6a08aba630087ae4e5d02f6904fff
[ "BSD-3-Clause" ]
permissive
ken1336/Yangmin
4ee8468f2d0f6c89ce17170cc7a08564a16c0a8e
d2adbb7547a0b12662e1cdfc78cbdcbfb574277b
refs/heads/master
2020-09-08T15:28:46.334254
2019-12-17T09:14:18
2019-12-17T09:14:18
221,171,731
0
0
null
null
null
null
UTF-8
C++
false
false
1,678
cpp
Ytest.cpp
#include<iostream> #include<cassert> #include "libyang.h" #include "commands.h" #include "context.h" #include "./min_extension/internal_module.hpp" #include"./min_extension/Context.hpp" volatile uint8_t verbose = 0; int main(){ //commands[i].func((const char *)"cmd_add"); //std::cout<<"internal modules count:"<<ctx->internal_module_count<<std::endl; min::context::Context ctx{}; //min::internal::InternalModule iModule{ctx.getContext()}; //std::cout<<iModule.getName()<<std::endl; //iModule.printModuleData(); ctx.add_model("../ietf-netconf.yang"); //ctx.print_list(stdout,LYD_XML); auto module = ctx.getModuleByIndex(6); std::cout<<module->getName()<<std::endl; module->printModuleData(0); module->test(); //ctx.print_xml(); //ly_modules_list list= ctx->models; std::cout<<"---------------------------------------list----------------------"<<std::endl; //std::cout<<"---------------------------------------"<<list.parsed_submodules_count<<"----------------------"<<std::endl; //std::cout<<"---------------------------------------"<<list.parsing_sub_modules_count<<"----------------------"<<std::endl; for(auto i = 0; i< 7; i++){ //std::cout<<ctx->models.list[i]->name<<std::endl; //std::cout<<list.list[i]->name<<std::endl; //ly_ctx_unset_searchdirs(ctx,i); } //min::internal::InternalModule iModule2{list.list[6]}; //iModule2.printModuleData(); //commands[1].func("ietf-netconf.yang"); std::cout<<"---------------------------------------clean----------------------"<<std::endl; }
3267b86f144b1aa2e10afd9170b40410deef7571
6d088ec295b33db11e378212d42d40d5a190c54c
/contrib/brl/bseg/bvxm/grid/Templates/bvxm_voxel_slab+bsta_vsum_num_obs+bsta_von_mises+float.3---.cxx
0bb64f88e4048e0533b9c40aba40676362108678
[]
no_license
vxl/vxl
29dffd5011f21a67e14c1bcbd5388fdbbc101b29
594ebed3d5fb6d0930d5758630113e044fee00bc
refs/heads/master
2023-08-31T03:56:24.286486
2023-08-29T17:53:12
2023-08-29T17:53:12
9,819,799
224
126
null
2023-09-14T15:52:32
2013-05-02T18:32:27
C++
UTF-8
C++
false
false
300
cxx
bvxm_voxel_slab+bsta_vsum_num_obs+bsta_von_mises+float.3---.cxx
#include <bvxm/grid/bvxm_voxel_slab.hxx> #include <bsta/bsta_attributes.h> #include <bsta/bsta_von_mises.h> #include <bsta/io/bsta_io_von_mises.h> #include <bsta/io/bsta_io_attributes.h> typedef bsta_vsum_num_obs<bsta_von_mises<float, 3> > dir_dist_type; BVXM_VOXEL_SLAB_INSTANTIATE(dir_dist_type);
2fa274117690e30486b57a75eb0b60f00eaf387e
9f04be5d5fbf90fb3178dbd42eb832be457483e2
/Sort_Sandbox.cpp
4723510151ad1c61638ad22e6f91ddb734c74169
[]
no_license
erasabi/sorting_algorithm_tester
05120a7b42b3070f6c1a0b818e6f711798238ee1
fcfd6c20a542f3b9f1edc6e610d587c3fe1f9029
refs/heads/master
2021-01-13T13:07:44.255273
2017-01-14T05:06:41
2017-01-14T05:06:41
78,834,013
0
0
null
null
null
null
UTF-8
C++
false
false
916
cpp
Sort_Sandbox.cpp
#include "Sort_Sandbox.h" #include <iostream> #include <stdio.h> #include <stdlib.h> //rand() #include <math.h> //pow() #include <sstream> //stringstream using namespace std; int main(int argc, char* argv[]){ int power, //power factor for array size n; //sample size of the array char data; //output data preference string sort_type = argv[1]; stringstream arg2; //takes char* input and converts to integer value arg2 << argv[2]; arg2 >> power; n = pow(4, power); //creates sample size for array data = *argv[3]; //initializes data preference int a[n]; //creates array of size n //initializes array with random numbers for(int i=0; i<n; i++) a[i] = rand() % n; if(sort_type == "insertion") insertion(a, n, data); else if(sort_type == "bubble") bubble(a, n, data); else cout << "error: invalid sort type" << endl; /**/ return 0; };
e3f168ceae8ef4c3b525ad3db74f4b7053ba3b6c
f7dff25777c257eaf60d29fdcbc7da10146a0416
/1181.cpp
d211b7fb8fa26dc7ab275f9dc2f708f348f7ef10
[]
no_license
pese2912/Algorithm
752cf989c62e4654642158a59d91b106b3f2a584
b23935f6a945e0e67b9f2fdea88c86cad35bb9f9
refs/heads/master
2021-01-10T05:36:12.322680
2016-04-12T12:22:36
2016-04-12T12:22:36
53,909,798
0
0
null
null
null
null
UTF-8
C++
false
false
662
cpp
1181.cpp
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <vector> using namespace std; bool comp(const string &a, const string &b) { if (a.size() < b.size()) { return true; } else if (a.size() == b.size()){ if (a < b){ return true; } else return false; } else { return false; } } int main() { vector<string> str; int num; scanf("%d", &num); for (int i = 0; i < num; i++) { string a; cin >> a; str.push_back(a); } sort(str.begin(), str.end(), comp); for (int i = 0; i < num; i++) { if (i>0 && str[i] == str[i-1]) { continue; } cout << str[i] << '\n'; } return 0; }
02b17e26d52e4a92d923fe93bf57945965534ac1
bc629494a8be039a8184f7959c531bfa1fb22abc
/pot.cpp
f2961c6a85c3f4dc88e795f9547ec1306c45a703
[]
no_license
emilppp/open.kattis.com
f2f47c4df10a9faf07f8a30b670172a3d3f4f2fe
d779e3c02f7641700e15aa37a58230421498ffdf
refs/heads/master
2021-09-07T14:56:38.000290
2018-02-24T11:51:31
2018-02-24T11:51:31
107,008,096
0
0
null
null
null
null
UTF-8
C++
false
false
241
cpp
pot.cpp
#include <iostream> #include <cmath> using namespace std; int main() { int n; long sum = 0; cin >> n; while(n--) { int p; cin >> p; sum += pow(p/10, p%10); } cout << sum; return 0; }
a1c108ef00cdadf54d4554fcc38e99f95a3e25ea
f61bb2133a9f149febae0dac34e00f7e627822a9
/Graficos II/DLL/EventManager.cpp
79408813fdd0a94223f0b4378dbd69edf416a3a5
[]
no_license
Lithiot/Graficos-II
35673d328693294462608414b01d1260c5dd90cc
3330eefe5d9e362f4ec27dea5b8a24d5cc503c89
refs/heads/master
2021-06-29T18:15:48.682390
2019-08-06T03:54:22
2019-08-06T03:54:22
144,927,528
0
0
null
null
null
null
UTF-8
C++
false
false
1,608
cpp
EventManager.cpp
#include "EventManager.h" EventManager* EventManager::instance = NULL; EventManager::EventManager() { } EventManager::~EventManager() { } void EventManager::AddNewEvent(int key, int value, int* valueToChange) { Event aux(key, value, valueToChange); createdEvents.push_back(aux); } void EventManager::AddNewEvent(int key, float value, float* valueToChange) { Event aux(key, value, valueToChange); createdEvents.push_back(aux); } void EventManager::AddNewEvent(int key, bool value, bool* valueToChange) { Event aux(key, value, valueToChange); createdEvents.push_back(aux); } void EventManager::ExecuteEvent(int key) { for (int i = 0; i < createdEvents.size(); i++) { Event aux = createdEvents.at(i); if (aux.key == key) { switch (aux.type) { case CHANGE_INT: *aux.intValueToChange = aux.intChangedValue; break; case CHANGE_FLOAT: *aux.floatValueToChange = aux.floatChangedValue; break; case CHANGE_BOOL: *aux.boolValueToChange = aux.boolChangedValue; break; } } } } Event::Event(int eventKey, int value, int* valueToChange) { key = eventKey; type = CHANGE_INT; intChangedValue = value; intValueToChange = valueToChange; } Event::Event(int eventKey, float value, float* valueToChange) { key = eventKey; type = CHANGE_FLOAT; floatChangedValue = value; floatValueToChange = valueToChange; } Event::Event(int eventKey, bool value, bool* valueToChange) { key = eventKey; type = CHANGE_BOOL; boolChangedValue = value; boolValueToChange = valueToChange; }
36b221e2a673ae63df3b6a5aae1a881aa4b0914c
aaeda5a34c75c9d9414aebe2d28360a9bbf803f5
/core/mepcomposite.h
5e22dc59f0321e295707c0cc0cffab63edfb7053
[]
no_license
dpietruchowski/MEPVision
598e4cb77acd310a8a8ea0feadc8b8b2d5ec58ac
10da2952735ce898ce3afac226b6938b6ed467e3
refs/heads/master
2020-03-29T21:57:45.669698
2016-08-12T12:08:14
2016-08-12T12:08:14
62,752,434
2
0
null
null
null
null
UTF-8
C++
false
false
2,095
h
mepcomposite.h
#ifndef MEPCOMPOSITE_H #define MEPCOMPOSITE_H #include "mepobject.h" #include "mepgene.h" #include <vector> #include <string> //TODO addchild - shouldnt be here class MEPSHARED_EXPORT MEPComposite : public MEPObject { public: typedef std::vector<MEPObjectPtr> Objects; MEPComposite(const MEPId& id, int size); MEPComposite(const MEPComposite&); void init(MEPGenerator&); int getSize() const; int getSumScore() const; bool isValid() const; bool isValidResults() const; void show(); std::vector<bool> isObjectsClone(const MEPComposite&); std::vector<bool> compare(const MEPComposite &rhs, int size) const; const MEPObject& findByOrder(int number) const; const MEPObject& findByRank(const int rank) const; const MEPObject& findById(const MEPId&) const; int findNumber(const MEPId&) const; int find(const MEPObject&) const; void clonePart(const MEPComposite& rhs, int startGeneNumber, int endGeneNumber); void addObject(MEPObjectPtr object, std::vector<int> args = std::vector<int>()); bool setObject(MEPObjectPtr object, std::vector<int> args = std::vector<int>()); const MEPObject& select(MEPSelectionType) const; protected: void swap(MEPComposite&); private: //Dziedziczace po MEPObject void saveObject(std::string&) const; void writeObject(std::string&) const; void writeObjectTree(std::string&) const; void showObject(const std::string& id); // void showObjectTree(const std::string& id) const; void clearObjectResults(); int sortObject(); int runObject(MEPFitness& fitness); virtual void addObject(Objects&, MEPObject&, std::vector<int>&) {} virtual MEPObjectPtr cloneObject() const = 0; //Meotdy MEPComposite virtual void initComposite(MEPGenerator&, int size) = 0; virtual void cloneCompositeObject(const MEPComposite& rhs, int objectNumber) = 0; private: Objects objects_; int size_; double normalized_; }; #endif // MEPCOMPOSITE_H
2d97248012066705b8c1820e6a16c561a8248fc7
e3ec7d68f544e82c6016409ce2a59a5680f19b1e
/C++/kniha/kap6/sumafile.cpp
a0695fff1e00e47a37ffe126c0bffb2b32830447
[]
no_license
branislavblazek/notes
429a9c3ceb142de9cfb460a0a8c1389f2313454e
e88072ff01ecba6e96d70decb5b5597755b8e925
refs/heads/master
2021-10-23T13:33:59.211385
2021-10-13T19:41:03
2021-10-13T19:41:03
239,040,112
0
0
null
null
null
null
UTF-8
C++
false
false
1,064
cpp
sumafile.cpp
#include <iostream> #include <fstream> #include <cstdlib> using namespace std; const int size = 60; int main() { char filename[size]; ifstream inFile; cout << "Zadajte meno datoveho suboru: "; cin.getline(filename, size); inFile.open(filename); if (!inFile.is_open()) { cout << "Nepodarilo sa otvorit subor " << filename << endl; exit(EXIT_FAILURE); } double value; double sum = 0.0; int count = 0; inFile >> value; while (inFile.good()) //while not EOF or something else { ++count; sum += value; inFile >> value; } if (inFile.eof()) { cout << "Koniec suboru" << endl; } else if (inFile.fail()) { cout << "Citanie sa ukoncilo, nespravne data" << endl; } else { cout << "Citanie sa ukoncilo" << endl; } if (count == 0) { cout << "Nespracovali sa ziadne data" << endl; } else { cout << "Pocet precitanych poloziek: " << count << endl; cout << "Sucet: " << sum << endl; cout << "Priemer: " << sum / count << endl; } inFile.close(); return 0; }
2a73f24d91f9fdf6b39e657d0fe8ef1017c38794
047b09758514aacb5d647380faa34b596a358ddb
/Delim.cpp
86112fdef2c8aba54f742cbeb54aa3468c08b778
[]
no_license
devonrball/Assignment3
d16f6fbf1d5aa8c94433a18a14d32e7276795d8b
741c6ef2dd5ab5c267d59568a2d2b046f381c322
refs/heads/master
2020-04-01T00:30:39.487007
2018-10-12T06:59:28
2018-10-12T06:59:28
152,700,026
0
0
null
null
null
null
UTF-8
C++
false
false
1,117
cpp
Delim.cpp
#include "Delim.h" using namespace std; Delim::Delim() //No use for default constructor in this implementation { data = '\0'; rightDelim = false; leftDelim = false; newLine = false; } Delim::Delim(char someChar) { data = someChar; checkIfDelim(); if(data==')'){ closer = '('; } else if(data==']'){ closer = '['; } else if(data == '}'){ closer = '{'; } else{ closer = '\0'; } } /*~Delim::Delim() { cout << "Delim deconstructed" << endl; }*/ bool Delim::checkIfDelim() { if((data=='(') || (data=='{') || (data=='[')){ this->leftDelim = true; this->rightDelim = false; this->newLine = false; } //identifies left Delimiters else if((data==')') || (data=='}') || (data==']')){ this->leftDelim = false; this->rightDelim = true; this->newLine = false; } //identifies right delimiters else { this->leftDelim = false; this->rightDelim = false; if(data=='\n'){ this->newLine = true; }else { this->newLine = false; } } // Identifies non-delimiters }
d876c944a09ab555206ce972ec652f47e91f65dd
5818c5cd536d5b04dd8a35f7362edf57e2832262
/recursion/10_horner's_rule.cpp
6ded848957393d0bacf66c6b8593c46d0f0d7665
[]
no_license
sanju-k-maurya/DSA_using_cpp
7ec0182e953677cdfcecc33fd22e202c600fc1dc
92379389ab67cd6662295a1e28acece7f8f6dcba
refs/heads/master
2023-03-01T05:07:59.016366
2021-02-04T17:55:15
2021-02-04T17:55:15
236,751,014
0
0
null
null
null
null
UTF-8
C++
false
false
608
cpp
10_horner's_rule.cpp
#include<iostream> using namespace std; double e(int x, int n) //Recursive approach { static double s; if(n==0) return s; s=1+ x*s/n; return e(x, n-1); } double e_iterative(int x, int n) //Iterative approach { double s=1; int i; double num=1; double den = 1; for(i=1;i<=n;i++) { num*=x; den*=i; s+=num/den; } return s; } int main() { int x,n; cout<<"Enter x and n : "; cin>>x>>n; cout<<e(x,n)<<endl; cout<<e_iterative(x,n)<<endl; return 0; }
73ad6508ee2a90ee2559186366e6417adfa4bac7
7dea2ddea8dfc593d1254d20be2a31a6e3520105
/exam/For all/Untitled Folder/exampleforall.cpp
98d2994dc96a47deb6976f7ef808ea01bb1f7119
[]
no_license
ken-hsu/pathplanning
13c1903d53c0ffc7c9b26a7a5b8d2772a78a2981
9843232d8a60d77c7683111143e4ae08208d6440
refs/heads/master
2021-07-26T12:45:13.676817
2020-04-24T02:43:27
2020-04-24T02:43:27
158,222,926
0
0
null
null
null
null
UTF-8
C++
false
false
3,384
cpp
exampleforall.cpp
/** * increase_waypoint2 */ #include "rt_nonfinite.h" #include "increase_waypoint2.h" #include "increase_waypoint2_terminate.h" #include "increase_waypoint2_emxAPI.h" #include "increase_waypoint2_initialize.h" /** * calcualte_distance2 */ #include "calculate_distance2.h" #include "calculate_distance2_terminate.h" #include "calculate_distance2_emxAPI.h" #include "calculate_distance2_initialize.h" /** * GPS2HIGHTC */ #include "GPS2HIGHTC.h" #include "GPS2HIGHTC_terminate.h" #include "GPS2HIGHTC_initialize.h" /** * HIGHT2SLOPE */ #include "HIGHT2SLOPE.h" #include "HIGHT2SLOPE_terminate.h" #include "HIGHT2SLOPE_initialize.h" #include <iostream> #include <stdio.h> using namespace std; #include <opencv2/opencv.hpp> int main(){ /** * increase_waypoint2 */ double lat[2] = {22.3339,22.3338}; double lon[2] = {121.4012,121.4002}; emxArray_real_T *waypoint_add_lat_ptr; emxArray_real_T *waypoint_add_lon_ptr; double waypoint_add_amount; emxInitArray_real_T(&waypoint_add_lat_ptr, 1); emxInitArray_real_T(&waypoint_add_lon_ptr, 1); increase_waypoint2(lat, lon, waypoint_add_lat_ptr, waypoint_add_lon_ptr, &waypoint_add_amount); // for (int i = 0 ;i < (int)waypoint_add_amount; i++){ // printf("%.4f \n",waypoint_add_lon->data[i]); // } /** * calcualte_distance2 */ emxArray_real_T *x_coordination; emxArray_real_T *dis_meter; int waypoint_lat_size[1]; int waypoint_lon_size[1]; double waypoint_lat_data[2000]; double waypoint_lon_data[2000]; emxInitArray_real_T(&x_coordination, 1); emxInitArray_real_T(&dis_meter, 1); double num_point = waypoint_add_amount; double init_lat = lat[0]; for (int i = 0; i<(int)waypoint_add_amount; i++){ waypoint_lat_data[i] = waypoint_add_lat_ptr->data[i]; waypoint_lon_data[i] = waypoint_add_lon_ptr->data[i]; } calculate_distance2(waypoint_lat_data, waypoint_lat_size, waypoint_lon_data, waypoint_lon_size,num_point ,init_lat, x_coordination, dis_meter); // for (int i = 0 ;i < (int)num_point; i++){ // printf("%.4f \n",x_coordination->data[i]); // } /** * GPS2HIGHTC */ cv::Mat img = cv::imread("/home/ken/src/Ken/pathplanning/ASTGTM2_N24E121_dem.tif",-1); cv::imshow("rgb",img); short int* img_data_ptr = (short int*)img.data; int Latitude_size[1] = {waypoint_add_amount}; int Lontitude_size[1] = {waypoint_add_amount}; double H_data[4000]; int H_size[1]; double c_record_data[8000]; int c_record_size[2]; GPS2HIGHTC(waypoint_lat_data, Latitude_size, waypoint_lon_data, Lontitude_size, img_data_ptr, H_data, H_size, c_record_data, c_record_size); for (int i = 0; i <(int)num_point; i++ ){ printf("[Hight is %.4f || H size is %d || index row %.4f || index column %.4f ]\n", H_data[i],H_size[0],c_record_data[i],c_record_data[i+11]); } /** * HIGHT2SLOPE */ int hight_size[1] = {waypoint_add_amount}; int dis_size[1] = {waypoint_add_amount}; double dis_data[4000]; double slope_data[3999]; int slope_size[1]; for (int i = 0; i <(int)num_point; i++ ){ dis_data[i] = dis_meter->data[i]; } HIGHT2SLOPE(H_data, hight_size, dis_data, dis_size, slope_data, slope_size); for (int i = 0; i < hight_size[0]; i++){ printf("%f \n",slope_data[i]); } }
bb0908770582f475c75a97efc9597f20dcc34398
020d30182de8039c46b3dd50fedeb8e775e847a3
/src/dataset.h
db2f2361977d3ac2d750f414aea0a4f9a2acf7c0
[]
no_license
VictorEijkhout/EduDL-public
a2638816c1fbd65da1b243537bc7c625b9f1b294
2c90a166133d4703c04b57575930fafd8d7a0c34
refs/heads/main
2023-04-18T22:10:33.430079
2021-05-08T21:00:01
2021-05-08T21:00:01
356,033,063
2
1
null
null
null
null
UTF-8
C++
false
false
3,056
h
dataset.h
/**************************************************************** **************************************************************** **** **** This text file is part of the source of **** `Introduction to High-Performance Scientific Computing' **** by Victor Eijkhout, copyright 2012-2021 **** **** Deep Learning Network code **** copyright 2021 Ilknur Mustafazade **** **************************************************************** ****************************************************************/ #ifndef CODE_DATASET_H #define CODE_DATASET_H //#include "matrix.h" #include "vector2.h" #include "vector.h" #include <vector> #include <iostream> class dataItem{ public: // should really be done through friends private: Vector data; // Data matrix //Vector label; // Label Categorization label; // Label public: dataItem( Vector data,/* Vector */ Categorization label) : data(data),label(label) {}; dataItem( float data,Categorization label) : data( std::vector<float>(data) ),label(label) {}; dataItem( std::vector<float> indata,std::vector<float> outdata ) : data( Vector(indata) ),label( Categorization(outdata) ) {}; int data_size() const { return data.size(); }; const std::vector<float>& data_values() const { return data.values(); }; int label_size() const { return label.size(); }; const std::vector<float>& label_values() const { return label.probabilities(); }; }; class Dataset { private: int nclasses{0}; // std::vector<dataItem> _items; // All the data: {data, label} private: VectorBatch dataBatch; VectorBatch labelBatch; int lowerbound{0},number{0}; public: Dataset() {}; Dataset( int n ); Dataset( std::vector<dataItem> ); void set_lowerbound( int b ); void set_number( int b ); void push_back(dataItem it); int size() const; int data_size() const; int label_size() const; dataItem item(int i) const; // const dataItem& at(int i) const { return _items.at(i); }; // dataItem& at(int i) { return _items.at(i); }; const Vector& data(int i) const; const std::vector<float> data_vals(int i) const; const std::vector<float> label_vals(int i) const; std::vector<float> stacked_data_vals(int i) const; std::vector<float> stacked_label_vals(int i) const; // const Categorization& label(int i) const { return _items.at(i).label; }; // const std::vector<dataItem>& items() const { return _items; }; //const Vector& label(int i) const { return items.at(i).label; }; std::string path; // Path of the dataset public: const auto& inputs() const { return dataBatch; }; const auto& labels() const { return labelBatch; }; int readTest(std::string dataPath); // Read modified MNIST Dataset void shuffle(); // Mix the dataset std::vector<Dataset> batch(int n) const; // Divides the dataset into n batches void stack(); std::pair<Dataset,Dataset> split(float trainFraction) const; // Train-test split }; #endif //CODE_DATASET_H
66ea2667a49cf9e5c679608a045962a069c5c89d
184bcf7925e6718b3021946581576f8cae80526b
/Useless/vijos/Train_base/3-simulate/p1772.cpp
da89b015b0be5e809a3cc40c495b93774dc03665
[]
no_license
iPhreetom/ACM
a99be74de61df37c427ffb685b375febad74ed9a
f3e639172be326846fe1f70437dcf98c90241aa0
refs/heads/master
2021-06-14T08:11:24.003465
2019-09-13T22:54:34
2019-09-13T22:54:34
142,748,718
0
0
null
null
null
null
UTF-8
C++
false
false
434
cpp
p1772.cpp
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); int ar[] = {1,2,3,4,5,6,7,8,9}; while(next_permutation(ar,ar+9)){ int a,b,c,i=0; a = ar[i++]*100 + ar[i++]*10 + ar[i++]; c = ar[i++]*100 + ar[i++]*10 + ar[i++]; b = ar[i++]*100 + ar[i++]*10 + ar[i++]; if(b == a*2 && c == a*3){ cout<<a<<' '<<b<<' '<<c<<'\n'; } } return 0; }
65dd4d57b57218520f7b2069d406c127ec39ef57
e43484bb35e711adbf5e7357a912fcc4eaef8a1f
/Git-Dashboard/GetPasswordsWindow.h
1f153feb1293e8d9e42acd68e4eedfd367b9dd9f
[ "MIT" ]
permissive
jplflyer/Git-Dashboard
8aeb38e6dc5bac714a5d5e5bf0e24fb0f62cef29
1aeaeb8495a5cfdc00906b9b82e798936df67f7c
refs/heads/main
2023-03-26T09:48:01.200218
2021-03-29T16:45:25
2021-03-29T16:45:25
343,510,329
1
0
null
null
null
null
UTF-8
C++
false
false
632
h
GetPasswordsWindow.h
#pragma once #include <QWidget> #include <showlib/StringVector.h> namespace Ui { class GetPasswordsWindow; } class GetPasswordsWindow : public QWidget { Q_OBJECT public: explicit GetPasswordsWindow(ShowLib::StringVector &vec, QWidget *parent = nullptr); ~GetPasswordsWindow(); private slots: void on_revealCB_stateChanged(int arg1); void on_nextBtn_clicked(); void on_passwordTF_textChanged(const QString &arg1); void on_passwordTF_returnPressed(); private: Ui::GetPasswordsWindow *ui; ShowLib::StringVector sshFilesNeedingPasswords; size_t fileIndex = 0; void setPrompts(); };
6103da9c06402e28d12c469ba0927dd692b38357
28b8ca5ff1a84547a2e1d289bc846309a6b5401c
/salary.h
0310da9a619094601fabe105ba1d2bba7f75df55
[]
no_license
VadimGerman/tz
4a042a6e07a74e3f03e0a7bb0d4ea119db8017cf
6b8e9cecffc5333ed6a2db0317244d296de59fcd
refs/heads/master
2020-05-29T22:01:29.100100
2019-05-30T11:10:58
2019-05-30T11:10:58
189,399,223
0
0
null
null
null
null
UTF-8
C++
false
false
198
h
salary.h
#ifndef SALARY_H #define SALARY_H #include "Clerk.h" class Salary { public: virtual ~Salary() {} virtual float compute(Clerk *clerk, QDate date) = 0; }; #endif // SALARY_H
b660d898659fac241eb27bb07b4fb9e1c5c1e964
848401f485da0dd1ddf0f48c7342660405dc77dc
/14502.cpp
c5ea746c7593743b74b30717609d4b56bcf23a19
[]
no_license
gusqls1603/2020-AlgoStudy
ae5a6b10a798d4d744eb77fca264611f58a9ac63
aeb0bd9e699bcc53641d826318bef5ff817f85e2
refs/heads/master
2023-03-01T06:35:59.051323
2021-02-16T06:44:24
2021-02-16T06:44:24
283,943,612
0
0
null
null
null
null
UTF-8
C++
false
false
1,713
cpp
14502.cpp
#include <iostream> #include <string.h> #include <queue> using namespace std; int N, M, map[10][10], E = 0; queue <pair <int, int>> oq; int count(queue<pair<int, int>> q, int a, int b, int c) { int cmap[10][10], cE = E - 3, x, y; memcpy(cmap, map, sizeof(map)); cmap[a / M + 1][a % M + 1] = 1; cmap[b / M + 1][b % M + 1] = 1; cmap[c / M + 1][c % M + 1] = 1; while (q.size() && cE) { x = q.front().first; y = q.front().second; if (cmap[x - 1][y] == 0) { cmap[x - 1][y] = 2; cE--; q.push(make_pair(x - 1, y)); } if (cmap[x][y + 1] == 0) { cmap[x][y + 1] = 2; cE--; q.push(make_pair(x, y + 1)); } if (cmap[x + 1][y] == 0) { cmap[x + 1][y] = 2; cE--; q.push(make_pair(x + 1, y)); } if (cmap[x][y - 1] == 0) { cmap[x][y - 1] = 2; cE--; q.push(make_pair(x, y - 1)); } q.pop(); } return cE; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N >> M; int i, j; for (i = 0; i <= N + 1; i++) { map[i][0] = 1; for (j = 1; j <= M; j++) { if (i == 0 || i == N + 1) { map[i][j] = 1; continue; } cin >> map[i][j]; switch (map[i][j]) { case 0: E++; break; case 2: oq.push(make_pair(i, j)); break; default: break; } } map[i][j] = 1; } int a, b, c, max_idx = N * M, cur, max = 0; for (a = 0; a < max_idx - 2; a++) { for (b = a + 1; b < max_idx - 1; b++) { for (c = b + 1; c < max_idx; c++) { if (map[a / M + 1][a % M + 1] || map[b / M + 1][b % M + 1] || map[c / M + 1][c % M + 1]) continue; cur = count(oq, a, b, c); if (cur > max) max = cur; } } } cout << max; return 0; }
cf727341a96df77387e51fddb5f0a24a8bd61544
7579d827cb7b50b438dfd9ef6fa80ba2797848c9
/sources/plug_osg/src/luna/bind_osg_CoordinateSystemNode.cpp
8134954d75f6c3e42ab86cc901759dd6adc94be0
[]
no_license
roche-emmanuel/sgt
809d00b056e36b7799bbb438b8099e3036377377
ee3a550f6172c7d14179d9d171e0124306495e45
refs/heads/master
2021-05-01T12:51:39.983104
2014-09-08T03:35:15
2014-09-08T03:35:15
79,538,908
3
0
null
null
null
null
UTF-8
C++
false
false
76,731
cpp
bind_osg_CoordinateSystemNode.cpp
#include <plug_common.h> #include <luna/wrappers/wrapper_osg_CoordinateSystemNode.h> class luna_wrapper_osg_CoordinateSystemNode { public: typedef Luna< osg::CoordinateSystemNode > luna_t; inline static bool _lg_typecheck_getTable(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } static int _bind_getTable(lua_State *L) { if (!_lg_typecheck_getTable(L)) { luaL_error(L, "luna typecheck failed in getTable function, expected prototype:\ngetTable(). Got arguments:\n%s",luna_dumpStack(L).c_str()); } osg::Referenced* self=(Luna< osg::Referenced >::check(L,1)); if(!self) { luaL_error(L, "Invalid object in function call getTable()"); } luna_wrapper_base* wrapper = luna_caster<osg::Referenced,luna_wrapper_base>::cast(self); //dynamic_cast<luna_wrapper_base*>(self); if(wrapper) { CHECK_RET(wrapper->pushTable(),0,"Cannot push table from value wrapper."); return 1; } return 0; } inline static bool _lg_typecheck_fromVoid(lua_State *L) { if( lua_gettop(L)!=1 ) return false; if( !Luna<void>::has_uniqueid(L,1,3625364) ) return false; return true; } static int _bind_fromVoid(lua_State *L) { if (!_lg_typecheck_fromVoid(L)) { luaL_error(L, "luna typecheck failed in fromVoid function, expected prototype:\nfromVoid(void*). Got arguments:\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self= (osg::CoordinateSystemNode*)(Luna< void >::check(L,1)); if(!self) { luaL_error(L, "Invalid object in function call fromVoid(...)"); } Luna< osg::CoordinateSystemNode >::push(L,self,false); return 1; } inline static bool _lg_typecheck_asVoid(lua_State *L) { if( lua_gettop(L)!=1 ) return false; if( !Luna<void>::has_uniqueid(L,1,50169651) ) return false; return true; } static int _bind_asVoid(lua_State *L) { if (!_lg_typecheck_asVoid(L)) { luaL_error(L, "luna typecheck failed in fromVoid function, expected prototype:\nasVoid(). Got arguments:\n%s",luna_dumpStack(L).c_str()); } void* self= (void*)(Luna< osg::Referenced >::check(L,1)); if(!self) { luaL_error(L, "Invalid object in function call asVoid(...)"); } Luna< void >::push(L,self,false); return 1; } // Derived class converters: static int _cast_from_Referenced(lua_State *L) { // all checked are already performed before reaching this point. //osg::CoordinateSystemNode* ptr= dynamic_cast< osg::CoordinateSystemNode* >(Luna< osg::Referenced >::check(L,1)); osg::CoordinateSystemNode* ptr= luna_caster< osg::Referenced, osg::CoordinateSystemNode >::cast(Luna< osg::Referenced >::check(L,1)); if(!ptr) return 0; // Otherwise push the pointer: Luna< osg::CoordinateSystemNode >::push(L,ptr,false); return 1; }; // Constructor checkers: inline static bool _lg_typecheck_ctor_overload_1(lua_State *L) { if( lua_gettop(L)!=0 ) return false; return true; } inline static bool _lg_typecheck_ctor_overload_2(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( lua_type(L,1)!=LUA_TSTRING ) return false; if( lua_type(L,2)!=LUA_TSTRING ) return false; return true; } inline static bool _lg_typecheck_ctor_overload_3(lua_State *L) { int luatop = lua_gettop(L); if( luatop<1 || luatop>2 ) return false; if( !Luna<void>::has_uniqueid(L,1,50169651) ) return false; if( (!(Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1))) ) return false; if( luatop>1 && !Luna<void>::has_uniqueid(L,2,27134364) ) return false; if( luatop>1 && (!(Luna< osg::CopyOp >::check(L,2))) ) return false; return true; } inline static bool _lg_typecheck_ctor_overload_4(lua_State *L) { if( lua_gettop(L)!=1 ) return false; if( lua_istable(L,1)==0 ) return false; return true; } inline static bool _lg_typecheck_ctor_overload_5(lua_State *L) { if( lua_gettop(L)!=3 ) return false; if( lua_istable(L,1)==0 ) return false; if( lua_type(L,2)!=LUA_TSTRING ) return false; if( lua_type(L,3)!=LUA_TSTRING ) return false; return true; } inline static bool _lg_typecheck_ctor_overload_6(lua_State *L) { int luatop = lua_gettop(L); if( luatop<2 || luatop>3 ) return false; if( lua_istable(L,1)==0 ) return false; if( !Luna<void>::has_uniqueid(L,2,50169651) ) return false; if( (!(Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,2))) ) return false; if( luatop>2 && !Luna<void>::has_uniqueid(L,3,27134364) ) return false; if( luatop>2 && (!(Luna< osg::CopyOp >::check(L,3))) ) return false; return true; } // Function checkers: inline static bool _lg_typecheck_cloneType(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_clone(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,27134364) ) return false; return true; } inline static bool _lg_typecheck_isSameKindAs(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( (lua_isnil(L,2)==0 && !Luna<void>::has_uniqueid(L,2,50169651)) ) return false; return true; } inline static bool _lg_typecheck_className(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_libraryName(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_accept(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,50169651) ) return false; return true; } inline static bool _lg_typecheck_set(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,50169651) ) return false; return true; } inline static bool _lg_typecheck_setFormat(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( lua_type(L,2)!=LUA_TSTRING ) return false; return true; } inline static bool _lg_typecheck_getFormat(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_setCoordinateSystem(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( lua_type(L,2)!=LUA_TSTRING ) return false; return true; } inline static bool _lg_typecheck_getCoordinateSystem(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_setEllipsoidModel(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( (lua_isnil(L,2)==0 && !Luna<void>::has_uniqueid(L,2,50169651)) ) return false; return true; } inline static bool _lg_typecheck_getEllipsoidModel_overload_1(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_getEllipsoidModel_overload_2(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_computeLocalCoordinateFrame(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,92303202) ) return false; return true; } inline static bool _lg_typecheck_computeLocalUpVector(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,92303202) ) return false; return true; } inline static bool _lg_typecheck_base_setName(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( lua_type(L,2)!=LUA_TSTRING ) return false; return true; } inline static bool _lg_typecheck_base_computeDataVariance(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_setUserData(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( (lua_isnil(L,2)==0 && !Luna<void>::has_uniqueid(L,2,50169651)) ) return false; return true; } inline static bool _lg_typecheck_base_getUserData_overload_1(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_getUserData_overload_2(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asTransform_overload_1(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asTransform_overload_2(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asCamera_overload_1(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asCamera_overload_2(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asSwitch_overload_1(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asSwitch_overload_2(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asGeode_overload_1(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asGeode_overload_2(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_ascend(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,50169651) ) return false; return true; } inline static bool _lg_typecheck_base_asGroup_overload_1(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_asGroup_overload_2(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_traverse(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,50169651) ) return false; return true; } inline static bool _lg_typecheck_base_addChild(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( (lua_isnil(L,2)==0 && !Luna<void>::has_uniqueid(L,2,50169651)) ) return false; return true; } inline static bool _lg_typecheck_base_insertChild(lua_State *L) { if( lua_gettop(L)!=3 ) return false; if( (lua_type(L,2)!=LUA_TNUMBER || lua_tointeger(L,2) != lua_tonumber(L,2)) ) return false; if( (lua_isnil(L,3)==0 && !Luna<void>::has_uniqueid(L,3,50169651)) ) return false; return true; } inline static bool _lg_typecheck_base_removeChildren(lua_State *L) { if( lua_gettop(L)!=3 ) return false; if( (lua_type(L,2)!=LUA_TNUMBER || lua_tointeger(L,2) != lua_tonumber(L,2)) ) return false; if( (lua_type(L,3)!=LUA_TNUMBER || lua_tointeger(L,3) != lua_tonumber(L,3)) ) return false; return true; } inline static bool _lg_typecheck_base_replaceChild(lua_State *L) { if( lua_gettop(L)!=3 ) return false; if( (lua_isnil(L,2)==0 && !Luna<void>::has_uniqueid(L,2,50169651)) ) return false; if( (lua_isnil(L,3)==0 && !Luna<void>::has_uniqueid(L,3,50169651)) ) return false; return true; } inline static bool _lg_typecheck_base_setChild(lua_State *L) { if( lua_gettop(L)!=3 ) return false; if( (lua_type(L,2)!=LUA_TNUMBER || lua_tointeger(L,2) != lua_tonumber(L,2)) ) return false; if( (lua_isnil(L,3)==0 && !Luna<void>::has_uniqueid(L,3,50169651)) ) return false; return true; } inline static bool _lg_typecheck_base_setThreadSafeRefUnref(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( lua_isboolean(L,2)==0 ) return false; return true; } inline static bool _lg_typecheck_base_releaseGLObjects(lua_State *L) { int luatop = lua_gettop(L); if( luatop<1 || luatop>2 ) return false; if( luatop>1 && (lua_isnil(L,2)==0 && !Luna<void>::has_uniqueid(L,2,50169651)) ) return false; return true; } inline static bool _lg_typecheck_base_computeBound(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_cloneType(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_clone(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,27134364) ) return false; return true; } inline static bool _lg_typecheck_base_isSameKindAs(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( (lua_isnil(L,2)==0 && !Luna<void>::has_uniqueid(L,2,50169651)) ) return false; return true; } inline static bool _lg_typecheck_base_className(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_libraryName(lua_State *L) { if( lua_gettop(L)!=1 ) return false; return true; } inline static bool _lg_typecheck_base_accept(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,2,50169651) ) return false; return true; } // Operator checkers: // (found 0 valid operators) // Constructor binds: // osg::CoordinateSystemNode::CoordinateSystemNode() static osg::CoordinateSystemNode* _bind_ctor_overload_1(lua_State *L) { if (!_lg_typecheck_ctor_overload_1(L)) { luaL_error(L, "luna typecheck failed in osg::CoordinateSystemNode::CoordinateSystemNode() function, expected prototype:\nosg::CoordinateSystemNode::CoordinateSystemNode()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } return new osg::CoordinateSystemNode(); } // osg::CoordinateSystemNode::CoordinateSystemNode(const std::string & format, const std::string & cs) static osg::CoordinateSystemNode* _bind_ctor_overload_2(lua_State *L) { if (!_lg_typecheck_ctor_overload_2(L)) { luaL_error(L, "luna typecheck failed in osg::CoordinateSystemNode::CoordinateSystemNode(const std::string & format, const std::string & cs) function, expected prototype:\nosg::CoordinateSystemNode::CoordinateSystemNode(const std::string & format, const std::string & cs)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } std::string format(lua_tostring(L,1),lua_objlen(L,1)); std::string cs(lua_tostring(L,2),lua_objlen(L,2)); return new osg::CoordinateSystemNode(format, cs); } // osg::CoordinateSystemNode::CoordinateSystemNode(const osg::CoordinateSystemNode & arg1, const osg::CopyOp & copyop = osg::CopyOp::SHALLOW_COPY) static osg::CoordinateSystemNode* _bind_ctor_overload_3(lua_State *L) { if (!_lg_typecheck_ctor_overload_3(L)) { luaL_error(L, "luna typecheck failed in osg::CoordinateSystemNode::CoordinateSystemNode(const osg::CoordinateSystemNode & arg1, const osg::CopyOp & copyop = osg::CopyOp::SHALLOW_COPY) function, expected prototype:\nosg::CoordinateSystemNode::CoordinateSystemNode(const osg::CoordinateSystemNode & arg1, const osg::CopyOp & copyop = osg::CopyOp::SHALLOW_COPY)\nClass arguments details:\narg 1 ID = 50169651\narg 2 ID = 27134364\n\n%s",luna_dumpStack(L).c_str()); } int luatop = lua_gettop(L); const osg::CoordinateSystemNode* _arg1_ptr=(Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1)); if( !_arg1_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg _arg1 in osg::CoordinateSystemNode::CoordinateSystemNode function"); } const osg::CoordinateSystemNode & _arg1=*_arg1_ptr; const osg::CopyOp* copyop_ptr=luatop>1 ? (Luna< osg::CopyOp >::check(L,2)) : NULL; if( luatop>1 && !copyop_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg copyop in osg::CoordinateSystemNode::CoordinateSystemNode function"); } const osg::CopyOp & copyop=luatop>1 ? *copyop_ptr : (const osg::CopyOp&)osg::CopyOp::SHALLOW_COPY; return new osg::CoordinateSystemNode(_arg1, copyop); } // osg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data) static osg::CoordinateSystemNode* _bind_ctor_overload_4(lua_State *L) { if (!_lg_typecheck_ctor_overload_4(L)) { luaL_error(L, "luna typecheck failed in osg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data) function, expected prototype:\nosg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } return new wrapper_osg_CoordinateSystemNode(L,NULL); } // osg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data, const std::string & format, const std::string & cs) static osg::CoordinateSystemNode* _bind_ctor_overload_5(lua_State *L) { if (!_lg_typecheck_ctor_overload_5(L)) { luaL_error(L, "luna typecheck failed in osg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data, const std::string & format, const std::string & cs) function, expected prototype:\nosg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data, const std::string & format, const std::string & cs)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } std::string format(lua_tostring(L,2),lua_objlen(L,2)); std::string cs(lua_tostring(L,3),lua_objlen(L,3)); return new wrapper_osg_CoordinateSystemNode(L,NULL, format, cs); } // osg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data, const osg::CoordinateSystemNode & arg2, const osg::CopyOp & copyop = osg::CopyOp::SHALLOW_COPY) static osg::CoordinateSystemNode* _bind_ctor_overload_6(lua_State *L) { if (!_lg_typecheck_ctor_overload_6(L)) { luaL_error(L, "luna typecheck failed in osg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data, const osg::CoordinateSystemNode & arg2, const osg::CopyOp & copyop = osg::CopyOp::SHALLOW_COPY) function, expected prototype:\nosg::CoordinateSystemNode::CoordinateSystemNode(lua_Table * data, const osg::CoordinateSystemNode & arg2, const osg::CopyOp & copyop = osg::CopyOp::SHALLOW_COPY)\nClass arguments details:\narg 2 ID = 50169651\narg 3 ID = 27134364\n\n%s",luna_dumpStack(L).c_str()); } int luatop = lua_gettop(L); const osg::CoordinateSystemNode* _arg2_ptr=(Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,2)); if( !_arg2_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg _arg2 in osg::CoordinateSystemNode::CoordinateSystemNode function"); } const osg::CoordinateSystemNode & _arg2=*_arg2_ptr; const osg::CopyOp* copyop_ptr=luatop>2 ? (Luna< osg::CopyOp >::check(L,3)) : NULL; if( luatop>2 && !copyop_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg copyop in osg::CoordinateSystemNode::CoordinateSystemNode function"); } const osg::CopyOp & copyop=luatop>2 ? *copyop_ptr : (const osg::CopyOp&)osg::CopyOp::SHALLOW_COPY; return new wrapper_osg_CoordinateSystemNode(L,NULL, _arg2, copyop); } // Overload binder for osg::CoordinateSystemNode::CoordinateSystemNode static osg::CoordinateSystemNode* _bind_ctor(lua_State *L) { if (_lg_typecheck_ctor_overload_1(L)) return _bind_ctor_overload_1(L); if (_lg_typecheck_ctor_overload_2(L)) return _bind_ctor_overload_2(L); if (_lg_typecheck_ctor_overload_3(L)) return _bind_ctor_overload_3(L); if (_lg_typecheck_ctor_overload_4(L)) return _bind_ctor_overload_4(L); if (_lg_typecheck_ctor_overload_5(L)) return _bind_ctor_overload_5(L); if (_lg_typecheck_ctor_overload_6(L)) return _bind_ctor_overload_6(L); luaL_error(L, "error in function CoordinateSystemNode, cannot match any of the overloads for function CoordinateSystemNode:\n CoordinateSystemNode()\n CoordinateSystemNode(const std::string &, const std::string &)\n CoordinateSystemNode(const osg::CoordinateSystemNode &, const osg::CopyOp &)\n CoordinateSystemNode(lua_Table *)\n CoordinateSystemNode(lua_Table *, const std::string &, const std::string &)\n CoordinateSystemNode(lua_Table *, const osg::CoordinateSystemNode &, const osg::CopyOp &)\n"); return NULL; } // Function binds: // osg::Object * osg::CoordinateSystemNode::cloneType() const static int _bind_cloneType(lua_State *L) { if (!_lg_typecheck_cloneType(L)) { luaL_error(L, "luna typecheck failed in osg::Object * osg::CoordinateSystemNode::cloneType() const function, expected prototype:\nosg::Object * osg::CoordinateSystemNode::cloneType() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Object * osg::CoordinateSystemNode::cloneType() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Object * lret = self->cloneType(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Object >::push(L,lret,false); return 1; } // osg::Object * osg::CoordinateSystemNode::clone(const osg::CopyOp & copyop) const static int _bind_clone(lua_State *L) { if (!_lg_typecheck_clone(L)) { luaL_error(L, "luna typecheck failed in osg::Object * osg::CoordinateSystemNode::clone(const osg::CopyOp & copyop) const function, expected prototype:\nosg::Object * osg::CoordinateSystemNode::clone(const osg::CopyOp & copyop) const\nClass arguments details:\narg 1 ID = 27134364\n\n%s",luna_dumpStack(L).c_str()); } const osg::CopyOp* copyop_ptr=(Luna< osg::CopyOp >::check(L,2)); if( !copyop_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg copyop in osg::CoordinateSystemNode::clone function"); } const osg::CopyOp & copyop=*copyop_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Object * osg::CoordinateSystemNode::clone(const osg::CopyOp &) const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Object * lret = self->clone(copyop); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Object >::push(L,lret,false); return 1; } // bool osg::CoordinateSystemNode::isSameKindAs(const osg::Object * obj) const static int _bind_isSameKindAs(lua_State *L) { if (!_lg_typecheck_isSameKindAs(L)) { luaL_error(L, "luna typecheck failed in bool osg::CoordinateSystemNode::isSameKindAs(const osg::Object * obj) const function, expected prototype:\nbool osg::CoordinateSystemNode::isSameKindAs(const osg::Object * obj) const\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } const osg::Object* obj=(Luna< osg::Referenced >::checkSubType< osg::Object >(L,2)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call bool osg::CoordinateSystemNode::isSameKindAs(const osg::Object *) const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } bool lret = self->isSameKindAs(obj); lua_pushboolean(L,lret?1:0); return 1; } // const char * osg::CoordinateSystemNode::className() const static int _bind_className(lua_State *L) { if (!_lg_typecheck_className(L)) { luaL_error(L, "luna typecheck failed in const char * osg::CoordinateSystemNode::className() const function, expected prototype:\nconst char * osg::CoordinateSystemNode::className() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const char * osg::CoordinateSystemNode::className() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const char * lret = self->className(); lua_pushstring(L,lret); return 1; } // const char * osg::CoordinateSystemNode::libraryName() const static int _bind_libraryName(lua_State *L) { if (!_lg_typecheck_libraryName(L)) { luaL_error(L, "luna typecheck failed in const char * osg::CoordinateSystemNode::libraryName() const function, expected prototype:\nconst char * osg::CoordinateSystemNode::libraryName() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const char * osg::CoordinateSystemNode::libraryName() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const char * lret = self->libraryName(); lua_pushstring(L,lret); return 1; } // void osg::CoordinateSystemNode::accept(osg::NodeVisitor & nv) static int _bind_accept(lua_State *L) { if (!_lg_typecheck_accept(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::accept(osg::NodeVisitor & nv) function, expected prototype:\nvoid osg::CoordinateSystemNode::accept(osg::NodeVisitor & nv)\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } osg::NodeVisitor* nv_ptr=(Luna< osg::Referenced >::checkSubType< osg::NodeVisitor >(L,2)); if( !nv_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg nv in osg::CoordinateSystemNode::accept function"); } osg::NodeVisitor & nv=*nv_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::accept(osg::NodeVisitor &). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->accept(nv); return 0; } // void osg::CoordinateSystemNode::set(const osg::CoordinateSystemNode & csn) static int _bind_set(lua_State *L) { if (!_lg_typecheck_set(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::set(const osg::CoordinateSystemNode & csn) function, expected prototype:\nvoid osg::CoordinateSystemNode::set(const osg::CoordinateSystemNode & csn)\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } const osg::CoordinateSystemNode* csn_ptr=(Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,2)); if( !csn_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg csn in osg::CoordinateSystemNode::set function"); } const osg::CoordinateSystemNode & csn=*csn_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::set(const osg::CoordinateSystemNode &). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->set(csn); return 0; } // void osg::CoordinateSystemNode::setFormat(const std::string & format) static int _bind_setFormat(lua_State *L) { if (!_lg_typecheck_setFormat(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::setFormat(const std::string & format) function, expected prototype:\nvoid osg::CoordinateSystemNode::setFormat(const std::string & format)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } std::string format(lua_tostring(L,2),lua_objlen(L,2)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::setFormat(const std::string &). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->setFormat(format); return 0; } // const std::string & osg::CoordinateSystemNode::getFormat() const static int _bind_getFormat(lua_State *L) { if (!_lg_typecheck_getFormat(L)) { luaL_error(L, "luna typecheck failed in const std::string & osg::CoordinateSystemNode::getFormat() const function, expected prototype:\nconst std::string & osg::CoordinateSystemNode::getFormat() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const std::string & osg::CoordinateSystemNode::getFormat() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const std::string & lret = self->getFormat(); lua_pushlstring(L,lret.data(),lret.size()); return 1; } // void osg::CoordinateSystemNode::setCoordinateSystem(const std::string & cs) static int _bind_setCoordinateSystem(lua_State *L) { if (!_lg_typecheck_setCoordinateSystem(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::setCoordinateSystem(const std::string & cs) function, expected prototype:\nvoid osg::CoordinateSystemNode::setCoordinateSystem(const std::string & cs)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } std::string cs(lua_tostring(L,2),lua_objlen(L,2)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::setCoordinateSystem(const std::string &). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->setCoordinateSystem(cs); return 0; } // const std::string & osg::CoordinateSystemNode::getCoordinateSystem() const static int _bind_getCoordinateSystem(lua_State *L) { if (!_lg_typecheck_getCoordinateSystem(L)) { luaL_error(L, "luna typecheck failed in const std::string & osg::CoordinateSystemNode::getCoordinateSystem() const function, expected prototype:\nconst std::string & osg::CoordinateSystemNode::getCoordinateSystem() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const std::string & osg::CoordinateSystemNode::getCoordinateSystem() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const std::string & lret = self->getCoordinateSystem(); lua_pushlstring(L,lret.data(),lret.size()); return 1; } // void osg::CoordinateSystemNode::setEllipsoidModel(osg::EllipsoidModel * ellipsode) static int _bind_setEllipsoidModel(lua_State *L) { if (!_lg_typecheck_setEllipsoidModel(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::setEllipsoidModel(osg::EllipsoidModel * ellipsode) function, expected prototype:\nvoid osg::CoordinateSystemNode::setEllipsoidModel(osg::EllipsoidModel * ellipsode)\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } osg::EllipsoidModel* ellipsode=(Luna< osg::Referenced >::checkSubType< osg::EllipsoidModel >(L,2)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::setEllipsoidModel(osg::EllipsoidModel *). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->setEllipsoidModel(ellipsode); return 0; } // osg::EllipsoidModel * osg::CoordinateSystemNode::getEllipsoidModel() static int _bind_getEllipsoidModel_overload_1(lua_State *L) { if (!_lg_typecheck_getEllipsoidModel_overload_1(L)) { luaL_error(L, "luna typecheck failed in osg::EllipsoidModel * osg::CoordinateSystemNode::getEllipsoidModel() function, expected prototype:\nosg::EllipsoidModel * osg::CoordinateSystemNode::getEllipsoidModel()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::EllipsoidModel * osg::CoordinateSystemNode::getEllipsoidModel(). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::EllipsoidModel * lret = self->getEllipsoidModel(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::EllipsoidModel >::push(L,lret,false); return 1; } // const osg::EllipsoidModel * osg::CoordinateSystemNode::getEllipsoidModel() const static int _bind_getEllipsoidModel_overload_2(lua_State *L) { if (!_lg_typecheck_getEllipsoidModel_overload_2(L)) { luaL_error(L, "luna typecheck failed in const osg::EllipsoidModel * osg::CoordinateSystemNode::getEllipsoidModel() const function, expected prototype:\nconst osg::EllipsoidModel * osg::CoordinateSystemNode::getEllipsoidModel() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const osg::EllipsoidModel * osg::CoordinateSystemNode::getEllipsoidModel() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const osg::EllipsoidModel * lret = self->getEllipsoidModel(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::EllipsoidModel >::push(L,lret,false); return 1; } // Overload binder for osg::CoordinateSystemNode::getEllipsoidModel static int _bind_getEllipsoidModel(lua_State *L) { if (_lg_typecheck_getEllipsoidModel_overload_1(L)) return _bind_getEllipsoidModel_overload_1(L); if (_lg_typecheck_getEllipsoidModel_overload_2(L)) return _bind_getEllipsoidModel_overload_2(L); luaL_error(L, "error in function getEllipsoidModel, cannot match any of the overloads for function getEllipsoidModel:\n getEllipsoidModel()\n getEllipsoidModel()\n"); return 0; } // osg::Matrixd osg::CoordinateSystemNode::computeLocalCoordinateFrame(const osg::Vec3d & position) const static int _bind_computeLocalCoordinateFrame(lua_State *L) { if (!_lg_typecheck_computeLocalCoordinateFrame(L)) { luaL_error(L, "luna typecheck failed in osg::Matrixd osg::CoordinateSystemNode::computeLocalCoordinateFrame(const osg::Vec3d & position) const function, expected prototype:\nosg::Matrixd osg::CoordinateSystemNode::computeLocalCoordinateFrame(const osg::Vec3d & position) const\nClass arguments details:\narg 1 ID = 92303202\n\n%s",luna_dumpStack(L).c_str()); } const osg::Vec3d* position_ptr=(Luna< osg::Vec3d >::check(L,2)); if( !position_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg position in osg::CoordinateSystemNode::computeLocalCoordinateFrame function"); } const osg::Vec3d & position=*position_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Matrixd osg::CoordinateSystemNode::computeLocalCoordinateFrame(const osg::Vec3d &) const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Matrixd stack_lret = self->computeLocalCoordinateFrame(position); osg::Matrixd* lret = new osg::Matrixd(stack_lret); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Matrixd >::push(L,lret,true); return 1; } // osg::Vec3d osg::CoordinateSystemNode::computeLocalUpVector(const osg::Vec3d & position) const static int _bind_computeLocalUpVector(lua_State *L) { if (!_lg_typecheck_computeLocalUpVector(L)) { luaL_error(L, "luna typecheck failed in osg::Vec3d osg::CoordinateSystemNode::computeLocalUpVector(const osg::Vec3d & position) const function, expected prototype:\nosg::Vec3d osg::CoordinateSystemNode::computeLocalUpVector(const osg::Vec3d & position) const\nClass arguments details:\narg 1 ID = 92303202\n\n%s",luna_dumpStack(L).c_str()); } const osg::Vec3d* position_ptr=(Luna< osg::Vec3d >::check(L,2)); if( !position_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg position in osg::CoordinateSystemNode::computeLocalUpVector function"); } const osg::Vec3d & position=*position_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Vec3d osg::CoordinateSystemNode::computeLocalUpVector(const osg::Vec3d &) const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Vec3d stack_lret = self->computeLocalUpVector(position); osg::Vec3d* lret = new osg::Vec3d(stack_lret); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Vec3d >::push(L,lret,true); return 1; } // void osg::CoordinateSystemNode::base_setName(const std::string & name) static int _bind_base_setName(lua_State *L) { if (!_lg_typecheck_base_setName(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::base_setName(const std::string & name) function, expected prototype:\nvoid osg::CoordinateSystemNode::base_setName(const std::string & name)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } std::string name(lua_tostring(L,2),lua_objlen(L,2)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::base_setName(const std::string &). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->CoordinateSystemNode::setName(name); return 0; } // void osg::CoordinateSystemNode::base_computeDataVariance() static int _bind_base_computeDataVariance(lua_State *L) { if (!_lg_typecheck_base_computeDataVariance(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::base_computeDataVariance() function, expected prototype:\nvoid osg::CoordinateSystemNode::base_computeDataVariance()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::base_computeDataVariance(). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->CoordinateSystemNode::computeDataVariance(); return 0; } // void osg::CoordinateSystemNode::base_setUserData(osg::Referenced * obj) static int _bind_base_setUserData(lua_State *L) { if (!_lg_typecheck_base_setUserData(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::base_setUserData(osg::Referenced * obj) function, expected prototype:\nvoid osg::CoordinateSystemNode::base_setUserData(osg::Referenced * obj)\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } osg::Referenced* obj=(Luna< osg::Referenced >::check(L,2)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::base_setUserData(osg::Referenced *). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->CoordinateSystemNode::setUserData(obj); return 0; } // osg::Referenced * osg::CoordinateSystemNode::base_getUserData() static int _bind_base_getUserData_overload_1(lua_State *L) { if (!_lg_typecheck_base_getUserData_overload_1(L)) { luaL_error(L, "luna typecheck failed in osg::Referenced * osg::CoordinateSystemNode::base_getUserData() function, expected prototype:\nosg::Referenced * osg::CoordinateSystemNode::base_getUserData()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Referenced * osg::CoordinateSystemNode::base_getUserData(). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Referenced * lret = self->CoordinateSystemNode::getUserData(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Referenced >::push(L,lret,false); return 1; } // const osg::Referenced * osg::CoordinateSystemNode::base_getUserData() const static int _bind_base_getUserData_overload_2(lua_State *L) { if (!_lg_typecheck_base_getUserData_overload_2(L)) { luaL_error(L, "luna typecheck failed in const osg::Referenced * osg::CoordinateSystemNode::base_getUserData() const function, expected prototype:\nconst osg::Referenced * osg::CoordinateSystemNode::base_getUserData() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const osg::Referenced * osg::CoordinateSystemNode::base_getUserData() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const osg::Referenced * lret = self->CoordinateSystemNode::getUserData(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Referenced >::push(L,lret,false); return 1; } // Overload binder for osg::CoordinateSystemNode::base_getUserData static int _bind_base_getUserData(lua_State *L) { if (_lg_typecheck_base_getUserData_overload_1(L)) return _bind_base_getUserData_overload_1(L); if (_lg_typecheck_base_getUserData_overload_2(L)) return _bind_base_getUserData_overload_2(L); luaL_error(L, "error in function base_getUserData, cannot match any of the overloads for function base_getUserData:\n base_getUserData()\n base_getUserData()\n"); return 0; } // osg::Transform * osg::CoordinateSystemNode::base_asTransform() static int _bind_base_asTransform_overload_1(lua_State *L) { if (!_lg_typecheck_base_asTransform_overload_1(L)) { luaL_error(L, "luna typecheck failed in osg::Transform * osg::CoordinateSystemNode::base_asTransform() function, expected prototype:\nosg::Transform * osg::CoordinateSystemNode::base_asTransform()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Transform * osg::CoordinateSystemNode::base_asTransform(). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Transform * lret = self->CoordinateSystemNode::asTransform(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Transform >::push(L,lret,false); return 1; } // const osg::Transform * osg::CoordinateSystemNode::base_asTransform() const static int _bind_base_asTransform_overload_2(lua_State *L) { if (!_lg_typecheck_base_asTransform_overload_2(L)) { luaL_error(L, "luna typecheck failed in const osg::Transform * osg::CoordinateSystemNode::base_asTransform() const function, expected prototype:\nconst osg::Transform * osg::CoordinateSystemNode::base_asTransform() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const osg::Transform * osg::CoordinateSystemNode::base_asTransform() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const osg::Transform * lret = self->CoordinateSystemNode::asTransform(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Transform >::push(L,lret,false); return 1; } // Overload binder for osg::CoordinateSystemNode::base_asTransform static int _bind_base_asTransform(lua_State *L) { if (_lg_typecheck_base_asTransform_overload_1(L)) return _bind_base_asTransform_overload_1(L); if (_lg_typecheck_base_asTransform_overload_2(L)) return _bind_base_asTransform_overload_2(L); luaL_error(L, "error in function base_asTransform, cannot match any of the overloads for function base_asTransform:\n base_asTransform()\n base_asTransform()\n"); return 0; } // osg::Camera * osg::CoordinateSystemNode::base_asCamera() static int _bind_base_asCamera_overload_1(lua_State *L) { if (!_lg_typecheck_base_asCamera_overload_1(L)) { luaL_error(L, "luna typecheck failed in osg::Camera * osg::CoordinateSystemNode::base_asCamera() function, expected prototype:\nosg::Camera * osg::CoordinateSystemNode::base_asCamera()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Camera * osg::CoordinateSystemNode::base_asCamera(). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Camera * lret = self->CoordinateSystemNode::asCamera(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Camera >::push(L,lret,false); return 1; } // const osg::Camera * osg::CoordinateSystemNode::base_asCamera() const static int _bind_base_asCamera_overload_2(lua_State *L) { if (!_lg_typecheck_base_asCamera_overload_2(L)) { luaL_error(L, "luna typecheck failed in const osg::Camera * osg::CoordinateSystemNode::base_asCamera() const function, expected prototype:\nconst osg::Camera * osg::CoordinateSystemNode::base_asCamera() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const osg::Camera * osg::CoordinateSystemNode::base_asCamera() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const osg::Camera * lret = self->CoordinateSystemNode::asCamera(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Camera >::push(L,lret,false); return 1; } // Overload binder for osg::CoordinateSystemNode::base_asCamera static int _bind_base_asCamera(lua_State *L) { if (_lg_typecheck_base_asCamera_overload_1(L)) return _bind_base_asCamera_overload_1(L); if (_lg_typecheck_base_asCamera_overload_2(L)) return _bind_base_asCamera_overload_2(L); luaL_error(L, "error in function base_asCamera, cannot match any of the overloads for function base_asCamera:\n base_asCamera()\n base_asCamera()\n"); return 0; } // osg::Switch * osg::CoordinateSystemNode::base_asSwitch() static int _bind_base_asSwitch_overload_1(lua_State *L) { if (!_lg_typecheck_base_asSwitch_overload_1(L)) { luaL_error(L, "luna typecheck failed in osg::Switch * osg::CoordinateSystemNode::base_asSwitch() function, expected prototype:\nosg::Switch * osg::CoordinateSystemNode::base_asSwitch()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Switch * osg::CoordinateSystemNode::base_asSwitch(). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Switch * lret = self->CoordinateSystemNode::asSwitch(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Switch >::push(L,lret,false); return 1; } // const osg::Switch * osg::CoordinateSystemNode::base_asSwitch() const static int _bind_base_asSwitch_overload_2(lua_State *L) { if (!_lg_typecheck_base_asSwitch_overload_2(L)) { luaL_error(L, "luna typecheck failed in const osg::Switch * osg::CoordinateSystemNode::base_asSwitch() const function, expected prototype:\nconst osg::Switch * osg::CoordinateSystemNode::base_asSwitch() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const osg::Switch * osg::CoordinateSystemNode::base_asSwitch() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const osg::Switch * lret = self->CoordinateSystemNode::asSwitch(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Switch >::push(L,lret,false); return 1; } // Overload binder for osg::CoordinateSystemNode::base_asSwitch static int _bind_base_asSwitch(lua_State *L) { if (_lg_typecheck_base_asSwitch_overload_1(L)) return _bind_base_asSwitch_overload_1(L); if (_lg_typecheck_base_asSwitch_overload_2(L)) return _bind_base_asSwitch_overload_2(L); luaL_error(L, "error in function base_asSwitch, cannot match any of the overloads for function base_asSwitch:\n base_asSwitch()\n base_asSwitch()\n"); return 0; } // osg::Geode * osg::CoordinateSystemNode::base_asGeode() static int _bind_base_asGeode_overload_1(lua_State *L) { if (!_lg_typecheck_base_asGeode_overload_1(L)) { luaL_error(L, "luna typecheck failed in osg::Geode * osg::CoordinateSystemNode::base_asGeode() function, expected prototype:\nosg::Geode * osg::CoordinateSystemNode::base_asGeode()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Geode * osg::CoordinateSystemNode::base_asGeode(). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Geode * lret = self->CoordinateSystemNode::asGeode(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Geode >::push(L,lret,false); return 1; } // const osg::Geode * osg::CoordinateSystemNode::base_asGeode() const static int _bind_base_asGeode_overload_2(lua_State *L) { if (!_lg_typecheck_base_asGeode_overload_2(L)) { luaL_error(L, "luna typecheck failed in const osg::Geode * osg::CoordinateSystemNode::base_asGeode() const function, expected prototype:\nconst osg::Geode * osg::CoordinateSystemNode::base_asGeode() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const osg::Geode * osg::CoordinateSystemNode::base_asGeode() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const osg::Geode * lret = self->CoordinateSystemNode::asGeode(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Geode >::push(L,lret,false); return 1; } // Overload binder for osg::CoordinateSystemNode::base_asGeode static int _bind_base_asGeode(lua_State *L) { if (_lg_typecheck_base_asGeode_overload_1(L)) return _bind_base_asGeode_overload_1(L); if (_lg_typecheck_base_asGeode_overload_2(L)) return _bind_base_asGeode_overload_2(L); luaL_error(L, "error in function base_asGeode, cannot match any of the overloads for function base_asGeode:\n base_asGeode()\n base_asGeode()\n"); return 0; } // void osg::CoordinateSystemNode::base_ascend(osg::NodeVisitor & nv) static int _bind_base_ascend(lua_State *L) { if (!_lg_typecheck_base_ascend(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::base_ascend(osg::NodeVisitor & nv) function, expected prototype:\nvoid osg::CoordinateSystemNode::base_ascend(osg::NodeVisitor & nv)\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } osg::NodeVisitor* nv_ptr=(Luna< osg::Referenced >::checkSubType< osg::NodeVisitor >(L,2)); if( !nv_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg nv in osg::CoordinateSystemNode::base_ascend function"); } osg::NodeVisitor & nv=*nv_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::base_ascend(osg::NodeVisitor &). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->CoordinateSystemNode::ascend(nv); return 0; } // osg::Group * osg::CoordinateSystemNode::base_asGroup() static int _bind_base_asGroup_overload_1(lua_State *L) { if (!_lg_typecheck_base_asGroup_overload_1(L)) { luaL_error(L, "luna typecheck failed in osg::Group * osg::CoordinateSystemNode::base_asGroup() function, expected prototype:\nosg::Group * osg::CoordinateSystemNode::base_asGroup()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Group * osg::CoordinateSystemNode::base_asGroup(). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Group * lret = self->CoordinateSystemNode::asGroup(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Group >::push(L,lret,false); return 1; } // const osg::Group * osg::CoordinateSystemNode::base_asGroup() const static int _bind_base_asGroup_overload_2(lua_State *L) { if (!_lg_typecheck_base_asGroup_overload_2(L)) { luaL_error(L, "luna typecheck failed in const osg::Group * osg::CoordinateSystemNode::base_asGroup() const function, expected prototype:\nconst osg::Group * osg::CoordinateSystemNode::base_asGroup() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const osg::Group * osg::CoordinateSystemNode::base_asGroup() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const osg::Group * lret = self->CoordinateSystemNode::asGroup(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Group >::push(L,lret,false); return 1; } // Overload binder for osg::CoordinateSystemNode::base_asGroup static int _bind_base_asGroup(lua_State *L) { if (_lg_typecheck_base_asGroup_overload_1(L)) return _bind_base_asGroup_overload_1(L); if (_lg_typecheck_base_asGroup_overload_2(L)) return _bind_base_asGroup_overload_2(L); luaL_error(L, "error in function base_asGroup, cannot match any of the overloads for function base_asGroup:\n base_asGroup()\n base_asGroup()\n"); return 0; } // void osg::CoordinateSystemNode::base_traverse(osg::NodeVisitor & arg1) static int _bind_base_traverse(lua_State *L) { if (!_lg_typecheck_base_traverse(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::base_traverse(osg::NodeVisitor & arg1) function, expected prototype:\nvoid osg::CoordinateSystemNode::base_traverse(osg::NodeVisitor & arg1)\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } osg::NodeVisitor* _arg1_ptr=(Luna< osg::Referenced >::checkSubType< osg::NodeVisitor >(L,2)); if( !_arg1_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg _arg1 in osg::CoordinateSystemNode::base_traverse function"); } osg::NodeVisitor & _arg1=*_arg1_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::base_traverse(osg::NodeVisitor &). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->CoordinateSystemNode::traverse(_arg1); return 0; } // bool osg::CoordinateSystemNode::base_addChild(osg::Node * child) static int _bind_base_addChild(lua_State *L) { if (!_lg_typecheck_base_addChild(L)) { luaL_error(L, "luna typecheck failed in bool osg::CoordinateSystemNode::base_addChild(osg::Node * child) function, expected prototype:\nbool osg::CoordinateSystemNode::base_addChild(osg::Node * child)\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } osg::Node* child=(Luna< osg::Referenced >::checkSubType< osg::Node >(L,2)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call bool osg::CoordinateSystemNode::base_addChild(osg::Node *). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } bool lret = self->CoordinateSystemNode::addChild(child); lua_pushboolean(L,lret?1:0); return 1; } // bool osg::CoordinateSystemNode::base_insertChild(unsigned int index, osg::Node * child) static int _bind_base_insertChild(lua_State *L) { if (!_lg_typecheck_base_insertChild(L)) { luaL_error(L, "luna typecheck failed in bool osg::CoordinateSystemNode::base_insertChild(unsigned int index, osg::Node * child) function, expected prototype:\nbool osg::CoordinateSystemNode::base_insertChild(unsigned int index, osg::Node * child)\nClass arguments details:\narg 2 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } unsigned int index=(unsigned int)lua_tointeger(L,2); osg::Node* child=(Luna< osg::Referenced >::checkSubType< osg::Node >(L,3)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call bool osg::CoordinateSystemNode::base_insertChild(unsigned int, osg::Node *). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } bool lret = self->CoordinateSystemNode::insertChild(index, child); lua_pushboolean(L,lret?1:0); return 1; } // bool osg::CoordinateSystemNode::base_removeChildren(unsigned int pos, unsigned int numChildrenToRemove) static int _bind_base_removeChildren(lua_State *L) { if (!_lg_typecheck_base_removeChildren(L)) { luaL_error(L, "luna typecheck failed in bool osg::CoordinateSystemNode::base_removeChildren(unsigned int pos, unsigned int numChildrenToRemove) function, expected prototype:\nbool osg::CoordinateSystemNode::base_removeChildren(unsigned int pos, unsigned int numChildrenToRemove)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } unsigned int pos=(unsigned int)lua_tointeger(L,2); unsigned int numChildrenToRemove=(unsigned int)lua_tointeger(L,3); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call bool osg::CoordinateSystemNode::base_removeChildren(unsigned int, unsigned int). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } bool lret = self->CoordinateSystemNode::removeChildren(pos, numChildrenToRemove); lua_pushboolean(L,lret?1:0); return 1; } // bool osg::CoordinateSystemNode::base_replaceChild(osg::Node * origChild, osg::Node * newChild) static int _bind_base_replaceChild(lua_State *L) { if (!_lg_typecheck_base_replaceChild(L)) { luaL_error(L, "luna typecheck failed in bool osg::CoordinateSystemNode::base_replaceChild(osg::Node * origChild, osg::Node * newChild) function, expected prototype:\nbool osg::CoordinateSystemNode::base_replaceChild(osg::Node * origChild, osg::Node * newChild)\nClass arguments details:\narg 1 ID = 50169651\narg 2 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } osg::Node* origChild=(Luna< osg::Referenced >::checkSubType< osg::Node >(L,2)); osg::Node* newChild=(Luna< osg::Referenced >::checkSubType< osg::Node >(L,3)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call bool osg::CoordinateSystemNode::base_replaceChild(osg::Node *, osg::Node *). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } bool lret = self->CoordinateSystemNode::replaceChild(origChild, newChild); lua_pushboolean(L,lret?1:0); return 1; } // bool osg::CoordinateSystemNode::base_setChild(unsigned int i, osg::Node * node) static int _bind_base_setChild(lua_State *L) { if (!_lg_typecheck_base_setChild(L)) { luaL_error(L, "luna typecheck failed in bool osg::CoordinateSystemNode::base_setChild(unsigned int i, osg::Node * node) function, expected prototype:\nbool osg::CoordinateSystemNode::base_setChild(unsigned int i, osg::Node * node)\nClass arguments details:\narg 2 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } unsigned int i=(unsigned int)lua_tointeger(L,2); osg::Node* node=(Luna< osg::Referenced >::checkSubType< osg::Node >(L,3)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call bool osg::CoordinateSystemNode::base_setChild(unsigned int, osg::Node *). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } bool lret = self->CoordinateSystemNode::setChild(i, node); lua_pushboolean(L,lret?1:0); return 1; } // void osg::CoordinateSystemNode::base_setThreadSafeRefUnref(bool threadSafe) static int _bind_base_setThreadSafeRefUnref(lua_State *L) { if (!_lg_typecheck_base_setThreadSafeRefUnref(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::base_setThreadSafeRefUnref(bool threadSafe) function, expected prototype:\nvoid osg::CoordinateSystemNode::base_setThreadSafeRefUnref(bool threadSafe)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } bool threadSafe=(bool)(lua_toboolean(L,2)==1); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::base_setThreadSafeRefUnref(bool). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->CoordinateSystemNode::setThreadSafeRefUnref(threadSafe); return 0; } // void osg::CoordinateSystemNode::base_releaseGLObjects(osg::State * arg1 = 0) const static int _bind_base_releaseGLObjects(lua_State *L) { if (!_lg_typecheck_base_releaseGLObjects(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::base_releaseGLObjects(osg::State * arg1 = 0) const function, expected prototype:\nvoid osg::CoordinateSystemNode::base_releaseGLObjects(osg::State * arg1 = 0) const\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } int luatop = lua_gettop(L); osg::State* _arg1=luatop>1 ? (Luna< osg::Referenced >::checkSubType< osg::State >(L,2)) : (osg::State*)0; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::base_releaseGLObjects(osg::State *) const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->CoordinateSystemNode::releaseGLObjects(_arg1); return 0; } // osg::BoundingSphered osg::CoordinateSystemNode::base_computeBound() const static int _bind_base_computeBound(lua_State *L) { if (!_lg_typecheck_base_computeBound(L)) { luaL_error(L, "luna typecheck failed in osg::BoundingSphered osg::CoordinateSystemNode::base_computeBound() const function, expected prototype:\nosg::BoundingSphered osg::CoordinateSystemNode::base_computeBound() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::BoundingSphered osg::CoordinateSystemNode::base_computeBound() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::BoundingSphered stack_lret = self->CoordinateSystemNode::computeBound(); osg::BoundingSphered* lret = new osg::BoundingSphered(stack_lret); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::BoundingSphered >::push(L,lret,true); return 1; } // osg::Object * osg::CoordinateSystemNode::base_cloneType() const static int _bind_base_cloneType(lua_State *L) { if (!_lg_typecheck_base_cloneType(L)) { luaL_error(L, "luna typecheck failed in osg::Object * osg::CoordinateSystemNode::base_cloneType() const function, expected prototype:\nosg::Object * osg::CoordinateSystemNode::base_cloneType() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Object * osg::CoordinateSystemNode::base_cloneType() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Object * lret = self->CoordinateSystemNode::cloneType(); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Object >::push(L,lret,false); return 1; } // osg::Object * osg::CoordinateSystemNode::base_clone(const osg::CopyOp & copyop) const static int _bind_base_clone(lua_State *L) { if (!_lg_typecheck_base_clone(L)) { luaL_error(L, "luna typecheck failed in osg::Object * osg::CoordinateSystemNode::base_clone(const osg::CopyOp & copyop) const function, expected prototype:\nosg::Object * osg::CoordinateSystemNode::base_clone(const osg::CopyOp & copyop) const\nClass arguments details:\narg 1 ID = 27134364\n\n%s",luna_dumpStack(L).c_str()); } const osg::CopyOp* copyop_ptr=(Luna< osg::CopyOp >::check(L,2)); if( !copyop_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg copyop in osg::CoordinateSystemNode::base_clone function"); } const osg::CopyOp & copyop=*copyop_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call osg::Object * osg::CoordinateSystemNode::base_clone(const osg::CopyOp &) const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } osg::Object * lret = self->CoordinateSystemNode::clone(copyop); if(!lret) return 0; // Do not write NULL pointers. Luna< osg::Object >::push(L,lret,false); return 1; } // bool osg::CoordinateSystemNode::base_isSameKindAs(const osg::Object * obj) const static int _bind_base_isSameKindAs(lua_State *L) { if (!_lg_typecheck_base_isSameKindAs(L)) { luaL_error(L, "luna typecheck failed in bool osg::CoordinateSystemNode::base_isSameKindAs(const osg::Object * obj) const function, expected prototype:\nbool osg::CoordinateSystemNode::base_isSameKindAs(const osg::Object * obj) const\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } const osg::Object* obj=(Luna< osg::Referenced >::checkSubType< osg::Object >(L,2)); osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call bool osg::CoordinateSystemNode::base_isSameKindAs(const osg::Object *) const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } bool lret = self->CoordinateSystemNode::isSameKindAs(obj); lua_pushboolean(L,lret?1:0); return 1; } // const char * osg::CoordinateSystemNode::base_className() const static int _bind_base_className(lua_State *L) { if (!_lg_typecheck_base_className(L)) { luaL_error(L, "luna typecheck failed in const char * osg::CoordinateSystemNode::base_className() const function, expected prototype:\nconst char * osg::CoordinateSystemNode::base_className() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const char * osg::CoordinateSystemNode::base_className() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const char * lret = self->CoordinateSystemNode::className(); lua_pushstring(L,lret); return 1; } // const char * osg::CoordinateSystemNode::base_libraryName() const static int _bind_base_libraryName(lua_State *L) { if (!_lg_typecheck_base_libraryName(L)) { luaL_error(L, "luna typecheck failed in const char * osg::CoordinateSystemNode::base_libraryName() const function, expected prototype:\nconst char * osg::CoordinateSystemNode::base_libraryName() const\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str()); } osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call const char * osg::CoordinateSystemNode::base_libraryName() const. Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } const char * lret = self->CoordinateSystemNode::libraryName(); lua_pushstring(L,lret); return 1; } // void osg::CoordinateSystemNode::base_accept(osg::NodeVisitor & nv) static int _bind_base_accept(lua_State *L) { if (!_lg_typecheck_base_accept(L)) { luaL_error(L, "luna typecheck failed in void osg::CoordinateSystemNode::base_accept(osg::NodeVisitor & nv) function, expected prototype:\nvoid osg::CoordinateSystemNode::base_accept(osg::NodeVisitor & nv)\nClass arguments details:\narg 1 ID = 50169651\n\n%s",luna_dumpStack(L).c_str()); } osg::NodeVisitor* nv_ptr=(Luna< osg::Referenced >::checkSubType< osg::NodeVisitor >(L,2)); if( !nv_ptr ) { luaL_error(L, "Dereferencing NULL pointer for arg nv in osg::CoordinateSystemNode::base_accept function"); } osg::NodeVisitor & nv=*nv_ptr; osg::CoordinateSystemNode* self=Luna< osg::Referenced >::checkSubType< osg::CoordinateSystemNode >(L,1); if(!self) { luaL_error(L, "Invalid object in function call void osg::CoordinateSystemNode::base_accept(osg::NodeVisitor &). Got : '%s'\n%s",typeid(Luna< osg::Referenced >::check(L,1)).name(),luna_dumpStack(L).c_str()); } self->CoordinateSystemNode::accept(nv); return 0; } // Operator binds: }; osg::CoordinateSystemNode* LunaTraits< osg::CoordinateSystemNode >::_bind_ctor(lua_State *L) { return luna_wrapper_osg_CoordinateSystemNode::_bind_ctor(L); } void LunaTraits< osg::CoordinateSystemNode >::_bind_dtor(osg::CoordinateSystemNode* obj) { osg::ref_ptr<osg::Referenced> refptr = obj; } const char LunaTraits< osg::CoordinateSystemNode >::className[] = "CoordinateSystemNode"; const char LunaTraits< osg::CoordinateSystemNode >::fullName[] = "osg::CoordinateSystemNode"; const char LunaTraits< osg::CoordinateSystemNode >::moduleName[] = "osg"; const char* LunaTraits< osg::CoordinateSystemNode >::parents[] = {"osg.Group", 0}; const int LunaTraits< osg::CoordinateSystemNode >::hash = 6002350; const int LunaTraits< osg::CoordinateSystemNode >::uniqueIDs[] = {50169651,0}; luna_RegType LunaTraits< osg::CoordinateSystemNode >::methods[] = { {"cloneType", &luna_wrapper_osg_CoordinateSystemNode::_bind_cloneType}, {"clone", &luna_wrapper_osg_CoordinateSystemNode::_bind_clone}, {"isSameKindAs", &luna_wrapper_osg_CoordinateSystemNode::_bind_isSameKindAs}, {"className", &luna_wrapper_osg_CoordinateSystemNode::_bind_className}, {"libraryName", &luna_wrapper_osg_CoordinateSystemNode::_bind_libraryName}, {"accept", &luna_wrapper_osg_CoordinateSystemNode::_bind_accept}, {"set", &luna_wrapper_osg_CoordinateSystemNode::_bind_set}, {"setFormat", &luna_wrapper_osg_CoordinateSystemNode::_bind_setFormat}, {"getFormat", &luna_wrapper_osg_CoordinateSystemNode::_bind_getFormat}, {"setCoordinateSystem", &luna_wrapper_osg_CoordinateSystemNode::_bind_setCoordinateSystem}, {"getCoordinateSystem", &luna_wrapper_osg_CoordinateSystemNode::_bind_getCoordinateSystem}, {"setEllipsoidModel", &luna_wrapper_osg_CoordinateSystemNode::_bind_setEllipsoidModel}, {"getEllipsoidModel", &luna_wrapper_osg_CoordinateSystemNode::_bind_getEllipsoidModel}, {"computeLocalCoordinateFrame", &luna_wrapper_osg_CoordinateSystemNode::_bind_computeLocalCoordinateFrame}, {"computeLocalUpVector", &luna_wrapper_osg_CoordinateSystemNode::_bind_computeLocalUpVector}, {"base_setName", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_setName}, {"base_computeDataVariance", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_computeDataVariance}, {"base_setUserData", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_setUserData}, {"base_getUserData", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_getUserData}, {"base_asTransform", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_asTransform}, {"base_asCamera", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_asCamera}, {"base_asSwitch", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_asSwitch}, {"base_asGeode", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_asGeode}, {"base_ascend", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_ascend}, {"base_asGroup", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_asGroup}, {"base_traverse", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_traverse}, {"base_addChild", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_addChild}, {"base_insertChild", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_insertChild}, {"base_removeChildren", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_removeChildren}, {"base_replaceChild", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_replaceChild}, {"base_setChild", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_setChild}, {"base_setThreadSafeRefUnref", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_setThreadSafeRefUnref}, {"base_releaseGLObjects", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_releaseGLObjects}, {"base_computeBound", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_computeBound}, {"base_cloneType", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_cloneType}, {"base_clone", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_clone}, {"base_isSameKindAs", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_isSameKindAs}, {"base_className", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_className}, {"base_libraryName", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_libraryName}, {"base_accept", &luna_wrapper_osg_CoordinateSystemNode::_bind_base_accept}, {"fromVoid", &luna_wrapper_osg_CoordinateSystemNode::_bind_fromVoid}, {"asVoid", &luna_wrapper_osg_CoordinateSystemNode::_bind_asVoid}, {"getTable", &luna_wrapper_osg_CoordinateSystemNode::_bind_getTable}, {0,0} }; luna_ConverterType LunaTraits< osg::CoordinateSystemNode >::converters[] = { {"osg::Referenced", &luna_wrapper_osg_CoordinateSystemNode::_cast_from_Referenced}, {0,0} }; luna_RegEnumType LunaTraits< osg::CoordinateSystemNode >::enumValues[] = { {0,0} };
97a8e26c9dd23cda4b99537beb9d186fdb800a02
056b50bd3c00b32022ae3af5ad490bf7ae2c4cd8
/v1/include/loadBalanceServer/TcpServer.h
6597b031f2dd324ac125d4b4989383d2c3a5b1ad
[ "MIT" ]
permissive
lexingsen/distributed-system-framework
66b8dbf894fdb8229ca92b0e9682572693aaa276
3b9a8aa88048055ebd0a0edea2142b81242367b3
refs/heads/master
2022-05-25T06:24:43.025007
2022-05-05T13:48:37
2022-05-05T13:48:37
178,776,814
73
30
null
null
null
null
UTF-8
C++
false
false
444
h
TcpServer.h
#ifndef _TCP_SERVER_H_ #define _TCP_SERVER_H_ #include <string> using namespace std; class TcpServer { public: TcpServer(const std::string& ip, unsigned short port); int Accept(); int Send(int fd, const std::string& msg); int Recv(int fd, std::string& msg); int getListenFd() const; std::string getIp() const; unsigned short getPort() const; private: int m_listenFd; unsigned short m_port; std::string m_ip; }; #endif
0e767427b35e090dffcff8b91d6cd9e1bcf58d6b
dca8d0641fa5608c6e3ba4ecf955d90eedc58102
/[EDD]Proyecto1_201800624/[EDD]ProyectoUno/[EDD]ProyectoUno/NodoLS.h
968d9f01403f8cec6fbed1fbdf0541043a8a3822
[]
no_license
car123che/-EDD-ProyectoUno
00517bf4b20ad8f3f695dba3617ecac6d15a22a5
ac89d6982dc634b40c67529d6854d30b20f571bb
refs/heads/master
2022-11-03T08:20:40.200760
2020-06-19T05:41:25
2020-06-19T05:41:25
269,880,888
0
0
null
null
null
null
UTF-8
C++
false
false
197
h
NodoLS.h
#pragma once #include <iostream> #include "Activo.h" class NodoLS { public: NodoLS* siguiente; int posicion; Activo* activo; NodoLS(Activo* a) { siguiente = 0; posicion = 0; activo = a; } };
91ce932230b01ced71097b49245f2fc9c77a423d
9c2d27f2b23630034f426434b3e2bfd384fb7134
/Assignment2/AccountInheritanceHierarchy/savingAccount.h
6c974c6c1ed8be108725c74fe9e5a9274d70915c
[]
no_license
XiaofengLighthouseLabs/Cpp-practice1
6c3bd8a773bd26b92847de61d3c95bb2c23c20d3
93e070dfa19c9825fcc4f84fb8d8a8d2e7140559
refs/heads/master
2020-07-29T17:22:15.488483
2019-09-21T00:13:18
2019-09-21T00:13:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,064
h
savingAccount.h
/* * savingAccount.h * * Created on: Jul 12, 2019 * Author: Xiaofeng Zhang */ #ifndef SAVINGACCOUNT_H_ #define SAVINGACCOUNT_H_ #include <iostream> #include <string> #include "account.h" using namespace std; class SavingAccount : public Account{ private: double interestRate; public: explicit SavingAccount(const string &fName, const string &lName, double iBalance, double rate) : Account (fName, lName, iBalance){ setInterestRate(rate); } // set interest rate void setInterestRate(double rate){ if(rate >= 0.0 && rate <= 1.0){ interestRate = rate; } else{ cout << "Error: Invalid interest rate." << endl; rate = -1; } } // get interest rate double getRate() const{ return interestRate; } //interest calculation function double interestCalculate() const{ return (Account :: getBalance() * interestRate); } void print() const{ Account :: print(); cout << "The Interest Amount is: " << interestCalculate() << endl; } }; #endif /* SAVINGACCOUNT_H_ */
b7f251ee34d6182f102a42a6d1b88bfd61204e1c
d09945668f19bb4bc17087c0cb8ccbab2b2dd688
/2017-2021/2019/iroha/day3/d.cpp
3a75e41b87e0d87eca7d3be9216e027db63cf456
[]
no_license
kmjp/procon
27270f605f3ae5d80fbdb28708318a6557273a57
8083028ece4be1460150aa3f0e69bdb57e510b53
refs/heads/master
2023-09-04T11:01:09.452170
2023-09-03T15:25:21
2023-09-03T15:25:21
30,825,508
23
2
null
2023-08-18T14:02:07
2015-02-15T11:25:23
C++
UTF-8
C++
false
false
1,315
cpp
d.cpp
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int H; string S[10]; int SY,SX,TY,TX; void solve() { int i,j,k,l,r,x,y; string s; cin>>H; FOR(y,H) cin>>S[y]; SY=SX=1,TY=TX=-1; FOR(i,1000) { if(abs(SY-TY)+abs(SX-TX)!=1) { cout<<"-"<<endl; } else { FOR(j,4) { int dd[4]={1,0,-1,0}; int ny=SY+dd[j]; int nx=SX+dd[j^1]; if(nx==TX&&ny==TY) continue; if(S[ny][nx]=='#') continue; SY=ny; SX=nx; if(j==0) cout<<"D"<<endl; if(j==1) cout<<"R"<<endl; if(j==2) cout<<"U"<<endl; if(j==3) cout<<"L"<<endl; break; } assert(j<4); } cin>>TY>>TX; TY--,TX--; } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }
4e0034c3eda7c02be3d322bfa44a332ebebd0f0b
66d6d8b59346bee299e54ae2b889da02ff62b292
/src/car.cpp
625db84799b1b448d77f51d17fe0a93c61897249
[ "MIT" ]
permissive
deepakzambre/PathPlanning
dc067b683c5261a9809b61d9ad796681c92ef71b
c81b2028c493c05ce7ad89285fbddf6cf718a72b
refs/heads/master
2020-03-24T09:03:45.124669
2018-08-20T04:51:25
2018-08-20T04:51:25
142,617,259
0
0
null
null
null
null
UTF-8
C++
false
false
11,003
cpp
car.cpp
#include "car.hpp" #include "common.hpp" #include <iostream> #include <iostream> #include <fstream> #include <cmath> #include <vector> #include "json.hpp" #include "spline.h" #include "Eigen-3.3/Eigen/Core" #include "Eigen-3.3/Eigen/QR" #include "Eigen-3.3/Eigen/Dense" #include "helper.hpp" #include "common.hpp" using namespace std; using json = nlohmann::json; using Eigen::MatrixXd; using Eigen::VectorXd; void Car::UpdateIterationSpeed() { if (this->last_speed > this->cruise_speed && this->iteration_speed > 1.0) { this->iteration_speed = this->last_speed - .224; } else if (this->last_speed < this->cruise_speed && this->iteration_speed <= (MAX_SPEED - 1.0)) { this->iteration_speed = min(49.5, this->last_speed + .224); } } void Car::EvaluateAndUpdateState(json &sensor_fusion) { if (this->d < 0) { this->state = CarState::LaneChange; this->target_lane = 0; this->last_speed = this->iteration_speed; this->last_lane = this->lane; return; } if (this->d > (NUM_LANES * LANE_SIZE)) { this->state = CarState::LaneChange; this->target_lane = NUM_LANES - 1; this->last_speed = this->iteration_speed; this->last_lane = this->lane; return; } if (this->state == CarState::LaneChange) { double target_lane_center = (this->target_lane * LANE_SIZE) + (LANE_SIZE / 2.0); if (target_lane_center - LANE_EPSILON <= this->d && this->d <= target_lane_center + LANE_EPSILON) { this->state = CarState::Cruise; this->UpdateIterationSpeed(); this->last_speed = this->iteration_speed; this->last_lane = this->lane; return; } this->state = CarState::LaneChange; this->UpdateIterationSpeed(); this->last_speed = this->iteration_speed; this->last_lane = this->lane; return; } int prev_size = this->old_path_x.size(); double end_s = prev_size > 0 ? this->old_path_end_s : this->s; bool too_close = false; vector<bool> is_obstruction{false, false, false}; vector<double> ahead_speed{MAX_SPEED, MAX_SPEED, MAX_SPEED}; vector<double> ahead_dist{numeric_limits<double>::max(), numeric_limits<double>::max(), numeric_limits<double>::max()}; for (int i = 0; i < sensor_fusion.size(); i++) { float check_d = sensor_fusion[i][6]; double check_vx = sensor_fusion[i][3]; double check_vy = sensor_fusion[i][4]; double check_speed = sqrt(check_vx * check_vx + check_vy * check_vy); double check_s = sensor_fusion[i][5]; int check_lane = (int)check_d / 4; if ((check_s <= this->s && (this->s - check_s) <= 5) || (this->s < check_s && (check_s - this->s) <= 20)) //abs(check_s - this->s) < 20) { is_obstruction[check_lane] = true; } if (check_s < ahead_dist[check_lane] && this->s < check_s) { if (check_s < (this->s + 20)) { ahead_speed[check_lane] = 2.2369 * check_speed - 20; } else if (check_s < (this->s + 30)) { ahead_speed[check_lane] = 2.2369 * check_speed - 10; } else if (check_s < (this->s + 50)) { ahead_speed[check_lane] = 2.2369 * check_speed; } } if (check_d < (2 + 4 * this->lane + 2) && check_d > (2 + 4 * this->lane - 2)) { //double future_check_s = check_s + ((double)prev_size * 0.02 * check_speed); //if (check_s > this->s && (future_check_s > end_s) && (future_check_s - end_s) < 30) if (check_s > this->s && (check_s - this->s) < 50) { too_close = true; } } } if (too_close) { if (this->lane == 0) { if (!is_obstruction[1]) { if (ahead_speed[0] < ahead_speed[1]) { this->state = CarState::LaneChange; this->target_lane = 1; this->cruise_speed = ahead_speed[1]; } else { this->state = CarState::Cruise; this->cruise_speed = ahead_speed[0]; } } else { this->state = CarState::Cruise; this->cruise_speed = ahead_speed[0]; } } else if (this->lane == 2) { if (!is_obstruction[1]) { if (ahead_speed[2] < ahead_speed[1]) { this->state = CarState::LaneChange; this->target_lane = 1; this->cruise_speed = ahead_speed[1]; } else { this->state = CarState::Cruise; this->cruise_speed = ahead_speed[2]; } } else { this->state = CarState::Cruise; this->cruise_speed = ahead_speed[2]; } } else { int next_lane = this->lane; if (!is_obstruction[this->lane - 1] && ahead_speed[this->lane - 1] > ahead_speed[this->lane] && ahead_speed[this->lane - 1] > ahead_speed[this->lane + 1]) { this->state = CarState::LaneChange; this->target_lane = this->lane - 1; this->cruise_speed = ahead_speed[this->lane - 1]; } else if (!is_obstruction[this->lane + 1] && ahead_speed[this->lane + 1] > ahead_speed[this->lane] && ahead_speed[this->lane + 1] > ahead_speed[this->lane - 1]) { this->state = CarState::LaneChange; this->target_lane = this->lane + 1; this->cruise_speed = ahead_speed[this->lane + 1]; } else { this->state = CarState::Cruise; this->cruise_speed = ahead_speed[this->lane]; } } } else { this->state = CarState::Cruise; this->cruise_speed = ahead_speed[this->lane]; } this->UpdateIterationSpeed(); this->last_speed = this->iteration_speed; this->last_lane = this->lane; LOG(INFO, "max lane speeds = " + to_string(ahead_speed[0]) + "," + to_string(ahead_speed[1]) + "," + to_string(ahead_speed[2])) LOG(INFO, "Cruise speed = " + to_string(this->cruise_speed)); LOG(INFO, "state = " + to_string(this->state)); } void Car::CalculateTrajectory( vector<double> map_waypoints_x, vector<double> map_waypoints_y, vector<double> map_waypoints_s) { vector<double> ptsx; vector<double> ptsy; double ref_x = this->x; double ref_y = this->y; double ref_yaw = deg2rad(this->yaw); int prev_size = this->old_path_x.size(); if (prev_size < 2) { LOG(INFO, "No Previous points"); ptsx.push_back(this->x - cos(this->yaw)); ptsy.push_back(this->y - sin(this->yaw)); ptsx.push_back(this->x); ptsy.push_back(this->y); } else { ref_x = this->old_path_x[prev_size - 1]; ref_y = this->old_path_y[prev_size - 1]; ref_yaw = atan2( ref_y - double(this->old_path_y[prev_size - 2]), ref_x - double(this->old_path_x[prev_size - 2])); ptsx.push_back(this->old_path_x[prev_size - 2]); ptsy.push_back(this->old_path_y[prev_size - 2]); ptsx.push_back(ref_x); ptsy.push_back(ref_y); } double end_s = prev_size > 0 ? this->old_path_end_s : this->s; vector<double> wp0 = getXY(end_s + 30, 2 + 4 * this->target_lane, map_waypoints_s, map_waypoints_x, map_waypoints_y); ptsx.push_back(wp0[0]); ptsy.push_back(wp0[1]); vector<double> wp1 = getXY(end_s + 60, 2 + 4 * this->target_lane, map_waypoints_s, map_waypoints_x, map_waypoints_y); ptsx.push_back(wp1[0]); ptsy.push_back(wp1[1]); vector<double> wp2 = getXY(end_s + 90, 2 + 4 * this->target_lane, map_waypoints_s, map_waypoints_x, map_waypoints_y); ptsx.push_back(wp2[0]); ptsy.push_back(wp2[1]); for (int i = 0; i < ptsx.size(); i++) { double shift_x = ptsx[i] - ref_x; double shift_y = ptsy[i] - ref_y; ptsx[i] = shift_x * cos(-1 * ref_yaw) - shift_y * sin(-1 * ref_yaw); ptsy[i] = shift_x * sin(-1 * ref_yaw) + shift_y * cos(-1 * ref_yaw); if (i != 0 && ptsx[i] <= ptsx[i - 1]) { ptsx[i] = ptsx[i] + 1; } } tk::spline s; s.set_points(ptsx, ptsy); this->next_x.clear(); this->next_y.clear(); for (int i = 0; i < prev_size; i++) { this->next_x.push_back(this->old_path_x[i]); this->next_y.push_back(this->old_path_y[i]); } double target_x = 30; double target_y = s(target_x); double target_dist = sqrt(target_x * target_x + target_y * target_y); double N = target_dist * 2.24 / (0.02 * this->iteration_speed); double x_addon = 0; double x_inc = target_x / N; for (int i = 1; i <= 50 - prev_size; i++) { x_addon += x_inc; double next_x = x_addon * cos(ref_yaw) - s(x_addon) * sin(ref_yaw) + ref_x; double next_y = x_addon * sin(ref_yaw) + s(x_addon) * cos(ref_yaw) + ref_y; this->next_x.push_back(next_x); this->next_y.push_back(next_y); } } void Car::Set(double in_x, double in_y, double in_s, double in_d, double in_yaw, double in_speed) { x = in_x; y = in_y; s = in_s; d = in_d; yaw = in_yaw; speed = in_speed; lane = (int)d / 4; } void Car::Log() { LOG(INFO, "************************************"); LOG(INFO, "car x = " + to_string(x) + ", car y = " + to_string(y) + ", car yaw = " + to_string(yaw)); LOG(INFO, "car x = " + to_string(x) + ", car y = " + to_string(y) + ", car yaw = " + to_string(yaw)); LOG(INFO, "car s = " + to_string(s) + ", car d = " + to_string(d)); LOG(INFO, "car speed = " + to_string(speed) + ", car target speed = " + to_string(iteration_speed)); LOG(INFO, "car lane = " + to_string(lane) + ", car target lane = " + to_string(target_lane)); } vector<double> JMT(vector<double> start, vector<double> end, double T) { /* Calculate the Jerk Minimizing Trajectory that connects the initial state to the final state in time T. INPUTS start - the vehicles start location given as a length three array corresponding to initial values of [s, s_dot, s_double_dot] end - the desired end state for vehicle. Like "start" this is a length three array. T - The duration, in seconds, over which this maneuver should occur. OUTPUT an array of length 6, each value corresponding to a coefficent in the polynomial s(t) = a_0 + a_1 * t + a_2 * t**2 + a_3 * t**3 + a_4 * t**4 + a_5 * t**5 EXAMPLE > JMT( [0, 10, 0], [10, 10, 0], 1) [0.0, 10.0, 0.0, 0.0, 0.0, 0.0] */ MatrixXd A = MatrixXd(3, 3); A << T * T * T, T * T * T * T, T * T * T * T * T, 3 * T * T, 4 * T * T * T, 5 * T * T * T * T, 6 * T, 12 * T * T, 20 * T * T * T; MatrixXd B = MatrixXd(3, 1); B << end[0] - (start[0] + start[1] * T + .5 * start[2] * T * T), end[1] - (start[1] + start[2] * T), end[2] - start[2]; MatrixXd Ai = A.inverse(); MatrixXd C = Ai * B; vector<double> result = {start[0], start[1], .5 * start[2]}; for (int i = 0; i < C.size(); i++) { result.push_back(C.data()[i]); } return result; }
5d093f8b14506dbeb4573da63441eb16bf60833e
a0c4ed3070ddff4503acf0593e4722140ea68026
/source/NET/UI/NCPA/NCPA/NCPADOMN.HXX
4c3e4c3baf0be6450c72475279394c609f7f3625
[]
no_license
cjacker/windows.xp.whistler
a88e464c820fbfafa64fbc66c7f359bbc43038d7
9f43e5fef59b44e47ba1da8c2b4197f8be4d4bc8
refs/heads/master
2022-12-10T06:47:33.086704
2020-09-19T15:06:48
2020-09-19T15:06:48
299,932,617
0
1
null
2020-09-30T13:43:42
2020-09-30T13:43:41
null
UTF-8
C++
false
false
8,757
hxx
NCPADOMN.HXX
/**********************************************************************/ /** Microsoft Windows NT **/ /** Copyright(c) Microsoft Corp., 2000 **/ /**********************************************************************/ /* NCPADOMN.HXX Domain and Computername alteration dialogs and classes FILE HISTORY: DavidHov 4/6/92 Created */ #ifndef _NCPADOMN_HXX_ #define _NCPADOMN_HXX_ enum ENUM_DOMAIN_ROLE { EROLE_UNKNOWN, EROLE_DC, EROLE_MEMBER, EROLE_TRUSTED, EROLE_STANDALONE }; enum ENUM_DOMMGR_NAME { EDRNM_COMPUTER, EDRNM_USER, EDRNM_DOMAIN, EDRNM_ACCT_PWD, EDRNM_ACCT_PWD_OLD, EDRNM_DC_NAME, EDRNM_LOGON_NAME, EDRNM_LOGON_PWD, EDRNM_WORKGROUP, EDRMN_MAX }; class LSA_POLICY ; /************************************************************************* NAME: DOMAIN_MANAGER SYNOPSIS: Functional encapsulation class for Domain and Computer name and role changing INTERFACE: Normal PARENT: BASE USES: NLS_STR, REGISTRY_MANAGER CAVEATS: NOTES: HISTORY: DavidHov 4/06/92 Created **************************************************************************/ class DOMAIN_MANAGER : public LSA_POLICY { private: APIERR _err ; // Last error which occurred APIERR _errMsg ; // Message explanatory text HWND _hwOwner ; // Parent window for dialogs SC_MANAGER * _pscManager ; // Service controller support REGISTRY_MANAGER * _pRegMgr ; // Registry support const TCHAR * _pchCmdLine ; // Command line from SETUP ENUM_DOMAIN_ROLE _enumRole ; // Machine role in domain BOOL _fRegMgrOwned ; // TRUE if created _pRegMgr BOOL _fAdmin ; // User known to be Admin BOOL _fDomainExists ; // Domain known to exist BOOL _fCreateDomain ; // Becoming DC of new domain BOOL _fMember ; // WINNT: member of domain BOOL _fInstall ; // Installation is occuring BOOL _fIdw ; // In-house IDW installation BOOL _fLanmanNt ; // Product is LANMAN/NT BOOL _fExpress ; // Install mode is EXPRESS BOOL _fUseComputerPassword ; // Use computer password for NET USE BOOL _fComputerNameChanged ; // Computer name was changed BOOL _fDomainChanged ; // Domain or workgroup was changed BOOL _fDlgDomainState ; // Last dialog choice BOOL _fAutoInstall ; // True if domain\workgroup passed in from INF. NLS_STR _nlsComputerName ; // Name of computer NLS_STR _nlsUserName ; // User name NLS_STR _nlsDomainName ; // Domain NLS_STR _nlsComputerAcctPassword ; // Password NLS_STR _nlsComputerAcctOldPw ; // Old Password NLS_STR _nlsDcName ; // DC Name (when known) NLS_STR _nlsQualifiedLogonUserName ; // Qualified user name NLS_STR _nlsLogonUserName ; // User name for logon NLS_STR _nlsLogonDomain ; // Domain name for logon NLS_STR _nlsLogonPassword ; // User Password for logon NLS_STR _nlsWorkgroup ; // Workgroup name // Extract the necessary strings from the SETUP command line BOOL ExtractParameters () ; // Extract the current information (user name, domain, etc.) // to provide default values for dialogs APIERR QueryCurrentInfo () ; // Get the DC name; set 'fDomainExists' accordingly APIERR GetDCName () ; // Attempt to "net use" IPC$ the Domain Controller // Allow the user to enter a logon name and password. APIERR UseIPConDC () ; // Attempt to create computer account on domain APIERR HandleDomainAccount () ; // Generate a password for the machine account based on machine name. APIERR MachineAccountPassword ( NLS_STR * pnlsMachineAccountPassword ) ; // Run the Windows/NT or LANMan/NT Domain Settings dialog APIERR RunDlgDomainSettings () ; APIERR RunDlgDomainWinNt () ; APIERR RunDlgDomainLanNt () ; APIERR RunDlgDomainLanNtRename () ; APIERR RunDlgChangeComputerName() ; // Dire warning; if "fChoice" give the user an option. BOOL DireWarning ( MSGID midBase, MSGID midEnd = 0, BOOL fChoice = FALSE, MSG_SEVERITY msgsev = MPSEV_WARNING ) const ; // Change the computer name APIERR SetMachineName ( const NLS_STR & nlsMachineName ) ; // Change the Windows Workgroup name APIERR SetWorkgroupName ( const NLS_STR & nlsWorkgroup ) ; // Join the chosen domain according to type, role, etc. APIERR JoinDomain () ; // Leave the primary domain APIERR LeaveDomain () ; // Perform SAM account manipulation required to join and leave // domains. APIERR AdjustDomain ( BOOL fAfterJoining ) ; // Revert to the "default" workgroup name, "Workgroup" APIERR SetDefaultWorkgroupName () ; // Check if this is an IDW build BOOL QueryIdw () ; // Change the password on the remote machine account APIERR ChangeMachineAcctPassword () ; // Return the flags on the existing machine account APIERR QueryMachineAccountFlags ( DWORD * pdwFlags ) ; // Set the flags on the machine account APIERR SetMachineAccountFlags ( DWORD dwFlags ) ; // Set the Start type for the netlogon service. APIERR AdjustNetlogonStartType( BOOL fJoining ); // Is the SID for the existing domain the same as for the new domain BOOL SameDomainSid( const NLS_STR & nlsDcName ); // Just change the Name of the domain APIERR RenameDomain(); public: DOMAIN_MANAGER ( HWND hwOwner, // For birthing dialogs ACCESS_MASK accessDesired = GENERIC_READ | GENERIC_EXECUTE, REGISTRY_MANAGER * pRegMgr = NULL, // For registry operations const TCHAR * pszComputerName = NULL, // DO NOT USE: future provision! BOOL fInstall = FALSE ); ~ DOMAIN_MANAGER () ; // Return a pointer to the name desired const NLS_STR * PeekName ( ENUM_DOMMGR_NAME edmgrnm ) const ; // Return the current computer role ENUM_DOMAIN_ROLE QueryRole () const ; // Allow the user to change the domain name, workgroup name, etc. APIERR DomainChange () ; // Allow the user to change the computer name APIERR ComputerNameChange ( BOOL fInstalling = FALSE ) ; // Install this machine according to the needs of the user. APIERR DomainInstall ( const TCHAR * pchSetupCmdLine ) ; // Return the last error which occured APIERR QueryLastError () { return _err ; } // Return the last error message explanatory text value APIERR QueryLastMsgError () { return _errMsg ; } // Display the last error. Return TRUE if the user elects // to continue, if allowed. "fDefaultButton" is only // used if "fButtons" is non-zero. BOOL DoMsgPopup ( BOOL fFatal, UINT fButtons = 0, UINT fDefaultButton = 0 ) ; // Return the computer name we're focused on. APIERR QueryMachineName ( NLS_STR * pnlsMachineName ) const ; // Return TRUE if this machine particpates in a primary domain APIERR QueryDomainMember ( BOOL * pfMember ) ; // See if the computer name was changed during execution BOOL QueryComputerNameChanged () { return _fComputerNameChanged ; } // See if the computer name was changed during execution BOOL QueryDomainChanged () { return _fDomainChanged ; } // Using types from ICANON.H, validate a name static APIERR ValidateName ( INT iNameType, const NLS_STR & nlsName, HWND hwDlgOwner = NULL, BOOL fAsPdc = FALSE ) ; // Fill the given NLS_STR with the machine account name for // this computer. APIERR MachineAccountName ( NLS_STR * pnlsMachineAccount ) ; // Set the SC_MANAGER pointer for use after main install VOID SetSCManager ( SC_MANAGER * pscManager ) { _pscManager = pscManager; } }; // End of NCPADOMN.HXX #endif // _NCPADOMN_HXX_
76f22f9fb3cea8a506e6156a58c49e9528215379
251921a9bad70bf0cef196a755b17a30e583d49d
/ArpHeader/ArpInterface/ArpFileNameControl.h
55ad86406ced68b31b3d72defb06b61215afb890
[ "Artistic-1.0" ]
permissive
tgkokk/Sequitur
6d25b901c14960445230c91571934b3bdc0db214
de306eb37de25cd8237c9a4bd30ce3e7a7ed416f
refs/heads/master
2021-01-17T07:50:13.962534
2014-01-01T21:52:41
2014-01-01T21:52:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,733
h
ArpFileNameControl.h
/* ArpFileNameControl.h * Copyright (c)2002 by Eric Hackborn. * All rights reserved. * * This code is not public domain, nor freely distributable. * Please direct any questions or requests to Eric Hackborn, * at <hackborn@angryredplanet.com>. * * ---------------------------------------------------------------------- * * To Do * ~~~~~~~~~~ * * - Nothing! * * ---------------------------------------------------------------------- * * Known Bugs * ~~~~~~~~~~ * * - None! Ha ha! * * ---------------------------------------------------------------------- * * History * ~~~~~~~ * 2002.07.15 hackborn@angryredplanet.com * Created this file. */ #ifndef ARPINTERFACE_ARPFILENAMECONTROL_H #define ARPINTERFACE_ARPFILENAMECONTROL_H #include <ArpCore/String16.h> #include <be/interface/Control.h> /*************************************************************************** * ARP-FILE-NAME-CONTROL * I display a file name. One can be dropped on me to set it. ***************************************************************************/ class ArpFileNameControl : public BControl { public: ArpFileNameControl(BRect frame, const char* name, uint32 resizeMask); virtual ~ArpFileNameControl(); virtual void AttachedToWindow(); virtual void Draw(BRect clip); virtual void MessageReceived(BMessage *msg); BString16 FileName() const; void SetFileName(const BString16* fileName); /* Little hack 'cause I didn't think this control out * very well. */ void SetFileNameNoInvoke(const BString16* fileName); protected: void DrawOn(BView* view, BRect clip); private: typedef BControl inherited; BString16 mFileName; // BMessage* mInvokedMsg; // BMessenger mTarget; }; #endif
a96071e0effa4bd800eaa9535e10e2fcd892b6fb
3a918810fff9810a3e77ba6e8d323cd67b99f4cd
/ArduinoPlatformio/02_demos/08 wifi/02_WebServerRelayAdvanced/ESP/Platformio/ESP8266/Sonoff/src/main.cpp
876130a495970e91c1ec22d7fc9ef68230ca782a
[]
no_license
ramonjunquera/GlobalEnvironment
7cdb81e7dd30619016ee36f3d4501ebb13891d8b
d099ce6fbaa4e9f570428ca30a058bf75a4ac4b5
refs/heads/master
2023-03-08T02:36:07.720569
2023-02-20T08:58:18
2023-02-20T08:58:18
110,946,331
5
1
null
null
null
null
UTF-8
C++
false
false
16,802
cpp
main.cpp
/* Autor: Ramón Junquera Tema: Conexión WiFi Objetivo: Crear un interruptor (relé) con control remoto por Internet Material adicional: Sonoff, cables, FTDI Descripción: Gestionaremos un relé de manera remota a través de un servidor web integrado en Sonoff. Para facilitar la identificación del servidor, se le asignará una ip fija. Guardamos en el sistema de archivos dos archivo: log y config. En log se guardan las última acciones realizadas en el dispositivo. En config se guarda el estado actual de relé y el horario. Gracias a ello somos capaces de recuperar el estado que tenía la última vez que se apagó. El estado del relé se puede cambiar a través de la web o pulsando el botón fisico. El interface web permite ver el estado actual del relé, el tipo de horario y las última acciones guardadas en el log. El dispositivo no depende de Internet para su correcto funcionamiento. Si cambiamos el estado del relé pulsando el interruptor y no tenemos conexión a Internet que nos permita obtener la hora actual, se guarda el número de segundos transcurridos desde el inicio del dispositivo y cuando se recupera la conexión a Internet se calcula y actualiza la fecha y hora correctas del evento. El led del dispositivo refleja en todo momento el estado del relé. Se han deshabilitado las URLs no permitidas. El punto de acceso correcto es http://192.168.1.199:8199/refresh Con la configuración adecuada del router, puede ser accesible desde el exterior. Pinout: FTDI Sonoff ---- ------ 3.3V 3.3V (pin más cerca del pulsador) TX RX RX TX GND GND (pin más lejos del pulsador) El log se guarda en el archivo "log". Al arrancar se lee su contenido y se mantiene en memoria. Tras cualquier cambio se sobreescribe. La estructura de un registro la siguiente: 4 bytes = fecha/hora en segundos transcurridos desde 1900 (uint32_t) 1 byte = contenido, tipo, estado y origen. bit 0 = tiene contenido?: no/sí = 0/1 bit 1 = started: no/si = 0/1 bit 2 = status changed: no/si = 0/1 bit 3 = time changed: no/si = 0/1 bit 4 = estado: OFF/ON = 0/1, time: invierno/verano = 0/1 bit 5 = origen: switch/web = 0/1 bit 6 = no utilizado bit 7 = no utilizado Tamaño total de un registro = 5 bytes. El número de registros viene definido por la constante maxLogLines La configuración se guarda en el archivo "config". Sólo contiene un byte con la siguiente estructura: bit 0 = estado actual: apagado/encendido = 0/1 bit 1 = horario de verano: no/sí = 0/1 bit 2 = no utilizado bit 3 = no utilizado bit 4 = no utilizado bit 5 = no utilizado bit 6 = no utilizado bit 7 = no utilizado En el horario de verano se debe añadir una hora más. */ #include <Arduino.h> #include <FS.h> //Librería de gestión de SPIFFS #include <ESP8266WiFi.h> #include <ESP8266WebServer.h> #include <time.h> //Creamos una instancia de un servidor escuchando por el puerto 80 llamado server ESP8266WebServer server(8199); //Definimos como constantes el nombre del punto de acceso y su contraseña const char *wifiSSID = "***"; const char *wifiPassword = "***"; //Definición de pines const byte relayPin = 12; //Pin del relé const byte ledPin = 13; //Pin del led integrado const byte switchPin = 0; //Pin del interruptor (pulsador) //const byte relayPin = 2; //Simula pin del relé = led antena = D4 //const byte ledPin = 14; //Simula led Sonoff = led integrado = D5 //const byte switchPin = D1; //Simula pin del interruptor (pulsador) //Nombres de los archivos const char *configFilename = "/config"; const char *logFilename = "/log"; //Número de registros del log const byte logRegMax = 20; //Zona horaria = GMT+1 const int8_t timeZone = 1; //Estructura de un registro del log struct logReg { uint32_t datetime = 0; byte flags = 0; }; byte configByte = 0; //Byte del archivo config: estado actual y horario de verano logReg logArray[logRegMax]; //Array de registros de log bool switchPressed=false; //Se ha pulsado el interruptor? void saveConfig() { //Guarda el byte de configuración en el archivo File f = SPIFFS.open(configFilename, "w"); f.write(configByte); f.close(); } void initSPIFFS() { //Inicializa el sistema de archivo //Carga el archivo config y lo aplica //Carga el archivo de log File f; //Inicializamos el acceso a archivos de SPIFFS SPIFFS.begin(); //Gestión de archivo config //Si no existe el archivo config...lo creamos if (!SPIFFS.exists(configFilename)) saveConfig(); //Lo abrimos como sólo lectura f = SPIFFS.open(configFilename, "r"); //Leemos su contenido f.readBytes((char *)&configByte, 1); //Ya podemos cerrarlo f.close(); //Gestión de archivo log //Si no existe al archivo log...no hacemos nada if (!SPIFFS.exists(logFilename)) return; //Seguro que existe el archivo log //Lo abrimos como sólo lectura f = SPIFFS.open(logFilename, "r"); //Calculamos cuántos registros contiene byte logRegCount = f.size() / sizeof(logReg); //Si es más de los permitidos...lo limitamos if (logRegCount > logRegMax) logRegCount = logRegMax; //Recorremos todos los registros a leer for (byte i = 0; i < logRegCount; i++) { //Leemos su contenido en la posición correcta del array f.readBytes((char *)(&logArray[i]), sizeof(logReg)); } //Hemos terminado con el archivo log f.close(); } void saveLogArray() { //Guarda el array de log en el archivo File f = SPIFFS.open(logFilename, "w"); f.write((byte *)logArray, sizeof(logReg) * logRegMax); f.close(); } void addLogArray(logReg *newLogReg) { //Añade un nuevo registro al principio de log //Tanto al array como al archivo //Movemos todos los registros una posición adelante for (byte i=logRegMax-1;i>0;i--) logArray[i]=logArray[i-1]; //Anotamos los detalles al primer registro logArray[0].datetime = (*newLogReg).datetime; logArray[0].flags = (*newLogReg).flags; //Guardamos el array de log en el archivo saveLogArray(); } uint32_t getTime() { //Calcula la fecha y hora actuales //Si no puede obtenerlo de Internet, devuelve el número de segundos //que lleva el dispositivo en marcha //Obtenemos la fecha y hora actuales time_t now = time(nullptr); //Si lo hemos conseguido... if (now) { //Si debemos sumarle la hora del horario de verano...lo hacemos if (configByte & 0b00000010) now += 3600; } else //No lo hemos conseguido { //Devolvemos los segundos que lleva en marcha el dispositivo now=millis()/1000; } return now; } void setRelay() { //Aplica el estado actual al relé digitalWrite(relayPin,configByte & 0b00000001); //Aplica el estado actual al led digitalWrite(ledPin,!(configByte & 0b00000001)); } void intSwitch() { //El interruptor ha cambiado de estado //Tiempo mínimo para admitir cambios de estado const uint32_t minTimeChange=1000; //un segundo //Hora del último cambio de estado del interruptor static uint32_t lastChange=0; //Anotamos la hora actual uint32_t now=millis(); //Si ha pasado el tiempo suficiente para tener en cuenta el cambio //y el interruptor está pulsado...lo anotamos if(now-lastChange>minTimeChange && !digitalRead(switchPin)) switchPressed=true; //El último cambio será ahora lastChange=now; } String formatDate(uint32_t s) { //Convierte el número de segundos transcurridos desde 1900 a un String //con el formato de fecha correcto: DD/MM/YYYY HH:MM:SS struct tm *t; char buffer[20]; //No necesitamos más de 20 caracteres //Convertimos la fecha en segundos a formato tm t=localtime((time_t*)&s); //Aplicamos formato sprintf(buffer,"%02d/%02d/%04d %02d:%02d:%02d",(*t).tm_mday,(*t).tm_mon+1,(*t).tm_year+1900,(*t).tm_hour,(*t).tm_min,(*t).tm_sec); return buffer; } String composeHTML() { //Devuelte un String con el html a enviar al cliente //Cabecera String a = "<h1>Sonoff</h1>"; //Horario a+="<p><h2>Horario de "; a+=(configByte & 0b00000010)?"verano":"invierno"; a+="</h2></p>"; //Estado a+="<p><h2>Estado actual: "; a+=(configByte & 0b00000001)?"ON":"OFF"; a+="</h2></p>"; //Botones a+="<p><a href=\"refresh\"><button style=""font-size:300%"">Actualizar</button></a>"; a+="&nbsp;<a href=\"changeStatus\"><button style=""font-size:300%"">Cambiar estado</button></a>"; a+="&nbsp;<a href=\"changeTime\"><button style=""font-size:300%"">Cambiar horario</button></a></p>"; //Recorremos todos los registros del array for (byte i = 0; i < logRegMax; i++) { //Inicio de párrafo a+="<p>"; //Anotamos las características del registro byte flags = logArray[i].flags; //Si el registro está vacío...hemos terminado de recorrer los registros del log if (!(flags & 0b00000001)) break; //El registro contiene algo //Mostramos la fecha con formato a+=formatDate(logArray[i].datetime); a+=" "; //Si es de arranque... if (flags & 0b00000010) a+="iniciado"; //Si es de cambio de horario else if(flags & 0b00000100) { a+="horario "; a+=(flags & 0b00001000)?"verano":"invierno"; } else //Tiene que ser de cambio de estado { a+=(flags & 0b00001000)?"ON":"OFF"; a+=" por "; a+=(flags & 0b00010000)?"web":"interruptor"; } //Fin de párrafo a+="</p>\n"; } //Fin de html a+="</html>\n"; //Devolvemos la cadena que hemos compuesto return a; } void changeTime() { //Cambio de horario verano/invierno //Cambiamos de horario configByte^=0b00000010; //Guardamos la configuración saveConfig(); //Debemos añadir una nueva línea al log que indique que el cambio de horario //Creamos un nuevo registro de log logReg newLogReg; //Anotamos que es un registro con contenido, de cambio de horario // bit 0 = tiene contenido?: sí = 1 // bit 1 = started: no = 0 // bit 2 = changed: time = 1 // bit 3 = time: invierno/verano = 0/1 // bit 4 = origen: switch/web = 0/1 (irrelevante) // bit 5 = no utilizado // bit 6 = no utilizado // bit 7 = no utilizado newLogReg.flags=0b00000101; //Si el horario actual es verano...lo anotamos if(configByte & 0b00000010) newLogReg.flags|=0b00001000; //Obtenemos la fecha actual y la guardamos en el registro newLogReg.datetime=getTime();; //Añadimos el registro al log addLogArray(&newLogReg); } void changeStatus(bool byWeb) { //Cambia el estado del relé y anota el cambio en el log. //Permite indicar si el cambio es con el interruptor local o por web. //Cambia el estado actual configByte^=0b00000001; //Guardamos la configuración saveConfig(); //Debemos añadir una nueva línea al log que indique que el usuario local //ha cambiado el estado //Creamos un nuevo registro de log logReg newLogReg; //Anotamos que es un registro con contenido, de cambio de estado, por el interruptor local // bit 0 = tiene contenido?: no/sí = 0/1 // bit 1 = started: no/si = 0/1 // bit 2 = changed: status/time = 0/1 // bit 3 = estado: OFF/ON = 0/1, time: invierno/verano = 0/1 // bit 4 = origen: switch/web = 0/1 // bit 5 = no utilizado // bit 6 = no utilizado // bit 7 = no utilizado newLogReg.flags=0b00000001; //Si el cambio es por web...lo anotamos if(byWeb) newLogReg.flags|=0b00010000; //Si el estado actual es encendido...anotamos que se ha cambiado a encendido if(configByte & 0b00000001) newLogReg.flags|=0b00001000; //Obtenemos la fecha actual y la guardamos en el registro newLogReg.datetime=getTime(); //Añadimos el registro al log addLogArray(&newLogReg); //Aplicamos el estado actual al relé setRelay(); } void handleRefresh() { //Gestiona una petición de refresco en página web //Simplemente mostramos el html de la web server.send(200,"text/html",composeHTML()); } void handleChangeStatus() { //Gestiona una petición de cambio de estado en página web //Cambiamos el estado del relé indicando que se ha realizado por la web changeStatus(true); //Refrescamos la página handleRefresh(); } void handleChangeTime() { //Gestiona una petición de cambio de horario en página web //Cambiamos el horario changeTime(); //Refrescamos la página handleRefresh(); } void handleNotFound() { //Gestiona una petición de una URL desconocida //No hacemos nada. No devolvemos respuesta //Al cliente le aparecerá un mensaje del tipo: Esta página no funciona porque no envía datos } void setup() { //Configuramos el pin del relé como salida pinMode(relayPin, OUTPUT); //Definimos el pin del led integrado como salida pinMode(ledPin, OUTPUT); //Configuramos el pin del interruptor como entrada con las resistencias de pullup activas pinMode(switchPin, INPUT_PULLUP); //Inicializamos el sistema de archivos y leemos config y log initSPIFFS(); //Aplicamos el estado actual al relé setRelay(); //Creamos un nuevo registro para indicar el actual arranque logReg logRegStart; //Obtenemos la fecha actual y gardamos en el registro //La fecha no será válida porque aun no hemos inicializado las comunicaciones //Aun así se guarda el número de segundos transcurridos desde el último reinicio de dispositivo, //que probablemente sea 0. //Ya actualizaremos a la hora correcta cuando consigamos comunicación logRegStart.datetime = getTime(); //Los detalles del actual registro son: // bit 0 = tiene contenido?: sí = 1 // bit 1 = started: si = 1 // bit 2 = changed: status/time = 0/1 (irrelevante) // bit 3 = estado: OFF/ON = 0/1, time: invierno/verano = 0/1 (irrelevante) // bit 4 = origen: switch/web = 0/1 (irrelevante) // bit 5 = no utilizado // bit 6 = no utilizado // bit 7 = no utilizado logRegStart.flags = 0b00000011; //Anotamos el nuevo registro en el log addLogArray(&logRegStart); //Definimos la hora de Internet //A la UTC le debemos añadir tantas horas como la zona horaria en la que estemos configTime((int32_t)timeZone * 3600, 0, "pool.ntp.org", "time.nist.gov"); //Definimos algunas funciones para gestionar las peticiones cliente dependiendo de la URL server.on("/refresh", handleRefresh); server.on("/changeStatus", handleChangeStatus); server.on("/changeTime", handleChangeTime); server.onNotFound(handleNotFound); //Arrancamos el servidor web server.begin(); //Configuramos la función de interrupción del switch attachInterrupt(switchPin,intSwitch,CHANGE); }; void wifiConnect() { //Intenta obtener conexión wifi si es que no la tiene //Se ha asignado la dirección Iip estática? static bool staticIpAssigned=false; //Último intento de conexión wifi que hicimos static uint32_t lastTry = 0; //Inicialmente nunca //Si no estamos conectados a wifi... if (WiFi.status() != WL_CONNECTED) { //...y han pasado más de 15 segundos desde el último intento... if (millis() - lastTry > 15000) { //...lo intentamos de nuevo WiFi.mode(WIFI_STA); WiFi.begin(wifiSSID, wifiPassword); //Anotamos que lo acabamos de intentar lastTry = millis(); } } else //Estamos conectados a wifi { //Si no se ha asignado la dirección ip estática...lo hacemos ahora if(!staticIpAssigned) WiFi.config(IPAddress(192,168,1,199),WiFi.gatewayIP(),WiFi.subnetMask()); } } void setLogDatetime() { //Comprobamos si hay registros de log sin fecha definida //Nota: si alguna vez hay registros sin fecha, habitualmente sólo será uno. //Recorremos todos los registros de log for (byte r = 0; r < logRegMax; r++) { //Si el registro tiene contenido... if (logArray[r].flags & 0b00000001) { //Si la fecha del registro es inferior a un año (60*60*24*365=31536000)... if (logArray[r].datetime < 31536000) { //...consideramos que la fecha es incorrecta //Obtenemos la fecha y hora actuales uint32_t now = getTime(); //Si es una fecha válida... if(now > 31536000) { //Calculamos la hora en la que se guardó este registro now = now - millis()/1000 + logArray[r].datetime; //Anotamos la hora correcta logArray[r].datetime = now; //Guardamos el log en el archivo saveLogArray(); } } } } } void loop() { //Comprobamos que mantenemos conexión wifi wifiConnect(); //Comprobamos si hay registros de log sin fecha definida setLogDatetime(); //Si se ha pulsado el interruptor... if(switchPressed) { //Estado cambiado con el interruptor local changeStatus(false); //Ya hemos gestionado la pulsación. La borramos switchPressed=false; } //Gestionamos el servidor web server.handleClient(); }
f523c5bc06f9cc45117dd592c7da796bf32bf07e
6288052de241a6044bdccc3c5ae3bba0c8639a3c
/perfect_sets_counter/binary_conv.cpp
aee4fb1d11425ab0964cb4a4a93793187adc5aa9
[]
no_license
ValerioTram/Simple_Algorithms
50b978f473dfa60b159671c6765d257ec817db4d
316c1aeaccb9eaa7bd9f295161385d96cc636ef4
refs/heads/main
2023-02-08T12:58:49.503554
2020-12-31T16:30:23
2020-12-31T16:30:23
325,833,493
0
0
null
null
null
null
UTF-8
C++
false
false
252
cpp
binary_conv.cpp
#include "binary_conv.h" vector<int> dec2bin(int dec_num) { vector<int> bin_num_vec; int i = 0; while(dec_num>0) { bin_num_vec.push_back(dec_num%2); dec_num = dec_num/2; i++; } return bin_num_vec; }
31bf2868cd758f8a1fe7bc49954ab9ff110ff55d
502381e7ca4ac8b11d696f3c2e13a04f30cb8f6d
/BestPuzlleMatchTheAdjacent/Classes/Status.h
fbd59238e77c985ed454bdc48dfdee5d76336671
[]
no_license
73153/IncomeTaxCalculator
2c70a7ceb09dc96969a90ff36f65681b199bfdca
38f54db09ebd0e85427401543850a19ee077066e
refs/heads/master
2021-01-20T15:10:43.059210
2017-02-22T12:15:08
2017-02-22T12:15:08
82,799,857
0
0
null
null
null
null
UTF-8
C++
false
false
347
h
Status.h
/* * Status.h * * Created on: 2013-7-18 * Author: maxing */ #ifndef STATUS_H_ #define STATUS_H_ #define MAX_UNREGULAR_STAGE 10 class Status { public: Status(); virtual ~Status(); bool mute; int highScore; int stage; int score; int target; int lastTarget; }; #endif /* STATUS_H_ */
16bb4fdb5f24e428e3e3bfde1501e2157d449c88
68beabeb4ac1dfdb6ab8b103087ab96a7f0a365b
/Separate Compilation/test.cpp
a4a458faf8863d1fd355b11345e80acb9405e2e2
[]
no_license
wangying2016/Seperate_Compilation_of_Class_Template
fc32c1a9da6dbcf26b7f33f08eff8fbf16eb49a3
784b1a62c7a4f581e26f5590fd51f147b7339097
refs/heads/master
2020-04-08T22:15:55.484647
2018-11-30T06:37:30
2018-11-30T06:37:30
159,779,498
1
1
null
null
null
null
UTF-8
C++
false
false
288
cpp
test.cpp
#include "MemoryCell.h" #include <iostream> #include <cstdlib> using namespace std; int main() { MemoryCell<int> m1; MemoryCell<double> m2{ 3.14 }; m1.write(37); m2.write(m2.read() * 2); cout << m1.read() << endl; cout << m2.read() << endl; system("pause"); return 0; }
cf3a8e789592d48e99270bf179ef0db6aff4d68c
3e520825665dbf75ccb93445c95d2a2573739233
/main.cpp
9f531dc2ba1f51d1ea3718d792c3fc93f4bf7cdd
[]
no_license
bartlomiej/BlockListChecker
995bf5f84a569e59c4a915d85b83b14830a44cee
86cca5d6ec6646d5eba3dbe3a6fab9c606ed4aa6
refs/heads/master
2020-04-26T03:54:19.612843
2019-03-01T10:47:38
2019-03-01T10:47:38
173,282,899
0
0
null
null
null
null
UTF-8
C++
false
false
592
cpp
main.cpp
#include "blocklistchecker.h" #include <QApplication> #include <QTextCodec> #include "singleapplication.h" int main(int argc, char *argv[]) { #ifndef Q_OS_UNIX QTextCodec::setCodecForLocale(QTextCodec::codecForName("Windows-1250")); #else QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); #endif SingleApplication a(argc, argv); a.setApplicationName("BlockListChecker"); a.setApplicationVersion("1.0.5"); a.setOrganizationDomain("cieslak.info.pl"); a.setOrganizationName("CIESLAK"); BlockListChecker w; w.show(); return a.exec(); }
315457939540cb183969fb6b9ca16b000702d5af
9fb01562288fde5dcafa25387d219256a26f7ba8
/wrap.cpp
6568c7068e1dc41d5cfd699318d56d9bcb20c131
[]
no_license
zootella/ftorrent
8a8a2d7709a99c305ffb3b88942078c0200a364b
05acb00e26b38e1dd545ad287820d834ff8d5fcf
refs/heads/master
2020-04-11T09:16:44.535991
2012-10-22T06:23:47
2012-10-22T06:23:47
536,161
0
0
null
null
null
null
UTF-8
C++
false
false
36,482
cpp
wrap.cpp
#include "heavy.h" extern app App; // Access global object // Takes a settings structure to look at, or null to not update settings // Starts libtorrent and adds extensions void InitializeLibtorrent(settings_structure *info) { try { App.session = new libtorrent::session; // Make the libtorrent session object if (info) // Added this UpdateSettings(info); // Update settings if a structure was given App.session->add_extension(&libtorrent::create_metadata_plugin); // Tell libtorrent which plugins to use App.session->add_extension(&libtorrent::create_ut_metadata_plugin); App.session->add_extension(&libtorrent::create_ut_pex_plugin); App.session->add_extension(&libtorrent::create_smart_ban_plugin); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Given settings in info, apply them to our libtorrent session void UpdateSettings(settings_structure *info) { try { // Apply settings in info to libtorrent libtorrent::session_settings s; // Make a new libtorrent session settings object s.use_dht_as_fallback = false; // didn't turn this off s.share_ratio_limit = info->seed_ratio_limit; // Copy info into a libtorrent session settings object s.seed_time_ratio_limit = info->seed_time_ratio_limit; s.seed_time_limit = info->seed_time_limit; s.active_downloads = info->active_downloads_limit; s.active_seeds = info->active_seeds_limit; s.active_limit = info->active_limit; App.session->set_settings(s); // Apply the settings to libtorrent // Tell libtorrent what kinds of alerts we want to find out about App.session->set_alert_mask(info->alert_mask); // Give libtorrent connection settings App.session->listen_on( std::make_pair(info->listen_start_port, info->listen_end_port), // Port range to listen on narrowRtoS(info->listen_interface).c_str()); // Network interface to use App.session->set_upload_rate_limit(info->max_upload_bandwidth); // Upload and download speed limits App.session->set_download_rate_limit(info->max_download_bandwidth); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Pause the libtorrent session and get resume data from each torrent // Ported from http://www.rasterbar.com/products/libtorrent/manual.html#save-resume-data void FreezeAndSaveAllFastResumeData() { try { // Count how many torrents will give us resume data int n = 0; // Pausing the whole session is better than pausing torrents individually App.session->pause(); // Loop through all the torrent handles std::vector<libtorrent::torrent_handle> handles = App.session->get_torrents(); for (std::vector<libtorrent::torrent_handle>::iterator i = handles.begin(); i != handles.end(); ++i) { libtorrent::torrent_handle &h = *i; if (!h.has_metadata()) continue; // Skip this one unless it has filename and piece hash metadata if (!h.is_valid()) continue; // And isn't uninitialized or aborted // Tell the torrent to generate resume data h.save_resume_data(); // Returns immediately, we'll get the data later after libtorrent gives us an alert n++; // Count one more torrent that will give us resume data } // Loop until we've gotten as many resume data alerts as we expect while (n > 0) { // Wait here for an alert const libtorrent::alert *alert = App.session->wait_for_alert(libtorrent::seconds(10)); // Wait up to 10 seconds if (alert == NULL) break; // Didn't get one, leave // Got an alert std::auto_ptr<libtorrent::alert> p = App.session->pop_alert(); // Tell libtorrent we've got it alert_structure info; ProcessAlert(alert, &info); // Copy information from alert into info // Only count this alert if it has resume data if (info.has_data) n--; } } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Tell libtorent to shut down void AbortTorrents() { try { if (App.session) App.session->abort(); // deleted the object instead of aborting it } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Have libtorrent generate resume data for the torrent with the given infohash // This returns immediately, when the data is ready, you'll get a save resume data alert void SignalFastResumeDataRequest(const char *id) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); if (h.has_metadata()) // True if we started with a .torrent file or got equivalent information from the swarm h.save_resume_data(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Save the resume data info knows about to a new file at path void SaveFastResumeData(alert_structure *info, wchar_t *path) { try { // Open a new file at path std::wstring w(path); // Convert path into a wide string boost::filesystem::wpath p(w); // Make that into a path object boost::filesystem::ofstream f(p, std::ios_base::binary); // Make an output file stream f.unsetf(std::ios_base::skipws); // Don't have the file skip whitespace // Write data in the file libtorrent::entry *e = info->resume_data; // Point e at the resume data libtorrent::bencode(std::ostream_iterator<char>(f), *e); // Bencode the data at e into the file // Close the file f.close(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Save DHT information in a file at path to look at next time so it starts up faster void SaveDhtState(const wchar_t *path) { try { // Open the file at path for writing std::wstring w(path); boost::filesystem::wpath p(w); boost::filesystem::ofstream f(p, std::ios_base::binary); f.unsetf(std::ios_base::skipws); libtorrent::entry e = App.session->dht_state(); // Get the DHT state as a bencoded object libtorrent::bencode(std::ostream_iterator<char>(f), e); // Serialize the bencoded information to a file // Close the file f.close(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Take all the alerts libtorrent is waiting to give us and look at each one void GetAlerts() { try { // Get an alert std::auto_ptr<libtorrent::alert> p = App.session->pop_alert(); // Move an alert from libtorrent to p while (p.get()) { // If p contans an alert libtorrent::alert *alert = p.get(); // Get it // Look at alert, filling info with information about it and copied from it alert_structure info; ProcessAlert(alert, &info); // Get the next alert p = App.session->pop_alert(); // Move the next alert from libtorrent to p and loop until libtorrent runs out } } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Given a libtorrent alert, fill a structure of info about it // After calling this function, you can look at the information in info to see the alert libtorrent sent you void ProcessAlert(const libtorrent::alert *alert, alert_structure *info) { // Get the category and the message info->category = alert->category(); info->message = widenStoC(alert->message()); // If it's a torrent alert const libtorrent::torrent_alert *a = dynamic_cast<const libtorrent::torrent_alert *>(alert); if (a) { // Get the torrent handle and make sure that torrent is initialized and not yet aborted libtorrent::torrent_handle h = a->handle; if (h.is_valid()) { // Get the infohash info->sha1 = base16(h.info_hash()); // If the alert is for save resume data const libtorrent::save_resume_data_alert *a1 = dynamic_cast<const libtorrent::save_resume_data_alert *>(alert); if (a1) { // Get the pointer to the resume data const boost::shared_ptr<libtorrent::entry> resume_ptr = a1->resume_data; info->has_data = 1; // Mark that this info structure has resume data info->resume_data = resume_ptr.get(); // Copy across the pointer to the resume data return; } // If the alert is for save resume data failed const libtorrent::save_resume_data_failed_alert *a2 = dynamic_cast<const libtorrent::save_resume_data_failed_alert *>(alert); if (a2) { // Get the error message info->message = widenStoC(a2->msg); return; } // If the alert is for fast resume rejected const libtorrent::fastresume_rejected_alert *a3 = dynamic_cast<const libtorrent::fastresume_rejected_alert *>(alert); if (a3) { // Get the error message info->message = widenStoC(a3->msg); return; } } } } // Takes infohash, the SHA1 infohash of the torrent file in base 16 ASCII characters // Takes trackerurl, the URL of the torrent's tracker // Takes torrentpath, the path to the .torrent file on the disk // Takes savepath, the path to where the program should save the torrent on the disk // Takes resumepath, the path to a file of resume information we saved earlier and can use now // Adds the torrent to libtorrent void AddTorrentWrap(char *infohash, char *trackerurl, wchar_t *torrentpath, wchar_t *savepath, wchar_t *resumepath) { try { // Output the information this function received log(L"adding torrent"); log(make(L"infohash: ", widenPtoC(infohash))); log(make(L"tracker url: ", widenPtoC(trackerurl))); log(make(L"torrent path: ", torrentpath)); log(make(L"resume file path: ", resumepath)); // Fill out a torrent parameters object libtorrent::add_torrent_params p; p.save_path = boost::filesystem::path(narrowRtoS(savepath)); p.info_hash = ParseHash(widenPtoC(infohash)); p.tracker_url = trackerurl; p.auto_managed = false; // changed this to true p.duplicate_is_error = true; // If we were given the path to a torrent file on the disk if (torrentpath) { boost::filesystem::ifstream f1(torrentpath, std::ios_base::binary); // Try to open it if (!f1.fail()) { // Opening it worked p.ti = new libtorrent::torrent_info(boost::filesystem::path(narrowRtoS(torrentpath))); // Add the path to the torrent parameters we're filling out } else { // Couldn't open it log(L"could not find torrent file"); } f1.close(); // Close the file we tried to open } std::vector<char> resumebuffer; // If we were given the path to a file of resume data on the disk that we saved before and can use now if (resumepath) { boost::filesystem::ifstream f2(resumepath, std::ios_base::binary); // Try to open it if (!f2.fail()) { // Opening it worked // Copy the file contents into resumebuffer f2.unsetf(std::ios_base::skipws); // Change whitespace option std::istream_iterator<char> streamiterator; std::istream_iterator<char> fileiterator(f2); std::copy(fileiterator, streamiterator, std::back_inserter(resumebuffer)); p.resume_data = &resumebuffer; // Add the resumebuffer to the torrent parameters we're filling out f2.close(); // Close the disk file we opened } else { log(L"could not find fast resume file"); } } // Add the new torrent we made to our libtorrent session libtorrent::torrent_handle h = App.session->add_torrent(p); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Remove the torrent with the given infohash from the program void RemoveTorrentWrap(const char *id) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.pause(); App.session->remove_torrent(h); //TODO another option here would delete the files on the disk, too } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Pause the torrent with the given infohash void PauseTorrent(const char *id) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.pause(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Resume the torrent with the given infohash after you paused it void ResumeTorrent(const char *id) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.resume(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Takes infohash text and a new save to path // Moves the torrent from where it is now to the given path void MoveTorrent(const char *id, wchar_t *path) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.pause(); // Pause the torrent libtorrent::storage_interface *storage = h.get_storage_impl(); // Access the torrent's storage implementation storage->release_files(); // Release all the file handles the torrent has open storage->move_storage(boost::filesystem::path(narrowRtoS(path))); // Move all the saved files to path h.resume(); // Resume the torrent } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Reannounce the torrent with the given infohash to its trackers now to find out about more peers void ForceReannounce(const char *id) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.force_reannounce(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Force restart the torrent with the given infohash that may have stopped because it had an error void ClearErrorAndRetry(const char *id) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.force_recheck(); // Disconnect peers and tracker, hash what we have on the disk, and then go back online h.clear_error(); // Clear this torrent's error state and start again h.resume(); // Unpause, start and go back online } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Turn auto management on or off for the torrent with the given infohash void SetAutoManagedTorrent(const char *id, bool auto_managed) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.auto_managed(auto_managed); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Set the given download to upload seed ratio on the torrent with the given infohash void SetSeedRatio(const char *id, float seed_ratio) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.set_ratio(seed_ratio); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Find out if we've got a valid handle for a torrent with the given infohash void IsValid(const char *id, int &is_valid) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); is_valid = h.is_valid(); // Reasons for invalid include not found, or filesystem character error } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Find out if the torrent with the given infohash has metadata, either from a .torrent file or downloaded from the swarm void HasMetadata(const char *id, int &has_metadata) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); has_metadata = h.has_metadata(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Fill out the given torrent structure with information from the torrent with the given infohash void GetTorrentInfo(const char *id, torrent_structure *info) { try { // Find the torrent handle and get its info object libtorrent::torrent_handle h = FindTorrentHandle(id); libtorrent::torrent_info i = h.get_torrent_info(); // Fill out some information info->created_by = widenStoC(i.creator()); info->comment = widenStoC(i.comment()); info->sha1 = base16(i.info_hash()); info->total_size = (long long)i.total_size(); info->piece_length = (int)i.piece_length(); // List trackers announce_structure a; std::vector<libtorrent::announce_entry> v1 = i.trackers(); std::vector<libtorrent::announce_entry>::iterator iterator1 = v1.begin(); while (iterator1 != v1.end()) { a.url = widenStoC(iterator1->url); a.tier = iterator1->tier; info->trackers.push_back(a); iterator1++; } // List web seeds std::vector<std::string> v2 = i.url_seeds(); std::vector<std::string>::iterator iterator2 = v2.begin(); while (iterator2 != v2.end()) { a.url = widenPtoC(iterator2->c_str()); a.tier = -1; info->seeds.push_back(a); iterator2++; } } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Fill out the given status structure with current information about the torrent with the given infohash void GetTorrentStatus(const char *id, status_structure *info) { try { // Find the torrent handle and get the status object libtorrent::torrent_handle h = FindTorrentHandle(id); libtorrent::torrent_status s = h.status(); // Fill out the given status structure info->total_done = s.total_done; info->total_wanted_done = s.total_wanted_done; info->total_wanted = s.total_wanted; info->total_download = s.total_download; info->total_upload = s.total_upload; info->total_payload_download = s.total_payload_download; info->total_payload_upload = s.total_payload_upload; info->all_time_payload_download = s.all_time_download; info->all_time_payload_upload = s.all_time_upload; info->download_rate = (float)s.download_rate; info->upload_rate = (float)s.upload_rate; info->download_payload_rate = (float)s.download_payload_rate; info->upload_payload_rate = (float)s.upload_payload_rate; info->num_peers = s.num_peers; info->num_uploads = s.num_uploads; info->num_seeds = s.num_seeds; info->num_connections = s.num_connections; info->state = s.state; info->progress = s.progress; info->paused = s.paused; info->finished = h.is_finished(); info->valid = h.is_valid(); info->auto_managed = h.is_auto_managed(); info->seeding_time = s.seeding_time; info->active_time = s.active_time; info->error = widenStoC(s.error); info->current_tracker = widenStoC(s.current_tracker); info->num_complete = s.num_complete; info->num_incomplete = s.num_incomplete; info->total_failed_bytes = s.total_failed_bytes; } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Add a tracker to the torrent with the given infohash void AddTracker(const char *id, char *url, int tier) { try { // Get the torent's list of trackers libtorrent::torrent_handle h = FindTorrentHandle(id); // Get the torrent handle std::vector<libtorrent::announce_entry> trackers = h.trackers(); // Get its list of trackers // Make a new announce entry object and fill it out libtorrent::announce_entry e(url); e.tier = tier; // Add it to the list and give the edited list back to the torrent trackers.push_back(e); h.replace_trackers(trackers); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Remove the given tracker from the torrent with the given infohash void RemoveTracker(const char *id, char *url, int tier) { try { // Get the torrent's list of trackers and make a new empty list libtorrent::torrent_handle h = FindTorrentHandle(id); // Get the torrent handle std::vector<libtorrent::announce_entry> trackers = h.trackers(); // Get the current list of trackers std::vector<libtorrent::announce_entry> trackers2; // Make a new empty list that will hold trackers // Loop down the torrent's list of trackers std::vector<libtorrent::announce_entry>::iterator i = trackers.begin(); while (i != trackers.end()) { libtorrent::announce_entry tracker = *i; if (tracker.tier != tier || strcmp(tracker.url.c_str(), url) != 0) // This tracker from the list doesn't match the one we're trying to remove trackers2.push_back(tracker); // Add it to the new list to save it i++; } // Give the torrent the new list with the one we wanted to remove not there h.replace_trackers(trackers2); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Find out how many trackers the torrent with the given infohash has void GetNumTrackers(const char *id, int &n) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); // Get the torrent handle std::vector<libtorrent::announce_entry> trackers; try { trackers = h.trackers(); // Get the torrent's list of trackers } catch (libtorrent::invalid_handle e) { return; } // Leave without changing the value of n catch (std::exception e) { return; } n = trackers.size(); // Save how many trackers are in the list to the variable we were given access to } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Takes the infohash of a torrent, a pointer to memory for an array of announce structures, and the number of structures that fit in it // Write information about the torrent's trackers in the given array of structures void GetTrackers(const char *id, announce_structure **torrent_trackers, int n) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); // Get the torrent handle std::vector<libtorrent::announce_entry> trackers = h.trackers(); // Get the list of trackers std::vector<libtorrent::announce_entry>::iterator i = trackers.begin(); // Make an iterator to loop down the trackers announce_structure **a = torrent_trackers; // Point a at the start of the given array of memory // Loop for each tracker int index = 0; while (i != trackers.end()) { libtorrent::announce_entry tracker = *i; announce_structure *info = *a; // Point info at the announce structure under a a++; // Move a forward for the next loop info->tier = tracker.tier; // Copy across the tier number info->url = widenStoC(tracker.url); // Copy the tracker address URL // Make sure we don't loop more than we've got memory to do so index++; if (index >= n) break; i++; // Move to the next tracker in the list } } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Ask the tracker for information about the torrent with the given infohash, like how many peers are complete void ScrapeTracker(const char *id) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.scrape_tracker(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Find out how many files the torrent with the given infohash contains void GetNumFiles(const char *id, int &num_files) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); libtorrent::torrent_info info = h.get_torrent_info(); libtorrent::file_storage files = info.files(); num_files = files.num_files(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Takes the infohash of a torrent, and a pointer an array of file structures // Writes information about the files that make up the torrent with the given infohash void GetFiles(const char *id, file_structure **file_entries) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); // Get the torrent handle libtorrent::torrent_info i = h.get_torrent_info(); // From it get the torrent info object libtorrent::file_storage f = i.files(); // And from that the file storage object // Find out how much of each file is saved std::vector<libtorrent::size_type> progress; h.file_progress(progress); // Slow, faster to tell it to just summarize pieces // Get the priority of each file std::vector<int> priorities = h.file_priorities(); // Loop for each file entry in the torrent's file storage vector int index = 0; std::vector<libtorrent::file_entry>::const_iterator iterator = f.begin(); while (iterator != f.end()) { file_structure *info = *file_entries; // Point info at the file structure at file entries // Copy across information info->index = index; // Save the index info->path = widenStoC(iterator->path.string()); // Get the file path info->size = iterator->size; // Size of the file in bytes info->total_done = progress[index]; // How many bytes of the file are saved info->priority = priorities[index]; // The file's download priority file_entries++; // Point file entries forward the size of one file structure index++; // Move to the next index iterator++; // Move iterator to the next file entry in the file storage vector } } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Find out how many peers the torrent with the given infohash has right now void GetNumPeers(const char *id, int &num_peers) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); std::vector<libtorrent::peer_info> peers; // Make a new empty vector try { h.get_peer_info(peers); // Have libtorrent fill it with with information about each peer } catch (libtorrent::invalid_handle e) { log(L"invalid handle exception"); return; } catch (std::exception e) { log(L"std exception"); return; } num_peers = peers.size(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Fill the given vector with information about the peers of the torrent with the given infohash void GetPeers(const char *id, std::vector<peer_structure> *v) { try { // Get information about the torrent's current peers libtorrent::torrent_handle h = FindTorrentHandle(id); // Look up the torrent handle std::vector<libtorrent::peer_info> peers; // Make a new empty vector that can hold peer_info objects h.get_peer_info(peers); // Have libtorrent fill it with information about each of this torrent's peers // Loop through the peers peer_structure p; std::vector<libtorrent::peer_info>::iterator i = peers.begin(); while (i != peers.end()) { // Copy information from the peer_info object i points to to our local peer_structure, p p.status_flags = i->flags; p.ip = widenStoC(i->ip.address().to_string()); p.source = i->source; p.up_speed = (float)i->up_speed; p.down_speed = (float)i->down_speed; p.payload_up_speed = (float)i->payload_up_speed; p.payload_down_speed = (float)i->payload_down_speed; p.peer_id = base16(i->pid); p.progress = i->progress; // Get the country code WCHAR c[3]; c[0] = (WCHAR)i->country[0]; c[1] = (WCHAR)i->country[1]; c[2] = L'\0'; p.country = c; // Get the client name try { p.client_name = widenStoC(i->client); } catch (std::runtime_error &e) { log(widenPtoC(e.what())); p.client_name = L""; } // Add the peer_structure we filled out to the vector we're supposed to fill v->push_back(p); i++; } } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Get the stripe pattern of pieces for the torrent with the given infohash void GetPiecesStatus(const char *id, pieces_structure *info) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); // Get the torrent handle libtorrent::bitfield b = h.status().pieces; // Get the bitfield of all the pieces int n = b.size(); // Find out how many pieces there are info->completed = 0; // Make a string with a "0" for each piece CString s; for (int i = 0; i < n; i++) s += L'0'; // Piece pending // Loop through all the torrent's peers std::vector<libtorrent::peer_info> peers; h.get_peer_info(peers); // Get information about all the torrent's peers std::vector<libtorrent::peer_info>::iterator iterator1 = peers.begin(); while (iterator1 != peers.end()) { if (iterator1->downloading_piece_index > -1 && iterator1->downloading_piece_index < n) // This peer is download a piece s.SetAt(iterator1->downloading_piece_index, L'a'); // Mark the piece active iterator1++; } // Loop through all the torrent's partial pieces std::vector<libtorrent::partial_piece_info> pieces; h.get_download_queue(pieces); // Get information about all the torrent's download requests and downloads in progress std::vector<libtorrent::partial_piece_info>::iterator iterator2 = pieces.begin(); while (iterator2 != pieces.end()) { libtorrent::partial_piece_info p = *iterator2; if (p.piece_index > -1 && p.piece_index < n) { // If the partial piece info structure has a valid piece index if (s[p.piece_index] != L'a') { // Mark the piece active in our record of them if (p.writing > 0) s.SetAt(p.piece_index, L'a'); // Piece active else if (p.requested > 0 && p.finished > 0) s.SetAt(p.piece_index, L'p'); // Piece partial else if (p.finished == 0) s.SetAt(p.piece_index, L'q'); // Piece queued } } iterator2++; } // Loop through all the pieces that aren't active in our record of them for (int i = 0; i < n; i++) { if (s[i] != L'a') { // Piece not active // The bitfield indicates we have this piece if (b[i]) { s.SetAt(i, L'x'); // Piece downloaded info->completed++; // Count one more piece downloaded // The bitfield indicates we don't have this piece } else { // Loop through all the peers bool available = false; // True when we've found one that has this piece iterator1 = peers.begin(); while (iterator1 != peers.end()) { if (iterator1->pieces[i]) { // The peer under iterator has piece i available = true; // Found it break; // Don't need to look anymore } iterator1++; } // No peer has the piece if (!available) { if (s[i] == L'p') // Piece partial, we've saved some of it so far s.SetAt(i, L'u'); // Piece unavailable partial, the rest of it is nowhere in the swarm else s.SetAt(i, L'U'); // Piece unavailable, it's entirely missing } } } } // Copy the string we made into the given structure info->pieces = s; } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Takes the infohash of a torrent, the index of a file in it, and the desired priority for that file // Sets the priority to the file in the torrent void SetFilePriority(const char *id, int index, int priority) { try { libtorrent::torrent_handle h = FindTorrentHandle(id); h.file_priority(index, priority); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Takes the infohash of a torrent, a pointer to a block of ints, and the number of ints in that block // Sets those priorities on the files in the torrent void SetFilePriorities(const char *id, int *priorities, int n) { try { // Convert the given array of ints into a vector of ints std::vector<int> v; for (int i = 0; i < n; i++) { int priority = *priorities; v.push_back(priority); // Add it to the end of the list priorities++; // Move the pointer forward to the next int } libtorrent::torrent_handle h = FindTorrentHandle(id); h.prioritize_files(v); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Tell libtorrent the host name and port number of a peer on the DHT void AddDhtNode(const char *address, int port) { try { App.session->add_dht_node(std::pair<std::string, int>(std::string(address), port)); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Tell libtorrent the domain name and port number of a DHT bootstrapping router void AddDhtRouter(const char *address, int port) { try { App.session->add_dht_router(std::pair<std::string, int>(std::string(address), port)); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Takes the path to DHT information saved from a previous session // Starts the DHT, using the file if it's there void StartDht(const wchar_t *path) { try { // Open the file std::wstring w(path); boost::filesystem::wpath p(w); boost::filesystem::ifstream f(p, std::ios_base::binary); // Initialize variables libtorrent::entry e = 0; // The bencoded DHT state information from the file bool b = false; // True once we've gotten information from the file if (!f.fail()) { try { // Read the file, parsing its contents into a libtorrent entry object e = libtorrent::bdecode(std::istream_iterator<char>(f), std::istream_iterator<char>()); b = true; // Record that worked without an exception } catch (std::exception &e) { // No file or bad information inside, we'll just start the DHT without resume data log(widenPtoC(e.what())); // Log a note but keep going } } // Start the DHT if (b) App.session->start_dht(e); // With the file information we got else App.session->start_dht(); // Without any information from a previous session } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Have libtorrent disconnect from the DHT void StopDht() { try { App.session->stop_dht(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Start the local service directory, which uses multicast to find peers on the LAN void StartLsd() { try { App.session->start_lsd(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Stop the local service directory void StopLsd() { try { App.session->stop_lsd(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Create port mappings on a UPnP device on the LAN void StartUpnp() { try { App.session->start_upnp(); // Returns an object you could use } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Stop the UPnP service void StopUpnp() { try { App.session->stop_upnp(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Use NAT-PMP to map ports on the router void StartNatpmp() { try { App.session->start_natpmp(); // Returns an object you could use } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } } // Stop the NAT-PMP service void StopNatpmp() { try { App.session->stop_natpmp(); } catch (std::exception &e) { log(widenPtoC(e.what())); } catch (...) { log(L"exception"); } }
728cc687a7265a9a0b36c04fce2174e3dd210596
7761859044d1881c83c60e3dbd380fed2cd14afb
/Pruebas/ArbolBinario/ArbolBinario.h
3093e236cf091b47257d3f51ff997e8cdfdd4b45
[]
no_license
camilojm27/ProgramacionCompetitiva
5f44ce4b92f4e38395e8b77e6c76d55e4b5f850b
d179814bcd1a171cf5c99c8959e0ca05d4877a63
refs/heads/master
2021-04-18T22:43:26.669044
2020-03-21T03:34:33
2020-03-21T03:34:33
126,571,358
0
0
null
2019-07-04T17:12:07
2018-03-24T06:09:34
C++
UTF-8
C++
false
false
308
h
ArbolBinario.h
#include <iostream> using namespace std; struct Nodo { int dato; Nodo *der; Nodo *izq; }; Nodo *crearNodo(int); void insertarNodo(Nodo *&arbol, int n); void mostrarArbol(Nodo *, int contador); bool busqueda(Nodo *arbol, int n); // Nodo *arbol = NULL; Con esta linea crea un nuevo arbol(Nodo)
0c7c896cfc0dac5674f287ab70b77c1f1c845943
2a3c5d469f89dfbbfc7be1d276867f62619418b0
/airbender.h
1785e7af3800a9d4119e199b47dbeba6abbe8ffc
[]
no_license
abialvarado14/Suyapa_Alvarado_lab9_avatar
b04799e58583d0af1d7839b7d8389851f59a7d95
9c446f2004be9dfd545e1dbaa87e31f0c343d1fc
refs/heads/master
2021-01-22T20:44:08.664080
2017-03-17T17:57:11
2017-03-17T17:57:11
85,347,873
0
0
null
null
null
null
UTF-8
C++
false
false
273
h
airbender.h
#include "Bender.h" #include <string> #ifndef AIRBENDER_H #define AIRBENDER_H using namespace std; class airbender : public Bender{ public: airbender(int, int, int, int, string); virtual void ataqueNormal(Bender*); virtual void ataqueEspecial(Bender*); }; #endif
612c0d4cce96d2373e6655405024dcbb2da64eff
61304bfb26ac0615629ebd44ecfcff2dce803fcb
/chefAndLeftRight.cpp
7df0b50f34c16e59d1d45091af5c873d11917494
[]
no_license
gokul1998/Codechef
c6109d5ade6c1fcfbb581647ed0ff8c97b441ccc
253a779a0c669cb2b41d3f1ede1bdf0f7259b40e
refs/heads/master
2020-06-23T09:48:58.653802
2019-07-24T08:11:33
2019-07-24T08:14:06
198,589,391
3
0
null
null
null
null
UTF-8
C++
false
false
472
cpp
chefAndLeftRight.cpp
#include<bits/stdc++.h> #define MOD 1000000007 using namespace std; int main(){ int t; cin>>t; while(t--){ string s; int i,len; long long r=1; cin>>s; len=s.size(); for(i=0;i<len;i++){ if(i%2==0){ if(s[i]=='l')r=(r*2)%MOD; else r=((r*2)+2)%MOD; // cout<<"if "; } else{ if(s[i]=='l')r=(2*r-1)%MOD; else r=(2*r+1)%MOD; // cout<<"else "; } //cout<<r<<" t"<<endl; } cout<<r<<endl; } }
751c789c8c7c0c81931e28563b505e1f19a76ac1
1e5cf97921ce4a6b18b169bd348db24c03e29c5b
/theory_and_practice/algorithms_and_data_structures/data_structures/avl_tree/avl_tree.hpp
c4a4da9811d283e0bce08ec147dc6fe391de83a9
[]
no_license
lnikon/edu
68c51cf1c1246939c748d698b74e982ea96ef7d1
7df043e24560fa136a2142871100af94021bd61e
refs/heads/master
2021-01-07T07:23:04.923479
2020-03-05T12:44:24
2020-03-05T12:44:24
241,619,433
0
0
null
null
null
null
UTF-8
C++
false
false
3,761
hpp
avl_tree.hpp
#pragma once #include <iostream> #include <stack> struct AVLNode { int value{0}; int height{0}; AVLNode* left{nullptr}; AVLNode* right{nullptr}; AVLNode(int value) : value(value), height(0), left(nullptr), right(nullptr) {} }; class AVLTree { public: ~AVLTree() {} AVLNode* insert(int value) { if (root == nullptr) { root = new AVLNode(value); } AVLNode** node = &root; while (*node != nullptr) { if (value > (*node)->value) { node = &(*node)->right; } else if (value < (*node)->value) { node = &(*node)->left; } else { /* No duplicate keys */ return *node; } } if (*node == nullptr) { *node = new AVLNode(value); return *node; } return nullptr; } AVLNode* search(int value) { if (root == nullptr) { return nullptr; } AVLNode** node = &root; while (*node != nullptr) { if (value > (*node)->value) { node = &(*node)->right; } else if (value < (*node)->value) { node = &(*node)->left; } else { return *node; } } return nullptr; } void preorderIterative() { preorderIterativeHelper(root); } void inorderIterative() { inorderIterativeHelper(root); } void preorder() { preorderHelper(root); } void inorder() { inorderHelper(root); } void postorder() { postorderHelper(root); } private: AVLNode* root{nullptr}; void leftLeftRotate() {} void leftRightRotate() {} void rightRightRotate() {} void rightLeftRotate() {} void height(const AVLNode* node) {} void balanceFactor(const AVLNode* node) {} void visit(AVLNode* node) { std::cout << "At node @" << node << " value = " << node->value << std::endl; } void preorderIterativeHelper(AVLNode* node) { if (node == nullptr) return; std::stack<AVLNode*> stack; stack.push(node); while (!stack.empty()) { AVLNode* node = stack.top(); stack.pop(); visit(node); if (node->right != nullptr) stack.push(node->right); if (node->left != nullptr) stack.push(node->left); } } void inorderIterativeHelper(AVLNode* node) { if (node == nullptr) return; std::stack<AVLNode*> stack; while (!stack.empty() || node != nullptr) { if (node != nullptr) { stack.push(node); node = node->left; } else { node = stack.top(); stack.pop(); visit(node); node = node->right; } } } void preorderHelper(AVLNode* node) { if (node == nullptr) return; visit(node); preorderHelper(node->left); preorderHelper(node->right); } void inorderHelper(AVLNode* node) { if (node == nullptr) return; inorderHelper(node->left); visit(node); inorderHelper(node->right); } void postorderHelper(AVLNode* node) { if (node == nullptr) return; postorderHelper(node->left); postorderHelper(node->right); visit(node); } };
56ee67550b15e6c36116f6573afbafffbb0dd4c3
09d1138225f295ec2e5f3e700b44acedcf73f383
/Plugins/Prism/ServerManager/vtkSMPrismThresholdRangeDomain.cxx
b4ac16032900e7c801d677554b32439d72eb3a73
[ "BSD-3-Clause" ]
permissive
nagyist/ParaView
e86d1ed88a805aecb13f707684103e43d5f6b09f
6810d701c44b2097baace5ad2c05f81c6d0fd310
refs/heads/master
2023-09-04T07:34:57.251637
2023-09-03T00:34:36
2023-09-03T00:34:57
85,244,343
0
0
BSD-3-Clause
2023-09-11T15:57:25
2017-03-16T21:44:59
C++
UTF-8
C++
false
false
2,938
cxx
vtkSMPrismThresholdRangeDomain.cxx
// SPDX-FileCopyrightText: Copyright (c) Kitware Inc. // SPDX-License-Identifier: BSD-3-Clause #include "vtkSMPrismThresholdRangeDomain.h" #include "vtkObjectFactory.h" #include "vtkPVXMLElement.h" #include "vtkSMDoubleVectorProperty.h" #include "vtkSMIntVectorProperty.h" #include "vtkSMStringVectorProperty.h" #include "vtkSMUncheckedPropertyHelper.h" #include <sstream> //------------------------------------------------------------------------------ vtkStandardNewMacro(vtkSMPrismThresholdRangeDomain); //------------------------------------------------------------------------------ vtkSMPrismThresholdRangeDomain::vtkSMPrismThresholdRangeDomain() = default; //------------------------------------------------------------------------------ vtkSMPrismThresholdRangeDomain::~vtkSMPrismThresholdRangeDomain() = default; //------------------------------------------------------------------------------ void vtkSMPrismThresholdRangeDomain::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "AxisId: " << this->AxisId << endl; } //============================================================================= namespace { template <typename T> T lexical_cast(const std::string& s) { std::stringstream ss(s); T result; if ((ss >> result).fail() || !(ss >> std::ws).eof()) { throw std::bad_cast(); } return result; } } //------------------------------------------------------------------------------ int vtkSMPrismThresholdRangeDomain::ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLElement* element) { if (!this->Superclass::ReadXMLAttributes(prop, element)) { return 0; } const char* axis_id = element->GetAttribute("axis_id"); if (axis_id) { try { this->AxisId = lexical_cast<int>(axis_id); } catch (const std::bad_cast&) { vtkErrorMacro("Invalid axis_id attribute: " << axis_id); return 0; } } else { vtkErrorMacro("Missing axis_id attribute."); return 0; } return 1; } //------------------------------------------------------------------------------ void vtkSMPrismThresholdRangeDomain::Update(vtkSMProperty*) { auto bounds = vtkSMDoubleVectorProperty::SafeDownCast(this->GetRequiredProperty("Bounds")); if (!bounds) { vtkErrorMacro("Missing required properties."); return; } vtkSMUncheckedPropertyHelper boundsHelper(bounds); std::vector<vtkEntry> values; switch (this->AxisId) { case 0: values.push_back(vtkEntry(boundsHelper.GetAsDouble(0), boundsHelper.GetAsDouble(1))); break; case 1: values.push_back(vtkEntry(boundsHelper.GetAsDouble(2), boundsHelper.GetAsDouble(3))); break; case 2: values.push_back(vtkEntry(boundsHelper.GetAsDouble(4), boundsHelper.GetAsDouble(5))); break; default: vtkErrorMacro("Invalid axis id: " << this->AxisId); return; } this->SetEntries(values); }
eb142eda57d17dba36c741376c3476392798b9db
2bce17904e161a4bdaa2d65cefd25802bf81c85b
/codeforces/906/B/B.cc
b407deb7dc44d17995070a5abf216a6a4367bfd7
[]
no_license
lichenk/AlgorithmContest
9c3e26ccbe66d56f27e574f5469e9cfa4c6a74a9
74f64554cb05dc173b5d44b8b67394a0b6bb3163
refs/heads/master
2020-03-24T12:52:13.437733
2018-08-26T01:41:13
2018-08-26T01:41:13
142,727,319
0
0
null
null
null
null
UTF-8
C++
false
false
3,273
cc
B.cc
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native") #include "bits/stdc++.h" #include <assert.h> using namespace std; typedef long long ll; typedef long double ld; #define PB push_back #define MP make_pair const int MOD=1000000007; #define endl "\n" #define fst first #define snd second const int UNDEF = -1; const int INF=1<<30; template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; } template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; } typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi; #ifdef ONLINE_JUDGE #define assert(...) /* nothing */ #endif #define DEBUG_CAT #ifdef DEBUG_CAT #define dbg(...) printf( __VA_ARGS__ ) #else #define dbg(...) /****nothing****/ #endif int rint();char rch();long long rlong(); const int maxn=100000; clock_t start; int a[maxn],b[maxn]; bitset<maxn> divm; int n,m,nm; inline bool checkneigh(int x, int y) { if (x>y) swap(x,y); int diff=y-x; //if (((diff==m)||diff==1 && divm[y])) printf("x:%d y:%d\n",x,y); return ((diff==m)||diff==1 && divm[y]); } inline void check() { for (int x=0;x<nm-m;x++) { if (checkneigh(a[x],a[x+m])) return; } for (int x=1;x<nm;x++) { if (divm[x] && checkneigh(a[x],a[x-1])) return; } printf("YES"); for (int x=0;x<nm;x++) { if (!divm[x]) printf("\n"); printf("%d ",a[x]+1); } exit(0); } void pr() { for (int x=0;x<nm;x++) { if (!divm[x]) printf("\n"); printf("%d ",a[x]); } } void brute() { for (int x=0;x<nm;x++) a[x]=x; while(1) { clock_t now=clock(); if (now - start > 1.72 * CLOCKS_PER_SEC) break; srand(now); random_shuffle(a,a+nm); check(); } } void smart1(int mode) { if (mode&2) swap(n,m); int pos=0; for (int x=0;x<n;x++) { int base=x*m; for (int y=base;y<base+m;y+=2) { a[pos++]=y; } for (int y=base+1;y<base+m;y+=2) { a[pos++]=y; } if (x&1) { reverse(a+base,a+base+m); if(mode&1)for (int y=base+1;y<base+m;y+=2) { swap(a[y-1],a[y]); } } } { memcpy(b,a,sizeof(a)); int id=0; for (int x=0;x<n;x+=2) { for (int y=0;y<m;y++) { a[id++]=b[x*m+y]; } } for (int x=1;x<n;x+=2) { for (int y=0;y<m;y++) { a[id++]=b[x*m+y]; } } } for (int x=1;x<n;x+=2) { int base=x*m; for (int y=base+1;y<base+m;y+=2) { swap(a[y],a[y-m]); } } if (mode&2) { memcpy(b,a,sizeof(a)); for (int x=0;x<n;x++) { for (int y=0;y<m;y++) { int val=b[x*m+y]; int r=val/m,c=val%m; a[y*n+x]=c*n+r; } } swap(n,m); } check(); //pr(); } int main() { start=clock(); ios_base::sync_with_stdio(false); cin.tie(0); scanf("%d%d",&n,&m); //printf("isneigh:%d\n",checkneigh(2,3)); nm=n*m; divm.set(); for (int x=0;x<nm;x+=m) divm[x]=false; for (int mode=0;mode<4;mode++) smart1(mode); brute(); assert(0); printf("NO\n"); } int rint() { int x; scanf("%d",&x); return x; } char rch() { char x; scanf("%c",&x); return x; } long long rlong() { long long x; scanf("%lld",&x); return x; }
9e77b15efa9fe7b105449dd75ad3f7e44d7a05bb
06df0250fc60734329682c263384561638e2a42e
/src/input/mouse/MouseState.cpp
c4a97ef7e4e47ca96ea627bcdf9d29f7f8fc932e
[]
no_license
mmicciolo/VenomFramework
2747811bf20bd8e3008e940e46dbd5592ce93ebc
085ae42548a730007983d7ce529f66039b7f4cac
refs/heads/master
2020-03-18T07:58:59.804675
2018-06-27T20:38:14
2018-06-27T20:38:14
134,480,500
0
0
null
null
null
null
UTF-8
C++
false
false
1,663
cpp
MouseState.cpp
#include "MouseState.h" bool VF::Input::MouseState::IsButtonPressed(MouseButtons::Buttons button) { switch (button) { case MouseButtons::Buttons::LEFT_BUTTON: return mouseData.leftButton == ButtonState::State::Pressed ? true : false; case MouseButtons::Buttons::RIGHT_BUTTON: return mouseData.rightButton == ButtonState::State::Pressed ? true : false; case MouseButtons::Buttons::MIDDLE_BUTTON: return mouseData.middleButton == ButtonState::State::Pressed ? true : false; case MouseButtons::Buttons::X_BUTTON_1: return mouseData.XButton1 == ButtonState::State::Pressed ? true : false; case MouseButtons::Buttons::X_BUTTON_2: return mouseData.XButton2 == ButtonState::State::Pressed ? true : false; default: return false; } } bool VF::Input::MouseState::IsButtonReleased(MouseButtons::Buttons button) { switch (button) { case MouseButtons::Buttons::LEFT_BUTTON: return mouseData.leftButton == ButtonState::State::Released ? true : false; case MouseButtons::Buttons::RIGHT_BUTTON: return mouseData.rightButton == ButtonState::State::Released ? true : false; case MouseButtons::Buttons::MIDDLE_BUTTON: return mouseData.middleButton == ButtonState::State::Released ? true : false; case MouseButtons::Buttons::X_BUTTON_1: return mouseData.XButton1 == ButtonState::State::Released ? true : false; case MouseButtons::Buttons::X_BUTTON_2: return mouseData.XButton2 == ButtonState::State::Released ? true : false; default: return false; } } VF::Input::MousePosition VF::Input::MouseState::GetMousePosition() { return mouseData.position; } int VF::Input::MouseState::GetScrollWheelValue() { return mouseData.scrollWheelValue; }
309bb5d3305efb7e72184e695b780aea599dfcc3
b96a1a03a0b34dd78d02e7293608f3ff7e6fbcd7
/Tutorial12_MeshClass/Mesh.h
c2e429ce3d96bd33a7cfbec05ff73677f440eeeb
[]
no_license
finoriko/CppOpenGL
e9cd67616516b536e56078230f30d011b3ee2107
1d5ea29c504924b0b8632371fd0e66ab6c7c576e
refs/heads/master
2021-05-25T17:37:54.538440
2020-06-14T14:56:55
2020-06-14T14:56:55
253,848,602
0
0
null
null
null
null
UTF-8
C++
false
false
3,497
h
Mesh.h
#pragma once #include<iostream> #include<vector> #include"Vertex.h" #include"Shader.h" #include"Texture.h" #include"Material.h" class Mesh { private: std::vector<Vertex> vertices; std::vector<GLuint> indices; GLuint VAO; GLuint VBO; GLuint EBO; glm::vec3 position; glm::vec3 rotation; glm::vec3 scale; glm::mat4 ModelMatrix; void initVertexData(Vertex* vertexArray, const unsigned& nrOfVertices, GLuint* indexArray, const unsigned& nrOfIndices) { for (size_t i = 0; i < nrOfVertices; i++) { this->vertices.push_back(vertexArray[i]); } for (size_t i = 0; i < nrOfIndices; i++) { this->indices.push_back(indexArray[i]); } } void initVAO() { glCreateVertexArrays(1, &this->VAO); glBindVertexArray(this->VAO); //GEN VBO AND BIND AND SEND DATA glGenBuffers(1, &this->VBO); glBindBuffer(GL_ARRAY_BUFFER, this->VBO); glBufferData(GL_ARRAY_BUFFER, this->vertices.size()*sizeof(Vertex), vertices.data(), GL_STATIC_DRAW); //GEN EBO AND BIND AND SEND DATA glGenBuffers(1, &this->EBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER,this->indices.size()* sizeof(GLuint), indices.data(), GL_STATIC_DRAW); //SET VERTEXATTRIBPOINTERS AND ENABLE(Input ASSEMBLY) /*GLuint attribLoc = glGetAttribLocation(core_program, "vertex_position"); glVertexAttribPointer(attribLoc, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),(GLvoid*)offsetof(Vertex,position)); glEnableVertexAttribArray(attribLoc);*/ //Position glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, position)); glEnableVertexAttribArray(0); //Color glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, color)); glEnableVertexAttribArray(1); //Texcoord glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, texcoord)); glEnableVertexAttribArray(2); //Normal glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, normal)); glEnableVertexAttribArray(3); //BIND VAO 0 glBindVertexArray(0); } void initModelMatrix() { this->position = glm::vec3(0.f); this->rotation = glm::vec3(0.f); this->scale = glm::vec3(1.f); this->ModelMatrix = glm::mat4(1.f); this->ModelMatrix = glm::translate(this->ModelMatrix, this->position); this->ModelMatrix = glm::rotate(this->ModelMatrix, glm::radians(this->rotation.x), glm::vec3(1.f, 0.f, 0.f)); this->ModelMatrix = glm::rotate(this->ModelMatrix, glm::radians(this->rotation.y), glm::vec3(0.f, 1.f, 0.f)); this->ModelMatrix = glm::rotate(this->ModelMatrix, glm::radians(this->rotation.z), glm::vec3(0.f, 0.f, 1.f)); this->ModelMatrix = glm::scale(this->ModelMatrix, this->scale); } void updateUniform(Shader* shader) { shader->setMat4fv(this->ModelMatrix, "ModelMatrix"); } public: Mesh(Vertex* vertexArray, const unsigned& nrOfVertices, GLuint* indexArray, const unsigned& nrOfIndices) { this->initVertexData(vertexArray, nrOfVertices, indexArray, nrOfIndices); this->initVAO(); this->initModelMatrix(); } ~Mesh() { glDeleteVertexArrays(1, &this->VAO); glDeleteBuffers(1, &this->VBO); glDeleteBuffers(1, &this->EBO); } void update() { } void render(Shader* shader) { //Update Uniform this->updateUniform(shader); shader->use(); //Bind VAO glBindVertexArray(this->VAO); //RENDER glDrawElements(GL_TRIANGLES, this->indices.size(), GL_UNSIGNED_INT, 0); } };
c38dfc334bf720f61d51d3f6c1440d74979a756b
778f08e46f73cb6f48c8681b95be74858adcbada
/gis_patrol_client/src/patrolCommunications/pAttribute.h
d6220770c7a78182440968d8f9ba620a7e71705e
[]
no_license
YuriyRusinov/gis_patrol_rubin
2704e2612431e9197da738ac9a860173a1127256
6c1344ac29fdfc28b63e737dab53900f8cab1ab1
refs/heads/master
2023-06-15T14:21:12.621001
2021-01-21T20:34:22
2021-01-21T20:34:22
265,806,283
0
0
null
null
null
null
UTF-8
C++
false
false
349
h
pAttribute.h
/* * @brief Абстрактный класс, описывающий параметры/группу параметров узла связи, * pAttribute.h * * (C) НИИ "Рубин" * @author * Ю.Л.Русинов */ #pragma once class pAttribute { public: virtual int getEntity() const=0; virtual qint64 getId() const=0; };
c3fc924bf406588a5f248b7f1b38f3b3ae24ffec
7b67cab222fa108d3bb9728ac5ccb8dccb820435
/PixelJetFinder/interface/PixelJetProducer.h
25db82437649778fb4cb9d53748f0db64ce9ac5d
[]
no_license
lsilvamiguel/usercode
5fbfa224c0be162df350cff8a6964e15d665b925
16e28f8126b844775853c58c0e6bba3a24e106dc
refs/heads/master
2021-01-09T05:57:56.039791
2016-12-21T16:05:30
2016-12-21T16:05:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,416
h
PixelJetProducer.h
// // Package: AnalysisExample/PixelJetFinder // Class: PixelJetProducer // // // Description: Produces PixelJets from PixelTracks // // Original Authors: M. De Mattia // Created: 6/8/2007 // #ifndef AnalysisExamples_PixelJetFinder_h #define AnalysisExamples_PixelJetFinder_h //#include <map> // Needed to use the DEFINE_FW_MODULE directive at the end of the cc file // and register this class as a framework module #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/EventSetup.h" // #include "Geometry/Vector/interface/GlobalVector.h" // #include "Geometry/Vector/interface/LocalVector.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/Common/interface/EDProduct.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/TrackReco/interface/Track.h" /* #include "DataFormats/TrackReco/interface/TrackExtra.h" */ /* #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h" */ /* #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h" */ /* #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" */ /* #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" */ /* #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" */ /* #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h" */ /* #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h" */ /* #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h" */ /* #include "TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h" */ /* #include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h" */ /* #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h" */ /* #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" */ /* #include "FWCore/MessageLogger/interface/MessageLogger.h" */ /* #include "DataFormats/DetId/interface/DetId.h" */ /* #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" */ /* #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" */ /* #include "AnalysisDataFormats/SiStripClusterInfo/interface/SiStripClusterInfo.h" */ #include "AnalysisExamples/PixelJet/interface/PixelJet.h" // Added for the trackassociator /* #include "SimTracker/TrackAssociation/test/testTrackAssociator.h" */ /* #include "SimTracker/Records/interface/TrackAssociatorRecord.h" */ /* #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" */ /* #include "DataFormats/TrackReco/interface/TrackFwd.h" */ /* #include "SimTracker/TrackAssociation/interface/TrackAssociatorBase.h" */ //#include <TMath.h> class PixelJetProducer : public edm::EDProducer { public: explicit PixelJetProducer(const edm::ParameterSet& conf); virtual ~PixelJetProducer(); virtual void beginJob(const edm::EventSetup& c); virtual void endJob(); virtual void produce(edm::Event& e, const edm::EventSetup& c); private: edm::ParameterSet conf_; std::string filename_; std::string pixeljet_; double eta_cut_; double ConeR_cut_; int NumTk_cut_; float Eta_cut_Eff_; unsigned int eventcounter_; }; #endif // AnalysisExamples_PixelJetFinder_h
efc78d305f7535271589e5619be76f483dfea54c
cd0b338301ee4997c4cb114899ebd407c2b62c0b
/Codeforces/1294A.cpp
8f89e85ffd4680ac014c94b1847d825f061d51dc
[]
no_license
shubh-am-gupta/Competitive-Programming-
c433b4fe3806df902ec46877417ed7e4209786c4
3138ca94910cd9d0e2aa0f8934ffc7cb1f3badbd
refs/heads/master
2021-09-08T03:53:39.851506
2020-10-02T06:43:55
2020-10-02T06:43:55
246,778,259
1
2
null
2021-08-31T03:45:21
2020-03-12T08:12:10
C++
UTF-8
C++
false
false
543
cpp
1294A.cpp
problem link--> https://codeforces.com/contest/1294/problem/A #include <bits/stdc++.h> using namespace std; typedef long long ll; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); #define test ll t; cin>>t; while(t--) int main() { fast; test{ ll a[3],n,x; cin>>a[0]>>a[1]>>a[2]>>n; sort(a,a+3); x=a[2]-a[0]+a[2]-a[1]; if(x<=n) n-=x; else{ cout<<"NO\n"; continue; } if(n%3==0)cout<<"YES\n"; else cout<<"NO\n"; } return 0; }
55ba0ca6fe8b9a8f81b178324cbdb570e3ca0030
7d5593b9bbaf6bb8eaacca88449d90c9c305c36e
/problems/928-minimize-malware-spread-ii/928.cc
a6e9dec7342b91dfd55286949f20cf0c7095cde9
[]
no_license
yottacto/leetcode
fc98052ed9d643be8a79116d28540596bcc7c26b
9a41e41c0982c1a313803d1d8288d086fbdbd5b6
refs/heads/master
2021-04-25T12:05:55.671066
2019-12-15T03:07:31
2019-12-15T03:07:31
111,814,868
2
0
null
null
null
null
UTF-8
C++
false
false
34
cc
928.cc
#include "928.hh" int main() { }
b24cd0afb1ec07562b71c101672b9f6683eea376
2d0ecc01a2876c52daad91f50c51cb5f052daf44
/acmicpc/icpc/trains/tzc/2013-08-23-bfs/简单版贪食蛇.cpp
e5138a1b4c7069197c8ddd63f764f14f66e0115a
[]
no_license
shimaomao/language
353cafdc9758142bbc2421b443070ec2942e62b2
4f1244c7222b07b03d13e534b0ee9340c3b43c07
refs/heads/master
2020-06-18T00:01:36.040333
2018-09-04T01:58:40
2018-09-04T01:58:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,517
cpp
简单版贪食蛇.cpp
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <queue> #include <algorithm> using namespace std; const int N = 105; int n, m; char map[N][N]; struct Point { int x, y; string steps; }; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; // E, W, S, N string ds[] = {"E", "W", "S", "N"}; bool ok(int x, int y) { return (x >= 0 && x < m && y >= 0 && y < n && map[x][y] != '#'); } Point you; string bfs() { queue<Point> Q; Q.push(you); Point cur, nex; while(!Q.empty()) { cur = Q.front(); Q.pop(); for(int i = 0; i < 4; i++) { nex.x = cur.x + dx[i]; nex.y = cur.y + dy[i]; if(!ok(nex.x, nex.y)) continue; if(map[nex.x][nex.y] == 'E') { return cur.steps + ds[i]; } nex.steps = cur.steps + ds[i]; map[nex.x][nex.y] = '#'; Q.push(nex); } } return "-1"; } int main() { while(scanf("%d%d", &m, &n) != EOF) { for(int i = 0; i < m; i++) { scanf("%s", map[i]); for(int j = 0; j < n; j++) { if(map[i][j] == 'S') { you.x = i; you.y = j; map[i][j] = '#'; you.steps = ""; } } } string ans = bfs(); if(ans == "-1") printf("Can't eat it!"); else cout << ans; printf("\n"); } return 0; }
b2c6c6f27a2bd78441901297efdd74972fe28af6
63b2914b4596a81eb17f37b5015a608b0b94f8f5
/2images_restruction/src/LoadJPEG.cpp
e543089b292ec342a0a36b421079710c00d3ef45
[]
no_license
TripleTLab/SfM_Reconstruction
66a82f905fdefc6f49633dfb2780051fc726e185
4db2b3847f5e0e1eaf63a7daa664d42db6669d5b
refs/heads/master
2021-01-24T10:38:54.273971
2018-03-28T12:19:48
2018-03-28T12:19:48
123,057,490
6
3
null
null
null
null
UTF-8
C++
false
false
3,479
cpp
LoadJPEG.cpp
#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <jpeglib.h> #include "image.h" void GetJPEGDimensions(const char *filename, int &w, int &h) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); FILE *f; if ((f = fopen(filename, "rb")) == NULL) { printf("[GetJPEGDimensions] Error: can't open file %s for reading\n", filename); return; } jpeg_stdio_src(&cinfo, f); jpeg_read_header(&cinfo, TRUE); w = cinfo.image_width; h = cinfo.image_height; printf("[GetJPEGDimensions] File %s: ( %d , %d )\n", filename, w, h); jpeg_destroy_decompress(&cinfo); fclose(f); } /* Note: information on libjpeg can be found here: * http://www.jpegcameras.com/libjpeg/libjpeg-2.html */ img_t *LoadJPEG(const char *filename) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); FILE *f; if ((f = fopen(filename, "rb")) == NULL) { printf("[LoadJPEG] Error: can't open file %s for reading\n", filename); return NULL; } jpeg_stdio_src(&cinfo, f); jpeg_read_header(&cinfo, TRUE); jpeg_start_decompress(&cinfo); int w = cinfo.output_width; int h = cinfo.output_height; int n = cinfo.output_components; assert(n == 1 || n == 3); img_t *img = img_new(w, h); JSAMPROW row = new JSAMPLE[n * w]; for (int y = 0; y < h; y++) { jpeg_read_scanlines(&cinfo, &row, 1); for (int x = 0; x < w; x++) { if (n == 3) { img_set_pixel(img, x, h - y - 1, row[3 * x + 0], row[3 * x + 1], row[3 * x + 2]); } else if (n == 1) { img_set_pixel(img, x, h - y - 1, row[x], row[x], row[x]); } } } jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); delete [] row; fclose(f); return img; } void WriteJPEG(const img_t *img, const char *filename) { struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); FILE *outfile; if ((outfile = fopen(filename, "wb")) == NULL) { printf("[WriteJPEG] can't open file %s for writing\n", filename); return; } jpeg_stdio_dest(&cinfo, outfile); cinfo.image_width = img->w; cinfo.image_height = img->h; cinfo.input_components = 3; cinfo.in_color_space = JCS_RGB; jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, 98, TRUE); jpeg_start_compress(&cinfo, TRUE); JSAMPROW row = new JSAMPLE[3 * img->w]; for (int y = 0; y < img->h; y++) { // JSAMPROW row_pointer[1]; int row_stride; row_stride = img->w * 3; for (int x = 0; x < img->w; x++) { color_t c = img_get_pixel((img_t *) img, x, img->h - y - 1); row[3 * x + 0] = c.r; row[3 * x + 1] = c.g; row[3 * x + 2] = c.b; } jpeg_write_scanlines(&cinfo, &row, 1); } jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); delete [] row; fclose(outfile); } #if 0 int main() { img_t *img = ReadJPEG("test.jpg"); img_write_bmp_file(img, "test.bmp"); return 0; } #endif
9a3d27306c117bed5cc5b3afd2bcfb6da936effc
8e068eede9730e6ce3773f1e7232c34dd03ef29d
/Engine/Common/Engine/Application/IGameLaunchOption.h
d64f53e1843dca35b8052c4f1a25b995e7eef11f
[ "MIT" ]
permissive
leec0m3t/Leggiero
2e228fa23f723132883577c8018e7f6a47879f61
8fe13d86454a08ba8a3a8cebe1ce92343090c1be
refs/heads/main
2023-04-09T19:17:06.555139
2021-04-19T06:54:00
2021-04-19T06:54:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
529
h
IGameLaunchOption.h
//////////////////////////////////////////////////////////////////////////////// // Application/IGameLaunchOption.h (Leggiero - Engine) // // Abstract Interface for Game Launch Option Class //////////////////////////////////////////////////////////////////////////////// #ifndef __ENGINE__APPLICATION__I_GAME_LAUNCH_OPTION_H #define __ENGINE__APPLICATION__I_GAME_LAUNCH_OPTION_H namespace Leggiero { // Interface for Game Launch Option class IGameLaunchOption { public: virtual ~IGameLaunchOption() { } }; } #endif
755e579846532c84eb57212b6aadf026006a4645
8e90818d38e59997949b0bf8a661df903f74fb3b
/zgsaPC/roomsvrzgsa/Service.cpp
4f2c5a4d085ef40e987a564c66c575dc87229b0d
[]
no_license
externIE/yingsanzhang
092a4dcc5f0b31f8ca66e6d1d5eeca2c166af5f3
f72f9e8739bdf9c550cab176af69dbe0a44ee9bc
refs/heads/master
2021-01-10T12:07:58.552113
2016-03-25T05:52:37
2016-03-25T05:52:37
54,697,781
0
0
null
null
null
null
UTF-8
C++
false
false
3,827
cpp
Service.cpp
#include "stdafx.h" #ifdef _DEBUG #define new DEBUG_NEW #endif const DWORD dwWaitFinished = 5000; // time to wait for threads to finish up CMainService::CMainService(const TCHAR* szServiceName, const TCHAR* szDisplayName, const int iMajorVersion, const int iMinorVersion) :CNTService(szServiceName, szDisplayName, iMajorVersion, iMinorVersion) { m_iStartParam = 0; m_iIncParam = 1; m_iState = m_iStartParam; } BOOL CMainService::OnInit() { // Read the registry parameters // Try opening the registry key: // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<AppName>\Parameters HKEY hkey; TCHAR szKey[1024]; _tcscpy(szKey, _T("SYSTEM\\CurrentControlSet\\Services\\")); _tcscat(szKey, m_szServiceName); _tcscat(szKey, _T("\\Parameters")); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) { // Yes we are installed DWORD dwType = 0; DWORD dwSize = sizeof(m_iStartParam); RegQueryValueEx(hkey, _T("Start"), NULL, &dwType, (BYTE*)&m_iStartParam, &dwSize); dwSize = sizeof(m_iIncParam); RegQueryValueEx(hkey, _T("Inc"), NULL, &dwType, (BYTE*)&m_iIncParam, &dwSize); RegCloseKey(hkey); } // Set the initial state m_iState = m_iStartParam; return TRUE; } void CMainService::Run() { m_dwThreadId = GetCurrentThreadId(); if(FALSE == m_MainServer.Initialize()){ UwlTrace(_T("server initialize failed!")); PostQuitMessage(0); } MSG msg; while (GetMessage(&msg, 0, 0, 0)){ DispatchMessage(&msg); } m_MainServer.Shutdown(); // wait for a while UwlTrace(_T("service is sleeping to finish(%lu)..."), m_iState); Sleep(dwWaitFinished); //wait for any threads to finish // Update the current state m_iState += m_iIncParam; } // Called when the service control manager wants to stop the service void CMainService::OnStop() { UwlTrace(_T("CMainService::OnStop()")); PostThreadMessage(m_dwThreadId, WM_QUIT, 0, 0); } // Process user control requests BOOL CMainService::OnUserControl(DWORD dwOpcode) { switch (dwOpcode) { case SERVICE_CONTROL_USER + 0: // Save the current status in the registry SaveStatus(); return TRUE; default: break; } return FALSE; // say not handled } // Save the current status in the registry void CMainService::SaveStatus() { UwlTrace(_T("Saving current status")); // Try opening the registry key: // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<AppName>\... HKEY hkey = NULL; TCHAR szKey[1024]; _tcscpy(szKey, _T("SYSTEM\\CurrentControlSet\\Services\\")); _tcscat(szKey, m_szServiceName); _tcscat(szKey, _T("\\Status")); DWORD dwDisp; DWORD dwErr; UwlTrace(_T("Creating key: %s"), szKey); dwErr = RegCreateKeyEx( HKEY_LOCAL_MACHINE, szKey, 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, &dwDisp); if (dwErr != ERROR_SUCCESS) { UwlTrace(_T("Failed to create Status key (%lu)"), dwErr); return; } // Set the registry values UwlTrace(_T("Saving 'Current' as %ld"), m_iState); RegSetValueEx(hkey, _T("Current"), 0, REG_DWORD, (BYTE*)&m_iState, sizeof(m_iState)); // Finished with key RegCloseKey(hkey); }
842c9340bd42a2e57bca8c2269910b38152683f8
3a4dd02d19b35f2e402e06891906e44942823416
/archive/2021s/solutions/ScribbleRoads.cpp
1cf0a4862ca942632780d48f4e1c8097bc788499
[]
no_license
mbhs/mbit
cbd2d4478447df0afccc118f28c55a224628014e
c9264cd8e526411f746ff526b4f6464ac80bc64e
refs/heads/master
2022-06-19T00:20:40.369880
2022-05-28T00:00:00
2022-05-28T00:00:00
192,783,606
1
2
null
2019-11-02T03:25:03
2019-06-19T18:21:22
CSS
UTF-8
C++
false
false
2,591
cpp
ScribbleRoads.cpp
#include <bits/stdc++.h> using namespace std; struct DSU { vector<int> e; void init(int n) { e = vector<int>(n, -1); } int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); } bool same_set(int a, int b) { return get(a) == get(b); } int size(int x) { return -e[get(x)]; } bool unite(int x, int y) { x = get(x); y = get(y); if (x == y) { return false; } if (e[x] > e[y]) { std::swap(x, y); } e[x] += e[y]; e[y] = x; return true; } }; const int N = 1e5 + 5; const int L = 10; int dp[L][N][2]; int solve(int e, int o, int p) { if (e >= L) { return p ^ ((o % 4) / 2); } auto& res = dp[e][o][p]; if (e + o == 1) { res = 0; return res; } if (res != -1) { return res; } if (p) { int t = solve(e, o, p ^ 1); if (t == 0) { res = 1; return res; } } if (e && o) { int t = solve(e - 1, o, p ^ 1); if (t == 0) { res = 1; return res; } } if (e >= 2) { int t = solve(e - 1, o, p ^ 1); if (t == 0) { res = 1; return res; } } if (o >= 2) { int t = solve(e + 1, o - 2, p); if (t == 0) { res = 1; return res; } } res = 0; return res; } void solve_case(int tc = 0) { int n, m; cin >> n >> m; vector<vector<int>> g(n); DSU D; D.init(n); for (int i = 0; i < m; ++i) { int u, v; cin >> u >> v; --u, --v; g[u].push_back(v); g[v].push_back(u); D.unite(u, v); } vector<int> comps; for (int i = 0; i < n; ++i) { comps.push_back(D.get(i)); } sort(comps.begin(), comps.end()); comps.erase(unique(comps.begin(), comps.end()), comps.end()); auto get_pos = [&](int x) -> int { return lower_bound(comps.begin(), comps.end(), x) - comps.begin(); }; int sz = comps.size(); vector<int> amt(sz); for (int i = 0; i < sz; ++i) { amt[i] = D.size(comps[i]); } int p = 0; long long dead = -m; for (auto& c : comps) { long long sz = D.size(c); dead += sz * (sz - 1) / 2; } p = dead % 2; int e = 0; int o = 0; for (int i = 0; i < sz; ++i) { if (amt[i] % 2 == 0) { ++e; } else { ++o; } } int ans = solve(e, o, p); if (ans == 0) { cout << "LOSE" << '\n'; } else { cout << "WIN" << '\n'; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); for (int i = 0; i < L; ++i) { for (int j = 0; j < N; ++j) { for (int k = 0; k < 2; ++k) { dp[i][j][k] = -1; } } } int tt; cin >> tt; for (int tc = 1; tc <= tt; tc++) { solve_case(tc); } return 0; }
0033549cc5d8452b1d378c2b04d54e951a1f7698
471126f2f0c9c139e55f0fcbabe9ebf9b444bae4
/Arma 3/@PUBattleRoyale/addons/br_code/config.cpp
1fd5d404eac295d2ee7beef900bc2330c2407fc8
[]
no_license
KiwiBear/DayZBattleRoyale
d1532c37571c7df92e0d49e835d00a5a08e0b96e
70d55b7c8fa551aa5ac7233b5f5b85e95e79c5f9
refs/heads/master
2021-01-20T08:34:10.907196
2014-05-16T19:03:00
2014-05-16T19:05:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
379
cpp
config.cpp
class CfgPatches { class br_code { units[] = {}; weapons[] = {}; requiredVersion = 0.1; requiredAddons[] = {}; }; }; class CfgMods { class BattleRoyale { dir = "PUBattleRoyale"; name = "Arma 3: Battle Royale Alpha"; picture = "\br_code\screen\mod.paa"; hidePicture = 0; hideName = 0; action = "http://www.dayzbattleroyale.com"; version = "0.1.8"; }; };
5c592c77be814dd188a11bbc44cea57a8ab9e414
31965d3125b23e955a45230b89e17a8bb96377e5
/moon/moon/logic/doer/playerData.cpp
03f0eebeeadb6b3948b1e956ce1ea443797b04b7
[]
no_license
jiyahan/moon
18e5a955c66fbb7251d6b7d67159bdf7c13d99a9
363072cdf3c3d0378b41a0c3237f4e604c7572ab
refs/heads/master
2021-06-04T21:26:13.436132
2016-05-10T06:41:35
2016-05-10T06:41:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,356
cpp
playerData.cpp
#include "StdAfx.h" using namespace moon; using namespace common::SystemId; bool CPlayer::loadData(CDataPacketReader &data) { if (m_boIsNewPlayer) { PlayerId charId; LPCSTR sCharName; WORD wLevel; BYTE btGender; data >> charId; data >> sCharName; data >> wLevel; data >> m_btJob; data >> btGender; m_nCreateTime = g_LogicEngine->getDateTime(); m_btGender = btGender; m_nLevel = 1; m_nExp = 0; m_Abil.m_nHP = INT_MAX - 1;//在重新计算属性时会设置正确值 m_Abil.m_nMP = INT_MAX - 1;//在重新计算属性时会设置正确值 gotoBornScene();//出生场景ID坐标 return true; } common::DBType::DataSectionHeader *pSecHdr; common::DBType::PlayerBasicData *pBaseData; //读取角色基本数据 if (data.getAvaliableLength() < sizeof(*pSecHdr) + sizeof(*pBaseData)) return false; pSecHdr = (common::DBType::DataSectionHeader*)data.getOffsetPtr(); data.adjustOffset(sizeof(*pSecHdr)); if (pSecHdr->wDataType != common::SystemId::sysPlayer) { logError( "角色(%lld:%s)数据的起始数据类型错误", m_EntityId.llid, m_sName); return false; } pBaseData = (common::DBType::PlayerBasicData*)data.getOffsetPtr(); data.adjustOffset(sizeof(*pBaseData)); m_nCreateTime = pBaseData->nCreateDateTime; m_nLevel = pBaseData->wLevel; m_nExp = pBaseData->nExp; m_GuildId = pBaseData->guildId; m_nCoin = pBaseData->nCoin; m_nGameGold = pBaseData->nGameGold; m_DearId = pBaseData->dearId; m_btGender = pBaseData->btGender; m_btJob = pBaseData->btJob; m_Abil.m_nHP = pBaseData->nHP; m_Abil.m_nMP = pBaseData->nMP; m_Bag.m_btBagCurSize = pBaseData->btCurBagSize; _asncpytA(m_sDearName, pBaseData->sDearName); //初始化放入地图 Scene *scene = g_staticSceneManager->getSceneByID(pBaseData->m_StaticPosition.nSceneId); if (scene) setScene(scene, pBaseData->m_StaticPosition.nMapX,pBaseData->m_StaticPosition.nMapY); else gotoBornScene(); //读取各系统数据 CDoerUnit *pActorModule; while (data.getAvaliableLength() > 0) { if (data.getAvaliableLength() < sizeof(*pSecHdr)) return false; pSecHdr = (common::DBType::DataSectionHeader*)data.getOffsetPtr(); size_t dwSecEndPos = data.getPosition() + sizeof(*pSecHdr) + pSecHdr->wDataCount * pSecHdr->wStructSize; pActorModule = getModule(pSecHdr->wDataType); if (pActorModule) { if (!pActorModule->loadData(data)) return false; assert(dwSecEndPos == data.getPosition()); } else { logError( "角色(%lld:%s)数据中的数据类型%d为未知类型", m_EntityId.llid, m_sName, pSecHdr->wDataType); return false; } } return true; } void CPlayer::saveData(CDataPacket &data) { //记录玩家动态副本位置 recordDynamicScenePosition(); /**** 保存角色基本数据 ****/ common::DBType::DataSectionHeader *pSecHdr; common::DBType::PlayerBasicData *pBaseData; //保留基本数据空间 data.reserve(data.getPosition() + sizeof(*pSecHdr) + sizeof(*pBaseData)); //写入角色基础数据头 pSecHdr = (common::DBType::DataSectionHeader*)data.getOffsetPtr(); data.adjustOffset(sizeof(*pSecHdr)); pSecHdr->wDataType = common::SystemId::sysPlayer; pSecHdr->wDataVersion = common::DBType::PlayerDataVersion; pSecHdr->wStructSize = sizeof(*pBaseData); pSecHdr->wDataCount = 1; //写入角色基础数据 pBaseData = (common::DBType::PlayerBasicData*)data.getOffsetPtr(); data.adjustOffset(sizeof(*pBaseData)); ZeroMemory(pBaseData, sizeof(*pBaseData)); pBaseData->charId = m_EntityId; _asncpytA(pBaseData->sCharName, m_sName); pBaseData->nAccountId = m_nAccountId; _asncpytA(pBaseData->sAccount, m_sAccount); pBaseData->nCreateDateTime = m_nCreateTime; pBaseData->wLevel = m_nLevel; pBaseData->nExp = m_nExp; pBaseData->nCoin = m_nCoin; pBaseData->nGameGold = m_nGameGold; pBaseData->guildId = m_GuildId; pBaseData->dearId = m_DearId; _asncpytA(pBaseData->sDearName, m_sDearName); pBaseData->btJob = m_btJob; pBaseData->btGender = m_btGender; pBaseData->m_StaticPosition = m_StaticPosition; pBaseData->m_DynamicPosition = m_DynamicPosition; pBaseData->nHP = m_Abil.m_nHP; pBaseData->nMP = m_Abil.m_nMP; pBaseData->btCurBagSize = m_Bag.m_btBagCurSize; //写入各系统数据 CDoerUnit *pActorModule; for (int i=1; i<sysCount; ++i) { pActorModule = getModule(i); if (pActorModule) { pActorModule->saveData(data); } } }
15955caf6a286b6060977d7390a6bb1a959524a1
03f037d0f6371856ede958f0c9d02771d5402baf
/graphics/VTK-7.0.0/Interaction/Widgets/Testing/Cxx/TestPlaneWidget.cxx
ea0e2586927fb045fc1867d82dae1a27389622ae
[ "BSD-3-Clause" ]
permissive
hlzz/dotfiles
b22dc2dc5a9086353ed6dfeee884f7f0a9ddb1eb
0591f71230c919c827ba569099eb3b75897e163e
refs/heads/master
2021-01-10T10:06:31.018179
2016-09-27T08:13:18
2016-09-27T08:13:18
55,040,954
4
0
null
null
null
null
UTF-8
C++
false
false
19,496
cxx
TestPlaneWidget.cxx
/*========================================================================= Program: Visualization Toolkit Module: TestPlaneWidget.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkSmartPointer.h" #include "vtkActor.h" #include "vtkCommand.h" #include "vtkConeSource.h" #include "vtkGlyph3D.h" #include "vtkInteractorEventRecorder.h" #include "vtkMultiBlockDataSet.h" #include "vtkMultiBlockPLOT3DReader.h" #include "vtkPlaneWidget.h" #include "vtkPolyData.h" #include "vtkPolyDataMapper.h" #include "vtkProbeFilter.h" #include "vtkProperty.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h" #include "vtkStructuredGrid.h" #include "vtkStructuredGridOutlineFilter.h" #include "vtkTestUtilities.h" const char TPWeventLog[] = "# StreamVersion 1\n" "CharEvent 192 232 0 0 105 1 i\n" "KeyReleaseEvent 192 230 0 0 105 1 i\n" "MouseMoveEvent 192 229 0 0 0 0 i\n" "MouseMoveEvent 192 228 0 0 0 0 i\n" "MouseMoveEvent 193 228 0 0 0 0 i\n" "MouseMoveEvent 194 227 0 0 0 0 i\n" "MouseMoveEvent 195 225 0 0 0 0 i\n" "MouseMoveEvent 196 220 0 0 0 0 i\n" "MouseMoveEvent 196 215 0 0 0 0 i\n" "MouseMoveEvent 196 206 0 0 0 0 i\n" "MouseMoveEvent 198 197 0 0 0 0 i\n" "MouseMoveEvent 198 190 0 0 0 0 i\n" "MouseMoveEvent 198 185 0 0 0 0 i\n" "MouseMoveEvent 199 178 0 0 0 0 i\n" "MouseMoveEvent 199 173 0 0 0 0 i\n" "MouseMoveEvent 198 168 0 0 0 0 i\n" "MouseMoveEvent 196 163 0 0 0 0 i\n" "MouseMoveEvent 196 159 0 0 0 0 i\n" "MouseMoveEvent 196 156 0 0 0 0 i\n" "MouseMoveEvent 195 151 0 0 0 0 i\n" "MouseMoveEvent 192 145 0 0 0 0 i\n" "MouseMoveEvent 187 142 0 0 0 0 i\n" "MouseMoveEvent 185 141 0 0 0 0 i\n" "MouseMoveEvent 181 139 0 0 0 0 i\n" "MouseMoveEvent 179 139 0 0 0 0 i\n" "MouseMoveEvent 177 138 0 0 0 0 i\n" "MouseMoveEvent 173 138 0 0 0 0 i\n" "MouseMoveEvent 171 138 0 0 0 0 i\n" "MouseMoveEvent 170 137 0 0 0 0 i\n" "MouseMoveEvent 170 138 0 0 0 0 i\n" "MouseMoveEvent 170 139 0 0 0 0 i\n" "MouseMoveEvent 170 142 0 0 0 0 i\n" "MouseMoveEvent 170 144 0 0 0 0 i\n" "MouseMoveEvent 163 147 0 0 0 0 i\n" "MouseMoveEvent 159 149 0 0 0 0 i\n" "MouseMoveEvent 155 149 0 0 0 0 i\n" "MouseMoveEvent 151 153 0 0 0 0 i\n" "MouseMoveEvent 150 154 0 0 0 0 i\n" "MouseMoveEvent 147 155 0 0 0 0 i\n" "MouseMoveEvent 146 158 0 0 0 0 i\n" "MouseMoveEvent 146 160 0 0 0 0 i\n" "MouseMoveEvent 146 161 0 0 0 0 i\n" "MouseMoveEvent 146 163 0 0 0 0 i\n" "MouseMoveEvent 146 164 0 0 0 0 i\n" "MouseMoveEvent 146 167 0 0 0 0 i\n" "MouseMoveEvent 146 171 0 0 0 0 i\n" "MouseMoveEvent 146 172 0 0 0 0 i\n" "MouseMoveEvent 146 173 0 0 0 0 i\n" "MouseMoveEvent 147 173 0 0 0 0 i\n" "MouseMoveEvent 147 172 0 0 0 0 i\n" "MouseMoveEvent 148 169 0 0 0 0 i\n" "MouseMoveEvent 149 167 0 0 0 0 i\n" "MouseMoveEvent 151 163 0 0 0 0 i\n" "MouseMoveEvent 153 158 0 0 0 0 i\n" "MouseMoveEvent 156 154 0 0 0 0 i\n" "MouseMoveEvent 161 150 0 0 0 0 i\n" "MouseMoveEvent 162 148 0 0 0 0 i\n" "MouseMoveEvent 163 147 0 0 0 0 i\n" "MouseMoveEvent 164 146 0 0 0 0 i\n" "MouseMoveEvent 165 145 0 0 0 0 i\n" "MouseMoveEvent 166 145 0 0 0 0 i\n" "MouseMoveEvent 167 146 0 0 0 0 i\n" "MouseMoveEvent 168 146 0 0 0 0 i\n" "MouseMoveEvent 169 146 0 0 0 0 i\n" "MouseMoveEvent 169 147 0 0 0 0 i\n" "MouseMoveEvent 170 147 0 0 0 0 i\n" "MouseMoveEvent 170 148 0 0 0 0 i\n" "MouseMoveEvent 170 149 0 0 0 0 i\n" "MouseMoveEvent 171 149 0 0 0 0 i\n" "MouseMoveEvent 171 150 0 0 0 0 i\n" "MouseMoveEvent 172 150 0 0 0 0 i\n" "MouseMoveEvent 172 151 0 0 0 0 i\n" "MouseMoveEvent 173 151 0 0 0 0 i\n" "MouseMoveEvent 174 151 0 0 0 0 i\n" "MouseMoveEvent 175 151 0 0 0 0 i\n" "MouseMoveEvent 177 151 0 0 0 0 i\n" "MouseMoveEvent 178 151 0 0 0 0 i\n" "MouseMoveEvent 179 151 0 0 0 0 i\n" "LeftButtonPressEvent 179 151 0 0 0 0 i\n" "MouseMoveEvent 179 152 0 0 0 0 i\n" "MouseMoveEvent 178 153 0 0 0 0 i\n" "MouseMoveEvent 177 154 0 0 0 0 i\n" "MouseMoveEvent 176 155 0 0 0 0 i\n" "MouseMoveEvent 175 156 0 0 0 0 i\n" "MouseMoveEvent 172 156 0 0 0 0 i\n" "MouseMoveEvent 167 157 0 0 0 0 i\n" "MouseMoveEvent 163 157 0 0 0 0 i\n" "MouseMoveEvent 160 158 0 0 0 0 i\n" "MouseMoveEvent 159 158 0 0 0 0 i\n" "MouseMoveEvent 158 159 0 0 0 0 i\n" "MouseMoveEvent 155 162 0 0 0 0 i\n" "MouseMoveEvent 153 165 0 0 0 0 i\n" "MouseMoveEvent 153 167 0 0 0 0 i\n" "MouseMoveEvent 151 168 0 0 0 0 i\n" "MouseMoveEvent 148 170 0 0 0 0 i\n" "MouseMoveEvent 146 170 0 0 0 0 i\n" "MouseMoveEvent 142 172 0 0 0 0 i\n" "MouseMoveEvent 140 172 0 0 0 0 i\n" "MouseMoveEvent 139 173 0 0 0 0 i\n" "MouseMoveEvent 138 174 0 0 0 0 i\n" "MouseMoveEvent 137 176 0 0 0 0 i\n" "MouseMoveEvent 133 177 0 0 0 0 i\n" "MouseMoveEvent 129 178 0 0 0 0 i\n" "MouseMoveEvent 128 179 0 0 0 0 i\n" "MouseMoveEvent 127 179 0 0 0 0 i\n" "MouseMoveEvent 122 179 0 0 0 0 i\n" "MouseMoveEvent 115 179 0 0 0 0 i\n" "MouseMoveEvent 114 179 0 0 0 0 i\n" "MouseMoveEvent 113 179 0 0 0 0 i\n" "LeftButtonReleaseEvent 113 179 0 0 0 0 i\n" "MouseMoveEvent 113 179 0 0 0 0 i\n" "MouseMoveEvent 113 178 0 0 0 0 i\n" "MouseMoveEvent 114 178 0 0 0 0 i\n" "MouseMoveEvent 115 178 0 0 0 0 i\n" "MouseMoveEvent 116 177 0 0 0 0 i\n" "MouseMoveEvent 117 177 0 0 0 0 i\n" "MouseMoveEvent 118 177 0 0 0 0 i\n" "MouseMoveEvent 120 176 0 0 0 0 i\n" "MouseMoveEvent 121 176 0 0 0 0 i\n" "MouseMoveEvent 124 174 0 0 0 0 i\n" "MouseMoveEvent 128 174 0 0 0 0 i\n" "MouseMoveEvent 133 174 0 0 0 0 i\n" "MouseMoveEvent 138 173 0 0 0 0 i\n" "MouseMoveEvent 141 173 0 0 0 0 i\n" "MouseMoveEvent 144 171 0 0 0 0 i\n" "MouseMoveEvent 147 169 0 0 0 0 i\n" "MouseMoveEvent 153 168 0 0 0 0 i\n" "MouseMoveEvent 156 168 0 0 0 0 i\n" "MouseMoveEvent 159 168 0 0 0 0 i\n" "MouseMoveEvent 160 168 0 0 0 0 i\n" "MouseMoveEvent 160 169 0 0 0 0 i\n" "MouseMoveEvent 159 169 0 0 0 0 i\n" "MouseMoveEvent 157 171 0 0 0 0 i\n" "MouseMoveEvent 153 173 0 0 0 0 i\n" "MouseMoveEvent 152 174 0 0 0 0 i\n" "MouseMoveEvent 151 174 0 0 0 0 i\n" "MouseMoveEvent 150 175 0 0 0 0 i\n" "MouseMoveEvent 149 175 0 0 0 0 i\n" "MouseMoveEvent 149 176 0 0 0 0 i\n" "MouseMoveEvent 148 176 0 0 0 0 i\n" "MouseMoveEvent 148 177 0 0 0 0 i\n" "MouseMoveEvent 147 177 0 0 0 0 i\n" "MouseMoveEvent 147 178 0 0 0 0 i\n" "MouseMoveEvent 146 179 0 0 0 0 i\n" "MouseMoveEvent 144 180 0 0 0 0 i\n" "MouseMoveEvent 141 180 0 0 0 0 i\n" "MouseMoveEvent 139 182 0 0 0 0 i\n" "MouseMoveEvent 138 183 0 0 0 0 i\n" "MouseMoveEvent 137 183 0 0 0 0 i\n" "MouseMoveEvent 137 184 0 0 0 0 i\n" "MouseMoveEvent 136 184 0 0 0 0 i\n" "MouseMoveEvent 136 185 0 0 0 0 i\n" "MouseMoveEvent 136 186 0 0 0 0 i\n" "MouseMoveEvent 135 186 0 0 0 0 i\n" "MouseMoveEvent 135 187 0 0 0 0 i\n" "MouseMoveEvent 135 188 0 0 0 0 i\n" "MouseMoveEvent 134 189 0 0 0 0 i\n" "MouseMoveEvent 133 189 0 0 0 0 i\n" "MouseMoveEvent 132 189 0 0 0 0 i\n" "LeftButtonPressEvent 132 189 0 0 0 0 i\n" "MouseMoveEvent 132 188 0 0 0 0 i\n" "MouseMoveEvent 132 186 0 0 0 0 i\n" "MouseMoveEvent 132 184 0 0 0 0 i\n" "MouseMoveEvent 132 182 0 0 0 0 i\n" "MouseMoveEvent 132 181 0 0 0 0 i\n" "MouseMoveEvent 132 179 0 0 0 0 i\n" "MouseMoveEvent 132 176 0 0 0 0 i\n" "MouseMoveEvent 133 175 0 0 0 0 i\n" "MouseMoveEvent 134 174 0 0 0 0 i\n" "MouseMoveEvent 134 172 0 0 0 0 i\n" "MouseMoveEvent 134 171 0 0 0 0 i\n" "MouseMoveEvent 135 168 0 0 0 0 i\n" "MouseMoveEvent 135 167 0 0 0 0 i\n" "LeftButtonReleaseEvent 135 167 0 0 0 0 i\n" "MouseMoveEvent 135 167 0 0 0 0 i\n" "MouseMoveEvent 136 166 0 0 0 0 i\n" "MouseMoveEvent 136 165 0 0 0 0 i\n" "MouseMoveEvent 136 164 0 0 0 0 i\n" "MouseMoveEvent 136 163 0 0 0 0 i\n" "MouseMoveEvent 136 162 0 0 0 0 i\n" "MouseMoveEvent 135 162 0 0 0 0 i\n" "MouseMoveEvent 134 162 0 0 0 0 i\n" "MouseMoveEvent 133 161 0 0 0 0 i\n" "RightButtonPressEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "TimerEvent 133 161 0 0 0 0 i\n" "MouseMoveEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "TimerEvent 133 160 0 0 0 0 i\n" "MouseMoveEvent 132 160 0 0 0 0 i\n" "TimerEvent 132 160 0 0 0 0 i\n" "MouseMoveEvent 132 159 0 0 0 0 i\n" "TimerEvent 132 159 0 0 0 0 i\n" "MouseMoveEvent 131 159 0 0 0 0 i\n" "RightButtonReleaseEvent 131 159 0 0 0 0 i\n" "MouseMoveEvent 131 159 0 0 0 0 i\n" "MouseMoveEvent 131 158 0 0 0 0 i\n" "MouseMoveEvent 131 155 0 0 0 0 i\n" "MouseMoveEvent 132 154 0 0 0 0 i\n" "MouseMoveEvent 132 152 0 0 0 0 i\n" "MouseMoveEvent 132 151 0 0 0 0 i\n" "MouseMoveEvent 133 150 0 0 0 0 i\n" "MouseMoveEvent 134 150 0 0 0 0 i\n" "RightButtonPressEvent 134 150 0 0 0 0 i\n" "MouseMoveEvent 134 149 0 0 0 0 i\n" "MouseMoveEvent 134 148 0 0 0 0 i\n" "MouseMoveEvent 134 149 0 0 0 0 i\n" "MouseMoveEvent 133 150 0 0 0 0 i\n" "MouseMoveEvent 131 151 0 0 0 0 i\n" "MouseMoveEvent 131 152 0 0 0 0 i\n" "MouseMoveEvent 131 153 0 0 0 0 i\n" "MouseMoveEvent 131 154 0 0 0 0 i\n" "MouseMoveEvent 130 157 0 0 0 0 i\n" "MouseMoveEvent 129 160 0 0 0 0 i\n" "MouseMoveEvent 129 161 0 0 0 0 i\n" "MouseMoveEvent 128 164 0 0 0 0 i\n" "MouseMoveEvent 125 167 0 0 0 0 i\n" "MouseMoveEvent 122 171 0 0 0 0 i\n" "MouseMoveEvent 122 173 0 0 0 0 i\n" "MouseMoveEvent 121 173 0 0 0 0 i\n" "MouseMoveEvent 121 175 0 0 0 0 i\n" "MouseMoveEvent 121 178 0 0 0 0 i\n" "MouseMoveEvent 121 179 0 0 0 0 i\n" "MouseMoveEvent 120 179 0 0 0 0 i\n" "MouseMoveEvent 120 181 0 0 0 0 i\n" "MouseMoveEvent 119 183 0 0 0 0 i\n" "MouseMoveEvent 118 185 0 0 0 0 i\n" "MouseMoveEvent 118 186 0 0 0 0 i\n" "MouseMoveEvent 117 187 0 0 0 0 i\n" "MouseMoveEvent 116 189 0 0 0 0 i\n" "MouseMoveEvent 113 190 0 0 0 0 i\n" "MouseMoveEvent 113 191 0 0 0 0 i\n" "MouseMoveEvent 113 190 0 0 0 0 i\n" "MouseMoveEvent 113 189 0 0 0 0 i\n" "RightButtonReleaseEvent 113 189 0 0 0 0 i\n" "MouseMoveEvent 112 189 0 0 0 0 i\n" "MouseMoveEvent 112 188 0 0 0 0 i\n" "MouseMoveEvent 112 187 0 0 0 0 i\n" "MouseMoveEvent 113 186 0 0 0 0 i\n" "MouseMoveEvent 114 185 0 0 0 0 i\n" "MouseMoveEvent 115 184 0 0 0 0 i\n" "MouseMoveEvent 116 183 0 0 0 0 i\n" "MouseMoveEvent 116 182 0 0 0 0 i\n" "MouseMoveEvent 117 181 0 0 0 0 i\n" "MouseMoveEvent 117 180 0 0 0 0 i\n" "MouseMoveEvent 118 179 0 0 0 0 i\n" "MouseMoveEvent 119 179 0 0 0 0 i\n" "MouseMoveEvent 120 178 0 0 0 0 i\n" "MouseMoveEvent 120 176 0 0 0 0 i\n" "MouseMoveEvent 120 174 0 0 0 0 i\n" "MouseMoveEvent 120 173 0 0 0 0 i\n" "MouseMoveEvent 120 172 0 0 0 0 i\n" "MiddleButtonPressEvent 120 172 0 0 0 0 i\n" "MouseMoveEvent 120 171 0 0 0 0 i\n" "MouseMoveEvent 121 166 0 0 0 0 i\n" "MouseMoveEvent 123 165 0 0 0 0 i\n" "MouseMoveEvent 125 165 0 0 0 0 i\n" "MouseMoveEvent 126 166 0 0 0 0 i\n" "MouseMoveEvent 129 167 0 0 0 0 i\n" "MouseMoveEvent 130 167 0 0 0 0 i\n" "MouseMoveEvent 133 169 0 0 0 0 i\n" "MouseMoveEvent 135 169 0 0 0 0 i\n" "MouseMoveEvent 136 169 0 0 0 0 i\n" "MouseMoveEvent 137 168 0 0 0 0 i\n" "MouseMoveEvent 139 169 0 0 0 0 i\n" "MouseMoveEvent 148 168 0 0 0 0 i\n" "MouseMoveEvent 158 165 0 0 0 0 i\n" "MouseMoveEvent 159 165 0 0 0 0 i\n" "MouseMoveEvent 163 165 0 0 0 0 i\n" "MouseMoveEvent 164 164 0 0 0 0 i\n" "MouseMoveEvent 165 164 0 0 0 0 i\n" "MouseMoveEvent 167 163 0 0 0 0 i\n" "MouseMoveEvent 168 163 0 0 0 0 i\n" "MouseMoveEvent 174 162 0 0 0 0 i\n" "MouseMoveEvent 178 161 0 0 0 0 i\n" "MouseMoveEvent 179 161 0 0 0 0 i\n" "MouseMoveEvent 180 161 0 0 0 0 i\n" "MouseMoveEvent 181 161 0 0 0 0 i\n" "MouseMoveEvent 183 161 0 0 0 0 i\n" "MouseMoveEvent 183 160 0 0 0 0 i\n" "MouseMoveEvent 182 159 0 0 0 0 i\n" "MiddleButtonReleaseEvent 182 159 0 0 0 0 i\n" "MouseMoveEvent 181 158 0 0 0 0 i\n" "MouseMoveEvent 180 158 0 0 0 0 i\n" "MouseMoveEvent 179 158 0 0 0 0 i\n" ; // This does the actual work: updates the probe. // Callback for the interaction class vtkTPWCallback : public vtkCommand { public: static vtkTPWCallback *New() { return new vtkTPWCallback; } virtual void Execute(vtkObject *caller, unsigned long, void*) { vtkPlaneWidget *planeWidget = reinterpret_cast<vtkPlaneWidget*>(caller); planeWidget->GetPolyData(this->PolyData); this->Actor->VisibilityOn(); } vtkTPWCallback():PolyData(0),Actor(0) {} vtkPolyData *PolyData; vtkActor *Actor; }; int TestPlaneWidget( int argc, char *argv[] ) { char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/combxyz.bin"); char* fname2 = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/combq.bin"); // Start by loading some data. // vtkSmartPointer<vtkMultiBlockPLOT3DReader> pl3d = vtkSmartPointer<vtkMultiBlockPLOT3DReader>::New(); pl3d->SetXYZFileName(fname); pl3d->SetQFileName(fname2); pl3d->SetScalarFunctionNumber(100); pl3d->SetVectorFunctionNumber(202); pl3d->Update(); vtkDataSet* pl3d_block0 = vtkDataSet::SafeDownCast(pl3d->GetOutput()->GetBlock(0)); delete [] fname; delete [] fname2; vtkSmartPointer<vtkPolyData> plane = vtkSmartPointer<vtkPolyData>::New(); vtkSmartPointer<vtkProbeFilter> probe = vtkSmartPointer<vtkProbeFilter>::New(); probe->SetInputData(plane); probe->SetSourceData(pl3d_block0); vtkSmartPointer<vtkPolyDataMapper> probeMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); probeMapper->SetInputConnection(probe->GetOutputPort()); double tmp[2]; pl3d_block0->GetScalarRange(tmp); probeMapper->SetScalarRange(tmp[0], tmp[1]); vtkSmartPointer<vtkActor> probeActor = vtkSmartPointer<vtkActor>::New(); probeActor->SetMapper(probeMapper); probeActor->VisibilityOff(); // An outline is shown for context. vtkSmartPointer<vtkStructuredGridOutlineFilter> outline = vtkSmartPointer<vtkStructuredGridOutlineFilter>::New(); outline->SetInputData(pl3d_block0); vtkSmartPointer<vtkPolyDataMapper> outlineMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); outlineMapper->SetInputConnection(outline->GetOutputPort()); vtkSmartPointer<vtkActor> outlineActor = vtkSmartPointer<vtkActor>::New(); outlineActor->SetMapper(outlineMapper); // Create the RenderWindow, Renderer and both Actors // vtkSmartPointer<vtkRenderer> ren1 = vtkSmartPointer<vtkRenderer>::New(); vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New(); renWin->AddRenderer(ren1); vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New(); iren->SetRenderWindow(renWin); // The SetInteractor method is how 3D widgets are associated with the render // window interactor. Internally, SetInteractor sets up a bunch of callbacks // using the Command/Observer mechanism (AddObserver()). vtkSmartPointer<vtkTPWCallback> myCallback = vtkSmartPointer<vtkTPWCallback>::New(); myCallback->PolyData = plane; myCallback->Actor = probeActor; // The plane widget is used probe the dataset. // vtkSmartPointer<vtkPlaneWidget> planeWidget = vtkSmartPointer<vtkPlaneWidget>::New(); planeWidget->SetInteractor(iren); planeWidget->SetInputData(pl3d_block0); planeWidget->NormalToXAxisOn(); planeWidget->SetResolution(20); planeWidget->SetRepresentationToOutline(); planeWidget->PlaceWidget(); planeWidget->AddObserver(vtkCommand::InteractionEvent,myCallback); ren1->AddActor(probeActor); ren1->AddActor(outlineActor); // Add the actors to the renderer, set the background and size // ren1->SetBackground(0.1, 0.2, 0.4); renWin->SetSize(300, 300); // record events vtkSmartPointer<vtkInteractorEventRecorder> recorder = vtkSmartPointer<vtkInteractorEventRecorder>::New(); recorder->SetInteractor(iren); // recorder->SetFileName("c:/record.log"); // recorder->Record(); recorder->ReadFromInputStringOn(); recorder->SetInputString(TPWeventLog); // render the image // renWin->SetMultiSamples(0); iren->Initialize(); renWin->Render(); recorder->Play(); // Remove the observers so we can go interactive. Without this the "-I" // testing option fails. recorder->Off(); iren->Start(); return EXIT_SUCCESS; }
a208ea5dee92f4d070c5040f8a7d750a9ea3279a
e1951b7f7a739b96e961797f8849e58dcb41f00d
/falcon/functional/operators.hpp
85571c60ed50e445254669073d3f1e210013ec40
[ "MIT" ]
permissive
jonathanpoelen/falcon
fcf2a92441bb2a7fc0c025ff25a197d24611da71
5b60a39787eedf15b801d83384193a05efd41a89
refs/heads/master
2021-01-17T10:21:17.492484
2016-03-27T23:28:50
2016-03-27T23:28:50
6,459,776
2
0
null
null
null
null
UTF-8
C++
false
false
15,266
hpp
operators.hpp
#ifndef FALCON_FUNCTIONAL_OPERATORS_HPP #define FALCON_FUNCTIONAL_OPERATORS_HPP #include <falcon/c++1x/syntax.hpp> #include <falcon/type_traits/default_or_type.hpp> #include <falcon/type_traits/internal_reference.hpp> #include <falcon/functional/is_transparent_inheritance.hpp> #include <utility> #include <type_traits> #if __cplusplus > 201103L # include <functional> #endif namespace falcon { namespace aux_ { struct is_transparent_t; } /** * Arithmetic operations * @{ */ #if __cplusplus > 201103L template<class T = void> using plus = std::plus<T>; template<class T = void> using minus = std::minus<T>; template<class T = void> using multiplies = std::multiplies<T>; template<class T = void> using divides = std::divides<T>; template<class T = void> using modulus = std::modulus<T>; #else template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct modulus; template<class T = void> struct divides; #endif template<class T = void> struct plus_equal; template<class T = void> struct minus_equal; template<class T = void> struct multiplies_equal; template<class T = void> struct modulus_equal; template<class T = void> struct divides_equal; template<class T = void> struct increment; template<class T = void> struct decrement; template<class T = void> struct post_increment; template<class T = void> struct post_decrement; /// \brief T += 1 template<class T = void> struct increment2; /// \brief T -= 1 template<class T = void> struct decrement2; /// \brief T = static_cast< T>(T + 1) template<class T = void> struct increment3; /// \brief T = static_cast< T>(T - 1) template<class T = void> struct decrement3; #if __cplusplus > 201103L template<class T = void> using negate = std::negate<T>; #else template<class T = void> struct negate; #endif template<class T = void> struct unary_plus; //@} /** * Comparisons * @{ */ #if __cplusplus > 201103L template<class T = void> using equal_to = std::equal_to<T>; template<class T = void> using not_equal_to = std::not_equal_to<T>; template<class T = void> using greater = std::greater<T>; template<class T = void> using less = std::less<T>; template<class T = void> using greater_equal = std::greater_equal<T>; template<class T = void> using less_equal = std::less_equal<T>; #else template<class T = void> struct equal_to; template<class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; #endif /// \brief !(T < U) && !(U < T) template<class T = void> struct equivalent; /// \brief !(T < U) && !(T > U) template<class T = void> struct equivalent2; //@} /** * Logical operations * @{ */ #if __cplusplus > 201103L template<class T = void> using logical_and = std::logical_and<T>; template<class T = void> using logical_or = std::logical_or<T>; template<class T = void> using logical_not = std::logical_not<T>; #else template<class T = void> struct logical_and; template<class T = void> struct logical_or; template<class T = void> struct logical_not; #endif //@} /** * Bitwise operations * @{ */ #if __cplusplus > 201103L template<class T = void> using bit_and = std::bit_and<T>; template<class T = void> using bit_or = std::bit_or<T>; template<class T = void> using bit_xor = std::bit_xor<T>; #else template<class T = void> struct bit_and; template<class T = void> struct bit_or; template<class T = void> struct bit_xor; #endif template<class T = void> struct bit_and_equal; template<class T = void> struct bit_or_equal; template<class T = void> struct bit_xor_equal; template<class T = void> struct left_shift; template<class T = void> struct right_shift; template<class T = void> struct left_shift_equal; template<class T = void> struct right_shift_equal; template<class T = void> struct bit_not; //@} /** * Accessor operations * @{ */ template<class T = void> struct dereference; template<class T = void> struct address; template<class T = void> struct arrow; template<class T = void, class Index = void> struct index; /// \brief *(T + Index) template<class T = void, typename Index = void> struct index2; //@} /** * Affectation * @{ */ template<class T = void> struct assign; //@} /** * @{ */ template<class T = void, class U = T> struct comma; template<class T = void, class Member = void> struct pointer_to_member; //@} #define FALCON_MAKE_BINARY_OP(name, op, Tres, T1, T2)\ template<class T>\ struct name\ {\ constexpr name() noexcept {}\ \ Tres operator()(T1 x, T2 y) const\ { return x op y; }\ \ typedef T first_argument_type;\ typedef T second_argument_type;\ typedef Tres result_type;\ };\ \ template<>\ struct name<void>\ {\ constexpr name() noexcept {}\ \ template<class T, class U>\ constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT(\ operator()(T&& x, U&& y) const\ , std::forward<T>(x) op std::forward<U>(y))\ \ typedef aux_::is_transparent_t is_transparent;\ }; #if __cplusplus == 201103L FALCON_MAKE_BINARY_OP(plus, +, T, T const &, T const &) FALCON_MAKE_BINARY_OP(minus, -, T, T const &, T const &) FALCON_MAKE_BINARY_OP(multiplies, *, T, T const &, T const &) FALCON_MAKE_BINARY_OP(modulus, %, T, T const &, T const &) FALCON_MAKE_BINARY_OP(divides, /, T, T const &, T const &) FALCON_MAKE_BINARY_OP(equal_to, ==, bool, T const &, T const &) FALCON_MAKE_BINARY_OP(not_equal_to, !=, bool, T const &, T const &) FALCON_MAKE_BINARY_OP(greater, > , bool, T const &, T const &) FALCON_MAKE_BINARY_OP(less, < , bool, T const &, T const &) FALCON_MAKE_BINARY_OP(greater_equal, >=, bool, T const &, T const &) FALCON_MAKE_BINARY_OP(less_equal, <=, bool, T const &, T const &) FALCON_MAKE_BINARY_OP(logical_and, &&, bool, T const &, T const &) FALCON_MAKE_BINARY_OP(logical_or, ||, bool, T const &, T const &) FALCON_MAKE_BINARY_OP(bit_and, &, T, T const &, T const &) FALCON_MAKE_BINARY_OP(bit_or, |, T, T const &, T const &) FALCON_MAKE_BINARY_OP(bit_xor, ^, T, T const &, T const &) #endif FALCON_MAKE_BINARY_OP(plus_equal, +=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(minus_equal, -=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(multiplies_equal, *=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(modulus_equal, %=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(divides_equal, /=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(bit_and_equal, &=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(bit_or_equal, |=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(bit_xor_equal, ^=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(left_shift, <<, T, T const &, T const &) FALCON_MAKE_BINARY_OP(right_shift, >>, T, T const &, T const &) FALCON_MAKE_BINARY_OP(left_shift_equal, <<=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(right_shift_equal,>>=, T&, T&, T const &) FALCON_MAKE_BINARY_OP(assign, =, T&, T&, T const &) #undef FALCON_MAKE_BINARY_OP #define FALCON_MAKE_UNARY_OP(name, op, Tres, T1)\ template<class T>\ struct name\ {\ constexpr name() noexcept {}\ \ Tres operator()(T1 x) const\ { return op x; }\ \ typedef T argument_type;\ typedef Tres result_type;\ };\ \ template<>\ struct name<void>\ {\ constexpr name() noexcept {}\ \ template<class T>\ constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT(\ operator()(T&& x) const\ , op std::forward<T>(x))\ \ typedef aux_::is_transparent_t is_transparent;\ }; #if __cplusplus == 201103L FALCON_MAKE_UNARY_OP(negate, -, T, T const &) FALCON_MAKE_UNARY_OP(logical_not, !, bool, T const &) #endif FALCON_MAKE_UNARY_OP(increment, ++, T&, T&) FALCON_MAKE_UNARY_OP(decrement, --, T&, T&) FALCON_MAKE_UNARY_OP(unary_plus, +, T, T const &) FALCON_MAKE_UNARY_OP( dereference, *, typename internal_reference<T>::type, T&) FALCON_MAKE_UNARY_OP(address, &, T*, T&) FALCON_MAKE_UNARY_OP(bit_not, ~, T, T const &) #undef FALCON_MAKE_UNARY_OP template<class T> struct dereference<T*> { constexpr dereference() noexcept {} constexpr T& operator()(T* x) const noexcept { return *x; } typedef T argument_type; typedef T& result_type; }; template<class T> struct dereference<T[]> : dereference<T*> {}; template<typename T, std::size_t N> struct dereference<T[N]> : dereference<T*> { typedef T argument_type[N]; }; #define FALCON_MAKE_UNARY_OP2(name, post_op, Tres, T1)\ template<class T>\ struct name\ {\ constexpr name() noexcept {}\ \ Tres operator()(T1 x) const\ { return x post_op; }\ \ typedef T argument_type;\ typedef Tres result_type;\ };\ \ template<>\ struct name<void>\ {\ constexpr name() noexcept {}\ \ template<class T>\ constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT(\ operator()(T&& x) const\ , std::forward<T>(x) post_op)\ \ typedef aux_::is_transparent_t is_transparent;\ }; FALCON_MAKE_UNARY_OP2(post_increment, ++, T&, T&) FALCON_MAKE_UNARY_OP2(post_decrement, --, T&, T&) FALCON_MAKE_UNARY_OP2(increment2, += 1, T&, T&) FALCON_MAKE_UNARY_OP2(decrement2, -= 1, T&, T&) #undef FALCON_MAKE_UNARY_OP2 #define FALCON_MAKE_UNARY_OP3(name, post_op, Tres, T1)\ template<class T>\ struct name\ {\ constexpr name() noexcept {}\ \ Tres operator()(T1 x) const\ { return (x = static_cast<T>(x post_op)), x; }\ \ typedef T argument_type;\ typedef Tres result_type;\ };\ \ template<>\ struct name<void>\ {\ constexpr name() noexcept {}\ \ template<class T>\ constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT(\ operator()(T&& x) const\ , ((x = static_cast<typename std::remove_reference<T>::type>(\ std::forward<T>(x) post_op)), x))\ \ typedef aux_::is_transparent_t is_transparent;\ }; FALCON_MAKE_UNARY_OP3(increment3, + 1, T&, T&) FALCON_MAKE_UNARY_OP3(decrement3, - 1, T&, T&) #undef FALCON_MAKE_UNARY_OP3 template<class T> struct equivalent { constexpr equivalent() noexcept {} constexpr bool operator()(const T& a, const T& b) const { return !(a < b) && !(b < a); } typedef T first_argument_type; typedef T second_argument_type; typedef bool result_type; }; template<> struct equivalent<void> { constexpr equivalent() noexcept {} template<class T, class U> constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT( operator()(const T& a, const U& b) const , !(a < b) && !(b < a)) typedef aux_::is_transparent_t is_transparent; }; template<class T> struct equivalent2 { constexpr equivalent2() noexcept {} constexpr bool operator()(const T& a, const T& b) const { return !(a < b) && !(a > b); } typedef T first_argument_type; typedef T second_argument_type; typedef bool result_type; }; template<> struct equivalent2<void> { constexpr equivalent2() noexcept {} template<class T, class U> constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT( operator()(const T& a, const U& b) const , !(a < b) && !(a > b)) typedef aux_::is_transparent_t is_transparent; }; template<class T> struct arrow { typedef T argument_type; typedef typename std::remove_const<T>::type::type& result_type; constexpr arrow() noexcept {} constexpr result_type operator()(T& a) const { return a.operator->(); } }; template<> struct arrow<void> { constexpr arrow() noexcept {} template<class T> constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT( operator()(T&& a) const , std::forward<T>(a).operator->()) typedef aux_::is_transparent_t is_transparent; }; template<typename T, typename Index> struct index { typedef T first_argument_type; typedef typename default_or_type<std::size_t, Index, void> ::type second_argument_type; typedef typename std::remove_const<T>::type::value_type& result_type; constexpr index() noexcept {} constexpr result_type operator()(T& a, second_argument_type i) const { return a[i]; } }; template<class T, class Index> struct index<T*, Index> { typedef T* first_argument_type; typedef typename default_or_type<std::size_t, Index, void> ::type second_argument_type; typedef T& result_type; constexpr index() noexcept {} constexpr result_type operator()(T& a, second_argument_type i) const { return a[i]; } }; template<typename T, typename Index> struct index<T[], Index> : index<T*, Index> {}; template<typename T, std::size_t N, typename Index> struct index<T[N], Index> : index<T*, Index> { typedef T first_argument_type[N]; }; template<> struct index<void, void> { constexpr index() noexcept {} template<typename T, typename Index> constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT( operator()(T&& a, Index && i) const , std::forward<T>(a)[std::forward<Index>(i)]) typedef aux_::is_transparent_t is_transparent; }; template<typename T, typename Index> struct index2 { typedef T first_argument_type; typedef typename default_or_type<std::size_t, Index, void> ::type second_argument_type; typedef typename std::remove_const<T>::type::type& result_type; constexpr index2() noexcept {} constexpr result_type operator()(T& a, second_argument_type i) const { return *(a + i); } }; template<typename T, typename Index> struct index2<T*, Index> : index<T*, Index> {}; template<typename T, typename Index> struct index2<T[], Index> : index<T*, Index> {}; template<typename T, std::size_t N, typename Index> struct index2<T[N], Index> : index<T*, Index> { typedef T first_argument_type[N]; }; template<> struct index2<void, void> { constexpr index2() noexcept {} template<typename T, typename Index> constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT( operator()(T&& a, Index&& i) const , *(std::forward<T>(a) + std::forward<Index>(i))) typedef aux_::is_transparent_t is_transparent; }; template<class T, class U> struct comma { typedef T first_argument_type; typedef U second_argument_type; typedef T& result_type; constexpr comma() noexcept {} constexpr result_type operator()(T& a, U& b) const { return (a , b); } }; template<> struct comma<void, void> { constexpr comma() noexcept {} template<class T, class U> constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT( operator()(T&& a, U&& b) const , (std::forward<T>(a), std::forward<U>(b))) typedef aux_::is_transparent_t is_transparent; }; template<typename T, typename Member> struct pointer_to_member { typedef T first_argument_type; typedef Member second_argument_type; typedef decltype(std::declval<T>().*std::declval<Member>()) result_type; constexpr pointer_to_member() noexcept {} constexpr result_type operator()(T& a, Member m) const { return a.*m; }; }; template<> struct pointer_to_member<void, void> { constexpr pointer_to_member() noexcept {} template<typename T, typename Member> constexpr CPP1X_DELEGATE_FUNCTION_NOEXCEPT( operator()(T&& a, Member m) const , std::forward<T>(a).*m) typedef aux_::is_transparent_t is_transparent; }; } #endif
0a89143efa1bed7d30f0e2d65e23aa7134ad5acc
b7bc9a7bcdd29ce77f39d5a390f5b5f6965e0326
/demo/OpenCV_Test/test_rotate.cpp
7011c3276fe902b846350af77300567c0514026d
[]
no_license
fengbingchun/OpenCV_Test
3ab3ddf06b788fd7b33905163b2f247df4ed1ae2
c0c9b54d4593689fbe33b1e4d30c116aced79285
refs/heads/master
2023-08-16T12:29:48.033454
2023-08-13T03:30:05
2023-08-13T03:30:05
53,253,299
210
119
null
null
null
null
UTF-8
C++
false
false
4,727
cpp
test_rotate.cpp
#include "fbc_cv_funset.hpp" #include <assert.h> #include <opencv2/opencv.hpp> #include <rotate.hpp> // Blog: http://blog.csdn.net/fengbingchun/article/details/51923769 int test_getRotationMatrix2D() { #ifdef _MSC_VER cv::Mat matSrc = cv::imread("../../../test_images/lena.png", 1); #else cv::Mat matSrc = cv::imread("test_images/lena.png", 1); #endif if (!matSrc.data) { std::cout << "read image fail" << std::endl; return -1; } double angle = -50.0; double scale = 0.6; fbc::Point2f center = fbc::Point2f(matSrc.cols / 2, matSrc.rows / 2); fbc::Mat_<double, 1> mat_rot(2, 3); fbc::getRotationMatrix2D(center, angle, scale, mat_rot); // Compute a rotation matrix with respect to the center of the image cv::Point center_ = cv::Point(matSrc.cols / 2, matSrc.rows / 2); // Get the rotation matrix with the specifications above cv::Mat mat_rot_ = cv::getRotationMatrix2D(center_, angle, scale); assert(mat_rot.cols == mat_rot_.cols && mat_rot.rows == mat_rot_.rows); assert(mat_rot.step == mat_rot_.step); for (int y = 0; y < mat_rot.rows; y++) { const fbc::uchar* p = mat_rot.ptr(y); const uchar* p_ = mat_rot_.ptr(y); for (int x = 0; x < mat_rot.step; x++) { assert(p[x] == p_[x]); } } return 0; } int test_rotate_uchar() { #ifdef _MSC_VER cv::Mat matSrc = cv::imread("../../../test_images/lena.png", 1); #else cv::Mat matSrc = cv::imread("test_images/lena.png", 1); #endif if (!matSrc.data) { std::cout << "read image fail" << std::endl; return -1; } double angle = -50.0; for (int interpolation = 0; interpolation < 5; interpolation++) { fbc::Point2f center = fbc::Point2f(matSrc.cols / 2.0, matSrc.rows / 2.0); fbc::Mat_<uchar, 3> mat(matSrc.rows, matSrc.cols, matSrc.data); fbc::Mat_<uchar, 3> rotate_dst; fbc::rotate(mat, rotate_dst, center, angle, true, interpolation); // Compute a rotation matrix with respect to the center of the image cv::Point2f center_ = cv::Point2f(matSrc.cols / 2.0, matSrc.rows / 2.0); // Get the rotation matrix with the specifications above cv::Mat mat_rot_ = getRotationMatrix2D(center_, angle, 1.0); cv::Mat rotate_dst_; cv::warpAffine(matSrc, rotate_dst_, mat_rot_, matSrc.size(), interpolation); assert(rotate_dst.step == rotate_dst_.step && rotate_dst.rows == rotate_dst_.rows); for (int y = 0; y < rotate_dst.rows; y++) { const fbc::uchar* p = rotate_dst.ptr(y); const uchar* p_ = rotate_dst_.ptr(y); for (int x = 0; x < rotate_dst.step; x++) { assert(p[x] == p_[x]); } } } return 0; } int test_rotate_float() { #ifdef _MSC_VER cv::Mat matSrc = cv::imread("../../../test_images/lena.png", 1); #else cv::Mat matSrc = cv::imread("test_images/lena.png", 1); #endif if (!matSrc.data) { std::cout << "read image fail" << std::endl; return -1; } cv::cvtColor(matSrc, matSrc, cv::COLOR_BGR2GRAY); matSrc.convertTo(matSrc, CV_32FC1); double angle = -50.0; for (int interpolation = 0; interpolation < 5; interpolation++) { fbc::Point2f center = fbc::Point2f(matSrc.cols / 2.0, matSrc.rows / 2.0); fbc::Mat_<float, 1> mat(matSrc.rows, matSrc.cols, matSrc.data); fbc::Mat_<float, 1> rotate_dst; fbc::rotate(mat, rotate_dst, center, angle, true, interpolation); // Compute a rotation matrix with respect to the center of the image cv::Point2f center_ = cv::Point2f(matSrc.cols / 2.0, matSrc.rows / 2.0); // Get the rotation matrix with the specifications above cv::Mat mat_rot_ = getRotationMatrix2D(center_, angle, 1.0); cv::Mat rotate_dst_; cv::warpAffine(matSrc, rotate_dst_, mat_rot_, matSrc.size(), interpolation); assert(rotate_dst.step == rotate_dst_.step && rotate_dst.rows == rotate_dst_.rows); for (int y = 0; y < rotate_dst.rows; y++) { const fbc::uchar* p = rotate_dst.ptr(y); const uchar* p_ = rotate_dst_.ptr(y); for (int x = 0; x < rotate_dst.step; x++) { assert(p[x] == p_[x]); } } } return 0; } int test_rotate_without_crop() { #ifdef _MSC_VER cv::Mat matSrc = cv::imread("../../../test_images/1.jpg", 1); #else cv::Mat matSrc = cv::imread("test_images/1.jpg", 1); #endif if (!matSrc.data) { std::cout << "read image fail" << std::endl; return -1; } double angle = -50.0; double scale = 0.6; fbc::Point2f center = fbc::Point2f(matSrc.cols / 2.0, matSrc.rows / 2.0); fbc::Mat_<uchar, 3> mat(matSrc.rows, matSrc.cols, matSrc.data); fbc::Mat_<uchar, 3> rotate_dst; fbc::rotate(mat, rotate_dst, center, angle, true/*false*/, 2, 0, fbc::Scalar(128, 255, 0)); cv::Mat mat_save(rotate_dst.rows, rotate_dst.cols, CV_8UC3, rotate_dst.data); #ifdef _MSC_VER cv::imwrite("../../../test_images/1_rotate2.jpg", mat_save); #else cv::imwrite("test_images/1_rotate2.jpg", mat_save); #endif return 0; }
21c3bf23ba09f70f25d95c9ec0869f5ea251cd4b
d49d829adcc867571592795035829ebe7b1601c9
/SSETest/SSETest/sqrt_test.cpp
35437e9e0daffe15b73712a7ef06dab12e237010
[]
no_license
caohaitao/CHTTest
12622088a0de0b88a6803d0b377afd9e23290ff0
e195ee1452758d9302586a15b438d0a710c7591e
refs/heads/master
2020-06-19T23:47:36.930966
2019-07-16T01:08:45
2019-07-16T01:08:45
196,917,081
0
0
null
null
null
null
ISO-8859-7
C++
false
false
3,972
cpp
sqrt_test.cpp
#include "stdlib.h" #include "stdio.h" #include "time.h" #include <chrono> #include "nmmintrin.h" #include <immintrin.h> #include "common.h" static float normal_sqrt(float * a, int n) { float sum = 0.0; for (int i = 0; i < n; i++) { sum += sqrt(a[i]); } return sum; } static float normal_sqrt_loop4(float * a, int n) { float sum = 0.0; size_t block = n / 4; size_t reserve = n % 4; float * p = a; for (size_t i = 0; i < block; ++i) { sum += sqrt(p[0]); sum += sqrt(p[1]); sum += sqrt(p[2]); sum += sqrt(p[3]); p += 4; } for (size_t i = 0; i < reserve; ++i) { sum += sqrt(p[i]); } return sum; } static float sse_sqrt(float * a, int n) { float sum = 0; __m128 sse_load; const float *p = a; int nBlockWidth = 4; size_t block = n / nBlockWidth; size_t reserved = n % nBlockWidth; for (size_t i = 0; i < block; ++i) { sse_load = _mm_load_ps(p); __m128 temp = _mm_sqrt_ps(sse_load); const float * q = (const float*)&temp; sum += q[0] + q[1] + q[2] + q[3]; p += nBlockWidth; } for (size_t i = 0; i < reserved; i++) { sum += sqrt(p[i]); } return sum; } static float sse_sqrt_256(float * a, int n) { float sum = 0; __m256 sse_load; const float *p = a; int nBlockWidth = 8; size_t block = n / nBlockWidth; size_t reserved = n % nBlockWidth; for (size_t i = 0; i < block; ++i) { sse_load = _mm256_load_ps(p); __m256 temp = _mm256_sqrt_ps(sse_load); const float * q = (const float*)&temp; sum += q[0] + q[1] + q[2] + q[3] + q[4] + q[5] + q[6] + q[7]; p += nBlockWidth; } for (size_t i = 0; i < reserved; i++) { sum += sqrt(p[i]); } return sum; } int sqrt_test(int argc, char ** argv) { int n = 40000; printf("n=%d\n", n); float * a = (float*)TAlignAlloc(sizeof(float)*n, 16); for (int i = 0; i < n; i++) { a[i] = (float)(i % 10); } typedef std::chrono::high_resolution_clock Time; typedef std::chrono::duration<double, std::ratio<1, 1000>> ms;//ΊΑΓλ typedef std::chrono::duration<float> fsec; float sum = 0; { auto t0 = Time::now(); sum = normal_sqrt(a, n); auto t1 = Time::now(); fsec fs = t1 - t0; ms d = std::chrono::duration_cast<ms>(fs); printf("normal_num,value(%0.4f) use_time(%0.4f ms)\n", sum, d.count()); } { auto t0 = Time::now(); sum = normal_sqrt_loop4(a, n); auto t1 = Time::now(); fsec fs = t1 - t0; ms d = std::chrono::duration_cast<ms>(fs); printf("normal_sqrt_loop4,value(%0.4f) use_time(%0.4f ms)\n", sum, d.count()); } { auto t0 = Time::now(); sum = sse_sqrt(a, n); auto t1 = Time::now(); fsec fs = t1 - t0; ms d = std::chrono::duration_cast<ms>(fs); printf("sse_sqrt,value(%0.4f) use_time(%0.4f ms)\n", sum, d.count()); } { auto t0 = Time::now(); sum = sse_sqrt_256(a, n); auto t1 = Time::now(); fsec fs = t1 - t0; ms d = std::chrono::duration_cast<ms>(fs); printf("sse_sqrt_256,value(%0.4f) use_time(%0.4f ms)\n", sum, d.count()); } return 0; }
a8851dd256aedb8fefffe94693062dbc8d1f599c
5672afd545d8d02e00a8a5e6fa5f6bf54ed16ec8
/src/engine/drawables/Drawable3DGrid.h
a16aba16398339b6798a136049d6f39ba331265b
[ "MIT", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
alopatindev/ponic
940470a7b4b57a628d598f31ea0ed28d66bddc58
e100b20dcbab584b51dfa871aa45dc2c15faef8b
refs/heads/master
2016-09-06T14:41:44.401235
2014-10-12T09:49:11
2014-10-12T09:49:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,480
h
Drawable3DGrid.h
#pragma once #include <engine/drawables/Drawable3D.h> #include <engine/GridManager.h> #include <engine/misc/Singleton.h> #include <glm/glm.hpp> #include <cstdlib> static const size_t GRID_WIDTH = 80; static const size_t GRID_HEIGHT = 50; static const float ASPECT_ADDITION = 1.0f; class Drawable3DGrid_Class : public Drawable3D { TileType m_gridBuffer[GRID_WIDTH][GRID_HEIGHT]; const Grid* m_grid; std::string m_gridName; glm::ivec2 m_cursor; // left+up corner of the grid glm::vec3 m_startPos; glm::vec3 m_tryPos; //bool m_canMove; bool m_onSlope; glm::ivec2 m_lastStep; public: Drawable3DGrid_Class(); virtual ~Drawable3DGrid_Class(); virtual void render() const; virtual void update(int dt); virtual void fixedUpdate(int dt); void setGrid(const std::string& grid); void step(const glm::ivec2& vec); void stepUp(); void stepDown(); void stepLeft(); void stepRight(); void stepCancel(); void trySetPosition(const glm::vec3& vec); /*bool didMove() { return m_canMove; }*/ float getTileWidth() const; float getTileHeight() const; const glm::vec2& getTileSize() const; TileType getTileType(const glm::vec2& vec, bool offsetHack = false) const; TileType getTileType(const glm::vec3& vec, bool offsetHack = false) const; TileType getTileType(float x, float y, bool offsetHack = false) const; const glm::ivec2& getCursor() const { return m_cursor; } const std::string& getGridName() const { return m_gridName; } const glm::ivec2& coordsToIndexes(float x, float y, bool offsetHack = false) const; const glm::ivec2& coordsToIndexes(const glm::vec2& vec, bool offsetHack = false) const; const glm::ivec2& coordsToIndexes(const glm::vec3& vec, bool offsetHack = false) const; const glm::vec3& indexesToCoords(int x, int y) const; const glm::vec3& indexesToCoords(const glm::ivec2& vec) const; //bool getNextSlopeOffset(const glm::vec3& pos, float& yOut) const; private: void repairBuffer(); void updateBuffer(); /*bool canStepUp() const; bool canStepDown() const;*/ bool canStepLeft() const; bool canStepRight() const; void calculateSlopeVertexes(const glm::vec3& pos, glm::ivec2& leftVertex, glm::ivec2& rightVertex) const; }; typedef Singleton<Drawable3DGrid_Class> Drawable3DGrid;
7d96754806cbc9a6ca92e4fd65ee3d9a1eb1451e
6d84fc2add0c42cf0ebe953686be54282139669d
/ThirdsEngine/Shader.cpp
fbb852f766ed1bce777b2d8fba90d74e7cc18263
[ "Apache-2.0" ]
permissive
OlisProgramming/ThirdsEngine
791a709c08d885862dbebd1c203939dc517a19e3
0f44ae9e96f47d69222a57f43c1744cd89995e44
refs/heads/master
2021-01-14T11:39:26.854655
2016-12-17T21:37:27
2016-12-17T21:37:27
68,458,042
0
0
null
null
null
null
UTF-8
C++
false
false
633
cpp
Shader.cpp
#include "Shader.h" namespace te { namespace render { Shader::Shader(std::string vert, std::string frag) { program = loadShaders(("shader/" + vert).c_str(), ("shader/" + frag).c_str()); idMVP = getUniformID("MVP"); } void Shader::bind() { glUseProgram(program); } GLuint Shader::getUniformID(const std::string& name) const { return glGetUniformLocation(program, name.c_str()); } void Shader::setUniform(GLuint id, const Mat4& val) const { glUniformMatrix4fv(id, 1, GL_FALSE, &val[0][0]); } void Shader::setUniform(GLuint id, const Vec3& val) const { glUniform3fv(id, 1, &val[0]); } } }
dd004f4dc665322e8df08bd6ac9631e32a88f37a
492076face9fc0534465ed58c30553ad19627c01
/Sources/main.cpp
5109477333ace208a366150782eb8d691dc7d15e
[]
no_license
Olive-Noire/PixMap-Editeur
084924c094024629ce72f7842fe349c0cc399194
3b350dc476f942a87ad1a57b29787eed64aee456
refs/heads/main
2023-03-23T00:42:02.288638
2021-03-13T15:17:01
2021-03-13T15:17:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
918
cpp
main.cpp
#include "../Headers/Editor.hpp" #include "../Headers/Image.hpp" #include <iostream> //#include <thread> //#include <windows.h> #include "../Headers/Files.hpp" #include "../Headers/Picker.hpp" int main(int argc,char* argv[]) { //_setmode(_fileno(stdout), 0x00020000); Editor editor; if (argc > 1 && ExistingFile(argv[1])) { editor.Open(argv[1]); //std::thread t{&Editor::Open,argv[1]}; } else { if (argc > 1) { std::cout << "ERREUR: Chargement du fichier : \n" << argv[1] << "\nce fichier n'existe pas ou possede des caracteres speciaux !\n\nchargement de \"unamed.ppm\"..."; std::cin.ignore(); std::system("cls"); } } while (Editor::start) { editor.Update(); if (editor.img == nullptr) editor.Render(); } return 0; }
f67659a8f231e71a2b4571bbcbe253be6a86cbd9
c7c3f07a9300944efb862e3dbf480de1aba6d64c
/DungeonCrawler/Room.h
a32f764d07e478295493da1ea12456e908092546
[]
no_license
carlwilke/DungeonCrawler
b7acee09335349061e01c6271dd5eb64312b22e6
c130f3d7897172d320bdc52f6131ab662acd9671
refs/heads/master
2022-11-05T07:20:19.695724
2020-06-23T14:50:42
2020-06-23T14:50:42
274,423,216
0
0
null
null
null
null
UTF-8
C++
false
false
343
h
Room.h
#pragma once #include <vector> #include "GameCharacter.h" #include "Item.h" #ifndef ROOM_H #define ROOM_H using namespace std; class Room { public: int position; bool isExit; vector<Item> items; vector<GameCharacter> enemies; Room(int, bool, vector<Item>, vector<GameCharacter>); void ClearLoot(); void ClearEnemies(); }; #endif
33497be90939fbe488f376a3856fdd3903dca3cf
39e4ba72b7983416458191d043c5251c5e67a21f
/test/handlers/screen.test.cpp
7ed9142de4719976e7f57b216eaea3a73e0452dd
[]
no_license
CalgaryMichael/barthes
3e5c75eb830b201d8a6da4883067d16d81312744
b1b17e188124b421f97b32e26700d64d66c3400e
refs/heads/main
2023-08-15T08:34:43.708578
2021-10-18T05:24:10
2021-10-18T05:24:10
403,179,194
0
0
null
null
null
null
UTF-8
C++
false
false
12,537
cpp
screen.test.cpp
#include <gtest/gtest.h> #include <barthes/config.h> #include <barthes/handlers/input.h> #include <barthes/handlers/screen.h> TEST(ScreenHandlerTest, generate_line__empty__no_value) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "" } }; std::string actual = barthes::generate_line(&tc, tc.file_buffer, 0); std::string expected = "\n"; EXPECT_EQ(actual, expected); } TEST(ScreenHandlerTest, generate_line__empty__outside_screen) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(0, 49), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; std::string actual = barthes::generate_line(&tc, tc.file_buffer, 0); std::string expected = "\n"; EXPECT_EQ(actual, expected); } TEST(ScreenHandlerTest, generate_line__in_view) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; std::string actual = barthes::generate_line(&tc, tc.file_buffer, 0); std::string expected = "Miles Davis\n"; EXPECT_EQ(actual, expected); } TEST(ScreenHandlerTest, generate_line__in_view__partial__start) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(0, 4), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; std::string actual = barthes::generate_line(&tc, tc.file_buffer, 0); std::string expected = "s Davis\n"; EXPECT_EQ(actual, expected); } TEST(ScreenHandlerTest, generate_line__in_view__partial__end) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 9), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; std::string actual = barthes::generate_line(&tc, tc.file_buffer, 0); std::string expected = "Miles Da\n"; EXPECT_EQ(actual, expected); } TEST(ScreenHandlerTest, generate_lines__in_view) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "Charles Mingus" } }; std::string actual = barthes::generate_lines(&tc, tc.file_buffer); std::string expected = "Miles Davis\nCharles Mingus\n"; EXPECT_EQ(actual, expected); } TEST(ScreenHandlerTest, generate_lines__in_view__partial__row) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(2, 0), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "Charles Mingus", "Nina Simone" } }; std::string actual = barthes::generate_lines(&tc, tc.file_buffer); std::string expected = "Nina Simone\n"; EXPECT_EQ(actual, expected); } TEST(ScreenHandlerTest, generate_lines__in_view__partial__col) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 9), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "Charles Mingus" } }; std::string actual = barthes::generate_lines(&tc, tc.file_buffer); std::string expected = "Miles Da\nCharles \n"; EXPECT_EQ(actual, expected); } TEST(ScreenHandlerTest, adjust_view__no_adjustment) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; EXPECT_EQ(barthes::adjust_view(&tc), false); EXPECT_EQ(tc.view.first, 0); EXPECT_EQ(tc.view.second, 0); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, adjust_view__scroll_up__in_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(1, 0), .cursor=std::make_pair(-1, 0), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; EXPECT_EQ(barthes::adjust_view(&tc), true); EXPECT_EQ(tc.view.first, 0); EXPECT_EQ(tc.view.second, 0); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, adjust_view__scroll_up__out_of_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .view=std::make_pair(0, 0), .cursor=std::make_pair(-1, 0), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; EXPECT_EQ(barthes::adjust_view(&tc), false); EXPECT_EQ(tc.view.first, 0); EXPECT_EQ(tc.view.second, 0); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, adjust_view__scroll_down__in_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(5, 50), .view=std::make_pair(1, 0), .cursor=std::make_pair(5, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane", "Nina Simone", "Roberta Flack", "Charles Mingus", "Herbie Hancock", "Max Roach" } }; EXPECT_EQ(barthes::adjust_view(&tc), true); EXPECT_EQ(tc.view.first, 2); EXPECT_EQ(tc.view.second, 0); EXPECT_EQ(tc.cursor.first, 4); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, adjust_view__scroll_down__out_of_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(5, 50), .view=std::make_pair(0, 0), .cursor=std::make_pair(5, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane", "Nina Simone" } }; EXPECT_EQ(barthes::adjust_view(&tc), false); EXPECT_EQ(tc.view.first, 0); EXPECT_EQ(tc.view.second, 0); EXPECT_EQ(tc.cursor.first, 2); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, adjust_view__scroll_right__in_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(5, 5), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, 5), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; EXPECT_EQ(barthes::adjust_view(&tc), true); EXPECT_EQ(tc.view.first, 0); EXPECT_EQ(tc.view.second, 1); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 4); } TEST(ScreenHandlerTest, adjust_view__scroll_right__out_of_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(5, 12), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, 12), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; EXPECT_EQ(barthes::adjust_view(&tc), false); EXPECT_EQ(tc.view.first, 0); EXPECT_EQ(tc.view.second, 0); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 11); } TEST(ScreenHandlerTest, adjust_view__scroll_left__in_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(5, 50), .view=std::make_pair(0, 2), .cursor=std::make_pair(0, -1), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; EXPECT_EQ(barthes::adjust_view(&tc), true); EXPECT_EQ(tc.view.first, 0); EXPECT_EQ(tc.view.second, 1); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, adjust_view__scroll_left__out_of_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(5, 50), .view=std::make_pair(0, 0), .cursor=std::make_pair(0, -1), .file_buffer=std::vector<std::string>{ "Miles Davis" } }; EXPECT_EQ(barthes::adjust_view(&tc), false); EXPECT_EQ(tc.view.first, 0); EXPECT_EQ(tc.view.second, 0); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, move_cursor__nowhere) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(0, 0), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, 0, 0); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, move_cursor__up__in_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(0, 0), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, barthes::UP, 0); EXPECT_EQ(tc.cursor.first, 1); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, move_cursor__up__out_of_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(1, 0), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, barthes::UP, 0); EXPECT_EQ(tc.cursor.first, 1); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, move_cursor__down__in_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(2, 0), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, barthes::DOWN, 0); EXPECT_EQ(tc.cursor.first, 1); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, move_cursor__down__out_of_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(0, 0), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, barthes::DOWN, 0); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 0); } TEST(ScreenHandlerTest, move_cursor__right__in_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(0, 0), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, 0, barthes::RIGHT); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 1); } TEST(ScreenHandlerTest, move_cursor__right__out_of_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(0, 11), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, 0, barthes::RIGHT); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 11); } TEST(ScreenHandlerTest, move_cursor__left__in_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(0, 2), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, 0, barthes::LEFT); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 1); } TEST(ScreenHandlerTest, move_cursor__left__out_of_bounds) { barthes::TermConfig tc = { .window_size=std::make_pair(50, 50), .cursor=std::make_pair(0, 0), .view=std::make_pair(0, 0), .file_buffer=std::vector<std::string>{ "Miles Davis", "John Coltrane" } }; barthes::move_cursor(&tc, 0, barthes::LEFT); EXPECT_EQ(tc.cursor.first, 0); EXPECT_EQ(tc.cursor.second, 0); }
a355965289323ae2d44fdb427ac245d5b5e6a463
2e10a55bcc27421c2ce00bac67d62ca3ae7a43be
/gcommon/source/gguinodecomponenttext.cpp
622e2fcb017d94827608d75f6420d821cbcb54c9
[ "Unlicense" ]
permissive
DavidCoenFish/ancient-code-0
2f72b8e20406b9877daa032f9e9fb8343da62340
243fb47b9302a77f9b9392b6e3f90bba2ef3c228
refs/heads/master
2020-03-21T10:18:30.613722
2018-06-24T01:18:30
2018-06-24T01:18:30
138,444,313
0
0
null
null
null
null
UTF-8
C++
false
false
14,209
cpp
gguinodecomponenttext.cpp
// // GGuiNodeComponentText.h // // Created by David Coen on 2011 04 12 // Copyright 2010 Pleasure seeking morons. All rights reserved. // #include "GGuiNodeComponentText.h" #include "GGui.h" #include "GGuiType.h" #include "GGuiFont.h" #include "GGuiFontDataLoad.h" #include "GGuiNode.h" #include "GGuiNodeComponentVisual.h" #include "GGuiNodeComponentTextLoad.h" #include "GStringUtility.h" #include "GMeshManual.h" #include "GMeshType.h" #include "GMeshStreamInfo.h" #include "GColour4Byte.h" #include "GColour4Float.h" #include "GMaterial.h" #include "GVector3Float.h" #include "GGuiManager.h" #include "GGuiFontManager.h" struct TGuiNodeComponentTextFlag { enum TEnum { TNone = 0x0000 , TVisible = 0x0001 , TMeshDirtyPos = 0x0002 //, TMeshDirtyAlpha = 0x0004 , TMeshDirtyColour = 0x0008 }; }; typedef boost::shared_ptr<GGuiNodeComponentText> TPointerGuiNodeComponentText; typedef boost::shared_ptr<GGuiNodeComponentVisual> TPointerGuiNodeComponentVisual; typedef boost::shared_ptr<GMeshManual> TPointerRenderMeshManual; typedef boost::weak_ptr<GMeshManual> TWeakRenderMeshManual; typedef boost::shared_ptr<GMaterialInstance> TPointerMaterialInstance; typedef boost::weak_ptr<GMaterialInstance> TWeakMaterialInstance; typedef std::vector<GMeshStreamInfo> TArrayStreamInfoLoad; typedef std::vector<unsigned char> TArrayByte; typedef std::vector<unsigned short> TArrayShort; //static void LocalUpdateAlpha( // TPointerRenderMeshManual& in_renderMeshManual, // const float in_alpha // ) //{ // if (!in_renderMeshManual) // { // return; // } // // GMeshManual& renderMeshManual = *in_renderMeshManual; // const int vertexCount = (renderMeshManual.GetMaxElementCount() / 6) * 4; // for (int index = 0; index < vertexCount; ++index) // { // renderMeshManual.GetFloatRef(index, 1, 3) = in_alpha; // } // // return; //} static void LocalUpdateColour( TPointerRenderMeshManual& in_renderMeshManual, const float in_red, const float in_green, const float in_blue, const float in_alpha ) { if (!in_renderMeshManual) { return; } GMeshManual& renderMeshManual = *in_renderMeshManual; const int vertexCount = (renderMeshManual.GetMaxElementCount() / 6) * 4; for (int index = 0; index < vertexCount; ++index) { float* const pData = &renderMeshManual.GetFloatRef(index, 1, 0); pData[0] = in_red; pData[1] = in_green; pData[2] = in_blue; pData[3] = in_alpha; } return; } static void LocalAddFontData( GMeshManual& inout_renderMeshManual, int& inout_vertexTrace, const GGuiFontDataLoad& in_fontData, const float in_scale, const GColour4Float& in_colour, const GVector2Float& in_origin, GGui& inout_gui ) { if (!in_fontData.GetFlagVisible()) { return; } const GVector2Float posLeftTop = inout_gui.CalculateDeviceFromScreenCoordinates(GVector2Float( in_origin.m_x, in_origin.m_y - (in_fontData.GetBaseLine() * in_scale) )); const GVector2Float posRightTop = inout_gui.CalculateDeviceFromScreenCoordinates(GVector2Float( in_origin.m_x + (in_fontData.GetSize().m_x * in_scale), in_origin.m_y - (in_fontData.GetBaseLine() * in_scale) )); const GVector2Float posLeftBottom = inout_gui.CalculateDeviceFromScreenCoordinates(GVector2Float( in_origin.m_x, in_origin.m_y + ((in_fontData.GetSize().m_y - in_fontData.GetBaseLine()) * in_scale) )); const GVector2Float posRightBottom = inout_gui.CalculateDeviceFromScreenCoordinates(GVector2Float( in_origin.m_x + (in_fontData.GetSize().m_x * in_scale), in_origin.m_y + ((in_fontData.GetSize().m_y - in_fontData.GetBaseLine()) * in_scale) )); //vertex0 pos { float* const pData = &inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 0, 0, 0); pData[0] = posLeftTop.m_x; pData[1] = posLeftTop.m_y; } //vertex0 colour { *(GColour4Float*)&inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 0, 1, 0) = in_colour; } //vertex0 uv { *(GVector2Float*)&inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 0, 2, 0) = in_fontData.GetUVTopLeft(); } //vertex1 pos { float* const pData = &inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 1, 0, 0); pData[0] = posRightTop.m_x; pData[1] = posRightTop.m_y; } //vertex1 colour { *(GColour4Float*)&inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 1, 1, 0) = in_colour; } //vertex1 uv { *(GVector2Float*)&inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 1, 2, 0) = GVector2Float( in_fontData.GetUVBottomRight().m_x, in_fontData.GetUVTopLeft().m_y ); } //vertex2 pos { float* const pData = &inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 2, 0, 0); pData[0] = posLeftBottom.m_x; pData[1] = posLeftBottom.m_y; } //vertex2 colour { *(GColour4Float*)&inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 2, 1, 0) = in_colour; } //vertex2 uv { *(GVector2Float*)&inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 2, 2, 0) = GVector2Float( in_fontData.GetUVTopLeft().m_x, in_fontData.GetUVBottomRight().m_y ); } //vertex3 pos { float* const pData = &inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 3, 0, 0); pData[0] = posRightBottom.m_x; pData[1] = posRightBottom.m_y; } //vertex3 colour { *(GColour4Float*)&inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 3, 1, 0) = in_colour; } //vertex3 uv { *(GVector2Float*)&inout_renderMeshManual.GetFloatRef(inout_vertexTrace + 3, 2, 0) = in_fontData.GetUVBottomRight(); } inout_vertexTrace += 4; return; } //static public methods /*static*/ GGuiNodeComponentText::TPointerGuiNodeComponentBase GGuiNodeComponentText::Factory( const void* const in_data, GGuiManager& inout_manager, GGuiNode& inout_parent, TArrayGuiNodeComponentPostLoadData& inout_arrayPostLoad ) { TPointerGuiNodeComponentBase pointer; if (!in_data) { return pointer; } const GGuiNodeComponentTextLoad& textLoad = *(GGuiNodeComponentTextLoad*)in_data; TPointerRenderMeshManual renderMeshManual; TWeakGuiFont guiFont = inout_manager.GetFontManager()->GetFont(GStringUtility::SafeString(textLoad.GetFontName())); TArrayStreamInfoLoad arrayStreamInfoLoad; GMeshStreamInfo::AppendStreamInfo( arrayStreamInfoLoad, GMeshType::TStreamType::TFloat, 2, GMeshType::TStreamUsage::TPosition ); GMeshStreamInfo::AppendStreamInfo( arrayStreamInfoLoad, GMeshType::TStreamType::TFloat, 4, GMeshType::TStreamUsage::TColour ); GMeshStreamInfo::AppendStreamInfo( arrayStreamInfoLoad, GMeshType::TStreamType::TFloat, 2, GMeshType::TStreamUsage::TUv0 ); const int maxCount = textLoad.GetMaximumCharCount(); const int vertexCount = maxCount * 4; if (maxCount <= 64) { TArrayByte vertexIndexArray; for (int index = 0; index < maxCount; ++index) { vertexIndexArray.push_back((index* 4) + 0); vertexIndexArray.push_back((index* 4) + 1); vertexIndexArray.push_back((index* 4) + 2); vertexIndexArray.push_back((index* 4) + 2); vertexIndexArray.push_back((index* 4) + 1); vertexIndexArray.push_back((index* 4) + 3); } renderMeshManual.reset(new GMeshManual( GMeshType::TPrimitiveType::TTriangle, vertexIndexArray, vertexCount, arrayStreamInfoLoad )); } else { TArrayShort vertexIndexArray; for (int index = 0; index < maxCount; ++index) { vertexIndexArray.push_back((index* 4) + 0); vertexIndexArray.push_back((index* 4) + 1); vertexIndexArray.push_back((index* 4) + 2); vertexIndexArray.push_back((index* 4) + 2); vertexIndexArray.push_back((index* 4) + 1); vertexIndexArray.push_back((index* 4) + 3); } renderMeshManual.reset(new GMeshManual( GMeshType::TPrimitiveType::TTriangle, vertexIndexArray, vertexCount, arrayStreamInfoLoad )); } renderMeshManual->SetElementCount(0); TPointerMaterialInstance materialInstance = inout_manager.GetMaterialColourTexture().lock(); TPointerGuiNodeComponentVisual pointerVisual; pointerVisual.reset(new GGuiNodeComponentVisual(renderMeshManual, materialInstance, textLoad.GetFlagVisible())); TWeakGuiNodeComponentVisual weakVisual = pointerVisual; { TPointerGuiNodeComponentBase pointerVisualBase = pointerVisual; inout_parent.AddComponent(pointerVisualBase); } TPointerGuiNodeComponentText pointerText; pointerText.reset(new GGuiNodeComponentText( GStringUtility::SafeString(textLoad.GetName()), maxCount, renderMeshManual, weakVisual, guiFont, GColour4Float(textLoad.GetColour()), textLoad.GetScale(), textLoad.GetHorizontalCharPad(), textLoad.GetFlagVisible() )); if (textLoad.GetText()) { pointerText->SetText(textLoad.GetText()); } pointer = pointerText; return pointer; } /*static*/ const unsigned int GGuiNodeComponentText::GetComponentFlag() { return GGuiType::TComponentFlag::TText; } //constructor GGuiNodeComponentText::GGuiNodeComponentText( const std::string& in_name, const GS32 in_maxCharCount, TPointerRenderMeshManual& in_renderMeshManual, //WARN: transferal of ownership TWeakGuiNodeComponentVisual& in_guiNodeComponentVisual, TWeakGuiFont& in_guiFont, const GColour4Float& in_colour, const float in_scale, const float in_horizontalCharPad, const bool in_visible ) : GGuiNodeComponentBase(GetComponentFlag()) , mName(in_name) , mMaxCharCount(in_maxCharCount) , mFlag(0) , mRenderMeshManual(in_renderMeshManual) , mColour(in_colour) , mScale(in_scale) , mHorizontalCharPad(in_horizontalCharPad) , mVisual(in_guiNodeComponentVisual) , mFont(in_guiFont) , mArrayFontDataIndex() , mParentTransformChangeId(0) , m_alpha(1.0F) { SetVisible(in_visible); return; } /*virtual*/ GGuiNodeComponentText::~GGuiNodeComponentText() { return; } //public methods void GGuiNodeComponentText::Update( GGui& inout_gui, GGuiNode& inout_node ) { if (mParentTransformChangeId != inout_node.GetTransformChangeId()) { mParentTransformChangeId = inout_node.GetTransformChangeId(); mFlag |= TGuiNodeComponentTextFlag::TMeshDirtyPos; } if (0 != (mFlag & TGuiNodeComponentTextFlag::TMeshDirtyPos)) { UpdateMesh(inout_gui, inout_node); //| TGuiNodeComponentTextFlag::TMeshDirtyAlpha mFlag &= ~(TGuiNodeComponentTextFlag::TMeshDirtyPos | TGuiNodeComponentTextFlag::TMeshDirtyColour); } if (0 != (mFlag & TGuiNodeComponentTextFlag::TMeshDirtyColour)) { LocalUpdateColour( mRenderMeshManual, mColour.m_red, mColour.m_green, mColour.m_blue, mColour.m_alpha * m_alpha ); mFlag &= ~TGuiNodeComponentTextFlag::TMeshDirtyColour; } return; } //public accessors const bool GGuiNodeComponentText::GetVisible()const { return (0 != (mFlag & TGuiNodeComponentTextFlag::TVisible)); } void GGuiNodeComponentText::SetVisible(const bool in_visible) { if (in_visible == GetVisible()) { return; } if (in_visible) { mFlag |= TGuiNodeComponentTextFlag::TVisible; } else { mFlag &= ~TGuiNodeComponentTextFlag::TVisible; } TPointerGuiNodeComponentVisual pointerVisual = mVisual.lock(); if (pointerVisual) { pointerVisual->SetVisible(in_visible); } return; } void GGuiNodeComponentText::SetAlpha(const float in_alpha) { if (m_alpha == in_alpha) { return; } m_alpha = in_alpha; mFlag |= TGuiNodeComponentTextFlag::TMeshDirtyColour; return; } void GGuiNodeComponentText::SetScale(const GR32 in_scale) { if (mScale == in_scale) { return; } mScale = in_scale; mFlag |= TGuiNodeComponentTextFlag::TMeshDirtyPos; return; } void GGuiNodeComponentText::SetColour(const GColour4Float& in_colour) { if (mColour == in_colour) { return; } mColour = in_colour; mFlag |= TGuiNodeComponentTextFlag::TMeshDirtyColour; //mFlag |= TGuiNodeComponentTextFlag::TMeshDirtyAlpha; return; } void GGuiNodeComponentText::SetText(const std::string& in_text) { TPointerGuiFont pointerFont = mFont.lock(); if (!pointerFont) { return; } GGuiFont& guiFont = *pointerFont; TArrayInt arrayFontDataIndex; for (std::string::const_iterator iterator = in_text.begin(); iterator != in_text.end(); ++iterator) { const int fontDataIndex = guiFont.GetIndexForChar(*iterator); arrayFontDataIndex.push_back(fontDataIndex); } SetArrayFontDataIndex(arrayFontDataIndex); return; } void GGuiNodeComponentText::SetText(const TArrayInt& in_text) { TPointerGuiFont pointerFont = mFont.lock(); if (!pointerFont || (0 == mMaxCharCount)) { return; } GGuiFont& guiFont = *pointerFont; TArrayInt arrayFontDataIndex; for (TArrayInt::const_iterator iterator = in_text.begin(); iterator != in_text.end(); ++iterator) { const int fontDataIndex = guiFont.GetIndexForChar(*iterator); arrayFontDataIndex.push_back(fontDataIndex); } SetArrayFontDataIndex(arrayFontDataIndex); return; } //private methods void GGuiNodeComponentText::SetArrayFontDataIndex(const TArrayInt& in_arrayFontDataIndex) { if (mArrayFontDataIndex == in_arrayFontDataIndex) { return; } mFlag |= TGuiNodeComponentTextFlag::TMeshDirtyPos; mArrayFontDataIndex.resize(0); for (GS32 index = 0; index < (GS32)in_arrayFontDataIndex.size(); ++index) { if (mMaxCharCount <= index) { break; } mArrayFontDataIndex.push_back(in_arrayFontDataIndex[index]); } return; } void GGuiNodeComponentText::UpdateMesh(GGui& inout_gui, GGuiNode& inout_node) { TPointerGuiFont pointerGuiFont = mFont.lock(); if (!mRenderMeshManual || !pointerGuiFont) { return; } GMeshManual& renderMeshManual = *mRenderMeshManual; GGuiFont& guiFont = *pointerGuiFont; float traceHorizontal = 0.0F; float traceVertical = guiFont.GetLineVerticalPad() * mScale; const GVector2Float& topLeft = inout_node.GetTransformScreenTopLeft(inout_gui); int vertexTrace = 0; const GColour4Float colour( mColour.m_red, mColour.m_green, mColour.m_blue, mColour.m_alpha * m_alpha ); for (TArrayInt::iterator iterator = mArrayFontDataIndex.begin(); iterator != mArrayFontDataIndex.end(); ++iterator) { const GGuiFontDataLoad* const pFontData = guiFont.GetIndexGliph(*iterator); if (!pFontData) { continue; } LocalAddFontData( renderMeshManual, vertexTrace, *pFontData, mScale, colour, topLeft + GVector2Float(traceHorizontal, traceVertical), inout_gui ); traceHorizontal += (pFontData->GetSize().m_x * mScale) + mHorizontalCharPad; } renderMeshManual.SetElementCount((vertexTrace / 4) * 6); return; }
bf584a245df192e4638d81a6b3285391c556cebe
97aa1181a8305fab0cfc635954c92880460ba189
/aten/src/TH/THStorageFunctions.cpp
2d58360a17c66088f92336a6ccb7ae39c429ae04
[ "BSD-2-Clause" ]
permissive
zhujiang73/pytorch_mingw
64973a4ef29cc10b96e5d3f8d294ad2a721ccacb
b0134a0acc937f875b7c4b5f3cef6529711ad336
refs/heads/master
2022-11-05T12:10:59.045925
2020-08-22T12:10:32
2020-08-22T12:10:32
123,688,924
8
4
NOASSERTION
2022-10-17T12:30:52
2018-03-03T12:15:16
C++
UTF-8
C++
false
false
2,407
cpp
THStorageFunctions.cpp
#include <climits> #include <c10/util/intrusive_ptr.h> #include <TH/THStorageFunctions.hpp> #include <TH/generic/THStorage.cpp> #include <TH/THGenerateAllTypes.h> #include <TH/generic/THStorage.cpp> #include <TH/THGenerateComplexTypes.h> #include <TH/generic/THStorage.cpp> #include <TH/THGenerateHalfType.h> #include <TH/generic/THStorage.cpp> #include <TH/THGenerateBoolType.h> #include <TH/generic/THStorage.cpp> #include <TH/THGenerateQTypes.h> #include <TH/generic/THStorage.cpp> #include <TH/THGenerateBFloat16Type.h> #include <TH/generic/THStorageCopy.cpp> #include <TH/THGenerateAllTypes.h> #include <TH/generic/THStorageCopy.cpp> #include <TH/THGenerateComplexTypes.h> #include <TH/generic/THStorageCopy.cpp> #include <TH/THGenerateHalfType.h> #include <TH/generic/THStorageCopy.cpp> #include <TH/THGenerateBoolType.h> #include <TH/generic/THStorageCopy.cpp> #include <TH/THGenerateQTypes.h> #include <TH/generic/THStorageCopy.cpp> #include <TH/THGenerateBFloat16Type.h> THStorage* THStorage_new() { THStorage* storage = c10::make_intrusive<at::StorageImpl>( c10::StorageImpl::use_byte_size_t(), 0, getTHDefaultAllocator(), true) .release(); return storage; } // Free a non-weak pointer to THStorage void THStorage_free(THStorage* storage) { if (!storage) { return; } c10::raw::intrusive_ptr::decref(storage); } void THStorage_retain(THStorage *storage) { if (storage) { c10::raw::intrusive_ptr::incref(storage); } } void THStorage_resizeBytes(THStorage* storage, ptrdiff_t size_bytes) { if (storage->resizable()) { /* case when the allocator does not have a realloc defined */ at::DataPtr new_data; if (size_bytes != 0) { new_data = storage->allocator()->allocate(size_bytes); } at::DataPtr old_data = storage->set_data_ptr(std::move(new_data)); ptrdiff_t old_capacity = storage->nbytes(); storage->set_nbytes(size_bytes); if (old_data != nullptr) { ptrdiff_t copy_capacity = old_capacity; if (storage->nbytes() < copy_capacity) { copy_capacity = storage->nbytes(); } if (copy_capacity > 0) { memcpy(storage->data(), old_data.get(), copy_capacity); } } } else { THError("Trying to resize storage that is not resizable"); } }
a2a8651b9e3086ba12830ff9a310ce6cc28f2d30
f3660c7c295b6f7d26cdb287015d710fe9637ed0
/src/226_invertBinaryTree.cpp
2c3e23e18e093d32ee9e033100ab1f6361304957
[]
no_license
freehawkzk/leetCode
d32e081cab2f772fc7b33056e228eb3709cb19f2
990019bf9eca7f619f69fe1157d7a0488f8a83c6
refs/heads/master
2021-01-10T11:47:44.846832
2020-09-14T07:14:01
2020-09-14T07:14:01
55,280,051
0
0
null
null
null
null
GB18030
C++
false
false
1,159
cpp
226_invertBinaryTree.cpp
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <bitset> #include <stack> #include <map> using namespace std; /************************************************************************/ /* * Invert a binary tree. * * 4 * / \ * 2 7 * / \ / \ * 1 3 6 9 * * to * * 4 * / \ * 7 2 * / \ / \ * 9 6 3 1 * * 分析 * 题目要求交换树中的所有左右子树节点。 */ /************************************************************************/ struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; TreeNode* invertTree(TreeNode* root) { if (root == NULL) { return NULL; } TreeNode* pT; pT = invertTree(root->right); root->right = invertTree(root->left); root->left = pT; return root; } int main() { TreeNode n1(1); TreeNode n2(2); TreeNode n3(3); TreeNode n4(4); TreeNode n6(6); TreeNode n7(7); TreeNode n9(9); n4.left = &n2; n4.right = &n7; n2.left = &n1; n2.right = &n3; n7.left = &n6; n7.right = &n9; TreeNode* pRoot = invertTree(&n4); return 0; }
3646be4989cfdd08e422f6d189ab310fbfefd79b
3cc352b29b8042b4a9746796b851d8469ff9ff62
/src/kmer_freq/FindKmerFrequencies.cc
61d3e6f209a72966f0c6e5020a4dc3bacb391978
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
CompRD/BroadCRD
1412faf3d1ffd9d1f9907a496cc22d59ea5ad185
303800297b32e993abd479d71bc4378f598314c5
refs/heads/master
2020-12-24T13:53:09.985406
2019-02-06T21:38:45
2019-02-06T21:38:45
34,069,434
4
0
null
null
null
null
UTF-8
C++
false
false
1,795
cc
FindKmerFrequencies.cc
///////////////////////////////////////////////////////////////////////////// // SOFTWARE COPYRIGHT NOTICE AGREEMENT // // This software and its documentation are copyright (2008) by the // // Broad Institute/Massachusetts Institute of Technology. All rights // // are reserved. This software is supplied without any warranty or // // guaranteed support whatsoever. Neither the Broad Institute nor MIT // // can be responsible for its use, misuse, or functionality. // ///////////////////////////////////////////////////////////////////////////// // Program: FindKmerFrequencies // // See Also: FindStrongKmers, FindGenomicKmers // // Find all the k-mers in a given fastb file and its reverse complement. // Output these kmers and their multiplicities, capped at 65535, optionally // excluding unique kmers. #include "MainTools.h" #include "kmer_freq/WriteKmerFrequencies.h" #include "kmers/KmerShape.h" int main( int argc, char *argv[] ) { RunTime( ); BeginCommandArguments; CommandArgument_KShape(K); CommandArgument_String_Doc(SEQS_IN, "Input fastb file from which to generate the kmer frequency table"); CommandArgument_String_OrDefault_Doc(KMER_FILE_OUT, "", "Ouput kmer freq table filename - otherwise append .freq_table.kn"); CommandArgument_Bool_OrDefault_Doc(INCLUDE_UNIQUE, True, "Include uniquely occuring kmers in frequency table"); EndCommandArguments; String kmerFile; if (KMER_FILE_OUT == "") kmerFile = SEQS_IN.SafeBefore(".fastb") + ".freq_table.k" + ToString(K); vecbasevector bases(SEQS_IN); cout << kmerFile << endl; #define CASE(_KSHAPE) \ WriteKmerFrequencies<_KSHAPE>(bases, kmerFile , INCLUDE_UNIQUE ) DISPATCH_ON_KSHAPE(K, CASE); }
0be7132dac853da5b4eeccdbc3158c2420b51407
98f1a0bfa5b20a0b81e9e555d76e706c62d949c9
/src/array/cpu/traversal.h
b593332746c192151126d36b5976e2c21b362d22
[ "Apache-2.0" ]
permissive
dmlc/dgl
3a8fbca3a7f0e9adf6e69679ad62948df48dfc42
bbc8ff6261f2e0d2b5982e992b6fbe545e2a4aa1
refs/heads/master
2023-08-31T16:33:21.139163
2023-08-31T07:49:22
2023-08-31T07:49:22
130,375,797
12,631
3,482
Apache-2.0
2023-09-14T15:48:24
2018-04-20T14:49:09
Python
UTF-8
C++
false
false
10,056
h
traversal.h
/** * Copyright (c) 2020 by Contributors * @file array/cpu/traversal.h * @brief Graph traversal routines. * * Traversal routines generate frontiers. Frontiers can be node frontiers or * edge frontiers depending on the traversal function. Each frontier is a list * of nodes/edges (specified by their ids). An optional tag can be specified for * each node/edge (represented by an int value). */ #ifndef DGL_ARRAY_CPU_TRAVERSAL_H_ #define DGL_ARRAY_CPU_TRAVERSAL_H_ #include <dgl/graph_interface.h> #include <stack> #include <tuple> #include <vector> namespace dgl { namespace aten { namespace impl { /** * @brief Traverse the graph in a breadth-first-search (BFS) order. * * The queue object must suffice following interface: * Members: * void push(IdType); // push one node * IdType top(); // get the first node * void pop(); // pop one node * bool empty(); // return true if the queue is empty * size_t size(); // return the size of the queue * For example, std::queue<IdType> is a valid queue type. * * The visit function must be compatible with following interface: * void (*visit)(IdType ); * * The frontier function must be compatible with following interface: * void (*make_frontier)(void); * * @param graph The graph. * @param sources Source nodes. * @param reversed If true, BFS follows the in-edge direction * @param queue The queue used to do bfs. * @param visit The function to call when a node is visited. * @param make_frontier The function to indicate that a new froniter can be * made; */ template < typename IdType, typename Queue, typename VisitFn, typename FrontierFn> void BFSTraverseNodes( const CSRMatrix &csr, IdArray source, Queue *queue, VisitFn visit, FrontierFn make_frontier) { const int64_t len = source->shape[0]; const IdType *src_data = static_cast<IdType *>(source->data); const IdType *indptr_data = static_cast<IdType *>(csr.indptr->data); const IdType *indices_data = static_cast<IdType *>(csr.indices->data); const int64_t num_nodes = csr.num_rows; std::vector<bool> visited(num_nodes); for (int64_t i = 0; i < len; ++i) { const IdType u = src_data[i]; visited[u] = true; visit(u); queue->push(u); } make_frontier(); while (!queue->empty()) { const size_t size = queue->size(); for (size_t i = 0; i < size; ++i) { const IdType u = queue->top(); queue->pop(); for (auto idx = indptr_data[u]; idx < indptr_data[u + 1]; ++idx) { auto v = indices_data[idx]; if (!visited[v]) { visited[v] = true; visit(v); queue->push(v); } } } make_frontier(); } } /** * @brief Traverse the graph in a breadth-first-search (BFS) order, returning * the edges of the BFS tree. * * The queue object must suffice following interface: * Members: * void push(IdType); // push one node * IdType top(); // get the first node * void pop(); // pop one node * bool empty(); // return true if the queue is empty * size_t size(); // return the size of the queue * For example, std::queue<IdType> is a valid queue type. * * The visit function must be compatible with following interface: * void (*visit)(IdType ); * * The frontier function must be compatible with following interface: * void (*make_frontier)(void); * * @param graph The graph. * @param sources Source nodes. * @param reversed If true, BFS follows the in-edge direction * @param queue The queue used to do bfs. * @param visit The function to call when a node is visited. * The argument would be edge ID. * @param make_frontier The function to indicate that a new frontier can be * made; */ template < typename IdType, typename Queue, typename VisitFn, typename FrontierFn> void BFSTraverseEdges( const CSRMatrix &csr, IdArray source, Queue *queue, VisitFn visit, FrontierFn make_frontier) { const int64_t len = source->shape[0]; const IdType *src_data = static_cast<IdType *>(source->data); const IdType *indptr_data = static_cast<IdType *>(csr.indptr->data); const IdType *indices_data = static_cast<IdType *>(csr.indices->data); const IdType *eid_data = static_cast<IdType *>(csr.data->data); const int64_t num_nodes = csr.num_rows; std::vector<bool> visited(num_nodes); for (int64_t i = 0; i < len; ++i) { const IdType u = src_data[i]; visited[u] = true; queue->push(u); } make_frontier(); while (!queue->empty()) { const size_t size = queue->size(); for (size_t i = 0; i < size; ++i) { const IdType u = queue->top(); queue->pop(); for (auto idx = indptr_data[u]; idx < indptr_data[u + 1]; ++idx) { auto e = eid_data ? eid_data[idx] : idx; const IdType v = indices_data[idx]; if (!visited[v]) { visited[v] = true; visit(e); queue->push(v); } } } make_frontier(); } } /** * @brief Traverse the graph in topological order. * * The queue object must suffice following interface: * Members: * void push(IdType); // push one node * IdType top(); // get the first node * void pop(); // pop one node * bool empty(); // return true if the queue is empty * size_t size(); // return the size of the queue * For example, std::queue<IdType> is a valid queue type. * * The visit function must be compatible with following interface: * void (*visit)(IdType ); * * The frontier function must be compatible with following interface: * void (*make_frontier)(void); * * @param graph The graph. * @param reversed If true, follows the in-edge direction * @param queue The queue used to do bfs. * @param visit The function to call when a node is visited. * @param make_frontier The function to indicate that a new froniter can be * made; */ template < typename IdType, typename Queue, typename VisitFn, typename FrontierFn> void TopologicalNodes( const CSRMatrix &csr, Queue *queue, VisitFn visit, FrontierFn make_frontier) { int64_t num_visited_nodes = 0; const IdType *indptr_data = static_cast<IdType *>(csr.indptr->data); const IdType *indices_data = static_cast<IdType *>(csr.indices->data); const int64_t num_nodes = csr.num_rows; const int64_t num_edges = csr.indices->shape[0]; std::vector<int64_t> degrees(num_nodes, 0); for (int64_t eid = 0; eid < num_edges; ++eid) { degrees[indices_data[eid]]++; } for (int64_t vid = 0; vid < num_nodes; ++vid) { if (degrees[vid] == 0) { visit(vid); queue->push(static_cast<IdType>(vid)); ++num_visited_nodes; } } make_frontier(); while (!queue->empty()) { const size_t size = queue->size(); for (size_t i = 0; i < size; ++i) { const IdType u = queue->top(); queue->pop(); for (auto idx = indptr_data[u]; idx < indptr_data[u + 1]; ++idx) { const IdType v = indices_data[idx]; if (--(degrees[v]) == 0) { visit(v); queue->push(v); ++num_visited_nodes; } } } make_frontier(); } if (num_visited_nodes != num_nodes) { LOG(FATAL) << "Error in topological traversal: loop detected in the given graph."; } } /** @brief Tags for ``DFSEdges``. */ enum DFSEdgeTag { kForward = 0, kReverse, kNonTree, }; /** * @brief Traverse the graph in a depth-first-search (DFS) order. * * The traversal visit edges in its DFS order. Edges have three tags: * FORWARD(0), REVERSE(1), NONTREE(2) * * A FORWARD edge is one in which `u` has been visisted but `v` has not. * A REVERSE edge is one in which both `u` and `v` have been visisted and the * edge is in the DFS tree. A NONTREE edge is one in which both `u` and `v` have * been visisted but the edge is NOT in the DFS tree. * * @param source Source node. * @param reversed If true, DFS follows the in-edge direction * @param has_reverse_edge If true, REVERSE edges are included * @param has_nontree_edge If true, NONTREE edges are included * @param visit The function to call when an edge is visited; the edge id and * its tag will be given as the arguments. */ template <typename IdType, typename VisitFn> void DFSLabeledEdges( const CSRMatrix &csr, IdType source, bool has_reverse_edge, bool has_nontree_edge, VisitFn visit) { const int64_t num_nodes = csr.num_rows; CHECK_GE(num_nodes, source) << "source " << source << " is out of range [0," << num_nodes << "]"; const IdType *indptr_data = static_cast<IdType *>(csr.indptr->data); const IdType *indices_data = static_cast<IdType *>(csr.indices->data); const IdType *eid_data = static_cast<IdType *>(csr.data->data); if (indptr_data[source + 1] - indptr_data[source] == 0) { // no out-going edges from the source node return; } typedef std::tuple<IdType, size_t, bool> StackEntry; std::stack<StackEntry> stack; std::vector<bool> visited(num_nodes); visited[source] = true; stack.push(std::make_tuple(source, 0, false)); IdType u = 0; int64_t i = 0; bool on_tree = false; while (!stack.empty()) { std::tie(u, i, on_tree) = stack.top(); const IdType v = indices_data[indptr_data[u] + i]; const IdType uv = eid_data ? eid_data[indptr_data[u] + i] : indptr_data[u] + i; if (visited[v]) { if (!on_tree && has_nontree_edge) { visit(uv, kNonTree); } else if (on_tree && has_reverse_edge) { visit(uv, kReverse); } stack.pop(); // find next one. if (indptr_data[u] + i < indptr_data[u + 1] - 1) { stack.push(std::make_tuple(u, i + 1, false)); } } else { visited[v] = true; std::get<2>(stack.top()) = true; visit(uv, kForward); // expand if (indptr_data[v] < indptr_data[v + 1]) { stack.push(std::make_tuple(v, 0, false)); } } } } } // namespace impl } // namespace aten } // namespace dgl #endif // DGL_ARRAY_CPU_TRAVERSAL_H_
50c199d275c7325240022357eaa300894f29f54f
3d3080ad2cb363065cc2bc2871403069cd2fe2e4
/Competitive Programming/Musical Chairs/main.cpp
4222f1af637b10fa47ac381d572afaccc2a56fb3
[]
no_license
Jacky-He/Competitive-Programming
e741fe79e3adcf0e7286fec49294effa2439b006
74050876175cfba7cc0274fef15d070bc80f771c
refs/heads/master
2020-11-24T17:27:13.033791
2020-01-03T18:36:16
2020-01-03T18:36:16
228,261,428
0
0
null
null
null
null
UTF-8
C++
false
false
1,086
cpp
main.cpp
#include <bits/stdc++.h> using namespace std; int n, k; int empty, student; int state [1000003]; //-1: empty, 0: nothing: 1: student stack <int> students; int lookup [1000003]; int studentcnt; int main () { scanf ("%d%d", &n, &k); studentcnt = k + 1; for (int x = 0; x < k; x++) { scanf ("%d", &empty); state [empty] = -1; } for (int x = 0; x < k + 1; x++) { scanf ("%d", &student); if (state [student] == -1) { state [student] = 0; studentcnt--; } else { state [student] = 1; lookup [student] = x + 1; } } int index = 1; while (studentcnt > 1) { if (state [index] == 1) { state [index] = 0; students.push(index); } if (state [index] == -1 && !students.empty()) { state [index] = 0; students.pop(); studentcnt--; } index = index%n + 1; } printf ("%d\n", lookup [students.top()]); return 0; }
67fdbc5a6de8f787cb530b4fb1f1e57da7f9b4c2
e75b113f11669324d51faf879ab562357c929d08
/game/src/mge/behaviours/PlayerBehaviour.cpp
957b87b9209ea16112374afb7a9205c12cda0b7b
[]
no_license
jeremy-coleman/HastyHarry
0524d4538b14c2545e909c7d75b5d17143358712
f44010e5dfcd616a9333520a804b879e79e7520c
refs/heads/master
2021-05-30T17:25:50.413870
2016-03-18T01:19:48
2016-03-18T01:19:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,518
cpp
PlayerBehaviour.cpp
#include <typeinfo> #include "mge/behaviours/PlayerBehaviour.hpp" #include "mge/behaviours/SoundBehaviour.hpp" #include "mge/core/GameObject.hpp" #include "mge/core/Camera.hpp" #include <sfml/window/event.hpp> #include <iostream> #include "..\..\include\tokamak.h" #include <glm/gtx/matrix_decompose.hpp> #include <SFML/window.hpp> #include "mge/PlayerControllerCB.hpp" #include "mge/core/World.hpp" #include "mge/core/GameObject.hpp" #include "SFML/Audio.hpp" #include "mge/util/Utility.hpp" #include "mge/config.hpp" #include "mge/core/Mesh.hpp" #include "mge/core/SoundEngine.hpp" #include "mge/core/Level.hpp" #include "mge/core/Timer.hpp" #include "mge/materials/ColorMaterial.hpp" #include "mge/behaviours/MoveSwitch.hpp" #include "mge/behaviours/RotateSwitch.hpp" #include "mge/behaviours/DeleteSwitch.hpp" //Constants needed fot the player controller #define WALLRUN_GRAVITY -5.0f #define NORMAL_GRAVITY -10.0f #define HARD_INERTIA 0.75f #define SOFT_INERTIA 0.975f #define MOVE_FORCE 240.0f #define RUN_MAXVELOCITY 15.0f #define WALK_MAXVELOCITY 8.0f #define AIR_CONTROLL 0.1f #define AIR_MAXVELOCITY 16.5f #define GROUND_JUMP_FORCE 5.5f #define WALLJUMP_NORMALFORCE 10.0f #define WALLJUMP_UPFORCE 5.0f #define WALLJUMP_FORWARDFORCE 0.0f #define ROTATE_SPEED 6.0f #define SLOW_FEEDBACK_RADIUS 4.0f #define SLOW_FEEDBACK_TIMER 11.0f #define DEATH_HEIGHT -40.0f #define RESPAWN_TIME 4.0f PlayerBehaviour::PlayerBehaviour(Camera* pCamera) : AbstractBehaviour() { _camera = pCamera; _prevMousePos = sf::Mouse::getPosition(); } PlayerBehaviour::~PlayerBehaviour() { _enemies.clear(); delete _raycastCube; } void PlayerBehaviour::Initialize() { _lastPosition = _owner->getPosition(); SpawnPos = _owner->getPosition(); f32 mass = 65.0f; f32 diameter = 2.0f; //Request a rigidbody from Physicsworld if (_owner->getRigidBody() != NULL) _owner->GetWorld()->getPhysics()->FreeRigidBody(_owner->getRigidBody()); neRigidBody* rigidBody = _owner->GetWorld()->getPhysics()->CreateRigidBody(); rigidBody->GravityEnable(false); //Add geometry to it and set it up neGeometry* geometry = rigidBody->AddGeometry(); geometry->SetSphereDiameter(diameter); //Create material and apply it _owner->GetWorld()->getPhysics()->SetMaterial(0, 100000000.0f, 0.0f); geometry->SetMaterialIndex(0); //Add a sensor for groundcheck { neSensor* sensor; neV3 sensorPos, sensorDir; sensorPos.Set(0.0f, 0.0f, 0.0f); sensorDir.Set(0.0f, -1.1f, 0.0f); sensor = rigidBody->AddSensor(); sensor->SetLineSensor(sensorPos, sensorDir); sensor->SetUserData('g'); } //TODO Place more ground sensors //Add sensors for Wall check { glm::vec3 sensorDir = glm::vec3(0, -2.5, 1.0); sensorDir = glm::normalize(sensorDir) * 1.2f; int sensorCount = 8; for (int i = 0; i < sensorCount; ++i) { neSensor* sensor; neV3 sensorPos; sensorPos.Set(0.0f, 0.0f, 0.0f); sensor = rigidBody->AddSensor(); sensor->SetLineSensor(sensorPos, Utility::glmToNe(sensorDir)); sensorDir = glm::rotateY(sensorDir, glm::radians(360.0f / sensorCount)); sensor->SetUserData('g'); } } //Add a sensor for Ceilcheck { neSensor* sensor; neV3 sensorPos, sensorDir; sensorPos.Set(0.0f, 0.0f, 0.0f); sensorDir.Set(0.0f, 1.01f, 0.0f); sensor = rigidBody->AddSensor(); sensor->SetLineSensor(sensorPos, sensorDir); sensor->SetUserData('c'); } //Add a sensor for raycast { neSensor* sensor; sensor = rigidBody->AddSensor(); glm::vec3 vecDir = _camera->getLocalForwardVector(); vecDir.z = -vecDir.z; vecDir = glm::normalize(vecDir) * 100.0f; sensor->SetLineSensor(Utility::glmToNe(_camera->getLocalPosition()), Utility::glmToNe(vecDir * 100)); sensor->SetUserData('r'); } //Add sensors for Wall check glm::vec3 sensorDir = glm::vec3(0, 0, 1.2); int sensorCount = 8; for (int i = 0; i < sensorCount; ++i) { neSensor* sensor; neV3 sensorPos; sensorPos.Set(0.0f, 0.0f, 0.0f); sensor = rigidBody->AddSensor(); sensor->SetLineSensor(sensorPos, Utility::glmToNe(sensorDir)); sensorDir = glm::rotateY(sensorDir, glm::radians(360.0f / sensorCount)); sensor->SetUserData('w'); } //Add a controller callback neRigidBodyController* controller; controller = rigidBody->AddController(&_playerControllerCB, 0); //Update dat Bounds rigidBody->UpdateBoundingInfo(); //Set Physics Propertys rigidBody->SetInertiaTensor(neSphereInertiaTensor(diameter, mass)); rigidBody->SetMass(mass); rigidBody->SetUserData((u32)this); //Parse pos and rot info to Tokamak glm::quat rot = _owner->getRotation();; neQ nRot; nRot.Set(rot.x, rot.y, rot.z, rot.w); rigidBody->SetPos(Utility::glmToNe(_owner->getPosition())); rigidBody->SetRotation(nRot); //Set the created rigidbody as the players rigidbody _owner->setRigidBody(rigidBody); //Set Camera as child and set position _camera->setParent(_owner); _camera->setLocalPosition(glm::vec3(0, 0.8, 0)); //Set audio listener volume sf::Listener::setGlobalVolume(100.0f); _raycastCube = new GameObject(""); Level::CurrentWorld->add(_raycastCube); _raycastCube->setMesh(Mesh::load(config::MGE_MODEL_PATH + "cube.obj")); _raycastCube->setMaterial(new ColorMaterial(glm::vec3(1, 0, 1))); _raycastCube->scale(glm::vec3(0.1f, 0.1f, 0.1f)); } void PlayerBehaviour::PlayerController(neRigidBodyController* pController, float pStep) { bool _landed = !_grounded; _moving = false; _grounded = false; _walled = false; //_owner->setParent(Level::CurrentWorld); _mouseDelta = _mouseDelta * pStep * ROTATE_SPEED; _angleY += _mouseDelta.x / 90.0f; neM3 rotationMatrixY; rotationMatrixY[0].Set(cos(_angleY), 0.0f, sin(_angleY)); rotationMatrixY[1].Set(0.0f, 1.0f, 0.0f); rotationMatrixY[2].Set(-sin(_angleY), 0.0f, cos(_angleY)); pController->GetRigidBody()->SetRotation(rotationMatrixY); //Camera rotation locked glm::vec3 camFor = _camera->getForwardVector() * -1.f; glm::vec3 bodyFor = _owner->getForwardVector(); bool camGreater = camFor.y > bodyFor.y ? true : false; if (camGreater) { if (glm::abs(glm::dot(bodyFor, camFor)) > 0.1) { _camera->rotate(glm::radians(-_mouseDelta.y), glm::vec3(1, 0, 0)); } else if (-_mouseDelta.y < 0.0f) _camera->rotate(glm::radians(-_mouseDelta.y), glm::vec3(1, 0, 0)); } else { if (glm::abs(glm::dot(bodyFor, camFor)) > 0.1) { _camera->rotate(glm::radians(-_mouseDelta.y), glm::vec3(1, 0, 0)); } else if (-_mouseDelta.y > 0.0f) _camera->rotate(glm::radians(-_mouseDelta.y), glm::vec3(1, 0, 0)); } //Sensor reading pController->GetRigidBody()->BeginIterateSensor(); neSensor* sensor; std::vector<glm::vec3> wallNormals; while (sensor = pController->GetRigidBody()->GetNextSensor()) { if (sensor->GetUserData() == 'g' && sensor->GetDetectDepth() > 0.0f) { if (_landed) { SoundEngine::PlayAudio("land", _owner); } _grounded = true; //_owner->setParent((GameObject*)sensor->GetDetectAnimatedBody()->GetUserData()); } else if (sensor->GetUserData() == 'c') { if (sensor->GetDetectDepth() > 0.0f && !_gravityReset) { //std::cout << "Reset: " << pStep << std::endl; _physicsVelocity.y = 0.0f; _gravityReset = true; } else if(sensor->GetDetectDepth() <= 0.0f) { //std::cout << "No Ceiling: " << sensor->GetDetectDepth() << std::endl; _gravityReset = false; } } else if (sensor->GetUserData() == 'w' && sensor->GetDetectDepth() > 0.0f) { //TODO Make sure the object is actually a wall _walled = true; wallNormals.push_back(Utility::neToGlm(sensor->GetDetectNormal())); } else if (sensor->GetUserData() == 'r') { _raycastCube->setLocalPosition(Utility::neToGlm(sensor->GetDetectContactPoint())); glm::vec3 vecDir = -_camera->getLocalForwardVector(); vecDir = glm::normalize(vecDir) * 100.0f; sensor->SetLineSensor(Utility::glmToNe(_camera->getLocalPosition()), Utility::glmToNe(vecDir)); if (!Timer::IsPaused() && !_holdingShoot && sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) && sensor->GetDetectDepth() > 0.0f) { GameObject* object = (GameObject*)sensor->GetDetectAnimatedBody()->GetUserData(); for (int i = 0; i < object->BehaviourCount(); i++) { MoveSwitch* moveS = dynamic_cast<MoveSwitch*>(object->getBehaviour(i)); if (moveS) { moveS->trigger(); } RotateSwitch* rotateS = dynamic_cast<RotateSwitch*>(object->getBehaviour(i)); if (rotateS) { rotateS->trigger(); } DeleteSwitch* deleteS = dynamic_cast<DeleteSwitch*>(object->getBehaviour(i)); if (deleteS) { deleteS->trigger(); } //object->getBehaviour(i)->trigger(Level::CurrentPlayer); //const char * s = "MoveSwitch"; //const char * b = typeid(object->getBehaviour(i)).name(); //if (strcmp(s, b)) { //object->getBehaviour(i)->trigger(Level::CurrentPlayer); //} } //delete (object); } _holdingShoot = sf::Mouse::isButtonPressed(sf::Mouse::Button::Left); } } //Group the wallnormals std::vector<glm::vec3> groupedWallNormals; for (std::vector<glm::vec3>::iterator it = wallNormals.begin(); it != wallNormals.end(); ++it) { bool notGroupedYet = false; if (groupedWallNormals.size() == 0) { notGroupedYet = true; } else { for (std::vector<glm::vec3>::iterator it2 = groupedWallNormals.begin(); it2 != groupedWallNormals.end(); ++it2) { if (!(*it == *it2)) { notGroupedYet = true; } } } if (notGroupedYet) { groupedWallNormals.push_back(*it); } } //Get the best candidate for wallrunning glm::vec3 potentialNormal; if (_walled) { float potentialDot = 1.0f; for (std::vector<glm::vec3>::iterator it = groupedWallNormals.begin(); it != groupedWallNormals.end(); ++it) { float dot = glm::dot((*it), _owner->getForwardVector()); if (abs(dot) < potentialDot) { potentialNormal = (*it); } } } //Reset WallJumped Flag if (_grounded || _walled && _falling) { _wallJumped = false; } //Apply Jump force _jumpVelocity = glm::vec3(0, 0, 0); if (!_holdingJump && sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { if (_grounded) { _jumpVelocity.y = GROUND_JUMP_FORCE; SoundEngine::PlayVoice("jump"); } else if (_walled && !_wallJumped) { //TODO Revise Walljump _jumpVelocity.y = WALLJUMP_UPFORCE; _moveVelocity += -_camera->getForwardVector() * WALLJUMP_FORWARDFORCE + potentialNormal * WALLJUMP_NORMALFORCE; _moveVelocity.y = 0.0f; _wallJumped = true; } } _holdingJump = sf::Keyboard::isKeyPressed(sf::Keyboard::Space); //Get Inputs _inputVector = glm::vec3(0, 0, 0); if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) { _inputVector -= glm::vec3(_owner->getForwardVector().x, 0.0f, _owner->getForwardVector().z); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) { _inputVector += glm::vec3(_owner->getForwardVector().x, 0.0f, _owner->getForwardVector().z); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) { _inputVector += glm::vec3(_owner->getRightVector().x, 0.0f, _owner->getRightVector().z); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { _inputVector -= glm::vec3(_owner->getRightVector().x, 0.0f, _owner->getRightVector().z); } //See if walking _walking = sf::Keyboard::isKeyPressed(sf::Keyboard::LShift); //Apply proper acceleration if (glm::length2(_inputVector) > 0.0f) { _moveVelocity += glm::normalize(_inputVector) * (_grounded ? MOVE_FORCE : MOVE_FORCE * AIR_CONTROLL) * pStep; _moving = true; } else if(_grounded){ _moveVelocity *= HARD_INERTIA; } else if (!_grounded) { _moveVelocity *= SOFT_INERTIA; } //Clamp the moveVelocity if (glm::length2(_moveVelocity) > (_grounded ? ((_walking && !_walled) ? WALK_MAXVELOCITY * WALK_MAXVELOCITY : RUN_MAXVELOCITY * RUN_MAXVELOCITY) : AIR_MAXVELOCITY * AIR_MAXVELOCITY)) { _moveVelocity = glm::normalize(_moveVelocity) * ((_grounded && !_walled) ? (_walking ? WALK_MAXVELOCITY : RUN_MAXVELOCITY) : AIR_MAXVELOCITY); } //TODO Implement that the player cant wallrun backwards //Remove Wallnormals from move Velocity for (std::vector<glm::vec3>::iterator it = groupedWallNormals.begin(); it != groupedWallNormals.end(); ++it) { float dot = glm::dot((*it), _moveVelocity); if (_grounded && dot < 0.0f || _wallJumped && dot < 0.0f || !_grounded && !_wallJumped) { _moveVelocity -= (*it) * dot; } } //See if falling _falling = _physicsVelocity.y < 0.0f; //Apply Gravity _physicsVelocity += _jumpVelocity; if (_walled && !_grounded && _falling) { _physicsVelocity += glm::vec3(0, WALLRUN_GRAVITY, 0) * pStep; } else if(!_grounded) { _physicsVelocity += glm::vec3(0, NORMAL_GRAVITY, 0) * pStep; } else if (_grounded && _falling) { _physicsVelocity = glm::vec3(0, 0, 0); } if (!Timer::IsPaused()) { //std::cout << "P: " << glm::round(_physicsVelocity) << " J: " << glm::round(_jumpVelocity) << " M: " << glm::round(_moveVelocity) << " R: " << glm::round(_moveVelocity + _jumpVelocity + _physicsVelocity) << std::endl; std::cout << "G: " << _grounded << " W: " << _walled << " F: " << _falling << " J: " << _wallJumped << std::endl; } //Apply the velocity pController->GetRigidBody()->SetVelocity(Utility::glmToNe(_moveVelocity + _physicsVelocity)); //Apply too slow feedback if (glm::length2(_lastPosition - _owner->getPosition()) > SLOW_FEEDBACK_RADIUS * SLOW_FEEDBACK_RADIUS) { _lastPosition = _owner->getPosition(); _slowFeedbackTimer = 0.0f; } else { _slowFeedbackTimer += pStep; if (_slowFeedbackTimer >= SLOW_FEEDBACK_TIMER) { _slowFeedbackTimer = 0.0f; SoundEngine::PlayVoice("slow_feedback"); } } //Apply Falling feedback if (_owner->getPosition().y < DEATH_HEIGHT) { _respawnTimer += pStep; if (!_dead) { _dead = true; SoundEngine::PlayVoice("fall"); } else if(_respawnTimer >= RESPAWN_TIME) { SoundEngine::PlayVoice("fall_feedback"); _physicsVelocity = glm::vec3(0,0,0); _moveVelocity = glm::vec3(0,0,0); pController->GetRigidBody()->SetVelocity(Utility::glmToNe(glm::vec3(0,0,0))); pController->GetRigidBody()->SetPos(Utility::glmToNe(SpawnPos)); _respawnTimer = 0.0f; _dead = false; } } } void PlayerBehaviour::update(float pStep) { //Calculate the mouse Vector _currMousePos = sf::Mouse::getPosition(); _mouseDelta = glm::vec2(_currMousePos.x, _currMousePos.y) - glm::vec2(_prevMousePos.x, _prevMousePos.y); //Keep the mouse from leaving the center if (!Timer::IsPaused()) { int screenHeight = sf::VideoMode::getDesktopMode().height; int screenWidth = sf::VideoMode::getDesktopMode().width; sf::Mouse::setPosition(sf::Vector2i(screenWidth / 2, screenHeight / 2)); } //Update previous mouse position _prevMousePos = sf::Mouse::getPosition(); //Updating the audio listener pos and dir sf::Listener::setPosition(_owner->getWorldPosition().x, _owner->getWorldPosition().y, _owner->getWorldPosition().z); sf::Listener::setDirection(_owner->getForwardVector().x, _owner->getForwardVector().y, -_owner->getForwardVector().z); sf::Listener::setUpVector(_camera->getUpVector().x, _camera->getUpVector().y, _camera->getUpVector().z); //Pause if (!_holdingPause && sf::Keyboard::isKeyPressed(sf::Keyboard::Key::P)) { Timer::TogglePause(); } _holdingPause = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::P); //Slowmotion if (!_holdingSlowmotion && sf::Mouse::isButtonPressed(sf::Mouse::Button::Right)) { Timer::Slowmotion = !Timer::Slowmotion; } _holdingSlowmotion = sf::Mouse::isButtonPressed(sf::Mouse::Button::Right); }
b607772b8e74727ad5830914a6e42172d0554238
4145500714b175cd40f6ecbd215635b5b859241f
/engine/XEffeEngine/XMedia/XMicrophone.h
161c6e3dbb5424981cfa40f04d91568da432dab8
[]
no_license
QiangJi/XEffect2D
3fbb1e5f1a3a7c94f9d1ab3abb57943fa9da7b62
bf7224542d8bb48de19b15a0b06a094bc78bd9f5
refs/heads/master
2020-12-13T12:52:53.945387
2014-04-22T08:45:37
2014-04-22T08:45:37
null
0
0
null
null
null
null
GB18030
C++
false
false
2,118
h
XMicrophone.h
#ifndef _JIA_XMICROPHONE_ #define _JIA_XMICROPHONE_ #include "al.h" #include "alc.h" #include "stdlib.h" #include "XBasicFun.h" //++++++++++++++++++++++++++++++++ //Author: 贾胜华(JiaShengHua) //Version: 1.0.0 //Date: 2013.3.15 //-------------------------------- //下面是一个关于录音设备的类 基于OpenAL enum _XCaptureState { CAPTURE_STATE_STOP, //录音设备停止 CAPTURE_STATE_START, //录音设备开始工作 }; #pragma comment(lib, "../lib/Alut/alut.lib") #pragma comment(lib, "../lib/OpenAL/Win32/OpenAL32.lib") class _XMicrophone { private: _XBool m_isInited; //是否进行初始化 ALCdevice * m_pCaptureDev; //录音设备的指针 ALCuint m_frequency; //音频的频率 ALCenum m_format; //音频的格式 ALCsizei m_buffersize; //音频的缓存空间大小 _XCaptureState m_captureState; //录音设备的状态 unsigned char *m_captureData; //麦克风录音的内容 int m_dataBuffMaxSize; //缓存的最大尺寸 int m_nowDataBuffSize; //当前有效的缓存尺寸 int m_byteRate; //一次采样的字节数 public: _XCaptureState getCaptureState() const {return m_captureState;} void printAllCaptureDevice(); //显示所有的录音设备 _XBool openDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); //打开设备 void captureStart() const //设置开始录音 { if(m_captureState == CAPTURE_STATE_STOP && m_isInited) alcCaptureStart(m_pCaptureDev); } void captureStop() const //设置停止录音 { if(m_captureState == CAPTURE_STATE_START && m_isInited) alcCaptureStop(m_pCaptureDev); } unsigned char * getCaptureData(int * size = NULL); //读取采样数据 int getByteRate() const {return m_byteRate;} void release() { if(!m_isInited) return; alcMakeContextCurrent(NULL); alcCaptureCloseDevice(m_pCaptureDev); XDELETE_ARRAY(m_captureData); m_isInited = XFalse; } _XMicrophone() :m_pCaptureDev(NULL) ,m_captureState(CAPTURE_STATE_STOP) ,m_isInited(XFalse) ,m_captureData(NULL) ,m_byteRate(1) { } ~_XMicrophone() { release(); } }; #endif