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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
265bd5ad26a8a9132a8c86d54b07b5d5cb0f1df3 | 485a772cc4978fa7711d2680356035b64919c8c3 | /even odd extraction.cpp | 9998473c3248b667b5214be10fbe263b8480fa56 | [] | no_license | saidur301297/C-Programming | 5eec970966be450c3d0ba7ddb4c79552d5c081e2 | 82c4ed07071df7b120f916fe86791a113f887bf3 | refs/heads/master | 2020-08-06T23:38:59.028871 | 2019-10-11T12:19:52 | 2019-10-11T12:19:52 | 213,202,430 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 762 | cpp | even odd extraction.cpp | #include<iostream>
using namespace std;
int main()
{
int n,i;
cout<<"Please enter a positive number:";
cin>>n;
cout<<"Enter " <<n<<" elements:";
int array[n];
for(i=0;i<n;i++)
cin>>array[i];
int even[n],odd[n],j=0,k=0;
for(i=0;i<n;i++)
if(array[i]%2==0)
even[j++]=array[i];
else
odd[k++]=array[i];
cout<<"Even array elements are: ";
for(i=0;i<j;i++)
cout<<even[i]<<" ";
cout<<"\nOdd array elements are: ";
for(i=0;i<k;i++)
cout<<odd[i]<<" ";
}
|
299507f6da2c20a2fa6e02af2a53ba10053884c1 | 615deed644c7a6e596e0af0fc10e34a8c5ee077c | /transaction/tests/StronglyConnectedComponents_unittest.cpp | e9bc3a3359d9f19c644b0f22aaa8e0fe67153499 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause"
] | permissive | UWQuickstep/quickstep | 796bddff114b5b66b29f290a92e75461e7cb1bad | 1a34cf8cd0b069286d0193b4d134bd9fa9168752 | refs/heads/master | 2022-05-02T12:19:25.337874 | 2022-04-15T09:30:48 | 2022-04-15T09:30:48 | 155,096,119 | 32 | 9 | Apache-2.0 | 2021-08-20T01:48:32 | 2018-10-28T17:20:54 | C++ | UTF-8 | C++ | false | false | 7,621 | cpp | StronglyConnectedComponents_unittest.cpp | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
#include "transaction/StronglyConnectedComponents.hpp"
#include <cstddef>
#include <cstdint>
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>
#include "transaction/DirectedGraph.hpp"
#include "transaction/Transaction.hpp"
#include "gtest/gtest.h"
namespace quickstep {
namespace transaction {
class GraphConfiguration {
public:
GraphConfiguration(DirectedGraph *graph,
const std::size_t num_transactions,
const std::vector<std::pair<transaction_id,
transaction_id>> &mapping)
: graph_(graph) {
for (std::size_t index = 0; index < num_transactions; ++index) {
const transaction_id transaction = static_cast<transaction_id>(index);
transaction_list_.push_back(transaction);
const DirectedGraph::node_id nid = graph->addNodeUnchecked(transaction);
node_id_list_.push_back(nid);
}
for (const std::pair<transaction_id, transaction_id> &edge : mapping) {
const transaction_id pending = edge.first;
const transaction_id owner = edge.second;
graph_->addEdgeUnchecked(pending, owner);
}
}
const std::vector<DirectedGraph::node_id>& getNodesList() const {
return node_id_list_;
}
private:
std::vector<transaction_id> transaction_list_;
std::vector<DirectedGraph::node_id> node_id_list_;
DirectedGraph *graph_;
};
class StronglyConnectedComponentsTestWithOneNode : public testing::Test {
protected:
StronglyConnectedComponentsTestWithOneNode() {
wait_for_graph_.reset(new DirectedGraph());
std::vector<std::pair<transaction_id, transaction_id>> edge_mapping;
// Configure the graph with just 1 node.
graph_configuration_ =
std::make_unique<GraphConfiguration>(wait_for_graph_.get(),
1,
edge_mapping);
scc_ = std::make_unique<StronglyConnectedComponents>(*wait_for_graph_);
}
std::unique_ptr<GraphConfiguration> graph_configuration_;
std::unique_ptr<DirectedGraph> wait_for_graph_;
std::unique_ptr<StronglyConnectedComponents> scc_;
};
class StronglyConnectedComponentsTestWithTwoNodesCycle : public testing::Test {
protected:
StronglyConnectedComponentsTestWithTwoNodesCycle() {
wait_for_graph_.reset(new DirectedGraph());
// Create 2 nodes with cycle.
std::vector<std::pair<transaction_id, transaction_id>> edge_mapping =
{{0, 1},
{1, 0}};
graph_configuration_ =
std::make_unique<GraphConfiguration>(wait_for_graph_.get(),
2,
edge_mapping);
// Run the SCC algorithm.
scc_ = std::make_unique<StronglyConnectedComponents>(*wait_for_graph_);
}
std::unique_ptr<GraphConfiguration> graph_configuration_;
std::unique_ptr<DirectedGraph> wait_for_graph_;
std::unique_ptr<StronglyConnectedComponents> scc_;
};
class StronglyConnectedComponentsTest : public testing::Test {
protected:
StronglyConnectedComponentsTest() {
// Prepare the graph.
wait_for_graph_.reset(new DirectedGraph());
// Create edges.
std::vector<std::pair<transaction_id, transaction_id>> edge_mapping =
{{0, 1},
{1, 2}, {1, 3}, {1, 4},
{2, 5},
{3, 4}, {3, 6},
{4, 1}, {4, 5}, {4, 6},
{5, 2}, {5, 7},
{6, 7}, {6, 9},
{7, 6},
{8, 6},
{9, 8}, {9, 10},
{10, 11}, {11, 9}};
// Configure the graph.
graph_configuration_ =
std::make_unique<GraphConfiguration>(wait_for_graph_.get(),
12,
edge_mapping);
// Run the SCC algorithm.
scc_ = std::make_unique<StronglyConnectedComponents>(*wait_for_graph_);
}
std::unique_ptr<GraphConfiguration> graph_configuration_;
std::unique_ptr<DirectedGraph> wait_for_graph_;
std::unique_ptr<StronglyConnectedComponents> scc_;
};
TEST_F(StronglyConnectedComponentsTestWithOneNode, TotalNumberOfComponents) {
std::uint64_t total_components = scc_->getTotalComponents();
EXPECT_EQ(1u, total_components);
}
TEST_F(StronglyConnectedComponentsTestWithOneNode, GetComponentId) {
std::uint64_t nid0_component =
scc_->getComponentId(graph_configuration_->getNodesList()[0]);
EXPECT_EQ(0u, nid0_component);
}
TEST_F(StronglyConnectedComponentsTestWithOneNode, GetComponentsMapping) {
std::unordered_map<std::uint64_t, std::vector<DirectedGraph::node_id>>
mapping = scc_->getComponentMapping();
std::vector<DirectedGraph::node_id> component_no_0 = mapping[0];
EXPECT_EQ(1u, component_no_0.size());
}
TEST_F(StronglyConnectedComponentsTestWithTwoNodesCycle, TotalNumberOfComponents) {
std::uint64_t total_components = scc_->getTotalComponents();
EXPECT_EQ(1u, total_components);
}
TEST_F(StronglyConnectedComponentsTestWithTwoNodesCycle, GetComponentId) {
DirectedGraph::node_id nid0 = DirectedGraph::node_id(0);
DirectedGraph::node_id nid1 = DirectedGraph::node_id(1);
// Since two nodes make a cycle, they should have same component id.
EXPECT_EQ(0u, scc_->getComponentId(nid0));
EXPECT_EQ(0u, scc_->getComponentId(nid1));
}
TEST_F(StronglyConnectedComponentsTestWithTwoNodesCycle, GetComponentsMapping) {
std::unordered_map<std::uint64_t, std::vector<DirectedGraph::node_id>>
mapping = scc_->getComponentMapping();
std::vector<DirectedGraph::node_id> component_no_0 = mapping[0];
// Since there are 2 nodes, and they are in the same SC component,
// the component size is 2.
EXPECT_EQ(2u, component_no_0.size());
}
TEST_F(StronglyConnectedComponentsTest, TotalNumberOfComponents) {
std::size_t total_components = scc_->getTotalComponents();
EXPECT_EQ(4u, total_components);
}
TEST_F(StronglyConnectedComponentsTest, GetComponentId) {
std::vector<DirectedGraph::node_id> nid_list;
for (DirectedGraph::node_id nid = 0;
nid < wait_for_graph_->getNumNodes();
++nid) {
nid_list.push_back(scc_->getComponentId(nid));
}
EXPECT_EQ(12u, nid_list.size());
// Check the result are as expected.
const std::vector<std::uint64_t> expected_components_ids =
{3, 2, 1, 2, 2, 1, 0, 0, 0, 0, 0, 0};
for (std::size_t i = 0; i < expected_components_ids.size(); ++i) {
EXPECT_EQ(expected_components_ids[i], nid_list[i]);
}
}
TEST_F(StronglyConnectedComponentsTest, GetComponentsMapping) {
std::unordered_map<std::uint64_t, std::vector<DirectedGraph::node_id>>
mapping = scc_->getComponentMapping();
// Check the components' size are OK.
EXPECT_EQ(6u, mapping[0].size());
EXPECT_EQ(2u, mapping[1].size());
EXPECT_EQ(3u, mapping[2].size());
EXPECT_EQ(1u, mapping[3].size());
}
} // namespace transaction
} // namespace quickstep
|
78a4c9e9e6dd14f9ab5b00cfb7d570a5c77d2154 | 759c6913ebc844e031470b2c9309932f0b044e33 | /VisualizationBase/src/declarative/GridLayoutFormElement.cpp | 74231b7a4727eaa5d6403d80b27b5904c8a20477 | [
"BSD-3-Clause"
] | permissive | patrick-luethi/Envision | 7a1221960ad1adde2e53e83359992d5e6af97574 | 9104d8a77e749a9f00ff5eef52ff4a1ea77eac88 | refs/heads/master | 2021-01-15T11:30:56.335586 | 2013-05-30T08:51:05 | 2013-05-30T08:51:05 | 15,878,040 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,607 | cpp | GridLayoutFormElement.cpp | /***********************************************************************************************************************
**
** Copyright (c) 2011, 2013 ETH Zurich
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
** following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice, this list of conditions and the
** following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
** following disclaimer in the documentation and/or other materials provided with the distribution.
** * Neither the name of the ETH Zurich nor the names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
**********************************************************************************************************************/
#include "GridLayoutFormElement.h"
#include "../items/ItemRegion.h"
#include "../cursor/LayoutCursor.h"
namespace Visualization {
GridLayoutFormElement::GridLayoutFormElement()
: numColumns_(1), numRows_(1), spaceBetweenColumns_{}, spaceBetweenRows_{}, lastCell_{QPair<int, int>(0, 0)},
defaultHorizontalAlignment_{LayoutStyle::Alignment::Left}, defaultVerticalAlignment_{LayoutStyle::Alignment::Top},
defaultColumnStretchFactor_{0}, defaultRowStretchFactor_{0}
{
// initialize element grid
elementGrid_ = QVector<QVector<FormElement*>>(numColumns_, QVector<FormElement*>(numRows_));
// initialize span grid
spanGrid_ = QVector<QVector<QPair<int, int>>>(numColumns_,QVector<QPair<int, int>>(numRows_, QPair<int, int>(1, 1)));
// initialize alignments
defaultColumnHorizontalAlignments_ = QVector<LayoutStyle::Alignment>(numColumns_, defaultVerticalAlignment_);
defaultRowVerticalAlignments_ = QVector<LayoutStyle::Alignment>(numRows_, defaultHorizontalAlignment_);
cellVerticalAlignmentGrid_ = QVector<QVector<LayoutStyle::Alignment>>(numColumns_,
QVector<LayoutStyle::Alignment>(numRows_, defaultVerticalAlignment_));
cellHorizontalAlignmentGrid_ = QVector<QVector<LayoutStyle::Alignment>>(numColumns_,
QVector<LayoutStyle::Alignment>(numRows_, defaultHorizontalAlignment_));
// initialize stretch factors
columnStretchFactors_ = QVector<float>(numColumns_, defaultColumnStretchFactor_);
rowStretchFactors_ = QVector<float>(numRows_, defaultRowStretchFactor_);
computeOverallStretchFactors();
}
GridLayoutFormElement::~GridLayoutFormElement()
{
// elements were deleted by Element
}
GridLayoutFormElement* GridLayoutFormElement::put(int column, int row, FormElement* element)
{
adjustSize(column, row);
lastCell_ = QPair<int, int>(column, row);
removeChild(elementGrid_[column][row]);
addChild(element);
SAFE_DELETE(elementGrid_[column][row]);
elementGrid_[column][row] = element;
return this;
}
void GridLayoutFormElement::computeSize(Item* item, int availableWidth, int availableHeight)
{
// Compute default sizes of all the elements
// Get the widest and tallest items (without merged cells)
QVector<int> widestInColumn(numColumns_, 0);
QVector<int> tallestInRow(numRows_, 0);
bool hasMultiColumn = false;
bool hasMultiRow = false;
for(int x=0; x<numColumns_; x++)
for(int y=0; y<numRows_; y++)
if (elementGrid_[x][y] != nullptr)
{
FormElement* element = elementGrid_[x][y];
QPair<int, int> cellSpan = spanGrid_[x][y];
element->computeSize(item, 0, 0); // any additional space is distributed later
if (cellSpan.first == 1)
{
if (element->width(item) > widestInColumn[x]) widestInColumn[x] = element->width(item);
}
else hasMultiColumn = true;
if (cellSpan.second == 1)
{
if (element->height(item) > tallestInRow[y]) tallestInRow[y] = element->height(item);
}
else hasMultiRow = true;
}
// modify widest cells in columns and tallest cells in rows if there are merged columns
if (hasMultiColumn or hasMultiRow)
for(int x=0; x<numColumns_; x++)
for(int y=0; y<numRows_; y++)
{
if (spanGrid_[x][y].first > 1)
{
int availableSpace = 0;
float availableStretchFactor = 0;
for (int column=x; column<x+spanGrid_[x][y].first; column++)
{
availableSpace += widestInColumn[column];
availableStretchFactor += columnStretchFactors_[column];
}
availableSpace += spaceBetweenColumns_ * (spanGrid_[x][y].first - 1);
int missingSpace = elementGrid_[x][y]->width(item) - availableSpace;
if (missingSpace > 0)
{
if (availableStretchFactor == 0) // add the additional space to some column
widestInColumn[x] += missingSpace;
else // distribute the additional space according to the stretch factors
for (int column=x; column<x+spanGrid_[x][y].first; column++)
widestInColumn[column] +=
std::ceil(missingSpace / availableStretchFactor * columnStretchFactors_[column]);
}
}
if (spanGrid_[x][y].second > 1)
{
int availableSpace = 0;
float availableStretchFactor = 0;
for (int row=y; row<y+spanGrid_[x][y].second; row++)
{
availableSpace += tallestInRow[row];
availableStretchFactor += rowStretchFactors_[row];
}
availableSpace += spaceBetweenRows_ * (spanGrid_[x][y].second - 1);
int missingSpace = elementGrid_[x][y]->height(item) - availableSpace;
if (missingSpace > 0)
{
if (availableStretchFactor == 0) // add the additional space to some column
tallestInRow[y] += missingSpace;
else // distribute the additional space according to the stretch factors
for (int row=y; row<y+spanGrid_[x][y].second; row++)
tallestInRow[row] +=
std::ceil(missingSpace / availableStretchFactor * rowStretchFactors_[row]);
}
}
}
// Compute grid size
int totalWidth = 0;
int totalHeight = 0;
// Compute grid width
for (auto columnWidth : widestInColumn) totalWidth += columnWidth;
if (numColumns_ > 0) totalWidth += leftMargin() + rightMargin();
if (numColumns_ > 1) totalWidth += spaceBetweenColumns_ * (numColumns_ - 1);
// Adjust widest cell in column values if there is additional space available
int additionalWidth = availableWidth - totalWidth;
// if availableWidth == 0, this is always false
if (additionalWidth > 0)
{
if (overallColumnStretchFactor_ > 0) // distribute the additional space according to the stretch factors
for (int x = 0; x<numColumns_; ++x)
widestInColumn[x] += std::floor(additionalWidth / overallColumnStretchFactor_ * columnStretchFactors_[x]);
totalWidth = availableWidth;
}
// Compute grid height
for (auto rowHeight : tallestInRow) totalHeight += rowHeight;
if (numRows_ > 0) totalHeight += topMargin() + bottomMargin();
if (numRows_ > 1) totalHeight += spaceBetweenRows_ * (numRows_ - 1);
// Adjust tallest cell in row values if there is additional space available
int additionalHeight = availableHeight - totalHeight;
// if availableHeight == 0, this is always false
if (additionalHeight > 0)
{
if (overallRowStretchFactor_ > 0) // distribute the additional space according to the stretch factors
for (int y = 0; y<numRows_; ++y)
tallestInRow[y] += std::floor(additionalHeight / overallRowStretchFactor_ * rowStretchFactors_[y]);
totalHeight = availableHeight;
}
setSize(item, QSize(totalWidth, totalHeight));
// Recompute all the element's sizes, if their size depends on their parent's size
for(int x=0; x<numColumns_; x++)
for(int y=0; y<numRows_; y++)
if (elementGrid_[x][y] != nullptr && elementGrid_[x][y]->sizeDependsOnParent(item))
{
FormElement* element = elementGrid_[x][y];
QPair<int, int> cellSpan = spanGrid_[x][y];
if (cellSpan.first == 1 && cellSpan.second == 1)
element->computeSize(item, widestInColumn[x], tallestInRow[y]);
else
{
int localAvailableWidth = 0;
for (int column=x; column<x+spanGrid_[x][y].first; column++)
localAvailableWidth += widestInColumn[column];
int localAvailableHeight = 0;
for (int row=y; row<y+spanGrid_[x][y].second; row++)
localAvailableHeight += tallestInRow[row];
element->computeSize(item, localAvailableWidth, localAvailableHeight);
}
}
// Set element positions
int left = leftMargin();
for(int x=0; x<numColumns_; ++x)
{
int top = topMargin();
for(int y=0; y<numRows_; ++y)
{
if (elementGrid_[x][y] != nullptr)
{
int xPos = left;
if (cellHorizontalAlignmentGrid_[x][y] == LayoutStyle::Alignment::Center)
{
if (spanGrid_[x][y].first == 1)
xPos += (widestInColumn[x] - elementGrid_[x][y]->width(item))/2;
else
{
int localAvailableWidth = 0;
for (int column=x; column<x+spanGrid_[x][y].first; column++)
localAvailableWidth += widestInColumn[column];
xPos += (localAvailableWidth - elementGrid_[x][y]->width(item))/2;
}
}
else if (cellHorizontalAlignmentGrid_[x][y] == LayoutStyle::Alignment::Right)
{
if (spanGrid_[x][y].first == 1)
xPos += (widestInColumn[x] - elementGrid_[x][y]->width(item));
else
{
int localAvailableWidth = 0;
for (int column=x; column<x+spanGrid_[x][y].first; column++)
localAvailableWidth += widestInColumn[column];
xPos += (localAvailableWidth - elementGrid_[x][y]->width(item));
}
}
int yPos = top;
if (cellVerticalAlignmentGrid_[x][y] == LayoutStyle::Alignment::Center)
{
if (spanGrid_[x][y].second == 1)
yPos += (tallestInRow[y] - elementGrid_[x][y]->height(item))/2;
else
{
int localAvailableHeight = 0;
for (int row=y; row<y+spanGrid_[x][y].second; row++)
localAvailableHeight += tallestInRow[row];
yPos += (localAvailableHeight - elementGrid_[x][y]->height(item))/2;
}
}
else if (cellVerticalAlignmentGrid_[x][y] == LayoutStyle::Alignment::Bottom)
{
if (spanGrid_[x][y].second == 1)
yPos += tallestInRow[y] - elementGrid_[x][y]->height(item);
else
{
int localAvailableHeight = 0;
for (int row=y; row<y+spanGrid_[x][y].second; row++)
localAvailableHeight += tallestInRow[row];
yPos += localAvailableHeight - elementGrid_[x][y]->height(item);
}
}
elementGrid_[x][y]->setPos(item, QPoint(xPos, yPos));
}
top += tallestInRow[y] + spaceBetweenRows_;
}
left += widestInColumn[x] + spaceBetweenColumns_;
}
}
bool GridLayoutFormElement::sizeDependsOnParent(const Item*) const
{
return overallColumnStretchFactor_ > 0 || overallRowStretchFactor_ > 0;
}
QList<ItemRegion> GridLayoutFormElement::regions(Item* item, int parentX, int parentY)
{
QList<ItemRegion> allRegions;
// regions for the child elements
for(int x=0; x<numColumns_; x++)
for(int y=0; y<numRows_; y++)
if(elementGrid_[x][y])
allRegions.append(elementGrid_[x][y]->regions(item, this->x(item) + parentX, this->y(item) + parentY));
// if grid consists of exactly one row or one column, add more cursor regions
if (numColumns_ == 1 || numRows_ == 1)
{
QRect wholeArea = QRect(QPoint(x(item) + parentX, y(item) + parentY), size(item));
QRect elementsArea = QRect(QPoint(wholeArea.left() + leftMargin(), wholeArea.top() + topMargin()),
QPoint(wholeArea.right() - rightMargin(), wholeArea.bottom() - bottomMargin()));
// This is the rectangle half-way between the bounding box of the layout and elementsArea.
QRect midArea = QRect(QPoint(wholeArea.left() + leftMargin()/2, wholeArea.top() + topMargin()/2),
QPoint(wholeArea.right() - rightMargin()/2, wholeArea.bottom() - bottomMargin()/2));
// if there is exactly one cell, the orientation is vertical
bool horizontal = (numColumns_ != 1);
int offset;
if (horizontal)
offset = (spaceBetweenColumns_ > 0) ? spaceBetweenColumns_/2 : 1;
else
offset = (spaceBetweenRows_ > 0) ? spaceBetweenRows_/2 : 1;
int last = horizontal ? midArea.left() : midArea.top();
int list_size = horizontal ? numColumns_ : numRows_;
int thisElementPos = horizontal ? parentX + x(item) : parentY + y(item);
for(int i = 0; i < (list_size); ++i)
{
ItemRegion cursorRegion;
if (horizontal)
{
auto child = elementGrid_[i][0];
cursorRegion.setRegion(QRect(last, elementsArea.top(), thisElementPos + child->x(item) - last,
elementsArea.height()));
last = thisElementPos + child->xEnd(item) + offset;
}
else
{
auto child = elementGrid_[0][i];
cursorRegion.setRegion(QRect(elementsArea.left(), last, elementsArea.width(),
thisElementPos + child->y(item) - last));
last = thisElementPos + child->yEnd(item) + offset;
}
adjustCursorRegionToAvoidZeroSize(cursorRegion.region(), horizontal, i==0, false);
// Note below, that a horizontal layout, means a vertical cursor
auto lc = new LayoutCursor(item, horizontal ? Cursor::VerticalCursor : Cursor::HorizontalCursor);
lc->setOwnerElement(this);
cursorRegion.setCursor(lc);
lc->setIndex(i);
lc->setVisualizationPosition(cursorRegion.region().topLeft());
lc->setVisualizationSize(horizontal ? QSize(2, height(item)) : QSize(width(item), 2));
lc->setOwnerElement(this);
if (i==0) lc->setIsAtBoundary(true);
cursorRegion.cursor()->setRegion(cursorRegion.region());
if (notLocationEquivalentCursors(item)) lc->setNotLocationEquivalent(true);
// Skip cursor?
if (!((i == 0) && noBoundaryCursors(item)) && !((i > 0) && noInnerCursors(item)))
allRegions.append(cursorRegion);
}
// Add trailing cursor region if not omitted
if (!noBoundaryCursors(item))
{
QRect trailing;
if (horizontal)
trailing.setRect(last, elementsArea.top(), midArea.right() + 1 - last, elementsArea.height());
else
trailing.setRect(elementsArea.left(), last, elementsArea.width(), midArea.bottom() + 1 - last);
adjustCursorRegionToAvoidZeroSize(trailing, horizontal, false, true);
allRegions.append(ItemRegion(trailing));
// Note below, that a horizontal layout, means a vertical cursor
auto lc = new LayoutCursor(item, horizontal ? Cursor::VerticalCursor : Cursor::HorizontalCursor);
lc->setOwnerElement(this);
allRegions.last().setCursor(lc);
lc->setIndex(list_size);
lc->setVisualizationPosition(allRegions.last().region().topLeft());
lc->setVisualizationSize(horizontal ? QSize(2, height(item)) : QSize(width(item), 2));
lc->setRegion(trailing);
lc->setIsAtBoundary(true);
if (notLocationEquivalentCursors(item)) lc->setNotLocationEquivalent(true);
}
}
return allRegions;
}
void GridLayoutFormElement::computeOverallStretchFactors()
{
overallColumnStretchFactor_ = 0;
for(auto stretchFactor : columnStretchFactors_) overallColumnStretchFactor_ += stretchFactor;
overallRowStretchFactor_ = 0;
for(auto stretchFactor : rowStretchFactors_) overallRowStretchFactor_ += stretchFactor;
}
void GridLayoutFormElement::adjustSize(int containColumn, int containRow)
{
if (containColumn >= numColumns_ || containRow >= numRows_)
{
// calculate new size
int newNumColumns = (containColumn < numColumns_) ? numColumns_ : containColumn + 1;
int newNumRows = (containRow < numRows_) ? numRows_ : containRow + 1;
// adjust element grid
auto newElementGrid = QVector<QVector<FormElement*>>(newNumColumns, QVector<FormElement*>(newNumRows, nullptr));
for (int x=0; x<numColumns_; x++)
for (int y=0; y<numRows_; y++)
newElementGrid[x][y] = elementGrid_[x][y];
elementGrid_ = newElementGrid;
// adjust span grid
auto newSpanGrid = QVector<QVector<QPair<int, int>>>(
newNumColumns,QVector<QPair<int, int>>(newNumRows, QPair<int, int>(1, 1)));
for (int x=0; x<numColumns_; x++)
for (int y=0; y<numRows_; y++)
newSpanGrid[x][y] = spanGrid_[x][y];
spanGrid_ = newSpanGrid;
// adjust alignments
if (numColumns_ < newNumColumns)
{
auto newColumnAlignments = QVector<LayoutStyle::Alignment>(newNumColumns, defaultHorizontalAlignment_);
for (int x=0; x<numColumns_; x++)
newColumnAlignments[x] = defaultColumnHorizontalAlignments_[x];
defaultColumnHorizontalAlignments_ = newColumnAlignments;
}
if (numRows_ < newNumRows)
{
auto newRowAlignments = QVector<LayoutStyle::Alignment>(newNumRows, defaultVerticalAlignment_);
for (int y=0; y<numRows_; y++)
newRowAlignments[y] = defaultRowVerticalAlignments_[y];
defaultRowVerticalAlignments_ = newRowAlignments;
}
auto newCellHorizontalGrid = QVector<QVector<LayoutStyle::Alignment>>(newNumColumns,
QVector<LayoutStyle::Alignment>(newNumRows));
for (int x=0; x<newNumColumns; x++)
for (int y=0; y<newNumRows; y++)
if (x<numColumns_ && y<numRows_)
newCellHorizontalGrid[x][y] = cellHorizontalAlignmentGrid_[x][y];
else
newCellHorizontalGrid[x][y] = defaultColumnHorizontalAlignments_[x];
cellHorizontalAlignmentGrid_ = newCellHorizontalGrid;
auto newCellVerticalGrid = QVector<QVector<LayoutStyle::Alignment>>(newNumColumns,
QVector<LayoutStyle::Alignment>(newNumRows));
for (int x=0; x<newNumColumns; x++)
for (int y=0; y<newNumRows; y++)
if (x<numColumns_ && y<numRows_)
newCellVerticalGrid[x][y] = cellVerticalAlignmentGrid_[x][y];
else
newCellVerticalGrid[x][y] = defaultRowVerticalAlignments_[y];
cellVerticalAlignmentGrid_ = newCellVerticalGrid;
// adjust stretch factors
if (numColumns_ < newNumColumns)
{
auto newColumnStretchFactors = QVector<float>(newNumColumns, defaultColumnStretchFactor_);
for (int x=0; x<numColumns_; x++)
newColumnStretchFactors[x] = columnStretchFactors_[x];
columnStretchFactors_ = newColumnStretchFactors;
}
if (numRows_ < newNumRows)
{
auto newRowStretchFactors = QVector<float>(newNumRows, defaultRowStretchFactor_);
for (int y=0; y<numRows_; y++)
newRowStretchFactors[y] = rowStretchFactors_[y];
rowStretchFactors_ = newRowStretchFactors;
}
computeOverallStretchFactors();
// set new grid size
numColumns_ = newNumColumns;
numRows_ = newNumRows;
}
}
inline void GridLayoutFormElement::adjustCursorRegionToAvoidZeroSize(QRect& region, bool horizontal, bool first, bool last)
{
// Make sure there is at least some space for the cursor Region.
if (horizontal && region.width() == 0) region.adjust((first?0:-1), 0, (last?0:1), 0);
if (!horizontal && region.height() == 0 ) region.adjust(0, (first?0:-1), 0, (last?0:1));
}
int GridLayoutFormElement::focusedElementIndex(Item* item) const
{
if (numColumns_ == 1)
for (int y=0; y<numRows_; ++y)
if (elementGrid_[0][y]->elementOrChildHasFocus(item)) return y;
if (numRows_ == 1)
for (int x=0; x<numColumns_; ++x)
if (elementGrid_[x][0]->elementOrChildHasFocus(item)) return x;
return -1;
}
} /* namespace Visualization */
|
4906511b18321aea7f5bcf62bda0fd424a00bc99 | f02e611399389097860e89780a41e98af3f314e4 | /targets/libraries/hellolib/include/hellolib/hellolib.hpp | b9e6041d5645dd05ee384a22c7eab784645f5349 | [] | no_license | range3/cpp-boilerplate | 0a1d1b14738c7f8de36fbee5bf5904b4dd033ec0 | f2441d3ac2fb97ebd4a45adc7a9f67e46c7857c3 | refs/heads/master | 2023-04-07T18:31:15.527066 | 2021-04-08T07:55:48 | 2021-04-08T07:55:48 | 341,076,550 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 56 | hpp | hellolib.hpp | #pragma once
namespace hellolib {
const char* say();
}
|
8e268b9c6cb0a5efecbac7c3c6e50677be7406fb | 65678f08931017fdf4af16c9e8da8d43d6fcdd72 | /Rshell/src/Output_Redirect.cpp | a80c90b897deb43dc677cc2fd2b958c8ce18c6b7 | [] | no_license | philn123/cs100 | 10184f41f538a56620f2fc7cb91dc48debd41980 | 7c047bf0df100ad52351741ba7e3df5785ba327b | refs/heads/master | 2020-04-11T13:36:37.461850 | 2018-12-14T18:18:07 | 2018-12-14T18:18:07 | 161,823,422 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,882 | cpp | Output_Redirect.cpp | #include "../header/Output_Redirect.h"
#include "../header/command.h"
#include "../header/base.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
#include <cstdlib>
#include <stdio.h>
#include <fcntl.h>
bool singleOutputRedirect :: execute() {
int fd, ret, status;
pid_t pid = fork();
//most of this is the same as input redirection
if(pid < 0) {
perror("Error in forking process");
exit(1);
return false;
}
else if(!pid) {
Command *c = (Command*)right;
//writing to output file
//man pages to get arguments
fd = open(c->getFirstArgument(), O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR);
if (fd < 0) {
perror("Open Failure");
exit(1); //EXIT_FAILURE
return false;
}
//it is one because 1 stands for stdout
//https://www.youtube.com/watch?v=EqndHT606Tw
ret = dup2(fd, 1);
if (ret < 0) {
perror("dup2");
exit(1);
return false;
}
if (close(fd) < 0) {
perror("Close Failure");
exit(1);
return false;
}
if (!left->execute()) { //if command doesnt work
exit(1);
return false;
}
exit(0);
return true;
}
else { //copying from command.cpp
do {
waitpid(pid, &status, 0);
} while (WIFEXITED(status) == -1);
}
return (!WEXITSTATUS(status));
}
bool doubleOutputRedirect :: execute() {
int fd, ret, status;
pid_t pid = fork();
//most of this is the same as input redirection
if(pid < 0) {
perror("Error in forking process");
exit(1);
return false;
}
else if(!pid) {
Command *c = (Command*)right;
//writing to output file
//man pages to get arguments
//i guess it just appends?
fd = open(c->getFirstArgument(), O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
if (fd < 0) {
perror("Open Failure");
exit(1); //EXIT_FAILURE
return false;
}
//it is one because 1 stands for stdout
//https://www.youtube.com/watch?v=EqndHT606Tw
ret = dup2(fd, 1);
if (ret < 0) {
perror("dup2");
exit(1);
return false;
}
if (close(fd) < 0) {
perror("Close Failure");
exit(1);
return false;
}
if (!left->execute()) { //if command doesnt work
exit(1);
return false;
}
exit(0);
return true;
}
else { //copying from command.cpp
do {
waitpid(pid, &status, 0);
} while (WIFEXITED(status) == -1);
}
return (!WEXITSTATUS(status));
}
|
76099d09891f4c2b59452edcb1c6855cf2438c97 | f6cf14142621b8c4709c6f2073172f39577b1964 | /common/lib/rec/robotino3/iocom/tag/BatteryMinFwd.h | 87b3ec4a3146b55df8d338a0061aef2dd531696d | [] | no_license | BusHero/robotino_api2 | f3eef6c1ace2ff5a8b93db691aa779db8a9ce3a1 | 9757814871aa90977c2548a8a558f4b2cb015e5d | refs/heads/master | 2021-06-18T21:32:14.390621 | 2021-02-18T15:21:48 | 2021-02-18T15:21:48 | 165,231,765 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 352 | h | BatteryMinFwd.h | #ifndef _REC_ROBOTINO3_IOCOM_TAG_BatteryMinFWD_H_
#define _REC_ROBOTINO3_IOCOM_TAG_BatteryMinFWD_H_
#include <QtCore>
namespace rec
{
namespace robotino3
{
namespace iocom
{
namespace tag
{
class BatteryMin;
typedef QSharedPointer< BatteryMin > BatteryMinPointer;
}
}
}
}
#endif //_REC_ROBOTINO3_IOCOM_TAG_BatteryMinFWD_H_
|
44eca214b295c8ca0b01316d067571d247217162 | cf91c0b8248ad922a58b756cd94ac6d7c72a0881 | /mic_input/mic_input.ino | 950796f50f74925c6dd5d435b3956ec0211a05b0 | [] | no_license | yasirfaizahmed/Arduino_repository | f20288bf0b91b10130ef23965490559f12bc5b6d | 5cb0563fa455269e813ca74e26c4f93ea044e71b | refs/heads/master | 2020-05-15T19:06:46.111792 | 2019-12-28T13:42:05 | 2019-12-28T13:42:05 | 182,446,657 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 245 | ino | mic_input.ino | const int micPin=A0;
const int outPin=9;
void setup()
{
pinMode(micPin,INPUT);
pinMode(outPin,OUTPUT);
Serial.begin(115200);
}
void loop()
{
int input=analogRead(micPin);
Serial.print("input=");
Serial.print(input);
delay(30);
}
|
8b255b1e6e83ba7f38614bc7989d281c79c661bb | 385cfbb27ee3bcc219ec2ac60fa22c2aa92ed8a0 | /Tools/MedusaExport/max50/include/iparamb.h | 82b7f2c9292b93eace72a41c74bb2afd53a120fb | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | palestar/medusa | edbddf368979be774e99f74124b9c3bc7bebb2a8 | 7f8dc717425b5cac2315e304982993354f7cb27e | refs/heads/develop | 2023-05-09T19:12:42.957288 | 2023-05-05T12:43:35 | 2023-05-05T12:43:35 | 59,434,337 | 35 | 18 | MIT | 2018-01-21T01:34:01 | 2016-05-22T21:05:17 | C++ | UTF-8 | C++ | false | false | 8,054 | h | iparamb.h | /**********************************************************************
*<
FILE: iparamb.h
DESCRIPTION: Interface to Parameter blocks
CREATED BY: Rolf Berteig
HISTORY: created 1/25/95
*> Copyright (c) 1994, All Rights Reserved.
**********************************************************************/
#ifndef __IPARAMB__
#define __IPARAMB__
class UserType : public ReferenceTarget {
public:
virtual ~UserType() {};
virtual Control* CreateController()=0;
virtual BOOL operator==( const UserType &t )=0;
virtual UserType& operator=( const UserType &t )=0;
};
// Built in data types
#include "paramtype.h"
// Chunk IDs for loading/saving
#define PB_COUNT_CHUNK 0x0001
#define PB_PARAM_CHUNK 0x0002
#define PB_INDEX_CHUNK 0x0003
#define PB_ANIMATABLE_CHUNK 0x0004
#define PB_VERSION_CHUNK 0x0005
#define PB_FLOAT_CHUNK (TYPE_FLOAT + 0x100)
#define PB_INT_CHUNK (TYPE_INT + 0x100)
#define PB_RGBA_CHUNK (TYPE_RGBA + 0x100)
#define PB_POINT3_CHUNK (TYPE_POINT3 + 0x100)
#define PB_BOOL_CHUNK (TYPE_BOOL + 0x100)
#define PB_TYPE_CHUNK 0x0200
#define PB_TYPE_FLOAT_CHUNK (PB_TYPE_CHUNK + TYPE_FLOAT)
#define PB_TYPE_INT_CHUNK (PB_TYPE_CHUNK + TYPE_INT)
#define PB_TYPE_RGBA_CHUNK (PB_TYPE_CHUNK + TYPE_RGBA)
#define PB_TYPE_POINT3_CHUNK (PB_TYPE_CHUNK + TYPE_POINT3)
#define PB_TYPE_BOOL_CHUNK (PB_TYPE_CHUNK + TYPE_BOOL)
#define PB_TYPE_USER_CHUNK (PB_TYPE_CHUNK + TYPE_USER)
// When a client of a param block receives the REFMSG_GET_PARAM_NAME
// message, the partID field is set to point at one of these structures.
// The client should fill in the parameter name.
class GetParamName {
public:
TSTR name;
int index;
GetParamName(TSTR n,int i) { name=n;index=i; }
};
// When a client of a param block receives the REFMSG_GET_PARAM_DIM
// message, the partID field is set to point at one of these structs.
// The client should set dim to point at it's dim descriptor.
class GetParamDim {
public:
ParamDimension *dim;
int index;
GetParamDim(int i) {index=i;dim=NULL;}
};
// To create a parameter block, pass an array of these descriptors
// into the Create function.
// Items in the parameter block can be refered to by index. The
// index is derived from the order in which the descriptors appear
// in the array. If a parameter is a UserType, then a pointer to a
// new UserType must be passed in. The parameter block will be responsible
// for deleting it when it is done with it.
class ParamBlockDesc {
public:
ParamType type;
UserType *user;
BOOL animatable;
};
// This version of the descriptor has an ID for each parameter.
class ParamBlockDescID {
public:
ParamType type;
UserType *user;
BOOL animatable;
DWORD id;
};
class IParamBlock;
// This class represents a virtual array of parameters.
// Parameter blocks are one such implementation of this class, but
// it can also be useful to implement a class that abstracts non-
// parameter block variables.
//
// The ParamMap class (see IParamM.h) uses this base class so that
// a ParamMap can be used to control UI for not only parameter blocks
// but variables stored outside of parameter blocks.
class IParamArray {
public:
virtual BOOL SetValue( int i, TimeValue t, float v ) {return FALSE;}
virtual BOOL SetValue( int i, TimeValue t, int v ) {return FALSE;}
virtual BOOL SetValue( int i, TimeValue t, Point3& v ) {return FALSE;}
virtual BOOL GetValue( int i, TimeValue t, float &v, Interval &ivalid ) {return FALSE;}
virtual BOOL GetValue( int i, TimeValue t, int &v, Interval &ivalid ) {return FALSE;}
virtual BOOL GetValue( int i, TimeValue t, Point3 &v, Interval &ivalid ) {return FALSE;}
// If it is a param block, this will get a pointer to it, otherwise it will return NULL.
// Note that casting won't work because of multiple iheritance.
virtual IParamBlock *GetParamBlock() {return NULL;}
// Checks to see if a keyframe exists for the given parameter at the given time
virtual BOOL KeyFrameAtTime(int i, TimeValue t) {return FALSE;}
};
class IParamBlock :
public ReferenceTarget,
public IParamArray {
public:
// Get's the super class of a parameters controller
virtual SClass_ID GetAnimParamControlType(int anim)=0;
// Get the param type
virtual ParamType GetParameterType(int i)=0;
// one for each known type
virtual BOOL SetValue( int i, TimeValue t, float v )=0;
virtual BOOL SetValue( int i, TimeValue t, int v )=0;
virtual BOOL SetValue( int i, TimeValue t, Point3& v )=0;
virtual BOOL SetValue( int i, TimeValue t, Color& v )=0; // uses Point3 controller
// one for each known type
virtual BOOL GetValue( int i, TimeValue t, float &v, Interval &ivalid )=0;
virtual BOOL GetValue( int i, TimeValue t, int &v, Interval &ivalid )=0;
virtual BOOL GetValue( int i, TimeValue t, Point3 &v, Interval &ivalid )=0;
virtual BOOL GetValue( int i, TimeValue t, Color &v, Interval &ivalid )=0; // uses Point3 Controller
virtual Color GetColor(int i, TimeValue t=0)=0;
virtual Point3 GetPoint3(int i, TimeValue t=0)=0;
virtual int GetInt(int i, TimeValue t=0)=0;
virtual float GetFloat(int i, TimeValue t=0)=0;
virtual DWORD GetVersion()=0;
virtual int NumParams()=0;
virtual void RemoveController(int i)=0;
virtual Control* GetController(int i)=0;
virtual void SetController(int i, Control *c, BOOL preserveFrame0Value=TRUE)=0;
virtual void SwapControllers(int j, int k )=0;
// Given the parameter index, what is the refNum?
virtual int GetRefNum(int paramNum)=0;
// Given the parameter index what is the animNum?
virtual int GetAnimNum(int paramNum)=0;
// Given the animNum what is the parameter index?
virtual int AnimNumToParamNum(int animNum)=0;
// Inherited from IParamArray
IParamBlock *GetParamBlock() {return this;}
// This is only for use in a RescaleWorldUnits() implementation:
// The param block implementation of RescaleWorldUnits scales only tracks
// that have dimension type = stdWorldDim. If letting the param block handle
// the rescaling is not sufficient, call this on just the parameters you need to rescale.
virtual void RescaleParam(int paramNum, float f)=0;
// When a NotifyRefChanged is received from a param block, you
// can call this method to find out which parameter generated the notify.
virtual int LastNotifyParamNum()=0;
};
CoreExport IParamBlock *CreateParameterBlock(ParamBlockDesc *pdesc, int count);
// Note: version must fit into 16 bits. (5/20/97)
CoreExport IParamBlock *CreateParameterBlock(ParamBlockDescID *pdesc, int count, DWORD version);
// This creates a new parameter block, based on an existing parameter block of
// a later version. The new parameter block inherits any parameters from
// the old parameter block whose parameter IDs match.
CoreExport IParamBlock *UpdateParameterBlock(
ParamBlockDescID *pdescOld, int oldCount, IParamBlock *oldPB,
ParamBlockDescID *pdescNew, int newCount, DWORD newVersion);
// ----------------------------------------------------------
// A handy post load call back for fixing up parameter blocks.
// This structure describes a version of the parameter block.
class ParamVersionDesc {
public:
ParamBlockDescID *desc;
int count;
DWORD version;
ParamVersionDesc(ParamBlockDescID *d,int c,int v) {desc=d;count=c;version=v;}
};
// This will look up the version of the loaded callback and
// fix it up so it matches the current version.
// NOTE: this thing deletes itself when it's done.
class ParamBlockPLCB : public PostLoadCallback {
public:
ParamVersionDesc *versions;
int count;
ParamVersionDesc *cur;
ReferenceTarget *targ;
int pbRefNum;
ParamBlockPLCB(
ParamVersionDesc *v,int cnt,ParamVersionDesc *c,
ReferenceTarget *t,int refNum)
{versions=v;count=cnt;cur=c;targ=t;pbRefNum=refNum;}
CoreExport void proc(ILoad *iload);
int Priority() { return 0; }
CoreExport INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0);
};
#endif
|
1d9d92b2dde32a400e6c37d6f9f1c80978150308 | 78fa2f85caeff81f9617690d37a505f92073dd89 | /src/TetMesh/TetEdge.cpp | 0cd8b0a62f2f1a871051f386a746cd52939bfd28 | [] | no_license | brettmillervfx/destroyer | daaf4093bde96eb200ef44d42bb4b40674b3d6b9 | 015d7c70039bc1fd582e1dca091c034bfc37627f | refs/heads/master | 2020-03-27T01:02:28.171599 | 2018-10-07T08:16:09 | 2018-10-07T08:16:09 | 145,676,317 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,785 | cpp | TetEdge.cpp | //
// Created by Brett Miller on 8/15/18.
//
#include "TetMesh/TetEdge.h"
#include "TetMesh/TetFace.h"
#include "TetMesh/TetNode.h"
namespace destroyer {
TetEdge::TetEdge(TetNodeRef n0, TetNodeRef n1) {
// Manage node connectivity.
nodes_[0] = n0;
n0->ConnectEdge(this);
nodes_[1] = n1;
n1->ConnectEdge(this);
midpoint_ = nullptr;
}
TetEdge::~TetEdge() {
nodes_[0]->DisconnectEdge(this);
nodes_[1]->DisconnectEdge(this);
}
Vec3 TetEdge::MidpointPosition() const {
return (nodes_[0]->Position() + nodes_[1]->Position()) / 2.0;
}
bool TetEdge::HasMidpoint() const {
return (midpoint_ != nullptr);
}
void TetEdge::SetMidpoint(TetNodeRef node) {
midpoint_ = node;
}
TetNodeRef TetEdge::Midpoint() const {
return midpoint_;
}
TetNodeRef TetEdge::GetFirstNode() const {
return nodes_[0];
}
TetNodeRef TetEdge::GetOtherNode(TetNodeRef node) const {
if (nodes_[0] == node)
return nodes_[1];
else if (nodes_[1] == node)
return nodes_[0];
else
return nullptr;
}
bool TetEdge::HasNode(TetNodeRef node) const {
return (nodes_[0] == node) | (nodes_[1] == node);
}
uint TetEdge::IncidentFaceCount() const {
return incident_faces_.size();
}
std::vector<TetFaceRef> TetEdge::GetIncidentFaces() const {
return incident_faces_;
}
uint TetEdge::IncidentBoundaryFaceCount() const {
uint boundary_face_count = 0;
for (auto& face: incident_faces_) {
if (face->IsBoundary())
boundary_face_count++;
}
return boundary_face_count;
}
std::vector<TetFaceRef> TetEdge::GetIncidentBoundaryFaces() const {
std::vector<TetFaceRef> boundary_faces;
for (auto& face: incident_faces_) {
if (face->IsBoundary())
boundary_faces.push_back(face);
}
return boundary_faces;
}
TetFaceRef TetEdge::GetFaceWithEdge(TetEdgeRef edge) const {
for (auto& face: incident_faces_) {
if (face->HasEdge(edge))
return face;
}
return nullptr;
}
std::vector<TetrahedronRef> TetEdge::GetIncidentTets() const {
return incident_tets_;
}
bool TetEdge::IsConnected() const {
// We consider the edge connected if there are incidental tetrahedra.
return (incident_tets_.size() > 0);
}
Real TetEdge::Length() const {
Vec3 edge_vec = nodes_[0]->Position() - nodes_[1]->Position();
return edge_vec.length();
}
Vec3 TetEdge::AsVector() const {
Vec3 edge_vec = nodes_[0]->Position() - nodes_[1]->Position();
return edge_vec;
}
bool TetEdge::IsNonManifold() const {
// The edge is considered non-manifold if more that two boundary faces are connected to it.
return (IncidentBoundaryFaceCount()>2);
}
void TetEdge::ConnectFace(TetFaceRef face) {
incident_faces_.push_back(face);
}
void TetEdge::DisconnectFace(TetFaceRef face) {
auto found_face = std::find(incident_faces_.begin(), incident_faces_.end(), face);
if (found_face != incident_faces_.end())
incident_faces_.erase(found_face);
}
void TetEdge::ConnectTetrahedron(TetrahedronRef tet) {
incident_tets_.push_back(tet);
}
void TetEdge::DisconnectTetrahedron(TetrahedronRef tet) {
auto found_tet = std::find(incident_tets_.begin(), incident_tets_.end(), tet);
if (found_tet != incident_tets_.end())
incident_tets_.erase(found_tet);
}
void TetEdge::ReplaceNode(TetNodeRef original, TetNodeRef replacement) {
// Find the index
int index = 0;
for (;index<2;index++)
if (nodes_[index] == original)
break;
// Foud the corresponsing node.
if (index<2) {
nodes_[index] = replacement;
original->DisconnectEdge(this);
replacement->ConnectEdge(this);
}
}
}; // namespace destroyer
|
c00dcc0acc561a7d52ac75e2ab87d6dd27c012fd | 65e76d8b280546b8d5a7610d41e64cf5657720f9 | /Webcrawler/funct.h | cb89a9b9760ed0937c6d7f72795ecd9202e8736c | [] | no_license | Nikos-Tsiougranas/Web-Server-Web-Crawler-Search-Engine | c24a1d4bb47ca3c63ed4b299316212843bf392bb | 658bb363ef8a68def5cfdc6cbb198d9103b6a1d7 | refs/heads/master | 2020-04-19T06:24:35.315902 | 2019-01-28T18:49:48 | 2019-01-28T18:49:48 | 168,016,844 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 898 | h | funct.h | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <pthread.h>
#include <unistd.h>
#include "string.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/wait.h>
#include <sys/poll.h>
#include <dirent.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/stat.h>
#include <cerrno>
#include <fcntl.h>
#include "queuelist.h"
#ifndef FUNCT_H
#define FUNCT_H
extern char host_ip[256];
extern int serving_port;
extern int p3write;
extern int p3read;
extern int p2initialisation;
extern char save_dir[256];
extern char st_URL[256];
extern int deathsignal;
extern Queuelist* buffer;
extern Queuelist* usedUrls;
extern pthread_mutex_t mtx;
extern pthread_cond_t cond_nonempty;
extern pthread_t* tid;
extern int* thread_doing_nothing;
int check_input(int argc, char** argv,int* command_port,int* numofthreads);
void closefun(int numofthreads);
#endif |
3e067665f82ed021bdaf4dfb5b51af470c7795fd | e7c48ae8678de798e8b10765c76f6c6b9282dd8b | /src/DefList.cpp | b96307a2ebbe0665d4e0c29e5ff4b3a4e23fba67 | [
"Apache-2.0"
] | permissive | dss-bridge/newdss | 7a4e9464ca3540721cbbaa4732edb136ba182cee | 5698e1bd7314bf910472f8e25fc2dac710543236 | refs/heads/master | 2020-12-12T23:16:59.873110 | 2016-07-07T21:04:42 | 2016-07-07T21:04:42 | 48,687,247 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,121 | cpp | DefList.cpp | /*
SDS, a bridge single-suit double-dummy quick-trick solver.
Copyright (C) 2015-16 by Soren Hein.
See LICENSE and README.
*/
#include <iomanip>
#include <assert.h>
#include "Trick.h"
#include "Header.h"
#include "DefList.h"
#include "AltMatrix2D.h"
#include "files.h"
#include "options.h"
using namespace std;
extern FilesType files;
extern OptionsType options;
extern unsigned highestDefNo;
extern vector<unsigned> holdCtr;
const CmpType cmpDetailToShort[SDS_HEADER_CMP_SIZE] =
{
SDS_SAME,
SDS_NEW_BETTER,
SDS_OLD_BETTER,
SDS_DIFFERENT,
SDS_NEW_BETTER,
SDS_OLD_BETTER,
SDS_DIFFERENT
};
DefList::DefList()
{
DefList::Reset();
}
DefList::~DefList()
{
}
void DefList::Reset()
{
headerDirty = true;
len = 0;
}
bool DefList::IsEmpty() const
{
return (len == 0);
}
bool DefList::Set1(
const Trick& trick)
{
headerDirty = true;
len = 1;
return list[0].Set1(trick);
}
bool DefList::Set2(
const Trick& trick10,
const Trick& trick11)
{
headerDirty = true;
len = 1;
return list[0].Set2(trick10, trick11);
}
bool DefList::Set3(
const Trick& trick10,
const Trick& trick11,
const Trick& trick12)
{
headerDirty = true;
len = 1;
return list[0].Set3(trick10, trick11, trick12);
}
bool DefList::Set11(
const Trick& trick1,
const Trick& trick2)
{
headerDirty = true;
len = 1;
return list[0].Set11(trick1, trick2);
}
bool DefList::Set12(
const Trick& trick1,
const Trick& trick20,
const Trick& trick21)
{
headerDirty = true;
len = 1;
return list[0].Set12(trick1, trick20, trick21);
}
bool DefList::Set13(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set13(trick);
}
bool DefList::Set14(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set14(trick);
}
bool DefList::Set31(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set31(trick);
}
bool DefList::Set111(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set111(trick);
}
bool DefList::Set112(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set112(trick);
}
bool DefList::Set122(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set122(trick);
}
bool DefList::Set123(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set123(trick);
}
bool DefList::Set113(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set113(trick);
}
bool DefList::Set114(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set114(trick);
}
bool DefList::Set1112(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set1112(trick);
}
bool DefList::Set1122(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set1122(trick);
}
bool DefList::Set1123(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set1123(trick);
}
bool DefList::Set1124(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set1124(trick);
}
bool DefList::Set11223(
const Trick trick[])
{
headerDirty = true;
len = 1;
return list[0].Set11223(trick);
}
Header& DefList::GetHeader()
{
holdCtr[950]++;
if (! headerDirty)
return header;
headerDirty = false;
holdCtr[951]++;
assert(len > 0);
list[0].GetHeader(header);
Header headerNew;
for (unsigned d = 1; d < len; d++)
{
list[d].GetHeader(headerNew);
header.MergeMin(headerNew);
}
return header;
}
bool DefList::operator == (
const DefList& def2) const
{
if (len != def2.len)
return false;
vector<bool> same1(len, false);
vector<bool> same2(len, false);
unsigned num = 0;
for (unsigned d2 = 0; d2 < len; d2++)
{
if (same2[d2])
continue;
for (unsigned d1 = 0; d1 < len; d1++)
{
if (same1[d1])
continue;
if (list[d1] == def2.list[d2])
{
num++;
same1[d1] = true;
same2[d2] = true;
}
}
}
return (num == len);
}
bool DefList::operator != (
const DefList& def2) const
{
return ! (* this == def2);
}
void DefList::operator += (
const Holding& holding)
{
// Prepends the current move in holding to each defense.
headerDirty = true;
for (unsigned d = 0; d < len; d++)
list[d] += holding;
DefList::RegisterSize("NEWDEF1");
DefList::Reduce();
}
void DefList::operator += (
const AltList& alt)
{
// Adds an alternative to the current set of alternatives,
// eliminating inferior ones (as seen from the defensive side).
vector<unsigned> seen(SDS_CMP_SIZE, 0);
vector<bool> skip(len, false);
bool purge = false;
AltList altMod;
bool altModFlag = false;
for (unsigned d = 0; d < len; d++)
{
CmpDetailType cd;
// cd = list[d].CompareWithExpand(alt);
// cd = list[d].CompareSemiHard(alt);
// cd = list[d].Compare(alt);
cd = list[d].CompareAlmostHard(alt);
CmpType cc = cmpDetailToShort[cd];
seen[cc] = 1;
if (cc == SDS_OLD_BETTER)
{
// Defense will prefer the new one.
purge = true;
skip[d] = true;
}
/* */
// if ((cd == SDS_HEADER_PLAY_OLD_BETTER && list[d].GetComplexity() == 1) ||
// (cd == SDS_HEADER_PLAY_NEW_BETTER && alt.GetComplexity() == 1))
// if (cd == SDS_HEADER_PLAY_OLD_BETTER ||
// cd == SDS_HEADER_PLAY_NEW_BETTER)
if (cd == SDS_HEADER_RANK_OLD_BETTER ||
cd == SDS_HEADER_RANK_NEW_BETTER)
{
unsigned tdef = list[d].GetTricks();
unsigned talt = alt.GetTricks();
if (tdef != talt)
continue;
// Could trawl the single alternative more efficiently, perhaps.
Header halt, hdef;
alt.GetHeader(halt);
unsigned ralt = halt.GetMaxRank();
list[d].GetHeader(hdef);
unsigned rdef = hdef.GetMaxRank();
// if (cd == SDS_HEADER_PLAY_OLD_BETTER && rdef+1 == ralt)
if (cd == SDS_HEADER_PLAY_OLD_BETTER && rdef < ralt)
{
altModFlag = true;
altMod = alt;
// list[d].Print(cout, "Def losing");
// cout << "cd " << static_cast<int>(cd) << "\n";
// altMod.Print(cout, "alt before");
altMod.FixRanks(rdef, tdef);
// altMod.Print(cout, "alt after");
// cout << endl;
}
// else if (cd == SDS_HEADER_PLAY_NEW_BETTER && ralt+1 == rdef)
else if (cd == SDS_HEADER_PLAY_NEW_BETTER && ralt < rdef)
{
// alt.Print(cout, "alt losing");
// cout << "cd " << static_cast<int>(cd) << "\n";
// list[d].Print(cout, "Def before");
list[d].FixRanks(ralt, talt);
// list[d].Print(cout, "Def before");
// cout << endl;
}
}
/* */
}
unsigned c = seen[SDS_SAME] + seen[SDS_NEW_BETTER] + seen[SDS_OLD_BETTER];
if (c > 1)
{
cout << seen[SDS_SAME] << " " <<
seen[SDS_NEW_BETTER] << " " <<
seen[SDS_OLD_BETTER] << "\n";
DefList::Print();
cout << "\n";
alt.Print(cout, "Offending alt");
CmpDetailType cd = list[0].Compare(alt);
cout << endl;
assert(c <= 1);
}
if (c == 1 && ! purge)
return;
if (purge)
{
assert(seen[SDS_OLD_BETTER]);
DefList::Purge(skip);
}
assert(len < SDS_MAX_DEF);
list[len++] = (altModFlag ? altMod : alt);
headerDirty = true;
DefList::RegisterSize("NEWDEF2");
}
void DefList::operator += (
const DefList& def2)
{
// For the defense, we just concatenate the defenses.
if (len == 0)
{
* this = def2;
return;
}
assert(def2.len > 0);
headerDirty = true;
if (options.debugDef)
{
DefList::Print(files.debug, "DefList::MergeDefender: old");
def2.Print(files.debug, "DefList::MergeDefender: new");
}
for (unsigned d2 = 0; d2 < def2.len; d2++)
* this += def2.list[d2];
if (options.debugDef)
DefList::Print(files.debug, "DefList::MergeDefender after merge");
DefList::RegisterSize("NEWDEF3");
}
void DefList::operator *= (
const DefList& def2)
{
/*
Need to make the "cross product" for declarer.
General principle:
List 1: min( max(a1, a2), max(a3, a4)
List 2: min( max(a5, a6), max(a7, a8)
max(List 1, List2) =
min( max(a1256), max(a1278), max(3456), max(3478))
For each defense, there is a worst rank needed in any of the
alternatives. If we eliminate that alternative, we lose the
reference to the rank, making the result too optimistic. So
we first figure out the worst rank for each defense. Then for
that defense, we go through its alternatives and lower the
ranks in each alternative. This is a bit tricky. We need
to know the highest rank held by the opponents.
*/
assert(len > 0);
assert(def2.len > 0);
headerDirty = true;
if (options.debugDef)
{
DefList::Print(files.debug, "DefList::MergeDeclarer old");
def2.Print(files.debug, "DefList::MergeDeclarer: new");
// DefList::Print(cout, "DefList::MergeDeclarer old");
// def2.Print(cout, "DefList::MergeDeclarer: new");
}
/*
If one side has > (at least once), = and no !=, AND
if the other side has <, = and perhaps !=, THEN
the first side is better.
Declarer will not choose the second side, as the defense
can then stick to the inferior ones and always do at least
as well.
*/
AltMatrix2D comp;
comp.SetDimensions(len, def2.len);
for (unsigned dOld = 0; dOld < len; dOld++)
for (unsigned dNew = 0; dNew < def2.len; dNew++)
comp.SetValue(dOld, dNew, list[dOld].CompareAlmostHard(def2.list[dNew]));
// comp.SetValue(dOld, dNew, list[dOld].CompareHard(def2.list[dNew]));
CmpDetailType c = comp.CompareDeclarer();
if (c == SDS_HEADER_PLAY_OLD_BETTER ||
c == SDS_HEADER_RANK_OLD_BETTER ||
c == SDS_HEADER_SAME)
{
// Nothing more to do.
}
else if (c == SDS_HEADER_PLAY_NEW_BETTER ||
c == SDS_HEADER_RANK_NEW_BETTER)
{
* this = def2;
}
else
{
// Make one copy.
unsigned oldLen = len;
vector<AltList> oldList(oldLen);
for (unsigned d = 0; d < oldLen; d++)
oldList[d] = list[d];
len = 0;
for (unsigned dnew = 0; dnew < def2.len; dnew++)
{
for (unsigned dold = 0; dold < oldLen; dold++)
{
switch (oldList[dold].CompareSemiHard(def2.list[dnew]))
{
case SDS_HEADER_SAME:
case SDS_HEADER_PLAY_OLD_BETTER:
case SDS_HEADER_RANK_OLD_BETTER:
* this += oldList[dold];
break;
case SDS_HEADER_PLAY_NEW_BETTER:
case SDS_HEADER_RANK_NEW_BETTER:
* this += def2.list[dnew];
break;
default:
AltList alt = oldList[dold] + def2.list[dnew];
* this += alt;
}
}
}
}
if (options.debugDef)
DefList::Print(files.debug, "DefList::MergeDeclarer after Merge");
DefList::RegisterSize("NEWDEF4");
}
bool DefList::MergeSidesSoft(
const DefList& def1,
const DefList& def2)
{
if (def2.len == 0)
{
* this = def1;
return true;
}
if (def1.len != def2.len)
return false;
if (options.debugDef)
{
def1.Print(files.debug, "DefList::MergeSidesSoft def1");
def2.Print(files.debug, "DefList::MergeSidesSoft def2");
// def1.Print(cout, "DefList::MergeSidesSoft def1");
// def2.Print(cout, "DefList::MergeSidesSoft def2");
}
DefList::Reset();
if (def1.len == 1 && def2.len == 1)
{
if (def1.list[0].CanMergeSides(def2.list[0]))
{
* this = def1;
list[0].SetStart();
}
else if (def1.list[0].MergeSoftSpecial(def2.list[0]))
{
// Success.
* this = def1;
list[0].Concatenate(def2.list[0]);
}
else
{
AltList alt = def1.list[0] + def2.list[0];
* this += alt;
}
list[0].ReduceSpecial(); // Dubious long-term
return true;
}
vector<bool> purge1(def1.len, false);
vector<bool> purge2(def2.len, false);
unsigned count = 0;
for (unsigned d2 = 0; d2 < def2.len; d2++)
{
if (purge2[d2])
continue;
for (unsigned d1 = 0; d1 < def1.len; d1++)
{
if (purge1[d1])
continue;
if (def1.list[d1].CanMergeSides(def2.list[d2]))
{
purge1[d1] = true;
purge2[d2] = true;
count++;
* this += def1.list[d1];
break;
}
}
}
if (count != def1.len)
return false;
* this = def1;
for (unsigned d = 0; d < len; d++)
list[d].SetStart();
if (options.debugDef)
DefList::Print(files.debug, "DefList::MergeSidesSoft result");
return true;
}
void DefList::MergeSidesHard(
const DefList& def1,
const DefList& def2)
{
// The two defenses have different starting sides.
// It is not clear that these should be merged. Here we take
// the view that it is nice to merge those entries that are the
// same except for the starting point. The rest are concatenated.
assert(def1.len > 0);
assert(def2.len > 0);
DefList::Reset();
if (options.debugDef)
{
def1.Print(files.debug, "DefList::MergeSidesHard def1");
def2.Print(files.debug, "DefList::MergeSidesHard def2");
}
// Merge defenses as a cross product.
for (unsigned d2 = 0; d2 < def2.len; d2++)
{
for (unsigned d1 = 0; d1 < def1.len; d1++)
{
AltList alt = def1.list[d1] + def2.list[d2];
* this += alt;
}
}
if (options.debugDef)
DefList::Print(files.debug, "DefList::MergeSidesHard result");
DefList::RegisterSize("NEWDEF5");
}
void DefList::Purge(
const vector<bool>& skip)
{
unsigned p = 0;
for (unsigned d = 0; d < len; d++)
{
if (! skip[d])
{
if (d > p)
list[p] = list[d];
p++;
}
}
len = p;
}
bool DefList::Reduce()
{
// Eliminate superfluous combinations, as seen by defenders.
if (len <= 1)
return false;
vector<bool> skip(len, false);
bool purge = false;
for (unsigned d1 = 0; d1 < len; d1++)
{
if (skip[d1])
continue;
for (unsigned d2 = d1+1; d2 < len; d2++)
{
if (skip[d2])
continue;
CmpDetailType cd = list[d2].Compare(list[d1]);
CmpType c = cmpDetailToShort[cd];
// If new (d1) is better, the defense will not choose it.
if (c == SDS_SAME || c == SDS_NEW_BETTER)
{
skip[d1] = true;
purge = true;
}
else if (c == SDS_OLD_BETTER)
{
skip[d2] = true;
purge = true;
}
}
}
if (purge)
DefList::Purge(skip);
return purge;
}
void DefList::RegisterSize(
const string& text)
{
if (len > highestDefNo)
{
highestDefNo = len;
files.track << text << ": " << len << "\n";
if (len > SDS_MAX_DEF)
{
cout << "Too many alternatives" << endl;
assert(false);
}
}
}
void DefList::Print(
ostream& out,
const string& text) const
{
if (! text.empty())
out << setw(0) << text << "\n";
out <<
right <<
setw(4) << "Def" <<
setw(6) << "Alt" <<
setw(6) << "No" <<
setw(6) << "Start" <<
setw(6) << "End" <<
setw(6) << "Cash" <<
setw(9) << "Ranks\n";
for (unsigned d = 0; d < len; d++)
list[d].Print(out, "", d);
out << endl;
}
|
e90cde69e56a96ef69f70c0f84aa6d90b4d14ee9 | b62f3c45adda3ff7e273759c976216201dea8dc2 | /src/test/main.cc | f4d38096da0eae88fdc550fdb2adf346580f264b | [] | no_license | jyosoman/FaultSim | 48bf9d1a0069c6aabd6558167a0f49446d800843 | 324696a2d7f01bfd96102ff4a042a2c05cc9bee9 | refs/heads/master | 2020-05-24T04:24:33.519986 | 2017-05-19T14:56:22 | 2017-05-19T14:56:22 | 84,820,876 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,456 | cc | main.cc | #include"base.hh"
#include"decoder.hh"
#include"mux.hh"
#include"flipFlop.hh"
#include<cstdio>
int main(){
DFlipFlop f;
// TriNandGate tj;
OutWire arr[4];
/* OutWire arr2[16]; */
// Multiplexer<16,4> mux;
// MinpNandGate<4> fin;
// Decoder<4> decode;
// for(int i=0;i<16;i++){
// mux.setWire(&arr2[i],i);
// }
for(int i=0;i<4;i++){
// mux.setWire(&arr[i],i+16);
// decode.setWire(&arr2[i],i);
// fin.setWire(&arr[i],i);
}
for(int i=0;i<2;i++){
f.setWire(&arr[i],i);
// tj.setWire(&arr[i],i);
}
f.test();
// cout<<FaultType::flist.size()<<endl;
// FaultType::FLiterator fliter=FaultType::flist.begin();
// for(;fliter!=FaultType::flist.end();++fliter){
// (*fliter)->setFaulty();
// }
// return 0;
// f.test();
// fin.test();
// decode.test();
return 0;
/* for(int i=0;i<16;i++){ */
/* arr2[i].set(true); */
/* for(int j=0;j<16;j++){ */
/* for(int k=0;k<4;k++){ */
/* if(j&1<<k){ */
/* arr[k].set(true); */
/* }else{ */
/* arr[k].set(false); */
/* } */
/* } */
/* mux.output(); */
/* std::cout<<i<<" "<<j<<" "<<std::boolalpha<<mux.getWire(0)->get()<<'\n'; */
/* } */
/* arr2[i].set(false); */
/* } */
/* return 0; */
/* return 0; */
}
|
1c0bc9cc2b6b31ca323cfe95594915f986ce524a | 1f7ed0251d8412e5f68533336fbc48b4fc1b2815 | /src/color.cc | 442334228ff6bf4d64033aadded67b1472c4548d | [
"MIT"
] | permissive | nagyist/kortex | bc83de1aca8e26768abc64e157e6b2993d35094a | 07f490ec7f36422aa41941641e7e7d81ec7eec26 | refs/heads/master | 2022-12-23T11:02:49.643800 | 2022-04-13T16:29:39 | 2022-04-13T16:29:39 | 92,093,604 | 0 | 0 | MIT | 2022-12-16T23:50:38 | 2017-05-22T19:52:00 | C++ | UTF-8 | C++ | false | false | 9,227 | cc | color.cc | // ---------------------------------------------------------------------------
//
// This file is part of the <kortex> library suite
//
// Copyright (C) 2013 Engin Tola
//
// See LICENSE file for license information.
//
// author: Engin Tola
// e-mail: engintola@gmail.com
// web : http://www.engintola.com
//
// ---------------------------------------------------------------------------
#include <cmath>
#include <kortex/color.h>
#include <kortex/string.h>
namespace kortex {
void hsv_to_rgb( float h, float s, float v, float &r, float &g, float &b ) {
if( s == 0.0f ) {
r = g = b = v;
return;
}
h /= 60.0f;
int i = (int)floor(h);
float f = h - float(i);
float p = v * ( 1.0f - s );
float q = v * ( 1.0f - s * f );
float t = v * ( 1.0f - s * ( 1.0f - f ) );
switch( i ) {
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
default: r = v; g = p; b = q; break;
}
}
void get_color(ColorName color, uchar &cr, uchar &cg, uchar &cb) {
switch( color ) {
case COLOR_BLACK : cr = 0; cg = 0; cb = 0; break;
case COLOR_WHITE : cr = 255; cg = 255; cb = 255; break;
case COLOR_RED : cr = 255; cg = 0; cb = 0; break;
case COLOR_GREEN : cr = 0; cg = 255; cb = 0; break;
case COLOR_BLUE : cr = 0; cg = 0; cb = 255; break;
case COLOR_CYAN : cr = 0; cg = 255; cb = 255; break;
case COLOR_YELLOW : cr = 255; cg = 255; cb = 0; break;
case COLOR_MAGENTA : cr = 255; cg = 0; cb = 255; break;
case COLOR_ORANGE : cr = 255; cg = 165; cb = 0; break;
case COLOR_PURPLE : cr = 128; cg = 0; cb = 128; break;
case COLOR_PINK : cr = 255; cg = 192; cb = 203; break;
case COLOR_BROWN : cr = 136; cg = 69; cb = 19; break;
case COLOR_GOLD : cr = 255; cg = 215; cb = 0; break;
case COLOR_SILVER : cr = 190; cg = 190; cb = 190; break;
case COLOR_LIME : cr = 210; cg = 245; cb = 60; break;
case COLOR_TEAL : cr = 0; cg = 128; cb = 128; break;
case COLOR_LAVENDER : cr = 230; cg = 190; cb = 255; break;
case COLOR_BEIGE : cr = 255; cg = 250; cb = 200; break;
case COLOR_MAROON : cr = 128; cg = 0; cb = 0; break;
case COLOR_MINT : cr = 170; cg = 255; cb = 195; break;
case COLOR_OLIVE : cr = 128; cg = 128; cb = 0; break;
case COLOR_CORAL : cr = 255; cg = 215; cb = 180; break;
case COLOR_GRAY : cr = 128; cg = 128; cb = 128; break;
case COLOR_LRED : cr = 255; cg = 51; cb = 51; break;
case COLOR_LGREEN : cr = 51; cg = 255; cb = 51; break;
case COLOR_LBLUE : cr = 51; cg = 51; cb = 255; break;
case COLOR_LCYAN : cr = 51; cg = 255; cb = 255; break;
case COLOR_LMAGENTA : cr = 255; cg = 51; cb = 255; break;
case COLOR_LYELLOW : cr = 255; cg = 255; cb = 51; break;
case COLOR_LORANGE : cr = 255; cg = 153; cb = 51; break;
case COLOR_LPURPLE : cr = 178; cg = 102; cb = 255; break;
case COLOR_LPINK : cr = 255; cg = 102; cb = 255; break;
case COLOR_LBROWN : cr = 205; cg = 133; cb = 63; break;
case COLOR_LGOLD : cr = 250; cg = 250; cb = 210; break;
case COLOR_LGRAY : cr = 90; cg = 90; cb = 90; break;
default : cr = 255; cg = 0; cb = 0; break;
}
}
ColorName get_color( const string& str ) {
if( !compare_string_nc(str, "black" ) ) return COLOR_BLACK ;
if( !compare_string_nc(str, "white" ) ) return COLOR_WHITE ;
if( !compare_string_nc(str, "red" ) ) return COLOR_RED ;
if( !compare_string_nc(str, "green" ) ) return COLOR_GREEN ;
if( !compare_string_nc(str, "blue" ) ) return COLOR_BLUE ;
if( !compare_string_nc(str, "cyan" ) ) return COLOR_CYAN ;
if( !compare_string_nc(str, "yellow" ) ) return COLOR_YELLOW ;
if( !compare_string_nc(str, "magenta" ) ) return COLOR_MAGENTA ;
if( !compare_string_nc(str, "orange" ) ) return COLOR_ORANGE ;
if( !compare_string_nc(str, "purple" ) ) return COLOR_PURPLE ;
if( !compare_string_nc(str, "pink" ) ) return COLOR_PINK ;
if( !compare_string_nc(str, "brown" ) ) return COLOR_BROWN ;
if( !compare_string_nc(str, "gold" ) ) return COLOR_GOLD ;
if( !compare_string_nc(str, "silver" ) ) return COLOR_SILVER ;
if( !compare_string_nc(str, "lime" ) ) return COLOR_LIME ;
if( !compare_string_nc(str, "teal" ) ) return COLOR_TEAL ;
if( !compare_string_nc(str, "lavender" ) ) return COLOR_LAVENDER ;
if( !compare_string_nc(str, "beige" ) ) return COLOR_BEIGE ;
if( !compare_string_nc(str, "maroon" ) ) return COLOR_MAROON ;
if( !compare_string_nc(str, "mint" ) ) return COLOR_MINT ;
if( !compare_string_nc(str, "olive" ) ) return COLOR_OLIVE ;
if( !compare_string_nc(str, "coral" ) ) return COLOR_CORAL ;
if( !compare_string_nc(str, "gray" ) ) return COLOR_GRAY ;
if( !compare_string_nc(str, "light-red" ) ) return COLOR_LRED ;
if( !compare_string_nc(str, "light-green" ) ) return COLOR_LGREEN ;
if( !compare_string_nc(str, "light-blue" ) ) return COLOR_LBLUE ;
if( !compare_string_nc(str, "light-cyan" ) ) return COLOR_LCYAN ;
if( !compare_string_nc(str, "light-magenta" ) ) return COLOR_LMAGENTA ;
if( !compare_string_nc(str, "light-yellow" ) ) return COLOR_LYELLOW ;
if( !compare_string_nc(str, "light-orange" ) ) return COLOR_LORANGE ;
if( !compare_string_nc(str, "light-purple" ) ) return COLOR_LPURPLE ;
if( !compare_string_nc(str, "light-pink" ) ) return COLOR_LPINK ;
if( !compare_string_nc(str, "light-brown" ) ) return COLOR_LBROWN ;
if( !compare_string_nc(str, "light-gold" ) ) return COLOR_LGOLD ;
if( !compare_string_nc(str, "light-gray" ) ) return COLOR_LGRAY ;
return COLOR_RED;
}
string get_color_string( const ColorName& color ) {
switch( color ) {
case COLOR_BLACK : return string("black" );
case COLOR_WHITE : return string("white" );
case COLOR_RED : return string("red" );
case COLOR_GREEN : return string("green" );
case COLOR_BLUE : return string("blue" );
case COLOR_CYAN : return string("cyan" );
case COLOR_YELLOW : return string("yellow" );
case COLOR_MAGENTA : return string("magenta" );
case COLOR_ORANGE : return string("orange" );
case COLOR_PURPLE : return string("purple" );
case COLOR_PINK : return string("pink" );
case COLOR_BROWN : return string("brown" );
case COLOR_GOLD : return string("gold" );
case COLOR_SILVER : return string("silver" );
case COLOR_LIME : return string("lime" );
case COLOR_TEAL : return string("teal" );
case COLOR_LAVENDER : return string("lavender" );
case COLOR_BEIGE : return string("beige" );
case COLOR_MAROON : return string("maroon" );
case COLOR_MINT : return string("mint" );
case COLOR_OLIVE : return string("olive" );
case COLOR_CORAL : return string("coral" );
case COLOR_GRAY : return string("gray" );
case COLOR_LRED : return string("light-red" );
case COLOR_LGREEN : return string("light-green" );
case COLOR_LBLUE : return string("light-blue" );
case COLOR_LCYAN : return string("light-cyan" );
case COLOR_LYELLOW : return string("light-yellow" );
case COLOR_LMAGENTA : return string("light-magenta" );
case COLOR_LORANGE : return string("light-orange" );
case COLOR_LPURPLE : return string("light-purple" );
case COLOR_LPINK : return string("light-pink" );
case COLOR_LBROWN : return string("light-brown" );
case COLOR_LGOLD : return string("light-gold" );
case COLOR_LGRAY : return string("light-gray" );
}
return "no-such-color";
}
float max_color_diff( const Color& a, const Color& b ) {
return std::max( std::fabs( float(a.r)-float(b.r) ),
std::max( std::fabs( float(a.g)-float(b.g) ),
std::fabs( float(a.b)-float(b.b) ) ) );
}
}
|
9946d341476f0cb6b356d490b300fd70aee8b580 | 75c22794271fe509915f2a22af13121be10489ea | /migrate/ioc/step4/ltask.hpp | 4da216b4a24e857242249b930fd4207c9abc7bfe | [
"BSD-3-Clause"
] | permissive | OS2World/DEV-SAMPLES-VisualAgeCPP4_Samples | 58c8edbfd1432add2e812abd1e60fbbb56ca7322 | 21975b49b0cb63cf4f6318b01c2d2daefc419cb4 | refs/heads/master | 2021-01-10T21:19:57.198852 | 2019-05-23T01:16:06 | 2019-05-23T01:16:06 | 18,744,150 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,534 | hpp | ltask.hpp | /*******************************************************************************
* FILE NAME: ltask.hpp *
* *
* DESCRIPTION: *
* *
* Classes *
* TaskPage *
* TaskCnrObj *
* *
* COPYRIGHT: *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1992, 1995 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
* CHANGE HISTORY: *
*******************************************************************************/
#ifndef _LTASK_
#define _LTASK_
#include <imcelcv.hpp>
#include <icnrctl.hpp>
#include <icnrcol.hpp>
#include <istring.hpp>
#include <icombobx.hpp>
#include <ientryfd.hpp>
#include <icmdhdr.hpp>
#include <icheckbx.hpp>
#include <imsgbox.hpp>
#include <ipoint.hpp>
#include <inotebk.hpp>
#include <iapp.hpp>
#include "ldbase.hpp"
#include "lproject.hpp"
#include "lpagectl.hpp"
/******************************************************************************
* Class TaskCnrObj - Task container object. *
******************************************************************************/
class TaskCnrObj : public IContainerObject
{
public:
/*------------------------ Constructors/Destructor ----------------------------
| Construct the object given a task, description, and billable flag. |
-----------------------------------------------------------------------------*/
TaskCnrObj( const IString& stTask,
const IString& stDesc,
const IString& stBill );
~TaskCnrObj();
/*------------------------------- Accessors -----------------------------------
| These functions provide a means of getting and setting the accessible |
| attributes of instances of this class: |
| task - Returns the task. |
| desc - Returns the description. |
| bill - Returns the billable status. |
| setTask - Sets the task. |
| setDesc - Sets the description. |
| setBill - Sets the billable status. |
| taskOffset - Returns the container offset for the task. |
| descOffset - Returns the container offset for the description. |
| billOffset - Returns the container offset for the billable status.|
-----------------------------------------------------------------------------*/
inline IString
task() const { return Task; };
inline IString
desc() const { return Desc; };
inline IString
bill() const { return Bill; };
inline TaskCnrObj
&setTask( const IString& ta ) { Task=ta; return *this; };
inline TaskCnrObj
&setDesc( const IString& de ) { Desc=de; return *this; };
inline TaskCnrObj
&setBill( const IString& bi ) { Bill=bi; return *this; };
inline unsigned long
taskOffset() { return offsetof( TaskCnrObj, Task ); };
inline unsigned long
descOffset() { return offsetof( TaskCnrObj, Desc ); };
inline unsigned long
billOffset() { return offsetof( TaskCnrObj, Bill ); };
private:
IString
Task,
Desc,
Bill;
};
/******************************************************************************
* Class TasksPage - Task page. *
******************************************************************************/
class TasksPage : public IMultiCellCanvas,
public ICommandHandler,
public ISelectHandler
{
public:
friend class TimeCard;
/*------------------------ Constructors/Destructor ----------------------------
| Construct the object in only one way: |
| 1) IWindow*, IString. |
-----------------------------------------------------------------------------*/
TasksPage( IWindow* pParent,
const IString& theKey = NULL );
~TasksPage();
/*------------------------ Database Functions ---------------------------------
| These functions are used to save data to the database: |
| verifyAndSave - Verify the page data and save to the database. |
-----------------------------------------------------------------------------*/
Boolean
verifyAndSave( IString& theString,
IString& theEntry,
const IString saveName = NULL );
/*------------------------------ Accessors ------------------------------------
| These functions provide a means of getting and setting the accessible |
| attributes of instances of this class: |
| pageSettings - Return the page settings for this page. |
| key - Return the key. |
| getTaskData - Return the task data. |
| setTaskData - Set the task data. |
-----------------------------------------------------------------------------*/
inline INotebook::PageSettings
pageSettings() { return thePageSettings; };
inline IString
&key() { return Key; };
inline LTaskData
&getTaskData() { return taskData; };
Boolean
setTasksData();
/*----------------------------- Page Manipulation -----------------------------
| These functions provide a means of manipulating the instances of this class:|
| fillEntryfields - Fill the entryfields for the given container object.|
-----------------------------------------------------------------------------*/
TasksPage&
fillEntryfields( TaskCnrObj* cnrObject );
protected:
/*----------------------------- Event Processing ------------------------------
| Handle and process events: |
| command - Process command events. |
| handleIt - Start handling events. |
-----------------------------------------------------------------------------*/
Boolean
command( ICommandEvent& event );
TasksPage
&handleIt();
private:
TasksPage
&setCells(),
&fillCnr();
Boolean
addTask( IString& i1, IString& i2, IString& i3 ),
changeTask( IString& i1, IString& i2, IString& i3, TaskCnrObj* cnrObj );
TasksPage
&unMark();
PageButtons
pageButtons;
PageCnrButtons
pageCnrButtons;
IStaticText
taskText,
billableText,
descrText;
// currentTasksText,
// descr2Text,
// billable2Text;
IEntryField
task;
ICheckBox
billable;
IEntryField
descr;
IContainerControl
*pCnr;
TaskCnrObj
*pTaskCnrObj;
IContainerColumn
*pColTask;
IContainerColumn
*pColDesc,
*pColBill;
LTaskData
taskData,
origTaskData;
IString
Key;
INotebook::PageSettings
thePageSettings;
PageCnrSelHandler
cnrSelHandler;
};
#endif
|
b3d0bf521fa4ccd130e1eb8fad1ba41e4fadfd3f | 474bb820fb472ff350bf032ee502010da0e455cb | /contest/100_1/f.cpp | a3e77f094db00f452de8cf207962d69ad80424ca | [] | no_license | wqrqwerqrw/acm_code | 839b1f3f50abcacec6f83acf3f002a887468b0d7 | 15b90fa1f12b8dca64d751525f9c73509f61328b | refs/heads/master | 2020-05-02T20:02:42.232841 | 2020-02-10T11:59:55 | 2020-02-10T11:59:55 | 178,177,685 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,200 | cpp | f.cpp | /*************************************************************************
> File Name: f.cpp
> Author: Wqr_
> Mail: xueduanwei@126.com
> Created Time: 2019年04月10日 星期三 18时44分41秒
************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct point {
int x, y;
};
int n;
point a, b;
unsigned long long int getdis(point in1, point in2) {
return (in1.x - in2.x) * (in1.x - in2.x) + (in1.y - in2.y) * (in1.y - in2.y);
}
unsigned long long int maxa = 0, maxb = 0;
int main() {
cin >> n;
scanf("%d %d %d %d", &a.x, &a.y, &b.x, &b.y);
for (int i = 0; i < n; i++) {
point in;
scanf("%d %d", &in.x, &in.y);
unsigned long long int disa = getdis(in, a), disb = getdis(in, b);
if (disa <= maxa || disb <= maxb) continue;
if (disa > disb) {
if (disb > maxb) maxb = disb;
} else if (disa < disb) {
if (disa > maxa) maxa = disa;
} else {
if (maxa >= maxb) {
maxa = disa;
} else {
maxb = disb;
}
}
}
cout << maxa + maxb;
return 0;
}
|
1227d0a0b9b32981477f8e4a7b473d9e34f2b60b | a36ece85a3f8f38823c25c8b811fdb3edaabcdce | /concurrency-tutorial/06_conc_for.cpp | 04b8d00758f3072fb20b9dee93b00214bc7b10fb | [
"MIT"
] | permissive | lucteo/cppnow2021-examples | f5b7c9be579127947db5e5e204197222160befb8 | 8ad8b9675dc7ed64f8600cdad1c8f96f3e7bfc16 | refs/heads/main | 2023-04-27T10:42:37.366150 | 2021-05-05T20:29:03 | 2021-05-05T20:29:03 | 359,230,980 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 457 | cpp | 06_conc_for.cpp | #include <concore/conc_for.hpp>
#include "../common/utils.hpp"
void work(int idx) {
CONCORE_PROFILING_FUNCTION();
sleep_in_between_ms(20, 40);
printf("I'm a proud worker, working on part %d\n", idx);
}
int main() {
profiling_sleep profiling_helper;
CONCORE_PROFILING_FUNCTION();
init_randomness();
concore::conc_for(0, 20, work);
// std::for_each(std::execution::par, int_iter{0}, int_iter{20}, work);
return 0;
}
|
76bb6824b5189fab4108e26dd8467045c1a92ae8 | b7a45921d713ae1c5ee0a11a7655c68772d7521b | /linux/src/main_part2.cpp | 0ff6d453b9ba4ad7018c52871fce24813a6678eb | [] | no_license | DexterAntonio/motionTracking | da47e62bf6a498cf067ebb26bdb5fcf22315c707 | 50905b1b3dc20034fad4bd1129654515fc0bd272 | refs/heads/master | 2022-02-17T07:13:59.204708 | 2019-09-20T04:59:31 | 2019-09-20T04:59:31 | 108,012,944 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 910 | cpp | main_part2.cpp | #include "ps3eye.h"
#include "context.h"
#include "frame_function.h"
#include <iostream>
#include "../include/context.h"
#define STRINGMACRO "||======================================||" //example of macro
int main(){
//STRINGMACRO;
std::string color;
std::cout << STRINGMACRO <<endl;
std::cout << "HW4: MOVEMENT TRACKING" << std::endl;
std::cout << "Instructions: Please keep camera still. To activate movement tracking " << endl;
std::cout << "Click on output window and press t then " <<endl;
std::cout << "enter color you would like to track images with in the command window" <<endl;
std::cout<< "OTHER COMMANDS: press a to average, i to invert, f to flip, n to go back to normal, esc to quit" <<std::endl;
std::cout << "if you move the camera press r to reset the background used to detect movement " <<endl;
std::cout << STRINGMACRO <<endl;
Context ctx;
run_camera(ctx);
}
|
6eb4998090bf55244656622866fbe98b1bbeeb73 | e413e4020617f2645f7f3ed89ec698183c17e919 | /Tracing/ftl2d/ftl2d_Tracer.cxx | 176fdeff1e14b11b17518c775f8788f4e3a6c307 | [] | no_license | YanXuHappygela/Farsight-latest | 5c349421b75262f89352cc05093c04d3d6dfb9b0 | 021b1766dc69138dcd64a5f834fdb558bc558a27 | refs/heads/master | 2020-04-24T13:28:25.601628 | 2014-09-30T18:51:29 | 2014-09-30T18:51:29 | 24,650,739 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,977 | cxx | ftl2d_Tracer.cxx | /*=========================================================================
Copyright 2009 Rensselaer Polytechnic Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#include "ftl2d_Tracer.h"
#define DEBUG 0
Tracer::Tracer(TraceConfig *config) {
VesselContainer.reserve(2000);
}
Tracer::~Tracer() {
//delete VesselContainer
std::vector<Vessel *>::iterator it;
for (it = VesselContainer.begin(); it != VesselContainer.end(); ++it)
delete (*it);
// std::cout << "Trace DELETED" << std::endl;
}
void Tracer::Run(ImageType::Pointer &im, SeedContainer2D *sc, TraceConfig *config) {
//TraceContainer *TC = new TraceContainer(config);
for (unsigned int i = 0; i <sc->getNumberOfSeeds(); i++) {
//for (unsigned int i = 6; i < 8; i++) {
Segment2D *s = new Segment2D(config); //index = 0
s->CopySeedInformation(sc->getSeed(i));
//Print the seed and Segment
#if DEBUG == 2
std::cout << "*****************************************************************************"<< std::endl;
std::cout << "Seed Point "<< std::endl;
sc->getSeed(i)->PrintSelf();
s->PrintSelf(2);
#endif
Segment2D* s_hit = this->HitTest(s);
//if (!this->HitTest(s, s_hit)) {
if (s_hit == NULL) {
delete s_hit;
s->Initialize(im);
#if DEBUG == 2
std::cout << "Starting Segment [(0)-not valid (1)-valid] "<<s->IsSeedSegmentValid()<< std::endl;
s->PrintSelf(2);
#endif
if (s->IsSeedSegmentValid()) {
Vessel *v = new Vessel(config, this->getNumberOfVessels());
v->AddSegmentToVessel(s);
Segment2D *s_prev = s;
while (s_prev->IsSegmentValid() == 1) {
Segment2D * s_new = TraceStep(im, s_prev, config);
#if DEBUG == 2
std::cout<<"Segment ID " << s_new->getID() << " FWD "<<"Vessel size " << v->getNumberOfSegments()<<std::endl;
s_new->PrintSelf(2);
std::cin.get();
#endif
if( !v->AddSegmentToVesselIfValid(s_new) )
break;
Segment2D* s_hit = this->HitTest(s_new);
//if (this->HitTest(s_new, s_hit)) {
if (s_hit != NULL) {
v->AddSegmentToVessel( s_hit);
v->SetEndType(22); //The vessel is HIT
#if DEBUG == 2
s_hit->PrintSelf(2);
s_new->PrintSelf(2);
v->PrintSelf(); std::cin.get();
#endif
break;
}
else {
delete s_hit;
}
s_prev = s_new;
}
s_prev = s;
s_prev->flipDirection(v->getNumberOfSegments());
v->flipDirection();
while (s_prev->IsSegmentValid() == 1) {
Segment2D *s_new = TraceStep(im, s_prev, config);
#if DEBUG == 2
std::cout<<"Segment ID " << s_new->getID() << " REV "<<"Vessel size " << v->getNumberOfSegments()<<std::endl;
s_new->PrintSelf(2);
std::cin.get();
#endif
if( !v->AddSegmentToVesselIfValid(s_new) )
break;
Segment2D* s_hit = this->HitTest(s_new);
if (s_hit != NULL) {
v->AddSegmentToVessel( s_hit);
v->SetEndType(22); //The vessel is HIT
#if DEBUG == 2
s_hit->PrintSelf(2);
s_new->PrintSelf(2);
v->PrintSelf(); std::cin.get();
#endif
break;
}
else {
delete s_hit;
}
s_prev = s_new;
}
if (v->IsVesselValid()) {
#if DEBUG >= 1
v->PrintSelf(); std::cin.get();
#endif
this->AddVessel(v);
#if DEBUG == 0
std::cout << i << "/"<<sc->getNumberOfSeeds()<<"\r";
#endif
}
}
}
}
}
Segment2D* Tracer::TraceStep(ImageType::Pointer &im, Segment2D* s_prev, TraceConfig *config){
Segment2D* s = new Segment2D(config);
s->advance( s_prev );
s->fitSuperEllipsoid(im);
s->SegmentValidCheck(); //implements the segment level rules
return s;
}
void Tracer::ApplyRules() {
}
void Tracer::AddBranchPoint(Segment2D* s1, Segment2D* s2) {
BranchPoint *b = new BranchPoint();
b->AddBranchPoint(s1, s2);
this->BranchPointContainer.push_back(b);
}
Segment2D* Tracer::HitTest( Segment2D *s) {
std::vector<Vessel *>::iterator it;
Vect2 mu, bdry1, bdry2, offset;
offset[0] = sin(s->getq())*s->geta1();
offset[1] = cos(s->getq())*s->geta1();
mu = s->getmu();
bdry1 = mu + offset;
bdry2 = mu - offset;
for (it = this->VesselContainer.begin(); it !=this->VesselContainer.end(); ++it) {
for (unsigned int j = 0; j < (*it)->getNumberOfSegments(); j++) {
// if (IsPointInsideSE(bdry1, (*it)->getSegment(j)) || IsPointInsideSE(bdry2, (*it)->getSegment(j)) || IsPointInsideSE(mu, (*it)->getSegment(j))) {
if (IsPointInsideSE(mu, (*it)->getSegment(j))) {
//std::cout<< "HIT vessel " << (*it)->getID()<< "Segment" << (*it)->getSegment(j)->getID() << std::endl;
this->AddBranchPoint((*it)->getSegment(j), s);
Segment2D *s_hit = new Segment2D((*it)->getSegment(j));
return s_hit;
}
}
}
return NULL;
}
bool Tracer::IsPointInsideSE(Vect2 &p, Segment2D *s) {
Vect2 dmu, R1, R2,D;
double a1, a2, d;
R1[0] = cos(s->getq());
R1[1] = sin(s->getq());
R2[0] = -1*R1[1];
R2[1] = R1[0];
a1 = s->geta1();
a2 = s->geta2() / 2;
dmu = p - (s->getmu() - a2*R2); // this is BK in the code
D[0] = dot_product(R1,dmu);
D[1] = dot_product(R2,dmu);
D[0] = D[0]/a1;
D[1] = D[1]/a2;
d = D[0]*D[0] + D[1]*D[1];
if (d < 1)
return 1;
else
return 0;
}
bool Tracer::getTraces(Vect2& p, unsigned int vs, unsigned int seg) {
if (vs < this->VesselContainer.size()) {
if (seg < this->VesselContainer[vs]->getNumberOfSegments()) {
p = this->VesselContainer[vs]->getSegment(seg)->getmu();
return 1;
}
}
return 0;
}
void Tracer::ReportXML (TraceConfig *config) {
xmlDocPtr doc = NULL; /* document pointer */
xmlNodePtr root_node = NULL, vessel_node = NULL, segment_node = NULL, node2 = NULL, node3 = NULL;/* node pointers */
xmlDtdPtr dtd = NULL; /* DTD pointer */
std::string str;
LIBXML_TEST_VERSION;
/*
* Creates a new document, a node and set it as a root node
*/
doc = xmlNewDoc(BAD_CAST "1.0");
root_node = xmlNewNode(NULL, BAD_CAST "Tracing2D");
str = "SuperEllipsoid2D";
xmlNewProp(root_node, BAD_CAST "Algorihm", BAD_CAST str.c_str());
str = ToString((double)config->getGridSpacing());
xmlNewProp(root_node, BAD_CAST "InputFileName", BAD_CAST config->getInputFileName().c_str());
str = ToString((double)config->getGridSpacing());
xmlNewProp(root_node, BAD_CAST "GridSpacing", BAD_CAST str.c_str());
str = ToString((double)config->getInitSeedSize());
xmlNewProp(root_node, BAD_CAST "InitialSeedSize", BAD_CAST str.c_str());
str = ToString((double)config->getSeedIntensityThreshold());
xmlNewProp(root_node, BAD_CAST "SeedIntensityThreshold", BAD_CAST str.c_str());
str = ToString((double)config->getStepRatio());
xmlNewProp(root_node, BAD_CAST "StepRatio", BAD_CAST str.c_str());
str = ToString((double)config->getAspectRatio());
xmlNewProp(root_node, BAD_CAST "AspectRatio", BAD_CAST str.c_str());
str = ToString((double)config->getMinimumVesselWidth());
xmlNewProp(root_node, BAD_CAST "MinimumVesselWidth", BAD_CAST str.c_str());
str = ToString((double)config->getMaximumVesselWidth());
xmlNewProp(root_node, BAD_CAST "MaximumVesselWidth", BAD_CAST str.c_str());
str = ToString((double)config->getPROP());
xmlNewProp(root_node, BAD_CAST "Sensitivity", BAD_CAST str.c_str());
xmlDocSetRootElement(doc, root_node);
std::vector<Vessel *>::iterator it;
for (it = this->VesselContainer.begin(); it !=this->VesselContainer.end(); ++it) {
vessel_node = xmlNewChild(root_node, NULL, BAD_CAST "TraceLine", NULL);
str = ToString((double)(*it)->getID());
xmlNewProp(vessel_node, BAD_CAST "ID", BAD_CAST str.c_str());
for (unsigned int j = 0; j < (*it)->getNumberOfSegments(); j++) {
segment_node = xmlNewChild(vessel_node, NULL, BAD_CAST "TraceBit", NULL);
str = ToString((double)(*it)->getSegment(j)->getID());
xmlNewProp(segment_node, BAD_CAST "ID", BAD_CAST str.c_str());
//node2 = xmlNewChild(segment_node, NULL, BAD_CAST "MU", NULL);
str = ToString((double) (*it)->getSegment(j)->getmu()[0]);
xmlNewProp(segment_node, BAD_CAST "x", BAD_CAST str.c_str());
str = ToString((double) (*it)->getSegment(j)->getmu()[1]);
xmlNewProp(segment_node, BAD_CAST "y", BAD_CAST str.c_str());
str = ToString((double) (*it)->getSegment(j)->geta1());
xmlNewProp(segment_node, BAD_CAST "a1", BAD_CAST str.c_str());
str = ToString((double) (*it)->getSegment(j)->geta2());
xmlNewProp(segment_node, BAD_CAST "a2", BAD_CAST str.c_str());
str = ToString((double) (*it)->getSegment(j)->gete1());
xmlNewProp(segment_node, BAD_CAST "e1", BAD_CAST str.c_str());
str = ToString((double) (*it)->getSegment(j)->getq());
xmlNewProp(segment_node, BAD_CAST "q", BAD_CAST str.c_str());
str = ToString((double) (*it)->getSegment(j)->getEndType());
xmlNewProp(segment_node, BAD_CAST "EndType", BAD_CAST str.c_str());
str = ToString((double) (*it)->getSegment(j)->getForegdIntensity());
xmlNewProp(segment_node, BAD_CAST "ForeGroundIntensity", BAD_CAST str.c_str());
str = ToString((double) (*it)->getSegment(j)->getBackgdIntensity());
xmlNewProp(segment_node, BAD_CAST "BackGroundIntensity", BAD_CAST str.c_str());
}
}
xmlSaveFormatFileEnc(config->getOutputFileName().c_str(), doc, MY_ENCODING, 1);
/*free the document */
xmlFreeDoc(doc);
xmlCleanupParser();
}
|
1e3a2b88023194bf97496395c317ca631c63d61b | 3bc10dca7b8d7383ddc121e864f22f0006e34603 | /Client/ActorGoldCoin.h | a0958fd92c23b9dbbfaddaf348c40785ce2e1b82 | [] | no_license | cloudstlife/AnimEditor | 0578d2f6338b9ad18697230bec0300744ba190c4 | f5919b2e026d482f1ad75d05eb67d5b238fa3143 | refs/heads/master | 2016-09-06T00:51:32.147553 | 2015-07-14T02:54:24 | 2015-07-14T02:54:24 | 39,050,108 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,150 | h | ActorGoldCoin.h | #ifndef ACTORGOLDCOIN_H
#define ACTORGOLDCOIN_H
#include "Actor.h"
namespace Ogre
{
class ActorGoldCoin:public Actor
{
public:
ActorGoldCoin(ActorDesc* desc, ISceneNode2D* node, IScene* scene);
virtual ~ActorGoldCoin();
virtual void initailze();
virtual void updateLogic( Real timeLapse );
virtual const String& type() const;
virtual void setProperty(const String& name, const Any& val );
void setActorPlayer(Actor* actor);
Actor* getActorPlayer();
void setFishOdds(int val);
int getFishOdds();
void setEnergy(int val);
int getEnergy();
public:
DYNAMIC_DECLARE( ActorGoldCoin );
private:
Actor* mPlayer;
int mOdds;
int mEnergy;
};
class ActorFactoryGoldCoin : public ActorFactory
{
public:
ActorFactoryGoldCoin();
virtual ~ActorFactoryGoldCoin();
virtual const String& type() const;
virtual Actor* createInstance( ActorDesc* actorDesc, ISceneNode2D* node, IScene* scene, const String& name = "" );
virtual ActorDesc* load( rapidxml::xml_node<>* xmlNode, const String& filename );
static const String TypeName;
};
}
#endif |
e900b0e7957d8bb3d989b227384d4ad6b453625b | ad00ea6f4a80d5a957857f40fb919623a0bdaf25 | /src/EncoderPeripheral.h | 0824fa147b43aa9eb8bb8e64a1c45a9117b6cb5a | [] | no_license | maxwellb/Makernet | 4de335a53278c87e7d935cc2ea6cab6b33154aee | ad1373b12b6400f3d20258a29e57d2454a8383e8 | refs/heads/master | 2021-05-25T18:01:33.983404 | 2017-11-07T19:50:45 | 2017-11-07T19:50:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,400 | h | EncoderPeripheral.h | /********************************************************
**
** EncoderPeripheral.h
**
** Part of the Makernet framework by Jeremy Gilbert
**
** License: GPL 3
** See footer for copyright and license details.
**
********************************************************/
#ifndef ENCODERPERIPHERAL_H
#define ENCODERPERIPHERAL_H
#include <BasePeripheral.h>
#include <Mailbox.h>
#include <MailboxService.h>
// This is a subclass of the mailbox dictionary. Every peripheral should have
// one so that the mailbox configuration is constant between the peripheral
// code and the object host code. To use it, create member variables for each
// mailbox that could handle values. Then wire them up in the configure()
// function of the implementation.
class EncoderMailboxService : public MailboxService {
public:
IntegerMailbox position = IntegerMailbox(0, "Encoder position");
IntegerMailbox buttonDown = IntegerMailbox(0, "Button down");
IntegerMailbox buttonUp = IntegerMailbox(0, "Button up");
virtual void configure() {
set( 0, position );
set( 1, buttonDown );
set( 2, buttonUp );
};
};
class EncoderPeripheral : public BasePeripheral, public IMailboxObserver {
public:
EncoderPeripheral();
virtual void configure();
EncoderMailboxService encoderMailboxSvc;
// From IMailboxObserver
virtual void onMailboxChange( Mailbox *m, bool wasTriggered );
};
#endif
|
3c4eee9130544cccd55ed16937f7a88f4e9efbf3 | 1305a4e2b3fe2430728c3360ffca8b5c2e7ddd73 | /problems/delete_arrayelemet.cpp | f45ccb57f42a9bcf3ae56e9b24e0b76431125e76 | [] | no_license | uttkarsh2406/STACK_QUEUE | 9c0b4e61dbdd93b1c3160b6435cc65f8eeb8d6f6 | 5053ead2cb6b09888a1957244c8dcd3ea417b7f0 | refs/heads/master | 2023-05-11T12:28:41.976913 | 2021-05-26T16:57:48 | 2021-05-26T16:57:48 | 367,585,191 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,067 | cpp | delete_arrayelemet.cpp | // { Driver Code Starts
#include<bits/stdc++.h>
using namespace std;
vector<int> deleteElement(int arr[],int n,int k);
int main()
{
int t,n,k;
cin>>t;
while(t--)
{
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
cin>>k;
vector<int> v;
v = deleteElement(arr,n,k);
vector<int>::iterator it;
for(it=v.begin();it!=v.end();it++)
cout<<*it<<" ";
cout<<endl;
}
return 0;
}
// } Driver Code Ends
vector<int> deleteElement(int arr[],int n,int k)
{
// complete the function
stack<int>a;
int count=0;
a.push(arr[0]);
for (int i = 1; i < n; i++)
{
/* code */
while (!a.empty() && a.top()<arr[i] && count<k)
{
/* code */
a.pop();
count++;
}
a.push(arr[i]);
}
int m=a.size();
vector<int>v(m);
while (!a.empty())
{
/* code */
v[--m]=a.top();
a.pop();
}
return v;
}
|
f9a53f063827d3b4fc49fb0084a10cb13394a134 | 6b96be2d042d9908c8db9e5996893a07bbb97009 | /Minimum_Number_of_Vertices_to_Reach_All_Nodes/solution.cpp | 2300666a84e0dfa1b1b53b0cc313c6d685d3bfc2 | [] | no_license | mixosaurus/leetcode_graph | 2e15b77d86d71a5e376cb7120edc3946afa5b7b3 | 22be214c081c228c3f8faf19d2eab0e0f8a8f9dc | refs/heads/master | 2022-12-18T09:54:44.589089 | 2020-09-06T08:26:39 | 2020-09-06T08:26:39 | 287,454,263 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 454 | cpp | solution.cpp | #include "solution.h"
#include<iostream>
#include<set>
//所有入度为零的顶点即为所求
vector<int> Solution::findSmallestSetOfVertices(int n, vector<vector<int>>& edges) {
int* in_degree = new int[n]{};
vector<int> answers;
for (vector<int> edge : edges) {
in_degree[edge[1]]++;
}
for (int i = 0; i < n;i++) {
if (in_degree[i] == 0) {
answers.push_back(i);
}
}
return answers;
}
|
8c259e351b8ac8c63fb6d4fc5550cadcf1c791ca | 61a62af6e831f3003892abf4f73bb1aa4d74d1c7 | /USACO/Training Pages/Chapter 1/1.4/crypt1.cpp | 6f1c6bd9a0d8ee190f515a4cbca4598c3e35a5fb | [] | no_license | amsraman/Competitive_Programming | 7e420e5d029e8adfbe7edf845db77f96bd1ae80d | 6f869a1e1716f56b081769d7f36ffa23ae82e356 | refs/heads/master | 2023-03-17T00:20:19.866063 | 2023-03-11T00:24:29 | 2023-03-11T00:24:29 | 173,763,104 | 16 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,366 | cpp | crypt1.cpp | /*
ID: adisund1
LANG: C++
TASK: crypt1
*/
#include <iostream>
#include <fstream>
using namespace std;
int exponent(int a, int b)
{
int ret = 1;
for(int i = 0; i<b; i++)
{
ret = ret*a;
}
return ret;
}
int valid(int a, int i[], int n)
{
int u;
while(a>0)
{
for(u = 0; u<n; u++)
{
if(i[u]==(a%10))
{
break;
}
}
if(u==n)
{
return 0;
}
else
{
a = a/10;
}
}
return 1;
}
int main()
{
int n, ans = 0;
ifstream infile("crypt1.in");
ofstream outfile("crypt1.out");
infile >> n;
int inp[n];
for(int i = 0; i<n; i++)
{
infile >> inp[i];
}
int a, b, z;
for(int i = 0; i<exponent(n,5); i++)
{
a = inp[i/exponent(n,4)];
a = a*10 + inp[(i%exponent(n,4))/exponent(n,3)];
a = a*10 + inp[(i%exponent(n,3))/exponent(n,2)];
b = inp[(i%exponent(n,2))/n];
b = b*10 + inp[i%n];
if(valid(a*b,inp,n)==1)
{
if(((valid(a*(b%10),inp,n)==1)&&(valid(a*(b/10),inp,n)==1))&&((a*(b%10)<1000)&&(a*(b/10)<1000)))
{
ans++;
}
}
}
outfile << ans << endl;
}
|
855700486679c3884baf5f713f465593642f8569 | bde48e03ea6aa87fb8f4ddb55965b705b0328dbc | /pagerank/main.cpp | 62eb3526e49336a0b67ff244674fe79994fe5e2f | [] | no_license | csehdan/pagerank | 7a69ccf0900127cbe6bb791d3a37813dd17c47de | b39f0f8e2b5297afaa6fa360f10429c6e737eb26 | refs/heads/master | 2021-01-09T20:21:28.265288 | 2016-08-01T06:47:23 | 2016-08-01T06:47:23 | 64,608,809 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,258 | cpp | main.cpp | #include<iostream>
#include<fstream>
#include<QList>
#define N 25 // number of webpages
#define D 0.85 // damping factor
#define NORM 100 // we score in the [0, 100] interval
using namespace std;
int links[N][N], L[N]; // adjacency matrix and number of links on each page
double Rank[N];
void init() // setting of initial values
{
for(int i=0; i<N; i++)
{
L[i]=0;
double n=N;
Rank[i]=1/n;
cout<< Rank[i] << endl;
for(int j=0; j<N; j++)
{
links[i][j]=-1;
}
}
}
void readdata() // reading data from file and computing L(i) at once
{
ifstream infile("data.csv");
for(int i=0; i<N; i++)
{
for(int j=0; j<N; j++)
{
if(i!=j)
{
infile >> links[i][j];
if(links[i][j]>0)
{
L[i]++;
}
}
}
}
}
double sum(int ind) // the sum needed in the Rank formula
{
double ret=0;
for(int i=0; i<N; i++)
{
if(links[ind][i]>0)
{
ret+=Rank[i]/(double)L[i];
}
}
return ret;
}
bool desc(const QPair<int, double> & p1, const QPair<int, double> & p2) // helper for sorting the result
{
if(p1.second > p2.second) return true;
else return false;
}
void makeorder()
{
QList<QPair<int, double> > list;
double max=0;
for(int i=0; i<N; i++)
{
list.append(QPair<int, double>(i+1, Rank[i]));
if(Rank[i]>max)
{
max=Rank[i];
}
}
qSort(list.begin(), list.end(), desc);
for(int i=0; i<list.length(); i++)
{
int score=list[i].second*NORM/max;
cout << list[i].first << "\t" << list[i].second << "\t" << score << endl;
}
}
int main()
{
int niter=0; // number of iterations
while(niter<1)
{
cout << "So how many iterations would you like?" << endl;
cin >> niter;
}
int all=niter; // we count all the performed iteration to have a neat answer at the end
init();
readdata();
while(niter--)
{
for(int i=0; i<N; i++)
{
Rank[i]=(1-D)/(double)N+D*sum(i); // the PageRank formula itself
}
if(niter==0)
{
for(int i=0; i<N; i++)
{
cout << i+1 << "\t" << Rank[i] << endl;
}
cout << "How many more iterations would you like?\n";
int more;
cin >> more;
if(more >= 0)
{
niter+=more;
all+=more;
}
else cout << "Very funny...\n";
}
}
cout << "Final order of webpages after " << all << " iterations:\n";
makeorder();
return 0;
}
|
93c09e64ee9ea5587ae1404250396e711af4c8c3 | b3021750880b0bdebf376f2bb5e9813833d98efd | /GraphicsRenderer/UVCoords.h | 363931eb7f04479336b59de5c0b4ab2f2a80a2be | [
"MIT"
] | permissive | AdamGPrice/Software-Graphics-Renderer | a314099f732314c60d3b9893cb58d17fa3f31263 | c4e04783314854b4a7712a67b511e8be1631fc97 | refs/heads/master | 2023-03-03T18:19:12.127500 | 2020-08-21T21:57:40 | 2020-08-21T21:57:40 | 238,786,005 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 500 | h | UVCoords.h | #pragma once
class UVCoords
{
public:
UVCoords();
UVCoords(float u, float v);
UVCoords(const UVCoords& other);
float GetU() const;
void SetU(float u);
float GetV() const;
void SetV(float v);
// Operators
UVCoords& operator= (const UVCoords& rhs);
const UVCoords operator+ (const UVCoords& rhs) const;
const UVCoords operator- (const UVCoords& rhs) const;
const UVCoords operator* (float scaler) const;
const UVCoords operator/ (float scaler) const;
private:
float _u;
float _v;
};
|
4e3291de3cf3a0ed0ec0102555d6468ad90864b5 | 651b4acdad7065ee25581200c3217e5416d5851b | /FOSDEM/LetaBotSource/MicroManagerTerran.h | 8bdbc1f556ac286fdd1694ac72617c513570841a | [
"MIT"
] | permissive | MartinRooijackers/LetaBot | 94a8632110e2663e112771ab0365b46a61b24cff | 10785b42d79fb95d39816d625ff7a7d6e18356ba | refs/heads/master | 2020-12-25T14:38:05.350218 | 2020-01-25T22:21:07 | 2020-01-25T22:21:07 | 62,893,190 | 21 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,993 | h | MicroManagerTerran.h | #pragma once
#include <BWAPI.h>
#include <vector>
#include <BWTA.h>
using namespace BWAPI;
enum MicroStatesTerran{
Terran_Defend_Base,
Terran_Hold,
Terran_Hunt,
Terran_Attack_Base
};
struct MicroSquadTerran{
std::vector<BWAPI::Unit> Marines;
std::vector<BWAPI::Unit> Medics;
std::vector<BWAPI::Unit> FireBats;
std::vector<BWAPI::Unit> ScienceVessels;
std::vector<BWAPI::Unit> Tanks;//tank support
std::vector<BWAPI::Unit> Goliaths;
std::vector<BWAPI::Unit> Vultures;
std::vector<BWAPI::Unit> SCVS;
std::vector<BWAPI::Unit> Wraiths;
std::vector<BWAPI::Unit> BattleCruisers;
MicroStatesTerran currentState;
BWAPI::Position AttackTarget;
BWAPI::Unit AttackBuilding;
//BWAPI::Position CurrentPosition;
};
//use for air superiority/harrasing etc
struct WraithSquadron{
std::vector<BWAPI::Unit> Wraiths;
};
enum controller{
Self,
Enemy,
Contested,
Neutral
};
struct MoveGraphT{
BWTA::Region* reg;
BWAPI::Position Center;
std::vector<int> Edges;
controller control; //who controls this node?
};
struct InfluenceBaseT{
BWTA::Region* reg;
BWAPI::TilePosition CClocation;
//std::vector<int> Edges;
int DefenceScoreNeeded;
MicroSquadTerran defenceSquad;
};
class MicroManagerTerran{
public:
std::vector< MicroSquadTerran* > Squads;
std::vector< MoveGraphT > Graph;
std::vector< InfluenceBaseT > DefenceBases;
MicroManagerTerran();
void onFrame();
void AddUnit( Unit unit);
void drawInfo();
void onDefend( MicroSquadTerran* SQuad );
void onAttack( MicroSquadTerran* SQuad );
void NextBuilding( MicroSquadTerran* SQuad );
void onBuildingDestroyed(Unit unit);
void InitialPush();
void OnFrameTerranSquadDefendExpand( MicroSquadTerran squad );
BWAPI::UnitType RecommendBio();// what Bio unit to build next
int MarineCount();
//int MedicCount();
int VesselCount();
//int FireBatCount();
int GoliathCount();
}; |
22f5c7d6d3842dfeb91e2a8dc03e8cfbd46c6054 | f7c159c424f237a2e11826c2c7e46360fd7c94cf | /src/Numerical/randomize_array.h | 0691e299cebaecd69b8d7b648adb75dc7dd19dc4 | [] | no_license | Makvagabo/algorithms | fab18de02739fe1cf2f9425e809b53e123b943eb | 90316b1cf5594794c91ceb94f769a7dc0061c074 | refs/heads/master | 2020-05-20T17:25:17.254126 | 2019-06-18T16:17:06 | 2019-07-27T21:49:47 | 185,687,516 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 355 | h | randomize_array.h | //
// Created by Alexander on 09.05.2019.
//
#ifndef ALGORITHMS_NUMERICAL_RANDOMIZE_ARRAY_H_
#define ALGORITHMS_NUMERICAL_RANDOMIZE_ARRAY_H_
namespace Numerical {
template<class T>
void RandomizeArray(PRNG *generator, T *arr, const int &size);
} // namespace Numerical
#include "randomize_array.hpp"
#endif // ALGORITHMS_NUMERICAL_RANDOMIZE_ARRAY_H_
|
3128c8ad65f6d6d7f0ba4f3aca848ccce7d63472 | 434a0a5461b8b366bf01684cfe5e14e70b7e565b | /Server/Server.cpp | 68fccdc281461ea7c771de82c1f2a7cc132af88d | [
"MIT"
] | permissive | wind612/NamePipe_cplus | 8e2510c56d0820ee198cade579cb00b044cf5dc2 | 42d4f2f8b296623280f9cc626496133e3a92b873 | refs/heads/master | 2020-07-09T06:20:31.763499 | 2019-08-23T05:07:18 | 2019-08-23T05:07:18 | 203,905,207 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 820 | cpp | Server.cpp | // Server.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "pch.h"
#include <iostream>
#include <thread>
#include "NamePipe.h"
#include <string>
#include <windows.h>
#include <conio.h> // for _getch();
using namespace std;
void hello()
{
std::cout << "Hello World!" << std::endl;
}
int main()
{
CNamePipe pipe;
hello();
//std::thread t(hello);
std::thread t(pipe_thread, &pipe);
int count = 0;
_getch();
while (++count < 100 + 1)
{
pipe.SendData();
Sleep(50);
}
printf("recv_err = %d\n", pipe.recv_err);
while (true)
{
string str;
getline(cin, str);
cout << "count=" << count++ << ", str=" << str << endl;
if (str == "exit")
{
break;
}
pipe.SendData();
}
t.join();
}
|
e353de3e2a281804ecc82e9368c74141346e9f62 | abeffec8a315bef1c0f8f829c2b193652baa2403 | /Practicum/Homework4/Header files/Deck.hpp | 46d87a6943e29816c2df016917656f80b7257592 | [
"MIT"
] | permissive | stefania-tsvetkova/FMI-OOP | 925a3602a7f4f01612f05cd7d2552be48837e299 | 9d6ab384b5b7a48e76965ca5bff1e6a995b1bcba | refs/heads/main | 2023-08-27T15:37:14.607232 | 2021-11-03T14:44:27 | 2021-11-03T14:44:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,644 | hpp | Deck.hpp | /**
* Solution to homework assignment 4
* Object Oriented Programming Course
* Faculty of Mathematics and Informatics of Sofia University
* Summer semester 2020/2021
*
* @author Stefania Tsvetkova
* @idnumber 62573
* @task 1
* @compiler VC
*/
#pragma once
#include "PendulumCard.hpp"
#include <vector>
class Deck
{
public:
// Constructors
Deck() = default;
Deck(const std::string& name);
Deck(const Deck& deck);
// Destructor
~Deck();
// Accessors
std::vector<MagicCard*> GetMagicCards() const;
std::vector<MonsterCard*> GetMonsterCards() const;
std::vector<PendulumCard*> GetPendulumCards() const;
std::vector<Card*> GetAllCards() const;
// Mutators
void SetName(const std::string& name);
// Operations
int MagicCardsCount() const;
int MonsterCardsCount() const;
int PendulumCardsCount() const;
int AllCardsCount() const;
void AddCard(const Card* card);
bool ChangeCard(const Card* card, int index); // returns true if the card is changed, otherwise - false
void Clear();
void Shuffle();
// Operators
Deck& operator=(const Deck& deck);
friend std::ostream& operator<<(std::ostream& stream, const Deck& deck);
friend std::istream& operator>>(std::istream& stream, Deck& deck);
private:
// Constants
static const int MONSTER_CARD_PROPERTIES_IN_FILE_COUNT = 5;
static const int MAGIC_CARD_PROPERTIES_IN_FILE_COUNT = 4;
static const int PENDELUM_CARD_PROPERTIES_IN_FILE_COUNT = 7;
static const int DEFAULT_CARDS_COUNT = 0;
// Properties
std::string name;
std::vector<Card*> cards;
int magicCardsCount;
int monsterCardsCount;
int pendulumCardsCount;
// Operations
void Copy(const Deck& deck);
};
|
aa5e3a3b16d612ae5ff5f982d89b0c0b262e71ef | 81a62452bd2a95f022a6136ea64f2e57050a4ac1 | /source/gui/main_window.cpp | fe07b3c61c52a680863a147f164a5bc258d88909 | [] | no_license | chicolismo/Cesar-from-first-principles | 7f3ab8172a19152e63d3d396a77a90b20fbb43a6 | bf7a0520f5f02d25eebed240f8be5db63642f481 | refs/heads/master | 2020-08-17T23:38:24.588804 | 2020-03-26T22:00:47 | 2020-03-26T22:00:47 | 215,724,589 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,882 | cpp | main_window.cpp | #include "main_window.h"
#include "panels.h"
#include "utils.h"
#include <chrono>
#include <cstdint>
#include <mutex>
#include <thread>
#include <wx/event.h>
#include <wx/msgdlg.h>
#include <wx/sizer.h>
namespace cesar::gui {
#define IS_DISPLAY_ADDRESS(address) \
(address) >= Cpu::BEGIN_DISPLAY_ADDRESS && \
(address) <= Cpu::END_DISPLAY_ADDRESS
// ===========================================================================
// MainWindow
// ===========================================================================
wxDEFINE_EVENT(wxEVT_THREAD_UPDATE, wxThreadEvent);
wxBEGIN_EVENT_TABLE(MainWindow, wxFrame)
EVT_MENU(ID_FileOpen, MainWindow::OnFileOpen)
EVT_MENU(wxID_EXIT, MainWindow::OnExit)
EVT_CLOSE(MainWindow::OnClose)
EVT_MOVE(MainWindow::OnMove)
EVT_TOGGLEBUTTON(ID_Run, MainWindow::OnRunButtonToggle)
EVT_BUTTON(ID_Next, MainWindow::OnNextButtonClick)
EVT_ACTIVATE(MainWindow::OnActivate)
wxEND_EVENT_TABLE()
MainWindow::MainWindow(const wxString &title)
: wxFrame(nullptr, wxID_ANY, title, wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxRESIZE_BORDER)),
semaphore(1, 1), should_raise_windows(true),
thread_is_running(false) {
this->Bind(wxEVT_THREAD, &MainWindow::OnThreadUpdate, this);
// Inicializando as janelas laterais
program_window = new ProgramWindow(this, &cpu, wxT("Programa"));
const wxSize psize = program_window->GetSize();
program_window->SetMaxSize(wxSize(psize.GetWidth(), wxDefaultCoord));
program_window->SetMinSize(wxSize(psize.GetWidth(), 300));
data_window = new DataWindow(this, &cpu, wxT("Dados"));
const wxSize dsize = data_window->GetSize();
data_window->SetMaxSize(wxSize(dsize.GetWidth(), wxDefaultCoord));
data_window->SetMinSize(wxSize(dsize.GetWidth(), 300));
program_window->Show(true);
data_window->Show(true);
text_display = new TextDisplay(this, &cpu);
text_display->Show(true);
// Displays de registradores
register_panels[0] = new RegisterPanel(this, 0, wxT("R0:"));
register_panels[1] = new RegisterPanel(this, 1, wxT("R1:"));
register_panels[2] = new RegisterPanel(this, 2, wxT("R2:"));
register_panels[3] = new RegisterPanel(this, 3, wxT("R3:"));
register_panels[4] = new RegisterPanel(this, 4, wxT("R4:"));
register_panels[5] = new RegisterPanel(this, 5, wxT("R5:"));
register_panels[6] = new RegisterPanel(this, 6, wxT("R6: (SP)"));
register_panels[7] = new RegisterPanel(this, 7, wxT("R7: (PC)"));
auto *register_grid = new wxFlexGridSizer(3, 3, 4, 4);
register_grid->Add(register_panels[0], 1, wxEXPAND);
register_grid->Add(register_panels[1], 1, wxEXPAND);
register_grid->Add(register_panels[2], 1, wxEXPAND);
register_grid->Add(register_panels[3], 1, wxEXPAND);
register_grid->Add(register_panels[4], 1, wxEXPAND);
register_grid->Add(register_panels[5], 1, wxEXPAND);
register_grid->Add(register_panels[6], 1, wxEXPAND);
register_grid->AddStretchSpacer();
register_grid->Add(register_panels[7], 1, wxEXPAND);
// Painéis de condições
condition_panels[0] = new ConditionPanel(this, wxT("N"));
condition_panels[1] = new ConditionPanel(this, wxT("Z"));
condition_panels[2] = new ConditionPanel(this, wxT("V"));
condition_panels[3] = new ConditionPanel(this, wxT("C"));
auto condition_box = new wxBoxSizer(wxHORIZONTAL);
condition_box->Add(condition_panels[0]);
condition_box->AddStretchSpacer();
condition_box->Add(condition_panels[1]);
condition_box->AddStretchSpacer();
condition_box->Add(condition_panels[2]);
condition_box->AddStretchSpacer();
condition_box->Add(condition_panels[3]);
// Painel de execuções
execution_panel = new ExecutionPanel(this);
// Painel de botões
button_panel = new ButtonPanel(this);
auto *middle_right_sizer = new wxBoxSizer(wxVERTICAL);
middle_right_sizer->Add(condition_box, 0, wxEXPAND);
middle_right_sizer->AddStretchSpacer();
middle_right_sizer->Add(button_panel, 0, wxEXPAND);
auto *middle_sizer = new wxBoxSizer(wxHORIZONTAL);
middle_sizer->Add(execution_panel);
middle_sizer->Add(middle_right_sizer);
auto *main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(register_grid, 1, wxALL | wxEXPAND, 10);
main_sizer->Add(
middle_sizer, 1, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 10);
SetSizerAndFit(main_sizer);
// Criando o menu
auto *menu_file = new wxMenu;
menu_file->Append(ID_FileOpen, "&Abrir...\tCtrl-A", "Abrir um arquivo");
menu_file->Append(ID_FileOpen, "&Salvar\tCtrl-S", "Salva o arquivo atual");
menu_file->Append(wxID_EXIT, "&Sair\tCtrl-x", "Termina o programa");
auto *menu_bar = new wxMenuBar;
menu_bar->Append(menu_file, "&Arquivo");
SetMenuBar(menu_bar);
Center(wxBOTH);
}
void MainWindow::UpdateSubwindowsPositions() {
const unsigned gap = 10;
const wxSize size = GetSize();
const wxPoint pos = GetPosition();
const wxSize pwsize = program_window->GetSize();
program_window->SetPosition(
wxPoint(pos.x - pwsize.GetWidth() - gap, pos.y));
data_window->SetPosition(wxPoint(pos.x + size.GetWidth() + gap, pos.y));
text_display->SetPosition(wxPoint(
program_window->GetPosition().x, gap + pos.y + size.GetHeight()));
program_window->SetSize(
program_window->GetSize().GetWidth(), size.GetHeight());
data_window->SetSize(data_window->GetSize().GetWidth(), size.GetHeight());
// text_display->SetSize(text_display->GetClientSize());
}
void MainWindow::UpdatePanels() {
for (std::size_t i = 0; i < 8; ++i) {
register_panels[i]->SetValue(cpu.registers[i]);
}
condition_panels[0]->led_display->SetTurnedOn(cpu.condition.negative == 1);
condition_panels[1]->led_display->SetTurnedOn(cpu.condition.zero == 1);
condition_panels[2]->led_display->SetTurnedOn(cpu.condition.overflow == 1);
condition_panels[3]->led_display->SetTurnedOn(cpu.condition.carry == 1);
}
void MainWindow::SetAddressValueAndUpdateTables(
const long address, const std::int8_t value) {
const auto unsigned_address = static_cast<std::uint16_t>(address);
cpu.memory[unsigned_address] = value;
program_window->table->RefreshItem(address);
data_window->table->RefreshItem(address);
if (IS_DISPLAY_ADDRESS(unsigned_address)) {
text_display->PaintNow();
}
}
void MainWindow::SetBase(const Base new_base) {
current_base = new_base;
for (auto &panel : register_panels) {
panel->SetBase(new_base);
}
program_window->SetBase(new_base);
data_window->SetBase(new_base);
}
void MainWindow::OnFileOpen(wxCommandEvent &WXUNUSED(event)) {
// TODO: Testar se os dados do arquivo atual foram alterados e exibir
// diálogo apropriado.
wxFileDialog dialog(this, _("Abrir arquivos .MEM do Cesar"), "", "",
"Arquivos MEM (*.mem)|*mem", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (dialog.ShowModal() == wxID_CANCEL) {
return; // Abertura de arquivo cancelada.
}
const std::string filename(dialog.GetPath().mb_str(wxConvUTF8));
// TODO: Enviar para o cpu ler os dados.
if (cpu.read_memory_from_binary_file(filename)) {
UpdatePanels();
}
}
void MainWindow::OnMove(wxMoveEvent &WXUNUSED(event)) {
UpdateSubwindowsPositions();
}
void MainWindow::OnExit(wxCommandEvent &WXUNUSED(event)) { Close(true); }
void MainWindow::OnClose(wxCloseEvent &WXUNUSED(event)) {
while (GetThread() && GetThread()->IsRunning()) {
GetThread()->Pause();
GetThread()->Delete();
}
Destroy(); // Destroi a janela principal
}
void MainWindow::OnRunButtonToggle(wxCommandEvent &event) {
auto *toggle_button =
static_cast<wxBitmapToggleButton *>(event.GetEventObject());
if (toggle_button->GetValue() && !thread_is_running) {
cpu.halted = false;
thread_is_running = true;
StartThread();
}
else {
thread_is_running = false;
}
}
void MainWindow::OnNextButtonClick(wxCommandEvent &WXUNUSED(event)) {
if (!thread_is_running) {
RunNextInstruction();
UpdatePanels();
}
}
void MainWindow::RunNextInstruction() { cpu.execute_next_instruction(); }
void MainWindow::OnRegisterPanelDoubleClick(int register_number) {
RegisterPanel *panel = register_panels[register_number];
std::uint16_t value = panel->current_value;
wxString current_value;
if (current_base == Base::Decimal) {
current_value.Printf("%d", value);
}
else {
current_value.Printf("%x", value);
}
wxString message;
message.Printf("Digite novo valor para o registrador %d", register_number);
wxTextEntryDialog dialog(this, message, wxT("Novo valor"), current_value,
wxTextEntryDialogStyle, panel->GetPosition());
if (dialog.ShowModal() == wxID_OK) {
bool is_valid_number;
std::string input(dialog.GetValue());
std::int16_t value =
TryConvertToWord(input, current_base, &is_valid_number);
if (is_valid_number) {
cpu.registers[register_number] = value;
panel->SetValue(static_cast<std::uint16_t>(value));
panel->Refresh();
}
}
}
void MainWindow::OnActivate(wxActivateEvent &event) {
if (event.GetActive()) {
if (should_raise_windows) {
should_raise_windows = false;
program_window->Raise();
data_window->Raise();
text_display->Raise();
Raise();
}
else {
should_raise_windows = true;
}
}
event.Skip();
}
void MainWindow::StartThread() {
if (CreateThread(wxTHREAD_JOINABLE) != wxTHREAD_NO_ERROR) {
wxLogError("Não foi possível criar a thread");
return;
}
if (GetThread()->Run() != wxTHREAD_NO_ERROR) {
wxLogError("Não foi possível executar a thread");
return;
}
}
void MainWindow::RefreshPanels() {
program_window->table->Refresh();
data_window->table->Refresh();
for (std::size_t i = 0; i < 8; ++i) {
register_panels[i]->digital_display->Refresh();
register_panels[i]->binary_display->Refresh();
}
condition_panels[0]->led_display->Refresh();
condition_panels[1]->led_display->Refresh();
condition_panels[2]->led_display->Refresh();
condition_panels[3]->led_display->Refresh();
text_display->Refresh();
}
void MainWindow::OnThreadUpdate(wxThreadEvent &WXUNUSED(event)) {
// Atualiza a interface e libera o semáforo.
UpdatePanels();
RefreshPanels();
semaphore.Post();
}
wxThread::ExitCode MainWindow::Entry() {
auto start = std::chrono::system_clock::now();
while (!GetThread()->TestDestroy()) {
RunNextInstruction();
auto now = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = now - start;
// Notifica a thread principal para atualizar a interface 60 vezes por
// segundo.
if (elapsed_seconds.count() > frame_time) {
start = now;
wxQueueEvent(GetEventHandler(), new wxThreadEvent());
semaphore.Wait();
}
if (cpu.halted) {
thread_is_running = false;
button_panel->btn_run->SetValue(false);
break;
}
if (!thread_is_running) {
break;
}
}
// Antes de encerrar a thread, notifica um última vez para atualizar a
// interface.
wxQueueEvent(GetEventHandler(), new wxThreadEvent());
semaphore.Wait();
return static_cast<wxThread::ExitCode>(0);
}
} // namespace cesar::gui
|
9ddeebf033fe4f415ec7eaf3f062f8f43c0ee5ff | 0cc85dba8627571ec4544ced429223f33a5240ac | /timer.h | f2ac4588f420ecf4deaa85e143fe458d667b12e3 | [] | no_license | aygongzhaohui/AMOS | 0f15e3ca99916e5f7b05ba02d45d88ff885151d0 | 20080513feaef94da28668b30d8b001b059659bf | refs/heads/master | 2021-01-10T14:03:42.032549 | 2016-04-07T06:08:08 | 2016-04-07T06:08:08 | 52,066,840 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,309 | h | timer.h | /**
* @file timer.h
* @brief
* @author GongZhaohui
* @version
* @date 2016-02-18
*/
#ifndef _AMOS_TIMER_H_
#define _AMOS_TIMER_H_
#include "event_handler.h"
namespace amos
{
class Timer
{
public:
Timer() : id_(0), delay_(0)
{
}
Timer(TIMER timerId, MSEC d)
: id_(timerId), delay_(d)
{
TimeNow(startTime_);
}
/**
* @brief Check if timer timeout
*
* @return >0 remain time for timeout
* <=0 expired time
*/
MSEC CheckTO() const
{
MSEC elapse = TimeDiffNow(startTime_);
return (delay_ - elapse);
}
/**
* @brief Reset the start time to now
*/
void Reset()
{
TimeNow(startTime_);
}
bool operator==(const Timer & t) const
{
return (id_ == t.id_);
}
bool operator<(const Timer & t) const
{
MSEC diff = TimeDiff(startTime_, t.startTime_);
return ((delay_ - t.delay_) < diff);
}
TIMER Id() const
{
return id_;
}
private:
TIMER id_;
MSEC delay_;
TIMESTAMP startTime_;
};
}
#endif
|
b0a49ee1857ffc294e015760b77f9b40430fe925 | 90f374d14fb2b2261ecec6a43612731ce4d90ca7 | /data_struct/binary_search_tree/detail/bst.inl | c0b6654961f08b9afc6c6c3a0d33408c9892260d | [] | no_license | ejtan/project | 3c11e9ffa60eab91117d2fd27af4c99ca08ae745 | 84b760a16c087d76e48782e5315790d0ed9283c7 | refs/heads/master | 2021-01-22T01:34:15.754112 | 2018-10-10T00:01:38 | 2018-10-10T00:01:38 | 102,220,122 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,803 | inl | bst.inl | #include <iostream>
/*-------------------------------------------------------------------------------------------------
* PRIVATE METHODS
*-----------------------------------------------------------------------------------------------*/
/* delete_tree()
* Deletes nodes in the BST recursively.
*/
template <typename Key, typename T>
void BST<Key, T>::delete_tree(BST_Node<Key, T> *node)
{
if (node->right)
delete_tree(node->right);
if (node->left)
delete_tree(node->left);
delete node;
}
/* recursive_inorder_print()
* Recursively prints values in sorted order.
*/
template <typename Key, typename T>
void BST<Key, T>::recursive_inorder_print(const BST_Node<Key, T> *node) const
{
if (node->left)
recursive_inorder_print(node->left);
std::cout << node->key << ' ';
if (node->right)
recursive_inorder_print(node->right);
}
/* recursive_remove()
* Recursively removes value form a tree.
*/
template <typename Key, typename T>
void BST<Key, T>::recursive_remove(const Key &key, BST_Node<Key, T> *&node)
{
if (!node) {
std::cout << key << " is not in the tree. Nothing is removed.\n";
return;
}
if (key < node->key) {
recursive_remove(key, node->left);
} else if (key > node->key) {
recursive_remove(key, node->right);
} else if (node->left && node->right) {
// Case for 2 children
node->key = min_node(node->right)->key;
recursive_remove(node->key, node->right);
} else {
BST_Node<Key, T> *old_node = node;
node = (node->left) ? node->left : node->right;
delete old_node;
n_ele--;
}
}
/* min_node()
* Takes in a node as root and finds the min node of the subtree.
*/
template <typename Key, typename T>
BST_Node<Key, T>* BST<Key, T>::min_node(BST_Node<Key, T> *node) const
{
if (!node) {
return nullptr;
} else {
while (node->left)
node = node->left;
return node;
}
}
/*-------------------------------------------------------------------------------------------------
* PUBLIC METHODS
*-----------------------------------------------------------------------------------------------*/
/* Default Constructor
*/
template <typename Key, typename T>
BST<Key, T>::BST()
{
root = nullptr;
n_ele = 0;
}
/* Destructor
*/
template <typename Key, typename T>
BST<Key, T>::~BST()
{
if (root)
delete_tree(root);
}
/* insert()
* Inserts an object into the tree. Inserts into root if tree is empty. Otherwise, transverse the
* tree until a node to insert the value is found. If the value is already inside the tree,
* a message is printed out and the value is not inserted into the tree.
*/
template <typename Key, typename T>
void BST<Key, T>::insert(const Key &key, const T &value)
{
if (!root) {
root = new BST_Node<Key, T>(key, value, nullptr, nullptr);
n_ele++;
} else {
// Use a curr node ptr for exiting while loop. prev ptr will be accessed when allocating
// new node
BST_Node<Key, T> *prev, *curr = root;
while (curr) {
prev = curr;
if (key < curr->key) {
curr = curr->left;
} else if (key > curr->key) {
curr = curr->right;
} else {
std::cout << key << " is already in tree.\n";
return;
}
}
// Allocate new node
if (key < prev->key)
prev->left = new BST_Node<Key, T>(key, value, nullptr, nullptr);
else
prev->right = new BST_Node<Key, T>(key, value, nullptr, nullptr);
n_ele++;
}
}
/* remove()
*/
template <typename Key, typename T>
void BST<Key, T>::remove(const Key &key)
{
recursive_remove(key, root);
}
/* size()
* Returns the number of allocated elements in the tree.
*/
template <typename Key, typename T>
std::size_t BST<Key, T>::size() const
{
return n_ele;
}
/* max()
* Transverses the tree to the max value.
*/
template <typename Key, typename T>
Key BST<Key, T>::max_key() const
{
// TODO: Add in handeling for when root is not allocated.
// Consider returing iterator to node rather than value itself.
BST_Node<Key, T> *node = root;
while (node->right)
node = node->right;
return node->key;
}
/* min()
* Transverses the tree to the min value.
*/
template <typename Key, typename T>
Key BST<Key, T>::min_key() const
{
// TODO: Add in handeling for when root is not allocated.
// Consider returing iterator to node rather than value itself.
BST_Node<Key, T> *node = root;
while (node->left)
node = node->left;
return node->key;
}
/* contains()
* Checks if a specific key is inside the tree.
*/
template <typename Key, typename T>
bool BST<Key, T>::contains(const Key &key) const
{
if (!root) {
return false;
} else {
BST_Node<Key, T> *curr = root;
while (curr) {
// If the value is neither less than or greater than the value in the current node,
// than the value must be the same as the current node.
if (key < curr->key)
curr = curr->left;
else if (key > curr->key)
curr = curr->right;
else
return true;
}
return false;
}
}
/* isEmpty()
* Checks if the tree is empty.
*/
template <typename Key, typename T>
bool BST<Key, T>::isEmpty() const
{
if (!root)
return true;
else
return false;
}
/* inorder_print()
* Prints data in sorted order.
*/
template <typename Key, typename T>
void BST<Key, T>::inorder_print() const
{
recursive_inorder_print(root);
std::cout << std::endl;
}
|
3db688af70be429f987becd35c83cbc7cba118b8 | e4546ddb2c42d5fef5059f008aa1af6d28fbf4ba | /Горб/polynom/tlist.h | c5e1a557e685bc40279f64eb61ff32856eec17a2 | [] | no_license | knightvmk/mp2-lab5-polynom | 96e8128160a633e9cb7dba6ca286a3414ffc771b | 07063c137d9ab3f89cdd662041ee51e496ef1fa3 | refs/heads/master | 2021-01-22T09:20:26.723228 | 2017-02-21T09:13:12 | 2017-02-21T09:13:12 | 81,954,207 | 0 | 0 | null | 2018-04-06T15:31:08 | 2017-02-14T14:35:47 | C++ | UTF-8 | C++ | false | false | 4,535 | h | tlist.h | #ifndef __TLIST_H__
#define __TLIST_H__
#include <stdlib.h>
#include <stdio.h>
#define CH_STR 10
// start clacc TList
template <class type>
class TList
{
private:
struct TNode
{
type val;
TNode *pNext;
TNode *pPrev;
short int pos;
};
TNode *pFirst;
TNode *pCurr;
short int len;
void RePos(bool key);
void FullRePos();
public:
TList();
short int GetLen() { return len; };
short int GetPos() { return pos; };
void SetPos(int _pos);
void GoNext();
void GoBack();
void InsFirst(const type &_val);
void InsLast(const type &_val);
void Ins(int _pos, const type &_val);
void DelFirst();
void DelLast();
void SetVal(const int _pos,const type &_val);
const type GetVal(const int _pos);
void DelCell(int _pos);
int* ToStr(); //for debug, not for use
};
template<class type>
inline int* TList<type>::ToStr()
{
int *res=new int[4];
SetPos(0);
for (register int i = 0; i < len; i++)
{
res[i] = pCurr->val;
GoNext();
} return res;
};
template <class type>
TList<type>::TList()
{
pCurr = pFirst = nullptr;
len = 0;
};
template <class type>
void TList<type>::InsFirst(const type &_val)
{
if (pFirst == nullptr)
{
pFirst = new TNode;
pFirst->pos = 0;
pFirst->val = _val;
pFirst->pNext = pFirst->pPrev = nullptr;
++len;
return;
}
TNode *p = new TNode;
if (p == 0) throw ("Bad mem alloc on create");
TNode *prev = pFirst;
p->val = _val;
p->pNext = pFirst;
p->pPrev = nullptr;
pCurr = pFirst = p;
TNode *next = pFirst->pNext;
next->pPrev = pFirst;
++len;
FullRePos();
};
template <class type>
void TList<type>::InsLast(const type &_val)
{
if (pFirst == nullptr)
{
InsFirst(_val);
return;
}
SetPos(len-1);
TNode *p = new TNode;
p->val = _val;
p->pos = len;
p->pNext = nullptr;
++len;
pCurr->pNext = p;
//SetPos(len);
p->pPrev = pCurr;
};
template<class type>
inline void TList<type>::SetPos(int _pos)
{
if (_pos<0 || _pos>len) throw ("Invalid position: out of the range");
if (_pos == 0)
{
pCurr = pFirst;
return;
}
while (pCurr->pos < _pos) GoNext();
while (pCurr->pos > _pos) GoBack();
};
template<class type>
inline void TList<type>::GoNext()
{
if (pCurr->pNext == nullptr)
{
//throw ("End of List!");
return;
}
pCurr = pCurr->pNext;
};
template <class type>
inline void TList<type>::GoBack()
{
if (pCurr->pPrev == nullptr)
{
//throw ("Out of first of the List!");
return;
}
pCurr = pCurr->pPrev;
};
template <class type>
void TList<type>::Ins(int _pos, const type &_val)
{
if (_pos < 0 || _pos > len) throw ("Bad position: out of the range!");
if (pFirst == nullptr) InsFirst(_val);
else if (_pos == 0) InsFirst(_val);
else if (_pos == len) InsLast(_val);
else
{
SetPos(_pos);
TNode *p = new TNode;
TNode *prev = pCurr->pPrev;
p->pos = _pos;
p->val = _val;
pCurr->pPrev = p;
prev->pNext = p;
p->pNext = pCurr;
p->pPrev = prev;
//pCurr = pCurr->pNext;
RePos(1);
++len;
}
};
template <class type>
inline void TList<type>::RePos(bool key) //Only after Insert by Pos
{
short int tmp = pCurr->pos; //
while (pCurr->pos != len) //Re Position
{
if(key) pCurr->pos++;
else pCurr->pos--;
GoNext();
}
//Back to list:
SetPos(tmp);
}
template<class type>
inline void TList<type>::FullRePos()
{
register short int ind = 0;
pCurr = pFirst;
while (ind!=len)
{
pCurr->pos = ind++;
GoNext();
}
};
template <class type>
inline void TList<type>::DelFirst()
{
if (pFirst == nullptr) return;
TNode *p = pFirst->pNext;
delete pFirst;
--len;
p->pPrev = nullptr;
pCurr = pFirst = p;
FullRePos();
};
template <class type>
inline void TList<type>::DelLast()
{
if (pFirst == nullptr) return;
SetPos(len-1);
TNode *p = pCurr->pPrev;
p->pNext = nullptr;
delete pCurr;
pCurr = p;
--len;
};
template<class type>
inline void TList<type>::SetVal(const int _pos, const type &_val)
{
if (_pos<0 || _pos>len) throw ("Bad position: out of the range");
SetPos(_pos);
pCurr->val = _val;
};
template<class type>
inline const type TList<type>::GetVal(const int _pos)
{
if (_pos<0 || _pos>len) throw ("Bad position: out of the range");
SetPos(_pos);
return pCurr->val;
};
template<class type>
void TList<type>::DelCell(const int _pos)
{
if (_pos<0 || _pos>len) throw ("Bad position: out of the range");
if (pFirst == nullptr) return;
else if (_pos == 0) DelFirst();
else if (_pos == len) DelLast();
else
{
SetPos(_pos);
TNode *prev = pCurr->pPrev;
TNode *next = pCurr->pNext;
delete pCurr;
prev->pNext = next;
next->pPrev = prev;
--len;
FullRePos();
}
};
#endif
|
3ba07d02933e09809ba03683a1bb86d3b309bd4a | f19ea08f3af3ddca70240242ef1ea30a32ce03f5 | /arduino/arduino.ino | 0cef93bd6c95868198ec8b6e2663045e07b64a44 | [] | no_license | FelippeRoza/windpowerDAQ | b1d87270e7e3a6c8483bd4bf205e4ab2006fae1e | 6faac37a1c01e2fdd2cc9d99f030dc8ba2350988 | refs/heads/master | 2021-05-15T16:14:17.309990 | 2017-10-23T13:06:41 | 2017-10-23T13:06:41 | 107,445,410 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,631 | ino | arduino.ino | #include <PWM.h>
int pin_out = 9;
int d = 1;
float output = 0.0;
int input = 10;
void setup() {
//initialize all timers except for 0, to save time keeping functions
//just because you init the timer doesn't change the default frequency until you call setpinfreq
InitTimersSafe();
//sets the frequency for the specified pin
bool success = SetPinFrequencySafe(pin_out, 20000);
//success == true if it worked
// Analog pins as input
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
// Init Serial
Serial.begin(115200);
setPwm(0);
}// end setup
void setPwm(int value){
output = map(input, 0, 100, 0, 400);
analogWrite(pin_out, output);
}
void send_serial(char type, int analog){
output = analog*5.0/1023.0;
if(type == 'i'){
output = (output - 2.5)/0.185;
}
else if(type == 'v'){
output = output*10.0/110.0;
}
Serial.println(String(type) + " :" + String(output));
delayMicroseconds(d);
}
void loop() {
if(Serial.available()) {
int signal = Serial.read();
if(signal == 119) {
//current sensors
send_serial( 'i', analogRead(A0) );
send_serial( 'i', analogRead(A2) );
send_serial( 'i', analogRead(A4) );
//voltage sensors
send_serial( 'v', analogRead(A1) );
send_serial( 'v', analogRead(A3) );
send_serial( 'v', analogRead(A5) );
}
if(signal == 'c'){
Serial.println("Insira o valor");
while(Serial.available() == 0){}
input = Serial.parseInt();
setPwm(input);
Serial.println(input);
}
}
}
|
66b277a1b3926290b52e6b5a92b8df1162a6c17f | 947c16ea428c396988f790097289289e590e5f38 | /lab_3/src/core/segmentrenderer.cpp | efc59a4ec17255fc766e1dc98641f49d038780d6 | [] | no_license | RullDeef/cg-lab | ed350e6560df78b8e490a996683895768142b051 | 8a46de19b595f68afef46aec6dbcb7c5aaf897fa | refs/heads/master | 2023-06-16T08:23:31.431634 | 2021-06-23T16:10:13 | 2021-06-23T16:10:13 | 387,730,748 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,309 | cpp | segmentrenderer.cpp | #include "segmentrenderer.hpp"
inline void clampPoint(double width, double& x, double& y, double dx, double dy)
{
if (x < 0.0)
{
y -= x * dy / dx;
x = 0.0;
}
else if (x >= width)
{
y += (width - 1 - x) * dy / dx;
x = width - 1;
}
}
void core::SegmentRenderer::drawSegment(QImage& image, Segment segment)
{
double width = image.width();
double height = image.height();
// clamp end points
double dx = segment.x2 - segment.x1;
double dy = segment.y2 - segment.y1;
clampPoint(width, segment.x1, segment.y1, dx, dy);
clampPoint(height, segment.y1, segment.x1, dy, dx);
clampPoint(width, segment.x2, segment.y2, -dx, -dy);
clampPoint(height, segment.y2, segment.x2, -dy, -dx);
// call virtual method
drawClampedSegment(image, segment);
}
void core::SegmentRenderer::startTiming()
{
startTime = std::chrono::high_resolution_clock::now();
}
void core::SegmentRenderer::stopTiming(double dx, double dy)
{
if (!timing_active)
return;
auto endTime = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration_cast<durr_t>(endTime - startTime);
drawTimes.push_front(elapsed.count() / 1000.0);
if (drawTimes.size() > queueSize)
drawTimes.pop_back();
}
|
231a641250cbec92ec3c65c245bba95938ce90c3 | 220ab14e8734e24793aef43b772f6599aad35dff | /Qt/main/Src/Window.cxx | c4a3442a0ce93cfeb45e029630692ca6cfe7d0e0 | [] | no_license | suryakiran/CodeSamples | 1ab93ae76d6d473fdf72b2ba663b4a43d382fbec | f2e18e8fa7611bca25f92fbd167a6a5a97b66a55 | refs/heads/master | 2016-09-15T13:57:35.113621 | 2016-02-07T15:54:55 | 2016-02-07T15:54:55 | 828,790 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 254 | cxx | Window.cxx | #include <Window.hxx>
#include <QScrollBar>
Window::Window (QWidget* p_parent)
: QMainWindow (p_parent)
{
setupUi (this);
QScrollBar* sb = new QScrollBar (Qt::Vertical, this);
Ui::MainWindow::treeWidget->addScrollBarWidget(sb,Qt::AlignBottom);
}
|
732e25bc0e9331dd03efc6c39bda058f1390f9d6 | 1dc719cc6bdc48beb7c26cf58fc581e420c25223 | /works_cubic/recsum.cpp | 24104c80d6bb9b868155519b6cca53550bc99022 | [] | no_license | ananduri/ewald | 6d1708a418602ff6ae0a010fb77b9cffc0a05108 | b2019c0c8db33f4c14874e527355ed18ee894a43 | refs/heads/master | 2021-03-27T19:11:10.603094 | 2015-10-28T19:50:33 | 2015-10-28T19:50:33 | 44,455,416 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,646 | cpp | recsum.cpp | #include "ewald.h"
double recsum(double x, double y, double z, double alpha, int recip_cut, int real_cut, double cellsize, bool charray[]){
double recip=0, k2;
double mu1[3];
double mu2[3];
double dipk1;
double dipk2;
for(int u=0; u<cellsize; ++u){
for(int v=0; v<cellsize; ++v){
for(int w=0; w<cellsize; ++w){
double kterm;
double I,J,K;
//do sum in k-space (leaving out k=0 term)
for (int i=(-1)*recip_cut; i<=recip_cut; i++){
for (int j=(-1)*recip_cut; j<=recip_cut; j++){
for (int k=(-1)*recip_cut; k<=recip_cut; k++){
I = (double) i;
J = (double) j;
K = (double) k;
k2 = (I*I + J*J + K*K)/(cellsize*cellsize);
if (k2 > 0.5/cellsize/cellsize){
if(charray[(int)(cellsize*cellsize*x + cellsize*y + z)]){
mu1[0] = 0;
mu1[1] = 0;
mu1[2] = 1;
}
else {
mu1[0] = 0;
mu1[1] = 0;
mu1[2] = -1;
}
if(charray[(int)(cellsize*cellsize*u + cellsize*v + w)]){
mu2[0] = 0;
mu2[1] = 0;
mu2[2] = 1;
}
else {
mu2[0] = 0;
mu2[1] = 0;
mu2[2] = -1;
}
dipk1 = mu1[0]*I/cellsize + mu1[1]*J/cellsize + mu1[2]*K/cellsize;
dipk2 = mu2[0]*I/cellsize + mu2[1]*J/cellsize + mu2[2]*K/cellsize;
kterm = 1;
kterm *= dipk1*dipk2*4*M_PI*M_PI;
kterm *= 0.5/(M_PI*k2);
kterm *= structure2(x-u,y-v,z-w,I/cellsize,J/cellsize,K/cellsize);
kterm *= exp(-M_PI*M_PI*k2/(alpha*alpha));
kterm /= cellsize*cellsize*cellsize;
recip += kterm;
}
}
}
}
}
}
}
return recip;
}
|
c36a7d1df0bcc1a402b3d14aa0db18963ec4084e | bbff50d94efc9bc27a449fd5adcfde0a2ee3b5bf | /codeforces/1517/C.cpp | 3304805c20dfd01fae0fc9d83c2baef4ba97e488 | [] | no_license | ameybhavsar24/competitive-programming | 389b1ffb9f3d11e18bb90b0bb03127086af2b1f0 | c9f74f4b9dba34b9d98d9e6c433d3d7890eaa63b | refs/heads/main | 2023-07-04T17:03:39.699518 | 2021-08-09T14:27:08 | 2021-08-09T14:27:08 | 379,605,431 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,512 | cpp | C.cpp | // Author: Amey Bhavsar - ameybhavsar24@(github & twitter)
// IDE: Geany on Ubuntu 20.04
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define MOD 1000000007
bool fail = false;
int cnt;
void dfs(int x, int y, vector< vector< int > >& ans, int set) {
if (x < 0 || x >= (int)ans.size() || y < 0 || y >= (int) ans.size()) {
return;
}
if (cnt == 0) return;
if (ans[x][y] != -1 && cnt != set) return;
ans[x][y] = set;
--cnt;
if (y > 0 && ans[x][y-1] == -1) {
dfs(x, y-1, ans, set);
} else if (x+1 < (int)ans.size() && ans[x+1][y] == -1) {
dfs(x+1, y, ans, set);
}
}
void solve() {
int n;
cin >> n;
vector< int > a(n);
for (auto& e:a) cin >> e;
vector< vector< int > > ans(n, vector< int> (n, 0));
rep(i,0,n) {
ans[i][i] = a[i];
rep(j,0,n) {
if (j < i) ans[i][j] = -1;
}
}
rep(i,0,n) {
cnt = a[i];
dfs(i,i,ans, a[i]);
}
vector< int > cnts(n, 0);
rep(i,0,n) {
rep(j,0,n) {
if (j<=i) {
cnts[ans[i][j]-1]++;
}
}
}
fail = 1;
rep(i,0,n) {
fail &= cnts[i] == i+1;
}
if (!fail) {
cout << -1 << '\n';
return;
}
rep(i,0,n) {
rep(j,0,n) {
if (j <= i) cout << ans[i][j] << ' ';
}
cout << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
solve();
return 0;
} |
1c63faef4dad47181dc45cec16a0e140e1ab1e63 | 6e790b19299272268806f8808d759a80401f8825 | /DX/DX/src/Include/Core/Input/misc/axis_mapper.h | 3ef8492664aa7cd2006147907db889d1efe12ca0 | [] | no_license | SilvanVR/DX | 8e80703e7ce015d287ba3ebc2fc0d78085d312f1 | 0fd7ec94e8d868c7a087f95f9dda60e97df38682 | refs/heads/master | 2023-07-16T01:42:48.306869 | 2021-08-28T02:36:32 | 2021-08-28T02:36:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,602 | h | axis_mapper.h | #pragma once
/**********************************************************************
class: AxisMapper (axis_mapper.h)
author: S. Hau
date: November 18, 2017
An axis represents a value in the range of [-1, 1].
Each axis value can be modified by two buttons.
Note that more than two buttons can be attached to an axis, e.g. for
modifying the axis value with different devices.
Code example:
axisMapper.registerAxis( "Forward", Key::W, Key::S, 5.0f );
axisMapper.registerAxis( "Forward", MouseKey::LButton, MouseKey::RButton, 5.0f );
F32 val = axisMapper.getAxis( "Forward" );
**********************************************************************/
#include "Core/Input/input_enums.hpp"
#include "OS/Window/keycodes.h"
namespace Core { namespace Input {
//----------------------------------------------------------------------
class Keyboard;
class Mouse;
class Controller;
//**********************************************************************
class AxisMapper
{
public:
AxisMapper(const Keyboard* keyboard, const Mouse* mouse, const Controller* controller)
: m_keyboard( keyboard ), m_mouse( mouse ), m_controller( controller ) {}
~AxisMapper() = default;
//----------------------------------------------------------------------
// Return the axis value for the corresponding axis. Note that the axes
// are already multiplied with delta, so dont do it again.
// @Param:
// "name": The name of the registered axis.
// @Return:
// The value of the registered axis (frame-rate independant).
//----------------------------------------------------------------------
F64 getAxisValue(const char* name) const;
//----------------------------------------------------------------------
// @Return:
// The value of the wheel axis (frame-rate independant).
//----------------------------------------------------------------------
F64 getMouseWheelAxisValue() const { return m_wheelAxis; }
//----------------------------------------------------------------------
// Register a new axis. The value of the axis interpolates
// between -1 and 1 depending on which key is/was pressed.
// This function can be called more than once for an axis, e.g. for
// setting up an axis for the mouse AND the keyboard.
// @Params:
// "name": The name of the new axis.
// "key0": This key increases the axis value.
// "key1": This key decreases the axis value.
// "acceleration": How fast the bounds are reached.
// "damping": How fast the axis value will jump back to 0.
//----------------------------------------------------------------------
void registerAxis(const char* name, Key key0, Key key1, F64 acceleration = 1.0f, F64 damping = 1.0f);
void registerAxis(const char* name, MouseKey key0, MouseKey key1, F64 acceleration = 1.0f, F64 damping = 1.0f);
void registerAxis(const char* name, ControllerKey key0, ControllerKey key1, F64 acceleration = 1.0f, F64 damping = 1.0f);
void unregisterAxis(const char* name);
//----------------------------------------------------------------------
// Updates an existing axis. Issues a warning if axis does not exist.
//----------------------------------------------------------------------
void updateAxis(const char* name, F64 acceleration, F64 damping);
//----------------------------------------------------------------------
void setMouseWheelAxisParams(F32 acc, F32 damping){ m_mouseWheelAcceleration = acc; m_mouseWheelDamping = damping; }
private:
const Keyboard* m_keyboard = nullptr;
const Mouse* m_mouse = nullptr;
const Controller* m_controller = nullptr;
F32 m_mouseWheelAcceleration = 50.0f;
F32 m_mouseWheelDamping = 7.0f;
// <---------- AXIS ----------->
struct AxisEvent
{
AxisEvent(EInputDevice _device, Key key0, Key key1) : device( _device ), keyboardKey0( key0 ), keyboardKey1( key1 ) {}
AxisEvent(EInputDevice _device, MouseKey key0, MouseKey key1) : device( _device ), mouseKey0( key0 ), mouseKey1( key1 ) {}
AxisEvent(EInputDevice _device, ControllerKey key0, ControllerKey key1) : device( _device ), controllerKey0( key0 ), controllerKey1( key1 ) {}
EInputDevice device;
union {
Key keyboardKey0;
MouseKey mouseKey0;
ControllerKey controllerKey0;
};
union {
Key keyboardKey1;
MouseKey mouseKey1;
ControllerKey controllerKey1;
};
};
struct Axis
{
F64 value = 0.0;
F64 acceleration = 1.0;
F64 damping = 1.0;
ArrayList<AxisEvent> events;
};
HashMap<StringID, Axis> m_axisMap;
F64 m_wheelAxis;
void _UpdateAxes(F64 delta);
void _UpdateMouseWheelAxis(F64 delta);
// Should be called once per tick. Checks if actions should be fired.
friend class InputManager;
void _UpdateInternalState(F64 delta);
NULL_COPY_AND_ASSIGN(AxisMapper)
};
} } // end namespaces
|
50697b72fa18304352f650f306f1071742323f79 | cf64c8d5097388ab7959b24533b0fc0fc6b37a0a | /llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h | 2c49ff4316ba9f5ed2e60f119cb012631a014ef0 | [
"Apache-2.0",
"NCSA"
] | permissive | vusec/typesan | 5959c8330d34535d5b2516e1c833fcb358b07ca7 | 831ca2af1a629e8ea93bb8c5b4215f12247b595c | refs/heads/master | 2021-07-05T17:54:28.212867 | 2021-05-05T10:41:27 | 2021-05-05T10:41:27 | 65,472,228 | 33 | 17 | null | null | null | null | UTF-8 | C++ | false | false | 3,207 | h | AMDGPUAsmPrinter.h | //===-- AMDGPUAsmPrinter.h - Print AMDGPU assembly code ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
/// \file
/// \brief AMDGPU Assembly printer class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUASMPRINTER_H
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUASMPRINTER_H
#include "llvm/CodeGen/AsmPrinter.h"
#include <vector>
namespace llvm {
class AMDGPUAsmPrinter final : public AsmPrinter {
private:
struct SIProgramInfo {
SIProgramInfo() :
VGPRBlocks(0),
SGPRBlocks(0),
Priority(0),
FloatMode(0),
Priv(0),
DX10Clamp(0),
DebugMode(0),
IEEEMode(0),
ScratchSize(0),
ComputePGMRSrc1(0),
LDSBlocks(0),
ScratchBlocks(0),
ComputePGMRSrc2(0),
NumVGPR(0),
NumSGPR(0),
FlatUsed(false),
VCCUsed(false),
CodeLen(0) {}
// Fields set in PGM_RSRC1 pm4 packet.
uint32_t VGPRBlocks;
uint32_t SGPRBlocks;
uint32_t Priority;
uint32_t FloatMode;
uint32_t Priv;
uint32_t DX10Clamp;
uint32_t DebugMode;
uint32_t IEEEMode;
uint32_t ScratchSize;
uint64_t ComputePGMRSrc1;
// Fields set in PGM_RSRC2 pm4 packet.
uint32_t LDSBlocks;
uint32_t ScratchBlocks;
uint64_t ComputePGMRSrc2;
uint32_t NumVGPR;
uint32_t NumSGPR;
uint32_t LDSSize;
bool FlatUsed;
// Bonus information for debugging.
bool VCCUsed;
uint64_t CodeLen;
};
void getSIProgramInfo(SIProgramInfo &Out, const MachineFunction &MF) const;
void findNumUsedRegistersSI(const MachineFunction &MF,
unsigned &NumSGPR,
unsigned &NumVGPR) const;
/// \brief Emit register usage information so that the GPU driver
/// can correctly setup the GPU state.
void EmitProgramInfoR600(const MachineFunction &MF);
void EmitProgramInfoSI(const MachineFunction &MF, const SIProgramInfo &KernelInfo);
void EmitAmdKernelCodeT(const MachineFunction &MF,
const SIProgramInfo &KernelInfo) const;
public:
explicit AMDGPUAsmPrinter(TargetMachine &TM,
std::unique_ptr<MCStreamer> Streamer);
bool runOnMachineFunction(MachineFunction &MF) override;
const char *getPassName() const override {
return "AMDGPU Assembly Printer";
}
/// Implemented in AMDGPUMCInstLower.cpp
void EmitInstruction(const MachineInstr *MI) override;
void EmitFunctionBodyStart() override;
void EmitFunctionEntryLabel() override;
void EmitGlobalVariable(const GlobalVariable *GV) override;
void EmitStartOfAsmFile(Module &M) override;
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
unsigned AsmVariant, const char *ExtraCode,
raw_ostream &O) override;
protected:
std::vector<std::string> DisasmLines, HexLines;
size_t DisasmLineMaxLen;
};
} // End anonymous llvm
#endif
|
28753a3eaeecd1ff148f85c60f563bfc8d1b4fea | d2a592747a66a3bdfd8d3e976cd3cc8dbde47884 | /core/src/inline_layout/utils.hpp | e1dfe0d3c17ee8620b3e7cd3a380b5a374ff5cb2 | [] | no_license | blockspacer/aardvark | 18e1e3e5c7985062f9b888777220820ee9c83f08 | c9b49aa07aef904f80764fc5ea1a664de02ee288 | refs/heads/master | 2020-09-10T23:46:59.740221 | 2019-11-15T07:28:24 | 2019-11-15T07:28:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,076 | hpp | utils.hpp | #pragma once
#include <optional>
#include <unicode/unistr.h>
#include "../base_types.hpp"
#include "../elements/elements.hpp"
#include "span.hpp"
namespace aardvark::inline_layout {
float measure_text_width(const UnicodeString& text, const SkPaint& paint,
std::optional<int> num_chars = std::nullopt);
int break_text(const UnicodeString& text, const SkPaint& paint,
float available_width, float* width = nullptr);
// Converts ICU UnicodeString to C++ std string (with UTF-16 encoding)
std::string icu_to_std_string(const UnicodeString& text);
// Calculates combined line metrics of the list of spans
LineMetrics calc_combined_metrics(
const std::vector<std::shared_ptr<Span>>& spans,
const LineMetrics& default_metrics);
// Renders list of spans into the provided container
void render_spans(const std::vector<std::shared_ptr<Span>>& spans,
const LineMetrics& metrics, const Position& offset,
std::vector<std::shared_ptr<Element>>* container);
} // namespace aardvark::inline_layout
|
44b8c431426a17720367ec2fb3f018a81e2457d6 | 72cb10c6911df82f1524e93578d3210cb1d57c58 | /bobberick-demo/services/PlayerStatsService.cpp | feb472daf5d0ae43b4a4cd2299866b1434d30ea5 | [
"MIT"
] | permissive | mikerovers/bobberick-tools | f68e426dec5989d7aa5cde7079ab8ac55a8fab8b | dee7556ad086384c26f379699b98ec0ca593845d | refs/heads/develop | 2020-03-28T07:11:53.374223 | 2019-03-08T22:23:15 | 2019-03-08T22:23:15 | 147,886,542 | 0 | 0 | null | 2018-12-20T13:16:21 | 2018-09-08T00:19:04 | C++ | UTF-8 | C++ | false | false | 11,779 | cpp | PlayerStatsService.cpp | #include "PlayerStatsService.h"
#include <algorithm>
#include "../../bobberick-framework/src/services/ServiceManager.h"
#include "../../bobberick-framework/src/services/SaveService.h"
void PlayerStatsService::init()
{
if (xp > 0)
{
xpTotal += xp;
saveMeta();
}
xp = 0;
shdActive = false;
invincible = false;
fireCooldown = 0;
normalWeapon = WeaponComponent("", "Training Bow of Nothing", false, 10, 30, "bullet", "characterShooting");
magicWeapon = WeaponComponent("", "Training Staff of Nothing", true, 30, 60, "bolt", "characterCasting");
comparingWeapon = WeaponComponent("", "", false, 0, 0, "", "");
hp = hpMax = getHPvalue(false);
atMin = getATminValue(false);
atMax = getATmaxValue(false);
shdTime = shdTimeMax = getSHDvalue(false);
shdRecov = getSHDrecovValue(false);
}
void PlayerStatsService::setStats(const int hp, const int hpMax, const int atMin, const int atMax,
const double shdTime, const double shdTimeMax, const double shdRecov,
const int xp)
{
PlayerStatsService::hp = hp;
PlayerStatsService::hpMax = hpMax;
PlayerStatsService::atMin = atMin;
PlayerStatsService::atMax = atMax;
PlayerStatsService::shdTime = shdTime;
PlayerStatsService::shdTimeMax = shdTimeMax;
PlayerStatsService::shdRecov = shdRecov;
PlayerStatsService::xp = xp;
}
void PlayerStatsService::setWeapons(WeaponComponent normal, WeaponComponent magic)
{
normalWeapon = normal;
magicWeapon = magic;
}
void PlayerStatsService::setMagicWeapon(WeaponComponent weapon)
{
magicWeapon = weapon;
}
void PlayerStatsService::setNormalWeapon(WeaponComponent weapon)
{
normalWeapon = weapon;
}
void PlayerStatsService::equipComparingWeapon() {
if (compareTime > 0 && !compareConfirmed) {
if (comparingWeapon.isMagic) {
magicWeapon = comparingWeapon;
} else {
normalWeapon = comparingWeapon;
}
compareTime = 0;
compareConfirmed = true;
}
}
void PlayerStatsService::setMetaStats(const int xpTotal, const int hpLv, const int atLv,
const int shdTimeLv, const int shdRecovLv)
{
PlayerStatsService::xpTotal = xpTotal;
PlayerStatsService::hpLv = hpLv;
PlayerStatsService::atLv = atLv;
PlayerStatsService::shdTimeLv = shdTimeLv;
PlayerStatsService::shdRecovLv = shdRecovLv;
}
void PlayerStatsService::update()
{
if (xp > 999999)
{
xp = 999999;
}
if (hp > 0)
{
// Shield recovery freezes when the player is dead.
if (shdActive)
{
shdTime -= 1;
if (shdTime <= 0)
{
shdActive = false;
}
}
else
{
// The shield mode only recovers when inactive.
shdTime += shdRecov;
if (shdTime > shdTimeMax)
{
shdTime = shdTimeMax;
}
}
if (fireCooldown > 0)
{
fireCooldown--;
}
}
else
{
shdActive = false;
shdTime = 0;
hp = 0;
}
if (compareTime > 0) {
compareTime--;
}
}
void PlayerStatsService::getHit(double attack)
{
if (!shdActive && !invincible)
{
hp -= attack;
if (hp < 0)
{
hp = 0;
}
}
}
void PlayerStatsService::heal(const int amount)
{
hp += amount;
if (hp > hpMax)
{
hp = hpMax;
}
}
int PlayerStatsService::attack(const bool magic)
{
if (fireCooldown <= 0)
{
int basePow = generator.getRandomNumber(atMin, atMax);
if (magic)
{
fireCooldown = magicWeapon.fireDelay;
return basePow + magicWeapon.power;
}
else
{
fireCooldown = normalWeapon.fireDelay;
return basePow + normalWeapon.power;
}
}
else
{
return -1; // Cannot fire a bullet yet.
}
}
void PlayerStatsService::toggleShield()
{
if (!shdActive && shdTime / shdTimeMax >= 0.5)
{
shdActive = true;
}
else if (shdActive)
{
shdActive = false;
}
}
bool PlayerStatsService::upgradeHPlevel()
{
if (getHPcost() > -1 && xpTotal >= getHPcost())
{
xpTotal -= getHPcost();
hpLv++;
init();
return true;
}
else
{
return false;
}
}
bool PlayerStatsService::upgradeATlevel()
{
if (getATcost() > -1 && xpTotal >= getATcost())
{
xpTotal -= getATcost();
atLv++;
init();
return true;
}
else
{
return false;
}
}
bool PlayerStatsService::upgradeSHDlevel()
{
if (getSHDcost() > -1 && xpTotal >= getSHDcost())
{
xpTotal -= getSHDcost();
shdTimeLv++;
init();
return true;
}
else
{
return false;
}
}
bool PlayerStatsService::upgradeSHDrecovLevel()
{
if (getSHDrecovCost() > -1 && xpTotal >= getSHDrecovCost())
{
xpTotal -= getSHDrecovCost();
shdRecovLv++;
init();
return true;
}
else
{
return false;
}
}
// Getters
int PlayerStatsService::getHP() const
{
return hp;
}
int PlayerStatsService::getHPmax() const
{
return hpMax;
}
int PlayerStatsService::getATmin() const
{
return atMin;
}
int PlayerStatsService::getATmax() const
{
return atMax;
}
double PlayerStatsService::getSHD() const
{
return shdTime;
}
int PlayerStatsService::getSHDmax() const
{
return shdTimeMax;
}
double PlayerStatsService::getSHDrecov() const
{
return shdRecov;
}
bool PlayerStatsService::getSHDactive() const
{
return shdActive;
}
int PlayerStatsService::getXPtotal() const
{
return xpTotal;
}
int PlayerStatsService::getHPlevel() const
{
return hpLv;
}
int PlayerStatsService::getATlevel() const
{
return atLv;
}
int PlayerStatsService::getSHDlevel() const
{
return shdTimeLv;
}
int PlayerStatsService::getSHDrecovLevel() const
{
return shdRecovLv;
}
int PlayerStatsService::getHPcost() const
{
if (getHPvalue(true) != -1)
{
return getHPvalue(true) * 10;
}
else
{
return -1;
}
}
int PlayerStatsService::getATcost() const
{
if (getATminValue(true) != -1)
{
return static_cast<int>(pow(getATminValue(true), 3));
}
else
{
return -1;
}
}
int PlayerStatsService::getSHDcost() const
{
if (getSHDvalue(true) != -1)
{
return static_cast<int>(pow((getSHDlevel() + 1) * 90, 1.6));
}
else
{
return -1;
}
}
int PlayerStatsService::getSHDrecovCost() const
{
if (getSHDrecovValue(true) != -1)
{
return static_cast<int>(pow((getSHDrecovLevel() + 1) * 120, 1.6));
}
else
{
return -1;
}
}
int PlayerStatsService::getHPvalue(bool next) const
{
if (!next)
{
return (int)std::min(100 * (pow(1.1, hpLv)), 500000.0);
}
else
{
if (getHPvalue(false) < 500000)
{
return (int)std::min(100 * (pow(1.1, hpLv + 1)), 500000.0);
}
else
{
return -1;
}
}
}
int PlayerStatsService::getATminValue(bool next) const
{
if (!next)
{
return (int)std::min(pow(atLv + 7, 1.3), 400.0);
}
else
{
if (getATminValue(false) < 400)
{
return (int)std::min(pow(atLv + 8, 1.3), 400.0);
}
else
{
return -1;
}
}
}
int PlayerStatsService::getATmaxValue(bool next) const
{
int value = getATminValue(next);
if (value > -1)
{
value = static_cast<int>((value * 1.5) + 1);
}
return std::min(value, 600);
}
int PlayerStatsService::getSHDvalue(bool next) const
{
if (!next)
{
return (int)std::min(120 + (10 * pow(shdTimeLv, 0.9)), 999.0);
}
else
{
if (getSHDvalue(false) < 999)
{
return (int)std::min(120 + (10 * pow(shdTimeLv + 1, 0.9)), 999.0);
}
else
{
return -1;
}
}
}
double PlayerStatsService::getSHDrecovValue(bool next) const
{
if (!next)
{
return std::min(0.1 + ((shdRecovLv) * 0.01), 1.0);
}
else
{
if (getSHDrecovValue(false) < 1)
{
return std::min(0.1 + ((shdRecovLv + 1) * 0.01), 1.0);
}
else
{
return -1;
}
}
}
void PlayerStatsService::changeHPmax(const int amount)
{
hpMax += amount;
if (hpMax < 1)
{
hpMax = 1;
}
if (hpMax > 999999)
{
hpMax = 999999;
}
if (hp > hpMax)
{
hp = hpMax;
}
}
void PlayerStatsService::changeATmin(const int amount)
{
atMin += amount;
if (atMin < 0)
{
atMin = 0;
}
if (atMin > atMax)
{
atMin = atMax;
}
}
void PlayerStatsService::changeATmax(const int amount)
{
atMax += amount;
if (atMax < 1)
{
atMax = 1;
}
if (atMin > atMax)
{
atMin = atMax;
}
}
void PlayerStatsService::setSHD(const int amount)
{
shdTime = amount;
}
void PlayerStatsService::save()
{
auto& save = ServiceManager::Instance()->getService<SaveService>();
save.keep<int>("hp", getHP());
save.keep<int>("hpMax", getHPmax());
save.keep<int>("atMin", getATmin());
save.keep<int>("atMax", getATmax());
save.keep<double>("shdTime", shdTime);
save.keep<double>("shdTimeMax", getSHDmax());
save.keep<double>("shdRecov", getSHDrecov());
save.keep<int>("xp", xp);
save.keep<bool>("w1IsMagic", normalWeapon.isMagic);
save.keep<int>("w1Power", normalWeapon.power);
save.keep<int>("w1FireDelay", normalWeapon.fireDelay);
save.keep<std::string>("w1BulletTexture", normalWeapon.bulletTexture);
save.keep<std::string>("w1TextureID", normalWeapon.textureID);
save.keep<std::string>("w1Name", normalWeapon.name);
save.keep<std::string>("w1AttackingTextureID", normalWeapon.attackingTextureID);
save.keep<bool>("w2IsMagic", magicWeapon.isMagic);
save.keep<int>("w2Power", magicWeapon.power);
save.keep<int>("w2FireDelay", magicWeapon.fireDelay);
save.keep<std::string>("w2BulletTexture", magicWeapon.bulletTexture);
save.keep<std::string>("w2TextureID", magicWeapon.textureID);
save.keep<std::string>("w2Name", magicWeapon.name);
save.keep<std::string>("w2AttackingTextureID", magicWeapon.attackingTextureID);
save.flush();
}
void PlayerStatsService::load()
{
auto& save = ServiceManager::Instance()->getService<SaveService>();
save.load();
setStats(
save.get<int>("hp"),
save.get<int>("hpMax"),
save.get<int>("atMin"),
save.get<int>("atMax"),
save.get<double>("shdTime"),
save.get<double>("shdTimeMax"),
save.get<double>("shdRecov"),
save.get<int>("xp")
);
normalWeapon = WeaponComponent(
save.get<std::string>("w1TextureID"),
save.get<std::string>("w1Name"),
save.get<bool>("w1IsMagic"),
save.get<int>("w1Power"),
save.get<int>("w1FireDelay"),
save.get<std::string>("w1BulletTexture"),
save.get<std::string>("w1AttackingTextureID")
);
magicWeapon = WeaponComponent(
save.get<std::string>("w2TextureID"),
save.get<std::string>("w2Name"),
save.get<bool>("w2IsMagic"),
save.get<int>("w2Power"),
save.get<int>("w2FireDelay"),
save.get<std::string>("w2BulletTexture"),
save.get<std::string>("w2AttackingTextureID")
);
}
bool PlayerStatsService::validateSave() const
{
auto& save = ServiceManager::Instance()->getService<SaveService>();
return save.has("hp")
&& save.has("hpMax")
&& save.has("atMin")
&& save.has("atMax")
&& save.has("shdTimeMax")
&& save.has("shdRecov")
&& save.has("w1IsMagic")
&& save.has("w1IsMagic")
&& save.has("w1FireDelay")
&& save.has("w1BulletTexture")
&& save.has("w1TextureID")
&& save.has("w1AttackingTextureID")
&& save.has("w1Name")
&& save.has("w2IsMagic")
&& save.has("w2Power")
&& save.has("w2FireDelay")
&& save.has("w2BulletTexture")
&& save.has("w2TextureID")
&& save.has("w2AttackingTextureID")
&& save.has("w2Name");
}
void PlayerStatsService::saveMeta()
{
auto& save = ServiceManager::Instance()->getService<SaveService>();
save.keep<int>("xpTotal", getXPtotal());
save.keep<int>("hpLv", getHPlevel());
save.keep<int>("atLv", getATlevel());
save.keep<int>("shdTimeLv", getSHDlevel());
save.keep<int>("shdRecovLv", getSHDrecovLevel());
save.flush();
}
void PlayerStatsService::wipeMeta()
{
xpTotal = 0;
hpLv = 0;
atLv = 0;
shdTimeLv = 0;
shdRecovLv = 0;
saveMeta();
}
void PlayerStatsService::loadMeta()
{
auto& save = ServiceManager::Instance()->getService<SaveService>();
save.load();
setMetaStats(
save.get<int>("xpTotal"),
save.get<int>("hpLv"),
save.get<int>("atLv"),
save.get<int>("shdTimeLv"),
save.get<int>("shdRecovLv")
);
}
bool PlayerStatsService::validateSaveMeta() const
{
auto& save = ServiceManager::Instance()->getService<SaveService>();
return save.has("xpTotal")
&& save.has("hpLv")
&& save.has("atLv")
&& save.has("shdTimeLv")
&& save.has("shdRecovLv");
} |
d2da079029d1b08aa8edc8c009651c64cb70f516 | 297497957c531d81ba286bc91253fbbb78b4d8be | /third_party/libwebrtc/modules/rtp_rtcp/source/capture_clock_offset_updater.cc | 4324f8a85c96905c60ff1d3fac3ca59c5cd41405 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | marco-c/gecko-dev-comments-removed | 7a9dd34045b07e6b22f0c636c0a836b9e639f9d3 | 61942784fb157763e65608e5a29b3729b0aa66fa | refs/heads/master | 2023-08-09T18:55:25.895853 | 2023-08-01T00:40:39 | 2023-08-01T00:40:39 | 211,297,481 | 0 | 0 | NOASSERTION | 2019-09-29T01:27:49 | 2019-09-27T10:44:24 | C++ | UTF-8 | C++ | false | false | 684 | cc | capture_clock_offset_updater.cc |
#include "modules/rtp_rtcp/source/capture_clock_offset_updater.h"
namespace webrtc {
absl::optional<int64_t>
CaptureClockOffsetUpdater::AdjustEstimatedCaptureClockOffset(
absl::optional<int64_t> remote_capture_clock_offset) const {
if (remote_capture_clock_offset == absl::nullopt ||
remote_to_local_clock_offset_ == absl::nullopt) {
return absl::nullopt;
}
return static_cast<uint64_t>(*remote_capture_clock_offset) +
static_cast<uint64_t>(*remote_to_local_clock_offset_);
}
void CaptureClockOffsetUpdater::SetRemoteToLocalClockOffset(
absl::optional<int64_t> offset_q32x32) {
remote_to_local_clock_offset_ = offset_q32x32;
}
}
|
2bb190c2a69f0155055677d34a1ccdd62237155c | 47bfbc4284622d124125daf60b1394def4a45b8b | /CrcXModem128.h | 420ac04055280b0d55897b58f2ee5297b54ffdb6 | [] | no_license | YoshinoTaro/CecXModem128 | d769c9c41e314cb8057f0c8e0067f8ea48cbdf4f | 9cb10a731759488c77aa4763cf8f129a95cc67e9 | refs/heads/master | 2022-12-04T18:50:22.334428 | 2020-09-04T01:28:45 | 2020-09-04T01:28:45 | 292,274,678 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,134 | h | CrcXModem128.h | /*
* Spresense Simple XModem library
* Copyright 2020 Yoshino Taro
*
* This xmodem library only supports 128 packet and CRC16
*
* This library is made for Sony Spresense.
* Copatibility to other platforms is not confirmed.
* You need Spresense boards below when you will try this sketch
* Spresense Main Board
* See the detail: https://developer.sony.com/develop/spresense/
*
* The license of this source code is LGPL v2.1
*
*/
#ifndef _CRCXMODEM128_H
#define _CRCXMODEM128_H
#include <Arduino.h>
#include <File.h>
#define SOH 0x01
#define EOT 0x04
#define ENQ 0x05
#define ACK 0x06
#define LF 0x0a
#define CR 0x0d
#define NAK 0x15
#define CAN 0x18
#define PACKET_LEN 128
class CrcXModem128
{
public:
CrcXModem128();
~CrcXModem128() { }
bool begin(Stream *port);
bool setDebug(Stream *port);
int8_t sendFile(File &sndFile);
int8_t recvFile(File &rcvFile);
private:
bool m_debug;
uint16_t m_crc16;
Stream *m_x_port;
Stream *m_d_port;
void write_payload(uint8_t val);
char read_payload();
void debug_print(String str, bool fatal=false);
};
#endif
|
6cae7f2e72b7e34eb0229d66da10fa6ec4c848ff | bd1ba126ac031133401bcd270c3a94f42f5a2390 | /SkelGenerator/messagebox.cpp | fba3601992778d26864d1320ee27aec3708686d1 | [] | no_license | vg-lab/SkelGenerator | 177b9fa56fb37e420e845657f1b555fe6171215d | fa1bc903b090e5c63e96c692b4abbbab1005b56a | refs/heads/master | 2023-03-19T08:58:22.913939 | 2021-03-08T14:04:18 | 2021-03-08T14:04:18 | 274,106,250 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,395 | cpp | messagebox.cpp | #include "messagebox.h"
#include <QAbstractButton>
namespace skelgenerator {
MessageBox::MessageBox(QWidget* parent): QMessageBox(parent) {
this->timeout = 0;
this->autoClose = false;
}
MessageBox::MessageBox(int timeout_, bool autoClose_,QWidget* parent): QMessageBox(parent) {
this->timeout = timeout_;
this->autoClose = autoClose_;
}
void MessageBox::showEvent(QShowEvent */* event */) {
if (autoClose) {
this->startTimer(1000);
}
}
void MessageBox::timerEvent(QTimerEvent */* event */) {
timeout--;
std::string msg_ =
this->msg + "\n\n This dialog will be closed and those segments will be automatically ignored in " +
std::to_string(timeout) + " seconds.";
this->setInformativeText(QString::fromStdString(msg_));
this->update();
this->repaint();
if (timeout <= 0) {
this->done(0);
}
}
int MessageBox::exec() {
this->msg = this->informativeText().toStdString();
if (autoClose) {
this->setInformativeText(QString::fromStdString(
msg + "\n\n This dialog will be closed and those segments will be automatically ignored in " +
std::to_string(timeout) + " seconds."));
}
return QMessageBox::exec();
}
}
|
b842b38299dc93fd3ec6e95cf2d084898e00963e | f81124e4a52878ceeb3e4b85afca44431ce68af2 | /re20_3/processor58/35/p | bf7e03b71f80fc194d0b8ffbaccc8f45f8b80ee8 | [] | no_license | chaseguy15/coe-of2 | 7f47a72987638e60fd7491ee1310ee6a153a5c10 | dc09e8d5f172489eaa32610e08e1ee7fc665068c | refs/heads/master | 2023-03-29T16:59:14.421456 | 2021-04-06T23:26:52 | 2021-04-06T23:26:52 | 355,040,336 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 16,810 | p | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "35";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
928
(
-0.00274481
-0.00260361
-0.0024638
-0.00232535
-0.00218823
-0.0020524
-0.00274604
-0.00260482
-0.00246499
-0.00232652
-0.00218938
-0.00205353
-0.00274851
-0.00260725
-0.00246737
-0.00232886
-0.00219167
-0.00205578
-0.00275222
-0.00261088
-0.00247093
-0.00233236
-0.00219511
-0.00205916
-0.00275715
-0.00261572
-0.00247568
-0.00233702
-0.00219969
-0.00206366
-0.00276332
-0.00262176
-0.00248162
-0.00234284
-0.00220541
-0.00206928
-0.00277071
-0.00262901
-0.00248873
-0.00234982
-0.00221226
-0.00207602
-0.00263746
-0.00249702
-0.00235796
-0.00222026
-0.00208387
-0.0026471
-0.00250648
-0.00236725
-0.00222938
-0.00209284
-0.00265794
-0.00251711
-0.00237768
-0.00223963
-0.00210291
-0.00266996
-0.00252891
-0.00238926
-0.002251
-0.00211409
-0.00268317
-0.00254186
-0.00240198
-0.00226349
-0.00212637
-0.00269754
-0.00255597
-0.00241583
-0.0022771
-0.00213974
-0.00271309
-0.00257123
-0.00243081
-0.00229181
-0.00215419
-0.0027298
-0.00258762
-0.0024469
-0.00230761
-0.00216973
-0.00274766
-0.00260515
-0.00246411
-0.00232451
-0.00218633
-0.00276667
-0.0026238
-0.00248242
-0.0023425
-0.00220401
-0.00278682
-0.00264358
-0.00250183
-0.00236156
-0.00222274
-0.0028081
-0.00266445
-0.00252233
-0.00238169
-0.00224252
-0.00283049
-0.00268643
-0.0025439
-0.00240288
-0.00226334
-0.002854
-0.00270949
-0.00256654
-0.00242512
-0.00228519
-0.0028786
-0.00273363
-0.00259024
-0.00244839
-0.00230807
-0.00290428
-0.00275884
-0.00261499
-0.0024727
-0.00233195
-0.00293105
-0.00278511
-0.00264077
-0.00249802
-0.00235683
-0.00295888
-0.00281242
-0.00266758
-0.00252435
-0.00238271
-0.00298771
-0.00284071
-0.00269536
-0.00255164
-0.00240952
-0.00301749
-0.00286995
-0.00272407
-0.00257983
-0.00243722
-0.00304872
-0.0029006
-0.00275416
-0.00260938
-0.00246625
-0.00308234
-0.00293354
-0.00278645
-0.00264105
-0.00249733
-0.00311375
-0.00296436
-0.00281669
-0.00267075
-0.0025265
-0.00314472
-0.00299536
-0.00284774
-0.00270185
-0.00255767
-0.00321946
-0.00306898
-0.00292028
-0.00277336
-0.00262819
-0.00329373
-0.00314224
-0.00299257
-0.00284472
-0.00269866
-0.00337127
-0.00321871
-0.00306802
-0.00291918
-0.00277218
-0.00345318
-0.00329946
-0.00314764
-0.0029977
-0.00284965
-0.00353894
-0.00338396
-0.00323092
-0.00307979
-0.00293059
-0.00362832
-0.00347199
-0.00331762
-0.00316521
-0.00301476
-0.00372113
-0.00356334
-0.00340755
-0.00325376
-0.00310195
-0.0038171
-0.00365776
-0.00350045
-0.00334516
-0.00319189
-0.00391596
-0.00375497
-0.00359603
-0.00343915
-0.00328432
-0.00401741
-0.00385467
-0.00369402
-0.00353544
-0.00337893
-0.00412114
-0.00395656
-0.00379408
-0.0036337
-0.00347542
-0.00422683
-0.00406032
-0.00389592
-0.00373364
-0.00357348
-0.00433414
-0.0041656
-0.00399919
-0.00383492
-0.00367278
-0.00444274
-0.00427208
-0.00410357
-0.00393721
-0.003773
-0.00455227
-0.00437942
-0.00420873
-0.0040402
-0.00387382
-0.0046624
-0.00448728
-0.00431434
-0.00414355
-0.00397492
-0.00477279
-0.00459535
-0.00442007
-0.00424696
-0.004076
-0.00488313
-0.00470329
-0.00452562
-0.00435011
-0.00417676
-0.0049931
-0.00481081
-0.00463069
-0.00445273
-0.00427692
-0.00510239
-0.00491762
-0.004735
-0.00455453
-0.0043762
-0.00521073
-0.00502343
-0.00483828
-0.00465526
-0.00447437
-0.00531784
-0.00512799
-0.00494027
-0.00475468
-0.00457119
-0.00542349
-0.00523106
-0.00504075
-0.00485255
-0.00466644
-0.00552744
-0.00533242
-0.00513951
-0.00494869
-0.00475993
-0.00562948
-0.00543187
-0.00523636
-0.0050429
-0.00485149
-0.00572942
-0.00552924
-0.00533111
-0.00513503
-0.00494097
-0.0058271
-0.00562434
-0.00542363
-0.00522493
-0.00502822
-0.00592236
-0.00571705
-0.00551376
-0.00531246
-0.00511313
-0.00491573
-0.00601507
-0.00580724
-0.0056014
-0.00539753
-0.00519559
-0.00499555
-0.00610512
-0.0058948
-0.00568645
-0.00548003
-0.00527552
-0.00507288
-0.0061924
-0.00597963
-0.00576881
-0.00555989
-0.00535284
-0.00514764
-0.00627683
-0.00606167
-0.00584841
-0.00563704
-0.00542751
-0.00521979
-0.00635835
-0.00614083
-0.00592521
-0.00571143
-0.00549947
-0.00528928
-0.00643688
-0.00621708
-0.00599914
-0.00578302
-0.00556868
-0.00535609
-0.0065124
-0.00629037
-0.00607018
-0.00585177
-0.00563513
-0.00542019
-0.00658486
-0.00636067
-0.00613829
-0.00591767
-0.00569878
-0.00548158
-0.00665423
-0.00642796
-0.00620346
-0.00598071
-0.00575965
-0.00554025
-0.0067205
-0.00649222
-0.00626568
-0.00604086
-0.00581772
-0.00559619
-0.00678366
-0.00655344
-0.00632495
-0.00609815
-0.00587299
-0.00564943
-0.00684371
-0.00661163
-0.00638126
-0.00615256
-0.00592547
-0.00569995
-0.00666679
-0.00643462
-0.0062041
-0.00597517
-0.00574779
-0.00671891
-0.00648505
-0.00625279
-0.00602211
-0.00579296
-0.00676803
-0.00653254
-0.00629865
-0.00606631
-0.00583547
-0.00681413
-0.00657712
-0.00634168
-0.00610777
-0.00587534
-0.00685725
-0.0066188
-0.0063819
-0.00614652
-0.0059126
-0.00689739
-0.0066576
-0.00641934
-0.00618258
-0.00594726
-0.00693458
-0.00669353
-0.00645401
-0.00621596
-0.00597934
-0.00696882
-0.00672662
-0.00648592
-0.00624669
-0.00600887
-0.00700015
-0.00675688
-0.00651511
-0.00627479
-0.00603586
-0.00702856
-0.00678433
-0.00654158
-0.00630027
-0.00606034
-0.00705408
-0.00680898
-0.00656535
-0.00632314
-0.00608232
-0.00707673
-0.00683085
-0.00658644
-0.00634344
-0.00610181
-0.00709651
-0.00684996
-0.00660486
-0.00636116
-0.00611883
-0.00711344
-0.00686631
-0.00662062
-0.00637633
-0.0061334
-0.00712754
-0.00687992
-0.00663374
-0.00638896
-0.00614552
-0.0071388
-0.00689079
-0.00664422
-0.00639904
-0.0061552
-0.00714724
-0.00689894
-0.00665208
-0.0064066
-0.00616246
-0.00715287
-0.00690438
-0.00665732
-0.00641164
-0.0061673
-0.00715567
-0.00690708
-0.00665993
-0.00641415
-0.00616971
-0.00314464
-0.00321938
-0.00329365
-0.00337118
-0.0034531
-0.00353886
-0.00362824
-0.00372105
-0.00381702
-0.00391588
-0.00401733
-0.00412107
-0.00422676
-0.00433407
-0.00444266
-0.0045522
-0.00466233
-0.00477273
-0.00488307
-0.00499304
-0.00510233
-0.00521067
-0.00531779
-0.00542344
-0.00552739
-0.00562943
-0.00572937
-0.00582705
-0.00592232
-0.00601503
-0.00610508
-0.00619236
-0.00627679
-0.00635831
-0.00643685
-0.00651236
-0.00658482
-0.0066542
-0.00672047
-0.00678363
-0.00684368
-0.00690061
-0.00695442
-0.00700513
-0.00705275
-0.00709729
-0.00713876
-0.00717718
-0.00721257
-0.00724494
-0.00727431
-0.00730069
-0.0073241
-0.00734455
-0.00736206
-0.00737663
-0.00738828
-0.00739701
-0.00740283
-0.00740573
-0.00299528
-0.0030689
-0.00314216
-0.00321863
-0.00329938
-0.00338388
-0.00347191
-0.00356326
-0.00365768
-0.00375489
-0.0038546
-0.00395649
-0.00406024
-0.00416553
-0.00427201
-0.00437935
-0.00448722
-0.00459528
-0.00470323
-0.00481075
-0.00491756
-0.00502337
-0.00512794
-0.00523101
-0.00533237
-0.00543183
-0.00552919
-0.0056243
-0.00571701
-0.0058072
-0.00589476
-0.0059796
-0.00606163
-0.0061408
-0.00621705
-0.00629034
-0.00636064
-0.00642793
-0.00649219
-0.00655341
-0.0066116
-0.00666676
-0.00671889
-0.006768
-0.00681411
-0.00685723
-0.00689737
-0.00693456
-0.0069688
-0.00700013
-0.00702854
-0.00705406
-0.00707671
-0.00709649
-0.00711343
-0.00712752
-0.00713878
-0.00714722
-0.00715285
-0.00715566
-0.00284766
-0.0029202
-0.00299249
-0.00306794
-0.00314756
-0.00323084
-0.00331754
-0.00340747
-0.00350037
-0.00359596
-0.00369394
-0.00379401
-0.00389585
-0.00399912
-0.0041035
-0.00420866
-0.00431427
-0.00442001
-0.00452556
-0.00463064
-0.00473495
-0.00483822
-0.00494022
-0.0050407
-0.00513946
-0.00523631
-0.00533107
-0.00542358
-0.00551372
-0.00560136
-0.00568641
-0.00576877
-0.00584838
-0.00592517
-0.00599911
-0.00607014
-0.00613826
-0.00620343
-0.00626566
-0.00632492
-0.00638124
-0.0064346
-0.00648502
-0.00653252
-0.00657709
-0.00661878
-0.00665757
-0.00669351
-0.0067266
-0.00675686
-0.00678431
-0.00680896
-0.00683083
-0.00684994
-0.00686629
-0.0068799
-0.00689078
-0.00689893
-0.00690436
-0.00690707
-0.00270177
-0.00277328
-0.00284464
-0.0029191
-0.00299763
-0.00307972
-0.00316514
-0.00325368
-0.00334508
-0.00343908
-0.00353536
-0.00363363
-0.00373357
-0.00383485
-0.00393715
-0.00404013
-0.00414349
-0.0042469
-0.00435005
-0.00445267
-0.00455448
-0.00465521
-0.00475462
-0.0048525
-0.00494864
-0.00504286
-0.00513499
-0.00522488
-0.00531242
-0.00539749
-0.00547999
-0.00555985
-0.005637
-0.0057114
-0.00578298
-0.00585174
-0.00591764
-0.00598068
-0.00604084
-0.00609812
-0.00615253
-0.00620408
-0.00625277
-0.00629862
-0.00634166
-0.00638188
-0.00641932
-0.00645399
-0.0064859
-0.00651509
-0.00654156
-0.00656533
-0.00658642
-0.00660484
-0.0066206
-0.00663372
-0.00664421
-0.00665206
-0.0066573
-0.00665991
-0.0025576
-0.00262811
-0.00269858
-0.0027721
-0.00284957
-0.00293051
-0.00301468
-0.00310187
-0.00319182
-0.00328424
-0.00337886
-0.00347535
-0.00357341
-0.00367271
-0.00377293
-0.00387375
-0.00397486
-0.00407594
-0.0041767
-0.00427686
-0.00437615
-0.00447432
-0.00457114
-0.00466639
-0.00475989
-0.00485145
-0.00494092
-0.00502818
-0.00511308
-0.00519555
-0.00527548
-0.00535281
-0.00542747
-0.00549943
-0.00556865
-0.00563509
-0.00569875
-0.00575962
-0.00581769
-0.00587296
-0.00592544
-0.00597515
-0.00602209
-0.00606628
-0.00610775
-0.0061465
-0.00618256
-0.00621594
-0.00624667
-0.00627477
-0.00630025
-0.00632313
-0.00634342
-0.00636115
-0.00637632
-0.00638894
-0.00639903
-0.00640658
-0.00641162
-0.00641413
-0.00311367
-0.00296428
-0.00281662
-0.00267067
-0.00252642
-0.00308227
-0.00293347
-0.00278638
-0.00264098
-0.00249726
-0.00304865
-0.00290053
-0.00275409
-0.00260931
-0.00246618
-0.00301742
-0.00286988
-0.002724
-0.00257977
-0.00243716
-0.00298764
-0.00284064
-0.0026953
-0.00255157
-0.00240945
-0.00295881
-0.00281235
-0.00266752
-0.00252429
-0.00238264
-0.00293098
-0.00278504
-0.00264071
-0.00249796
-0.00235677
-0.00290422
-0.00275878
-0.00261493
-0.00247264
-0.00233189
-0.00287854
-0.00273358
-0.00259018
-0.00244833
-0.00230801
-0.00285394
-0.00270944
-0.00256649
-0.00242506
-0.00228514
-0.00283044
-0.00268637
-0.00254385
-0.00240283
-0.00226329
-0.00280805
-0.0026644
-0.00252227
-0.00238164
-0.00224247
-0.00278677
-0.00264353
-0.00250178
-0.00236151
-0.00222269
-0.00276663
-0.00262376
-0.00248238
-0.00234245
-0.00220396
-0.00274762
-0.00260511
-0.00246407
-0.00232447
-0.00218629
-0.00272976
-0.00258758
-0.00244686
-0.00230757
-0.00216969
-0.00271305
-0.00257119
-0.00243077
-0.00229177
-0.00215415
-0.00269751
-0.00255593
-0.0024158
-0.00227706
-0.0021397
-0.00268313
-0.00254183
-0.00240195
-0.00226346
-0.00212633
-0.00266993
-0.00252888
-0.00238923
-0.00225097
-0.00211406
-0.00265791
-0.00251708
-0.00237766
-0.0022396
-0.00210289
-0.00264708
-0.00250645
-0.00236722
-0.00222935
-0.00209282
-0.0027793
-0.00263744
-0.00249699
-0.00235794
-0.00222023
-0.00208385
-0.00277069
-0.00262899
-0.00248871
-0.0023498
-0.00221224
-0.002076
-0.0027633
-0.00262175
-0.0024816
-0.00234282
-0.00220539
-0.00206926
-0.00275714
-0.0026157
-0.00247567
-0.002337
-0.00219967
-0.00206365
-0.00275221
-0.00261087
-0.00247092
-0.00233235
-0.0021951
-0.00205915
-0.00274851
-0.00260724
-0.00246736
-0.00232885
-0.00219166
-0.00205577
-0.00274604
-0.00260482
-0.00246499
-0.00232652
-0.00218937
-0.00205352
-0.00274481
-0.00260361
-0.0024638
-0.00232535
-0.00218823
-0.0020524
)
;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value nonuniform 0();
}
cylinder
{
type zeroGradient;
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
procBoundary58to57
{
type processor;
value nonuniform List<scalar>
183
(
-0.00288743
-0.00288869
-0.00289121
-0.00289499
-0.00290002
-0.00290631
-0.00291385
-0.00277932
-0.00277932
-0.00278915
-0.0028002
-0.00281246
-0.00282592
-0.00284058
-0.00285643
-0.00287347
-0.00289168
-0.00291106
-0.0029316
-0.00295329
-0.00297612
-0.00300007
-0.00302515
-0.00305133
-0.00307862
-0.00310698
-0.00313636
-0.00316672
-0.00319855
-0.00323286
-0.00326489
-0.00329585
-0.00337175
-0.00344706
-0.00352569
-0.0036088
-0.00369585
-0.00378663
-0.00388091
-0.00397847
-0.004079
-0.00418223
-0.00428783
-0.00439548
-0.00450483
-0.00461555
-0.00472728
-0.00483968
-0.00495242
-0.00506515
-0.00517756
-0.00528933
-0.00540019
-0.00550985
-0.00561806
-0.00572457
-0.00582918
-0.00593169
-0.00603192
-0.00612971
-0.00622492
-0.00631743
-0.00640713
-0.00649394
-0.00657778
-0.00665858
-0.00673629
-0.00681089
-0.00688232
-0.00695058
-0.00701566
-0.00707753
-0.00690063
-0.00690063
-0.00695445
-0.00700516
-0.00705277
-0.00709731
-0.00713878
-0.0071772
-0.00721259
-0.00724496
-0.00727433
-0.00730071
-0.00732412
-0.00734457
-0.00736208
-0.00737665
-0.0073883
-0.00739703
-0.00740285
-0.00740575
-0.00329577
-0.00337167
-0.00344698
-0.00352561
-0.00360872
-0.00369577
-0.00378654
-0.00388083
-0.00397839
-0.00407893
-0.00418215
-0.00428776
-0.0043954
-0.00450476
-0.00461548
-0.00472721
-0.00483962
-0.00495235
-0.00506508
-0.00517749
-0.00528927
-0.00540013
-0.00550979
-0.005618
-0.00572452
-0.00582914
-0.00593165
-0.00603188
-0.00612967
-0.00622488
-0.00631739
-0.0064071
-0.0064939
-0.00657774
-0.00665854
-0.00673626
-0.00681085
-0.00688229
-0.00695055
-0.00701563
-0.0070775
-0.00713618
-0.00719166
-0.00724395
-0.00729306
-0.007339
-0.00738178
-0.00742142
-0.00745794
-0.00749134
-0.00752166
-0.00754889
-0.00757306
-0.00759417
-0.00761224
-0.00762729
-0.00763931
-0.00764833
-0.00765434
-0.00765733
-0.00326481
-0.00323279
-0.00319848
-0.00316665
-0.0031363
-0.00310691
-0.00307855
-0.00305127
-0.00302509
-0.00300002
-0.00297606
-0.00295323
-0.00293155
-0.00291101
-0.00289163
-0.00287342
-0.00285639
-0.00284054
-0.00282589
-0.00281243
-0.00280017
-0.00278913
-0.00278913
-0.00292261
-0.00291383
-0.00290629
-0.00290001
-0.00289498
-0.0028912
-0.00288869
-0.00288743
)
;
}
procBoundary58to59
{
type processor;
value nonuniform List<scalar>
181
(
-0.00191782
-0.00191893
-0.00192115
-0.00192447
-0.0019289
-0.00193442
-0.00194105
-0.00194878
-0.0019576
-0.00196751
-0.0019785
-0.00199057
-0.00200372
-0.00201793
-0.00203321
-0.00204954
-0.00206692
-0.00208534
-0.00210479
-0.00212527
-0.00214675
-0.00216924
-0.00219272
-0.00221719
-0.00224262
-0.00226898
-0.00229623
-0.00232476
-0.00235526
-0.00238393
-0.00241521
-0.00248478
-0.0025544
-0.00262701
-0.00270347
-0.0027833
-0.00286626
-0.00295213
-0.00304065
-0.00313154
-0.0032245
-0.00331924
-0.00341544
-0.00351277
-0.00361093
-0.00370959
-0.00380845
-0.0039072
-0.00400555
-0.00410324
-0.0042
-0.00429559
-0.00438979
-0.0044824
-0.00457322
-0.00466211
-0.0047489
-0.00483348
-0.00483348
-0.00472024
-0.00479739
-0.00487208
-0.00494425
-0.00501385
-0.00508084
-0.00514521
-0.00520694
-0.00526602
-0.00532246
-0.00537625
-0.00542742
-0.00547597
-0.00552192
-0.00556528
-0.00560608
-0.00564435
-0.00568009
-0.00571333
-0.0057441
-0.00577241
-0.00579829
-0.00582175
-0.00584281
-0.00586149
-0.0058778
-0.00589176
-0.00590337
-0.00591265
-0.0059196
-0.00592424
-0.00592655
-0.00241513
-0.0024847
-0.00255432
-0.00262694
-0.0027034
-0.00278323
-0.00286618
-0.00295205
-0.00304057
-0.00313146
-0.00322443
-0.00331917
-0.00341537
-0.00351271
-0.00361086
-0.00370953
-0.00380839
-0.00390714
-0.0040055
-0.00410319
-0.00419995
-0.00429554
-0.00438974
-0.00448235
-0.00457318
-0.00466206
-0.00474886
-0.00483344
-0.00491569
-0.00499551
-0.00507284
-0.00514761
-0.00521976
-0.00528925
-0.00535606
-0.00542016
-0.00548155
-0.00554022
-0.00559616
-0.0056494
-0.00569993
-0.00574777
-0.00579294
-0.00583545
-0.00587532
-0.00591258
-0.00594724
-0.00597932
-0.00600885
-0.00603585
-0.00606032
-0.0060823
-0.00610179
-0.00611881
-0.00613338
-0.0061455
-0.00615519
-0.00616244
-0.00616728
-0.00616969
-0.00238386
-0.00235519
-0.00232469
-0.00229616
-0.00226892
-0.00224256
-0.00221713
-0.00219266
-0.00216918
-0.0021467
-0.00212521
-0.00210474
-0.0020853
-0.00206688
-0.0020495
-0.00203317
-0.0020179
-0.00200368
-0.00199054
-0.00197847
-0.00196748
-0.00195757
-0.00194876
-0.00194104
-0.00193441
-0.00192888
-0.00192446
-0.00192114
-0.00191893
-0.00191782
)
;
}
}
// ************************************************************************* //
| |
b8ba043b312d968b2a84238dc28c856229ab0039 | 12740b4fc87c22e78541d2f2be4a4318bc74a4d8 | /sensor_startup/include/sensor_startup/imu_reader.h | 55b11b9f597c8e22acaa8e627dff1d4b2e10461d | [] | no_license | glhwork/renov_robot | bd279cfb35c8cbc3d56ca31e1424408e84e1d21a | 527ad754a62361b325a8adc8debc92a5b9cc8ba2 | refs/heads/master | 2020-05-17T07:55:10.497457 | 2019-08-25T03:18:39 | 2019-08-25T03:18:39 | 183,591,045 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,847 | h | imu_reader.h | #ifndef IMU_READER_H
#define IMU_READER_H
#include <string>
#include <sstream>
#include <eigen3/Eigen/Dense>
#include "ros/ros.h"
#include "sensor_msgs/Imu.h"
#include "serial/serial.h"
// considering neccessity of null drift compensation
namespace mobile_base {
struct ImuCommand {
uint8_t OUTPUT_FREQUENCY_00HZ[6] = {0x68, 0x05, 0x00, 0x0c, 0x00, 0x11};
uint8_t OUTPUT_FREQUENCY_05HZ[6] = {0x68, 0x05, 0x00, 0x0c, 0x00, 0x12};
uint8_t OUTPUT_FREQUENCY_15HZ[6] = {0x68, 0x05, 0x00, 0x0c, 0x00, 0x13};
uint8_t OUTPUT_FREQUENCY_25HZ[6] = {0x68, 0x05, 0x00, 0x0c, 0x03, 0x14};
uint8_t OUTPUT_FREQUENCY_35HZ[6] = {0x68, 0x05, 0x00, 0x0c, 0x00, 0x15};
uint8_t OUTPUT_FREQUENCY_50HZ[6] = {0x68, 0x05, 0x00, 0x0c, 0x00, 0x16};
uint8_t OUTPUT_FREQUENCY_100HZ[6] = {0x68, 0x05, 0x00, 0x0c, 0x00, 0x17};
uint8_t ASK_FOR_DATA[5] = {0x68, 0x04, 0x00, 0x04, 0x08};
uint8_t BAUDRATE_9600[6] = {0x68, 0x05, 0x00, 0x0b, 0x02, 0x12};
uint8_t BAUDRATE_19200[6] = {0x68, 0x05, 0x00, 0x0b, 0x02, 0x13};
uint8_t BAUDRATE_38400[6] = {0x68, 0x05, 0x00, 0x0b, 0x02, 0x14};
uint8_t BAUDRATE_115200[6] = {0x68, 0x05, 0x00, 0x0b, 0x02, 0x15};
uint8_t RESET_EULER_ANGLE[5] = {0x68, 0x04, 0x00, 0x28, 0x0c};
}; // struct ImuCommand
class ImuReader {
public:
ImuReader();
~ImuReader() {}
void SerialInit();
void ParamInit();
void Setup();
void ReadData();
void DataParser(const std::vector<uint8_t>& data);
int Converter(const uint8_t a, const uint8_t b, const uint8_t c);
private:
/* PARAMETERS */
std::string port_id;
int baud_rate;
std::string imu_frame_id;
std::string imu_pub_topic;
bool use_request;
int output_freq;
ImuCommand cmd;
serial::Serial imu_ser;
ros::NodeHandle n_private;
ros::NodeHandle nh;
ros::Publisher imu_pub;
}; // class ImuReader
} // namespace mobile_base
#endif
|
5ed83e906b7e7489e49006a0f2f89504569fdaca | dca0414cbab3ed7b62131cc56f4e787751592d85 | /SimpleObjectDrawLib/IDrawableObjBase.cpp | 990848f253b7bb06c91bde0cc0bb3b3cdaf2ec8f | [
"BSD-2-Clause"
] | permissive | HiroakiIMAI/SimpleObjectDrawingLibrary | 2ba853910b10391de995fa8a0e8ed474562a5d24 | 28c77d13c3d0ff7665a6a9812700ce327de400df | refs/heads/master | 2023-06-07T22:11:17.002803 | 2021-01-28T15:07:04 | 2021-01-28T15:07:04 | 315,174,078 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 897 | cpp | IDrawableObjBase.cpp | #include "include/IDrawableObjBase.h"
namespace SmplObjDrwLib {
namespace color4fv {
const float LLGRAY[4] = { 0.9, 0.9, 0.9, 1.0 };
const float LGRAY[4] = { 0.8, 0.8, 0.8, 1.0 };
const float GRAY[4] = { 0.5, 0.5, 0.5, 1.0 };
const float DGRAY[4] = { 0.2, 0.2, 0.2, 1.0 };
const float DDGRAY[4] = { 0.1, 0.1, 0.1, 1.0 };
const float BLACK[4] = { 0.0, 0.0, 0.0, 1.0 };
const float WHITE[4] = { 1.0, 1.0, 1.0, 1.0 };
const float RED[4] = { 0.0, 0.0, 1.0, 1.0 };
const float GREEN[4] = { 0.0, 0.0, 1.0, 1.0 };
const float BLUE[4] = { 0.0, 0.0, 1.0, 1.0 };
}
}
void SmplObjDrwLib::copyColor4fv(const float src[4], float* dst)
{
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
dst[3] = src[3];
}
using namespace SmplObjDrwLib;
IDrawableObjBase::IDrawableObjBase(std::string)
: ISodlObjBase(name)
, visible(true)
{
}
IDrawableObjBase::~IDrawableObjBase()
{
}
|
d95d7f2bbd209fc767d7b88f5304fa9002427e31 | 990a27d854cffc226ed54a7c0a2c4207a04dbb95 | /scenegame.h | 4b7f1a0b7c8bc0ea3e01cbf8a13f3907cbb8603e | [] | no_license | AndreyKoshlan/MinesweeperBattleRoyale | ee37443e4f89dc165216b28d6e35843f56e92387 | 8d4084ad08175087cd0a4be59960b9b9f36b0820 | refs/heads/main | 2023-05-08T11:13:29.707008 | 2021-05-31T20:49:51 | 2021-05-31T20:49:51 | 372,617,167 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 282 | h | scenegame.h | #ifndef GAMESCENE_H
#define GAMESCENE_H
#include <QGraphicsScene>
#include "client.h"
#include "gamefield.h"
class SceneGame : public QGraphicsScene
{
Q_OBJECT
public:
GameField* field;
SceneGame(Client* client);
private:
Client* client;
};
#endif // GAMESCENE_H
|
59bdd33544125d09c6fd818bb9483f1daefcd055 | 16a95d35f44a9ee90aa3d2faaa3808931b7c008e | /Thi/thi thu 7/hihi/source.cpp | 1e44938356500f8581dbb31bfc912bf25cd2eae6 | [] | no_license | hoangtuyenblogger/Phuong-Phap-Lap-Trinh-Huong-Doi-Tuong | 690e1ff65f98e83bd032bd355bd060614042daf2 | 53a742c122a22b0838ecb3da04749a0c0a324ab1 | refs/heads/master | 2022-12-18T13:04:14.578932 | 2020-09-17T09:31:51 | 2020-09-17T09:31:51 | 233,080,281 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,037 | cpp | source.cpp | #include <iostream>
#include<string>
using namespace std;
#include"map.h"
/*------- lop nguoi ----------------*/
nguoi::nguoi()
{
ten="";
ngaysinh="";
}
nguoi::nguoi(string _ten, string _ngaysinh)
{
ten = _ten;
ngaysinh = _ngaysinh;
}
void nguoi::nhap()
{
cout<<"Nhap ho ten : ";
getline(cin,ten);
cout<<"Nhap ngay sinh (dd/mm/yyyy) : ";
getline(cin,ngaysinh);
}
void nguoi::xuat()
{
cout<<"Ho ten : "<<ten<<endl;
cout<<"Ngay sinh : "<<ngaysinh<<endl;
}
float nguoi::chieu_cao_trung_binh()
{
return 165.6;
}
/*------ lop sinh vien -------*/
sinhvien::sinhvien() : nguoi()
{
mssv="00000000";
lop="0000";
}
sinhvien::sinhvien(string _ten, string _diachi, string _mssv, string _lop) : nguoi(_ten, _diachi)
{
mssv = _mssv;
lop = _lop;
}
void sinhvien::nhap()
{
nguoi::nhap();
cout<<"Nhap MSSV : ";
getline(cin,mssv);
cout<<"Nhap ten lop : ";
getline(cin,lop);
for(int i=0;i<3;i++)
{
cout<<"Nhap diem hoc phan "<<i+1<<" : ";
cin>>ds_hoc_phan[i];
}
diem_tb();
}
float sinhvien::diem_tb()
{
return (ds_hoc_phan[0]+ds_hoc_phan[1]+ds_hoc_phan[2])/3.0;
}
void sinhvien::xuat()
{
nguoi::xuat();
cout<<"MSSV: "<<mssv<<endl;
cout<<"Lop: "<<lop<<endl;
for(int i=0;i<3;i++)
{
cout<<"Diem hoc phan "<<i+1<<" : ";
cout<<ds_hoc_phan[i]<<endl;
}
cout<<"Diem trung binh hoc phan : "<<diem_tb()<<endl;
}
bool sinhvien::dk_khen_thuong()
{
for(int i=0;i<3;i++)
{
if(diem_tb() > 8 && ds_hoc_phan[i] >= 5)
{
return true;
}
else
{
return false;
}
}
}
float sinhvien::chieu_cao_trung_binh()
{
return nguoi::chieu_cao_trung_binh() + 10;
}
/*---- lop giang vien ----*/
void giangvien::nhap()
{
nguoi::nhap();
cout<<"Nhap MSGV: ";
getline(cin,msgv);
cout<<"Nhap ten khoa: ";
getline(cin,khoa);
cout<<"Nhap so bai bao: ";
cin>>so_bai_bao;
}
void giangvien::xuat()
{
nguoi::xuat();
cout<<"MSGV: "<<msgv<<endl;
cout<<"Khoa : "<<khoa<<endl;
cout<<"So bai bao: "<<so_bai_bao<<endl;
}
bool giangvien::dk_khen_thuong()
{
if(so_bai_bao > 1)
{
return true;
}
else
{
return false;
}
}
|
1de6b0131ed10092ddbfdb6cb919a98357109e2a | 1e611633b703c2a3a4099bb882bfecae7feddb7f | /programs/sumPairs.cpp | a7c2c612f2da72a68e37346e002d92818e3a256b | [] | no_license | namansukhwani/C-CPP-Campus-Practice | 0569b6ff3a6788d2e2e68ff45b59db077c8eb1a3 | c76fa19e7a8b82b9872097198e2598f1183148d4 | refs/heads/master | 2023-06-27T05:11:39.853152 | 2021-07-29T19:53:48 | 2021-07-29T19:53:48 | 383,215,221 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,056 | cpp | sumPairs.cpp | #include <bits/stdc++.h>
using namespace std;
vector<int> SplitString(string s)
{
vector<int> v;
string temp = "";
for (int i = 0; i < s.length(); i++)
{
if (s[i] == ' ')
{
if (temp.length() != 0)
{
v.push_back(stoi(temp));
temp = "";
}
}
else
{
temp.push_back(s[i]);
}
}
if (temp.length() != 0)
{
v.push_back(stoi(temp));
}
return v;
}
void PrintVector(vector<int> v)
{
for (int i = 0; i < v.size(); i++)
{
cout << v[i] << " ";
}
}
int findPairs(vector<int> v,int n){
int i,ans=0;
for(i=0;i<v.size()-1;i++){
for(int j=i+1;j<v.size();j++){
if((v[i]+v[j])==n){
ans+=1;
}
}
}
return ans;
}
int main()
{
int n;
cin>>n;
cin.ignore(256, '\n');
string inputString;
getline(cin, inputString);
vector<int> arr = SplitString(inputString);
cout<<findPairs(arr,n);
} |
9f08cec61feb4673b9c617a719c418826be4e0be | 519ce4b9fbf25e837758c0ad6793ae90ce194341 | /Sudoku c++/Sudoku c++/Sudoku.cpp | de904e9dd37ce469f0e1d8b8e721fa27ad0a4730 | [] | no_license | PhillBenoit/C-Data-Structures-spring- | 98efc95439991e5d5f62c3cf564aa09c9bde5432 | 8607e17eb43abd11230900eb050368298f3f5de2 | refs/heads/master | 2021-01-21T20:07:05.568089 | 2017-05-23T15:47:23 | 2017-05-23T15:47:23 | 92,190,847 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,631 | cpp | Sudoku.cpp | #include "Sudoku.h"
//initializes the board and the possibilites.
//posibilities reresent the boolean posibility of that number being in that location.
//
//If the upper left most is square is blank:
// board[0][0] = 0 and possible[0][0][0-8] all are true
//
//If the upper left most is square is 1:
// board[0][0] = 1 and possible[0][0][0] is true but:
// possible[0][0][1 - 8] are all false because that number is assigned to that square
// possible[1 - 8][0][0] are all false because that row has a 1
// possible[0][1 - 8][0] are all false because that column has a 1
// possible[0-2][0-2][0] are all false because that 3x3 grid has a 1
Sudoku::Sudoku()
{
for (short x = 0; x < size; x++)
{
for (short y = 0; y < size; y++)
{
board[x][y] = 0;
for (short z = 0; z < size; z++)
{
possible[x][y][z] = true;
}
}
}
solved = 0;
}
Sudoku::~Sudoku()
{
}
//Adds the contents of a text file to the board.
void Sudoku::addFile(string inputFile)
{
//creates stream from passed file name
ifstream file(inputFile);
//tests to make sure file was oppened properly
if (file.is_open())
{
//counter for integer characters found in the file
short intCounter = 0;
//will hold a single line of text extracted from the file
string lineOfText;
//loops until end of file or 81 integers are found
while (getline(file, lineOfText) && intCounter < fullGridSize)
{
//steps through the characters of the line of text
for (short step = 0; step < (short)lineOfText.length(); step++)
{
char testChar = lineOfText[step];
//if the character is a digit, add it to the board
if (isdigit(testChar))
{
//skipps adding 0s as they were added when the object was initialized
if (atoi(&testChar) != 0)
{
assignSquare(atoi(&testChar), intCounter / size, intCounter % size);
}
//steps up number of integers found
intCounter++;
}
}
}
//if not enough integers were found, there was an error
if (intCounter > fullGridSize)
{
printf("Not enough integers were found in the text file. (found: %d expected: %d)\n", intCounter, fullGridSize);
}
file.close();
}
else //else flag for improper file oppening
{
printf("Error opening text file.\n");
}
}
//If the upper left most is square is 1:
// board[0][0] = 1 and possible[0][0][0] is true but:
// possible[0][0][1 - 8] are all false because that number is assigned to that square
// possible[1 - 8][0][0] are all false because that row has a 1
// possible[0][1 - 8][0] are all false because that column has a 1
// possible[0-2][0-2][0] are all false because that 3x3 grid has a 1
void Sudoku::assignSquare(short numberToAssign, short x, short y)
{
board[x][y] = numberToAssign;
//if (board[5][6] == 1) printf("found the problem\n");
//decriments to allow proper assignment of matrix values
numberToAssign--;
//makes possibilites fase as per the above rules
//also overwrites the true area as a side effect
for (short counter = 0; counter < size; counter++)
{
possible[x][y][counter] = false;
possible[x][counter][numberToAssign] = false;
possible[counter][y][numberToAssign] = false;
//nifty way of stepping through a 2d object with a linear value
short subGridX = ((x / subGridSize) * subGridSize) + (counter / subGridSize);
short subGridY = ((y / subGridSize) * subGridSize) + (counter % subGridSize);
possible[ subGridX ][ subGridY ][numberToAssign] = false;
}
//Switches the only true statement back on
possible[x][y][numberToAssign] = true;
//steps up count of solved squares
solved++;
}
//formats the board for printing to the screen
void Sudoku::printBoard()
{
//steps through rows
for (short x = 0; x < size; x++)
{
//add blank line every three lines
if (x % subGridSize == 0) printf("\n");
//seps through columns
for (short y = 0; y < size; y++)
{
//add blank space every three columns
if (y % subGridSize == 0) printf(" ");
//print - instead of 0
if (board[x][y] == 0) printf("-");
//print digits
else printf("%d", board[x][y]);
}
//new line
printf("\n");
}
//new line when done
printf("\n");
}
//converts possible array to text 1s and 0s and saves it to a text file.
//Used for debugging what spaces have been left unsolved.
void Sudoku::savePossible(string outputFile)
{
ofstream file(outputFile);
if (file.is_open())
{
for (short x = 0; x < size; x++)
{
//blank row between sub grids
if (x % subGridSize == 0) file << "\n";
for (short y = 0; y < size; y++)
{
//extra space between sub grids
if (y % subGridSize == 0) file << " ";
for (short z = 0; z < size; z++)
{
//converts boolean to 1 or 0
if (possible[x][y][z]) file << z+1;
else file << "-";
}
//space between represented squares
file << " ";
}
//new line at the end of every row
file << "\n";
}
file.close();
}
else
{
printf("Error opening output file.\n");
}
}
void Sudoku::clear()
{
for (short x = 0; x < size; x++)
{
for (short y = 0; y < size; y++)
{
board[x][y] = 0;
for (short z = 0; z < size; z++)
{
possible[x][y][z] = true;
}
}
}
solved = 0;
}
bool Sudoku::isValid()
{
for (short x = 0; x < size; x++)
{
for (short y = 0; y < size; y++)
{
short s = findOnlyPossible(possible[x][y]);
if ( s > size)
{
return false;
}
}
}
return true;
}
void Sudoku::solve()
{
//used to see how many new squares were solved between loops
short solved;
do
{
//saves the current number of solved squares to see how many
//new squares were solved after the running the tests
solved = this->solved;
onlyRemaining();
onlyPossibleRow();
onlyPossibleColumn();
onlyPossibleSubGrid();
//if nothing was found, search for pairs
//if (this->solved == solved) pairSearch();
//displays the number added through each loop
printf("Added %d\n", this->solved - solved);
//ends if no new solutions are found or the board has been filled
} while (this->solved != solved && this->solved < fullGridSize);
if (this->solved == fullGridSize) printf("The board was completed.\n");
//saves possible for debugging if the board wasn't finished
else
{
printf("The board was not completed.\n");
}
}
//Checks a boolean array to see if only 1 value is true.
//Returns the value or 9 if muliple or 10 if 0 values are found.
short Sudoku::findOnlyPossible(bool possible[])
{
short returnValue = size + 1;
for (short step = 0; step < size; step++)
{
if (possible[step] && returnValue < size)
{
step = size;
returnValue = size;
}
if (possible[step] && returnValue > size) returnValue = step;
}
return returnValue;
}
//steps through the board and tests each 0 square for only 1 possible solution
void Sudoku::onlyRemaining()
{
for (short x = 0; x < size; x++)
{
for (short y = 0; y < size; y++)
{
if (board[x][y] == 0)
{
short found = findOnlyPossible(possible[x][y]);
if (found < size) assignSquare(found + 1, x, y);
}
}
}
}
//tests each row to see if each value is only possible in one place
void Sudoku::onlyPossibleRow()
{
bool searchArray[size];
for (short row = 0; row < size; row++)
{
for (short value = 0; value < size; value++)
{
//assigns search array for passing to findOnlyPossible
for (short step = 0; step < size; step++)
searchArray[step] = possible[row][step][value];
short foundColumn = findOnlyPossible(searchArray);
//assigns the found square if one was found
//and it has a value of 0 on the board
if (foundColumn < size && board[row][foundColumn] == 0)
assignSquare(value + 1, row, foundColumn);
}
}
}
//tests each column to see if each value is only possible in one place
void Sudoku::onlyPossibleColumn()
{
bool searchArray[size];
for (short column = 0; column < size; column++)
{
for (short value = 0; value < size; value++)
{
//assigns search array for passing to findOnlyPossible
for (short step = 0; step < size; step++)
searchArray[step] = possible[step][column][value];
short foundRow = findOnlyPossible(searchArray);
//assigns the found square if one was found
//and it has a value of 0 on the board
if (foundRow < size && board[foundRow][column] == 0)
assignSquare(value + 1, foundRow, column);
}
}
}
//tests each sub grid to see if each value is only possible in one place
void Sudoku::onlyPossibleSubGrid()
{
bool searchArray[size];
for (short subGridXCounter = 0; subGridXCounter < subGridSize; subGridXCounter++)
{
for (short subGridYCounter = 0; subGridYCounter < subGridSize; subGridYCounter++)
{
for (short value = 0; value < size; value++)
{
short subGridX;
short subGridY;
//assigns search array for passing to findOnlyPossible
for (short step = 0; step < size; step++)
{
subGridX = ((subGridXCounter * subGridSize) + (step / subGridSize));
subGridY = ((subGridYCounter * subGridSize) + (step % subGridSize));
searchArray[step] = possible[subGridX][subGridY][value];
}
short foundValue = findOnlyPossible(searchArray);
subGridX = ((subGridXCounter * subGridSize) + (foundValue / subGridSize));
subGridY = ((subGridYCounter * subGridSize) + (foundValue % subGridSize));
//assigns the found square if one was found
//and it has a value of 0 on the board
if (foundValue < size && board[subGridX][subGridY] == 0)
assignSquare(value + 1, subGridX, subGridY);
}
}
}
}
void Sudoku::pairSearch()
{
//An array of pointers to lists with the possibilites for each square.
//Lists contain a count used for finding pairs of matched sets
PossibleList * linkedPossible[size][size];
for (short x = 0; x < size; x++)
{
for (short y = 0; y < size; y++)
{
linkedPossible[x][y] = new PossibleList();
if (board[x][y] == 0) linkedPossible[x][y]->addList(possible[x][y], size);
}
}
if (!rowPairSearch(linkedPossible))
if (!columnPairSearch(linkedPossible))
bruteForceMode(linkedPossible);
}
bool Sudoku::rowPairSearch(PossibleList * searchBoard[size][size])
{
for (int x = 0; x < size; x++)
{
for (int y = 0; y < size - 1; y++)
{
if (searchBoard[x][y]->size == 2)
{
for (int restOfY = y + 1; restOfY < size; restOfY++)
{
if (searchBoard[x][restOfY]->size == 2)
{
PossibleList * testList = new PossibleList();
short ommited = testList->mergePair(searchBoard[x][y], searchBoard[x][restOfY]);
if (testList->size == 3)
{
for (short threeStep = 0; threeStep < size; threeStep++)
{
if (searchBoard[x][threeStep]->size == 3 &&
searchBoard[x][threeStep]->head->value == testList->head->value &&
searchBoard[x][threeStep]->head->next->value == testList->head->next->value &&
searchBoard[x][threeStep]->tail->value == testList->tail->value)
{
assignSquare(ommited + 1, x, threeStep + 1);
assignFromPair(x, y, ommited, searchBoard[x][y]);
assignFromPair(x, restOfY, ommited, searchBoard[x][restOfY]);
return true;
}//end compare value if
}//end threeStep for loop
}//end 3 in merged list if
}//end find second set if
}//end rest of y loop
}//end find first set if
}//end y
}//end x
return false;
}//end method
bool Sudoku::columnPairSearch(PossibleList * searchBoard[size][size])
{
for (int y = 0; y < size; y++)
{
for (int x = 0; x < size - 1; x++)
{
if (searchBoard[x][y]->size == 2)
{
for (int restOfX = x + 1; restOfX < size; restOfX++)
{
if (searchBoard[restOfX][y]->size == 2)
{
PossibleList * testList = new PossibleList();
short ommited = testList->mergePair(searchBoard[x][y], searchBoard[restOfX][y]);
if (testList->size == 3)
{
for (short threeStep = 0; threeStep < size; threeStep++)
{
if (searchBoard[threeStep][y]->size == 3 &&
searchBoard[threeStep][y]->head->value == testList->head->value &&
searchBoard[threeStep][y]->head->next->value == testList->head->next->value &&
searchBoard[threeStep][y]->tail->value == testList->tail->value)
{
assignSquare(ommited + 1, threeStep, y);
assignFromPair(x, y, ommited, searchBoard[x][y]);
assignFromPair(restOfX, y, ommited, searchBoard[threeStep][y]);
return true;
}//end compare value if
}//end threeStep for loop
}//end 3 in merged list if
}//end find second set if
}//end rest of x loop
}//end find first set if
}//end x
}//end y
return false;
}
void Sudoku::assignFromPair(short x, short y, short omit, PossibleList * pair)
{
short value = (pair->head->value == omit) ? pair->head->next->value : pair->head->value;
assignSquare(value + 1, x, y);
}
void Sudoku::bruteForceMode(PossibleList * searchBoard[size][size])
{
}
BruteForceSolver::BruteForceSolver()
{
startingBoard.clear();
testBoard.clear();
solution = new GuessList;
counter = 0;
}
void BruteForceSolver::copyBoard(Sudoku * destination, Sudoku source)
{
destination->clear();
for (short x = 0; x < source.size; x++)
{
for (short y = 0; y < source.size; y++)
{
if (source.board[x][y] != 0) destination->assignSquare(source.board[x][y], x, y);
}
}
}
void BruteForceSolver::start()
{
if (testBoard.solved != testBoard.fullGridSize)
{
if (testBoard.isValid())
{
GuessList list = GuessList();
findLeastPossible(&list, testBoard);
while (list.top != nullptr)
{
copyBoard(&testBoard, startingBoard);
solution->push(*list.top);
Guess * currentGuesses = solution->top;
while (currentGuesses != nullptr)
{
testBoard.assignSquare(currentGuesses->guess + 1, currentGuesses->x, currentGuesses->y);
currentGuesses = currentGuesses->next;
}
testBoard.solve();
start();
string saveBoard = "possible";
saveBoard += to_string(counter) + ".txt";
//testBoard.savePossible(saveBoard);
testBoard.printBoard();
counter++;
testBoard.printBoard();
if (testBoard.solved != testBoard.fullGridSize) solution->pop();
if (testBoard.solved == testBoard.fullGridSize) list.top = nullptr;
list.pop();
}
}
}
}
void BruteForceSolver::findLeastPossible(GuessList * list, Sudoku s)
{
PossibleList * linkedPossible[s.size][s.size];
short leastPossible = s.size + 1;
for (short x = 0; x < s.size; x++)
{
for (short y = 0; y < s.size; y++)
{
linkedPossible[x][y] = new PossibleList();
if (s.board[x][y] == 0) linkedPossible[x][y]->addList(s.possible[x][y], s.size);
if (linkedPossible[x][y]->size >= 2 && linkedPossible[x][y]->size < leastPossible)
leastPossible = linkedPossible[x][y]->size;
}
}
for (short x = 0; x < s.size; x++)
{
for (short y = 0; y < s.size; y++)
{
if (leastPossible == linkedPossible[x][y]->size)
{
PossibleNode * cursor = linkedPossible[x][y]->head;
while (cursor != nullptr)
{
list->push(cursor->value, x, y);
printf("Value : %d\nx: %d\ny: %d\n\n", cursor->value, x, y);
cursor = cursor->next;
}
}
}
}
}
Guess::Guess()
{
x = 0;
y = 0;
guess = 0;
next = nullptr;
}
GuessList::GuessList()
{
top = nullptr;
}
void GuessList::push(short guess, short x, short y)
{
Guess * newGuess = new Guess();
newGuess->x = x;
newGuess->y = y;
newGuess->guess = guess;
newGuess->next = top;
top = newGuess;
}
void GuessList::push(Guess passedGuess)
{
push(passedGuess.guess, passedGuess.x, passedGuess.y);
}
void GuessList::pop()
{
if (top != nullptr) top = top->next;
} |
a35497f59067e056c3aaf0b2e5103dbf807554d2 | 1a2a6cae61a9ac654609b4c3517242e0b01a8301 | /source/persistence-example/simu-code/cpp/source/ModelParameters.hpp | 6f7ccee161bda4f1f297a0b456df49e7324aa281 | [
"MIT"
] | permissive | ImperialCollegeLondon/coli-noise-and-growth | c587c473443bbfcf34e3dbfad444f0a8d7a9447b | 1b4c9c211c865a54948a4927ea69b64c5ef09453 | refs/heads/master | 2021-01-01T20:36:06.703708 | 2017-07-31T13:24:11 | 2017-07-31T13:24:11 | 98,890,230 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 955 | hpp | ModelParameters.hpp | /*
__ Francois Bertaux, Imperial College
__ f.bertaux@imperial.ac.uk
__ December 2015
*/
#ifndef MODEL_PARAMETERS
#define MODEL_PARAMETERS
#include "libs/nr3.h"
struct ModelParameters
{
Int mf_NumSpecies;
Int mf_NumReacs;
VecDoub mf_ReacRates;
ModelParameters();
// for stochastic gene expression
inline void set_km(Doub km) { mf_ReacRates[0] = km; }
inline void set_rm(Doub rm) { mf_ReacRates[1] = rm; }
inline void set_kp(Doub kp) { mf_ReacRates[2] = kp; }
inline void set_rp(Doub rp) { mf_ReacRates[3] = rp; }
// for birth and division size (LNM)
Doub lnm_a;
Doub lnm_b;
Doub lnm_sigma_1;
Doub lnm_sigma_2;
// for growth and toxin inhibition
Doub regulation_conc;
Doub regulation_hill;
Doub mu_max;
Doub alpha_max;
Doub alpha_CV;
// for dependent GE
Doub km_0;
Doub km_per_size;
Doub km_per_alpha;
Doub kp_0;
Doub kp_per_size;
};
#endif
|
892d8df4aaefea860d082a359ed8f6fa5c48c6a5 | f855ea48bd08d76e204d09cb9a66d00ec14f49a7 | /DP/Solve_Sellproblem.cpp | 2aa2b34030d63d944df405bc363d1d842108b641 | [] | no_license | Akash-verma998/CPP | 087b6bb3f59f1125863f950e05df932739dbffb9 | 789b522d1d137cb776a4d9e22e51fb417589b378 | refs/heads/main | 2023-02-15T22:22:36.299089 | 2021-01-18T06:59:04 | 2021-01-18T06:59:04 | 330,578,219 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 480 | cpp | Solve_Sellproblem.cpp | #include<iostream>
using namespace std;
long long solve(int n, int x, int y, int z)
{
int *dp = new int[n+1];
//bottom up DP
dp[0]=0;
dp[1]=0;
for(int i=2;i<=n;i++)
{
if(i%2==0)
{
dp[i] = min(dp[i/2]+x,dp[i-1]+y);
}
else
{
dp[i] = min(dp[i-1]+y,dp[(i+1)/2]+x+z);
}
}
return dp[n];
}
int main()
{
int n,x,y,z;
cin>>n>>x>>y>>z;
cout<<solve(n,x,y,z);
return 0;
}
|
155b9307249ac42b6b3e008954ceb0f78b55d346 | 2426c94bbfc4d3d28724f739e085f9408185d0c3 | /Apps/Tools/Outlook/EditManager.cpp | b11e1bb683842f431947fff040282f3b3c285f9f | [] | no_license | formist/LinkMe | 16fda499ed4554bb44e6b602a68e487bd2db05a6 | 0e693c0cd0bcc286567061228df495f311fde26a | refs/heads/master | 2020-04-13T19:32:07.378168 | 2013-07-24T04:07:01 | 2013-07-24T04:07:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,988 | cpp | EditManager.cpp | #include "StdAfx.h"
#include "EditManager.h"
HWND EditManager::m_hWindow = NULL;
HHOOK EditManager::m_hHook = NULL;
EditManager::EditControlList EditManager::m_editControls;
EditManager::EditManager()
{
// Create the edit window and install the hook.
CreateEditWindow();
InstallHook();
}
void EditManager::Shutdown()
{
// Delete all control states.
for (EditControlList::iterator it = m_editControls.begin(); it != m_editControls.end(); ++it)
delete (*it);
m_editControls.clear();
// Uninstall the hook and destroy the edit window.
UninstallHook();
DestroyEditWindow();
}
void EditManager::Add(EditControl* pEditControl)
{
m_editControls.push_back(pEditControl);
}
EditControl* EditManager::GetEditControl(HWND hWnd)
{
// Iterate until found.
for (EditControlList::iterator it = m_editControls.begin(); it != m_editControls.end(); ++it)
{
if ((*it)->GetWindowHandle() == hWnd)
return *it;
}
return NULL;
}
void EditManager::CreateEditWindow()
{
// Register a new class.
const wchar_t className[] = L"LinkMeEditWindow";
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = 0;
wndclass.lpfnWndProc = &EditWndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = _AtlModule.GetResourceInstance();
wndclass.hIcon = NULL;
wndclass.hCursor = NULL;
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = className;
wndclass.hIconSm = NULL;
::RegisterClassEx(&wndclass);
// Create a window from that class.
m_hWindow = ::CreateWindow(className, L"LinkMeAddin", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 200, NULL, NULL, _AtlModule.GetResourceInstance(), NULL);
}
void EditManager::DestroyEditWindow()
{
if (m_hWindow != NULL)
{
::DestroyWindow(m_hWindow);
m_hWindow = NULL;
}
}
void EditManager::InstallHook()
{
m_hHook = ::SetWindowsHookEx(WH_CBT, (HOOKPROC) HookProc, 0, GetCurrentThreadId());
}
void EditManager::UninstallHook()
{
if (m_hHook != NULL)
{
::UnhookWindowsHookEx(m_hHook);
m_hHook = NULL;
}
}
LRESULT CALLBACK EditManager::HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// Look for the creation of controls.
if (nCode == HCBT_CREATEWND)
{
HWND hWnd = (HWND) wParam;
// Grab the class name.
LPCBT_CREATEWND cw = (LPCBT_CREATEWND) lParam;
LPCREATESTRUCT cs = (LPCREATESTRUCT) cw->lpcs;
LPCWSTR className = cs->lpszClass;
WCHAR temp[1024];
if (!HIWORD(cs->lpszClass))
{
if (::GetClassName(hWnd, temp, sizeof(temp) / sizeof(WCHAR) -1 ) == 0)
className = NULL;
else
className = temp;
}
if (className != NULL)
{
// Interested in RichEdit20W controls.
if (wcscmp(className, L"RichEdit20W") == 0)
{
// Call the next handler.
LRESULT result = ::CallNextHookEx(m_hHook, nCode, wParam, lParam);
// Post the message to the edit state window.
::PostMessage(m_hWindow, RICHEDIT20W_CREATEWND, (WPARAM) hWnd, 0);
return result;
}
}
}
// Call the next handler.
return ::CallNextHookEx(m_hHook, nCode, wParam, lParam);
}
LRESULT CALLBACK EditManager::EditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// Look for the create of the edit control.
switch (uMsg)
{
case RICHEDIT20W_CREATEWND:
{
NewRichEdit20W((HWND) wParam);
return 0;
}
}
return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
}
void EditManager::NewRichEdit20W(HWND hWnd)
{
// Check if it belongs to one of the edit controls.
for (EditControlList::iterator it = m_editControls.begin(); it != m_editControls.end(); ++it)
{
EditControl* pEditControl = *it;
// If it belongs to any of the controls then hook it.
if (pEditControl->ContainsWindow(hWnd))
{
pEditControl->HookWindow(hWnd);
break;
}
}
}
|
810b620b537e8be8b6c2be2e71a2976726cd2d84 | e94caa5e0894eb25ff09ad75aa104e484d9f0582 | /data/l7/mp2/ggg/B/cc-pVTZ/restart.cc | 0c65e1eb60afe0f556d2912931e998cb37b69b75 | [] | no_license | bdnguye2/divergence_mbpt_noncovalent | d74e5d755497509026e4ac0213ed66f3ca296908 | f29b8c75ba2f1c281a9b81979d2a66d2fd48e09c | refs/heads/master | 2022-04-14T14:09:08.951134 | 2020-04-04T10:49:03 | 2020-04-04T10:49:03 | 240,377,466 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 444 | cc | restart.cc | $chkbas= 104741.359060184
$nucrep= 1842.11678146796
$chkaux= 503085253.113835
$chkupro= 1.00000000000000
$chkipro= 2.00000000000000
$chklasrep= 1.00000000000000
$chkisy6= 4.00000000000000
$chkmos= 273.882919964228
$chkCCVPQ_ISQR= 5011.78353906812
$chkbqia= 78.6963342644115
$chkr0_MP2= 0.00000000000000
$energy_MP2= -1083.14257944915
$sccss= 1.00000000000000
$sccos= 1.00000000000000
$end
|
40cf61de40b3403f6ce973690f001c560af07899 | da478bc774b74005370117f192ef7e9f81d4b8fa | /Final/backtracking/subset_back.cpp | b5833426254034c2085909ff6be0e829f342db42 | [] | no_license | Utlesh/code | 20c8b63dcec825f144d780e2f2d9b0f22191986f | 029d7030f775076be12a65564cbe80373d6e3ac0 | refs/heads/master | 2020-05-02T05:41:06.632614 | 2015-07-30T10:18:02 | 2015-07-30T10:18:02 | 39,931,679 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,045 | cpp | subset_back.cpp | #include<iostream>
using namespace std;
#include<algorithm>
void printsubset(int arr[],int t_size)
{
for(int i=0;i<t_size;++i)
cout<<arr[i]<<" ";
cout<<"\n";
}
void backtrack(int weights[],int s_size,int arr[],int t_size,int sum,int itr,int target)
{
if(sum==target)
{
printsubset(arr,t_size);
return ;
}
else
{
if(itr<s_size&&sum+weights[itr]<=target)
{
for(int i=itr;i<s_size;++i)
{
arr[t_size] = weights[i] ;
if(sum+weights[i]<=target)
backtrack(weights,s_size,arr,t_size+1,sum+weights[i],i+1,target);
}
}
}
}
void print_subset(int weights[],int s_size,int target)
{
int *arr = new int[s_size];
int total_sum = 0;
sort(weights,weights + s_size);
for(int i=0;i<s_size;++i)
total_sum += weights[i];
if(total_sum>=weights[0]&&total_sum>=target)
backtrack(weights,s_size,arr,0,0,0,target);
}
int main()
{
int weights[] = {15, 22, 14, 26, 32, 9, 16, 8};
int target = 53;
print_subset(weights,8,target);
return 0;
}
|
104ec371a7743a9c6a1a080063daf110c2481920 | 9eaf4a76cfe18e8e5a84e75d202d8eef8d2493cd | /src/Settings.cpp | c642544bff3481df1bb0cf74fe83ede88270c530 | [
"MIT"
] | permissive | StianAndreOlsen/ColorVario | 23e0b57c0a0608b6bdf6eef3427e3f7b6f179483 | 2c2b34c06f26d6fe29e4be294b554d3cfd8a8b71 | refs/heads/master | 2023-04-07T17:15:46.539612 | 2023-03-25T07:01:49 | 2023-03-25T07:01:49 | 253,718,945 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,276 | cpp | Settings.cpp | #include "Settings.h"
#include "dlog.h"
#include "StringFunctions.h"
#include <fstream>
bool Kystsoft::Settings::load(const std::string& fileName)
{
std::ifstream is(fileName);
if (!is.is_open() || !load(is))
{
dlog(DLOG_ERROR) << "Unable to load settings from \"" << fileName << "\"";
return false;
}
// dlog(DLOG_DEBUG) << "Settings loaded from \"" << fileName << "\"";
return true;
}
bool Kystsoft::Settings::load(std::istream& is)
{
std::ostringstream os;
removeComments(is, os);
std::istringstream iss(os.str());
return loadValues(iss) > 0;
}
void Kystsoft::Settings::removeComments(std::istream& is, std::ostream& os)
{
char c = 0;
while (is.get(c))
{
if (c == ';' || c == '#')
{
// bypass line
while (is.get(c))
if (c == '\n')
{ os << c; break; }
}
else
{
os << c;
}
}
}
bool Kystsoft::Settings::hasValue(const std::string& key) const
{
return valueMap.find(key) != valueMap.end();
}
std::string Kystsoft::Settings::value(const std::string& key) const
{
auto i = valueMap.find(key);
if (i == valueMap.end())
return std::string();
return i->second;
}
std::vector<std::string> Kystsoft::Settings::values(const std::string& key) const
{
std::vector<std::string> values;
auto range = valueMap.equal_range(key);
for (auto i = range.first; i != range.second; ++i)
values.push_back(i->second);
return values;
}
size_t Kystsoft::Settings::loadValues(std::istream& is)
{
size_t initialSize = valueMap.size();
std::string section;
std::string line;
while (std::getline(is, line))
{
// [section]
{
std::istringstream iss(line);
char c = 0;
if (iss >> c && c == '[' && std::getline(iss, section, ']'))
{
section = trim(section);
continue; // read next line
}
}
// name=value
{
std::istringstream iss(line);
std::string name;
if (std::getline(iss, name, '='))
{
name = trim(name);
if (!name.empty())
{
// empty values are allowed
std::string value;
std::getline(iss, value);
value = unquote(trim(value));
valueMap.insert(std::make_pair(section + '.' + name, value));
}
}
}
}
return valueMap.size() - initialSize;
}
|
a439eae1a736747e7156bb99cd3b527c8183a275 | 950ec9dd55dc32975c46b3b61b98434edc9b2d0c | /AICore_Files/State, Message, and Entity Systems/State.h | 1099033195d1e2381866b4039a5a8d1b8a0c08a1 | [] | no_license | aSaul2006/GameEngineProject | a99bb0f73d74388f99758c84ca1215093eba972f | 3b3c5ada569aa1fc86383f90a078ecd439247ad1 | refs/heads/master | 2021-01-10T14:41:14.269844 | 2013-03-04T15:58:13 | 2013-03-04T15:58:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,299 | h | State.h | /************************************************************************
* Program Name: State.h *
* Name: Thomas Culp *
* Date: January 25, 2013 *
* Description: Header file for State classes *
* Controls what the AI does in each state *
* All state sub classes use singleton design *
* Update: *
* *
************************************************************************/
#pragma once
//-----------------------------------------------------------------------
// Predeclaration classes
//-----------------------------------------------------------------------
struct Message;
class PlayerEntity;
class TemplateEntity;
/////////////////////////////////////////////////////
// NOTE: Add a predeclaration for each ENTITY_TYPE //
/////////////////////////////////////////////////////
//-----------------------------------------------------------------------
// Template class
//-----------------------------------------------------------------------
template <class entity_class>
//-----------------------------------------------------------------------
// State base class
//-----------------------------------------------------------------------
class State
{
public:
bool m_bDelayedMessageDispatched; // stores whether or not a delayed message has been created
// ~State function: default destructor
virtual ~State() {};
// Enter function: runs a set of commands when a state is entered
virtual void Enter(entity_class* Entity) = 0;
// Execute function: runs a set of commands every frame, returns true if entity was deleted/killed during this update call
virtual bool Execute(entity_class* Entity) = 0;
// Exit function: runs a set of commands when a state is exited
virtual void Exit(entity_class* Entity) = 0;
// OnMessage function: runs a set of commands when a message is received
virtual bool OnMessage(entity_class* Entity, const Message& msg) = 0;
};
///////////////////////////////////////////////////////////////////////////////
// NOTE: THESE ARE JUST GENERIC STATES TO USE AS TEMPLATES FOR CUSTOM STATES //
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------
// TemplateEntity initialization state sub class
//-----------------------------------------------------------------------
class TemplateEntity_InitState : public State<TemplateEntity>
{
private:
// TemplateEntity_InitState function: default constructor
TemplateEntity_InitState() {m_bDelayedMessageDispatched = false;};
// TemplateEntity_InitState function: copy constructor
TemplateEntity_InitState(TemplateEntity_InitState const&) {};
// operator= overload so instance can't be copied
TemplateEntity_InitState& operator=(TemplateEntity_InitState const&) {};
static TemplateEntity_InitState* m_pInstance; // static pointer to own class
public:
// Instance function: ensures only a single instance of this class exists
static TemplateEntity_InitState* Instance();
// Enter function: runs a set of commands when a state is entered
virtual void Enter(TemplateEntity* Entity) {};
// Execute function: runs a set of commands every frame, returns true if entity was deleted/killed during this update call
virtual bool Execute(TemplateEntity* Entity);
// Exit function: runs a set of commands when a state is exited
virtual void Exit(TemplateEntity* Entity) {};
// OnMessage function: runs a set of commands when a message is received
virtual bool OnMessage(TemplateEntity* Entity, const Message& msg);
// The only thing the initialization state does is change the state to something else
// The initialization state is useful because the Enter function will not be ran on the first state assigned
// The Enter function isn't commonly used, but it can be helpful
// An example of when the Enter and Exit functions will be useful is for when an entity switches to an attack state
// Upon entering the attack state that entity can draw his weapons and when exiting that state he can sheathe his weapons
};
//-----------------------------------------------------------------------
// TemplateEntity roam state sub class
//-----------------------------------------------------------------------
class TemplateEntity_RoamState : public State<TemplateEntity>
{
private:
// TemplateEntity_RoamState function: default constructor
TemplateEntity_RoamState() {m_bDelayedMessageDispatched = false;};
// TemplateEntity_RoamState function: copy constructor
TemplateEntity_RoamState(TemplateEntity_RoamState const&) {};
// operator= overload so instance can't be copied
TemplateEntity_RoamState& operator=(TemplateEntity_RoamState const&) {};
static TemplateEntity_RoamState* m_pInstance; // static pointer to own class
public:
// Instance function: ensures only a single instance of this class exists
static TemplateEntity_RoamState* Instance();
// Enter function: runs a set of commands when a state is entered
virtual void Enter(TemplateEntity* Entity) {};
// Execute function: runs a set of commands every frame, returns true if entity was deleted/killed during this update call
virtual bool Execute(TemplateEntity* Entity);
// Exit function: runs a set of commands when a state is exited
virtual void Exit(TemplateEntity* Entity) {};
// OnMessage function: runs a set of commands when a message is received
virtual bool OnMessage(TemplateEntity* Entity, const Message& msg);
};
//-----------------------------------------------------------------------
// TemplateEntity attack state sub class
//-----------------------------------------------------------------------
class TemplateEntity_AttackState : public State<TemplateEntity>
{
private:
// TemplateEntity_AttackState function: default constructor
TemplateEntity_AttackState() {m_bDelayedMessageDispatched = false;};
// TemplateEntity_AttackState function: copy constructor
TemplateEntity_AttackState(TemplateEntity_AttackState const&) {};
// operator= overload so instance can't be copied
TemplateEntity_AttackState& operator=(TemplateEntity_AttackState const&) {};
static TemplateEntity_AttackState* m_pInstance; // static pointer to own class
public:
// Instance function: ensures only a single instance of this class exists
static TemplateEntity_AttackState* Instance();
// Enter function: runs a set of commands when a state is entered
virtual void Enter(TemplateEntity* Entity) {};
// Execute function: runs a set of commands every frame, returns true if entity was deleted/killed during this update call
virtual bool Execute(TemplateEntity* Entity);
// Exit function: runs a set of commands when a state is exited
virtual void Exit(TemplateEntity* Entity) {};
// OnMessage function: runs a set of commands when a message is received
virtual bool OnMessage(TemplateEntity* Entity, const Message& msg);
};
//-----------------------------------------------------------------------
// TemplateEntity dead state sub class
//-----------------------------------------------------------------------
class TemplateEntity_DeadState : public State<TemplateEntity>
{
private:
// TemplateEntity_DeadState function: default constructor
TemplateEntity_DeadState() {m_bDelayedMessageDispatched = false;};
// TemplateEntity_DeadState function: copy constructor
TemplateEntity_DeadState(TemplateEntity_DeadState const&) {};
// operator= overload so instance can't be copied
TemplateEntity_DeadState& operator=(TemplateEntity_DeadState const&) {};
static TemplateEntity_DeadState* m_pInstance; // static pointer to own class
public:
// Instance function: ensures only a single instance of this class exists
static TemplateEntity_DeadState* Instance();
// Enter function: runs a set of commands when a state is entered
virtual void Enter(TemplateEntity* Entity) {};
// Execute function: runs a set of commands every frame, returns true if entity was deleted/killed during this update call
virtual bool Execute(TemplateEntity* Entity);
// Exit function: runs a set of commands when a state is exited
virtual void Exit(TemplateEntity* Entity);
// OnMessage function: runs a set of commands when a message is received
virtual bool OnMessage(TemplateEntity* Entity, const Message& msg);
}; |
ca82aa0579bc38ee671eaaf12bb34ed47b372980 | dd3b029e2868974608070ff6843a91b6764bd5a6 | /gpu_demos_pack/demos/face_detection/face_detection.cpp | 223d1a51d5fe3aa7263e4fedc723df37fbca46d2 | [
"BSD-3-Clause"
] | permissive | apavlenko/opencv_extra | 24814328d28cbf276c597296f6b23dd569cecb11 | a68336d2797e92194ca0f846a49202838b1e7ee6 | refs/heads/master | 2021-01-15T18:45:08.272472 | 2013-12-30T07:52:49 | 2013-12-30T07:52:49 | 6,368,394 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,022 | cpp | face_detection.cpp | #include <iostream>
#include <iomanip>
#include <stdexcept>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/gpu/gpu.hpp>
#include "utility.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
enum Method
{
HAAR,
LBP,
METHOD_MAX
};
const char* method_str[] =
{
"HAAR",
"LBP"
};
class App : public BaseApp
{
public:
App();
protected:
void runAppLogic();
void processAppKey(int key);
void printAppHelp();
bool parseAppCmdArgs(int& i, int argc, const char* argv[]);
private:
void displayState(cv::Mat& outImg, double proc_fps, double total_fps);
string haarCascadeName_;
string lbpCascadeName_;
Method method_;
bool useGpu_;
int curSource_;
bool fullscreen_;
bool reloadCascade_;
};
App::App()
{
haarCascadeName_ = "data/face_detection_haar.xml";
lbpCascadeName_ = "data/face_detection_lbp.xml";
method_ = HAAR;
useGpu_ = true;
curSource_ = 0;
fullscreen_ = false;
reloadCascade_ = true;
}
void App::runAppLogic()
{
if (sources_.empty())
{
cout << "Using default frames source... \n" << endl;
sources_.push_back(FrameSource::video("data/face_detection.avi"));
}
CascadeClassifier cascade_cpu;
CascadeClassifier_GPU cascade_gpu;
Mat frame_cpu, gray_cpu, outImg;
GpuMat frame_gpu, gray_gpu, facesBuf_gpu;
vector<Rect> faces;
const string wndName = "Face Detection Demo";
if (fullscreen_)
{
namedWindow(wndName, WINDOW_NORMAL);
setWindowProperty(wndName, WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
setWindowProperty(wndName, WND_PROP_ASPECT_RATIO, CV_WINDOW_FREERATIO);
}
while (isActive())
{
if (reloadCascade_)
{
const string& cascadeName = method_ == HAAR ? haarCascadeName_ : lbpCascadeName_;
cascade_gpu.load(cascadeName);
cascade_cpu.load(cascadeName);
reloadCascade_ = false;
}
const int64 total_start = getTickCount();
sources_[curSource_]->next(frame_cpu);
double proc_fps = 0.0;
if (useGpu_)
{
frame_gpu.upload(frame_cpu);
makeGray(frame_gpu, gray_gpu);
cascade_gpu.visualizeInPlace = false;
cascade_gpu.findLargestObject = false;
const int64 proc_start = getTickCount();
const int detections_num = cascade_gpu.detectMultiScale(gray_gpu, facesBuf_gpu, 1.2, 4);
proc_fps = getTickFrequency() / (getTickCount() - proc_start);
if (detections_num == 0)
faces.clear();
else
{
faces.resize(detections_num);
Mat facesMat(1, detections_num, DataType<Rect>::type, &faces[0]);
facesBuf_gpu.colRange(0, detections_num).download(facesMat);
}
}
else
{
makeGray(frame_cpu, gray_cpu);
const Size minSize = cascade_gpu.getClassifierSize();
const int64 proc_start = getTickCount();
cascade_cpu.detectMultiScale(gray_cpu, faces, 1.2, 4, CV_HAAR_SCALE_IMAGE, minSize);
proc_fps = getTickFrequency() / (getTickCount() - proc_start);
}
frame_cpu.copyTo(outImg);
for (size_t i = 0; i < faces.size(); i++)
rectangle(outImg, faces[i], CV_RGB(0, 255, 0), 3);
const double total_fps = getTickFrequency() / (getTickCount() - total_start);
displayState(outImg, proc_fps, total_fps);
imshow(wndName, outImg);
wait(30);
}
}
void App::displayState(Mat& outImg, double proc_fps, double total_fps)
{
const Scalar fontColorRed = CV_RGB(255, 0, 0);
ostringstream txt;
int i = 0;
txt.str(""); txt << "Source size: " << outImg.cols << 'x' << outImg.rows;
printText(outImg, txt.str(), i++);
txt.str(""); txt << "Method: " << method_str[method_] << (useGpu_ ? " CUDA" : " CPU");
printText(outImg, txt.str(), i++);
txt.str(""); txt << "FPS (FD only): " << fixed << setprecision(1) << proc_fps;
printText(outImg, txt.str(), i++);
txt.str(""); txt << "FPS (total): " << fixed << setprecision(1) << total_fps;
printText(outImg, txt.str(), i++);
printText(outImg, "Space - switch CUDA / CPU mode", i++, fontColorRed);
printText(outImg, "M - switch method", i++, fontColorRed);
if (sources_.size() > 1)
printText(outImg, "N - switch source", i++, fontColorRed);
}
void App::processAppKey(int key)
{
switch (toupper(key & 0xff))
{
case 32 /*space*/:
useGpu_ = !useGpu_;
cout << "Switch mode to " << (useGpu_ ? "CUDA" : "CPU") << endl;
break;
case 'M':
method_ = static_cast<Method>((method_ + 1) % METHOD_MAX);
reloadCascade_ = true;
cout << "Switch method to " << method_str[method_] << endl;
break;
case 'N':
if (sources_.size() > 1)
{
curSource_ = (curSource_ + 1) % sources_.size();
sources_[curSource_]->reset();
cout << "Switch source to " << curSource_ << endl;
}
break;
}
}
void App::printAppHelp()
{
cout << "This sample demonstrates different Face Detection algorithms \n" << endl;
cout << "Usage: demo_face_detection [options] \n" << endl;
cout << "Launch Options: \n"
<< " --fullscreen \n"
<< " Launch in fullscreen mode \n" << endl;
}
bool App::parseAppCmdArgs(int& i, int, const char* argv[])
{
string arg(argv[i]);
if (arg == "--fullscreen")
{
fullscreen_ = true;
return true;
}
return false;
}
RUN_APP(App)
|
faf9c2051c23dbb267e22ab1c0ad3cc180aa2fe5 | dc8ef4c1b5dbf4afbb41d91d517acb53ea3cc5ba | /Hackerearth/TreeQuery.cpp | 251aefbfe1ab259e90e16f2568aa3c6313c3b9e8 | [] | no_license | NavonilDas/Algos | 731960271dc1bc3f097d88a9f67da8e53430e9bc | b9dec1b4c752a8a8db40088558f140c232ae21f2 | refs/heads/master | 2021-05-16T21:57:16.656394 | 2020-09-11T14:07:42 | 2020-09-11T14:07:42 | 250,485,548 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,139 | cpp | TreeQuery.cpp | #include <bits/stdc++.h>
using namespace std;
#define FASTIO \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define ll long long
#define endl '\n'
#define ull long long
#define vi vector<int>
#define mat vector<vector<int>>
/// Still Trying :(
// TODO: LAZY PROPOGATION
void buildTree(mat &adj,mat &tree,vector<bool> &visited,int i){
visited[i] = true;
for(int ne:adj[i]){
if(!visited[ne]){
visited[ne] = true;
tree[i].push_back(ne);
buildTree(adj,tree,visited,ne);
}
}
}
void printLeaf(mat &tree,int i,vi &seg,vi &parent){
if(tree[i].size() == 0){
seg[i] = 1;
}
else{
seg[i] = 1;
for(int ne:tree[i]){
parent[ne] = i;
printLeaf(tree,ne,seg,parent);
seg[i] += seg[ne];
}
}
}
void update(int i,vi &parent,vi &seg,mat &tree){
if(seg[i] == 0){
seg[i] = 1;
for(int ne:tree[i]){
seg[i] += seg[ne];
}
}else
seg[i] = 0;
int p = parent[i];
while(p != -1){
if(seg[p] == 0) return;
seg[p] = 1;
for(int ne:tree[p]){
seg[p] += seg[ne];
}
p = parent[p];
}
}
int main()
{
FASTIO;
#ifdef OFFLINE_EXE
freopen("input.txt","r",stdin);
#endif
int n,q;
cin>>n>>q;
mat adj(n);
int a,b;
for(int i=0;i<n-1;++i){
cin>>a>>b;
adj[a-1].push_back(b-1);
adj[b-1].push_back(a-1);
}
mat tree(n);
vi seg(n,0);
vi parent(n);
vector<bool> visited(n);
buildTree(adj,tree,visited,0);
adj.clear();
visited.clear();
parent[0] = -1;
printLeaf(tree,0,seg,parent);
short typ;
int node;
while(q--){
cin>>typ>>node;
if(typ == 2)
cout<<seg[node-1]<<endl;
else{
update(node-1,parent,seg,tree);
// for(int i:seg)
// cout<<i<<" ";
// cout<<endl;
}
}
// for(int i=0;i<n;++i)
// cout<<parent[i]<<endl;
return 0;
} |
dd28ce8a8728e4998bf4dd54f4824c5b31a0f94d | 2a00e0bd33a22e259fa5495c1b84c43b870a7895 | /Generation/Viewer/GateViewer.hpp | ba707e43cd3af98f4573f64ed6eb5501aee5b8e0 | [
"MIT"
] | permissive | Natsirtt/get-the-cheese-gen | c94a2b057c4f314d5ca89735a9717058f9e1c09b | ec66c5d6cc3c44312e3daabec6ba16b8225da5a5 | refs/heads/master | 2020-12-24T14:17:50.306688 | 2014-04-28T10:54:46 | 2014-04-28T10:54:46 | 16,137,367 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 472 | hpp | GateViewer.hpp | #ifndef GATEVIEWER_HPP
#define GATEVIEWER_HPP
#include "Shape.hpp"
#include "../Enum.hpp"
class GraphViewer;
class GateViewer : public Shape {
public:
GateViewer(GraphViewer* gw, Id gid);
virtual ~GateViewer() {};
void update(int dt);
void draw();
void setSize(int size);
bool isInside(Vector p);
private:
void drawArrow(Vector p1, Vector p2);
GraphViewer* mGraphViewer;
Id mId;
int mNodeSize;
};
#endif // NODEVIEWER_HPP
|
694c5ce39ad64eca7a6b8e9c086e7042b630f6f0 | ec4d83925a7e8056b22f9cf0000a6c4beafea952 | /src/SortedMerge.cpp | 0ccca06e8d6bbf5d8088a76706445a858e787726 | [] | no_license | ilyail3/V8-MR | 8b7656d08123f68fb091f4e762a2816f8651f6e8 | b5aa47f387009fdc2a81a2b7e8757028e70ea4c9 | refs/heads/master | 2021-04-03T09:35:13.416040 | 2016-07-12T03:51:47 | 2016-07-12T03:51:47 | 63,014,260 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,361 | cpp | SortedMerge.cpp | //
// Created by ilya on 7/10/16.
//
#include <vector>
#include <cstring>
#include "SortedMerge.h"
#include "reader/KVStreamReader.h"
void SortedMerge::merge(char **file, SeqFileWriter *writer) {
std::vector<KVStreamReader*> readers;
char item[10000];
char key[10000];
for(int i = 0 ; file[i] != nullptr ; i++){
readers.push_back(new KVStreamReader(file[i]));
}
while(true){
char* smallest = nullptr;
for(auto it = readers.begin() ; it != readers.end() ; it++){
if((*it)->has_next()){
if(smallest == nullptr)
smallest = (*it)->peek();
else if(strcmp(smallest, (*it)->peek()) > 0)
smallest = (*it)->peek();
}
}
if(smallest == nullptr) break;
strcpy(key, smallest);
writer->write_key(key);
for(auto it = readers.begin() ; it != readers.end() ; it++) {
if ((*it)->has_next() && strcmp(key, (*it)->peek()) == 0) {
(*it)->next(item);
while((*it)->has_next() && (*it)->next_type() == TypeValue){
(*it)->next(item);
writer->write_value(item);
}
}
}
}
for(auto it = readers.begin() ; it != readers.end() ; it++) {
delete *it;
}
} |
bc055dfca03a6c6b3809ce247ad6d16001308005 | 684d1fdb7d202971365162b8714a87354597b4b6 | /Main_Code/ServoCodeWorking.ino | 42861b9fafb6e76f7e518ae88b1bf75483a2bf86 | [
"MIT"
] | permissive | MSinnott/WaterThoseOSV | 408ab3c6db94fd9c7fbf66b5fc6096c92439505e | 23b6de2c7ebfbca5c803d63fc8e67f08c634637f | refs/heads/master | 2020-04-10T17:21:38.786505 | 2017-05-05T15:28:40 | 2017-05-05T15:28:40 | 84,139,824 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,119 | ino | ServoCodeWorking.ino | #include <Servo.h>
int pingPin = 2;
int servoPin = 5;
int water_servo_pin = 4;
int servoAngle = 0;
int limitSwitch = A1;
int salinityPin = A0;
boolean saltFlag = false;
int pump[] = {36, 37};
Servo servo;
Servo water_servo;
void init_sensors() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pump[0], OUTPUT);
pinMode(pump[1], OUTPUT);
resetServo();
servo.detach();
}
void loop_sensors() {
Serial.println("Calculated Depth : " + (String)measureDepth() + " cm");
//Serial.println(analogRead(salinityPin));
delay(5000);
// for(servoAngle = 0; servoAngle < 180; servoAngle++){ //move the micro servo from 0 degrees to 180 degrees
// servo.write(servoAngle);
// delay(50);
// }
}
void resetServo(){
servo.attach(servoPin);
servo.write(180);
}
double measureDepth(){
int topOfWater = 180;
int flag = 0;
int servoAngle = 180;
servo.attach(servoPin);
servo.write(servoAngle);
boolean limit = false;
while(!limit){
//Serial.println(analogRead(limitSwitch));
if(analogRead(limitSwitch) > 512){
Serial.println((String) ("Bottom hit at theta = " + (String)servoAngle));
limit = true;
}
servoAngle--;
if(servoAngle == 0) servoAngle = 180;
servo.write(servoAngle);
Serial.println((String) ("Conductivity = " + (String) analogRead(salinityPin)));
if(flag == 0 && analogRead(salinityPin)>25){
Serial.println((String) ("Water hit at theta = " + (String) servoAngle));
topOfWater = servoAngle;
flag = 1;
}
if(analogRead(salinityPin)>=50){
saltFlag = true;
}
delay(50);
}
servo.write(180);
return((servoAngle-topOfWater)*(6.0*3.14159/360.0));
}
void retrieve_water(){
water_servo.attach(water_servo_pin);
water_servo.write(0);
delay(1000);
water_servo.write(180);
}
void pump_stop(){
digitalWrite(pump[0], LOW);
digitalWrite(pump[1], LOW);
}
void pump_in(){
digitalWrite(pump[0], HIGH);
digitalWrite(pump[1], LOW);
}
void pump_out(){
digitalWrite(pump[0], LOW);
digitalWrite(pump[1], HIGH);
}
int getDist(){
long duration, cm;
// The PING is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING: a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
cm = microsecondsToCentimeters(duration);
return cm;
}
long microsecondsToCentimeters(long microseconds) {
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
|
55df4edea7d72b44e1ca5de7fd80a02bee0eff6d | 303e341606dbc4c4082d1a5864d5ccffea01d312 | /src/searchSuggestionsSystem.hpp | 19320628d8485fd4386f47e75100f21346674df7 | [] | no_license | dominikheinisch/algorithms | 02c39b3600e02537e7071cedd9dd08a2d20df2fb | e10e54ed986e46a2b2b9779e52b6afc236a62222 | refs/heads/master | 2022-07-24T12:04:58.417772 | 2020-05-20T07:59:12 | 2020-05-20T07:59:12 | 254,881,561 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,465 | hpp | searchSuggestionsSystem.hpp | #include <vector>
#include <set>
#include <string>
//static int x = [] () {std::ios::sync_with_stdio(false); std::cin.tie(0); return 0;} ();
class suggestedProductsSolution {
public:
std::vector<std::vector<std::string>> suggestedProducts(
std::vector<std::string>& products, std::string searchWord)
{
std::vector<std::string> partialWords;
for (int i=0; i < searchWord.size(); ++i) {
partialWords.push_back(searchWord.substr(0, i+1));
}
std::set<std::string> sortedProducts;
for (int i=0; i < products.size(); ++i) {
if(products[i][0] == searchWord[0]) sortedProducts.insert(products[i]);
}
std::vector<std::vector<std::string>> result(searchWord.size(), std::vector<std::string>());
for (int i=0; i < partialWords.size(); ++i) {
for (auto it = sortedProducts.begin(); it != sortedProducts.end();) {
if (it->size() < partialWords[i].size() ||
!std::equal(partialWords[i].begin(), partialWords[i].end(), it->begin()))
{
auto temp = it++;
sortedProducts.erase(temp);
} else {
result[i].push_back(*it);
++it;
if(result[i].size() == 3) {
it = sortedProducts.end();
}
}
}
}
return result;
}
}; |
516a16f0db327f9352eee6652ef5d9ffa44a98ee | e38e89d5b2b84ea07c6105c9e4be76160bb4e56a | /geant/EXOsim/src/EXOPhysicsList.cc | 64623acdb1dc1cddc80e62b14f61f20422a1f342 | [] | no_license | qxia1991/offline | d06ef060bc5e4e0c08de3d36b667bd3802315370 | f67c7f11f4131661bb81dfb914d653223abea129 | refs/heads/master | 2022-04-17T20:09:23.407344 | 2020-04-12T21:18:51 | 2020-04-12T21:18:51 | 159,555,892 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,505 | cc | EXOPhysicsList.cc |
#include <globals.hh>
#include <G4ios.hh>
#include <G4Version.hh>
#include <G4ProcessManager.hh>
#include <G4ProcessVector.hh>
#include <G4ParticleTypes.hh>
#include <G4ParticleTable.hh>
#if 0+G4VERSION_NUMBER >= 960
#include <G4GenericPhysicsList.hh>
#endif
#include <G4SystemOfUnits.hh>
#include <G4UnitsTable.hh>
#include <G4Material.hh>
#include <G4MaterialTable.hh>
//#include <iomanip>
#include <G4StateManager.hh>
#include <G4ApplicationState.hh>
//#include "G4DataQuestionaire.hh"
#include "EXOSim/EXOPhysicsList.hh"
#include "EXOSim/EXOPhysicsListMessenger.hh"
EXOPhysicsList::EXOPhysicsList(G4int ver)
: G4VModularPhysicsList()
{
SetVerboseLevel(ver);
//DeclareProperties();
fMessenger = new EXOPhysicsListMessenger(this, "/PhysicsList/");
defaultCutValue = 10.0*CLHEP::mm;
//Default cuts are applied everywhere, then A G4Region is defined below to set
//cuts for innerCryostat and all daughters to much finer cuts.
defaultCutValue = 10.0*CLHEP::mm;
cutForGamma = defaultCutValue;
cutForElectron = defaultCutValue;
cutForPositron = defaultCutValue;
cutForMuon = 0.0;
cutForProton = defaultCutValue;
cutForNeutron = 0.0;
cutForAlpha = 0.0;
cutForGenericIon = 0.0;
cutInsideTPC = 0.1*CLHEP::mm;
cutInnerRegion = 1.0*CLHEP::mm;
//G4DataQuestionaire it(photon);
G4cout << "<<< Geant4 Physics List simulation engine: EXOPhysicsList" << G4endl;
G4cout << G4endl;
RegisterPhysicsConstructor("EXOEmPenelopePhysics");
//RegisterPhysicsConstructor("G4EmExtraPhysics");
RegisterPhysicsConstructor("G4OpticalPhysics");
RegisterPhysicsConstructor("EXONeutronPhysics");
// RegisterPhysicsConstructor("G4HadronElasticPhysics");
// RegisterPhysicsConstructor("G4StoppingPhysics");
#if 0+G4VERSION_NUMBER >= 1000
// RegisterPhysicsConstructor("G4HadronPhysicsQGSP_BERT");
#else
// RegisterPhysicsConstructor("HadronPhysicsQGSP_BERT");
#endif
// RegisterPhysicsConstructor("HadronPhysicsLHEP_BERT_HP");
// RegisterPhysicsConstructor("G4IonPhysics");
RegisterPhysicsConstructor("G4DecayPhysics");
RegisterPhysicsConstructor("G4RadioactiveDecayPhysics");
RegisterPhysicsConstructor("EXOSpecialPhysics");
}
EXOPhysicsList::~EXOPhysicsList()
{
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include <G4BosonConstructor.hh>
#include <G4LeptonConstructor.hh>
#include <G4MesonConstructor.hh>
#include <G4BaryonConstructor.hh>
#include <G4IonConstructor.hh>
#include <G4ShortLivedConstructor.hh>
void EXOPhysicsList::ConstructParticle()
{
if (verboseLevel>0) G4cout << __PRETTY_FUNCTION__ << G4endl;
// As of version 4.10 all used particles MUST be created in here,
// so we are firing anything just for the case
G4Geantino::GeantinoDefinition();
G4BosonConstructor::ConstructParticle();
G4LeptonConstructor::ConstructParticle();
G4MesonConstructor::ConstructParticle();
G4BaryonConstructor::ConstructParticle();
G4IonConstructor::ConstructParticle();
G4ShortLivedConstructor::ConstructParticle();
G4VModularPhysicsList::ConstructParticle();
}
void EXOPhysicsList::ConstructProcess()
{
if (verboseLevel>0) G4cout << __PRETTY_FUNCTION__ << G4endl;
G4VModularPhysicsList::ConstructProcess();
if (verboseLevel>2) {
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
pmanager->DumpInfo();
}
}
}
#include <G4RegionStore.hh>
void EXOPhysicsList::SetCuts()
{
if (verboseLevel >0){
G4cout << "EXOPhysicsList::SetCuts:";
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
}
//G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(250*eV, 100*MeV);
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
//
//this->SetCutsWithDefault();
G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(50*CLHEP::eV, 100*CLHEP::MeV);
if (cutForGamma>0.) SetCutValue(cutForGamma, "gamma");
if (cutForElectron>0.) SetCutValue(cutForElectron, "e-");
if (cutForPositron>0.) SetCutValue(cutForPositron, "e+");
if (cutForMuon>0.) SetCutValue(cutForMuon, "mu-");
if (cutForMuon>0.) SetCutValue(cutForMuon, "mu+");
if (cutForProton>0.) SetCutValue(cutForProton, "proton");
if (cutForNeutron>0.) SetCutValue(cutForNeutron, "neutron");
if (cutForAlpha>0.) SetCutValue(cutForAlpha, "alpha");
if (cutForGenericIon>0.) SetCutValue(cutForGenericIon, "GenericIon");
if (cutInsideTPC>0.) {
G4Region* region = G4RegionStore::GetInstance()->GetRegion("TPC");
G4ProductionCuts* cuts = new G4ProductionCuts;
cuts->SetProductionCut(cutInsideTPC);
region->SetProductionCuts(cuts);
}
if (cutInnerRegion>0.) {
G4Region* region;
G4ProductionCuts* cuts;
// Set cuts for inner detector stuff with finer tracking
region = G4RegionStore::GetInstance()->GetRegion("InnerRegion");
cuts = new G4ProductionCuts;
cuts->SetProductionCut(0.1*cutInnerRegion,G4ProductionCuts::GetIndex("gamma"));
cuts->SetProductionCut(cutInnerRegion,G4ProductionCuts::GetIndex("e-"));
cuts->SetProductionCut(cutInnerRegion,G4ProductionCuts::GetIndex("e+"));
region->SetProductionCuts(cuts);
G4cout <<"InnerRegion cuts are set to:" << G4endl;
G4cout <<" gamma cut = "<< cuts->GetProductionCut("gamma")/CLHEP::mm <<" mm"<< G4endl;
G4cout <<" electron cut = "<< cuts->GetProductionCut("e-")/CLHEP::mm <<" mm"<< G4endl;
G4cout <<" positron cut = "<< cuts->GetProductionCut("e+")/CLHEP::mm <<" mm"<< G4endl;
}
if (cutInsideTPC>0.){
G4Region* region;
G4ProductionCuts* cuts;
// Set cuts for inner detector stuff with finer tracking
region = G4RegionStore::GetInstance()->GetRegion("TPC");
cuts = new G4ProductionCuts;
cuts->SetProductionCut(0.1*cutInsideTPC,G4ProductionCuts::GetIndex("gamma"));
cuts->SetProductionCut(cutInsideTPC,G4ProductionCuts::GetIndex("e-"));
cuts->SetProductionCut(cutInsideTPC,G4ProductionCuts::GetIndex("e+"));
region->SetProductionCuts(cuts);
G4cout <<"InsideTPC cuts are set to:" << G4endl;
G4cout <<" gamma cut = "<< cuts->GetProductionCut("gamma")/CLHEP::mm <<" mm"<< G4endl;
G4cout <<" electron cut = "<< cuts->GetProductionCut("e-")/CLHEP::mm <<" mm"<< G4endl;
G4cout <<" positron cut = "<< cuts->GetProductionCut("e+")/CLHEP::mm <<" mm"<< G4endl;
}
if (verboseLevel>0) DumpCutValuesTable();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#if 0+G4VERSION_NUMBER >= 950
#include "G4BuilderType.hh"
namespace {
static const G4String typeUnknown = "Unknown";
static const G4String typeTransportation = "Transportation";
static const G4String typeElectromagnetic = "Electromagnetic";
static const G4String typeEmExtra = "EmExtra";
static const G4String typeDecay = "Decay";
static const G4String typeHadronElastic = "HadronElastic";
static const G4String typeHadronInelastic = "HadronInelastic";
static const G4String typeStopping = "Stopping";
static const G4String typeIons = "Ions";
static const G4String noType = "------";
}
const G4String& G4VPhysicsConstructor__GetPhysicsTypeName(G4BuilderType aType)
{
switch (aType) {
case bUnknown: return typeUnknown; break;
case bTransportation: return typeTransportation; break;
case bElectromagnetic: return typeElectromagnetic; break;
case bEmExtra: return typeEmExtra; break;
case bDecay: return typeDecay; break;
case bHadronElastic: return typeHadronElastic; break;
case bHadronInelastic: return typeHadronInelastic; break;
case bStopping: return typeStopping; break;
case bIons: return typeIons; break;
default: ;
}
return noType;
}
#endif
void EXOPhysicsList::ListPhysics()
{
G4cout << "Registered physics constructors" << G4endl;
const G4VPhysicsConstructor *phys = 0;
for(int i=0;i<100;i++) {
phys = GetPhysics(i);
if (phys==0) break;
G4cout << " [" << i <<"] '" << phys->GetPhysicsName() <<"'";
#if 0+G4VERSION_NUMBER >= 950
G4cout << " (" << G4VPhysicsConstructor__GetPhysicsTypeName((G4BuilderType)phys->GetPhysicsType()) <<")";
#endif
if (verboseLevel > 2)
G4cout <<" "<< (void*)phys;
G4cout << G4endl;
}
}
void EXOPhysicsList::ClearPhysics()
{
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
if(!(currentState==G4State_PreInit)){
G4Exception("EXOPhysicsList::ClearPhysics",
"Run0203", JustWarning,
"Geant4 kernel is not PreInit state : Method ignored.");
return;
}
#if 0+G4VERSION_NUMBER >= 1000
((G4VMPLsubInstanceManager.offset[g4vmplInstanceID]).physicsVector)->clear();
#else
physicsVector->clear();
#endif
}
void EXOPhysicsList::RegisterPhysics(G4VPhysicsConstructor* phys)
{
if (verboseLevel > 0 )
G4cout << "EXOPhysicsList::RegisterPhysics: " << phys->GetPhysicsName() << " is added" << G4endl;
G4VModularPhysicsList::RegisterPhysics(phys);
}
void EXOPhysicsList::ReplacePhysics(G4VPhysicsConstructor* phys)
{
#if 0+G4VERSION_NUMBER >= 950
G4VModularPhysicsList::ReplacePhysics(phys);
#else
// Can't implement this without G4VPhysicsContructor::typePhysics
G4cerr << "EXOPhysicsList::ReplacePhysics(phys) call is not available in this version of Geant4." << G4endl;
#endif
}
void EXOPhysicsList::RemovePhysics(G4VPhysicsConstructor* phys)
{
#if 0+G4VERSION_NUMBER >= 950
G4VModularPhysicsList::RemovePhysics(phys);
#else
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
if(!(currentState==G4State_PreInit)){
G4Exception("EXOPhysicsList::RemovePhysics",
"Run0205", JustWarning,
"Geant4 kernel is not PreInit state : Method ignored.");
return;
}
for (G4PhysConstVector::iterator itr = physicsVector->begin(); itr != physicsVector->end(); itr++) {
if ( phys == (*itr)) {
if (verboseLevel > 0 )
G4cout << "EXOPhysicsList::RemovePhysics: " << (*itr)->GetPhysicsName() << " is removed" << G4endl;
physicsVector->erase(itr);
break;
}
}
#endif
}
#if 0+G4VERSION_NUMBER >= 1000
#include <G4PhysicsConstructorRegistry.hh>
void EXOPhysicsList::RegisterPhysicsConstructor(const G4String& phys_name)
{
G4VPhysicsConstructor *phys = G4PhysicsConstructorRegistry::Instance()->GetPhysicsConstructor(phys_name);
if (phys)
RegisterPhysics(phys);
else
G4cerr << "Can't find physics constructor '" << phys_name <<"'"<< G4endl;
}
#else
// simulate if it's not provided
#include "EXOSim/EXOEmPenelopePhysics.hh"
#include "EXOSim/EXONeutronPhysics.hh"
#include "EXOSim/EXOSpecialPhysics.hh"
//
#include <G4DecayPhysics.hh>
#include <G4RadioactiveDecayPhysics.hh>
#include <G4EmStandardPhysics.hh>
#include <G4EmPenelopePhysics.hh>
#include <G4OpticalPhysics.hh>
#include <G4EmExtraPhysics.hh>
#include <G4HadronElasticPhysics.hh>
#if 0+G4VERSION_NUMBER >= 940
#include <G4HadronElasticPhysicsHP.hh>
#endif
#include <G4IonPhysics.hh>
#if 0+G4VERSION_NUMBER < 1000
#include <G4QStoppingPhysics.hh>
#endif
#if 0+G4VERSION_NUMBER >= 960
#include <G4StoppingPhysics.hh>
#endif
#include <HadronPhysicsFTFP_BERT.hh>
#if 0+G4VERSION_NUMBER >= 960
#include <HadronPhysicsFTFP_BERT_HP.hh>
#endif
#include <HadronPhysicsQGSP_BERT.hh>
#include <HadronPhysicsQGSP_BERT_HP.hh>
#include <HadronPhysicsLHEP.hh>
#if 0+G4VERSION_NUMBER <= 940
#include <HadronPhysicsLHEP_BERT_HP.hh>
#endif
#if 0+G4VERSION_NUMBER >= 940
#include <HadronPhysicsShielding.hh>
#endif
//#include <G4Physics.hh>
void EXOPhysicsList::RegisterPhysicsConstructor(const G4String& phys_name)
{
// G4cout << __PRETTY_FUNCTION__ <<" "<< phys_name << G4endl;
// EXO
if (phys_name == "EXOSpecial") {
// EXOSpecialPhysics();
} else if (phys_name == "EXOEmPenelopePhysics") {
RegisterPhysics( new EXOEmPenelopePhysics());
} else if (phys_name == "EXONeutronPhysics") {
RegisterPhysics( new EXONeutronPhysics());
} else if (phys_name == "EXOSpecialPhysics") {
RegisterPhysics( new EXOSpecialPhysics());
// decay
} else if (phys_name == "G4DecayPhysics") {
RegisterPhysics( new G4DecayPhysics());
} else if (phys_name == "G4RadioactiveDecayPhysics") {
RegisterPhysics( new G4RadioactiveDecayPhysics());
// electromagnetic
} else if (phys_name == "G4EmStandardPhysics") {
RegisterPhysics( new G4EmStandardPhysics());
} else if (phys_name == "G4EmPenelopePhysics") {
RegisterPhysics( new G4EmPenelopePhysics());
} else if (phys_name == "G4OpticalPhysics") {
RegisterPhysics( new G4OpticalPhysics());
// gamma_lepto_buclear
} else if (phys_name == "G4EmExtraPhysics") {
RegisterPhysics( new G4EmExtraPhysics());
// hadron_elastic
} else if (phys_name == "G4HadronElasticPhysics") {
RegisterPhysics( new G4HadronElasticPhysics());
} else if (phys_name == "G4HadronElasticPhysicsHP") {
#if 0+G4VERSION_NUMBER >= 940
RegisterPhysics( new G4HadronElasticPhysicsHP());
#else
RegisterPhysics( new G4HadronElasticPhysics("elastic",0,true));
#endif
// hadron_inelastic
} else if (phys_name == "HadronPhysicsFTFP_BERT") {
RegisterPhysics( new HadronPhysicsFTFP_BERT());
#if 0+G4VERSION_NUMBER >= 960
} else if (phys_name == "HadronPhysicsFTFP_BERT_HP") {
RegisterPhysics( new HadronPhysicsFTFP_BERT_HP());
#endif
} else if (phys_name == "HadronPhysicsQGSP_BERT") {
RegisterPhysics( new HadronPhysicsQGSP_BERT());
} else if (phys_name == "HadronPhysicsQGSP_BERT_HP") {
RegisterPhysics( new HadronPhysicsQGSP_BERT_HP());
} else if (phys_name == "HadronPhysicsLHEP") {
RegisterPhysics( new HadronPhysicsLHEP());
#if 0+G4VERSION_NUMBER <= 940
} else if (phys_name == "HadronPhysicsLHEP_BERT_HP") {
RegisterPhysics( new HadronPhysicsLHEP_BERT_HP());
#endif
#if 0+G4VERSION_NUMBER >= 940
} else if (phys_name == "HadronPhysicsShielding") {
RegisterPhysics( new HadronPhysicsShielding());
#endif
// ions
} else if (phys_name == "G4IonPhysics") {
RegisterPhysics( new G4IonPhysics());
// limiters
// } else if (phys_name == "G4NeutronTrackingCut") {
// RegisterPhysics( new G4NeutronTrackingCut());
// stopping
} else if (phys_name == "G4StoppingPhysics" ||
phys_name == "G4QStoppingPhysics") {
#if 0+G4VERSION_NUMBER >= 960
RegisterPhysics( new G4StoppingPhysics());
#else
RegisterPhysics( new G4QStoppingPhysics());
#endif
} else
G4cerr << "Can't find physics constructor '" << phys_name <<"'"<< G4endl;
}
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#if 0+G4VERSION_NUMBER >= 960
G4VModularPhysicsList* EXOPhysicsList::GetGenericPhysicsList(const G4String& list_names)
{
std::vector<G4String> list;
for (str_size i = 0, j = list_names.index(' ',0); true; i = j+1, j = list_names.index(' ',j+1)) {
G4String str;
str.assign(list_names,i,((j!=std::string::npos)?j-i:-1));
if (!str.empty()) list.push_back(str);
if (j == std::string::npos) break;
}
G4GenericPhysicsList* physics = new G4GenericPhysicsList(&list);
return physics;
}
#else
G4VModularPhysicsList* EXOPhysicsList::GetGenericPhysicsList(const G4String& list_names)
{
//G4Exception("EXOPhysicsList","1",FatalException,"Call GetGenericPhysicsList(name) is not implemented in this version of Geant4.");
G4cerr << "EXOPhysicsList::GetGenericPhysicsList(name) call is not available in this version of Geant4." << G4endl;
return 0;
}
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#if 0+G4VERSION_NUMBER >= 922
#include <G4PhysListFactory.hh>
G4VModularPhysicsList* EXOPhysicsList::GetReferencePhysicsList(const G4String& list_name)
{
G4PhysListFactory physicsFactory;
return physicsFactory.GetReferencePhysList(list_name);
}
#else
G4VModularPhysicsList* EXOPhysicsList::GetReferencePhysicsList(const G4String& list_name)
{
G4cerr << "EXOPhysicsList::GetReferencePhysicsList(name) call is not available in this version of Geant4." << G4endl;
return 0;
}
#endif
|
7a2dfe088176ec4259abab28d59c7de4dbc694df | 214355db2ebb44a0c63a993d96cd759e0061a33b | /EmptyProject/pch.h | 06a7602dfd416d9d22340eedad8f70eaf2e5d770 | [] | no_license | JeongTaeLee/Gleise-518D | b59e24a2f5722155c732adc346ace087cd66c691 | b9f69cb33b63f4a4e25e6399d8915e35daf95df9 | refs/heads/master | 2020-05-02T21:31:55.350658 | 2019-04-02T05:47:45 | 2019-04-02T05:47:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,714 | h | pch.h | #pragma once
#pragma comment(lib, "dsound.lib")
enum
{
WINDOWX = 1280,
WINDOWY = 720,
};
using namespace std;
#include <iostream>
#include <functional>
#include <thread>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <fstream>
#include <random>
using Vector4 = D3DXVECTOR4;
using Vector3 = D3DXVECTOR3;
using Vector2 = D3DXVECTOR2;
using Matrix = D3DXMATRIX;
using Quaternion = D3DXQUATERNION;
using RefV3 = const Vector3 &;
using RefStr = const wstring &;
#ifdef DEBUG
#define DEBUG_LOG(s) cout << s << endl
#define DEBUG_LOGW(s) wcout << s << endl
#define DEBUG_LOG_V3(s) cout << s.x << ", " << s.y << ", " << s.z << endl;
#define DEBUG_LOG_V2(s) cout << s.x << ", " << s.y << endl;
#else
#define DEBUG_LOG(s)
#define DEBUG_LOG(s)
#define DEBUG_LOGW(s)
#define DEBUG_LOG_V3(s)
#define DEBUG_LOG_V2(s)
#endif
#define g_device DXUTGetD3D9Device()
extern float fFrameTime;
inline float Et()
{
return DXUTGetElapsedTime() * fFrameTime;
}
struct texture
{
LPDIRECT3DTEXTURE9 lpTex = nullptr;
D3DXIMAGE_INFO info;
texture(LPDIRECT3DTEXTURE9 _lpTex, D3DXIMAGE_INFO _info)
:lpTex(_lpTex), info(_info)
{}
~texture()
{
SAFE_RELEASE(lpTex);
}
};
#include "SceneManager.h"
#include "InputManager.h"
#include "ObjectManager.h"
#include "ResourceManager.h"
#include "CameraManger.h"
#include "MapManager.h"
#include "SoundManager.h"
#include "MeshLoader.h"
#include "Func.h"
#include "GameObject.h"
#include "Component.h"
#include "Transform.h"
#include "Renderer.h"
#include "ShaderRenderer.h"
#include "UIRenderer.h"
#include "Animater.h"
#include "RigidBody.h"
#include "PixelCollider.h"
#include "Collider.h"
#include "Text.h"
#include "BBRenderer.h" |
3a361eff358d781e9c2e3bdc79b3b0dfe45be9a3 | abd20d547fd002845a8f32116193ae3d6fd5cc6e | /AP-CS-Semester2/Simulation2/fishsim.cpp | b8b143f7008d5bd55ff14f195d72fa72ff2e42c4 | [] | no_license | erichmusick/CppExamples | 2503651ad4a96a7fe4da59afd648b41d72570e28 | fc58ea729fbfc23e72bc66893296586ab5e9b063 | refs/heads/master | 2021-03-12T19:55:23.534295 | 2014-02-02T21:06:18 | 2014-02-02T21:06:18 | 16,427,256 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,943 | cpp | fishsim.cpp | // AP Computer Science Marine Biology Case Study program
// Copyright (C) 2000 College Board and Educational Testing Service
// 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.
// 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.
// fishsim.cpp - copyright statement added 5/31/2000
/**** I N C L U D E F I L E S ****/
#include <iostream>
#include <conio.h>
#include <fstream>
#include <string>
#include <vector> // erichmusick
#include <Windows.h> // erichmusick
#include "environ.h"
#include "display.h"
#include "simulate.h"
#include "../../AP-CS-Misc/Common/CommonFunctions.h"
using namespace std;
/**** F U N C T I O N P R O T O T Y P E S ****/
void pressEnterToContinue();
/**** F U N C T I O N S ****/
// PRESS ENTER TO CONTINUE
/* Purpose - Pause the program until the user presses enter
* Parameters - None.
* Input - Program waits for user to press enter before continuing
* Process - Program waits for user to press enter before continuing
* Output - None.
* Return - None.
*/
void pressEnterToContinue() {
char key;
cout << "\nPress ENTER to continue...";
key = 'a';
while (int(key) != 13) {
key = char(_getch());
if (key == 0) {
key = char(_getch());
}
}
return;
}
/**** M A I N ****/
int main()
{
// Get initial environment settings
char setEnv;
int numRows;
int numCols;
int numFish;
int index;
vector<int> fishRow;
vector<int> fishCol;
cout << "Would you like to define an environment? (Y/N; N uses current ";
cout << "settings in\nfish.dat)\n? ";
cin >> setEnv;
cout << endl;
if (toupper(setEnv) == 'Y') {
do {
cout << "Number of rows? ";
cin >> numRows;
} while (numRows <= 0 || numRows >= 46);
do {
cout << "Number of columns? ";
cin >> numCols;
} while (numCols <= 0 || numCols >= 78);
do {
cout << "Number of fish? ";
cin >> numFish;
} while (numFish < 0);
if (numFish != 0) {
fishRow.resize(numFish);
fishCol.resize(numFish);
}
for (index = 0; index < numFish; index++) {
do {
cout << "Fish ";
cout << index + 1;
cout << " initial row: ";
cin >> fishRow[index];
} while (fishRow[index] < 0 || fishRow[index] >= numRows);
do {
cout << "Fish ";
cout << index + 1;
cout << " initial column: ";
cin >> fishCol[index];
} while (fishCol[index] < 0 || fishCol[index] >= numCols);
}
ofstream output;
output.open("fish.dat");
if (!output) {
cerr << "Unable to open fish.dat.";
}
else {
output << numRows << " " << numCols << endl;
for (index = 0; index < numFish; index++) {
output << fishRow[index] << " " << fishCol[index] << endl;
}
}
output.close();
}
// replace filename below with appropriate file (full path if necessary)
ifstream input("fish.dat");
Environment env(input);
//Display display(100,100); // for graphics display
Display display; // for text display
string s;
Simulation sim;
int step;
int numSteps;
char displaySim;
int stepTime;
// INPUT: Get number of times the fish should move
do {
cout << "Steps in simulation? ";
cin >> numSteps;
} while (numSteps < 0);
// INPUT: Display the movement of the fish?
// commented out at this time because there is no point in not
// displaying the simulation at this point in time
/* do {
cout << "Display Simulation (Show each move of the fish) (y/n)? ";
cin >> displaySim;
displaySim = toupper(displaySim);
} while (displaySim != 'Y' && displaySim != 'N'); */
displaySim = 'Y';
if (displaySim == 'Y') { // User wants to display the movement of the fish
// INPUT: Get amount to pause before each "step"/move
do {
cout << "Time between steps (in milliseconds)? ";
cin >> stepTime;
} while (stepTime < 0);
}
pressEnterToContinue();
if (displaySim == 'Y') {
//_setcursortype(0);
Common::ClearScreen();
display.Show(env, true);
cout << "Press a key to end simulation early";
Sleep(stepTime);
}
for (step = 0; step < numSteps; step++)
{
sim.Step(env);
if (displaySim == 'Y') {
display.Show(env, false, 2, 2);
Sleep(stepTime);
}
else {
if (step == 0) {
cout << "Simulating guppy movement. Please wait...\n";
cout << "Press a key to end simulation early";
}
}
if (_kbhit()) {
_getch();
//__flush_win95_keyup_events();
break;
}
}
//_setcursortype(2);
return 0;
}
|
e0cdf75d7f559105d465418ee2f98a36a1435851 | b1cca159764e0cedd802239af2fc95543c7e761c | /ext/libgecode3/vendor/gecode-3.7.3/examples/alpha.cpp | 827b61048a780db50a32059f62e36dbf2137a275 | [
"MIT",
"Apache-2.0"
] | permissive | chef/dep-selector-libgecode | b6b878a1ed4a6c9c6045297e2bfec534cf1a1e8e | 76d7245d981c8742dc539be18ec63ad3e9f4a16a | refs/heads/main | 2023-09-02T19:15:43.797125 | 2021-08-24T17:02:02 | 2021-08-24T17:02:02 | 18,507,156 | 8 | 18 | Apache-2.0 | 2023-08-22T21:15:31 | 2014-04-07T05:23:13 | Ruby | UTF-8 | C++ | false | false | 4,893 | cpp | alpha.cpp | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2001
*
* Last modified:
* $Date: 2010-10-07 20:52:01 +1100 (Thu, 07 Oct 2010) $ by $Author: schulte $
* $Revision: 11473 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <gecode/driver.hh>
#include <gecode/int.hh>
#include <gecode/minimodel.hh>
using namespace Gecode;
/**
* \brief %Example: %Alpha puzzle
*
* Well-known cryptoarithmetic puzzle of unknown origin.
*
* \ingroup Example
*
*/
class Alpha : public Script {
protected:
/// Alphabet has 26 letters
static const int n = 26;
/// Array for letters
IntVarArray le;
public:
/// Branching to use for model
enum {
BRANCH_NONE, ///< Choose variable left to right
BRANCH_INVERSE, ///< Choose variable right to left
BRANCH_SIZE ///< Choose variable with smallest size
};
/// Actual model
Alpha(const Options& opt) : le(*this,n,1,n) {
IntVar
a(le[ 0]), b(le[ 1]), c(le[ 2]), e(le[ 4]), f(le[ 5]),
g(le[ 6]), h(le[ 7]), i(le[ 8]), j(le[ 9]), k(le[10]),
l(le[11]), m(le[12]), n(le[13]), o(le[14]), p(le[15]),
q(le[16]), r(le[17]), s(le[18]), t(le[19]), u(le[20]),
v(le[21]), w(le[22]), x(le[23]), y(le[24]), z(le[25]);
rel(*this, b+a+l+l+e+t == 45, opt.icl());
rel(*this, c+e+l+l+o == 43, opt.icl());
rel(*this, c+o+n+c+e+r+t == 74, opt.icl());
rel(*this, f+l+u+t+e == 30, opt.icl());
rel(*this, f+u+g+u+e == 50, opt.icl());
rel(*this, g+l+e+e == 66, opt.icl());
rel(*this, j+a+z+z == 58, opt.icl());
rel(*this, l+y+r+e == 47, opt.icl());
rel(*this, o+b+o+e == 53, opt.icl());
rel(*this, o+p+e+r+a == 65, opt.icl());
rel(*this, p+o+l+k+a == 59, opt.icl());
rel(*this, q+u+a+r+t+e+t == 50, opt.icl());
rel(*this, s+a+x+o+p+h+o+n+e == 134, opt.icl());
rel(*this, s+c+a+l+e == 51, opt.icl());
rel(*this, s+o+l+o == 37, opt.icl());
rel(*this, s+o+n+g == 61, opt.icl());
rel(*this, s+o+p+r+a+n+o == 82, opt.icl());
rel(*this, t+h+e+m+e == 72, opt.icl());
rel(*this, v+i+o+l+i+n == 100, opt.icl());
rel(*this, w+a+l+t+z == 34, opt.icl());
distinct(*this, le, opt.icl());
switch (opt.branching()) {
case BRANCH_NONE:
branch(*this, le, INT_VAR_NONE, INT_VAL_MIN);
break;
case BRANCH_INVERSE:
branch(*this, le.slice(le.size()-1,-1), INT_VAR_NONE, INT_VAL_MIN);
break;
case BRANCH_SIZE:
branch(*this, le, INT_VAR_SIZE_MIN, INT_VAL_MIN);
break;
}
}
/// Constructor for cloning \a s
Alpha(bool share, Alpha& s) : Script(share,s) {
le.update(*this, share, s.le);
}
/// Copy during cloning
virtual Space*
copy(bool share) {
return new Alpha(share,*this);
}
/// Print solution
virtual void
print(std::ostream& os) const {
os << "\t";
for (int i = 0; i < n; i++) {
os << ((char) (i+'a')) << '=' << le[i] << ((i<n-1)?", ":"\n");
if ((i+1) % 8 == 0)
os << std::endl << "\t";
}
os << std::endl;
}
};
/** \brief Main-function
* \relates Alpha
*/
int
main(int argc, char* argv[]) {
Options opt("Alpha");
opt.solutions(0);
opt.iterations(10);
opt.branching(Alpha::BRANCH_NONE);
opt.branching(Alpha::BRANCH_NONE, "none");
opt.branching(Alpha::BRANCH_INVERSE, "inverse");
opt.branching(Alpha::BRANCH_SIZE, "size");
opt.parse(argc,argv);
Script::run<Alpha,DFS,Options>(opt);
return 0;
}
// STATISTICS: example-any
|
91a522aedfd330a6e95f1dc181cd5f9963b61ee0 | 0cb85cd0c88a9b9f0cca4472742c2bf9febef2d8 | /CS AdminKit/development2/common_nagent_sdk/include/kca/prss/settingsstorage.h | 19633d72ca6ccdbaa51a0b26ec1ea7d69facad36 | [] | no_license | seth1002/antivirus-1 | 9dfbadc68e16e51f141ac8b3bb283c1d25792572 | 3752a3b20e1a8390f0889f6192ee6b851e99e8a4 | refs/heads/master | 2020-07-15T00:30:19.131934 | 2016-07-21T13:59:11 | 2016-07-21T13:59:11 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 4,891 | h | settingsstorage.h | /*!
* (C) 2002 "Kaspersky Lab"
*
* \file PRSS/SettingsStorage.h
* \author Андрей Казачков
* \date 2002
* \brief Главный интерфейс модуля Product Settings Storage.
*
*/
#ifndef KLPRSS_SETTINGSSTORAGE_H
#define KLPRSS_SETTINGSSTORAGE_H
namespace KLPRSS
{
/*!
\brief Максимальная длина, в символах, строки имени продукта,
версии, секции (без нулевого символа).
*/
const int c_nMaxNameLength=31;
//! Информация о лицензионных ключах в Product Info Settings Storage
#define KLPRSS_SECTION_LIC_INFO L"LicensingInfo"
//! информация об активном лицензионном ключе
#define KLPRSS_VAL_LIC_KEY_CURRENT L"CurrentKey"
//! информация о резервном лицензионном ключе
#define KLPRSS_VAL_LIC_KEY_NEXT L"NextKey"
/*! application components-to-update list section KLPRSS_SECTION_PRODCOMP
Section contains KLPRSS_VAL_PRODCOMPS variable which is array of params
Each array item has at least two variables:
KLPRSS_VAL_NAME component name
KLPRSS_VAL_VERSION component version
*/
#define KLPRSS_SECTION_PRODCOMP L"ProductComponents"
//!array of params that contain components info
#define KLPRSS_VAL_PRODCOMPS L"Components" //ARRAY_T|PARAMS_T
#define KLPRSS_SECTION_PRODFIXES L"ProductFixes"
//KLCONN_VAL_FIXES
/*!
\brief Стандартные переменные.
*/
#define KLPRSS_VAL_NAME L"Name"
#define KLPRSS_VAL_VERSION L"Version"
#define KLPRSS_VAL_INSTALLTIME L"InstallTime"
#define KLPRSS_VAL_MODULETYPE L"ModuleType"
#define KLPRSS_VAL_STARTFLAGS L"StartFlags"
#define KLPRSS_VAL_FILENAME L"FileName"
#define KLPRSS_VAL_FILEPATH L"FilePath"
#define KLPRSS_VAL_CUSTOMNAME L"CustomName"
#define KLPRSS_VAL_WELLKNOWNNAME L"WellKnown"
#define KLPRSS_VAL_TASKS L"Tasks"
#define KLPRSS_VAL_TASKS_COMPLEMENTED L"TasksComplemented"
#define KLPRSS_VAL_EVENTS L"Events"
#define KLPRSS_VAL_KILLTIMEOUT L"KillTimeout"
#define KLPRSS_VAL_PINGTIMEOUT L"PingTimeout"
#define KLPRSS_VAL_ACCEPTED_CMDS L"AcceptedCmds"
#define KLPRSS_VAL_LOCAL_ONLY L"LocalOnly"
#define KLPRSS_VAL_INSTANCES L"Instances"
#define KLPRSS_VAL_LASTSTART L"LastStartTime"
#define KLPRSS_VAL_LASTSTOP L"LastStopTime"
#define KLPRSS_VAL_INSTANCEPORT L"InstancePort"
#define KLPRSS_VAL_CONNTYPE L"ConnectionType"
#define KLPRSS_VAL_CONNECTIONNAME L"ConnectionName"
#define KLPRSS_VAL_PID L"Pid"
};
/*!
\brief Информация о продукте.
*/
//! Корневая папка продукта STRING_T
#define KLPRSS_PRODVAL_INSTALLFOLDER L"Folder"
//! KLPRSS_PRODVAL_INSTALLTIME
#define KLPRSS_PRODVAL_INSTALLTIME KLPRSS_VAL_INSTALLTIME
//! KLPRSS_PRODVAL_LASTUPDATETIME
#define KLPRSS_PRODVAL_LASTUPDATETIME L"LastUpdateTime"
//! KLPRSS_PRODVAL_DISPLAYNAME
#define KLPRSS_PRODVAL_DISPLAYNAME L"DisplayName"
//! Папка антивирусных баз продукта STRING_T
#define KLPRSS_PRODVAL_BASEFOLDER L"BaseFolder"
//! Дата антивирусных баз, DATE_TIME_T.
#define KLPRSS_PRODVAL_BASEDATE L"BaseDate"
//! Дата обновления антивирусных баз, DATE_TIME_T.
#define KLPRSS_PRODVAL_BASEINSTALLDATE L"BaseInstallDate"
//! Количество записей в антивирусных базах, INT_T
#define KLPRSS_PRODVAL_BASERECORDS L"BaseRecords"
//! Папка с ключами STRING_T
#define KLPRSS_PRODVAL_KEYFOLDER L"KeyFolder"
//! Локализация продукта STRING_T
#define KLPRSS_PRODVAL_LOCID L"LocID"
//! Product full version in w.x.y.z format, STRING_T
#define KLPRSS_PRODVAL_VERSION L"ProdVersion"
//! Connector full version in w.x.y.z format, STRING_T
#define KLPRSS_CONNECTOR_VERSION L"ConnectorVersion"
//! Connector flags, INT_T
#define KLPRSS_CONNECTOR_FLAGS L"ConnectorFlags"
//! Connector component name, STRING_T
#define KLPRSS_CONNECTOR_COMPONENT_NAME L"ConnectorComponentName"
//! Connector instance id, STRING_T
#define KLPRSS_CONNECTOR_INSTANCE_ID L"ConnectorInstanceId"
//! Название ОС STRING_T
#define KLPRSS_PRODVAL_OS_NAME L"OsName"
//! Версия ОС STRING_T
#define KLPRSS_PRODVAL_OS_VERSION L"OsVersion"
//! Релиз ОС STRING_T
#define KLPRSS_PRODVAL_OS_RELEASE L"OsRelease"
#endif // KLPRSS_SETTINGSSTORAGE_H
|
87af38071a36bd0e263b09ee886bbe9a25e054c0 | a94a34cd7af1f45267e6eb0dfda627f1a9c7070c | /Practices/Training/Competition/SummerVacation/20190724/source/jn02-54_192.168.100.54_白语诚/intersect.cpp | 3ad954c8eec0c1e3e777cf7dccf2ee9a62ea368c | [] | no_license | AI1379/OILearning | 91f266b942d644e8567cda20c94126ee63e6dd4b | 98a3bd303bc2be97e8ca86d955d85eb7c1920035 | refs/heads/master | 2021-10-16T16:37:39.161312 | 2021-10-09T11:50:32 | 2021-10-09T11:50:32 | 187,294,534 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 731 | cpp | intersect.cpp | #include<bits/stdc++.h>
using namespace std;
long long xa,ya,num=1,s,xb,yb,n,l;
int dst[100001];
struct as
{
int a,b;
}dstt[100001];
bool cmp(as a,as b)
{
return a.a<b.a;
}
int main()
{
freopen("intersect.in","r",stdin);
freopen("intersect.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>xa>>ya>>xb>>yb;
dst[i]=xa*ya;
}
sort(dst+1,dst+n+1);
for(int i=2;i<=n+1;i++)
{
if(dst[i]==dst[i-1])num++;
else dstt[++s].a=num,dstt[s].b=dst[i-1],num=1;
}
sort(dstt+1,dstt+s+1,cmp);
long long a=0,b=dstt[s].a,c=0;
for(int i=s;dstt[i].a==b;i--)
{
if(abs(dstt[i].b)>abs(a))a=dstt[i].b;
if(abs(dstt[i].b)==0)continue;
if(abs(dstt[i].b)==abs(a)&&dstt[i].b<0)a=dstt[i].b;
}
cout<<a<<".00";
return 0;
}
|
a354c69468c188222abba5b699af1d15aeff40e5 | c1ccf743b07e21ef86a1d7d2f68e63cdd2af0dce | /uboone/LLSelectionTool/OpT0Finder/Base/BaseAlgorithm.h | cf7d909bf8aa8b8aab244208a62ca19ca5127e55 | [] | no_license | MicroBooNE/uboonecode | 383425806d3ae0a89f3930e20b87016deda1d478 | b575e518da1098a274cb1f4cef57e9f76c11c279 | refs/heads/master | 2021-01-12T03:19:44.325785 | 2017-01-30T19:25:50 | 2017-01-30T19:25:50 | 78,196,104 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,004 | h | BaseAlgorithm.h | /**
* \file BaseAlgorithm.h
*
* \ingroup Base
*
* \brief Class def header for a class BaseAlgorithm
*
* @author kazuhiro
*/
/** \addtogroup Base
@{*/
#ifndef OPT0FINDER_BASEALGORITHM_H
#define OPT0FINDER_BASEALGORITHM_H
#include "OpT0FinderTypes.h"
#include "OpT0FinderFMWKInterface.h"
#include "LoggerFeature.h"
#include "uboone/LLBasicTool/GeoAlgo/GeoAABox.h"
#include <vector>
namespace flashana {
class FlashMatchManager;
/**
\class BaseAlgorithm
*/
class BaseAlgorithm : public LoggerFeature {
friend class FlashMatchManager;
public:
/// Default constructor
BaseAlgorithm(const Algorithm_t type, const std::string name);
/// Default destructor
~BaseAlgorithm(){}
/// Function to accept configuration
void Configure(const Config_t &pset);
/// Algorithm type
Algorithm_t AlgorithmType() const;
/// Algorithm name
const std::string& AlgorithmName() const;
double OpDetX(size_t i) const; ///< PMT X position getter
double OpDetY(size_t i) const; ///< PMT Y position getter
double OpDetZ(size_t i) const; ///< PMT Z position getter
const ::geoalgo::AABox& ActiveVolume() const { return _active_volume; } ///< Detector active volume getter
double ActiveXMax() const; ///< Detector active volume's maximum x value
double ActiveYMax() const; ///< Detector active volume's maximum x value
double ActiveZMax() const; ///< Detector active volume's maximum x value
double ActiveXMin() const; ///< Detector active volume's minimum x value
double ActiveYMin() const; ///< Detector active volume's minimum x value
double ActiveZMin() const; ///< Detector active volume's minimum x value
const std::vector<double>& OpDetXArray() const; ///< PMT X position array getter
const std::vector<double>& OpDetYArray() const; ///< PMT Y position array getter
const std::vector<double>& OpDetZArray() const; ///< PMT Z position array getter
size_t NOpDets() const; ///< Getter for # of PMTs
double DriftVelocity() const;
protected:
virtual void _Configure_(const Config_t &pset) = 0;
private:
void SetOpDetPositions( const std::vector<double>& pos_x,
const std::vector<double>& pos_y,
const std::vector<double>& pos_z );
void SetActiveVolume( const double xmin, const double xmax,
const double ymin, const double ymax,
const double zmin, const double zmax );
void SetDriftVelocity( const double v );
Algorithm_t _type; ///< Algorithm type
std::string _name; ///< Algorithm name
std::vector<double> _opdet_x_v; ///< OpticalDetector X position array
std::vector<double> _opdet_y_v; ///< OpticalDetector Y position array
std::vector<double> _opdet_z_v; ///< OpticalDetector Z position array
::geoalgo::AABox _active_volume; ///< Detector active volume
double _drift_velocity; ///< Drift velocity in [cm/us]
};
}
#endif
/** @} */ // end of doxygen group
|
af2201f7fc93436ddf7c409f794d7a53b609e5b7 | 824fef714384292d6885435d9939481d25927152 | /po/porender.h | 415873f3bad7c0131d0b51f16334d691f0126cea | [] | no_license | BleedingChips/old_serial_elf | 031a4351dda5a42fbef614e4f67d54eb5caa7ff3 | 377d9cafbb82c3de5e160505b24c16871f58fe40 | refs/heads/master | 2021-01-16T21:48:39.722437 | 2017-05-26T06:19:58 | 2017-05-26T06:19:58 | 21,087,842 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,367 | h | porender.h | #ifndef PORENDER_H
#define PORENDER_H
#include <string>
#include <map>
#include "popublic.h"
#include "extrabuffer.h"
#include "threadmessage.h"
#include "pogenvironment.h"
#include "plugin.h"
class PORender:public ThreadUnit::Work,public POGEnvironment
{
static const long DeflutInterTime;
friend class PO;
POPublic* PPS;
long RunTime,IntervalTime;
void MainFinish();
void MainStart();
float MouseX,MouseY,MouseZ;
bool Run;
PML APL;
ThreadMessage<int>::Receive TMI;
ExtraBuffer<PAL >::Sent EBHPA;
ExtraBuffer<PML>::Receive EBHPM;
ExtraBuffer<INFL >::Sent EBHM;
void AddLogic(PAL* Tem,const Handle<Plugin::Logic>& U)
{
Tem->push_back(U);
}
void AddInf(INFL* Tem,const Handle<Information>& U)
{
Tem->AddInfromation(U);
}
void ReadRender(PML* Tem);
bool CreatPlugin(const std::string& P);
void SetMainStart()
{
RunTime=SDL_GetTicks();
}
void ThreadConnect(ThreadUnit *);
void ThreadSynchroIn();
void ThreadSynchroOut();
void FinalExit();
public:
long Time()
{
return IntervalTime;
}
PORender(const std::string& Ti,const int& W,const int& H):RunTime(0),IntervalTime(DeflutInterTime),POGEnvironment(Ti,W,H) {}
static int CalculateSize(std::string);
bool MainRender();
void Init();
void Exit()
{
Run=false;
}
void GetFloatMouseLocation(float &X,float &Y)
{
X=MouseX;
Y=MouseY;
}
void GetFloatMouseLocation(float &X,float &Y,float &Z)
{
X=MouseX;
Y=MouseY;
Z=MouseZ;
}
~PORender() {}
};
const long PORender::DeflutInterTime=16;
void PORender::ReadRender(PML *Tem)
{
if(!Tem->empty())
{
for(PML::iterator Po=Tem->begin(); Po!=Tem->end(); ++Po)
if(Po->Exist())
{
(*Po)->Init(this);
APL.push_back(*Po);
}
Tem->clear();
}
}
bool PORender::CreatPlugin(const std::string &P)
{
Handle<Plugin::Render> HPH;
Handle<Plugin::Logic> HPA;
Plugin* PS;
if(PPS->CreatPlugin(P,HPH,HPA))
{
if(HPH.Exist())
{
HPH->Init(this);
APL.push_back(HPH);
HPH->SynchroIn();
}
if(HPA.Exist())
{
HPA->SetName(P);
EBHPA.Write(&PORender::AddLogic,this,HPA);
}
return true;
}
else if(PPS->CreatPlugin(P,HPH,HPA,PS))
{
if(HPH.Exist())
{
HPH->Connect(PS);
HPH->Init(this);
APL.push_back(HPH);
HPH->SynchroIn();
}
if(HPA.Exist())
{
HPA->SetName(P);
HPA->Connect(PS);
EBHPA.Write(&PORender::AddLogic,this,HPA);
}
return true;
}
return false;
}
void PORender::FinalExit()
{
APL.clear();
POGEnvironment::Exit();
}
void PORender::ThreadSynchroIn()
{
if(!PPS->Run)
Run=false;
}
void PORender::ThreadSynchroOut()
{
if(!PPS->Run)
Run=false;
else if(!Run)
PPS->Run=false;
PPS->MouseX=MouseX;
PPS->MouseY=MouseY;
PPS->MouseZ=MouseZ;
}
void PORender::ThreadConnect(ThreadUnit *SP)
{
PPS=dynamic_cast<POPublic*>(SP);
Entrust(EBHPA.GetPoint(&PPS->EBHPA));
Entrust(EBHM.GetPoint(&PPS->EBHM));
Entrust(TMI.GetPoint(&PPS->TMI));
Entrust(EBHPM.GetPoint(&PPS->EBHPM));
}
void PORender::Init()
{
POGEnvironment::Init();
RunTime=GetTicks();
srand(GetTicks());
}
bool PORender::MainRender()
{
if(Run)
{
MainStart();
Handle<Information> Tem;
while(GetEvent(Tem))
{
if(Tem.Exist())
{
if(Tem->IsExit())
{
Run=false;
return false;
}
else
{
if(Tem->IsMouse())
{
int K,Y;
Tem->GetMouse(K,Y);
MouseX=K*2.0/WindowW-1.0;
MouseY=1.0-Y*2.0/WindowH;
MouseZ=0.0;
}
if(Tem->IsKeyUp())
if(Tem->IsSpecialKeyESC())
{
Run=false;
return false;
}
EBHM.Write(&PORender::AddInf,this,Tem);
}
}
}
int Temp;
while(TMI.GetThreadMessage(Temp))
{
switch(Temp)
{
case POPublic::MouseLock:
LockMouse();
break;
case POPublic::MouseRelease:
ReleaseMouse();
break;
}
}
EBHPM.Read(&PORender::ReadRender,this);
if(!MouseFree())
LockMouseDetail(WindowW/2,WindowH/2);
Tem.Unused();
for(PML::iterator Po=APL.begin(); Po!=APL.end(); ++Po)
if(Po->Exist()) (*Po)->SynchroIn();
else APL.erase(Po--);
Set3D();
for(PML::iterator Po=APL.begin(); Po!=APL.end(); ++Po)
if(Po->Exist()) (*Po)->Layer3D(this);
else APL.erase(Po--);
for(PML::iterator Po=APL.begin(); Po!=APL.end(); ++Po)
if(Po->Exist()) (*Po)->LayerBland(this);
else APL.erase(Po--);
for(PML::iterator Po=APL.begin(); Po!=APL.end(); ++Po)
if(Po->Exist()) (*Po)->LayerSpecial(this);
else APL.erase(Po--);
Set2D();
for(PML::iterator Po=APL.begin(); Po!=APL.end(); ++Po)
if(Po->Exist()) (*Po)->Layer2D(this);
else APL.erase(Po--);
for(PML::iterator Po=APL.begin(); Po!=APL.end(); ++Po)
if(Po->Exist())
{
(*Po)->SynchroOut();
}
else APL.erase(Po--);
//TrackResource();
MainFinish();
return true;
}
else return false;
}
void PORender::MainStart()
{
RunTime=GetTicks();
CleanScreen();
}
void PORender::MainFinish()
{
IntervalTime=GetTicks()-RunTime;
if(IntervalTime<DeflutInterTime)
{
FrameworkDelay(DeflutInterTime-IntervalTime);
IntervalTime=DeflutInterTime;
}
}
#endif // POMAIN_H
|
653edfa6c475d0b35ac0a5ec81d8ec85a380a878 | f848704c5dffc027468c7400a5cc06aad7957bf0 | /src/grayCode/grayCode.cpp | c0b358d4e843d910831ff547677fb69e21b7e0ae | [] | no_license | lin-credible/leetcode | 4bdfd01090ac2b1f04388d86130b18bd2ae63ada | 76e3ccef63c679a7af98eff855d9b1dc6a5983a1 | refs/heads/master | 2021-01-18T13:28:20.653686 | 2015-11-11T01:44:27 | 2015-11-11T01:44:27 | 25,737,619 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,157 | cpp | grayCode.cpp | // Source : https://oj.leetcode.com/problems/gray-code/
// Author : Hao Chen
// Date : 2014-06-20
/**********************************************************************************
*
* The gray code is a binary numeral system where two successive values differ in only one bit.
*
* Given a non-negative integer n representing the total number of bits in the code,
* print the sequence of gray code. A gray code sequence must begin with 0.
*
* For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:
*
* 00 - 0
* 01 - 1
* 11 - 3
* 10 - 2
*
* Note:
* For a given n, a gray code sequence is not uniquely defined.
*
* For example, [0,2,3,1] is also a valid gray code sequence according to the above definition.
*
* For now, the judge is able to judge based on one instance of gray code sequence. Sorry about that.
*
**********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
vector<int> grayCode(int n) {
vector<int> v;
//n = 1<<n;
int x =0;
v.push_back(x);
for(int i=0; i<n; i++){
int len = v.size();
for (int j=0; j<len; j++){
x = v[j]<<1;
if (j%2==0){
v.push_back(x);
v.push_back(x+1);
}else{
v.push_back(x+1);
v.push_back(x);
}
}
v.erase(v.begin(), v.begin()+len);
}
return v;
}
void printBits(int n, int len){
for(int i=len-1; i>=0; i--) {
if (n & (1<<i)) {
printf("1");
}else{
printf("0");
}
}
}
void printVector(vector<int>& v, int bit_len)
{
vector<int>::iterator it;
for(it=v.begin(); it!=v.end(); ++it){
//bitset<bit_len> bin(*it);
printBits(*it, bit_len);
cout << " ";
//cout << *it << " ";
}
cout << endl;
}
int main(int argc, char** argv)
{
int n = 2;
if (argc>1){
n = atoi(argv[1]);
}
vector<int> v = grayCode(n);
printVector(v, n);
return 0;
}
|
7a2950340c4dbf0b2596477e56666fee69f13357 | 4e0e547faea00915da80df29ad803b36207058d8 | /src/control_points/hull_grid_points.cpp | dc698fb9c73612b9b19ebf08683e2b283f53567d | [] | no_license | fshamshirdar/3DShapeSynthesis | 5a9c734cb2b89f57381722e39c901512cfb273b4 | 64757a6f85c57882dafaf48b303ef75d3d637c79 | refs/heads/master | 2021-08-30T05:53:32.294500 | 2017-12-16T09:00:55 | 2017-12-16T09:00:55 | 112,975,245 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,818 | cpp | hull_grid_points.cpp | #include "mix_match.h"
#include "control_points/hull_grid_points.h"
#include <set>
#include <iostream>
HullGridPoints::HullGridPoints(int nx, int ny, int nz) : nx(nx), ny(ny), nz(nz)
{
}
std::vector<ControlPointsMiner::ControlPoint*> HullGridPoints::findControlPoints(Data::Part* ref, Data::Part* target)
{
scaleToTarget(ref, target);
HullGridPoints::HullGridPoint*** refPoints;
HullGridPoints::HullGridPoint*** targetPoints;
std::vector<ControlPointsMiner::ControlPoint*> controlPoints;
// XZ
if (nx != 0 && nz != 0) {
refPoints = findXZHullPoints(ref, nx, nz);
targetPoints = findXZHullPoints(target, nx, nz);
std::vector<ControlPointsMiner::ControlPoint*> controlPointsXZ = findCorrespondingPoints(refPoints, targetPoints, nx, nz);
controlPoints.insert(controlPoints.end(), controlPointsXZ.begin(), controlPointsXZ.end());
}
// XY
if (nx != 0 && ny != 0) {
refPoints = findXYHullPoints(ref, nx, ny);
targetPoints = findXYHullPoints(target, nx, ny);
std::vector<ControlPointsMiner::ControlPoint*> controlPointsXY = findCorrespondingPoints(refPoints, targetPoints, nx, ny);
controlPoints.insert(controlPoints.end(), controlPointsXY.begin(), controlPointsXY.end());
}
// YZ
if (ny != 0 && nz != 0) {
refPoints = findYZHullPoints(ref, ny, nz);
targetPoints = findYZHullPoints(target, ny, nz);
std::vector<ControlPointsMiner::ControlPoint*> controlPointsYZ = findCorrespondingPoints(refPoints, targetPoints, ny, nz);
controlPoints.insert(controlPoints.end(), controlPointsYZ.begin(), controlPointsYZ.end());
}
unscaleToRef(ref, target);
return controlPoints;
}
std::vector<ControlPointsMiner::ControlPoint*> HullGridPoints::findCorrespondingPoints(HullGridPoints::HullGridPoint*** refPoints, HullGridPoints::HullGridPoint*** targetPoints, int n, int m)
{
std::vector<ControlPointsMiner::ControlPoint*> controlPoints;
for (int i=0; i<2; i++) {
for (int j=0; j<n; j++) {
for (int k=0; k<m; k++) {
if (refPoints[i][j][k].vertex && targetPoints[i][j][k].vertex &&
refPoints[0][j][k].vertex != refPoints[1][j][k].vertex &&
targetPoints[0][j][k].vertex != targetPoints[1][j][k].vertex) {
ControlPointsMiner::ControlPoint* pair = new ControlPointsMiner::ControlPoint;
pair->translation = (targetPoints[i][j][k].vertex->pos - refPoints[i][j][k].vertex->pos);
pair->vertex = refPoints[i][j][k].vertex;
pair->pair = targetPoints[i][j][k].vertex;
controlPoints.push_back(pair);
}
}
}
}
return controlPoints;
}
HullGridPoints::HullGridPoint*** HullGridPoints::findXZHullPoints(Data::Part* part, int n, int m)
{
HullGridPoints::HullGridPoint*** points = new HullGridPoints::HullGridPoint**[2]; // back and front
points[0] = new HullGridPoints::HullGridPoint*[n];
points[1] = new HullGridPoints::HullGridPoint*[n];
for (int i=0; i<n; i++) {
points[0][i] = new HullGridPoints::HullGridPoint[m]();
points[1][i] = new HullGridPoints::HullGridPoint[m]();
}
// XZ plane
Eigen::Vector3f min = part->boundingBox.min();
Eigen::Vector3f max = part->boundingBox.max();
float width = max[0] - min[0];
float height = max[2] - min[2];
float cellWidth = width / n;
float cellHeight = height / m;
for (auto rit = part->regions.begin(); rit != part->regions.end(); rit++) {
Data::Region* region = (*rit);
for (auto vit = (*rit)->vertices.begin(); vit != (*rit)->vertices.end(); vit++) {
Data::Vertex* vertex = (*vit);
int i = int((vertex->pos[0] - min[0]) / cellWidth);
int j = int((vertex->pos[2] - min[2]) / cellHeight);
i = (i >= n) ? n-1 : i;
j = (j >= m) ? m-1 : j;
Eigen::Vector4f frontMid;
Eigen::Vector4f backMid;
float dist;
frontMid << min[0] + i * cellWidth + cellWidth / 2., min[1], min[2] + j * cellHeight + cellHeight / 2., 1.;
dist = (vertex->pos - frontMid).norm();
if (! points[0][i][j].vertex || dist < points[0][i][j].dist) {
points[0][i][j].vertex = vertex;
points[0][i][j].dist = dist;
}
backMid << min[0] + i * cellWidth + cellWidth / 2., max[1], min[2] + j * cellHeight + cellHeight / 2., 1.;
dist = (vertex->pos - backMid).norm();
if (! points[1][i][j].vertex || dist < points[1][i][j].dist) {
points[1][i][j].vertex = vertex;
points[1][i][j].dist = dist;
}
}
}
return points;
}
HullGridPoints::HullGridPoint*** HullGridPoints::findXYHullPoints(Data::Part* part, int n, int m)
{
HullGridPoints::HullGridPoint*** points = new HullGridPoints::HullGridPoint**[2]; // back and front
points[0] = new HullGridPoints::HullGridPoint*[n];
points[1] = new HullGridPoints::HullGridPoint*[n];
for (int i=0; i<n; i++) {
points[0][i] = new HullGridPoints::HullGridPoint[m]();
points[1][i] = new HullGridPoints::HullGridPoint[m]();
}
// XY plane
Eigen::Vector3f min = part->boundingBox.min();
Eigen::Vector3f max = part->boundingBox.max();
float width = max[0] - min[0];
float height = max[1] - min[1];
float cellWidth = width / n;
float cellHeight = height / m;
for (auto rit = part->regions.begin(); rit != part->regions.end(); rit++) {
Data::Region* region = (*rit);
for (auto vit = (*rit)->vertices.begin(); vit != (*rit)->vertices.end(); vit++) {
Data::Vertex* vertex = (*vit);
int i = int((vertex->pos[0] - min[0]) / cellWidth);
int j = int((vertex->pos[1] - min[1]) / cellHeight);
i = (i >= n) ? n-1 : i;
j = (j >= m) ? m-1 : j;
Eigen::Vector4f frontMid;
Eigen::Vector4f backMid;
float dist;
frontMid << min[0] + i * cellWidth + cellWidth / 2., min[1] + j * cellHeight + cellHeight / 2., min[2], 1.;
dist = (vertex->pos - frontMid).norm();
if (! points[0][i][j].vertex || dist < points[0][i][j].dist) {
points[0][i][j].vertex = vertex;
points[0][i][j].dist = dist;
}
backMid << min[0] + i * cellWidth + cellWidth / 2., min[1] + j * cellHeight + cellHeight / 2., max[2], 1.;
dist = (vertex->pos - backMid).norm();
if (! points[1][i][j].vertex || dist < points[1][i][j].dist) {
points[1][i][j].vertex = vertex;
points[1][i][j].dist = dist;
}
}
}
return points;
}
HullGridPoints::HullGridPoint*** HullGridPoints::findYZHullPoints(Data::Part* part, int n, int m)
{
HullGridPoints::HullGridPoint*** points = new HullGridPoints::HullGridPoint**[2]; // back and front
points[0] = new HullGridPoints::HullGridPoint*[n];
points[1] = new HullGridPoints::HullGridPoint*[n];
for (int i=0; i<n; i++) {
points[0][i] = new HullGridPoints::HullGridPoint[m]();
points[1][i] = new HullGridPoints::HullGridPoint[m]();
}
// YZ plane
Eigen::Vector3f min = part->boundingBox.min();
Eigen::Vector3f max = part->boundingBox.max();
float width = max[1] - min[1];
float height = max[2] - min[2];
float cellWidth = width / n;
float cellHeight = height / m;
for (auto rit = part->regions.begin(); rit != part->regions.end(); rit++) {
Data::Region* region = (*rit);
for (auto vit = (*rit)->vertices.begin(); vit != (*rit)->vertices.end(); vit++) {
Data::Vertex* vertex = (*vit);
int i = int((vertex->pos[1] - min[1]) / cellWidth);
int j = int((vertex->pos[2] - min[2]) / cellHeight);
i = (i >= n) ? n-1 : i;
j = (j >= m) ? m-1 : j;
Eigen::Vector4f frontMid;
Eigen::Vector4f backMid;
float dist;
frontMid << min[0], min[1] + i * cellWidth + cellWidth / 2., min[2] + j * cellHeight + cellHeight / 2., 1.;
dist = (vertex->pos - frontMid).norm();
if (! points[0][i][j].vertex || dist < points[0][i][j].dist) {
points[0][i][j].vertex = vertex;
points[0][i][j].dist = dist;
}
backMid << max[0], min[1] + i * cellWidth + cellWidth / 2., min[2] + j * cellHeight + cellHeight / 2., 1.;
dist = (vertex->pos - backMid).norm();
if (! points[1][i][j].vertex || dist < points[1][i][j].dist) {
points[1][i][j].vertex = vertex;
points[1][i][j].dist = dist;
}
}
}
return points;
}
|
a195994a925ffe9e0b8a939ea1fed4fba47bc818 | 144338f53b85d4d5b31f127a594f59ce97bbac45 | /NonUniformSplineKnotsVS/NonBufferedFullAlgorithm.cpp | bc949a3264fc74f02a9b3cd4cad3ca486eeefa4a | [] | no_license | vildibald/2ndRedducedUniformSplineKnotsVS | 22189390ae22dd9571de19f2eb67047e92d7926b | 88593be58e124300d797ff57ff9d605b9a41b8cc | refs/heads/master | 2020-03-08T21:55:58.406982 | 2018-04-06T16:17:48 | 2018-04-06T16:17:48 | 116,498,119 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 177 | cpp | NonBufferedFullAlgorithm.cpp | #include "stdafx.h"
#include "NonBufferedFullAlgorithm.h"
NonBufferedFullAlgorithm::NonBufferedFullAlgorithm()
{
}
NonBufferedFullAlgorithm::~NonBufferedFullAlgorithm()
{
}
|
125683ff950a5dc9f13aead526b4f79a34815a2e | 4494a98250e12bd954ac966916bc7d9a2b4bbbe6 | /plugins/user/user_mysql.h | a629eccd6954e2565a4cf9c42b77ab5006890eca | [
"Apache-2.0"
] | permissive | mengya9/SWP | 74a857146ce9e66f610f888ab684a15b239faac8 | 851cb1b8ad92260c76b560416e20ea6a592d8469 | refs/heads/master | 2021-01-12T01:28:59.564660 | 2017-02-27T12:06:30 | 2017-02-27T12:06:30 | 78,391,891 | 0 | 0 | null | 2017-01-09T03:51:18 | 2017-01-09T03:51:18 | null | UTF-8 | C++ | false | false | 4,117 | h | user_mysql.h | // Copyright (c) 2016 The tourism Authors. All rights reserved.
// user_mysql.h
// Created on: 2016年8月16日.
// Author: Paco.
#ifndef PLUGINS_USER_USER_MYSQL_H_
#define PLUGINS_USER_USER_MYSQL_H_
#include "public/config/config.h"
#include "public/basic/basictypes.h"
#include "pub/storage/data_engine.h"
//#include "pub/net/typedef.h"
namespace user {
//用户充值状态
#define CREDIT_INPROCESS "1" //处理中
#define CREDIT_SUCCESS "2"
#define CREDIT_FAIL "3"
//用户充值数据库状态
#define DB_CREDIT_INPROCESS_STR "0,"
#define DB_CREDIT_CLIENT_SUCCESS_STR "1,"
#define DB_CREDIT_CLIENT_FAIL_STR "2,"
#define DB_CREDIT_SERVER_SUCCESS_STR "3,"
#define DB_CREDIT_SERVER_FAIL_STR "4,"
#define DB_CREDIT_INPROCESS 0
#define DB_CREDIT_CLIENT_SUCCESS 1
#define DB_CREDIT_CLIENT_FAIL 2
#define DB_CREDIT_SERVER_SUCCESS 3
#define DB_CREDIT_SERVER_FAIL 4
enum FlowType {
DEPOSIT = 1, //入金
WITHDRAW, //出金
OPEN_POSITION, //建仓
CLOSE_POSITION //平仓
};
class UserMysql {
public:
UserMysql(config::FileConfig* config);
~UserMysql();
public:
int32 UserInfoSelect(std::string uids, base_logic::DictionaryValue* dic);
int32 AccountInfoSelect(int64 uid, base_logic::DictionaryValue* dic);
int32 OrderListSelect(int64 uid, std::string flow_type, int32 start_pos,
int32 count, base_logic::DictionaryValue* dic);
int32 OrderDetailSelect(int64 uid, int64 flow_id, int32 flow_type,
base_logic::DictionaryValue* dic);
int32 BankcardListSelect(int64 uid, base_logic::DictionaryValue* dic);
int32 BindBankcardInsertAndSelect(int64 uid, int32 bank_id, std::string branch_bank,
std::string card_no, std::string bank_username, base_logic::DictionaryValue* dic);
int32 UnbindBankcardDelete(std::string phone_num, int32 bank_id);
int32 ChangeDefaultBankcard(int64 uid, int32 bank_id);
int32 BankAccountInfoSelect(std::string account, base_logic::DictionaryValue* dic);
int32 CreditListSelect(int64 uid, std::string status, int64 start_pos, int64 count, base_logic::DictionaryValue* dic);
int32 CreditDetailSelect(int64 uid, int64 recharge_id, base_logic::DictionaryValue* dic);
int32 UserWithdrawInsertAndSelect(int64 uid, double money,
int64 bankcard_id, std::string passwd, base_logic::DictionaryValue* dic);
int32 UserWithdrawListSelect(int64 uid, std::string status,
int64 startPos, int64 count, base_logic::DictionaryValue* dic);
// int32 UserWithdrawDetailSelect(int64 uid, int64 withdraw_id, base_logic::DictionaryValue* dic);
int32 RechargeInfoInsertAndSelect(int64 uid, double price, base_logic::DictionaryValue* dic);
int32 ChangeRechargeStatusAndSelect(int64 rid, int64 result, base_logic::DictionaryValue* dic);
int32 ChangeUserInfoUpdate(int64 uid, std::string nickname,
std::string headurl, int64 gender);
int32 DeviceTokenUpdate(int64 uid, std::string dt);
static void CallUserInfoSelect(void* param, base_logic::Value* value);
static void CallAccountInfoSelect(void* param, base_logic::Value* value);
static void CallOrderListSelect(void* param, base_logic::Value* value);
static void CallOrderDetailSelect(void* param, base_logic::Value* value);
// static void CallBankCardListSelect(void* param, base_logic::Value* value);
static void CallBindBankcardInsertAndSelect(void* param, base_logic::Value* value);
static void CallBankAccountInfoSelect(void* param, base_logic::Value* value);
static void CallCreditListSelect(void* param, base_logic::Value* value);
static void CallCreditDetailSelect(void* param, base_logic::Value* value);
static void CallBankcardListSelect(void* param, base_logic::Value* value);
static void CallUserWithdrawInsertAndSelect(void* param, base_logic::Value* value);
static void CallUserWithdrawListSelect(void* param, base_logic::Value* value);
static void CallRechargeInfoInsertAndSelect(void* param, base_logic::Value* value);
static void CallChangeRechargeStatusAndSelect(void* param, base_logic::Value* value);
private:
base_logic::DataEngine* mysql_engine_;
};
} // namespace user
#endif // PLUGINS_USER_USER_MYSQL_H_
|
9db45e0b5c29bc5fb2c95602a8b964f78c677c62 | ad7711ab0bf1682723d3f9cb3a5c526d12b23a58 | /main.cpp | ed2b1bd8ed35907981459223f6f4a8cc2a49d873 | [] | no_license | cust2112/otus_cpp_p_DZ_4 | 47fe6f430c72efa9feeb289753cbaa4a4ed1ae26 | 8d582c23f9c6624d345887abc5a7cdbd7fcbfa81 | refs/heads/master | 2023-07-16T14:47:08.284301 | 2021-08-30T12:19:54 | 2021-08-30T12:19:54 | 396,700,728 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 241 | cpp | main.cpp |
#include "common/utils.h"
#include "editor/editor.h"
#include "gui/textmodeui/textmodeui.h"
int main ()
{
TextModeUI gui;
Editor editor (gui); USED_IMPLICITLY (editor);
gui.startEventLoop ();
return 0;
}
|
b9fa30f89db6bd28480837e8a38d93ab83d71f37 | 6af4068cf5ce7bf3f198c1c61b2507d723b838ad | /tree_binary_search/findAncestorsOfGivenTree.cpp | 7efabd706bbe90956063551c6efb9ff2fe76240d | [] | no_license | monk78/Standard-Algorithms | 87a06b8614b8bf73d56eaa6f7fda1507944a98db | ad31a7adb2560150509a6476878cfdadc7a5fdc4 | refs/heads/master | 2023-02-26T10:41:29.570831 | 2021-01-29T12:45:00 | 2021-01-29T12:45:00 | 290,782,763 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,496 | cpp | findAncestorsOfGivenTree.cpp | /** Author:Monk_
* Topic:inorder traversal without using recursion with the help of stack binary Tree **/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define _for(i,a,b) for(i=a;i<b;i++)
#define _rfor(i,a,b) for(i=a;i>=b;i--)
#define mp(a,b) make_pair(a,b)
void fast(){
ios_base::sync_with_stdio(false);
cout.tie(NULL);
}
class Node{
public:
int data;
Node *left,*right;
Node(int d){
data=d;
left=NULL;
right=NULL;
}
};
Node *buildTree(){
int d;
cin>>d;
if(d==-1)return NULL;
Node *root=new Node(d);
root->left=buildTree();
root->right=buildTree();
return root;
}
void printIn(Node *root){
stack<Node*>st;
Node *curr=root;
while(curr!=NULL||(!st.empty())){
while(curr!=NULL){
st.push(curr);
curr=curr->left;
}
curr=st.top();
st.pop();
cout<<curr->data<<" ";
curr=curr->right;
}
}
bool Ancestor(Node *root,int target){
//Node *curr=root;
if(root==NULL)return false;
if(root->data==target)return true;
if(Ancestor(root->left,target)||Ancestor(root->right,target)){
cout<<root->data<<" ";
return true;
}
return false;
}
int main(){
fast();
int t;
Node *root=buildTree();
cout<<"without Ancestor the program is:"<<endl;
printIn(root);
cout<<"\nenter target:";
cin>>t;
cout<<"with ancestors:"<<endl;
Ancestor(root,t);
return 0;
}
|
45fdd3ed5cd09f86e7b19f6c8129c42df4363307 | 5d83739af703fb400857cecc69aadaf02e07f8d1 | /Archive2/fd/9ae26e5c0e99e4/main.cpp | 77fcef4509ee201c20ba0083dafb144b11ad8c5f | [] | no_license | WhiZTiM/coliru | 3a6c4c0bdac566d1aa1c21818118ba70479b0f40 | 2c72c048846c082f943e6c7f9fa8d94aee76979f | refs/heads/master | 2021-01-01T05:10:33.812560 | 2015-08-24T19:09:22 | 2015-08-24T19:09:22 | 56,789,706 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 609 | cpp | main.cpp | #include <iostream>
#include <memory>
#include <new>
struct MyClass {
char c;
char d;
virtual ~MyClass() {} // needed for introducing overhead
void *operator new[](std::size_t count) {
void *p = ::operator new[](count);
std::cout << "allocating " << count << " bytes\n";
return p;
}
};
int main() {
for( auto count : { 1, 5, 10, 20 } ) {
std::cout << "allocating " << sizeof(MyClass) << " * " << count << " items\n";
auto x = new MyClass[count];
delete[] x;
}
}
|
57da3a92c76fa1f29fe237fe138734707956321b | 83de5cee4d261df631d745087c47227ddcb77a3a | /RCX2_IR_Programmer1/RCX2_IR_Programmer1.ino | 78a1603f2d9959b854043dbc08196fa78a4b2536 | [] | no_license | BobGenom/arduino_sketches | 2a44e2e4e750839cc1c25efe1306b030a642dece | 518e69b3acee2950a98f802a61cca655e34d6cb6 | refs/heads/master | 2021-01-13T00:59:36.300948 | 2016-03-16T19:12:35 | 2016-03-16T19:12:35 | 49,028,733 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,083 | ino | RCX2_IR_Programmer1.ino | #include <SoftwareSerial.h>
/**
* Hardware layout for the RCX Programmer. Version 1.1.0
*
* Pin usage IR LED and TSOP for 950nm and 38kHz carrier:
*
* IR-LED:SFH-409 TSOP 31236
* cathode anode
* - + Data VCC GND
* | | | | |
* | | | | |
* | | | | |
* | | | | |
* | | | |
* 9 10 11 12 13 GND
*
* ARDUINO
*
* Precondition
* Arduino drivers are installed.
*
*
* Description
*
* Producing the carrier 38khz when sending
* a data byte over IR is done busy waiting and not using interrupts.
* All timing values in function send(data) are manualy optimized for
* a 16MHz ATmega32u4. So this (not using interupts) is a more
* generic solution which should work on many Arduino flavours.
*
* A future version might use interrupts.
*
*/
#define RX_PIN 11
#define RX_ON_OFF 13
#define TX_PIN 10
#define TX_ON_OFF 9
SoftwareSerial mySerial(RX_PIN, 12); // RX, TX
/**
* to calculate parity
*/
int CountSetBits (int x)
{
int count = 0;
for (int n=0; n<16; ++n) {
if (x & (1<<n)) {
++count;
}
}
return count;
}
#define STOPBIT 0x400
#define PARITYBIT 0x200
/**
* send 11 bits like this:
* 1 start bit 0
* 8 data bits
* 1 odd parity bit 1
* 1 stop bit 1
*/
void send(int data) {
data= (data<<1) | ((CountSetBits(data)&1)?0:PARITYBIT) | STOPBIT;
noInterrupts();
for(uint8_t b=11; b; b--) {
if(data&1){
for(uint8_t i=0; i<14; i++) {
digitalWrite(TX_PIN, LOW);
delayMicroseconds(7);
digitalWrite(TX_PIN, LOW);
delayMicroseconds(7);
}
} else {
for(uint8_t i=0; i<14; i++) {
digitalWrite(TX_PIN, HIGH);
delayMicroseconds(7);
digitalWrite(TX_PIN, LOW);
delayMicroseconds(7);
}
}
data>>=1;
}
interrupts();
}
void powerRX(int mode) {
pinMode(RX_ON_OFF, OUTPUT);
digitalWrite(RX_ON_OFF, mode);
}
void powerTX() {
pinMode(TX_PIN, OUTPUT);
pinMode(TX_ON_OFF, OUTPUT);
digitalWrite(TX_ON_OFF, LOW);
}
void setup() {
Serial.begin(2400);
while (!Serial){
; // wait for a Serial to connect to save TSOP power
}
powerRX(HIGH);
powerTX();
mySerial.begin(2400);
}
void loop() { // run over and over
static int r,s;
static long t0;
static uint8_t state=0;
if (mySerial.available()) {
r=mySerial.read();
if (state!=1 || r!=255) {
Serial.write(r);
state=2;
} else {
state=3;
}
}
if (Serial.available()) {
s=Serial.read();
// fake a (full duplex) IR echo to make lejosfirmdl happy
Serial.write(s);
send(s);
powerRX(HIGH);
state=1;
t0=millis();
}
if (millis()-t0>10000) {
if (state==0) {
} else {
// shut down TSOP after 10secs Serial silence to save power
powerRX(LOW);
state=0;
}
t0=millis();
}
}
|
4254c3f0f4e9f4c06200f38bbd00621ed18841f7 | a0848fcf9dbc171549aadb9de9b331e8e72a9fd9 | /C15_constexpr.cpp | 9dd213d5104c805248f3fdbc0f75b3bcd001a8c3 | [] | no_license | CK-Han/ModernEffectiveC-Study | 1d212e73ffc1a14cbf1376a3b0d4cfa06be511ba | 6823690358b320a00fcfc6b7f7f56c37199c5511 | refs/heads/master | 2021-05-14T01:55:20.124940 | 2018-01-11T16:53:24 | 2018-01-11T16:53:24 | 116,580,529 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 521 | cpp | C15_constexpr.cpp | #include <iostream>
using namespace std;
class Point
{
public:
constexpr Point(double _x, double _y) : x(_x), y(_y) {}
constexpr double GetX() const noexcept { return x; }
constexpr double GetY() const noexcept { return y; }
//constexpr void SetX(double newX) noexcept { x = newX; }
private:
double x, y;
};
constexpr Point
GetPointAdded(const Point& p1, const Point& p2)
{
return{ p1.GetX() + p2.GetX(), p1.GetY() + p2.GetY() };
}
void main()
{
constexpr auto t = GetPointAdded(Point(3,4), Point(5,2));
}
|
c9e8e67aa3b0340f20efafbac20f2ee5bdf60c64 | 35b34bc82a6f04104d1bf18506d0761dcaee3996 | /src/maze.cpp | 442883a63ba2957cdb8452941ae2d9165c8eb865 | [] | no_license | destinyson7/Among-Us | e2e8fc59607cff0bb65b42b2d5cd6d8fd9626d73 | 57f224f6a1a5f2a239e60901eeb870063232fe4a | refs/heads/main | 2023-03-29T05:56:59.720908 | 2021-04-01T17:54:59 | 2021-04-01T17:54:59 | 352,773,344 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,709 | cpp | maze.cpp | #include "maze.h"
#include <iostream>
#include <stack>
#include <vector>
template <class Ch, class Tr, class Container>
basic_ostream<Ch, Tr> &operator<<(basic_ostream<Ch, Tr> &os, Container const &x)
{
os << "{ ";
for (auto &y : x)
{
os << y << " ";
}
return os << "}";
}
template <class X, class Y>
ostream &operator<<(ostream &os, pair<X, Y> const &p)
{
return os << "[" << p.ff << ", " << p.ss << "]";
}
Maze::Maze(Shader &shader)
{
this->shader = shader;
this->translate = glm::vec3(-0.75f, -0.55f, 0.0f);
this->initRenderData();
}
Maze::~Maze()
{
glDeleteVertexArrays(1, &this->quadVAO);
}
void Maze::DrawMaze()
{
// prepare transformations
this->shader.Use();
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, this->translate);
this->shader.SetMatrix4("model", model);
glBindVertexArray(this->quadVAO);
glDrawArrays(GL_LINES, 0, this->n_edges);
glBindVertexArray(0);
}
vector<float> Maze::GenerateMaze(float edge_length, pair<int, int> start_position)
{
// GameObject maze[this->MAZE_WIDTH][this->MAZE_HEIGHT];
for (int i = 0; i < this->MAZE_HEIGHT; i++)
{
for (int j = 0; j < this->MAZE_WIDTH; j++)
{
this->maze[i][j].bottom_left = {(float)(j * edge_length), (float)(i * edge_length)};
this->maze[i][j].top_left = {(float)(j * edge_length), (float)((i + 1) * edge_length)};
this->maze[i][j].bottom_right = {(float)((j + 1) * edge_length), (float)(i * edge_length)};
this->maze[i][j].top_right = {(float)((j + 1) * edge_length), (float)((i + 1) * edge_length)};
// cout << edge_length << endl;
// cout << mp((float)((j + 1) * edge_length), (float)((i + 1) * edge_length)) << endl;
}
}
// cout << this->maze << endl;
stack<pii> s;
s.push(mp(0, 0));
while (!s.empty())
{
pii top = s.top();
s.pop();
bool check = false;
if (top.ff + 1 < this->MAZE_HEIGHT && !((this->maze[top.ff + 1][top.ss]).visited))
{
check = true;
}
if (top.ff - 1 >= 0 && !((this->maze[top.ff - 1][top.ss]).visited))
{
check = true;
}
if (top.ss + 1 < this->MAZE_WIDTH && !((this->maze[top.ff][top.ss + 1]).visited))
{
check = true;
}
if (top.ss - 1 >= 0 && !((this->maze[top.ff][top.ss - 1]).visited))
{
check = true;
}
if (!check)
{
continue;
}
s.push(top);
while (true)
{
int where = rand() % 4;
int r = top.ff, c = top.ss;
if (where == 0 && c + 1 < this->MAZE_WIDTH && !((this->maze[r][c + 1]).visited))
{
s.push(mp(r, c + 1));
this->maze[r][c + 1].visited = true;
this->maze[r][c].IS_RIGHT_OPEN = 1;
this->maze[r][c + 1].IS_LEFT_OPEN = 1;
break;
}
if (where == 1 && c - 1 >= 0 && !((this->maze[r][c - 1]).visited))
{
s.push(mp(r, c - 1));
this->maze[r][c - 1].visited = true;
this->maze[r][c].IS_LEFT_OPEN = 1;
this->maze[r][c - 1].IS_RIGHT_OPEN = 1;
break;
}
if (where == 2 && r + 1 < this->MAZE_HEIGHT && !((this->maze[r + 1][c]).visited))
{
s.push(mp(r + 1, c));
this->maze[r + 1][c].visited = true;
this->maze[r][c].IS_TOP_OPEN = 1;
this->maze[r + 1][c].IS_BOTTOM_OPEN = 1;
break;
}
if (where == 3 && r - 1 >= 0 && !((this->maze[r - 1][c]).visited))
{
s.push(mp(r - 1, c));
this->maze[r - 1][c].visited = true;
this->maze[r][c].IS_BOTTOM_OPEN = 1;
this->maze[r - 1][c].IS_TOP_OPEN = 1;
break;
}
}
}
// cout << "** " << this->n_edges << endl;
vector<float> vertices_vec;
// int ind = 0;
for (int i = 0; i < this->MAZE_HEIGHT; i++)
{
for (int j = 0; j < this->MAZE_WIDTH; j++)
{
// cout << "****" << endl;
if (!((this->maze[i][j]).IS_BOTTOM_OPEN))
{
vertices_vec.push_back((this->maze[i][j]).bottom_left.first);
vertices_vec.push_back((this->maze[i][j]).bottom_left.second);
vertices_vec.push_back((this->maze[i][j]).bottom_right.first);
vertices_vec.push_back((this->maze[i][j]).bottom_right.second);
(this->edges).pb(mp(this->maze[i][j].bottom_left, this->maze[i][j].bottom_right));
}
if (!((this->maze[i][j]).IS_TOP_OPEN))
{
vertices_vec.push_back((this->maze[i][j]).top_left.first);
vertices_vec.push_back((this->maze[i][j]).top_left.second);
vertices_vec.push_back((this->maze[i][j]).top_right.first);
vertices_vec.push_back((this->maze[i][j]).top_right.second);
(this->edges).pb(mp(this->maze[i][j].top_left, this->maze[i][j].top_right));
}
if (!((this->maze[i][j]).IS_LEFT_OPEN))
{
vertices_vec.push_back((this->maze[i][j]).bottom_left.first);
vertices_vec.push_back((this->maze[i][j]).bottom_left.second);
vertices_vec.push_back((this->maze[i][j]).top_left.first);
vertices_vec.push_back((this->maze[i][j]).top_left.second);
(this->edges).pb(mp(this->maze[i][j].bottom_left, this->maze[i][j].top_left));
}
if (!((this->maze[i][j]).IS_RIGHT_OPEN))
{
vertices_vec.push_back((this->maze[i][j]).bottom_right.first);
vertices_vec.push_back((this->maze[i][j]).bottom_right.second);
vertices_vec.push_back((this->maze[i][j]).top_right.first);
vertices_vec.push_back((this->maze[i][j]).top_right.second);
(this->edges).pb(mp(this->maze[i][j].bottom_right, this->maze[i][j].top_right));
}
}
}
this->FloydWarshall();
// cout << this->n_edges << " " << ind << endl;
// assert(ind == n_vertices * 4);
return vertices_vec;
}
void Maze::FloydWarshall()
{
for (int i = 0; i < this->MAZE_HEIGHT * this->MAZE_WIDTH; i++)
{
for (int j = 0; j < this->MAZE_HEIGHT * this->MAZE_WIDTH; j++)
{
this->dist[i][j] = 1e8;
}
}
for (int i = 0; i < this->MAZE_HEIGHT * this->MAZE_WIDTH; i++)
{
this->dist[i][i] = 0;
}
for (int i = 0; i < this->MAZE_HEIGHT; i++)
{
for (int j = 0; j < this->MAZE_WIDTH; j++)
{
if ((this->maze[i][j]).IS_BOTTOM_OPEN)
{
int ff = i * MAZE_WIDTH + j;
int ss = (i - 1) * MAZE_WIDTH + j;
this->dist[ff][ss] = 1;
this->dist[ss][ff] = 1;
}
if ((this->maze[i][j]).IS_TOP_OPEN)
{
int ff = i * MAZE_WIDTH + j;
int ss = (i + 1) * MAZE_WIDTH + j;
this->dist[ff][ss] = 1;
this->dist[ss][ff] = 1;
}
if ((this->maze[i][j]).IS_LEFT_OPEN)
{
int ff = i * MAZE_WIDTH + j;
int ss = i * MAZE_WIDTH + j - 1;
this->dist[ff][ss] = 1;
this->dist[ss][ff] = 1;
}
if ((this->maze[i][j]).IS_RIGHT_OPEN)
{
int ff = i * MAZE_WIDTH + j;
int ss = i * MAZE_WIDTH + j + 1;
this->dist[ff][ss] = 1;
this->dist[ss][ff] = 1;
}
}
}
int n = MAZE_HEIGHT * MAZE_WIDTH;
for (int k = 0; k < n; k++)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
this->dist[i][j] = min(this->dist[i][j], this->dist[i][k] + this->dist[k][j]);
}
}
}
}
void Maze::initRenderData()
{
// configure VAO/VBO
unsigned int VBO;
// float vertices[] = {
// // pos // tex
// 0.0f, 1.0f, 0.0f, 1.0f,
// 1.0f, 0.0f, 1.0f, 0.0f,
// 0.0f, 0.0f, 0.0f, 0.0f,
// 0.0f, 1.0f, 0.0f, 1.0f,
// 1.0f, 1.0f, 1.0f, 1.0f,
// 1.0f, 0.0f, 1.0f, 0.0f};
vector<float> vertices_vec = GenerateMaze(this->EDGE_LENGTH, {0, 0});
int len_vertices = vertices_vec.size();
this->n_edges = len_vertices;
// cout << vertices_vec << endl;
float vertices[len_vertices];
cout << "len " << len_vertices << endl;
for (int i = 0; i < len_vertices; i++)
{
vertices[i] = vertices_vec[i];
}
glGenVertexArrays(1, &this->quadVAO);
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindVertexArray(this->quadVAO);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void *)0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
|
0e50e5b4f8dae40b5cac9f4c3475e34770aefd3d | ba33db2bc7f3c8f5ba5355294b2ab6f5faec97c2 | /src/amun/gpu/mblas/vector.h | ce3a9eaeb2f29bac98867ca15a35b3221f17147e | [
"MIT"
] | permissive | skoppula/amun | 5060c132ab22b8310cbf1c603c7a4a77ef65a9ad | 0905c43827a0a725f4e4c4bdd3866f6fa5e91df9 | refs/heads/master | 2020-04-05T21:53:40.494624 | 2018-11-12T19:49:55 | 2018-11-12T19:49:55 | 157,237,286 | 0 | 0 | NOASSERTION | 2018-11-12T15:47:22 | 2018-11-12T15:47:21 | null | UTF-8 | C++ | false | false | 3,853 | h | vector.h | #pragma once
/*
* Vector.h
*
* Created on: 8 Dec 2016
* Author: hieu
*/
#include "gpu/types-gpu.h"
namespace amunmt {
namespace GPU {
namespace mblas {
template<typename T>
class Vector
{
public:
Vector()
:size_(0)
,maxSize_(0)
,data_(nullptr)
{
}
Vector(unsigned size)
:maxSize_(0)
,data_(nullptr)
{
newSize(size);
}
Vector(unsigned size, const T &val)
:maxSize_(0)
,data_(nullptr)
{
newSize(size);
if (val) {
abort();
}
else {
HANDLE_ERROR(cudaMemsetAsync(data_, 0, size_ * sizeof(float), CudaStreamHandler::GetStream()));
}
}
Vector(const std::vector<T> &vec)
:maxSize_(0)
{
newSize(vec.size());
HANDLE_ERROR( cudaMemcpyAsync(data_, vec.data(), vec.size() * sizeof(T), cudaMemcpyHostToDevice, CudaStreamHandler::GetStream()) );
}
Vector(const Vector<T> &other)
:maxSize_(other.size_)
,size_(other.size_)
{
HANDLE_ERROR( cudaMalloc(&data_, size_ * sizeof(T)) );
//std::cerr << "malloc data2:" << data_ << std::endl;
HANDLE_ERROR( cudaMemcpyAsync(
data_,
other.data_,
size_ * sizeof(T),
cudaMemcpyDeviceToDevice,
CudaStreamHandler::GetStream()) );
}
~Vector()
{
//std::cerr << "~Vector=" << this << std::endl;
HANDLE_ERROR(cudaFree(data_));
}
unsigned size() const
{ return size_; }
unsigned maxSize() const
{ return maxSize_; }
T *data()
{ return data_; }
const T *data() const
{ return data_; }
void resize(unsigned newSize)
{
if (newSize > maxSize_) {
T *newData;
HANDLE_ERROR( cudaMalloc(&newData, newSize * sizeof(T)) );
if (maxSize_) {
assert(data_);
HANDLE_ERROR( cudaMemcpyAsync(
newData,
data_,
size_ * sizeof(T),
cudaMemcpyDeviceToDevice,
CudaStreamHandler::GetStream()) );
HANDLE_ERROR(cudaFree(data_));
}
else {
assert(data_ == nullptr);
}
data_ = newData;
maxSize_ = newSize;
}
size_ = newSize;
}
void newSize(unsigned newSize)
{
reserve(newSize);
size_ = newSize;
}
void reserve(unsigned newSize)
{
if (newSize > maxSize_) {
if (maxSize_) {
HANDLE_ERROR(cudaFree(data_));
}
HANDLE_ERROR( cudaMalloc(&data_, newSize * sizeof(T)) );
maxSize_ = newSize;
}
}
void clear()
{
size_ = 0;
}
void swap(Vector &other)
{
std::swap(size_, other.size_);
std::swap(maxSize_, other.maxSize_);
std::swap(data_, other.data_);
}
virtual std::string Debug(unsigned verbosity = 1) const
{
std::stringstream strm;
strm << size_ << " " << std::flush;
if (verbosity == 1) {
HANDLE_ERROR( cudaStreamSynchronize(CudaStreamHandler::GetStream()));
unsigned maxCol = std::min((unsigned) 2, size());
T tmp[2];
HANDLE_ERROR( cudaMemcpy(tmp, data(), maxCol * sizeof(T), cudaMemcpyDeviceToHost) );
for (size_t i = 0; i < maxCol; ++i) {
strm << " " << tmp[i];
}
if (size() > 3) {
strm << "...";
HANDLE_ERROR( cudaMemcpy(tmp, data() + size() - maxCol, maxCol * sizeof(T), cudaMemcpyDeviceToHost) );
for (size_t i = 0; i < maxCol; ++i) {
strm << tmp[i] << " ";
}
}
}
else if (verbosity == 2) {
T h_data[size()];
const cudaStream_t& stream = CudaStreamHandler::GetStream();
HANDLE_ERROR( cudaMemcpyAsync(
&h_data,
data(),
size() * sizeof(T),
cudaMemcpyDeviceToHost,
stream) );
HANDLE_ERROR( cudaStreamSynchronize(stream) );
for (unsigned i = 0; i < size(); ++i) {
strm << " " << h_data[i];
}
}
return strm.str();
}
protected:
unsigned size_, maxSize_;
T *data_;
};
}
}
}
|
a5f575ee147b090abe880f4b7b985a51cc3a01c8 | 72f38989dc70662c56041415fcf5e591b5920c8d | /Widgets/gamewidget.h | 6d83e3a6cd5886df42b84fd02ed1c846fb416f47 | [] | no_license | QrveFeverTeam/QrveFever | f295b338bd83f4af31a2d61a9a7ce8531a9aa53a | 80439339f339f5eb089a95f51653bb0bae7b4e81 | refs/heads/master | 2016-09-10T12:48:44.944438 | 2013-06-13T11:52:20 | 2013-06-13T11:52:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 566 | h | gamewidget.h | #ifndef GAMEWIDGET_H
#define GAMEWIDGET_H
#include <QWidget>
#include "datatypes.h"
#include "Game/game.h"
namespace Ui {
class GameWidget;
}
class GameWidget : public QWidget
{
Q_OBJECT
public:
explicit GameWidget(const QList<UserData>& users, QWidget *parent = 0);
~GameWidget();
Game* game() const;
private:
Ui::GameWidget *ui;
Game* m_game;
signals:
void exit();
private slots:
void on_pushButton_clicked();
void toReachChanged(int toReach);
void finished(const QString& winner);
};
#endif // GAMEWIDGET_H
|
7d20f0e1da6d8c718fea7dc40fb51eda5e45e4c8 | c61bb26df0a79a69a895d5de72b9389fbc454235 | /case-lmac-core-2/ila/src/lmac_core_2.cc | 7807dbf0a4fc09e5c53a808872ed12cbed41f097 | [
"MIT"
] | permissive | Bo-Yuan-Huang/FwSynth | 8ba1bef8bf11ffa04d98d81a0ec79c6cd2fdf0f4 | 7d3b4872d437e03cf6334354215faa23a1539195 | refs/heads/master | 2020-04-25T18:06:42.412698 | 2019-05-06T18:39:10 | 2019-05-06T18:39:10 | 172,973,298 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 338 | cc | lmac_core_2.cc | // lmac_core_2.cc
//
// The implementation of the LMAC-CORE-2 ILA.
//
// References:
// - https://github.com/lewiz-support/LMAC_CORE2
#include <ilang/ilang++.h>
#include <ilang/util/log.h>
#include <lmac_core_2/lmac_core_2.h>
void ExportLmacCore2ToFile(const std::string& file_name) {
auto m = ilang::Ila("lmac_core_2");
return;
}
|
c21106651b5a0c5d95c644ceeb68908d6332f70c | 7409c20db411b8615ce4fa5809f953996e4b1da5 | /trunk/source2/jam_generator.h | f387b7687f15281a094125de6a5a3ff752e4246e | [] | no_license | jfinn24985/butter | bc997213520c9cc1552fbac62c63f093f393d137 | d09e89c8f358267349f67d3bd3fa8706372ab1c8 | refs/heads/master | 2021-12-31T21:17:41.586261 | 2021-05-02T20:00:03 | 2021-05-02T20:00:03 | 124,422,694 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,193 | h | jam_generator.h | #ifndef BUTTER_JAM_GENERATOR_H
#define BUTTER_JAM_GENERATOR_H
#include "generator.h"
#include "basic_style.h"
#include <qstring.h>
#include <memory>
#include <qtextstream.h>
namespace butter { class base_generator; }
namespace butter { class compound_artifact; }
namespace butter { class location; }
namespace butter {
//Build file generator for standard jam.
//
//This is the build system generator of choice as is supports the widest range of
//build options.
//
//\cond XDOC
//<style style="make">
//<limitation>The <code>standard</code> jam tool does not provide
//a shared library target. Providing a shared library for this style is on
//the <link target="todo">TODO list</link>.</limitation>
//\endcond XDOC
class jam_generator : public generator<jam_generator> {
template <class derived> friend class generator;
public:
static const basic_style style;
static const QString build_file_name;
static const QString build_file_sysname;
private:
//A template Jamrules.
static const char * default_rules[];
public:
//The name of the jam rules document.
static const QString rules_name;
private:
//Text for the a main targets associated sub-targets
QString lib_defn_;
//Jam "Grist" of the current target location. Set in initialisation.
QString grist_;
//The full target name for the currently processing target (defined in start_target)
QString qualified_target_name_;
//Main ctor, takes top-level a_project.
//
//\pre a_project.parent = nul
jam_generator();
//no copy
jam_generator(const jam_generator & ) = delete;
//no copy
jam_generator(jam_generator && source) = delete;
//no assign
jam_generator & operator =(const jam_generator & ) = delete;
public:
inline ~jam_generator() {};
//Create bjam generator object.s
static std::unique_ptr< base_generator > create();
private:
//** This method a library association to the current target entry for a_target.
//
//Responsibilites
//- Properties
// - associated includes, ldflags, cflags
void assoc_library();
QTextOStream & a_os;
//** This method sets up object for creating a new target entry for a_target.
//
//Responsibilites
//- Properties
// - doc/source: includes, ldflags, cflags
// - compiler
//- Other
// - set compilation for individual
void assoc_source();
public:
//Check a_source for butter properties and add information to a_os.
//a_is_source is true of a_source stereotype is "source" and false
//if stereotype is "document".
void check_properties();
private:
//Build the inter-buildfile link from this artifact/location to its parent and
//vice-versa. This is called just before the artifact is closed so has access
//to the (almost) complete content.
void descendent_link(compound_artifact & a_art, compound_artifact & a_sys, const location & a_loc);
//** This method finalises the target entry for a_target.
void end_target();
//In this style external targets are not used, external library
//data is written in local-targets directly where it is
//referenced.
//
//Responsibility
//- Properties
// - project (defines external)
// - buildfile
//- Other
// - external target
void external_target();
//Write extra details to the top-level build file.
//
//Responsibilities:
//- Property handling
// - build-dir
// - project: flags, include, ldflags, (library) type
// - style
// - version
void initialise();
//** Create an install target.
//
//Responsibilites
//- Properties
// - install (library, executable and document)
void install_target();
//** This method sets up object for creating a new target entry for a_target.
//
//Responsibility
//- Properties
// - compiler
// - include, ldflags, cflags
// - buildfile
// - type (library)
//- Other
// - shared lib
// - static lib
// - executable
// - non-standard target
void start_target();
};
} // namespace butter
#endif
|
97045e1ec41a535df4983a46b5cc6721ffa15af9 | 7300a2f3e5d6a542401fd011be01d19036c73f7f | /Luksafors.cpp | f944c4bb13895cd217214b0339e952c455c54f43 | [] | no_license | Zarins84/C | 3f1895d87fa375f28470ba1b3b69814653b7241e | bdb52ee7244e1488874795cbf87c3a40242b01ad | refs/heads/main | 2023-06-16T14:40:39.982089 | 2021-07-13T09:46:01 | 2021-07-13T09:46:01 | 385,280,550 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,407 | cpp | Luksafors.cpp | #include <iostream>
#include <chrono>
#include <thread>
int main(){
using namespace std;
using namespace std::this_thread;
using namespace std::chrono;
char red[]= {0x1b,'[','0',';','3','1','m',0};
cout << red << "_______" << endl;
cout << red << "|RED| " << endl;
cout << red << "_______" << endl;
sleep_for(nanoseconds(50));
sleep_until(system_clock::now() + seconds(3));
char yellow[]= {0x1b,'[','0',';','3','3','m',0};
cout << yellow << "_______" << endl;
cout << yellow << "|YELLOW|" << endl;
cout << yellow << "_______" << endl;
sleep_for(nanoseconds(50));
sleep_until(system_clock::now() + seconds(1));
if (system("CLS")) system("clear");
cout << "\n" << "\n" << endl;
cout << yellow << "_______" << endl;
cout << yellow << "|YELLOW|" << endl;
cout << yellow << "_______" << endl;
sleep_for(nanoseconds(50));
sleep_until(system_clock::now() + seconds(1));
if (system("CLS")) system("clear");
char green[]= {0x1b,'[','0',';','3','2','m',0};
cout << "\n" << "\n" << "\n" << "\n" << endl;
cout << green << "_______" << endl;
cout << green << "|GREEN|" << endl;
cout << green << "_______" << endl;
sleep_for(nanoseconds(50));
sleep_until(system_clock::now() + seconds(3));
if (system("CLS")) system("clear");
}
|
5025ca2179c99297fede5ea33aa97181faf96e77 | fcb6f2aebb7da6bea8d4a18617c70cf469f3d73f | /Types.h | 916610e1eee1d2741f2364559cdad8e70d80ae5a | [] | no_license | lpcvoid/valheim-tools | 2e5f13db3a32b36e3ae42395e7ae825a91b7d5d2 | 39790ff839526c04a2fa7fc1db34ad60208b4da0 | refs/heads/master | 2023-03-31T07:13:05.169266 | 2021-04-05T12:38:44 | 2021-04-05T12:38:44 | 350,014,112 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 323 | h | Types.h | //
// Created by lpcvoid on 03/04/2021.
//
#pragma once
namespace valheim {
template <typename T>
using Vec2 = std::tuple<T,T>;
template <typename T>
using Vec3 = std::tuple<T,T,T>;
using Position = std::tuple<float, float, float>;
using Quaternion = std::tuple<float, float, float, float>;
}
|
693fd5b8dee48ea58ecea44c3d0930fa61db3033 | bd557df5a0b1b0973a5ac1c3cf5e434ae4363f8a | /strategy-pattern/main.cc | c07ecbbc3afdd01d6895657a756196d869ed824c | [] | no_license | qls152/CPP-design-parttern | bec7bd3cc123efd3f0c244ee8e987cf1319ca46f | 41eaea6ff3f72f5eb24d067cf70c0330da4dd099 | refs/heads/master | 2023-06-27T00:41:14.746516 | 2021-07-29T11:33:25 | 2021-07-29T11:33:25 | 204,311,565 | 12 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 200 | cc | main.cc | #include "duck/mallard_duck.h"
int main() {
std::shared_ptr<Duck> mallard = std::make_shared<MallardDuck>();
mallard->display();
mallard->performFly();
mallard->performQuack();
return 0;
} |
c0e11e064b1816dcbcde0d412d4d77e6ae07e787 | a2d80446ecffca438a3b7e8476a820e3c4ec9bdb | /BlinkAnalysis/EyeCalibration.h | e0198af2b7160a51704e80a447cf623ddfad1937 | [] | no_license | mdfeist/BlinkAnalysis | 88ad8570a7024ccb983f3b1279d2f4da06616649 | a9156aa31f822edfd0606ba2ce0bd72e4479cf8e | refs/heads/master | 2021-01-22T12:08:20.337547 | 2013-08-16T20:34:00 | 2013-08-16T20:34:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,005 | h | EyeCalibration.h | #pragma once
#include "stdafx.h"
#include "AppData.h"
#include <vector>
#include <osg/Vec3>
class EyeCalibration {
private:
class CalibrationPoint {
private:
int _x, _y;
osg::Vec3 _ray;
public:
CalibrationPoint() {}
CalibrationPoint(int x, int y, osg::Vec3 ray) {
_x = x;
_y = y;
_ray = ray;
}
osg::Vec3& ray() { return _ray; }
int& x() { return _x; }
int& y() { return _y; }
bool equal(const CalibrationPoint& rhs) {
return _x==rhs._x && _y==rhs._y;
}
/** Multiply by scalar. */
inline const CalibrationPoint operator * (float rhs) const
{
return CalibrationPoint(_x*rhs, _y*rhs, _ray*rhs);
}
/** Unary multiply by scalar. */
inline CalibrationPoint& operator *= (float rhs)
{
_x*=rhs;
_y*=rhs;
_ray*=rhs;
return *this;
}
/** Divide by scalar. */
inline const CalibrationPoint operator / (float rhs) const
{
return CalibrationPoint(_x/rhs, _y/rhs, _ray/rhs);
}
/** Unary divide by scalar. */
inline CalibrationPoint& operator /= (float rhs)
{
_x/=rhs;
_y/=rhs;
_ray/=rhs;
return *this;
}
/** Binary vector add. */
inline const CalibrationPoint operator + (const CalibrationPoint& rhs) const
{
return CalibrationPoint(_x+rhs._x, _y+rhs._y, _ray+rhs._ray);
}
/** Binary vector add. */
inline CalibrationPoint& operator += (const CalibrationPoint& rhs)
{
_x+=rhs._x;
_y+=rhs._y;
_ray+=rhs._ray;
return *this;
}
/** Binary vector subtract. */
inline const CalibrationPoint operator - (CalibrationPoint& rhs) const
{
return CalibrationPoint(_x-rhs._x, _y-rhs._y, _ray-rhs._ray);
}
/** Binary vector subtract. */
inline CalibrationPoint& operator -= (const CalibrationPoint& rhs)
{
_x-=rhs._x;
_y-=rhs._y;
_ray-=rhs._ray;
return *this;
}
/** Negation operator. Returns the negative of the Vec3f. */
inline const CalibrationPoint operator - () const
{
return CalibrationPoint(-_x, -_y, -_ray);
}
};
class Segment {
private:
CalibrationPoint _p1, _p2;
public:
Segment() {}
Segment(CalibrationPoint from, CalibrationPoint to) {
_p1 = from;
_p2 = to;
}
CalibrationPoint& p1() { return _p1; }
CalibrationPoint& p2() { return _p2; }
int x1() { return _p1.x(); }
int y1() { return _p1.y(); }
int x2() { return _p2.x(); }
int y2() { return _p2.y(); }
};
// Typedef an STL vector of vertices which are used to represent
// a polygon/contour and a series of triangles.
typedef std::vector< CalibrationPoint > CalibrationPointVector;
typedef std::vector< Segment > SegmentVector;
int rbHeadId;
int rbViewingObjectId;
// Used to store the calibrated eye vectors
float *eyeVectorArray;
unsigned long viewingWidth;
unsigned long viewingHeight;
unsigned long viewingMargin;
char* getNameById(int id);
CalibrationPointVector calibrationPoints;
int center_x, center_y;
// triangulate a contour/polygon, places results in STL vector as series of triangles.
bool triangulate(CalibrationPointVector &contour, CalibrationPointVector &result);
// compute area of a contour/polygon
float area(CalibrationPointVector &contour);
// decide if point Px/Py is inside triangle defined by
// (Ax,Ay) (Bx,By) (Cx,Cy)
bool insideTriangle(CalibrationPoint A, CalibrationPoint B, CalibrationPoint C, CalibrationPoint P);
bool snip(CalibrationPointVector &contour,int u,int v,int w,int n,int *V);
// Convex Hull
SegmentVector calculateConvexHull(CalibrationPointVector processingPoints);
bool boundingPointsOfHull(SegmentVector &contour, CalibrationPointVector &result);
bool isInCircumCircle(CalibrationPoint &point, CalibrationPointVector &traingle);
bool sort(CalibrationPointVector &points, int center_x, int center_y);
int getLineIntersection(CalibrationPoint A, CalibrationPoint B, CalibrationPoint C, CalibrationPoint D);
bool isEdge(CalibrationPointVector processingPoints, Segment edge);
int isLeft(Segment segment, CalibrationPoint r);
bool isLess(CalibrationPoint a, CalibrationPoint b, int center_x, int center_y);
SegmentVector getEdges(CalibrationPointVector processingPoints);
CalibrationPoint getClosestPoint(CalibrationPoint a, CalibrationPoint b, CalibrationPoint point, bool segmentClamp);
struct ComparePoints : std::binary_function<CalibrationPoint, CalibrationPoint, bool> {
ComparePoints(EyeCalibration * cal, int x, int y) : _cal(cal), _x(x), _y(y) {}
bool operator() (const CalibrationPoint& a, const CalibrationPoint& b) const {
return _cal->isLess(a, b, _x, _y);
}
EyeCalibration * _cal;
int _x, _y;
};
struct ComparePointsDistanceFrom : std::binary_function<CalibrationPoint, CalibrationPoint, bool> {
ComparePointsDistanceFrom(EyeCalibration * cal, CalibrationPoint point) : _cal(cal), _point(point) {}
bool operator() (CalibrationPoint a, CalibrationPoint b) {
float distanceA = (_point.x()-a.x())*(_point.x()-a.x()) + (_point.y()-a.y())*(_point.y()-a.y());
float distanceB = (_point.x()-b.x())*(_point.x()-b.x()) + (_point.y()-b.y())*(_point.y()-b.y());
if (distanceA > distanceB)
return true;
return false;
}
EyeCalibration * _cal;
CalibrationPoint _point;
};
public:
EyeCalibration(void);
~EyeCalibration(void);
void setHeadId(int id) { this->rbHeadId = id; }
int getHeadId() { return this->rbHeadId; }
char* getHeadName() { return getNameById(this->rbHeadId); }
void setViewingObjectId(int id) { this->rbViewingObjectId = id; }
int getViewingObjectId() { return this->rbViewingObjectId; }
char* getViewingObjectName() { return getNameById(this->rbViewingObjectId); }
bool addPoint();
bool calibrate();
void createTestData();
void saveRayMap();
}; |
3199d1e782b48e532fd16521d27d5785157b2c3d | d2d2913bc9513657f3ab7721d44392258c030c3a | /include/algorithm/degl.hpp | 5236d21b34e154c6d6885b86318b2398a3db72d1 | [
"MIT"
] | permissive | tsakiridis/deplusplus | c9f4ec0b34700e59f6648a99e39d2c8adae55e89 | 383754182c929ab51d9af045bbf138d6d74c009c | refs/heads/master | 2021-01-02T08:18:48.219828 | 2017-08-01T10:51:03 | 2017-08-01T11:05:35 | 66,169,287 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,279 | hpp | degl.hpp | /*!
* \file
* \author Nikos Tsakiridis <tsakirin@auth.gr>
* \version 1.0
*
* \brief Declarations of the DEGL algorithm.
*
* DEGL is a template class. Under the src/ folder you can find
* the implementation for this class methods. Allowed templates
* are float and double. Use double for extra precision.
*/
#ifndef DE_DEGL_HPP
#define DE_DEGL_HPP
#include <cstdint>
#include <vector>
#include <array>
#include "algorithm/base_algorithm.hpp"
namespace DE {
namespace Algorithm {
/*!
* \class DEGL
* \brief The DEGL algorithm
*
* The DEGL algorithm \cite Das2009 (Das, S., Abraham, A., Chakraborty, U. K.,
* & Konar, A. (2009). Differential Evolution Using a Neighborhood-Based
* Mutation Operator. IEEE Transactions on Evolutionary Computation, 13(3))
* is a variant of the DE algorithm which can be used for the optimization of
* real-parameter problems. It utilizes the concept of small (local) neighbor-
* hoods for each population member, defined in a ring topology.
* To make the DEGL class work, a class must be defined inheriting the
* abstract base class Base, implementing the pure virtual functions of the
* class
*
* \see Base
* \see SimpleFitnessFunction
*/
template <class T>
class DEGL : public Base<T> {
public:
/*!
* \brief Create a new optimizer from an existing initial chromosome
*
* \param problem : Pointer to a Base Problem
* \param initial_chromosome : An initial (ideally not random) solution
* \param minimize : If true, minimize the fitness function
*/
DEGL(std::shared_ptr<Problem::Base<T>> problem,
const std::vector<T>& initial_chromosome,
const bool minimize = true);
/*!
* \brief Create a new optimizer with no a priori knowledge
*
* \param problem : Pointer to a Base Problem
* \param minimize : If true, minimize the fitness function
*/
DEGL(std::shared_ptr<Problem::Base<T>> problem, const bool minimize = true);
/*!
* \brief Apply DEGL
*
* \param max_generations : Maximum number of evolution generations
*
* \return The best solution
*/
void evolve_population(const std::size_t max_generations = 5000);
private:
static constexpr float F = 0.8; /*!< Scale factor */
static constexpr float Cr = 0.9; /*!< Crossover factor */
const std::size_t k_; /*!< Neighborhood size */
std::vector<float> w_; /*!< Weight for every solution [N_] */
std::vector<float> w_mutated_; /*!< Mutated weight parameters [N_] */
/*!
* \brief Initialize the weights
*/
void initialize_weights();
/*!
* Ring topology; find which indexes are within the neighborhood of a given
* index.
*
* \param index : The current position
*
* \return A vector with all the valid indexes
*/
std::vector<std::size_t> get_neighborhood_indexes(
const std::size_t index) const;
/*!
* Ring topology; get random indexes from within a neighborhood
*
* \param places : The vector from get_valid_indexes
*
* \return An array with two random indexes.
*/
std::array<std::size_t, 2> get_random_local_indexes(
const std::vector<std::size_t>& places) const;
/*!
* \brief Get two random different indexes from [0, N_ - 1].
*
* Furthermore, they should be different from \param avoid
*
* \param avoid : the index to avoid
*/
std::array<std::size_t, 2> get_random_global_indexes(
const std::size_t avoid) const;
/*!
* Find the best from within a neighborhood.
*
* \param places : Vector with valid places (get_valid_indexes)
*
* \return The position of the local best
*/
std::size_t find_local_best(const std::vector<std::size_t>& places) const;
/*!
* Mutation in DEGL [Das, et. al].
*
* Mutation as described in DEGL. Get 2 random local indexes and 2 global
* indexes. Find the local best (global best is passed from outside).
* Mutate w and chromosome and ensure constraints.
*
* \param index : chromosome to be mutated
* \param global_best : index of the global best chromosome
*/
std::vector<T> mutate(const std::size_t index, const std::size_t global_best);
}; // class DEGL
} // namespace Algorithm
} // namespace DE
#endif // DE_DEGL_HPP
|
84b4676c0b16f31e8352ffdedbd92ba12533fbe8 | 185a0c0c02f33f37b2570fd6eee6c5b5f89624f7 | /Simplex02/cdn/SA.h | ecedb4da4abd69812874946e96b837f0180cbd40 | [] | no_license | Waydrow/CodeCraft | 5c340c6a5bd74ca72a20b8afebebd75224f1690f | 8512d9d5e0e2bc5f717c778af0577e86c621273b | refs/heads/master | 2021-06-17T00:49:27.680577 | 2017-04-26T10:32:20 | 2017-04-26T10:32:20 | 84,938,259 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,975 | h | SA.h | #include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <stdio.h>
#include <time.h>
#include <math.h>
#define TIME_LIMIT 85
#define EPS 1e-8
#define DELTA 0.98
// 20
#define T 50
#define LIMIT 200
#define OLOOP 18200
#define ILOOP 50 // 内层
#define Iterations 22000
#define P_GONE 0.8
#define P_SWAP 0.8
#define P_FLIP 0.7
#define P_CROSS 0.7
int may_server_num;
using namespace std;
int iterations = 0;
Individual GetNext(Individual ans) {
if(int(ans.count()) > may_server_num) {
double pGone = get_random_real(0, 1);
if (pGone < P_GONE) {
int postion = get_random_int(0, nodesNum - 1);
if(ans.gen[postion]){ // 为 1 则反转
ans.gen[postion] = 0;
}
}
} else {
double pFlip = get_random_real(0, 1);
if(pFlip < P_FLIP) {
int postion = get_random_int(0, nodesNum - 1);
int le = get_random_int(1, serverLevel);
if (ans.gen[postion])
ans.gen[postion] = 0;
else
ans.gen[postion] = le;
}
}
double pSwap = get_random_real(0, 1);
if(pSwap < P_SWAP) {
int x = get_random_int(0, nodesNum - 1);
//int y = get_random_int(0, nodesNum - 1);
int y;
if (x == 0) {
y = x + 1;
} else {
y = x - 1;
}
int temp = ans.gen[x];
ans.gen[x] = ans.gen[y];
ans.gen[y] = temp;
}
/*
double pCross = get_random_real(0, 1);
if (pCross < P_CROSS) {
int x = get_random_int(0, nodesNum - 1);
bitset<BITSIZE> bbb;
bbb.reset();
for (int i = 0; i < nodesNum - x; i++) {
bbb[i] = ans[x+i];
}
for (int i = nodesNum - x; i < nodesNum; i++) {
bbb[i] = ans[i - nodesNum + x];
}
ans = bbb;
}
*/
return ans;
}
Individual SA(Individual tempIn, MinCostFlowSolution * mcf) {
// int startSA = clock();
if(nodesNum < 800) {
may_server_num = 65;
} else {
may_server_num = 120;
}
double t = T;
Individual curPlan = tempIn;
Individual newPlan;
int P_L = 0;
int P_F = 0;
Individual plan;
long long cost = 1000000000;
while(iterations < Iterations) {
iterations++;
long long curCost = 0;
long long newCost = 0;
for(int i = 0; i < ILOOP; i++) {
newPlan = GetNext(curPlan);
mcf->CalCost(curPlan, 0, false);
curCost = curPlan.cost;
mcf->CalCost(newPlan, 0, false);
newCost = newPlan.cost;
double dE = newCost - curCost;
if(dE < 0) {
curPlan = newPlan;
curCost = newCost;
P_L = 0;
P_F = 0;
if(curCost < cost) {
plan = curPlan;
cost = curCost;
cout << "Cost: " << cost << ", Num: " << plan.count() << endl;
}
} else {
double rd = get_random_real(0, 1);
if(exp(-dE / t) > rd) {
curPlan = newPlan;
curCost = newCost;
}
P_L++;
}
if(P_L > LIMIT) {
P_F++;
break;
}
if (double(clock() - start) / CLOCKS_PER_SEC > TIME_LIMIT) {
return plan;
}
}
if(P_F > OLOOP){
printf("OLOOP: P_F = %d\n", P_F);
break;
}
// t *= DELTA;
// t = T * 1.0 /(1 + iterations);
}
cout<<"iterations :"<<iterations<<endl;
return plan;
}
|
cb5af3ddce653584d217081bfda67f95312ef0c9 | df0694732e41fda2d3d0cd19a2eafef268142e18 | /src/extractor.cpp | 410aaf88f9c902d21713305e4ea95d512c325eb6 | [] | no_license | KDE/kfilemetadata | c72ff08d253d750079b4541b776ae33b78b98325 | 766ebea95fe89191a150794fd20fc9e2a016dd94 | refs/heads/master | 2023-09-01T15:03:20.008484 | 2023-08-29T21:30:21 | 2023-08-29T21:30:21 | 42,722,466 | 17 | 5 | null | 2021-06-05T20:23:56 | 2015-09-18T13:01:01 | C++ | UTF-8 | C++ | false | false | 986 | cpp | extractor.cpp | /*
SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "extractor.h"
#include "extractor_p.h"
#include "extractorplugin.h"
#include <utility>
using namespace KFileMetaData;
Extractor::Extractor()
: d(new ExtractorPrivate)
{
}
Extractor::~Extractor() = default;
Extractor::Extractor(Extractor&& other)
{
d = std::move(other.d);
}
void Extractor::extract(ExtractionResult* result)
{
d->m_plugin->extract(result);
}
QStringList Extractor::mimetypes() const
{
return d->m_plugin->mimetypes();
}
QVariantMap Extractor::extractorProperties() const
{
return d->m_metaData;
}
void Extractor::setExtractorPlugin(ExtractorPlugin *extractorPlugin)
{
d->m_plugin = extractorPlugin;
}
void Extractor::setAutoDeletePlugin(ExtractorPluginOwnership autoDelete)
{
d->m_autoDeletePlugin = autoDelete;
}
void Extractor::setMetaData(const QVariantMap &metaData)
{
d->m_metaData = metaData;
}
|
5e35070de882ebbe0675b1833973a8c04d08b942 | 5af59606120d2e64b62493263989db39596149f8 | /examples/example_hernan/example_hernan.cpp | c4144eb5bd537404816b88c52a25af18f8b1f85b | [] | no_license | nairaucar/exactdiagg | 89b96116821a57a7bd53151ca8326235ca8880cd | 99a0a004d88861effcc43df4f98591b450ab7c19 | refs/heads/master | 2023-06-18T23:54:48.975071 | 2021-07-18T21:50:14 | 2021-07-18T21:50:14 | 279,977,434 | 0 | 0 | null | 2020-07-15T20:59:31 | 2020-07-15T20:59:30 | null | UTF-8 | C++ | false | false | 5,594 | cpp | example_hernan.cpp | #include "examples/all.h"
#include"exactdiagg/all.h"
#include <iostream>
#include <complex.h>
using namespace std;
double tb_exact(int L){
double e=0, k, ek;
for(int a=0;a<L;a++){
k=2*M_PI*a/L;
ek=-2*cos(k);
if(ek<0){
e+=ek;
}
}
return(e);
}
std::string order="OSP";
const int lonx=5;
const int lenx=4*lonx;
int toIdx(int pos, int orb, int spin)
{
int idx=0;
if(order=="POS" ) idx= 4*pos + 2*orb + spin ;
else if(order=="OSP" ) idx= pos +(2*orb + spin)*lonx;
else {}; // something wrong!!
return idx;
}
inline FermiOp Fock(int pos, int orb, int spin, bool occ ) { return FermiOp(toIdx(pos, orb, spin), occ); }
QOperatorG<cmpx> Ham_KH_fluxed(int L, double t1, double t2, double U, double V, double J, double dmu, double phi)
{
cout<<"building KH model with magnetic flux"<<endl;
QOperatorG<cmpx> H;
complex<double> imag(0.0, 1.0);
double e0 = (-0.5*U -V +0.5*J), mu = dmu - e0;
for(int pos=0; pos<L; pos++)
{
for(int orb=0; orb<2; orb++) H.Add( Fock(pos, orb, 0, true)*Fock(pos, orb, 0, false)
*Fock(pos, orb, 1, true)*Fock(pos, orb, 1, false), U);
for(int s1 =0; s1 <2; s1++)
for(int s2 =0; s2 <2; s2++)
{
H.Add( Fock(pos, 0, s1, true)*Fock(pos, 0, s1, false)
*Fock(pos, 1, s2, true)*Fock(pos, 1, s2, false), V - ((s1==s2)? J:0) );
if(s1!=s2 && J!=0)
H.Add( Fock(pos, 0, s1, true)*Fock(pos, 0, 1-s1, false)
*Fock(pos, 1, s2, true)*Fock(pos, 1, 1-s2, false), -J);
}
if(J!=0)
for(int orb=0; orb<2; orb++) H.Add( Fock(pos, orb, 0, true )*Fock(pos, orb, 1, true )
*Fock(pos, 1-orb, 0, false)*Fock(pos, 1-orb, 1, false), -J);
for(int orb=0; orb<2; orb++) for(int spin=0; spin<2; spin++)
{
H.Add( Fock( pos , orb, spin, true)*Fock((pos+1)%L, orb, spin, false), -((orb==0)? t1:t2) * exp( imag*(phi/L)) );
H.Add( Fock((pos+1)%L, orb, spin, true)*Fock( pos , orb, spin, false), -((orb==0)? t1:t2) * exp(-imag*(phi/L)) );
if(mu!=0)
H.Add( Fock( pos , orb, spin, true)*Fock( pos , orb, spin, false), -mu );
}
}
return H;
}
template<int L>
SymmetryGroup<4*L,cmpx> KH_Group()
{
const int Lt=4*L;
auto chain_T1 = TranslationOp<L> (1);
auto system_T1 = TensorPow<L,4> (chain_T1);
auto trasl_group = CyclicGroupPow<Lt> (system_T1, L);
auto system_OF = TranslationOp<Lt> (2*L);
auto OF_group = Z2_Group<Lt, cmpx> (system_OF);
auto orb_SF = TranslationOp<2*L> (L);
auto sys_SF = TensorPow<2*L,2> (orb_SF);
auto SF_group = Z2_Group<Lt, cmpx> (sys_SF);
auto chain_rflx = ReflectionOp<L>;
auto system_rflx = TensorPow<L, 4, ElementaryOp<L> > (chain_rflx);
auto rflx_group = Z2_Group<Lt, cmpx> (system_rflx);
auto system_PH = ParticleHoleOp<Lt>;
auto PH_group = Z2_Group<Lt, cmpx> (system_PH);
auto G = trasl_group;
G = G.DirectProd(SF_group);
G = G.DirectProd(OF_group);
G = G.DirectProd(rflx_group); //only for \Phi=0
G = G.DirectProd(PH_group); //only for half-filled
return G;
}
void KHC_N(Parameters param)
{
const int L=lonx;
const int Lt=lenx;
int Le=L;
double t1=param.t1, t2=param.t2, U=param.U, V=param.V, J=param.J, nPart=param.nPart, phi=param.phi;
cout<<"L="<<L<<"\tt1="<<t1<<"\tt2="<<t2<<"\tU="<<U<<"\tV="<<V<<"\tJ="<<J<<"\tphi="<<phi<<"\tnPart="<<nPart<<endl;
auto H = Ham_KH_fluxed(L, t1, t2, U, V, J, 0, phi);
auto G = KH_Group<L>();
cout<<"nSym= "<<G.nSym()<<endl<<endl;
auto b=FockBasisFixedChargeG<Lt>(nPart, G, 16);
auto gs=FindGS<Lt>(H, b, G, nPart);
// for(int nu=1; nu<G.nSym(); nu++)
// {
// b.SetSym(G, nu);
// auto gsn = FindGS<Lt>(H, b, G, nPart);
// gs = std::min( gs, gsn );
// }
cout<<"GS(nPart="<<gs.nPart<<") --> sym="<<gs.sym<<" ener="<<gs.ener<<endl<<endl;
ofstream E0stream("E0.dat");
E0stream<<gs.ener;
}
/*
void KHC_mu(Parameters param)
{
const int L=lonx;
const int Lt=lenx;
int Le=L;
double t1=param.t1, t2=param.t2, U=param.U, V=param.V, J=param.J, dmu=param.dmu, phi=param.phi;
cout<<"L="<<L<<"\tt1="<<t1<<"\tt2="<<t2<<"\tU="<<U<<"\tV="<<V<<"\tJ="<<J<<"\tphi="<<phi<<"\tdmu="<<dmu<<endl;
auto H = Ham_KH_fluxed(L, t1, t2, U, V, J, dmu, phi);
auto G = KH_Group<L>();
auto b0 = FockBasisFixedChargeG<Lt>(Lt/2, G, 0);
auto EF = FindGS<Lt>(H, b0, G, Lt/2);
cout<<"starting with half-filled E0="<<EF.ener<<endl;
for(int nPart=0; nPart<=Lt; nPart++)
{
auto b=FockBasisFixedChargeG<Lt>(nPart, G, 0);
auto gs=FindGS<Lt>(H,b,G,nPart);
for(int nu=1; nu<G.nSym(); nu++)
{
b.SetSym(G, nu);
auto gsn = FindGS<Lt>(H, b, G, nPart);
gs = std::min( gs, gsn );
}
cout<<"nPart="<<gs.nPart<<" --> sym="<<gs.sym<<" ener="<<gs.ener<<endl<<endl;
EF = std::min( EF, gs );
}
cout<<"GS: nPart="<<EF.nPart<<" sym="<<EF.sym<<" ener="<<EF.ener<<endl;
ofstream E0stream("E0.dat");
E0stream<<EF.ener;
}
*/
void Hernan_ED_gs(const char filename[])
{
auto param=Parameters(filename);
// if(param.model=="KHC" ) KHC_mu(param);
if(param.model=="KHCN") KHC_N (param);
}
|
10760c655830f52ae48216f0c4358b2383e4532b | 785463ea0d81e1ab888a858e31ab8cf8b24e4ce6 | /src/plugins/gta3/std.stream/stdinc.hpp | 143ca38cc9db0c3899aa2888f94c64aa6f2ccf64 | [
"MIT"
] | permissive | GTAResources/modloader | 475853390165290d0b5f37f239f3e6b15f36195a | 18f85c2766d4e052a452c7b1d8f5860a6daac24b | refs/heads/master | 2021-02-07T17:32:29.299117 | 2018-01-20T16:23:25 | 2018-01-20T16:23:25 | 244,057,341 | 1 | 1 | MIT | 2020-02-29T23:33:52 | 2020-02-29T23:33:51 | null | UTF-8 | C++ | false | false | 278 | hpp | stdinc.hpp | /*
* Copyright (C) 2014 LINK/2012 <dma_2012@hotmail.com>
* Licensed under the MIT License, see LICENSE at top level directory.
*
*/
#pragma once
#include <stdinc/gta3/stdinc.hpp>
#include <f92la/f92la.h>
#include "CdStreamInfo.h"
#include "CDirectory.h"
#include "CPool.h" |
186ee8d375675287fb0a41b97656e4e4fc74d8cb | 74d611fd0c55c9c9af72b9bfc21cab1ad34f4c80 | /Arduino Sketches/_39_Rainbow_Maker/_39_Rainbow_Maker.ino | 04edb88099a52be8f8c31f8c35cb1a387ce2632d | [] | no_license | jtlai0921/Arduino-Sketches | d0d82ab7a1aad96bb419ce92d4f9bff0e01f765f | 0862d0a714729d297866597fc626092cc7e7cb1d | refs/heads/master | 2020-12-21T04:56:58.035698 | 2020-01-26T13:11:02 | 2020-01-26T13:11:02 | 236,313,977 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,046 | ino | _39_Rainbow_Maker.ino |
int latchpin = 8; // connect to pin 12 on the '595
int clockpin = 10; // connect to pin 11 on the '595
int datapin = 12; // connect to pin 14 on the '595
int zz = 500; // delay variable
int va[]={
1,2,4,8,16,32,64,128,255};
int va2[]={
1,3,7,15,31,63,127,255};
void setup()
{
pinMode(latchpin, OUTPUT);
pinMode(clockpin, OUTPUT);
pinMode(datapin, OUTPUT);
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 0);
shiftOut(datapin, clockpin, MSBFIRST, 0);
shiftOut(datapin, clockpin, MSBFIRST, 0);
shiftOut(datapin, clockpin, MSBFIRST, 0);
digitalWrite(latchpin, HIGH);
randomSeed(analogRead(0));
}
void allRed() //
// turns on all RED
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 255); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, 0); // green
shiftOut(datapin, clockpin, MSBFIRST, 0); // blue
shiftOut(datapin, clockpin, MSBFIRST, 255); // red
digitalWrite(latchpin, HIGH);
}
void allBlue() //
// turns on all blue
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 255); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, 0); // green
shiftOut(datapin, clockpin, MSBFIRST, 255); // blue
shiftOut(datapin, clockpin, MSBFIRST, 0); // red
digitalWrite(latchpin, HIGH);
}
void allGreen() //
// turns on all green
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 255); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, 255); // green
shiftOut(datapin, clockpin, MSBFIRST, 0); // blue
shiftOut(datapin, clockpin, MSBFIRST, 0); // red
digitalWrite(latchpin, HIGH);
}
void allOn() //
// turns on all LEDs. Only use if power supply adequate!!
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 255); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, 255); // green
shiftOut(datapin, clockpin, MSBFIRST, 255); // blue
shiftOut(datapin, clockpin, MSBFIRST, 255); // red
digitalWrite(latchpin, HIGH);
}
void allYellow() //
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 255); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, 255); // green
shiftOut(datapin, clockpin, MSBFIRST, 0); // blue
shiftOut(datapin, clockpin, MSBFIRST, 255); // red
digitalWrite(latchpin, HIGH);
}
void allAqua() //
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 255); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, 255); // green
shiftOut(datapin, clockpin, MSBFIRST, 255); // blue
shiftOut(datapin, clockpin, MSBFIRST, 0); // red
digitalWrite(latchpin, HIGH);
}
void allPurple() //
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 255); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, 0); // green
shiftOut(datapin, clockpin, MSBFIRST, 255); // blue
shiftOut(datapin, clockpin, MSBFIRST, 255); // red
digitalWrite(latchpin, HIGH);
}
void clearMatrix()
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, 0); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, 0); // green
shiftOut(datapin, clockpin, MSBFIRST, 0); // blue
shiftOut(datapin, clockpin, MSBFIRST, 0); // red
digitalWrite(latchpin, HIGH);
}
void lostinspace()
// warning! warning! blinkiness ahead!
{
for (int z=0; z<100; z++)
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, va[random(8)]); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, va[random(8)]); // green
shiftOut(datapin, clockpin, MSBFIRST, va[random(8)]); // blue
shiftOut(datapin, clockpin, MSBFIRST, va[random(8)]); // red
digitalWrite(latchpin, HIGH);
delay(100);
}
}
void displayLEDs(int rr, int gg, int bb, int cc, int dd)
// inserts the base-10 values into the shiftOut functions, and holds the display
// for dd milliseconds
{
digitalWrite(latchpin, LOW);
shiftOut(datapin, clockpin, MSBFIRST, cc); // cathodes
shiftOut(datapin, clockpin, MSBFIRST, gg); // green
shiftOut(datapin, clockpin, MSBFIRST, bb); // blue
shiftOut(datapin, clockpin, MSBFIRST, rr); // red
digitalWrite(latchpin, HIGH);
delay(dd);
}
void loop()
{
// first, light up the whole display in solid colours
allOn();
delay(zz);
delay(zz);
allRed();
delay(zz);
delay(zz);
allGreen();
delay(zz);
delay(zz);
allBlue();
delay(zz);
delay(zz);
allPurple();
delay(zz);
delay(zz);
allYellow();
delay(zz);
delay(zz);
allAqua();
delay(1000);
// now, just some individual LEDs, using random values
lostinspace(); // :)
// scroll some horizontal and vertical lines
for (int z=0; z<5; z++)
{
for (int q=1; q<129; q*=2)
{
displayLEDs(255,0,0,q,200);
}
}
clearMatrix();
delay(1000);
for (int z=0; z<5; z++)
{
for (int q=1; q<129; q*=2)
{
displayLEDs(0,255,0,q,200);
displayLEDs(q,0,0,255,200);
}
}
clearMatrix();
delay(1000);
for (int z=0; z<5; z++)
{
for (int q=1; q<9; q++)
{
displayLEDs(0,0,255,va2[q],200);
}
}
clearMatrix();
delay(1000);
}
|
4d11cbbcf709d1be40dd61e5d1577e420345769f | 67cbba6d29f664049b5b27de0966360aa8af3b72 | /Homework/CIS17b_Review_2/prob3table.cpp | e46a30a1fd81260092319bc0912c4d0bfee70514 | [] | no_license | vctralcaraz/AlcarazVictor_CIS17b_48037 | 388c971c05d993cd254155c078c02f85c930b0bb | 54a323dc973e55da518b53e59b019b821641889a | refs/heads/master | 2020-09-17T05:01:22.582913 | 2016-10-13T18:35:25 | 2016-10-13T18:35:25 | 67,661,127 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,454 | cpp | prob3table.cpp | /*
* File: Prob3Table.cpp
* Author: Victor Alcaraz
* Created on September 2, 2016, 12:01 AM
* Purpose:
*/
#include "Prob3Table.h"
Prob3Table::Prob3Table(char const *file, int row, int col)
{
//initialize variables
ifstream fin;
//initialize rows and cols
rows = row;
cols = col;
grandTotal = 0;
//open file
fin.open(file);
//check if the file was properly opened
if(fin.fail())
{
cout << "There was an error opening the file\n";
exit(1);
}
//declare dynamic arrays
int size = cols * rows;
table = new int[size];
rowSum = new int[rows];
colSum = new int[cols];
//initialize all arrays to 0
for(int i = 0; i < size; i++)
{
table[i] = 0;
}
for(int i = 0; i < rows; i++)
{
rowSum[i] = 0;
}
for(int i = 0; i < cols; i++)
{
colSum[i] = 0;
}
// cout << "setting base table..." << endl << endl;
//reading from a file and storing values to array
char temp;
string temp2 = "";
int i = 0;
int count = 0;
int tCount = 0; //test total number of input numbers
while(!fin.eof())
{
fin >> temp;
count++;
temp2 += temp;
if(count == 3)
{
int temp = atoi(temp2.c_str());
table[i] = temp;
i++;
temp2 = "";
count = 0;
tCount++;
}
}
fin.close();
calcTable();
}
Prob3Table::~Prob3Table()
{
// cout << "deleting base dynamic variables... " << endl;
delete [] table;
delete [] rowSum;
delete [] colSum;
// cout << "done deleting base variables... " << endl;
}
void Prob3Table::calcTable(void)
{
int size = cols * rows;
//getting the sum of rows
int sum = 0; //sum of each row
int k = 0; //sum array index
for(int i = 0; i < size; i++)
{
if(i % cols == 0 && i != 0)
{
rowSum[k++] = sum;
sum = 0;
}
sum += table[i];
if(i == size - 1)
{
rowSum[k] = sum;
}
}
//getting the sum of the cols
//int count = 0;
sum = 0; //sum of each col
int j = 0; //sum array index
for(int i = 0; i < cols; i++)
{
for(int k = 0; k < rows; k++)
{
sum += table[i + (k * cols)];
}
colSum[j++] = sum;
grandTotal += sum;
sum = 0;
}
}
|
883aa362a6fe8fe5142d4da9f862f2fb4137195e | 5f62c7e49aa17873d9a87b4ec0ea7d1297907170 | /src/CalorimeterSD.cpp | 36f63c4b7ac310ccb983813fb7e94e30fbba6ec7 | [] | no_license | KrisitnaGudkova/calorimeter | 1377559deaf62b3da48f1cc4b339d449eb324a9c | afae910d2b6def97454c125fb1f9356b8fb74ea6 | refs/heads/master | 2022-11-29T23:32:12.505242 | 2020-08-06T15:25:22 | 2020-08-06T15:25:22 | 285,603,867 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,284 | cpp | CalorimeterSD.cpp | #include "CalorimeterSD.hpp"
#include "G4HCofThisEvent.hh"
#include "G4Step.hh"
#include "G4ThreeVector.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CalorimeterSD::CalorimeterSD(const G4String& name, const G4String& hitsCollectionName) : G4VSensitiveDetector(name), fHitsCollection(0)
{
collectionName.insert(hitsCollectionName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CalorimeterSD::~CalorimeterSD()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void CalorimeterSD::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection = new CalorHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
G4int hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection( hcID, fHitsCollection );
// Create hits
// fNofCells for cells + one more for total sums
fHitsCollection->insert(new CalorHit());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool CalorimeterSD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
// energy deposit
G4double edep = step->GetTotalEnergyDeposit();
if ( edep==0. ) return false;
// G4TouchableHistory* touchable
// = (G4TouchableHistory*)(step->GetPreStepPoint()->GetTouchable());
// Get hit accounting data for this cell
CalorHit* hit = (*fHitsCollection)[0];
if ( ! hit )
{
G4cerr << "Cannot access hit " << G4endl;
exit(1);
}
// Get hit for total accounting
// CalorHit* hitTotal
//= (*fHitsCollection)[noYLayers*noZLayers-1];
// Add values
hit->Add(edep);
// G4cout << "SD"<<edep << " ";
// hitTotal->Add(edep);
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void CalorimeterSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel>1 )
{
G4int nofHits = fHitsCollection->entries();
G4cout << "\n-------->Hits Collection: in this event they are " << nofHits << G4endl;
(*fHitsCollection)[0]->Print();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
e83648cbbf1443da8846639e8628d6f121ef4b7c | 6ca8f9a932f25494401c8974b463078745fef963 | /Client/Code/Loading.cpp | ec24c47b881c27fe21b30a713021aa26f18cde7e | [] | no_license | jang6556/DungeonDefenders | 29cca6047e828d8f2b5c77c0059cfbaace4d53bf | 526fe493b89ac4f8e883074f60a05a7b96fa0c43 | refs/heads/master | 2023-02-01T12:39:34.271291 | 2020-12-07T16:55:03 | 2020-12-07T16:55:03 | 319,384,221 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 38,095 | cpp | Loading.cpp | #include "stdafx.h"
#include "..\Header\Loading.h"
#include "GraphicDev.h"
#include "ManageMent.h"
#include "../Header/SceneIntro.h"
#include "../Header/Camera.h"
#include "Texture.h"
#include "../Header/CameraDynamic.h"
#include "InputDev.h"
#include "Renderer.h"
#include "../Header/Player.h"
#include "../Header/UI_Header.h"
#include "../Header/Effect_Header.h"
#include "../Header/FireBullet.h"
#include "../Header/CrossBowArrow.h"
#include "../Header/SharpBullet.h"
#include "../Header/CrossBow.h"
#include "../Header/Item_Header.h"
#include "../Header/Static_Object.h"
#include "../Header/BuildObject_Header.h"
#include "../Header/StatUI_Header.h"
#include "../Header/Decal_Header.h"
_USING(Client)
HRESULT CLoading::Load_Static()
{
if (FAILED(Load_Static_Shader()))
return E_FAIL;
if (FAILED(Load_Static_Texture()))
return E_FAIL;
if (FAILED(Load_Static_StaticMesh()))
return E_FAIL;
if (FAILED(Load_Static_DynamicMesh()))
return E_FAIL;
if (FAILED(Load_StaticObject()))
return E_FAIL;
m_iComplete = 100;
return NOERROR;
}
HRESULT CLoading::Load_StaticObject()
{
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"CAMERA", CCameraDynamic::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"PLAYER", CPlayer::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILLPANEL", CSkillPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"VERTICALBACKGROUND", CVerticalBarBackGround::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"VERTICALBACKGROUNDREV", CVerticalBarBackGroundRev::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"VERTICALHP", CVerticalBarHP::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"VERTICALMP", CVerticalBarMP::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"VERTICALHPEFFECT", CVerticalBarHPEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"VERTICALMPEFFECT", CVerticalBarMPEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"PANEL", CPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"BLOODEFFECT", CBloodEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"FIREBULLET", CFireBullet::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"CROSSBOWARROW", CCrossBowArrow::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SHARPBULLET", CSharpBullet::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SHARPBULLETEFFECT", CSharpBulletEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SHARPBULLETEXPLOSIVE", CSharpBulletExplosive::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"FIREBULLETEFFECT", CFireBulletEffect::Create(m_pGraphicDev))))
return E_FAIL;
m_iComplete = 90;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_1", CShotGun::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_2", CLightShot::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_3", CBuildIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_4", CBombIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_5", CPoisionFieldIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_6", CShieldIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_7", CMissileTowerIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"CROSSBOW", CCrossBow::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"FIREBULLET_FIRE", CFireBulletFireEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MANA_TOKEN", CManaToken::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"PRESENT_BOMB", CPresentBomb::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"FOG_EFFECT", CFogEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"POISION_FIELD", CPoisionField::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MONSTER_HP_BAR", CMonsterHpBar::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MONSTER_HP_FRAME", CMonsterHpFrame::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MONSTER_HP_CURR", CMonsterHpCurr::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"EXP_BAR", CExpBar::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"WAVE_PANEL", CWavePanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"WAVE_BAR", CWaveBar::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"WAVE_INFO", CWaveInfo::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"WAVE_BAR_CONTENT", CWaveBarContents::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"BUILD_LOADING_BAR", CBuildLoadingBar::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"BUILD_LOADING_CONTENT", CBuildLoadingContent::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"PLAYER_INFO", CPlayerInfo::Create(m_pGraphicDev))))
return E_FAIL;
m_iComplete = 95;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MONSTER_HP_COLOR", CMonsterHpColor::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MONSTER_HP_FONT", CMonsterHpNum::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"CRYSTAL", CCrystal::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"CRYSTAL_CORE", CCrystalCore::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"CRYSTAL_HEAD", CCrystalHead::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"CRYSTAL_RING", CCrystalRing::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SHIELD", CShield::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MISSILE_TOWER", CMissilTower::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"GLOWBALL", CGlowBall::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MISSILE_TOWER_BULLET", CMissileTowerBullet::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"PROJECTILE", CProjectile::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"DAMAGE_BUFFER", CDamageBuffer::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"DAMAGE_FONT", CDamageFont::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"PHASE", CPhase::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"WAVE_NUM", CWaveNum::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"STRIKE_TOWER", CStrikeTower::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"LIGHTNING_TOWER", CLightningTower::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_9", CStrikeTowerIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_8", CLightningTowerIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_ICON_10", CHealIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"STAT_UI_PANEL", CStatPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"STAT_UI_BACKGROUND", CStatBackGround::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"DAMAGE_UP_ICON", CDamageUpIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"HEALTH_UP_ICON", CHealthUpIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"COOL_DOWN_ICON", CCoolDownIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MANA_DOWN_ICON", CManaDownIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"PLAYER_INFO_PANEL", CPlayerInfoPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"EMPTY_PANEL", CEmptyPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"POINT_ICON", CPointIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"NUM_ICON", CNumIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"ATTACK_PANEL", CAttackPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_DAMAGE_PANEL", CSkillDamagePanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"HEALTH_PANEL", CHealthPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"COOL_PANEL", CCoolPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MANA_PANEL", CManaPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"DOT_ICON", CDotIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"PERCENT_ICON", CPercentIcon::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"POINT_NUM_PANEL", CPointNumPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"ATTACK_NUM_PANEL", CAttackNumPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SKILL_NUM_PANEL", CSkillDamageNumPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"HEALTH_NUM_PANEL", CHealthNumPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"COOL_NUM_PANEL", CCoolNumPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MANA_NUM_PANEL", CManaNumPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"ABILITY_NUM_PANEL", CAbilityNumPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"LEVEL_PANEL", CLevelPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"NUMBER_UI", CNumberUI::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"NUMBER_PANEL", CNumberPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"TEXT_UI", CTextUI::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"TEXT_PANEL", CTextPanel::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"LIGHTNING_BOLT", CLightningBolt::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"STRIKE_BEAM", CStrikeBeam::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"BOMB_EFFECT", CBombEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"LIGHTNING_EFFECT_SPHERE", CLightningSphere::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"LIGHTNING_EFFECT_BOLT", CLightningBoltEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"ITEM_EFFECT", CItemEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"BLUE_EXPLOSION", CBlueExplosion::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"YELLOW_EXPLOSION", CYellowExplosion::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"TOWER_HIT_EFFECT", CTowerHitEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"POISON_FIELD_EFFECT", CPoisonFieldEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"MOUSE_POINT", CMousePoint::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"SUMMONDECAL", CSummonDecal::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"RANGEDECAL", CRangeDecal::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"BUILDPOINT", CBuildPoint::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"BUILD_EFFECT", CBuildEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"LAVA_EFFECT", CLavaEffect::Create(m_pGraphicDev))))
return E_FAIL;
if (FAILED(CGameObjectMgr::GetInstance()->AddObejct_Prototype(SCENESTATIC, L"LAVA_FOG_EFFECT", CLavaFogEffect::Create(m_pGraphicDev))))
return E_FAIL;
return NOERROR;
}
HRESULT CLoading::Load_Static_Texture()
{
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"BLOODEFFECT", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/Frame/Blood1/Blood_%d.png", 19), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SKYBOXTEX", CTexture::Create(m_pGraphicDev, L"../Texture/burger%d.dds", 1, CTexture::CUBE), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"PANEL", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/Panel/Panel%d.tga", 11), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"VERTICALBAR", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/VerticalBar/VerticalBar%d.tga", 6), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHARPBULLET_EFFECT", CTexture::Create(m_pGraphicDev, L"Resource/StaticMesh/Bullet/Soul%d.png", 1), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHARPBULLETEXPLOSIVE", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/Explode/Explode%d.tga", 4), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"FIREBULLETEFFECT", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/Frame/Final_Fire02/Final_Fire%d.tga", 31), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SKILL_ICON", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/SkillIcon/SkillIcon%d.tga", 10), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"FIREBULLET_FIRE", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/FireBulletEffect/FireBulletEffect%d.tga", 3), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"FOG_EFFECT", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/Single/BS/fogSheet_%d.tga", 2), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"MONSTER_UI", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/MonsterUI/MonsterUI%d.tga", 5), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"MONSTER_FONT", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/Font/Skin/%d.png", 11), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"DAMAGE_FONT", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/Font/Damage/%d.png", 11), SCENESTATIC)))
return E_FAIL;
m_iComplete = 15;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"PHASE", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/Text/Phase/%d.png", 3), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WAVE_NUM", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/Text/WaveNum/%d.png", 3), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"FILTER", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Filter/%d.tga", 1), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"STAT_UI", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/StatUI/%d.tga",27), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"NUMBER_UI", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/Font/Damage/White/%d.png", 12), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"TEXT_UI", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/TextPanel/%d.png", 6), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"BOMB_EXPLOSION", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/Frame/Explosion/explosionFlipbook_%d.tga",16), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"LIGHTNING_EFFECT", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/LightningEffect/LightningEffect%d.tga", 2), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"PARTICLE", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/Particle/%d.png", 8), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"DECAL", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/Decal/%d.tga", 4), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"MOUSE_POINT", CTexture::Create(m_pGraphicDev, L"Resource/Texture/UI/Mouse/%d.png", 3), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"LAVA_EFFECT", CTexture::Create(m_pGraphicDev, L"Resource/Texture/Effect/LavaEffect/%d.tga", 3), SCENESTATIC)))
return E_FAIL;
m_iComplete = 25;
return NOERROR;
}
HRESULT CLoading::Load_Static_Shader()
{
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHADER", CShader::Create(m_pGraphicDev, L"ShaderFile/Shader.fx"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHADERUI", CShader::Create(m_pGraphicDev, L"ShaderFile/ShaderUI.fx"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHADERVERTICAL", CShader::Create(m_pGraphicDev, L"ShaderFile/ShaderVertical.fx"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHADERVERTICALEFFECT", CShader::Create(m_pGraphicDev, L"ShaderFile/ShaderVerticalEffect.fx"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHADEREFFECT", CShader::Create(m_pGraphicDev, L"ShaderFile/ShaderEffect.fx"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHADER_COOL", CShader::Create(m_pGraphicDev, L"ShaderFile/ShaderUI_Cool.fx"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHADER_TOWER_BULLET", CShader::Create(m_pGraphicDev, L"ShaderFile/Shader_Tower_Bullet.fx"), SCENESTATIC)))
return E_FAIL;
m_iComplete = 8;
return NOERROR;
}
HRESULT CLoading::Load_Static_StaticMesh()
{
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"MAGUSQUARTER", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MagusQuarters/", L"MagusQuarters.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CROSSSTAIR", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/StairGroup_01/", L"StairGroup_01.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"LONGSTAIR", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/StairGroup_02/", L"StairGroup_02.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHORTSTAIR", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/CoreStairs_withedges/", L"CoreStairs_withedges.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CROSSBOW", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/CrossBow/", L"CrossBow.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"ARCANEPAD", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/ArcanePad_HI/", L"ArcanePad_HI.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CROSSBOWARROW", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/CrossBowArrow/", L"CrossBowArrow.x"), SCENESTATIC)))
return E_FAIL;
m_iComplete = 37;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"FIREBULLET", CMeshStatic::Create(m_pGraphicDev, L"Resource/StaticMesh/FireBall/", L"FireBall.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHARPBULLET", CMeshStatic::Create(m_pGraphicDev, L"Resource/StaticMesh/Bullet/", L"Bullet.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"ARROW", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Arrow/", L"Arrow.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"MANA_TOKEN", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/ManaToken/", L"ManaToken.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"PRESENT_BOMB", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Present/", L"Present.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CRYSTAL_CORE", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Crystal/", L"Crystal.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CRYSTAL_HEAD", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Crystal/Accessory1/", L"Accessory1.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CRYSTAL_RING", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Crystal/Accessory2/", L"Accessory2.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"GLOWBALL", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Effect/GlowBall/", L"GlowBall.x"), SCENESTATIC)))
return E_FAIL;
m_iComplete = 59;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"HEAD_PROJECTILE", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Effect/Head_Projectile/", L"Head_Projectile.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"PROJECTILE", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Effect/Projectile1/", L"Projectile1.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CENTER_ARCH", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_14/", L"Group_14.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CENTER_WALL", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_15/", L"Group_15.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"BRIDGE_WALL", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_11/", L"Group_11.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SET_RAIL", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_45/", L"Group_45.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"LONG_RAIL", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/WoodRailing_SingleWide_HI/", L"WoodRailing_SingleWide_HI.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"DOUBLE_RAIL", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_09/", L"Group_09.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"CRYSTAL_STAFF", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_41/", L"Group_41.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALLTORCH_DOUBLE", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_34/", L"Group_34.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALLTORCH_TRIPLE", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_03/", L"Group_03.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALLTORCH_ANGLE", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_06/", L"Group_06.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALLTORCH_HEIGHT", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_35/", L"Group_35.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALLTORCH_SINGLE", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/WallTorch_HI/", L"WallTorch_HI.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALLTORCH_LONG", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_36/", L"Group_36.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"LIGHTNING_BOLT", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/Effect/Projectile2/", L"Projectile2.x"), SCENESTATIC)))
return E_FAIL;
m_iComplete = 67;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"DOOR", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_25/", L"Group_25.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHORT_RAIL" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/WoodRailingGroup_01/", L"WoodRailingGroup_01.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"ROOF" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/magusQuartersRoof_SM/", L"magusQuartersRoof_SM.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SINGLE_BRIDGE" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/WallTrim_01_low/", L"WallTrim_01_low.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALL_BANNER_0" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_16/", L"Group_16.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALL_BANNER_1" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_17/", L"Group_17.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALL_BANNER_2" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_19/", L"Group_19.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALL_BANNER_3" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_43/", L"Group_43.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALL_BANNER_4" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Wall_Banner01A/", L"Wall_Banner01A.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALL_BANNER_5" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/WallBanner_Large_HI/", L"WallBanner_Large_HI.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"WALL_BANNER_6" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/WallBanner_Small_HI/", L"WallBanner_Small_HI.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SIDE_STAIR" , CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/CoreStairs_3x_cnr/", L"CoreStairs_3x_cnr.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"LARGE_CRYSTAL", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/LargeCrystalLight_HI/", L"LargeCrystalLight_HI.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"BARREL_0", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Barrel_HI/", L"Barrel_HI.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"BARREL_1", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_29/", L"Group_29.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"BARREL_2", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_31/", L"Group_31.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"BARREL_3", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_32/", L"Group_32.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"TABLE_0", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_27/", L"Group_27.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"TABLE_1", CMeshStatic::Create(m_pGraphicDev, L"Resource/Mesh/StaticMesh/MapObject/Group_37/", L"Group_37.x"), SCENESTATIC)))
return E_FAIL;
m_iComplete = 73;
return NOERROR;
}
HRESULT CLoading::Load_Static_DynamicMesh()
{
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"HUNTRESS", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/Huntress/", L"Huntress.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"DEMON", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/Demon/", L"Demon.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"TRESURECHEST", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/TresureChest/", L"TresureChest.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"DARKELFARCHER", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/DarkElfArcher/", L"DarkElfArcher.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"GOBLIN", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/Goblin/", L"Goblin.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"KOBOLD", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/Kobold/", L"Kobold.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"SHIELD", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/MageBlockade/", L"MageBlockade.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"LIGHTNIG_TOWER", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/LightningTower/", L"LightningTower.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"MISSILE_TOWER", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/MissleTower/", L"MissleTower.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"ORCBRUISER", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/OrcBruiser/", L"OrcBruiser.x"), SCENESTATIC)))
return E_FAIL;
if (FAILED(CComponentMgr::GetInstance()->AddPrototype(L"STRIKE_TOWER", CMeshDynamic::Create(m_pGraphicDev, L"Resource/Mesh/DynamicMesh/StrikerTower/", L"StrikerTower.x"), SCENESTATIC)))
return E_FAIL;
m_iComplete = 87;
return NOERROR;
}
CLoading::CLoading(LPDIRECT3DDEVICE9 _m_pGraphicDev)
:m_pGraphicDev(_m_pGraphicDev),
m_pComponentMgr(CComponentMgr::GetInstance())
{
m_pGraphicDev->AddRef();
m_pComponentMgr->AddRef();
}
HRESULT CLoading::Initialize(SCENEID eSceneID)
{
m_eSceneID = eSceneID;
InitializeCriticalSection(&m_CS);
m_hThread = (HANDLE)_beginthreadex(nullptr, 1, Thread_Main, this, 0, nullptr);
if (m_hThread == nullptr)
return E_FAIL;
return NOERROR;
}
_uint CLoading::Thread_Main(void * Arg)
{
CLoading* pLoading = (CLoading*)Arg;
EnterCriticalSection(&pLoading->m_CS);
HRESULT hResult;
hResult=pLoading->Load_Static();
if (FAILED(hResult))
return -1;
LeaveCriticalSection(&pLoading->m_CS);
return _uint(0);
}
CLoading * CLoading::Create(LPDIRECT3DDEVICE9 _m_pGraphicDev, SCENEID eSceneID)
{
CLoading* pInstance = new CLoading(_m_pGraphicDev);
if (FAILED(pInstance->Initialize(eSceneID)))
{
_MSGBOX("CLoading Created Failed");
Safe_Release(pInstance);
}
return pInstance;
}
void CLoading::Free()
{
WaitForSingleObject(m_hThread, INFINITE);
CloseHandle(m_hThread);
DeleteCriticalSection(&m_CS);
Safe_Release(m_pGraphicDev);
Safe_Release(m_pComponentMgr);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.