hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 109 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count int64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count int64 1 48.5k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 7 1.05M | avg_line_length float64 1.21 330k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 0.99 | author_id stringlengths 2 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
821f165803b125cea9cc871c3481c2f197be0042 | 2,630 | cpp | C++ | packages/monte_carlo/collision/native/src/MonteCarlo_NuclearScatteringDistributionFactoryHelpers.cpp | lkersting/SCR-2123 | 06ae3d92998664a520dc6a271809a5aeffe18f72 | [
"BSD-3-Clause"
] | null | null | null | packages/monte_carlo/collision/native/src/MonteCarlo_NuclearScatteringDistributionFactoryHelpers.cpp | lkersting/SCR-2123 | 06ae3d92998664a520dc6a271809a5aeffe18f72 | [
"BSD-3-Clause"
] | null | null | null | packages/monte_carlo/collision/native/src/MonteCarlo_NuclearScatteringDistributionFactoryHelpers.cpp | lkersting/SCR-2123 | 06ae3d92998664a520dc6a271809a5aeffe18f72 | [
"BSD-3-Clause"
] | null | null | null | //---------------------------------------------------------------------------//
//!
//! \file MonteCarlo_NuclearScatteringDistributionFactoryHelpers.cpp
//! \author Alex Robinson
//! \brief Nuclear scattering distribution factory helper function defs.
//!
//---------------------------------------------------------------------------//
// FRENSIE Includes
#include "MonteCarlo_NuclearScatteringDistributionFactoryHelpers.hpp"
#include "Utility_ContractException.hpp"
namespace MonteCarlo{
// Calculate the AND/DLW block distribution array sizes
void calculateDistArraySizes(
const Teuchos::ArrayView<const double>& location_block,
const Teuchos::ArrayView<const double>& data_block,
Teuchos::Array<unsigned>& dist_array_sizes )
{
unsigned first_index = 0, second_index = 1;
dist_array_sizes.resize( location_block.size() );
// find first/next nonzero positive location block values
while( first_index != location_block.size() )
{
if( location_block[ first_index ] > 0 )
{
if( first_index < location_block.size() - 1)
{
// find the second nonzero positive location block value
while( second_index != location_block.size() )
{
if( location_block[ second_index ] > 0 )
{
dist_array_sizes[ first_index ] = location_block[ second_index ] - location_block[ first_index ];
break;
}
else
{
dist_array_sizes[ second_index ] = 0;
}
++second_index;
}
// Check if the second index is beyond the bounds of the array
if( second_index == location_block.size() and first_index != location_block.size() - 1 )
{
dist_array_sizes[ first_index ] = data_block.size() + 1 - location_block[first_index];
}
first_index = second_index;
++second_index;
}
else
{
dist_array_sizes[ first_index ] = data_block.size() + 1 - location_block[first_index];
++first_index;
++second_index;
}
}
else
{
dist_array_sizes[ first_index ] = 0;
++first_index;
++second_index;
}
}
// Make sure every index in the location block has a corresponding array size
testPostcondition( dist_array_sizes.size() ==
location_block.size() );
}
} // end MonteCarlo namespace
//---------------------------------------------------------------------------//
// end MonteCarlo_NuclearScatteringDistributionFactoryHelpers.cpp
//---------------------------------------------------------------------------//
| 33.291139 | 109 | 0.563498 | lkersting |
821fc404ff54bbeef8ed972acf54742e34e6f555 | 5,791 | hpp | C++ | include/abc_mayus.hpp | mitsiu-carreno/cpp_banner | 8f1ecbe47b9aa2ddf2c12fe321479ed351716c70 | [
"MIT"
] | null | null | null | include/abc_mayus.hpp | mitsiu-carreno/cpp_banner | 8f1ecbe47b9aa2ddf2c12fe321479ed351716c70 | [
"MIT"
] | null | null | null | include/abc_mayus.hpp | mitsiu-carreno/cpp_banner | 8f1ecbe47b9aa2ddf2c12fe321479ed351716c70 | [
"MIT"
] | null | null | null | #ifndef ABC_MAYUS_H
#define ABC_MAYUS_H
#include "constants.hpp"
#include <array>
#include <string>
/*
...............
:::::::::::::::
:+:+:+:+:+:+:+:
+:+:+:+:+:+:+:+
+#+#+#+#+#+#+#+
#+#+#+#+#+#+#+#
###############
*/
namespace ABC{
static std::array <std::string, constants::rows_per_letter> A {{
" . ",
" ::: ",
" :+ +: ",
" +:+ +:+ ",
" +#+ +#+ ",
" #+#+#+#+#+# ",
" #### ####",
}};
static std::array <std::string, constants::rows_per_letter> B {{
" .......... ",
" :::: ::::",
" :+:+ :+:+",
" +:+:+:+:+: ",
" +#+# +#+#",
" #+#+ #+#+",
" ########## ",
}};
static std::array <std::string, constants::rows_per_letter> C {{
" ......... ",
" :::: ::::",
" +:+: ",
" :+:+ ",
" +#+# ",
" #+#+ #+#+",
" ######### ",
}};
static std::array <std::string, constants::rows_per_letter> D {{
" ......... ",
" :::::::::: ",
" :+:+ +:+: ",
" +:+: +:+:+",
" +#+# +#+# ",
" #+#+#+#+#+ ",
" ######### ",
}};
static std::array <std::string, constants::rows_per_letter> E {{
" ..........",
" ::::::::::",
" :+:+ ",
" +:+:+:+:+:",
" +#+# ",
" #+#+#+#+#+",
" ##########",
}};
static std::array <std::string, constants::rows_per_letter> F {{
" ..........",
" ::::::::::",
" :+:+ ",
" +:+:+:+:+:",
" +#+#+#+#+#",
" #+#+ ",
" #### ",
}};
static std::array <std::string, constants::rows_per_letter> G {{
" ......... ",
" :::: :::: ",
" +:+: ",
" :+:+ +:+:+",
" +#+# #+#",
" #+#+ #+#+ ",
" ######### ",
}};
static std::array <std::string, constants::rows_per_letter> H {{
" .... ....",
" :::: ::::",
" :+:+ :+:+",
" +:+:+:+:+:+",
" +#+# +#+#",
" #+#+ #+#+",
" #### ####",
}};
static std::array <std::string, constants::rows_per_letter> I {{
" .... ",
" :::: ",
" :+:+ ",
" +:+: ",
" +#+# ",
" #+#+ ",
" #### ",
}};
static std::array <std::string, constants::rows_per_letter> J {{
" ....",
" ::::",
" +:+:",
" :+:+",
" #+# #+#+",
" #+# +#+# ",
" ####### ",
}};
static std::array <std::string, constants::rows_per_letter> K {{
" .... ....",
" :::: :::: ",
" :+:+ :+:+ ",
" +:+:+:+ ",
" +#+# +#+# ",
" #+#+ #+#+ ",
" #### ####",
}};
static std::array <std::string, constants::rows_per_letter> L {{
" .... ",
" :::: ",
" :+:+ ",
" +:+: ",
" +#+# ",
" #+#+#+#+#+",
" ##########",
}};
static std::array <std::string, constants::rows_per_letter> M {{
" ... ...",
" :::: ::::",
" :+:+: +:+:+",
" +:+ :+ :+ +:+",
" +#+ #+#+ +#+",
" #+# +# #+#",
" ### ###",
}};
static std::array <std::string, constants::rows_per_letter> N {{
" ... ...",
" :::: :::",
" :+:+: :+:",
" +:+ :+ +:+",
" +#+ #+ +#+",
" #+# +#+#+",
" ### ###",
}};
static std::array <std::string, constants::rows_per_letter> O {{
" ......... ",
" :::: :::: ",
" +:+: :+:+",
" :+:+ +:+:",
" +#+# #+#+",
" #+#+ #+#+ ",
" ######### ",
}};
static std::array <std::string, constants::rows_per_letter> P {{
" .......... ",
" :::: ::::",
" :+:+ :+:+",
" +:+:+:+:+: ",
" +#+# ",
" #+#+ ",
" #### ",
}};
static std::array <std::string, constants::rows_per_letter> Q {{
" ......... ",
" :::: :::: ",
" +:+: :+:+",
" :+:+ +:+:",
" +#+# +# #+#+",
" #+#+ #+#+# ",
" ######### ",
}};
static std::array <std::string, constants::rows_per_letter> R {{
" .......... ",
" :::: ::::",
" :+:+ :+:+",
" +:+:+:+:+: ",
" +#+# #+#+ ",
" #+#+ #+#+ ",
" #### ####",
}};
static std::array <std::string, constants::rows_per_letter> S {{
" ........ ",
" :::: ::: ",
" +:+:+ ",
" :+:+:+:+:+ ",
" +#+#+",
" #+# +#+#",
" ######## ",
}};
static std::array <std::string, constants::rows_per_letter> T {{
" ............",
" ::::::::::::",
" :+:+ ",
" +:+: ",
" +#+# ",
" #+#+ ",
" #### ",
}};
static std::array <std::string, constants::rows_per_letter> U {{
" .... ....",
" :::: ::::",
" +:+: +:+:",
" :+:+ :+:+",
" +#+# #+#+",
" #+#+ +#+# ",
" ######## ",
}};
static std::array <std::string, constants::rows_per_letter> V {{
" .... ....",
" :::: ::::",
" +:+: +:+:",
" :+:+ :+:+",
" #+#+ #+#+ ",
" +#+#+# ",
" #### ",
}};
static std::array <std::string, constants::rows_per_letter> W {{
" ... ... ...",
" ::: ::: :::",
" :+: +:+ :+:",
" +:+ :+: +:+",
" +#+ #+# +#+",
" +#+#+ +#+#+ ",
" ### ### ",
}};
static std::array <std::string, constants::rows_per_letter> X {{
" .... ....",
" :::: :::: ",
" :+:+ :+:+ ",
" +:+:+:+ ",
" +#+# +#+# ",
" #+#+ #+#+ ",
" #### ####",
}};
static std::array <std::string, constants::rows_per_letter> Y {{
" .... ....",
" :::: :::: ",
" :+:+ :+:+ ",
" +:+:+:+ ",
" #+#+# ",
" +#+#+ ",
" ##### ",
}};
static std::array <std::string, constants::rows_per_letter> Z {{
" ...........",
" :::::::::::",
" :+:+ ",
" :+:+ ",
" #+#+ ",
" +#+#+#+#+#+",
" ###########",
}};
static std::array <std::string, constants::rows_per_letter> SPCE {{
" ",
" ",
" ",
" ",
" ",
" ",
" ",
}};
}
#endif
| 19.832192 | 68 | 0.240718 | mitsiu-carreno |
8223a2030ae954198be5ff85348c8720420984c3 | 19,655 | cpp | C++ | Programs/ResourceEditor/Classes/SlotSupportModule/Private/EditorSlotSystem.cpp | Serviak/dava.engine | d51a26173a3e1b36403f846ca3b2e183ac298a1a | [
"BSD-3-Clause"
] | 1 | 2020-11-14T10:18:24.000Z | 2020-11-14T10:18:24.000Z | Programs/ResourceEditor/Classes/SlotSupportModule/Private/EditorSlotSystem.cpp | Serviak/dava.engine | d51a26173a3e1b36403f846ca3b2e183ac298a1a | [
"BSD-3-Clause"
] | null | null | null | Programs/ResourceEditor/Classes/SlotSupportModule/Private/EditorSlotSystem.cpp | Serviak/dava.engine | d51a26173a3e1b36403f846ca3b2e183ac298a1a | [
"BSD-3-Clause"
] | 1 | 2020-09-05T21:16:17.000Z | 2020-09-05T21:16:17.000Z | #include "Classes/SlotSupportModule/Private/EditorSlotSystem.h"
#include "Classes/SlotSupportModule/Private/SlotTemplatesData.h"
#include "Classes/Commands2/SlotCommands.h"
#include "Classes/Commands2/Base/RECommandBatch.h"
#include "Classes/Commands2/SetFieldValueCommand.h"
#include "Classes/Commands2/RemoveComponentCommand.h"
#include "Classes/Commands2/AddComponentCommand.h"
#include "Classes/Commands2/EntityRemoveCommand.h"
#include "Classes/Commands2/Base/RECommandNotificationObject.h"
#include "Classes/Commands2/EntityAddCommand.h"
#include "Classes/Selection/Selection.h"
#include "Classes/Qt/Scene/SceneSignals.h"
#include <TArc/Core/ContextAccessor.h>
#include <TArc/DataProcessing/DataContext.h>
#include <Scene3D/Systems/SlotSystem.h>
#include <Scene3D/Components/SlotComponent.h>
#include <Scene3D/Components/SingleComponents/TransformSingleComponent.h>
#include <Scene3D/Scene.h>
#include <Render/RenderHelper.h>
#include <Render/Highlevel/RenderSystem.h>
#include <Base/BaseTypes.h>
#include <Utils/Utils.h>
#include <QObject>
const DAVA::FastName EditorSlotSystem::emptyItemName = DAVA::FastName("Empty");
namespace EditorSlotSystemDetail
{
void DetachSlotForRemovingEntity(DAVA::Entity* entity, SceneEditor2* scene, REDependentCommandsHolder& holder)
{
for (DAVA::uint32 i = 0; i < entity->GetComponentCount(DAVA::Component::SLOT_COMPONENT); ++i)
{
DAVA::SlotComponent* component = static_cast<DAVA::SlotComponent*>(entity->GetComponent(DAVA::Component::SLOT_COMPONENT, i));
holder.AddPreCommand(std::make_unique<AttachEntityToSlot>(scene, component, nullptr, DAVA::FastName()));
}
for (DAVA::int32 i = 0; i < entity->GetChildrenCount(); ++i)
{
DetachSlotForRemovingEntity(entity->GetChild(i), scene, holder);
}
}
} // namespace EditorSlotSystemDetail
EditorSlotSystem::EditorSlotSystem(DAVA::Scene* scene, DAVA::TArc::ContextAccessor* accessor_)
: SceneSystem(scene)
, accessor(accessor_)
{
}
void EditorSlotSystem::AddEntity(DAVA::Entity* entity)
{
DVASSERT(entity->GetComponentCount(DAVA::Component::SLOT_COMPONENT) > 0);
entities.push_back(entity);
pendingOnInitialize.insert(entity);
}
void EditorSlotSystem::RemoveEntity(DAVA::Entity* entity)
{
DVASSERT(entity->GetComponentCount(DAVA::Component::SLOT_COMPONENT) > 0);
DAVA::FindAndRemoveExchangingWithLast(entities, entity);
pendingOnInitialize.erase(entity);
}
void EditorSlotSystem::AddComponent(DAVA::Entity* entity, DAVA::Component* component)
{
DVASSERT(component->GetType() == DAVA::Component::SLOT_COMPONENT);
pendingOnInitialize.insert(entity);
if (entity->GetComponentCount(DAVA::Component::SLOT_COMPONENT) == 1)
{
#if defined(__DAVAENGINE_DEBUG__)
DVASSERT(std::find(entities.begin(), entities.end(), entity) == entities.end());
#endif
entities.push_back(entity);
}
}
void EditorSlotSystem::RemoveComponent(DAVA::Entity* entity, DAVA::Component* component)
{
DVASSERT(component->GetType() == DAVA::Component::SLOT_COMPONENT);
if (entity->GetComponentCount(DAVA::Component::SLOT_COMPONENT) == 1)
{
DAVA::FindAndRemoveExchangingWithLast(entities, entity);
pendingOnInitialize.erase(entity);
}
}
void EditorSlotSystem::Process(DAVA::float32 timeElapsed)
{
using namespace DAVA;
for (Entity* entity : pendingOnInitialize)
{
Set<FastName> names;
Set<SlotComponent*> uninitializedSlots;
for (uint32 i = 0; i < entity->GetComponentCount(Component::SLOT_COMPONENT); ++i)
{
SlotComponent* slotComponent = static_cast<SlotComponent*>(entity->GetComponent(Component::SLOT_COMPONENT, i));
FastName slotName = slotComponent->GetSlotName();
if (slotName.IsValid())
{
names.insert(slotName);
}
else
{
uninitializedSlots.insert(slotComponent);
}
}
uint32 slotIndex = 1;
for (SlotComponent* component : uninitializedSlots)
{
FastName newSlotName(Format("Slot_%u", slotIndex++));
while (names.count(newSlotName) > 0)
{
newSlotName = FastName(Format("Slot_%u", slotIndex++));
}
component->SetSlotName(newSlotName);
}
}
SceneEditor2* scene = static_cast<SceneEditor2*>(GetScene());
SlotSystem* slotSystem = scene->slotSystem;
if (scene->modifSystem->InCloneState() == false &&
scene->modifSystem->InCloneDoneState() == false)
{
for (Entity* entity : pendingOnInitialize)
{
uint32 slotCount = entity->GetComponentCount(Component::SLOT_COMPONENT);
for (uint32 slotIndex = 0; slotIndex < slotCount; ++slotIndex)
{
SlotComponent* component = static_cast<SlotComponent*>(entity->GetComponent(Component::SLOT_COMPONENT, slotIndex));
Entity* loadedEntity = slotSystem->LookUpLoadedEntity(component);
if (loadedEntity == nullptr)
{
Vector<SlotSystem::ItemsCache::Item> items = slotSystem->GetItems(component->GetConfigFilePath());
if (items.empty())
{
RefPtr<Entity> newEntity(new Entity());
slotSystem->AttachEntityToSlot(component, newEntity.Get(), emptyItemName);
}
else
{
slotSystem->AttachItemToSlot(component, items.front().itemName);
}
}
else
{
loadedEntity->SetName(component->GetSlotName());
}
}
}
pendingOnInitialize.clear();
}
for (Entity* entity : scene->transformSingleComponent->localTransformChanged)
{
SlotComponent* slot = scene->slotSystem->LookUpSlot(entity);
if (slot == nullptr)
{
continue;
}
Matrix4 jointTranfsorm = scene->slotSystem->GetJointTransform(slot);
bool inverseSuccessed = jointTranfsorm.Inverse();
DVASSERT(inverseSuccessed);
Matrix4 attachmentTransform = jointTranfsorm * entity->GetLocalTransform();
scene->slotSystem->SetAttachmentTransform(slot, attachmentTransform);
}
for (Entity* entity : entities)
{
for (uint32 i = 0; i < entity->GetComponentCount(Component::SLOT_COMPONENT); ++i)
{
SlotComponent* component = static_cast<SlotComponent*>(entity->GetComponent(Component::SLOT_COMPONENT, i));
Entity* loadedEntity = scene->slotSystem->LookUpLoadedEntity(component);
if (loadedEntity != nullptr)
{
for (int32 j = 0; j < loadedEntity->GetChildrenCount(); ++j)
{
Entity* child = loadedEntity->GetChild(j);
if (child->GetLocked() == false)
{
child->SetLocked(true);
}
}
}
}
}
}
void EditorSlotSystem::WillClone(DAVA::Entity* originalEntity)
{
auto extractSlots = [this](DAVA::Entity* entity)
{
DAVA::uint32 slotCount = entity->GetComponentCount(DAVA::Component::SLOT_COMPONENT);
if (slotCount > 0)
{
DAVA::Scene* scene = GetScene();
for (DAVA::uint32 i = 0; i < slotCount; ++i)
{
AttachedItemInfo info;
info.component = static_cast<DAVA::SlotComponent*>(entity->GetComponent(DAVA::Component::SLOT_COMPONENT, i));
info.entity = scene->slotSystem->LookUpLoadedEntity(info.component);
info.itemName = info.component->GetLoadedItemName();
inClonedState[entity].push_back(info);
DetachEntity(info.component, info.entity);
}
}
};
extractSlots(originalEntity);
DAVA::Vector<DAVA::Entity*> children;
originalEntity->GetChildEntitiesWithComponent(children, DAVA::Component::SLOT_COMPONENT);
for (DAVA::Entity* e : children)
{
extractSlots(e);
}
}
void EditorSlotSystem::DidCloned(DAVA::Entity* originalEntity, DAVA::Entity* newEntity)
{
auto restoreSlots = [this](DAVA::Entity* entity)
{
auto iter = inClonedState.find(entity);
if (iter == inClonedState.end())
{
return;
}
const DAVA::Vector<AttachedItemInfo> infos = iter->second;
for (const AttachedItemInfo& info : infos)
{
AttachEntity(info.component, info.entity, info.itemName);
}
inClonedState.erase(iter);
};
restoreSlots(originalEntity);
DAVA::Vector<DAVA::Entity*> children;
originalEntity->GetChildEntitiesWithComponent(children, DAVA::Component::SLOT_COMPONENT);
for (DAVA::Entity* e : children)
{
restoreSlots(e);
}
clonedEntityes.insert(newEntity);
}
void EditorSlotSystem::DetachEntity(DAVA::SlotComponent* component, DAVA::Entity* entity)
{
DAVA::Entity* slotEntity = component->GetEntity();
DAVA::Entity* loadedEntity = GetScene()->slotSystem->LookUpLoadedEntity(component);
DVASSERT(loadedEntity == entity);
DVASSERT(slotEntity == entity->GetParent());
slotEntity->RemoveNode(entity);
}
void EditorSlotSystem::AttachEntity(DAVA::SlotComponent* component, DAVA::Entity* entity, DAVA::FastName itemName)
{
DAVA::SlotSystem* slotSystem = GetScene()->slotSystem;
Selection::Lock();
slotSystem->AttachEntityToSlot(component, entity, itemName);
Selection::Unlock();
}
DAVA::Entity* EditorSlotSystem::AttachEntity(DAVA::SlotComponent* component, DAVA::FastName itemName)
{
Selection::Lock();
SCOPE_EXIT
{
Selection::Unlock();
};
DAVA::SlotSystem* slotSystem = GetScene()->slotSystem;
DAVA::Entity* result = nullptr;
if (itemName == emptyItemName)
{
DAVA::RefPtr<DAVA::Entity> newEntity(new DAVA::Entity());
slotSystem->AttachEntityToSlot(component, newEntity.Get(), itemName);
return newEntity.Get();
}
else
{
return slotSystem->AttachItemToSlot(component, itemName);
}
}
void EditorSlotSystem::AccumulateDependentCommands(REDependentCommandsHolder& holder)
{
SceneEditor2* scene = static_cast<SceneEditor2*>(GetScene());
auto changeSlotVisitor = [&](const RECommand* command)
{
const SetFieldValueCommand* cmd = static_cast<const SetFieldValueCommand*>(command);
const DAVA::Reflection::Field& field = cmd->GetField();
DAVA::ReflectedObject object = field.ref.GetDirectObject();
DAVA::FastName fieldName = field.key.Cast<DAVA::FastName>(DAVA::FastName(""));
const DAVA::ReflectedType* type = object.GetReflectedType();
if (type == DAVA::ReflectedTypeDB::Get<DAVA::SlotComponent>())
{
DAVA::SlotComponent* component = object.GetPtr<DAVA::SlotComponent>();
DAVA::Entity* entity = scene->slotSystem->LookUpLoadedEntity(component);
if (fieldName == DAVA::SlotComponent::ConfigPathFieldName)
{
DAVA::RefPtr<DAVA::Entity> newEntity(new DAVA::Entity());
holder.AddPreCommand(std::make_unique<AttachEntityToSlot>(scene, component, newEntity.Get(), emptyItemName));
}
}
};
const RECommandNotificationObject& commandInfo = holder.GetMasterCommandInfo();
commandInfo.ForEach(changeSlotVisitor, CMDID_REFLECTED_FIELD_MODIFY);
auto removeSlotVisitor = [&](const RECommand* command)
{
const RemoveComponentCommand* cmd = static_cast<const RemoveComponentCommand*>(command);
DAVA::Component* component = const_cast<DAVA::Component*>(cmd->GetComponent());
if (component->GetType() == DAVA::Component::SLOT_COMPONENT)
{
DAVA::SlotComponent* slotComponent = static_cast<DAVA::SlotComponent*>(component);
holder.AddPreCommand(std::make_unique<AttachEntityToSlot>(scene, slotComponent, nullptr, DAVA::FastName()));
}
};
commandInfo.ForEach(removeSlotVisitor, CMDID_COMPONENT_REMOVE);
auto removeEntityVisitor = [&](const RECommand* command)
{
const EntityRemoveCommand* cmd = static_cast<const EntityRemoveCommand*>(command);
DAVA::Entity* entityToRemove = cmd->GetEntity();
EditorSlotSystemDetail::DetachSlotForRemovingEntity(entityToRemove, scene, holder);
};
commandInfo.ForEach(removeEntityVisitor, CMDID_ENTITY_REMOVE);
auto loadDefaultItem = [&](DAVA::SlotComponent* component)
{
DAVA::Vector<DAVA::SlotSystem::ItemsCache::Item> items = scene->slotSystem->GetItems(component->GetConfigFilePath());
if (items.empty())
{
DAVA::RefPtr<DAVA::Entity> newEntity(new DAVA::Entity());
holder.AddPostCommand(std::unique_ptr<DAVA::Command>(new AttachEntityToSlot(scene, component, newEntity.Get(), emptyItemName)));
}
else
{
holder.AddPostCommand(std::unique_ptr<DAVA::Command>(new AttachEntityToSlot(scene, component, items.front().itemName)));
}
};
auto addSlotVisitor = [&](const RECommand* command)
{
const AddComponentCommand* cmd = static_cast<const AddComponentCommand*>(command);
DAVA::Component* component = cmd->GetComponent();
if (component->GetType() == DAVA::Component::SLOT_COMPONENT)
{
loadDefaultItem(static_cast<DAVA::SlotComponent*>(component));
}
};
commandInfo.ForEach(addSlotVisitor, CMDID_COMPONENT_ADD);
auto addEntityVisitor = [&](const RECommand* command)
{
const EntityAddCommand* cmd = static_cast<const EntityAddCommand*>(command);
DAVA::Entity* entityForAdd = cmd->GetEntity();
auto iter = clonedEntityes.find(entityForAdd);
if (iter != clonedEntityes.end())
{
DAVA::Vector<DAVA::Entity*> slotEntityes;
entityForAdd->GetChildEntitiesWithComponent(slotEntityes, DAVA::Component::SLOT_COMPONENT);
slotEntityes.push_back(entityForAdd);
for (DAVA::Entity* e : slotEntityes)
{
for (DAVA::uint32 i = 0; i < e->GetComponentCount(DAVA::Component::SLOT_COMPONENT); ++i)
{
loadDefaultItem(static_cast<DAVA::SlotComponent*>(e->GetComponent(DAVA::Component::SLOT_COMPONENT, i)));
}
}
clonedEntityes.erase(iter);
}
};
commandInfo.ForEach(addEntityVisitor, CMDID_ENTITY_ADD);
}
void EditorSlotSystem::ProcessCommand(const RECommandNotificationObject& commandNotification)
{
SceneEditor2* scene = static_cast<SceneEditor2*>(GetScene());
auto visitor = [&](const RECommand* command)
{
const SetFieldValueCommand* cmd = static_cast<const SetFieldValueCommand*>(command);
const DAVA::Reflection::Field& field = cmd->GetField();
DAVA::ReflectedObject object = field.ref.GetDirectObject();
DAVA::FastName fieldName = field.key.Cast<DAVA::FastName>(DAVA::FastName(""));
const DAVA::ReflectedType* type = object.GetReflectedType();
if (type == DAVA::ReflectedTypeDB::Get<DAVA::SlotComponent>())
{
DAVA::SlotComponent* component = object.GetPtr<DAVA::SlotComponent>();
if (fieldName == DAVA::SlotComponent::SlotNameFieldName)
{
DAVA::Entity* entity = scene->slotSystem->LookUpLoadedEntity(component);
DVASSERT(entity != nullptr);
entity->SetName(component->GetSlotName());
}
}
if (type == DAVA::ReflectedTypeDB::Get<DAVA::Entity>() && fieldName == DAVA::Entity::EntityNameFieldName)
{
DAVA::Entity* entity = object.GetPtr<DAVA::Entity>();
DAVA::SlotComponent* component = scene->slotSystem->LookUpSlot(entity);
if (component != nullptr)
{
component->SetSlotName(entity->GetName());
}
}
};
commandNotification.ForEach(visitor, CMDID_REFLECTED_FIELD_MODIFY);
}
void EditorSlotSystem::Draw()
{
using namespace DAVA;
SlotTemplatesData* data = accessor->GetGlobalContext()->GetData<SlotTemplatesData>();
Scene* scene = GetScene();
Color boxColor = data->GetBoxColor();
Color boxEdgeColor = data->GetBoxEdgesColor();
Color pivotColor = data->GetPivotColor();
RenderHelper* rh = scene->GetRenderSystem()->GetDebugDrawer();
for (Entity* entity : entities)
{
for (uint32 i = 0; i < entity->GetComponentCount(Component::SLOT_COMPONENT); ++i)
{
SlotComponent* component = static_cast<SlotComponent*>(entity->GetComponent(Component::SLOT_COMPONENT, i));
FastName templateName = component->GetTemplateName();
const SlotTemplatesData::Template* t = data->GetTemplate(templateName);
if (t != nullptr)
{
Vector3 min(-t->pivot.x, -t->pivot.y, -t->pivot.z);
Vector3 max(t->boundingBoxSize.x - t->pivot.x,
t->boundingBoxSize.y - t->pivot.y,
t->boundingBoxSize.z - t->pivot.z);
AABBox3 box(min, max);
Matrix4 transform;
if (component->GetJointName().IsValid())
{
transform = scene->slotSystem->GetResultTranform(component);
}
else
{
transform = component->GetAttachmentTransform();
}
Matrix4 worldTransform = entity->GetWorldTransform();
transform = worldTransform * transform;
rh->DrawAABoxTransformed(box, transform, boxColor, RenderHelper::DRAW_SOLID_DEPTH);
rh->DrawAABoxTransformed(box, transform, boxEdgeColor, RenderHelper::DRAW_WIRE_DEPTH);
Vector3 pivot = Vector3(0.0f, 0.0f, 0.0f) * transform;
rh->DrawIcosahedron(pivot, 0.3f, pivotColor, RenderHelper::DRAW_SOLID_DEPTH);
}
}
}
}
std::unique_ptr<DAVA::Command> EditorSlotSystem::PrepareForSave(bool /*saveForGame*/)
{
if (entities.empty())
{
return nullptr;
}
SceneEditor2* sceneEditor = static_cast<SceneEditor2*>(GetScene());
DAVA::SlotSystem* slotSystem = sceneEditor->slotSystem;
RECommandBatch* batchCommand = new RECommandBatch("Prepare for save", static_cast<DAVA::uint32>(entities.size()));
for (DAVA::Entity* entity : entities)
{
for (DAVA::uint32 i = 0; i < entity->GetComponentCount(DAVA::Component::SLOT_COMPONENT); ++i)
{
DAVA::SlotComponent* component = static_cast<DAVA::SlotComponent*>(entity->GetComponent(DAVA::Component::SLOT_COMPONENT, i));
batchCommand->Add(std::make_unique<AttachEntityToSlot>(sceneEditor, component, nullptr, DAVA::FastName()));
}
}
return std::unique_ptr<DAVA::Command>(batchCommand);
}
void EditorSlotSystem::SetScene(DAVA::Scene* scene)
{
{
SceneEditor2* currentScene = static_cast<SceneEditor2*>(GetScene());
if (currentScene != nullptr)
{
currentScene->modifSystem->RemoveDelegate(this);
}
}
SceneSystem::SetScene(scene);
{
SceneEditor2* currentScene = static_cast<SceneEditor2*>(GetScene());
if (currentScene != nullptr)
{
currentScene->modifSystem->AddDelegate(this);
}
}
}
| 37.870906 | 140 | 0.637192 | Serviak |
8225925142f97fec44546ace05d5668f3bbc46a9 | 2,917 | cpp | C++ | src/hawck-macrod.cpp | aidanharris/Hawck | aab56e85fb7408d9020f6e387b93d9f18d902415 | [
"BSD-2-Clause"
] | null | null | null | src/hawck-macrod.cpp | aidanharris/Hawck | aab56e85fb7408d9020f6e387b93d9f18d902415 | [
"BSD-2-Clause"
] | null | null | null | src/hawck-macrod.cpp | aidanharris/Hawck | aab56e85fb7408d9020f6e387b93d9f18d902415 | [
"BSD-2-Clause"
] | null | null | null | #include "MacroDaemon.hpp"
#include "Daemon.hpp"
#include <iostream>
#if MESON_COMPILE
#include <hawck_config.h>
#else
#define MACROD_VERSION "unknown"
#endif
extern "C" {
#include <syslog.h>
#include <getopt.h>
}
using namespace std;
static int no_fork;
int main(int argc, char *argv[]) {
string HELP =
"Usage: hawck-macrod [--no-fork]\n"
"\n"
"Options:\n"
" --no-fork Don't daemonize/fork.\n"
" -h, --help Display this help information.\n"
" --version Display version and exit.\n"
;
//daemonize("/var/log/hawck-input/log");
static struct option long_options[] =
{
/* These options set a flag. */
{"no-fork", no_argument, &no_fork, 1},
{"version", no_argument, 0, 0},
/* These options don’t set a flag.
We distinguish them by their indices. */
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
/* getopt_long stores the option index here. */
int option_index = 0;
unordered_map<string, function<void(const string& opt)>> long_handlers = {
{"version", [&](const string&) {
cout << "Hawck InputD v" MACROD_VERSION << endl;
exit(0);
}},
};
do {
int c = getopt_long(argc, argv, "h",
long_options, &option_index);
/* Detect the end of the options. */
if (c == -1)
break;
switch (c) {
case 0: {
/* If this option set a flag, do nothing else now. */
if (long_options[option_index].flag != 0)
break;
string name(long_options[option_index].name);
string arg(optarg ? optarg : "");
if (long_handlers.find(name) != long_handlers.end())
long_handlers[name](arg);
break;
}
case 'h':
cout << HELP;
exit(0);
case '?':
/* getopt_long already printed an error message. */
break;
default:
cout << "DEFAULT" << endl;
abort ();
}
} while (true);
cout << "hawck-macrod v" MACROD_VERSION " forking ..." << endl;
if (!no_fork) {
const char *home_cstring = getenv("HOME");
if (home_cstring == nullptr) {
cout << "Unable to find home directory" << endl;
daemonize("/dev/null");
} else {
string HOME(home_cstring);
daemonize(HOME + "/.local/share/hawck/macrod.log");
}
}
MacroDaemon daemon;
try {
daemon.run();
} catch (exception &e) {
cout << e.what() << endl;
syslog(LOG_CRIT, "MacroD: %s", e.what());
throw;
}
}
| 27.518868 | 78 | 0.479602 | aidanharris |
822658319b6ba1100e3ac2af687932608bc94da2 | 6,072 | cpp | C++ | src/Tread/mac_cstring.cpp | hogsy/xtread | 9d4eaf2778b8b687256788c7617b19542986bf32 | [
"MIT"
] | 1 | 2019-07-20T12:10:20.000Z | 2019-07-20T12:10:20.000Z | src/Tread/mac_cstring.cpp | hogsy/xtread | 9d4eaf2778b8b687256788c7617b19542986bf32 | [
"MIT"
] | null | null | null | src/Tread/mac_cstring.cpp | hogsy/xtread | 9d4eaf2778b8b687256788c7617b19542986bf32 | [
"MIT"
] | null | null | null | // MAC_CSTRING.CPP
// Copyright (c) 2000 Joe Riedel, Nick Randal.
// Author: Joe Riedel.
#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
#include "futils.h"
// Replacement class to MFC standard string.
CString::CString()
{
m_pString = NULL;
m_nLength = 0;
}
CString::CString(const CString& ToCopy)
{
m_pString = NULL;
m_nLength = 0;
*this = ToCopy;
}
CString::CString(const char* pString)
{
m_pString = NULL;
m_nLength = 0;
*this = pString;
}
CString::~CString()
{
FreeData();
}
void CString::FreeData()
{
if(m_pString != NULL)
delete[] m_pString;
m_pString = NULL;
m_nLength = 0;
}
void CString::Format(const char* format, ...)
{
va_list argptr;
char text[512];
va_start(argptr, format);
vsprintf(text, format, argptr);
va_end(argptr);
*this = text;
}
bool CString::IsEmpty()
{
return m_nLength == 0;
}
int CString::Find(const char* szString)
{
char* str;
if(m_nLength == 0)
return -1;
str = strstr(m_pString, szString);
if(str == m_pString || str == 0)
return -1;
return (int)(str-m_pString);
}
int CString::Delete(int nIndex, int nCount)
{
if(m_nLength == 0)
return 0;
if(nIndex > m_nLength-1 || nIndex < 0)
return m_nLength;
if(nCount == 0)
return m_nLength;
if((nCount+nIndex) > m_nLength)
nCount -= (nCount+nIndex)-m_nLength;
char* str1 = m_pString;
char* str2 = m_pString;
str1[nIndex+nCount-1] = 0; // Terminate it at the last char to delete.
str2 = &str2[nIndex+nCount];
m_pString = 0;
m_nLength = 0;
*this = str1;
*this += str2;
return m_nLength;
}
CString& CString::operator += (const char c)
{
char* pOld;
int nNewLen;
// Allocate one more char.
nNewLen = m_nLength + 1;
pOld = m_pString;
m_pString = new char[nNewLen+1];
if(m_nLength > 0)
strcpy(m_pString, pOld);
m_pString[nNewLen-1] = c;
m_pString[nNewLen] = 0;
delete[] pOld;
m_nLength = nNewLen;
return *this;
}
CString::operator const char*() const
{
return m_pString;
}
CString& CString::operator += (const CString& sOther)
{
*this = *this + sOther;
return *this;
}
CString& CString::operator += (const char* szOther)
{
*this = *this + szOther;
return *this;
}
const CString& CString::operator = (const CString& sSrc)
{
if(sSrc.m_pString == m_pString)
return sSrc;
FreeData();
if(sSrc.m_nLength == 0)
{
this->m_pString = NULL;
this->m_nLength = 0;
}
else
{
this->m_nLength = sSrc.m_nLength;
this->m_pString = new char[this->m_nLength+1];
if(this->m_pString == NULL)
{
this->m_nLength = 0;
return sSrc;
}
strcpy(this->m_pString, sSrc.m_pString);
}
return sSrc;
}
const char* CString::operator = (const char* szSrc)
{
if(m_pString == szSrc)
return szSrc;
FreeData();
int nLen;
if(szSrc == NULL)
nLen = 0;
else
nLen = strlen(szSrc);
if(nLen == 0)
{
m_pString = NULL;
m_nLength = 0;
return szSrc;
}
m_pString = new char[nLen+1];
strcpy(m_pString, szSrc);
m_nLength = nLen;
return szSrc;
}
bool operator != (const CString& sString, const CString& sOther)
{
return !(sString==sOther);
}
bool operator != (const CString& sString, const char* szOther)
{
return !(sString == szOther);
}
bool operator == (const CString& sString, const char* szOther)
{
int nLen;
if(szOther == NULL)
nLen = 0;
else
nLen = strlen(szOther);
if(sString.m_nLength != nLen)
return false;
if(sString.m_nLength == 0 && nLen == 0)
return true;
return strcmp(sString.m_pString, szOther) == 0;
}
bool operator == (const CString& sString, const CString& sOther)
{
if(sString.m_nLength != sOther.m_nLength)
return false;
if(sString.m_nLength == 0 && sOther.m_nLength == 0)
return true;
return strcmp(sString.m_pString, sOther.m_pString) == 0;
}
CString operator + (const CString& sString, const CString& sOther)
{
CString sAdd;
sAdd.m_nLength = sString.m_nLength + sOther.m_nLength;
if(sAdd.m_nLength == 0)
return sAdd;
if(sString.m_nLength == 0)
{
sAdd = sOther;
return sAdd;
}
else if(sOther.m_nLength == 0)
{
sAdd = sString;
return sAdd;
}
sAdd.m_pString = new char[sAdd.m_nLength+1];
strcpy(sAdd.m_pString, sString.m_pString);
strcat(sAdd.m_pString, sOther.m_pString);
return sAdd;
}
int CString::GetLength()
{
return m_nLength;
}
void CString::Replace(char a, char b)
{
int i;
for(i = 0; i < m_nLength; i++)
{
if(m_pString[i] == a)
m_pString[i] = b;
}
}
CString operator + (const char* szString, const CString& sString)
{
CString sAdd;
int nLen;
if(szString == NULL)
nLen = 0;
else
nLen = strlen(szString);
sAdd.m_nLength = sString.m_nLength + nLen;
if(sAdd.m_nLength == 0)
return sAdd;
if(sString.m_nLength == 0)
{
sAdd.m_nLength = nLen;
sAdd.m_pString = new char[nLen+1];
strcpy(sAdd.m_pString, szString);
return sAdd;
}
else if(nLen == 0)
{
sAdd = sString;
return sAdd;
}
sAdd.m_pString = new char[sAdd.m_nLength+1];
strcpy(sAdd.m_pString, szString);
strcat(sAdd.m_pString, sString.m_pString);
return sAdd;
}
CString operator + (const CString& sString, const char* szOther)
{
CString sAdd;
int nLen;
if(szOther == NULL)
nLen = 0;
else
nLen = strlen(szOther);
sAdd.m_nLength = sString.m_nLength + nLen;
if(sAdd.m_nLength == 0)
return sAdd;
if(sString.m_nLength == 0)
{
sAdd.m_nLength = nLen;
sAdd.m_pString = new char[nLen+1];
strcpy(sAdd.m_pString, szOther);
return sAdd;
}
else if(nLen == 0)
{
sAdd = sString;
return sAdd;
}
sAdd.m_pString = new char[sAdd.m_nLength+1];
strcpy(sAdd.m_pString, sString.m_pString);
strcat(sAdd.m_pString, szOther);
return sAdd;
}
char CString::operator[](int nIndex) const
{
if(nIndex >= m_nLength)
return 0;
return m_pString[nIndex];
}
void CString::MakeLower()
{
int i;
for(i = 0; i < m_nLength; i++)
m_pString[i] = (char)tolower(m_pString[i]);
}
void CString::MakeUpper()
{
int i;
for(i = 0; i < m_nLength; i++)
m_pString[i] = (char)toupper(m_pString[i]);
}
void CString::ConvertUnixPath()
{
if(m_nLength > 0)
::ConvertUnixPath(m_pString);
}
| 6,072 | 6,072 | 0.657115 | hogsy |
8226988fcd4940dee4d217a6ab9ec80e5580c01a | 13,806 | cpp | C++ | src/dawn_native/vulkan/BackendVk.cpp | dcerisano/dawn-ray-tracing-linux | 984b4cd0ca2886009a70c22d38cc656cbc565e67 | [
"Apache-2.0"
] | null | null | null | src/dawn_native/vulkan/BackendVk.cpp | dcerisano/dawn-ray-tracing-linux | 984b4cd0ca2886009a70c22d38cc656cbc565e67 | [
"Apache-2.0"
] | null | null | null | src/dawn_native/vulkan/BackendVk.cpp | dcerisano/dawn-ray-tracing-linux | 984b4cd0ca2886009a70c22d38cc656cbc565e67 | [
"Apache-2.0"
] | null | null | null | // Copyright 2019 The Dawn Authors
//
// 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 "dawn_native/vulkan/BackendVk.h"
#include "common/Log.h"
#include "common/SystemUtils.h"
#include "dawn_native/Instance.h"
#include "dawn_native/VulkanBackend.h"
#include "dawn_native/vulkan/AdapterVk.h"
#include "dawn_native/vulkan/VulkanError.h"
// TODO(crbug.com/dawn/283): Link against the Vulkan Loader and remove this.
#if defined(DAWN_ENABLE_SWIFTSHADER)
# if defined(DAWN_PLATFORM_LINUX) || defined(DAWN_PLATFORM_FUSCHIA)
constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.so";
# elif defined(DAWN_PLATFORM_WINDOWS)
constexpr char kSwiftshaderLibName[] = "vk_swiftshader.dll";
# elif defined(DAWN_PLATFORM_MAC)
constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.dylib";
# else
# error "Unimplemented Swiftshader Vulkan backend platform"
# endif
#endif
#if defined(DAWN_PLATFORM_LINUX)
# if defined(DAWN_PLATFORM_ANDROID)
constexpr char kVulkanLibName[] = "libvulkan.so";
# else
constexpr char kVulkanLibName[] = "libvulkan.so.1";
# endif
#elif defined(DAWN_PLATFORM_WINDOWS)
constexpr char kVulkanLibName[] = "vulkan-1.dll";
#elif defined(DAWN_PLATFORM_FUCHSIA)
constexpr char kVulkanLibName[] = "libvulkan.so";
#elif defined(DAWN_ENABLE_SWIFTSHADER)
const char* kVulkanLibName = kSwiftshaderLibName;
#else
# error "Unimplemented Vulkan backend platform"
#endif
namespace dawn_native { namespace vulkan {
Backend::Backend(InstanceBase* instance)
: BackendConnection(instance, wgpu::BackendType::Vulkan) {
}
Backend::~Backend() {
if (mDebugUtilsCallback != VK_NULL_HANDLE) {
mFunctions.DestroyDebugUtilsMessengerEXT(mInstance, mDebugUtilsCallback, nullptr);
mDebugUtilsCallback = VK_NULL_HANDLE;
}
if (mDebugReportCallback != VK_NULL_HANDLE) {
mFunctions.DestroyDebugReportCallbackEXT(mInstance, mDebugReportCallback, nullptr);
mDebugReportCallback = VK_NULL_HANDLE;
}
// VkPhysicalDevices are destroyed when the VkInstance is destroyed
if (mInstance != VK_NULL_HANDLE) {
mFunctions.DestroyInstance(mInstance, nullptr);
mInstance = VK_NULL_HANDLE;
}
}
const VulkanFunctions& Backend::GetFunctions() const {
return mFunctions;
}
VkInstance Backend::GetVkInstance() const {
return mInstance;
}
const VulkanGlobalInfo& Backend::GetGlobalInfo() const {
return mGlobalInfo;
}
MaybeError Backend::LoadVulkan() {
#if defined(DAWN_ENABLE_VULKAN_VALIDATION_LAYERS)
if (GetInstance()->IsBackendValidationEnabled()) {
std::string vkDataDir = GetExecutableDirectory() + DAWN_VK_DATA_DIR;
/*if (!SetEnvironmentVar("VK_LAYER_PATH", vkDataDir.c_str())) {
return DAWN_DEVICE_LOST_ERROR("Couldn't set VK_LAYER_PATH");
}*/
}
#endif
#if defined(DAWN_SWIFTSHADER_VK_ICD_JSON)
std::string fullSwiftshaderICDPath =
GetExecutableDirectory() + DAWN_SWIFTSHADER_VK_ICD_JSON;
if (!SetEnvironmentVar("VK_ICD_FILENAMES", fullSwiftshaderICDPath.c_str())) {
return DAWN_DEVICE_LOST_ERROR("Couldn't set VK_ICD_FILENAMES");
}
#endif
if (mVulkanLib.Open(kVulkanLibName)) {
return {};
}
dawn::WarningLog() << std::string("Couldn't open ") + kVulkanLibName;
#if defined(DAWN_ENABLE_SWIFTSHADER)
if (strcmp(kVulkanLibName, kSwiftshaderLibName) != 0) {
if (mVulkanLib.Open(kSwiftshaderLibName)) {
return {};
}
dawn::WarningLog() << std::string("Couldn't open ") + kSwiftshaderLibName;
}
#endif
return DAWN_DEVICE_LOST_ERROR("Couldn't load Vulkan");
}
MaybeError Backend::Initialize() {
DAWN_TRY(LoadVulkan());
DAWN_TRY(mFunctions.LoadGlobalProcs(mVulkanLib));
DAWN_TRY_ASSIGN(mGlobalInfo, GatherGlobalInfo(*this));
VulkanGlobalKnobs usedGlobalKnobs = {};
DAWN_TRY_ASSIGN(usedGlobalKnobs, CreateInstance());
*static_cast<VulkanGlobalKnobs*>(&mGlobalInfo) = usedGlobalKnobs;
DAWN_TRY(mFunctions.LoadInstanceProcs(mInstance, mGlobalInfo));
if (usedGlobalKnobs.debugUtils) {
DAWN_TRY(RegisterDebugUtils());
}
if (usedGlobalKnobs.debugReport) {
DAWN_TRY(RegisterDebugReport());
}
DAWN_TRY_ASSIGN(mPhysicalDevices, GetPhysicalDevices(*this));
return {};
}
std::vector<std::unique_ptr<AdapterBase>> Backend::DiscoverDefaultAdapters() {
std::vector<std::unique_ptr<AdapterBase>> adapters;
for (VkPhysicalDevice physicalDevice : mPhysicalDevices) {
std::unique_ptr<Adapter> adapter = std::make_unique<Adapter>(this, physicalDevice);
if (GetInstance()->ConsumedError(adapter->Initialize())) {
continue;
}
adapters.push_back(std::move(adapter));
}
return adapters;
}
ResultOrError<VulkanGlobalKnobs> Backend::CreateInstance() {
VulkanGlobalKnobs usedKnobs = {};
std::vector<const char*> layersToRequest;
std::vector<const char*> extensionsToRequest;
// vktrace works by instering a layer, but we hide it behind a macro due to the vktrace
// layer crashes when used without vktrace server started. See this vktrace issue:
// https://github.com/LunarG/VulkanTools/issues/254
// Also it is good to put it in first position so that it doesn't see Vulkan calls inserted
// by other layers.
#if defined(DAWN_USE_VKTRACE)
if (mGlobalInfo.vktrace) {
layersToRequest.push_back(kLayerNameLunargVKTrace);
usedKnobs.vktrace = true;
}
#endif
// RenderDoc installs a layer at the system level for its capture but we don't want to use
// it unless we are debugging in RenderDoc so we hide it behind a macro.
#if defined(DAWN_USE_RENDERDOC)
if (mGlobalInfo.renderDocCapture) {
layersToRequest.push_back(kLayerNameRenderDocCapture);
usedKnobs.renderDocCapture = true;
}
#endif
if (GetInstance()->IsBackendValidationEnabled()) {
if (mGlobalInfo.standardValidation) {
layersToRequest.push_back(kLayerNameLunargStandardValidation);
usedKnobs.standardValidation = true;
}
if (mGlobalInfo.debugUtils) {
extensionsToRequest.push_back(kExtensionNameExtDebugUtils);
usedKnobs.debugUtils = true;
}
if (mGlobalInfo.debugReport) {
extensionsToRequest.push_back(kExtensionNameExtDebugReport);
usedKnobs.debugReport = true;
}
}
if (mGlobalInfo.fuchsiaImagePipeSwapchain) {
layersToRequest.push_back(kLayerNameFuchsiaImagePipeSwapchain);
usedKnobs.fuchsiaImagePipeSwapchain = true;
}
// Always request all extensions used to create VkSurfaceKHR objects so that they are
// always available for embedders looking to create VkSurfaceKHR on our VkInstance.
if (mGlobalInfo.macosSurface) {
extensionsToRequest.push_back(kExtensionNameMvkMacosSurface);
usedKnobs.macosSurface = true;
}
if (mGlobalInfo.externalMemoryCapabilities) {
extensionsToRequest.push_back(kExtensionNameKhrExternalMemoryCapabilities);
usedKnobs.externalMemoryCapabilities = true;
}
if (mGlobalInfo.externalSemaphoreCapabilities) {
extensionsToRequest.push_back(kExtensionNameKhrExternalSemaphoreCapabilities);
usedKnobs.externalSemaphoreCapabilities = true;
}
if (mGlobalInfo.getPhysicalDeviceProperties2) {
extensionsToRequest.push_back(kExtensionNameKhrGetPhysicalDeviceProperties2);
usedKnobs.getPhysicalDeviceProperties2 = true;
}
if (mGlobalInfo.surface) {
extensionsToRequest.push_back(kExtensionNameKhrSurface);
usedKnobs.surface = true;
}
if (mGlobalInfo.waylandSurface) {
extensionsToRequest.push_back(kExtensionNameKhrWaylandSurface);
usedKnobs.waylandSurface = true;
}
if (mGlobalInfo.win32Surface) {
extensionsToRequest.push_back(kExtensionNameKhrWin32Surface);
usedKnobs.win32Surface = true;
}
if (mGlobalInfo.xcbSurface) {
extensionsToRequest.push_back(kExtensionNameKhrXcbSurface);
usedKnobs.xcbSurface = true;
}
if (mGlobalInfo.xlibSurface) {
extensionsToRequest.push_back(kExtensionNameKhrXlibSurface);
usedKnobs.xlibSurface = true;
}
if (mGlobalInfo.fuchsiaImagePipeSurface) {
extensionsToRequest.push_back(kExtensionNameFuchsiaImagePipeSurface);
usedKnobs.fuchsiaImagePipeSurface = true;
}
VkApplicationInfo appInfo;
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appInfo.pNext = nullptr;
appInfo.pApplicationName = nullptr;
appInfo.applicationVersion = 0;
appInfo.pEngineName = nullptr;
appInfo.engineVersion = 0;
appInfo.apiVersion = mGlobalInfo.apiVersion;
VkInstanceCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.pApplicationInfo = &appInfo;
createInfo.enabledLayerCount = static_cast<uint32_t>(layersToRequest.size());
createInfo.ppEnabledLayerNames = layersToRequest.data();
createInfo.enabledExtensionCount = static_cast<uint32_t>(extensionsToRequest.size());
createInfo.ppEnabledExtensionNames = extensionsToRequest.data();
if (usedKnobs.debugUtils) {
mDebugUtilsMessengerEXTInfo.sType =
VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
mDebugUtilsMessengerEXTInfo.messageSeverity =
(VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT);
mDebugUtilsMessengerEXTInfo.messageType =
(VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT);
mDebugUtilsMessengerEXTInfo.pfnUserCallback = Backend::OnDebugUtilsCallback;
createInfo.pNext = &mDebugUtilsMessengerEXTInfo;
}
DAWN_TRY(CheckVkSuccess(mFunctions.CreateInstance(&createInfo, nullptr, &mInstance),
"vkCreateInstance"));
return usedKnobs;
}
MaybeError Backend::RegisterDebugUtils() {
return CheckVkSuccess(
mFunctions.CreateDebugUtilsMessengerEXT(mInstance, &mDebugUtilsMessengerEXTInfo,
nullptr, &mDebugUtilsCallback),
"vkCreateDebugUtilsMessengerEXT");
}
MaybeError Backend::RegisterDebugReport() {
VkDebugReportCallbackCreateInfoEXT createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
createInfo.pNext = nullptr;
createInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
createInfo.pfnCallback = Backend::OnDebugReportCallback;
createInfo.pUserData = this;
return CheckVkSuccess(mFunctions.CreateDebugReportCallbackEXT(
mInstance, &createInfo, nullptr, &mDebugReportCallback),
"vkCreateDebugReportcallback");
}
VKAPI_ATTR VkBool32 VKAPI_CALL
Backend::OnDebugUtilsCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData) {
/*std::string msg;
msg += pCallbackData->pMessageIdName;
msg += "::";
msg += pCallbackData->pMessage;
dawn::WarningLog() << msg;*/
return VK_FALSE;
}
VKAPI_ATTR VkBool32 VKAPI_CALL
Backend::OnDebugReportCallback(VkDebugReportFlagsEXT flags,
VkDebugReportObjectTypeEXT /*objectType*/,
uint64_t /*object*/,
size_t /*location*/,
int32_t /*messageCode*/,
const char* /*pLayerPrefix*/,
const char* pMessage,
void* /*pUserdata*/) {
dawn::WarningLog() << pMessage;
ASSERT((flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) == 0);
return VK_FALSE;
}
BackendConnection* Connect(InstanceBase* instance) {
Backend* backend = new Backend(instance);
if (instance->ConsumedError(backend->Initialize())) {
delete backend;
return nullptr;
}
return backend;
}
}} // namespace dawn_native::vulkan
| 39.221591 | 99 | 0.659496 | dcerisano |
822b0c4fff7583ac3e10b2f283f7761fa34fd5fb | 932 | hpp | C++ | src/engine/physics/find-closest-edges.hpp | Ghabriel/ecs-pong | dde705134afd218812e1ac529519d92d8e965acd | [
"Apache-2.0"
] | null | null | null | src/engine/physics/find-closest-edges.hpp | Ghabriel/ecs-pong | dde705134afd218812e1ac529519d92d8e965acd | [
"Apache-2.0"
] | null | null | null | src/engine/physics/find-closest-edges.hpp | Ghabriel/ecs-pong | dde705134afd218812e1ac529519d92d8e965acd | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <vector>
#include "find-squared-distance.hpp"
#include "../shapes/Circle.hpp"
#include "../shapes/LineSegment.hpp"
#include "../shapes/Rectangle.hpp"
namespace physics {
std::vector<OrientedLineSegment> findClosestEdges(
const Rectangle& rect,
const Circle& circle
) {
std::array<OrientedLineSegment, 4> edges = rect.getOrientedEdges();
std::vector<OrientedLineSegment> result;
result.reserve(4);
float distance = -1;
for (const OrientedLineSegment& edge : edges) {
float d = findSquaredDistance(edge.segment, circle.center);
if (std::abs(d - distance) < 1e-3) {
result.push_back(edge);
} else if (distance == -1 || d < distance) {
result.clear();
result.push_back(edge);
distance = d;
}
}
return result;
}
}
| 27.411765 | 75 | 0.572961 | Ghabriel |
822b7a4d42f4a67cf9b38499807775364e266c2b | 1,371 | hh | C++ | TEvtGen/EvtGen/EvtGenBase/EvtSecondary.hh | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 52 | 2016-12-11T13:04:01.000Z | 2022-03-11T11:49:35.000Z | TEvtGen/EvtGen/EvtGenBase/EvtSecondary.hh | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 1,388 | 2016-11-01T10:27:36.000Z | 2022-03-30T15:26:09.000Z | TEvtGen/EvtGen/EvtGenBase/EvtSecondary.hh | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 275 | 2016-06-21T20:24:05.000Z | 2022-03-31T13:06:19.000Z | //--------------------------------------------------------------------------
//
// Environment:
// This software is part of the EvtGen package developed jointly
// for the BaBar and CLEO collaborations. If you use all or part
// of it, please give an appropriate acknowledgement.
//
// Copyright Information: See EvtGen/COPYRIGHT
// Copyright (C) 1998 Caltech, UCSB
//
// Module: EvtGen/EvtSecondary.hh
//
// Description:Class store decays of secondary particles
//
// Modification history:
//
// RYD March. 12, 1998 Module created
//
//------------------------------------------------------------------------
#ifndef EVTSECONDARY_HH
#define EVTSECONDARY_HH
const int EVTSECONDARYLENGTH =100;
class EvtParticle;
#include <iosfwd>
class EvtSecondary {
public:
EvtSecondary(){}
~EvtSecondary(){}
void init();
int getStdHepIndex(int i) {return _stdhepindex[i];}
int getD1(int i) {return _id1[i];}
int getD2(int i) {return _id2[i];}
int getD3(int i) {return _id3[i];}
int getNPart();
void createSecondary(int stdhepindex,EvtParticle* prnt);
friend std::ostream& operator<<(std::ostream& s, const EvtSecondary& secondary);
private:
int _npart;
int _stdhepindex[EVTSECONDARYLENGTH];
int _id1[EVTSECONDARYLENGTH];
int _id2[EVTSECONDARYLENGTH];
int _id3[EVTSECONDARYLENGTH];
};
#endif
| 22.47541 | 84 | 0.619256 | AllaMaevskaya |
822f788e50b97d15ef0dd250492453233577edd2 | 8,904 | cpp | C++ | Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp | patrickwilmes/serenity | 6df246091b633f7828e5315b681908dae1f89860 | [
"BSD-2-Clause"
] | null | null | null | Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp | patrickwilmes/serenity | 6df246091b633f7828e5315b681908dae1f89860 | [
"BSD-2-Clause"
] | null | null | null | Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp | patrickwilmes/serenity | 6df246091b633f7828e5315b681908dae1f89860 | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/AggregateError.h>
#include <LibJS/Runtime/Array.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/PromiseReaction.h>
#include <LibJS/Runtime/PromiseResolvingElementFunctions.h>
namespace JS {
PromiseResolvingElementFunction::PromiseResolvingElementFunction(size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
: NativeFunction(prototype)
, m_index(index)
, m_values(values)
, m_capability(move(capability))
, m_remaining_elements(remaining_elements)
{
}
void PromiseResolvingElementFunction::initialize(GlobalObject& global_object)
{
Base::initialize(global_object);
define_direct_property(vm().names.length, Value(1), Attribute::Configurable);
}
ThrowCompletionOr<Value> PromiseResolvingElementFunction::call()
{
if (m_already_called)
return js_undefined();
m_already_called = true;
return resolve_element();
}
void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(&m_values);
visitor.visit(m_capability.promise);
visitor.visit(m_capability.resolve);
visitor.visit(m_capability.reject);
visitor.visit(&m_remaining_elements);
}
PromiseAllResolveElementFunction* PromiseAllResolveElementFunction::create(GlobalObject& global_object, size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements)
{
return global_object.heap().allocate<PromiseAllResolveElementFunction>(global_object, index, values, capability, remaining_elements, *global_object.function_prototype());
}
PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
: PromiseResolvingElementFunction(index, values, move(capability), remaining_elements, prototype)
{
}
ThrowCompletionOr<Value> PromiseAllResolveElementFunction::resolve_element()
{
auto& vm = this->vm();
auto& global_object = this->global_object();
// 8. Set values[index] to x.
m_values.values()[m_index] = vm.argument(0);
// 9. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
// 10. If remainingElementsCount.[[Value]] is 0, then
if (--m_remaining_elements.value == 0) {
// a. Let valuesArray be ! CreateArrayFromList(values).
auto* values_array = Array::create_from(global_object, m_values.values());
// b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
return JS::call(global_object, *m_capability.resolve, js_undefined(), values_array);
}
// 11. Return undefined.
return js_undefined();
}
PromiseAllSettledResolveElementFunction* PromiseAllSettledResolveElementFunction::create(GlobalObject& global_object, size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements)
{
return global_object.heap().allocate<PromiseAllSettledResolveElementFunction>(global_object, index, values, capability, remaining_elements, *global_object.function_prototype());
}
PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
: PromiseResolvingElementFunction(index, values, move(capability), remaining_elements, prototype)
{
}
ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_element()
{
auto& vm = this->vm();
auto& global_object = this->global_object();
// 9. Let obj be ! OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(global_object, global_object.object_prototype());
// 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "fulfilled").
MUST(object->create_data_property_or_throw(vm.names.status, js_string(vm, "fulfilled"sv)));
// 11. Perform ! CreateDataPropertyOrThrow(obj, "value", x).
MUST(object->create_data_property_or_throw(vm.names.value, vm.argument(0)));
// 12. Set values[index] to obj.
m_values.values()[m_index] = object;
// 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
// 14. If remainingElementsCount.[[Value]] is 0, then
if (--m_remaining_elements.value == 0) {
// a. Let valuesArray be ! CreateArrayFromList(values).
auto* values_array = Array::create_from(global_object, m_values.values());
// b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
return JS::call(global_object, *m_capability.resolve, js_undefined(), values_array);
}
// 15. Return undefined.
return js_undefined();
}
PromiseAllSettledRejectElementFunction* PromiseAllSettledRejectElementFunction::create(GlobalObject& global_object, size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements)
{
return global_object.heap().allocate<PromiseAllSettledRejectElementFunction>(global_object, index, values, capability, remaining_elements, *global_object.function_prototype());
}
PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
: PromiseResolvingElementFunction(index, values, move(capability), remaining_elements, prototype)
{
}
ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element()
{
auto& vm = this->vm();
auto& global_object = this->global_object();
// 9. Let obj be ! OrdinaryObjectCreate(%Object.prototype%).
auto* object = Object::create(global_object, global_object.object_prototype());
// 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "rejected").
MUST(object->create_data_property_or_throw(vm.names.status, js_string(vm, "rejected"sv)));
// 11. Perform ! CreateDataPropertyOrThrow(obj, "reason", x).
MUST(object->create_data_property_or_throw(vm.names.reason, vm.argument(0)));
// 12. Set values[index] to obj.
m_values.values()[m_index] = object;
// 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
// 14. If remainingElementsCount.[[Value]] is 0, then
if (--m_remaining_elements.value == 0) {
// a. Let valuesArray be ! CreateArrayFromList(values).
auto* values_array = Array::create_from(global_object, m_values.values());
// b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
return JS::call(global_object, *m_capability.resolve, js_undefined(), values_array);
}
// 15. Return undefined.
return js_undefined();
}
PromiseAnyRejectElementFunction* PromiseAnyRejectElementFunction::create(GlobalObject& global_object, size_t index, PromiseValueList& errors, PromiseCapability capability, RemainingElements& remaining_elements)
{
return global_object.heap().allocate<PromiseAnyRejectElementFunction>(global_object, index, errors, capability, remaining_elements, *global_object.function_prototype());
}
PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, PromiseCapability capability, RemainingElements& remaining_elements, Object& prototype)
: PromiseResolvingElementFunction(index, errors, move(capability), remaining_elements, prototype)
{
}
ThrowCompletionOr<Value> PromiseAnyRejectElementFunction::resolve_element()
{
auto& vm = this->vm();
auto& global_object = this->global_object();
// 8. Set errors[index] to x.
m_values.values()[m_index] = vm.argument(0);
// 9. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
// 10. If remainingElementsCount.[[Value]] is 0, then
if (--m_remaining_elements.value == 0) {
// a. Let error be a newly created AggregateError object.
auto* error = AggregateError::create(global_object);
// b. Perform ! DefinePropertyOrThrow(error, "errors", PropertyDescriptor { [[Configurable]]: true, [[Enumerable]]: false, [[Writable]]: true, [[Value]]: ! CreateArrayFromList(errors) }).
auto* errors_array = Array::create_from(global_object, m_values.values());
MUST(error->define_property_or_throw(vm.names.errors, { .value = errors_array, .writable = true, .enumerable = false, .configurable = true }));
// c. Return ? Call(promiseCapability.[[Reject]], undefined, « error »).
return JS::call(global_object, *m_capability.reject, js_undefined(), error);
}
return js_undefined();
}
}
| 44.298507 | 226 | 0.750562 | patrickwilmes |
82303b45ab9d5739e17f6ddf085cb05be6335f06 | 604 | cpp | C++ | tests/clocale/clocale_fwd.cpp | olegpublicprofile/stdfwd | 19671bcc8e53bd4c008f07656eaf25a22495e093 | [
"MIT"
] | 11 | 2021-03-15T07:06:21.000Z | 2021-09-27T13:54:25.000Z | tests/clocale/clocale_fwd.cpp | olegpublicprofile/stdfwd | 19671bcc8e53bd4c008f07656eaf25a22495e093 | [
"MIT"
] | null | null | null | tests/clocale/clocale_fwd.cpp | olegpublicprofile/stdfwd | 19671bcc8e53bd4c008f07656eaf25a22495e093 | [
"MIT"
] | 1 | 2021-06-24T10:46:46.000Z | 2021-06-24T10:46:46.000Z | #include "tests/clocale/clocale_fwd.hpp"
#include <clocale>
//------------------------------------------------------------------------------
namespace clocale_tests {
//------------------------------------------------------------------------------
int TestClass::getInt()
{
return 42;
}
//------------------------------------------------------------------------------
std::lconv TestClass::getLconv()
{
return std::lconv();
}
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------
| 20.133333 | 80 | 0.221854 | olegpublicprofile |
4363cc88e33fd11cbef2a3d9b217dee7d2770f51 | 6,140 | cpp | C++ | dsp/common/multicore/jacobian_on_core.cpp | RoelofBerg/fimreg | df8c58c38017af685911767c156cbe1db01546a2 | [
"BSD-3-Clause"
] | 6 | 2015-06-04T12:53:20.000Z | 2021-06-01T09:47:52.000Z | dsp/common/multicore/jacobian_on_core.cpp | RoelofBerg/fimreg | df8c58c38017af685911767c156cbe1db01546a2 | [
"BSD-3-Clause"
] | null | null | null | dsp/common/multicore/jacobian_on_core.cpp | RoelofBerg/fimreg | df8c58c38017af685911767c156cbe1db01546a2 | [
"BSD-3-Clause"
] | 7 | 2015-07-30T09:36:14.000Z | 2018-08-24T03:59:27.000Z | /* =====================================
=== FIMREG - Fast Image Registration ===
========================================
Written by Roelof Berg, Berg Solutions (rberg@berg-solutions.de) with support from
Lars Koenig, Fraunhofer MEVIS (lars.koenig@mevis.fraunhofer.de) Jan Ruehaak, Fraunhofer
MEVIS (jan.ruehaak@mevis.fraunhofer.de).
THIS IS A LIMITED RESEARCH PROTOTYPE. Documentation: www.berg-solutions.de/fimreg.html
------------------------------------------------------------------------------
Copyright (c) 2014, Roelof Berg
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 owner 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.
----------------------------------------------------------------------------*/
/*
* jacobian.cpp
*
* CODE GENERATED BY MATLAB CODER (THE HUMAN READABILITY IS THEREFORE LIMITED)
*
*/
/* Include files */
#include "calcDSPLayout.h"
#include "jacobian_on_core.h"
#include "ssd_on_core.h"
/* Custom Source Code */
#include "pseudo_stdafx.h" //precompiled header not possible because of include position of matlab
#include "stdio.h"
#include "string.h"
#include "logout.h"
#include "matlab_c_ssdRigid2D.h"
/* Type Definitions */
/* Named Constants */
/* Variable Declarations */
/* Variable Definitions */
/* Function Declarations */
/* Function Definitions */
void jacobian_on_core(const real32_T w[3], const uint32_T BoundBox[4], const uint32_T MarginAddon[3], const real32_T
DSPRange[4], const uint8_T *Tvec, const uint32_T TOffset, const uint8_T*
Rvec, const uint32_T ROffset, const uint32_T d, real32_T *SSD, real32_T JD[3], real32_T JD2[9], const uint32_T i_from, const uint32_T i_to)
{
real32_T omegaR[4];
real32_T omegaT[4];
int32_T mR[2];
int32_T mT[2];
//Clear return memory (values will be summed up, so have to start at 0)
*SSD=0;
memset(JD, 0, sizeof(real32_T) * 3);
memset(JD2, 0, sizeof(real32_T) * 9);
#ifdef _TRACE_MC_
logout("[sjh_%u] Calc SSD JAC HESS from %u to %u DSPRange[%f,%f,%f,%f]\n", i_from, i_from, i_to, (double)DSPRange[0], (double)DSPRange[1], (double)DSPRange[2], (double)DSPRange[3]);
#endif
omegaR[0] = DSPRange[0]-0.5f;
omegaR[1] = DSPRange[1]+0.5f;
omegaR[2] = DSPRange[2]-0.5f;
omegaR[3] = DSPRange[3]+0.5f;
mR[0] = (int)(omegaR[1]-omegaR[0]);
mR[1] = (int)(omegaR[3]-omegaR[2]);
const real32_T shift = (d/2)+0.5f;
omegaT[0] = BoundBox[0] - shift-0.5f;
omegaT[1] = BoundBox[1] - shift+0.5f;
omegaT[2] = BoundBox[2] - shift-0.5f;
omegaT[3] = BoundBox[3] - shift+0.5f;
mT[0] = (int)(BoundBox[1]-BoundBox[0])+1;
mT[1] = (int)(BoundBox[3]-BoundBox[2])+1;
//debug
#ifdef _TRACE_OUTPUT_
logout("d=%u, shift=%f\n", d, (double)shift);
const uint8_T* p=&Tvec[TOffset];
uint32_T iWidth = (BoundBox[1]+1)-BoundBox[0];
uint32_T iHeight = (BoundBox[3]+1)-BoundBox[2];
uint32_T iA=(iWidth+MarginAddon[0])*((iHeight/4)+MarginAddon[1])+(iWidth/4)-1;
uint32_T iB=(iWidth+MarginAddon[0])*((iHeight/2)+MarginAddon[1])+(iWidth*3/4)-1;
uint32_T iC=(iWidth+MarginAddon[0])*((iHeight*6/10)+MarginAddon[1])+(iWidth*8/10)-1;
logout("f(0), f(1) ... f(0x%x), f(0x%x) ... f(0x%x), f(0x%x)\n", iA, iA+1, iB-1, iB);
logout("T: %.2x %.2x ... %.2x %.2x ... %.2x %.2x ... %.2x %.2x\n",
p[0], p[1], p[iA], p[iA+1], p[iB-1], p[iB], p[iC-1], p[iC]
);
p=&Rvec[ROffset];
iWidth = uint32_T(DSPRange[1]-DSPRange[0]);
iHeight = uint32_T(DSPRange[3]-DSPRange[2]);
iA=iWidth*(iHeight/4)+(iWidth/4)-1;
iB=iWidth*(iHeight/2)+(iWidth*3/4)-1;
iC=iWidth*(iHeight*6/10)+(iWidth*8/10)-1;
logout("R: %.2x %.2x ... %.2x %.2x ... %.2x %.2x ... %.2x %.2x\n",
p[0], p[1], p[iA], p[iA+1], p[iB-1], p[iB], p[iC-1], p[iC]
);
logout("mT=[%u, %u], omegaT=[%f, %f, %f, %f]\n",
mT[0], mT[1], (double)omegaT[0], (double)omegaT[1], (double)omegaT[2], (double)omegaT[3]);
logout("mR=[%u, %u], omegaR=[%f, %f, %f, %f]\n",
mR[0], mR[1], (double)omegaR[0], (double)omegaR[1], (double)omegaR[2], (double)omegaR[3]);
logout("MarginAddon=[%u, %u, %u], DSPRange=[%f, %f, %f, %f], d=%u\n",
MarginAddon[0], MarginAddon[1], MarginAddon[2], (double)DSPRange[0], (double)DSPRange[1], (double)DSPRange[2], (double)DSPRange[3], d);
#endif
*SSD = matlab_c_ssdRigid2D((t_pixel*)(&Rvec[ROffset]), mR, omegaR,
(t_pixel*)(&Tvec[TOffset]), mT, omegaT,
&w[0], &MarginAddon[0],
&DSPRange[0], i_from, i_to, JD, JD2);
#ifdef _TRACE_MC_
logout("[sjh_%u] SSD = %f, JD = [%f %f %f], JD2 = [%f ... %f ... %f]\n", i_from, *SSD, (double)JD[0], (double)JD[1], (double)JD[2], (double)JD2[0], (double)JD2[4], (double)JD2[8]);
#endif
}
/* End of code generation (jacobian.cpp) */
| 39.87013 | 183 | 0.633062 | RoelofBerg |
436804273ff4ef547312b09eaa05413fe2232f55 | 3,045 | hpp | C++ | fprime-sphinx-drivers/Util/SphinxDrvUtil.hpp | fprime-community/fprime-sphinx-drivers | ce9efa8564b0eeee46b75bdee79a41a4d0dfd65b | [
"Apache-2.0"
] | 1 | 2021-02-22T12:34:25.000Z | 2021-02-22T12:34:25.000Z | fprime-sphinx-drivers/Util/SphinxDrvUtil.hpp | fprime-community/fprime-sphinx-drivers | ce9efa8564b0eeee46b75bdee79a41a4d0dfd65b | [
"Apache-2.0"
] | 2 | 2021-08-11T17:14:54.000Z | 2021-09-09T22:31:19.000Z | fprime-sphinx-drivers/Util/SphinxDrvUtil.hpp | fprime-community/fprime-sphinx-drivers | ce9efa8564b0eeee46b75bdee79a41a4d0dfd65b | [
"Apache-2.0"
] | 1 | 2021-05-19T02:04:10.000Z | 2021-05-19T02:04:10.000Z | // ======================================================================
// \title SphinxDrvUtil.hpp
// \author arizvi
// \brief hpp file for Sphinx Util
//
// \copyright
// Copyright 2009-2015, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// ======================================================================
#ifndef SPHINX_DRV_UTIL_HPP
#define SPHINX_DRV_UTIL_HPP
#include "Fw/Types/BasicTypes.hpp"
#include "SphinxDrvTimerUtil.hpp"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifndef TGT_OS_TYPE_VXWORKS
#include <map>
#endif
#define U32_MAX (0xffffffff)
#define I32_MAX (0x7fffffff)
#define I32_MIN (0x80000000)
#define BITS_PER_BYTE 8
namespace Drv {
#ifndef TGT_OS_TYPE_VXWORKS
/* Emulated register memory for unit tests */
extern std::map<U32, U32> emuRegMap;
#endif
/**
* type manipulation functions
*/
/* Converts a buffer address into a U32 for writes
*
* NB: this will chop off a pointer in 64-bit architectures. Only use if
* you're sure you want exactly 4 bytes from the pointer, but may need to
* cross-compile in different architectures.
*/
U32 ptrToU32(U8* ptr);
/* Converts a word address into a U32
*
* NB: this will chop off a pointer in 64-bit architectures. Only use if
* you're sure you want exactly 4 bytes from the pointer, but may need to
* cross-compile in different architectures.
*/
U32 ptrToU32(U32* ptr);
/* Takes the address of the word as a U8* buf
*/
U8* wordAsBuf(U32& word);
/**
* Memory manipulation functions
*/
/* Writes one bit at a given address */
void writeMemBit(U8* mem, U32 bit, U32 val);
/* Reads one bit at a given address */
U32 readMemBit(U8* mem, U32 bit);
/**
* Register manipulation functions
*/
/* Reads the register of a given address */
U32 readReg(U32 reg);
/* Writes to the register of a given address */
void writeReg(U32 reg, U32 val, U32 flag = 0);
/* Reads a bitrange of the register of a given address
*
* Imagine scanning from right (LSB) to left (MSB), extracting `count` bits
* starting at bit `start`
*
* e.g. readRegPartial(reg, 0, 32) is the entire word
* readRegPartial(reg, 5, 1) is bit 5's value
* readRegPartial(reg, 8, 8) is the 2nd LSB byte's value
*/
U32 readRegPartial(U32 reg, U32 start, U32 count);
/* Writes a bitrange of the register of a given address
*
* Imagine scanning from right (LSB) to left (MSB), overwriting `count` bits
* starting at bit `start`
*
* NB: Functions like a read-modify-write, but is not atomic
*
* e.g. num = 0xf00
* writeRegPartial((U32)(&num), 0, 4, 0xf); num == 0xf0f
* writeRegPartial((U32)(&num), 4, 4, 0xe); num == 0xfef
* writeRegPartial((U32)(&num), 8, 8, 0xbe); num == 0xbeef
*/
void writeRegPartial(U32 reg, U32 start, U32 count, U32 val);
/* Reads one bit value at a given register */
U32 readBit(U32 reg, U32 bit);
}
#endif
| 27.681818 | 78 | 0.639409 | fprime-community |
436819bf2de1e80f438c5c1d7aa0758f8f82d75e | 1,667 | hpp | C++ | Voicebank.hpp | haruneko/uzume_utau | da0656ccaa5b3e12f28acd9ed20d07799dcf798c | [
"MIT"
] | null | null | null | Voicebank.hpp | haruneko/uzume_utau | da0656ccaa5b3e12f28acd9ed20d07799dcf798c | [
"MIT"
] | null | null | null | Voicebank.hpp | haruneko/uzume_utau | da0656ccaa5b3e12f28acd9ed20d07799dcf798c | [
"MIT"
] | null | null | null | // Copyright 2020 Hal@shurabaP. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
#ifndef UZUME_UTAU_VOICEBANK_HPP
#define UZUME_UTAU_VOICEBANK_HPP
#include <vector>
#include "Affix.hpp"
#include "Character.hpp"
#include "WaveLabel.hpp"
namespace uzume { namespace utau {
extern const char *CharacterFilename;
extern const char *LabelsFilename;
extern const char *AffixesFilename;
std::string DefaultFileReader(const char *filepath);
std::vector<std::string> DefaultDirectoryEnumerator(const char *filepath);
/**
* Voicebank represents a single UTAU voicebank.
*/
class Voicebank final {
public:
Voicebank() = delete;
Voicebank(Character character, Affixes affixes, std::unordered_map<std::string, std::vector<WaveLabel> > labels);
/**
* Voicebank#from generates Voicebank in a single directory.
* @param filepath to a UTAU voicebank.
* @param read specifies a way to read files. (For debug or testing)
* @param enumerate specifies a way to enumerate a list of directories in a specified directory. (For debug or testing)
*/
static Voicebank from(
const char* filepath,
const std::function<std::string(const char*)>& read = DefaultFileReader,
const std::function<std::vector<std::string>(const char*)>& enumerate = DefaultDirectoryEnumerator);
std::string to_string() const;
const Character character;
const Affixes affixes;
const std::unordered_map<std::string, std::vector<WaveLabel> > labels;
};
} }
#endif //UZUME_UTAU_VOICEBANK_HPP
| 33.34 | 124 | 0.704259 | haruneko |
43681ddfee9d42e9843642182c62e17106954fbd | 4,160 | cc | C++ | src/Modules/Legacy/Math/SetSubmatrix.cc | mhansen1/SCIRun | 9719c570a6d6911a9eb8df584bd2c4ad8b8cd2ba | [
"Unlicense"
] | null | null | null | src/Modules/Legacy/Math/SetSubmatrix.cc | mhansen1/SCIRun | 9719c570a6d6911a9eb8df584bd2c4ad8b8cd2ba | [
"Unlicense"
] | null | null | null | src/Modules/Legacy/Math/SetSubmatrix.cc | mhansen1/SCIRun | 9719c570a6d6911a9eb8df584bd2c4ad8b8cd2ba | [
"Unlicense"
] | null | null | null | /*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2015 Scientific Computing and Imaging Institute,
University of Utah.
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.
*/
///
///@class SetSubmatrix
///@brief Clip out a subregion from a Matrix
///
///@author
/// Michael Callahan
/// Department of Computer Science
/// University of Utah
///@date January 2002
///
#include <Dataflow/Network/Ports/MatrixPort.h>
#include <Dataflow/Network/Module.h>
#include <Dataflow/GuiInterface/GuiVar.h>
#include <Core/Util/StringUtil.h>
namespace SCIRun {
class SetSubmatrix : public Module
{
private:
GuiInt startcol_;
GuiInt startrow_;
GuiInt nrow_;
GuiInt ncol_;
GuiInt srow_;
GuiInt scol_;
public:
SetSubmatrix(GuiContext* ctx);
virtual ~SetSubmatrix();
virtual void execute();
};
DECLARE_MAKER(SetSubmatrix)
SetSubmatrix::SetSubmatrix(GuiContext* ctx)
: Module("SetSubmatrix", ctx, Filter,"Math", "SCIRun"),
startcol_(get_ctx()->subVar("startcol"), 0),
startrow_(get_ctx()->subVar("startrow"), 0),
nrow_(get_ctx()->subVar("nrow"), 0),
ncol_(get_ctx()->subVar("ncol"), 0),
srow_(get_ctx()->subVar("srow"), 0),
scol_(get_ctx()->subVar("scol"), 0)
{
}
SetSubmatrix::~SetSubmatrix()
{
}
void
SetSubmatrix::execute()
{
MatrixHandle imatrix;
if (!get_input_handle("Input Matrix", imatrix))
return;
MatrixHandle smatrix;
if (!get_input_handle("Input Submatrix", smatrix))
return;
if( inputs_changed_ )
{
nrow_.set(imatrix->nrows());
ncol_.set(imatrix->ncols());
srow_.set(smatrix->nrows());
scol_.set(smatrix->ncols());
nrow_.reset();
ncol_.reset();
srow_.reset();
scol_.reset();
}
MatrixHandle cmatrix;
if (get_input_handle("Optional Start Bounds", cmatrix, false))
{
if( cmatrix->nrows() == 2 && cmatrix->ncols() == 1 )
{
startrow_.set( (int) (size_type)cmatrix->get(0, 0) );
startcol_.set( (int) (size_type)cmatrix->get(1, 0) );
startrow_.reset();
startcol_.reset();
}
else if( cmatrix->nrows() == 1 && cmatrix->ncols() == 2 )
{
startrow_.set( (int) (size_type)cmatrix->get(0, 0) );
startcol_.set( (int) (size_type)cmatrix->get(0, 1) );
startrow_.reset();
startcol_.reset();
}
else
{
error( "Input start matrix is not a 2x1 or 1x2 matrix" );
return;
}
}
if (startrow_.get() + srow_.get() > nrow_.get() ||
startcol_.get() + scol_.get() > ncol_.get() )
{
error("Start plus submatrix range must be less than or equal to max range.");
return;
}
if( inputs_changed_ ||
!oport_cached("Output Matrix") ||
startrow_.changed( true ) ||
startcol_.changed( true ) )
{
MatrixHandle omatrix = imatrix->clone();
for( int row=0; row<smatrix->nrows(); ++row)
{
for( int col=0; col<smatrix->ncols(); ++col)
{
omatrix->put( startrow_.get()+row, startcol_.get()+col,
smatrix->get(row, col) );
}
}
send_output_handle("Output Matrix", omatrix);
}
}
} // End namespace SCIRun
| 24.186047 | 81 | 0.660577 | mhansen1 |
436ae36119c1f88b4a67aad6dfe221de70f98198 | 640 | cpp | C++ | Kattis_Problems/Pivot.cpp | MAXI0008/Kattis-Problems | ff6ec752b741a56fc37a993c528fc925ca302cc8 | [
"MIT"
] | 3 | 2019-04-01T05:38:09.000Z | 2021-11-17T11:43:20.000Z | Kattis_Problems/Pivot.cpp | MAXI0008/Algorithms-Practices | ff6ec752b741a56fc37a993c528fc925ca302cc8 | [
"MIT"
] | null | null | null | Kattis_Problems/Pivot.cpp | MAXI0008/Algorithms-Practices | ff6ec752b741a56fc37a993c528fc925ca302cc8 | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
int main() {
vector<int> V;
vector<int> Vmax;
vector<int> Vmin;
int n;
cin >> n;
int v;
for (int i = 0; i < n; i++) {
cin >> v;
V.push_back(v);
Vmax.push_back(0);
Vmin.push_back(0);
}
Vmax[0] = V[0];
for (int i = 1; i < n; i++) {
Vmax[i] = max(V[i], Vmax[i-1]);
}
Vmin[n-1] = V[n-1];
for (int i = n-2; i >= 0; i--) {
Vmin[i] = min(V[i], Vmin[i+1]);
}
int r = 0;
for (int i = 0; i < n; i++) {
if (V[i] >= Vmax[i] && V[i] <= Vmin[i]) r++;
}
cout << r;
return 0;
} | 20.645161 | 52 | 0.403125 | MAXI0008 |
436fcddd955a05e1148cf9f92ea4ffe945e7e01c | 1,265 | cpp | C++ | Galaga/framework/Node.cpp | MKachi/Galaga | 0601dcc8492530c6ac9176803b9e2bb8c8ae6b1e | [
"MIT"
] | null | null | null | Galaga/framework/Node.cpp | MKachi/Galaga | 0601dcc8492530c6ac9176803b9e2bb8c8ae6b1e | [
"MIT"
] | null | null | null | Galaga/framework/Node.cpp | MKachi/Galaga | 0601dcc8492530c6ac9176803b9e2bb8c8ae6b1e | [
"MIT"
] | null | null | null | #include "Node.h"
Node::Node()
: _tag("")
, _active(true)
, _depth(0)
, _position(Vector2::zero)
, _rotate(0.0f)
, _scale(Vector2::one)
, _parent(nullptr)
{ }
Node::~Node()
{ }
void Node::setTag(const string& tag)
{ }
void Node::setActive(bool active)
{
_active = active;
}
void Node::setDepth(int depth)
{
_depth = depth;
}
void Node::setPosition(const Vector2& position)
{
_position = position;
}
void Node::setRotate(float rotate)
{
_rotate = rotate;
}
void Node::setScale(const Vector2& scale)
{
_scale = scale;
}
void Node::removeParent()
{
_parent->removeChild(this);
_parent = nullptr;
}
void Node::setParent(Node* parent)
{
_parent = parent;
}
void Node::addChild(Node* child)
{
_children.push_back(child);
}
void Node::removeChild(Node* child)
{
_children.erase(std::find(_children.begin(), _children.end(), child));
}
void Node::removeChildByTag(const string& tag)
{
Node* target = nullptr;
for (auto& child : _children)
{
if (child->getTag() == tag)
{
target = child;
}
}
_children.erase(std::find(_children.begin(), _children.end(), target));
}
Node* Node::getChildByTag(const string& tag)
{
for (auto& child : _children)
{
if (child->getTag() == tag)
{
return child;
}
}
return nullptr;
}
| 14.213483 | 72 | 0.656126 | MKachi |
4370243553713eb28962a5da9a948686a9020bc0 | 22,325 | cpp | C++ | DiscImageCreator/xml.cpp | rmMinusR/DiscImageCreator | 073bb40c06e3249d9d6b52975c7f0e60ef754040 | [
"Apache-2.0"
] | null | null | null | DiscImageCreator/xml.cpp | rmMinusR/DiscImageCreator | 073bb40c06e3249d9d6b52975c7f0e60ef754040 | [
"Apache-2.0"
] | null | null | null | DiscImageCreator/xml.cpp | rmMinusR/DiscImageCreator | 073bb40c06e3249d9d6b52975c7f0e60ef754040 | [
"Apache-2.0"
] | null | null | null | /**
* Copyright 2011-2018 sarami
*
* 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 "struct.h"
#include "calcHash.h"
#include "check.h"
#include "execIoctl.h"
#include "execScsiCmd.h"
#include "execScsiCmdforCD.h"
#include "execScsiCmdforDVD.h"
#include "get.h"
#include "init.h"
#include "output.h"
#include "xml.h"
#include "_external/prngcd.h"
BOOL OutputGameHash(
#ifdef _WIN32
CComPtr<IXmlWriter> pWriter,
#else
XMLElement* pWriter,
#endif
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDISC pDisc,
_TCHAR* pszFullPath,
_TCHAR* szPath,
BOOL bDesync
) {
if (*pExecType == fd) {
if (!OutputHash(pWriter, pszFullPath, _T(".bin"), 1, 1, FALSE)) {
return FALSE;
}
}
else if (*pExecType == dvd || *pExecType == xbox || *pExecType == xboxswap ||
*pExecType == xgd2swap || *pExecType == xgd3swap || *pExecType == bd) {
if (!OutputHash(pWriter, pszFullPath, _T(".iso"), 1, 1, FALSE)) {
return FALSE;
}
if (pExtArg->byRawDump) {
if (!OutputHash(pWriter, pszFullPath, _T(".raw"), 1, 1, FALSE)) {
return FALSE;
}
}
if (*pExecType == dvd || *pExecType == xbox) {
_tcsncpy(szPath, pszFullPath, _MAX_PATH);
if (*pExecType == xbox) {
if (!PathRemoveFileSpec(szPath)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!PathAppend(szPath, _T("SS.bin"))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!OutputHash(pWriter, szPath, _T(".bin"), 1, 1, FALSE)) {
return FALSE;
}
}
if (!PathRemoveFileSpec(szPath)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!PathAppend(szPath, _T("PFI.bin"))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!OutputHash(pWriter, szPath, _T(".bin"), 1, 1, FALSE)) {
return FALSE;
}
if (!PathRemoveFileSpec(szPath)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!PathAppend(szPath, _T("DMI.bin"))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!OutputHash(pWriter, szPath, _T(".bin"), 1, 1, FALSE)) {
return FALSE;
}
}
}
else {
if (!pDisc->SUB.byDesync || !bDesync) {
OutputDiscLogA(OUTPUT_DHYPHEN_PLUS_STR(Hash(Whole image)));
if (pDisc->SCSI.trackType == TRACK_TYPE::dataExist ||
pDisc->SCSI.trackType == TRACK_TYPE::pregapDataIn1stTrack) {
if (!OutputHash(pWriter, pszFullPath, _T(".scm"), 1, 1, FALSE)) {
return FALSE;
}
}
if (!OutputHash(pWriter, pszFullPath, _T(".img"), 1, 1, FALSE)) {
return FALSE;
}
}
for (UCHAR i = pDisc->SCSI.toc.FirstTrack; i <= pDisc->SCSI.toc.LastTrack; i++) {
if (!OutputHash(pWriter, pszFullPath, _T(".bin"), i, pDisc->SCSI.toc.LastTrack, bDesync)) {
return FALSE;
}
}
}
return TRUE;
}
BOOL ReadWriteDat(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDISC pDisc,
_TCHAR* pszFullPath,
_TCHAR* szDrive,
_TCHAR* szDir,
_TCHAR* szFname,
BOOL bDesync
) {
#ifdef _WIN32
WCHAR wszDefaultDat[_MAX_PATH] = {};
if (!GetModuleFileNameW(NULL, wszDefaultDat, sizeof(wszDefaultDat) / sizeof(wszDefaultDat[0]))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!PathRemoveFileSpecW(wszDefaultDat)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!PathAppendW(wszDefaultDat, L"default.dat")) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
HRESULT hr = S_OK;
CComPtr<IXmlReader> pReader;
CComPtr<IStream> pReadStream;
if (FAILED(hr = SHCreateStreamOnFileW(wszDefaultDat, STGM_READ, &pReadStream))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = CreateXmlReader(__uuidof(IXmlReader), reinterpret_cast<void**>(&pReader), 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pReader->SetInput(pReadStream))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pReader->SetProperty(XmlReaderProperty_DtdProcessing, DtdProcessing_Parse))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
WCHAR wszPathForDat[_MAX_PATH] = {};
_TCHAR szTmpPath[_MAX_PATH] = {};
if (bDesync) {
_sntprintf(szTmpPath, _MAX_PATH, _T("%s\\%s\\%s (Subs indexes).dat"), szDrive, szDir, szFname);
}
else {
_sntprintf(szTmpPath, _MAX_PATH, _T("%s\\%s\\%s.dat"), szDrive, szDir, szFname);
}
szTmpPath[_MAX_FNAME - 1] = 0;
#ifndef UNICODE
if (!MultiByteToWideChar(CP_ACP, 0
, szTmpPath, sizeof(szTmpPath) / sizeof(szTmpPath[0])
, wszPathForDat, sizeof(wszPathForDat) / sizeof(wszPathForDat[0]))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
#else
//RSC MOD type definition (was redefined at line 235)
size_t size = sizeof(wszPathForDat) / sizeof(wszPathForDat[0]);
wcsncpy(wszPathForDat, szTmpPath, size);
wszPathForDat[size - 1] = 0;
#endif
CComPtr<IXmlWriter> pWriter;
CComPtr<IStream> pWriteStream;
if (FAILED(hr = SHCreateStreamOnFileW(wszPathForDat, STGM_CREATE | STGM_WRITE, &pWriteStream))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = CreateXmlWriter(__uuidof(IXmlWriter), reinterpret_cast<void**>(&pWriter), 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pWriter->SetOutput(pWriteStream))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pWriter->SetProperty(XmlWriterProperty_Indent, TRUE))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pWriter->WriteStartDocument(XmlStandalone_Omit))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pWriter->WriteDocType(L"datafile"
, L"-//Logiqx//DTD ROM Management Datafile//EN", L"http://www.logiqx.com/Dats/datafile.dtd", NULL))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
WCHAR wszDir[_MAX_DIR] = {};
#ifndef UNICODE
if (!MultiByteToWideChar(CP_ACP, 0, szDir, _MAX_DIR, wszDir, sizeof(wszDir) / sizeof(wszDir[0]))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
#else
//RSC MOD removed redefinition
size = sizeof(wszDir) / sizeof(wszDir[0]);
wcsncpy(wszDir, szDir, size);
wszDir[size - 1] = 0;
#endif
LPWCH p = wcsrchr(wszDir, L'\\');
*p = NULL;
p = wcsrchr(wszDir, L'\\');
LPWCH pCurrentDir = p + 1;
XmlNodeType nodeType;
LPCWSTR pwszLocalName = NULL;
LPCWSTR pwszValue = NULL;
while (S_OK == pReader->Read(&nodeType)) {
switch (nodeType) {
case XmlNodeType_Element:
if (FAILED(hr = pReader->GetLocalName(&pwszLocalName, NULL))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
else if (!pwszLocalName) {
OutputErrorString(_T("[L:%d] LocalName is NULL\n"), (INT)__LINE__);
return FALSE;
}
if (!wcsncmp(pwszLocalName, L"game", 4)) {
if (S_FALSE == pReader->MoveToFirstAttribute()) {
break;
}
do {
LPCWSTR pwszAttributeName = NULL;
if (FAILED(hr = pReader->GetLocalName(&pwszAttributeName, NULL))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
else if (!pwszAttributeName) {
OutputErrorString(_T("[L:%d] AttributeName is NULL\n"), (INT)__LINE__);
return FALSE;
}
if (!wcsncmp(pwszAttributeName, L"name", 4)) {
if (FAILED(hr = pWriter->WriteStartElement(NULL, pwszLocalName, NULL))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pWriter->WriteAttributeString(NULL, pwszAttributeName, NULL, pCurrentDir))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
}
} while (S_OK == pReader->MoveToNextAttribute());
}
else {
if (FAILED(hr = pWriter->WriteStartElement(NULL, pwszLocalName, NULL))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
}
break;
case XmlNodeType_Text:
if (FAILED(hr = pReader->GetValue(&pwszValue, NULL))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
else if (!pwszValue) {
OutputErrorString(_T("Error GetValue, NULL, L:%d\n"), (INT)__LINE__);
return FALSE;
}
if (!wcsncmp(pwszLocalName, L"description", 11) && !wcsncmp(pwszValue, L"foo", 3)) {
if (FAILED(hr = pWriter->WriteString(pCurrentDir))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
}
else {
if (FAILED(hr = pWriter->WriteString(pwszValue))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
}
break;
case XmlNodeType_EndElement:
if (FAILED(hr = pReader->GetLocalName(&pwszLocalName, NULL))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
else if (!pwszLocalName) {
OutputErrorString(_T("[L:%d] LocalName is NULL\n"), (INT)__LINE__);
return FALSE;
}
if (!wcsncmp(pwszLocalName, L"game", 4)) {
OutputGameHash(pWriter, pExecType, pExtArg, pDisc, pszFullPath, szTmpPath, bDesync);
}
if (FAILED(hr = pWriter->WriteEndElement())) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
break;
case XmlNodeType_None:
break;
case XmlNodeType_Attribute:
break;
case XmlNodeType_CDATA:
break;
case XmlNodeType_ProcessingInstruction:
break;
case XmlNodeType_Comment:
break;
case XmlNodeType_DocumentType:
break;
case XmlNodeType_Whitespace:
#if 0
if (FAILED(hr = pWriter->WriteWhitespace(L"\n"))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pWriter->WriteWhitespace(L"\t"))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
#endif
break;
case XmlNodeType_XmlDeclaration:
break;
default:
break;
}
}
if (FAILED(hr = pWriter->WriteEndDocument())) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pWriter->Flush())) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
#else
CHAR szDefaultDat[_MAX_PATH] = {};
if (!GetModuleFileName(NULL, szDefaultDat, sizeof(szDefaultDat) / sizeof(szDefaultDat[0]))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!PathRemoveFileSpec(szDefaultDat)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!PathAppend(szDefaultDat, "default.dat")) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
XMLDocument xmlReader;
XMLError err = xmlReader.LoadFile(szDefaultDat);
if (err != XML_SUCCESS) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
CHAR szPathForDat[_MAX_PATH] = {};
_TCHAR szTmpPath[_MAX_PATH] = {};
if (bDesync) {
_sntprintf(szPathForDat, _MAX_PATH, _T("%s%s%s (Subs indexes).dat"), szDrive, szDir, szFname);
}
else {
_sntprintf(szPathForDat, _MAX_PATH, _T("%s%s%s.dat"), szDrive, szDir, szFname);
}
szPathForDat[_MAX_PATH - 1] = 0;
XMLDocument xmlWriter;
XMLDeclaration* decl = xmlWriter.NewDeclaration();
xmlWriter.InsertEndChild(decl);
XMLUnknown* unk = xmlWriter.NewUnknown("DOCTYPE datafile PUBLIC \"-//Logiqx//DTD ROM Management Datafile//EN\" \"http://www.logiqx.com/Dats/datafile.dtd\"");
xmlWriter.InsertEndChild(unk);
XMLElement* readElem = xmlReader.FirstChildElement();
BOOL bDescription = FALSE;
// datafile
while (readElem) {
XMLElement* newElem1 = xmlWriter.NewElement(readElem->Name());
if (readElem->GetText() == NULL) {
newElem1->SetText("\n");
}
else {
newElem1->SetText(readElem->GetText());
}
XMLElement* readElem2 = readElem->FirstChildElement();
// header, game
while (readElem2) {
XMLElement* newElem2 = newElem1->GetDocument()->NewElement(readElem2->Name());
if (readElem2->GetText() == NULL) {
if (!strcmp(readElem2->Name(), "game")) {
newElem2->SetAttribute("name", szDir);
}
else {
newElem2->SetText("\n");
}
}
else {
newElem2->SetText(readElem2->GetText());
}
XMLElement* readElem3 = readElem2->FirstChildElement();
// description, rom name etc.
while (readElem3) {
XMLElement* newElem3 = newElem2->GetDocument()->NewElement(readElem3->Name());
if (readElem3->GetText() == NULL) {
newElem3->SetText("\n");
}
else {
if (!strcmp(readElem3->Name(), "description") && !strcmp(readElem2->Name(), "game")) {
newElem3->SetText(szDir);
bDescription = TRUE;
}
else {
newElem3->SetText(readElem3->GetText());
}
}
newElem2->InsertEndChild(newElem3);
readElem3 = readElem3->NextSiblingElement();
}
if (bDescription) {
OutputGameHash(newElem2, pExecType, pExtArg, pDisc, pszFullPath, szTmpPath, bDesync);
}
newElem1->InsertEndChild(newElem2);
readElem2 = readElem2->NextSiblingElement();
}
xmlWriter.InsertEndChild(newElem1);
readElem = readElem->NextSiblingElement();
}
xmlWriter.SaveFile(szPathForDat);
#endif
return TRUE;
}
BOOL OutputHash(
#ifdef _WIN32
CComPtr<IXmlWriter> pWriter,
#else
XMLElement* pWriter,
#endif
_TCHAR* pszFullPath,
LPCTSTR szExt,
UCHAR uiTrack,
UCHAR uiLastTrack,
BOOL bDesync
) {
_TCHAR pszFnameAndExt[_MAX_PATH] = {};
_TCHAR pszOutPath[_MAX_PATH] = {};
FILE* fp = NULL;
if (bDesync) {
fp = CreateOrOpenFile(pszFullPath, _T(" (Subs indexes)"), pszOutPath
, pszFnameAndExt, NULL, szExt, _T("rb"), uiTrack, uiLastTrack);
}
else {
fp = CreateOrOpenFile(pszFullPath, NULL, pszOutPath
, pszFnameAndExt, NULL, szExt, _T("rb"), uiTrack, uiLastTrack);
}
if (!fp) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T(" => %s\n"), pszOutPath);
return FALSE;
}
UINT64 ui64FileSize = GetFileSize64(0, fp);
DWORD dwSectorSizeOne = CD_RAW_SECTOR_SIZE;
if (!_tcsncmp(szExt, _T(".iso"), 4) ||
!_tcsncmp(pszFnameAndExt, _T("SS.bin"), 6) ||
!_tcsncmp(pszFnameAndExt, _T("PFI.bin"), 7) ||
!_tcsncmp(pszFnameAndExt, _T("DMI.bin"), 7) ||
ui64FileSize == 1228800 || ui64FileSize == 1261568 || ui64FileSize == 1474560) {
dwSectorSizeOne = DISC_RAW_READ_SIZE;
}
UINT64 ui64SectorSizeAll = ui64FileSize / (UINT64)dwSectorSizeOne;
if (ui64FileSize >= dwSectorSizeOne) {
MD5_CTX context = {};
SHA1Context sha = {};
CalcInit(&context, &sha);
BYTE data[CD_RAW_SECTOR_SIZE] = {};
DWORD crc32 = 0;
int nRet = TRUE;
// TODO: This code can more speed up! if reduce calling fread()
for (UINT64 i = 1; i <= ui64SectorSizeAll; i++) {
if (fread(data, sizeof(BYTE), dwSectorSizeOne, fp) < dwSectorSizeOne) {
OutputErrorString(_T("Failed to read: read size %ld [F:%s][L:%d]\n"), dwSectorSizeOne, _T(__FUNCTION__), __LINE__);
return FALSE;
};
nRet = CalcHash(&crc32, &context, &sha, data, dwSectorSizeOne);
if (!nRet) {
break;
}
OutputString(_T("\rCalculating hash: %s [%lld/%lld]")
, pszFnameAndExt, i * dwSectorSizeOne, ui64FileSize);
}
//RSC MOD type adaptation
OutputString(_T("\n"));
FcloseAndNull(fp);
if (!nRet) {
return nRet;
}
BYTE digest[16] = {};
BYTE Message_Digest[20] = {};
if (CalcEnd(&context, &sha, digest, Message_Digest)) {
if (!_tcsncmp(szExt, _T(".scm"), 4) ||
!_tcsncmp(szExt, _T(".img"), 4) ||
!_tcsncmp(pszFnameAndExt, _T("SS.bin"), 6) ||
!_tcsncmp(pszFnameAndExt, _T("PFI.bin"), 7) ||
!_tcsncmp(pszFnameAndExt, _T("DMI.bin"), 7)
) {
#ifndef _DEBUG
OutputHashData(g_LogFile.fpDisc, pszFnameAndExt,
ui64FileSize, crc32, digest, Message_Digest);
#endif
}
else {
#ifdef _WIN32
HRESULT hr = S_OK;
if (FAILED(hr = pWriter->WriteStartElement(NULL, L"rom", NULL))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
WCHAR wszFnameAndExt[_MAX_PATH] = {};
#ifndef UNICODE
if (!MultiByteToWideChar(CP_ACP, 0
, pszFnameAndExt, sizeof(pszFnameAndExt) / sizeof(pszFnameAndExt[0])
, wszFnameAndExt, sizeof(wszFnameAndExt) / sizeof(wszFnameAndExt[0]))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
#else
size_t size = sizeof(wszFnameAndExt) / sizeof(wszFnameAndExt[0]);
wcsncpy(wszFnameAndExt, pszFnameAndExt, size);
wszFnameAndExt[size - 1] = 0;
#endif
if (FAILED(hr = pWriter->WriteAttributeString(NULL, L"name", NULL, wszFnameAndExt))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
WCHAR buf[128] = {};
_snwprintf(buf, sizeof(buf) / sizeof(buf[0]), L"%llu", ui64FileSize);
buf[127] = 0;
if (FAILED(hr = pWriter->WriteAttributeString(NULL, L"size", NULL, buf))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
_snwprintf(buf, sizeof(buf) / sizeof(buf[0]), L"%08lx", crc32);
buf[127] = 0;
if (FAILED(hr = pWriter->WriteAttributeString(NULL, L"crc", NULL, buf))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
_snwprintf(buf, sizeof(buf) / sizeof(buf[0])
, L"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
, digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7]
, digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15]);
buf[127] = 0;
if (FAILED(hr = pWriter->WriteAttributeString(NULL, L"md5", NULL, buf))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
_snwprintf(buf, sizeof(buf) / sizeof(buf[0])
, L"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
, Message_Digest[0], Message_Digest[1], Message_Digest[2], Message_Digest[3], Message_Digest[4]
, Message_Digest[5], Message_Digest[6], Message_Digest[7], Message_Digest[8], Message_Digest[9]
, Message_Digest[10], Message_Digest[11], Message_Digest[12], Message_Digest[13], Message_Digest[14]
, Message_Digest[15], Message_Digest[16], Message_Digest[17], Message_Digest[18], Message_Digest[19]);
buf[127] = 0;
if (FAILED(hr = pWriter->WriteAttributeString(NULL, L"sha1", NULL, buf))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
if (FAILED(hr = pWriter->WriteEndElement())) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
OutputErrorString(_T("Dat error: %08.8lx\n"), hr);
return FALSE;
}
#else
XMLElement* newElem4 = pWriter->GetDocument()->NewElement("rom");
newElem4->SetAttribute("name", pszFnameAndExt);
CHAR buf[128] = {};
_snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%llu", ui64FileSize);
buf[127] = 0;
newElem4->SetAttribute("size", buf);
_snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%08lx", crc32);
buf[127] = 0;
newElem4->SetAttribute("crc", buf);
_snprintf(buf, sizeof(buf) / sizeof(buf[0])
, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
, digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7]
, digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15]);
buf[127] = 0;
newElem4->SetAttribute("md5", buf);
_snprintf(buf, sizeof(buf) / sizeof(buf[0])
, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
, Message_Digest[0], Message_Digest[1], Message_Digest[2], Message_Digest[3], Message_Digest[4]
, Message_Digest[5], Message_Digest[6], Message_Digest[7], Message_Digest[8], Message_Digest[9]
, Message_Digest[10], Message_Digest[11], Message_Digest[12], Message_Digest[13], Message_Digest[14]
, Message_Digest[15], Message_Digest[16], Message_Digest[17], Message_Digest[18], Message_Digest[19]);
buf[127] = 0;
newElem4->SetAttribute("sha1", buf);
pWriter->InsertEndChild(newElem4);
#endif
}
}
}
return TRUE;
}
| 33.420659 | 158 | 0.67776 | rmMinusR |
437088568a9036a6fe58cb594b026265acc13db4 | 2,687 | cpp | C++ | test/test_matrix_scalar_division.cpp | AMatrix/AMatrix | 325c3b59d99605f0b50b6e7be3556dd23881992c | [
"MIT"
] | 24 | 2017-10-31T17:22:09.000Z | 2020-05-20T21:16:41.000Z | test/test_matrix_scalar_division.cpp | AMatrix/AMatrix | 325c3b59d99605f0b50b6e7be3556dd23881992c | [
"MIT"
] | 8 | 2017-10-28T07:27:44.000Z | 2019-01-24T16:38:15.000Z | test/test_matrix_scalar_division.cpp | AMatrix/AMatrix | 325c3b59d99605f0b50b6e7be3556dd23881992c | [
"MIT"
] | 7 | 2018-04-22T18:12:08.000Z | 2019-01-16T10:39:41.000Z | #include "amatrix.h"
#include "checks.h"
template <std::size_t TSize1, std::size_t TSize2>
int TestMatrixScalarSelfDivision() {
AMatrix::Matrix<double, TSize1, TSize2> a_matrix;
for (std::size_t i = 0; i < a_matrix.size1(); i++)
for (std::size_t j = 0; j < a_matrix.size2(); j++)
a_matrix(i, j) = 2.33 * i - 4.52 * j;
a_matrix /= 2.3;
for (std::size_t i = 0; i < a_matrix.size1(); i++)
for (std::size_t j = 0; j < a_matrix.size2(); j++)
AMATRIX_CHECK_EQUAL(a_matrix(i, j), (2.33 * i - 4.52 * j) / 2.3);
return 0; // not failed
}
template <std::size_t TSize1, std::size_t TSize2>
int TestMatrixScalarDivision() {
AMatrix::Matrix<double, TSize1, TSize2> a_matrix;
for (std::size_t i = 0; i < a_matrix.size1(); i++)
for (std::size_t j = 0; j < a_matrix.size2(); j++)
a_matrix(i, j) = 2.33 * i - 4.52 * j;
auto b_matrix = a_matrix / 2.3;
for (std::size_t i = 0; i < a_matrix.size1(); i++)
for (std::size_t j = 0; j < a_matrix.size2(); j++)
AMATRIX_CHECK_EQUAL(b_matrix(i, j), (2.33 * i - 4.52 * j) / 2.3);
return 0; // not failed
}
int main() {
int number_of_failed_tests = 0;
// scalar self product test
number_of_failed_tests += TestMatrixScalarSelfDivision<1, 1>();
number_of_failed_tests += TestMatrixScalarSelfDivision<1, 2>();
number_of_failed_tests += TestMatrixScalarSelfDivision<2, 1>();
number_of_failed_tests += TestMatrixScalarSelfDivision<2, 2>();
number_of_failed_tests += TestMatrixScalarSelfDivision<3, 1>();
number_of_failed_tests += TestMatrixScalarSelfDivision<3, 2>();
number_of_failed_tests += TestMatrixScalarSelfDivision<3, 3>();
number_of_failed_tests += TestMatrixScalarSelfDivision<1, 3>();
number_of_failed_tests += TestMatrixScalarSelfDivision<2, 3>();
number_of_failed_tests += TestMatrixScalarSelfDivision<3, 3>();
number_of_failed_tests += TestMatrixScalarDivision<1, 1>();
number_of_failed_tests += TestMatrixScalarDivision<1, 2>();
number_of_failed_tests += TestMatrixScalarDivision<2, 1>();
number_of_failed_tests += TestMatrixScalarDivision<2, 2>();
number_of_failed_tests += TestMatrixScalarDivision<3, 1>();
number_of_failed_tests += TestMatrixScalarDivision<3, 2>();
number_of_failed_tests += TestMatrixScalarDivision<3, 3>();
number_of_failed_tests += TestMatrixScalarDivision<1, 3>();
number_of_failed_tests += TestMatrixScalarDivision<2, 3>();
number_of_failed_tests += TestMatrixScalarDivision<3, 3>();
std::cout << number_of_failed_tests << " tests failed" << std::endl;
return number_of_failed_tests;
}
| 38.385714 | 77 | 0.662449 | AMatrix |
43786c18f1aab9d303630a8d1b575aa9a2c8f317 | 12,991 | cpp | C++ | Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.cpp | wyyrepo/MITK | d0837f3d0d44f477b888ec498e9a2ed407e79f20 | [
"BSD-3-Clause"
] | 1 | 2021-11-20T08:19:27.000Z | 2021-11-20T08:19:27.000Z | Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.cpp | wyyrepo/MITK | d0837f3d0d44f477b888ec498e9a2ed407e79f20 | [
"BSD-3-Clause"
] | null | null | null | Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.cpp | wyyrepo/MITK | d0837f3d0d44f477b888ec498e9a2ed407e79f20 | [
"BSD-3-Clause"
] | null | null | null | /*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkOpenCVVideoControls.h"
#include <QmitkVideoBackground.h>
#include <QmitkRenderWindow.h>
#include <mitkOpenCVVideoSource.h>
#include <mitkIPersistenceService.h>
class QmitkOpenCVVideoControlsPrivate
{
public:
QmitkOpenCVVideoControlsPrivate(QmitkOpenCVVideoControls* q, const std::string& id)
: q(q)
, m_Id(id)
{}
///
/// muellerm: persitence service implementation
///
PERSISTENCE_GET_SERVICE_METHOD_MACRO
QmitkOpenCVVideoControls* q;
///
/// muellerm: a unique id for the prop list
///
std::string m_Id;
void ToPropertyList();
void FromPropertyList();
};
QmitkOpenCVVideoControls::QmitkOpenCVVideoControls(QmitkVideoBackground* _VideoBackground
, QmitkRenderWindow* _RenderWindow
, QWidget * parent, Qt::WindowFlags f)
: QWidget(parent, f)
, m_VideoBackground(nullptr)
, m_RenderWindow(nullptr)
, m_VideoSource(nullptr)
, m_Controls(new Ui::QmitkOpenCVVideoControls)
, m_SliderCurrentlyMoved(false)
, d(new QmitkOpenCVVideoControlsPrivate(this, "QmitkOpenCVVideoControls"))
{
m_Controls->setupUi(this);
m_Controls->FileChooser->SetFileMustExist(true);
m_Controls->FileChooser->SetSelectDir(false);
this->SetRenderWindow(_RenderWindow);
this->SetVideoBackground(_VideoBackground);
d->FromPropertyList();
mitk::IPersistenceService* persistenceService = d->GetPersistenceService();
if (persistenceService != nullptr)
{
persistenceService->AddPropertyListReplacedObserver(this);
}
else
{
MITK_WARN << "No Persistence Service available in constructor";
}
}
QmitkOpenCVVideoControls::~QmitkOpenCVVideoControls()
{
if (m_VideoSource != nullptr && m_VideoSource->IsCapturingEnabled())
{
this->Stop(); // emulate stop
}
mitk::IPersistenceService* persistenceService = d->GetPersistenceService();
if (persistenceService != nullptr)
{
persistenceService->RemovePropertyListReplacedObserver(this);
}
else
{
MITK_WARN << "No Persistence Service available in destructor";
}
d->ToPropertyList();
}
void QmitkOpenCVVideoControls::on_VideoProgressSlider_valueChanged(int /*value*/)
{
//Fixes T23169
on_VideoProgressSlider_sliderReleased();
}
void QmitkOpenCVVideoControls::on_UseGrabbingDeviceButton_clicked(bool /*checked=false*/)
{
m_Controls->GrabbingDevicePanel->setEnabled(true);
m_Controls->VideoFilePanel->setEnabled(false);
}
void QmitkOpenCVVideoControls::on_UseVideoFileButton_clicked(bool /*checked=false*/)
{
m_Controls->GrabbingDevicePanel->setEnabled(false);
m_Controls->VideoFilePanel->setEnabled(true);
m_Controls->FileChooser->setEnabled(true);
}
void QmitkOpenCVVideoControls::on_VideoProgressSlider_sliderPressed()
{
m_SliderCurrentlyMoved = true;
// temporary pause the video while sliding
if (!m_VideoSource->GetCapturePaused())
m_VideoSource->PauseCapturing();
}
void QmitkOpenCVVideoControls::on_VideoProgressSlider_sliderReleased()
{
double progressRatio = static_cast<double>(m_Controls->VideoProgressSlider->value())
/ static_cast<double>(m_Controls->VideoProgressSlider->maximum());
m_VideoSource->SetVideoCaptureProperty(CV_CAP_PROP_POS_FRAMES, progressRatio*m_VideoSource->GetVideoCaptureProperty(CV_CAP_PROP_FRAME_COUNT));
// resume the video ( if it was not paused by the user)
if (m_VideoSource->GetCapturePaused() && m_Controls->PlayButton->isChecked())
m_VideoSource->PauseCapturing();
m_SliderCurrentlyMoved = false;
}
void QmitkOpenCVVideoControls::on_RepeatVideoButton_clicked(bool checked)
{
MITK_INFO << "repeat video clicked";
m_VideoSource->SetRepeatVideo(checked);
}
void QmitkOpenCVVideoControls::on_PlayButton_clicked(bool checked)
{
MITK_INFO << "play button clicked";
if (checked)
{
this->Play();
}
else
{
// show pause button
this->IsPlaying(true);
m_VideoSource->PauseCapturing();
}
}
void QmitkOpenCVVideoControls::on_StopButton_clicked(bool /*checked=false*/)
{
this->Stop();
}
void QmitkOpenCVVideoControls::Play()
{
if (m_VideoSource->GetCapturePaused())
{
this->IsPlaying(false);
m_VideoSource->PauseCapturing();
}
else
{
if (m_Controls->UseGrabbingDeviceButton->isChecked())
{
m_VideoSource->SetVideoCameraInput(m_Controls->GrabbingDeviceNumber->text().toInt(), false);
m_Controls->VideoFileControls->setEnabled(false);
}
else
{
m_VideoSource->SetVideoFileInput(m_Controls->FileChooser->GetFile().c_str(), m_Controls->RepeatVideoButton->isChecked(), false);
m_VideoSource->SetRepeatVideo(m_Controls->RepeatVideoButton->isChecked());
m_Controls->VideoProgressSlider->setValue(0);
}
m_VideoSource->StartCapturing();
if (!m_VideoSource->IsCapturingEnabled())
{
MITK_ERROR << "Video could not be initialized!";
m_Controls->PlayButton->setChecked(false);
}
else
{
int hertz = m_Controls->UpdateRate->text().toInt();
int updateTime = itk::Math::Round<int, double>(1000.0 / hertz);
// resets the whole background
m_VideoBackground->SetTimerDelay(updateTime);
m_VideoBackground->AddRenderWindow(m_RenderWindow->GetVtkRenderWindow());
this->connect(m_VideoBackground, SIGNAL(NewFrameAvailable(mitk::VideoSource*))
, this, SLOT(NewFrameAvailable(mitk::VideoSource*)));
this->connect(m_VideoBackground, SIGNAL(EndOfVideoSourceReached(mitk::VideoSource*))
, this, SLOT(EndOfVideoSourceReached(mitk::VideoSource*)));
m_VideoBackground->Enable();
this->m_Controls->StopButton->setEnabled(true);
// show video file controls
if (m_Controls->UseVideoFileButton->isChecked())
{
m_Controls->VideoFileControls->setEnabled(true);
m_Controls->RepeatVideoButton->setEnabled(true);
m_Controls->VideoProgressSlider->setEnabled(true);
}
// show pause button
this->IsPlaying(false);
// disable other controls
m_Controls->GrabbingDevicePanel->setEnabled(false);
m_Controls->VideoFilePanel->setEnabled(false);
m_Controls->UseGrabbingDeviceButton->setEnabled(false);
m_Controls->UseVideoFileButton->setEnabled(false);
m_Controls->UpdateRatePanel->setEnabled(false);
}
}
}
void QmitkOpenCVVideoControls::Stop()
{
// disable video file controls, stop button and show play button again
m_Controls->UseGrabbingDeviceButton->setEnabled(true);
m_Controls->UseVideoFileButton->setEnabled(true);
if (m_Controls->UseGrabbingDeviceButton->isChecked())
on_UseGrabbingDeviceButton_clicked(true);
else
on_UseVideoFileButton_clicked(true);
m_Controls->UpdateRatePanel->setEnabled(true);
m_Controls->VideoProgressSlider->setValue(0);
m_Controls->VideoFileControls->setEnabled(false);
this->m_Controls->StopButton->setEnabled(false);
this->IsPlaying(true);
if (m_VideoBackground)
{
m_VideoBackground->Disable();
if (m_RenderWindow)
m_VideoBackground->RemoveRenderWindow(m_RenderWindow->GetVtkRenderWindow());
this->disconnect(m_VideoBackground, SIGNAL(NewFrameAvailable(mitk::VideoSource*))
, this, SLOT(NewFrameAvailable(mitk::VideoSource*)));
}
if (m_VideoSource != nullptr)
m_VideoSource->StopCapturing();
}
void QmitkOpenCVVideoControls::Reset()
{
this->Stop();
}
void QmitkOpenCVVideoControls::IsPlaying(bool paused)
{
if (paused)
{
m_Controls->PlayButton->setText("Play");
m_Controls->PlayButton->setIcon(QIcon(":/OpenCVVideoSupportUI/media-playback-start.png"));
m_Controls->PlayButton->setChecked(false);
}
else
{
m_Controls->PlayButton->setText("Pause");
m_Controls->PlayButton->setIcon(QIcon(":/OpenCVVideoSupportUI/media-playback-pause.png"));
m_Controls->PlayButton->setChecked(true);
}
}
void QmitkOpenCVVideoControls::NewFrameAvailable(mitk::VideoSource* /*videoSource*/)
{
emit NewOpenCVFrameAvailable(m_VideoSource->GetCurrentFrame());
if (!m_SliderCurrentlyMoved)
{
m_Controls->VideoProgressSlider->setValue(itk::Math::Round<int, double>(m_VideoSource->GetVideoCaptureProperty(CV_CAP_PROP_POS_FRAMES)
*(1 / m_VideoSource->GetVideoCaptureProperty(CV_CAP_PROP_FRAME_COUNT)
*m_Controls->VideoProgressSlider->maximum())));
}
}
void QmitkOpenCVVideoControls::EndOfVideoSourceReached(mitk::VideoSource* /*videoSource*/)
{
if (m_Controls->RepeatVideoButton->isChecked())
{
this->Reset();
this->Play();
}
else
{
this->Stop();
}
}
void QmitkOpenCVVideoControls::SetRenderWindow(QmitkRenderWindow* _RenderWindow)
{
if (m_RenderWindow == _RenderWindow)
return;
// In Reset() m_MultiWidget is used, set it to 0 now for avoiding errors
if (_RenderWindow == nullptr)
m_RenderWindow = nullptr;
this->Reset();
m_RenderWindow = _RenderWindow;
if (m_RenderWindow == nullptr)
{
this->setEnabled(false);
}
else
{
this->setEnabled(true);
}
}
QmitkRenderWindow* QmitkOpenCVVideoControls::GetRenderWindow() const
{
return m_RenderWindow;
}
void QmitkOpenCVVideoControls::SetVideoBackground(QmitkVideoBackground* _VideoBackground)
{
if (m_VideoBackground == _VideoBackground)
return;
if (m_VideoBackground != nullptr)
this->disconnect(m_VideoBackground, SIGNAL(destroyed(QObject*))
, this, SLOT(QObjectDestroyed(QObject*)));
this->Reset();
m_VideoBackground = _VideoBackground;
if (m_VideoBackground == nullptr)
{
m_VideoSource = nullptr;
MITK_WARN << "m_MultiWidget is 0";
this->setEnabled(false);
}
else
{
this->setEnabled(true);
m_VideoSource = dynamic_cast<mitk::OpenCVVideoSource*>(m_VideoBackground->GetVideoSource());
// preset form entries
if (m_VideoSource != nullptr)
{
if (!m_VideoSource->GetVideoFileName().empty())
{
m_Controls->FileChooser->SetFile(m_VideoSource->GetVideoFileName());
on_UseGrabbingDeviceButton_clicked(false);
}
else if (m_VideoSource->GetGrabbingDeviceNumber() >= 0)
m_Controls->GrabbingDeviceNumber->setValue(m_VideoSource->GetGrabbingDeviceNumber());
m_Controls->UpdateRate->setValue(m_VideoBackground->GetTimerDelay());
this->connect(m_VideoBackground, SIGNAL(destroyed(QObject*))
, this, SLOT(QObjectDestroyed(QObject*)));
}
else
{
MITK_WARN << "m_VideoSource is 0";
this->setEnabled(false);
}
}
}
QmitkVideoBackground* QmitkOpenCVVideoControls::GetVideoBackground() const
{
return m_VideoBackground;
}
void QmitkOpenCVVideoControls::QObjectDestroyed(QObject * obj /*= 0 */)
{
if (m_VideoBackground == obj)
{
m_VideoSource = nullptr;
this->SetVideoBackground(nullptr);
}
}
void QmitkOpenCVVideoControlsPrivate::ToPropertyList()
{
mitk::IPersistenceService* persistenceService = this->GetPersistenceService();
if (persistenceService != nullptr)
{
mitk::PropertyList::Pointer propList = persistenceService->GetPropertyList(m_Id);
propList->Set("deviceType", q->m_Controls->UseGrabbingDeviceButton->isChecked() ? 0 : 1);
propList->Set("grabbingDeviceNumber", q->m_Controls->GrabbingDeviceNumber->value());
propList->Set("updateRate", q->m_Controls->UpdateRate->value());
propList->Set("repeatVideo", q->m_Controls->RepeatVideoButton->isChecked());
}
else
{
MITK_WARN << "Persistence Service not available.";
}
}
void QmitkOpenCVVideoControlsPrivate::FromPropertyList()
{
mitk::IPersistenceService* persistenceService = this->GetPersistenceService();
if (persistenceService != nullptr)
{
mitk::PropertyList::Pointer propList = persistenceService->GetPropertyList(m_Id);
bool repeatVideo = false;
propList->Get("repeatVideo", repeatVideo);
q->m_Controls->RepeatVideoButton->setChecked(repeatVideo);
int updateRate = 25;
propList->Get("updateRate", updateRate);
q->m_Controls->UpdateRate->setValue(updateRate);
int grabbingDeviceNumber = 0;
propList->Get("grabbingDeviceNumber", grabbingDeviceNumber);
q->m_Controls->GrabbingDeviceNumber->setValue(grabbingDeviceNumber);
int deviceType = 0;
propList->Get("deviceType", deviceType);
if (deviceType == 0)
{
q->m_Controls->UseGrabbingDeviceButton->setChecked(true);
}
else
{
q->m_Controls->UseVideoFileButton->setChecked(true);
}
}
else
{
MITK_WARN << "Persistence Service not available.";
}
}
void QmitkOpenCVVideoControls::AfterPropertyListReplaced(const std::string& id, mitk::PropertyList* /*propertyList*/)
{
if (id == d->m_Id)
d->FromPropertyList();
}
| 28.933185 | 144 | 0.722423 | wyyrepo |
43789fa96864d228a445bcf42be4766a63a1abf3 | 8,217 | hpp | C++ | include/alibabacloud/rpc.hpp | alibabacloud-sdk-cpp/rpc | b7f84bf89f6f8c8f2ac5e3c6b5ffeda98444834b | [
"Apache-2.0"
] | 3 | 2020-07-01T07:15:02.000Z | 2020-08-08T08:46:22.000Z | include/alibabacloud/rpc.hpp | alibabacloud-sdk-cpp/rpc | b7f84bf89f6f8c8f2ac5e3c6b5ffeda98444834b | [
"Apache-2.0"
] | 38 | 2020-07-09T06:07:20.000Z | 2021-02-22T14:02:49.000Z | include/alibabacloud/rpc.hpp | alibabacloud-sdk-cpp/rpc | b7f84bf89f6f8c8f2ac5e3c6b5ffeda98444834b | [
"Apache-2.0"
] | 4 | 2020-04-02T06:02:04.000Z | 2021-02-22T13:48:06.000Z | // This file is auto-generated, don't edit it. Thanks.
#ifndef ALIBABACLOUD_RPC_H_
#define ALIBABACLOUD_RPC_H_
#include <alibabacloud/credential.hpp>
#include <alibabacloud/rpcutil.hpp>
#include <boost/any.hpp>
#include <darabonba/core.hpp>
#include <darabonba/util.hpp>
#include <iostream>
#include <map>
using namespace std;
namespace Alibabacloud_RPC {
class Config : public Darabonba::Model {
public:
Config() {}
explicit Config(const std::map<string, boost::any> &config)
: Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
Darabonba::Model::validatePattern("regionId", regionId, "^[a-zA-Z0-9_-]+$");
Darabonba::Model::validatePattern("network", network, "^[a-zA-Z0-9_-]+$");
Darabonba::Model::validatePattern("suffix", suffix, "^[a-zA-Z0-9_-]+$");
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (accessKeyId) {
res["accessKeyId"] = boost::any(*accessKeyId);
}
if (accessKeySecret) {
res["accessKeySecret"] = boost::any(*accessKeySecret);
}
if (securityToken) {
res["securityToken"] = boost::any(*securityToken);
}
if (protocol) {
res["protocol"] = boost::any(*protocol);
}
if (regionId) {
res["regionId"] = boost::any(*regionId);
}
if (readTimeout) {
res["readTimeout"] = boost::any(*readTimeout);
}
if (connectTimeout) {
res["connectTimeout"] = boost::any(*connectTimeout);
}
if (httpProxy) {
res["httpProxy"] = boost::any(*httpProxy);
}
if (httpsProxy) {
res["httpsProxy"] = boost::any(*httpsProxy);
}
if (endpoint) {
res["endpoint"] = boost::any(*endpoint);
}
if (noProxy) {
res["noProxy"] = boost::any(*noProxy);
}
if (maxIdleConns) {
res["maxIdleConns"] = boost::any(*maxIdleConns);
}
if (network) {
res["network"] = boost::any(*network);
}
if (userAgent) {
res["userAgent"] = boost::any(*userAgent);
}
if (suffix) {
res["suffix"] = boost::any(*suffix);
}
if (socks5Proxy) {
res["socks5Proxy"] = boost::any(*socks5Proxy);
}
if (socks5NetWork) {
res["socks5NetWork"] = boost::any(*socks5NetWork);
}
if (endpointType) {
res["endpointType"] = boost::any(*endpointType);
}
if (openPlatformEndpoint) {
res["openPlatformEndpoint"] = boost::any(*openPlatformEndpoint);
}
if (type) {
res["type"] = boost::any(*type);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("accessKeyId") != m.end() && !m["accessKeyId"].empty()) {
accessKeyId =
make_shared<string>(boost::any_cast<string>(m["accessKeyId"]));
}
if (m.find("accessKeySecret") != m.end() && !m["accessKeySecret"].empty()) {
accessKeySecret =
make_shared<string>(boost::any_cast<string>(m["accessKeySecret"]));
}
if (m.find("securityToken") != m.end() && !m["securityToken"].empty()) {
securityToken =
make_shared<string>(boost::any_cast<string>(m["securityToken"]));
}
if (m.find("protocol") != m.end() && !m["protocol"].empty()) {
protocol = make_shared<string>(boost::any_cast<string>(m["protocol"]));
}
if (m.find("regionId") != m.end() && !m["regionId"].empty()) {
regionId = make_shared<string>(boost::any_cast<string>(m["regionId"]));
}
if (m.find("readTimeout") != m.end() && !m["readTimeout"].empty()) {
readTimeout = make_shared<int>(boost::any_cast<int>(m["readTimeout"]));
}
if (m.find("connectTimeout") != m.end() && !m["connectTimeout"].empty()) {
connectTimeout =
make_shared<int>(boost::any_cast<int>(m["connectTimeout"]));
}
if (m.find("httpProxy") != m.end() && !m["httpProxy"].empty()) {
httpProxy = make_shared<string>(boost::any_cast<string>(m["httpProxy"]));
}
if (m.find("httpsProxy") != m.end() && !m["httpsProxy"].empty()) {
httpsProxy =
make_shared<string>(boost::any_cast<string>(m["httpsProxy"]));
}
if (m.find("endpoint") != m.end() && !m["endpoint"].empty()) {
endpoint = make_shared<string>(boost::any_cast<string>(m["endpoint"]));
}
if (m.find("noProxy") != m.end() && !m["noProxy"].empty()) {
noProxy = make_shared<string>(boost::any_cast<string>(m["noProxy"]));
}
if (m.find("maxIdleConns") != m.end() && !m["maxIdleConns"].empty()) {
maxIdleConns = make_shared<int>(boost::any_cast<int>(m["maxIdleConns"]));
}
if (m.find("network") != m.end() && !m["network"].empty()) {
network = make_shared<string>(boost::any_cast<string>(m["network"]));
}
if (m.find("userAgent") != m.end() && !m["userAgent"].empty()) {
userAgent = make_shared<string>(boost::any_cast<string>(m["userAgent"]));
}
if (m.find("suffix") != m.end() && !m["suffix"].empty()) {
suffix = make_shared<string>(boost::any_cast<string>(m["suffix"]));
}
if (m.find("socks5Proxy") != m.end() && !m["socks5Proxy"].empty()) {
socks5Proxy =
make_shared<string>(boost::any_cast<string>(m["socks5Proxy"]));
}
if (m.find("socks5NetWork") != m.end() && !m["socks5NetWork"].empty()) {
socks5NetWork =
make_shared<string>(boost::any_cast<string>(m["socks5NetWork"]));
}
if (m.find("endpointType") != m.end() && !m["endpointType"].empty()) {
endpointType =
make_shared<string>(boost::any_cast<string>(m["endpointType"]));
}
if (m.find("openPlatformEndpoint") != m.end() &&
!m["openPlatformEndpoint"].empty()) {
openPlatformEndpoint = make_shared<string>(
boost::any_cast<string>(m["openPlatformEndpoint"]));
}
if (m.find("type") != m.end() && !m["type"].empty()) {
type = make_shared<string>(boost::any_cast<string>(m["type"]));
}
}
shared_ptr<string> accessKeyId{};
shared_ptr<string> accessKeySecret{};
shared_ptr<string> securityToken{};
shared_ptr<string> protocol{};
shared_ptr<string> regionId{};
shared_ptr<int> readTimeout{};
shared_ptr<int> connectTimeout{};
shared_ptr<string> httpProxy{};
shared_ptr<string> httpsProxy{};
shared_ptr<Alibabacloud_Credential::Client> credential{};
shared_ptr<string> endpoint{};
shared_ptr<string> noProxy{};
shared_ptr<int> maxIdleConns{};
shared_ptr<string> network{};
shared_ptr<string> userAgent{};
shared_ptr<string> suffix{};
shared_ptr<string> socks5Proxy{};
shared_ptr<string> socks5NetWork{};
shared_ptr<string> endpointType{};
shared_ptr<string> openPlatformEndpoint{};
shared_ptr<string> type{};
~Config() = default;
};
class Client {
public:
shared_ptr<string> _endpoint{};
shared_ptr<string> _regionId{};
shared_ptr<string> _protocol{};
shared_ptr<string> _userAgent{};
shared_ptr<string> _endpointRule{};
shared_ptr<map<string, string>> _endpointMap{};
shared_ptr<string> _suffix{};
shared_ptr<int> _readTimeout{};
shared_ptr<int> _connectTimeout{};
shared_ptr<string> _httpProxy{};
shared_ptr<string> _httpsProxy{};
shared_ptr<string> _socks5Proxy{};
shared_ptr<string> _socks5NetWork{};
shared_ptr<string> _noProxy{};
shared_ptr<string> _network{};
shared_ptr<string> _productId{};
shared_ptr<int> _maxIdleConns{};
shared_ptr<string> _endpointType{};
shared_ptr<string> _openPlatformEndpoint{};
shared_ptr<Alibabacloud_Credential::Client> _credential{};
explicit Client(const shared_ptr<Config> &config);
map<string, boost::any>
doRequest(shared_ptr<string> action, shared_ptr<string> protocol,
shared_ptr<string> method, shared_ptr<string> version,
shared_ptr<string> authType,
shared_ptr<map<string, boost::any>> query,
shared_ptr<map<string, boost::any>> body,
shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
string getUserAgent();
string getAccessKeyId();
string getAccessKeySecret();
string getSecurityToken();
void checkConfig(shared_ptr<Config> config);
static boost::any defaultAny(const boost::any &inputValue,
const boost::any &defaultValue);
~Client() = default;
};
} // namespace Alibabacloud_RPC
#endif
| 34.817797 | 80 | 0.625532 | alibabacloud-sdk-cpp |
437a7f8051a27da958fc969fb79dca91ce670d4f | 502 | cpp | C++ | src/backend/message/boost_serializer.cpp | jessesleeping/my_peloton | a19426cfe34a04692a11008eaffc9c3c9b49abc4 | [
"Apache-2.0"
] | 6 | 2017-04-28T00:38:52.000Z | 2018-11-06T07:06:49.000Z | src/backend/message/boost_serializer.cpp | jessesleeping/my_peloton | a19426cfe34a04692a11008eaffc9c3c9b49abc4 | [
"Apache-2.0"
] | 4 | 2017-07-08T00:41:56.000Z | 2017-07-08T00:42:13.000Z | src/backend/message/boost_serializer.cpp | eric-haibin-lin/pelotondb | 904d6bbd041a0498ee0e034d4f9f9f27086c3cab | [
"Apache-2.0"
] | 1 | 2020-06-19T08:05:03.000Z | 2020-06-19T08:05:03.000Z | //===----------------------------------------------------------------------===//
//
// PelotonDB
//
// boost_serializer.cpp
//
// Identification: src/backend/message/boost_serializer.cpp
//
// Copyright (c) 2015, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#include "backend/message/boost_serializer.h"
namespace peloton {
namespace message {
} // namespace message
} // namespace peloton
| 22.818182 | 80 | 0.460159 | jessesleeping |
437bb6b219a28e69d7166fbb27e7919a428d4fa3 | 9,030 | cc | C++ | Filters/src/FixCaloShowerStepPtrs_module.cc | bonventre/Offline | 77db9d6368f27ab9401c690c2c2a4257ade6c231 | [
"Apache-2.0"
] | 1 | 2021-05-25T19:10:10.000Z | 2021-05-25T19:10:10.000Z | Filters/src/FixCaloShowerStepPtrs_module.cc | bonventre/Offline | 77db9d6368f27ab9401c690c2c2a4257ade6c231 | [
"Apache-2.0"
] | 1 | 2019-11-22T14:45:51.000Z | 2019-11-22T14:50:03.000Z | Filters/src/FixCaloShowerStepPtrs_module.cc | bonventre/Offline | 77db9d6368f27ab9401c690c2c2a4257ade6c231 | [
"Apache-2.0"
] | 2 | 2019-10-14T17:46:58.000Z | 2020-03-30T21:05:15.000Z | ////////////////////////////////////////////////////////////////////////
// Class: FixCaloShowerStepPtrs
// Plugin Type: producer (art v2_06_02)
// File: FixCaloShowerStepPtrs_module.cc
//
// This module fixes an off-by-one bug in earlier versions of CompressDigiMCs
// before commit XXXXXXX
//
// Generated at Wed Apr 12 16:10:46 2017 by Andrew Edmonds using cetskelgen
// from cetlib version v2_02_00.
////////////////////////////////////////////////////////////////////////
#include "art/Framework/Core/EDProducer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
#include "canvas/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include "art_root_io/TFileService.h"
#include <memory>
#include "MCDataProducts/inc/StrawDigiMCCollection.hh"
#include "MCDataProducts/inc/CrvDigiMCCollection.hh"
#include "MCDataProducts/inc/CaloShowerStepCollection.hh"
#include "MCDataProducts/inc/CaloShowerSimCollection.hh"
#include "MCDataProducts/inc/CaloShowerStepROCollection.hh"
#include "MCDataProducts/inc/StepPointMCCollection.hh"
#include "MCDataProducts/inc/SimParticleCollection.hh"
#include "Mu2eUtilities/inc/compressSimParticleCollection.hh"
#include "MCDataProducts/inc/GenParticleCollection.hh"
#include "MCDataProducts/inc/SimParticleTimeMap.hh"
#include "MCDataProducts/inc/SimParticleRemapping.hh"
#include "DataProducts/inc/IndexMap.hh"
namespace mu2e {
class FixCaloShowerStepPtrs;
typedef std::map<art::Ptr<mu2e::CaloShowerStep>, art::Ptr<mu2e::CaloShowerStep> > CaloShowerStepRemap;
}
class mu2e::FixCaloShowerStepPtrs : public art::EDProducer {
public:
explicit FixCaloShowerStepPtrs(fhicl::ParameterSet const & pset);
// The compiler-generated destructor is fine for non-base
// classes without bare pointers or other resource use.
// Plugins should not be copied or assigned.
FixCaloShowerStepPtrs(FixCaloShowerStepPtrs const &) = delete;
FixCaloShowerStepPtrs(FixCaloShowerStepPtrs &&) = delete;
FixCaloShowerStepPtrs & operator = (FixCaloShowerStepPtrs const &) = delete;
FixCaloShowerStepPtrs & operator = (FixCaloShowerStepPtrs &&) = delete;
// Required functions.
void produce(art::Event & event) override;
// Other functions
art::Ptr<mu2e::CaloShowerStep> copyCaloShowerStep(const mu2e::CaloShowerStep& old_calo_shower_step);
void copyCaloShowerSim(const mu2e::CaloShowerSim& old_calo_shower_sim, const CaloShowerStepRemap& remap);
void copyCaloShowerStepRO(const mu2e::CaloShowerStepRO& old_calo_shower_step_ro, const CaloShowerStepRemap& remap);
private:
// art tags for the input collections
std::vector<art::InputTag> _caloShowerStepTags;
art::InputTag _caloShowerSimTag;
art::InputTag _caloShowerStepROTag;
// handles to the old collections
art::Handle<CaloShowerStepCollection> _caloShowerStepsHandle;
art::Handle<CaloShowerSimCollection> _caloShowerSimsHandle;
art::Handle<CaloShowerStepROCollection> _caloShowerStepROsHandle;
// unique_ptrs to the new output collections
std::unique_ptr<CaloShowerStepCollection> _newCaloShowerSteps;
std::unique_ptr<CaloShowerSimCollection> _newCaloShowerSims;
std::unique_ptr<CaloShowerStepROCollection> _newCaloShowerStepROs;
// for StepPointMCs, SimParticles and GenParticles we also need reference their new locations with art::Ptrs and so need their ProductIDs and Getters
art::ProductID _newCaloShowerStepsPID;
const art::EDProductGetter* _newCaloShowerStepGetter;
std::map<art::ProductID, const art::EDProductGetter*> _oldCaloShowerStepGetter;
};
mu2e::FixCaloShowerStepPtrs::FixCaloShowerStepPtrs(fhicl::ParameterSet const & pset)
: art::EDProducer{pset},
_caloShowerStepTags(pset.get<std::vector<art::InputTag> >("caloShowerStepTags")),
_caloShowerSimTag(pset.get<art::InputTag>("caloShowerSimTag")),
_caloShowerStepROTag(pset.get<art::InputTag>("caloShowerStepROTag"))
{
// Call appropriate produces<>() functions here.
produces<CaloShowerStepCollection>();
produces<CaloShowerSimCollection>();
produces<CaloShowerStepROCollection>();
}
void mu2e::FixCaloShowerStepPtrs::produce(art::Event & event)
{
// Check to see if this collection has the bug
_newCaloShowerSims = std::unique_ptr<CaloShowerSimCollection>(new CaloShowerSimCollection);
event.getByLabel(_caloShowerSimTag, _caloShowerSimsHandle);
const auto& caloShowerSims = *_caloShowerSimsHandle;
bool bug_found = true;
for (const auto& i_caloShowerSim : caloShowerSims) {
for (const auto& i_caloShowerStep : i_caloShowerSim.caloShowerSteps()) {
if(i_caloShowerStep.key()==0) {
bug_found = false;
break;
}
}
}
// Implementation of required member function here.
CaloShowerStepRemap caloShowerStepRemap;
_newCaloShowerSteps = std::unique_ptr<CaloShowerStepCollection>(new CaloShowerStepCollection);
_newCaloShowerStepsPID = event.getProductID<CaloShowerStepCollection>();
_newCaloShowerStepGetter = event.productGetter(_newCaloShowerStepsPID);
for (std::vector<art::InputTag>::const_iterator i_tag = _caloShowerStepTags.begin(); i_tag != _caloShowerStepTags.end(); ++i_tag) {
const auto& oldCaloShowerSteps = event.getValidHandle<CaloShowerStepCollection>(*i_tag);
art::ProductID i_product_id = oldCaloShowerSteps.id();
_oldCaloShowerStepGetter[i_product_id] = event.productGetter(i_product_id);
for (CaloShowerStepCollection::const_iterator i_caloShowerStep = oldCaloShowerSteps->begin(); i_caloShowerStep != oldCaloShowerSteps->end(); ++i_caloShowerStep) {
if (bug_found) {
art::Ptr<mu2e::CaloShowerStep> oldShowerStepPtr(i_product_id, i_caloShowerStep - oldCaloShowerSteps->begin()+1, _oldCaloShowerStepGetter[i_product_id]);
art::Ptr<mu2e::CaloShowerStep> newShowerStepPtr = copyCaloShowerStep(*i_caloShowerStep);
caloShowerStepRemap[oldShowerStepPtr] = newShowerStepPtr;
}
else {
art::Ptr<mu2e::CaloShowerStep> oldShowerStepPtr(i_product_id, i_caloShowerStep - oldCaloShowerSteps->begin(), _oldCaloShowerStepGetter[i_product_id]);
art::Ptr<mu2e::CaloShowerStep> newShowerStepPtr = copyCaloShowerStep(*i_caloShowerStep);
caloShowerStepRemap[oldShowerStepPtr] = newShowerStepPtr;
// std::cout << "AE: " << oldShowerStepPtr << " --> " << newShowerStepPtr << std::endl;
}
}
}
for (const auto& i_caloShowerSim : caloShowerSims) {
copyCaloShowerSim(i_caloShowerSim, caloShowerStepRemap);
}
_newCaloShowerStepROs = std::unique_ptr<CaloShowerStepROCollection>(new CaloShowerStepROCollection);
event.getByLabel(_caloShowerStepROTag, _caloShowerStepROsHandle);
const auto& caloShowerStepROs = *_caloShowerStepROsHandle;
for (const auto& i_caloShowerStepRO : caloShowerStepROs) {
copyCaloShowerStepRO(i_caloShowerStepRO, caloShowerStepRemap);
}
event.put(std::move(_newCaloShowerSteps));
event.put(std::move(_newCaloShowerSims));
event.put(std::move(_newCaloShowerStepROs));
}
art::Ptr<mu2e::CaloShowerStep> mu2e::FixCaloShowerStepPtrs::copyCaloShowerStep(const mu2e::CaloShowerStep& old_calo_shower_step) {
// Need this if-statement because sometimes the SimParticle that is being Ptr'd to
// is not there... The Ptr itself is valid (i.e. old_step.simParticle().isNonnull() returns true)
// but there is no object there and so when we try to get the id of the SimParticle
// there is a segfault
if (old_calo_shower_step.simParticle().get()) {
CaloShowerStep new_calo_shower_step = old_calo_shower_step;
_newCaloShowerSteps->push_back(new_calo_shower_step);
return art::Ptr<mu2e::CaloShowerStep>(_newCaloShowerStepsPID, _newCaloShowerSteps->size()-1, _newCaloShowerStepGetter);
}
else {
return art::Ptr<CaloShowerStep>();
}
}
void mu2e::FixCaloShowerStepPtrs::copyCaloShowerSim(const mu2e::CaloShowerSim& old_calo_shower_sim, const CaloShowerStepRemap& remap) {
const auto& caloShowerStepPtrs = old_calo_shower_sim.caloShowerSteps();
std::vector<art::Ptr<CaloShowerStep> > newCaloShowerStepPtrs;
for (const auto& i_caloShowerStepPtr : caloShowerStepPtrs) {
// std::cout << "AE: " << i_caloShowerStepPtr << std::endl;
newCaloShowerStepPtrs.push_back(remap.at(i_caloShowerStepPtr));
}
CaloShowerSim new_calo_shower_sim = old_calo_shower_sim;
new_calo_shower_sim.setCaloShowerSteps(newCaloShowerStepPtrs);
_newCaloShowerSims->push_back(new_calo_shower_sim);
}
void mu2e::FixCaloShowerStepPtrs::copyCaloShowerStepRO(const mu2e::CaloShowerStepRO& old_calo_shower_step_ro, const CaloShowerStepRemap& remap) {
const auto& caloShowerStepPtr = old_calo_shower_step_ro.caloShowerStep();
CaloShowerStepRO new_calo_shower_step_ro = old_calo_shower_step_ro;
new_calo_shower_step_ro.setCaloShowerStep(remap.at(caloShowerStepPtr));
_newCaloShowerStepROs->push_back(new_calo_shower_step_ro);
}
DEFINE_ART_MODULE(mu2e::FixCaloShowerStepPtrs)
| 43.834951 | 166 | 0.774419 | bonventre |
437fcfb533350aef3a1fbae296bb84b9eb778b4e | 45,288 | cpp | C++ | WRK-V1.2/clr/src/vm/binder.cpp | intj-t/openvmsft | 0d17fbce8607ab2b880be976c2e86d8cfc3e83bb | [
"Intel"
] | null | null | null | WRK-V1.2/clr/src/vm/binder.cpp | intj-t/openvmsft | 0d17fbce8607ab2b880be976c2e86d8cfc3e83bb | [
"Intel"
] | null | null | null | WRK-V1.2/clr/src/vm/binder.cpp | intj-t/openvmsft | 0d17fbce8607ab2b880be976c2e86d8cfc3e83bb | [
"Intel"
] | null | null | null | // ==++==
//
//
// Copyright (c) 2006 Microsoft Corporation. All rights reserved.
//
// The use and distribution terms for this software are contained in the file
// named license.txt, which can be found in the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by the
// terms of this license.
//
// You must not remove this notice, or any other, from this software.
//
//
// ==--==
#include "common.h"
#include "binder.h"
#include "ecall.h"
#include "field.h"
#include "excep.h"
#include "message.h"
#include "comnumber.h"
#include "eeconfig.h"
#include "rwlock.h"
#include "runtimehandles.h"
#include "customattribute.h"
#include "debugdebugger.h"
#ifndef DACCESS_COMPILE
void Binder::Init(Module *pModule,
const ClassDescription *pClassDescriptions,
DWORD cClassDescriptions,
const MethodDescription *pMethodDescriptions,
DWORD cMethodDescriptions,
const FieldDescription *pFieldDescriptions,
DWORD cFieldDescriptions,
const TypeDescription *pTypeDescriptions,
DWORD cTypeDescriptions)
{
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
FORBID_FAULT;
}
CONTRACTL_END;
m_pModule = pModule;
pModule->m_pBinder = this;
m_classDescriptions = pClassDescriptions;
m_methodDescriptions = pMethodDescriptions;
m_fieldDescriptions = pFieldDescriptions;
m_typeDescriptions = pTypeDescriptions;
//
// Initialize Class RID array
//
_ASSERTE(cClassDescriptions < USHRT_MAX);
m_cClassRIDs = (USHORT) cClassDescriptions;
m_pClassRIDs = new USHORT [m_cClassRIDs];
ZeroMemory(m_pClassRIDs, m_cClassRIDs * sizeof(*m_pClassRIDs));
//
// Initialize Method RID array
//
_ASSERTE(cMethodDescriptions < USHRT_MAX);
m_cMethodMDs = (USHORT) cMethodDescriptions;
m_pMethodMDs = new MethodDesc * [m_cMethodMDs];
ZeroMemory(m_pMethodMDs, m_cMethodMDs * sizeof(*m_pMethodMDs));
//
// Initialize Field RID array
//
_ASSERTE(cFieldDescriptions < USHRT_MAX);
m_cFieldRIDs = (USHORT) cFieldDescriptions;
m_pFieldRIDs = new USHORT [m_cFieldRIDs];
ZeroMemory(m_pFieldRIDs, m_cFieldRIDs * sizeof(*m_pFieldRIDs));
//
// Initialize TypeHandle array
//
_ASSERTE(cTypeDescriptions < USHRT_MAX);
m_cTypeHandles = (USHORT) cTypeDescriptions;
m_pTypeHandles = new TypeHandle [m_cTypeHandles];
ZeroMemory(m_pTypeHandles, m_cTypeHandles * sizeof(*m_pTypeHandles));
}
void Binder::Destroy()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
FORBID_FAULT;
}
CONTRACTL_END;
if (m_pClassRIDs != NULL
&& !m_pModule->IsPersistedObject(m_pClassRIDs))
delete [] m_pClassRIDs;
if (m_pMethodMDs != NULL
&& !m_pModule->IsPersistedObject(m_pMethodMDs))
delete [] m_pMethodMDs;
if (m_pFieldRIDs != NULL
&& !m_pModule->IsPersistedObject(m_pFieldRIDs))
delete [] m_pFieldRIDs;
if (m_pTypeHandles != NULL)
delete [] m_pTypeHandles;
}
#endif // #ifndef DACCESS_COMPILE
mdTypeDef Binder::GetTypeDef(BinderClassID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
PRECONDITION(id != CLASS__NIL);
PRECONDITION(id <= m_cClassRIDs);
}
CONTRACTL_END;
if (m_pClassRIDs[id-1] == 0)
LookupClass(id);
return TokenFromRid(m_pClassRIDs[id-1], mdtTypeDef);
}
mdMethodDef Binder::GetMethodDef(BinderMethodID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
PRECONDITION(id != METHOD__NIL);
PRECONDITION(id <= m_cMethodMDs);
}
CONTRACTL_END;
if (m_pMethodMDs[id-1] == NULL)
LookupMethod(id);
return m_pMethodMDs[id-1]->GetMemberDef();
}
mdFieldDef Binder::GetFieldDef(BinderFieldID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
PRECONDITION(id != FIELD__NIL);
PRECONDITION(id <= m_cFieldRIDs);
}
CONTRACTL_END;
if (m_pFieldRIDs[id-1] == 0)
LookupField(id);
return TokenFromRid(m_pFieldRIDs[id-1], mdtFieldDef);
}
//
// Raw retrieve structures from ID. Use these when
// you don't care about class Restore or .cctors.
//
MethodTable *Binder::RawGetClass(BinderClassID id, ClassLoadLevel level)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
FORBID_FAULT;
SO_TOLERANT;
PRECONDITION(CheckPointer(m_pModule));
PRECONDITION(id != CLASS__NIL);
PRECONDITION(id <= m_cClassRIDs);
}
CONTRACTL_END;
TypeHandle th = m_pModule->LookupTypeDef(TokenFromRid(m_pClassRIDs[id-1], mdtTypeDef), level);
_ASSERTE(!th.IsNull());
_ASSERTE(th.IsUnsharedMT());
return th.AsMethodTable();
}
MethodDesc *Binder::RawGetMethod(BinderMethodID id)
{
CONTRACT(MethodDesc*)
{
NOTHROW;
GC_NOTRIGGER;
FORBID_FAULT;
SO_TOLERANT;
PRECONDITION(CheckPointer(m_pModule));
PRECONDITION(id != METHOD__NIL);
PRECONDITION(id <= m_cMethodMDs);
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
MethodDesc *pMD = m_pMethodMDs[id - 1];
RETURN pMD;
}
FieldDesc *Binder::RawGetField(BinderFieldID id)
{
CONTRACT(FieldDesc*)
{
NOTHROW;
GC_NOTRIGGER;
FORBID_FAULT;
SO_TOLERANT;
PRECONDITION(CheckPointer(m_pModule));
PRECONDITION(id != FIELD__NIL);
PRECONDITION(id <= m_cFieldRIDs);
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
const FieldDescription *f = m_fieldDescriptions + (id - 1);
PREFIX_ASSUME(f != NULL);
MethodTable *pMT = RawGetClass(f->classID, CLASS_LOAD_UNRESTOREDTYPEKEY);
PREFIX_ASSUME(pMT != NULL);
// Can't do this because the class may not be restored yet.
// _ASSERTE(m_pFieldRIDs[id-1]-1 < (pMT->GetClass()->GetNumStaticFields()
// + pMT->GetNumIntroducedInstanceFields()));
g_IBCLogger.LogFieldDescsAccess(pMT->GetClass());
FieldDesc *pFD = pMT->GetClass()->GetFieldDescListPtr() +
(m_pFieldRIDs[id-1] - 1);
RETURN pFD;
}
TypeHandle Binder::RawGetType(BinderTypeID id)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
FORBID_FAULT;
SO_TOLERANT;
PRECONDITION(CheckPointer(m_pModule));
PRECONDITION(id != TYPE__NIL);
PRECONDITION(id <= m_cTypeHandles);
}
CONTRACTL_END;
TypeHandle th = m_pTypeHandles[id-1];
_ASSERTE(!th.IsNull());
return th;
}
//
// Inline function to check a class for init & restore
//
inline void Binder::CheckInit(MethodTable *pMT)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(COMPlusThrowOM());
}
CONTRACTL_END;
if (!pMT->IsClassInited())
{
#ifndef DACCESS_COMPILE
InitClass(pMT);
#else
DacNotImpl();
#endif
}
}
//
// Fetch retrieve structures from ID - doesn't
// trigger class init
//
MethodTable *Binder::FetchClass(BinderClassID id, BOOL fLoad/* = TRUE*/, ClassLoadLevel level/* = CLASS_LOADED*/)
{
CONTRACTL
{
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) NOTHROW; else THROWS;
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) GC_NOTRIGGER; else GC_TRIGGERS;
MODE_ANY;
if (fLoad) SO_INTOLERANT; else SO_TOLERANT;
}
CONTRACTL_END;
_ASSERTE(id != CLASS__NIL);
_ASSERTE(id <= m_cClassRIDs);
MethodTable *pMT;
if (m_pClassRIDs[id-1] == 0)
{
pMT = LookupClass(id, fLoad, level);
// If we're looking up the class because it wasn't in the class RID cache, then
// it is possible that we won't load the type. While by definition we will always
// have String and CriticalFinalizerObject loaded (we load them in
// AppDomain::LoadBaseSystemClasses), new cases could be introduced so this is
// just the safe thing to do.
if (pMT == NULL)
{
return NULL;
}
// handle special classes
switch (id) {
case CLASS__STRING:
// Strings are not "normal" objects, so we need to mess with their method table a bit
// so that the GC can figure out how big each string is...
pMT->SetBaseSize(ObjSizeOf(StringObject));
pMT->SetComponentSize(2);
break;
case CLASS__CRITICAL_FINALIZER_OBJECT:
// To introduce a class with a critical finalizer,
// we'll explicitly load CriticalFinalizerObject and set the bit
// here.
pMT->SetHasCriticalFinalizer();
break;
default:
break;
}
}
else
{
pMT = RawGetClass(id, CLASS_LOAD_UNRESTOREDTYPEKEY);
PREFIX_ASSUME(pMT != NULL);
if (fLoad)
ClassLoader::EnsureLoaded(pMT, level);
g_IBCLogger.LogMethodTableAccess(pMT);
}
return pMT;
}
MethodDesc *Binder::FetchMethod(BinderMethodID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
}
CONTRACTL_END;
_ASSERTE(id != METHOD__NIL);
_ASSERTE(id <= m_cMethodMDs);
MethodDesc *pMD;
if (m_pMethodMDs[id-1] == 0)
pMD = LookupMethod(id);
else
{
pMD = RawGetMethod(id);
pMD->CheckRestore();
g_IBCLogger.LogMethodDescAccess(pMD);
}
if (m_methodDescriptions[id-1].sig != NULL)
{
// Initialize the sig here where it's safe. (Otherwise it would typically happen
// during a MethodDesc::Call.)
PCCOR_SIGNATURE pSig;
DWORD cbSigSize;
m_methodDescriptions[id-1].sig->GetBinarySig(&pSig, &cbSigSize);
}
return pMD;
}
FieldDesc *Binder::FetchField(BinderFieldID id)
{
CONTRACTL
{
if (FORBIDGC_LOADER_USE_ENABLED() ) NOTHROW; else THROWS;
if (FORBIDGC_LOADER_USE_ENABLED() ) GC_NOTRIGGER; else GC_TRIGGERS;
MODE_ANY;
if (FORBIDGC_LOADER_USE_ENABLED() ) FORBID_FAULT; else INJECT_FAULT(ThrowOutOfMemory());
SO_TOLERANT;
}
CONTRACTL_END;
_ASSERTE(id != FIELD__NIL);
_ASSERTE(id <= m_cFieldRIDs);
FieldDesc *pFD;
if (m_pFieldRIDs[id-1] == 0)
pFD = LookupField(id);
else
{
pFD = RawGetField(id);
pFD->GetEnclosingMethodTable()->CheckRestore();
}
return pFD;
}
TypeHandle Binder::FetchType(BinderTypeID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
PRECONDITION(id != TYPE__NIL);
PRECONDITION(id <= m_cTypeHandles);
}
CONTRACTL_END;
TypeHandle th = m_pTypeHandles[id-1];
if (th.IsNull())
th = LookupType(id);
return th;
}
//
// Normal retrieve structures from ID
//
MethodTable *Binder::GetClass(BinderClassID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
}
CONTRACTL_END;
#ifndef DACCESS_COMPILE
_ASSERTE (GetThread ());
TRIGGERSGC ();
#ifdef STRESS_HEAP
// Force a GC here because GetClass could trigger GC nondeterminsticly
if (g_pConfig->GetGCStressLevel() != 0)
{
Thread * pThread = GetThread ();
BOOL bInCoopMode = pThread->PreemptiveGCDisabled ();
GCX_COOP ();
if (bInCoopMode)
{
pThread->PulseGCMode ();
}
}
#endif //STRESS_HEAP
#endif //DACCESS_COMPILE
MethodTable *pMT = FetchClass(id);
CheckInit(pMT);
return pMT;
}
MethodDesc *Binder::GetMethod(BinderMethodID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
}
CONTRACTL_END;
#ifndef DACCESS_COMPILE
_ASSERTE (GetThread ());
TRIGGERSGC ();
#ifdef STRESS_HEAP
// Force a GC here because GetMethod could trigger GC nondeterminsticly
if (g_pConfig->GetGCStressLevel() != 0)
{
Thread * pThread = GetThread ();
BOOL bInCoopMode = pThread->PreemptiveGCDisabled ();
GCX_COOP ();
if (bInCoopMode)
{
pThread->PulseGCMode ();
}
}
#endif //STRESS_HEAP
#endif //DACCESS_COMPILE
MethodDesc *pMD = FetchMethod(id);
CheckInit(pMD->GetMethodTable());
// Record this method desc if required
g_IBCLogger.LogMethodDescAccess(pMD);
return pMD;
}
FieldDesc *Binder::GetField(BinderFieldID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
}
CONTRACTL_END;
#ifndef DACCESS_COMPILE
_ASSERTE (GetThread ());
TRIGGERSGC ();
#ifdef STRESS_HEAP
// Force a GC here because GetField could trigger GC nondeterminsticly
if (g_pConfig->GetGCStressLevel() != 0)
{
Thread * pThread = GetThread ();
BOOL bInCoopMode = pThread->PreemptiveGCDisabled ();
GCX_COOP ();
if (bInCoopMode)
{
pThread->PulseGCMode ();
}
}
#endif //STRESS_HEAP
#endif //DACCESS_COMPILE
FieldDesc *pFD = FetchField(id);
CheckInit(pFD->GetEnclosingMethodTable());
return pFD;
}
TypeHandle Binder::GetType(BinderTypeID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
}
CONTRACTL_END;
#ifndef DACCESS_COMPILE
_ASSERTE (GetThread ());
TRIGGERSGC ();
#ifdef STRESS_HEAP
// Force a GC here because GetType could trigger GC nondeterminsticly
if (g_pConfig->GetGCStressLevel() != 0)
{
Thread * pThread = GetThread ();
BOOL bInCoopMode = pThread->PreemptiveGCDisabled ();
GCX_COOP ();
if (bInCoopMode)
{
pThread->PulseGCMode ();
}
}
#endif //STRESS_HEAP
#endif //DACCESS_COMPILE
TypeHandle th = FetchType(id);
return th;
}
//
// Method address - these could conceivably be implemented
// more efficiently than accessing the Desc info.
//
const BYTE *Binder::GetMethodAddress(BinderMethodID id)
{
WRAPPER_CONTRACT;
return GetMethod(id)->GetAddrofCode();
}
//
// Offsets - these could conceivably be implemented
// more efficiently than accessing the Desc info.
//
DWORD Binder::GetFieldOffset(BinderFieldID id)
{
WRAPPER_CONTRACT;
return FetchField(id)->GetOffset();
}
BOOL Binder::IsClass(MethodTable *pMT, BinderClassID id)
{
CONTRACTL
{
GC_NOTRIGGER;
NOTHROW;
FORBID_FAULT;
MODE_ANY;
}
CONTRACTL_END;
if (m_pClassRIDs[id-1] == 0)
return PTR_HOST_TO_TADDR(LookupClass(id, FALSE, CLASS_LOAD_UNRESTOREDTYPEKEY)) ==
PTR_HOST_TO_TADDR(pMT);
else
return PTR_HOST_TO_TADDR(RawGetClass(id, CLASS_LOAD_UNRESTOREDTYPEKEY)) ==
PTR_HOST_TO_TADDR(pMT);
}
BOOL Binder::IsType(TypeHandle th, BinderTypeID id)
{
CONTRACTL
{
GC_NOTRIGGER;
NOTHROW;
FORBID_FAULT;
MODE_ANY;
}
CONTRACTL_END;
if (RawGetType(id) == th)
return TRUE;
if (!m_pTypeHandles[id-1].IsNull())
return FALSE;
else
return LookupType(id, FALSE) == th;
}
#ifndef DACCESS_COMPILE
void Binder::InitClass(MethodTable *pMT)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(CheckPointer(pMT));
}
CONTRACTL_END;
// Switch to cooperative GC mode before we manipulate any OBJECTREF's.
GCX_COOP();
pMT->CheckRunClassInitThrowing();
}
#endif // #ifndef DACCESS_COMPILE
MethodTable *Binder::LookupClass(BinderClassID id, BOOL fLoad, ClassLoadLevel level/* = CLASS_LOADED*/)
{
CONTRACTL
{
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) NOTHROW; else THROWS;
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) GC_NOTRIGGER; else GC_TRIGGERS;
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) FORBID_FAULT; else { INJECT_FAULT(COMPlusThrowOM()); }
MODE_ANY;
PRECONDITION(CheckPointer(m_pModule));
PRECONDITION(id != CLASS__NIL);
PRECONDITION(id <= m_cClassRIDs);
}
CONTRACTL_END;
MethodTable *pMT;
const ClassDescription *d = m_classDescriptions + (id - 1);
PREFIX_ASSUME(d != NULL);
if (!fLoad)
{
ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE();
pMT = ClassLoader::LoadTypeByNameThrowing(m_pModule->GetAssembly(), d->namesp, d->name,
ClassLoader::ReturnNullIfNotFound,
// == FailIfNotLoadedOrNotRestored
ClassLoader::DontLoadTypes,
level).AsMethodTable();
if (pMT == NULL)
return NULL;
}
else
{
pMT = ClassLoader::LoadTypeByNameThrowing(m_pModule->GetAssembly(), d->namesp, d->name,
ClassLoader::ThrowIfNotFound,
ClassLoader::LoadTypes,
level).AsMethodTable();
}
if (pMT == NULL)
return NULL; // Not needed, but makes prefast happy
_ASSERTE(pMT->GetModule() == m_pModule);
mdTypeDef td = pMT->GetCl();
_ASSERTE(!IsNilToken(td));
_ASSERTE(RidFromToken(td) <= USHRT_MAX);
m_pClassRIDs[id-1] = (USHORT) RidFromToken(td);
return pMT;
}
MethodDesc *Binder::LookupMethod(BinderMethodID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
INJECT_FAULT(ThrowOutOfMemory());
PRECONDITION(CheckPointer(m_pModule));
PRECONDITION(id != METHOD__NIL);
PRECONDITION(id <= m_cMethodMDs);
}
CONTRACTL_END;
const MethodDescription *d = m_methodDescriptions + (id - 1);
MethodTable *pMT = FetchClass(d->classID);
MethodDesc *pMD = (d->sig != NULL) ?
pMT->GetClass()->FindMethod(d->name, d->sig) :
pMT->GetClass()->FindMethodByName(d->name);
PREFIX_ASSUME_MSGF(pMD != NULL, ("EE expects method to exist: %s:%s\n", pMT->GetDebugClassName(), d->name));
_ASSERTE(pMD->GetSlot()+1 <= USHRT_MAX);
#ifndef DACCESS_COMPILE
m_pMethodMDs[id-1] = pMD;
#endif
return pMD;
}
FieldDesc *Binder::LookupField(BinderFieldID id)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
SO_TOLERANT;
INJECT_FAULT(ThrowOutOfMemory());
PRECONDITION(CheckPointer(m_pModule));
PRECONDITION(id != FIELD__NIL);
PRECONDITION(id <= m_cFieldRIDs);
}
CONTRACTL_END;
const FieldDescription *d = m_fieldDescriptions + (id - 1);
PREFIX_ASSUME(d != NULL);
MethodTable *pMT = FetchClass(d->classID);
FieldDesc *pFD;
pFD = pMT->GetClass()->FindField(d->name, NULL, 0, NULL);
#ifndef DACCESS_COMPILE
PREFIX_ASSUME_MSGF(pFD != NULL, ("EE expects field to exist: %s:%s\n", pMT->GetDebugClassName(), d->name));
_ASSERTE(pFD - pMT->GetApproxFieldDescListRaw() >= 0);
_ASSERTE(pFD - pMT->GetApproxFieldDescListRaw() < (pMT->GetNumStaticFields()
+ pMT->GetNumIntroducedInstanceFields()));
_ASSERTE(pFD - pMT->GetApproxFieldDescListRaw() + 1 < USHRT_MAX);
USHORT index = (USHORT)(pFD - pMT->GetApproxFieldDescListRaw());
m_pFieldRIDs[id-1] = index+1;
#endif
return pFD;
}
TypeHandle Binder::LookupType(BinderTypeID id, BOOL fLoad)
{
CONTRACTL
{
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) NOTHROW; else THROWS;
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) GC_NOTRIGGER; else GC_TRIGGERS;
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) FORBID_FAULT; else { INJECT_FAULT(COMPlusThrowOM()); }
if (! fLoad) SO_TOLERANT; else SO_INTOLERANT;
MODE_ANY;
PRECONDITION(CheckPointer(m_pModule));
PRECONDITION(id != TYPE__NIL);
PRECONDITION(id <= m_cTypeHandles);
}
CONTRACTL_END;
const TypeDescription *d = m_typeDescriptions + (id - 1);
TypeHandle th = m_pTypeHandles[id-1];
if (!th.IsNull())
return th;
if (!fLoad)
{
MethodTable *mt = LookupClass(d->classID, FALSE);
if (mt == NULL)
return TypeHandle();
{
ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE();
th = ClassLoader::LoadArrayTypeThrowing(TypeHandle(mt), d->type, d->rank, ClassLoader::LoadTypes);
}
}
else
{
th = ClassLoader::LoadArrayTypeThrowing(TypeHandle(GetClass(d->classID)), d->type, d->rank);
}
if (th.IsNull())
return TypeHandle();
#ifndef DACCESS_COMPILE
m_pTypeHandles[id-1] = th;
#endif
return th;
}
BOOL Binder::IsException(MethodTable *pMT, RuntimeExceptionKind kind)
{
WRAPPER_CONTRACT;
return IsClass(pMT, (BinderClassID) (kind + CLASS__MSCORLIB_COUNT));
}
MethodTable *Binder::GetException(RuntimeExceptionKind kind)
{
WRAPPER_CONTRACT;
return GetClass((BinderClassID) (kind + CLASS__MSCORLIB_COUNT));
}
MethodTable *Binder::FetchException(RuntimeExceptionKind kind)
{
WRAPPER_CONTRACT;
return FetchClass((BinderClassID) (kind + CLASS__MSCORLIB_COUNT));
}
LPCUTF8 Binder::GetExceptionName(RuntimeExceptionKind kind)
{
WRAPPER_CONTRACT;
return GetClassName((BinderClassID) (kind + CLASS__MSCORLIB_COUNT));
}
BOOL Binder::IsElementType(MethodTable *pMT, CorElementType type)
{
WRAPPER_CONTRACT;
BinderClassID id = (BinderClassID) (type + CLASS__MSCORLIB_COUNT + kLastException);
_ASSERTE(GetClassName(id) != NULL);
return IsClass(pMT, id);
}
MethodTable *Binder::GetElementType(CorElementType type)
{
WRAPPER_CONTRACT;
BinderClassID id = (BinderClassID) (type + CLASS__MSCORLIB_COUNT + kLastException);
_ASSERTE(GetClassName(id) != NULL);
return GetClass(id);
}
MethodTable *Binder::FetchElementType(CorElementType type, BOOL fLoad/* = TRUE*/, ClassLoadLevel level/* = CLASS_LOADED*/)
{
CONTRACTL
{
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) NOTHROW; else THROWS;
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) GC_NOTRIGGER; else GC_TRIGGERS;
if (FORBIDGC_LOADER_USE_ENABLED() || !fLoad) FORBID_FAULT; else { INJECT_FAULT(COMPlusThrowOM()); }
MODE_ANY;
}
CONTRACTL_END;
BinderClassID id = (BinderClassID) (type + CLASS__MSCORLIB_COUNT + kLastException);
_ASSERTE(GetClassName(id) != NULL);
return FetchClass(id, fLoad, level);
}
MethodTable *Binder::LookupElementType(CorElementType type, ClassLoadLevel level /* = CLASS_LOADED */)
{
WRAPPER_CONTRACT;
BinderClassID id = (BinderClassID) (type + CLASS__MSCORLIB_COUNT + kLastException);
return LookupClass(id, FALSE, level);
}
LPCUTF8 Binder::GetElementTypeName(CorElementType type)
{
WRAPPER_CONTRACT;
return GetClassName((BinderClassID) (type + CLASS__MSCORLIB_COUNT + kLastException));
}
///////////////////////////////////////////////////////////////////////////////
// Mscorlib:
///////////////////////////////////////////////////////////////////////////////
// For the dac compile we only need the array size
#define CountOfMscorlibClassDescriptions \
((CLASS__MSCORLIB_COUNT - 1) + kLastException + ELEMENT_TYPE_MAX)
#define CountOfMscorlibMethodDescriptions (METHOD__MSCORLIB_COUNT - 1)
#define CountOfMscorlibFieldDescriptions (FIELD__MSCORLIB_COUNT - 1)
#define CountOfMscorlibTypeDescriptions (TYPE__MSCORLIB_COUNT - 1)
#ifndef DACCESS_COMPILE
#include "nativeoverlapped.h"
const Binder::ClassDescription Binder::MscorlibClassDescriptions[] =
{
#define DEFINE_CLASS(i,n,s) { PTR_CSTR((TADDR) g_ ## n ## NS ), PTR_CSTR((TADDR) # s ) },
#include "mscorlib.h"
// Include all exception types here
#define EXCEPTION_BEGIN_DEFINE(ns, reKind, bHRformessage, hr) { PTR_CSTR((TADDR)ns) , PTR_CSTR((TADDR) # reKind ) },
#define EXCEPTION_ADD_HR(hr)
#define EXCEPTION_END_DEFINE()
#include "rexcep.h"
#undef EXCEPTION_BEGIN_DEFINE
#undef EXCEPTION_ADD_HR
#undef EXCEPTION_END_DEFINE
// Now include all signature types
#define TYPEINFO(e,ns,c,s,g,ia,ip,if,im) { PTR_CSTR((TADDR)ns) , PTR_CSTR((TADDR)c) },
#include "cortypeinfo.h"
#undef TYPEINFO
};
#define gsig_NoSig (*(char*)NULL)
const Binder::MethodDescription Binder::MscorlibMethodDescriptions[] =
{
#define DEFINE_METHOD(c,i,s,g) { CLASS__ ## c , PTR_CUTF8((TADDR) # s ), PTR_HARDCODEDMETASIG((TADDR) & gsig_ ## g ) },
#include "mscorlib.h"
} ;
const Binder::FieldDescription Binder::MscorlibFieldDescriptions[] =
{
#define DEFINE_FIELD(c,i,s) { CLASS__ ## c , PTR_CUTF8((TADDR) # s ) },
#ifdef _DEBUG
#define DEFINE_FIELD_U(c,i,s,uc,uf) { CLASS__ ## c , PTR_CUTF8((TADDR) # s ) },
#endif // _DEBUG
#include "mscorlib.h"
};
const Binder::TypeDescription Binder::MscorlibTypeDescriptions[] =
{
{ CLASS__BYTE, ELEMENT_TYPE_SZARRAY, 1 },
{ CLASS__OBJECT, ELEMENT_TYPE_SZARRAY, 1 },
{ CLASS__VARIANT, ELEMENT_TYPE_SZARRAY, 1 },
{ CLASS__VOID, ELEMENT_TYPE_PTR, 0 },
};
#endif // DACCESS_COMPILE
#ifndef DACCESS_COMPILE
#ifdef _DEBUG
const Binder::FieldOffsetCheck Binder::MscorlibFieldOffsets[] =
{
#define DEFINE_FIELD_U(c,i,s,uc,uf) { FIELD__ ## c ## __ ## i, offsetof(uc, uf), sizeof(((uc*)1)->uf) },
#include "mscorlib.h"
{ (BinderFieldID) 0 }
};
const Binder::ClassSizeCheck Binder::MscorlibClassSizes[] =
{
#define DEFINE_CLASS_U(i,n,s,uc) { CLASS__ ## i, sizeof(uc) },
#include "mscorlib.h"
{ (BinderClassID) 0 }
};
//
// check the basic consistency between mscorlib and mscorwks
//
void Binder::CheckMscorlib()
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
INJECT_FAULT(ThrowOutOfMemory());
}
CONTRACTL_END;
const FieldOffsetCheck *pOffsets = MscorlibFieldOffsets;
while (pOffsets->fieldID != FIELD__NIL)
{
FieldDesc *pFD = g_Mscorlib.FetchField(pOffsets->fieldID);
DWORD offset = pFD->GetOffset();
if (!pFD->IsFieldOfValueType())
{
offset += Object::GetOffsetOfFirstField();
}
CONSISTENCY_CHECK_MSGF(offset == pOffsets->expectedOffset,
("Managed class field offset does not match unmanaged class field offset\n"
"man: 0x%x, unman: 0x%x, Name: %s\n", offset, pOffsets->expectedOffset, pFD->GetName()));
DWORD size = pFD->LoadSize();
CONSISTENCY_CHECK_MSGF(size == pOffsets->expectedSize,
("Managed class field size does not match unmanaged class field size\n"
"man: 0x%x, unman: 0x%x, Name: %s\n", size, pOffsets->expectedSize, pFD->GetName()));
pOffsets++;
}
const ClassSizeCheck *pSizes = MscorlibClassSizes;
while (pSizes->classID != CLASS__NIL)
{
MethodTable *pMT = g_Mscorlib.FetchClass(pSizes->classID);
// hidden size of the type that participates in the allignment calculation
DWORD hiddenSize = pMT->IsValueType() ? sizeof(MethodTable*) : 0;
DWORD size = pMT->GetBaseSize() - (sizeof(ObjHeader)+hiddenSize);
DWORD expectedsize = (DWORD)ALIGN_UP(pSizes->expectedSize + (sizeof(ObjHeader) + hiddenSize),
DATA_ALIGNMENT) - (sizeof(ObjHeader) + hiddenSize);
CONSISTENCY_CHECK_MSGF(size == expectedsize,
("Managed object size does not match unmanaged object size\n"
"man: 0x%x, unman: 0x%x, Name: %s\n", size, expectedsize, pMT->GetDebugClassName()));
pSizes++;
}
}
//
// check consistency of the unmanaged and managed fcall signatures
//
/* static */ FCSigCheck* FCSigCheck::g_pFCSigCheck;
static void FCallCheckSignature(MethodDesc* pMD, LPVOID pImpl, BOOL* pfDuplicateImplementations)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
char* pUnmanagedSig = NULL;
FCSigCheck* pSigCheck = FCSigCheck::g_pFCSigCheck;
while (pSigCheck != NULL)
{
if (pImpl == pSigCheck->func) {
if (pUnmanagedSig != NULL)
{
// There are multiple fcalls with identical entrypoints. Skip signature check now
// to give a better assert later.
*pfDuplicateImplementations = TRUE;
return;
}
pUnmanagedSig = pSigCheck->signature;
}
pSigCheck = pSigCheck->next;
}
MetaSig msig(pMD);
int argIndex = -2; // start with return value
char* pUnmanagedArg = pUnmanagedSig;
for (;;)
{
CorElementType argType = ELEMENT_TYPE_END;
TypeHandle argTypeHandle;
if (argIndex == -2)
{
// return value
argType = msig.GetReturnType();
if (argType == ELEMENT_TYPE_VALUETYPE)
argTypeHandle = msig.GetRetTypeHandleThrowing();
}
if (argIndex == -1)
{
// this ptr
if (msig.HasThis())
argType = ELEMENT_TYPE_CLASS;
else
argIndex++; // move on to the first argument
}
if (argIndex >= 0)
{
argType = msig.NextArg();
if (argType == ELEMENT_TYPE_END)
break;
if (argType == ELEMENT_TYPE_VALUETYPE)
argTypeHandle = msig.GetLastTypeHandleThrowing();
}
const char* expectedType = NULL;
switch (argType)
{
case ELEMENT_TYPE_VOID:
expectedType = pMD->IsCtor() ? NULL : "void";
break;
case ELEMENT_TYPE_BOOLEAN:
expectedType = (argIndex == -2) ? "FC_BOOL_RET" : "CLR_BOOL";
break;
case ELEMENT_TYPE_CHAR:
expectedType = (argIndex == -2) ? "FC_CHAR_RET" : "CLR_CHAR";
break;
case ELEMENT_TYPE_I1:
expectedType = (argIndex == -2) ? "FC_INT8_RET" : "INT8";
break;
case ELEMENT_TYPE_U1:
expectedType = (argIndex == -2) ? "FC_UINT8_RET" : "UINT8";
break;
case ELEMENT_TYPE_I2:
expectedType = (argIndex == -2) ? "FC_INT16_RET" : "INT16";
break;
case ELEMENT_TYPE_U2:
expectedType = (argIndex == -2) ? "FC_UINT16_RET" : "UINT16";
break;
// case ELEMENT_TYPE_I4:
// expectedType = "INT32";
// break;
// case ELEMENT_TYPE_U4:
// expectedType = "UINT32";
// break;
case ELEMENT_TYPE_I8:
expectedType = (argIndex == -2) ? "INT64" : "VINT64";
break;
case ELEMENT_TYPE_U8:
expectedType = (argIndex == -2) ? "UINT64" : "VUINT64";
break;
case ELEMENT_TYPE_R4:
expectedType = (argIndex == -2) ? "float" : "Vfloat";
break;
case ELEMENT_TYPE_R8:
expectedType = (argIndex == -2) ? "double" : "Vdouble";
break;
case ELEMENT_TYPE_VALUETYPE:
{
_ASSERTE(!argTypeHandle.IsNull());
StackSString ssArgTypeName;
argTypeHandle.GetName(ssArgTypeName);
// These types are special cased as ELEMENT_TYPE_I in class.cpp
if ((ssArgTypeName.Equals(SL(L"System.RuntimeTypeHandle"))) ||
(ssArgTypeName.Equals(SL(L"System.RuntimeArgumentHandle"))) ||
(ssArgTypeName.Equals(SL(L"System.RuntimeMethodHandle"))) ||
(ssArgTypeName.Equals(SL(L"System.RuntimeFieldHandle"))))
break;
// If the verifier type for a small valuetype is not a valuetype, it means that on
// all !VALUETYPES_BY_REFERENCE platforms this argument gets passed directly
// but on this platform it is always BYREF, so there's likely to be a mismatch.
CONSISTENCY_CHECK_MSGF(
(argTypeHandle.GetSize() >= sizeof(ARG_SLOT))
|| (argTypeHandle.GetVerifierCorElementType() != ELEMENT_TYPE_VALUETYPE),
("The fcall signature contains small value type that is likely to be source of portability problems\n"
"Method: %s:%s. Argument: %d\n", pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName, argIndex));
}
break;
default:
// no checks for other types
break;
}
if (pUnmanagedSig != NULL)
{
CONSISTENCY_CHECK_MSGF(pUnmanagedArg != NULL,
("Unexpected end of managed fcall signature\n"
"Method: %s:%s\n", pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName));
char* pUnmanagedArgEnd = strchr(pUnmanagedArg, ',');
char* pUnmanagedTypeEnd = (pUnmanagedArgEnd != NULL) ?
pUnmanagedArgEnd : (pUnmanagedArg + strlen(pUnmanagedArg));
if (argIndex != -2)
{
// skip argument name
while(pUnmanagedTypeEnd > pUnmanagedArg)
{
char c = *(pUnmanagedTypeEnd-1);
if ((c != '_')
&& ((c < '0') || ('9' < c))
&& ((c < 'a') || ('z' < c))
&& ((c < 'A') || ('Z' < c)))
break;
pUnmanagedTypeEnd--;
}
}
// skip whitespaces
while(pUnmanagedTypeEnd > pUnmanagedArg)
{
char c = *(pUnmanagedTypeEnd-1);
if ((c != 0x20) && (c != '\t') && (c != '\n') && (c != '\r'))
break;
pUnmanagedTypeEnd--;
}
if (expectedType != NULL)
{
size_t len = pUnmanagedTypeEnd - pUnmanagedArg;
CONSISTENCY_CHECK_MSGF(strlen(expectedType) == len && SString::_strnicmp(expectedType, pUnmanagedArg, (COUNT_T)len) == 0,
("The managed and unmanaged fcall signatures do not match\n"
"Method: %s:%s. Argument: %d Expecting: %s\n", pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName, argIndex, expectedType));
}
pUnmanagedArg = (pUnmanagedArgEnd != NULL) ? (pUnmanagedArgEnd+1) : NULL;
}
argIndex++;
}
if (pUnmanagedSig != NULL)
{
if (msig.IsVarArg())
{
CONSISTENCY_CHECK_MSGF((pUnmanagedArg != NULL) && strcmp(pUnmanagedArg, "...") == 0,
("Expecting varargs in unmanaged fcall signature\n"
"Method: %s:%s\n", pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName));
}
else
{
CONSISTENCY_CHECK_MSGF(pUnmanagedArg == NULL,
("Unexpected end of unmanaged fcall signature\n"
"Method: %s:%s\n", pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName));
}
}
}
struct FCImplEntry
{
LPVOID m_pImplementation;
MethodDesc * m_pMD;
};
static int __cdecl fcImplEntryCmp(const void* a_, const void* b_)
{
LEAF_CONTRACT;
FCImplEntry *a = (FCImplEntry *)a_;
FCImplEntry *b = (FCImplEntry *)b_;
return(int)((size_t)a->m_pImplementation - (size_t)b->m_pImplementation);
}
//
// extended check of consistency between mscorlib and mscorwks:
// - verifies that all references from mscorlib to mscorwks are present
// - verifies that all references from mscorwks to mscorlib are present
// - limited detection of mismatches between managed and unmanaged fcall signatures
//
void Binder::CheckMscorlibExtended()
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;
INJECT_FAULT(ThrowOutOfMemory());
}
CONTRACTL_END;
// check the consistency of BCL and VM
// note: it is not enabled by default because of it is time consuming and
// changes the bootstrap sequence of the EE
if (!g_pConfig->GetConfigDWORD(L"ConsistencyCheck", 0))
return;
//
// VM referencing BCL (mscorlib.h)
//
for (BinderClassID cID = (BinderClassID) 1; cID <= g_Mscorlib.m_cClassRIDs; cID = (BinderClassID) (cID + 1)) {
if (g_Mscorlib.GetClassName(cID) != NULL) // Allow for CorSigElement entries with no classes
g_Mscorlib.FetchClass(cID);
}
for (BinderMethodID mID = (BinderMethodID) 1; mID <= g_Mscorlib.m_cMethodMDs; mID = (BinderMethodID) (mID + 1))
g_Mscorlib.FetchMethod(mID);
for (BinderFieldID fID = (BinderFieldID) 1; fID <= g_Mscorlib.m_cFieldRIDs; fID = (BinderFieldID) (fID + 1))
g_Mscorlib.FetchField(fID);
//
// BCL referencing VM (ecall.cpp)
//
HRESULT hr = S_OK;
Module *pModule = g_Mscorlib.m_pModule;
IMDInternalImport *pInternalImport = pModule->GetMDImport();
HENUMInternal hEnum;
LPVOID pImplementation = NULL;
const DWORD dwMaxNumEntries = 2000;
DWORD dwNumEntries = 0;
NewArrayHolder<FCImplEntry> pSortedEntries(NULL);
BOOL fDuplicateImplementations = FALSE;
// for all methods...
IfFailGo(pInternalImport->EnumAllInit(mdtMethodDef, &hEnum));
// Allocate a temporary array to store the static FCall entry points.
pSortedEntries = new FCImplEntry[dwMaxNumEntries];
for (;;) {
mdTypeDef td;
mdTypeDef tdClass;
DWORD dwImplFlags;
if (!pInternalImport->EnumNext(&hEnum, &td))
break;
pInternalImport->GetMethodImplProps(td, NULL, &dwImplFlags);
// ... that are internal calls ...
if (!IsMiInternalCall(dwImplFlags))
continue;
IfFailGo(pInternalImport->GetParentToken(td, &tdClass));
TypeHandle type;
HRESULT hr = ClassLoader::LoadTypeDefOrRefNoThrow(pModule, tdClass, &type, NULL,
ClassLoader::ThrowIfNotFound,
ClassLoader::FailIfUninstDefOrRef);
if (FAILED(hr) || type.IsNull()) {
LPCUTF8 pszClassName;
LPCUTF8 pszNameSpace;
pInternalImport->GetNameOfTypeDef(tdClass, &pszClassName, &pszNameSpace);
CONSISTENCY_CHECK_MSGF(false, ("Unable to load class from mscorlib: %s.%s\n", pszNameSpace, pszClassName));
}
MethodDesc *pMD = type.AsMethodTable()->GetClass()->FindMethod(td);
_ASSERTE(pMD);
// Get the implementation entrypoint and store it in the array
pImplementation = ECall::GetStaticFCallImpl(pMD);
if (pImplementation) {
if (dwNumEntries >= dwMaxNumEntries) {
_ASSERTE(!"dwMaxNumEntries too small");
ThrowHR(E_FAIL);
}
pSortedEntries[dwNumEntries].m_pImplementation = pImplementation;
pSortedEntries[dwNumEntries].m_pMD = pMD;
++dwNumEntries;
}
DWORD id = ECall::GetIDForMethod(pMD);
// ... check that the method is in the fcall table.
if (id == 0) {
LPCUTF8 pszClassName;
LPCUTF8 pszNameSpace;
pInternalImport->GetNameOfTypeDef(tdClass, &pszClassName, &pszNameSpace);
LPCUTF8 pszName = pInternalImport->GetNameOfMethodDef(td);
CONSISTENCY_CHECK_MSGF(false, ("Unable to find internalcall implementation: %s.%s::%s\n", pszNameSpace, pszClassName, pszName));
}
else {
FCallCheckSignature(pMD, ECall::GetFCallImpl(pMD), &fDuplicateImplementations);
}
}
pInternalImport->EnumClose(&hEnum);
//
// Sort the static FCall entrypoints, and check for duplication.
//
_ASSERTE(dwNumEntries>=2); // We should at least find 2 static FCall entries.
qsort (pSortedEntries, // start of array
dwNumEntries, // array size in elements
sizeof(FCImplEntry), // element size in bytes
fcImplEntryCmp); // comparere function
for (DWORD i=1; i<dwNumEntries; i++)
{
if (pSortedEntries[i].m_pImplementation == pSortedEntries[i-1].m_pImplementation)
{
// The fcall entrypoints has to be at unique addresses. If you get failure here, use the following steps
// to fix it:
// 1. Consider merging the offending fcalls into one fcall. Do they really do different things?
// 2. If it does not make sense to merge the offending fcalls into one,
// add FCUnique(<a random unique number here>); to one of the offending fcalls.
// Attach debugger to see the names of the offending methods in debug output.
_ASSERTE(!"Duplicate pImplementation entries found in reverse fcall table");
MethodDesc* pMD1 = pSortedEntries[i-1].m_pMD;
LPCUTF8 pszMethodName1 = pMD1->GetName();
LPCUTF8 pszNamespace1 = 0;
LPCUTF8 pszName1 = pMD1->GetClass()->GetFullyQualifiedNameInfo(&pszNamespace1);
MethodDesc* pMD2 = pSortedEntries[i].m_pMD;
LPCUTF8 pszMethodName2 = pMD2->GetName();
LPCUTF8 pszNamespace2 = 0;
LPCUTF8 pszName2 = pMD2->GetClass()->GetFullyQualifiedNameInfo(&pszNamespace2);
CONSISTENCY_CHECK_MSGF(false, ("Duplicate implementation found: %s.%s::%s and %s.%s::%s\n",
pszNamespace1, pszName1, pszMethodName1, pszNamespace2, pszName2, pszMethodName2));
fDuplicateImplementations = TRUE;
}
}
// Make sure that nothing slipped through the cracks from FCallCheckSignature
if (fDuplicateImplementations)
{
_ASSERTE(!"Duplicate FCALL implementations");
ThrowHR(E_FAIL);
}
// Verify that there are no unused entries in the ecall table
if (!ECall::CheckUnusedFCalls())
{
ThrowHR(E_FAIL);
}
//
// Stub constants
//
#define ASMCONSTANTS_C_ASSERT(cond)
#define ASMCONSTANTS_RUNTIME_ASSERT(cond) _ASSERTE(cond)
#include "asmconstants.h"
ErrExit:
_ASSERTE(SUCCEEDED(hr));
}
#endif // _DEBUG
#endif // #ifndef DACCESS_COMPILE
GVAL_IMPL(Binder, g_Mscorlib);
#ifndef DACCESS_COMPILE
void Binder::StartupMscorlib(Module *pModule)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
C_ASSERT(CLASS__MSCORLIB_COUNT < USHRT_MAX);
C_ASSERT(METHOD__MSCORLIB_COUNT < USHRT_MAX);
C_ASSERT(FIELD__MSCORLIB_COUNT < USHRT_MAX);
C_ASSERT(TYPE__MSCORLIB_COUNT < USHRT_MAX);
C_ASSERT(CountOfMscorlibClassDescriptions == NumItems(MscorlibClassDescriptions));
C_ASSERT(CountOfMscorlibMethodDescriptions == NumItems(MscorlibMethodDescriptions));
C_ASSERT(CountOfMscorlibFieldDescriptions == NumItems(MscorlibFieldDescriptions));
C_ASSERT(CountOfMscorlibTypeDescriptions == NumItems(MscorlibTypeDescriptions));
{
g_Mscorlib.Init(pModule,
MscorlibClassDescriptions,
NumItems(MscorlibClassDescriptions),
MscorlibMethodDescriptions,
NumItems(MscorlibMethodDescriptions),
MscorlibFieldDescriptions,
NumItems(MscorlibFieldDescriptions),
MscorlibTypeDescriptions,
NumItems(MscorlibTypeDescriptions));
}
}
#endif // #ifndef DACCESS_COMPILE
#ifdef DACCESS_COMPILE
void
Binder::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
{
DAC_ENUM_DTHIS();
DacEnumMemoryRegion(PTR_TO_TADDR(m_classDescriptions),
CountOfMscorlibClassDescriptions * sizeof(ClassDescription));
DacEnumMemoryRegion(PTR_TO_TADDR(m_methodDescriptions),
CountOfMscorlibMethodDescriptions * sizeof(MethodDescription));
DacEnumMemoryRegion(PTR_TO_TADDR(m_fieldDescriptions),
CountOfMscorlibFieldDescriptions * sizeof(FieldDescription));
DacEnumMemoryRegion(PTR_TO_TADDR(m_typeDescriptions),
CountOfMscorlibTypeDescriptions * sizeof(TypeDescription));
if (m_pModule.IsValid())
{
m_pModule->EnumMemoryRegions(flags, true);
}
DacEnumMemoryRegion(PTR_TO_TADDR(m_pClassRIDs),
m_cClassRIDs * sizeof(USHORT));
DacEnumMemoryRegion(PTR_TO_TADDR(m_pFieldRIDs),
m_cFieldRIDs * sizeof(USHORT));
DacEnumMemoryRegion(PTR_TO_TADDR(m_pMethodMDs),
m_cMethodMDs * sizeof(PTR_MethodDesc));
DacEnumMemoryRegion(PTR_TO_TADDR(m_pTypeHandles),
m_cTypeHandles * sizeof(TypeHandle));
}
#endif // #ifdef DACCESS_COMPILE
| 28.69962 | 145 | 0.611619 | intj-t |
43800000c799c05fa9cbb572839f18a0cfbb2a9b | 1,609 | cpp | C++ | source/data/shader/Shader.cpp | atkurtul/RadixEngine | 0eb1c176a25aa9430f54d5a20ce5749360c51381 | [
"Zlib"
] | 163 | 2016-08-28T23:24:05.000Z | 2022-03-31T04:51:51.000Z | source/data/shader/Shader.cpp | atkurtul/RadixEngine | 0eb1c176a25aa9430f54d5a20ce5749360c51381 | [
"Zlib"
] | 144 | 2016-09-10T08:40:06.000Z | 2020-12-03T17:20:03.000Z | source/data/shader/Shader.cpp | atkurtul/RadixEngine | 0eb1c176a25aa9430f54d5a20ce5749360c51381 | [
"Zlib"
] | 88 | 2016-02-22T08:34:49.000Z | 2022-03-05T12:29:19.000Z | #include <radix/data/shader/Shader.hpp>
#include <radix/core/gl/OpenGL.hpp>
namespace radix {
void Shader::bind() const {
glUseProgram(handle);
}
void Shader::release() const {
glUseProgram(0);
}
int Shader::uni(const std::string &name) {
// Check if the uniform name is already in our map
auto it = locationMap.find(name);
if (it != locationMap.end()) {
return it->second;
}
// If its not, get the location and store it
GLint loc = glGetUniformLocation(handle, name.c_str());
locationMap.insert({name, loc});
return loc;
}
int Shader::uni(const char *name) {
// Check if the uniform name is already in our map
auto it = locationMap.find(name);
if (it != locationMap.end()) {
return it->second;
}
// If its not, get the location and store it
GLint loc = glGetUniformLocation(handle, name);
locationMap.insert({name, loc});
return loc;
}
int Shader::att(const std::string &name) {
// Check if the attribute name is already in our map
auto it = locationMap.find(name);
if (it != locationMap.end()) {
return it->second;
}
// If its not, get the location and store it
GLint loc = glGetAttribLocation(handle, name.c_str());
locationMap.insert({name, loc});
return loc;
}
int Shader::att(const char *name) {
// Check if the attribute name is already in our map
auto it = locationMap.find(name);
if (it != locationMap.end()) {
return it->second;
}
// If its not, get the location and store it
GLint loc = glGetAttribLocation(handle, name);
locationMap.insert({name, loc});
return loc;
}
} /* namespace radix */
| 22.347222 | 57 | 0.666252 | atkurtul |
43801ea75098710939c180f291824ffb571ace12 | 30,164 | cpp | C++ | linalg/amgxsolver.cpp | shahzebsiddiqui/mfem | 08b339303b11b98a1aa3db5e04369a6405d4ca5a | [
"BSD-3-Clause"
] | 1 | 2019-03-24T04:35:42.000Z | 2019-03-24T04:35:42.000Z | linalg/amgxsolver.cpp | shahzebsiddiqui/mfem | 08b339303b11b98a1aa3db5e04369a6405d4ca5a | [
"BSD-3-Clause"
] | null | null | null | linalg/amgxsolver.cpp | shahzebsiddiqui/mfem | 08b339303b11b98a1aa3db5e04369a6405d4ca5a | [
"BSD-3-Clause"
] | 1 | 2022-03-17T12:25:48.000Z | 2022-03-17T12:25:48.000Z | // Copyright (c) 2010-2020, Lawrence Livermore National Security, LLC. Produced
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
// LICENSE and NOTICE for details. LLNL-CODE-806117.
//
// This file is part of the MFEM library. For more information and source code
// availability visit https://mfem.org.
//
// MFEM is free software; you can redistribute it and/or modify it under the
// terms of the BSD-3 license. We welcome feedback and contributions, see file
// CONTRIBUTING.md for details.
// Implementation of the MFEM wrapper for Nvidia's multigrid library, AmgX
//
// This work is partially based on:
//
// Pi-Yueh Chuang and Lorena A. Barba (2017).
// AmgXWrapper: An interface between PETSc and the NVIDIA AmgX library.
// J. Open Source Software, 2(16):280, doi:10.21105/joss.00280
//
// See https://github.com/barbagroup/AmgXWrapper.
#include "../config/config.hpp"
#include "amgxsolver.hpp"
#ifdef MFEM_USE_AMGX
namespace mfem
{
int AmgXSolver::count = 0;
AMGX_resources_handle AmgXSolver::rsrc = nullptr;
AmgXSolver::AmgXSolver()
: ConvergenceCheck(false) {};
AmgXSolver::AmgXSolver(const AMGX_MODE amgxMode_, const bool verbose)
{
amgxMode = amgxMode_;
if (amgxMode == AmgXSolver::SOLVER) { ConvergenceCheck = true;}
else { ConvergenceCheck = false;}
DefaultParameters(amgxMode, verbose);
InitSerial();
}
#ifdef MFEM_USE_MPI
AmgXSolver::AmgXSolver(const MPI_Comm &comm,
const AMGX_MODE amgxMode_, const bool verbose)
{
std::string config;
amgxMode = amgxMode_;
if (amgxMode == AmgXSolver::SOLVER) { ConvergenceCheck = true;}
else { ConvergenceCheck = false;}
DefaultParameters(amgxMode, verbose);
InitExclusiveGPU(comm);
}
AmgXSolver::AmgXSolver(const MPI_Comm &comm, const int nDevs,
const AMGX_MODE amgxMode_, const bool verbose)
{
std::string config;
amgxMode = amgxMode_;
if (amgxMode == AmgXSolver::SOLVER) { ConvergenceCheck = true;}
else { ConvergenceCheck = false;}
DefaultParameters(amgxMode_, verbose);
InitMPITeams(comm, nDevs);
}
#endif
AmgXSolver::~AmgXSolver()
{
if (isInitialized) { Finalize(); }
}
void AmgXSolver::InitSerial()
{
count++;
mpi_gpu_mode = "serial";
AMGX_SAFE_CALL(AMGX_initialize());
AMGX_SAFE_CALL(AMGX_initialize_plugins());
AMGX_SAFE_CALL(AMGX_install_signal_handler());
MFEM_VERIFY(configSrc != CONFIG_SRC::UNDEFINED,
"AmgX configuration is not defined \n");
if (configSrc == CONFIG_SRC::EXTERNAL)
{
AMGX_SAFE_CALL(AMGX_config_create_from_file(&cfg, amgx_config.c_str()));
}
else
{
AMGX_SAFE_CALL(AMGX_config_create(&cfg, amgx_config.c_str()));
}
AMGX_resources_create_simple(&rsrc, cfg);
AMGX_solver_create(&solver, rsrc, precision_mode, cfg);
AMGX_matrix_create(&AmgXA, rsrc, precision_mode);
AMGX_vector_create(&AmgXP, rsrc, precision_mode);
AMGX_vector_create(&AmgXRHS, rsrc, precision_mode);
isInitialized = true;
}
#ifdef MFEM_USE_MPI
void AmgXSolver::InitExclusiveGPU(const MPI_Comm &comm)
{
// If this instance has already been initialized, skip
if (isInitialized)
{
mfem_error("This AmgXSolver instance has been initialized on this process.");
}
// Note that every MPI rank may talk to a GPU
mpi_gpu_mode = "mpi-gpu-exclusive";
gpuProc = 0;
// Increment number of AmgX instances
count++;
MPI_Comm_dup(comm, &gpuWorld);
MPI_Comm_size(gpuWorld, &gpuWorldSize);
MPI_Comm_rank(gpuWorld, &myGpuWorldRank);
// Each rank will only see 1 device call it device 0
nDevs = 1, devID = 0;
InitAmgX();
isInitialized = true;
}
// Initialize for MPI ranks > GPUs, all devices are visible to all of the MPI
// ranks
void AmgXSolver::InitMPITeams(const MPI_Comm &comm,
const int nDevs)
{
// If this instance has already been initialized, skip
if (isInitialized)
{
mfem_error("This AmgXSolver instance has been initialized on this process.");
}
mpi_gpu_mode = "mpi-teams";
// Increment number of AmgX instances
count++;
// Get the name of this node
int len;
char name[MPI_MAX_PROCESSOR_NAME];
MPI_Get_processor_name(name, &len);
nodeName = name;
int globalcommrank;
MPI_Comm_rank(comm, &globalcommrank);
// Initialize communicators and corresponding information
InitMPIcomms(comm, nDevs);
// Only processes in gpuWorld are required to initialize AmgX
if (gpuProc == 0)
{
InitAmgX();
}
isInitialized = true;
}
#endif
void AmgXSolver::ReadParameters(const std::string config,
const CONFIG_SRC source)
{
amgx_config = config;
configSrc = source;
}
void AmgXSolver::SetConvergenceCheck(bool setConvergenceCheck_)
{
ConvergenceCheck = setConvergenceCheck_;
}
void AmgXSolver::DefaultParameters(const AMGX_MODE amgxMode_,
const bool verbose)
{
amgxMode = amgxMode_;
configSrc = INTERNAL;
if (amgxMode == AMGX_MODE::PRECONDITIONER)
{
amgx_config = "{\n"
" \"config_version\": 2, \n"
" \"solver\": { \n"
" \"solver\": \"AMG\", \n"
" \"presweeps\": 1, \n"
" \"postsweeps\": 1, \n"
" \"interpolator\": \"D2\", \n"
" \"max_iters\": 2, \n"
" \"convergence\": \"ABSOLUTE\", \n"
" \"cycle\": \"V\"";
if (verbose)
{
amgx_config = amgx_config + ",\n"
" \"obtain_timings\": 1, \n"
" \"print_grid_stats\": 1, \n"
" \"monitor_residual\": 1, \n"
" \"print_solve_stats\": 1 \n";
}
else
{
amgx_config = amgx_config + "\n";
}
amgx_config = amgx_config + " }\n" + "}\n";
}
else if (amgxMode == AMGX_MODE::SOLVER)
{
amgx_config = "{ \n"
" \"config_version\": 2, \n"
" \"solver\": { \n"
" \"preconditioner\": { \n"
" \"solver\": \"AMG\", \n"
" \"smoother\": { \n"
" \"scope\": \"jacobi\", \n"
" \"solver\": \"BLOCK_JACOBI\", \n"
" \"relaxation_factor\": 0.7 \n"
" }, \n"
" \"presweeps\": 1, \n"
" \"interpolator\": \"D2\", \n"
" \"max_row_sum\" : 0.9, \n"
" \"strength_threshold\" : 0.25, \n"
" \"max_iters\": 2, \n"
" \"scope\": \"amg\", \n"
" \"max_levels\": 100, \n"
" \"cycle\": \"V\", \n"
" \"postsweeps\": 1 \n"
" }, \n"
" \"solver\": \"PCG\", \n"
" \"max_iters\": 100, \n"
" \"convergence\": \"RELATIVE_MAX\", \n"
" \"scope\": \"main\", \n"
" \"tolerance\": 1e-12, \n"
" \"monitor_residual\": 1, \n"
" \"norm\": \"L2\" ";
if (verbose)
{
amgx_config = amgx_config + ", \n"
" \"obtain_timings\": 1, \n"
" \"print_grid_stats\": 1, \n"
" \"print_solve_stats\": 1 \n";
}
else
{
amgx_config = amgx_config + "\n";
}
amgx_config = amgx_config + " } \n" + "} \n";
}
else
{
mfem_error("AmgX mode not supported \n");
}
}
// Sets up AmgX library for MPI builds
#ifdef MFEM_USE_MPI
void AmgXSolver::InitAmgX()
{
// Set up once
if (count == 1)
{
AMGX_SAFE_CALL(AMGX_initialize());
AMGX_SAFE_CALL(AMGX_initialize_plugins());
AMGX_SAFE_CALL(AMGX_install_signal_handler());
AMGX_SAFE_CALL(AMGX_register_print_callback(
[](const char *msg, int length)->void
{
int irank; MPI_Comm_rank(MPI_COMM_WORLD, &irank);
if (irank == 0) { mfem::out<<msg;} }));
}
MFEM_VERIFY(configSrc != CONFIG_SRC::UNDEFINED,
"AmgX configuration is not defined \n");
if (configSrc == CONFIG_SRC::EXTERNAL)
{
AMGX_SAFE_CALL(AMGX_config_create_from_file(&cfg, amgx_config.c_str()));
}
else
{
AMGX_SAFE_CALL(AMGX_config_create(&cfg, amgx_config.c_str()));
}
// Let AmgX handle returned error codes internally
AMGX_SAFE_CALL(AMGX_config_add_parameters(&cfg, "exception_handling=1"));
// Create an AmgX resource object, only the first instance needs to create
// the resource object.
if (count == 1) { AMGX_resources_create(&rsrc, cfg, &gpuWorld, 1, &devID); }
// Create AmgX vector object for unknowns and RHS
AMGX_vector_create(&AmgXP, rsrc, precision_mode);
AMGX_vector_create(&AmgXRHS, rsrc, precision_mode);
// Create AmgX matrix object for unknowns and RHS
AMGX_matrix_create(&AmgXA, rsrc, precision_mode);
// Create an AmgX solver object
AMGX_solver_create(&solver, rsrc, precision_mode, cfg);
// Obtain the default number of rings based on current configuration
AMGX_config_get_default_number_of_rings(cfg, &ring);
}
// Groups MPI ranks into teams and assigns the roots to talk to GPUs
void AmgXSolver::InitMPIcomms(const MPI_Comm &comm, const int nDevs)
{
// Duplicate the global communicator
MPI_Comm_dup(comm, &globalCpuWorld);
MPI_Comm_set_name(globalCpuWorld, "globalCpuWorld");
// Get size and rank for global communicator
MPI_Comm_size(globalCpuWorld, &globalSize);
MPI_Comm_rank(globalCpuWorld, &myGlobalRank);
// Get the communicator for processors on the same node (local world)
MPI_Comm_split_type(globalCpuWorld,
MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &localCpuWorld);
MPI_Comm_set_name(localCpuWorld, "localCpuWorld");
// Get size and rank for local communicator
MPI_Comm_size(localCpuWorld, &localSize);
MPI_Comm_rank(localCpuWorld, &myLocalRank);
// Set up corresponding ID of the device used by each local process
SetDeviceIDs(nDevs);
MPI_Barrier(globalCpuWorld);
// Split the global world into a world involved in AmgX and a null world
MPI_Comm_split(globalCpuWorld, gpuProc, 0, &gpuWorld);
// Get size and rank for the communicator corresponding to gpuWorld
if (gpuWorld != MPI_COMM_NULL)
{
MPI_Comm_set_name(gpuWorld, "gpuWorld");
MPI_Comm_size(gpuWorld, &gpuWorldSize);
MPI_Comm_rank(gpuWorld, &myGpuWorldRank);
}
else // for those that will not communicate with the GPU
{
gpuWorldSize = MPI_UNDEFINED;
myGpuWorldRank = MPI_UNDEFINED;
}
// Split local world into worlds corresponding to each CUDA device
MPI_Comm_split(localCpuWorld, devID, 0, &devWorld);
MPI_Comm_set_name(devWorld, "devWorld");
// Get size and rank for the communicator corresponding to myWorld
MPI_Comm_size(devWorld, &devWorldSize);
MPI_Comm_rank(devWorld, &myDevWorldRank);
MPI_Barrier(globalCpuWorld);
}
// Determine MPI teams based on available devices
void AmgXSolver::SetDeviceIDs(const int nDevs)
{
// Set the ID of device that each local process will use
if (nDevs == localSize) // # of the devices and local process are the same
{
devID = myLocalRank;
gpuProc = 0;
}
else if (nDevs > localSize) // there are more devices than processes
{
MFEM_WARNING("CUDA devices on the node " << nodeName.c_str() <<
" are more than the MPI processes launched. Only "<<
nDevs << " devices will be used.\n");
devID = myLocalRank;
gpuProc = 0;
}
else // in case there are more ranks than devices
{
int nBasic = localSize / nDevs,
nRemain = localSize % nDevs;
if (myLocalRank < (nBasic+1)*nRemain)
{
devID = myLocalRank / (nBasic + 1);
if (myLocalRank % (nBasic + 1) == 0) { gpuProc = 0; }
}
else
{
devID = (myLocalRank - (nBasic+1)*nRemain) / nBasic + nRemain;
if ((myLocalRank - (nBasic+1)*nRemain) % nBasic == 0) { gpuProc = 0; }
}
}
}
void AmgXSolver::GatherArray(const Array<double> &inArr, Array<double> &outArr,
const int mpiTeamSz, const MPI_Comm &mpiTeamComm) const
{
// Calculate number of elements to be collected from each process
Array<int> Apart(mpiTeamSz);
int locAsz = inArr.Size();
MPI_Gather(&locAsz, 1, MPI_INT,
Apart.HostWrite(),1, MPI_INT,0,mpiTeamComm);
MPI_Barrier(mpiTeamComm);
// Determine stride for process (to be used by root)
Array<int> Adisp(mpiTeamSz);
int myid; MPI_Comm_rank(mpiTeamComm, &myid);
if (myid == 0)
{
Adisp[0] = 0;
for (int i=1; i<mpiTeamSz; ++i)
{
Adisp[i] = Adisp[i-1] + Apart[i-1];
}
}
MPI_Gatherv(inArr.HostRead(), inArr.Size(), MPI_DOUBLE,
outArr.HostWrite(), Apart.HostRead(), Adisp.HostRead(),
MPI_DOUBLE, 0, mpiTeamComm);
}
void AmgXSolver::GatherArray(const Vector &inArr, Vector &outArr,
const int mpiTeamSz, const MPI_Comm &mpiTeamComm) const
{
// Calculate number of elements to be collected from each process
Array<int> Apart(mpiTeamSz);
int locAsz = inArr.Size();
MPI_Gather(&locAsz, 1, MPI_INT,
Apart.HostWrite(),1, MPI_INT,0,mpiTeamComm);
MPI_Barrier(mpiTeamComm);
// Determine stride for process (to be used by root)
Array<int> Adisp(mpiTeamSz);
int myid; MPI_Comm_rank(mpiTeamComm, &myid);
if (myid == 0)
{
Adisp[0] = 0;
for (int i=1; i<mpiTeamSz; ++i)
{
Adisp[i] = Adisp[i-1] + Apart[i-1];
}
}
MPI_Gatherv(inArr.HostRead(), inArr.Size(), MPI_DOUBLE,
outArr.HostWrite(), Apart.HostRead(), Adisp.HostRead(),
MPI_DOUBLE, 0, mpiTeamComm);
}
void AmgXSolver::GatherArray(const Array<int> &inArr, Array<int> &outArr,
const int mpiTeamSz, const MPI_Comm &mpiTeamComm) const
{
// Calculate number of elements to be collected from each process
Array<int> Apart(mpiTeamSz);
int locAsz = inArr.Size();
MPI_Gather(&locAsz, 1, MPI_INT,
Apart.GetData(),1, MPI_INT,0,mpiTeamComm);
MPI_Barrier(mpiTeamComm);
// Determine stride for process (to be used by root)
Array<int> Adisp(mpiTeamSz);
int myid; MPI_Comm_rank(mpiTeamComm, &myid);
if (myid == 0)
{
Adisp[0] = 0;
for (int i=1; i<mpiTeamSz; ++i)
{
Adisp[i] = Adisp[i-1] + Apart[i-1];
}
}
MPI_Gatherv(inArr.HostRead(), inArr.Size(), MPI_INT,
outArr.HostWrite(), Apart.HostRead(), Adisp.HostRead(),
MPI_INT, 0, mpiTeamComm);
}
void AmgXSolver::GatherArray(const Array<int64_t> &inArr,
Array<int64_t> &outArr,
const int mpiTeamSz, const MPI_Comm &mpiTeamComm) const
{
// Calculate number of elements to be collected from each process
Array<int> Apart(mpiTeamSz);
int locAsz = inArr.Size();
MPI_Gather(&locAsz, 1, MPI_INT,
Apart.GetData(),1, MPI_INT,0,mpiTeamComm);
MPI_Barrier(mpiTeamComm);
// Determine stride for process
Array<int> Adisp(mpiTeamSz);
int myid; MPI_Comm_rank(mpiTeamComm, &myid);
if (myid == 0)
{
Adisp[0] = 0;
for (int i=1; i<mpiTeamSz; ++i)
{
Adisp[i] = Adisp[i-1] + Apart[i-1];
}
}
MPI_Gatherv(inArr.HostRead(), inArr.Size(), MPI_INT64_T,
outArr.HostWrite(), Apart.HostRead(), Adisp.HostRead(),
MPI_INT64_T, 0, mpiTeamComm);
MPI_Barrier(mpiTeamComm);
}
void AmgXSolver::GatherArray(const Vector &inArr, Vector &outArr,
const int mpiTeamSz, const MPI_Comm &mpiTeamComm,
Array<int> &Apart, Array<int> &Adisp) const
{
// Calculate number of elements to be collected from each process
int locAsz = inArr.Size();
MPI_Allgather(&locAsz, 1, MPI_INT,
Apart.HostWrite(),1, MPI_INT, mpiTeamComm);
MPI_Barrier(mpiTeamComm);
// Determine stride for process
Adisp[0] = 0;
for (int i=1; i<mpiTeamSz; ++i)
{
Adisp[i] = Adisp[i-1] + Apart[i-1];
}
MPI_Gatherv(inArr.HostRead(), inArr.Size(), MPI_DOUBLE,
outArr.HostWrite(), Apart.HostRead(), Adisp.HostRead(),
MPI_DOUBLE, 0, mpiTeamComm);
}
void AmgXSolver::ScatterArray(const Vector &inArr, Vector &outArr,
const int mpiTeamSz, const MPI_Comm &mpiTeamComm,
Array<int> &Apart, Array<int> &Adisp) const
{
MPI_Scatterv(inArr.HostRead(),Apart.HostRead(),Adisp.HostRead(),
MPI_DOUBLE,outArr.HostWrite(),outArr.Size(),
MPI_DOUBLE, 0, mpiTeamComm);
}
#endif
void AmgXSolver::SetMatrix(const SparseMatrix &in_A, const bool update_mat)
{
if (update_mat == false)
{
AMGX_matrix_upload_all(AmgXA, in_A.Height(),
in_A.NumNonZeroElems(),
1, 1,
in_A.ReadI(),
in_A.ReadJ(),
in_A.ReadData(), NULL);
AMGX_solver_setup(solver, AmgXA);
AMGX_vector_bind(AmgXP, AmgXA);
AMGX_vector_bind(AmgXRHS, AmgXA);
}
else
{
AMGX_matrix_replace_coefficients(AmgXA,
in_A.Height(),
in_A.NumNonZeroElems(),
in_A.ReadData(), NULL);
}
}
#ifdef MFEM_USE_MPI
void AmgXSolver::SetMatrix(const HypreParMatrix &A, const bool update_mat)
{
// Require hypre >= 2.16.
#if MFEM_HYPRE_VERSION < 21600
mfem_error("Hypre version 2.16+ is required when using AmgX \n");
#endif
hypre_ParCSRMatrix * A_ptr =
(hypre_ParCSRMatrix *)const_cast<HypreParMatrix&>(A);
hypre_CSRMatrix *A_csr = hypre_MergeDiagAndOffd(A_ptr);
Array<double> loc_A(A_csr->data, (int)A_csr->num_nonzeros);
const Array<int> loc_I(A_csr->i, (int)A_csr->num_rows+1);
// Column index must be int64_t so we must promote here
Array<int64_t> loc_J((int)A_csr->num_nonzeros);
for (int i=0; i<A_csr->num_nonzeros; ++i)
{
loc_J[i] = A_csr->big_j[i];
}
// Assumes one GPU per MPI rank
if (mpi_gpu_mode=="mpi-gpu-exclusive")
{
return SetMatrixMPIGPUExclusive(A, loc_A, loc_I, loc_J, update_mat);
}
// Assumes teams of MPI ranks are sharing a GPU
if (mpi_gpu_mode == "mpi-teams")
{
return SetMatrixMPITeams(A, loc_A, loc_I, loc_J, update_mat);
}
mfem_error("Unsupported MPI_GPU combination \n");
}
void AmgXSolver::SetMatrixMPIGPUExclusive(const HypreParMatrix &A,
const Array<double> &loc_A,
const Array<int> &loc_I,
const Array<int64_t> &loc_J,
const bool update_mat)
{
// Create a vector of offsets describing matrix row partitions
Array<int64_t> rowPart(gpuWorldSize+1); rowPart = 0.0;
int64_t myStart = A.GetRowStarts()[0];
MPI_Allgather(&myStart, 1, MPI_INT64_T,
rowPart.GetData(),1, MPI_INT64_T
,gpuWorld);
MPI_Barrier(gpuWorld);
rowPart[gpuWorldSize] = A.M();
const int nGlobalRows = A.M();
const int local_rows = loc_I.Size()-1;
const int num_nnz = loc_I[local_rows];
if (update_mat == false)
{
AMGX_distribution_handle dist;
AMGX_distribution_create(&dist, cfg);
AMGX_distribution_set_partition_data(dist, AMGX_DIST_PARTITION_OFFSETS,
rowPart.GetData());
AMGX_matrix_upload_distributed(AmgXA, nGlobalRows, local_rows,
num_nnz, 1, 1, loc_I.Read(),
loc_J.Read(), loc_A.Read(),
NULL, dist);
AMGX_distribution_destroy(dist);
MPI_Barrier(gpuWorld);
AMGX_solver_setup(solver, AmgXA);
AMGX_vector_bind(AmgXP, AmgXA);
AMGX_vector_bind(AmgXRHS, AmgXA);
}
else
{
AMGX_matrix_replace_coefficients(AmgXA,nGlobalRows,num_nnz,loc_A, NULL);
}
}
void AmgXSolver::SetMatrixMPITeams(const HypreParMatrix &A,
const Array<double> &loc_A,
const Array<int> &loc_I,
const Array<int64_t> &loc_J,
const bool update_mat)
{
// The following arrays hold the consolidated diagonal + off-diagonal matrix
// data
Array<int> all_I;
Array<int64_t> all_J;
Array<double> all_A;
// Determine array sizes
int J_allsz(0), all_NNZ(0), nDevRows(0);
const int loc_row_len = std::abs(A.RowPart()[1] -
A.RowPart()[0]); // end of row partition
const int loc_Jz_sz = loc_J.Size();
const int loc_A_sz = loc_A.Size();
MPI_Reduce(&loc_row_len, &nDevRows, 1, MPI_INT, MPI_SUM, 0, devWorld);
MPI_Reduce(&loc_Jz_sz, &J_allsz, 1, MPI_INT, MPI_SUM, 0, devWorld);
MPI_Reduce(&loc_A_sz, &all_NNZ, 1, MPI_INT, MPI_SUM, 0, devWorld);
MPI_Barrier(devWorld);
if (myDevWorldRank == 0)
{
all_I.SetSize(nDevRows+devWorldSize);
all_J.SetSize(J_allsz); all_J = 0.0;
all_A.SetSize(all_NNZ);
}
GatherArray(loc_I, all_I, devWorldSize, devWorld);
GatherArray(loc_J, all_J, devWorldSize, devWorld);
GatherArray(loc_A, all_A, devWorldSize, devWorld);
MPI_Barrier(devWorld);
int local_nnz(0);
int64_t local_rows(0);
if (myDevWorldRank == 0)
{
// A fix up step is needed for the array holding row data to remove extra
// zeros when consolidating team data.
Array<int> z_ind(devWorldSize+1);
int iter = 1;
while (iter < devWorldSize-1)
{
// Determine the indices of zeros in global all_I array
int counter = 0;
z_ind[counter] = counter;
counter++;
for (int idx=1; idx<all_I.Size()-1; idx++)
{
if (all_I[idx]==0)
{
z_ind[counter] = idx-1;
counter++;
}
}
z_ind[devWorldSize] = all_I.Size()-1;
// End of determining indices of zeros in global all_I Array
// Bump all_I
for (int idx=z_ind[1]+1; idx < z_ind[2]; idx++)
{
all_I[idx] = all_I[idx-1] + (all_I[idx+1] - all_I[idx]);
}
// Shift array after bump to remove unnecessary values in middle of
// array
for (int idx=z_ind[2]; idx < all_I.Size()-1; ++idx)
{
all_I[idx] = all_I[idx+1];
}
iter++;
}
// LAST TIME THROUGH ARRAY
// Determine the indices of zeros in global row_ptr array
int counter = 0;
z_ind[counter] = counter;
counter++;
for (int idx=1; idx<all_I.Size()-1; idx++)
{
if (all_I[idx]==0)
{
z_ind[counter] = idx-1;
counter++;
}
}
z_ind[devWorldSize] = all_I.Size()-1;
// End of determining indices of zeros in global all_I Array BUMP all_I
// one last time
for (int idx=z_ind[1]+1; idx < all_I.Size()-1; idx++)
{
all_I[idx] = all_I[idx-1] + (all_I[idx+1] - all_I[idx]);
}
local_nnz = all_I[all_I.Size()-devWorldSize];
local_rows = nDevRows;
}
// Create row partition
mat_local_rows = local_rows; // class copy
Array<int64_t> rowPart;
if (gpuProc == 0)
{
rowPart.SetSize(gpuWorldSize+1); rowPart=0;
MPI_Allgather(&local_rows, 1, MPI_INT64_T,
&rowPart.GetData()[1], 1, MPI_INT64_T,
gpuWorld);
MPI_Barrier(gpuWorld);
// Fixup step
for (int i=1; i<rowPart.Size(); ++i)
{
rowPart[i] += rowPart[i-1];
}
// Upload A matrix to AmgX
MPI_Barrier(gpuWorld);
int nGlobalRows = A.M();
if (update_mat == false)
{
AMGX_distribution_handle dist;
AMGX_distribution_create(&dist, cfg);
AMGX_distribution_set_partition_data(dist, AMGX_DIST_PARTITION_OFFSETS,
rowPart.GetData());
AMGX_matrix_upload_distributed(AmgXA, nGlobalRows, local_rows,
local_nnz,
1, 1, all_I.ReadWrite(),
all_J.Read(),
all_A.Read(),
nullptr, dist);
AMGX_distribution_destroy(dist);
MPI_Barrier(gpuWorld);
AMGX_solver_setup(solver, AmgXA);
// Bind vectors to A
AMGX_vector_bind(AmgXP, AmgXA);
AMGX_vector_bind(AmgXRHS, AmgXA);
}
else
{
AMGX_matrix_replace_coefficients(AmgXA,nGlobalRows,local_nnz,all_A,NULL);
}
}
}
#endif
void AmgXSolver::SetOperator(const Operator& op)
{
height = op.Height();
width = op.Width();
if (const SparseMatrix* Aptr =
dynamic_cast<const SparseMatrix*>(&op))
{
SetMatrix(*Aptr);
}
#ifdef MFEM_USE_MPI
else if (const HypreParMatrix* Aptr =
dynamic_cast<const HypreParMatrix*>(&op))
{
SetMatrix(*Aptr);
}
#endif
else
{
mfem_error("Unsupported Operator Type \n");
}
}
void AmgXSolver::UpdateOperator(const Operator& op)
{
if (const SparseMatrix* Aptr =
dynamic_cast<const SparseMatrix*>(&op))
{
SetMatrix(*Aptr, true);
}
#ifdef MFEM_USE_MPI
else if (const HypreParMatrix* Aptr =
dynamic_cast<const HypreParMatrix*>(&op))
{
SetMatrix(*Aptr, true);
}
#endif
else
{
mfem_error("Unsupported Operator Type \n");
}
}
void AmgXSolver::Mult(const Vector& B, Vector& X) const
{
// Set initial guess to zero
X.UseDevice(true);
X = 0.0;
// Mult for serial, and mpi-exclusive modes
if (mpi_gpu_mode != "mpi-teams")
{
AMGX_vector_upload(AmgXP, X.Size(), 1, X.ReadWrite());
AMGX_vector_upload(AmgXRHS, B.Size(), 1, B.Read());
if (mpi_gpu_mode != "serial")
{
#ifdef MFEM_USE_MPI
MPI_Barrier(gpuWorld);
#endif
}
AMGX_solver_solve(solver,AmgXRHS, AmgXP);
AMGX_SOLVE_STATUS status;
AMGX_solver_get_status(solver, &status);
if (status != AMGX_SOLVE_SUCCESS && ConvergenceCheck)
{
if (status == AMGX_SOLVE_DIVERGED)
{
mfem_error("AmgX solver failed to solve system \n");
}
else
{
mfem_error("AmgX solver diverged \n");
}
}
AMGX_vector_download(AmgXP, X.Write());
return;
}
#ifdef MFEM_USE_MPI
Vector all_X(mat_local_rows);
Vector all_B(mat_local_rows);
Array<int> Apart_X(devWorldSize);
Array<int> Adisp_X(devWorldSize);
Array<int> Apart_B(devWorldSize);
Array<int> Adisp_B(devWorldSize);
GatherArray(X, all_X, devWorldSize, devWorld, Apart_X, Adisp_X);
GatherArray(B, all_B, devWorldSize, devWorld, Apart_B, Adisp_B);
MPI_Barrier(devWorld);
if (gpuWorld != MPI_COMM_NULL)
{
AMGX_vector_upload(AmgXP, all_X.Size(), 1, all_X.ReadWrite());
AMGX_vector_upload(AmgXRHS, all_B.Size(), 1, all_B.ReadWrite());
MPI_Barrier(gpuWorld);
AMGX_solver_solve(solver,AmgXRHS, AmgXP);
AMGX_SOLVE_STATUS status;
AMGX_solver_get_status(solver, &status);
if (status != AMGX_SOLVE_SUCCESS && amgxMode == SOLVER)
{
if (status == AMGX_SOLVE_DIVERGED)
{
mfem_error("AmgX solver failed to solve system \n");
}
else
{
mfem_error("AmgX solver diverged \n");
}
}
AMGX_vector_download(AmgXP, all_X.Write());
}
ScatterArray(all_X, X, devWorldSize, devWorld, Apart_X, Adisp_X);
#endif
}
int AmgXSolver::GetNumIterations()
{
int getIters;
AMGX_solver_get_iterations_number(solver, &getIters);
return getIters;
}
void AmgXSolver::Finalize()
{
// Check instance is initialized
if (! isInitialized || count < 1)
{
mfem_error("Error in AmgXSolver::Finalize(). \n"
"This AmgXWrapper has not been initialized. \n"
"Please initialize it before finalization.\n");
}
// Only processes using GPU are required to destroy AmgX content
#ifdef MFEM_USE_MPI
if (gpuProc == 0 || mpi_gpu_mode == "serial")
#endif
{
// Destroy solver instance
AMGX_solver_destroy(solver);
// Destroy matrix instance
AMGX_matrix_destroy(AmgXA);
// Destroy RHS and unknown vectors
AMGX_vector_destroy(AmgXP);
AMGX_vector_destroy(AmgXRHS);
// Only the last instance need to destroy resource and finalizing AmgX
if (count == 1)
{
AMGX_resources_destroy(rsrc);
AMGX_SAFE_CALL(AMGX_config_destroy(cfg));
AMGX_SAFE_CALL(AMGX_finalize_plugins());
AMGX_SAFE_CALL(AMGX_finalize());
}
else
{
AMGX_config_destroy(cfg);
}
#ifdef MFEM_USE_MPI
// destroy gpuWorld
if (mpi_gpu_mode != "serial")
{
MPI_Comm_free(&gpuWorld);
}
#endif
}
// re-set necessary variables in case users want to reuse the variable of
// this instance for a new instance
#ifdef MFEM_USE_MPI
gpuProc = MPI_UNDEFINED;
if (globalCpuWorld != MPI_COMM_NULL)
{
MPI_Comm_free(&globalCpuWorld);
MPI_Comm_free(&localCpuWorld);
MPI_Comm_free(&devWorld);
}
#endif
// decrease the number of instances
count -= 1;
// change status
isInitialized = false;
}
} // mfem namespace
#endif
| 29.087753 | 84 | 0.590837 | shahzebsiddiqui |
438629cd1b3721c2df720a9d66f31540d4e6393a | 1,044 | cpp | C++ | webGLTest/engine/shaders/shader_phong.cpp | geefr/webexperiments | afcd8b9e01bf501e87d5fcfda4abae6d6ee0ef05 | [
"BSD-2-Clause"
] | null | null | null | webGLTest/engine/shaders/shader_phong.cpp | geefr/webexperiments | afcd8b9e01bf501e87d5fcfda4abae6d6ee0ef05 | [
"BSD-2-Clause"
] | null | null | null | webGLTest/engine/shaders/shader_phong.cpp | geefr/webexperiments | afcd8b9e01bf501e87d5fcfda4abae6d6ee0ef05 | [
"BSD-2-Clause"
] | null | null | null |
#include "shader_phong.h"
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
Shader_phong::Shader_phong() {
mShaders = {
"data/shaders/vertex/default.vert",
"data/shaders/fragment/phong.frag",
};
}
Shader_phong::~Shader_phong() {}
/// Compile the shader, make ready to be used etc.
void Shader_phong::initialiseGLData() {
Shader_materialinterface::initialiseGLData();
mShaderUniformDiffuseTexturePresent = glGetUniformLocation(mShaderProgram, "diffuseTexturePresent");
mShaderUniformDiffuseTextureSampler = glGetUniformLocation(mShaderProgram, "diffuseTexture");
}
void Shader_phong::bind() {
Shader_materialinterface::bind();
if( mTextures.diffuse ) {
// A diffuse texture is present, flag to override the material
glUniform1i(mShaderUniformDiffuseTexturePresent, GL_TRUE);
mTextures.diffuse->bind(GL_TEXTURE0);
glUniform1i(mShaderUniformDiffuseTextureSampler, 0);
} else {
// A diffuse texture isn't present, just render the material
glUniform1i(mShaderUniformDiffuseTexturePresent, GL_FALSE);
}
}
| 28.216216 | 101 | 0.769157 | geefr |
4387149acf2ffd0cc66c99c047d0f6da1caef098 | 1,926 | hpp | C++ | src/Modules/VisualsModule/Entity/BaseVisual.hpp | danielfilipealmeida/Orange | e0118a7d1391e74c15c707e64a2e0458d51d318f | [
"MIT"
] | null | null | null | src/Modules/VisualsModule/Entity/BaseVisual.hpp | danielfilipealmeida/Orange | e0118a7d1391e74c15c707e64a2e0458d51d318f | [
"MIT"
] | null | null | null | src/Modules/VisualsModule/Entity/BaseVisual.hpp | danielfilipealmeida/Orange | e0118a7d1391e74c15c707e64a2e0458d51d318f | [
"MIT"
] | null | null | null | //
// BaseVisual.hpp
// orange
//
// Created by Daniel Almeida on 02/12/2018.
//
#ifndef BaseVisual_hpp
#define BaseVisual_hpp
#include <stdio.h>
#include "EntityInterface.hpp"
#include "DrawableInterface.hpp"
#include "PlayableInterface.hpp"
#include "ofMain.h"
#define THUMB_WIDTH 160
#define THUMB_HEIGHT 120
namespace Orange {
namespace Visuals {
/*!
Implements the interface for all Visuals
*/
class BaseVisual :
public Orange::Base::EntityInterface,
public Orange::Base::DrawableInterface,
public Orange::Base::PlayableInterface,
public ofBaseUpdates
{
public:
std::string hash;
BaseVisual();
/*!
Draws the Visual in a given rect
\param float x
\param float y
\param float w
\param float h
*/
void draw(float x, float y, float w, float h);
/*!
Renders the visual to be drawn later
*/
void render();
ofJson toJson();
void setFromJson(ofJson json);
/*!
Returns a thumbnail of the video
\returns ofImage
*/
virtual ofImage& getThumbnail() = 0;
/*!
Returns the texture of the video
\returns ofFbo*
*/
virtual ofTexture& getTexture() = 0;
virtual void generateThumbnail() = 0;
/*!
Getter that tells if the visual has a thumbnail set or not
\return Boolean
*/
virtual Boolean thumbCreated() = 0;
};
}
}
#endif /* BaseVisual_hpp */
| 22.658824 | 71 | 0.47352 | danielfilipealmeida |
4389f385fa943ac9bffa7d1b76f7d574948ee287 | 6,932 | cpp | C++ | plugin_III/game_III/common.cpp | thelink2012/plugin-sdk | 5b4133a6161bcd7c9fe5041d52ef9aff44f12892 | [
"Zlib"
] | null | null | null | plugin_III/game_III/common.cpp | thelink2012/plugin-sdk | 5b4133a6161bcd7c9fe5041d52ef9aff44f12892 | [
"Zlib"
] | null | null | null | plugin_III/game_III/common.cpp | thelink2012/plugin-sdk | 5b4133a6161bcd7c9fe5041d52ef9aff44f12892 | [
"Zlib"
] | null | null | null | /*
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "common.h"
// Converted from cdecl float FindPlayerHeading(void) 0x4A1220;
float FindPlayerHeading() {
return plugin::CallAndReturn<float, 0x4A1220>();
}
// Converted from cdecl CVector& FindPlayerCentreOfWorld_NoSniperShift(void) 0x4A11C0;
CVector& FindPlayerCentreOfWorld_NoSniperShift() {
return plugin::CallAndReturn<CVector&, 0x4A11C0>();
}
// Converted from cdecl CVector& FindPlayerCentreOfWorld(int playerId) 0x4A1170;
CVector& FindPlayerCentreOfWorld(int playerId) {
return plugin::CallAndReturn<CVector&, 0x4A1170, int>(playerId);
}
// Converted from cdecl CPlayerPed* FindPlayerPed(void) 0x4A1150;
CPlayerPed* FindPlayerPed() {
return plugin::CallAndReturn<CPlayerPed*, 0x4A1150>();
}
// Converted from cdecl CTrain* FindPlayerTrain(void) 0x4A1120;
CTrain* FindPlayerTrain() {
return plugin::CallAndReturn<CTrain*, 0x4A1120>();
}
// Converted from cdecl CEntity* FindPlayerEntity(void) 0x4A10F0;
CEntity* FindPlayerEntity() {
return plugin::CallAndReturn<CEntity*, 0x4A10F0>();
}
// Converted from cdecl CVehicle* FindPlayerVehicle(void) 0x4A10C0;
CVehicle* FindPlayerVehicle() {
return plugin::CallAndReturn<CVehicle*, 0x4A10C0>();
}
// Converted from cdecl CVector& FindPlayerSpeed(void) 0x4A1090;
CVector& FindPlayerSpeed() {
return plugin::CallAndReturn<CVector&, 0x4A1090>();
}
// Converted from cdecl CVector& FindPlayerCoors(void) 0x4A1030;
CVector& FindPlayerCoors() {
return plugin::CallAndReturn<CVector&, 0x4A1030>();
}
// Converted from cdecl RwTexture* GetFirstTexture(RwTexDictionary *texDictionary) 0x5264E0
RwTexture* GetFirstTexture(RwTexDictionary* texDictionary) {
return plugin::CallAndReturn<RwTexture*, 0x5264E0, RwTexDictionary*>(texDictionary);
}
// Converted from cdecl RwObject* GetFirstObject(RwFrame *frame) 0x526460
RwObject* GetFirstObject(RwFrame* frame) {
return plugin::CallAndReturn<RwObject*, 0x526460, RwFrame*>(frame);
}
// Converted from cdecl RpAtomic* GetFirstAtomic(RpClump *clump) 0x526420
RpAtomic* GetFirstAtomic(RpClump* clump) {
return plugin::CallAndReturn<RpAtomic*, 0x526420, RpClump*>(clump);
}
// Converted from cdecl void SetAmbientColours(RwRGBAReal *colours) 0x526FA0
void SetAmbientColours(RwRGBAReal* colours) {
plugin::Call<0x526FA0, RwRGBAReal*>(colours);
}
// Converted from cdecl void SetAmbientColoursForPedsCarsAndObjects(void) 0x526F80
void SetAmbientColoursForPedsCarsAndObjects() {
plugin::Call<0x526F80>();
}
// Converted from cdecl void SetAmbientColours(void) 0x526F60
void SetAmbientColours() {
plugin::Call<0x526F60>();
}
// Converted from cdecl void ActivateDirectional(void) 0x526F50
void ActivateDirectional() {
plugin::Call<0x526F50>();
}
// Converted from cdecl void DeActivateDirectional(void) 0x526F40
void DeActivateDirectional() {
plugin::Call<0x526F40>();
}
// Converted from cdecl void ReSetAmbientAndDirectionalColours(void) 0x526F10
void ReSetAmbientAndDirectionalColours() {
plugin::Call<0x526F10>();
}
// Converted from cdecl void SetBrightMarkerColours(float power) 0x526E60
void SetBrightMarkerColours(float power) {
plugin::Call<0x526E60, float>(power);
}
// Converted from cdecl void SetAmbientAndDirectionalColours(float power) 0x526DE0
void SetAmbientAndDirectionalColours(float power) {
plugin::Call<0x526DE0, float>(power);
}
// Converted from cdecl void RemoveExtraDirectionalLights(RpWorld *world) 0x526DB0
void RemoveExtraDirectionalLights(RpWorld* world) {
plugin::Call<0x526DB0, RpWorld*>(world);
}
// Converted from cdecl void AddAnExtraDirectionalLight(RpWorld *world,float x,float y,float z,float red,float green,float blue) 0x526C70
void AddAnExtraDirectionalLight(RpWorld* world, float x, float y, float z, float red, float green, float blue) {
plugin::Call<0x526C70, RpWorld*, float, float, float, float, float, float>(world, x, y, z, red, green, blue);
}
// Converted from cdecl void WorldReplaceNormalLightsWithScorched(RpWorld *world,float intensity) 0x526C10
void WorldReplaceNormalLightsWithScorched(RpWorld* world, float intensity) {
plugin::Call<0x526C10, RpWorld*, float>(world, intensity);
}
// Converted from cdecl RpWorld* LightsDestroy(RpWorld *world) 0x526B40
RpWorld* LightsDestroy(RpWorld* world) {
return plugin::CallAndReturn<RpWorld*, 0x526B40, RpWorld*>(world);
}
// Converted from cdecl RpWorld* LightsCreate(RpWorld *world) 0x5269A0
RpWorld* LightsCreate(RpWorld* world) {
return plugin::CallAndReturn<RpWorld*, 0x5269A0, RpWorld*>(world);
}
// Converted from cdecl void SetLightsWithTimeOfDayColour(RpWorld *world) 0x526510
void SetLightsWithTimeOfDayColour(RpWorld* world) {
plugin::Call<0x526510, RpWorld*>(world);
}
// Converted from cdecl RwFrame* GetFirstChild(RwFrame *frame) 0x5264A0
RwFrame* GetFirstChild(RwFrame* frame) {
return plugin::CallAndReturn<RwFrame*, 0x5264A0, RwFrame*>(frame);
}
// Converted from cdecl RpAtomic* GetFirstAtomicCallback(RpAtomic *atomic, void *data) 0x526410
RpAtomic* GetFirstAtomicCallback(RpAtomic* atomic, void* data) {
return plugin::CallAndReturn<RpAtomic*, 0x526410, RpAtomic*, void*>(atomic, data);
}
// Converted from cdecl RwObject* GetFirstObjectCallback(RwObject *object, void *data) 0x526450
RwObject* GetFirstObjectCallback(RwObject* object, void* data) {
return plugin::CallAndReturn<RwObject*, 0x526450, RwObject*, void*>(object, data);
}
// Converted from cdecl RwFrame* GetFirstFrameCallback(RwFrame *frame, void *data) 0x526490
RwFrame* GetFirstFrameCallback(RwFrame* frame, void* data) {
return plugin::CallAndReturn<RwFrame*, 0x526490, RwFrame*, void*>(frame, data);
}
// Converted from cdecl RwTexture* GetFirstTextureCallback(RwTexture *texture, void *data) 0x5264D0
RwTexture* GetFirstTextureCallback(RwTexture* texture, void* data) {
return plugin::CallAndReturn<RwTexture*, 0x5264D0, RwTexture*, void*>(texture, data);
}
// Converted from cdecl void WorldReplaceScorchedLightsWithNormal(RpWorld *world) 0x526C50
void WorldReplaceScorchedLightsWithNormal(RpWorld* world) {
plugin::Call<0x526C50, RpWorld*>(world);
}
// Converted from cdecl void CreateDebugFont(void) 0x526300
void CreateDebugFont() {
plugin::Call<0x526300>();
}
// Converted from cdecl void DestroyDebugFont(void) 0x526310
void DestroyDebugFont() {
plugin::Call<0x526310>();
}
// Converted from cdecl void FlushObrsPrintfs(void) 0x526320
void FlushObrsPrintfs() {
plugin::Call<0x526320>();
}
// Converted from cdecl void DefinedState(void) 0x526330
void DefinedState() {
plugin::Call<0x526330>();
}
CAnimBlendAssociation* RpAnimBlendClumpGetAssociation(RpClump* clump, unsigned int animId) {
return plugin::CallAndReturn<CAnimBlendAssociation*, 0x4055C0>(clump, animId);
}
| 36.104167 | 137 | 0.7676 | thelink2012 |
438cc4ad6436456bb3e7372919a63788096d8dab | 4,137 | cpp | C++ | 19-inheritance/readerEx.19.05/shape.cpp | heavy3/programming-abstractions | e10eab5fe7d9ca7d7d4cc96551524707214e43a8 | [
"MIT"
] | 81 | 2018-11-15T21:23:19.000Z | 2022-03-06T09:46:36.000Z | 19-inheritance/readerEx.19.05/shape.cpp | heavy3/programming-abstractions | e10eab5fe7d9ca7d7d4cc96551524707214e43a8 | [
"MIT"
] | null | null | null | 19-inheritance/readerEx.19.05/shape.cpp | heavy3/programming-abstractions | e10eab5fe7d9ca7d7d4cc96551524707214e43a8 | [
"MIT"
] | 41 | 2018-11-15T21:23:24.000Z | 2022-02-24T03:02:26.000Z | //
// shape.cpp
//
// This program implements the Shape class hierarchy.
//
// --------------------------------------------------------------------------
// Attribution: "Programming Abstractions in C++" by Eric Roberts
// Chapter 19, Exercise 5
// Stanford University, Autumn Quarter 2012
// http://web.stanford.edu/class/archive/cs/cs106b/cs106b.1136/materials/CS106BX-Reader.pdf
// --------------------------------------------------------------------------
//
// Extended by Glenn Streiff on 3/24/17.
// Copyright © 2017 Glenn Streiff. All rights reserved. (derivative work)
//
#include "shape.h"
#include <cmath>
// Class: Shape (abstract)
void Shape::setLocation(double x, double y) {
this->x = x;
this->y = y;
}
void Shape::move(double x, double y) {
this->x += x;
this->y += y;
}
std::string Shape::getColor() const {
return this->color;
}
void Shape::setColor(std::string color) {
this->color = color;
}
Shape::Shape() {
color = "BLACK";
x = y = 0;
}
Shape::Shape(double x, double y, std::string color) {
this->color = color;
this->x = x;
this->y = y;
}
// Class: Line
Line::Line(double x1, double y1, double x2, double y2, std::string color):
Shape(x1, y1, color) {
this->dx = x2 - x1;
this->dy = y2 - y1;
}
void Line::draw(GWindow& gw) {
gw.setColor(color);
gw.drawLine(x, y, x + dx, y + dy);
}
// Function: contains
// Usage: if (line.contains(x, y)) { . . . }
// -----------------------------------------
// Returns true if a coordinate is proximate to a line
// (within the pixel proximity specified).
bool Line::contains(double x, double y, double pixelProximity) const {
double dist = distToLine(x, y);
return (abs(dist) <= pixelProximity);
}
// Function: distToLine
// Usage: double dist = distToLine(x, y);
// --------------------------------------
// Returns the distance from a point to a line.
//
// See:
// https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
double Line::distToLine(double x, double y) const {
double dist;
double x1 = this->x;
double y1 = this->y;
double x2 = this->x + dx;
double y2 = this->y + dy;
double n = abs((dy)*x - (dx)*y + x2*y1 - y2*x1);
double d = sqrt(pow(dy, 2) + pow((dx),2));
if (d == 0) error("distToLine: Not a line");
dist = n / d;
return dist;
}
// Class: Rect
Rect::Rect(double x,
double y,
double width,
double height,
std::string color): Shape(x, y, color) {
this->width = width;
this->height = height;
}
void Rect::draw(GWindow& gw) {
gw.setColor(color);
gw.fillRect(x, y, width, height);
}
bool Rect::contains(double x, double y, double pixelProximity) const {
return ((this->x <= x) && (this->x + width >= x) &&
(this->y <= y) && (this->y + height>= y));
}
// Class: Square
Square::Square(double x,
double y,
double size,
std::string color): Rect(x, y, size, size, color) {
// Empty
}
// Class: Oval
Oval::Oval(double x,
double y,
double width,
double height,
std::string color): Shape(x, y, color) {
this->width = width;
this->height = height;
}
void Oval::draw(GWindow& gw) {
gw.setColor(color);
gw.fillOval(x, y, width, height);
}
// Function: contains
// Usage: if (oval.contains(x, y)) { . . . }
// -----------------------------------------
// Returns true if a given coordinate resides within an oval.
//
// See:
// http://math.stackexchange.com/questions/76457/check-if-a-point-is-within-an-ellipse
bool Oval::contains(double x, double y, double pixelProximity) const {
double rx = width/2;
double ry = height/2;
double h = this->x + rx;
double k = this->y + ry;
double e = pow(x-h, 2)/pow(rx,2) + pow(-1*(y-k), 2)/pow(ry,2);
return (e <= 1);
}
// Class: Circle
Circle::Circle(double x,
double y,
double radius,
std::string color):
Oval(x - radius, y - radius, 2*radius, 2*radius, color) {
// Empty
}
| 24.052326 | 91 | 0.542422 | heavy3 |
43931aa375be338e0524abc4fa13199015b946db | 824 | cpp | C++ | framework/shape.cpp | SiMein/programmiersprachen-raytracer | 4de29e334ec77644c886312111293b0218670ee5 | [
"MIT"
] | null | null | null | framework/shape.cpp | SiMein/programmiersprachen-raytracer | 4de29e334ec77644c886312111293b0218670ee5 | [
"MIT"
] | null | null | null | framework/shape.cpp | SiMein/programmiersprachen-raytracer | 4de29e334ec77644c886312111293b0218670ee5 | [
"MIT"
] | null | null | null | #include "shape.hpp"
Shape::Shape(std::string const& name):
name_ {name}{/*std::cout << "I am the Shape-contructor !";*/}
Shape::Shape(std::string const& name, std::shared_ptr<Material> const& ma_co):
name_ {name},
ma_co_ {ma_co}{/* std::cout << "I am the Shape-contructor !";*/} // da ein struct, muss init direkt erfolgen in cpp und hpp !!!!
Shape::~Shape(){
// std::cout << "I am the Shape-Destruktor !";
}
std::ostream& Shape::print(std::ostream& os) const{ // Printausgabe der Attrib von Shape-- weitere print-attrib. siehe Kindklassen
os << "Shape-Name : " << name_ << "\n" << "Shape-Material : " << *ma_co_ << "\n"; // *ma_co_ dereferenz., weil zeiger
return os;
}
std::ostream& operator <<(std::ostream& os,Shape const& s){ // free Operator-Overloading
return s.print(os);
} | 35.826087 | 134 | 0.628641 | SiMein |
4397595081f765251230d29df04592ca413eb7ef | 307 | cpp | C++ | 3rdparty/lzma/CPP/7zip/Compress/LzmaRegister.cpp | WieszKto/IrrlichtBAW | bcef8386c2ca7f06ff006b866c397035551a2351 | [
"Apache-2.0"
] | 216 | 2020-08-27T20:04:48.000Z | 2022-03-28T19:31:41.000Z | 3rdparty/lzma/CPP/7zip/Compress/LzmaRegister.cpp | WieszKto/IrrlichtBAW | bcef8386c2ca7f06ff006b866c397035551a2351 | [
"Apache-2.0"
] | 165 | 2020-09-17T20:12:30.000Z | 2022-03-30T21:32:18.000Z | 3rdparty/lzma/CPP/7zip/Compress/LzmaRegister.cpp | WieszKto/IrrlichtBAW | bcef8386c2ca7f06ff006b866c397035551a2351 | [
"Apache-2.0"
] | 118 | 2018-10-29T08:43:57.000Z | 2022-01-07T06:49:25.000Z | // LzmaRegister.cpp
#include "StdAfx.h"
#include "../Common/RegisterCodec.h"
#include "LzmaDecoder.h"
#ifndef EXTRACT_ONLY
#include "LzmaEncoder.h"
#endif
namespace NCompress {
namespace NLzma {
REGISTER_CODEC_E(LZMA,
CDecoder(),
CEncoder(),
0x30101,
"LZMA")
}}
| 13.347826 | 37 | 0.638436 | WieszKto |
439841d50c3f7fa0f335b76b8cecf53968e37077 | 8,266 | cpp | C++ | bridge/SfxrNode.cpp | xioxin/lab_sound_bridge | ab903af11c128860a492f50fc22b283f6dad5f95 | [
"BSD-2-Clause"
] | 1 | 2021-12-31T06:15:54.000Z | 2021-12-31T06:15:54.000Z | bridge/SfxrNode.cpp | xioxin/lab_sound_bridge | ab903af11c128860a492f50fc22b283f6dad5f95 | [
"BSD-2-Clause"
] | null | null | null | bridge/SfxrNode.cpp | xioxin/lab_sound_bridge | ab903af11c128860a492f50fc22b283f6dad5f95 | [
"BSD-2-Clause"
] | null | null | null | #include "./dart_api/dart_api.h"
#include "LabSound/LabSound.h"
#include "KeepNode.cpp"
#include "struct.h"
using namespace lab;
DART_EXPORT int createSfxrNode(AudioContext* context) {
auto node = std::make_shared<SfxrNode>(*context);
return keepNode(node);
}
// todo AudioSetting: preset waveType
DART_EXPORT int SfxrNode_waveType(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioSetting(nodeId, 1, node->waveType()) : -1;
}
DART_EXPORT int SfxrNode_attackTime(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 1, node->attackTime()) : -1;
}
DART_EXPORT int SfxrNode_sustainTime(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 2, node->sustainTime()) : -1;
}
DART_EXPORT int SfxrNode_sustainPunch(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 3, node->sustainPunch()) : -1;
}
DART_EXPORT int SfxrNode_decayTime(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 4, node->decayTime()) : -1;
}
DART_EXPORT int SfxrNode_startFrequency(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 5, node->startFrequency()) : -1;
}
DART_EXPORT int SfxrNode_minFrequency(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 6, node->minFrequency()) : -1;
}
DART_EXPORT int SfxrNode_slide(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 7, node->slide()) : -1;
}
DART_EXPORT int SfxrNode_deltaSlide(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 8, node->deltaSlide()) : -1;
}
DART_EXPORT int SfxrNode_vibratoDepth(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 9, node->vibratoDepth()) : -1;
}
DART_EXPORT int SfxrNode_vibratoSpeed(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 10, node->vibratoSpeed()) : -1;
}
DART_EXPORT int SfxrNode_changeAmount(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 11, node->changeAmount()) : -1;
}
DART_EXPORT int SfxrNode_changeSpeed(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 12, node->changeSpeed()) : -1;
}
DART_EXPORT int SfxrNode_squareDuty(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 13, node->squareDuty()) : -1;
}
DART_EXPORT int SfxrNode_dutySweep(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 14, node->dutySweep()) : -1;
}
DART_EXPORT int SfxrNode_repeatSpeed(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 15, node->repeatSpeed()) : -1;
}
DART_EXPORT int SfxrNode_phaserOffset(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 16, node->phaserOffset()) : -1;
}
DART_EXPORT int SfxrNode_phaserSweep(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 17, node->phaserSweep()) : -1;
}
DART_EXPORT int SfxrNode_lpFilterCutoff(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 18, node->lpFilterCutoff()) : -1;
}
DART_EXPORT int SfxrNode_lpFilterCutoffSweep(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 19, node->lpFilterCutoffSweep()) : -1;
}
DART_EXPORT int SfxrNode_lpFiterResonance(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 20, node->lpFiterResonance()) : -1;
}
DART_EXPORT int SfxrNode_hpFilterCutoff(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 21, node->hpFilterCutoff()) : -1;
}
DART_EXPORT int SfxrNode_hpFilterCutoffSweep(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? keepAudioParam(nodeId, 22, node->hpFilterCutoffSweep()) : -1;
}
DART_EXPORT void SfxrNode_setStartFrequencyInHz(int nodeId, float value) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node) node->setStartFrequencyInHz(value);
}
DART_EXPORT void SfxrNode_setVibratoSpeedInHz(int nodeId, float value) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node) node->setVibratoSpeedInHz(value);
}
DART_EXPORT float SfxrNode_envelopeTimeInSeconds(int nodeId, float sfxrEnvTime) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? node->envelopeTimeInSeconds(sfxrEnvTime) : 0.0;
}
DART_EXPORT float SfxrNode_envelopeTimeInSfxrUnits(int nodeId, float t) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? node->envelopeTimeInSfxrUnits(t) : 0.0;
}
DART_EXPORT float SfxrNode_frequencyInSfxrUnits(int nodeId, float hz) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? node->frequencyInSfxrUnits(hz) : 0.0;
}
DART_EXPORT float SfxrNode_frequencyInHz(int nodeId, float sfxr) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? node->frequencyInHz(sfxr) : 0.0;
}
DART_EXPORT float SfxrNode_vibratoInSfxrUnits(int nodeId, float hz) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? node->vibratoInSfxrUnits(hz) : 0.0;
}
DART_EXPORT float SfxrNode_vibratoInHz(int nodeId, float sfxr) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? node->vibratoInHz(sfxr) : 0.0;
}
DART_EXPORT float SfxrNode_filterFreqInHz(int nodeId, float sfxr) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? node->filterFreqInHz(sfxr) : 0.0;
}
DART_EXPORT float SfxrNode_filterFreqInSfxrUnits(int nodeId, float hz) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
return node ? node->filterFreqInSfxrUnits(hz) : 0.0;
}
DART_EXPORT void SfxrNode_setDefaultBeep(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->setDefaultBeep();
}
DART_EXPORT void SfxrNode_coin(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->coin();
}
DART_EXPORT void SfxrNode_laser(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->laser();
}
DART_EXPORT void SfxrNode_explosion(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->explosion();
}
DART_EXPORT void SfxrNode_powerUp(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->powerUp();
}
DART_EXPORT void SfxrNode_hit(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->hit();
}
DART_EXPORT void SfxrNode_jump(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->jump();
}
DART_EXPORT void SfxrNode_select(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->select();
}
DART_EXPORT void SfxrNode_mutate(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->mutate();
}
DART_EXPORT void SfxrNode_randomize(int nodeId) {
auto node = std::static_pointer_cast<SfxrNode>(getNode(nodeId));
if(node)node->randomize();
}
| 40.321951 | 81 | 0.736632 | xioxin |
43a193afed69861719ff4301f69e5448a2814214 | 828 | hpp | C++ | lib/inc/facter/facts/linux/block_device_resolver.hpp | ploubser/cfacter | 269717adb4472a66f9763a228498f47771d41343 | [
"Apache-2.0"
] | null | null | null | lib/inc/facter/facts/linux/block_device_resolver.hpp | ploubser/cfacter | 269717adb4472a66f9763a228498f47771d41343 | [
"Apache-2.0"
] | null | null | null | lib/inc/facter/facts/linux/block_device_resolver.hpp | ploubser/cfacter | 269717adb4472a66f9763a228498f47771d41343 | [
"Apache-2.0"
] | null | null | null | /**
* @file
* Declares the Linux block device fact resolver.
*/
#ifndef FACTER_FACTS_LINUX_BLOCK_DEVICE_RESOLVER_HPP_
#define FACTER_FACTS_LINUX_BLOCK_DEVICE_RESOLVER_HPP_
#include "../fact_resolver.hpp"
namespace facter { namespace facts { namespace linux {
/**
* Responsible for resolving block device facts.
*/
struct block_device_resolver : fact_resolver
{
/**
* Constructs the block_device_resolver.
*/
block_device_resolver();
protected:
/**
* Called to resolve all facts the resolver is responsible for.
* @param facts The fact map that is resolving facts.
*/
virtual void resolve_facts(fact_map& facts);
};
}}} // namespace facter::facts::linux
#endif // FACTER_FACTS_LINUX_BLOCK_DEVICE_RESOLVER_HPP_
| 25.090909 | 71 | 0.671498 | ploubser |
43a2221e6154ff22957e877c50472bf6a2f73f61 | 8,478 | cpp | C++ | src/libtsduck/base/types/tsArgMix.cpp | harmonicinc-com/tsduck | 67f25161a3b37b1f3c486d5ef2e013486c3d9893 | [
"BSD-2-Clause"
] | 542 | 2017-06-21T07:40:10.000Z | 2022-03-29T13:44:39.000Z | src/libtsduck/base/types/tsArgMix.cpp | harmonicinc-com/tsduck | 67f25161a3b37b1f3c486d5ef2e013486c3d9893 | [
"BSD-2-Clause"
] | 939 | 2017-09-01T21:00:42.000Z | 2022-03-31T14:39:27.000Z | src/libtsduck/base/types/tsArgMix.cpp | harmonicinc-com/tsduck | 67f25161a3b37b1f3c486d5ef2e013486c3d9893 | [
"BSD-2-Clause"
] | 167 | 2017-10-30T12:07:29.000Z | 2022-03-23T11:36:10.000Z | //----------------------------------------------------------------------------
//
// TSDuck - The MPEG Transport Stream Toolkit
// Copyright (c) 2005-2021, Thierry Lelegard
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
//
//----------------------------------------------------------------------------
#include "tsArgMix.h"
#include "tsUString.h"
const std::string ts::ArgMix::empty;
const ts::UString ts::ArgMix::uempty;
//----------------------------------------------------------------------------
// ArgMix constructors.
//----------------------------------------------------------------------------
ts::ArgMix::ArgMix() :
_type(0),
_size(0),
_value(int32_t(0)),
_aux(nullptr)
{
}
ts::ArgMix::ArgMix(const ts::ArgMix& other) :
_type(other._type),
_size(other._size),
_value(other._value),
_aux(other._aux == nullptr ? nullptr : new UString(*other._aux))
{
}
ts::ArgMix::ArgMix(ts::ArgMix&& other) :
_type(other._type),
_size(other._size),
_value(other._value),
_aux(other._aux)
{
other._aux = nullptr;
}
ts::ArgMix::ArgMix(TypeFlags type, size_t size, const Value value) :
_type(type),
_size(uint8_t(size)),
_value(value),
_aux(nullptr)
{
}
//----------------------------------------------------------------------------
// Destructor.
//----------------------------------------------------------------------------
ts::ArgMix::~ArgMix()
{
// Deallocate auxiliary string, when there is one.
if (_aux != nullptr) {
delete _aux;
_aux = nullptr;
}
}
//----------------------------------------------------------------------------
// Return ArgMix value as a string.
//----------------------------------------------------------------------------
const char* ts::ArgMix::toCharPtr() const
{
switch (_type) {
case STRING | BIT8: {
// A pointer to char.
return _value.charptr == nullptr ? "" : _value.charptr;
}
case STRING | BIT8 | CLASS: {
// A pointer to std::string.
return _value.string == nullptr ? "" : _value.string->c_str();
}
default: {
return "";
}
}
}
const ts::UChar* ts::ArgMix::toUCharPtr() const
{
switch (_type) {
case STRING | BIT16: {
// A pointer to UChar.
return _value.ucharptr == nullptr ? u"" : _value.ucharptr;
}
case STRING | BIT16 | CLASS: {
// A pointer to UString.
return _value.ustring == nullptr ? u"" : _value.ustring->c_str();
}
case STRING | BIT8: {
// A pointer to char. Need to allocate an auxiliary string.
if (_value.charptr != nullptr && _aux == nullptr) {
_aux = new UString;
_aux->assignFromUTF8(_value.charptr);
}
return _aux == nullptr ? u"" : _aux->c_str();
}
case STRING | BIT8 | CLASS: {
// A pointer to std::string. Need to allocate an auxiliary string.
if (_value.string != nullptr && _aux == nullptr) {
_aux = new UString;
_aux->assignFromUTF8(*_value.string);
}
return _aux == nullptr ? u"" : _aux->c_str();
}
case STRING | BIT16 | CLASS | STRINGIFY: {
// A pointer to StringifyInterface. Need to allocate an auxiliary string.
if (_value.stringify != nullptr && _aux == nullptr) {
_aux = new UString(_value.stringify->toString());
}
return _aux == nullptr ? u"" : _aux->c_str();
}
case ANUMBER: {
// A pointer to AbstractNumer. Need to allocate an auxiliary string.
if (_value.anumber != nullptr && _aux == nullptr) {
_aux = new UString(_value.anumber->toString());
}
return _aux == nullptr ? u"" : _aux->c_str();
}
default: {
return u"";
}
}
}
const std::string& ts::ArgMix::toString() const
{
if (_type == (STRING | BIT8 | CLASS)) {
return _value.string != nullptr ? *_value.string : empty;
}
else {
return empty;
}
}
const ts::UString& ts::ArgMix::toUString() const
{
switch (_type) {
case STRING | BIT8: {
// A pointer to char. Need to allocate an auxiliary string.
if (_value.charptr != nullptr && _aux == nullptr) {
_aux = new UString;
_aux->assignFromUTF8(_value.charptr);
}
return _aux == nullptr ? uempty : *_aux;
}
case STRING | BIT8 | CLASS: {
// A pointer to std::string. Need to allocate an auxiliary string.
if (_value.string != nullptr && _aux == nullptr) {
_aux = new UString;
_aux->assignFromUTF8(*_value.string);
}
return _aux == nullptr ? uempty : *_aux;
}
case STRING | BIT16: {
// A pointer to UChar. Need to allocate an auxiliary string.
if (_value.charptr != nullptr && _aux == nullptr) {
_aux = new UString(_value.ucharptr);
}
return _aux == nullptr ? uempty : *_aux;
}
case STRING | BIT16 | CLASS: {
// A pointer to UString.
return _value.ustring == nullptr ? uempty : *_value.ustring;
}
case STRING | BIT16 | CLASS | STRINGIFY: {
// A pointer to StringifyInterface. Need to allocate an auxiliary string.
if (_value.stringify != nullptr && _aux == nullptr) {
_aux = new UString(_value.stringify->toString());
}
return _aux == nullptr ? uempty : *_aux;
}
case ANUMBER: {
// A pointer to AbstractNumer. Need to allocate an auxiliary string.
if (_value.anumber != nullptr && _aux == nullptr) {
_aux = new UString(_value.anumber->toString());
}
return _aux == nullptr ? uempty : *_aux;
}
default: {
return uempty;
}
}
}
//----------------------------------------------------------------------------
// Return ArgMix value as a double.
//----------------------------------------------------------------------------
double ts::ArgMix::toDouble() const
{
if ((_type & DOUBLE) == DOUBLE) {
return _value.dbl;
}
else if ((_type & ANUMBER) == ANUMBER) {
return _value.anumber->toDouble();
}
else if (isSigned()) {
return double(toInt64());
}
else if (isUnsigned()) {
return double(toUInt64());
}
else {
return 0.0;
}
}
//----------------------------------------------------------------------------
// Return ArgMix value as an AbstractNumber.
//----------------------------------------------------------------------------
const ts::AbstractNumber& ts::ArgMix::toAbstractNumber() const
{
switch (_type) {
case ANUMBER: {
return _value.anumber != nullptr ? *_value.anumber : *AbstractNumber::INVALID;
}
default: {
return *AbstractNumber::INVALID;
}
}
}
| 32.988327 | 90 | 0.5092 | harmonicinc-com |
43a2f4d0862e1d20b8c57b0b8c52c5f7a88c92f8 | 10,525 | cpp | C++ | src/bin2llvmir/optimizations/idioms/idioms_analysis.cpp | Andrik-555/retdec | 1ac63a520da02912daf836b924f41d95b1b5fa10 | [
"MIT",
"BSD-3-Clause"
] | 521 | 2019-03-29T15:44:08.000Z | 2022-03-22T09:46:19.000Z | src/bin2llvmir/optimizations/idioms/idioms_analysis.cpp | Andrik-555/retdec | 1ac63a520da02912daf836b924f41d95b1b5fa10 | [
"MIT",
"BSD-3-Clause"
] | 30 | 2019-06-04T17:00:49.000Z | 2021-09-08T20:44:19.000Z | src/bin2llvmir/optimizations/idioms/idioms_analysis.cpp | Andrik-555/retdec | 1ac63a520da02912daf836b924f41d95b1b5fa10 | [
"MIT",
"BSD-3-Clause"
] | 99 | 2019-03-29T16:04:13.000Z | 2022-03-28T16:59:34.000Z | /**
* @file src/bin2llvmir/optimizations/idioms/idioms_analysis.cpp
* @brief Instruction idioms analysis
* @copyright (c) 2017 Avast Software, licensed under the MIT license
*/
#include "retdec/bin2llvmir/optimizations/idioms/idioms_analysis.h"
using namespace llvm;
namespace retdec {
namespace bin2llvmir {
/*
* Stats of exchanged idioms.
*/
STATISTIC(NumIdioms, "Number of idioms exchanged in total");
/**
* Analyse given BasicBlock and use instruction exchanger to transform
* instruction idioms
*
* @param bb BasicBlock to analyse
* @param exchanger instruction idiom exchanger
* @param fname instruction idiom exchanger name (for debug purpose only)
*/
bool IdiomsAnalysis::analyse(llvm::BasicBlock & bb, llvm::Instruction * (IdiomsAnalysis::*exchanger)(llvm::BasicBlock::iterator) const, const char * fname) {
bool change_made = false;
for (BasicBlock::iterator iter = bb.begin(), end = bb.end(); iter != end; /**/) {
BasicBlock::iterator insn = iter;
++iter; // go to next instruction to use valid iterator in next loop
// call exchanger on every instruction
Instruction * res = (this->*exchanger)(insn);
if (res) {
++NumIdioms;
change_made = true;
(*insn).replaceAllUsesWith(res);
print_dbg(fname, *insn);
// Move the name to the new instruction first.
res->takeName(&*insn);
// Insert the new instruction into the basic block...
BasicBlock * InstParent = (*insn).getParent();
// If we replace a PHI with something that isn't a PHI,
// fix up the insertion point.
if (! isa<PHINode>(res) && isa<PHINode>(insn))
insn = InstParent->getFirstInsertionPt();
InstParent->getInstList().insert(insn, res);
(*insn).eraseFromParent();
}
}
return change_made;
}
/**
* Do instruction idioms analysis pass
*
* @param f Function to analyse for instruction idioms
* @param p actual pass
* @return true whenever an exchange has been made, otherwise 0
*/
bool IdiomsAnalysis::doAnalysis(Function & f, Pass * p) {
/*
* Instruction idioms are inspected in a tree of Instructions. Every
* instruction idiom has to be called on a basic block. Position of
* instruction idiom exchangers is IMPORTANT! More complicated instruction
* idioms have to be exchanged before simplier ones. They can consist of
* other instruction idioms (the simple ones), so they have to be exchanged
* at first place!
*/
bool change_made = false; // was there any exchange?
CC_compiler cc = getCompiler();
CC_arch arch = getArch();
// Inspect multi-basic block idioms
if (cc == CC_GCC || cc == CC_ANY) {
change_made |= analyse(f, p, &IdiomsGCC::exchangeCondBitShiftDivMultiBB,
"IdiomsGCC::exchangeCondBitShiftDivMultiBB");
}
// Inspect basic-block idioms
for (Function::iterator b = f.begin(); b != f.end(); ++b) {
BasicBlock & bb = *b;
if (arch == ARCH_POWERPC || arch == ARCH_ARM || arch == ARCH_x86 || arch == ARCH_THUMB || arch == ARCH_ANY)
if (cc == CC_GCC || cc == CC_Intel || cc == CC_VStudio || cc == CC_ANY) {
change_made |= analyse(bb, &IdiomsMagicDivMod::signedMod1,
"IdiomsMagicDivMod::signedMod1");
change_made |= analyse(bb, &IdiomsMagicDivMod::signedMod2,
"IdiomsMagicDivMod::signedMod2");
change_made |= analyse(bb, &IdiomsMagicDivMod::magicUnsignedDiv2,
"IdiomsMagicDivMod::magicUnsignedDiv2");
change_made |= analyse(bb, &IdiomsMagicDivMod::magicUnsignedDiv1,
"IdiomsMagicDivMod::magicUnsignedDiv1");
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv1,
"IdiomsMagicDivMod::magicSignedDiv1");
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv2,
"IdiomsMagicDivMod::magicSignedDiv2");
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv3,
"IdiomsMagicDivMod::magicSignedDiv3");
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv4,
"IdiomsMagicDivMod::magicSignedDiv4");
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv5,
"IdiomsMagicDivMod::magicSignedDiv5");
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv6,
"IdiomsMagicDivMod::magicSignedDiv6");
// Found in PowerPC - div 10
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv7pos,
"IdiomsMagicDivMod::magicSignedDiv7pos");
// Found in PowerPC - the same as previous, but the divisor
// is negative, i.e. div -10
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv7neg,
"IdiomsMagicDivMod::magicSignedDiv7neg");
// Found in PowerPC - div 6
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv8pos,
"IdiomsMagicDivMod::magicSignedDiv8pos");
// Found in PowerPC - the same as previous, but the divisor
// is negative, i.e. div -3
change_made |= analyse(bb, &IdiomsMagicDivMod::magicSignedDiv8neg,
"IdiomsMagicDivMod::magicSignedDiv8neg");
change_made |= analyse(bb, &IdiomsMagicDivMod::unsignedMod,
"IdiomsMagicDivMod::unsignedMod");
}
// all arch
if (cc == CC_GCC || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsGCC::exchangeSignedModuloByTwo,
"IdiomsGCC::exchangeSignedModuloByTwo");
// PowerPC model lacks FPU and x86 uses x87.
if (arch == ARCH_ARM || arch == ARCH_THUMB || arch == ARCH_MIPS || arch == ARCH_ANY)
if (cc == CC_GCC || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsGCC::exchangeCopysign,
"IdiomsGCC::exchangeCopysign");
// PowerPC model lacks FPU and x86 uses x87.
if (arch == ARCH_ARM || arch == ARCH_THUMB || arch == ARCH_MIPS || arch == ARCH_ANY)
if (cc == CC_GCC || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsGCC::exchangeFloatAbs,
"IdiomsGCC::exchangeFloatAbs");
if (arch == ARCH_x86 || arch == ARCH_ANY)
if (cc == CC_Intel || cc == CC_VStudio || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsVStudio::exchangeOrMinusOneAssign,
"IdiomsVStudio::exchangeOrMinusOneAssign");
if (arch == ARCH_x86 || arch == ARCH_ANY)
if (cc == CC_Intel || cc == CC_VStudio || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsVStudio::exchangeAndZeroAssign,
"IdiomsVStudio::exchangeAndZeroAssign");
// all arch
if (cc == CC_GCC || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsGCC::exchangeCondBitShiftDiv1,
"IdiomsGCC::exchangeCondBitShiftDiv1");
// all arch
if (cc == CC_GCC || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsGCC::exchangeCondBitShiftDiv2,
"IdiomsGCC::exchangeCondBitShiftDiv2");
// all arch
if (cc == CC_GCC || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsGCC::exchangeCondBitShiftDiv3,
"IdiomsGCC::exchangeCondBitShiftDiv3");
// all arch
if (cc == CC_GCC || cc == CC_Intel || cc == CC_LLVM || cc == CC_VStudio || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsCommon::exchangeSignedModulo2n,
"IdiomsCommon::exchangeSignedModulo2n");
// all arch
if (cc == CC_GCC || cc == CC_Intel || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsCommon::exchangeGreaterEqualZero,
"IdiomsCommon::exchangeGreaterEqualZero");
// all arch
if (cc == CC_GCC || cc == CC_LLVM || cc == CC_VStudio || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsGCC::exchangeXorMinusOne,
"IdiomsGCC::exchangeXorMinusOne");
if (arch == ARCH_POWERPC || arch == ARCH_ARM || arch == ARCH_THUMB || arch == ARCH_MIPS || arch == ARCH_ANY)
if (cc == CC_GCC || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsCommon::exchangeDivByMinusTwo,
"IdiomsCommon::exchangeDivByMinusTwo");
// all arch
if (cc == CC_GCC || cc == CC_Intel || cc == CC_LLVM || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsCommon::exchangeLessThanZero,
"IdiomsCommon::exchangeLessThanZero");
// PowerPC model lacks FPU and x86 uses x87.
if (cc == CC_GCC || cc == CC_ANY)
if (arch == ARCH_ARM || arch == ARCH_THUMB || arch == ARCH_MIPS || arch == ARCH_ANY)
change_made |= analyse(bb, &IdiomsGCC::exchangeFloatNeg,
"IdiomsGCC::exchangeFloatNeg");
// all arch
if (cc == CC_GCC || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsCommon::exchangeUnsignedModulo2n,
"IdiomsCommon::exchangeUnsignedModulo2n");
// all arch
if (cc == CC_LLVM || cc == CC_ANY)
change_made |= analyse(bb, &IdiomsLLVM::exchangeIsGreaterThanMinusOne,
"IdiomsLLVM::exchangeIsGreaterThanMinusOne");
// all arch
// all compilers
change_made |= analyse(bb, &IdiomsCommon::exchangeBitShiftSDiv1,
"IdiomsCommon::exchangeBitShiftSDiv1");
// all arch
// all compilers
change_made |= analyse(bb, &IdiomsCommon::exchangeBitShiftSDiv2,
"IdiomsCommon::exchangeBitShiftSDiv2");
// all arch
// all compilers
change_made |= analyse(bb, &IdiomsCommon::exchangeBitShiftUDiv,
"IdiomsCommon::exchangeBitShiftUDiv");
// all arch
// all compilers
change_made |= analyse(bb, &IdiomsCommon::exchangeBitShiftMul,
"IdiomsCommon::exchangeBitShiftMul");
// all arch
if (cc == CC_LLVM || cc == CC_ANY) {
change_made |= analyse(bb, &IdiomsLLVM::exchangeIsGreaterThanMinusOne,
"IdiomsLLVM::exchangeIsGreaterThanMinusOne");
}
// all arch
if (cc == CC_LLVM || cc == CC_ANY) {
change_made |= analyse(bb, &IdiomsLLVM::exchangeCompareEq,
"IdiomsLLVM::exchangeCompareEq");
#if 0
/* We do not recognize this well */
change_made |= analyse(bb, &IdiomsLLVM::exchangeCompareNeq,
"IdiomsLLVM::exchangeCompareNeq");
#endif
change_made |= analyse(bb, &IdiomsLLVM::exchangeCompareSlt,
"IdiomsLLVM::exchangeCompareSlt");
change_made |= analyse(bb, &IdiomsLLVM::exchangeCompareSle,
"IdiomsLLVM::exchangeCompareSle");
}
}
return change_made;
}
/**
* Analyse given Function and use instruction exchanger to transform
* instruction idioms
*
* @param f function to visit
* @param p actual pass
* @param exchanger instruction idiom exchanger
* @param fname instruction idiom exchanger name (for debug purpose only)
* @return true whenever an exchange has been made, otherwise 0
*/
bool IdiomsAnalysis::analyse(llvm::Function & f, llvm::Pass * p, int (IdiomsAnalysis::*exchanger)(llvm::Function &, llvm::Pass *) const, const char * fname) {
int num_idioms = 0;
num_idioms += IdiomsGCC::exchangeCondBitShiftDivMultiBB(f, p);
NumIdioms += num_idioms;
return num_idioms == 0;
}
} // namespace bin2llvmir
} // namespace retdec
| 34.850993 | 158 | 0.679525 | Andrik-555 |
43a92d4d30027ae174df7187ff30f24a055fa52a | 851 | cpp | C++ | Software Eng (1)/Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/gucf_Generic2.lump.cpp | HealthSouthern48/Unity-project | ad1956e23f55910dd6f51710d11413ecbf5b7b6d | [
"MIT"
] | null | null | null | Software Eng (1)/Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/gucf_Generic2.lump.cpp | HealthSouthern48/Unity-project | ad1956e23f55910dd6f51710d11413ecbf5b7b6d | [
"MIT"
] | null | null | null | Software Eng (1)/Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/gucf_Generic2.lump.cpp | HealthSouthern48/Unity-project | ad1956e23f55910dd6f51710d11413ecbf5b7b6d | [
"MIT"
] | null | null | null | //Generated lump file. generated by Bee.NativeProgramSupport.Lumping
#include "C:/Users/19022/Downloads/Unity/Editor/Data/il2cpp/libil2cpp/os/Generic/COM.cpp"
#include "C:/Users/19022/Downloads/Unity/Editor/Data/il2cpp/libil2cpp/os/Generic/CrashHelpers.cpp"
#include "C:/Users/19022/Downloads/Unity/Editor/Data/il2cpp/libil2cpp/os/Generic/Environment.cpp"
#include "C:/Users/19022/Downloads/Unity/Editor/Data/il2cpp/libil2cpp/os/Generic/File.cpp"
#include "C:/Users/19022/Downloads/Unity/Editor/Data/il2cpp/libil2cpp/os/Generic/MarshalStringAlloc.cpp"
#include "C:/Users/19022/Downloads/Unity/Editor/Data/il2cpp/libil2cpp/os/Generic/Process.cpp"
#include "C:/Users/19022/Downloads/Unity/Editor/Data/il2cpp/libil2cpp/os/Generic/SocketBridge.cpp"
#include "C:/Users/19022/Downloads/Unity/Editor/Data/il2cpp/libil2cpp/os/Generic/SocketImpl.cpp"
| 85.1 | 105 | 0.807286 | HealthSouthern48 |
43acd8bd0376964d59d14d4a656d09da71b239bc | 99,969 | cpp | C++ | src/QtAV/Videos/nVideosDispatcher.cpp | Vladimir-Lin/QtAV | a50400a216fdb493bdf353d8af894bcfca985685 | [
"MIT"
] | null | null | null | src/QtAV/Videos/nVideosDispatcher.cpp | Vladimir-Lin/QtAV | a50400a216fdb493bdf353d8af894bcfca985685 | [
"MIT"
] | null | null | null | src/QtAV/Videos/nVideosDispatcher.cpp | Vladimir-Lin/QtAV | a50400a216fdb493bdf353d8af894bcfca985685 | [
"MIT"
] | null | null | null | #include <qtav.h>
typedef struct {
N::Plan * plan ;
QWidget * widget ;
} ExtraPacket ;
N::VideosDispatcher:: VideosDispatcher ( QObject * parent )
: QObject ( parent )
, SyntaxDispatcher ( )
, UuidSyntax ( )
, plan ( NULL )
{
nConnect ( this , SIGNAL ( EmitListClips ( ) ) ,
this , SLOT ( SendListClips ( ) ) ) ;
nConnect ( this , SIGNAL ( EmitClipsGroup ( ) ) ,
this , SLOT ( SendClipsGroup ( ) ) ) ;
nConnect ( this , SIGNAL ( EmitClips ( ) ) ,
this , SLOT ( SendClips ( ) ) ) ;
nConnect ( this , SIGNAL ( EmitVideos ( ) ) ,
this , SLOT ( SendVideos ( ) ) ) ;
nConnect ( this , SIGNAL ( EmitEditings ( ) ) ,
this , SLOT ( SendEditings ( ) ) ) ;
}
N::VideosDispatcher::~VideosDispatcher (void)
{
}
int N::VideosDispatcher::type(void) const
{
return CiosMenuId ( 79 , 0 , 1 ) ;
}
void N::VideosDispatcher::Help(QStringList & help)
{
help << tr("===== Videos dispatcher commands =====") ;
help << QString("set video variable name value : %1").arg(tr("set variable into name")) ;
help << QString("show video variables : %1").arg(tr("show variables")) ;
help << QString("list clips (N): %1").arg(tr("open up clip list")) ;
help << QString("search clips by name ... syntax ... : %1").arg(tr("search clips")) ;
help << QString("search clips by files ... items ... : %1").arg(tr("search clips")) ;
help << QString("search clips by id ... items ... : %1").arg(tr("search clips")) ;
help << QString("search clips in list by name ... syntax ... : %1").arg(tr("search clips and open in list")) ;
help << QString("search albums by id ... items ... : %1").arg(tr("search album by identifiers exactly")) ;
help << QString("search albums by identifiers ... syntax ... : %1").arg(tr("search album by identifiers with bracket syntax")) ;
help << QString("search albums by name ... syntax ... : %1").arg(tr("search album with bracket syntax")) ;
help << QString("search albums by tags ... syntax ... : %1").arg(tr("search album by tags")) ;
help << QString("search albums by uuid ... items ... : %1").arg(tr("search albums in uuid format")) ;
help << QString("search albums by files ... items ... : %1").arg(tr("search albums by file size")) ;
help << QString("search albums by pictures ... items ... : %1").arg(tr("search albums by picture files")) ;
help << QString("edit albums by id ... items ... : %1").arg(tr("edit album by identifiers exactly")) ;
help << QString("catalog albums identical ( with/without progress ) : %1").arg(tr("catalog identical albums into files")) ;
help << QString("catalog albums by organizations : %1").arg(tr("catalog albums depend on its organization")) ;
help << QString("catalog albums by products : %1").arg(tr("catalog albums depend on its product identifiers")) ;
help << QString("catalog albums by orders : %1").arg(tr("catalog albums depend on its video clips")) ;
help << QString("catalog albums by commodity : %1").arg(tr("catalog albums depend on its commodity")) ;
}
int N::VideosDispatcher::matching(QString cmd)
{
QStringList C = CommandTokens ( cmd ) ;
////////////////////////////////////////////////////////////////////////////
command = cmd ;
arguments . clear ( ) ;
arguments <= C ;
////////////////////////////////////////////////////////////////////////////
if ( ( C . count ( ) == 3 ) && ( "list" == C [ 0 ] . toLower ( ) ) ) {
if ( "clips" == C [ 1 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 1 , 1 ) ;
} ;
} ;
////////////////////////////////////////////////////////////////////////////
if ( ( C . count ( ) > 4 ) && ( "search" == C [ 0 ] . toLower ( ) ) ) {
if ( "clips" == C [ 1 ] . toLower ( ) ) {
////////////////////////////////////////////////////////////////////////
if ( "by" == C [ 2 ] . toLower ( ) ) {
if ( "name" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 1 , 2 ) ;
} ;
if ( "files" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 1 , 3 ) ;
} ;
if ( "id" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 1 , 4 ) ;
} ;
} ;
////////////////////////////////////////////////////////////////////////
if ( ( C . count ( ) > 6 ) ) {
if ( "in" == C [ 2 ] . toLower ( ) ) {
if ( "list" == C [ 3 ] . toLower ( ) ) {
if ( "by" == C [ 4 ] . toLower ( ) ) {
if ( "name" == C [ 5 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 1 , 5 ) ;
} ;
} ;
} ;
} ;
} ;
} ;
} ;
////////////////////////////////////////////////////////////////////////////
if ( ( C . count ( ) > 4 ) && ( "search" == C [ 0 ] . toLower ( ) ) ) {
if ( "albums" == C [ 1 ] . toLower ( ) ) {
if ( "by" == C [ 2 ] . toLower ( ) ) {
if ( "id" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 3 , 1 ) ;
} ;
//////////////////////////////////////////////////////////////////////
if ( "identifiers" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 3 , 2 ) ;
} ;
//////////////////////////////////////////////////////////////////////
if ( "name" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 3 , 3 ) ;
} ;
//////////////////////////////////////////////////////////////////////
if ( "uuid" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 3 , 4 ) ;
} ;
//////////////////////////////////////////////////////////////////////
if ( "files" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 3 , 5 ) ;
} ;
//////////////////////////////////////////////////////////////////////
if ( "pictures" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 3 , 6 ) ;
} ;
//////////////////////////////////////////////////////////////////////
if ( "tags" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 3 , 7 ) ;
} ;
} ;
} ;
} ;
////////////////////////////////////////////////////////////////////////////
if ( ( C . count ( ) > 1 ) && "catalog" == C [ 0 ] . toLower ( ) ) {
if ( "albums" == C [ 1 ] . toLower ( ) ) {
if ( ( C . count ( ) > 2 ) && "identical" == C [ 2 ] . toLower ( ) ) {
bool c = true ;
if ( ! Variables . contains ( "OutputList" ) ) {
Report ( tr("You need to set up variable OutputList") ) ;
Report ( "\n" ) ;
c = false ;
} ;
if ( ! Variables . contains ( "OutputUuid" ) ) {
Report ( tr("You need to set up variable OutputUuid") ) ;
Report ( "\n" ) ;
c = false ;
} ;
if ( ! c ) return 0 ;
return CiosMenuId ( 79 , 4 , 1 ) ;
} ;
if ( ( C . count ( ) > 3 ) && "by" == C [ 2 ] . toLower ( ) ) {
if ( "organizations" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 4 , 2 ) ;
} ;
if ( "products" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 4 , 3 ) ;
} ;
if ( "orders" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 4 , 4 ) ;
} ;
if ( "commodity" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 4 , 5 ) ;
} ;
} ;
} ;
} ;
////////////////////////////////////////////////////////////////////////////
if ( ( C . count ( ) > 4 ) && ( "edit" == C [ 0 ] . toLower ( ) ) ) {
if ( "albums" == C [ 1 ] . toLower ( ) ) {
if ( "by" == C [ 2 ] . toLower ( ) ) {
if ( "id" == C [ 3 ] . toLower ( ) ) {
return CiosMenuId ( 79 , 5 , 1 ) ;
} ;
} ;
} ;
} ;
////////////////////////////////////////////////////////////////////////////
if ( ( C . count ( ) == 5 ) && ( "set" == C [ 0 ] . toLower ( ) ) ) {
if ( "video" == C [ 1 ] . toLower ( ) ) {
if ( ( "variable" == C [ 2 ] . toLower ( ) ) ) {
return CiosMenuId ( 79 , 2 , 1 ) ;
} ;
} ;
} ;
////////////////////////////////////////////////////////////////////////////
if ( ( C . count ( ) == 3 ) && ( "show" == C [ 0 ] . toLower ( ) ) ) {
if ( "video" == C [ 1 ] . toLower ( ) ) {
if ( ( "variables" == C [ 2 ] . toLower ( ) ) ) {
return CiosMenuId ( 79 , 2 , 2 ) ;
} ;
} ;
} ;
////////////////////////////////////////////////////////////////////////////
return 0 ;
}
bool N::VideosDispatcher::execute(int id)
{
switch ( id ) {
case CiosMenuId ( 79 , 1 , 1 ) :
ListClips ( ) ;
return true ;
case CiosMenuId ( 79 , 1 , 2 ) :
SearchClips ( ) ;
return true ;
case CiosMenuId ( 79 , 1 , 3 ) :
SearchFiles ( ) ;
return true ;
case CiosMenuId ( 79 , 1 , 4 ) :
ClipsId ( ) ;
return true ;
case CiosMenuId ( 79 , 1 , 5 ) :
SearchClip ( ) ;
return true ;
case CiosMenuId ( 79 , 2 , 1 ) :
setVariable ( ) ;
return true ;
case CiosMenuId ( 79 , 2 , 2 ) :
showVariables ( ) ;
return true ;
case CiosMenuId ( 79 , 3 , 1 ) :
SearchId ( ) ;
return true ;
case CiosMenuId ( 79 , 3 , 2 ) :
SearchIdentifiers ( ) ;
return true ;
case CiosMenuId ( 79 , 3 , 3 ) :
SearchAlbums ( ) ;
return true ;
case CiosMenuId ( 79 , 3 , 4 ) :
SearchUUIDs ( ) ;
return true ;
case CiosMenuId ( 79 , 3 , 5 ) :
AlbumFiles ( ) ;
return true ;
case CiosMenuId ( 79 , 3 , 6 ) :
AlbumPictures ( ) ;
return true ;
case CiosMenuId ( 79 , 3 , 7 ) :
SearchTags ( ) ;
return true ;
case CiosMenuId ( 79 , 4 , 1 ) :
MatchIdenticals ( ) ;
return true ;
case CiosMenuId ( 79 , 4 , 2 ) :
CatalogAlbums ( ) ;
return true ;
case CiosMenuId ( 79 , 4 , 3 ) :
CatalogProducts ( ) ;
return true ;
case CiosMenuId ( 79 , 4 , 4 ) :
CatalogOrders ( ) ;
return true ;
case CiosMenuId ( 79 , 4 , 5 ) :
CatalogCommodity ( ) ;
return true ;
case CiosMenuId ( 79 , 5 , 1 ) :
EditId ( ) ;
return true ;
} ;
return false ;
}
void N::VideosDispatcher::setExtras(void * data)
{
ExtraPacket * ep = (ExtraPacket *) data ;
QWidget * ww = ep -> widget ;
plan = ep -> plan ;
nConnect ( this , SIGNAL ( ListClips (int) ) ,
ww , SLOT ( ListClips (int) ) ) ;
nConnect ( this , SIGNAL ( ListClips (QString,UUIDs&) ) ,
ww , SLOT ( ListClips (QString,UUIDs&) ) ) ;
nConnect ( this , SIGNAL ( ListClip (QString,UUIDs&) ) ,
ww , SLOT ( ListClip (QString,UUIDs&) ) ) ;
nConnect ( this , SIGNAL ( ListVideo (QString,UUIDs&) ) ,
ww , SLOT ( ListVideo (QString,UUIDs&) ) ) ;
nConnect ( this , SIGNAL ( AlbumDetails(SUID,QString) ) ,
ww , SLOT ( AlbumDetails(SUID,QString) ) ) ;
Variables [ "Language" ] = plan -> LanguageId ;
}
bool N::VideosDispatcher::FilterType(SqlConnection & SC,int Type,UUIDs & U,UUIDs & P)
{
return UuidSyntax::FilterType ( SC , PlanTable(MajorUuid) , Type , U , P ) ;
}
bool N::VideosDispatcher::NamesOwners(SqlConnection & SC,UUIDs & U,UUIDs & P)
{
return UuidSyntax::NamesOwners ( SC , PlanTable(NameMaps) , U , P ) ;
}
void N::VideosDispatcher::setVariable(void)
{
if ( arguments . count ( ) != 5 ) return ;
QString n = arguments [ 3 ] . toString ( ) ;
QString v = arguments [ 4 ] . toString ( ) ;
Variables [ n ] = arguments [ 4 ] ;
Report ( QString("%1 => %2\n").arg(n).arg(v) ) ;
}
void N::VideosDispatcher::showVariables(void)
{
QStringList K = Variables . keys ( ) ;
QString k ;
QString v ;
foreach ( k , K ) {
v = Variables [ k ] . toString ( ) ;
Report ( QString("%1 => %2\n").arg(k).arg(v) ) ;
} ;
}
void N::VideosDispatcher::SendListClips(void)
{
while ( Clips . count ( ) > 0 ) {
int c = Clips . first ( ) ;
Clips . takeFirst ( ) ;
emit ListClips ( c ) ;
} ;
}
void N::VideosDispatcher::SendClipsGroup(void)
{
while ( ClipsPaddings . count ( ) > 0 ) {
QString p = ClipsPaddings . first ( ) ;
UUIDs U = ClipsQueues [ p ] ;
ClipsPaddings . takeFirst ( ) ;
ClipsQueues . remove ( p ) ;
emit ListClips ( p , U ) ;
} ;
}
void N::VideosDispatcher::SendClips(void)
{
while ( ClipPaddings . count ( ) > 0 ) {
QString p = ClipPaddings . first ( ) ;
UUIDs U = ClipQueues [ p ] ;
ClipPaddings . takeFirst ( ) ;
ClipQueues . remove ( p ) ;
emit ListClip ( p , U ) ;
} ;
}
void N::VideosDispatcher::SendVideos(void)
{
while ( VideoPaddings . count ( ) > 0 ) {
QString p = VideoPaddings . first ( ) ;
UUIDs U = VideoQueues [ p ] ;
VideoPaddings . takeFirst ( ) ;
VideoQueues . remove ( p ) ;
emit ListVideo ( p , U ) ;
} ;
}
void N::VideosDispatcher::SendEditings(void)
{
while ( EditPaddings . count ( ) > 0 ) {
QString p = EditPaddings . first ( ) ;
UUIDs U = EditQueues [ p ] ;
SUID u ;
EditPaddings . takeFirst ( ) ;
EditQueues . remove ( p ) ;
foreach ( u , U ) {
emit AlbumDetails ( u , p ) ;
} ;
} ;
}
void N::VideosDispatcher::ListClips(void)
{
if ( arguments . count ( ) != 3 ) return ;
int c = arguments [ 2 ] . toInt ( ) ;
Clips << c ;
emit EmitListClips ( ) ;
}
bool N::VideosDispatcher::ExactId(SqlConnection & SC,UUIDs & U,QString K)
{
FinanceManager FM ( plan ) ;
SUID u = FM . FindIdentifier ( SC , K ) ;
if ( u > 0 ) {
if ( ! U . contains ( u ) ) U << u ;
} else {
Report ( tr("Found nothing for `%1`").arg(K) ) ;
Report ( "\n" ) ;
} ;
return ( U . count ( ) > 0 ) ;
}
bool N::VideosDispatcher::LikeId(SqlConnection & SC,UUIDs & U,QString K)
{
QString W ;
QString Q ;
SUID u ;
///////////////////////////////////////////////////////////////////
W = QString("where `name` like '%1' order by `id` asc").arg(K) ;
Q = SC . sql . SelectFrom ( "uuid" , PlanTable(Identifiers) , W ) ;
SqlLoopNow ( SC , Q ) ;
u = SC . Uuid ( 0 ) ;
if ( u > 0 ) {
if ( ! U.contains ( u ) ) U << u ;
} else {
Report ( tr("Found nothing for `%1`").arg(K) ) ;
Report ( "\n" ) ;
} ;
SqlLoopErr ( SC , Q ) ;
Report ( tr("Found nothing for `%1`").arg(K) ) ;
Report ( "\n" ) ;
SqlLoopEnd ( SC , Q ) ;
///////////////////////////////////////////////////////////////////
return ( U . count ( ) > 0 ) ;
}
bool N::VideosDispatcher::RegexpId(SqlConnection & SC,UUIDs & U,QString K)
{
QString W ;
QString Q ;
SUID u ;
///////////////////////////////////////////////////////////////////
W = QString("where `name` regexp '%1' order by `id` asc").arg(K) ;
Q = SC . sql . SelectFrom ( "uuid" , PlanTable(Identifiers) , W ) ;
SqlLoopNow ( SC , Q ) ;
u = SC . Uuid ( 0 ) ;
if ( u > 0 ) {
if ( ! U.contains ( u ) ) U << u ;
} else {
Report ( tr("Found nothing for `%1`").arg(K) ) ;
Report ( "\n" ) ;
} ;
SqlLoopErr ( SC , Q ) ;
Report ( tr("Found nothing for `%1`").arg(K) ) ;
Report ( "\n" ) ;
SqlLoopEnd ( SC , Q ) ;
///////////////////////////////////////////////////////////////////
return ( U . count ( ) > 0 ) ;
}
bool N::VideosDispatcher::MatchId(SqlConnection & SC,UUIDs & U,QString K)
{
if ( K . contains ( "%" ) ) {
return LikeId ( SC , U , K ) ;
} ;
if ( K . contains ( "*" ) ) {
return RegexpId ( SC , U , K ) ;
} ;
return ExactId ( SC , U , K ) ;
}
bool N::VideosDispatcher::ReportNames(SqlConnection & SC,UUIDs & U)
{
GroupItems GI ( plan ) ;
SUID u ;
/////////////////////////////////////////////////
foreach ( u , U ) {
QStringList NS = GI . Names ( SC , u ) ;
Report ( tr("Commodity %1").arg(u) ) ;
Report ( "\n" ) ;
if ( NS . count ( ) > 0 ) {
for (int i = 0 ; i < NS . count ( ) ; i++ ) {
Report ( "=> " ) ;
Report ( NS[i] ) ;
Report ( "\n" ) ;
} ;
} ;
} ;
/////////////////////////////////////////////////
return true ;
}
bool N::VideosDispatcher::FetchAlbums(SqlConnection & SC,UUIDs & U,UUIDs & P)
{
GroupItems GI ( plan ) ;
SUID u ;
SUID z ;
///////////////////////////////////////////
GI . AutoMap = true ;
GI . GroupTable = GI . LookTable (
Types :: Commodity ,
Types :: Album ,
Groups :: Subordination ) ;
///////////////////////////////////////////
foreach ( u , U ) {
UUIDs XU ;
XU = GI . Subordination (
SC ,
u ,
Types :: Commodity ,
Types :: Album ,
Groups :: Subordination ,
SC . OrderByAsc ( "position" ) ) ;
foreach ( z , XU ) {
if ( ! P . contains ( z ) ) P << z ;
} ;
} ;
///////////////////////////////////////////
return ( P . count ( ) > 0 ) ;
}
bool N::VideosDispatcher::FetchNames(SqlConnection & SC,UUIDs & U,QString K)
{
if ( K . contains ( "%" ) ) {
FetchLike ( SC , PlanTable(Names) , U , K ) ;
} else
if ( K . contains ( "*" ) ) {
FetchRegexp ( SC , PlanTable(Names) , U , K ) ;
} else {
K = "%" + K + "%" ;
FetchLike ( SC , PlanTable(Names) , U , K ) ;
} ;
/////////////////////////////////////////////////
return ( U . count ( ) > 0 ) ;
}
bool N::VideosDispatcher::FetchByTag(SqlConnection & SC,UUIDs & U,QString Key)
{
TagsManager TM ( plan ) ;
GroupItems GI ( plan ) ;
UUIDs T ;
UUIDs P ;
UUIDs L ;
SUID u ;
/////////////////////////////////////////////////
TM . GetTags ( SC , T , Key ) ;
if ( T . count ( ) <= 0 ) return false ;
/////////////////////////////////////////////////
GI . AutoMap = true ;
GI . GroupTable = GI . LookTable (
Types::Tag ,
Types::Album ,
Groups::Subordination ) ;
foreach ( u , T ) {
P = GI . Subordination (
SC ,
u ,
Types::Tag ,
Types::Album ,
Groups::Subordination ,
SC . OrderByAsc ( "position" ) ) ;
L << P ;
} ;
/////////////////////////////////////////////////
P . clear ( ) ;
P = Uniqueness ( L ) ;
foreach ( u , P ) {
if ( ! U . contains ( u ) ) U << u ;
} ;
/////////////////////////////////////////////////
return ( U . count ( ) > 0 ) ;
}
void N::VideosDispatcher::SearchClips(void)
{
QStringList s = Syntax ( command ) ;
QStringList k ;
QStringList t ;
QString l ;
bool c = true ;
///////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "search" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "clips" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "by" != l ) c = false ;
l = s [ 3 ] . toLower ( ) ;
if ( "name" != l ) c = false ;
///////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=0;i<4;i++) s . takeFirst ( ) ;
///////////////////////////////////////////////////////
int left = 0 ;
int right = 0 ;
if ( ! isSyntax ( left , right , s , k ) ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=left;i<=right;i++) t << s [ i ] ;
l = t . join ( " " ) ;
Report ( tr("Syntax : %1") . arg ( l ) ) ;
Report ( "\n" ) ;
///////////////////////////////////////////////////////
QMap<QString,UUIDs> UM ;
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs U ;
UUIDs P ;
/////////////////////////////////////////////////////
foreach ( l , k ) {
UM [ l ] = U ;
FetchNames ( SC , UM [ l ] , l ) ;
} ;
/////////////////////////////////////////////////////
if ( Operate ( U , t , UM ) ) {
if ( NamesOwners ( SC , U , P ) ) {
FilterType ( SC , Types::Video , P , X ) ;
} ;
} ;
/////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
///////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 clips") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = t . join ( " " ) ;
ClipsPaddings << l ;
ClipsQueues [ l ] = X ;
emit EmitClipsGroup ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::SearchClip(void)
{
QStringList s = Syntax ( command ) ;
QStringList k ;
QStringList t ;
QString l ;
bool c = true ;
///////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "search" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "clips" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "in" != l ) c = false ;
l = s [ 3 ] . toLower ( ) ;
if ( "list" != l ) c = false ;
l = s [ 4 ] . toLower ( ) ;
if ( "by" != l ) c = false ;
l = s [ 5 ] . toLower ( ) ;
if ( "name" != l ) c = false ;
///////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=0;i<6;i++) s . takeFirst ( ) ;
///////////////////////////////////////////////////////
int left = 0 ;
int right = 0 ;
if ( ! isSyntax ( left , right , s , k ) ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=left;i<=right;i++) t << s [ i ] ;
l = t . join ( " " ) ;
Report ( tr("Syntax : %1") . arg ( l ) ) ;
Report ( "\n" ) ;
///////////////////////////////////////////////////////
QMap<QString,UUIDs> UM ;
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs U ;
UUIDs P ;
/////////////////////////////////////////////////////
foreach ( l , k ) {
UM [ l ] = U ;
FetchNames ( SC , UM [ l ] , l ) ;
} ;
/////////////////////////////////////////////////////
if ( Operate ( U , t , UM ) ) {
if ( NamesOwners ( SC , U , P ) ) {
FilterType ( SC , Types::Video , P , X ) ;
} ;
} ;
/////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
///////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 clips") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = t . join ( " " ) ;
ClipPaddings << l ;
ClipQueues [ l ] = X ;
emit EmitClips ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::SearchId(void)
{
QStringList s ;
QString l ;
bool c = true ;
s <= arguments ;
///////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "search" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "albums" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "by" != l ) c = false ;
l = s [ 3 ] . toLower ( ) ;
if ( "id" != l ) c = false ;
///////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=0;i<4;i++) s . takeFirst ( ) ;
if ( s . count ( ) <= 0 ) c = false ;
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs C ;
/////////////////////////////////////////////////////
foreach ( l , s ) ExactId ( SC , C , l ) ;
if ( C . count ( ) > 0 ) {
ReportNames ( SC , C ) ;
FetchAlbums ( SC , C , X ) ;
} ;
/////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
///////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 albums") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
VideoPaddings << l ;
VideoQueues [ l ] = X ;
emit EmitVideos ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::SearchIdentifiers(void)
{
QStringList s = Syntax ( command ) ;
QStringList k ;
QStringList t ;
QString l ;
bool c = true ;
///////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "search" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "albums" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "by" != l ) c = false ;
l = s [ 3 ] . toLower ( ) ;
if ( "identifiers" != l ) c = false ;
///////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=0;i<4;i++) s . takeFirst ( ) ;
///////////////////////////////////////////////////////
int left = 0 ;
int right = 0 ;
if ( ! isSyntax ( left , right , s , k ) ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=left;i<=right;i++) t << s [ i ] ;
l = t . join ( " " ) ;
Report ( tr("Syntax : %1") . arg ( l ) ) ;
Report ( "\n" ) ;
///////////////////////////////////////////////////////
QMap<QString,UUIDs> UM ;
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs U ;
UUIDs C ;
/////////////////////////////////////////////////////
foreach ( l , k ) {
UM [ l ] = U ;
MatchId ( SC , UM [ l ] , l ) ;
} ;
/////////////////////////////////////////////////////
if ( Operate ( C , t , UM ) ) {
if ( C . count ( ) > 0 ) {
ReportNames ( SC , C ) ;
FetchAlbums ( SC , C , X ) ;
} ;
} ;
/////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
///////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 albums") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
VideoPaddings << l ;
VideoQueues [ l ] = X ;
emit EmitVideos ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::SearchAlbums(void)
{
QStringList s = Syntax ( command ) ;
QStringList k ;
QStringList t ;
QString l ;
bool c = true ;
///////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "search" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "albums" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "by" != l ) c = false ;
l = s [ 3 ] . toLower ( ) ;
if ( "name" != l ) c = false ;
///////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=0;i<4;i++) s . takeFirst ( ) ;
///////////////////////////////////////////////////////
int left = 0 ;
int right = 0 ;
if ( ! isSyntax ( left , right , s , k ) ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=left;i<=right;i++) t << s [ i ] ;
l = t . join ( " " ) ;
Report ( tr("Syntax : %1") . arg ( l ) ) ;
Report ( "\n" ) ;
///////////////////////////////////////////////////////
QMap<QString,UUIDs> UM ;
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs U ;
/////////////////////////////////////////////////////
foreach ( l , k ) {
UM [ l ] = U ;
FetchNames ( SC , UM [ l ] , l ) ;
} ;
/////////////////////////////////////////////////////
if ( Operate ( U , t , UM ) ) {
FilterType ( SC , Types::Album , U , X ) ;
} ;
/////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
///////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 albums") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
VideoPaddings << l ;
VideoQueues [ l ] = X ;
emit EmitVideos ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::SearchUUIDs(void)
{
QStringList s ;
QString l ;
bool c = true ;
s <= arguments ;
///////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "search" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "albums" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "by" != l ) c = false ;
l = s [ 3 ] . toLower ( ) ;
if ( "uuid" != l ) c = false ;
///////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=0;i<4;i++) s . takeFirst ( ) ;
if ( s . count ( ) <= 0 ) c = false ;
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
UUIDs X ;
foreach ( l , s ) {
SUID u = l . toULongLong ( ) ;
if ( ! X . contains ( u ) ) X << u ;
} ;
///////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 albums") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
VideoPaddings << l ;
VideoQueues [ l ] = X ;
emit EmitVideos ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::MatchIdenticals(void)
{
QStringList s ;
QString l ;
QString OutputList ;
QString OutputUuid ;
bool c = true ;
bool p = true ;
int language = Variables [ "Language" ] . toInt () ;
////////////////////////////////////////////////////////////
s <= arguments ;
if ( ! Variables . contains ( "OutputList" ) ) {
Report ( tr("You need to set up variable OutputList") ) ;
Report ( "\n" ) ;
c = false ;
} ;
if ( ! Variables . contains ( "OutputUuid" ) ) {
Report ( tr("You need to set up variable OutputUuid") ) ;
Report ( "\n" ) ;
c = false ;
} ;
OutputList = Variables [ "OutputList" ] . toString ( ) ;
OutputUuid = Variables [ "OutputUuid" ] . toString ( ) ;
////////////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "catalog" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "albums" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "identical" != l ) c = false ;
////////////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
////////////////////////////////////////////////////////////
if ( s . count ( ) > 4 ) {
if ( "progress" == s [ 4 ] . toLower ( ) ) {
if ( "without" == s [ 4 ] . toLower ( ) ) {
p = false ;
} ;
} ;
} ;
////////////////////////////////////////////////////////////
NAMEs S ;
UUIDs U ;
SqlConnection SC ( plan -> sql ) ;
////////////////////////////////////////////////////////////
if ( SC . open ( FunctionString ) ) {
QString Q ;
QString N ;
SUID u ;
qint64 total ;
qint64 index = 0 ;
bool go = true ;
int id = -1 ;
//////////////////////////////////////////////////////////
Q = QString("select `uuid` from `divisions`"
" where `type` = %1 ;").arg(Types::Album) ;
SqlLoopNow ( SC , Q ) ;
U << SC . Uuid ( 0 ) ;
SqlLoopErr ( SC , Q ) ;
SqlLoopEnd ( SC , Q ) ;
//////////////////////////////////////////////////////////
total = U . count ( ) ;
if ( total > 0 ) {
id = plan -> Progress ( tr("Catalog albums") ,
tr("%v/%m albums") ) ;
if ( id >= 0 ) {
plan -> Start ( id , &index , &go ) ;
plan -> setRange ( id , 0 , total ) ;
} ;
} ;
//////////////////////////////////////////////////////////
while ( go && ( index < total ) ) {
u = U [ index ] ;
N = SC . getName (
PlanTable(Names) ,
"uuid" ,
language ,
u ) ;
if ( N . length ( ) > 0 ) {
S [ u ] = N ;
} ;
index++ ;
} ;
//////////////////////////////////////////////////////////
if ( id >= 0 ) plan -> Finish ( id ) ;
//////////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
////////////////////////////////////////////////////////////
U . clear ( ) ;
if ( SortedUuids ( S , U ) ) {
QStringList L ;
QStringList G ;
QString LS ;
QString GS ;
QByteArray LL ;
QByteArray GG ;
SUID z ;
toStrings ( S , U , L ) ;
foreach ( z , U ) {
G << QString("%1 => %2") . arg ( z ) . arg ( S [ z ] ) ;
} ;
LS = L . join ( "\n" ) ;
GS = G . join ( "\n" ) ;
LL = LS . toUtf8 ( ) ;
GG = GS . toUtf8 ( ) ;
File::toFile ( OutputList , LL ) ;
File::toFile ( OutputUuid , GG ) ;
} ;
Report ( tr("Catalog identical albums completed") ) ;
Report ( "\n" ) ;
Alert ( Done ) ;
}
SUID N::VideosDispatcher::MapToCompany(QString ID)
{
SUID u ;
foreach ( u , Matchings ) {
QString S = MatchingScripts [ u ] ;
if ( Scripts::StringMatching ( S , ID ) ) {
return ToCompanies [ u ] ;
} ;
} ;
return 0 ;
}
void N::VideosDispatcher::CatalogAlbums(void)
{
int lines = 0 ;
GroupItems GI ( plan ) ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs Ouids ;
SUID u ;
SUID c ;
SUID x ;
Ouids = SC.Uuids(PlanTable(Organizations),"uuid",SC.OrderByAsc("id")) ;
foreach ( u , Ouids ) {
QStringList names ;
QString on ;
UUIDs Auids ;
UUIDs Cuids ;
UUIDs Xuids ;
names = GI . Names ( SC , u ) ;
if (names.count()>0) on = names[0] ;
Auids = GI . Subordination (
SC ,
u ,
Types :: Organization ,
Types :: Album ,
Groups :: Subordination ,
SC . OrderByAsc ( "position" ) ) ;
Cuids = GI . Subordination (
SC ,
u ,
Types :: Organization ,
Types :: Commodity ,
Groups :: Subordination ,
SC . OrderByAsc ( "position" ) ) ;
Report ( QString("<%1> has (%2,%3)\n" ).arg(on).arg(Auids.count()).arg(Cuids.count()) ) ;
lines++ ;
// if ( 0 == ( lines % 100 ) ) Clear ( ) ;
foreach ( c , Cuids ) {
Xuids = GI . Subordination (
SC ,
c ,
Types :: Commodity ,
Types :: Album ,
Groups :: Subordination ,
SC.OrderByAsc("position") ) ;
foreach ( x , Xuids ) {
if ( !Auids.contains(x) ) Auids << x ;
} ;
} ;
if (Auids.count()>0) {
Report ( QString("Append <%1> into <%2>\n" ).arg(Auids.count()).arg(on) ) ;
lines++ ;
// if ( 0 == ( lines % 100 ) ) Clear ( ) ;
GI . FullDetach (
SC ,
u ,
Types :: Organization ,
Types :: Album ,
Groups :: Subordination ) ;
GI . Join (
SC ,
u ,
Types :: Organization ,
Types :: Album ,
Groups :: Subordination ,
0 ,
Auids ) ;
} ;
} ;
SC . close ( ) ;
} ;
SC . remove ( ) ;
Alert ( Done ) ;
}
void N::VideosDispatcher::CatalogProducts(void)
{
Matchings . clear ( ) ;
Companies . clear ( ) ;
ToCompanies . clear ( ) ;
MatchingScripts . clear ( ) ;
CompanyNames . clear ( ) ;
GroupItems GI ( plan ) ;
SqlConnection SC ( plan -> sql ) ;
if (SC.open("VideoCLI","Catalog")) {
QString Q ;
QString N ;
UUIDs U ;
SUID u ;
int Lines = 0 ;
/////////////////////////////////////////
Q = SC.sql.SelectFrom (
"script,company" ,
"dvdmatching" ,
"order by id asc" ) ;
SqlLoopNow ( SC , Q ) ;
SUID SCRIPT = SC.Uuid(0) ;
SUID COMPANY = SC.Uuid(1) ;
Matchings << SCRIPT ;
Companies << COMPANY ;
ToCompanies [ SCRIPT ] = COMPANY ;
SqlLoopErr ( SC , Q ) ;
SqlLoopEnd ( SC , Q ) ;
/////////////////////////////////////////
foreach (u,Matchings) {
Q = SC.sql.SelectFrom (
"script" ,
PlanTable(Scripts) ,
SC.WhereUuid(u) ) ;
if (SC.Fetch(Q)) {
QString XX = SC.String(0) ;
MatchingScripts [ u ] = XX ;
} ;
} ;
/////////////////////////////////////////
foreach (u,Companies) {
QStringList L = GI.Names(SC,u) ;
if (L.count()>0) {
CompanyNames[u] = L[0] ;
} ;
} ;
/////////////////////////////////////////
U = SC . Uuids (
PlanTable(Commodities) ,
"uuid" ,
SC.OrderByAsc("id") ) ;
foreach (u,U) {
Q = SC.sql.SelectFrom (
"name" ,
PlanTable(Identifiers) ,
SC.WhereUuid(u) ) ;
if (SC.Fetch(Q)) {
N = SC.String(0) ;
if (N.length()>0) {
N = N . toUpper ( ) ;
SUID x = MapToCompany(N) ;
if (x>0) {
UUIDs CU ;
CU << u ;
Report ( QString("%1 => %2\n").arg(N).arg(CompanyNames[x]) ) ;
Lines++ ;
if (Lines>=100) {
if ( NULL != History ) {
History -> clear ( ) ;
} ;
Lines = 0 ;
} ;
GI . Join (
SC ,
x ,
Types :: Organization ,
Types :: Commodity ,
Groups :: Subordination ,
0 ,
CU ,
false ) ;
} ;
} ;
} ;
plan -> processEvents ( ) ;
} ;
SC.close() ;
} ;
SC.remove() ;
Report ( tr("Completed") ) ;
Report ( "\n" ) ;
Alert ( Done ) ;
}
void N::VideosDispatcher::CatalogOrders(void)
{
int total = 0 ;
ZMAPs NtoV ;
QStringList VCL ;
UUIDs CUL ;
GroupItems GI ( plan ) ;
// VideoManager VM ( plan ) ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
QStringList N ;
QString Q ;
QString V ;
QString S ;
UUIDs U ;
SUID u ;
SUID z ;
int lines = 0 ;
Report ( QString("Starting\n") ) ;
//////////////////////////////////////
U = SC . Uuids (
PlanTable(Videos) ,
"uuid" ,
SC.OrderByAsc("id") ) ;
foreach (u,U) {
z = 0 ;
Q = QString("select first from groups where t1 = %1 and t2 = %2 and relation = %3 and second = %4 ;")
. arg (N::Types ::Album )
. arg (N::Types ::Video )
. arg (N::Groups::Subordination)
. arg (u ) ;
if (SC.Fetch(Q)) z = SC.Uuid(0) ;
if (z<=0) {
N = GI.Names(SC,u) ;
if (N.length()>0) {
QString X = N[0] ;
N = X.split('/') ;
if (N.count()>2) {
if (!VCL.contains(X)) {
VCL << X ;
NtoV [ X ] = u ;
} ;
} ;
} ;
} ;
} ;
//////////////////////////////////////
Report ( QString("Completed\n") ) ;
VCL . sort ( ) ;
S = VCL . join ( "\n" ) ;
QByteArray BS = S.toUtf8() ;
N::File::toFile("G:/Temp/EurAV.txt",BS) ;
foreach ( V , VCL ) {
u = NtoV [ V ] ;
CUL << u ;
// S = QString("%1 => %2").arg(u).arg(V) ;
// Report ( S ) ;
// Report ( "\n" ) ;
// lines++ ;
// total++ ;
// if (lines>200) {
// Clear ( ) ;
// lines = 0 ;
// } ;
} ;
//////////////////////////////////////
SC.close() ;
} ;
SC.remove() ;
Report ( QString("%1 Completed\n").arg(total) ) ;
// emit ListClip ( "European" , CUL ) ;
Alert ( Done ) ;
}
void N::VideosDispatcher::CatalogCommodity(void)
{
QStringList Used ;
QStringList All ;
int language ;
SqlConnection SC ( plan -> sql ) ;
language = Variables["Language"].toInt() ;
if ( SC . open ( FunctionString ) ) {
QString Q ;
QString N ;
UUIDs U ;
SUID u ;
/////////////////////////////////////////
Q = SC.sql.SelectFrom (
"script" ,
"dvdmatching" ,
"order by id asc" ) ;
SqlLoopNow ( SC , Q ) ;
U << SC . Uuid ( 0 ) ;
SqlLoopErr ( SC , Q ) ;
SqlLoopEnd ( SC , Q ) ;
/////////////////////////////////////////
foreach (u,U) {
N = SC . getName (
PlanTable(Names) ,
"uuid" ,
language ,
u ) ;
if (N.length()>0) Used << N ;
} ;
/////////////////////////////////////////
U = SC . Uuids (
PlanTable(Commodities) ,
"uuid" ,
SC.OrderByAsc("id") ) ;
foreach (u,U) {
Q = SC.sql.SelectFrom (
"name" ,
PlanTable(Identifiers) ,
SC.WhereUuid(u) ) ;
if (SC.Fetch(Q)) {
N = SC.String(0) ;
if (N.length()>0) {
int xid ;
N = N . toUpper ( ) ;
xid = N . indexOf ( '-' ) ;
if (xid>0) {
QString n = N.left(xid+1) ;
if (!Used.contains(n)) {
if (!All.contains(n)) {
bool correct = true ;
if (n.contains(' ')) {
correct = false ;
} ;
if (!(n.at(0)>='A' && n.at(0)<='Z')) {
correct = false ;
} ;
if (correct) All << n ;
} ;
} ;
} ;
} ;
} ;
plan -> processEvents ( ) ;
} ;
/////////////////////////////////////////
All . sort ( ) ;
foreach (N,All) {
QString SS ;
int tt = Scripts::Matching ;
SS = QString("function matching(ss)\n"
"{\n"
" return ( ss . indexOf ( \"%1\" ) == 0 ) ;\n"
"}\n" ).arg(N) ;
u = SC.Unique (
PlanTable(MajorUuid) ,
"uuid" ,
7789120 ) ;
SC . assureUuid (
PlanTable(MajorUuid) ,
u ,
Types::Script ) ;
SC . assureUuid (
PlanTable(Scripts ) ,
u ,
tt ) ;
SC . assureName (
PlanTable(Names) ,
u ,
language ,
N ) ;
Q = SC.sql.Update (
PlanTable(Scripts) ,
"where uuid = :UUID" ,
2,"script","type" ) ;
SC.Prepare ( Q ) ;
SC.Bind ( "uuid" , u ) ;
SC.Bind ( "type" , tt ) ;
SC.Bind ( "script" , SS.toUtf8() ) ;
SC.Exec ( ) ;
} ;
/////////////////////////////////////////
SC.close() ;
} ;
SC.remove() ;
Report ( tr("Completed") ) ;
Report ( "\n" ) ;
Alert ( Done ) ;
}
void N::VideosDispatcher::EditId(void)
{
QStringList s ;
QString l ;
bool c = true ;
s <= arguments ;
///////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "edit" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "albums" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "by" != l ) c = false ;
l = s [ 3 ] . toLower ( ) ;
if ( "id" != l ) c = false ;
///////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=0;i<4;i++) s . takeFirst ( ) ;
if ( s . count ( ) <= 0 ) c = false ;
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs C ;
/////////////////////////////////////////////////////
foreach ( l , s ) ExactId ( SC , C , l ) ;
if ( C . count ( ) > 0 ) {
ReportNames ( SC , C ) ;
FetchAlbums ( SC , C , X ) ;
} ;
/////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
///////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 albums") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
EditPaddings << l ;
EditQueues [ l ] = X ;
emit EmitEditings ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::SearchFiles(void)
{
static char * cmds [ ] = { "search" , "clips" , "by" , "files" , NULL } ;
QStringList s = N::CommandTokens ( command ) ;
QString l ;
bool c = compare ( 4 , s , cmds ) ;
////////////////////////////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
for (int i=0;i<4;i++) s . takeFirst ( ) ;
////////////////////////////////////////////////////////////////////////////
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
VideoManager VM ( plan ) ;
if ( SC . open ( FunctionString ) ) {
QString f ;
//////////////////////////////////////////////////////////////////////////
foreach ( f , s ) VM . ClipsFilename ( SC , f , X ) ;
//////////////////////////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
////////////////////////////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 clips") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
ClipsPaddings << l ;
ClipsQueues [ l ] = X ;
emit EmitClipsGroup ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::ClipsId(void)
{
static char * cmds [ ] = { "search" , "clips" , "by" , "id" , NULL } ;
QStringList s = N::CommandTokens ( command ) ;
QString l ;
bool c = compare ( 4 , s , cmds ) ;
////////////////////////////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
////////////////////////////////////////////////////////////////////////////
for (int i=0;i<4;i++) s . takeFirst ( ) ;
if ( s . count ( ) <= 0 ) c = false ;
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
////////////////////////////////////////////////////////////////////////////
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
GroupItems GI ( plan ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs C ;
UUIDs A ;
//////////////////////////////////////////////////////////////////////////
foreach ( l , s ) ExactId ( SC , C , l ) ;
if ( C . count ( ) > 0 ) {
ReportNames ( SC , C ) ;
FetchAlbums ( SC , C , A ) ;
if ( A . count ( ) > 0 ) {
SUID u ;
GI . AutoMap = true ;
GI . GroupTable = GI . LookTable (
Types::Album ,
Types::Video ,
Groups::Subordination ) ;
foreach ( u , A ) {
UUIDs V = GI . Subordination (
SC ,
u ,
Types::Album ,
Types::Video ,
Groups::Subordination ,
SC . OrderByAsc ( "position" ) ) ;
SUID v ;
foreach ( v , V ) {
if ( ! X . contains ( v ) ) X << v ;
} ;
} ;
} ;
} ;
//////////////////////////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
////////////////////////////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 clips") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
ClipsPaddings << l ;
ClipsQueues [ l ] = X ;
emit EmitClipsGroup ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::AlbumFiles(void)
{
static char * cmds [ ] = { "search" , "albums" , "by" , "files" , NULL } ;
QStringList s = N::CommandTokens ( command ) ;
QString l ;
bool c = compare ( 4 , s , cmds ) ;
////////////////////////////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
for (int i=0;i<4;i++) s . takeFirst ( ) ;
////////////////////////////////////////////////////////////////////////////
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
VideoManager VM ( plan ) ;
if ( SC . open ( FunctionString ) ) {
QString f ;
UUIDs C ;
//////////////////////////////////////////////////////////////////////////
foreach ( f , s ) VM . ClipsFilename ( SC , f , C ) ;
if ( C . count ( ) > 0 ) VM . ClipsToAlbums ( SC , C , X ) ;
//////////////////////////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
////////////////////////////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 albums") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
VideoPaddings << l ;
VideoQueues [ l ] = X ;
emit EmitVideos ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::AlbumPictures(void)
{
static char * cmds [ ] = { "search","albums","by","pictures",NULL } ;
QStringList s = N::CommandTokens ( command ) ;
QString l ;
bool c = compare ( 4 , s , cmds ) ;
////////////////////////////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
for (int i=0;i<4;i++) s . takeFirst ( ) ;
////////////////////////////////////////////////////////////////////////////
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
PictureManager PM ( plan ) ;
VideoManager VM ( plan ) ;
if ( SC . open ( FunctionString ) ) {
QString f ;
UUIDs I ;
//////////////////////////////////////////////////////////////////////////
foreach ( f , s ) {
SUID puid = 0 ;
PM . Import ( SC , f , puid ) ;
if ( ( puid > 0 ) && ( ! I . contains ( puid ) ) ) I << puid ;
} ;
if ( I . count ( ) > 0 ) VM . ImagesToAlbums ( SC, I , X ) ;
//////////////////////////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
////////////////////////////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 albums") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = s . join ( " " ) ;
VideoPaddings << l ;
VideoQueues [ l ] = X ;
emit EmitVideos ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
void N::VideosDispatcher::SearchTags(void)
{
QStringList s = Syntax ( command ) ;
QStringList k ;
QStringList t ;
QString l ;
bool c = true ;
///////////////////////////////////////////////////////
l = s [ 0 ] . toLower ( ) ;
if ( "search" != l ) c = false ;
l = s [ 1 ] . toLower ( ) ;
if ( "albums" != l ) c = false ;
l = s [ 2 ] . toLower ( ) ;
if ( "by" != l ) c = false ;
l = s [ 3 ] . toLower ( ) ;
if ( "tags" != l ) c = false ;
///////////////////////////////////////////////////////
if ( ! c ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=0;i<4;i++) s . takeFirst ( ) ;
///////////////////////////////////////////////////////
int left = 0 ;
int right = 0 ;
if ( ! isSyntax ( left , right , s , k ) ) {
Report ( tr("Syntax error") ) ;
Report ( "\n" ) ;
return ;
} ;
///////////////////////////////////////////////////////
for (int i=left;i<=right;i++) t << s [ i ] ;
l = t . join ( " " ) ;
Report ( tr("Syntax : %1") . arg ( l ) ) ;
Report ( "\n" ) ;
///////////////////////////////////////////////////////
QMap<QString,UUIDs> UM ;
UUIDs X ;
SqlConnection SC ( plan -> sql ) ;
if ( SC . open ( FunctionString ) ) {
UUIDs U ;
/////////////////////////////////////////////////////
foreach ( l , k ) {
UM [ l ] = U ;
FetchByTag ( SC , UM [ l ] , l ) ;
} ;
/////////////////////////////////////////////////////
Operate ( U , t , UM ) ;
X = Uniqueness ( U ) ;
/////////////////////////////////////////////////////
SC . close ( ) ;
} ;
SC . remove ( ) ;
///////////////////////////////////////////////////////
if ( X . count ( ) > 0 ) {
QString m ;
m = tr("Found %1 albums") . arg ( X . count ( ) ) ;
Report ( m ) ;
Report ( "\n" ) ;
l = t . join ( " " ) ;
VideoPaddings << l ;
VideoQueues [ l ] = X ;
emit EmitVideos ( ) ;
} else {
Report ( tr("Found nothing") ) ;
Report ( "\n" ) ;
} ;
}
| 55.942361 | 130 | 0.200452 | Vladimir-Lin |
43af485bff84f3c13efea28cbea9bb2877e41b46 | 1,793 | hpp | C++ | model/include/primitive.hpp | psnbaba/Computer_graphics | 25adabdb29a2cf0c7797b7f658fedafffc719408 | [
"MIT"
] | 1 | 2018-12-06T05:19:36.000Z | 2018-12-06T05:19:36.000Z | model/include/primitive.hpp | psnbaba/Computer_graphics | 25adabdb29a2cf0c7797b7f658fedafffc719408 | [
"MIT"
] | null | null | null | model/include/primitive.hpp | psnbaba/Computer_graphics | 25adabdb29a2cf0c7797b7f658fedafffc719408 | [
"MIT"
] | null | null | null | #ifndef _PRIMITIVE_HPP_
#define _PRIMITIVE_HPP_
#include "glm/vec4.hpp"
#include<math.h>
#define PI 3.1419
namespace csX75{
class shape {
public:
glm::vec4 *v_positions;
glm::vec4 *v_colors;
std::size_t size ;
int numofvert ;
};
class square:public shape{
private:
glm::vec4 positions[8];
glm::vec4 colors[8] ;
void maketriangles(void);
public:
square() {} ;
square(glm::vec4 col);
~square() {} ;
};
class square_wo_topface:public shape{
private:
glm::vec4 positions[8];
glm::vec4 colors[8] ;
void maketriangles(void);
public:
square_wo_topface() {} ;
square_wo_topface(glm::vec4 col) ;
~square_wo_topface() {} ;
};
class cylinder:public shape{
private:
glm::vec4 positions[22];
glm::vec4 colors[22] ;
void maketriangles(void);
public:
cylinder() {} ;
cylinder(glm::vec4 col) ;
~cylinder() {} ;
};
class sphere:public shape{
private:
glm::vec4 positions[70];
glm::vec4 colors[70] ;
void maketriangles(void);
public:
sphere() {} ;
sphere(glm::vec4 col) ;
~sphere() {} ;
};
class cone:public shape{
private:
glm::vec4 positions[11];
glm::vec4 colors[11] ;
void maketriangles(void);
public:
cone() {} ;
cone(glm::vec4 col) ;
~cone() {} ;
};
void quad(int a, int b, int c, int d , int index
, shape* , glm::vec4* , glm::vec4*) ;
}
#endif
| 19.703297 | 53 | 0.475739 | psnbaba |
43af87e6303b09fa66fa639467d6e92764604bc3 | 368 | hpp | C++ | src/Entity.hpp | davidsmithxc/CPP-SDL2-RPG-Physics-Based-2D-Platformer-for-Beginners | 9268a436e75a8e67c6ffe16bdfc25ea2df917776 | [
"Apache-2.0"
] | null | null | null | src/Entity.hpp | davidsmithxc/CPP-SDL2-RPG-Physics-Based-2D-Platformer-for-Beginners | 9268a436e75a8e67c6ffe16bdfc25ea2df917776 | [
"Apache-2.0"
] | null | null | null | src/Entity.hpp | davidsmithxc/CPP-SDL2-RPG-Physics-Based-2D-Platformer-for-Beginners | 9268a436e75a8e67c6ffe16bdfc25ea2df917776 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "Math.hpp"
class Entity
{
public:
Entity(Vector2f p_pos, SDL_Texture* p_tex);
// TODO: make getters const
Vector2f& getPos() { return pos; }
SDL_Texture* getTex();
SDL_Rect getCurrentFrame();
private:
Vector2f pos;
SDL_Rect currentFrame;
SDL_Texture* tex;
}; | 19.368421 | 47 | 0.671196 | davidsmithxc |
43b50cb573b79d495ae732a227cb2ff6897838da | 686 | cpp | C++ | code archive/GJ/a013.cpp | brianbbsu/program | c4505f2b8c0b91010e157db914a63c49638516bc | [
"MIT"
] | 4 | 2018-04-08T08:07:58.000Z | 2021-06-07T14:55:24.000Z | code archive/GJ/a013.cpp | brianbbsu/program | c4505f2b8c0b91010e157db914a63c49638516bc | [
"MIT"
] | null | null | null | code archive/GJ/a013.cpp | brianbbsu/program | c4505f2b8c0b91010e157db914a63c49638516bc | [
"MIT"
] | 1 | 2018-10-29T12:37:25.000Z | 2018-10-29T12:37:25.000Z | /**********************************************************************************/
/* Problem: a013 "成績分佈 (*)" from if 判斷式、多重條件 */
/* Language: C++ */
/* Result: AC (3ms, 176KB) on ZeroJudge */
/* Author: briansu at 2016-08-24 21:23:32 */
/**********************************************************************************/
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n;
cin>>n;
if(n>=75 && n<=90)
{
cout<<"YES";
}
else
{
cout<<"NO";
}
} | 29.826087 | 84 | 0.258017 | brianbbsu |
43b8679942ba5a14920d7dbb6cb55737d2da6774 | 25,583 | cpp | C++ | Source/AllProjects/Drivers/IR/GC-IRE/GC-IRES_DriverImpl.cpp | MarkStega/CQC | c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07 | [
"MIT"
] | 51 | 2020-12-26T18:17:16.000Z | 2022-03-15T04:29:35.000Z | Source/AllProjects/Drivers/IR/GC-IRE/GC-IRES_DriverImpl.cpp | MarkStega/CQC | c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07 | [
"MIT"
] | null | null | null | Source/AllProjects/Drivers/IR/GC-IRE/GC-IRES_DriverImpl.cpp | MarkStega/CQC | c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07 | [
"MIT"
] | 4 | 2020-12-28T07:24:39.000Z | 2021-12-29T12:09:37.000Z | //
// FILE NAME: GE-IRES_DriverImpl.cpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 07/29/2008
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2020
//
// This software is copyrighted by 'Charmed Quark Systems, Ltd' and
// the author (Dean Roddey.) It is licensed under the MIT Open Source
// license:
//
// https://opensource.org/licenses/MIT
//
// DESCRIPTION:
//
// This file implements the bulk of the driver implementation. Some of the
// functionality provided here is accessed via server side ORB objects that
// we register, and which the generic IR client side driver uses to talk
// to us.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "GC-IRES.hpp"
// ---------------------------------------------------------------------------
// Magic macros
// ---------------------------------------------------------------------------
RTTIDecls(TGCIRESDriver,TBaseIRSrvDriver)
// ---------------------------------------------------------------------------
// Local data
// ---------------------------------------------------------------------------
namespace GCIRES_DriverImpl
{
const tCIDLib::TEncodedTime enctMinInterval = kCIDLib::enctOneMilliSec * 250;
const tCIDLib::TEncodedTime enctPollInterval = kCIDLib::enctOneMinute;
}
// ---------------------------------------------------------------------------
// CLASS: TGCIRESDriver::TOOPair
// PREFIX: oop
// ---------------------------------------------------------------------------
TGCIRESDriver::TOOPair::TOOPair() :
m_c4Off(0)
, m_c4On(0)
{
}
TGCIRESDriver::TOOPair::TOOPair(const tCIDLib::TCard4 c4On
, const tCIDLib::TCard4 c4Off) :
m_c4Off(c4Off)
, m_c4On(c4On)
{
}
TGCIRESDriver::TOOPair::~TOOPair()
{
}
tCIDLib::TVoid
TGCIRESDriver::TOOPair::Set(const tCIDLib::TCard4 c4On
, const tCIDLib::TCard4 c4Off)
{
m_c4Off = c4Off;
m_c4On = c4On;
}
// ---------------------------------------------------------------------------
// CLASS: TGCIRESDriver
// PREFIX: drv
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// TGCIRESDriver: Constructors and Destructor
// ---------------------------------------------------------------------------
TGCIRESDriver::TGCIRESDriver(const TCQCDriverObjCfg& cqcdcToLoad) :
TBaseIRSrvDriver(cqcdcToLoad)
, m_bTrainingMode(kCIDLib::False)
, m_c4FldIdFirmwareVer(kCIDLib::c4MaxCard)
, m_c4FldIdTrainingMode(kCIDLib::c4MaxCard)
, m_enctLastMsg(0)
, m_enctNextEvent(0)
, m_pcommGCIRE(0)
, m_strCmdPrefix(L"GC-IRE,")
, m_strPort()
{
}
TGCIRESDriver::~TGCIRESDriver()
{
// Clean up the comm port if not already
if (m_pcommGCIRE)
{
try
{
if (m_pcommGCIRE->bIsOpen())
m_pcommGCIRE->Close();
delete m_pcommGCIRE;
m_pcommGCIRE= 0;
}
catch(...)
{
}
}
}
// ---------------------------------------------------------------------------
// TGCIRESDriver: Protected, inherited methods
// ---------------------------------------------------------------------------
tCIDLib::TBoolean TGCIRESDriver::bCheckRecTrainingData(TString& strKeyToFill)
{
// If we aren't online, then throw, else do it
CheckOnline(CID_FILE, CID_LINE);
//
// Store the current value, then clear the member. Return whether it
// had a value or not.
//
const tCIDLib::TBoolean bRet = !m_strTrainVal.bIsEmpty();
if (bRet)
{
strKeyToFill = m_strTrainVal;
m_strTrainVal.Clear();
}
return bRet;
}
tCIDLib::TBoolean
TGCIRESDriver::bGetCommResource(TThread& thrThis)
{
// Open the port now, and set the configuration
try
{
// Create the port object if needed, else close if open just in case
if (!m_pcommGCIRE)
m_pcommGCIRE = facCIDComm().pcommMakeNew(m_strPort);
else if (m_pcommGCIRE->bIsOpen())
m_pcommGCIRE->Close();
m_pcommGCIRE->Open();
m_pcommGCIRE->SetCfg(m_cpcfgSerial);
//
// We have to pause a bit here, since it takes it a couple
// seconds to get happy, then issue a read for a few junk
// bytes it seems to spit out. If we get a shutdown request
// while waiting, just return immediately.
//
if (!thrThis.bSleep(2000))
return kCIDLib::True;
tCIDLib::TCard1 ac1Junk[10];
m_pcommGCIRE->c4ReadRawBufMS(ac1Junk, 10, 50);
}
catch(TError& errToCatch)
{
if(eVerboseLevel() > tCQCKit::EVerboseLvls::Medium)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
}
return kCIDLib::False;
}
return kCIDLib::True;
}
//
// We don't check online here, since it's intended to try to get us back
// online if possible.
//
tCIDLib::TBoolean TGCIRESDriver::bResetConnection()
{
// If we aren't online, then throw, else do it
CheckOnline(CID_FILE, CID_LINE);
// Force it out of training mode
m_bTrainingMode = kCIDLib::False;
ClearEventQ();
bStoreBoolFld(m_c4FldIdTrainingMode, m_bTrainingMode, kCIDLib::True);
return (ePing(kCIDLib::False) == tCQCKit::ECommResults::Success);
}
tCIDLib::TVoid TGCIRESDriver::ClearRecTrainingData()
{
// If we aren't online, then throw, else do it
CheckOnline(CID_FILE, CID_LINE);
m_strTrainVal.Clear();
}
tCQCKit::ECommResults
TGCIRESDriver::eConnectToDevice(TThread& thrThis)
{
// Tell it we want CR terminators
static const tCIDLib::TCard1 ac1Term[] = { 0x74, 0x63, 0xD };
m_pcommGCIRE->c4WriteRawBufMS(ac1Term, 3, 100);
if (!bGetMsg(m_strTmp, 2000, kCIDLib::False) || (m_strTmp != L"terminator,CR"))
{
return tCQCKit::ECommResults::LostConnection;
}
// We just use the ping method for this, and tell it to store the version
return ePing(kCIDLib::True);
}
tCQCKit::EDrvInitRes TGCIRESDriver::eInitializeImpl()
{
// Call our parent IR base drivers
TParent::eInitializeImpl();
//
// Make sure that we were configured for a serial connection. Otherwise,
// its a bad configuration.
//
const TCQCDriverObjCfg& cqcdcOurs = cqcdcThis();
if (cqcdcOurs.conncfgReal().clsIsA() != TCQCSerialConnCfg::clsThis())
{
facCQCKit().LogMsg
(
CID_FILE
, CID_LINE
, kKitErrs::errcDrv_BadConnCfgType
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::Config
, cqcdcOurs.conncfgReal().clsIsA()
, clsIsA()
, TCQCSerialConnCfg::clsThis()
);
return tCQCKit::EDrvInitRes::Failed;
}
//
// Its the right type so do the down cast and get the data out of it
// that we need.
//
const TCQCSerialConnCfg& conncfgSer
= static_cast<const TCQCSerialConnCfg&>(cqcdcOurs.conncfgReal());
m_strPort = conncfgSer.strPortPath();
m_cpcfgSerial = conncfgSer.cpcfgSerial();
// Clean up any existing port so it'll get recreated with new config
delete m_pcommGCIRE;
m_pcommGCIRE = 0;
//
// Register our couple of fields. We just provide one that indicates
// the training mode state, so that the client can display an
// indicator that shows whether the driver is in training mode or not.
//
TVector<TCQCFldDef> colFlds(8);
TCQCFldDef flddCmd;
//
// Create the fields that we need for a receiver only type of
// IR driver.
//
flddCmd.Set
(
TFacCQCIR::strFldName_FirmwareVer
, tCQCKit::EFldTypes::String
, tCQCKit::EFldAccess::Read
);
colFlds.objAdd(flddCmd);
flddCmd.Set
(
TFacCQCIR::strFldName_TrainingState
, tCQCKit::EFldTypes::Boolean
, tCQCKit::EFldAccess::Read
);
colFlds.objAdd(flddCmd);
// Tell our base class about our fields
SetFields(colFlds);
// Look up the ids of our fields, for efficiency
m_c4FldIdFirmwareVer = pflddFind
(
TFacCQCIR::strFldName_FirmwareVer
, kCIDLib::True
)->c4Id();
m_c4FldIdTrainingMode = pflddFind
(
TFacCQCIR::strFldName_TrainingState
, kCIDLib::True
)->c4Id();
//
// Set the poll time a little faster than normal, since all we are doing
// is listening for data coming in. We'll set 100ms for polls, and 5
// seconds for reconnection.
//
SetPollTimes(100, 5000);
//
// Crank up the actions processing thread if it's not already. It runs
// until we are unloaded pulling events out of the queue and processing
// them.
//
StartActionsThread();
//
// In our case we want to go to 'wait for config' mode, not wait for
// comm res, since we need to get configuration before we can go online.
//
return tCQCKit::EDrvInitRes::WaitConfig;
}
tCQCKit::ECommResults TGCIRESDriver::ePollDevice(TThread&)
{
tCQCKit::ECommResults eRes = tCQCKit::ECommResults::Success;
tCIDLib::TEncodedTime enctCur = TTime::enctNow();
if (bGetMsg(m_strPollMsg, 10, kCIDLib::False))
{
//
// See if we have reached the next event time, and if not, we just
// eat it. If we have, reset the next event time for the next round
// and process it.
//
if (enctCur >= m_enctNextEvent)
{
m_enctNextEvent = enctCur + GCIRES_DriverImpl::enctMinInterval;
ProcessSignal(m_strPollMsg);
}
//
// While there are events still waiting, eat them, since they
// will be the subsequent events from the same button press.
//
while (bGetMsg(m_strPollMsg, 100, kCIDLib::False));
}
else
{
// If we've not had any activity for a while, then ping it
if (enctCur > m_enctLastMsg + GCIRES_DriverImpl::enctPollInterval)
eRes = ePing(kCIDLib::False);
}
return eRes;
}
tCIDLib::TVoid TGCIRESDriver::EnterRecTrainingMode()
{
// If we aren't online, then throw
CheckOnline(CID_FILE, CID_LINE);
// We can't already be in training mode
if (m_bTrainingMode)
{
facCQCIR().ThrowErr
(
CID_FILE
, CID_LINE
, kIRErrs::errcTrain_AlreadyTraining
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::Already
, strMoniker()
);
}
//
// We make them wait until all the queued events are processed before
// they can do any training. It will only wait for a while and then
// throw if the queue doesn't empty.
//
WaitForActions();
// Ok, go and and set the training mode flag and the field
m_bTrainingMode = kCIDLib::True;
bStoreBoolFld(m_c4FldIdTrainingMode, m_bTrainingMode, kCIDLib::True);
// Clear out our current and previous training value fields
m_strTrainVal.Clear();
}
tCIDLib::TVoid TGCIRESDriver::ExitRecTrainingMode()
{
// If we aren't online, then throw, else lock and do it
CheckOnline(CID_FILE, CID_LINE);
if (!m_bTrainingMode)
{
facCQCIR().ThrowErr
(
CID_FILE
, CID_LINE
, kIRErrs::errcTrain_NotTraining
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::Already
, strMoniker()
);
}
m_bTrainingMode = kCIDLib::False;
bStoreBoolFld(m_c4FldIdTrainingMode, m_bTrainingMode, kCIDLib::True);
}
tCIDLib::TVoid TGCIRESDriver::ReleaseCommResource()
{
try
{
if (m_pcommGCIRE->bIsOpen())
m_pcommGCIRE->Close();
}
catch(const TError& errToCatch)
{
LogError(errToCatch, tCQCKit::EVerboseLvls::Medium);
}
}
tCIDLib::TVoid TGCIRESDriver::TerminateImpl()
{
// Call our parent class next
TParent::TerminateImpl();
}
// ---------------------------------------------------------------------------
// TGCIRESDriver: Private, non-virtual methods
// ---------------------------------------------------------------------------
//
// The signals we get are compressed, so we have to expand them out. We
// then use that info to create a hash which we format in the output
// string.
//
tCIDLib::TBoolean
TGCIRESDriver::bEncodeSignal(const TString& strSig, TString& strKeyToFill)
{
const tCIDLib::ERadices eRadix(tCIDLib::ERadices::Dec);
strKeyToFill.Clear();
// It should start with the prefix
if (!strSig.bStartsWith(m_strCmdPrefix))
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::Medium)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"The IR data did not start with the GC-IRE prefix"
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
return kCIDLib::False;
}
// We don't keep the prefix since it never changes
tCIDLib::TCard4 c4Index = m_strCmdPrefix.c4Length();
const tCIDLib::TCh* pszSrc = strSig.pszBufferAt(c4Index);
const tCIDLib::TCh* const pszEnd = pszSrc + (strSig.c4Length() - c4Index);
// Next we get a carrier frequency
m_strTmp.Clear();
while ((pszSrc < pszEnd) && (*pszSrc != kCIDLib::chComma))
m_strTmp.Append(*pszSrc++);
//
// Skip the comma and convert the frequency, though we aren't using
// it at this point. At least we verify it's a valid frequency number.
//
*pszSrc++;
tCIDLib::TCard4 c4Freq;
if (!m_strTmp.bToCard4(c4Freq, eRadix))
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::Medium)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"The IR frequency value was not valid"
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
return kCIDLib::False;
}
//
// Now we have to start pulling things in one character at a time.
// If we see a number, then it's got to be a pair, so we scan in
// up to the next comma, and then to the next comma or non-digit.
// For each pair we see, until we get four, we store them as the
// repeat pairs.
//
// If a non-digit, it's got to be A, B, C or D, and we pull out the
// appropriate repeat pair and copy that over.
//
const tCIDLib::TCard4 c4MaxPairs = 1024;
m_colPairs.RemoveAll();
TOOPair oopCur;
{
const tCIDLib::TCard4 c4MaxReps = 4;
tCIDLib::TCard4 c4RepCount = 0;
TOOPair aRepPairs[c4MaxReps];
while (pszSrc < pszEnd)
{
const tCIDLib::TCh chCur = *pszSrc;
if (TRawStr::bIsDigit(chCur))
{
if (m_colPairs.c4ElemCount() >= c4MaxPairs)
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::Medium)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"Maximum pair count was reached"
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
return kCIDLib::False;
}
//
// Scan forward to the next comma, all of which have to be
// digits.
//
m_strTmp.Clear();
while ((pszSrc < pszEnd) && TRawStr::bIsDigit(*pszSrc))
m_strTmp.Append(*pszSrc++);
// We had to hit a comma
if (*pszSrc != kCIDLib::chComma)
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::Medium)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"Expected a comma next in IR data"
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
return kCIDLib::False;
}
// Validate and store the on value
tCIDLib::TCard4 c4OnVal;
if (!m_strTmp.bToCard4(c4OnVal, eRadix))
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::Medium)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"On transition value was not a number"
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
return kCIDLib::False;
}
//
// Now move forward and go till we hit a comma or non-digit
// or the end.
//
m_strTmp.Clear();
pszSrc++;
while ((pszSrc < pszEnd) && TRawStr::bIsDigit(*pszSrc))
m_strTmp.Append(*pszSrc++);
if (pszSrc < pszEnd)
{
if ((*pszSrc != kCIDLib::chComma)
&& ((*pszSrc < kCIDLib::chLatin_A)
|| (*pszSrc > kCIDLib::chLatin_D)))
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::Medium)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"Expected a comma or repeat character"
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
return kCIDLib::False;
}
// If it was a comma, we can now skip over it
if (*pszSrc == kCIDLib::chComma)
pszSrc++;
}
// Validate and store the off value
tCIDLib::TCard4 c4OffVal;
if (!m_strTmp.bToCard4(c4OffVal, eRadix))
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::Medium)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"Off transition value was not a number"
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
return kCIDLib::False;
}
// If we've not filled the rep list yet, then do that
oopCur.Set(c4OnVal, c4OffVal);
if (c4RepCount < c4MaxReps)
aRepPairs[c4RepCount++] = oopCur;
// And add it to our list
m_colPairs.objAdd(oopCur);
}
else
{
// It's got to be a repeat pair, so look it up
const tCIDLib::TCard4 c4RepInd = (chCur - kCIDLib::chLatin_A);
if (c4RepInd >= c4RepCount)
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::Medium)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"Bad repeat character"
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
return kCIDLib::False;
}
// Copy over this pair and move forward
m_colPairs.objAdd(aRepPairs[c4RepInd]);
pszSrc++;
// If we are on a comma, move forward
if (*pszSrc == kCIDLib::chComma)
pszSrc++;
}
}
}
//
// Now let's generate the hash and format it out. We have to have
// at least 4 pairs, or we do nothing since it can't be anything
// meaningful.
//
const tCIDLib::TCard4 c4Pairs = m_colPairs.c4ElemCount();
tCIDLib::TCard4 c4Hash = 0;
if (c4Pairs > 4)
{
const tCIDLib::TCard4 c4Prime32 = 16777619;
// Start the hash with the hash basis value
c4Hash = 2166136261;
for (tCIDLib::TCard4 c4Index = 0; c4Index < c4Pairs - 1; c4Index++)
{
// Get the next two successive pairs
const TOOPair& oopCur = m_colPairs[c4Index];
const TOOPair& oopNext = m_colPairs[c4Index + 1];
//
// Compare the on and then off values and add their result to the
// hash. We break out if one of them is larger than 1000, which
// represents a long break.
//
tCIDLib::TCard4 c4Value = c4Compare(oopCur.m_c4On, oopNext.m_c4On);
c4Hash = (c4Hash * c4Prime32) ^ c4Value;
if (oopNext.m_c4On > 1000)
break;
c4Value = c4Compare(oopCur.m_c4Off, oopNext.m_c4Off);
c4Hash = (c4Hash * c4Prime32) ^ c4Value;
if (oopNext.m_c4Off > 1000)
break;
}
}
// Format the hash out to text
strKeyToFill.SetFormatted(c4Hash, tCIDLib::ERadices::Dec);
return kCIDLib::True;
}
// A helper to get a message from the device
tCIDLib::TBoolean
TGCIRESDriver::bGetMsg( TString& strToFill
, const tCIDLib::TCard4 c4WaitFor
, const tCIDLib::TBoolean bThrowIfNot)
{
//
// See if we get some data. It returns ASCII text, so we can use a
// helper method from the base driver class.
//
if (!bGetASCIITermMsg(*m_pcommGCIRE, c4WaitFor, 0xD, 0, strToFill))
{
if (bThrowIfNot)
{
facGCIRES().ThrowErr
(
CID_FILE
, CID_LINE
, kGCIREErrs::errcComm_Timeout
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::Timeout
);
}
return kCIDLib::False;
}
// Set the last message time stamp
m_enctLastMsg = TTime::enctNow();
return kCIDLib::True;
}
//
// Compare the on or off values of two successive pairs and return a
// relationship value.
//
tCIDLib::TCard4
TGCIRESDriver::c4Compare(const tCIDLib::TCard4 c4First
, const tCIDLib::TCard4 c4Second) const
{
if (c4Second < ((c4First * 65) / 100))
return 0;
if (c4First < ((c4Second * 65) / 100))
return 2;
return 1;
}
//
// Used to periodically ping the device if we don't hear anything for a
// while. Since it's getting the version, we also use it on connect, in
// which case we tell it to store the version in the firmware field.
//
tCQCKit::ECommResults TGCIRESDriver::ePing(const tCIDLib::TBoolean bStore)
{
// Ask the device for it's version info
static const tCIDLib::TCard1 ac1Send[] = { 0x67, 0x76, 0xD };
m_pcommGCIRE->c4WriteRawBufMS(ac1Send, 3, 100);
if (bGetMsg(m_strTmp, 2000, kCIDLib::False))
{
if (bStore)
{
m_strTmp.Prepend(L"Version ");
bStoreStringFld(m_c4FldIdFirmwareVer, m_strTmp, kCIDLib::True);
}
return tCQCKit::ECommResults::Success;
}
return tCQCKit::ECommResults::LostConnection;
}
//
// When the poll sees a message come in, it calls us here. WE process
// any messages that make up the incoming signal and queue the generated
// key, or store it as training data if in trailing mode.
//
tCIDLib::TVoid TGCIRESDriver::ProcessSignal(const TString& strMsg)
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::High)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"Raw IR event data"
, strMsg
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
// Encode the signal in our format
TString strKey;
if (bEncodeSignal(strMsg, strKey))
{
if (eVerboseLevel() >= tCQCKit::EVerboseLvls::High)
{
facGCIRES().LogMsg
(
CID_FILE
, CID_LINE
, L"IR signal was expanded successfully"
, m_strTmp
, tCIDLib::ESeverities::Status
, tCIDLib::EErrClasses::AppStatus
);
}
// It's a good signal. If training, then store it else queue it
if (m_bTrainingMode)
m_strTrainVal = strKey;
else
QueueRecEvent(strKey);
}
}
| 29.817016 | 83 | 0.520267 | MarkStega |
43b958a8dca6aad394949b97d4fc55e257bed184 | 7,002 | cpp | C++ | src/core/CL/kernels/CLSelectKernel.cpp | MaximMilashchenko/ComputeLibrary | 91ee4d0a9ef128b16936921470a0e3ffef347536 | [
"MIT"
] | 2,313 | 2017-03-24T16:25:28.000Z | 2022-03-31T03:00:30.000Z | src/core/CL/kernels/CLSelectKernel.cpp | MaximMilashchenko/ComputeLibrary | 91ee4d0a9ef128b16936921470a0e3ffef347536 | [
"MIT"
] | 952 | 2017-03-28T07:05:58.000Z | 2022-03-30T09:54:02.000Z | src/core/CL/kernels/CLSelectKernel.cpp | MaximMilashchenko/ComputeLibrary | 91ee4d0a9ef128b16936921470a0e3ffef347536 | [
"MIT"
] | 714 | 2017-03-24T22:21:51.000Z | 2022-03-18T19:49:57.000Z | /*
* Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
* 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 "src/core/CL/kernels/CLSelectKernel.h"
#include "arm_compute/core/CL/CLHelpers.h"
#include "arm_compute/core/CL/CLKernelLibrary.h"
#include "arm_compute/core/CL/ICLTensor.h"
#include "arm_compute/core/Helpers.h"
#include "arm_compute/core/TensorInfo.h"
#include "arm_compute/core/Utils.h"
#include "src/core/CL/CLValidate.h"
#include "src/core/helpers/AutoConfiguration.h"
#include "src/core/helpers/WindowHelpers.h"
#include "support/StringSupport.h"
namespace arm_compute
{
namespace
{
Status validate_arguments(const ITensorInfo *c, const ITensorInfo *x, const ITensorInfo *y, const ITensorInfo *output)
{
ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(c, x, y, output);
ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(x);
ARM_COMPUTE_RETURN_ERROR_ON(x->data_type() == DataType::UNKNOWN);
ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(x, y);
ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(x, y);
ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(c, 1, DataType::U8);
const bool is_same_rank = (c->tensor_shape().num_dimensions() == x->tensor_shape().num_dimensions());
ARM_COMPUTE_RETURN_ERROR_ON(is_same_rank && (x->tensor_shape() != c->tensor_shape()));
ARM_COMPUTE_RETURN_ERROR_ON(!is_same_rank && ((c->tensor_shape().num_dimensions() > 1) || (c->tensor_shape().x() != x->tensor_shape()[x->tensor_shape().num_dimensions() - 1])));
if(output->total_size() != 0)
{
ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(x, output);
ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(x, output);
}
return Status{};
}
} // namespace
CLSelectKernel::CLSelectKernel()
: _c(nullptr), _x(nullptr), _y(nullptr), _output(nullptr), _has_same_rank(false)
{
_type = CLKernelType::ELEMENTWISE;
}
void CLSelectKernel::configure(const CLCompileContext &compile_context, const ICLTensor *c, const ICLTensor *x, const ICLTensor *y, ICLTensor *output)
{
ARM_COMPUTE_ERROR_ON_NULLPTR(c, x, y, output);
ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(c->info(), x->info(), y->info(), output->info()));
_c = c;
_x = x;
_y = y;
_output = output;
_has_same_rank = (c->info()->tensor_shape().num_dimensions() == x->info()->tensor_shape().num_dimensions());
auto padding_info = get_padding_info({ c, x, y, output });
const unsigned int vec_size_x = adjust_vec_size(16 / x->info()->element_size(), x->info()->dimension(0));
const int vec_size_x_leftovers = output->info()->dimension(0) % vec_size_x;
// Set build options
CLBuildOptions build_opts;
build_opts.add_option("-DDATA_TYPE=" + get_cl_unsigned_type_from_element_size(x->info()->element_size()));
build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(vec_size_x));
build_opts.add_option("-DVEC_SIZE_LEFTOVER=" + support::cpp11::to_string(vec_size_x_leftovers));
// Create kernel
std::string kernel_name = "select";
if(_has_same_rank)
{
kernel_name += "_same_rank";
}
else
{
const bool is_input_rank_greater_than_two = x->info()->tensor_shape().num_dimensions() > 2;
if(is_input_rank_greater_than_two)
{
const size_t width = x->info()->tensor_shape().x();
const size_t height = x->info()->tensor_shape().y();
const size_t outer_size = x->info()->tensor_shape()[x->info()->tensor_shape().num_dimensions() - 1];
const size_t depth_size = x->info()->tensor_shape().total_size() / (width * height * outer_size);
build_opts.add_option("-DDEPTH_SIZE=" + support::cpp11::to_string(depth_size));
}
kernel_name += "_different_rank";
kernel_name += is_input_rank_greater_than_two ? "_n" : "_2";
}
_kernel = create_kernel(compile_context, kernel_name, build_opts.options());
// Configure kernel window
auto_init_if_empty(*output->info(), *x->info()->clone());
Window win = calculate_max_window(*x->info(), Steps(vec_size_x));
ICLKernel::configure_internal(win);
_config_id = "select_";
_config_id += string_from_data_type(x->info()->data_type());
_config_id += "_";
_config_id += support::cpp11::to_string(x->info()->dimension(0));
_config_id += "_";
_config_id += support::cpp11::to_string(x->info()->dimension(1));
_config_id += "_";
_config_id += support::cpp11::to_string(x->info()->dimension(2));
ARM_COMPUTE_ERROR_ON(has_padding_changed(padding_info));
}
Status CLSelectKernel::validate(const ITensorInfo *c, const ITensorInfo *x, const ITensorInfo *y, const ITensorInfo *output)
{
ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(c, x, y, output));
return Status{};
}
void CLSelectKernel::run(const arm_compute::Window &window, cl::CommandQueue &queue)
{
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window);
Window collapsed = window.collapse_if_possible(ICLKernel::window(), Window::DimZ);
Window slice = collapsed.first_slice_window_3D();
if(!_has_same_rank)
{
Window vector_slice = window.first_slice_window_1D();
vector_slice.set(Window::DimX, Window::Dimension(0, 0, 0));
unsigned int idx = 0;
add_1D_tensor_argument(idx, _c, vector_slice);
}
do
{
unsigned int idx = _has_same_rank ? 0 : num_arguments_per_1D_tensor();
if(_has_same_rank)
{
add_3D_tensor_argument(idx, _c, slice);
}
add_3D_tensor_argument(idx, _x, slice);
add_3D_tensor_argument(idx, _y, slice);
add_3D_tensor_argument(idx, _output, slice);
enqueue(queue, *this, slice, lws_hint());
}
while(collapsed.slide_window_slice_3D(slice));
}
} // namespace arm_compute
| 41.678571 | 181 | 0.695944 | MaximMilashchenko |
43bea1f8f7a0d534335f87fb25aead74209e37f9 | 49,605 | cpp | C++ | SourceCode/main.cpp | jdg534/VulkanEngine | ed7055691e86e4c534b5fe05e29ca30575d4e303 | [
"MIT"
] | null | null | null | SourceCode/main.cpp | jdg534/VulkanEngine | ed7055691e86e4c534b5fe05e29ca30575d4e303 | [
"MIT"
] | null | null | null | SourceCode/main.cpp | jdg534/VulkanEngine | ed7055691e86e4c534b5fe05e29ca30575d4e303 | [
"MIT"
] | null | null | null | #include <optional>
#include <iostream>
#include <fstream>
#include <string> // needed for checking validation layers
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <cassert>
#include <exception>
#include <cstdlib>
#include <glm/glm.hpp>
#define GLFW_INCLUDE_VULKAN
#ifdef _WINDOWS
#define VK_USE_PLATFORM_WIN32_KHR
#define GLFW_EXPOSE_NATIVE_WGL
#define GLFW_EXPOSE_NATIVE_WIN32
#endif // _WINDOWS
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#ifdef _WINDOWS
#include <Windows.h>
#endif // _WINDOWS
static const std::vector<const char*> s_validationLayers = { "VK_LAYER_KHRONOS_validation" }; // following tutorial structure, refactor once we're got a triangle on screen
static const std::vector<const char*> s_requiredPhysicalDeviceExtentions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME }; // these constraints are meant to be used on a created device, not during device creation
struct Vertex
{
glm::vec2 position;
glm::vec3 colour;
static VkVertexInputBindingDescription GetBindingDescription()
{
VkVertexInputBindingDescription bindingDesc = {};
bindingDesc.stride = sizeof(VkVertexInputBindingDescription);
bindingDesc.binding = 0;
bindingDesc.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
return bindingDesc;
}
static std::array<VkVertexInputAttributeDescription, 2> GetAttributeDescriptions()
{
std::array<VkVertexInputAttributeDescription, 2> attribDescs = {};
attribDescs[0].binding = 0;
attribDescs[0].location = 0;
attribDescs[0].format = VK_FORMAT_R32G32_SFLOAT;
attribDescs[0].offset = offsetof(Vertex, position);
attribDescs[1].binding = 0; // was 1, need to check docs
attribDescs[1].location = 1;
attribDescs[1].format = VK_FORMAT_R32G32B32_SFLOAT;
attribDescs[1].offset = offsetof(Vertex, colour);
return attribDescs;
}
};
class VulkanApp
{
public:
VulkanApp()
: m_windowWidth(800)
, m_windowHeight(600)
, m_window(nullptr)
, m_vulkanInstance(nullptr)
, m_vulkanPhysicalDevice(nullptr)
, m_vulkanLogicalDevice(nullptr)
, m_graphicsQueue(nullptr)
, m_surfaceToDrawTo(nullptr)
, m_presentQueue(nullptr)
, m_swapChain(nullptr)
, m_vertexShaderModule(nullptr)
, m_fragmentShaderModule(nullptr)
, m_pipeline(nullptr)
, m_pipelineLayout(nullptr)
, m_renderPass(nullptr)
, m_commandPool(nullptr)
, m_getImageTimeOutNanoSeconds(0)
, m_currentFrameSyncObjectIndex(0)
, m_frameBufferResized(false)
, m_vertexBuffer(nullptr)
, m_vertexBufferMemory(nullptr)
#if (NDEBUG)
, m_useVulkanValidationLayers(false) // release build
#else
, m_useVulkanValidationLayers(true) // debug build
#endif
{}
~VulkanApp()
{}
void Run()
{
Init();
MainLoop();
Shutdown();
}
private:
struct QueueFamilyIndices
{
std::optional<uint32_t> m_graphicsFamilyIndex;
std::optional<uint32_t> m_presentFamilyIndex;
bool ValueReady()
{
return m_graphicsFamilyIndex.has_value() && m_presentFamilyIndex.has_value();
}
};
struct SwapChainSupportDetails
{
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats;
std::vector<VkPresentModeKHR> presentModes;
};
void Init()
{
try
{
InitWindow();
InitVulkan();
}
catch (const std::exception& ex)
{
#ifdef _WINDOWS
OutputDebugString(ex.what());
#else
// non windows code here
#endif
}
m_getImageTimeOutNanoSeconds = static_cast<uint64_t>(std::powl(2, 64));
}
void InitWindow()
{
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
m_window = glfwCreateWindow(m_windowWidth, m_windowHeight, "Vulkan window", nullptr, nullptr);
glfwSetWindowUserPointer(m_window, this);
glfwSetFramebufferSizeCallback(m_window, OnFrameBufferResizeCallback);
}
void InitVulkan()
{
CreateVulkanInstance();
SetupVulkanDebugMessenger();
CreateSurfaceToDrawTo();
// QueryVulkanExtentions(); // add it back in if we need to check the extention strings
SelectVulkanDevice();
CreateLogicalVulkanDevice();
CreateSwapChain();
CreateImageViews();
CreateRenderPass();
CreateGraphicsPipeline();
CreateFrameBuffers();
CreateCommandPool();
CreateVertexBuffer();
CreateCommandBuffers();
CreateVulkanSyncObjects();
}
bool AreVulkanValidationLayersSupported()
{
uint32_t nLayers = 0;
vkEnumerateInstanceLayerProperties(&nLayers, nullptr);
std::vector<VkLayerProperties> availableLayers(nLayers);
vkEnumerateInstanceLayerProperties(&nLayers, availableLayers.data());
const std::string targetLayerStr = std::string(s_validationLayers[0]);
bool validationLayerFound = false;
for (uint32_t i = 0; i < nLayers && !validationLayerFound; ++i)
{
validationLayerFound = targetLayerStr == availableLayers[i].layerName;
}
return validationLayerFound;
}
std::vector<const char*> GetRequiredVulkanExtentions()
{
// Message callback
uint32_t glfwRequiredExtCount = 0;
const char** glfwExtCStrs;
glfwExtCStrs = glfwGetRequiredInstanceExtensions(&glfwRequiredExtCount);
std::vector<const char*> extCStrs(glfwExtCStrs, glfwExtCStrs + glfwRequiredExtCount);
if (AreVulkanValidationLayersSupported())
{
extCStrs.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
}
return extCStrs;
}
void CreateVulkanInstance()
{
if (m_useVulkanValidationLayers && !AreVulkanValidationLayersSupported())
{
throw std::runtime_error("tried to run with Vulkan validation layers, this setup doesn't support them.");
}
VkApplicationInfo appInfo = {};
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appInfo.pApplicationName = "Vulkan Triangle";
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
appInfo.pEngineName = "Learning Vulkan Engine";
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
appInfo.apiVersion = VK_API_VERSION_1_1;
VkInstanceCreateInfo instanceCreateInfo = {};
instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceCreateInfo.pApplicationInfo = &appInfo; // tutorial used stack memory, should be ok
const std::vector<const char*> requiredExtentions = GetRequiredVulkanExtentions();
instanceCreateInfo.enabledExtensionCount = static_cast<uint32_t>(requiredExtentions.size());
instanceCreateInfo.ppEnabledExtensionNames = requiredExtentions.data();
VkDebugUtilsMessengerCreateInfoEXT dbgCreateInfo = {};
// declared outside the if so doesn't go out of scope on calling vkCreateInstance()
if (m_useVulkanValidationLayers)
{
instanceCreateInfo.enabledLayerCount = static_cast<uint32_t>(s_validationLayers.size());
instanceCreateInfo.ppEnabledLayerNames = s_validationLayers.data();
PopulateVulkanDebugMessengerCreateInfo(dbgCreateInfo);
instanceCreateInfo.pNext = &dbgCreateInfo;
}
else
{
instanceCreateInfo.enabledLayerCount = 0;
instanceCreateInfo.pNext = nullptr;
}
VkResult instanceCreateRes = vkCreateInstance(&instanceCreateInfo, nullptr, &m_vulkanInstance); // the nullptr would be for an allocator callback function.
if (instanceCreateRes != VK_SUCCESS)
{
throw std::runtime_error("failed to create Vulkan instance");
}
std::cout << "Vulkan Instance created successfully" << std::endl;
}
void PopulateVulkanDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo)
{
createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
createInfo.pfnUserCallback = VulkanDebugCallback;
}
void SetupVulkanDebugMessenger()
{
if (!m_useVulkanValidationLayers)
return;
VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
PopulateVulkanDebugMessengerCreateInfo(createInfo);
if (CreateDebugUtilsMessengerEXT(m_vulkanInstance, &createInfo, nullptr, &m_vulkanDebugMessenger) != VK_SUCCESS)
{
throw std::runtime_error("Failed to set up a Vulkan debug messenger!");
}
}
void QueryVulkanExtentions()
{
// assumes m_vulkanInstance has been initialised
uint32_t nVulkanExtentions = 0;
vkEnumerateInstanceExtensionProperties(nullptr, &nVulkanExtentions, nullptr);
std::vector<VkExtensionProperties> extensions(nVulkanExtentions);
vkEnumerateInstanceExtensionProperties(nullptr, &nVulkanExtentions, extensions.data());
std::cout << nVulkanExtentions << " Vulkan extensions detected:\n";
for (const VkExtensionProperties& currExt: extensions)
{
std::cout << currExt.extensionName << std::endl;
}
}
void CreateSurfaceToDrawTo()
{
// this needs to be called before SelectVulkanDevice()
#ifdef _WINDOWS
// m_surfaceToDrawTo
VkWin32SurfaceCreateInfoKHR surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
surfaceCreateInfo.hwnd = glfwGetWin32Window(m_window);
surfaceCreateInfo.hinstance = GetModuleHandle(nullptr);
if (vkCreateWin32SurfaceKHR(m_vulkanInstance, &surfaceCreateInfo, nullptr, &m_surfaceToDrawTo) != VK_SUCCESS)
{
throw std::runtime_error("Failed to create surface to draw to");
}
// glfwCreateWindowSurface() easier way to do the above, function part of glfw...
#else
// non windows equivelent code here
#endif // _WINDOWS
}
void SelectVulkanDevice()
{
uint32_t deviceCount = 0;
vkEnumeratePhysicalDevices(m_vulkanInstance, &deviceCount, nullptr);
if (deviceCount == 0)
{
throw std::runtime_error("failed to find GPUs with Vulkan support!");
}
std::vector<VkPhysicalDevice> devices(deviceCount);
vkEnumeratePhysicalDevices(m_vulkanInstance, &deviceCount, devices.data());
uint32_t suitabilityScoreToBeat = 0;
uint32_t currentDeviceSuitabilityScore = 0;
for (const VkPhysicalDevice& currentDevice : devices)
{
currentDeviceSuitabilityScore = CalculateVulkanDeviceSuitability(currentDevice);
if (suitabilityScoreToBeat < currentDeviceSuitabilityScore)
{
m_vulkanPhysicalDevice = currentDevice;
suitabilityScoreToBeat = currentDeviceSuitabilityScore;
}
}
if (m_vulkanPhysicalDevice == nullptr)
{
throw std::runtime_error("Found Vulkan physical devices, but none were suitable");
}
m_graphicsQueueFamilyIndices = FindQueueFamilies(m_vulkanPhysicalDevice);
if (!m_graphicsQueueFamilyIndices.ValueReady())
{
throw std::runtime_error("Found Vulkan physical devices, but the device didn't support queue families");
}
}
QueueFamilyIndices FindQueueFamilies(VkPhysicalDevice device)
{
// finds command queues, just care about graphics. could expand to
QueueFamilyIndices indices;
uint32_t nQueueFamilies = 0;
vkGetPhysicalDeviceQueueFamilyProperties(device, &nQueueFamilies, nullptr);
if (nQueueFamilies == 0)
{
throw std::runtime_error("No Vulkan Queue families found");
}
std::vector<VkQueueFamilyProperties> queueFamilies(nQueueFamilies);
vkGetPhysicalDeviceQueueFamilyProperties(device, &nQueueFamilies, queueFamilies.data());
uint32_t i = 0;
for (const VkQueueFamilyProperties& currentQueueFamilyProperties : queueFamilies)
{
VkBool32 gotPresentSupport = false;
vkGetPhysicalDeviceSurfaceSupportKHR(device, i, m_surfaceToDrawTo, &gotPresentSupport);
if (currentQueueFamilyProperties.queueCount > 0 && currentQueueFamilyProperties.queueFlags & VK_QUEUE_GRAPHICS_BIT)
{
indices.m_graphicsFamilyIndex = i;
}
if (currentQueueFamilyProperties.queueCount > 0 && gotPresentSupport)
{
indices.m_presentFamilyIndex = i;
}
if (indices.ValueReady())
{
return indices;
}
++i;
}
return indices;
}
uint32_t CalculateVulkanDeviceSuitability(VkPhysicalDevice deviceToCheck)
{
uint32_t suitabilityScore = 0;
VkPhysicalDeviceProperties deviceProperties = {};
VkPhysicalDeviceFeatures deviceFeatures = {};
vkGetPhysicalDeviceProperties(deviceToCheck, &deviceProperties);
vkGetPhysicalDeviceFeatures(deviceToCheck, &deviceFeatures);
if (deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
{
suitabilityScore += 1000;
}
suitabilityScore += deviceProperties.limits.maxImageDimension2D;
// return 0 if note good enough checks at end
if (!deviceFeatures.geometryShader)
{
suitabilityScore = 0;
}
const bool deviceMeetsMinSupportExtentions = DeviceHasMinimumExtentionSupportLevel(deviceToCheck);
if (!deviceMeetsMinSupportExtentions)
{
suitabilityScore = 0;
}
bool swapChainSupportNeedsMet = DeviceHasMinimumSwapChainSupportLevel(deviceToCheck);
if (!swapChainSupportNeedsMet)
{
suitabilityScore = 0;
}
return suitabilityScore;
}
bool DeviceHasMinimumExtentionSupportLevel(VkPhysicalDevice deviceToCheck)
{
uint32_t nExtentions = 0;
vkEnumerateDeviceExtensionProperties(deviceToCheck, nullptr, &nExtentions, nullptr);
if (nExtentions == 0)
{
return false;
}
std::vector<VkExtensionProperties> extentionsPresent(nExtentions);
vkEnumerateDeviceExtensionProperties(deviceToCheck, nullptr, &nExtentions, extentionsPresent.data());
std::set<std::string> requiredExtentionsSet(s_requiredPhysicalDeviceExtentions.begin(), s_requiredPhysicalDeviceExtentions.end());
for (const VkExtensionProperties& extention : extentionsPresent)
{
requiredExtentionsSet.erase(extention.extensionName);
}
return requiredExtentionsSet.empty(); // if the set isn't empty there's a required extention that isn't supported
}
bool DeviceHasMinimumSwapChainSupportLevel(VkPhysicalDevice device)
{
SwapChainSupportDetails swapChainSupport = QueryPhysicalDeviceSwapChainSupport(device);
return !swapChainSupport.formats.empty() && !swapChainSupport.presentModes.empty();
}
void CreateLogicalVulkanDevice()
{
assert(m_graphicsQueueFamilyIndices.ValueReady());
std::set<uint32_t> queueFamilyIndices = { m_graphicsQueueFamilyIndices.m_graphicsFamilyIndex.value(), m_graphicsQueueFamilyIndices.m_presentFamilyIndex.value() };
const float queuePriority = 1.0f;
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
for (uint32_t queueFamilyIndex : queueFamilyIndices)
{
VkDeviceQueueCreateInfo queueCreateInfo = {};
queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueCreateInfo.queueFamilyIndex = m_graphicsQueueFamilyIndices.m_graphicsFamilyIndex.value();
queueCreateInfo.queueCount = 1;
queueCreateInfo.pQueuePriorities = &queuePriority;
queueCreateInfos.push_back(queueCreateInfo);
}
VkPhysicalDeviceFeatures deviceFeatures = {}; // populate with stuff from vkGetPhysicalDeviceFeatures(), for now keep it simple
VkDeviceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
createInfo.pQueueCreateInfos = queueCreateInfos.data();
createInfo.queueCreateInfoCount = static_cast<uint32_t>(queueCreateInfos.size());
createInfo.pEnabledFeatures = &deviceFeatures;
createInfo.enabledExtensionCount = static_cast<uint32_t>(s_requiredPhysicalDeviceExtentions.size());
createInfo.ppEnabledExtensionNames = s_requiredPhysicalDeviceExtentions.data();
if (m_useVulkanValidationLayers)
{
createInfo.enabledLayerCount = static_cast<uint32_t>(s_validationLayers.size());
createInfo.ppEnabledLayerNames = s_validationLayers.data();
}
else
{
createInfo.enabledLayerCount = 0;
}
if (vkCreateDevice(m_vulkanPhysicalDevice, &createInfo, nullptr, &m_vulkanLogicalDevice) != VK_SUCCESS)
{
throw std::runtime_error("failed to create logical vulkan device!");
}
vkGetDeviceQueue(m_vulkanLogicalDevice, m_graphicsQueueFamilyIndices.m_graphicsFamilyIndex.value(), 0, &m_graphicsQueue);
vkGetDeviceQueue(m_vulkanLogicalDevice, m_graphicsQueueFamilyIndices.m_presentFamilyIndex.value(), 0, &m_presentQueue);
if (m_graphicsQueue == nullptr || m_presentQueue == nullptr)
{
throw std::runtime_error("failed to get the graphics or present queue!");
}
else if (m_graphicsQueue == m_presentQueue)
{
std::cout << "The Vulkan Graphics queue and the Present queue are the same queue" << std::endl;
}
}
SwapChainSupportDetails QueryPhysicalDeviceSwapChainSupport(VkPhysicalDevice physicalDevice)
{
SwapChainSupportDetails details;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, m_surfaceToDrawTo, &details.capabilities);
uint32_t nSupportedFormats = 0;
vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surfaceToDrawTo, &nSupportedFormats, nullptr);
if (nSupportedFormats != 0)
{
details.formats.resize(nSupportedFormats);
vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surfaceToDrawTo, &nSupportedFormats, details.formats.data());
}
uint32_t nSupportedPresentModes = 0;
vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surfaceToDrawTo, &nSupportedPresentModes, nullptr);
if (nSupportedPresentModes != 0)
{
details.presentModes.resize(nSupportedPresentModes);
vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surfaceToDrawTo, &nSupportedPresentModes, details.presentModes.data());
}
return details;
}
static inline VkSurfaceFormatKHR SelectSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats)
{
for (const VkSurfaceFormatKHR& format : availableFormats)
{
if (format.format == VK_FORMAT_B8G8R8A8_UNORM && VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
{
return format;
}
}
return availableFormats[0]; // return first element if can't pick the optimal surface format
}
static inline VkPresentModeKHR SelectPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes)
{
for (const VkPresentModeKHR& currentPresentMode: availablePresentModes)
{
if (currentPresentMode == VK_PRESENT_MODE_MAILBOX_KHR)
{
return currentPresentMode;
}
}
return VK_PRESENT_MODE_FIFO_KHR;
}
VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& surfaceCapabilities)
{
// reduced due to compile errors
VkExtent2D extentToUse = { m_windowWidth, m_windowHeight };
return extentToUse;
}
void CreateSwapChain()
{
// validation for the swap chain support will have been used before reaching this function
SwapChainSupportDetails supportedSwapChainDetails = QueryPhysicalDeviceSwapChainSupport(m_vulkanPhysicalDevice);
VkSurfaceFormatKHR formatToCreateWith = SelectSwapSurfaceFormat(supportedSwapChainDetails.formats);
VkPresentModeKHR presentModeToCreateWith = SelectPresentMode(supportedSwapChainDetails.presentModes);
VkExtent2D extent = ChooseSwapExtent(supportedSwapChainDetails.capabilities);
uint32_t imageCountToCreateWith = supportedSwapChainDetails.capabilities.minImageCount + 1;
if (supportedSwapChainDetails.capabilities.maxImageCount > 0 && imageCountToCreateWith > supportedSwapChainDetails.capabilities.maxImageCount) {
imageCountToCreateWith = supportedSwapChainDetails.capabilities.maxImageCount;
}
VkSwapchainCreateInfoKHR swapChainCreateInfo = {};
swapChainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
swapChainCreateInfo.surface = m_surfaceToDrawTo;
swapChainCreateInfo.minImageCount = imageCountToCreateWith;
swapChainCreateInfo.imageFormat = formatToCreateWith.format;
swapChainCreateInfo.imageColorSpace = formatToCreateWith.colorSpace;
swapChainCreateInfo.imageExtent = extent;
swapChainCreateInfo.imageArrayLayers = 1;
swapChainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
QueueFamilyIndices indicesStruct = FindQueueFamilies(m_vulkanPhysicalDevice);
uint32_t queueIndeices[] = { indicesStruct.m_graphicsFamilyIndex.value(), indicesStruct.m_presentFamilyIndex.value() };
if (indicesStruct.m_graphicsFamilyIndex != indicesStruct.m_presentFamilyIndex)
{
swapChainCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
swapChainCreateInfo.queueFamilyIndexCount = 2;
swapChainCreateInfo.pQueueFamilyIndices = queueIndeices;
}
else
{
swapChainCreateInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
swapChainCreateInfo.queueFamilyIndexCount = 0; // Optional
swapChainCreateInfo.pQueueFamilyIndices = nullptr; // Optional
}
swapChainCreateInfo.preTransform = supportedSwapChainDetails.capabilities.currentTransform;
swapChainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
swapChainCreateInfo.presentMode = presentModeToCreateWith;
swapChainCreateInfo.clipped = VK_TRUE;
swapChainCreateInfo.oldSwapchain = VK_NULL_HANDLE;
#ifdef _WINDOWS
// _putenv("DISABLE_VK_LAYER_VALVE_steam_overlay_1=1");
#endif // _WINDOWS
// see: https://vulkan-tutorial.com/FAQ
if (vkCreateSwapchainKHR(m_vulkanLogicalDevice, &swapChainCreateInfo, nullptr, &m_swapChain) != VK_SUCCESS)
{
throw std::runtime_error("Failed to create swap chain");
}
// get additional swap chain info post creation
uint32_t nSwapChainImagesPostCreation = 0;
vkGetSwapchainImagesKHR(m_vulkanLogicalDevice, m_swapChain, &nSwapChainImagesPostCreation, nullptr);
m_swapChainImages.resize(nSwapChainImagesPostCreation);
vkGetSwapchainImagesKHR(m_vulkanLogicalDevice, m_swapChain, &nSwapChainImagesPostCreation, m_swapChainImages.data());
m_swapChainImageFormat = formatToCreateWith.format;
m_swapChainExtent = extent;
}
void CreateImageViews()
{
const size_t nSwapChainImages = m_swapChainImages.size();
m_swapChainImageViews.resize(nSwapChainImages);
for (size_t i = 0; i < nSwapChainImages; ++i)
{
VkImageViewCreateInfo imgViewCreateInfo = {};
imgViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
imgViewCreateInfo.image = m_swapChainImages[i];
imgViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
imgViewCreateInfo.format = m_swapChainImageFormat;
imgViewCreateInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
imgViewCreateInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
imgViewCreateInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
imgViewCreateInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
imgViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
imgViewCreateInfo.subresourceRange.baseMipLevel = 0;
imgViewCreateInfo.subresourceRange.levelCount = 1;
imgViewCreateInfo.subresourceRange.baseArrayLayer = 0;
imgViewCreateInfo.subresourceRange.layerCount = 1;
if (vkCreateImageView(m_vulkanLogicalDevice, &imgViewCreateInfo, nullptr, &m_swapChainImageViews[i]) != VK_SUCCESS)
{
throw std::runtime_error("Failed to create an image view");
}
}
}
void CreateGraphicsPipeline()
{
const std::vector<char> vertexShaderCode = ReadShader("Shaders/DefaultVert.spv");
const std::vector<char> fragmentShaderCode = ReadShader("Shaders/DefaultFrag.spv");
m_vertexShaderModule = CreateShaderModule(vertexShaderCode);
m_fragmentShaderModule = CreateShaderModule(fragmentShaderCode);
VkPipelineShaderStageCreateInfo vertexShaderStageCreateInfo = {};
vertexShaderStageCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vertexShaderStageCreateInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertexShaderStageCreateInfo.module = m_vertexShaderModule;
vertexShaderStageCreateInfo.pName = "main";
VkPipelineShaderStageCreateInfo fragmentShaderStageCreateInfo = {};
fragmentShaderStageCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fragmentShaderStageCreateInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fragmentShaderStageCreateInfo.module = m_fragmentShaderModule;
fragmentShaderStageCreateInfo.pName = "main";
VkPipelineShaderStageCreateInfo piplineStagesCreateInfo[] = { vertexShaderStageCreateInfo, fragmentShaderStageCreateInfo };
VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo = {};
vertexInputStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
VkVertexInputBindingDescription vertBindingDesc = Vertex::GetBindingDescription();
std::array< VkVertexInputAttributeDescription, 2> attribDesc = Vertex::GetAttributeDescriptions();
vertexInputStateCreateInfo.vertexBindingDescriptionCount = 1;
vertexInputStateCreateInfo.vertexAttributeDescriptionCount = static_cast<uint32_t>(attribDesc.size());
vertexInputStateCreateInfo.pVertexBindingDescriptions = &vertBindingDesc;
vertexInputStateCreateInfo.pVertexAttributeDescriptions = attribDesc.data();
VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCreateInfo = {};
inputAssemblyStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
inputAssemblyStateCreateInfo.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
inputAssemblyStateCreateInfo.primitiveRestartEnable = VK_FALSE;
VkViewport viewport = {};
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = static_cast<float>(m_swapChainExtent.width);
viewport.height = static_cast<float>(m_swapChainExtent.height);
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
VkRect2D scissorRect = {};
scissorRect.offset = {0, 0};
scissorRect.extent = m_swapChainExtent;
VkPipelineViewportStateCreateInfo viewportStateCreateInfo = {};
viewportStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportStateCreateInfo.viewportCount = 1;
viewportStateCreateInfo.pViewports = &viewport;
viewportStateCreateInfo.scissorCount = 1;
viewportStateCreateInfo.pScissors = &scissorRect;
VkPipelineRasterizationStateCreateInfo rasterisationStateCreateInfo = {};
rasterisationStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterisationStateCreateInfo.depthClampEnable = VK_FALSE;
rasterisationStateCreateInfo.rasterizerDiscardEnable = VK_FALSE; // VK_TRUE results on dropping the results before presenting to frame buffer
rasterisationStateCreateInfo.polygonMode = VK_POLYGON_MODE_FILL; // as opposed to lines or points
rasterisationStateCreateInfo.lineWidth = 1.0f;
rasterisationStateCreateInfo.cullMode = VK_CULL_MODE_BACK_BIT;
rasterisationStateCreateInfo.frontFace = VK_FRONT_FACE_CLOCKWISE;
rasterisationStateCreateInfo.depthBiasEnable = VK_FALSE;
rasterisationStateCreateInfo.depthBiasConstantFactor = rasterisationStateCreateInfo.depthBiasClamp = rasterisationStateCreateInfo.depthBiasSlopeFactor = 0.0f;
VkPipelineMultisampleStateCreateInfo multisampleStateCreateInfo = {};
multisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
multisampleStateCreateInfo.sampleShadingEnable = VK_FALSE;
multisampleStateCreateInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
multisampleStateCreateInfo.minSampleShading = 1.0f;
multisampleStateCreateInfo.pSampleMask = nullptr;
multisampleStateCreateInfo.alphaToCoverageEnable = VK_FALSE;
multisampleStateCreateInfo.alphaToOneEnable = VK_FALSE;
// add depth buffer state here once got to depth buffering stage of the tutorial
VkPipelineColorBlendAttachmentState colourBlendAttachmentState = {}; // should be named disabled colour blend attachment state
colourBlendAttachmentState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
colourBlendAttachmentState.blendEnable = VK_FALSE;
colourBlendAttachmentState.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
colourBlendAttachmentState.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO;
colourBlendAttachmentState.colorBlendOp = VK_BLEND_OP_ADD;
colourBlendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
colourBlendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
colourBlendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
VkPipelineColorBlendStateCreateInfo colourBlendStateCreateInfo = {};
colourBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colourBlendStateCreateInfo.logicOpEnable = VK_FALSE;
colourBlendStateCreateInfo.logicOp = VK_LOGIC_OP_COPY; // Optional
colourBlendStateCreateInfo.attachmentCount = 1;
colourBlendStateCreateInfo.pAttachments = &colourBlendAttachmentState;
// defaults to black no alpha
colourBlendStateCreateInfo.blendConstants[0] = 0.0f; // Optional
colourBlendStateCreateInfo.blendConstants[1] = 0.0f; // Optional
colourBlendStateCreateInfo.blendConstants[2] = 0.0f; // Optional
colourBlendStateCreateInfo.blendConstants[3] = 0.0f; // Optional
VkDynamicState pipelineDynamicStates[] =
{
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_LINE_WIDTH
};
VkPipelineDynamicStateCreateInfo pipelineDynamicStatesCreateInfo = {};
pipelineDynamicStatesCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
pipelineDynamicStatesCreateInfo.dynamicStateCount = 2;
pipelineDynamicStatesCreateInfo.pDynamicStates = pipelineDynamicStates;
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = {};
pipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutCreateInfo.setLayoutCount = 0; // Optional
pipelineLayoutCreateInfo.pSetLayouts = nullptr; // Optional
pipelineLayoutCreateInfo.pushConstantRangeCount = 0; // Optional
pipelineLayoutCreateInfo.pPushConstantRanges = nullptr; // Optional
if (vkCreatePipelineLayout(m_vulkanLogicalDevice, &pipelineLayoutCreateInfo, nullptr, &m_pipelineLayout) != VK_SUCCESS)
{
throw std::runtime_error("failed to create pipeline layout!");
}
VkGraphicsPipelineCreateInfo pipelineCreateInfo = {};
pipelineCreateInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineCreateInfo.stageCount = 2;
pipelineCreateInfo.pStages = piplineStagesCreateInfo;
pipelineCreateInfo.pVertexInputState = &vertexInputStateCreateInfo;
pipelineCreateInfo.pInputAssemblyState = &inputAssemblyStateCreateInfo;
pipelineCreateInfo.pViewportState = &viewportStateCreateInfo;
pipelineCreateInfo.pRasterizationState = &rasterisationStateCreateInfo;
pipelineCreateInfo.pMultisampleState = &multisampleStateCreateInfo;
pipelineCreateInfo.pColorBlendState = &colourBlendStateCreateInfo;
pipelineCreateInfo.layout = m_pipelineLayout;
pipelineCreateInfo.renderPass = m_renderPass;
pipelineCreateInfo.subpass = 0;
pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE;
pipelineCreateInfo.basePipelineIndex = -1;
if (vkCreateGraphicsPipelines(m_vulkanLogicalDevice, VK_NULL_HANDLE, 1, &pipelineCreateInfo, nullptr, &m_pipeline) != VK_SUCCESS)
{
throw std::runtime_error("Failed to create graphics pipeline.");
}
}
void CreateRenderPass()
{
VkAttachmentDescription colourAttachment = {};
colourAttachment.format = m_swapChainImageFormat;
colourAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
colourAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
colourAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
colourAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
colourAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colourAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
colourAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
VkAttachmentReference colourAttachmentRef = {};
colourAttachmentRef.attachment = 0;
colourAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkSubpassDescription subpass = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &colourAttachmentRef;
// VkRenderPass m_renderPass;
VkRenderPassCreateInfo renderPassCreateInfo = {};
renderPassCreateInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassCreateInfo.attachmentCount = 1;
renderPassCreateInfo.pAttachments = &colourAttachment;
renderPassCreateInfo.subpassCount = 1;
renderPassCreateInfo.pSubpasses = &subpass;
VkSubpassDependency renderPassDependency = {};
renderPassDependency.srcSubpass = VK_SUBPASS_EXTERNAL;
renderPassDependency.dstSubpass = 0;
renderPassDependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
renderPassDependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
renderPassDependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
renderPassCreateInfo.dependencyCount = 1;
renderPassCreateInfo.pDependencies = &renderPassDependency;
if (vkCreateRenderPass(m_vulkanLogicalDevice, &renderPassCreateInfo, nullptr, &m_renderPass) != VK_SUCCESS)
{
throw std::runtime_error("Failed to create the render pass");
}
}
static std::vector<char> ReadShader(const std::string& shaderFilePath)
{
std::ifstream shaderFile(shaderFilePath, std::ios::binary | std::ios::ate); // opens file in binary mode at end of file
if (!shaderFile.is_open())
{
throw std::runtime_error("Failed to open " + shaderFilePath);
}
const size_t shaderFileSize = shaderFile.tellg();
shaderFile.seekg(0);
std::vector<char> shaderCode(shaderFileSize);
shaderFile.read(shaderCode.data(), shaderFileSize);
shaderFile.close();
return shaderCode;
}
VkShaderModule CreateShaderModule(const std::vector<char>& shaderCode)
{
VkShaderModuleCreateInfo moduleCreateInfo = {};
moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
moduleCreateInfo.codeSize = shaderCode.size();
moduleCreateInfo.pCode = reinterpret_cast<const uint32_t*>(shaderCode.data());
VkShaderModule resultingModule = nullptr;
if (vkCreateShaderModule(m_vulkanLogicalDevice, &moduleCreateInfo, nullptr, &resultingModule) != VK_SUCCESS)
{
throw std::runtime_error("Failed to create shader module");
}
return resultingModule;
}
void CreateFrameBuffers()
{
const size_t nImagesInSwapChainViews = m_swapChainImageViews.size();
assert(nImagesInSwapChainViews > 0);
m_swapChainFrameBuffers.resize(nImagesInSwapChainViews);
for (size_t i = 0; i < nImagesInSwapChainViews; ++i)
{
VkFramebufferCreateInfo framebufferCreateInfo = {};
framebufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferCreateInfo.renderPass = m_renderPass;
framebufferCreateInfo.attachmentCount = 1;
framebufferCreateInfo.pAttachments = &m_swapChainImageViews[i];
framebufferCreateInfo.width = m_swapChainExtent.width;
framebufferCreateInfo.height = m_swapChainExtent.height;
framebufferCreateInfo.layers = 1;
if (vkCreateFramebuffer(m_vulkanLogicalDevice, &framebufferCreateInfo, nullptr, &m_swapChainFrameBuffers[i]) != VK_SUCCESS)
{
throw std::runtime_error("Failed to create frame buffer");
}
}
}
void CreateCommandPool()
{
QueueFamilyIndices queueFamilyIndices = FindQueueFamilies(m_vulkanPhysicalDevice);
VkCommandPoolCreateInfo cmdPoolCreateInfo = {};
cmdPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
cmdPoolCreateInfo.queueFamilyIndex = queueFamilyIndices.m_graphicsFamilyIndex.value();
cmdPoolCreateInfo.flags = 0;
if (vkCreateCommandPool(m_vulkanLogicalDevice, &cmdPoolCreateInfo, nullptr, &m_commandPool))
{
throw std::runtime_error("Failed to create command queue");
}
}
void CreateVertexBuffer()
{
m_vertices =
{
{{0.0f, -0.5f}, {1.0f, 1.0f, 1.0f}},
{{0.5f, 0.5f}, {0.0f, 1.0f, 0.0f}},
{{-0.5f, 0.5f}, {0.0f, 0.0f, 1.0f}},
};
VkBufferCreateInfo vertBufCreateInfo = {};
vertBufCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
vertBufCreateInfo.size = sizeof(m_vertices[0]) * m_vertices.size();
vertBufCreateInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
vertBufCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
if (vkCreateBuffer(m_vulkanLogicalDevice, &vertBufCreateInfo, nullptr, &m_vertexBuffer) != VK_SUCCESS)
{
throw std::runtime_error("failed to create vertex buffer");
}
// get the buffer memory requirements
VkMemoryRequirements bufMemRequirements = {};
vkGetBufferMemoryRequirements(m_vulkanLogicalDevice, m_vertexBuffer, &bufMemRequirements);
VkMemoryAllocateInfo vkMallocInfo = {};
vkMallocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
vkMallocInfo.allocationSize = bufMemRequirements.size;
vkMallocInfo.memoryTypeIndex = FindMemoryType(bufMemRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
if (vkAllocateMemory(m_vulkanLogicalDevice, &vkMallocInfo, nullptr, &m_vertexBufferMemory) != VK_SUCCESS)
{
throw std::runtime_error("Failed to allocate vertex buffer memory.");
}
vkBindBufferMemory(m_vulkanLogicalDevice, m_vertexBuffer, m_vertexBufferMemory, 0); // 0 is an offset, if non 0, make sure that (val % bufMemRequirements.alignment == 0)
// copy the values to the device memory
void* deviceMem = nullptr;
vkMapMemory(m_vulkanLogicalDevice, m_vertexBufferMemory, 0, vertBufCreateInfo.size, 0, &deviceMem);
std::memcpy(deviceMem, m_vertices.data(), static_cast<size_t>(vertBufCreateInfo.size));
vkUnmapMemory(m_vulkanLogicalDevice, m_vertexBufferMemory);
}
uint32_t FindMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags memProperties)
{
// get the physical device memory requirements
VkPhysicalDeviceMemoryProperties physicalDeviceMemProperties = {};
vkGetPhysicalDeviceMemoryProperties(m_vulkanPhysicalDevice, &physicalDeviceMemProperties);
for (uint32_t i = 0; i < physicalDeviceMemProperties.memoryTypeCount; ++i)
{
if ((typeFilter & (1 << i)) && (physicalDeviceMemProperties.memoryTypes[i].propertyFlags & memProperties) == memProperties)
{
return i;
}
}
throw std::runtime_error("Failed to find memory type that fits the flags");
return 0;
}
void CreateCommandBuffers()
{
const size_t nFrameBuffers = m_swapChainFrameBuffers.size();
m_commandBuffers.resize(nFrameBuffers);
VkCommandBufferAllocateInfo cmdBuffersAllocInfo = {};
cmdBuffersAllocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
cmdBuffersAllocInfo.commandPool = m_commandPool;
cmdBuffersAllocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
cmdBuffersAllocInfo.commandBufferCount = static_cast<uint32_t>(nFrameBuffers);
if (vkAllocateCommandBuffers(m_vulkanLogicalDevice, &cmdBuffersAllocInfo, m_commandBuffers.data()))
{
throw std::runtime_error("Failed to allocate Vulkan Command buffers");
}
// check if this is in the correct place.... sound like something that should be in a Draw() function
for (size_t i = 0; i < nFrameBuffers; ++i)
{
VkCommandBufferBeginInfo cmdBuffBeginInfo = {};
cmdBuffBeginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
if (vkBeginCommandBuffer(m_commandBuffers[i], &cmdBuffBeginInfo) != VK_SUCCESS)
{
throw std::runtime_error("Failed the start recording a command buffer!");
}
VkRenderPassBeginInfo renderPassBeginInfo = {};
renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassBeginInfo.framebuffer = m_swapChainFrameBuffers[i];
renderPassBeginInfo.renderPass = m_renderPass;
renderPassBeginInfo.renderArea.offset = { 0, 0 };
renderPassBeginInfo.renderArea.extent = m_swapChainExtent;
VkClearValue clearColour = { 0.0f, 0.0f, 0.0f, 1.0f}; // RGBA?
renderPassBeginInfo.pClearValues = &clearColour;
renderPassBeginInfo.clearValueCount = 1;
vkCmdBeginRenderPass(m_commandBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
// start draw commands
vkCmdBindPipeline(m_commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline);
VkDeviceSize offsets[] = { 0 };
vkCmdBindVertexBuffers(m_commandBuffers[i], 0, 1, &m_vertexBuffer, offsets);
vkCmdDraw(m_commandBuffers[i], static_cast<uint32_t>(m_vertices.size()), 1, 0, 0);
// end draw commands
vkCmdEndRenderPass(m_commandBuffers[i]);
if (vkEndCommandBuffer(m_commandBuffers[i]) != VK_SUCCESS)
{
throw std::runtime_error("Failed to finish recording commands to buffer");
}
}
}
void CreateVulkanSyncObjects()
{
VkSemaphoreCreateInfo semaphoneCreateInfo = {};
semaphoneCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
VkFenceCreateInfo fenceCreateInfo = {};
fenceCreateInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceCreateInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
m_imageAvailableSemaphones.resize(S_MAX_FRAMES_TO_PROCESS_AT_ONCE);
m_renderFinishedSemaphores.resize(S_MAX_FRAMES_TO_PROCESS_AT_ONCE);
m_activeFrameInProcessFences.resize(S_MAX_FRAMES_TO_PROCESS_AT_ONCE);
for (size_t i = 0; i < S_MAX_FRAMES_TO_PROCESS_AT_ONCE; ++i)
{
if (vkCreateSemaphore(m_vulkanLogicalDevice, &semaphoneCreateInfo, nullptr, &m_imageAvailableSemaphones[i]) != VK_SUCCESS
|| vkCreateSemaphore(m_vulkanLogicalDevice, &semaphoneCreateInfo, nullptr, &m_renderFinishedSemaphores[i]) != VK_SUCCESS
|| vkCreateFence(m_vulkanLogicalDevice, &fenceCreateInfo, nullptr, &m_activeFrameInProcessFences[i]) != VK_SUCCESS)
{
throw std::runtime_error("Failed to Create vulkan sync objects.");
}
}
}
void MainLoop()
{
while (!glfwWindowShouldClose(m_window))
{
glfwPollEvents();
// Update() float delta time here
Draw();
}
vkDeviceWaitIdle(m_vulkanLogicalDevice);
}
void Update(const float deltaSeconds)
{
// TODO add logic for updating scene objects here
}
void Draw()
{
// wait for fence
vkWaitForFences(m_vulkanLogicalDevice, 1, &m_activeFrameInProcessFences[m_currentFrameSyncObjectIndex], VK_TRUE, m_getImageTimeOutNanoSeconds);
// get next image index from swap chain
uint32_t imageIndex = 0; // not to be confused with m_currentFrameSemaphoreIndex
VkResult acquireNextImgRes = vkAcquireNextImageKHR(m_vulkanLogicalDevice, m_swapChain, m_getImageTimeOutNanoSeconds, m_imageAvailableSemaphones[m_currentFrameSyncObjectIndex], VK_NULL_HANDLE, &imageIndex);
if (acquireNextImgRes == VK_ERROR_OUT_OF_DATE_KHR)
{
RecreateSwapChain();
}
else if (acquireNextImgRes != VK_SUCCESS && acquireNextImgRes != VK_SUBOPTIMAL_KHR)
{
throw std::runtime_error("Failed to acquire swap chain image.");
}
// submit the command buffer for the frame
VkSubmitInfo submitInfo = {};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
VkPipelineStageFlags WaitStagesArray[] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitDstStageMask = WaitStagesArray;
submitInfo.pWaitSemaphores = &m_imageAvailableSemaphones[m_currentFrameSyncObjectIndex];
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &m_commandBuffers[imageIndex];
submitInfo.commandBufferCount = 1;
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &m_renderFinishedSemaphores[m_currentFrameSyncObjectIndex];
vkResetFences(m_vulkanLogicalDevice, 1, &m_activeFrameInProcessFences[m_currentFrameSyncObjectIndex]);
if (vkQueueSubmit(m_graphicsQueue, 1, &submitInfo, m_activeFrameInProcessFences[m_currentFrameSyncObjectIndex]) != VK_SUCCESS)
{
throw std::runtime_error("Failed to submit draw command buffer.");
}
// present the image final image
VkPresentInfoKHR presentInfo = {};
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = &m_renderFinishedSemaphores[m_currentFrameSyncObjectIndex];
presentInfo.swapchainCount = 1;
presentInfo.pImageIndices = &imageIndex;
presentInfo.pResults = nullptr;
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = &m_swapChain;
VkResult vkQueuePresentRes = vkQueuePresentKHR(m_presentQueue, &presentInfo);
if (vkQueuePresentRes == VK_ERROR_OUT_OF_DATE_KHR || vkQueuePresentRes == VK_SUBOPTIMAL_KHR || m_frameBufferResized)
{
m_frameBufferResized = false;
RecreateSwapChain();
}
++m_currentFrameSyncObjectIndex;
m_currentFrameSyncObjectIndex %= S_MAX_FRAMES_TO_PROCESS_AT_ONCE;
}
static void OnFrameBufferResizeCallback(GLFWwindow* window, int width, int height)
{
VulkanApp* appPtr = reinterpret_cast<VulkanApp*>(glfwGetWindowUserPointer(window));
appPtr->m_frameBufferResized = true;
appPtr->m_windowWidth = static_cast<uint32_t>(width);
appPtr->m_windowHeight = static_cast<uint32_t>(height);
}
void RecreateSwapChain()
{
int width = 0, height = 0;
while (width == 0 || height == 0)
{
glfwGetFramebufferSize(m_window, &width, &height);
glfwWaitEvents();
}
vkDeviceWaitIdle(m_vulkanLogicalDevice);
CleanupSwapChain();
CreateSwapChain();
CreateImageViews();
CreateRenderPass();
CreateGraphicsPipeline();
CreateFrameBuffers();
CreateCommandBuffers();
}
void CleanupSwapChain()
{
for (size_t i = 0; i < m_swapChainFrameBuffers.size(); ++i)
{
vkDestroyFramebuffer(m_vulkanLogicalDevice, m_swapChainFrameBuffers[i], nullptr);
}
vkFreeCommandBuffers(m_vulkanLogicalDevice, m_commandPool, static_cast<uint32_t>(m_commandBuffers.size()), m_commandBuffers.data());
vkDestroyPipeline(m_vulkanLogicalDevice, m_pipeline, nullptr);
vkDestroyPipelineLayout(m_vulkanLogicalDevice, m_pipelineLayout, nullptr);
vkDestroyRenderPass(m_vulkanLogicalDevice, m_renderPass, nullptr);
for (size_t i = 0; i < m_swapChainImageViews.size(); ++i)
{
vkDestroyImageView(m_vulkanLogicalDevice, m_swapChainImageViews[i], nullptr);
}
vkDestroySwapchainKHR(m_vulkanLogicalDevice, m_swapChain, nullptr);
}
void Shutdown()
{
CleanupSwapChain();
vkDestroyBuffer(m_vulkanLogicalDevice, m_vertexBuffer, nullptr);
vkFreeMemory(m_vulkanLogicalDevice, m_vertexBufferMemory, nullptr);
if (m_imageAvailableSemaphones.size() > 0 || m_renderFinishedSemaphores.size() > 0 || m_activeFrameInProcessFences.size() > 0)
{
for (size_t i = 0; i < S_MAX_FRAMES_TO_PROCESS_AT_ONCE; ++i)
{
vkDestroySemaphore(m_vulkanLogicalDevice, m_imageAvailableSemaphones[i], nullptr);
vkDestroySemaphore(m_vulkanLogicalDevice, m_renderFinishedSemaphores[i], nullptr);
vkDestroyFence(m_vulkanLogicalDevice, m_activeFrameInProcessFences[i], nullptr);
}
}
if (m_commandPool)
{
vkDestroyCommandPool(m_vulkanLogicalDevice, m_commandPool, nullptr);
}
if (m_vertexShaderModule)
{
vkDestroyShaderModule(m_vulkanLogicalDevice, m_vertexShaderModule, nullptr);
}
if (m_fragmentShaderModule)
{
vkDestroyShaderModule(m_vulkanLogicalDevice, m_fragmentShaderModule, nullptr);
}
if (m_useVulkanValidationLayers)
{
DestroyDebugUtilsMessengerEXT(m_vulkanInstance, m_vulkanDebugMessenger, nullptr);
}
if (m_vulkanLogicalDevice)
{
vkDestroyDevice(m_vulkanLogicalDevice, nullptr); // note that this also deletes the graphics queue
}
if (m_surfaceToDrawTo)
{
vkDestroySurfaceKHR(m_vulkanInstance, m_surfaceToDrawTo, nullptr);
}
vkDestroyInstance(m_vulkanInstance, nullptr);
glfwDestroyWindow(m_window);
glfwTerminate();
m_window = nullptr;
}
// Debug functions
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
auto func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
if (func != nullptr) {
return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
}
else {
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
}
static VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData)
{
if (messageSeverity >= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
{
// std::cout << ?
}
std::cerr << "validation layer: " << pCallbackData->pMessage << std::endl;
return VK_FALSE;
}
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator)
{
auto func = (PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
if (func != nullptr)
{
func(instance, debugMessenger, pAllocator);
}
}
// end of debug functions
uint32_t m_windowWidth;
uint32_t m_windowHeight;
GLFWwindow* m_window;
VkInstance m_vulkanInstance;
VkPhysicalDevice m_vulkanPhysicalDevice; //note that this gets deleted when destroying m_vulkanInstance
VkDevice m_vulkanLogicalDevice;
VkQueue m_graphicsQueue;
QueueFamilyIndices m_graphicsQueueFamilyIndices;
VkDebugUtilsMessengerEXT m_vulkanDebugMessenger;
const bool m_useVulkanValidationLayers;
// window surface creation variables
VkSurfaceKHR m_surfaceToDrawTo;
VkQueue m_presentQueue;
// swap chain variables, note need the enable to extensions
VkSwapchainKHR m_swapChain;
std::vector<VkImage> m_swapChainImages;
VkFormat m_swapChainImageFormat;
VkExtent2D m_swapChainExtent;
std::vector<VkImageView> m_swapChainImageViews;
VkShaderModule m_vertexShaderModule;
VkShaderModule m_fragmentShaderModule;
VkPipeline m_pipeline;
VkPipelineLayout m_pipelineLayout;
VkRenderPass m_renderPass;
std::vector<VkFramebuffer> m_swapChainFrameBuffers;
// use these to "send drawing commands"
VkCommandPool m_commandPool;
std::vector<VkCommandBuffer> m_commandBuffers;
// VkSemaphore m_imageReadyToDrawToSemaphore;
// VkSemaphore m_finishedDrawingSemaphore;
uint64_t m_getImageTimeOutNanoSeconds; // refactor name
static const size_t S_MAX_FRAMES_TO_PROCESS_AT_ONCE = 2;
std::vector<VkSemaphore> m_imageAvailableSemaphones;
std::vector<VkSemaphore> m_renderFinishedSemaphores;
std::vector<VkFence> m_activeFrameInProcessFences;
size_t m_currentFrameSyncObjectIndex;
bool m_frameBufferResized;
// start of Vertex buffers tutorial additions
VkBuffer m_vertexBuffer;
VkDeviceMemory m_vertexBufferMemory;
std::vector<Vertex> m_vertices;
};
int main()
{
VulkanApp vkApp;
vkApp.Run();
return 0;
} | 38.157692 | 207 | 0.796775 | jdg534 |
43bec92259a74e4d2e1f59d61e45f2b700b4f88d | 4,163 | hpp | C++ | include/Buffer.hpp | marcosivni/dicomlib | dd268d07368ff4f1ffd1f94cdaa1e2dbf30bc5c7 | [
"BSD-3-Clause"
] | null | null | null | include/Buffer.hpp | marcosivni/dicomlib | dd268d07368ff4f1ffd1f94cdaa1e2dbf30bc5c7 | [
"BSD-3-Clause"
] | null | null | null | include/Buffer.hpp | marcosivni/dicomlib | dd268d07368ff4f1ffd1f94cdaa1e2dbf30bc5c7 | [
"BSD-3-Clause"
] | null | null | null | #ifndef BUFFER_HPP_INCLUDE_GUARD_7711062925
#define BUFFER_HPP_INCLUDE_GUARD_7711062925
#include <queue>
#include <vector>
#include <boost/utility.hpp>
#include "socket/Base.hpp"
#include "socket/SwitchEndian.hpp"
#include "Types.hpp"
#include "Exceptions.hpp"
#include "Tag.hpp"
namespace dicom
{
//!Buffer for data going between the library and the network.
/*!
RATIONALE:
Because data is send to us across the wire in the form of a series
of PDVs (See Part 8, Annex E), it doesn't seem to be practical to read data
directly from a socket onto a dataset. An intermediatry 'holding stage' needs
to be introduced to pull together data from a series of PDVs and make it
ready to be fed onto a dataset. (An alternative solution might involve something
clever with callbacks, but I'm not really sure how.)
This functionality is provided by the Buffer class. I haven't spent much time
fine - tuning this class, I suspect that there is scope for considerable improvement
in terms of both speed and interface.
Note that this class also has a responsibility to perform endian corrections as data
is fed onto and off of it. (This means that it's duplicating functionality provided
by class Socket. Is there a way of abstracting this out into one place?)
-This abstraction has now mostly been done in socket/SwitchEndian.hpp
Lots of scope for optimization in this class - in fact, I suspect that
this is the biggest bottleneck in the library.
Should look at the interaction between this class and Socket - it might
be that we CAN do in-place endian switches, because once the data
has been written to the socket we don't care about it any more, so
corruption isn't an issue.
We tried using std::deque to implement this, but took a big performance hit.
vector is the only guaranteed contiguous container, which means we can
directly pass data to socket and file functions.
*/
class Buffer : public std::vector<BYTE>, boost::noncopyable
{
private:
/*!
We keep track of position using this variable rather than
an iterator, because vector iterators can get invalidated
by insertions. I'm not very happy about this.
*/
size_type I_;
public:
const int ExternalByteOrder_;
Buffer(int ExternalByteOrder):I_(0),ExternalByteOrder_(ExternalByteOrder){}
iterator position();
void Increment(size_type i);
Buffer& operator << (std::string data);
template <typename T>
Buffer& operator << (T data)
{
BOOST_STATIC_ASSERT(::boost::is_fundamental<T>::value);//because we're treating it as a byte stream.
if(ExternalByteOrder_!=__BYTE_ORDER && sizeof(T)!=1)
{
data=SwitchEndian<T>(data);
}
BYTE* pdata=reinterpret_cast<BYTE*> (&data);
for(BYTE* p=pdata;p<pdata+sizeof(T);p++)
{
push_back(*p);
}
return *this;
}
Buffer& operator << (Tag tag);
template<typename T>
Buffer& operator >> (T& data)
{
BOOST_STATIC_ASSERT(!(::boost::is_const<T>::value));//because we're writing to it.
BOOST_STATIC_ASSERT(::boost::is_fundamental<T>::value);//because we're treating it as a byte stream.
BYTE* pdata=reinterpret_cast<BYTE*> (&data);
if(int(sizeof(T))>(end()-position()))
throw dicom::exception("Attempting to read beyond end of buffer");
for(BYTE* p=pdata;p<pdata+sizeof(T);p++)//this is tedious to have to check.
{
//can we do this with a copy?
*p=*position();
I_++;
}
if(ExternalByteOrder_!=__BYTE_ORDER && sizeof(T)!=1)
data=SwitchEndian<T>(data);
return *this;
}
Buffer& operator >>(std::vector<UINT16>& data);
Buffer& operator >>(std::vector<BYTE>& data);
Buffer& operator >>(std::string& data);
Buffer& operator >>(Tag& tag);
//!Override this to make sure we keep I_ nice.
void clear();
/*!
This has now been optimized. We could probably combine the
two functions into a templated one if we really wanted to.
*/
void AddVector(const std::vector<BYTE>& data)
{
insert(this->end(),data.begin(),data.end());
}
void AddVector(const std::vector<UINT16>& data);
};
}
#endif //BUFFER_HPP_INCLUDE_GUARD_7711062925
| 29.94964 | 103 | 0.705741 | marcosivni |
43c29a45732ff52bc6e1b960a6c5abd6f1cfa805 | 455 | cpp | C++ | test/graph/diameter.cpp | taklimone/library | 5819a5f4d6da4e52d6ab583fdf084045f992e708 | [
"MIT"
] | null | null | null | test/graph/diameter.cpp | taklimone/library | 5819a5f4d6da4e52d6ab583fdf084045f992e708 | [
"MIT"
] | null | null | null | test/graph/diameter.cpp | taklimone/library | 5819a5f4d6da4e52d6ab583fdf084045f992e708 | [
"MIT"
] | null | null | null | #define PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_A
#include "graph/diameter.hpp"
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n; cin >> n;
vector<vector<edge<int>>> G(n, vector<edge<int>>());
for(int i = 1; i < n; ++i) {
int s, t, w;
cin >> s >> t >> w;
G[s].push_back({t, w});
G[t].push_back({s, w});
}
cout << diameter<int>(G) << endl;
} | 23.947368 | 80 | 0.551648 | taklimone |
43c4a2f2d53aee512dd56e575332e16957866321 | 334 | cpp | C++ | PETCS/Basic/ccc13j1.cpp | dl4us/Competitive-Programming-1 | d42fab3bd68168adbe4b5f594f19ee5dfcd1389b | [
"MIT"
] | null | null | null | PETCS/Basic/ccc13j1.cpp | dl4us/Competitive-Programming-1 | d42fab3bd68168adbe4b5f594f19ee5dfcd1389b | [
"MIT"
] | null | null | null | PETCS/Basic/ccc13j1.cpp | dl4us/Competitive-Programming-1 | d42fab3bd68168adbe4b5f594f19ee5dfcd1389b | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int x, y;
int main() {
cin.sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("../../input.txt", "r", stdin);
freopen("../../output.txt", "w", stdout);
#endif
cin >> x >> y;
cout << y + (y-x) << "\n";
return 0;
}
| 20.875 | 46 | 0.497006 | dl4us |
43ca0bb4ef12d60f9965ee6a52e04de40d77a8ab | 402 | cpp | C++ | src/examples/4_remote_control.cpp | MartinRobomaze/Srobko2 | 807361ce5ee404ae7f976da3b14b3cb0522a9aa6 | [
"MIT"
] | 1 | 2021-06-10T08:27:42.000Z | 2021-06-10T08:27:42.000Z | src/examples/4_remote_control.cpp | MartinRobomaze/Srobko2 | 807361ce5ee404ae7f976da3b14b3cb0522a9aa6 | [
"MIT"
] | 2 | 2021-06-07T13:01:46.000Z | 2021-06-07T13:21:19.000Z | src/examples/4_remote_control.cpp | MartinRobomaze/Srobko2 | 807361ce5ee404ae7f976da3b14b3cb0522a9aa6 | [
"MIT"
] | null | null | null | #include <Arduino.h>
#include <robot/radio.h>
#include <robot/motors.h>
#include <robot/types.h>
Radio radio;
Motors motors;
void setup() {
}
void loop() {
RobotPosition position;
// Precitaj data z ovladaca.
bool newData = radio.readData(position);
// Ak si dostal nove data.
if (newData) {
// Nastav motory na prijatu poziciu.
motors.move(position);
}
}
| 16.08 | 44 | 0.636816 | MartinRobomaze |
43ca8607192ae4236d98242452402be1a4046626 | 752 | cpp | C++ | OrionUO/DateTimeStamp.cpp | shiryux/UOA-OrionUO | fd81d57db51efd39ecfaaa19fd0fb881bde8fef8 | [
"MIT"
] | null | null | null | OrionUO/DateTimeStamp.cpp | shiryux/UOA-OrionUO | fd81d57db51efd39ecfaaa19fd0fb881bde8fef8 | [
"MIT"
] | null | null | null | OrionUO/DateTimeStamp.cpp | shiryux/UOA-OrionUO | fd81d57db51efd39ecfaaa19fd0fb881bde8fef8 | [
"MIT"
] | null | null | null | // This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
/***********************************************************************************
**
** DateTimeStamp.cpp
**
** Copyright (C) September 2017 Hotride
**
************************************************************************************
*/
//----------------------------------------------------------------------------------
#include "stdafx.h"
//----------------------------------------------------------------------------------
string GetBuildDateTimeStamp()
{
return string(__DATE__ " " __TIME__);
}
//----------------------------------------------------------------------------------
| 39.578947 | 84 | 0.307181 | shiryux |
43ce051f8325bc485ae60cfb71bdbcf31a41ef93 | 4,013 | hpp | C++ | include/nuls/system/wallet/hd_public.hpp | ccccbjcn/nuls-v2-cplusplus-sdk | 3d5a76452fe0673eba490b26e5a95fea3d5788df | [
"MIT"
] | 1 | 2020-04-26T07:32:52.000Z | 2020-04-26T07:32:52.000Z | include/nuls/system/wallet/hd_public.hpp | CCC-NULS/nuls-cplusplus-sdk | 3d5a76452fe0673eba490b26e5a95fea3d5788df | [
"MIT"
] | null | null | null | include/nuls/system/wallet/hd_public.hpp | CCC-NULS/nuls-cplusplus-sdk | 3d5a76452fe0673eba490b26e5a95fea3d5788df | [
"MIT"
] | null | null | null | /**
* Copyright (c) 2020 libnuls developers (see AUTHORS)
*
* This file is part of libnuls.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBNULS_SYSTEM_WALLET_HD_PUBLIC_KEY_HPP
#define LIBNULS_SYSTEM_WALLET_HD_PUBLIC_KEY_HPP
#include <cstdint>
#include <iostream>
#include <string>
#include <nuls/system/define.hpp>
#include <nuls/system/math/elliptic_curve.hpp>
#include <nuls/system/utility/data.hpp>
#include <nuls/system/wallet/ec_public.hpp>
namespace libnuls {
namespace system {
namespace wallet {
/// A constant used in key derivation.
static BC_CONSTEXPR uint32_t hd_first_hardened_key = 1 << 31;
/// An hd key chain code.
static BC_CONSTEXPR size_t hd_chain_code_size = 32;
typedef byte_array<hd_chain_code_size> hd_chain_code;
/// A decoded hd public or private key.
static BC_CONSTEXPR size_t hd_key_size = 82;
typedef byte_array<hd_key_size> hd_key;
/// Key derivation information used in the serialization format.
struct BC_API hd_lineage
{
uint64_t prefixes;
uint8_t depth;
uint32_t parent_fingerprint;
uint32_t child_number;
bool operator==(const hd_lineage& other) const;
bool operator!=(const hd_lineage& other) const;
};
class hd_private;
/// An extended public key, as defined by BIP 32.
class BC_API hd_public
{
public:
static const uint32_t mainnet;
static const uint32_t testnet;
static uint32_t to_prefix(uint64_t prefixes)
{
return prefixes & 0x00000000FFFFFFFF;
}
/// Constructors.
hd_public();
hd_public(const hd_public& other);
hd_public(const hd_key& public_key);
hd_public(const hd_key& public_key, uint32_t prefix);
hd_public(const std::string& encoded);
hd_public(const std::string& encoded, uint32_t prefix);
/// Operators.
bool operator<(const hd_public& other) const;
bool operator==(const hd_public& other) const;
bool operator!=(const hd_public& other) const;
hd_public& operator=(const hd_public& other);
friend std::istream& operator>>(std::istream& in, hd_public& to);
friend std::ostream& operator<<(std::ostream& out,
const hd_public& of);
/// Cast operators.
operator bool() const;
operator const ec_compressed&() const;
/// Serializer.
std::string encoded() const;
/// Accessors.
const hd_chain_code& chain_code() const;
const hd_lineage& lineage() const;
const ec_compressed& point() const;
/// Methods.
hd_key to_hd_key() const;
hd_public derive_public(uint32_t index) const;
protected:
/// Factories.
static hd_public from_secret(const ec_secret& secret,
const hd_chain_code& chain_code, const hd_lineage& lineage);
/// Helpers.
uint32_t fingerprint() const;
/// Members.
/// These should be const, apart from the need to implement assignment.
bool valid_;
hd_chain_code chain_;
hd_lineage lineage_;
ec_compressed point_;
private:
static hd_public from_key(const hd_key& public_key);
static hd_public from_string(const std::string& encoded);
static hd_public from_key(const hd_key& public_key, uint32_t prefix);
static hd_public from_string(const std::string& encoded, uint32_t prefix);
hd_public(const ec_compressed& point,
const hd_chain_code& chain_code, const hd_lineage& lineage);
};
} // namespace wallet
} // namespace system
} // namespace libnuls
#endif
| 29.947761 | 78 | 0.725392 | ccccbjcn |
43d3a7d04a81812ca3a8e56785fcb6aad037f723 | 13,365 | hpp | C++ | test/Mesh/test_unionMeshSegment.hpp | fvicini/gedim | c38cad9c40e7edabb6ea9da94599152d5a6542b0 | [
"MIT"
] | null | null | null | test/Mesh/test_unionMeshSegment.hpp | fvicini/gedim | c38cad9c40e7edabb6ea9da94599152d5a6542b0 | [
"MIT"
] | null | null | null | test/Mesh/test_unionMeshSegment.hpp | fvicini/gedim | c38cad9c40e7edabb6ea9da94599152d5a6542b0 | [
"MIT"
] | null | null | null | #ifndef __TEST_UnionMeshSegment_H
#define __TEST_UnionMeshSegment_H
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <gmock/gmock-matchers.h>
#include "GeometryUtilities.hpp"
#include "IntersectorMesh2DSegment.hpp"
#include "UnionMeshSegment.hpp"
using namespace testing;
using namespace std;
namespace GedimUnitTesting
{
TEST(TestUnionMeshSegment, TestUnionMeshSegment)
{
try
{
Gedim::GeometryUtilitiesConfig geometryUtilitiesConfig;
Gedim::GeometryUtilities geometryUtilities(geometryUtilitiesConfig);
// unify simple two points mesh
{
Gedim::IntersectorMesh2DSegment::IntersectionMesh meshOne;
Gedim::IntersectorMesh2DSegment::IntersectionMesh meshTwo;
meshOne.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
0.0,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshOne.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
1.0,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshTwo.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
0.0,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshTwo.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
1.0,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
vector<double> curvilinearCoordinatesMeshOne;
vector<double> curvilinearCoordinatesMeshTwo;
Gedim::IntersectorMesh2DSegment::ToCurvilinearCoordinates(meshOne, curvilinearCoordinatesMeshOne);
Gedim::IntersectorMesh2DSegment::ToCurvilinearCoordinates(meshTwo, curvilinearCoordinatesMeshTwo);
Gedim::UnionMeshSegment UnionMeshSegment(geometryUtilities);
Gedim::UnionMeshSegment::UnionMesh result;
ASSERT_NO_THROW(UnionMeshSegment.CreateUnionMesh(curvilinearCoordinatesMeshOne,
curvilinearCoordinatesMeshTwo,
result));
EXPECT_EQ(result.Points.size(), 2);
EXPECT_EQ(result.Points[0.0000000000000000e+00].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Both);
EXPECT_EQ(result.Points[0.0000000000000000e+00].MeshIndices.size(), 2);
EXPECT_EQ(result.Points[0.0000000000000000e+00].MeshIndices[0], 0);
EXPECT_EQ(result.Points[0.0000000000000000e+00].MeshIndices[1], 0);
EXPECT_EQ(result.Points[1.0000000000000000e+00].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Both);
EXPECT_EQ(result.Points[1.0000000000000000e+00].MeshIndices.size(), 2);
EXPECT_EQ(result.Points[1.0000000000000000e+00].MeshIndices[0], 1);
EXPECT_EQ(result.Points[1.0000000000000000e+00].MeshIndices[1], 1);
EXPECT_EQ(result.Segments.size(), 1);
EXPECT_EQ(result.Segments[0].Points, vector<double>({ 0.0000000000000000e+00, 1.0000000000000000e+00 }));
EXPECT_EQ(result.Segments[0].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::Both);
EXPECT_EQ(result.Segments[0].MeshIndices, vector<unsigned int>({ 0, 0 }));
}
// unify four points mesh with four points mesh
{
Gedim::IntersectorMesh2DSegment::IntersectionMesh meshOne;
Gedim::IntersectorMesh2DSegment::IntersectionMesh meshTwo;
meshOne.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
0.0,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshOne.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
0.25,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshOne.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
0.5,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshOne.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
1.0,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshTwo.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
0.0,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshTwo.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
0.5,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshTwo.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
0.75,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
meshTwo.Points.insert(pair<double,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint>(
1.0,
Gedim::IntersectorMesh2DSegment::IntersectionMesh::IntersectionMeshPoint()));
vector<double> curvilinearCoordinatesMeshOne;
vector<double> curvilinearCoordinatesMeshTwo;
Gedim::IntersectorMesh2DSegment::ToCurvilinearCoordinates(meshOne, curvilinearCoordinatesMeshOne);
Gedim::IntersectorMesh2DSegment::ToCurvilinearCoordinates(meshTwo, curvilinearCoordinatesMeshTwo);
Gedim::UnionMeshSegment UnionMeshSegment(geometryUtilities);
Gedim::UnionMeshSegment::UnionMesh result;
ASSERT_NO_THROW(UnionMeshSegment.CreateUnionMesh(curvilinearCoordinatesMeshOne,
curvilinearCoordinatesMeshTwo,
result));
EXPECT_EQ(result.Points.size(), 5);
EXPECT_EQ(result.Points[0.0000000000000000e+00].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Both);
EXPECT_EQ(result.Points[0.0000000000000000e+00].MeshIndices.size(), 2);
EXPECT_EQ(result.Points[0.0000000000000000e+00].MeshIndices[0], 0);
EXPECT_EQ(result.Points[0.0000000000000000e+00].MeshIndices[1], 0);
EXPECT_EQ(result.Points[2.5000000000000000e-01].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::First);
EXPECT_EQ(result.Points[2.5000000000000000e-01].MeshIndices.size(), 2);
EXPECT_EQ(result.Points[2.5000000000000000e-01].MeshIndices[0], 1);
EXPECT_EQ(result.Points[5.0000000000000000e-01].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Both);
EXPECT_EQ(result.Points[5.0000000000000000e-01].MeshIndices.size(), 2);
EXPECT_EQ(result.Points[5.0000000000000000e-01].MeshIndices[0], 2);
EXPECT_EQ(result.Points[5.0000000000000000e-01].MeshIndices[1], 1);
EXPECT_EQ(result.Points[7.5000000000000000e-01].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Second);
EXPECT_EQ(result.Points[7.5000000000000000e-01].MeshIndices.size(), 2);
EXPECT_EQ(result.Points[7.5000000000000000e-01].MeshIndices[1], 2);
EXPECT_EQ(result.Points[1.0000000000000000e+00].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Both);
EXPECT_EQ(result.Points[1.0000000000000000e+00].MeshIndices.size(), 2);
EXPECT_EQ(result.Points[1.0000000000000000e+00].MeshIndices[0], 3);
EXPECT_EQ(result.Points[1.0000000000000000e+00].MeshIndices[1], 3);
EXPECT_EQ(result.Segments.size(), 4);
EXPECT_EQ(result.Segments[0].Points, vector<double>({ 0.0000000000000000e+00, 2.5000000000000000e-01 }));
EXPECT_EQ(result.Segments[0].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::Both);
EXPECT_EQ(result.Segments[0].MeshIndices, vector<unsigned int>({ 0, 0 }));
EXPECT_EQ(result.Segments[1].Points, vector<double>({ 2.5000000000000000e-01, 5.0000000000000000e-01 }));
EXPECT_EQ(result.Segments[1].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::Both);
EXPECT_EQ(result.Segments[1].MeshIndices, vector<unsigned int>({ 1, 0 }));
EXPECT_EQ(result.Segments[2].Points, vector<double>({ 5.0000000000000000e-01, 7.5000000000000000e-01 }));
EXPECT_EQ(result.Segments[2].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::Both);
EXPECT_EQ(result.Segments[2].MeshIndices, vector<unsigned int>({ 2, 1 }));
EXPECT_EQ(result.Segments[3].Points, vector<double>({ 7.5000000000000000e-01, 1.0000000000000000e+00 }));
EXPECT_EQ(result.Segments[3].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::Both);
EXPECT_EQ(result.Segments[3].MeshIndices, vector<unsigned int>({ 2, 2 }));
}
// unify three points mesh with three points mesh
{
vector<double> curvilinearCoordinatesMeshOne = { 0.25, 0.75, 1.0 };
vector<double> curvilinearCoordinatesMeshTwo = { 0.0, 0.5, 0.75 };
Gedim::UnionMeshSegment UnionMeshSegment(geometryUtilities);
Gedim::UnionMeshSegment::UnionMesh result;
ASSERT_NO_THROW(UnionMeshSegment.CreateUnionMesh(curvilinearCoordinatesMeshOne,
curvilinearCoordinatesMeshTwo,
result));
EXPECT_EQ(result.Points.size(), 5);
EXPECT_EQ(result.Points[0.0000000000000000e+00].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Second);
EXPECT_EQ(result.Points[0.0000000000000000e+00].MeshIndices, vector<unsigned int>({ 0, 0 }));
EXPECT_EQ(result.Points[2.5000000000000000e-01].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::First);
EXPECT_EQ(result.Points[2.5000000000000000e-01].MeshIndices, vector<unsigned int>({ 0, 0 }));
EXPECT_EQ(result.Points[5.0000000000000000e-01].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Second);
EXPECT_EQ(result.Points[5.0000000000000000e-01].MeshIndices, vector<unsigned int>({ 0, 1 }));
EXPECT_EQ(result.Points[7.5000000000000000e-01].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::Both);
EXPECT_EQ(result.Points[7.5000000000000000e-01].MeshIndices, vector<unsigned int>({ 1, 2 }));
EXPECT_EQ(result.Points[1.0000000000000000e+00].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshPoint::UnionMeshPoint::Types::First);
EXPECT_EQ(result.Points[1.0000000000000000e+00].MeshIndices, vector<unsigned int>({ 2, 0 }));
EXPECT_EQ(result.Segments.size(), 4);
EXPECT_EQ(result.Segments[0].Points, vector<double>({ 0.0000000000000000e+00, 2.5000000000000000e-01 }));
EXPECT_EQ(result.Segments[0].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::Second);
EXPECT_EQ(result.Segments[0].MeshIndices, vector<unsigned int>({ 0, 0 }));
EXPECT_EQ(result.Segments[1].Points, vector<double>({ 2.5000000000000000e-01, 5.0000000000000000e-01 }));
EXPECT_EQ(result.Segments[1].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::Both);
EXPECT_EQ(result.Segments[1].MeshIndices, vector<unsigned int>({ 0, 0 }));
EXPECT_EQ(result.Segments[2].Points, vector<double>({ 5.0000000000000000e-01, 7.5000000000000000e-01 }));
EXPECT_EQ(result.Segments[2].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::Both);
EXPECT_EQ(result.Segments[2].MeshIndices, vector<unsigned int>({ 0, 1 }));
EXPECT_EQ(result.Segments[3].Points, vector<double>({ 7.5000000000000000e-01, 1.0000000000000000e+00 }));
EXPECT_EQ(result.Segments[3].Type, Gedim::UnionMeshSegment::UnionMesh::UnionMeshSegment::Types::First);
EXPECT_EQ(result.Segments[3].MeshIndices, vector<unsigned int>({ 1, 0 }));
}
}
catch (const exception& exception)
{
cerr<< exception.what()<< endl;
FAIL();
}
}
}
#endif // __TEST_UnionMeshSegment_H
| 65.195122 | 145 | 0.665245 | fvicini |
43d5af569de41d3d49d9f9032d8f600bf66ea3c6 | 881 | cpp | C++ | interview-prep/nth-fibonacci.cpp | boringwave/Cookbook | 3778b2d1a8ee99a733560f29ae3a4ee986170d01 | [
"MIT"
] | null | null | null | interview-prep/nth-fibonacci.cpp | boringwave/Cookbook | 3778b2d1a8ee99a733560f29ae3a4ee986170d01 | [
"MIT"
] | null | null | null | interview-prep/nth-fibonacci.cpp | boringwave/Cookbook | 3778b2d1a8ee99a733560f29ae3a4ee986170d01 | [
"MIT"
] | null | null | null | #include <iostream>
using namespace std;
// recursion will limit this at larger numbers
int find_nth(int n)
{
if( n == 0 )
return 0;
else if(n == 1)
return 1;
else
return find_nth(n-1) + find_nth(n-2);
}
// traditional
int find_nth_2(int n)
{
/* Initial values */
int a = 1;
int b = 0;
int c;
/* Calculate the sequence untill the Nth number */
for (int i = 0; i <n; i++)
{
c = a + b;
a = b;
b = c;
}
return c; // return the desired number
}
// DP
int find_nth_3(int n)
{
int fib[n];
fib[0] = 0;
fib[1] = 1;
for(int i= 2 ; i < n+1 ; i++)
{
fib[i] = fib[i-1] + fib[i-2];
}
return fib[n];
}
int main()
{
cout<<"what number? " << endl;
int n;
while(cin >> n) // -1 terminates
{
if(n==-1) break;
cout << find_nth_3(n) << " ";
}
return 0;
}
| 13.553846 | 54 | 0.490352 | boringwave |
43e03f69f888e8cec85dcc095ab9cd9b06a14871 | 291 | hpp | C++ | include/Matrix3by3.hpp | CaptCrunch333/flight_controller_temp | df996cb6721cc00efe3c46379ecc7d992ae9c764 | [
"BSD-3-Clause"
] | null | null | null | include/Matrix3by3.hpp | CaptCrunch333/flight_controller_temp | df996cb6721cc00efe3c46379ecc7d992ae9c764 | [
"BSD-3-Clause"
] | null | null | null | include/Matrix3by3.hpp | CaptCrunch333/flight_controller_temp | df996cb6721cc00efe3c46379ecc7d992ae9c764 | [
"BSD-3-Clause"
] | 3 | 2020-10-26T12:37:07.000Z | 2020-10-27T04:44:27.000Z | #pragma once
#include "common_srv/Vector3D.hpp"
class Matrix3by3
{
protected:
Vector3D<float> v1, v2, v3;
public:
Matrix3by3();
Matrix3by3(Vector3D<float>, Vector3D<float>, Vector3D<float>);
Vector3D<float> TransformVector(Vector3D<float>);
void Transpose();
};
| 20.785714 | 66 | 0.687285 | CaptCrunch333 |
43e79576da9b5c9e22e517a38c5b22828ccc7fa6 | 8,169 | cpp | C++ | src/levenshtein_automaton/MDAG.cpp | virgilwjj/levenshtein_automaton | 53dc79bf8d744768b4daf8bc16c5007cd2816269 | [
"MIT"
] | 1 | 2021-05-14T09:55:21.000Z | 2021-05-14T09:55:21.000Z | src/levenshtein_automaton/MDAG.cpp | virgilwjj/levenshtein_automaton | 53dc79bf8d744768b4daf8bc16c5007cd2816269 | [
"MIT"
] | null | null | null | src/levenshtein_automaton/MDAG.cpp | virgilwjj/levenshtein_automaton | 53dc79bf8d744768b4daf8bc16c5007cd2816269 | [
"MIT"
] | null | null | null | #include "levenshtein_automaton/MDAG.h"
namespace la
{
MDAG::MDAG(const std::vector<std::string> &strCollection)
{
this->addStrings(strCollection);
}
void
MDAG::addStrings(const std::vector<std::string> &strCollection)
{
if (this->sourceNode != nullptr)
{
std::string previousString{""};
for (const auto ¤tString : strCollection)
{
int mpsIndex{this->calculateMinimizationProcessingStartIndex(previousString, currentString)};
if (mpsIndex != -1)
{
std::string transitionSubstring{previousString.substr(0, mpsIndex)};
std::string minimizationProcessingSubString{previousString.substr(mpsIndex)};
this->replaceOrRegister(this->sourceNode->transition(transitionSubstring), minimizationProcessingSubString);
}
this->addStringInternal(currentString);
previousString = currentString;
}
this->replaceOrRegister(this->sourceNode, previousString);
} else {
// todo
// throw ex
}
}
int
MDAG::calculateMinimizationProcessingStartIndex(const std::string &prevStr, const std::string &currStr)
{
int mpsIndex;
if (!currStr.starts_with(prevStr)){
int shortestStringLength{static_cast<int>(std::min(prevStr.length(), currStr.length()))};
for (mpsIndex = 0; mpsIndex < shortestStringLength && prevStr.at(mpsIndex) == currStr.at(mpsIndex); ++mpsIndex);
}
else {
mpsIndex = -1;
}
return mpsIndex;
}
std::string
MDAG::determineLongestPrefixInMDAG(const std::string &str)
{
MDAGNode *currentNode{this->sourceNode};
int numberOfChars{static_cast<int>(str.length())};
int onePastPrefixEndIndex{0};
for (int i{0}; i < numberOfChars; ++onePastPrefixEndIndex)
{
char currentChar = str.at(i);
if (!currentNode->hasOutgoingTransition(currentChar))
break;
currentNode = currentNode->transition(currentChar);
++i;
}
return str.substr(0, onePastPrefixEndIndex);
}
std::tuple<int, MDAGNode *>
MDAG::getTransitionPathFirstConfluenceNodeData(MDAGNode *originNode, const std::string &str)
{
int currentIndex{0};
int charCount{static_cast<int>(str.length())};
MDAGNode *currentNode;
for (currentNode = originNode; currentIndex < charCount; ++currentIndex)
{
char currentChar{str.at(currentIndex)};
currentNode = currentNode->hasOutgoingTransition(currentChar) ? currentNode->transition(currentChar) : nullptr;
if (currentNode == nullptr || currentNode->isConfluenceNode())
break;
}
bool noConfluenceNode = currentNode == originNode || currentIndex == charCount;
if (noConfluenceNode) {
return {0, nullptr};
} else {
return {currentIndex, currentNode};
}
}
void
MDAG::replaceOrRegister(MDAGNode *originNode, const std::string &str)
{
// add
if (str.empty())
return;
char transitionLabelChar{str.at(0)};
MDAGNode *relevantTargetNode{originNode->transition(transitionLabelChar)};
if (relevantTargetNode->hasTransitions() && !str.substr(1).empty())
{
this->replaceOrRegister(relevantTargetNode, str.substr(1));
}
MDAGNode *equivalentNode = this->equivalenceClassMDAGNodeHashMap.at(relevantTargetNode);
if (equivalentNode == nullptr)
this->equivalenceClassMDAGNodeHashMap.emplace(relevantTargetNode, relevantTargetNode);
else if (equivalentNode != relevantTargetNode)
{
relevantTargetNode->decrementTargetIncomingTransitionCounts();
this->transitionCount -= relevantTargetNode->getOutgoingTransitionCount();
originNode->reassignOutgoingTransition(transitionLabelChar, relevantTargetNode, equivalentNode);
}
}
void
MDAG::addTransitionPath(MDAGNode *originNode, const std::string &str)
{
if (!str.empty()) {
MDAGNode *currentNode{originNode};
int charCount{static_cast<int>(str.length())};
for (int i = 0; i < charCount; ++this->transitionCount) {
char currentChar = str.at(i);
bool isLastChar = i == charCount - 1;
currentNode = currentNode->addOutgoingTransition(currentChar, isLastChar);
this->charTreeSet.insert(currentChar);
++i;
}
}
else {
originNode->setAcceptStateStatus(true);
}
}
void
MDAG::removeTransitionPathRegisterEntries(const std::string &str)
{
MDAGNode *currentNode{this->sourceNode};
int charCount{static_cast<int>(str.length())};
for (int i = 0; i < charCount; ++i)
{
currentNode = currentNode->transition(str.at(i));
if (this->equivalenceClassMDAGNodeHashMap.at(currentNode) == currentNode) {
this->equivalenceClassMDAGNodeHashMap.erase(currentNode);
}
currentNode->clearStoredHashCode();
}
}
void
MDAG::cloneTransitionPath(MDAGNode *pivotConfluenceNode, const std::string &transitionStringToPivotNode, const std::string &str)
{
MDAGNode *lastTargetNode = pivotConfluenceNode->transition(str);
MDAGNode *lastClonedNode{nullptr};
char lastTransitionLabelChar{0};
for (int i = str.length(); i >= 0; --i)
{
std::string currentTransitionString = i > 0 ? str.substr(0, i) : "";
MDAGNode *currentTargetNode = i > 0 ? pivotConfluenceNode->transition(currentTransitionString) : pivotConfluenceNode;
MDAGNode *clonedNode;
if (i == 0) {
std::string transitionStringToPivotNodeParent{transitionStringToPivotNode.substr(0, transitionStringToPivotNode.length() - 1)};
char parentTransitionLabelChar{transitionStringToPivotNode.at(transitionStringToPivotNode.length() - 1)};
clonedNode = pivotConfluenceNode->clone(this->sourceNode->transition(transitionStringToPivotNodeParent), parentTransitionLabelChar);
}
else {
clonedNode = currentTargetNode->clone();
}
this->transitionCount += clonedNode->getOutgoingTransitionCount();
if (lastClonedNode != nullptr)
{
clonedNode->reassignOutgoingTransition(lastTransitionLabelChar, lastTargetNode, lastClonedNode);
lastTargetNode = currentTargetNode;
}
lastClonedNode = clonedNode;
lastTransitionLabelChar = i > 0 ? str.at(i - 1) : 0;
}
}
void
MDAG::addStringInternal(const std::string &str)
{
std::string prefixString{this->determineLongestPrefixInMDAG(str)};//前缀字符串
std::string suffixString{str.substr(prefixString.length())};//后缀字符串
auto [toFirstConfluenceNodeTransitionCharIndex, firstConfluenceNodeInPrefix] = this->getTransitionPathFirstConfluenceNodeData(this->sourceNode, prefixString);
// todo 0
this->removeTransitionPathRegisterEntries(toFirstConfluenceNodeTransitionCharIndex == 0 ? prefixString : prefixString.substr(0, toFirstConfluenceNodeTransitionCharIndex));
if (firstConfluenceNodeInPrefix != nullptr)
{
std::string transitionStringOfPathToFirstConfluenceNode{prefixString.substr(0, toFirstConfluenceNodeTransitionCharIndex + 1)};
std::string transitionStringOfToBeDuplicatedPath{prefixString.substr(toFirstConfluenceNodeTransitionCharIndex + 1)};
this->cloneTransitionPath(firstConfluenceNodeInPrefix, transitionStringOfPathToFirstConfluenceNode, transitionStringOfToBeDuplicatedPath);
}
this->addTransitionPath(this->sourceNode->transition(prefixString), suffixString);
}
} | 42.994737 | 179 | 0.632513 | virgilwjj |
43e9a30c9d51430770a99fd40490a9a9ba30afdd | 472 | cpp | C++ | src/ctewriter.cpp | ekkus93/CarND-PID-Control-Project | e98f4bf16f3c2f5c615cdfcc62977b958df1ac0f | [
"MIT"
] | null | null | null | src/ctewriter.cpp | ekkus93/CarND-PID-Control-Project | e98f4bf16f3c2f5c615cdfcc62977b958df1ac0f | [
"MIT"
] | null | null | null | src/ctewriter.cpp | ekkus93/CarND-PID-Control-Project | e98f4bf16f3c2f5c615cdfcc62977b958df1ac0f | [
"MIT"
] | null | null | null | #include "ctewriter.h"
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
CTEWriter::CTEWriter()
{
isOpen_ = false;
}
CTEWriter::~CTEWriter()
{
if (isOpen_)
{
Close();
}
}
void CTEWriter::Open(string filename)
{
outfile_ = new ofstream(filename);
isOpen_ = true;
}
void CTEWriter::Write(int step, double cte)
{
*outfile_ << step << "," << cte << "\n";
}
void CTEWriter::Close()
{
outfile_->close();
isOpen_ = false;
} | 13.111111 | 43 | 0.635593 | ekkus93 |
43ea40ea91c0042311139293456e65f073a0eac8 | 820 | cpp | C++ | examples/pe_header.cpp | sirofen/read-memory-dll | 035b008cdb6ffbf2d00f30234f9ef976c04eee1e | [
"MIT"
] | null | null | null | examples/pe_header.cpp | sirofen/read-memory-dll | 035b008cdb6ffbf2d00f30234f9ef976c04eee1e | [
"MIT"
] | null | null | null | examples/pe_header.cpp | sirofen/read-memory-dll | 035b008cdb6ffbf2d00f30234f9ef976c04eee1e | [
"MIT"
] | null | null | null | // example
#include <pe_header.hpp>
// spdlog
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
// module
#include <module/module_run.hpp>
#include <module/base_listener.hpp>
// WINAPI
#include <Windows.h>
class listener : public module::base_listener {
public:
void value_accessible_string(const std::string& _val) override {
SPDLOG_INFO("Value accessible: {}", _val);
}
};
void read_dos_msg(uintptr_t base_address) {
/* address to DOS stub message */
auto m_offs = 0x4E;
uintptr_t m_addr = base_address + m_offs;
module::internal::module_run module_o;
module_o.add_listener(std::make_shared<listener>());
module_o.set_address(m_addr);
module_o.set_break_key(VK_F12);
module_o.run();
}
| 21.025641 | 68 | 0.713415 | sirofen |
43f027b6a04079f51f9a0d5e174c03d3d1cc23c1 | 5,966 | cpp | C++ | src/qt/mempooltablemodel.cpp | drivechain-project/Mainchain | 1a948ab1ceb5bba57c0509c991133659d40c10e9 | [
"MIT"
] | null | null | null | src/qt/mempooltablemodel.cpp | drivechain-project/Mainchain | 1a948ab1ceb5bba57c0509c991133659d40c10e9 | [
"MIT"
] | null | null | null | src/qt/mempooltablemodel.cpp | drivechain-project/Mainchain | 1a948ab1ceb5bba57c0509c991133659d40c10e9 | [
"MIT"
] | null | null | null | // Copyright (c) 2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/mempooltablemodel.h>
#include <qt/clientmodel.h>
#include <qt/drivechainunits.h>
#include <qt/optionsmodel.h>
#include <qt/guiutil.h>
#include <primitives/transaction.h>
#include <txmempool.h>
#include <utilmoneystr.h>
#include <validation.h>
#include <QDateTime>
#include <QLocale>
#include <QString>
Q_DECLARE_METATYPE(MemPoolTableObject)
MemPoolTableModel::MemPoolTableModel(QObject *parent) :
QAbstractTableModel(parent)
{
nTx = 0;
nBytes = 0;
}
int MemPoolTableModel::rowCount(const QModelIndex & /*parent*/) const
{
return model.size();
}
int MemPoolTableModel::columnCount(const QModelIndex & /*parent*/) const
{
return 6;
}
QVariant MemPoolTableModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) {
return false;
}
int row = index.row();
int col = index.column();
if (!model.at(row).canConvert<MemPoolTableObject>())
return QVariant();
MemPoolTableObject object = model.at(row).value<MemPoolTableObject>();
switch (role) {
case Qt::DisplayRole:
{
// Time
if (col == 0) {
return object.time;
}
// Value
if (col == 1) {
return QString::fromStdString(FormatMoney(object.value));
}
// Value USD
if (col == 2) {
return "$" + QLocale(QLocale::English).toString(ConvertToFiat(object.value, nUSDBTC), 'f', 0);
}
// sats / byte
if (col == 3) {
return QString::number(object.feeRate.GetFeePerB());
}
// Total fee in USD
// txid
if (col == 4) {
return "$" + QLocale(QLocale::English).toString(ConvertToFiat(object.fee, nUSDBTC), 'f', 2);
}
if (col == 5) {
return QString::fromStdString(object.txid.ToString()).left(21) + "...";
}
}
case Qt::TextAlignmentRole:
{
// Time
if (col == 0) {
return int(Qt::AlignRight | Qt::AlignVCenter);
}
// Value
if (col == 1) {
return int(Qt::AlignRight | Qt::AlignVCenter);
}
// Value USD
if (col == 2) {
return int(Qt::AlignRight | Qt::AlignVCenter);
}
// Sats / byte
if (col == 3) {
return int(Qt::AlignRight | Qt::AlignVCenter);
}
// Fee in USD
if (col == 4) {
return int(Qt::AlignRight | Qt::AlignVCenter);
}
// txid
if (col == 5) {
return int(Qt::AlignLeft | Qt::AlignVCenter);
}
}
case HashRole:
{
return QString::fromStdString(object.txid.ToString());
}
}
return QVariant();
}
QVariant MemPoolTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole) {
if (orientation == Qt::Horizontal) {
switch (section) {
case 0:
return QString("Time");
case 1:
return QString("BTC");
case 2:
return QString("$");
case 3:
return QString("Sat/vB");
case 4:
return QString("Fee $");
case 5:
return QString("TxID");
}
}
}
return QVariant();
}
void MemPoolTableModel::setClientModel(ClientModel *model)
{
this->clientModel = model;
OptionsModel* optionsModel = model->getOptionsModel();
connect(optionsModel, SIGNAL(usdBTCChanged(int)),
this, SLOT(setUSDBTC(int)));
setUSDBTC(optionsModel->getUSDBTC());
}
void MemPoolTableModel::updateModel()
{
if (!clientModel)
return;
if (clientModel->inInitialBlockDownload())
return;
// Get recent mempool entries
std::vector<TxMempoolInfo> vInfo = mempool.InfoRecent(10);
// Check if there is a transaction that we already know.
// If we find one then cut down vInfo to only new transactions.
if (model.size() && model.front().canConvert<MemPoolTableObject>()) {
MemPoolTableObject old = model.front().value<MemPoolTableObject>();
for (auto it = vInfo.begin(); it != vInfo.end(); it++) {
if (!it->tx)
continue;
if (it->tx->GetHash() == old.txid) {
vInfo = std::vector<TxMempoolInfo>(vInfo.begin(), it);
break;
}
}
}
if (vInfo.empty())
return;
// Add new data to table
beginInsertRows(QModelIndex(), 0, vInfo.size() - 1);
for (auto it = vInfo.begin(); it != vInfo.end(); it++) {
if (!it->tx)
continue;
MemPoolTableObject object;
object.txid = it->tx->GetHash();
object.time = QDateTime::fromTime_t((int64_t)it->nTime).toString("hh:mm MMM dd");
object.value = it->tx->GetValueOut();
object.feeRate = it->feeRate;
object.fee = it->fee;
model.prepend(QVariant::fromValue(object));
}
endInsertRows();
// Remove extra entries
if (model.size() > 50)
{
beginRemoveRows(QModelIndex(), model.size() - std::abs(50 - model.size()), model.size() - 1);
while (model.size() > 50)
model.pop_back();
endRemoveRows();
}
}
void MemPoolTableModel::memPoolSizeChanged(long nTxIn, size_t nBytesIn)
{
if (nTxIn != nTx || nBytesIn != nBytes) {
nTx = nTxIn;
nBytes = nBytesIn;
updateModel();
}
}
void MemPoolTableModel::setUSDBTC(int nUSDBTCIn)
{
nUSDBTC = nUSDBTCIn;
updateModel();
}
bool MemPoolTableModel::GetTx(const uint256& txid, CTransactionRef& tx) const
{
if (!mempool.exists(txid))
return false;
tx = mempool.get(txid);
return true;
}
| 25.82684 | 106 | 0.563862 | drivechain-project |
43f0469e6ea1bb2ba3b91da2c1cb4ab7a753c4c7 | 29,687 | cpp | C++ | cfdgame_BackUpThisFolder_ButDontShipItWithYourGame/il2cppOutput/Bulk_UnityEngine.InputModule_0.cpp | toropippi/FluidLander_Alpha | e17410fc1092fa1127d993fcbd5b99a9ada39294 | [
"CC-BY-2.0",
"Apache-2.0"
] | 7 | 2019-12-04T07:04:37.000Z | 2022-01-28T02:55:05.000Z | cfdgame_BackUpThisFolder_ButDontShipItWithYourGame/il2cppOutput/Bulk_UnityEngine.InputModule_0.cpp | toropippi/FluidLander_Alpha | e17410fc1092fa1127d993fcbd5b99a9ada39294 | [
"CC-BY-2.0",
"Apache-2.0"
] | null | null | null | cfdgame_BackUpThisFolder_ButDontShipItWithYourGame/il2cppOutput/Bulk_UnityEngine.InputModule_0.cpp | toropippi/FluidLander_Alpha | e17410fc1092fa1127d993fcbd5b99a9ada39294 | [
"CC-BY-2.0",
"Apache-2.0"
] | 3 | 2019-12-04T07:04:38.000Z | 2022-01-28T02:55:07.000Z | #include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <limits>
#include <assert.h>
#include <stdint.h>
#include "il2cpp-class-internals.h"
#include "codegen/il2cpp-codegen.h"
#include "il2cpp-object-internals.h"
// System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType>
struct Action_1_t4115288129;
// System.Action`2<System.Int32,System.Object>
struct Action_2_t11315885;
// System.Action`2<System.Int32,System.String>
struct Action_2_t3073627706;
// System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr>
struct Action_3_t3628100363;
// System.AsyncCallback
struct AsyncCallback_t3962456242;
// System.Char[]
struct CharU5BU5D_t3528271667;
// System.DelegateData
struct DelegateData_t1677132599;
// System.IAsyncResult
struct IAsyncResult_t767004451;
// System.Reflection.MethodInfo
struct MethodInfo_t;
// System.String
struct String_t;
// System.Void
struct Void_t1185182177;
extern RuntimeClass* NativeInputSystem_t922881982_il2cpp_TypeInfo_var;
extern const RuntimeMethod* Action_1_Invoke_m4124360174_RuntimeMethod_var;
extern const RuntimeMethod* Action_2_Invoke_m3260321530_RuntimeMethod_var;
extern const RuntimeMethod* Action_3_Invoke_m3685538658_RuntimeMethod_var;
extern const uint32_t NativeInputSystem_NotifyBeforeUpdate_m101187815_MetadataUsageId;
extern const uint32_t NativeInputSystem_NotifyDeviceDiscovered_m3978728918_MetadataUsageId;
extern const uint32_t NativeInputSystem_NotifyUpdate_m517501689_MetadataUsageId;
#ifndef U3CMODULEU3E_T692745541_H
#define U3CMODULEU3E_T692745541_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// <Module>
struct U3CModuleU3E_t692745541
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CMODULEU3E_T692745541_H
#ifndef RUNTIMEOBJECT_H
#define RUNTIMEOBJECT_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Object
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEOBJECT_H
struct Il2CppArrayBounds;
#ifndef RUNTIMEARRAY_H
#define RUNTIMEARRAY_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Array
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEARRAY_H
#ifndef STRING_T_H
#define STRING_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.String
struct String_t : public RuntimeObject
{
public:
// System.Int32 System.String::length
int32_t ___length_0;
// System.Char System.String::start_char
Il2CppChar ___start_char_1;
public:
inline static int32_t get_offset_of_length_0() { return static_cast<int32_t>(offsetof(String_t, ___length_0)); }
inline int32_t get_length_0() const { return ___length_0; }
inline int32_t* get_address_of_length_0() { return &___length_0; }
inline void set_length_0(int32_t value)
{
___length_0 = value;
}
inline static int32_t get_offset_of_start_char_1() { return static_cast<int32_t>(offsetof(String_t, ___start_char_1)); }
inline Il2CppChar get_start_char_1() const { return ___start_char_1; }
inline Il2CppChar* get_address_of_start_char_1() { return &___start_char_1; }
inline void set_start_char_1(Il2CppChar value)
{
___start_char_1 = value;
}
};
struct String_t_StaticFields
{
public:
// System.String System.String::Empty
String_t* ___Empty_2;
// System.Char[] System.String::WhiteChars
CharU5BU5D_t3528271667* ___WhiteChars_3;
public:
inline static int32_t get_offset_of_Empty_2() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___Empty_2)); }
inline String_t* get_Empty_2() const { return ___Empty_2; }
inline String_t** get_address_of_Empty_2() { return &___Empty_2; }
inline void set_Empty_2(String_t* value)
{
___Empty_2 = value;
Il2CppCodeGenWriteBarrier((&___Empty_2), value);
}
inline static int32_t get_offset_of_WhiteChars_3() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___WhiteChars_3)); }
inline CharU5BU5D_t3528271667* get_WhiteChars_3() const { return ___WhiteChars_3; }
inline CharU5BU5D_t3528271667** get_address_of_WhiteChars_3() { return &___WhiteChars_3; }
inline void set_WhiteChars_3(CharU5BU5D_t3528271667* value)
{
___WhiteChars_3 = value;
Il2CppCodeGenWriteBarrier((&___WhiteChars_3), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // STRING_T_H
#ifndef VALUETYPE_T3640485471_H
#define VALUETYPE_T3640485471_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ValueType
struct ValueType_t3640485471 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_com
{
};
#endif // VALUETYPE_T3640485471_H
#ifndef NATIVEINPUTSYSTEM_T922881982_H
#define NATIVEINPUTSYSTEM_T922881982_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngineInternal.Input.NativeInputSystem
struct NativeInputSystem_t922881982 : public RuntimeObject
{
public:
public:
};
struct NativeInputSystem_t922881982_StaticFields
{
public:
// System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr> UnityEngineInternal.Input.NativeInputSystem::onUpdate
Action_3_t3628100363 * ___onUpdate_0;
// System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType> UnityEngineInternal.Input.NativeInputSystem::onBeforeUpdate
Action_1_t4115288129 * ___onBeforeUpdate_1;
// System.Action`2<System.Int32,System.String> UnityEngineInternal.Input.NativeInputSystem::s_OnDeviceDiscoveredCallback
Action_2_t3073627706 * ___s_OnDeviceDiscoveredCallback_2;
public:
inline static int32_t get_offset_of_onUpdate_0() { return static_cast<int32_t>(offsetof(NativeInputSystem_t922881982_StaticFields, ___onUpdate_0)); }
inline Action_3_t3628100363 * get_onUpdate_0() const { return ___onUpdate_0; }
inline Action_3_t3628100363 ** get_address_of_onUpdate_0() { return &___onUpdate_0; }
inline void set_onUpdate_0(Action_3_t3628100363 * value)
{
___onUpdate_0 = value;
Il2CppCodeGenWriteBarrier((&___onUpdate_0), value);
}
inline static int32_t get_offset_of_onBeforeUpdate_1() { return static_cast<int32_t>(offsetof(NativeInputSystem_t922881982_StaticFields, ___onBeforeUpdate_1)); }
inline Action_1_t4115288129 * get_onBeforeUpdate_1() const { return ___onBeforeUpdate_1; }
inline Action_1_t4115288129 ** get_address_of_onBeforeUpdate_1() { return &___onBeforeUpdate_1; }
inline void set_onBeforeUpdate_1(Action_1_t4115288129 * value)
{
___onBeforeUpdate_1 = value;
Il2CppCodeGenWriteBarrier((&___onBeforeUpdate_1), value);
}
inline static int32_t get_offset_of_s_OnDeviceDiscoveredCallback_2() { return static_cast<int32_t>(offsetof(NativeInputSystem_t922881982_StaticFields, ___s_OnDeviceDiscoveredCallback_2)); }
inline Action_2_t3073627706 * get_s_OnDeviceDiscoveredCallback_2() const { return ___s_OnDeviceDiscoveredCallback_2; }
inline Action_2_t3073627706 ** get_address_of_s_OnDeviceDiscoveredCallback_2() { return &___s_OnDeviceDiscoveredCallback_2; }
inline void set_s_OnDeviceDiscoveredCallback_2(Action_2_t3073627706 * value)
{
___s_OnDeviceDiscoveredCallback_2 = value;
Il2CppCodeGenWriteBarrier((&___s_OnDeviceDiscoveredCallback_2), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // NATIVEINPUTSYSTEM_T922881982_H
#ifndef BOOLEAN_T97287965_H
#define BOOLEAN_T97287965_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Boolean
struct Boolean_t97287965
{
public:
// System.Boolean System.Boolean::m_value
bool ___m_value_2;
public:
inline static int32_t get_offset_of_m_value_2() { return static_cast<int32_t>(offsetof(Boolean_t97287965, ___m_value_2)); }
inline bool get_m_value_2() const { return ___m_value_2; }
inline bool* get_address_of_m_value_2() { return &___m_value_2; }
inline void set_m_value_2(bool value)
{
___m_value_2 = value;
}
};
struct Boolean_t97287965_StaticFields
{
public:
// System.String System.Boolean::FalseString
String_t* ___FalseString_0;
// System.String System.Boolean::TrueString
String_t* ___TrueString_1;
public:
inline static int32_t get_offset_of_FalseString_0() { return static_cast<int32_t>(offsetof(Boolean_t97287965_StaticFields, ___FalseString_0)); }
inline String_t* get_FalseString_0() const { return ___FalseString_0; }
inline String_t** get_address_of_FalseString_0() { return &___FalseString_0; }
inline void set_FalseString_0(String_t* value)
{
___FalseString_0 = value;
Il2CppCodeGenWriteBarrier((&___FalseString_0), value);
}
inline static int32_t get_offset_of_TrueString_1() { return static_cast<int32_t>(offsetof(Boolean_t97287965_StaticFields, ___TrueString_1)); }
inline String_t* get_TrueString_1() const { return ___TrueString_1; }
inline String_t** get_address_of_TrueString_1() { return &___TrueString_1; }
inline void set_TrueString_1(String_t* value)
{
___TrueString_1 = value;
Il2CppCodeGenWriteBarrier((&___TrueString_1), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BOOLEAN_T97287965_H
#ifndef ENUM_T4135868527_H
#define ENUM_T4135868527_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Enum
struct Enum_t4135868527 : public ValueType_t3640485471
{
public:
public:
};
struct Enum_t4135868527_StaticFields
{
public:
// System.Char[] System.Enum::split_char
CharU5BU5D_t3528271667* ___split_char_0;
public:
inline static int32_t get_offset_of_split_char_0() { return static_cast<int32_t>(offsetof(Enum_t4135868527_StaticFields, ___split_char_0)); }
inline CharU5BU5D_t3528271667* get_split_char_0() const { return ___split_char_0; }
inline CharU5BU5D_t3528271667** get_address_of_split_char_0() { return &___split_char_0; }
inline void set_split_char_0(CharU5BU5D_t3528271667* value)
{
___split_char_0 = value;
Il2CppCodeGenWriteBarrier((&___split_char_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Enum
struct Enum_t4135868527_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.Enum
struct Enum_t4135868527_marshaled_com
{
};
#endif // ENUM_T4135868527_H
#ifndef INT32_T2950945753_H
#define INT32_T2950945753_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Int32
struct Int32_t2950945753
{
public:
// System.Int32 System.Int32::m_value
int32_t ___m_value_2;
public:
inline static int32_t get_offset_of_m_value_2() { return static_cast<int32_t>(offsetof(Int32_t2950945753, ___m_value_2)); }
inline int32_t get_m_value_2() const { return ___m_value_2; }
inline int32_t* get_address_of_m_value_2() { return &___m_value_2; }
inline void set_m_value_2(int32_t value)
{
___m_value_2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INT32_T2950945753_H
#ifndef INTPTR_T_H
#define INTPTR_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.IntPtr
struct IntPtr_t
{
public:
// System.Void* System.IntPtr::m_value
void* ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); }
inline void* get_m_value_0() const { return ___m_value_0; }
inline void** get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(void* value)
{
___m_value_0 = value;
}
};
struct IntPtr_t_StaticFields
{
public:
// System.IntPtr System.IntPtr::Zero
intptr_t ___Zero_1;
public:
inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); }
inline intptr_t get_Zero_1() const { return ___Zero_1; }
inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; }
inline void set_Zero_1(intptr_t value)
{
___Zero_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INTPTR_T_H
#ifndef VOID_T1185182177_H
#define VOID_T1185182177_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void
struct Void_t1185182177
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VOID_T1185182177_H
#ifndef DELEGATE_T1188392813_H
#define DELEGATE_T1188392813_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Delegate
struct Delegate_t1188392813 : public RuntimeObject
{
public:
// System.IntPtr System.Delegate::method_ptr
Il2CppMethodPointer ___method_ptr_0;
// System.IntPtr System.Delegate::invoke_impl
intptr_t ___invoke_impl_1;
// System.Object System.Delegate::m_target
RuntimeObject * ___m_target_2;
// System.IntPtr System.Delegate::method
intptr_t ___method_3;
// System.IntPtr System.Delegate::delegate_trampoline
intptr_t ___delegate_trampoline_4;
// System.IntPtr System.Delegate::method_code
intptr_t ___method_code_5;
// System.Reflection.MethodInfo System.Delegate::method_info
MethodInfo_t * ___method_info_6;
// System.Reflection.MethodInfo System.Delegate::original_method_info
MethodInfo_t * ___original_method_info_7;
// System.DelegateData System.Delegate::data
DelegateData_t1677132599 * ___data_8;
public:
inline static int32_t get_offset_of_method_ptr_0() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___method_ptr_0)); }
inline Il2CppMethodPointer get_method_ptr_0() const { return ___method_ptr_0; }
inline Il2CppMethodPointer* get_address_of_method_ptr_0() { return &___method_ptr_0; }
inline void set_method_ptr_0(Il2CppMethodPointer value)
{
___method_ptr_0 = value;
}
inline static int32_t get_offset_of_invoke_impl_1() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___invoke_impl_1)); }
inline intptr_t get_invoke_impl_1() const { return ___invoke_impl_1; }
inline intptr_t* get_address_of_invoke_impl_1() { return &___invoke_impl_1; }
inline void set_invoke_impl_1(intptr_t value)
{
___invoke_impl_1 = value;
}
inline static int32_t get_offset_of_m_target_2() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___m_target_2)); }
inline RuntimeObject * get_m_target_2() const { return ___m_target_2; }
inline RuntimeObject ** get_address_of_m_target_2() { return &___m_target_2; }
inline void set_m_target_2(RuntimeObject * value)
{
___m_target_2 = value;
Il2CppCodeGenWriteBarrier((&___m_target_2), value);
}
inline static int32_t get_offset_of_method_3() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___method_3)); }
inline intptr_t get_method_3() const { return ___method_3; }
inline intptr_t* get_address_of_method_3() { return &___method_3; }
inline void set_method_3(intptr_t value)
{
___method_3 = value;
}
inline static int32_t get_offset_of_delegate_trampoline_4() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___delegate_trampoline_4)); }
inline intptr_t get_delegate_trampoline_4() const { return ___delegate_trampoline_4; }
inline intptr_t* get_address_of_delegate_trampoline_4() { return &___delegate_trampoline_4; }
inline void set_delegate_trampoline_4(intptr_t value)
{
___delegate_trampoline_4 = value;
}
inline static int32_t get_offset_of_method_code_5() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___method_code_5)); }
inline intptr_t get_method_code_5() const { return ___method_code_5; }
inline intptr_t* get_address_of_method_code_5() { return &___method_code_5; }
inline void set_method_code_5(intptr_t value)
{
___method_code_5 = value;
}
inline static int32_t get_offset_of_method_info_6() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___method_info_6)); }
inline MethodInfo_t * get_method_info_6() const { return ___method_info_6; }
inline MethodInfo_t ** get_address_of_method_info_6() { return &___method_info_6; }
inline void set_method_info_6(MethodInfo_t * value)
{
___method_info_6 = value;
Il2CppCodeGenWriteBarrier((&___method_info_6), value);
}
inline static int32_t get_offset_of_original_method_info_7() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___original_method_info_7)); }
inline MethodInfo_t * get_original_method_info_7() const { return ___original_method_info_7; }
inline MethodInfo_t ** get_address_of_original_method_info_7() { return &___original_method_info_7; }
inline void set_original_method_info_7(MethodInfo_t * value)
{
___original_method_info_7 = value;
Il2CppCodeGenWriteBarrier((&___original_method_info_7), value);
}
inline static int32_t get_offset_of_data_8() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___data_8)); }
inline DelegateData_t1677132599 * get_data_8() const { return ___data_8; }
inline DelegateData_t1677132599 ** get_address_of_data_8() { return &___data_8; }
inline void set_data_8(DelegateData_t1677132599 * value)
{
___data_8 = value;
Il2CppCodeGenWriteBarrier((&___data_8), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DELEGATE_T1188392813_H
#ifndef NATIVEINPUTUPDATETYPE_T3942820534_H
#define NATIVEINPUTUPDATETYPE_T3942820534_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngineInternal.Input.NativeInputUpdateType
struct NativeInputUpdateType_t3942820534
{
public:
// System.Int32 UnityEngineInternal.Input.NativeInputUpdateType::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(NativeInputUpdateType_t3942820534, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // NATIVEINPUTUPDATETYPE_T3942820534_H
#ifndef MULTICASTDELEGATE_T_H
#define MULTICASTDELEGATE_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.MulticastDelegate
struct MulticastDelegate_t : public Delegate_t1188392813
{
public:
// System.MulticastDelegate System.MulticastDelegate::prev
MulticastDelegate_t * ___prev_9;
// System.MulticastDelegate System.MulticastDelegate::kpm_next
MulticastDelegate_t * ___kpm_next_10;
public:
inline static int32_t get_offset_of_prev_9() { return static_cast<int32_t>(offsetof(MulticastDelegate_t, ___prev_9)); }
inline MulticastDelegate_t * get_prev_9() const { return ___prev_9; }
inline MulticastDelegate_t ** get_address_of_prev_9() { return &___prev_9; }
inline void set_prev_9(MulticastDelegate_t * value)
{
___prev_9 = value;
Il2CppCodeGenWriteBarrier((&___prev_9), value);
}
inline static int32_t get_offset_of_kpm_next_10() { return static_cast<int32_t>(offsetof(MulticastDelegate_t, ___kpm_next_10)); }
inline MulticastDelegate_t * get_kpm_next_10() const { return ___kpm_next_10; }
inline MulticastDelegate_t ** get_address_of_kpm_next_10() { return &___kpm_next_10; }
inline void set_kpm_next_10(MulticastDelegate_t * value)
{
___kpm_next_10 = value;
Il2CppCodeGenWriteBarrier((&___kpm_next_10), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MULTICASTDELEGATE_T_H
#ifndef ACTION_1_T4115288129_H
#define ACTION_1_T4115288129_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType>
struct Action_1_t4115288129 : public MulticastDelegate_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ACTION_1_T4115288129_H
#ifndef ACTION_2_T3073627706_H
#define ACTION_2_T3073627706_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Action`2<System.Int32,System.String>
struct Action_2_t3073627706 : public MulticastDelegate_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ACTION_2_T3073627706_H
#ifndef ACTION_3_T3628100363_H
#define ACTION_3_T3628100363_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr>
struct Action_3_t3628100363 : public MulticastDelegate_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ACTION_3_T3628100363_H
// System.Void System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType>::Invoke(!0)
extern "C" IL2CPP_METHOD_ATTR void Action_1_Invoke_m4124360174_gshared (Action_1_t4115288129 * __this, int32_t p0, const RuntimeMethod* method);
// System.Void System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr>::Invoke(!0,!1,!2)
extern "C" IL2CPP_METHOD_ATTR void Action_3_Invoke_m3685538658_gshared (Action_3_t3628100363 * __this, int32_t p0, int32_t p1, intptr_t p2, const RuntimeMethod* method);
// System.Void System.Action`2<System.Int32,System.Object>::Invoke(!0,!1)
extern "C" IL2CPP_METHOD_ATTR void Action_2_Invoke_m873780839_gshared (Action_2_t11315885 * __this, int32_t p0, RuntimeObject * p1, const RuntimeMethod* method);
// System.Void UnityEngineInternal.Input.NativeInputSystem::set_hasDeviceDiscoveredCallback(System.Boolean)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_set_hasDeviceDiscoveredCallback_m4093248293 (RuntimeObject * __this /* static, unused */, bool ___value0, const RuntimeMethod* method);
// System.Void System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType>::Invoke(!0)
inline void Action_1_Invoke_m4124360174 (Action_1_t4115288129 * __this, int32_t p0, const RuntimeMethod* method)
{
(( void (*) (Action_1_t4115288129 *, int32_t, const RuntimeMethod*))Action_1_Invoke_m4124360174_gshared)(__this, p0, method);
}
// System.Void System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr>::Invoke(!0,!1,!2)
inline void Action_3_Invoke_m3685538658 (Action_3_t3628100363 * __this, int32_t p0, int32_t p1, intptr_t p2, const RuntimeMethod* method)
{
(( void (*) (Action_3_t3628100363 *, int32_t, int32_t, intptr_t, const RuntimeMethod*))Action_3_Invoke_m3685538658_gshared)(__this, p0, p1, p2, method);
}
// System.Void System.Action`2<System.Int32,System.String>::Invoke(!0,!1)
inline void Action_2_Invoke_m3260321530 (Action_2_t3073627706 * __this, int32_t p0, String_t* p1, const RuntimeMethod* method)
{
(( void (*) (Action_2_t3073627706 *, int32_t, String_t*, const RuntimeMethod*))Action_2_Invoke_m873780839_gshared)(__this, p0, p1, method);
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void UnityEngineInternal.Input.NativeInputSystem::.cctor()
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem__cctor_m2718866957 (RuntimeObject * __this /* static, unused */, const RuntimeMethod* method)
{
{
NativeInputSystem_set_hasDeviceDiscoveredCallback_m4093248293(NULL /*static, unused*/, (bool)0, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngineInternal.Input.NativeInputSystem::NotifyBeforeUpdate(UnityEngineInternal.Input.NativeInputUpdateType)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_NotifyBeforeUpdate_m101187815 (RuntimeObject * __this /* static, unused */, int32_t ___updateType0, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (NativeInputSystem_NotifyBeforeUpdate_m101187815_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Action_1_t4115288129 * V_0 = NULL;
{
IL2CPP_RUNTIME_CLASS_INIT(NativeInputSystem_t922881982_il2cpp_TypeInfo_var);
Action_1_t4115288129 * L_0 = ((NativeInputSystem_t922881982_StaticFields*)il2cpp_codegen_static_fields_for(NativeInputSystem_t922881982_il2cpp_TypeInfo_var))->get_onBeforeUpdate_1();
V_0 = L_0;
Action_1_t4115288129 * L_1 = V_0;
if (!L_1)
{
goto IL_0014;
}
}
{
Action_1_t4115288129 * L_2 = V_0;
int32_t L_3 = ___updateType0;
NullCheck(L_2);
Action_1_Invoke_m4124360174(L_2, L_3, /*hidden argument*/Action_1_Invoke_m4124360174_RuntimeMethod_var);
}
IL_0014:
{
return;
}
}
// System.Void UnityEngineInternal.Input.NativeInputSystem::NotifyUpdate(UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_NotifyUpdate_m517501689 (RuntimeObject * __this /* static, unused */, int32_t ___updateType0, int32_t ___eventCount1, intptr_t ___eventData2, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (NativeInputSystem_NotifyUpdate_m517501689_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Action_3_t3628100363 * V_0 = NULL;
{
IL2CPP_RUNTIME_CLASS_INIT(NativeInputSystem_t922881982_il2cpp_TypeInfo_var);
Action_3_t3628100363 * L_0 = ((NativeInputSystem_t922881982_StaticFields*)il2cpp_codegen_static_fields_for(NativeInputSystem_t922881982_il2cpp_TypeInfo_var))->get_onUpdate_0();
V_0 = L_0;
Action_3_t3628100363 * L_1 = V_0;
if (!L_1)
{
goto IL_0016;
}
}
{
Action_3_t3628100363 * L_2 = V_0;
int32_t L_3 = ___updateType0;
int32_t L_4 = ___eventCount1;
intptr_t L_5 = ___eventData2;
NullCheck(L_2);
Action_3_Invoke_m3685538658(L_2, L_3, L_4, (intptr_t)L_5, /*hidden argument*/Action_3_Invoke_m3685538658_RuntimeMethod_var);
}
IL_0016:
{
return;
}
}
// System.Void UnityEngineInternal.Input.NativeInputSystem::NotifyDeviceDiscovered(System.Int32,System.String)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_NotifyDeviceDiscovered_m3978728918 (RuntimeObject * __this /* static, unused */, int32_t ___deviceId0, String_t* ___deviceDescriptor1, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (NativeInputSystem_NotifyDeviceDiscovered_m3978728918_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Action_2_t3073627706 * V_0 = NULL;
{
IL2CPP_RUNTIME_CLASS_INIT(NativeInputSystem_t922881982_il2cpp_TypeInfo_var);
Action_2_t3073627706 * L_0 = ((NativeInputSystem_t922881982_StaticFields*)il2cpp_codegen_static_fields_for(NativeInputSystem_t922881982_il2cpp_TypeInfo_var))->get_s_OnDeviceDiscoveredCallback_2();
V_0 = L_0;
Action_2_t3073627706 * L_1 = V_0;
if (!L_1)
{
goto IL_0015;
}
}
{
Action_2_t3073627706 * L_2 = V_0;
int32_t L_3 = ___deviceId0;
String_t* L_4 = ___deviceDescriptor1;
NullCheck(L_2);
Action_2_Invoke_m3260321530(L_2, L_3, L_4, /*hidden argument*/Action_2_Invoke_m3260321530_RuntimeMethod_var);
}
IL_0015:
{
return;
}
}
// System.Void UnityEngineInternal.Input.NativeInputSystem::set_hasDeviceDiscoveredCallback(System.Boolean)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_set_hasDeviceDiscoveredCallback_m4093248293 (RuntimeObject * __this /* static, unused */, bool ___value0, const RuntimeMethod* method)
{
typedef void (*NativeInputSystem_set_hasDeviceDiscoveredCallback_m4093248293_ftn) (bool);
static NativeInputSystem_set_hasDeviceDiscoveredCallback_m4093248293_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (NativeInputSystem_set_hasDeviceDiscoveredCallback_m4093248293_ftn)il2cpp_codegen_resolve_icall ("UnityEngineInternal.Input.NativeInputSystem::set_hasDeviceDiscoveredCallback(System.Boolean)");
_il2cpp_icall_func(___value0);
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| 34.359954 | 223 | 0.811668 | toropippi |
43f17a2e25b739303cab9bf0a653fd6b0edd379b | 461 | cpp | C++ | Contributor Corner/Himanshi/max_min_sum.cpp | hitu1304/interview-corner | 97503d1967c646f731275ae3665f142814c6a9d7 | [
"MIT"
] | 39 | 2020-11-01T13:58:48.000Z | 2021-02-12T08:39:37.000Z | Contributor Corner/Himanshi/max_min_sum.cpp | hitu1304/interview-corner | 97503d1967c646f731275ae3665f142814c6a9d7 | [
"MIT"
] | 86 | 2020-09-25T07:20:40.000Z | 2021-02-18T20:36:29.000Z | Contributor Corner/Himanshi/max_min_sum.cpp | hitu1304/interview-corner | 97503d1967c646f731275ae3665f142814c6a9d7 | [
"MIT"
] | 43 | 2020-12-18T03:32:42.000Z | 2021-02-19T18:08:19.000Z | # include <iostream>
# include <vector>
# include <algorithm>
using namespace std;
class solution
{
public:
int find_sum(vector<int>& arr)
{
sort(arr.begin(),arr.end());
return arr[0] + arr[arr.size()-1];
}
};
int main()
{
vector<int> arr;
int key,size;
cin >> size;
while(size--)
{
cin >> key;
arr.push_back(key);
}
solution sol;
cout << sol.find_sum(arr) << endl;
return 0;
}
| 14.870968 | 42 | 0.537961 | hitu1304 |
43fd3788ca6ea1b7ab787db69e739a319e84109e | 426 | cpp | C++ | src/examples/04_module/06_vectors/main.cpp | acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-djchenevert | 0f7b3f47eb518fc4e85ec853cab9ceb4c629025a | [
"MIT"
] | null | null | null | src/examples/04_module/06_vectors/main.cpp | acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-djchenevert | 0f7b3f47eb518fc4e85ec853cab9ceb4c629025a | [
"MIT"
] | null | null | null | src/examples/04_module/06_vectors/main.cpp | acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-djchenevert | 0f7b3f47eb518fc4e85ec853cab9ceb4c629025a | [
"MIT"
] | null | null | null | #include "vec.h"
#include<vector>
#include<iostream>
using std::vector; using std::cout;
int main()
{
vector<int> nums{10, 3, 2};
cout<<"capacity: "<<nums.capacity()<<"\n";
nums.push_back(20);
cout<<"capacity: "<<nums.capacity()<<"\n";
cout<<nums[3]<<"\n";
for(std::size_t i =0; i < nums.size(); ++i)
{
cout<<nums[i]<<"\n";
}
cout<<"\n for ranged\n";
for (auto n: nums)
{
cout<<n<<"\n";
}
return 0;
} | 14.2 | 44 | 0.558685 | acc-cosc-1337-fall-2020 |
a102ffa27e3faf9609b89a74f1f3a5520b128d19 | 3,557 | cpp | C++ | tutorials/common/common_utils_linux.cpp | VickyZengg/MediaSDK | 924da6d0664e77cef46eeef7821694dad140b8df | [
"MIT"
] | 782 | 2017-04-04T15:50:34.000Z | 2022-03-31T05:15:00.000Z | tutorials/common/common_utils_linux.cpp | VickyZengg/MediaSDK | 924da6d0664e77cef46eeef7821694dad140b8df | [
"MIT"
] | 1,260 | 2017-04-04T18:48:37.000Z | 2022-03-31T01:53:25.000Z | tutorials/common/common_utils_linux.cpp | VickyZengg/MediaSDK | 924da6d0664e77cef46eeef7821694dad140b8df | [
"MIT"
] | 538 | 2017-04-05T00:19:25.000Z | 2022-03-31T09:43:35.000Z | // Copyright (c) 2019 Intel Corporation
//
// 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 "mfxvideo.h"
#if (MFX_VERSION_MAJOR == 1) && (MFX_VERSION_MINOR < 8)
#include "mfxlinux.h"
#endif
#include "common_utils.h"
#include "common_vaapi.h"
/* =====================================================
* Linux implementation of OS-specific utility functions
*/
mfxStatus Initialize(mfxIMPL impl, mfxVersion ver, MFXVideoSession* pSession, mfxFrameAllocator* pmfxAllocator, bool bCreateSharedHandles)
{
mfxStatus sts = MFX_ERR_NONE;
// Initialize Intel Media SDK Session
sts = pSession->Init(impl, &ver);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
// Create VA display
mfxHDL displayHandle = { 0 };
sts = CreateVAEnvDRM(&displayHandle);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
// Provide VA display handle to Media SDK
sts = pSession->SetHandle(static_cast < mfxHandleType >(MFX_HANDLE_VA_DISPLAY), displayHandle);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
// If mfxFrameAllocator is provided it means we need to setup memory allocator
if (pmfxAllocator) {
pmfxAllocator->pthis = *pSession; // We use Media SDK session ID as the allocation identifier
pmfxAllocator->Alloc = simple_alloc;
pmfxAllocator->Free = simple_free;
pmfxAllocator->Lock = simple_lock;
pmfxAllocator->Unlock = simple_unlock;
pmfxAllocator->GetHDL = simple_gethdl;
// Since we are using video memory we must provide Media SDK with an external allocator
sts = pSession->SetFrameAllocator(pmfxAllocator);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
}
return sts;
}
void Release()
{
CleanupVAEnvDRM();
}
void mfxGetTime(mfxTime* timestamp)
{
clock_gettime(CLOCK_REALTIME, timestamp);
}
double TimeDiffMsec(mfxTime tfinish, mfxTime tstart)
{
double result;
long long elapsed_nsec = tfinish.tv_nsec - tstart.tv_nsec;
long long elapsed_sec = tfinish.tv_sec - tstart.tv_sec;
//if (tstart.tv_sec==0) return -1;
//timespec uses two fields -- check if borrowing necessary
if (elapsed_nsec < 0) {
elapsed_sec -= 1;
elapsed_nsec += 1000000000;
}
//return total converted to milliseconds
result = (double)elapsed_sec *1000.0;
result += (double)elapsed_nsec / 1000000;
return result;
}
void ClearYUVSurfaceVMem(mfxMemId memId)
{
ClearYUVSurfaceVAAPI(memId);
}
void ClearRGBSurfaceVMem(mfxMemId memId)
{
ClearRGBSurfaceVAAPI(memId);
}
| 33.556604 | 138 | 0.712679 | VickyZengg |
a1046c63df551892daef9509963a344438f9cd83 | 5,773 | hpp | C++ | libraries/lib-polymer/include/polymer-core/tools/simple-animator.hpp | ddiakopoulos/polymer | a052d6cea5c9714ca3a8f9200bf626eb2df85601 | [
"BSD-3-Clause"
] | 256 | 2019-01-06T00:30:05.000Z | 2022-03-12T15:41:04.000Z | libraries/lib-polymer/include/polymer-core/tools/simple-animator.hpp | ddiakopoulos/polymer | a052d6cea5c9714ca3a8f9200bf626eb2df85601 | [
"BSD-3-Clause"
] | 8 | 2019-01-06T01:46:43.000Z | 2021-03-17T18:00:55.000Z | libraries/lib-polymer/include/polymer-core/tools/simple-animator.hpp | ddiakopoulos/polymer | a052d6cea5c9714ca3a8f9200bf626eb2df85601 | [
"BSD-3-Clause"
] | 22 | 2019-01-06T22:31:51.000Z | 2022-01-27T02:13:21.000Z | #pragma once
#ifndef polymer_simple_animator_hpp
#define polymer_simple_animator_hpp
#include "polymer-core/util/util.hpp"
#include "polymer-core/math/math-common.hpp"
#include <list>
#include <functional>
#include <thread>
namespace tween
{
struct linear
{
inline static float ease_in_out(const float t) { return t; }
};
struct sine
{
inline static float ease_in_out(float t)
{
return -0.5f * (std::cos((float)POLYMER_PI * t) - 1.f);
}
};
struct smoothstep
{
inline static float ease_in_out(const float t)
{
float scale = t * t * (3.f - 2.f * t);
return scale * 1.0f;
}
};
struct circular
{
inline static float ease_in_out(float t)
{
t *= 2;
if (t < 1) return -0.5f * (sqrt(1 - t * t) - 1);
else
{
t -= 2;
return 0.5f * (sqrt(1 - t * t) + 1);
}
}
};
struct exp
{
inline static float ease_in_out(float t)
{
if (t == 0.f) return 0.f;
if (t == 1.f) return 1.f;
t *= 2;
if (t < 1) return 0.5f * std::powf(2, 10 * (t - 1));
return 0.5f * (-std::powf(2, -10 * (t - 1)) + 2);
}
};
struct cubic
{
inline static float ease_in_out(float t)
{
t *= 2;
if (t < 1) return 0.5f * t*t*t;
t -= 2;
return 0.5f*(t*t*t + 2);
}
};
struct quartic
{
inline static float ease_in_out(float t)
{
t *= 2;
if (t < 1) return 0.5f*t*t*t*t;
else
{
t -= 2;
return -0.5f * (t*t*t*t - 2.0f);
}
}
};
}
namespace polymer
{
enum playback_state
{
none = 0x1,
loop = 0x2,
playback_forward = 0x4,
playback_reverse = 0x8,
};
class tween_event
{
void * variable;
float t0, t1;
std::function<void(float t)> forward_update_impl;
std::function<void(float t)> reverse_update_impl;
friend class simple_animator;
float duration_seconds;
public:
tween_event(void * v, float t0, float t1, float duration, std::function<void(float t)> fwd, std::function<void(float t)> rvs)
: variable(v), t0(t0), t1(t1), duration_seconds(duration), forward_update_impl(fwd), reverse_update_impl(rvs) {}
std::function<void()> on_finish;
std::function<void(float t)> on_update;
playback_state state {static_cast<playback_state>(none | playback_forward)};
};
// A simple playback manager for basic animation curves.
// @todo - threading, on_start callback, trigger delay, polymer::property support
class simple_animator
{
std::list<tween_event> tweens;
float now_seconds = 0.0f;
public:
void update(const float dt)
{
now_seconds += dt;
for (auto it = begin(tweens); it != end(tweens);)
{
if (now_seconds < it->t1)
{
const float dx = static_cast<float>((now_seconds - it->t0) / (it->t1 - it->t0));
if (it->on_update) it->on_update(dx);
if (it->state & playback_forward) it->forward_update_impl(dx);
else it->reverse_update_impl(dx);
++it;
}
else
{
if (it->state & loop)
{
it->t0 = now_seconds;
it->t1 = now_seconds + it->duration_seconds;
if (it->state & playback_forward)
{
it->state = static_cast<playback_state>(it->state & ~playback_forward); // unset fwd
it->state = static_cast<playback_state>(it->state | playback_reverse); // set reverse
}
else
{
it->state = static_cast<playback_state>(it->state & ~playback_reverse);
it->state = static_cast<playback_state>(it->state | playback_forward);
}
}
else
{
it->forward_update_impl(1.f);
if (it->on_update) it->on_update(1.f);
if (it->on_finish) it->on_finish();
it = tweens.erase(it);
}
}
}
}
void cancel_all()
{
tweens.clear();
}
template<class VariableType, class EasingFunc>
tween_event & add_tween(VariableType * variable, VariableType targetValue, float duration_seconds, EasingFunc ease)
{
VariableType initialValue = *variable;
auto forward_update = [initialValue, variable, targetValue, ease](float t)
{
*variable = static_cast<VariableType>(initialValue * (1.f - ease(t)) + targetValue * ease(t));
};
auto reverse_update = [initialValue, variable, targetValue, ease](float t)
{
*variable = static_cast<VariableType>(targetValue * (1.f - ease(t)) + initialValue * ease(t));
};
tweens.emplace_back(variable, now_seconds, now_seconds + duration_seconds, duration_seconds, forward_update, reverse_update);
return tweens.back();
}
};
}
#endif // end polymer_simple_animator_hpp
| 29.156566 | 137 | 0.482591 | ddiakopoulos |
a107727d8868b0f340d0abee93cc11c7716c0823 | 3,668 | hpp | C++ | src/base/command/CommandUtil.hpp | saichikine/GMAT | 80bde040e12946a61dae90d9fc3538f16df34190 | [
"Apache-2.0"
] | null | null | null | src/base/command/CommandUtil.hpp | saichikine/GMAT | 80bde040e12946a61dae90d9fc3538f16df34190 | [
"Apache-2.0"
] | null | null | null | src/base/command/CommandUtil.hpp | saichikine/GMAT | 80bde040e12946a61dae90d9fc3538f16df34190 | [
"Apache-2.0"
] | 1 | 2021-12-05T05:40:15.000Z | 2021-12-05T05:40:15.000Z | //$Id$
//------------------------------------------------------------------------------
// CommandUtil
//------------------------------------------------------------------------------
// GMAT: General Mission Analysis Tool
//
// Copyright (c) 2002 - 2018 United States Government as represented by the
// Administrator of the National Aeronautics and Space Administration.
// All Other Rights Reserved.
//
// 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.
//
// Developed jointly by NASA/GSFC and Thinking Systems, Inc. under contract
// number S-67573-G
//
// Author: Linda Jun
// Created: 2005/11/28
//
/**
* This file provides methods to get whole mission sequence string.
*/
//------------------------------------------------------------------------------
#ifndef CommandUtil_hpp
#define CommandUtil_hpp
#include "gmatdefs.hpp"
#include "GmatCommand.hpp"
namespace GmatCommandUtil
{
GmatCommand GMAT_API *GetFirstCommand(GmatCommand *cmd);
GmatCommand GMAT_API *GetLastCommand(GmatCommand *cmd);
GmatCommand GMAT_API *GetNextCommand(GmatCommand *cmd);
GmatCommand GMAT_API *GetPreviousCommand(GmatCommand *from, GmatCommand *cmd);
GmatCommand GMAT_API *GetMatchingEnd(GmatCommand *cmd, bool getMatchingElse = false);
GmatCommand GMAT_API *GetParentCommand(GmatCommand *top, GmatCommand *cmd);
GmatCommand GMAT_API *GetSubParent(GmatCommand *brCmd, GmatCommand *cmd);
GmatCommand GMAT_API *RemoveCommand(GmatCommand *seq, GmatCommand *cmd);
bool GMAT_API IsElseFoundInIf(GmatCommand *ifCmd);
bool GMAT_API ClearCommandSeq(GmatCommand *seq, bool leaveFirstCmd = true,
bool callRunComplete = true);
bool GMAT_API IsAfter(GmatCommand *cmd1, GmatCommand *cmd2);
void GMAT_API ResetCommandSequenceChanged(GmatCommand *cmd);
void GMAT_API ResetBranchCommandChanged(GmatCommand *brCmd, Integer level);
bool GMAT_API HasCommandSequenceChanged(GmatCommand *cmd);
bool GMAT_API HasBranchCommandChanged(GmatCommand *brCmd, Integer level);
bool GMAT_API FindObject(GmatCommand *cmd, UnsignedInt objType,
const std::string &objName, std::string &cmdName,
GmatCommand **cmdUsing, bool checkWrappers = false);
bool GMAT_API FindObjectFromSubCommands(GmatCommand *brCmd, Integer level,
UnsignedInt objType, const std::string &objName,
std::string &cmdName, GmatCommand **cmdUsing, bool checkWrappers = false);
std::string GMAT_API GetCommandSeqString(GmatCommand *cmd, bool showAddr = true,
bool showGenStr = false, bool showSummaryName = false,
const std::string &indentStr = "---");
void GMAT_API GetSubCommandString(GmatCommand* brCmd, Integer level,
std::string &cmdseq, bool showAddr = true,
bool showGenStr = false, bool showSummaryName = false,
const std::string &indentStr = "---");
void GMAT_API ShowCommand(const std::string &title1, GmatCommand *cmd1,
const std::string &title2 = "", GmatCommand *cmd2 = NULL);
}
#endif // CommandUtil_hpp
| 50.246575 | 95 | 0.662214 | saichikine |
a1095a6cf96c8331e225ba4ce9baadb5e73124ab | 11,370 | cpp | C++ | tests/bin/mt_mssd.cpp | Guanmoyu/Tengine | 2628086834f5e25455d175df732713618c8445d9 | [
"Apache-2.0"
] | 2 | 2020-12-14T14:49:03.000Z | 2021-05-14T08:09:59.000Z | tests/bin/mt_mssd.cpp | Guanmoyu/Tengine | 2628086834f5e25455d175df732713618c8445d9 | [
"Apache-2.0"
] | null | null | null | tests/bin/mt_mssd.cpp | Guanmoyu/Tengine | 2628086834f5e25455d175df732713618c8445d9 | [
"Apache-2.0"
] | null | null | null | /*
* 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.
*/
/*
* Copyright (c) 2018, Open AI Lab
* Author: chunyinglv@openailab.com
*/
#include <unistd.h>
#include <sys/time.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <memory>
#include <thread>
#include <mutex>
#include <atomic>
#include "tengine_operations.h"
#include "tengine_c_api.h"
#include "cpu_device.h"
#define DEF_PROTO "models/MobileNetSSD_deploy.prototxt"
#define DEF_MODEL "models/MobileNetSSD_deploy.caffemodel"
#define DEF_IMAGE "tests/images/ssd_dog.jpg"
std::atomic<int> thread_done;
int thread_num = 0;
std::string image_file;
std::string cpu_2A72_save_name = "cpu_2A72";
std::string cpu_4A53_save_name = "cpu_4A53";
std::string gpu_save_name = "gpu";
int cpu_2A72_repeat_count = 120;
int gpu_repeat_count = 105;
int cpu_4A53_repeat_count = 95;
volatile int barrier = 1;
struct Box
{
float x0;
float y0;
float x1;
float y1;
int class_idx;
float score;
};
void get_input_data_ssd(std::string& image_file, float* input_data, int img_h, int img_w)
{
image img = imread(image_file.c_str());
image resImg = resize_image(img, img_w, img_h);
resImg = rgb2bgr_premute(resImg);
float* img_data = ( float* )resImg.data;
int hw = img_h * img_w;
float mean[3] = {127.5, 127.5, 127.5};
for(int c = 0; c < 3; c++)
{
for(int h = 0; h < img_h; h++)
{
for(int w = 0; w < img_w; w++)
{
input_data[c * hw + h * img_w + w] = 0.007843 * (*img_data - mean[c]);
img_data++;
}
}
}
}
void post_process_ssd(std::string& image_file, float threshold, float* outdata, int num, const std::string& save_name)
{
const char* class_names[] = {"background", "aeroplane", "bicycle", "bird", "boat", "bottle",
"bus", "car", "cat", "chair", "cow", "diningtable",
"dog", "horse", "motorbike", "person", "pottedplant", "sheep",
"sofa", "train", "tvmonitor"};
image im = imread(image_file.c_str());
int raw_h = im.h;
int raw_w = im.w;
std::vector<Box> boxes;
printf("detect result num: %d \n", num);
for(int i = 0; i < num; i++)
{
if(outdata[1] >= threshold)
{
Box box;
box.class_idx = outdata[0];
box.score = outdata[1];
box.x0 = outdata[2] * raw_w;
box.y0 = outdata[3] * raw_h;
box.x1 = outdata[4] * raw_w;
box.y1 = outdata[5] * raw_h;
boxes.push_back(box);
printf("%s\t:%.0f%%\n", class_names[box.class_idx], box.score * 100);
printf("BOX:( %g , %g ),( %g , %g )\n", box.x0, box.y0, box.x1, box.y1);
}
outdata += 6;
}
for(int i = 0; i < ( int )boxes.size(); i++)
{
Box box = boxes[i];
std::ostringstream score_str;
score_str << box.score * 100;
std::string labelstr = std::string(class_names[box.class_idx]) + " : " + score_str.str();
put_label(im, labelstr.c_str(), 0.02, box.x0, box.y0, 255, 255, 125);
draw_box(im, box.x0, box.y0, box.x1, box.y1, 2, 125, 0, 125);
}
save_image(im, "Mobilenet_SSD.jpg");
std::cout << "======================================\n";
std::cout << "[DETECTED IMAGE SAVED]:\t"
<< "Mobilenet_SSD"
<< "\n";
std::cout << "======================================\n";
}
void run_test(graph_t graph, const std::string& save_name, int repeat_count, float* avg_time)
{
int img_h = 300;
int img_w = 300;
int img_size = img_h * img_w * 3;
float* input_data = ( float* )malloc(sizeof(float) * img_size);
int node_idx = 0;
int tensor_idx = 0;
tensor_t input_tensor = get_graph_input_tensor(graph, node_idx, tensor_idx);
if(input_tensor == nullptr)
{
printf("Get input node failed : node_idx: %d, tensor_idx: %d\n", node_idx, tensor_idx);
return;
}
int dims[] = {1, 3, img_h, img_w};
set_tensor_shape(input_tensor, dims, 4);
int ret_prerun = prerun_graph(graph);
if(ret_prerun < 0)
{
std::printf("prerun failed\n");
return;
}
if(save_name == "gpu")
{
// warm up
get_input_data_ssd(image_file, input_data, img_h, img_w);
set_tensor_buffer(input_tensor, input_data, img_size * 4);
run_graph(graph, 1);
barrier = 0;
}
else
{
while(barrier)
;
}
struct timeval t0, t1;
float total_time = 0.f;
for(int i = 0; i < repeat_count; i++)
{
get_input_data_ssd(image_file, input_data, img_h, img_w);
gettimeofday(&t0, NULL);
set_tensor_buffer(input_tensor, input_data, img_size * 4);
run_graph(graph, 1);
gettimeofday(&t1, NULL);
float mytime = ( float )((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
total_time += mytime;
}
std::cout << "--------------------------------------\n";
std::cout << save_name << ": repeat " << repeat_count << " times, avg " << total_time / repeat_count
<< " ms all: " << total_time << "ms\n";
(*avg_time) = total_time / repeat_count;
tensor_t out_tensor = get_graph_output_tensor(graph, 0, 0); //"detection_out");
int out_dim[4];
get_tensor_shape(out_tensor, out_dim, 4);
float* outdata = ( float* )get_tensor_buffer(out_tensor);
int num = out_dim[1];
float show_threshold = 0.5;
post_process_ssd(image_file, show_threshold, outdata, num, save_name + "_save.jpg");
release_graph_tensor(out_tensor);
release_graph_tensor(input_tensor);
postrun_graph(graph);
free(input_data);
destroy_graph(graph);
}
void cpu_thread_a53(const char* pproto_file, const char* pmodel_file, float* avg_time)
{
graph_t graph = create_graph(NULL, "caffe", pproto_file, pmodel_file);
if(graph == nullptr)
{
thread_done++;
return;
}
if(set_graph_device(graph, "a53") < 0)
{
std::cerr << "set device a53 failed\n";
}
run_test(graph, cpu_4A53_save_name, cpu_4A53_repeat_count, avg_time);
thread_done++;
}
void cpu_thread_a72(const char* pproto_file, const char* pmodel_file, float* avg_time)
{
graph_t graph = create_graph(NULL, "caffe", pproto_file, pmodel_file);
if(graph == nullptr)
{
thread_done++;
return;
}
if(set_graph_device(graph, "a72") < 0)
{
std::cerr << "set device a72 failed\n";
}
run_test(graph, cpu_2A72_save_name, cpu_2A72_repeat_count, avg_time);
thread_done++;
}
void gpu_thread(const char* pproto_file, const char* pmodel_file, float* avg_time)
{
graph_t graph = create_graph(NULL, "caffe", pproto_file, pmodel_file);
if(graph == nullptr)
{
thread_done++;
return;
}
set_graph_device(graph, "acl_opencl");
run_test(graph, gpu_save_name, gpu_repeat_count, avg_time);
thread_done++;
}
int main(int argc, char* argv[])
{
const std::string root_path;
std::string proto_file;
std::string model_file;
const char* pproto_file;
const char* pmodel_file;
int res;
while((res = getopt(argc, argv, "p:m:i:hd:")) != -1)
{
switch(res)
{
case 'p':
proto_file = optarg;
break;
case 'm':
model_file = optarg;
break;
case 'i':
image_file = optarg;
break;
case 'h':
std::cout << "[Usage]: " << argv[0] << " [-h]\n"
<< " [-p proto_file] [-m model_file] [-i image_file]\n";
return 0;
default:
break;
}
}
if(proto_file.empty())
{
proto_file = root_path + DEF_PROTO;
std::cout << "proto file not specified,using " << proto_file << " by default\n";
}
if(model_file.empty())
{
model_file = root_path + DEF_MODEL;
std::cout << "model file not specified,using " << model_file << " by default\n";
}
if(image_file.empty())
{
image_file = root_path + DEF_IMAGE;
std::cout << "image file not specified,using " << image_file << " by default\n";
}
/* do not let GPU run concat */
setenv("GPU_CONCAT", "0", 1);
/* using GPU fp16 */
setenv("ACL_FP16", "1", 1);
/* default CPU device using 0,1,2,3 */
setenv("TENGINE_CPU_LIST", "2", 1);
/* using fp32 or int8 */
setenv("KERNEL_MODE", "2", 1);
// init tengine
init_tengine();
if(request_tengine_version("0.9") < 0)
return -1;
// collect avg_time for each case
float avg_times[3] = {0., 0., 0.};
// thread 0 for cpu 2A72
const struct cpu_info* p_info = get_predefined_cpu("rk3399");
int a72_list[] = {4, 5};
set_online_cpu(( struct cpu_info* )p_info, a72_list, sizeof(a72_list) / sizeof(int));
create_cpu_device("a72", p_info);
// thread 3 for cpu 4A53
const struct cpu_info* p_info1 = get_predefined_cpu("rk3399");
int a53_list[] = {0, 1, 2, 3};
set_online_cpu(( struct cpu_info* )p_info1, a53_list, sizeof(a53_list) / sizeof(int));
create_cpu_device("a53", p_info1);
#if 0
if (load_model(model_name, "caffe", proto_file.c_str(), model_file.c_str()) < 0)
{
std::cout<<"load model failed\n";
return 1;
}
std::cout << "load model done!\n";
#endif
pproto_file = proto_file.c_str();
pmodel_file = model_file.c_str();
thread_done = 0;
std::thread* t0 = new std::thread(cpu_thread_a72, pproto_file, pmodel_file, &avg_times[0]);
thread_num++;
// thread 1 for gpu +1 A53
std::thread* t1 = new std::thread(gpu_thread, pproto_file, pmodel_file, &avg_times[1]);
thread_num++;
std::thread* t2 = new std::thread(cpu_thread_a53, pproto_file, pmodel_file, &avg_times[2]);
thread_num++;
t0->join();
delete t0;
t1->join();
delete t1;
t2->join();
delete t2;
std::cout << "thread_done: " << ( int )thread_done << "\ntest done\n";
std::cout << "=================================================\n";
std::cout << " Using 3 thread, MSSD performance "
<< (1000. / avg_times[0] + 1000. / avg_times[1] + 1000. / avg_times[2]) << " FPS \n";
std::cout << "=================================================\n";
release_tengine();
return 0;
}
| 29.764398 | 118 | 0.575989 | Guanmoyu |
a10b4888c142fac2b4bb43cfdde7a16716b4608c | 771 | hpp | C++ | include/RED4ext/Types/generated/game/EffectAction_NewEffect_ReverseFromLastHit.hpp | Cyberpunk-Extended-Development-Team/RED4ext.SDK | 2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae | [
"MIT"
] | 1 | 2021-02-01T23:07:50.000Z | 2021-02-01T23:07:50.000Z | include/RED4ext/Types/generated/game/EffectAction_NewEffect_ReverseFromLastHit.hpp | Cyberpunk-Extended-Development-Team/RED4ext.SDK | 2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae | [
"MIT"
] | null | null | null | include/RED4ext/Types/generated/game/EffectAction_NewEffect_ReverseFromLastHit.hpp | Cyberpunk-Extended-Development-Team/RED4ext.SDK | 2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae | [
"MIT"
] | null | null | null | #pragma once
// This file is generated from the Game's Reflection data
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/REDhash.hpp>
#include <RED4ext/CName.hpp>
#include <RED4ext/Types/generated/game/EffectPostAction.hpp>
namespace RED4ext
{
namespace game {
struct EffectAction_NewEffect_ReverseFromLastHit : game::EffectPostAction
{
static constexpr const char* NAME = "gameEffectAction_NewEffect_ReverseFromLastHit";
static constexpr const char* ALIAS = NAME;
CName tagInThisFile; // 40
float forwardOffset; // 48
bool childEffect; // 4C
uint8_t unk4D[0x50 - 0x4D]; // 4D
CName childEffectTag; // 50
};
RED4EXT_ASSERT_SIZE(EffectAction_NewEffect_ReverseFromLastHit, 0x58);
} // namespace game
} // namespace RED4ext
| 27.535714 | 88 | 0.757458 | Cyberpunk-Extended-Development-Team |
a10b5d8d6b63f90d2959a933a050822761048db7 | 25,800 | cpp | C++ | common/ArgonEngine/ArgonInit.cpp | skylersaleh/ArgonEngine | 7847269b720892f7e9a64907ec9ee13ab80037fd | [
"MIT"
] | null | null | null | common/ArgonEngine/ArgonInit.cpp | skylersaleh/ArgonEngine | 7847269b720892f7e9a64907ec9ee13ab80037fd | [
"MIT"
] | null | null | null | common/ArgonEngine/ArgonInit.cpp | skylersaleh/ArgonEngine | 7847269b720892f7e9a64907ec9ee13ab80037fd | [
"MIT"
] | null | null | null | //Generated by the Argon Build System
#include "ArgonInit.h"
#define GLFW_USE_CHDIR 1
#include <stdlib.h>
#include "Utility.h"
#include "Hardware.h"
#include "VirtualResource.h"
#ifdef USE_GLEW
#include "GL/glew.h"
#endif
#ifdef USE_SDL
#include "SDL2/SDL.h"
#ifdef USE_OPENGL
#ifndef USE_OPENGLES
#include "SDL2/SDL_opengl.h"
#endif
#endif
#ifdef USE_OPENGLES
#include "SDL2/SDL_opengles2.h"
#endif
#endif
#ifdef USE_GLFW
#include "GLFW/glfw3.h"
#endif
#ifdef PLATFORM_UNIX
#include <unistd.h>
#include <pwd.h>
#endif
#ifdef PLATFORM_WINDOWS
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#ifdef USE_RTAUDIO
#include <RtAudio/RtAudio.h>
#endif
#include <iostream>
#include "AudioSystem.h"
#ifdef PLATFORM_WINDOWS
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include <shlobj.h>
#include <knownfolders.h>
#include <objbase.h>
#endif
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_RESET "\x1b[0m"
namespace Argon{
static void (*manual_redraw)()=NULL;
bool run=true;
Vector2f last_screen;
Vector2f last_position;
Vector2f last_minimum_size;
bool last_screen_enabled=true;
bool last_full_screen;
std::string last_title;
void set_manual_redraw(void (*draw)()){manual_redraw=draw;}
static void InitVirtual(std::string organization_name, std::string app_name){
std::cout<<"Argon Engine"<<std::endl;
std::cout<<"------------"<<std::endl;
#ifdef USE_SDL
std::string base = SDL_GetBasePath();
char* c = SDL_GetPrefPath(organization_name.c_str(),app_name.c_str());
std::string doc_dir = c;
SDL_free(c);
std::string home ="";
std::string pref_dir = c;
std::string tmp_dir = pref_dir;
#ifdef PLATFORM_UNIX
home = getenv("HOME");
if (!home.size()) {
struct passwd* pwd = getpwuid(getuid());
if (pwd)
home = pwd->pw_dir;
}
doc_dir=home;
std::cout<<"Home directory is "<<home<<"\n";
if(getenv("TMPDIR"))
tmp_dir = getenv("TMPDIR");
std::cout<<"TMP directory is "<<tmp_dir<<"\n";
#endif
#endif
#ifdef PLATFORM_MAC
doc_dir = home+"/Documents";
pref_dir = home+"/Library/Application Support/"+organization_name+"/"+app_name;
#endif
#ifdef PLATFORM_WINDOWS
char output[MAX_PATH];
output[MAX_PATH-1] = 0;
SHGetFolderPathA(NULL,CSIDL_PERSONAL,NULL,CSIDL_FLAG_NO_ALIAS,output);
doc_dir = output;
SHGetFolderPathA(NULL,CSIDL_LOCAL_APPDATA,NULL,CSIDL_FLAG_NO_ALIAS,output);
pref_dir = output;
#endif
std::cout<< "Save files are stored in "<<doc_dir<<"\n";
VirtualResource::all_sources()["document:"]=new VirtualResourceIO(doc_dir,true);
VirtualResource::all_sources()["resource:"]=new VirtualResourceIO(base+"resources",false);
VirtualResource::all_sources()["shader:"]=new VirtualResourceIO(base+"shaders",false);
VirtualResource::all_sources()["user:"]=
VirtualResource::all_sources()["home:"]=new VirtualResourceIO(home,true);
VirtualResource::all_sources()["save:"]=
VirtualResource::all_sources()["app-data:"]=
VirtualResource::all_sources()["pref:"]=new VirtualResourceIO(pref_dir,true);
VirtualResource::all_sources()["cache:"]=
VirtualResource::all_sources()["tmp:"]=new VirtualResourceIO(tmp_dir,true);
Argon::VirtualResource::initialize();
}
void update_frame(){
Argon::Listener::current_frame++;
Argon::AudioSource3D* curr = Argon::AudioSource3D::root_source;
while(curr){
curr->finalize_data();
curr=curr->next_source;
}
}
#ifdef USE_GLFW
void resize(GLFWwindow* window, int x, int y);
void MouseCallback(GLFWwindow* window, double x, double y);
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
static void ScrollCallback(GLFWwindow* window, double x, double y);
static void MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
static void CursorEnterCallback(GLFWwindow* window, int entered);
static void WindowMinimizeCallback(GLFWwindow* window, int iconified);
static void WindowFocusCallback(GLFWwindow* window, int focused);
GLFWwindow* main_window;
static void Terminate(int code){
glfwTerminate();
exit(code);
}
static void InitWindow(){
if(glfwInit()!=GL_TRUE)return Terminate(1);
glfwDefaultWindowHints();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,1);
glfwWindowHint(GLFW_SAMPLES,4);
glfwWindowHint(GLFW_ALPHA_BITS, 8);
//if(glfwOpenWindow(800,600,8,8,8,8,24,0,GLFW_WINDOW)!=GL_TRUE)return Terminate(1);
if(!(main_window=glfwCreateWindow(800,600,"ArgonEngineApp",NULL,NULL))){
std::cout<<"Couldn't create window\n";
Terminate(-1);
}
Argon::Screen::width=800;
Argon::Screen::height=600;
last_full_screen=Screen::full_screen;
last_screen=Vector2f(Screen::width,Screen::height);
glfwMakeContextCurrent(main_window);
glfwSetWindowSizeCallback(main_window,&resize);
glfwSetCursorPosCallback(main_window,&MouseCallback);
glfwSetKeyCallback(main_window, &KeyCallback);
glfwSetScrollCallback(main_window, &ScrollCallback);
glfwSetMouseButtonCallback(main_window, &MouseButtonCallback);
glfwSetCursorEnterCallback(main_window, &CursorEnterCallback);
glfwSetWindowFocusCallback(main_window, &WindowFocusCallback);
glfwSetWindowIconifyCallback(main_window, &WindowMinimizeCallback);
glfwSwapInterval(1);
}
static void WindowFocusCallback(GLFWwindow* window, int focused)
{
Argon::Input::push_update(kInputIDWindowInactive, !focused);
}
static void WindowMinimizeCallback(GLFWwindow* window, int iconified)
{
Argon::Input::push_update(kInputIDWindowMinimized, iconified);
}
void resize(GLFWwindow* window, int x, int y)
{
Argon::Screen::width=x;
Argon::Screen::height=y;
}
void MouseCallback(GLFWwindow* window, double x,double y){
if(Argon::Screen::height&&Argon::Screen::width){
Argon::Input::push_update(kInputIDMouseX, x/Argon::Screen::width*2.-1.);
Argon::Input::push_update(kInputIDMouseY, y/Argon::Screen::height*-2.+1.);
}
}
static void MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
{
if(button==2)button=1;
else if (button==1)button=2;
if(action==GLFW_PRESS)
Argon::Input::push_update(kInputIDMouseButton0+button, 1.0);
else if(action==GLFW_RELEASE)
Argon::Input::push_update(kInputIDMouseButton0+button, 0.0);
}
static void ScrollCallback(GLFWwindow* window, double x, double y)
{
Argon::Input::push_update(kInputIDMouseHorzScroll, x);
Argon::Input::push_update(kInputIDMouseVertScroll, y);
}
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if(action==GLFW_PRESS)
Argon::Input::push_update(kInputKeyboard|uint16_t(key), 1.0);
else if(action==GLFW_RELEASE)
Argon::Input::push_update(kInputKeyboard|uint16_t(key), 0.0);
}
void PollJoysticks(){
for(int x=GLFW_JOYSTICK_1;x<GLFW_JOYSTICK_LAST;++x)
{
if(glfwJoystickPresent(x)){
int size =0;
const float* axes=glfwGetJoystickAxes(x, &size);
uint8_t device_bits = Argon::kInputDevice0+x;
for(int i=0;i<size;++i){
uint16_t axis_bits = Argon::kInputAxisX+i;
Argon::Input::push_update(Argon::kInputJoy|device_bits|axis_bits, axes[i]);
}
size=1;
const uint8_t* buttons=glfwGetJoystickButtons(x, &size);
for(int i=0;i<size;++i){
uint16_t axis_bits = i;
Argon::Input::push_update(Argon::kInputJoy|device_bits|axis_bits, buttons[i]);
}
}
}
}
static void CursorEnterCallback(GLFWwindow* window, int entered)
{
Argon::Input::push_update(kInputIDWindowHasMouse, entered);
}
static void SetGamma(GLFWwindow* window, float value)
{
GLFWmonitor* monitor = glfwGetWindowMonitor(window);
if (!monitor)
monitor = glfwGetPrimaryMonitor();
float gamma_value = value;
glfwSetGamma(monitor, gamma_value);
}
int audio_callback( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
{
float *buffer = (float *) outputBuffer;
if ( status )
std::cout << "Stream underflow detected!" << std::endl;
for (size_t i=0; i<Argon::kAudioBufferSize*2; ++i) buffer[i]=0;
for(size_t i=0;i<Argon::kAudioNumberOfChannels;++i)
if(Argon::AudioNode::root_nodes[i]) Argon::AudioNode::root_nodes[i]->render(buffer+i*Argon::kAudioBufferSize);
update_frame();
return 0;
}
void cleanup_rtaudio(RtAudio&dac){
if ( dac.isStreamOpen() ) {
try {dac.stopStream();}
catch ( RtError& e ) {
e.printMessage();
}
dac.closeStream();
}
}
void init_rtaudio(RtAudio &dac){
InitVirtual();
unsigned int bufferFrames;
if ( dac.getDeviceCount() < 1 ) {
std::cout << "\nNo audio devices found!\n";
cleanup_rtaudio(dac);
}
// Let RtAudio print messages to stderr.
dac.showWarnings( true );
// Set our stream parameters for output only.
bufferFrames =Argon::kAudioBufferSize;
RtAudio::StreamParameters oParams;
oParams.deviceId = dac.getDefaultOutputDevice();
oParams.nChannels = Argon::kAudioNumberOfChannels;
oParams.firstChannel = 0;
RtAudio::StreamOptions options;
options.flags = RTAUDIO_SCHEDULE_REALTIME | RTAUDIO_NONINTERLEAVED;
try {
dac.openStream( &oParams, NULL, RTAUDIO_FLOAT32, Argon::kAudioSampleRate, &bufferFrames, &audio_callback, NULL, &options );
dac.startStream();
}
catch ( RtError& e ) {
e.printMessage();
cleanup_rtaudio(dac);
}
}
RtAudio dac;
void initialize_engine(){
InitWindow();
InitVirtual();
init_rtaudio(dac);
int code=0;
if(GLEW_OK!=(code=glewInit())){
std::cout<<"GLEW Failed to init: "<<code<<"\n"; Terminate(-1);
};
if(!GLEW_VERSION_2_0){
std::cout<<"OpenGL 2.0 is required\n"; Terminate(-1);
};
SetGamma(main_window,1.0);
}
void terminate_engine(){
glfwDestroyWindow(main_window);
std::cout<<"Quit\n";
cleanup_rtaudio(dac);
Terminate(0);
}
bool poll_events(){
glfwPollEvents();
PollJoysticks();
return !glfwWindowShouldClose(main_window);
}
void swap_buffers(){
glfwSwapBuffers(main_window);
}
#endif
#ifdef USE_SDL
static SDL_GLContext context;
static SDL_Window *win = nullptr;
int handle_event(void* userdata,SDL_Event* event);
void terminate_engine(){
if (context) {
/* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
SDL_GL_DeleteContext(context);
}
SDL_Quit();
exit(0);
}
SDL_AudioDeviceID dev;
int audio_buffer_index=0;
static float audio_buffer[Argon::kAudioNumberOfChannels][Argon::kAudioBufferSize];
void sdl_audio_callback(void *userdata, Uint8 * stream,int len){
float *buffer = (float *) stream;
len = len/4;
for(int o=0;o<len;){
if(audio_buffer_index==Argon::kAudioBufferSize){
for(size_t c=0;c<Argon::kAudioNumberOfChannels;++c)
for (size_t i=0; i<Argon::kAudioBufferSize; ++i) audio_buffer[c][i]=0;
for(size_t i=0;i<Argon::kAudioNumberOfChannels;++i)
if(Argon::AudioNode::root_nodes[i]) Argon::AudioNode::root_nodes[i]->render(audio_buffer[i]);
audio_buffer_index=0;
}
for(size_t c=0;c<Argon::kAudioNumberOfChannels;++c){
buffer[o++]=audio_buffer[c][audio_buffer_index];
}
++audio_buffer_index;
}
update_frame();
}
void init_audio(){
SDL_AudioSpec want, have;
SDL_zero(want);
want.freq = Argon::kAudioSampleRate;
want.format = AUDIO_F32SYS;
want.channels = 2;
want.samples = Argon::kAudioBufferSize;
want.callback=sdl_audio_callback;
if (SDL_OpenAudio(&want, &have) < 0) {
printf("Failed to open audio: %s\n", SDL_GetError());
}
std::cout<<"Audio Sample Rate: "<<have.freq<<"\n";
std::cout<<"Audio Channels: "<<int(have.channels)<<"\n";
SDL_PauseAudio(0);
}
void initialize_engine(std::string organization_name, std::string app_name){
SDL_SetMainReady();
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
std::cout << SDL_GetError() << std::endl;
terminate_engine();
}
//Enable VSync
if( !SDL_SetHint( SDL_HINT_RENDER_VSYNC, "1" ) )
{
printf( "Warning: VSync not enabled!" );
}
InitVirtual(organization_name, app_name);
init_audio();
SDL_Rect r;
SDL_GetDisplayBounds(0, &r);
Argon::Screen::size=Vector2f(512, 512);
Argon::Screen::position=Vector2f(100, 100);
Argon::Screen::actual_size=Vector2f(r.w,r.h);
last_full_screen=Screen::full_screen;
last_screen=Screen::size;
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,1);
//SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
win = SDL_CreateWindow("test", 100, 100, Argon::Screen::size[0], Argon::Screen::size[1], SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
// Create an OpenGL context associated with the window.
//SDL_GLContext glcontext = SDL_GL_CreateContext(win);
context=SDL_GL_CreateContext(win);
SDL_GL_MakeCurrent(win, context);
#ifdef USE_GLEW
glewExperimental = GL_TRUE;
//SDL_GL_MakeCurrent(win, glcontext);
int code = 0;
if(GLEW_OK!=(code=glewInit())){
std::cout << glewGetErrorString(code) << std::endl;
std::cout<<"GLEW Failed to init: "<<code<<std::endl;
};
if(!GLEW_VERSION_2_0){
std::cout<<"OpenGL 2.0 is required\n";
};
#endif
//SDL_AddEventWatch(handle_event, NULL);
if (SDL_GL_SetSwapInterval(-1) != -1){}
else if (SDL_GL_SetSwapInterval(1) != -1){}
else std::cout << "Could not enable VSync.\n";
SDL_SetEventFilter(handle_event, NULL);
}
uint32_t sdl_key_to_argon(SDL_Keycode key){
if(key>=SDLK_F1&&key<=SDLK_F12)return kInputIDF1+key-SDLK_F1;
else if(key>=SDLK_F13&&key<=SDLK_F24)return kInputIDF13+key-SDLK_F13;
else if(key>=SDLK_KP_1&&key<=SDLK_KP_9)return kInputKeyboard|uint16_t(key-SDLK_KP_1 +321);
switch (key) {
case SDLK_KP_0: return kInputIDKP0;
case SDLK_KP_DECIMAL: return kInputIDKPDecimal;
case SDLK_KP_DIVIDE: return kInputIDKPDivide;
case SDLK_KP_MULTIPLY: return kInputIDKPMultiply;
case SDLK_KP_MINUS: return kInputIDKPSubtract;
case SDLK_KP_PLUS: return kInputIDKPAdd;
case SDLK_KP_ENTER: return kInputIDKPEnter;
case SDLK_KP_EQUALS: return kInputIDKPEqual;
case SDLK_LSHIFT:return kInputIDLeftShift;
case SDLK_RSHIFT:return kInputIDRightShift;
case SDLK_LALT:return kInputIDLeftAlt;
case SDLK_RALT:return kInputIDRightAlt;
case SDLK_LCTRL:return kInputIDLeftControl;
case SDLK_RCTRL:return kInputIDRightControl;
case SDLK_LGUI:return kInputIDLeftSuper;
case SDLK_RGUI:return kInputIDRightSuper;
case SDLK_MENU:return kInputIDMenu;
case SDLK_UP:return kInputIDUp;
case SDLK_DOWN:return kInputIDDown;
case SDLK_RIGHT:return kInputIDRight;
case SDLK_LEFT:return kInputIDLeft;
case SDLK_ESCAPE:return kInputIDEscape;
case SDLK_RETURN:return kInputIDEnter;
case SDLK_TAB:return kInputIDTab;
case SDLK_BACKSPACE:return kInputIDBackspace;
case SDLK_INSERT:return kInputIDInsert;
case SDLK_DELETE:return kInputIDDelete;
case SDLK_PAGEUP:return kInputIDPageUp;
case SDLK_PAGEDOWN:return kInputIDPageDown;
case SDLK_HOME:return kInputIDHome;
case SDLK_END:return kInputIDEnd;
case SDLK_CAPSLOCK:return kInputIDCapsLock;
case SDLK_SCROLLLOCK:return kInputIDScrollLock;
case SDLK_NUMLOCKCLEAR:return kInputIDNumLock;
case SDLK_PRINTSCREEN:return kInputIDPrintScreen;
case SDLK_PAUSE:return kInputIDPause;
}
return key;
}
void handle_joy_axis_event(SDL_Event &e){
uint32_t axis = e.jaxis.axis;
if(axis>1)++axis;
if(axis>5)++axis;
uint32_t id = kInputJoy| (kInputDeviceIncrement*e.jaxis.which)|(kInputAxisIncrement*axis+kInputAxisAnalogStart);
Argon::Input::push_update(id, e.jaxis.value/32768.f);
}
void handle_joy_button_event(SDL_Event &e){
uint32_t id = kInputJoy| (kInputDeviceIncrement*e.jbutton.which)|(kInputAxisIncrement*e.jbutton.button+kInputAxisButtonStart);
Argon::Input::push_update(id, e.jbutton.state);
}
void handle_joy_hat_event(SDL_Event &e){
uint32_t id = kInputJoy| (kInputDeviceIncrement*e.jhat.which)|(kInputAxisIncrement*e.jhat.hat+kInputAxisHatStart);
Argon::Input::push_update(id, e.jhat.value);
}
void handle_window_event(SDL_Event &e){
switch (e.window.event) {
case SDL_WINDOWEVENT_MOVED:
Argon::Screen::position=Vector2f(e.window.data1,e.window.data2);
last_position=Argon::Screen::position;
break;
case SDL_WINDOWEVENT_RESIZED:
Argon::Screen::size=Vector2f(e.window.data1,e.window.data2);
last_full_screen=Screen::full_screen;
last_screen=Screen::size;
if(manual_redraw){
//Redraw twice to fully update deffered state.
manual_redraw();
manual_redraw();
}
swap_buffers();
break;
case SDL_WINDOWEVENT_MINIMIZED:
Argon::Input::push_update(kInputIDWindowMinimized, 1);
break;
case SDL_WINDOWEVENT_RESTORED:
Argon::Input::push_update(kInputIDWindowMinimized, 0);
break;
case SDL_WINDOWEVENT_ENTER:
Argon::Input::push_update(kInputIDWindowHasMouse, 1);
break;
case SDL_WINDOWEVENT_LEAVE:
Argon::Input::push_update(kInputIDWindowHasMouse, 0);
break;
case SDL_WINDOWEVENT_EXPOSED:
case SDL_WINDOWEVENT_SHOWN:
case SDL_WINDOWEVENT_FOCUS_GAINED:
Argon::Input::push_update(kInputIDWindowInactive, 0);
break;
case SDL_WINDOWEVENT_HIDDEN:
case SDL_WINDOWEVENT_FOCUS_LOST:
Argon::Input::push_update(kInputIDWindowInactive, 1);
break;
}
}
std::map<int32_t, SDL_Joystick*> joys;
int handle_event(void* userdata,SDL_Event* event){
static float mousex = 0;
static float mousey = 0;
SDL_Event e=*event;
//Handle events on queue
// while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
run=false;
}else if (e.type==SDL_JOYDEVICEADDED){
SDL_Joystick* &j = joys[e.jdevice.which];
if(!j) j=SDL_JoystickOpen(e.jdevice.which);
}else if (e.type==SDL_JOYDEVICEREMOVED){
SDL_Joystick* &j = joys[e.jdevice.which];
if(j) SDL_JoystickClose(j);
j=NULL;
}else if (e.type==SDL_MOUSEMOTION){
Argon::Input::push_update(kInputIDMouseX, e.motion.x/Argon::Screen::size[0]*2.-1.);
Argon::Input::push_update(kInputIDMouseY, e.motion.y/Argon::Screen::size[1]*-2.+1.);
}else if(e.type==SDL_MOUSEBUTTONUP||e.type==SDL_MOUSEBUTTONDOWN){
Argon::Input::push_update(kInputIDMouseX, e.button.x/Argon::Screen::size[0]*2.-1.);
Argon::Input::push_update(kInputIDMouseY, e.button.y/Argon::Screen::size[1]*-2.+1.);
Argon::Input::push_update(kInputMouse|e.button.button, SDL_MOUSEBUTTONDOWN==e.type);
}else if(e.type==SDL_KEYDOWN||e.type==SDL_KEYUP){
SDL_Keycode key_c =SDL_GetKeyFromScancode(e.key.keysym.scancode);
uint32_t key =sdl_key_to_argon(key_c);
Argon::Input::push_update(key, e.key.state==SDL_PRESSED?1.0:0.);
}else if(e.type==SDL_WINDOWEVENT)handle_window_event(e);
else if (e.type ==SDL_JOYAXISMOTION)handle_joy_axis_event(e);
else if (e.type ==SDL_JOYBUTTONDOWN||e.type==SDL_JOYBUTTONUP)handle_joy_button_event(e);
else if (e.type ==SDL_JOYAXISMOTION)handle_joy_axis_event(e);
else if (e.type ==SDL_JOYHATMOTION)handle_joy_hat_event(e);
else if (e.type==SDL_JOYBALLMOTION){std::cout<<"BALL"<<std::endl;}
else if (e.type==SDL_MOUSEWHEEL){
if(e.wheel.which!=SDL_TOUCH_MOUSEID){
Argon::Input::push_update(kInputIDMouseHorzScroll,mousex+= e.wheel.x);
Argon::Input::push_update(kInputIDMouseVertScroll, mousey+=e.wheel.y);
}
}
}
return true;
}
void slow_poll(){
static int x=0;
//if(++x%10)return;
if(last_title!=Screen::title){
SDL_SetWindowTitle(win, Screen::title.c_str());
last_title=Screen::title;
}
if(SleepLock::sleep_enabled()!=last_screen_enabled){
last_screen_enabled=SleepLock::sleep_enabled();
if(SleepLock::sleep_enabled())SDL_EnableScreenSaver();
else SDL_DisableScreenSaver();
}
int secs=0,pct=0;
int state=SDL_GetPowerInfo(&secs, &pct);
if(state==SDL_POWERSTATE_CHARGING)Input::push_update(kInputIDBatteryState, kBatteryCharging);
else if(state==SDL_POWERSTATE_CHARGED)Input::push_update(kInputIDBatteryState, kBatteryFull);
else if(state==SDL_POWERSTATE_ON_BATTERY)Input::push_update(kInputIDBatteryState, kBatteryDischarging);
else Input::push_update(kInputIDBatteryState, kNoBattery);
Input::push_update(kInputIDBatteryTimeRemaining, secs);
Input::push_update(kInputIDBatteryPercent, pct);
}
bool poll_events(){
SDL_Event e;
while( SDL_PollEvent( &e ) != 0 ){
}
if(last_screen!=Screen::size){
SDL_SetWindowSize(win, Screen::size[0], Screen::size[1]);
last_screen=Screen::size;
manual_redraw();
manual_redraw();
SDL_GL_MakeCurrent(win, context);
SDL_GL_SwapWindow(win);
}
if(last_minimum_size!=Screen::minimum_size){
SDL_SetWindowMinimumSize(win, Screen::minimum_size[0], Screen::minimum_size[1]);
last_minimum_size=Screen::minimum_size;
}
if(last_full_screen!=Screen::full_screen){
SDL_SetWindowFullscreen(win, Screen::full_screen?SDL_WINDOW_FULLSCREEN_DESKTOP:0);
last_full_screen=Screen::full_screen;
last_screen=Screen::size;
manual_redraw();
manual_redraw();
SDL_GL_MakeCurrent(win, context);
SDL_GL_SwapWindow(win);
}
if(last_position!=Screen::position){
last_position=Screen::position;
SDL_SetWindowPosition(win, last_position[0], last_position[1]);
}
slow_poll();
return run;
}
Timer t;
void swap_buffers(){
static double accumulator = 0;
accumulator -= t.delta_time();
//Linear IFR based accumulator to approximate frame time.
while(accumulator > 0.0166666666666666666){
Argon::Thread::sleep(accumulator);
accumulator -= t.delta_time();
}
accumulator += 0.01666666666666666;
if (accumulator < -0.5)accumulator = -0.5;
SDL_GL_MakeCurrent(win, context);
SDL_GL_SwapWindow(win);
}
#endif
}
| 35.197817 | 167 | 0.621589 | skylersaleh |
a110e9f3a9991da1b79bba2f381598f3ccdf990a | 1,332 | hpp | C++ | gem/Code/Source/Types/AlarmHandle.hpp | loherangrin/addons.o3de.date-time | e3e7719204490dc2b69598e88803aaa1b3bb4fa3 | [
"Apache-2.0"
] | null | null | null | gem/Code/Source/Types/AlarmHandle.hpp | loherangrin/addons.o3de.date-time | e3e7719204490dc2b69598e88803aaa1b3bb4fa3 | [
"Apache-2.0"
] | null | null | null | gem/Code/Source/Types/AlarmHandle.hpp | loherangrin/addons.o3de.date-time | e3e7719204490dc2b69598e88803aaa1b3bb4fa3 | [
"Apache-2.0"
] | null | null | null | /* Copyright 2022 Matteo Grasso
*
* 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.
*/
#pragma once
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <DateTime/Types/Alarm.hpp>
namespace Loherangrin::Gems::DateTime
{
class Alarm;
}
namespace Loherangrin::Gems::DateTime
{
class AlarmHandle
{
public:
static AlarmHandle ReWrapAlarm(AlarmHandle&& io_alarmHandle);
AlarmHandle();
AlarmId GetAlarmId() const;
const Alarm* GetAlarm() const;
Alarm* GetAlarm();
AlarmComparison CompareTo(const AlarmHandle& i_other) const;
private:
using AlarmPointer = AZStd::shared_ptr<Alarm>;
AlarmHandle(AlarmId i_alarmId);
AlarmHandle(AlarmPointer&& io_alarm);
AlarmId m_alarmId;
AlarmPointer m_alarm;
static inline AlarmId s_lastAlarmId = 0;
friend Alarm;
};
} // Loherangrin::Gems::DateTime
| 22.965517 | 75 | 0.742492 | loherangrin |
e1627b8cd74c9c7d2422b4965a81becda20b1d82 | 979 | cpp | C++ | 01 Arrays/26 unionTwoSortedArrays.cpp | vishwaphansal/amazon-sde | 547258364b072f054732e12cb1e963eb665f2da7 | [
"Apache-2.0"
] | null | null | null | 01 Arrays/26 unionTwoSortedArrays.cpp | vishwaphansal/amazon-sde | 547258364b072f054732e12cb1e963eb665f2da7 | [
"Apache-2.0"
] | null | null | null | 01 Arrays/26 unionTwoSortedArrays.cpp | vishwaphansal/amazon-sde | 547258364b072f054732e12cb1e963eb665f2da7 | [
"Apache-2.0"
] | null | null | null | int removeDuplicates(int arr[], int n)
{
if (n==0 || n==1)
return n;
int j = 0;
for (int i=0; i < n-1; i++)
if (arr[i] != arr[i+1])
arr[j++] = arr[i];
arr[j++] = arr[n-1];
return j;
}
vector<int> findUnion(int arr1[], int arr2[], int n, int m)
{
vector<int> ans;
n = removeDuplicates(arr1, n);
m = removeDuplicates(arr2, m);
int i = 0, j = 0;
while (i < n && j < m) {
if (arr1[i] < arr2[j])
ans.push_back(arr1[i++]);
else if (arr2[j] < arr1[i])
ans.push_back(arr2[j++]);
else if (arr1[i] == arr2[j]) {
ans.push_back(arr1[i++]);
j++;
}
else {
ans.push_back(arr2[j++]);
i++;
}
}
while (i < n) {
ans.push_back(arr1[i++]);
}
while (j < m) {
ans.push_back(arr2[j++]);
}
return ans;
}
| 18.12963 | 59 | 0.389173 | vishwaphansal |
e162b12b1a463c1cd43247e532fb638c4181ae1e | 5,003 | cpp | C++ | shared/test/unit_test/scratch_space_controler/scratch_space_controler_tests.cpp | mattcarter2017/compute-runtime | 1f52802aac02c78c19d5493dd3a2402830bbe438 | [
"Intel",
"MIT"
] | null | null | null | shared/test/unit_test/scratch_space_controler/scratch_space_controler_tests.cpp | mattcarter2017/compute-runtime | 1f52802aac02c78c19d5493dd3a2402830bbe438 | [
"Intel",
"MIT"
] | null | null | null | shared/test/unit_test/scratch_space_controler/scratch_space_controler_tests.cpp | mattcarter2017/compute-runtime | 1f52802aac02c78c19d5493dd3a2402830bbe438 | [
"Intel",
"MIT"
] | null | null | null | /*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/scratch_space_controller_base.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
class MockScratchSpaceControllerBase : public ScratchSpaceControllerBase {
public:
MockScratchSpaceControllerBase(uint32_t rootDeviceIndex,
ExecutionEnvironment &environment,
InternalAllocationStorage &allocationStorage) : ScratchSpaceControllerBase(rootDeviceIndex, environment, allocationStorage) {}
void programHeaps(HeapContainer &heapContainer,
uint32_t offset,
uint32_t requiredPerThreadScratchSize,
uint32_t requiredPerThreadPrivateScratchSize,
uint32_t currentTaskCount,
OsContext &osContext,
bool &stateBaseAddressDirty,
bool &vfeStateDirty) override {
ScratchSpaceControllerBase::programHeaps(heapContainer, offset, requiredPerThreadScratchSize, requiredPerThreadPrivateScratchSize, currentTaskCount, osContext, stateBaseAddressDirty, vfeStateDirty);
programHeapsCalled = true;
}
void programBindlessSurfaceStateForScratch(BindlessHeapsHelper *heapsHelper,
uint32_t requiredPerThreadScratchSize,
uint32_t requiredPerThreadPrivateScratchSize,
uint32_t currentTaskCount,
OsContext &osContext,
bool &stateBaseAddressDirty,
bool &vfeStateDirty,
NEO::CommandStreamReceiver *csr) override {
ScratchSpaceControllerBase::programBindlessSurfaceStateForScratch(heapsHelper, requiredPerThreadScratchSize, requiredPerThreadPrivateScratchSize, currentTaskCount, osContext, stateBaseAddressDirty, vfeStateDirty, csr);
programBindlessSurfaceStateForScratchCalled = true;
}
ResidencyContainer residencyContainer;
bool programHeapsCalled = false;
bool programBindlessSurfaceStateForScratchCalled = false;
};
using ScratchComtrolerTests = Test<DeviceFixture>;
HWTEST_F(ScratchComtrolerTests, givenCommandQueueWhenProgramHeapsCalledThenThenProgramHeapsCalled) {
MockCsrHw2<FamilyType> csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield());
csr.initializeTagAllocation();
csr.setupContext(*pDevice->getDefaultEngine().osContext);
ExecutionEnvironment *execEnv = static_cast<ExecutionEnvironment *>(pDevice->getExecutionEnvironment());
std::unique_ptr<ScratchSpaceController> scratchController = std::make_unique<MockScratchSpaceControllerBase>(pDevice->getRootDeviceIndex(),
*execEnv,
*csr.getInternalAllocationStorage());
bool gsbaStateDirty = false;
bool frontEndStateDirty = false;
HeapContainer heapContainer;
scratchController->programHeaps(heapContainer, 0, 0, 0, 0, *pDevice->getDefaultEngine().osContext, gsbaStateDirty, frontEndStateDirty);
EXPECT_TRUE(static_cast<MockScratchSpaceControllerBase *>(scratchController.get())->programHeapsCalled);
}
HWTEST_F(ScratchComtrolerTests, givenCommandQueueWhenProgramHeapBindlessCalledThenThenProgramBindlessSurfaceStateForScratchCalled) {
MockCsrHw2<FamilyType> csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield());
csr.initializeTagAllocation();
csr.setupContext(*pDevice->getDefaultEngine().osContext);
ExecutionEnvironment *execEnv = static_cast<ExecutionEnvironment *>(pDevice->getExecutionEnvironment());
std::unique_ptr<MockScratchSpaceControllerBase> scratchController = std::make_unique<MockScratchSpaceControllerBase>(pDevice->getRootDeviceIndex(),
*execEnv,
*csr.getInternalAllocationStorage());
bool gsbaStateDirty = false;
bool frontEndStateDirty = false;
HeapContainer heapContainer;
scratchController->programBindlessSurfaceStateForScratch(nullptr, 0, 0, 0, *pDevice->getDefaultEngine().osContext, gsbaStateDirty, frontEndStateDirty, &csr);
EXPECT_TRUE(static_cast<MockScratchSpaceControllerBase *>(scratchController.get())->programBindlessSurfaceStateForScratchCalled);
} | 59.559524 | 226 | 0.653808 | mattcarter2017 |
e1637a0dae374ae4d43b92dc45d8bc5022ec9ebf | 485 | hpp | C++ | library/ATF/tagAFX_OLDTOOLINFO.hpp | lemkova/Yorozuya | f445d800078d9aba5de28f122cedfa03f26a38e4 | [
"MIT"
] | 29 | 2017-07-01T23:08:31.000Z | 2022-02-19T10:22:45.000Z | library/ATF/tagAFX_OLDTOOLINFO.hpp | kotopes/Yorozuya | 605c97d3a627a8f6545cc09f2a1b0a8afdedd33a | [
"MIT"
] | 90 | 2017-10-18T21:24:51.000Z | 2019-06-06T02:30:33.000Z | library/ATF/tagAFX_OLDTOOLINFO.hpp | kotopes/Yorozuya | 605c97d3a627a8f6545cc09f2a1b0a8afdedd33a | [
"MIT"
] | 44 | 2017-12-19T08:02:59.000Z | 2022-02-24T23:15:01.000Z | // This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
#include <HINSTANCE__.hpp>
#include <HWND__.hpp>
#include <tagRECT.hpp>
START_ATF_NAMESPACE
struct tagAFX_OLDTOOLINFO
{
unsigned int cbSize;
unsigned int uFlags;
HWND__ *hwnd;
unsigned int uId;
tagRECT rect;
HINSTANCE__ *hinst;
char *lpszText;
};
END_ATF_NAMESPACE
| 22.045455 | 108 | 0.672165 | lemkova |
e164219c9a2357c2439d1c423e81ec61a8a06154 | 1,233 | cc | C++ | src/sys/sysmgr/integration_tests/test_sysmgr_service.cc | zarelaky/fuchsia | 858cc1914de722b13afc2aaaee8a6bd491cd8d9a | [
"BSD-3-Clause"
] | null | null | null | src/sys/sysmgr/integration_tests/test_sysmgr_service.cc | zarelaky/fuchsia | 858cc1914de722b13afc2aaaee8a6bd491cd8d9a | [
"BSD-3-Clause"
] | null | null | null | src/sys/sysmgr/integration_tests/test_sysmgr_service.cc | zarelaky/fuchsia | 858cc1914de722b13afc2aaaee8a6bd491cd8d9a | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/fidl/cpp/binding_set.h>
#include <lib/sys/cpp/component_context.h>
#include <lib/zx/channel.h>
#include <test/sysmgr/cpp/fidl.h>
#include "src/lib/syslog/cpp/logger.h"
namespace sysmgr {
namespace test {
namespace {
class Service : public ::test::sysmgr::Interface {
public:
Service() : context_(sys::ComponentContext::Create()) {
context_->outgoing()->AddPublicService(bindings_.GetHandler(this));
}
~Service() = default;
void Ping(PingCallback callback) override {
FX_LOGS(INFO) << "Received ping.";
callback("test_sysmgr_service_startup");
}
private:
std::unique_ptr<sys::ComponentContext> context_;
fidl::BindingSet<::test::sysmgr::Interface> bindings_;
};
} // namespace
} // namespace test
} // namespace sysmgr
int main(int argc, const char** argv) {
syslog::InitLogger();
async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
sysmgr::test::Service service;
FX_LOGS(INFO) << "Entering loop.";
loop.Run();
return 0;
}
| 24.66 | 73 | 0.712084 | zarelaky |
e16464d9374192c9326ca9e0d9900ada4fa1afc6 | 7,585 | cpp | C++ | src/rviz/view_manager.cpp | yinzixuan126/rviz | c228cf5e03ef44c7581f449a34845722fe10f9a3 | [
"MIT"
] | 9 | 2017-12-17T07:43:15.000Z | 2021-10-10T15:03:39.000Z | src/rviz/view_manager.cpp | yinzixuan126/rviz | c228cf5e03ef44c7581f449a34845722fe10f9a3 | [
"MIT"
] | null | null | null | src/rviz/view_manager.cpp | yinzixuan126/rviz | c228cf5e03ef44c7581f449a34845722fe10f9a3 | [
"MIT"
] | 6 | 2016-01-27T03:40:58.000Z | 2021-06-15T08:12:14.000Z | /*
* Copyright (c) 2012, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <sstream>
#include "rviz/display_context.h"
#include "rviz/failed_view_controller.h"
#include "rviz/properties/enum_property.h"
#include "rviz/properties/property_tree_model.h"
#include "rviz/render_panel.h"
#include "rviz/view_controller.h"
#include "rviz/view_manager.h"
namespace rviz
{
ViewManager::ViewManager( DisplayContext* context )
: context_( context )
, root_property_( new ViewControllerContainer )
, property_model_( new PropertyTreeModel( root_property_ ))
, factory_( new PluginlibFactory<ViewController>( "rviz", "rviz::ViewController" ))
, current_( NULL )
, render_panel_( NULL )
{
property_model_->setDragDropClass( "view-controller" );
connect( property_model_, SIGNAL( configChanged() ), this, SIGNAL( configChanged() ));
}
ViewManager::~ViewManager()
{
delete property_model_;
delete factory_;
}
void ViewManager::initialize()
{
setCurrent( create( "rviz/Orbit" ), false );
}
void ViewManager::update( float wall_dt, float ros_dt )
{
if( getCurrent() )
{
getCurrent()->update( wall_dt, ros_dt );
}
}
ViewController* ViewManager::create( const QString& class_id )
{
QString error;
ViewController* view = factory_->make( class_id, &error );
if( !view )
{
view = new FailedViewController( class_id, error );
}
view->initialize( context_ );
return view;
}
ViewController* ViewManager::getCurrent() const
{
return current_;
}
void ViewManager::setCurrentFrom( ViewController* source_view )
{
if( source_view == NULL )
{
return;
}
ViewController* previous = getCurrent();
if( source_view != previous )
{
ViewController* new_current = copy( source_view );
setCurrent( new_current, false );
Q_EMIT configChanged();
}
}
void ViewManager::onCurrentDestroyed( QObject* obj )
{
if( obj == current_ )
{
current_ = NULL;
}
}
void ViewManager::setCurrent( ViewController* new_current, bool mimic_view )
{
ViewController* previous = getCurrent();
if( previous )
{
if( mimic_view )
{
new_current->mimic( previous );
}
else
{
new_current->transitionFrom( previous );
}
disconnect( previous, SIGNAL( destroyed( QObject* )), this, SLOT( onCurrentDestroyed( QObject* )));
}
new_current->setName( "Current View" );
connect( new_current, SIGNAL( destroyed( QObject* )), this, SLOT( onCurrentDestroyed( QObject* )));
current_ = new_current;
root_property_->addChildToFront( new_current );
delete previous;
if( render_panel_ )
{
// This setViewController() can indirectly call
// ViewManager::update(), so make sure getCurrent() will return the
// new one by this point.
render_panel_->setViewController( new_current );
}
Q_EMIT currentChanged();
}
void ViewManager::setCurrentViewControllerType( const QString& new_class_id )
{
setCurrent( create( new_class_id ), true );
}
void ViewManager::copyCurrentToList()
{
ViewController* current = getCurrent();
if( current )
{
ViewController* new_copy = copy( current );
new_copy->setName( factory_->getClassName( new_copy->getClassId() ));
root_property_->addChild( new_copy );
}
}
ViewController* ViewManager::getViewAt( int index ) const
{
if( index < 0 )
{
index = 0;
}
return qobject_cast<ViewController*>( root_property_->childAt( index + 1 ));
}
int ViewManager::getNumViews() const
{
int count = root_property_->numChildren();
if( count <= 0 )
{
return 0;
}
else
{
return count-1;
}
}
void ViewManager::add( ViewController* view, int index )
{
if( index < 0 )
{
index = root_property_->numChildren();
}
else
{
index++;
}
property_model_->getRoot()->addChild( view, index );
}
ViewController* ViewManager::take( ViewController* view )
{
for( int i = 0; i < getNumViews(); i++ )
{
if( getViewAt( i ) == view )
{
return qobject_cast<ViewController*>( root_property_->takeChildAt( i + 1 ));
}
}
return NULL;
}
ViewController* ViewManager::takeAt( int index )
{
if( index < 0 )
{
return NULL;
}
return qobject_cast<ViewController*>( root_property_->takeChildAt( index + 1 ));
}
void ViewManager::load( const Config& config )
{
Config current_config = config.mapGetChild( "Current" );
QString class_id;
if( current_config.mapGetString( "Class", &class_id ))
{
ViewController* new_current = create( class_id );
new_current->load( current_config );
setCurrent( new_current, false );
}
Config saved_views_config = config.mapGetChild( "Saved" );
root_property_->removeChildren( 1 );
int num_saved = saved_views_config.listLength();
for( int i = 0; i < num_saved; i++ )
{
Config view_config = saved_views_config.listChildAt( i );
if( view_config.mapGetString( "Class", &class_id ))
{
ViewController* view = create( class_id );
view->load( view_config );
add( view );
}
}
}
void ViewManager::save( Config config ) const
{
getCurrent()->save( config.mapMakeChild( "Current" ));
Config saved_views_config = config.mapMakeChild( "Saved" );
for( int i = 0; i < getNumViews(); i++ )
{
getViewAt( i )->save( saved_views_config.listAppendNew() );
}
}
ViewController* ViewManager::copy( ViewController* source )
{
Config config;
source->save( config );
ViewController* copy_of_source = create( source->getClassId() );
copy_of_source->load( config );
return copy_of_source;
}
void ViewManager::setRenderPanel( RenderPanel* render_panel )
{
render_panel_ = render_panel;
}
Qt::ItemFlags ViewControllerContainer::getViewFlags( int column ) const
{
return Property::getViewFlags( column ) | Qt::ItemIsDropEnabled;
}
void ViewControllerContainer::addChild( Property* child, int index )
{
if( index == 0 )
{
index = 1;
}
Property::addChild( child, index );
}
void ViewControllerContainer::addChildToFront( Property* child )
{
Property::addChild( child, 0 );
}
} // end namespace rviz
| 25.538721 | 103 | 0.69677 | yinzixuan126 |
e1692a95c41192e3ea3563971c7bbe9f95faae55 | 14,141 | cpp | C++ | src/SignerInfo.cpp | selfienetworks/COSE-C | 97d1805e71b7a6770093c5e6790d46611680d563 | [
"BSD-3-Clause"
] | 25 | 2016-07-15T12:11:42.000Z | 2021-11-19T20:52:46.000Z | src/SignerInfo.cpp | selfienetworks/COSE-C | 97d1805e71b7a6770093c5e6790d46611680d563 | [
"BSD-3-Clause"
] | 96 | 2015-09-04T05:12:01.000Z | 2021-12-30T08:39:56.000Z | src/SignerInfo.cpp | selfienetworks/COSE-C | 97d1805e71b7a6770093c5e6790d46611680d563 | [
"BSD-3-Clause"
] | 21 | 2015-05-27T03:27:21.000Z | 2021-08-10T15:10:10.000Z | /** \file SignerInfo.c
* Contains implementation of the functions related to HCOSE_SIGNER handle
* objects.
*/
#include <stdlib.h>
#ifndef __MBED__
#include <memory.h>
#endif
#include "cose/cose.h"
#include "cose_int.h"
#include "cose/cose_configure.h"
#include "cose_crypto.h"
#if INCLUDE_SIGN || INCLUDE_COUNTERSIGNATURE
#if INCLUDE_SIGN
COSE *SignerRoot = nullptr;
bool IsValidSignerHandle(HCOSE_SIGNER h)
{
COSE_SignerInfo *p = (COSE_SignerInfo *)h;
return _COSE_IsInList(SignerRoot, (COSE *)p);
}
#endif
bool _COSE_SignerInfo_Release(COSE_SignerInfo *pSigner)
{
// Check ref counting
if (pSigner->m_message.m_refCount > 1) {
pSigner->m_message.m_refCount--;
return true;
}
_COSE_Release(&pSigner->m_message);
if (pSigner->m_pkey != nullptr) {
COSE_KEY_Free((HCOSE_KEY)pSigner->m_pkey);
}
return true;
}
#if INCLUDE_SIGN
bool COSE_Signer_Free(HCOSE_SIGNER hSigner)
{
COSE_SignerInfo *pSigner = (COSE_SignerInfo *)hSigner;
bool fRet = false;
if (!IsValidSignerHandle(hSigner)) {
goto errorReturn;
}
if (pSigner->m_message.m_refCount > 1) {
pSigner->m_message.m_refCount--;
return true;
}
_COSE_SignerInfo_Release(pSigner);
_COSE_RemoveFromList(&SignerRoot, &pSigner->m_message);
COSE_FREE(pSigner, &pSigner->m_message.m_allocContext);
fRet = true;
errorReturn:
return fRet;
}
HCOSE_SIGNER COSE_Signer_Init(CBOR_CONTEXT_COMMA cose_errback *perror)
{
COSE_SignerInfo *pobj =
(COSE_SignerInfo *)COSE_CALLOC(1, sizeof(COSE_SignerInfo), context);
if (pobj == nullptr) {
if (perror != nullptr) {
perror->err = COSE_ERR_OUT_OF_MEMORY;
}
return nullptr;
}
if (!_COSE_SignerInfo_Init(COSE_INIT_FLAGS_NO_CBOR_TAG, pobj,
COSE_recipient_object, CBOR_CONTEXT_PARAM_COMMA perror)) {
_COSE_SignerInfo_Release(pobj);
COSE_FREE(pobj, context);
return nullptr;
}
_COSE_InsertInList(&SignerRoot, &pobj->m_message);
return (HCOSE_SIGNER)pobj;
}
#endif
bool _COSE_SignerInfo_Init(COSE_INIT_FLAGS flags,
COSE_SignerInfo *pobj,
int msgType,
CBOR_CONTEXT_COMMA cose_errback *errp)
{
return _COSE_Init(
flags, &pobj->m_message, msgType, CBOR_CONTEXT_PARAM_COMMA errp);
}
COSE_SignerInfo *_COSE_SignerInfo_Init_From_Object(cn_cbor *cbor,
COSE_SignerInfo *pIn,
CBOR_CONTEXT_COMMA cose_errback *perr)
{
COSE_SignerInfo *pSigner = pIn;
if (pSigner == nullptr) {
pSigner =
(COSE_SignerInfo *)COSE_CALLOC(1, sizeof(COSE_SignerInfo), context);
CHECK_CONDITION(pSigner != nullptr, COSE_ERR_OUT_OF_MEMORY);
}
CHECK_CONDITION(cbor->type == CN_CBOR_ARRAY, COSE_ERR_INVALID_PARAMETER);
if (!_COSE_Init_From_Object(
&pSigner->m_message, cbor, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
#if INCLUDE_SIGN
if (pIn == nullptr) {
_COSE_InsertInList(&SignerRoot, &pSigner->m_message);
}
#endif
return pSigner;
errorReturn:
if (pSigner != nullptr && pIn == nullptr) {
_COSE_SignerInfo_Release(pSigner);
COSE_FREE(pSigner, context);
}
return nullptr;
}
static bool BuildToBeSigned(byte **ppbToSign,
size_t *pcbToSign,
const cn_cbor *pcborBody,
const cn_cbor *pcborProtected,
const cn_cbor *pcborProtectedSign,
const byte *pbExternal,
size_t cbExternal,
const char *const contextString,
CBOR_CONTEXT_COMMA cose_errback *perr)
{
cn_cbor *pArray = nullptr;
cn_cbor_errback cbor_error;
size_t cbToSign;
byte *pbToSign = nullptr;
bool f = false;
cn_cbor *cn = nullptr;
if (false) {
errorReturn:
if (cn != nullptr) {
CN_CBOR_FREE(cn, context);
}
if (pArray != nullptr) {
CN_CBOR_FREE(pArray, context);
}
if (pbToSign != nullptr) {
COSE_FREE(pbToSign, context);
}
return f;
}
pArray = cn_cbor_array_create(CBOR_CONTEXT_PARAM_COMMA & cbor_error);
CHECK_CONDITION_CBOR(pArray != nullptr, cbor_error);
cn = cn_cbor_string_create(
contextString, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
CHECK_CONDITION_CBOR(cn != nullptr, cbor_error);
CHECK_CONDITION_CBOR(
cn_cbor_array_append(pArray, cn, &cbor_error), cbor_error);
cn = nullptr;
if (pcborProtected->length == 1 && (pcborProtected->v.bytes[0] == 0xa0)) {
cn = cn_cbor_data_create(
nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
}
else {
cn = cn_cbor_data_create(pcborProtected->v.bytes,
(int)pcborProtected->length, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
}
CHECK_CONDITION_CBOR(cn != nullptr, cbor_error);
CHECK_CONDITION_CBOR(
cn_cbor_array_append(pArray, cn, &cbor_error), cbor_error);
cn = nullptr;
if ((pcborProtectedSign->length == 1) &&
(pcborProtectedSign->v.bytes[0] == 0xa0)) {
cn = cn_cbor_data_create(
nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
}
else {
cn = cn_cbor_data_create(pcborProtectedSign->v.bytes,
(int)pcborProtectedSign->length,
CBOR_CONTEXT_PARAM_COMMA & cbor_error);
}
CHECK_CONDITION_CBOR(cn != nullptr, cbor_error);
CHECK_CONDITION_CBOR(
cn_cbor_array_append(pArray, cn, &cbor_error), cbor_error);
cn = nullptr;
cn = cn_cbor_data_create(
pbExternal, (int)cbExternal, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
CHECK_CONDITION_CBOR(cn != nullptr, cbor_error);
CHECK_CONDITION_CBOR(
cn_cbor_array_append(pArray, cn, &cbor_error), cbor_error);
cn = nullptr;
cn = cn_cbor_data_create(pcborBody->v.bytes, (int)pcborBody->length,
CBOR_CONTEXT_PARAM_COMMA & cbor_error);
CHECK_CONDITION_CBOR(cn != nullptr, cbor_error);
CHECK_CONDITION_CBOR(
cn_cbor_array_append(pArray, cn, &cbor_error), cbor_error);
cn = nullptr;
cbToSign = cn_cbor_encode_size(pArray);
CHECK_CONDITION(cbToSign > 0, COSE_ERR_CBOR);
pbToSign = (byte *)COSE_CALLOC(cbToSign, 1, context);
CHECK_CONDITION(pbToSign != nullptr, COSE_ERR_OUT_OF_MEMORY);
const ssize_t writtenBits =
cn_cbor_encoder_write(pbToSign, 0, cbToSign, pArray);
CHECK_CONDITION(writtenBits >= 0, COSE_ERR_CBOR);
CHECK_CONDITION((size_t)writtenBits == cbToSign, COSE_ERR_CBOR);
*ppbToSign = pbToSign;
*pcbToSign = cbToSign;
pbToSign = nullptr;
f = true;
goto errorReturn;
}
bool _COSE_Signer_sign(COSE_SignerInfo *pSigner,
const cn_cbor *pcborBody,
const cn_cbor *pcborProtected,
const char *const contextString,
cose_errback *perr)
{
#ifdef USE_CBOR_CONTEXT
cn_cbor_context *context = &pSigner->m_message.m_allocContext;
#endif
cn_cbor *pcborProtectedSign = nullptr;
cn_cbor *pArray = nullptr;
cn_cbor *cnAlgorithm = nullptr;
size_t cbToSign;
byte *pbToSign = nullptr;
int alg;
bool fRet = false;
pArray = cn_cbor_array_create(CBOR_CONTEXT_PARAM_COMMA nullptr);
CHECK_CONDITION(pArray != nullptr, COSE_ERR_OUT_OF_MEMORY);
cnAlgorithm = _COSE_map_get_int(
&pSigner->m_message, COSE_Header_Algorithm, COSE_BOTH, perr);
if (cnAlgorithm == nullptr) {
goto errorReturn;
}
if (cnAlgorithm->type == CN_CBOR_TEXT) {
FAIL_CONDITION(COSE_ERR_UNKNOWN_ALGORITHM);
}
else {
CHECK_CONDITION((cnAlgorithm->type == CN_CBOR_UINT ||
cnAlgorithm->type == CN_CBOR_INT),
COSE_ERR_INVALID_PARAMETER);
alg = (int)cnAlgorithm->v.sint;
}
pcborProtectedSign = _COSE_encode_protected(&pSigner->m_message, perr);
if (pcborProtectedSign == nullptr) {
goto errorReturn;
}
if (!BuildToBeSigned(&pbToSign, &cbToSign, pcborBody, pcborProtected,
pcborProtectedSign, pSigner->m_message.m_pbExternal,
pSigner->m_message.m_cbExternal, contextString,
CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
switch (alg) {
#ifdef USE_ECDSA_SHA_256
case COSE_Algorithm_ECDSA_SHA_256:
if (!ECDSA_Sign(&pSigner->m_message, INDEX_SIGNATURE,
pSigner->m_pkey, 256, pbToSign, cbToSign, perr)) {
goto errorReturn;
}
break;
#endif
#ifdef USE_ECDSA_SHA_384
case COSE_Algorithm_ECDSA_SHA_384:
if (!ECDSA_Sign(&pSigner->m_message, INDEX_SIGNATURE,
pSigner->m_pkey, 384, pbToSign, cbToSign, perr)) {
goto errorReturn;
}
break;
#endif
#ifdef USE_ECDSA_SHA_512
case COSE_Algorithm_ECDSA_SHA_512:
if (!ECDSA_Sign(&pSigner->m_message, INDEX_SIGNATURE,
pSigner->m_pkey, 512, pbToSign, cbToSign, perr)) {
goto errorReturn;
}
break;
#endif
#ifdef USE_EDDSA
case COSE_Algorithm_EdDSA:
if (!EdDSA_Sign(&pSigner->m_message, INDEX_SIGNATURE,
pSigner->m_pkey, pbToSign, cbToSign, perr)) {
goto errorReturn;
}
break;
#endif
default:
FAIL_CONDITION(COSE_ERR_UNKNOWN_ALGORITHM);
}
#if INCLUDE_COUNTERSIGNATURE
if (pSigner->m_message.m_counterSigners != nullptr) {
if (!_COSE_CounterSign_Sign(
&pSigner->m_message, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
}
#endif
#if INCLUDE_COUNTERSIGNATURE1
if (pSigner->m_message.m_counterSign1 != NULL) {
if (!_COSE_CounterSign1_Sign(
&pSigner->m_message, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
}
#endif
fRet = true;
errorReturn:
if (pArray != nullptr) {
COSE_FREE(pArray, context);
}
if (pbToSign != nullptr) {
COSE_FREE(pbToSign, context);
}
return fRet;
}
#if INCLUDE_SIGN
bool COSE_Signer_SetKey2(HCOSE_SIGNER h, HCOSE_KEY pKey, cose_errback *perr)
{
COSE_SignerInfo *p;
if (false) {
errorReturn:
return false;
}
CHECK_CONDITION(IsValidSignerHandle(h), COSE_ERR_INVALID_HANDLE);
CHECK_CONDITION(IsValidKeyHandle(pKey), COSE_ERR_INVALID_HANDLE);
p = (COSE_SignerInfo *)h;
if (p->m_pkey != nullptr) {
COSE_KEY_Free((HCOSE_KEY)p->m_pkey);
}
COSE_KEY *pcose = (COSE_KEY *)pKey;
p->m_pkey = pcose;
if (pcose != nullptr) {
pcose->m_refCount += 1;
}
return true;
}
bool COSE_Signer_SetKey(HCOSE_SIGNER h, const cn_cbor *pKey, cose_errback *perr)
{
HCOSE_KEY cose = nullptr;
bool fRet = false;
if (false) {
errorReturn:
if (cose != nullptr) {
COSE_KEY_Free(cose);
}
return fRet;
}
CHECK_CONDITION(pKey != nullptr, COSE_ERR_INVALID_PARAMETER);
CHECK_CONDITION(IsValidSignerHandle(h), COSE_ERR_INVALID_HANDLE);
#ifdef USE_CBOR_CONTEXT
COSE_SignerInfo *p = (COSE_SignerInfo *)h;
cn_cbor_context *context = &p->m_message.m_allocContext;
#endif
cose = COSE_KEY_FromCbor((cn_cbor *)pKey, CBOR_CONTEXT_PARAM_COMMA perr);
CHECK_CONDITION(cose != nullptr, COSE_ERR_OUT_OF_MEMORY);
fRet = COSE_Signer_SetKey2(h, cose, perr);
return fRet;
}
/*!
* @brief Set the application external data for authentication
*
* Signer data objects support the authentication of external application
* supplied data. This function is provided to supply that data to the library.
*
* The external data is not copied, nor will be it freed when the handle is
* released.
*
* @param hcose Handle for the COSE MAC data object
* @param pbEternalData point to the external data
* @param cbExternalData size of the external data
* @param perr location to return errors
* @return result of the operation.
*/
bool COSE_Signer_SetExternal(HCOSE_SIGNER hcose,
const byte *pbExternalData,
size_t cbExternalData,
cose_errback *perr)
{
if (!IsValidSignerHandle(hcose)) {
if (perr != nullptr) {
perr->err = COSE_ERR_INVALID_HANDLE;
}
return false;
}
return _COSE_SetExternal(&((COSE_SignerInfo *)hcose)->m_message,
pbExternalData, cbExternalData, perr);
}
#endif
bool _COSE_Signer_validate(COSE_SignerInfo *pSigner,
const cn_cbor *pcborBody,
const cn_cbor *pcborProtected,
const char *const contextString,
cose_errback *perr)
{
byte *pbToBeSigned = nullptr;
int alg = 0;
#ifdef USE_CBOR_CONTEXT
cn_cbor_context *context = &pSigner->m_message.m_allocContext;
#endif
size_t cbToBeSigned;
bool fRet = false;
const cn_cbor *cn = _COSE_map_get_int(
&pSigner->m_message, COSE_Header_Algorithm, COSE_BOTH, perr);
if (cn == nullptr) {
errorReturn:
if (pbToBeSigned != nullptr) {
COSE_FREE(pbToBeSigned, context);
}
return fRet;
}
if (cn->type == CN_CBOR_TEXT) {
FAIL_CONDITION(COSE_ERR_UNKNOWN_ALGORITHM);
}
else {
CHECK_CONDITION((cn->type == CN_CBOR_UINT || cn->type == CN_CBOR_INT),
COSE_ERR_INVALID_PARAMETER);
alg = (int)cn->v.sint;
}
// Build protected headers
cn_cbor *cnProtected =
_COSE_arrayget_int(&pSigner->m_message, INDEX_PROTECTED);
CHECK_CONDITION(
(cnProtected != nullptr) && (cnProtected->type == CN_CBOR_BYTES),
COSE_ERR_INVALID_PARAMETER);
// Build authenticated data
if (!BuildToBeSigned(&pbToBeSigned, &cbToBeSigned, pcborBody,
pcborProtected, cnProtected, pSigner->m_message.m_pbExternal,
pSigner->m_message.m_cbExternal, contextString,
CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
cn_cbor *cnSignature =
_COSE_arrayget_int(&pSigner->m_message, INDEX_SIGNATURE);
CHECK_CONDITION(
(cnSignature != nullptr) && (cnSignature->type == CN_CBOR_BYTES),
COSE_ERR_INVALID_PARAMETER);
switch (alg) {
#ifdef USE_ECDSA_SHA_256
case COSE_Algorithm_ECDSA_SHA_256:
if (!ECDSA_Verify(&pSigner->m_message, INDEX_SIGNATURE,
pSigner->m_pkey, 256, pbToBeSigned, cbToBeSigned, perr)) {
goto errorReturn;
}
break;
#endif
#ifdef USE_ECDSA_SHA_384
case COSE_Algorithm_ECDSA_SHA_384:
if (!ECDSA_Verify(&pSigner->m_message, INDEX_SIGNATURE,
pSigner->m_pkey, 384, pbToBeSigned, cbToBeSigned, perr)) {
goto errorReturn;
}
break;
#endif
#ifdef USE_ECDSA_SHA_512
case COSE_Algorithm_ECDSA_SHA_512:
if (!ECDSA_Verify(&pSigner->m_message, INDEX_SIGNATURE,
pSigner->m_pkey, 512, pbToBeSigned, cbToBeSigned, perr)) {
goto errorReturn;
}
break;
#endif
#ifdef USE_EDDSA
case COSE_Algorithm_EdDSA:
if (!EdDSA_Verify(&pSigner->m_message, INDEX_SIGNATURE,
pSigner->m_pkey, pbToBeSigned, cbToBeSigned, perr)) {
goto errorReturn;
}
break;
#endif
default:
FAIL_CONDITION(COSE_ERR_UNKNOWN_ALGORITHM);
break;
}
fRet = true;
goto errorReturn;
}
#if INCLUDE_SIGN
cn_cbor *COSE_Signer_map_get_int(HCOSE_SIGNER h,
int key,
int flags,
cose_errback *perr)
{
if (!IsValidSignerHandle(h)) {
if (perr != nullptr) {
perr->err = COSE_ERR_INVALID_HANDLE;
}
return nullptr;
}
return _COSE_map_get_int((COSE *)h, key, flags, perr);
}
bool COSE_Signer_map_put_int(HCOSE_SIGNER h,
int key,
cn_cbor *value,
int flags,
cose_errback *perr)
{
CHECK_CONDITION(IsValidSignerHandle(h), COSE_ERR_INVALID_HANDLE);
CHECK_CONDITION(value != nullptr, COSE_ERR_INVALID_PARAMETER);
return _COSE_map_put(
&((COSE_SignerInfo *)h)->m_message, key, value, flags, perr);
errorReturn:
return false;
}
#endif
#endif
| 24.423143 | 80 | 0.742451 | selfienetworks |
e17116102c287cfb25547c0020606ed0de805ae8 | 63,287 | cc | C++ | components/nist_sblas/nist_spblas.cc | Technica-Corporation/ProtoNN-ESP32 | 8822ad37677ca3ae8b0c519d19d0f4882e3c32ac | [
"Apache-2.0"
] | 3 | 2019-07-10T09:07:08.000Z | 2019-11-19T19:26:24.000Z | components/nist_sblas/nist_spblas.cc | Technica-Corporation/ProtoNN-ESP32 | 8822ad37677ca3ae8b0c519d19d0f4882e3c32ac | [
"Apache-2.0"
] | null | null | null | components/nist_sblas/nist_spblas.cc | Technica-Corporation/ProtoNN-ESP32 | 8822ad37677ca3ae8b0c519d19d0f4882e3c32ac | [
"Apache-2.0"
] | null | null | null | /*
*
* Sparse BLAS (Basic Linear Algebra Subprograms) Library
*
* A C++ implementation of the routines specified by the ANSI C
* interface specification of the Sparse BLAS in the BLAS Technical
* Forum Standard[1]. For details, see [2].
*
* Mathematical and Computational Sciences Division
* National Institute of Technology,
* Gaithersburg, MD USA
*
*
* [1] BLAS Technical Forum: www.netlib.org/blas/blast-forum/
* [2] I. S. Duff, M. A. Heroux, R. Pozo, "An Overview of the Sparse Basic
* Linear Algebra Subprograms: The new standard of the BLAS Techincal
* Forum," Vol. 28, No. 2, pp. 239-267,ACM Transactions on Mathematical
* Software (TOMS), 2002.
*
*
* DISCLAIMER:
*
* This software was developed at the National Institute of Standards and
* Technology (NIST) by employees of the Federal Government in the course
* of their official duties. Pursuant to title 17 Section 105 of the
* United States Code, this software is not subject to copyright protection
* and is in the public domain. NIST assumes no responsibility whatsoever for
* its use by other parties, and makes no guarantees, expressed or implied,
* about its quality, reliability, or any other characteristic.
*
*
*/
/* numeric is for accumulate() below */
#include <iostream>
#include <complex>
#include <numeric>
#include <vector>
#include <utility>
/* pair defined here */
#include "blas_sparse.h"
#ifdef SPBLAS_ERROR_FATAL
#include <cassert>
#define ASSERT_RETURN(x, ret_val) assert(x)
#define ERROR_RETURN(ret_val) assert(0)
#else
#define ASSERT_RETURN(x, ret_val) {if (!(x)) return ret_val;}
#define ERROR_RETURN(ret_val) return ret_val
#endif
using namespace std;
namespace NIST_SPBLAS
{
/**
Generic sparse matrix (base) class: defines only the structure
(size, symmetry, etc.) and maintains state during construction,
but does not specify the actual nonzero values, or their type.
*/
class Sp_mat
{
private:
int num_rows_;
int num_cols_;
int num_nonzeros_;
/* ... */
int void_;
int nnew_; /* avoid using "new" since it is a C++ keyword */
int open_;
int valid_;
int unit_diag_ ;
int complex_;
int real_;
int single_precision_;
int double_precision_;
int upper_triangular_;
int lower_triangular_;
int upper_symmetric_;
int lower_symmetric_;
int upper_hermitian_;
int lower_hermitian_;
int general_;
int one_base_;
/* optional block information */
int Mb_; /* matrix is partitioned into Mb x Nb blocks */
int Nb_; /* otherwise 0, if regular (non-blocked) matrix */
int k_; /* for constant blocks, each block is k x l */
int l_; /* otherwise 0, if variable blocks are used. */
int rowmajor_; /* 1,if block storage is rowm major. */
int colmajor_; /* 1,if block storage is column major. */
/* unused optimization paramters */
int opt_regular_;
int opt_irregular_;
int opt_block_;
int opt_unassembled_;
vector<int> K_; /* these are GLOBAL index of starting point of block */
vector<int> L_; /* i.e. block(i,j) starts at global location (K[i],L[i]) */
/* and of size (K[i+1]-K[i] x L[i+1]-L[i]) */
public:
Sp_mat(int M, int N) :
num_rows_(M), /* default construction */
num_cols_(N),
num_nonzeros_(0),
void_(0),
nnew_(1),
open_(0),
valid_(0),
unit_diag_(0),
complex_(0),
real_(0),
single_precision_(0),
double_precision_(0),
upper_triangular_(0),
lower_triangular_(0),
upper_symmetric_(0),
lower_symmetric_(0),
upper_hermitian_(0),
lower_hermitian_(0),
general_(0),
one_base_(0),
Mb_(0),
Nb_(0),
k_(0),
l_(0),
rowmajor_(0),
colmajor_(0),
opt_regular_(0),
opt_irregular_(1),
opt_block_(0),
opt_unassembled_(0),
K_(),
L_()
{}
int& num_rows() { return num_rows_; }
int& num_cols() { return num_cols_; }
int& num_nonzeros() { return num_nonzeros_;}
int num_rows() const { return num_rows_; }
int num_cols() const { return num_cols_; }
int num_nonzeros() const { return num_nonzeros_;}
int is_one_base() const { return (one_base_ ? 1 : 0); }
int is_zero_base() const { return (one_base_ ? 0 : 1); }
int is_void() const { return void_; }
int is_new() const { return nnew_; }
int is_open() const { return open_; }
int is_valid() const { return valid_; }
int is_unit_diag() const { return unit_diag_; }
int is_complex() const { return complex_;}
int is_real() const { return real_;}
int is_single_precision() const { return single_precision_;}
int is_double_precision() const { return double_precision_;}
int is_upper_triangular() const { return upper_triangular_;}
int is_lower_triangular() const { return lower_triangular_;}
int is_triangular() const { return upper_triangular_ ||
lower_triangular_; }
int is_lower_symmetric() const { return lower_symmetric_; }
int is_upper_symmetric() const { return upper_symmetric_; }
int is_symmetric() const { return upper_symmetric_ ||
lower_symmetric_; }
int is_lower_hermitian() const { return lower_hermitian_; }
int is_upper_hermitian() const { return upper_hermitian_; }
int is_hermitian() const { return lower_hermitian_ ||
upper_hermitian_; }
int is_general() const { return !( is_hermitian() || is_symmetric()) ; }
int is_lower_storage() const { return is_lower_triangular() ||
is_lower_symmetric() ||
is_lower_hermitian() ; }
int is_upper_storage() const { return is_upper_triangular() ||
is_upper_symmetric() ||
is_upper_hermitian() ; }
int is_opt_regular() const { return opt_regular_; }
int is_opt_irregular() const { return opt_irregular_; }
int is_opt_block() const { return opt_block_;}
int is_opt_unassembled() const { return opt_unassembled_;}
int K(int i) const { return (k_ ? i*k_ : K_[i] ); }
int L(int i) const { return (l_ ? i*l_ : L_[i] ); }
int is_rowmajor() const { return rowmajor_; }
int is_colmajor() const { return colmajor_; }
void set_one_base() { one_base_ = 1; }
void set_zero_base() { one_base_ = 0; }
void set_void() { void_ = 1; nnew_ = open_ = valid_ = 0;}
void set_new() { nnew_ = 1; void_ = open_ = valid_ = 0;}
void set_open() { open_ = 1; void_ = nnew_ = valid_ = 0;}
void set_valid() { valid_ = 1; void_ = nnew_ = open_ = 0; }
void set_unit_diag() { unit_diag_ = 1;}
void set_complex() {complex_ = 1; }
void set_real() { real_ = 1; }
void set_single_precision() { single_precision_ = 1; }
void set_double_precision() { double_precision_ = 1; }
void set_upper_triangular() { upper_triangular_ = 1; }
void set_lower_triangular() { lower_triangular_ = 1; }
void set_upper_symmetric() { upper_symmetric_ = 1; }
void set_lower_symmetric() { lower_symmetric_ = 1; }
void set_upper_hermitian() { upper_hermitian_ = 1; }
void set_lower_hermitian() { lower_hermitian_ = 1; }
void set_const_block_parameters(int Mb, int Nb, int k, int l)
{
Mb_ = Mb;
Nb_ = Nb;
k_ = k;
l_ = l;
}
void set_var_block_parameters(int Mb, int Nb, const int *k, const int *l)
{
Mb_ = Mb;
Nb_ = Nb;
k_ = 0;
l_ = 0;
K_.resize(Mb+1);
K_[0] = 0;
for (int i=0; i<Mb; i++)
K_[i+1] = k[i] + K_[i];
L_.resize(Nb+1);
L_[0] = 0;
for (int j=0; j<Mb; j++)
K_[j+1] = k[j] + K_[j];
}
virtual int end_construction()
{
if (is_open() || is_new())
{
set_valid();
return 0;
}
else
ERROR_RETURN(1);
}
virtual void print() const;
virtual void destroy() {};
virtual ~Sp_mat() {};
};
template <class T>
class TSp_mat : public Sp_mat
{
private:
vector< vector< pair<T, int> > > S;
vector<T> diag; /* optional diag if matrix is
triangular. Created
at end_construction() phase */
private:
inline T sp_dot_product( const vector< pair<T, int> > &r,
const T* x, int incx ) const
{
T sum(0);
if (incx == 1)
{
for ( typename vector< pair<T,int> >::const_iterator p = r.begin();
p < r.end(); p++)
{
//sum = sum + p->first * x[p->second];
sum += p->first * x[p->second];
}
}
else /* incx != 1 */
{
for ( typename vector< pair<T,int> >::const_iterator p = r.begin();
p < r.end(); p++)
{
//sum = sum + p->first * x[p->second * incx];
sum += p->first * x[p->second * incx];
}
}
return sum;
}
inline T sp_conj_dot_product( const vector< pair<T, int> > &r,
const T* x, int incx ) const
{
T sum(0);
if (incx == 1)
{
for ( typename vector< pair<T,int> >::const_iterator p = r.begin();
p < r.end(); p++)
{
sum += conj(p->first) * x[p->second];
}
}
else /* incx != 1 */
{
for ( typename vector< pair<T,int> >::const_iterator p = r.begin();
p < r.end(); p++)
{
//sum = sum + p->first * x[p->second * incx];
sum += conj(p->first) * x[p->second * incx];
}
}
return sum;
}
inline void sp_axpy( const T& alpha, const vector< pair<T,int> > &r,
T* y, int incy) const
{
if (incy == 1)
{
for (typename vector< pair<T,int> >::const_iterator p = r.begin();
p < r.end(); p++)
y[p->second] += alpha * p->first;
}
else /* incy != 1 */
{
for (typename vector< pair<T,int> >::const_iterator p = r.begin();
p < r.end(); p++)
y[incy * p->second] += alpha * p->first;
}
}
inline void sp_conj_axpy( const T& alpha, const vector< pair<T,int> > &r,
T* y, int incy) const
{
if (incy == 1)
{
for (typename vector< pair<T,int> >::const_iterator p = r.begin();
p < r.end(); p++)
y[p->second] += alpha * conj(p->first);
}
else /* incy != 1 */
{
for (typename vector< pair<T,int> >::const_iterator p = r.begin();
p < r.end(); p++)
y[incy * p->second] += alpha * conj(p->first);
}
}
void mult_diag(const T& alpha, const T* x, int incx, T* y, int incy)
const
{
const T* X = x;
T* Y = y;
typename vector<T>::const_iterator d= diag.begin();
for ( ; d < diag.end(); X+=incx, d++, Y+=incy)
{
*Y += alpha * *d * *X;
}
}
void mult_conj_diag(const T& alpha, const T* x, int incx, T* y, int incy)
const
{
const T* X = x;
T* Y = y;
typename vector<T>::const_iterator d= diag.begin();
for ( ; d < diag.end(); X+=incx, d++, Y+=incy)
{
*Y += alpha * conj(*d) * *X;
}
}
void nondiag_mult_vec(const T& alpha, const T* x, int incx,
T* y, int incy) const
{
int M = num_rows();
if (incy == 1)
{
for (int i=0; i<M; i++)
y[i] += alpha * sp_dot_product(S[i], x, incx);
}
else
{
for (int i=0; i<M; i++)
y[i * incy] += alpha * sp_dot_product(S[i], x, incx);
}
}
void nondiag_mult_vec_conj(const T& alpha, const T* x, int incx,
T* y, int incy) const
{
int M = num_rows();
if (incy == 1)
{
for (int i=0; i<M; i++)
y[i] += alpha * sp_conj_dot_product(S[i], x, incx);
}
else
{
for (int i=0; i<M; i++)
y[i * incy] += alpha * sp_conj_dot_product(S[i], x, incx);
}
}
void nondiag_mult_vec_transpose(const T& alpha, const T* x, int incx,
T* y, int incy) const
{
/* saxpy: y += (alpha * x[i]) row[i] */
int M = num_rows();
const T* X = x;
for (int i=0; i<M; i++, X += incx)
sp_axpy( alpha * *X, S[i], y, incy);
}
void nondiag_mult_vec_conj_transpose(const T& alpha, const T* x, int incx,
T* y, int incy) const
{
/* saxpy: y += (alpha * x[i]) row[i] */
int M = num_rows();
const T* X = x;
for (int i=0; i<M; i++, X += incx)
sp_conj_axpy( alpha * *X, S[i], y, incy);
}
void mult_vec(const T& alpha, const T* x, int incx, T* y, int incy)
const
{
nondiag_mult_vec(alpha, x, incx, y, incy);
if (is_triangular() || is_symmetric())
mult_diag(alpha, x, incx, y, incy);
if (is_symmetric())
nondiag_mult_vec_transpose(alpha, x, incx, y, incy);
}
void mult_vec_transpose(const T& alpha, const T* x, int incx, T* y,
int incy) const
{
nondiag_mult_vec_transpose(alpha, x, incx, y, incy);
if (is_triangular() || is_symmetric())
mult_diag(alpha, x, incx, y, incy);
if (is_symmetric())
nondiag_mult_vec(alpha, x, incx, y, incy);
}
void mult_vec_conj_transpose(const T& alpha, const T* x, int incx, T* y,
int incy) const
{
nondiag_mult_vec_conj_transpose(alpha, x, incx, y, incy);
if (is_triangular() || is_symmetric())
mult_conj_diag(alpha, x, incx, y, incy);
if (is_symmetric())
nondiag_mult_vec_conj(alpha, x, incx, y, incy);
}
int triangular_solve(T alpha, T* x, int incx ) const
{
if (alpha == (T) 0.0)
ERROR_RETURN(1);
if ( ! is_triangular() )
ERROR_RETURN(1);
int N = num_rows();
if (is_lower_triangular())
{
for (int i=0, ii=0; i<N; i++, ii += incx)
{
x[ii] = (x[ii] - sp_dot_product(S[i], x, incx)) / diag[i];
}
if (alpha != (T) 1.0)
{
for (int i=0, ii=0; i<N; i++, ii += incx)
x[ii] /= alpha;
}
}
else if (is_upper_triangular())
{
for (int i=N-1, ii=(N-1)*incx ; 0<=i ; i--, ii-=incx)
{
x[ii] = (x[ii] - sp_dot_product(S[i],x, incx)) / diag[i];
}
if (alpha != (T) 1.0)
{
for (int i=N-1, ii=(N-1)*incx ; 0<=i ; i--, ii-=incx)
x[ii] /= alpha;
}
}
else
ERROR_RETURN(1);
return 0;
}
int transpose_triangular_solve(T alpha, T* x, int incx) const
{
if ( ! is_triangular())
return -1;
int N = num_rows();
if (is_lower_triangular())
{
for (int j=N-1, jj=(N-1)*incx; 0<=j; j--, jj -= incx)
{
x[jj] /= diag[j] ;
sp_axpy( -x[jj], S[j], x, incx);
}
if (alpha != (T) 1.0)
{
for (int jj=(N-1)*incx; 0<=jj; jj -=incx)
x[jj] /= alpha;
}
}
else if (is_upper_triangular())
{
for (int j=0, jj=0; j<N; j++, jj += incx)
{
x[jj] /= diag[j];
sp_axpy(- x[jj], S[j], x, incx);
}
if (alpha != (T) 1.0)
{
for (int jj=(N-1)*incx; 0<=jj; jj -=incx)
x[jj] /= alpha;
}
}
else
ERROR_RETURN(1);
return 0;
}
int transpose_triangular_conj_solve(T alpha, T* x, int incx) const
{
if ( ! is_triangular())
return -1;
int N = num_rows();
if (is_lower_triangular())
{
for (int j=N-1, jj=(N-1)*incx; 0<=j; j--, jj -= incx)
{
x[jj] /= conj(diag[j]) ;
sp_conj_axpy( -x[jj], S[j], x, incx);
}
if (alpha != (T) 1.0)
{
for (int jj=(N-1)*incx; 0<=jj; jj -=incx)
x[jj] /= alpha;
}
}
else if (is_upper_triangular())
{
for (int j=0, jj=0; j<N; j++, jj += incx)
{
x[jj] /= conj(diag[j]);
sp_conj_axpy(- x[jj], S[j], x, incx);
}
if (alpha != (T) 1.0)
{
for (int jj=(N-1)*incx; 0<=jj; jj -=incx)
x[jj] /= alpha;
}
}
else
ERROR_RETURN(1);
return 0;
}
public:
inline T& val(pair<T, int> &VP) { return VP.first; }
inline int& col_index(pair<T,int> &VP) { return VP.second; }
inline const T& val(pair<T, int> const &VP) const { return VP.first; }
inline int col_index(pair<T,int> const &VP) const { return VP.second; }
TSp_mat( int M, int N) : Sp_mat(M,N), S(M), diag() {}
void destroy()
{
// set vector sizes to zero
(vector<T>(0)).swap(diag);
(vector< vector< pair<T, int> > > (0) ).swap(S);
}
/**
This function is the entry point for all of the insert routines in
this implementation. It fills the sparse matrix, one entry at a time.
If matrix is declared unit_diagonal, then inserting any diagonal
values is ignored. If it is symmetric (upper/lower) or triangular
(upper/lower) inconsistent values are not caught. (That is, entries
into the upper region of a lower triangular matrix is not reported.)
[NOTE: the base is determined at the creation phase, and can be determined
by testing whether BLAS_usgp(A, blas_one_base) returns 1. If it returns 0,
then offsets are zero based.]
@param val the numeric value of entry A(i,j)
@param i the row index of A(i,j)
@param j the column index of A(i,j)
@return 0 if succesful, 1 otherwise
*/
int insert_entry(T val, int i, int j)
{
if (is_one_base())
{
i--;
j--;
}
/* make sure the indices are in range */
ASSERT_RETURN(i >= 0, 1);
ASSERT_RETURN(i < num_rows(), 1);
ASSERT_RETURN(j >= 0, 1);
ASSERT_RETURN(j < num_cols(), 1);
/* allocate space for the diagonal, if this is the first time
* trying to insert values.
*/
if (is_new())
{
set_open();
if (is_triangular() || is_symmetric())
{
diag.resize(num_rows());
if (is_unit_diag())
{
for (unsigned int ii=0; ii< diag.size(); ii++)
diag[ii] = T(1.0);
}
else
{
for (unsigned int ii=0; ii< diag.size(); ii++)
diag[ii] = (T) 0.0;
}
}
}
if (is_open())
{
if (i==j && (is_triangular() || is_symmetric() || is_hermitian()) )
{
if (!is_unit_diag())
{
diag[i] += val;
}
else /* if unit diagonal */
{
if (val != (T) 1)
ERROR_RETURN(0); /* tries to insert non-unit diagonal */
}
if (is_upper_storage() && i > j)
ERROR_RETURN(0); /* tries to fill lower-triangular region */
else
if (is_lower_storage() && i < j)
ERROR_RETURN(0); /* tries to fill upper-triangular region */
}
else
{
S[i].push_back( make_pair(val, j) );
}
num_nonzeros() ++;
}
return 0;
}
int insert_entries( int nz, const T* Val, const int *I, const int *J)
{
for (int i=0; i<nz; i++)
{
insert_entry(Val[i], I[i], J[i]) ;
}
return 0;
}
int insert_row(int k, int nz, const T* Val, const int *J)
{
for (int i=0; i<nz; i++)
insert_entry(Val[i], k, J[i]);
return 0;
}
int insert_col(int k, int nz, const T* Val, const int *I)
{
for (int i=0; i<nz; i++)
insert_entry(Val[i], I[i], k);
return 0;
}
int insert_block(const T* Val, int row_stride,
int col_stride, int bi, int bj)
{
/* translate from block index to global indices */
int Iend = K(bi+1);
int Jend = L(bj+1);
for (int i=K(bi), r=0; i<Iend; i++, r += row_stride)
for (int j=L(bi); j<Jend; j++, r += col_stride)
insert_entry( Val[r], i, j );
return 0;
}
int end_construction()
{
return Sp_mat::end_construction();
}
int usmv(enum blas_trans_type transa, const T& alpha, const T* x , int incx,
T* y, int incy) const
{
ASSERT_RETURN(is_valid(), -1);
if (transa == blas_no_trans)
mult_vec(alpha, x, incx, y, incy);
else
if (transa == blas_conj_trans)
mult_vec_conj_transpose(alpha, x, incx, y, incy);
else
if ( transa == blas_trans)
mult_vec_transpose(alpha, x, incx, y, incy);
else
ERROR_RETURN(1);
return 0;
}
int usmm(enum blas_order_type ordera, enum blas_trans_type transa,
int nrhs, const T& alpha, const T* b, int ldb, T* C, int ldC) const
{
if (ordera == blas_rowmajor)
{
/* for each column of C, perform a mat_vec */
for (int i=0; i<nrhs; i++)
{
usmv( transa, alpha, &b[i], ldb, &C[i], ldC );
}
return 0;
}
else
if (ordera == blas_colmajor)
{
/* for each column of C, perform a mat_vec */
for (int i=0; i<nrhs; i++)
{
usmv( transa, alpha, &b[i*ldb], 1, &C[i*ldC], 1 );
}
return 0;
}
else
ERROR_RETURN(1);
}
int ussv( enum blas_trans_type transa, const T& alpha, T* x, int incx) const
{
if (transa == blas_trans)
return transpose_triangular_solve(alpha, x, incx);
else
if (transa == blas_conj_trans)
return transpose_triangular_conj_solve(alpha, x, incx);
else
if (transa == blas_no_trans)
return triangular_solve(alpha, x, incx);
else
ERROR_RETURN(1);
}
int ussm( enum blas_order_type ordera, enum blas_trans_type transa, int nrhs,
const T& alpha, T* C, int ldC) const
{
if (ordera == blas_rowmajor)
{
/* for each column of C, perform a usmv */
for (int i=0; i<nrhs; i++)
{
ussv(
transa, alpha, &C[i], ldC );
}
return 0;
}
else
if (ordera == blas_colmajor)
{
/* for each column of C, perform a mat_vec */
for (int i=0; i<nrhs; i++)
{
ussv( transa, alpha, &C[i*ldC], 1 );
}
return 0;
}
else
ERROR_RETURN(1);
}
void print() const
{
Sp_mat::print(); /* print matrix header info */
/* if there is actual data, print out contents */
for (int i=0; i<num_rows(); i++)
for (unsigned int j=0; j< S[i].size(); j++)
cout << i << " " << col_index(S[i][j]) <<
" " << val(S[i][j]) << "\n";
/* if matrix is triangular, print out diagonals */
if (is_upper_triangular() || is_lower_triangular())
{
for (unsigned int i=0; i< diag.size(); i++)
cout << i << " " << i << " " << diag[i] << "\n";
}
}
};
typedef TSp_mat<float> FSp_mat;
typedef TSp_mat<double> DSp_mat;
typedef TSp_mat<complex<float> > CSp_mat;
typedef TSp_mat<complex<double> > ZSp_mat;
void table_print();
void print(int A);
}
/* namespace */
namespace NIST_SPBLAS
{
static vector<Sp_mat *> Table;
static unsigned int Table_active_matrices = 0;
int Table_insert(Sp_mat* S);
int Table_remove(unsigned int i);
/*
finds an empty slot in global sparse marix table, and fills it with
given entry. Returns -1 if no spot found, or table is corrupt.
*/
int Table_insert(Sp_mat* S)
{
if (Table_active_matrices <= Table.size())
{
Table.push_back(S);
Table_active_matrices++;
return Table.size() - 1;
}
else
{
/* there is an available slot; find it. */
for (unsigned int i=0; i<Table.size(); i++)
{
if (Table[i] == NULL)
{
Table[i] = S;
Table_active_matrices++;
return i;
}
}
}
return -1;
}
/*
removes an exisiting sparse matrix from global table. Returns 0, if
successfull, 1 otherwise.
*/
int Table_remove(unsigned int i)
{
if (i < Table.size() && Table[i] != NULL)
{
Table[i] = NULL;
Table_active_matrices--;
return 0;
}
else
return -1;
}
void Sp_mat::print() const
{
cout << "State : " <<
(is_void() ? "void" :
is_new() ? "new" :
is_open() ? "open" :
is_valid() ? "valid" : "unknown") << "\n";
cout << "M = " << num_rows() << " N = " << num_cols() <<
" nz = " << num_nonzeros() << "\n";
#define yesno(exp) ( (exp) ? "yes" : "no" )
cout << "real: " << yesno(is_real()) << "\n";
cout << "complex: " << yesno(is_complex()) << "\n";
cout << "double " << yesno(is_double_precision()) << "\n";
cout << "single " << yesno(is_single_precision()) << "\n";
cout << "upper_triangular: " << yesno(is_upper_triangular()) << "\n";
cout << "lower_triangular: " << yesno(is_lower_triangular()) << "\n";
cout << "regular: " << yesno(is_opt_regular()) << "\n";
cout << "irregular: " << yesno(is_opt_irregular()) << "\n";
cout << "block: " << yesno(is_opt_block()) << "\n";
cout << "unassembled:" << yesno(is_opt_unassembled()) << "\n";
#undef yesno
}
void table_print()
{
cout << "Table has " << Table.size() << " element(s). \n";
for (unsigned int i=0; i< Table.size(); i++)
{
if (Table[i] != 0)
{
cout << "***** Table[" << i << "]: \n";
Table[i]->print();
cout << "\n\n";
}
}
}
void print(int A)
{
cout << "\n";
Table[A]->print();
cout << "\n";
}
}
/* namespace NIST_SPBLAS */
using namespace std;
using namespace NIST_SPBLAS;
/* Level 1 */
/* these macros are useful for creating some consistency between the
various precisions and floating point types.
*/
typedef float FLOAT;
typedef double DOUBLE;
typedef complex<float> COMPLEX_FLOAT;
typedef complex<double> COMPLEX_DOUBLE;
typedef float SPBLAS_FLOAT_IN;
typedef double SPBLAS_DOUBLE_IN;
typedef const void * SPBLAS_COMPLEX_FLOAT_IN;
typedef const void * SPBLAS_COMPLEX_DOUBLE_IN;
typedef float * SPBLAS_FLOAT_OUT;
typedef double * SPBLAS_DOUBLE_OUT;
typedef void * SPBLAS_COMPLEX_FLOAT_OUT;
typedef void * SPBLAS_COMPLEX_DOUBLE_OUT;
typedef float * SPBLAS_FLOAT_IN_OUT;
typedef double * SPBLAS_DOUBLE_IN_OUT;
typedef void * SPBLAS_COMPLEX_FLOAT_IN_OUT;
typedef void * SPBLAS_COMPLEX_DOUBLE_IN_OUT;
typedef const float * SPBLAS_VECTOR_FLOAT_IN;
typedef const double * SPBLAS_VECTOR_DOUBLE_IN;
typedef const void * SPBLAS_VECTOR_COMPLEX_FLOAT_IN;
typedef const void * SPBLAS_VECTOR_COMPLEX_DOUBLE_IN;
typedef float * SPBLAS_VECTOR_FLOAT_OUT;
typedef double * SPBLAS_VECTOR_DOUBLE_OUT;
typedef void * SPBLAS_VECTOR_COMPLEX_FLOAT_OUT;
typedef void * SPBLAS_VECTOR_COMPLEX_DOUBLE_OUT;
typedef float * SPBLAS_VECTOR_FLOAT_IN_OUT;
typedef double * SPBLAS_VECTOR_DOUBLE_IN_OUT;
typedef void * SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT;
typedef void * SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT;
#define SPBLAS_TO_FLOAT_IN(x) x
#define SPBLAS_TO_DOUBLE_IN(x) x
#define SPBLAS_TO_COMPLEX_FLOAT_IN(x) \
(* reinterpret_cast<const complex<float> *>(x))
#define SPBLAS_TO_COMPLEX_DOUBLE_IN(x) \
(* reinterpret_cast<const complex<double> *>(x))
#define SPBLAS_TO_FLOAT_OUT(x) x
#define SPBLAS_TO_DOUBLE_OUT(x) x
#define SPBLAS_TO_COMPLEX_FLOAT_OUT(x) reinterpret_cast<complex<float> *>(x)
#define SPBLAS_TO_COMPLEX_DOUBLE_OUT(x) reinterpret_cast<complex<double> *>(x)
#define SPBLAS_TO_FLOAT_IN_OUT(x) x
#define SPBLAS_TO_DOUBLE_IN_OUT(x) x
#define SPBLAS_TO_COMPLEX_FLOAT_IN_OUT(x) reinterpret_cast<complex<float> *>(x)
#define SPBLAS_TO_COMPLEX_DOUBLE_IN_OUT(x) reinterpret_cast<complex<double>*>(x)
#define SPBLAS_TO_VECTOR_DOUBLE_IN(x) x
#define SPBLAS_TO_VECTOR_FLOAT_IN(x) x
#define SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN(x) \
reinterpret_cast<const complex<float>*>(x)
#define SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN(x) \
reinterpret_cast<const complex<double>*>(x)
#define SPBLAS_TO_VECTOR_DOUBLE_OUT(x) x
#define SPBLAS_TO_VECTOR_FLOAT_OUT(x) x
#define SPBLAS_TO_VECTOR_COMPLEX_FLOAT_OUT(x) \
reinterpret_cast<complex<float>*>(x)
#define SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_OUT(x) \
reinterpret_cast<complex<double>*>(x)
#define SPBLAS_TO_VECTOR_DOUBLE_IN_OUT(x) x
#define SPBLAS_TO_VECTOR_FLOAT_IN_OUT(x) x
#define SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN_OUT(x) \
reinterpret_cast<complex<float>*>(x)
#define SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN_OUT(x) \
reinterpret_cast<complex<double>*>(x)
#define BLAS_FLOAT_NAME(routine_name) BLAS_s##routine_name
#define BLAS_DOUBLE_NAME(routine_name) BLAS_d##routine_name
#define BLAS_COMPLEX_FLOAT_NAME(routine_name) BLAS_c##routine_name
#define BLAS_COMPLEX_DOUBLE_NAME(routine_name) BLAS_z##routine_name
#define TSp_MAT_SET_FLOAT(A) {A->set_single_precision(); A->set_real();}
#define TSp_MAT_SET_DOUBLE(A) {A->set_double_precision(); A->set_real();}
#define TSp_MAT_SET_COMPLEX_FLOAT(A) {A->set_single_precision(); A->set_complex();}
#define TSp_MAT_SET_COMPLEX_DOUBLE(A) {A->set_double_precision(); A->set_complex();}
/*------------------------------------*/
/* Non-precision Sparse BLAS routines */
/*------------------------------------*/
/* -------- */
/* USSP() */
/* -------- */
int BLAS_ussp(blas_sparse_matrix A, int pname)
{
Sp_mat *S = Table[A];
/* Note: these are returns, in the case */
/* statement, so "break" is not needed. */
switch (pname)
{
case (blas_zero_base) : S->set_zero_base(); break;
case (blas_one_base) : S->set_one_base(); break;
case (blas_unit_diag) : S->set_unit_diag(); break;
case (blas_complex) : S->set_complex(); break;
case (blas_real) : S->set_real(); break;
case (blas_single_precision) : S->set_single_precision(); break;
case (blas_double_precision) : S->set_double_precision(); break;
case (blas_lower_triangular) : S->set_lower_triangular(); break;
case (blas_upper_triangular) : S->set_upper_triangular(); break;
case (blas_lower_symmetric) : S->set_lower_symmetric(); break;
case (blas_upper_symmetric) : S->set_upper_symmetric(); break;
case (blas_lower_hermitian) : S->set_lower_hermitian(); break;
case (blas_upper_hermitian) : S->set_upper_hermitian(); break;
/* optimizations not used */
case (blas_regular ) :
case (blas_irregular) :
case (blas_block) :
case (blas_unassembled) : return 0;
default: return -1; /* invalid property */
}
return 0;
}
/* -------- */
/* USGP() */
/* -------- */
int BLAS_usgp(blas_sparse_matrix A, int pname)
{
Sp_mat *S = Table[A];
switch (pname)
{
case (blas_num_rows) : return S->num_rows();
case (blas_num_cols) : return S->num_cols();
case (blas_num_nonzeros) : return S->num_nonzeros();
case (blas_complex) : return S->is_complex();
case (blas_real) : return S->is_real();
case (blas_single_precision) : return S->is_single_precision();
case (blas_double_precision) : return S->is_double_precision();
case (blas_lower_triangular) : return S->is_lower_triangular(); break;
case (blas_upper_triangular) : return S->is_upper_triangular(); break;
case (blas_general) : return S->is_general();
case (blas_symmetric) : return S->is_symmetric();
case (blas_hermitian) : return S->is_hermitian();
case (blas_zero_base) : return S->is_zero_base();
case (blas_one_base) : return S->is_one_base();
case (blas_rowmajor) : return S->is_rowmajor();
case (blas_colmajor) : return S->is_colmajor();
case (blas_new_handle) : return S->is_new();
case (blas_valid_handle) : return S->is_valid();
case (blas_open_handle) : return S->is_open();
case (blas_invalid_handle) : return S->is_void();
case (blas_regular) : return S->is_opt_regular();
case (blas_irregular) : return S->is_opt_irregular();
case (blas_block) : return S->is_opt_block();
case (blas_unassembled) : return S->is_opt_unassembled();
default: return -1; /* invalid property */
}
}
/* -------- */
/* USDS() */
/* -------- */
int BLAS_usds(int A)
{
Sp_mat *S = Table[A];
S->destroy();
Table_remove(A);
return 0;
}
/* --------------------------- */
/* Level 1 generic routines */
/* --------------------------- */
/* dummy routines for real version of usdot to compile. */
inline const double& conj(const double &x)
{
return x;
}
inline const float& conj(const float &x)
{
return x;
}
template <class T>
void BLAS_xusdot( enum blas_conj_type conj_flag, int nz,
const T *x, const int *index, const T *y, int incy,
T *r, enum blas_base_type index_base)
{
T t(0);
if (index_base == blas_one_base)
y -= incy;
if (conj_flag == blas_no_conj)
{
for (int i=0; i<nz; i++)
t += x[i] * y[index[i]*incy];
}
else
for (int i=0; i<nz; i++)
t += conj(x[i]) * y[index[i]*incy];
*r = t;
}
template <class T>
void BLAS_xusaxpy(int nz, T alpha, const T *x,
const int *index, T *y, int incy,
enum blas_base_type index_base)
{
if (index_base == blas_one_base)
y -= incy;
for (int i=0; i<nz; i++)
{
// y[index[i]*incy] += (alpha * x[i]);
}
}
template <class T>
void BLAS_xusga( int nz, const T *y, int incy, T *x, const int *indx,
enum blas_base_type index_base )
{
if (index_base == blas_one_base)
y -= incy;
for (int i=0; i<nz; i++)
x[i] = y[indx[i]*incy];
}
template <class T>
void BLAS_xusgz( int nz, T *y, int incy, T *x, const int *indx,
enum blas_base_type index_base )
{
if (index_base == blas_one_base)
y -= incy;
for (int i=0; i<nz; i++)
{
x[i] = y[indx[i]*incy];
y[indx[i]*incy] = (T) 0.0;
}
}
template <class T>
void BLAS_xussc(int nz, const T *x, T *y, int incy, const int *index,
enum blas_base_type index_base)
{
if (index_base == blas_one_base)
y -= incy;
for (int i=0; i<nz; i++)
y[index[i]*incy] = x[i];
}
/* --------------------------- */
/* Level 2&3 generic precision */
/* --------------------------- */
template <class T>
int BLAS_xuscr_insert_entry(blas_sparse_matrix A, const T& val, int i, int j)
{
return ((TSp_mat<T> *)Table[A])->insert_entry(val, i, j);
}
template <class T>
int BLAS_xuscr_insert_entries(blas_sparse_matrix A, int nz, const T* Val,
const int* I, const int *J)
{
return ((TSp_mat<T>*) Table[A])->insert_entries(nz, Val, I, J);
}
template <class T>
int BLAS_xuscr_insert_col(blas_sparse_matrix A, int j, int nz, const T* Val,
const int* indx)
{
return ((TSp_mat<T>*) Table[A])->insert_col(j, nz, Val, indx);
}
template <class T>
int BLAS_xuscr_insert_row(blas_sparse_matrix A, int i, int nz, const T* Val,
const int* indx)
{
return ((TSp_mat<T>*) Table[A])->insert_row(i, nz, Val, indx);
}
template <class T>
int BLAS_xuscr_insert_clique(blas_sparse_matrix A, int k, int l, const T* Val,
const int row_stride, const int col_stride, const int *indx,
const int *jndx)
{
return ((TSp_mat<T>*) Table[A])->insert_clique(k, l, Val, row_stride,
col_stride, indx, jndx);
}
template <class T>
int BLAS_xuscr_insert_block(blas_sparse_matrix A, const T* Val,
const int row_stride, const int col_stride, int bi, int bj )
{
return ((TSp_mat<T>*) Table[A])->insert_block(Val,
row_stride, col_stride, bi, bj);
}
inline int BLAS_xuscr_end(blas_sparse_matrix A)
{
return (Table[A])->end_construction();
}
template <class T>
int BLAS_xusmv(enum blas_trans_type transa, const T& alpha,
blas_sparse_matrix A, const T *x, int incx, T *y, int incy )
{
TSp_mat<T> *M = (TSp_mat<T> *) Table[A];
ASSERT_RETURN(M->is_valid(), 1);
return M->usmv(transa, alpha, x, incx, y, incy);
}
template <class T>
int BLAS_xusmm(enum blas_order_type ordera, enum blas_trans_type transa,
int nrhs, const T& alpha, blas_sparse_matrix A,
const T *B, int ldB, T* C, int ldC)
{
TSp_mat<T> *M = (TSp_mat<T> *) Table[A];
ASSERT_RETURN(M->is_valid(), 1);
return M->usmm(ordera, transa, nrhs, alpha, B, ldB, C, ldC);
}
template <class T>
int BLAS_xussv(enum blas_trans_type transa, const T& alpha,
blas_sparse_matrix A, T *x, int incx)
{
TSp_mat<T> *M =
(TSp_mat<T> *) Table[A];
ASSERT_RETURN(M->is_valid(), 1);
return M->ussv(transa, alpha, x, incx);
}
template <class T>
int BLAS_xussm(enum blas_order_type orderA, enum blas_trans_type transa,
int nrhs, const T& alpha, blas_sparse_matrix A, T *C, int ldC)
{
TSp_mat<T> *M =
(TSp_mat<T> *) Table[A];
ASSERT_RETURN(M->is_valid(), 1);
return M->ussm(orderA, transa, nrhs, alpha, C, ldC);
}
/* --- end of generic rouintes ---- */
/*********/
/* ---- double Level 1 rouintes ----- */
/*********/
void BLAS_DOUBLE_NAME(usdot)(
enum blas_conj_type conj_flag,
int nz,
SPBLAS_VECTOR_DOUBLE_IN x,
const int *index,
SPBLAS_VECTOR_DOUBLE_IN y,
int incy,
SPBLAS_DOUBLE_OUT r,
enum blas_base_type index_base)
{
BLAS_xusdot(conj_flag, nz,
SPBLAS_TO_VECTOR_DOUBLE_IN( x ), index,
SPBLAS_TO_VECTOR_DOUBLE_IN( y ), incy,
SPBLAS_TO_DOUBLE_OUT( r ), index_base);
}
void BLAS_DOUBLE_NAME(usaxpy)(
int nz,
SPBLAS_DOUBLE_IN alpha,
SPBLAS_VECTOR_DOUBLE_IN x,
const int *index,
SPBLAS_VECTOR_DOUBLE_IN_OUT y,
int incy,
enum blas_base_type index_base)
{
BLAS_xusaxpy(nz, SPBLAS_TO_DOUBLE_IN( alpha ),
SPBLAS_TO_VECTOR_DOUBLE_IN( x ), index,
SPBLAS_TO_VECTOR_DOUBLE_IN_OUT( y ),
incy, index_base);
}
void BLAS_DOUBLE_NAME(usga)(
int nz,
SPBLAS_VECTOR_DOUBLE_IN y,
int incy,
SPBLAS_VECTOR_DOUBLE_IN_OUT x,
const int *indx,
enum blas_base_type index_base )
{
BLAS_xusga( nz, SPBLAS_TO_VECTOR_DOUBLE_IN( y ), incy,
SPBLAS_TO_VECTOR_DOUBLE_IN_OUT( x ), indx, index_base);
}
void BLAS_DOUBLE_NAME(usgz)(
int nz,
SPBLAS_VECTOR_DOUBLE_IN_OUT y,
int incy,
SPBLAS_VECTOR_DOUBLE_OUT x,
const int *indx,
enum blas_base_type index_base )
{
BLAS_xusgz(nz, SPBLAS_TO_DOUBLE_IN_OUT(y ), incy, SPBLAS_TO_DOUBLE_OUT( x ),
indx, index_base);
}
void BLAS_DOUBLE_NAME(ussc)(
int nz,
SPBLAS_VECTOR_DOUBLE_IN x,
SPBLAS_VECTOR_DOUBLE_IN_OUT y,
int incy,
const int *index,
enum blas_base_type index_base)
{
BLAS_xussc(nz, SPBLAS_TO_VECTOR_DOUBLE_IN( x ),
SPBLAS_TO_DOUBLE_IN_OUT( y ), incy, index,
index_base);
}
/* DOUBLE Level 2/3 creation routines */
int BLAS_DOUBLE_NAME(uscr_begin)(int M, int N)
{
TSp_mat<DOUBLE> *A = new TSp_mat<DOUBLE>(M, N);
TSp_MAT_SET_DOUBLE(A);
return Table_insert(A);
}
blas_sparse_matrix BLAS_DOUBLE_NAME(uscr_block_begin)(
int Mb, int Nb, int k, int l )
{
TSp_mat<DOUBLE> *A = new TSp_mat<DOUBLE>(Mb*k, Nb*l);
TSp_MAT_SET_DOUBLE(A);
A->set_const_block_parameters(Mb, Nb, k, l);
return Table_insert(A);
}
blas_sparse_matrix BLAS_DOUBLE_NAME(uscr_variable_block_begin)(
int Mb, int Nb, const int *k, const int *l )
{
TSp_mat<DOUBLE> *A = new TSp_mat<DOUBLE>(
accumulate(k, k+Mb, 0), accumulate(l, l+Nb, 0) );
TSp_MAT_SET_DOUBLE(A);
A->set_var_block_parameters(Mb, Nb, k, l);
return Table_insert(A);
}
/* DOUBLE Level 2/3 insertion routines */
int BLAS_DOUBLE_NAME(uscr_insert_entry)(
blas_sparse_matrix A, SPBLAS_DOUBLE_IN val, int i, int j )
{
return BLAS_xuscr_insert_entry(A, SPBLAS_TO_DOUBLE_IN( val ), i, j);
}
int BLAS_DOUBLE_NAME(uscr_insert_entries)(
blas_sparse_matrix A, int nz,
SPBLAS_VECTOR_DOUBLE_IN val,
const int *indx, const int *jndx )
{
return BLAS_xuscr_insert_entries(A, nz, SPBLAS_TO_VECTOR_DOUBLE_IN( val ), indx, jndx);
}
int BLAS_DOUBLE_NAME(uscr_insert_col)(
blas_sparse_matrix A, int j, int nz,
SPBLAS_VECTOR_DOUBLE_IN val, const int *indx )
{
return BLAS_xuscr_insert_col(A, j, nz, SPBLAS_TO_VECTOR_DOUBLE_IN( val ), indx);
}
int BLAS_DOUBLE_NAME(uscr_insert_row)(
blas_sparse_matrix A, int i, int nz,
SPBLAS_VECTOR_DOUBLE_IN val, const int *indx );
int BLAS_DOUBLE_NAME(uscr_insert_clique)(
blas_sparse_matrix A,
const int k,
const int l,
SPBLAS_VECTOR_DOUBLE_IN val,
const int row_stride,
const int col_stride,
const int *indx,
const int *jndx );
int BLAS_DOUBLE_NAME(uscr_insert_block)(
blas_sparse_matrix A,
SPBLAS_VECTOR_DOUBLE_IN val,
int row_stride,
int col_stride,
int i, int j )
{
return BLAS_xuscr_insert_block(
A, SPBLAS_TO_VECTOR_DOUBLE_IN( val ),
row_stride, col_stride, i, j);
}
int BLAS_DOUBLE_NAME(uscr_end)(blas_sparse_matrix A)
{
return BLAS_xuscr_end(A);
}
/* DOUBLE Level 2/3 computational routines */
int BLAS_DOUBLE_NAME(usmv)(enum
blas_trans_type transa,
SPBLAS_DOUBLE_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_DOUBLE_IN x,
int incx,
SPBLAS_VECTOR_DOUBLE_IN_OUT y,
int incy )
{
return BLAS_xusmv(
transa, SPBLAS_TO_DOUBLE_IN( alpha ), A,
SPBLAS_TO_VECTOR_DOUBLE_IN( x ), incx,
SPBLAS_TO_VECTOR_DOUBLE_IN_OUT( y ), incy);
}
int BLAS_DOUBLE_NAME(usmm)(
enum blas_order_type order,
enum blas_trans_type transa,
int nrhs,
SPBLAS_DOUBLE_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_DOUBLE_IN b,
int ldb,
SPBLAS_VECTOR_DOUBLE_IN_OUT c,
int ldc )
{
return BLAS_xusmm(
order, transa, nrhs,
SPBLAS_TO_DOUBLE_IN( alpha), A,
SPBLAS_TO_VECTOR_DOUBLE_IN(b), ldb,
SPBLAS_TO_VECTOR_DOUBLE_IN_OUT( c ), ldc);
}
int BLAS_DOUBLE_NAME(ussv)(
enum blas_trans_type transa,
SPBLAS_DOUBLE_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_DOUBLE_IN_OUT x,
int incx )
{
return BLAS_xussv( transa,
SPBLAS_TO_DOUBLE_IN( alpha ), A,
SPBLAS_TO_VECTOR_DOUBLE_IN_OUT( x ),
incx);
}
int BLAS_DOUBLE_NAME(ussm)(
enum blas_order_type order,
enum blas_trans_type transt,
int nrhs,
SPBLAS_DOUBLE_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_DOUBLE_IN_OUT b,
int ldb )
{
return BLAS_xussm(order, transt, nrhs,
SPBLAS_TO_DOUBLE_IN( alpha ), A,
SPBLAS_TO_VECTOR_DOUBLE_IN_OUT( b ), ldb);
}
/* ---- end of DOUBLE routines ------- */
void BLAS_COMPLEX_DOUBLE_NAME(usdot)(
enum blas_conj_type conj_flag,
int nz,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN x,
const int *index,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN y,
int incy,
SPBLAS_COMPLEX_DOUBLE_OUT r,
enum blas_base_type index_base)
{
BLAS_xusdot(conj_flag, nz,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( x ), index,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( y ), incy,
SPBLAS_TO_COMPLEX_DOUBLE_OUT( r ), index_base);
}
void BLAS_COMPLEX_DOUBLE_NAME(usaxpy)(
int nz,
SPBLAS_COMPLEX_DOUBLE_IN alpha,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN x,
const int *index,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT y,
int incy,
enum blas_base_type index_base)
{
BLAS_xusaxpy(nz, SPBLAS_TO_COMPLEX_DOUBLE_IN( alpha ),
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( x ), index,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN_OUT( y ),
incy, index_base);
}
void BLAS_COMPLEX_DOUBLE_NAME(usga)(
int nz,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN y,
int incy,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT x,
const int *indx,
enum blas_base_type index_base )
{
BLAS_xusga( nz, SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( y ), incy,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN_OUT( x ), indx, index_base);
}
void BLAS_COMPLEX_DOUBLE_NAME(usgz)(
int nz,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT y,
int incy,
SPBLAS_VECTOR_COMPLEX_DOUBLE_OUT x,
const int *indx,
enum blas_base_type index_base )
{
BLAS_xusgz(nz, SPBLAS_TO_COMPLEX_DOUBLE_IN_OUT(y ), incy, SPBLAS_TO_COMPLEX_DOUBLE_OUT( x ),
indx, index_base);
}
void BLAS_COMPLEX_DOUBLE_NAME(ussc)(
int nz,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN x,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT y,
int incy,
const int *index,
enum blas_base_type index_base)
{
BLAS_xussc(nz, SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( x ),
SPBLAS_TO_COMPLEX_DOUBLE_IN_OUT( y ), incy, index,
index_base);
}
/* COMPLEX_DOUBLE Level 2/3 creation routines */
int BLAS_COMPLEX_DOUBLE_NAME(uscr_begin)(int M, int N)
{
TSp_mat<COMPLEX_DOUBLE> *A = new TSp_mat<COMPLEX_DOUBLE>(M, N);
TSp_MAT_SET_COMPLEX_DOUBLE(A);
return Table_insert(A);
}
blas_sparse_matrix BLAS_COMPLEX_DOUBLE_NAME(uscr_block_begin)(
int Mb, int Nb, int k, int l )
{
TSp_mat<COMPLEX_DOUBLE> *A = new TSp_mat<COMPLEX_DOUBLE>(Mb*k, Nb*l);
TSp_MAT_SET_COMPLEX_DOUBLE(A);
A->set_const_block_parameters(Mb, Nb, k, l);
return Table_insert(A);
}
blas_sparse_matrix BLAS_COMPLEX_DOUBLE_NAME(uscr_variable_block_begin)(
int Mb, int Nb, const int *k, const int *l )
{
TSp_mat<COMPLEX_DOUBLE> *A = new TSp_mat<COMPLEX_DOUBLE>(
accumulate(k, k+Mb, 0), accumulate(l, l+Nb, 0) );
TSp_MAT_SET_COMPLEX_DOUBLE(A);
A->set_var_block_parameters(Mb, Nb, k, l);
return Table_insert(A);
}
/* COMPLEX_DOUBLE Level 2/3 insertion routines */
int BLAS_COMPLEX_DOUBLE_NAME(uscr_insert_entry)(
blas_sparse_matrix A, SPBLAS_COMPLEX_DOUBLE_IN val, int i, int j )
{
return BLAS_xuscr_insert_entry(A, SPBLAS_TO_COMPLEX_DOUBLE_IN( val ), i, j);
}
int BLAS_COMPLEX_DOUBLE_NAME(uscr_insert_entries)(
blas_sparse_matrix A, int nz,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN val,
const int *indx, const int *jndx )
{
return BLAS_xuscr_insert_entries(A, nz, SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( val ), indx, jndx);
}
int BLAS_COMPLEX_DOUBLE_NAME(uscr_insert_col)(
blas_sparse_matrix A, int j, int nz,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN val, const int *indx )
{
return BLAS_xuscr_insert_col(A, j, nz, SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( val ), indx);
}
int BLAS_COMPLEX_DOUBLE_NAME(uscr_insert_row)(
blas_sparse_matrix A, int i, int nz,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN val, const int *indx );
int BLAS_COMPLEX_DOUBLE_NAME(uscr_insert_clique)(
blas_sparse_matrix A,
const int k,
const int l,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN val,
const int row_stride,
const int col_stride,
const int *indx,
const int *jndx );
int BLAS_COMPLEX_DOUBLE_NAME(uscr_insert_block)(
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN val,
int row_stride,
int col_stride,
int i, int j )
{
return BLAS_xuscr_insert_block(
A, SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( val ),
row_stride, col_stride, i, j);
}
int BLAS_COMPLEX_DOUBLE_NAME(uscr_end)(blas_sparse_matrix A)
{
return BLAS_xuscr_end(A);
}
/* COMPLEX_DOUBLE Level 2/3 computational routines */
int BLAS_COMPLEX_DOUBLE_NAME(usmv)(enum
blas_trans_type transa,
SPBLAS_COMPLEX_DOUBLE_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN x,
int incx,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT y,
int incy )
{
return BLAS_xusmv(
transa, SPBLAS_TO_COMPLEX_DOUBLE_IN( alpha ), A,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN( x ), incx,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN_OUT( y ), incy);
}
int BLAS_COMPLEX_DOUBLE_NAME(usmm)(
enum blas_order_type order,
enum blas_trans_type transa,
int nrhs,
SPBLAS_COMPLEX_DOUBLE_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN b,
int ldb,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT c,
int ldc )
{
return BLAS_xusmm(
order, transa, nrhs,
SPBLAS_TO_COMPLEX_DOUBLE_IN( alpha), A,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN(b), ldb,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN_OUT( c ), ldc);
}
int BLAS_COMPLEX_DOUBLE_NAME(ussv)(
enum blas_trans_type transa,
SPBLAS_COMPLEX_DOUBLE_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT x,
int incx )
{
return BLAS_xussv( transa,
SPBLAS_TO_COMPLEX_DOUBLE_IN( alpha ), A,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN_OUT( x ),
incx);
}
int BLAS_COMPLEX_DOUBLE_NAME(ussm)(
enum blas_order_type order,
enum blas_trans_type transt,
int nrhs,
SPBLAS_COMPLEX_DOUBLE_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_DOUBLE_IN_OUT b,
int ldb )
{
return BLAS_xussm(order, transt, nrhs,
SPBLAS_TO_COMPLEX_DOUBLE_IN( alpha ), A,
SPBLAS_TO_VECTOR_COMPLEX_DOUBLE_IN_OUT( b ), ldb);
}
/* ---- end of COMPLEX_COMPLEX_COMPLEX_DOUBLE routines ------- */
/*********/
/* ---- double Level 1 rouintes ----- */
/*********/
void BLAS_FLOAT_NAME(usdot)(
enum blas_conj_type conj_flag,
int nz,
SPBLAS_VECTOR_FLOAT_IN x,
const int *index,
SPBLAS_VECTOR_FLOAT_IN y,
int incy,
SPBLAS_FLOAT_OUT r,
enum blas_base_type index_base)
{
BLAS_xusdot(conj_flag, nz,
SPBLAS_TO_VECTOR_FLOAT_IN( x ), index,
SPBLAS_TO_VECTOR_FLOAT_IN( y ), incy,
SPBLAS_TO_FLOAT_OUT( r ), index_base);
}
void BLAS_FLOAT_NAME(usaxpy)(
int nz,
SPBLAS_FLOAT_IN alpha,
SPBLAS_VECTOR_FLOAT_IN x,
const int *index,
SPBLAS_VECTOR_FLOAT_IN_OUT y,
int incy,
enum blas_base_type index_base)
{
BLAS_xusaxpy(nz, SPBLAS_TO_FLOAT_IN( alpha ),
SPBLAS_TO_VECTOR_FLOAT_IN( x ), index,
SPBLAS_TO_VECTOR_FLOAT_IN_OUT( y ),
incy, index_base);
}
void BLAS_FLOAT_NAME(usga)(
int nz,
SPBLAS_VECTOR_FLOAT_IN y,
int incy,
SPBLAS_VECTOR_FLOAT_IN_OUT x,
const int *indx,
enum blas_base_type index_base )
{
BLAS_xusga( nz, SPBLAS_TO_VECTOR_FLOAT_IN( y ), incy,
SPBLAS_TO_VECTOR_FLOAT_IN_OUT( x ), indx, index_base);
}
void BLAS_FLOAT_NAME(usgz)(
int nz,
SPBLAS_VECTOR_FLOAT_IN_OUT y,
int incy,
SPBLAS_VECTOR_FLOAT_OUT x,
const int *indx,
enum blas_base_type index_base )
{
BLAS_xusgz(nz, SPBLAS_TO_FLOAT_IN_OUT(y ), incy, SPBLAS_TO_FLOAT_OUT( x ),
indx, index_base);
}
void BLAS_FLOAT_NAME(ussc)(
int nz,
SPBLAS_VECTOR_FLOAT_IN x,
SPBLAS_VECTOR_FLOAT_IN_OUT y,
int incy,
const int *index,
enum blas_base_type index_base)
{
BLAS_xussc(nz, SPBLAS_TO_VECTOR_FLOAT_IN( x ),
SPBLAS_TO_FLOAT_IN_OUT( y ), incy, index,
index_base);
}
/* FLOAT Level 2/3 creation routines */
int BLAS_FLOAT_NAME(uscr_begin)(int M, int N)
{
TSp_mat<FLOAT> *A = new TSp_mat<FLOAT>(M, N);
TSp_MAT_SET_FLOAT(A);
return Table_insert(A);
}
blas_sparse_matrix BLAS_FLOAT_NAME(uscr_block_begin)(
int Mb, int Nb, int k, int l )
{
TSp_mat<FLOAT> *A = new TSp_mat<FLOAT>(Mb*k, Nb*l);
TSp_MAT_SET_FLOAT(A);
A->set_const_block_parameters(Mb, Nb, k, l);
return Table_insert(A);
}
blas_sparse_matrix BLAS_FLOAT_NAME(uscr_variable_block_begin)(
int Mb, int Nb, const int *k, const int *l )
{
TSp_mat<FLOAT> *A = new TSp_mat<FLOAT>(
accumulate(k, k+Mb, 0), accumulate(l, l+Nb, 0) );
TSp_MAT_SET_FLOAT(A);
A->set_var_block_parameters(Mb, Nb, k, l);
return Table_insert(A);
}
/* FLOAT Level 2/3 insertion routines */
int BLAS_FLOAT_NAME(uscr_insert_entry)(
blas_sparse_matrix A, SPBLAS_FLOAT_IN val, int i, int j )
{
return BLAS_xuscr_insert_entry(A, SPBLAS_TO_FLOAT_IN( val ), i, j);
}
int BLAS_FLOAT_NAME(uscr_insert_entries)(
blas_sparse_matrix A, int nz,
SPBLAS_VECTOR_FLOAT_IN val,
const int *indx, const int *jndx )
{
return BLAS_xuscr_insert_entries(A, nz, SPBLAS_TO_VECTOR_FLOAT_IN( val ), indx, jndx);
}
int BLAS_FLOAT_NAME(uscr_insert_col)(
blas_sparse_matrix A, int j, int nz,
SPBLAS_VECTOR_FLOAT_IN val, const int *indx )
{
return BLAS_xuscr_insert_col(A, j, nz, SPBLAS_TO_VECTOR_FLOAT_IN( val ), indx);
}
int BLAS_FLOAT_NAME(uscr_insert_row)(
blas_sparse_matrix A, int i, int nz,
SPBLAS_VECTOR_FLOAT_IN val, const int *indx );
int BLAS_FLOAT_NAME(uscr_insert_clique)(
blas_sparse_matrix A,
const int k,
const int l,
SPBLAS_VECTOR_FLOAT_IN val,
const int row_stride,
const int col_stride,
const int *indx,
const int *jndx );
int BLAS_FLOAT_NAME(uscr_insert_block)(
blas_sparse_matrix A,
SPBLAS_VECTOR_FLOAT_IN val,
int row_stride,
int col_stride,
int i, int j )
{
return BLAS_xuscr_insert_block(
A, SPBLAS_TO_VECTOR_FLOAT_IN( val ),
row_stride, col_stride, i, j);
}
int BLAS_FLOAT_NAME(uscr_end)(blas_sparse_matrix A)
{
return BLAS_xuscr_end(A);
}
/* FLOAT Level 2/3 computational routines */
int BLAS_FLOAT_NAME(usmv)(enum
blas_trans_type transa,
SPBLAS_FLOAT_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_FLOAT_IN x,
int incx,
SPBLAS_VECTOR_FLOAT_IN_OUT y,
int incy )
{
return BLAS_xusmv(
transa, SPBLAS_TO_FLOAT_IN( alpha ), A,
SPBLAS_TO_VECTOR_FLOAT_IN( x ), incx,
SPBLAS_TO_VECTOR_FLOAT_IN_OUT( y ), incy);
}
int BLAS_FLOAT_NAME(usmm)(
enum blas_order_type order,
enum blas_trans_type transa,
int nrhs,
SPBLAS_FLOAT_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_FLOAT_IN b,
int ldb,
SPBLAS_VECTOR_FLOAT_IN_OUT c,
int ldc )
{
return BLAS_xusmm(
order, transa, nrhs,
SPBLAS_TO_FLOAT_IN( alpha), A,
SPBLAS_TO_VECTOR_FLOAT_IN(b), ldb,
SPBLAS_TO_VECTOR_FLOAT_IN_OUT( c ), ldc);
}
int BLAS_FLOAT_NAME(ussv)(
enum blas_trans_type transa,
SPBLAS_FLOAT_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_FLOAT_IN_OUT x,
int incx )
{
return BLAS_xussv( transa,
SPBLAS_TO_FLOAT_IN( alpha ), A,
SPBLAS_TO_VECTOR_FLOAT_IN_OUT( x ),
incx);
}
int BLAS_FLOAT_NAME(ussm)(
enum blas_order_type order,
enum blas_trans_type transt,
int nrhs,
SPBLAS_FLOAT_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_FLOAT_IN_OUT b,
int ldb )
{
return BLAS_xussm(order, transt, nrhs,
SPBLAS_TO_FLOAT_IN( alpha ), A,
SPBLAS_TO_VECTOR_FLOAT_IN_OUT( b ), ldb);
}
/* ---- end of FLOAT routines ------- */
void BLAS_COMPLEX_FLOAT_NAME(usdot)(
enum blas_conj_type conj_flag,
int nz,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN x,
const int *index,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN y,
int incy,
SPBLAS_COMPLEX_FLOAT_OUT r,
enum blas_base_type index_base)
{
BLAS_xusdot(conj_flag, nz,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( x ), index,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( y ), incy,
SPBLAS_TO_COMPLEX_FLOAT_OUT( r ), index_base);
}
void BLAS_COMPLEX_FLOAT_NAME(usaxpy)(
int nz,
SPBLAS_COMPLEX_FLOAT_IN alpha,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN x,
const int *index,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT y,
int incy,
enum blas_base_type index_base)
{
BLAS_xusaxpy(nz, SPBLAS_TO_COMPLEX_FLOAT_IN( alpha ),
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( x ), index,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN_OUT( y ),
incy, index_base);
}
void BLAS_COMPLEX_FLOAT_NAME(usga)(
int nz,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN y,
int incy,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT x,
const int *indx,
enum blas_base_type index_base )
{
BLAS_xusga( nz, SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( y ), incy,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN_OUT( x ), indx, index_base);
}
void BLAS_COMPLEX_FLOAT_NAME(usgz)(
int nz,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT y,
int incy,
SPBLAS_VECTOR_COMPLEX_FLOAT_OUT x,
const int *indx,
enum blas_base_type index_base )
{
BLAS_xusgz(nz, SPBLAS_TO_COMPLEX_FLOAT_IN_OUT(y ), incy, SPBLAS_TO_COMPLEX_FLOAT_OUT( x ),
indx, index_base);
}
void BLAS_COMPLEX_FLOAT_NAME(ussc)(
int nz,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN x,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT y,
int incy,
const int *index,
enum blas_base_type index_base)
{
BLAS_xussc(nz, SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( x ),
SPBLAS_TO_COMPLEX_FLOAT_IN_OUT( y ), incy, index,
index_base);
}
/* COMPLEX_FLOAT Level 2/3 creation routines */
int BLAS_COMPLEX_FLOAT_NAME(uscr_begin)(int M, int N)
{
TSp_mat<COMPLEX_FLOAT> *A = new TSp_mat<COMPLEX_FLOAT>(M, N);
TSp_MAT_SET_COMPLEX_FLOAT(A);
return Table_insert(A);
}
blas_sparse_matrix BLAS_COMPLEX_FLOAT_NAME(uscr_block_begin)(
int Mb, int Nb, int k, int l )
{
TSp_mat<COMPLEX_FLOAT> *A = new TSp_mat<COMPLEX_FLOAT>(Mb*k, Nb*l);
TSp_MAT_SET_COMPLEX_FLOAT(A);
A->set_const_block_parameters(Mb, Nb, k, l);
return Table_insert(A);
}
blas_sparse_matrix BLAS_COMPLEX_FLOAT_NAME(uscr_variable_block_begin)(
int Mb, int Nb, const int *k, const int *l )
{
TSp_mat<COMPLEX_FLOAT> *A = new TSp_mat<COMPLEX_FLOAT>(
accumulate(k, k+Mb, 0), accumulate(l, l+Nb, 0) );
TSp_MAT_SET_COMPLEX_FLOAT(A);
A->set_var_block_parameters(Mb, Nb, k, l);
return Table_insert(A);
}
/* COMPLEX_FLOAT Level 2/3 insertion routines */
int BLAS_COMPLEX_FLOAT_NAME(uscr_insert_entry)(
blas_sparse_matrix A, SPBLAS_COMPLEX_FLOAT_IN val, int i, int j )
{
return BLAS_xuscr_insert_entry(A, SPBLAS_TO_COMPLEX_FLOAT_IN( val ), i, j);
}
int BLAS_COMPLEX_FLOAT_NAME(uscr_insert_entries)(
blas_sparse_matrix A, int nz,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN val,
const int *indx, const int *jndx )
{
return BLAS_xuscr_insert_entries(A, nz, SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( val ), indx, jndx);
}
int BLAS_COMPLEX_FLOAT_NAME(uscr_insert_col)(
blas_sparse_matrix A, int j, int nz,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN val, const int *indx )
{
return BLAS_xuscr_insert_col(A, j, nz, SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( val ), indx);
}
int BLAS_COMPLEX_FLOAT_NAME(uscr_insert_row)(
blas_sparse_matrix A, int i, int nz,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN val, const int *indx );
int BLAS_COMPLEX_FLOAT_NAME(uscr_insert_clique)(
blas_sparse_matrix A,
const int k,
const int l,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN val,
const int row_stride,
const int col_stride,
const int *indx,
const int *jndx );
int BLAS_COMPLEX_FLOAT_NAME(uscr_insert_block)(
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN val,
int row_stride,
int col_stride,
int i, int j )
{
return BLAS_xuscr_insert_block(
A, SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( val ),
row_stride, col_stride, i, j);
}
int BLAS_COMPLEX_FLOAT_NAME(uscr_end)(blas_sparse_matrix A)
{
return BLAS_xuscr_end(A);
}
/* COMPLEX_FLOAT Level 2/3 computational routines */
int BLAS_COMPLEX_FLOAT_NAME(usmv)(enum
blas_trans_type transa,
SPBLAS_COMPLEX_FLOAT_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN x,
int incx,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT y,
int incy )
{
return BLAS_xusmv(
transa, SPBLAS_TO_COMPLEX_FLOAT_IN( alpha ), A,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN( x ), incx,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN_OUT( y ), incy);
}
int BLAS_COMPLEX_FLOAT_NAME(usmm)(
enum blas_order_type order,
enum blas_trans_type transa,
int nrhs,
SPBLAS_COMPLEX_FLOAT_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN b,
int ldb,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT c,
int ldc )
{
return BLAS_xusmm(
order, transa, nrhs,
SPBLAS_TO_COMPLEX_FLOAT_IN( alpha), A,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN(b), ldb,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN_OUT( c ), ldc);
}
int BLAS_COMPLEX_FLOAT_NAME(ussv)(
enum blas_trans_type transa,
SPBLAS_COMPLEX_FLOAT_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT x,
int incx )
{
return BLAS_xussv( transa,
SPBLAS_TO_COMPLEX_FLOAT_IN( alpha ), A,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN_OUT( x ),
incx);
}
int BLAS_COMPLEX_FLOAT_NAME(ussm)(
enum blas_order_type order,
enum blas_trans_type transt,
int nrhs,
SPBLAS_COMPLEX_FLOAT_IN alpha,
blas_sparse_matrix A,
SPBLAS_VECTOR_COMPLEX_FLOAT_IN_OUT b,
int ldb )
{
return BLAS_xussm(order, transt, nrhs,
SPBLAS_TO_COMPLEX_FLOAT_IN( alpha ), A,
SPBLAS_TO_VECTOR_COMPLEX_FLOAT_IN_OUT( b ), ldb);
}
/* ---- end of COMPLEX_COMPLEX_COMPLEX_FLOAT routines ------- */
| 26.227518 | 98 | 0.595762 | Technica-Corporation |
e1735bc34bcde81ef35f6a8ef8714f4a69ec413b | 9,008 | cpp | C++ | c++/meta.cpp | dscharrer/void | 80a0281f18dd8d32db8ceb5e7db31f4c8af096f6 | [
"Zlib"
] | 28 | 2015-02-21T02:17:22.000Z | 2022-01-24T20:52:15.000Z | c++/meta.cpp | dscharrer/void | 80a0281f18dd8d32db8ceb5e7db31f4c8af096f6 | [
"Zlib"
] | null | null | null | c++/meta.cpp | dscharrer/void | 80a0281f18dd8d32db8ceb5e7db31f4c8af096f6 | [
"Zlib"
] | null | null | null |
#include <iostream>
#include <utility>
#include <type_traits>
#include <cstdint>
// --------------------------------------------------------------------------
template <typename T, T Value>
struct meta_int : public std::integral_constant<T, Value> {
template <typename TT, typename = typename std::enable_if<std::is_convertible<T, TT>::value>::type>
constexpr operator TT() const { return TT(Value); }
static constexpr T get() { return Value; }
};
#define META { return { }; }
#define META_INT_BINARY_OPERATOR(op) \
template <typename T0, T0 v0, typename T1, T1 v1> \
constexpr auto operator op(meta_int<T0, v0>, meta_int<T1, v1>) \
-> meta_int<decltype(v0 op v1), (v0 op v1)> META
META_INT_BINARY_OPERATOR(+)
META_INT_BINARY_OPERATOR(-)
META_INT_BINARY_OPERATOR(*)
META_INT_BINARY_OPERATOR(/)
META_INT_BINARY_OPERATOR(%)
META_INT_BINARY_OPERATOR(&)
META_INT_BINARY_OPERATOR(|)
META_INT_BINARY_OPERATOR(==)
META_INT_BINARY_OPERATOR(!=)
//META_INT_BINARY_OPERATOR(>)
META_INT_BINARY_OPERATOR(<)
META_INT_BINARY_OPERATOR(>=)
META_INT_BINARY_OPERATOR(<=)
#undef META_INT_BINARY_OPERATOR
template <typename T0, T0 v0, typename T1, T1 v1, typename = typename std::enable_if<(v0 <= v1)>::type>
constexpr auto min(meta_int<T0, v0>, meta_int<T1, v1>) -> meta_int<T0, v0> META
template <typename T0, T0 v0, typename T1, T1 v1, typename = typename std::enable_if<(v0 > v1)>::type>
constexpr auto min(meta_int<T0, v0>, meta_int<T1, v1>) -> meta_int<T1, v1> META
template <typename T0, T0 v0, typename T1, T1 v1, typename = typename std::enable_if<(v0 >= v1)>::type>
constexpr auto max(meta_int<T0, v0>, meta_int<T1, v1>) -> meta_int<T0, v0> META
template <typename T0, T0 v0, typename T1, T1 v1, typename = typename std::enable_if<(v0 < v1)>::type>
constexpr auto max(meta_int<T0, v0>, meta_int<T1, v1>) -> meta_int<T1, v1> META
template <std::size_t Accum, char... Chars>
struct make_meta_int {
static_assert(sizeof...(Chars) == 0, "bad overload");
typedef meta_int<std::size_t, Accum> type;
};
template <std::size_t Accum, char C0, char... Chars>
struct make_meta_int<Accum, C0, Chars...> {
static_assert(C0 >= '0' && C0 <= '9', "invalid digit");
static_assert((Accum == 0 || Accum * 10 > Accum) && (Accum * 10) / 10 == Accum, "overflow detected");
static_assert(C0 != 0 || sizeof...(Chars) == 0, "hex and octal formats not supported");
typedef typename make_meta_int<Accum * 10 + std::size_t(C0 - '0'), Chars...>::type type;
};
// TODO support float and hex and octal literals?
template <char... Chars>
constexpr auto operator "" _m() -> typename make_meta_int<0, Chars...>::type META
#define META_RETURN_IF(Cond, Result) \
typename std::enable_if<decltype(Cond)::value, decltype(Result)>::type META
#define META_RETURN(Result) \
decltype(Result) META
template <typename T, T... Chars>
struct meta_string;
template <typename T, T... A, T... B>
constexpr auto operator+(meta_string<T, A...>, meta_string<T, B...>) -> meta_string<T, A..., B...> META
template <typename T, T... A, T B>
constexpr auto operator+(meta_string<T, A...>, meta_int<T, B>) -> meta_string<T, A..., B> META
template <typename T, T A, T... B>
constexpr auto operator+(meta_int<T, A>, meta_string<T, B...>) -> meta_string<T, A, B...> META
template <typename T, T... Chars>
struct meta_string {
typedef T char_type;
static constexpr std::size_t _length = sizeof...(Chars);
typedef meta_int<bool, false> False;
typedef meta_int<bool, true> True;
typedef meta_int<std::size_t, 0> Zero;
typedef meta_int<std::size_t, 1> One;
typedef meta_int<std::size_t, _length> End;
static constexpr T _data[_length] = { Chars... };
template <T C>
struct _append { typedef meta_string<T, Chars..., C> type; };
// ----
static constexpr const T * data() { return _data; }
// ----
static constexpr auto length() -> meta_int<std::size_t, _length> META
static constexpr auto size() -> META_RETURN(length())
static constexpr auto empty() -> META_RETURN(size() == 0_m)
static constexpr auto npos() -> meta_int<std::size_t, std::size_t(-1)> META
template <typename Index>
static constexpr auto at(Index) -> meta_int<T, _data[Index::value]> META
/* TODO
static constexpr auto head(Zero) -> meta_string<T> META
template <typename Length>
static constexpr auto head(Length l) -> META_RETURN_IF(
l != 0_m,
head(l - 1_m) + at(l - 1_m)
)
*/
template <std::size_t Length, typename Dummy = void>
struct _head {
typedef decltype(typename _head<Length - 1>::type() + at(meta_int<std::size_t, Length - 1>())) type;
};
template <typename Dummy>
struct _head<0, Dummy> {
typedef meta_string<T> type;
};
template <typename Length>
static constexpr auto head(Length) -> typename _head<Length::value>::type META
/* TODO
static constexpr auto tail(Zero) -> meta_string<T> META
template <typename Length>
static constexpr auto tail(Length l) -> META_RETURN_IF(
l != 0_m,
at(length() - l) + tail(l - 1_m)
)
*/
template <std::size_t Length, typename Dummy = void>
struct _tail {
typedef decltype(at(meta_int<std::size_t, length() - Length>()) + typename _tail<Length - 1>::type()) type;
};
template <typename Dummy>
struct _tail<0, Dummy> {
typedef meta_string<T> type;
};
template <typename Length>
static constexpr auto tail(Length) -> typename _tail<Length::value>::type META
// ----
// TODO s + l > length()
// TODO check 0 <= s < length()
template <typename Start, typename Length>
static constexpr auto substr(Start s, Length l = npos()) -> META_RETURN(
tail(length() - s).head(l)
)
// TODO s + l > length()
// TODO check 0 <= s < length()
template <typename Start, typename Length, typename Replacement>
static constexpr auto replace(Start s, Length l, Replacement r) -> META_RETURN(
head(s) + r + tail(length() - s - l)
)
// TODO s + l > length()
// TODO check 0 <= s < length()
template <typename Start, typename Length>
static constexpr auto erase(Start s, Length l = npos()) -> META_RETURN(
head(s) + tail(length() - s - l)
)
/*
// TODO OR NOT TODO, THAT IS THE QUESTION. check 0 <= p < length()
template <typename Pos, typename String>
static constexpr auto insert(Pos p, String s) -> META_RETURN(
replace(p, 0_m, s)
)
*/
};
template <typename T, T... Chars>
constexpr std::size_t meta_string<T, Chars...>::_length;
template <typename T, T... Chars>
constexpr T meta_string<T, Chars...>::_data[meta_string<T, Chars...>::_length];
template <char... Chars>
std::ostream & operator<<(std::ostream & os, meta_string<char, Chars...> str) {
os.write(str.data(), str.length());
return os;
}
template <typename T, T Value>
std::ostream & operator<<(std::ostream & os, meta_int<T, Value>) {
return os << Value;
}
// --------------------------------------------------------------------------
template <
typename Wrapper,
typename Prefix = meta_string<
typename std::decay<decltype(*Wrapper::value)>::type
>,
std::size_t Remaining = sizeof(Wrapper::value) / sizeof(*Wrapper::value)
>
struct to_meta_string {
private:
static constexpr std::size_t length = sizeof(Wrapper::value) / sizeof(*Wrapper::value);
typedef meta_int<typename Prefix::char_type, Wrapper::value[length - Remaining]> next_char;
public:
typedef typename to_meta_string<
Wrapper,
decltype(Prefix() + next_char()),
Remaining - 1
>::type type;
};
template <typename Wrapper, typename Prefix>
struct to_meta_string<Wrapper, Prefix, 0> {
typedef Prefix type;
};
#define STRING_WRAPPER_NAME(name) raw_ ## name ## _wrapper
#define DECLARE_STRING_WRAPPER(name, str) \
struct STRING_WRAPPER_NAME(name) { \
static constexpr char value[] = str; \
};
#define DECLARE_STRING(name, str) \
DECLARE_STRING_WRAPPER(name, str) \
static constexpr typename to_meta_string<STRING_WRAPPER_NAME(name)>::type name { };
// --------------------------------------------------------------------------
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/config/limits.hpp>
#define S_DECOMPOSE_HELPER(z, n, data) \
BOOST_PP_COMMA_IF(n) (n < sizeof(data) ? data[n] : '\0')
#define S_DECOMPOSE(STR) \
BOOST_PP_REPEAT(BOOST_PP_LIMIT_REPEAT, S_DECOMPOSE_HELPER, STR)
#define S(s) meta_string<char, S_DECOMPOSE(s)>().head(meta_int<std::size_t, sizeof(s) - 1>())
// --------------------------------------------------------------------------
#include "type_name.hpp"
DECLARE_STRING(long_string, "This string can be however long you want it to be!")
int main() {
auto str = S("Hello") + S(" ") + S("World") + S("!");
std::cout << type_name(str) << std::endl;
auto modified = str.substr(1_m, 5_m).replace(1_m, 2_m, S("?-?"));
std::cout << type_name(modified) << std::endl;
std::cout << "\"" << str << "\" \"" << modified
<< "\" = " << str.length() << " / " << BOOST_PP_LIMIT_REPEAT << std::endl;
auto mixed = long_string + S(" Or can it?");
std::cout << type_name(mixed) << std::endl;
std::cout << '"' << mixed << '"' << std::endl;
return 0;
}
| 32.171429 | 109 | 0.661412 | dscharrer |
e173c776ef723425a1104008899b2d4ecd0ae596 | 6,862 | hpp | C++ | falcon/memory/temporary_raw_storage.hpp | jonathanpoelen/falcon | 5b60a39787eedf15b801d83384193a05efd41a89 | [
"MIT"
] | 2 | 2018-02-02T14:19:59.000Z | 2018-05-13T02:48:24.000Z | falcon/memory/temporary_raw_storage.hpp | jonathanpoelen/falcon | 5b60a39787eedf15b801d83384193a05efd41a89 | [
"MIT"
] | null | null | null | falcon/memory/temporary_raw_storage.hpp | jonathanpoelen/falcon | 5b60a39787eedf15b801d83384193a05efd41a89 | [
"MIT"
] | null | null | null | #ifndef FALCON_MEMORY_TEMPORARY_RAW_STORAGE_HPP
#define FALCON_MEMORY_TEMPORARY_RAW_STORAGE_HPP
#include <falcon/type_traits/is_nothrow_swap.hpp>
#include <falcon/parameter/optimal_index_pack.hpp>
#include <falcon/parameter/parameter_pack.hpp>
#include <falcon/parameter/index_element.hpp>
#include <falcon/tuple/optimal_tuple.hpp>
#include <falcon/memory/allocate.hpp>
#include <falcon/utility/unpack.hpp>
#include <falcon/functional/arg.hpp>
#include <type_traits>
#include <memory>
#include <array>
#include <tuple>
namespace falcon {
namespace _aux {
template<class>
using usingsize__t = std::size_t;
}
/**
* Allocates storage containing \a Elements types
*/
template<class Allocator, class... Elements>
class temporary_raw_storage_with_allocator
{
typedef typename std::allocator_traits<Allocator>
::template rebind_alloc<char> internal_allocator;
typedef std::allocator_traits<internal_allocator> allocator_traits;
typedef typename allocator_traits::size_type size_type;
typedef typename allocator_traits::pointer pointer;
static constexpr bool is_noexcept()
{ return noexcept(allocator_traits::allocate(std::declval<internal_allocator&>(), size_type(0))); }
public:
typedef Allocator allocator_type;
typedef std::tuple<Elements*...> tuple_type;
typedef tuple_type type;
temporary_raw_storage_with_allocator()
noexcept(noexcept(internal_allocator()))
: t(0, tuple_type(), internal_allocator())
{}
explicit
temporary_raw_storage_with_allocator(_aux::usingsize__t<Elements>... sizes)
noexcept(temporary_raw_storage_with_allocator::is_noexcept())
: t(0, tuple_type(), internal_allocator())
{ init_(indexes(), optimal_indexes(), sizes...); }
explicit
temporary_raw_storage_with_allocator(
const allocator_type & alloc, _aux::usingsize__t<Elements>... sizes)
noexcept(temporary_raw_storage_with_allocator::is_noexcept())
: t(0, tuple_type(), internal_allocator(alloc))
{ init_(indexes(), optimal_indexes(), sizes...); }
temporary_raw_storage_with_allocator(
temporary_raw_storage_with_allocator && other) noexcept
: t(std::move(other.t))
{
get<0>(other.t) = 0;
get<1>(other.t) = tuple_type();
}
temporary_raw_storage_with_allocator &
operator=(temporary_raw_storage_with_allocator && other) noexcept
{
using std::swap;
temporary_raw_storage_with_allocator tmp(std::move(other));
swap(tmp, *this);
return *this;
}
temporary_raw_storage_with_allocator(temporary_raw_storage_with_allocator const &) = delete;
temporary_raw_storage_with_allocator&
operator=(temporary_raw_storage_with_allocator const &) = delete;
~temporary_raw_storage_with_allocator()
{ allocator_traits::deallocate(allocator_(), pointer_(), size_()); }
/**
* \return tuple on uninitialized pointers
*/
const tuple_type &
get_tuple() const noexcept
{ return get<1>(t); }
allocator_type
get_allocator() const
{ return allocator_type(allocator_()); }
explicit operator bool () const noexcept
{ return pointer_(); }
void swap(temporary_raw_storage_with_allocator & other)
noexcept(_aux::is_nothrow_swap<internal_allocator>())
{
using std::swap;
swap(get<1>(t), get<1>(other.t));
swap(get<0>(t), get<0>(other.t));
swap(get<2>(t), get<2>(other.t));
}
private:
typedef parameter_pack<Elements...> elements;
typedef build_parameter_index_t<sizeof...(Elements)> indexes;
typedef typename optimal_index_pack<elements>::type optimal_indexes;
typedef std::is_same<indexes, optimal_indexes> same;
optimal_tuple<
size_type,
tuple_type,
internal_allocator
> t;
size_type size_() const noexcept
{ return get<0>(t); }
char * pointer_() const noexcept
{ return reinterpret_cast<char*>(std::get<index_element<0, optimal_indexes>::value>(get<1>(t))); }
internal_allocator & allocator_() noexcept
{ return get<2>(t); }
template <std::size_t... Indexes, std::size_t... OptiIndexes>
void init_(
parameter_index<Indexes...>, parameter_index<OptiIndexes...>,
_aux::usingsize__t<Elements>... sizes)
noexcept(temporary_raw_storage_with_allocator::is_noexcept())
{
const char * p1 = 0;
const char * p2 = 0;
std::array<std::size_t, sizeof...(Indexes)> szs;
FALCON_UNPACK((
p2 = reinterpret_cast<char*>(reinterpret_cast<size_t>(p1 + (
std::alignment_of<typename parameter_element<OptiIndexes, elements>::type>::value - 1)
) & -std::alignment_of<typename parameter_element<OptiIndexes, elements>::type>::value),
szs[OptiIndexes] = std::size_t(p1 - static_cast<char*>(0)),
p1 = p2,
p1 += sizeof(typename parameter_element<OptiIndexes, elements>::type)
* ::falcon::arg<OptiIndexes>(size_t(sizes)...)
));
get<0>(t) = size_type(p1 - static_cast<char*>(0));
void * const p = allocator_traits::allocate(allocator_(), get<0>(t));
if (!is_noexcept() && !p) {
get<0>(t) = 0;
get<1>(t) = std::tuple<Elements*...>{static_cast<Elements*>(nullptr)...};
return ;
}
get<1>(t) = std::tuple<Elements*...>{
reinterpret_cast<Elements*>(static_cast<char*>(p) + szs[Indexes])...
};
}
};
/**
* Allocates storage containing \a Elements types
*/
template<class... Elements>
using temporary_raw_storage = temporary_raw_storage_with_allocator<std::allocator<char>, Elements...>;
template<typename... Elements, typename Allocator>
temporary_raw_storage_with_allocator<Allocator, Elements...>
make_temporary_raw_storage(const Allocator & alloc, _aux::usingsize__t<Elements>... sizes)
{ return temporary_raw_storage_with_allocator<Allocator, Elements...>(alloc, sizes...); }
template<typename... Elements>
temporary_raw_storage<Elements...>
make_temporary_raw_storage(_aux::usingsize__t<Elements>... sizes)
{ return temporary_raw_storage<Elements...>(sizes...); }
template<class T>
struct raw_element
{ size_t n; };
namespace _aux {
template<class T>
struct is_raw_element
: std::false_type
{};
template<class T>
struct is_raw_element<raw_element<T>>
: std::true_type
{};
}
template<typename... Elements, typename Allocator>
typename std::enable_if<
!_aux::is_raw_element<Allocator>::value,
temporary_raw_storage_with_allocator<Allocator, Elements...>>::type
make_temporary_raw_storage(const Allocator & alloc, raw_element<Elements>... e)
{ return temporary_raw_storage_with_allocator<Allocator, Elements...>(alloc, e.n...); }
template <typename... Elements>
temporary_raw_storage<Elements...>
make_temporary_raw_storage(raw_element<Elements>... e)
{ return temporary_raw_storage<Elements...>(e.n...); }
template<typename... Elements, typename Allocator>
void swap(
temporary_raw_storage_with_allocator<Allocator, Elements...> & a,
temporary_raw_storage_with_allocator<Allocator, Elements...> & b
) noexcept(noexcept(a.swap(b)))
{ a.swap(b); }
}
#endif
| 30.633929 | 102 | 0.728068 | jonathanpoelen |
e174e782b45278796acdfd282a235f3ca98dd3e5 | 7,861 | hpp | C++ | util.hpp | JMMackenzie/RMQV | beb9a43c6b8b07045afe847d95596f91a1b95c05 | [
"Apache-2.0"
] | 1 | 2021-07-14T07:57:04.000Z | 2021-07-14T07:57:04.000Z | util.hpp | JMMackenzie/RMQV | beb9a43c6b8b07045afe847d95596f91a1b95c05 | [
"Apache-2.0"
] | null | null | null | util.hpp | JMMackenzie/RMQV | beb9a43c6b8b07045afe847d95596f91a1b95c05 | [
"Apache-2.0"
] | 2 | 2018-06-23T16:10:32.000Z | 2018-06-27T07:21:17.000Z | #pragma once
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <locale>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sys/time.h>
#include <sys/resource.h>
#include "succinct/broadword.hpp"
#include <cilk/cilk.h>
#include <cilk/reducer_list.h>
#include <cilk/cilk_api.h>
#define DS2I_LIKELY(x) __builtin_expect(!!(x), 1)
#define DS2I_UNLIKELY(x) __builtin_expect(!!(x), 0)
#define DS2I_NOINLINE __attribute__((noinline))
#define DS2I_ALWAYSINLINE __attribute__((always_inline))
#if defined(__GNUC__) && !defined(__clang__)
#define DS2I_FLATTEN_FUNC __attribute__((always_inline,flatten))
#else
# define DS2I_FLATTEN_FUNC DS2I_ALWAYSINLINE
#endif
void output_trec(const std::vector<std::pair<double, uint64_t>>& top_k,
uint32_t topic_id,
std::vector<std::string>& id_map,
std::string const &query_type,
std::ofstream& output) {
for (size_t n = 0; n < top_k.size(); ++n) {
output << topic_id << " "
<< "Q0" << " "
<< id_map[top_k[n].second] << " "
<< n+1 << " "
<< top_k[n].first << " "
<< query_type << std::endl;
}
}
namespace ds2i {
// Cilk
void init_threads(int32_t threads) {
// Set the number of threads
if (threads > 0) {
__cilkrts_set_param("nworkers", std::to_string(threads).c_str());
std::cerr << "Using up to " << threads << " threads." << std::endl;
}
// Just do something to get the workers spawned
cilk_for (size_t i = 0; i < 10000; ++i) {
size_t x = 5;
x = x * 10;
}
}
inline uint64_t ceil_log2(const uint64_t x) {
assert(x > 0);
return (x > 1) ? succinct::broadword::msb(x - 1) + 1 : 0;
}
inline std::ostream& logger()
{
time_t t = std::time(nullptr);
// XXX(ot): put_time unsupported in g++ 4.7
// return std::cerr
// << std::put_time(std::localtime(&t), "%F %T")
// << ": ";
std::locale loc;
const std::time_put<char>& tp =
std::use_facet<std::time_put<char>>(loc);
const char *fmt = "%F %T";
tp.put(std::cerr, std::cerr, ' ',
std::localtime(&t), fmt, fmt + strlen(fmt));
return std::cerr << ": ";
}
inline double get_time_usecs() {
timeval tv;
gettimeofday(&tv, NULL);
return double(tv.tv_sec) * 1000000 + double(tv.tv_usec);
}
inline double get_user_time_usecs() {
rusage ru;
getrusage(RUSAGE_SELF, &ru);
return double(ru.ru_utime.tv_sec) * 1000000 + double(ru.ru_utime.tv_usec);
}
// stolen from folly
template <class T>
inline void do_not_optimize_away(T&& datum) {
asm volatile("" : "+r" (datum));
}
template<typename T>
struct has_next_geq
{
template<typename Fun> struct sfinae {};
template<typename U> static char test(sfinae<decltype(U::has_next)>);
template<typename U> static int test(...);
enum { value = sizeof(test<T>(0)) == sizeof(char) };
};
// A more powerful version of boost::function_input_iterator that also works
// with lambdas.
//
// Important: the functors must be stateless, otherwise the behavior is
// undefined.
template <typename State, typename AdvanceFunctor, typename ValueFunctor>
class function_iterator
: public std::iterator<std::forward_iterator_tag,
typename std::result_of<ValueFunctor(State)>::type> {
public:
function_iterator()
{}
function_iterator(State initial_state)
: m_state(initial_state)
{}
friend inline
void swap(function_iterator& lhs, function_iterator& rhs)
{
using std::swap;
swap(lhs.m_state, rhs.m_state);
}
// XXX why isn't this inherited from std::iterator?
typedef typename std::result_of<ValueFunctor(State)>::type value_type;
value_type operator*() const
{
// XXX I do not know if this trick is legal for stateless lambdas,
// but it seems to work on GCC and Clang
return (*static_cast<ValueFunctor*>(nullptr))(m_state);
}
function_iterator& operator++()
{
(*static_cast<AdvanceFunctor*>(nullptr))(m_state);
return *this;
}
function_iterator operator++(int)
{
function_iterator it(*this);
operator++();
return it;
}
bool operator==(function_iterator const& other) const
{
return m_state == other.m_state;
}
bool operator!=(function_iterator const& other) const
{
return !(*this == other);
}
private:
State m_state;
};
template <typename State, typename AdvanceFunctor, typename ValueFunctor>
function_iterator<State, AdvanceFunctor, ValueFunctor>
make_function_iterator(State initial_state, AdvanceFunctor, ValueFunctor)
{
return function_iterator<State, AdvanceFunctor, ValueFunctor>(initial_state);
}
struct stats_line {
stats_line()
: first(true)
{
std::cout << "{";
}
~stats_line()
{
std::cout << "}" << std::endl;
}
template <typename K, typename T>
stats_line& operator()(K const& key, T const& value)
{
if (!first) {
std::cout << ", ";
} else {
first = false;
}
emit(key);
std::cout << ": ";
emit(value);
return *this;
}
template <typename T>
stats_line& operator()(T const& obj)
{
return obj.dump(*this);
}
private:
template <typename T>
void emit(T const& v) const
{
std::cout << v;
}
// XXX properly escape strings
void emit(const char* s) const
{
std::cout << '"' << s << '"';
}
void emit(std::string const& s) const
{
emit(s.c_str());
}
template <typename T>
void emit(std::vector<T> const& v) const
{
std::cout << "[";
bool first = true;
for (auto const& i: v) {
if (first) {
first = false;
} else {
std::cout << ", ";
}
emit(i);
}
std::cout << "]";
}
template <typename K, typename V>
void emit(std::map<K, V> const& m) const
{
std::vector<std::pair<K, V>> v(m.begin(), m.end());
emit(v);
}
template <typename Tuple, size_t Pos>
typename std::enable_if<Pos != 0, void>::type
emit_tuple_helper(Tuple const& t) const
{
emit_tuple_helper<Tuple, Pos - 1>(t);
std::cout << ", ";
emit(std::get<Pos>(t));
}
template <typename Tuple, size_t Pos>
typename std::enable_if<Pos == 0, void>::type
emit_tuple_helper(Tuple const& t) const
{
emit(std::get<0>(t));
}
template <typename ...Tp>
void emit(std::tuple<Tp...> const& t) const
{
std::cout << "[";
emit_tuple_helper<std::tuple<Tp...>, sizeof...(Tp) - 1>(t);
std::cout << "]";
}
template <typename T1, typename T2>
void emit(std::pair<T1, T2> const& p) const
{
emit(std::make_tuple(p.first, p.second));
}
bool first;
};
}
| 26.379195 | 85 | 0.525378 | JMMackenzie |
e175c0a2812552923483fb967bc771e735d70fab | 478 | cpp | C++ | modules/logic/src/Logic/Itk/ImageToImageFilter/gmLogicItkBinaryFillholeImageFilter.cpp | GraphMIC/GraphMIC | 8fc2aeb0143ee1292c6757f010fc9e8c68823e2b | [
"BSD-3-Clause"
] | 43 | 2016-04-11T11:34:05.000Z | 2022-03-31T03:37:57.000Z | modules/logic/src/Logic/Itk/ImageToImageFilter/gmLogicItkBinaryFillholeImageFilter.cpp | kevinlq/GraphMIC | 8fc2aeb0143ee1292c6757f010fc9e8c68823e2b | [
"BSD-3-Clause"
] | 1 | 2016-05-17T12:58:16.000Z | 2016-05-17T12:58:16.000Z | modules/logic/src/Logic/Itk/ImageToImageFilter/gmLogicItkBinaryFillholeImageFilter.cpp | kevinlq/GraphMIC | 8fc2aeb0143ee1292c6757f010fc9e8c68823e2b | [
"BSD-3-Clause"
] | 14 | 2016-05-13T20:23:16.000Z | 2021-12-20T10:33:19.000Z | #include "gmLogicItkBinaryFillholeImageFilter.hpp"
namespace gm
{
namespace Logic
{
namespace Itk
{
auto BinaryFillholeImageFilter::Register =
Logic::Register<BinaryFillholeImageFilter>("itk",
"BinaryFillholeImageFilter",
"http://www.itk.org/Doxygen/html/classitk_1_1BinaryFillholeImageFilter.html");
}
}
}
| 29.875 | 133 | 0.523013 | GraphMIC |
e176cf6370f8450640b2c33c43251f132486bb13 | 2,058 | hpp | C++ | include/Pomdog/Graphics/IndexBuffer.hpp | bis83/pomdog | 133a9262958d539ae6d93664e6cb2207b5b6c7ff | [
"MIT"
] | null | null | null | include/Pomdog/Graphics/IndexBuffer.hpp | bis83/pomdog | 133a9262958d539ae6d93664e6cb2207b5b6c7ff | [
"MIT"
] | null | null | null | include/Pomdog/Graphics/IndexBuffer.hpp | bis83/pomdog | 133a9262958d539ae6d93664e6cb2207b5b6c7ff | [
"MIT"
] | null | null | null | // Copyright (c) 2013-2015 mogemimi.
// Distributed under the MIT license. See LICENSE.md file for details.
#ifndef POMDOG_INDEXBUFFER_4119FC34_HPP
#define POMDOG_INDEXBUFFER_4119FC34_HPP
#include "detail/ForwardDeclarations.hpp"
#include "BufferUsage.hpp"
#include "IndexElementSize.hpp"
#include "Pomdog/Basic/Export.hpp"
#include <cstddef>
#include <memory>
namespace Pomdog {
class POMDOG_EXPORT IndexBuffer {
public:
IndexBuffer() = delete;
IndexBuffer(IndexBuffer const&) = delete;
IndexBuffer(IndexBuffer &&) = default;
IndexBuffer(GraphicsDevice & graphicsDevice,
IndexElementSize elementSize,
void const* indices, std::size_t indexCount,
Pomdog::BufferUsage bufferUsage);
IndexBuffer(GraphicsDevice & graphicsDevice,
IndexElementSize elementSize, std::size_t indexCount,
Pomdog::BufferUsage bufferUsage);
IndexBuffer(std::shared_ptr<GraphicsDevice> const& graphicsDevice,
IndexElementSize elementSize,
void const* indices, std::size_t indexCount,
Pomdog::BufferUsage bufferUsage);
IndexBuffer(std::shared_ptr<GraphicsDevice> const& graphicsDevice,
IndexElementSize elementSize, std::size_t indexCount,
Pomdog::BufferUsage bufferUsage);
~IndexBuffer();
IndexBuffer & operator=(IndexBuffer const&) = delete;
IndexBuffer & operator=(IndexBuffer &&) = default;
std::size_t IndexCount() const noexcept;
IndexElementSize ElementSize() const noexcept;
std::size_t SizeInBytes() const noexcept;
Pomdog::BufferUsage BufferUsage() const noexcept;
void SetData(void const* source, std::size_t elementCount);
void SetData(std::size_t offsetInBytes,
void const* source, std::size_t elementCount);
public:
Detail::NativeBuffer* NativeIndexBuffer();
private:
std::unique_ptr<Detail::NativeBuffer> nativeIndexBuffer;
std::uint32_t indexCount;
IndexElementSize elementSize;
Pomdog::BufferUsage bufferUsage;
};
} // namespace Pomdog
#endif // POMDOG_INDEXBUFFER_4119FC34_HPP
| 28.985915 | 70 | 0.735666 | bis83 |
e176db4c7036137ce3bf3e8ba877d53e30feb7a4 | 2,184 | cpp | C++ | adaptors/x11/key-grab-x.cpp | pwisbey/dali-adaptor | 21d5e77316e53285fa1e210a93b13cf9889e3b54 | [
"Apache-2.0"
] | null | null | null | adaptors/x11/key-grab-x.cpp | pwisbey/dali-adaptor | 21d5e77316e53285fa1e210a93b13cf9889e3b54 | [
"Apache-2.0"
] | null | null | null | adaptors/x11/key-grab-x.cpp | pwisbey/dali-adaptor | 21d5e77316e53285fa1e210a93b13cf9889e3b54 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* 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.
*
*/
// CLASS HEADER
#include <key-grab.h>
// EXTERNAL INCLUDES
#include <Ecore_X.h>
#include <utilX.h>
// INTERNAL INCLUDES
#include <window.h>
#include <key-impl.h>
#include <ecore-x-types.h>
namespace Dali
{
namespace KeyGrab
{
bool GrabKeyTopmost( Window window, Dali::KEY daliKey )
{
return GrabKey( window, daliKey, TOPMOST);
}
bool UngrabKeyTopmost( Window window, Dali::KEY daliKey )
{
return UngrabKey( window, daliKey );
}
bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode )
{
int xGrabMode;
if( grabMode == TOPMOST )
{
xGrabMode = TOP_POSITION_GRAB;
}
else if( grabMode == SHARED )
{
xGrabMode = SHARED_GRAB;
}
else if( grabMode == OVERRIDE_EXCLUSIVE )
{
xGrabMode = OR_EXCLUSIVE_GRAB;
}
else if( grabMode == EXCLUSIVE )
{
xGrabMode = EXCLUSIVE_GRAB;
}
else
{
return false;
}
int ret = utilx_grab_key ( static_cast<Display*>( ecore_x_display_get() ),
static_cast<XWindow>( AnyCast<Ecore_X_Window>( window.GetNativeHandle() ) ),
Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKey ), xGrabMode );
return ret==0;
}
bool UngrabKey( Window window, Dali::KEY daliKey )
{
int ret = utilx_ungrab_key ( static_cast<Display*>( ecore_x_display_get() ),
static_cast<XWindow>( AnyCast<Ecore_X_Window>( window.GetNativeHandle() ) ),
Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKey ) );
return ret==0;
}
} // namespace KeyGrab
} // namespace Dali
| 24.539326 | 107 | 0.668498 | pwisbey |
e1775d18f3911889348cfc235cc56655b7247163 | 2,571 | cpp | C++ | Trees/bt-to-cll.cpp | divyanshu013/algorithm-journey | 8dc32daa732f16099da148bb8669778d4ef3172a | [
"MIT"
] | null | null | null | Trees/bt-to-cll.cpp | divyanshu013/algorithm-journey | 8dc32daa732f16099da148bb8669778d4ef3172a | [
"MIT"
] | null | null | null | Trees/bt-to-cll.cpp | divyanshu013/algorithm-journey | 8dc32daa732f16099da148bb8669778d4ef3172a | [
"MIT"
] | null | null | null | /*******************************************************************************
BT to CLL
=========
Ref - http://www.geeksforgeeks.org/convert-a-binary-tree-to-a-circular-doubly-link-list/
--------------------------------------------------------------------------------
Problem
=======
1) Write a general purpose function that concatenates two given circular doubly lists (This function is explained below).
2) Now traverse the given tree
a) Recursively convert left subtree to a circular DLL. Let the converted list be leftList.
b) Recursively convert right subtree to a circular DLL. Let the converted list be rightList.
c) Make a circular linked list of root of the tree, make left and right of root to point to itself.
d) Concatenate leftList with list of single root node.
e) Concatenate the list produced in step above (d) with rightList.
--------------------------------------------------------------------------------
Time Complexity
===============
O(n)
--------------------------------------------------------------------------------
Output
======
10 -> 20 -> 30 -> 40 -> 50
*******************************************************************************/
#include <stdio.h>
struct Node {
int data;
Node *left;
Node *right;
};
struct Node * getNode(int data) {
Node *newNode = new Node();
newNode->data = data;
newNode->left = newNode->right = NULL;
return newNode;
}
void printList(Node *head) {
Node *temp = head;
do {
printf("%d -> ", temp->data);
temp = temp->right;
} while(temp != head);
printf("\b\b\b \n");
}
struct Node * concatenate(Node *leftList, Node *rightList) {
// if either list is empty return the other
if(!leftList)
return rightList;
if(!rightList)
return leftList;
Node *leftLast = leftList->left;
Node *rightLast = rightList->left;
leftLast->right = rightList;
rightList->left = leftLast;
rightLast->right = leftList;
leftList->left = rightLast;
return leftList;
}
struct Node * toCLL(Node *root) {
if(root) {
Node *left = toCLL(root->left);
Node *right = toCLL(root->right);
root->left = root->right = root;
return concatenate(concatenate(left, root), right);
}
return root; // if NULL
}
int main() {
/* BST
40
/ \
20 50
/ \
10 30 */
Node *root = getNode(40);
root->left = getNode(20);
root->right = getNode(50);
root->left->left = getNode(10);
root->left->right = getNode(30);
root = toCLL(root);
printList(root);
return 0;
}
| 23.805556 | 121 | 0.5317 | divyanshu013 |
e177b28d664c3aba0cd9be17036da5d2ac71e052 | 4,187 | cpp | C++ | src/core/utility/GameSpeedController.cpp | Robograde/Robograde | 2c9a7d0b8250ec240102d504127f5c54532cb2b0 | [
"Zlib"
] | 5 | 2015-10-11T10:22:39.000Z | 2019-07-24T10:09:13.000Z | src/core/utility/GameSpeedController.cpp | Robograde/Robograde | 2c9a7d0b8250ec240102d504127f5c54532cb2b0 | [
"Zlib"
] | null | null | null | src/core/utility/GameSpeedController.cpp | Robograde/Robograde | 2c9a7d0b8250ec240102d504127f5c54532cb2b0 | [
"Zlib"
] | null | null | null | /**************************************************
Copyright 2015 Daniel "MonzUn" Bengtsson
***************************************************/
#include "GameSpeedController.h"
#include "../CompileFlags.h"
#include <network/NetworkInfo.h>
#include <utility/Logger.h>
#include <input/Input.h>
#include <input/KeyBindings.h>
#include <messaging/GameMessages.h>
#include "GameData.h"
#include "GameModeSelector.h"
#include "../subsystem/utility/SSMail.h"
#include "../subsystem/menu/SSInGameMenu.h"
#include "../utility/PlayerData.h"
#include "../subsystem/input/SSKeyBinding.h"
#define AUTO_DEBUG_SPEED_MULTIPLIER 3
GameSpeedController& GameSpeedController::GetInstance( )
{
static GameSpeedController instance;
return instance;
}
void GameSpeedController::Startup()
{
if ( g_GameModeSelector.GetCurrentGameMode().Type == GameModeType::AIOnly )
for ( int i = 0; i < AUTO_DEBUG_SPEED_MULTIPLIER; ++i )
IncreaseSpeed();
DEV(
g_Script.Register( "ToggleUserLayer", [&] ( IScriptEngine* ) -> int { ToggleUserLayer(); return 0; } );
);
g_Script.Register( "ToggleSimLayer", [&] ( IScriptEngine* ) -> int { ToggleSimLayer(); return 0; } );
}
void GameSpeedController::Update()
{
DEV(
const GameMode& currentGameMode = g_GameModeSelector.GetCurrentGameMode();
if ( currentGameMode.IsSimulation && !g_GameData.IsDedicatedServer() )
{
if ( g_SSKeyBinding.ActionUpDown( ACTION_INCREASE_SIMULATION_RATE ) )
IncreaseSpeed();
else if ( g_SSKeyBinding.ActionUpDown( ACTION_DECREASE_SIMULATION_RATE ) )
DecreaseSpeed();
}
if ( g_SSKeyBinding.ActionDownUp( ACTION_TOGGLE_USER_LAYER ) )
ToggleUserLayer();
);
}
void GameSpeedController::Reset()
{
m_AccumulatedTicks = 0;
m_UpdateCount = 0;
m_UserLayerActive = true;
m_SimLayerActive = true;
m_Gamestarted = false;
m_TicksPerFrame = m_TicksPerSecond / DEFAULT_SIMULATION_RATE;
}
bool GameSpeedController::ShouldUpdateUserLayer() const
{
return m_UserLayerActive;
}
bool GameSpeedController::ShouldUpdateSimLayer( const GameTimer::DeltaTimeInfo& deltaTimeInfo )
{
bool toReturn = false;
if ( m_SimLayerActive && m_Gamestarted )
{
GameMode gameMode = g_GameModeSelector.GetCurrentGameMode();
if ( gameMode.IsSimulation )
{
if ( !gameMode.IsNetworked || g_NetworkInfo.AmIHost() )
{
if ( m_UpdateCount > 2 ) // The first two deltaticks are bad since one is from the menu and the second is from loading screen
m_AccumulatedTicks += deltaTimeInfo.DeltaTicks;
++m_UpdateCount;
if ( m_AccumulatedTicks >= m_TicksPerFrame ) // If it is time to take another step
{
m_AccumulatedTicks -= m_TicksPerFrame;
toReturn = true;
}
}
else if ( g_NetworkInfo.DecrementFramesToRun() ) // If host say we can run a frame
toReturn = true;
}
}
return toReturn;
}
bool GameSpeedController::GetUserLayerActive() const
{
return m_UserLayerActive;
}
bool GameSpeedController::GetSimLayerActive() const
{
return m_SimLayerActive;
}
bool GameSpeedController::GetGamestarted() const
{
return m_Gamestarted;
}
void GameSpeedController::SetUserLayerActive( bool shouldRunUserLayer )
{
m_UserLayerActive = shouldRunUserLayer;
}
void GameSpeedController::SetSimLayerActive( bool shouldRunSimLayer )
{
m_SimLayerActive = shouldRunSimLayer;
}
void GameSpeedController::SetGameStarted( bool gameStarted )
{
m_Gamestarted = gameStarted;
}
void GameSpeedController::ToggleUserLayer()
{
m_UserLayerActive = !m_UserLayerActive;
}
void GameSpeedController::ToggleSimLayer()
{
m_SimLayerActive = !m_SimLayerActive;
}
void GameSpeedController::IncreaseSpeed( )
{
if ( m_TicksPerSecond / m_TicksPerFrame < 920U )
{
m_TicksPerFrame = m_TicksPerFrame >> 1; // Division by 2
Logger::Log( "Game speed was increased to " + rToString( m_TicksPerSecond / m_TicksPerFrame ) + " FPS", "GameSpeedController", LogSeverity::INFO_MSG );
}
}
void GameSpeedController::DecreaseSpeed( )
{
if ( m_TicksPerSecond / m_TicksPerFrame > 1 )
{
m_TicksPerFrame = m_TicksPerFrame << 1; // Multiplication with 2
Logger::Log( "Game speed was decreased to " + rToString( m_TicksPerSecond / m_TicksPerFrame ) + " FPS", "GameSpeedController", LogSeverity::INFO_MSG );
}
}
| 26.839744 | 153 | 0.726057 | Robograde |
e179c530e46c90bdbb21f32910c46bb107ec18e4 | 8,359 | cpp | C++ | Samples/Logging/cpp/Scenario2.xaml.cpp | CrZGerry/Windows-universal-samples | 2fbdfea60458ab5c915083de9979f5668e676acb | [
"MIT"
] | 2 | 2018-12-25T14:44:11.000Z | 2020-05-25T08:41:59.000Z | Samples/Logging/cpp/Scenario2.xaml.cpp | CrZGerry/Windows-universal-samples | 2fbdfea60458ab5c915083de9979f5668e676acb | [
"MIT"
] | null | null | null | Samples/Logging/cpp/Scenario2.xaml.cpp | CrZGerry/Windows-universal-samples | 2fbdfea60458ab5c915083de9979f5668e676acb | [
"MIT"
] | 2 | 2020-07-13T03:05:00.000Z | 2021-08-11T15:16:12.000Z | //*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "Scenario2.xaml.h"
using namespace SDKTemplate;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace concurrency;
Scenario2::Scenario2()
{
// This sample UI is interested in events from
// the LoggingSessionScenario class so the UI can be updated.
LoggingScenario->StatusChanged += ref new StatusChangedHandler(this, &Scenario2::OnStatusChanged);
InitializeComponent();
}
void Scenario2::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e)
{
UpdateControls();
}
Windows::UI::Xaml::Controls::ScrollViewer^ Scenario2::FindScrollViewer(DependencyObject^ depObject)
{
if (depObject == nullptr)
{
return nullptr;
}
int countThisLevel = Windows::UI::Xaml::Media::VisualTreeHelper::GetChildrenCount(depObject);
if (countThisLevel <= 0)
{
return nullptr;
}
for (int childIndex = 0; childIndex < countThisLevel; childIndex++)
{
DependencyObject^ childDepObject = Windows::UI::Xaml::Media::VisualTreeHelper::GetChild(depObject, childIndex);
ScrollViewer^ sv = dynamic_cast<ScrollViewer^>(childDepObject);
if (sv != nullptr)
{
return sv;
}
sv = FindScrollViewer(childDepObject);
if (sv != nullptr)
{
return sv;
}
}
return nullptr;
}
// Add a message to the UI control which displays status while the sample is running.
void Scenario2::AddMessage(Platform::String^ message)
{
Platform::String^ messageToAdd = "";
messageToAdd += message;
messageToAdd += "\r\n";
StatusMessageList->Text += messageToAdd;
StatusMessageList->Select(StatusMessageList->Text->Length(), 0);
ScrollViewer^ sv = FindScrollViewer(StatusMessageList);
if (sv != nullptr)
{
sv->ChangeView(nullptr, StatusMessageList->ActualHeight, nullptr);
}
}
// Call AddMessage on the UI thread.
task<void> Scenario2::AddMessageDispatch(Platform::String^ message)
{
return create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]() {
AddMessage(message);
})));
}
// AddLogFileMessageDispatch updates the UI with status information when
// a new log file is created.
task<void> Scenario2::AddLogFileMessageDispatch(Platform::String^ message, const std::wstring& logFileFullPath)
{
return create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]() {
// On the UI thread...
Platform::String^ finalMessage;
if (!logFileFullPath.empty())
{
// Add a message to the UI indicating a new log file was created.
Platform::String^ path = ref new Platform::String(logFileFullPath.c_str());
Platform::String^ directoryName;
Platform::String^ fileName;
std::wstring::size_type posLastSlash = logFileFullPath.find_last_of(L'\\');
if (posLastSlash > 0 && posLastSlash < logFileFullPath.size() - 1)
{
directoryName = ref new Platform::String(logFileFullPath.substr(0, posLastSlash).c_str());
fileName = ref new Platform::String(logFileFullPath.substr(posLastSlash + 1, logFileFullPath.size() - (posLastSlash + 1)).c_str());
}
else
{
directoryName = "";
fileName = "";
}
finalMessage = message + ": " + fileName;
finalMessage = message + ": " + fileName;
ViewLogInfo->Text =
"Log folder: \"" + directoryName + "\"\r\n" +
"- To view with tracerpt: tracerpt.exe \"" + path + "\" -of XML -o LogFile.xml\r\n" +
"- To view with Windows Performance Toolkit (WPT): wpa.exe \"" + path + "\"";
}
else
{
finalMessage = message + ": none, nothing logged since saving the last file.";
}
AddMessage(finalMessage);
})));
}
void Scenario2::OnStatusChanged(Platform::Object^ sender, LoggingScenarioEventArgs^ e)
{
if (e->Type == LoggingScenarioEventType::BusyStatusChanged)
{
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]() {
UpdateControls();
})));
}
else if (e->Type == LoggingScenarioEventType::LogFileGenerated)
{
AddLogFileMessageDispatch("LogFileGenerated", e->LogFileFullPath).then([]() {
});
}
else if (e->Type == LoggingScenarioEventType::LoggingEnabledDisabled)
{
Platform::String^ message = "Logging has been " + (e->Enabled ? "enabled" : "disabled") + ".";
AddMessageDispatch(message);
}
}
void Scenario2::UpdateControls()
{
if (LoggingScenario->LoggingEnabled)
{
InputTextBlock1->Text = "Logging is enabled. Click 'Disable Logging' to disable logging. With logging enabled, you can click 'Log Messages' to use the logging API to generate log files.";
EnableDisableLoggingButton->Content = "Disable Logging";
if (LoggingScenario->IsBusy)
{
EnableDisableLoggingButton->IsEnabled = false;
DoScenarioButton->IsEnabled = false;
}
else
{
EnableDisableLoggingButton->IsEnabled = true;
DoScenarioButton->IsEnabled = true;
}
}
else
{
InputTextBlock1->Text = "Logging is disabled. Click 'Enable Logging' to enable logging. After you enable logging you can click 'Log Messages' to use the logging API to generate log files.";
EnableDisableLoggingButton->Content = "Enable Logging";
DoScenarioButton->IsEnabled = false;
if (LoggingScenario->IsBusy)
{
EnableDisableLoggingButton->IsEnabled = false;
}
else
{
EnableDisableLoggingButton->IsEnabled = true;
}
}
}
// Enabled/disabled logging.
void Scenario2::EnableDisableLogging(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
if (LoggingScenario->LoggingEnabled)
{
MainPage::Current->NotifyUser("Disabling logging...", NotifyType::StatusMessage);
}
else
{
MainPage::Current->NotifyUser("Enabling logging...", NotifyType::StatusMessage);
}
LoggingScenario->ToggleLoggingEnabledDisabled();
UpdateControls();
if (this->LoggingScenario->LoggingEnabled)
{
MainPage::Current->NotifyUser("Logging enabled.", NotifyType::StatusMessage);
}
else
{
MainPage::Current->NotifyUser("Logging disabled.", NotifyType::StatusMessage);
}
}
// Run a sample scenario which logs lots of messages to produce several log files.
void Scenario2::DoScenario(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
DoScenarioButton->IsEnabled = false;
MainPage::Current->NotifyUser("Scenario running...", NotifyType::StatusMessage);
// Allow the UI to update...
create_task(DoScenarioButton->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]() {}))).then([this]()
{
// Run the scenario asynchronously.
return LoggingScenario->DoScenarioAsync();
}).then([this](task<void> previousTask) {
// After the scenario completes, re-enable UI controls and display a message.
DoScenarioButton->IsEnabled = true;
MainPage::Current->NotifyUser("Scenario finished.", NotifyType::StatusMessage);
}, task_continuation_context::use_current());
}
| 36.502183 | 198 | 0.622682 | CrZGerry |
e17b225c8e5702d41477ae85700a1f6b97cd26ca | 405 | cpp | C++ | Tutorials/Particles/ElectromagneticPIC/NodalFlags.cpp | wolfram-schmidt/amrex | 88120db4736c325a2d3d2c291adacaffd3bf224b | [
"BSD-3-Clause-LBNL"
] | null | null | null | Tutorials/Particles/ElectromagneticPIC/NodalFlags.cpp | wolfram-schmidt/amrex | 88120db4736c325a2d3d2c291adacaffd3bf224b | [
"BSD-3-Clause-LBNL"
] | null | null | null | Tutorials/Particles/ElectromagneticPIC/NodalFlags.cpp | wolfram-schmidt/amrex | 88120db4736c325a2d3d2c291adacaffd3bf224b | [
"BSD-3-Clause-LBNL"
] | null | null | null | #include "NodalFlags.H"
using namespace amrex;
IntVect YeeGrid::Bx_nodal_flag(1,0,0);
IntVect YeeGrid::By_nodal_flag(0,1,0);
IntVect YeeGrid::Bz_nodal_flag(0,0,1);
IntVect YeeGrid::Ex_nodal_flag(0,1,1);
IntVect YeeGrid::Ey_nodal_flag(1,0,1);
IntVect YeeGrid::Ez_nodal_flag(1,1,0);
IntVect YeeGrid::jx_nodal_flag(0,1,1);
IntVect YeeGrid::jy_nodal_flag(1,0,1);
IntVect YeeGrid::jz_nodal_flag(1,1,0);
| 25.3125 | 41 | 0.758025 | wolfram-schmidt |
e17c213349bea46063ef177b7b0016bda77f9e5b | 2,187 | cpp | C++ | example/gherkin.cpp | ambushed/ut | 248df4dd091781b45b2cde7332774226d6a459b3 | [
"BSL-1.0"
] | 567 | 2020-06-30T20:16:52.000Z | 2022-03-31T21:22:41.000Z | example/gherkin.cpp | ambushed/ut | 248df4dd091781b45b2cde7332774226d6a459b3 | [
"BSL-1.0"
] | 85 | 2020-07-01T02:21:03.000Z | 2022-03-27T22:12:35.000Z | example/gherkin.cpp | ambushed/ut | 248df4dd091781b45b2cde7332774226d6a459b3 | [
"BSL-1.0"
] | 63 | 2020-07-08T06:47:30.000Z | 2022-03-27T15:08:34.000Z | //
// Copyright (c) 2019-2020 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/ut.hpp>
#include <fstream>
#include <numeric>
#include <streambuf>
#include <string>
template <class T>
class calculator {
public:
auto enter(const T& value) -> void { values_.push_back(value); }
auto add() -> void {
result_ = std::accumulate(std::cbegin(values_), std::cend(values_), T{});
}
auto sub() -> void {
result_ = std::accumulate(std::cbegin(values_) + 1, std::cend(values_),
values_.front(), std::minus{});
}
auto get() const -> T { return result_; }
private:
std::vector<T> values_{};
T result_{};
};
int main(int argc, const char** argv) {
using namespace boost::ut;
bdd::gherkin::steps steps = [](auto& steps) {
steps.feature("Calculator") = [&] {
steps.scenario("*") = [&] {
steps.given("I have calculator") = [&] {
calculator<int> calc{};
steps.when("I enter {value}") = [&](int value) { calc.enter(value); };
steps.when("I press add") = [&] { calc.add(); };
steps.when("I press sub") = [&] { calc.sub(); };
steps.then("I expect {value}") = [&](int result) {
expect(that % calc.get() == result);
};
};
};
};
};
// clang-format off
"Calculator"_test = steps |
R"(
Feature: Calculator
Scenario: Addition
Given I have calculator
When I enter 40
When I enter 2
When I press add
Then I expect 42
Scenario: Subtraction
Given I have calculator
When I enter 4
When I enter 2
When I press sub
Then I expect 2
)";
// clang-format on
if (argc == 2) {
const auto file = [](const auto path) {
std::ifstream file{path};
return std::string{(std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>()};
};
"Calculator"_test = steps | file(argv[1]);
}
}
| 26.670732 | 80 | 0.551898 | ambushed |
e17e2044fdb9cd1c4922361e662f1ec7098c4e1e | 6,500 | hh | C++ | parsing.hh | KholdStare/qnd-integer-parsing-experiments | bf8598affb9754e7ba797b4056e145b296a81fdf | [
"BSL-1.0"
] | 33 | 2020-05-26T21:06:53.000Z | 2021-09-29T13:04:22.000Z | parsing.hh | KholdStare/qnd-integer-parsing-experiments | bf8598affb9754e7ba797b4056e145b296a81fdf | [
"BSL-1.0"
] | 8 | 2020-05-27T04:20:11.000Z | 2020-08-24T10:43:09.000Z | parsing.hh | KholdStare/qnd-integer-parsing-experiments | bf8598affb9754e7ba797b4056e145b296a81fdf | [
"BSL-1.0"
] | 2 | 2020-06-07T12:25:54.000Z | 2020-06-28T05:51:06.000Z | #pragma once
#include <iostream>
#include <iomanip>
#include <charconv>
#include <cstring>
#include <ios>
#include <bitset>
#ifdef QND_TEST_BOOST
#include <boost/spirit/include/qi.hpp>
#endif
#include <immintrin.h>
inline std::uint64_t parse_char_conv(std::string_view s) noexcept
{
std::uint64_t result = 0;
std::from_chars(s.data(), s.data() + s.size(), result);
return result;
}
#ifdef QND_TEST_BOOST
inline std::uint64_t parse_qi(std::string_view s) noexcept
{
using boost::spirit::qi::parse;
std::uint64_t result = 0;
parse(s.data(), s.data() + s.size(), result);
return result;
}
#endif
inline std::uint64_t parse_naive(std::string_view s) noexcept
{
std::uint64_t result = 0;
for(char digit : s)
{
result *= 10;
result += digit - '0';
}
return result;
}
inline std::uint64_t parse_unrolled(std::string_view s) noexcept
{
std::uint64_t result = 0;
result += (s[0] - '0') * 1000000000000000ULL;
result += (s[1] - '0') * 100000000000000ULL;
result += (s[2] - '0') * 10000000000000ULL;
result += (s[3] - '0') * 1000000000000ULL;
result += (s[4] - '0') * 100000000000ULL;
result += (s[5] - '0') * 10000000000ULL;
result += (s[6] - '0') * 1000000000ULL;
result += (s[7] - '0') * 100000000ULL;
result += (s[8] - '0') * 10000000ULL;
result += (s[9] - '0') * 1000000ULL;
result += (s[10] - '0') * 100000ULL;
result += (s[11] - '0') * 10000ULL;
result += (s[12] - '0') * 1000ULL;
result += (s[13] - '0') * 100ULL;
result += (s[14] - '0') * 10ULL;
result += (s[15] - '0');
return result;
}
inline std::uint64_t assemble_from_128i(__m128i chunk) noexcept
{
{
const auto mult = _mm_set_epi8(1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10);
chunk = _mm_maddubs_epi16(chunk, mult);
}
{
const auto mult = _mm_set_epi16(1, 100, 1, 100, 1, 100, 1, 100);
chunk = _mm_madd_epi16(chunk, mult);
}
{
chunk = _mm_packus_epi32(chunk, chunk);
const auto mult = _mm_set_epi16(0, 0, 0, 0, 1, 10000, 1, 10000);
chunk = _mm_madd_epi16(chunk, mult);
}
return ((chunk[0] & 0xffffffff) * 100000000) + (chunk[0] >> 32);
}
inline std::uint64_t parse_16_chars(const char* string) noexcept
{
auto chunk = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(string));
auto zeros = _mm_set1_epi8('0');
chunk = chunk - zeros;
return assemble_from_128i(chunk);
}
inline std::uint64_t parse_8_chars(const char* string) noexcept
{
std::uint64_t chunk = 0;
std::memcpy(&chunk, string, sizeof(chunk));
// 1-byte mask trick (works on 4 pairs of single digits)
std::uint64_t lower_digits = (chunk & 0x0f000f000f000f00) >> 8;
std::uint64_t upper_digits = (chunk & 0x000f000f000f000f) * 10;
chunk = lower_digits + upper_digits;
// 2-byte mask trick (works on 2 pairs of two digits)
lower_digits = (chunk & 0x00ff000000ff0000) >> 16;
upper_digits = (chunk & 0x000000ff000000ff) * 100;
chunk = lower_digits + upper_digits;
// 4-byte mask trick (works on pair of four digits)
lower_digits = (chunk & 0x0000ffff00000000) >> 32;
upper_digits = (chunk & 0x000000000000ffff) * 10000;
chunk = lower_digits + upper_digits;
return chunk;
}
inline std::uint64_t parse_trick(std::string_view s) noexcept
{
std::uint64_t upper_digits = parse_8_chars(s.data());
std::uint64_t lower_digits = parse_8_chars(s.data() + 8);
return upper_digits * 100000000 + lower_digits;
}
inline std::uint64_t parse_trick_simd(std::string_view s) noexcept
{
return parse_16_chars(s.data());
}
namespace detail
{
template <typename T>
inline void print_bits(T v)
{
std::cout << std::setfill('0') << std::setw(sizeof(v) * 2) << std::hex << v
<< " " << std::bitset<sizeof(v) * 8>(v) << std::endl;
}
inline void print_bits(__m128i v)
{
print_bits(v[0]);
print_bits(v[1]);
}
inline __m128i get_numeric_mask(__m128i chunk)
{
const auto wrap = _mm_set1_epi8(-128);
const auto digit_upper_bound = _mm_set1_epi8(10) + wrap;
return _mm_cmplt_epi8(chunk + wrap, digit_upper_bound);
}
inline std::uint64_t get_digit_count_from_numeric_mask(__m128i mask)
{
auto condensed_mask = _mm_movemask_epi8(mask);
// cannot use leading zeros, because digits can be present in the string that
// are not part of the first numeric sequence
return __tzcnt_u64(~condensed_mask);
}
inline __m128i shift_bytes_left(__m128i a, std::uint64_t num_bytes)
{
// branching sucks
auto shifted = _mm_slli_si128(a, 8);
if (num_bytes >= 8)
{
return _mm_slli_epi64(shifted, (num_bytes - 8) * 8);
}
else
{
auto partial_result = _mm_slli_epi64(a, num_bytes * 8);
auto overlay = _mm_srli_epi64(shifted, (8 - num_bytes) * 8);
return _mm_or_si128(partial_result, overlay);
}
}
// Implemented by stevenhoving in issue #3
inline __m128i shift_bytes_left_branchless(__m128i a, std::uint64_t num_bytes)
{
constexpr auto mask = static_cast<char>(-128);
static const char shift_shuffle_lookup[32]{
mask, mask, mask, mask, mask, mask, mask, mask, mask, mask, mask, mask, mask, mask, mask, mask,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
const auto lookup_center = shift_shuffle_lookup + 16;
const auto shuffle = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(lookup_center - num_bytes));
return _mm_shuffle_epi8(a, shuffle);
}
}
#define unlikely(...) __builtin_expect(!!(__VA_ARGS__), 0)
#define likely(...) __builtin_expect(!!(__VA_ARGS__), 1)
inline std::from_chars_result from_chars(const char* first, const char* last, std::uint64_t& result)
{
auto buffer_size = last - first;
std::uint64_t value = 0;
if (likely(buffer_size >= sizeof(__m128i)))
{
auto chunk = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(first));
const auto zeros = _mm_set1_epi8('0');
chunk = chunk - zeros;
const auto numeric_mask = detail::get_numeric_mask(chunk);
const auto num_digits = detail::get_digit_count_from_numeric_mask(numeric_mask);
const auto num_non_digits = sizeof(chunk) - num_digits;
chunk = detail::shift_bytes_left_branchless(chunk, num_non_digits);
value = assemble_from_128i(chunk);
first += num_digits;
}
result = value;
return {first}; // TODO: return an error code
}
inline std::uint64_t parse_general_trick_simd(std::string_view s) noexcept
{
std::uint64_t result = 0;
from_chars(s.data(), s.data() + s.size(), result);
return result;
}
extern const char* example_timestamp;
| 28.761062 | 102 | 0.668769 | KholdStare |
e18277d166e04f74fd857f4cb731c457dfff702a | 1,815 | cc | C++ | test/vector_iterator.cc | Victor-Savu/xtd | 504b7adc826afd12c59c6b6680177385bf63ebfa | [
"MIT"
] | null | null | null | test/vector_iterator.cc | Victor-Savu/xtd | 504b7adc826afd12c59c6b6680177385bf63ebfa | [
"MIT"
] | null | null | null | test/vector_iterator.cc | Victor-Savu/xtd | 504b7adc826afd12c59c6b6680177385bf63ebfa | [
"MIT"
] | null | null | null | #include <xtd/vector.hh>
#include <string>
#include <algorithm>
#include <gtest/gtest.h>
TEST(vector_iterator, construction) {
xtd::vector<int> v;
xtd::vector<int> const cv;
xtd::vector<int>::iterator def_mut;
xtd::vector<int>::iterator mut{v, 0};
xtd::vector<int>::iterator mut_copy{mut};
xtd::vector<int>::const_iterator def_ct;
xtd::vector<int>::const_iterator ct{cv, 0};
xtd::vector<int>::const_iterator ct_copy{ct};
xtd::vector<int>::const_iterator ct_copy_from_mut{mut};
}
TEST(vector_iterator, range_for) {
xtd::vector<std::string> v;
std::string msg;
v.push("Hello");
v.push(" world!");
for (auto&& s : v) msg += s;
EXPECT_EQ("Hello world!", msg);
}
TEST(vector_iterator, accumulate) {
xtd::vector<std::string> v;
v.push("Hello");
v.push(" world!");
std::string msg = std::accumulate(std::begin(v), std::end(v), std::string{});
EXPECT_EQ("Hello world!", msg);
xtd::vector<std::string>& w{v};
std::string msgw = std::accumulate(std::begin(w), std::end(w), std::string{});
EXPECT_EQ("Hello world!", msgw);
}
TEST(vector_iterator, deref) {
xtd::vector<std::string> v;
v.push("Hello");
v.push(" world!");
auto i = v.begin();
EXPECT_EQ("Hello", *i);
}
TEST(vector_iterator, pre_increment) {
xtd::vector<std::string> v;
v.push("Hello");
v.push(" world!");
auto i = v.begin();
EXPECT_EQ(" world!", *(++i));
EXPECT_EQ(" world!", *i);
}
TEST(vector_iterator, post_increment) {
xtd::vector<std::string> v;
v.push("Hello");
v.push(" world!");
auto i = v.begin();
EXPECT_EQ("Hello", *(i++));
EXPECT_EQ(" world!", *i);
}
TEST(vector_iterator, equality_comparable) {
xtd::vector<std::string> v;
v.push("Hello");
v.push(" world!");
auto i = v.begin();
auto j = i;
EXPECT_EQ(i, j);
EXPECT_NE(i, v.end());
}
| 20.625 | 80 | 0.625344 | Victor-Savu |
e18955102604b2fcfe07bb045dd1607e0b80d96c | 145,759 | cpp | C++ | src/textGeometryBSU.cpp | macton/chromium-bsu | 27e70290913f62401f1ecfca9e806b6ba9170547 | [
"ClArtistic"
] | 3 | 2019-06-07T16:09:28.000Z | 2021-04-01T21:46:24.000Z | src/textGeometryBSU.cpp | macton/chromium-bsu | 27e70290913f62401f1ecfca9e806b6ba9170547 | [
"ClArtistic"
] | 1 | 2020-12-19T15:20:14.000Z | 2020-12-28T10:00:31.000Z | src/textGeometryBSU.cpp | macton/chromium-bsu | 27e70290913f62401f1ecfca9e806b6ba9170547 | [
"ClArtistic"
] | 3 | 2016-04-19T17:07:30.000Z | 2019-03-01T05:47:53.000Z | /*
* Copyright (c) 2000 Mark B. Allan. All rights reserved.
*
* "Chromium B.S.U." is free software; you can redistribute
* it and/or use it and/or modify it under the terms of the
* "Clarified Artistic License"
*/
#ifdef HAVE_CONFIG_H
#include <chromium-bsu-config.h>
#endif
#include "textGeometry.h"
#include "compatibility.h"
#if defined(HAVE_APPLE_OPENGL_FRAMEWORK) || defined(HAVE_OPENGL_GL_H)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
// one of these days I'll get around to stripifying this data...
//========================================================================================
static float data_Front_Face[][3] = {
{ -2.196728, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.474057, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, 0.277315, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, 0.474057, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.998917, 0.105369, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, 0.277315, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.062568, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.998917, 0.105369, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.203025, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371595, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.062568, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.203025, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.062568, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.509167, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.203025, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.509167, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386300, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386300, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386300, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.363750, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.363750, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.363750, -0.593432, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.363750, -0.593432, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386375, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386375, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386375, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386375, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386375, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371595, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371595, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.509475, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371595, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.188333, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.509475, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.188333, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371595, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.062568, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371595, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.030136, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.062568, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.030136, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.996690, -0.072866, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.030136, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.648750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.278750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.278750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.278750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.648750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.648750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.040199, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.459628, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.825017, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.008337, -0.622225, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.986252, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.825017, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.986252, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.040199, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.142244, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.825017, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.040199, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.023750, -0.524922, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.142244, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.040199, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.023750, -0.524922, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.040199, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.023750, -0.264258, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.023750, -0.524922, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.243791, -0.131630, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.023750, -0.264258, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.661693, -0.156457, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.460460, -0.145088, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.243791, -0.131630, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.661693, -0.156457, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.243791, -0.131630, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.243791, -0.131630, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.740200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.459628, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.127764, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.310723, 0.622930, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.288752, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.127764, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.288752, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.740200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.561640, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.127764, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.740200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.561640, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.740200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.681883, 0.487957, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.561640, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.678707, 0.405453, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.681883, 0.487957, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.675048, 0.321275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.678707, 0.405453, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.451288, 0.184034, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.675048, 0.321275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.451288, 0.184034, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.232997, 0.198856, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.451288, 0.184034, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.033247, 0.211340, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.232997, 0.198856, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.583750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.953750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.953750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.953750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.583750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.583750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.658700, 0.264277, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.706200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.543700, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.680900, -0.520343, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.670025, -0.187694, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.670025, -0.187694, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.658700, 0.264277, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.475715, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.431785, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.475715, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.237480, -0.186443, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.226593, -0.520340, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.248810, 0.264275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.237480, -0.186443, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.618790, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.201298, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.248810, 0.264275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.618790, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.248810, 0.264275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.596250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.618790, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.596250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.596250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.699077, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.596250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.699077, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.463423, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.699077, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.566250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.463423, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.566250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.658700, 0.264277, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.566250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.566250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.658700, 0.264277, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.543700, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.566250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.658700, 0.264277, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.023750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.393750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.393750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.393750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.023750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.023750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 110.0, 110.0, 110.0 } };
//========================================================================================
static float data_Front_Bevel[][3] = {
{ -1.858750, -0.495000, 0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -1.908750, -0.474057, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.176250, -0.807500, 0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -1.908750, -0.474057, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.176250, -0.807500, 0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -2.176250, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.196728, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.443750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.196728, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386375, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.443750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -3.443750, -0.807500, 0.137500 }, { -0.990621, 0.136637, -0.000000 },
{ -3.386375, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.413750, -0.590000, 0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.386375, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.363750, -0.593432, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.413750, -0.590000, 0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.413750, -0.590000, 0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.363750, -0.593432, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.413750, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.363750, -0.593432, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.363750, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.413750, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.413750, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.363750, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.443750, 0.807500, 0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ -3.363750, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.386300, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -3.443750, 0.807500, 0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ -3.443750, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -3.386300, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.176250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -3.386300, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.176250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.176250, 0.807500, 0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.858750, 0.495000, 0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -2.196728, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, 0.474057, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.858750, 0.495000, 0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -1.858750, 0.495000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.908750, 0.474057, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.858750, 0.265000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.908750, 0.474057, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, 0.277315, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.858750, 0.265000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.265000, 0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.908750, 0.277315, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.966250, 0.060000, 0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.908750, 0.277315, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.998917, 0.105369, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.966250, 0.060000, 0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.966250, 0.060000, 0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -1.998917, 0.105369, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.213750, 0.020000, 0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -1.998917, 0.105369, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.062568, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.213750, 0.020000, 0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -2.213750, 0.020000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.263750, 0.062568, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.213750, 0.012500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.263750, 0.062568, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.030136, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.213750, 0.012500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.012500, 0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -2.263750, -0.030136, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.963750, -0.027500, 0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -2.263750, -0.030136, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.996690, -0.072866, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.963750, -0.027500, 0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -1.963750, -0.027500, 0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.996690, -0.072866, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.858750, -0.232500, 0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.996690, -0.072866, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.858750, -0.232500, 0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.858750, -0.232500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.858750, -0.495000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.908750, -0.244560, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.908750, -0.474057, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.858750, -0.495000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.313750, 0.220000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.263750, 0.203025, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.313750, 0.492500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.263750, 0.203025, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.509167, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.313750, 0.492500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.492500, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.263750, 0.509167, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.396250, 0.602500, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.263750, 0.509167, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.396250, 0.602500, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.371250, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.943750, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.371250, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.943750, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, 0.602500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.993750, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.943750, 0.112500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.993750, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.943750, 0.112500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.112500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.993750, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.396250, 0.112500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.993750, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371595, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.396250, 0.112500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, 0.112500, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.371595, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.313750, 0.220000, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.371595, 0.062500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, 0.203025, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.313750, 0.220000, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, -0.492500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.263750, -0.509475, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.313750, -0.205000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.263750, -0.509475, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.188333, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.313750, -0.205000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.205000, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.263750, -0.188333, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.396250, -0.095000, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.263750, -0.188333, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.396250, -0.095000, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, -0.095000, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.943750, -0.095000, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.371250, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.943750, -0.095000, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, -0.095000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.993750, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.943750, -0.600000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.993750, -0.045000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.993750, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.943750, -0.600000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.993750, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.396250, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.993750, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.371595, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.396250, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, -0.600000, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.371595, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.313750, -0.492500, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.371595, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.263750, -0.509475, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -2.313750, -0.492500, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -1.228750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.278750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.698750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.278750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.648750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.698750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.698750, -0.807500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.648750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.698750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.648750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.648750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.698750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.648750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.228750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.648750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.278750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.228750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.228750, -0.475000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.278750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.228750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.278750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.278750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.228750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.480000, 0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.331250, -0.459628, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.061250, -0.807500, 0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.331250, -0.459628, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.040199, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.061250, -0.807500, 0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.061250, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.040199, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.028750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.040199, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.986252, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.028750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.028750, -0.807500, 0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -0.986252, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.068750, -0.562500, 0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -0.986252, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.008337, -0.622225, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.068750, -0.562500, 0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.068750, -0.562500, 0.137500 }, { 0.149805, 0.988716, 0.000000 },
{ -1.008337, -0.622225, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.821250, -0.600000, 0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -1.008337, -0.622225, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.825017, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.821250, -0.600000, 0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.821250, -0.600000, 0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.825017, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.163750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.825017, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.142244, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.163750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.163750, -0.600000, 0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.142244, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.073750, -0.505000, 0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.142244, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.023750, -0.524922, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.073750, -0.505000, 0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.073750, -0.505000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.023750, -0.524922, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.073750, -0.292500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.023750, -0.524922, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.023750, -0.264258, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.073750, -0.292500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.292500, 0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.023750, -0.264258, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.256250, -0.182500, 0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.023750, -0.264258, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.243791, -0.131630, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.256250, -0.182500, 0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.256250, -0.182500, 0.137500 }, { 0.061992, -0.998077, -0.000000 },
{ -0.243791, -0.131630, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.457500, -0.195000, 0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.243791, -0.131630, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.460460, -0.145088, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.457500, -0.195000, 0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.457500, -0.195000, 0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.460460, -0.145088, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.678750, -0.207500, 0.137500 }, { 0.056407, -0.998408, -0.000000 },
{ -0.460460, -0.145088, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.661693, -0.156457, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.678750, -0.207500, 0.137500 }, { 0.056407, -0.998408, -0.000000 },
{ -0.678750, -0.207500, 0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -0.661693, -0.156457, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.081250, 0.132500, 0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -0.661693, -0.156457, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.081250, 0.132500, 0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -1.081250, 0.132500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.081250, 0.480000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.031250, 0.155715, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.031250, 0.459628, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -1.081250, 0.480000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.480000, 0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -1.031250, 0.459628, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.761250, 0.807500, 0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -1.031250, 0.459628, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.740200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.761250, 0.807500, 0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -0.761250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.740200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.740200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.288752, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.331250, 0.807500, 0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.288752, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.371250, 0.562500, 0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.288752, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.310723, 0.622930, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.371250, 0.562500, 0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.371250, 0.562500, 0.137500 }, { -0.159546, -0.987191, -0.000000 },
{ 0.310723, 0.622930, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.123750, 0.602500, 0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ 0.310723, 0.622930, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.127764, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.123750, 0.602500, 0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ 0.123750, 0.602500, 0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ 0.127764, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.536250, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.127764, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.561640, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.536250, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -0.536250, 0.602500, 0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.561640, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.631250, 0.472500, 0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.561640, 0.652500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.681883, 0.487957, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.631250, 0.472500, 0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.631250, 0.472500, 0.137500 }, { 0.999261, 0.038433, 0.000000 },
{ -0.681883, 0.487957, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.628750, 0.407500, 0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.681883, 0.487957, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.678707, 0.405453, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.628750, 0.407500, 0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.628750, 0.407500, 0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.678707, 0.405453, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.626250, 0.350000, 0.137500 }, { 0.999056, 0.043437, 0.000000 },
{ -0.678707, 0.405453, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.675048, 0.321275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.626250, 0.350000, 0.137500 }, { 0.999056, 0.043437, 0.000000 },
{ -0.626250, 0.350000, 0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.675048, 0.321275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.438750, 0.235000, 0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.675048, 0.321275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.451288, 0.184034, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.438750, 0.235000, 0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.438750, 0.235000, 0.137500 }, { -0.067745, 0.997703, -0.000000 },
{ -0.451288, 0.184034, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.236250, 0.248750, 0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.451288, 0.184034, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.232997, 0.198856, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.236250, 0.248750, 0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.236250, 0.248750, 0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.232997, 0.198856, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.016250, 0.262500, 0.137500 }, { -0.062378, 0.998053, -0.000000 },
{ -0.232997, 0.198856, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.033247, 0.211340, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ -0.016250, 0.262500, 0.137500 }, { -0.062378, 0.998053, -0.000000 },
{ -0.016250, 0.262500, 0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ -0.033247, 0.211340, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.381250, -0.075000, 0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ -0.033247, 0.211340, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.381250, -0.075000, 0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ 0.381250, -0.075000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.381250, -0.480000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.331250, -0.098139, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.331250, -0.459628, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.381250, -0.480000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.953750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.533750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.953750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.583750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.533750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.533750, -0.807500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.583750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.533750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.583750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.583750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.533750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.583750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.003750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.583750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.953750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.003750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.003750, -0.475000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.953750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.003750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.953750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 0.953750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.003750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 2.761250, 0.807500, 0.137500 }, { 0.995392, -0.095886, -0.000000 },
{ 2.706200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.708750, 0.262500, 0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.706200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.658700, 0.264277, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.708750, 0.262500, 0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.708750, 0.262500, 0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.658700, 0.264277, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.720000, -0.186250, 0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.658700, 0.264277, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.670025, -0.187694, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.720000, -0.186250, 0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.720000, -0.186250, 0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.670025, -0.187694, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.731250, -0.530000, 0.137500 }, { 0.999465, 0.032710, 0.000000 },
{ 2.670025, -0.187694, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.680900, -0.520343, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.731250, -0.530000, 0.137500 }, { 0.999465, 0.032710, 0.000000 },
{ 2.731250, -0.530000, 0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.680900, -0.520343, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.645000, -0.727500, 0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.680900, -0.520343, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.645000, -0.727500, 0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.645000, -0.727500, 0.137500 }, { 0.365476, -0.930821, -0.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.441250, -0.807500, 0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 2.607450, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.431785, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.441250, -0.807500, 0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 2.441250, -0.807500, 0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 2.431785, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.466250, -0.807500, 0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 2.431785, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.475715, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.466250, -0.807500, 0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.466250, -0.807500, 0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.475715, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.262500, -0.727500, 0.137500 }, { -0.365476, -0.930821, -0.000000 },
{ 1.475715, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.262500, -0.727500, 0.137500 }, { -0.365476, -0.930821, -0.000000 },
{ 1.262500, -0.727500, 0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.176250, -0.530000, 0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.300038, -0.688523, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.226593, -0.520340, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.176250, -0.530000, 0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.176250, -0.530000, 0.137500 }, { -0.999469, 0.032591, -0.000000 },
{ 1.226593, -0.520340, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.187500, -0.185000, 0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.226593, -0.520340, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.237480, -0.186443, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.187500, -0.185000, 0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.187500, -0.185000, 0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.237480, -0.186443, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.198750, 0.262500, 0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.237480, -0.186443, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.248810, 0.264275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.198750, 0.262500, 0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.198750, 0.262500, 0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.248810, 0.264275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.146250, 0.807500, 0.137500 }, { -0.995392, -0.095886, -0.000000 },
{ 1.248810, 0.264275, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.201298, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.146250, 0.807500, 0.137500 }, { -0.995392, -0.095886, -0.000000 },
{ 1.146250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.201298, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.676250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.201298, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.618790, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.676250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.676250, 0.807500, 0.137500 }, { 0.990405, -0.138196, -0.000000 },
{ 1.618790, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.646250, 0.592500, 0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.618790, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.596250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.646250, 0.592500, 0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.646250, 0.592500, 0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.596250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.646250, -0.532500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.596250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.596250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.646250, -0.532500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.646250, -0.532500, 0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.596250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.718750, -0.600000, 0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.596250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.699077, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 1.718750, -0.600000, 0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.718750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.699077, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.443750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.699077, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.463423, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.443750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.443750, -0.600000, 0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.463423, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.516250, -0.532500, 0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.463423, -0.650000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.566250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.516250, -0.532500, 0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.516250, -0.532500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.566250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.516250, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.566250, -0.554265, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.566250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.516250, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.516250, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.566250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.486250, 0.807500, 0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ 2.566250, 0.595972, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.543700, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.486250, 0.807500, 0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ 2.486250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.543700, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.761250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.543700, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.706200, 0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.761250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 3.393750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.973750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 3.393750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.023750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.973750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 2.973750, -0.807500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 3.023750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.973750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 3.023750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.023750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 2.973750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.023750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.443750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.023750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.393750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.443750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.475000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.393750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.443750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.393750, -0.525000, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.393750, -0.757500, 0.187500 }, { -0.000000, -0.000000, 1.000000 },
{ 3.443750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 110.0, 110.0, 110.0 } };
//========================================================================================
static float data_Back_Face[][3] = {
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.474057, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, 0.474057, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, 0.277315, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, 0.277315, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.998917, 0.105369, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.998917, 0.105369, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.062568, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.062568, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.203025, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.062568, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.203025, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.203025, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.509167, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.509167, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386300, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386300, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.363750, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386300, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.363750, -0.593432, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.363750, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386375, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.363750, -0.593432, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386375, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386375, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386375, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386375, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.509475, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.509475, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.188333, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.188333, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.062568, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.062568, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.030136, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.030136, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.030136, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.996690, -0.072866, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.278750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.278750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.648750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.648750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.648750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.278750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.459628, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.040199, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.986252, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.008337, -0.622225, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.825017, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.040199, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.986252, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.825017, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.040199, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.825017, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.142244, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.040199, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.142244, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.524922, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.040199, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.524922, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.524922, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.264258, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.264258, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.243791, -0.131630, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.243791, -0.131630, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.460460, -0.145088, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.661693, -0.156457, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.243791, -0.131630, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.661693, -0.156457, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.243791, -0.131630, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.459628, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.740200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.288752, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.310723, 0.622930, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.127764, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.740200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.288752, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.127764, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.740200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.127764, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.561640, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.740200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.561640, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.561640, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.681883, 0.487957, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.681883, 0.487957, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.678707, 0.405453, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.678707, 0.405453, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.675048, 0.321275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.675048, 0.321275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.451288, 0.184034, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.451288, 0.184034, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.451288, 0.184034, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.232997, 0.198856, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.232997, 0.198856, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.033247, 0.211340, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.953750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.953750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.583750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.583750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.583750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.953750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.543700, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.706200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.658700, 0.264277, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.670025, -0.187694, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.680900, -0.520343, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.658700, 0.264277, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.670025, -0.187694, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.431785, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.475715, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.475715, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.226593, -0.520340, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.237480, -0.186443, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.237480, -0.186443, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.248810, 0.264275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.248810, 0.264275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.201298, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.618790, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.248810, 0.264275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.618790, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.618790, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.596250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.596250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.596250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.596250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.699077, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.699077, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.699077, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.463423, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.463423, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.658700, 0.264277, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.658700, 0.264277, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.658700, 0.264277, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.543700, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.393750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.393750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.023750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.023750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.023750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.393750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 110.0, 110.0, 110.0 } };
//========================================================================================
static float data_Back_Bevel[][3] = {
{ -1.858750, -0.495000, -0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -2.196728, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.474057, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.858750, -0.495000, -0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -2.176250, -0.807500, -0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -2.176250, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -3.386375, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386375, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.176250, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -3.443750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -3.443750, -0.807500, -0.137500 }, { -0.990621, 0.136637, -0.000000 },
{ -3.363750, -0.593432, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386375, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.363750, -0.593432, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.443750, -0.807500, -0.137500 }, { -0.990621, 0.136637, -0.000000 },
{ -3.413750, -0.590000, -0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.413750, -0.590000, -0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.363750, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.363750, -0.593432, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.363750, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.413750, -0.590000, -0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.413750, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.413750, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.386300, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.363750, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386300, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.413750, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.443750, 0.807500, -0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ -3.443750, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.386300, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -3.443750, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.176250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.176250, 0.807500, -0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -1.908750, 0.474057, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.196728, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, 0.474057, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.176250, 0.807500, -0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -1.858750, 0.495000, -0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -1.858750, 0.495000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.908750, 0.277315, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, 0.474057, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, 0.277315, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.858750, 0.495000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.265000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.265000, -0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.998917, 0.105369, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, 0.277315, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.998917, 0.105369, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.858750, 0.265000, -0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.966250, 0.060000, -0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.966250, 0.060000, -0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -2.263750, 0.062568, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.998917, 0.105369, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.062568, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.966250, 0.060000, -0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -2.213750, 0.020000, -0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -2.213750, 0.020000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.263750, -0.030136, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.062568, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.030136, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.213750, 0.020000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.012500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.012500, -0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -1.996690, -0.072866, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.030136, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.996690, -0.072866, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.213750, 0.012500, -0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -1.963750, -0.027500, -0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -1.963750, -0.027500, -0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.996690, -0.072866, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.963750, -0.027500, -0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.858750, -0.232500, -0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.858750, -0.232500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.908750, -0.474057, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.244560, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.908750, -0.474057, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.858750, -0.232500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, -0.495000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.313750, 0.220000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.263750, 0.509167, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.203025, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.509167, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.313750, 0.220000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.492500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.492500, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.371250, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.509167, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.313750, 0.492500, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, 0.602500, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, 0.602500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.993750, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.396250, 0.602500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, 0.602500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, 0.602500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.993750, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.943750, 0.602500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.112500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.112500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.371595, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.943750, 0.112500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, 0.112500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, 0.112500, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.263750, 0.203025, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, 0.062500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, 0.203025, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.396250, 0.112500, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, 0.220000, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, -0.492500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.263750, -0.188333, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.509475, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.188333, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.313750, -0.492500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.205000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.205000, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.188333, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.313750, -0.205000, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, -0.095000, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, -0.095000, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.993750, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371250, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.396250, -0.095000, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, -0.095000, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, -0.095000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.993750, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.045000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.943750, -0.095000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.600000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.371595, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.993750, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.943750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, -0.600000, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.263750, -0.509475, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.371595, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.263750, -0.509475, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -2.396250, -0.600000, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, -0.492500, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -1.228750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.648750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.278750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.648750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.228750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.698750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.698750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.648750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.648750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.648750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.698750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.475000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.278750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.648750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.278750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.698750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.228750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.228750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.278750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.278750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.278750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.228750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.228750, -0.807500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.480000, -0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.040199, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.459628, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.040199, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.381250, -0.480000, -0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.061250, -0.807500, -0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.061250, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -0.986252, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.040199, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.986252, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.061250, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.028750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.028750, -0.807500, -0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.008337, -0.622225, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.986252, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.008337, -0.622225, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.028750, -0.807500, -0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.068750, -0.562500, -0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.068750, -0.562500, -0.137500 }, { 0.149805, 0.988716, 0.000000 },
{ -0.825017, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.008337, -0.622225, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.825017, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.068750, -0.562500, -0.137500 }, { 0.149805, 0.988716, 0.000000 },
{ -0.821250, -0.600000, -0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.821250, -0.600000, -0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.142244, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.825017, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.142244, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.821250, -0.600000, -0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.163750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.163750, -0.600000, -0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.023750, -0.524922, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.142244, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.524922, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.163750, -0.600000, -0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.073750, -0.505000, -0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.073750, -0.505000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.023750, -0.264258, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.524922, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.264258, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.073750, -0.505000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.292500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.292500, -0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.243791, -0.131630, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.023750, -0.264258, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.243791, -0.131630, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.073750, -0.292500, -0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.256250, -0.182500, -0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.256250, -0.182500, -0.137500 }, { 0.061992, -0.998077, -0.000000 },
{ -0.460460, -0.145088, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.243791, -0.131630, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.460460, -0.145088, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.256250, -0.182500, -0.137500 }, { 0.061992, -0.998077, -0.000000 },
{ -0.457500, -0.195000, -0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.457500, -0.195000, -0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.661693, -0.156457, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.460460, -0.145088, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.661693, -0.156457, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.457500, -0.195000, -0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.678750, -0.207500, -0.137500 }, { 0.056407, -0.998408, -0.000000 },
{ -0.678750, -0.207500, -0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.661693, -0.156457, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.678750, -0.207500, -0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -1.081250, 0.132500, -0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -1.081250, 0.132500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.031250, 0.459628, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.155715, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.459628, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.081250, 0.132500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.480000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.480000, -0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -0.740200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.031250, 0.459628, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.740200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -1.081250, 0.480000, -0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -0.761250, 0.807500, -0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -0.761250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.288752, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.740200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.288752, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.761250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.331250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.331250, 0.807500, -0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.310723, 0.622930, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.288752, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.310723, 0.622930, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, 0.807500, -0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.371250, 0.562500, -0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.371250, 0.562500, -0.137500 }, { -0.159546, -0.987191, -0.000000 },
{ 0.127764, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.310723, 0.622930, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.127764, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.371250, 0.562500, -0.137500 }, { -0.159546, -0.987191, -0.000000 },
{ 0.123750, 0.602500, -0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ 0.123750, 0.602500, -0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ -0.561640, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.127764, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.561640, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.123750, 0.602500, -0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ -0.536250, 0.602500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -0.536250, 0.602500, -0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.681883, 0.487957, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.561640, 0.652500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.681883, 0.487957, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.536250, 0.602500, -0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.631250, 0.472500, -0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.631250, 0.472500, -0.137500 }, { 0.999261, 0.038433, 0.000000 },
{ -0.678707, 0.405453, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.681883, 0.487957, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.678707, 0.405453, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.631250, 0.472500, -0.137500 }, { 0.999261, 0.038433, 0.000000 },
{ -0.628750, 0.407500, -0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.628750, 0.407500, -0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.675048, 0.321275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.678707, 0.405453, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.675048, 0.321275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.628750, 0.407500, -0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.626250, 0.350000, -0.137500 }, { 0.999056, 0.043437, 0.000000 },
{ -0.626250, 0.350000, -0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.451288, 0.184034, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.675048, 0.321275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.451288, 0.184034, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.626250, 0.350000, -0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.438750, 0.235000, -0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.438750, 0.235000, -0.137500 }, { -0.067745, 0.997703, -0.000000 },
{ -0.232997, 0.198856, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.451288, 0.184034, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.232997, 0.198856, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.438750, 0.235000, -0.137500 }, { -0.067745, 0.997703, -0.000000 },
{ -0.236250, 0.248750, -0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.236250, 0.248750, -0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.033247, 0.211340, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.232997, 0.198856, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.033247, 0.211340, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.236250, 0.248750, -0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.016250, 0.262500, -0.137500 }, { -0.062378, 0.998053, -0.000000 },
{ -0.016250, 0.262500, -0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.033247, 0.211340, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ -0.016250, 0.262500, -0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ 0.381250, -0.075000, -0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ 0.381250, -0.075000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.331250, -0.459628, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.098139, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.331250, -0.459628, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.381250, -0.075000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.480000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.583750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.953750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.583750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.003750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.533750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.533750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.583750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.583750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.583750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.533750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.475000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.953750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.583750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.953750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.533750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.003750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.003750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.953750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.953750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 0.953750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.003750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.807500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 2.761250, 0.807500, -0.137500 }, { 0.995392, -0.095886, -0.000000 },
{ 2.658700, 0.264277, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.706200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.658700, 0.264277, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.761250, 0.807500, -0.137500 }, { 0.995392, -0.095886, -0.000000 },
{ 2.708750, 0.262500, -0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.708750, 0.262500, -0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.670025, -0.187694, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.658700, 0.264277, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.670025, -0.187694, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.708750, 0.262500, -0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.720000, -0.186250, -0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.720000, -0.186250, -0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.680900, -0.520343, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.670025, -0.187694, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.680900, -0.520343, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.720000, -0.186250, -0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.731250, -0.530000, -0.137500 }, { 0.999465, 0.032710, 0.000000 },
{ 2.731250, -0.530000, -0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.680900, -0.520343, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.731250, -0.530000, -0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.645000, -0.727500, -0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.645000, -0.727500, -0.137500 }, { 0.365476, -0.930821, -0.000000 },
{ 2.431785, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.607450, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.431785, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.645000, -0.727500, -0.137500 }, { 0.365476, -0.930821, -0.000000 },
{ 2.441250, -0.807500, -0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 2.441250, -0.807500, -0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 1.475715, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.431785, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.475715, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.441250, -0.807500, -0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 1.466250, -0.807500, -0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.466250, -0.807500, -0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.475715, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.466250, -0.807500, -0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.262500, -0.727500, -0.137500 }, { -0.365476, -0.930821, -0.000000 },
{ 1.262500, -0.727500, -0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.226593, -0.520340, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.300038, -0.688523, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.226593, -0.520340, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.262500, -0.727500, -0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.176250, -0.530000, -0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.176250, -0.530000, -0.137500 }, { -0.999469, 0.032591, -0.000000 },
{ 1.237480, -0.186443, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.226593, -0.520340, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.237480, -0.186443, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.176250, -0.530000, -0.137500 }, { -0.999469, 0.032591, -0.000000 },
{ 1.187500, -0.185000, -0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.187500, -0.185000, -0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.248810, 0.264275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.237480, -0.186443, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.248810, 0.264275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.187500, -0.185000, -0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.198750, 0.262500, -0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.198750, 0.262500, -0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.201298, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.248810, 0.264275, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.201298, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.198750, 0.262500, -0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.146250, 0.807500, -0.137500 }, { -0.995392, -0.095886, -0.000000 },
{ 1.146250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.618790, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.201298, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.618790, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.146250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.676250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.676250, 0.807500, -0.137500 }, { 0.990405, -0.138196, -0.000000 },
{ 1.596250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.618790, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.596250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.676250, 0.807500, -0.137500 }, { 0.990405, -0.138196, -0.000000 },
{ 1.646250, 0.592500, -0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.646250, 0.592500, -0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.596250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.596250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.596250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.646250, 0.592500, -0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.646250, -0.532500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.646250, -0.532500, -0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.699077, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.596250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.699077, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.646250, -0.532500, -0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.718750, -0.600000, -0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.718750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.463423, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.699077, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.463423, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 1.718750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.443750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.443750, -0.600000, -0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.566250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.463423, -0.650000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.443750, -0.600000, -0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.516250, -0.532500, -0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.516250, -0.532500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.566250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, -0.554265, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.516250, -0.532500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.516250, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.516250, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.543700, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.566250, 0.595972, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.543700, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.516250, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.486250, 0.807500, -0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ 2.486250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.706200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.543700, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.706200, 0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.486250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.761250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 3.023750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.393750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.023750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.443750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 2.973750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 2.973750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 3.023750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.023750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.023750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.973750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.475000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.393750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.023750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.393750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 2.973750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.393750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.393750, -0.525000, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.393750, -0.757500, -0.187500 }, { 0.000000, 0.000000, -1.000000 },
{ 3.443750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.443750, -0.807500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 110.0, 110.0, 110.0} };
//========================================================================================
static float data_Side[][3] = {
{ -1.858750, -0.495000, -0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -1.858750, -0.495000, 0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -2.176250, -0.807500, 0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -1.858750, -0.495000, -0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -2.176250, -0.807500, 0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -2.176250, -0.807500, -0.137500 }, { 0.701473, -0.712696, -0.000000 },
{ -2.176250, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.176250, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -3.443750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.176250, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -3.443750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -3.443750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -3.443750, -0.807500, -0.137500 }, { -0.990621, 0.136637, -0.000000 },
{ -3.443750, -0.807500, 0.137500 }, { -0.990621, 0.136637, -0.000000 },
{ -3.413750, -0.590000, 0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.443750, -0.807500, -0.137500 }, { -0.990621, 0.136637, -0.000000 },
{ -3.413750, -0.590000, 0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.413750, -0.590000, -0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.413750, -0.590000, -0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.413750, -0.590000, 0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.413750, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.413750, -0.590000, -0.137500 }, { -0.997653, 0.068480, -0.000000 },
{ -3.413750, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.413750, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.413750, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.413750, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.443750, 0.807500, 0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ -3.413750, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ -3.443750, 0.807500, 0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ -3.443750, 0.807500, -0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ -3.443750, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -3.443750, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.176250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -3.443750, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.176250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.176250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.176250, 0.807500, -0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -2.176250, 0.807500, 0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -1.858750, 0.495000, 0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -2.176250, 0.807500, -0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -1.858750, 0.495000, 0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -1.858750, 0.495000, -0.137500 }, { 0.701473, 0.712696, 0.000000 },
{ -1.858750, 0.495000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.495000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.265000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.495000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.265000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.265000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, 0.265000, -0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.858750, 0.265000, 0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.966250, 0.060000, 0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.858750, 0.265000, -0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.966250, 0.060000, 0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.966250, 0.060000, -0.137500 }, { 0.885620, -0.464411, -0.000000 },
{ -1.966250, 0.060000, -0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -1.966250, 0.060000, 0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -2.213750, 0.020000, 0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -1.966250, 0.060000, -0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -2.213750, 0.020000, 0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -2.213750, 0.020000, -0.137500 }, { 0.159546, -0.987191, -0.000000 },
{ -2.213750, 0.020000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.020000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.012500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.020000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.012500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.012500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.213750, 0.012500, -0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -2.213750, 0.012500, 0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -1.963750, -0.027500, 0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -2.213750, 0.012500, -0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -1.963750, -0.027500, 0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -1.963750, -0.027500, -0.137500 }, { 0.157991, 0.987441, 0.000000 },
{ -1.963750, -0.027500, -0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.963750, -0.027500, 0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.858750, -0.232500, 0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.963750, -0.027500, -0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.858750, -0.232500, 0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.858750, -0.232500, -0.137500 }, { 0.890043, 0.455876, 0.000000 },
{ -1.858750, -0.232500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, -0.232500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, -0.495000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, -0.232500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, -0.495000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.858750, -0.495000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.313750, 0.220000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.220000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.492500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.220000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.492500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.492500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, 0.492500, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.313750, 0.492500, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, 0.602500, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.313750, 0.492500, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, 0.602500, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, 0.602500, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, 0.602500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.396250, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.396250, 0.602500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, 0.602500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, 0.602500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.602500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.112500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.602500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.112500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.112500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, 0.112500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.943750, 0.112500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, 0.112500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.943750, 0.112500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, 0.112500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, 0.112500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, 0.112500, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.396250, 0.112500, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, 0.220000, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.396250, 0.112500, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, 0.220000, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, 0.220000, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, -0.492500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.492500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.205000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.492500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.205000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.205000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -2.313750, -0.205000, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.313750, -0.205000, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, -0.095000, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.313750, -0.205000, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, -0.095000, 0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, -0.095000, -0.137500 }, { -0.800000, -0.600000, -0.000000 },
{ -2.396250, -0.095000, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.396250, -0.095000, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, -0.095000, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.396250, -0.095000, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, -0.095000, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, -0.095000, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -2.943750, -0.095000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.095000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.600000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.095000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.600000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.600000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -2.943750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.943750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.943750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -2.396250, -0.600000, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.396250, -0.600000, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, -0.492500, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.396250, -0.600000, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, -0.492500, 0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -2.313750, -0.492500, -0.137500 }, { -0.793309, 0.608819, -0.000000 },
{ -1.228750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.228750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.698750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.228750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.698750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.698750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.698750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.807500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.475000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.698750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.698750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.228750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.698750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.228750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.228750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -1.228750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.228750, -0.475000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.228750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.228750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.228750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ -1.228750, -0.807500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.480000, -0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.381250, -0.480000, 0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.061250, -0.807500, 0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.381250, -0.480000, -0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.061250, -0.807500, 0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.061250, -0.807500, -0.137500 }, { 0.715249, -0.698869, -0.000000 },
{ 0.061250, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.061250, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.028750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.061250, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.028750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.028750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -1.028750, -0.807500, -0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.028750, -0.807500, 0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.068750, -0.562500, 0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.028750, -0.807500, -0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.068750, -0.562500, 0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.068750, -0.562500, -0.137500 }, { -0.986933, -0.161132, -0.000000 },
{ -1.068750, -0.562500, -0.137500 }, { 0.149805, 0.988716, 0.000000 },
{ -1.068750, -0.562500, 0.137500 }, { 0.149805, 0.988716, 0.000000 },
{ -0.821250, -0.600000, 0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -1.068750, -0.562500, -0.137500 }, { 0.149805, 0.988716, 0.000000 },
{ -0.821250, -0.600000, 0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.821250, -0.600000, -0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.821250, -0.600000, -0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.821250, -0.600000, 0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.163750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.821250, -0.600000, -0.137500 }, { 0.075115, 0.997175, -0.000000 },
{ -0.163750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.163750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.163750, -0.600000, -0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.163750, -0.600000, 0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.073750, -0.505000, 0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.163750, -0.600000, -0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.073750, -0.505000, 0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.073750, -0.505000, -0.137500 }, { -0.725953, 0.687745, -0.000000 },
{ -0.073750, -0.505000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.505000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.292500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.505000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.292500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.292500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -0.073750, -0.292500, -0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.073750, -0.292500, 0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.256250, -0.182500, 0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.073750, -0.292500, -0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.256250, -0.182500, 0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.256250, -0.182500, -0.137500 }, { -0.516220, -0.856456, -0.000000 },
{ -0.256250, -0.182500, -0.137500 }, { 0.061992, -0.998077, -0.000000 },
{ -0.256250, -0.182500, 0.137500 }, { 0.061992, -0.998077, -0.000000 },
{ -0.457500, -0.195000, 0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.256250, -0.182500, -0.137500 }, { 0.061992, -0.998077, -0.000000 },
{ -0.457500, -0.195000, 0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.457500, -0.195000, -0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.457500, -0.195000, -0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.457500, -0.195000, 0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.678750, -0.207500, 0.137500 }, { 0.056407, -0.998408, -0.000000 },
{ -0.457500, -0.195000, -0.137500 }, { 0.059200, -0.998246, -0.000000 },
{ -0.678750, -0.207500, 0.137500 }, { 0.056407, -0.998408, -0.000000 },
{ -0.678750, -0.207500, -0.137500 }, { 0.056407, -0.998408, -0.000000 },
{ -0.678750, -0.207500, -0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -0.678750, -0.207500, 0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -1.081250, 0.132500, 0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -0.678750, -0.207500, -0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -1.081250, 0.132500, 0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -1.081250, 0.132500, -0.137500 }, { -0.645304, -0.763926, -0.000000 },
{ -1.081250, 0.132500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.132500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.480000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.132500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.480000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.480000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ -1.081250, 0.480000, -0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -1.081250, 0.480000, 0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -0.761250, 0.807500, 0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -1.081250, 0.480000, -0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -0.761250, 0.807500, 0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -0.761250, 0.807500, -0.137500 }, { -0.715249, 0.698869, -0.000000 },
{ -0.761250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.761250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.331250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ -0.761250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.331250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.331250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.331250, 0.807500, -0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.331250, 0.807500, 0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.371250, 0.562500, 0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.331250, 0.807500, -0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.371250, 0.562500, 0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.371250, 0.562500, -0.137500 }, { 0.986933, 0.161132, 0.000000 },
{ 0.371250, 0.562500, -0.137500 }, { -0.159546, -0.987191, -0.000000 },
{ 0.371250, 0.562500, 0.137500 }, { -0.159546, -0.987191, -0.000000 },
{ 0.123750, 0.602500, 0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ 0.371250, 0.562500, -0.137500 }, { -0.159546, -0.987191, -0.000000 },
{ 0.123750, 0.602500, 0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ 0.123750, 0.602500, -0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ 0.123750, 0.602500, -0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ 0.123750, 0.602500, 0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ -0.536250, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.123750, 0.602500, -0.137500 }, { -0.080030, -0.996792, -0.000000 },
{ -0.536250, 0.602500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -0.536250, 0.602500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ -0.536250, 0.602500, -0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.536250, 0.602500, 0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.631250, 0.472500, 0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.536250, 0.602500, -0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.631250, 0.472500, 0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.631250, 0.472500, -0.137500 }, { 0.807391, -0.590017, -0.000000 },
{ -0.631250, 0.472500, -0.137500 }, { 0.999261, 0.038433, 0.000000 },
{ -0.631250, 0.472500, 0.137500 }, { 0.999261, 0.038433, 0.000000 },
{ -0.628750, 0.407500, 0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.631250, 0.472500, -0.137500 }, { 0.999261, 0.038433, 0.000000 },
{ -0.628750, 0.407500, 0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.628750, 0.407500, -0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.628750, 0.407500, -0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.628750, 0.407500, 0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.626250, 0.350000, 0.137500 }, { 0.999056, 0.043437, 0.000000 },
{ -0.628750, 0.407500, -0.137500 }, { 0.999162, 0.040935, 0.000000 },
{ -0.626250, 0.350000, 0.137500 }, { 0.999056, 0.043437, 0.000000 },
{ -0.626250, 0.350000, -0.137500 }, { 0.999056, 0.043437, 0.000000 },
{ -0.626250, 0.350000, -0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.626250, 0.350000, 0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.438750, 0.235000, 0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.626250, 0.350000, -0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.438750, 0.235000, 0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.438750, 0.235000, -0.137500 }, { 0.522829, 0.852438, 0.000000 },
{ -0.438750, 0.235000, -0.137500 }, { -0.067745, 0.997703, -0.000000 },
{ -0.438750, 0.235000, 0.137500 }, { -0.067745, 0.997703, -0.000000 },
{ -0.236250, 0.248750, 0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.438750, 0.235000, -0.137500 }, { -0.067745, 0.997703, -0.000000 },
{ -0.236250, 0.248750, 0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.236250, 0.248750, -0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.236250, 0.248750, -0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.236250, 0.248750, 0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.016250, 0.262500, 0.137500 }, { -0.062378, 0.998053, -0.000000 },
{ -0.236250, 0.248750, -0.137500 }, { -0.065062, 0.997881, -0.000000 },
{ -0.016250, 0.262500, 0.137500 }, { -0.062378, 0.998053, -0.000000 },
{ -0.016250, 0.262500, -0.137500 }, { -0.062378, 0.998053, -0.000000 },
{ -0.016250, 0.262500, -0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ -0.016250, 0.262500, 0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ 0.381250, -0.075000, 0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ -0.016250, 0.262500, -0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ 0.381250, -0.075000, 0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ 0.381250, -0.075000, -0.137500 }, { 0.647231, 0.762294, 0.000000 },
{ 0.381250, -0.075000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.075000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.480000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.075000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.480000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 0.381250, -0.480000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 1.003750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.533750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 1.003750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.533750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.533750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 0.533750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.807500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.475000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 0.533750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.533750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.003750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 0.533750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.003750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.003750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.003750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.475000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.003750, -0.807500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 2.761250, 0.807500, -0.137500 }, { 0.995392, -0.095886, -0.000000 },
{ 2.761250, 0.807500, 0.137500 }, { 0.995392, -0.095886, -0.000000 },
{ 2.708750, 0.262500, 0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.761250, 0.807500, -0.137500 }, { 0.995392, -0.095886, -0.000000 },
{ 2.708750, 0.262500, 0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.708750, 0.262500, -0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.708750, 0.262500, -0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.708750, 0.262500, 0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.720000, -0.186250, 0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.708750, 0.262500, -0.137500 }, { 0.999370, -0.035477, -0.000000 },
{ 2.720000, -0.186250, 0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.720000, -0.186250, -0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.720000, -0.186250, -0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.720000, -0.186250, 0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.731250, -0.530000, 0.137500 }, { 0.999465, 0.032710, 0.000000 },
{ 2.720000, -0.186250, -0.137500 }, { 0.999583, 0.028886, 0.000000 },
{ 2.731250, -0.530000, 0.137500 }, { 0.999465, 0.032710, 0.000000 },
{ 2.731250, -0.530000, -0.137500 }, { 0.999465, 0.032710, 0.000000 },
{ 2.731250, -0.530000, -0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.731250, -0.530000, 0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.645000, -0.727500, 0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.731250, -0.530000, -0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.645000, -0.727500, 0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.645000, -0.727500, -0.137500 }, { 0.916423, -0.400210, -0.000000 },
{ 2.645000, -0.727500, -0.137500 }, { 0.365476, -0.930821, -0.000000 },
{ 2.645000, -0.727500, 0.137500 }, { 0.365476, -0.930821, -0.000000 },
{ 2.441250, -0.807500, 0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 2.645000, -0.727500, -0.137500 }, { 0.365476, -0.930821, -0.000000 },
{ 2.441250, -0.807500, 0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 2.441250, -0.807500, -0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 2.441250, -0.807500, -0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 2.441250, -0.807500, 0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 1.466250, -0.807500, 0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 2.441250, -0.807500, -0.137500 }, { 0.185983, -0.982553, -0.000000 },
{ 1.466250, -0.807500, 0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.466250, -0.807500, -0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.466250, -0.807500, -0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.466250, -0.807500, 0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.262500, -0.727500, 0.137500 }, { -0.365476, -0.930821, -0.000000 },
{ 1.466250, -0.807500, -0.137500 }, { -0.185983, -0.982553, -0.000000 },
{ 1.262500, -0.727500, 0.137500 }, { -0.365476, -0.930821, -0.000000 },
{ 1.262500, -0.727500, -0.137500 }, { -0.365476, -0.930821, -0.000000 },
{ 1.262500, -0.727500, -0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.262500, -0.727500, 0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.176250, -0.530000, 0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.262500, -0.727500, -0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.176250, -0.530000, 0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.176250, -0.530000, -0.137500 }, { -0.916423, -0.400210, -0.000000 },
{ 1.176250, -0.530000, -0.137500 }, { -0.999469, 0.032591, -0.000000 },
{ 1.176250, -0.530000, 0.137500 }, { -0.999469, 0.032591, -0.000000 },
{ 1.187500, -0.185000, 0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.176250, -0.530000, -0.137500 }, { -0.999469, 0.032591, -0.000000 },
{ 1.187500, -0.185000, 0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.187500, -0.185000, -0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.187500, -0.185000, -0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.187500, -0.185000, 0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.198750, 0.262500, 0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.187500, -0.185000, -0.137500 }, { -0.999583, 0.028862, -0.000000 },
{ 1.198750, 0.262500, 0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.198750, 0.262500, -0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.198750, 0.262500, -0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.198750, 0.262500, 0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.146250, 0.807500, 0.137500 }, { -0.995392, -0.095886, -0.000000 },
{ 1.198750, 0.262500, -0.137500 }, { -0.999372, -0.035442, -0.000000 },
{ 1.146250, 0.807500, 0.137500 }, { -0.995392, -0.095886, -0.000000 },
{ 1.146250, 0.807500, -0.137500 }, { -0.995392, -0.095886, -0.000000 },
{ 1.146250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.146250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.676250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.146250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.676250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.676250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.676250, 0.807500, -0.137500 }, { 0.990405, -0.138196, -0.000000 },
{ 1.676250, 0.807500, 0.137500 }, { 0.990405, -0.138196, -0.000000 },
{ 1.646250, 0.592500, 0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.676250, 0.807500, -0.137500 }, { 0.990405, -0.138196, -0.000000 },
{ 1.646250, 0.592500, 0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.646250, 0.592500, -0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.646250, 0.592500, -0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.646250, 0.592500, 0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.646250, -0.532500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.646250, 0.592500, -0.137500 }, { 0.997598, -0.069264, -0.000000 },
{ 1.646250, -0.532500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.646250, -0.532500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 1.646250, -0.532500, -0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.646250, -0.532500, 0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.718750, -0.600000, 0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.646250, -0.532500, -0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.718750, -0.600000, 0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.718750, -0.600000, -0.137500 }, { 0.681419, 0.731894, 0.000000 },
{ 1.718750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.718750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.443750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 1.718750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.443750, -0.600000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.443750, -0.600000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.443750, -0.600000, -0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.443750, -0.600000, 0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.516250, -0.532500, 0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.443750, -0.600000, -0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.516250, -0.532500, 0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.516250, -0.532500, -0.137500 }, { -0.681419, 0.731894, -0.000000 },
{ 2.516250, -0.532500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.516250, -0.532500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.516250, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.516250, -0.532500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.516250, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.516250, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.516250, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.516250, 0.592500, 0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.486250, 0.807500, 0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ 2.516250, 0.592500, -0.137500 }, { -0.997598, -0.069264, -0.000000 },
{ 2.486250, 0.807500, 0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ 2.486250, 0.807500, -0.137500 }, { -0.990405, -0.138196, -0.000000 },
{ 2.486250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.486250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.761250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.486250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.761250, 0.807500, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.761250, 0.807500, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 3.443750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 2.973750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 3.443750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 2.973750, -0.807500, 0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 2.973750, -0.807500, -0.137500 }, { 0.000000, -1.000000, -0.000000 },
{ 2.973750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.807500, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.807500, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.475000, 0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.475000, -0.137500 }, { -1.000000, 0.000000, -0.000000 },
{ 2.973750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.973750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 2.973750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.475000, 0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.475000, -0.137500 }, { 0.000000, 1.000000, -0.000000 },
{ 3.443750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.443750, -0.475000, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.443750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.443750, -0.475000, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.443750, -0.807500, 0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 3.443750, -0.807500, -0.137500 }, { 1.000000, 0.000000, 0.000000 },
{ 110.0, 110.0, 110.0 } };
//------------------------------------------------------------------------------
void textGeometryBSU (bool full)
{
int i = 0;
bool done = false;
bool Front_Face_Triangles = true;
bool Front_Bevel_Triangles = true;
bool Back_Face_Triangles = true;
bool Back_Bevel_Triangles = true;
bool Side_Triangles = true;
if(!full)
Back_Face_Triangles = Back_Bevel_Triangles = Side_Triangles = false;
glBegin(GL_TRIANGLES);
if( Front_Face_Triangles )
{
i = 0;
done = false;
while(!done)
{
glNormal3fv(data_Front_Face[i+1]);
glVertex3fv(data_Front_Face[i]);
i+=2;
if(data_Front_Face[i][0] > 100.0)
done = true;
}
}
if( Front_Bevel_Triangles )
{
i = 0;
done = false;
while(!done)
{
glNormal3fv(data_Front_Bevel[i+1]);
glVertex3fv(data_Front_Bevel[i]);
i+=2;
if(data_Front_Bevel[i][0] > 100.0)
done = true;
}
}
if( Back_Face_Triangles )
{
i = 0;
done = false;
while(!done)
{
glNormal3fv(data_Back_Face[i+1]);
glVertex3fv(data_Back_Face[i]);
i+=2;
if(data_Back_Face[i][0] > 100.0)
done = true;
}
}
if( Back_Bevel_Triangles )
{
i = 0;
done = false;
while(!done)
{
glNormal3fv(data_Back_Bevel[i+1]);
glVertex3fv(data_Back_Bevel[i]);
i+=2;
if(data_Back_Bevel[i][0] > 100.0)
done = true;
}
}
if( Side_Triangles )
{
i = 0;
done = false;
while(!done)
{
glNormal3fv(data_Side[i+1]);
glVertex3fv(data_Side[i]);
i+=2;
if(data_Side[i][0] > 100.0)
done = true;
}
}
glEnd();
}
| 53.745944 | 90 | 0.570208 | macton |
e189908db1299387f0dfb154280c49f47c939fc8 | 12,640 | cc | C++ | src/MADetectorConstruction.cc | TomSB1423/MuOnArgon | 5a610605ee189cc62cffe702d808a342c5f155a7 | [
"MIT"
] | 2 | 2021-12-12T21:56:43.000Z | 2022-02-09T02:11:47.000Z | src/MADetectorConstruction.cc | yramachers/MuOnArgon | 2fad6acfb5b4868b006ff1748431b5cd23169eb0 | [
"MIT"
] | null | null | null | src/MADetectorConstruction.cc | yramachers/MuOnArgon | 2fad6acfb5b4868b006ff1748431b5cd23169eb0 | [
"MIT"
] | null | null | null | #include "MADetectorConstruction.hh"
#include <cmath>
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4Polyhedra.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4GDMLParser.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4SDManager.hh"
#include "MALiquidSD.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
MADetectorConstruction::MADetectorConstruction()
{
DefineCommand();
DefineMaterials();
}
MADetectorConstruction::~MADetectorConstruction()
{
delete fDetectorMessenger;
}
auto MADetectorConstruction::Construct() -> G4VPhysicalVolume*
{
return SetupCryostat();
}
void MADetectorConstruction::DefineMaterials()
{
G4NistManager* nistManager = G4NistManager::Instance();
nistManager->FindOrBuildMaterial("G4_Galactic");
nistManager->FindOrBuildMaterial("G4_lAr");
nistManager->FindOrBuildMaterial("G4_AIR");
nistManager->FindOrBuildMaterial("G4_STAINLESS-STEEL");
nistManager->FindOrBuildMaterial("G4_Cu");
nistManager->FindOrBuildMaterial("G4_Gd");
auto* C = new G4Element("Carbon", "C", 6., 12.011 * g / mole);
auto* O = new G4Element("Oxygen", "O", 8., 16.00 * g / mole);
auto* Ca = new G4Element("Calcium", "Ca", 20., 40.08 * g / mole);
auto* Mg = new G4Element("Magnesium", "Mg", 12., 24.31 * g / mole);
auto* Gd = new G4Element("Gadolinium", "Gd", 64., 157.25 * g / mole);
// Standard Rock definition, similar to Gran Sasso rock
// with density from PDG report
auto* stdRock = new G4Material("StdRock", 2.65 * g / cm3, 4);
stdRock->AddElement(O, 52.0 * perCent);
stdRock->AddElement(Ca, 27.0 * perCent);
stdRock->AddElement(C, 12.0 * perCent);
stdRock->AddElement(Mg, 9.0 * perCent);
auto* H = new G4Element("Hydrogen", "H", 1., 1.00794 * g / mole);
auto* N = new G4Element("Nitrogen", "N", 7., 14.00 * g / mole);
auto* puMat = new G4Material("polyurethane", 0.3 * g / cm3, 4); // high density foam
puMat->AddElement(H, 16);
puMat->AddElement(O, 2);
puMat->AddElement(C, 8);
puMat->AddElement(N, 2);
// PMMA and PMMA with Gd
G4double density = 1.18 * g / cm3;
auto* pmma = new G4Material("PMMA", density, 3);
pmma->AddElement(H, 8);
pmma->AddElement(C, 5);
pmma->AddElement(O, 2);
auto* pmmagd = new G4Material("PMMAGd", density, 4);
pmmagd->AddElement(H, 53.0 * perCent);
pmmagd->AddElement(C, 33.0 * perCent);
pmmagd->AddElement(O, 13.0 * perCent);
pmmagd->AddElement(Gd, 1.0 * perCent);
}
void MADetectorConstruction::ConstructSDandField()
{
G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
// Only need to construct the (per-thread) SD once
if(!fSD.Get())
{
G4String liquidSDname = "LiquidSD";
MALiquidSD* aliquidSD = new MALiquidSD(liquidSDname,
"LiquidHitsCollection");
fSD.Put(aliquidSD);
// Also only add it once to the SD manager!
G4SDManager::GetSDMpointer()->AddNewDetector(fSD.Get());
SetSensitiveDetector("TPC_log", fSD.Get());
SetSensitiveDetector("IB_log", fSD.Get());
SetSensitiveDetector("OB_log", fSD.Get());
}
else
{
G4cout << " >>> fSD has entry. Repeated call." << G4endl;
}
}
auto MADetectorConstruction::SetupCryostat() -> G4VPhysicalVolume*
{
// Get materials
auto* worldMaterial = G4Material::GetMaterial("G4_Galactic");
auto* larMat = G4Material::GetMaterial("G4_lAr");
auto* airMat = G4Material::GetMaterial("G4_AIR");
auto* steelMat = G4Material::GetMaterial("G4_STAINLESS-STEEL");
auto* copperMat = G4Material::GetMaterial("G4_Cu");
auto* stdRock = G4Material::GetMaterial("StdRock");
auto* puMat = G4Material::GetMaterial("polyurethane");
auto* pmmaMat = G4Material::GetMaterial("PMMA");
auto* pmmagdMat = G4Material::GetMaterial("PMMAGd");
// size parameter, unit [cm]
// cavern
G4double stone = 100.0; // Hall wall thickness 1 m
G4double hallrad = 900.0; // Hall diameter 18 m
G4double hallhheight = 650.0; // Hall height 13 m
// cryostat
G4double tankhside = 570.5; // cryostat cube side 11.41 m
G4double outerwall = 1.2; // outer SS wall thickness
G4double insulation = 62.0; // polyurethane foam
G4double innerwall = 0.12; // inner SS membrane
// octagons, 2 planes in z
const G4double rInner[] = {0.0*cm, 0.0*cm}; // full volume
const G4double rOutTPC[] = {177.5*cm, 177.5*cm};
const G4double rOutAc[] = {182.5*cm, 182.5*cm}; // Acrylic 5cm
const G4double rOutIB[] = {222.5*cm, 222.5*cm}; // Inner Buffer 40cm
const G4double rOutAc2[] = {232.5*cm, 232.5*cm}; // Acrylic+Gd 10cm
const G4double rOutOB[] = {272.5*cm, 272.5*cm}; // Outer Buffer 40cm
const G4double rOutCu[] = {272.6*cm, 272.6*cm}; // Copper 1mm
const G4double zTPC[] = {-175.0*cm, 175.0*cm};
const G4double zAc[] = {-180.0*cm, 180.0*cm};
const G4double zIB[] = {-220.0*cm, 220.0*cm};
const G4double zAc2[] = {-230.0*cm, 230.0*cm};
const G4double zOB[] = {-270.0*cm, 270.0*cm};
const G4double zCu[] = {-270.1*cm, 270.1*cm};
// total
G4double offset =
hallhheight - tankhside; // shift cavern floor to keep detector centre at origin
G4double worldside = hallhheight + stone + offset + 0.1; // larger than rest
G4double larside =
tankhside - outerwall - insulation - innerwall; // cube side of LAr volume
fvertexZ = (worldside - stone - 0.1) * cm; // max vertex height
fmaxrad = (hallrad + stone) * cm; // max vertex circle radius
// Volumes for this geometry
//
// World
//
auto* worldSolid = new G4Tubs("World", 0.0 * cm, (hallrad + stone + 0.1) * cm,
(hallhheight + stone + offset + 0.1) * cm, 0.0, CLHEP::twopi);
auto* fWorldLogical = new G4LogicalVolume(worldSolid, worldMaterial, "World_log");
auto* fWorldPhysical = new G4PVPlacement(nullptr, G4ThreeVector(), fWorldLogical,
"World_phys", nullptr, false, 0);
//
// Cavern
//
auto* cavernSolid = new G4Tubs("Cavern", 0.0 * cm, (hallrad + stone) * cm,
(hallhheight + stone) * cm, 0.0, CLHEP::twopi);
auto* fCavernLogical = new G4LogicalVolume(cavernSolid, stdRock, "Cavern_log");
auto* fCavernPhysical =
new G4PVPlacement(nullptr, G4ThreeVector(0., 0., 0.), fCavernLogical,
"Cavern_phys", fWorldLogical, false, 0);
//
// Hall
//
auto* hallSolid = new G4Tubs("Hall", 0.0 * cm, hallrad * cm, hallhheight * cm, 0.0, CLHEP::twopi);
auto* fHallLogical = new G4LogicalVolume(hallSolid, airMat, "Hall_log");
auto* fHallPhysical =
new G4PVPlacement(nullptr, G4ThreeVector(0., 0., 0.), fHallLogical,
"Hall_phys", fCavernLogical, false, 0, true);
//
// Tank
//
auto* tankSolid = new G4Box("Tank", tankhside * cm, tankhside * cm, tankhside * cm);
auto* fTankLogical = new G4LogicalVolume(tankSolid, steelMat, "Tank_log");
auto* fTankPhysical =
new G4PVPlacement(nullptr, G4ThreeVector(0., 0., -offset * cm), fTankLogical,
"Tank_phys", fHallLogical, false, 0, true);
//
// Insulator
//
auto* puSolid = new G4Box("Insulator", (tankhside - outerwall) * cm,
(tankhside - outerwall) * cm, (tankhside - outerwall) * cm);
auto* fPuLogical = new G4LogicalVolume(puSolid, puMat, "Pu_log");
auto* fPuPhysical = new G4PVPlacement(nullptr, G4ThreeVector(), fPuLogical, "Pu_phys",
fTankLogical, false, 0, true);
//
// Membrane
//
auto* membraneSolid = new G4Box("Membrane", (tankhside - outerwall - insulation) * cm,
(tankhside - outerwall - insulation) * cm,
(tankhside - outerwall - insulation) * cm);
auto* fMembraneLogical = new G4LogicalVolume(membraneSolid, steelMat, "Membrane_log");
auto* fMembranePhysical =
new G4PVPlacement(nullptr, G4ThreeVector(), fMembraneLogical, "Membrane_phys",
fPuLogical, false, 0, true);
//
// LAr filling box
//
auto* larSolid = new G4Box("LAr", larside * cm, larside * cm, larside * cm);
auto* fLarLogical = new G4LogicalVolume(larSolid, larMat, "Lar_log");
auto* fLarPhysical = new G4PVPlacement(nullptr, G4ThreeVector(), fLarLogical,
"Lar_phys", fMembraneLogical, false, 0, true);
//
// copper Faraday cage
//
G4int nSides = 8; // regular Octagon
G4int nPlanes = 2;
auto* copperSolid = new G4Polyhedra("Copper", 0.0, CLHEP::twopi, nSides, nPlanes,
zCu, rInner, rOutCu);
auto* fCuLogical = new G4LogicalVolume(copperSolid, copperMat, "Cu_log");
auto* fCuPhysical = new G4PVPlacement(nullptr, G4ThreeVector(), fCuLogical,
"Cu_phys", fLarLogical, false, 0, true);
//
// LAr Outer buffer
//
auto* obSolid = new G4Polyhedra("OuterB", 0.0, CLHEP::twopi, nSides, nPlanes,
zOB, rInner, rOutOB);
auto* fOBLogical = new G4LogicalVolume(obSolid, larMat, "OB_log");
auto* fOBPhysical = new G4PVPlacement(nullptr, G4ThreeVector(), fOBLogical,
"OB_phys", fCuLogical, false, 0, true);
//
// Acrylic + Gd
//
auto* ac2Solid = new G4Polyhedra("PMMAGd", 0.0, CLHEP::twopi, nSides, nPlanes,
zAc2, rInner, rOutAc2);
auto* fAc2Logical = new G4LogicalVolume(ac2Solid, pmmagdMat, "Ac2_log");
auto* fAc2Physical = new G4PVPlacement(nullptr, G4ThreeVector(), fAc2Logical,
"Ac2_phys", fOBLogical, false, 0, true);
//
// LAr Inner buffer
//
auto* ibSolid = new G4Polyhedra("InnerB", 0.0, CLHEP::twopi, nSides, nPlanes,
zIB, rInner, rOutIB);
auto* fIBLogical = new G4LogicalVolume(ibSolid, larMat, "IB_log");
auto* fIBPhysical = new G4PVPlacement(nullptr, G4ThreeVector(), fIBLogical,
"IB_phys", fAc2Logical, false, 0, true);
//
// Acrylic shell
//
auto* acSolid = new G4Polyhedra("PMMA", 0.0, CLHEP::twopi, nSides, nPlanes,
zAc, rInner, rOutAc);
auto* fAcLogical = new G4LogicalVolume(acSolid, pmmaMat, "Ac_log");
auto* fAcPhysical = new G4PVPlacement(nullptr, G4ThreeVector(), fAcLogical,
"Ac_phys", fIBLogical, false, 0, true);
//
// TPC
//
auto* tpcSolid = new G4Polyhedra("TPC", 0.0, CLHEP::twopi, nSides, nPlanes,
zTPC, rInner, rOutTPC);
auto* fTPCLogical = new G4LogicalVolume(tpcSolid, larMat, "TPC_log");
auto* fTPCPhysical = new G4PVPlacement(nullptr, G4ThreeVector(), fTPCLogical,
"TPC_phys", fAcLogical, false, 0, true);
//
// Visualization attributes
//
fWorldLogical->SetVisAttributes(G4VisAttributes::GetInvisible());
auto* redVisAtt = new G4VisAttributes(G4Colour::Red());
redVisAtt->SetVisibility(true);
auto* greyVisAtt = new G4VisAttributes(G4Colour::Grey());
greyVisAtt->SetVisibility(true);
auto* greenVisAtt = new G4VisAttributes(G4Colour::Green());
greenVisAtt->SetVisibility(true);
auto* blueVisAtt = new G4VisAttributes(G4Colour::Blue());
blueVisAtt->SetVisibility(true);
fCavernLogical->SetVisAttributes(redVisAtt);
fHallLogical->SetVisAttributes(greyVisAtt);
fTankLogical->SetVisAttributes(blueVisAtt);
fPuLogical->SetVisAttributes(greyVisAtt);
fMembraneLogical->SetVisAttributes(blueVisAtt);
fLarLogical->SetVisAttributes(greyVisAtt);
fCuLogical->SetVisAttributes(greenVisAtt);
return fWorldPhysical;
}
void MADetectorConstruction::ExportGeometry(const G4String& file)
{
G4GDMLParser parser;
parser.Write(file);
}
void MADetectorConstruction::DefineCommand()
{
// Define geometry command directory using generic messenger class
fDetectorMessenger = new G4GenericMessenger(this, "/MA/detector/",
"Commands for controlling detector setup");
// GDML Export
fDetectorMessenger
->DeclareMethod("exportGeometry", &MADetectorConstruction::ExportGeometry)
.SetGuidance("Export current geometry to a GDML file")
.SetParameterName("filename", false)
.SetDefaultValue("wlgd.gdml")
.SetStates(G4State_Idle)
.SetToBeBroadcasted(false);
}
| 38.187311 | 100 | 0.63125 | TomSB1423 |
e192dcdbb10d6a20aa17f678919c3461acf9c243 | 704 | cpp | C++ | ejercicio1/src/Socio.cpp | matbentancur/pav | df556249e342863286ad1c991a5613bd63e09902 | [
"MIT"
] | null | null | null | ejercicio1/src/Socio.cpp | matbentancur/pav | df556249e342863286ad1c991a5613bd63e09902 | [
"MIT"
] | 1 | 2018-04-05T15:06:04.000Z | 2018-04-15T21:46:44.000Z | ejercicio1/src/Socio.cpp | matbentancur/pav | df556249e342863286ad1c991a5613bd63e09902 | [
"MIT"
] | null | null | null | #include "Socio.h"
Socio::Socio() {
//contrutuctor
}
Socio::Socio(DtSocio& dtSocio) {
this->CI = dtSocio.getCI();
this->nombre = dtSocio.getNombre();
}
Socio::Socio(string CI, string nombre) {
this->CI = CI;
this->nombre = nombre;
}
Socio::~Socio() {
//destructor
}
string Socio::getCI(){
return this->CI;
}
void Socio::setCI(string CI){
this->CI = CI;
}
string Socio::getNombre(){
return this->nombre;
}
void Socio::setNombre(string nombre){
this->nombre = nombre;
}
ostream& operator << (ostream& salida, const Socio& socio) {
salida <<
"Cedula: " << socio.CI << "\n" <<
"Nombre: " << socio.nombre << "\n"
;
return salida;
}
| 16 | 60 | 0.582386 | matbentancur |
e198247c4cce39d2fa326f0bf8d8cd2a222c2d3b | 45,872 | inl | C++ | src/Framework/Collision/CollisionDetectionAlgorithm.inl | Oncle-Ha/peridyno | 7952252923d637685bf3a982856aca8095b78c50 | [
"Apache-2.0"
] | 22 | 2021-05-26T09:19:07.000Z | 2022-03-28T04:06:21.000Z | src/Framework/Collision/CollisionDetectionAlgorithm.inl | Oncle-Ha/peridyno | 7952252923d637685bf3a982856aca8095b78c50 | [
"Apache-2.0"
] | 1 | 2021-07-27T09:43:42.000Z | 2022-02-07T14:47:18.000Z | src/Framework/Collision/CollisionDetectionAlgorithm.inl | Oncle-Ha/peridyno | 7952252923d637685bf3a982856aca8095b78c50 | [
"Apache-2.0"
] | 11 | 2021-04-24T03:43:33.000Z | 2022-03-11T14:09:21.000Z | #include "Topology/Primitive3D.h"
namespace dyno
{
struct ClipVertex
{
Vector<Real, 3> v;
};
template<typename Real>
DYN_FUNC float fsign(Real v)
{
return v < 0 ? -Real(1) : Real(1);
}
//--------------------------------------------------------------------------------------------------
// qBoxtoBox
//--------------------------------------------------------------------------------------------------
template<typename Real>
DYN_FUNC inline bool trackFaceAxis(int& axis, Real& sMax, Vector<Real, 3>& axisNormal, int n, Real s, const Vector<Real, 3>& normal)
{
if (s > Real(0))
return true;
if (s > sMax)
{
sMax = s;
axis = n;
axisNormal = normal;
}
return false;
}
//--------------------------------------------------------------------------------------------------
template<typename Real>
DYN_FUNC inline bool trackEdgeAxis(int& axis, Real& sMax, Vector<Real, 3>& axisNormal, int n, Real s, const Vector<Real, 3>& normal)
{
if (s > Real(0))
return true;
Real l = Real(1) / normal.norm();
s *= l;
if (s > sMax)
{
sMax = s;
axis = n;
axisNormal = normal * l;
}
return false;
}
template<typename Real>
//--------------------------------------------------------------------------------------------------
DYN_FUNC void computeReferenceEdgesAndBasis(unsigned char* out, SquareMatrix<Real, 3>* basis, Vector<Real, 3>* e, const Vector<Real, 3>& eR, const Transform<Real, 3>& rtx, Vector<Real, 3> n, int axis)
{
n = rtx.rotation().transpose()*n;
if (axis >= 3)
axis -= 3;
auto rot_t = rtx.rotation();
SquareMatrix<Real, 3> outB;
switch (axis)
{
case 0:
if (n.x > Real(0.0))
{
out[0] = 1;
out[1] = 8;
out[2] = 7;
out[3] = 9;
*e = Vector<Real, 3>(eR.y, eR.z, eR.x);
//basis->SetRows(rtx.rotation.ey, rtx.rotation.ez, rtx.rotation.ex);
outB.setCol(0, rot_t.col(1));
outB.setCol(1, rot_t.col(2));
outB.setCol(2, rot_t.col(0));
}
else
{
out[0] = 11;
out[1] = 3;
out[2] = 10;
out[3] = 5;
*e = Vector<Real, 3>(eR.z, eR.y, eR.x);
//basis->SetRows(rtx.rotation.ez, rtx.rotation.ey, -rtx.rotation.ex);
outB.setCol(0, rot_t.col(2));
outB.setCol(1, rot_t.col(1));
outB.setCol(2, -rot_t.col(0));
}
break;
case 1:
if (n.y > Real(0.0))
{
out[0] = 0;
out[1] = 1;
out[2] = 2;
out[3] = 3;
*e = Vector<Real, 3>(eR.z, eR.x, eR.y);
//basis->SetRows(rtx.rotation.ez, rtx.rotation.ex, rtx.rotation.ey);
outB.setCol(0, rot_t.col(2));
outB.setCol(1, rot_t.col(0));
outB.setCol(2, rot_t.col(1));
}
else
{
out[0] = 4;
out[1] = 5;
out[2] = 6;
out[3] = 7;
*e = Vector<Real, 3>(eR.z, eR.x, eR.y);
//basis->SetRows(rtx.rotation.ez, -rtx.rotation.ex, -rtx.rotation.ey);
outB.setCol(0, rot_t.col(2));
outB.setCol(1, -rot_t.col(0));
outB.setCol(2, -rot_t.col(1));
}
break;
case 2:
if (n.z > Real(0.0))
{
out[0] = 11;
out[1] = 4;
out[2] = 8;
out[3] = 0;
*e = Vector<Real, 3>(eR.y, eR.x, eR.z);
//basis->SetRows(-rtx.rotation.ey, rtx.rotation.ex, rtx.rotation.ez);
outB.setCol(0, -rot_t.col(1));
outB.setCol(1, rot_t.col(0));
outB.setCol(2, rot_t.col(2));
}
else
{
out[0] = 6;
out[1] = 10;
out[2] = 2;
out[3] = 9;
*e = Vector<Real, 3>(eR.y, eR.x, eR.z);
//basis->SetRows(-rtx.rotation.ey, -rtx.rotation.ex, -rtx.rotation.ez);
outB.setCol(0, -rot_t.col(1));
outB.setCol(1, -rot_t.col(0));
outB.setCol(2, -rot_t.col(2));
}
break;
}
*basis = outB;
}
//--------------------------------------------------------------------------------------------------
template<typename Real>
DYN_FUNC void computeIncidentFace(ClipVertex* out, const Transform<Real, 3>& itx, const Vector<Real, 3>& e, Vector<Real, 3> n)
{
n = -itx.rotation().transpose()*n;
Vector<Real, 3> absN = abs(n);
if (absN.x > absN.y && absN.x > absN.z)
{
if (n.x > Real(0.0))
{
out[0].v = Vector<Real, 3>(e.x, e.y, -e.z);
out[1].v = Vector<Real, 3>(e.x, e.y, e.z);
out[2].v = Vector<Real, 3>(e.x, -e.y, e.z);
out[3].v = Vector<Real, 3>(e.x, -e.y, -e.z);
}
else
{
out[0].v = Vector<Real, 3>(-e.x, -e.y, e.z);
out[1].v = Vector<Real, 3>(-e.x, e.y, e.z);
out[2].v = Vector<Real, 3>(-e.x, e.y, -e.z);
out[3].v = Vector<Real, 3>(-e.x, -e.y, -e.z);
}
}
else if (absN.y > absN.x && absN.y > absN.z)
{
if (n.y > Real(0.0))
{
out[0].v = Vector<Real, 3>(-e.x, e.y, e.z);
out[1].v = Vector<Real, 3>(e.x, e.y, e.z);
out[2].v = Vector<Real, 3>(e.x, e.y, -e.z);
out[3].v = Vector<Real, 3>(-e.x, e.y, -e.z);
}
else
{
out[0].v = Vector<Real, 3>(e.x, -e.y, e.z);
out[1].v = Vector<Real, 3>(-e.x, -e.y, e.z);
out[2].v = Vector<Real, 3>(-e.x, -e.y, -e.z);
out[3].v = Vector<Real, 3>(e.x, -e.y, -e.z);
}
}
else
{
if (n.z > Real(0.0))
{
out[0].v = Vector<Real, 3>(-e.x, e.y, e.z);
out[1].v = Vector<Real, 3>(-e.x, -e.y, e.z);
out[2].v = Vector<Real, 3>(e.x, -e.y, e.z);
out[3].v = Vector<Real, 3>(e.x, e.y, e.z);
}
else
{
out[0].v = Vector<Real, 3>(e.x, -e.y, -e.z);
out[1].v = Vector<Real, 3>(-e.x, -e.y, -e.z);
out[2].v = Vector<Real, 3>(-e.x, e.y, -e.z);
out[3].v = Vector<Real, 3>(e.x, e.y, -e.z);
}
}
for (int i = 0; i < 4; ++i)
out[i].v = itx * out[i].v;
}
//--------------------------------------------------------------------------------------------------
#define InFront( a ) \
((a) < float( 0.0 ))
#define Behind( a ) \
((a) >= float( 0.0 ))
#define On( a ) \
((a) < float( 0.005 ) && (a) > -float( 0.005 ))
template<typename Real>
DYN_FUNC int orthographic(ClipVertex* out, Real sign, Real e, int axis, int clipEdge, ClipVertex* in, int inCount)
{
int outCount = 0;
ClipVertex a = in[inCount - 1];
for (int i = 0; i < inCount; ++i)
{
ClipVertex b = in[i];
Real da = sign * a.v[axis] - e;
Real db = sign * b.v[axis] - e;
ClipVertex cv;
// B
if (((InFront(da) && InFront(db)) || On(da) || On(db)))
{
out[outCount++] = b;
}
// I
else if (InFront(da) && Behind(db))
{
cv.v = a.v + (b.v - a.v) * (da / (da - db));
out[outCount++] = cv;
}
else if (Behind(da) && InFront(db))
{
cv.v = a.v + (b.v - a.v) * (da / (da - db));
out[outCount++] = cv;
out[outCount++] = b;
}
a = b;
}
return outCount;
}
//--------------------------------------------------------------------------------------------------
// Resources (also see q3BoxtoBox's resources):
// http://www.randygaul.net/2013/10/27/sutherland-hodgman-clipping/
template<typename Real>
DYN_FUNC int clip(ClipVertex* outVerts, float* outDepths, const Vector<Real, 3>& rPos, const Vector<Real, 3>& e, unsigned char* clipEdges, const SquareMatrix<Real, 3>& basis, ClipVertex* incident)
{
int inCount = 4;
int outCount;
ClipVertex in[8];
ClipVertex out[8];
for (int i = 0; i < 4; ++i)
in[i].v = basis.transpose()*(incident[i].v - rPos);
outCount = orthographic(out, Real(1.0), e.x, 0, clipEdges[0], in, inCount);
if (outCount == 0)
return 0;
inCount = orthographic(in, Real(1.0), e.y, 1, clipEdges[1], out, outCount);
if (inCount == 0)
return 0;
outCount = orthographic(out, Real(-1.0), e.x, 0, clipEdges[2], in, inCount);
if (outCount == 0)
return 0;
inCount = orthographic(in, Real(-1.0), e.y, 1, clipEdges[3], out, outCount);
// Keep incident vertices behind the reference face
outCount = 0;
for (int i = 0; i < inCount; ++i)
{
Real d = in[i].v.z - e.z;
if (d <= Real(0.0))
{
outVerts[outCount].v = basis * in[i].v + rPos;
outDepths[outCount++] = d;
}
}
//assert(outCount <= 8);
return outCount;
}
//--------------------------------------------------------------------------------------------------
template<typename Real>
DYN_FUNC inline void edgesContact(Vector<Real, 3>& CA, Vector<Real, 3>& CB, const Vector<Real, 3>& PA, const Vector<Real, 3>& QA, const Vector<Real, 3>& PB, const Vector<Real, 3>& QB)
{
Vector<Real, 3> DA = QA - PA;
Vector<Real, 3> DB = QB - PB;
Vector<Real, 3> r = PA - PB;
Real a = DA.dot(DA);
Real e = DB.dot(DB);
Real f = DB.dot(r);
Real c = DA.dot(r);
Real b = DA.dot(DB);
Real denom = a * e - b * b;
Real TA = (b * f - c * e) / denom;
Real TB = (b * TA + f) / e;
CA = PA + DA * TA;
CB = PB + DB * TB;
}
//--------------------------------------------------------------------------------------------------
template<typename Real>
DYN_FUNC void computeSupportEdge(Vector<Real, 3>& aOut, Vector<Real, 3>& bOut, const SquareMatrix<Real, 3>& rot, const Vector<Real, 3>& trans, const Vector<Real, 3>& e, Vector<Real, 3> n)
{
n = rot.transpose()*n;
Vector<Real, 3> absN = abs(n);
Vector<Real, 3> a, b;
// x > y
if (absN.x > absN.y)
{
// x > y > z
if (absN.y > absN.z)
{
a = Vector<Real, 3>(e.x, e.y, e.z);
b = Vector<Real, 3>(e.x, e.y, -e.z);
}
// x > z > y || z > x > y
else
{
a = Vector<Real, 3>(e.x, e.y, e.z);
b = Vector<Real, 3>(e.x, -e.y, e.z);
}
}
// y > x
else
{
// y > x > z
if (absN.x > absN.z)
{
a = Vector<Real, 3>(e.x, e.y, e.z);
b = Vector<Real, 3>(e.x, e.y, -e.z);
}
// z > y > x || y > z > x
else
{
a = Vector<Real, 3>(e.x, e.y, e.z);
b = Vector<Real, 3>(-e.x, e.y, e.z);
}
}
Real signx = fsign(n.x);
Real signy = fsign(n.y);
Real signz = fsign(n.z);
a.x *= signx;
a.y *= signy;
a.z *= signz;
b.x *= signx;
b.y *= signy;
b.z *= signz;
aOut = rot * trans + a;
bOut = rot * trans + b;
}
template<typename Real>
DYN_FUNC void CollisionDetection<Real>::request(Manifold& m, const OBox3D box0, const OBox3D box1)
{
m.contactCount = 0;
Coord3D v = box1.center - box0.center;
Coord3D eA = box0.extent;
Coord3D eB = box1.extent;
Matrix3D rotA;
rotA.setCol(0, box0.u);
rotA.setCol(1, box0.v);
rotA.setCol(2, box0.w);
Matrix3D rotB;
rotB.setCol(0, box1.u);
rotB.setCol(1, box1.v);
rotB.setCol(2, box1.w);
// B's frame in A's space
Matrix3D C = rotA.transpose() * rotB;
Matrix3D absC;
bool parallel = false;
const float kCosTol = float(1.0e-6);
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
{
float val = abs(C(i, j));
absC(i, j) = val;
if (val + kCosTol >= float(1.0))
parallel = true;
}
}
Matrix3D C_t = C.transpose();
Matrix3D absC_t = absC.transpose();
// Vector from center A to center B in A's space
Coord3D t = rotA.transpose() * v;
// Query states
Real s;
Real aMax = -REAL_MAX;
Real bMax = -REAL_MAX;
float eMax = -REAL_MAX;
int aAxis = ~0;
int bAxis = ~0;
int eAxis = ~0;
Coord3D nA;
Coord3D nB;
Coord3D nE;
// Face axis checks
// a's x axis
s = abs(t.x) - (box0.extent.x + absC_t.col(0).dot(box1.extent));
if (trackFaceAxis(aAxis, aMax, nA, 0, s, rotA.col(0)))
return;
// a's y axis
s = abs(t.y) - (box0.extent.y + absC_t.col(1).dot(box1.extent));
if (trackFaceAxis(aAxis, aMax, nA, 1, s, rotA.col(1)))
return;
// a's z axis
s = abs(t.z) - (box0.extent.z + absC_t.col(2).dot(box1.extent));
if (trackFaceAxis(aAxis, aMax, nA, 2, s, rotA.col(2)))
return;
// b's x axis
s = abs(t.dot(C.col(0))) - (box1.extent.x + absC.col(0).dot(box0.extent));
if (trackFaceAxis(bAxis, bMax, nB, 3, s, rotB.col(0)))
return;
// b's y axis
s = abs(t.dot(C.col(1))) - (box1.extent.y + absC.col(1).dot(box0.extent));
if (trackFaceAxis(bAxis, bMax, nB, 4, s, rotB.col(1)))
return;
// b's z axis
s = abs(t.dot(C.col(2))) - (box1.extent.z + absC.col(2).dot(box0.extent));
if (trackFaceAxis(bAxis, bMax, nB, 5, s, rotB.col(2)))
return;
if (!parallel)
{
// Edge axis checks
float rA;
float rB;
// Cross( a.x, b.x )
rA = eA.y * absC(2, 0) + eA.z * absC(1, 0);
rB = eB.y * absC(0, 2) + eB.z * absC(0, 1);
s = abs(t.z * C(1, 0) - t.y * C(2, 0)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 6, s, Coord3D(float(0.0), -C(2, 0), C(1, 0))))
return;
// Cross( a.x, b.y )
rA = eA.y * absC(2, 1) + eA.z * absC(1, 1);
rB = eB.x * absC(0, 2) + eB.z * absC(0, 0);
s = abs(t.z * C(1, 1) - t.y * C(2, 1)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 7, s, Coord3D(float(0.0), -C(2, 1), C(1, 1))))
return;
// Cross( a.x, b.z )
rA = eA.y * absC(2, 2) + eA.z * absC(1, 2);
rB = eB.x * absC(0, 1) + eB.y * absC(0, 0);
s = abs(t.z * C(1, 2) - t.y * C(2, 2)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 8, s, Coord3D(float(0.0), -C(2, 2), C(1, 2))))
return;
// Cross( a.y, b.x )
rA = eA.x * absC(2, 0) + eA.z * absC(0, 0);
rB = eB.y * absC(1, 2) + eB.z * absC(1, 1);
s = abs(t.x * C(2, 0) - t.z * C(0, 0)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 9, s, Coord3D(C(2, 0), float(0.0), -C(0, 0))))
return;
// Cross( a.y, b.y )
rA = eA.x * absC(2, 1) + eA.z * absC(0, 1);
rB = eB.x * absC(1, 2) + eB.z * absC(1, 0);
s = abs(t.x * C(2, 1) - t.z * C(0, 1)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 10, s, Coord3D(C(2, 1), float(0.0), -C(0, 1))))
return;
// Cross( a.y, b.z )
rA = eA.x * absC(2, 2) + eA.z * absC(0, 2);
rB = eB.x * absC(1, 1) + eB.y * absC(1, 0);
s = abs(t.x * C(2, 2) - t.z * C(0, 2)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 11, s, Coord3D(C(2, 2), float(0.0), -C(0, 2))))
return;
// Cross( a.z, b.x )
rA = eA.x * absC(1, 0) + eA.y * absC(0, 0);
rB = eB.y * absC(2, 2) + eB.z * absC(2, 1);
s = abs(t.y * C(0, 0) - t.x * C(1, 0)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 12, s, Coord3D(-C(1, 0), C(0, 0), float(0.0))))
return;
// Cross( a.z, b.y )
rA = eA.x * absC(1, 1) + eA.y * absC(0, 1);
rB = eB.x * absC(2, 2) + eB.z * absC(2, 0);
s = abs(t.y * C(0, 1) - t.x * C(1, 1)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 13, s, Coord3D(-C(1, 1), C(0, 1), float(0.0))))
return;
// Cross( a.z, b.z )
rA = eA.x * absC(1, 2) + eA.y * absC(0, 2);
rB = eB.x * absC(2, 1) + eB.y * absC(2, 0);
s = abs(t.y * C(0, 2) - t.x * C(1, 2)) - (rA + rB);
if (trackEdgeAxis(eAxis, eMax, nE, 14, s, Coord3D(-C(1, 2), C(0, 2), float(0.0))))
return;
}
// Artificial axis bias to improve frame coherence
const float kRelTol = float(0.95);
const float kAbsTol = float(0.01);
int axis;
float sMax;
Coord3D n;
float faceMax = std::max(aMax, bMax);
if (kRelTol * eMax > faceMax + kAbsTol)
{
axis = eAxis;
sMax = eMax;
n = nE;
}
else
{
if (kRelTol * bMax > aMax + kAbsTol)
{
axis = bAxis;
sMax = bMax;
n = nB;
}
else
{
axis = aAxis;
sMax = aMax;
n = nA;
}
}
if (n.dot(v) < float(0.0))
n = -n;
if (axis == ~0)
return;
Transform3D atx(box0.center, rotA);
Transform3D btx(box1.center, rotB);
if (axis < 6)
{
Transform3D rtx;
Transform3D itx;
Coord3D eR;
Coord3D eI;
bool flip;
if (axis < 3)
{
rtx = atx;
itx = btx;
eR = eA;
eI = eB;
flip = false;
}
else
{
rtx = btx;
itx = atx;
eR = eB;
eI = eA;
flip = true;
n = -n;
}
// Compute reference and incident edge information necessary for clipping
ClipVertex incident[4];
computeIncidentFace(incident, itx, eI, n);
unsigned char clipEdges[4];
Matrix3D basis;
Coord3D e;
computeReferenceEdgesAndBasis(clipEdges, &basis, &e, eR, rtx, n, axis);
// Clip the incident face against the reference face side planes
ClipVertex out[8];
float depths[8];
int outNum;
outNum = clip(out, depths, rtx.translation(), e, clipEdges, basis, incident);
if (outNum)
{
m.contactCount = outNum;
m.normal = flip ? -n : n;
for (int i = 0; i < outNum; ++i)
{
m.contacts[i].position = out[i].v;
m.contacts[i].penetration = depths[i];
}
}
}
else
{
n = rotA * n;
if (n.dot(v) < float(0.0))
n = -n;
Coord3D PA, QA;
Coord3D PB, QB;
computeSupportEdge(PA, QA, rotA, box0.center, eA, n);
computeSupportEdge(PB, QB, rotB, box1.center, eB, -n);
Coord3D CA, CB;
edgesContact(CA, CB, PA, QA, PB, QB);
m.normal = n;
m.contactCount = 1;
m.contacts[0].penetration = sMax;
m.contacts[0].position = (CA + CB) * float(0.5);
}
}
template<typename Real>
DYN_FUNC void CollisionDetection<Real>::request(Manifold& m, const Sphere3D& sphere, const OBox3D& box)
{
m.contactCount = 0;
Point3D c0(sphere.center);
Real r0 = sphere.radius;
Point3D vproj = c0.project(box);
bool bInside = c0.inside(box);
Segment3D dir = bInside ? c0 - vproj : vproj - c0;
Real sMax = bInside ? -dir.direction().norm() - r0 : dir.direction().norm() - r0;
if (sMax >= 0)
return;
m.normal = dir.direction().normalize();
m.contacts[0].penetration = sMax;
m.contacts[0].position = vproj.origin;
m.contactCount = 1;
}
template<typename Real>
DYN_FUNC void CollisionDetection<Real>::request(Manifold& m, const OBox3D& box, const Sphere3D& sphere)
{
request(m, sphere, box);
m.normal = -m.normal;
}
template<typename Real>
DYN_FUNC void CollisionDetection<Real>::request(Manifold& m, const Sphere3D& sphere0, const Sphere3D& sphere1)
{
m.contactCount = 0;
auto c0 = sphere0.center;
auto c1 = sphere1.center;
Real r0 = sphere0.radius;
Real r1 = sphere1.radius;
auto dir = c1 - c0;
Real sMax = dir.norm() - r0 - r1;
if (sMax >= 0)
return;
m.normal = dir.normalize();
m.contacts[0].penetration = sMax;
m.contacts[0].position = c0 + (r0 - 0.5 * sMax) * m.normal;
m.contactCount = 1;
}
template<typename Real>
DYN_FUNC inline bool checkOverlap(
Real lowerBoundary1,
Real upperBoundary1,
Real lowerBoundary2,
Real upperBoundary2,
Real& intersectionDistance,
Real& boundary1,
Real& boundary2
)
{
if (!((lowerBoundary1 > upperBoundary2) || (lowerBoundary2 > upperBoundary1)))
{
if (lowerBoundary1 < lowerBoundary2)
{
if (upperBoundary1 > upperBoundary2)
{
intersectionDistance = upperBoundary2 - lowerBoundary2;
if (upperBoundary2 - lowerBoundary1 > upperBoundary1 - lowerBoundary2)
{
boundary1 = upperBoundary1;
boundary2 = lowerBoundary2;
}
else
{
boundary1 = lowerBoundary1;
boundary2 = upperBoundary2;
}
}
else
{
intersectionDistance = upperBoundary1 - lowerBoundary2;
boundary1 = upperBoundary1;
boundary2 = lowerBoundary2;
}
}
else
{
if (upperBoundary1 > upperBoundary2)
{
intersectionDistance = upperBoundary2 - lowerBoundary1;
boundary1 = lowerBoundary1;
boundary2 = upperBoundary2;
}
else
{
intersectionDistance = upperBoundary1 - lowerBoundary1;
if (upperBoundary2 - lowerBoundary1 > upperBoundary1 - lowerBoundary2)
{
boundary1 = upperBoundary1;
boundary2 = lowerBoundary2;
}
else
{
boundary1 = lowerBoundary1;
boundary2 = upperBoundary2;
}
}
}
return true;
}
intersectionDistance = Real(0.0f);
return false;
}
template<typename Real>
DYN_FUNC inline bool checkOverlapAxis(
Real& lowerBoundary1,
Real& upperBoundary1,
Real& lowerBoundary2,
Real& upperBoundary2,
Real& intersectionDistance,
Real& boundary1,
Real& boundary2,
const Vector<Real, 3> axisNormal,
Tet3D tet1,
Tet3D tet2)
{
//projection to axis
for (int i = 0; i < 4; i++)
{
if (i == 0)
{
lowerBoundary1 = upperBoundary1 = tet1.v[0].dot(axisNormal);
lowerBoundary2 = upperBoundary2 = tet2.v[0].dot(axisNormal);
}
else
{
lowerBoundary1 = glm::min(lowerBoundary1, tet1.v[i].dot(axisNormal));
lowerBoundary2 = glm::min(lowerBoundary2, tet2.v[i].dot(axisNormal));
upperBoundary1 = glm::max(upperBoundary1, tet1.v[i].dot(axisNormal));
upperBoundary2 = glm::max(upperBoundary2, tet2.v[i].dot(axisNormal));
}
}
/*printf(" axis = %.3lf %.3lf %.3lf\nlb1 = %.3lf lb2 = %.3lf\nub1 = %.3lf ub2 = %.3lf\n",
axisNormal[0], axisNormal[1], axisNormal[2],
lowerBoundary1, lowerBoundary2,
upperBoundary1, upperBoundary2
);*/
return checkOverlap(lowerBoundary1, upperBoundary1, lowerBoundary2, upperBoundary2, intersectionDistance, boundary1, boundary2);
}
template<typename Real>
DYN_FUNC inline bool checkOverlapAxis(
Real& lowerBoundary1,
Real& upperBoundary1,
Real& lowerBoundary2,
Real& upperBoundary2,
Real& intersectionDistance,
Real& boundary1,
Real& boundary2,
const Vector<Real, 3> axisNormal,
Tet3D tet,
OrientedBox3D box)
{
//projection to axis
for (int i = 0; i < 4; i++)
{
if (i == 0)
lowerBoundary1 = upperBoundary1 = tet.v[0].dot(axisNormal);
else
{
lowerBoundary1 = glm::min(lowerBoundary1, tet.v[i].dot(axisNormal));
upperBoundary1 = glm::max(upperBoundary1, tet.v[i].dot(axisNormal));
}
}
Coord3D center = box.center;
Coord3D u = box.u;
Coord3D v = box.v;
Coord3D w = box.w;
Coord3D extent = box.extent;
Coord3D p;
p = (center - u * extent[0] - v * extent[1] - w * extent[2]);
lowerBoundary2 = upperBoundary2 = p.dot(axisNormal);
p = (center - u * extent[0] - v * extent[1] + w * extent[2]);
lowerBoundary2 = glm::min(lowerBoundary2, p.dot(axisNormal));
upperBoundary2 = glm::max(upperBoundary2, p.dot(axisNormal));
p = (center - u * extent[0] + v * extent[1] - w * extent[2]);
lowerBoundary2 = glm::min(lowerBoundary2, p.dot(axisNormal));
upperBoundary2 = glm::max(upperBoundary2, p.dot(axisNormal));
p = (center - u * extent[0] + v * extent[1] + w * extent[2]);
lowerBoundary2 = glm::min(lowerBoundary2, p.dot(axisNormal));
upperBoundary2 = glm::max(upperBoundary2, p.dot(axisNormal));
p = (center + u * extent[0] - v * extent[1] - w * extent[2]);
lowerBoundary2 = glm::min(lowerBoundary2, p.dot(axisNormal));
upperBoundary2 = glm::max(upperBoundary2, p.dot(axisNormal));
p = (center + u * extent[0] - v * extent[1] + w * extent[2]);
lowerBoundary2 = glm::min(lowerBoundary2, p.dot(axisNormal));
upperBoundary2 = glm::max(upperBoundary2, p.dot(axisNormal));
p = (center + u * extent[0] + v * extent[1] - w * extent[2]);
lowerBoundary2 = glm::min(lowerBoundary2, p.dot(axisNormal));
upperBoundary2 = glm::max(upperBoundary2, p.dot(axisNormal));
p = (center + u * extent[0] + v * extent[1] + w * extent[2]);
lowerBoundary2 = glm::min(lowerBoundary2, p.dot(axisNormal));
upperBoundary2 = glm::max(upperBoundary2, p.dot(axisNormal));
return checkOverlap(lowerBoundary1, upperBoundary1, lowerBoundary2, upperBoundary2, intersectionDistance, boundary1, boundary2);
}
template<typename Real>
DYN_FUNC inline void setupContactTets(
Real boundary1,
Real boundary2,
const Vector<Real, 3> axisNormal,
Tet3D tet1,
Tet3D tet2,
Real sMax,
TManifold<Real>& m)
{
int cnt1, cnt2;
unsigned char boundaryPoints1[4], boundaryPoints2[4];
cnt1 = cnt2 = 0;
for (unsigned char i = 0; i < 4; i++)
{
if (abs(tet1.v[i].dot(axisNormal) - boundary1) < abs(sMax))
boundaryPoints1[cnt1 ++] = i;
if (abs(tet2.v[i].dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2 ++] = i;
}
//printf("cnt1 = %d, cnt2 = %d\n", cnt1, cnt2);
if (cnt1 == 1 || cnt2 == 1)
{
m.normal = (boundary1 > boundary2) ? axisNormal : - axisNormal;
m.contacts[0].penetration = sMax;
m.contacts[0].position = (cnt1 == 1) ? tet1.v[boundaryPoints1[0]] : tet2.v[boundaryPoints2[0]];
m.contactCount = 1;
return;
}
else if (cnt1 == 2)
{
Segment3D s1(tet1.v[boundaryPoints1[0]], tet1.v[boundaryPoints1[1]]);
if (cnt2 == 2)
{
Segment3D s2(tet2.v[boundaryPoints2[0]], tet2.v[boundaryPoints2[1]]);
Segment3D dir = s1.proximity(s2);//v0: self v1: other
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
m.contacts[0].penetration = sMax;
m.contacts[0].position = dir.v0;
m.contactCount = 1;
return;
}
else //cnt2 == 3
{
m.contactCount = 0;
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
Triangle3D t2(tet2.v[boundaryPoints2[0]], tet2.v[boundaryPoints2[1]], tet2.v[boundaryPoints2[2]]);
Coord3D dirTmp1 = Point3D(s1.v0).project(t2).origin - s1.v0;
Coord3D dirTmp2 = Point3D(s1.v1).project(t2).origin - s1.v1;
if (dirTmp1.cross(axisNormal).norm() < 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s1.v0;
m.contactCount ++;
}
if (dirTmp2.cross(axisNormal).norm() < 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s1.v1;
m.contactCount++;
}
for (int i = 0; i < 3; i++)
{
Segment3D s2(t2.v[(i + 1) % 3], t2.v[(i + 2) % 3]);
Segment3D dir = s1.proximity(s2);
/*printf("dir: %.3lf %.3lf %.3lf\naxisnormal %.3lf %.3lf %.3lf\n%.6lf\n",
dir.direction()[0], dir.direction()[1], dir.direction()[2],
axisNormal[0], axisNormal[1], axisNormal[2],
dir.direction().normalize().cross(axisNormal).norm());*/
if ( (!dir.isValid()) || dir.direction().normalize().cross(axisNormal).norm() < 1e-5)
{
//printf("Yes\n");
if ((dir.v0 - s1.v0).norm() > 1e-5 && (dir.v0 - s1.v1).norm() > 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
}
}
}
}
}
else if (cnt1 == 3)
{
Triangle3D t1(tet1.v[boundaryPoints1[0]], tet1.v[boundaryPoints1[1]], tet1.v[boundaryPoints1[2]]);
if (cnt2 == 2)
{
Segment3D s2(tet2.v[boundaryPoints2[0]], tet2.v[boundaryPoints2[1]]);
m.contactCount = 0;
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
Coord3D dirTmp1 = Point3D(s2.v0).project(t1).origin - s2.v0;
Coord3D dirTmp2 = Point3D(s2.v1).project(t1).origin - s2.v1;
if (dirTmp1.cross(axisNormal).norm() < 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s2.v0;
m.contactCount++;
}
if (dirTmp2.cross(axisNormal).norm() < 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s2.v1;
m.contactCount++;
}
for (int i = 0; i < 3; i++)
{
Segment3D s1(t1.v[(i + 1) % 3], t1.v[(i + 2) % 3]);
Segment3D dir = s2.proximity(s1);
if ((!dir.isValid()) || dir.direction().normalize().cross(axisNormal).norm() < 1e-5)
{
if ((dir.v0 - s2.v0).norm() > 1e-5 && (dir.v0 - s2.v1).norm() > 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
}
}
}
}
if (cnt2 == 3)
{
Triangle3D t1(tet1.v[boundaryPoints1[0]], tet1.v[boundaryPoints1[1]], tet1.v[boundaryPoints1[2]]);
Triangle3D t2(tet2.v[boundaryPoints2[0]], tet2.v[boundaryPoints2[1]], tet2.v[boundaryPoints2[2]]);
m.contactCount = 0;
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
for (int i = 0; i < 3; i++)
{
if ((Point3D(t1.v[i]).project(t2).origin - t1.v[i]).cross(t2.normal()).norm() < 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = t1.v[i];
m.contactCount++;
}
if ((Point3D(t2.v[i]).project(t1).origin - t2.v[i]).cross(t1.normal()).norm() < 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = t2.v[i];
m.contactCount++;
}
for (int j = 0; j < 3; j++)
{
Segment3D s1(t1.v[(i + 1) % 3], t1.v[(i + 2) % 3]);
Segment3D s2(t2.v[(j + 1) % 3], t2.v[(j + 2) % 3]);
Segment3D dir = s1.proximity(s2);
if ((!dir.isValid()) || dir.direction().normalize().cross(axisNormal).norm() < 1e-5)
{
if ((dir.v0 - s1.v0).norm() > 1e-5 && (dir.v0 - s1.v1).norm() > 1e-5)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
}
}
}
}
}
}
}
template<typename Real>
DYN_FUNC inline void setupContactTets(
Real boundary1,
Real boundary2,
const Vector<Real, 3> axisNormal,
Tet3D tet,
TOrientedBox3D<Real> box,
Real sMax,
TManifold<Real>& m)
{
int cnt1, cnt2;
unsigned char boundaryPoints1[4];
Coord3D boundaryPoints2[8];
cnt1 = cnt2 = 0;
for (unsigned char i = 0; i < 4; i++)
{
if (abs(tet.v[i].dot(axisNormal) - boundary1) < abs(sMax))
boundaryPoints1[cnt1++] = i;
}
Coord3D center = box.center;
Coord3D u = box.u;
Coord3D v = box.v;
Coord3D w = box.w;
Coord3D extent = box.extent;
Coord3D p;
p = (center - u * extent[0] - v * extent[1] - w * extent[2]);
if (abs(p.dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2++] = p;
p = (center - u * extent[0] - v * extent[1] + w * extent[2]);
if (abs(p.dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2++] = p;
p = (center - u * extent[0] + v * extent[1] - w * extent[2]);
if (abs(p.dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2++] = p;
p = (center - u * extent[0] + v * extent[1] + w * extent[2]);
if (abs(p.dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2++] = p;
p = (center + u * extent[0] - v * extent[1] - w * extent[2]);
if (abs(p.dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2++] = p;
p = (center + u * extent[0] - v * extent[1] + w * extent[2]);
if (abs(p.dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2++] = p;
p = (center + u * extent[0] + v * extent[1] - w * extent[2]);
if (abs(p.dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2++] = p;
p = (center + u * extent[0] + v * extent[1] + w * extent[2]);
if (abs(p.dot(axisNormal) - boundary2) < abs(sMax))
boundaryPoints2[cnt2++] = p;
//printf("cnt1 = %d, cnt2 = %d %.3lf\n", cnt1, cnt2, sMax);
if (cnt1 == 1 || cnt2 == 1)
{
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
m.contacts[0].penetration = sMax;
m.contacts[0].position = (cnt1 == 1) ? tet.v[boundaryPoints1[0]] : boundaryPoints2[0];
m.contactCount = 1;
return;
}
else if (cnt1 == 2)
{
Segment3D s1(tet.v[boundaryPoints1[0]], tet.v[boundaryPoints1[1]]);
if (cnt2 == 2)
{
Segment3D s2(boundaryPoints2[0], boundaryPoints2[1]);
Segment3D dir = s1.proximity(s2);//v0: self v1: other
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
m.contacts[0].penetration = sMax;
m.contacts[0].position = dir.v0;
m.contactCount = 1;
return;
}
else //cnt2 == 4
{
//if (cnt2 != 4)
// printf("?????????\n");
for(int tmp_i = 1; tmp_i < 4; tmp_i ++)
for (int tmp_j = tmp_i + 1; tmp_j < 4; tmp_j++)
{
if ((boundaryPoints2[tmp_i] - boundaryPoints2[0]).dot(boundaryPoints2[tmp_j] - boundaryPoints2[0]) < EPSILON)
{
int tmp_k = 1 + 2 + 3 - tmp_i - tmp_j;
Coord3D p2 = boundaryPoints2[tmp_i];
Coord3D p3 = boundaryPoints2[tmp_j];
Coord3D p4 = boundaryPoints2[tmp_k];
boundaryPoints2[1] = p2;
boundaryPoints2[2] = p3;
boundaryPoints2[3] = p4;
break;
}
}
//printf("%.3lf %.3lf %.3lf\n", boundaryPoints2[0][0], boundaryPoints2[0][1], boundaryPoints2[0][2]);
//printf("%.3lf %.3lf %.3lf\n", boundaryPoints2[1][0], boundaryPoints2[1][1], boundaryPoints2[1][2]);
//printf("%.3lf %.3lf %.3lf\n", boundaryPoints2[2][0], boundaryPoints2[2][1], boundaryPoints2[2][2]);
//printf("%.3lf %.3lf %.3lf\n", boundaryPoints2[3][0], boundaryPoints2[3][1], boundaryPoints2[3][2]);
m.contactCount = 0;
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
Triangle3D t2(boundaryPoints2[0], boundaryPoints2[1], boundaryPoints2[2]);
Coord3D dirTmp1 = Point3D(s1.v0).project(t2).origin - s1.v0;
Coord3D dirTmp2 = Point3D(s1.v1).project(t2).origin - s1.v1;
/*printf("%.3lf %.3lf %.3lf\n", axisNormal[0], axisNormal[1], axisNormal[2]);
printf("%.3lf %.3lf %.3lf %.5lf %.5lf %.5lf\n", dirTmp1[0], dirTmp1[1], dirTmp1[2], dirTmp1.cross(axisNormal)[0], dirTmp1.cross(axisNormal)[1], dirTmp1.cross(axisNormal)[2]);
printf("%.3lf %.3lf %.3lf %.5lf %.5lf %.5lf\n", dirTmp2[0], dirTmp2[1], dirTmp2[2], dirTmp2.cross(axisNormal)[0], dirTmp2.cross(axisNormal)[1], dirTmp2.cross(axisNormal)[2]);*/
if (dirTmp1.cross(axisNormal).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s1.v0;
m.contactCount++;
}
if (dirTmp2.cross(axisNormal).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s1.v1;
m.contactCount++;
}
t2 = Triangle3D(boundaryPoints2[3], boundaryPoints2[1], boundaryPoints2[2]);
dirTmp1 = Point3D(s1.v0).project(t2).origin - s1.v0;
dirTmp2 = Point3D(s1.v1).project(t2).origin - s1.v1;
/*printf("%.3lf %.3lf %.3lf\n", dirTmp1[0], dirTmp1[1], dirTmp1[2]);
printf("%.3lf %.3lf %.3lf\n", dirTmp2[0], dirTmp2[1], dirTmp2[2]);*/
if (dirTmp1.cross(axisNormal).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s1.v0;
m.contactCount++;
}
if (dirTmp2.cross(axisNormal).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s1.v1;
m.contactCount++;
}
for (int i = 0; i < 4; i++)
{
Segment3D s2;
if (i < 2)
s2 = Segment3D(boundaryPoints2[0], boundaryPoints2[i]);
else
s2 = Segment3D(boundaryPoints2[3], boundaryPoints2[i - 2]);
Segment3D dir = s1.proximity(s2);
/*printf("dir: %.3lf %.3lf %.3lf\naxisnormal %.3lf %.3lf %.3lf\n%.6lf\n",
dir.direction()[0], dir.direction()[1], dir.direction()[2],
axisNormal[0], axisNormal[1], axisNormal[2],
dir.direction().normalize().cross(axisNormal).norm());*/
if ((!dir.isValid()) || dir.direction().normalize().cross(axisNormal).norm() < 1e-4)
{
//printf("Yes\n");
if ((dir.v0 - s1.v0).norm() > 1e-4 && (dir.v0 - s1.v1).norm() > 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
}
}
}
}
}
else if (cnt1 == 3)
{
Triangle3D t1(tet.v[boundaryPoints1[0]], tet.v[boundaryPoints1[1]], tet.v[boundaryPoints1[2]]);
//printf("%.3lf %.3lf %.3lf\n", axisNormal[0], axisNormal[1], axisNormal[2]);
if (cnt2 == 2)
{
Segment3D s2(boundaryPoints2[0], boundaryPoints2[1]);
m.contactCount = 0;
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
Coord3D dirTmp1 = Point3D(s2.v0).project(t1).origin - s2.v0;
Coord3D dirTmp2 = Point3D(s2.v1).project(t1).origin - s2.v1;
if (dirTmp1.cross(axisNormal).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s2.v0;
m.contactCount++;
}
if (dirTmp2.cross(axisNormal).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = s2.v1;
m.contactCount++;
}
for (int i = 0; i < 3; i++)
{
Segment3D s1(t1.v[(i + 1) % 3], t1.v[(i + 2) % 3]);
Segment3D dir = s2.proximity(s1);
if ((!dir.isValid()) || dir.direction().normalize().cross(axisNormal).norm() < 1e-4)
{
if ((dir.v0 - s2.v0).norm() > 1e-4 && (dir.v0 - s2.v1).norm() > 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
}
}
}
}
else
{
Triangle3D t1(tet.v[boundaryPoints1[0]], tet.v[boundaryPoints1[1]], tet.v[boundaryPoints1[2]]);
//Triangle3D t2(tet2.v[boundaryPoints2[0]], tet2.v[boundaryPoints2[1]], tet2.v[boundaryPoints2[2]]);
//if (cnt2 != 4)
// printf("?????????\n");
for (int tmp_i = 1; tmp_i < 4; tmp_i++)
for (int tmp_j = tmp_i + 1; tmp_j < 4; tmp_j++)
{
if ((boundaryPoints2[tmp_i] - boundaryPoints2[0]).dot(boundaryPoints2[tmp_j] - boundaryPoints2[0]) < EPSILON)
{
int tmp_k = 1 + 2 + 3 - tmp_i - tmp_j;
Coord3D p2 = boundaryPoints2[tmp_i];
Coord3D p3 = boundaryPoints2[tmp_j];
Coord3D p4 = boundaryPoints2[tmp_k];
boundaryPoints2[1] = p2;
boundaryPoints2[2] = p3;
boundaryPoints2[3] = p4;
break;
}
}
m.contactCount = 0;
m.normal = (boundary1 > boundary2) ? axisNormal : -axisNormal;
for(int i = 0; i < 4; i ++)
if ((Point3D(boundaryPoints2[i]).project(t1).origin - boundaryPoints2[i]).cross(t1.normal()).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = boundaryPoints2[i];
m.contactCount++;
//printf("b");
}
for (int i = 0; i < 3; i++)
{
Triangle3D t2(boundaryPoints2[0], boundaryPoints2[1], boundaryPoints2[2]);
if ((Point3D(t1.v[i]).project(t2).origin - t1.v[i]).cross(t2.normal()).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = t1.v[i];
m.contactCount++;
//printf("a1");
}
t2 = Triangle3D(boundaryPoints2[3], boundaryPoints2[1], boundaryPoints2[2]);
if ((Point3D(t1.v[i]).project(t2).origin - t1.v[i]).cross(t2.normal()).norm() < 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = t1.v[i];
m.contactCount++;
//printf("a2");
}
Segment3D s1(t1.v[(i + 1) % 3], t1.v[(i + 2) % 3]);
Segment3D s2(boundaryPoints2[0], boundaryPoints2[1]);
Segment3D dir = s1.proximity(s2);
if ((!dir.isValid()) || dir.direction().cross(axisNormal).norm() < 1e-4)
{
if ((dir.v0 - s1.v0).norm() > 1e-4 && (dir.v0 - s1.v1).norm() > 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
//printf("c");
}
}
s2 = Segment3D(boundaryPoints2[0], boundaryPoints2[2]);
dir = s1.proximity(s2);
if ((!dir.isValid()) || dir.direction().cross(axisNormal).norm() < 1e-4)
{
if ((dir.v0 - s1.v0).norm() > 1e-4 && (dir.v0 - s1.v1).norm() > 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
//printf("c");
}
}
s2 = Segment3D(boundaryPoints2[3], boundaryPoints2[2]);
dir = s1.proximity(s2);
if ((!dir.isValid()) || dir.direction().cross(axisNormal).norm() < 1e-4)
{
if ((dir.v0 - s1.v0).norm() > 1e-4 && (dir.v0 - s1.v1).norm() > 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
//printf("c");
}
}
s2 = Segment3D(boundaryPoints2[3], boundaryPoints2[1]);
dir = s1.proximity(s2);
if ((!dir.isValid()) || dir.direction().cross(axisNormal).norm() < 1e-4)
{
if ((dir.v0 - s1.v0).norm() > 1e-4 && (dir.v0 - s1.v1).norm() > 1e-4)
{
m.contacts[m.contactCount].penetration = sMax;
m.contacts[m.contactCount].position = dir.v0;
m.contactCount++;
//printf("c");
}
}
}
}
}
}
//Separating Axis Theorem for tets
template<typename Real>
DYN_FUNC void CollisionDetection<Real>::request(Manifold& m, const Tet3D& tet0, const Tet3D& tet1)
{
m.contactCount = 0;
Real sMax = (Real)INT_MAX;
Real sIntersect;
Real lowerBoundary1, upperBoundary1, lowerBoundary2, upperBoundary2;
Real l1, u1, l2, u2;
Coord3D axis = Coord3D(0, 1, 0);
Coord3D axisTmp = axis;
Real boundary1, boundary2, b1, b2;
// no penetration when the tets are illegal
if (abs(tet0.volume()) < EPSILON || abs(tet1.volume()) < EPSILON)
return;
for(int i = 0; i < 4; i ++)
{
//tet0 face axis i
axisTmp = tet0.face(i).normal();
if (checkOverlapAxis(l1, u1, l2, u2, sIntersect, b1, b2, axisTmp, tet0, tet1) == false)
{
m.contactCount = 0;
return;
}
else
{
if (sIntersect < sMax)
{
sMax = sIntersect;
lowerBoundary1 = l1;
lowerBoundary2 = l2;
upperBoundary1 = u1;
upperBoundary2 = u2;
boundary1 = b1;
boundary2 = b2;
axis = axisTmp;
}
}
//tet1 face axis i
axisTmp = tet1.face(i).normal();
if (checkOverlapAxis(l1, u1, l2, u2, sIntersect, b1, b2, axisTmp, tet0, tet1) == false)
{
m.contactCount = 0;
return;
}
else
{
if (sIntersect < sMax)
{
sMax = sIntersect;
lowerBoundary1 = l1;
lowerBoundary2 = l2;
upperBoundary1 = u1;
upperBoundary2 = u2;
boundary1 = b1;
boundary2 = b2;
axis = axisTmp;
}
}
}
const int segmentIndex[6][2] = {
0, 1,
0, 2,
0, 3,
1, 2,
1, 3,
2, 3
};
for(int i = 0; i < 6; i ++)
for (int j = 0; j < 6; j++)
{
Coord3D dirTet1 = tet0.v[segmentIndex[i][0]] - tet0.v[segmentIndex[i][1]];
Coord3D dirTet2 = tet1.v[segmentIndex[j][0]] - tet1.v[segmentIndex[j][1]];
axisTmp = dirTet1.cross(dirTet2);
if (axisTmp.norm() > EPSILON)
{
axisTmp /= axisTmp.norm();
}
else //parallel, choose an arbitary direction
{
if (abs(dirTet1[0]) > EPSILON)
axisTmp = Coord3D(dirTet1[1], -dirTet1[0], 0);
else
axisTmp = Coord3D(0, dirTet1[2], -dirTet1[1]);
axisTmp /= axisTmp.norm();
}
if (checkOverlapAxis(l1, u1, l2, u2, sIntersect, b1, b2, axisTmp, tet0, tet1) == false)
{
m.contactCount = 0;
return;
}
else
{
if (sIntersect < sMax)
{
sMax = sIntersect;
lowerBoundary1 = l1;
lowerBoundary2 = l2;
upperBoundary1 = u1;
upperBoundary2 = u2;
boundary1 = b1;
boundary2 = b2;
axis = axisTmp;
}
}
}
//printf("YES YYYYYYYEEES\n!\n");
//set up contacts using axis
setupContactTets(boundary1, boundary2, axis, tet0, tet1, -sMax, m);
}
//Separating Axis Theorem for tet-OBB
template<typename Real>
DYN_FUNC void CollisionDetection<Real>::request(Manifold& m, const Tet3D& tet, const OBox3D& box)
{
m.contactCount = 0;
Real sMax = (Real)INT_MAX;
Real sIntersect;
Real lowerBoundary1, upperBoundary1, lowerBoundary2, upperBoundary2;
Real l1, u1, l2, u2;
Coord3D axis = Coord3D(0, 1, 0);
Coord3D axisTmp = axis;
Real boundary1, boundary2, b1, b2;
for (int i = 0; i < 4; i++)
{
//tet face axis i
axisTmp = tet.face(i).normal();
if (checkOverlapAxis(l1, u1, l2, u2, sIntersect, b1, b2, axisTmp, tet, box) == false)
{
m.contactCount = 0;
return;
}
else
{
if (sIntersect < sMax)
{
sMax = sIntersect;
lowerBoundary1 = l1;
lowerBoundary2 = l2;
upperBoundary1 = u1;
upperBoundary2 = u2;
boundary1 = b1;
boundary2 = b2;
axis = axisTmp;
}
}
}
//u
axisTmp = box.u / box.u.norm();
if (checkOverlapAxis(l1, u1, l2, u2, sIntersect, b1, b2, axisTmp, tet, box) == false)
{
m.contactCount = 0;
return;
}
else
{
if (sIntersect < sMax)
{
sMax = sIntersect;
lowerBoundary1 = l1;
lowerBoundary2 = l2;
upperBoundary1 = u1;
upperBoundary2 = u2;
boundary1 = b1;
boundary2 = b2;
axis = axisTmp;
}
}
//v
axisTmp = box.v / box.v.norm();
if (checkOverlapAxis(l1, u1, l2, u2, sIntersect, b1, b2, axisTmp, tet, box) == false)
{
m.contactCount = 0;
return;
}
else
{
if (sIntersect < sMax)
{
sMax = sIntersect;
lowerBoundary1 = l1;
lowerBoundary2 = l2;
upperBoundary1 = u1;
upperBoundary2 = u2;
boundary1 = b1;
boundary2 = b2;
axis = axisTmp;
}
}
//w
axisTmp = box.w / box.w.norm();
if (checkOverlapAxis(l1, u1, l2, u2, sIntersect, b1, b2, axisTmp, tet, box) == false)
{
m.contactCount = 0;
return;
}
else
{
if (sIntersect < sMax)
{
sMax = sIntersect;
lowerBoundary1 = l1;
lowerBoundary2 = l2;
upperBoundary1 = u1;
upperBoundary2 = u2;
boundary1 = b1;
boundary2 = b2;
axis = axisTmp;
}
}
const int segmentIndex[6][2] = {
0, 1,
0, 2,
0, 3,
1, 2,
1, 3,
2, 3
};
//dir generated by cross product from tet and box
for (int i = 0; i < 6; i++)
{
Coord3D dirTet = tet.v[segmentIndex[i][0]] - tet.v[segmentIndex[i][1]];
for(int j = 0; j < 3; j ++)
{
Coord3D boxDir = (j == 0) ? (box.u) : ((j == 1) ? (box.v) : (box.w));
axisTmp = dirTet.cross(boxDir);
if (axisTmp.norm() > EPSILON)
{
axisTmp /= axisTmp.norm();
}
else //parallel, choose an arbitary direction
{
if (abs(dirTet[0]) > EPSILON)
axisTmp = Coord3D(dirTet[1], -dirTet[0], 0);
else
axisTmp = Coord3D(0, dirTet[2], -dirTet[1]);
axisTmp /= axisTmp.norm();
}
if (checkOverlapAxis(l1, u1, l2, u2, sIntersect, b1, b2, axisTmp, tet, box) == false)
{
m.contactCount = 0;
return;
}
else
{
if (sIntersect < sMax)
{
sMax = sIntersect;
lowerBoundary1 = l1;
lowerBoundary2 = l2;
upperBoundary1 = u1;
upperBoundary2 = u2;
boundary1 = b1;
boundary2 = b2;
axis = axisTmp;
}
}
}
}
setupContactTets(boundary1, boundary2, axis, tet, box, -sMax, m);
}
template<typename Real>
DYN_FUNC void CollisionDetection<Real>::request(Manifold& m, const OBox3D& box, const Tet3D& tet)
{
request(m, tet, box);
m.normal *= -1;
}
} | 27.111111 | 201 | 0.563525 | Oncle-Ha |
e19c5b5f91f8e5293792f7b6420ac2d7de5e2209 | 723 | cpp | C++ | Unique Email Addresses.cpp | durgirajesh/Leetcode | 18b11cd90e8a5ce33f4029d5b7edf9502273bc76 | [
"MIT"
] | 2 | 2020-06-25T12:46:13.000Z | 2021-07-06T06:34:33.000Z | Unique Email Addresses.cpp | durgirajesh/Leetcode | 18b11cd90e8a5ce33f4029d5b7edf9502273bc76 | [
"MIT"
] | null | null | null | Unique Email Addresses.cpp | durgirajesh/Leetcode | 18b11cd90e8a5ce33f4029d5b7edf9502273bc76 | [
"MIT"
] | null | null | null | class Solution {
public:
int numUniqueEmails(vector<string>& emails) {
set<string> vec;
for(string str : emails){
string email; int i=0;
bool flag=false;
while(i < str.length()){
if(!flag && str[i]=='.'){
i++;
}
if(!flag && str[i]=='+'){
while(str[i]!='@'){
i++;
}
}
if(str[i]=='@'){
flag=true;
}
email+=str[i];
i++;
}
vec.insert(email);
}
return vec.size();
}
};
| 25.821429 | 50 | 0.29184 | durgirajesh |
e19dca167caedeb0d0d61d6fea4ce2d2b48b00a6 | 549 | cpp | C++ | kernel/system/dmzSystemRefCountLinux.cpp | shillcock/dmz | 02174b45089e12cd7f0840d5259a00403cd1ccff | [
"MIT"
] | 2 | 2015-11-05T03:03:40.000Z | 2016-02-03T21:50:40.000Z | kernel/system/dmzSystemRefCountLinux.cpp | ashok/dmz | 2f8d4bced646f25abf2e98bdc0d378dafb4b32ed | [
"MIT"
] | null | null | null | kernel/system/dmzSystemRefCountLinux.cpp | ashok/dmz | 2f8d4bced646f25abf2e98bdc0d378dafb4b32ed | [
"MIT"
] | null | null | null | #include <dmzSystemRefCount.h>
#include <dmzTypesBase.h>
#include <atomic_ops.h>
struct dmz::RefCount::State {
AO_t value;
State () : value (1) {;}
};
dmz::RefCount::RefCount () : _state (*(new State)) {;}
dmz::RefCount::~RefCount () { delete &_state; }
dmz::Int32
dmz::RefCount::ref () {
return dmz::Int32 (AO_fetch_and_add1 (&(_state.value)));
}
dmz::Int32
dmz::RefCount::unref () {
const Int32 ReturnCount (AO_fetch_and_sub1 (&(_state.value)));
if (ReturnCount == 0) { _ref_count_is_zero (); }
return ReturnCount;
}
| 17.15625 | 65 | 0.64663 | shillcock |
e19e9274c5562185e5b9e0043eed3d6d5503e920 | 230 | cpp | C++ | source/Components/Component.cpp | dom380/IMAT3606-Coursework-2 | 36f50b25823cd3170a403a2e2ef50e3019fcd73b | [
"FTL",
"Zlib",
"Apache-2.0",
"MIT"
] | null | null | null | source/Components/Component.cpp | dom380/IMAT3606-Coursework-2 | 36f50b25823cd3170a403a2e2ef50e3019fcd73b | [
"FTL",
"Zlib",
"Apache-2.0",
"MIT"
] | null | null | null | source/Components/Component.cpp | dom380/IMAT3606-Coursework-2 | 36f50b25823cd3170a403a2e2ef50e3019fcd73b | [
"FTL",
"Zlib",
"Apache-2.0",
"MIT"
] | null | null | null | #include "Components\Component.h"
Component::Component(ComponentType type)
{
this->type = type;
}
ComponentType Component::getType()
{
return type;
}
bool Component::isType(ComponentType type)
{
return this->type == type;
}
| 13.529412 | 42 | 0.726087 | dom380 |
e1a88944ed437b9c35bd465fadfd4bdcd1981e3a | 119,239 | cpp | C++ | src/gui/UserInterface.cpp | SpookyGhost2D/SpookyGhost | bfddccee9239aedf7928e781042e5ca1d78a49e1 | [
"MIT"
] | 182 | 2021-05-23T19:00:06.000Z | 2022-03-29T06:00:18.000Z | src/gui/UserInterface.cpp | SpookyGhost2D/SpookyGhost | bfddccee9239aedf7928e781042e5ca1d78a49e1 | [
"MIT"
] | 2 | 2021-05-25T04:56:23.000Z | 2021-11-08T17:52:26.000Z | src/gui/UserInterface.cpp | SpookyGhost2D/SpookyGhost | bfddccee9239aedf7928e781042e5ca1d78a49e1 | [
"MIT"
] | 9 | 2021-06-02T16:47:56.000Z | 2021-12-04T08:40:18.000Z | #include <ctime>
#include "gui/gui_common.h"
#include <ncine/imgui_internal.h>
#include <ncine/Application.h>
#include <ncine/FileSystem.h>
#include <ncine/IFile.h>
#include <ncine/LuaStateManager.h>
#include <ncine/Random.h>
#include "singletons.h"
#include "gui/gui_labels.h"
#include "gui/gui_tips.h"
#include "gui/UserInterface.h"
#include "gui/FileDialog.h"
#include "Canvas.h"
#include "SpriteManager.h"
#include "AnimationManager.h"
#include "PropertyAnimation.h"
#include "ParallelAnimationGroup.h"
#include "SequentialAnimationGroup.h"
#include "GridAnimation.h"
#include "GridFunctionLibrary.h"
#include "Script.h"
#include "ScriptAnimation.h"
#include "Sprite.h"
#include "Texture.h"
#include "ScriptManager.h"
#include "version.h"
#include <ncine/version.h>
#include "projects_strings.h"
#if defined(__ANDROID__) || defined(__EMSCRIPTEN__)
#include "textures_strings.h"
#endif
#include "scripts_strings.h"
namespace {
// clang-format off
const char *anchorPointItems[] = { "Center", "Bottom Left", "Top Left", "Bottom Right", "Top Right" };
enum AnchorPointsEnum { CENTER, BOTTOM_LEFT, TOP_LEFT, BOTTOM_RIGHT, TOP_RIGHT };
const char *blendingPresets[] = { "Disabled", "Alpha", "Pre-multiplied Alpha", "Additive", "Multiply" };
const char *easingCurveTypes[] = { "Linear", "Quadratic", "Cubic", "Quartic", "Quintic", "Sine", "Exponential", "Circular" };
const char *loopDirections[] = { "Forward", "Backward" };
const char *loopModes[] = { "Disabled", "Rewind", "Ping Pong" };
const char *animationTypes[] = { "Parallel Group", "Sequential Group", "Property", "Grid", "Script" };
enum AnimationTypesEnum { PARALLEL_GROUP, SEQUENTIAL_GROUP, PROPERTY, GRID, SCRIPT };
// clang-format on
static const int PlotArraySize = 512;
static float plotArray[PlotArraySize];
static int plotValueIndex = 0;
#if defined(__linux__) && !defined(__ANDROID__) && defined(NCPROJECT_DATA_DIR_DIST)
const char *docsFile = "../../doc/spookyghost/documentation.html";
#else
const char *docsFile = "../docs/documentation.html";
#endif
static bool showTipsWindow = false;
static bool showAboutWindow = false;
static bool showQuitPopup = false;
static bool hoveringOnCanvasWindow = false;
static bool hoveringOnCanvas = false;
static bool deleteKeyPressed = false;
static bool enableKeyboardNav = true;
static int numFrames = 0;
static unsigned int currentTipIndex = 0;
const float imageTooltipSize = 100.0f;
const float imageTooltipDelay = 0.5f;
unsigned int nextSpriteNameId()
{
static unsigned int spriteNameId = 0;
return spriteNameId++;
}
unsigned int nextAnimNameId()
{
static unsigned int animNameId = 0;
return animNameId++;
}
}
///////////////////////////////////////////////////////////
// CONSTRUCTORS and DESTRUCTOR
///////////////////////////////////////////////////////////
UserInterface::UserInterface()
: selectedSpriteEntry_(&theSpriteMgr->root()), selectedTextureIndex_(0), selectedScriptIndex_(0),
selectedAnimation_(&theAnimMgr->animGroup()), spriteGraph_(4), renderGuiWindow_(*this),
saverData_(*theCanvas, *theSpriteMgr, *theScriptingMgr, *theAnimMgr)
{
#ifdef __EMSCRIPTEN__
loadTextureLocalFile_.setLoadedCallback([](const nc::EmscriptenLocalFile &localFile, void *userData) {
UserInterface *ui = reinterpret_cast<UserInterface *>(userData);
if (localFile.size() > 0)
ui->loadTexture(localFile.filename(), localFile.data(), localFile.size());
}, this);
reloadTextureLocalFile_.setLoadedCallback([](const nc::EmscriptenLocalFile &localFile, void *userData) {
UserInterface *ui = reinterpret_cast<UserInterface *>(userData);
if (localFile.size() > 0)
ui->reloadTexture(localFile.filename(), localFile.data(), localFile.size());
}, this);
#endif
ImGuiIO &io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io.FontGlobalScale = theCfg.guiScaling;
#ifdef WITH_FONTAWESOME
// Merge icons from Font Awesome into the default font
static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
ImFontConfig icons_config;
icons_config.MergeMode = true;
icons_config.PixelSnapH = true;
// Loading font from memory so that a font can be an Android asset file
nctl::UniquePtr<nc::IFile> fontFile = nc::IFile::createFileHandle(nc::fs::joinPath(nc::fs::dataPath(), "fonts/" FONT_ICON_FILE_NAME_FAS).data());
fontFile->open(nc::IFile::OpenMode::READ);
const long int fontFileSize = fontFile->size();
nctl::UniquePtr<uint8_t[]> fontFileBuffer = nctl::makeUnique<uint8_t[]>(fontFileSize);
fontFile->read(fontFileBuffer.get(), fontFileSize);
io.Fonts->AddFontFromMemoryTTF(fontFileBuffer.get(), fontFileSize, 12.0f, &icons_config, icons_ranges);
// Transfer ownership to ImGui
fontFileBuffer.release();
fontFile->close();
#endif
applyDarkStyle();
spookyLogo_ = nctl::makeUnique<Texture>(nc::fs::joinPath(nc::fs::dataPath(), "icon96.png").data());
ncineLogo_ = nctl::makeUnique<Texture>(nc::fs::joinPath(nc::fs::dataPath(), "ncine96.png").data());
canvasGuiSection_.setResize(theCanvas->size());
if (theCfg.startupProjectName.isEmpty() == false)
{
const nctl::String startupProject = nc::fs::joinPath(theCfg.projectsPath, theCfg.startupProjectName);
if (nc::fs::isReadableFile(startupProject.data()))
openProject(startupProject.data());
}
if (theCfg.autoPlayOnStart)
theAnimMgr->play();
Tips::initStrings();
if (theCfg.showTipsOnStart)
showTipsWindow = true;
currentTipIndex = nc::random().fastInteger(0, Tips::Count);
}
///////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
///////////////////////////////////////////////////////////
void UserInterface::pushStatusInfoMessage(const char *message)
{
statusMessage_.format("%s%s", Labels::INFO_MARKER, message);
lastStatus_ = nc::TimeStamp::now();
}
void UserInterface::pushStatusErrorMessage(const char *message)
{
statusMessage_.format("%s%s", Labels::ERROR_MARKER, message);
lastStatus_ = nc::TimeStamp::now();
}
const SaveAnim &UserInterface::saveAnimStatus() const
{
return renderGuiWindow_.saveAnimStatus();
}
bool UserInterface::shouldSaveFrames() const
{
return renderGuiWindow_.shouldSaveFrames();
}
bool UserInterface::shouldSaveSpritesheet() const
{
return renderGuiWindow_.shouldSaveSpritesheet();
}
void UserInterface::signalFrameSaved()
{
renderGuiWindow_.signalFrameSaved();
}
void UserInterface::cancelRender()
{
renderGuiWindow_.cancelRender();
}
void UserInterface::closeModalsAndUndockables()
{
showTipsWindow = false;
showAboutWindow = false;
showQuitPopup = false;
FileDialog::config.windowOpen = false;
}
void UserInterface::pressDeleteKey()
{
deleteKeyPressed = true;
}
void UserInterface::moveSprite(int xDiff, int yDiff)
{
if (selectedSpriteEntry_->isSprite() && hoveringOnCanvas)
{
Sprite *sprite = selectedSpriteEntry_->toSprite();
sprite->x += xDiff;
sprite->y += yDiff;
}
}
bool UserInterface::menuNewEnabled()
{
return (theAnimMgr->anims().isEmpty() == false ||
theScriptingMgr->scripts().isEmpty() == false ||
theSpriteMgr->children().isEmpty() == false ||
theSpriteMgr->textures().isEmpty() == false);
}
bool UserInterface::menuSaveEnabled()
{
return (lastLoadedProject_.isEmpty() == false &&
nc::fs::isReadableFile(lastLoadedProject_.data()) &&
menuNewEnabled());
}
bool UserInterface::menuSaveAsEnabled()
{
return menuNewEnabled();
}
bool UserInterface::menuQuickOpenEnabled()
{
return (lastQuickSavedProject_.isEmpty() == false &&
nc::fs::isReadableFile(lastQuickSavedProject_.data()));
}
bool UserInterface::menuQuickSaveEnabled()
{
return menuNewEnabled();
}
void UserInterface::menuNew()
{
selectedSpriteEntry_ = &theSpriteMgr->root();
selectedAnimation_ = nullptr;
// Always clear animations before sprites
theAnimMgr->clear();
theScriptingMgr->clear();
theSpriteMgr->clear();
}
void UserInterface::menuOpen()
{
FileDialog::config.directory = theCfg.projectsPath;
FileDialog::config.windowIcon = Labels::FileDialog_OpenIcon;
FileDialog::config.windowTitle = "Open project file";
FileDialog::config.okButton = Labels::Ok;
FileDialog::config.selectionType = FileDialog::SelectionType::FILE;
FileDialog::config.extensions = "lua\0\0";
FileDialog::config.action = FileDialog::Action::OPEN_PROJECT;
FileDialog::config.windowOpen = true;
}
void UserInterface::menuSave()
{
theSaver->save(lastLoadedProject_.data(), saverData_);
ui::auxString.format("Saved project file \"%s\"\n", lastLoadedProject_.data());
pushStatusInfoMessage(ui::auxString.data());
}
void UserInterface::menuSaveAs()
{
FileDialog::config.directory = theCfg.projectsPath;
FileDialog::config.windowIcon = Labels::FileDialog_SaveIcon;
FileDialog::config.windowTitle = "Save project file";
FileDialog::config.okButton = Labels::Ok;
FileDialog::config.selectionType = FileDialog::SelectionType::NEW_FILE;
FileDialog::config.extensions = nullptr;
FileDialog::config.action = FileDialog::Action::SAVE_PROJECT;
FileDialog::config.windowOpen = true;
}
void UserInterface::menuQuickOpen()
{
if (openProject(lastQuickSavedProject_.data()))
numFrames = 0; // force focus on the canvas
}
void UserInterface::menuQuickSave()
{
time_t now;
struct tm *ts;
now = time(nullptr);
ts = localtime(&now);
lastQuickSavedProject_ = theCfg.projectsPath;
nctl::String fileName(ui::MaxStringLength);
const unsigned int length = strftime(fileName.data(), fileName.capacity() - 1, "quicksave_%Y%m%d_%H%M%S.lua", ts);
fileName.setLength(length);
lastQuickSavedProject_ = nc::fs::joinPath(lastQuickSavedProject_, fileName);
theSaver->save(lastQuickSavedProject_.data(), saverData_);
ui::auxString.format("Saved project file \"%s\"\n", lastQuickSavedProject_.data());
pushStatusInfoMessage(ui::auxString.data());
}
void UserInterface::quit()
{
#if defined(__ANDROID__) || defined(__EMSCRIPTEN__)
nc::theApplication().quit();
#else
showQuitPopup = true;
#endif
}
bool UserInterface::openDocumentationEnabled()
{
#ifdef __ANDROID__
return false; // TODO: open with a WebView
#else
nctl::String docsPath = nc::fs::joinPath(nc::fs::dataPath(), docsFile);
return nc::fs::isReadableFile(docsPath.data());
#endif
}
void UserInterface::openDocumentation()
{
nctl::String docsPath = nc::fs::joinPath(nc::fs::dataPath(), docsFile);
openFile(docsPath.data());
}
void UserInterface::toggleAnimation()
{
if (selectedAnimation_ && hoveringOnCanvasWindow)
{
if (selectedAnimation_->state() != IAnimation::State::PLAYING)
selectedAnimation_->play();
else
selectedAnimation_->pause();
}
}
void UserInterface::reloadScript()
{
if (theScriptingMgr->scripts().isEmpty() == false)
{
Script *script = theScriptingMgr->scripts()[selectedScriptIndex_].get();
script->reload();
theAnimMgr->reloadScript(script);
ui::auxString.format("Reloaded script \"%s\"\n", script->name().data());
pushStatusInfoMessage(ui::auxString.data());
}
}
void UserInterface::createGui()
{
if (lastStatus_.secondsSince() >= 2.0f)
statusMessage_.clear();
createDockingSpace();
//createToolbarWindow();
createTexturesWindow();
if (numFrames == 1)
ImGui::SetNextWindowFocus();
createSpritesWindow();
createScriptsWindow();
createAnimationsWindow();
if (numFrames == 1)
ImGui::SetNextWindowFocus();
createSpriteWindow();
createAnimationWindow();
renderGuiWindow_.create();
createFileDialog();
if (numFrames == 1)
ImGui::SetNextWindowFocus();
createCanvasWindow();
createTexRectWindow();
ImGui::Begin("Status");
ImGui::Text("%s", statusMessage_.data());
ImGui::End();
if (showTipsWindow)
createTipsWindow();
if (showAboutWindow)
createAboutWindow();
if (showQuitPopup)
createQuitPopup();
createConfigWindow();
deleteKeyPressed = false;
if (enableKeyboardNav)
{
// Enable keyboard navigation again
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
}
enableKeyboardNav = true;
if (numFrames < 2)
numFrames++;
}
///////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS
///////////////////////////////////////////////////////////
bool UserInterface::openProject(const char *filename)
{
if (nc::fs::isReadableFile(filename) && theSaver->load(filename, saverData_))
{
selectedSpriteEntry_ = &theSpriteMgr->root();
selectedTextureIndex_ = 0;
selectedScriptIndex_ = 0;
selectedAnimation_ = &theAnimMgr->animGroup();
canvasGuiSection_.setResize(theCanvas->size());
renderGuiWindow_.setResize(renderGuiWindow_.saveAnimStatus().canvasResize);
lastLoadedProject_ = filename;
ui::auxString.format("Loaded project file \"%s\"\n", filename);
pushStatusInfoMessage(ui::auxString.data());
return true;
}
else
{
ui::auxString.format("Cannot load project file \"%s\"\n", filename);
pushStatusErrorMessage(ui::auxString.data());
return false;
}
}
bool UserInterface::loadTexture(const char *filename)
{
nctl::UniquePtr<Texture> texture = nctl::makeUnique<Texture>(filename);
const bool hasLoaded = postLoadTexture(texture, filename);
if (texture->dataSize() > 0)
{
theSpriteMgr->textures().pushBack(nctl::move(texture));
selectedTextureIndex_ = theSpriteMgr->textures().size() - 1;
}
return hasLoaded;
}
bool UserInterface::reloadTexture(const char *filename)
{
nctl::UniquePtr<Texture> &texture = theSpriteMgr->textures()[selectedTextureIndex_];
texture->loadFromFile(filename);
return postLoadTexture(texture, filename);
}
bool UserInterface::loadScript(const char *filename)
{
nctl::UniquePtr<Script> script = nctl::makeUnique<Script>();
const bool hasLoaded = script->load(filename);
theScriptingMgr->scripts().pushBack(nctl::move(script));
// Check if the script is in the configuration path or in the data directory
const nctl::String baseName = nc::fs::baseName(filename);
const nctl::String nameInConfigDir = nc::fs::joinPath(theCfg.scriptsPath, baseName);
const nctl::String nameInDataDir = nc::fs::joinPath(ui::scriptsDataDir, baseName);
if ((nameInConfigDir == filename && nc::fs::isReadableFile(nameInConfigDir.data())) ||
(nameInDataDir == filename && nc::fs::isReadableFile(nameInDataDir.data())))
{
// Set the script name to its basename to allow for relocatable project files
theScriptingMgr->scripts().back()->setName(baseName);
}
selectedScriptIndex_ = theScriptingMgr->scripts().size() - 1;
if (hasLoaded)
{
if (theScriptingMgr->scripts().back()->canRun())
{
ui::auxString.format("Loaded script \"%s\"", filename);
pushStatusInfoMessage(ui::auxString.data());
}
else
{
ui::auxString.format("Loaded script \"%s\", but it cannot run", filename);
pushStatusErrorMessage(ui::auxString.data());
}
}
else
{
ui::auxString.format("Cannot load script \"%s\"", filename);
pushStatusErrorMessage(ui::auxString.data());
}
return hasLoaded;
}
#ifdef __EMSCRIPTEN__
bool UserInterface::loadTexture(const char *bufferName, const char *bufferPtr, unsigned long int bufferSize)
{
nctl::UniquePtr<Texture> texture = nctl::makeUnique<Texture>(bufferName, reinterpret_cast<const unsigned char *>(bufferPtr), bufferSize);
const bool hasLoaded = postLoadTexture(texture, bufferName);
if (texture->dataSize() > 0)
{
theSpriteMgr->textures().pushBack(nctl::move(texture));
selectedTextureIndex_ = theSpriteMgr->textures().size() - 1;
}
return hasLoaded;
}
#endif
#ifdef __EMSCRIPTEN__
bool UserInterface::reloadTexture(const char *bufferName, const char *bufferPtr, unsigned long int bufferSize)
{
nctl::UniquePtr<Texture> &texture = theSpriteMgr->textures()[selectedTextureIndex_];
texture->loadFromMemory(bufferName, reinterpret_cast<const unsigned char *>(bufferPtr), bufferSize);
return postLoadTexture(texture, bufferName);
}
#endif
bool UserInterface::postLoadTexture(nctl::UniquePtr<Texture> &texture, const char *name)
{
if (texture->dataSize() > 0)
{
// Check if the texture is in the configuration path or in the data directory
const nctl::String baseName = nc::fs::baseName(name);
const nctl::String nameInConfigDir = nc::fs::joinPath(theCfg.texturesPath, baseName);
const nctl::String nameInDataDir = nc::fs::joinPath(ui::texturesDataDir, baseName);
if ((nameInConfigDir == name && nc::fs::isReadableFile(nameInConfigDir.data())) ||
(nameInDataDir == name && nc::fs::isReadableFile(nameInDataDir.data())))
{
// Set the texture name to its basename to allow for relocatable project files
texture->setName(baseName);
}
ui::auxString.format("Loaded texture \"%s\"", name);
pushStatusInfoMessage(ui::auxString.data());
return true;
}
else
{
ui::auxString.format("Cannot load texture \"%s\"", name);
pushStatusErrorMessage(ui::auxString.data());
return false;
}
}
void UserInterface::createDockingSpace()
{
ImGuiIO &io = ImGui::GetIO();
if ((io.ConfigFlags & ImGuiConfigFlags_DockingEnable) == 0)
return;
const ImGuiWindowFlags windowFlags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar |
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBackground;
ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos);
ImGui::SetNextWindowSize(viewport->Size);
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
bool open = true;
ImGui::Begin("DockSpace", &open, windowFlags);
ImGui::PopStyleVar(3);
createInitialDocking();
createMenuBar();
ImGui::End();
}
void UserInterface::createInitialDocking()
{
const ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_PassthruCentralNode;
const ImGuiID dockspaceId = ImGui::GetID("TheDockSpace");
if (ImGui::DockBuilderGetNode(dockspaceId) != nullptr)
{
ImGui::DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
return;
}
ImGui::DockBuilderRemoveNode(dockspaceId);
ImGui::DockBuilderAddNode(dockspaceId, ImGuiDockNodeFlags_DockSpace);
ImGuiID dockMainId = dockspaceId;
ImGuiID dockIdUp = ImGui::DockBuilderSplitNode(dockMainId, ImGuiDir_Up, 0.02f, nullptr, &dockMainId);
ImGuiID dockIdDown = ImGui::DockBuilderSplitNode(dockMainId, ImGuiDir_Down, 0.02f, nullptr, &dockMainId);
ImGuiID dockIdLeft = ImGui::DockBuilderSplitNode(dockMainId, ImGuiDir_Left, 0.275f, nullptr, &dockMainId);
ImGuiID dockIdRight = ImGui::DockBuilderSplitNode(dockMainId, ImGuiDir_Right, 0.5f, nullptr, &dockMainId);
ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::DockBuilderSetNodeSize(dockIdUp, ImVec2(viewport->Size.x, ImGui::GetFrameHeight()));
ImGui::DockBuilderSetNodeSize(dockIdDown, ImVec2(viewport->Size.x, ImGui::GetFrameHeight()));
ImGui::DockBuilderSetNodeSize(dockIdLeft, ImVec2(viewport->Size.x * 0.32f, viewport->Size.y));
ImGui::DockBuilderSetNodeSize(dockIdRight, ImVec2(viewport->Size.x * 0.275f, viewport->Size.y));
ImGuiID dockIdLeftDown = ImGui::DockBuilderSplitNode(dockIdLeft, ImGuiDir_Down, 0.35f, nullptr, &dockIdLeft);
ImGuiID dockIdRightDown = ImGui::DockBuilderSplitNode(dockIdRight, ImGuiDir_Down, 0.335f, nullptr, &dockIdRight);
ImGui::DockBuilderDockWindow("Toolbar", dockIdUp);
ImGui::DockBuilderDockWindow(Labels::Textures, dockIdLeft);
ImGui::DockBuilderDockWindow(Labels::Sprites, dockIdLeft);
ImGui::DockBuilderDockWindow(Labels::Scripts, dockIdLeft);
ImGui::DockBuilderDockWindow(Labels::Animations, dockIdLeftDown);
ImGui::DockBuilderDockWindow(Labels::Canvas, dockMainId);
ImGui::DockBuilderDockWindow(Labels::TexRect, dockMainId);
ImGui::DockBuilderDockWindow(Labels::Sprite, dockIdRight);
ImGui::DockBuilderDockWindow(Labels::Animation, dockIdRight);
ImGui::DockBuilderDockWindow(Labels::Render, dockIdRightDown);
ImGui::DockBuilderDockWindow("Status", dockIdDown);
ImGuiDockNode *node = ImGui::DockBuilderGetNode(dockIdUp);
node->LocalFlags |= (ImGuiDockNodeFlags_NoTabBar);
node = ImGui::DockBuilderGetNode(dockIdDown);
node->LocalFlags |= (ImGuiDockNodeFlags_NoTabBar);
ImGui::DockBuilderFinish(dockspaceId);
}
void UserInterface::createMenuBar()
{
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem(Labels::New, "CTRL + N", false, menuNewEnabled()))
menuNew();
if (ImGui::MenuItem(Labels::Open, "CTRL + O"))
menuOpen();
const bool openBundledEnabled = ProjectsStrings::Count > 0;
if (ImGui::BeginMenu(Labels::OpenBundled, openBundledEnabled))
{
for (unsigned int i = 0; i < ProjectsStrings::Count; i++)
{
if (ImGui::MenuItem(ProjectsStrings::Names[i]))
{
if (openProject(nc::fs::joinPath(ui::projectsDataDir, ProjectsStrings::Names[i]).data()))
numFrames = 0; // force focus on the canvas
}
}
ImGui::EndMenu();
}
if (ImGui::MenuItem(Labels::Save, "CTRL + S", false, menuSaveEnabled()))
menuSave();
if (ImGui::MenuItem(Labels::SaveAs, nullptr, false, menuSaveAsEnabled()))
menuSaveAs();
ImGui::Separator();
if (ImGui::MenuItem(Labels::QuickOpen, "F9", false, menuQuickOpenEnabled()))
menuQuickOpen();
if (ImGui::MenuItem(Labels::QuickSave, "F5", false, menuQuickSaveEnabled()))
menuQuickSave();
ImGui::Separator();
if (ImGui::MenuItem(Labels::Configuration))
showConfigWindow = true;
ImGui::Separator();
if (ImGui::MenuItem(Labels::Quit, "CTRL + Q"))
quit();
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Help"))
{
if (ImGui::MenuItem(Labels::Documentation, "F1", false, openDocumentationEnabled()))
openDocumentation();
if (ImGui::MenuItem(Labels::Tips))
showTipsWindow = true;
if (ImGui::MenuItem(Labels::About))
showAboutWindow = true;
ImGui::EndMenu();
}
ImGui::EndMenuBar();
}
}
void UserInterface::createToolbarWindow()
{
const ImGuiWindowFlags windowFlags = ImGuiWindowFlags_None | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("Toolbar", nullptr, windowFlags);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
if (ImGui::Button(Labels::New) && menuNewEnabled())
menuNew();
ImGui::SameLine();
if (ImGui::Button(Labels::Open))
menuOpen();
ImGui::SameLine();
if (ImGui::Button(Labels::Save) && menuSaveEnabled())
menuSave();
ImGui::SameLine();
if (ImGui::Button(Labels::SaveAs) && menuSaveAsEnabled())
menuSaveAs();
ImGui::SameLine();
if (ImGui::Button(Labels::QuickOpen) && menuQuickOpenEnabled())
menuQuickOpen();
ImGui::SameLine();
if (ImGui::Button(Labels::QuickSave) && menuQuickSaveEnabled())
menuQuickSave();
ImGui::SameLine();
if (ImGui::Button(Labels::Quit))
quit();
ImGui::PopStyleVar(2);
ImGui::End();
}
void UserInterface::recursiveRemoveSpriteWithTexture(SpriteGroup &group, Texture &tex)
{
// Deleting backwards without iterators
for (int i = group.children().size() - 1; i >= 0; i--)
{
Sprite *sprite = group.children()[i]->toSprite();
SpriteGroup *spriteGroup = group.children()[i]->toGroup();
if (sprite && &sprite->texture() == &tex)
{
updateSelectedAnimOnSpriteRemoval(sprite);
theAnimMgr->removeSprite(sprite);
group.children().removeAt(i);
}
else if (spriteGroup)
recursiveRemoveSpriteWithTexture(group, tex);
}
}
void UserInterface::removeTexture()
{
recursiveRemoveSpriteWithTexture(theSpriteMgr->root(), *theSpriteMgr->textures()[selectedTextureIndex_]);
theSpriteMgr->textures().removeAt(selectedTextureIndex_);
theSpriteMgr->updateSpritesArray();
if (selectedTextureIndex_ > 0)
selectedTextureIndex_--;
}
void openReloadTextureDialog()
{
FileDialog::config.directory = theCfg.texturesPath;
FileDialog::config.windowIcon = Labels::FileDialog_OpenIcon;
FileDialog::config.windowTitle = "Reload texture file";
FileDialog::config.okButton = Labels::Ok;
FileDialog::config.selectionType = FileDialog::SelectionType::FILE;
FileDialog::config.extensions = "png\0\0";
FileDialog::config.action = FileDialog::Action::RELOAD_TEXTURE;
FileDialog::config.windowOpen = true;
}
void UserInterface::createTexturesWindow()
{
ImGui::Begin(Labels::Textures);
#if defined(__ANDROID__) || defined(__EMSCRIPTEN__)
const bool openBundledEnabled = TexturesStrings::Count > 0;
if (openBundledEnabled)
{
ui::comboString.clear();
ui::comboString.append(Labels::BundledTextures);
ui::comboString.setLength(ui::comboString.length() + 1);
for (unsigned int i = 0; i < TexturesStrings::Count; i++)
{
ui::comboString.formatAppend("%s", TexturesStrings::Names[i]);
ui::comboString.setLength(ui::comboString.length() + 1);
}
ui::comboString.setLength(ui::comboString.length() + 1);
// Append a second '\0' to signal the end of the combo item list
ui::comboString[ui::comboString.length() - 1] = '\0';
static int currentComboTexture = 0;
if (ImGui::Combo("###BundledTextures", ¤tComboTexture, ui::comboString.data()) && currentComboTexture > 0)
{
loadTexture(nc::fs::joinPath(ui::texturesDataDir, TexturesStrings::Names[currentComboTexture - 1]).data());
currentComboTexture = 0;
}
}
#endif
if (ImGui::Button(Labels::Load))
{
#ifndef __EMSCRIPTEN__
FileDialog::config.directory = theCfg.texturesPath;
FileDialog::config.windowIcon = Labels::FileDialog_OpenIcon;
FileDialog::config.windowTitle = "Load texture file";
FileDialog::config.okButton = Labels::Ok;
FileDialog::config.selectionType = FileDialog::SelectionType::FILE;
FileDialog::config.extensions = "png\0\0";
FileDialog::config.action = FileDialog::Action::LOAD_TEXTURE;
FileDialog::config.windowOpen = true;
#else
loadTextureLocalFile_.load();
#endif
}
const bool enableButtons = theSpriteMgr->textures().isEmpty() == false;
ImGui::BeginDisabled(enableButtons == false);
ImGui::SameLine();
if (ImGui::Button(Labels::Remove) || (deleteKeyPressed && ImGui::IsWindowHovered()))
removeTexture();
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
if (ImGui::Button(Labels::Reload))
{
#ifndef __EMSCRIPTEN__
openReloadTextureDialog();
#else
reloadTextureLocalFile_.load();
#endif
}
ImGui::EndDisabled();
ImGui::Separator();
if (theSpriteMgr->textures().isEmpty() == false)
{
for (unsigned int i = 0; i < theSpriteMgr->textures().size(); i++)
{
Texture &texture = *theSpriteMgr->textures()[i];
ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen;
if (i == selectedTextureIndex_)
nodeFlags |= ImGuiTreeNodeFlags_Selected;
ImGui::TreeNodeEx(static_cast<void *>(&texture), nodeFlags, "#%u: \"%s\" (%d x %d)",
i, texture.name().data(), texture.width(), texture.height());
if (ImGui::IsItemHovered() && ImGui::GetCurrentContext()->HoveredIdTimer > imageTooltipDelay)
{
if (texture.width() > 0 && texture.height() > 0)
{
const float aspectRatio = texture.width() / static_cast<float>(texture.height());
float width = imageTooltipSize;
float height = imageTooltipSize;
if (aspectRatio > 1.0f)
height = width / aspectRatio;
else
width *= aspectRatio;
ImGui::BeginTooltip();
ImGui::Image(texture.imguiTexId(), ImVec2(width, height), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f));
ImGui::EndTooltip();
}
}
if (ImGui::IsItemClicked())
selectedTextureIndex_ = i;
if (ImGui::BeginPopupContextItem())
{
selectedTextureIndex_ = i;
if (ImGui::MenuItem(Labels::Reload))
{
#ifndef __EMSCRIPTEN__
openReloadTextureDialog();
#else
reloadTextureLocalFile_.load();
#endif
}
if (ImGui::MenuItem(Labels::Remove))
removeTexture();
ImGui::EndPopup();
}
}
}
ImGui::End();
}
void recursiveCloneSprite(const Sprite *parentSprite, Sprite *clonedParentSprite)
{
// Reverse for loop to add cloned child sprites after the original ones
for (int i = theSpriteMgr->sprites().size() - 1; i >= 0; i--)
{
Sprite *childSprite = theSpriteMgr->sprites()[i];
if (childSprite->parent() == parentSprite)
{
const int index = childSprite->indexInParent();
childSprite->parentGroup()->children().insertAt(index + 1, nctl::move(childSprite->clone()));
Sprite *clonedChildSprite = childSprite->parentGroup()->children()[index + 1]->toSprite();
clonedChildSprite->setParentGroup(childSprite->parentGroup());
clonedChildSprite->setParent(clonedParentSprite);
recursiveCloneSprite(childSprite, clonedChildSprite);
}
}
}
void UserInterface::cloneSprite()
{
// TODO: Should the name of a cloned anim, animGroup, sprite and spriteGroup have a "_%u" id suffix?
ASSERT(selectedSpriteEntry_->isSprite());
const Sprite *selectedSprite = selectedSpriteEntry_->toSprite();
const int index = selectedSpriteEntry_->indexInParent();
selectedSpriteEntry_->parentGroup()->children().insertAt(index + 1, nctl::move(selectedSprite->clone()));
Sprite *clonedSprite = selectedSpriteEntry_->parentGroup()->children()[index + 1]->toSprite();
clonedSprite->setParentGroup(selectedSpriteEntry_->parentGroup());
recursiveCloneSprite(selectedSprite, clonedSprite);
theSpriteMgr->updateSpritesArray();
selectedSpriteEntry_ = clonedSprite;
}
void UserInterface::cloneSpriteGroup()
{
ASSERT(selectedSpriteEntry_->isGroup());
const SpriteGroup *selectedGroup = selectedSpriteEntry_->toGroup();
const int index = selectedSpriteEntry_->indexInParent();
selectedSpriteEntry_->parentGroup()->children().insertAt(index + 1, nctl::move(selectedGroup->clone()));
SpriteGroup *clonedGroup = selectedSpriteEntry_->parentGroup()->children()[index + 1]->toGroup();
clonedGroup->setParentGroup(selectedSpriteEntry_->parentGroup());
theSpriteMgr->updateSpritesArray();
selectedSpriteEntry_ = clonedGroup;
}
void UserInterface::removeSprite()
{
ASSERT(selectedSpriteEntry_->isSprite());
Sprite *selectedSprite = selectedSpriteEntry_->toSprite();
SpriteEntry *newSelection = nullptr;
// Update sprite entry selection
nctl::Array<nctl::UniquePtr<SpriteEntry>> &children = selectedSprite->parentGroup()->children();
const int index = selectedSprite->indexInParent();
if (index > 0)
newSelection = children[index - 1].get();
else
{
if (children.size() > 1)
newSelection = children[index + 1].get();
else
newSelection = selectedSprite->parentGroup();
}
children.removeAt(index);
updateSelectedAnimOnSpriteRemoval(selectedSprite); // always before removing the animation
theAnimMgr->removeSprite(selectedSprite);
updateParentOnSpriteRemoval(selectedSprite);
theSpriteMgr->updateSpritesArray();
selectedSpriteEntry_ = newSelection;
}
void UserInterface::recursiveRemoveSpriteGroup(SpriteGroup &group)
{
for (unsigned int i = 0; i < group.children().size(); i++)
{
Sprite *childSprite = group.children()[i]->toSprite();
SpriteGroup *childGroup = group.children()[i]->toGroup();
if (childSprite)
{
updateSelectedAnimOnSpriteRemoval(childSprite); // always before removing the animation
theAnimMgr->removeSprite(childSprite);
updateParentOnSpriteRemoval(childSprite);
}
else if (childGroup)
recursiveRemoveSpriteGroup(*childGroup);
}
}
void UserInterface::removeSpriteGroup()
{
ASSERT(selectedSpriteEntry_->isGroup());
SpriteGroup *selectedGroup = selectedSpriteEntry_->toGroup();
recursiveRemoveSpriteGroup(*selectedGroup);
SpriteEntry *newSelection = nullptr;
// Update sprite entry selection
nctl::Array<nctl::UniquePtr<SpriteEntry>> &children = selectedGroup->parentGroup()->children();
const int index = selectedGroup->indexInParent();
if (index > 0)
newSelection = children[index - 1].get();
else
{
if (children.size() > 1)
newSelection = children[index + 1].get();
else
newSelection = selectedGroup->parentGroup();
}
children.removeAt(index);
theSpriteMgr->updateSpritesArray();
selectedSpriteEntry_ = newSelection;
}
struct DragSpriteEntryPayload
{
SpriteGroup &parent;
unsigned int index;
};
namespace {
bool editSpriteName = false;
}
void UserInterface::createSpriteListEntry(SpriteEntry &entry, unsigned int index)
{
static bool setFocus = false;
Sprite *sprite = entry.toSprite();
SpriteGroup *groupEntry = entry.toGroup();
bool treeIsOpen = false;
ui::auxString.clear();
if (sprite)
{
if (sprite->parentGroup() == &theSpriteMgr->root())
{
ui::auxString.format("###SpriteColor%lu", reinterpret_cast<uintptr_t>(sprite));
ImGui::ColorEdit3(ui::auxString.data(), entry.entryColor().data(), ImGuiColorEditFlags_NoInputs);
ImGui::SameLine();
}
// To preserve indentation no group is created
ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen;
if (selectedSpriteEntry_ == &entry)
nodeFlags |= ImGuiTreeNodeFlags_Selected;
ui::auxString.format("%s###Sprite%lu", sprite->visible ? Labels::VisibleIcon : Labels::InvisibleIcon, reinterpret_cast<uintptr_t>(sprite));
ImGui::Checkbox(ui::auxString.data(), &sprite->visible);
ImGui::SameLine();
ui::auxString.format("#%u: \"%s\" (%d x %d) %s", sprite->spriteId(), sprite->name.data(), sprite->width(), sprite->height(),
&sprite->texture() == theSpriteMgr->textures()[selectedTextureIndex_].get() ? Labels::SelectedTextureIcon : "");
if (editSpriteName && &entry == selectedSpriteEntry_)
{
ui::auxString.format("###SpriteName%lu", reinterpret_cast<uintptr_t>(sprite));
if (setFocus)
{
ImGui::SetKeyboardFocusHere();
setFocus = false;
}
ImGui::InputText(ui::auxString.data(), sprite->name.data(), sprite->name.capacity(),
ImGuiInputTextFlags_CallbackResize | ImGuiInputTextFlags_EnterReturnsTrue, ui::inputTextCallback, &sprite->name);
if (ImGui::IsItemDeactivated())
editSpriteName = false;
}
else
ImGui::TreeNodeEx(static_cast<void *>(sprite), nodeFlags, "%s", ui::auxString.data());
if (ImGui::BeginPopupContextItem())
{
selectedSpriteEntry_ = sprite;
const bool enableSelectParent = sprite->parent() != nullptr;
ImGui::BeginDisabled(enableSelectParent == false);
if (ImGui::MenuItem(Labels::SelectParent))
selectedSpriteEntry_ = sprite->parent();
ImGui::EndDisabled();
if (ImGui::MenuItem(Labels::SelectParentGroup))
selectedSpriteEntry_ = sprite->parentGroup();
ImGui::Separator();
if (ImGui::MenuItem(Labels::Clone))
cloneSprite();
if (ImGui::MenuItem(Labels::Remove))
removeSprite();
ImGui::EndPopup();
}
if (ImGui::IsItemHovered() && ImGui::GetCurrentContext()->HoveredIdTimer > imageTooltipDelay && editSpriteName == false)
{
if (sprite->texture().width() > 0 && sprite->texture().height() > 0 &&
sprite->texRect().w > 0 && sprite->texRect().h > 0)
{
const float invTextureWidth = 1.0f / sprite->texture().width();
const float invTextureHeight = 1.0f / sprite->texture().height();
const float aspectRatio = sprite->texRect().w / static_cast<float>(sprite->texRect().h);
const nc::Recti texRect = sprite->flippingTexRect();
const ImVec2 uv0(texRect.x * invTextureWidth, texRect.y * invTextureHeight);
const ImVec2 uv1(uv0.x + texRect.w * invTextureWidth, uv0.y + texRect.h * invTextureHeight);
float width = imageTooltipSize;
float height = imageTooltipSize;
if (aspectRatio > 1.0f)
height = width / aspectRatio;
else
width *= aspectRatio;
ImGui::BeginTooltip();
ImGui::Image(sprite->texture().imguiTexId(), ImVec2(width, height), uv0, uv1);
ImGui::EndTooltip();
}
}
}
else if (groupEntry)
{
ui::auxString.format("###GroupColor%lu", reinterpret_cast<uintptr_t>(groupEntry));
ImGui::ColorEdit3(ui::auxString.data(), groupEntry->entryColor().data(), ImGuiColorEditFlags_NoInputs);
ImGui::SameLine();
// To preserve indentation no group is created
ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_DefaultOpen;
if (selectedSpriteEntry_ == &entry)
nodeFlags |= ImGuiTreeNodeFlags_Selected;
ui::auxString.format("%s \"%s\"", Labels::GroupIcon, groupEntry->name().data());
if (editSpriteName && selectedSpriteEntry_ == &entry)
{
ui::auxString.format("###GroupName%lu", reinterpret_cast<uintptr_t>(groupEntry));
if (setFocus)
{
ImGui::SetKeyboardFocusHere();
setFocus = false;
}
ImGui::InputText(ui::auxString.data(), groupEntry->name().data(), groupEntry->name().capacity(),
ImGuiInputTextFlags_CallbackResize | ImGuiInputTextFlags_EnterReturnsTrue, ui::inputTextCallback, &groupEntry->name());
if (ImGui::IsItemDeactivated())
editSpriteName = false;
}
else
treeIsOpen = ImGui::TreeNodeEx(static_cast<void *>(groupEntry), nodeFlags, "%s", ui::auxString.data());
if (ImGui::BeginPopupContextItem())
{
selectedSpriteEntry_ = groupEntry;
if (ImGui::MenuItem(Labels::SelectParentGroup))
selectedSpriteEntry_ = groupEntry->parentGroup();
ImGui::Separator();
if (ImGui::MenuItem(Labels::Clone))
cloneSpriteGroup();
if (ImGui::MenuItem(Labels::Remove))
removeSpriteGroup();
ImGui::EndPopup();
}
}
if (ImGui::IsItemClicked())
{
selectedSpriteEntry_ = &entry;
editSpriteName = false;
if (ImGui::GetIO().KeyCtrl)
{
editSpriteName = true;
setFocus = true;
}
}
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAllowNullID))
{
ASSERT(entry.toGroup() != &theSpriteMgr->root());
DragSpriteEntryPayload dragPayload = { *entry.parentGroup(), index };
ImGui::SetDragDropPayload("SPRITEENTRY_TREENODE", &dragPayload, sizeof(DragSpriteEntryPayload));
ImGui::Text("%s", ui::auxString.data());
ImGui::EndDragDropSource();
}
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("SPRITEENTRY_TREENODE"))
{
IM_ASSERT(payload->DataSize == sizeof(DragSpriteEntryPayload));
const DragSpriteEntryPayload &dragPayload = *reinterpret_cast<const DragSpriteEntryPayload *>(payload->Data);
bool dragIsPossible = true;
if (dragPayload.parent.children()[dragPayload.index]->isGroup())
{
SpriteGroup *dragGrop = dragPayload.parent.children()[dragPayload.index]->toGroup();
SpriteGroup *destParent = entry.parentGroup();
while (destParent != nullptr)
{
if (destParent == dragGrop)
{
// Trying to drag a group inside one of its children
dragIsPossible = false;
break;
}
destParent = destParent->parentGroup();
}
}
if (dragIsPossible)
{
nctl::UniquePtr<SpriteEntry> dragEntry(nctl::move(dragPayload.parent.children()[dragPayload.index]));
selectedSpriteEntry_ = dragEntry.get(); // set before moving the unique pointer
dragPayload.parent.children().removeAt(dragPayload.index);
if (entry.isGroup())
{
dragEntry->setParentGroup(entry.toGroup());
entry.toGroup()->children().pushBack(nctl::move(dragEntry));
}
else
{
dragEntry->setParentGroup(entry.parentGroup());
entry.parentGroup()->children().insertAt(index, nctl::move(dragEntry));
}
theSpriteMgr->updateSpritesArray();
}
ImGui::EndDragDropTarget();
}
}
if (entry.isGroup() && treeIsOpen)
{
// Reversed order to match the rendering layer order
for (int i = groupEntry->children().size() - 1; i >= 0; i--)
createSpriteListEntry(*groupEntry->children()[i], i);
ImGui::TreePop();
}
}
void moveSpriteEntry(SpriteEntry &spriteEntry, unsigned int indexInParent, bool upDirection)
{
SpriteGroup *parentGroup = spriteEntry.parentGroup();
const unsigned int spriteId = spriteEntry.isSprite() ? spriteEntry.spriteId() : 0;
const int swapIndexDiff = upDirection ? 1 : -1;
nctl::swap(parentGroup->children()[indexInParent], parentGroup->children()[indexInParent + swapIndexDiff]);
if (spriteEntry.isSprite())
{
// Performing an explicit swap to avoid a call to `updateLinearArray()`
theSpriteMgr->sprites()[spriteId]->setSpriteId(spriteId + swapIndexDiff);
theSpriteMgr->sprites()[spriteId + swapIndexDiff]->setSpriteId(spriteId);
nctl::swap(theSpriteMgr->sprites()[spriteId], theSpriteMgr->sprites()[spriteId + swapIndexDiff]);
}
else
theSpriteMgr->updateSpritesArray();
}
void UserInterface::createSpritesWindow()
{
ImGui::Begin(Labels::Sprites);
if (theSpriteMgr->textures().isEmpty() == false)
{
if (ImGui::Button(Labels::Add))
{
if (selectedTextureIndex_ >= 0 && selectedTextureIndex_ < theSpriteMgr->textures().size())
{
if (theSpriteMgr->sprites().isEmpty())
numFrames = 0; // force focus on the canvas
Texture &tex = *theSpriteMgr->textures()[selectedTextureIndex_];
Sprite *addedSprite = theSpriteMgr->addSprite(selectedSpriteEntry_, &tex);
ui::auxString.format("Sprite%u", nextSpriteNameId());
addedSprite->name = ui::auxString;
selectedSpriteEntry_ = addedSprite;
theSpriteMgr->updateSpritesArray();
}
}
ImGui::SameLine();
if (ImGui::Button(Labels::AddGroup))
{
SpriteGroup *addedGroup = theSpriteMgr->addGroup(selectedSpriteEntry_);
ui::auxString.format("Group%u", nextSpriteNameId());
addedGroup->name() = ui::auxString;
selectedSpriteEntry_ = addedGroup;
theSpriteMgr->updateSpritesArray();
}
const bool enableRemoveButton = theSpriteMgr->children().isEmpty() == false && selectedSpriteEntry_ != &theSpriteMgr->root();
ImGui::BeginDisabled(enableRemoveButton == false);
ImGui::SameLine();
if (ImGui::Button(Labels::Remove) || (enableRemoveButton && deleteKeyPressed && ImGui::IsWindowHovered() && editSpriteName == false))
{
if (selectedSpriteEntry_->isSprite())
removeSprite();
else if (selectedSpriteEntry_->isGroup())
removeSpriteGroup();
}
ImGui::EndDisabled();
// Repeat the check after the remove button
const bool enableCloneButton = theSpriteMgr->children().isEmpty() == false && selectedSpriteEntry_ != &theSpriteMgr->root();
ImGui::BeginDisabled(enableCloneButton == false);
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
if (ImGui::Button(Labels::Clone))
{
if (selectedSpriteEntry_->isSprite())
cloneSprite();
else if (selectedSpriteEntry_->isGroup())
cloneSpriteGroup();
}
ImGui::EndDisabled();
const unsigned int indexInParent = selectedSpriteEntry_->indexInParent();
SpriteGroup *parentGroup = selectedSpriteEntry_->parentGroup();
const bool enableMoveUpButton = enableCloneButton && indexInParent < parentGroup->children().size() - 1;
ImGui::BeginDisabled(enableMoveUpButton == false);
if (ImGui::Button(Labels::MoveUp))
moveSpriteEntry(*selectedSpriteEntry_, indexInParent, true);
ImGui::EndDisabled();
ImGui::SameLine();
const bool enableMoveDownButton = enableCloneButton && indexInParent > 0;
ImGui::BeginDisabled(enableMoveDownButton == false);
if (ImGui::Button(Labels::MoveDown))
moveSpriteEntry(*selectedSpriteEntry_, indexInParent, false);
ImGui::EndDisabled();
if (ImGui::IsWindowHovered())
{
// Disable keyboard navigation
ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NavEnableKeyboard);
enableKeyboardNav = false;
if (enableMoveUpButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_UpArrow)))
moveSpriteEntry(*selectedSpriteEntry_, indexInParent, true);
if (enableMoveDownButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_DownArrow)))
moveSpriteEntry(*selectedSpriteEntry_, indexInParent, false);
}
ImGui::Separator();
}
else
ImGui::Text("Load at least one texture in order to add sprites");
if (theSpriteMgr->children().isEmpty() == false)
{
// Special group list entry for the root group in the sprite manager
ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_DefaultOpen;
if (selectedSpriteEntry_ == &theSpriteMgr->root())
nodeFlags |= ImGuiTreeNodeFlags_Selected;
ui::auxString.format("%s Root (%u children)", Labels::GroupIcon, theSpriteMgr->children().size());
// Force tree expansion to see the selected animation
if (selectedSpriteEntry_ && selectedSpriteEntry_ != &theSpriteMgr->root())
ImGui::SetNextItemOpen(true, ImGuiCond_Always);
const bool treeIsOpen = ImGui::TreeNodeEx(static_cast<void *>(&theSpriteMgr->root()), nodeFlags, "%s", ui::auxString.data());
if (ImGui::IsItemClicked())
selectedSpriteEntry_ = &theSpriteMgr->root();
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("SPRITEENTRY_TREENODE"))
{
IM_ASSERT(payload->DataSize == sizeof(DragSpriteEntryPayload));
const DragSpriteEntryPayload &dragPayload = *reinterpret_cast<const DragSpriteEntryPayload *>(payload->Data);
nctl::UniquePtr<SpriteEntry> dragEntry(nctl::move(dragPayload.parent.children()[dragPayload.index]));
selectedSpriteEntry_ = dragEntry.get(); // set before moving the unique pointer
dragPayload.parent.children().removeAt(dragPayload.index);
dragEntry->setParentGroup(&theSpriteMgr->root());
theSpriteMgr->children().pushBack(nctl::move(dragEntry));
theSpriteMgr->updateSpritesArray();
ImGui::EndDragDropTarget();
}
}
if (treeIsOpen)
{
// Reversed order to match the rendering layer order
for (int i = theSpriteMgr->children().size() - 1; i >= 0; i--)
createSpriteListEntry(*theSpriteMgr->children()[i], i);
ImGui::TreePop();
}
}
ImGui::End();
}
void UserInterface::removeScript()
{
Script *selectedScript = theScriptingMgr->scripts()[selectedScriptIndex_].get();
theAnimMgr->removeScript(selectedScript);
theScriptingMgr->scripts().removeAt(selectedScriptIndex_);
if (selectedScriptIndex_ > 0)
selectedScriptIndex_--;
}
void UserInterface::createScriptsWindow()
{
ImGui::Begin(Labels::Scripts);
const bool openBundledEnabled = ScriptsStrings::Count > 0;
if (openBundledEnabled)
{
ui::comboString.clear();
ui::comboString.append(Labels::BundledScripts);
ui::comboString.setLength(ui::comboString.length() + 1);
for (unsigned int i = 0; i < ScriptsStrings::Count; i++)
{
ui::comboString.formatAppend("%s", ScriptsStrings::Names[i]);
ui::comboString.setLength(ui::comboString.length() + 1);
}
ui::comboString.setLength(ui::comboString.length() + 1);
// Append a second '\0' to signal the end of the combo item list
ui::comboString[ui::comboString.length() - 1] = '\0';
static int currentComboScript = 0;
if (ImGui::Combo("###BundledScripts", ¤tComboScript, ui::comboString.data()) && currentComboScript > 0)
{
loadScript(nc::fs::joinPath(ui::scriptsDataDir, ScriptsStrings::Names[currentComboScript - 1]).data());
currentComboScript = 0;
}
}
if (ImGui::Button(Labels::Load))
{
FileDialog::config.directory = theCfg.scriptsPath;
FileDialog::config.windowIcon = Labels::FileDialog_OpenIcon;
FileDialog::config.windowTitle = "Load script file";
FileDialog::config.okButton = Labels::Ok;
FileDialog::config.selectionType = FileDialog::SelectionType::FILE;
FileDialog::config.extensions = "lua\0\0";
FileDialog::config.action = FileDialog::Action::LOAD_SCRIPT;
FileDialog::config.windowOpen = true;
}
const bool enableButtons = theScriptingMgr->scripts().isEmpty() == false;
ImGui::BeginDisabled(enableButtons == false);
ImGui::SameLine();
if (ImGui::Button(Labels::Remove) || (deleteKeyPressed && ImGui::IsWindowHovered()))
removeScript();
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
if (ImGui::Button(Labels::Reload))
reloadScript();
ImGui::EndDisabled();
ImGui::Separator();
if (theScriptingMgr->scripts().isEmpty() == false)
{
for (unsigned int i = 0; i < theScriptingMgr->scripts().size(); i++)
{
Script &script = *theScriptingMgr->scripts()[i];
ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen;
if (i == selectedScriptIndex_)
nodeFlags |= ImGuiTreeNodeFlags_Selected;
ui::auxString.format("#%u: \"%s\" %s", i, nc::fs::baseName(script.name().data()).data(), script.canRun() ? Labels::CheckIcon : Labels::TimesIcon);
ImGui::TreeNodeEx(static_cast<void *>(&script), nodeFlags, "%s", ui::auxString.data());
if (ImGui::IsItemClicked())
selectedScriptIndex_ = i;
if (ImGui::IsItemHovered() && script.canRun() == false)
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(450.0f);
ImGui::TextColored(ImVec4(0.925f, 0.243f, 0.251f, 1.0f), "%s", script.errorMsg());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
if (ImGui::BeginPopupContextItem())
{
selectedScriptIndex_ = i;
if (ImGui::MenuItem(Labels::Reload))
reloadScript();
if (ImGui::MenuItem(Labels::Remove))
removeScript();
ImGui::EndPopup();
}
}
}
ImGui::End();
}
void UserInterface::removeAnimation()
{
IAnimation *newSelection = nullptr;
if (selectedAnimation_->parent())
{
nctl::Array<nctl::UniquePtr<IAnimation>> &anims = selectedAnimation_->parent()->anims();
const int index = selectedAnimation_->indexInParent();
if (index > 0)
newSelection = anims[index - 1].get();
else
{
if (anims.size() > 1)
newSelection = anims[index + 1].get();
else
newSelection = selectedAnimation_->parent();
}
}
theAnimMgr->removeAnimation(selectedAnimation_);
selectedAnimation_ = newSelection;
}
struct DragAnimationPayload
{
AnimationGroup &parent;
unsigned int index;
};
namespace {
IAnimation *removeAnimWithContextMenu = nullptr;
bool editAnimName = false;
}
void UserInterface::createAnimationListEntry(IAnimation &anim, unsigned int index, unsigned int &animId)
{
static bool setFocus = false;
ImGuiTreeNodeFlags nodeFlags = anim.isGroup() ? (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_DefaultOpen)
: (ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen);
if (&anim == selectedAnimation_)
nodeFlags |= ImGuiTreeNodeFlags_Selected;
AnimationGroup *animGroup = nullptr;
if (anim.isGroup())
animGroup = static_cast<AnimationGroup *>(&anim);
// To preserve indentation no group is created
if (anim.isGroup() == false)
{
SpriteEntry *spriteEntry = nullptr;
if (anim.type() == IAnimation::Type::PROPERTY)
spriteEntry = static_cast<PropertyAnimation &>(anim).sprite();
else if (anim.type() == IAnimation::Type::GRID)
spriteEntry = static_cast<GridAnimation &>(anim).sprite();
else if (anim.type() == IAnimation::Type::SCRIPT)
spriteEntry = static_cast<ScriptAnimation &>(anim).sprite();
if (spriteEntry != nullptr)
{
ui::auxString.format("###AnimColor%lu", reinterpret_cast<uintptr_t>(spriteEntry));
nc::Colorf entryColor = spriteEntry->entryColor();
if (spriteEntry->parentGroup() != &theSpriteMgr->root())
entryColor = spriteEntry->parentGroup()->entryColor();
const ImVec4 entryVecColor(entryColor);
ImGui::ColorButton(ui::auxString.data(), entryVecColor, ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoDragDrop);
ImGui::SameLine();
}
}
ui::auxString.format("%s###Anim%lu", anim.enabled ? Labels::EnabledAnimIcon : Labels::DisabledAnimIcon, reinterpret_cast<uintptr_t>(&anim));
ImGui::Checkbox(ui::auxString.data(), &anim.enabled);
ImGui::SameLine();
ui::auxString.clear();
if (anim.isGroup())
ui::auxString.format("%s ", Labels::GroupIcon);
ui::auxString.formatAppend("#%u: ", animId);
if (anim.name.isEmpty() == false)
ui::auxString.formatAppend("\"%s\" (", anim.name.data());
if (anim.type() == IAnimation::Type::PARALLEL_GROUP)
ui::auxString.formatAppend("Parallel Group (%u children)", animGroup->anims().size());
else if (anim.type() == IAnimation::Type::SEQUENTIAL_GROUP)
ui::auxString.formatAppend("Sequential Group (%u children)", animGroup->anims().size());
if (anim.type() == IAnimation::Type::PROPERTY)
{
PropertyAnimation &propertyAnim = static_cast<PropertyAnimation &>(anim);
ui::auxString.formatAppend("%s property", propertyAnim.propertyName());
if (propertyAnim.sprite() != nullptr)
{
if (propertyAnim.sprite()->name.isEmpty() == false)
ui::auxString.formatAppend(" for sprite \"%s\"", propertyAnim.sprite()->name.data());
if (propertyAnim.sprite() == selectedSpriteEntry_)
ui::auxString.formatAppend(" %s", Labels::SelectedSpriteIcon);
if (propertyAnim.isLocked())
ui::auxString.formatAppend(" %s", Labels::LockedAnimIcon);
}
}
else if (anim.type() == IAnimation::Type::GRID)
{
GridAnimation &gridAnim = static_cast<GridAnimation &>(anim);
ui::auxString.formatAppend("%s grid", (gridAnim.function() != nullptr) ? gridAnim.function()->name().data() : "None");
if (gridAnim.sprite() != nullptr)
{
if (gridAnim.sprite()->name.isEmpty() == false)
ui::auxString.formatAppend(" for sprite \"%s\"", gridAnim.sprite()->name.data());
if (gridAnim.sprite() == selectedSpriteEntry_)
ui::auxString.formatAppend(" %s", Labels::SelectedSpriteIcon);
if (gridAnim.isLocked())
ui::auxString.formatAppend(" %s", Labels::LockedAnimIcon);
}
}
else if (anim.type() == IAnimation::Type::SCRIPT)
{
ScriptAnimation &scriptAnim = static_cast<ScriptAnimation &>(anim);
ui::auxString.append("Script");
if (scriptAnim.sprite() != nullptr)
{
if (scriptAnim.sprite()->name.isEmpty() == false)
ui::auxString.formatAppend(" for sprite \"%s\"", scriptAnim.sprite()->name.data());
if (scriptAnim.sprite() == selectedSpriteEntry_)
ui::auxString.formatAppend(" %s", Labels::SelectedSpriteIcon);
if (scriptAnim.isLocked())
ui::auxString.formatAppend(" %s", Labels::LockedAnimIcon);
}
}
if (anim.name.isEmpty() == false)
ui::auxString.append(")");
if (anim.state() == IAnimation::State::STOPPED)
ui::auxString.formatAppend(" %s", Labels::StopIcon);
else if (anim.state() == IAnimation::State::PAUSED)
ui::auxString.formatAppend(" %s", Labels::PauseIcon);
else if (anim.state() == IAnimation::State::PLAYING)
ui::auxString.formatAppend(" %s", Labels::PlayIcon);
// Force tree expansion to see the selected animation
if (selectedAnimation_ && animGroup && (selectedAnimation_ != animGroup))
{
if (animGroup == selectedAnimation_->parent())
ImGui::SetNextItemOpen(true, ImGuiCond_Always);
}
bool treeIsOpen = false;
if (editAnimName && selectedAnimation_ == &anim)
{
ui::auxString.format("###AnimationName%lu", reinterpret_cast<uintptr_t>(&anim));
if (setFocus)
{
ImGui::SetKeyboardFocusHere();
setFocus = false;
}
if ((nodeFlags & ImGuiTreeNodeFlags_Leaf) == 0)
{
nodeFlags |= ImGuiTreeNodeFlags_AllowItemOverlap;
treeIsOpen = ImGui::TreeNodeEx(static_cast<void *>(&anim), nodeFlags, "");
ImGui::SameLine();
}
ImGui::InputText(ui::auxString.data(), anim.name.data(), anim.name.capacity(),
ImGuiInputTextFlags_CallbackResize | ImGuiInputTextFlags_EnterReturnsTrue, ui::inputTextCallback, &anim.name);
if (ImGui::IsItemDeactivated())
editAnimName = false;
}
else
treeIsOpen = ImGui::TreeNodeEx(static_cast<void *>(&anim), nodeFlags, "%s", ui::auxString.data());
if (ImGui::IsItemClicked())
{
if (selectedAnimation_ != &anim)
editAnimName = false;
selectedAnimation_ = &anim;
if (ImGui::GetIO().KeyCtrl)
{
editAnimName = true;
setFocus = true;
}
if (anim.type() == IAnimation::Type::PROPERTY)
{
PropertyAnimation &propertyAnim = static_cast<PropertyAnimation &>(anim);
if (propertyAnim.sprite())
selectedSpriteEntry_ = propertyAnim.sprite();
}
else if (anim.type() == IAnimation::Type::GRID)
{
GridAnimation &gridAnim = static_cast<GridAnimation &>(anim);
if (gridAnim.sprite())
selectedSpriteEntry_ = gridAnim.sprite();
}
else if (anim.type() == IAnimation::Type::SCRIPT)
{
ScriptAnimation &scriptAnim = static_cast<ScriptAnimation &>(anim);
if (scriptAnim.sprite())
selectedSpriteEntry_ = scriptAnim.sprite();
}
}
if (ImGui::BeginPopupContextItem())
{
selectedAnimation_ = &anim;
if (ImGui::MenuItem(Labels::Play))
selectedAnimation_->play();
if (ImGui::MenuItem(Labels::Pause))
selectedAnimation_->pause();
if (ImGui::MenuItem(Labels::Stop))
selectedAnimation_->stop();
ImGui::Separator();
const bool showLocked = anim.isGroup() == false;
if (showLocked)
{
CurveAnimation &curveAnim = static_cast<CurveAnimation &>(anim);
bool locked = curveAnim.isLocked();
ui::auxString.format("Locked %s", Labels::LockedAnimIcon);
ImGui::Checkbox(ui::auxString.data(), &locked);
curveAnim.setLocked(locked);
}
if (ImGui::MenuItem(Labels::SelectParent))
selectedAnimation_ = anim.parent();
ImGui::Separator();
if (ImGui::MenuItem(Labels::Clone))
selectedAnimation_->parent()->anims().insertAt(++index, nctl::move(selectedAnimation_->clone()));
if (ImGui::MenuItem(Labels::Remove))
removeAnimWithContextMenu = &anim;
ImGui::EndPopup();
}
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None))
{
DragAnimationPayload dragPayload = { *anim.parent(), index };
ImGui::SetDragDropPayload("ANIMATION_TREENODE", &dragPayload, sizeof(DragAnimationPayload));
ImGui::Text("%s", ui::auxString.data());
ImGui::EndDragDropSource();
}
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("ANIMATION_TREENODE"))
{
IM_ASSERT(payload->DataSize == sizeof(DragAnimationPayload));
const DragAnimationPayload &dragPayload = *reinterpret_cast<const DragAnimationPayload *>(payload->Data);
bool dragIsPossible = true;
if (dragPayload.parent.anims()[dragPayload.index]->isGroup())
{
AnimationGroup *dragAnimGroup = static_cast<AnimationGroup *>(dragPayload.parent.anims()[dragPayload.index].get());
AnimationGroup *destParent = anim.parent();
while (destParent != nullptr)
{
if (destParent == dragAnimGroup)
{
// Trying to drag a parent group inside a children
dragIsPossible = false;
break;
}
destParent = destParent->parent();
}
}
if (dragIsPossible)
{
nctl::UniquePtr<IAnimation> dragAnimation(nctl::move(dragPayload.parent.anims()[dragPayload.index]));
selectedAnimation_ = dragAnimation.get(); // set before moving the unique pointer
dragPayload.parent.anims().removeAt(dragPayload.index);
if (anim.isGroup())
{
dragAnimation->setParent(animGroup);
animGroup->anims().pushBack(nctl::move(dragAnimation));
}
else
{
dragAnimation->setParent(anim.parent());
anim.parent()->anims().insertAt(index, nctl::move(dragAnimation));
}
}
ImGui::EndDragDropTarget();
}
}
animId++;
if (anim.isGroup() && treeIsOpen)
{
for (unsigned int i = 0; i < animGroup->anims().size(); i++)
createAnimationListEntry(*animGroup->anims()[i], i, animId);
ImGui::TreePop();
}
}
void UserInterface::createAnimationsWindow()
{
ImGui::Begin(Labels::Animations);
static int currentComboAnimType = 0;
ImGui::PushItemWidth(150.0f);
ImGui::Combo("Type", ¤tComboAnimType, animationTypes, IM_ARRAYSIZE(animationTypes));
ImGui::PopItemWidth();
ImGui::SameLine();
if (ImGui::Button(Labels::Add))
{
nctl::Array<nctl::UniquePtr<IAnimation>> *anims = &theAnimMgr->anims();
AnimationGroup *parent = &theAnimMgr->animGroup();
if (selectedAnimation_)
{
if (selectedAnimation_->isGroup())
{
AnimationGroup *animGroup = static_cast<AnimationGroup *>(selectedAnimation_);
anims = &animGroup->anims();
parent = animGroup;
}
else if (selectedAnimation_->parent() != nullptr)
{
anims = &selectedAnimation_->parent()->anims();
parent = selectedAnimation_->parent();
}
}
Sprite *selectedSprite = selectedSpriteEntry_->toSprite();
// Search the index of the selected animation in its parent
unsigned int selectedIndex = anims->size() - 1;
for (unsigned int i = 0; i < anims->size(); i++)
{
if ((*anims)[i].get() == selectedAnimation_)
{
selectedIndex = i;
break;
}
}
switch (currentComboAnimType)
{
case AnimationTypesEnum::PARALLEL_GROUP:
anims->insertAt(++selectedIndex, nctl::makeUnique<ParallelAnimationGroup>());
break;
case AnimationTypesEnum::SEQUENTIAL_GROUP:
anims->insertAt(++selectedIndex, nctl::makeUnique<SequentialAnimationGroup>());
break;
case AnimationTypesEnum::PROPERTY:
anims->insertAt(++selectedIndex, nctl::makeUnique<PropertyAnimation>(selectedSprite));
static_cast<PropertyAnimation &>(*(*anims)[selectedIndex]).setProperty(Properties::Types::NONE);
break;
case AnimationTypesEnum::GRID:
anims->insertAt(++selectedIndex, nctl::makeUnique<GridAnimation>(selectedSprite));
break;
case AnimationTypesEnum::SCRIPT:
Script *selectedScript = nullptr;
if (theScriptingMgr->scripts().isEmpty() == false &&
selectedScriptIndex_ >= 0 && selectedScriptIndex_ <= theScriptingMgr->scripts().size() - 1)
{
selectedScript = theScriptingMgr->scripts()[selectedScriptIndex_].get();
}
anims->insertAt(++selectedIndex, nctl::makeUnique<ScriptAnimation>(selectedSprite, selectedScript));
break;
}
(*anims)[selectedIndex]->setParent(parent);
selectedAnimation_ = (*anims)[selectedIndex].get();
if (selectedAnimation_->isGroup())
ui::auxString.format("AnimGroup%u", nextAnimNameId());
else
ui::auxString.format("Anim%u", nextAnimNameId());
selectedAnimation_->name = ui::auxString;
}
// Remove an animation as instructed by the context menu
if (removeAnimWithContextMenu)
{
selectedAnimation_ = removeAnimWithContextMenu;
removeAnimation();
removeAnimWithContextMenu = nullptr;
}
const bool enableRemoveButton = selectedAnimation_ && selectedAnimation_ != &theAnimMgr->animGroup();
ImGui::BeginDisabled(enableRemoveButton == false);
ImGui::SameLine();
if (ImGui::Button(Labels::Remove) || (deleteKeyPressed && ImGui::IsWindowHovered() && editAnimName == false))
removeAnimation();
ImGui::EndDisabled();
// Search the index of the selected animation in its parent
int selectedIndex = selectedAnimation_ ? selectedAnimation_->indexInParent() : -1;
// Repeat the check after the remove button
const bool enableCloneButton = selectedAnimation_ && selectedAnimation_ != &theAnimMgr->animGroup();
ImGui::BeginDisabled(enableCloneButton == false);
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
if (ImGui::Button(Labels::Clone))
selectedAnimation_->parent()->anims().insertAt(++selectedIndex, nctl::move(selectedAnimation_->clone()));
ImGui::EndDisabled();
const bool enablePlayButtons = selectedAnimation_ != nullptr && theAnimMgr->anims().isEmpty() == false;
ImGui::BeginDisabled(enablePlayButtons == false);
if (ImGui::Button(Labels::Stop))
selectedAnimation_->stop();
ImGui::SameLine();
if (ImGui::Button(Labels::Pause))
selectedAnimation_->pause();
ImGui::SameLine();
if (ImGui::Button(Labels::Play))
selectedAnimation_->play();
ImGui::EndDisabled();
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
const bool enableMoveUpButton = enableCloneButton && selectedIndex > 0;
ImGui::BeginDisabled(enableMoveUpButton == false);
ImGui::SameLine();
if (ImGui::Button(Labels::MoveUp))
nctl::swap(selectedAnimation_->parent()->anims()[selectedIndex], selectedAnimation_->parent()->anims()[selectedIndex - 1]);
ImGui::EndDisabled();
const bool enableMoveDownButton = enableCloneButton && selectedIndex < selectedAnimation_->parent()->anims().size() - 1;
ImGui::BeginDisabled(enableMoveDownButton == false);
ImGui::SameLine();
if (ImGui::Button(Labels::MoveDown))
nctl::swap(selectedAnimation_->parent()->anims()[selectedIndex], selectedAnimation_->parent()->anims()[selectedIndex + 1]);
ImGui::EndDisabled();
if (ImGui::IsWindowHovered())
{
// Disable keyboard navigation
ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NavEnableKeyboard);
enableKeyboardNav = false;
if (enableMoveUpButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_UpArrow)))
nctl::swap(selectedAnimation_->parent()->anims()[selectedIndex], selectedAnimation_->parent()->anims()[selectedIndex - 1]);
if (enableMoveDownButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_DownArrow)))
nctl::swap(selectedAnimation_->parent()->anims()[selectedIndex], selectedAnimation_->parent()->anims()[selectedIndex + 1]);
}
ImGui::PushItemWidth(200.0f);
ImGui::SliderFloat("Speed Multiplier", &theAnimMgr->speedMultiplier(), 0.0f, 5.0f);
ImGui::PopItemWidth();
ImGui::SameLine();
ui::auxString.format("%s##Speed Multiplier", Labels::Reset);
if (ImGui::Button(ui::auxString.data()))
theAnimMgr->speedMultiplier() = 1.0f;
ImGui::Separator();
if (theAnimMgr->anims().isEmpty() == false)
{
// Special animation list entry for the root animation group in the animation manager
ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_DefaultOpen;
if (selectedAnimation_ == &theAnimMgr->animGroup())
nodeFlags |= ImGuiTreeNodeFlags_Selected;
ui::auxString.format("%s Root (%u children)", Labels::GroupIcon, theAnimMgr->anims().size());
if (theAnimMgr->animGroup().state() == IAnimation::State::STOPPED)
ui::auxString.formatAppend(" %s", Labels::StopIcon);
else if (theAnimMgr->animGroup().state() == IAnimation::State::PAUSED)
ui::auxString.formatAppend(" %s", Labels::PauseIcon);
else if (theAnimMgr->animGroup().state() == IAnimation::State::PLAYING)
ui::auxString.formatAppend(" %s", Labels::PlayIcon);
// Force tree expansion to see the selected animation
if (selectedAnimation_ && selectedAnimation_ != &theAnimMgr->animGroup())
ImGui::SetNextItemOpen(true, ImGuiCond_Always);
const bool treeIsOpen = ImGui::TreeNodeEx(static_cast<void *>(&theAnimMgr->animGroup()), nodeFlags, "%s", ui::auxString.data());
if (ImGui::IsItemClicked())
selectedAnimation_ = &theAnimMgr->animGroup();
if (ImGui::BeginPopupContextItem())
{
selectedAnimation_ = &theAnimMgr->animGroup();
if (ImGui::MenuItem(Labels::Play))
theAnimMgr->animGroup().play();
if (ImGui::MenuItem(Labels::Pause))
theAnimMgr->animGroup().pause();
if (ImGui::MenuItem(Labels::Stop))
theAnimMgr->animGroup().stop();
ImGui::EndPopup();
}
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("ANIMATION_TREENODE"))
{
IM_ASSERT(payload->DataSize == sizeof(DragAnimationPayload));
const DragAnimationPayload &dragPayload = *reinterpret_cast<const DragAnimationPayload *>(payload->Data);
nctl::UniquePtr<IAnimation> dragAnimation(nctl::move(dragPayload.parent.anims()[dragPayload.index]));
selectedAnimation_ = dragAnimation.get(); // set before moving the unique pointer
dragPayload.parent.anims().removeAt(dragPayload.index);
dragAnimation->setParent(&theAnimMgr->animGroup());
theAnimMgr->anims().pushBack(nctl::move(dragAnimation));
ImGui::EndDragDropTarget();
}
}
if (treeIsOpen)
{
unsigned int animId = 0;
for (unsigned int i = 0; i < theAnimMgr->anims().size(); i++)
createAnimationListEntry(*theAnimMgr->anims()[i], i, animId);
ImGui::TreePop();
}
}
ImGui::End();
}
void UserInterface::createSpriteWindow()
{
ImGui::Begin(Labels::Sprite);
if (selectedSpriteEntry_->isSprite())
{
Sprite &sprite = *selectedSpriteEntry_->toSprite();
ImGui::InputText("Name", sprite.name.data(), Sprite::MaxNameLength,
ImGuiInputTextFlags_CallbackResize, ui::inputTextCallback, &sprite.name);
int currentTextureCombo = theSpriteMgr->textureIndex(&sprite.texture());
ui::comboString.clear();
for (unsigned int i = 0; i < theSpriteMgr->textures().size(); i++)
{
const Texture ¤tTex = *theSpriteMgr->textures()[i];
ui::comboString.formatAppend("#%u: \"%s\" (%d x %d)", i, currentTex.name().data(), currentTex.width(), currentTex.height());
ui::comboString.setLength(ui::comboString.length() + 1);
}
ui::comboString.setLength(ui::comboString.length() + 1);
// Append a second '\0' to signal the end of the combo item list
ui::comboString[ui::comboString.length() - 1] = '\0';
ImGui::Combo("Texture", ¤tTextureCombo, ui::comboString.data());
Texture *newTexture = theSpriteMgr->textures()[currentTextureCombo].get();
if (&sprite.texture() != newTexture)
{
nc::Recti texRect = sprite.texRect();
sprite.setTexture(newTexture);
if (newTexture->width() > texRect.x && newTexture->height() > texRect.y)
{
if (newTexture->width() < texRect.x + texRect.w)
texRect.w = newTexture->width() - texRect.x;
if (newTexture->height() < texRect.y + texRect.h)
texRect.h = newTexture->width() - texRect.y;
sprite.setTexRect(texRect);
}
}
// Create an array of sprites that can be a parent of the selected one
static SpriteEntry *lastSelectedSpriteEntry = nullptr;
if (lastSelectedSpriteEntry != selectedSpriteEntry_)
{
spriteGraph_.clear();
spriteGraph_.pushBack(SpriteStruct(-1, nullptr));
for (unsigned int i = 0; i < theSpriteMgr->sprites().size(); i++)
theSpriteMgr->sprites()[i]->visited = false;
visitSprite(sprite);
for (unsigned int i = 0; i < theSpriteMgr->sprites().size(); i++)
{
if (theSpriteMgr->sprites()[i]->visited == false)
spriteGraph_.pushBack(SpriteStruct(i, theSpriteMgr->sprites()[i]));
}
lastSelectedSpriteEntry = selectedSpriteEntry_;
}
const ImVec2 colorButtonComboSize(ImGui::GetTextLineHeight(), ImGui::GetTextLineHeight());
Sprite *parentSprite = sprite.parent();
if (ImGui::BeginCombo("Parent", "", ImGuiComboFlags_CustomPreview))
{
// Reversed order to match the rendering layer order
for (int i = spriteGraph_.size() - 1; i >= 0; i--)
{
const int index = spriteGraph_[i].index;
Sprite *currentSprite = spriteGraph_[i].sprite;
if (index >= 0)
{
ImGui::PushID(currentSprite);
const bool isSelected = (parentSprite == currentSprite);
if (ImGui::Selectable("", isSelected))
parentSprite = currentSprite;
if (isSelected)
ImGui::SetItemDefaultFocus();
ImGui::SameLine();
nc::Colorf entryColor = currentSprite->entryColor();
if (currentSprite->parentGroup() != &theSpriteMgr->root())
entryColor = currentSprite->parentGroup()->entryColor();
const ImVec4 color(entryColor);
ImGui::ColorButton(currentSprite->name.data(), color, ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop, colorButtonComboSize);
ImGui::SameLine();
ImGui::Text("#%d: \"%s\"", currentSprite->spriteId(), currentSprite->name.data());
ImGui::PopID();
}
else
{
if (ImGui::Selectable("None", parentSprite == nullptr))
parentSprite = nullptr;
}
}
ImGui::EndCombo();
}
if (ImGui::BeginComboPreview())
{
if (parentSprite != nullptr)
{
nc::Colorf entryColor = parentSprite->entryColor();
if (parentSprite->parentGroup() != &theSpriteMgr->root())
entryColor = parentSprite->parentGroup()->entryColor();
const ImVec4 entryVecColor(entryColor);
ImGui::ColorButton(parentSprite->name.data(), entryVecColor, ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop, colorButtonComboSize);
ImGui::SameLine();
ImGui::Text("#%d: \"%s\"", parentSprite->spriteId(), parentSprite->name.data());
}
else
ImGui::TextUnformatted("None");
ImGui::EndComboPreview();
}
const Sprite *prevParent = sprite.parent();
if (prevParent != parentSprite)
{
const nc::Vector2f absPosition = sprite.absPosition();
sprite.setParent(parentSprite);
sprite.setAbsPosition(absPosition);
}
ImGui::Separator();
nc::Vector2f position(sprite.x, sprite.y);
ImGui::SliderFloat2("Position", position.data(), 0.0f, static_cast<float>(theCanvas->texWidth()));
sprite.x = roundf(position.x);
sprite.y = roundf(position.y);
ImGui::SliderFloat("Rotation", &sprite.rotation, 0.0f, 360.0f);
ImGui::SliderFloat2("Scale", sprite.scaleFactor.data(), 0.0f, 8.0f);
ImGui::SameLine();
ui::auxString.format("%s##Scale", Labels::Reset);
if (ImGui::Button(ui::auxString.data()))
sprite.scaleFactor.set(1.0f, 1.0f);
const float halfBiggerDimension = sprite.width() > sprite.height() ? sprite.width() * 0.5f : sprite.height() * 0.5f;
ImGui::SliderFloat2("Anchor Point", sprite.anchorPoint.data(), -halfBiggerDimension, halfBiggerDimension);
static int currentAnchorSelection = 0;
if (ImGui::Combo("Anchor Presets", ¤tAnchorSelection, anchorPointItems, IM_ARRAYSIZE(anchorPointItems)))
{
switch (currentAnchorSelection)
{
case AnchorPointsEnum::CENTER:
sprite.anchorPoint.set(0.0f, 0.0f);
break;
case AnchorPointsEnum::BOTTOM_LEFT:
sprite.anchorPoint.set(-sprite.width() * 0.5f, sprite.height() * 0.5f);
break;
case AnchorPointsEnum::TOP_LEFT:
sprite.anchorPoint.set(-sprite.width() * 0.5f, -sprite.height() * 0.5f);
break;
case AnchorPointsEnum::BOTTOM_RIGHT:
sprite.anchorPoint.set(sprite.width() * 0.5f, sprite.height() * 0.5f);
break;
case AnchorPointsEnum::TOP_RIGHT:
sprite.anchorPoint.set(sprite.width() * 0.5f, -sprite.height() * 0.5f);
break;
}
}
sprite.anchorPoint.x = roundf(sprite.anchorPoint.x);
sprite.anchorPoint.y = roundf(sprite.anchorPoint.y);
if (sprite.parent() != nullptr)
{
ImGui::Text("Abs Position: %f, %f", sprite.absPosition().x, sprite.absPosition().y);
ImGui::Text("Abs Rotation: %f", sprite.absRotation());
ImGui::Text("Abs Scale: %f, %f", sprite.absScaleFactor().x, sprite.absScaleFactor().y);
}
ImGui::Separator();
nc::Recti texRect = sprite.texRect();
int minX = texRect.x;
int maxX = minX + texRect.w;
ImGui::DragIntRange2("Rect X", &minX, &maxX, 1.0f, 0, sprite.texture().width());
int minY = texRect.y;
int maxY = minY + texRect.h;
ImGui::DragIntRange2("Rect Y", &minY, &maxY, 1.0f, 0, sprite.texture().height());
texRect.x = minX;
texRect.w = maxX - minX;
texRect.y = minY;
texRect.h = maxY - minY;
if (texRect.x < 0)
texRect.x = 0;
if (texRect.w <= 0)
texRect.w = 1;
if (texRect.y < 0)
texRect.y = 0;
if (texRect.h <= 0)
texRect.h = 1;
ImGui::SameLine();
ui::auxString.format("%s##Rect", Labels::Reset);
if (ImGui::Button(ui::auxString.data()))
texRect = nc::Recti(0, 0, sprite.texture().width(), sprite.texture().height());
const nc::Recti currentTexRect = sprite.texRect();
if (texRect.x != currentTexRect.x || texRect.y != currentTexRect.y ||
texRect.w != currentTexRect.w || texRect.h != currentTexRect.h)
{
sprite.setTexRect(texRect);
}
bool isFlippedX = sprite.isFlippedX();
ImGui::Checkbox("Flipped X", &isFlippedX);
ImGui::SameLine();
bool isFlippedY = sprite.isFlippedY();
ImGui::Checkbox("Flipped Y", &isFlippedY);
if (isFlippedX != sprite.isFlippedX())
sprite.setFlippedX(isFlippedX);
if (isFlippedY != sprite.isFlippedY())
sprite.setFlippedY(isFlippedY);
ImGui::Separator();
int currentRgbBlendingPreset = static_cast<int>(sprite.rgbBlendingPreset());
ImGui::Combo("RGB Blending", ¤tRgbBlendingPreset, blendingPresets, IM_ARRAYSIZE(blendingPresets));
sprite.setRgbBlendingPreset(static_cast<Sprite::BlendingPreset>(currentRgbBlendingPreset));
int currentAlphaBlendingPreset = static_cast<int>(sprite.alphaBlendingPreset());
ImGui::Combo("Alpha Blending", ¤tAlphaBlendingPreset, blendingPresets, IM_ARRAYSIZE(blendingPresets));
sprite.setAlphaBlendingPreset(static_cast<Sprite::BlendingPreset>(currentAlphaBlendingPreset));
ImGui::ColorEdit4("Color", sprite.color.data(), ImGuiColorEditFlags_AlphaBar);
ImGui::SameLine();
ui::auxString.format("%s##Color", Labels::Reset);
if (ImGui::Button(ui::auxString.data()))
sprite.color = nc::Colorf::White;
}
ImGui::End();
}
void UserInterface::createDelayAnimationGui(IAnimation &anim)
{
float delay = anim.delay();
ImGui::SliderFloat("Delay", &delay, 0.0f, 10.0f, "%.3fs");
if (delay < 0.0f)
delay = 0.0f;
anim.setDelay(delay);
ui::auxString.format("%.3fs / %.3fs", anim.currentDelay(), anim.delay());
if (anim.delay() > 0)
ImGui::ProgressBar(anim.currentDelay() / anim.delay(), ImVec2(0.0f, 0.0f), ui::auxString.data());
}
void UserInterface::createLoopAnimationGui(LoopComponent &loop)
{
int currentLoopDirection = static_cast<int>(loop.direction());
ImGui::Combo("Direction", ¤tLoopDirection, loopDirections, IM_ARRAYSIZE(loopDirections));
loop.setDirection(static_cast<Loop::Direction>(currentLoopDirection));
int currentLoopMode = static_cast<int>(loop.mode());
ImGui::Combo("Loop Mode", ¤tLoopMode, loopModes, IM_ARRAYSIZE(loopModes));
loop.setMode(static_cast<Loop::Mode>(currentLoopMode));
if (loop.mode() != Loop::Mode::DISABLED)
{
float loopDelay = loop.delay();
ImGui::SliderFloat("Loop Delay", &loopDelay, 0.0f, 10.0f, "%.3fs");
if (loopDelay < 0.0f)
loopDelay = 0.0f;
loop.setDelay(loopDelay);
ui::auxString.format("%.3fs / %.3fs", loop.currentDelay(), loopDelay);
if (loopDelay > 0.0f)
ImGui::ProgressBar(loop.currentDelay() / loopDelay, ImVec2(0.0f, 0.0f), ui::auxString.data());
}
}
void UserInterface::createOverrideSpriteGui(AnimationGroup &animGroup)
{
if (animGroup.anims().isEmpty() == false)
{
static Sprite *animSprite = nullptr;
const ImVec2 colorButtonComboSize(ImGui::GetTextLineHeight(), ImGui::GetTextLineHeight());
bool comboReturnValue = false;
if ((comboReturnValue = ImGui::BeginCombo("Sprite##Override", "", ImGuiComboFlags_CustomPreview)))
{
// Reversed order to match the rendering layer order
for (int i = theSpriteMgr->sprites().size() - 1; i >= 0; i--)
{
Sprite *sprite = theSpriteMgr->sprites()[i];
ImGui::PushID(sprite);
const bool isSelected = (sprite == animSprite);
if (ImGui::Selectable("", isSelected))
animSprite = sprite;
if (isSelected)
ImGui::SetItemDefaultFocus();
ImGui::SameLine();
nc::Colorf entryColor = sprite->entryColor();
if (sprite->parentGroup() != &theSpriteMgr->root())
entryColor = sprite->parentGroup()->entryColor();
const ImVec4 color(entryColor);
ImGui::ColorButton(sprite->name.data(), color, ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop, colorButtonComboSize);
ImGui::SameLine();
ImGui::Text("#%d: \"%s\"", sprite->spriteId(), sprite->name.data());
ImGui::PopID();
}
ImGui::EndCombo();
}
if (ImGui::BeginComboPreview())
{
if (animSprite != nullptr)
{
nc::Colorf entryColor = animSprite->entryColor();
if (animSprite->parentGroup() != &theSpriteMgr->root())
entryColor = animSprite->parentGroup()->entryColor();
const ImVec4 entryVecColor(entryColor);
ImGui::ColorButton(animSprite->name.data(), entryVecColor, ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop, colorButtonComboSize);
ImGui::SameLine();
ImGui::Text("#%d: \"%s\"", animSprite->spriteId(), animSprite->name.data());
}
else
ImGui::TextUnformatted("None");
ImGui::EndComboPreview();
}
ImGui::SameLine();
if (ImGui::Button(Labels::Apply))
theAnimMgr->overrideSprite(animGroup, animSprite);
}
}
void UserInterface::createCurveAnimationGui(CurveAnimation &anim, const CurveAnimationGuiLimits &limits)
{
createDelayAnimationGui(anim);
int currentComboCurveType = static_cast<int>(anim.curve().type());
ImGui::Combo("Easing Curve", ¤tComboCurveType, easingCurveTypes, IM_ARRAYSIZE(easingCurveTypes));
anim.curve().setType(static_cast<EasingCurve::Type>(currentComboCurveType));
createLoopAnimationGui(anim.curve().loop());
ImGui::SliderFloat("Shift", &anim.curve().shift(), limits.minShift, limits.maxShift);
ImGui::SameLine();
ui::auxString.format("%s##Shift", Labels::Reset);
if (ImGui::Button(ui::auxString.data()))
anim.curve().shift() = 0.0f;
ImGui::SliderFloat("Scale", &anim.curve().scale(), limits.minScale, limits.maxScale);
ImGui::SameLine();
ui::auxString.format("%s##Scale", Labels::Reset);
if (ImGui::Button(ui::auxString.data()))
anim.curve().scale() = 1.0f;
ImGui::Separator();
ImGui::SliderFloat("Speed", &anim.speed(), 0.0f, 5.0f);
ImGui::SameLine();
ui::auxString.format("%s##Speed", Labels::Reset);
if (ImGui::Button(ui::auxString.data()))
anim.speed() = 1.0f;
ImGui::SliderFloat("Initial", &anim.curve().initialValue(), 0.0f, 1.0f);
ImGui::SameLine();
ImGui::Checkbox("##InitialEnabled", &anim.curve().hasInitialValue());
ImGui::SliderFloat("Start", &anim.curve().start(), 0.0f, 1.0f);
ImGui::SliderFloat("End", &anim.curve().end(), 0.0f, 1.0f);
ImGui::SliderFloat("Time", &anim.curve().time(), anim.curve().start(), anim.curve().end());
if (anim.curve().start() > anim.curve().end() ||
anim.curve().end() < anim.curve().start())
{
anim.curve().start() = anim.curve().end();
}
if (anim.curve().hasInitialValue() == false)
{
if (anim.curve().loop().direction() == Loop::Direction::FORWARD)
anim.curve().setInitialValue(anim.curve().start());
else
anim.curve().setInitialValue(anim.curve().end());
}
else
{
if (anim.curve().initialValue() < anim.curve().start())
anim.curve().initialValue() = anim.curve().start();
else if (anim.curve().initialValue() > anim.curve().end())
anim.curve().initialValue() = anim.curve().end();
}
if (anim.curve().time() < anim.curve().start())
anim.curve().time() = anim.curve().start();
else if (anim.curve().time() > anim.curve().end())
anim.curve().time() = anim.curve().end();
plotArray[plotValueIndex] = anim.curve().value();
ui::auxString.format("%f", plotArray[plotValueIndex]);
ImGui::PlotLines("Values", plotArray, PlotArraySize, 0, ui::auxString.data());
ImGui::SameLine();
ui::auxString.format("%s##Values", Labels::Reset);
if (ImGui::Button(ui::auxString.data()))
{
plotValueIndex = 0;
for (unsigned int i = 0; i < PlotArraySize; i++)
plotArray[i] = 0.0f;
}
if (anim.state() == IAnimation::State::PLAYING)
{
plotValueIndex++;
if (plotValueIndex >= PlotArraySize)
plotValueIndex = 0;
}
}
void UserInterface::createAnimationWindow()
{
ImGui::Begin(Labels::Animation);
if (theAnimMgr->anims().isEmpty() == false && selectedAnimation_ != nullptr && selectedAnimation_ != &theAnimMgr->animGroup())
{
IAnimation &anim = *selectedAnimation_;
if (anim.type() == IAnimation::Type::PROPERTY)
{
PropertyAnimation &propertyAnim = static_cast<PropertyAnimation &>(*selectedAnimation_);
createPropertyAnimationGui(propertyAnim);
}
else if (anim.type() == IAnimation::Type::GRID)
{
GridAnimation &gridAnim = static_cast<GridAnimation &>(*selectedAnimation_);
createGridAnimationGui(gridAnim);
}
else if (anim.type() == IAnimation::Type::SCRIPT)
{
ScriptAnimation &scriptAnim = static_cast<ScriptAnimation &>(*selectedAnimation_);
createScriptAnimationGui(scriptAnim);
}
else if (anim.type() == IAnimation::Type::SEQUENTIAL_GROUP)
{
SequentialAnimationGroup &sequentialAnim = static_cast<SequentialAnimationGroup &>(*selectedAnimation_);
ImGui::InputText("Name", sequentialAnim.name.data(), IAnimation::MaxNameLength,
ImGuiInputTextFlags_CallbackResize, ui::inputTextCallback, &sequentialAnim.name);
createDelayAnimationGui(sequentialAnim);
createLoopAnimationGui(sequentialAnim.loop());
createOverrideSpriteGui(sequentialAnim);
}
else if (anim.type() == IAnimation::Type::PARALLEL_GROUP)
{
ParallelAnimationGroup ¶llelAnim = static_cast<ParallelAnimationGroup &>(*selectedAnimation_);
ImGui::InputText("Name", parallelAnim.name.data(), IAnimation::MaxNameLength,
ImGuiInputTextFlags_CallbackResize, ui::inputTextCallback, ¶llelAnim.name);
createDelayAnimationGui(parallelAnim);
createLoopAnimationGui(parallelAnim.loop());
createOverrideSpriteGui(parallelAnim);
}
}
ImGui::End();
}
bool createCustomSpritesCombo(CurveAnimation &anim)
{
Sprite *animSprite = nullptr;
if (anim.type() == IAnimation::Type::PROPERTY)
animSprite = static_cast<PropertyAnimation &>(anim).sprite();
else if (anim.type() == IAnimation::Type::GRID)
animSprite = static_cast<GridAnimation &>(anim).sprite();
else if (anim.type() == IAnimation::Type::SCRIPT)
animSprite = static_cast<ScriptAnimation &>(anim).sprite();
const ImVec2 colorButtonComboSize(ImGui::GetTextLineHeight(), ImGui::GetTextLineHeight());
Sprite *selectedSprite = animSprite;
bool comboReturnValue = false;
if ((comboReturnValue = ImGui::BeginCombo("Sprite", "", ImGuiComboFlags_CustomPreview)))
{
// Reversed order to match the rendering layer order
for (int i = theSpriteMgr->sprites().size() - 1; i >= 0; i--)
{
Sprite *sprite = theSpriteMgr->sprites()[i];
ImGui::PushID(sprite);
const bool isSelected = (sprite == animSprite);
if (ImGui::Selectable("", isSelected))
selectedSprite = sprite;
if (isSelected)
ImGui::SetItemDefaultFocus();
ImGui::SameLine();
nc::Colorf entryColor = sprite->entryColor();
if (sprite->parentGroup() != &theSpriteMgr->root())
entryColor = sprite->parentGroup()->entryColor();
const ImVec4 color(entryColor);
ImGui::ColorButton(sprite->name.data(), color, ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop, colorButtonComboSize);
ImGui::SameLine();
ImGui::Text("#%d: \"%s\" (%d x %d)", sprite->spriteId(), sprite->name.data(), sprite->width(), sprite->height());
ImGui::PopID();
}
if (ImGui::Selectable("None", animSprite == nullptr))
selectedSprite = nullptr;
ImGui::EndCombo();
}
if (ImGui::BeginComboPreview())
{
if (animSprite != nullptr)
{
nc::Colorf entryColor = animSprite->entryColor();
if (animSprite->parentGroup() != &theSpriteMgr->root())
entryColor = animSprite->parentGroup()->entryColor();
const ImVec4 entryVecColor(entryColor);
ImGui::ColorButton(animSprite->name.data(), entryVecColor, ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop, colorButtonComboSize);
ImGui::SameLine();
ImGui::Text("#%d: \"%s\" (%d x %d)", animSprite->spriteId(), animSprite->name.data(), animSprite->width(), animSprite->height());
}
else
ImGui::TextUnformatted("None");
ImGui::EndComboPreview();
}
if (comboReturnValue)
{
if (anim.type() == IAnimation::Type::PROPERTY)
static_cast<PropertyAnimation &>(anim).setSprite(selectedSprite);
else if (anim.type() == IAnimation::Type::GRID)
static_cast<GridAnimation &>(anim).setSprite(selectedSprite);
else if (anim.type() == IAnimation::Type::SCRIPT)
static_cast<ScriptAnimation &>(anim).setSprite(selectedSprite);
}
return comboReturnValue;
}
void UserInterface::createPropertyAnimationGui(PropertyAnimation &anim)
{
static CurveAnimationGuiLimits limits;
ImGui::InputText("Name", anim.name.data(), IAnimation::MaxNameLength,
ImGuiInputTextFlags_CallbackResize, ui::inputTextCallback, &anim.name);
ImGui::Separator();
if (theSpriteMgr->sprites().isEmpty() == false)
{
const bool comboReturnValue = createCustomSpritesCombo(anim);
if (comboReturnValue && anim.sprite() != nullptr)
selectedSpriteEntry_ = anim.sprite();
Sprite &sprite = *anim.sprite();
static int currentComboProperty = -1;
currentComboProperty = static_cast<Properties::Types>(anim.propertyType());
bool setCurveShift = false;
if (ImGui::Combo("Property", ¤tComboProperty, Properties::Strings, IM_ARRAYSIZE(Properties::Strings)))
setCurveShift = true;
anim.setProperty(static_cast<Properties::Types>(currentComboProperty));
switch (currentComboProperty)
{
case Properties::Types::NONE:
break;
case Properties::Types::POSITION_X:
limits.minShift = -sprite.width() * 0.5f;
limits.maxShift = theCanvas->texWidth() + sprite.width() * 0.5f;
limits.minScale = -theCanvas->texWidth();
limits.maxScale = theCanvas->texWidth();
break;
case Properties::Types::POSITION_Y:
limits.minShift = -sprite.height() * 0.5f;
limits.maxShift = theCanvas->texHeight() + sprite.height() * 0.5f;
limits.minScale = -theCanvas->texHeight();
limits.maxScale = theCanvas->texHeight();
break;
case Properties::Types::ROTATION:
limits.minShift = 0.0f;
limits.maxShift = 360.0f;
limits.minScale = -360.0f;
limits.maxScale = 360.0f;
break;
case Properties::Types::SCALE_X:
limits.minShift = -8.0f;
limits.maxShift = 8.0f;
limits.minScale = -8.0f;
limits.maxScale = 8.0f;
break;
case Properties::Types::SCALE_Y:
limits.minShift = -8.0f;
limits.maxShift = 8.0f;
limits.minScale = -8.0f;
limits.maxScale = 8.0f;
break;
case Properties::Types::ANCHOR_X:
limits.minShift = -sprite.width() * 0.5f;
limits.maxShift = sprite.width() * 0.5f;
limits.minScale = -sprite.width();
limits.maxScale = sprite.width();
break;
case Properties::Types::ANCHOR_Y:
limits.minShift = -sprite.height() * 0.5f;
limits.maxShift = sprite.height() * 0.5f;
limits.minScale = -sprite.height();
limits.maxScale = sprite.height();
break;
case Properties::Types::OPACITY:
limits.minShift = 0.0f;
limits.maxShift = 1.0f;
limits.minScale = -1.0f;
limits.maxScale = 1.0f;
break;
case Properties::Types::COLOR_R:
limits.minShift = 0.0f;
limits.maxShift = 1.0f;
limits.minScale = -1.0f;
limits.maxScale = 1.0f;
break;
case Properties::Types::COLOR_G:
limits.minShift = 0.0f;
limits.maxShift = 1.0f;
limits.minScale = -1.0f;
limits.maxScale = 1.0f;
break;
case Properties::Types::COLOR_B:
limits.minShift = 0.0f;
limits.maxShift = 1.0f;
limits.minScale = -1.0f;
limits.maxScale = 1.0f;
break;
}
if (setCurveShift && anim.property())
anim.curve().setShift(*anim.property());
ImGui::SameLine();
bool isLocked = anim.isLocked();
ImGui::Checkbox(Labels::Locked, &isLocked);
anim.setLocked(isLocked);
}
else
ImGui::TextDisabled("There are no sprites to animate");
createCurveAnimationGui(anim, limits);
}
void UserInterface::createGridAnimationGui(GridAnimation &anim)
{
CurveAnimationGuiLimits limits;
limits.minScale = -10.0f;
limits.maxScale = 10.0f;
limits.minShift = -100.0f;
limits.maxShift = 100.0f;
ImGui::InputText("Name", anim.name.data(), IAnimation::MaxNameLength,
ImGuiInputTextFlags_CallbackResize, ui::inputTextCallback, &anim.name);
ImGui::Separator();
if (theSpriteMgr->sprites().isEmpty() == false)
{
const bool comboReturnValue = createCustomSpritesCombo(anim);
if (comboReturnValue && anim.sprite() != nullptr)
selectedSpriteEntry_ = anim.sprite();
int currentComboFunction = 0;
ui::comboString.clear();
ui::comboString.formatAppend("None");
ui::comboString.setLength(ui::comboString.length() + 1);
for (unsigned int i = 0; i < GridFunctionLibrary::gridFunctions().size(); i++)
{
const nctl::String &functionName = GridFunctionLibrary::gridFunctions()[i].name();
ui::comboString.formatAppend("%s", functionName.data());
ui::comboString.setLength(ui::comboString.length() + 1);
if (anim.function() && functionName == anim.function()->name())
currentComboFunction = i + 1;
}
ui::comboString.setLength(ui::comboString.length() + 1);
// Append a second '\0' to signal the end of the combo item list
ui::comboString[ui::comboString.length() - 1] = '\0';
ImGui::Combo("Function", ¤tComboFunction, ui::comboString.data());
const GridFunction *gridFunction = (currentComboFunction > 0) ? &GridFunctionLibrary::gridFunctions()[currentComboFunction - 1] : nullptr;
if (anim.function() != gridFunction)
anim.setFunction(gridFunction);
ImGui::SameLine();
bool isLocked = anim.isLocked();
ImGui::Checkbox(Labels::Locked, &isLocked);
anim.setLocked(isLocked);
if (anim.function() != nullptr)
{
for (unsigned int i = 0; i < anim.function()->numParameters(); i++)
{
const GridFunction::ParameterInfo ¶mInfo = anim.function()->parameterInfo(i);
ui::auxString.format("%s##GridFunction%u", paramInfo.name.data(), i);
float minValue = paramInfo.minValue.value0;
float maxValue = paramInfo.maxValue.value0;
if (anim.sprite())
{
if (paramInfo.minMultiply == GridFunction::ValueMultiply::SPRITE_WIDTH)
minValue *= anim.sprite()->width();
else if (paramInfo.minMultiply == GridFunction::ValueMultiply::SPRITE_HEIGHT)
minValue *= anim.sprite()->height();
if (paramInfo.maxMultiply == GridFunction::ValueMultiply::SPRITE_WIDTH)
maxValue *= anim.sprite()->width();
else if (paramInfo.maxMultiply == GridFunction::ValueMultiply::SPRITE_HEIGHT)
maxValue *= anim.sprite()->height();
}
switch (paramInfo.type)
{
case GridFunction::ParameterType::FLOAT:
ImGui::SliderFloat(ui::auxString.data(), &anim.parameters()[i].value0, minValue, maxValue);
break;
case GridFunction::ParameterType::VECTOR2F:
ImGui::SliderFloat2(ui::auxString.data(), &anim.parameters()[i].value0, minValue, maxValue);
break;
}
if (anim.sprite())
{
if (paramInfo.anchorType == GridFunction::AnchorType::X)
anim.sprite()->gridAnchorPoint.x = anim.parameters()[i].value0;
else if (paramInfo.anchorType == GridFunction::AnchorType::Y)
anim.sprite()->gridAnchorPoint.y = anim.parameters()[i].value0;
else if (paramInfo.anchorType == GridFunction::AnchorType::XY)
{
anim.sprite()->gridAnchorPoint.x = anim.parameters()[i].value0;
anim.sprite()->gridAnchorPoint.y = anim.parameters()[i].value1;
}
}
ImGui::SameLine();
ui::auxString.format("%s##GridFunction%u", Labels::Reset, i);
if (ImGui::Button(ui::auxString.data()))
{
anim.parameters()[i].value0 = paramInfo.initialValue.value0;
anim.parameters()[i].value1 = paramInfo.initialValue.value1;
}
}
}
}
else
ImGui::TextDisabled("There are no sprites to animate");
createCurveAnimationGui(anim, limits);
}
void UserInterface::createScriptAnimationGui(ScriptAnimation &anim)
{
CurveAnimationGuiLimits limits;
limits.minScale = -10.0f;
limits.maxScale = 10.0f;
limits.minShift = -100.0f;
limits.maxShift = 100.0f;
ImGui::InputText("Name", anim.name.data(), IAnimation::MaxNameLength,
ImGuiInputTextFlags_CallbackResize, ui::inputTextCallback, &anim.name);
ImGui::Separator();
if (theSpriteMgr->sprites().isEmpty() == false)
{
const bool comboReturnValue = createCustomSpritesCombo(anim);
if (comboReturnValue && anim.sprite() != nullptr)
selectedSpriteEntry_ = anim.sprite();
}
else
ImGui::TextDisabled("There are no sprites to animate");
int scriptIndex = theScriptingMgr->scriptIndex(anim.script());
if (theScriptingMgr->scripts().isEmpty() == false)
{
// Assign to current script if none was assigned before
if (scriptIndex < 0)
scriptIndex = selectedScriptIndex_;
ui::comboString.clear();
for (unsigned int i = 0; i < theScriptingMgr->scripts().size(); i++)
{
Script &script = *theScriptingMgr->scripts()[i];
ui::comboString.formatAppend("#%u: \"%s\" %s", i, nc::fs::baseName(script.name().data()).data(),
script.canRun() ? Labels::CheckIcon : Labels::TimesIcon);
ui::comboString.setLength(ui::comboString.length() + 1);
}
ui::comboString.setLength(ui::comboString.length() + 1);
// Append a second '\0' to signal the end of the combo item list
ui::comboString[ui::comboString.length() - 1] = '\0';
// Also assign if no script was assigned before
if (ImGui::Combo("Script", &scriptIndex, ui::comboString.data()) || anim.script() == nullptr)
{
anim.setScript(theScriptingMgr->scripts()[scriptIndex].get());
selectedScriptIndex_ = scriptIndex;
}
ImGui::SameLine();
bool isLocked = anim.isLocked();
ImGui::Checkbox(Labels::Locked, &isLocked);
anim.setLocked(isLocked);
}
else
ImGui::TextDisabled("There are no scripts to use for animation");
createCurveAnimationGui(anim, limits);
}
void UserInterface::createFileDialog()
{
static nctl::String selection = nctl::String(nc::fs::MaxPathLength);
if (FileDialog::create(FileDialog::config, selection))
{
switch (FileDialog::config.action)
{
case FileDialog::Action::OPEN_PROJECT:
if (openProject(selection.data()))
numFrames = 0; // force focus on the canvas
break;
case FileDialog::Action::SAVE_PROJECT:
if (nc::fs::hasExtension(selection.data(), "lua") == false)
selection = selection + ".lua";
if (nc::fs::isFile(selection.data()) && FileDialog::config.allowOverwrite == false)
{
ui::auxString.format("Cannot overwrite existing file \"%s\"\n", selection.data());
pushStatusErrorMessage(ui::auxString.data());
}
else
{
#ifdef __EMSCRIPTEN__
theSaver->save(nc::fs::baseName(selection.data()).data(), saverData_);
ui::auxString.format("Saved project file \"%s\"\n", nc::fs::baseName(selection.data()).data());
#else
theSaver->save(selection.data(), saverData_);
ui::auxString.format("Saved project file \"%s\"\n", selection.data());
#endif
pushStatusInfoMessage(ui::auxString.data());
}
break;
case FileDialog::Action::LOAD_TEXTURE:
loadTexture(selection.data());
break;
case FileDialog::Action::RELOAD_TEXTURE:
reloadTexture(selection.data());
break;
case FileDialog::Action::LOAD_SCRIPT:
loadScript(selection.data());
break;
case FileDialog::Action::RENDER_DIR:
renderGuiWindow_.directory = selection;
break;
}
}
}
void UserInterface::SpriteProperties::save(Sprite &sprite)
{
if (saved_)
return;
ASSERT(saved_ == false);
parent_ = sprite.parent();
position_.set(sprite.x, sprite.y);
rotation_ = sprite.rotation;
scaleFactor_ = sprite.scaleFactor;
anchorPoint_ = sprite.anchorPoint;
color_ = sprite.color;
const nc::Vector2f absPosition = sprite.absPosition();
sprite.setParent(nullptr);
sprite.setAbsPosition(absPosition);
sprite.rotation = 0.0f;
sprite.scaleFactor.set(1.0f, 1.0f);
sprite.anchorPoint.set(0.0f, 0.0f);
sprite.color = nc::Colorf::White;
saved_ = true;
}
void UserInterface::SpriteProperties::restore(Sprite &sprite)
{
if (saved_ == false)
return;
ASSERT(saved_ == true);
sprite.setParent(parent_);
sprite.x = position_.x;
sprite.y = position_.y;
sprite.rotation = rotation_;
sprite.scaleFactor = scaleFactor_;
sprite.anchorPoint = anchorPoint_;
sprite.color = color_;
saved_ = false;
}
void UserInterface::createCanvasWindow()
{
const float canvasZoom = canvasGuiSection_.zoomAmount();
hoveringOnCanvasWindow = false;
ImGui::SetNextWindowSize(ImVec2(theCanvas->texWidth() * canvasZoom, theCanvas->texHeight() * canvasZoom), ImGuiCond_Once);
ImGui::Begin(Labels::Canvas, nullptr, ImGuiWindowFlags_HorizontalScrollbar);
if (ImGui::IsWindowHovered())
hoveringOnCanvasWindow = true;
canvasGuiSection_.create(*theCanvas);
const ImVec2 cursorScreenPos = ImGui::GetCursorScreenPos();
ImGui::Image(theCanvas->imguiTexId(), ImVec2(theCanvas->texWidth() * canvasZoom, theCanvas->texHeight() * canvasZoom), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f));
ImDrawList *drawList = ImGui::GetWindowDrawList();
const float lineThickness = (canvasZoom < 1.0f) ? 1.0f : canvasZoom;
if (canvasGuiSection_.showBorders())
{
const ImRect borderRect(cursorScreenPos.x, cursorScreenPos.y, cursorScreenPos.x + theCanvas->texWidth() * canvasZoom, cursorScreenPos.y + theCanvas->texHeight() * canvasZoom);
drawList->AddRect(borderRect.Min, borderRect.Max, ImColor(1.0f, 0.0f, 1.0f, 1.0f), 0.0f, ImDrawFlags_RoundCornersAll, lineThickness);
}
hoveringOnCanvas = false;
if (ImGui::IsItemHovered() && theSpriteMgr->sprites().isEmpty() == false && selectedSpriteEntry_->isSprite())
{
// Disable keyboard navigation for an easier sprite move with arrow keys
ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NavEnableKeyboard);
enableKeyboardNav = false;
hoveringOnCanvas = true;
const ImVec2 mousePos = ImGui::GetMousePos();
const ImVec2 relativePos(mousePos.x - cursorScreenPos.x, mousePos.y - cursorScreenPos.y);
Sprite &sprite = *selectedSpriteEntry_->toSprite();
const nc::Vector2f newSpriteAbsPos(roundf(relativePos.x / canvasZoom), roundf(relativePos.y / canvasZoom));
const nc::Vector2f spriteRelativePos(newSpriteAbsPos - sprite.absPosition());
static bool shiftAndClick = false;
static bool ctrlAndClick = false;
if (ImGui::GetIO().KeyShift || ImGui::GetIO().KeyCtrl)
{
if (ImGui::IsMouseDown(ImGuiMouseButton_Left))
{
shiftAndClick = ImGui::GetIO().KeyShift;
ctrlAndClick = ImGui::GetIO().KeyCtrl;
// One frame lasting message
statusMessage_.format("Coordinates: %d, %d", static_cast<int>(spriteRelativePos.x), static_cast<int>(spriteRelativePos.y));
ImU32 color = IM_COL32(0, 0, 0, 255); // opaque black
if (ImGui::GetIO().KeyShift)
color |= 0x000000FF; // red
if (ImGui::GetIO().KeyCtrl)
color |= 0x00FF0000; // blue
const ImRect spriteRect(cursorScreenPos.x + (sprite.absPosition().x - sprite.absWidth() / 2) * canvasZoom,
cursorScreenPos.y + (sprite.absPosition().y - sprite.absHeight() / 2) * canvasZoom,
cursorScreenPos.x + (sprite.absPosition().x + sprite.absWidth() / 2) * canvasZoom,
cursorScreenPos.y + (sprite.absPosition().y + sprite.absHeight() / 2) * canvasZoom);
drawList->AddRect(spriteRect.Min, spriteRect.Max, color, 0.0f, ImDrawFlags_RoundCornersAll, lineThickness);
if (spriteRect.Contains(mousePos))
{
drawList->AddLine(ImVec2(spriteRect.Min.x, mousePos.y), ImVec2(spriteRect.Max.x, mousePos.y), color, lineThickness);
drawList->AddLine(ImVec2(mousePos.x, spriteRect.Min.y), ImVec2(mousePos.x, spriteRect.Max.y), color, lineThickness);
}
spriteProps_.save(sprite);
const float rectHalfSize = 2.0f * canvasZoom;
drawList->AddRectFilled(ImVec2(mousePos.x - rectHalfSize, mousePos.y - rectHalfSize), ImVec2(mousePos.x + rectHalfSize, mousePos.y + rectHalfSize), color);
if (ImGui::GetIO().KeyCtrl &&
(spriteRelativePos.x != sprite.gridAnchorPoint.x || spriteRelativePos.y != sprite.gridAnchorPoint.y))
{
// Update grid anchor point while pressing Ctrl, clicking and moving the mouse
sprite.gridAnchorPoint = spriteRelativePos;
theAnimMgr->assignGridAnchorToParameters(&sprite);
}
}
if (ImGui::GetIO().KeyShift && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{
spriteProps_.restore(sprite);
// Update sprite anchor point while pressing Shift and releasing the mouse button
sprite.anchorPoint = spriteRelativePos;
sprite.setAbsPosition(newSpriteAbsPos);
}
}
else
{
if (shiftAndClick || ctrlAndClick)
{
spriteProps_.restore(sprite);
if (shiftAndClick)
{
// Update sprite anchor point while clicking the mouse button and releasing the Shift key
sprite.anchorPoint = spriteRelativePos;
sprite.setAbsPosition(newSpriteAbsPos);
}
}
else if (ImGui::GetIO().KeyAlt && (ImGui::IsMouseDragging(ImGuiMouseButton_Left, 1.0f) || ImGui::IsMouseReleased(ImGuiMouseButton_Left)))
{
// Update sprite position while pressing Alt, clicking and moving the mouse (with pixel snapping)
if (sprite.absPosition().x != newSpriteAbsPos.x || sprite.absPosition().y != newSpriteAbsPos.y)
sprite.setAbsPosition(newSpriteAbsPos);
}
shiftAndClick = false;
ctrlAndClick = false;
}
}
mouseWheelCanvasZoom();
ImGui::End();
}
void UserInterface::createTexRectWindow()
{
const float canvasZoom = canvasGuiSection_.zoomAmount();
static MouseStatus mouseStatus_ = MouseStatus::IDLE;
static ImVec2 startPos(0.0f, 0.0f);
static ImVec2 endPos(0.0f, 0.0f);
static bool moveRect = false;
static bool resizeRect = false;
static ImVec2 resizeDir(0.0f, 0.0f);
Sprite &sprite = *selectedSpriteEntry_->toSprite();
const ImVec2 size = selectedSpriteEntry_->isSprite()
? ImVec2(sprite.texture().width() * canvasZoom, sprite.texture().height() * canvasZoom)
: ImVec2(theCanvas->texWidth() * canvasZoom, theCanvas->texHeight() * canvasZoom);
ImGui::SetNextWindowSize(size, ImGuiCond_Once);
ImGui::Begin(Labels::TexRect, nullptr, ImGuiWindowFlags_HorizontalScrollbar);
ui::auxString.format("Zoom: %.2f", canvasGuiSection_.zoomAmount());
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
if (ImGui::Button(Labels::PlusIcon))
canvasGuiSection_.increaseZoom();
ImGui::SameLine();
if (ImGui::Button(Labels::MinusIcon))
canvasGuiSection_.decreaseZoom();
ImGui::PopStyleVar();
ImGui::SameLine();
if (ImGui::Button(ui::auxString.data()))
canvasGuiSection_.resetZoom();
ImGui::Separator();
if (selectedSpriteEntry_->isSprite())
{
const ImVec2 cursorScreenPos = ImGui::GetCursorScreenPos();
nc::Recti texRect = sprite.texRect();
ImGui::Image(sprite.imguiTexId(), size);
mouseWheelCanvasZoom();
if (ImGui::IsItemHovered())
{
// Disable keyboard navigation
ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NavEnableKeyboard);
enableKeyboardNav = false;
const ImVec2 mousePos = ImGui::GetMousePos();
ImVec2 relPos(mousePos.x - cursorScreenPos.x, mousePos.y - cursorScreenPos.y);
relPos.x = roundf(relPos.x / canvasZoom);
relPos.y = roundf(relPos.y / canvasZoom);
// One frame lasting message
statusMessage_.format("Coordinates: %d, %d", static_cast<int>(relPos.x), static_cast<int>(relPos.y));
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
{
mouseStatus_ = MouseStatus::CLICKED;
startPos = ImGui::GetMousePos();
// Only moving the rectangle if the user starts dragging from inside it
const bool insideTexRect = (relPos.x >= texRect.x) && (relPos.x <= (texRect.x + texRect.w)) &&
(relPos.y >= texRect.y) && (relPos.y <= (texRect.y + texRect.h));
moveRect = (resizeRect == false && ImGui::GetIO().KeyAlt && insideTexRect);
// Pressing Alt and dragging from outside the rectangle will do nothing
if (moveRect == false && ImGui::GetIO().KeyAlt)
mouseStatus_ = MouseStatus::IDLE;
resizeRect = (moveRect == false && ImGui::GetIO().KeyShift && insideTexRect);
// Determining if the user has clicked a corner or a side
const float threshold = 0.2f;
resizeDir.x = 0;
if ((relPos.x - texRect.x) <= texRect.w * threshold)
resizeDir.x = -1;
else if ((relPos.x - texRect.x) >= texRect.w * (1.0f - threshold))
resizeDir.x = 1;
resizeDir.y = 0;
if ((relPos.y - texRect.y) <= texRect.h * threshold)
resizeDir.y = -1;
else if ((relPos.y - texRect.y) >= texRect.h * (1.0f - threshold))
resizeDir.y = 1;
if (resizeDir.x == 0 && resizeDir.y == 0)
resizeRect = false;
// Pressing Shift and dragging from outside the rectangle will do nothing
if (resizeRect == false && ImGui::GetIO().KeyShift)
mouseStatus_ = MouseStatus::IDLE;
}
}
if (ImGui::IsWindowHovered() && mouseStatus_ != MouseStatus::IDLE && mouseStatus_ != MouseStatus::RELEASED)
{
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left))
{
mouseStatus_ = MouseStatus::DRAGGING;
endPos = ImGui::GetMousePos();
// If the user releases the Alt key while dragging
if (moveRect && ImGui::GetIO().KeyAlt == false)
mouseStatus_ = MouseStatus::RELEASED;
// If the user releases the Shift key while dragging
if (resizeRect && ImGui::GetIO().KeyShift == false)
mouseStatus_ = MouseStatus::RELEASED;
}
else if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{
mouseStatus_ = MouseStatus::RELEASED;
endPos = ImGui::GetMousePos();
}
}
else if (mouseStatus_ == MouseStatus::CLICKED || mouseStatus_ == MouseStatus::DRAGGING)
mouseStatus_ = MouseStatus::RELEASED;
if (moveRect == false && resizeRect == false)
{
if (mouseStatus_ == MouseStatus::CLICKED)
{
// Clipping to image
if (startPos.x > cursorScreenPos.x + size.x)
startPos.x = cursorScreenPos.x + size.x;
if (startPos.y > cursorScreenPos.y + size.y)
startPos.y = cursorScreenPos.y + size.y;
// Zoomed pixel snapping
if (canvasZoom > 1.0f)
{
startPos.x = roundf((startPos.x - cursorScreenPos.x) / canvasZoom) * canvasZoom + cursorScreenPos.x;
startPos.y = roundf((startPos.y - cursorScreenPos.y) / canvasZoom) * canvasZoom + cursorScreenPos.y;
}
}
else if (mouseStatus_ == MouseStatus::DRAGGING || mouseStatus_ == MouseStatus::RELEASED)
{
// Clipping to image
if (endPos.x < cursorScreenPos.x)
endPos.x = cursorScreenPos.x;
if (endPos.y < cursorScreenPos.y)
endPos.y = cursorScreenPos.y;
if (endPos.x > cursorScreenPos.x + size.x)
endPos.x = cursorScreenPos.x + size.x;
if (endPos.y > cursorScreenPos.y + size.y)
endPos.y = cursorScreenPos.y + size.y;
// Zoomed pixel snapping
if (canvasZoom > 1.0f)
{
endPos.x = roundf((endPos.x - cursorScreenPos.x) / canvasZoom) * canvasZoom + cursorScreenPos.x;
endPos.y = roundf((endPos.y - cursorScreenPos.y) / canvasZoom) * canvasZoom + cursorScreenPos.y;
}
}
}
else
{
if (mouseStatus_ == MouseStatus::DRAGGING || mouseStatus_ == MouseStatus::RELEASED)
{
const ImVec2 diff(roundf((endPos.x - startPos.x) / canvasZoom), roundf((endPos.y - startPos.y) / canvasZoom));
if (moveRect)
{
texRect.x += roundf((endPos.x - startPos.x) / canvasZoom); // rewrite
texRect.y += roundf((endPos.y - startPos.y) / canvasZoom);
}
else if (resizeRect)
{
if (resizeDir.x > 0.0f)
texRect.w += diff.x;
else if (resizeDir.x < 0.0f)
{
texRect.x += diff.x;
texRect.w -= diff.x;
}
if (resizeDir.y > 0.0f)
texRect.h += diff.y;
else if (resizeDir.y < 0.0f)
{
texRect.y += diff.y;
texRect.h -= diff.y;
}
}
if (texRect.w <= 0)
texRect.w = 1;
if (texRect.h <= 0)
texRect.h = 1;
// Clipping to image
if (texRect.x < 0)
texRect.x = 0;
if (texRect.y < 0)
texRect.y = 0;
if (texRect.x > size.x - texRect.w)
texRect.x = size.x - texRect.w;
if (texRect.y > size.y - texRect.h)
texRect.y = size.y - texRect.h;
}
}
ImVec2 minRect(startPos);
ImVec2 maxRect(endPos);
if (mouseStatus_ == MouseStatus::IDLE || mouseStatus_ == MouseStatus::CLICKED || moveRect || resizeRect ||
(!(maxRect.x - minRect.x != 0.0f && maxRect.y - minRect.y != 0.0f) && mouseStatus_ != MouseStatus::DRAGGING))
{
// Setting the non covered rect from the sprite texrect
minRect.x = cursorScreenPos.x + (texRect.x * canvasZoom);
minRect.y = cursorScreenPos.y + (texRect.y * canvasZoom);
maxRect.x = minRect.x + (texRect.w * canvasZoom);
maxRect.y = minRect.y + (texRect.h * canvasZoom);
}
else
{
// Setting the non covered rect from the mouse dragged area
if (minRect.x > maxRect.x)
nctl::swap(minRect.x, maxRect.x);
if (minRect.y > maxRect.y)
nctl::swap(minRect.y, maxRect.y);
}
const ImU32 darkGray = IM_COL32(0, 0, 0, 85);
ImRect top(ImVec2(cursorScreenPos.x, cursorScreenPos.y), ImVec2(cursorScreenPos.x + size.x, minRect.y));
ImRect left(ImVec2(cursorScreenPos.x, minRect.y), ImVec2(minRect.x, cursorScreenPos.y + size.y));
ImRect right(ImVec2(maxRect.x, minRect.y), ImVec2(cursorScreenPos.x + size.x, cursorScreenPos.y + size.y));
ImRect bottom(ImVec2(minRect.x, maxRect.y), ImVec2(maxRect.x, cursorScreenPos.y + size.y));
ImDrawList *drawList = ImGui::GetWindowDrawList();
drawList->AddRectFilled(top.Min, top.Max, darkGray);
drawList->AddRectFilled(left.Min, left.Max, darkGray);
drawList->AddRectFilled(right.Min, right.Max, darkGray);
drawList->AddRectFilled(bottom.Min, bottom.Max, darkGray);
if (mouseStatus_ == MouseStatus::RELEASED)
{
texRect.x = (minRect.x - cursorScreenPos.x) / canvasZoom;
texRect.y = (minRect.y - cursorScreenPos.y) / canvasZoom;
texRect.w = (maxRect.x - minRect.x) / canvasZoom;
texRect.h = (maxRect.y - minRect.y) / canvasZoom;
ASSERT(texRect.x >= 0);
ASSERT(texRect.y >= 0);
if (texRect.w > 0 && texRect.h > 0)
sprite.setTexRect(texRect);
moveRect = false;
resizeRect = false;
// Back to idle mouse status after assigning the new texrect
mouseStatus_ = MouseStatus::IDLE;
}
}
ImGui::End();
}
void UserInterface::createTipsWindow()
{
if (showTipsWindow == false)
return;
const ImVec2 windowPos = ImVec2(ImGui::GetWindowViewport()->Size.x * 0.5f, ImGui::GetWindowViewport()->Size.y * 0.5f);
ImGui::SetNextWindowPos(windowPos, ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f));
ImGui::Begin("Tips", &showTipsWindow, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking);
ImGui::Text("%s Did you know...", Labels::LightbulbIcon);
ImGui::NewLine();
const float startY = ImGui::GetCursorPosY();
ImGui::TextWrapped("%s", Tips::Strings[currentTipIndex].data());
const float endY = ImGui::GetCursorPosY();
const unsigned int numLines = (endY - startY) / ImGui::GetTextLineHeight();
// Check if `MaxNumberLines` has not been updated to the longest tip string
if (ImGui::IsWindowAppearing() == false)
ASSERT(numLines <= Tips::MaxNumberLines);
if (numLines < Tips::MaxNumberLines)
{
static char emptyLines[Tips::MaxNumberLines + 1] = "\0";
for (unsigned int i = 0; i < Tips::MaxNumberLines - numLines; i++)
emptyLines[i] = '\n';
emptyLines[Tips::MaxNumberLines - numLines] = '\0';
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
ImGui::TextUnformatted(emptyLines);
ImGui::PopStyleVar();
}
ImGui::NewLine();
ImGui::Checkbox("Show Tips On Start", &theCfg.showTipsOnStart);
ImGui::SameLine();
ui::auxString.format("%s Prev", Labels::PreviousIcon);
const bool enablePrevButton = (currentTipIndex >= 1);
ImGui::BeginDisabled(enablePrevButton == false);
if (ImGui::Button(ui::auxString.data()))
currentTipIndex--;
ImGui::EndDisabled();
ImGui::SameLine();
ImGui::Text("%u / %u", currentTipIndex + 1, Tips::Count);
ImGui::SameLine();
ui::auxString.format("Next %s", Labels::NextIcon);
const bool enableNextButton = (currentTipIndex <= Tips::Count - 2);
ImGui::BeginDisabled(enableNextButton == false);
if (ImGui::Button(ui::auxString.data()))
currentTipIndex++;
ImGui::EndDisabled();
ImGui::SameLine();
if (ImGui::Button(Labels::Close))
showTipsWindow = false;
// Auto-save on window close
if (showTipsWindow == false)
theSaver->saveCfg(theCfg);
if (ImGui::IsWindowHovered())
{
// Disable keyboard navigation
ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NavEnableKeyboard);
enableKeyboardNav = false;
if (enablePrevButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)))
currentTipIndex--;
if (enableNextButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_RightArrow)))
currentTipIndex++;
}
ImGui::End();
}
void UserInterface::createAboutWindow()
{
const ImVec2 windowPos = ImVec2(ImGui::GetWindowViewport()->Size.x * 0.5f, ImGui::GetWindowViewport()->Size.y * 0.5f);
ImGui::SetNextWindowPos(windowPos, ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f));
ImGui::Begin("About", &showAboutWindow, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking);
ImVec2 cursorPos = ImGui::GetCursorPos();
const ImVec2 spookySize(spookyLogo_->width() * 2.0f, spookyLogo_->height() * 2.0f);
cursorPos.x = (ImGui::GetWindowSize().x - spookySize.x) * 0.5f;
ImGui::SetCursorPos(cursorPos);
ImGui::Image(spookyLogo_->imguiTexId(), spookySize);
ImGui::Spacing();
#ifdef WITH_GIT_VERSION
ImGui::Text("SpookyGhost %s (%s)", VersionStrings::Version, VersionStrings::GitBranch);
#endif
ImGui::Text("SpookyGhost compiled on %s at %s", __DATE__, __TIME__);
ImGui::Spacing();
ImGui::Text("https://encelo.itch.io/spookyghost");
for (unsigned int i = 0; i < 4; i++)
ImGui::Spacing();
ImGui::Separator();
for (unsigned int i = 0; i < 4; i++)
ImGui::Spacing();
cursorPos = ImGui::GetCursorPos();
const ImVec2 ncineSize(ncineLogo_->width() * 2.0f, ncineLogo_->height() * 2.0f);
cursorPos.x = (ImGui::GetWindowSize().x - ncineSize.x) * 0.5f;
ImGui::SetCursorPos(cursorPos);
ImGui::Image(ncineLogo_->imguiTexId(), spookySize);
ImGui::Spacing();
ImGui::Text("Based on nCine %s (%s)", nc::VersionStrings::Version, nc::VersionStrings::GitBranch);
ImGui::Text("nCine compiled on %s at %s", nc::VersionStrings::CompilationDate, nc::VersionStrings::CompilationTime);
ImGui::Spacing();
ImGui::Text("https://ncine.github.io/");
ImGui::NewLine();
if (ImGui::Button(Labels::Close))
showAboutWindow = false;
ImGui::End();
}
void UserInterface::createQuitPopup()
{
const ImVec2 windowPos = ImVec2(ImGui::GetWindowViewport()->Size.x * 0.5f, ImGui::GetWindowViewport()->Size.y * 0.5f);
ImGui::SetNextWindowPos(windowPos, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
ImGui::OpenPopup(Labels::Quit);
ImGui::BeginPopupModal(Labels::Quit, nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::TextUnformatted("Quit the program?");
if (ImGui::Button(Labels::Ok))
{
nc::theApplication().quit();
showQuitPopup = false;
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button(Labels::Cancel))
{
showQuitPopup = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
void UserInterface::mouseWheelCanvasZoom()
{
if (ImGui::IsWindowHovered() && ImGui::GetIO().KeyCtrl && ImGui::GetIO().MouseWheel != 0.0f)
{
const float wheel = ImGui::GetIO().MouseWheel;
if (wheel > 0.0f)
canvasGuiSection_.increaseZoom();
else if (wheel < 0.0f)
canvasGuiSection_.decreaseZoom();
}
}
void UserInterface::visitSprite(Sprite &sprite)
{
sprite.visited = true;
for (unsigned int i = 0; i < sprite.children().size(); i++)
visitSprite(*sprite.children()[i]);
}
void recursiveUpdateParentOnSpriteRemoval(SpriteGroup &group, Sprite *sprite)
{
for (unsigned int i = 0; i < group.children().size(); i++)
{
Sprite *childSprite = group.children()[i]->toSprite();
SpriteGroup *childGroup = group.children()[i]->toGroup();
if (childSprite && childSprite->parent() == sprite)
childSprite->setParent(nullptr);
else if (childGroup)
recursiveUpdateParentOnSpriteRemoval(*childGroup, sprite);
}
}
void UserInterface::updateParentOnSpriteRemoval(Sprite *sprite)
{
recursiveUpdateParentOnSpriteRemoval(theSpriteMgr->root(), sprite);
}
void UserInterface::updateSelectedAnimOnSpriteRemoval(Sprite *sprite)
{
if (selectedAnimation_)
{
if (selectedAnimation_->type() == IAnimation::Type::PROPERTY)
{
PropertyAnimation &propertyAnim = static_cast<PropertyAnimation &>(*selectedAnimation_);
if (propertyAnim.sprite() == sprite)
selectedAnimation_ = nullptr;
}
else if (selectedAnimation_->type() == IAnimation::Type::GRID)
{
GridAnimation &gridAnim = static_cast<GridAnimation &>(*selectedAnimation_);
if (gridAnim.sprite() == sprite)
selectedAnimation_ = nullptr;
}
else if (selectedAnimation_->type() == IAnimation::Type::SCRIPT)
{
ScriptAnimation &scriptAnim = static_cast<ScriptAnimation &>(*selectedAnimation_);
if (scriptAnim.sprite() == sprite)
selectedAnimation_ = nullptr;
}
}
}
| 34.117024 | 177 | 0.70326 | SpookyGhost2D |
e1aa6d749f22decfc74219bc6a87fc4db549ce50 | 4,922 | cc | C++ | examples/generic_event_queue/main.cc | hendrik-skubch/magic_func | 591dbde620f6b490d10402590851145ab2f6b18b | [
"BSD-3-Clause"
] | 2 | 2017-05-28T14:04:37.000Z | 2021-04-08T17:22:45.000Z | examples/generic_event_queue/main.cc | hendrik-skubch/magic_func | 591dbde620f6b490d10402590851145ab2f6b18b | [
"BSD-3-Clause"
] | null | null | null | examples/generic_event_queue/main.cc | hendrik-skubch/magic_func | 591dbde620f6b490d10402590851145ab2f6b18b | [
"BSD-3-Clause"
] | 1 | 2021-01-07T02:16:04.000Z | 2021-01-07T02:16:04.000Z | #include <cassert>
#include <cstring>
#include <iostream>
#include <string>
#include "generic_event_queue.h"
// Class defining event functions.
//
// Functions here do not need to be implemented, extended or anything else.
// Rather, they are simply a function name to refer to with its type signature.
// The fact these are part of a class is purely for organizative purposes.
class FooEvents {
public:
static void OnFoo(const std::string& str) {}
static void OnBar(int x, int y) {}
static void LvalueReferenceExample(int& value) {}
// C++14 support is required for non-copyable and rvalue reference arguments.
static void NonCopyableExample(std::unique_ptr<int> x) {}
static void RvalueReferenceExample(std::unique_ptr<int>&& x) {}
};
int main() {
GenericEventQueue event_queue;
// Add an event listener for OnFoo events.
event_queue.AddEventListener(
FooEvents::OnFoo,
[](const std::string& str) {
std::cout << "OnFoo called: " << str << std::endl;
});
// Add an event listener for OnBar events.
event_queue.AddEventListener(
FooEvents::OnBar,
[](int x, int y) {
std::cout << "OnBar called: " << x << ", " << y << std::endl;
});
// Add an event listener that receives an lvalue reference.
event_queue.AddEventListener(
FooEvents::LvalueReferenceExample,
[](int& value) {
value = 7;
std::cout << "Setting reference value to " << value << std::endl;
});
// This does nothing because there are no enqueued events.
event_queue.Dispatch();
// So, let's enqueue some.
event_queue.Enqueue(FooEvents::OnFoo, "this goes to the event listener");
event_queue.Enqueue(FooEvents::OnBar, 2, 3);
// With C++11 features we can also pass lvalue references as events.
// For that we must make sure to use std::ref() or the reference will decay.
int value = 5;
event_queue.Enqueue(FooEvents::LvalueReferenceExample, std::ref(value));
assert(value == 5);
// Now this synchronously calls any listeners with the provided arguments.
event_queue.Dispatch();
// The value we passed should have been updated by the dispatch.
std::cout << "Value is now " << value << " after dispatch." << std::endl;
assert(value == 7);
#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900)
// There are a few more things we can do if we have C++14 support.
// These are possible because of C++14 generalized lambda captures, which
// allow moving objects into lambdas instead of only copying them.
std::cout << "--------------------------" << std::endl;
std::cout << "| C++14 extras |" << std::endl;
std::cout << "--------------------------" << std::endl;
// Add an event listener that receives a non-copyable object.
event_queue.AddEventListener(
FooEvents::NonCopyableExample,
[](std::unique_ptr<int> x) {
std::cout << "NonCopyable called: " << *x << std::endl;
});
// Move a unique_ptr into the event queue.
// The event queue will detect that std::unique_ptr<int> is not copyable
// and will automatically move it when calling the first registered listener.
std::unique_ptr<int> p1(new int(16));
event_queue.Enqueue(FooEvents::NonCopyableExample, std::move(p1));
assert(p1 == nullptr);
// Add an event listener that receives an rvalue reference.
// The object is not moved unless this listener explicitly does so.
event_queue.AddEventListener(
FooEvents::RvalueReferenceExample,
[](std::unique_ptr<int>&& x) {
// This is where moving actually happens.
// If we don't move here the second listener will get a valid object.
assert(x != nullptr);
std::unique_ptr<int> value = std::move(x);
assert(value != nullptr);
assert(x == nullptr);
std::cout << "RvalueReferenceExample called: " << *value << std::endl;
});
// Add a second event listener that receives an rvalue reference.
// In this case, since the object was moved by the first listener we will
// receive an empty object.
event_queue.AddEventListener(
FooEvents::RvalueReferenceExample,
[](std::unique_ptr<int>&& x) {
assert(x == nullptr);
std::cout << "RvalueReferenceExample called: empty object" << std::endl;
});
// Move another unique_ptr into the event queue.
//
// The unique pointer will be moved only when a listener explicitly takes
// the rvalue reference into an object. In this example, this happens inside
// the body of the first listener, but if commented out the second listener
// will still receive a valid object.
std::unique_ptr<int> p2(new int(32));
event_queue.Enqueue(FooEvents::RvalueReferenceExample, std::move(p2));
assert(p2 == nullptr);
// Dispatch the enqueued events.
event_queue.Dispatch();
#endif // __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900)
return 0;
}
| 37.287879 | 80 | 0.665177 | hendrik-skubch |
e1b36cfabc2bfeb9b27670043d91b6e4160d03ab | 4,322 | cpp | C++ | src/plugins/poshuku/plugins/webkitview/interceptadaptor.cpp | Maledictus/leechcraft | 79ec64824de11780b8e8bdfd5d8a2f3514158b12 | [
"BSL-1.0"
] | 120 | 2015-01-22T14:10:39.000Z | 2021-11-25T12:57:16.000Z | src/plugins/poshuku/plugins/webkitview/interceptadaptor.cpp | Maledictus/leechcraft | 79ec64824de11780b8e8bdfd5d8a2f3514158b12 | [
"BSL-1.0"
] | 8 | 2015-02-07T19:38:19.000Z | 2017-11-30T20:18:28.000Z | src/plugins/poshuku/plugins/webkitview/interceptadaptor.cpp | Maledictus/leechcraft | 79ec64824de11780b8e8bdfd5d8a2f3514158b12 | [
"BSL-1.0"
] | 33 | 2015-02-07T16:59:55.000Z | 2021-10-12T00:36:40.000Z | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2014 Georg Rudoy
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
**********************************************************************/
#include "interceptadaptor.h"
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QWebFrame>
#include <util/sll/visitor.h>
#include <util/network/customnetworkreply.h>
#include "customwebview.h"
#include "customwebpage.h"
Q_DECLARE_METATYPE (QNetworkReply*)
namespace LC
{
namespace Poshuku
{
namespace WebKitView
{
void InterceptAdaptor::AddInterceptor (const IInterceptableRequests::Interceptor_t& interceptor)
{
Interceptors_ << interceptor;
}
namespace
{
IInterceptableRequests::ResourceType DeriveResourceType (const QNetworkRequest& req)
{
auto acceptList = req.rawHeader ("Accept").split (',');
for (auto& item : acceptList)
{
const int pos = item.indexOf (';');
if (pos > 0)
item = item.left (pos);
}
acceptList.removeAll ("*/*");
if (acceptList.isEmpty ())
return IInterceptableRequests::ResourceType::Unknown;
auto find = [&acceptList] (const auto& f)
{
return std::any_of (acceptList.begin (), acceptList.end (), f);
};
if (find ([] (const QByteArray& arr) { return arr.startsWith ("image/"); }))
return IInterceptableRequests::ResourceType::Image;
if (find ([] (const QByteArray& arr) { return arr == "text/html" || arr == "application/xhtml+xml" || arr == "application/xml"; }))
return IInterceptableRequests::ResourceType::SubFrame;
if (find ([] (const QByteArray& arr) { return arr == "text/css"; }))
return IInterceptableRequests::ResourceType::Stylesheet;
const auto& path = req.url ().path ();
if (path.endsWith ("png") || path.endsWith ("jpg") || path.endsWith ("gif"))
return IInterceptableRequests::ResourceType::Image;
if (path.endsWith ("js"))
return IInterceptableRequests::ResourceType::Script;
return IInterceptableRequests::ResourceType::Unknown;
}
}
void InterceptAdaptor::HandleNAM (const IHookProxy_ptr& hook,
QNetworkAccessManager*,
QNetworkAccessManager::Operation*,
QIODevice**)
{
auto req = hook->GetValue ("request").value<QNetworkRequest> ();
if (!req.originatingObject ())
return;
const auto& reqUrl = req.url ();
if (reqUrl.scheme () == "data")
return;
const auto frame = qobject_cast<QWebFrame*> (req.originatingObject ());
const auto page = frame ? frame->page () : nullptr;
if (!page)
return;
if (frame == page->mainFrame () &&
frame->requestedUrl () == reqUrl)
return;
if (auto cwp = qobject_cast<CustomWebPage*> (page);
cwp && reqUrl == cwp->GetLoadingURL ())
return;
const auto view = qobject_cast<CustomWebView*> (page->view ());
IInterceptableRequests::RequestInfo info
{
reqUrl,
page->mainFrame ()->url (),
IInterceptableRequests::NavigationType::Unknown,
DeriveResourceType (req),
view ? std::optional<IWebView*> { view } : std::optional<IWebView*> {}
};
bool beenRedirected = false;
for (const auto& interceptor : Interceptors_)
{
const auto shouldBlock = Util::Visit (interceptor (info),
[] (IInterceptableRequests::Allow) { return false; },
[&] (const IInterceptableRequests::Redirect& r)
{
req.setUrl (r.NewUrl_);
info.RequestUrl_ = r.NewUrl_;
beenRedirected = true;
return false;
},
[] (IInterceptableRequests::Block) { return true; });
if (shouldBlock)
{
Reject (hook, frame, reqUrl);
return;
}
}
if (beenRedirected)
hook->SetValue ("request", QVariant::fromValue (req));
}
void InterceptAdaptor::Reject (const IHookProxy_ptr& hook,
QWebFrame *frame, const QUrl& reqUrl)
{
hook->CancelDefault ();
qDebug () << "rejecting" << frame << reqUrl;
const auto result = new Util::CustomNetworkReply { reqUrl, frame };
result->SetContent (QObject::tr ("Blocked"));
result->setError (QNetworkReply::ContentAccessDenied,
QObject::tr ("Blocked: %1")
.arg (reqUrl.toString ()));
hook->SetReturnValue (QVariant::fromValue<QNetworkReply*> (result));
}
}
}
}
| 28.813333 | 134 | 0.652938 | Maledictus |
e1b696cc8c5a85ba236609c645838348d7a5943d | 390 | cpp | C++ | src/profiling/profiler.cpp | h4k1m0u/video | 4739f8b1b6c837c41fdb53fc7dea97a47b285d0b | [
"MIT"
] | 5 | 2021-11-11T23:59:38.000Z | 2022-03-24T02:10:40.000Z | src/profiling/profiler.cpp | h4k1m0u/video | 4739f8b1b6c837c41fdb53fc7dea97a47b285d0b | [
"MIT"
] | null | null | null | src/profiling/profiler.cpp | h4k1m0u/video | 4739f8b1b6c837c41fdb53fc7dea97a47b285d0b | [
"MIT"
] | 1 | 2022-01-15T13:31:10.000Z | 2022-01-15T13:31:10.000Z | #include <iostream>
#include "profiling/profiler.hpp"
void Profiler::start() {
time_start = steady_clock::now();
}
void Profiler::stop() {
time_stop = steady_clock::now();
interval = time_stop - time_start;
}
void Profiler::print(const std::string& label) {
// show duration time in seconds
std::cout << "Duration " << label << ": " << interval.count() << "s" << std::endl;
}
| 21.666667 | 84 | 0.648718 | h4k1m0u |
e1bc11165a4a6173f70fc64dc166493c596518f1 | 6,196 | cpp | C++ | tests/unit/encoding/nfd-constants.t.cpp | Pesa/ndn-cxx | 0249d71d97b2f1f5313f24cec7c84450a795f2ca | [
"OpenSSL"
] | 106 | 2015-01-06T10:08:29.000Z | 2022-02-27T13:40:16.000Z | tests/unit/encoding/nfd-constants.t.cpp | Pesa/ndn-cxx | 0249d71d97b2f1f5313f24cec7c84450a795f2ca | [
"OpenSSL"
] | 6 | 2015-10-15T23:21:06.000Z | 2016-12-20T19:03:10.000Z | tests/unit/encoding/nfd-constants.t.cpp | Pesa/ndn-cxx | 0249d71d97b2f1f5313f24cec7c84450a795f2ca | [
"OpenSSL"
] | 147 | 2015-01-15T15:07:29.000Z | 2022-02-03T13:08:43.000Z | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received copies of the GNU General Public License and GNU Lesser
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
* <http://www.gnu.org/licenses/>.
*
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
#include "ndn-cxx/encoding/nfd-constants.hpp"
#include "tests/boost-test.hpp"
#include <boost/lexical_cast.hpp>
#include <iomanip>
#include <sstream>
namespace ndn {
namespace nfd {
namespace tests {
BOOST_AUTO_TEST_SUITE(Encoding)
BOOST_AUTO_TEST_SUITE(TestNfdConstants)
BOOST_AUTO_TEST_CASE(PrintFaceScope)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_SCOPE_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_SCOPE_NON_LOCAL), "non-local");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_SCOPE_LOCAL), "local");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<FaceScope>(126)), "126");
}
BOOST_AUTO_TEST_CASE(PrintFacePersistency)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_PERSISTENCY_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_PERSISTENCY_ON_DEMAND), "on-demand");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_PERSISTENCY_PERSISTENT), "persistent");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_PERSISTENCY_PERMANENT), "permanent");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<FacePersistency>(110)), "110");
}
BOOST_AUTO_TEST_CASE(PrintLinkType)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(LINK_TYPE_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(LINK_TYPE_POINT_TO_POINT), "point-to-point");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(LINK_TYPE_MULTI_ACCESS), "multi-access");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(LINK_TYPE_AD_HOC), "adhoc");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<LinkType>(104)), "104");
}
BOOST_AUTO_TEST_CASE(PrintFaceEventKind)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_CREATED), "created");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_DESTROYED), "destroyed");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_UP), "up");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(FACE_EVENT_DOWN), "down");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<FaceEventKind>(175)), "175");
}
BOOST_AUTO_TEST_CASE(ParseRouteOrigin)
{
auto expectSuccess = [] (const std::string& input, RouteOrigin expected) {
BOOST_TEST_CONTEXT("input = " << std::quoted(input)) {
std::istringstream is(input);
RouteOrigin routeOrigin;
is >> routeOrigin;
BOOST_CHECK(!is.fail());
BOOST_CHECK_EQUAL(routeOrigin, expected);
}
};
auto expectFail = [] (const std::string& input) {
BOOST_TEST_CONTEXT("input = " << std::quoted(input)) {
std::istringstream is(input);
RouteOrigin routeOrigin;
is >> routeOrigin;
BOOST_CHECK(is.fail());
BOOST_CHECK_EQUAL(routeOrigin, ROUTE_ORIGIN_NONE);
}
};
expectSuccess("none", ROUTE_ORIGIN_NONE);
expectSuccess("App", ROUTE_ORIGIN_APP);
expectSuccess("AutoReg", ROUTE_ORIGIN_AUTOREG);
expectSuccess("Client", ROUTE_ORIGIN_CLIENT);
expectSuccess("AutoConf", ROUTE_ORIGIN_AUTOCONF);
expectSuccess("NLSR", ROUTE_ORIGIN_NLSR);
expectSuccess("PrefixAnn", ROUTE_ORIGIN_PREFIXANN);
expectSuccess("static", ROUTE_ORIGIN_STATIC);
expectSuccess("27", static_cast<RouteOrigin>(27));
expectSuccess(" app", ROUTE_ORIGIN_APP);
expectSuccess("app ", ROUTE_ORIGIN_APP);
expectSuccess(" app ", ROUTE_ORIGIN_APP);
expectFail("unrecognized");
expectFail("-1");
expectFail("0.1");
expectFail("65537");
expectFail("");
}
BOOST_AUTO_TEST_CASE(PrintRouteOrigin)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_APP), "app");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_AUTOREG), "autoreg");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_CLIENT), "client");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_AUTOCONF), "autoconf");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_NLSR), "nlsr");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_PREFIXANN), "prefixann");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_STATIC), "static");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<RouteOrigin>(27)), "27");
}
BOOST_AUTO_TEST_CASE(PrintRouteFlags)
{
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_FLAGS_NONE), "none");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_FLAG_CHILD_INHERIT), "child-inherit");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_FLAG_CAPTURE), "capture");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<RouteFlags>(
ROUTE_FLAG_CHILD_INHERIT | ROUTE_FLAG_CAPTURE)), "child-inherit|capture");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<RouteFlags>(
ROUTE_FLAG_CAPTURE | 0x9c)), "capture|0x9c");
}
BOOST_AUTO_TEST_SUITE_END() // TestNfdConstants
BOOST_AUTO_TEST_SUITE_END() // Encoding
} // namespace tests
} // namespace nfd
} // namespace ndn
| 41.864865 | 98 | 0.753712 | Pesa |
e1bd3d598a66ded57ed6d1203b1a74c22aed748c | 3,355 | cpp | C++ | Demo/DemoAppBase.cpp | loreStefani/SoftRP | 2676145f74c734b272268820b1e1c503aa8ff765 | [
"MIT"
] | null | null | null | Demo/DemoAppBase.cpp | loreStefani/SoftRP | 2676145f74c734b272268820b1e1c503aa8ff765 | [
"MIT"
] | null | null | null | Demo/DemoAppBase.cpp | loreStefani/SoftRP | 2676145f74c734b272268820b1e1c503aa8ff765 | [
"MIT"
] | null | null | null | #include "DemoAppBase.h"
using namespace SoftRPDemo;
DemoAppBase::DemoAppBase(HINSTANCE hInstance, unsigned int width, unsigned int height)
:SingleWindowApp(hInstance, width, height), m_viewPort{ getWidth(), getHeight() },
m_renderTarget{}, m_depthBuffer{ getWidth(), getHeight() },
m_inputVertexLayout{ SoftRP::InputVertexLayout::create(std::vector<size_t>{}) },
m_outputVertexLayout{ SoftRP::OutputVertexLayout::create(0) } {
m_lastTime = std::chrono::high_resolution_clock::now();
updateView();
}
void DemoAppBase::onUpdate(){
const auto now = std::chrono::high_resolution_clock::now();
auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastTime);
renderFrame(delta.count());
m_lastTime = now;
m_millis += delta;
m_frameCount++;
std::wstring delta_str = std::to_wstring(delta.count());
if (m_millis >= std::chrono::milliseconds{ 1000 }) {
m_fpsString = std::to_wstring(m_frameCount);
m_frameCount = 0;
m_millis = m_millis - std::chrono::milliseconds{ 1000 };
}
SetWindowText(getWindowHandle(),
(delta_str + std::wstring{ L" ms, " } + m_fpsString + std::wstring{ L" FPS" } + m_messageString).c_str());
}
void DemoAppBase::onResize(){
unsigned int width = getWidth();
unsigned int height = getHeight();
m_viewPort = SoftRP::ViewPort{ width, height };
m_depthBuffer.resize(width, height);
m_camera.makePerspective(static_cast<float>(width) / static_cast<float>(height));
m_renderTarget.setWindowHandle(getWindowHandle());
m_renderTarget.resize(getWidth(), getHeight());
}
bool DemoAppBase::onMouseDown(MouseButton mouseButton, MousePos mousePos){
if (mouseButton == MouseButton::MIDDLE)
return false;
SetCapture(getWindowHandle());
m_lastMousePos.mouseX = mousePos.mouseX;
m_lastMousePos.mouseY = mousePos.mouseY;
m_mouseCaptured = true;
m_leftButtonDown = mouseButton == MouseButton::LEFT;
return true;
}
bool DemoAppBase::onMouseUp(MouseButton mouseButton, MousePos mousePos) {
if (mouseButton == MouseButton::MIDDLE)
return false;
ReleaseCapture();
m_mouseCaptured = false;
return true;
}
bool DemoAppBase::onMouseMove(MousePos mousePos){
if (!m_mouseCaptured)
return false;
float deltaX = degsToRadians(static_cast<float>(mousePos.mouseX - m_lastMousePos.mouseX));
float deltaY = degsToRadians(static_cast<float>(mousePos.mouseY - m_lastMousePos.mouseY));
m_lastMousePos.mouseX = mousePos.mouseX;
m_lastMousePos.mouseY = mousePos.mouseY;
if (m_leftButtonDown) {
m_theta += deltaX* 0.25f;
m_phi += deltaY*0.25f;
} else {
m_radius += 0.05f * deltaX;
}
updateView();
return true;
}
void DemoAppBase::updateView() {
m_phi = max(m_phi, 0.5f);
m_phi = min(m_phi, PI - 0.5f);
m_radius = max(m_radius, m_minRadius);
m_radius = min(m_radius, m_maxRadius);
const auto cosTheta = std::cos(m_theta);
const auto sinTheta = std::sin(m_theta);
const auto cosPhi = std::cos(m_phi);
const auto sinPhi = std::sin(m_phi);
const float x = m_radius*cosTheta*sinPhi;
const float z = m_radius*sinTheta*sinPhi;
const float y = m_radius*cosPhi;
m_camera.lookAt(SoftRP::Math::Vector3{ x, y, z }, m_lookAt);
}
void DemoAppBase::setWindowText(const std::wstring& text) {
m_messageString = std::wstring{L", "} + text;
}
void DemoAppBase::setWindowText(std::wstring&& text) {
m_messageString = std::wstring{ L", " } + std::move(text);
} | 29.173913 | 112 | 0.727869 | loreStefani |
e1ce7d5113ba4116b0573a52c33229869230a772 | 200,633 | inl | C++ | 2d_samples/pmj02_329.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | 1 | 2021-12-10T23:35:04.000Z | 2021-12-10T23:35:04.000Z | 2d_samples/pmj02_329.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | null | null | null | 2d_samples/pmj02_329.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | null | null | null | {std::array<float,2>{0.201500699f, 0.181056455f},
std::array<float,2>{0.872883677f, 0.705885351f},
std::array<float,2>{0.284197956f, 0.935171962f},
std::array<float,2>{0.547898114f, 0.495615005f},
std::array<float,2>{0.400407821f, 0.358174562f},
std::array<float,2>{0.649318337f, 0.866324723f},
std::array<float,2>{0.00560980709f, 0.596858203f},
std::array<float,2>{0.889439344f, 0.0387387723f},
std::array<float,2>{0.330537468f, 0.099126406f},
std::array<float,2>{0.573348939f, 0.522119582f},
std::array<float,2>{0.143626437f, 0.772142947f},
std::array<float,2>{0.768525302f, 0.274484247f},
std::array<float,2>{0.0893684775f, 0.411701083f},
std::array<float,2>{0.94584918f, 0.994981527f},
std::array<float,2>{0.446665406f, 0.626096308f},
std::array<float,2>{0.707467854f, 0.20279555f},
std::array<float,2>{0.0437583923f, 0.0279188864f},
std::array<float,2>{0.916816831f, 0.58993423f},
std::array<float,2>{0.431781679f, 0.828147173f},
std::array<float,2>{0.670877755f, 0.339050889f},
std::array<float,2>{0.2760683f, 0.461302727f},
std::array<float,2>{0.50160259f, 0.877765596f},
std::array<float,2>{0.22060138f, 0.722325206f},
std::array<float,2>{0.821317017f, 0.14266853f},
std::array<float,2>{0.47886762f, 0.248147428f},
std::array<float,2>{0.726186931f, 0.658848345f},
std::array<float,2>{0.104067147f, 0.95175904f},
std::array<float,2>{0.974471152f, 0.402941525f},
std::array<float,2>{0.170283854f, 0.296425611f},
std::array<float,2>{0.794876039f, 0.810567319f},
std::array<float,2>{0.34768194f, 0.54422456f},
std::array<float,2>{0.618092954f, 0.0657792762f},
std::array<float,2>{0.126580283f, 0.0812992975f},
std::array<float,2>{0.75202632f, 0.552158058f},
std::array<float,2>{0.317470282f, 0.78237009f},
std::array<float,2>{0.586147785f, 0.30810979f},
std::array<float,2>{0.463687211f, 0.38671869f},
std::array<float,2>{0.695264816f, 0.968293011f},
std::array<float,2>{0.0678012371f, 0.680619299f},
std::array<float,2>{0.963144839f, 0.2310206f},
std::array<float,2>{0.310351551f, 0.126110181f},
std::array<float,2>{0.537242591f, 0.734971702f},
std::array<float,2>{0.216447905f, 0.891983032f},
std::array<float,2>{0.85347873f, 0.445936412f},
std::array<float,2>{0.0172206033f, 0.316495389f},
std::array<float,2>{0.905330539f, 0.817345321f},
std::array<float,2>{0.384307057f, 0.569150746f},
std::array<float,2>{0.631998241f, 0.00443565939f},
std::array<float,2>{0.123832889f, 0.213976026f},
std::array<float,2>{0.99022764f, 0.65500921f},
std::array<float,2>{0.488318324f, 0.976634443f},
std::array<float,2>{0.738869667f, 0.428365856f},
std::array<float,2>{0.371471733f, 0.264265209f},
std::array<float,2>{0.609101474f, 0.752981007f},
std::array<float,2>{0.182611138f, 0.509826481f},
std::array<float,2>{0.798242688f, 0.117958069f},
std::array<float,2>{0.40818885f, 0.0559902415f},
std::array<float,2>{0.678389072f, 0.617817104f},
std::array<float,2>{0.0473241173f, 0.84673214f},
std::array<float,2>{0.92979753f, 0.361177266f},
std::array<float,2>{0.234399512f, 0.479529977f},
std::array<float,2>{0.828791857f, 0.920385361f},
std::array<float,2>{0.26310882f, 0.695716798f},
std::array<float,2>{0.524320483f, 0.163534716f},
std::array<float,2>{0.179519251f, 0.221269757f},
std::array<float,2>{0.805875659f, 0.676712692f},
std::array<float,2>{0.361156136f, 0.959468782f},
std::array<float,2>{0.595428765f, 0.38101247f},
std::array<float,2>{0.49985072f, 0.302119941f},
std::array<float,2>{0.743990839f, 0.789887428f},
std::array<float,2>{0.110777885f, 0.558287501f},
std::array<float,2>{0.993651509f, 0.0933924317f},
std::array<float,2>{0.254068136f, 0.0116041387f},
std::array<float,2>{0.522433579f, 0.571904421f},
std::array<float,2>{0.248136237f, 0.822249472f},
std::array<float,2>{0.837120354f, 0.323429376f},
std::array<float,2>{0.0584403425f, 0.442734331f},
std::array<float,2>{0.925089061f, 0.903860629f},
std::array<float,2>{0.419773012f, 0.746613503f},
std::array<float,2>{0.679769397f, 0.135050535f},
std::array<float,2>{0.0723761469f, 0.111333601f},
std::array<float,2>{0.957075894f, 0.500749528f},
std::array<float,2>{0.458853036f, 0.76126945f},
std::array<float,2>{0.702165902f, 0.254786253f},
std::array<float,2>{0.323390126f, 0.431098074f},
std::array<float,2>{0.578321099f, 0.971072495f},
std::array<float,2>{0.140614092f, 0.641445875f},
std::array<float,2>{0.763201356f, 0.210063681f},
std::array<float,2>{0.381026f, 0.166299626f},
std::array<float,2>{0.633950949f, 0.693887055f},
std::array<float,2>{0.0310098361f, 0.907198966f},
std::array<float,2>{0.896866381f, 0.473981947f},
std::array<float,2>{0.207368523f, 0.367518097f},
std::array<float,2>{0.84539938f, 0.857279062f},
std::array<float,2>{0.298298866f, 0.610655427f},
std::array<float,2>{0.54050827f, 0.0529733524f},
std::array<float,2>{0.233558774f, 0.0403690077f},
std::array<float,2>{0.820170105f, 0.60584712f},
std::array<float,2>{0.267228633f, 0.873537302f},
std::array<float,2>{0.509071052f, 0.344385207f},
std::array<float,2>{0.42376408f, 0.486234337f},
std::array<float,2>{0.662430048f, 0.925712407f},
std::array<float,2>{0.032750044f, 0.715945542f},
std::array<float,2>{0.911103666f, 0.172101825f},
std::array<float,2>{0.353356987f, 0.187629983f},
std::array<float,2>{0.614002943f, 0.633701622f},
std::array<float,2>{0.162976369f, 0.984582067f},
std::array<float,2>{0.782794714f, 0.416871637f},
std::array<float,2>{0.0946686193f, 0.267470747f},
std::array<float,2>{0.979000211f, 0.778071642f},
std::array<float,2>{0.469483197f, 0.529806554f},
std::array<float,2>{0.729228914f, 0.107415706f},
std::array<float,2>{0.0142120924f, 0.151206315f},
std::array<float,2>{0.879896581f, 0.731284499f},
std::array<float,2>{0.391728401f, 0.890119553f},
std::array<float,2>{0.644789934f, 0.458045036f},
std::array<float,2>{0.293205857f, 0.333177149f},
std::array<float,2>{0.557395399f, 0.842619777f},
std::array<float,2>{0.189748719f, 0.580970943f},
std::array<float,2>{0.865308464f, 0.0229702443f},
std::array<float,2>{0.441510499f, 0.0763590932f},
std::array<float,2>{0.713637471f, 0.534205496f},
std::array<float,2>{0.0803647414f, 0.797812521f},
std::array<float,2>{0.943745613f, 0.286639631f},
std::array<float,2>{0.148744583f, 0.394836247f},
std::array<float,2>{0.774583042f, 0.942332804f},
std::array<float,2>{0.343670428f, 0.665223718f},
std::array<float,2>{0.569245398f, 0.23736082f},
std::array<float,2>{0.246035591f, 0.196817875f},
std::array<float,2>{0.840420246f, 0.629752636f},
std::array<float,2>{0.250015318f, 0.999372602f},
std::array<float,2>{0.519318402f, 0.407273799f},
std::array<float,2>{0.414985806f, 0.278988421f},
std::array<float,2>{0.684313357f, 0.766157329f},
std::array<float,2>{0.0623539612f, 0.516952097f},
std::array<float,2>{0.926482618f, 0.093776688f},
std::array<float,2>{0.365976423f, 0.0337956361f},
std::array<float,2>{0.599896371f, 0.598496199f},
std::array<float,2>{0.175624162f, 0.862029493f},
std::array<float,2>{0.809923768f, 0.352608562f},
std::array<float,2>{0.116603583f, 0.497774392f},
std::array<float,2>{0.99808681f, 0.930859566f},
std::array<float,2>{0.493625462f, 0.708250344f},
std::array<float,2>{0.749249458f, 0.18590872f},
std::array<float,2>{0.0260264631f, 0.0686497912f},
std::array<float,2>{0.893647671f, 0.539423883f},
std::array<float,2>{0.376453072f, 0.807771206f},
std::array<float,2>{0.63988924f, 0.290153533f},
std::array<float,2>{0.301810473f, 0.402331799f},
std::array<float,2>{0.545852304f, 0.945474684f},
std::array<float,2>{0.204616681f, 0.662360668f},
std::array<float,2>{0.850968301f, 0.244642928f},
std::array<float,2>{0.456964433f, 0.145509854f},
std::array<float,2>{0.695571482f, 0.726267576f},
std::array<float,2>{0.0742969289f, 0.879142106f},
std::array<float,2>{0.955427945f, 0.464862138f},
std::array<float,2>{0.133206695f, 0.343173862f},
std::array<float,2>{0.759197056f, 0.832594037f},
std::array<float,2>{0.325444639f, 0.589764833f},
std::array<float,2>{0.584854662f, 0.0249456111f},
std::array<float,2>{0.156631708f, 0.000475084787f},
std::array<float,2>{0.788531244f, 0.564251602f},
std::array<float,2>{0.356847823f, 0.815657973f},
std::array<float,2>{0.612250388f, 0.313016325f},
std::array<float,2>{0.474093348f, 0.452337652f},
std::array<float,2>{0.73123467f, 0.898079336f},
std::array<float,2>{0.10015732f, 0.739439249f},
std::array<float,2>{0.98261255f, 0.131807163f},
std::array<float,2>{0.272552043f, 0.226920009f},
std::array<float,2>{0.514971375f, 0.683658838f},
std::array<float,2>{0.227902785f, 0.962050676f},
std::array<float,2>{0.815947294f, 0.387824684f},
std::array<float,2>{0.0390610956f, 0.310992181f},
std::array<float,2>{0.908695519f, 0.786988735f},
std::array<float,2>{0.429315001f, 0.550705433f},
std::array<float,2>{0.658160329f, 0.0837935582f},
std::array<float,2>{0.0837003514f, 0.15892157f},
std::array<float,2>{0.940663993f, 0.701408446f},
std::array<float,2>{0.43831417f, 0.915724695f},
std::array<float,2>{0.717724204f, 0.482180089f},
std::array<float,2>{0.339425474f, 0.36545378f},
std::array<float,2>{0.566124439f, 0.848284841f},
std::array<float,2>{0.154380858f, 0.621289372f},
std::array<float,2>{0.778142869f, 0.0621004179f},
std::array<float,2>{0.395137012f, 0.122994632f},
std::array<float,2>{0.644040823f, 0.512678683f},
std::array<float,2>{0.00928167813f, 0.755257189f},
std::array<float,2>{0.878136933f, 0.261538506f},
std::array<float,2>{0.193048626f, 0.424935281f},
std::array<float,2>{0.861002326f, 0.981094599f},
std::array<float,2>{0.289331824f, 0.651423514f},
std::array<float,2>{0.561563313f, 0.217942908f},
std::array<float,2>{0.145111218f, 0.139575273f},
std::array<float,2>{0.770998716f, 0.745762169f},
std::array<float,2>{0.334422946f, 0.900479794f},
std::array<float,2>{0.57700187f, 0.439399749f},
std::array<float,2>{0.451664388f, 0.326418638f},
std::array<float,2>{0.703432798f, 0.827391267f},
std::array<float,2>{0.0932818055f, 0.575997829f},
std::array<float,2>{0.950562119f, 0.0142933819f},
std::array<float,2>{0.285250783f, 0.0894130766f},
std::array<float,2>{0.552208662f, 0.561548769f},
std::array<float,2>{0.196917012f, 0.795934975f},
std::array<float,2>{0.869998217f, 0.29830423f},
std::array<float,2>{0.00316765206f, 0.376783282f},
std::array<float,2>{0.886196554f, 0.955572605f},
std::array<float,2>{0.403097421f, 0.672553301f},
std::array<float,2>{0.653176963f, 0.223657489f},
std::array<float,2>{0.106916212f, 0.0483346246f},
std::array<float,2>{0.968902528f, 0.616458297f},
std::array<float,2>{0.481955528f, 0.85231483f},
std::array<float,2>{0.721511126f, 0.373303562f},
std::array<float,2>{0.347073883f, 0.470273226f},
std::array<float,2>{0.62178874f, 0.913522482f},
std::array<float,2>{0.164213955f, 0.691318512f},
std::array<float,2>{0.790582776f, 0.168828636f},
std::array<float,2>{0.436891764f, 0.204793438f},
std::array<float,2>{0.666762888f, 0.647702813f},
std::array<float,2>{0.0408924408f, 0.97640425f},
std::array<float,2>{0.921645999f, 0.43363747f},
std::array<float,2>{0.226356283f, 0.251840472f},
std::array<float,2>{0.824839532f, 0.763326943f},
std::array<float,2>{0.278810292f, 0.507217586f},
std::array<float,2>{0.505020201f, 0.116269633f},
std::array<float,2>{0.214673012f, 0.104667976f},
std::array<float,2>{0.856921852f, 0.523843467f},
std::array<float,2>{0.307219476f, 0.775750339f},
std::array<float,2>{0.533980191f, 0.270650029f},
std::array<float,2>{0.389932841f, 0.420331478f},
std::array<float,2>{0.625990927f, 0.991566539f},
std::array<float,2>{0.0211232863f, 0.637140691f},
std::array<float,2>{0.902225494f, 0.191985399f},
std::array<float,2>{0.313309282f, 0.178986892f},
std::array<float,2>{0.593696713f, 0.713903606f},
std::array<float,2>{0.131709069f, 0.926285684f},
std::array<float,2>{0.755625725f, 0.491318375f},
std::array<float,2>{0.0643121451f, 0.347672492f},
std::array<float,2>{0.966953278f, 0.86750257f},
std::array<float,2>{0.466143817f, 0.602945447f},
std::array<float,2>{0.691305339f, 0.0461855419f},
std::array<float,2>{0.0542718731f, 0.24113287f},
std::array<float,2>{0.935894072f, 0.668700695f},
std::array<float,2>{0.412921309f, 0.940396369f},
std::array<float,2>{0.674485624f, 0.39377889f},
std::array<float,2>{0.258055389f, 0.285078913f},
std::array<float,2>{0.529296815f, 0.800808251f},
std::array<float,2>{0.239892527f, 0.535256982f},
std::array<float,2>{0.835821092f, 0.0728713349f},
std::array<float,2>{0.484769136f, 0.0184405204f},
std::array<float,2>{0.736022115f, 0.585036457f},
std::array<float,2>{0.120455362f, 0.837178707f},
std::array<float,2>{0.985711873f, 0.331079692f},
std::array<float,2>{0.186530143f, 0.455965072f},
std::array<float,2>{0.804500759f, 0.884729147f},
std::array<float,2>{0.370973259f, 0.726739347f},
std::array<float,2>{0.604999363f, 0.153113842f},
std::array<float,2>{0.222237036f, 0.141109839f},
std::array<float,2>{0.822286367f, 0.719591916f},
std::array<float,2>{0.274658382f, 0.876546264f},
std::array<float,2>{0.502297759f, 0.463985145f},
std::array<float,2>{0.430283546f, 0.336839855f},
std::array<float,2>{0.667994082f, 0.831272542f},
std::array<float,2>{0.0467540435f, 0.592386067f},
std::array<float,2>{0.915311396f, 0.0298379473f},
std::array<float,2>{0.350038886f, 0.0631066859f},
std::array<float,2>{0.620273411f, 0.54567641f},
std::array<float,2>{0.169712663f, 0.808936954f},
std::array<float,2>{0.796038926f, 0.294125527f},
std::array<float,2>{0.103423439f, 0.405996591f},
std::array<float,2>{0.974892974f, 0.950202227f},
std::array<float,2>{0.476794243f, 0.656401217f},
std::array<float,2>{0.723114014f, 0.247255251f},
std::array<float,2>{0.00624987157f, 0.0370195508f},
std::array<float,2>{0.887071311f, 0.594211161f},
std::array<float,2>{0.399616033f, 0.864514291f},
std::array<float,2>{0.651903391f, 0.357256085f},
std::array<float,2>{0.28270036f, 0.492990613f},
std::array<float,2>{0.549026608f, 0.936954916f},
std::array<float,2>{0.199521109f, 0.704208553f},
std::array<float,2>{0.8749879f, 0.182203084f},
std::array<float,2>{0.448781312f, 0.200689256f},
std::array<float,2>{0.70990169f, 0.627508104f},
std::array<float,2>{0.0870896578f, 0.993833661f},
std::array<float,2>{0.948094904f, 0.413330644f},
std::array<float,2>{0.141121745f, 0.27664566f},
std::array<float,2>{0.76576376f, 0.771013439f},
std::array<float,2>{0.329284787f, 0.519667685f},
std::array<float,2>{0.571103811f, 0.100201778f},
std::array<float,2>{0.179756671f, 0.120221779f},
std::array<float,2>{0.800665677f, 0.509307086f},
std::array<float,2>{0.373108178f, 0.751397252f},
std::array<float,2>{0.605581343f, 0.261835337f},
std::array<float,2>{0.490949839f, 0.425919443f},
std::array<float,2>{0.740704f, 0.979099333f},
std::array<float,2>{0.122641452f, 0.653584659f},
std::array<float,2>{0.992076695f, 0.211622611f},
std::array<float,2>{0.2648426f, 0.16198343f},
std::array<float,2>{0.525991499f, 0.698781669f},
std::array<float,2>{0.237103626f, 0.918857276f},
std::array<float,2>{0.830970049f, 0.478428096f},
std::array<float,2>{0.0501237325f, 0.362077504f},
std::array<float,2>{0.932204247f, 0.844055295f},
std::array<float,2>{0.409282863f, 0.619479835f},
std::array<float,2>{0.677276969f, 0.0572687946f},
std::array<float,2>{0.0701138005f, 0.234187067f},
std::array<float,2>{0.96109134f, 0.682960153f},
std::array<float,2>{0.462230265f, 0.966776967f},
std::array<float,2>{0.692075074f, 0.383959025f},
std::array<float,2>{0.319605201f, 0.30620262f},
std::array<float,2>{0.588952005f, 0.784127116f},
std::array<float,2>{0.127307102f, 0.553797126f},
std::array<float,2>{0.751395524f, 0.0790478289f},
std::array<float,2>{0.384971529f, 0.00659381459f},
std::array<float,2>{0.630431652f, 0.568003953f},
std::array<float,2>{0.0185165275f, 0.819866776f},
std::array<float,2>{0.902681351f, 0.319914639f},
std::array<float,2>{0.217203394f, 0.448548883f},
std::array<float,2>{0.853631198f, 0.893594801f},
std::array<float,2>{0.310779274f, 0.737891674f},
std::array<float,2>{0.536108732f, 0.127335683f},
std::array<float,2>{0.138595492f, 0.207689062f},
std::array<float,2>{0.765619278f, 0.64385426f},
std::array<float,2>{0.32111463f, 0.969819963f},
std::array<float,2>{0.580821455f, 0.433284968f},
std::array<float,2>{0.459281772f, 0.257793546f},
std::array<float,2>{0.69926244f, 0.758372188f},
std::array<float,2>{0.0708152652f, 0.502989054f},
std::array<float,2>{0.960088193f, 0.110645771f},
std::array<float,2>{0.299096942f, 0.0523679033f},
std::array<float,2>{0.542373121f, 0.6128214f},
std::array<float,2>{0.209161237f, 0.858610213f},
std::array<float,2>{0.84649092f, 0.369474024f},
std::array<float,2>{0.0287650581f, 0.475193262f},
std::array<float,2>{0.895206451f, 0.908834279f},
std::array<float,2>{0.378932327f, 0.69269979f},
std::array<float,2>{0.635338068f, 0.165772721f},
std::array<float,2>{0.112322949f, 0.090865314f},
std::array<float,2>{0.996084094f, 0.555610061f},
std::array<float,2>{0.497747928f, 0.792686045f},
std::array<float,2>{0.744510651f, 0.303529948f},
std::array<float,2>{0.361999899f, 0.37904489f},
std::array<float,2>{0.595913708f, 0.957297385f},
std::array<float,2>{0.177097946f, 0.677832484f},
std::array<float,2>{0.807030857f, 0.220274806f},
std::array<float,2>{0.420913965f, 0.134360954f},
std::array<float,2>{0.682515085f, 0.749092579f},
std::array<float,2>{0.0559304059f, 0.905010045f},
std::array<float,2>{0.922578752f, 0.444933891f},
std::array<float,2>{0.247114792f, 0.320698023f},
std::array<float,2>{0.839572191f, 0.823692918f},
std::array<float,2>{0.257262528f, 0.573575735f},
std::array<float,2>{0.521258712f, 0.00784801692f},
std::array<float,2>{0.188121781f, 0.0196485445f},
std::array<float,2>{0.863451362f, 0.57993114f},
std::array<float,2>{0.294972509f, 0.840450823f},
std::array<float,2>{0.555034757f, 0.334884226f},
std::array<float,2>{0.393942386f, 0.459640324f},
std::array<float,2>{0.648323119f, 0.887666583f},
std::array<float,2>{0.0131579926f, 0.733255744f},
std::array<float,2>{0.882628143f, 0.149496257f},
std::array<float,2>{0.341213465f, 0.236140713f},
std::array<float,2>{0.568161249f, 0.667240858f},
std::array<float,2>{0.152330175f, 0.944009483f},
std::array<float,2>{0.775589764f, 0.397917837f},
std::array<float,2>{0.0791356489f, 0.287178725f},
std::array<float,2>{0.942032933f, 0.800207734f},
std::array<float,2>{0.443770438f, 0.532631218f},
std::array<float,2>{0.71246016f, 0.0743312836f},
std::array<float,2>{0.0347934142f, 0.174445972f},
std::array<float,2>{0.91317904f, 0.718627453f},
std::array<float,2>{0.425385773f, 0.922938287f},
std::array<float,2>{0.661144674f, 0.486922801f},
std::array<float,2>{0.268387169f, 0.34611401f},
std::array<float,2>{0.5105111f, 0.871515572f},
std::array<float,2>{0.231353968f, 0.607928693f},
std::array<float,2>{0.816698074f, 0.0427292287f},
std::array<float,2>{0.472440332f, 0.107483886f},
std::array<float,2>{0.727897942f, 0.52756083f},
std::array<float,2>{0.0967495069f, 0.779895782f},
std::array<float,2>{0.97823602f, 0.26915738f},
std::array<float,2>{0.160988152f, 0.414369404f},
std::array<float,2>{0.783858836f, 0.98686403f},
std::array<float,2>{0.35442397f, 0.636455834f},
std::array<float,2>{0.615736127f, 0.189537063f},
std::array<float,2>{0.205685496f, 0.243762791f},
std::array<float,2>{0.849075437f, 0.66208744f},
std::array<float,2>{0.30292967f, 0.94798243f},
std::array<float,2>{0.544653893f, 0.399818122f},
std::array<float,2>{0.37889871f, 0.292652458f},
std::array<float,2>{0.638423979f, 0.804783702f},
std::array<float,2>{0.0240156949f, 0.541258514f},
std::array<float,2>{0.891031682f, 0.0674454346f},
std::array<float,2>{0.327125669f, 0.0260811467f},
std::array<float,2>{0.583274603f, 0.586366475f},
std::array<float,2>{0.135848969f, 0.834454954f},
std::array<float,2>{0.761064351f, 0.341659993f},
std::array<float,2>{0.0772000253f, 0.466929436f},
std::array<float,2>{0.95357275f, 0.881232679f},
std::array<float,2>{0.454312593f, 0.722717047f},
std::array<float,2>{0.697457552f, 0.14694716f},
std::array<float,2>{0.0601636656f, 0.0959662795f},
std::array<float,2>{0.928617954f, 0.5180071f},
std::array<float,2>{0.416849256f, 0.768106043f},
std::array<float,2>{0.686040401f, 0.279795259f},
std::array<float,2>{0.253435761f, 0.410153508f},
std::array<float,2>{0.515719354f, 0.997689843f},
std::array<float,2>{0.243599176f, 0.632266462f},
std::array<float,2>{0.843107641f, 0.197818041f},
std::array<float,2>{0.495147943f, 0.184163645f},
std::array<float,2>{0.747652769f, 0.709486842f},
std::array<float,2>{0.113529749f, 0.933195591f},
std::array<float,2>{0.996433198f, 0.499433756f},
std::array<float,2>{0.173609018f, 0.354595333f},
std::array<float,2>{0.811297953f, 0.860077977f},
std::array<float,2>{0.364341348f, 0.600136101f},
std::array<float,2>{0.598716438f, 0.031419415f},
std::array<float,2>{0.154271558f, 0.0591692068f},
std::array<float,2>{0.779646039f, 0.624303579f},
std::array<float,2>{0.336696655f, 0.850751758f},
std::array<float,2>{0.562556446f, 0.364087105f},
std::array<float,2>{0.439752311f, 0.483469069f},
std::array<float,2>{0.715761304f, 0.916379094f},
std::array<float,2>{0.085574463f, 0.700940013f},
std::array<float,2>{0.938837826f, 0.156676203f},
std::array<float,2>{0.29198733f, 0.2167321f},
std::array<float,2>{0.559726715f, 0.649043083f},
std::array<float,2>{0.193954289f, 0.982789576f},
std::array<float,2>{0.861779451f, 0.423338234f},
std::array<float,2>{0.0115732905f, 0.258297414f},
std::array<float,2>{0.875692844f, 0.757632613f},
std::array<float,2>{0.39813143f, 0.514495134f},
std::array<float,2>{0.641540945f, 0.123282127f},
std::array<float,2>{0.0978758633f, 0.128964067f},
std::array<float,2>{0.982094407f, 0.741711855f},
std::array<float,2>{0.474891394f, 0.895495355f},
std::array<float,2>{0.73420161f, 0.449530154f},
std::array<float,2>{0.357999235f, 0.315472692f},
std::array<float,2>{0.610912144f, 0.813412309f},
std::array<float,2>{0.159514576f, 0.56581372f},
std::array<float,2>{0.785290003f, 0.00387110445f},
std::array<float,2>{0.425981015f, 0.0855016485f},
std::array<float,2>{0.659801006f, 0.547118187f},
std::array<float,2>{0.0368838646f, 0.788261592f},
std::array<float,2>{0.906961083f, 0.308889717f},
std::array<float,2>{0.2295627f, 0.389447212f},
std::array<float,2>{0.813141882f, 0.964319289f},
std::array<float,2>{0.2709952f, 0.68593204f},
std::array<float,2>{0.512979567f, 0.22934705f},
std::array<float,2>{0.167114988f, 0.17124024f},
std::array<float,2>{0.791876137f, 0.688557088f},
std::array<float,2>{0.344658136f, 0.910694182f},
std::array<float,2>{0.624319553f, 0.472653538f},
std::array<float,2>{0.484053195f, 0.371119171f},
std::array<float,2>{0.71928066f, 0.855461657f},
std::array<float,2>{0.108247332f, 0.614730537f},
std::array<float,2>{0.971941471f, 0.0499641113f},
std::array<float,2>{0.27982384f, 0.114838615f},
std::array<float,2>{0.50667733f, 0.504005373f},
std::array<float,2>{0.223007143f, 0.764041603f},
std::array<float,2>{0.826462567f, 0.253002226f},
std::array<float,2>{0.0427402928f, 0.436645031f},
std::array<float,2>{0.918315113f, 0.973224819f},
std::array<float,2>{0.434835583f, 0.645471454f},
std::array<float,2>{0.664137185f, 0.206015348f},
std::array<float,2>{0.0916157216f, 0.0134133277f},
std::array<float,2>{0.951479852f, 0.576691389f},
std::array<float,2>{0.450117975f, 0.824335098f},
std::array<float,2>{0.705257356f, 0.325919598f},
std::array<float,2>{0.333868355f, 0.44125098f},
std::array<float,2>{0.575497568f, 0.900281072f},
std::array<float,2>{0.147854775f, 0.743161082f},
std::array<float,2>{0.772648036f, 0.138294265f},
std::array<float,2>{0.40474093f, 0.225614876f},
std::array<float,2>{0.656167388f, 0.674385548f},
std::array<float,2>{0.000870096497f, 0.954678476f},
std::array<float,2>{0.883674085f, 0.377039909f},
std::array<float,2>{0.197746322f, 0.299596429f},
std::array<float,2>{0.867321253f, 0.793751955f},
std::array<float,2>{0.288833261f, 0.559408665f},
std::array<float,2>{0.5537678f, 0.0875334591f},
std::array<float,2>{0.240829259f, 0.0721309632f},
std::array<float,2>{0.833537042f, 0.538592875f},
std::array<float,2>{0.261176378f, 0.804434478f},
std::array<float,2>{0.53031075f, 0.281838208f},
std::array<float,2>{0.411950797f, 0.391403079f},
std::array<float,2>{0.673291624f, 0.938081563f},
std::array<float,2>{0.0516500138f, 0.670818925f},
std::array<float,2>{0.935429096f, 0.239561781f},
std::array<float,2>{0.36879167f, 0.154801711f},
std::array<float,2>{0.603469431f, 0.730074286f},
std::array<float,2>{0.183945119f, 0.885572076f},
std::array<float,2>{0.80157125f, 0.454805493f},
std::array<float,2>{0.118362792f, 0.329010397f},
std::array<float,2>{0.988088071f, 0.839843094f},
std::array<float,2>{0.486691505f, 0.582741499f},
std::array<float,2>{0.73661232f, 0.0157182235f},
std::array<float,2>{0.0216296464f, 0.194307998f},
std::array<float,2>{0.899474502f, 0.639961302f},
std::array<float,2>{0.387013346f, 0.98912251f},
std::array<float,2>{0.627340078f, 0.418644577f},
std::array<float,2>{0.305613905f, 0.273176551f},
std::array<float,2>{0.533078492f, 0.774050355f},
std::array<float,2>{0.211489201f, 0.526738107f},
std::array<float,2>{0.858094871f, 0.102909334f},
std::array<float,2>{0.468103677f, 0.043734815f},
std::array<float,2>{0.688937128f, 0.604203105f},
std::array<float,2>{0.0660674721f, 0.870047867f},
std::array<float,2>{0.965948999f, 0.350866854f},
std::array<float,2>{0.129177362f, 0.488497436f},
std::array<float,2>{0.757026434f, 0.928044021f},
std::array<float,2>{0.316179186f, 0.712104321f},
std::array<float,2>{0.590122879f, 0.177690804f},
std::array<float,2>{0.237953484f, 0.162868753f},
std::array<float,2>{0.831403434f, 0.697023392f},
std::array<float,2>{0.264261127f, 0.921473145f},
std::array<float,2>{0.527118981f, 0.478616893f},
std::array<float,2>{0.408629537f, 0.359731138f},
std::array<float,2>{0.676148117f, 0.846596599f},
std::array<float,2>{0.0494001098f, 0.618920147f},
std::array<float,2>{0.933063686f, 0.054746177f},
std::array<float,2>{0.374364108f, 0.118957996f},
std::array<float,2>{0.607282341f, 0.511527061f},
std::array<float,2>{0.180986762f, 0.752155125f},
std::array<float,2>{0.799101532f, 0.265217543f},
std::array<float,2>{0.121404335f, 0.429675192f},
std::array<float,2>{0.991196394f, 0.978361845f},
std::array<float,2>{0.49191609f, 0.655616045f},
std::array<float,2>{0.742075503f, 0.213821813f},
std::array<float,2>{0.0189249869f, 0.00577558158f},
std::array<float,2>{0.903357923f, 0.570143402f},
std::array<float,2>{0.386238396f, 0.817810237f},
std::array<float,2>{0.628941178f, 0.317525923f},
std::array<float,2>{0.312395066f, 0.44645527f},
std::array<float,2>{0.536566198f, 0.891370714f},
std::array<float,2>{0.217954025f, 0.735418141f},
std::array<float,2>{0.854873598f, 0.125656039f},
std::array<float,2>{0.461836278f, 0.232124448f},
std::array<float,2>{0.692707598f, 0.681012273f},
std::array<float,2>{0.0689419657f, 0.96741116f},
std::array<float,2>{0.962855041f, 0.385575324f},
std::array<float,2>{0.128734216f, 0.307414025f},
std::array<float,2>{0.750249624f, 0.781320512f},
std::array<float,2>{0.318401128f, 0.551059783f},
std::array<float,2>{0.58801657f, 0.080589138f},
std::array<float,2>{0.168520987f, 0.0646469891f},
std::array<float,2>{0.794938266f, 0.543587565f},
std::array<float,2>{0.351492316f, 0.812349916f},
std::array<float,2>{0.619904697f, 0.29546687f},
std::array<float,2>{0.477951795f, 0.403762579f},
std::array<float,2>{0.724248946f, 0.952828586f},
std::array<float,2>{0.102270246f, 0.659635544f},
std::array<float,2>{0.976474524f, 0.24952589f},
std::array<float,2>{0.273988068f, 0.14391233f},
std::array<float,2>{0.503641903f, 0.721664965f},
std::array<float,2>{0.22111845f, 0.878061235f},
std::array<float,2>{0.823612869f, 0.462465137f},
std::array<float,2>{0.0457273051f, 0.33844471f},
std::array<float,2>{0.914593637f, 0.829429924f},
std::array<float,2>{0.431278408f, 0.591468573f},
std::array<float,2>{0.669621289f, 0.028525142f},
std::array<float,2>{0.0859997198f, 0.202062398f},
std::array<float,2>{0.949171662f, 0.625042677f},
std::array<float,2>{0.447751909f, 0.99605906f},
std::array<float,2>{0.710617125f, 0.410240382f},
std::array<float,2>{0.328990012f, 0.274199337f},
std::array<float,2>{0.571907222f, 0.772807479f},
std::array<float,2>{0.142162055f, 0.522594154f},
std::array<float,2>{0.767449796f, 0.0984772816f},
std::array<float,2>{0.39911446f, 0.0377823524f},
std::array<float,2>{0.650808394f, 0.59612745f},
std::array<float,2>{0.00747695053f, 0.86613673f},
std::array<float,2>{0.888262689f, 0.359175503f},
std::array<float,2>{0.201106384f, 0.494375467f},
std::array<float,2>{0.873091042f, 0.933866858f},
std::array<float,2>{0.281597227f, 0.706066787f},
std::array<float,2>{0.549843907f, 0.180067137f},
std::array<float,2>{0.15078187f, 0.236363485f},
std::array<float,2>{0.77674371f, 0.664837897f},
std::array<float,2>{0.340327173f, 0.942780614f},
std::array<float,2>{0.566909611f, 0.396265209f},
std::array<float,2>{0.444778383f, 0.285282701f},
std::array<float,2>{0.711334944f, 0.798173428f},
std::array<float,2>{0.0789870396f, 0.533968389f},
std::array<float,2>{0.942888856f, 0.0774869025f},
std::array<float,2>{0.296214849f, 0.0222064964f},
std::array<float,2>{0.556489825f, 0.581312835f},
std::array<float,2>{0.189202607f, 0.8436777f},
std::array<float,2>{0.864853561f, 0.332433283f},
std::array<float,2>{0.012029347f, 0.457230717f},
std::array<float,2>{0.88090843f, 0.889434159f},
std::array<float,2>{0.392677367f, 0.732093155f},
std::array<float,2>{0.646960378f, 0.151811451f},
std::array<float,2>{0.0960374847f, 0.105966933f},
std::array<float,2>{0.976915658f, 0.530369043f},
std::array<float,2>{0.471264571f, 0.779080987f},
std::array<float,2>{0.726810753f, 0.266106755f},
std::array<float,2>{0.3545371f, 0.417483419f},
std::array<float,2>{0.616739929f, 0.986278415f},
std::array<float,2>{0.16201365f, 0.634305775f},
std::array<float,2>{0.784528494f, 0.188811377f},
std::array<float,2>{0.424467057f, 0.173270062f},
std::array<float,2>{0.660956323f, 0.715651631f},
std::array<float,2>{0.0333810374f, 0.924116552f},
std::array<float,2>{0.913054347f, 0.485081166f},
std::array<float,2>{0.232326195f, 0.344917625f},
std::array<float,2>{0.81788224f, 0.874562502f},
std::array<float,2>{0.26871717f, 0.606488168f},
std::array<float,2>{0.511286795f, 0.03916879f},
std::array<float,2>{0.210557938f, 0.0540452451f},
std::array<float,2>{0.847593606f, 0.610203028f},
std::array<float,2>{0.300282508f, 0.855545282f},
std::array<float,2>{0.541783988f, 0.368832648f},
std::array<float,2>{0.380554825f, 0.473224282f},
std::array<float,2>{0.636575222f, 0.907674432f},
std::array<float,2>{0.0282853302f, 0.694687903f},
std::array<float,2>{0.896312356f, 0.167612329f},
std::array<float,2>{0.321397156f, 0.209615126f},
std::array<float,2>{0.581853509f, 0.642009795f},
std::array<float,2>{0.136960223f, 0.972261846f},
std::array<float,2>{0.764547884f, 0.429714203f},
std::array<float,2>{0.071816504f, 0.255654931f},
std::array<float,2>{0.959021926f, 0.760580838f},
std::array<float,2>{0.460720837f, 0.501015961f},
std::array<float,2>{0.700858593f, 0.112818979f},
std::array<float,2>{0.0548066832f, 0.136669159f},
std::array<float,2>{0.923651278f, 0.747937024f},
std::array<float,2>{0.420791298f, 0.90283668f},
std::array<float,2>{0.682697713f, 0.441849589f},
std::array<float,2>{0.256602198f, 0.322292149f},
std::array<float,2>{0.520471334f, 0.820359409f},
std::array<float,2>{0.246862248f, 0.570405006f},
std::array<float,2>{0.838032305f, 0.0100242626f},
std::array<float,2>{0.496267885f, 0.0921213701f},
std::array<float,2>{0.745175958f, 0.557083368f},
std::array<float,2>{0.111824892f, 0.790955842f},
std::array<float,2>{0.994670272f, 0.301344305f},
std::array<float,2>{0.17668739f, 0.382785678f},
std::array<float,2>{0.808053017f, 0.960702777f},
std::array<float,2>{0.362483948f, 0.676836193f},
std::array<float,2>{0.597599983f, 0.222091854f},
std::array<float,2>{0.19463858f, 0.217178836f},
std::array<float,2>{0.863198698f, 0.65085119f},
std::array<float,2>{0.292284399f, 0.982098043f},
std::array<float,2>{0.559195042f, 0.424016744f},
std::array<float,2>{0.397448957f, 0.259953588f},
std::array<float,2>{0.641623497f, 0.753961205f},
std::array<float,2>{0.00993114337f, 0.513502955f},
std::array<float,2>{0.876529336f, 0.121763036f},
std::array<float,2>{0.337178439f, 0.0611527376f},
std::array<float,2>{0.563581407f, 0.622151911f},
std::array<float,2>{0.153161511f, 0.84959656f},
std::array<float,2>{0.78100282f, 0.36639747f},
std::array<float,2>{0.0840706751f, 0.480879009f},
std::array<float,2>{0.937811077f, 0.914683759f},
std::array<float,2>{0.44066599f, 0.702941477f},
std::array<float,2>{0.716764092f, 0.159371763f},
std::array<float,2>{0.0357637964f, 0.0826532096f},
std::array<float,2>{0.908125281f, 0.548965335f},
std::array<float,2>{0.427557498f, 0.786004782f},
std::array<float,2>{0.658947527f, 0.312319964f},
std::array<float,2>{0.269718319f, 0.387348741f},
std::array<float,2>{0.512254179f, 0.961188912f},
std::array<float,2>{0.228968129f, 0.684898496f},
std::array<float,2>{0.813554227f, 0.228423476f},
std::array<float,2>{0.476449013f, 0.1320941f},
std::array<float,2>{0.733327568f, 0.739028215f},
std::array<float,2>{0.0994794369f, 0.896846652f},
std::array<float,2>{0.981010616f, 0.451440036f},
std::array<float,2>{0.159173712f, 0.31352672f},
std::array<float,2>{0.786731422f, 0.815321326f},
std::array<float,2>{0.358830988f, 0.562753975f},
std::array<float,2>{0.610065162f, 0.00100534875f},
std::array<float,2>{0.134819835f, 0.0240269657f},
std::array<float,2>{0.760719538f, 0.588161469f},
std::array<float,2>{0.327420235f, 0.833252192f},
std::array<float,2>{0.582876205f, 0.341904551f},
std::array<float,2>{0.453129411f, 0.46620509f},
std::array<float,2>{0.698334575f, 0.880719781f},
std::array<float,2>{0.0765064731f, 0.725364923f},
std::array<float,2>{0.954384208f, 0.145092666f},
std::array<float,2>{0.304033667f, 0.245869353f},
std::array<float,2>{0.543521702f, 0.663904369f},
std::array<float,2>{0.206152529f, 0.946504772f},
std::array<float,2>{0.847681403f, 0.401289582f},
std::array<float,2>{0.0249082185f, 0.289697886f},
std::array<float,2>{0.892307639f, 0.807006717f},
std::array<float,2>{0.377170146f, 0.540543914f},
std::array<float,2>{0.637355268f, 0.0697344467f},
std::array<float,2>{0.114345007f, 0.187160686f},
std::array<float,2>{0.997372091f, 0.707468152f},
std::array<float,2>{0.494508982f, 0.930035174f},
std::array<float,2>{0.746358573f, 0.496148646f},
std::array<float,2>{0.364027798f, 0.352066129f},
std::array<float,2>{0.597898006f, 0.862888396f},
std::array<float,2>{0.172271013f, 0.59891963f},
std::array<float,2>{0.812343657f, 0.034216553f},
std::array<float,2>{0.417660236f, 0.0951901004f},
std::array<float,2>{0.68724525f, 0.5162763f},
std::array<float,2>{0.0586470701f, 0.76728797f},
std::array<float,2>{0.929109395f, 0.27820304f},
std::array<float,2>{0.242874712f, 0.406745225f},
std::array<float,2>{0.842510104f, 0.998585045f},
std::array<float,2>{0.252415597f, 0.629893303f},
std::array<float,2>{0.517169118f, 0.19602558f},
std::array<float,2>{0.185086831f, 0.153524771f},
std::array<float,2>{0.801976085f, 0.728426754f},
std::array<float,2>{0.367662311f, 0.88356179f},
std::array<float,2>{0.602227688f, 0.45625186f},
std::array<float,2>{0.487382859f, 0.330486089f},
std::array<float,2>{0.737461209f, 0.83598417f},
std::array<float,2>{0.117264614f, 0.584523857f},
std::array<float,2>{0.98713702f, 0.0186897833f},
std::array<float,2>{0.260525376f, 0.0736838281f},
std::array<float,2>{0.530239284f, 0.536204755f},
std::array<float,2>{0.241986021f, 0.80177319f},
std::array<float,2>{0.832954347f, 0.283956707f},
std::array<float,2>{0.0517990366f, 0.392818511f},
std::array<float,2>{0.933621883f, 0.941329181f},
std::array<float,2>{0.410830021f, 0.669813454f},
std::array<float,2>{0.672104418f, 0.241713285f},
std::array<float,2>{0.0652724132f, 0.045800589f},
std::array<float,2>{0.965360045f, 0.60210067f},
std::array<float,2>{0.467455149f, 0.868641257f},
std::array<float,2>{0.687524319f, 0.349462599f},
std::array<float,2>{0.314800411f, 0.490570694f},
std::array<float,2>{0.591400802f, 0.927429795f},
std::array<float,2>{0.129888445f, 0.713263631f},
std::array<float,2>{0.756251514f, 0.178590402f},
std::array<float,2>{0.387999356f, 0.193146348f},
std::array<float,2>{0.628054678f, 0.638418078f},
std::array<float,2>{0.0227389429f, 0.990518928f},
std::array<float,2>{0.898663998f, 0.421383172f},
std::array<float,2>{0.211943552f, 0.270391017f},
std::array<float,2>{0.858745456f, 0.776652932f},
std::array<float,2>{0.306336224f, 0.524479687f},
std::array<float,2>{0.53170526f, 0.103662826f},
std::array<float,2>{0.223662987f, 0.115617171f},
std::array<float,2>{0.828053832f, 0.5064556f},
std::array<float,2>{0.28044191f, 0.761759698f},
std::array<float,2>{0.506885827f, 0.250918269f},
std::array<float,2>{0.434333235f, 0.435169697f},
std::array<float,2>{0.665281892f, 0.975582004f},
std::array<float,2>{0.0410214849f, 0.64707458f},
std::array<float,2>{0.919844389f, 0.203737751f},
std::array<float,2>{0.344762832f, 0.169801444f},
std::array<float,2>{0.623433292f, 0.690246046f},
std::array<float,2>{0.166965693f, 0.91283083f},
std::array<float,2>{0.792707026f, 0.468823522f},
std::array<float,2>{0.10918954f, 0.374269933f},
std::array<float,2>{0.971583009f, 0.85308224f},
std::array<float,2>{0.482684314f, 0.615529597f},
std::array<float,2>{0.720026851f, 0.0473841429f},
std::array<float,2>{0.0019401873f, 0.223442554f},
std::array<float,2>{0.883796215f, 0.673188567f},
std::array<float,2>{0.40553546f, 0.95658052f},
std::array<float,2>{0.655116618f, 0.375034899f},
std::array<float,2>{0.287749052f, 0.297471672f},
std::array<float,2>{0.552749395f, 0.795144141f},
std::array<float,2>{0.198340788f, 0.560992837f},
std::array<float,2>{0.868508995f, 0.088843964f},
std::array<float,2>{0.450775474f, 0.0152060688f},
std::array<float,2>{0.706484079f, 0.574236333f},
std::array<float,2>{0.089855507f, 0.82627809f},
std::array<float,2>{0.952335536f, 0.327502757f},
std::array<float,2>{0.147383034f, 0.437999427f},
std::array<float,2>{0.771673977f, 0.901628911f},
std::array<float,2>{0.332055509f, 0.744722188f},
std::array<float,2>{0.574256361f, 0.140388265f},
std::array<float,2>{0.215708092f, 0.12851724f},
std::array<float,2>{0.852258921f, 0.737291098f},
std::array<float,2>{0.308709592f, 0.893028557f},
std::array<float,2>{0.538746357f, 0.44745791f},
std::array<float,2>{0.383331835f, 0.318667203f},
std::array<float,2>{0.630892873f, 0.819008291f},
std::array<float,2>{0.0156863071f, 0.566591978f},
std::array<float,2>{0.904561341f, 0.00766740786f},
std::array<float,2>{0.316533267f, 0.0800378621f},
std::array<float,2>{0.587111175f, 0.552885234f},
std::array<float,2>{0.125387564f, 0.785074353f},
std::array<float,2>{0.753027141f, 0.305110991f},
std::array<float,2>{0.0665170625f, 0.382985204f},
std::array<float,2>{0.963917911f, 0.965788543f},
std::array<float,2>{0.464356959f, 0.682234466f},
std::array<float,2>{0.693534315f, 0.232637882f},
std::array<float,2>{0.0483280569f, 0.0581925623f},
std::array<float,2>{0.930750787f, 0.620593965f},
std::array<float,2>{0.406696469f, 0.845476568f},
std::array<float,2>{0.679532528f, 0.362853378f},
std::array<float,2>{0.262396455f, 0.477500647f},
std::array<float,2>{0.524505794f, 0.919322014f},
std::array<float,2>{0.235698611f, 0.698009908f},
std::array<float,2>{0.829496145f, 0.16046907f},
std::array<float,2>{0.489818215f, 0.211957917f},
std::array<float,2>{0.739477277f, 0.652715385f},
std::array<float,2>{0.124267943f, 0.98044306f},
std::array<float,2>{0.988976479f, 0.427615404f},
std::array<float,2>{0.182898879f, 0.262779474f},
std::array<float,2>{0.797696054f, 0.750003994f},
std::array<float,2>{0.372221768f, 0.508282602f},
std::array<float,2>{0.608160257f, 0.119522013f},
std::array<float,2>{0.143382624f, 0.100594051f},
std::array<float,2>{0.769383669f, 0.520823538f},
std::array<float,2>{0.331860453f, 0.770339727f},
std::array<float,2>{0.57295239f, 0.27568841f},
std::array<float,2>{0.445601463f, 0.412857622f},
std::array<float,2>{0.708644986f, 0.993133664f},
std::array<float,2>{0.088734448f, 0.628652573f},
std::array<float,2>{0.946922898f, 0.199874297f},
std::array<float,2>{0.283216834f, 0.183399811f},
std::array<float,2>{0.547588468f, 0.703323185f},
std::array<float,2>{0.203061357f, 0.935878158f},
std::array<float,2>{0.871810436f, 0.493562132f},
std::array<float,2>{0.00471825385f, 0.356341898f},
std::array<float,2>{0.889850736f, 0.864227891f},
std::array<float,2>{0.4020316f, 0.595383525f},
std::array<float,2>{0.649532139f, 0.0358521193f},
std::array<float,2>{0.104716837f, 0.246976838f},
std::array<float,2>{0.973117054f, 0.657494962f},
std::array<float,2>{0.479632378f, 0.949457109f},
std::array<float,2>{0.725057781f, 0.405205905f},
std::array<float,2>{0.348877639f, 0.293627053f},
std::array<float,2>{0.619112015f, 0.810299277f},
std::array<float,2>{0.171828836f, 0.546634614f},
std::array<float,2>{0.793410659f, 0.0638236627f},
std::array<float,2>{0.433281273f, 0.0312224403f},
std::array<float,2>{0.67175281f, 0.593670249f},
std::array<float,2>{0.0445458665f, 0.830890238f},
std::array<float,2>{0.917311132f, 0.337408394f},
std::array<float,2>{0.219175383f, 0.463787943f},
std::array<float,2>{0.820631444f, 0.875791848f},
std::array<float,2>{0.276660264f, 0.720123708f},
std::array<float,2>{0.500051916f, 0.142042518f},
std::array<float,2>{0.163969442f, 0.191040903f},
std::array<float,2>{0.781605005f, 0.634984195f},
std::array<float,2>{0.352497488f, 0.987742066f},
std::array<float,2>{0.61431706f, 0.415941328f},
std::array<float,2>{0.47007674f, 0.26815635f},
std::array<float,2>{0.729498208f, 0.781047404f},
std::array<float,2>{0.0950195864f, 0.528959394f},
std::array<float,2>{0.979706883f, 0.10861218f},
std::array<float,2>{0.266117573f, 0.0418017656f},
std::array<float,2>{0.507892966f, 0.608751416f},
std::array<float,2>{0.232789218f, 0.872329295f},
std::array<float,2>{0.81843257f, 0.347355962f},
std::array<float,2>{0.0321102031f, 0.487555265f},
std::array<float,2>{0.911363602f, 0.92225343f},
std::array<float,2>{0.422585905f, 0.717272997f},
std::array<float,2>{0.663966656f, 0.175323114f},
std::array<float,2>{0.0819551349f, 0.0752581656f},
std::array<float,2>{0.944853485f, 0.531489253f},
std::array<float,2>{0.442602992f, 0.799138367f},
std::array<float,2>{0.714554846f, 0.28890729f},
std::array<float,2>{0.341982484f, 0.396514177f},
std::array<float,2>{0.569909096f, 0.944910586f},
std::array<float,2>{0.150368273f, 0.666194379f},
std::array<float,2>{0.773668826f, 0.234699816f},
std::array<float,2>{0.391582221f, 0.148562521f},
std::array<float,2>{0.64615041f, 0.734257579f},
std::array<float,2>{0.0155882277f, 0.888276041f},
std::array<float,2>{0.879601777f, 0.460627913f},
std::array<float,2>{0.190698192f, 0.335233063f},
std::array<float,2>{0.866943479f, 0.841790795f},
std::array<float,2>{0.294170231f, 0.579005241f},
std::array<float,2>{0.557784081f, 0.0213541854f},
std::array<float,2>{0.249969006f, 0.00946768466f},
std::array<float,2>{0.836778224f, 0.572706223f},
std::array<float,2>{0.25551492f, 0.822309375f},
std::array<float,2>{0.523260474f, 0.321938694f},
std::array<float,2>{0.418692976f, 0.444256783f},
std::array<float,2>{0.680966616f, 0.906169713f},
std::array<float,2>{0.057568375f, 0.748960495f},
std::array<float,2>{0.924788475f, 0.133510113f},
std::array<float,2>{0.359869033f, 0.219087347f},
std::array<float,2>{0.594097197f, 0.6795277f},
std::array<float,2>{0.178220659f, 0.958762407f},
std::array<float,2>{0.805414081f, 0.38029927f},
std::array<float,2>{0.110219747f, 0.304577798f},
std::array<float,2>{0.992420554f, 0.791173458f},
std::array<float,2>{0.498663157f, 0.55606544f},
std::array<float,2>{0.742374539f, 0.0904271975f},
std::array<float,2>{0.0293510575f, 0.164227352f},
std::array<float,2>{0.89802444f, 0.69144845f},
std::array<float,2>{0.382564932f, 0.909282267f},
std::array<float,2>{0.633490801f, 0.476493448f},
std::array<float,2>{0.296958894f, 0.370777518f},
std::array<float,2>{0.539842129f, 0.857786715f},
std::array<float,2>{0.208825722f, 0.611807466f},
std::array<float,2>{0.84378773f, 0.0516644903f},
std::array<float,2>{0.457277417f, 0.109446332f},
std::array<float,2>{0.701317847f, 0.502701998f},
std::array<float,2>{0.0733527243f, 0.759077787f},
std::array<float,2>{0.958658516f, 0.25601235f},
std::array<float,2>{0.138997287f, 0.43199876f},
std::array<float,2>{0.762116492f, 0.969229162f},
std::array<float,2>{0.323169559f, 0.643069625f},
std::array<float,2>{0.579143107f, 0.208512858f},
std::array<float,2>{0.227282792f, 0.230129838f},
std::array<float,2>{0.81519413f, 0.686977804f},
std::array<float,2>{0.271492064f, 0.963595688f},
std::array<float,2>{0.514293075f, 0.390410215f},
std::array<float,2>{0.428702891f, 0.310490549f},
std::array<float,2>{0.656977057f, 0.787491739f},
std::array<float,2>{0.0372378789f, 0.548179805f},
std::array<float,2>{0.909820318f, 0.0846540406f},
std::array<float,2>{0.356373698f, 0.00227184105f},
std::array<float,2>{0.612636089f, 0.565424383f},
std::array<float,2>{0.157477722f, 0.813498914f},
std::array<float,2>{0.787524223f, 0.314743549f},
std::array<float,2>{0.10100209f, 0.45110181f},
std::array<float,2>{0.983805239f, 0.895654619f},
std::array<float,2>{0.473163843f, 0.741072893f},
std::array<float,2>{0.732021451f, 0.130767465f},
std::array<float,2>{0.0086678518f, 0.124269098f},
std::array<float,2>{0.877228916f, 0.514674425f},
std::array<float,2>{0.396285415f, 0.75621891f},
std::array<float,2>{0.642987311f, 0.25927797f},
std::array<float,2>{0.290327847f, 0.421967536f},
std::array<float,2>{0.560771465f, 0.983720362f},
std::array<float,2>{0.191953778f, 0.650136769f},
std::array<float,2>{0.860005498f, 0.214943185f},
std::array<float,2>{0.438972861f, 0.158006743f},
std::array<float,2>{0.718245745f, 0.70009923f},
std::array<float,2>{0.0828330591f, 0.917851329f},
std::array<float,2>{0.939801574f, 0.483177185f},
std::array<float,2>{0.155412674f, 0.364797056f},
std::array<float,2>{0.778395712f, 0.850023687f},
std::array<float,2>{0.33842805f, 0.623331249f},
std::array<float,2>{0.564590216f, 0.060284555f},
std::array<float,2>{0.174606398f, 0.032709226f},
std::array<float,2>{0.809489846f, 0.600622892f},
std::array<float,2>{0.366522819f, 0.860723495f},
std::array<float,2>{0.60084945f, 0.353974611f},
std::array<float,2>{0.492445946f, 0.498363197f},
std::array<float,2>{0.748520732f, 0.931761146f},
std::array<float,2>{0.115663946f, 0.710848153f},
std::array<float,2>{0.999671996f, 0.185065985f},
std::array<float,2>{0.250991076f, 0.198547989f},
std::array<float,2>{0.517839432f, 0.631165385f},
std::array<float,2>{0.244394407f, 0.996289074f},
std::array<float,2>{0.84138006f, 0.408356339f},
std::array<float,2>{0.0615024753f, 0.28115052f},
std::array<float,2>{0.927512944f, 0.769509554f},
std::array<float,2>{0.41549176f, 0.518871367f},
std::array<float,2>{0.68490684f, 0.0974492878f},
std::array<float,2>{0.0755745098f, 0.148310795f},
std::array<float,2>{0.95648247f, 0.724328697f},
std::array<float,2>{0.455174625f, 0.88243258f},
std::array<float,2>{0.696893394f, 0.468736053f},
std::array<float,2>{0.325051934f, 0.340092719f},
std::array<float,2>{0.585715294f, 0.835475504f},
std::array<float,2>{0.134745806f, 0.587371588f},
std::array<float,2>{0.758252561f, 0.0268592611f},
std::array<float,2>{0.375640213f, 0.0668419823f},
std::array<float,2>{0.639349878f, 0.542163789f},
std::array<float,2>{0.0264918096f, 0.80593133f},
std::array<float,2>{0.892902732f, 0.29106015f},
std::array<float,2>{0.203490674f, 0.39894557f},
std::array<float,2>{0.850513518f, 0.948767066f},
std::array<float,2>{0.300826102f, 0.660656095f},
std::array<float,2>{0.546364784f, 0.242265955f},
std::array<float,2>{0.132423371f, 0.17652756f},
std::array<float,2>{0.754378319f, 0.711342096f},
std::array<float,2>{0.313738316f, 0.929380774f},
std::array<float,2>{0.592105389f, 0.489706486f},
std::array<float,2>{0.465017408f, 0.350403845f},
std::array<float,2>{0.689770579f, 0.870520413f},
std::array<float,2>{0.0625931025f, 0.604836404f},
std::array<float,2>{0.967872083f, 0.0445861183f},
std::array<float,2>{0.308099478f, 0.101574168f},
std::array<float,2>{0.534468532f, 0.525534391f},
std::array<float,2>{0.213647366f, 0.77523911f},
std::array<float,2>{0.855671704f, 0.271813035f},
std::array<float,2>{0.0198942497f, 0.419415265f},
std::array<float,2>{0.90051645f, 0.989984334f},
std::array<float,2>{0.388674885f, 0.638995767f},
std::array<float,2>{0.625423312f, 0.194420427f},
std::array<float,2>{0.119620919f, 0.0173708834f},
std::array<float,2>{0.985016167f, 0.58359319f},
std::array<float,2>{0.485684663f, 0.838303268f},
std::array<float,2>{0.73448658f, 0.329362273f},
std::array<float,2>{0.36939913f, 0.453368098f},
std::array<float,2>{0.603704154f, 0.885979056f},
std::array<float,2>{0.185670927f, 0.728527009f},
std::array<float,2>{0.80359441f, 0.15606834f},
std::array<float,2>{0.413513988f, 0.238527268f},
std::array<float,2>{0.674992144f, 0.671726108f},
std::array<float,2>{0.0536424182f, 0.938869596f},
std::array<float,2>{0.93652904f, 0.391710699f},
std::array<float,2>{0.239045158f, 0.282582015f},
std::array<float,2>{0.834202945f, 0.803661048f},
std::array<float,2>{0.259753227f, 0.53807056f},
std::array<float,2>{0.528081596f, 0.0711552501f},
std::array<float,2>{0.195904732f, 0.0861658379f},
std::array<float,2>{0.871076047f, 0.560091078f},
std::array<float,2>{0.286598027f, 0.794038773f},
std::array<float,2>{0.550804794f, 0.30011338f},
std::array<float,2>{0.404289305f, 0.378259033f},
std::array<float,2>{0.6536147f, 0.953536034f},
std::array<float,2>{0.00230224011f, 0.674809992f},
std::array<float,2>{0.885195851f, 0.22466585f},
std::array<float,2>{0.33539018f, 0.136923552f},
std::array<float,2>{0.578083158f, 0.743583381f},
std::array<float,2>{0.146430939f, 0.898711443f},
std::array<float,2>{0.769585311f, 0.440333098f},
std::array<float,2>{0.0923206657f, 0.325123727f},
std::array<float,2>{0.949942112f, 0.826093495f},
std::array<float,2>{0.452901214f, 0.577960372f},
std::array<float,2>{0.70457375f, 0.0123405904f},
std::array<float,2>{0.0399986655f, 0.206307888f},
std::array<float,2>{0.920602977f, 0.645563424f},
std::array<float,2>{0.436300188f, 0.973977506f},
std::array<float,2>{0.667457283f, 0.436095387f},
std::array<float,2>{0.277590185f, 0.251959741f},
std::array<float,2>{0.504866242f, 0.764802575f},
std::array<float,2>{0.225555077f, 0.50522691f},
std::array<float,2>{0.826042771f, 0.11341881f},
std::array<float,2>{0.481029928f, 0.0490734428f},
std::array<float,2>{0.722223818f, 0.613729239f},
std::array<float,2>{0.105831161f, 0.853827059f},
std::array<float,2>{0.970664978f, 0.372904778f},
std::array<float,2>{0.165442467f, 0.471341759f},
std::array<float,2>{0.789880812f, 0.911196053f},
std::array<float,2>{0.34574911f, 0.687893152f},
std::array<float,2>{0.6222381f, 0.170384347f},
std::array<float,2>{0.208066791f, 0.167335555f},
std::array<float,2>{0.844579458f, 0.695020735f},
std::array<float,2>{0.297831863f, 0.907745302f},
std::array<float,2>{0.539265573f, 0.472937971f},
std::array<float,2>{0.382055372f, 0.368403465f},
std::array<float,2>{0.632861793f, 0.856164336f},
std::array<float,2>{0.0302215684f, 0.609471917f},
std::array<float,2>{0.897577226f, 0.0542746671f},
std::array<float,2>{0.322652459f, 0.112312213f},
std::array<float,2>{0.579961419f, 0.501843512f},
std::array<float,2>{0.139315397f, 0.760173023f},
std::array<float,2>{0.762233496f, 0.25523448f},
std::array<float,2>{0.0738084614f, 0.430323482f},
std::array<float,2>{0.95832324f, 0.971948385f},
std::array<float,2>{0.457948834f, 0.642488122f},
std::array<float,2>{0.701873124f, 0.209288999f},
std::array<float,2>{0.0566573404f, 0.0103330296f},
std::array<float,2>{0.924170852f, 0.571179986f},
std::array<float,2>{0.418091893f, 0.820870757f},
std::array<float,2>{0.681586027f, 0.323088378f},
std::array<float,2>{0.255360931f, 0.44216904f},
std::array<float,2>{0.52250278f, 0.90254885f},
std::array<float,2>{0.249418899f, 0.747091055f},
std::array<float,2>{0.836313486f, 0.135940328f},
std::array<float,2>{0.498294353f, 0.222333372f},
std::array<float,2>{0.743009448f, 0.67768085f},
std::array<float,2>{0.109553434f, 0.960094631f},
std::array<float,2>{0.99315244f, 0.382055193f},
std::array<float,2>{0.178560778f, 0.301204383f},
std::array<float,2>{0.804943502f, 0.790052295f},
std::array<float,2>{0.3596614f, 0.557499349f},
std::array<float,2>{0.594325781f, 0.0926251933f},
std::array<float,2>{0.149681211f, 0.0780776218f},
std::array<float,2>{0.774222791f, 0.533270776f},
std::array<float,2>{0.342651159f, 0.798341095f},
std::array<float,2>{0.56955415f, 0.286108464f},
std::array<float,2>{0.443057001f, 0.395722628f},
std::array<float,2>{0.713962555f, 0.943171918f},
std::array<float,2>{0.0810735077f, 0.664151609f},
std::array<float,2>{0.944725394f, 0.237193257f},
std::array<float,2>{0.294522673f, 0.152269274f},
std::array<float,2>{0.558253706f, 0.731738508f},
std::array<float,2>{0.190958619f, 0.88896668f},
std::array<float,2>{0.866696715f, 0.457756251f},
std::array<float,2>{0.0147564039f, 0.332887113f},
std::array<float,2>{0.879143476f, 0.842885852f},
std::array<float,2>{0.390846103f, 0.581867933f},
std::array<float,2>{0.64594382f, 0.0214947145f},
std::array<float,2>{0.095630765f, 0.189104542f},
std::array<float,2>{0.980263829f, 0.633904636f},
std::array<float,2>{0.470292658f, 0.985649705f},
std::array<float,2>{0.730026305f, 0.417421073f},
std::array<float,2>{0.351856947f, 0.266172171f},
std::array<float,2>{0.61478126f, 0.778361142f},
std::array<float,2>{0.163455695f, 0.530886114f},
std::array<float,2>{0.782003343f, 0.105482899f},
std::array<float,2>{0.422056884f, 0.0399583057f},
std::array<float,2>{0.663479507f, 0.606997907f},
std::array<float,2>{0.0317327529f, 0.874248803f},
std::array<float,2>{0.911950231f, 0.34558636f},
std::array<float,2>{0.233382374f, 0.484411567f},
std::array<float,2>{0.819315493f, 0.924382925f},
std::array<float,2>{0.266013771f, 0.714888334f},
std::array<float,2>{0.508727551f, 0.173592106f},
std::array<float,2>{0.17125307f, 0.249114662f},
std::array<float,2>{0.793515503f, 0.660137832f},
std::array<float,2>{0.349585354f, 0.95245111f},
std::array<float,2>{0.618595481f, 0.403907061f},
std::array<float,2>{0.480085999f, 0.295262367f},
std::array<float,2>{0.725272775f, 0.812000573f},
std::array<float,2>{0.105085813f, 0.543130338f},
std::array<float,2>{0.973156929f, 0.0650124177f},
std::array<float,2>{0.277248591f, 0.0289680846f},
std::array<float,2>{0.50073576f, 0.591192901f},
std::array<float,2>{0.219490275f, 0.829987645f},
std::array<float,2>{0.820834458f, 0.338308811f},
std::array<float,2>{0.0441061631f, 0.462078959f},
std::array<float,2>{0.917692542f, 0.878539085f},
std::array<float,2>{0.432782322f, 0.720923305f},
std::array<float,2>{0.671182454f, 0.144344717f},
std::array<float,2>{0.0881268159f, 0.0976705998f},
std::array<float,2>{0.946576238f, 0.5234254f},
std::array<float,2>{0.445949763f, 0.77342546f},
std::array<float,2>{0.708445787f, 0.273875535f},
std::array<float,2>{0.331218332f, 0.410958856f},
std::array<float,2>{0.572732866f, 0.995223522f},
std::array<float,2>{0.142637327f, 0.625541866f},
std::array<float,2>{0.768582523f, 0.201175004f},
std::array<float,2>{0.401823282f, 0.180486739f},
std::array<float,2>{0.650378346f, 0.706900299f},
std::array<float,2>{0.00428289268f, 0.934407711f},
std::array<float,2>{0.890340865f, 0.494759917f},
std::array<float,2>{0.20241797f, 0.35877198f},
std::array<float,2>{0.871500194f, 0.865301251f},
std::array<float,2>{0.283759415f, 0.596672297f},
std::array<float,2>{0.546898961f, 0.0371980891f},
std::array<float,2>{0.236051947f, 0.0554149039f},
std::array<float,2>{0.830047309f, 0.618573189f},
std::array<float,2>{0.262013376f, 0.846037924f},
std::array<float,2>{0.525011539f, 0.360328674f},
std::array<float,2>{0.407137752f, 0.479027867f},
std::array<float,2>{0.678913832f, 0.921156406f},
std::array<float,2>{0.0484986417f, 0.696384192f},
std::array<float,2>{0.931457222f, 0.162269101f},
std::array<float,2>{0.372629642f, 0.213133961f},
std::array<float,2>{0.607719243f, 0.656031489f},
std::array<float,2>{0.18322131f, 0.97797507f},
std::array<float,2>{0.797157109f, 0.428783774f},
std::array<float,2>{0.124794289f, 0.265127063f},
std::array<float,2>{0.98838228f, 0.752449393f},
std::array<float,2>{0.489640832f, 0.510891855f},
std::array<float,2>{0.740089238f, 0.118509851f},
std::array<float,2>{0.0162583515f, 0.125129193f},
std::array<float,2>{0.904828131f, 0.736180246f},
std::array<float,2>{0.383018613f, 0.89081198f},
std::array<float,2>{0.631572247f, 0.447140157f},
std::array<float,2>{0.309246242f, 0.318144947f},
std::array<float,2>{0.538096964f, 0.817946374f},
std::array<float,2>{0.215292752f, 0.569732189f},
std::array<float,2>{0.851775885f, 0.00527010951f},
std::array<float,2>{0.464003116f, 0.0804886967f},
std::array<float,2>{0.694305599f, 0.551380038f},
std::array<float,2>{0.0673497021f, 0.781762779f},
std::array<float,2>{0.964638233f, 0.306775749f},
std::array<float,2>{0.125875667f, 0.38499561f},
std::array<float,2>{0.753625572f, 0.96697098f},
std::array<float,2>{0.317057371f, 0.681414545f},
std::array<float,2>{0.587769449f, 0.23188059f},
std::array<float,2>{0.225076899f, 0.203398556f},
std::array<float,2>{0.825215459f, 0.64657706f},
std::array<float,2>{0.278083056f, 0.974740684f},
std::array<float,2>{0.504374206f, 0.434787005f},
std::array<float,2>{0.435627759f, 0.250405639f},
std::array<float,2>{0.667925775f, 0.762565076f},
std::array<float,2>{0.0392199717f, 0.506024539f},
std::array<float,2>{0.920175552f, 0.115763366f},
std::array<float,2>{0.346277177f, 0.0472518429f},
std::array<float,2>{0.622751594f, 0.615759671f},
std::array<float,2>{0.1657556f, 0.852738738f},
std::array<float,2>{0.789344966f, 0.374658257f},
std::array<float,2>{0.106018633f, 0.469338566f},
std::array<float,2>{0.969837129f, 0.912447572f},
std::array<float,2>{0.480697215f, 0.689729929f},
std::array<float,2>{0.721984267f, 0.16922684f},
std::array<float,2>{0.00256365491f, 0.0880002528f},
std::array<float,2>{0.885453939f, 0.561406255f},
std::array<float,2>{0.403692126f, 0.795509756f},
std::array<float,2>{0.654084206f, 0.296961337f},
std::array<float,2>{0.286671996f, 0.375637054f},
std::array<float,2>{0.551667213f, 0.956309855f},
std::array<float,2>{0.195489988f, 0.673398077f},
std::array<float,2>{0.870353878f, 0.222687528f},
std::array<float,2>{0.452371716f, 0.139961347f},
std::array<float,2>{0.704710364f, 0.744588792f},
std::array<float,2>{0.0918064788f, 0.902331412f},
std::array<float,2>{0.949576914f, 0.43787697f},
std::array<float,2>{0.145520121f, 0.327690393f},
std::array<float,2>{0.770488083f, 0.82690835f},
std::array<float,2>{0.335780323f, 0.574943542f},
std::array<float,2>{0.577593982f, 0.0148898698f},
std::array<float,2>{0.186293364f, 0.0191455223f},
std::array<float,2>{0.802987754f, 0.584117472f},
std::array<float,2>{0.369916588f, 0.836456895f},
std::array<float,2>{0.604062915f, 0.330817431f},
std::array<float,2>{0.486137599f, 0.456756592f},
std::array<float,2>{0.735221028f, 0.8830145f},
std::array<float,2>{0.11982052f, 0.727707446f},
std::array<float,2>{0.984609425f, 0.154195517f},
std::array<float,2>{0.258826613f, 0.241557345f},
std::array<float,2>{0.52742511f, 0.669137001f},
std::array<float,2>{0.238421619f, 0.940698147f},
std::array<float,2>{0.834739029f, 0.393113613f},
std::array<float,2>{0.0530078933f, 0.283219278f},
std::array<float,2>{0.937096953f, 0.80252552f},
std::array<float,2>{0.41388014f, 0.536923885f},
std::array<float,2>{0.675298452f, 0.0741475597f},
std::array<float,2>{0.0634034798f, 0.177838832f},
std::array<float,2>{0.968571544f, 0.71366626f},
std::array<float,2>{0.465479612f, 0.926844358f},
std::array<float,2>{0.689978778f, 0.490904033f},
std::array<float,2>{0.314085007f, 0.348695159f},
std::array<float,2>{0.592663109f, 0.869043946f},
std::array<float,2>{0.132140547f, 0.601570129f},
std::array<float,2>{0.754461884f, 0.0453508049f},
std::array<float,2>{0.389301836f, 0.104279861f},
std::array<float,2>{0.625976145f, 0.525102973f},
std::array<float,2>{0.0201169979f, 0.776995003f},
std::array<float,2>{0.901247919f, 0.2695508f},
std::array<float,2>{0.213232517f, 0.421768844f},
std::array<float,2>{0.855957747f, 0.990816295f},
std::array<float,2>{0.308523655f, 0.638170123f},
std::array<float,2>{0.534755051f, 0.192683324f},
std::array<float,2>{0.133893147f, 0.144718513f},
std::array<float,2>{0.758733213f, 0.724916637f},
std::array<float,2>{0.324306309f, 0.879934967f},
std::array<float,2>{0.585180342f, 0.466564685f},
std::array<float,2>{0.455700904f, 0.342458963f},
std::array<float,2>{0.696580112f, 0.833527863f},
std::array<float,2>{0.0757533237f, 0.58851254f},
std::array<float,2>{0.957006931f, 0.0234657414f},
std::array<float,2>{0.301451296f, 0.0700886697f},
std::array<float,2>{0.546817958f, 0.540369749f},
std::array<float,2>{0.203743055f, 0.807565928f},
std::array<float,2>{0.850046039f, 0.289428383f},
std::array<float,2>{0.0269764327f, 0.400553226f},
std::array<float,2>{0.893521249f, 0.946909487f},
std::array<float,2>{0.37512365f, 0.663101614f},
std::array<float,2>{0.638690829f, 0.245481938f},
std::array<float,2>{0.11611703f, 0.0349383764f},
std::array<float,2>{0.99920398f, 0.599491894f},
std::array<float,2>{0.492703944f, 0.862505496f},
std::array<float,2>{0.74892056f, 0.351738811f},
std::array<float,2>{0.366787761f, 0.496627688f},
std::array<float,2>{0.601177216f, 0.930551469f},
std::array<float,2>{0.17421858f, 0.707752347f},
std::array<float,2>{0.808901131f, 0.186592892f},
std::array<float,2>{0.415908664f, 0.195362285f},
std::array<float,2>{0.685434759f, 0.630456209f},
std::array<float,2>{0.0606826246f, 0.998272419f},
std::array<float,2>{0.927229285f, 0.406534791f},
std::array<float,2>{0.244808555f, 0.27769506f},
std::array<float,2>{0.841210723f, 0.766945362f},
std::array<float,2>{0.251568824f, 0.515859187f},
std::array<float,2>{0.518145502f, 0.095485732f},
std::array<float,2>{0.191850454f, 0.121133529f},
std::array<float,2>{0.859646916f, 0.512766302f},
std::array<float,2>{0.290880978f, 0.75443846f},
std::array<float,2>{0.561069787f, 0.26041463f},
std::array<float,2>{0.395868808f, 0.424482197f},
std::array<float,2>{0.643269658f, 0.981494546f},
std::array<float,2>{0.00818384346f, 0.651129186f},
std::array<float,2>{0.87781471f, 0.217394307f},
std::array<float,2>{0.33800894f, 0.159987405f},
std::array<float,2>{0.565095246f, 0.702589989f},
std::array<float,2>{0.155811772f, 0.914239705f},
std::array<float,2>{0.77929157f, 0.481021494f},
std::array<float,2>{0.0821364373f, 0.367011487f},
std::array<float,2>{0.940219939f, 0.848762631f},
std::array<float,2>{0.438828588f, 0.623046398f},
std::array<float,2>{0.718739867f, 0.0607017837f},
std::array<float,2>{0.0376387537f, 0.227645189f},
std::array<float,2>{0.909314275f, 0.685132205f},
std::array<float,2>{0.428025931f, 0.961726248f},
std::array<float,2>{0.656430185f, 0.386899233f},
std::array<float,2>{0.272106826f, 0.31197992f},
std::array<float,2>{0.514025629f, 0.785563231f},
std::array<float,2>{0.227005392f, 0.54954809f},
std::array<float,2>{0.814465642f, 0.0822193101f},
std::array<float,2>{0.472923994f, 0.00151423144f},
std::array<float,2>{0.73189795f, 0.563091636f},
std::array<float,2>{0.101537317f, 0.814549387f},
std::array<float,2>{0.984184682f, 0.314201295f},
std::array<float,2>{0.157898173f, 0.451711684f},
std::array<float,2>{0.788075805f, 0.897051811f},
std::array<float,2>{0.355882794f, 0.738734901f},
std::array<float,2>{0.613097906f, 0.132437676f},
std::array<float,2>{0.246240944f, 0.133012071f},
std::array<float,2>{0.838725507f, 0.748461604f},
std::array<float,2>{0.256196141f, 0.905752122f},
std::array<float,2>{0.519749105f, 0.44339937f},
std::array<float,2>{0.420179456f, 0.321479231f},
std::array<float,2>{0.683221042f, 0.822774291f},
std::array<float,2>{0.0556498542f, 0.572892606f},
std::array<float,2>{0.923284054f, 0.00915807392f},
std::array<float,2>{0.362942845f, 0.0901195258f},
std::array<float,2>{0.596857905f, 0.55649966f},
std::array<float,2>{0.176206201f, 0.791596591f},
std::array<float,2>{0.808561265f, 0.304197341f},
std::array<float,2>{0.111502916f, 0.380685687f},
std::array<float,2>{0.994350731f, 0.958347797f},
std::array<float,2>{0.496632725f, 0.679051161f},
std::array<float,2>{0.745758951f, 0.219445854f},
std::array<float,2>{0.0274896305f, 0.0508525483f},
std::array<float,2>{0.895852685f, 0.612074554f},
std::array<float,2>{0.380101651f, 0.858102977f},
std::array<float,2>{0.635850847f, 0.370563269f},
std::array<float,2>{0.300541639f, 0.475649834f},
std::array<float,2>{0.541028798f, 0.910008907f},
std::array<float,2>{0.210259587f, 0.69207114f},
std::array<float,2>{0.847014844f, 0.164815351f},
std::array<float,2>{0.46002996f, 0.208180815f},
std::array<float,2>{0.700264633f, 0.642796695f},
std::array<float,2>{0.0715750307f, 0.969646752f},
std::array<float,2>{0.959687889f, 0.432484806f},
std::array<float,2>{0.137320176f, 0.256479949f},
std::array<float,2>{0.76381284f, 0.759442508f},
std::array<float,2>{0.322071135f, 0.502057612f},
std::array<float,2>{0.58134079f, 0.110108696f},
std::array<float,2>{0.161315873f, 0.10900075f},
std::array<float,2>{0.785020947f, 0.528534412f},
std::array<float,2>{0.355051219f, 0.780734599f},
std::array<float,2>{0.616495967f, 0.26782155f},
std::array<float,2>{0.470985472f, 0.4152022f},
std::array<float,2>{0.727337122f, 0.988064051f},
std::array<float,2>{0.0963269547f, 0.635677814f},
std::array<float,2>{0.977409959f, 0.190661952f},
std::array<float,2>{0.269328862f, 0.175000057f},
std::array<float,2>{0.511217475f, 0.717568338f},
std::array<float,2>{0.231473774f, 0.922750056f},
std::array<float,2>{0.81784606f, 0.488219321f},
std::array<float,2>{0.0337650105f, 0.346738905f},
std::array<float,2>{0.912597358f, 0.872977018f},
std::array<float,2>{0.42402187f, 0.609078765f},
std::array<float,2>{0.660178483f, 0.0413689874f},
std::array<float,2>{0.0784350783f, 0.235244125f},
std::array<float,2>{0.942835629f, 0.666887701f},
std::array<float,2>{0.445057124f, 0.9445346f},
std::array<float,2>{0.711552978f, 0.396979243f},
std::array<float,2>{0.340522826f, 0.288086325f},
std::array<float,2>{0.566834986f, 0.799411535f},
std::array<float,2>{0.150975555f, 0.531923652f},
std::array<float,2>{0.777270854f, 0.0758012682f},
std::array<float,2>{0.393442214f, 0.0206868853f},
std::array<float,2>{0.647453249f, 0.578468323f},
std::array<float,2>{0.0126769738f, 0.841251493f},
std::array<float,2>{0.881660223f, 0.335907012f},
std::array<float,2>{0.188573986f, 0.460077047f},
std::array<float,2>{0.864465535f, 0.88797462f},
std::array<float,2>{0.296699464f, 0.733718216f},
std::array<float,2>{0.556016505f, 0.149390817f},
std::array<float,2>{0.141644761f, 0.199518904f},
std::array<float,2>{0.766680002f, 0.628246844f},
std::array<float,2>{0.328192592f, 0.992576599f},
std::array<float,2>{0.571430326f, 0.412591726f},
std::array<float,2>{0.448057324f, 0.27619493f},
std::array<float,2>{0.710374355f, 0.770012021f},
std::array<float,2>{0.0865746513f, 0.521159708f},
std::array<float,2>{0.948459089f, 0.101535484f},
std::array<float,2>{0.281802952f, 0.0354565643f},
std::array<float,2>{0.550306737f, 0.594784498f},
std::array<float,2>{0.20046398f, 0.863752127f},
std::array<float,2>{0.873696268f, 0.355660498f},
std::array<float,2>{0.00700144237f, 0.493693173f},
std::array<float,2>{0.8880198f, 0.936504185f},
std::array<float,2>{0.398784518f, 0.703732193f},
std::array<float,2>{0.650902748f, 0.182845175f},
std::array<float,2>{0.101671189f, 0.0641110465f},
std::array<float,2>{0.975797355f, 0.546007097f},
std::array<float,2>{0.478487223f, 0.809767187f},
std::array<float,2>{0.723686457f, 0.292969257f},
std::array<float,2>{0.350589842f, 0.404556155f},
std::array<float,2>{0.619499743f, 0.950005889f},
std::array<float,2>{0.16804263f, 0.657776356f},
std::array<float,2>{0.795620859f, 0.246369481f},
std::array<float,2>{0.430710256f, 0.142155185f},
std::array<float,2>{0.669021547f, 0.720466375f},
std::array<float,2>{0.0451536961f, 0.875374317f},
std::array<float,2>{0.914093256f, 0.463247478f},
std::array<float,2>{0.221474886f, 0.337307692f},
std::array<float,2>{0.82418704f, 0.830385447f},
std::array<float,2>{0.273587167f, 0.593094647f},
std::array<float,2>{0.503349125f, 0.0304812547f},
std::array<float,2>{0.218674034f, 0.00730822794f},
std::array<float,2>{0.855055988f, 0.566984951f},
std::array<float,2>{0.311655819f, 0.818582892f},
std::array<float,2>{0.537024915f, 0.318930417f},
std::array<float,2>{0.386127383f, 0.447868198f},
std::array<float,2>{0.629831135f, 0.893122852f},
std::array<float,2>{0.0191905685f, 0.73659569f},
std::array<float,2>{0.904207706f, 0.128155798f},
std::array<float,2>{0.318889081f, 0.233385012f},
std::array<float,2>{0.588642478f, 0.681949914f},
std::array<float,2>{0.128079414f, 0.965016723f},
std::array<float,2>{0.750916183f, 0.3835302f},
std::array<float,2>{0.0684592053f, 0.30530408f},
std::array<float,2>{0.96206975f, 0.784652114f},
std::array<float,2>{0.461349964f, 0.553302944f},
std::array<float,2>{0.692952394f, 0.079286322f},
std::array<float,2>{0.0490128286f, 0.160955712f},
std::array<float,2>{0.933444381f, 0.69755882f},
std::array<float,2>{0.408949435f, 0.919457257f},
std::array<float,2>{0.676370502f, 0.476588011f},
std::array<float,2>{0.263927639f, 0.36277318f},
std::array<float,2>{0.526504278f, 0.844917536f},
std::array<float,2>{0.237601519f, 0.621032298f},
std::array<float,2>{0.831917942f, 0.0577564538f},
std::array<float,2>{0.491335839f, 0.119851775f},
std::array<float,2>{0.741557717f, 0.508778632f},
std::array<float,2>{0.12158867f, 0.750667334f},
std::array<float,2>{0.990638494f, 0.263618022f},
std::array<float,2>{0.181613177f, 0.427057296f},
std::array<float,2>{0.79957813f, 0.979875743f},
std::array<float,2>{0.374571264f, 0.653318286f},
std::array<float,2>{0.606526077f, 0.212605447f},
std::array<float,2>{0.19898735f, 0.225303411f},
std::array<float,2>{0.869022787f, 0.675441802f},
std::array<float,2>{0.287275493f, 0.953925788f},
std::array<float,2>{0.553438485f, 0.378741115f},
std::array<float,2>{0.406041771f, 0.300424933f},
std::array<float,2>{0.65473789f, 0.794640481f},
std::array<float,2>{0.001375227f, 0.559696317f},
std::array<float,2>{0.884636402f, 0.0864562765f},
std::array<float,2>{0.332742333f, 0.0119004808f},
std::array<float,2>{0.574772f, 0.577378631f},
std::array<float,2>{0.146669403f, 0.825656414f},
std::array<float,2>{0.772163212f, 0.324279279f},
std::array<float,2>{0.0908168256f, 0.439867914f},
std::array<float,2>{0.95310837f, 0.899373055f},
std::array<float,2>{0.450629145f, 0.743867338f},
std::array<float,2>{0.706964731f, 0.137524083f},
std::array<float,2>{0.0417732f, 0.114153095f},
std::array<float,2>{0.919367075f, 0.505653024f},
std::array<float,2>{0.433628887f, 0.765482485f},
std::array<float,2>{0.665684164f, 0.252482653f},
std::array<float,2>{0.281212032f, 0.435641736f},
std::array<float,2>{0.507519603f, 0.974221587f},
std::array<float,2>{0.22456038f, 0.646297336f},
std::array<float,2>{0.827235162f, 0.206604794f},
std::array<float,2>{0.483029187f, 0.170584634f},
std::array<float,2>{0.720540345f, 0.688417196f},
std::array<float,2>{0.108692966f, 0.912067413f},
std::array<float,2>{0.970916808f, 0.471057594f},
std::array<float,2>{0.166212305f, 0.372157961f},
std::array<float,2>{0.792208016f, 0.854023457f},
std::array<float,2>{0.34545067f, 0.613985717f},
std::array<float,2>{0.623897135f, 0.0495299064f},
std::array<float,2>{0.130488768f, 0.0440083109f},
std::array<float,2>{0.756479204f, 0.605278492f},
std::array<float,2>{0.315152168f, 0.870748997f},
std::array<float,2>{0.591112614f, 0.349827856f},
std::array<float,2>{0.466822445f, 0.489894181f},
std::array<float,2>{0.68816781f, 0.929159164f},
std::array<float,2>{0.0648405701f, 0.711569309f},
std::array<float,2>{0.965317786f, 0.176082149f},
std::array<float,2>{0.305945456f, 0.195207238f},
std::array<float,2>{0.532087505f, 0.639275253f},
std::array<float,2>{0.212742805f, 0.989537895f},
std::array<float,2>{0.859272361f, 0.419773787f},
std::array<float,2>{0.0233252011f, 0.272189409f},
std::array<float,2>{0.899111509f, 0.774521947f},
std::array<float,2>{0.388372928f, 0.525880992f},
std::array<float,2>{0.628745496f, 0.102473944f},
std::array<float,2>{0.117740735f, 0.155326575f},
std::array<float,2>{0.98658663f, 0.729409873f},
std::array<float,2>{0.487957925f, 0.886432111f},
std::array<float,2>{0.738052309f, 0.453870445f},
std::array<float,2>{0.367964745f, 0.329774618f},
std::array<float,2>{0.601772785f, 0.838538766f},
std::array<float,2>{0.18489489f, 0.583474517f},
std::array<float,2>{0.802376568f, 0.0166734736f},
std::array<float,2>{0.410567939f, 0.0707026795f},
std::array<float,2>{0.672442198f, 0.537376165f},
std::array<float,2>{0.0527319759f, 0.802886784f},
std::array<float,2>{0.93436563f, 0.282862395f},
std::array<float,2>{0.241381347f, 0.392178357f},
std::array<float,2>{0.832352638f, 0.939170837f},
std::array<float,2>{0.260086209f, 0.671018779f},
std::array<float,2>{0.529740334f, 0.238930553f},
std::array<float,2>{0.172454864f, 0.185009047f},
std::array<float,2>{0.811635494f, 0.710265458f},
std::array<float,2>{0.36362654f, 0.932477772f},
std::array<float,2>{0.598479807f, 0.498739898f},
std::array<float,2>{0.495076329f, 0.35439688f},
std::array<float,2>{0.746909738f, 0.861070096f},
std::array<float,2>{0.115000442f, 0.601211667f},
std::array<float,2>{0.997952878f, 0.0330973417f},
std::array<float,2>{0.252726942f, 0.0967444554f},
std::array<float,2>{0.516991794f, 0.519422829f},
std::array<float,2>{0.242265597f, 0.768778205f},
std::array<float,2>{0.842249393f, 0.280282974f},
std::array<float,2>{0.059523996f, 0.408844054f},
std::array<float,2>{0.929334939f, 0.996617198f},
std::array<float,2>{0.417419791f, 0.631507099f},
std::array<float,2>{0.68663615f, 0.198970214f},
std::array<float,2>{0.0768609196f, 0.0264319386f},
std::array<float,2>{0.95460093f, 0.587873161f},
std::array<float,2>{0.453801274f, 0.834985733f},
std::array<float,2>{0.699041188f, 0.340436757f},
std::array<float,2>{0.328107566f, 0.468100786f},
std::array<float,2>{0.582057595f, 0.882004559f},
std::array<float,2>{0.135654569f, 0.723651767f},
std::array<float,2>{0.760021508f, 0.147470474f},
std::array<float,2>{0.377675474f, 0.242985293f},
std::array<float,2>{0.637008905f, 0.660189331f},
std::array<float,2>{0.0248589665f, 0.94856149f},
std::array<float,2>{0.891874015f, 0.398513436f},
std::array<float,2>{0.206942305f, 0.291649312f},
std::array<float,2>{0.8481493f, 0.80647409f},
std::array<float,2>{0.304384291f, 0.542554557f},
std::array<float,2>{0.543147027f, 0.0673397183f},
std::array<float,2>{0.229257002f, 0.0844058171f},
std::array<float,2>{0.814119458f, 0.54839164f},
std::array<float,2>{0.270151675f, 0.788011372f},
std::array<float,2>{0.511778474f, 0.309904665f},
std::array<float,2>{0.426930815f, 0.390113354f},
std::array<float,2>{0.65860641f, 0.96333015f},
std::array<float,2>{0.0356316604f, 0.687148452f},
std::array<float,2>{0.907544732f, 0.229975209f},
std::array<float,2>{0.359271795f, 0.130015731f},
std::array<float,2>{0.609573185f, 0.740307093f},
std::array<float,2>{0.158295527f, 0.896180332f},
std::array<float,2>{0.786461949f, 0.450358659f},
std::array<float,2>{0.0990204215f, 0.315376639f},
std::array<float,2>{0.980621755f, 0.814211905f},
std::array<float,2>{0.475770086f, 0.564800501f},
std::array<float,2>{0.73272121f, 0.00251191249f},
std::array<float,2>{0.0104963742f, 0.215536758f},
std::array<float,2>{0.876176238f, 0.649859488f},
std::array<float,2>{0.39687705f, 0.984197319f},
std::array<float,2>{0.642149329f, 0.422425568f},
std::array<float,2>{0.292734653f, 0.259191453f},
std::array<float,2>{0.559008181f, 0.756729126f},
std::array<float,2>{0.194864541f, 0.515210688f},
std::array<float,2>{0.862487197f, 0.124657869f},
std::array<float,2>{0.44109723f, 0.0600132793f},
std::array<float,2>{0.715865552f, 0.623750687f},
std::array<float,2>{0.0844815299f, 0.850253046f},
std::array<float,2>{0.938047171f, 0.364632577f},
std::array<float,2>{0.152827993f, 0.482893884f},
std::array<float,2>{0.780460596f, 0.917106628f},
std::array<float,2>{0.337713838f, 0.699492216f},
std::array<float,2>{0.564237654f, 0.157482401f},
std::array<float,2>{0.23070924f, 0.172441483f},
std::array<float,2>{0.817259908f, 0.71671772f},
std::array<float,2>{0.267818123f, 0.92496103f},
std::array<float,2>{0.510124207f, 0.485408694f},
std::array<float,2>{0.425159812f, 0.344015539f},
std::array<float,2>{0.662080646f, 0.873233318f},
std::array<float,2>{0.0342034474f, 0.606325388f},
std::array<float,2>{0.913933218f, 0.0406985208f},
std::array<float,2>{0.353905141f, 0.106669046f},
std::array<float,2>{0.615270495f, 0.529683053f},
std::array<float,2>{0.160510376f, 0.777750611f},
std::array<float,2>{0.78342104f, 0.266805798f},
std::array<float,2>{0.0975214466f, 0.41614759f},
std::array<float,2>{0.977594316f, 0.985119581f},
std::array<float,2>{0.471991718f, 0.633136511f},
std::array<float,2>{0.728262842f, 0.188129619f},
std::array<float,2>{0.0136195086f, 0.0228396356f},
std::array<float,2>{0.882121444f, 0.580286324f},
std::array<float,2>{0.394171745f, 0.841890454f},
std::array<float,2>{0.64747566f, 0.333793163f},
std::array<float,2>{0.295783937f, 0.458886802f},
std::array<float,2>{0.555624723f, 0.890469611f},
std::array<float,2>{0.187720999f, 0.730584204f},
std::array<float,2>{0.864214361f, 0.150749609f},
std::array<float,2>{0.444056243f, 0.238095075f},
std::array<float,2>{0.712176561f, 0.665841579f},
std::array<float,2>{0.0796116441f, 0.941637099f},
std::array<float,2>{0.941497147f, 0.395351738f},
std::array<float,2>{0.151453912f, 0.286399305f},
std::array<float,2>{0.775903642f, 0.797239423f},
std::array<float,2>{0.341617614f, 0.535154939f},
std::array<float,2>{0.567529559f, 0.076662764f},
std::array<float,2>{0.177278444f, 0.0929406509f},
std::array<float,2>{0.807196617f, 0.558057427f},
std::array<float,2>{0.361668169f, 0.789397538f},
std::array<float,2>{0.596366405f, 0.302512825f},
std::array<float,2>{0.49716869f, 0.381456703f},
std::array<float,2>{0.745025218f, 0.959629834f},
std::array<float,2>{0.113087244f, 0.675848186f},
std::array<float,2>{0.995224476f, 0.221103206f},
std::array<float,2>{0.257690996f, 0.135276675f},
std::array<float,2>{0.520547807f, 0.746308148f},
std::array<float,2>{0.247889638f, 0.903755724f},
std::array<float,2>{0.839087188f, 0.442973018f},
std::array<float,2>{0.0565591343f, 0.323771477f},
std::array<float,2>{0.922211051f, 0.821521044f},
std::array<float,2>{0.421756953f, 0.571350932f},
std::array<float,2>{0.681895792f, 0.0110178553f},
std::array<float,2>{0.0703209043f, 0.210607886f},
std::array<float,2>{0.960683584f, 0.6409477f},
std::array<float,2>{0.459876388f, 0.971516967f},
std::array<float,2>{0.699827492f, 0.431164294f},
std::array<float,2>{0.320314616f, 0.254121244f},
std::array<float,2>{0.58053416f, 0.761037767f},
std::array<float,2>{0.137953505f, 0.500362754f},
std::array<float,2>{0.765101671f, 0.11182531f},
std::array<float,2>{0.379549474f, 0.0536063612f},
std::array<float,2>{0.635217309f, 0.611290932f},
std::array<float,2>{0.0292209927f, 0.856559694f},
std::array<float,2>{0.894841552f, 0.368120193f},
std::array<float,2>{0.209477529f, 0.474563777f},
std::array<float,2>{0.845909655f, 0.906253397f},
std::array<float,2>{0.299382716f, 0.693364501f},
std::array<float,2>{0.542573988f, 0.166708872f},
std::array<float,2>{0.127506539f, 0.23069869f},
std::array<float,2>{0.751794279f, 0.679865539f},
std::array<float,2>{0.320027471f, 0.967956364f},
std::array<float,2>{0.589785337f, 0.385995656f},
std::array<float,2>{0.462524325f, 0.307769269f},
std::array<float,2>{0.691853762f, 0.782723904f},
std::array<float,2>{0.0695203319f, 0.552680194f},
std::array<float,2>{0.961459637f, 0.0816821903f},
std::array<float,2>{0.311161458f, 0.00391220627f},
std::array<float,2>{0.535176635f, 0.568421125f},
std::array<float,2>{0.217329293f, 0.816499591f},
std::array<float,2>{0.854020298f, 0.316938549f},
std::array<float,2>{0.0180516038f, 0.445774078f},
std::array<float,2>{0.903196633f, 0.892188132f},
std::array<float,2>{0.385285527f, 0.734781206f},
std::array<float,2>{0.630230069f, 0.126814038f},
std::array<float,2>{0.122556761f, 0.117563479f},
std::array<float,2>{0.99126476f, 0.510483027f},
std::array<float,2>{0.490323126f, 0.753890395f},
std::array<float,2>{0.740949214f, 0.263835818f},
std::array<float,2>{0.37389946f, 0.427918315f},
std::array<float,2>{0.60622865f, 0.977117777f},
std::array<float,2>{0.180437535f, 0.654327273f},
std::array<float,2>{0.800117373f, 0.21446839f},
std::array<float,2>{0.409902126f, 0.164012522f},
std::array<float,2>{0.67693311f, 0.695819616f},
std::array<float,2>{0.0503646247f, 0.920613587f},
std::array<float,2>{0.931910396f, 0.480122834f},
std::array<float,2>{0.236655354f, 0.360687017f},
std::array<float,2>{0.830562651f, 0.847310781f},
std::array<float,2>{0.265199304f, 0.61721611f},
std::array<float,2>{0.525614858f, 0.0563854948f},
std::array<float,2>{0.199823543f, 0.0385135077f},
std::array<float,2>{0.874313951f, 0.597407699f},
std::array<float,2>{0.282880574f, 0.866771579f},
std::array<float,2>{0.549690187f, 0.357462585f},
std::array<float,2>{0.40023452f, 0.495200574f},
std::array<float,2>{0.651854575f, 0.934783101f},
std::array<float,2>{0.00651949644f, 0.705466926f},
std::array<float,2>{0.887393057f, 0.1812343f},
std::array<float,2>{0.32975024f, 0.202172816f},
std::array<float,2>{0.570565462f, 0.626581669f},
std::array<float,2>{0.140699819f, 0.994143248f},
std::array<float,2>{0.766307056f, 0.411606491f},
std::array<float,2>{0.0876832157f, 0.275079548f},
std::array<float,2>{0.947369397f, 0.771804035f},
std::array<float,2>{0.448292524f, 0.521755993f},
std::array<float,2>{0.709467828f, 0.0986783281f},
std::array<float,2>{0.0460984558f, 0.143505841f},
std::array<float,2>{0.915849864f, 0.721841156f},
std::array<float,2>{0.429793328f, 0.877323091f},
std::array<float,2>{0.668497264f, 0.461636901f},
std::array<float,2>{0.275278926f, 0.339660257f},
std::array<float,2>{0.502673209f, 0.828814924f},
std::array<float,2>{0.222002208f, 0.590458333f},
std::array<float,2>{0.822817028f, 0.0274030659f},
std::array<float,2>{0.477232009f, 0.0661282167f},
std::array<float,2>{0.723543763f, 0.544716537f},
std::array<float,2>{0.102598324f, 0.811297417f},
std::array<float,2>{0.975427866f, 0.296323925f},
std::array<float,2>{0.169358358f, 0.402471006f},
std::array<float,2>{0.796849906f, 0.951512396f},
std::array<float,2>{0.35045293f, 0.658483267f},
std::array<float,2>{0.620807111f, 0.248802334f},
std::array<float,2>{0.211158082f, 0.191440612f},
std::array<float,2>{0.857662618f, 0.637537599f},
std::array<float,2>{0.305144399f, 0.992098451f},
std::array<float,2>{0.532598674f, 0.420466423f},
std::array<float,2>{0.387456208f, 0.271359086f},
std::array<float,2>{0.627460301f, 0.776314437f},
std::array<float,2>{0.022416098f, 0.524300635f},
std::array<float,2>{0.900325716f, 0.105053969f},
std::array<float,2>{0.315796733f, 0.0466059186f},
std::array<float,2>{0.590332568f, 0.603287876f},
std::array<float,2>{0.129458249f, 0.867787361f},
std::array<float,2>{0.757432997f, 0.348254085f},
std::array<float,2>{0.0655759647f, 0.491757065f},
std::array<float,2>{0.966648936f, 0.926216364f},
std::array<float,2>{0.468705893f, 0.714780807f},
std::array<float,2>{0.689430892f, 0.179293841f},
std::array<float,2>{0.0508098006f, 0.0724707022f},
std::array<float,2>{0.9349038f, 0.535950124f},
std::array<float,2>{0.411457926f, 0.801333606f},
std::array<float,2>{0.673523128f, 0.28441605f},
std::array<float,2>{0.261677176f, 0.394139349f},
std::array<float,2>{0.530882895f, 0.939602256f},
std::array<float,2>{0.240264758f, 0.668069363f},
std::array<float,2>{0.833142877f, 0.240534127f},
std::array<float,2>{0.487088472f, 0.152736649f},
std::array<float,2>{0.736991286f, 0.727162421f},
std::array<float,2>{0.11898195f, 0.88379842f},
std::array<float,2>{0.987516999f, 0.455424279f},
std::array<float,2>{0.184536085f, 0.332019091f},
std::array<float,2>{0.800925016f, 0.837799132f},
std::array<float,2>{0.368529648f, 0.585903287f},
std::array<float,2>{0.602644444f, 0.0179675743f},
std::array<float,2>{0.148110151f, 0.0137881879f},
std::array<float,2>{0.773341298f, 0.575510561f},
std::array<float,2>{0.333269238f, 0.82809937f},
std::array<float,2>{0.576070964f, 0.327012777f},
std::array<float,2>{0.449427217f, 0.438938767f},
std::array<float,2>{0.705813825f, 0.901221871f},
std::array<float,2>{0.0911365226f, 0.745270491f},
std::array<float,2>{0.951940715f, 0.139142513f},
std::array<float,2>{0.288357079f, 0.224136442f},
std::array<float,2>{0.554304004f, 0.672270954f},
std::array<float,2>{0.197918132f, 0.955503881f},
std::array<float,2>{0.867816687f, 0.376304895f},
std::array<float,2>{0.000461638381f, 0.298610657f},
std::array<float,2>{0.882926226f, 0.796396434f},
std::array<float,2>{0.405115962f, 0.562389851f},
std::array<float,2>{0.655745924f, 0.0889047757f},
std::array<float,2>{0.107781388f, 0.168353975f},
std::array<float,2>{0.972329259f, 0.690593541f},
std::array<float,2>{0.483501077f, 0.913580775f},
std::array<float,2>{0.719021738f, 0.469983965f},
std::array<float,2>{0.344176322f, 0.373870194f},
std::array<float,2>{0.624613464f, 0.851989508f},
std::array<float,2>{0.167487949f, 0.616807103f},
std::array<float,2>{0.791443169f, 0.0487617068f},
std::array<float,2>{0.435475975f, 0.1168378f},
std::array<float,2>{0.664905667f, 0.507482171f},
std::array<float,2>{0.0421256758f, 0.762946248f},
std::array<float,2>{0.918687701f, 0.251188904f},
std::array<float,2>{0.223164544f, 0.434167504f},
std::array<float,2>{0.826718509f, 0.976002097f},
std::array<float,2>{0.279558331f, 0.648404658f},
std::array<float,2>{0.506267309f, 0.204554498f},
std::array<float,2>{0.159770638f, 0.131106064f},
std::array<float,2>{0.786093056f, 0.739995062f},
std::array<float,2>{0.357761621f, 0.897818804f},
std::array<float,2>{0.610426247f, 0.452678353f},
std::array<float,2>{0.475366831f, 0.312566876f},
std::array<float,2>{0.733486533f, 0.816330552f},
std::array<float,2>{0.0984034538f, 0.563633144f},
std::array<float,2>{0.981888115f, 0.000751513813f},
std::array<float,2>{0.271003336f, 0.0830559582f},
std::array<float,2>{0.513429463f, 0.550201118f},
std::array<float,2>{0.230232984f, 0.786578953f},
std::array<float,2>{0.81264323f, 0.31143254f},
std::array<float,2>{0.0363749005f, 0.388241857f},
std::array<float,2>{0.906411111f, 0.962594807f},
std::array<float,2>{0.426371127f, 0.684346497f},
std::array<float,2>{0.659522414f, 0.227198094f},
std::array<float,2>{0.0849672109f, 0.0618468896f},
std::array<float,2>{0.939021349f, 0.621963263f},
std::array<float,2>{0.440248311f, 0.848106682f},
std::array<float,2>{0.715272903f, 0.366098613f},
std::array<float,2>{0.336222023f, 0.481515765f},
std::array<float,2>{0.563339353f, 0.915237904f},
std::array<float,2>{0.153713122f, 0.702054799f},
std::array<float,2>{0.779837191f, 0.158646882f},
std::array<float,2>{0.397710025f, 0.21852836f},
std::array<float,2>{0.641021013f, 0.652139187f},
std::array<float,2>{0.0109686786f, 0.980747342f},
std::array<float,2>{0.87519145f, 0.425614238f},
std::array<float,2>{0.193431392f, 0.261054754f},
std::array<float,2>{0.862190068f, 0.75584805f},
std::array<float,2>{0.291400015f, 0.511842608f},
std::array<float,2>{0.560168982f, 0.122240841f},
std::array<float,2>{0.243954375f, 0.094580844f},
std::array<float,2>{0.843424439f, 0.517161131f},
std::array<float,2>{0.253402978f, 0.765855372f},
std::array<float,2>{0.516511559f, 0.278802216f},
std::array<float,2>{0.416120529f, 0.408168077f},
std::array<float,2>{0.685587347f, 0.999638855f},
std::array<float,2>{0.059649758f, 0.629043162f},
std::array<float,2>{0.928058326f, 0.196458757f},
std::array<float,2>{0.365207762f, 0.186364233f},
std::array<float,2>{0.599247158f, 0.70889926f},
std::array<float,2>{0.173039645f, 0.931555808f},
std::array<float,2>{0.810773849f, 0.497521073f},
std::array<float,2>{0.113958187f, 0.353445441f},
std::array<float,2>{0.996749997f, 0.861762583f},
std::array<float,2>{0.495785296f, 0.597735524f},
std::array<float,2>{0.74737525f, 0.0334345959f},
std::array<float,2>{0.0237780754f, 0.244438186f},
std::array<float,2>{0.891443014f, 0.662637115f},
std::array<float,2>{0.378334135f, 0.945993066f},
std::array<float,2>{0.63795507f, 0.4016065f},
std::array<float,2>{0.303540438f, 0.290692866f},
std::array<float,2>{0.544260085f, 0.808306813f},
std::array<float,2>{0.205080375f, 0.539946079f},
std::array<float,2>{0.849551499f, 0.069230333f},
std::array<float,2>{0.454641312f, 0.0244915336f},
std::array<float,2>{0.697858095f, 0.589216292f},
std::array<float,2>{0.0780256465f, 0.832235932f},
std::array<float,2>{0.953872859f, 0.343349576f},
std::array<float,2>{0.136284992f, 0.465536982f},
std::array<float,2>{0.761423826f, 0.879394948f},
std::array<float,2>{0.326593846f, 0.725594878f},
std::array<float,2>{0.583858073f, 0.146415308f},
std::array<float,2>{0.19018282f, 0.150348738f},
std::array<float,2>{0.866194427f, 0.732859135f},
std::array<float,2>{0.293829948f, 0.887162328f},
std::array<float,2>{0.556996882f, 0.459436148f},
std::array<float,2>{0.392311037f, 0.334352851f},
std::array<float,2>{0.645181954f, 0.840322196f},
std::array<float,2>{0.0139736608f, 0.579470873f},
std::array<float,2>{0.880503178f, 0.0203908235f},
std::array<float,2>{0.343256027f, 0.075086832f},
std::array<float,2>{0.568540096f, 0.532917738f},
std::array<float,2>{0.149148494f, 0.800696969f},
std::array<float,2>{0.77494359f, 0.288030267f},
std::array<float,2>{0.0805837959f, 0.398153692f},
std::array<float,2>{0.94414115f, 0.943772137f},
std::array<float,2>{0.442182422f, 0.6676687f},
std::array<float,2>{0.713139653f, 0.235799968f},
std::array<float,2>{0.0324383117f, 0.0420783162f},
std::array<float,2>{0.910609245f, 0.607848823f},
std::array<float,2>{0.422950506f, 0.871978641f},
std::array<float,2>{0.663006425f, 0.346323222f},
std::array<float,2>{0.266683608f, 0.486812949f},
std::array<float,2>{0.509466767f, 0.923501432f},
std::array<float,2>{0.234039947f, 0.717828274f},
std::array<float,2>{0.819525063f, 0.174248368f},
std::array<float,2>{0.468843162f, 0.189983517f},
std::array<float,2>{0.728594899f, 0.635963619f},
std::array<float,2>{0.0938467383f, 0.986581326f},
std::array<float,2>{0.979260206f, 0.414643824f},
std::array<float,2>{0.162121072f, 0.268557668f},
std::array<float,2>{0.782491148f, 0.779733419f},
std::array<float,2>{0.352592379f, 0.527882278f},
std::array<float,2>{0.613303363f, 0.107934438f},
std::array<float,2>{0.140080288f, 0.11087396f},
std::array<float,2>{0.762714207f, 0.503549695f},
std::array<float,2>{0.324028403f, 0.757949889f},
std::array<float,2>{0.57874608f, 0.257243216f},
std::array<float,2>{0.458025694f, 0.432884961f},
std::array<float,2>{0.702650428f, 0.970359623f},
std::array<float,2>{0.0729435161f, 0.644364595f},
std::array<float,2>{0.9577896f, 0.207261503f},
std::array<float,2>{0.298525065f, 0.165156066f},
std::array<float,2>{0.540653229f, 0.693141043f},
std::array<float,2>{0.207552209f, 0.908296883f},
std::array<float,2>{0.844797611f, 0.475074232f},
std::array<float,2>{0.03059626f, 0.370076537f},
std::array<float,2>{0.897384048f, 0.859286904f},
std::array<float,2>{0.381708503f, 0.612648368f},
std::array<float,2>{0.634760082f, 0.0522170849f},
std::array<float,2>{0.111020535f, 0.219871998f},
std::array<float,2>{0.993988097f, 0.678371847f},
std::array<float,2>{0.499072433f, 0.957890153f},
std::array<float,2>{0.743182838f, 0.379476637f},
std::array<float,2>{0.360413164f, 0.302802116f},
std::array<float,2>{0.594843626f, 0.792170405f},
std::array<float,2>{0.179141954f, 0.555084884f},
std::array<float,2>{0.806454778f, 0.0914641097f},
std::array<float,2>{0.419097841f, 0.00831037201f},
std::array<float,2>{0.680381954f, 0.574185491f},
std::array<float,2>{0.0577614531f, 0.824210882f},
std::array<float,2>{0.925464571f, 0.320947409f},
std::array<float,2>{0.248785466f, 0.444554299f},
std::array<float,2>{0.837570488f, 0.904359162f},
std::array<float,2>{0.254869938f, 0.749933541f},
std::array<float,2>{0.521562278f, 0.134136394f},
std::array<float,2>{0.181965441f, 0.21094282f},
std::array<float,2>{0.798750699f, 0.653995872f},
std::array<float,2>{0.371799707f, 0.978721321f},
std::array<float,2>{0.608584702f, 0.426338196f},
std::array<float,2>{0.489049852f, 0.262365401f},
std::array<float,2>{0.738359213f, 0.751600206f},
std::array<float,2>{0.123297319f, 0.508789718f},
std::array<float,2>{0.989732623f, 0.120722383f},
std::array<float,2>{0.263653636f, 0.057109762f},
std::array<float,2>{0.523775756f, 0.620066524f},
std::array<float,2>{0.234940752f, 0.844635248f},
std::array<float,2>{0.828523576f, 0.361445189f},
std::array<float,2>{0.0478468426f, 0.477824301f},
std::array<float,2>{0.930227697f, 0.918085873f},
std::array<float,2>{0.407285303f, 0.69852823f},
std::array<float,2>{0.677992463f, 0.161290735f},
std::array<float,2>{0.0679493472f, 0.0784014463f},
std::array<float,2>{0.96384877f, 0.554504275f},
std::array<float,2>{0.463236064f, 0.783455968f},
std::array<float,2>{0.694567442f, 0.305878997f},
std::array<float,2>{0.318241179f, 0.384584635f},
std::array<float,2>{0.586815953f, 0.965863705f},
std::array<float,2>{0.126300409f, 0.683286011f},
std::array<float,2>{0.752523482f, 0.233746514f},
std::array<float,2>{0.383812487f, 0.12748535f},
std::array<float,2>{0.632519722f, 0.737738848f},
std::array<float,2>{0.0169180427f, 0.894119859f},
std::array<float,2>{0.905813217f, 0.448763669f},
std::array<float,2>{0.215851456f, 0.319805145f},
std::array<float,2>{0.8529073f, 0.819363296f},
std::array<float,2>{0.30975908f, 0.5676018f},
std::array<float,2>{0.537851274f, 0.00586618809f},
std::array<float,2>{0.220112339f, 0.0294577554f},
std::array<float,2>{0.821917951f, 0.592219532f},
std::array<float,2>{0.275410354f, 0.831665337f},
std::array<float,2>{0.501237512f, 0.336238742f},
std::array<float,2>{0.432234228f, 0.464566797f},
std::array<float,2>{0.670381188f, 0.876232147f},
std::array<float,2>{0.0432186164f, 0.719155788f},
std::array<float,2>{0.916443646f, 0.141416445f},
std::array<float,2>{0.348463863f, 0.247940123f},
std::array<float,2>{0.617671609f, 0.657097518f},
std::array<float,2>{0.170753732f, 0.95068562f},
std::array<float,2>{0.794230878f, 0.405467689f},
std::array<float,2>{0.103789262f, 0.294791967f},
std::array<float,2>{0.973831594f, 0.809350252f},
std::array<float,2>{0.47913444f, 0.545140624f},
std::array<float,2>{0.726018488f, 0.0627070591f},
std::array<float,2>{0.00491071632f, 0.182060197f},
std::array<float,2>{0.888746738f, 0.7048226f},
std::array<float,2>{0.401020676f, 0.937013924f},
std::array<float,2>{0.648713768f, 0.492457598f},
std::array<float,2>{0.285097033f, 0.356740445f},
std::array<float,2>{0.548642874f, 0.865121782f},
std::array<float,2>{0.20174396f, 0.594502628f},
std::array<float,2>{0.872123063f, 0.0364968628f},
std::array<float,2>{0.447142333f, 0.0997695997f},
std::array<float,2>{0.707541108f, 0.520145476f},
std::array<float,2>{0.0889457986f, 0.770560861f},
std::array<float,2>{0.945476711f, 0.277117372f},
std::array<float,2>{0.144086286f, 0.413967401f},
std::array<float,2>{0.76784277f, 0.993592501f},
std::array<float,2>{0.33087638f, 0.627251685f},
std::array<float,2>{0.573772609f, 0.200268909f},
std::array<float,2>{0.239700392f, 0.240051806f},
std::array<float,2>{0.835276008f, 0.669941783f},
std::array<float,2>{0.258464485f, 0.937843859f},
std::array<float,2>{0.528611243f, 0.391063452f},
std::array<float,2>{0.412407666f, 0.28158024f},
std::array<float,2>{0.674164355f, 0.803908587f},
std::array<float,2>{0.0537145324f, 0.53810966f},
std::array<float,2>{0.936407328f, 0.0714080632f},
std::array<float,2>{0.370175421f, 0.0165063702f},
std::array<float,2>{0.604904294f, 0.582206488f},
std::array<float,2>{0.187443063f, 0.838947833f},
std::array<float,2>{0.803850651f, 0.32820347f},
std::array<float,2>{0.120794468f, 0.454553664f},
std::array<float,2>{0.98595804f, 0.885009229f},
std::array<float,2>{0.485086471f, 0.72966516f},
std::array<float,2>{0.73565197f, 0.154603168f},
std::array<float,2>{0.0206810944f, 0.103295036f},
std::array<float,2>{0.9017784f, 0.526899874f},
std::array<float,2>{0.390494406f, 0.773463964f},
std::array<float,2>{0.626737416f, 0.27256918f},
std::array<float,2>{0.306764692f, 0.418125749f},
std::array<float,2>{0.533618331f, 0.988318622f},
std::array<float,2>{0.214156255f, 0.640480042f},
std::array<float,2>{0.857358396f, 0.193812907f},
std::array<float,2>{0.466540158f, 0.176781639f},
std::array<float,2>{0.690645993f, 0.712567449f},
std::array<float,2>{0.0634922907f, 0.92838496f},
std::array<float,2>{0.967438638f, 0.48920548f},
std::array<float,2>{0.130988404f, 0.351148546f},
std::array<float,2>{0.755183101f, 0.869529009f},
std::array<float,2>{0.312683254f, 0.603798449f},
std::array<float,2>{0.592909694f, 0.0434563346f},
std::array<float,2>{0.164979488f, 0.0503600053f},
std::array<float,2>{0.790358245f, 0.614784002f},
std::array<float,2>{0.347520262f, 0.854788601f},
std::array<float,2>{0.621418417f, 0.372041106f},
std::array<float,2>{0.481675833f, 0.471680462f},
std::array<float,2>{0.721149743f, 0.910644531f},
std::array<float,2>{0.107104942f, 0.68925482f},
std::array<float,2>{0.969405055f, 0.171824381f},
std::array<float,2>{0.27866742f, 0.205152616f},
std::array<float,2>{0.505829632f, 0.644736946f},
std::array<float,2>{0.225672841f, 0.972666562f},
std::array<float,2>{0.824363112f, 0.437241822f},
std::array<float,2>{0.0401215106f, 0.253672987f},
std::array<float,2>{0.921248734f, 0.764258385f},
std::array<float,2>{0.43710804f, 0.504792154f},
std::array<float,2>{0.666236043f, 0.114315644f},
std::array<float,2>{0.0930588469f, 0.137741297f},
std::array<float,2>{0.951025426f, 0.742580354f},
std::array<float,2>{0.451612681f, 0.899834812f},
std::array<float,2>{0.703717291f, 0.440509707f},
std::array<float,2>{0.334609747f, 0.325308621f},
std::array<float,2>{0.576332629f, 0.824757993f},
std::array<float,2>{0.144584998f, 0.576196551f},
std::array<float,2>{0.770822108f, 0.0127897682f},
std::array<float,2>{0.402512431f, 0.0869565532f},
std::array<float,2>{0.652446866f, 0.559007525f},
std::array<float,2>{0.00353306578f, 0.793228507f},
std::array<float,2>{0.886632204f, 0.299051493f},
std::array<float,2>{0.196599364f, 0.37758854f},
std::array<float,2>{0.869409084f, 0.954368114f},
std::array<float,2>{0.286043733f, 0.674118996f},
std::array<float,2>{0.552289605f, 0.226139709f},
std::array<float,2>{0.15521428f, 0.15717116f},
std::array<float,2>{0.777368486f, 0.700656414f},
std::array<float,2>{0.339125931f, 0.916836202f},
std::array<float,2>{0.565702915f, 0.484295875f},
std::array<float,2>{0.437943399f, 0.363342315f},
std::array<float,2>{0.717226446f, 0.851121664f},
std::array<float,2>{0.0830804408f, 0.624652147f},
std::array<float,2>{0.940985143f, 0.0587746613f},
std::array<float,2>{0.28956759f, 0.124017172f},
std::array<float,2>{0.562488317f, 0.513675332f},
std::array<float,2>{0.192781135f, 0.75687778f},
std::array<float,2>{0.860536754f, 0.258469045f},
std::array<float,2>{0.00885106809f, 0.42381084f},
std::array<float,2>{0.878508568f, 0.983103752f},
std::array<float,2>{0.394886494f, 0.648783803f},
std::array<float,2>{0.644432425f, 0.216067091f},
std::array<float,2>{0.0998535603f, 0.00320561044f},
std::array<float,2>{0.982972085f, 0.565931976f},
std::array<float,2>{0.474586993f, 0.812753737f},
std::array<float,2>{0.730941653f, 0.316361606f},
std::array<float,2>{0.357051551f, 0.450138927f},
std::array<float,2>{0.611629546f, 0.894564569f},
std::array<float,2>{0.156913534f, 0.741286814f},
std::array<float,2>{0.788902283f, 0.129610971f},
std::array<float,2>{0.428870082f, 0.228643164f},
std::array<float,2>{0.65757519f, 0.686456144f},
std::array<float,2>{0.0385332257f, 0.964419067f},
std::array<float,2>{0.908544958f, 0.388755471f},
std::array<float,2>{0.228475556f, 0.309206039f},
std::array<float,2>{0.815817595f, 0.788737774f},
std::array<float,2>{0.273129195f, 0.547773242f},
std::array<float,2>{0.515523195f, 0.0853598937f},
std::array<float,2>{0.204137251f, 0.0679660738f},
std::array<float,2>{0.851194203f, 0.541636586f},
std::array<float,2>{0.302356392f, 0.805248141f},
std::array<float,2>{0.545311451f, 0.292273909f},
std::array<float,2>{0.376794934f, 0.400302768f},
std::array<float,2>{0.640460253f, 0.947528064f},
std::array<float,2>{0.02548627f, 0.661343396f},
std::array<float,2>{0.894044101f, 0.243436635f},
std::array<float,2>{0.325920969f, 0.147445038f},
std::array<float,2>{0.584248066f, 0.723398566f},
std::array<float,2>{0.133507475f, 0.881372869f},
std::array<float,2>{0.759346962f, 0.46731019f},
std::array<float,2>{0.0748401731f, 0.341023386f},
std::array<float,2>{0.955699086f, 0.83453393f},
std::array<float,2>{0.456199348f, 0.586762309f},
std::array<float,2>{0.696208537f, 0.0254272018f},
std::array<float,2>{0.0618521906f, 0.197320208f},
std::array<float,2>{0.926009357f, 0.632552505f},
std::array<float,2>{0.41442129f, 0.997421563f},
std::array<float,2>{0.683909297f, 0.409326762f},
std::array<float,2>{0.250822961f, 0.27958256f},
std::array<float,2>{0.518612146f, 0.767991126f},
std::array<float,2>{0.245584935f, 0.518230796f},
std::array<float,2>{0.839967906f, 0.096496053f},
std::array<float,2>{0.494037449f, 0.0321817137f},
std::array<float,2>{0.749892652f, 0.599991977f},
std::array<float,2>{0.116995923f, 0.85950315f},
std::array<float,2>{0.998765886f, 0.355016321f},
std::array<float,2>{0.17510514f, 0.499795765f},
std::array<float,2>{0.810430944f, 0.932684958f},
std::array<float,2>{0.365539759f, 0.709013343f},
std::array<float,2>{0.600350201f, 0.18392773f},
std::array<float,2>{0.21345903f, 0.179470241f},
std::array<float,2>{0.855955303f, 0.714546978f},
std::array<float,2>{0.30774036f, 0.92593503f},
std::array<float,2>{0.534336627f, 0.492162138f},
std::array<float,2>{0.389155716f, 0.348530293f},
std::array<float,2>{0.625047207f, 0.868112624f},
std::array<float,2>{0.0196809322f, 0.603220522f},
std::array<float,2>{0.900665402f, 0.0466719531f},
std::array<float,2>{0.313620597f, 0.105260611f},
std::array<float,2>{0.591810524f, 0.524035335f},
std::array<float,2>{0.132621452f, 0.77592212f},
std::array<float,2>{0.753921628f, 0.271013796f},
std::array<float,2>{0.0629540011f, 0.420791805f},
std::array<float,2>{0.968217313f, 0.9917503f},
std::array<float,2>{0.46524784f, 0.637288272f},
std::array<float,2>{0.689675391f, 0.19189322f},
std::array<float,2>{0.0532306843f, 0.017633304f},
std::array<float,2>{0.936859131f, 0.585541904f},
std::array<float,2>{0.413287401f, 0.837408304f},
std::array<float,2>{0.675094128f, 0.331713587f},
std::array<float,2>{0.259314001f, 0.455179691f},
std::array<float,2>{0.528061271f, 0.884249806f},
std::array<float,2>{0.238883808f, 0.727430046f},
std::array<float,2>{0.834324777f, 0.15256238f},
std::array<float,2>{0.485381514f, 0.240452081f},
std::array<float,2>{0.73481673f, 0.66843605f},
std::array<float,2>{0.119217306f, 0.939904451f},
std::array<float,2>{0.98524034f, 0.394325852f},
std::array<float,2>{0.185913354f, 0.284624428f},
std::array<float,2>{0.803385794f, 0.801752448f},
std::array<float,2>{0.369366705f, 0.535722911f},
std::array<float,2>{0.603973627f, 0.0725257844f},
std::array<float,2>{0.146222427f, 0.0891998187f},
std::array<float,2>{0.769897163f, 0.562132418f},
std::array<float,2>{0.334961355f, 0.796829522f},
std::array<float,2>{0.577636957f, 0.298356593f},
std::array<float,2>{0.452694654f, 0.376118511f},
std::array<float,2>{0.704314232f, 0.955153286f},
std::array<float,2>{0.0926162526f, 0.672070503f},
std::array<float,2>{0.950111985f, 0.224392712f},
std::array<float,2>{0.286336333f, 0.13874732f},
std::array<float,2>{0.551102459f, 0.74547112f},
std::array<float,2>{0.196113348f, 0.901092768f},
std::array<float,2>{0.870681524f, 0.438595146f},
std::array<float,2>{0.00211052923f, 0.326745659f},
std::array<float,2>{0.884780526f, 0.827809215f},
std::array<float,2>{0.403864264f, 0.575438678f},
std::array<float,2>{0.653374434f, 0.0140559264f},
std::array<float,2>{0.105631098f, 0.204198286f},
std::array<float,2>{0.970374465f, 0.648188412f},
std::array<float,2>{0.48132351f, 0.975695848f},
std::array<float,2>{0.722536206f, 0.434531063f},
std::array<float,2>{0.34613499f, 0.251458138f},
std::array<float,2>{0.622338057f, 0.762706578f},
std::array<float,2>{0.165173665f, 0.507775664f},
std::array<float,2>{0.789605081f, 0.117152222f},
std::array<float,2>{0.436236203f, 0.0485208258f},
std::array<float,2>{0.666998088f, 0.616987765f},
std::array<float,2>{0.0396455824f, 0.851622701f},
std::array<float,2>{0.920880735f, 0.373593122f},
std::array<float,2>{0.225210384f, 0.46994251f},
std::array<float,2>{0.825851023f, 0.913838804f},
std::array<float,2>{0.277369767f, 0.69090575f},
std::array<float,2>{0.504549026f, 0.168205097f},
std::array<float,2>{0.157421544f, 0.227320567f},
std::array<float,2>{0.787324488f, 0.684181213f},
std::array<float,2>{0.35599944f, 0.962840855f},
std::array<float,2>{0.612388194f, 0.388483465f},
std::array<float,2>{0.473546147f, 0.311214149f},
std::array<float,2>{0.732295215f, 0.786182582f},
std::array<float,2>{0.100808464f, 0.549881935f},
std::array<float,2>{0.983525455f, 0.0833062679f},
std::array<float,2>{0.271786869f, 0.000510317914f},
std::array<float,2>{0.514430881f, 0.563855708f},
std::array<float,2>{0.22736305f, 0.816007435f},
std::array<float,2>{0.815174758f, 0.312981427f},
std::array<float,2>{0.0374755114f, 0.452902496f},
std::array<float,2>{0.910019636f, 0.897518933f},
std::array<float,2>{0.428295046f, 0.739967883f},
std::array<float,2>{0.65722537f, 0.130961791f},
std::array<float,2>{0.0827330947f, 0.122518085f},
std::array<float,2>{0.939531207f, 0.512114108f},
std::array<float,2>{0.439242214f, 0.755423188f},
std::array<float,2>{0.71788007f, 0.26093924f},
std::array<float,2>{0.338723421f, 0.425401419f},
std::array<float,2>{0.56477958f, 0.98055774f},
std::array<float,2>{0.155707061f, 0.652035892f},
std::array<float,2>{0.778805792f, 0.218420193f},
std::array<float,2>{0.396080911f, 0.158365503f},
std::array<float,2>{0.642676413f, 0.701761186f},
std::array<float,2>{0.00852007978f, 0.915334225f},
std::array<float,2>{0.876969516f, 0.481861442f},
std::array<float,2>{0.192342713f, 0.365826219f},
std::array<float,2>{0.860122263f, 0.847815156f},
std::array<float,2>{0.290042728f, 0.621793568f},
std::array<float,2>{0.560915887f, 0.0616664179f},
std::array<float,2>{0.244162515f, 0.0336687081f},
std::array<float,2>{0.841757476f, 0.597947717f},
std::array<float,2>{0.251308173f, 0.861509621f},
std::array<float,2>{0.517813861f, 0.353067279f},
std::array<float,2>{0.415233016f, 0.497075975f},
std::array<float,2>{0.684584558f, 0.931193531f},
std::array<float,2>{0.0612432435f, 0.708733559f},
std::array<float,2>{0.927357197f, 0.186134025f},
std::array<float,2>{0.366343111f, 0.196748465f},
std::array<float,2>{0.60082525f, 0.629185498f},
std::array<float,2>{0.174490571f, 0.999834955f},
std::array<float,2>{0.809229195f, 0.407956511f},
std::array<float,2>{0.115399621f, 0.278549463f},
std::array<float,2>{0.99999398f, 0.765950441f},
std::array<float,2>{0.492306441f, 0.517461777f},
std::array<float,2>{0.748203754f, 0.0943512246f},
std::array<float,2>{0.0268406998f, 0.146095872f},
std::array<float,2>{0.892603517f, 0.725861967f},
std::array<float,2>{0.375905544f, 0.879719079f},
std::array<float,2>{0.639458418f, 0.46562773f},
std::array<float,2>{0.301220357f, 0.343622983f},
std::array<float,2>{0.545922935f, 0.832478046f},
std::array<float,2>{0.203329787f, 0.589086831f},
std::array<float,2>{0.850253522f, 0.0247880332f},
std::array<float,2>{0.455376476f, 0.0689422935f},
std::array<float,2>{0.697037101f, 0.539765477f},
std::array<float,2>{0.0752531886f, 0.808463931f},
std::array<float,2>{0.956120253f, 0.29099676f},
std::array<float,2>{0.134309739f, 0.401787192f},
std::array<float,2>{0.758014619f, 0.946073115f},
std::array<float,2>{0.324792594f, 0.663071513f},
std::array<float,2>{0.585551977f, 0.244157538f},
std::array<float,2>{0.232499242f, 0.188290209f},
std::array<float,2>{0.818801582f, 0.633044899f},
std::array<float,2>{0.266601056f, 0.985045493f},
std::array<float,2>{0.50823307f, 0.416460603f},
std::array<float,2>{0.422748476f, 0.266922921f},
std::array<float,2>{0.663726866f, 0.777354777f},
std::array<float,2>{0.0318446346f, 0.529340208f},
std::array<float,2>{0.911407948f, 0.106738836f},
std::array<float,2>{0.352102757f, 0.0408314839f},
std::array<float,2>{0.614603162f, 0.606098831f},
std::array<float,2>{0.163682804f, 0.873407304f},
std::array<float,2>{0.781389952f, 0.343940735f},
std::array<float,2>{0.0947460905f, 0.485627115f},
std::array<float,2>{0.979755342f, 0.925237834f},
std::array<float,2>{0.469970673f, 0.716437876f},
std::array<float,2>{0.729743123f, 0.172685608f},
std::array<float,2>{0.0152345123f, 0.077091597f},
std::array<float,2>{0.879845262f, 0.534761846f},
std::array<float,2>{0.391212165f, 0.796982288f},
std::array<float,2>{0.646422505f, 0.286191165f},
std::array<float,2>{0.294309735f, 0.39523679f},
std::array<float,2>{0.557954192f, 0.941753387f},
std::array<float,2>{0.190499753f, 0.665709436f},
std::array<float,2>{0.866815269f, 0.237978026f},
std::array<float,2>{0.442676604f, 0.150397956f},
std::array<float,2>{0.714684963f, 0.730846345f},
std::array<float,2>{0.0817613229f, 0.890256226f},
std::array<float,2>{0.945150554f, 0.45858407f},
std::array<float,2>{0.149979025f, 0.333568454f},
std::array<float,2>{0.773805797f, 0.842111409f},
std::array<float,2>{0.342048258f, 0.580345333f},
std::array<float,2>{0.570152998f, 0.0225411765f},
std::array<float,2>{0.177914441f, 0.0109315449f},
std::array<float,2>{0.805426896f, 0.571581006f},
std::array<float,2>{0.36031577f, 0.821600735f},
std::array<float,2>{0.59381032f, 0.324115396f},
std::array<float,2>{0.49897638f, 0.443245113f},
std::array<float,2>{0.742513537f, 0.903391063f},
std::array<float,2>{0.109985769f, 0.746370673f},
std::array<float,2>{0.99263984f, 0.135653347f},
std::array<float,2>{0.255664706f, 0.220936209f},
std::array<float,2>{0.523140192f, 0.676243365f},
std::array<float,2>{0.249710798f, 0.959853828f},
std::array<float,2>{0.836507916f, 0.381646097f},
std::array<float,2>{0.0573358499f, 0.302456796f},
std::array<float,2>{0.924540818f, 0.789200544f},
std::array<float,2>{0.418738186f, 0.557774365f},
std::array<float,2>{0.680813134f, 0.0930315554f},
std::array<float,2>{0.0737304017f, 0.166934595f},
std::array<float,2>{0.958920836f, 0.693645716f},
std::array<float,2>{0.457165897f, 0.906669378f},
std::array<float,2>{0.701439559f, 0.474214405f},
std::array<float,2>{0.322952241f, 0.367833018f},
std::array<float,2>{0.579487026f, 0.856834888f},
std::array<float,2>{0.138847798f, 0.61090368f},
std::array<float,2>{0.761850417f, 0.0534287132f},
std::array<float,2>{0.382574916f, 0.112235598f},
std::array<float,2>{0.63367492f, 0.500060856f},
std::array<float,2>{0.0296327565f, 0.760890424f},
std::array<float,2>{0.898377478f, 0.25422883f},
std::array<float,2>{0.208505303f, 0.431527853f},
std::array<float,2>{0.84412241f, 0.971226335f},
std::array<float,2>{0.297321171f, 0.640644729f},
std::array<float,2>{0.539698899f, 0.210815877f},
std::array<float,2>{0.125114202f, 0.126608431f},
std::array<float,2>{0.753374994f, 0.734527528f},
std::array<float,2>{0.31682089f, 0.892427623f},
std::array<float,2>{0.587306082f, 0.445409268f},
std::array<float,2>{0.464667708f, 0.317192972f},
std::array<float,2>{0.693741322f, 0.816848218f},
std::array<float,2>{0.0667366982f, 0.568833113f},
std::array<float,2>{0.964208245f, 0.00434360933f},
std::array<float,2>{0.308877885f, 0.0818993822f},
std::array<float,2>{0.539001048f, 0.552391231f},
std::array<float,2>{0.215445369f, 0.783188701f},
std::array<float,2>{0.852451205f, 0.307997584f},
std::array<float,2>{0.0160882343f, 0.385964215f},
std::array<float,2>{0.904368222f, 0.96823597f},
std::array<float,2>{0.38377434f, 0.68002373f},
std::array<float,2>{0.631301999f, 0.230731145f},
std::array<float,2>{0.124066219f, 0.0564660653f},
std::array<float,2>{0.989070833f, 0.617503583f},
std::array<float,2>{0.490184695f, 0.847438753f},
std::array<float,2>{0.739522934f, 0.360437483f},
std::array<float,2>{0.372330248f, 0.480226815f},
std::array<float,2>{0.607930183f, 0.92073673f},
std::array<float,2>{0.182804555f, 0.696285725f},
std::array<float,2>{0.797392845f, 0.163622558f},
std::array<float,2>{0.406250387f, 0.214718625f},
std::array<float,2>{0.6794222f, 0.654694259f},
std::array<float,2>{0.0479897745f, 0.977328062f},
std::array<float,2>{0.930972517f, 0.428149313f},
std::array<float,2>{0.235401556f, 0.263978273f},
std::array<float,2>{0.829219103f, 0.753480852f},
std::array<float,2>{0.262684435f, 0.51050055f},
std::array<float,2>{0.524888933f, 0.117349856f},
std::array<float,2>{0.202654868f, 0.0990126431f},
std::array<float,2>{0.872038126f, 0.521496475f},
std::array<float,2>{0.283609152f, 0.771680892f},
std::array<float,2>{0.547823489f, 0.275289685f},
std::array<float,2>{0.402236551f, 0.411246121f},
std::array<float,2>{0.649841249f, 0.994597495f},
std::array<float,2>{0.00462775072f, 0.626900434f},
std::array<float,2>{0.890086293f, 0.202460393f},
std::array<float,2>{0.331745893f, 0.181472391f},
std::array<float,2>{0.573004127f, 0.705127716f},
std::array<float,2>{0.143291175f, 0.934921145f},
std::array<float,2>{0.769255936f, 0.495492667f},
std::array<float,2>{0.0885310322f, 0.357700676f},
std::array<float,2>{0.9470976f, 0.86717099f},
std::array<float,2>{0.445525587f, 0.597605765f},
std::array<float,2>{0.708811045f, 0.0381461643f},
std::array<float,2>{0.0448521525f, 0.248622626f},
std::array<float,2>{0.917224526f, 0.658433557f},
std::array<float,2>{0.433566391f, 0.951355577f},
std::array<float,2>{0.671399951f, 0.402698189f},
std::array<float,2>{0.276506931f, 0.296075642f},
std::array<float,2>{0.500403881f, 0.811232924f},
std::array<float,2>{0.218904838f, 0.54443574f},
std::array<float,2>{0.820385456f, 0.0663208291f},
std::array<float,2>{0.479879946f, 0.0276499987f},
std::array<float,2>{0.724695861f, 0.590690434f},
std::array<float,2>{0.104944505f, 0.829035938f},
std::array<float,2>{0.972810745f, 0.339435339f},
std::array<float,2>{0.17162399f, 0.461711943f},
std::array<float,2>{0.793073237f, 0.87707907f},
std::array<float,2>{0.348643005f, 0.722020924f},
std::array<float,2>{0.618662357f, 0.143287003f},
std::array<float,2>{0.241699606f, 0.154308304f},
std::array<float,2>{0.832608342f, 0.729813814f},
std::array<float,2>{0.26046136f, 0.885188758f},
std::array<float,2>{0.529864013f, 0.454315603f},
std::array<float,2>{0.4109146f, 0.328479946f},
std::array<float,2>{0.67216599f, 0.839302182f},
std::array<float,2>{0.0521236323f, 0.582483232f},
std::array<float,2>{0.933970273f, 0.0161591396f},
std::array<float,2>{0.367213756f, 0.0715512261f},
std::array<float,2>{0.602314949f, 0.538342535f},
std::array<float,2>{0.185488701f, 0.804122806f},
std::array<float,2>{0.802183688f, 0.28135559f},
std::array<float,2>{0.117476314f, 0.390827298f},
std::array<float,2>{0.986819685f, 0.937550068f},
std::array<float,2>{0.487675905f, 0.67020762f},
std::array<float,2>{0.737723887f, 0.239863276f},
std::array<float,2>{0.0226948857f, 0.0431158431f},
std::array<float,2>{0.898769557f, 0.603696167f},
std::array<float,2>{0.387856156f, 0.869331539f},
std::array<float,2>{0.628199399f, 0.351332575f},
std::array<float,2>{0.306581974f, 0.489012122f},
std::array<float,2>{0.531383872f, 0.928531706f},
std::array<float,2>{0.212387994f, 0.712764502f},
std::array<float,2>{0.858605802f, 0.177167773f},
std::array<float,2>{0.46765551f, 0.193472251f},
std::array<float,2>{0.687888205f, 0.640142858f},
std::array<float,2>{0.0651776046f, 0.988650978f},
std::array<float,2>{0.965635538f, 0.418356836f},
std::array<float,2>{0.130268171f, 0.272935748f},
std::array<float,2>{0.755886257f, 0.773706377f},
std::array<float,2>{0.314470857f, 0.527287364f},
std::array<float,2>{0.591605842f, 0.103269309f},
std::array<float,2>{0.166687444f, 0.114673726f},
std::array<float,2>{0.792784095f, 0.50444448f},
std::array<float,2>{0.345137417f, 0.764432728f},
std::array<float,2>{0.623232961f, 0.253564358f},
std::array<float,2>{0.482466787f, 0.437449008f},
std::array<float,2>{0.719815195f, 0.972955942f},
std::array<float,2>{0.109055191f, 0.645007014f},
std::array<float,2>{0.971226096f, 0.205345392f},
std::array<float,2>{0.280691594f, 0.171426699f},
std::array<float,2>{0.507139266f, 0.689104974f},
std::array<float,2>{0.223937571f, 0.910299003f},
std::array<float,2>{0.827865064f, 0.471987545f},
std::array<float,2>{0.0413650796f, 0.3715913f},
std::array<float,2>{0.919563174f, 0.854669929f},
std::array<float,2>{0.434192091f, 0.615118623f},
std::array<float,2>{0.665416062f, 0.0505543053f},
std::array<float,2>{0.0902009755f, 0.226379231f},
std::array<float,2>{0.952511609f, 0.674068928f},
std::array<float,2>{0.451051891f, 0.954294205f},
std::array<float,2>{0.706137836f, 0.3777197f},
std::array<float,2>{0.332311958f, 0.299265593f},
std::array<float,2>{0.574661851f, 0.793117464f},
std::array<float,2>{0.147192076f, 0.55876404f},
std::array<float,2>{0.771872759f, 0.0873795226f},
std::array<float,2>{0.405278206f, 0.0131269163f},
std::array<float,2>{0.654937088f, 0.576471329f},
std::array<float,2>{0.00152221823f, 0.825022936f},
std::array<float,2>{0.884172082f, 0.325649351f},
std::array<float,2>{0.198563412f, 0.440858662f},
std::array<float,2>{0.868335485f, 0.899504304f},
std::array<float,2>{0.288070053f, 0.742408454f},
std::array<float,2>{0.55322051f, 0.138033658f},
std::array<float,2>{0.152885765f, 0.215900868f},
std::array<float,2>{0.781231642f, 0.648638189f},
std::array<float,2>{0.337094545f, 0.983328998f},
std::array<float,2>{0.563833117f, 0.423507631f},
std::array<float,2>{0.440864623f, 0.258652955f},
std::array<float,2>{0.716328323f, 0.757166028f},
std::array<float,2>{0.0843468234f, 0.513996482f},
std::array<float,2>{0.93750912f, 0.123695873f},
std::array<float,2>{0.292200804f, 0.0589913391f},
std::array<float,2>{0.559515119f, 0.624927521f},
std::array<float,2>{0.194470659f, 0.851542771f},
std::array<float,2>{0.863014817f, 0.363537103f},
std::array<float,2>{0.01014785f, 0.483955652f},
std::array<float,2>{0.876810849f, 0.916562438f},
std::array<float,2>{0.397212595f, 0.700343728f},
std::array<float,2>{0.641979039f, 0.156759173f},
std::array<float,2>{0.0992766619f, 0.0850037262f},
std::array<float,2>{0.981253803f, 0.547436535f},
std::array<float,2>{0.476287752f, 0.788945317f},
std::array<float,2>{0.732926011f, 0.309564024f},
std::array<float,2>{0.358604938f, 0.389060736f},
std::array<float,2>{0.610209703f, 0.964842081f},
std::array<float,2>{0.158850953f, 0.686113179f},
std::array<float,2>{0.786899209f, 0.228773296f},
std::array<float,2>{0.427257597f, 0.129791752f},
std::array<float,2>{0.658844173f, 0.741510093f},
std::array<float,2>{0.0361284725f, 0.894802153f},
std::array<float,2>{0.907852948f, 0.449779689f},
std::array<float,2>{0.228539586f, 0.316117674f},
std::array<float,2>{0.813886642f, 0.812519014f},
std::array<float,2>{0.269786f, 0.56625849f},
std::array<float,2>{0.512653053f, 0.00310037658f},
std::array<float,2>{0.206386372f, 0.0257670768f},
std::array<float,2>{0.848120987f, 0.586656272f},
std::array<float,2>{0.303938329f, 0.834809661f},
std::array<float,2>{0.543797493f, 0.341239661f},
std::array<float,2>{0.37736997f, 0.467557758f},
std::array<float,2>{0.63748163f, 0.881737411f},
std::array<float,2>{0.025263954f, 0.723280489f},
std::array<float,2>{0.892436326f, 0.147017181f},
std::array<float,2>{0.327352494f, 0.243255854f},
std::array<float,2>{0.582658112f, 0.661549032f},
std::array<float,2>{0.135228723f, 0.947506666f},
std::array<float,2>{0.760409772f, 0.400101632f},
std::array<float,2>{0.0764152631f, 0.292091936f},
std::array<float,2>{0.954113126f, 0.805541098f},
std::array<float,2>{0.453376174f, 0.541910529f},
std::array<float,2>{0.698615909f, 0.0682320669f},
std::array<float,2>{0.0589445196f, 0.183734506f},
std::array<float,2>{0.928902686f, 0.709346354f},
std::array<float,2>{0.417768836f, 0.932905674f},
std::array<float,2>{0.687465906f, 0.499693453f},
std::array<float,2>{0.252174735f, 0.355409592f},
std::array<float,2>{0.517412364f, 0.859668612f},
std::array<float,2>{0.243077844f, 0.599677324f},
std::array<float,2>{0.842757463f, 0.0318369269f},
std::array<float,2>{0.494178414f, 0.096250549f},
std::array<float,2>{0.74613142f, 0.518482327f},
std::array<float,2>{0.114569634f, 0.767686069f},
std::array<float,2>{0.997200966f, 0.279450536f},
std::array<float,2>{0.172004536f, 0.409619868f},
std::array<float,2>{0.812082291f, 0.997100532f},
std::array<float,2>{0.363993645f, 0.632781327f},
std::array<float,2>{0.598086894f, 0.197518498f},
std::array<float,2>{0.189432308f, 0.235465631f},
std::array<float,2>{0.865127683f, 0.667779326f},
std::array<float,2>{0.296083063f, 0.943585932f},
std::array<float,2>{0.556391895f, 0.398308724f},
std::array<float,2>{0.392977953f, 0.287671268f},
std::array<float,2>{0.646691978f, 0.800431311f},
std::array<float,2>{0.0118900109f, 0.532991052f},
std::array<float,2>{0.881206334f, 0.0749253929f},
std::array<float,2>{0.340003163f, 0.0200949721f},
std::array<float,2>{0.567256451f, 0.579223156f},
std::array<float,2>{0.150580078f, 0.840049803f},
std::array<float,2>{0.776477575f, 0.334180295f},
std::array<float,2>{0.0787744969f, 0.459016949f},
std::array<float,2>{0.943241715f, 0.886841536f},
std::array<float,2>{0.444571763f, 0.732449949f},
std::array<float,2>{0.710955262f, 0.149909198f},
std::array<float,2>{0.0335258655f, 0.108176425f},
std::array<float,2>{0.912686706f, 0.528220296f},
std::array<float,2>{0.424750268f, 0.77943933f},
std::array<float,2>{0.660862029f, 0.268932402f},
std::array<float,2>{0.268903196f, 0.415006489f},
std::array<float,2>{0.511588693f, 0.986548543f},
std::array<float,2>{0.231963426f, 0.636173129f},
std::array<float,2>{0.818315923f, 0.1904089f},
std::array<float,2>{0.471595109f, 0.174030975f},
std::array<float,2>{0.726806641f, 0.718200624f},
std::array<float,2>{0.0959339887f, 0.923737228f},
std::array<float,2>{0.976752877f, 0.486365914f},
std::array<float,2>{0.161774889f, 0.346439123f},
std::array<float,2>{0.784361959f, 0.871803284f},
std::array<float,2>{0.354806155f, 0.607636511f},
std::array<float,2>{0.617112637f, 0.0423501059f},
std::array<float,2>{0.137120336f, 0.051896885f},
std::array<float,2>{0.764385104f, 0.612531722f},
std::array<float,2>{0.321634054f, 0.858911574f},
std::array<float,2>{0.581586123f, 0.369650632f},
std::array<float,2>{0.460688651f, 0.474628389f},
std::array<float,2>{0.700937867f, 0.908556998f},
std::array<float,2>{0.0720996037f, 0.693084955f},
std::array<float,2>{0.959270775f, 0.165387318f},
std::array<float,2>{0.300016969f, 0.207479835f},
std::array<float,2>{0.541625798f, 0.644096136f},
std::array<float,2>{0.210910618f, 0.97060746f},
std::array<float,2>{0.847382605f, 0.432727039f},
std::array<float,2>{0.0279294606f, 0.257062286f},
std::array<float,2>{0.896023691f, 0.758198559f},
std::array<float,2>{0.38065213f, 0.503662407f},
std::array<float,2>{0.636243701f, 0.111170322f},
std::array<float,2>{0.112152793f, 0.133929327f},
std::array<float,2>{0.995075226f, 0.749630272f},
std::array<float,2>{0.496436566f, 0.904568791f},
std::array<float,2>{0.745365858f, 0.444626451f},
std::array<float,2>{0.362722397f, 0.321272999f},
std::array<float,2>{0.597211242f, 0.823881626f},
std::array<float,2>{0.176465645f, 0.573973894f},
std::array<float,2>{0.80767709f, 0.00862144772f},
std::array<float,2>{0.420449942f, 0.0915567279f},
std::array<float,2>{0.682861507f, 0.554885924f},
std::array<float,2>{0.0550558381f, 0.792398274f},
std::array<float,2>{0.923540592f, 0.303162932f},
std::array<float,2>{0.246756434f, 0.379856139f},
std::array<float,2>{0.838221729f, 0.95757252f},
std::array<float,2>{0.256406009f, 0.678706288f},
std::array<float,2>{0.520097673f, 0.220117256f},
std::array<float,2>{0.180772498f, 0.161475405f},
std::array<float,2>{0.799030006f, 0.69834429f},
std::array<float,2>{0.374056816f, 0.918400645f},
std::array<float,2>{0.607154191f, 0.477730662f},
std::array<float,2>{0.492046773f, 0.361737221f},
std::array<float,2>{0.74180299f, 0.844292104f},
std::array<float,2>{0.121146649f, 0.619773686f},
std::array<float,2>{0.990818918f, 0.0566481166f},
std::array<float,2>{0.264438927f, 0.120894954f},
std::array<float,2>{0.527036905f, 0.509233654f},
std::array<float,2>{0.238220975f, 0.751748025f},
std::array<float,2>{0.831077576f, 0.262464404f},
std::array<float,2>{0.0497916825f, 0.426581979f},
std::array<float,2>{0.932647586f, 0.978930891f},
std::array<float,2>{0.40830338f, 0.654124975f},
std::array<float,2>{0.675862789f, 0.211233795f},
std::array<float,2>{0.0691827461f, 0.00626466004f},
std::array<float,2>{0.962412238f, 0.567786574f},
std::array<float,2>{0.461561143f, 0.819657981f},
std::array<float,2>{0.692421257f, 0.319443405f},
std::array<float,2>{0.318675697f, 0.449207127f},
std::array<float,2>{0.588340938f, 0.894345939f},
std::array<float,2>{0.128649503f, 0.737383246f},
std::array<float,2>{0.750118375f, 0.127808094f},
std::array<float,2>{0.386554271f, 0.233434498f},
std::array<float,2>{0.629283249f, 0.683446765f},
std::array<float,2>{0.0187764466f, 0.966248274f},
std::array<float,2>{0.9037112f, 0.384501576f},
std::array<float,2>{0.218111053f, 0.305936545f},
std::array<float,2>{0.854615927f, 0.783312082f},
std::array<float,2>{0.312214822f, 0.55431217f},
std::array<float,2>{0.53619206f, 0.0782646537f},
std::array<float,2>{0.220737666f, 0.0629579276f},
std::array<float,2>{0.823352218f, 0.545259595f},
std::array<float,2>{0.27422905f, 0.80910635f},
std::array<float,2>{0.503866434f, 0.294523269f},
std::array<float,2>{0.431482524f, 0.405594081f},
std::array<float,2>{0.669864953f, 0.951075315f},
std::array<float,2>{0.045459792f, 0.656942725f},
std::array<float,2>{0.914834261f, 0.247737035f},
std::array<float,2>{0.351301253f, 0.141214505f},
std::array<float,2>{0.619689524f, 0.71896857f},
std::array<float,2>{0.168803886f, 0.876164317f},
std::array<float,2>{0.795169592f, 0.464613318f},
std::array<float,2>{0.102326341f, 0.336106628f},
std::array<float,2>{0.976193786f, 0.83200562f},
std::array<float,2>{0.477697849f, 0.592040122f},
std::array<float,2>{0.724394858f, 0.0296358764f},
std::array<float,2>{0.00769634033f, 0.200670317f},
std::array<float,2>{0.888440311f, 0.627133429f},
std::array<float,2>{0.399399817f, 0.993168592f},
std::array<float,2>{0.650608301f, 0.413603038f},
std::array<float,2>{0.28141734f, 0.276925981f},
std::array<float,2>{0.550150871f, 0.770890296f},
std::array<float,2>{0.200686187f, 0.520411968f},
std::array<float,2>{0.87331897f, 0.100040995f},
std::array<float,2>{0.447400957f, 0.0363535173f},
std::array<float,2>{0.710891426f, 0.594442546f},
std::array<float,2>{0.0863597393f, 0.864746988f},
std::array<float,2>{0.948894739f, 0.356635243f},
std::array<float,2>{0.142342284f, 0.492367357f},
std::array<float,2>{0.767303884f, 0.9373945f},
std::array<float,2>{0.328742087f, 0.704980135f},
std::array<float,2>{0.572070122f, 0.181755438f},
std::array<float,2>{0.22287859f, 0.16915904f},
std::array<float,2>{0.826379418f, 0.689526498f},
std::array<float,2>{0.280195117f, 0.912141979f},
std::array<float,2>{0.506478727f, 0.46961838f},
std::array<float,2>{0.434656799f, 0.374990523f},
std::array<float,2>{0.664494812f, 0.852840185f},
std::array<float,2>{0.0426030792f, 0.616174996f},
std::array<float,2>{0.917981029f, 0.0471110865f},
std::array<float,2>{0.344346732f, 0.116028689f},
std::array<float,2>{0.624203026f, 0.506282628f},
std::array<float,2>{0.167307898f, 0.762356997f},
std::array<float,2>{0.791708827f, 0.250234097f},
std::array<float,2>{0.108052097f, 0.4348436f},
std::array<float,2>{0.971704841f, 0.974943757f},
std::array<float,2>{0.484320134f, 0.646952212f},
std::array<float,2>{0.71968478f, 0.203289181f},
std::array<float,2>{0.000492576743f, 0.0150750512f},
std::array<float,2>{0.88344264f, 0.575111389f},
std::array<float,2>{0.404332101f, 0.82686466f},
std::array<float,2>{0.655973136f, 0.327941328f},
std::array<float,2>{0.288628072f, 0.437629521f},
std::array<float,2>{0.554113507f, 0.90208149f},
std::array<float,2>{0.197409913f, 0.744336188f},
std::array<float,2>{0.867543638f, 0.139849126f},
std::array<float,2>{0.449735701f, 0.222995788f},
std::array<float,2>{0.705391407f, 0.673610926f},
std::array<float,2>{0.091468744f, 0.956211865f},
std::array<float,2>{0.951402485f, 0.375827998f},
std::array<float,2>{0.147477657f, 0.297147661f},
std::array<float,2>{0.772855103f, 0.795725286f},
std::array<float,2>{0.333569854f, 0.56105566f},
std::array<float,2>{0.575265169f, 0.088255316f},
std::array<float,2>{0.183672115f, 0.073840268f},
std::array<float,2>{0.801479757f, 0.536700964f},
std::array<float,2>{0.369077802f, 0.802317441f},
std::array<float,2>{0.603048265f, 0.283447981f},
std::array<float,2>{0.486564785f, 0.393531233f},
std::array<float,2>{0.736336231f, 0.940672755f},
std::array<float,2>{0.118639722f, 0.669375181f},
std::array<float,2>{0.988029003f, 0.241430074f},
std::array<float,2>{0.260840118f, 0.153861508f},
std::array<float,2>{0.530594528f, 0.728011966f},
std::array<float,2>{0.241082683f, 0.88310039f},
std::array<float,2>{0.833886802f, 0.456843734f},
std::array<float,2>{0.0513591133f, 0.330741614f},
std::array<float,2>{0.935176551f, 0.836884558f},
std::array<float,2>{0.411710739f, 0.584345043f},
std::array<float,2>{0.673044205f, 0.0195139404f},
std::array<float,2>{0.0663888305f, 0.192624927f},
std::array<float,2>{0.966217041f, 0.637880743f},
std::array<float,2>{0.46799466f, 0.991003871f},
std::array<float,2>{0.688484192f, 0.421542227f},
std::array<float,2>{0.316087931f, 0.2700001f},
std::array<float,2>{0.589924335f, 0.777332604f},
std::array<float,2>{0.128940254f, 0.52517581f},
std::array<float,2>{0.757180572f, 0.104005493f},
std::array<float,2>{0.386809736f, 0.0450355262f},
std::array<float,2>{0.627024353f, 0.601985276f},
std::array<float,2>{0.021938365f, 0.868734181f},
std::array<float,2>{0.899819553f, 0.349066705f},
std::array<float,2>{0.211752847f, 0.491170704f},
std::array<float,2>{0.858376145f, 0.927241385f},
std::array<float,2>{0.30522871f, 0.713439584f},
std::array<float,2>{0.532905936f, 0.178128883f},
std::array<float,2>{0.136227965f, 0.245278254f},
std::array<float,2>{0.760804892f, 0.663568437f},
std::array<float,2>{0.326815575f, 0.947179198f},
std::array<float,2>{0.583189845f, 0.400871843f},
std::array<float,2>{0.454525411f, 0.289220899f},
std::array<float,2>{0.697741807f, 0.807200074f},
std::array<float,2>{0.0775562003f, 0.540246069f},
std::array<float,2>{0.953260303f, 0.0698473528f},
std::array<float,2>{0.303165227f, 0.0238389969f},
std::array<float,2>{0.54488492f, 0.588644087f},
std::array<float,2>{0.205810606f, 0.833773553f},
std::array<float,2>{0.848781943f, 0.342722774f},
std::array<float,2>{0.0242983848f, 0.466461599f},
std::array<float,2>{0.890831649f, 0.88018328f},
std::array<float,2>{0.378459543f, 0.724765003f},
std::array<float,2>{0.638658583f, 0.144926831f},
std::array<float,2>{0.113477834f, 0.0954383835f},
std::array<float,2>{0.996115565f, 0.516096413f},
std::array<float,2>{0.495594919f, 0.766708851f},
std::array<float,2>{0.747910321f, 0.277532965f},
std::array<float,2>{0.364638746f, 0.40634653f},
std::array<float,2>{0.598942041f, 0.998432577f},
std::array<float,2>{0.173518792f, 0.630676806f},
std::array<float,2>{0.811055183f, 0.195719615f},
std::array<float,2>{0.416549802f, 0.186997607f},
std::array<float,2>{0.686350822f, 0.707806706f},
std::array<float,2>{0.0603728481f, 0.930232942f},
std::array<float,2>{0.928230822f, 0.496894985f},
std::array<float,2>{0.243372306f, 0.351910174f},
std::array<float,2>{0.842869341f, 0.862674654f},
std::array<float,2>{0.253885031f, 0.599312425f},
std::array<float,2>{0.515984297f, 0.0348623917f},
std::array<float,2>{0.194269866f, 0.0608528927f},
std::array<float,2>{0.8615399f, 0.622742116f},
std::array<float,2>{0.291571647f, 0.848917127f},
std::array<float,2>{0.559999287f, 0.366701543f},
std::array<float,2>{0.398354322f, 0.481266081f},
std::array<float,2>{0.641184092f, 0.914435923f},
std::array<float,2>{0.0112647787f, 0.702309847f},
std::array<float,2>{0.875754356f, 0.159869537f},
std::array<float,2>{0.336461276f, 0.217570424f},
std::array<float,2>{0.562851429f, 0.651076078f},
std::array<float,2>{0.153870821f, 0.981716275f},
std::array<float,2>{0.779519022f, 0.424597621f},
std::array<float,2>{0.0858601555f, 0.260715216f},
std::array<float,2>{0.938544035f, 0.754868209f},
std::array<float,2>{0.43962115f, 0.513127267f},
std::array<float,2>{0.715411186f, 0.121353097f},
std::array<float,2>{0.0366300754f, 0.132794559f},
std::array<float,2>{0.907086611f, 0.738487601f},
std::array<float,2>{0.426029831f, 0.897447407f},
std::array<float,2>{0.660026848f, 0.452133149f},
std::array<float,2>{0.270610958f, 0.314437717f},
std::array<float,2>{0.5128631f, 0.814721107f},
std::array<float,2>{0.229823783f, 0.563450336f},
std::array<float,2>{0.813318193f, 0.00185815897f},
std::array<float,2>{0.474751979f, 0.0823335052f},
std::array<float,2>{0.733939946f, 0.549736857f},
std::array<float,2>{0.0980557948f, 0.7853688f},
std::array<float,2>{0.982366264f, 0.311569452f},
std::array<float,2>{0.159402728f, 0.387057275f},
std::array<float,2>{0.7855497f, 0.961433053f},
std::array<float,2>{0.35836941f, 0.685310423f},
std::array<float,2>{0.611168623f, 0.227981806f},
std::array<float,2>{0.209352642f, 0.209134683f},
std::array<float,2>{0.846324444f, 0.642309248f},
std::array<float,2>{0.298943341f, 0.971814454f},
std::array<float,2>{0.542081833f, 0.430622727f},
std::array<float,2>{0.379183084f, 0.254953325f},
std::array<float,2>{0.635674834f, 0.759989381f},
std::array<float,2>{0.0284756441f, 0.501505196f},
std::array<float,2>{0.895383894f, 0.112611666f},
std::array<float,2>{0.321017802f, 0.054626178f},
std::array<float,2>{0.580781817f, 0.60965389f},
std::array<float,2>{0.138331518f, 0.856419802f},
std::array<float,2>{0.765351593f, 0.368523538f},
std::array<float,2>{0.071067296f, 0.472749174f},
std::array<float,2>{0.960443377f, 0.908097208f},
std::array<float,2>{0.459107429f, 0.695081711f},
std::array<float,2>{0.699602425f, 0.167225495f},
std::array<float,2>{0.0558587834f, 0.0923680812f},
std::array<float,2>{0.922751665f, 0.557331562f},
std::array<float,2>{0.421352088f, 0.790387928f},
std::array<float,2>{0.682195365f, 0.301022619f},
std::array<float,2>{0.256872386f, 0.382124364f},
std::array<float,2>{0.521221995f, 0.960323393f},
std::array<float,2>{0.247518122f, 0.677409232f},
std::array<float,2>{0.83982569f, 0.222418129f},
std::array<float,2>{0.497980148f, 0.136015326f},
std::array<float,2>{0.744185984f, 0.747423232f},
std::array<float,2>{0.112762243f, 0.902593732f},
std::array<float,2>{0.995624423f, 0.441939741f},
std::array<float,2>{0.176951036f, 0.322844326f},
std::array<float,2>{0.806713641f, 0.821053326f},
std::array<float,2>{0.362293959f, 0.571002543f},
std::array<float,2>{0.596001565f, 0.010667461f},
std::array<float,2>{0.151908472f, 0.0219205059f},
std::array<float,2>{0.775750577f, 0.581663728f},
std::array<float,2>{0.340863466f, 0.843035877f},
std::array<float,2>{0.5680812f, 0.332646519f},
std::array<float,2>{0.443415493f, 0.457868487f},
std::array<float,2>{0.712699831f, 0.888694108f},
std::array<float,2>{0.0795174912f, 0.731453001f},
std::array<float,2>{0.942278743f, 0.151964083f},
std::array<float,2>{0.295352072f, 0.237058803f},
std::array<float,2>{0.554797888f, 0.664404571f},
std::array<float,2>{0.188251525f, 0.942995906f},
std::array<float,2>{0.863567173f, 0.395846635f},
std::array<float,2>{0.0127532715f, 0.285876572f},
std::array<float,2>{0.88256377f, 0.798610032f},
std::array<float,2>{0.393740118f, 0.533540428f},
std::array<float,2>{0.648192704f, 0.0777271912f},
std::array<float,2>{0.0971030444f, 0.173564404f},
std::array<float,2>{0.978453636f, 0.715290189f},
std::array<float,2>{0.472300112f, 0.924675882f},
std::array<float,2>{0.72758621f, 0.484794617f},
std::array<float,2>{0.354222715f, 0.345251292f},
std::array<float,2>{0.616000414f, 0.874471307f},
std::array<float,2>{0.160866573f, 0.60726881f},
std::array<float,2>{0.784042478f, 0.0397124439f},
std::array<float,2>{0.425701708f, 0.105864771f},
std::array<float,2>{0.661482036f, 0.53113085f},
std::array<float,2>{0.0350553952f, 0.778567553f},
std::array<float,2>{0.913414776f, 0.266509384f},
std::array<float,2>{0.230999097f, 0.417110056f},
std::array<float,2>{0.816547394f, 0.985401154f},
std::array<float,2>{0.268117398f, 0.634266794f},
std::array<float,2>{0.510478973f, 0.189217553f},
std::array<float,2>{0.169600755f, 0.144241676f},
std::array<float,2>{0.79615128f, 0.721023619f},
std::array<float,2>{0.349810392f, 0.878699422f},
std::array<float,2>{0.620392859f, 0.462358057f},
std::array<float,2>{0.477021962f, 0.337990582f},
std::array<float,2>{0.72270298f, 0.829614341f},
std::array<float,2>{0.10310749f, 0.591027677f},
std::array<float,2>{0.974722743f, 0.029127866f},
std::array<float,2>{0.274649501f, 0.0652244687f},
std::array<float,2>{0.501957417f, 0.54323709f},
std::array<float,2>{0.222610936f, 0.811692357f},
std::array<float,2>{0.822585464f, 0.295160502f},
std::array<float,2>{0.0465551317f, 0.40415594f},
std::array<float,2>{0.915198624f, 0.95222646f},
std::array<float,2>{0.430573225f, 0.659801245f},
std::array<float,2>{0.668248415f, 0.249471635f},
std::array<float,2>{0.0873667523f, 0.0373956971f},
std::array<float,2>{0.947927415f, 0.596413016f},
std::array<float,2>{0.449058175f, 0.865650713f},
std::array<float,2>{0.709487975f, 0.358578712f},
std::array<float,2>{0.329360694f, 0.49488622f},
std::array<float,2>{0.570932269f, 0.934212267f},
std::array<float,2>{0.141505286f, 0.706600904f},
std::array<float,2>{0.766048789f, 0.180279434f},
std::array<float,2>{0.39983952f, 0.201449111f},
std::array<float,2>{0.652307928f, 0.625910461f},
std::array<float,2>{0.00593424682f, 0.995521605f},
std::array<float,2>{0.886814296f, 0.410765737f},
std::array<float,2>{0.199257985f, 0.273564041f},
std::array<float,2>{0.874654531f, 0.773141921f},
std::array<float,2>{0.28237164f, 0.523003399f},
std::array<float,2>{0.549309134f, 0.0981211066f},
std::array<float,2>{0.236877769f, 0.11826849f},
std::array<float,2>{0.830675125f, 0.51102525f},
std::array<float,2>{0.264931351f, 0.7528916f},
std::array<float,2>{0.526354849f, 0.264726192f},
std::array<float,2>{0.409498125f, 0.429162055f},
std::array<float,2>{0.677676439f, 0.977677286f},
std::array<float,2>{0.0498138517f, 0.6557917f},
std::array<float,2>{0.932428598f, 0.213272482f},
std::array<float,2>{0.373387426f, 0.162473381f},
std::array<float,2>{0.60582304f, 0.696601033f},
std::array<float,2>{0.180086389f, 0.921118319f},
std::array<float,2>{0.800435781f, 0.479321182f},
std::array<float,2>{0.123025484f, 0.359908551f},
std::array<float,2>{0.991780996f, 0.845750332f},
std::array<float,2>{0.491166592f, 0.618235648f},
std::array<float,2>{0.740292192f, 0.0555993281f},
std::array<float,2>{0.0182705894f, 0.231621936f},
std::array<float,2>{0.902569056f, 0.68125546f},
std::array<float,2>{0.385169834f, 0.967097163f},
std::array<float,2>{0.630677581f, 0.385030806f},
std::array<float,2>{0.310856432f, 0.306935668f},
std::array<float,2>{0.535728335f, 0.782113075f},
std::array<float,2>{0.216969654f, 0.551689625f},
std::array<float,2>{0.853981555f, 0.080126144f},
std::array<float,2>{0.461942762f, 0.00493018143f},
std::array<float,2>{0.692332089f, 0.56943363f},
std::array<float,2>{0.0699868351f, 0.818291008f},
std::array<float,2>{0.961340249f, 0.317923427f},
std::array<float,2>{0.127002776f, 0.447004586f},
std::array<float,2>{0.751150787f, 0.890949488f},
std::array<float,2>{0.319566995f, 0.735859096f},
std::array<float,2>{0.589245617f, 0.125286132f},
std::array<float,2>{0.197216272f, 0.137269944f},
std::array<float,2>{0.869786739f, 0.744076252f},
std::array<float,2>{0.285526812f, 0.899099588f},
std::array<float,2>{0.551856399f, 0.439506054f},
std::array<float,2>{0.40286538f, 0.324605316f},
std::array<float,2>{0.652891636f, 0.825289071f},
std::array<float,2>{0.0034092681f, 0.577460289f},
std::array<float,2>{0.885769486f, 0.0121106068f},
std::array<float,2>{0.334076405f, 0.0868649557f},
std::array<float,2>{0.576713383f, 0.560050488f},
std::array<float,2>{0.145432457f, 0.794823945f},
std::array<float,2>{0.771308243f, 0.300637186f},
std::array<float,2>{0.0935949385f, 0.378504902f},
std::array<float,2>{0.950212359f, 0.953662992f},
std::array<float,2>{0.451932847f, 0.675559163f},
std::array<float,2>{0.703299701f, 0.225373581f},
std::array<float,2>{0.0406306125f, 0.0497601777f},
std::array<float,2>{0.921391666f, 0.614086151f},
std::array<float,2>{0.436696589f, 0.854332209f},
std::array<float,2>{0.666707218f, 0.372433752f},
std::array<float,2>{0.279170811f, 0.470863819f},
std::array<float,2>{0.505332649f, 0.911721408f},
std::array<float,2>{0.226096034f, 0.68814379f},
std::array<float,2>{0.825095952f, 0.170850679f},
std::array<float,2>{0.482248396f, 0.206832469f},
std::array<float,2>{0.721310556f, 0.646176279f},
std::array<float,2>{0.106467739f, 0.974514306f},
std::array<float,2>{0.969091654f, 0.435881317f},
std::array<float,2>{0.1643226f, 0.252900004f},
std::array<float,2>{0.790920377f, 0.765165746f},
std::array<float,2>{0.346828938f, 0.505554974f},
std::array<float,2>{0.621913552f, 0.113841608f},
std::array<float,2>{0.131394982f, 0.102138899f},
std::array<float,2>{0.755472004f, 0.526137352f},
std::array<float,2>{0.313212067f, 0.774775326f},
std::array<float,2>{0.593457401f, 0.272315949f},
std::array<float,2>{0.465923727f, 0.41950202f},
std::array<float,2>{0.69114846f, 0.989444375f},
std::array<float,2>{0.0640204102f, 0.63948071f},
std::array<float,2>{0.967078924f, 0.194975957f},
std::array<float,2>{0.307463229f, 0.17580536f},
std::array<float,2>{0.53372246f, 0.711738348f},
std::array<float,2>{0.214468732f, 0.928872347f},
std::array<float,2>{0.856684089f, 0.490026444f},
std::array<float,2>{0.0214118101f, 0.34985581f},
std::array<float,2>{0.9019503f, 0.87103796f},
std::array<float,2>{0.389733613f, 0.605213642f},
std::array<float,2>{0.626254082f, 0.0443738475f},
std::array<float,2>{0.120154664f, 0.239137322f},
std::array<float,2>{0.985564411f, 0.671179354f},
std::array<float,2>{0.484501153f, 0.939396501f},
std::array<float,2>{0.73624891f, 0.392568499f},
std::array<float,2>{0.370761722f, 0.283020675f},
std::array<float,2>{0.605354965f, 0.803003013f},
std::array<float,2>{0.186772466f, 0.537352085f},
std::array<float,2>{0.804386258f, 0.0703224391f},
std::array<float,2>{0.412662953f, 0.0170689858f},
std::array<float,2>{0.67461127f, 0.58302331f},
std::array<float,2>{0.054560855f, 0.838688254f},
std::array<float,2>{0.935592473f, 0.329957247f},
std::array<float,2>{0.240172729f, 0.453661263f},
std::array<float,2>{0.835605502f, 0.886703968f},
std::array<float,2>{0.258059472f, 0.729083657f},
std::array<float,2>{0.528987348f, 0.155713663f},
std::array<float,2>{0.175340354f, 0.199193627f},
std::array<float,2>{0.809709489f, 0.631789088f},
std::array<float,2>{0.365781724f, 0.99689585f},
std::array<float,2>{0.599791646f, 0.408986181f},
std::array<float,2>{0.493314147f, 0.280707985f},
std::array<float,2>{0.749309003f, 0.768963456f},
std::array<float,2>{0.116383389f, 0.519163251f},
std::array<float,2>{0.998373628f, 0.097064659f},
std::array<float,2>{0.250412941f, 0.0328789055f},
std::array<float,2>{0.519223988f, 0.601450443f},
std::array<float,2>{0.245761245f, 0.861327291f},
std::array<float,2>{0.840712667f, 0.354115844f},
std::array<float,2>{0.0621205643f, 0.49886784f},
std::array<float,2>{0.926659882f, 0.932335079f},
std::array<float,2>{0.414568514f, 0.710083961f},
std::array<float,2>{0.684414983f, 0.184744924f},
std::array<float,2>{0.0746312514f, 0.0670747757f},
std::array<float,2>{0.955225766f, 0.542954803f},
std::array<float,2>{0.456596702f, 0.806351125f},
std::array<float,2>{0.695397317f, 0.29190889f},
std::array<float,2>{0.325408697f, 0.398890644f},
std::array<float,2>{0.584625185f, 0.948271215f},
std::array<float,2>{0.133015633f, 0.660601377f},
std::array<float,2>{0.758956432f, 0.242884412f},
std::array<float,2>{0.37614575f, 0.14772743f},
std::array<float,2>{0.640094101f, 0.72390914f},
std::array<float,2>{0.026327366f, 0.882193446f},
std::array<float,2>{0.893992484f, 0.467829913f},
std::array<float,2>{0.205045745f, 0.340602428f},
std::array<float,2>{0.850643694f, 0.835424662f},
std::array<float,2>{0.302045912f, 0.587603271f},
std::array<float,2>{0.545449495f, 0.0267736576f},
std::array<float,2>{0.227769405f, 0.00291610835f},
std::array<float,2>{0.81638056f, 0.564630985f},
std::array<float,2>{0.272938609f, 0.814081967f},
std::array<float,2>{0.51488775f, 0.314945012f},
std::array<float,2>{0.429465592f, 0.450555086f},
std::array<float,2>{0.657784343f, 0.896424592f},
std::array<float,2>{0.0386120453f, 0.740483642f},
std::array<float,2>{0.909163117f, 0.130329788f},
std::array<float,2>{0.356681138f, 0.229594886f},
std::array<float,2>{0.611826003f, 0.687446475f},
std::array<float,2>{0.15640077f, 0.963035285f},
std::array<float,2>{0.78816992f, 0.38968876f},
std::array<float,2>{0.100413933f, 0.309761971f},
std::array<float,2>{0.982675672f, 0.787670732f},
std::array<float,2>{0.473727316f, 0.548817039f},
std::array<float,2>{0.731011569f, 0.084180139f},
std::array<float,2>{0.00957479887f, 0.157250553f},
std::array<float,2>{0.878240287f, 0.699249625f},
std::array<float,2>{0.395413905f, 0.917414308f},
std::array<float,2>{0.643755198f, 0.482457101f},
std::array<float,2>{0.289171904f, 0.364372909f},
std::array<float,2>{0.56198281f, 0.850572467f},
std::array<float,2>{0.19330734f, 0.624002755f},
std::array<float,2>{0.861233771f, 0.0597325452f},
std::array<float,2>{0.43799451f, 0.124819033f},
std::array<float,2>{0.717474997f, 0.515622795f},
std::array<float,2>{0.0839819983f, 0.756430328f},
std::array<float,2>{0.940805674f, 0.258824348f},
std::array<float,2>{0.154658347f, 0.422848374f},
std::array<float,2>{0.778018951f, 0.98396796f},
std::array<float,2>{0.339728266f, 0.649420619f},
std::array<float,2>{0.566297174f, 0.215665206f},
std::array<float,2>{0.248301342f, 0.219492525f},
std::array<float,2>{0.837212801f, 0.678787351f},
std::array<float,2>{0.254241973f, 0.958024919f},
std::array<float,2>{0.522077262f, 0.380606472f},
std::array<float,2>{0.419481725f, 0.303783417f},
std::array<float,2>{0.680091858f, 0.791896522f},
std::array<float,2>{0.0582536198f, 0.556217611f},
std::array<float,2>{0.9250108f, 0.0899233595f},
std::array<float,2>{0.360848665f, 0.00896097813f},
std::array<float,2>{0.595461965f, 0.573138177f},
std::array<float,2>{0.179199636f, 0.823187947f},
std::array<float,2>{0.806147277f, 0.321766406f},
std::array<float,2>{0.110443301f, 0.44367829f},
std::array<float,2>{0.993262529f, 0.905336618f},
std::array<float,2>{0.499753416f, 0.748128355f},
std::array<float,2>{0.743764877f, 0.13307707f},
std::array<float,2>{0.0309500042f, 0.109910525f},
std::array<float,2>{0.896687329f, 0.502284229f},
std::array<float,2>{0.381126285f, 0.759535491f},
std::array<float,2>{0.634191394f, 0.256728441f},
std::array<float,2>{0.297991604f, 0.432361275f},
std::array<float,2>{0.540270805f, 0.969447315f},
std::array<float,2>{0.207271859f, 0.643033981f},
std::array<float,2>{0.845468938f, 0.208362669f},
std::array<float,2>{0.45863694f, 0.164750502f},
std::array<float,2>{0.70249933f, 0.692277789f},
std::array<float,2>{0.0725102127f, 0.909671128f},
std::array<float,2>{0.957453012f, 0.47595942f},
std::array<float,2>{0.140380263f, 0.370153219f},
std::array<float,2>{0.76360625f, 0.85820502f},
std::array<float,2>{0.323540509f, 0.61205399f},
std::array<float,2>{0.57837677f, 0.051042892f},
std::array<float,2>{0.162815765f, 0.0412520058f},
std::array<float,2>{0.78315568f, 0.609195113f},
std::array<float,2>{0.353200346f, 0.872751653f},
std::array<float,2>{0.61405915f, 0.346938133f},
std::array<float,2>{0.469404727f, 0.487877369f},
std::array<float,2>{0.72943759f, 0.92238462f},
std::array<float,2>{0.0944469646f, 0.717492104f},
std::array<float,2>{0.97864902f, 0.175102979f},
std::array<float,2>{0.267350376f, 0.19068788f},
std::array<float,2>{0.50892669f, 0.635259569f},
std::array<float,2>{0.233852223f, 0.987971008f},
std::array<float,2>{0.820056081f, 0.415487111f},
std::array<float,2>{0.0331112184f, 0.268059105f},
std::array<float,2>{0.910681784f, 0.780336022f},
std::array<float,2>{0.423548698f, 0.528787911f},
std::array<float,2>{0.662123919f, 0.109198369f},
std::array<float,2>{0.0802082941f, 0.149093494f},
std::array<float,2>{0.943409801f, 0.73342067f},
std::array<float,2>{0.441795737f, 0.88778913f},
std::array<float,2>{0.713485003f, 0.460438699f},
std::array<float,2>{0.343455166f, 0.335450679f},
std::array<float,2>{0.56902647f, 0.840934336f},
std::array<float,2>{0.148577049f, 0.578158975f},
std::array<float,2>{0.774680078f, 0.0209586918f},
std::array<float,2>{0.391884834f, 0.0760964677f},
std::array<float,2>{0.644668996f, 0.53202039f},
std::array<float,2>{0.0145484377f, 0.799666107f},
std::array<float,2>{0.880293608f, 0.288436979f},
std::array<float,2>{0.189632565f, 0.397216946f},
std::array<float,2>{0.865624964f, 0.94462949f},
std::array<float,2>{0.293399125f, 0.666631877f},
std::array<float,2>{0.557194173f, 0.235010892f},
std::array<float,2>{0.143872902f, 0.182943687f},
std::array<float,2>{0.76815182f, 0.704065979f},
std::array<float,2>{0.330173731f, 0.936191916f},
std::array<float,2>{0.57349658f, 0.494049847f},
std::array<float,2>{0.446342319f, 0.355949402f},
std::array<float,2>{0.707214415f, 0.863322496f},
std::array<float,2>{0.0896784216f, 0.595212936f},
std::array<float,2>{0.946240664f, 0.0353277773f},
std::array<float,2>{0.284537107f, 0.101078592f},
std::array<float,2>{0.548223615f, 0.521462142f},
std::array<float,2>{0.201255172f, 0.769543231f},
std::array<float,2>{0.872743964f, 0.276081234f},
std::array<float,2>{0.0056787082f, 0.412351727f},
std::array<float,2>{0.889321446f, 0.992211103f},
std::array<float,2>{0.400696784f, 0.628064394f},
std::array<float,2>{0.649163485f, 0.199431926f},
std::array<float,2>{0.104356349f, 0.0307240952f},
std::array<float,2>{0.974303305f, 0.592970848f},
std::array<float,2>{0.478618592f, 0.830151081f},
std::array<float,2>{0.72634989f, 0.337048799f},
std::array<float,2>{0.348046869f, 0.462897241f},
std::array<float,2>{0.617858946f, 0.875172675f},
std::array<float,2>{0.170132712f, 0.720342934f},
std::array<float,2>{0.794522285f, 0.142564356f},
std::array<float,2>{0.431940675f, 0.246242553f},
std::array<float,2>{0.670428336f, 0.658200681f},
std::array<float,2>{0.0436751731f, 0.949808955f},
std::array<float,2>{0.916565239f, 0.404302955f},
std::array<float,2>{0.220358491f, 0.293413311f},
std::array<float,2>{0.821769774f, 0.809973478f},
std::array<float,2>{0.276233405f, 0.546158969f},
std::array<float,2>{0.501727819f, 0.064436011f},
std::array<float,2>{0.216587439f, 0.0795440152f},
std::array<float,2>{0.853106081f, 0.553637028f},
std::array<float,2>{0.310273916f, 0.784306526f},
std::array<float,2>{0.537549913f, 0.305535316f},
std::array<float,2>{0.384666502f, 0.38378635f},
std::array<float,2>{0.632277668f, 0.965105057f},
std::array<float,2>{0.0174093135f, 0.681881189f},
std::array<float,2>{0.90553385f, 0.233106926f},
std::array<float,2>{0.317869097f, 0.128211424f},
std::array<float,2>{0.586193442f, 0.736528873f},
std::array<float,2>{0.126937926f, 0.893463135f},
std::array<float,2>{0.752316952f, 0.44808057f},
std::array<float,2>{0.0675054491f, 0.319189608f},
std::array<float,2>{0.963025987f, 0.818605483f},
std::array<float,2>{0.463520229f, 0.567350924f},
std::array<float,2>{0.695061624f, 0.00693615712f},
std::array<float,2>{0.0469101742f, 0.21284838f},
std::array<float,2>{0.930113077f, 0.652892411f},
std::array<float,2>{0.407743156f, 0.979638278f},
std::array<float,2>{0.678592265f, 0.426840633f},
std::array<float,2>{0.262929827f, 0.263334602f},
std::array<float,2>{0.524123311f, 0.750832558f},
std::array<float,2>{0.234787971f, 0.508459508f},
std::array<float,2>{0.829092681f, 0.120008491f},
std::array<float,2>{0.488646716f, 0.0578643493f},
std::array<float,2>{0.739021063f, 0.620780706f},
std::array<float,2>{0.123655505f, 0.845165253f},
std::array<float,2>{0.989829063f, 0.362330258f},
std::array<float,2>{0.182265311f, 0.477050722f},
std::array<float,2>{0.797967017f, 0.919880033f},
std::array<float,2>{0.371254593f, 0.697374463f},
std::array<float,2>{0.609203219f, 0.160861582f},
std::array<float,2>{0.192446947f, 0.159462377f},
std::array<float,2>{0.860679269f, 0.702810168f},
std::array<float,2>{0.289851964f, 0.914879799f},
std::array<float,2>{0.562060356f, 0.480613798f},
std::array<float,2>{0.394590616f, 0.36646682f},
std::array<float,2>{0.644277394f, 0.849290788f},
std::array<float,2>{0.00925809424f, 0.62254709f},
std::array<float,2>{0.878789485f, 0.0613774918f},
std::array<float,2>{0.33899048f, 0.121858701f},
std::array<float,2>{0.56555146f, 0.513375819f},
std::array<float,2>{0.154977411f, 0.754337788f},
std::array<float,2>{0.777718306f, 0.26005441f},
std::array<float,2>{0.0832941011f, 0.424198776f},
std::array<float,2>{0.941388249f, 0.982230186f},
std::array<float,2>{0.437696189f, 0.650574446f},
std::array<float,2>{0.716867387f, 0.216833264f},
std::array<float,2>{0.0381433554f, 0.00129138259f},
std::array<float,2>{0.908426285f, 0.562556803f},
std::array<float,2>{0.429066569f, 0.815063894f},
std::array<float,2>{0.657301605f, 0.31376189f},
std::array<float,2>{0.273245811f, 0.451359481f},
std::array<float,2>{0.515322208f, 0.896566868f},
std::array<float,2>{0.228171766f, 0.739000082f},
std::array<float,2>{0.815485656f, 0.131963313f},
std::array<float,2>{0.474188387f, 0.228106916f},
std::array<float,2>{0.730527282f, 0.684607625f},
std::array<float,2>{0.0997345746f, 0.961170554f},
std::array<float,2>{0.983159602f, 0.387694299f},
std::array<float,2>{0.157206282f, 0.312088788f},
std::array<float,2>{0.788740873f, 0.785769582f},
std::array<float,2>{0.357188702f, 0.549183667f},
std::array<float,2>{0.611523569f, 0.0829260349f},
std::array<float,2>{0.133612067f, 0.0695166588f},
std::array<float,2>{0.759741426f, 0.540805221f},
std::array<float,2>{0.326128751f, 0.806812823f},
std::array<float,2>{0.584041893f, 0.289973825f},
std::array<float,2>{0.456369698f, 0.40089792f},
std::array<float,2>{0.695818484f, 0.946556151f},
std::array<float,2>{0.0749853924f, 0.663744211f},
std::array<float,2>{0.95584172f, 0.245842531f},
std::array<float,2>{0.302519888f, 0.145448104f},
std::array<float,2>{0.545063436f, 0.725290358f},
std::array<float,2>{0.204481348f, 0.88052839f},
std::array<float,2>{0.851523817f, 0.465874612f},
std::array<float,2>{0.0258440655f, 0.342253506f},
std::array<float,2>{0.894406617f, 0.833039165f},
std::array<float,2>{0.376686394f, 0.588126302f},
std::array<float,2>{0.640179753f, 0.0241718609f},
std::array<float,2>{0.116930492f, 0.196155086f},
std::array<float,2>{0.998955488f, 0.630294085f},
std::array<float,2>{0.493695199f, 0.999001741f},
std::array<float,2>{0.749712527f, 0.407108277f},
std::array<float,2>{0.365361959f, 0.277885735f},
std::array<float,2>{0.60022676f, 0.767506838f},
std::array<float,2>{0.175012231f, 0.51642549f},
std::array<float,2>{0.810217321f, 0.0947389007f},
std::array<float,2>{0.4141877f, 0.034500543f},
std::array<float,2>{0.683824182f, 0.598833919f},
std::array<float,2>{0.0617218427f, 0.86322093f},
std::array<float,2>{0.926076472f, 0.352462322f},
std::array<float,2>{0.245273992f, 0.496430814f},
std::array<float,2>{0.840105712f, 0.92972666f},
std::array<float,2>{0.250616312f, 0.707239211f},
std::array<float,2>{0.518817425f, 0.18731676f},
std::array<float,2>{0.187218785f, 0.241960466f},
std::array<float,2>{0.803981006f, 0.669593632f},
std::array<float,2>{0.370536417f, 0.941008747f},
std::array<float,2>{0.604693055f, 0.393063962f},
std::array<float,2>{0.485162467f, 0.283715814f},
std::array<float,2>{0.73540628f, 0.802144885f},
std::array<float,2>{0.121080093f, 0.536391139f},
std::array<float,2>{0.986256242f, 0.073375009f},
std::array<float,2>{0.258789003f, 0.0188029837f},
std::array<float,2>{0.528437197f, 0.58473587f},
std::array<float,2>{0.239414707f, 0.836261988f},
std::array<float,2>{0.835022509f, 0.330092192f},
std::array<float,2>{0.0541932918f, 0.456542283f},
std::array<float,2>{0.936115146f, 0.883361876f},
std::array<float,2>{0.412336498f, 0.728255332f},
std::array<float,2>{0.673977852f, 0.153717756f},
std::array<float,2>{0.0637482032f, 0.103853263f},
std::array<float,2>{0.967660904f, 0.52489382f},
std::array<float,2>{0.466737628f, 0.776538849f},
std::array<float,2>{0.690764427f, 0.270089537f},
std::array<float,2>{0.312824607f, 0.420988411f},
std::array<float,2>{0.593190491f, 0.990398288f},
std::array<float,2>{0.131250143f, 0.638658941f},
std::array<float,2>{0.755017698f, 0.192875177f},
std::array<float,2>{0.390371948f, 0.178382471f},
std::array<float,2>{0.626536012f, 0.713129461f},
std::array<float,2>{0.0208947286f, 0.927499056f},
std::array<float,2>{0.901401103f, 0.490446806f},
std::array<float,2>{0.213989764f, 0.349287033f},
std::array<float,2>{0.856955945f, 0.868217647f},
std::array<float,2>{0.306944907f, 0.60248661f},
std::array<float,2>{0.533440053f, 0.0455923975f},
std::array<float,2>{0.22590977f, 0.047821518f},
std::array<float,2>{0.824577928f, 0.615388393f},
std::array<float,2>{0.278404117f, 0.853345275f},
std::array<float,2>{0.505542338f, 0.374251515f},
std::array<float,2>{0.437397838f, 0.469066203f},
std::array<float,2>{0.666403353f, 0.913027108f},
std::array<float,2>{0.040397808f, 0.690143943f},
std::array<float,2>{0.920913219f, 0.169539407f},
std::array<float,2>{0.347205013f, 0.203948125f},
std::array<float,2>{0.621157944f, 0.647328973f},
std::array<float,2>{0.16462031f, 0.975170851f},
std::array<float,2>{0.7901209f, 0.435485601f},
std::array<float,2>{0.107274167f, 0.250549674f},
std::array<float,2>{0.969677091f, 0.762174129f},
std::array<float,2>{0.481924653f, 0.50674051f},
std::array<float,2>{0.720762908f, 0.115332089f},
std::array<float,2>{0.00384172145f, 0.140343294f},
std::array<float,2>{0.886273563f, 0.745103836f},
std::array<float,2>{0.402596354f, 0.901575804f},
std::array<float,2>{0.652645767f, 0.438389897f},
std::array<float,2>{0.285651177f, 0.327245981f},
std::array<float,2>{0.552502811f, 0.82665956f},
std::array<float,2>{0.196474701f, 0.574633718f},
std::array<float,2>{0.869178593f, 0.0155507009f},
std::array<float,2>{0.451380819f, 0.0885932744f},
std::array<float,2>{0.704058111f, 0.560599685f},
std::array<float,2>{0.0929111913f, 0.795235574f},
std::array<float,2>{0.950760365f, 0.297775984f},
std::array<float,2>{0.144857898f, 0.375475436f},
std::array<float,2>{0.770530164f, 0.956861615f},
std::array<float,2>{0.334948123f, 0.673088491f},
std::array<float,2>{0.576521039f, 0.223375991f},
std::array<float,2>{0.235320345f, 0.213523954f},
std::array<float,2>{0.828189075f, 0.655275166f},
std::array<float,2>{0.263393015f, 0.97826761f},
std::array<float,2>{0.523535609f, 0.429312915f},
std::array<float,2>{0.4076159f, 0.265555203f},
std::array<float,2>{0.677794337f, 0.752395272f},
std::array<float,2>{0.0473688133f, 0.51128453f},
std::array<float,2>{0.930458486f, 0.118675083f},
std::array<float,2>{0.37185961f, 0.0550271161f},
std::array<float,2>{0.608814538f, 0.618765771f},
std::array<float,2>{0.181832165f, 0.846315742f},
std::array<float,2>{0.798560381f, 0.359598309f},
std::array<float,2>{0.123095706f, 0.478920758f},
std::array<float,2>{0.989307702f, 0.921742022f},
std::array<float,2>{0.48891595f, 0.696802497f},
std::array<float,2>{0.7386778f, 0.162625283f},
std::array<float,2>{0.0167366415f, 0.0809757635f},
std::array<float,2>{0.906189859f, 0.550867975f},
std::array<float,2>{0.38423422f, 0.781734943f},
std::array<float,2>{0.632681072f, 0.307186335f},
std::array<float,2>{0.309995651f, 0.385273665f},
std::array<float,2>{0.537674427f, 0.967637599f},
std::array<float,2>{0.216256902f, 0.68085897f},
std::array<float,2>{0.852715194f, 0.232314125f},
std::array<float,2>{0.463096976f, 0.125790671f},
std::array<float,2>{0.694675028f, 0.735599458f},
std::array<float,2>{0.0682623163f, 0.891161382f},
std::array<float,2>{0.963420451f, 0.446758628f},
std::array<float,2>{0.126201138f, 0.317797512f},
std::array<float,2>{0.752819717f, 0.81756866f},
std::array<float,2>{0.317893714f, 0.569965422f},
std::array<float,2>{0.586492181f, 0.00555040361f},
std::array<float,2>{0.170460537f, 0.0287117697f},
std::array<float,2>{0.79417181f, 0.59173274f},
std::array<float,2>{0.348258972f, 0.829162657f},
std::array<float,2>{0.617248595f, 0.338861436f},
std::array<float,2>{0.479427695f, 0.46269837f},
std::array<float,2>{0.725759804f, 0.878192782f},
std::array<float,2>{0.103712946f, 0.721345603f},
std::array<float,2>{0.973899603f, 0.143772006f},
std::array<float,2>{0.275800705f, 0.249811038f},
std::array<float,2>{0.501171649f, 0.659251094f},
std::array<float,2>{0.21975252f, 0.952954054f},
std::array<float,2>{0.822240055f, 0.403353989f},
std::array<float,2>{0.0431127027f, 0.295807838f},
std::array<float,2>{0.916154265f, 0.812201083f},
std::array<float,2>{0.432430446f, 0.543702483f},
std::array<float,2>{0.67010963f, 0.0649179593f},
std::array<float,2>{0.0892949104f, 0.179910317f},
std::array<float,2>{0.945702791f, 0.706533194f},
std::array<float,2>{0.446813315f, 0.933657825f},
std::array<float,2>{0.70780921f, 0.494448513f},
std::array<float,2>{0.330787241f, 0.359061003f},
std::array<float,2>{0.574035883f, 0.865839422f},
std::array<float,2>{0.144524947f, 0.595884383f},
std::array<float,2>{0.767666817f, 0.037886329f},
std::array<float,2>{0.401300877f, 0.0981452912f},
std::array<float,2>{0.648581684f, 0.522758245f},
std::array<float,2>{0.00515343621f, 0.772479713f},
std::array<float,2>{0.88902849f, 0.27403143f},
std::array<float,2>{0.201947942f, 0.410514086f},
std::array<float,2>{0.872432649f, 0.995711327f},
std::array<float,2>{0.284802914f, 0.625445008f},
std::array<float,2>{0.548541963f, 0.201818764f},
std::array<float,2>{0.149373919f, 0.15138194f},
std::array<float,2>{0.77531606f, 0.732376158f},
std::array<float,2>{0.342958689f, 0.889214039f},
std::array<float,2>{0.56883198f, 0.457356662f},
std::array<float,2>{0.441991419f, 0.332161486f},
std::array<float,2>{0.71308583f, 0.843451262f},
std::array<float,2>{0.0810270682f, 0.581124127f},
std::array<float,2>{0.944056869f, 0.0222647283f},
std::array<float,2>{0.293504f, 0.0773475468f},
std::array<float,2>{0.556705177f, 0.533808708f},
std::array<float,2>{0.190314516f, 0.797886252f},
std::array<float,2>{0.865802586f, 0.28552267f},
std::array<float,2>{0.013845481f, 0.396007746f},
std::array<float,2>{0.880707741f, 0.942436159f},
std::array<float,2>{0.392480016f, 0.664754689f},
std::array<float,2>{0.645299792f, 0.236792922f},
std::array<float,2>{0.0942237005f, 0.0395070985f},
std::array<float,2>{0.979241669f, 0.606850505f},
std::array<float,2>{0.46916151f, 0.874864697f},
std::array<float,2>{0.729003668f, 0.345148772f},
std::array<float,2>{0.352965891f, 0.485224783f},
std::array<float,2>{0.613641143f, 0.924013257f},
std::array<float,2>{0.16240041f, 0.71542263f},
std::array<float,2>{0.782371223f, 0.172952741f},
std::array<float,2>{0.423236787f, 0.188639477f},
std::array<float,2>{0.662723362f, 0.634690523f},
std::array<float,2>{0.0325597785f, 0.986001492f},
std::array<float,2>{0.910277069f, 0.417926282f},
std::array<float,2>{0.234139517f, 0.26565364f},
std::array<float,2>{0.819690466f, 0.778863788f},
std::array<float,2>{0.267010003f, 0.530607343f},
std::array<float,2>{0.509580731f, 0.106385037f},
std::array<float,2>{0.207968086f, 0.113144562f},
std::array<float,2>{0.845095754f, 0.50134474f},
std::array<float,2>{0.298761338f, 0.760333121f},
std::array<float,2>{0.540783286f, 0.255404651f},
std::array<float,2>{0.381441206f, 0.429962248f},
std::array<float,2>{0.63445133f, 0.972619534f},
std::array<float,2>{0.0303855129f, 0.641786695f},
std::array<float,2>{0.897051573f, 0.209752887f},
std::array<float,2>{0.323829383f, 0.167772949f},
std::array<float,2>{0.578858137f, 0.694525898f},
std::array<float,2>{0.139665648f, 0.907408655f},
std::array<float,2>{0.763083935f, 0.473579288f},
std::array<float,2>{0.0731971934f, 0.369135499f},
std::array<float,2>{0.957582414f, 0.855805278f},
std::array<float,2>{0.45843184f, 0.610029042f},
std::array<float,2>{0.703085363f, 0.0538790897f},
std::array<float,2>{0.0578844137f, 0.221768662f},
std::array<float,2>{0.925678492f, 0.677072883f},
std::array<float,2>{0.419329733f, 0.960476816f},
std::array<float,2>{0.680512071f, 0.38237679f},
std::array<float,2>{0.254520804f, 0.30152145f},
std::array<float,2>{0.521966338f, 0.790646553f},
std::array<float,2>{0.248545423f, 0.556852102f},
std::array<float,2>{0.837784946f, 0.0918146521f},
std::array<float,2>{0.499405205f, 0.00980880763f},
std::array<float,2>{0.743444026f, 0.570570529f},
std::array<float,2>{0.111260459f, 0.820747912f},
std::array<float,2>{0.993796229f, 0.322539926f},
std::array<float,2>{0.178897455f, 0.441638678f},
std::array<float,2>{0.806155503f, 0.903155506f},
std::array<float,2>{0.360796452f, 0.747591734f},
std::array<float,2>{0.594975948f, 0.136364505f},
std::array<float,2>{0.230004445f, 0.130609035f},
std::array<float,2>{0.812748551f, 0.740841925f},
std::array<float,2>{0.271361172f, 0.895937681f},
std::array<float,2>{0.513192773f, 0.450739801f},
std::array<float,2>{0.426545262f, 0.314613014f},
std::array<float,2>{0.659310162f, 0.813827634f},
std::array<float,2>{0.0365559384f, 0.565087914f},
std::array<float,2>{0.90670079f, 0.00206509558f},
std::array<float,2>{0.357433975f, 0.0847715139f},
std::array<float,2>{0.610625684f, 0.547957301f},
std::array<float,2>{0.16007036f, 0.787300408f},
std::array<float,2>{0.785810232f, 0.310299188f},
std::array<float,2>{0.0983802378f, 0.390265435f},
std::array<float,2>{0.981523037f, 0.963862538f},
std::array<float,2>{0.475171506f, 0.686525583f},
std::array<float,2>{0.733696103f, 0.230431318f},
std::array<float,2>{0.0110666752f, 0.0604122952f},
std::array<float,2>{0.875475109f, 0.623273373f},
std::array<float,2>{0.397639215f, 0.849728584f},
std::array<float,2>{0.640667021f, 0.365217507f},
std::array<float,2>{0.29109633f, 0.483133852f},
std::array<float,2>{0.560398102f, 0.917621732f},
std::array<float,2>{0.193604156f, 0.699777961f},
std::array<float,2>{0.861922204f, 0.157883525f},
std::array<float,2>{0.44009763f, 0.215156406f},
std::array<float,2>{0.714848876f, 0.650316715f},
std::array<float,2>{0.0852980688f, 0.983492613f},
std::array<float,2>{0.939417064f, 0.422293723f},
std::array<float,2>{0.153503969f, 0.25968343f},
std::array<float,2>{0.780042112f, 0.756102681f},
std::array<float,2>{0.336180478f, 0.514911592f},
std::array<float,2>{0.563213348f, 0.124254607f},
std::array<float,2>{0.173268691f, 0.0971883088f},
std::array<float,2>{0.811026037f, 0.51878041f},
std::array<float,2>{0.364915192f, 0.769057333f},
std::array<float,2>{0.599408031f, 0.280876577f},
std::array<float,2>{0.495870948f, 0.408613175f},
std::array<float,2>{0.74718821f, 0.99633944f},
std::array<float,2>{0.114191391f, 0.63099885f},
std::array<float,2>{0.996827781f, 0.198424101f},
std::array<float,2>{0.25303033f, 0.185315534f},
std::array<float,2>{0.516144991f, 0.710640013f},
std::array<float,2>{0.24366045f, 0.932088017f},
std::array<float,2>{0.843747199f, 0.49816227f},
std::array<float,2>{0.059918534f, 0.353654236f},
std::array<float,2>{0.927894771f, 0.860588729f},
std::array<float,2>{0.416482478f, 0.600845635f},
std::array<float,2>{0.685996294f, 0.0324639454f},
std::array<float,2>{0.0777775571f, 0.242551908f},
std::array<float,2>{0.953750432f, 0.66095221f},
std::array<float,2>{0.454868406f, 0.949070096f},
std::array<float,2>{0.698192775f, 0.399402916f},
std::array<float,2>{0.326346725f, 0.291383356f},
std::array<float,2>{0.583496511f, 0.805842936f},
std::array<float,2>{0.136619702f, 0.542286277f},
std::array<float,2>{0.76161921f, 0.0665538386f},
std::array<float,2>{0.378009677f, 0.0272607394f},
std::array<float,2>{0.637929559f, 0.586969078f},
std::array<float,2>{0.0234430674f, 0.83575356f},
std::array<float,2>{0.891226292f, 0.339929283f},
std::array<float,2>{0.20541814f, 0.468391985f},
std::array<float,2>{0.84930855f, 0.882627606f},
std::array<float,2>{0.303312927f, 0.724567294f},
std::array<float,2>{0.544136047f, 0.147990391f},
std::array<float,2>{0.129784942f, 0.194701314f},
std::array<float,2>{0.757612765f, 0.638905525f},
std::array<float,2>{0.315652966f, 0.990130007f},
std::array<float,2>{0.590660155f, 0.41916573f},
std::array<float,2>{0.468443245f, 0.27165252f},
std::array<float,2>{0.68909651f, 0.774904847f},
std::array<float,2>{0.065887332f, 0.525748909f},
std::array<float,2>{0.966534495f, 0.102009676f},
std::array<float,2>{0.304763436f, 0.0448410399f},
std::array<float,2>{0.532445192f, 0.60464704f},
std::array<float,2>{0.211260036f, 0.870289564f},
std::array<float,2>{0.857811034f, 0.350300789f},
std::array<float,2>{0.0220886935f, 0.489324898f},
std::array<float,2>{0.899902821f, 0.929571927f},
std::array<float,2>{0.387415588f, 0.711076021f},
std::array<float,2>{0.627851665f, 0.176512927f},
std::array<float,2>{0.118700676f, 0.0709491745f},
std::array<float,2>{0.987790585f, 0.537628472f},
std::array<float,2>{0.486977279f, 0.80341202f},
std::array<float,2>{0.737300098f, 0.282439709f},
std::array<float,2>{0.368310213f, 0.39198634f},
std::array<float,2>{0.602909148f, 0.938575506f},
std::array<float,2>{0.184101403f, 0.671446562f},
std::array<float,2>{0.801136732f, 0.238360986f},
std::array<float,2>{0.411222637f, 0.155903876f},
std::array<float,2>{0.673688173f, 0.72881335f},
std::array<float,2>{0.0510392971f, 0.886070251f},
std::array<float,2>{0.934729099f, 0.453418195f},
std::array<float,2>{0.240507931f, 0.329313129f},
std::array<float,2>{0.833437383f, 0.837970376f},
std::array<float,2>{0.261340529f, 0.58387208f},
std::array<float,2>{0.531119764f, 0.0173130892f},
std::array<float,2>{0.198143452f, 0.0126774656f},
std::array<float,2>{0.86804831f, 0.577764213f},
std::array<float,2>{0.288134009f, 0.825839281f},
std::array<float,2>{0.554535985f, 0.324906588f},
std::array<float,2>{0.405024827f, 0.440158963f},
std::array<float,2>{0.655355275f, 0.898617685f},
std::array<float,2>{0.000178271264f, 0.743228436f},
std::array<float,2>{0.883077085f, 0.137175724f},
std::array<float,2>{0.333018869f, 0.224993855f},
std::array<float,2>{0.575791597f, 0.675147116f},
std::array<float,2>{0.148244649f, 0.953254223f},
std::array<float,2>{0.773109913f, 0.377961755f},
std::array<float,2>{0.0910451785f, 0.299931228f},
std::array<float,2>{0.951860905f, 0.794200897f},
std::array<float,2>{0.449696481f, 0.560393214f},
std::array<float,2>{0.705671489f, 0.0864185393f},
std::array<float,2>{0.0424275547f, 0.169979855f},
std::array<float,2>{0.91890496f, 0.687661886f},
std::array<float,2>{0.435244322f, 0.911572754f},
std::array<float,2>{0.664580286f, 0.471585184f},
std::array<float,2>{0.279298723f, 0.372685105f},
std::array<float,2>{0.50599128f, 0.853570402f},
std::array<float,2>{0.223395497f, 0.613370717f},
std::array<float,2>{0.827048063f, 0.0489338189f},
std::array<float,2>{0.483781457f, 0.113636985f},
std::array<float,2>{0.718868613f, 0.504895747f},
std::array<float,2>{0.107534349f, 0.765055418f},
std::array<float,2>{0.972651064f, 0.252209753f},
std::array<float,2>{0.167911723f, 0.436481357f},
std::array<float,2>{0.791217506f, 0.973642528f},
std::array<float,2>{0.343782902f, 0.645819485f},
std::array<float,2>{0.624817014f, 0.206273794f},
std::array<float,2>{0.217700392f, 0.232903197f},
std::array<float,2>{0.854347885f, 0.682490706f},
std::array<float,2>{0.311427265f, 0.965458453f},
std::array<float,2>{0.535619259f, 0.383122504f},
std::array<float,2>{0.385690868f, 0.304744095f},
std::array<float,2>{0.629898012f, 0.784746587f},
std::array<float,2>{0.0176640768f, 0.553006709f},
std::array<float,2>{0.902906477f, 0.0795899481f},
std::array<float,2>{0.320160449f, 0.00752452994f},
std::array<float,2>{0.58935678f, 0.566667259f},
std::array<float,2>{0.127884835f, 0.81920439f},
std::array<float,2>{0.751481354f, 0.318452895f},
std::array<float,2>{0.0695842654f, 0.447554916f},
std::array<float,2>{0.961808503f, 0.892753184f},
std::array<float,2>{0.46269539f, 0.737021744f},
std::array<float,2>{0.691649914f, 0.128832519f},
std::array<float,2>{0.0506705269f, 0.119301476f},
std::array<float,2>{0.931691647f, 0.507831991f},
std::array<float,2>{0.410007447f, 0.750270545f},
std::array<float,2>{0.677204072f, 0.263043076f},
std::array<float,2>{0.2655707f, 0.427397907f},
std::array<float,2>{0.525850773f, 0.980018318f},
std::array<float,2>{0.236396968f, 0.652458727f},
std::array<float,2>{0.830112338f, 0.212163433f},
std::array<float,2>{0.49055776f, 0.160321727f},
std::array<float,2>{0.741180897f, 0.697980285f},
std::array<float,2>{0.122106075f, 0.919064879f},
std::array<float,2>{0.991645813f, 0.477291733f},
std::array<float,2>{0.180369481f, 0.363060087f},
std::array<float,2>{0.799887836f, 0.845299542f},
std::array<float,2>{0.373742968f, 0.620202541f},
std::array<float,2>{0.606041849f, 0.0585559867f},
std::array<float,2>{0.140890807f, 0.0358967632f},
std::array<float,2>{0.766407609f, 0.595543563f},
std::array<float,2>{0.329949915f, 0.863868773f},
std::array<float,2>{0.57039094f, 0.356190383f},
std::array<float,2>{0.448640376f, 0.493331611f},
std::array<float,2>{0.709162772f, 0.935670972f},
std::array<float,2>{0.0874245688f, 0.703453839f},
std::array<float,2>{0.947706223f, 0.18324326f},
std::array<float,2>{0.283058017f, 0.200055644f},
std::array<float,2>{0.549352825f, 0.628786147f},
std::array<float,2>{0.200166062f, 0.992678642f},
std::array<float,2>{0.874267399f, 0.412620068f},
std::array<float,2>{0.00682710111f, 0.275432587f},
std::array<float,2>{0.887645543f, 0.770165443f},
std::array<float,2>{0.400106579f, 0.520522535f},
std::array<float,2>{0.651390016f, 0.100902751f},
std::array<float,2>{0.102832504f, 0.141830251f},
std::array<float,2>{0.975207567f, 0.719807565f},
std::array<float,2>{0.477374762f, 0.875548899f},
std::array<float,2>{0.7231462f, 0.463457376f},
std::array<float,2>{0.35033825f, 0.337706f},
std::array<float,2>{0.620962858f, 0.830693722f},
std::array<float,2>{0.169112995f, 0.593403459f},
std::array<float,2>{0.796440184f, 0.0309905577f},
std::array<float,2>{0.429983944f, 0.0635192245f},
std::array<float,2>{0.668902457f, 0.546594441f},
std::array<float,2>{0.046383556f, 0.810369015f},
std::array<float,2>{0.915536761f, 0.293724f},
std::array<float,2>{0.221915662f, 0.404820204f},
std::array<float,2>{0.823235214f, 0.94946605f},
std::array<float,2>{0.275133163f, 0.657446921f},
std::array<float,2>{0.502746046f, 0.246615291f},
std::array<float,2>{0.160164908f, 0.17558299f},
std::array<float,2>{0.783484101f, 0.716903269f},
std::array<float,2>{0.353647768f, 0.92200911f},
std::array<float,2>{0.615638256f, 0.487313539f},
std::array<float,2>{0.471800447f, 0.347556382f},
std::array<float,2>{0.728432953f, 0.872204959f},
std::array<float,2>{0.0973003358f, 0.608575106f},
std::array<float,2>{0.977849662f, 0.0416006818f},
std::array<float,2>{0.267973095f, 0.108759955f},
std::array<float,2>{0.50998807f, 0.529084682f},
std::array<float,2>{0.230837986f, 0.780954599f},
std::array<float,2>{0.817123175f, 0.268469751f},
std::array<float,2>{0.0345746055f, 0.415628701f},
std::array<float,2>{0.913694501f, 0.98742944f},
std::array<float,2>{0.424885213f, 0.635021389f},
std::array<float,2>{0.661686659f, 0.19138509f},
std::array<float,2>{0.0798818842f, 0.0212026276f},
std::array<float,2>{0.941699982f, 0.578669548f},
std::array<float,2>{0.444194347f, 0.841370463f},
std::array<float,2>{0.711944044f, 0.335033506f},
std::array<float,2>{0.341355652f, 0.460883886f},
std::array<float,2>{0.56779629f, 0.888561904f},
std::array<float,2>{0.151799887f, 0.734089673f},
std::array<float,2>{0.776288211f, 0.148920298f},
std::array<float,2>{0.394355506f, 0.234478086f},
std::array<float,2>{0.647803783f, 0.666307449f},
std::array<float,2>{0.0132909706f, 0.94519043f},
std::array<float,2>{0.882067502f, 0.396940768f},
std::array<float,2>{0.187758669f, 0.288752288f},
std::array<float,2>{0.863810062f, 0.798857033f},
std::array<float,2>{0.295605481f, 0.531604111f},
std::array<float,2>{0.555292726f, 0.0754647106f},
std::array<float,2>{0.247649163f, 0.0906716958f},
std::array<float,2>{0.83929199f, 0.555670142f},
std::array<float,2>{0.257448882f, 0.791329861f},
std::array<float,2>{0.520791352f, 0.304330081f},
std::array<float,2>{0.421429843f, 0.380103946f},
std::array<float,2>{0.681852937f, 0.958613515f},
std::array<float,2>{0.0563110262f, 0.679319382f},
std::array<float,2>{0.921991289f, 0.218791723f},
std::array<float,2>{0.361362368f, 0.133730292f},
std::array<float,2>{0.59655863f, 0.748736322f},
std::array<float,2>{0.177675992f, 0.905848265f},
std::array<float,2>{0.807375908f, 0.443947613f},
std::array<float,2>{0.112812176f, 0.322062731f},
std::array<float,2>{0.995559871f, 0.822547913f},
std::array<float,2>{0.497552544f, 0.57231909f},
std::array<float,2>{0.744709194f, 0.00963771809f},
std::array<float,2>{0.0289561115f, 0.208859786f},
std::array<float,2>{0.894656956f, 0.643504918f},
std::array<float,2>{0.379649401f, 0.968775451f},
std::array<float,2>{0.634857118f, 0.431690156f},
std::array<float,2>{0.29979068f, 0.256342322f},
std::array<float,2>{0.54281199f, 0.758825839f},
std::array<float,2>{0.209809512f, 0.502516747f},
std::array<float,2>{0.845993638f, 0.109772041f},
std::array<float,2>{0.459567845f, 0.0514765792f},
std::array<float,2>{0.699970126f, 0.611457348f},
std::array<float,2>{0.0706087947f, 0.85755825f},
std::array<float,2>{0.960726917f, 0.37094304f},
std::array<float,2>{0.137834862f, 0.476169676f},
std::array<float,2>{0.764841914f, 0.909438133f},
std::array<float,2>{0.320615739f, 0.691867411f},
std::array<float,2>{0.580167532f, 0.164442912f},
std::array<float,2>{0.24262844f, 0.185678333f},
std::array<float,2>{0.841899633f, 0.708268344f},
std::array<float,2>{0.252600253f, 0.931150734f},
std::array<float,2>{0.51667273f, 0.498028368f},
std::array<float,2>{0.416997313f, 0.352909297f},
std::array<float,2>{0.686932802f, 0.862149f},
std::array<float,2>{0.0592985563f, 0.59836489f},
std::array<float,2>{0.929638565f, 0.0339718014f},
std::array<float,2>{0.363399237f, 0.0939982682f},
std::array<float,2>{0.598329782f, 0.51663512f},
std::array<float,2>{0.172849044f, 0.766569138f},
std::array<float,2>{0.811892867f, 0.279163361f},
std::array<float,2>{0.114760496f, 0.407501161f},
std::array<float,2>{0.99773562f, 0.999098122f},
std::array<float,2>{0.494688302f, 0.629451275f},
std::array<float,2>{0.746635199f, 0.197229519f},
std::array<float,2>{0.0245515443f, 0.0252164286f},
std::array<float,2>{0.891606987f, 0.589369416f},
std::array<float,2>{0.377721578f, 0.832891285f},
std::array<float,2>{0.636774004f, 0.342840731f},
std::array<float,2>{0.304640591f, 0.465198427f},
std::array<float,2>{0.543303609f, 0.879152f},
std::array<float,2>{0.206613794f, 0.726323366f},
std::array<float,2>{0.848436952f, 0.145798966f},
std::array<float,2>{0.453927547f, 0.244915739f},
std::array<float,2>{0.698758245f, 0.662234664f},
std::array<float,2>{0.0770564675f, 0.945710123f},
std::array<float,2>{0.954950333f, 0.401991516f},
std::array<float,2>{0.135327756f, 0.290496469f},
std::array<float,2>{0.759827316f, 0.807908297f},
std::array<float,2>{0.327801287f, 0.539259732f},
std::array<float,2>{0.582402706f, 0.0683954954f},
std::array<float,2>{0.158623159f, 0.0836050659f},
std::array<float,2>{0.786346674f, 0.550381124f},
std::array<float,2>{0.359067708f, 0.786686003f},
std::array<float,2>{0.609765828f, 0.310670733f},
std::array<float,2>{0.476050496f, 0.388103187f},
std::array<float,2>{0.732532501f, 0.962241292f},
std::array<float,2>{0.0987277254f, 0.683996141f},
std::array<float,2>{0.980793655f, 0.226647899f},
std::array<float,2>{0.270418853f, 0.131576285f},
std::array<float,2>{0.511999071f, 0.739693701f},
std::array<float,2>{0.229233056f, 0.898355305f},
std::array<float,2>{0.814376891f, 0.452613175f},
std::array<float,2>{0.0353514701f, 0.313468844f},
std::array<float,2>{0.907313645f, 0.815901339f},
std::array<float,2>{0.427120715f, 0.564001501f},
std::array<float,2>{0.658293366f, 0.000111475725f},
std::array<float,2>{0.084809415f, 0.218022704f},
std::array<float,2>{0.93825227f, 0.651682258f},
std::array<float,2>{0.441176176f, 0.981224239f},
std::array<float,2>{0.716151357f, 0.425102502f},
std::array<float,2>{0.337535292f, 0.261231482f},
std::array<float,2>{0.564121246f, 0.7548967f},
std::array<float,2>{0.152353659f, 0.512249827f},
std::array<float,2>{0.780734837f, 0.122559406f},
std::array<float,2>{0.396501273f, 0.0622874945f},
std::array<float,2>{0.642570555f, 0.621421158f},
std::array<float,2>{0.0105436509f, 0.848459959f},
std::array<float,2>{0.876459062f, 0.365682781f},
std::array<float,2>{0.195105061f, 0.481982827f},
std::array<float,2>{0.862697184f, 0.915839434f},
std::array<float,2>{0.292597532f, 0.701536417f},
std::array<float,2>{0.558623612f, 0.159086466f},
std::array<float,2>{0.146902099f, 0.223914877f},
std::array<float,2>{0.7722767f, 0.672660172f},
std::array<float,2>{0.332979769f, 0.955958128f},
std::array<float,2>{0.575053751f, 0.376596272f},
std::array<float,2>{0.450388879f, 0.298049331f},
std::array<float,2>{0.70654422f, 0.796384752f},
std::array<float,2>{0.0905724242f, 0.562006474f},
std::array<float,2>{0.952762663f, 0.0896930397f},
std::array<float,2>{0.287362427f, 0.0145233097f},
std::array<float,2>{0.553521931f, 0.575745285f},
std::array<float,2>{0.198766351f, 0.827460229f},
std::array<float,2>{0.86866796f, 0.326390564f},
std::array<float,2>{0.00102554355f, 0.43904683f},
std::array<float,2>{0.884282053f, 0.900657713f},
std::array<float,2>{0.405909002f, 0.74603492f},
std::array<float,2>{0.654475152f, 0.139280722f},
std::array<float,2>{0.108417854f, 0.1164895f},
std::array<float,2>{0.971172512f, 0.507014096f},
std::array<float,2>{0.483221471f, 0.763527572f},
std::array<float,2>{0.720238328f, 0.251555413f},
std::array<float,2>{0.3456918f, 0.434036732f},
std::array<float,2>{0.623634338f, 0.976200461f},
std::array<float,2>{0.166487679f, 0.647864878f},
std::array<float,2>{0.792414784f, 0.205014959f},
std::array<float,2>{0.433934927f, 0.168491304f},
std::array<float,2>{0.665976882f, 0.690953791f},
std::array<float,2>{0.0415275693f, 0.913121641f},
std::array<float,2>{0.919027865f, 0.470518082f},
std::array<float,2>{0.224259347f, 0.373181075f},
std::array<float,2>{0.827457309f, 0.852092743f},
std::array<float,2>{0.280910522f, 0.616430342f},
std::array<float,2>{0.507664323f, 0.0479865931f},
std::array<float,2>{0.212542847f, 0.0459382832f},
std::array<float,2>{0.859127045f, 0.602734387f},
std::array<float,2>{0.305767804f, 0.867206335f},
std::array<float,2>{0.531889379f, 0.347991496f},
std::array<float,2>{0.388664991f, 0.491647631f},
std::array<float,2>{0.628491998f, 0.926648736f},
std::array<float,2>{0.0231179371f, 0.714176118f},
std::array<float,2>{0.899259269f, 0.178778395f},
std::array<float,2>{0.31541276f, 0.192235559f},
std::array<float,2>{0.590883613f, 0.636744916f},
std::array<float,2>{0.130792126f, 0.991272628f},
std::array<float,2>{0.756651103f, 0.420146406f},
std::array<float,2>{0.0645311922f, 0.270845681f},
std::array<float,2>{0.964849114f, 0.775412321f},
std::array<float,2>{0.467042714f, 0.52351433f},
std::array<float,2>{0.688384831f, 0.10493347f},
std::array<float,2>{0.0524549782f, 0.152970508f},
std::array<float,2>{0.934269369f, 0.726855636f},
std::array<float,2>{0.410334527f, 0.884436548f},
std::array<float,2>{0.672638774f, 0.455623239f},
std::array<float,2>{0.259849638f, 0.331311554f},
std::array<float,2>{0.529346824f, 0.837108195f},
std::array<float,2>{0.241555408f, 0.585223079f},
std::array<float,2>{0.832175732f, 0.0182269569f},
std::array<float,2>{0.488230497f, 0.0732389987f},
std::array<float,2>{0.737847805f, 0.5355286f},
std::array<float,2>{0.117970034f, 0.80111587f},
std::array<float,2>{0.986543894f, 0.284800559f},
std::array<float,2>{0.184601992f, 0.393991768f},
std::array<float,2>{0.802521229f, 0.940177977f},
std::array<float,2>{0.367765993f, 0.668936908f},
std::array<float,2>{0.601954997f, 0.240944311f},
std::array<float,2>{0.200252131f, 0.202941954f},
std::array<float,2>{0.873889685f, 0.62635237f},
std::array<float,2>{0.282220721f, 0.994672835f},
std::array<float,2>{0.550643265f, 0.411900908f},
std::array<float,2>{0.398518354f, 0.274786264f},
std::array<float,2>{0.651232064f, 0.772306323f},
std::array<float,2>{0.00716400612f, 0.522371411f},
std::array<float,2>{0.887824535f, 0.0994922742f},
std::array<float,2>{0.328394204f, 0.0389093645f},
std::array<float,2>{0.571585119f, 0.596936941f},
std::array<float,2>{0.142042786f, 0.866588593f},
std::array<float,2>{0.767073274f, 0.357911825f},
std::array<float,2>{0.0867401138f, 0.495951682f},
std::array<float,2>{0.948613346f, 0.935400903f},
std::array<float,2>{0.447819322f, 0.705687821f},
std::array<float,2>{0.710081995f, 0.180690765f},
std::array<float,2>{0.0453609526f, 0.0654382333f},
std::array<float,2>{0.914419949f, 0.544126689f},
std::array<float,2>{0.43101418f, 0.810953557f},
std::array<float,2>{0.669213772f, 0.296645135f},
std::array<float,2>{0.273685604f, 0.403301299f},
std::array<float,2>{0.503000677f, 0.95197612f},
std::array<float,2>{0.221300483f, 0.659001291f},
std::array<float,2>{0.823857427f, 0.248414189f},
std::array<float,2>{0.478244156f, 0.142905474f},
std::array<float,2>{0.724089265f, 0.722516239f},
std::array<float,2>{0.101939619f, 0.877653956f},
std::array<float,2>{0.975854158f, 0.461099952f},
std::array<float,2>{0.168214396f, 0.339155763f},
std::array<float,2>{0.795854747f, 0.828439713f},
std::array<float,2>{0.351025283f, 0.590306699f},
std::array<float,2>{0.619279444f, 0.0282058362f},
std::array<float,2>{0.128197864f, 0.00481011067f},
std::array<float,2>{0.750500441f, 0.568945408f},
std::array<float,2>{0.319172591f, 0.81704247f},
std::array<float,2>{0.588579714f, 0.316827238f},
std::array<float,2>{0.461137682f, 0.446255594f},
std::array<float,2>{0.693197668f, 0.89162457f},
std::array<float,2>{0.0687797293f, 0.735143423f},
std::array<float,2>{0.962272465f, 0.126220837f},
std::array<float,2>{0.311894715f, 0.231393635f},
std::array<float,2>{0.536681175f, 0.680357277f},
std::array<float,2>{0.218261972f, 0.968715131f},
std::array<float,2>{0.855381668f, 0.386259049f},
std::array<float,2>{0.0194264911f, 0.30854556f},
std::array<float,2>{0.903847814f, 0.782486856f},
std::array<float,2>{0.38594234f, 0.551831365f},
std::array<float,2>{0.629571855f, 0.0811589062f},
std::array<float,2>{0.121839978f, 0.163255066f},
std::array<float,2>{0.990267754f, 0.695334494f},
std::array<float,2>{0.491679877f, 0.92004621f},
std::array<float,2>{0.741450846f, 0.47975564f},
std::array<float,2>{0.374958724f, 0.361032635f},
std::array<float,2>{0.606707156f, 0.847101986f},
std::array<float,2>{0.181286559f, 0.618023455f},
std::array<float,2>{0.799413741f, 0.0556722507f},
std::array<float,2>{0.408918351f, 0.117720246f},
std::array<float,2>{0.676699519f, 0.510021687f},
std::array<float,2>{0.0491791926f, 0.753386021f},
std::array<float,2>{0.933105707f, 0.264473945f},
std::array<float,2>{0.237440884f, 0.428551167f},
std::array<float,2>{0.83168596f, 0.97698313f},
std::array<float,2>{0.263812006f, 0.65511328f},
std::array<float,2>{0.526686013f, 0.214166924f},
std::array<float,2>{0.175852925f, 0.134783119f},
std::array<float,2>{0.808171332f, 0.747019172f},
std::array<float,2>{0.363146722f, 0.904122114f},
std::array<float,2>{0.596927762f, 0.442529142f},
std::array<float,2>{0.497045249f, 0.323567271f},
std::array<float,2>{0.745947421f, 0.821918309f},
std::array<float,2>{0.111761376f, 0.572048068f},
std::array<float,2>{0.994475722f, 0.0113020483f},
std::array<float,2>{0.255905241f, 0.093721211f},
std::array<float,2>{0.519970655f, 0.558426082f},
std::array<float,2>{0.246367931f, 0.789646983f},
std::array<float,2>{0.838441074f, 0.301810801f},
std::array<float,2>{0.0553479493f, 0.38115719f},
std::array<float,2>{0.922934592f, 0.959144115f},
std::array<float,2>{0.42009896f, 0.676411867f},
std::array<float,2>{0.683382988f, 0.221461296f},
std::array<float,2>{0.0714995414f, 0.0530727878f},
std::array<float,2>{0.959812343f, 0.610386968f},
std::array<float,2>{0.460322827f, 0.857031703f},
std::array<float,2>{0.700514913f, 0.367405295f},
std::array<float,2>{0.321914047f, 0.473644018f},
std::array<float,2>{0.581159651f, 0.906801462f},
std::array<float,2>{0.137471795f, 0.694269896f},
std::array<float,2>{0.763936698f, 0.166219264f},
std::array<float,2>{0.380330861f, 0.210220501f},
std::array<float,2>{0.636127174f, 0.641120851f},
std::array<float,2>{0.0277947858f, 0.970911205f},
std::array<float,2>{0.895522654f, 0.430808872f},
std::array<float,2>{0.210012436f, 0.254431516f},
std::array<float,2>{0.846768439f, 0.761576891f},
std::array<float,2>{0.300316155f, 0.500689626f},
std::array<float,2>{0.541274428f, 0.111622341f},
std::array<float,2>{0.231719002f, 0.107103378f},
std::array<float,2>{0.817513466f, 0.530230105f},
std::array<float,2>{0.269237995f, 0.778287232f},
std::array<float,2>{0.510746896f, 0.267206401f},
std::array<float,2>{0.424276888f, 0.416647494f},
std::array<float,2>{0.660479069f, 0.984762847f},
std::array<float,2>{0.0339496396f, 0.6334095f},
std::array<float,2>{0.912269413f, 0.187952861f},
std::array<float,2>{0.355403215f, 0.172135904f},
std::array<float,2>{0.616262078f, 0.716307044f},
std::array<float,2>{0.161526084f, 0.925374568f},
std::array<float,2>{0.784834504f, 0.485872716f},
std::array<float,2>{0.0964824781f, 0.344628036f},
std::array<float,2>{0.977238774f, 0.87397635f},
std::array<float,2>{0.47074002f, 0.605636835f},
std::array<float,2>{0.727253735f, 0.0402033068f},
std::array<float,2>{0.0123644667f, 0.23767671f},
std::array<float,2>{0.88145262f, 0.665356219f},
std::array<float,2>{0.393289894f, 0.942048728f},
std::array<float,2>{0.647150397f, 0.394736826f},
std::array<float,2>{0.296455771f, 0.287007898f},
std::array<float,2>{0.555841506f, 0.797461629f},
std::array<float,2>{0.188939199f, 0.534649312f},
std::array<float,2>{0.864687324f, 0.0765796751f},
std::array<float,2>{0.445208073f, 0.0234321952f},
std::array<float,2>{0.711833537f, 0.580793917f},
std::array<float,2>{0.0781848729f, 0.842429638f},
std::array<float,2>{0.942515969f, 0.333302945f},
std::array<float,2>{0.15124847f, 0.458414227f},
std::array<float,2>{0.776948631f, 0.889833808f},
std::array<float,2>{0.340585321f, 0.731170356f},
std::array<float,2>{0.566619754f, 0.1510427f},
std::array<float,2>{0.203934357f, 0.146548972f},
std::array<float,2>{0.849738181f, 0.72295934f},
std::array<float,2>{0.301729143f, 0.881023645f},
std::array<float,2>{0.546397746f, 0.467181534f},
std::array<float,2>{0.375264078f, 0.341353178f},
std::array<float,2>{0.638918698f, 0.834218264f},
std::array<float,2>{0.0271674041f, 0.586101949f},
std::array<float,2>{0.893295407f, 0.0262800828f},
std::array<float,2>{0.324478477f, 0.0678695738f},
std::array<float,2>{0.58525306f, 0.541267157f},
std::array<float,2>{0.134092107f, 0.805035651f},
std::array<float,2>{0.758536637f, 0.292917192f},
std::array<float,2>{0.0760608763f, 0.399632066f},
std::array<float,2>{0.956560671f, 0.948223174f},
std::array<float,2>{0.455828309f, 0.661759913f},
std::array<float,2>{0.69642061f, 0.244101509f},
std::array<float,2>{0.0609524883f, 0.0315731391f},
std::array<float,2>{0.926835835f, 0.600489795f},
std::array<float,2>{0.415549397f, 0.860233128f},
std::array<float,2>{0.685268342f, 0.354743987f},
std::array<float,2>{0.251859188f, 0.499102145f},
std::array<float,2>{0.518435597f, 0.933431745f},
std::array<float,2>{0.245115668f, 0.709810257f},
std::array<float,2>{0.841031969f, 0.184405267f},
std::array<float,2>{0.492945939f, 0.198080704f},
std::array<float,2>{0.748540223f, 0.632045865f},
std::array<float,2>{0.115747571f, 0.99796176f},
std::array<float,2>{0.999404013f, 0.409761101f},
std::array<float,2>{0.173847944f, 0.280052364f},
std::array<float,2>{0.808659017f, 0.768339932f},
std::array<float,2>{0.367085338f, 0.517642796f},
std::array<float,2>{0.601536155f, 0.0957421362f},
std::array<float,2>{0.156150743f, 0.123345196f},
std::array<float,2>{0.778976202f, 0.514352143f},
std::array<float,2>{0.338351578f, 0.757481694f},
std::array<float,2>{0.565306664f, 0.258002341f},
std::array<float,2>{0.438508481f, 0.423074037f},
std::array<float,2>{0.718396544f, 0.982597113f},
std::array<float,2>{0.0824973062f, 0.649305701f},
std::array<float,2>{0.940064371f, 0.216383457f},
std::array<float,2>{0.290601611f, 0.15646337f},
std::array<float,2>{0.561328113f, 0.700849771f},
std::array<float,2>{0.191620186f, 0.916096926f},
std::array<float,2>{0.859475851f, 0.483751386f},
std::array<float,2>{0.0078876745f, 0.363891751f},
std::array<float,2>{0.877539039f, 0.850966752f},
std::array<float,2>{0.395627797f, 0.624100506f},
std::array<float,2>{0.64354068f, 0.0595676377f},
std::array<float,2>{0.101239853f, 0.229208082f},
std::array<float,2>{0.984058142f, 0.685572803f},
std::array<float,2>{0.472818404f, 0.96405834f},
std::array<float,2>{0.731670976f, 0.389255166f},
std::array<float,2>{0.355531335f, 0.308605969f},
std::array<float,2>{0.613023579f, 0.788501322f},
std::array<float,2>{0.15818879f, 0.54726404f},
std::array<float,2>{0.78775686f, 0.0857681856f},
std::array<float,2>{0.427870572f, 0.00348065351f},
std::array<float,2>{0.656623483f, 0.565611899f},
std::array<float,2>{0.0380212776f, 0.813153625f},
std::array<float,2>{0.909507632f, 0.315889418f},
std::array<float,2>{0.226727217f, 0.44938916f},
std::array<float,2>{0.814898968f, 0.895096421f},
std::array<float,2>{0.272350758f, 0.742178023f},
std::array<float,2>{0.513744473f, 0.129300311f},
std::array<float,2>{0.165844396f, 0.205572993f},
std::array<float,2>{0.789253533f, 0.645079315f},
std::array<float,2>{0.346529424f, 0.973523974f},
std::array<float,2>{0.622875035f, 0.436964571f},
std::array<float,2>{0.48080641f, 0.253412634f},
std::array<float,2>{0.721797287f, 0.76373297f},
std::array<float,2>{0.10634622f, 0.50432533f},
std::array<float,2>{0.969996333f, 0.115020633f},
std::array<float,2>{0.277982116f, 0.0500994101f},
std::array<float,2>{0.50402236f, 0.6144045f},
std::array<float,2>{0.224762559f, 0.855042517f},
std::array<float,2>{0.82547456f, 0.371510655f},
std::array<float,2>{0.0393215008f, 0.472189099f},
std::array<float,2>{0.92009753f, 0.911023378f},
std::array<float,2>{0.435954243f, 0.68882525f},
std::array<float,2>{0.667538226f, 0.171131343f},
std::array<float,2>{0.0920676962f, 0.087648131f},
std::array<float,2>{0.949398875f, 0.5592677f},
std::array<float,2>{0.452576548f, 0.793642938f},
std::array<float,2>{0.704994023f, 0.299464405f},
std::array<float,2>{0.335566491f, 0.377339602f},
std::array<float,2>{0.577262461f, 0.954844236f},
std::array<float,2>{0.145879388f, 0.674727738f},
std::array<float,2>{0.77007699f, 0.225872204f},
std::array<float,2>{0.403515279f, 0.138475016f},
std::array<float,2>{0.65403831f, 0.74270314f},
std::array<float,2>{0.00279893866f, 0.899977207f},
std::array<float,2>{0.885507524f, 0.440971166f},
std::array<float,2>{0.195786804f, 0.326101422f},
std::array<float,2>{0.870368063f, 0.824644446f},
std::array<float,2>{0.287061751f, 0.577040195f},
std::array<float,2>{0.551442623f, 0.0134429606f},
std::array<float,2>{0.238576263f, 0.016012283f},
std::array<float,2>{0.83471024f, 0.582854152f},
std::array<float,2>{0.259096175f, 0.839379489f},
std::array<float,2>{0.52762264f, 0.32870692f},
std::array<float,2>{0.413812459f, 0.454953671f},
std::array<float,2>{0.675602496f, 0.885477126f},
std::array<float,2>{0.0528249741f, 0.730335772f},
std::array<float,2>{0.937425435f, 0.155165806f},
std::array<float,2>{0.369816452f, 0.239345968f},
std::array<float,2>{0.604426265f, 0.670624137f},
std::array<float,2>{0.186235189f, 0.938352704f},
std::array<float,2>{0.802911997f, 0.391197562f},
std::array<float,2>{0.119910739f, 0.282127291f},
std::array<float,2>{0.984739304f, 0.804531634f},
std::array<float,2>{0.486064583f, 0.539043903f},
std::array<float,2>{0.735008717f, 0.072003305f},
std::array<float,2>{0.0204348881f, 0.177305967f},
std::array<float,2>{0.901009321f, 0.712371826f},
std::array<float,2>{0.389556438f, 0.927890599f},
std::array<float,2>{0.625511944f, 0.488579482f},
std::array<float,2>{0.308318615f, 0.350799531f},
std::array<float,2>{0.534952343f, 0.869861782f},
std::array<float,2>{0.212938935f, 0.604327321f},
std::array<float,2>{0.856214106f, 0.0435336679f},
std::array<float,2>{0.465727329f, 0.102564156f},
std::array<float,2>{0.690418005f, 0.526465952f},
std::array<float,2>{0.0632182211f, 0.774174452f},
std::array<float,2>{0.968410611f, 0.273298115f},
std::array<float,2>{0.132028461f, 0.418902248f},
std::array<float,2>{0.754831254f, 0.988872588f},
std::array<float,2>{0.3144252f, 0.63975364f},
std::array<float,2>{0.592310905f, 0.193906933f},
std::array<float,2>{0.219351619f, 0.247468755f},
std::array<float,2>{0.821119487f, 0.656542242f},
std::array<float,2>{0.276916116f, 0.950609744f},
std::array<float,2>{0.500640988f, 0.406126291f},
std::array<float,2>{0.432883978f, 0.294311136f},
std::array<float,2>{0.670928121f, 0.808666289f},
std::array<float,2>{0.044202432f, 0.545645773f},
std::array<float,2>{0.917808652f, 0.0634072796f},
std::array<float,2>{0.349205017f, 0.0302421898f},
std::array<float,2>{0.618244231f, 0.59253788f},
std::array<float,2>{0.171053499f, 0.831352055f},
std::array<float,2>{0.793780565f, 0.336511016f},
std::array<float,2>{0.105249584f, 0.464298576f},
std::array<float,2>{0.973614633f, 0.87687695f},
std::array<float,2>{0.48039785f, 0.719392955f},
std::array<float,2>{0.725384712f, 0.140646785f},
std::array<float,2>{0.0040859906f, 0.100526005f},
std::array<float,2>{0.890508056f, 0.519826889f},
std::array<float,2>{0.401462585f, 0.771276414f},
std::array<float,2>{0.649977207f, 0.276484281f},
std::array<float,2>{0.284004033f, 0.413155973f},
std::array<float,2>{0.5472188f, 0.994100273f},
std::array<float,2>{0.202261761f, 0.627860367f},
std::array<float,2>{0.871103644f, 0.201169267f},
std::array<float,2>{0.446218371f, 0.182562709f},
std::array<float,2>{0.708147585f, 0.704508245f},
std::array<float,2>{0.0883485749f, 0.936624587f},
std::array<float,2>{0.946487904f, 0.492901146f},
std::array<float,2>{0.142925054f, 0.357041776f},
std::array<float,2>{0.768900692f, 0.864409268f},
std::array<float,2>{0.331510633f, 0.593806803f},
std::array<float,2>{0.572373688f, 0.0366565734f},
std::array<float,2>{0.183465064f, 0.0574867874f},
std::array<float,2>{0.797046721f, 0.619188428f},
std::array<float,2>{0.372913748f, 0.843764484f},
std::array<float,2>{0.607478559f, 0.362012476f},
std::array<float,2>{0.489498228f, 0.478101134f},
std::array<float,2>{0.739874721f, 0.918664396f},
std::array<float,2>{0.124513015f, 0.699139535f},
std::array<float,2>{0.988733351f, 0.161792412f},
std::array<float,2>{0.261919111f, 0.211806789f},
std::array<float,2>{0.525187492f, 0.653326929f},
std::array<float,2>{0.236141741f, 0.979315937f},
std::array<float,2>{0.829696715f, 0.426269203f},
std::array<float,2>{0.0486769825f, 0.26202175f},
std::array<float,2>{0.931353033f, 0.751137495f},
std::array<float,2>{0.406859994f, 0.509558082f},
std::array<float,2>{0.679114699f, 0.120521396f},
std::array<float,2>{0.0670474172f, 0.127161995f},
std::array<float,2>{0.964382589f, 0.738132358f},
std::array<float,2>{0.46433574f, 0.893880486f},
std::array<float,2>{0.693999648f, 0.448420793f},
std::array<float,2>{0.317314804f, 0.32021293f},
std::array<float,2>{0.587430775f, 0.820128798f},
std::array<float,2>{0.125688434f, 0.56813395f},
std::array<float,2>{0.753726423f, 0.00646316539f},
std::array<float,2>{0.383146018f, 0.0788449422f},
std::array<float,2>{0.631835282f, 0.554025531f},
std::array<float,2>{0.0165382251f, 0.783698678f},
std::array<float,2>{0.905245543f, 0.306549251f},
std::array<float,2>{0.214875132f, 0.384073824f},
std::array<float,2>{0.851938128f, 0.966435671f},
std::array<float,2>{0.309445977f, 0.682619512f},
std::array<float,2>{0.538460195f, 0.234004989f},
std::array<float,2>{0.139580011f, 0.165669084f},
std::array<float,2>{0.762609899f, 0.692533433f},
std::array<float,2>{0.322434336f, 0.909121454f},
std::array<float,2>{0.579597235f, 0.475379258f},
std::array<float,2>{0.45770967f, 0.369212031f},
std::array<float,2>{0.702004433f, 0.858649909f},
std::array<float,2>{0.0740313157f, 0.61323911f},
std::array<float,2>{0.958240807f, 0.0526440777f},
std::array<float,2>{0.297473192f, 0.110357478f},
std::array<float,2>{0.539326429f, 0.503220856f},
std::array<float,2>{0.208296955f, 0.758621097f},
std::array<float,2>{0.844473362f, 0.257560581f},
std::array<float,2>{0.0298406519f, 0.43348518f},
std::array<float,2>{0.897809446f, 0.969997585f},
std::array<float,2>{0.382240683f, 0.643712342f},
std::array<float,2>{0.633293033f, 0.207797632f},
std::array<float,2>{0.109743543f, 0.00823405106f},
std::array<float,2>{0.992775381f, 0.573440015f},
std::array<float,2>{0.498183608f, 0.823260188f},
std::array<float,2>{0.742915928f, 0.320360929f},
std::array<float,2>{0.359470606f, 0.445238173f},
std::array<float,2>{0.594658196f, 0.905245721f},
std::array<float,2>{0.178257227f, 0.74943763f},
std::array<float,2>{0.804898083f, 0.134594575f},
std::array<float,2>{0.418225557f, 0.220698163f},
std::array<float,2>{0.681169391f, 0.678070247f},
std::array<float,2>{0.0569814406f, 0.957179248f},
std::array<float,2>{0.923874438f, 0.379256636f},
std::array<float,2>{0.249208227f, 0.303385288f},
std::array<float,2>{0.836051404f, 0.792936981f},
std::array<float,2>{0.255125701f, 0.555183172f},
std::array<float,2>{0.52293545f, 0.0911439955f},
std::array<float,2>{0.191354796f, 0.0745357797f},
std::array<float,2>{0.866359174f, 0.532355189f},
std::array<float,2>{0.294895619f, 0.800006807f},
std::array<float,2>{0.558424056f, 0.287501931f},
std::array<float,2>{0.390948564f, 0.397478312f},
std::array<float,2>{0.645642638f, 0.944202423f},
std::array<float,2>{0.0150750289f, 0.667163074f},
std::array<float,2>{0.879277587f, 0.235848695f},
std::array<float,2>{0.342358232f, 0.149825737f},
std::array<float,2>{0.569651902f, 0.732997358f},
std::array<float,2>{0.149622306f, 0.887262583f},
std::array<float,2>{0.773977041f, 0.459776044f},
std::array<float,2>{0.0813172162f, 0.33465606f},
std::array<float,2>{0.944356203f, 0.84070164f},
std::array<float,2>{0.443166763f, 0.579651415f},
std::array<float,2>{0.714239538f, 0.0199130494f},
std::array<float,2>{0.0312684886f, 0.189821228f},
std::array<float,2>{0.911678016f, 0.636530697f},
std::array<float,2>{0.422362685f, 0.987132311f},
std::array<float,2>{0.663284063f, 0.414216787f},
std::array<float,2>{0.265793741f, 0.269465685f},
std::array<float,2>{0.508445919f, 0.780237496f},
std::array<float,2>{0.233060256f, 0.527656496f},
std::array<float,2>{0.818894088f, 0.107833534f},
std::array<float,2>{0.470462739f, 0.0426609926f},
std::array<float,2>{0.730237901f, 0.608234406f},
std::array<float,2>{0.095287703f, 0.871200442f},
std::array<float,2>{0.980123639f, 0.345776945f},
std::array<float,2>{0.163201436f, 0.487128198f},
std::array<float,2>{0.781928241f, 0.923212945f},
std::array<float,2>{0.351726711f, 0.71833235f},
std::array<float,2>{0.615070879f, 0.174657181f}} | 48.982666 | 52 | 0.7346 | st-ario |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.